@sps-woodland/tabs 8.50.2 → 8.51.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,3077 +1,17 @@
1
- import * as N from "react";
2
- import R, { useState as J, useRef as k, useEffect as H, useReducer as Sr, useCallback as V, useMemo as q, useContext as ae, createContext as Kr } from "react";
3
- import { flushSync as Wt } from "react-dom";
4
- import { Metadata as ve, modChildren as _r, cl as Te, Content as Er, useChildTestIdAttrBuilder as Tr, Icon as ut } from "@sps-woodland/core";
5
- import { code as dt } from "@spscommerce/utils";
6
- class ft {
7
- constructor(e) {
8
- this.keyMap = /* @__PURE__ */ new Map(), this.firstKey = null, this.lastKey = null, this.iterable = e;
9
- let r = (s) => {
10
- if (this.keyMap.set(s.key, s), s.childNodes && s.type === "section") for (let c of s.childNodes) r(c);
11
- };
12
- for (let s of e) r(s);
13
- let n = null, i = 0, l = 0;
14
- for (let [s, c] of this.keyMap)
15
- n ? (n.nextKey = s, c.prevKey = n.key) : (this.firstKey = s, c.prevKey = void 0), c.type === "item" && (c.index = i++), (c.type === "section" || c.type === "item") && l++, n = c, n.nextKey = void 0;
16
- this._size = l, this.lastKey = n?.key ?? null;
17
- }
18
- *[Symbol.iterator]() {
19
- yield* this.iterable;
20
- }
21
- get size() {
22
- return this._size;
23
- }
24
- getKeys() {
25
- return this.keyMap.keys();
26
- }
27
- getKeyBefore(e) {
28
- let r = this.keyMap.get(e);
29
- return r ? r.prevKey ?? null : null;
30
- }
31
- getKeyAfter(e) {
32
- let r = this.keyMap.get(e);
33
- return r ? r.nextKey ?? null : null;
34
- }
35
- getFirstKey() {
36
- return this.firstKey;
37
- }
38
- getLastKey() {
39
- return this.lastKey;
40
- }
41
- getItem(e) {
42
- return this.keyMap.get(e) ?? null;
43
- }
44
- at(e) {
45
- const r = [
46
- ...this.getKeys()
47
- ];
48
- return this.getItem(r[e]);
49
- }
50
- getChildren(e) {
51
- return this.keyMap.get(e)?.childNodes || [];
52
- }
53
- }
54
- class X extends Set {
55
- constructor(e, r, n) {
56
- super(e), e instanceof X ? (this.anchorKey = r ?? e.anchorKey, this.currentKey = n ?? e.currentKey) : (this.anchorKey = r ?? null, this.currentKey = n ?? null);
57
- }
58
- }
59
- const Pr = typeof document < "u" ? R.useInsertionEffect ?? R.useLayoutEffect : () => {
60
- };
61
- function Ut(t, e, r) {
62
- let [n, i] = J(t || e), l = k(n), s = k(t !== void 0), c = t !== void 0;
63
- H(() => {
64
- let g = s.current;
65
- g !== c && process.env.NODE_ENV !== "production" && console.warn(`WARN: A component changed from ${g ? "controlled" : "uncontrolled"} to ${c ? "controlled" : "uncontrolled"}.`), s.current = c;
66
- }, [
67
- c
68
- ]);
69
- let u = c ? t : n;
70
- Pr(() => {
71
- l.current = u;
72
- });
73
- let [, b] = Sr(() => ({}), {}), y = V((g, ...$) => {
74
- let v = typeof g == "function" ? g(l.current) : g;
75
- Object.is(l.current, v) || (l.current = v, i(v), b(), r?.(v, ...$));
76
- }, [
77
- r
78
- ]);
79
- return [
80
- u,
81
- y
82
- ];
83
- }
84
- function kr(t, e) {
85
- if (t.size !== e.size) return !1;
86
- for (let r of t)
87
- if (!e.has(r)) return !1;
88
- return !0;
89
- }
90
- function xr(t) {
91
- let { selectionMode: e = "none", disallowEmptySelection: r = !1, allowDuplicateSelectionEvents: n, selectionBehavior: i = "toggle", disabledBehavior: l = "all" } = t, s = k(!1), [, c] = J(!1), u = k(null), b = k(null), [, y] = J(null), g = q(() => pt(t.selectedKeys), [
92
- t.selectedKeys
93
- ]), $ = q(() => pt(t.defaultSelectedKeys, new X()), [
94
- t.defaultSelectedKeys
95
- ]), [v, M] = Ut(g, $, t.onSelectionChange), F = q(() => t.disabledKeys ? new Set(t.disabledKeys) : /* @__PURE__ */ new Set(), [
96
- t.disabledKeys
97
- ]), [_, C] = J(i);
98
- i === "replace" && _ === "toggle" && typeof v == "object" && v.size === 0 && C("replace");
99
- let E = k(i);
100
- return H(() => {
101
- i !== E.current && (C(i), E.current = i);
102
- }, [
103
- i
104
- ]), {
105
- selectionMode: e,
106
- disallowEmptySelection: r,
107
- selectionBehavior: _,
108
- setSelectionBehavior: C,
109
- get isFocused() {
110
- return s.current;
111
- },
112
- setFocused(x) {
113
- s.current = x, c(x);
114
- },
115
- get focusedKey() {
116
- return u.current;
117
- },
118
- get childFocusStrategy() {
119
- return b.current;
120
- },
121
- setFocusedKey(x, m = "first") {
122
- u.current = x, b.current = m, y(x);
123
- },
124
- selectedKeys: v,
125
- setSelectedKeys(x) {
126
- (n || !kr(x, v)) && M(x);
127
- },
128
- disabledKeys: F,
129
- disabledBehavior: l
130
- };
131
- }
132
- function pt(t, e) {
133
- return t ? t === "all" ? "all" : new X(t) : e;
134
- }
135
- function Lr(t, e) {
136
- return typeof e.getChildren == "function" ? e.getChildren(t.key) : t.childNodes;
137
- }
138
- function Cr(t) {
139
- return Ir(t);
140
- }
141
- function Ir(t, e) {
142
- for (let r of t)
143
- return r;
144
- }
145
- function Oe(t, e, r) {
146
- if (e.parentKey === r.parentKey) return e.index - r.index;
147
- let n = [
148
- ...ht(t, e),
149
- e
150
- ], i = [
151
- ...ht(t, r),
152
- r
153
- ], l = n.slice(0, i.length).findIndex((s, c) => s !== i[c]);
154
- return l !== -1 ? (e = n[l], r = i[l], e.index - r.index) : n.findIndex((s) => s === r) >= 0 ? 1 : (i.findIndex((s) => s === e) >= 0, -1);
155
- }
156
- function ht(t, e) {
157
- let r = [], n = e;
158
- for (; n?.parentKey != null; )
159
- n = t.getItem(n.parentKey), n && r.unshift(n);
160
- return r;
161
- }
162
- class et {
163
- constructor(e, r, n) {
164
- this.collection = e, this.state = r, this.allowsCellSelection = n?.allowsCellSelection ?? !1, this._isSelectAll = null, this.layoutDelegate = n?.layoutDelegate || null, this.fullCollection = n?.fullCollection || null;
165
- }
166
- /**
167
- * The type of selection that is allowed in the collection.
168
- */
169
- get selectionMode() {
170
- return this.state.selectionMode;
171
- }
172
- /**
173
- * Whether the collection allows empty selection.
174
- */
175
- get disallowEmptySelection() {
176
- return this.state.disallowEmptySelection;
177
- }
178
- /**
179
- * The selection behavior for the collection.
180
- */
181
- get selectionBehavior() {
182
- return this.state.selectionBehavior;
183
- }
184
- /**
185
- * Sets the selection behavior for the collection.
186
- */
187
- setSelectionBehavior(e) {
188
- this.state.setSelectionBehavior(e);
189
- }
190
- /**
191
- * Whether the collection is currently focused.
192
- */
193
- get isFocused() {
194
- return this.state.isFocused;
195
- }
196
- /**
197
- * Sets whether the collection is focused.
198
- */
199
- setFocused(e) {
200
- this.state.setFocused(e);
201
- }
202
- /**
203
- * The current focused key in the collection.
204
- */
205
- get focusedKey() {
206
- return this.state.focusedKey;
207
- }
208
- /** Whether the first or last child of the focused key should receive focus. */
209
- get childFocusStrategy() {
210
- return this.state.childFocusStrategy;
211
- }
212
- /**
213
- * Sets the focused key.
214
- */
215
- setFocusedKey(e, r) {
216
- (e == null || this.collection.getItem(e)) && this.state.setFocusedKey(e, r);
217
- }
218
- /**
219
- * The currently selected keys in the collection.
220
- */
221
- get selectedKeys() {
222
- return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
223
- }
224
- /**
225
- * The raw selection value for the collection.
226
- * Either 'all' for select all, or a set of keys.
227
- */
228
- get rawSelection() {
229
- return this.state.selectedKeys;
230
- }
231
- /**
232
- * Returns whether a key is selected.
233
- */
234
- isSelected(e) {
235
- if (this.state.selectionMode === "none") return !1;
236
- let r = this.getKey(e);
237
- return r == null ? !1 : this.state.selectedKeys === "all" ? this.canSelectItem(r) : this.state.selectedKeys.has(r);
238
- }
239
- /**
240
- * Whether the selection is empty.
241
- */
242
- get isEmpty() {
243
- return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
244
- }
245
- /**
246
- * Whether all items in the collection are selected.
247
- */
248
- get isSelectAll() {
249
- if (this.isEmpty) return !1;
250
- if (this.state.selectedKeys === "all") return !0;
251
- if (this._isSelectAll != null) return this._isSelectAll;
252
- let e = this.getSelectAllKeys(), r = this.state.selectedKeys;
253
- return this._isSelectAll = e.every((n) => r.has(n)), this._isSelectAll;
254
- }
255
- get firstSelectedKey() {
256
- let e = null;
257
- for (let r of this.state.selectedKeys) {
258
- let n = this.collection.getItem(r);
259
- (!e || n && Oe(this.collection, n, e) < 0) && (e = n);
260
- }
261
- return e?.key ?? null;
262
- }
263
- get lastSelectedKey() {
264
- let e = null;
265
- for (let r of this.state.selectedKeys) {
266
- let n = this.collection.getItem(r);
267
- (!e || n && Oe(this.collection, n, e) > 0) && (e = n);
268
- }
269
- return e?.key ?? null;
270
- }
271
- get disabledKeys() {
272
- return this.state.disabledKeys;
273
- }
274
- get disabledBehavior() {
275
- return this.state.disabledBehavior;
276
- }
277
- /**
278
- * Extends the selection to the given key.
279
- */
280
- extendSelection(e) {
281
- if (this.selectionMode === "none") return;
282
- if (this.selectionMode === "single") {
283
- this.replaceSelection(e);
284
- return;
285
- }
286
- let r = this.getKey(e);
287
- if (r == null) return;
288
- let n;
289
- if (this.state.selectedKeys === "all") n = new X([
290
- r
291
- ], r, r);
292
- else {
293
- let i = this.state.selectedKeys, l = i.anchorKey ?? r;
294
- n = new X(i, l, r);
295
- for (let s of this.getKeyRange(l, i.currentKey ?? r)) n.delete(s);
296
- for (let s of this.getKeyRange(r, l)) this.canSelectItem(s) && n.add(s);
297
- }
298
- this.state.setSelectedKeys(n);
299
- }
300
- getKeyRange(e, r) {
301
- let n = this.collection.getItem(e), i = this.collection.getItem(r);
302
- return n && i ? Oe(this.collection, n, i) <= 0 ? this.getKeyRangeInternal(e, r) : this.getKeyRangeInternal(r, e) : [];
303
- }
304
- getKeyRangeInternal(e, r) {
305
- if (this.layoutDelegate?.getKeyRange) return this.layoutDelegate.getKeyRange(e, r);
306
- let n = [], i = e;
307
- for (; i != null; ) {
308
- let l = this.collection.getItem(i);
309
- if (l && (l.type === "item" || l.type === "cell" && this.allowsCellSelection) && n.push(i), i === r) return n;
310
- i = this.collection.getKeyAfter(i);
311
- }
312
- return [];
313
- }
314
- getKey(e) {
315
- let r = this.collection.getItem(e);
316
- if (!r || r.type === "cell" && this.allowsCellSelection) return e;
317
- for (; r && r.type !== "item" && r.parentKey != null; ) r = this.collection.getItem(r.parentKey);
318
- return !r || r.type !== "item" ? null : r.key;
319
- }
320
- /**
321
- * Toggles whether the given key is selected.
322
- */
323
- toggleSelection(e) {
324
- if (this.selectionMode === "none") return;
325
- if (this.selectionMode === "single" && !this.isSelected(e)) {
326
- this.replaceSelection(e);
327
- return;
328
- }
329
- let r = this.getKey(e);
330
- if (r == null) return;
331
- let n = new X(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
332
- n.has(r) ? n.delete(r) : this.canSelectItem(r) && (n.add(r), n.anchorKey = r, n.currentKey = r), !(this.disallowEmptySelection && n.size === 0) && this.state.setSelectedKeys(n);
333
- }
334
- /**
335
- * Replaces the selection with only the given key.
336
- */
337
- replaceSelection(e) {
338
- if (this.selectionMode === "none") return;
339
- let r = this.getKey(e);
340
- if (r == null) return;
341
- let n = this.canSelectItem(r) ? new X([
342
- r
343
- ], r, r) : new X();
344
- this.state.setSelectedKeys(n);
345
- }
346
- /**
347
- * Replaces the selection with the given keys.
348
- */
349
- setSelectedKeys(e) {
350
- if (this.selectionMode === "none") return;
351
- let r = new X();
352
- for (let n of e) {
353
- let i = this.getKey(n);
354
- if (i != null && (r.add(i), this.selectionMode === "single"))
355
- break;
356
- }
357
- this.state.setSelectedKeys(r);
358
- }
359
- getSelectAllKeys() {
360
- let e = this.fullCollection ?? this.collection, r = [], n = (i) => {
361
- for (; i != null; ) {
362
- if (this.canSelectItemIn(i, e)) {
363
- let l = e.getItem(i);
364
- l?.type === "item" && r.push(i), l?.hasChildNodes && (this.allowsCellSelection || l.type !== "item") && n(Cr(Lr(l, e))?.key ?? null);
365
- }
366
- i = e.getKeyAfter(i);
367
- }
368
- };
369
- return n(e.getFirstKey()), r;
370
- }
371
- /**
372
- * Selects all items in the collection.
373
- */
374
- selectAll() {
375
- !this.isSelectAll && this.selectionMode === "multiple" && this.state.setSelectedKeys("all");
376
- }
377
- /**
378
- * Removes all keys from the selection.
379
- */
380
- clearSelection() {
381
- !this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0) && this.state.setSelectedKeys(new X());
382
- }
383
- /**
384
- * Toggles between select all and an empty selection.
385
- */
386
- toggleSelectAll() {
387
- this.isSelectAll ? this.clearSelection() : this.selectAll();
388
- }
389
- select(e, r) {
390
- this.selectionMode !== "none" && (this.selectionMode === "single" ? this.isSelected(e) && !this.disallowEmptySelection ? this.toggleSelection(e) : this.replaceSelection(e) : this.selectionBehavior === "toggle" || r && (r.pointerType === "touch" || r.pointerType === "virtual") ? this.toggleSelection(e) : this.replaceSelection(e));
391
- }
392
- /**
393
- * Returns whether the current selection is equal to the given selection.
394
- */
395
- isSelectionEqual(e) {
396
- if (e === this.state.selectedKeys) return !0;
397
- let r = this.selectedKeys;
398
- if (e.size !== r.size) return !1;
399
- for (let n of e)
400
- if (!r.has(n)) return !1;
401
- for (let n of r)
402
- if (!e.has(n)) return !1;
403
- return !0;
404
- }
405
- canSelectItem(e) {
406
- return this.canSelectItemIn(e, this.collection);
407
- }
408
- canSelectItemIn(e, r) {
409
- if (this.state.selectionMode === "none" || this.state.disabledKeys.has(e)) return !1;
410
- let n = r.getItem(e);
411
- return !(!n || n?.props?.isDisabled || n.type === "cell" && !this.allowsCellSelection);
412
- }
413
- isDisabled(e) {
414
- return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(e) || !!this.collection.getItem(e)?.props?.isDisabled);
415
- }
416
- isLink(e) {
417
- return !!this.collection.getItem(e)?.props?.href;
418
- }
419
- getItemProps(e) {
420
- return this.collection.getItem(e)?.props;
421
- }
422
- withCollection(e) {
423
- return new et(e, this.state, {
424
- allowsCellSelection: this.allowsCellSelection,
425
- layoutDelegate: this.layoutDelegate || void 0,
426
- fullCollection: this.fullCollection ?? this.collection
427
- });
428
- }
429
- }
430
- class Fr {
431
- build(e, r) {
432
- return this.context = r, bt(() => this.iterateCollection(e));
433
- }
434
- *iterateCollection(e) {
435
- let { children: r, items: n } = e;
436
- if (R.isValidElement(r) && r.type === R.Fragment) yield* this.iterateCollection({
437
- children: r.props.children,
438
- items: n
439
- });
440
- else if (typeof r == "function") {
441
- if (!n) throw new Error("props.children was a function but props.items is missing");
442
- let i = 0;
443
- for (let l of n)
444
- yield* this.getFullNode({
445
- value: l,
446
- index: i
447
- }, {
448
- renderer: r
449
- }), i++;
450
- } else {
451
- let i = [];
452
- R.Children.forEach(r, (s) => {
453
- s && i.push(s);
454
- });
455
- let l = 0;
456
- for (let s of i) {
457
- let c = this.getFullNode({
458
- element: s,
459
- index: l
460
- }, {});
461
- for (let u of c)
462
- l++, yield u;
463
- }
464
- }
465
- }
466
- getKey(e, r, n, i) {
467
- if (e.key != null) return e.key;
468
- if (r.type === "cell" && r.key != null) return `${i}${r.key}`;
469
- let l = r.value;
470
- if (l != null) {
471
- let s = l.key ?? l.id;
472
- if (s == null) throw new Error("No key found for item");
473
- return s;
474
- }
475
- return i ? `${i}.${r.index}` : `$.${r.index}`;
476
- }
477
- getChildState(e, r) {
478
- return {
479
- renderer: r.renderer || e.renderer
480
- };
481
- }
482
- *getFullNode(e, r, n, i) {
483
- if (R.isValidElement(e.element) && e.element.type === R.Fragment) {
484
- let u = [];
485
- R.Children.forEach(e.element.props.children, (y) => {
486
- u.push(y);
487
- });
488
- let b = e.index ?? 0;
489
- for (const y of u) yield* this.getFullNode({
490
- element: y,
491
- index: b++
492
- }, r, n, i);
493
- return;
494
- }
495
- let l = e.element;
496
- if (!l && e.value && r && r.renderer) {
497
- let u = this.cache.get(e.value);
498
- if (u && (!u.shouldInvalidate || !u.shouldInvalidate(this.context))) {
499
- u.index = e.index, u.parentKey = i ? i.key : null, yield u;
500
- return;
501
- }
502
- l = r.renderer(e.value);
503
- }
504
- if (R.isValidElement(l)) {
505
- let u = l.type;
506
- if (typeof u != "function" && typeof u.getCollectionNode != "function") {
507
- let $ = l.type;
508
- throw new Error(`Unknown element <${$}> in collection.`);
509
- }
510
- let b = u.getCollectionNode(l.props, this.context), y = e.index ?? 0, g = b.next();
511
- for (; !g.done && g.value; ) {
512
- let $ = g.value;
513
- e.index = y;
514
- let v = $.key ?? null;
515
- v == null && (v = $.element ? null : this.getKey(l, e, r, n));
516
- let F = [
517
- ...this.getFullNode({
518
- ...$,
519
- key: v,
520
- index: y,
521
- wrapper: Mr(e.wrapper, $.wrapper)
522
- }, this.getChildState(r, $), n ? `${n}${l.key}` : l.key, i)
523
- ];
524
- for (let _ of F) {
525
- if (_.value = $.value ?? e.value ?? null, _.value && this.cache.set(_.value, _), e.type && _.type !== e.type) throw new Error(`Unsupported type <${Ae(_.type)}> in <${Ae(i?.type ?? "unknown parent type")}>. Only <${Ae(e.type)}> is supported.`);
526
- y++, yield _;
527
- }
528
- g = b.next(F);
529
- }
530
- return;
531
- }
532
- if (e.key == null || e.type == null) return;
533
- let s = this, c = {
534
- type: e.type,
535
- props: e.props,
536
- key: e.key,
537
- parentKey: i ? i.key : null,
538
- value: e.value ?? null,
539
- level: (i?.level ?? 0) + (i?.type === "item" ? 1 : 0),
540
- index: e.index,
541
- rendered: e.rendered,
542
- textValue: e.textValue ?? "",
543
- "aria-label": e["aria-label"],
544
- wrapper: e.wrapper,
545
- shouldInvalidate: e.shouldInvalidate,
546
- hasChildNodes: e.hasChildNodes || !1,
547
- childNodes: bt(function* () {
548
- if (!e.hasChildNodes || !e.childNodes) return;
549
- let u = 0;
550
- for (let b of e.childNodes()) {
551
- b.key != null && (b.key = `${c.key}${b.key}`);
552
- let y = s.getFullNode({
553
- ...b,
554
- index: u
555
- }, s.getChildState(r, b), c.key, c);
556
- for (let g of y)
557
- u++, yield g;
558
- }
559
- })
560
- };
561
- yield c;
562
- }
563
- constructor() {
564
- this.cache = /* @__PURE__ */ new WeakMap();
565
- }
566
- }
567
- function bt(t) {
568
- let e = [], r = null;
569
- return {
570
- *[Symbol.iterator]() {
571
- for (let n of e) yield n;
572
- r || (r = t());
573
- for (let n of r)
574
- e.push(n), yield n;
575
- }
576
- };
577
- }
578
- function Mr(t, e) {
579
- if (t && e) return (r) => t(e(r));
580
- if (t) return t;
581
- if (e) return e;
582
- }
583
- function Ae(t) {
584
- return t[0].toUpperCase() + t.slice(1);
585
- }
586
- function Dr(t, e, r) {
587
- let n = q(() => new Fr(), []), { children: i, items: l, collection: s } = t;
588
- return q(() => {
589
- if (s) return s;
590
- let u = n.build({
591
- children: i,
592
- items: l
593
- }, r);
594
- return e(u);
595
- }, [
596
- n,
597
- i,
598
- l,
599
- s,
600
- r,
601
- e
602
- ]);
603
- }
604
- function Nr(t) {
605
- let { filter: e, layoutDelegate: r } = t, n = xr(t), i = q(() => t.disabledKeys ? new Set(t.disabledKeys) : /* @__PURE__ */ new Set(), [
606
- t.disabledKeys
607
- ]), l = V((b) => e ? new ft(e(b)) : new ft(b), [
608
- e
609
- ]), s = q(() => ({
610
- suppressTextValueWarning: t.suppressTextValueWarning
611
- }), [
612
- t.suppressTextValueWarning
613
- ]), c = Dr(t, l, s), u = q(() => new et(c, n, {
614
- layoutDelegate: r
615
- }), [
616
- c,
617
- n,
618
- r
619
- ]);
620
- return Rr(c, u), {
621
- collection: c,
622
- disabledKeys: i,
623
- selectionManager: u
624
- };
625
- }
626
- function Rr(t, e) {
627
- const r = k(null);
628
- H(() => {
629
- if (e.focusedKey != null && !t.getItem(e.focusedKey) && r.current) {
630
- let n = r.current.getKeyAfter(e.focusedKey), i = null;
631
- for (; n != null; ) {
632
- let l = t.getItem(n);
633
- if (l && l.type === "item" && !e.isDisabled(n)) {
634
- i = n;
635
- break;
636
- }
637
- n = r.current.getKeyAfter(n);
638
- }
639
- if (i == null)
640
- for (n = r.current.getKeyBefore(e.focusedKey); n != null; ) {
641
- let l = t.getItem(n);
642
- if (l && l.type === "item" && !e.isDisabled(n)) {
643
- i = n;
644
- break;
645
- }
646
- n = r.current.getKeyBefore(n);
647
- }
648
- e.setFocusedKey(i);
649
- }
650
- r.current = t;
651
- }, [
652
- t,
653
- e
654
- ]);
655
- }
656
- function Or(t) {
657
- let [e, r] = Ut(t.selectedKey, t.defaultSelectedKey ?? null, t.onSelectionChange), n = q(() => e != null ? [
658
- e
659
- ] : [], [
660
- e
661
- ]), { collection: i, disabledKeys: l, selectionManager: s } = Nr({
662
- ...t,
663
- selectionMode: "single",
664
- disallowEmptySelection: !0,
665
- allowDuplicateSelectionEvents: !0,
666
- selectedKeys: n,
667
- onSelectionChange: (u) => {
668
- if (u === "all") return;
669
- let b = u.values().next().value ?? null;
670
- b === e && t.onSelectionChange && t.onSelectionChange(b), r(b);
671
- }
672
- }), c = e != null ? i.getItem(e) : null;
673
- return {
674
- collection: i,
675
- disabledKeys: l,
676
- selectionManager: s,
677
- selectedKey: e,
678
- setSelectedKey: r,
679
- selectedItem: c
680
- };
681
- }
682
- function Ar(t) {
683
- let e = Or({
684
- ...t,
685
- onSelectionChange: t.onSelectionChange ? (s) => {
686
- s != null && t.onSelectionChange?.(s);
687
- } : void 0,
688
- suppressTextValueWarning: !0,
689
- defaultSelectedKey: t.defaultSelectedKey ?? yt(t.collection, t.disabledKeys ? new Set(t.disabledKeys) : /* @__PURE__ */ new Set()) ?? void 0
690
- }), { selectionManager: r, collection: n, selectedKey: i } = e, l = k(i);
691
- return H(() => {
692
- let s = i;
693
- t.selectedKey == null && (r.isEmpty || s == null || !n.getItem(s)) && (s = yt(n, e.disabledKeys), s != null && r.setSelectedKeys([
694
- s
695
- ])), (s != null && r.focusedKey == null || !r.isFocused && s !== l.current) && r.setFocusedKey(s), l.current = s;
696
- }), {
697
- ...e,
698
- isDisabled: t.isDisabled || !1
699
- };
700
- }
701
- function yt(t, e) {
702
- let r = null;
703
- if (t) {
704
- for (r = t.getFirstKey(); r != null && (e.has(r) || t.getItem(r)?.props?.isDisabled) && r !== t.getLastKey(); ) r = t.getKeyAfter(r);
705
- r != null && (e.has(r) || t.getItem(r)?.props?.isDisabled) && r === t.getLastKey() && (r = t.getFirstKey());
706
- }
707
- return r;
708
- }
709
- const Br = /* @__PURE__ */ new Set([
710
- "id"
711
- ]), zr = /* @__PURE__ */ new Set([
712
- "aria-label",
713
- "aria-labelledby",
714
- "aria-describedby",
715
- "aria-details"
716
- ]), Wr = /* @__PURE__ */ new Set([
717
- "href",
718
- "hrefLang",
719
- "target",
720
- "rel",
721
- "download",
722
- "ping",
723
- "referrerPolicy"
724
- ]), Ur = /* @__PURE__ */ new Set([
725
- "dir",
726
- "lang",
727
- "hidden",
728
- "inert",
729
- "translate"
730
- ]), gt = /* @__PURE__ */ new Set([
731
- "onClick",
732
- "onAuxClick",
733
- "onContextMenu",
734
- "onDoubleClick",
735
- "onMouseDown",
736
- "onMouseEnter",
737
- "onMouseLeave",
738
- "onMouseMove",
739
- "onMouseOut",
740
- "onMouseOver",
741
- "onMouseUp",
742
- "onTouchCancel",
743
- "onTouchEnd",
744
- "onTouchMove",
745
- "onTouchStart",
746
- "onPointerDown",
747
- "onPointerMove",
748
- "onPointerUp",
749
- "onPointerCancel",
750
- "onPointerEnter",
751
- "onPointerLeave",
752
- "onPointerOver",
753
- "onPointerOut",
754
- "onGotPointerCapture",
755
- "onLostPointerCapture",
756
- "onScroll",
757
- "onWheel",
758
- "onAnimationStart",
759
- "onAnimationEnd",
760
- "onAnimationIteration",
761
- "onTransitionCancel",
762
- "onTransitionEnd",
763
- "onTransitionRun",
764
- "onTransitionStart"
765
- ]), Vr = /^(data-.*)$/;
766
- function Hr(t, e = {}) {
767
- let { labelable: r, isLink: n, global: i, events: l = i, propNames: s } = e, c = {};
768
- for (const u in t) Object.prototype.hasOwnProperty.call(t, u) && (Br.has(u) || r && zr.has(u) || n && Wr.has(u) || i && Ur.has(u) || l && (gt.has(u) || u.endsWith("Capture") && gt.has(u.slice(0, -7))) || s?.has(u) || Vr.test(u)) && (c[u] = t[u]);
769
- return c;
770
- }
771
- const Vt = /* @__PURE__ */ new WeakMap();
772
- function xe(t, e, r) {
773
- if (!t)
774
- return "";
775
- typeof e == "string" && (e = e.replace(/\s+/g, ""));
776
- let n = Vt.get(t);
777
- return process.env.NODE_ENV !== "production" && !n && console.error("There is no tab id, please check if you have rendered the tab panel before the tab list."), `${n}-${r}-${e}`;
778
- }
779
- function tt(...t) {
780
- return (...e) => {
781
- for (let r of t) typeof r == "function" && r(...e);
782
- };
783
- }
784
- const ie = typeof document < "u" ? R.useLayoutEffect : () => {
785
- }, Le = {
786
- prefix: String(Math.round(Math.random() * 1e10)),
787
- current: 0
788
- }, Ht = /* @__PURE__ */ R.createContext(Le), jr = /* @__PURE__ */ R.createContext(!1);
789
- let Gr = !!(typeof window < "u" && window.document && window.document.createElement), Be = /* @__PURE__ */ new WeakMap();
790
- function Yr(t = !1) {
791
- let e = ae(Ht), r = k(null);
792
- if (r.current === null && !t) {
793
- let n = R.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentOwner?.current;
794
- if (n) {
795
- let i = Be.get(n);
796
- i == null ? Be.set(n, {
797
- id: e.current,
798
- state: n.memoizedState
799
- }) : n.memoizedState !== i.state && (e.current = i.id, Be.delete(n));
800
- }
801
- r.current = ++e.current;
802
- }
803
- return r.current;
804
- }
805
- function Xr(t) {
806
- let e = ae(Ht);
807
- e === Le && !Gr && process.env.NODE_ENV !== "production" && console.warn("When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.");
808
- let r = Yr(!!t), n = e === Le && process.env.NODE_ENV === "test" ? "react-aria" : `react-aria${e.prefix}`;
809
- return t || `${n}-${r}`;
810
- }
811
- function qr(t) {
812
- let e = R.useId(), [r] = J(jt()), n = r || process.env.NODE_ENV === "test" ? "react-aria" : `react-aria${Le.prefix}`;
813
- return t || `${n}-${e}`;
814
- }
815
- const Jr = typeof R.useId == "function" ? qr : Xr;
816
- function Zr() {
817
- return !1;
818
- }
819
- function Qr() {
820
- return !0;
821
- }
822
- function en(t) {
823
- return () => {
824
- };
825
- }
826
- function jt() {
827
- return typeof R.useSyncExternalStore == "function" ? R.useSyncExternalStore(en, Zr, Qr) : ae(jr);
828
- }
829
- let tn = !!(typeof window < "u" && window.document && window.document.createElement), de = /* @__PURE__ */ new Map(), ye;
830
- typeof FinalizationRegistry < "u" && (ye = new FinalizationRegistry((t) => {
831
- de.delete(t);
832
- }));
833
- function Me(t) {
834
- let [e, r] = J(t), n = k(null), i = Jr(e), l = k(null);
835
- if (ye && ye.register(l, i), tn) {
836
- const s = de.get(i);
837
- s && !s.includes(n) ? s.push(n) : de.set(i, [
838
- n
839
- ]);
840
- }
841
- return ie(() => {
842
- let s = i;
843
- return () => {
844
- ye && ye.unregister(l), de.delete(s);
845
- };
846
- }, [
847
- i
848
- ]), H(() => {
849
- let s = n.current;
850
- return s && r(s), () => {
851
- s && (n.current = null);
852
- };
853
- }), i;
854
- }
855
- function rn(t, e) {
856
- if (t === e) return t;
857
- let r = de.get(t);
858
- if (r)
859
- return r.forEach((i) => i.current = e), e;
860
- let n = de.get(e);
861
- return n ? (n.forEach((i) => i.current = t), t) : e;
862
- }
863
- function nn(...t) {
864
- return t.length === 1 && t[0] ? t[0] : (e) => {
865
- let r = !1;
866
- const n = t.map((i) => {
867
- const l = $t(i, e);
868
- return r ||= typeof l == "function", l;
869
- });
870
- if (r) return () => {
871
- n.forEach((i, l) => {
872
- typeof i == "function" ? i() : $t(t[l], null);
873
- });
874
- };
875
- };
876
- }
877
- function $t(t, e) {
878
- if (typeof t == "function") return t(e);
879
- t != null && (t.current = e);
880
- }
881
- function Gt(t) {
882
- var e, r, n = "";
883
- if (typeof t == "string" || typeof t == "number") n += t;
884
- else if (typeof t == "object") if (Array.isArray(t)) {
885
- var i = t.length;
886
- for (e = 0; e < i; e++) t[e] && (r = Gt(t[e])) && (n && (n += " "), n += r);
887
- } else for (r in t) t[r] && (n && (n += " "), n += r);
888
- return n;
889
- }
890
- function on() {
891
- for (var t, e, r = 0, n = "", i = arguments.length; r < i; r++) (t = arguments[r]) && (e = Gt(t)) && (n && (n += " "), n += e);
892
- return n;
893
- }
894
- function G(...t) {
895
- let e = {
896
- ...t[0]
897
- };
898
- for (let r = 1; r < t.length; r++) {
899
- let n = t[r];
900
- for (let i in n) {
901
- let l = e[i], s = n[i];
902
- typeof l == "function" && typeof s == "function" && // This is a lot faster than a regex.
903
- i[0] === "o" && i[1] === "n" && i.charCodeAt(2) >= /* 'A' */
904
- 65 && i.charCodeAt(2) <= /* 'Z' */
905
- 90 ? e[i] = tt(l, s) : (i === "className" || i === "UNSAFE_className") && typeof l == "string" && typeof s == "string" ? e[i] = on(l, s) : i === "id" && l && s ? e.id = rn(l, s) : i === "ref" && l && s ? e.ref = nn(l, s) : e[i] = s !== void 0 ? s : l;
906
- }
907
- }
908
- return e;
909
- }
910
- function Q(t) {
911
- if (ln()) t.focus({
912
- preventScroll: !0
913
- });
914
- else {
915
- let e = sn(t);
916
- t.focus(), an(e);
917
- }
918
- }
919
- let Ke = null;
920
- function ln() {
921
- if (Ke == null) {
922
- Ke = !1;
923
- try {
924
- document.createElement("div").focus({
925
- get preventScroll() {
926
- return Ke = !0, !0;
927
- }
928
- });
929
- } catch {
930
- }
931
- }
932
- return Ke;
933
- }
934
- function sn(t) {
935
- let e = t.parentNode, r = [], n = document.scrollingElement || document.documentElement;
936
- for (; e instanceof HTMLElement && e !== n; )
937
- (e.offsetHeight < e.scrollHeight || e.offsetWidth < e.scrollWidth) && r.push({
938
- element: e,
939
- scrollTop: e.scrollTop,
940
- scrollLeft: e.scrollLeft
941
- }), e = e.parentNode;
942
- return n instanceof HTMLElement && r.push({
943
- element: n,
944
- scrollTop: n.scrollTop,
945
- scrollLeft: n.scrollLeft
946
- }), r;
947
- }
948
- function an(t) {
949
- for (let { element: e, scrollTop: r, scrollLeft: n } of t)
950
- e.scrollTop = r, e.scrollLeft = n;
951
- }
952
- const z = (t) => t?.ownerDocument ?? document, Y = (t) => t && "window" in t && t.window === t ? t : z(t).defaultView || window;
953
- function cn(t) {
954
- return t !== null && typeof t == "object" && "nodeType" in t && typeof t.nodeType == "number";
955
- }
956
- function un(t) {
957
- return cn(t) && t.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in t;
958
- }
959
- let dn = !1;
960
- function De() {
961
- return dn;
962
- }
963
- function P(t, e) {
964
- if (!De()) return e && t ? t.contains(e) : !1;
965
- if (!t || !e) return !1;
966
- let r = e;
967
- for (; r !== null; ) {
968
- if (r === t) return !0;
969
- r.tagName === "SLOT" && r.assignedSlot ? r = r.assignedSlot.parentNode : un(r) ? r = r.host : r = r.parentNode;
970
- }
971
- return !1;
972
- }
973
- const Z = (t = document) => {
974
- if (!De()) return t.activeElement;
975
- let e = t.activeElement;
976
- for (; e && "shadowRoot" in e && e.shadowRoot?.activeElement; ) e = e.shadowRoot.activeElement;
977
- return e;
978
- };
979
- function w(t) {
980
- if (De() && t.target instanceof Element && t.target.shadowRoot) {
981
- if ("composedPath" in t) return t.composedPath()[0] ?? null;
982
- if ("composedPath" in t.nativeEvent) return t.nativeEvent.composedPath()[0] ?? null;
983
- }
984
- return t.target;
985
- }
986
- function vt(t) {
987
- if (!t) return !1;
988
- let e = t.getRootNode(), r = Y(t);
989
- if (!(e instanceof r.Document || e instanceof r.ShadowRoot)) return !1;
990
- let n = e.activeElement;
991
- return n != null && t.contains(n);
992
- }
993
- const fn = typeof Element < "u" && "checkVisibility" in Element.prototype;
994
- function pn(t) {
995
- const e = Y(t);
996
- if (!(t instanceof e.HTMLElement) && !(t instanceof e.SVGElement)) return !1;
997
- let { display: r, visibility: n } = t.style, i = r !== "none" && n !== "hidden" && n !== "collapse";
998
- if (i) {
999
- const { getComputedStyle: l } = t.ownerDocument.defaultView;
1000
- let { display: s, visibility: c } = l(t);
1001
- i = s !== "none" && c !== "hidden" && c !== "collapse";
1002
- }
1003
- return i;
1004
- }
1005
- function hn(t, e) {
1006
- return !t.hasAttribute("hidden") && // Ignore HiddenSelect when tree walking.
1007
- !t.hasAttribute("data-react-aria-prevent-focus") && (t.nodeName === "DETAILS" && e && e.nodeName !== "SUMMARY" ? t.hasAttribute("open") : !0);
1008
- }
1009
- function rt(t, e) {
1010
- return fn ? t.checkVisibility({
1011
- visibilityProperty: !0
1012
- }) && !t.closest("[data-react-aria-prevent-focus]") : t.nodeName !== "#comment" && pn(t) && hn(t, e) && (!t.parentElement || rt(t.parentElement, t));
1013
- }
1014
- const nt = [
1015
- "input:not([disabled]):not([type=hidden])",
1016
- "select:not([disabled])",
1017
- "textarea:not([disabled])",
1018
- "button:not([disabled])",
1019
- "a[href]",
1020
- "area[href]",
1021
- "summary",
1022
- "iframe",
1023
- "object",
1024
- "embed",
1025
- "audio[controls]",
1026
- "video[controls]",
1027
- '[contenteditable]:not([contenteditable^="false"])',
1028
- "permission"
1029
- ], bn = nt.join(":not([hidden]),") + ",[tabindex]:not([disabled]):not([hidden])";
1030
- nt.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
1031
- const yn = nt.join(':not([hidden]):not([tabindex="-1"]),');
1032
- function Yt(t, e) {
1033
- return t.matches(bn) && !qt(t) && (e?.skipVisibilityCheck || rt(t));
1034
- }
1035
- function Xt(t) {
1036
- return t.matches(yn) && rt(t) && !qt(t);
1037
- }
1038
- function qt(t) {
1039
- let e = t;
1040
- for (; e != null; ) {
1041
- if (e instanceof e.ownerDocument.defaultView.HTMLElement && e.inert) return !0;
1042
- e = e.parentElement;
1043
- }
1044
- return !1;
1045
- }
1046
- function Jt(t) {
1047
- let e = t;
1048
- return e.nativeEvent = t, e.isDefaultPrevented = () => e.defaultPrevented, e.isPropagationStopped = () => e.cancelBubble, e.persist = () => {
1049
- }, e;
1050
- }
1051
- function gn(t, e) {
1052
- Object.defineProperty(t, "target", {
1053
- value: e
1054
- }), Object.defineProperty(t, "currentTarget", {
1055
- value: e
1056
- });
1057
- }
1058
- function $n(t) {
1059
- let e = k({
1060
- isFocused: !1,
1061
- observer: null
1062
- });
1063
- return ie(() => {
1064
- const r = e.current;
1065
- return () => {
1066
- r.observer && (r.observer.disconnect(), r.observer = null);
1067
- };
1068
- }, []), V((r) => {
1069
- let n = w(r);
1070
- if (n instanceof HTMLButtonElement || n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement) {
1071
- e.current.isFocused = !0;
1072
- let i = n, l = (s) => {
1073
- if (e.current.isFocused = !1, i.disabled) {
1074
- let c = Jt(s);
1075
- t?.(c);
1076
- }
1077
- e.current.observer && (e.current.observer.disconnect(), e.current.observer = null);
1078
- };
1079
- i.addEventListener("focusout", l, {
1080
- once: !0
1081
- }), e.current.observer = new MutationObserver(() => {
1082
- if (e.current.isFocused && i.disabled) {
1083
- e.current.observer?.disconnect();
1084
- let s = i === Z() ? null : Z();
1085
- i.dispatchEvent(new FocusEvent("blur", {
1086
- relatedTarget: s
1087
- })), i.dispatchEvent(new FocusEvent("focusout", {
1088
- bubbles: !0,
1089
- relatedTarget: s
1090
- }));
1091
- }
1092
- }), e.current.observer.observe(i, {
1093
- attributes: !0,
1094
- attributeFilter: [
1095
- "disabled"
1096
- ]
1097
- });
1098
- }
1099
- }, [
1100
- t
1101
- ]);
1102
- }
1103
- let Ce = !1;
1104
- function mt(t) {
1105
- for (; t && !Yt(t, {
1106
- skipVisibilityCheck: !0
1107
- }); ) t = t.parentElement;
1108
- let e = Y(t), r = e.document.activeElement;
1109
- if (!r || r === t) return;
1110
- Ce = !0;
1111
- let n = !1, i = (y) => {
1112
- (w(y) === r || n) && y.stopImmediatePropagation();
1113
- }, l = (y) => {
1114
- (w(y) === r || n) && (y.stopImmediatePropagation(), !t && !n && (n = !0, Q(r), u()));
1115
- }, s = (y) => {
1116
- (w(y) === t || n) && y.stopImmediatePropagation();
1117
- }, c = (y) => {
1118
- (w(y) === t || n) && (y.stopImmediatePropagation(), n || (n = !0, Q(r), u()));
1119
- };
1120
- e.addEventListener("blur", i, !0), e.addEventListener("focusout", l, !0), e.addEventListener("focusin", c, !0), e.addEventListener("focus", s, !0);
1121
- let u = () => {
1122
- cancelAnimationFrame(b), e.removeEventListener("blur", i, !0), e.removeEventListener("focusout", l, !0), e.removeEventListener("focusin", c, !0), e.removeEventListener("focus", s, !0), Ce = !1, n = !1;
1123
- }, b = requestAnimationFrame(u);
1124
- return u;
1125
- }
1126
- function Ne(t) {
1127
- if (typeof window > "u" || window.navigator == null) return !1;
1128
- let e = window.navigator.userAgentData?.brands;
1129
- return Array.isArray(e) && e.some((r) => t.test(r.brand)) || t.test(window.navigator.userAgent);
1130
- }
1131
- function it(t) {
1132
- return typeof window < "u" && window.navigator != null ? t.test(window.navigator.userAgentData?.platform || window.navigator.platform) : !1;
1133
- }
1134
- function te(t) {
1135
- if (process.env.NODE_ENV === "test") return t;
1136
- let e = null;
1137
- return () => (e == null && (e = t()), e);
1138
- }
1139
- const le = te(function() {
1140
- return it(/^Mac/i);
1141
- }), vn = te(function() {
1142
- return it(/^iPhone/i);
1143
- }), Zt = te(function() {
1144
- return it(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
1145
- le() && navigator.maxTouchPoints > 1;
1146
- }), Re = te(function() {
1147
- return vn() || Zt();
1148
- }), mn = te(function() {
1149
- return le() || Re();
1150
- }), wn = te(function() {
1151
- return Ne(/AppleWebKit/i) && !Sn();
1152
- }), Sn = te(function() {
1153
- return Ne(/Chrome/i);
1154
- }), Qt = te(function() {
1155
- return Ne(/Android/i);
1156
- }), Kn = te(function() {
1157
- return Ne(/Firefox/i);
1158
- });
1159
- function je(t) {
1160
- return t.pointerType === "" && t.isTrusted ? !0 : Qt() && t.pointerType ? t.type === "click" && t.buttons === 1 : t.detail === 0 && !t.pointerType;
1161
- }
1162
- function _n(t) {
1163
- return !Qt() && t.width === 0 && t.height === 0 || t.width === 1 && t.height === 1 && t.pressure === 0 && t.detail === 0 && t.pointerType === "mouse";
1164
- }
1165
- const En = /* @__PURE__ */ Kr({
1166
- isNative: !0,
1167
- open: Pn,
1168
- useHref: (t) => t
1169
- });
1170
- function ot() {
1171
- return ae(En);
1172
- }
1173
- function ee(t, e, r = !0) {
1174
- let { metaKey: n, ctrlKey: i, altKey: l, shiftKey: s } = e;
1175
- Kn() && window.event?.type?.startsWith("key") && t.target === "_blank" && (le() ? n = !0 : i = !0);
1176
- let c = wn() && le() && !Zt() && process.env.NODE_ENV !== "test" ? new KeyboardEvent("keydown", {
1177
- keyIdentifier: "Enter",
1178
- metaKey: n,
1179
- ctrlKey: i,
1180
- altKey: l,
1181
- shiftKey: s
1182
- }) : new MouseEvent("click", {
1183
- metaKey: n,
1184
- ctrlKey: i,
1185
- altKey: l,
1186
- shiftKey: s,
1187
- detail: 1,
1188
- bubbles: !0,
1189
- cancelable: !0
1190
- });
1191
- ee.isOpening = r, Q(t), t.dispatchEvent(c), ee.isOpening = !1;
1192
- }
1193
- ee.isOpening = !1;
1194
- function Tn(t, e) {
1195
- if (t instanceof HTMLAnchorElement) e(t);
1196
- else if (t.hasAttribute("data-href")) {
1197
- let r = document.createElement("a");
1198
- r.href = t.getAttribute("data-href"), t.hasAttribute("data-target") && (r.target = t.getAttribute("data-target")), t.hasAttribute("data-rel") && (r.rel = t.getAttribute("data-rel")), t.hasAttribute("data-download") && (r.download = t.getAttribute("data-download")), t.hasAttribute("data-ping") && (r.ping = t.getAttribute("data-ping")), t.hasAttribute("data-referrer-policy") && (r.referrerPolicy = t.getAttribute("data-referrer-policy")), t.appendChild(r), e(r), t.removeChild(r);
1199
- }
1200
- }
1201
- function Pn(t, e) {
1202
- Tn(t, (r) => ee(r, e));
1203
- }
1204
- function kn(t) {
1205
- const r = ot().useHref(t?.href ?? "");
1206
- return {
1207
- href: t?.href ? r : void 0,
1208
- target: t?.target,
1209
- rel: t?.rel,
1210
- download: t?.download,
1211
- ping: t?.ping,
1212
- referrerPolicy: t?.referrerPolicy
1213
- };
1214
- }
1215
- let me = null;
1216
- const xn = /* @__PURE__ */ new Set();
1217
- let $e = /* @__PURE__ */ new Map(), se = !1, Ge = !1;
1218
- function lt(t, e) {
1219
- for (let r of xn) r(t, e);
1220
- }
1221
- function Ln(t) {
1222
- return !(t.metaKey || !le() && t.altKey || t.ctrlKey || t.key === "Control" || t.key === "Shift" || t.key === "Meta");
1223
- }
1224
- function Ie(t) {
1225
- se = !0, !ee.isOpening && Ln(t) && (me = "keyboard", lt("keyboard", t));
1226
- }
1227
- function j(t) {
1228
- me = "pointer", "pointerType" in t && t.pointerType, (t.type === "mousedown" || t.type === "pointerdown") && (se = !0, lt("pointer", t));
1229
- }
1230
- function er(t) {
1231
- !ee.isOpening && je(t) && (se = !0, me = "virtual");
1232
- }
1233
- function tr(t) {
1234
- let e = Y(w(t)), r = z(w(t));
1235
- w(t) === e || w(t) === r || Ce || !t.isTrusted || (!se && !Ge && (me = "virtual", lt("virtual", t)), se = !1, Ge = !1);
1236
- }
1237
- function rr() {
1238
- Ce || (se = !1, Ge = !0);
1239
- }
1240
- function wt(t) {
1241
- if (typeof window > "u" || typeof document > "u") return;
1242
- const e = Y(t), r = z(t);
1243
- if ($e.get(e)) return;
1244
- let n = e.HTMLElement.prototype.focus;
1245
- e.HTMLElement.prototype.focus = function() {
1246
- se = !0, n.apply(this, arguments);
1247
- }, r.addEventListener("keydown", Ie, !0), r.addEventListener("keyup", Ie, !0), r.addEventListener("click", er, !0), e.addEventListener("focus", tr, !0), e.addEventListener("blur", rr, !1), typeof PointerEvent < "u" ? (r.addEventListener("pointerdown", j, !0), r.addEventListener("pointermove", j, !0), r.addEventListener("pointerup", j, !0)) : process.env.NODE_ENV === "test" && (r.addEventListener("mousedown", j, !0), r.addEventListener("mousemove", j, !0), r.addEventListener("mouseup", j, !0)), e.addEventListener("beforeunload", () => {
1248
- nr(t);
1249
- }, {
1250
- once: !0
1251
- }), $e.set(e, {
1252
- focus: n
1253
- });
1254
- }
1255
- const nr = (t, e) => {
1256
- const r = Y(t), n = z(t);
1257
- e && n.removeEventListener("DOMContentLoaded", e), $e.has(r) && (r.HTMLElement.prototype.focus = $e.get(r).focus, n.removeEventListener("keydown", Ie, !0), n.removeEventListener("keyup", Ie, !0), n.removeEventListener("click", er, !0), r.removeEventListener("focus", tr, !0), r.removeEventListener("blur", rr, !1), typeof PointerEvent < "u" ? (n.removeEventListener("pointerdown", j, !0), n.removeEventListener("pointermove", j, !0), n.removeEventListener("pointerup", j, !0)) : process.env.NODE_ENV === "test" && (n.removeEventListener("mousedown", j, !0), n.removeEventListener("mousemove", j, !0), n.removeEventListener("mouseup", j, !0)), $e.delete(r));
1258
- };
1259
- function Cn(t) {
1260
- const e = z(t);
1261
- let r;
1262
- return e.readyState !== "loading" ? wt(t) : (r = () => {
1263
- wt(t);
1264
- }, e.addEventListener("DOMContentLoaded", r)), () => nr(t, r);
1265
- }
1266
- typeof document < "u" && Cn();
1267
- function Ye() {
1268
- return me;
1269
- }
1270
- let ne = /* @__PURE__ */ new Map(), Xe = /* @__PURE__ */ new Set();
1271
- function St() {
1272
- if (typeof window > "u") return;
1273
- function t(n) {
1274
- return "propertyName" in n;
1275
- }
1276
- let e = (n) => {
1277
- let i = w(n);
1278
- if (!t(n) || !i) return;
1279
- let l = ne.get(i);
1280
- l || (l = /* @__PURE__ */ new Set(), ne.set(i, l), i.addEventListener("transitioncancel", r, {
1281
- once: !0
1282
- })), l.add(n.propertyName);
1283
- }, r = (n) => {
1284
- let i = w(n);
1285
- if (!t(n) || !i) return;
1286
- let l = ne.get(i);
1287
- if (l && (l.delete(n.propertyName), l.size === 0 && (i.removeEventListener("transitioncancel", r), ne.delete(i)), ne.size === 0)) {
1288
- for (let s of Xe) s();
1289
- Xe.clear();
1290
- }
1291
- };
1292
- document.body.addEventListener("transitionrun", e), document.body.addEventListener("transitionend", r);
1293
- }
1294
- typeof document < "u" && (document.readyState !== "loading" ? St() : document.addEventListener("DOMContentLoaded", St));
1295
- function In() {
1296
- for (const [t] of ne)
1297
- "isConnected" in t && !t.isConnected && ne.delete(t);
1298
- }
1299
- function ir(t) {
1300
- requestAnimationFrame(() => {
1301
- In(), ne.size === 0 ? t() : Xe.add(t);
1302
- });
1303
- }
1304
- function Fe(t) {
1305
- if (!t.isConnected) return;
1306
- const e = z(t);
1307
- if (Ye() === "virtual") {
1308
- let r = Z(e);
1309
- ir(() => {
1310
- const n = Z(e);
1311
- (n === r || n === e.body) && t.isConnected && Q(t);
1312
- });
1313
- } else Q(t);
1314
- }
1315
- function Fn(t) {
1316
- let { isDisabled: e, onFocus: r, onBlur: n, onFocusChange: i } = t;
1317
- const l = V((u) => {
1318
- if (w(u) === u.currentTarget)
1319
- return n && n(u), i && i(!1), !0;
1320
- }, [
1321
- n,
1322
- i
1323
- ]), s = $n(l), c = V((u) => {
1324
- let b = w(u);
1325
- const y = z(b), g = y ? Z(y) : Z();
1326
- b === u.currentTarget && b === g && (r && r(u), i && i(!0), s(u));
1327
- }, [
1328
- i,
1329
- r,
1330
- s
1331
- ]);
1332
- return {
1333
- focusProps: {
1334
- onFocus: !e && (r || i || n) ? c : void 0,
1335
- onBlur: !e && (n || i) ? l : void 0
1336
- }
1337
- };
1338
- }
1339
- function Kt(t) {
1340
- if (!t) return;
1341
- let e = !0;
1342
- return (r) => {
1343
- let n = {
1344
- ...r,
1345
- preventDefault() {
1346
- r.preventDefault();
1347
- },
1348
- isDefaultPrevented() {
1349
- return r.isDefaultPrevented();
1350
- },
1351
- stopPropagation() {
1352
- e && process.env.NODE_ENV !== "production" ? console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.") : e = !0;
1353
- },
1354
- continuePropagation() {
1355
- e = !1;
1356
- },
1357
- isPropagationStopped() {
1358
- return e;
1359
- }
1360
- };
1361
- t(n), e && r.stopPropagation();
1362
- };
1363
- }
1364
- function Mn(t) {
1365
- return {
1366
- keyboardProps: t.isDisabled ? {} : {
1367
- onKeyDown: Kt(t.onKeyDown),
1368
- onKeyUp: Kt(t.onKeyUp)
1369
- }
1370
- };
1371
- }
1372
- function or(t, e) {
1373
- ie(() => {
1374
- if (t && t.ref && e)
1375
- return t.ref.current = e.current, () => {
1376
- t.ref && (t.ref.current = null);
1377
- };
1378
- });
1379
- }
1380
- let Dn = /* @__PURE__ */ R.createContext(null);
1381
- function Nn(t) {
1382
- let e = ae(Dn) || {};
1383
- or(e, t);
1384
- let { ref: r, ...n } = e;
1385
- return n;
1386
- }
1387
- function Rn(t, e) {
1388
- let { focusProps: r } = Fn(t), { keyboardProps: n } = Mn(t), i = G(r, n), l = Nn(e), s = t.isDisabled ? {} : l, c = k(t.autoFocus);
1389
- H(() => {
1390
- c.current && e.current && Fe(e.current), c.current = !1;
1391
- }, [
1392
- e
1393
- ]);
1394
- let u = t.excludeFromTabOrder ? -1 : 0;
1395
- return t.isDisabled && (u = void 0), {
1396
- focusableProps: G({
1397
- ...i,
1398
- tabIndex: u
1399
- }, s)
1400
- };
1401
- }
1402
- function qe(t) {
1403
- return mn() ? t.altKey : t.ctrlKey;
1404
- }
1405
- function ze(t, e) {
1406
- let r = `[data-key="${CSS.escape(String(e))}"]`, n = t.current?.dataset.collection;
1407
- return n && (r = `[data-collection="${CSS.escape(n)}"]${r}`), t.current?.querySelector(r);
1408
- }
1409
- const lr = /* @__PURE__ */ new WeakMap();
1410
- function On(t) {
1411
- let e = Me();
1412
- return lr.set(t, e), e;
1413
- }
1414
- function An(t) {
1415
- return lr.get(t);
1416
- }
1417
- function ce(t) {
1418
- return le() ? t.metaKey : t.ctrlKey;
1419
- }
1420
- function sr(t) {
1421
- let e = zn(z(t));
1422
- e !== t && (e && Bn(e, t), t && ar(t, e));
1423
- }
1424
- function Bn(t, e) {
1425
- t.dispatchEvent(new FocusEvent("blur", {
1426
- relatedTarget: e
1427
- })), t.dispatchEvent(new FocusEvent("focusout", {
1428
- bubbles: !0,
1429
- relatedTarget: e
1430
- }));
1431
- }
1432
- function ar(t, e) {
1433
- t.dispatchEvent(new FocusEvent("focus", {
1434
- relatedTarget: e
1435
- })), t.dispatchEvent(new FocusEvent("focusin", {
1436
- bubbles: !0,
1437
- relatedTarget: e
1438
- }));
1439
- }
1440
- function zn(t) {
1441
- let e = Z(t), r = e?.getAttribute("aria-activedescendant");
1442
- return r && t.getElementById(r) || e;
1443
- }
1444
- let ue = "default", Je = "", Pe = /* @__PURE__ */ new WeakMap();
1445
- function _t(t) {
1446
- if (Re()) {
1447
- if (ue === "default") {
1448
- const e = z(t);
1449
- Je = e.documentElement.style.webkitUserSelect, e.documentElement.style.webkitUserSelect = "none";
1450
- }
1451
- ue = "disabled";
1452
- } else if (t instanceof HTMLElement || t instanceof SVGElement) {
1453
- let e = "userSelect" in t.style ? "userSelect" : "webkitUserSelect";
1454
- Pe.set(t, t.style[e]), t.style[e] = "none";
1455
- }
1456
- }
1457
- function We(t) {
1458
- if (Re()) {
1459
- if (ue !== "disabled") return;
1460
- ue = "restoring", setTimeout(() => {
1461
- ir(() => {
1462
- if (ue === "restoring") {
1463
- const e = z(t);
1464
- e.documentElement.style.webkitUserSelect === "none" && (e.documentElement.style.webkitUserSelect = Je || ""), Je = "", ue = "default";
1465
- }
1466
- });
1467
- }, 300);
1468
- } else if ((t instanceof HTMLElement || t instanceof SVGElement) && t && Pe.has(t)) {
1469
- let e = Pe.get(t), r = "userSelect" in t.style ? "userSelect" : "webkitUserSelect";
1470
- t.style[r] === "none" && (t.style[r] = e), t.getAttribute("style") === "" && t.removeAttribute("style"), Pe.delete(t);
1471
- }
1472
- }
1473
- function Et(t) {
1474
- return t?.defaultView?.__webpack_nonce__ || globalThis.__webpack_nonce__ || void 0;
1475
- }
1476
- let Ue = /* @__PURE__ */ new WeakMap();
1477
- function Wn(t) {
1478
- let e = t ?? (typeof document < "u" ? document : void 0);
1479
- if (!e) return Et(e);
1480
- if (Ue.has(e)) return Ue.get(e);
1481
- let r = e.querySelector('meta[property="csp-nonce"]'), n = r && r instanceof Y(r).HTMLMetaElement && (r.nonce || r.content) || Et(e) || void 0;
1482
- return n !== void 0 && Ue.set(e, n), n;
1483
- }
1484
- const cr = R.createContext({
1485
- register: () => {
1486
- }
1487
- });
1488
- cr.displayName = "PressResponderContext";
1489
- const Un = R.useInsertionEffect ?? ie;
1490
- function ke(t) {
1491
- const e = k(null);
1492
- return Un(() => {
1493
- e.current = t;
1494
- }, [
1495
- t
1496
- ]), V((...r) => {
1497
- const n = e.current;
1498
- return n?.(...r);
1499
- }, []);
1500
- }
1501
- function ur() {
1502
- let t = k(/* @__PURE__ */ new Map()), e = V((i, l, s, c) => {
1503
- let u = c?.once ? (...b) => {
1504
- t.current.delete(s), s(...b);
1505
- } : s;
1506
- t.current.set(s, {
1507
- type: l,
1508
- eventTarget: i,
1509
- fn: u,
1510
- options: c
1511
- }), i.addEventListener(l, u, c);
1512
- }, []), r = V((i, l, s, c) => {
1513
- let u = t.current.get(s)?.fn || s;
1514
- i.removeEventListener(l, u, c), t.current.delete(s);
1515
- }, []), n = V(() => {
1516
- t.current.forEach((i, l) => {
1517
- r(i.eventTarget, i.type, l, i.options);
1518
- });
1519
- }, [
1520
- r
1521
- ]);
1522
- return H(() => n, [
1523
- n
1524
- ]), {
1525
- addGlobalListener: e,
1526
- removeGlobalListener: r,
1527
- removeAllGlobalListeners: n
1528
- };
1529
- }
1530
- function Vn(t) {
1531
- let e = ae(cr);
1532
- if (e) {
1533
- let { register: r, ref: n, ...i } = e;
1534
- t = G(i, t), r();
1535
- }
1536
- return or(e, t.ref), t;
1537
- }
1538
- class _e {
1539
- #e;
1540
- constructor(e, r, n, i) {
1541
- this.#e = !0;
1542
- const s = (i?.target ?? n.currentTarget)?.getBoundingClientRect();
1543
- let c, u = 0, b, y = null;
1544
- n.clientX != null && n.clientY != null && (b = n.clientX, y = n.clientY), s && (b != null && y != null ? (c = b - s.left, u = y - s.top) : (c = s.width / 2, u = s.height / 2)), this.type = e, this.pointerType = r, this.target = n.currentTarget, this.shiftKey = n.shiftKey, this.metaKey = n.metaKey, this.ctrlKey = n.ctrlKey, this.altKey = n.altKey, this.x = c, this.y = u, this.key = n.key;
1545
- }
1546
- continuePropagation() {
1547
- this.#e = !1;
1548
- }
1549
- get shouldStopPropagation() {
1550
- return this.#e;
1551
- }
1552
- }
1553
- const Tt = /* @__PURE__ */ Symbol("linkClicked"), Pt = "react-aria-pressable-style", kt = "data-react-aria-pressable";
1554
- function dr(t) {
1555
- let { onPress: e, onPressChange: r, onPressStart: n, onPressEnd: i, onPressUp: l, onClick: s, isDisabled: c, isPressed: u, preventFocusOnPress: b, shouldCancelOnPointerExit: y, allowTextSelectionOnPress: g, ref: $, ...v } = Vn(t), [M, F] = J(!1), _ = k({
1556
- isPressed: !1,
1557
- ignoreEmulatedMouseEvents: !1,
1558
- didFirePressStart: !1,
1559
- isTriggeringEvent: !1,
1560
- activePointerId: null,
1561
- target: null,
1562
- isOverTarget: !1,
1563
- pointerType: null,
1564
- disposables: []
1565
- }), { addGlobalListener: C, removeAllGlobalListeners: E } = ur(), x = V((o, p) => {
1566
- let h = _.current;
1567
- if (c || h.didFirePressStart) return !1;
1568
- let f = !0;
1569
- if (h.isTriggeringEvent = !0, n) {
1570
- let K = new _e("pressstart", p, o);
1571
- n(K), f = K.shouldStopPropagation;
1572
- }
1573
- return r && r(!0), h.isTriggeringEvent = !1, h.didFirePressStart = !0, F(!0), f;
1574
- }, [
1575
- c,
1576
- n,
1577
- r
1578
- ]), m = V((o, p, h = !0) => {
1579
- let f = _.current;
1580
- if (!f.didFirePressStart) return !1;
1581
- f.didFirePressStart = !1, f.isTriggeringEvent = !0;
1582
- let K = !0;
1583
- if (i) {
1584
- let a = new _e("pressend", p, o);
1585
- i(a), K = a.shouldStopPropagation;
1586
- }
1587
- if (r && r(!1), F(!1), e && h && !c) {
1588
- let a = new _e("press", p, o);
1589
- e(a), K &&= a.shouldStopPropagation;
1590
- }
1591
- return f.isTriggeringEvent = !1, K;
1592
- }, [
1593
- c,
1594
- i,
1595
- r,
1596
- e
1597
- ]), T = ke(m), O = V((o, p) => {
1598
- let h = _.current;
1599
- if (c) return !1;
1600
- if (l) {
1601
- h.isTriggeringEvent = !0;
1602
- let f = new _e("pressup", p, o);
1603
- return l(f), h.isTriggeringEvent = !1, f.shouldStopPropagation;
1604
- }
1605
- return !0;
1606
- }, [
1607
- c,
1608
- l
1609
- ]), I = ke(O), A = V((o) => {
1610
- let p = _.current;
1611
- if (p.isPressed && p.target) {
1612
- p.didFirePressStart && p.pointerType != null && m(oe(p.target, o), p.pointerType, !1), p.isPressed = !1, p.isOverTarget = !1, p.activePointerId = null, p.pointerType = null, E(), g || We(p.target);
1613
- for (let h of p.disposables) h();
1614
- p.disposables = [];
1615
- }
1616
- }, [
1617
- g,
1618
- E,
1619
- m
1620
- ]), L = ke(A), W = V((o) => {
1621
- y && A(o);
1622
- }, [
1623
- y,
1624
- A
1625
- ]), U = V((o) => {
1626
- c || s?.(o);
1627
- }, [
1628
- c,
1629
- s
1630
- ]), B = V((o, p) => {
1631
- if (!c && s) {
1632
- let h = new MouseEvent("click", o);
1633
- gn(h, p), s(Jt(h));
1634
- }
1635
- }, [
1636
- c,
1637
- s
1638
- ]), D = q(() => {
1639
- let o = _.current, p = {
1640
- onKeyDown(f) {
1641
- if (Ve(f.nativeEvent, f.currentTarget) && P(f.currentTarget, w(f))) {
1642
- Ct(w(f), f.key) && f.preventDefault();
1643
- let K = !0;
1644
- !o.isPressed && !f.repeat && (o.target = f.currentTarget, o.isPressed = !0, o.pointerType = "keyboard", K = x(f, "keyboard"));
1645
- let a = f.currentTarget, d = (S) => {
1646
- Ve(S, a) && !S.repeat && P(a, w(S)) && o.target && I(oe(o.target, S), "keyboard");
1647
- };
1648
- C(z(f.currentTarget), "keyup", tt(d, h), !0), K && f.stopPropagation(), f.metaKey && le() && o.metaKeyEvents?.set(f.key, f.nativeEvent);
1649
- } else f.key === "Meta" && (o.metaKeyEvents = /* @__PURE__ */ new Map());
1650
- },
1651
- onClick(f) {
1652
- if (!(f && !P(f.currentTarget, w(f))) && f && f.button === 0 && !o.isTriggeringEvent && !ee.isOpening) {
1653
- let K = !0;
1654
- if (c && f.preventDefault(), !o.ignoreEmulatedMouseEvents && !o.isPressed && (o.pointerType === "virtual" || je(f.nativeEvent))) {
1655
- let a = x(f, "virtual"), d = I(f, "virtual"), S = T(f, "virtual");
1656
- U(f), K = a && d && S;
1657
- } else if (o.isPressed && o.pointerType !== "keyboard") {
1658
- let a = o.pointerType || f.nativeEvent.pointerType || "virtual", d = I(oe(f.currentTarget, f), a), S = T(oe(f.currentTarget, f), a, !0);
1659
- K = d && S, o.isOverTarget = !1, U(f), L(f);
1660
- }
1661
- o.ignoreEmulatedMouseEvents = !1, K && f.stopPropagation();
1662
- }
1663
- }
1664
- }, h = (f) => {
1665
- if (o.isPressed && o.target && Ve(f, o.target)) {
1666
- Ct(w(f), f.key) && f.preventDefault();
1667
- let K = w(f), a = P(o.target, K);
1668
- T(oe(o.target, f), "keyboard", a), a && B(f, o.target), E(), f.key !== "Enter" && st(o.target) && P(o.target, K) && !f[Tt] && (f[Tt] = !0, ee(o.target, f, !1)), o.isPressed = !1, o.metaKeyEvents?.delete(f.key);
1669
- } else if (f.key === "Meta" && o.metaKeyEvents?.size) {
1670
- let K = o.metaKeyEvents;
1671
- o.metaKeyEvents = void 0;
1672
- for (let a of K.values()) o.target?.dispatchEvent(new KeyboardEvent("keyup", a));
1673
- }
1674
- };
1675
- if (typeof PointerEvent < "u") {
1676
- p.onPointerDown = (a) => {
1677
- if (a.button !== 0 || !P(a.currentTarget, w(a))) return;
1678
- if (_n(a.nativeEvent)) {
1679
- o.pointerType = "virtual";
1680
- return;
1681
- }
1682
- o.pointerType = a.pointerType;
1683
- let d = !0;
1684
- if (!o.isPressed) {
1685
- o.isPressed = !0, o.isOverTarget = !0, o.activePointerId = a.pointerId, o.target = a.currentTarget, g || _t(o.target), d = x(a, o.pointerType);
1686
- let S = w(a);
1687
- "releasePointerCapture" in S && ("hasPointerCapture" in S ? S.hasPointerCapture(a.pointerId) && S.releasePointerCapture(a.pointerId) : S.releasePointerCapture(a.pointerId)), C(z(a.currentTarget), "pointerup", f, !1), C(z(a.currentTarget), "pointercancel", K, !1);
1688
- }
1689
- d && a.stopPropagation();
1690
- }, p.onMouseDown = (a) => {
1691
- if (P(a.currentTarget, w(a)) && a.button === 0) {
1692
- if (b) {
1693
- let d = mt(a.target);
1694
- d && o.disposables.push(d);
1695
- }
1696
- a.stopPropagation();
1697
- }
1698
- }, p.onPointerUp = (a) => {
1699
- !P(a.currentTarget, w(a)) || o.pointerType === "virtual" || a.button === 0 && !o.isPressed && I(a, o.pointerType || a.pointerType);
1700
- }, p.onPointerEnter = (a) => {
1701
- a.pointerId === o.activePointerId && o.target && !o.isOverTarget && o.pointerType != null && (o.isOverTarget = !0, x(oe(o.target, a), o.pointerType));
1702
- }, p.onPointerLeave = (a) => {
1703
- a.pointerId === o.activePointerId && o.target && o.isOverTarget && o.pointerType != null && (o.isOverTarget = !1, T(oe(o.target, a), o.pointerType, !1), W(a));
1704
- };
1705
- let f = (a) => {
1706
- if (a.pointerId === o.activePointerId && o.isPressed && a.button === 0 && o.target) {
1707
- if (P(o.target, w(a)) && o.pointerType != null) {
1708
- let d = !1, S = setTimeout(() => {
1709
- o.isPressed && o.target instanceof HTMLElement && (d ? L(a) : (Q(o.target), o.target.click()));
1710
- }, 80);
1711
- C(a.currentTarget, "click", () => d = !0, !0), o.disposables.push(() => clearTimeout(S));
1712
- } else
1713
- L(a);
1714
- o.isOverTarget = !1;
1715
- }
1716
- }, K = (a) => {
1717
- L(a);
1718
- };
1719
- p.onDragStart = (a) => {
1720
- P(a.currentTarget, w(a)) && L(a);
1721
- };
1722
- } else if (process.env.NODE_ENV === "test") {
1723
- p.onMouseDown = (a) => {
1724
- if (a.button !== 0 || !P(a.currentTarget, w(a))) return;
1725
- if (o.ignoreEmulatedMouseEvents) {
1726
- a.stopPropagation();
1727
- return;
1728
- }
1729
- if (o.isPressed = !0, o.isOverTarget = !0, o.target = a.currentTarget, o.pointerType = je(a.nativeEvent) ? "virtual" : "mouse", Wt(() => x(a, o.pointerType)) && a.stopPropagation(), b) {
1730
- let S = mt(a.target);
1731
- S && o.disposables.push(S);
1732
- }
1733
- C(z(a.currentTarget), "mouseup", f, !1);
1734
- }, p.onMouseEnter = (a) => {
1735
- if (!P(a.currentTarget, w(a))) return;
1736
- let d = !0;
1737
- o.isPressed && !o.ignoreEmulatedMouseEvents && o.pointerType != null && (o.isOverTarget = !0, d = x(a, o.pointerType)), d && a.stopPropagation();
1738
- }, p.onMouseLeave = (a) => {
1739
- if (!P(a.currentTarget, w(a))) return;
1740
- let d = !0;
1741
- o.isPressed && !o.ignoreEmulatedMouseEvents && o.pointerType != null && (o.isOverTarget = !1, d = T(a, o.pointerType, !1), W(a)), d && a.stopPropagation();
1742
- }, p.onMouseUp = (a) => {
1743
- P(a.currentTarget, w(a)) && !o.ignoreEmulatedMouseEvents && a.button === 0 && !o.isPressed && I(a, o.pointerType || "mouse");
1744
- };
1745
- let f = (a) => {
1746
- if (a.button === 0) {
1747
- if (o.ignoreEmulatedMouseEvents) {
1748
- o.ignoreEmulatedMouseEvents = !1;
1749
- return;
1750
- }
1751
- o.target && P(o.target, w(a)) && o.pointerType != null || L(a), o.isOverTarget = !1;
1752
- }
1753
- };
1754
- p.onTouchStart = (a) => {
1755
- if (!P(a.currentTarget, w(a))) return;
1756
- let d = Hn(a.nativeEvent);
1757
- if (!d) return;
1758
- o.activePointerId = d.identifier, o.ignoreEmulatedMouseEvents = !0, o.isOverTarget = !0, o.isPressed = !0, o.target = a.currentTarget, o.pointerType = "touch", g || _t(o.target), x(re(o.target, a), o.pointerType) && a.stopPropagation(), C(Y(a.currentTarget), "scroll", K, !0);
1759
- }, p.onTouchMove = (a) => {
1760
- if (!P(a.currentTarget, w(a))) return;
1761
- if (!o.isPressed) {
1762
- a.stopPropagation();
1763
- return;
1764
- }
1765
- let d = xt(a.nativeEvent, o.activePointerId), S = !0;
1766
- d && Lt(d, a.currentTarget) ? !o.isOverTarget && o.pointerType != null && (o.isOverTarget = !0, S = x(re(o.target, a), o.pointerType)) : o.isOverTarget && o.pointerType != null && (o.isOverTarget = !1, S = T(re(o.target, a), o.pointerType, !1), W(re(o.target, a))), S && a.stopPropagation();
1767
- }, p.onTouchEnd = (a) => {
1768
- if (!P(a.currentTarget, w(a))) return;
1769
- if (!o.isPressed) {
1770
- a.stopPropagation();
1771
- return;
1772
- }
1773
- let d = xt(a.nativeEvent, o.activePointerId), S = !0;
1774
- d && Lt(d, a.currentTarget) && o.pointerType != null ? (I(re(o.target, a), o.pointerType), S = T(re(o.target, a), o.pointerType), B(a.nativeEvent, o.target)) : o.isOverTarget && o.pointerType != null && (S = T(re(o.target, a), o.pointerType, !1)), S && a.stopPropagation(), o.isPressed = !1, o.activePointerId = null, o.isOverTarget = !1, o.ignoreEmulatedMouseEvents = !0, o.target && !g && We(o.target), E();
1775
- }, p.onTouchCancel = (a) => {
1776
- P(a.currentTarget, w(a)) && (a.stopPropagation(), o.isPressed && L(re(o.target, a)));
1777
- };
1778
- let K = (a) => {
1779
- o.isPressed && P(w(a), o.target) && L({
1780
- currentTarget: o.target,
1781
- shiftKey: !1,
1782
- ctrlKey: !1,
1783
- metaKey: !1,
1784
- altKey: !1
1785
- });
1786
- };
1787
- p.onDragStart = (a) => {
1788
- P(a.currentTarget, w(a)) && L(a);
1789
- };
1790
- }
1791
- return p;
1792
- }, [
1793
- C,
1794
- c,
1795
- b,
1796
- E,
1797
- g,
1798
- W,
1799
- x,
1800
- U,
1801
- B
1802
- ]);
1803
- return H(() => {
1804
- if (!$ || process.env.NODE_ENV === "test") return;
1805
- const o = z($.current);
1806
- if (!o || !o.head || o.getElementById(Pt)) return;
1807
- const p = o.createElement("style");
1808
- p.id = Pt;
1809
- let h = Wn(o);
1810
- h && (p.nonce = h), p.textContent = `
1811
- @layer {
1812
- [${kt}] {
1813
- touch-action: pan-x pan-y pinch-zoom;
1814
- }
1815
- }
1816
- `.trim(), o.head.prepend(p);
1817
- }, [
1818
- $
1819
- ]), H(() => {
1820
- let o = _.current;
1821
- return () => {
1822
- g || We(o.target ?? void 0);
1823
- for (let p of o.disposables) p();
1824
- o.disposables = [];
1825
- };
1826
- }, [
1827
- g
1828
- ]), {
1829
- isPressed: u || M,
1830
- pressProps: G(v, D, {
1831
- [kt]: !0
1832
- })
1833
- };
1834
- }
1835
- function st(t) {
1836
- return t.tagName === "A" && t.hasAttribute("href");
1837
- }
1838
- function Ve(t, e) {
1839
- const { key: r, code: n } = t, i = e, l = i.getAttribute("role");
1840
- return (r === "Enter" || r === " " || r === "Spacebar" || n === "Space") && !(i instanceof Y(i).HTMLInputElement && !fr(i, r) || i instanceof Y(i).HTMLTextAreaElement || i.isContentEditable) && // Links should only trigger with Enter key
1841
- !((l === "link" || !l && st(i)) && r !== "Enter");
1842
- }
1843
- function Hn(t) {
1844
- const { targetTouches: e } = t;
1845
- return e.length > 0 ? e[0] : null;
1846
- }
1847
- function xt(t, e) {
1848
- const r = t.changedTouches;
1849
- for (let n = 0; n < r.length; n++) {
1850
- const i = r[n];
1851
- if (i.identifier === e) return i;
1852
- }
1853
- return null;
1854
- }
1855
- function re(t, e) {
1856
- let r = 0, n = 0;
1857
- return e.targetTouches && e.targetTouches.length === 1 && (r = e.targetTouches[0].clientX, n = e.targetTouches[0].clientY), {
1858
- currentTarget: t,
1859
- shiftKey: e.shiftKey,
1860
- ctrlKey: e.ctrlKey,
1861
- metaKey: e.metaKey,
1862
- altKey: e.altKey,
1863
- clientX: r,
1864
- clientY: n
1865
- };
1866
- }
1867
- function oe(t, e) {
1868
- let r = e.clientX, n = e.clientY;
1869
- return {
1870
- currentTarget: t,
1871
- shiftKey: e.shiftKey,
1872
- ctrlKey: e.ctrlKey,
1873
- metaKey: e.metaKey,
1874
- altKey: e.altKey,
1875
- clientX: r,
1876
- clientY: n,
1877
- key: e.key
1878
- };
1879
- }
1880
- function jn(t) {
1881
- let e = 0, r = 0;
1882
- return t.width !== void 0 ? e = t.width / 2 : t.radiusX !== void 0 && (e = t.radiusX), t.height !== void 0 ? r = t.height / 2 : t.radiusY !== void 0 && (r = t.radiusY), {
1883
- top: t.clientY - r,
1884
- right: t.clientX + e,
1885
- bottom: t.clientY + r,
1886
- left: t.clientX - e
1887
- };
1888
- }
1889
- function Gn(t, e) {
1890
- return !(t.left > e.right || e.left > t.right || t.top > e.bottom || e.top > t.bottom);
1891
- }
1892
- function Lt(t, e) {
1893
- let r = e.getBoundingClientRect(), n = jn(t);
1894
- return Gn(r, n);
1895
- }
1896
- function Yn(t) {
1897
- return t instanceof HTMLInputElement ? !1 : t instanceof HTMLButtonElement ? t.type !== "submit" && t.type !== "reset" : !st(t);
1898
- }
1899
- function Ct(t, e) {
1900
- return t instanceof HTMLInputElement ? !fr(t, e) : Yn(t);
1901
- }
1902
- const Xn = /* @__PURE__ */ new Set([
1903
- "checkbox",
1904
- "radio",
1905
- "range",
1906
- "color",
1907
- "file",
1908
- "image",
1909
- "button",
1910
- "submit",
1911
- "reset"
1912
- ]);
1913
- function fr(t, e) {
1914
- return t.type === "checkbox" || t.type === "radio" ? e === " " : Xn.has(t.type);
1915
- }
1916
- let qn = 0;
1917
- const He = /* @__PURE__ */ new Map();
1918
- function Jn(t) {
1919
- let [e, r] = J();
1920
- return ie(() => {
1921
- if (!t) return;
1922
- let n = He.get(t);
1923
- if (n)
1924
- r(n.element.id);
1925
- else {
1926
- let i = `react-aria-description-${qn++}`;
1927
- r(i);
1928
- let l = document.createElement("div");
1929
- l.id = i, l.style.display = "none", l.textContent = t, document.body.appendChild(l), n = {
1930
- refCount: 0,
1931
- element: l
1932
- }, He.set(t, n);
1933
- }
1934
- return n.refCount++, () => {
1935
- n && --n.refCount === 0 && (n.element.remove(), He.delete(t));
1936
- };
1937
- }, [
1938
- t
1939
- ]), {
1940
- "aria-describedby": t ? e : void 0
1941
- };
1942
- }
1943
- const Zn = 500;
1944
- function Qn(t) {
1945
- let { isDisabled: e, onLongPressStart: r, onLongPressEnd: n, onLongPress: i, threshold: l = Zn, accessibilityDescription: s } = t;
1946
- const c = k(void 0);
1947
- let { addGlobalListener: u, removeGlobalListener: b } = ur(), { pressProps: y } = dr({
1948
- isDisabled: e,
1949
- onPressStart($) {
1950
- if ($.continuePropagation(), ($.pointerType === "mouse" || $.pointerType === "touch") && (r && r({
1951
- ...$,
1952
- type: "longpressstart"
1953
- }), c.current = setTimeout(() => {
1954
- $.target.dispatchEvent(new PointerEvent("pointercancel", {
1955
- bubbles: !0
1956
- })), z($.target).activeElement !== $.target && Q($.target), i && i({
1957
- ...$,
1958
- type: "longpress"
1959
- }), c.current = void 0;
1960
- }, l), $.pointerType === "touch")) {
1961
- let v = (F) => {
1962
- F.preventDefault();
1963
- }, M = Y($.target);
1964
- u($.target, "contextmenu", v, {
1965
- once: !0
1966
- }), u(M, "pointerup", () => {
1967
- setTimeout(() => {
1968
- b($.target, "contextmenu", v);
1969
- }, 30);
1970
- }, {
1971
- once: !0
1972
- });
1973
- }
1974
- },
1975
- onPressEnd($) {
1976
- c.current && clearTimeout(c.current), n && ($.pointerType === "mouse" || $.pointerType === "touch") && n({
1977
- ...$,
1978
- type: "longpressend"
1979
- });
1980
- }
1981
- }), g = Jn(i && !e ? s : void 0);
1982
- return {
1983
- longPressProps: G(y, g)
1984
- };
1985
- }
1986
- function ei(t) {
1987
- let { id: e, selectionManager: r, key: n, ref: i, shouldSelectOnPressUp: l, shouldUseVirtualFocus: s, focus: c, isDisabled: u, onAction: b, allowsDifferentPressOrigin: y, linkBehavior: g = "action" } = t, $ = ot();
1988
- e = Me(e);
1989
- let v = (d) => {
1990
- if (d.pointerType === "keyboard" && qe(d)) r.toggleSelection(n);
1991
- else {
1992
- if (r.selectionMode === "none") return;
1993
- if (r.isLink(n)) {
1994
- if (g === "selection" && i.current) {
1995
- let S = r.getItemProps(n);
1996
- $.open(i.current, d, S.href, S.routerOptions), r.setSelectedKeys(r.selectedKeys);
1997
- return;
1998
- } else if (g === "override" || g === "none") return;
1999
- }
2000
- r.selectionMode === "single" ? r.isSelected(n) && !r.disallowEmptySelection ? r.toggleSelection(n) : r.replaceSelection(n) : d && d.shiftKey ? r.extendSelection(n) : r.selectionBehavior === "toggle" || d && (ce(d) || d.pointerType === "touch" || d.pointerType === "virtual") ? r.toggleSelection(n) : r.replaceSelection(n);
2001
- }
2002
- };
2003
- H(() => {
2004
- n === r.focusedKey && r.isFocused && (s ? sr(i.current) : c ? c() : Z() !== i.current && i.current && Fe(i.current));
2005
- }, [
2006
- i,
2007
- n,
2008
- r.focusedKey,
2009
- r.childFocusStrategy,
2010
- r.isFocused,
2011
- s
2012
- ]), u = u || r.isDisabled(n);
2013
- let M = {};
2014
- !s && !u ? M = {
2015
- tabIndex: n === r.focusedKey ? 0 : -1,
2016
- onFocus(d) {
2017
- w(d) === i.current && r.setFocusedKey(n);
2018
- }
2019
- } : u && (M.onMouseDown = (d) => {
2020
- d.preventDefault();
2021
- }), H(() => {
2022
- u && r.focusedKey === n && r.setFocusedKey(null);
2023
- }, [
2024
- r,
2025
- u,
2026
- n
2027
- ]);
2028
- let F = r.isLink(n) && g === "override", _ = b && t.UNSTABLE_itemBehavior === "action", C = r.isLink(n) && g !== "selection" && g !== "none", E = !u && r.canSelectItem(n) && !F && !_, x = (b || C) && !u, m = x && (r.selectionBehavior === "replace" ? !E : !E || r.isEmpty), T = x && E && r.selectionBehavior === "replace", O = m || T, I = k(null), A = O && E, L = k(!1), W = k(!1), U = r.getItemProps(n), B = (d) => {
2029
- b && (b(), i.current?.dispatchEvent(new CustomEvent("react-aria-item-action", {
2030
- bubbles: !0
2031
- }))), C && i.current && $.open(i.current, d, U.href, U.routerOptions);
2032
- }, D = {
2033
- ref: i
2034
- };
2035
- if (l ? (D.onPressStart = (d) => {
2036
- I.current = d.pointerType, L.current = A, d.pointerType === "keyboard" && (!O || Ft(d.key)) && v(d);
2037
- }, y ? (D.onPressUp = m ? void 0 : (d) => {
2038
- d.pointerType === "mouse" && E && v(d);
2039
- }, D.onPress = m ? B : (d) => {
2040
- d.pointerType !== "keyboard" && d.pointerType !== "mouse" && E && v(d);
2041
- }) : D.onPress = (d) => {
2042
- if (m || T && d.pointerType !== "mouse") {
2043
- if (d.pointerType === "keyboard" && !It(d.key)) return;
2044
- B(d);
2045
- } else d.pointerType !== "keyboard" && E && v(d);
2046
- }) : (D.onPressStart = (d) => {
2047
- I.current = d.pointerType, L.current = A, W.current = m, E && (d.pointerType === "mouse" && !m || d.pointerType === "keyboard" && (!x || Ft(d.key))) && v(d);
2048
- }, D.onPress = (d) => {
2049
- (d.pointerType === "touch" || d.pointerType === "pen" || d.pointerType === "virtual" || d.pointerType === "keyboard" && O && It(d.key) || d.pointerType === "mouse" && W.current) && (O ? B(d) : E && v(d));
2050
- }), M["data-collection"] = An(r.collection), M["data-key"] = n, D.preventFocusOnPress = s, s && (D = G(D, {
2051
- onPressStart(d) {
2052
- d.pointerType !== "touch" && (r.setFocused(!0), r.setFocusedKey(n));
2053
- },
2054
- onPress(d) {
2055
- d.pointerType === "touch" && (r.setFocused(!0), r.setFocusedKey(n));
2056
- }
2057
- })), U)
2058
- for (let d of [
2059
- "onPressStart",
2060
- "onPressEnd",
2061
- "onPressChange",
2062
- "onPress",
2063
- "onPressUp",
2064
- "onClick"
2065
- ]) U[d] && (D[d] = tt(D[d], U[d]));
2066
- let { pressProps: o, isPressed: p } = dr(D), h = T ? (d) => {
2067
- I.current === "mouse" && (d.stopPropagation(), d.preventDefault(), B(d));
2068
- } : void 0, { longPressProps: f } = Qn({
2069
- isDisabled: !A,
2070
- onLongPress(d) {
2071
- d.pointerType === "touch" && (v(d), r.setSelectionBehavior("toggle"));
2072
- }
2073
- }), K = (d) => {
2074
- I.current === "touch" && L.current && d.preventDefault();
2075
- }, a = g !== "none" && r.isLink(n) ? (d) => {
2076
- ee.isOpening || d.preventDefault();
2077
- } : void 0;
2078
- return {
2079
- itemProps: G(
2080
- M,
2081
- E || m || s && !u ? o : {},
2082
- A ? f : {},
2083
- {
2084
- onDoubleClick: h,
2085
- onDragStartCapture: K,
2086
- onClick: a,
2087
- id: e
2088
- },
2089
- // Prevent DOM focus from moving on mouse down when using virtual focus
2090
- s ? {
2091
- onMouseDown: (d) => d.preventDefault()
2092
- } : void 0
2093
- ),
2094
- isPressed: p,
2095
- isSelected: r.isSelected(n),
2096
- isFocused: r.isFocused && r.focusedKey === n,
2097
- isDisabled: u,
2098
- allowsSelection: E,
2099
- hasAction: O
2100
- };
2101
- }
2102
- function It(t) {
2103
- return t === "Enter";
2104
- }
2105
- function Ft(t) {
2106
- return t === " ";
2107
- }
2108
- function ti(t, e, r) {
2109
- let { key: n, isDisabled: i, shouldSelectOnPressUp: l } = t, { selectionManager: s, selectedKey: c } = e, u = n === c, b = i || e.isDisabled || e.selectionManager.isDisabled(n), y = e.collection.getItem(n), { itemProps: g, isPressed: $ } = ei({
2110
- selectionManager: s,
2111
- key: n,
2112
- ref: r,
2113
- isDisabled: b,
2114
- // Link tabs should behave like native anchors (navigate on press up)
2115
- // This avoids reopening beforeunload dialogs when browsers replay
2116
- // queued pointer enter/leave events after cancellation.
2117
- shouldSelectOnPressUp: l ?? y?.props.href != null,
2118
- linkBehavior: "selection"
2119
- }), v = xe(e, n, "tab"), M = xe(e, n, "tabpanel"), { tabIndex: F } = g, _ = Hr(y?.props, {
2120
- labelable: !0
2121
- });
2122
- delete _.id;
2123
- let C = kn(y?.props), { focusableProps: E } = Rn({
2124
- ...y?.props,
2125
- isDisabled: b
2126
- }, r);
2127
- return {
2128
- tabProps: G(_, E, C, g, {
2129
- id: v,
2130
- "aria-selected": u,
2131
- "aria-disabled": b || void 0,
2132
- "aria-controls": u ? M : void 0,
2133
- tabIndex: b ? void 0 : F,
2134
- role: "tab"
2135
- }),
2136
- isSelected: u,
2137
- isDisabled: b,
2138
- isPressed: $
2139
- };
2140
- }
2141
- class ri {
2142
- constructor(e, r, n, i) {
2143
- this._walkerStack = [], this._currentSetFor = /* @__PURE__ */ new Set(), this._acceptNode = (s) => {
2144
- if (s.nodeType === Node.ELEMENT_NODE) {
2145
- const c = s.shadowRoot;
2146
- if (c) {
2147
- const u = this._doc.createTreeWalker(c, this.whatToShow, {
2148
- acceptNode: this._acceptNode
2149
- });
2150
- return this._walkerStack.unshift(u), NodeFilter.FILTER_ACCEPT;
2151
- } else {
2152
- if (typeof this.filter == "function") return this.filter(s);
2153
- if (this.filter?.acceptNode) return this.filter.acceptNode(s);
2154
- if (this.filter === null) return NodeFilter.FILTER_ACCEPT;
2155
- }
2156
- }
2157
- return NodeFilter.FILTER_SKIP;
2158
- }, this._doc = e, this.root = r, this.filter = i ?? null, this.whatToShow = n ?? NodeFilter.SHOW_ALL, this._currentNode = r, this._walkerStack.unshift(e.createTreeWalker(r, n, this._acceptNode));
2159
- const l = r.shadowRoot;
2160
- if (l) {
2161
- const s = this._doc.createTreeWalker(l, this.whatToShow, {
2162
- acceptNode: this._acceptNode
2163
- });
2164
- this._walkerStack.unshift(s);
2165
- }
2166
- }
2167
- get currentNode() {
2168
- return this._currentNode;
2169
- }
2170
- set currentNode(e) {
2171
- if (!P(this.root, e)) throw new Error("Cannot set currentNode to a node that is not contained by the root node.");
2172
- const r = [];
2173
- let n = e, i = e;
2174
- for (this._currentNode = e; n && n !== this.root; ) if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
2175
- const s = n, c = this._doc.createTreeWalker(s, this.whatToShow, {
2176
- acceptNode: this._acceptNode
2177
- });
2178
- r.push(c), c.currentNode = i, this._currentSetFor.add(c), n = i = s.host;
2179
- } else n = n.parentNode;
2180
- const l = this._doc.createTreeWalker(this.root, this.whatToShow, {
2181
- acceptNode: this._acceptNode
2182
- });
2183
- r.push(l), l.currentNode = i, this._currentSetFor.add(l), this._walkerStack = r;
2184
- }
2185
- get doc() {
2186
- return this._doc;
2187
- }
2188
- firstChild() {
2189
- let e = this.currentNode, r = this.nextNode();
2190
- return P(e, r) ? (r && (this.currentNode = r), r) : (this.currentNode = e, null);
2191
- }
2192
- lastChild() {
2193
- let r = this._walkerStack[0].lastChild();
2194
- return r && (this.currentNode = r), r;
2195
- }
2196
- nextNode() {
2197
- const e = this._walkerStack[0].nextNode();
2198
- if (e) {
2199
- if (e.shadowRoot) {
2200
- let n;
2201
- if (typeof this.filter == "function" ? n = this.filter(e) : this.filter?.acceptNode && (n = this.filter.acceptNode(e)), n === NodeFilter.FILTER_ACCEPT)
2202
- return this.currentNode = e, e;
2203
- let i = this.nextNode();
2204
- return i && (this.currentNode = i), i;
2205
- }
2206
- return e && (this.currentNode = e), e;
2207
- } else if (this._walkerStack.length > 1) {
2208
- this._walkerStack.shift();
2209
- let r = this.nextNode();
2210
- return r && (this.currentNode = r), r;
2211
- } else return null;
2212
- }
2213
- previousNode() {
2214
- const e = this._walkerStack[0];
2215
- if (e.currentNode === e.root) {
2216
- if (this._currentSetFor.has(e))
2217
- if (this._currentSetFor.delete(e), this._walkerStack.length > 1) {
2218
- this._walkerStack.shift();
2219
- let n = this.previousNode();
2220
- return n && (this.currentNode = n), n;
2221
- } else return null;
2222
- return null;
2223
- }
2224
- const r = e.previousNode();
2225
- if (r) {
2226
- if (r.shadowRoot) {
2227
- let i;
2228
- if (typeof this.filter == "function" ? i = this.filter(r) : this.filter?.acceptNode && (i = this.filter.acceptNode(r)), i === NodeFilter.FILTER_ACCEPT)
2229
- return r && (this.currentNode = r), r;
2230
- let l = this.lastChild();
2231
- return l && (this.currentNode = l), l;
2232
- }
2233
- return r && (this.currentNode = r), r;
2234
- } else if (this._walkerStack.length > 1) {
2235
- this._walkerStack.shift();
2236
- let n = this.previousNode();
2237
- return n && (this.currentNode = n), n;
2238
- } else return null;
2239
- }
2240
- /**
2241
- * @deprecated
2242
- */
2243
- nextSibling() {
2244
- return null;
2245
- }
2246
- /**
2247
- * @deprecated
2248
- */
2249
- previousSibling() {
2250
- return null;
2251
- }
2252
- /**
2253
- * @deprecated
2254
- */
2255
- parentNode() {
2256
- return null;
2257
- }
2258
- }
2259
- function ni(t, e, r, n) {
2260
- return De() ? new ri(t, e, r, n) : t.createTreeWalker(e, r, n);
2261
- }
2262
- function ii(t) {
2263
- if (!t.form)
2264
- return Array.from(z(t).querySelectorAll(`input[type="radio"][name="${CSS.escape(t.name)}"]`)).filter((n) => !n.form);
2265
- const e = t.form.elements.namedItem(t.name);
2266
- let r = Y(t);
2267
- return e instanceof r.RadioNodeList ? Array.from(e).filter((n) => n instanceof r.HTMLInputElement) : e instanceof r.HTMLInputElement ? [
2268
- e
2269
- ] : [];
2270
- }
2271
- function oi(t) {
2272
- if (t.checked) return !0;
2273
- const e = ii(t);
2274
- return e.length > 0 && !e.some((r) => r.checked);
2275
- }
2276
- function pr(t, e) {
2277
- return !t || !e ? !1 : e.some((r) => P(r, t));
2278
- }
2279
- function hr(t, e, r) {
2280
- let n = e?.tabbable ? Xt : Yt, i = t?.nodeType === Node.ELEMENT_NODE ? t : null, l = z(i), s = ni(l, t || l, NodeFilter.SHOW_ELEMENT, {
2281
- acceptNode(c) {
2282
- return P(e?.from, c) || e?.tabbable && c.tagName === "INPUT" && c.getAttribute("type") === "radio" && (!oi(c) || s.currentNode.tagName === "INPUT" && s.currentNode.type === "radio" && s.currentNode.name === c.name) ? NodeFilter.FILTER_REJECT : n(c) && (!r || pr(c, r)) && (!e?.accept || e.accept(c)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
2283
- }
2284
- });
2285
- return e?.from && (s.currentNode = e.from), s;
2286
- }
2287
- class at {
2288
- constructor() {
2289
- this.fastMap = /* @__PURE__ */ new Map(), this.root = new Mt({
2290
- scopeRef: null
2291
- }), this.fastMap.set(null, this.root);
2292
- }
2293
- get size() {
2294
- return this.fastMap.size;
2295
- }
2296
- getTreeNode(e) {
2297
- return this.fastMap.get(e);
2298
- }
2299
- addTreeNode(e, r, n) {
2300
- let i = this.fastMap.get(r ?? null);
2301
- if (!i) return;
2302
- let l = new Mt({
2303
- scopeRef: e
2304
- });
2305
- i.addChild(l), l.parent = i, this.fastMap.set(e, l), n && (l.nodeToRestore = n);
2306
- }
2307
- addNode(e) {
2308
- this.fastMap.set(e.scopeRef, e);
2309
- }
2310
- removeTreeNode(e) {
2311
- if (e === null) return;
2312
- let r = this.fastMap.get(e);
2313
- if (!r) return;
2314
- let n = r.parent;
2315
- for (let l of this.traverse()) l !== r && r.nodeToRestore && l.nodeToRestore && r.scopeRef && r.scopeRef.current && pr(l.nodeToRestore, r.scopeRef.current) && (l.nodeToRestore = r.nodeToRestore);
2316
- let i = r.children;
2317
- n && (n.removeChild(r), i.size > 0 && i.forEach((l) => n && n.addChild(l))), this.fastMap.delete(r.scopeRef);
2318
- }
2319
- // Pre Order Depth First
2320
- *traverse(e = this.root) {
2321
- if (e.scopeRef != null && (yield e), e.children.size > 0) for (let r of e.children) yield* this.traverse(r);
2322
- }
2323
- clone() {
2324
- let e = new at();
2325
- for (let r of this.traverse()) e.addTreeNode(r.scopeRef, r.parent?.scopeRef ?? null, r.nodeToRestore);
2326
- return e;
2327
- }
2328
- }
2329
- class Mt {
2330
- constructor(e) {
2331
- this.children = /* @__PURE__ */ new Set(), this.contain = !1, this.scopeRef = e.scopeRef;
2332
- }
2333
- addChild(e) {
2334
- this.children.add(e), e.parent = this;
2335
- }
2336
- removeChild(e) {
2337
- this.children.delete(e), e.parent = void 0;
2338
- }
2339
- }
2340
- new at();
2341
- function li(t, e) {
2342
- let r = e?.isDisabled, [n, i] = J(!1);
2343
- return ie(() => {
2344
- if (t?.current && !r) {
2345
- let l = () => {
2346
- if (t.current) {
2347
- let c = hr(t.current, {
2348
- tabbable: !0
2349
- });
2350
- i(!!c.nextNode());
2351
- }
2352
- };
2353
- l();
2354
- let s = new MutationObserver(l);
2355
- return s.observe(t.current, {
2356
- subtree: !0,
2357
- childList: !0,
2358
- attributes: !0,
2359
- attributeFilter: [
2360
- "tabIndex",
2361
- "disabled"
2362
- ]
2363
- }), () => {
2364
- s.disconnect();
2365
- };
2366
- }
2367
- }), r ? !1 : n;
2368
- }
2369
- function br(t, e) {
2370
- let { id: r, "aria-label": n, "aria-labelledby": i } = t;
2371
- return r = Me(r), i && n ? i = [
2372
- .../* @__PURE__ */ new Set([
2373
- r,
2374
- ...i.trim().split(/\s+/)
2375
- ])
2376
- ].join(" ") : i && (i = i.trim().split(/\s+/).join(" ")), !n && !i && e && (n = e), {
2377
- id: r,
2378
- "aria-label": n,
2379
- "aria-labelledby": i
2380
- };
2381
- }
2382
- function si(t, e, r) {
2383
- let n = li(r) ? void 0 : 0;
2384
- const i = xe(e, t.id ?? e?.selectedKey, "tabpanel"), l = br({
2385
- ...t,
2386
- id: i,
2387
- "aria-labelledby": xe(e, e?.selectedKey, "tab")
2388
- });
2389
- return {
2390
- tabPanelProps: G(l, {
2391
- tabIndex: n,
2392
- role: "tabpanel",
2393
- "aria-describedby": t["aria-describedby"],
2394
- "aria-details": t["aria-details"]
2395
- })
2396
- };
2397
- }
2398
- class ai {
2399
- constructor(e, r, n, i = /* @__PURE__ */ new Set()) {
2400
- this.collection = e, this.flipDirection = r === "rtl" && n === "horizontal", this.disabledKeys = i, this.tabDirection = n === "horizontal";
2401
- }
2402
- getKeyLeftOf(e) {
2403
- return this.flipDirection ? this.getNextKey(e) : this.getPreviousKey(e);
2404
- }
2405
- getKeyRightOf(e) {
2406
- return this.flipDirection ? this.getPreviousKey(e) : this.getNextKey(e);
2407
- }
2408
- isDisabled(e) {
2409
- return this.disabledKeys.has(e) || !!this.collection.getItem(e)?.props?.isDisabled;
2410
- }
2411
- getFirstKey() {
2412
- let e = this.collection.getFirstKey();
2413
- return e != null && this.isDisabled(e) && (e = this.getNextKey(e)), e;
2414
- }
2415
- getLastKey() {
2416
- let e = this.collection.getLastKey();
2417
- return e != null && this.isDisabled(e) && (e = this.getPreviousKey(e)), e;
2418
- }
2419
- getKeyAbove(e) {
2420
- return this.tabDirection ? null : this.getPreviousKey(e);
2421
- }
2422
- getKeyBelow(e) {
2423
- return this.tabDirection ? null : this.getNextKey(e);
2424
- }
2425
- getNextKey(e) {
2426
- let r = e;
2427
- do
2428
- r = this.collection.getKeyAfter(r), r == null && (r = this.collection.getFirstKey());
2429
- while (r != null && this.isDisabled(r));
2430
- return r;
2431
- }
2432
- getPreviousKey(e) {
2433
- let r = e;
2434
- do
2435
- r = this.collection.getKeyBefore(r), r == null && (r = this.collection.getLastKey());
2436
- while (r != null && this.isDisabled(r));
2437
- return r;
2438
- }
2439
- }
2440
- const ci = /* @__PURE__ */ new Set([
2441
- "Arab",
2442
- "Syrc",
2443
- "Samr",
2444
- "Mand",
2445
- "Thaa",
2446
- "Mend",
2447
- "Nkoo",
2448
- "Adlm",
2449
- "Rohg",
2450
- "Hebr"
2451
- ]), ui = /* @__PURE__ */ new Set([
2452
- "ae",
2453
- "ar",
2454
- "arc",
2455
- "bcc",
2456
- "bqi",
2457
- "ckb",
2458
- "dv",
2459
- "fa",
2460
- "glk",
2461
- "he",
2462
- "ku",
2463
- "mzn",
2464
- "nqo",
2465
- "pnb",
2466
- "ps",
2467
- "sd",
2468
- "ug",
2469
- "ur",
2470
- "yi"
2471
- ]);
2472
- function di(t) {
2473
- if (Intl.Locale) {
2474
- let r = new Intl.Locale(t).maximize(), n = typeof r.getTextInfo == "function" ? r.getTextInfo() : r.textInfo;
2475
- if (n) return n.direction === "rtl";
2476
- if (r.script) return ci.has(r.script);
2477
- }
2478
- let e = t.split("-")[0];
2479
- return ui.has(e);
2480
- }
2481
- const yr = /* @__PURE__ */ Symbol.for("react-aria.i18n.locale");
2482
- function gr() {
2483
- let t = typeof window < "u" && window[yr] || typeof navigator < "u" && (navigator.language || navigator.userLanguage) || "en-US";
2484
- try {
2485
- Intl.DateTimeFormat.supportedLocalesOf([
2486
- t
2487
- ]);
2488
- } catch {
2489
- t = "en-US";
2490
- }
2491
- return {
2492
- locale: t,
2493
- direction: di(t) ? "rtl" : "ltr"
2494
- };
2495
- }
2496
- let Ze = gr(), ge = /* @__PURE__ */ new Set();
2497
- function Dt() {
2498
- Ze = gr();
2499
- for (let t of ge) t(Ze);
2500
- }
2501
- function fi() {
2502
- let t = jt(), [e, r] = J(Ze);
2503
- return H(() => (ge.size === 0 && window.addEventListener("languagechange", Dt), ge.add(r), () => {
2504
- ge.delete(r), ge.size === 0 && window.removeEventListener("languagechange", Dt);
2505
- }), []), t ? {
2506
- locale: typeof window < "u" && window[yr] || "en-US",
2507
- direction: "ltr"
2508
- } : e;
2509
- }
2510
- const pi = /* @__PURE__ */ R.createContext(null);
2511
- function $r() {
2512
- let t = fi();
2513
- return ae(pi) || t;
2514
- }
2515
- const hi = "react-aria-clear-focus", bi = "react-aria-focus";
2516
- function yi(t, e) {
2517
- if (!t) return !1;
2518
- let r = window.getComputedStyle(t), n = document.scrollingElement || document.documentElement, i = /(auto|scroll)/.test(r.overflow + r.overflowX + r.overflowY);
2519
- return t === n && r.overflow !== "hidden" && (i = !0), i && e && (i = t.scrollHeight !== t.clientHeight || t.scrollWidth !== t.clientWidth), i;
2520
- }
2521
- function Nt(t, e) {
2522
- let r = [], n = document.scrollingElement || document.documentElement;
2523
- do
2524
- yi(t, e) && r.push(t), t = t.parentElement;
2525
- while (t && t !== n);
2526
- return r;
2527
- }
2528
- function Qe(t, e, r = {}) {
2529
- let { block: n = "nearest", inline: i = "nearest" } = r;
2530
- if (t === e) return;
2531
- let l = t.scrollTop, s = t.scrollLeft, c = e.getBoundingClientRect(), u = t.getBoundingClientRect(), b = window.getComputedStyle(e), y = window.getComputedStyle(t), g = document.scrollingElement || document.documentElement, $ = t === g ? 0 : u.top, v = t === g ? t.clientHeight : u.bottom, M = t === g ? 0 : u.left, F = t === g ? t.clientWidth : u.right, _ = parseInt(b.scrollMarginTop, 10) || 0, C = parseInt(b.scrollMarginBottom, 10) || 0, E = parseInt(b.scrollMarginLeft, 10) || 0, x = parseInt(b.scrollMarginRight, 10) || 0, m = parseInt(y.scrollPaddingTop, 10) || 0, T = parseInt(y.scrollPaddingBottom, 10) || 0, O = parseInt(y.scrollPaddingLeft, 10) || 0, I = parseInt(y.scrollPaddingRight, 10) || 0, A = parseInt(y.borderTopWidth, 10) || 0, L = parseInt(y.borderBottomWidth, 10) || 0, W = parseInt(y.borderLeftWidth, 10) || 0, U = parseInt(y.borderRightWidth, 10) || 0, B = c.top - _, D = c.bottom + C, o = c.left - E, p = c.right + x, h = t === g ? 0 : W + U, f = t === g ? 0 : A + L, K = t.offsetWidth - t.clientWidth - h, a = t.offsetHeight - t.clientHeight - f, d = $ + A + m, S = v - L - T - a, fe = M + W + O, pe = F - U - I;
2532
- y.direction === "rtl" && !Re() ? fe += K : pe -= K;
2533
- let we = B < d || D > S, Se = o < fe || p > pe;
2534
- if (we && n === "start") l += B - d;
2535
- else if (we && n === "center") l += (B + D) / 2 - (d + S) / 2;
2536
- else if (we && n === "end") l += D - S;
2537
- else if (we && n === "nearest") {
2538
- let he = B - d, be = D - S;
2539
- l += Math.abs(he) <= Math.abs(be) ? he : be;
2540
- }
2541
- if (Se && i === "start") s += o - fe;
2542
- else if (Se && i === "center") s += (o + p) / 2 - (fe + pe) / 2;
2543
- else if (Se && i === "end") s += p - pe;
2544
- else if (Se && i === "nearest") {
2545
- let he = o - fe, be = p - pe;
2546
- s += Math.abs(he) <= Math.abs(be) ? he : be;
2547
- }
2548
- if (process.env.NODE_ENV === "test") {
2549
- t.scrollLeft = s, t.scrollTop = l;
2550
- return;
2551
- }
2552
- t.scrollTo({
2553
- left: s,
2554
- top: l
2555
- });
2556
- }
2557
- function Rt(t, e = {}) {
2558
- let { containingElement: r } = e;
2559
- if (t && t.isConnected) {
2560
- let n = document.scrollingElement || document.documentElement;
2561
- if (window.getComputedStyle(n).overflow === "hidden") {
2562
- let { left: l, top: s } = t.getBoundingClientRect(), c = Nt(t, !0);
2563
- for (let y of c) Qe(y, t);
2564
- let { left: u, top: b } = t.getBoundingClientRect();
2565
- if (Math.abs(l - u) > 1 || Math.abs(s - b) > 1) {
2566
- c = r ? Nt(r, !0) : [];
2567
- for (let y of c) Qe(y, r, {
2568
- block: "center",
2569
- inline: "center"
2570
- });
2571
- }
2572
- } else {
2573
- let { left: l, top: s } = t.getBoundingClientRect();
2574
- t?.scrollIntoView?.({
2575
- block: "nearest"
2576
- });
2577
- let { left: c, top: u } = t.getBoundingClientRect();
2578
- (Math.abs(l - c) > 1 || Math.abs(s - u) > 1) && (r?.scrollIntoView?.({
2579
- block: "center",
2580
- inline: "center"
2581
- }), t.scrollIntoView?.({
2582
- block: "nearest"
2583
- }));
2584
- }
2585
- }
2586
- }
2587
- function Ee(t, e, r, n) {
2588
- let i = ke(r), l = r == null;
2589
- H(() => {
2590
- if (l || !t.current) return;
2591
- let s = t.current;
2592
- return s.addEventListener(e, i, n), () => {
2593
- s.removeEventListener(e, i, n);
2594
- };
2595
- }, [
2596
- t,
2597
- e,
2598
- n,
2599
- l
2600
- ]);
2601
- }
2602
- const gi = 1e3;
2603
- function $i(t) {
2604
- let { keyboardDelegate: e, selectionManager: r, onTypeSelect: n } = t, i = k({
2605
- search: "",
2606
- timeout: void 0
2607
- }).current, l = (s) => {
2608
- let c = vi(s.key);
2609
- if (!(!c || s.ctrlKey || s.metaKey || !P(s.currentTarget, w(s)) || i.search.length === 0 && c === " ")) {
2610
- if (c === " " && i.search.trim().length > 0 && (s.preventDefault(), "continuePropagation" in s || s.stopPropagation()), i.search += c, e.getKeyForSearch != null) {
2611
- let u = e.getKeyForSearch(i.search, r.focusedKey);
2612
- u == null && (u = e.getKeyForSearch(i.search)), u != null && (r.setFocusedKey(u), n && n(u));
2613
- }
2614
- clearTimeout(i.timeout), i.timeout = setTimeout(() => {
2615
- i.search = "";
2616
- }, gi);
2617
- }
2618
- };
2619
- return {
2620
- typeSelectProps: {
2621
- // Using a capturing listener to catch the keydown event before
2622
- // other hooks in order to handle the Spacebar event.
2623
- onKeyDownCapture: e.getKeyForSearch ? l : void 0
2624
- }
2625
- };
2626
- }
2627
- function vi(t) {
2628
- return t.length === 1 || !/^[A-Z]/i.test(t) ? t : "";
2629
- }
2630
- function Ot(t, e) {
2631
- const r = k(!0), n = k(null);
2632
- ie(() => (r.current = !0, () => {
2633
- r.current = !1;
2634
- }), []), ie(() => {
2635
- r.current ? r.current = !1 : (!n.current || e.some((i, l) => !Object.is(i, n[l]))) && t(), n.current = e;
2636
- }, e);
2637
- }
2638
- function mi(t) {
2639
- let { selectionManager: e, keyboardDelegate: r, ref: n, autoFocus: i = !1, shouldFocusWrap: l = !1, disallowEmptySelection: s = !1, disallowSelectAll: c = !1, escapeKeyBehavior: u = "clearSelection", selectOnFocus: b = e.selectionBehavior === "replace", disallowTypeAhead: y = !1, shouldUseVirtualFocus: g, allowsTabNavigation: $ = !1, scrollRef: v = n, linkBehavior: M = "action" } = t, { direction: F } = $r(), _ = ot(), C = (o) => {
2640
- if (o.altKey && o.key === "Tab" && o.preventDefault(), !n.current || !P(n.current, w(o))) return;
2641
- const p = (h, f) => {
2642
- if (h != null) {
2643
- if (e.isLink(h) && M === "selection" && b && !qe(o)) {
2644
- Wt(() => {
2645
- e.setFocusedKey(h, f);
2646
- });
2647
- let K = ze(n, h), a = e.getItemProps(h);
2648
- K && _.open(K, o, a.href, a.routerOptions);
2649
- return;
2650
- }
2651
- if (e.setFocusedKey(h, f), e.isLink(h) && M === "override") return;
2652
- o.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(h) : b && !qe(o) && e.replaceSelection(h);
2653
- }
2654
- };
2655
- switch (o.key) {
2656
- case "ArrowDown":
2657
- if (r.getKeyBelow) {
2658
- let h = e.focusedKey != null ? r.getKeyBelow?.(e.focusedKey) : r.getFirstKey?.();
2659
- h == null && l && (h = r.getFirstKey?.(e.focusedKey)), h != null && (o.preventDefault(), p(h));
2660
- }
2661
- break;
2662
- case "ArrowUp":
2663
- if (r.getKeyAbove) {
2664
- let h = e.focusedKey != null ? r.getKeyAbove?.(e.focusedKey) : r.getLastKey?.();
2665
- h == null && l && (h = r.getLastKey?.(e.focusedKey)), h != null && (o.preventDefault(), p(h));
2666
- }
2667
- break;
2668
- case "ArrowLeft":
2669
- if (r.getKeyLeftOf) {
2670
- let h = e.focusedKey != null ? r.getKeyLeftOf?.(e.focusedKey) : r.getFirstKey?.();
2671
- h == null && l && (h = F === "rtl" ? r.getFirstKey?.(e.focusedKey) : r.getLastKey?.(e.focusedKey)), h != null && (o.preventDefault(), p(h, F === "rtl" ? "first" : "last"));
2672
- }
2673
- break;
2674
- case "ArrowRight":
2675
- if (r.getKeyRightOf) {
2676
- let h = e.focusedKey != null ? r.getKeyRightOf?.(e.focusedKey) : r.getFirstKey?.();
2677
- h == null && l && (h = F === "rtl" ? r.getLastKey?.(e.focusedKey) : r.getFirstKey?.(e.focusedKey)), h != null && (o.preventDefault(), p(h, F === "rtl" ? "last" : "first"));
2678
- }
2679
- break;
2680
- case "Home":
2681
- if (r.getFirstKey) {
2682
- if (e.focusedKey === null && o.shiftKey) return;
2683
- o.preventDefault();
2684
- let h = r.getFirstKey(e.focusedKey, ce(o));
2685
- e.setFocusedKey(h), h != null && (ce(o) && o.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(h) : b && e.replaceSelection(h));
2686
- }
2687
- break;
2688
- case "End":
2689
- if (r.getLastKey) {
2690
- if (e.focusedKey === null && o.shiftKey) return;
2691
- o.preventDefault();
2692
- let h = r.getLastKey(e.focusedKey, ce(o));
2693
- e.setFocusedKey(h), h != null && (ce(o) && o.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(h) : b && e.replaceSelection(h));
2694
- }
2695
- break;
2696
- case "PageDown":
2697
- if (r.getKeyPageBelow && e.focusedKey != null) {
2698
- let h = r.getKeyPageBelow(e.focusedKey);
2699
- h != null && (o.preventDefault(), p(h));
2700
- }
2701
- break;
2702
- case "PageUp":
2703
- if (r.getKeyPageAbove && e.focusedKey != null) {
2704
- let h = r.getKeyPageAbove(e.focusedKey);
2705
- h != null && (o.preventDefault(), p(h));
2706
- }
2707
- break;
2708
- case "a":
2709
- ce(o) && e.selectionMode === "multiple" && c !== !0 && (o.preventDefault(), e.selectAll());
2710
- break;
2711
- case "Escape":
2712
- u === "clearSelection" && !s && e.selectedKeys.size !== 0 && (o.stopPropagation(), o.preventDefault(), e.clearSelection());
2713
- break;
2714
- case "Tab":
2715
- if (!$) {
2716
- if (o.shiftKey) n.current.focus();
2717
- else {
2718
- let h = hr(n.current, {
2719
- tabbable: !0
2720
- }), f, K;
2721
- do
2722
- K = h.lastChild(), K && (f = K);
2723
- while (K);
2724
- let a = Z();
2725
- f && (!vt(f) || a && !Xt(a)) && Q(f);
2726
- }
2727
- break;
2728
- }
2729
- }
2730
- }, E = k({
2731
- top: 0,
2732
- left: 0
2733
- });
2734
- Ee(v, "scroll", () => {
2735
- E.current = {
2736
- top: v.current?.scrollTop ?? 0,
2737
- left: v.current?.scrollLeft ?? 0
2738
- };
2739
- });
2740
- let x = (o) => {
2741
- if (e.isFocused) {
2742
- P(o.currentTarget, w(o)) || e.setFocused(!1);
2743
- return;
2744
- }
2745
- if (P(o.currentTarget, w(o))) {
2746
- if (e.setFocused(!0), e.focusedKey == null) {
2747
- let p = (f) => {
2748
- f != null && (e.setFocusedKey(f), b && !e.isSelected(f) && e.replaceSelection(f));
2749
- }, h = o.relatedTarget;
2750
- h && o.currentTarget.compareDocumentPosition(h) & Node.DOCUMENT_POSITION_FOLLOWING ? p(e.lastSelectedKey ?? r.getLastKey?.()) : p(e.firstSelectedKey ?? r.getFirstKey?.());
2751
- } else v.current && (v.current.scrollTop = E.current.top, v.current.scrollLeft = E.current.left);
2752
- if (e.focusedKey != null && v.current) {
2753
- let p = ze(n, e.focusedKey);
2754
- p instanceof HTMLElement && (!vt(p) && !g && Q(p), Ye() === "keyboard" && Rt(p, {
2755
- containingElement: n.current
2756
- }));
2757
- }
2758
- }
2759
- }, m = (o) => {
2760
- P(o.currentTarget, o.relatedTarget) || e.setFocused(!1);
2761
- }, T = k(!1);
2762
- Ee(n, bi, g ? (o) => {
2763
- let { detail: p } = o;
2764
- o.stopPropagation(), e.setFocused(!0), p?.focusStrategy === "first" && (T.current = !0);
2765
- } : void 0), Ot(() => {
2766
- if (T.current) {
2767
- let o = r.getFirstKey?.() ?? null;
2768
- if (o == null) {
2769
- let p = Z();
2770
- sr(n.current), ar(p, null), e.collection.size > 0 && (T.current = !1);
2771
- } else
2772
- e.setFocusedKey(o), T.current = !1;
2773
- }
2774
- }, [
2775
- e.collection
2776
- ]), Ot(() => {
2777
- e.collection.size > 0 && (T.current = !1);
2778
- }, [
2779
- e.focusedKey
2780
- ]), Ee(n, hi, g ? (o) => {
2781
- o.stopPropagation(), e.setFocused(!1), o.detail?.clearFocusKey && e.setFocusedKey(null);
2782
- } : void 0);
2783
- const O = k(i), I = k(!1);
2784
- H(() => {
2785
- if (O.current) {
2786
- let o = null;
2787
- i === "first" && (o = r.getFirstKey?.() ?? null), i === "last" && (o = r.getLastKey?.() ?? null);
2788
- let p = e.selectedKeys;
2789
- if (p.size) {
2790
- for (let h of p) if (e.canSelectItem(h)) {
2791
- o = h;
2792
- break;
2793
- }
2794
- }
2795
- e.setFocused(!0), e.setFocusedKey(o), o == null && !g && n.current && Fe(n.current), e.collection.size > 0 && (O.current = !1, I.current = !0);
2796
- }
2797
- });
2798
- let A = k(e.focusedKey), L = k(null);
2799
- H(() => {
2800
- if (e.isFocused && e.focusedKey != null && (e.focusedKey !== A.current || I.current) && v.current && n.current) {
2801
- let o = Ye(), p = ze(n, e.focusedKey);
2802
- if (!(p instanceof HTMLElement))
2803
- return;
2804
- (o === "keyboard" || I.current) && (L.current && cancelAnimationFrame(L.current), L.current = requestAnimationFrame(() => {
2805
- v.current && (Qe(v.current, p), o !== "virtual" && Rt(p, {
2806
- containingElement: n.current
2807
- }));
2808
- }));
2809
- }
2810
- !g && e.isFocused && e.focusedKey == null && A.current != null && n.current && Fe(n.current), A.current = e.focusedKey, I.current = !1;
2811
- }), H(() => () => {
2812
- L.current && cancelAnimationFrame(L.current);
2813
- }, []), Ee(n, "react-aria-focus-scope-restore", (o) => {
2814
- o.preventDefault(), e.setFocused(!0);
2815
- });
2816
- let W = {
2817
- onKeyDown: C,
2818
- onFocus: x,
2819
- onBlur: m,
2820
- onMouseDown(o) {
2821
- v.current === w(o) && o.preventDefault();
2822
- }
2823
- }, { typeSelectProps: U } = $i({
2824
- keyboardDelegate: r,
2825
- selectionManager: e
2826
- });
2827
- y || (W = G(U, W));
2828
- let B;
2829
- g || (B = e.focusedKey == null ? 0 : -1);
2830
- let D = On(e.collection);
2831
- return {
2832
- collectionProps: G(W, {
2833
- tabIndex: B,
2834
- "data-collection": D
2835
- })
2836
- };
2837
- }
2838
- function wi(t, e, r) {
2839
- let { orientation: n = "horizontal", keyboardActivation: i = "automatic" } = t, { collection: l, selectionManager: s, disabledKeys: c } = e, { direction: u } = $r(), b = q(() => new ai(l, u, n, c), [
2840
- l,
2841
- c,
2842
- n,
2843
- u
2844
- ]), { collectionProps: y } = mi({
2845
- ref: r,
2846
- selectionManager: s,
2847
- keyboardDelegate: b,
2848
- selectOnFocus: i === "automatic",
2849
- disallowEmptySelection: !0,
2850
- scrollRef: r,
2851
- linkBehavior: "selection"
2852
- }), g = Me();
2853
- Vt.set(e, g);
2854
- let $ = br({
2855
- ...t,
2856
- id: g
2857
- });
2858
- return {
2859
- tabListProps: {
2860
- ...G(y, $),
2861
- role: "tablist",
2862
- "aria-orientation": n,
2863
- tabIndex: void 0
2864
- }
2865
- };
2866
- }
2867
- function Si(t, e, r) {
2868
- return e in t ? Object.defineProperty(t, e, {
2869
- value: r,
2870
- enumerable: !0,
2871
- configurable: !0,
2872
- writable: !0
2873
- }) : t[e] = r, t;
2874
- }
2875
- function At(t, e) {
2876
- var r = Object.keys(t);
2877
- if (Object.getOwnPropertySymbols) {
2878
- var n = Object.getOwnPropertySymbols(t);
2879
- e && (n = n.filter(function(i) {
2880
- return Object.getOwnPropertyDescriptor(t, i).enumerable;
2881
- })), r.push.apply(r, n);
2882
- }
2883
- return r;
2884
- }
2885
- function Bt(t) {
2886
- for (var e = 1; e < arguments.length; e++) {
2887
- var r = arguments[e] != null ? arguments[e] : {};
2888
- e % 2 ? At(Object(r), !0).forEach(function(n) {
2889
- Si(t, n, r[n]);
2890
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : At(Object(r)).forEach(function(n) {
2891
- Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
2892
- });
2893
- }
2894
- return t;
2895
- }
2896
- var Ki = (t, e, r) => {
2897
- for (var n of Object.keys(t)) {
2898
- var i;
2899
- if (t[n] !== ((i = e[n]) !== null && i !== void 0 ? i : r[n]))
2900
- return !1;
2901
- }
2902
- return !0;
2903
- }, ct = (t) => (e) => {
2904
- var r = t.defaultClassName, n = Bt(Bt({}, t.defaultVariants), e);
2905
- for (var i in n) {
2906
- var l, s = (l = n[i]) !== null && l !== void 0 ? l : t.defaultVariants[i];
2907
- if (s != null) {
2908
- var c = s;
2909
- typeof c == "boolean" && (c = c === !0 ? "true" : "false");
2910
- var u = (
2911
- // @ts-expect-error
2912
- t.variantClassNames[i][c]
2913
- );
2914
- u && (r += " " + u);
2915
- }
2916
- }
2917
- for (var [b, y] of t.compoundVariants)
2918
- Ki(b, n, t.defaultVariants) && (r += " " + y);
2919
- return r;
2920
- }, _i = ct({ defaultClassName: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz0", variantClassNames: { context: { container: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz1", navigation: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz2" }, active: { true: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz3", false: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz4" }, disabled: { true: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz5", false: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz6" } }, defaultVariants: {}, compoundVariants: [[{ context: "container", active: !0 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz7"], [{ context: "container", active: !1 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz8"], [{ context: "container", active: !1, disabled: !1 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzz9"], [{ context: "navigation", active: !0 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzza"], [{ context: "navigation", active: !1 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzb"], [{ context: "navigation", active: !1, disabled: !1 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzc"], [{ context: "navigation", active: !1, disabled: !0 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzd"]] }), Ei = ct({ defaultClassName: "", variantClassNames: { active: { true: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzze", false: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzf" }, disabled: { true: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzg", false: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzh" }, context: { navigation: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzi", container: "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzj" } }, defaultVariants: {}, compoundVariants: [[{ context: "navigation", active: !0 }, "pkg_sps-woodland_tabs__version_8_50_2__hash_kz6kzzk"]] });
2921
- function vr({
2922
- context: t,
2923
- item: e,
2924
- state: r,
2925
- ...n
2926
- }) {
2927
- const { key: i } = e, l = N.useRef(null), { tabProps: s } = ti({ key: i }, r, l), c = r.selectedKey === i, u = r.disabledKeys.has(i), b = _r(e.rendered, (y) => y.type.displayName === "SpsTag" || ve.isWoodlandComponent(y.type) && ve.get(y.type).name === "Tag" ? [{
2928
- className: Te(y.props.className, Ei({ active: c, disabled: u, context: t }))
2929
- }] : [{}]);
2930
- return /* @__PURE__ */ N.createElement(
2931
- "div",
2932
- {
2933
- ...s,
2934
- ref: l,
2935
- className: _i({ active: c, disabled: u, context: t }),
2936
- ...n
2937
- },
2938
- b
2939
- );
2940
- }
2941
- ve.set(vr, { name: "Tab" });
2942
- function mr({
2943
- context: t,
2944
- "data-testid": e,
2945
- state: r,
2946
- ...n
2947
- }) {
2948
- const i = N.useRef(null), { tabPanelProps: l } = si(n, r, i), s = t === "container" ? Er : "div";
2949
- return /* @__PURE__ */ N.createElement(
2950
- s,
2951
- {
2952
- ...l,
2953
- ref: i,
2954
- "data-testid": e
2955
- },
2956
- r.selectedItem ? r.selectedItem.props.children : null
2957
- );
2958
- }
2959
- ve.set(mr, { name: "TabPanel" });
2960
- var Ti = 39, Pi = "pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er1", zt = "pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er2", ki = "pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er3", xi = "pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er4", Li = ct({ defaultClassName: "pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er5 pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er0", variantClassNames: { context: { container: "pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er6", navigation: "pkg_sps-woodland_tabs__version_8_50_2__hash_fy26er7" } }, defaultVariants: {}, compoundVariants: [] });
2961
- const Ci = 0.75;
2962
- function wr({
2963
- className: t,
2964
- context: e = "navigation",
2965
- "data-testid": r,
2966
- selectedKey: n,
2967
- defaultSelectedKey: i,
2968
- ...l
2969
- }) {
2970
- const s = {
2971
- ...l,
2972
- selectedKey: n ?? void 0,
2973
- defaultSelectedKey: i ?? void 0
2974
- }, c = Ar(s), u = N.useRef(null), { tabListProps: b } = wi(s, c, u), y = Tr({ "data-testid": r }), g = e === "container", [$, v] = N.useState(!1), [M, F] = N.useState(!1), _ = N.useCallback(() => {
2975
- const m = u.current;
2976
- if (!m) return;
2977
- const T = m.scrollWidth - m.clientWidth;
2978
- v(m.scrollLeft > 1), F(T - m.scrollLeft > 1);
2979
- }, []);
2980
- N.useEffect(() => {
2981
- const m = u.current;
2982
- if (!m) return;
2983
- _(), m.addEventListener("scroll", _, { passive: !0 });
2984
- const T = new ResizeObserver(_);
2985
- return T.observe(m), () => {
2986
- m.removeEventListener("scroll", _), T.disconnect();
2987
- };
2988
- }, [_]);
2989
- const C = (m) => {
2990
- const T = u.current;
2991
- if (!T) return;
2992
- const O = T.clientWidth * Ci;
2993
- T.scrollBy({ left: m === "left" ? -O : O, behavior: "smooth" });
2994
- }, E = N.useCallback(() => {
2995
- const m = u.current;
2996
- if (!m) return;
2997
- const T = m.querySelector('[aria-selected="true"]');
2998
- if (!T) return;
2999
- const O = m.getBoundingClientRect(), I = T.getBoundingClientRect(), A = Ti, L = m.scrollLeft > 1, W = m.scrollWidth - m.clientWidth - m.scrollLeft > 1, U = O.left + (L ? A : 0), B = O.right - (W ? A : 0);
3000
- I.left < U ? m.scrollBy({
3001
- left: I.left - (O.left + A),
3002
- behavior: "smooth"
3003
- }) : I.right > B && m.scrollBy({
3004
- left: I.right - (O.right - A),
3005
- behavior: "smooth"
3006
- });
3007
- }, []);
3008
- N.useEffect(() => {
3009
- E();
3010
- }, [c.selectedKey, E]);
3011
- const x = () => {
3012
- requestAnimationFrame(() => E());
3013
- };
3014
- return /* @__PURE__ */ N.createElement(N.Fragment, null, /* @__PURE__ */ N.createElement("div", { className: Pi, "data-testid": r }, g && $ && /* @__PURE__ */ N.createElement(
3015
- "button",
3016
- {
3017
- "aria-label": "Show previous tabs",
3018
- title: "Show previous tabs",
3019
- className: Te(zt, ki),
3020
- "data-side": "left",
3021
- onClick: () => C("left"),
3022
- type: "button"
3023
- },
3024
- /* @__PURE__ */ N.createElement(ut, { icon: "chevron-left", size: "sm", "aria-hidden": "true" })
3025
- ), /* @__PURE__ */ N.createElement(
3026
- "div",
3027
- {
3028
- ...b,
3029
- ref: u,
3030
- className: Te(Li({ context: e }), t),
3031
- onClickCapture: x
3032
- },
3033
- [...c.collection].map((m) => /* @__PURE__ */ N.createElement(
3034
- vr,
3035
- {
3036
- key: m.key,
3037
- item: m,
3038
- state: c,
3039
- context: e,
3040
- ...y(`tab-${String(m.key)}`)
3041
- }
3042
- ))
3043
- ), g && M && /* @__PURE__ */ N.createElement(
3044
- "button",
3045
- {
3046
- "aria-label": "Show more tabs",
3047
- title: "Show more tabs",
3048
- className: Te(zt, xi),
3049
- onClick: () => C("right"),
3050
- type: "button"
3051
- },
3052
- /* @__PURE__ */ N.createElement(ut, { icon: "chevron-right", size: "sm", "aria-hidden": "true" })
3053
- )), /* @__PURE__ */ N.createElement(
3054
- mr,
3055
- {
3056
- key: c.selectedItem ? c.selectedItem.key : null,
3057
- state: c,
3058
- context: e,
3059
- ...y("tab-panel")
3060
- }
3061
- ));
3062
- }
3063
- ve.set(wr, { name: "Tabs" });
3064
- const Ii = {
3065
- components: [wr],
1
+ import { Tabs as e } from "@sps-woodland/core/tabs";
2
+ export * from "@sps-woodland/core/tabs";
3
+ import { code as t } from "@spscommerce/utils";
4
+ const o = {
5
+ components: [e],
3066
6
  examples: {
3067
7
  basic: {
3068
8
  label: "Basic Navigation Tabs",
3069
- description: dt`
9
+ description: t`
3070
10
  <p>Navigation tabs</p>
3071
11
  `,
3072
12
  examples: {
3073
13
  basic: {
3074
- react: dt`
14
+ react: t`
3075
15
  import { Item } from "@react-stately/collections";
3076
16
  import { Box, Icon } from "@sps-woodland/core";
3077
17
  import { Tabs } from "@sps-woodland/tabs";
@@ -3137,10 +77,9 @@ const Ii = {
3137
77
  }
3138
78
  }
3139
79
  }
3140
- }, Ri = {
3141
- "Tabbed Navigation": Ii
80
+ }, i = {
81
+ "Tabbed Navigation": o
3142
82
  };
3143
83
  export {
3144
- Ri as MANIFEST,
3145
- wr as Tabs
84
+ i as MANIFEST
3146
85
  };