treeselectjs 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,8 +30,8 @@ import Treeselect from 'treeselectjs'
30
30
 
31
31
  Import treeselectjs (UMD)
32
32
  ```
33
- <script src="https://cdn.jsdelivr.net/npm/treeselectjs@0.12.2/dist/treeselectjs.umd.js"></script>
34
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/treeselectjs@0.12.2/dist/treeselectjs.css" />
33
+ <script src="https://cdn.jsdelivr.net/npm/treeselectjs@0.12.3/dist/treeselectjs.umd.js"></script>
34
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/treeselectjs@0.12.3/dist/treeselectjs.css" />
35
35
  ...
36
36
  <script>
37
37
  ...
@@ -561,7 +561,7 @@ Je = function(e, t) {
561
561
  return s.append(i, a), s;
562
562
  }, at = function(e) {
563
563
  const t = document.createElement("div");
564
- return Es(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, d, ot).call(this, t), !0), t.addEventListener("mouseout", () => o(this, d, rt).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, d, ct).call(this, s, e)), t;
564
+ return t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), Es(t, e.htmlAttr), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, d, ot).call(this, t), !0), t.addEventListener("mouseout", () => o(this, d, rt).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, d, ct).call(this, s, e)), t;
565
565
  }, ot = function(e) {
566
566
  n(this, D) && o(this, d, ce).call(this, !0, e);
567
567
  }, rt = function(e) {
@@ -1 +1 @@
1
- (function(C,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(C=typeof globalThis<"u"?globalThis:C||self,C.Treeselect=p())})(this,function(){"use strict";var ys=Object.defineProperty;var Ie=C=>{throw TypeError(C)};var xs=(C,p,w)=>p in C?ys(C,p,{enumerable:!0,configurable:!0,writable:!0,value:w}):C[p]=w;var r=(C,p,w)=>xs(C,typeof p!="symbol"?p+"":p,w),ce=(C,p,w)=>p.has(C)||Ie("Cannot "+w);var n=(C,p,w)=>(ce(C,p,"read from private field"),w?w.call(C):p.get(C)),g=(C,p,w)=>p.has(C)?Ie("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(C):p.set(C,w),k=(C,p,w,X)=>(ce(C,p,"write to private field"),X?X.call(C,w):p.set(C,w),w),o=(C,p,w)=>(ce(C,p,"access private method"),w);var V,_,M,A,h,Pe,Y,Be,Ve,K,j,De,He,Ge,Fe,Me,qe,je,Re,$e,We,Ue,ze,Ye,Ke,Xe,Je,he,q,H,T,W,d,Ze,Qe,et,tt,st,it,de,lt,nt,at,ue,ot,rt,ct,ht,dt,ut,pt,mt,ft,Ct,bt,pe,se,me,gt,f,b,R,U,$,O,I,N,G,c,fe,Ce,kt,wt,Et,vt,Lt,yt,be,xt,St,_t,At,ge,Nt,ie,ke,le,Tt,we,Ot,It,Pt,Bt,Vt;const C={arrowUp:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 15l-6-6-6 6"/></svg>',arrowDown:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>',arrowRight:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>',attention:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',clear:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',cross:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',check:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',partialCheck:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>'},p=(l,e)=>{if(e.innerHTML="",typeof l=="string")e.innerHTML=l;else{const t=l.cloneNode(!0);e.appendChild(t)}},w=l=>{const e=l?{...l}:{};return Object.keys(C).forEach(t=>{e[t]||(e[t]=C[t])}),e},X=l=>l.reduce((e,{name:t},s)=>(e+=t,s<l.length-1&&(e+=", "),e),"");class Dt{constructor({value:e,showTags:t,tagsCountText:s,clearable:i,isAlwaysOpened:a,searchable:u,placeholder:m,disabled:L,isSingleSelect:E,id:v,ariaLabel:y,iconElements:x,inputCallback:S,searchCallback:P,openCallback:D,closeCallback:F,keydownCallback:z,focusCallback:te,blurCallback:oe,nameChangeCallback:re}){g(this,h);r(this,"value");r(this,"showTags");r(this,"tagsCountText");r(this,"clearable");r(this,"isAlwaysOpened");r(this,"searchable");r(this,"placeholder");r(this,"disabled");r(this,"isSingleSelect");r(this,"id");r(this,"ariaLabel");r(this,"iconElements");r(this,"isOpened");r(this,"searchText");r(this,"srcElement");g(this,V);g(this,_);g(this,M);g(this,A);r(this,"inputCallback");r(this,"searchCallback");r(this,"openCallback");r(this,"closeCallback");r(this,"keydownCallback");r(this,"focusCallback");r(this,"blurCallback");r(this,"nameChangeCallback");this.value=e,this.showTags=t,this.tagsCountText=s,this.searchable=u,this.placeholder=m,this.clearable=i,this.isAlwaysOpened=a,this.disabled=L,this.isSingleSelect=E,this.id=v,this.ariaLabel=y,this.iconElements=x,this.isOpened=!1,this.searchText="",k(this,V,o(this,h,Ge).call(this)),k(this,_,o(this,h,$e).call(this)),k(this,M,o(this,h,ze).call(this)),k(this,A,null),this.inputCallback=S,this.searchCallback=P,this.openCallback=D,this.closeCallback=F,this.keydownCallback=z,this.focusCallback=te,this.blurCallback=oe,this.nameChangeCallback=re,this.srcElement=o(this,h,De).call(this,n(this,V),n(this,_),n(this,M)),o(this,h,Pe).call(this)}focus(){setTimeout(()=>n(this,_).focus(),0)}blur(){this.isOpened&&o(this,h,j).call(this),this.clearSearch(),n(this,_).blur()}updateValue(e){this.value=e,o(this,h,Y).call(this),o(this,h,K).call(this)}removeItem(e){this.value=this.value.filter(t=>t.id!==e),o(this,h,he).call(this),o(this,h,Y).call(this),o(this,h,K).call(this)}clear(){this.value=[],o(this,h,he).call(this),o(this,h,Y).call(this),this.clearSearch()}openClose(){o(this,h,j).call(this)}clearSearch(){this.searchText="",this.searchCallback(""),o(this,h,K).call(this)}}V=new WeakMap,_=new WeakMap,M=new WeakMap,A=new WeakMap,h=new WeakSet,Pe=function(){o(this,h,Y).call(this),o(this,h,K).call(this),o(this,h,Be).call(this)},Y=function(){if(n(this,V).innerHTML="",this.showTags){n(this,V).append(...o(this,h,Fe).call(this));const e=X(this.value);this.nameChangeCallback(e)}else{const e=o(this,h,Re).call(this);n(this,V).appendChild(e),this.nameChangeCallback(e.innerText)}n(this,V).appendChild(n(this,_))},Be=function(){const e=[];n(this,M).innerHTML="",this.clearable&&e.push(o(this,h,Ye).call(this)),this.isAlwaysOpened||e.push(o(this,h,Xe).call(this,this.isOpened)),e.length&&n(this,M).append(...e)},Ve=function(){if(!this.isAlwaysOpened&&n(this,A)){const e=this.isOpened?this.iconElements.arrowUp:this.iconElements.arrowDown;p(e,n(this,A))}},K=function(){var e;(e=this.value)!=null&&e.length?(n(this,_).removeAttribute("placeholder"),this.srcElement.classList.remove("treeselect-input--value-not-selected")):(n(this,_).setAttribute("placeholder",this.placeholder),this.srcElement.classList.add("treeselect-input--value-not-selected")),this.searchable?this.srcElement.classList.remove("treeselect-input--unsearchable"):this.srcElement.classList.add("treeselect-input--unsearchable"),this.isSingleSelect?this.srcElement.classList.add("treeselect-input--is-single-select"):this.srcElement.classList.remove("treeselect-input--is-single-select"),n(this,_).value=this.searchText},j=function(){this.isOpened=!this.isOpened,o(this,h,Ve).call(this),this.isOpened?this.openCallback():this.closeCallback()},De=function(e,t,s){const i=document.createElement("div");return i.classList.add("treeselect-input"),i.setAttribute("tabindex","-1"),i.addEventListener("mousedown",a=>o(this,h,He).call(this,a)),i.addEventListener("focus",()=>this.focusCallback(),!0),i.addEventListener("blur",()=>this.blurCallback(),!0),e.appendChild(t),i.append(e,s),i},He=function(e){e.stopPropagation(),this.isOpened||o(this,h,j).call(this),this.focus()},Ge=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__tags"),e},Fe=function(){return this.value.map(e=>{const t=document.createElement("div");t.classList.add("treeselect-input__tags-element"),t.setAttribute("tabindex","-1"),t.setAttribute("tag-id",e.id.toString()),t.setAttribute("title",e.name);const s=o(this,h,qe).call(this,e.name),i=o(this,h,je).call(this);return t.addEventListener("mousedown",a=>o(this,h,Me).call(this,a,e.id)),t.append(s,i),t})},Me=function(e,t){e.preventDefault(),e.stopPropagation(),this.removeItem(t),this.focus()},qe=function(e){const t=document.createElement("span");return t.classList.add("treeselect-input__tags-name"),t.textContent=e,t},je=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__tags-cross"),p(this.iconElements.cross,e),e},Re=function(){const e=document.createElement("span");if(e.classList.add("treeselect-input__tags-count"),!this.value.length)return e.textContent="",e.setAttribute("title",""),e;const t=this.value.length===1?this.value[0].name:`${this.value.length} ${this.tagsCountText}`;return e.textContent=t,e.setAttribute("title",t),e},$e=function(){const e=document.createElement("input");return e.classList.add("treeselect-input__edit"),this.id&&e.setAttribute("id",this.id),(!this.searchable||this.disabled)&&e.setAttribute("readonly","readonly"),this.disabled&&e.setAttribute("tabindex","-1"),this.ariaLabel.length&&e.setAttribute("aria-label",this.ariaLabel),e.addEventListener("keydown",t=>o(this,h,We).call(this,t)),e.addEventListener("input",t=>o(this,h,Ue).call(this,t,e)),e},We=function(e){e.stopPropagation();const t=e.key;t==="Backspace"&&!this.searchText.length&&this.value.length&&!this.showTags&&this.clear(),t==="Backspace"&&!this.searchText.length&&this.value.length&&this.removeItem(this.value[this.value.length-1].id),e.code==="Space"&&(!this.searchText||!this.searchable)&&o(this,h,j).call(this),(t==="Enter"||t==="ArrowDown"||t==="ArrowUp")&&e.preventDefault(),this.keydownCallback(e),t!=="Tab"&&this.focus()},Ue=function(e,t){e.stopPropagation();const s=this.searchText,i=t.value.trim();if(s.length===0&&i.length===0){t.value="";return}if(this.searchable){const a=e.target.value;this.searchCallback(a),this.isOpened||o(this,h,j).call(this)}else t.value="";this.searchText=t.value},ze=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__operators"),e},Ye=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__clear"),e.setAttribute("tabindex","-1"),p(this.iconElements.clear,e),e.addEventListener("mousedown",t=>o(this,h,Ke).call(this,t)),e},Ke=function(e){e.preventDefault(),e.stopPropagation(),(this.searchText.length||this.value.length)&&this.clear(),this.focus()},Xe=function(e){k(this,A,document.createElement("span")),n(this,A).classList.add("treeselect-input__arrow");const t=e?this.iconElements.arrowUp:this.iconElements.arrowDown;return p(t,n(this,A)),n(this,A).addEventListener("mousedown",s=>o(this,h,Je).call(this,s)),n(this,A)},Je=function(e){e.stopPropagation(),e.preventDefault(),this.focus(),o(this,h,j).call(this)},he=function(){this.inputCallback(this.value)};const Ee=(l,e,t,s)=>{Mt(e);const i=e.filter(a=>!a.disabled&&l.some(u=>u===a.id));if(t&&i.length){i[0].checked=!0;return}i.forEach(a=>{a.checked=!0;const u=ne(a,e,s);a.checked=u})},ne=({id:l,checked:e},t,s)=>{const i=t.find(u=>u.id===l);if(!i)return!1;if(s)return i.checked=i.disabled?!1:!!e,i.checked;const a=ve(!!e,i,t);return Le(i,t),a},ve=(l,e,t)=>{if(!e.isGroup)return e.checked=e.disabled?!1:!!l,e.isPartialChecked=!1,e.checked;const s=t.filter(m=>m.childOf===e.id);return!l||e.disabled||e.isPartialChecked?(e.checked=!1,e.isPartialChecked=!1,ae(e,s,t),e.checked):ye(s,t)?xe(s)?(e.checked=!1,e.isPartialChecked=!1,e.disabled=!0,e.checked):(e.checked=!1,e.isPartialChecked=!0,s.forEach(m=>{ve(l,m,t)}),e.checked):(e.checked=!0,e.isPartialChecked=!1,ae(e,s,t),e.checked)},Le=(l,e)=>{const t=e.find(s=>s.id===l.childOf);t&&(Ht(t,e),Le(t,e))},Ht=(l,e)=>{const t=J(l,e);if(xe(t)){l.checked=!1,l.isPartialChecked=!1,l.disabled=!0;return}if(Gt(t)){l.checked=!0,l.isPartialChecked=!1;return}if(Ft(t)){l.checked=!1,l.isPartialChecked=!0;return}l.checked=!1,l.isPartialChecked=!1},ae=({checked:l,disabled:e},t,s)=>{t.forEach(i=>{i.disabled=!!e||!!i.disabled,i.checked=!!l&&!i.disabled,i.isPartialChecked=!1;const a=J(i,s);ae({checked:l,disabled:e},a,s)})},ye=(l,e)=>l.some(i=>i.disabled)?!0:l.some(i=>{if(i.isGroup){const a=J(i,e);return ye(a,e)}return!1}),xe=l=>l.every(e=>!!e.disabled),Gt=l=>l.every(e=>!!e.checked),Ft=l=>l.some(e=>!!e.checked||!!e.isPartialChecked),Mt=l=>{l.forEach(e=>{e.checked=!1,e.isPartialChecked=!1})},qt=(l,e,t)=>{const s={level:0,groupId:""},i=Se(l,e,s.groupId,s.level);return Rt(i,t)},Se=(l,e,t,s)=>l.reduce((i,a)=>{var E;const u=!!((E=a.children)!=null&&E.length),m=s>=e&&u,L=s>e;if(i.push({id:a.value,name:a.name,childOf:t,isGroup:u,checked:!1,isPartialChecked:!1,level:s,isClosed:m,hidden:L,disabled:a.disabled??!1}),u){const v=Se(a.children,e,a.value,s+1);i.push(...v)}return i},[]),J=({id:l},e)=>e.filter(t=>t.childOf===l),jt=l=>{const{ungroupedNodes:e,allGroupedNodes:t,allNodes:s}=l.reduce((a,u)=>(u.checked&&(a.allNodes.push(u),u.isGroup?a.allGroupedNodes.push(u):a.ungroupedNodes.push(u)),a),{ungroupedNodes:[],allGroupedNodes:[],allNodes:[]}),i=s.filter(a=>!t.some(({id:u})=>u===a.childOf));return{ungroupedNodes:e,groupedNodes:i,allNodes:s}},Rt=(l,e)=>(l.filter(s=>!!s.disabled).forEach(({id:s})=>ne({id:s,checked:!1},l,e)),l),Z=(l,{id:e,isClosed:t})=>{J({id:e},l).forEach(i=>{i.hidden=t??!1,i.isGroup&&!i.isClosed&&Z(l,{id:i.id,isClosed:t})})},$t=l=>{l.filter(e=>e.isGroup&&!e.disabled&&(e.checked||e.isPartialChecked)).forEach(e=>{e.isClosed=!1,Z(l,e)})},Wt=(l,e)=>{const t=Ut(l,e);l.forEach(s=>{t.some(({id:a})=>a===s.id)?(s.isGroup&&(s.isClosed=!1,Z(l,s)),s.hidden=!1):s.hidden=!0})},Ut=(l,e)=>l.reduce((t,s)=>{if(s.name.toLowerCase().includes(e.toLowerCase())){if(t.push(s),s.isGroup){const a=_e(s.id,l);t.push(...a)}if(s.childOf){const a=Ae(s.childOf,l);t.push(...a)}}return t},[]),_e=(l,e)=>e.reduce((t,s)=>(s.childOf===l&&(t.push(s),s.isGroup&&t.push(..._e(s.id,e))),t),[]),Ae=(l,e)=>e.reduce((t,s)=>(s.id===l&&(t.push(s),s.childOf&&t.push(...Ae(s.childOf,e))),t),[]),zt=l=>{const{duplications:e}=l.reduce((t,s)=>(t.allItems.some(i=>i.toString()===s.id.toString())&&t.duplications.push(s.id),t.allItems.push(s.id),t),{duplications:[],allItems:[]});e.length&&console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`)},Yt=(l,e,t,s,i,a,u,m,L,E)=>{Ee(l,e,i,L),m&&u&&$t(e),Q(e,t,s,a,E)},Q=(l,e,t,s,i)=>{l.forEach(a=>{const u=e.querySelector(`[input-id="${a.id}"]`),m=B(u);u.checked=a.checked,Kt(a,m,s),Xt(a,m),Jt(a,m),Zt(a,m,t),Qt(a,m),ts(a,m,l,i),es(a,u,t)}),ss(l,e)},Kt=(l,e,t)=>{l.checked?e.classList.add("treeselect-list__item--checked"):e.classList.remove("treeselect-list__item--checked"),Array.isArray(t)&&t[0]===l.id&&!l.disabled?e.classList.add("treeselect-list__item--single-selected"):e.classList.remove("treeselect-list__item--single-selected")},Xt=(l,e)=>{l.isPartialChecked?e.classList.add("treeselect-list__item--partial-checked"):e.classList.remove("treeselect-list__item--partial-checked")},Jt=(l,e)=>{l.disabled?e.classList.add("treeselect-list__item--disabled"):e.classList.remove("treeselect-list__item--disabled")},Zt=(l,e,t)=>{if(l.isGroup){const s=e.querySelector(".treeselect-list__item-icon"),i=l.isClosed?t.arrowRight:t.arrowDown;p(i,s),l.isClosed?e.classList.add("treeselect-list__item--closed"):e.classList.remove("treeselect-list__item--closed")}},Qt=(l,e)=>{l.hidden?e.classList.add("treeselect-list__item--hidden"):e.classList.remove("treeselect-list__item--hidden")},es=(l,e,t)=>{const i=e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");l.checked?p(t.check,i):l.isPartialChecked?p(t.partialCheck,i):i.innerHTML=""},ts=(l,e,t,s)=>{const i=l.level===0,a=20,u=5;if(i){const m=t.some(v=>v.isGroup&&v.level===l.level),L=!l.isGroup&&m?`${a}px`:`${u}px`,E=l.isGroup?"0":L;s?e.style.paddingRight=E:e.style.paddingLeft=E}else{const m=l.isGroup?`${l.level*a}px`:`${l.level*a+a}px`;s?e.style.paddingRight=m:e.style.paddingLeft=m}e.setAttribute("level",l.level.toString()),e.setAttribute("group",l.isGroup.toString())},ss=(l,e)=>{const t=l.some(i=>!i.hidden),s=e.querySelector(".treeselect-list__empty");t?s.classList.add("treeselect-list__empty--hidden"):s.classList.remove("treeselect-list__empty--hidden")},B=l=>l.parentNode.parentNode,Ne=(l,e)=>e.find(t=>t.id.toString()===l),is=l=>B(l).querySelector(".treeselect-list__item-icon"),ls=(l,e)=>{e&&Object.keys(e).forEach(t=>{const s=e[t];typeof s=="string"&&l.setAttribute(t,s)})};class ns{constructor({options:e,value:t,openLevel:s,listSlotHtmlComponent:i,tagsSortFn:a,emptyText:u,isSingleSelect:m,iconElements:L,showCount:E,disabledBranchNode:v,expandSelected:y,isIndependentNodes:x,rtl:S,listClassName:P,inputCallback:D,arrowClickCallback:F,mouseupCallback:z}){g(this,d);r(this,"options");r(this,"value");r(this,"openLevel");r(this,"listSlotHtmlComponent");r(this,"tagsSortFn");r(this,"emptyText");r(this,"isSingleSelect");r(this,"showCount");r(this,"disabledBranchNode");r(this,"expandSelected");r(this,"isIndependentNodes");r(this,"rtl");r(this,"listClassName");r(this,"iconElements");r(this,"searchText");r(this,"flattedOptions");r(this,"flattedOptionsBeforeSearch");r(this,"selectedNodes");r(this,"srcElement");r(this,"inputCallback");r(this,"arrowClickCallback");r(this,"mouseupCallback");g(this,q,null);g(this,H,!0);g(this,T,[]);g(this,W,!0);this.options=e,this.value=t,this.openLevel=s??0,this.listSlotHtmlComponent=i??null,this.tagsSortFn=a??null,this.emptyText=u??"No results found...",this.isSingleSelect=m??!1,this.showCount=E??!1,this.disabledBranchNode=v??!1,this.expandSelected=y??!1,this.isIndependentNodes=x??!1,this.rtl=S??!1,this.listClassName=P??"",this.iconElements=L,this.searchText="",this.flattedOptions=qt(this.options,this.openLevel,this.isIndependentNodes),this.flattedOptionsBeforeSearch=this.flattedOptions,this.selectedNodes={nodes:[],groupedNodes:[],allNodes:[]},this.srcElement=o(this,d,et).call(this),this.inputCallback=D,this.arrowClickCallback=F,this.mouseupCallback=z,zt(this.flattedOptions)}updateValue(e){this.value=e,k(this,T,this.isSingleSelect?this.value:[]),Yt(e,this.flattedOptions,this.srcElement,this.iconElements,this.isSingleSelect,n(this,T),this.expandSelected,n(this,W),this.isIndependentNodes,this.rtl),k(this,W,!1),o(this,d,me).call(this)}updateSearchValue(e){if(e===this.searchText)return;const t=this.searchText===""&&e!=="";this.searchText=e,t&&(this.flattedOptionsBeforeSearch=JSON.parse(JSON.stringify(this.flattedOptions))),this.searchText===""&&(this.flattedOptions=this.flattedOptionsBeforeSearch.map(s=>{const i=this.flattedOptions.find(a=>a.id===s.id);return i.isClosed=s.isClosed,i.hidden=s.hidden,i}),this.flattedOptionsBeforeSearch=[]),this.searchText&&Wt(this.flattedOptions,e),Q(this.flattedOptions,this.srcElement,this.iconElements,n(this,T),this.rtl),this.focusFirstListElement()}callKeyAction(e){k(this,H,!1);const t=this.srcElement.querySelector(".treeselect-list__item--focused");if(t==null?void 0:t.classList.contains("treeselect-list__item--hidden"))return;const i=e.key;i==="Enter"&&t&&t.dispatchEvent(new Event("mousedown")),(i==="ArrowLeft"||i==="ArrowRight")&&o(this,d,Ze).call(this,t,e),(i==="ArrowDown"||i==="ArrowUp")&&o(this,d,Qe).call(this,t,i)}focusFirstListElement(){const e="treeselect-list__item--focused",t=this.srcElement.querySelector(`.${e}`),s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(B(a)).display!=="none");if(!s.length)return;t&&t.classList.remove(e),B(s[0]).classList.add(e)}isLastFocusedElementExist(){return!!n(this,q)}}q=new WeakMap,H=new WeakMap,T=new WeakMap,W=new WeakMap,d=new WeakSet,Ze=function(e,t){if(!e)return;const s=t.key,a=e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"),u=Ne(a,this.flattedOptions),m=e.querySelector(".treeselect-list__item-icon");s==="ArrowLeft"&&!u.isClosed&&u.isGroup&&(m.dispatchEvent(new Event("mousedown")),t.preventDefault()),s==="ArrowRight"&&u.isClosed&&u.isGroup&&(m.dispatchEvent(new Event("mousedown")),t.preventDefault())},Qe=function(e,t){var i;const s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(B(a)).display!=="none");if(s.length)if(!e)B(s[0]).classList.add("treeselect-list__item--focused");else{const a=s.findIndex(D=>B(D).classList.contains("treeselect-list__item--focused"));B(s[a]).classList.remove("treeselect-list__item--focused");const m=t==="ArrowDown"?a+1:a-1,L=t==="ArrowDown"?0:s.length-1,E=s[m]??s[L],v=!s[m],y=B(E);y.classList.add("treeselect-list__item--focused");const x=this.srcElement.getBoundingClientRect(),S=y.getBoundingClientRect();if(v&&t==="ArrowDown"){this.srcElement.scroll(0,0);return}if(v&&t==="ArrowUp"){this.srcElement.scroll(0,this.srcElement.scrollHeight);return}const P=((i=this.listSlotHtmlComponent)==null?void 0:i.clientHeight)??0;if(x.y+x.height<S.y+S.height+P){this.srcElement.scroll(0,this.srcElement.scrollTop+S.height);return}if(x.y>S.y){this.srcElement.scroll(0,this.srcElement.scrollTop-S.height);return}}},et=function(){const e=o(this,d,tt).call(this),t=o(this,d,de).call(this,this.options);e.append(...t);const s=o(this,d,nt).call(this);e.append(s);const i=o(this,d,lt).call(this);return i&&e.append(i),e},tt=function(){const e=document.createElement("div");return e.classList.add("treeselect-list"),this.listClassName.length>0&&e.classList.add(this.listClassName),this.isSingleSelect&&e.classList.add("treeselect-list--single-select"),this.disabledBranchNode&&e.classList.add("treeselect-list--disabled-branch-node"),e.addEventListener("mouseout",t=>o(this,d,st).call(this,t)),e.addEventListener("mousemove",()=>o(this,d,it).call(this)),e.addEventListener("mouseup",()=>this.mouseupCallback(),!0),e},st=function(e){e.stopPropagation(),n(this,q)&&n(this,H)&&n(this,q).classList.add("treeselect-list__item--focused")},it=function(){k(this,H,!0)},de=function(e){return e.reduce((t,s)=>{var a;if((a=s.children)!=null&&a.length){const u=o(this,d,at).call(this,s),m=o(this,d,de).call(this,s.children);return u.append(...m),t.push(u),t}const i=o(this,d,ue).call(this,s,!1);return t.push(i),t},[])},lt=function(){if(!this.listSlotHtmlComponent)return null;const e=document.createElement("div");return e.classList.add("treeselect-list__slot"),e.appendChild(this.listSlotHtmlComponent),e},nt=function(){const e=document.createElement("div");e.classList.add("treeselect-list__empty"),e.setAttribute("title",this.emptyText);const t=document.createElement("span");t.classList.add("treeselect-list__empty-icon"),p(this.iconElements.attention,t);const s=document.createElement("span");return s.classList.add("treeselect-list__empty-text"),s.textContent=this.emptyText,e.append(t,s),e},at=function(e){const t=document.createElement("div");t.setAttribute("group-container-id",e.value.toString()),t.classList.add("treeselect-list__group-container");const s=o(this,d,ue).call(this,e,!0);return t.appendChild(s),t},ue=function(e,t){const s=o(this,d,ot).call(this,e);if(t){const u=o(this,d,dt).call(this);s.appendChild(u),s.classList.add("treeselect-list__item--group")}const i=o(this,d,pt).call(this,e),a=o(this,d,mt).call(this,e,t);return s.append(i,a),s},ot=function(e){const t=document.createElement("div");return ls(t,e.htmlAttr),t.setAttribute("tabindex","-1"),t.setAttribute("title",e.name),t.classList.add("treeselect-list__item"),t.addEventListener("mouseover",()=>o(this,d,rt).call(this,t),!0),t.addEventListener("mouseout",()=>o(this,d,ct).call(this,t),!0),t.addEventListener("mousedown",s=>o(this,d,ht).call(this,s,e)),t},rt=function(e){n(this,H)&&o(this,d,pe).call(this,!0,e)},ct=function(e){n(this,H)&&(o(this,d,pe).call(this,!1,e),k(this,q,e))},ht=function(e,t){var a;if(e.preventDefault(),e.stopPropagation(),(a=this.flattedOptions.find(u=>u.id===t.value))==null?void 0:a.disabled)return;const i=e.target.querySelector(".treeselect-list__item-checkbox");i.checked=!i.checked,o(this,d,Ct).call(this,i,t)},dt=function(){const e=document.createElement("span");return e.setAttribute("tabindex","-1"),e.classList.add("treeselect-list__item-icon"),p(this.iconElements.arrowDown,e),e.addEventListener("mousedown",t=>o(this,d,ut).call(this,t)),e},ut=function(e){e.preventDefault(),e.stopPropagation(),o(this,d,bt).call(this,e)},pt=function(e){const t=document.createElement("div");t.classList.add("treeselect-list__item-checkbox-container");const s=document.createElement("span");s.classList.add("treeselect-list__item-checkbox-icon"),s.innerHTML="";const i=document.createElement("input");return i.setAttribute("tabindex","-1"),i.setAttribute("type","checkbox"),i.setAttribute("input-id",e.value.toString()),i.classList.add("treeselect-list__item-checkbox"),t.append(s,i),t},mt=function(e,t){const s=document.createElement("label");if(s.textContent=e.name,s.classList.add("treeselect-list__item-label"),t&&this.showCount){const i=o(this,d,ft).call(this,e);s.appendChild(i)}return s},ft=function(e){const t=document.createElement("span"),s=this.flattedOptions.filter(i=>i.childOf===e.value);return t.textContent=`(${s.length})`,t.classList.add("treeselect-list__item-label-counter"),t},Ct=function(e,t){const s=this.flattedOptions.find(i=>i.id===t.value);if(s){if(s!=null&&s.isGroup&&this.disabledBranchNode){const i=is(e);i==null||i.dispatchEvent(new Event("mousedown"));return}if(this.isSingleSelect){const[i]=n(this,T);if(s.id===i)return;k(this,T,[s.id]),Ee([s.id],this.flattedOptions,this.isSingleSelect,this.isIndependentNodes)}else{s.checked=e.checked;const i=ne(s,this.flattedOptions,this.isIndependentNodes);e.checked=i}Q(this.flattedOptions,this.srcElement,this.iconElements,n(this,T),this.rtl),o(this,d,gt).call(this)}},bt=function(e){var a,u;const t=(u=(a=e.target)==null?void 0:a.parentNode)==null?void 0:u.querySelector("[input-id]"),s=(t==null?void 0:t.getAttribute("input-id"))??null,i=Ne(s,this.flattedOptions);i&&(i.isClosed=!i.isClosed,Z(this.flattedOptions,i),Q(this.flattedOptions,this.srcElement,this.iconElements,n(this,T),this.rtl),this.arrowClickCallback(i.id,i.isClosed))},pe=function(e,t){const s="treeselect-list__item--focused";if(e){const i=Array.from(this.srcElement.querySelectorAll(`.${s}`));i.length&&i.forEach(a=>a.classList.remove(s)),t.classList.add(s)}else t.classList.remove(s)},se=function(e){return this.tagsSortFn===null?e:[...e].sort((t,s)=>this.tagsSortFn({value:t.id,name:t.name},{value:s.id,name:s.name}))},me=function(){const{ungroupedNodes:e,groupedNodes:t,allNodes:s}=jt(this.flattedOptions);this.selectedNodes={nodes:o(this,d,se).call(this,e),groupedNodes:o(this,d,se).call(this,t),allNodes:o(this,d,se).call(this,s)}},gt=function(){o(this,d,me).call(this),this.inputCallback(this.selectedNodes),this.value=this.selectedNodes.nodes.map(e=>e.id)};const Te=({parentHtmlContainer:l,staticList:e,appendToBody:t,isSingleSelect:s,value:i,direction:a})=>{l||console.error("Validation: parentHtmlContainer prop is required!"),e&&t&&console.error("Validation: You should set staticList to false if you use appendToBody!"),s&&Array.isArray(i)&&console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"),!s&&!Array.isArray(i)&&console.error("Validation: you should pass an array as a value!"),a&&a!=="auto"&&a!=="bottom"&&a!=="top"&&console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!")},ee=l=>l.map(e=>e.id),as=l=>l==null?[]:Array.isArray(l)?l:[l],os=(l,e)=>{if(e){const[t]=l;return t??null}return l};class rs{constructor({parentHtmlContainer:e,value:t,options:s,openLevel:i,appendToBody:a,alwaysOpen:u,showTags:m,tagsCountText:L,tagsSortFn:E,clearable:v,searchable:y,placeholder:x,grouped:S,isGroupedValue:P,listSlotHtmlComponent:D,disabled:F,emptyText:z,staticList:te,id:oe,ariaLabel:re,isSingleSelect:Oe,showCount:cs,disabledBranchNode:hs,direction:ds,expandSelected:us,saveScrollPosition:ps,isIndependentNodes:ms,rtl:fs,listClassName:Cs,iconElements:bs,inputCallback:gs,openCallback:ks,closeCallback:ws,nameChangeCallback:Es,searchCallback:vs,openCloseGroupCallback:Ls}){g(this,c);r(this,"parentHtmlContainer");r(this,"value");r(this,"options");r(this,"openLevel");r(this,"appendToBody");r(this,"alwaysOpen");r(this,"showTags");r(this,"tagsCountText");r(this,"tagsSortFn");r(this,"clearable");r(this,"searchable");r(this,"placeholder");r(this,"grouped");r(this,"isGroupedValue");r(this,"listSlotHtmlComponent");r(this,"disabled");r(this,"emptyText");r(this,"staticList");r(this,"id");r(this,"ariaLabel");r(this,"isSingleSelect");r(this,"showCount");r(this,"disabledBranchNode");r(this,"direction");r(this,"expandSelected");r(this,"saveScrollPosition");r(this,"isIndependentNodes");r(this,"rtl");r(this,"listClassName");r(this,"iconElements");r(this,"inputCallback");r(this,"openCallback");r(this,"closeCallback");r(this,"nameChangeCallback");r(this,"searchCallback");r(this,"openCloseGroupCallback");r(this,"ungroupedValue");r(this,"groupedValue");r(this,"allValue");r(this,"isListOpened");r(this,"selectedName");r(this,"srcElement");g(this,f,null);g(this,b,null);g(this,R,null);g(this,U,0);g(this,$,0);g(this,O,null);g(this,I,null);g(this,N,null);g(this,G,null);Te({parentHtmlContainer:e,value:t,staticList:te,appendToBody:a,isSingleSelect:Oe}),this.parentHtmlContainer=e,this.value=[],this.options=s??[],this.openLevel=i??0,this.appendToBody=a??!1,this.alwaysOpen=!!(u&&!F),this.showTags=m??!0,this.tagsCountText=L??"elements selected",this.tagsSortFn=E??null,this.clearable=v??!0,this.searchable=y??!0,this.placeholder=x??"Search...",this.grouped=S??!0,this.isGroupedValue=P??!1,this.listSlotHtmlComponent=D??null,this.disabled=F??!1,this.emptyText=z??"No results found...",this.staticList=!!(te&&!this.appendToBody),this.id=oe??"",this.ariaLabel=re??"",this.isSingleSelect=Oe??!1,this.showCount=cs??!1,this.disabledBranchNode=hs??!1,this.direction=ds??"auto",this.expandSelected=us??!1,this.saveScrollPosition=ps??!0,this.isIndependentNodes=ms??!1,this.rtl=fs??!1,this.listClassName=Cs??"",this.iconElements=w(bs),this.inputCallback=gs,this.openCallback=ks,this.closeCallback=ws,this.nameChangeCallback=Es,this.searchCallback=vs,this.openCloseGroupCallback=Ls,this.ungroupedValue=[],this.groupedValue=[],this.allValue=[],this.isListOpened=!1,this.selectedName="",this.srcElement=null,o(this,c,fe).call(this,t)}mount(){Te({parentHtmlContainer:this.parentHtmlContainer,value:this.value,staticList:this.staticList,appendToBody:this.appendToBody,isSingleSelect:this.isSingleSelect}),this.iconElements=w(this.iconElements),o(this,c,fe).call(this,this.value)}updateValue(e){const t=as(e),s=n(this,f);s&&(s.updateValue(t),o(this,c,be).call(this,s==null?void 0:s.selectedNodes))}destroy(){this.srcElement&&(o(this,c,ge).call(this),this.srcElement.innerHTML="",this.srcElement=null,o(this,c,le).call(this,!0))}focus(){n(this,b)&&n(this,b).focus()}toggleOpenClose(){n(this,b)&&(n(this,b).openClose(),n(this,b).focus())}scrollWindowHandler(){this.updateListPosition()}focusWindowHandler(e){var s,i,a;((s=this.srcElement)==null?void 0:s.contains(e.target))||((i=n(this,f))==null?void 0:i.srcElement.contains(e.target))||((a=n(this,b))==null||a.blur(),o(this,c,le).call(this,!1),o(this,c,ie).call(this,!1))}blurWindowHandler(){var e;(e=n(this,b))==null||e.blur(),o(this,c,le).call(this,!1),o(this,c,ie).call(this,!1)}updateListPosition(){var P;const e=this.srcElement,t=(P=n(this,f))==null?void 0:P.srcElement;if(!e||!t)return;const{height:s}=t.getBoundingClientRect(),{x:i,y:a,height:u,width:m}=e.getBoundingClientRect(),L=window.innerHeight,E=a,v=L-a-u;let y=E>v&&E>=s&&v<s;if(this.direction!=="auto"&&(y=this.direction==="top"),this.appendToBody){(t.style.top!=="0px"||t.style.left!=="0px")&&(t.style.top="0px",t.style.left="0px");const D=i+window.scrollX,F=y?a+window.scrollY-s:a+window.scrollY+u;t.style.transform=`translate(${D}px,${F}px)`,t.style.width=`${m}px`}const x=y?"top":"bottom";t.getAttribute("direction")!==x&&(t.setAttribute("direction",x),o(this,c,Nt).call(this,y,this.appendToBody))}}return f=new WeakMap,b=new WeakMap,R=new WeakMap,U=new WeakMap,$=new WeakMap,O=new WeakMap,I=new WeakMap,N=new WeakMap,G=new WeakMap,c=new WeakSet,fe=function(e){var a;this.destroy();const{container:t,list:s,input:i}=o(this,c,kt).call(this);this.srcElement=t,k(this,f,s),k(this,b,i),k(this,O,this.scrollWindowHandler.bind(this)),k(this,I,this.scrollWindowHandler.bind(this)),k(this,N,this.focusWindowHandler.bind(this)),k(this,G,this.blurWindowHandler.bind(this)),this.alwaysOpen&&((a=n(this,b))==null||a.openClose()),this.disabled?this.srcElement.classList.add("treeselect--disabled"):this.srcElement.classList.remove("treeselect--disabled"),this.updateValue(e??this.value)},Ce=function({groupedNodes:e,nodes:t,allNodes:s}){this.ungroupedValue=t?ee(t):[],this.groupedValue=e?ee(e):[],this.allValue=s?ee(s):[];let i=[];this.isIndependentNodes||this.isSingleSelect?i=this.allValue:this.isGroupedValue?i=this.groupedValue:i=this.ungroupedValue,this.value=os(i,this.isSingleSelect)},kt=function(){const e=this.parentHtmlContainer;e.classList.add("treeselect"),this.rtl&&e.setAttribute("dir","rtl");const t=new ns({value:[],options:this.options,openLevel:this.openLevel,listSlotHtmlComponent:this.listSlotHtmlComponent,tagsSortFn:this.tagsSortFn,emptyText:this.emptyText,isSingleSelect:this.isSingleSelect,showCount:this.showCount,disabledBranchNode:this.disabledBranchNode,expandSelected:this.expandSelected,isIndependentNodes:this.isIndependentNodes,rtl:this.rtl,listClassName:this.listClassName,iconElements:this.iconElements,inputCallback:i=>o(this,c,xt).call(this,i),arrowClickCallback:(i,a)=>o(this,c,St).call(this,i,a),mouseupCallback:()=>{var i;return(i=n(this,b))==null?void 0:i.focus()}}),s=new Dt({value:[],showTags:this.showTags,tagsCountText:this.tagsCountText,clearable:this.clearable,isAlwaysOpened:this.alwaysOpen,searchable:this.searchable,placeholder:this.placeholder,disabled:this.disabled,isSingleSelect:this.isSingleSelect,id:this.id,ariaLabel:this.ariaLabel,iconElements:this.iconElements,inputCallback:i=>o(this,c,wt).call(this,i),searchCallback:i=>o(this,c,vt).call(this,i),openCallback:()=>o(this,c,At).call(this),closeCallback:()=>o(this,c,ge).call(this),keydownCallback:i=>o(this,c,Et).call(this,i),focusCallback:()=>o(this,c,Lt).call(this),blurCallback:()=>o(this,c,yt).call(this),nameChangeCallback:i=>o(this,c,_t).call(this,i)});return this.appendToBody&&k(this,R,new ResizeObserver(()=>this.updateListPosition())),e.append(s.srcElement),{container:e,list:t,input:s}},wt=function(e){var i,a;const t=ee(e);(i=n(this,f))==null||i.updateValue(t);const s=((a=n(this,f))==null?void 0:a.selectedNodes)??{};o(this,c,Ce).call(this,s),o(this,c,we).call(this)},Et=function(e){var t;this.isListOpened&&((t=n(this,f))==null||t.callKeyAction(e))},vt=function(e){n(this,$)&&clearTimeout(n(this,$)),k(this,$,window.setTimeout(()=>{var t;(t=n(this,f))==null||t.updateSearchValue(e),this.updateListPosition()},350)),o(this,c,Bt).call(this,e)},Lt=function(){o(this,c,ie).call(this,!0),n(this,N)&&n(this,N)&&n(this,G)&&(document.addEventListener("mousedown",n(this,N),!0),document.addEventListener("focus",n(this,N),!0),window.addEventListener("blur",n(this,G)))},yt=function(){setTimeout(()=>{var s,i;const e=(s=n(this,b))==null?void 0:s.srcElement.contains(document.activeElement),t=(i=n(this,f))==null?void 0:i.srcElement.contains(document.activeElement);!e&&!t&&this.blurWindowHandler()},1)},be=function(e){var s;if(!e)return;let t=[];this.isIndependentNodes||this.isSingleSelect?t=e.allNodes:this.grouped?t=e.groupedNodes:t=e.nodes,(s=n(this,b))==null||s.updateValue(t),o(this,c,Ce).call(this,e)},xt=function(e){var t,s,i;o(this,c,be).call(this,e),this.isSingleSelect&&!this.alwaysOpen&&((t=n(this,b))==null||t.openClose(),(s=n(this,b))==null||s.clearSearch()),(i=n(this,b))==null||i.focus(),o(this,c,we).call(this)},St=function(e,t){var s;(s=n(this,b))==null||s.focus(),this.updateListPosition(),o(this,c,Vt).call(this,e,t)},_t=function(e){this.selectedName!==e&&(this.selectedName=e,o(this,c,Ot).call(this))},At=function(){var e;this.isListOpened=!0,n(this,O)&&n(this,I)&&(window.addEventListener("scroll",n(this,O),!0),window.addEventListener("resize",n(this,I))),!(!n(this,f)||!this.srcElement)&&(this.appendToBody?(document.body.appendChild(n(this,f).srcElement),(e=n(this,R))==null||e.observe(this.srcElement)):this.srcElement.appendChild(n(this,f).srcElement),this.updateListPosition(),o(this,c,ke).call(this,!0),o(this,c,Tt).call(this),o(this,c,It).call(this))},ge=function(){var t;this.alwaysOpen||(this.isListOpened=!1,n(this,O)&&n(this,I)&&(window.removeEventListener("scroll",n(this,O),!0),window.removeEventListener("resize",n(this,I))),!n(this,f)||!this.srcElement)||!(this.appendToBody?document.body.contains(n(this,f).srcElement):this.srcElement.contains(n(this,f).srcElement))||(k(this,U,n(this,f).srcElement.scrollTop),this.appendToBody?(document.body.removeChild(n(this,f).srcElement),(t=n(this,R))==null||t.disconnect()):this.srcElement.removeChild(n(this,f).srcElement),o(this,c,ke).call(this,!1),o(this,c,Pt).call(this))},Nt=function(e,t){if(!n(this,f)||!n(this,b))return;const s=t?"treeselect-list--top-to-body":"treeselect-list--top",i=t?"treeselect-list--bottom-to-body":"treeselect-list--bottom";e?(n(this,f).srcElement.classList.add(s),n(this,f).srcElement.classList.remove(i),n(this,b).srcElement.classList.add("treeselect-input--top"),n(this,b).srcElement.classList.remove("treeselect-input--bottom")):(n(this,f).srcElement.classList.remove(s),n(this,f).srcElement.classList.add(i),n(this,b).srcElement.classList.remove("treeselect-input--top"),n(this,b).srcElement.classList.add("treeselect-input--bottom"))},ie=function(e){!n(this,b)||!n(this,f)||(e?(n(this,b).srcElement.classList.add("treeselect-input--focused"),n(this,f).srcElement.classList.add("treeselect-list--focused")):(n(this,b).srcElement.classList.remove("treeselect-input--focused"),n(this,f).srcElement.classList.remove("treeselect-list--focused")))},ke=function(e){var t,s,i,a;e?(t=n(this,b))==null||t.srcElement.classList.add("treeselect-input--opened"):(s=n(this,b))==null||s.srcElement.classList.remove("treeselect-input--opened"),this.staticList?(i=n(this,f))==null||i.srcElement.classList.add("treeselect-list--static"):(a=n(this,f))==null||a.srcElement.classList.remove("treeselect-list--static")},le=function(e){!n(this,O)||!n(this,I)||!n(this,N)||!n(this,G)||((!this.alwaysOpen||e)&&(window.removeEventListener("scroll",n(this,O),!0),window.removeEventListener("resize",n(this,I))),document.removeEventListener("mousedown",n(this,N),!0),document.removeEventListener("focus",n(this,N),!0),window.removeEventListener("blur",n(this,G)))},Tt=function(){var t,s,i;const e=(t=n(this,f))==null?void 0:t.isLastFocusedElementExist();this.saveScrollPosition&&e?(s=n(this,f))==null||s.srcElement.scroll(0,n(this,U)):(i=n(this,f))==null||i.focusFirstListElement()},we=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("input",{detail:this.value})),this.inputCallback&&this.inputCallback(this.value)},Ot=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("name-change",{detail:this.selectedName})),this.nameChangeCallback&&this.nameChangeCallback(this.selectedName)},It=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("open",{detail:this.value})),this.openCallback&&this.openCallback(this.value))},Pt=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("close",{detail:this.value})),this.closeCallback&&this.closeCallback(this.value))},Bt=function(e){var s;const t=(e==null?void 0:e.trim())??"";(s=this.srcElement)==null||s.dispatchEvent(new CustomEvent("search",{detail:t})),this.searchCallback&&this.searchCallback(t)},Vt=function(e,t){var s;(s=this.srcElement)==null||s.dispatchEvent(new CustomEvent("open-close-group",{detail:{groupId:e,isClosed:t}})),this.openCloseGroupCallback&&this.openCloseGroupCallback(e,t)},rs});
1
+ (function(C,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(C=typeof globalThis<"u"?globalThis:C||self,C.Treeselect=p())})(this,function(){"use strict";var ys=Object.defineProperty;var Ie=C=>{throw TypeError(C)};var xs=(C,p,w)=>p in C?ys(C,p,{enumerable:!0,configurable:!0,writable:!0,value:w}):C[p]=w;var r=(C,p,w)=>xs(C,typeof p!="symbol"?p+"":p,w),ce=(C,p,w)=>p.has(C)||Ie("Cannot "+w);var n=(C,p,w)=>(ce(C,p,"read from private field"),w?w.call(C):p.get(C)),g=(C,p,w)=>p.has(C)?Ie("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(C):p.set(C,w),k=(C,p,w,X)=>(ce(C,p,"write to private field"),X?X.call(C,w):p.set(C,w),w),o=(C,p,w)=>(ce(C,p,"access private method"),w);var V,_,M,A,h,Pe,Y,Be,Ve,K,j,De,He,Ge,Fe,Me,qe,je,Re,$e,We,Ue,ze,Ye,Ke,Xe,Je,he,q,H,T,W,d,Ze,Qe,et,tt,st,it,de,lt,nt,at,ue,ot,rt,ct,ht,dt,ut,pt,mt,ft,Ct,bt,pe,se,me,gt,f,b,R,U,$,O,I,N,G,c,fe,Ce,kt,wt,Et,vt,Lt,yt,be,xt,St,_t,At,ge,Nt,ie,ke,le,Tt,we,Ot,It,Pt,Bt,Vt;const C={arrowUp:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 15l-6-6-6 6"/></svg>',arrowDown:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>',arrowRight:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>',attention:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',clear:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',cross:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',check:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',partialCheck:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>'},p=(l,e)=>{if(e.innerHTML="",typeof l=="string")e.innerHTML=l;else{const t=l.cloneNode(!0);e.appendChild(t)}},w=l=>{const e=l?{...l}:{};return Object.keys(C).forEach(t=>{e[t]||(e[t]=C[t])}),e},X=l=>l.reduce((e,{name:t},s)=>(e+=t,s<l.length-1&&(e+=", "),e),"");class Dt{constructor({value:e,showTags:t,tagsCountText:s,clearable:i,isAlwaysOpened:a,searchable:u,placeholder:m,disabled:L,isSingleSelect:E,id:v,ariaLabel:y,iconElements:x,inputCallback:S,searchCallback:P,openCallback:D,closeCallback:F,keydownCallback:z,focusCallback:te,blurCallback:oe,nameChangeCallback:re}){g(this,h);r(this,"value");r(this,"showTags");r(this,"tagsCountText");r(this,"clearable");r(this,"isAlwaysOpened");r(this,"searchable");r(this,"placeholder");r(this,"disabled");r(this,"isSingleSelect");r(this,"id");r(this,"ariaLabel");r(this,"iconElements");r(this,"isOpened");r(this,"searchText");r(this,"srcElement");g(this,V);g(this,_);g(this,M);g(this,A);r(this,"inputCallback");r(this,"searchCallback");r(this,"openCallback");r(this,"closeCallback");r(this,"keydownCallback");r(this,"focusCallback");r(this,"blurCallback");r(this,"nameChangeCallback");this.value=e,this.showTags=t,this.tagsCountText=s,this.searchable=u,this.placeholder=m,this.clearable=i,this.isAlwaysOpened=a,this.disabled=L,this.isSingleSelect=E,this.id=v,this.ariaLabel=y,this.iconElements=x,this.isOpened=!1,this.searchText="",k(this,V,o(this,h,Ge).call(this)),k(this,_,o(this,h,$e).call(this)),k(this,M,o(this,h,ze).call(this)),k(this,A,null),this.inputCallback=S,this.searchCallback=P,this.openCallback=D,this.closeCallback=F,this.keydownCallback=z,this.focusCallback=te,this.blurCallback=oe,this.nameChangeCallback=re,this.srcElement=o(this,h,De).call(this,n(this,V),n(this,_),n(this,M)),o(this,h,Pe).call(this)}focus(){setTimeout(()=>n(this,_).focus(),0)}blur(){this.isOpened&&o(this,h,j).call(this),this.clearSearch(),n(this,_).blur()}updateValue(e){this.value=e,o(this,h,Y).call(this),o(this,h,K).call(this)}removeItem(e){this.value=this.value.filter(t=>t.id!==e),o(this,h,he).call(this),o(this,h,Y).call(this),o(this,h,K).call(this)}clear(){this.value=[],o(this,h,he).call(this),o(this,h,Y).call(this),this.clearSearch()}openClose(){o(this,h,j).call(this)}clearSearch(){this.searchText="",this.searchCallback(""),o(this,h,K).call(this)}}V=new WeakMap,_=new WeakMap,M=new WeakMap,A=new WeakMap,h=new WeakSet,Pe=function(){o(this,h,Y).call(this),o(this,h,K).call(this),o(this,h,Be).call(this)},Y=function(){if(n(this,V).innerHTML="",this.showTags){n(this,V).append(...o(this,h,Fe).call(this));const e=X(this.value);this.nameChangeCallback(e)}else{const e=o(this,h,Re).call(this);n(this,V).appendChild(e),this.nameChangeCallback(e.innerText)}n(this,V).appendChild(n(this,_))},Be=function(){const e=[];n(this,M).innerHTML="",this.clearable&&e.push(o(this,h,Ye).call(this)),this.isAlwaysOpened||e.push(o(this,h,Xe).call(this,this.isOpened)),e.length&&n(this,M).append(...e)},Ve=function(){if(!this.isAlwaysOpened&&n(this,A)){const e=this.isOpened?this.iconElements.arrowUp:this.iconElements.arrowDown;p(e,n(this,A))}},K=function(){var e;(e=this.value)!=null&&e.length?(n(this,_).removeAttribute("placeholder"),this.srcElement.classList.remove("treeselect-input--value-not-selected")):(n(this,_).setAttribute("placeholder",this.placeholder),this.srcElement.classList.add("treeselect-input--value-not-selected")),this.searchable?this.srcElement.classList.remove("treeselect-input--unsearchable"):this.srcElement.classList.add("treeselect-input--unsearchable"),this.isSingleSelect?this.srcElement.classList.add("treeselect-input--is-single-select"):this.srcElement.classList.remove("treeselect-input--is-single-select"),n(this,_).value=this.searchText},j=function(){this.isOpened=!this.isOpened,o(this,h,Ve).call(this),this.isOpened?this.openCallback():this.closeCallback()},De=function(e,t,s){const i=document.createElement("div");return i.classList.add("treeselect-input"),i.setAttribute("tabindex","-1"),i.addEventListener("mousedown",a=>o(this,h,He).call(this,a)),i.addEventListener("focus",()=>this.focusCallback(),!0),i.addEventListener("blur",()=>this.blurCallback(),!0),e.appendChild(t),i.append(e,s),i},He=function(e){e.stopPropagation(),this.isOpened||o(this,h,j).call(this),this.focus()},Ge=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__tags"),e},Fe=function(){return this.value.map(e=>{const t=document.createElement("div");t.classList.add("treeselect-input__tags-element"),t.setAttribute("tabindex","-1"),t.setAttribute("tag-id",e.id.toString()),t.setAttribute("title",e.name);const s=o(this,h,qe).call(this,e.name),i=o(this,h,je).call(this);return t.addEventListener("mousedown",a=>o(this,h,Me).call(this,a,e.id)),t.append(s,i),t})},Me=function(e,t){e.preventDefault(),e.stopPropagation(),this.removeItem(t),this.focus()},qe=function(e){const t=document.createElement("span");return t.classList.add("treeselect-input__tags-name"),t.textContent=e,t},je=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__tags-cross"),p(this.iconElements.cross,e),e},Re=function(){const e=document.createElement("span");if(e.classList.add("treeselect-input__tags-count"),!this.value.length)return e.textContent="",e.setAttribute("title",""),e;const t=this.value.length===1?this.value[0].name:`${this.value.length} ${this.tagsCountText}`;return e.textContent=t,e.setAttribute("title",t),e},$e=function(){const e=document.createElement("input");return e.classList.add("treeselect-input__edit"),this.id&&e.setAttribute("id",this.id),(!this.searchable||this.disabled)&&e.setAttribute("readonly","readonly"),this.disabled&&e.setAttribute("tabindex","-1"),this.ariaLabel.length&&e.setAttribute("aria-label",this.ariaLabel),e.addEventListener("keydown",t=>o(this,h,We).call(this,t)),e.addEventListener("input",t=>o(this,h,Ue).call(this,t,e)),e},We=function(e){e.stopPropagation();const t=e.key;t==="Backspace"&&!this.searchText.length&&this.value.length&&!this.showTags&&this.clear(),t==="Backspace"&&!this.searchText.length&&this.value.length&&this.removeItem(this.value[this.value.length-1].id),e.code==="Space"&&(!this.searchText||!this.searchable)&&o(this,h,j).call(this),(t==="Enter"||t==="ArrowDown"||t==="ArrowUp")&&e.preventDefault(),this.keydownCallback(e),t!=="Tab"&&this.focus()},Ue=function(e,t){e.stopPropagation();const s=this.searchText,i=t.value.trim();if(s.length===0&&i.length===0){t.value="";return}if(this.searchable){const a=e.target.value;this.searchCallback(a),this.isOpened||o(this,h,j).call(this)}else t.value="";this.searchText=t.value},ze=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__operators"),e},Ye=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__clear"),e.setAttribute("tabindex","-1"),p(this.iconElements.clear,e),e.addEventListener("mousedown",t=>o(this,h,Ke).call(this,t)),e},Ke=function(e){e.preventDefault(),e.stopPropagation(),(this.searchText.length||this.value.length)&&this.clear(),this.focus()},Xe=function(e){k(this,A,document.createElement("span")),n(this,A).classList.add("treeselect-input__arrow");const t=e?this.iconElements.arrowUp:this.iconElements.arrowDown;return p(t,n(this,A)),n(this,A).addEventListener("mousedown",s=>o(this,h,Je).call(this,s)),n(this,A)},Je=function(e){e.stopPropagation(),e.preventDefault(),this.focus(),o(this,h,j).call(this)},he=function(){this.inputCallback(this.value)};const Ee=(l,e,t,s)=>{Mt(e);const i=e.filter(a=>!a.disabled&&l.some(u=>u===a.id));if(t&&i.length){i[0].checked=!0;return}i.forEach(a=>{a.checked=!0;const u=ne(a,e,s);a.checked=u})},ne=({id:l,checked:e},t,s)=>{const i=t.find(u=>u.id===l);if(!i)return!1;if(s)return i.checked=i.disabled?!1:!!e,i.checked;const a=ve(!!e,i,t);return Le(i,t),a},ve=(l,e,t)=>{if(!e.isGroup)return e.checked=e.disabled?!1:!!l,e.isPartialChecked=!1,e.checked;const s=t.filter(m=>m.childOf===e.id);return!l||e.disabled||e.isPartialChecked?(e.checked=!1,e.isPartialChecked=!1,ae(e,s,t),e.checked):ye(s,t)?xe(s)?(e.checked=!1,e.isPartialChecked=!1,e.disabled=!0,e.checked):(e.checked=!1,e.isPartialChecked=!0,s.forEach(m=>{ve(l,m,t)}),e.checked):(e.checked=!0,e.isPartialChecked=!1,ae(e,s,t),e.checked)},Le=(l,e)=>{const t=e.find(s=>s.id===l.childOf);t&&(Ht(t,e),Le(t,e))},Ht=(l,e)=>{const t=J(l,e);if(xe(t)){l.checked=!1,l.isPartialChecked=!1,l.disabled=!0;return}if(Gt(t)){l.checked=!0,l.isPartialChecked=!1;return}if(Ft(t)){l.checked=!1,l.isPartialChecked=!0;return}l.checked=!1,l.isPartialChecked=!1},ae=({checked:l,disabled:e},t,s)=>{t.forEach(i=>{i.disabled=!!e||!!i.disabled,i.checked=!!l&&!i.disabled,i.isPartialChecked=!1;const a=J(i,s);ae({checked:l,disabled:e},a,s)})},ye=(l,e)=>l.some(i=>i.disabled)?!0:l.some(i=>{if(i.isGroup){const a=J(i,e);return ye(a,e)}return!1}),xe=l=>l.every(e=>!!e.disabled),Gt=l=>l.every(e=>!!e.checked),Ft=l=>l.some(e=>!!e.checked||!!e.isPartialChecked),Mt=l=>{l.forEach(e=>{e.checked=!1,e.isPartialChecked=!1})},qt=(l,e,t)=>{const s={level:0,groupId:""},i=Se(l,e,s.groupId,s.level);return Rt(i,t)},Se=(l,e,t,s)=>l.reduce((i,a)=>{var E;const u=!!((E=a.children)!=null&&E.length),m=s>=e&&u,L=s>e;if(i.push({id:a.value,name:a.name,childOf:t,isGroup:u,checked:!1,isPartialChecked:!1,level:s,isClosed:m,hidden:L,disabled:a.disabled??!1}),u){const v=Se(a.children,e,a.value,s+1);i.push(...v)}return i},[]),J=({id:l},e)=>e.filter(t=>t.childOf===l),jt=l=>{const{ungroupedNodes:e,allGroupedNodes:t,allNodes:s}=l.reduce((a,u)=>(u.checked&&(a.allNodes.push(u),u.isGroup?a.allGroupedNodes.push(u):a.ungroupedNodes.push(u)),a),{ungroupedNodes:[],allGroupedNodes:[],allNodes:[]}),i=s.filter(a=>!t.some(({id:u})=>u===a.childOf));return{ungroupedNodes:e,groupedNodes:i,allNodes:s}},Rt=(l,e)=>(l.filter(s=>!!s.disabled).forEach(({id:s})=>ne({id:s,checked:!1},l,e)),l),Z=(l,{id:e,isClosed:t})=>{J({id:e},l).forEach(i=>{i.hidden=t??!1,i.isGroup&&!i.isClosed&&Z(l,{id:i.id,isClosed:t})})},$t=l=>{l.filter(e=>e.isGroup&&!e.disabled&&(e.checked||e.isPartialChecked)).forEach(e=>{e.isClosed=!1,Z(l,e)})},Wt=(l,e)=>{const t=Ut(l,e);l.forEach(s=>{t.some(({id:a})=>a===s.id)?(s.isGroup&&(s.isClosed=!1,Z(l,s)),s.hidden=!1):s.hidden=!0})},Ut=(l,e)=>l.reduce((t,s)=>{if(s.name.toLowerCase().includes(e.toLowerCase())){if(t.push(s),s.isGroup){const a=_e(s.id,l);t.push(...a)}if(s.childOf){const a=Ae(s.childOf,l);t.push(...a)}}return t},[]),_e=(l,e)=>e.reduce((t,s)=>(s.childOf===l&&(t.push(s),s.isGroup&&t.push(..._e(s.id,e))),t),[]),Ae=(l,e)=>e.reduce((t,s)=>(s.id===l&&(t.push(s),s.childOf&&t.push(...Ae(s.childOf,e))),t),[]),zt=l=>{const{duplications:e}=l.reduce((t,s)=>(t.allItems.some(i=>i.toString()===s.id.toString())&&t.duplications.push(s.id),t.allItems.push(s.id),t),{duplications:[],allItems:[]});e.length&&console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`)},Yt=(l,e,t,s,i,a,u,m,L,E)=>{Ee(l,e,i,L),m&&u&&$t(e),Q(e,t,s,a,E)},Q=(l,e,t,s,i)=>{l.forEach(a=>{const u=e.querySelector(`[input-id="${a.id}"]`),m=B(u);u.checked=a.checked,Kt(a,m,s),Xt(a,m),Jt(a,m),Zt(a,m,t),Qt(a,m),ts(a,m,l,i),es(a,u,t)}),ss(l,e)},Kt=(l,e,t)=>{l.checked?e.classList.add("treeselect-list__item--checked"):e.classList.remove("treeselect-list__item--checked"),Array.isArray(t)&&t[0]===l.id&&!l.disabled?e.classList.add("treeselect-list__item--single-selected"):e.classList.remove("treeselect-list__item--single-selected")},Xt=(l,e)=>{l.isPartialChecked?e.classList.add("treeselect-list__item--partial-checked"):e.classList.remove("treeselect-list__item--partial-checked")},Jt=(l,e)=>{l.disabled?e.classList.add("treeselect-list__item--disabled"):e.classList.remove("treeselect-list__item--disabled")},Zt=(l,e,t)=>{if(l.isGroup){const s=e.querySelector(".treeselect-list__item-icon"),i=l.isClosed?t.arrowRight:t.arrowDown;p(i,s),l.isClosed?e.classList.add("treeselect-list__item--closed"):e.classList.remove("treeselect-list__item--closed")}},Qt=(l,e)=>{l.hidden?e.classList.add("treeselect-list__item--hidden"):e.classList.remove("treeselect-list__item--hidden")},es=(l,e,t)=>{const i=e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");l.checked?p(t.check,i):l.isPartialChecked?p(t.partialCheck,i):i.innerHTML=""},ts=(l,e,t,s)=>{const i=l.level===0,a=20,u=5;if(i){const m=t.some(v=>v.isGroup&&v.level===l.level),L=!l.isGroup&&m?`${a}px`:`${u}px`,E=l.isGroup?"0":L;s?e.style.paddingRight=E:e.style.paddingLeft=E}else{const m=l.isGroup?`${l.level*a}px`:`${l.level*a+a}px`;s?e.style.paddingRight=m:e.style.paddingLeft=m}e.setAttribute("level",l.level.toString()),e.setAttribute("group",l.isGroup.toString())},ss=(l,e)=>{const t=l.some(i=>!i.hidden),s=e.querySelector(".treeselect-list__empty");t?s.classList.add("treeselect-list__empty--hidden"):s.classList.remove("treeselect-list__empty--hidden")},B=l=>l.parentNode.parentNode,Ne=(l,e)=>e.find(t=>t.id.toString()===l),is=l=>B(l).querySelector(".treeselect-list__item-icon"),ls=(l,e)=>{e&&Object.keys(e).forEach(t=>{const s=e[t];typeof s=="string"&&l.setAttribute(t,s)})};class ns{constructor({options:e,value:t,openLevel:s,listSlotHtmlComponent:i,tagsSortFn:a,emptyText:u,isSingleSelect:m,iconElements:L,showCount:E,disabledBranchNode:v,expandSelected:y,isIndependentNodes:x,rtl:S,listClassName:P,inputCallback:D,arrowClickCallback:F,mouseupCallback:z}){g(this,d);r(this,"options");r(this,"value");r(this,"openLevel");r(this,"listSlotHtmlComponent");r(this,"tagsSortFn");r(this,"emptyText");r(this,"isSingleSelect");r(this,"showCount");r(this,"disabledBranchNode");r(this,"expandSelected");r(this,"isIndependentNodes");r(this,"rtl");r(this,"listClassName");r(this,"iconElements");r(this,"searchText");r(this,"flattedOptions");r(this,"flattedOptionsBeforeSearch");r(this,"selectedNodes");r(this,"srcElement");r(this,"inputCallback");r(this,"arrowClickCallback");r(this,"mouseupCallback");g(this,q,null);g(this,H,!0);g(this,T,[]);g(this,W,!0);this.options=e,this.value=t,this.openLevel=s??0,this.listSlotHtmlComponent=i??null,this.tagsSortFn=a??null,this.emptyText=u??"No results found...",this.isSingleSelect=m??!1,this.showCount=E??!1,this.disabledBranchNode=v??!1,this.expandSelected=y??!1,this.isIndependentNodes=x??!1,this.rtl=S??!1,this.listClassName=P??"",this.iconElements=L,this.searchText="",this.flattedOptions=qt(this.options,this.openLevel,this.isIndependentNodes),this.flattedOptionsBeforeSearch=this.flattedOptions,this.selectedNodes={nodes:[],groupedNodes:[],allNodes:[]},this.srcElement=o(this,d,et).call(this),this.inputCallback=D,this.arrowClickCallback=F,this.mouseupCallback=z,zt(this.flattedOptions)}updateValue(e){this.value=e,k(this,T,this.isSingleSelect?this.value:[]),Yt(e,this.flattedOptions,this.srcElement,this.iconElements,this.isSingleSelect,n(this,T),this.expandSelected,n(this,W),this.isIndependentNodes,this.rtl),k(this,W,!1),o(this,d,me).call(this)}updateSearchValue(e){if(e===this.searchText)return;const t=this.searchText===""&&e!=="";this.searchText=e,t&&(this.flattedOptionsBeforeSearch=JSON.parse(JSON.stringify(this.flattedOptions))),this.searchText===""&&(this.flattedOptions=this.flattedOptionsBeforeSearch.map(s=>{const i=this.flattedOptions.find(a=>a.id===s.id);return i.isClosed=s.isClosed,i.hidden=s.hidden,i}),this.flattedOptionsBeforeSearch=[]),this.searchText&&Wt(this.flattedOptions,e),Q(this.flattedOptions,this.srcElement,this.iconElements,n(this,T),this.rtl),this.focusFirstListElement()}callKeyAction(e){k(this,H,!1);const t=this.srcElement.querySelector(".treeselect-list__item--focused");if(t==null?void 0:t.classList.contains("treeselect-list__item--hidden"))return;const i=e.key;i==="Enter"&&t&&t.dispatchEvent(new Event("mousedown")),(i==="ArrowLeft"||i==="ArrowRight")&&o(this,d,Ze).call(this,t,e),(i==="ArrowDown"||i==="ArrowUp")&&o(this,d,Qe).call(this,t,i)}focusFirstListElement(){const e="treeselect-list__item--focused",t=this.srcElement.querySelector(`.${e}`),s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(B(a)).display!=="none");if(!s.length)return;t&&t.classList.remove(e),B(s[0]).classList.add(e)}isLastFocusedElementExist(){return!!n(this,q)}}q=new WeakMap,H=new WeakMap,T=new WeakMap,W=new WeakMap,d=new WeakSet,Ze=function(e,t){if(!e)return;const s=t.key,a=e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"),u=Ne(a,this.flattedOptions),m=e.querySelector(".treeselect-list__item-icon");s==="ArrowLeft"&&!u.isClosed&&u.isGroup&&(m.dispatchEvent(new Event("mousedown")),t.preventDefault()),s==="ArrowRight"&&u.isClosed&&u.isGroup&&(m.dispatchEvent(new Event("mousedown")),t.preventDefault())},Qe=function(e,t){var i;const s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(B(a)).display!=="none");if(s.length)if(!e)B(s[0]).classList.add("treeselect-list__item--focused");else{const a=s.findIndex(D=>B(D).classList.contains("treeselect-list__item--focused"));B(s[a]).classList.remove("treeselect-list__item--focused");const m=t==="ArrowDown"?a+1:a-1,L=t==="ArrowDown"?0:s.length-1,E=s[m]??s[L],v=!s[m],y=B(E);y.classList.add("treeselect-list__item--focused");const x=this.srcElement.getBoundingClientRect(),S=y.getBoundingClientRect();if(v&&t==="ArrowDown"){this.srcElement.scroll(0,0);return}if(v&&t==="ArrowUp"){this.srcElement.scroll(0,this.srcElement.scrollHeight);return}const P=((i=this.listSlotHtmlComponent)==null?void 0:i.clientHeight)??0;if(x.y+x.height<S.y+S.height+P){this.srcElement.scroll(0,this.srcElement.scrollTop+S.height);return}if(x.y>S.y){this.srcElement.scroll(0,this.srcElement.scrollTop-S.height);return}}},et=function(){const e=o(this,d,tt).call(this),t=o(this,d,de).call(this,this.options);e.append(...t);const s=o(this,d,nt).call(this);e.append(s);const i=o(this,d,lt).call(this);return i&&e.append(i),e},tt=function(){const e=document.createElement("div");return e.classList.add("treeselect-list"),this.listClassName.length>0&&e.classList.add(this.listClassName),this.isSingleSelect&&e.classList.add("treeselect-list--single-select"),this.disabledBranchNode&&e.classList.add("treeselect-list--disabled-branch-node"),e.addEventListener("mouseout",t=>o(this,d,st).call(this,t)),e.addEventListener("mousemove",()=>o(this,d,it).call(this)),e.addEventListener("mouseup",()=>this.mouseupCallback(),!0),e},st=function(e){e.stopPropagation(),n(this,q)&&n(this,H)&&n(this,q).classList.add("treeselect-list__item--focused")},it=function(){k(this,H,!0)},de=function(e){return e.reduce((t,s)=>{var a;if((a=s.children)!=null&&a.length){const u=o(this,d,at).call(this,s),m=o(this,d,de).call(this,s.children);return u.append(...m),t.push(u),t}const i=o(this,d,ue).call(this,s,!1);return t.push(i),t},[])},lt=function(){if(!this.listSlotHtmlComponent)return null;const e=document.createElement("div");return e.classList.add("treeselect-list__slot"),e.appendChild(this.listSlotHtmlComponent),e},nt=function(){const e=document.createElement("div");e.classList.add("treeselect-list__empty"),e.setAttribute("title",this.emptyText);const t=document.createElement("span");t.classList.add("treeselect-list__empty-icon"),p(this.iconElements.attention,t);const s=document.createElement("span");return s.classList.add("treeselect-list__empty-text"),s.textContent=this.emptyText,e.append(t,s),e},at=function(e){const t=document.createElement("div");t.setAttribute("group-container-id",e.value.toString()),t.classList.add("treeselect-list__group-container");const s=o(this,d,ue).call(this,e,!0);return t.appendChild(s),t},ue=function(e,t){const s=o(this,d,ot).call(this,e);if(t){const u=o(this,d,dt).call(this);s.appendChild(u),s.classList.add("treeselect-list__item--group")}const i=o(this,d,pt).call(this,e),a=o(this,d,mt).call(this,e,t);return s.append(i,a),s},ot=function(e){const t=document.createElement("div");return t.setAttribute("tabindex","-1"),t.setAttribute("title",e.name),ls(t,e.htmlAttr),t.classList.add("treeselect-list__item"),t.addEventListener("mouseover",()=>o(this,d,rt).call(this,t),!0),t.addEventListener("mouseout",()=>o(this,d,ct).call(this,t),!0),t.addEventListener("mousedown",s=>o(this,d,ht).call(this,s,e)),t},rt=function(e){n(this,H)&&o(this,d,pe).call(this,!0,e)},ct=function(e){n(this,H)&&(o(this,d,pe).call(this,!1,e),k(this,q,e))},ht=function(e,t){var a;if(e.preventDefault(),e.stopPropagation(),(a=this.flattedOptions.find(u=>u.id===t.value))==null?void 0:a.disabled)return;const i=e.target.querySelector(".treeselect-list__item-checkbox");i.checked=!i.checked,o(this,d,Ct).call(this,i,t)},dt=function(){const e=document.createElement("span");return e.setAttribute("tabindex","-1"),e.classList.add("treeselect-list__item-icon"),p(this.iconElements.arrowDown,e),e.addEventListener("mousedown",t=>o(this,d,ut).call(this,t)),e},ut=function(e){e.preventDefault(),e.stopPropagation(),o(this,d,bt).call(this,e)},pt=function(e){const t=document.createElement("div");t.classList.add("treeselect-list__item-checkbox-container");const s=document.createElement("span");s.classList.add("treeselect-list__item-checkbox-icon"),s.innerHTML="";const i=document.createElement("input");return i.setAttribute("tabindex","-1"),i.setAttribute("type","checkbox"),i.setAttribute("input-id",e.value.toString()),i.classList.add("treeselect-list__item-checkbox"),t.append(s,i),t},mt=function(e,t){const s=document.createElement("label");if(s.textContent=e.name,s.classList.add("treeselect-list__item-label"),t&&this.showCount){const i=o(this,d,ft).call(this,e);s.appendChild(i)}return s},ft=function(e){const t=document.createElement("span"),s=this.flattedOptions.filter(i=>i.childOf===e.value);return t.textContent=`(${s.length})`,t.classList.add("treeselect-list__item-label-counter"),t},Ct=function(e,t){const s=this.flattedOptions.find(i=>i.id===t.value);if(s){if(s!=null&&s.isGroup&&this.disabledBranchNode){const i=is(e);i==null||i.dispatchEvent(new Event("mousedown"));return}if(this.isSingleSelect){const[i]=n(this,T);if(s.id===i)return;k(this,T,[s.id]),Ee([s.id],this.flattedOptions,this.isSingleSelect,this.isIndependentNodes)}else{s.checked=e.checked;const i=ne(s,this.flattedOptions,this.isIndependentNodes);e.checked=i}Q(this.flattedOptions,this.srcElement,this.iconElements,n(this,T),this.rtl),o(this,d,gt).call(this)}},bt=function(e){var a,u;const t=(u=(a=e.target)==null?void 0:a.parentNode)==null?void 0:u.querySelector("[input-id]"),s=(t==null?void 0:t.getAttribute("input-id"))??null,i=Ne(s,this.flattedOptions);i&&(i.isClosed=!i.isClosed,Z(this.flattedOptions,i),Q(this.flattedOptions,this.srcElement,this.iconElements,n(this,T),this.rtl),this.arrowClickCallback(i.id,i.isClosed))},pe=function(e,t){const s="treeselect-list__item--focused";if(e){const i=Array.from(this.srcElement.querySelectorAll(`.${s}`));i.length&&i.forEach(a=>a.classList.remove(s)),t.classList.add(s)}else t.classList.remove(s)},se=function(e){return this.tagsSortFn===null?e:[...e].sort((t,s)=>this.tagsSortFn({value:t.id,name:t.name},{value:s.id,name:s.name}))},me=function(){const{ungroupedNodes:e,groupedNodes:t,allNodes:s}=jt(this.flattedOptions);this.selectedNodes={nodes:o(this,d,se).call(this,e),groupedNodes:o(this,d,se).call(this,t),allNodes:o(this,d,se).call(this,s)}},gt=function(){o(this,d,me).call(this),this.inputCallback(this.selectedNodes),this.value=this.selectedNodes.nodes.map(e=>e.id)};const Te=({parentHtmlContainer:l,staticList:e,appendToBody:t,isSingleSelect:s,value:i,direction:a})=>{l||console.error("Validation: parentHtmlContainer prop is required!"),e&&t&&console.error("Validation: You should set staticList to false if you use appendToBody!"),s&&Array.isArray(i)&&console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"),!s&&!Array.isArray(i)&&console.error("Validation: you should pass an array as a value!"),a&&a!=="auto"&&a!=="bottom"&&a!=="top"&&console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!")},ee=l=>l.map(e=>e.id),as=l=>l==null?[]:Array.isArray(l)?l:[l],os=(l,e)=>{if(e){const[t]=l;return t??null}return l};class rs{constructor({parentHtmlContainer:e,value:t,options:s,openLevel:i,appendToBody:a,alwaysOpen:u,showTags:m,tagsCountText:L,tagsSortFn:E,clearable:v,searchable:y,placeholder:x,grouped:S,isGroupedValue:P,listSlotHtmlComponent:D,disabled:F,emptyText:z,staticList:te,id:oe,ariaLabel:re,isSingleSelect:Oe,showCount:cs,disabledBranchNode:hs,direction:ds,expandSelected:us,saveScrollPosition:ps,isIndependentNodes:ms,rtl:fs,listClassName:Cs,iconElements:bs,inputCallback:gs,openCallback:ks,closeCallback:ws,nameChangeCallback:Es,searchCallback:vs,openCloseGroupCallback:Ls}){g(this,c);r(this,"parentHtmlContainer");r(this,"value");r(this,"options");r(this,"openLevel");r(this,"appendToBody");r(this,"alwaysOpen");r(this,"showTags");r(this,"tagsCountText");r(this,"tagsSortFn");r(this,"clearable");r(this,"searchable");r(this,"placeholder");r(this,"grouped");r(this,"isGroupedValue");r(this,"listSlotHtmlComponent");r(this,"disabled");r(this,"emptyText");r(this,"staticList");r(this,"id");r(this,"ariaLabel");r(this,"isSingleSelect");r(this,"showCount");r(this,"disabledBranchNode");r(this,"direction");r(this,"expandSelected");r(this,"saveScrollPosition");r(this,"isIndependentNodes");r(this,"rtl");r(this,"listClassName");r(this,"iconElements");r(this,"inputCallback");r(this,"openCallback");r(this,"closeCallback");r(this,"nameChangeCallback");r(this,"searchCallback");r(this,"openCloseGroupCallback");r(this,"ungroupedValue");r(this,"groupedValue");r(this,"allValue");r(this,"isListOpened");r(this,"selectedName");r(this,"srcElement");g(this,f,null);g(this,b,null);g(this,R,null);g(this,U,0);g(this,$,0);g(this,O,null);g(this,I,null);g(this,N,null);g(this,G,null);Te({parentHtmlContainer:e,value:t,staticList:te,appendToBody:a,isSingleSelect:Oe}),this.parentHtmlContainer=e,this.value=[],this.options=s??[],this.openLevel=i??0,this.appendToBody=a??!1,this.alwaysOpen=!!(u&&!F),this.showTags=m??!0,this.tagsCountText=L??"elements selected",this.tagsSortFn=E??null,this.clearable=v??!0,this.searchable=y??!0,this.placeholder=x??"Search...",this.grouped=S??!0,this.isGroupedValue=P??!1,this.listSlotHtmlComponent=D??null,this.disabled=F??!1,this.emptyText=z??"No results found...",this.staticList=!!(te&&!this.appendToBody),this.id=oe??"",this.ariaLabel=re??"",this.isSingleSelect=Oe??!1,this.showCount=cs??!1,this.disabledBranchNode=hs??!1,this.direction=ds??"auto",this.expandSelected=us??!1,this.saveScrollPosition=ps??!0,this.isIndependentNodes=ms??!1,this.rtl=fs??!1,this.listClassName=Cs??"",this.iconElements=w(bs),this.inputCallback=gs,this.openCallback=ks,this.closeCallback=ws,this.nameChangeCallback=Es,this.searchCallback=vs,this.openCloseGroupCallback=Ls,this.ungroupedValue=[],this.groupedValue=[],this.allValue=[],this.isListOpened=!1,this.selectedName="",this.srcElement=null,o(this,c,fe).call(this,t)}mount(){Te({parentHtmlContainer:this.parentHtmlContainer,value:this.value,staticList:this.staticList,appendToBody:this.appendToBody,isSingleSelect:this.isSingleSelect}),this.iconElements=w(this.iconElements),o(this,c,fe).call(this,this.value)}updateValue(e){const t=as(e),s=n(this,f);s&&(s.updateValue(t),o(this,c,be).call(this,s==null?void 0:s.selectedNodes))}destroy(){this.srcElement&&(o(this,c,ge).call(this),this.srcElement.innerHTML="",this.srcElement=null,o(this,c,le).call(this,!0))}focus(){n(this,b)&&n(this,b).focus()}toggleOpenClose(){n(this,b)&&(n(this,b).openClose(),n(this,b).focus())}scrollWindowHandler(){this.updateListPosition()}focusWindowHandler(e){var s,i,a;((s=this.srcElement)==null?void 0:s.contains(e.target))||((i=n(this,f))==null?void 0:i.srcElement.contains(e.target))||((a=n(this,b))==null||a.blur(),o(this,c,le).call(this,!1),o(this,c,ie).call(this,!1))}blurWindowHandler(){var e;(e=n(this,b))==null||e.blur(),o(this,c,le).call(this,!1),o(this,c,ie).call(this,!1)}updateListPosition(){var P;const e=this.srcElement,t=(P=n(this,f))==null?void 0:P.srcElement;if(!e||!t)return;const{height:s}=t.getBoundingClientRect(),{x:i,y:a,height:u,width:m}=e.getBoundingClientRect(),L=window.innerHeight,E=a,v=L-a-u;let y=E>v&&E>=s&&v<s;if(this.direction!=="auto"&&(y=this.direction==="top"),this.appendToBody){(t.style.top!=="0px"||t.style.left!=="0px")&&(t.style.top="0px",t.style.left="0px");const D=i+window.scrollX,F=y?a+window.scrollY-s:a+window.scrollY+u;t.style.transform=`translate(${D}px,${F}px)`,t.style.width=`${m}px`}const x=y?"top":"bottom";t.getAttribute("direction")!==x&&(t.setAttribute("direction",x),o(this,c,Nt).call(this,y,this.appendToBody))}}return f=new WeakMap,b=new WeakMap,R=new WeakMap,U=new WeakMap,$=new WeakMap,O=new WeakMap,I=new WeakMap,N=new WeakMap,G=new WeakMap,c=new WeakSet,fe=function(e){var a;this.destroy();const{container:t,list:s,input:i}=o(this,c,kt).call(this);this.srcElement=t,k(this,f,s),k(this,b,i),k(this,O,this.scrollWindowHandler.bind(this)),k(this,I,this.scrollWindowHandler.bind(this)),k(this,N,this.focusWindowHandler.bind(this)),k(this,G,this.blurWindowHandler.bind(this)),this.alwaysOpen&&((a=n(this,b))==null||a.openClose()),this.disabled?this.srcElement.classList.add("treeselect--disabled"):this.srcElement.classList.remove("treeselect--disabled"),this.updateValue(e??this.value)},Ce=function({groupedNodes:e,nodes:t,allNodes:s}){this.ungroupedValue=t?ee(t):[],this.groupedValue=e?ee(e):[],this.allValue=s?ee(s):[];let i=[];this.isIndependentNodes||this.isSingleSelect?i=this.allValue:this.isGroupedValue?i=this.groupedValue:i=this.ungroupedValue,this.value=os(i,this.isSingleSelect)},kt=function(){const e=this.parentHtmlContainer;e.classList.add("treeselect"),this.rtl&&e.setAttribute("dir","rtl");const t=new ns({value:[],options:this.options,openLevel:this.openLevel,listSlotHtmlComponent:this.listSlotHtmlComponent,tagsSortFn:this.tagsSortFn,emptyText:this.emptyText,isSingleSelect:this.isSingleSelect,showCount:this.showCount,disabledBranchNode:this.disabledBranchNode,expandSelected:this.expandSelected,isIndependentNodes:this.isIndependentNodes,rtl:this.rtl,listClassName:this.listClassName,iconElements:this.iconElements,inputCallback:i=>o(this,c,xt).call(this,i),arrowClickCallback:(i,a)=>o(this,c,St).call(this,i,a),mouseupCallback:()=>{var i;return(i=n(this,b))==null?void 0:i.focus()}}),s=new Dt({value:[],showTags:this.showTags,tagsCountText:this.tagsCountText,clearable:this.clearable,isAlwaysOpened:this.alwaysOpen,searchable:this.searchable,placeholder:this.placeholder,disabled:this.disabled,isSingleSelect:this.isSingleSelect,id:this.id,ariaLabel:this.ariaLabel,iconElements:this.iconElements,inputCallback:i=>o(this,c,wt).call(this,i),searchCallback:i=>o(this,c,vt).call(this,i),openCallback:()=>o(this,c,At).call(this),closeCallback:()=>o(this,c,ge).call(this),keydownCallback:i=>o(this,c,Et).call(this,i),focusCallback:()=>o(this,c,Lt).call(this),blurCallback:()=>o(this,c,yt).call(this),nameChangeCallback:i=>o(this,c,_t).call(this,i)});return this.appendToBody&&k(this,R,new ResizeObserver(()=>this.updateListPosition())),e.append(s.srcElement),{container:e,list:t,input:s}},wt=function(e){var i,a;const t=ee(e);(i=n(this,f))==null||i.updateValue(t);const s=((a=n(this,f))==null?void 0:a.selectedNodes)??{};o(this,c,Ce).call(this,s),o(this,c,we).call(this)},Et=function(e){var t;this.isListOpened&&((t=n(this,f))==null||t.callKeyAction(e))},vt=function(e){n(this,$)&&clearTimeout(n(this,$)),k(this,$,window.setTimeout(()=>{var t;(t=n(this,f))==null||t.updateSearchValue(e),this.updateListPosition()},350)),o(this,c,Bt).call(this,e)},Lt=function(){o(this,c,ie).call(this,!0),n(this,N)&&n(this,N)&&n(this,G)&&(document.addEventListener("mousedown",n(this,N),!0),document.addEventListener("focus",n(this,N),!0),window.addEventListener("blur",n(this,G)))},yt=function(){setTimeout(()=>{var s,i;const e=(s=n(this,b))==null?void 0:s.srcElement.contains(document.activeElement),t=(i=n(this,f))==null?void 0:i.srcElement.contains(document.activeElement);!e&&!t&&this.blurWindowHandler()},1)},be=function(e){var s;if(!e)return;let t=[];this.isIndependentNodes||this.isSingleSelect?t=e.allNodes:this.grouped?t=e.groupedNodes:t=e.nodes,(s=n(this,b))==null||s.updateValue(t),o(this,c,Ce).call(this,e)},xt=function(e){var t,s,i;o(this,c,be).call(this,e),this.isSingleSelect&&!this.alwaysOpen&&((t=n(this,b))==null||t.openClose(),(s=n(this,b))==null||s.clearSearch()),(i=n(this,b))==null||i.focus(),o(this,c,we).call(this)},St=function(e,t){var s;(s=n(this,b))==null||s.focus(),this.updateListPosition(),o(this,c,Vt).call(this,e,t)},_t=function(e){this.selectedName!==e&&(this.selectedName=e,o(this,c,Ot).call(this))},At=function(){var e;this.isListOpened=!0,n(this,O)&&n(this,I)&&(window.addEventListener("scroll",n(this,O),!0),window.addEventListener("resize",n(this,I))),!(!n(this,f)||!this.srcElement)&&(this.appendToBody?(document.body.appendChild(n(this,f).srcElement),(e=n(this,R))==null||e.observe(this.srcElement)):this.srcElement.appendChild(n(this,f).srcElement),this.updateListPosition(),o(this,c,ke).call(this,!0),o(this,c,Tt).call(this),o(this,c,It).call(this))},ge=function(){var t;this.alwaysOpen||(this.isListOpened=!1,n(this,O)&&n(this,I)&&(window.removeEventListener("scroll",n(this,O),!0),window.removeEventListener("resize",n(this,I))),!n(this,f)||!this.srcElement)||!(this.appendToBody?document.body.contains(n(this,f).srcElement):this.srcElement.contains(n(this,f).srcElement))||(k(this,U,n(this,f).srcElement.scrollTop),this.appendToBody?(document.body.removeChild(n(this,f).srcElement),(t=n(this,R))==null||t.disconnect()):this.srcElement.removeChild(n(this,f).srcElement),o(this,c,ke).call(this,!1),o(this,c,Pt).call(this))},Nt=function(e,t){if(!n(this,f)||!n(this,b))return;const s=t?"treeselect-list--top-to-body":"treeselect-list--top",i=t?"treeselect-list--bottom-to-body":"treeselect-list--bottom";e?(n(this,f).srcElement.classList.add(s),n(this,f).srcElement.classList.remove(i),n(this,b).srcElement.classList.add("treeselect-input--top"),n(this,b).srcElement.classList.remove("treeselect-input--bottom")):(n(this,f).srcElement.classList.remove(s),n(this,f).srcElement.classList.add(i),n(this,b).srcElement.classList.remove("treeselect-input--top"),n(this,b).srcElement.classList.add("treeselect-input--bottom"))},ie=function(e){!n(this,b)||!n(this,f)||(e?(n(this,b).srcElement.classList.add("treeselect-input--focused"),n(this,f).srcElement.classList.add("treeselect-list--focused")):(n(this,b).srcElement.classList.remove("treeselect-input--focused"),n(this,f).srcElement.classList.remove("treeselect-list--focused")))},ke=function(e){var t,s,i,a;e?(t=n(this,b))==null||t.srcElement.classList.add("treeselect-input--opened"):(s=n(this,b))==null||s.srcElement.classList.remove("treeselect-input--opened"),this.staticList?(i=n(this,f))==null||i.srcElement.classList.add("treeselect-list--static"):(a=n(this,f))==null||a.srcElement.classList.remove("treeselect-list--static")},le=function(e){!n(this,O)||!n(this,I)||!n(this,N)||!n(this,G)||((!this.alwaysOpen||e)&&(window.removeEventListener("scroll",n(this,O),!0),window.removeEventListener("resize",n(this,I))),document.removeEventListener("mousedown",n(this,N),!0),document.removeEventListener("focus",n(this,N),!0),window.removeEventListener("blur",n(this,G)))},Tt=function(){var t,s,i;const e=(t=n(this,f))==null?void 0:t.isLastFocusedElementExist();this.saveScrollPosition&&e?(s=n(this,f))==null||s.srcElement.scroll(0,n(this,U)):(i=n(this,f))==null||i.focusFirstListElement()},we=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("input",{detail:this.value})),this.inputCallback&&this.inputCallback(this.value)},Ot=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("name-change",{detail:this.selectedName})),this.nameChangeCallback&&this.nameChangeCallback(this.selectedName)},It=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("open",{detail:this.value})),this.openCallback&&this.openCallback(this.value))},Pt=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("close",{detail:this.value})),this.closeCallback&&this.closeCallback(this.value))},Bt=function(e){var s;const t=(e==null?void 0:e.trim())??"";(s=this.srcElement)==null||s.dispatchEvent(new CustomEvent("search",{detail:t})),this.searchCallback&&this.searchCallback(t)},Vt=function(e,t){var s;(s=this.srcElement)==null||s.dispatchEvent(new CustomEvent("open-close-group",{detail:{groupId:e,isClosed:t}})),this.openCloseGroupCallback&&this.openCloseGroupCallback(e,t)},rs});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "treeselectjs",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "description": "Treeselect JS",
5
5
  "main": "./dist/treeselectjs.umd.js",
6
6
  "module": "./dist/treeselectjs.mjs",
@@ -65,7 +65,7 @@
65
65
  "ts-jest": "^29.2.5",
66
66
  "ts-node": "^10.9.2",
67
67
  "typescript": "^5.7.3",
68
- "vite": "^6.1.1",
68
+ "vite": "^6.2.0",
69
69
  "vite-plugin-dts": "^4.5.0"
70
70
  },
71
71
  "files": [