@altinn/altinn-components 0.56.31 → 0.56.33

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.
@@ -0,0 +1,3487 @@
1
+ "use client";
2
+ import * as p from "react";
3
+ import ce, { forwardRef as A, useState as ye, useRef as ve, useEffect as ue, createContext as De, useContext as oe, useMemo as ze, useLayoutEffect as jn, useReducer as Vr, useId as Ve, isValidElement as $n, memo as Br, useCallback as jr, Children as fn, version as $r } from "react";
4
+ import { jsx as v, jsxs as ie, Fragment as Ut } from "react/jsx-runtime";
5
+ import { c as X } from "./lite-1fxw3LjI.js";
6
+ import { S as se, a as Kr } from "./index-D7FJjvrv.js";
7
+ import * as Kn from "react-dom";
8
+ import { flushSync as Wn } from "react-dom";
9
+ import { S as Wr, B as Ye, u as qr } from "./button-BB5sYVKY.js";
10
+ import { V as Xt, u as Gt, F as pt, a as Hr, b as Ur, c as hn } from "./index-z82sbSVU.js";
11
+ import { P as jt } from "./paragraph-BRiIBpbY.js";
12
+ import { I as ot } from "./input-wBv_FkEV.js";
13
+ import { L as Te } from "./label-xTmTyPhk.js";
14
+ import { f as qn, b as Xr, o as Hn, c as Un, g as Mt, a as Xn, s as Gr } from "./floating-ui.dom-bEgaHJCq.js";
15
+ import { u as Be } from "./use-merge-refs-Cj4kTYVj.js";
16
+ import { T as Yr } from "./textarea-BBstVlPT.js";
17
+ const qe = (e, r) => {
18
+ const t = {}, n = {};
19
+ let o = 0;
20
+ const i = e.length;
21
+ for (; o < i; )
22
+ n[e[o]] = 1, o += 1;
23
+ for (const s in r)
24
+ Object.hasOwn(n, s) || (t[s] = r[s]);
25
+ return t;
26
+ }, Gn = De({
27
+ elements: { current: /* @__PURE__ */ new Map() },
28
+ getOrderedItems: () => [],
29
+ setFocusableValue: () => {
30
+ },
31
+ onShiftTab: () => {
32
+ },
33
+ focusableValue: null,
34
+ orientation: "horizontal"
35
+ }), Zr = A(({ activeValue: e, asChild: r, orientation: t = "horizontal", onBlur: n, onFocus: o, ...i }, s) => {
36
+ const a = r ? se : "div", l = e ?? null, [c, f] = ye(l), [d, h] = ye(!1), u = ve(/* @__PURE__ */ new Map()), m = ve(null), g = Be([s, m]), C = () => {
37
+ if (!m.current)
38
+ return [];
39
+ const x = Array.from(m.current.querySelectorAll("[data-roving-tabindex-item]"));
40
+ return Array.from(u.current).sort((y, b) => x.indexOf(y[1]) - x.indexOf(b[1])).map(([y, b]) => ({ value: y, element: b }));
41
+ };
42
+ return ue(() => {
43
+ f(l);
44
+ }, [l]), v(Gn.Provider, { value: {
45
+ elements: u,
46
+ getOrderedItems: C,
47
+ focusableValue: c,
48
+ setFocusableValue: f,
49
+ onShiftTab: () => {
50
+ h(!0);
51
+ },
52
+ orientation: t
53
+ }, children: v(a, { ...i, tabIndex: d ? -1 : 0, onBlur: (x) => {
54
+ n?.(x), h(!1), f(e ?? null);
55
+ }, onFocus: (x) => {
56
+ if (o?.(x), x.target !== x.currentTarget)
57
+ return;
58
+ const y = C();
59
+ y.length !== 0 && (c != null ? u.current.get(c)?.focus() : e != null ? u.current.get(e)?.focus() : y.at(0)?.element.focus());
60
+ }, ref: g }) });
61
+ }), Jr = (e) => {
62
+ const { elements: r, getOrderedItems: t, setFocusableValue: n, focusableValue: o, onShiftTab: i, orientation: s } = oe(Gn);
63
+ return {
64
+ getOrderedItems: t,
65
+ isFocusable: o === e,
66
+ orientation: s,
67
+ getRovingProps: (a) => ({
68
+ ...a,
69
+ ref: (l) => {
70
+ l ? r.current.set(e, l) : r.current.delete(e);
71
+ },
72
+ onKeyDown: (l) => {
73
+ if (a?.onKeyDown?.(l), l.shiftKey && l.key === "Tab") {
74
+ i();
75
+ return;
76
+ }
77
+ },
78
+ onFocus: (l) => {
79
+ a?.onFocus?.(l), n(e);
80
+ },
81
+ "data-roving-tabindex-item": !0,
82
+ tabIndex: o === e ? 0 : -1
83
+ })
84
+ };
85
+ };
86
+ function Nt(e, r) {
87
+ const t = e.findIndex((n) => n.value === r);
88
+ return e.at(t === e.length - 1 ? 0 : t + 1);
89
+ }
90
+ function Pt(e, r) {
91
+ const t = e.findIndex((n) => n.value === r);
92
+ return e.at(t === 0 ? -1 : t - 1);
93
+ }
94
+ const Qr = A(({ value: e, asChild: r, ...t }, n) => {
95
+ const o = r ? se : "div", i = e ?? (typeof t.children == "string" ? t.children : ""), { getOrderedItems: s, getRovingProps: a, orientation: l } = Jr(i), c = a({
96
+ onKeyDown: (d) => {
97
+ t?.onKeyDown?.(d);
98
+ const h = s();
99
+ let u;
100
+ switch (l) {
101
+ case "horizontal":
102
+ d.key === "ArrowRight" && (u = Nt(h, i)), d.key === "ArrowLeft" && (u = Pt(h, i));
103
+ break;
104
+ case "vertical":
105
+ d.key === "ArrowDown" && (u = Nt(h, i)), d.key === "ArrowUp" && (u = Pt(h, i));
106
+ break;
107
+ case "ambiguous":
108
+ ["ArrowRight", "ArrowDown"].includes(d.key) && (u = Nt(h, i)), ["ArrowLeft", "ArrowUp"].includes(d.key) && (u = Pt(h, i));
109
+ }
110
+ d.key === "Home" && (u = h[0]), d.key === "End" && (u = h[h.length - 1]), u && (d.preventDefault(), u.element.focus());
111
+ }
112
+ }), f = Be([n, c.ref]);
113
+ return v(o, { ...t, ...c, ref: f, children: t.children });
114
+ }), eo = (e, r, t) => {
115
+ const n = (t - 1) / 2, o = Math.max(1, Math.min(Math.max(e - Math.floor(n), 1), r - t + 1)), i = Math.min(Math.max(e + Math.ceil(n), t), r), s = Array.from({ length: i + 1 - o }, (a, l) => l + o);
116
+ return t > 4 && o > 1 && s.splice(0, 2, 1, 0), t > 3 && i < r && s.splice(-2, 2, 0, r), s;
117
+ }, Ds = ({ currentPage: e = 1, setCurrentPage: r, onChange: t, totalPages: n = 1, showPages: o = 7 }) => ze(() => {
118
+ const i = e < n, s = e !== 1, a = (l) => (c) => {
119
+ if (l < 1 || l > n)
120
+ return c.preventDefault();
121
+ t?.(c, l), c.defaultPrevented || r?.(l);
122
+ };
123
+ return {
124
+ /** Number of steps */
125
+ pages: eo(e, n, o).map((l, c) => ({
126
+ /**
127
+ * Page number or "ellipsis" for the ellipsis item
128
+ */
129
+ page: l || "ellipsis",
130
+ /**
131
+ * Unique key for the item
132
+ */
133
+ itemKey: l ? `page-${l}` : `ellipsis-${c}`,
134
+ // React key utility
135
+ /**
136
+ * Properties to spread on Pagination.Button
137
+ */
138
+ buttonProps: l ? {
139
+ "aria-current": l === e ? "page" : void 0,
140
+ onClick: a(l),
141
+ variant: l === e ? "primary" : "tertiary"
142
+ } : null
143
+ })),
144
+ /** Properties to spread on Pagination.Button used for previous naviagation */
145
+ prevButtonProps: {
146
+ "aria-hidden": !s,
147
+ // Using aria-hidden to support all HTML elements because of potential asChild
148
+ onClick: a(e - 1),
149
+ variant: "tertiary"
150
+ },
151
+ /** Properties to spread on Pagination.Button used for next naviagation */
152
+ nextButtonProps: {
153
+ "aria-hidden": !i,
154
+ // Using aria-hidden to support all HTML elements because of potential asChild
155
+ onClick: a(e + 1),
156
+ variant: "tertiary"
157
+ },
158
+ /** Indication if previous page action should be shown or not */
159
+ hasPrev: s,
160
+ /** Indication if next page action should be shown or not */
161
+ hasNext: i
162
+ };
163
+ }, [e, n, o]), to = A(function({ className: r, count: t, maxCount: n, variant: o = "base", ...i }, s) {
164
+ return v("span", { className: X("ds-badge", r), "data-count": t && n && t > n ? `${n}+` : t, "data-variant": o, ref: s, ...i });
165
+ }), no = A(function({ className: r, overlap: t = "rectangle", placement: n = "top-right", ...o }, i) {
166
+ return v("span", { className: X("ds-badge--position", r), "data-overlap": t, "data-placement": n, ref: i, ...o });
167
+ }), ro = Object.assign(to, { Position: no });
168
+ ro.Position.displayName = "Badge.Position";
169
+ const oo = A(({ asChild: e, className: r, ...t }, n) => v(e ? se : "a", { className: X("ds-link", r), ref: n, ...t }));
170
+ oo.displayName = "Link";
171
+ function Ct() {
172
+ return typeof window < "u";
173
+ }
174
+ function Et(e) {
175
+ return Yn(e) ? (e.nodeName || "").toLowerCase() : "#document";
176
+ }
177
+ function it(e) {
178
+ var r;
179
+ return (e == null || (r = e.ownerDocument) == null ? void 0 : r.defaultView) || window;
180
+ }
181
+ function io(e) {
182
+ var r;
183
+ return (r = (Yn(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : r.documentElement;
184
+ }
185
+ function Yn(e) {
186
+ return Ct() ? e instanceof Node || e instanceof it(e).Node : !1;
187
+ }
188
+ function ge(e) {
189
+ return Ct() ? e instanceof Element || e instanceof it(e).Element : !1;
190
+ }
191
+ function Oe(e) {
192
+ return Ct() ? e instanceof HTMLElement || e instanceof it(e).HTMLElement : !1;
193
+ }
194
+ function $t(e) {
195
+ return !Ct() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof it(e).ShadowRoot;
196
+ }
197
+ function mn(e) {
198
+ return ["html", "body", "#document"].includes(Et(e));
199
+ }
200
+ function so(e) {
201
+ return it(e).getComputedStyle(e);
202
+ }
203
+ function ao(e) {
204
+ if (Et(e) === "html")
205
+ return e;
206
+ const r = (
207
+ // Step into the shadow DOM of the parent of a slotted node.
208
+ e.assignedSlot || // DOM Element detected.
209
+ e.parentNode || // ShadowRoot detected.
210
+ $t(e) && e.host || // Fallback.
211
+ io(e)
212
+ );
213
+ return $t(r) ? r.host : r;
214
+ }
215
+ function Se(e) {
216
+ let r = e.activeElement;
217
+ for (; ((t = r) == null || (t = t.shadowRoot) == null ? void 0 : t.activeElement) != null; ) {
218
+ var t;
219
+ r = r.shadowRoot.activeElement;
220
+ }
221
+ return r;
222
+ }
223
+ function de(e, r) {
224
+ if (!e || !r)
225
+ return !1;
226
+ const t = r.getRootNode == null ? void 0 : r.getRootNode();
227
+ if (e.contains(r))
228
+ return !0;
229
+ if (t && $t(t)) {
230
+ let n = r;
231
+ for (; n; ) {
232
+ if (e === n)
233
+ return !0;
234
+ n = n.parentNode || n.host;
235
+ }
236
+ }
237
+ return !1;
238
+ }
239
+ function Zn() {
240
+ const e = navigator.userAgentData;
241
+ return e != null && e.platform ? e.platform : navigator.platform;
242
+ }
243
+ function Jn() {
244
+ const e = navigator.userAgentData;
245
+ return e && Array.isArray(e.brands) ? e.brands.map((r) => {
246
+ let {
247
+ brand: t,
248
+ version: n
249
+ } = r;
250
+ return t + "/" + n;
251
+ }).join(" ") : navigator.userAgent;
252
+ }
253
+ function Qn(e) {
254
+ return e.mozInputSource === 0 && e.isTrusted ? !0 : Kt() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
255
+ }
256
+ function er(e) {
257
+ return co() ? !1 : !Kt() && e.width === 0 && e.height === 0 || Kt() && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
258
+ e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
259
+ }
260
+ function tr() {
261
+ return /apple/i.test(navigator.vendor);
262
+ }
263
+ function Kt() {
264
+ const e = /android/i;
265
+ return e.test(Zn()) || e.test(Jn());
266
+ }
267
+ function lo() {
268
+ return Zn().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
269
+ }
270
+ function co() {
271
+ return Jn().includes("jsdom/");
272
+ }
273
+ function uo(e) {
274
+ return "nativeEvent" in e;
275
+ }
276
+ function fo(e) {
277
+ return e.matches("html,body");
278
+ }
279
+ function be(e) {
280
+ return e?.ownerDocument || document;
281
+ }
282
+ function Dt(e, r) {
283
+ if (r == null)
284
+ return !1;
285
+ if ("composedPath" in e)
286
+ return e.composedPath().includes(r);
287
+ const t = e;
288
+ return t.target != null && r.contains(t.target);
289
+ }
290
+ function Le(e) {
291
+ return "composedPath" in e ? e.composedPath()[0] : e.target;
292
+ }
293
+ const ho = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
294
+ function mo(e) {
295
+ return Oe(e) && e.matches(ho);
296
+ }
297
+ function fe(e) {
298
+ e.preventDefault(), e.stopPropagation();
299
+ }
300
+ function nr(e) {
301
+ return e ? e.getAttribute("role") === "combobox" && mo(e) : !1;
302
+ }
303
+ const pn = Math.floor;
304
+ var po = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], bt = /* @__PURE__ */ po.join(","), rr = typeof Element > "u", He = rr ? function() {
305
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, gt = !rr && Element.prototype.getRootNode ? function(e) {
306
+ var r;
307
+ return e == null || (r = e.getRootNode) === null || r === void 0 ? void 0 : r.call(e);
308
+ } : function(e) {
309
+ return e?.ownerDocument;
310
+ }, vt = function e(r, t) {
311
+ var n;
312
+ t === void 0 && (t = !0);
313
+ var o = r == null || (n = r.getAttribute) === null || n === void 0 ? void 0 : n.call(r, "inert"), i = o === "" || o === "true", s = i || t && r && e(r.parentNode);
314
+ return s;
315
+ }, bo = function(r) {
316
+ var t, n = r == null || (t = r.getAttribute) === null || t === void 0 ? void 0 : t.call(r, "contenteditable");
317
+ return n === "" || n === "true";
318
+ }, go = function(r, t, n) {
319
+ if (vt(r))
320
+ return [];
321
+ var o = Array.prototype.slice.apply(r.querySelectorAll(bt));
322
+ return t && He.call(r, bt) && o.unshift(r), o = o.filter(n), o;
323
+ }, vo = function e(r, t, n) {
324
+ for (var o = [], i = Array.from(r); i.length; ) {
325
+ var s = i.shift();
326
+ if (!vt(s, !1))
327
+ if (s.tagName === "SLOT") {
328
+ var a = s.assignedElements(), l = a.length ? a : s.children, c = e(l, !0, n);
329
+ n.flatten ? o.push.apply(o, c) : o.push({
330
+ scopeParent: s,
331
+ candidates: c
332
+ });
333
+ } else {
334
+ var f = He.call(s, bt);
335
+ f && n.filter(s) && (t || !r.includes(s)) && o.push(s);
336
+ var d = s.shadowRoot || // check for an undisclosed shadow
337
+ typeof n.getShadowRoot == "function" && n.getShadowRoot(s), h = !vt(d, !1) && (!n.shadowRootFilter || n.shadowRootFilter(s));
338
+ if (d && h) {
339
+ var u = e(d === !0 ? s.children : d.children, !0, n);
340
+ n.flatten ? o.push.apply(o, u) : o.push({
341
+ scopeParent: s,
342
+ candidates: u
343
+ });
344
+ } else
345
+ i.unshift.apply(i, s.children);
346
+ }
347
+ }
348
+ return o;
349
+ }, or = function(r) {
350
+ return !isNaN(parseInt(r.getAttribute("tabindex"), 10));
351
+ }, ir = function(r) {
352
+ if (!r)
353
+ throw new Error("No node provided");
354
+ return r.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(r.tagName) || bo(r)) && !or(r) ? 0 : r.tabIndex;
355
+ }, yo = function(r, t) {
356
+ var n = ir(r);
357
+ return n < 0 && t && !or(r) ? 0 : n;
358
+ }, xo = function(r, t) {
359
+ return r.tabIndex === t.tabIndex ? r.documentOrder - t.documentOrder : r.tabIndex - t.tabIndex;
360
+ }, sr = function(r) {
361
+ return r.tagName === "INPUT";
362
+ }, wo = function(r) {
363
+ return sr(r) && r.type === "hidden";
364
+ }, Co = function(r) {
365
+ var t = r.tagName === "DETAILS" && Array.prototype.slice.apply(r.children).some(function(n) {
366
+ return n.tagName === "SUMMARY";
367
+ });
368
+ return t;
369
+ }, Eo = function(r, t) {
370
+ for (var n = 0; n < r.length; n++)
371
+ if (r[n].checked && r[n].form === t)
372
+ return r[n];
373
+ }, Io = function(r) {
374
+ if (!r.name)
375
+ return !0;
376
+ var t = r.form || gt(r), n = function(a) {
377
+ return t.querySelectorAll('input[type="radio"][name="' + a + '"]');
378
+ }, o;
379
+ if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
380
+ o = n(window.CSS.escape(r.name));
381
+ else
382
+ try {
383
+ o = n(r.name);
384
+ } catch (s) {
385
+ return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", s.message), !1;
386
+ }
387
+ var i = Eo(o, r.form);
388
+ return !i || i === r;
389
+ }, Ro = function(r) {
390
+ return sr(r) && r.type === "radio";
391
+ }, Oo = function(r) {
392
+ return Ro(r) && !Io(r);
393
+ }, So = function(r) {
394
+ var t, n = r && gt(r), o = (t = n) === null || t === void 0 ? void 0 : t.host, i = !1;
395
+ if (n && n !== r) {
396
+ var s, a, l;
397
+ for (i = !!((s = o) !== null && s !== void 0 && (a = s.ownerDocument) !== null && a !== void 0 && a.contains(o) || r != null && (l = r.ownerDocument) !== null && l !== void 0 && l.contains(r)); !i && o; ) {
398
+ var c, f, d;
399
+ n = gt(o), o = (c = n) === null || c === void 0 ? void 0 : c.host, i = !!((f = o) !== null && f !== void 0 && (d = f.ownerDocument) !== null && d !== void 0 && d.contains(o));
400
+ }
401
+ }
402
+ return i;
403
+ }, bn = function(r) {
404
+ var t = r.getBoundingClientRect(), n = t.width, o = t.height;
405
+ return n === 0 && o === 0;
406
+ }, To = function(r, t) {
407
+ var n = t.displayCheck, o = t.getShadowRoot;
408
+ if (getComputedStyle(r).visibility === "hidden")
409
+ return !0;
410
+ var i = He.call(r, "details>summary:first-of-type"), s = i ? r.parentElement : r;
411
+ if (He.call(s, "details:not([open]) *"))
412
+ return !0;
413
+ if (!n || n === "full" || n === "legacy-full") {
414
+ if (typeof o == "function") {
415
+ for (var a = r; r; ) {
416
+ var l = r.parentElement, c = gt(r);
417
+ if (l && !l.shadowRoot && o(l) === !0)
418
+ return bn(r);
419
+ r.assignedSlot ? r = r.assignedSlot : !l && c !== r.ownerDocument ? r = c.host : r = l;
420
+ }
421
+ r = a;
422
+ }
423
+ if (So(r))
424
+ return !r.getClientRects().length;
425
+ if (n !== "legacy-full")
426
+ return !0;
427
+ } else if (n === "non-zero-area")
428
+ return bn(r);
429
+ return !1;
430
+ }, ko = function(r) {
431
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(r.tagName))
432
+ for (var t = r.parentElement; t; ) {
433
+ if (t.tagName === "FIELDSET" && t.disabled) {
434
+ for (var n = 0; n < t.children.length; n++) {
435
+ var o = t.children.item(n);
436
+ if (o.tagName === "LEGEND")
437
+ return He.call(t, "fieldset[disabled] *") ? !0 : !o.contains(r);
438
+ }
439
+ return !0;
440
+ }
441
+ t = t.parentElement;
442
+ }
443
+ return !1;
444
+ }, Mo = function(r, t) {
445
+ return !(t.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
446
+ // because we're limited in the type of selectors we can use in JSDom (see related
447
+ // note related to `candidateSelectors`)
448
+ vt(t) || wo(t) || To(t, r) || // For a details element with a summary, the summary element gets the focus
449
+ Co(t) || ko(t));
450
+ }, Wt = function(r, t) {
451
+ return !(Oo(t) || ir(t) < 0 || !Mo(r, t));
452
+ }, No = function(r) {
453
+ var t = parseInt(r.getAttribute("tabindex"), 10);
454
+ return !!(isNaN(t) || t >= 0);
455
+ }, Po = function e(r) {
456
+ var t = [], n = [];
457
+ return r.forEach(function(o, i) {
458
+ var s = !!o.scopeParent, a = s ? o.scopeParent : o, l = yo(a, s), c = s ? e(o.candidates) : a;
459
+ l === 0 ? s ? t.push.apply(t, c) : t.push(a) : n.push({
460
+ documentOrder: i,
461
+ tabIndex: l,
462
+ item: o,
463
+ isScope: s,
464
+ content: c
465
+ });
466
+ }), n.sort(xo).reduce(function(o, i) {
467
+ return i.isScope ? o.push.apply(o, i.content) : o.push(i.content), o;
468
+ }, []).concat(t);
469
+ }, nt = function(r, t) {
470
+ t = t || {};
471
+ var n;
472
+ return t.getShadowRoot ? n = vo([r], t.includeContainer, {
473
+ filter: Wt.bind(null, t),
474
+ flatten: !1,
475
+ getShadowRoot: t.getShadowRoot,
476
+ shadowRootFilter: No
477
+ }) : n = go(r, t.includeContainer, Wt.bind(null, t)), Po(n);
478
+ }, Do = function(r, t) {
479
+ if (t = t || {}, !r)
480
+ throw new Error("No node provided");
481
+ return He.call(r, bt) === !1 ? !1 : Wt(t, r);
482
+ }, ht = typeof document < "u" ? jn : ue;
483
+ function yt(e, r) {
484
+ if (e === r)
485
+ return !0;
486
+ if (typeof e != typeof r)
487
+ return !1;
488
+ if (typeof e == "function" && e.toString() === r.toString())
489
+ return !0;
490
+ let t, n, o;
491
+ if (e && r && typeof e == "object") {
492
+ if (Array.isArray(e)) {
493
+ if (t = e.length, t !== r.length) return !1;
494
+ for (n = t; n-- !== 0; )
495
+ if (!yt(e[n], r[n]))
496
+ return !1;
497
+ return !0;
498
+ }
499
+ if (o = Object.keys(e), t = o.length, t !== Object.keys(r).length)
500
+ return !1;
501
+ for (n = t; n-- !== 0; )
502
+ if (!{}.hasOwnProperty.call(r, o[n]))
503
+ return !1;
504
+ for (n = t; n-- !== 0; ) {
505
+ const i = o[n];
506
+ if (!(i === "_owner" && e.$$typeof) && !yt(e[i], r[i]))
507
+ return !1;
508
+ }
509
+ return !0;
510
+ }
511
+ return e !== e && r !== r;
512
+ }
513
+ function ar(e) {
514
+ return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
515
+ }
516
+ function gn(e, r) {
517
+ const t = ar(e);
518
+ return Math.round(r * t) / t;
519
+ }
520
+ function At(e) {
521
+ const r = p.useRef(e);
522
+ return ht(() => {
523
+ r.current = e;
524
+ }), r;
525
+ }
526
+ function Ao(e) {
527
+ e === void 0 && (e = {});
528
+ const {
529
+ placement: r = "bottom",
530
+ strategy: t = "absolute",
531
+ middleware: n = [],
532
+ platform: o,
533
+ elements: {
534
+ reference: i,
535
+ floating: s
536
+ } = {},
537
+ transform: a = !0,
538
+ whileElementsMounted: l,
539
+ open: c
540
+ } = e, [f, d] = p.useState({
541
+ x: 0,
542
+ y: 0,
543
+ strategy: t,
544
+ placement: r,
545
+ middlewareData: {},
546
+ isPositioned: !1
547
+ }), [h, u] = p.useState(n);
548
+ yt(h, n) || u(n);
549
+ const [m, g] = p.useState(null), [C, x] = p.useState(null), y = p.useCallback((k) => {
550
+ k !== M.current && (M.current = k, g(k));
551
+ }, []), b = p.useCallback((k) => {
552
+ k !== j.current && (j.current = k, x(k));
553
+ }, []), w = i || m, _ = s || C, M = p.useRef(null), j = p.useRef(null), $ = p.useRef(f), Z = l != null, G = At(l), q = At(o), S = At(c), N = p.useCallback(() => {
554
+ if (!M.current || !j.current)
555
+ return;
556
+ const k = {
557
+ placement: r,
558
+ strategy: t,
559
+ middleware: h
560
+ };
561
+ q.current && (k.platform = q.current), Un(M.current, j.current, k).then((R) => {
562
+ const U = {
563
+ ...R,
564
+ // The floating element's position may be recomputed while it's closed
565
+ // but still mounted (such as when transitioning out). To ensure
566
+ // `isPositioned` will be `false` initially on the next open, avoid
567
+ // setting it to `true` when `open === false` (must be specified).
568
+ isPositioned: S.current !== !1
569
+ };
570
+ P.current && !yt($.current, U) && ($.current = U, Kn.flushSync(() => {
571
+ d(U);
572
+ }));
573
+ });
574
+ }, [h, r, t, q, S]);
575
+ ht(() => {
576
+ c === !1 && $.current.isPositioned && ($.current.isPositioned = !1, d((k) => ({
577
+ ...k,
578
+ isPositioned: !1
579
+ })));
580
+ }, [c]);
581
+ const P = p.useRef(!1);
582
+ ht(() => (P.current = !0, () => {
583
+ P.current = !1;
584
+ }), []), ht(() => {
585
+ if (w && (M.current = w), _ && (j.current = _), w && _) {
586
+ if (G.current)
587
+ return G.current(w, _, N);
588
+ N();
589
+ }
590
+ }, [w, _, N, G, Z]);
591
+ const E = p.useMemo(() => ({
592
+ reference: M,
593
+ floating: j,
594
+ setReference: y,
595
+ setFloating: b
596
+ }), [y, b]), D = p.useMemo(() => ({
597
+ reference: w,
598
+ floating: _
599
+ }), [w, _]), B = p.useMemo(() => {
600
+ const k = {
601
+ position: t,
602
+ left: 0,
603
+ top: 0
604
+ };
605
+ if (!D.floating)
606
+ return k;
607
+ const R = gn(D.floating, f.x), U = gn(D.floating, f.y);
608
+ return a ? {
609
+ ...k,
610
+ transform: "translate(" + R + "px, " + U + "px)",
611
+ ...ar(D.floating) >= 1.5 && {
612
+ willChange: "transform"
613
+ }
614
+ } : {
615
+ position: t,
616
+ left: R,
617
+ top: U
618
+ };
619
+ }, [t, a, D.floating, f.x, f.y]);
620
+ return p.useMemo(() => ({
621
+ ...f,
622
+ update: N,
623
+ refs: E,
624
+ elements: D,
625
+ floatingStyles: B
626
+ }), [f, N, E, D, B]);
627
+ }
628
+ const _o = (e, r) => ({
629
+ ...Hn(e),
630
+ options: [e, r]
631
+ }), Fo = (e, r) => ({
632
+ ...qn(e),
633
+ options: [e, r]
634
+ }), Lo = (e, r) => ({
635
+ ...Xr(e),
636
+ options: [e, r]
637
+ });
638
+ function Yt(e) {
639
+ return p.useMemo(() => e.every((r) => r == null) ? null : (r) => {
640
+ e.forEach((t) => {
641
+ typeof t == "function" ? t(r) : t != null && (t.current = r);
642
+ });
643
+ }, e);
644
+ }
645
+ const lr = {
646
+ ...p
647
+ }, zo = lr.useInsertionEffect, Vo = zo || ((e) => e());
648
+ function Ce(e) {
649
+ const r = p.useRef(() => {
650
+ if (process.env.NODE_ENV !== "production")
651
+ throw new Error("Cannot call an event handler while rendering.");
652
+ });
653
+ return Vo(() => {
654
+ r.current = e;
655
+ }), p.useCallback(function() {
656
+ for (var t = arguments.length, n = new Array(t), o = 0; o < t; o++)
657
+ n[o] = arguments[o];
658
+ return r.current == null ? void 0 : r.current(...n);
659
+ }, []);
660
+ }
661
+ const Zt = "ArrowUp", st = "ArrowDown", Ue = "ArrowLeft", Ze = "ArrowRight";
662
+ function ut(e, r, t) {
663
+ return Math.floor(e / r) !== t;
664
+ }
665
+ function et(e, r) {
666
+ return r < 0 || r >= e.current.length;
667
+ }
668
+ function _t(e, r) {
669
+ return le(e, {
670
+ disabledIndices: r
671
+ });
672
+ }
673
+ function vn(e, r) {
674
+ return le(e, {
675
+ decrement: !0,
676
+ startingIndex: e.current.length,
677
+ disabledIndices: r
678
+ });
679
+ }
680
+ function le(e, r) {
681
+ let {
682
+ startingIndex: t = -1,
683
+ decrement: n = !1,
684
+ disabledIndices: o,
685
+ amount: i = 1
686
+ } = r === void 0 ? {} : r;
687
+ const s = e.current;
688
+ let a = t;
689
+ do
690
+ a += n ? -i : i;
691
+ while (a >= 0 && a <= s.length - 1 && mt(s, a, o));
692
+ return a;
693
+ }
694
+ function Bo(e, r) {
695
+ let {
696
+ event: t,
697
+ orientation: n,
698
+ loop: o,
699
+ cols: i,
700
+ disabledIndices: s,
701
+ minIndex: a,
702
+ maxIndex: l,
703
+ prevIndex: c,
704
+ stopEvent: f = !1
705
+ } = r, d = c;
706
+ if (t.key === Zt) {
707
+ if (f && fe(t), c === -1)
708
+ d = l;
709
+ else if (d = le(e, {
710
+ startingIndex: d,
711
+ amount: i,
712
+ decrement: !0,
713
+ disabledIndices: s
714
+ }), o && (c - i < a || d < 0)) {
715
+ const h = c % i, u = l % i, m = l - (u - h);
716
+ u === h ? d = l : d = u > h ? m : m - i;
717
+ }
718
+ et(e, d) && (d = c);
719
+ }
720
+ if (t.key === st && (f && fe(t), c === -1 ? d = a : (d = le(e, {
721
+ startingIndex: c,
722
+ amount: i,
723
+ disabledIndices: s
724
+ }), o && c + i > l && (d = le(e, {
725
+ startingIndex: c % i - i,
726
+ amount: i,
727
+ disabledIndices: s
728
+ }))), et(e, d) && (d = c)), n === "both") {
729
+ const h = pn(c / i);
730
+ t.key === Ze && (f && fe(t), c % i !== i - 1 ? (d = le(e, {
731
+ startingIndex: c,
732
+ disabledIndices: s
733
+ }), o && ut(d, i, h) && (d = le(e, {
734
+ startingIndex: c - c % i - 1,
735
+ disabledIndices: s
736
+ }))) : o && (d = le(e, {
737
+ startingIndex: c - c % i - 1,
738
+ disabledIndices: s
739
+ })), ut(d, i, h) && (d = c)), t.key === Ue && (f && fe(t), c % i !== 0 ? (d = le(e, {
740
+ startingIndex: c,
741
+ decrement: !0,
742
+ disabledIndices: s
743
+ }), o && ut(d, i, h) && (d = le(e, {
744
+ startingIndex: c + (i - c % i),
745
+ decrement: !0,
746
+ disabledIndices: s
747
+ }))) : o && (d = le(e, {
748
+ startingIndex: c + (i - c % i),
749
+ decrement: !0,
750
+ disabledIndices: s
751
+ })), ut(d, i, h) && (d = c));
752
+ const u = pn(l / i) === h;
753
+ et(e, d) && (o && u ? d = t.key === Ue ? l : le(e, {
754
+ startingIndex: c - c % i - 1,
755
+ disabledIndices: s
756
+ }) : d = c);
757
+ }
758
+ return d;
759
+ }
760
+ function jo(e, r, t) {
761
+ const n = [];
762
+ let o = 0;
763
+ return e.forEach((i, s) => {
764
+ let {
765
+ width: a,
766
+ height: l
767
+ } = i;
768
+ if (a > r && process.env.NODE_ENV !== "production")
769
+ throw new Error("[Floating UI]: Invalid grid - item width at index " + s + " is greater than grid columns");
770
+ let c = !1;
771
+ for (t && (o = 0); !c; ) {
772
+ const f = [];
773
+ for (let d = 0; d < a; d++)
774
+ for (let h = 0; h < l; h++)
775
+ f.push(o + d + h * r);
776
+ o % r + a <= r && f.every((d) => n[d] == null) ? (f.forEach((d) => {
777
+ n[d] = s;
778
+ }), c = !0) : o++;
779
+ }
780
+ }), [...n];
781
+ }
782
+ function $o(e, r, t, n, o) {
783
+ if (e === -1) return -1;
784
+ const i = t.indexOf(e), s = r[e];
785
+ switch (o) {
786
+ case "tl":
787
+ return i;
788
+ case "tr":
789
+ return s ? i + s.width - 1 : i;
790
+ case "bl":
791
+ return s ? i + (s.height - 1) * n : i;
792
+ case "br":
793
+ return t.lastIndexOf(e);
794
+ }
795
+ }
796
+ function Ko(e, r) {
797
+ return r.flatMap((t, n) => e.includes(t) ? [n] : []);
798
+ }
799
+ function mt(e, r, t) {
800
+ if (t)
801
+ return t.includes(r);
802
+ const n = e[r];
803
+ return n == null || n.hasAttribute("disabled") || n.getAttribute("aria-disabled") === "true";
804
+ }
805
+ let yn = 0;
806
+ function Ne(e, r) {
807
+ r === void 0 && (r = {});
808
+ const {
809
+ preventScroll: t = !1,
810
+ cancelPrevious: n = !0,
811
+ sync: o = !1
812
+ } = r;
813
+ n && cancelAnimationFrame(yn);
814
+ const i = () => e?.focus({
815
+ preventScroll: t
816
+ });
817
+ o ? i() : yn = requestAnimationFrame(i);
818
+ }
819
+ var Q = typeof document < "u" ? jn : ue;
820
+ function xt() {
821
+ return xt = Object.assign ? Object.assign.bind() : function(e) {
822
+ for (var r = 1; r < arguments.length; r++) {
823
+ var t = arguments[r];
824
+ for (var n in t)
825
+ Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
826
+ }
827
+ return e;
828
+ }, xt.apply(this, arguments);
829
+ }
830
+ let xn = !1, Wo = 0;
831
+ const wn = () => (
832
+ // Ensure the id is unique with multiple independent versions of Floating UI
833
+ // on <React 18
834
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + Wo++
835
+ );
836
+ function qo() {
837
+ const [e, r] = p.useState(() => xn ? wn() : void 0);
838
+ return Q(() => {
839
+ e == null && r(wn());
840
+ }, []), p.useEffect(() => {
841
+ xn = !0;
842
+ }, []), e;
843
+ }
844
+ const Ho = lr.useId, Jt = Ho || qo;
845
+ let rt;
846
+ process.env.NODE_ENV !== "production" && (rt = /* @__PURE__ */ new Set());
847
+ function Ft() {
848
+ for (var e, r = arguments.length, t = new Array(r), n = 0; n < r; n++)
849
+ t[n] = arguments[n];
850
+ const o = "Floating UI: " + t.join(" ");
851
+ if (!((e = rt) != null && e.has(o))) {
852
+ var i;
853
+ (i = rt) == null || i.add(o), console.warn(o);
854
+ }
855
+ }
856
+ function Uo() {
857
+ for (var e, r = arguments.length, t = new Array(r), n = 0; n < r; n++)
858
+ t[n] = arguments[n];
859
+ const o = "Floating UI: " + t.join(" ");
860
+ if (!((e = rt) != null && e.has(o))) {
861
+ var i;
862
+ (i = rt) == null || i.add(o), console.error(o);
863
+ }
864
+ }
865
+ function Xo() {
866
+ const e = /* @__PURE__ */ new Map();
867
+ return {
868
+ emit(r, t) {
869
+ var n;
870
+ (n = e.get(r)) == null || n.forEach((o) => o(t));
871
+ },
872
+ on(r, t) {
873
+ e.set(r, [...e.get(r) || [], t]);
874
+ },
875
+ off(r, t) {
876
+ var n;
877
+ e.set(r, ((n = e.get(r)) == null ? void 0 : n.filter((o) => o !== t)) || []);
878
+ }
879
+ };
880
+ }
881
+ const Go = /* @__PURE__ */ p.createContext(null), Yo = /* @__PURE__ */ p.createContext(null), Qt = () => {
882
+ var e;
883
+ return ((e = p.useContext(Go)) == null ? void 0 : e.id) || null;
884
+ }, It = () => p.useContext(Yo);
885
+ function Xe(e) {
886
+ return "data-floating-ui-" + e;
887
+ }
888
+ function Pe(e) {
889
+ const r = ve(e);
890
+ return Q(() => {
891
+ r.current = e;
892
+ }), r;
893
+ }
894
+ function Zo(e, r) {
895
+ var t;
896
+ let n = [], o = (t = e.find((i) => i.id === r)) == null ? void 0 : t.parentId;
897
+ for (; o; ) {
898
+ const i = e.find((s) => s.id === o);
899
+ o = i?.parentId, i && (n = n.concat(i));
900
+ }
901
+ return n;
902
+ }
903
+ function We(e, r) {
904
+ let t = e.filter((o) => {
905
+ var i;
906
+ return o.parentId === r && ((i = o.context) == null ? void 0 : i.open);
907
+ }), n = t;
908
+ for (; n.length; )
909
+ n = e.filter((o) => {
910
+ var i;
911
+ return (i = n) == null ? void 0 : i.some((s) => {
912
+ var a;
913
+ return o.parentId === s.id && ((a = o.context) == null ? void 0 : a.open);
914
+ });
915
+ }), t = t.concat(n);
916
+ return t;
917
+ }
918
+ function Jo(e, r) {
919
+ let t, n = -1;
920
+ function o(i, s) {
921
+ s > n && (t = i, n = s), We(e, i).forEach((l) => {
922
+ o(l.id, s + 1);
923
+ });
924
+ }
925
+ return o(r, 0), e.find((i) => i.id === t);
926
+ }
927
+ let $e = /* @__PURE__ */ new WeakMap(), dt = /* @__PURE__ */ new WeakSet(), ft = {}, Lt = 0;
928
+ const Qo = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype, cr = (e) => e && (e.host || cr(e.parentNode)), ei = (e, r) => r.map((t) => {
929
+ if (e.contains(t))
930
+ return t;
931
+ const n = cr(t);
932
+ return e.contains(n) ? n : null;
933
+ }).filter((t) => t != null);
934
+ function ti(e, r, t, n) {
935
+ const o = "data-floating-ui-inert", i = n ? "inert" : t ? "aria-hidden" : null, s = ei(r, e), a = /* @__PURE__ */ new Set(), l = new Set(s), c = [];
936
+ ft[o] || (ft[o] = /* @__PURE__ */ new WeakMap());
937
+ const f = ft[o];
938
+ s.forEach(d), h(r), a.clear();
939
+ function d(u) {
940
+ !u || a.has(u) || (a.add(u), u.parentNode && d(u.parentNode));
941
+ }
942
+ function h(u) {
943
+ !u || l.has(u) || [].forEach.call(u.children, (m) => {
944
+ if (Et(m) !== "script")
945
+ if (a.has(m))
946
+ h(m);
947
+ else {
948
+ const g = i ? m.getAttribute(i) : null, C = g !== null && g !== "false", x = ($e.get(m) || 0) + 1, y = (f.get(m) || 0) + 1;
949
+ $e.set(m, x), f.set(m, y), c.push(m), x === 1 && C && dt.add(m), y === 1 && m.setAttribute(o, ""), !C && i && m.setAttribute(i, "true");
950
+ }
951
+ });
952
+ }
953
+ return Lt++, () => {
954
+ c.forEach((u) => {
955
+ const m = ($e.get(u) || 0) - 1, g = (f.get(u) || 0) - 1;
956
+ $e.set(u, m), f.set(u, g), m || (!dt.has(u) && i && u.removeAttribute(i), dt.delete(u)), g || u.removeAttribute(o);
957
+ }), Lt--, Lt || ($e = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), dt = /* @__PURE__ */ new WeakSet(), ft = {});
958
+ };
959
+ }
960
+ function Cn(e, r, t) {
961
+ r === void 0 && (r = !1), t === void 0 && (t = !1);
962
+ const n = be(e[0]).body;
963
+ return ti(e.concat(Array.from(n.querySelectorAll("[aria-live]"))), n, r, t);
964
+ }
965
+ const Ge = () => ({
966
+ getShadowRoot: !0,
967
+ displayCheck: (
968
+ // JSDOM does not support the `tabbable` library. To solve this we can
969
+ // check if `ResizeObserver` is a real function (not polyfilled), which
970
+ // determines if the current environment is JSDOM-like.
971
+ typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
972
+ )
973
+ });
974
+ function ur(e, r) {
975
+ const t = nt(e, Ge());
976
+ r === "prev" && t.reverse();
977
+ const n = t.indexOf(Se(be(e)));
978
+ return t.slice(n + 1)[0];
979
+ }
980
+ function dr() {
981
+ return ur(document.body, "next");
982
+ }
983
+ function fr() {
984
+ return ur(document.body, "prev");
985
+ }
986
+ function tt(e, r) {
987
+ const t = r || e.currentTarget, n = e.relatedTarget;
988
+ return !n || !de(t, n);
989
+ }
990
+ function ni(e) {
991
+ nt(e, Ge()).forEach((t) => {
992
+ t.dataset.tabindex = t.getAttribute("tabindex") || "", t.setAttribute("tabindex", "-1");
993
+ });
994
+ }
995
+ function En(e) {
996
+ e.querySelectorAll("[data-tabindex]").forEach((t) => {
997
+ const n = t.dataset.tabindex;
998
+ delete t.dataset.tabindex, n ? t.setAttribute("tabindex", n) : t.removeAttribute("tabindex");
999
+ });
1000
+ }
1001
+ function ri(e, r, t) {
1002
+ const n = e.indexOf(r);
1003
+ function o(s) {
1004
+ const a = Xe("focus-guard");
1005
+ let l = n + (s ? 1 : 0), c = e[l];
1006
+ for (; c && (!c.isConnected || c.hasAttribute(a) || de(t, c)); )
1007
+ s ? l++ : l--, c = e[l];
1008
+ return c;
1009
+ }
1010
+ const i = o(!0);
1011
+ return i || o(!1);
1012
+ }
1013
+ const en = {
1014
+ border: 0,
1015
+ clip: "rect(0 0 0 0)",
1016
+ height: "1px",
1017
+ margin: "-1px",
1018
+ overflow: "hidden",
1019
+ padding: 0,
1020
+ position: "fixed",
1021
+ whiteSpace: "nowrap",
1022
+ width: "1px",
1023
+ top: 0,
1024
+ left: 0
1025
+ };
1026
+ let oi;
1027
+ function In(e) {
1028
+ e.key === "Tab" && (e.target, clearTimeout(oi));
1029
+ }
1030
+ const wt = /* @__PURE__ */ p.forwardRef(function(r, t) {
1031
+ const [n, o] = p.useState();
1032
+ Q(() => (tr() && o("button"), document.addEventListener("keydown", In), () => {
1033
+ document.removeEventListener("keydown", In);
1034
+ }), []);
1035
+ const i = {
1036
+ ref: t,
1037
+ tabIndex: 0,
1038
+ // Role is only for VoiceOver
1039
+ role: n,
1040
+ "aria-hidden": n ? void 0 : !0,
1041
+ [Xe("focus-guard")]: "",
1042
+ style: en
1043
+ };
1044
+ return /* @__PURE__ */ p.createElement("span", xt({}, r, i));
1045
+ }), hr = /* @__PURE__ */ p.createContext(null), Rn = /* @__PURE__ */ Xe("portal");
1046
+ function ii(e) {
1047
+ e === void 0 && (e = {});
1048
+ const {
1049
+ id: r,
1050
+ root: t
1051
+ } = e, n = Jt(), o = mr(), [i, s] = p.useState(null), a = p.useRef(null);
1052
+ return Q(() => () => {
1053
+ i?.remove(), queueMicrotask(() => {
1054
+ a.current = null;
1055
+ });
1056
+ }, [i]), Q(() => {
1057
+ if (!n || a.current) return;
1058
+ const l = r ? document.getElementById(r) : null;
1059
+ if (!l) return;
1060
+ const c = document.createElement("div");
1061
+ c.id = n, c.setAttribute(Rn, ""), l.appendChild(c), a.current = c, s(c);
1062
+ }, [r, n]), Q(() => {
1063
+ if (!n || a.current) return;
1064
+ let l = t || o?.portalNode;
1065
+ l && !ge(l) && (l = l.current), l = l || document.body;
1066
+ let c = null;
1067
+ r && (c = document.createElement("div"), c.id = r, l.appendChild(c));
1068
+ const f = document.createElement("div");
1069
+ f.id = n, f.setAttribute(Rn, ""), l = c || l, l.appendChild(f), a.current = f, s(f);
1070
+ }, [r, t, n, o]), i;
1071
+ }
1072
+ function si(e) {
1073
+ const {
1074
+ children: r,
1075
+ id: t,
1076
+ root: n = null,
1077
+ preserveTabOrder: o = !0
1078
+ } = e, i = ii({
1079
+ id: t,
1080
+ root: n
1081
+ }), [s, a] = p.useState(null), l = p.useRef(null), c = p.useRef(null), f = p.useRef(null), d = p.useRef(null), h = s?.modal, u = s?.open, m = (
1082
+ // The FocusManager and therefore floating element are currently open/
1083
+ // rendered.
1084
+ !!s && // Guards are only for non-modal focus management.
1085
+ !s.modal && // Don't render if unmount is transitioning.
1086
+ s.open && o && !!(n || i)
1087
+ );
1088
+ return p.useEffect(() => {
1089
+ if (!i || !o || h)
1090
+ return;
1091
+ function g(C) {
1092
+ i && tt(C) && (C.type === "focusin" ? En : ni)(i);
1093
+ }
1094
+ return i.addEventListener("focusin", g, !0), i.addEventListener("focusout", g, !0), () => {
1095
+ i.removeEventListener("focusin", g, !0), i.removeEventListener("focusout", g, !0);
1096
+ };
1097
+ }, [i, o, h]), p.useEffect(() => {
1098
+ i && (u || En(i));
1099
+ }, [u, i]), /* @__PURE__ */ p.createElement(hr.Provider, {
1100
+ value: p.useMemo(() => ({
1101
+ preserveTabOrder: o,
1102
+ beforeOutsideRef: l,
1103
+ afterOutsideRef: c,
1104
+ beforeInsideRef: f,
1105
+ afterInsideRef: d,
1106
+ portalNode: i,
1107
+ setFocusManagerState: a
1108
+ }), [o, i])
1109
+ }, m && i && /* @__PURE__ */ p.createElement(wt, {
1110
+ "data-type": "outside",
1111
+ ref: l,
1112
+ onFocus: (g) => {
1113
+ if (tt(g, i)) {
1114
+ var C;
1115
+ (C = f.current) == null || C.focus();
1116
+ } else {
1117
+ const x = fr() || s?.refs.domReference.current;
1118
+ x?.focus();
1119
+ }
1120
+ }
1121
+ }), m && i && /* @__PURE__ */ p.createElement("span", {
1122
+ "aria-owns": i.id,
1123
+ style: en
1124
+ }), i && /* @__PURE__ */ Kn.createPortal(r, i), m && i && /* @__PURE__ */ p.createElement(wt, {
1125
+ "data-type": "outside",
1126
+ ref: c,
1127
+ onFocus: (g) => {
1128
+ if (tt(g, i)) {
1129
+ var C;
1130
+ (C = d.current) == null || C.focus();
1131
+ } else {
1132
+ const x = dr() || s?.refs.domReference.current;
1133
+ x?.focus(), s?.closeOnFocusOut && s?.onOpenChange(!1, g.nativeEvent, "focus-out");
1134
+ }
1135
+ }
1136
+ }));
1137
+ }
1138
+ const mr = () => p.useContext(hr), qt = "data-floating-ui-focusable";
1139
+ function pr(e) {
1140
+ return e ? e.hasAttribute(qt) ? e : e.querySelector("[" + qt + "]") || e : null;
1141
+ }
1142
+ const On = 20;
1143
+ let Fe = [];
1144
+ function zt(e) {
1145
+ Fe = Fe.filter((t) => t.isConnected);
1146
+ let r = e;
1147
+ if (!(!r || Et(r) === "body")) {
1148
+ if (!Do(r, Ge())) {
1149
+ const t = nt(r, Ge())[0];
1150
+ t && (r = t);
1151
+ }
1152
+ Fe.push(r), Fe.length > On && (Fe = Fe.slice(-On));
1153
+ }
1154
+ }
1155
+ function Sn() {
1156
+ return Fe.slice().reverse().find((e) => e.isConnected);
1157
+ }
1158
+ const ai = /* @__PURE__ */ p.forwardRef(function(r, t) {
1159
+ return /* @__PURE__ */ p.createElement("button", xt({}, r, {
1160
+ type: "button",
1161
+ ref: t,
1162
+ tabIndex: -1,
1163
+ style: en
1164
+ }));
1165
+ });
1166
+ function li(e) {
1167
+ const {
1168
+ context: r,
1169
+ children: t,
1170
+ disabled: n = !1,
1171
+ order: o = ["content"],
1172
+ guards: i = !0,
1173
+ initialFocus: s = 0,
1174
+ returnFocus: a = !0,
1175
+ restoreFocus: l = !1,
1176
+ modal: c = !0,
1177
+ visuallyHiddenDismiss: f = !1,
1178
+ closeOnFocusOut: d = !0
1179
+ } = e, {
1180
+ open: h,
1181
+ refs: u,
1182
+ nodeId: m,
1183
+ onOpenChange: g,
1184
+ events: C,
1185
+ dataRef: x,
1186
+ floatingId: y,
1187
+ elements: {
1188
+ domReference: b,
1189
+ floating: w
1190
+ }
1191
+ } = r, _ = typeof s == "number" && s < 0, M = nr(b) && _, j = Qo() ? i : !0, $ = Pe(o), Z = Pe(s), G = Pe(a), q = It(), S = mr(), N = p.useRef(null), P = p.useRef(null), E = p.useRef(!1), D = p.useRef(!1), B = p.useRef(-1), k = S != null, R = pr(w), U = Ce(function(z) {
1192
+ return z === void 0 && (z = R), z ? nt(z, Ge()) : [];
1193
+ }), te = Ce((z) => {
1194
+ const T = U(z);
1195
+ return $.current.map((O) => b && O === "reference" ? b : R && O === "floating" ? R : T).filter(Boolean).flat();
1196
+ });
1197
+ p.useEffect(() => {
1198
+ E.current = !1;
1199
+ }, [n]), p.useEffect(() => {
1200
+ if (n || !c) return;
1201
+ function z(O) {
1202
+ if (O.key === "Tab") {
1203
+ de(R, Se(be(R))) && U().length === 0 && !M && fe(O);
1204
+ const F = te(), H = Le(O);
1205
+ $.current[0] === "reference" && H === b && (fe(O), O.shiftKey ? Ne(F[F.length - 1]) : Ne(F[1])), $.current[1] === "floating" && H === R && O.shiftKey && (fe(O), Ne(F[0]));
1206
+ }
1207
+ }
1208
+ const T = be(R);
1209
+ return T.addEventListener("keydown", z), () => {
1210
+ T.removeEventListener("keydown", z);
1211
+ };
1212
+ }, [n, b, R, c, $, M, U, te]), p.useEffect(() => {
1213
+ if (n || !w) return;
1214
+ function z(T) {
1215
+ const O = Le(T), H = U().indexOf(O);
1216
+ H !== -1 && (B.current = H);
1217
+ }
1218
+ return w.addEventListener("focusin", z), () => {
1219
+ w.removeEventListener("focusin", z);
1220
+ };
1221
+ }, [n, w, U]), p.useEffect(() => {
1222
+ if (n || !d) return;
1223
+ function z() {
1224
+ D.current = !0, setTimeout(() => {
1225
+ D.current = !1;
1226
+ });
1227
+ }
1228
+ function T(O) {
1229
+ const F = O.relatedTarget;
1230
+ queueMicrotask(() => {
1231
+ const H = !(de(b, F) || de(w, F) || de(F, w) || de(S?.portalNode, F) || F != null && F.hasAttribute(Xe("focus-guard")) || q && (We(q.nodesRef.current, m).find((ee) => {
1232
+ var ne, Y;
1233
+ return de((ne = ee.context) == null ? void 0 : ne.elements.floating, F) || de((Y = ee.context) == null ? void 0 : Y.elements.domReference, F);
1234
+ }) || Zo(q.nodesRef.current, m).find((ee) => {
1235
+ var ne, Y;
1236
+ return ((ne = ee.context) == null ? void 0 : ne.elements.floating) === F || ((Y = ee.context) == null ? void 0 : Y.elements.domReference) === F;
1237
+ })));
1238
+ if (l && H && Se(be(R)) === be(R).body) {
1239
+ Oe(R) && R.focus();
1240
+ const ee = B.current, ne = U(), Y = ne[ee] || ne[ne.length - 1] || R;
1241
+ Oe(Y) && Y.focus();
1242
+ }
1243
+ (M || !c) && F && H && !D.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
1244
+ F !== Sn() && (E.current = !0, g(!1, O, "focus-out"));
1245
+ });
1246
+ }
1247
+ if (w && Oe(b))
1248
+ return b.addEventListener("focusout", T), b.addEventListener("pointerdown", z), w.addEventListener("focusout", T), () => {
1249
+ b.removeEventListener("focusout", T), b.removeEventListener("pointerdown", z), w.removeEventListener("focusout", T);
1250
+ };
1251
+ }, [n, b, w, R, c, m, q, S, g, d, l, U, M]), p.useEffect(() => {
1252
+ var z;
1253
+ if (n) return;
1254
+ const T = Array.from((S == null || (z = S.portalNode) == null ? void 0 : z.querySelectorAll("[" + Xe("portal") + "]")) || []);
1255
+ if (w) {
1256
+ const O = [w, ...T, N.current, P.current, $.current.includes("reference") || M ? b : null].filter((H) => H != null), F = c || M ? Cn(O, j, !j) : Cn(O);
1257
+ return () => {
1258
+ F();
1259
+ };
1260
+ }
1261
+ }, [n, b, w, c, $, S, M, j]), Q(() => {
1262
+ if (n || !Oe(R)) return;
1263
+ const z = be(R), T = Se(z);
1264
+ queueMicrotask(() => {
1265
+ const O = te(R), F = Z.current, H = (typeof F == "number" ? O[F] : F.current) || R, ee = de(R, T);
1266
+ !_ && !ee && h && Ne(H, {
1267
+ preventScroll: H === R
1268
+ });
1269
+ });
1270
+ }, [n, h, R, _, te, Z]), Q(() => {
1271
+ if (n || !R) return;
1272
+ let z = !1;
1273
+ const T = be(R), O = Se(T);
1274
+ let H = x.current.openEvent;
1275
+ const ee = u.domReference.current;
1276
+ zt(O);
1277
+ function ne(Y) {
1278
+ let {
1279
+ open: Ie,
1280
+ reason: Ee,
1281
+ event: J,
1282
+ nested: Re
1283
+ } = Y;
1284
+ Ie && (H = J), Ee === "escape-key" && u.domReference.current && zt(u.domReference.current), Ee === "hover" && J.type === "mouseleave" && (E.current = !0), Ee === "outside-press" && (Re ? (E.current = !1, z = !0) : E.current = !(Qn(J) || er(J)));
1285
+ }
1286
+ return C.on("openchange", ne), () => {
1287
+ C.off("openchange", ne);
1288
+ const Y = Se(T), Ie = de(w, Y) || q && We(q.nodesRef.current, m).some((me) => {
1289
+ var _e;
1290
+ return de((_e = me.context) == null ? void 0 : _e.elements.floating, Y);
1291
+ });
1292
+ (Ie || H && ["click", "mousedown"].includes(H.type)) && u.domReference.current && zt(u.domReference.current);
1293
+ const J = ee || O, Re = nt(be(J).body, Ge());
1294
+ queueMicrotask(() => {
1295
+ let me = Sn();
1296
+ !me && Oe(J) && w && (me = ri(Re, J, w)), // eslint-disable-next-line react-hooks/exhaustive-deps
1297
+ G.current && !E.current && Oe(me) && // If the focus moved somewhere else after mount, avoid returning focus
1298
+ // since it likely entered a different element which should be
1299
+ // respected: https://github.com/floating-ui/floating-ui/issues/2607
1300
+ (!(me !== Y && Y !== T.body) || Ie) && me.focus({
1301
+ preventScroll: z
1302
+ });
1303
+ });
1304
+ };
1305
+ }, [n, w, R, G, x, u, C, q, m]), Q(() => {
1306
+ if (!n && S)
1307
+ return S.setFocusManagerState({
1308
+ modal: c,
1309
+ closeOnFocusOut: d,
1310
+ open: h,
1311
+ onOpenChange: g,
1312
+ refs: u
1313
+ }), () => {
1314
+ S.setFocusManagerState(null);
1315
+ };
1316
+ }, [n, S, c, h, g, u, d]), Q(() => {
1317
+ if (n || !R || typeof MutationObserver != "function" || _) return;
1318
+ const z = () => {
1319
+ const O = R.getAttribute("tabindex"), F = U(), H = Se(be(w)), ee = F.indexOf(H);
1320
+ ee !== -1 && (B.current = ee), $.current.includes("floating") || H !== u.domReference.current && F.length === 0 ? O !== "0" && R.setAttribute("tabindex", "0") : O !== "-1" && R.setAttribute("tabindex", "-1");
1321
+ };
1322
+ z();
1323
+ const T = new MutationObserver(z);
1324
+ return T.observe(R, {
1325
+ childList: !0,
1326
+ subtree: !0,
1327
+ attributes: !0
1328
+ }), () => {
1329
+ T.disconnect();
1330
+ };
1331
+ }, [n, w, R, u, $, U, _]);
1332
+ function xe(z) {
1333
+ return n || !f || !c ? null : /* @__PURE__ */ p.createElement(ai, {
1334
+ ref: z === "start" ? N : P,
1335
+ onClick: (T) => g(!1, T.nativeEvent)
1336
+ }, typeof f == "string" ? f : "Dismiss");
1337
+ }
1338
+ const he = !n && j && (c ? !M : !0) && (k || c);
1339
+ return /* @__PURE__ */ p.createElement(p.Fragment, null, he && /* @__PURE__ */ p.createElement(wt, {
1340
+ "data-type": "inside",
1341
+ ref: S?.beforeInsideRef,
1342
+ onFocus: (z) => {
1343
+ if (c) {
1344
+ const O = te();
1345
+ Ne(o[0] === "reference" ? O[0] : O[O.length - 1]);
1346
+ } else if (S != null && S.preserveTabOrder && S.portalNode)
1347
+ if (E.current = !1, tt(z, S.portalNode)) {
1348
+ const O = dr() || b;
1349
+ O?.focus();
1350
+ } else {
1351
+ var T;
1352
+ (T = S.beforeOutsideRef.current) == null || T.focus();
1353
+ }
1354
+ }
1355
+ }), !M && xe("start"), t, xe("end"), he && /* @__PURE__ */ p.createElement(wt, {
1356
+ "data-type": "inside",
1357
+ ref: S?.afterInsideRef,
1358
+ onFocus: (z) => {
1359
+ if (c)
1360
+ Ne(te()[0]);
1361
+ else if (S != null && S.preserveTabOrder && S.portalNode)
1362
+ if (d && (E.current = !0), tt(z, S.portalNode)) {
1363
+ const O = fr() || b;
1364
+ O?.focus();
1365
+ } else {
1366
+ var T;
1367
+ (T = S.afterOutsideRef.current) == null || T.focus();
1368
+ }
1369
+ }
1370
+ }));
1371
+ }
1372
+ const ci = {
1373
+ pointerdown: "onPointerDown",
1374
+ mousedown: "onMouseDown",
1375
+ click: "onClick"
1376
+ }, ui = {
1377
+ pointerdown: "onPointerDownCapture",
1378
+ mousedown: "onMouseDownCapture",
1379
+ click: "onClickCapture"
1380
+ }, Tn = (e) => {
1381
+ var r, t;
1382
+ return {
1383
+ escapeKey: typeof e == "boolean" ? e : (r = e?.escapeKey) != null ? r : !1,
1384
+ outsidePress: typeof e == "boolean" ? e : (t = e?.outsidePress) != null ? t : !0
1385
+ };
1386
+ };
1387
+ function di(e, r) {
1388
+ r === void 0 && (r = {});
1389
+ const {
1390
+ open: t,
1391
+ onOpenChange: n,
1392
+ elements: o,
1393
+ dataRef: i
1394
+ } = e, {
1395
+ enabled: s = !0,
1396
+ escapeKey: a = !0,
1397
+ outsidePress: l = !0,
1398
+ outsidePressEvent: c = "pointerdown",
1399
+ referencePress: f = !1,
1400
+ referencePressEvent: d = "pointerdown",
1401
+ ancestorScroll: h = !1,
1402
+ bubbles: u,
1403
+ capture: m
1404
+ } = r, g = It(), C = Ce(typeof l == "function" ? l : () => !1), x = typeof l == "function" ? C : l, y = p.useRef(!1), b = p.useRef(!1), {
1405
+ escapeKey: w,
1406
+ outsidePress: _
1407
+ } = Tn(u), {
1408
+ escapeKey: M,
1409
+ outsidePress: j
1410
+ } = Tn(m), $ = Ce((P) => {
1411
+ var E;
1412
+ if (!t || !s || !a || P.key !== "Escape")
1413
+ return;
1414
+ const D = (E = i.current.floatingContext) == null ? void 0 : E.nodeId, B = g ? We(g.nodesRef.current, D) : [];
1415
+ if (!w && (P.stopPropagation(), B.length > 0)) {
1416
+ let k = !0;
1417
+ if (B.forEach((R) => {
1418
+ var U;
1419
+ if ((U = R.context) != null && U.open && !R.context.dataRef.current.__escapeKeyBubbles) {
1420
+ k = !1;
1421
+ return;
1422
+ }
1423
+ }), !k)
1424
+ return;
1425
+ }
1426
+ n(!1, uo(P) ? P.nativeEvent : P, "escape-key");
1427
+ }), Z = Ce((P) => {
1428
+ var E;
1429
+ const D = () => {
1430
+ var B;
1431
+ $(P), (B = Le(P)) == null || B.removeEventListener("keydown", D);
1432
+ };
1433
+ (E = Le(P)) == null || E.addEventListener("keydown", D);
1434
+ }), G = Ce((P) => {
1435
+ var E;
1436
+ const D = y.current;
1437
+ y.current = !1;
1438
+ const B = b.current;
1439
+ if (b.current = !1, c === "click" && B || D || typeof x == "function" && !x(P))
1440
+ return;
1441
+ const k = Le(P), R = "[" + Xe("inert") + "]", U = be(o.floating).querySelectorAll(R);
1442
+ let te = ge(k) ? k : null;
1443
+ for (; te && !mn(te); ) {
1444
+ const T = ao(te);
1445
+ if (mn(T) || !ge(T))
1446
+ break;
1447
+ te = T;
1448
+ }
1449
+ if (U.length && ge(k) && !fo(k) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
1450
+ !de(k, o.floating) && // If the target root element contains none of the markers, then the
1451
+ // element was injected after the floating element rendered.
1452
+ Array.from(U).every((T) => !de(te, T)))
1453
+ return;
1454
+ if (Oe(k) && N) {
1455
+ const T = k.clientWidth > 0 && k.scrollWidth > k.clientWidth, O = k.clientHeight > 0 && k.scrollHeight > k.clientHeight;
1456
+ let F = O && P.offsetX > k.clientWidth;
1457
+ if (O && so(k).direction === "rtl" && (F = P.offsetX <= k.offsetWidth - k.clientWidth), F || T && P.offsetY > k.clientHeight)
1458
+ return;
1459
+ }
1460
+ const xe = (E = i.current.floatingContext) == null ? void 0 : E.nodeId, he = g && We(g.nodesRef.current, xe).some((T) => {
1461
+ var O;
1462
+ return Dt(P, (O = T.context) == null ? void 0 : O.elements.floating);
1463
+ });
1464
+ if (Dt(P, o.floating) || Dt(P, o.domReference) || he)
1465
+ return;
1466
+ const z = g ? We(g.nodesRef.current, xe) : [];
1467
+ if (z.length > 0) {
1468
+ let T = !0;
1469
+ if (z.forEach((O) => {
1470
+ var F;
1471
+ if ((F = O.context) != null && F.open && !O.context.dataRef.current.__outsidePressBubbles) {
1472
+ T = !1;
1473
+ return;
1474
+ }
1475
+ }), !T)
1476
+ return;
1477
+ }
1478
+ n(!1, P, "outside-press");
1479
+ }), q = Ce((P) => {
1480
+ var E;
1481
+ const D = () => {
1482
+ var B;
1483
+ G(P), (B = Le(P)) == null || B.removeEventListener(c, D);
1484
+ };
1485
+ (E = Le(P)) == null || E.addEventListener(c, D);
1486
+ });
1487
+ p.useEffect(() => {
1488
+ if (!t || !s)
1489
+ return;
1490
+ i.current.__escapeKeyBubbles = w, i.current.__outsidePressBubbles = _;
1491
+ function P(B) {
1492
+ n(!1, B, "ancestor-scroll");
1493
+ }
1494
+ const E = be(o.floating);
1495
+ a && E.addEventListener("keydown", M ? Z : $, M), x && E.addEventListener(c, j ? q : G, j);
1496
+ let D = [];
1497
+ return h && (ge(o.domReference) && (D = Mt(o.domReference)), ge(o.floating) && (D = D.concat(Mt(o.floating))), !ge(o.reference) && o.reference && o.reference.contextElement && (D = D.concat(Mt(o.reference.contextElement)))), D = D.filter((B) => {
1498
+ var k;
1499
+ return B !== ((k = E.defaultView) == null ? void 0 : k.visualViewport);
1500
+ }), D.forEach((B) => {
1501
+ B.addEventListener("scroll", P, {
1502
+ passive: !0
1503
+ });
1504
+ }), () => {
1505
+ a && E.removeEventListener("keydown", M ? Z : $, M), x && E.removeEventListener(c, j ? q : G, j), D.forEach((B) => {
1506
+ B.removeEventListener("scroll", P);
1507
+ });
1508
+ };
1509
+ }, [i, o, a, x, c, t, n, h, s, w, _, $, M, Z, G, j, q]), p.useEffect(() => {
1510
+ y.current = !1;
1511
+ }, [x, c]);
1512
+ const S = p.useMemo(() => ({
1513
+ onKeyDown: $,
1514
+ [ci[d]]: (P) => {
1515
+ f && n(!1, P.nativeEvent, "reference-press");
1516
+ }
1517
+ }), [$, n, f, d]), N = p.useMemo(() => ({
1518
+ onKeyDown: $,
1519
+ onMouseDown() {
1520
+ b.current = !0;
1521
+ },
1522
+ onMouseUp() {
1523
+ b.current = !0;
1524
+ },
1525
+ [ui[c]]: () => {
1526
+ y.current = !0;
1527
+ }
1528
+ }), [$, c]);
1529
+ return p.useMemo(() => s ? {
1530
+ reference: S,
1531
+ floating: N
1532
+ } : {}, [s, S, N]);
1533
+ }
1534
+ function fi(e) {
1535
+ const {
1536
+ open: r = !1,
1537
+ onOpenChange: t,
1538
+ elements: n
1539
+ } = e, o = Jt(), i = p.useRef({}), [s] = p.useState(() => Xo()), a = Qt() != null;
1540
+ if (process.env.NODE_ENV !== "production") {
1541
+ const u = n.reference;
1542
+ u && !ge(u) && Uo("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
1543
+ }
1544
+ const [l, c] = p.useState(n.reference), f = Ce((u, m, g) => {
1545
+ i.current.openEvent = u ? m : void 0, s.emit("openchange", {
1546
+ open: u,
1547
+ event: m,
1548
+ reason: g,
1549
+ nested: a
1550
+ }), t?.(u, m, g);
1551
+ }), d = p.useMemo(() => ({
1552
+ setPositionReference: c
1553
+ }), []), h = p.useMemo(() => ({
1554
+ reference: l || n.reference || null,
1555
+ floating: n.floating || null,
1556
+ domReference: n.reference
1557
+ }), [l, n.reference, n.floating]);
1558
+ return p.useMemo(() => ({
1559
+ dataRef: i,
1560
+ open: r,
1561
+ onOpenChange: f,
1562
+ elements: h,
1563
+ events: s,
1564
+ floatingId: o,
1565
+ refs: d
1566
+ }), [r, f, h, s, o, d]);
1567
+ }
1568
+ function hi(e) {
1569
+ e === void 0 && (e = {});
1570
+ const {
1571
+ nodeId: r
1572
+ } = e, t = fi({
1573
+ ...e,
1574
+ elements: {
1575
+ reference: null,
1576
+ floating: null,
1577
+ ...e.elements
1578
+ }
1579
+ }), n = e.rootContext || t, o = n.elements, [i, s] = p.useState(null), [a, l] = p.useState(null), f = o?.reference || i, d = p.useRef(null), h = It();
1580
+ Q(() => {
1581
+ f && (d.current = f);
1582
+ }, [f]);
1583
+ const u = Ao({
1584
+ ...e,
1585
+ elements: {
1586
+ ...o,
1587
+ ...a && {
1588
+ reference: a
1589
+ }
1590
+ }
1591
+ }), m = p.useCallback((b) => {
1592
+ const w = ge(b) ? {
1593
+ getBoundingClientRect: () => b.getBoundingClientRect(),
1594
+ contextElement: b
1595
+ } : b;
1596
+ l(w), u.refs.setReference(w);
1597
+ }, [u.refs]), g = p.useCallback((b) => {
1598
+ (ge(b) || b === null) && (d.current = b, s(b)), (ge(u.refs.reference.current) || u.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
1599
+ // `null` to support `positionReference` + an unstable `reference`
1600
+ // callback ref.
1601
+ b !== null && !ge(b)) && u.refs.setReference(b);
1602
+ }, [u.refs]), C = p.useMemo(() => ({
1603
+ ...u.refs,
1604
+ setReference: g,
1605
+ setPositionReference: m,
1606
+ domReference: d
1607
+ }), [u.refs, g, m]), x = p.useMemo(() => ({
1608
+ ...u.elements,
1609
+ domReference: f
1610
+ }), [u.elements, f]), y = p.useMemo(() => ({
1611
+ ...u,
1612
+ ...n,
1613
+ refs: C,
1614
+ elements: x,
1615
+ nodeId: r
1616
+ }), [u, C, x, r, n]);
1617
+ return Q(() => {
1618
+ n.dataRef.current.floatingContext = y;
1619
+ const b = h?.nodesRef.current.find((w) => w.id === r);
1620
+ b && (b.context = y);
1621
+ }), p.useMemo(() => ({
1622
+ ...u,
1623
+ context: y,
1624
+ refs: C,
1625
+ elements: x
1626
+ }), [u, C, x, y]);
1627
+ }
1628
+ const kn = "active", Mn = "selected";
1629
+ function Vt(e, r, t) {
1630
+ const n = /* @__PURE__ */ new Map(), o = t === "item";
1631
+ let i = e;
1632
+ if (o && e) {
1633
+ const {
1634
+ [kn]: s,
1635
+ [Mn]: a,
1636
+ ...l
1637
+ } = e;
1638
+ i = l;
1639
+ }
1640
+ return {
1641
+ ...t === "floating" && {
1642
+ tabIndex: -1,
1643
+ [qt]: ""
1644
+ },
1645
+ ...i,
1646
+ ...r.map((s) => {
1647
+ const a = s ? s[t] : null;
1648
+ return typeof a == "function" ? e ? a(e) : null : a;
1649
+ }).concat(e).reduce((s, a) => (a && Object.entries(a).forEach((l) => {
1650
+ let [c, f] = l;
1651
+ if (!(o && [kn, Mn].includes(c)))
1652
+ if (c.indexOf("on") === 0) {
1653
+ if (n.has(c) || n.set(c, []), typeof f == "function") {
1654
+ var d;
1655
+ (d = n.get(c)) == null || d.push(f), s[c] = function() {
1656
+ for (var h, u = arguments.length, m = new Array(u), g = 0; g < u; g++)
1657
+ m[g] = arguments[g];
1658
+ return (h = n.get(c)) == null ? void 0 : h.map((C) => C(...m)).find((C) => C !== void 0);
1659
+ };
1660
+ }
1661
+ } else
1662
+ s[c] = f;
1663
+ }), s), {})
1664
+ };
1665
+ }
1666
+ function mi(e) {
1667
+ e === void 0 && (e = []);
1668
+ const r = e.map((a) => a?.reference), t = e.map((a) => a?.floating), n = e.map((a) => a?.item), o = p.useCallback(
1669
+ (a) => Vt(a, e, "reference"),
1670
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1671
+ r
1672
+ ), i = p.useCallback(
1673
+ (a) => Vt(a, e, "floating"),
1674
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1675
+ t
1676
+ ), s = p.useCallback(
1677
+ (a) => Vt(a, e, "item"),
1678
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1679
+ n
1680
+ );
1681
+ return p.useMemo(() => ({
1682
+ getReferenceProps: o,
1683
+ getFloatingProps: i,
1684
+ getItemProps: s
1685
+ }), [o, i, s]);
1686
+ }
1687
+ let Nn = !1;
1688
+ function Rt(e, r, t) {
1689
+ switch (e) {
1690
+ case "vertical":
1691
+ return r;
1692
+ case "horizontal":
1693
+ return t;
1694
+ default:
1695
+ return r || t;
1696
+ }
1697
+ }
1698
+ function Pn(e, r) {
1699
+ return Rt(r, e === Zt || e === st, e === Ue || e === Ze);
1700
+ }
1701
+ function Bt(e, r, t) {
1702
+ return Rt(r, e === st, t ? e === Ue : e === Ze) || e === "Enter" || e === " " || e === "";
1703
+ }
1704
+ function pi(e, r, t) {
1705
+ return Rt(r, t ? e === Ue : e === Ze, e === st);
1706
+ }
1707
+ function Dn(e, r, t) {
1708
+ return Rt(r, t ? e === Ze : e === Ue, e === Zt);
1709
+ }
1710
+ function bi(e, r) {
1711
+ const {
1712
+ open: t,
1713
+ onOpenChange: n,
1714
+ elements: o
1715
+ } = e, {
1716
+ listRef: i,
1717
+ activeIndex: s,
1718
+ onNavigate: a = () => {
1719
+ },
1720
+ enabled: l = !0,
1721
+ selectedIndex: c = null,
1722
+ allowEscape: f = !1,
1723
+ loop: d = !1,
1724
+ nested: h = !1,
1725
+ rtl: u = !1,
1726
+ virtual: m = !1,
1727
+ focusItemOnOpen: g = "auto",
1728
+ focusItemOnHover: C = !0,
1729
+ openOnArrowKeyDown: x = !0,
1730
+ disabledIndices: y = void 0,
1731
+ orientation: b = "vertical",
1732
+ cols: w = 1,
1733
+ scrollItemIntoView: _ = !0,
1734
+ virtualItemRef: M,
1735
+ itemSizes: j,
1736
+ dense: $ = !1
1737
+ } = r;
1738
+ process.env.NODE_ENV !== "production" && (f && (d || Ft("`useListNavigation` looping must be enabled to allow escaping."), m || Ft("`useListNavigation` must be virtual to allow escaping.")), b === "vertical" && w > 1 && Ft("In grid list navigation mode (`cols` > 1), the `orientation` should", 'be either "horizontal" or "both".'));
1739
+ const Z = pr(o.floating), G = Pe(Z), q = Qt(), S = It(), N = Ce(a), P = p.useRef(g), E = p.useRef(c ?? -1), D = p.useRef(null), B = p.useRef(!0), k = p.useRef(N), R = p.useRef(!!o.floating), U = p.useRef(t), te = p.useRef(!1), xe = p.useRef(!1), he = Pe(y), z = Pe(t), T = Pe(_), O = Pe(c), [F, H] = p.useState(), [ee, ne] = p.useState(), Y = Ce(function(L, V, I) {
1740
+ I === void 0 && (I = !1);
1741
+ function W(K) {
1742
+ m ? (H(K.id), S?.events.emit("virtualfocus", K), M && (M.current = K)) : Ne(K, {
1743
+ preventScroll: !0,
1744
+ // Mac Safari does not move the virtual cursor unless the focus call
1745
+ // is sync. However, for the very first focus call, we need to wait
1746
+ // for the position to be ready in order to prevent unwanted
1747
+ // scrolling. This means the virtual cursor will not move to the first
1748
+ // item when first opening the floating element, but will on
1749
+ // subsequent calls. `preventScroll` is supported in modern Safari,
1750
+ // so we can use that instead.
1751
+ // iOS Safari must be async or the first item will not be focused.
1752
+ sync: lo() && tr() ? Nn || te.current : !1
1753
+ });
1754
+ }
1755
+ const ae = L.current[V.current];
1756
+ ae && W(ae), requestAnimationFrame(() => {
1757
+ const K = L.current[V.current] || ae;
1758
+ if (!K) return;
1759
+ ae || W(K);
1760
+ const re = T.current;
1761
+ re && Ee && (I || !B.current) && (K.scrollIntoView == null || K.scrollIntoView(typeof re == "boolean" ? {
1762
+ block: "nearest",
1763
+ inline: "nearest"
1764
+ } : re));
1765
+ });
1766
+ });
1767
+ Q(() => {
1768
+ document.createElement("div").focus({
1769
+ get preventScroll() {
1770
+ return Nn = !0, !1;
1771
+ }
1772
+ });
1773
+ }, []), Q(() => {
1774
+ l && (t && o.floating ? P.current && c != null && (xe.current = !0, E.current = c, N(c)) : R.current && (E.current = -1, k.current(null)));
1775
+ }, [l, t, o.floating, c, N]), Q(() => {
1776
+ if (l && t && o.floating)
1777
+ if (s == null) {
1778
+ if (te.current = !1, O.current != null)
1779
+ return;
1780
+ if (R.current && (E.current = -1, Y(i, E)), (!U.current || !R.current) && P.current && (D.current != null || P.current === !0 && D.current == null)) {
1781
+ let L = 0;
1782
+ const V = () => {
1783
+ i.current[0] == null ? (L < 2 && (L ? requestAnimationFrame : queueMicrotask)(V), L++) : (E.current = D.current == null || Bt(D.current, b, u) || h ? _t(i, he.current) : vn(i, he.current), D.current = null, N(E.current));
1784
+ };
1785
+ V();
1786
+ }
1787
+ } else et(i, s) || (E.current = s, Y(i, E, xe.current), xe.current = !1);
1788
+ }, [l, t, o.floating, s, O, h, i, b, u, N, Y, he]), Q(() => {
1789
+ var L;
1790
+ if (!l || o.floating || !S || m || !R.current)
1791
+ return;
1792
+ const V = S.nodesRef.current, I = (L = V.find((K) => K.id === q)) == null || (L = L.context) == null ? void 0 : L.elements.floating, W = Se(be(o.floating)), ae = V.some((K) => K.context && de(K.context.elements.floating, W));
1793
+ I && !ae && B.current && I.focus({
1794
+ preventScroll: !0
1795
+ });
1796
+ }, [l, o.floating, S, q, m]), Q(() => {
1797
+ if (!l || !S || !m || q) return;
1798
+ function L(V) {
1799
+ ne(V.id), M && (M.current = V);
1800
+ }
1801
+ return S.events.on("virtualfocus", L), () => {
1802
+ S.events.off("virtualfocus", L);
1803
+ };
1804
+ }, [l, S, m, q, M]), Q(() => {
1805
+ k.current = N, R.current = !!o.floating;
1806
+ }), Q(() => {
1807
+ t || (D.current = null);
1808
+ }, [t]), Q(() => {
1809
+ U.current = t;
1810
+ }, [t]);
1811
+ const Ie = s != null, Ee = p.useMemo(() => {
1812
+ function L(I) {
1813
+ if (!t) return;
1814
+ const W = i.current.indexOf(I);
1815
+ W !== -1 && N(W);
1816
+ }
1817
+ return {
1818
+ onFocus(I) {
1819
+ let {
1820
+ currentTarget: W
1821
+ } = I;
1822
+ L(W);
1823
+ },
1824
+ onClick: (I) => {
1825
+ let {
1826
+ currentTarget: W
1827
+ } = I;
1828
+ return W.focus({
1829
+ preventScroll: !0
1830
+ });
1831
+ },
1832
+ // Safari
1833
+ ...C && {
1834
+ onMouseMove(I) {
1835
+ let {
1836
+ currentTarget: W
1837
+ } = I;
1838
+ L(W);
1839
+ },
1840
+ onPointerLeave(I) {
1841
+ let {
1842
+ pointerType: W
1843
+ } = I;
1844
+ !B.current || W === "touch" || (E.current = -1, Y(i, E), N(null), m || Ne(G.current, {
1845
+ preventScroll: !0
1846
+ }));
1847
+ }
1848
+ }
1849
+ };
1850
+ }, [t, G, Y, C, i, N, m]), J = Ce((L) => {
1851
+ if (B.current = !1, te.current = !0, !z.current && L.currentTarget === G.current)
1852
+ return;
1853
+ if (h && Dn(L.key, b, u)) {
1854
+ fe(L), n(!1, L.nativeEvent, "list-navigation"), Oe(o.domReference) && !m && o.domReference.focus();
1855
+ return;
1856
+ }
1857
+ const V = E.current, I = _t(i, y), W = vn(i, y);
1858
+ if (L.key === "Home" && (fe(L), E.current = I, N(E.current)), L.key === "End" && (fe(L), E.current = W, N(E.current)), w > 1) {
1859
+ const ae = j || Array.from({
1860
+ length: i.current.length
1861
+ }, () => ({
1862
+ width: 1,
1863
+ height: 1
1864
+ })), K = jo(ae, w, $), re = K.findIndex((we) => we != null && !mt(i.current, we, y)), je = K.reduce((we, ke, lt) => ke != null && !mt(i.current, ke, y) ? lt : we, -1), Je = K[Bo({
1865
+ current: K.map((we) => we != null ? i.current[we] : null)
1866
+ }, {
1867
+ event: L,
1868
+ orientation: b,
1869
+ loop: d,
1870
+ cols: w,
1871
+ // treat undefined (empty grid spaces) as disabled indices so we
1872
+ // don't end up in them
1873
+ disabledIndices: Ko([...y || i.current.map((we, ke) => mt(i.current, ke) ? ke : void 0), void 0], K),
1874
+ minIndex: re,
1875
+ maxIndex: je,
1876
+ prevIndex: $o(
1877
+ E.current > W ? I : E.current,
1878
+ ae,
1879
+ K,
1880
+ w,
1881
+ // use a corner matching the edge closest to the direction
1882
+ // we're moving in so we don't end up in the same item. Prefer
1883
+ // top/left over bottom/right.
1884
+ L.key === st ? "bl" : L.key === Ze ? "tr" : "tl"
1885
+ ),
1886
+ stopEvent: !0
1887
+ })];
1888
+ if (Je != null && (E.current = Je, N(E.current)), b === "both")
1889
+ return;
1890
+ }
1891
+ if (Pn(L.key, b)) {
1892
+ if (fe(L), t && !m && Se(L.currentTarget.ownerDocument) === L.currentTarget) {
1893
+ E.current = Bt(L.key, b, u) ? I : W, N(E.current);
1894
+ return;
1895
+ }
1896
+ Bt(L.key, b, u) ? d ? E.current = V >= W ? f && V !== i.current.length ? -1 : I : le(i, {
1897
+ startingIndex: V,
1898
+ disabledIndices: y
1899
+ }) : E.current = Math.min(W, le(i, {
1900
+ startingIndex: V,
1901
+ disabledIndices: y
1902
+ })) : d ? E.current = V <= I ? f && V !== -1 ? i.current.length : W : le(i, {
1903
+ startingIndex: V,
1904
+ decrement: !0,
1905
+ disabledIndices: y
1906
+ }) : E.current = Math.max(I, le(i, {
1907
+ startingIndex: V,
1908
+ decrement: !0,
1909
+ disabledIndices: y
1910
+ })), et(i, E.current) ? N(null) : N(E.current);
1911
+ }
1912
+ }), Re = p.useMemo(() => m && t && Ie && {
1913
+ "aria-activedescendant": ee || F
1914
+ }, [m, t, Ie, ee, F]), me = p.useMemo(() => ({
1915
+ "aria-orientation": b === "both" ? void 0 : b,
1916
+ ...!nr(o.domReference) && Re,
1917
+ onKeyDown: J,
1918
+ onPointerMove() {
1919
+ B.current = !0;
1920
+ }
1921
+ }), [Re, J, o.domReference, b]), _e = p.useMemo(() => {
1922
+ function L(I) {
1923
+ g === "auto" && Qn(I.nativeEvent) && (P.current = !0);
1924
+ }
1925
+ function V(I) {
1926
+ P.current = g, g === "auto" && er(I.nativeEvent) && (P.current = !0);
1927
+ }
1928
+ return {
1929
+ ...Re,
1930
+ onKeyDown(I) {
1931
+ B.current = !1;
1932
+ const W = I.key.indexOf("Arrow") === 0, ae = pi(I.key, b, u), K = Dn(I.key, b, u), re = Pn(I.key, b), je = (h ? ae : re) || I.key === "Enter" || I.key.trim() === "";
1933
+ if (m && t) {
1934
+ const lt = S?.nodesRef.current.find((ct) => ct.parentId == null), Me = S && lt ? Jo(S.nodesRef.current, lt.id) : null;
1935
+ if (W && Me && M) {
1936
+ const ct = new KeyboardEvent("keydown", {
1937
+ key: I.key,
1938
+ bubbles: !0
1939
+ });
1940
+ if (ae || K) {
1941
+ var Je, we;
1942
+ const zr = ((Je = Me.context) == null ? void 0 : Je.elements.domReference) === I.currentTarget, un = K && !zr ? (we = Me.context) == null ? void 0 : we.elements.domReference : ae ? i.current.find((dn) => dn?.id === F) : null;
1943
+ un && (fe(I), un.dispatchEvent(ct), ne(void 0));
1944
+ }
1945
+ if (re && Me.context && Me.context.open && Me.parentId && I.currentTarget !== Me.context.elements.domReference) {
1946
+ var ke;
1947
+ fe(I), (ke = Me.context.elements.domReference) == null || ke.dispatchEvent(ct);
1948
+ return;
1949
+ }
1950
+ }
1951
+ return J(I);
1952
+ }
1953
+ if (!(!t && !x && W)) {
1954
+ if (je && (D.current = h && re ? null : I.key), h) {
1955
+ ae && (fe(I), t ? (E.current = _t(i, he.current), N(E.current)) : n(!0, I.nativeEvent, "list-navigation"));
1956
+ return;
1957
+ }
1958
+ re && (c != null && (E.current = c), fe(I), !t && x ? n(!0, I.nativeEvent, "list-navigation") : J(I), t && N(E.current));
1959
+ }
1960
+ },
1961
+ onFocus() {
1962
+ t && !m && N(null);
1963
+ },
1964
+ onPointerDown: V,
1965
+ onMouseDown: L,
1966
+ onClick: L
1967
+ };
1968
+ }, [F, Re, J, he, g, i, h, N, n, t, x, b, u, c, S, m, M]);
1969
+ return p.useMemo(() => l ? {
1970
+ reference: _e,
1971
+ floating: me,
1972
+ item: Ee
1973
+ } : {}, [l, _e, me, Ee]);
1974
+ }
1975
+ const gi = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
1976
+ function vi(e, r) {
1977
+ var t;
1978
+ r === void 0 && (r = {});
1979
+ const {
1980
+ open: n,
1981
+ floatingId: o
1982
+ } = e, {
1983
+ enabled: i = !0,
1984
+ role: s = "dialog"
1985
+ } = r, a = (t = gi.get(s)) != null ? t : s, l = Jt(), f = Qt() != null, d = p.useMemo(() => a === "tooltip" || s === "label" ? {
1986
+ ["aria-" + (s === "label" ? "labelledby" : "describedby")]: n ? o : void 0
1987
+ } : {
1988
+ "aria-expanded": n ? "true" : "false",
1989
+ "aria-haspopup": a === "alertdialog" ? "dialog" : a,
1990
+ "aria-controls": n ? o : void 0,
1991
+ ...a === "listbox" && {
1992
+ role: "combobox"
1993
+ },
1994
+ ...a === "menu" && {
1995
+ id: l
1996
+ },
1997
+ ...a === "menu" && f && {
1998
+ role: "menuitem"
1999
+ },
2000
+ ...s === "select" && {
2001
+ "aria-autocomplete": "none"
2002
+ },
2003
+ ...s === "combobox" && {
2004
+ "aria-autocomplete": "list"
2005
+ }
2006
+ }, [a, o, f, n, l, s]), h = p.useMemo(() => {
2007
+ const m = {
2008
+ id: o,
2009
+ ...a && {
2010
+ role: a
2011
+ }
2012
+ };
2013
+ return a === "tooltip" || s === "label" ? m : {
2014
+ ...m,
2015
+ ...a === "menu" && {
2016
+ "aria-labelledby": l
2017
+ }
2018
+ };
2019
+ }, [a, o, l, s]), u = p.useCallback((m) => {
2020
+ let {
2021
+ active: g,
2022
+ selected: C
2023
+ } = m;
2024
+ const x = {
2025
+ role: "option",
2026
+ ...g && {
2027
+ id: o + "-option"
2028
+ }
2029
+ };
2030
+ switch (s) {
2031
+ case "select":
2032
+ return {
2033
+ ...x,
2034
+ "aria-selected": g && C
2035
+ };
2036
+ case "combobox":
2037
+ return {
2038
+ ...x,
2039
+ ...g && {
2040
+ "aria-selected": !0
2041
+ }
2042
+ };
2043
+ }
2044
+ return {};
2045
+ }, [o, s]);
2046
+ return p.useMemo(() => i ? {
2047
+ reference: d,
2048
+ floating: h,
2049
+ item: u
2050
+ } : {}, [i, d, h, u]);
2051
+ }
2052
+ function Ke(e, r, t) {
2053
+ let n = t.initialDeps ?? [], o, i = !0;
2054
+ function s() {
2055
+ var a, l, c;
2056
+ let f;
2057
+ t.key && ((a = t.debug) != null && a.call(t)) && (f = Date.now());
2058
+ const d = e();
2059
+ if (!(d.length !== n.length || d.some((m, g) => n[g] !== m)))
2060
+ return o;
2061
+ n = d;
2062
+ let u;
2063
+ if (t.key && ((l = t.debug) != null && l.call(t)) && (u = Date.now()), o = r(...d), t.key && ((c = t.debug) != null && c.call(t))) {
2064
+ const m = Math.round((Date.now() - f) * 100) / 100, g = Math.round((Date.now() - u) * 100) / 100, C = g / 16, x = (y, b) => {
2065
+ for (y = String(y); y.length < b; )
2066
+ y = " " + y;
2067
+ return y;
2068
+ };
2069
+ console.info(
2070
+ `%c⏱ ${x(g, 5)} /${x(m, 5)} ms`,
2071
+ `
2072
+ font-size: .6rem;
2073
+ font-weight: bold;
2074
+ color: hsl(${Math.max(
2075
+ 0,
2076
+ Math.min(120 - 120 * C, 120)
2077
+ )}deg 100% 31%);`,
2078
+ t?.key
2079
+ );
2080
+ }
2081
+ return t?.onChange && !(i && t.skipInitialOnChange) && t.onChange(o), i = !1, o;
2082
+ }
2083
+ return s.updateDeps = (a) => {
2084
+ n = a;
2085
+ }, s;
2086
+ }
2087
+ function An(e, r) {
2088
+ if (e === void 0)
2089
+ throw new Error("Unexpected undefined");
2090
+ return e;
2091
+ }
2092
+ const yi = (e, r) => Math.abs(e - r) < 1.01, xi = (e, r, t) => {
2093
+ let n;
2094
+ return function(...o) {
2095
+ e.clearTimeout(n), n = e.setTimeout(() => r.apply(this, o), t);
2096
+ };
2097
+ }, _n = (e) => {
2098
+ const { offsetWidth: r, offsetHeight: t } = e;
2099
+ return { width: r, height: t };
2100
+ }, wi = (e) => e, Ci = (e) => {
2101
+ const r = Math.max(e.startIndex - e.overscan, 0), t = Math.min(e.endIndex + e.overscan, e.count - 1), n = [];
2102
+ for (let o = r; o <= t; o++)
2103
+ n.push(o);
2104
+ return n;
2105
+ }, Ei = (e, r) => {
2106
+ const t = e.scrollElement;
2107
+ if (!t)
2108
+ return;
2109
+ const n = e.targetWindow;
2110
+ if (!n)
2111
+ return;
2112
+ const o = (s) => {
2113
+ const { width: a, height: l } = s;
2114
+ r({ width: Math.round(a), height: Math.round(l) });
2115
+ };
2116
+ if (o(_n(t)), !n.ResizeObserver)
2117
+ return () => {
2118
+ };
2119
+ const i = new n.ResizeObserver((s) => {
2120
+ const a = () => {
2121
+ const l = s[0];
2122
+ if (l?.borderBoxSize) {
2123
+ const c = l.borderBoxSize[0];
2124
+ if (c) {
2125
+ o({ width: c.inlineSize, height: c.blockSize });
2126
+ return;
2127
+ }
2128
+ }
2129
+ o(_n(t));
2130
+ };
2131
+ e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(a) : a();
2132
+ });
2133
+ return i.observe(t, { box: "border-box" }), () => {
2134
+ i.unobserve(t);
2135
+ };
2136
+ }, Fn = {
2137
+ passive: !0
2138
+ }, Ln = typeof window > "u" ? !0 : "onscrollend" in window, Ii = (e, r) => {
2139
+ const t = e.scrollElement;
2140
+ if (!t)
2141
+ return;
2142
+ const n = e.targetWindow;
2143
+ if (!n)
2144
+ return;
2145
+ let o = 0;
2146
+ const i = e.options.useScrollendEvent && Ln ? () => {
2147
+ } : xi(
2148
+ n,
2149
+ () => {
2150
+ r(o, !1);
2151
+ },
2152
+ e.options.isScrollingResetDelay
2153
+ ), s = (f) => () => {
2154
+ const { horizontal: d, isRtl: h } = e.options;
2155
+ o = d ? t.scrollLeft * (h && -1 || 1) : t.scrollTop, i(), r(o, f);
2156
+ }, a = s(!0), l = s(!1);
2157
+ t.addEventListener("scroll", a, Fn);
2158
+ const c = e.options.useScrollendEvent && Ln;
2159
+ return c && t.addEventListener("scrollend", l, Fn), () => {
2160
+ t.removeEventListener("scroll", a), c && t.removeEventListener("scrollend", l);
2161
+ };
2162
+ }, Ri = (e, r, t) => {
2163
+ if (r?.borderBoxSize) {
2164
+ const n = r.borderBoxSize[0];
2165
+ if (n)
2166
+ return Math.round(
2167
+ n[t.options.horizontal ? "inlineSize" : "blockSize"]
2168
+ );
2169
+ }
2170
+ return e[t.options.horizontal ? "offsetWidth" : "offsetHeight"];
2171
+ }, Oi = (e, {
2172
+ adjustments: r = 0,
2173
+ behavior: t
2174
+ }, n) => {
2175
+ var o, i;
2176
+ const s = e + r;
2177
+ (i = (o = n.scrollElement) == null ? void 0 : o.scrollTo) == null || i.call(o, {
2178
+ [n.options.horizontal ? "left" : "top"]: s,
2179
+ behavior: t
2180
+ });
2181
+ };
2182
+ class Si {
2183
+ constructor(r) {
2184
+ 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__ */ (() => {
2185
+ let t = null;
2186
+ const n = () => t || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : t = new this.targetWindow.ResizeObserver((o) => {
2187
+ o.forEach((i) => {
2188
+ const s = () => {
2189
+ this._measureElement(i.target, i);
2190
+ };
2191
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(s) : s();
2192
+ });
2193
+ }));
2194
+ return {
2195
+ disconnect: () => {
2196
+ var o;
2197
+ (o = n()) == null || o.disconnect(), t = null;
2198
+ },
2199
+ observe: (o) => {
2200
+ var i;
2201
+ return (i = n()) == null ? void 0 : i.observe(o, { box: "border-box" });
2202
+ },
2203
+ unobserve: (o) => {
2204
+ var i;
2205
+ return (i = n()) == null ? void 0 : i.unobserve(o);
2206
+ }
2207
+ };
2208
+ })(), this.range = null, this.setOptions = (t) => {
2209
+ Object.entries(t).forEach(([n, o]) => {
2210
+ typeof o > "u" && delete t[n];
2211
+ }), this.options = {
2212
+ debug: !1,
2213
+ initialOffset: 0,
2214
+ overscan: 1,
2215
+ paddingStart: 0,
2216
+ paddingEnd: 0,
2217
+ scrollPaddingStart: 0,
2218
+ scrollPaddingEnd: 0,
2219
+ horizontal: !1,
2220
+ getItemKey: wi,
2221
+ rangeExtractor: Ci,
2222
+ onChange: () => {
2223
+ },
2224
+ measureElement: Ri,
2225
+ initialRect: { width: 0, height: 0 },
2226
+ scrollMargin: 0,
2227
+ gap: 0,
2228
+ indexAttribute: "data-index",
2229
+ initialMeasurementsCache: [],
2230
+ lanes: 1,
2231
+ isScrollingResetDelay: 150,
2232
+ enabled: !0,
2233
+ isRtl: !1,
2234
+ useScrollendEvent: !1,
2235
+ useAnimationFrameWithResizeObserver: !1,
2236
+ ...t
2237
+ };
2238
+ }, this.notify = (t) => {
2239
+ var n, o;
2240
+ (o = (n = this.options).onChange) == null || o.call(n, this, t);
2241
+ }, this.maybeNotify = Ke(
2242
+ () => (this.calculateRange(), [
2243
+ this.isScrolling,
2244
+ this.range ? this.range.startIndex : null,
2245
+ this.range ? this.range.endIndex : null
2246
+ ]),
2247
+ (t) => {
2248
+ this.notify(t);
2249
+ },
2250
+ {
2251
+ key: process.env.NODE_ENV !== "production" && "maybeNotify",
2252
+ debug: () => this.options.debug,
2253
+ initialDeps: [
2254
+ this.isScrolling,
2255
+ this.range ? this.range.startIndex : null,
2256
+ this.range ? this.range.endIndex : null
2257
+ ]
2258
+ }
2259
+ ), this.cleanup = () => {
2260
+ this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
2261
+ }, this._didMount = () => () => {
2262
+ this.cleanup();
2263
+ }, this._willUpdate = () => {
2264
+ var t;
2265
+ const n = this.options.enabled ? this.options.getScrollElement() : null;
2266
+ if (this.scrollElement !== n) {
2267
+ if (this.cleanup(), !n) {
2268
+ this.maybeNotify();
2269
+ return;
2270
+ }
2271
+ this.scrollElement = n, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((t = this.scrollElement) == null ? void 0 : t.window) ?? null, this.elementsCache.forEach((o) => {
2272
+ this.observer.observe(o);
2273
+ }), this.unsubs.push(
2274
+ this.options.observeElementRect(this, (o) => {
2275
+ this.scrollRect = o, this.maybeNotify();
2276
+ })
2277
+ ), this.unsubs.push(
2278
+ this.options.observeElementOffset(this, (o, i) => {
2279
+ this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o, this.isScrolling = i, this.maybeNotify();
2280
+ })
2281
+ ), this._scrollToOffset(this.getScrollOffset(), {
2282
+ adjustments: void 0,
2283
+ behavior: void 0
2284
+ });
2285
+ }
2286
+ }, 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 = (t, n) => {
2287
+ const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
2288
+ for (let s = n - 1; s >= 0; s--) {
2289
+ const a = t[s];
2290
+ if (o.has(a.lane))
2291
+ continue;
2292
+ const l = i.get(
2293
+ a.lane
2294
+ );
2295
+ if (l == null || a.end > l.end ? i.set(a.lane, a) : a.end < l.end && o.set(a.lane, !0), o.size === this.options.lanes)
2296
+ break;
2297
+ }
2298
+ return i.size === this.options.lanes ? Array.from(i.values()).sort((s, a) => s.end === a.end ? s.index - a.index : s.end - a.end)[0] : void 0;
2299
+ }, this.getMeasurementOptions = Ke(
2300
+ () => [
2301
+ this.options.count,
2302
+ this.options.paddingStart,
2303
+ this.options.scrollMargin,
2304
+ this.options.getItemKey,
2305
+ this.options.enabled,
2306
+ this.options.lanes
2307
+ ],
2308
+ (t, n, o, i, s, a) => (this.prevLanes !== void 0 && this.prevLanes !== a && (this.lanesChangedFlag = !0), this.prevLanes = a, this.pendingMeasuredCacheIndexes = [], {
2309
+ count: t,
2310
+ paddingStart: n,
2311
+ scrollMargin: o,
2312
+ getItemKey: i,
2313
+ enabled: s,
2314
+ lanes: a
2315
+ }),
2316
+ {
2317
+ key: !1
2318
+ }
2319
+ ), this.getMeasurements = Ke(
2320
+ () => [this.getMeasurementOptions(), this.itemSizeCache],
2321
+ ({ count: t, paddingStart: n, scrollMargin: o, getItemKey: i, enabled: s, lanes: a }, l) => {
2322
+ if (!s)
2323
+ return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
2324
+ if (this.laneAssignments.size > t)
2325
+ for (const h of this.laneAssignments.keys())
2326
+ h >= t && this.laneAssignments.delete(h);
2327
+ this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMeasuredCacheIndexes = []), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((h) => {
2328
+ this.itemSizeCache.set(h.key, h.size);
2329
+ }));
2330
+ const c = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
2331
+ this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === t && (this.lanesSettling = !1);
2332
+ const f = this.measurementsCache.slice(0, c), d = new Array(a).fill(
2333
+ void 0
2334
+ );
2335
+ for (let h = 0; h < c; h++) {
2336
+ const u = f[h];
2337
+ u && (d[u.lane] = h);
2338
+ }
2339
+ for (let h = c; h < t; h++) {
2340
+ const u = i(h), m = this.laneAssignments.get(h);
2341
+ let g, C;
2342
+ if (m !== void 0 && this.options.lanes > 1) {
2343
+ g = m;
2344
+ const w = d[g], _ = w !== void 0 ? f[w] : void 0;
2345
+ C = _ ? _.end + this.options.gap : n + o;
2346
+ } else {
2347
+ const w = this.options.lanes === 1 ? f[h - 1] : this.getFurthestMeasurement(f, h);
2348
+ C = w ? w.end + this.options.gap : n + o, g = w ? w.lane : h % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(h, g);
2349
+ }
2350
+ const x = l.get(u), y = typeof x == "number" ? x : this.options.estimateSize(h), b = C + y;
2351
+ f[h] = {
2352
+ index: h,
2353
+ start: C,
2354
+ size: y,
2355
+ end: b,
2356
+ key: u,
2357
+ lane: g
2358
+ }, d[g] = h;
2359
+ }
2360
+ return this.measurementsCache = f, f;
2361
+ },
2362
+ {
2363
+ key: process.env.NODE_ENV !== "production" && "getMeasurements",
2364
+ debug: () => this.options.debug
2365
+ }
2366
+ ), this.calculateRange = Ke(
2367
+ () => [
2368
+ this.getMeasurements(),
2369
+ this.getSize(),
2370
+ this.getScrollOffset(),
2371
+ this.options.lanes
2372
+ ],
2373
+ (t, n, o, i) => this.range = t.length > 0 && n > 0 ? Ti({
2374
+ measurements: t,
2375
+ outerSize: n,
2376
+ scrollOffset: o,
2377
+ lanes: i
2378
+ }) : null,
2379
+ {
2380
+ key: process.env.NODE_ENV !== "production" && "calculateRange",
2381
+ debug: () => this.options.debug
2382
+ }
2383
+ ), this.getVirtualIndexes = Ke(
2384
+ () => {
2385
+ let t = null, n = null;
2386
+ const o = this.calculateRange();
2387
+ return o && (t = o.startIndex, n = o.endIndex), this.maybeNotify.updateDeps([this.isScrolling, t, n]), [
2388
+ this.options.rangeExtractor,
2389
+ this.options.overscan,
2390
+ this.options.count,
2391
+ t,
2392
+ n
2393
+ ];
2394
+ },
2395
+ (t, n, o, i, s) => i === null || s === null ? [] : t({
2396
+ startIndex: i,
2397
+ endIndex: s,
2398
+ overscan: n,
2399
+ count: o
2400
+ }),
2401
+ {
2402
+ key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
2403
+ debug: () => this.options.debug
2404
+ }
2405
+ ), this.indexFromElement = (t) => {
2406
+ const n = this.options.indexAttribute, o = t.getAttribute(n);
2407
+ return o ? parseInt(o, 10) : (console.warn(
2408
+ `Missing attribute name '${n}={index}' on measured element.`
2409
+ ), -1);
2410
+ }, this._measureElement = (t, n) => {
2411
+ const o = this.indexFromElement(t), i = this.measurementsCache[o];
2412
+ if (!i)
2413
+ return;
2414
+ const s = i.key, a = this.elementsCache.get(s);
2415
+ a !== t && (a && this.observer.unobserve(a), this.observer.observe(t), this.elementsCache.set(s, t)), t.isConnected && this.resizeItem(o, this.options.measureElement(t, n, this));
2416
+ }, this.resizeItem = (t, n) => {
2417
+ const o = this.measurementsCache[t];
2418
+ if (!o)
2419
+ return;
2420
+ const i = this.itemSizeCache.get(o.key) ?? o.size, s = n - i;
2421
+ s !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(o, s, this) : o.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", s), this._scrollToOffset(this.getScrollOffset(), {
2422
+ adjustments: this.scrollAdjustments += s,
2423
+ behavior: void 0
2424
+ })), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, n)), this.notify(!1));
2425
+ }, this.measureElement = (t) => {
2426
+ if (!t) {
2427
+ this.elementsCache.forEach((n, o) => {
2428
+ n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(o));
2429
+ });
2430
+ return;
2431
+ }
2432
+ this._measureElement(t, void 0);
2433
+ }, this.getVirtualItems = Ke(
2434
+ () => [this.getVirtualIndexes(), this.getMeasurements()],
2435
+ (t, n) => {
2436
+ const o = [];
2437
+ for (let i = 0, s = t.length; i < s; i++) {
2438
+ const a = t[i], l = n[a];
2439
+ o.push(l);
2440
+ }
2441
+ return o;
2442
+ },
2443
+ {
2444
+ key: process.env.NODE_ENV !== "production" && "getVirtualItems",
2445
+ debug: () => this.options.debug
2446
+ }
2447
+ ), this.getVirtualItemForOffset = (t) => {
2448
+ const n = this.getMeasurements();
2449
+ if (n.length !== 0)
2450
+ return An(
2451
+ n[br(
2452
+ 0,
2453
+ n.length - 1,
2454
+ (o) => An(n[o]).start,
2455
+ t
2456
+ )]
2457
+ );
2458
+ }, this.getMaxScrollOffset = () => {
2459
+ if (!this.scrollElement) return 0;
2460
+ if ("scrollHeight" in this.scrollElement)
2461
+ return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
2462
+ {
2463
+ const t = this.scrollElement.document.documentElement;
2464
+ return this.options.horizontal ? t.scrollWidth - this.scrollElement.innerWidth : t.scrollHeight - this.scrollElement.innerHeight;
2465
+ }
2466
+ }, this.getOffsetForAlignment = (t, n, o = 0) => {
2467
+ if (!this.scrollElement) return 0;
2468
+ const i = this.getSize(), s = this.getScrollOffset();
2469
+ n === "auto" && (n = t >= s + i ? "end" : "start"), n === "center" ? t += (o - i) / 2 : n === "end" && (t -= i);
2470
+ const a = this.getMaxScrollOffset();
2471
+ return Math.max(Math.min(a, t), 0);
2472
+ }, this.getOffsetForIndex = (t, n = "auto") => {
2473
+ t = Math.max(0, Math.min(t, this.options.count - 1));
2474
+ const o = this.measurementsCache[t];
2475
+ if (!o)
2476
+ return;
2477
+ const i = this.getSize(), s = this.getScrollOffset();
2478
+ if (n === "auto")
2479
+ if (o.end >= s + i - this.options.scrollPaddingEnd)
2480
+ n = "end";
2481
+ else if (o.start <= s + this.options.scrollPaddingStart)
2482
+ n = "start";
2483
+ else
2484
+ return [s, n];
2485
+ if (n === "end" && t === this.options.count - 1)
2486
+ return [this.getMaxScrollOffset(), n];
2487
+ const a = n === "end" ? o.end + this.options.scrollPaddingEnd : o.start - this.options.scrollPaddingStart;
2488
+ return [
2489
+ this.getOffsetForAlignment(a, n, o.size),
2490
+ n
2491
+ ];
2492
+ }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (t, { align: n = "start", behavior: o } = {}) => {
2493
+ o === "smooth" && this.isDynamicMode() && console.warn(
2494
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
2495
+ ), this._scrollToOffset(this.getOffsetForAlignment(t, n), {
2496
+ adjustments: void 0,
2497
+ behavior: o
2498
+ });
2499
+ }, this.scrollToIndex = (t, { align: n = "auto", behavior: o } = {}) => {
2500
+ o === "smooth" && this.isDynamicMode() && console.warn(
2501
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
2502
+ ), t = Math.max(0, Math.min(t, this.options.count - 1)), this.currentScrollToIndex = t;
2503
+ let i = 0;
2504
+ const s = 10, a = (c) => {
2505
+ if (!this.targetWindow) return;
2506
+ const f = this.getOffsetForIndex(t, c);
2507
+ if (!f) {
2508
+ console.warn("Failed to get offset for index:", t);
2509
+ return;
2510
+ }
2511
+ const [d, h] = f;
2512
+ this._scrollToOffset(d, { adjustments: void 0, behavior: o }), this.targetWindow.requestAnimationFrame(() => {
2513
+ const u = () => {
2514
+ if (this.currentScrollToIndex !== t) return;
2515
+ const m = this.getScrollOffset(), g = this.getOffsetForIndex(t, h);
2516
+ if (!g) {
2517
+ console.warn("Failed to get offset for index:", t);
2518
+ return;
2519
+ }
2520
+ yi(g[0], m) || l(h);
2521
+ };
2522
+ this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(u) : u();
2523
+ });
2524
+ }, l = (c) => {
2525
+ this.targetWindow && this.currentScrollToIndex === t && (i++, i < s ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, s), this.targetWindow.requestAnimationFrame(() => a(c))) : console.warn(
2526
+ `Failed to scroll to index ${t} after ${s} attempts.`
2527
+ ));
2528
+ };
2529
+ a(n);
2530
+ }, this.scrollBy = (t, { behavior: n } = {}) => {
2531
+ n === "smooth" && this.isDynamicMode() && console.warn(
2532
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
2533
+ ), this._scrollToOffset(this.getScrollOffset() + t, {
2534
+ adjustments: void 0,
2535
+ behavior: n
2536
+ });
2537
+ }, this.getTotalSize = () => {
2538
+ var t;
2539
+ const n = this.getMeasurements();
2540
+ let o;
2541
+ if (n.length === 0)
2542
+ o = this.options.paddingStart;
2543
+ else if (this.options.lanes === 1)
2544
+ o = ((t = n[n.length - 1]) == null ? void 0 : t.end) ?? 0;
2545
+ else {
2546
+ const i = Array(this.options.lanes).fill(null);
2547
+ let s = n.length - 1;
2548
+ for (; s >= 0 && i.some((a) => a === null); ) {
2549
+ const a = n[s];
2550
+ i[a.lane] === null && (i[a.lane] = a.end), s--;
2551
+ }
2552
+ o = Math.max(...i.filter((a) => a !== null));
2553
+ }
2554
+ return Math.max(
2555
+ o - this.options.scrollMargin + this.options.paddingEnd,
2556
+ 0
2557
+ );
2558
+ }, this._scrollToOffset = (t, {
2559
+ adjustments: n,
2560
+ behavior: o
2561
+ }) => {
2562
+ this.options.scrollToFn(t, { behavior: o, adjustments: n }, this);
2563
+ }, this.measure = () => {
2564
+ this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
2565
+ }, this.setOptions(r);
2566
+ }
2567
+ }
2568
+ const br = (e, r, t, n) => {
2569
+ for (; e <= r; ) {
2570
+ const o = (e + r) / 2 | 0, i = t(o);
2571
+ if (i < n)
2572
+ e = o + 1;
2573
+ else if (i > n)
2574
+ r = o - 1;
2575
+ else
2576
+ return o;
2577
+ }
2578
+ return e > 0 ? e - 1 : 0;
2579
+ };
2580
+ function Ti({
2581
+ measurements: e,
2582
+ outerSize: r,
2583
+ scrollOffset: t,
2584
+ lanes: n
2585
+ }) {
2586
+ const o = e.length - 1, i = (l) => e[l].start;
2587
+ if (e.length <= n)
2588
+ return {
2589
+ startIndex: 0,
2590
+ endIndex: o
2591
+ };
2592
+ let s = br(
2593
+ 0,
2594
+ o,
2595
+ i,
2596
+ t
2597
+ ), a = s;
2598
+ if (n === 1)
2599
+ for (; a < o && e[a].end < t + r; )
2600
+ a++;
2601
+ else if (n > 1) {
2602
+ const l = Array(n).fill(0);
2603
+ for (; a < o && l.some((f) => f < t + r); ) {
2604
+ const f = e[a];
2605
+ l[f.lane] = f.end, a++;
2606
+ }
2607
+ const c = Array(n).fill(t + r);
2608
+ for (; s >= 0 && c.some((f) => f >= t); ) {
2609
+ const f = e[s];
2610
+ c[f.lane] = f.start, s--;
2611
+ }
2612
+ s = Math.max(0, s - s % n), a = Math.min(o, a + (n - 1 - a % n));
2613
+ }
2614
+ return { startIndex: s, endIndex: a };
2615
+ }
2616
+ const zn = typeof document < "u" ? p.useLayoutEffect : p.useEffect;
2617
+ function ki({
2618
+ useFlushSync: e = !0,
2619
+ ...r
2620
+ }) {
2621
+ const t = p.useReducer(() => ({}), {})[1], n = {
2622
+ ...r,
2623
+ onChange: (i, s) => {
2624
+ var a;
2625
+ e && s ? Wn(t) : t(), (a = r.onChange) == null || a.call(r, i, s);
2626
+ }
2627
+ }, [o] = p.useState(
2628
+ () => new Si(n)
2629
+ );
2630
+ return o.setOptions(n), zn(() => o._didMount(), []), zn(() => o._willUpdate()), o;
2631
+ }
2632
+ function Mi(e) {
2633
+ return ki({
2634
+ observeElementRect: Ei,
2635
+ observeElementOffset: Ii,
2636
+ scrollToFn: Oi,
2637
+ ...e
2638
+ });
2639
+ }
2640
+ const Ae = De(void 0), gr = De({
2641
+ activeIndex: 0
2642
+ }), Ni = (e, r) => r.type === "SET_ACTIVE_INDEX" ? {
2643
+ ...e,
2644
+ activeIndex: r.payload
2645
+ } : e, vr = De(() => {
2646
+ throw new Error("ComboboxIdDispatch must be used within a provider");
2647
+ }), Pi = ({ children: e }) => {
2648
+ const [r, t] = Vr(Ni, {
2649
+ activeIndex: 0
2650
+ });
2651
+ return v(gr.Provider, { value: r, children: v(vr.Provider, { value: t, children: e }) });
2652
+ };
2653
+ function tn() {
2654
+ return oe(vr);
2655
+ }
2656
+ function Ot() {
2657
+ return oe(gr);
2658
+ }
2659
+ const yr = A(({ asChild: e, interactive: r, id: t, className: n, ...o }, i) => {
2660
+ if (r && !t)
2661
+ throw new Error("If ComboboxCustom is interactive, it must have an id");
2662
+ const s = e ? se : "div", a = Ve(), { activeIndex: l } = Ot(), c = oe(Ae);
2663
+ if (!c)
2664
+ throw new Error("ComboboxCustom must be used within a Combobox");
2665
+ const { customIds: f, setListRef: d, getItemProps: h, size: u } = c, m = ze(() => t && f.indexOf(t) || 0, [t, f]), g = Yt([
2666
+ (C) => {
2667
+ d(m, C);
2668
+ },
2669
+ i
2670
+ ]);
2671
+ return v(Te, { "data-size": u, asChild: !0, children: v(s, { ref: g, tabIndex: -1, className: X("ds-combobox__custom", n), id: t || a, role: "option", "aria-selected": l === m, "data-active": l === m, ...qe(["interactive"], o), ...qe(["onClick", "onPointerLeave"], h()) }) });
2672
+ }), xr = ({ size: e, error: r, formFieldProps: t }) => v("div", { className: "ds-combobox__error-message", id: t.errorId, "aria-live": "polite", "aria-relevant": "additions removals", children: r && v(Xt, { "data-size": e, children: r }) });
2673
+ xr.displayName = "ComboboxError";
2674
+ let Vn = 0;
2675
+ function Di(e) {
2676
+ const [r, t] = ye(e), n = e || r;
2677
+ return ue(() => {
2678
+ r == null && (Vn += 1, t(`aksel-icon-${Vn}`));
2679
+ }, [r]), n;
2680
+ }
2681
+ const Bn = ce.useId;
2682
+ function at(e) {
2683
+ var r;
2684
+ return Bn !== void 0 ? Bn().replace(/(:)/g, "") : (r = Di(e)) !== null && r !== void 0 ? r : "";
2685
+ }
2686
+ var Ai = function(e, r) {
2687
+ var t = {};
2688
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
2689
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
2690
+ for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
2691
+ r.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (t[n[o]] = e[n[o]]);
2692
+ return t;
2693
+ };
2694
+ const _i = A((e, r) => {
2695
+ var { title: t, titleId: n } = e, o = Ai(e, ["title", "titleId"]);
2696
+ let i = at();
2697
+ return i = t ? n || "title-" + i : void 0, ce.createElement(
2698
+ "svg",
2699
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: r, "aria-labelledby": i }, o),
2700
+ t ? ce.createElement("title", { id: i }, t) : null,
2701
+ ce.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M18.998 6.94a.75.75 0 0 1 .063 1.058l-8 9a.75.75 0 0 1-1.091.032l-5-5a.75.75 0 1 1 1.06-1.06l4.438 4.437 7.471-8.405A.75.75 0 0 1 19 6.939", clipRule: "evenodd" })
2702
+ );
2703
+ });
2704
+ var Fi = function(e, r) {
2705
+ var t = {};
2706
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
2707
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
2708
+ for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
2709
+ r.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (t[n[o]] = e[n[o]]);
2710
+ return t;
2711
+ };
2712
+ const Li = A((e, r) => {
2713
+ var { title: t, titleId: n } = e, o = Fi(e, ["title", "titleId"]);
2714
+ let i = at();
2715
+ return i = t ? n || "title-" + i : void 0, ce.createElement(
2716
+ "svg",
2717
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: r, "aria-labelledby": i }, o),
2718
+ t ? ce.createElement("title", { id: i }, t) : null,
2719
+ ce.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M5.97 9.47a.75.75 0 0 1 1.06 0L12 14.44l4.97-4.97a.75.75 0 1 1 1.06 1.06l-5.5 5.5a.75.75 0 0 1-1.06 0l-5.5-5.5a.75.75 0 0 1 0-1.06", clipRule: "evenodd" })
2720
+ );
2721
+ });
2722
+ var zi = function(e, r) {
2723
+ var t = {};
2724
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
2725
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
2726
+ for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
2727
+ r.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (t[n[o]] = e[n[o]]);
2728
+ return t;
2729
+ };
2730
+ const Vi = A((e, r) => {
2731
+ var { title: t, titleId: n } = e, o = zi(e, ["title", "titleId"]);
2732
+ let i = at();
2733
+ return i = t ? n || "title-" + i : void 0, ce.createElement(
2734
+ "svg",
2735
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: r, "aria-labelledby": i }, o),
2736
+ t ? ce.createElement("title", { id: i }, t) : null,
2737
+ ce.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M11.47 7.97a.75.75 0 0 1 1.06 0l5.5 5.5a.75.75 0 1 1-1.06 1.06L12 9.56l-4.97 4.97a.75.75 0 0 1-1.06-1.06z", clipRule: "evenodd" })
2738
+ );
2739
+ });
2740
+ var Bi = function(e, r) {
2741
+ var t = {};
2742
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
2743
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
2744
+ for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
2745
+ r.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (t[n[o]] = e[n[o]]);
2746
+ return t;
2747
+ };
2748
+ const ji = A((e, r) => {
2749
+ var { title: t, titleId: n } = e, o = Bi(e, ["title", "titleId"]);
2750
+ let i = at();
2751
+ return i = t ? n || "title-" + i : void 0, ce.createElement(
2752
+ "svg",
2753
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: r, "aria-labelledby": i }, o),
2754
+ t ? ce.createElement("title", { id: i }, t) : null,
2755
+ ce.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 2.25A4.75 4.75 0 0 0 7.25 7v2.25H7A1.75 1.75 0 0 0 5.25 11v9c0 .414.336.75.75.75h12a.75.75 0 0 0 .75-.75v-9A1.75 1.75 0 0 0 17 9.25h-.25V7A4.75 4.75 0 0 0 12 2.25m3.25 7V7a3.25 3.25 0 0 0-6.5 0v2.25zM12 13a1.5 1.5 0 0 0-.75 2.8V17a.75.75 0 0 0 1.5 0v-1.2A1.5 1.5 0 0 0 12 13", clipRule: "evenodd" })
2756
+ );
2757
+ });
2758
+ var $i = function(e, r) {
2759
+ var t = {};
2760
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
2761
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
2762
+ for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
2763
+ r.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (t[n[o]] = e[n[o]]);
2764
+ return t;
2765
+ };
2766
+ const Ki = A((e, r) => {
2767
+ var { title: t, titleId: n } = e, o = $i(e, ["title", "titleId"]);
2768
+ let i = at();
2769
+ return i = t ? n || "title-" + i : void 0, ce.createElement(
2770
+ "svg",
2771
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: r, "aria-labelledby": i }, o),
2772
+ t ? ce.createElement("title", { id: i }, t) : null,
2773
+ ce.createElement("path", { fill: "currentColor", d: "M6.53 5.47a.75.75 0 0 0-1.06 1.06L10.94 12l-5.47 5.47a.75.75 0 1 0 1.06 1.06L12 13.06l5.47 5.47a.75.75 0 1 0 1.06-1.06L13.06 12l5.47-5.47a.75.75 0 0 0-1.06-1.06L12 10.94z" })
2774
+ );
2775
+ });
2776
+ function Wi(e) {
2777
+ return $n(e) && e.type === yr;
2778
+ }
2779
+ function qi(e) {
2780
+ return Wi(e) && e.props.interactive === !0;
2781
+ }
2782
+ const wr = "internal-option-", pe = (e) => wr + e, Ht = (e) => e.slice(wr.length), Qe = (e, r) => {
2783
+ const t = e.value;
2784
+ e.value = r;
2785
+ const n = e._valueTracker;
2786
+ typeof n < "u" && n.setValue(t), e.dispatchEvent(new Event("change", { bubbles: !0 }));
2787
+ }, Cr = A(function({ asChild: r, className: t, ...n }, o) {
2788
+ return v(r ? se : "button", { className: X("ds-chip", t), type: r ? void 0 : "button", ref: o, ...n });
2789
+ }), Er = A(function(r, t) {
2790
+ return v(Cr, { "data-removable": !0, ref: t, ...r });
2791
+ }), Ir = A(function({ asChild: r, children: t, className: n, "data-size": o, "data-color": i, ...s }, a) {
2792
+ const l = s.type ?? "checkbox";
2793
+ return ie(r ? se : "label", { className: X("ds-chip", n), "data-size": o, "data-color": i, ref: a, children: [v(ot, { ...s, type: l }), v(Kr, { children: t })] });
2794
+ }), Hi = A(function(r, t) {
2795
+ return v(Ir, { ref: t, type: "radio", ...r });
2796
+ }), St = {
2797
+ Button: Cr,
2798
+ Checkbox: Ir,
2799
+ Radio: Hi,
2800
+ Removable: Er
2801
+ };
2802
+ St.Button.displayName = "Chip.Button";
2803
+ St.Checkbox.displayName = "Chip.Checkbox";
2804
+ St.Radio.displayName = "Chip.Radio";
2805
+ St.Removable.displayName = "Chip.Removable";
2806
+ const Rr = () => {
2807
+ const e = oe(Ae);
2808
+ if (!e)
2809
+ throw new Error("ComboboxContext is missing");
2810
+ const { size: r, readOnly: t, disabled: n, selectedOptions: o, chipSrLabel: i, handleSelectOption: s, inputRef: a } = e;
2811
+ return v(Ut, { children: Object.keys(o).map((l) => v(Er, { "data-size": r, disabled: n, onKeyDown: (c) => {
2812
+ t || n || c.key === "Enter" && (c.stopPropagation(), s({
2813
+ option: o[l],
2814
+ remove: !0
2815
+ }), a?.current?.focus());
2816
+ }, onClick: () => {
2817
+ t || n || s({
2818
+ option: o[l],
2819
+ remove: !0
2820
+ });
2821
+ }, "aria-label": i(o[l]), children: o[l].label }, l)) });
2822
+ };
2823
+ Rr.displayName = "ComboboxChips";
2824
+ const Or = A((e, r) => {
2825
+ const t = oe(Ae);
2826
+ if (!t)
2827
+ throw new Error("ComboboxContext is missing");
2828
+ const { readOnly: n, disabled: o, clearButtonLabel: i, handleSelectOption: s } = t;
2829
+ return v("button", { ...e, ref: r, disabled: o, className: X("ds-combobox__clear-button", "ds-focus"), onClick: () => {
2830
+ n || o || s({ option: null, clear: !0 });
2831
+ }, onKeyDown: (a) => {
2832
+ n || o || a.key === "Enter" && (a.stopPropagation(), s({ option: null, clear: !0 }));
2833
+ }, type: "button", "aria-label": i, children: v(Ki, { fontSize: "1.5em", title: "Clear selection" }) });
2834
+ });
2835
+ Or.displayName = "ComboboxClearButton";
2836
+ const Sr = ({ hideClearButton: e, listId: r, error: t, hideChips: n, handleKeyDown: o, ...i }) => {
2837
+ const s = oe(Ae), a = tn(), l = ve(null);
2838
+ if (!s)
2839
+ throw new Error("ComboboxContext is missing");
2840
+ const c = (E) => {
2841
+ a?.({ type: "SET_ACTIVE_INDEX", payload: E });
2842
+ }, { forwareddRef: f, readOnly: d, disabled: h, open: u, inputRef: m, refs: g, inputValue: C, multiple: x, selectedOptions: y, formFieldProps: b, htmlSize: w, options: _, setOpen: M, getReferenceProps: j, setInputValue: $, handleSelectOption: Z, size: G } = s, q = Yt([f, m]), S = (E) => {
2843
+ const D = E.target.value;
2844
+ $(D), c(0);
2845
+ for (const B of Object.values(_))
2846
+ if (B.label.toLowerCase() === D.toLowerCase()) {
2847
+ if (y[pe(B.value)])
2848
+ continue;
2849
+ Z({ option: B });
2850
+ }
2851
+ }, N = !e && Object.keys(y).length > 0, P = j({
2852
+ ref: g?.setReference,
2853
+ role: null,
2854
+ "aria-controls": null,
2855
+ "aria-expanded": null,
2856
+ "aria-haspopup": null,
2857
+ /* If we click the wrapper, toggle open, set index to first option, and focus the input */
2858
+ onClick(E) {
2859
+ h || d || l.current?.contains(E.target) || (M(!u), c(0), m.current?.focus());
2860
+ },
2861
+ /* Handles list navigation */
2862
+ onKeyDown: o,
2863
+ // preventDefault on keydown to avoid sending in form
2864
+ onKeyPress(E) {
2865
+ E.key === "Enter" && E.preventDefault();
2866
+ }
2867
+ });
2868
+ return v(jt, { "data-size": G, asChild: !0, children: ie("div", { ...P, "aria-disabled": h ? "true" : void 0, className: X("ds-textfield__input", "ds-combobox__input__wrapper", d && "ds-combobox--readonly", t && "ds-combobox--error"), children: [ie("div", { className: "ds-combobox__chip-and-input", children: [x && !n && v(Rr, {}), v(jt, { "data-size": G, asChild: !0, children: v("input", { ref: q, "aria-activedescendant": P["aria-activedescendant"], readOnly: d, "aria-autocomplete": "list", role: "combobox", "aria-expanded": u, "aria-controls": u ? r : void 0, autoComplete: "off", size: w, value: C, ...qe(["style", "className"], i), ...b.inputProps, className: "ds-combobox__input", onChange: (E) => {
2869
+ S(E), !u && M(!0), i.onChange?.(E);
2870
+ } }) })] }), N && v(Or, { ref: l }), v("div", { className: "ds-combobox__arrow", children: u ? v(Vi, { title: "arrow up", fontSize: "1.5em" }) : v(Li, { title: "arrow down", fontSize: "1.5em" }) })] }) });
2871
+ };
2872
+ Sr.displayName = "ComboboxInput";
2873
+ const Tr = ({ label: e, description: r, hideLabel: t, size: n, readOnly: o, formFieldProps: i }) => ie(Ut, { children: [e && ie(Te, { "data-size": n, htmlFor: i.inputProps.id, className: X("ds-combobox__label", t && "ds-sr-only"), children: [o && v(ji, { "aria-hidden": !0, className: "ds-combobox__readonly__icon" }), e] }), r && v(jt, { asChild: !0, "data-size": n, children: v("div", { id: i.descriptionId, className: X("ds-combobox__description", t && "ds-sr-only"), children: r }) })] });
2874
+ Tr.displayName = "ComboboxLabel";
2875
+ const kr = ({ selectedOptions: e, multiple: r, name: t }) => {
2876
+ const n = Object.keys(e).map((o) => Ht(o));
2877
+ return v("select", { name: t, multiple: r, style: { display: "none" }, value: r ? n : n[0], onChange: () => {
2878
+ }, children: n.map((o) => v("option", { value: o }, o)) });
2879
+ };
2880
+ kr.displayName = "ComboboxNative";
2881
+ const Mr = A(({ children: e, className: r, ...t }, n) => v("span", { className: X("ds-combobox__option__description", r), ref: n, ...t, children: e }));
2882
+ Mr.displayName = "ComboboxOptionDescription";
2883
+ const Nr = ({ multiple: e, selected: r }) => v("div", { className: X(e && "ds-combobox__option__icon-wrapper", r && "ds-combobox__option__icon-wrapper--selected"), children: r && v(_i, { className: "ds-combobox__option__icon-wrapper__icon", "aria-hidden": !0 }) });
2884
+ Nr.displayName = "SelectedIcon";
2885
+ const Ui = ({ id: e, ref: r, value: t }) => {
2886
+ const n = Ve(), o = e || n, i = oe(Ae), { activeIndex: s } = Ot(), a = tn();
2887
+ if (!i)
2888
+ throw new Error("ComboboxOption must be used within a Combobox");
2889
+ const { selectedOptions: l, onOptionClick: c, setListRef: f, customIds: d, filteredOptions: h } = i, u = ze(() => h.indexOf(pe(String(t))) + d.length, [d.length, h, t]), m = Yt([
2890
+ (y) => {
2891
+ f(u, y);
2892
+ },
2893
+ r
2894
+ ]);
2895
+ if (u === -1)
2896
+ throw new Error("Internal error: ComboboxOption did not find index");
2897
+ const g = l[pe(t)], C = s === u;
2898
+ ue(() => {
2899
+ C && a?.({ type: "SET_ACTIVE_INDEX", payload: u });
2900
+ }, [n, e, a, C, u]);
2901
+ const x = Gt(() => c(t), 50);
2902
+ return {
2903
+ id: o,
2904
+ ref: m,
2905
+ selected: g,
2906
+ active: C,
2907
+ onOptionClick: x
2908
+ };
2909
+ }, nn = Br(A(({ value: e, description: r, children: t, className: n, ...o }, i) => {
2910
+ const s = Ve(), { id: a, ref: l, selected: c, active: f, onOptionClick: d } = Ui({
2911
+ id: o.id,
2912
+ ref: i,
2913
+ value: e
2914
+ }), h = oe(Ae);
2915
+ if (!h)
2916
+ throw new Error("ComboboxOption must be used within a Combobox");
2917
+ const { size: u, multiple: m, getItemProps: g } = h, C = g();
2918
+ return v(Te, { "data-size": "md", asChild: !0, children: ie("button", { ref: l, id: a, role: "option", type: "button", "aria-selected": !!c, "aria-labelledby": s, tabIndex: -1, onClick: (x) => {
2919
+ d(), o.onClick?.(x);
2920
+ }, className: X("ds-combobox__option", f && "ds-combobox__option--active", m && "ds-combobox__option--multiple", n), ...qe(["displayValue"], o), ...qe(["onClick", "onPointerLeave"], C), children: [v(Te, { asChild: !0, "data-size": u, children: v("span", { children: v(Nr, { multiple: m, selected: !!c }) }) }), ie(Te, { className: "ds-combobox__option__label", "data-size": u, id: s, children: [t, r && v(Mr, { children: r })] })] }) });
2921
+ }));
2922
+ nn.displayName = "ComboboxOption";
2923
+ function Xi(e) {
2924
+ return $n(e) && e.type === nn;
2925
+ }
2926
+ const Gi = (e) => !!e;
2927
+ function Yi({ children: e, inputValue: r, multiple: t, filter: n = (i, s) => s.label.toLowerCase().startsWith(i.toLowerCase()), initialValue: o }) {
2928
+ const i = jr(n, [n]), { optionsChildren: s, customIds: a, restChildren: l, interactiveChildren: c } = ze(() => fn.toArray(e).reduce((y, b) => {
2929
+ if (Xi(b))
2930
+ y.optionsChildren.push(b);
2931
+ else if (y.restChildren.push(b), qi(b)) {
2932
+ const w = b;
2933
+ if (y.interactiveChildren.push(w), !w.props.id)
2934
+ throw new Error("If ComboboxCustom is interactive, it must have an id");
2935
+ y.customIds.push(w.props.id);
2936
+ }
2937
+ return y;
2938
+ }, {
2939
+ optionsChildren: [],
2940
+ customIds: [],
2941
+ restChildren: [],
2942
+ interactiveChildren: []
2943
+ }), [e]), f = ze(() => {
2944
+ const C = [], x = {};
2945
+ return s.map((y) => {
2946
+ const b = y.props;
2947
+ let w = b.displayValue || "";
2948
+ if (!b.displayValue) {
2949
+ let _ = "";
2950
+ fn.forEach(b.children, (M) => {
2951
+ if (typeof M == "string")
2952
+ _ += M;
2953
+ else
2954
+ throw new Error("If ComboboxOption is not a string, it must have a displayValue prop");
2955
+ }), w = _;
2956
+ }
2957
+ return C.includes(b.value) && console.warn(`Combobox has multiple options with the same value: ${b.value}`), C.push(b.value), x[pe(String(b.value))] = {
2958
+ value: String(b.value),
2959
+ label: w,
2960
+ displayValue: b.displayValue,
2961
+ description: b.description
2962
+ }, null;
2963
+ }), x;
2964
+ }, [s]), d = ze(() => (o?.map((C) => pe(C)) || []).reduce((C, x) => {
2965
+ const y = f[x];
2966
+ return Gi(y) && (C[x] = y), C;
2967
+ }, {}), [o, f]), [h, u] = ye(d), { filteredOptions: m, filteredOptionsChildren: g } = ze(() => {
2968
+ const C = [], x = Object.keys(f).map((y, b) => !t && Object.keys(h).length === 1 || t && h[y] || i(r, f[y]) ? (C.push(y), s[b]) : null).filter((y) => y);
2969
+ return { filteredOptions: C, filteredOptionsChildren: x };
2970
+ }, [
2971
+ i,
2972
+ r,
2973
+ t,
2974
+ f,
2975
+ s,
2976
+ h
2977
+ ]);
2978
+ return {
2979
+ filteredOptionsChildren: g,
2980
+ filteredOptions: m,
2981
+ restChildren: l,
2982
+ options: f,
2983
+ customIds: a,
2984
+ selectedOptions: h,
2985
+ interactiveChildren: c,
2986
+ setSelectedOptions: u
2987
+ };
2988
+ }
2989
+ const Zi = ({ readOnly: e, disabled: r, interactiveChildren: t, filteredOptions: n, inputValue: o, selectedOptions: i, multiple: s, open: a, options: l, setOpen: c, handleSelectOption: f }) => {
2990
+ const { activeIndex: d } = Ot();
2991
+ return Gt((m) => {
2992
+ if (!(e || r) && m)
2993
+ switch (m.key) {
2994
+ case "ArrowDown":
2995
+ if (m.preventDefault(), a)
2996
+ break;
2997
+ c(!0);
2998
+ break;
2999
+ case "ArrowUp":
3000
+ if (m.preventDefault(), d !== 0)
3001
+ break;
3002
+ c(!1);
3003
+ break;
3004
+ case "Enter": {
3005
+ if (m.preventDefault(), !a)
3006
+ break;
3007
+ if (d <= t.length - 1) {
3008
+ const x = t[d];
3009
+ if (x.props.onSelect) {
3010
+ x?.props.onSelect();
3011
+ return;
3012
+ }
3013
+ }
3014
+ const g = d - t.length, C = n[g];
3015
+ f({ option: l[C] });
3016
+ break;
3017
+ }
3018
+ case "Backspace":
3019
+ if (!s) {
3020
+ const g = Object.keys(i).pop();
3021
+ g && f({
3022
+ option: i[g],
3023
+ remove: !0
3024
+ });
3025
+ break;
3026
+ }
3027
+ if (o === "" && s) {
3028
+ const g = Object.keys(i).pop();
3029
+ g && f({
3030
+ option: i[g],
3031
+ remove: !0
3032
+ });
3033
+ }
3034
+ break;
3035
+ }
3036
+ }, 20);
3037
+ }, Ji = ({ listRef: e }) => {
3038
+ const [r, t] = ye(!1), { activeIndex: n } = Ot(), o = tn(), { refs: i, floatingStyles: s, context: a } = hi({
3039
+ open: r,
3040
+ onOpenChange: (m) => {
3041
+ m || o?.({ type: "SET_ACTIVE_INDEX", payload: 0 }), Wn(() => {
3042
+ i.floating.current && !m && (i.floating.current.scrollTop = 0), setTimeout(() => {
3043
+ t(m);
3044
+ }, 1);
3045
+ });
3046
+ },
3047
+ whileElementsMounted: (m, g, C) => (Xn(m, g, C), () => {
3048
+ g.scrollTop = 0;
3049
+ }),
3050
+ middleware: [
3051
+ Fo({ padding: 10 }),
3052
+ Lo({
3053
+ apply({ rects: m, elements: g }) {
3054
+ requestAnimationFrame(() => {
3055
+ Object.assign(g.floating.style, {
3056
+ width: `${m.reference.width}px`,
3057
+ maxHeight: "200px"
3058
+ });
3059
+ });
3060
+ }
3061
+ }),
3062
+ _o(10)
3063
+ ]
3064
+ }), l = vi(a, { role: "listbox" }), c = di(a), f = bi(a, {
3065
+ listRef: e,
3066
+ activeIndex: n,
3067
+ virtual: !0,
3068
+ scrollItemIntoView: !0,
3069
+ enabled: r,
3070
+ focusItemOnHover: !0,
3071
+ onNavigate: (m) => {
3072
+ o?.({ type: "SET_ACTIVE_INDEX", payload: m || 0 });
3073
+ }
3074
+ }), { getReferenceProps: d, getFloatingProps: h, getItemProps: u } = mi([l, c, f]);
3075
+ return {
3076
+ open: r,
3077
+ setOpen: t,
3078
+ activeIndex: n,
3079
+ refs: i,
3080
+ floatingStyles: s,
3081
+ context: a,
3082
+ getReferenceProps: d,
3083
+ getFloatingProps: h,
3084
+ getItemProps: u
3085
+ };
3086
+ }, Qi = De(null), es = (e, r) => {
3087
+ const t = oe(Qi), n = Ve(), o = e.id ?? `${r}-${n}`, i = e.errorId ?? `${r}-error-${n}`, s = `${r}-description-${n}`, a = e.size ?? t?.size ?? "md", l = t?.disabled || e?.disabled, c = !l && !!(e.error || t?.error);
3088
+ return {
3089
+ hasError: c,
3090
+ errorId: i,
3091
+ descriptionId: s,
3092
+ size: a,
3093
+ inputProps: {
3094
+ id: o,
3095
+ disabled: l,
3096
+ "aria-invalid": c ? !0 : void 0,
3097
+ "aria-describedby": X(e["aria-describedby"], !!e?.description && typeof e?.description == "string" && s, c && !t?.error && i, c && !!t?.error && t?.errorId) || void 0
3098
+ }
3099
+ };
3100
+ }, ts = A(({ value: e, initialValue: r = [], onValueChange: t, label: n, hideLabel: o = !1, description: i, multiple: s = !1, disabled: a = !1, readOnly: l = !1, hideChips: c = !1, clearButtonLabel: f = "Fjern alt", hideClearButton: d = !1, error: h, errorId: u, id: m, name: g, portal: C = !0, htmlSize: x = 0, virtual: y = !1, children: b, style: w, size: _ = "md", loading: M, loadingLabel: j = "Laster...", filter: $, chipSrLabel: Z = (N) => "Slett " + N.label, className: G, ...q }, S) => {
3101
+ const N = ve(null), P = ve(null), E = ve([]), [D, B] = ye(q.inputValue || "");
3102
+ ue(() => {
3103
+ typeof q.inputValue == "string" && B(q.inputValue);
3104
+ }, [q.inputValue]);
3105
+ const { selectedOptions: k, options: R, restChildren: U, interactiveChildren: te, customIds: xe, filteredOptionsChildren: he, filteredOptions: z, setSelectedOptions: T } = Yi({
3106
+ children: b,
3107
+ inputValue: D,
3108
+ filter: $,
3109
+ multiple: s,
3110
+ initialValue: r
3111
+ }), { open: O, setOpen: F, refs: H, floatingStyles: ee, context: ne, getReferenceProps: Y, getFloatingProps: Ie, getItemProps: Ee } = Ji({
3112
+ listRef: E
3113
+ }), J = es({
3114
+ disabled: a,
3115
+ error: h,
3116
+ errorId: u,
3117
+ size: _,
3118
+ description: i,
3119
+ id: m
3120
+ }, "combobox");
3121
+ ue(() => {
3122
+ if (e && e.length > 0 && !s) {
3123
+ const V = R[pe(e[0])];
3124
+ N.current && Qe(N.current, V?.label || "");
3125
+ }
3126
+ }, [s, e, R]), ue(() => {
3127
+ if (e && Object.keys(R).length >= 0) {
3128
+ const V = e.map((I) => R[pe(I)]);
3129
+ T(V.reduce((I, W) => (I[pe(W.value)] = W, I), {}));
3130
+ }
3131
+ }, [s, e, R, T]);
3132
+ const me = Gt((V) => {
3133
+ const { option: I, clear: W, remove: ae } = V;
3134
+ if (W) {
3135
+ T({}), N.current && Qe(N.current, ""), t?.([]);
3136
+ return;
3137
+ }
3138
+ if (!I)
3139
+ return;
3140
+ if (ae) {
3141
+ const re = { ...k };
3142
+ delete re[pe(I.value)], T(re), t?.(Object.keys(re).map((je) => Ht(je)));
3143
+ return;
3144
+ }
3145
+ const K = { ...k };
3146
+ if (s)
3147
+ K[pe(I.value)] ? delete K[pe(I.value)] : K[pe(I.value)] = I, N.current && Qe(N.current, ""), N.current?.focus();
3148
+ else {
3149
+ for (const re of Object.keys(K))
3150
+ delete K[re];
3151
+ K[pe(I.value)] = I, N.current && Qe(N.current, I?.label || ""), setTimeout(() => {
3152
+ N.current?.setSelectionRange(I?.label?.length || 0, I?.label?.length || 0);
3153
+ }, 0);
3154
+ }
3155
+ T(K), t?.(Object.keys(K).map((re) => Ht(re))), !s && F(!1), H.domReference.current?.focus();
3156
+ }, 50), _e = Zi({
3157
+ filteredOptions: z,
3158
+ selectedOptions: k,
3159
+ readOnly: J.readOnly || !1,
3160
+ disabled: a,
3161
+ multiple: s,
3162
+ inputValue: D,
3163
+ options: R,
3164
+ open: O,
3165
+ interactiveChildren: te,
3166
+ setOpen: F,
3167
+ handleSelectOption: me
3168
+ }), L = Mi({
3169
+ count: Object.keys(he).length,
3170
+ getScrollElement: () => y ? H.floating.current : null,
3171
+ estimateSize: () => 70,
3172
+ measureElement: (V) => V.getBoundingClientRect().height,
3173
+ overscan: 7
3174
+ });
3175
+ return ie(Ae.Provider, { value: {
3176
+ size: _,
3177
+ options: R,
3178
+ selectedOptions: k,
3179
+ multiple: s,
3180
+ disabled: a,
3181
+ readOnly: l,
3182
+ open: O,
3183
+ inputRef: N,
3184
+ refs: H,
3185
+ inputValue: D,
3186
+ formFieldProps: J,
3187
+ htmlSize: x,
3188
+ clearButtonLabel: f,
3189
+ customIds: xe,
3190
+ filteredOptions: z,
3191
+ setInputValue: B,
3192
+ setOpen: F,
3193
+ getReferenceProps: Y,
3194
+ getItemProps: Ee,
3195
+ /* Recieves the value of the option, and searches for it in our values lookup */
3196
+ onOptionClick: (V) => {
3197
+ if (l || a)
3198
+ return;
3199
+ const I = R[pe(V)];
3200
+ me({ option: I });
3201
+ },
3202
+ handleSelectOption: me,
3203
+ chipSrLabel: Z,
3204
+ listRef: E,
3205
+ forwareddRef: S,
3206
+ setListRef: (V, I) => {
3207
+ E.current[V] = I;
3208
+ }
3209
+ }, children: [ie("div", { className: X("ds-combobox", `ds-combobox--${_}`, a && "ds-combobox__disabled", G), style: w, ref: P, children: [g && v(kr, { name: g, selectedOptions: k, multiple: s }), v(Tr, { label: n, description: i, size: _, readOnly: l, hideLabel: o, formFieldProps: J }), v(Sr, { ...qe(["inputValue"], q), hideClearButton: d, listId: ne.floatingId || "", error: h, hideChips: c, handleKeyDown: _e, "aria-busy": M }), v(xr, { size: _, error: h, formFieldProps: J })] }), O && v(si, { root: C ? null : P, children: v(li, { context: ne, initialFocus: -1, visuallyHiddenDismiss: !0, children: ie("div", { "aria-labelledby": J.inputProps.id, "aria-autocomplete": "list", tabIndex: -1, ...Ie({
3210
+ ref: H.setFloating,
3211
+ style: {
3212
+ ...ee
3213
+ }
3214
+ }), className: X("ds-combobox__options-wrapper", `ds-combobox--${_}`), children: [y && v("div", { style: {
3215
+ height: `${L.getTotalSize()}px`,
3216
+ width: "100%",
3217
+ position: "relative"
3218
+ }, children: L.getVirtualItems().map((V) => v("div", { ref: L.measureElement, "data-index": V.index, style: {
3219
+ position: "absolute",
3220
+ top: 0,
3221
+ left: 0,
3222
+ width: "100%",
3223
+ transform: `translateY(${V.start}px)`
3224
+ }, children: he[V.index] }, V.index)) }), M ? ie(yr, { className: "ds-combobox__loading", children: [v(Wr, { "aria-label": "Laster", "data-size": "sm" }), j] }) : ie(Ut, { children: [U, !y && he] })] }) }) })] });
3225
+ }), Pr = A((e, r) => v(Pi, { children: v(ts, { ...e, ref: r }) }));
3226
+ Pr.displayName = "Combobox";
3227
+ const Dr = A(({ children: e, className: r, ...t }, n) => {
3228
+ const o = oe(Ae);
3229
+ if (!o)
3230
+ throw new Error("ComboboxEmpty must be used within a Combobox");
3231
+ const { filteredOptions: i, size: s } = o;
3232
+ return i.length === 0 && v(Te, { "data-size": s, asChild: !0, children: v("div", { ref: n, className: X("ds-combobox__empty", r), ...t, children: e }) });
3233
+ });
3234
+ Dr.displayName = "ComboboxEmpty";
3235
+ const Tt = Pr;
3236
+ Tt.Option = nn;
3237
+ Tt.Empty = Dr;
3238
+ Tt.Option.displayName = "Combobox.Option";
3239
+ Tt.Empty.displayName = "Combobox.Empty";
3240
+ const As = A(function({ "data-size": r, className: t, style: n, children: o, label: i, description: s, error: a, ...l }, c) {
3241
+ return ie(pt, { "data-size": r, className: t, style: n, children: [v(ot, { type: "checkbox", ref: c, ...l }), !!i && v(Te, { weight: "regular", children: i }), !!s && v("div", { "data-field": "description", children: s }), !!a && v(Xt, { children: a })] });
3242
+ }), rn = De({
3243
+ current: null
3244
+ }), Ar = ({ children: e }) => {
3245
+ const r = ve(null);
3246
+ return v(rn.Provider, { value: r, children: e });
3247
+ };
3248
+ Ar.displayName = "DialogTriggerContext";
3249
+ const ns = A(function({ asChild: r, children: t, className: n, placement: o = "center", closeButton: i = "Lukk dialogvindu", closedby: s = "closerequest", modal: a = !0, onClose: l, open: c, ...f }, d) {
3250
+ const h = oe(rn), u = ve(null), m = r ? se : "dialog", g = Be([h, d, u]), C = a ? "showModal" : "show";
3251
+ return ue(() => u.current?.[c ? C : "close"](), [c]), ue(() => {
3252
+ const x = u.current, y = (w) => {
3253
+ if (w.defaultPrevented)
3254
+ return;
3255
+ const { clientY: _, clientX: M, target: j } = w;
3256
+ if (j instanceof Element && w.type === "click" && j.closest('[data-command="close"]'))
3257
+ return x?.close();
3258
+ if (!(x && "closedBy" in x)) {
3259
+ if (w instanceof KeyboardEvent)
3260
+ return s === "none" && w.key === "Escape" && w.preventDefault();
3261
+ if (!window.getSelection()?.toString() && x && j === x && s === "any") {
3262
+ const { top: $, left: Z, right: G, bottom: q } = x.getBoundingClientRect();
3263
+ $ <= _ && _ <= q && Z <= M && M <= G || x?.close();
3264
+ }
3265
+ }
3266
+ }, b = () => {
3267
+ const w = x?.querySelector("[autofocus]");
3268
+ document.activeElement !== w && w?.focus();
3269
+ };
3270
+ return x?.addEventListener("animationend", b), x?.addEventListener("click", y), x?.addEventListener("keydown", y), () => {
3271
+ x?.removeEventListener("animationend", b), x?.removeEventListener("click", y), x?.removeEventListener("keydown", y);
3272
+ };
3273
+ }, [s]), ue(() => {
3274
+ const x = (b) => l?.(b), y = u.current;
3275
+ return y?.addEventListener("close", x), () => y?.removeEventListener("close", x);
3276
+ }, [l]), ie(m, { className: X("ds-dialog", n), ref: g, "data-placement": o, "data-modal": a, closedby: s, ...f, children: [i !== !1 && v(Ye, { "aria-label": i, "data-color": "neutral", icon: !0, variant: "tertiary", "data-command": "close" }), t] });
3277
+ }), rs = A(function({ asChild: r, className: t, ...n }, o) {
3278
+ return v(r ? se : "div", { className: X("ds-dialog__block", t), ref: o, ...n });
3279
+ }), os = A(function({ asChild: r, ...t }, n) {
3280
+ const o = oe(rn);
3281
+ return v(r ? se : Ye, { "aria-haspopup": "dialog", onClick: () => {
3282
+ o.current?.getAttribute("data-modal") === "true" ? o.current?.showModal() : o.current?.show();
3283
+ }, ref: n, ...t });
3284
+ }), on = Object.assign(ns, {
3285
+ Block: rs,
3286
+ TriggerContext: Ar,
3287
+ Trigger: os
3288
+ });
3289
+ on.Block.displayName = "Dialog.Block";
3290
+ on.TriggerContext.displayName = "Dialog.TriggerContext";
3291
+ on.Trigger.displayName = "Dialog.Trigger";
3292
+ const _r = ({ children: e }) => {
3293
+ const r = Ve(), [t, n] = ye(r);
3294
+ return v(sn.Provider, { value: { popoverId: t, setPopoverId: n }, children: e });
3295
+ };
3296
+ _r.displayName = "PopoverTriggerContext";
3297
+ const sn = De({}), is = A(function({ id: r, className: t, onClose: n, onOpen: o, open: i, variant: s = "default", placement: a = "top", autoPlacement: l = !0, asChild: c = !1, ...f }, d) {
3298
+ const h = c ? se : "div", u = ve(null), m = Be([u, d]), { popoverId: g, setPopoverId: C } = oe(sn), [x, y] = ye(!1), b = i ?? x;
3299
+ return ue(() => {
3300
+ const w = u.current, _ = (j) => {
3301
+ const $ = j.target, Z = $?.closest?.(`[popovertarget="${w?.id}"]`), G = !Z && !w?.contains($);
3302
+ Z && j.preventDefault(), b && (Z || G) ? (y(!1), n?.()) : !b && Z && (y(!0), o?.());
3303
+ }, M = (j) => {
3304
+ j.key !== "Escape" || !b || (j.preventDefault(), y(!1), n?.());
3305
+ };
3306
+ return w?.togglePopover?.(b), document.addEventListener("click", _, !0), document.addEventListener("keydown", M), () => {
3307
+ document.removeEventListener("click", _, !0), document.removeEventListener("keydown", M);
3308
+ };
3309
+ }, [b]), ue(() => {
3310
+ const w = u.current, _ = document.querySelector(`[popovertarget="${w?.id}"]`);
3311
+ if (w && _ && b)
3312
+ return Xn(_, w, () => {
3313
+ Un(_, w, {
3314
+ placement: a,
3315
+ strategy: "fixed",
3316
+ middleware: [
3317
+ Hn((M) => {
3318
+ const j = getComputedStyle(M.elements.floating, "::before");
3319
+ return parseFloat(j.height);
3320
+ }),
3321
+ ...l ? [qn({ fallbackAxisSideDirection: "start" }), Gr()] : [],
3322
+ ss
3323
+ ]
3324
+ }).then(({ x: M, y: j }) => {
3325
+ w.style.translate = `${Math.round(M)}px ${Math.round(j)}px`;
3326
+ });
3327
+ });
3328
+ }, [b, a, r, l]), ue(() => {
3329
+ r && C?.(r);
3330
+ }, [r]), v(h, { className: X("ds-popover", t), id: r || g, popover: "manual", "data-variant": s, ref: m, ...f });
3331
+ }), ss = {
3332
+ name: "ArrowPseudoElement",
3333
+ fn(e) {
3334
+ const { elements: r, rects: t, placement: n } = e;
3335
+ let o = `${Math.round(t.reference.width / 2 + t.reference.x - e.x)}px`, i = `${Math.round(t.reference.height / 2 + t.reference.y - e.y)}px`;
3336
+ switch (t.reference.width > t.floating.width && (o = `${Math.round(t.floating.width / 2)}px`), t.reference.height > t.floating.height && (i = `${Math.round(t.floating.height / 2)}px`), n.split("-")[0]) {
3337
+ case "top":
3338
+ i = "100%";
3339
+ break;
3340
+ case "right":
3341
+ o = "0";
3342
+ break;
3343
+ case "bottom":
3344
+ i = "0";
3345
+ break;
3346
+ case "left":
3347
+ o = "100%";
3348
+ break;
3349
+ }
3350
+ return r.floating.setAttribute("data-placement", n.split("-")[0]), r.floating.style.setProperty("--ds-popover-arrow-x", o), r.floating.style.setProperty("--ds-popover-arrow-y", i), e;
3351
+ }
3352
+ }, as = A(function({ id: r, inline: t, asChild: n, ...o }, i) {
3353
+ const { popoverId: s } = oe(sn), a = n ? se : t ? "button" : Ye, l = Object.assign({
3354
+ [$r.startsWith("19") ? "popoverTarget" : "popovertarget"]: s,
3355
+ ...t ? {
3356
+ "data-popover": "inline"
3357
+ } : {}
3358
+ }, o);
3359
+ return v(a, { ref: i, ...l });
3360
+ }), _s = A(function({ asChild: r, ...t }, n) {
3361
+ return v(r ? se : "li", { ...t, ref: n });
3362
+ }), Fr = (e, { asChild: r, className: t, ...n }, o) => v(r ? se : e, { className: X("ds-list", t), ref: o, ...n }), Fs = A(function(r, t) {
3363
+ return Fr("ul", r, t);
3364
+ });
3365
+ A(function(r, t) {
3366
+ return Fr("ol", r, t);
3367
+ });
3368
+ const ls = A(function({ "aria-label": r = "Sidenavigering", asChild: t, className: n, ...o }, i) {
3369
+ return v(t ? se : "nav", { "aria-label": r, className: X("ds-pagination", n), ref: i, ...o });
3370
+ }), cs = A(function(r, t) {
3371
+ return v(Ye, { ref: t, ...r });
3372
+ }), us = A(function({ asChild: r, className: t, ...n }, o) {
3373
+ return v(r ? se : "li", { ref: o, ...n });
3374
+ }), ds = A(function({ asChild: r, ...t }, n) {
3375
+ return v(r ? se : "ul", { ref: n, ...t });
3376
+ }), an = Object.assign(ls, {
3377
+ List: ds,
3378
+ Item: us,
3379
+ Button: cs
3380
+ });
3381
+ an.List.displayName = "Pagination.List";
3382
+ an.Item.displayName = "Pagination.Item";
3383
+ an.Button.displayName = "Pagination.Button";
3384
+ const Lr = Object.assign(is, {
3385
+ TriggerContext: _r,
3386
+ Trigger: as
3387
+ });
3388
+ Lr.TriggerContext.displayName = "Popover.TriggerContext";
3389
+ Lr.Trigger.displayName = "Popover.Trigger";
3390
+ const fs = A(function({ className: r, ...t }, n) {
3391
+ return v("div", { ref: n, className: X("ds-search", r), ...t });
3392
+ }), hs = A(function({ children: r = "Søk", ...t }, n) {
3393
+ return v(Ye, { ref: n, type: "submit", ...t, children: r });
3394
+ }), ms = A(function({ "aria-label": r = "Tøm", onClick: t, ...n }, o) {
3395
+ return v(Ye, { ref: o, variant: "tertiary", type: "reset", "aria-label": r, onClick: (s) => {
3396
+ const a = s.target;
3397
+ let l = null;
3398
+ if (a instanceof HTMLElement && (l = a.closest(".ds-search")?.querySelector("input")), !l)
3399
+ throw new Error("Input is missing");
3400
+ if (!(l instanceof HTMLInputElement))
3401
+ throw new Error("Input is not an input element");
3402
+ s.preventDefault(), Qe(l, ""), l.focus(), t?.(s);
3403
+ }, icon: !0, ...n });
3404
+ }), ps = A(function({ ...r }, t) {
3405
+ return v(ot, {
3406
+ ref: t,
3407
+ type: "search",
3408
+ /* We need an empty placeholder for the clear button to be able to show/hide */
3409
+ placeholder: "",
3410
+ ...r
3411
+ });
3412
+ }), ln = Object.assign(fs, {
3413
+ Clear: ms,
3414
+ Button: hs,
3415
+ Input: ps
3416
+ });
3417
+ ln.Clear.displayName = "Search.Clear";
3418
+ ln.Button.displayName = "Search.Button";
3419
+ ln.Input.displayName = "Search.Input";
3420
+ const Ls = A(function({ asChild: r, className: t, height: n, style: o, variant: i = "rectangle", width: s, ...a }, l) {
3421
+ const c = r ? se : "span", f = i === "text", d = qr("ds-skeleton-opacity-fade"), h = Be([d, l]);
3422
+ return v(c, { "aria-hidden": "true", className: X("ds-skeleton", t), "data-text": f ? "-".repeat(Number(s) || 1) : void 0, "data-variant": i, ref: h, style: f ? o : { width: s, height: n, ...o }, ...a });
3423
+ }), zs = A(function({ "data-size": r, children: t, className: n, description: o, label: i, position: s, style: a, ...l }, c) {
3424
+ return ie(pt, { className: n, "data-position": s, "data-size": r, style: a, children: [v(ot, { type: "checkbox", role: "switch", ref: c, ...l }), !!i && v(Te, { weight: "regular", children: i }), !!o && v("div", { "data-field": "description", children: o })] });
3425
+ }), kt = De({}), bs = A(function({ value: r, defaultValue: t, className: n, onChange: o, ...i }, s) {
3426
+ const a = ve(null), l = r !== void 0, [c, f] = ye(t), [d, h] = ye(/* @__PURE__ */ new Map());
3427
+ let u = o;
3428
+ return l || (u = (m) => {
3429
+ f(m), o?.(m);
3430
+ }, r = c), v(kt.Provider, { value: {
3431
+ value: r,
3432
+ defaultValue: t,
3433
+ onChange: u,
3434
+ tablistRef: a,
3435
+ panelButtonMap: d,
3436
+ setPanelButtonMap: h
3437
+ }, children: v("div", { className: X("ds-tabs", n), ref: s, ...i }) });
3438
+ }), gs = A(function({ children: r, ...t }, n) {
3439
+ const { value: o, tablistRef: i } = oe(kt), s = Be([n, i]);
3440
+ return v(Zr, { role: "tablist", activeValue: o, orientation: "ambiguous", ref: s, ...t, children: r });
3441
+ }), vs = A(function({ children: r, value: t, id: n, ...o }, i) {
3442
+ const { value: s, tablistRef: a, setPanelButtonMap: l } = oe(kt), c = t === s, f = Ve(), d = n ?? `tabpanel-${f}`, [h, u] = ye(!1), [m, g] = ye(void 0), C = ve(null), x = Be([i, C]);
3443
+ return ue(() => {
3444
+ if (!C.current)
3445
+ return;
3446
+ const y = C.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
3447
+ u(y.length > 0);
3448
+ }, [r]), ue(() => {
3449
+ if (!a)
3450
+ return;
3451
+ const y = a.current?.querySelector(`[role="tab"][data-value="${t}"]`);
3452
+ g(y ? y.id : void 0), y && l?.((b) => new Map(b).set(y.id, d));
3453
+ }, [a]), v("div", { ref: x, id: d, role: "tabpanel", tabIndex: h ? void 0 : 0, "aria-labelledby": m, hidden: !c, ...o, children: r });
3454
+ }), ys = A(function({ value: r, id: t, onClick: n, ...o }, i) {
3455
+ const s = oe(kt), a = Ve(), l = t ?? `tab-${a}`;
3456
+ return v(Qr, { value: r, ...o, asChild: !0, children: v("button", { ref: i, id: l, "aria-selected": s.value === r, "data-value": r, role: "tab", type: "button", onClick: (c) => {
3457
+ s.onChange?.(r), n?.(c);
3458
+ }, "aria-controls": s.panelButtonMap?.get(l), ...o }) });
3459
+ }), cn = Object.assign(bs, {
3460
+ List: gs,
3461
+ Tab: ys,
3462
+ Panel: vs
3463
+ });
3464
+ cn.Tab.displayName = "Tabs.Tab";
3465
+ cn.List.displayName = "Tabs.List";
3466
+ cn.Panel.displayName = "Tabs.Panel";
3467
+ const Vs = A(function({ label: r, description: t, error: n, multiline: o, prefix: i, suffix: s, "data-size": a, counter: l, style: c, className: f, ...d }, h) {
3468
+ return ie(pt, { className: f, "data-size": a, style: c, children: [!!r && v(Te, { children: r }), !!t && v(Hr, { children: t }), ie(Ur, { children: [i === void 0 || v(hn, { children: i }), o === !0 ? v(Yr, { ref: h, "aria-invalid": !!n || void 0, ...d }) : v(ot, { ref: h, "aria-invalid": !!n || void 0, ...d }), s === void 0 || v(hn, { children: s })] }), !!l && v(pt.Counter, { ...typeof l == "number" ? { limit: l } : l }), !!n && v(Xt, { children: n })] });
3469
+ });
3470
+ export {
3471
+ ro as B,
3472
+ As as C,
3473
+ on as D,
3474
+ oo as L,
3475
+ an as P,
3476
+ zs as S,
3477
+ Vs as T,
3478
+ St as a,
3479
+ Tt as b,
3480
+ _s as c,
3481
+ Fs as d,
3482
+ Lr as e,
3483
+ ln as f,
3484
+ Ls as g,
3485
+ cn as h,
3486
+ Ds as u
3487
+ };