treeselectjs 0.10.0 → 0.11.0

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
@@ -9,8 +9,8 @@ A multi-select js component with nested options.
9
9
  - Typescript support
10
10
 
11
11
  Build data:
12
- - treeselectjs.mjs 50.80 kB │ gzip: 11.51 kB
13
- - treeselectjs.umd.js 41.22 kB │ gzip: 10.51 kB
12
+ - treeselectjs.mjs 51.08 kB │ gzip: 11.59 kB
13
+ - treeselectjs.umd.js 41.45 kB │ gzip: 10.57 kB
14
14
  - treeselectjs.css 6.93 kB │ gzip: 1.38 kB
15
15
 
16
16
  **Live Demo:** https://dipson88.github.io/treeselectjs/
@@ -25,13 +25,13 @@ Import treeselectjs (ES)
25
25
  ```
26
26
  import Treeselect from 'treeselectjs'
27
27
 
28
- @import 'treeselectjs/dist/treeselectjs.css // Styles
28
+ @import 'treeselectjs/dist/treeselectjs.css' // Styles
29
29
  ```
30
30
 
31
31
  Import treeselectjs (UMD)
32
32
  ```
33
- <script src="https://cdn.jsdelivr.net/npm/treeselectjs@0.10.0/dist/treeselectjs.umd.js"></script>
34
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/treeselectjs@0.10.0/dist/treeselectjs.css" />
33
+ <script src="https://cdn.jsdelivr.net/npm/treeselectjs@0.11.0/dist/treeselectjs.umd.js"></script>
34
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/treeselectjs@0.11.0/dist/treeselectjs.css" />
35
35
  ...
36
36
  <script>
37
37
  ...
@@ -142,6 +142,7 @@ Name | Type (default) | Description
142
142
  **direction** | String (auto) | A force direction for the list. Supported values: `auto`, `top`, `bottom`.
143
143
  **expandSelected** | Boolean (false) | All groups which have checked values will be expanded on the init.
144
144
  **saveScrollPosition** | Boolean (true) | The list saves the last scroll position before close. If you open the list your scroll will be on the previous position. If you set the value to `false` - the scroll will have position 0 and the first item will be focused every time.
145
+ **listClassName** | String ('') | A class name for list. Useful to change styles for `appendToBody` mode.
145
146
 
146
147
  #### Input settings props
147
148
  Name | Type (default) | Description
@@ -86,6 +86,7 @@ export declare interface ITreeselectParams {
86
86
  saveScrollPosition?: boolean;
87
87
  isIndependentNodes?: boolean;
88
88
  rtl?: boolean;
89
+ listClassName?: string;
89
90
  iconElements?: Partial<IconsType>;
90
91
  inputCallback?: (value: ValueType) => void;
91
92
  openCallback?: (value: ValueType) => void;
@@ -132,6 +133,7 @@ declare class Treeselect implements ITreeselect {
132
133
  saveScrollPosition: boolean;
133
134
  isIndependentNodes: boolean;
134
135
  rtl: boolean;
136
+ listClassName: string;
135
137
  iconElements: IconsType;
136
138
  inputCallback: ((value: ValueType) => void) | undefined;
137
139
  openCallback: ((value: ValueType) => void) | undefined;
@@ -145,7 +147,7 @@ declare class Treeselect implements ITreeselect {
145
147
  isListOpened: boolean;
146
148
  selectedName: string;
147
149
  srcElement: HTMLElement | null;
148
- constructor({ parentHtmlContainer, value, options, openLevel, appendToBody, alwaysOpen, showTags, tagsCountText, clearable, searchable, placeholder, grouped, isGroupedValue, listSlotHtmlComponent, disabled, emptyText, staticList, id, ariaLabel, isSingleSelect, showCount, disabledBranchNode, direction, expandSelected, saveScrollPosition, isIndependentNodes, rtl, iconElements, inputCallback, openCallback, closeCallback, nameChangeCallback, searchCallback, openCloseGroupCallback }: ITreeselectParams);
150
+ constructor({ parentHtmlContainer, value, options, openLevel, appendToBody, alwaysOpen, showTags, tagsCountText, clearable, searchable, placeholder, grouped, isGroupedValue, listSlotHtmlComponent, disabled, emptyText, staticList, id, ariaLabel, isSingleSelect, showCount, disabledBranchNode, direction, expandSelected, saveScrollPosition, isIndependentNodes, rtl, listClassName, iconElements, inputCallback, openCallback, closeCallback, nameChangeCallback, searchCallback, openCloseGroupCallback }: ITreeselectParams);
149
151
  mount(): void;
150
152
  updateValue(newValue: ValueInputType): void;
151
153
  destroy(): void;
@@ -1,6 +1,6 @@
1
- var ri = Object.defineProperty;
2
- var ci = (l, e, t) => e in l ? ri(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var c = (l, e, t) => (ci(l, typeof e != "symbol" ? e + "" : e, t), t), kt = (l, e, t) => {
1
+ var ci = Object.defineProperty;
2
+ var hi = (l, e, t) => e in l ? ci(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var c = (l, e, t) => (hi(l, typeof e != "symbol" ? e + "" : e, t), t), kt = (l, e, t) => {
4
4
  if (!e.has(l))
5
5
  throw TypeError("Cannot " + t);
6
6
  };
@@ -31,9 +31,9 @@ const Pt = {
31
31
  return Object.keys(Pt).forEach((t) => {
32
32
  e[t] || (e[t] = Pt[t]);
33
33
  }), e;
34
- }, hi = (l) => l.reduce((e, { name: t }, s) => (e += t, s < l.length - 1 && (e += ", "), e), "");
35
- var N, E, D, v, ue, Ht, H, W, pe, Gt, me, Mt, G, U, O, V, fe, Ft, be, qt, Ce, jt, ge, Rt, ke, $t, we, Wt, Ee, Ut, ve, zt, Le, Yt, ye, Kt, xe, Xt, Se, Jt, _e, Zt, Ae, Qt, Te, es, Ne, ts, z, wt;
36
- class di {
34
+ }, di = (l) => l.reduce((e, { name: t }, s) => (e += t, s < l.length - 1 && (e += ", "), e), "");
35
+ var T, E, H, v, ue, Ht, G, W, pe, Gt, me, Mt, M, U, O, D, fe, Ft, Ce, qt, be, jt, ge, Rt, ke, $t, we, Wt, Ee, Ut, ve, zt, Le, Yt, ye, Kt, xe, Xt, Se, Jt, _e, Zt, Ae, Qt, Ne, es, Te, ts, z, wt;
36
+ class ui {
37
37
  constructor({
38
38
  value: e,
39
39
  showTags: t,
@@ -42,30 +42,30 @@ class di {
42
42
  isAlwaysOpened: a,
43
43
  searchable: h,
44
44
  placeholder: d,
45
- disabled: C,
45
+ disabled: b,
46
46
  isSingleSelect: f,
47
- id: b,
47
+ id: C,
48
48
  ariaLabel: g,
49
49
  iconElements: k,
50
50
  inputCallback: w,
51
51
  searchCallback: y,
52
52
  openCallback: x,
53
- closeCallback: $,
53
+ closeCallback: V,
54
54
  keydownCallback: ae,
55
- focusCallback: Ct,
55
+ focusCallback: bt,
56
56
  blurCallback: gt,
57
57
  nameChangeCallback: oe
58
58
  }) {
59
59
  // Private methods
60
60
  r(this, ue);
61
- r(this, H);
61
+ r(this, G);
62
62
  r(this, pe);
63
63
  r(this, me);
64
- r(this, G);
64
+ r(this, M);
65
65
  r(this, O);
66
66
  r(this, fe);
67
- r(this, be);
68
67
  r(this, Ce);
68
+ r(this, be);
69
69
  r(this, ge);
70
70
  r(this, ke);
71
71
  r(this, we);
@@ -77,8 +77,8 @@ class di {
77
77
  r(this, Se);
78
78
  r(this, _e);
79
79
  r(this, Ae);
80
- r(this, Te);
81
80
  r(this, Ne);
81
+ r(this, Te);
82
82
  // Emits
83
83
  r(this, z);
84
84
  // Props
@@ -99,9 +99,9 @@ class di {
99
99
  c(this, "searchText");
100
100
  c(this, "srcElement");
101
101
  // PrivateInnerState
102
- r(this, N, void 0);
102
+ r(this, T, void 0);
103
103
  r(this, E, void 0);
104
- r(this, D, void 0);
104
+ r(this, H, void 0);
105
105
  r(this, v, void 0);
106
106
  // Callbacks
107
107
  c(this, "inputCallback");
@@ -112,62 +112,62 @@ class di {
112
112
  c(this, "focusCallback");
113
113
  c(this, "blurCallback");
114
114
  c(this, "nameChangeCallback");
115
- this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = h, this.placeholder = d, this.clearable = i, this.isAlwaysOpened = a, this.disabled = C, this.isSingleSelect = f, this.id = b, this.ariaLabel = g, this.iconElements = k, this.isOpened = !1, this.searchText = "", m(this, N, o(this, Ce, jt).call(this)), m(this, E, o(this, Le, Yt).call(this)), m(this, D, o(this, Se, Jt).call(this)), m(this, v, null), this.inputCallback = w, this.searchCallback = y, this.openCallback = x, this.closeCallback = $, this.keydownCallback = ae, this.focusCallback = Ct, this.blurCallback = gt, this.nameChangeCallback = oe, this.srcElement = o(this, fe, Ft).call(this, n(this, N), n(this, E), n(this, D)), o(this, ue, Ht).call(this);
115
+ this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = h, this.placeholder = d, this.clearable = i, this.isAlwaysOpened = a, this.disabled = b, this.isSingleSelect = f, this.id = C, this.ariaLabel = g, this.iconElements = k, this.isOpened = !1, this.searchText = "", m(this, T, o(this, be, jt).call(this)), m(this, E, o(this, Le, Yt).call(this)), m(this, H, o(this, Se, Jt).call(this)), m(this, v, null), this.inputCallback = w, this.searchCallback = y, this.openCallback = x, this.closeCallback = V, this.keydownCallback = ae, this.focusCallback = bt, this.blurCallback = gt, this.nameChangeCallback = oe, this.srcElement = o(this, fe, Ft).call(this, n(this, T), n(this, E), n(this, H)), o(this, ue, Ht).call(this);
116
116
  }
117
117
  // Public methods
118
118
  focus() {
119
119
  setTimeout(() => n(this, E).focus(), 0);
120
120
  }
121
121
  blur() {
122
- this.isOpened && o(this, O, V).call(this), this.clearSearch(), n(this, E).blur();
122
+ this.isOpened && o(this, O, D).call(this), this.clearSearch(), n(this, E).blur();
123
123
  }
124
124
  updateValue(e) {
125
- this.value = e, o(this, H, W).call(this), o(this, G, U).call(this);
125
+ this.value = e, o(this, G, W).call(this), o(this, M, U).call(this);
126
126
  }
127
127
  removeItem(e) {
128
- this.value = this.value.filter((t) => t.id !== e), o(this, z, wt).call(this), o(this, H, W).call(this), o(this, G, U).call(this);
128
+ this.value = this.value.filter((t) => t.id !== e), o(this, z, wt).call(this), o(this, G, W).call(this), o(this, M, U).call(this);
129
129
  }
130
130
  clear() {
131
- this.value = [], o(this, z, wt).call(this), o(this, H, W).call(this), this.clearSearch();
131
+ this.value = [], o(this, z, wt).call(this), o(this, G, W).call(this), this.clearSearch();
132
132
  }
133
133
  openClose() {
134
- o(this, O, V).call(this);
134
+ o(this, O, D).call(this);
135
135
  }
136
136
  clearSearch() {
137
- this.searchText = "", this.searchCallback(""), o(this, G, U).call(this);
137
+ this.searchText = "", this.searchCallback(""), o(this, M, U).call(this);
138
138
  }
139
139
  }
140
- N = new WeakMap(), E = new WeakMap(), D = new WeakMap(), v = new WeakMap(), ue = new WeakSet(), Ht = function() {
141
- o(this, H, W).call(this), o(this, G, U).call(this), o(this, pe, Gt).call(this);
142
- }, H = new WeakSet(), W = function() {
143
- if (n(this, N).innerHTML = "", this.showTags) {
144
- n(this, N).append(...o(this, ge, Rt).call(this));
145
- const e = hi(this.value);
140
+ T = new WeakMap(), E = new WeakMap(), H = new WeakMap(), v = new WeakMap(), ue = new WeakSet(), Ht = function() {
141
+ o(this, G, W).call(this), o(this, M, U).call(this), o(this, pe, Gt).call(this);
142
+ }, G = new WeakSet(), W = function() {
143
+ if (n(this, T).innerHTML = "", this.showTags) {
144
+ n(this, T).append(...o(this, ge, Rt).call(this));
145
+ const e = di(this.value);
146
146
  this.nameChangeCallback(e);
147
147
  } else {
148
148
  const e = o(this, ve, zt).call(this);
149
- n(this, N).appendChild(e), this.nameChangeCallback(e.innerText);
149
+ n(this, T).appendChild(e), this.nameChangeCallback(e.innerText);
150
150
  }
151
- n(this, N).appendChild(n(this, E));
151
+ n(this, T).appendChild(n(this, E));
152
152
  }, pe = new WeakSet(), Gt = function() {
153
153
  const e = [];
154
- n(this, D).innerHTML = "", this.clearable && e.push(o(this, _e, Zt).call(this)), this.isAlwaysOpened || e.push(o(this, Te, es).call(this, this.isOpened)), e.length && n(this, D).append(...e);
154
+ n(this, H).innerHTML = "", this.clearable && e.push(o(this, _e, Zt).call(this)), this.isAlwaysOpened || e.push(o(this, Ne, es).call(this, this.isOpened)), e.length && n(this, H).append(...e);
155
155
  }, me = new WeakSet(), Mt = function() {
156
156
  if (!this.isAlwaysOpened && n(this, v)) {
157
157
  const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
158
158
  I(e, n(this, v));
159
159
  }
160
- }, G = new WeakSet(), U = function() {
160
+ }, M = new WeakSet(), U = function() {
161
161
  var e;
162
162
  (e = this.value) != null && e.length ? (n(this, E).removeAttribute("placeholder"), this.srcElement.classList.remove("treeselect-input--value-not-selected")) : (n(this, E).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, E).value = this.searchText;
163
- }, O = new WeakSet(), V = function() {
163
+ }, O = new WeakSet(), D = function() {
164
164
  this.isOpened = !this.isOpened, o(this, me, Mt).call(this), this.isOpened ? this.openCallback() : this.closeCallback();
165
165
  }, fe = new WeakSet(), Ft = function(e, t, s) {
166
166
  const i = document.createElement("div");
167
- return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (a) => o(this, be, qt).call(this, a)), i.addEventListener("focus", () => this.focusCallback(), !0), i.addEventListener("blur", () => this.blurCallback(), !0), e.appendChild(t), i.append(e, s), i;
168
- }, be = new WeakSet(), qt = function(e) {
169
- e.stopPropagation(), this.isOpened || o(this, O, V).call(this), this.focus();
170
- }, Ce = new WeakSet(), jt = function() {
167
+ return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (a) => o(this, Ce, qt).call(this, a)), i.addEventListener("focus", () => this.focusCallback(), !0), i.addEventListener("blur", () => this.blurCallback(), !0), e.appendChild(t), i.append(e, s), i;
168
+ }, Ce = new WeakSet(), qt = function(e) {
169
+ e.stopPropagation(), this.isOpened || o(this, O, D).call(this), this.focus();
170
+ }, be = new WeakSet(), jt = function() {
171
171
  const e = document.createElement("div");
172
172
  return e.classList.add("treeselect-input__tags"), e;
173
173
  }, ge = new WeakSet(), Rt = function() {
@@ -197,7 +197,7 @@ N = new WeakMap(), E = new WeakMap(), D = new WeakMap(), v = new WeakMap(), ue =
197
197
  }, ye = new WeakSet(), Kt = function(e) {
198
198
  e.stopPropagation();
199
199
  const t = e.key;
200
- 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, O, V).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
200
+ 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, O, D).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
201
201
  }, xe = new WeakSet(), Xt = function(e, t) {
202
202
  e.stopPropagation();
203
203
  const s = this.searchText, i = t.value.trim();
@@ -207,7 +207,7 @@ N = new WeakMap(), E = new WeakMap(), D = new WeakMap(), v = new WeakMap(), ue =
207
207
  }
208
208
  if (this.searchable) {
209
209
  const a = e.target.value;
210
- this.searchCallback(a), this.isOpened || o(this, O, V).call(this);
210
+ this.searchCallback(a), this.isOpened || o(this, O, D).call(this);
211
211
  } else
212
212
  t.value = "";
213
213
  this.searchText = t.value;
@@ -219,17 +219,17 @@ N = new WeakMap(), E = new WeakMap(), D = new WeakMap(), v = new WeakMap(), ue =
219
219
  return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), I(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => o(this, Ae, Qt).call(this, t)), e;
220
220
  }, Ae = new WeakSet(), Qt = function(e) {
221
221
  e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus();
222
- }, Te = new WeakSet(), es = function(e) {
222
+ }, Ne = new WeakSet(), es = function(e) {
223
223
  m(this, v, document.createElement("span")), n(this, v).classList.add("treeselect-input__arrow");
224
224
  const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown;
225
- return I(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => o(this, Ne, ts).call(this, s)), n(this, v);
226
- }, Ne = new WeakSet(), ts = function(e) {
227
- e.stopPropagation(), e.preventDefault(), this.focus(), o(this, O, V).call(this);
225
+ return I(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => o(this, Te, ts).call(this, s)), n(this, v);
226
+ }, Te = new WeakSet(), ts = function(e) {
227
+ e.stopPropagation(), e.preventDefault(), this.focus(), o(this, O, D).call(this);
228
228
  }, z = new WeakSet(), wt = function() {
229
229
  this.inputCallback(this.value);
230
230
  };
231
231
  const ss = (l, e, t, s) => {
232
- fi(e);
232
+ Ci(e);
233
233
  const i = e.filter((a) => !a.disabled && l.some((h) => h === a.id));
234
234
  if (t && i.length) {
235
235
  i[0].checked = !0;
@@ -257,18 +257,18 @@ const ss = (l, e, t, s) => {
257
257
  }), e.checked) : (e.checked = !0, e.isPartialChecked = !1, Et(e, s, t), e.checked);
258
258
  }, ls = (l, e) => {
259
259
  const t = e.find((s) => s.id === l.childOf);
260
- t && (ui(t, e), ls(t, e));
261
- }, ui = (l, e) => {
260
+ t && (pi(t, e), ls(t, e));
261
+ }, pi = (l, e) => {
262
262
  const t = ft(l, e);
263
263
  if (as(t)) {
264
264
  l.checked = !1, l.isPartialChecked = !1, l.disabled = !0;
265
265
  return;
266
266
  }
267
- if (pi(t)) {
267
+ if (mi(t)) {
268
268
  l.checked = !0, l.isPartialChecked = !1;
269
269
  return;
270
270
  }
271
- if (mi(t)) {
271
+ if (fi(t)) {
272
272
  l.checked = !1, l.isPartialChecked = !0;
273
273
  return;
274
274
  }
@@ -285,16 +285,16 @@ const ss = (l, e, t, s) => {
285
285
  return ns(a, e);
286
286
  }
287
287
  return !1;
288
- }), as = (l) => l.every((e) => !!e.disabled), pi = (l) => l.every((e) => !!e.checked), mi = (l) => l.some((e) => !!e.checked || !!e.isPartialChecked), fi = (l) => {
288
+ }), as = (l) => l.every((e) => !!e.disabled), mi = (l) => l.every((e) => !!e.checked), fi = (l) => l.some((e) => !!e.checked || !!e.isPartialChecked), Ci = (l) => {
289
289
  l.forEach((e) => {
290
290
  e.checked = !1, e.isPartialChecked = !1;
291
291
  });
292
292
  }, bi = (l, e, t) => {
293
293
  const s = { level: 0, groupId: "" }, i = os(l, e, s.groupId, s.level);
294
- return gi(i, t);
294
+ return ki(i, t);
295
295
  }, os = (l, e, t, s) => l.reduce((i, a) => {
296
296
  var f;
297
- const h = !!((f = a.children) != null && f.length), d = s >= e && h, C = s > e;
297
+ const h = !!((f = a.children) != null && f.length), d = s >= e && h, b = s > e;
298
298
  if (i.push({
299
299
  id: a.value,
300
300
  name: a.name,
@@ -304,14 +304,14 @@ const ss = (l, e, t, s) => {
304
304
  isPartialChecked: !1,
305
305
  level: s,
306
306
  isClosed: d,
307
- hidden: C,
307
+ hidden: b,
308
308
  disabled: a.disabled ?? !1
309
309
  }), h) {
310
- const b = os(a.children, e, a.value, s + 1);
311
- i.push(...b);
310
+ const C = os(a.children, e, a.value, s + 1);
311
+ i.push(...C);
312
312
  }
313
313
  return i;
314
- }, []), ft = ({ id: l }, e) => e.filter((t) => t.childOf === l), Ci = (l) => {
314
+ }, []), ft = ({ id: l }, e) => e.filter((t) => t.childOf === l), gi = (l) => {
315
315
  const { ungroupedNodes: e, allGroupedNodes: t, allNodes: s } = l.reduce(
316
316
  (a, h) => (h.checked && (a.allNodes.push(h), h.isGroup ? a.allGroupedNodes.push(h) : a.ungroupedNodes.push(h)), a),
317
317
  {
@@ -321,22 +321,22 @@ const ss = (l, e, t, s) => {
321
321
  }
322
322
  ), i = s.filter((a) => !t.some(({ id: h }) => h === a.childOf));
323
323
  return { ungroupedNodes: e, groupedNodes: i, allNodes: s };
324
- }, gi = (l, e) => (l.filter((s) => !!s.disabled).forEach(
324
+ }, ki = (l, e) => (l.filter((s) => !!s.disabled).forEach(
325
325
  ({ id: s }) => It({ id: s, checked: !1 }, l, e)
326
- ), l), bt = (l, { id: e, isClosed: t }) => {
326
+ ), l), Ct = (l, { id: e, isClosed: t }) => {
327
327
  ft({ id: e }, l).forEach((i) => {
328
- i.hidden = t ?? !1, i.isGroup && !i.isClosed && bt(l, { id: i.id, isClosed: t });
328
+ i.hidden = t ?? !1, i.isGroup && !i.isClosed && Ct(l, { id: i.id, isClosed: t });
329
329
  });
330
- }, ki = (l) => {
330
+ }, wi = (l) => {
331
331
  l.filter((e) => e.isGroup && !e.disabled && (e.checked || e.isPartialChecked)).forEach((e) => {
332
- e.isClosed = !1, bt(l, e);
332
+ e.isClosed = !1, Ct(l, e);
333
333
  });
334
- }, wi = (l, e) => {
335
- const t = Ei(l, e);
334
+ }, Ei = (l, e) => {
335
+ const t = vi(l, e);
336
336
  l.forEach((s) => {
337
- t.some(({ id: a }) => a === s.id) ? (s.isGroup && (s.isClosed = !1, bt(l, s)), s.hidden = !1) : s.hidden = !0;
337
+ t.some(({ id: a }) => a === s.id) ? (s.isGroup && (s.isClosed = !1, Ct(l, s)), s.hidden = !1) : s.hidden = !0;
338
338
  });
339
- }, Ei = (l, e) => l.reduce((t, s) => {
339
+ }, vi = (l, e) => l.reduce((t, s) => {
340
340
  if (s.name.toLowerCase().includes(e.toLowerCase())) {
341
341
  if (t.push(s), s.isGroup) {
342
342
  const a = rs(s.id, l);
@@ -348,7 +348,7 @@ const ss = (l, e, t, s) => {
348
348
  }
349
349
  }
350
350
  return t;
351
- }, []), rs = (l, e) => e.reduce((t, s) => (s.childOf === l && (t.push(s), s.isGroup && t.push(...rs(s.id, e))), t), []), cs = (l, e) => e.reduce((t, s) => (s.id === l && (t.push(s), s.childOf && t.push(...cs(s.childOf, e))), t), []), vi = (l) => {
351
+ }, []), rs = (l, e) => e.reduce((t, s) => (s.childOf === l && (t.push(s), s.isGroup && t.push(...rs(s.id, e))), t), []), cs = (l, e) => e.reduce((t, s) => (s.id === l && (t.push(s), s.childOf && t.push(...cs(s.childOf, e))), t), []), Li = (l) => {
352
352
  const { duplications: e } = l.reduce(
353
353
  (t, s) => (t.allItems.some((i) => i.toString() === s.id.toString()) && t.duplications.push(s.id), t.allItems.push(s.id), t),
354
354
  {
@@ -357,50 +357,50 @@ const ss = (l, e, t, s) => {
357
357
  }
358
358
  );
359
359
  e.length && console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`);
360
- }, Li = (l, e, t, s, i, a, h, d, C, f) => {
361
- ss(l, e, i, C), d && h && ki(e), ce(e, t, s, a, f);
360
+ }, yi = (l, e, t, s, i, a, h, d, b, f) => {
361
+ ss(l, e, i, b), d && h && wi(e), ce(e, t, s, a, f);
362
362
  }, ce = (l, e, t, s, i) => {
363
363
  l.forEach((a) => {
364
- const h = e.querySelector(`[input-id="${a.id}"]`), d = T(h);
365
- h.checked = a.checked, yi(a, d, s), xi(a, d), Si(a, d), _i(a, d, t), Ai(a, d), Ni(a, d, l, i), Ti(a, h, t);
366
- }), Oi(l, e);
367
- }, yi = (l, e, t) => {
364
+ const h = e.querySelector(`[input-id="${a.id}"]`), d = N(h);
365
+ h.checked = a.checked, xi(a, d, s), Si(a, d), _i(a, d), Ai(a, d, t), Ni(a, d), Oi(a, d, l, i), Ti(a, h, t);
366
+ }), Ii(l, e);
367
+ }, xi = (l, e, t) => {
368
368
  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");
369
- }, xi = (l, e) => {
370
- l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
371
369
  }, Si = (l, e) => {
370
+ l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
371
+ }, _i = (l, e) => {
372
372
  l.disabled ? e.classList.add("treeselect-list__item--disabled") : e.classList.remove("treeselect-list__item--disabled");
373
- }, _i = (l, e, t) => {
373
+ }, Ai = (l, e, t) => {
374
374
  if (l.isGroup) {
375
375
  const s = e.querySelector(".treeselect-list__item-icon"), i = l.isClosed ? t.arrowRight : t.arrowDown;
376
376
  I(i, s), l.isClosed ? e.classList.add("treeselect-list__item--closed") : e.classList.remove("treeselect-list__item--closed");
377
377
  }
378
- }, Ai = (l, e) => {
378
+ }, Ni = (l, e) => {
379
379
  l.hidden ? e.classList.add("treeselect-list__item--hidden") : e.classList.remove("treeselect-list__item--hidden");
380
380
  }, Ti = (l, e, t) => {
381
381
  const i = e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");
382
382
  l.checked ? I(t.check, i) : l.isPartialChecked ? I(t.partialCheck, i) : i.innerHTML = "";
383
- }, Ni = (l, e, t, s) => {
383
+ }, Oi = (l, e, t, s) => {
384
384
  const i = l.level === 0, a = 20, h = 5;
385
385
  if (i) {
386
- const d = t.some((b) => b.isGroup && b.level === l.level), C = !l.isGroup && d ? `${a}px` : `${h}px`, f = l.isGroup ? "0" : C;
386
+ const d = t.some((C) => C.isGroup && C.level === l.level), b = !l.isGroup && d ? `${a}px` : `${h}px`, f = l.isGroup ? "0" : b;
387
387
  s ? e.style.paddingRight = f : e.style.paddingLeft = f;
388
388
  } else {
389
389
  const d = l.isGroup ? `${l.level * a}px` : `${l.level * a + a}px`;
390
390
  s ? e.style.paddingRight = d : e.style.paddingLeft = d;
391
391
  }
392
392
  e.setAttribute("level", l.level.toString()), e.setAttribute("group", l.isGroup.toString());
393
- }, Oi = (l, e) => {
393
+ }, Ii = (l, e) => {
394
394
  const t = l.some((i) => !i.hidden), s = e.querySelector(".treeselect-list__empty");
395
395
  t ? s.classList.add("treeselect-list__empty--hidden") : s.classList.remove("treeselect-list__empty--hidden");
396
- }, T = (l) => l.parentNode.parentNode, Vt = (l, e) => e.find((t) => t.id.toString() === l), Ii = (l) => T(l).querySelector(".treeselect-list__item-icon"), Pi = (l, e) => {
396
+ }, N = (l) => l.parentNode.parentNode, Vt = (l, e) => e.find((t) => t.id.toString() === l), Pi = (l) => N(l).querySelector(".treeselect-list__item-icon"), Bi = (l, e) => {
397
397
  e && Object.keys(e).forEach((t) => {
398
398
  const s = e[t];
399
399
  typeof s == "string" && l.setAttribute(t, s);
400
400
  });
401
401
  };
402
- var M, P, S, Y, Oe, hs, Ie, ds, Pe, us, Be, ps, Ve, ms, De, fs, K, vt, He, bs, Ge, Cs, Me, gs, X, Lt, Fe, ks, qe, ws, je, Es, Re, vs, $e, Ls, We, ys, Ue, xs, ze, Ss, Ye, _s, Ke, As, Xe, Ts, J, yt, Z, xt, Je, Ns;
403
- class Bi {
402
+ var F, P, S, Y, Oe, hs, Ie, ds, Pe, us, Be, ps, Ve, ms, De, fs, K, vt, He, Cs, Ge, bs, Me, gs, X, Lt, Fe, ks, qe, ws, je, Es, Re, vs, $e, Ls, We, ys, Ue, xs, ze, Ss, Ye, _s, Ke, As, Xe, Ns, J, yt, Z, xt, Je, Ts;
403
+ class Vi {
404
404
  constructor({
405
405
  options: e,
406
406
  value: t,
@@ -409,14 +409,15 @@ class Bi {
409
409
  emptyText: a,
410
410
  isSingleSelect: h,
411
411
  iconElements: d,
412
- showCount: C,
412
+ showCount: b,
413
413
  disabledBranchNode: f,
414
- expandSelected: b,
414
+ expandSelected: C,
415
415
  isIndependentNodes: g,
416
416
  rtl: k,
417
- inputCallback: w,
418
- arrowClickCallback: y,
419
- mouseupCallback: x
417
+ listClassName: w,
418
+ inputCallback: y,
419
+ arrowClickCallback: x,
420
+ mouseupCallback: V
420
421
  }) {
421
422
  // Private methods
422
423
  r(this, Oe);
@@ -458,6 +459,7 @@ class Bi {
458
459
  c(this, "expandSelected");
459
460
  c(this, "isIndependentNodes");
460
461
  c(this, "rtl");
462
+ c(this, "listClassName");
461
463
  c(this, "iconElements");
462
464
  // InnerState
463
465
  c(this, "searchText");
@@ -470,15 +472,15 @@ class Bi {
470
472
  c(this, "arrowClickCallback");
471
473
  c(this, "mouseupCallback");
472
474
  // PrivateInnerState
473
- r(this, M, null);
475
+ r(this, F, null);
474
476
  r(this, P, !0);
475
477
  r(this, S, []);
476
478
  r(this, Y, !0);
477
- this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = a ?? "No results found...", this.isSingleSelect = h ?? !1, this.showCount = C ?? !1, this.disabledBranchNode = f ?? !1, this.expandSelected = b ?? !1, this.isIndependentNodes = g ?? !1, this.rtl = k ?? !1, this.iconElements = d, this.searchText = "", this.flattedOptions = bi(this.options, this.openLevel, this.isIndependentNodes), this.flattedOptionsBeforeSearch = this.flattedOptions, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.srcElement = o(this, Pe, us).call(this), this.inputCallback = w, this.arrowClickCallback = y, this.mouseupCallback = x, vi(this.flattedOptions);
479
+ this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = a ?? "No results found...", this.isSingleSelect = h ?? !1, this.showCount = b ?? !1, this.disabledBranchNode = f ?? !1, this.expandSelected = C ?? !1, this.isIndependentNodes = g ?? !1, this.rtl = k ?? !1, this.listClassName = w ?? "", this.iconElements = d, this.searchText = "", this.flattedOptions = bi(this.options, this.openLevel, this.isIndependentNodes), this.flattedOptionsBeforeSearch = this.flattedOptions, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.srcElement = o(this, Pe, us).call(this), this.inputCallback = y, this.arrowClickCallback = x, this.mouseupCallback = V, Li(this.flattedOptions);
478
480
  }
479
481
  // Public methods
480
482
  updateValue(e) {
481
- this.value = e, m(this, S, this.isSingleSelect ? this.value : []), Li(
483
+ this.value = e, m(this, S, this.isSingleSelect ? this.value : []), yi(
482
484
  e,
483
485
  this.flattedOptions,
484
486
  this.srcElement,
@@ -498,7 +500,7 @@ class Bi {
498
500
  this.searchText = e, t && (this.flattedOptionsBeforeSearch = JSON.parse(JSON.stringify(this.flattedOptions))), this.searchText === "" && (this.flattedOptions = this.flattedOptionsBeforeSearch.map((s) => {
499
501
  const i = this.flattedOptions.find((a) => a.id === s.id);
500
502
  return i.isClosed = s.isClosed, i.hidden = s.hidden, i;
501
- }), this.flattedOptionsBeforeSearch = []), this.searchText && wi(this.flattedOptions, e), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.focusFirstListElement();
503
+ }), this.flattedOptionsBeforeSearch = []), this.searchText && Ei(this.flattedOptions, e), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.focusFirstListElement();
502
504
  }
503
505
  callKeyAction(e) {
504
506
  m(this, P, !1);
@@ -510,17 +512,17 @@ class Bi {
510
512
  }
511
513
  focusFirstListElement() {
512
514
  const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
513
- (a) => window.getComputedStyle(T(a)).display !== "none"
515
+ (a) => window.getComputedStyle(N(a)).display !== "none"
514
516
  );
515
517
  if (!s.length)
516
518
  return;
517
- t && t.classList.remove(e), T(s[0]).classList.add(e);
519
+ t && t.classList.remove(e), N(s[0]).classList.add(e);
518
520
  }
519
521
  isLastFocusedElementExist() {
520
- return !!n(this, M);
522
+ return !!n(this, F);
521
523
  }
522
524
  }
523
- M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe = new WeakSet(), hs = function(e, t) {
525
+ F = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe = new WeakSet(), hs = function(e, t) {
524
526
  if (!e)
525
527
  return;
526
528
  const s = t.key, a = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), h = Vt(a, this.flattedOptions), d = e.querySelector(".treeselect-list__item-icon");
@@ -528,24 +530,24 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
528
530
  }, Ie = new WeakSet(), ds = function(e, t) {
529
531
  var i;
530
532
  const s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
531
- (a) => window.getComputedStyle(T(a)).display !== "none"
533
+ (a) => window.getComputedStyle(N(a)).display !== "none"
532
534
  );
533
535
  if (s.length)
534
536
  if (!e)
535
- T(s[0]).classList.add("treeselect-list__item--focused");
537
+ N(s[0]).classList.add("treeselect-list__item--focused");
536
538
  else {
537
539
  const a = s.findIndex(
538
- (x) => T(x).classList.contains("treeselect-list__item--focused")
540
+ (x) => N(x).classList.contains("treeselect-list__item--focused")
539
541
  );
540
- T(s[a]).classList.remove("treeselect-list__item--focused");
541
- const d = t === "ArrowDown" ? a + 1 : a - 1, C = t === "ArrowDown" ? 0 : s.length - 1, f = s[d] ?? s[C], b = !s[d], g = T(f);
542
+ N(s[a]).classList.remove("treeselect-list__item--focused");
543
+ const d = t === "ArrowDown" ? a + 1 : a - 1, b = t === "ArrowDown" ? 0 : s.length - 1, f = s[d] ?? s[b], C = !s[d], g = N(f);
542
544
  g.classList.add("treeselect-list__item--focused");
543
545
  const k = this.srcElement.getBoundingClientRect(), w = g.getBoundingClientRect();
544
- if (b && t === "ArrowDown") {
546
+ if (C && t === "ArrowDown") {
545
547
  this.srcElement.scroll(0, 0);
546
548
  return;
547
549
  }
548
- if (b && t === "ArrowUp") {
550
+ if (C && t === "ArrowUp") {
549
551
  this.srcElement.scroll(0, this.srcElement.scrollHeight);
550
552
  return;
551
553
  }
@@ -562,15 +564,15 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
562
564
  }, Pe = new WeakSet(), us = function() {
563
565
  const e = o(this, Be, ps).call(this), t = o(this, K, vt).call(this, this.options);
564
566
  e.append(...t);
565
- const s = o(this, Ge, Cs).call(this);
567
+ const s = o(this, Ge, bs).call(this);
566
568
  e.append(s);
567
- const i = o(this, He, bs).call(this);
569
+ const i = o(this, He, Cs).call(this);
568
570
  return i && e.append(i), e;
569
571
  }, Be = new WeakSet(), ps = function() {
570
572
  const e = document.createElement("div");
571
- return e.classList.add("treeselect-list"), 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, Ve, ms).call(this, t)), e.addEventListener("mousemove", () => o(this, De, fs).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), e;
573
+ 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, Ve, ms).call(this, t)), e.addEventListener("mousemove", () => o(this, De, fs).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), e;
572
574
  }, Ve = new WeakSet(), ms = function(e) {
573
- e.stopPropagation(), n(this, M) && n(this, P) && n(this, M).classList.add("treeselect-list__item--focused");
575
+ e.stopPropagation(), n(this, F) && n(this, P) && n(this, F).classList.add("treeselect-list__item--focused");
574
576
  }, De = new WeakSet(), fs = function() {
575
577
  m(this, P, !0);
576
578
  }, K = new WeakSet(), vt = function(e) {
@@ -583,12 +585,12 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
583
585
  const i = o(this, X, Lt).call(this, s, !1);
584
586
  return t.push(i), t;
585
587
  }, []);
586
- }, He = new WeakSet(), bs = function() {
588
+ }, He = new WeakSet(), Cs = function() {
587
589
  if (!this.listSlotHtmlComponent)
588
590
  return null;
589
591
  const e = document.createElement("div");
590
592
  return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
591
- }, Ge = new WeakSet(), Cs = function() {
593
+ }, Ge = new WeakSet(), bs = function() {
592
594
  const e = document.createElement("div");
593
595
  e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
594
596
  const t = document.createElement("span");
@@ -610,11 +612,11 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
610
612
  return s.append(i, a), s;
611
613
  }, Fe = new WeakSet(), ks = function(e) {
612
614
  const t = document.createElement("div");
613
- return Pi(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, qe, ws).call(this, t), !0), t.addEventListener("mouseout", () => o(this, je, Es).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, Re, vs).call(this, s, e)), t;
615
+ return Bi(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, qe, ws).call(this, t), !0), t.addEventListener("mouseout", () => o(this, je, Es).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, Re, vs).call(this, s, e)), t;
614
616
  }, qe = new WeakSet(), ws = function(e) {
615
617
  n(this, P) && o(this, J, yt).call(this, !0, e);
616
618
  }, je = new WeakSet(), Es = function(e) {
617
- n(this, P) && (o(this, J, yt).call(this, !1, e), m(this, M, e));
619
+ n(this, P) && (o(this, J, yt).call(this, !1, e), m(this, F, e));
618
620
  }, Re = new WeakSet(), vs = function(e, t) {
619
621
  var a;
620
622
  if (e.preventDefault(), e.stopPropagation(), (a = this.flattedOptions.find((h) => h.id === t.value)) == null ? void 0 : a.disabled)
@@ -625,7 +627,7 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
625
627
  const e = document.createElement("span");
626
628
  return e.setAttribute("tabindex", "-1"), e.classList.add("treeselect-list__item-icon"), I(this.iconElements.arrowDown, e), e.addEventListener("mousedown", (t) => o(this, We, ys).call(this, t)), e;
627
629
  }, We = new WeakSet(), ys = function(e) {
628
- e.preventDefault(), e.stopPropagation(), o(this, Xe, Ts).call(this, e);
630
+ e.preventDefault(), e.stopPropagation(), o(this, Xe, Ns).call(this, e);
629
631
  }, Ue = new WeakSet(), xs = function(e) {
630
632
  const t = document.createElement("div");
631
633
  t.classList.add("treeselect-list__item-checkbox-container");
@@ -647,7 +649,7 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
647
649
  const s = this.flattedOptions.find((i) => i.id === t.value);
648
650
  if (s) {
649
651
  if (s != null && s.isGroup && this.disabledBranchNode) {
650
- const i = Ii(e);
652
+ const i = Pi(e);
651
653
  i == null || i.dispatchEvent(new Event("mousedown"));
652
654
  return;
653
655
  }
@@ -661,12 +663,12 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
661
663
  const i = It(s, this.flattedOptions, this.isIndependentNodes);
662
664
  e.checked = i;
663
665
  }
664
- ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), o(this, Je, Ns).call(this);
666
+ ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), o(this, Je, Ts).call(this);
665
667
  }
666
- }, Xe = new WeakSet(), Ts = function(e) {
668
+ }, Xe = new WeakSet(), Ns = function(e) {
667
669
  var a, h;
668
670
  const t = (h = (a = e.target) == null ? void 0 : a.parentNode) == null ? void 0 : h.querySelector("[input-id]"), s = (t == null ? void 0 : t.getAttribute("input-id")) ?? null, i = Vt(s, this.flattedOptions);
669
- i && (i.isClosed = !i.isClosed, bt(this.flattedOptions, i), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.arrowClickCallback(i.id, i.isClosed));
671
+ i && (i.isClosed = !i.isClosed, Ct(this.flattedOptions, i), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.arrowClickCallback(i.id, i.isClosed));
670
672
  }, J = new WeakSet(), yt = function(e, t) {
671
673
  const s = "treeselect-list__item--focused";
672
674
  if (e) {
@@ -675,9 +677,9 @@ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe =
675
677
  } else
676
678
  t.classList.remove(s);
677
679
  }, Z = new WeakSet(), xt = function() {
678
- const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = Ci(this.flattedOptions);
680
+ const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = gi(this.flattedOptions);
679
681
  this.selectedNodes = { nodes: e, groupedNodes: t, allNodes: s };
680
- }, Je = new WeakSet(), Ns = function() {
682
+ }, Je = new WeakSet(), Ts = function() {
681
683
  o(this, Z, xt).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
682
684
  };
683
685
  const Dt = ({
@@ -689,15 +691,15 @@ const Dt = ({
689
691
  direction: a
690
692
  }) => {
691
693
  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!");
692
- }, re = (l) => l.map((e) => e.id), Vi = (l) => l ? Array.isArray(l) ? l : [l] : [], Di = (l, e) => {
694
+ }, re = (l) => l.map((e) => e.id), Di = (l) => l ? Array.isArray(l) ? l : [l] : [], Hi = (l, e) => {
693
695
  if (e) {
694
696
  const [t] = l;
695
697
  return t ?? null;
696
698
  }
697
699
  return l;
698
700
  };
699
- var u, p, F, Q, q, _, A, L, B, ee, St, te, _t, Ze, Os, Qe, Is, et, Ps, tt, Bs, st, Vs, it, Ds, se, At, lt, Hs, nt, Gs, at, Ms, ot, Fs, ie, Tt, rt, qs, j, he, le, Nt, R, de, ct, js, ne, Ot, ht, Rs, dt, $s, ut, Ws, pt, Us, mt, zs;
700
- class Gi {
701
+ var u, p, q, Q, j, _, A, L, B, ee, St, te, _t, Ze, Os, Qe, Is, et, Ps, tt, Bs, st, Vs, it, Ds, se, At, lt, Hs, nt, Gs, at, Ms, ot, Fs, ie, Nt, rt, qs, R, he, le, Tt, $, de, ct, js, ne, Ot, ht, Rs, dt, $s, ut, Ws, pt, Us, mt, zs;
702
+ class Mi {
701
703
  constructor({
702
704
  parentHtmlContainer: e,
703
705
  value: t,
@@ -706,17 +708,17 @@ class Gi {
706
708
  appendToBody: a,
707
709
  alwaysOpen: h,
708
710
  showTags: d,
709
- tagsCountText: C,
711
+ tagsCountText: b,
710
712
  clearable: f,
711
- searchable: b,
713
+ searchable: C,
712
714
  placeholder: g,
713
715
  grouped: k,
714
716
  isGroupedValue: w,
715
717
  listSlotHtmlComponent: y,
716
718
  disabled: x,
717
- emptyText: $,
719
+ emptyText: V,
718
720
  staticList: ae,
719
- id: Ct,
721
+ id: bt,
720
722
  ariaLabel: gt,
721
723
  isSingleSelect: oe,
722
724
  showCount: Ys,
@@ -726,13 +728,14 @@ class Gi {
726
728
  saveScrollPosition: Zs,
727
729
  isIndependentNodes: Qs,
728
730
  rtl: ei,
729
- iconElements: ti,
730
- inputCallback: si,
731
- openCallback: ii,
732
- closeCallback: li,
733
- nameChangeCallback: ni,
734
- searchCallback: ai,
735
- openCloseGroupCallback: oi
731
+ listClassName: ti,
732
+ iconElements: si,
733
+ inputCallback: ii,
734
+ openCallback: li,
735
+ closeCallback: ni,
736
+ nameChangeCallback: ai,
737
+ searchCallback: oi,
738
+ openCloseGroupCallback: ri
736
739
  }) {
737
740
  r(this, ee);
738
741
  r(this, te);
@@ -749,9 +752,9 @@ class Gi {
749
752
  r(this, ot);
750
753
  r(this, ie);
751
754
  r(this, rt);
752
- r(this, j);
753
- r(this, le);
754
755
  r(this, R);
756
+ r(this, le);
757
+ r(this, $);
755
758
  r(this, ct);
756
759
  // Emits
757
760
  r(this, ne);
@@ -788,6 +791,7 @@ class Gi {
788
791
  c(this, "saveScrollPosition");
789
792
  c(this, "isIndependentNodes");
790
793
  c(this, "rtl");
794
+ c(this, "listClassName");
791
795
  c(this, "iconElements");
792
796
  c(this, "inputCallback");
793
797
  c(this, "openCallback");
@@ -806,11 +810,11 @@ class Gi {
806
810
  r(this, u, null);
807
811
  r(this, p, null);
808
812
  // Resize props
809
- r(this, F, null);
813
+ r(this, q, null);
810
814
  // List position scroll
811
815
  r(this, Q, 0);
812
816
  // Timer for search text
813
- r(this, q, 0);
817
+ r(this, j, 0);
814
818
  // Outside listeners
815
819
  r(this, _, null);
816
820
  r(this, A, null);
@@ -822,7 +826,7 @@ class Gi {
822
826
  staticList: ae,
823
827
  appendToBody: a,
824
828
  isSingleSelect: oe
825
- }), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = a ?? !1, this.alwaysOpen = !!(h && !x), this.showTags = d ?? !0, this.tagsCountText = C ?? "elements selected", this.clearable = f ?? !0, this.searchable = b ?? !0, this.placeholder = g ?? "Search...", this.grouped = k ?? !0, this.isGroupedValue = w ?? !1, this.listSlotHtmlComponent = y ?? null, this.disabled = x ?? !1, this.emptyText = $ ?? "No results found...", this.staticList = !!(ae && !this.appendToBody), this.id = Ct ?? "", this.ariaLabel = gt ?? "", this.isSingleSelect = oe ?? !1, this.showCount = Ys ?? !1, this.disabledBranchNode = Ks ?? !1, this.direction = Xs ?? "auto", this.expandSelected = Js ?? !1, this.saveScrollPosition = Zs ?? !0, this.isIndependentNodes = Qs ?? !1, this.rtl = ei ?? !1, this.iconElements = Bt(ti), this.inputCallback = si, this.openCallback = ii, this.closeCallback = li, this.nameChangeCallback = ni, this.searchCallback = ai, this.openCloseGroupCallback = oi, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, o(this, ee, St).call(this, t);
829
+ }), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = a ?? !1, this.alwaysOpen = !!(h && !x), this.showTags = d ?? !0, this.tagsCountText = b ?? "elements selected", this.clearable = f ?? !0, this.searchable = C ?? !0, this.placeholder = g ?? "Search...", this.grouped = k ?? !0, this.isGroupedValue = w ?? !1, this.listSlotHtmlComponent = y ?? null, this.disabled = x ?? !1, this.emptyText = V ?? "No results found...", this.staticList = !!(ae && !this.appendToBody), this.id = bt ?? "", this.ariaLabel = gt ?? "", this.isSingleSelect = oe ?? !1, this.showCount = Ys ?? !1, this.disabledBranchNode = Ks ?? !1, this.direction = Xs ?? "auto", this.expandSelected = Js ?? !1, this.saveScrollPosition = Zs ?? !0, this.isIndependentNodes = Qs ?? !1, this.rtl = ei ?? !1, this.listClassName = ti ?? "", this.iconElements = Bt(si), this.inputCallback = ii, this.openCallback = li, this.closeCallback = ni, this.nameChangeCallback = ai, this.searchCallback = oi, this.openCloseGroupCallback = ri, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, o(this, ee, St).call(this, t);
826
830
  }
827
831
  mount() {
828
832
  Dt({
@@ -834,11 +838,11 @@ class Gi {
834
838
  }), this.iconElements = Bt(this.iconElements), o(this, ee, St).call(this, this.value);
835
839
  }
836
840
  updateValue(e) {
837
- const t = Vi(e), s = n(this, u);
841
+ const t = Di(e), s = n(this, u);
838
842
  s && (s.updateValue(t), o(this, se, At).call(this, s == null ? void 0 : s.selectedNodes));
839
843
  }
840
844
  destroy() {
841
- this.srcElement && (o(this, ie, Tt).call(this), this.srcElement.innerHTML = "", this.srcElement = null, o(this, R, de).call(this, !0));
845
+ this.srcElement && (o(this, ie, Nt).call(this), this.srcElement.innerHTML = "", this.srcElement = null, o(this, $, de).call(this, !0));
842
846
  }
843
847
  focus() {
844
848
  n(this, p) && n(this, p).focus();
@@ -852,11 +856,11 @@ class Gi {
852
856
  }
853
857
  focusWindowHandler(e) {
854
858
  var s, i, a;
855
- ((s = this.srcElement) == null ? void 0 : s.contains(e.target)) || ((i = n(this, u)) == null ? void 0 : i.srcElement.contains(e.target)) || ((a = n(this, p)) == null || a.blur(), o(this, R, de).call(this, !1), o(this, j, he).call(this, !1));
859
+ ((s = this.srcElement) == null ? void 0 : s.contains(e.target)) || ((i = n(this, u)) == null ? void 0 : i.srcElement.contains(e.target)) || ((a = n(this, p)) == null || a.blur(), o(this, $, de).call(this, !1), o(this, R, he).call(this, !1));
856
860
  }
857
861
  blurWindowHandler() {
858
862
  var e;
859
- (e = n(this, p)) == null || e.blur(), o(this, R, de).call(this, !1), o(this, j, he).call(this, !1);
863
+ (e = n(this, p)) == null || e.blur(), o(this, $, de).call(this, !1), o(this, R, he).call(this, !1);
860
864
  }
861
865
  // Update direction of the list. Support appendToBody and standard mode with absolute
862
866
  updateListPosition() {
@@ -869,18 +873,18 @@ class Gi {
869
873
  y: a,
870
874
  height: h,
871
875
  width: d
872
- } = e.getBoundingClientRect(), C = window.innerHeight, f = a, b = C - a - h;
873
- let g = f > b && f >= s && b < s;
876
+ } = e.getBoundingClientRect(), b = window.innerHeight, f = a, C = b - a - h;
877
+ let g = f > C && f >= s && C < s;
874
878
  if (this.direction !== "auto" && (g = this.direction === "top"), this.appendToBody) {
875
879
  (t.style.top !== "0px" || t.style.left !== "0px") && (t.style.top = "0px", t.style.left = "0px");
876
- const x = i + window.scrollX, $ = g ? a + window.scrollY - s : a + window.scrollY + h;
877
- t.style.transform = `translate(${x}px,${$}px)`, t.style.width = `${d}px`;
880
+ const x = i + window.scrollX, V = g ? a + window.scrollY - s : a + window.scrollY + h;
881
+ t.style.transform = `translate(${x}px,${V}px)`, t.style.width = `${d}px`;
878
882
  }
879
883
  const k = g ? "top" : "bottom";
880
884
  t.getAttribute("direction") !== k && (t.setAttribute("direction", k), o(this, rt, qs).call(this, g, this.appendToBody));
881
885
  }
882
886
  }
883
- u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q = new WeakMap(), _ = new WeakMap(), A = new WeakMap(), L = new WeakMap(), B = new WeakMap(), ee = new WeakSet(), St = function(e) {
887
+ u = new WeakMap(), p = new WeakMap(), q = new WeakMap(), Q = new WeakMap(), j = new WeakMap(), _ = new WeakMap(), A = new WeakMap(), L = new WeakMap(), B = new WeakMap(), ee = new WeakSet(), St = function(e) {
884
888
  var a;
885
889
  this.destroy();
886
890
  const { container: t, list: s, input: i } = o(this, Ze, Os).call(this);
@@ -892,11 +896,11 @@ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q =
892
896
  }) {
893
897
  this.ungroupedValue = t ? re(t) : [], this.groupedValue = e ? re(e) : [], this.allValue = s ? re(s) : [];
894
898
  let i = [];
895
- this.isIndependentNodes || this.isSingleSelect ? i = this.allValue : this.isGroupedValue ? i = this.groupedValue : i = this.ungroupedValue, this.value = Di(i, this.isSingleSelect);
899
+ this.isIndependentNodes || this.isSingleSelect ? i = this.allValue : this.isGroupedValue ? i = this.groupedValue : i = this.ungroupedValue, this.value = Hi(i, this.isSingleSelect);
896
900
  }, Ze = new WeakSet(), Os = function() {
897
901
  const e = this.parentHtmlContainer;
898
902
  e.classList.add("treeselect"), this.rtl && e.setAttribute("dir", "rtl");
899
- const t = new Bi({
903
+ const t = new Vi({
900
904
  value: [],
901
905
  // updateValue method calls in initMount method to set actual value
902
906
  options: this.options,
@@ -909,6 +913,7 @@ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q =
909
913
  expandSelected: this.expandSelected,
910
914
  isIndependentNodes: this.isIndependentNodes,
911
915
  rtl: this.rtl,
916
+ listClassName: this.listClassName,
912
917
  iconElements: this.iconElements,
913
918
  inputCallback: (i) => o(this, lt, Hs).call(this, i),
914
919
  arrowClickCallback: (i, a) => o(this, nt, Gs).call(this, i, a),
@@ -916,7 +921,7 @@ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q =
916
921
  var i;
917
922
  return (i = n(this, p)) == null ? void 0 : i.focus();
918
923
  }
919
- }), s = new di({
924
+ }), s = new ui({
920
925
  value: [],
921
926
  // updateValue method calls in initMount method to set actual value
922
927
  showTags: this.showTags,
@@ -933,13 +938,13 @@ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q =
933
938
  inputCallback: (i) => o(this, Qe, Is).call(this, i),
934
939
  searchCallback: (i) => o(this, tt, Bs).call(this, i),
935
940
  openCallback: () => o(this, ot, Fs).call(this),
936
- closeCallback: () => o(this, ie, Tt).call(this),
941
+ closeCallback: () => o(this, ie, Nt).call(this),
937
942
  keydownCallback: (i) => o(this, et, Ps).call(this, i),
938
943
  focusCallback: () => o(this, st, Vs).call(this),
939
944
  blurCallback: () => o(this, it, Ds).call(this),
940
945
  nameChangeCallback: (i) => o(this, at, Ms).call(this, i)
941
946
  });
942
- return this.appendToBody && m(this, F, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
947
+ return this.appendToBody && m(this, q, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
943
948
  }, Qe = new WeakSet(), Is = function(e) {
944
949
  var i, a;
945
950
  const t = re(e);
@@ -950,12 +955,12 @@ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q =
950
955
  var t;
951
956
  this.isListOpened && ((t = n(this, u)) == null || t.callKeyAction(e));
952
957
  }, tt = new WeakSet(), Bs = function(e) {
953
- n(this, q) && clearTimeout(n(this, q)), m(this, q, window.setTimeout(() => {
958
+ n(this, j) && clearTimeout(n(this, j)), m(this, j, window.setTimeout(() => {
954
959
  var t;
955
960
  (t = n(this, u)) == null || t.updateSearchValue(e), this.updateListPosition();
956
961
  }, 350)), o(this, pt, Us).call(this, e);
957
962
  }, st = new WeakSet(), Vs = function() {
958
- o(this, j, he).call(this, !0), n(this, L) && n(this, L) && n(this, B) && (document.addEventListener("mousedown", n(this, L), !0), document.addEventListener("focus", n(this, L), !0), window.addEventListener("blur", n(this, B)));
963
+ o(this, R, he).call(this, !0), n(this, L) && n(this, L) && n(this, B) && (document.addEventListener("mousedown", n(this, L), !0), document.addEventListener("focus", n(this, L), !0), window.addEventListener("blur", n(this, B)));
959
964
  }, it = new WeakSet(), Ds = function() {
960
965
  setTimeout(() => {
961
966
  var s, i;
@@ -978,21 +983,21 @@ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q =
978
983
  this.selectedName !== e && (this.selectedName = e, o(this, ht, Rs).call(this));
979
984
  }, ot = new WeakSet(), Fs = function() {
980
985
  var e;
981
- this.isListOpened = !0, n(this, _) && n(this, A) && (window.addEventListener("scroll", n(this, _), !0), window.addEventListener("resize", n(this, A))), !(!n(this, u) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, u).srcElement), (e = n(this, F)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, u).srcElement), this.updateListPosition(), o(this, le, Nt).call(this, !0), o(this, ct, js).call(this), o(this, dt, $s).call(this));
982
- }, ie = new WeakSet(), Tt = function() {
986
+ this.isListOpened = !0, n(this, _) && n(this, A) && (window.addEventListener("scroll", n(this, _), !0), window.addEventListener("resize", n(this, A))), !(!n(this, u) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, u).srcElement), (e = n(this, q)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, u).srcElement), this.updateListPosition(), o(this, le, Tt).call(this, !0), o(this, ct, js).call(this), o(this, dt, $s).call(this));
987
+ }, ie = new WeakSet(), Nt = function() {
983
988
  var t;
984
- this.alwaysOpen || (this.isListOpened = !1, n(this, _) && n(this, A) && (window.removeEventListener("scroll", n(this, _), !0), window.removeEventListener("resize", n(this, A))), !n(this, u) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, u).srcElement) : this.srcElement.contains(n(this, u).srcElement)) || (m(this, Q, n(this, u).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, u).srcElement), (t = n(this, F)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, u).srcElement), o(this, le, Nt).call(this, !1), o(this, ut, Ws).call(this));
989
+ this.alwaysOpen || (this.isListOpened = !1, n(this, _) && n(this, A) && (window.removeEventListener("scroll", n(this, _), !0), window.removeEventListener("resize", n(this, A))), !n(this, u) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, u).srcElement) : this.srcElement.contains(n(this, u).srcElement)) || (m(this, Q, n(this, u).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, u).srcElement), (t = n(this, q)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, u).srcElement), o(this, le, Tt).call(this, !1), o(this, ut, Ws).call(this));
985
990
  }, rt = new WeakSet(), qs = function(e, t) {
986
991
  if (!n(this, u) || !n(this, p))
987
992
  return;
988
993
  const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", i = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
989
994
  e ? (n(this, u).srcElement.classList.add(s), n(this, u).srcElement.classList.remove(i), n(this, p).srcElement.classList.add("treeselect-input--top"), n(this, p).srcElement.classList.remove("treeselect-input--bottom")) : (n(this, u).srcElement.classList.remove(s), n(this, u).srcElement.classList.add(i), n(this, p).srcElement.classList.remove("treeselect-input--top"), n(this, p).srcElement.classList.add("treeselect-input--bottom"));
990
- }, j = new WeakSet(), he = function(e) {
995
+ }, R = new WeakSet(), he = function(e) {
991
996
  !n(this, p) || !n(this, u) || (e ? (n(this, p).srcElement.classList.add("treeselect-input--focused"), n(this, u).srcElement.classList.add("treeselect-list--focused")) : (n(this, p).srcElement.classList.remove("treeselect-input--focused"), n(this, u).srcElement.classList.remove("treeselect-list--focused")));
992
- }, le = new WeakSet(), Nt = function(e) {
997
+ }, le = new WeakSet(), Tt = function(e) {
993
998
  var t, s, i, a;
994
999
  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 ? (i = n(this, u)) == null || i.srcElement.classList.add("treeselect-list--static") : (a = n(this, u)) == null || a.srcElement.classList.remove("treeselect-list--static");
995
- }, R = new WeakSet(), de = function(e) {
1000
+ }, $ = new WeakSet(), de = function(e) {
996
1001
  !n(this, _) || !n(this, A) || !n(this, L) || !n(this, B) || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", n(this, _), !0), window.removeEventListener("resize", n(this, A))), document.removeEventListener("mousedown", n(this, L), !0), document.removeEventListener("focus", n(this, L), !0), window.removeEventListener("blur", n(this, B)));
997
1002
  }, ct = new WeakSet(), js = function() {
998
1003
  var t, s, i;
@@ -1019,5 +1024,5 @@ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q =
1019
1024
  (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("open-close-group", { detail: { groupId: e, isClosed: t } })), this.openCloseGroupCallback && this.openCloseGroupCallback(e, t);
1020
1025
  };
1021
1026
  export {
1022
- Gi as default
1027
+ Mi as default
1023
1028
  };
@@ -1 +1 @@
1
- (function(b,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(b=typeof globalThis<"u"?globalThis:b||self,b.Treeselect=p())})(this,function(){var P,y,H,x,pe,Ut,G,oe,me,zt,fe,Yt,M,re,B,j,be,Kt,Ce,Xt,ge,Jt,ke,Zt,we,Qt,Ee,es,ve,ts,Le,ss,ye,is,xe,ls,Se,ns,_e,as,Ae,os,Te,rs,Ne,cs,Oe,hs,z,xt,F,V,_,Y,Ie,ds,Pe,us,Be,ps,Ve,ms,De,fs,He,bs,K,St,Ge,Cs,Me,gs,Fe,ks,X,_t,je,ws,qe,Es,Re,vs,$e,Ls,We,ys,Ue,xs,ze,Ss,Ye,_s,Ke,As,Xe,Ts,Je,Ns,J,At,Z,Tt,Ze,Os,u,m,q,Q,R,A,T,S,D,ee,Nt,te,Ot,Qe,Is,et,Ps,tt,Bs,st,Vs,it,Ds,lt,Hs,se,It,nt,Gs,at,Ms,ot,Fs,rt,js,ie,Pt,ct,qs,$,gt,le,Bt,W,kt,ht,Rs,ne,Vt,dt,$s,ut,Ws,pt,Us,mt,zs,ft,Ys;"use strict";var Hi=Object.defineProperty;var Gi=(b,p,f)=>p in b?Hi(b,p,{enumerable:!0,configurable:!0,writable:!0,value:f}):b[p]=f;var c=(b,p,f)=>(Gi(b,typeof p!="symbol"?p+"":p,f),f),yt=(b,p,f)=>{if(!p.has(b))throw TypeError("Cannot "+f)};var n=(b,p,f)=>(yt(b,p,"read from private field"),f?f.call(b):p.get(b)),r=(b,p,f)=>{if(p.has(b))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(b):p.set(b,f)},C=(b,p,f,U)=>(yt(b,p,"write to private field"),U?U.call(b,f):p.set(b,f),f);var o=(b,p,f)=>(yt(b,p,"access private method"),f);const b="",p={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>'},f=(l,e)=>{if(e.innerHTML="",typeof l=="string")e.innerHTML=l;else{const t=l.cloneNode(!0);e.appendChild(t)}},U=l=>{const e=l?{...l}:{};return Object.keys(p).forEach(t=>{e[t]||(e[t]=p[t])}),e},Ks=l=>l.reduce((e,{name:t},s)=>(e+=t,s<l.length-1&&(e+=", "),e),"");class Xs{constructor({value:e,showTags:t,tagsCountText:s,clearable:i,isAlwaysOpened:a,searchable:h,placeholder:d,disabled:w,isSingleSelect:g,id:k,ariaLabel:E,iconElements:v,inputCallback:L,searchCallback:N,openCallback:O,closeCallback:ae,keydownCallback:bt,focusCallback:vt,blurCallback:Lt,nameChangeCallback:Ct}){r(this,pe);r(this,G);r(this,me);r(this,fe);r(this,M);r(this,B);r(this,be);r(this,Ce);r(this,ge);r(this,ke);r(this,we);r(this,Ee);r(this,ve);r(this,Le);r(this,ye);r(this,xe);r(this,Se);r(this,_e);r(this,Ae);r(this,Te);r(this,Ne);r(this,Oe);r(this,z);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");c(this,"isOpened");c(this,"searchText");c(this,"srcElement");r(this,P,void 0);r(this,y,void 0);r(this,H,void 0);r(this,x,void 0);c(this,"inputCallback");c(this,"searchCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"keydownCallback");c(this,"focusCallback");c(this,"blurCallback");c(this,"nameChangeCallback");this.value=e,this.showTags=t,this.tagsCountText=s,this.searchable=h,this.placeholder=d,this.clearable=i,this.isAlwaysOpened=a,this.disabled=w,this.isSingleSelect=g,this.id=k,this.ariaLabel=E,this.iconElements=v,this.isOpened=!1,this.searchText="",C(this,P,o(this,ge,Jt).call(this)),C(this,y,o(this,ye,is).call(this)),C(this,H,o(this,_e,as).call(this)),C(this,x,null),this.inputCallback=L,this.searchCallback=N,this.openCallback=O,this.closeCallback=ae,this.keydownCallback=bt,this.focusCallback=vt,this.blurCallback=Lt,this.nameChangeCallback=Ct,this.srcElement=o(this,be,Kt).call(this,n(this,P),n(this,y),n(this,H)),o(this,pe,Ut).call(this)}focus(){setTimeout(()=>n(this,y).focus(),0)}blur(){this.isOpened&&o(this,B,j).call(this),this.clearSearch(),n(this,y).blur()}updateValue(e){this.value=e,o(this,G,oe).call(this),o(this,M,re).call(this)}removeItem(e){this.value=this.value.filter(t=>t.id!==e),o(this,z,xt).call(this),o(this,G,oe).call(this),o(this,M,re).call(this)}clear(){this.value=[],o(this,z,xt).call(this),o(this,G,oe).call(this),this.clearSearch()}openClose(){o(this,B,j).call(this)}clearSearch(){this.searchText="",this.searchCallback(""),o(this,M,re).call(this)}}P=new WeakMap,y=new WeakMap,H=new WeakMap,x=new WeakMap,pe=new WeakSet,Ut=function(){o(this,G,oe).call(this),o(this,M,re).call(this),o(this,me,zt).call(this)},G=new WeakSet,oe=function(){if(n(this,P).innerHTML="",this.showTags){n(this,P).append(...o(this,ke,Zt).call(this));const e=Ks(this.value);this.nameChangeCallback(e)}else{const e=o(this,Le,ss).call(this);n(this,P).appendChild(e),this.nameChangeCallback(e.innerText)}n(this,P).appendChild(n(this,y))},me=new WeakSet,zt=function(){const e=[];n(this,H).innerHTML="",this.clearable&&e.push(o(this,Ae,os).call(this)),this.isAlwaysOpened||e.push(o(this,Ne,cs).call(this,this.isOpened)),e.length&&n(this,H).append(...e)},fe=new WeakSet,Yt=function(){if(!this.isAlwaysOpened&&n(this,x)){const e=this.isOpened?this.iconElements.arrowUp:this.iconElements.arrowDown;f(e,n(this,x))}},M=new WeakSet,re=function(){var e;(e=this.value)!=null&&e.length?(n(this,y).removeAttribute("placeholder"),this.srcElement.classList.remove("treeselect-input--value-not-selected")):(n(this,y).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,y).value=this.searchText},B=new WeakSet,j=function(){this.isOpened=!this.isOpened,o(this,fe,Yt).call(this),this.isOpened?this.openCallback():this.closeCallback()},be=new WeakSet,Kt=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,Ce,Xt).call(this,a)),i.addEventListener("focus",()=>this.focusCallback(),!0),i.addEventListener("blur",()=>this.blurCallback(),!0),e.appendChild(t),i.append(e,s),i},Ce=new WeakSet,Xt=function(e){e.stopPropagation(),this.isOpened||o(this,B,j).call(this),this.focus()},ge=new WeakSet,Jt=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__tags"),e},ke=new WeakSet,Zt=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,Ee,es).call(this,e.name),i=o(this,ve,ts).call(this);return t.addEventListener("mousedown",a=>o(this,we,Qt).call(this,a,e.id)),t.append(s,i),t})},we=new WeakSet,Qt=function(e,t){e.preventDefault(),e.stopPropagation(),this.removeItem(t),this.focus()},Ee=new WeakSet,es=function(e){const t=document.createElement("span");return t.classList.add("treeselect-input__tags-name"),t.textContent=e,t},ve=new WeakSet,ts=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__tags-cross"),f(this.iconElements.cross,e),e},Le=new WeakSet,ss=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},ye=new WeakSet,is=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,xe,ls).call(this,t)),e.addEventListener("input",t=>o(this,Se,ns).call(this,t,e)),e},xe=new WeakSet,ls=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,B,j).call(this),(t==="Enter"||t==="ArrowDown"||t==="ArrowUp")&&e.preventDefault(),this.keydownCallback(e),t!=="Tab"&&this.focus()},Se=new WeakSet,ns=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,B,j).call(this)}else t.value="";this.searchText=t.value},_e=new WeakSet,as=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__operators"),e},Ae=new WeakSet,os=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__clear"),e.setAttribute("tabindex","-1"),f(this.iconElements.clear,e),e.addEventListener("mousedown",t=>o(this,Te,rs).call(this,t)),e},Te=new WeakSet,rs=function(e){e.preventDefault(),e.stopPropagation(),(this.searchText.length||this.value.length)&&this.clear(),this.focus()},Ne=new WeakSet,cs=function(e){C(this,x,document.createElement("span")),n(this,x).classList.add("treeselect-input__arrow");const t=e?this.iconElements.arrowUp:this.iconElements.arrowDown;return f(t,n(this,x)),n(this,x).addEventListener("mousedown",s=>o(this,Oe,hs).call(this,s)),n(this,x)},Oe=new WeakSet,hs=function(e){e.stopPropagation(),e.preventDefault(),this.focus(),o(this,B,j).call(this)},z=new WeakSet,xt=function(){this.inputCallback(this.value)};const Dt=(l,e,t,s)=>{ei(e);const i=e.filter(a=>!a.disabled&&l.some(h=>h===a.id));if(t&&i.length){i[0].checked=!0;return}i.forEach(a=>{a.checked=!0;const h=wt(a,e,s);a.checked=h})},wt=({id:l,checked:e},t,s)=>{const i=t.find(h=>h.id===l);if(!i)return!1;if(s)return i.checked=i.disabled?!1:!!e,i.checked;const a=Ht(!!e,i,t);return Gt(i,t),a},Ht=(l,e,t)=>{if(!e.isGroup)return e.checked=e.disabled?!1:!!l,e.isPartialChecked=!1,e.checked;const s=t.filter(d=>d.childOf===e.id);return!l||e.disabled||e.isPartialChecked?(e.checked=!1,e.isPartialChecked=!1,Et(e,s,t),e.checked):Mt(s,t)?Ft(s)?(e.checked=!1,e.isPartialChecked=!1,e.disabled=!0,e.checked):(e.checked=!1,e.isPartialChecked=!0,s.forEach(d=>{Ht(l,d,t)}),e.checked):(e.checked=!0,e.isPartialChecked=!1,Et(e,s,t),e.checked)},Gt=(l,e)=>{const t=e.find(s=>s.id===l.childOf);t&&(Js(t,e),Gt(t,e))},Js=(l,e)=>{const t=ce(l,e);if(Ft(t)){l.checked=!1,l.isPartialChecked=!1,l.disabled=!0;return}if(Zs(t)){l.checked=!0,l.isPartialChecked=!1;return}if(Qs(t)){l.checked=!1,l.isPartialChecked=!0;return}l.checked=!1,l.isPartialChecked=!1},Et=({checked:l,disabled:e},t,s)=>{t.forEach(i=>{i.disabled=!!e||!!i.disabled,i.checked=!!l&&!i.disabled,i.isPartialChecked=!1;const a=ce(i,s);Et({checked:l,disabled:e},a,s)})},Mt=(l,e)=>l.some(i=>i.disabled)?!0:l.some(i=>{if(i.isGroup){const a=ce(i,e);return Mt(a,e)}return!1}),Ft=l=>l.every(e=>!!e.disabled),Zs=l=>l.every(e=>!!e.checked),Qs=l=>l.some(e=>!!e.checked||!!e.isPartialChecked),ei=l=>{l.forEach(e=>{e.checked=!1,e.isPartialChecked=!1})},ti=(l,e,t)=>{const s={level:0,groupId:""},i=jt(l,e,s.groupId,s.level);return ii(i,t)},jt=(l,e,t,s)=>l.reduce((i,a)=>{var g;const h=!!((g=a.children)!=null&&g.length),d=s>=e&&h,w=s>e;if(i.push({id:a.value,name:a.name,childOf:t,isGroup:h,checked:!1,isPartialChecked:!1,level:s,isClosed:d,hidden:w,disabled:a.disabled??!1}),h){const k=jt(a.children,e,a.value,s+1);i.push(...k)}return i},[]),ce=({id:l},e)=>e.filter(t=>t.childOf===l),si=l=>{const{ungroupedNodes:e,allGroupedNodes:t,allNodes:s}=l.reduce((a,h)=>(h.checked&&(a.allNodes.push(h),h.isGroup?a.allGroupedNodes.push(h):a.ungroupedNodes.push(h)),a),{ungroupedNodes:[],allGroupedNodes:[],allNodes:[]}),i=s.filter(a=>!t.some(({id:h})=>h===a.childOf));return{ungroupedNodes:e,groupedNodes:i,allNodes:s}},ii=(l,e)=>(l.filter(s=>!!s.disabled).forEach(({id:s})=>wt({id:s,checked:!1},l,e)),l),he=(l,{id:e,isClosed:t})=>{ce({id:e},l).forEach(i=>{i.hidden=t??!1,i.isGroup&&!i.isClosed&&he(l,{id:i.id,isClosed:t})})},li=l=>{l.filter(e=>e.isGroup&&!e.disabled&&(e.checked||e.isPartialChecked)).forEach(e=>{e.isClosed=!1,he(l,e)})},ni=(l,e)=>{const t=ai(l,e);l.forEach(s=>{t.some(({id:a})=>a===s.id)?(s.isGroup&&(s.isClosed=!1,he(l,s)),s.hidden=!1):s.hidden=!0})},ai=(l,e)=>l.reduce((t,s)=>{if(s.name.toLowerCase().includes(e.toLowerCase())){if(t.push(s),s.isGroup){const a=qt(s.id,l);t.push(...a)}if(s.childOf){const a=Rt(s.childOf,l);t.push(...a)}}return t},[]),qt=(l,e)=>e.reduce((t,s)=>(s.childOf===l&&(t.push(s),s.isGroup&&t.push(...qt(s.id,e))),t),[]),Rt=(l,e)=>e.reduce((t,s)=>(s.id===l&&(t.push(s),s.childOf&&t.push(...Rt(s.childOf,e))),t),[]),oi=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.`)},ri=(l,e,t,s,i,a,h,d,w,g)=>{Dt(l,e,i,w),d&&h&&li(e),de(e,t,s,a,g)},de=(l,e,t,s,i)=>{l.forEach(a=>{const h=e.querySelector(`[input-id="${a.id}"]`),d=I(h);h.checked=a.checked,ci(a,d,s),hi(a,d),di(a,d),ui(a,d,t),pi(a,d),fi(a,d,l,i),mi(a,h,t)}),bi(l,e)},ci=(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")},hi=(l,e)=>{l.isPartialChecked?e.classList.add("treeselect-list__item--partial-checked"):e.classList.remove("treeselect-list__item--partial-checked")},di=(l,e)=>{l.disabled?e.classList.add("treeselect-list__item--disabled"):e.classList.remove("treeselect-list__item--disabled")},ui=(l,e,t)=>{if(l.isGroup){const s=e.querySelector(".treeselect-list__item-icon"),i=l.isClosed?t.arrowRight:t.arrowDown;f(i,s),l.isClosed?e.classList.add("treeselect-list__item--closed"):e.classList.remove("treeselect-list__item--closed")}},pi=(l,e)=>{l.hidden?e.classList.add("treeselect-list__item--hidden"):e.classList.remove("treeselect-list__item--hidden")},mi=(l,e,t)=>{const i=e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");l.checked?f(t.check,i):l.isPartialChecked?f(t.partialCheck,i):i.innerHTML=""},fi=(l,e,t,s)=>{const i=l.level===0,a=20,h=5;if(i){const d=t.some(k=>k.isGroup&&k.level===l.level),w=!l.isGroup&&d?`${a}px`:`${h}px`,g=l.isGroup?"0":w;s?e.style.paddingRight=g:e.style.paddingLeft=g}else{const d=l.isGroup?`${l.level*a}px`:`${l.level*a+a}px`;s?e.style.paddingRight=d:e.style.paddingLeft=d}e.setAttribute("level",l.level.toString()),e.setAttribute("group",l.isGroup.toString())},bi=(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")},I=l=>l.parentNode.parentNode,$t=(l,e)=>e.find(t=>t.id.toString()===l),Ci=l=>I(l).querySelector(".treeselect-list__item-icon"),gi=(l,e)=>{e&&Object.keys(e).forEach(t=>{const s=e[t];typeof s=="string"&&l.setAttribute(t,s)})};class ki{constructor({options:e,value:t,openLevel:s,listSlotHtmlComponent:i,emptyText:a,isSingleSelect:h,iconElements:d,showCount:w,disabledBranchNode:g,expandSelected:k,isIndependentNodes:E,rtl:v,inputCallback:L,arrowClickCallback:N,mouseupCallback:O}){r(this,Ie);r(this,Pe);r(this,Be);r(this,Ve);r(this,De);r(this,He);r(this,K);r(this,Ge);r(this,Me);r(this,Fe);r(this,X);r(this,je);r(this,qe);r(this,Re);r(this,$e);r(this,We);r(this,Ue);r(this,ze);r(this,Ye);r(this,Ke);r(this,Xe);r(this,Je);r(this,J);r(this,Z);r(this,Ze);c(this,"options");c(this,"value");c(this,"openLevel");c(this,"listSlotHtmlComponent");c(this,"emptyText");c(this,"isSingleSelect");c(this,"showCount");c(this,"disabledBranchNode");c(this,"expandSelected");c(this,"isIndependentNodes");c(this,"rtl");c(this,"iconElements");c(this,"searchText");c(this,"flattedOptions");c(this,"flattedOptionsBeforeSearch");c(this,"selectedNodes");c(this,"srcElement");c(this,"inputCallback");c(this,"arrowClickCallback");c(this,"mouseupCallback");r(this,F,null);r(this,V,!0);r(this,_,[]);r(this,Y,!0);this.options=e,this.value=t,this.openLevel=s??0,this.listSlotHtmlComponent=i??null,this.emptyText=a??"No results found...",this.isSingleSelect=h??!1,this.showCount=w??!1,this.disabledBranchNode=g??!1,this.expandSelected=k??!1,this.isIndependentNodes=E??!1,this.rtl=v??!1,this.iconElements=d,this.searchText="",this.flattedOptions=ti(this.options,this.openLevel,this.isIndependentNodes),this.flattedOptionsBeforeSearch=this.flattedOptions,this.selectedNodes={nodes:[],groupedNodes:[],allNodes:[]},this.srcElement=o(this,Be,ps).call(this),this.inputCallback=L,this.arrowClickCallback=N,this.mouseupCallback=O,oi(this.flattedOptions)}updateValue(e){this.value=e,C(this,_,this.isSingleSelect?this.value:[]),ri(e,this.flattedOptions,this.srcElement,this.iconElements,this.isSingleSelect,n(this,_),this.expandSelected,n(this,Y),this.isIndependentNodes,this.rtl),C(this,Y,!1),o(this,Z,Tt).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&&ni(this.flattedOptions,e),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),this.focusFirstListElement()}callKeyAction(e){C(this,V,!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,Ie,ds).call(this,t,e),(i==="ArrowDown"||i==="ArrowUp")&&o(this,Pe,us).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(I(a)).display!=="none");if(!s.length)return;t&&t.classList.remove(e),I(s[0]).classList.add(e)}isLastFocusedElementExist(){return!!n(this,F)}}F=new WeakMap,V=new WeakMap,_=new WeakMap,Y=new WeakMap,Ie=new WeakSet,ds=function(e,t){if(!e)return;const s=t.key,a=e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"),h=$t(a,this.flattedOptions),d=e.querySelector(".treeselect-list__item-icon");s==="ArrowLeft"&&!h.isClosed&&h.isGroup&&(d.dispatchEvent(new Event("mousedown")),t.preventDefault()),s==="ArrowRight"&&h.isClosed&&h.isGroup&&(d.dispatchEvent(new Event("mousedown")),t.preventDefault())},Pe=new WeakSet,us=function(e,t){var i;const s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(I(a)).display!=="none");if(s.length)if(!e)I(s[0]).classList.add("treeselect-list__item--focused");else{const a=s.findIndex(O=>I(O).classList.contains("treeselect-list__item--focused"));I(s[a]).classList.remove("treeselect-list__item--focused");const d=t==="ArrowDown"?a+1:a-1,w=t==="ArrowDown"?0:s.length-1,g=s[d]??s[w],k=!s[d],E=I(g);E.classList.add("treeselect-list__item--focused");const v=this.srcElement.getBoundingClientRect(),L=E.getBoundingClientRect();if(k&&t==="ArrowDown"){this.srcElement.scroll(0,0);return}if(k&&t==="ArrowUp"){this.srcElement.scroll(0,this.srcElement.scrollHeight);return}const N=((i=this.listSlotHtmlComponent)==null?void 0:i.clientHeight)??0;if(v.y+v.height<L.y+L.height+N){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}}},Be=new WeakSet,ps=function(){const e=o(this,Ve,ms).call(this),t=o(this,K,St).call(this,this.options);e.append(...t);const s=o(this,Me,gs).call(this);e.append(s);const i=o(this,Ge,Cs).call(this);return i&&e.append(i),e},Ve=new WeakSet,ms=function(){const e=document.createElement("div");return e.classList.add("treeselect-list"),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,De,fs).call(this,t)),e.addEventListener("mousemove",()=>o(this,He,bs).call(this)),e.addEventListener("mouseup",()=>this.mouseupCallback(),!0),e},De=new WeakSet,fs=function(e){e.stopPropagation(),n(this,F)&&n(this,V)&&n(this,F).classList.add("treeselect-list__item--focused")},He=new WeakSet,bs=function(){C(this,V,!0)},K=new WeakSet,St=function(e){return e.reduce((t,s)=>{var a;if((a=s.children)!=null&&a.length){const h=o(this,Fe,ks).call(this,s),d=o(this,K,St).call(this,s.children);return h.append(...d),t.push(h),t}const i=o(this,X,_t).call(this,s,!1);return t.push(i),t},[])},Ge=new WeakSet,Cs=function(){if(!this.listSlotHtmlComponent)return null;const e=document.createElement("div");return e.classList.add("treeselect-list__slot"),e.appendChild(this.listSlotHtmlComponent),e},Me=new WeakSet,gs=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"),f(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},Fe=new WeakSet,ks=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,X,_t).call(this,e,!0);return t.appendChild(s),t},X=new WeakSet,_t=function(e,t){const s=o(this,je,ws).call(this,e);if(t){const h=o(this,We,ys).call(this);s.appendChild(h),s.classList.add("treeselect-list__item--group")}const i=o(this,ze,Ss).call(this,e),a=o(this,Ye,_s).call(this,e,t);return s.append(i,a),s},je=new WeakSet,ws=function(e){const t=document.createElement("div");return gi(t,e.htmlAttr),t.setAttribute("tabindex","-1"),t.setAttribute("title",e.name),t.classList.add("treeselect-list__item"),t.addEventListener("mouseover",()=>o(this,qe,Es).call(this,t),!0),t.addEventListener("mouseout",()=>o(this,Re,vs).call(this,t),!0),t.addEventListener("mousedown",s=>o(this,$e,Ls).call(this,s,e)),t},qe=new WeakSet,Es=function(e){n(this,V)&&o(this,J,At).call(this,!0,e)},Re=new WeakSet,vs=function(e){n(this,V)&&(o(this,J,At).call(this,!1,e),C(this,F,e))},$e=new WeakSet,Ls=function(e,t){var a;if(e.preventDefault(),e.stopPropagation(),(a=this.flattedOptions.find(h=>h.id===t.value))==null?void 0:a.disabled)return;const i=e.target.querySelector(".treeselect-list__item-checkbox");i.checked=!i.checked,o(this,Xe,Ts).call(this,i,t)},We=new WeakSet,ys=function(){const e=document.createElement("span");return e.setAttribute("tabindex","-1"),e.classList.add("treeselect-list__item-icon"),f(this.iconElements.arrowDown,e),e.addEventListener("mousedown",t=>o(this,Ue,xs).call(this,t)),e},Ue=new WeakSet,xs=function(e){e.preventDefault(),e.stopPropagation(),o(this,Je,Ns).call(this,e)},ze=new WeakSet,Ss=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},Ye=new WeakSet,_s=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,Ke,As).call(this,e);s.appendChild(i)}return s},Ke=new WeakSet,As=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},Xe=new WeakSet,Ts=function(e,t){const s=this.flattedOptions.find(i=>i.id===t.value);if(s){if(s!=null&&s.isGroup&&this.disabledBranchNode){const i=Ci(e);i==null||i.dispatchEvent(new Event("mousedown"));return}if(this.isSingleSelect){const[i]=n(this,_);if(s.id===i)return;C(this,_,[s.id]),Dt([s.id],this.flattedOptions,this.isSingleSelect,this.isIndependentNodes)}else{s.checked=e.checked;const i=wt(s,this.flattedOptions,this.isIndependentNodes);e.checked=i}de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),o(this,Ze,Os).call(this)}},Je=new WeakSet,Ns=function(e){var a,h;const t=(h=(a=e.target)==null?void 0:a.parentNode)==null?void 0:h.querySelector("[input-id]"),s=(t==null?void 0:t.getAttribute("input-id"))??null,i=$t(s,this.flattedOptions);i&&(i.isClosed=!i.isClosed,he(this.flattedOptions,i),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),this.arrowClickCallback(i.id,i.isClosed))},J=new WeakSet,At=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)},Z=new WeakSet,Tt=function(){const{ungroupedNodes:e,groupedNodes:t,allNodes:s}=si(this.flattedOptions);this.selectedNodes={nodes:e,groupedNodes:t,allNodes:s}},Ze=new WeakSet,Os=function(){o(this,Z,Tt).call(this),this.inputCallback(this.selectedNodes),this.value=this.selectedNodes.nodes.map(e=>e.id)};const Wt=({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!")},ue=l=>l.map(e=>e.id),wi=l=>l?Array.isArray(l)?l:[l]:[],Ei=(l,e)=>{if(e){const[t]=l;return t??null}return l};class vi{constructor({parentHtmlContainer:e,value:t,options:s,openLevel:i,appendToBody:a,alwaysOpen:h,showTags:d,tagsCountText:w,clearable:g,searchable:k,placeholder:E,grouped:v,isGroupedValue:L,listSlotHtmlComponent:N,disabled:O,emptyText:ae,staticList:bt,id:vt,ariaLabel:Lt,isSingleSelect:Ct,showCount:Li,disabledBranchNode:yi,direction:xi,expandSelected:Si,saveScrollPosition:_i,isIndependentNodes:Ai,rtl:Ti,iconElements:Ni,inputCallback:Oi,openCallback:Ii,closeCallback:Pi,nameChangeCallback:Bi,searchCallback:Vi,openCloseGroupCallback:Di}){r(this,ee);r(this,te);r(this,Qe);r(this,et);r(this,tt);r(this,st);r(this,it);r(this,lt);r(this,se);r(this,nt);r(this,at);r(this,ot);r(this,rt);r(this,ie);r(this,ct);r(this,$);r(this,le);r(this,W);r(this,ht);r(this,ne);r(this,dt);r(this,ut);r(this,pt);r(this,mt);r(this,ft);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,"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,"iconElements");c(this,"inputCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"nameChangeCallback");c(this,"searchCallback");c(this,"openCloseGroupCallback");c(this,"ungroupedValue");c(this,"groupedValue");c(this,"allValue");c(this,"isListOpened");c(this,"selectedName");c(this,"srcElement");r(this,u,null);r(this,m,null);r(this,q,null);r(this,Q,0);r(this,R,0);r(this,A,null);r(this,T,null);r(this,S,null);r(this,D,null);Wt({parentHtmlContainer:e,value:t,staticList:bt,appendToBody:a,isSingleSelect:Ct}),this.parentHtmlContainer=e,this.value=[],this.options=s??[],this.openLevel=i??0,this.appendToBody=a??!1,this.alwaysOpen=!!(h&&!O),this.showTags=d??!0,this.tagsCountText=w??"elements selected",this.clearable=g??!0,this.searchable=k??!0,this.placeholder=E??"Search...",this.grouped=v??!0,this.isGroupedValue=L??!1,this.listSlotHtmlComponent=N??null,this.disabled=O??!1,this.emptyText=ae??"No results found...",this.staticList=!!(bt&&!this.appendToBody),this.id=vt??"",this.ariaLabel=Lt??"",this.isSingleSelect=Ct??!1,this.showCount=Li??!1,this.disabledBranchNode=yi??!1,this.direction=xi??"auto",this.expandSelected=Si??!1,this.saveScrollPosition=_i??!0,this.isIndependentNodes=Ai??!1,this.rtl=Ti??!1,this.iconElements=U(Ni),this.inputCallback=Oi,this.openCallback=Ii,this.closeCallback=Pi,this.nameChangeCallback=Bi,this.searchCallback=Vi,this.openCloseGroupCallback=Di,this.ungroupedValue=[],this.groupedValue=[],this.allValue=[],this.isListOpened=!1,this.selectedName="",this.srcElement=null,o(this,ee,Nt).call(this,t)}mount(){Wt({parentHtmlContainer:this.parentHtmlContainer,value:this.value,staticList:this.staticList,appendToBody:this.appendToBody,isSingleSelect:this.isSingleSelect}),this.iconElements=U(this.iconElements),o(this,ee,Nt).call(this,this.value)}updateValue(e){const t=wi(e),s=n(this,u);s&&(s.updateValue(t),o(this,se,It).call(this,s==null?void 0:s.selectedNodes))}destroy(){this.srcElement&&(o(this,ie,Pt).call(this),this.srcElement.innerHTML="",this.srcElement=null,o(this,W,kt).call(this,!0))}focus(){n(this,m)&&n(this,m).focus()}toggleOpenClose(){n(this,m)&&(n(this,m).openClose(),n(this,m).focus())}scrollWindowHandler(){this.updateListPosition()}focusWindowHandler(e){var s,i,a;((s=this.srcElement)==null?void 0:s.contains(e.target))||((i=n(this,u))==null?void 0:i.srcElement.contains(e.target))||((a=n(this,m))==null||a.blur(),o(this,W,kt).call(this,!1),o(this,$,gt).call(this,!1))}blurWindowHandler(){var e;(e=n(this,m))==null||e.blur(),o(this,W,kt).call(this,!1),o(this,$,gt).call(this,!1)}updateListPosition(){var N;const e=this.srcElement,t=(N=n(this,u))==null?void 0:N.srcElement;if(!e||!t)return;const{height:s}=t.getBoundingClientRect(),{x:i,y:a,height:h,width:d}=e.getBoundingClientRect(),w=window.innerHeight,g=a,k=w-a-h;let E=g>k&&g>=s&&k<s;if(this.direction!=="auto"&&(E=this.direction==="top"),this.appendToBody){(t.style.top!=="0px"||t.style.left!=="0px")&&(t.style.top="0px",t.style.left="0px");const O=i+window.scrollX,ae=E?a+window.scrollY-s:a+window.scrollY+h;t.style.transform=`translate(${O}px,${ae}px)`,t.style.width=`${d}px`}const v=E?"top":"bottom";t.getAttribute("direction")!==v&&(t.setAttribute("direction",v),o(this,ct,qs).call(this,E,this.appendToBody))}}return u=new WeakMap,m=new WeakMap,q=new WeakMap,Q=new WeakMap,R=new WeakMap,A=new WeakMap,T=new WeakMap,S=new WeakMap,D=new WeakMap,ee=new WeakSet,Nt=function(e){var a;this.destroy();const{container:t,list:s,input:i}=o(this,Qe,Is).call(this);this.srcElement=t,C(this,u,s),C(this,m,i),C(this,A,this.scrollWindowHandler.bind(this)),C(this,T,this.scrollWindowHandler.bind(this)),C(this,S,this.focusWindowHandler.bind(this)),C(this,D,this.blurWindowHandler.bind(this)),this.alwaysOpen&&((a=n(this,m))==null||a.openClose()),this.disabled?this.srcElement.classList.add("treeselect--disabled"):this.srcElement.classList.remove("treeselect--disabled"),this.updateValue(e??this.value)},te=new WeakSet,Ot=function({groupedNodes:e,nodes:t,allNodes:s}){this.ungroupedValue=t?ue(t):[],this.groupedValue=e?ue(e):[],this.allValue=s?ue(s):[];let i=[];this.isIndependentNodes||this.isSingleSelect?i=this.allValue:this.isGroupedValue?i=this.groupedValue:i=this.ungroupedValue,this.value=Ei(i,this.isSingleSelect)},Qe=new WeakSet,Is=function(){const e=this.parentHtmlContainer;e.classList.add("treeselect"),this.rtl&&e.setAttribute("dir","rtl");const t=new ki({value:[],options:this.options,openLevel:this.openLevel,listSlotHtmlComponent:this.listSlotHtmlComponent,emptyText:this.emptyText,isSingleSelect:this.isSingleSelect,showCount:this.showCount,disabledBranchNode:this.disabledBranchNode,expandSelected:this.expandSelected,isIndependentNodes:this.isIndependentNodes,rtl:this.rtl,iconElements:this.iconElements,inputCallback:i=>o(this,nt,Gs).call(this,i),arrowClickCallback:(i,a)=>o(this,at,Ms).call(this,i,a),mouseupCallback:()=>{var i;return(i=n(this,m))==null?void 0:i.focus()}}),s=new Xs({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,et,Ps).call(this,i),searchCallback:i=>o(this,st,Vs).call(this,i),openCallback:()=>o(this,rt,js).call(this),closeCallback:()=>o(this,ie,Pt).call(this),keydownCallback:i=>o(this,tt,Bs).call(this,i),focusCallback:()=>o(this,it,Ds).call(this),blurCallback:()=>o(this,lt,Hs).call(this),nameChangeCallback:i=>o(this,ot,Fs).call(this,i)});return this.appendToBody&&C(this,q,new ResizeObserver(()=>this.updateListPosition())),e.append(s.srcElement),{container:e,list:t,input:s}},et=new WeakSet,Ps=function(e){var i,a;const t=ue(e);(i=n(this,u))==null||i.updateValue(t);const s=((a=n(this,u))==null?void 0:a.selectedNodes)??{};o(this,te,Ot).call(this,s),o(this,ne,Vt).call(this)},tt=new WeakSet,Bs=function(e){var t;this.isListOpened&&((t=n(this,u))==null||t.callKeyAction(e))},st=new WeakSet,Vs=function(e){n(this,R)&&clearTimeout(n(this,R)),C(this,R,window.setTimeout(()=>{var t;(t=n(this,u))==null||t.updateSearchValue(e),this.updateListPosition()},350)),o(this,mt,zs).call(this,e)},it=new WeakSet,Ds=function(){o(this,$,gt).call(this,!0),n(this,S)&&n(this,S)&&n(this,D)&&(document.addEventListener("mousedown",n(this,S),!0),document.addEventListener("focus",n(this,S),!0),window.addEventListener("blur",n(this,D)))},lt=new WeakSet,Hs=function(){setTimeout(()=>{var s,i;const e=(s=n(this,m))==null?void 0:s.srcElement.contains(document.activeElement),t=(i=n(this,u))==null?void 0:i.srcElement.contains(document.activeElement);!e&&!t&&this.blurWindowHandler()},1)},se=new WeakSet,It=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,m))==null||s.updateValue(t),o(this,te,Ot).call(this,e)},nt=new WeakSet,Gs=function(e){var t,s,i;o(this,se,It).call(this,e),this.isSingleSelect&&!this.alwaysOpen&&((t=n(this,m))==null||t.openClose(),(s=n(this,m))==null||s.clearSearch()),(i=n(this,m))==null||i.focus(),o(this,ne,Vt).call(this)},at=new WeakSet,Ms=function(e,t){var s;(s=n(this,m))==null||s.focus(),this.updateListPosition(),o(this,ft,Ys).call(this,e,t)},ot=new WeakSet,Fs=function(e){this.selectedName!==e&&(this.selectedName=e,o(this,dt,$s).call(this))},rt=new WeakSet,js=function(){var e;this.isListOpened=!0,n(this,A)&&n(this,T)&&(window.addEventListener("scroll",n(this,A),!0),window.addEventListener("resize",n(this,T))),!(!n(this,u)||!this.srcElement)&&(this.appendToBody?(document.body.appendChild(n(this,u).srcElement),(e=n(this,q))==null||e.observe(this.srcElement)):this.srcElement.appendChild(n(this,u).srcElement),this.updateListPosition(),o(this,le,Bt).call(this,!0),o(this,ht,Rs).call(this),o(this,ut,Ws).call(this))},ie=new WeakSet,Pt=function(){var t;this.alwaysOpen||(this.isListOpened=!1,n(this,A)&&n(this,T)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),!n(this,u)||!this.srcElement)||!(this.appendToBody?document.body.contains(n(this,u).srcElement):this.srcElement.contains(n(this,u).srcElement))||(C(this,Q,n(this,u).srcElement.scrollTop),this.appendToBody?(document.body.removeChild(n(this,u).srcElement),(t=n(this,q))==null||t.disconnect()):this.srcElement.removeChild(n(this,u).srcElement),o(this,le,Bt).call(this,!1),o(this,pt,Us).call(this))},ct=new WeakSet,qs=function(e,t){if(!n(this,u)||!n(this,m))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,u).srcElement.classList.add(s),n(this,u).srcElement.classList.remove(i),n(this,m).srcElement.classList.add("treeselect-input--top"),n(this,m).srcElement.classList.remove("treeselect-input--bottom")):(n(this,u).srcElement.classList.remove(s),n(this,u).srcElement.classList.add(i),n(this,m).srcElement.classList.remove("treeselect-input--top"),n(this,m).srcElement.classList.add("treeselect-input--bottom"))},$=new WeakSet,gt=function(e){!n(this,m)||!n(this,u)||(e?(n(this,m).srcElement.classList.add("treeselect-input--focused"),n(this,u).srcElement.classList.add("treeselect-list--focused")):(n(this,m).srcElement.classList.remove("treeselect-input--focused"),n(this,u).srcElement.classList.remove("treeselect-list--focused")))},le=new WeakSet,Bt=function(e){var t,s,i,a;e?(t=n(this,m))==null||t.srcElement.classList.add("treeselect-input--opened"):(s=n(this,m))==null||s.srcElement.classList.remove("treeselect-input--opened"),this.staticList?(i=n(this,u))==null||i.srcElement.classList.add("treeselect-list--static"):(a=n(this,u))==null||a.srcElement.classList.remove("treeselect-list--static")},W=new WeakSet,kt=function(e){!n(this,A)||!n(this,T)||!n(this,S)||!n(this,D)||((!this.alwaysOpen||e)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),document.removeEventListener("mousedown",n(this,S),!0),document.removeEventListener("focus",n(this,S),!0),window.removeEventListener("blur",n(this,D)))},ht=new WeakSet,Rs=function(){var t,s,i;const e=(t=n(this,u))==null?void 0:t.isLastFocusedElementExist();this.saveScrollPosition&&e?(s=n(this,u))==null||s.srcElement.scroll(0,n(this,Q)):(i=n(this,u))==null||i.focusFirstListElement()},ne=new WeakSet,Vt=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("input",{detail:this.value})),this.inputCallback&&this.inputCallback(this.value)},dt=new WeakSet,$s=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("name-change",{detail:this.selectedName})),this.nameChangeCallback&&this.nameChangeCallback(this.selectedName)},ut=new WeakSet,Ws=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("open",{detail:this.value})),this.openCallback&&this.openCallback(this.value))},pt=new WeakSet,Us=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("close",{detail:this.value})),this.closeCallback&&this.closeCallback(this.value))},mt=new WeakSet,zs=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)},ft=new WeakSet,Ys=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)},vi});
1
+ var Gi=Object.defineProperty;var Mi=(C,p,f)=>p in C?Gi(C,p,{enumerable:!0,configurable:!0,writable:!0,value:f}):C[p]=f;var c=(C,p,f)=>(Mi(C,typeof p!="symbol"?p+"":p,f),f),yt=(C,p,f)=>{if(!p.has(C))throw TypeError("Cannot "+f)};var n=(C,p,f)=>(yt(C,p,"read from private field"),f?f.call(C):p.get(C)),r=(C,p,f)=>{if(p.has(C))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(C):p.set(C,f)},b=(C,p,f,z)=>(yt(C,p,"write to private field"),z?z.call(C,f):p.set(C,f),f);var o=(C,p,f)=>(yt(C,p,"access private method"),f);(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(){var P,y,H,x,pe,Ut,G,oe,me,zt,fe,Yt,M,re,B,q,Ce,Kt,be,Xt,ge,Jt,ke,Zt,we,Qt,Ee,es,ve,ts,Le,ss,ye,is,xe,ls,Se,ns,_e,as,Ae,os,Te,rs,Ne,cs,Oe,hs,Y,xt,F,V,_,K,Ie,ds,Pe,us,Be,ps,Ve,ms,De,fs,He,Cs,X,St,Ge,bs,Me,gs,Fe,ks,J,_t,je,ws,qe,Es,Re,vs,$e,Ls,We,ys,Ue,xs,ze,Ss,Ye,_s,Ke,As,Xe,Ts,Je,Ns,Z,At,Q,Tt,Ze,Os,u,m,R,ee,$,A,T,S,D,te,Nt,se,Ot,Qe,Is,et,Ps,tt,Bs,st,Vs,it,Ds,lt,Hs,ie,It,nt,Gs,at,Ms,ot,Fs,rt,js,le,Pt,ct,qs,W,gt,ne,Bt,U,kt,ht,Rs,ae,Vt,dt,$s,ut,Ws,pt,Us,mt,zs,ft,Ys;"use strict";const C="",p={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>'},f=(l,e)=>{if(e.innerHTML="",typeof l=="string")e.innerHTML=l;else{const t=l.cloneNode(!0);e.appendChild(t)}},z=l=>{const e=l?{...l}:{};return Object.keys(p).forEach(t=>{e[t]||(e[t]=p[t])}),e},Ks=l=>l.reduce((e,{name:t},s)=>(e+=t,s<l.length-1&&(e+=", "),e),"");class Xs{constructor({value:e,showTags:t,tagsCountText:s,clearable:i,isAlwaysOpened:a,searchable:h,placeholder:d,disabled:w,isSingleSelect:g,id:k,ariaLabel:E,iconElements:v,inputCallback:L,searchCallback:N,openCallback:O,closeCallback:j,keydownCallback:Ct,focusCallback:vt,blurCallback:Lt,nameChangeCallback:bt}){r(this,pe);r(this,G);r(this,me);r(this,fe);r(this,M);r(this,B);r(this,Ce);r(this,be);r(this,ge);r(this,ke);r(this,we);r(this,Ee);r(this,ve);r(this,Le);r(this,ye);r(this,xe);r(this,Se);r(this,_e);r(this,Ae);r(this,Te);r(this,Ne);r(this,Oe);r(this,Y);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");c(this,"isOpened");c(this,"searchText");c(this,"srcElement");r(this,P,void 0);r(this,y,void 0);r(this,H,void 0);r(this,x,void 0);c(this,"inputCallback");c(this,"searchCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"keydownCallback");c(this,"focusCallback");c(this,"blurCallback");c(this,"nameChangeCallback");this.value=e,this.showTags=t,this.tagsCountText=s,this.searchable=h,this.placeholder=d,this.clearable=i,this.isAlwaysOpened=a,this.disabled=w,this.isSingleSelect=g,this.id=k,this.ariaLabel=E,this.iconElements=v,this.isOpened=!1,this.searchText="",b(this,P,o(this,ge,Jt).call(this)),b(this,y,o(this,ye,is).call(this)),b(this,H,o(this,_e,as).call(this)),b(this,x,null),this.inputCallback=L,this.searchCallback=N,this.openCallback=O,this.closeCallback=j,this.keydownCallback=Ct,this.focusCallback=vt,this.blurCallback=Lt,this.nameChangeCallback=bt,this.srcElement=o(this,Ce,Kt).call(this,n(this,P),n(this,y),n(this,H)),o(this,pe,Ut).call(this)}focus(){setTimeout(()=>n(this,y).focus(),0)}blur(){this.isOpened&&o(this,B,q).call(this),this.clearSearch(),n(this,y).blur()}updateValue(e){this.value=e,o(this,G,oe).call(this),o(this,M,re).call(this)}removeItem(e){this.value=this.value.filter(t=>t.id!==e),o(this,Y,xt).call(this),o(this,G,oe).call(this),o(this,M,re).call(this)}clear(){this.value=[],o(this,Y,xt).call(this),o(this,G,oe).call(this),this.clearSearch()}openClose(){o(this,B,q).call(this)}clearSearch(){this.searchText="",this.searchCallback(""),o(this,M,re).call(this)}}P=new WeakMap,y=new WeakMap,H=new WeakMap,x=new WeakMap,pe=new WeakSet,Ut=function(){o(this,G,oe).call(this),o(this,M,re).call(this),o(this,me,zt).call(this)},G=new WeakSet,oe=function(){if(n(this,P).innerHTML="",this.showTags){n(this,P).append(...o(this,ke,Zt).call(this));const e=Ks(this.value);this.nameChangeCallback(e)}else{const e=o(this,Le,ss).call(this);n(this,P).appendChild(e),this.nameChangeCallback(e.innerText)}n(this,P).appendChild(n(this,y))},me=new WeakSet,zt=function(){const e=[];n(this,H).innerHTML="",this.clearable&&e.push(o(this,Ae,os).call(this)),this.isAlwaysOpened||e.push(o(this,Ne,cs).call(this,this.isOpened)),e.length&&n(this,H).append(...e)},fe=new WeakSet,Yt=function(){if(!this.isAlwaysOpened&&n(this,x)){const e=this.isOpened?this.iconElements.arrowUp:this.iconElements.arrowDown;f(e,n(this,x))}},M=new WeakSet,re=function(){var e;(e=this.value)!=null&&e.length?(n(this,y).removeAttribute("placeholder"),this.srcElement.classList.remove("treeselect-input--value-not-selected")):(n(this,y).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,y).value=this.searchText},B=new WeakSet,q=function(){this.isOpened=!this.isOpened,o(this,fe,Yt).call(this),this.isOpened?this.openCallback():this.closeCallback()},Ce=new WeakSet,Kt=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,be,Xt).call(this,a)),i.addEventListener("focus",()=>this.focusCallback(),!0),i.addEventListener("blur",()=>this.blurCallback(),!0),e.appendChild(t),i.append(e,s),i},be=new WeakSet,Xt=function(e){e.stopPropagation(),this.isOpened||o(this,B,q).call(this),this.focus()},ge=new WeakSet,Jt=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__tags"),e},ke=new WeakSet,Zt=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,Ee,es).call(this,e.name),i=o(this,ve,ts).call(this);return t.addEventListener("mousedown",a=>o(this,we,Qt).call(this,a,e.id)),t.append(s,i),t})},we=new WeakSet,Qt=function(e,t){e.preventDefault(),e.stopPropagation(),this.removeItem(t),this.focus()},Ee=new WeakSet,es=function(e){const t=document.createElement("span");return t.classList.add("treeselect-input__tags-name"),t.textContent=e,t},ve=new WeakSet,ts=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__tags-cross"),f(this.iconElements.cross,e),e},Le=new WeakSet,ss=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},ye=new WeakSet,is=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,xe,ls).call(this,t)),e.addEventListener("input",t=>o(this,Se,ns).call(this,t,e)),e},xe=new WeakSet,ls=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,B,q).call(this),(t==="Enter"||t==="ArrowDown"||t==="ArrowUp")&&e.preventDefault(),this.keydownCallback(e),t!=="Tab"&&this.focus()},Se=new WeakSet,ns=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,B,q).call(this)}else t.value="";this.searchText=t.value},_e=new WeakSet,as=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__operators"),e},Ae=new WeakSet,os=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__clear"),e.setAttribute("tabindex","-1"),f(this.iconElements.clear,e),e.addEventListener("mousedown",t=>o(this,Te,rs).call(this,t)),e},Te=new WeakSet,rs=function(e){e.preventDefault(),e.stopPropagation(),(this.searchText.length||this.value.length)&&this.clear(),this.focus()},Ne=new WeakSet,cs=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 f(t,n(this,x)),n(this,x).addEventListener("mousedown",s=>o(this,Oe,hs).call(this,s)),n(this,x)},Oe=new WeakSet,hs=function(e){e.stopPropagation(),e.preventDefault(),this.focus(),o(this,B,q).call(this)},Y=new WeakSet,xt=function(){this.inputCallback(this.value)};const Dt=(l,e,t,s)=>{ei(e);const i=e.filter(a=>!a.disabled&&l.some(h=>h===a.id));if(t&&i.length){i[0].checked=!0;return}i.forEach(a=>{a.checked=!0;const h=wt(a,e,s);a.checked=h})},wt=({id:l,checked:e},t,s)=>{const i=t.find(h=>h.id===l);if(!i)return!1;if(s)return i.checked=i.disabled?!1:!!e,i.checked;const a=Ht(!!e,i,t);return Gt(i,t),a},Ht=(l,e,t)=>{if(!e.isGroup)return e.checked=e.disabled?!1:!!l,e.isPartialChecked=!1,e.checked;const s=t.filter(d=>d.childOf===e.id);return!l||e.disabled||e.isPartialChecked?(e.checked=!1,e.isPartialChecked=!1,Et(e,s,t),e.checked):Mt(s,t)?Ft(s)?(e.checked=!1,e.isPartialChecked=!1,e.disabled=!0,e.checked):(e.checked=!1,e.isPartialChecked=!0,s.forEach(d=>{Ht(l,d,t)}),e.checked):(e.checked=!0,e.isPartialChecked=!1,Et(e,s,t),e.checked)},Gt=(l,e)=>{const t=e.find(s=>s.id===l.childOf);t&&(Js(t,e),Gt(t,e))},Js=(l,e)=>{const t=ce(l,e);if(Ft(t)){l.checked=!1,l.isPartialChecked=!1,l.disabled=!0;return}if(Zs(t)){l.checked=!0,l.isPartialChecked=!1;return}if(Qs(t)){l.checked=!1,l.isPartialChecked=!0;return}l.checked=!1,l.isPartialChecked=!1},Et=({checked:l,disabled:e},t,s)=>{t.forEach(i=>{i.disabled=!!e||!!i.disabled,i.checked=!!l&&!i.disabled,i.isPartialChecked=!1;const a=ce(i,s);Et({checked:l,disabled:e},a,s)})},Mt=(l,e)=>l.some(i=>i.disabled)?!0:l.some(i=>{if(i.isGroup){const a=ce(i,e);return Mt(a,e)}return!1}),Ft=l=>l.every(e=>!!e.disabled),Zs=l=>l.every(e=>!!e.checked),Qs=l=>l.some(e=>!!e.checked||!!e.isPartialChecked),ei=l=>{l.forEach(e=>{e.checked=!1,e.isPartialChecked=!1})},ti=(l,e,t)=>{const s={level:0,groupId:""},i=jt(l,e,s.groupId,s.level);return ii(i,t)},jt=(l,e,t,s)=>l.reduce((i,a)=>{var g;const h=!!((g=a.children)!=null&&g.length),d=s>=e&&h,w=s>e;if(i.push({id:a.value,name:a.name,childOf:t,isGroup:h,checked:!1,isPartialChecked:!1,level:s,isClosed:d,hidden:w,disabled:a.disabled??!1}),h){const k=jt(a.children,e,a.value,s+1);i.push(...k)}return i},[]),ce=({id:l},e)=>e.filter(t=>t.childOf===l),si=l=>{const{ungroupedNodes:e,allGroupedNodes:t,allNodes:s}=l.reduce((a,h)=>(h.checked&&(a.allNodes.push(h),h.isGroup?a.allGroupedNodes.push(h):a.ungroupedNodes.push(h)),a),{ungroupedNodes:[],allGroupedNodes:[],allNodes:[]}),i=s.filter(a=>!t.some(({id:h})=>h===a.childOf));return{ungroupedNodes:e,groupedNodes:i,allNodes:s}},ii=(l,e)=>(l.filter(s=>!!s.disabled).forEach(({id:s})=>wt({id:s,checked:!1},l,e)),l),he=(l,{id:e,isClosed:t})=>{ce({id:e},l).forEach(i=>{i.hidden=t??!1,i.isGroup&&!i.isClosed&&he(l,{id:i.id,isClosed:t})})},li=l=>{l.filter(e=>e.isGroup&&!e.disabled&&(e.checked||e.isPartialChecked)).forEach(e=>{e.isClosed=!1,he(l,e)})},ni=(l,e)=>{const t=ai(l,e);l.forEach(s=>{t.some(({id:a})=>a===s.id)?(s.isGroup&&(s.isClosed=!1,he(l,s)),s.hidden=!1):s.hidden=!0})},ai=(l,e)=>l.reduce((t,s)=>{if(s.name.toLowerCase().includes(e.toLowerCase())){if(t.push(s),s.isGroup){const a=qt(s.id,l);t.push(...a)}if(s.childOf){const a=Rt(s.childOf,l);t.push(...a)}}return t},[]),qt=(l,e)=>e.reduce((t,s)=>(s.childOf===l&&(t.push(s),s.isGroup&&t.push(...qt(s.id,e))),t),[]),Rt=(l,e)=>e.reduce((t,s)=>(s.id===l&&(t.push(s),s.childOf&&t.push(...Rt(s.childOf,e))),t),[]),oi=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.`)},ri=(l,e,t,s,i,a,h,d,w,g)=>{Dt(l,e,i,w),d&&h&&li(e),de(e,t,s,a,g)},de=(l,e,t,s,i)=>{l.forEach(a=>{const h=e.querySelector(`[input-id="${a.id}"]`),d=I(h);h.checked=a.checked,ci(a,d,s),hi(a,d),di(a,d),ui(a,d,t),pi(a,d),fi(a,d,l,i),mi(a,h,t)}),Ci(l,e)},ci=(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")},hi=(l,e)=>{l.isPartialChecked?e.classList.add("treeselect-list__item--partial-checked"):e.classList.remove("treeselect-list__item--partial-checked")},di=(l,e)=>{l.disabled?e.classList.add("treeselect-list__item--disabled"):e.classList.remove("treeselect-list__item--disabled")},ui=(l,e,t)=>{if(l.isGroup){const s=e.querySelector(".treeselect-list__item-icon"),i=l.isClosed?t.arrowRight:t.arrowDown;f(i,s),l.isClosed?e.classList.add("treeselect-list__item--closed"):e.classList.remove("treeselect-list__item--closed")}},pi=(l,e)=>{l.hidden?e.classList.add("treeselect-list__item--hidden"):e.classList.remove("treeselect-list__item--hidden")},mi=(l,e,t)=>{const i=e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");l.checked?f(t.check,i):l.isPartialChecked?f(t.partialCheck,i):i.innerHTML=""},fi=(l,e,t,s)=>{const i=l.level===0,a=20,h=5;if(i){const d=t.some(k=>k.isGroup&&k.level===l.level),w=!l.isGroup&&d?`${a}px`:`${h}px`,g=l.isGroup?"0":w;s?e.style.paddingRight=g:e.style.paddingLeft=g}else{const d=l.isGroup?`${l.level*a}px`:`${l.level*a+a}px`;s?e.style.paddingRight=d:e.style.paddingLeft=d}e.setAttribute("level",l.level.toString()),e.setAttribute("group",l.isGroup.toString())},Ci=(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")},I=l=>l.parentNode.parentNode,$t=(l,e)=>e.find(t=>t.id.toString()===l),bi=l=>I(l).querySelector(".treeselect-list__item-icon"),gi=(l,e)=>{e&&Object.keys(e).forEach(t=>{const s=e[t];typeof s=="string"&&l.setAttribute(t,s)})};class ki{constructor({options:e,value:t,openLevel:s,listSlotHtmlComponent:i,emptyText:a,isSingleSelect:h,iconElements:d,showCount:w,disabledBranchNode:g,expandSelected:k,isIndependentNodes:E,rtl:v,listClassName:L,inputCallback:N,arrowClickCallback:O,mouseupCallback:j}){r(this,Ie);r(this,Pe);r(this,Be);r(this,Ve);r(this,De);r(this,He);r(this,X);r(this,Ge);r(this,Me);r(this,Fe);r(this,J);r(this,je);r(this,qe);r(this,Re);r(this,$e);r(this,We);r(this,Ue);r(this,ze);r(this,Ye);r(this,Ke);r(this,Xe);r(this,Je);r(this,Z);r(this,Q);r(this,Ze);c(this,"options");c(this,"value");c(this,"openLevel");c(this,"listSlotHtmlComponent");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,"iconElements");c(this,"searchText");c(this,"flattedOptions");c(this,"flattedOptionsBeforeSearch");c(this,"selectedNodes");c(this,"srcElement");c(this,"inputCallback");c(this,"arrowClickCallback");c(this,"mouseupCallback");r(this,F,null);r(this,V,!0);r(this,_,[]);r(this,K,!0);this.options=e,this.value=t,this.openLevel=s??0,this.listSlotHtmlComponent=i??null,this.emptyText=a??"No results found...",this.isSingleSelect=h??!1,this.showCount=w??!1,this.disabledBranchNode=g??!1,this.expandSelected=k??!1,this.isIndependentNodes=E??!1,this.rtl=v??!1,this.listClassName=L??"",this.iconElements=d,this.searchText="",this.flattedOptions=ti(this.options,this.openLevel,this.isIndependentNodes),this.flattedOptionsBeforeSearch=this.flattedOptions,this.selectedNodes={nodes:[],groupedNodes:[],allNodes:[]},this.srcElement=o(this,Be,ps).call(this),this.inputCallback=N,this.arrowClickCallback=O,this.mouseupCallback=j,oi(this.flattedOptions)}updateValue(e){this.value=e,b(this,_,this.isSingleSelect?this.value:[]),ri(e,this.flattedOptions,this.srcElement,this.iconElements,this.isSingleSelect,n(this,_),this.expandSelected,n(this,K),this.isIndependentNodes,this.rtl),b(this,K,!1),o(this,Q,Tt).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&&ni(this.flattedOptions,e),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),this.focusFirstListElement()}callKeyAction(e){b(this,V,!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,Ie,ds).call(this,t,e),(i==="ArrowDown"||i==="ArrowUp")&&o(this,Pe,us).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(I(a)).display!=="none");if(!s.length)return;t&&t.classList.remove(e),I(s[0]).classList.add(e)}isLastFocusedElementExist(){return!!n(this,F)}}F=new WeakMap,V=new WeakMap,_=new WeakMap,K=new WeakMap,Ie=new WeakSet,ds=function(e,t){if(!e)return;const s=t.key,a=e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"),h=$t(a,this.flattedOptions),d=e.querySelector(".treeselect-list__item-icon");s==="ArrowLeft"&&!h.isClosed&&h.isGroup&&(d.dispatchEvent(new Event("mousedown")),t.preventDefault()),s==="ArrowRight"&&h.isClosed&&h.isGroup&&(d.dispatchEvent(new Event("mousedown")),t.preventDefault())},Pe=new WeakSet,us=function(e,t){var i;const s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(I(a)).display!=="none");if(s.length)if(!e)I(s[0]).classList.add("treeselect-list__item--focused");else{const a=s.findIndex(O=>I(O).classList.contains("treeselect-list__item--focused"));I(s[a]).classList.remove("treeselect-list__item--focused");const d=t==="ArrowDown"?a+1:a-1,w=t==="ArrowDown"?0:s.length-1,g=s[d]??s[w],k=!s[d],E=I(g);E.classList.add("treeselect-list__item--focused");const v=this.srcElement.getBoundingClientRect(),L=E.getBoundingClientRect();if(k&&t==="ArrowDown"){this.srcElement.scroll(0,0);return}if(k&&t==="ArrowUp"){this.srcElement.scroll(0,this.srcElement.scrollHeight);return}const N=((i=this.listSlotHtmlComponent)==null?void 0:i.clientHeight)??0;if(v.y+v.height<L.y+L.height+N){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}}},Be=new WeakSet,ps=function(){const e=o(this,Ve,ms).call(this),t=o(this,X,St).call(this,this.options);e.append(...t);const s=o(this,Me,gs).call(this);e.append(s);const i=o(this,Ge,bs).call(this);return i&&e.append(i),e},Ve=new WeakSet,ms=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,De,fs).call(this,t)),e.addEventListener("mousemove",()=>o(this,He,Cs).call(this)),e.addEventListener("mouseup",()=>this.mouseupCallback(),!0),e},De=new WeakSet,fs=function(e){e.stopPropagation(),n(this,F)&&n(this,V)&&n(this,F).classList.add("treeselect-list__item--focused")},He=new WeakSet,Cs=function(){b(this,V,!0)},X=new WeakSet,St=function(e){return e.reduce((t,s)=>{var a;if((a=s.children)!=null&&a.length){const h=o(this,Fe,ks).call(this,s),d=o(this,X,St).call(this,s.children);return h.append(...d),t.push(h),t}const i=o(this,J,_t).call(this,s,!1);return t.push(i),t},[])},Ge=new WeakSet,bs=function(){if(!this.listSlotHtmlComponent)return null;const e=document.createElement("div");return e.classList.add("treeselect-list__slot"),e.appendChild(this.listSlotHtmlComponent),e},Me=new WeakSet,gs=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"),f(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},Fe=new WeakSet,ks=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,J,_t).call(this,e,!0);return t.appendChild(s),t},J=new WeakSet,_t=function(e,t){const s=o(this,je,ws).call(this,e);if(t){const h=o(this,We,ys).call(this);s.appendChild(h),s.classList.add("treeselect-list__item--group")}const i=o(this,ze,Ss).call(this,e),a=o(this,Ye,_s).call(this,e,t);return s.append(i,a),s},je=new WeakSet,ws=function(e){const t=document.createElement("div");return gi(t,e.htmlAttr),t.setAttribute("tabindex","-1"),t.setAttribute("title",e.name),t.classList.add("treeselect-list__item"),t.addEventListener("mouseover",()=>o(this,qe,Es).call(this,t),!0),t.addEventListener("mouseout",()=>o(this,Re,vs).call(this,t),!0),t.addEventListener("mousedown",s=>o(this,$e,Ls).call(this,s,e)),t},qe=new WeakSet,Es=function(e){n(this,V)&&o(this,Z,At).call(this,!0,e)},Re=new WeakSet,vs=function(e){n(this,V)&&(o(this,Z,At).call(this,!1,e),b(this,F,e))},$e=new WeakSet,Ls=function(e,t){var a;if(e.preventDefault(),e.stopPropagation(),(a=this.flattedOptions.find(h=>h.id===t.value))==null?void 0:a.disabled)return;const i=e.target.querySelector(".treeselect-list__item-checkbox");i.checked=!i.checked,o(this,Xe,Ts).call(this,i,t)},We=new WeakSet,ys=function(){const e=document.createElement("span");return e.setAttribute("tabindex","-1"),e.classList.add("treeselect-list__item-icon"),f(this.iconElements.arrowDown,e),e.addEventListener("mousedown",t=>o(this,Ue,xs).call(this,t)),e},Ue=new WeakSet,xs=function(e){e.preventDefault(),e.stopPropagation(),o(this,Je,Ns).call(this,e)},ze=new WeakSet,Ss=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},Ye=new WeakSet,_s=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,Ke,As).call(this,e);s.appendChild(i)}return s},Ke=new WeakSet,As=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},Xe=new WeakSet,Ts=function(e,t){const s=this.flattedOptions.find(i=>i.id===t.value);if(s){if(s!=null&&s.isGroup&&this.disabledBranchNode){const i=bi(e);i==null||i.dispatchEvent(new Event("mousedown"));return}if(this.isSingleSelect){const[i]=n(this,_);if(s.id===i)return;b(this,_,[s.id]),Dt([s.id],this.flattedOptions,this.isSingleSelect,this.isIndependentNodes)}else{s.checked=e.checked;const i=wt(s,this.flattedOptions,this.isIndependentNodes);e.checked=i}de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),o(this,Ze,Os).call(this)}},Je=new WeakSet,Ns=function(e){var a,h;const t=(h=(a=e.target)==null?void 0:a.parentNode)==null?void 0:h.querySelector("[input-id]"),s=(t==null?void 0:t.getAttribute("input-id"))??null,i=$t(s,this.flattedOptions);i&&(i.isClosed=!i.isClosed,he(this.flattedOptions,i),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),this.arrowClickCallback(i.id,i.isClosed))},Z=new WeakSet,At=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)},Q=new WeakSet,Tt=function(){const{ungroupedNodes:e,groupedNodes:t,allNodes:s}=si(this.flattedOptions);this.selectedNodes={nodes:e,groupedNodes:t,allNodes:s}},Ze=new WeakSet,Os=function(){o(this,Q,Tt).call(this),this.inputCallback(this.selectedNodes),this.value=this.selectedNodes.nodes.map(e=>e.id)};const Wt=({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!")},ue=l=>l.map(e=>e.id),wi=l=>l?Array.isArray(l)?l:[l]:[],Ei=(l,e)=>{if(e){const[t]=l;return t??null}return l};class vi{constructor({parentHtmlContainer:e,value:t,options:s,openLevel:i,appendToBody:a,alwaysOpen:h,showTags:d,tagsCountText:w,clearable:g,searchable:k,placeholder:E,grouped:v,isGroupedValue:L,listSlotHtmlComponent:N,disabled:O,emptyText:j,staticList:Ct,id:vt,ariaLabel:Lt,isSingleSelect:bt,showCount:Li,disabledBranchNode:yi,direction:xi,expandSelected:Si,saveScrollPosition:_i,isIndependentNodes:Ai,rtl:Ti,listClassName:Ni,iconElements:Oi,inputCallback:Ii,openCallback:Pi,closeCallback:Bi,nameChangeCallback:Vi,searchCallback:Di,openCloseGroupCallback:Hi}){r(this,te);r(this,se);r(this,Qe);r(this,et);r(this,tt);r(this,st);r(this,it);r(this,lt);r(this,ie);r(this,nt);r(this,at);r(this,ot);r(this,rt);r(this,le);r(this,ct);r(this,W);r(this,ne);r(this,U);r(this,ht);r(this,ae);r(this,dt);r(this,ut);r(this,pt);r(this,mt);r(this,ft);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,"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,"iconElements");c(this,"inputCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"nameChangeCallback");c(this,"searchCallback");c(this,"openCloseGroupCallback");c(this,"ungroupedValue");c(this,"groupedValue");c(this,"allValue");c(this,"isListOpened");c(this,"selectedName");c(this,"srcElement");r(this,u,null);r(this,m,null);r(this,R,null);r(this,ee,0);r(this,$,0);r(this,A,null);r(this,T,null);r(this,S,null);r(this,D,null);Wt({parentHtmlContainer:e,value:t,staticList:Ct,appendToBody:a,isSingleSelect:bt}),this.parentHtmlContainer=e,this.value=[],this.options=s??[],this.openLevel=i??0,this.appendToBody=a??!1,this.alwaysOpen=!!(h&&!O),this.showTags=d??!0,this.tagsCountText=w??"elements selected",this.clearable=g??!0,this.searchable=k??!0,this.placeholder=E??"Search...",this.grouped=v??!0,this.isGroupedValue=L??!1,this.listSlotHtmlComponent=N??null,this.disabled=O??!1,this.emptyText=j??"No results found...",this.staticList=!!(Ct&&!this.appendToBody),this.id=vt??"",this.ariaLabel=Lt??"",this.isSingleSelect=bt??!1,this.showCount=Li??!1,this.disabledBranchNode=yi??!1,this.direction=xi??"auto",this.expandSelected=Si??!1,this.saveScrollPosition=_i??!0,this.isIndependentNodes=Ai??!1,this.rtl=Ti??!1,this.listClassName=Ni??"",this.iconElements=z(Oi),this.inputCallback=Ii,this.openCallback=Pi,this.closeCallback=Bi,this.nameChangeCallback=Vi,this.searchCallback=Di,this.openCloseGroupCallback=Hi,this.ungroupedValue=[],this.groupedValue=[],this.allValue=[],this.isListOpened=!1,this.selectedName="",this.srcElement=null,o(this,te,Nt).call(this,t)}mount(){Wt({parentHtmlContainer:this.parentHtmlContainer,value:this.value,staticList:this.staticList,appendToBody:this.appendToBody,isSingleSelect:this.isSingleSelect}),this.iconElements=z(this.iconElements),o(this,te,Nt).call(this,this.value)}updateValue(e){const t=wi(e),s=n(this,u);s&&(s.updateValue(t),o(this,ie,It).call(this,s==null?void 0:s.selectedNodes))}destroy(){this.srcElement&&(o(this,le,Pt).call(this),this.srcElement.innerHTML="",this.srcElement=null,o(this,U,kt).call(this,!0))}focus(){n(this,m)&&n(this,m).focus()}toggleOpenClose(){n(this,m)&&(n(this,m).openClose(),n(this,m).focus())}scrollWindowHandler(){this.updateListPosition()}focusWindowHandler(e){var s,i,a;((s=this.srcElement)==null?void 0:s.contains(e.target))||((i=n(this,u))==null?void 0:i.srcElement.contains(e.target))||((a=n(this,m))==null||a.blur(),o(this,U,kt).call(this,!1),o(this,W,gt).call(this,!1))}blurWindowHandler(){var e;(e=n(this,m))==null||e.blur(),o(this,U,kt).call(this,!1),o(this,W,gt).call(this,!1)}updateListPosition(){var N;const e=this.srcElement,t=(N=n(this,u))==null?void 0:N.srcElement;if(!e||!t)return;const{height:s}=t.getBoundingClientRect(),{x:i,y:a,height:h,width:d}=e.getBoundingClientRect(),w=window.innerHeight,g=a,k=w-a-h;let E=g>k&&g>=s&&k<s;if(this.direction!=="auto"&&(E=this.direction==="top"),this.appendToBody){(t.style.top!=="0px"||t.style.left!=="0px")&&(t.style.top="0px",t.style.left="0px");const O=i+window.scrollX,j=E?a+window.scrollY-s:a+window.scrollY+h;t.style.transform=`translate(${O}px,${j}px)`,t.style.width=`${d}px`}const v=E?"top":"bottom";t.getAttribute("direction")!==v&&(t.setAttribute("direction",v),o(this,ct,qs).call(this,E,this.appendToBody))}}return u=new WeakMap,m=new WeakMap,R=new WeakMap,ee=new WeakMap,$=new WeakMap,A=new WeakMap,T=new WeakMap,S=new WeakMap,D=new WeakMap,te=new WeakSet,Nt=function(e){var a;this.destroy();const{container:t,list:s,input:i}=o(this,Qe,Is).call(this);this.srcElement=t,b(this,u,s),b(this,m,i),b(this,A,this.scrollWindowHandler.bind(this)),b(this,T,this.scrollWindowHandler.bind(this)),b(this,S,this.focusWindowHandler.bind(this)),b(this,D,this.blurWindowHandler.bind(this)),this.alwaysOpen&&((a=n(this,m))==null||a.openClose()),this.disabled?this.srcElement.classList.add("treeselect--disabled"):this.srcElement.classList.remove("treeselect--disabled"),this.updateValue(e??this.value)},se=new WeakSet,Ot=function({groupedNodes:e,nodes:t,allNodes:s}){this.ungroupedValue=t?ue(t):[],this.groupedValue=e?ue(e):[],this.allValue=s?ue(s):[];let i=[];this.isIndependentNodes||this.isSingleSelect?i=this.allValue:this.isGroupedValue?i=this.groupedValue:i=this.ungroupedValue,this.value=Ei(i,this.isSingleSelect)},Qe=new WeakSet,Is=function(){const e=this.parentHtmlContainer;e.classList.add("treeselect"),this.rtl&&e.setAttribute("dir","rtl");const t=new ki({value:[],options:this.options,openLevel:this.openLevel,listSlotHtmlComponent:this.listSlotHtmlComponent,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,nt,Gs).call(this,i),arrowClickCallback:(i,a)=>o(this,at,Ms).call(this,i,a),mouseupCallback:()=>{var i;return(i=n(this,m))==null?void 0:i.focus()}}),s=new Xs({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,et,Ps).call(this,i),searchCallback:i=>o(this,st,Vs).call(this,i),openCallback:()=>o(this,rt,js).call(this),closeCallback:()=>o(this,le,Pt).call(this),keydownCallback:i=>o(this,tt,Bs).call(this,i),focusCallback:()=>o(this,it,Ds).call(this),blurCallback:()=>o(this,lt,Hs).call(this),nameChangeCallback:i=>o(this,ot,Fs).call(this,i)});return this.appendToBody&&b(this,R,new ResizeObserver(()=>this.updateListPosition())),e.append(s.srcElement),{container:e,list:t,input:s}},et=new WeakSet,Ps=function(e){var i,a;const t=ue(e);(i=n(this,u))==null||i.updateValue(t);const s=((a=n(this,u))==null?void 0:a.selectedNodes)??{};o(this,se,Ot).call(this,s),o(this,ae,Vt).call(this)},tt=new WeakSet,Bs=function(e){var t;this.isListOpened&&((t=n(this,u))==null||t.callKeyAction(e))},st=new WeakSet,Vs=function(e){n(this,$)&&clearTimeout(n(this,$)),b(this,$,window.setTimeout(()=>{var t;(t=n(this,u))==null||t.updateSearchValue(e),this.updateListPosition()},350)),o(this,mt,zs).call(this,e)},it=new WeakSet,Ds=function(){o(this,W,gt).call(this,!0),n(this,S)&&n(this,S)&&n(this,D)&&(document.addEventListener("mousedown",n(this,S),!0),document.addEventListener("focus",n(this,S),!0),window.addEventListener("blur",n(this,D)))},lt=new WeakSet,Hs=function(){setTimeout(()=>{var s,i;const e=(s=n(this,m))==null?void 0:s.srcElement.contains(document.activeElement),t=(i=n(this,u))==null?void 0:i.srcElement.contains(document.activeElement);!e&&!t&&this.blurWindowHandler()},1)},ie=new WeakSet,It=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,m))==null||s.updateValue(t),o(this,se,Ot).call(this,e)},nt=new WeakSet,Gs=function(e){var t,s,i;o(this,ie,It).call(this,e),this.isSingleSelect&&!this.alwaysOpen&&((t=n(this,m))==null||t.openClose(),(s=n(this,m))==null||s.clearSearch()),(i=n(this,m))==null||i.focus(),o(this,ae,Vt).call(this)},at=new WeakSet,Ms=function(e,t){var s;(s=n(this,m))==null||s.focus(),this.updateListPosition(),o(this,ft,Ys).call(this,e,t)},ot=new WeakSet,Fs=function(e){this.selectedName!==e&&(this.selectedName=e,o(this,dt,$s).call(this))},rt=new WeakSet,js=function(){var e;this.isListOpened=!0,n(this,A)&&n(this,T)&&(window.addEventListener("scroll",n(this,A),!0),window.addEventListener("resize",n(this,T))),!(!n(this,u)||!this.srcElement)&&(this.appendToBody?(document.body.appendChild(n(this,u).srcElement),(e=n(this,R))==null||e.observe(this.srcElement)):this.srcElement.appendChild(n(this,u).srcElement),this.updateListPosition(),o(this,ne,Bt).call(this,!0),o(this,ht,Rs).call(this),o(this,ut,Ws).call(this))},le=new WeakSet,Pt=function(){var t;this.alwaysOpen||(this.isListOpened=!1,n(this,A)&&n(this,T)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),!n(this,u)||!this.srcElement)||!(this.appendToBody?document.body.contains(n(this,u).srcElement):this.srcElement.contains(n(this,u).srcElement))||(b(this,ee,n(this,u).srcElement.scrollTop),this.appendToBody?(document.body.removeChild(n(this,u).srcElement),(t=n(this,R))==null||t.disconnect()):this.srcElement.removeChild(n(this,u).srcElement),o(this,ne,Bt).call(this,!1),o(this,pt,Us).call(this))},ct=new WeakSet,qs=function(e,t){if(!n(this,u)||!n(this,m))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,u).srcElement.classList.add(s),n(this,u).srcElement.classList.remove(i),n(this,m).srcElement.classList.add("treeselect-input--top"),n(this,m).srcElement.classList.remove("treeselect-input--bottom")):(n(this,u).srcElement.classList.remove(s),n(this,u).srcElement.classList.add(i),n(this,m).srcElement.classList.remove("treeselect-input--top"),n(this,m).srcElement.classList.add("treeselect-input--bottom"))},W=new WeakSet,gt=function(e){!n(this,m)||!n(this,u)||(e?(n(this,m).srcElement.classList.add("treeselect-input--focused"),n(this,u).srcElement.classList.add("treeselect-list--focused")):(n(this,m).srcElement.classList.remove("treeselect-input--focused"),n(this,u).srcElement.classList.remove("treeselect-list--focused")))},ne=new WeakSet,Bt=function(e){var t,s,i,a;e?(t=n(this,m))==null||t.srcElement.classList.add("treeselect-input--opened"):(s=n(this,m))==null||s.srcElement.classList.remove("treeselect-input--opened"),this.staticList?(i=n(this,u))==null||i.srcElement.classList.add("treeselect-list--static"):(a=n(this,u))==null||a.srcElement.classList.remove("treeselect-list--static")},U=new WeakSet,kt=function(e){!n(this,A)||!n(this,T)||!n(this,S)||!n(this,D)||((!this.alwaysOpen||e)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),document.removeEventListener("mousedown",n(this,S),!0),document.removeEventListener("focus",n(this,S),!0),window.removeEventListener("blur",n(this,D)))},ht=new WeakSet,Rs=function(){var t,s,i;const e=(t=n(this,u))==null?void 0:t.isLastFocusedElementExist();this.saveScrollPosition&&e?(s=n(this,u))==null||s.srcElement.scroll(0,n(this,ee)):(i=n(this,u))==null||i.focusFirstListElement()},ae=new WeakSet,Vt=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("input",{detail:this.value})),this.inputCallback&&this.inputCallback(this.value)},dt=new WeakSet,$s=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("name-change",{detail:this.selectedName})),this.nameChangeCallback&&this.nameChangeCallback(this.selectedName)},ut=new WeakSet,Ws=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("open",{detail:this.value})),this.openCallback&&this.openCallback(this.value))},pt=new WeakSet,Us=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("close",{detail:this.value})),this.closeCallback&&this.closeCallback(this.value))},mt=new WeakSet,zs=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)},ft=new WeakSet,Ys=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)},vi});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "treeselectjs",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Treeselect JS",
5
5
  "main": "./dist/treeselectjs.umd.js",
6
6
  "module": "./dist/treeselectjs.mjs",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "scripts": {
25
25
  "dev": "vite",
26
- "build": "tsc && vite build",
26
+ "build": "tsc && vite build && node postBuild.js",
27
27
  "preview": "vite preview",
28
28
  "prettier": "prettier --w src && prettier --w app && prettier --w demo"
29
29
  },
@@ -49,7 +49,7 @@
49
49
  "devDependencies": {
50
50
  "prettier": "^2.8.7",
51
51
  "typescript": "^4.9.3",
52
- "vite": "^4.2.0",
52
+ "vite": "^4.5.2",
53
53
  "vite-plugin-dts": "^2.2.0"
54
54
  },
55
55
  "files": [