UNPKG

treeselectjs

Version:
1,160 lines 51.9 kB
var Kt = Object.defineProperty; var we = (i) => { throw TypeError(i); }; var Xt = (i, e, t) => e in i ? Kt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t; var c = (i, e, t) => Xt(i, typeof e != "symbol" ? e + "" : e, t), ee = (i, e, t) => e.has(i) || we("Cannot " + t); var n = (i, e, t) => (ee(i, e, "read from private field"), t ? t.call(i) : e.get(i)), g = (i, e, t) => e.has(i) ? we("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, s) => (ee(i, e, "write to private field"), s ? s.call(i, t) : e.set(i, t), t), a = (i, e, t) => (ee(i, e, "access private method"), t); const ve = { 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>' }, O = (i, e) => { if (e.innerHTML = "", typeof i == "string") e.innerHTML = i; else { const t = i.cloneNode(!0); e.appendChild(t); } }, ke = (i) => { const e = i ? { ...i } : {}; return Object.keys(ve).forEach((t) => { e[t] || (e[t] = ve[t]); }), e; }, Zt = (i) => i.reduce((e, { name: t }, s) => (e += t, s < i.length - 1 && (e += ", "), e), ""); var _, S, D, x, h, Se, j, xe, ye, U, B, Te, Ae, Ie, Ne, _e, Oe, He, Pe, Ve, Be, De, Ge, Me, Fe, Re, $e, te; class Jt { constructor({ value: e, showTags: t, tagsCountText: s, clearable: l, isAlwaysOpened: r, searchable: u, placeholder: f, disabled: w, isSingleSelect: k, id: E, ariaLabel: C, iconElements: v, inputCallback: L, searchCallback: T, openCallback: N, closeCallback: H, keydownCallback: W, focusCallback: F, nameChangeCallback: Q }) { g(this, h); // Props c(this, "value"); c(this, "showTags"); c(this, "tagsCountText"); c(this, "clearable"); c(this, "isAlwaysOpened"); c(this, "searchable"); c(this, "placeholder"); c(this, "disabled"); c(this, "isSingleSelect"); c(this, "id"); c(this, "ariaLabel"); c(this, "iconElements"); // InnerState c(this, "isOpened"); c(this, "searchText"); c(this, "srcElement"); // PrivateInnerState g(this, _); g(this, S); g(this, D); g(this, x); // Callbacks c(this, "inputCallback"); c(this, "searchCallback"); c(this, "openCallback"); c(this, "closeCallback"); c(this, "keydownCallback"); c(this, "focusCallback"); c(this, "nameChangeCallback"); this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = u, this.placeholder = f, this.clearable = l, this.isAlwaysOpened = r, this.disabled = w, this.isSingleSelect = k, this.id = E, this.ariaLabel = C, this.iconElements = v, this.isOpened = !1, this.searchText = "", b(this, _, a(this, h, Ie).call(this)), b(this, S, a(this, h, Ve).call(this)), b(this, D, a(this, h, Ge).call(this)), b(this, x, null), this.inputCallback = L, this.searchCallback = T, this.openCallback = N, this.closeCallback = H, this.keydownCallback = W, this.focusCallback = F, this.nameChangeCallback = Q, this.srcElement = a(this, h, Te).call(this, { htmlTagsSection: n(this, _), htmlEditControl: n(this, S), htmlOperators: n(this, D) }), a(this, h, Se).call(this); } // Public methods focus() { setTimeout(() => n(this, S).focus(), 0); } blur() { this.isOpened && a(this, h, B).call(this), this.clearSearch(), n(this, S).blur(); } updateValue(e) { this.value = e, a(this, h, j).call(this), a(this, h, U).call(this); } removeItem(e) { this.value = this.value.filter((t) => t.id !== e), a(this, h, te).call(this), a(this, h, j).call(this), a(this, h, U).call(this); } clear() { this.value = [], a(this, h, te).call(this), a(this, h, j).call(this), this.clearSearch(); } openClose() { a(this, h, B).call(this); } clearSearch() { this.searchText = "", this.searchCallback(""), a(this, h, U).call(this); } } _ = new WeakMap(), S = new WeakMap(), D = new WeakMap(), x = new WeakMap(), h = new WeakSet(), // Private methods Se = function() { a(this, h, j).call(this), a(this, h, U).call(this), a(this, h, xe).call(this); }, j = function() { if (n(this, _).innerHTML = "", this.showTags) { n(this, _).append(...a(this, h, Ne).call(this)); const e = Zt(this.value); this.nameChangeCallback(e); } else { const e = a(this, h, Pe).call(this); n(this, _).appendChild(e), this.nameChangeCallback(e.innerText); } n(this, _).appendChild(n(this, S)); }, xe = function() { const e = []; n(this, D).innerHTML = "", this.clearable && e.push(a(this, h, Me).call(this)), this.isAlwaysOpened || e.push(a(this, h, Re).call(this, this.isOpened)), e.length && n(this, D).append(...e); }, ye = function() { if (!this.isAlwaysOpened && n(this, x)) { const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown; O(e, n(this, x)); } }, U = function() { var e; (e = this.value) != null && e.length ? (n(this, S).removeAttribute("placeholder"), this.srcElement.classList.remove("treeselect-input--value-not-selected")) : (n(this, S).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, S).value = this.searchText; }, B = function() { this.isOpened = !this.isOpened, a(this, h, ye).call(this), this.isOpened ? this.openCallback() : this.closeCallback(); }, Te = function({ htmlTagsSection: e, htmlEditControl: t, htmlOperators: s }) { const l = document.createElement("div"); return l.classList.add("treeselect-input"), l.setAttribute("tabindex", "-1"), l.addEventListener("mousedown", (r) => a(this, h, Ae).call(this, r)), l.addEventListener("focus", () => this.focusCallback(), !0), e.appendChild(t), l.append(e, s), l; }, Ae = function(e) { e.stopPropagation(), this.isOpened || a(this, h, B).call(this), this.focus(); }, Ie = function() { const e = document.createElement("div"); return e.classList.add("treeselect-input__tags"), e; }, Ne = 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 = a(this, h, Oe).call(this, e.name), l = a(this, h, He).call(this); return t.addEventListener("mousedown", (r) => a(this, h, _e).call(this, r, e.id)), t.append(s, l), t; }); }, _e = function(e, t) { e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus(); }, Oe = function(e) { const t = document.createElement("span"); return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t; }, He = function() { const e = document.createElement("span"); return e.classList.add("treeselect-input__tags-cross"), O(this.iconElements.cross, e), e; }, Pe = 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; }, Ve = 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) => a(this, h, Be).call(this, t)), e.addEventListener("input", (t) => a(this, h, De).call(this, t, e)), e; }, Be = 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) && a(this, h, B).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus(); }, De = function(e, t) { e.stopPropagation(); const s = this.searchText, l = t.value.trim(); if (s.length === 0 && l.length === 0) { t.value = ""; return; } if (this.searchable) { const r = e.target.value; this.searchCallback(r), this.isOpened || a(this, h, B).call(this); } else t.value = ""; this.searchText = t.value; }, Ge = function() { const e = document.createElement("div"); return e.classList.add("treeselect-input__operators"), e; }, Me = function() { const e = document.createElement("span"); return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), O(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => a(this, h, Fe).call(this, t)), e; }, Fe = function(e) { e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus(); }, Re = function(e) { b(this, x, document.createElement("span")), n(this, x).classList.add("treeselect-input__arrow"); const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown; return O(t, n(this, x)), n(this, x).addEventListener("mousedown", (s) => a(this, h, $e).call(this, s)), n(this, x); }, $e = function(e) { e.stopPropagation(), e.preventDefault(), this.focus(), a(this, h, B).call(this); }, // Emits te = function() { this.inputCallback(this.value); }; const We = ({ newValue: i, optionsTreeMap: e, isSingleSelect: t, isIndependentNodes: s }) => { ss(e); const l = i.map((u) => e.get(u) ?? null).filter((u) => u !== null && !u.disabled), [r] = l; if (t && l.length && r) { r.checked = !0; return; } l.forEach((u) => { u.checked = !0; const f = be({ option: u, optionsTreeMap: e, isIndependentNodes: s }); u.checked = f; }); }, be = ({ option: { id: i, checked: e }, optionsTreeMap: t, isIndependentNodes: s }) => { const l = t.get(i) ?? null; if (l === null) return !1; if (s) return l.checked = !l.disabled && e, l.checked; const r = je({ checked: e, currentOption: l, optionsTreeMap: t }); return Ue({ childOption: l, optionsTreeMap: t }), r; }, je = ({ checked: i, currentOption: e, optionsTreeMap: t }) => { if (!e.isGroup) return e.checked = !e.disabled && i, e.isPartialChecked = !1, e.checked; const s = K({ id: e.id, optionsTreeMap: t }); return !i || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, se({ option: e, children: s, optionsTreeMap: t }), e.checked) : ze({ children: s, optionsTreeMap: t }) ? Ye(s) ? (e.checked = !1, e.isPartialChecked = !1, e.disabled = !0, e.checked) : (e.checked = !1, e.isPartialChecked = !0, s.forEach((f) => { je({ checked: i, currentOption: f, optionsTreeMap: t }); }), e.checked) : (e.checked = !0, e.isPartialChecked = !1, se({ option: e, children: s, optionsTreeMap: t }), e.checked); }, Ue = ({ childOption: i, optionsTreeMap: e }) => { const t = e.get(i.childOf) ?? null; t !== null && (Qt({ parentOption: t, optionsTreeMap: e }), Ue({ childOption: t, optionsTreeMap: e })); }, Qt = ({ parentOption: i, optionsTreeMap: e }) => { const t = K({ id: i.id, optionsTreeMap: e }); if (Ye(t)) { i.checked = !1, i.isPartialChecked = !1, i.disabled = !0; return; } if (es(t)) { i.checked = !0, i.isPartialChecked = !1; return; } if (ts(t)) { i.checked = !1, i.isPartialChecked = !0; return; } i.checked = !1, i.isPartialChecked = !1; }, se = ({ option: { checked: i, disabled: e }, children: t, optionsTreeMap: s }) => { t.forEach((l) => { l.disabled = e || l.disabled, l.checked = i && !l.disabled, l.isPartialChecked = !1; const r = K({ id: l.id, optionsTreeMap: s }); se({ option: { checked: i, disabled: e }, children: r, optionsTreeMap: s }); }); }, ze = ({ children: i, optionsTreeMap: e }) => i.some((s) => s.disabled) ? !0 : i.some((s) => { if (!s.isGroup) return !1; const l = K({ id: s.id, optionsTreeMap: e }); return ze({ children: l, optionsTreeMap: e }); }), Ye = (i) => i.every((e) => !!e.disabled), es = (i) => i.every((e) => e.checked), ts = (i) => i.some((e) => e.checked || e.isPartialChecked), ss = (i) => { i.forEach((e) => { e.checked = !1, e.isPartialChecked = !1; }); }, is = ({ options: i, openLevel: e, isIndependentNodes: t }) => { const s = { level: 0, groupId: "" }, l = /* @__PURE__ */ new Map(); return qe({ optionsTreeMap: l, options: i, openLevel: e, groupId: s.groupId, level: s.level }), as({ optionsTreeMap: l, isIndependentNodes: t }), l; }, qe = ({ optionsTreeMap: i, options: e, openLevel: t, groupId: s, level: l }) => { e.forEach((r) => { var C, v; const u = (((C = r.children) == null ? void 0 : C.length) ?? 0) > 0, f = l >= t && u, w = l > t, k = ((v = r.children) == null ? void 0 : v.map((L) => L.value)) ?? [], E = r.value; i.has(E) && console.error( `Validation: You have duplicated option value: ${E}! You should use unique values. Duplicates will lead to unexpected behavior.` ), i.set(E, { id: E, name: r.name, childOf: s, isGroup: u, checked: !1, isPartialChecked: !1, level: l, isClosed: f, hidden: w, disabled: r.disabled ?? !1, isGroupSelectable: !u || (r.isGroupSelectable ?? !0), children: k, // Html elements will be added during their creation checkboxHtmlElement: null, itemHtmlElement: null, arrowItemHtmlElement: null, checkboxIconHtmlElement: null }), u && qe({ optionsTreeMap: i, options: r.children, openLevel: t, groupId: E, level: l + 1 }); }); }, ls = (i, e) => i === null ? null : e.get(i) ?? e.get(parseInt(i)) ?? null, K = ({ id: i, optionsTreeMap: e }) => { const t = e.get(i) ?? null; return t === null ? [] : t.children.reduce((s, l) => { const r = e.get(l) ?? null; return r !== null && s.push(r), s; }, []); }, ns = (i) => { const e = [], t = [], s = []; i.forEach((r) => { r.checked && (s.push(r), r.isGroup ? t.push(r) : e.push(r)); }); const l = s.filter((r) => !t.some(({ id: u }) => u === r.childOf)); return { ungroupedNodes: e, groupedNodes: l, allNodes: s }; }, as = ({ optionsTreeMap: i, isIndependentNodes: e }) => { const t = []; i.forEach((s) => { s.disabled && t.push(s); }), t.forEach( ({ id: s }) => be({ option: { id: s, checked: !1 }, optionsTreeMap: i, isIndependentNodes: e }) ); }, X = (i, { id: e, isClosed: t }) => { K({ id: e, optionsTreeMap: i }).forEach((l) => { l.hidden = t ?? !1, l.isGroup && !l.isClosed && X(i, { id: l.id, isClosed: t }); }); }, rs = (i, e) => { if (e) { cs(i); return; } i.forEach((t) => { t.checked && Ce(t.childOf, i), t.isGroup && !t.disabled && (t.checked || t.isPartialChecked) && (t.isClosed = !1, X(i, t)); }); }, cs = (i) => { let e = null; for (const [t, s] of i) if (s.checked && !s.disabled) { e = s; break; } e && (e.isGroup && (e.isClosed = !1, X(i, e)), Ce(e.childOf, i)); }, Ce = (i, e) => { const t = e.get(i) ?? null; t && (t.isClosed = !1, X(e, t), Ce(t.childOf, e)); }, os = (i, e) => { i.forEach((t) => { const s = t.name.toLowerCase().includes(e.toLowerCase()); s && (t.isGroup && (t.isClosed = !0), t.childOf && Ke(t.childOf, i)), t.hidden = !s; }); }, Ke = (i, e) => { const t = e.get(i) ?? null; t && (t.hidden = !1, t.isClosed = !1, Ke(t.childOf, e)); }, hs = ({ optionsTreeMap: i, beforeSearchStateMap: e }) => { i.forEach((t) => { const s = e.get(t.id); s && (t.hidden = s.hidden, t.isClosed = s.isClosed); }), e.clear(); }, ds = ({ optionsTreeMap: i, beforeSearchStateMap: e }) => { e.clear(), i.forEach((t) => { e.set(t.id, { hidden: t.hidden, isClosed: t.isClosed }); }); }, us = (i) => new IntersectionObserver( (e) => { e.forEach((t) => { t.target.classList.toggle("treeselect-list__item--scroll-not-visible", !t.isIntersecting); }); }, { root: i, threshold: 0.5 } ), ms = ({ optionsTreeMap: i, emptyListHtmlElement: e, iconElements: t, previousSingleSelectedValue: s, rtl: l }) => { i.forEach((r) => { const u = r.checkboxHtmlElement; u && (u.checked = r.checked), bs({ option: r, previousSingleSelectedValue: s }), Cs(r), Es(r), ws({ option: r, iconElements: t }), vs(r), ps({ option: r, optionsTreeMap: i, rtl: l }), ks({ option: r, iconElements: t }), Ls(r); }), fs({ optionsTreeMap: i, emptyListHtmlElement: e }); }, ps = ({ option: i, optionsTreeMap: e, rtl: t }) => { const s = i.level === 0, l = 20, r = 5; let u = "0"; if (s) { let w = !1; for (const [E, C] of e) if (C.isGroup && C.level === i.level) { w = !0; break; } const k = !i.isGroup && w ? `${l}px` : `${r}px`; u = i.isGroup ? "0" : k; } else u = i.isGroup ? `${i.level * l}px` : `${i.level * l + l}px`; const f = i.itemHtmlElement; f && (t ? f.style.paddingRight = u : f.style.paddingLeft = u, f.setAttribute("level", i.level.toString()), f.setAttribute("group", i.isGroup.toString())); }, fs = ({ optionsTreeMap: i, emptyListHtmlElement: e }) => { let t = !1; for (const [s, l] of i) if (!l.hidden) { t = !0; break; } e == null || e.classList.toggle("treeselect-list__empty--hidden", t); }, gs = (i, e) => { e && Object.keys(e).forEach((t) => { const s = e[t]; typeof s == "string" && i.setAttribute(t, s); }); }, bs = ({ option: i, previousSingleSelectedValue: e }) => { const t = i.itemHtmlElement; t == null || t.classList.toggle("treeselect-list__item--checked", i.checked); const s = Array.isArray(e) && e[0] === i.id && !i.disabled; t == null || t.classList.toggle("treeselect-list__item--single-selected", s); }, Cs = (i) => { const e = i.itemHtmlElement; e == null || e.classList.toggle("treeselect-list__item--partial-checked", i.isPartialChecked); }, Es = (i) => { const e = i.itemHtmlElement; e == null || e.classList.toggle("treeselect-list__item--disabled", i.disabled); }, ws = ({ option: i, iconElements: e }) => { const t = i.arrowItemHtmlElement; if (i.isGroup && t) { const s = i.isClosed ? e.arrowRight : e.arrowDown; O(s, t); const l = i.itemHtmlElement; l == null || l.classList.toggle("treeselect-list__item--closed", i.isClosed); } }, vs = (i) => { const e = i.itemHtmlElement; e == null || e.classList.toggle("treeselect-list__item--hidden", i.hidden); }, ks = ({ option: i, iconElements: e }) => { const t = i.checkboxIconHtmlElement; t && (i.checked ? O(e.check, t) : i.isPartialChecked ? O(e.partialCheck, t) : t.innerHTML = ""); }, Ls = (i) => { const e = i.itemHtmlElement; e == null || e.classList.toggle("treeselect-list__item--non-selectable-group", !i.isGroupSelectable); }, Ss = ({ newValue: i, optionsTreeMap: e, isSingleSelect: t, expandSelected: s, isFirstValueUpdate: l, isIndependentNodes: r }) => { We({ newValue: i, optionsTreeMap: e, isSingleSelect: t, isIndependentNodes: r }), l && s && rs(e, t); }; var G, P, M, Y, o, z, Xe, Ze, Je, Qe, et, tt, ie, st, it, lt, le, nt, at, rt, ct, ot, ht, dt, ut, mt, ne, pt, ft, ae, J, re, gt; class xs { constructor({ options: e, value: t, openLevel: s, listSlotHtmlComponent: l, tagsSortFn: r, emptyText: u, isSingleSelect: f, iconElements: w, showCount: k, disabledBranchNode: E, expandSelected: C, isIndependentNodes: v, rtl: L, listClassName: T, isBoostedRendering: N, inputCallback: H, arrowClickCallback: W, mouseupCallback: F }) { g(this, o); // Props c(this, "options"); c(this, "value"); c(this, "openLevel"); c(this, "listSlotHtmlComponent"); c(this, "tagsSortFn"); c(this, "emptyText"); c(this, "isSingleSelect"); c(this, "showCount"); c(this, "disabledBranchNode"); c(this, "expandSelected"); c(this, "isIndependentNodes"); c(this, "rtl"); c(this, "listClassName"); c(this, "isBoostedRendering"); c(this, "iconElements"); // InnerState c(this, "searchText"); c(this, "intersectionItemsObserver"); c(this, "selectedNodes"); c(this, "optionsTreeMap"); c(this, "beforeSearchStateMap"); c(this, "emptyListHtmlElement"); c(this, "srcElement"); // Callbacks c(this, "inputCallback"); c(this, "arrowClickCallback"); c(this, "mouseupCallback"); // PrivateInnerState g(this, G, null); g(this, P, !0); g(this, M, []); g(this, Y, !0); this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = l ?? null, this.tagsSortFn = r ?? null, this.emptyText = u ?? "No results found...", this.isSingleSelect = f ?? !1, this.showCount = k ?? !1, this.disabledBranchNode = E ?? !1, this.expandSelected = C ?? !1, this.isIndependentNodes = v ?? !1, this.rtl = L ?? !1, this.listClassName = T ?? "", this.isBoostedRendering = N, this.iconElements = w, this.searchText = "", this.intersectionItemsObserver = null, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.optionsTreeMap = is({ options: this.options, openLevel: this.openLevel, isIndependentNodes: this.isIndependentNodes }), this.beforeSearchStateMap = /* @__PURE__ */ new Map(), this.emptyListHtmlElement = null, this.srcElement = a(this, o, Je).call(this), this.inputCallback = H, this.arrowClickCallback = W, this.mouseupCallback = F; } // Public methods updateValue(e) { this.value = e, b(this, M, this.isSingleSelect ? this.value : []), Ss({ newValue: e, optionsTreeMap: this.optionsTreeMap, isSingleSelect: this.isSingleSelect, expandSelected: this.expandSelected, isFirstValueUpdate: n(this, Y), isIndependentNodes: this.isIndependentNodes }), a(this, o, z).call(this), b(this, Y, !1), a(this, o, re).call(this); } updateSearchValue(e) { if (e === this.searchText) return; const t = this.searchText === "" && e !== ""; this.searchText = e, t && ds({ beforeSearchStateMap: this.beforeSearchStateMap, optionsTreeMap: this.optionsTreeMap }), this.searchText === "" && hs({ beforeSearchStateMap: this.beforeSearchStateMap, optionsTreeMap: this.optionsTreeMap }), this.searchText && os(this.optionsTreeMap, e), a(this, o, z).call(this), this.focusFirstListElement(); } callKeyAction(e) { b(this, P, !1); const t = this.srcElement.querySelector(".treeselect-list__item--focused"); if (t == null ? void 0 : t.classList.contains("treeselect-list__item--hidden")) return; const l = e.key; l === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (l === "ArrowLeft" || l === "ArrowRight") && a(this, o, Xe).call(this, t, e), (l === "ArrowDown" || l === "ArrowUp") && a(this, o, Ze).call(this, t, l); } focusFirstListElement() { const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = a(this, o, ne).call(this); if (!s.length) return; t && t.classList.remove(e); const [l] = s; l.classList.add(e); } isLastFocusedElementExist() { return !!n(this, G); } destroy() { this.intersectionItemsObserver && this.intersectionItemsObserver.disconnect(); } } G = new WeakMap(), P = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), o = new WeakSet(), // Private methods z = function() { ms({ optionsTreeMap: this.optionsTreeMap, emptyListHtmlElement: this.emptyListHtmlElement, iconElements: this.iconElements, previousSingleSelectedValue: n(this, M), rtl: this.rtl }); }, Xe = function(e, t) { if (!e) return; const s = t.key, r = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), u = ls(r, this.optionsTreeMap), f = u.arrowItemHtmlElement; s === "ArrowLeft" && !u.isClosed && u.isGroup && (f.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && u.isClosed && u.isGroup && (f.dispatchEvent(new Event("mousedown")), t.preventDefault()); }, Ze = function(e, t) { var r; const s = a(this, o, ne).call(this); if (!s.length) return; const l = "treeselect-list__item--focused"; if (e) { const u = s.findIndex((N) => N.classList.contains(l)); s[u].classList.remove(l); const w = t === "ArrowDown" ? u + 1 : u - 1, k = t === "ArrowDown" ? 0 : s.length - 1, E = !s[w], C = s[w] ?? s[k]; C.classList.add(l); const v = this.srcElement.getBoundingClientRect(), L = C.getBoundingClientRect(); if (E && t === "ArrowDown") { this.srcElement.scroll(0, 0); return; } if (E && t === "ArrowUp") { this.srcElement.scroll(0, this.srcElement.scrollHeight); return; } const T = ((r = this.listSlotHtmlComponent) == null ? void 0 : r.clientHeight) ?? 0; if (v.y + v.height < L.y + L.height + T) { this.srcElement.scroll(0, this.srcElement.scrollTop + L.height); return; } if (v.y > L.y) { this.srcElement.scroll(0, this.srcElement.scrollTop - L.height); return; } } else { const [u] = s; u.classList.add(l); } }, Je = function() { const e = a(this, o, Qe).call(this), t = a(this, o, ie).call(this, this.options); e.append(...t); const s = a(this, o, it).call(this); e.append(s); const l = a(this, o, st).call(this); return l && e.append(l), e; }, Qe = 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) => a(this, o, et).call(this, t)), e.addEventListener("mousemove", () => a(this, o, tt).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), this.isBoostedRendering && (this.intersectionItemsObserver = us(e)), e; }, et = function(e) { e.stopPropagation(), n(this, G) && n(this, P) && n(this, G).classList.add("treeselect-list__item--focused"); }, tt = function() { b(this, P, !0); }, ie = function(e) { return e.reduce((t, s) => { var r; if ((r = s.children) != null && r.length) { const u = a(this, o, lt).call(this, s), f = a(this, o, ie).call(this, s.children); return u.append(...f), t.push(u), t; } const l = a(this, o, le).call(this, s, !1); return t.push(l), t; }, []); }, st = function() { if (!this.listSlotHtmlComponent) return null; const e = document.createElement("div"); return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e; }, it = 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"), O(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), this.emptyListHtmlElement = e, e; }, lt = function(e) { const t = document.createElement("div"); t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container"); const s = a(this, o, le).call(this, e, !0); return t.appendChild(s), t; }, le = function(e, t) { const s = a(this, o, nt).call(this, e); if (t) { const u = a(this, o, ot).call(this, e); s.appendChild(u), s.classList.add("treeselect-list__item--group"); } const l = a(this, o, dt).call(this, e), r = a(this, o, ut).call(this, e, t); return s.append(l, r), s; }, nt = function(e) { const t = document.createElement("div"); t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), gs(t, e.htmlAttr), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => a(this, o, at).call(this, t), !0), t.addEventListener("mouseout", () => a(this, o, rt).call(this, t), !0), t.addEventListener("mousedown", (l) => a(this, o, ct).call(this, l, e)), this.intersectionItemsObserver && this.intersectionItemsObserver.observe(t); const s = this.optionsTreeMap.get(e.value); return s && (s.itemHtmlElement = t), t; }, at = function(e) { n(this, P) && a(this, o, ae).call(this, !0, e); }, rt = function(e) { n(this, P) && (a(this, o, ae).call(this, !1, e), b(this, G, e)); }, ct = function(e, t) { e.preventDefault(), e.stopPropagation(); const s = this.optionsTreeMap.get(t.value) ?? null; if (s != null && s.disabled) return; const l = s == null ? void 0 : s.checkboxHtmlElement; l && (l.checked = !l.checked, a(this, o, pt).call(this, l, t)); }, ot = function(e) { const t = document.createElement("span"); t.setAttribute("tabindex", "-1"), t.classList.add("treeselect-list__item-icon"), O(this.iconElements.arrowDown, t), t.addEventListener("mousedown", (l) => a(this, o, ht).call(this, l, e)); const s = this.optionsTreeMap.get(e.value); return s && (s.arrowItemHtmlElement = t), t; }, ht = function(e, t) { e.preventDefault(), e.stopPropagation(), a(this, o, ft).call(this, t); }, dt = 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 l = document.createElement("input"); l.setAttribute("tabindex", "-1"), l.setAttribute("type", "checkbox"), l.setAttribute("input-id", e.value.toString()), l.classList.add("treeselect-list__item-checkbox"), t.append(s, l); const r = this.optionsTreeMap.get(e.value); return r && (r.checkboxHtmlElement = l, r.checkboxIconHtmlElement = s), t; }, ut = function(e, t) { const s = document.createElement("label"); if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) { const l = a(this, o, mt).call(this, e); s.appendChild(l); } return s; }, mt = function(e) { var l; const t = document.createElement("span"), s = ((l = this.optionsTreeMap.get(e.value)) == null ? void 0 : l.children) ?? []; return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t; }, ne = function() { const e = []; return this.optionsTreeMap.forEach((t) => { !t.hidden && t.itemHtmlElement && e.push(t.itemHtmlElement); }), e; }, // Actions pt = function(e, t) { const s = this.optionsTreeMap.get(t.value) ?? null; if (s === null) return; const l = s.isGroupSelectable ?? !0; if (s.isGroup && (this.disabledBranchNode || !l)) { const r = s.arrowItemHtmlElement; r == null || r.dispatchEvent(new Event("mousedown")); return; } if (this.isSingleSelect) { const [r] = n(this, M); if (s.id === r) return; b(this, M, [s.id]), We({ newValue: [s.id], optionsTreeMap: this.optionsTreeMap, isSingleSelect: this.isSingleSelect, isIndependentNodes: this.isIndependentNodes }); } else { s.checked = e.checked; const r = be({ option: s, optionsTreeMap: this.optionsTreeMap, isIndependentNodes: this.isIndependentNodes }); e.checked = r; } a(this, o, z).call(this), a(this, o, gt).call(this); }, ft = function(e) { const t = this.optionsTreeMap.get(e.value) ?? null; t !== null && (t.isClosed = !t.isClosed, X(this.optionsTreeMap, t), a(this, o, z).call(this), this.arrowClickCallback(t.id, t.isClosed)); }, ae = function(e, t) { const s = "treeselect-list__item--focused"; if (e) { const l = Array.from(this.srcElement.querySelectorAll(`.${s}`)); l.length && l.forEach((r) => r.classList.remove(s)), t.classList.add(s); } else t.classList.remove(s); }, J = 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 })); }, re = function() { const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = ns(this.optionsTreeMap); this.selectedNodes = { nodes: a(this, o, J).call(this, e), groupedNodes: a(this, o, J).call(this, t), allNodes: a(this, o, J).call(this, s) }; }, // Emits gt = function() { a(this, o, re).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id); }; const Le = ({ parentHtmlContainer: i, staticList: e, appendToBody: t, isSingleSelect: s, value: l, direction: r }) => { i || 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(l) && console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"), !s && !Array.isArray(l) && console.error("Validation: you should pass an array as a value!"), r && r !== "auto" && r !== "bottom" && r !== "top" && console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!"); }, Z = (i) => i.map((e) => e.id), ys = (i) => i == null ? [] : Array.isArray(i) ? i : [i], Ts = (i, e) => { if (e) { const [t] = i; return t ?? null; } return i; }; var m, p, R, q, $, A, I, y, V, d, ce, oe, bt, Ct, Et, wt, vt, he, kt, Lt, St, xt, de, ue, me, pe, fe, yt, ge, Tt, At, It, Nt, _t; class Is { constructor({ parentHtmlContainer: e, value: t, options: s, openLevel: l, appendToBody: r, alwaysOpen: u, showTags: f, tagsCountText: w, tagsSortFn: k, clearable: E, searchable: C, placeholder: v, grouped: L, isGroupedValue: T, listSlotHtmlComponent: N, disabled: H, emptyText: W, staticList: F, id: Q, ariaLabel: Ot, isSingleSelect: Ee, showCount: Ht, disabledBranchNode: Pt, direction: Vt, expandSelected: Bt, saveScrollPosition: Dt, isIndependentNodes: Gt, rtl: Mt, listClassName: Ft, isBoostedRendering: Rt, iconElements: $t, inputCallback: Wt, openCallback: jt, closeCallback: Ut, nameChangeCallback: zt, searchCallback: Yt, openCloseGroupCallback: qt }) { g(this, d); // Props c(this, "parentHtmlContainer"); c(this, "value"); c(this, "options"); c(this, "openLevel"); c(this, "appendToBody"); c(this, "alwaysOpen"); c(this, "showTags"); c(this, "tagsCountText"); c(this, "tagsSortFn"); c(this, "clearable"); c(this, "searchable"); c(this, "placeholder"); c(this, "grouped"); c(this, "isGroupedValue"); c(this, "listSlotHtmlComponent"); c(this, "disabled"); c(this, "emptyText"); c(this, "staticList"); c(this, "id"); c(this, "ariaLabel"); c(this, "isSingleSelect"); c(this, "showCount"); c(this, "disabledBranchNode"); c(this, "direction"); c(this, "expandSelected"); c(this, "saveScrollPosition"); c(this, "isIndependentNodes"); c(this, "rtl"); c(this, "listClassName"); c(this, "isBoostedRendering"); c(this, "iconElements"); c(this, "inputCallback"); c(this, "openCallback"); c(this, "closeCallback"); c(this, "nameChangeCallback"); c(this, "searchCallback"); c(this, "openCloseGroupCallback"); // InnerState c(this, "ungroupedValue"); c(this, "groupedValue"); c(this, "allValue"); c(this, "isListOpened"); c(this, "selectedName"); c(this, "srcElement"); // Components g(this, m, null); g(this, p, null); // Resize props g(this, R, null); // List position scroll g(this, q, 0); // Timer for search text g(this, $, 0); // Outside listeners g(this, A, null); g(this, I, null); g(this, y, null); g(this, V, null); Le({ parentHtmlContainer: e, value: t, staticList: F, appendToBody: r, isSingleSelect: Ee }), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = l ?? 0, this.appendToBody = r ?? !1, this.alwaysOpen = !!(u && !H), this.showTags = f ?? !0, this.tagsCountText = w ?? "elements selected", this.tagsSortFn = k ?? null, this.clearable = E ?? !0, this.searchable = C ?? !0, this.placeholder = v ?? "Search...", this.grouped = L ?? !0, this.isGroupedValue = T ?? !1, this.listSlotHtmlComponent = N ?? null, this.disabled = H ?? !1, this.emptyText = W ?? "No results found...", this.staticList = !!(F && !this.appendToBody), this.id = Q ?? "", this.ariaLabel = Ot ?? "", this.isSingleSelect = Ee ?? !1, this.showCount = Ht ?? !1, this.disabledBranchNode = Pt ?? !1, this.direction = Vt ?? "auto", this.expandSelected = Bt ?? !1, this.saveScrollPosition = Dt ?? !0, this.isIndependentNodes = Gt ?? !1, this.rtl = Mt ?? !1, this.listClassName = Ft ?? "", this.isBoostedRendering = Rt ?? !1, this.iconElements = ke($t), this.inputCallback = Wt, this.openCallback = jt, this.closeCallback = Ut, this.nameChangeCallback = zt, this.searchCallback = Yt, this.openCloseGroupCallback = qt, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, a(this, d, ce).call(this, t); } mount() { Le({ parentHtmlContainer: this.parentHtmlContainer, value: this.value, staticList: this.staticList, appendToBody: this.appendToBody, isSingleSelect: this.isSingleSelect }), this.iconElements = ke(this.iconElements), a(this, d, ce).call(this, this.value); } updateValue(e) { const t = ys(e), s = n(this, m); s && (s.updateValue(t), a(this, d, he).call(this, s == null ? void 0 : s.selectedNodes)); } destroy() { var e; this.srcElement && (a(this, d, de).call(this), this.srcElement.innerHTML = "", this.srcElement = null, a(this, d, fe).call(this, !0), (e = n(this, m)) == null || e.destroy()); } focus() { n(this, p) && n(this, p).focus(); } toggleOpenClose() { n(this, p) && (n(this, p).openClose(), n(this, p).focus()); } // Outside Listeners scrollWindowHandler() { this.updateListPosition(); } focusWindowHandler(e) { var s, l; ((s = this.srcElement) == null ? void 0 : s.contains(e.target)) || ((l = n(this, m)) == null ? void 0 : l.srcElement.contains(e.target)) || this.blurWindowHandler(); } blurWindowHandler() { var e; (e = n(this, p)) == null || e.blur(), a(this, d, fe).call(this, !1), a(this, d, me).call(this, !1); } // Update direction of the list. Support appendToBody and standard mode with absolute updateListPosition() { var T; const e = this.srcElement, t = (T = n(this, m)) == null ? void 0 : T.srcElement; if (!e || !t) return; if (this.staticList) { t.setAttribute("direction", "bottom"), a(this, d, ue).call(this, !1, this.appendToBody); return; } const { height: s } = t.getBoundingClientRect(), { x: l, y: r, height: u, width: f } = e.getBoundingClientRect(), w = window.innerHeight, k = r, E = w - r - u; let C = k > E && k >= s && E < s; if (this.direction !== "auto" && (C = this.direction === "top"), this.appendToBody) { (t.style.top !== "0px" || t.style.left !== "0px") && (t.style.top = "0px", t.style.left = "0px"); const N = l + window.scrollX, H = C ? r + window.scrollY - s : r + window.scrollY + u; t.style.transform = `translate(${N}px,${H}px)`, t.style.width = `${f}px`; } const v = C ? "top" : "bottom"; t.getAttribute("direction") !== v && (t.setAttribute("direction", v), a(this, d, ue).call(this, C, this.appendToBody)); } } m = new WeakMap(), p = new WeakMap(), R = new WeakMap(), q = new WeakMap(), $ = new WeakMap(), A = new WeakMap(), I = new WeakMap(), y = new WeakMap(), V = new WeakMap(), d = new WeakSet(), ce = function(e) { var r; this.destroy(); const { container: t, list: s, input: l } = a(this, d, bt).call(this); this.srcElement = t, b(this, m, s), b(this, p, l), b(this, A, this.scrollWindowHandler.bind(this)), b(this, I, this.scrollWindowHandler.bind(this)), b(this, y, this.focusWindowHandler.bind(this)), b(this, V, this.blurWindowHandler.bind(this)), this.alwaysOpen && ((r = n(this, p)) == null || r.openClose()), this.disabled ? this.srcElement.classList.add("treeselect--disabled") : this.srcElement.classList.remove("treeselect--disabled"), this.updateValue(e ?? this.value); }, oe = function({ groupedNodes: e, nodes: t, allNodes: s }) { this.ungroupedValue = t ? Z(t) : [], this.groupedValue = e ? Z(e) : [], this.allValue = s ? Z(s) : []; let l = []; this.isIndependentNodes || this.isSingleSelect ? l = this.allValue : this.isGroupedValue ? l = this.groupedValue : l = this.ungroupedValue, this.value = Ts(l, this.isSingleSelect); }, bt = function() { const e = this.parentHtmlContainer; e.classList.add("treeselect"); const t = new xs({ value: [], // updateValue method calls in initMount method to set actual 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, isBoostedRendering: this.isBoostedRendering, iconElements: this.iconElements, inputCallback: (l) => a(this, d, kt).call(this, l), arrowClickCallback: (l, r) => a(this, d, Lt).call(this, l, r), mouseupCallback: () => { var l; return (l = n(this, p)) == null ? void 0 : l.focus(); } }), s = new Jt({ value: [], // updateValue method calls in initMount method to set actual 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: (l) => a(this, d, Ct).call(this, l), searchCallback: (l) => a(this, d, wt).call(this, l), openCallback: () => a(this, d, xt).call(this), closeCallback: () => a(this, d, de).call(this), keydownCallback: (l) => a(this, d, Et).call(this, l), focusCallback: () => a(this, d, vt).call(this), nameChangeCallback: (l) => a(this, d, St).call(this, l) }); return this.rtl && (e.setAttribute("dir", "rtl"), t.srcElement.setAttribute("dir", "rtl")), this.appendToBody && b(this, R, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s }; }, Ct = function(e) { var l, r; const t = Z(e); (l = n(this, m)) == null || l.updateValue(t); const s = ((r = n(this, m)) == null ? void 0 : r.selectedNodes) ?? {}; a(this, d, oe).call(this, s), a(this, d, ge).call(this); }, Et = function(e) { var t; this.isListOpened && ((t = n(this, m)) == null || t.callKeyAction(e)); }, wt = function(e) { n(this, $) && clearTimeout(n(this, $)), b(this, $, window.setTimeout(() => { var t; (t = n(this, m)) == null || t.updateSearchValue(e), this.updateListPosition(); }, 350)), a(this, d, Nt).call(this, e); }, vt = function() { a(this, d, me).call(this, !0), n(this, y) && n(this, y) && n(this, V) && (document.addEventListener("mousedown", n(this, y), !0), document.addEventListener("focus", n(this, y), !0), window.addEventListener("blur", n(this, V), { capture: !1 })); }, he = 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, p)) == null || s.updateValue(t), a(this, d, oe).call(this, e); }, kt = function(e) { var t, s, l; a(this, d, he).call(this, e), this.isSingleSelect && !this.alwaysOpen && ((t = n(this, p)) == null || t.openClose(), (s = n(this, p)) == null || s.clearSearch()), (l = n(this, p)) == null || l.focus(), a(this, d, ge).call(this); }, Lt = function(e, t) { var s; (s = n(this, p)) == null || s.focus(), this.updateListPosition(), a(this, d, _t).call(this, e, t); }, St = function(e) { this.selectedName !== e && (this.selectedName = e, a(this, d, Tt).call(this)); }, xt = function() { var e; this.isListOpened = !0, n(this, A) && n(this, I) && (window.addEventListener("scroll", n(this, A), !0), window.addEventListener("resize", n(this, I))), !(!n(this, m) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, m).srcElement), (e = n(this, R)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, m).srcElement), this.updateListPosition(), a(this, d, pe).call(this, !0), a(this, d, yt).call(this), a(this, d, At).call(this)); }, de = function() { var t; this.alwaysOpen || (this.isListOpened = !1, n(this, A) && n(this, I) && (window.removeEventListener("scroll", n(this, A), !0), window.removeEventListener("resize", n(this, I))), !n(this, m) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, m).srcElement) : this.srcElement.contains(n(this, m).srcElement)) || (b(this, q, n(this, m).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, m).srcElement), (t = n(this, R)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, m).srcElement), a(this, d, pe).call(this, !1), a(this, d, It).call(this)); }, ue = function(e, t) { if (!n(this, m) || !n(this, p)) return; const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", l = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom"; e ? (n(this, m).srcElement.classList.add(s), n(this, m).srcElement.classList.remove(l), n(this, p).srcElement.classList.add("treeselect-input--top"), n(this, p).srcElement.classList.remove("treeselect-input--bottom")) : (n(this, m).srcElement.classList.remove(s), n(this, m).srcElement.classList.add(l), n(this, p).srcElement.classList.remove("treeselect-input--top"), n(this, p).srcElement.classList.add("treeselect-input--bottom")); }, me = function(e) { !n(this, p) || !n(this, m) || (e ? (n(this, p).srcElement.classList.add("treeselect-input--focused"), n(this, m).srcElement.classList.add("treeselect-list--focused")) : (n(this, p).srcElement.classList.remove("treeselect-input--focused"), n(this, m).srcElement.classList.remove("treeselect-list--focused"))); }, pe = function(e) { var t, s, l, r; e ? (t = n(this, p)) == null || t.srcElement.classList.add("treeselect-input--opened") : (s = n(this, p)) == null || s.srcElement.classList.remove("treeselect-input--opened"), this.staticList ? (l = n(this, m)) == null || l.srcElement.classList.add("treeselect-list--static") : (r = n(this, m)) == null || r.srcElement.classList.remove("treeselect-list--static"); }, fe = function(e) { !n(this, A) || !n(this, I) || !n(this, y) || !n(this, V) || ((!