@konstructio/ui 0.1.2-alpha.74 → 0.1.2-alpha.75

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.
Files changed (62) hide show
  1. package/dist/{Modal-CXRo8f-h.js → Modal-BTOXCb0Y.js} +1 -1
  2. package/dist/assets/icons/components/Home2.d.ts +3 -0
  3. package/dist/assets/icons/components/Home2.js +28 -0
  4. package/dist/assets/icons/components/Upload.d.ts +3 -0
  5. package/dist/assets/icons/components/Upload.js +28 -0
  6. package/dist/assets/icons/components/index.d.ts +2 -0
  7. package/dist/assets/icons/components/index.js +70 -66
  8. package/dist/assets/icons/index.js +70 -66
  9. package/dist/components/Button/Button.variants.js +4 -5
  10. package/dist/components/ButtonGroup/ButtonGroup.js +1 -1
  11. package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.js +1 -1
  12. package/dist/components/DateRangePicker/components/CalendarPanel/components/IndependentModeCalendar/IndependentModeCalendar.js +1 -1
  13. package/dist/components/DateRangePicker/components/CalendarPanel/components/TogetherModeCalendar/TogetherModeCalendar.js +1 -1
  14. package/dist/components/Filter/Filter.js +24 -22
  15. package/dist/components/Filter/Filter.types.d.ts +8 -0
  16. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.hook.d.ts +3 -1
  17. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.hook.js +57 -41
  18. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +75 -49
  19. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.types.d.ts +2 -0
  20. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.hook.js +38 -37
  21. package/dist/components/Filter/components/DateRangeFilterDropdown/DateRangeFilterDropdown.hook.js +31 -30
  22. package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.js +64 -47
  23. package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.types.d.ts +2 -0
  24. package/dist/components/Filter/components/TimeFilterDropdown/TimeFilterDropdown.hook.js +35 -34
  25. package/dist/components/Filter/contexts/filter.context.d.ts +4 -0
  26. package/dist/components/Filter/contexts/filter.context.js +7 -0
  27. package/dist/components/Filter/contexts/filter.hook.d.ts +2 -0
  28. package/dist/components/Filter/contexts/filter.hook.js +11 -0
  29. package/dist/components/Filter/contexts/filter.provider.d.ts +5 -0
  30. package/dist/components/Filter/contexts/filter.provider.js +6 -0
  31. package/dist/components/Filter/contexts/index.d.ts +3 -0
  32. package/dist/components/Filter/contexts/index.js +8 -0
  33. package/dist/components/LineChart/LineChart.js +55 -52
  34. package/dist/components/LineChart/LineChart.types.d.ts +2 -0
  35. package/dist/components/Modal/Modal.js +1 -1
  36. package/dist/components/Modal/components/Wrapper/Wrapper.js +2 -2
  37. package/dist/components/Modal/components/index.js +1 -1
  38. package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +394 -353
  39. package/dist/components/Select/Select.types.d.ts +1 -0
  40. package/dist/components/Select/Select.variants.js +1 -1
  41. package/dist/components/Select/components/List/List.js +64 -61
  42. package/dist/components/Select/components/List/List.types.d.ts +1 -0
  43. package/dist/components/Select/components/Wrapper.js +46 -44
  44. package/dist/components/Select/constants/index.d.ts +1 -0
  45. package/dist/components/Select/constants/index.js +3 -1
  46. package/dist/components/Select/constants/list.d.ts +1 -0
  47. package/dist/components/Select/constants/list.js +4 -0
  48. package/dist/components/Toast/Toast.js +192 -184
  49. package/dist/components/Toast/Toast.variants.js +6 -12
  50. package/dist/components/VirtualizedTable/VirtualizedTable.js +57 -55
  51. package/dist/components/VirtualizedTable/VirtualizedTable.types.d.ts +2 -0
  52. package/dist/components/VirtualizedTable/components/Filter/Filter.js +55 -54
  53. package/dist/components/VirtualizedTable/components/Filter/Filter.types.d.ts +1 -0
  54. package/dist/components/index.js +1 -1
  55. package/dist/icons.d.ts +1 -1
  56. package/dist/icons.js +70 -66
  57. package/dist/index.js +1 -1
  58. package/dist/package.json +10 -10
  59. package/dist/proxy-BvdTb_6B.js +4974 -0
  60. package/dist/styles.css +1 -1
  61. package/package.json +10 -10
  62. package/dist/proxy-0sbyKj-k.js +0 -4946
@@ -1,170 +1,173 @@
1
- import { jsx as g, jsxs as R } from "react/jsx-runtime";
2
- import * as S from "react";
3
- import { useRef as T, useMemo as k, useEffect as D } from "react";
4
- import { flushSync as W } from "react-dom";
5
- import { Typography as O } from "../../../Typography/Typography.js";
6
- import { cn as z } from "../../../../utils/index.js";
7
- import { TruncateText as L } from "../TruncateText/TruncateText.js";
1
+ import { jsx as m, jsxs as N } from "react/jsx-runtime";
2
+ import * as w from "react";
3
+ import { useRef as T, useMemo as k, useEffect as L } from "react";
4
+ import { flushSync as D } from "react-dom";
5
+ import { Typography as y } from "../../../Typography/Typography.js";
6
+ import { cn as C } from "../../../../utils/index.js";
7
+ import { TruncateText as W } from "../TruncateText/TruncateText.js";
8
8
  import { usePhoneNumberContext as V } from "../../contexts/phone-number.hook.js";
9
- function x(r, l, e) {
10
- let s = e.initialDeps ?? [], t, o = !0;
11
- function n() {
12
- var i, a, u;
9
+ function x(o, r, e) {
10
+ let t = e.initialDeps ?? [], s, n = !0;
11
+ function i() {
12
+ var l, a, u;
13
13
  let c;
14
- e.key && ((i = e.debug) != null && i.call(e)) && (c = Date.now());
15
- const d = r();
16
- if (!(d.length !== s.length || d.some((v, f) => s[f] !== v)))
17
- return t;
18
- s = d;
19
- let m;
20
- if (e.key && ((a = e.debug) != null && a.call(e)) && (m = Date.now()), t = l(...d), e.key && ((u = e.debug) != null && u.call(e))) {
21
- const v = Math.round((Date.now() - c) * 100) / 100, f = Math.round((Date.now() - m) * 100) / 100, y = f / 16, E = (p, w) => {
22
- for (p = String(p); p.length < w; )
23
- p = " " + p;
24
- return p;
14
+ e.key && ((l = e.debug) != null && l.call(e)) && (c = Date.now());
15
+ const d = o();
16
+ if (!(d.length !== t.length || d.some((S, f) => t[f] !== S)))
17
+ return s;
18
+ t = d;
19
+ let p;
20
+ if (e.key && ((a = e.debug) != null && a.call(e)) && (p = Date.now()), s = r(...d), e.key && ((u = e.debug) != null && u.call(e))) {
21
+ const S = Math.round((Date.now() - c) * 100) / 100, f = Math.round((Date.now() - p) * 100) / 100, b = f / 16, E = (g, O) => {
22
+ for (g = String(g); g.length < O; )
23
+ g = " " + g;
24
+ return g;
25
25
  };
26
26
  console.info(
27
- `%c⏱ ${E(f, 5)} /${E(v, 5)} ms`,
27
+ `%c⏱ ${E(f, 5)} /${E(S, 5)} ms`,
28
28
  `
29
29
  font-size: .6rem;
30
30
  font-weight: bold;
31
31
  color: hsl(${Math.max(
32
32
  0,
33
- Math.min(120 - 120 * y, 120)
33
+ Math.min(120 - 120 * b, 120)
34
34
  )}deg 100% 31%);`,
35
35
  e?.key
36
36
  );
37
37
  }
38
- return e?.onChange && !(o && e.skipInitialOnChange) && e.onChange(t), o = !1, t;
38
+ return e?.onChange && !(n && e.skipInitialOnChange) && e.onChange(s), n = !1, s;
39
39
  }
40
- return n.updateDeps = (i) => {
41
- s = i;
42
- }, n;
40
+ return i.updateDeps = (l) => {
41
+ t = l;
42
+ }, i;
43
43
  }
44
- function C(r, l) {
45
- if (r === void 0)
44
+ function I(o, r) {
45
+ if (o === void 0)
46
46
  throw new Error("Unexpected undefined");
47
- return r;
47
+ return o;
48
48
  }
49
- const j = (r, l) => Math.abs(r - l) < 1.01, P = (r, l, e) => {
50
- let s;
51
- return function(...t) {
52
- r.clearTimeout(s), s = r.setTimeout(() => l.apply(this, t), e);
49
+ const j = (o, r) => Math.abs(o - r) < 1.01, P = (o, r, e) => {
50
+ let t;
51
+ return function(...s) {
52
+ o.clearTimeout(t), t = o.setTimeout(() => r.apply(this, s), e);
53
53
  };
54
- }, I = (r) => {
55
- const { offsetWidth: l, offsetHeight: e } = r;
56
- return { width: l, height: e };
57
- }, B = (r) => r, H = (r) => {
58
- const l = Math.max(r.startIndex - r.overscan, 0), e = Math.min(r.endIndex + r.overscan, r.count - 1), s = [];
59
- for (let t = l; t <= e; t++)
60
- s.push(t);
61
- return s;
62
- }, $ = (r, l) => {
63
- const e = r.scrollElement;
54
+ }, z = (o) => {
55
+ const { offsetWidth: r, offsetHeight: e } = o;
56
+ return { width: r, height: e };
57
+ }, B = (o) => o, H = (o) => {
58
+ const r = Math.max(o.startIndex - o.overscan, 0), e = Math.min(o.endIndex + o.overscan, o.count - 1), t = [];
59
+ for (let s = r; s <= e; s++)
60
+ t.push(s);
61
+ return t;
62
+ }, $ = (o, r) => {
63
+ const e = o.scrollElement;
64
64
  if (!e)
65
65
  return;
66
- const s = r.targetWindow;
67
- if (!s)
66
+ const t = o.targetWindow;
67
+ if (!t)
68
68
  return;
69
- const t = (n) => {
70
- const { width: i, height: a } = n;
71
- l({ width: Math.round(i), height: Math.round(a) });
69
+ const s = (i) => {
70
+ const { width: l, height: a } = i;
71
+ r({ width: Math.round(l), height: Math.round(a) });
72
72
  };
73
- if (t(I(e)), !s.ResizeObserver)
73
+ if (s(z(e)), !t.ResizeObserver)
74
74
  return () => {
75
75
  };
76
- const o = new s.ResizeObserver((n) => {
77
- const i = () => {
78
- const a = n[0];
76
+ const n = new t.ResizeObserver((i) => {
77
+ const l = () => {
78
+ const a = i[0];
79
79
  if (a?.borderBoxSize) {
80
80
  const u = a.borderBoxSize[0];
81
81
  if (u) {
82
- t({ width: u.inlineSize, height: u.blockSize });
82
+ s({ width: u.inlineSize, height: u.blockSize });
83
83
  return;
84
84
  }
85
85
  }
86
- t(I(e));
86
+ s(z(e));
87
87
  };
88
- r.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(i) : i();
88
+ o.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
89
89
  });
90
- return o.observe(e, { box: "border-box" }), () => {
91
- o.unobserve(e);
90
+ return n.observe(e, { box: "border-box" }), () => {
91
+ n.unobserve(e);
92
92
  };
93
- }, A = {
93
+ }, _ = {
94
94
  passive: !0
95
- }, F = typeof window > "u" ? !0 : "onscrollend" in window, q = (r, l) => {
96
- const e = r.scrollElement;
95
+ }, A = typeof window > "u" ? !0 : "onscrollend" in window, q = (o, r) => {
96
+ const e = o.scrollElement;
97
97
  if (!e)
98
98
  return;
99
- const s = r.targetWindow;
100
- if (!s)
99
+ const t = o.targetWindow;
100
+ if (!t)
101
101
  return;
102
- let t = 0;
103
- const o = r.options.useScrollendEvent && F ? () => {
102
+ let s = 0;
103
+ const n = o.options.useScrollendEvent && A ? () => {
104
104
  } : P(
105
- s,
105
+ t,
106
106
  () => {
107
- l(t, !1);
107
+ r(s, !1);
108
108
  },
109
- r.options.isScrollingResetDelay
110
- ), n = (c) => () => {
111
- const { horizontal: d, isRtl: h } = r.options;
112
- t = d ? e.scrollLeft * (h && -1 || 1) : e.scrollTop, o(), l(t, c);
113
- }, i = n(!0), a = n(!1);
114
- e.addEventListener("scroll", i, A);
115
- const u = r.options.useScrollendEvent && F;
116
- return u && e.addEventListener("scrollend", a, A), () => {
117
- e.removeEventListener("scroll", i), u && e.removeEventListener("scrollend", a);
109
+ o.options.isScrollingResetDelay
110
+ ), i = (c) => () => {
111
+ const { horizontal: d, isRtl: h } = o.options;
112
+ s = d ? e.scrollLeft * (h && -1 || 1) : e.scrollTop, n(), r(s, c);
113
+ }, l = i(!0), a = i(!1);
114
+ e.addEventListener("scroll", l, _);
115
+ const u = o.options.useScrollendEvent && A;
116
+ return u && e.addEventListener("scrollend", a, _), () => {
117
+ e.removeEventListener("scroll", l), u && e.removeEventListener("scrollend", a);
118
118
  };
119
- }, U = (r, l, e) => {
120
- if (l?.borderBoxSize) {
121
- const s = l.borderBoxSize[0];
122
- if (s)
119
+ }, U = (o, r, e) => {
120
+ if (r?.borderBoxSize) {
121
+ const t = r.borderBoxSize[0];
122
+ if (t)
123
123
  return Math.round(
124
- s[e.options.horizontal ? "inlineSize" : "blockSize"]
124
+ t[e.options.horizontal ? "inlineSize" : "blockSize"]
125
125
  );
126
126
  }
127
- return r[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
128
- }, K = (r, {
129
- adjustments: l = 0,
127
+ return o[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
128
+ }, K = (o, {
129
+ adjustments: r = 0,
130
130
  behavior: e
131
- }, s) => {
132
- var t, o;
133
- const n = r + l;
134
- (o = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || o.call(t, {
135
- [s.options.horizontal ? "left" : "top"]: n,
131
+ }, t) => {
132
+ var s, n;
133
+ const i = o + r;
134
+ (n = (s = t.scrollElement) == null ? void 0 : s.scrollTo) == null || n.call(s, {
135
+ [t.options.horizontal ? "left" : "top"]: i,
136
136
  behavior: e
137
137
  });
138
138
  };
139
- class G {
140
- constructor(l) {
141
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.currentScrollToIndex = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
139
+ class X {
140
+ constructor(r) {
141
+ this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollState = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.now = () => {
142
+ var e, t, s;
143
+ return ((s = (t = (e = this.targetWindow) == null ? void 0 : e.performance) == null ? void 0 : t.now) == null ? void 0 : s.call(t)) ?? Date.now();
144
+ }, this.observer = /* @__PURE__ */ (() => {
142
145
  let e = null;
143
- const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
144
- t.forEach((o) => {
145
- const n = () => {
146
- this._measureElement(o.target, o);
146
+ const t = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((s) => {
147
+ s.forEach((n) => {
148
+ const i = () => {
149
+ this._measureElement(n.target, n);
147
150
  };
148
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(n) : n();
151
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(i) : i();
149
152
  });
150
153
  }));
151
154
  return {
152
155
  disconnect: () => {
153
- var t;
154
- (t = s()) == null || t.disconnect(), e = null;
156
+ var s;
157
+ (s = t()) == null || s.disconnect(), e = null;
155
158
  },
156
- observe: (t) => {
157
- var o;
158
- return (o = s()) == null ? void 0 : o.observe(t, { box: "border-box" });
159
+ observe: (s) => {
160
+ var n;
161
+ return (n = t()) == null ? void 0 : n.observe(s, { box: "border-box" });
159
162
  },
160
- unobserve: (t) => {
161
- var o;
162
- return (o = s()) == null ? void 0 : o.unobserve(t);
163
+ unobserve: (s) => {
164
+ var n;
165
+ return (n = t()) == null ? void 0 : n.unobserve(s);
163
166
  }
164
167
  };
165
168
  })(), this.range = null, this.setOptions = (e) => {
166
- Object.entries(e).forEach(([s, t]) => {
167
- typeof t > "u" && delete e[s];
169
+ Object.entries(e).forEach(([t, s]) => {
170
+ typeof s > "u" && delete e[t];
168
171
  }), this.options = {
169
172
  debug: !1,
170
173
  initialOffset: 0,
@@ -193,8 +196,8 @@ class G {
193
196
  ...e
194
197
  };
195
198
  }, this.notify = (e) => {
196
- var s, t;
197
- (t = (s = this.options).onChange) == null || t.call(s, this, e);
199
+ var t, s;
200
+ (s = (t = this.options).onChange) == null || s.call(t, this, e);
198
201
  }, this.maybeNotify = x(
199
202
  () => (this.calculateRange(), [
200
203
  this.isScrolling,
@@ -214,45 +217,45 @@ class G {
214
217
  ]
215
218
  }
216
219
  ), this.cleanup = () => {
217
- this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
220
+ this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.rafId != null && this.targetWindow && (this.targetWindow.cancelAnimationFrame(this.rafId), this.rafId = null), this.scrollState = null, this.scrollElement = null, this.targetWindow = null;
218
221
  }, this._didMount = () => () => {
219
222
  this.cleanup();
220
223
  }, this._willUpdate = () => {
221
224
  var e;
222
- const s = this.options.enabled ? this.options.getScrollElement() : null;
223
- if (this.scrollElement !== s) {
224
- if (this.cleanup(), !s) {
225
+ const t = this.options.enabled ? this.options.getScrollElement() : null;
226
+ if (this.scrollElement !== t) {
227
+ if (this.cleanup(), !t) {
225
228
  this.maybeNotify();
226
229
  return;
227
230
  }
228
- this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((t) => {
229
- this.observer.observe(t);
231
+ this.scrollElement = t, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((s) => {
232
+ this.observer.observe(s);
230
233
  }), this.unsubs.push(
231
- this.options.observeElementRect(this, (t) => {
232
- this.scrollRect = t, this.maybeNotify();
234
+ this.options.observeElementRect(this, (s) => {
235
+ this.scrollRect = s, this.maybeNotify();
233
236
  })
234
237
  ), this.unsubs.push(
235
- this.options.observeElementOffset(this, (t, o) => {
236
- this.scrollAdjustments = 0, this.scrollDirection = o ? this.getScrollOffset() < t ? "forward" : "backward" : null, this.scrollOffset = t, this.isScrolling = o, this.maybeNotify();
238
+ this.options.observeElementOffset(this, (s, n) => {
239
+ this.scrollAdjustments = 0, this.scrollDirection = n ? this.getScrollOffset() < s ? "forward" : "backward" : null, this.scrollOffset = s, this.isScrolling = n, this.scrollState && this.scheduleScrollReconcile(), this.maybeNotify();
237
240
  })
238
241
  ), this._scrollToOffset(this.getScrollOffset(), {
239
242
  adjustments: void 0,
240
243
  behavior: void 0
241
244
  });
242
245
  }
243
- }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, s) => {
244
- const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
245
- for (let n = s - 1; n >= 0; n--) {
246
- const i = e[n];
247
- if (t.has(i.lane))
246
+ }, this.rafId = null, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, t) => {
247
+ const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
248
+ for (let i = t - 1; i >= 0; i--) {
249
+ const l = e[i];
250
+ if (s.has(l.lane))
248
251
  continue;
249
- const a = o.get(
250
- i.lane
252
+ const a = n.get(
253
+ l.lane
251
254
  );
252
- if (a == null || i.end > a.end ? o.set(i.lane, i) : i.end < a.end && t.set(i.lane, !0), t.size === this.options.lanes)
255
+ if (a == null || l.end > a.end ? n.set(l.lane, l) : l.end < a.end && s.set(l.lane, !0), s.size === this.options.lanes)
253
256
  break;
254
257
  }
255
- return o.size === this.options.lanes ? Array.from(o.values()).sort((n, i) => n.end === i.end ? n.index - i.index : n.end - i.end)[0] : void 0;
258
+ return n.size === this.options.lanes ? Array.from(n.values()).sort((i, l) => i.end === l.end ? i.index - l.index : i.end - l.end)[0] : void 0;
256
259
  }, this.getMeasurementOptions = x(
257
260
  () => [
258
261
  this.options.count,
@@ -262,21 +265,21 @@ class G {
262
265
  this.options.enabled,
263
266
  this.options.lanes
264
267
  ],
265
- (e, s, t, o, n, i) => (this.prevLanes !== void 0 && this.prevLanes !== i && (this.lanesChangedFlag = !0), this.prevLanes = i, this.pendingMeasuredCacheIndexes = [], {
268
+ (e, t, s, n, i, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
266
269
  count: e,
267
- paddingStart: s,
268
- scrollMargin: t,
269
- getItemKey: o,
270
- enabled: n,
271
- lanes: i
270
+ paddingStart: t,
271
+ scrollMargin: s,
272
+ getItemKey: n,
273
+ enabled: i,
274
+ lanes: l
272
275
  }),
273
276
  {
274
277
  key: !1
275
278
  }
276
279
  ), this.getMeasurements = x(
277
280
  () => [this.getMeasurementOptions(), this.itemSizeCache],
278
- ({ count: e, paddingStart: s, scrollMargin: t, getItemKey: o, enabled: n, lanes: i }, a) => {
279
- if (!n)
281
+ ({ count: e, paddingStart: t, scrollMargin: s, getItemKey: n, enabled: i, lanes: l }, a) => {
282
+ if (!i)
280
283
  return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
281
284
  if (this.laneAssignments.size > e)
282
285
  for (const h of this.laneAssignments.keys())
@@ -286,31 +289,31 @@ class G {
286
289
  }));
287
290
  const u = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
288
291
  this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
289
- const c = this.measurementsCache.slice(0, u), d = new Array(i).fill(
292
+ const c = this.measurementsCache.slice(0, u), d = new Array(l).fill(
290
293
  void 0
291
294
  );
292
295
  for (let h = 0; h < u; h++) {
293
- const m = c[h];
294
- m && (d[m.lane] = h);
296
+ const p = c[h];
297
+ p && (d[p.lane] = h);
295
298
  }
296
299
  for (let h = u; h < e; h++) {
297
- const m = o(h), v = this.laneAssignments.get(h);
298
- let f, y;
299
- if (v !== void 0 && this.options.lanes > 1) {
300
- f = v;
301
- const b = d[f], M = b !== void 0 ? c[b] : void 0;
302
- y = M ? M.end + this.options.gap : s + t;
300
+ const p = n(h), S = this.laneAssignments.get(h);
301
+ let f, b;
302
+ if (S !== void 0 && this.options.lanes > 1) {
303
+ f = S;
304
+ const v = d[f], M = v !== void 0 ? c[v] : void 0;
305
+ b = M ? M.end + this.options.gap : t + s;
303
306
  } else {
304
- const b = this.options.lanes === 1 ? c[h - 1] : this.getFurthestMeasurement(c, h);
305
- y = b ? b.end + this.options.gap : s + t, f = b ? b.lane : h % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(h, f);
307
+ const v = this.options.lanes === 1 ? c[h - 1] : this.getFurthestMeasurement(c, h);
308
+ b = v ? v.end + this.options.gap : t + s, f = v ? v.lane : h % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(h, f);
306
309
  }
307
- const E = a.get(m), p = typeof E == "number" ? E : this.options.estimateSize(h), w = y + p;
310
+ const E = a.get(p), g = typeof E == "number" ? E : this.options.estimateSize(h), O = b + g;
308
311
  c[h] = {
309
312
  index: h,
310
- start: y,
311
- size: p,
312
- end: w,
313
- key: m,
313
+ start: b,
314
+ size: g,
315
+ end: O,
316
+ key: p,
314
317
  lane: f
315
318
  }, d[f] = h;
316
319
  }
@@ -327,11 +330,11 @@ class G {
327
330
  this.getScrollOffset(),
328
331
  this.options.lanes
329
332
  ],
330
- (e, s, t, o) => this.range = e.length > 0 && s > 0 ? J({
333
+ (e, t, s, n) => this.range = e.length > 0 && t > 0 ? G({
331
334
  measurements: e,
332
- outerSize: s,
333
- scrollOffset: t,
334
- lanes: o
335
+ outerSize: t,
336
+ scrollOffset: s,
337
+ lanes: n
335
338
  }) : null,
336
339
  {
337
340
  key: process.env.NODE_ENV !== "production" && "calculateRange",
@@ -339,76 +342,97 @@ class G {
339
342
  }
340
343
  ), this.getVirtualIndexes = x(
341
344
  () => {
342
- let e = null, s = null;
343
- const t = this.calculateRange();
344
- return t && (e = t.startIndex, s = t.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
345
+ let e = null, t = null;
346
+ const s = this.calculateRange();
347
+ return s && (e = s.startIndex, t = s.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, t]), [
345
348
  this.options.rangeExtractor,
346
349
  this.options.overscan,
347
350
  this.options.count,
348
351
  e,
349
- s
352
+ t
350
353
  ];
351
354
  },
352
- (e, s, t, o, n) => o === null || n === null ? [] : e({
353
- startIndex: o,
354
- endIndex: n,
355
- overscan: s,
356
- count: t
355
+ (e, t, s, n, i) => n === null || i === null ? [] : e({
356
+ startIndex: n,
357
+ endIndex: i,
358
+ overscan: t,
359
+ count: s
357
360
  }),
358
361
  {
359
362
  key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
360
363
  debug: () => this.options.debug
361
364
  }
362
365
  ), this.indexFromElement = (e) => {
363
- const s = this.options.indexAttribute, t = e.getAttribute(s);
364
- return t ? parseInt(t, 10) : (console.warn(
365
- `Missing attribute name '${s}={index}' on measured element.`
366
+ const t = this.options.indexAttribute, s = e.getAttribute(t);
367
+ return s ? parseInt(s, 10) : (console.warn(
368
+ `Missing attribute name '${t}={index}' on measured element.`
366
369
  ), -1);
367
- }, this._measureElement = (e, s) => {
368
- const t = this.indexFromElement(e), o = this.measurementsCache[t];
369
- if (!o)
370
+ }, this.shouldMeasureDuringScroll = (e) => {
371
+ var t;
372
+ if (!this.scrollState || this.scrollState.behavior !== "smooth")
373
+ return !0;
374
+ const s = this.scrollState.index ?? ((t = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : t.index);
375
+ if (s !== void 0 && this.range) {
376
+ const n = Math.max(
377
+ this.options.overscan,
378
+ Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
379
+ ), i = Math.max(0, s - n), l = Math.min(
380
+ this.options.count - 1,
381
+ s + n
382
+ );
383
+ return e >= i && e <= l;
384
+ }
385
+ return !0;
386
+ }, this._measureElement = (e, t) => {
387
+ if (!e.isConnected) {
388
+ this.observer.unobserve(e);
389
+ return;
390
+ }
391
+ const s = this.indexFromElement(e), n = this.measurementsCache[s];
392
+ if (!n)
370
393
  return;
371
- const n = o.key, i = this.elementsCache.get(n);
372
- i !== e && (i && this.observer.unobserve(i), this.observer.observe(e), this.elementsCache.set(n, e)), e.isConnected && this.resizeItem(t, this.options.measureElement(e, s, this));
373
- }, this.resizeItem = (e, s) => {
374
- const t = this.measurementsCache[e];
375
- if (!t)
394
+ const i = n.key, l = this.elementsCache.get(i);
395
+ l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(i, e)), this.shouldMeasureDuringScroll(s) && this.resizeItem(s, this.options.measureElement(e, t, this));
396
+ }, this.resizeItem = (e, t) => {
397
+ var s;
398
+ const n = this.measurementsCache[e];
399
+ if (!n)
376
400
  return;
377
- const o = this.itemSizeCache.get(t.key) ?? t.size, n = s - o;
378
- n !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(t, n, this) : t.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", n), this._scrollToOffset(this.getScrollOffset(), {
379
- adjustments: this.scrollAdjustments += n,
401
+ const i = this.itemSizeCache.get(n.key) ?? n.size, l = t - i;
402
+ l !== 0 && (((s = this.scrollState) == null ? void 0 : s.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(n, l, this) : n.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", l), this._scrollToOffset(this.getScrollOffset(), {
403
+ adjustments: this.scrollAdjustments += l,
380
404
  behavior: void 0
381
- })), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
405
+ })), this.pendingMeasuredCacheIndexes.push(n.index), this.itemSizeCache = new Map(this.itemSizeCache.set(n.key, t)), this.notify(!1));
382
406
  }, this.measureElement = (e) => {
383
407
  if (!e) {
384
- this.elementsCache.forEach((s, t) => {
385
- s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
408
+ this.elementsCache.forEach((t, s) => {
409
+ t.isConnected || (this.observer.unobserve(t), this.elementsCache.delete(s));
386
410
  });
387
411
  return;
388
412
  }
389
413
  this._measureElement(e, void 0);
390
414
  }, this.getVirtualItems = x(
391
415
  () => [this.getVirtualIndexes(), this.getMeasurements()],
392
- (e, s) => {
393
- const t = [];
394
- for (let o = 0, n = e.length; o < n; o++) {
395
- const i = e[o], a = s[i];
396
- t.push(a);
416
+ (e, t) => {
417
+ const s = [];
418
+ for (let n = 0, i = e.length; n < i; n++) {
419
+ const l = e[n], a = t[l];
420
+ s.push(a);
397
421
  }
398
- return t;
422
+ return s;
399
423
  },
400
424
  {
401
425
  key: process.env.NODE_ENV !== "production" && "getVirtualItems",
402
426
  debug: () => this.options.debug
403
427
  }
404
428
  ), this.getVirtualItemForOffset = (e) => {
405
- const s = this.getMeasurements();
406
- if (s.length !== 0)
407
- return C(
408
- s[_(
429
+ const t = this.getMeasurements();
430
+ if (t.length !== 0)
431
+ return I(
432
+ t[F(
409
433
  0,
410
- s.length - 1,
411
- (t) => C(s[t]).start,
434
+ t.length - 1,
435
+ (s) => I(t[s]).start,
412
436
  e
413
437
  )]
414
438
  );
@@ -420,219 +444,236 @@ class G {
420
444
  const e = this.scrollElement.document.documentElement;
421
445
  return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
422
446
  }
423
- }, this.getOffsetForAlignment = (e, s, t = 0) => {
447
+ }, this.getOffsetForAlignment = (e, t, s = 0) => {
424
448
  if (!this.scrollElement) return 0;
425
- const o = this.getSize(), n = this.getScrollOffset();
426
- s === "auto" && (s = e >= n + o ? "end" : "start"), s === "center" ? e += (t - o) / 2 : s === "end" && (e -= o);
427
- const i = this.getMaxScrollOffset();
428
- return Math.max(Math.min(i, e), 0);
429
- }, this.getOffsetForIndex = (e, s = "auto") => {
449
+ const n = this.getSize(), i = this.getScrollOffset();
450
+ t === "auto" && (t = e >= i + n ? "end" : "start"), t === "center" ? e += (s - n) / 2 : t === "end" && (e -= n);
451
+ const l = this.getMaxScrollOffset();
452
+ return Math.max(Math.min(l, e), 0);
453
+ }, this.getOffsetForIndex = (e, t = "auto") => {
430
454
  e = Math.max(0, Math.min(e, this.options.count - 1));
431
- const t = this.measurementsCache[e];
432
- if (!t)
433
- return;
434
- const o = this.getSize(), n = this.getScrollOffset();
435
- if (s === "auto")
436
- if (t.end >= n + o - this.options.scrollPaddingEnd)
437
- s = "end";
438
- else if (t.start <= n + this.options.scrollPaddingStart)
439
- s = "start";
455
+ const s = this.getSize(), n = this.getScrollOffset(), i = this.measurementsCache[e];
456
+ if (!i) return;
457
+ if (t === "auto")
458
+ if (i.end >= n + s - this.options.scrollPaddingEnd)
459
+ t = "end";
460
+ else if (i.start <= n + this.options.scrollPaddingStart)
461
+ t = "start";
440
462
  else
441
- return [n, s];
442
- if (s === "end" && e === this.options.count - 1)
443
- return [this.getMaxScrollOffset(), s];
444
- const i = s === "end" ? t.end + this.options.scrollPaddingEnd : t.start - this.options.scrollPaddingStart;
463
+ return [n, t];
464
+ if (t === "end" && e === this.options.count - 1)
465
+ return [this.getMaxScrollOffset(), t];
466
+ const l = t === "end" ? i.end + this.options.scrollPaddingEnd : i.start - this.options.scrollPaddingStart;
445
467
  return [
446
- this.getOffsetForAlignment(i, s, t.size),
447
- s
468
+ this.getOffsetForAlignment(l, t, i.size),
469
+ t
448
470
  ];
449
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
450
- t === "smooth" && this.isDynamicMode() && console.warn(
451
- "The `smooth` scroll behavior is not fully supported with dynamic size."
452
- ), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
453
- adjustments: void 0,
454
- behavior: t
455
- });
456
- }, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
457
- t === "smooth" && this.isDynamicMode() && console.warn(
458
- "The `smooth` scroll behavior is not fully supported with dynamic size."
459
- ), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
460
- let o = 0;
461
- const n = 10, i = (u) => {
462
- if (!this.targetWindow) return;
463
- const c = this.getOffsetForIndex(e, u);
464
- if (!c) {
465
- console.warn("Failed to get offset for index:", e);
466
- return;
467
- }
468
- const [d, h] = c;
469
- this._scrollToOffset(d, { adjustments: void 0, behavior: t }), this.targetWindow.requestAnimationFrame(() => {
470
- if (!this.targetWindow) return;
471
- const m = () => {
472
- if (this.currentScrollToIndex !== e) return;
473
- const v = this.getScrollOffset(), f = this.getOffsetForIndex(e, h);
474
- if (!f) {
475
- console.warn("Failed to get offset for index:", e);
476
- return;
477
- }
478
- j(f[0], v) || a(h);
479
- };
480
- this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(m) : m();
481
- });
482
- }, a = (u) => {
483
- this.targetWindow && this.currentScrollToIndex === e && (o++, o < n ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", o, n), this.targetWindow.requestAnimationFrame(() => i(u))) : console.warn(
484
- `Failed to scroll to index ${e} after ${n} attempts.`
485
- ));
486
- };
487
- i(s);
488
- }, this.scrollBy = (e, { behavior: s } = {}) => {
489
- s === "smooth" && this.isDynamicMode() && console.warn(
490
- "The `smooth` scroll behavior is not fully supported with dynamic size."
491
- ), this._scrollToOffset(this.getScrollOffset() + e, {
492
- adjustments: void 0,
493
- behavior: s
494
- });
471
+ }, this.scrollToOffset = (e, { align: t = "start", behavior: s = "auto" } = {}) => {
472
+ const n = this.getOffsetForAlignment(e, t), i = this.now();
473
+ this.scrollState = {
474
+ index: null,
475
+ align: t,
476
+ behavior: s,
477
+ startedAt: i,
478
+ lastTargetOffset: n,
479
+ stableFrames: 0
480
+ }, this._scrollToOffset(n, { adjustments: void 0, behavior: s }), this.scheduleScrollReconcile();
481
+ }, this.scrollToIndex = (e, {
482
+ align: t = "auto",
483
+ behavior: s = "auto"
484
+ } = {}) => {
485
+ e = Math.max(0, Math.min(e, this.options.count - 1));
486
+ const n = this.getOffsetForIndex(e, t);
487
+ if (!n)
488
+ return;
489
+ const [i, l] = n, a = this.now();
490
+ this.scrollState = {
491
+ index: e,
492
+ align: l,
493
+ behavior: s,
494
+ startedAt: a,
495
+ lastTargetOffset: i,
496
+ stableFrames: 0
497
+ }, this._scrollToOffset(i, { adjustments: void 0, behavior: s }), this.scheduleScrollReconcile();
498
+ }, this.scrollBy = (e, { behavior: t = "auto" } = {}) => {
499
+ const s = this.getScrollOffset() + e, n = this.now();
500
+ this.scrollState = {
501
+ index: null,
502
+ align: "start",
503
+ behavior: t,
504
+ startedAt: n,
505
+ lastTargetOffset: s,
506
+ stableFrames: 0
507
+ }, this._scrollToOffset(s, { adjustments: void 0, behavior: t }), this.scheduleScrollReconcile();
495
508
  }, this.getTotalSize = () => {
496
509
  var e;
497
- const s = this.getMeasurements();
498
- let t;
499
- if (s.length === 0)
500
- t = this.options.paddingStart;
510
+ const t = this.getMeasurements();
511
+ let s;
512
+ if (t.length === 0)
513
+ s = this.options.paddingStart;
501
514
  else if (this.options.lanes === 1)
502
- t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
515
+ s = ((e = t[t.length - 1]) == null ? void 0 : e.end) ?? 0;
503
516
  else {
504
- const o = Array(this.options.lanes).fill(null);
505
- let n = s.length - 1;
506
- for (; n >= 0 && o.some((i) => i === null); ) {
507
- const i = s[n];
508
- o[i.lane] === null && (o[i.lane] = i.end), n--;
517
+ const n = Array(this.options.lanes).fill(null);
518
+ let i = t.length - 1;
519
+ for (; i >= 0 && n.some((l) => l === null); ) {
520
+ const l = t[i];
521
+ n[l.lane] === null && (n[l.lane] = l.end), i--;
509
522
  }
510
- t = Math.max(...o.filter((i) => i !== null));
523
+ s = Math.max(...n.filter((l) => l !== null));
511
524
  }
512
525
  return Math.max(
513
- t - this.options.scrollMargin + this.options.paddingEnd,
526
+ s - this.options.scrollMargin + this.options.paddingEnd,
514
527
  0
515
528
  );
516
529
  }, this._scrollToOffset = (e, {
517
- adjustments: s,
518
- behavior: t
530
+ adjustments: t,
531
+ behavior: s
519
532
  }) => {
520
- this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
533
+ this.options.scrollToFn(e, { behavior: s, adjustments: t }, this);
521
534
  }, this.measure = () => {
522
535
  this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
523
- }, this.setOptions(l);
536
+ }, this.setOptions(r);
537
+ }
538
+ scheduleScrollReconcile() {
539
+ if (!this.targetWindow) {
540
+ this.scrollState = null;
541
+ return;
542
+ }
543
+ this.rafId == null && (this.rafId = this.targetWindow.requestAnimationFrame(() => {
544
+ this.rafId = null, this.reconcileScroll();
545
+ }));
546
+ }
547
+ reconcileScroll() {
548
+ if (!this.scrollState || !this.scrollElement) return;
549
+ if (this.now() - this.scrollState.startedAt > 5e3) {
550
+ this.scrollState = null;
551
+ return;
552
+ }
553
+ const t = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0, s = t ? t[0] : this.scrollState.lastTargetOffset, n = 1, i = s !== this.scrollState.lastTargetOffset;
554
+ if (!i && j(s, this.getScrollOffset())) {
555
+ if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= n) {
556
+ this.scrollState = null;
557
+ return;
558
+ }
559
+ } else
560
+ this.scrollState.stableFrames = 0, i && (this.scrollState.lastTargetOffset = s, this.scrollState.behavior = "auto", this._scrollToOffset(s, {
561
+ adjustments: void 0,
562
+ behavior: "auto"
563
+ }));
564
+ this.scheduleScrollReconcile();
524
565
  }
525
566
  }
526
- const _ = (r, l, e, s) => {
527
- for (; r <= l; ) {
528
- const t = (r + l) / 2 | 0, o = e(t);
529
- if (o < s)
530
- r = t + 1;
531
- else if (o > s)
532
- l = t - 1;
567
+ const F = (o, r, e, t) => {
568
+ for (; o <= r; ) {
569
+ const s = (o + r) / 2 | 0, n = e(s);
570
+ if (n < t)
571
+ o = s + 1;
572
+ else if (n > t)
573
+ r = s - 1;
533
574
  else
534
- return t;
575
+ return s;
535
576
  }
536
- return r > 0 ? r - 1 : 0;
577
+ return o > 0 ? o - 1 : 0;
537
578
  };
538
- function J({
539
- measurements: r,
540
- outerSize: l,
579
+ function G({
580
+ measurements: o,
581
+ outerSize: r,
541
582
  scrollOffset: e,
542
- lanes: s
583
+ lanes: t
543
584
  }) {
544
- const t = r.length - 1, o = (a) => r[a].start;
545
- if (r.length <= s)
585
+ const s = o.length - 1, n = (a) => o[a].start;
586
+ if (o.length <= t)
546
587
  return {
547
588
  startIndex: 0,
548
- endIndex: t
589
+ endIndex: s
549
590
  };
550
- let n = _(
591
+ let i = F(
551
592
  0,
552
- t,
553
- o,
593
+ s,
594
+ n,
554
595
  e
555
- ), i = n;
556
- if (s === 1)
557
- for (; i < t && r[i].end < e + l; )
558
- i++;
559
- else if (s > 1) {
560
- const a = Array(s).fill(0);
561
- for (; i < t && a.some((c) => c < e + l); ) {
562
- const c = r[i];
563
- a[c.lane] = c.end, i++;
596
+ ), l = i;
597
+ if (t === 1)
598
+ for (; l < s && o[l].end < e + r; )
599
+ l++;
600
+ else if (t > 1) {
601
+ const a = Array(t).fill(0);
602
+ for (; l < s && a.some((c) => c < e + r); ) {
603
+ const c = o[l];
604
+ a[c.lane] = c.end, l++;
564
605
  }
565
- const u = Array(s).fill(e + l);
566
- for (; n >= 0 && u.some((c) => c >= e); ) {
567
- const c = r[n];
568
- u[c.lane] = c.start, n--;
606
+ const u = Array(t).fill(e + r);
607
+ for (; i >= 0 && u.some((c) => c >= e); ) {
608
+ const c = o[i];
609
+ u[c.lane] = c.start, i--;
569
610
  }
570
- n = Math.max(0, n - n % s), i = Math.min(t, i + (s - 1 - i % s));
611
+ i = Math.max(0, i - i % t), l = Math.min(s, l + (t - 1 - l % t));
571
612
  }
572
- return { startIndex: n, endIndex: i };
613
+ return { startIndex: i, endIndex: l };
573
614
  }
574
- const N = typeof document < "u" ? S.useLayoutEffect : S.useEffect;
575
- function Q({
576
- useFlushSync: r = !0,
577
- ...l
615
+ const R = typeof document < "u" ? w.useLayoutEffect : w.useEffect;
616
+ function J({
617
+ useFlushSync: o = !0,
618
+ ...r
578
619
  }) {
579
- const e = S.useReducer(() => ({}), {})[1], s = {
580
- ...l,
581
- onChange: (o, n) => {
582
- var i;
583
- r && n ? W(e) : e(), (i = l.onChange) == null || i.call(l, o, n);
620
+ const e = w.useReducer(() => ({}), {})[1], t = {
621
+ ...r,
622
+ onChange: (n, i) => {
623
+ var l;
624
+ o && i ? D(e) : e(), (l = r.onChange) == null || l.call(r, n, i);
584
625
  }
585
- }, [t] = S.useState(
586
- () => new G(s)
626
+ }, [s] = w.useState(
627
+ () => new X(t)
587
628
  );
588
- return t.setOptions(s), N(() => t._didMount(), []), N(() => t._willUpdate()), t;
629
+ return s.setOptions(t), R(() => s._didMount(), []), R(() => s._willUpdate()), s;
589
630
  }
590
- function X(r) {
591
- return Q({
631
+ function Q(o) {
632
+ return J({
592
633
  observeElementRect: $,
593
634
  observeElementOffset: q,
594
635
  scrollToFn: K,
595
- ...r
636
+ ...o
596
637
  });
597
638
  }
598
- const oe = ({
599
- showFlagOnSearch: r,
600
- showNameOnSearch: l
639
+ const le = ({
640
+ showFlagOnSearch: o,
641
+ showNameOnSearch: r
601
642
  }) => {
602
- const e = T(null), { termOfSearch: s, countries: t, handleSelectCountry: o } = V(), n = k(() => t.filter(
603
- (a) => a.name.toLocaleLowerCase().includes(s.toLowerCase())
604
- ), [s]), i = X({
605
- count: n.length,
643
+ const e = T(null), { termOfSearch: t, countries: s, handleSelectCountry: n } = V(), i = k(() => s.filter(
644
+ (a) => a.name.toLocaleLowerCase().includes(t.toLowerCase())
645
+ ), [t]), l = Q({
646
+ count: i.length,
606
647
  overscan: 5,
607
648
  getScrollElement: () => e.current,
608
649
  estimateSize: () => 40
609
650
  });
610
- return D(() => {
611
- n.length > 0 && i.scrollToIndex(0);
612
- }, [s, i]), n.length === 0 ? /* @__PURE__ */ g("div", { className: "overflow-y-auto max-h-60 snap-y snap-mandatory", children: /* @__PURE__ */ g("ul", { className: "relative", children: /* @__PURE__ */ g("li", { className: "w-full flex items-center h-10 select-none px-6", children: /* @__PURE__ */ g(
613
- O,
651
+ return L(() => {
652
+ i.length > 0 && l.scrollToIndex(0);
653
+ }, [t, l]), i.length === 0 ? /* @__PURE__ */ m("div", { className: "overflow-y-auto max-h-60 snap-y snap-mandatory", children: /* @__PURE__ */ m("ul", { className: "relative", children: /* @__PURE__ */ m("li", { className: "w-full flex items-center h-10 select-none px-6", children: /* @__PURE__ */ m(
654
+ y,
614
655
  {
615
656
  variant: "body2",
616
657
  component: "span",
617
658
  className: "flex gap-2 items-center text-left",
618
659
  children: "No options"
619
660
  }
620
- ) }) }) }) : /* @__PURE__ */ g(
661
+ ) }) }) }) : /* @__PURE__ */ m(
621
662
  "div",
622
663
  {
623
664
  ref: e,
624
665
  className: "overflow-y-auto max-h-60 snap-y snap-mandatory scrollbar",
625
- children: /* @__PURE__ */ g(
666
+ children: /* @__PURE__ */ m(
626
667
  "ul",
627
668
  {
628
669
  className: "relative",
629
- style: { height: i.getTotalSize() },
630
- children: i.getVirtualItems().map((a) => {
631
- const u = n[a.index], { flag: c, name: d, prefix: h } = u;
632
- return /* @__PURE__ */ g(
670
+ style: { height: l.getTotalSize() },
671
+ children: l.getVirtualItems().map((a) => {
672
+ const u = i[a.index], { flag: c, name: d, prefix: h } = u;
673
+ return /* @__PURE__ */ m(
633
674
  "li",
634
675
  {
635
- className: z(
676
+ className: C(
636
677
  "absolute",
637
678
  "w-full",
638
679
  "snap-start",
@@ -646,10 +687,10 @@ const oe = ({
646
687
  top: a.start,
647
688
  height: a.size
648
689
  },
649
- children: /* @__PURE__ */ g(
690
+ children: /* @__PURE__ */ m(
650
691
  "button",
651
692
  {
652
- className: z(
693
+ className: C(
653
694
  "w-full",
654
695
  "h-full",
655
696
  "cursor-pointer",
@@ -662,16 +703,16 @@ const oe = ({
662
703
  "focus:bg-gray-50",
663
704
  "dark:hover:bg-metal-700"
664
705
  ),
665
- onClick: () => o(u),
666
- children: /* @__PURE__ */ R(
667
- O,
706
+ onClick: () => n(u),
707
+ children: /* @__PURE__ */ N(
708
+ y,
668
709
  {
669
710
  variant: "body2",
670
711
  component: "span",
671
712
  className: "flex gap-2 items-center text-left",
672
713
  children: [
673
- r && /* @__PURE__ */ g(c, {}),
674
- l && /* @__PURE__ */ g(L, { text: d, prefix: h })
714
+ o && /* @__PURE__ */ m(c, {}),
715
+ r && /* @__PURE__ */ m(W, { text: d, prefix: h })
675
716
  ]
676
717
  }
677
718
  )
@@ -687,5 +728,5 @@ const oe = ({
687
728
  );
688
729
  };
689
730
  export {
690
- oe as FlagSelectorList
731
+ le as FlagSelectorList
691
732
  };