New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

multiple-select-vanilla

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiple-select-vanilla - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

26

dist/cjs/multiple-select.js

@@ -1,26 +0,2 @@

"use strict";var T=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var q=(o,t,e)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var U=(o,t)=>{for(var e in t)T(o,e,{get:t[e],enumerable:!0})},K=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of G(t))!z.call(o,i)&&i!==e&&T(o,i,{get:()=>t[i],enumerable:!(s=P(t,i))||s.enumerable});return o};var V=o=>K(T({},"__esModule",{value:!0}),o);var a=(o,t,e)=>(q(o,typeof t!="symbol"?t+"":t,e),e);var tt={};U(tt,{BindingEventService:()=>A,MultipleSelectInstance:()=>L,VirtualScroll:()=>y,calculateAvailableSpace:()=>v,compareObjects:()=>k,createDomElement:()=>d,deepCopy:()=>C,findByParam:()=>g,findParent:()=>H,getElementOffset:()=>S,getElementSize:()=>b,htmlEncode:()=>x,insertAfter:()=>M,multipleSelect:()=>F,removeDiacritics:()=>m,removeUndefined:()=>D,setDataKeys:()=>w,stripScripts:()=>_,toggleElement:()=>B,toggleElementClass:()=>Q,windowScrollPosition:()=>N});module.exports=V(tt);var A=class{constructor(t){a(this,"_distinctEvent");a(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,i){let l=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let u of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,u))&&(n.addEventListener(u,s,i),this._boundedEvents.push({element:n,eventName:u,listener:s}))});else for(let n of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,i),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let i=Array.isArray(t)?t:[t],l=Array.isArray(e)?e||"":[e||""];for(let n of i){s||(s=this._boundedEvents.find(u=>{if(u.element===n&&(!e||u.eventName===e))return u.listener}));for(let u of l)n?.removeEventListener?.(u,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:i}=t;this.unbind(e,s,i)}}};var $=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};$.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var O=$.locales;var Y=50,J=4,I={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},X=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(I,O["en-US"]);var Z={BLOCK_ROWS:Y,CLUSTER_BLOCKS:J,DEFAULTS:I,METHODS:X},p=Z;var y=class{constructor(t){a(this,"cache");a(this,"clusterRows");a(this,"dataStart");a(this,"dataEnd");a(this,"rows");a(this,"scrollEl");a(this,"blockHeight");a(this,"clusterHeight");a(this,"contentEl");a(this,"parentEl");a(this,"itemHeight");a(this,"lastCluster");a(this,"scrollTop");a(this,"destroy");a(this,"callback");a(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl?.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{this.contentEl.innerHTML="",this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let c=t[0]+t[0]+t[0];this.contentEl.innerHTML=this.sanitizer?this.sanitizer(`${c}`):`${c}`,this.cache.data=c,this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=e.rows.join(""),i=this.checkChanges("data",s),l=this.checkChanges("top",e.topOffset),n=this.checkChanges("bottom",e.bottomOffset),u=[];i&&l?(e.topOffset&&u.push(this.getExtra("top",e.topOffset)),u.push(s),e.bottomOffset&&u.push(this.getExtra("bottom",e.bottomOffset)),this.contentEl.innerHTML=this.sanitizer?this.sanitizer(u.join("")):u.join("")):n&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*p.BLOCK_ROWS,this.clusterRows=p.BLOCK_ROWS*p.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*p.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<p.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-p.BLOCK_ROWS)*e,0),i=s+this.clusterRows,l=Math.max(s*this.itemHeight,0),n=Math.max((t.length-i)*this.itemHeight,0),u=[],c=s;l<1&&c++;for(let r=s;r<i;r++)t[r]&&u.push(t[r]);return this.dataStart=s,this.dataEnd=i,{topOffset:l,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s.outerHTML}};function v(o){let t=0,e=0,s=0,i=0,l=window.innerHeight??0,n=window.innerWidth??0,u=N(),c=u.top,r=u.left,h=S(o);if(h){let E=h.top??0,f=h.left??0;e=E-c,t=l-(E-c),s=f-r,i=n-(f-r)}return{top:e,bottom:t,left:s,right:i}}function d(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(i=>{let l=t[i];typeof l=="object"?Object.assign(s[i],l):s[i]=t[i]}),e&&e.appendChild&&e.appendChild(s),s}function S(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,i=0,l=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,l=t.right,i=t.bottom),{top:e,left:s,bottom:i,right:l}}function b(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let i=o.style.display,l=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=i,o.style.position=l}return s||0}function H(o,t){let e=null,s=o?.parentElement;for(;s;){let[i,l,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))s.classList.contains(c)&&(l?s?.tagName.toLowerCase()===l&&(e=s):e=s);s=s.parentElement}return e}function M(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function x(o){let t=typeof o=="string"?o:String(o),e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return(t||"").toString().replace(/[&<>"']/g,s=>e[s])}function B(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function Q(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function N(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}function k(o,t,e=!1){let s=Object.keys(o),i=Object.keys(t);if(e&&s.length!==i.length)return!1;for(let l of s)if(i.includes(l)&&o[l]!==t[l])return!1;return!0}function C(o){let t=()=>{let i={};for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&(i[l]=C(o[l]));return i},e=()=>o.map(i=>C(i)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function w(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((i,l)=>{i&&(i.visible=typeof i?.visible>"u"?!0:i.visible,i.divider||(i._key=`option_${s}_${l}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function g(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let i of s.children)if(i&&(i[t]===e||i[t]===`${+i[t]}`&&+i[t]===e))return i}}}function _(o){let t=document.createElement("div");t.innerHTML=o;let e=t.getElementsByTagName("script"),s=e.length;for(;s--;)e[s].parentNode?.removeChild(e[s]);return t.innerHTML}function D(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function m(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:i})=>e.replace(s,i),o)}var L=class{constructor(t,e){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"ulElm");a(this,"parentElm");a(this,"labelElm");a(this,"selectAllParentElm");a(this,"selectAllElm");a(this,"searchInputElm");a(this,"selectGroupElms");a(this,"selectItemElms");a(this,"disableItemElms");a(this,"noResultsElm");a(this,"options");a(this,"selectAllName","");a(this,"selectGroupName","");a(this,"selectItemName","");a(this,"tabIndex");a(this,"updateDataStart");a(this,"updateDataEnd");a(this,"virtualScroll");a(this,"locales",{});this.options=Object.assign({},p.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=d("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=d("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(d("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(d("div",{className:"icon-close"})),this.choiceElm.appendChild(d("div",{className:"icon-caret"})),this.dropElm=d("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let i=this.elm.getAttribute("data-test")||this.options.dataTest;i&&(this.parentElm.dataset.test=i,this.dropElm.dataset.test=i),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),M(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`data-name="selectAll${t}"`,this.selectGroupName=`data-name="selectGroup${t}"`,this.selectItemName=`data-name="selectItem${t}"`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",l=>{l.target===this.choiceElm||H(l.target,".ms-choice")===this.choiceElm||(l.target===this.dropElm||H(l.target,".ms-drop")!==this.dropElm&&l.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{this.initRow(e)&&t.push(this.initRow(e))}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=w(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(i=>{s.children.push(this.initRow(i,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=d("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(d("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=d("div",{className:"ms-select-all"});let e=document.createElement("label");d("input",{type:"checkbox",checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(d("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=d("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=this.getListRows(),e=0;if(this.options.selectAll&&!this.options.single&&(e=-1),t.length>p.BLOCK_ROWS*p.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let i=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+e,this.updateDataEnd=this.virtualScroll.dataEnd+e,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>(this.data?.length??0)&&(this.updateDataEnd=this.data?.length??0))};this.ulElm&&(this.virtualScroll=new y({rows:t,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{i(),this.events()}})),i(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(this.ulElm.innerHTML=this.options.sanitizer?this.options.sanitizer(t.join("")):t.join("")),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;this.events()}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>{t.push(...this.initListItem(e))}),t.push(`<li class="ms-no-results">${this.formatNoMatchesFound()}</li>`),t}initListItem(t,e=0){let s=this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml,i=t?.title?`title="${t.title}"`:"",l=this.options.multiple?"multiple":"",n=this.options.single?"radio":"checkbox",u="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(u="hide-radio "),t.selected&&(u+="selected "),t.type==="optgroup"){let h=this.options.styler(t),E=h?`style="${h}"`:"",f=[],j=this.options.hideOptgroupCheckboxes||this.options.single?`<span ${this.selectGroupName} data-key="${t._key}"></span>`:`<input type="checkbox"
${this.selectGroupName}
data-key="${t._key}"
${t.selected?' checked="checked"':""}
${t.disabled?' disabled="disabled"':""}
>`;return!u.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(u+="hide-radio "),f.push(`
<li class="${`group ${u}`.trim()}" ${E}>
<label class="optgroup${this.options.single||t.disabled?" disabled":""}">
${j}${s?t.label:x(t.label)}
</label>
</li>
`),t.children.forEach(W=>{f.push(...this.initListItem(W,1))}),f}let c=this.options.styler(t),r=c?`style="${c}"`:"";return u+=t.classes||"",e&&this.options.single&&(u+=`option-level-${e} `),t.divider?'<li class="option-divider"/>':[`
<li ${l||u?`class="${(l+u).trim()}"`:""} ${i} ${r}>
<label ${t.disabled?'class="disabled"':""}>
<input type="${n}"
value="${encodeURI(t.value)}"
data-key="${t._key}"
${this.selectItemName}
${t.selected?' checked="checked"':""}
${t.disabled?' disabled="disabled"':""}
>
<span>${s?t.text:x(t.text)}</span>
</label>
</li>
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(D({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return D({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key),n=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(l)===!1){n();return}this._check(l,i),this.options.onClick(D({text:l.text,value:l.value,selected:l.selected,data:l._data})),n()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=S(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=v(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?_(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(h=>h===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,B(this.selectAllElm.closest("li"),!t)),B(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?C(e):this.options}refreshOptions(t){k(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:m(l.toLowerCase()),search:m(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:m(n.toLowerCase()),search:m(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(l.toLowerCase()),search:m(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(e)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=v(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=v(this.dropElm),{top:l,left:n}=S(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let E=l-u;E<0&&(E=0),(E>0||t)&&(e="top",this.dropElm.style.top=`${E<0?0:E}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let E=n-(c-h);this.dropElm.style.left=`${E}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var F=function(o,t){return typeof o=="string"?R(document.querySelectorAll(o),t):o instanceof Node?R([o],t):R(o,t)};function R(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new L(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}F.defaults=p.DEFAULTS;F.locales={...O};F.methods=p.METHODS;typeof window<"u"&&(window.multipleSelect=F);
"use strict";var T=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var st=Object.prototype.hasOwnProperty;var it=(o,t,e)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var lt=(o,t)=>{for(var e in t)T(o,e,{get:t[e],enumerable:!0})},ot=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of et(t))!st.call(o,l)&&l!==e&&T(o,l,{get:()=>t[l],enumerable:!(s=tt(t,l))||s.enumerable});return o};var nt=o=>ot(T({},"__esModule",{value:!0}),o);var u=(o,t,e)=>(it(o,typeof t!="symbol"?t+"":t,e),e);var ht={};lt(ht,{BindingEventService:()=>A,MultipleSelectInstance:()=>H,VirtualScroll:()=>F,calculateAvailableSpace:()=>D,compareObjects:()=>R,convertItemRowToHtml:()=>b,convertStringStyleToElementStyle:()=>B,createDomElement:()=>h,createDomStructure:()=>$,deepCopy:()=>v,emptyElement:()=>g,findByParam:()=>f,findParent:()=>k,getElementOffset:()=>L,getElementSize:()=>y,insertAfter:()=>j,isDefined:()=>J,multipleSelect:()=>O,objectRemoveEmptyProps:()=>N,removeDiacritics:()=>m,removeUndefined:()=>C,setDataKeys:()=>I,stripScripts:()=>W,toCamelCase:()=>P,toggleElement:()=>w,toggleElementClass:()=>pt,windowScrollPosition:()=>X});module.exports=nt(ht);var A=class{constructor(t){u(this,"_distinctEvent");u(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,l){let i=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let a of i)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,a))&&(n.addEventListener(a,s,l),this._boundedEvents.push({element:n,eventName:a,listener:s}))});else for(let n of i)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,l),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let l=Array.isArray(t)?t:[t],i=Array.isArray(e)?e||"":[e||""];for(let n of l){s||(s=this._boundedEvents.find(a=>{if(a.element===n&&(!e||a.eventName===e))return a.listener}));for(let a of i)n?.removeEventListener?.(a,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:l}=t;this.unbind(e,s,l)}}};var V=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};V.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var x=V.locales;var ut=50,at=4,Y={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,cssStyler:()=>null,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},rt=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(Y,x["en-US"]);var ct={BLOCK_ROWS:ut,CLUSTER_BLOCKS:at,DEFAULTS:Y,METHODS:rt},d=ct;function R(o,t,e=!1){let s=Object.keys(o),l=Object.keys(t);if(e&&s.length!==l.length)return!1;for(let i of s)if(l.includes(i)&&o[i]!==t[i])return!1;return!0}function v(o){let t=()=>{let l={};for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(l[i]=v(o[i]));return l},e=()=>o.map(l=>v(l)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function J(o){return o!=null&&o!==""}function N(o){return typeof o=="object"?Object.fromEntries(Object.entries(o).filter(([t,e])=>J(e))):o}function I(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((l,i)=>{l&&(l.visible=typeof l?.visible>"u"?!0:l.visible,l.divider||(l._key=`option_${s}_${i}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function f(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let l of s.children)if(l&&(l[t]===e||l[t]===`${+l[t]}`&&+l[t]===e))return l}}}function W(o){return o.replace(/(\b)(on[a-z]+)(\s*)=([^>]*)|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;|&#60;)(\/*)(script|script defer)(.*)(&#62;|&gt;|&gt;">)/gi,"")}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function P(o){return o.replace(/[\W_]+(.)/g,(t,e)=>e.toUpperCase())}function m(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:l})=>e.replace(s,l),o)}function B(o){let t={};if(o){let e=o.replace(/\s/g,"").split(";");for(let s of e){let[l,i]=s.trim().split(":");l&&(t[P(l)]=i.trim())}console.warn("[multiple-select-vanilla] Please note that `styler` is deprecated, please migrate to `cssStyler` when possible.")}return t}function D(o){let t=0,e=0,s=0,l=0,i=window.innerHeight??0,n=window.innerWidth??0,a=X(),c=a.top,r=a.left,p=L(o);if(p){let E=p.top??0,S=p.left??0;e=E-c,t=i-(E-c),s=S-r,l=n-(S-r)}return{top:e,bottom:t,left:s,right:l}}function h(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(l=>{let i=t[l];typeof i=="object"?Object.assign(s[l],i):s[l]=t[l]}),e?.appendChild&&e.appendChild(s),s}function $(o,t,e){let s="";o.props?.innerHTML&&(s=o.props.innerHTML,delete o.props.innerHTML);let l=h(o.tagName,N(o.props),t),i=e;if(i||(i=l),s&&(l.innerHTML=s),o.attrs)for(let n of Object.keys(o.attrs))l.setAttribute(n,o.attrs[n]);if(o.children)for(let n of o.children)$(n,l,i);return t?.appendChild(l),l}function b(o){return o.hasOwnProperty("tagName")?$(o):document.createElement("li")}function g(o){for(;o?.firstChild;)o.lastChild&&o.removeChild(o.lastChild);return o}function L(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,l=0,i=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,i=t.right,l=t.bottom),{top:e,left:s,bottom:l,right:i}}function y(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let l=o.style.display,i=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=l,o.style.position=i}return s||0}function k(o,t){let e=null,s=o?.parentElement;for(;s;){let[l,i,n,a]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&a)for(let c of a.replace(n,"").split(" "))s.classList.contains(c)&&(i?s?.tagName.toLowerCase()===i&&(e=s):e=s);s=s.parentElement}return e}function j(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function w(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function pt(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function X(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}var F=class{constructor(t){u(this,"cache");u(this,"clusterRows");u(this,"dataStart");u(this,"dataEnd");u(this,"rows");u(this,"scrollEl");u(this,"blockHeight");u(this,"clusterHeight");u(this,"contentEl");u(this,"parentEl");u(this,"itemHeight");u(this,"lastCluster");u(this,"scrollTop");u(this,"destroy");u(this,"callback");u(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl?.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{g(this.contentEl),this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let n=b(t[0]);this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.cache.data=[t[0]],this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=this.checkChanges("data",e.rows),l=this.checkChanges("top",e.topOffset),i=this.checkChanges("bottom",e.bottomOffset);g(this.contentEl),s&&l?(e.topOffset&&this.contentEl.appendChild(this.getExtra("top",e.topOffset)),e.rows.forEach(n=>this.contentEl.appendChild(b(n))),e.bottomOffset&&this.contentEl.appendChild(this.getExtra("bottom",e.bottomOffset))):i&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*d.BLOCK_ROWS,this.clusterRows=d.BLOCK_ROWS*d.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*d.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-d.BLOCK_ROWS)*e,0),l=s+this.clusterRows,i=Math.max(s*this.itemHeight,0),n=Math.max((t.length-l)*this.itemHeight,0),a=[],c=s;i<1&&c++;for(let r=s;r<l;r++)t[r]&&a.push(t[r]);return this.dataStart=s,this.dataEnd=l,{topOffset:i,bottomOffset:n,rowsAbove:c,rows:a}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s}};var H=class{constructor(t,e){this.elm=t;u(this,"_bindEventService");u(this,"allSelected",!1);u(this,"fromHtml",!1);u(this,"choiceElm");u(this,"closeElm");u(this,"closeSearchElm");u(this,"filterText","");u(this,"updateData",[]);u(this,"data",[]);u(this,"dataTotal");u(this,"dropElm");u(this,"okButtonElm");u(this,"filterParentElm");u(this,"ulElm");u(this,"parentElm");u(this,"labelElm");u(this,"selectAllParentElm");u(this,"selectAllElm");u(this,"searchInputElm");u(this,"selectGroupElms");u(this,"selectItemElms");u(this,"disableItemElms");u(this,"noResultsElm");u(this,"options");u(this,"selectAllName","");u(this,"selectGroupName","");u(this,"selectItemName","");u(this,"tabIndex");u(this,"updateDataStart");u(this,"updateDataEnd");u(this,"virtualScroll");u(this,"locales",{});this.options=Object.assign({},d.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}get isRenderAsHtml(){return this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=h("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=h("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(h("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(h("div",{className:"icon-close"})),this.choiceElm.appendChild(h("div",{className:"icon-caret"})),this.dropElm=h("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let l=this.elm.getAttribute("data-test")||this.options.dataTest;l&&(this.parentElm.dataset.test=l,this.dropElm.dataset.test=l),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),j(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`selectAll${t}`,this.selectGroupName=`selectGroup${t}`,this.selectItemName=`selectItem${t}`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",i=>{i.target===this.choiceElm||k(i.target,".ms-choice")===this.choiceElm||(i.target===this.dropElm||k(i.target,".ms-drop")!==this.dropElm&&i.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{let s=this.initRow(e);s&&t.push(s)}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=I(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(l=>{s.children.push(this.initRow(l,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=h("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(h("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"})),this.options.showSearchClear&&this.filterParentElm.appendChild(h("span",{className:"icon-close"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=h("div",{className:"ms-select-all"});let e=document.createElement("label");h("input",{type:"checkbox",ariaChecked:String(this.allSelected),checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(h("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=h("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=0,e=this.getListRows();if(this.options.selectAll&&!this.options.single&&(t=-1),e.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let l=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+t,this.updateDataEnd=this.virtualScroll.dataEnd+t,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>this.getDataLength()&&(this.updateDataEnd=this.getDataLength()))};this.ulElm&&(this.virtualScroll=new F({rows:e,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{l(),this.events()}})),l(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(g(this.ulElm),e.forEach(s=>this.ulElm.appendChild(b(s)))),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;return this.events(),e}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>t.push(...this.initListItem(e))),t.push({tagName:"li",props:{className:"ms-no-results",textContent:this.formatNoMatchesFound()}}),t}initListItem(t,e=0){let s=t?.title||"",l=this.options.multiple?"multiple":"",i=this.options.single?"radio":"checkbox",n="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(n="hide-radio "),t.selected&&(n+="selected "),t.type==="optgroup"){let M=[],Z=this.options.hideOptgroupCheckboxes||this.options.single?{tagName:"span",props:{dataset:{name:this.selectGroupName,key:t._key}}}:{tagName:"input",props:{type:"checkbox",dataset:{name:this.selectGroupName,key:t._key},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:t.disabled}};!n.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(n+="hide-radio ");let z={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(z.props,t.label);let _={tagName:"li",props:{className:`group ${n}`.trim()},children:[{tagName:"label",props:{className:`optgroup${this.options.single||t.disabled?" disabled":""}`},children:[Z,z]}]},U=this.options.cssStyler(t),K=String(this.options.styler(t)||"");return K&&(_.props.style=B(K)),U&&(_.props.style=U),M.push(_),t.children.forEach(Q=>M.push(...this.initListItem(Q,1))),M}if(n+=t.classes||"",e&&this.options.single&&(n+=`option-level-${e} `),t.divider)return[{tagName:"li",props:{className:"option-divider"}}];let a=l||n?(l+n).trim():"",c=`${t.disabled?"disabled":""}`,r={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(r.props,t.text);let p={tagName:"input",props:{type:i,value:encodeURI(t.value),dataset:{key:t._key,name:this.selectItemName},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:!!t.disabled}};t.selected&&(p.attrs={checked:"checked"});let E={tagName:"li",props:{className:a,title:s},children:[{tagName:"label",props:{className:c},children:[p,r]}]},S=this.options.cssStyler(t),q=String(this.options.styler(t)||"");return q&&(E.props.style=B(q)),S&&(E.props.style=S),[E]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let l=s.children.filter(i=>i&&i.selected&&!i.disabled&&i.visible).length;s.children.length&&(s.selected=!this.options.single&&l&&l===s.children.filter(i=>i&&!i.disabled&&i.visible&&!i.divider).length),e+=l}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=y(this.dropElm,"outer","width")+20)):t=y(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.closeSearchElm=this.filterParentElm?.querySelector(".icon-close"),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[data-name="${this.selectAllName}"]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectGroupName}"],span[data-name="${this.selectGroupName}"]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.closeSearchElm&&this._bindEventService.bind(this.closeSearchElm,"click",e=>{e.preventDefault(),this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];this.selectItemElms?.forEach(l=>{l.closest("li")?.style.display!=="none"&&s.push(l)}),s.length&&s[0].hasAttribute("data-name")&&this.setSelects([s[0].value])}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,l=s.checked,i=f(this.data,"_key",s.dataset.key);this._checkGroup(i,l),this.options.onOptgroupClick(C({label:i.label,selected:i.selected,data:i._data,children:i.children.map(n=>{if(n)return C({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,l=s.checked,i=f(this.data,"_key",s.dataset.key),n=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(i)===!1){n();return}this._check(i,l),this.options.onClick(C({text:i.text,value:i.value,selected:i.selected,data:i._data})),n()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.getDataLength()||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let i=L(this.dropElm),n;this.options.container instanceof Node?n=this.options.container:typeof this.options.container=="string"&&(n=this.options.container==="body"?document.body:document.querySelector(this.options.container)),n.appendChild(this.dropElm),this.dropElm.style.top=`${i?.top??0}px`,this.dropElm.style.left=`${i?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${y(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;this.options.maxHeightUnit==="row"&&(e=y(this.dropElm.querySelector("ul>li"),"outer","height")*this.options.maxHeight);let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(i=>i.style.width=`${this.options.multipleWidth}px`),this.getDataLength()&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:i,top:n}=D(this.dropElm),a=this.dropElm.getBoundingClientRect().height;l=i<a&&n>i?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}applyAsTextOrHtmlWhenEnabled(t,e){t||(t={}),this.isRenderAsHtml?t.innerHTML=typeof this.options.sanitizer=="function"?this.options.sanitizer(e):e:t.textContent=e}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let l=this.choiceElm?.querySelector("span"),i=e.length,n=null,a=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?W(r):r}return s.join(this.options.displayDelimiter)};if(l){if(i===0){let r=this.options.placeholder||"";l.classList.add("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,r)}else i<this.options.minimumCountSelected?n=a():this.formatAllSelected()&&i===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&i>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(i,this.dataTotal)&&i>this.options.minimumCountSelected?n=this.formatCountSelected(i,this.dataTotal):n=a();if(n!==null&&(l?.classList.remove("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,n)),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was deprecated and replaced by `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";l.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(p=>p===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(t){for(let s=this.updateDataStart;s<this.updateDataEnd;s++){let l=this.updateData[s],i=this.dropElm.querySelector(`input[data-key=${l._key}]`);if(i){i.checked=l.selected;let n=i.closest("li");n&&(l.selected&&!n.classList.contains("selected")?n.classList.add("selected"):l.selected||n.classList.remove("selected"))}}let e=this.data?.filter(s=>s.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,w(this.selectAllElm.closest("li"),!e)),w(this.noResultsElm,e),this.virtualScroll&&(this.virtualScroll.rows=t??this.getListRows())}getData(){return this.options.data}getDataLength(){return this.data?.length??0}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?v(e):this.options}refreshOptions(t){R(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let l=s.children.filter(i=>i?.selected);if(!l.length)continue;if(t==="value"||this.options.single)e.push(...l.map(i=>t==="value"&&i._value||i[t]));else{let i=[];i.push("["),i.push(s.label),i.push(`: ${l.map(n=>n[t]).join(", ")}`),i.push("]"),e.push(i.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let l=!1,i=n=>{for(let a of n){let c=!1;if(e==="text"){let r=document.createElement("div");this.applyAsTextOrHtmlWhenEnabled(r,a.text),c=t.includes(r.textContent?.trim()??"")}else c=t.includes(a._value||a.value),!c&&a.value===`${+a.value}`&&(c=t.includes(+a.value));a.selected!==c&&(l=!0),a.selected=c}};for(let n of this.data||[])n.type==="optgroup"?i(n.children):i([n]);l&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=f(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=f(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(l=>{l&&!l.disabled&&!l.divider&&(s||l.visible)&&(l.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText===s)return;this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let n=`${i?.label??""}`;if(i!=null){let a=this.options.customFilter({label:m(n.toLowerCase()),search:m(s),originalLabel:n,originalSearch:e,row:i});i.visible=a;for(let c of i.children)c&&(c.visible=a)}}else{for(let n of i.children)if(n!=null){let a=`${n?.text??""}`;n.visible=this.options.customFilter({text:m(a.toLowerCase()),search:m(s),originalText:a,originalSearch:e,row:n,parent:i})}i.visible=i.children.filter(n=>n?.visible).length>0}else{let n=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(n.toLowerCase()),search:m(s),originalText:n,originalSearch:e,row:i})}let l=this.initListItems();this.initSelected(t),this.updateSelected(l),t||this.options.onFilter(e)}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,l=this.okButtonElm?.getBoundingClientRect().height??0,i=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+l+i+5,{bottom:a,top:c}=D(this.parentElm),r=this.options.maxHeight;if(e?r=a-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let p=this.dropElm?.querySelector("ul");return p&&(p.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:l}=D(this.dropElm),{top:i,left:n}=L(this.parentElm),a=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,p=this.parentElm.getBoundingClientRect().width;if(s>a)e="bottom";else if(a>s&&l>s){if(this.options.container){let E=i-a;E<0&&(E=0),(E>0||t)&&(e="top",this.dropElm.style.top=`${E<0?0:E}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}r-c<n&&(this.dropElm.style.left=`${n-(c-p)}px`)}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),l=this.dropElm.querySelector("ul"),i=26,n=s?.clientWidth??0+i,c=l.scrollHeight>l.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(p=>{p.scrollWidth>r&&(r=p.scrollWidth)}),r+=i+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let l=s.offsetWidth;return t.parentNode?.removeChild(t),e-l}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var O=function(o,t){return typeof o=="string"?G(document.querySelectorAll(o),t):o instanceof Node?G([o],t):G(o,t)};function G(o,t){let e=Array.from(o),s=[];for(let l=0;l<e.length;l++){let i=e[l];try{i._multipleSelect!==void 0&&(i._multipleSelect.destroy(),delete i._multipleSelect),i._multipleSelect=new H(i,t||{}),i._multipleSelect.init();let n=i._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete i._multipleSelect,n.onAfterHardDestroyed=()=>s[l]=null,s.push(i._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}O.defaults=d.DEFAULTS;O.locales={...x};O.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=O);
//# sourceMappingURL=multiple-select.js.map

@@ -1,26 +0,2 @@

var j=Object.defineProperty;var W=(o,t,e)=>t in o?j(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var a=(o,t,e)=>(W(o,typeof t!="symbol"?t+"":t,e),e);var A=class{constructor(t){a(this,"_distinctEvent");a(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,i){let l=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let u of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,u))&&(n.addEventListener(u,s,i),this._boundedEvents.push({element:n,eventName:u,listener:s}))});else for(let n of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,i),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let i=Array.isArray(t)?t:[t],l=Array.isArray(e)?e||"":[e||""];for(let n of i){s||(s=this._boundedEvents.find(u=>{if(u.element===n&&(!e||u.eventName===e))return u.listener}));for(let u of l)n?.removeEventListener?.(u,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:i}=t;this.unbind(e,s,i)}}};var M=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};M.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var y=M.locales;var P=50,G=4,k={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},z=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(k,y["en-US"]);var q={BLOCK_ROWS:P,CLUSTER_BLOCKS:G,DEFAULTS:k,METHODS:z},p=q;var v=class{constructor(t){a(this,"cache");a(this,"clusterRows");a(this,"dataStart");a(this,"dataEnd");a(this,"rows");a(this,"scrollEl");a(this,"blockHeight");a(this,"clusterHeight");a(this,"contentEl");a(this,"parentEl");a(this,"itemHeight");a(this,"lastCluster");a(this,"scrollTop");a(this,"destroy");a(this,"callback");a(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl?.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{this.contentEl.innerHTML="",this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let c=t[0]+t[0]+t[0];this.contentEl.innerHTML=this.sanitizer?this.sanitizer(`${c}`):`${c}`,this.cache.data=c,this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=e.rows.join(""),i=this.checkChanges("data",s),l=this.checkChanges("top",e.topOffset),n=this.checkChanges("bottom",e.bottomOffset),u=[];i&&l?(e.topOffset&&u.push(this.getExtra("top",e.topOffset)),u.push(s),e.bottomOffset&&u.push(this.getExtra("bottom",e.bottomOffset)),this.contentEl.innerHTML=this.sanitizer?this.sanitizer(u.join("")):u.join("")):n&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*p.BLOCK_ROWS,this.clusterRows=p.BLOCK_ROWS*p.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*p.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<p.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-p.BLOCK_ROWS)*e,0),i=s+this.clusterRows,l=Math.max(s*this.itemHeight,0),n=Math.max((t.length-i)*this.itemHeight,0),u=[],c=s;l<1&&c++;for(let r=s;r<i;r++)t[r]&&u.push(t[r]);return this.dataStart=s,this.dataEnd=i,{topOffset:l,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s.outerHTML}};function S(o){let t=0,e=0,s=0,i=0,l=window.innerHeight??0,n=window.innerWidth??0,u=U(),c=u.top,r=u.left,h=C(o);if(h){let E=h.top??0,f=h.left??0;e=E-c,t=l-(E-c),s=f-r,i=n-(f-r)}return{top:e,bottom:t,left:s,right:i}}function d(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(i=>{let l=t[i];typeof l=="object"?Object.assign(s[i],l):s[i]=t[i]}),e&&e.appendChild&&e.appendChild(s),s}function C(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,i=0,l=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,l=t.right,i=t.bottom),{top:e,left:s,bottom:i,right:l}}function b(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let i=o.style.display,l=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=i,o.style.position=l}return s||0}function O(o,t){let e=null,s=o?.parentElement;for(;s;){let[i,l,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))s.classList.contains(c)&&(l?s?.tagName.toLowerCase()===l&&(e=s):e=s);s=s.parentElement}return e}function w(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function H(o){let t=typeof o=="string"?o:String(o),e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return(t||"").toString().replace(/[&<>"']/g,s=>e[s])}function x(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function ut(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function U(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}function _(o,t,e=!1){let s=Object.keys(o),i=Object.keys(t);if(e&&s.length!==i.length)return!1;for(let l of s)if(i.includes(l)&&o[l]!==t[l])return!1;return!0}function D(o){let t=()=>{let i={};for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&(i[l]=D(o[l]));return i},e=()=>o.map(i=>D(i)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function R(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((i,l)=>{i&&(i.visible=typeof i?.visible>"u"?!0:i.visible,i.divider||(i._key=`option_${s}_${l}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function g(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let i of s.children)if(i&&(i[t]===e||i[t]===`${+i[t]}`&&+i[t]===e))return i}}}function $(o){let t=document.createElement("div");t.innerHTML=o;let e=t.getElementsByTagName("script"),s=e.length;for(;s--;)e[s].parentNode?.removeChild(e[s]);return t.innerHTML}function L(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function m(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:i})=>e.replace(s,i),o)}var F=class{constructor(t,e){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"ulElm");a(this,"parentElm");a(this,"labelElm");a(this,"selectAllParentElm");a(this,"selectAllElm");a(this,"searchInputElm");a(this,"selectGroupElms");a(this,"selectItemElms");a(this,"disableItemElms");a(this,"noResultsElm");a(this,"options");a(this,"selectAllName","");a(this,"selectGroupName","");a(this,"selectItemName","");a(this,"tabIndex");a(this,"updateDataStart");a(this,"updateDataEnd");a(this,"virtualScroll");a(this,"locales",{});this.options=Object.assign({},p.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=d("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=d("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(d("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(d("div",{className:"icon-close"})),this.choiceElm.appendChild(d("div",{className:"icon-caret"})),this.dropElm=d("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let i=this.elm.getAttribute("data-test")||this.options.dataTest;i&&(this.parentElm.dataset.test=i,this.dropElm.dataset.test=i),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),w(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`data-name="selectAll${t}"`,this.selectGroupName=`data-name="selectGroup${t}"`,this.selectItemName=`data-name="selectItem${t}"`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",l=>{l.target===this.choiceElm||O(l.target,".ms-choice")===this.choiceElm||(l.target===this.dropElm||O(l.target,".ms-drop")!==this.dropElm&&l.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{this.initRow(e)&&t.push(this.initRow(e))}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=R(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(i=>{s.children.push(this.initRow(i,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=d("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(d("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=d("div",{className:"ms-select-all"});let e=document.createElement("label");d("input",{type:"checkbox",checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(d("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=d("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=this.getListRows(),e=0;if(this.options.selectAll&&!this.options.single&&(e=-1),t.length>p.BLOCK_ROWS*p.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let i=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+e,this.updateDataEnd=this.virtualScroll.dataEnd+e,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>(this.data?.length??0)&&(this.updateDataEnd=this.data?.length??0))};this.ulElm&&(this.virtualScroll=new v({rows:t,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{i(),this.events()}})),i(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(this.ulElm.innerHTML=this.options.sanitizer?this.options.sanitizer(t.join("")):t.join("")),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;this.events()}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>{t.push(...this.initListItem(e))}),t.push(`<li class="ms-no-results">${this.formatNoMatchesFound()}</li>`),t}initListItem(t,e=0){let s=this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml,i=t?.title?`title="${t.title}"`:"",l=this.options.multiple?"multiple":"",n=this.options.single?"radio":"checkbox",u="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(u="hide-radio "),t.selected&&(u+="selected "),t.type==="optgroup"){let h=this.options.styler(t),E=h?`style="${h}"`:"",f=[],I=this.options.hideOptgroupCheckboxes||this.options.single?`<span ${this.selectGroupName} data-key="${t._key}"></span>`:`<input type="checkbox"
${this.selectGroupName}
data-key="${t._key}"
${t.selected?' checked="checked"':""}
${t.disabled?' disabled="disabled"':""}
>`;return!u.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(u+="hide-radio "),f.push(`
<li class="${`group ${u}`.trim()}" ${E}>
<label class="optgroup${this.options.single||t.disabled?" disabled":""}">
${I}${s?t.label:H(t.label)}
</label>
</li>
`),t.children.forEach(N=>{f.push(...this.initListItem(N,1))}),f}let c=this.options.styler(t),r=c?`style="${c}"`:"";return u+=t.classes||"",e&&this.options.single&&(u+=`option-level-${e} `),t.divider?'<li class="option-divider"/>':[`
<li ${l||u?`class="${(l+u).trim()}"`:""} ${i} ${r}>
<label ${t.disabled?'class="disabled"':""}>
<input type="${n}"
value="${encodeURI(t.value)}"
data-key="${t._key}"
${this.selectItemName}
${t.selected?' checked="checked"':""}
${t.disabled?' disabled="disabled"':""}
>
<span>${s?t.text:H(t.text)}</span>
</label>
</li>
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(L({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return L({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key),n=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(l)===!1){n();return}this._check(l,i),this.options.onClick(L({text:l.text,value:l.value,selected:l.selected,data:l._data})),n()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=C(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=S(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?$(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(h=>h===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,x(this.selectAllElm.closest("li"),!t)),x(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?D(e):this.options}refreshOptions(t){_(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:m(l.toLowerCase()),search:m(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:m(n.toLowerCase()),search:m(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(l.toLowerCase()),search:m(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(e)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=S(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=S(this.dropElm),{top:l,left:n}=C(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let E=l-u;E<0&&(E=0),(E>0||t)&&(e="top",this.dropElm.style.top=`${E<0?0:E}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let E=n-(c-h);this.dropElm.style.left=`${E}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var T=function(o,t){return typeof o=="string"?B(document.querySelectorAll(o),t):o instanceof Node?B([o],t):B(o,t)};function B(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new F(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}T.defaults=p.DEFAULTS;T.locales={...y};T.methods=p.METHODS;typeof window<"u"&&(window.multipleSelect=T);export{A as BindingEventService,F as MultipleSelectInstance,v as VirtualScroll,S as calculateAvailableSpace,_ as compareObjects,d as createDomElement,D as deepCopy,g as findByParam,O as findParent,C as getElementOffset,b as getElementSize,H as htmlEncode,w as insertAfter,T as multipleSelect,m as removeDiacritics,L as removeUndefined,R as setDataKeys,$ as stripScripts,x as toggleElement,ut as toggleElementClass,U as windowScrollPosition};
var X=Object.defineProperty;var Z=(o,t,e)=>t in o?X(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var u=(o,t,e)=>(Z(o,typeof t!="symbol"?t+"":t,e),e);var A=class{constructor(t){u(this,"_distinctEvent");u(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,l){let i=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let a of i)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,a))&&(n.addEventListener(a,s,l),this._boundedEvents.push({element:n,eventName:a,listener:s}))});else for(let n of i)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,l),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let l=Array.isArray(t)?t:[t],i=Array.isArray(e)?e||"":[e||""];for(let n of l){s||(s=this._boundedEvents.find(a=>{if(a.element===n&&(!e||a.eventName===e))return a.listener}));for(let a of i)n?.removeEventListener?.(a,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:l}=t;this.unbind(e,s,l)}}};var P=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};P.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var v=P.locales;var Q=50,tt=4,$={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,cssStyler:()=>null,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},et=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign($,v["en-US"]);var st={BLOCK_ROWS:Q,CLUSTER_BLOCKS:tt,DEFAULTS:$,METHODS:et},d=st;function j(o,t,e=!1){let s=Object.keys(o),l=Object.keys(t);if(e&&s.length!==l.length)return!1;for(let i of s)if(l.includes(i)&&o[i]!==t[i])return!1;return!0}function C(o){let t=()=>{let l={};for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(l[i]=C(o[i]));return l},e=()=>o.map(l=>C(l)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function it(o){return o!=null&&o!==""}function G(o){return typeof o=="object"?Object.fromEntries(Object.entries(o).filter(([t,e])=>it(e))):o}function q(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((l,i)=>{l&&(l.visible=typeof l?.visible>"u"?!0:l.visible,l.divider||(l._key=`option_${s}_${i}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function b(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let l of s.children)if(l&&(l[t]===e||l[t]===`${+l[t]}`&&+l[t]===e))return l}}}function z(o){return o.replace(/(\b)(on[a-z]+)(\s*)=([^>]*)|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;|&#60;)(\/*)(script|script defer)(.*)(&#62;|&gt;|&gt;">)/gi,"")}function D(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function U(o){return o.replace(/[\W_]+(.)/g,(t,e)=>e.toUpperCase())}function m(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:l})=>e.replace(s,l),o)}function k(o){let t={};if(o){let e=o.replace(/\s/g,"").split(";");for(let s of e){let[l,i]=s.trim().split(":");l&&(t[U(l)]=i.trim())}console.warn("[multiple-select-vanilla] Please note that `styler` is deprecated, please migrate to `cssStyler` when possible.")}return t}function L(o){let t=0,e=0,s=0,l=0,i=window.innerHeight??0,n=window.innerWidth??0,a=lt(),c=a.top,r=a.left,p=F(o);if(p){let E=p.top??0,f=p.left??0;e=E-c,t=i-(E-c),s=f-r,l=n-(f-r)}return{top:e,bottom:t,left:s,right:l}}function h(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(l=>{let i=t[l];typeof i=="object"?Object.assign(s[l],i):s[l]=t[l]}),e?.appendChild&&e.appendChild(s),s}function K(o,t,e){let s="";o.props?.innerHTML&&(s=o.props.innerHTML,delete o.props.innerHTML);let l=h(o.tagName,G(o.props),t),i=e;if(i||(i=l),s&&(l.innerHTML=s),o.attrs)for(let n of Object.keys(o.attrs))l.setAttribute(n,o.attrs[n]);if(o.children)for(let n of o.children)K(n,l,i);return t?.appendChild(l),l}function g(o){return o.hasOwnProperty("tagName")?K(o):document.createElement("li")}function y(o){for(;o?.firstChild;)o.lastChild&&o.removeChild(o.lastChild);return o}function F(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,l=0,i=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,i=t.right,l=t.bottom),{top:e,left:s,bottom:l,right:i}}function S(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let l=o.style.display,i=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=l,o.style.position=i}return s||0}function w(o,t){let e=null,s=o?.parentElement;for(;s;){let[l,i,n,a]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&a)for(let c of a.replace(n,"").split(" "))s.classList.contains(c)&&(i?s?.tagName.toLowerCase()===i&&(e=s):e=s);s=s.parentElement}return e}function V(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function M(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function dt(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function lt(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}var H=class{constructor(t){u(this,"cache");u(this,"clusterRows");u(this,"dataStart");u(this,"dataEnd");u(this,"rows");u(this,"scrollEl");u(this,"blockHeight");u(this,"clusterHeight");u(this,"contentEl");u(this,"parentEl");u(this,"itemHeight");u(this,"lastCluster");u(this,"scrollTop");u(this,"destroy");u(this,"callback");u(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl?.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{y(this.contentEl),this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let n=g(t[0]);this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.cache.data=[t[0]],this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=this.checkChanges("data",e.rows),l=this.checkChanges("top",e.topOffset),i=this.checkChanges("bottom",e.bottomOffset);y(this.contentEl),s&&l?(e.topOffset&&this.contentEl.appendChild(this.getExtra("top",e.topOffset)),e.rows.forEach(n=>this.contentEl.appendChild(g(n))),e.bottomOffset&&this.contentEl.appendChild(this.getExtra("bottom",e.bottomOffset))):i&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*d.BLOCK_ROWS,this.clusterRows=d.BLOCK_ROWS*d.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*d.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-d.BLOCK_ROWS)*e,0),l=s+this.clusterRows,i=Math.max(s*this.itemHeight,0),n=Math.max((t.length-l)*this.itemHeight,0),a=[],c=s;i<1&&c++;for(let r=s;r<l;r++)t[r]&&a.push(t[r]);return this.dataStart=s,this.dataEnd=l,{topOffset:i,bottomOffset:n,rowsAbove:c,rows:a}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s}};var O=class{constructor(t,e){this.elm=t;u(this,"_bindEventService");u(this,"allSelected",!1);u(this,"fromHtml",!1);u(this,"choiceElm");u(this,"closeElm");u(this,"closeSearchElm");u(this,"filterText","");u(this,"updateData",[]);u(this,"data",[]);u(this,"dataTotal");u(this,"dropElm");u(this,"okButtonElm");u(this,"filterParentElm");u(this,"ulElm");u(this,"parentElm");u(this,"labelElm");u(this,"selectAllParentElm");u(this,"selectAllElm");u(this,"searchInputElm");u(this,"selectGroupElms");u(this,"selectItemElms");u(this,"disableItemElms");u(this,"noResultsElm");u(this,"options");u(this,"selectAllName","");u(this,"selectGroupName","");u(this,"selectItemName","");u(this,"tabIndex");u(this,"updateDataStart");u(this,"updateDataEnd");u(this,"virtualScroll");u(this,"locales",{});this.options=Object.assign({},d.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}get isRenderAsHtml(){return this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=h("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=h("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(h("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(h("div",{className:"icon-close"})),this.choiceElm.appendChild(h("div",{className:"icon-caret"})),this.dropElm=h("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let l=this.elm.getAttribute("data-test")||this.options.dataTest;l&&(this.parentElm.dataset.test=l,this.dropElm.dataset.test=l),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),V(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`selectAll${t}`,this.selectGroupName=`selectGroup${t}`,this.selectItemName=`selectItem${t}`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",i=>{i.target===this.choiceElm||w(i.target,".ms-choice")===this.choiceElm||(i.target===this.dropElm||w(i.target,".ms-drop")!==this.dropElm&&i.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{let s=this.initRow(e);s&&t.push(s)}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=q(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(l=>{s.children.push(this.initRow(l,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=h("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(h("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"})),this.options.showSearchClear&&this.filterParentElm.appendChild(h("span",{className:"icon-close"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=h("div",{className:"ms-select-all"});let e=document.createElement("label");h("input",{type:"checkbox",ariaChecked:String(this.allSelected),checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(h("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=h("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=0,e=this.getListRows();if(this.options.selectAll&&!this.options.single&&(t=-1),e.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let l=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+t,this.updateDataEnd=this.virtualScroll.dataEnd+t,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>this.getDataLength()&&(this.updateDataEnd=this.getDataLength()))};this.ulElm&&(this.virtualScroll=new H({rows:e,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{l(),this.events()}})),l(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(y(this.ulElm),e.forEach(s=>this.ulElm.appendChild(g(s)))),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;return this.events(),e}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>t.push(...this.initListItem(e))),t.push({tagName:"li",props:{className:"ms-no-results",textContent:this.formatNoMatchesFound()}}),t}initListItem(t,e=0){let s=t?.title||"",l=this.options.multiple?"multiple":"",i=this.options.single?"radio":"checkbox",n="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(n="hide-radio "),t.selected&&(n+="selected "),t.type==="optgroup"){let x=[],Y=this.options.hideOptgroupCheckboxes||this.options.single?{tagName:"span",props:{dataset:{name:this.selectGroupName,key:t._key}}}:{tagName:"input",props:{type:"checkbox",dataset:{name:this.selectGroupName,key:t._key},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:t.disabled}};!n.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(n+="hide-radio ");let N={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(N.props,t.label);let B={tagName:"li",props:{className:`group ${n}`.trim()},children:[{tagName:"label",props:{className:`optgroup${this.options.single||t.disabled?" disabled":""}`},children:[Y,N]}]},I=this.options.cssStyler(t),W=String(this.options.styler(t)||"");return W&&(B.props.style=k(W)),I&&(B.props.style=I),x.push(B),t.children.forEach(J=>x.push(...this.initListItem(J,1))),x}if(n+=t.classes||"",e&&this.options.single&&(n+=`option-level-${e} `),t.divider)return[{tagName:"li",props:{className:"option-divider"}}];let a=l||n?(l+n).trim():"",c=`${t.disabled?"disabled":""}`,r={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(r.props,t.text);let p={tagName:"input",props:{type:i,value:encodeURI(t.value),dataset:{key:t._key,name:this.selectItemName},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:!!t.disabled}};t.selected&&(p.attrs={checked:"checked"});let E={tagName:"li",props:{className:a,title:s},children:[{tagName:"label",props:{className:c},children:[p,r]}]},f=this.options.cssStyler(t),R=String(this.options.styler(t)||"");return R&&(E.props.style=k(R)),f&&(E.props.style=f),[E]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let l=s.children.filter(i=>i&&i.selected&&!i.disabled&&i.visible).length;s.children.length&&(s.selected=!this.options.single&&l&&l===s.children.filter(i=>i&&!i.disabled&&i.visible&&!i.divider).length),e+=l}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=S(this.dropElm,"outer","width")+20)):t=S(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.closeSearchElm=this.filterParentElm?.querySelector(".icon-close"),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[data-name="${this.selectAllName}"]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectGroupName}"],span[data-name="${this.selectGroupName}"]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.closeSearchElm&&this._bindEventService.bind(this.closeSearchElm,"click",e=>{e.preventDefault(),this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];this.selectItemElms?.forEach(l=>{l.closest("li")?.style.display!=="none"&&s.push(l)}),s.length&&s[0].hasAttribute("data-name")&&this.setSelects([s[0].value])}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,l=s.checked,i=b(this.data,"_key",s.dataset.key);this._checkGroup(i,l),this.options.onOptgroupClick(D({label:i.label,selected:i.selected,data:i._data,children:i.children.map(n=>{if(n)return D({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,l=s.checked,i=b(this.data,"_key",s.dataset.key),n=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(i)===!1){n();return}this._check(i,l),this.options.onClick(D({text:i.text,value:i.value,selected:i.selected,data:i._data})),n()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.getDataLength()||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let i=F(this.dropElm),n;this.options.container instanceof Node?n=this.options.container:typeof this.options.container=="string"&&(n=this.options.container==="body"?document.body:document.querySelector(this.options.container)),n.appendChild(this.dropElm),this.dropElm.style.top=`${i?.top??0}px`,this.dropElm.style.left=`${i?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${S(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;this.options.maxHeightUnit==="row"&&(e=S(this.dropElm.querySelector("ul>li"),"outer","height")*this.options.maxHeight);let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(i=>i.style.width=`${this.options.multipleWidth}px`),this.getDataLength()&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:i,top:n}=L(this.dropElm),a=this.dropElm.getBoundingClientRect().height;l=i<a&&n>i?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}applyAsTextOrHtmlWhenEnabled(t,e){t||(t={}),this.isRenderAsHtml?t.innerHTML=typeof this.options.sanitizer=="function"?this.options.sanitizer(e):e:t.textContent=e}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let l=this.choiceElm?.querySelector("span"),i=e.length,n=null,a=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?z(r):r}return s.join(this.options.displayDelimiter)};if(l){if(i===0){let r=this.options.placeholder||"";l.classList.add("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,r)}else i<this.options.minimumCountSelected?n=a():this.formatAllSelected()&&i===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&i>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(i,this.dataTotal)&&i>this.options.minimumCountSelected?n=this.formatCountSelected(i,this.dataTotal):n=a();if(n!==null&&(l?.classList.remove("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,n)),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was deprecated and replaced by `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";l.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(p=>p===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(t){for(let s=this.updateDataStart;s<this.updateDataEnd;s++){let l=this.updateData[s],i=this.dropElm.querySelector(`input[data-key=${l._key}]`);if(i){i.checked=l.selected;let n=i.closest("li");n&&(l.selected&&!n.classList.contains("selected")?n.classList.add("selected"):l.selected||n.classList.remove("selected"))}}let e=this.data?.filter(s=>s.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,M(this.selectAllElm.closest("li"),!e)),M(this.noResultsElm,e),this.virtualScroll&&(this.virtualScroll.rows=t??this.getListRows())}getData(){return this.options.data}getDataLength(){return this.data?.length??0}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?C(e):this.options}refreshOptions(t){j(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let l=s.children.filter(i=>i?.selected);if(!l.length)continue;if(t==="value"||this.options.single)e.push(...l.map(i=>t==="value"&&i._value||i[t]));else{let i=[];i.push("["),i.push(s.label),i.push(`: ${l.map(n=>n[t]).join(", ")}`),i.push("]"),e.push(i.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let l=!1,i=n=>{for(let a of n){let c=!1;if(e==="text"){let r=document.createElement("div");this.applyAsTextOrHtmlWhenEnabled(r,a.text),c=t.includes(r.textContent?.trim()??"")}else c=t.includes(a._value||a.value),!c&&a.value===`${+a.value}`&&(c=t.includes(+a.value));a.selected!==c&&(l=!0),a.selected=c}};for(let n of this.data||[])n.type==="optgroup"?i(n.children):i([n]);l&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=b(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=b(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(l=>{l&&!l.disabled&&!l.divider&&(s||l.visible)&&(l.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText===s)return;this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let n=`${i?.label??""}`;if(i!=null){let a=this.options.customFilter({label:m(n.toLowerCase()),search:m(s),originalLabel:n,originalSearch:e,row:i});i.visible=a;for(let c of i.children)c&&(c.visible=a)}}else{for(let n of i.children)if(n!=null){let a=`${n?.text??""}`;n.visible=this.options.customFilter({text:m(a.toLowerCase()),search:m(s),originalText:a,originalSearch:e,row:n,parent:i})}i.visible=i.children.filter(n=>n?.visible).length>0}else{let n=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(n.toLowerCase()),search:m(s),originalText:n,originalSearch:e,row:i})}let l=this.initListItems();this.initSelected(t),this.updateSelected(l),t||this.options.onFilter(e)}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,l=this.okButtonElm?.getBoundingClientRect().height??0,i=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+l+i+5,{bottom:a,top:c}=L(this.parentElm),r=this.options.maxHeight;if(e?r=a-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let p=this.dropElm?.querySelector("ul");return p&&(p.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:l}=L(this.dropElm),{top:i,left:n}=F(this.parentElm),a=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,p=this.parentElm.getBoundingClientRect().width;if(s>a)e="bottom";else if(a>s&&l>s){if(this.options.container){let E=i-a;E<0&&(E=0),(E>0||t)&&(e="top",this.dropElm.style.top=`${E<0?0:E}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}r-c<n&&(this.dropElm.style.left=`${n-(c-p)}px`)}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),l=this.dropElm.querySelector("ul"),i=26,n=s?.clientWidth??0+i,c=l.scrollHeight>l.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(p=>{p.scrollWidth>r&&(r=p.scrollWidth)}),r+=i+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let l=s.offsetWidth;return t.parentNode?.removeChild(t),e-l}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var T=function(o,t){return typeof o=="string"?_(document.querySelectorAll(o),t):o instanceof Node?_([o],t):_(o,t)};function _(o,t){let e=Array.from(o),s=[];for(let l=0;l<e.length;l++){let i=e[l];try{i._multipleSelect!==void 0&&(i._multipleSelect.destroy(),delete i._multipleSelect),i._multipleSelect=new O(i,t||{}),i._multipleSelect.init();let n=i._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete i._multipleSelect,n.onAfterHardDestroyed=()=>s[l]=null,s.push(i._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}T.defaults=d.DEFAULTS;T.locales={...v};T.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=T);export{A as BindingEventService,O as MultipleSelectInstance,H as VirtualScroll,L as calculateAvailableSpace,j as compareObjects,g as convertItemRowToHtml,k as convertStringStyleToElementStyle,h as createDomElement,K as createDomStructure,C as deepCopy,y as emptyElement,b as findByParam,w as findParent,F as getElementOffset,S as getElementSize,V as insertAfter,it as isDefined,T as multipleSelect,G as objectRemoveEmptyProps,m as removeDiacritics,D as removeUndefined,q as setDataKeys,z as stripScripts,U as toCamelCase,M as toggleElement,dt as toggleElementClass,lt as windowScrollPosition};
//# sourceMappingURL=multiple-select.js.map

@@ -1,26 +0,2 @@

"use strict";var MultipleSelect=(()=>{var T=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var q=(o,t,e)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var U=(o,t)=>{for(var e in t)T(o,e,{get:t[e],enumerable:!0})},K=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of G(t))!z.call(o,i)&&i!==e&&T(o,i,{get:()=>t[i],enumerable:!(s=P(t,i))||s.enumerable});return o};var V=o=>K(T({},"__esModule",{value:!0}),o);var a=(o,t,e)=>(q(o,typeof t!="symbol"?t+"":t,e),e);var tt={};U(tt,{BindingEventService:()=>A,MultipleSelectInstance:()=>L,VirtualScroll:()=>y,calculateAvailableSpace:()=>v,compareObjects:()=>k,createDomElement:()=>d,deepCopy:()=>C,findByParam:()=>g,findParent:()=>H,getElementOffset:()=>S,getElementSize:()=>b,htmlEncode:()=>x,insertAfter:()=>M,multipleSelect:()=>F,removeDiacritics:()=>m,removeUndefined:()=>D,setDataKeys:()=>w,stripScripts:()=>_,toggleElement:()=>B,toggleElementClass:()=>Q,windowScrollPosition:()=>N});var A=class{constructor(t){a(this,"_distinctEvent");a(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,i){let l=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let u of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,u))&&(n.addEventListener(u,s,i),this._boundedEvents.push({element:n,eventName:u,listener:s}))});else for(let n of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,i),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let i=Array.isArray(t)?t:[t],l=Array.isArray(e)?e||"":[e||""];for(let n of i){s||(s=this._boundedEvents.find(u=>{if(u.element===n&&(!e||u.eventName===e))return u.listener}));for(let u of l)n?.removeEventListener?.(u,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:i}=t;this.unbind(e,s,i)}}};var $=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};$.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var O=$.locales;var Y=50,J=4,I={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},X=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(I,O["en-US"]);var Z={BLOCK_ROWS:Y,CLUSTER_BLOCKS:J,DEFAULTS:I,METHODS:X},p=Z;var y=class{constructor(t){a(this,"cache");a(this,"clusterRows");a(this,"dataStart");a(this,"dataEnd");a(this,"rows");a(this,"scrollEl");a(this,"blockHeight");a(this,"clusterHeight");a(this,"contentEl");a(this,"parentEl");a(this,"itemHeight");a(this,"lastCluster");a(this,"scrollTop");a(this,"destroy");a(this,"callback");a(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl?.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{this.contentEl.innerHTML="",this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let c=t[0]+t[0]+t[0];this.contentEl.innerHTML=this.sanitizer?this.sanitizer(`${c}`):`${c}`,this.cache.data=c,this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=e.rows.join(""),i=this.checkChanges("data",s),l=this.checkChanges("top",e.topOffset),n=this.checkChanges("bottom",e.bottomOffset),u=[];i&&l?(e.topOffset&&u.push(this.getExtra("top",e.topOffset)),u.push(s),e.bottomOffset&&u.push(this.getExtra("bottom",e.bottomOffset)),this.contentEl.innerHTML=this.sanitizer?this.sanitizer(u.join("")):u.join("")):n&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*p.BLOCK_ROWS,this.clusterRows=p.BLOCK_ROWS*p.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*p.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<p.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-p.BLOCK_ROWS)*e,0),i=s+this.clusterRows,l=Math.max(s*this.itemHeight,0),n=Math.max((t.length-i)*this.itemHeight,0),u=[],c=s;l<1&&c++;for(let r=s;r<i;r++)t[r]&&u.push(t[r]);return this.dataStart=s,this.dataEnd=i,{topOffset:l,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s.outerHTML}};function v(o){let t=0,e=0,s=0,i=0,l=window.innerHeight??0,n=window.innerWidth??0,u=N(),c=u.top,r=u.left,h=S(o);if(h){let E=h.top??0,f=h.left??0;e=E-c,t=l-(E-c),s=f-r,i=n-(f-r)}return{top:e,bottom:t,left:s,right:i}}function d(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(i=>{let l=t[i];typeof l=="object"?Object.assign(s[i],l):s[i]=t[i]}),e&&e.appendChild&&e.appendChild(s),s}function S(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,i=0,l=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,l=t.right,i=t.bottom),{top:e,left:s,bottom:i,right:l}}function b(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let i=o.style.display,l=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=i,o.style.position=l}return s||0}function H(o,t){let e=null,s=o?.parentElement;for(;s;){let[i,l,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))s.classList.contains(c)&&(l?s?.tagName.toLowerCase()===l&&(e=s):e=s);s=s.parentElement}return e}function M(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function x(o){let t=typeof o=="string"?o:String(o),e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return(t||"").toString().replace(/[&<>"']/g,s=>e[s])}function B(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function Q(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function N(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}function k(o,t,e=!1){let s=Object.keys(o),i=Object.keys(t);if(e&&s.length!==i.length)return!1;for(let l of s)if(i.includes(l)&&o[l]!==t[l])return!1;return!0}function C(o){let t=()=>{let i={};for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&(i[l]=C(o[l]));return i},e=()=>o.map(i=>C(i)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function w(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((i,l)=>{i&&(i.visible=typeof i?.visible>"u"?!0:i.visible,i.divider||(i._key=`option_${s}_${l}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function g(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let i of s.children)if(i&&(i[t]===e||i[t]===`${+i[t]}`&&+i[t]===e))return i}}}function _(o){let t=document.createElement("div");t.innerHTML=o;let e=t.getElementsByTagName("script"),s=e.length;for(;s--;)e[s].parentNode?.removeChild(e[s]);return t.innerHTML}function D(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function m(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:i})=>e.replace(s,i),o)}var L=class{constructor(t,e){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"ulElm");a(this,"parentElm");a(this,"labelElm");a(this,"selectAllParentElm");a(this,"selectAllElm");a(this,"searchInputElm");a(this,"selectGroupElms");a(this,"selectItemElms");a(this,"disableItemElms");a(this,"noResultsElm");a(this,"options");a(this,"selectAllName","");a(this,"selectGroupName","");a(this,"selectItemName","");a(this,"tabIndex");a(this,"updateDataStart");a(this,"updateDataEnd");a(this,"virtualScroll");a(this,"locales",{});this.options=Object.assign({},p.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=d("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=d("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(d("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(d("div",{className:"icon-close"})),this.choiceElm.appendChild(d("div",{className:"icon-caret"})),this.dropElm=d("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let i=this.elm.getAttribute("data-test")||this.options.dataTest;i&&(this.parentElm.dataset.test=i,this.dropElm.dataset.test=i),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),M(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`data-name="selectAll${t}"`,this.selectGroupName=`data-name="selectGroup${t}"`,this.selectItemName=`data-name="selectItem${t}"`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",l=>{l.target===this.choiceElm||H(l.target,".ms-choice")===this.choiceElm||(l.target===this.dropElm||H(l.target,".ms-drop")!==this.dropElm&&l.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{this.initRow(e)&&t.push(this.initRow(e))}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=w(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(i=>{s.children.push(this.initRow(i,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=d("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(d("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=d("div",{className:"ms-select-all"});let e=document.createElement("label");d("input",{type:"checkbox",checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(d("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=d("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=this.getListRows(),e=0;if(this.options.selectAll&&!this.options.single&&(e=-1),t.length>p.BLOCK_ROWS*p.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let i=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+e,this.updateDataEnd=this.virtualScroll.dataEnd+e,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>(this.data?.length??0)&&(this.updateDataEnd=this.data?.length??0))};this.ulElm&&(this.virtualScroll=new y({rows:t,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{i(),this.events()}})),i(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(this.ulElm.innerHTML=this.options.sanitizer?this.options.sanitizer(t.join("")):t.join("")),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;this.events()}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>{t.push(...this.initListItem(e))}),t.push(`<li class="ms-no-results">${this.formatNoMatchesFound()}</li>`),t}initListItem(t,e=0){let s=this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml,i=t?.title?`title="${t.title}"`:"",l=this.options.multiple?"multiple":"",n=this.options.single?"radio":"checkbox",u="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(u="hide-radio "),t.selected&&(u+="selected "),t.type==="optgroup"){let h=this.options.styler(t),E=h?`style="${h}"`:"",f=[],j=this.options.hideOptgroupCheckboxes||this.options.single?`<span ${this.selectGroupName} data-key="${t._key}"></span>`:`<input type="checkbox"
${this.selectGroupName}
data-key="${t._key}"
${t.selected?' checked="checked"':""}
${t.disabled?' disabled="disabled"':""}
>`;return!u.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(u+="hide-radio "),f.push(`
<li class="${`group ${u}`.trim()}" ${E}>
<label class="optgroup${this.options.single||t.disabled?" disabled":""}">
${j}${s?t.label:x(t.label)}
</label>
</li>
`),t.children.forEach(W=>{f.push(...this.initListItem(W,1))}),f}let c=this.options.styler(t),r=c?`style="${c}"`:"";return u+=t.classes||"",e&&this.options.single&&(u+=`option-level-${e} `),t.divider?'<li class="option-divider"/>':[`
<li ${l||u?`class="${(l+u).trim()}"`:""} ${i} ${r}>
<label ${t.disabled?'class="disabled"':""}>
<input type="${n}"
value="${encodeURI(t.value)}"
data-key="${t._key}"
${this.selectItemName}
${t.selected?' checked="checked"':""}
${t.disabled?' disabled="disabled"':""}
>
<span>${s?t.text:x(t.text)}</span>
</label>
</li>
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(D({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return D({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key),n=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(l)===!1){n();return}this._check(l,i),this.options.onClick(D({text:l.text,value:l.value,selected:l.selected,data:l._data})),n()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=S(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=v(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?_(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(h=>h===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,B(this.selectAllElm.closest("li"),!t)),B(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?C(e):this.options}refreshOptions(t){k(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:m(l.toLowerCase()),search:m(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:m(n.toLowerCase()),search:m(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(l.toLowerCase()),search:m(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(e)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=v(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=v(this.dropElm),{top:l,left:n}=S(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let E=l-u;E<0&&(E=0),(E>0||t)&&(e="top",this.dropElm.style.top=`${E<0?0:E}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let E=n-(c-h);this.dropElm.style.left=`${E}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var F=function(o,t){return typeof o=="string"?R(document.querySelectorAll(o),t):o instanceof Node?R([o],t):R(o,t)};function R(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new L(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}F.defaults=p.DEFAULTS;F.locales={...O};F.methods=p.METHODS;typeof window<"u"&&(window.multipleSelect=F);return V(tt);})();
"use strict";var MultipleSelect=(()=>{var T=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var st=Object.prototype.hasOwnProperty;var it=(o,t,e)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var lt=(o,t)=>{for(var e in t)T(o,e,{get:t[e],enumerable:!0})},ot=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of et(t))!st.call(o,l)&&l!==e&&T(o,l,{get:()=>t[l],enumerable:!(s=tt(t,l))||s.enumerable});return o};var nt=o=>ot(T({},"__esModule",{value:!0}),o);var u=(o,t,e)=>(it(o,typeof t!="symbol"?t+"":t,e),e);var ht={};lt(ht,{BindingEventService:()=>A,MultipleSelectInstance:()=>H,VirtualScroll:()=>F,calculateAvailableSpace:()=>D,compareObjects:()=>R,convertItemRowToHtml:()=>b,convertStringStyleToElementStyle:()=>B,createDomElement:()=>h,createDomStructure:()=>$,deepCopy:()=>v,emptyElement:()=>g,findByParam:()=>f,findParent:()=>k,getElementOffset:()=>L,getElementSize:()=>y,insertAfter:()=>j,isDefined:()=>J,multipleSelect:()=>O,objectRemoveEmptyProps:()=>N,removeDiacritics:()=>m,removeUndefined:()=>C,setDataKeys:()=>I,stripScripts:()=>W,toCamelCase:()=>P,toggleElement:()=>w,toggleElementClass:()=>pt,windowScrollPosition:()=>X});var A=class{constructor(t){u(this,"_distinctEvent");u(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,l){let i=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let a of i)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,a))&&(n.addEventListener(a,s,l),this._boundedEvents.push({element:n,eventName:a,listener:s}))});else for(let n of i)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,l),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let l=Array.isArray(t)?t:[t],i=Array.isArray(e)?e||"":[e||""];for(let n of l){s||(s=this._boundedEvents.find(a=>{if(a.element===n&&(!e||a.eventName===e))return a.listener}));for(let a of i)n?.removeEventListener?.(a,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:l}=t;this.unbind(e,s,l)}}};var V=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};V.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var x=V.locales;var ut=50,at=4,Y={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,cssStyler:()=>null,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},rt=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(Y,x["en-US"]);var ct={BLOCK_ROWS:ut,CLUSTER_BLOCKS:at,DEFAULTS:Y,METHODS:rt},d=ct;function R(o,t,e=!1){let s=Object.keys(o),l=Object.keys(t);if(e&&s.length!==l.length)return!1;for(let i of s)if(l.includes(i)&&o[i]!==t[i])return!1;return!0}function v(o){let t=()=>{let l={};for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(l[i]=v(o[i]));return l},e=()=>o.map(l=>v(l)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function J(o){return o!=null&&o!==""}function N(o){return typeof o=="object"?Object.fromEntries(Object.entries(o).filter(([t,e])=>J(e))):o}function I(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((l,i)=>{l&&(l.visible=typeof l?.visible>"u"?!0:l.visible,l.divider||(l._key=`option_${s}_${i}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function f(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let l of s.children)if(l&&(l[t]===e||l[t]===`${+l[t]}`&&+l[t]===e))return l}}}function W(o){return o.replace(/(\b)(on[a-z]+)(\s*)=([^>]*)|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;|&#60;)(\/*)(script|script defer)(.*)(&#62;|&gt;|&gt;">)/gi,"")}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function P(o){return o.replace(/[\W_]+(.)/g,(t,e)=>e.toUpperCase())}function m(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:l})=>e.replace(s,l),o)}function B(o){let t={};if(o){let e=o.replace(/\s/g,"").split(";");for(let s of e){let[l,i]=s.trim().split(":");l&&(t[P(l)]=i.trim())}console.warn("[multiple-select-vanilla] Please note that `styler` is deprecated, please migrate to `cssStyler` when possible.")}return t}function D(o){let t=0,e=0,s=0,l=0,i=window.innerHeight??0,n=window.innerWidth??0,a=X(),c=a.top,r=a.left,p=L(o);if(p){let E=p.top??0,S=p.left??0;e=E-c,t=i-(E-c),s=S-r,l=n-(S-r)}return{top:e,bottom:t,left:s,right:l}}function h(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(l=>{let i=t[l];typeof i=="object"?Object.assign(s[l],i):s[l]=t[l]}),e?.appendChild&&e.appendChild(s),s}function $(o,t,e){let s="";o.props?.innerHTML&&(s=o.props.innerHTML,delete o.props.innerHTML);let l=h(o.tagName,N(o.props),t),i=e;if(i||(i=l),s&&(l.innerHTML=s),o.attrs)for(let n of Object.keys(o.attrs))l.setAttribute(n,o.attrs[n]);if(o.children)for(let n of o.children)$(n,l,i);return t?.appendChild(l),l}function b(o){return o.hasOwnProperty("tagName")?$(o):document.createElement("li")}function g(o){for(;o?.firstChild;)o.lastChild&&o.removeChild(o.lastChild);return o}function L(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,l=0,i=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,i=t.right,l=t.bottom),{top:e,left:s,bottom:l,right:i}}function y(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let l=o.style.display,i=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=l,o.style.position=i}return s||0}function k(o,t){let e=null,s=o?.parentElement;for(;s;){let[l,i,n,a]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&a)for(let c of a.replace(n,"").split(" "))s.classList.contains(c)&&(i?s?.tagName.toLowerCase()===i&&(e=s):e=s);s=s.parentElement}return e}function j(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function w(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function pt(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function X(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}var F=class{constructor(t){u(this,"cache");u(this,"clusterRows");u(this,"dataStart");u(this,"dataEnd");u(this,"rows");u(this,"scrollEl");u(this,"blockHeight");u(this,"clusterHeight");u(this,"contentEl");u(this,"parentEl");u(this,"itemHeight");u(this,"lastCluster");u(this,"scrollTop");u(this,"destroy");u(this,"callback");u(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl?.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{g(this.contentEl),this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let n=b(t[0]);this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.cache.data=[t[0]],this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=this.checkChanges("data",e.rows),l=this.checkChanges("top",e.topOffset),i=this.checkChanges("bottom",e.bottomOffset);g(this.contentEl),s&&l?(e.topOffset&&this.contentEl.appendChild(this.getExtra("top",e.topOffset)),e.rows.forEach(n=>this.contentEl.appendChild(b(n))),e.bottomOffset&&this.contentEl.appendChild(this.getExtra("bottom",e.bottomOffset))):i&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*d.BLOCK_ROWS,this.clusterRows=d.BLOCK_ROWS*d.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*d.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-d.BLOCK_ROWS)*e,0),l=s+this.clusterRows,i=Math.max(s*this.itemHeight,0),n=Math.max((t.length-l)*this.itemHeight,0),a=[],c=s;i<1&&c++;for(let r=s;r<l;r++)t[r]&&a.push(t[r]);return this.dataStart=s,this.dataEnd=l,{topOffset:i,bottomOffset:n,rowsAbove:c,rows:a}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s}};var H=class{constructor(t,e){this.elm=t;u(this,"_bindEventService");u(this,"allSelected",!1);u(this,"fromHtml",!1);u(this,"choiceElm");u(this,"closeElm");u(this,"closeSearchElm");u(this,"filterText","");u(this,"updateData",[]);u(this,"data",[]);u(this,"dataTotal");u(this,"dropElm");u(this,"okButtonElm");u(this,"filterParentElm");u(this,"ulElm");u(this,"parentElm");u(this,"labelElm");u(this,"selectAllParentElm");u(this,"selectAllElm");u(this,"searchInputElm");u(this,"selectGroupElms");u(this,"selectItemElms");u(this,"disableItemElms");u(this,"noResultsElm");u(this,"options");u(this,"selectAllName","");u(this,"selectGroupName","");u(this,"selectItemName","");u(this,"tabIndex");u(this,"updateDataStart");u(this,"updateDataEnd");u(this,"virtualScroll");u(this,"locales",{});this.options=Object.assign({},d.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}get isRenderAsHtml(){return this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=h("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=h("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(h("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(h("div",{className:"icon-close"})),this.choiceElm.appendChild(h("div",{className:"icon-caret"})),this.dropElm=h("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let l=this.elm.getAttribute("data-test")||this.options.dataTest;l&&(this.parentElm.dataset.test=l,this.dropElm.dataset.test=l),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),j(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`selectAll${t}`,this.selectGroupName=`selectGroup${t}`,this.selectItemName=`selectItem${t}`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",i=>{i.target===this.choiceElm||k(i.target,".ms-choice")===this.choiceElm||(i.target===this.dropElm||k(i.target,".ms-drop")!==this.dropElm&&i.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{let s=this.initRow(e);s&&t.push(s)}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=I(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(l=>{s.children.push(this.initRow(l,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=h("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(h("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"})),this.options.showSearchClear&&this.filterParentElm.appendChild(h("span",{className:"icon-close"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=h("div",{className:"ms-select-all"});let e=document.createElement("label");h("input",{type:"checkbox",ariaChecked:String(this.allSelected),checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(h("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=h("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=0,e=this.getListRows();if(this.options.selectAll&&!this.options.single&&(t=-1),e.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let l=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+t,this.updateDataEnd=this.virtualScroll.dataEnd+t,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>this.getDataLength()&&(this.updateDataEnd=this.getDataLength()))};this.ulElm&&(this.virtualScroll=new F({rows:e,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{l(),this.events()}})),l(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(g(this.ulElm),e.forEach(s=>this.ulElm.appendChild(b(s)))),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;return this.events(),e}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>t.push(...this.initListItem(e))),t.push({tagName:"li",props:{className:"ms-no-results",textContent:this.formatNoMatchesFound()}}),t}initListItem(t,e=0){let s=t?.title||"",l=this.options.multiple?"multiple":"",i=this.options.single?"radio":"checkbox",n="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(n="hide-radio "),t.selected&&(n+="selected "),t.type==="optgroup"){let M=[],Z=this.options.hideOptgroupCheckboxes||this.options.single?{tagName:"span",props:{dataset:{name:this.selectGroupName,key:t._key}}}:{tagName:"input",props:{type:"checkbox",dataset:{name:this.selectGroupName,key:t._key},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:t.disabled}};!n.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(n+="hide-radio ");let z={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(z.props,t.label);let _={tagName:"li",props:{className:`group ${n}`.trim()},children:[{tagName:"label",props:{className:`optgroup${this.options.single||t.disabled?" disabled":""}`},children:[Z,z]}]},U=this.options.cssStyler(t),K=String(this.options.styler(t)||"");return K&&(_.props.style=B(K)),U&&(_.props.style=U),M.push(_),t.children.forEach(Q=>M.push(...this.initListItem(Q,1))),M}if(n+=t.classes||"",e&&this.options.single&&(n+=`option-level-${e} `),t.divider)return[{tagName:"li",props:{className:"option-divider"}}];let a=l||n?(l+n).trim():"",c=`${t.disabled?"disabled":""}`,r={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(r.props,t.text);let p={tagName:"input",props:{type:i,value:encodeURI(t.value),dataset:{key:t._key,name:this.selectItemName},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:!!t.disabled}};t.selected&&(p.attrs={checked:"checked"});let E={tagName:"li",props:{className:a,title:s},children:[{tagName:"label",props:{className:c},children:[p,r]}]},S=this.options.cssStyler(t),q=String(this.options.styler(t)||"");return q&&(E.props.style=B(q)),S&&(E.props.style=S),[E]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let l=s.children.filter(i=>i&&i.selected&&!i.disabled&&i.visible).length;s.children.length&&(s.selected=!this.options.single&&l&&l===s.children.filter(i=>i&&!i.disabled&&i.visible&&!i.divider).length),e+=l}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=y(this.dropElm,"outer","width")+20)):t=y(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.closeSearchElm=this.filterParentElm?.querySelector(".icon-close"),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[data-name="${this.selectAllName}"]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectGroupName}"],span[data-name="${this.selectGroupName}"]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.closeSearchElm&&this._bindEventService.bind(this.closeSearchElm,"click",e=>{e.preventDefault(),this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];this.selectItemElms?.forEach(l=>{l.closest("li")?.style.display!=="none"&&s.push(l)}),s.length&&s[0].hasAttribute("data-name")&&this.setSelects([s[0].value])}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,l=s.checked,i=f(this.data,"_key",s.dataset.key);this._checkGroup(i,l),this.options.onOptgroupClick(C({label:i.label,selected:i.selected,data:i._data,children:i.children.map(n=>{if(n)return C({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,l=s.checked,i=f(this.data,"_key",s.dataset.key),n=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(i)===!1){n();return}this._check(i,l),this.options.onClick(C({text:i.text,value:i.value,selected:i.selected,data:i._data})),n()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.getDataLength()||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let i=L(this.dropElm),n;this.options.container instanceof Node?n=this.options.container:typeof this.options.container=="string"&&(n=this.options.container==="body"?document.body:document.querySelector(this.options.container)),n.appendChild(this.dropElm),this.dropElm.style.top=`${i?.top??0}px`,this.dropElm.style.left=`${i?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${y(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;this.options.maxHeightUnit==="row"&&(e=y(this.dropElm.querySelector("ul>li"),"outer","height")*this.options.maxHeight);let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(i=>i.style.width=`${this.options.multipleWidth}px`),this.getDataLength()&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:i,top:n}=D(this.dropElm),a=this.dropElm.getBoundingClientRect().height;l=i<a&&n>i?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}applyAsTextOrHtmlWhenEnabled(t,e){t||(t={}),this.isRenderAsHtml?t.innerHTML=typeof this.options.sanitizer=="function"?this.options.sanitizer(e):e:t.textContent=e}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let l=this.choiceElm?.querySelector("span"),i=e.length,n=null,a=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?W(r):r}return s.join(this.options.displayDelimiter)};if(l){if(i===0){let r=this.options.placeholder||"";l.classList.add("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,r)}else i<this.options.minimumCountSelected?n=a():this.formatAllSelected()&&i===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&i>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(i,this.dataTotal)&&i>this.options.minimumCountSelected?n=this.formatCountSelected(i,this.dataTotal):n=a();if(n!==null&&(l?.classList.remove("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,n)),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was deprecated and replaced by `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";l.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(p=>p===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(t){for(let s=this.updateDataStart;s<this.updateDataEnd;s++){let l=this.updateData[s],i=this.dropElm.querySelector(`input[data-key=${l._key}]`);if(i){i.checked=l.selected;let n=i.closest("li");n&&(l.selected&&!n.classList.contains("selected")?n.classList.add("selected"):l.selected||n.classList.remove("selected"))}}let e=this.data?.filter(s=>s.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,w(this.selectAllElm.closest("li"),!e)),w(this.noResultsElm,e),this.virtualScroll&&(this.virtualScroll.rows=t??this.getListRows())}getData(){return this.options.data}getDataLength(){return this.data?.length??0}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?v(e):this.options}refreshOptions(t){R(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let l=s.children.filter(i=>i?.selected);if(!l.length)continue;if(t==="value"||this.options.single)e.push(...l.map(i=>t==="value"&&i._value||i[t]));else{let i=[];i.push("["),i.push(s.label),i.push(`: ${l.map(n=>n[t]).join(", ")}`),i.push("]"),e.push(i.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let l=!1,i=n=>{for(let a of n){let c=!1;if(e==="text"){let r=document.createElement("div");this.applyAsTextOrHtmlWhenEnabled(r,a.text),c=t.includes(r.textContent?.trim()??"")}else c=t.includes(a._value||a.value),!c&&a.value===`${+a.value}`&&(c=t.includes(+a.value));a.selected!==c&&(l=!0),a.selected=c}};for(let n of this.data||[])n.type==="optgroup"?i(n.children):i([n]);l&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=f(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=f(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(l=>{l&&!l.disabled&&!l.divider&&(s||l.visible)&&(l.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText===s)return;this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let n=`${i?.label??""}`;if(i!=null){let a=this.options.customFilter({label:m(n.toLowerCase()),search:m(s),originalLabel:n,originalSearch:e,row:i});i.visible=a;for(let c of i.children)c&&(c.visible=a)}}else{for(let n of i.children)if(n!=null){let a=`${n?.text??""}`;n.visible=this.options.customFilter({text:m(a.toLowerCase()),search:m(s),originalText:a,originalSearch:e,row:n,parent:i})}i.visible=i.children.filter(n=>n?.visible).length>0}else{let n=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(n.toLowerCase()),search:m(s),originalText:n,originalSearch:e,row:i})}let l=this.initListItems();this.initSelected(t),this.updateSelected(l),t||this.options.onFilter(e)}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,l=this.okButtonElm?.getBoundingClientRect().height??0,i=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+l+i+5,{bottom:a,top:c}=D(this.parentElm),r=this.options.maxHeight;if(e?r=a-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let p=this.dropElm?.querySelector("ul");return p&&(p.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:l}=D(this.dropElm),{top:i,left:n}=L(this.parentElm),a=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,p=this.parentElm.getBoundingClientRect().width;if(s>a)e="bottom";else if(a>s&&l>s){if(this.options.container){let E=i-a;E<0&&(E=0),(E>0||t)&&(e="top",this.dropElm.style.top=`${E<0?0:E}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}r-c<n&&(this.dropElm.style.left=`${n-(c-p)}px`)}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),l=this.dropElm.querySelector("ul"),i=26,n=s?.clientWidth??0+i,c=l.scrollHeight>l.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(p=>{p.scrollWidth>r&&(r=p.scrollWidth)}),r+=i+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let l=s.offsetWidth;return t.parentNode?.removeChild(t),e-l}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var O=function(o,t){return typeof o=="string"?G(document.querySelectorAll(o),t):o instanceof Node?G([o],t):G(o,t)};function G(o,t){let e=Array.from(o),s=[];for(let l=0;l<e.length;l++){let i=e[l];try{i._multipleSelect!==void 0&&(i._multipleSelect.destroy(),delete i._multipleSelect),i._multipleSelect=new H(i,t||{}),i._multipleSelect.init();let n=i._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete i._multipleSelect,n.onAfterHardDestroyed=()=>s[l]=null,s.push(i._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}O.defaults=d.DEFAULTS;O.locales={...x};O.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=O);return nt(ht);})();
//# sourceMappingURL=multiple-select.js.map

23

dist/types/interfaces/interfaces.d.ts

@@ -0,1 +1,3 @@

/// <reference types="trusted-types" />
export type InferDOMType<T> = T extends CSSStyleDeclaration ? Partial<CSSStyleDeclaration> : T extends infer R ? R : any;
export type OptionDataObject = {

@@ -7,5 +9,12 @@ [value: string]: number | string | boolean;

}
export interface HtmlStruct {
tagName: keyof HTMLElementTagNameMap;
props?: any;
attrs?: Record<any, string>;
children?: HtmlStruct[];
}
export interface OptionRowData {
text: string;
value: string | number | boolean;
classes?: string;
divider?: string;

@@ -15,3 +24,7 @@ disabled?: boolean;

visible?: boolean | string;
title?: string;
type?: 'option' | 'optgroup';
_data?: {
divider?: string;
};
_key?: string;

@@ -25,8 +38,14 @@ _value?: string | number | boolean;

}
export interface VirtualCache {
bottom: number;
data: HtmlStruct[];
scrollTop: number;
top: number;
}
export interface VirtualScrollOption {
rows: string[];
rows: HtmlStruct[];
scrollEl: HTMLElement;
contentEl: HTMLElement;
callback: () => void;
sanitizer?: (dirtyHtml: string) => string;
sanitizer?: (html: string) => string | TrustedHTML;
}

@@ -33,0 +52,0 @@ export interface MultipleSelectLocale {

@@ -0,1 +1,2 @@

/// <reference types="trusted-types" />
import { LabelFilter, MultipleSelectLocale, OptGroupRowData, OptionRowData, OptionRowDivider, TextFilter } from './interfaces';

@@ -8,2 +9,4 @@ export interface MultipleSelectView {

}
export type CSSStyleDeclarationReadonly = 'length' | 'parentRule' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty';
export type CSSStyleDeclarationWritable = keyof Omit<CSSStyleDeclaration, CSSStyleDeclarationReadonly>;
export interface MultipleSelectOption extends MultipleSelectLocale {

@@ -14,3 +17,3 @@ /** @deprecated @alias `displayTitle` Add a title. By default this option is set to false. */

adjustedHeightPadding: number;
/** Use optional string to override "All selected" text instead of `formatAllSelected()`, the latter should be prefered */
/** Use optional string to override "All selected" text instead of `formatAllSelected()`, the latter should be preferred */
allSelectedText?: string;

@@ -29,3 +32,3 @@ /** Auto-adjust the Drop menu height to fit with available space */

container?: string | HTMLElement | null;
/** Use optional string to override selected count text "# of % selected" instead of `formatCountSelected()`, the latter should be prefered */
/** Use optional string to override selected count text "# of % selected" instead of `formatCountSelected()`, the latter should be preferred */
countSelectedText?: string;

@@ -87,5 +90,5 @@ /** provide custom data */

name?: string;
/** Use optional string to override text when filtering "No matches found" instead of `formatNoMatchesFound()`, the latter should be prefered */
/** Use optional string to override text when filtering "No matches found" instead of `formatNoMatchesFound()`, the latter should be preferred */
noMatchesFoundText?: string;
/** Use optional string to override "OK" button text instead of `formatOkButton()`, the latter should be prefered */
/** Use optional string to override "OK" button text instead of `formatOkButton()`, the latter should be preferred */
okButtonText?: string;

@@ -102,3 +105,3 @@ /** Should we open the dropdown while hovering the select? */

selectAll?: boolean;
/** Use optional string to override "Select All" checkbox text instead of `formatSelectAll()`, the latter should be prefered */
/** Use optional string to override "Select All" checkbox text instead of `formatSelectAll()`, the latter should be preferred */
selectAllText?: string;

@@ -113,2 +116,4 @@ /** Whether or not Multiple Select allows you to select only one option.By default this option is set to false. */

showClear?: boolean;
/** Show a clear button on the filter search input, defaults to false */
showSearchClear?: boolean;
/** Display the OK button at bottom of the list when using multiple selection to easily close the drop, defaults to false. */

@@ -124,8 +129,10 @@ showOkButton?: boolean;

customFilter(options: LabelFilter | TextFilter): boolean;
/** The item styler function, return style string to custom the item style such as background: red. The function take one parameter: value. */
/** The item styler function, return style string to customize the item style such as background: red. The function take one parameter: value. */
cssStyler: (value: OptionRowData | OptGroupRowData) => CSSStyleDeclaration | null;
/** @deprecated @use `cssStyler`. The item styler function, return style string to customize the item style such as background: red. The function take one parameter: value. */
styler: (value: OptionRowData | OptGroupRowData) => string | boolean | null;
/** Returns HTML label attribute of a DOM element */
labelTemplate: (elm: any) => string;
/** Returns HTML text template of a DOM element */
textTemplate: (elm: any) => string;
labelTemplate: (elm: HTMLOptionElement) => string;
/** Returns HTML text template of a DOM element as a string */
textTemplate: (elm: HTMLOptionElement) => string;
/** Fires after the multiple-select DOM element is created. */

@@ -174,4 +181,4 @@ onAfterCreate: () => void;

*/
sanitizer?: (dirtyHtml: string) => string;
sanitizer?: (html: string) => string | TrustedHTML;
}
//# sourceMappingURL=multipleSelectOption.interface.d.ts.map
import type { MultipleSelectOption } from './interfaces/multipleSelectOption.interface';
import type { MultipleSelectLocales, OptGroupRowData, OptionRowData } from './interfaces';
import type { HtmlStruct, MultipleSelectLocales, OptGroupRowData, OptionRowData } from './interfaces';
import { BindingEventService, VirtualScroll } from './services';

@@ -11,2 +11,3 @@ export declare class MultipleSelectInstance {

protected closeElm?: HTMLElement | null;
protected closeSearchElm?: HTMLElement | null;
protected filterText: string;

@@ -38,2 +39,3 @@ protected updateData: any[];

locales: MultipleSelectLocales;
get isRenderAsHtml(): boolean | undefined;
constructor(elm: HTMLSelectElement, options?: Partial<Omit<MultipleSelectOption, 'onHardDestroy' | 'onAfterHardDestroy'>>);

@@ -49,9 +51,9 @@ init(): void;

protected initData(): void;
protected initRow(elm: HTMLOptionElement, groupDisabled?: boolean): any;
protected initRow(elm: HTMLOptionElement, groupDisabled?: boolean): OptionRowData | OptGroupRowData | null;
protected initDrop(): void;
protected initFilter(): void;
protected initList(): void;
protected initListItems(): void;
protected getListRows(): string[];
protected initListItem(row: any, level?: number): string[] | "<li class=\"option-divider\"/>";
protected initListItems(): HtmlStruct[];
protected getListRows(): HtmlStruct[];
protected initListItem(row: OptionRowData | OptGroupRowData, level?: number): HtmlStruct[];
protected initSelected(ignoreTrigger?: boolean): void;

@@ -68,7 +70,14 @@ protected initView(): void;

close(): void;
/**
* apply value to an HTML element as text or as HTML with innerHTML when enabled
* @param elm
* @param value
*/
protected applyAsTextOrHtmlWhenEnabled(elmOrProp: HTMLElement | any, value: string): void;
protected update(ignoreTrigger?: boolean): void;
protected updateSelected(): void;
protected updateSelected(rows?: HtmlStruct[]): void;
getData(): {
[value: string]: string | number | boolean;
} | (string | number | boolean | import("./interfaces").OptionRowDivider | OptionRowData | OptGroupRowData)[] | undefined;
getDataLength(): number;
/**

@@ -75,0 +84,0 @@ * Get current options, by default we'll return an immutable deep copy of the options to avoid conflicting with the lib

@@ -1,8 +0,8 @@

import { VirtualScrollOption } from '../interfaces';
import { HtmlStruct, VirtualCache, VirtualScrollOption } from '../interfaces';
export declare class VirtualScroll {
cache: any;
cache: VirtualCache;
clusterRows?: number;
dataStart: number;
dataEnd: number;
rows: string[];
rows: HtmlStruct[];
scrollEl: HTMLElement;

@@ -20,14 +20,14 @@ blockHeight?: number;

constructor(options: VirtualScrollOption);
initDOM(rows: string[]): void;
initDOM(rows: HtmlStruct[]): void;
getRowsHeight(): void;
getNum(): number;
initData(rows: string[], num: number): {
initData(rows: HtmlStruct[], num: number): {
topOffset: number;
bottomOffset: number;
rowsAbove: number;
rows: string[];
rows: HtmlStruct[];
};
checkChanges(type: string, value: number | string): boolean;
getExtra(className: string, height: number): string;
checkChanges<T extends keyof VirtualCache>(type: T, value: VirtualCache[T]): boolean;
getExtra(className: string, height: number): HTMLLIElement;
}
//# sourceMappingURL=virtual-scroll.d.ts.map

@@ -1,3 +0,2 @@

export type InferType<T> = T extends infer R ? R : any;
export type InferDOMType<T> = T extends CSSStyleDeclaration ? Partial<CSSStyleDeclaration> : T extends infer R ? R : any;
import { HtmlStruct, InferDOMType } from '../interfaces';
export interface HtmlElementPosition {

@@ -9,2 +8,3 @@ top: number;

}
export declare function convertStringStyleToElementStyle(styleStr: string): CSSStyleDeclaration;
/** calculate available space for each side of the DOM element */

@@ -30,2 +30,16 @@ export declare function calculateAvailableSpace(element: HTMLElement): {

}, appendToParent?: HTMLElement): HTMLElementTagNameMap[T];
/**
* From an HtmlBlock, create the DOM structure and append it to dedicated DOM element, for example:
* `{ tagName: 'li', props: { className: 'some-class' }, attrs: { 'aria-label': 'some label' }, children: [] }`
* @param item
* @param appendToElm
*/
export declare function createDomStructure(item: HtmlStruct, appendToElm?: HTMLElement, parentElm?: HTMLElement): HTMLElement;
/** takes an html block object and converts to a real HTMLElement */
export declare function convertItemRowToHtml(item: HtmlStruct): HTMLElement;
/**
* Empty a DOM element by removing all of its DOM element children leaving with an empty element (basically an empty shell)
* @return {object} element - updated element
*/
export declare function emptyElement<T extends Element = Element>(element?: T | null): T | undefined | null;
/** Get HTML element offset with pure JS */

@@ -44,10 +58,2 @@ export declare function getElementOffset(element?: HTMLElement): HtmlElementPosition | undefined;

export declare function insertAfter(referenceNode: HTMLElement, newNode: HTMLElement): void;
/**
* HTML encode using a plain <div>
* Create a in-memory div, set it's inner text(which a div can encode)
* then grab the encoded contents back out. The div never exists on the page.
* @param {String} inputValue - input value to be encoded
* @return {String}
*/
export declare function htmlEncode(inputValue: string): string;
/** Display or hide matched element */

@@ -54,0 +60,0 @@ export declare function toggleElement(elm?: HTMLElement | null, display?: boolean): void;

@@ -10,7 +10,10 @@ /** Compare two objects */

export declare function deepCopy(objectOrArray: any | any[]): any | any[];
export declare function isDefined(val: any): boolean;
export declare function objectRemoveEmptyProps(obj: any): any;
export declare function setDataKeys(data: any[]): number;
export declare function findByParam(data: any, param: any, value: any): any;
export declare function stripScripts(str: string): string;
export declare function stripScripts(dirtyHtml: string): string;
export declare function removeUndefined(obj: any): any;
export declare function toCamelCase(str: string): string;
export declare function removeDiacritics(str: string): string;
//# sourceMappingURL=utils.d.ts.map
{
"name": "multiple-select-vanilla",
"version": "0.5.0",
"version": "0.6.0",
"exports": {

@@ -48,3 +48,3 @@ ".": {

},
"gitHead": "5c6b2b3003fc001bbdf47d26e24e656a8cd0e033"
"gitHead": "c90b9c116decc269affd3793827b81e08a88ddef"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc