mimir-ui-kit 1.38.5 → 1.38.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,1946 +0,0 @@
1
- import * as v from "react";
2
- import ke, { useReducer as Ft, useMemo as Y, useSyncExternalStore as Ht, useId as Nt, useEffect as j, useCallback as ut, useRef as ne, useLayoutEffect as ft, createContext as me, useContext as X, useState as ee, Fragment as dt } from "react";
3
- import { n as z, s as ge, d as Be, u as It, o as ae, p as Wt, t as kt, e as ce, W as Ve, y as _e, T as Bt, H as Ye } from "./keyboard-mgWkd2Vh.js";
4
- import { A as Vt, h as _t } from "./focus-management-BtPpk3D1.js";
5
- import * as ye from "react-dom";
6
- import { createPortal as Yt } from "react-dom";
7
- function jt(e) {
8
- if (e === null) return { width: 0, height: 0 };
9
- let { width: t, height: n } = e.getBoundingClientRect();
10
- return { width: t, height: n };
11
- }
12
- function To(e, t = !1) {
13
- let [n, o] = Ft(() => ({}), {}), r = Y(() => jt(e), [e, n]);
14
- return z(() => {
15
- if (!e) return;
16
- let i = new ResizeObserver(o);
17
- return i.observe(e), () => {
18
- i.disconnect();
19
- };
20
- }, [e]), t ? { width: `${r.width}px`, height: `${r.height}px` } : r;
21
- }
22
- let zt = class extends Map {
23
- constructor(t) {
24
- super(), this.factory = t;
25
- }
26
- get(t) {
27
- let n = super.get(t);
28
- return n === void 0 && (n = this.factory(t), this.set(t, n)), n;
29
- }
30
- };
31
- function mt(e, t) {
32
- let n = e(), o = /* @__PURE__ */ new Set();
33
- return { getSnapshot() {
34
- return n;
35
- }, subscribe(r) {
36
- return o.add(r), () => o.delete(r);
37
- }, dispatch(r, ...i) {
38
- let l = t[r].call(n, ...i);
39
- l && (n = l, o.forEach((s) => s()));
40
- } };
41
- }
42
- function gt(e) {
43
- return Ht(e.subscribe, e.getSnapshot, e.getSnapshot);
44
- }
45
- let Ut = new zt(() => mt(() => [], { ADD(e) {
46
- return this.includes(e) ? this : [...this, e];
47
- }, REMOVE(e) {
48
- let t = this.indexOf(e);
49
- if (t === -1) return this;
50
- let n = this.slice();
51
- return n.splice(t, 1), n;
52
- } }));
53
- function ht(e, t) {
54
- let n = Ut.get(t), o = Nt(), r = gt(n);
55
- if (z(() => {
56
- if (e) return n.dispatch("ADD", o), () => n.dispatch("REMOVE", o);
57
- }, [n, e]), !e) return !1;
58
- let i = r.indexOf(o), l = r.length;
59
- return i === -1 && (i = l, l += 1), i === l - 1;
60
- }
61
- function Mo(e, t, n) {
62
- let o = ge((r) => {
63
- let i = r.getBoundingClientRect();
64
- i.x === 0 && i.y === 0 && i.width === 0 && i.height === 0 && n();
65
- });
66
- j(() => {
67
- if (!e) return;
68
- let r = t === null ? null : t instanceof HTMLElement ? t : t.current;
69
- if (!r) return;
70
- let i = Be();
71
- if (typeof ResizeObserver < "u") {
72
- let l = new ResizeObserver(() => o.current(r));
73
- l.observe(r), i.add(() => l.disconnect());
74
- }
75
- if (typeof IntersectionObserver < "u") {
76
- let l = new IntersectionObserver(() => o.current(r));
77
- l.observe(r), i.add(() => l.disconnect());
78
- }
79
- return () => i.dispose();
80
- }, [t, o, e]);
81
- }
82
- function pt() {
83
- return /iPhone/gi.test(window.navigator.platform) || /Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0;
84
- }
85
- function Xt() {
86
- return /Android/gi.test(window.navigator.userAgent);
87
- }
88
- function qt() {
89
- return pt() || Xt();
90
- }
91
- function se(e, t, n, o) {
92
- let r = ge(n);
93
- j(() => {
94
- if (!e) return;
95
- function i(l) {
96
- r.current(l);
97
- }
98
- return document.addEventListener(t, i, o), () => document.removeEventListener(t, i, o);
99
- }, [e, t, o]);
100
- }
101
- function Gt(e, t, n, o) {
102
- let r = ge(n);
103
- j(() => {
104
- if (!e) return;
105
- function i(l) {
106
- r.current(l);
107
- }
108
- return window.addEventListener(t, i, o), () => window.removeEventListener(t, i, o);
109
- }, [e, t, o]);
110
- }
111
- const Ke = 30;
112
- function Lo(e, t, n) {
113
- let o = ht(e, "outside-click"), r = ge(n), i = ut(function(c, u) {
114
- if (c.defaultPrevented) return;
115
- let a = u(c);
116
- if (a === null || !a.getRootNode().contains(a) || !a.isConnected) return;
117
- let m = function g(f) {
118
- return typeof f == "function" ? g(f()) : Array.isArray(f) || f instanceof Set ? f : [f];
119
- }(t);
120
- for (let g of m) if (g !== null && (g.contains(a) || c.composed && c.composedPath().includes(g))) return;
121
- return !Vt(a, _t.Loose) && a.tabIndex !== -1 && c.preventDefault(), r.current(c, a);
122
- }, [r, t]), l = ne(null);
123
- se(o, "pointerdown", (c) => {
124
- var u, a;
125
- l.current = ((a = (u = c.composedPath) == null ? void 0 : u.call(c)) == null ? void 0 : a[0]) || c.target;
126
- }, !0), se(o, "mousedown", (c) => {
127
- var u, a;
128
- l.current = ((a = (u = c.composedPath) == null ? void 0 : u.call(c)) == null ? void 0 : a[0]) || c.target;
129
- }, !0), se(o, "click", (c) => {
130
- qt() || l.current && (i(c, () => l.current), l.current = null);
131
- }, !0);
132
- let s = ne({ x: 0, y: 0 });
133
- se(o, "touchstart", (c) => {
134
- s.current.x = c.touches[0].clientX, s.current.y = c.touches[0].clientY;
135
- }, !0), se(o, "touchend", (c) => {
136
- let u = { x: c.changedTouches[0].clientX, y: c.changedTouches[0].clientY };
137
- if (!(Math.abs(u.x - s.current.x) >= Ke || Math.abs(u.y - s.current.y) >= Ke)) return i(c, () => c.target instanceof HTMLElement ? c.target : null);
138
- }, !0), Gt(o, "blur", (c) => i(c, () => window.document.activeElement instanceof HTMLIFrameElement ? window.document.activeElement : null), !0);
139
- }
140
- function wt(...e) {
141
- return Y(() => It(...e), [...e]);
142
- }
143
- function Do(e, t, n, o) {
144
- let r = ge(n);
145
- j(() => {
146
- e = e ?? window;
147
- function i(l) {
148
- r.current(l);
149
- }
150
- return e.addEventListener(t, i, o), () => e.removeEventListener(t, i, o);
151
- }, [e, t, o]);
152
- }
153
- function Kt() {
154
- let e;
155
- return { before({ doc: t }) {
156
- var n;
157
- let o = t.documentElement, r = (n = t.defaultView) != null ? n : window;
158
- e = Math.max(0, r.innerWidth - o.clientWidth);
159
- }, after({ doc: t, d: n }) {
160
- let o = t.documentElement, r = Math.max(0, o.clientWidth - o.offsetWidth), i = Math.max(0, e - r);
161
- n.style(o, "paddingRight", `${i}px`);
162
- } };
163
- }
164
- function Jt() {
165
- return pt() ? { before({ doc: e, d: t, meta: n }) {
166
- function o(r) {
167
- return n.containers.flatMap((i) => i()).some((i) => i.contains(r));
168
- }
169
- t.microTask(() => {
170
- var r;
171
- if (window.getComputedStyle(e.documentElement).scrollBehavior !== "auto") {
172
- let s = Be();
173
- s.style(e.documentElement, "scrollBehavior", "auto"), t.add(() => t.microTask(() => s.dispose()));
174
- }
175
- let i = (r = window.scrollY) != null ? r : window.pageYOffset, l = null;
176
- t.addEventListener(e, "click", (s) => {
177
- if (s.target instanceof HTMLElement) try {
178
- let c = s.target.closest("a");
179
- if (!c) return;
180
- let { hash: u } = new URL(c.href), a = e.querySelector(u);
181
- a && !o(a) && (l = a);
182
- } catch {
183
- }
184
- }, !0), t.addEventListener(e, "touchstart", (s) => {
185
- if (s.target instanceof HTMLElement) if (o(s.target)) {
186
- let c = s.target;
187
- for (; c.parentElement && o(c.parentElement); ) c = c.parentElement;
188
- t.style(c, "overscrollBehavior", "contain");
189
- } else t.style(s.target, "touchAction", "none");
190
- }), t.addEventListener(e, "touchmove", (s) => {
191
- if (s.target instanceof HTMLElement) {
192
- if (s.target.tagName === "INPUT") return;
193
- if (o(s.target)) {
194
- let c = s.target;
195
- for (; c.parentElement && c.dataset.headlessuiPortal !== "" && !(c.scrollHeight > c.clientHeight || c.scrollWidth > c.clientWidth); ) c = c.parentElement;
196
- c.dataset.headlessuiPortal === "" && s.preventDefault();
197
- } else s.preventDefault();
198
- }
199
- }, { passive: !1 }), t.add(() => {
200
- var s;
201
- let c = (s = window.scrollY) != null ? s : window.pageYOffset;
202
- i !== c && window.scrollTo(0, i), l && l.isConnected && (l.scrollIntoView({ block: "nearest" }), l = null);
203
- });
204
- });
205
- } } : {};
206
- }
207
- function Qt() {
208
- return { before({ doc: e, d: t }) {
209
- t.style(e.documentElement, "overflow", "hidden");
210
- } };
211
- }
212
- function Zt(e) {
213
- let t = {};
214
- for (let n of e) Object.assign(t, n(t));
215
- return t;
216
- }
217
- let J = mt(() => /* @__PURE__ */ new Map(), { PUSH(e, t) {
218
- var n;
219
- let o = (n = this.get(e)) != null ? n : { doc: e, count: 0, d: Be(), meta: /* @__PURE__ */ new Set() };
220
- return o.count++, o.meta.add(t), this.set(e, o), this;
221
- }, POP(e, t) {
222
- let n = this.get(e);
223
- return n && (n.count--, n.meta.delete(t)), this;
224
- }, SCROLL_PREVENT({ doc: e, d: t, meta: n }) {
225
- let o = { doc: e, d: t, meta: Zt(n) }, r = [Jt(), Kt(), Qt()];
226
- r.forEach(({ before: i }) => i == null ? void 0 : i(o)), r.forEach(({ after: i }) => i == null ? void 0 : i(o));
227
- }, SCROLL_ALLOW({ d: e }) {
228
- e.dispose();
229
- }, TEARDOWN({ doc: e }) {
230
- this.delete(e);
231
- } });
232
- J.subscribe(() => {
233
- let e = J.getSnapshot(), t = /* @__PURE__ */ new Map();
234
- for (let [n] of e) t.set(n, n.documentElement.style.overflow);
235
- for (let n of e.values()) {
236
- let o = t.get(n.doc) === "hidden", r = n.count !== 0;
237
- (r && !o || !r && o) && J.dispatch(n.count > 0 ? "SCROLL_PREVENT" : "SCROLL_ALLOW", n), n.count === 0 && J.dispatch("TEARDOWN", n);
238
- }
239
- });
240
- function en(e, t, n = () => ({ containers: [] })) {
241
- let o = gt(J), r = t ? o.get(t) : void 0, i = r ? r.count > 0 : !1;
242
- return z(() => {
243
- if (!(!t || !e)) return J.dispatch("PUSH", t, n), () => J.dispatch("POP", t, n);
244
- }, [e, t]), i;
245
- }
246
- function $o(e, t, n = () => [document.body]) {
247
- let o = ht(e, "scroll-lock");
248
- en(o, t, (r) => {
249
- var i;
250
- return { containers: [...(i = r.containers) != null ? i : [], n] };
251
- });
252
- }
253
- function Ce() {
254
- return typeof window < "u";
255
- }
256
- function ie(e) {
257
- return vt(e) ? (e.nodeName || "").toLowerCase() : "#document";
258
- }
259
- function W(e) {
260
- var t;
261
- return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
262
- }
263
- function _(e) {
264
- var t;
265
- return (t = (vt(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
266
- }
267
- function vt(e) {
268
- return Ce() ? e instanceof Node || e instanceof W(e).Node : !1;
269
- }
270
- function $(e) {
271
- return Ce() ? e instanceof Element || e instanceof W(e).Element : !1;
272
- }
273
- function V(e) {
274
- return Ce() ? e instanceof HTMLElement || e instanceof W(e).HTMLElement : !1;
275
- }
276
- function Je(e) {
277
- return !Ce() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof W(e).ShadowRoot;
278
- }
279
- function he(e) {
280
- const {
281
- overflow: t,
282
- overflowX: n,
283
- overflowY: o,
284
- display: r
285
- } = B(e);
286
- return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !["inline", "contents"].includes(r);
287
- }
288
- function tn(e) {
289
- return ["table", "td", "th"].includes(ie(e));
290
- }
291
- function Oe(e) {
292
- return [":popover-open", ":modal"].some((t) => {
293
- try {
294
- return e.matches(t);
295
- } catch {
296
- return !1;
297
- }
298
- });
299
- }
300
- function je(e) {
301
- const t = ze(), n = $(e) ? B(e) : e;
302
- return n.transform !== "none" || n.perspective !== "none" || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || ["transform", "perspective", "filter"].some((o) => (n.willChange || "").includes(o)) || ["paint", "layout", "strict", "content"].some((o) => (n.contain || "").includes(o));
303
- }
304
- function nn(e) {
305
- let t = q(e);
306
- for (; V(t) && !oe(t); ) {
307
- if (je(t))
308
- return t;
309
- if (Oe(t))
310
- return null;
311
- t = q(t);
312
- }
313
- return null;
314
- }
315
- function ze() {
316
- return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
317
- }
318
- function oe(e) {
319
- return ["html", "body", "#document"].includes(ie(e));
320
- }
321
- function B(e) {
322
- return W(e).getComputedStyle(e);
323
- }
324
- function Se(e) {
325
- return $(e) ? {
326
- scrollLeft: e.scrollLeft,
327
- scrollTop: e.scrollTop
328
- } : {
329
- scrollLeft: e.scrollX,
330
- scrollTop: e.scrollY
331
- };
332
- }
333
- function q(e) {
334
- if (ie(e) === "html")
335
- return e;
336
- const t = (
337
- // Step into the shadow DOM of the parent of a slotted node.
338
- e.assignedSlot || // DOM Element detected.
339
- e.parentNode || // ShadowRoot detected.
340
- Je(e) && e.host || // Fallback.
341
- _(e)
342
- );
343
- return Je(t) ? t.host : t;
344
- }
345
- function xt(e) {
346
- const t = q(e);
347
- return oe(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : V(t) && he(t) ? t : xt(t);
348
- }
349
- function ue(e, t, n) {
350
- var o;
351
- t === void 0 && (t = []), n === void 0 && (n = !0);
352
- const r = xt(e), i = r === ((o = e.ownerDocument) == null ? void 0 : o.body), l = W(r);
353
- if (i) {
354
- const s = Fe(l);
355
- return t.concat(l, l.visualViewport || [], he(r) ? r : [], s && n ? ue(s) : []);
356
- }
357
- return t.concat(r, ue(r, [], n));
358
- }
359
- function Fe(e) {
360
- return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
361
- }
362
- function on() {
363
- const e = navigator.userAgentData;
364
- return e && Array.isArray(e.brands) ? e.brands.map((t) => {
365
- let {
366
- brand: n,
367
- version: o
368
- } = t;
369
- return n + "/" + o;
370
- }).join(" ") : navigator.userAgent;
371
- }
372
- const re = Math.min, D = Math.max, fe = Math.round, ve = Math.floor, G = (e) => ({
373
- x: e,
374
- y: e
375
- }), rn = {
376
- left: "right",
377
- right: "left",
378
- bottom: "top",
379
- top: "bottom"
380
- }, ln = {
381
- start: "end",
382
- end: "start"
383
- };
384
- function Qe(e, t, n) {
385
- return D(e, re(t, n));
386
- }
387
- function le(e, t) {
388
- return typeof e == "function" ? e(t) : e;
389
- }
390
- function K(e) {
391
- return e.split("-")[0];
392
- }
393
- function pe(e) {
394
- return e.split("-")[1];
395
- }
396
- function yt(e) {
397
- return e === "x" ? "y" : "x";
398
- }
399
- function bt(e) {
400
- return e === "y" ? "height" : "width";
401
- }
402
- function Q(e) {
403
- return ["top", "bottom"].includes(K(e)) ? "y" : "x";
404
- }
405
- function Rt(e) {
406
- return yt(Q(e));
407
- }
408
- function sn(e, t, n) {
409
- n === void 0 && (n = !1);
410
- const o = pe(e), r = Rt(e), i = bt(r);
411
- let l = r === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
412
- return t.reference[i] > t.floating[i] && (l = be(l)), [l, be(l)];
413
- }
414
- function cn(e) {
415
- const t = be(e);
416
- return [He(e), t, He(t)];
417
- }
418
- function He(e) {
419
- return e.replace(/start|end/g, (t) => ln[t]);
420
- }
421
- function an(e, t, n) {
422
- const o = ["left", "right"], r = ["right", "left"], i = ["top", "bottom"], l = ["bottom", "top"];
423
- switch (e) {
424
- case "top":
425
- case "bottom":
426
- return n ? t ? r : o : t ? o : r;
427
- case "left":
428
- case "right":
429
- return t ? i : l;
430
- default:
431
- return [];
432
- }
433
- }
434
- function un(e, t, n, o) {
435
- const r = pe(e);
436
- let i = an(K(e), n === "start", o);
437
- return r && (i = i.map((l) => l + "-" + r), t && (i = i.concat(i.map(He)))), i;
438
- }
439
- function be(e) {
440
- return e.replace(/left|right|bottom|top/g, (t) => rn[t]);
441
- }
442
- function fn(e) {
443
- return {
444
- top: 0,
445
- right: 0,
446
- bottom: 0,
447
- left: 0,
448
- ...e
449
- };
450
- }
451
- function dn(e) {
452
- return typeof e != "number" ? fn(e) : {
453
- top: e,
454
- right: e,
455
- bottom: e,
456
- left: e
457
- };
458
- }
459
- function Re(e) {
460
- const {
461
- x: t,
462
- y: n,
463
- width: o,
464
- height: r
465
- } = e;
466
- return {
467
- width: o,
468
- height: r,
469
- top: n,
470
- left: t,
471
- right: t + o,
472
- bottom: n + r,
473
- x: t,
474
- y: n
475
- };
476
- }
477
- function Ze(e, t, n) {
478
- let {
479
- reference: o,
480
- floating: r
481
- } = e;
482
- const i = Q(t), l = Rt(t), s = bt(l), c = K(t), u = i === "y", a = o.x + o.width / 2 - r.width / 2, m = o.y + o.height / 2 - r.height / 2, g = o[s] / 2 - r[s] / 2;
483
- let f;
484
- switch (c) {
485
- case "top":
486
- f = {
487
- x: a,
488
- y: o.y - r.height
489
- };
490
- break;
491
- case "bottom":
492
- f = {
493
- x: a,
494
- y: o.y + o.height
495
- };
496
- break;
497
- case "right":
498
- f = {
499
- x: o.x + o.width,
500
- y: m
501
- };
502
- break;
503
- case "left":
504
- f = {
505
- x: o.x - r.width,
506
- y: m
507
- };
508
- break;
509
- default:
510
- f = {
511
- x: o.x,
512
- y: o.y
513
- };
514
- }
515
- switch (pe(t)) {
516
- case "start":
517
- f[l] -= g * (n && u ? -1 : 1);
518
- break;
519
- case "end":
520
- f[l] += g * (n && u ? -1 : 1);
521
- break;
522
- }
523
- return f;
524
- }
525
- const mn = async (e, t, n) => {
526
- const {
527
- placement: o = "bottom",
528
- strategy: r = "absolute",
529
- middleware: i = [],
530
- platform: l
531
- } = n, s = i.filter(Boolean), c = await (l.isRTL == null ? void 0 : l.isRTL(t));
532
- let u = await l.getElementRects({
533
- reference: e,
534
- floating: t,
535
- strategy: r
536
- }), {
537
- x: a,
538
- y: m
539
- } = Ze(u, o, c), g = o, f = {}, d = 0;
540
- for (let h = 0; h < s.length; h++) {
541
- const {
542
- name: p,
543
- fn: x
544
- } = s[h], {
545
- x: y,
546
- y: w,
547
- data: b,
548
- reset: R
549
- } = await x({
550
- x: a,
551
- y: m,
552
- initialPlacement: o,
553
- placement: g,
554
- strategy: r,
555
- middlewareData: f,
556
- rects: u,
557
- platform: l,
558
- elements: {
559
- reference: e,
560
- floating: t
561
- }
562
- });
563
- a = y ?? a, m = w ?? m, f = {
564
- ...f,
565
- [p]: {
566
- ...f[p],
567
- ...b
568
- }
569
- }, R && d <= 50 && (d++, typeof R == "object" && (R.placement && (g = R.placement), R.rects && (u = R.rects === !0 ? await l.getElementRects({
570
- reference: e,
571
- floating: t,
572
- strategy: r
573
- }) : R.rects), {
574
- x: a,
575
- y: m
576
- } = Ze(u, g, c)), h = -1);
577
- }
578
- return {
579
- x: a,
580
- y: m,
581
- placement: g,
582
- strategy: r,
583
- middlewareData: f
584
- };
585
- };
586
- async function Ae(e, t) {
587
- var n;
588
- t === void 0 && (t = {});
589
- const {
590
- x: o,
591
- y: r,
592
- platform: i,
593
- rects: l,
594
- elements: s,
595
- strategy: c
596
- } = e, {
597
- boundary: u = "clippingAncestors",
598
- rootBoundary: a = "viewport",
599
- elementContext: m = "floating",
600
- altBoundary: g = !1,
601
- padding: f = 0
602
- } = le(t, e), d = dn(f), p = s[g ? m === "floating" ? "reference" : "floating" : m], x = Re(await i.getClippingRect({
603
- element: (n = await (i.isElement == null ? void 0 : i.isElement(p))) == null || n ? p : p.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(s.floating)),
604
- boundary: u,
605
- rootBoundary: a,
606
- strategy: c
607
- })), y = m === "floating" ? {
608
- x: o,
609
- y: r,
610
- width: l.floating.width,
611
- height: l.floating.height
612
- } : l.reference, w = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(s.floating)), b = await (i.isElement == null ? void 0 : i.isElement(w)) ? await (i.getScale == null ? void 0 : i.getScale(w)) || {
613
- x: 1,
614
- y: 1
615
- } : {
616
- x: 1,
617
- y: 1
618
- }, R = Re(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
619
- elements: s,
620
- rect: y,
621
- offsetParent: w,
622
- strategy: c
623
- }) : y);
624
- return {
625
- top: (x.top - R.top + d.top) / b.y,
626
- bottom: (R.bottom - x.bottom + d.bottom) / b.y,
627
- left: (x.left - R.left + d.left) / b.x,
628
- right: (R.right - x.right + d.right) / b.x
629
- };
630
- }
631
- const gn = function(e) {
632
- return e === void 0 && (e = {}), {
633
- name: "flip",
634
- options: e,
635
- async fn(t) {
636
- var n, o;
637
- const {
638
- placement: r,
639
- middlewareData: i,
640
- rects: l,
641
- initialPlacement: s,
642
- platform: c,
643
- elements: u
644
- } = t, {
645
- mainAxis: a = !0,
646
- crossAxis: m = !0,
647
- fallbackPlacements: g,
648
- fallbackStrategy: f = "bestFit",
649
- fallbackAxisSideDirection: d = "none",
650
- flipAlignment: h = !0,
651
- ...p
652
- } = le(e, t);
653
- if ((n = i.arrow) != null && n.alignmentOffset)
654
- return {};
655
- const x = K(r), y = Q(s), w = K(s) === s, b = await (c.isRTL == null ? void 0 : c.isRTL(u.floating)), R = g || (w || !h ? [be(s)] : cn(s)), C = d !== "none";
656
- !g && C && R.push(...un(s, h, d, b));
657
- const S = [s, ...R], P = await Ae(t, p), N = [];
658
- let H = ((o = i.flip) == null ? void 0 : o.overflows) || [];
659
- if (a && N.push(P[x]), m) {
660
- const A = sn(r, l, b);
661
- N.push(P[A[0]], P[A[1]]);
662
- }
663
- if (H = [...H, {
664
- placement: r,
665
- overflows: N
666
- }], !N.every((A) => A <= 0)) {
667
- var M, I;
668
- const A = (((M = i.flip) == null ? void 0 : M.index) || 0) + 1, U = S[A];
669
- if (U)
670
- return {
671
- data: {
672
- index: A,
673
- overflows: H
674
- },
675
- reset: {
676
- placement: U
677
- }
678
- };
679
- let T = (I = H.filter((k) => k.overflows[0] <= 0).sort((k, E) => k.overflows[1] - E.overflows[1])[0]) == null ? void 0 : I.placement;
680
- if (!T)
681
- switch (f) {
682
- case "bestFit": {
683
- var L;
684
- const k = (L = H.filter((E) => {
685
- if (C) {
686
- const O = Q(E.placement);
687
- return O === y || // Create a bias to the `y` side axis due to horizontal
688
- // reading directions favoring greater width.
689
- O === "y";
690
- }
691
- return !0;
692
- }).map((E) => [E.placement, E.overflows.filter((O) => O > 0).reduce((O, F) => O + F, 0)]).sort((E, O) => E[1] - O[1])[0]) == null ? void 0 : L[0];
693
- k && (T = k);
694
- break;
695
- }
696
- case "initialPlacement":
697
- T = s;
698
- break;
699
- }
700
- if (r !== T)
701
- return {
702
- reset: {
703
- placement: T
704
- }
705
- };
706
- }
707
- return {};
708
- }
709
- };
710
- };
711
- async function hn(e, t) {
712
- const {
713
- placement: n,
714
- platform: o,
715
- elements: r
716
- } = e, i = await (o.isRTL == null ? void 0 : o.isRTL(r.floating)), l = K(n), s = pe(n), c = Q(n) === "y", u = ["left", "top"].includes(l) ? -1 : 1, a = i && c ? -1 : 1, m = le(t, e);
717
- let {
718
- mainAxis: g,
719
- crossAxis: f,
720
- alignmentAxis: d
721
- } = typeof m == "number" ? {
722
- mainAxis: m,
723
- crossAxis: 0,
724
- alignmentAxis: null
725
- } : {
726
- mainAxis: m.mainAxis || 0,
727
- crossAxis: m.crossAxis || 0,
728
- alignmentAxis: m.alignmentAxis
729
- };
730
- return s && typeof d == "number" && (f = s === "end" ? d * -1 : d), c ? {
731
- x: f * a,
732
- y: g * u
733
- } : {
734
- x: g * u,
735
- y: f * a
736
- };
737
- }
738
- const pn = function(e) {
739
- return e === void 0 && (e = 0), {
740
- name: "offset",
741
- options: e,
742
- async fn(t) {
743
- var n, o;
744
- const {
745
- x: r,
746
- y: i,
747
- placement: l,
748
- middlewareData: s
749
- } = t, c = await hn(t, e);
750
- return l === ((n = s.offset) == null ? void 0 : n.placement) && (o = s.arrow) != null && o.alignmentOffset ? {} : {
751
- x: r + c.x,
752
- y: i + c.y,
753
- data: {
754
- ...c,
755
- placement: l
756
- }
757
- };
758
- }
759
- };
760
- }, wn = function(e) {
761
- return e === void 0 && (e = {}), {
762
- name: "shift",
763
- options: e,
764
- async fn(t) {
765
- const {
766
- x: n,
767
- y: o,
768
- placement: r
769
- } = t, {
770
- mainAxis: i = !0,
771
- crossAxis: l = !1,
772
- limiter: s = {
773
- fn: (p) => {
774
- let {
775
- x,
776
- y
777
- } = p;
778
- return {
779
- x,
780
- y
781
- };
782
- }
783
- },
784
- ...c
785
- } = le(e, t), u = {
786
- x: n,
787
- y: o
788
- }, a = await Ae(t, c), m = Q(K(r)), g = yt(m);
789
- let f = u[g], d = u[m];
790
- if (i) {
791
- const p = g === "y" ? "top" : "left", x = g === "y" ? "bottom" : "right", y = f + a[p], w = f - a[x];
792
- f = Qe(y, f, w);
793
- }
794
- if (l) {
795
- const p = m === "y" ? "top" : "left", x = m === "y" ? "bottom" : "right", y = d + a[p], w = d - a[x];
796
- d = Qe(y, d, w);
797
- }
798
- const h = s.fn({
799
- ...t,
800
- [g]: f,
801
- [m]: d
802
- });
803
- return {
804
- ...h,
805
- data: {
806
- x: h.x - n,
807
- y: h.y - o,
808
- enabled: {
809
- [g]: i,
810
- [m]: l
811
- }
812
- }
813
- };
814
- }
815
- };
816
- }, vn = function(e) {
817
- return e === void 0 && (e = {}), {
818
- name: "size",
819
- options: e,
820
- async fn(t) {
821
- var n, o;
822
- const {
823
- placement: r,
824
- rects: i,
825
- platform: l,
826
- elements: s
827
- } = t, {
828
- apply: c = () => {
829
- },
830
- ...u
831
- } = le(e, t), a = await Ae(t, u), m = K(r), g = pe(r), f = Q(r) === "y", {
832
- width: d,
833
- height: h
834
- } = i.floating;
835
- let p, x;
836
- m === "top" || m === "bottom" ? (p = m, x = g === (await (l.isRTL == null ? void 0 : l.isRTL(s.floating)) ? "start" : "end") ? "left" : "right") : (x = m, p = g === "end" ? "top" : "bottom");
837
- const y = h - a.top - a.bottom, w = d - a.left - a.right, b = re(h - a[p], y), R = re(d - a[x], w), C = !t.middlewareData.shift;
838
- let S = b, P = R;
839
- if ((n = t.middlewareData.shift) != null && n.enabled.x && (P = w), (o = t.middlewareData.shift) != null && o.enabled.y && (S = y), C && !g) {
840
- const H = D(a.left, 0), M = D(a.right, 0), I = D(a.top, 0), L = D(a.bottom, 0);
841
- f ? P = d - 2 * (H !== 0 || M !== 0 ? H + M : D(a.left, a.right)) : S = h - 2 * (I !== 0 || L !== 0 ? I + L : D(a.top, a.bottom));
842
- }
843
- await c({
844
- ...t,
845
- availableWidth: P,
846
- availableHeight: S
847
- });
848
- const N = await l.getDimensions(s.floating);
849
- return d !== N.width || h !== N.height ? {
850
- reset: {
851
- rects: !0
852
- }
853
- } : {};
854
- }
855
- };
856
- };
857
- function Et(e) {
858
- const t = B(e);
859
- let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
860
- const r = V(e), i = r ? e.offsetWidth : n, l = r ? e.offsetHeight : o, s = fe(n) !== i || fe(o) !== l;
861
- return s && (n = i, o = l), {
862
- width: n,
863
- height: o,
864
- $: s
865
- };
866
- }
867
- function Ue(e) {
868
- return $(e) ? e : e.contextElement;
869
- }
870
- function te(e) {
871
- const t = Ue(e);
872
- if (!V(t))
873
- return G(1);
874
- const n = t.getBoundingClientRect(), {
875
- width: o,
876
- height: r,
877
- $: i
878
- } = Et(t);
879
- let l = (i ? fe(n.width) : n.width) / o, s = (i ? fe(n.height) : n.height) / r;
880
- return (!l || !Number.isFinite(l)) && (l = 1), (!s || !Number.isFinite(s)) && (s = 1), {
881
- x: l,
882
- y: s
883
- };
884
- }
885
- const xn = /* @__PURE__ */ G(0);
886
- function Ct(e) {
887
- const t = W(e);
888
- return !ze() || !t.visualViewport ? xn : {
889
- x: t.visualViewport.offsetLeft,
890
- y: t.visualViewport.offsetTop
891
- };
892
- }
893
- function yn(e, t, n) {
894
- return t === void 0 && (t = !1), !n || t && n !== W(e) ? !1 : t;
895
- }
896
- function Z(e, t, n, o) {
897
- t === void 0 && (t = !1), n === void 0 && (n = !1);
898
- const r = e.getBoundingClientRect(), i = Ue(e);
899
- let l = G(1);
900
- t && (o ? $(o) && (l = te(o)) : l = te(e));
901
- const s = yn(i, n, o) ? Ct(i) : G(0);
902
- let c = (r.left + s.x) / l.x, u = (r.top + s.y) / l.y, a = r.width / l.x, m = r.height / l.y;
903
- if (i) {
904
- const g = W(i), f = o && $(o) ? W(o) : o;
905
- let d = g, h = Fe(d);
906
- for (; h && o && f !== d; ) {
907
- const p = te(h), x = h.getBoundingClientRect(), y = B(h), w = x.left + (h.clientLeft + parseFloat(y.paddingLeft)) * p.x, b = x.top + (h.clientTop + parseFloat(y.paddingTop)) * p.y;
908
- c *= p.x, u *= p.y, a *= p.x, m *= p.y, c += w, u += b, d = W(h), h = Fe(d);
909
- }
910
- }
911
- return Re({
912
- width: a,
913
- height: m,
914
- x: c,
915
- y: u
916
- });
917
- }
918
- function bn(e) {
919
- let {
920
- elements: t,
921
- rect: n,
922
- offsetParent: o,
923
- strategy: r
924
- } = e;
925
- const i = r === "fixed", l = _(o), s = t ? Oe(t.floating) : !1;
926
- if (o === l || s && i)
927
- return n;
928
- let c = {
929
- scrollLeft: 0,
930
- scrollTop: 0
931
- }, u = G(1);
932
- const a = G(0), m = V(o);
933
- if ((m || !m && !i) && ((ie(o) !== "body" || he(l)) && (c = Se(o)), V(o))) {
934
- const g = Z(o);
935
- u = te(o), a.x = g.x + o.clientLeft, a.y = g.y + o.clientTop;
936
- }
937
- return {
938
- width: n.width * u.x,
939
- height: n.height * u.y,
940
- x: n.x * u.x - c.scrollLeft * u.x + a.x,
941
- y: n.y * u.y - c.scrollTop * u.y + a.y
942
- };
943
- }
944
- function Rn(e) {
945
- return Array.from(e.getClientRects());
946
- }
947
- function Ne(e, t) {
948
- const n = Se(e).scrollLeft;
949
- return t ? t.left + n : Z(_(e)).left + n;
950
- }
951
- function En(e) {
952
- const t = _(e), n = Se(e), o = e.ownerDocument.body, r = D(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), i = D(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
953
- let l = -n.scrollLeft + Ne(e);
954
- const s = -n.scrollTop;
955
- return B(o).direction === "rtl" && (l += D(t.clientWidth, o.clientWidth) - r), {
956
- width: r,
957
- height: i,
958
- x: l,
959
- y: s
960
- };
961
- }
962
- function Cn(e, t) {
963
- const n = W(e), o = _(e), r = n.visualViewport;
964
- let i = o.clientWidth, l = o.clientHeight, s = 0, c = 0;
965
- if (r) {
966
- i = r.width, l = r.height;
967
- const u = ze();
968
- (!u || u && t === "fixed") && (s = r.offsetLeft, c = r.offsetTop);
969
- }
970
- return {
971
- width: i,
972
- height: l,
973
- x: s,
974
- y: c
975
- };
976
- }
977
- function On(e, t) {
978
- const n = Z(e, !0, t === "fixed"), o = n.top + e.clientTop, r = n.left + e.clientLeft, i = V(e) ? te(e) : G(1), l = e.clientWidth * i.x, s = e.clientHeight * i.y, c = r * i.x, u = o * i.y;
979
- return {
980
- width: l,
981
- height: s,
982
- x: c,
983
- y: u
984
- };
985
- }
986
- function et(e, t, n) {
987
- let o;
988
- if (t === "viewport")
989
- o = Cn(e, n);
990
- else if (t === "document")
991
- o = En(_(e));
992
- else if ($(t))
993
- o = On(t, n);
994
- else {
995
- const r = Ct(e);
996
- o = {
997
- ...t,
998
- x: t.x - r.x,
999
- y: t.y - r.y
1000
- };
1001
- }
1002
- return Re(o);
1003
- }
1004
- function Ot(e, t) {
1005
- const n = q(e);
1006
- return n === t || !$(n) || oe(n) ? !1 : B(n).position === "fixed" || Ot(n, t);
1007
- }
1008
- function Sn(e, t) {
1009
- const n = t.get(e);
1010
- if (n)
1011
- return n;
1012
- let o = ue(e, [], !1).filter((s) => $(s) && ie(s) !== "body"), r = null;
1013
- const i = B(e).position === "fixed";
1014
- let l = i ? q(e) : e;
1015
- for (; $(l) && !oe(l); ) {
1016
- const s = B(l), c = je(l);
1017
- !c && s.position === "fixed" && (r = null), (i ? !c && !r : !c && s.position === "static" && !!r && ["absolute", "fixed"].includes(r.position) || he(l) && !c && Ot(e, l)) ? o = o.filter((a) => a !== l) : r = s, l = q(l);
1018
- }
1019
- return t.set(e, o), o;
1020
- }
1021
- function An(e) {
1022
- let {
1023
- element: t,
1024
- boundary: n,
1025
- rootBoundary: o,
1026
- strategy: r
1027
- } = e;
1028
- const l = [...n === "clippingAncestors" ? Oe(t) ? [] : Sn(t, this._c) : [].concat(n), o], s = l[0], c = l.reduce((u, a) => {
1029
- const m = et(t, a, r);
1030
- return u.top = D(m.top, u.top), u.right = re(m.right, u.right), u.bottom = re(m.bottom, u.bottom), u.left = D(m.left, u.left), u;
1031
- }, et(t, s, r));
1032
- return {
1033
- width: c.right - c.left,
1034
- height: c.bottom - c.top,
1035
- x: c.left,
1036
- y: c.top
1037
- };
1038
- }
1039
- function Tn(e) {
1040
- const {
1041
- width: t,
1042
- height: n
1043
- } = Et(e);
1044
- return {
1045
- width: t,
1046
- height: n
1047
- };
1048
- }
1049
- function Pn(e, t, n) {
1050
- const o = V(t), r = _(t), i = n === "fixed", l = Z(e, !0, i, t);
1051
- let s = {
1052
- scrollLeft: 0,
1053
- scrollTop: 0
1054
- };
1055
- const c = G(0);
1056
- if (o || !o && !i)
1057
- if ((ie(t) !== "body" || he(r)) && (s = Se(t)), o) {
1058
- const f = Z(t, !0, i, t);
1059
- c.x = f.x + t.clientLeft, c.y = f.y + t.clientTop;
1060
- } else r && (c.x = Ne(r));
1061
- let u = 0, a = 0;
1062
- if (r && !o && !i) {
1063
- const f = r.getBoundingClientRect();
1064
- a = f.top + s.scrollTop, u = f.left + s.scrollLeft - // RTL <body> scrollbar.
1065
- Ne(r, f);
1066
- }
1067
- const m = l.left + s.scrollLeft - c.x - u, g = l.top + s.scrollTop - c.y - a;
1068
- return {
1069
- x: m,
1070
- y: g,
1071
- width: l.width,
1072
- height: l.height
1073
- };
1074
- }
1075
- function Pe(e) {
1076
- return B(e).position === "static";
1077
- }
1078
- function tt(e, t) {
1079
- if (!V(e) || B(e).position === "fixed")
1080
- return null;
1081
- if (t)
1082
- return t(e);
1083
- let n = e.offsetParent;
1084
- return _(e) === n && (n = n.ownerDocument.body), n;
1085
- }
1086
- function St(e, t) {
1087
- const n = W(e);
1088
- if (Oe(e))
1089
- return n;
1090
- if (!V(e)) {
1091
- let r = q(e);
1092
- for (; r && !oe(r); ) {
1093
- if ($(r) && !Pe(r))
1094
- return r;
1095
- r = q(r);
1096
- }
1097
- return n;
1098
- }
1099
- let o = tt(e, t);
1100
- for (; o && tn(o) && Pe(o); )
1101
- o = tt(o, t);
1102
- return o && oe(o) && Pe(o) && !je(o) ? n : o || nn(e) || n;
1103
- }
1104
- const Mn = async function(e) {
1105
- const t = this.getOffsetParent || St, n = this.getDimensions, o = await n(e.floating);
1106
- return {
1107
- reference: Pn(e.reference, await t(e.floating), e.strategy),
1108
- floating: {
1109
- x: 0,
1110
- y: 0,
1111
- width: o.width,
1112
- height: o.height
1113
- }
1114
- };
1115
- };
1116
- function Ln(e) {
1117
- return B(e).direction === "rtl";
1118
- }
1119
- const Dn = {
1120
- convertOffsetParentRelativeRectToViewportRelativeRect: bn,
1121
- getDocumentElement: _,
1122
- getClippingRect: An,
1123
- getOffsetParent: St,
1124
- getElementRects: Mn,
1125
- getClientRects: Rn,
1126
- getDimensions: Tn,
1127
- getScale: te,
1128
- isElement: $,
1129
- isRTL: Ln
1130
- };
1131
- function $n(e, t) {
1132
- let n = null, o;
1133
- const r = _(e);
1134
- function i() {
1135
- var s;
1136
- clearTimeout(o), (s = n) == null || s.disconnect(), n = null;
1137
- }
1138
- function l(s, c) {
1139
- s === void 0 && (s = !1), c === void 0 && (c = 1), i();
1140
- const {
1141
- left: u,
1142
- top: a,
1143
- width: m,
1144
- height: g
1145
- } = e.getBoundingClientRect();
1146
- if (s || t(), !m || !g)
1147
- return;
1148
- const f = ve(a), d = ve(r.clientWidth - (u + m)), h = ve(r.clientHeight - (a + g)), p = ve(u), y = {
1149
- rootMargin: -f + "px " + -d + "px " + -h + "px " + -p + "px",
1150
- threshold: D(0, re(1, c)) || 1
1151
- };
1152
- let w = !0;
1153
- function b(R) {
1154
- const C = R[0].intersectionRatio;
1155
- if (C !== c) {
1156
- if (!w)
1157
- return l();
1158
- C ? l(!1, C) : o = setTimeout(() => {
1159
- l(!1, 1e-7);
1160
- }, 1e3);
1161
- }
1162
- w = !1;
1163
- }
1164
- try {
1165
- n = new IntersectionObserver(b, {
1166
- ...y,
1167
- // Handle <iframe>s
1168
- root: r.ownerDocument
1169
- });
1170
- } catch {
1171
- n = new IntersectionObserver(b, y);
1172
- }
1173
- n.observe(e);
1174
- }
1175
- return l(!0), i;
1176
- }
1177
- function Fn(e, t, n, o) {
1178
- o === void 0 && (o = {});
1179
- const {
1180
- ancestorScroll: r = !0,
1181
- ancestorResize: i = !0,
1182
- elementResize: l = typeof ResizeObserver == "function",
1183
- layoutShift: s = typeof IntersectionObserver == "function",
1184
- animationFrame: c = !1
1185
- } = o, u = Ue(e), a = r || i ? [...u ? ue(u) : [], ...ue(t)] : [];
1186
- a.forEach((x) => {
1187
- r && x.addEventListener("scroll", n, {
1188
- passive: !0
1189
- }), i && x.addEventListener("resize", n);
1190
- });
1191
- const m = u && s ? $n(u, n) : null;
1192
- let g = -1, f = null;
1193
- l && (f = new ResizeObserver((x) => {
1194
- let [y] = x;
1195
- y && y.target === u && f && (f.unobserve(t), cancelAnimationFrame(g), g = requestAnimationFrame(() => {
1196
- var w;
1197
- (w = f) == null || w.observe(t);
1198
- })), n();
1199
- }), u && !c && f.observe(u), f.observe(t));
1200
- let d, h = c ? Z(e) : null;
1201
- c && p();
1202
- function p() {
1203
- const x = Z(e);
1204
- h && (x.x !== h.x || x.y !== h.y || x.width !== h.width || x.height !== h.height) && n(), h = x, d = requestAnimationFrame(p);
1205
- }
1206
- return n(), () => {
1207
- var x;
1208
- a.forEach((y) => {
1209
- r && y.removeEventListener("scroll", n), i && y.removeEventListener("resize", n);
1210
- }), m == null || m(), (x = f) == null || x.disconnect(), f = null, c && cancelAnimationFrame(d);
1211
- };
1212
- }
1213
- const Me = Ae, Hn = pn, Nn = wn, In = gn, Wn = vn, kn = (e, t, n) => {
1214
- const o = /* @__PURE__ */ new Map(), r = {
1215
- platform: Dn,
1216
- ...n
1217
- }, i = {
1218
- ...r.platform,
1219
- _c: o
1220
- };
1221
- return mn(e, t, {
1222
- ...r,
1223
- platform: i
1224
- });
1225
- };
1226
- var xe = typeof document < "u" ? ft : j;
1227
- function Ee(e, t) {
1228
- if (e === t)
1229
- return !0;
1230
- if (typeof e != typeof t)
1231
- return !1;
1232
- if (typeof e == "function" && e.toString() === t.toString())
1233
- return !0;
1234
- let n, o, r;
1235
- if (e && t && typeof e == "object") {
1236
- if (Array.isArray(e)) {
1237
- if (n = e.length, n !== t.length) return !1;
1238
- for (o = n; o-- !== 0; )
1239
- if (!Ee(e[o], t[o]))
1240
- return !1;
1241
- return !0;
1242
- }
1243
- if (r = Object.keys(e), n = r.length, n !== Object.keys(t).length)
1244
- return !1;
1245
- for (o = n; o-- !== 0; )
1246
- if (!{}.hasOwnProperty.call(t, r[o]))
1247
- return !1;
1248
- for (o = n; o-- !== 0; ) {
1249
- const i = r[o];
1250
- if (!(i === "_owner" && e.$$typeof) && !Ee(e[i], t[i]))
1251
- return !1;
1252
- }
1253
- return !0;
1254
- }
1255
- return e !== e && t !== t;
1256
- }
1257
- function At(e) {
1258
- return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
1259
- }
1260
- function nt(e, t) {
1261
- const n = At(e);
1262
- return Math.round(t * n) / n;
1263
- }
1264
- function Le(e) {
1265
- const t = v.useRef(e);
1266
- return xe(() => {
1267
- t.current = e;
1268
- }), t;
1269
- }
1270
- function Bn(e) {
1271
- e === void 0 && (e = {});
1272
- const {
1273
- placement: t = "bottom",
1274
- strategy: n = "absolute",
1275
- middleware: o = [],
1276
- platform: r,
1277
- elements: {
1278
- reference: i,
1279
- floating: l
1280
- } = {},
1281
- transform: s = !0,
1282
- whileElementsMounted: c,
1283
- open: u
1284
- } = e, [a, m] = v.useState({
1285
- x: 0,
1286
- y: 0,
1287
- strategy: n,
1288
- placement: t,
1289
- middlewareData: {},
1290
- isPositioned: !1
1291
- }), [g, f] = v.useState(o);
1292
- Ee(g, o) || f(o);
1293
- const [d, h] = v.useState(null), [p, x] = v.useState(null), y = v.useCallback((E) => {
1294
- E !== C.current && (C.current = E, h(E));
1295
- }, []), w = v.useCallback((E) => {
1296
- E !== S.current && (S.current = E, x(E));
1297
- }, []), b = i || d, R = l || p, C = v.useRef(null), S = v.useRef(null), P = v.useRef(a), N = c != null, H = Le(c), M = Le(r), I = Le(u), L = v.useCallback(() => {
1298
- if (!C.current || !S.current)
1299
- return;
1300
- const E = {
1301
- placement: t,
1302
- strategy: n,
1303
- middleware: g
1304
- };
1305
- M.current && (E.platform = M.current), kn(C.current, S.current, E).then((O) => {
1306
- const F = {
1307
- ...O,
1308
- // The floating element's position may be recomputed while it's closed
1309
- // but still mounted (such as when transitioning out). To ensure
1310
- // `isPositioned` will be `false` initially on the next open, avoid
1311
- // setting it to `true` when `open === false` (must be specified).
1312
- isPositioned: I.current !== !1
1313
- };
1314
- A.current && !Ee(P.current, F) && (P.current = F, ye.flushSync(() => {
1315
- m(F);
1316
- }));
1317
- });
1318
- }, [g, t, n, M, I]);
1319
- xe(() => {
1320
- u === !1 && P.current.isPositioned && (P.current.isPositioned = !1, m((E) => ({
1321
- ...E,
1322
- isPositioned: !1
1323
- })));
1324
- }, [u]);
1325
- const A = v.useRef(!1);
1326
- xe(() => (A.current = !0, () => {
1327
- A.current = !1;
1328
- }), []), xe(() => {
1329
- if (b && (C.current = b), R && (S.current = R), b && R) {
1330
- if (H.current)
1331
- return H.current(b, R, L);
1332
- L();
1333
- }
1334
- }, [b, R, L, H, N]);
1335
- const U = v.useMemo(() => ({
1336
- reference: C,
1337
- floating: S,
1338
- setReference: y,
1339
- setFloating: w
1340
- }), [y, w]), T = v.useMemo(() => ({
1341
- reference: b,
1342
- floating: R
1343
- }), [b, R]), k = v.useMemo(() => {
1344
- const E = {
1345
- position: n,
1346
- left: 0,
1347
- top: 0
1348
- };
1349
- if (!T.floating)
1350
- return E;
1351
- const O = nt(T.floating, a.x), F = nt(T.floating, a.y);
1352
- return s ? {
1353
- ...E,
1354
- transform: "translate(" + O + "px, " + F + "px)",
1355
- ...At(T.floating) >= 1.5 && {
1356
- willChange: "transform"
1357
- }
1358
- } : {
1359
- position: n,
1360
- left: O,
1361
- top: F
1362
- };
1363
- }, [n, s, T.floating, a.x, a.y]);
1364
- return v.useMemo(() => ({
1365
- ...a,
1366
- update: L,
1367
- refs: U,
1368
- elements: T,
1369
- floatingStyles: k
1370
- }), [a, L, U, T, k]);
1371
- }
1372
- const Tt = (e, t) => ({
1373
- ...Hn(e),
1374
- options: [e, t]
1375
- }), Vn = (e, t) => ({
1376
- ...Nn(e),
1377
- options: [e, t]
1378
- }), _n = (e, t) => ({
1379
- ...In(e),
1380
- options: [e, t]
1381
- }), Yn = (e, t) => ({
1382
- ...Wn(e),
1383
- options: [e, t]
1384
- }), Pt = {
1385
- ...v
1386
- }, jn = Pt.useInsertionEffect, zn = jn || ((e) => e());
1387
- function Mt(e) {
1388
- const t = v.useRef(() => {
1389
- if (process.env.NODE_ENV !== "production")
1390
- throw new Error("Cannot call an event handler while rendering.");
1391
- });
1392
- return zn(() => {
1393
- t.current = e;
1394
- }), v.useCallback(function() {
1395
- for (var n = arguments.length, o = new Array(n), r = 0; r < n; r++)
1396
- o[r] = arguments[r];
1397
- return t.current == null ? void 0 : t.current(...o);
1398
- }, []);
1399
- }
1400
- var Ie = typeof document < "u" ? ft : j;
1401
- let ot = !1, Un = 0;
1402
- const rt = () => (
1403
- // Ensure the id is unique with multiple independent versions of Floating UI
1404
- // on <React 18
1405
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + Un++
1406
- );
1407
- function Xn() {
1408
- const [e, t] = v.useState(() => ot ? rt() : void 0);
1409
- return Ie(() => {
1410
- e == null && t(rt());
1411
- }, []), v.useEffect(() => {
1412
- ot = !0;
1413
- }, []), e;
1414
- }
1415
- const qn = Pt.useId, Gn = qn || Xn;
1416
- let de;
1417
- process.env.NODE_ENV !== "production" && (de = /* @__PURE__ */ new Set());
1418
- function Kn() {
1419
- for (var e, t = arguments.length, n = new Array(t), o = 0; o < t; o++)
1420
- n[o] = arguments[o];
1421
- const r = "Floating UI: " + n.join(" ");
1422
- if (!((e = de) != null && e.has(r))) {
1423
- var i;
1424
- (i = de) == null || i.add(r), console.warn(r);
1425
- }
1426
- }
1427
- function Jn() {
1428
- for (var e, t = arguments.length, n = new Array(t), o = 0; o < t; o++)
1429
- n[o] = arguments[o];
1430
- const r = "Floating UI: " + n.join(" ");
1431
- if (!((e = de) != null && e.has(r))) {
1432
- var i;
1433
- (i = de) == null || i.add(r), console.error(r);
1434
- }
1435
- }
1436
- function Qn() {
1437
- const e = /* @__PURE__ */ new Map();
1438
- return {
1439
- emit(t, n) {
1440
- var o;
1441
- (o = e.get(t)) == null || o.forEach((r) => r(n));
1442
- },
1443
- on(t, n) {
1444
- e.set(t, [...e.get(t) || [], n]);
1445
- },
1446
- off(t, n) {
1447
- var o;
1448
- e.set(t, ((o = e.get(t)) == null ? void 0 : o.filter((r) => r !== n)) || []);
1449
- }
1450
- };
1451
- }
1452
- const Zn = /* @__PURE__ */ v.createContext(null), eo = /* @__PURE__ */ v.createContext(null), to = () => {
1453
- var e;
1454
- return ((e = v.useContext(Zn)) == null ? void 0 : e.id) || null;
1455
- }, no = () => v.useContext(eo), oo = "data-floating-ui-focusable";
1456
- function ro(e) {
1457
- const {
1458
- open: t = !1,
1459
- onOpenChange: n,
1460
- elements: o
1461
- } = e, r = Gn(), i = v.useRef({}), [l] = v.useState(() => Qn()), s = to() != null;
1462
- if (process.env.NODE_ENV !== "production") {
1463
- const f = o.reference;
1464
- f && !$(f) && Jn("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
1465
- }
1466
- const [c, u] = v.useState(o.reference), a = Mt((f, d, h) => {
1467
- i.current.openEvent = f ? d : void 0, l.emit("openchange", {
1468
- open: f,
1469
- event: d,
1470
- reason: h,
1471
- nested: s
1472
- }), n == null || n(f, d, h);
1473
- }), m = v.useMemo(() => ({
1474
- setPositionReference: u
1475
- }), []), g = v.useMemo(() => ({
1476
- reference: c || o.reference || null,
1477
- floating: o.floating || null,
1478
- domReference: o.reference
1479
- }), [c, o.reference, o.floating]);
1480
- return v.useMemo(() => ({
1481
- dataRef: i,
1482
- open: t,
1483
- onOpenChange: a,
1484
- elements: g,
1485
- events: l,
1486
- floatingId: r,
1487
- refs: m
1488
- }), [t, a, g, l, r, m]);
1489
- }
1490
- function io(e) {
1491
- e === void 0 && (e = {});
1492
- const {
1493
- nodeId: t
1494
- } = e, n = ro({
1495
- ...e,
1496
- elements: {
1497
- reference: null,
1498
- floating: null,
1499
- ...e.elements
1500
- }
1501
- }), o = e.rootContext || n, r = o.elements, [i, l] = v.useState(null), [s, c] = v.useState(null), a = (r == null ? void 0 : r.reference) || i, m = v.useRef(null), g = no();
1502
- Ie(() => {
1503
- a && (m.current = a);
1504
- }, [a]);
1505
- const f = Bn({
1506
- ...e,
1507
- elements: {
1508
- ...r,
1509
- ...s && {
1510
- reference: s
1511
- }
1512
- }
1513
- }), d = v.useCallback((w) => {
1514
- const b = $(w) ? {
1515
- getBoundingClientRect: () => w.getBoundingClientRect(),
1516
- contextElement: w
1517
- } : w;
1518
- c(b), f.refs.setReference(b);
1519
- }, [f.refs]), h = v.useCallback((w) => {
1520
- ($(w) || w === null) && (m.current = w, l(w)), ($(f.refs.reference.current) || f.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
1521
- // `null` to support `positionReference` + an unstable `reference`
1522
- // callback ref.
1523
- w !== null && !$(w)) && f.refs.setReference(w);
1524
- }, [f.refs]), p = v.useMemo(() => ({
1525
- ...f.refs,
1526
- setReference: h,
1527
- setPositionReference: d,
1528
- domReference: m
1529
- }), [f.refs, h, d]), x = v.useMemo(() => ({
1530
- ...f.elements,
1531
- domReference: a
1532
- }), [f.elements, a]), y = v.useMemo(() => ({
1533
- ...f,
1534
- ...o,
1535
- refs: p,
1536
- elements: x,
1537
- nodeId: t
1538
- }), [f, p, x, t, o]);
1539
- return Ie(() => {
1540
- o.dataRef.current.floatingContext = y;
1541
- const w = g == null ? void 0 : g.nodesRef.current.find((b) => b.id === t);
1542
- w && (w.context = y);
1543
- }), v.useMemo(() => ({
1544
- ...f,
1545
- context: y,
1546
- refs: p,
1547
- elements: x
1548
- }), [f, p, x, y]);
1549
- }
1550
- const it = "active", lt = "selected";
1551
- function De(e, t, n) {
1552
- const o = /* @__PURE__ */ new Map(), r = n === "item";
1553
- let i = e;
1554
- if (r && e) {
1555
- const {
1556
- [it]: l,
1557
- [lt]: s,
1558
- ...c
1559
- } = e;
1560
- i = c;
1561
- }
1562
- return {
1563
- ...n === "floating" && {
1564
- tabIndex: -1,
1565
- [oo]: ""
1566
- },
1567
- ...i,
1568
- ...t.map((l) => {
1569
- const s = l ? l[n] : null;
1570
- return typeof s == "function" ? e ? s(e) : null : s;
1571
- }).concat(e).reduce((l, s) => (s && Object.entries(s).forEach((c) => {
1572
- let [u, a] = c;
1573
- if (!(r && [it, lt].includes(u)))
1574
- if (u.indexOf("on") === 0) {
1575
- if (o.has(u) || o.set(u, []), typeof a == "function") {
1576
- var m;
1577
- (m = o.get(u)) == null || m.push(a), l[u] = function() {
1578
- for (var g, f = arguments.length, d = new Array(f), h = 0; h < f; h++)
1579
- d[h] = arguments[h];
1580
- return (g = o.get(u)) == null ? void 0 : g.map((p) => p(...d)).find((p) => p !== void 0);
1581
- };
1582
- }
1583
- } else
1584
- l[u] = a;
1585
- }), l), {})
1586
- };
1587
- }
1588
- function lo(e) {
1589
- e === void 0 && (e = []);
1590
- const t = e.map((s) => s == null ? void 0 : s.reference), n = e.map((s) => s == null ? void 0 : s.floating), o = e.map((s) => s == null ? void 0 : s.item), r = v.useCallback(
1591
- (s) => De(s, e, "reference"),
1592
- // eslint-disable-next-line react-hooks/exhaustive-deps
1593
- t
1594
- ), i = v.useCallback(
1595
- (s) => De(s, e, "floating"),
1596
- // eslint-disable-next-line react-hooks/exhaustive-deps
1597
- n
1598
- ), l = v.useCallback(
1599
- (s) => De(s, e, "item"),
1600
- // eslint-disable-next-line react-hooks/exhaustive-deps
1601
- o
1602
- );
1603
- return v.useMemo(() => ({
1604
- getReferenceProps: r,
1605
- getFloatingProps: i,
1606
- getItemProps: l
1607
- }), [r, i, l]);
1608
- }
1609
- function st(e, t) {
1610
- return {
1611
- ...e,
1612
- rects: {
1613
- ...e.rects,
1614
- floating: {
1615
- ...e.rects.floating,
1616
- height: t
1617
- }
1618
- }
1619
- };
1620
- }
1621
- const so = (e) => ({
1622
- name: "inner",
1623
- options: e,
1624
- async fn(t) {
1625
- const {
1626
- listRef: n,
1627
- overflowRef: o,
1628
- onFallbackChange: r,
1629
- offset: i = 0,
1630
- index: l = 0,
1631
- minItemsVisible: s = 4,
1632
- referenceOverflowThreshold: c = 0,
1633
- scrollRef: u,
1634
- ...a
1635
- } = le(e, t), {
1636
- rects: m,
1637
- elements: {
1638
- floating: g
1639
- }
1640
- } = t, f = n.current[l], d = (u == null ? void 0 : u.current) || g, h = g.clientTop || d.clientTop, p = g.clientTop !== 0, x = d.clientTop !== 0, y = g === d;
1641
- if (process.env.NODE_ENV !== "production" && (t.placement.startsWith("bottom") || Kn('`placement` side must be "bottom" when using the `inner`', "middleware.")), !f)
1642
- return {};
1643
- const w = {
1644
- ...t,
1645
- ...await Tt(-f.offsetTop - g.clientTop - m.reference.height / 2 - f.offsetHeight / 2 - i).fn(t)
1646
- }, b = await Me(st(w, d.scrollHeight + h + g.clientTop), a), R = await Me(w, {
1647
- ...a,
1648
- elementContext: "reference"
1649
- }), C = D(0, b.top), S = w.y + C, P = fe(D(0, d.scrollHeight + (p && y || x ? h * 2 : 0) - C - D(0, b.bottom)));
1650
- if (d.style.maxHeight = P + "px", d.scrollTop = C, r) {
1651
- const N = d.scrollHeight > d.offsetHeight && d.offsetHeight < f.offsetHeight * s - 1 || R.top >= -c || R.bottom >= -c;
1652
- ye.flushSync(() => r(N));
1653
- }
1654
- return o && (o.current = await Me(st({
1655
- ...w,
1656
- y: S
1657
- }, d.offsetHeight + h + g.clientTop), a)), {
1658
- y: S
1659
- };
1660
- }
1661
- });
1662
- function co(e, t) {
1663
- const {
1664
- open: n,
1665
- elements: o
1666
- } = e, {
1667
- enabled: r = !0,
1668
- overflowRef: i,
1669
- scrollRef: l,
1670
- onChange: s
1671
- } = t, c = Mt(s), u = v.useRef(!1), a = v.useRef(null), m = v.useRef(null);
1672
- v.useEffect(() => {
1673
- if (!r) return;
1674
- function f(h) {
1675
- if (h.ctrlKey || !d || i.current == null)
1676
- return;
1677
- const p = h.deltaY, x = i.current.top >= -0.5, y = i.current.bottom >= -0.5, w = d.scrollHeight - d.clientHeight, b = p < 0 ? -1 : 1, R = p < 0 ? "max" : "min";
1678
- d.scrollHeight <= d.clientHeight || (!x && p > 0 || !y && p < 0 ? (h.preventDefault(), ye.flushSync(() => {
1679
- c((C) => C + Math[R](p, w * b));
1680
- })) : /firefox/i.test(on()) && (d.scrollTop += p));
1681
- }
1682
- const d = (l == null ? void 0 : l.current) || o.floating;
1683
- if (n && d)
1684
- return d.addEventListener("wheel", f), requestAnimationFrame(() => {
1685
- a.current = d.scrollTop, i.current != null && (m.current = {
1686
- ...i.current
1687
- });
1688
- }), () => {
1689
- a.current = null, m.current = null, d.removeEventListener("wheel", f);
1690
- };
1691
- }, [r, n, o.floating, i, l, c]);
1692
- const g = v.useMemo(() => ({
1693
- onKeyDown() {
1694
- u.current = !0;
1695
- },
1696
- onWheel() {
1697
- u.current = !1;
1698
- },
1699
- onPointerMove() {
1700
- u.current = !1;
1701
- },
1702
- onScroll() {
1703
- const f = (l == null ? void 0 : l.current) || o.floating;
1704
- if (!(!i.current || !f || !u.current)) {
1705
- if (a.current !== null) {
1706
- const d = f.scrollTop - a.current;
1707
- (i.current.bottom < -0.5 && d < -1 || i.current.top < -0.5 && d > 1) && ye.flushSync(() => c((h) => h + d));
1708
- }
1709
- requestAnimationFrame(() => {
1710
- a.current = f.scrollTop;
1711
- });
1712
- }
1713
- }
1714
- }), [o.floating, c, i, l]);
1715
- return v.useMemo(() => r ? {
1716
- floating: g
1717
- } : {}, [r, g]);
1718
- }
1719
- let we = me({ styles: void 0, setReference: () => {
1720
- }, setFloating: () => {
1721
- }, getReferenceProps: () => ({}), getFloatingProps: () => ({}), slot: {} });
1722
- we.displayName = "FloatingContext";
1723
- let Xe = me(null);
1724
- Xe.displayName = "PlacementContext";
1725
- function Fo(e) {
1726
- return Y(() => e ? typeof e == "string" ? { to: e } : e : null, [e]);
1727
- }
1728
- function Ho() {
1729
- return X(we).setReference;
1730
- }
1731
- function No() {
1732
- let { getFloatingProps: e, slot: t } = X(we);
1733
- return ut((...n) => Object.assign({}, e(...n), { "data-anchor": t.anchor }), [e, t]);
1734
- }
1735
- function Io(e = null) {
1736
- e === !1 && (e = null), typeof e == "string" && (e = { to: e });
1737
- let t = X(Xe), n = Y(() => e, [JSON.stringify(e, (r, i) => {
1738
- var l;
1739
- return (l = i == null ? void 0 : i.outerHTML) != null ? l : i;
1740
- })]);
1741
- z(() => {
1742
- t == null || t(n ?? null);
1743
- }, [t, n]);
1744
- let o = X(we);
1745
- return Y(() => [o.setFloating, e ? o.styles : {}], [o.setFloating, e, o.styles]);
1746
- }
1747
- let ct = 4;
1748
- function Wo({ children: e, enabled: t = !0 }) {
1749
- let [n, o] = ee(null), [r, i] = ee(0), l = ne(null), [s, c] = ee(null);
1750
- ao(s);
1751
- let u = t && n !== null && s !== null, { to: a = "bottom", gap: m = 0, offset: g = 0, padding: f = 0, inner: d } = uo(n, s), [h, p = "center"] = a.split(" ");
1752
- z(() => {
1753
- u && i(0);
1754
- }, [u]);
1755
- let { refs: x, floatingStyles: y, context: w } = io({ open: u, placement: h === "selection" ? p === "center" ? "bottom" : `bottom-${p}` : p === "center" ? `${h}` : `${h}-${p}`, strategy: "absolute", transform: !1, middleware: [Tt({ mainAxis: h === "selection" ? 0 : m, crossAxis: g }), Vn({ padding: f }), h !== "selection" && _n({ padding: f }), h === "selection" && d ? so({ ...d, padding: f, overflowRef: l, offset: r, minItemsVisible: ct, referenceOverflowThreshold: f, onFallbackChange(M) {
1756
- var I, L;
1757
- if (!M) return;
1758
- let A = w.elements.floating;
1759
- if (!A) return;
1760
- let U = parseFloat(getComputedStyle(A).scrollPaddingBottom) || 0, T = Math.min(ct, A.childElementCount), k = 0, E = 0;
1761
- for (let O of (L = (I = w.elements.floating) == null ? void 0 : I.childNodes) != null ? L : []) if (O instanceof HTMLElement) {
1762
- let F = O.offsetTop, qe = F + O.clientHeight + U, Te = A.scrollTop, Ge = Te + A.clientHeight;
1763
- if (F >= Te && qe <= Ge) T--;
1764
- else {
1765
- E = Math.max(0, Math.min(qe, Ge) - Math.max(F, Te)), k = O.clientHeight;
1766
- break;
1767
- }
1768
- }
1769
- T >= 1 && i((O) => {
1770
- let F = k * T - E + U;
1771
- return O >= F ? O : F;
1772
- });
1773
- } }) : null, Yn({ padding: f, apply({ availableWidth: M, availableHeight: I, elements: L }) {
1774
- Object.assign(L.floating.style, { overflow: "auto", maxWidth: `${M}px`, maxHeight: `min(var(--anchor-max-height, 100vh), ${I}px)` });
1775
- } })].filter(Boolean), whileElementsMounted: Fn }), [b = h, R = p] = w.placement.split("-");
1776
- h === "selection" && (b = "selection");
1777
- let C = Y(() => ({ anchor: [b, R].filter(Boolean).join(" ") }), [b, R]), S = co(w, { overflowRef: l, onChange: i }), { getReferenceProps: P, getFloatingProps: N } = lo([S]), H = ae((M) => {
1778
- c(M), x.setFloating(M);
1779
- });
1780
- return v.createElement(Xe.Provider, { value: o }, v.createElement(we.Provider, { value: { setFloating: H, setReference: x.setReference, styles: y, getReferenceProps: P, getFloatingProps: N, slot: C } }, e));
1781
- }
1782
- function ao(e) {
1783
- z(() => {
1784
- if (!e) return;
1785
- let t = new MutationObserver(() => {
1786
- let n = window.getComputedStyle(e).maxHeight, o = parseFloat(n);
1787
- if (isNaN(o)) return;
1788
- let r = parseInt(n);
1789
- isNaN(r) || o !== r && (e.style.maxHeight = `${Math.ceil(o)}px`);
1790
- });
1791
- return t.observe(e, { attributes: !0, attributeFilter: ["style"] }), () => {
1792
- t.disconnect();
1793
- };
1794
- }, [e]);
1795
- }
1796
- function uo(e, t) {
1797
- var n, o, r;
1798
- let i = $e((n = e == null ? void 0 : e.gap) != null ? n : "var(--anchor-gap, 0)", t), l = $e((o = e == null ? void 0 : e.offset) != null ? o : "var(--anchor-offset, 0)", t), s = $e((r = e == null ? void 0 : e.padding) != null ? r : "var(--anchor-padding, 0)", t);
1799
- return { ...e, gap: i, offset: l, padding: s };
1800
- }
1801
- function $e(e, t, n = void 0) {
1802
- let o = Wt(), r = ae((c, u) => {
1803
- if (c == null) return [n, null];
1804
- if (typeof c == "number") return [c, null];
1805
- if (typeof c == "string") {
1806
- if (!u) return [n, null];
1807
- let a = at(c, u);
1808
- return [a, (m) => {
1809
- let g = Lt(c);
1810
- {
1811
- let f = g.map((d) => window.getComputedStyle(u).getPropertyValue(d));
1812
- o.requestAnimationFrame(function d() {
1813
- o.nextFrame(d);
1814
- let h = !1;
1815
- for (let [x, y] of g.entries()) {
1816
- let w = window.getComputedStyle(u).getPropertyValue(y);
1817
- if (f[x] !== w) {
1818
- f[x] = w, h = !0;
1819
- break;
1820
- }
1821
- }
1822
- if (!h) return;
1823
- let p = at(c, u);
1824
- a !== p && (m(p), a = p);
1825
- });
1826
- }
1827
- return o.dispose;
1828
- }];
1829
- }
1830
- return [n, null];
1831
- }), i = Y(() => r(e, t)[0], [e, t]), [l = i, s] = ee();
1832
- return z(() => {
1833
- let [c, u] = r(e, t);
1834
- if (s(c), !!u) return u(s);
1835
- }, [e, t]), l;
1836
- }
1837
- function Lt(e) {
1838
- let t = /var\((.*)\)/.exec(e);
1839
- if (t) {
1840
- let n = t[1].indexOf(",");
1841
- if (n === -1) return [t[1]];
1842
- let o = t[1].slice(0, n).trim(), r = t[1].slice(n + 1).trim();
1843
- return r ? [o, ...Lt(r)] : [o];
1844
- }
1845
- return [];
1846
- }
1847
- function at(e, t) {
1848
- let n = document.createElement("div");
1849
- t.appendChild(n), n.style.setProperty("margin-top", "0px", "important"), n.style.setProperty("margin-top", e, "important");
1850
- let o = parseFloat(window.getComputedStyle(n).marginTop) || 0;
1851
- return t.removeChild(n), o;
1852
- }
1853
- function fo(e) {
1854
- let t = ae(e), n = ne(!1);
1855
- j(() => (n.current = !1, () => {
1856
- n.current = !0, kt(() => {
1857
- n.current && t();
1858
- });
1859
- }), [t]);
1860
- }
1861
- function mo() {
1862
- let e = typeof document > "u";
1863
- return "useSyncExternalStore" in v ? ((t) => t.useSyncExternalStore)(v)(() => () => {
1864
- }, () => !1, () => !e) : !1;
1865
- }
1866
- function go() {
1867
- let e = mo(), [t, n] = v.useState(ce.isHandoffComplete);
1868
- return t && ce.isHandoffComplete === !1 && n(!1), v.useEffect(() => {
1869
- t !== !0 && n(!0);
1870
- }, [t]), v.useEffect(() => ce.handoff(), []), e ? !1 : t;
1871
- }
1872
- let ho = me(!1);
1873
- function po() {
1874
- return X(ho);
1875
- }
1876
- function wo(e) {
1877
- let t = po(), n = X($t), o = wt(e), [r, i] = ee(() => {
1878
- var l;
1879
- if (!t && n !== null) return (l = n.current) != null ? l : null;
1880
- if (ce.isServer) return null;
1881
- let s = o == null ? void 0 : o.getElementById("headlessui-portal-root");
1882
- if (s) return s;
1883
- if (o === null) return null;
1884
- let c = o.createElement("div");
1885
- return c.setAttribute("id", "headlessui-portal-root"), o.body.appendChild(c);
1886
- });
1887
- return j(() => {
1888
- r !== null && (o != null && o.body.contains(r) || o == null || o.body.appendChild(r));
1889
- }, [r, o]), j(() => {
1890
- t || n !== null && i(n.current);
1891
- }, [n, i, t]), r;
1892
- }
1893
- let Dt = dt, vo = Ve(function(e, t) {
1894
- let n = e, o = ne(null), r = _e(Bt((a) => {
1895
- o.current = a;
1896
- }), t), i = wt(o), l = wo(o), [s] = ee(() => {
1897
- var a;
1898
- return ce.isServer ? null : (a = i == null ? void 0 : i.createElement("div")) != null ? a : null;
1899
- }), c = X(We), u = go();
1900
- return z(() => {
1901
- !l || !s || l.contains(s) || (s.setAttribute("data-headlessui-portal", ""), l.appendChild(s));
1902
- }, [l, s]), z(() => {
1903
- if (s && c) return c.register(s);
1904
- }, [c, s]), fo(() => {
1905
- var a;
1906
- !l || !s || (s instanceof Node && l.contains(s) && l.removeChild(s), l.childNodes.length <= 0 && ((a = l.parentElement) == null || a.removeChild(l)));
1907
- }), u ? !l || !s ? null : Yt(Ye({ ourProps: { ref: r }, theirProps: n, slot: {}, defaultTag: Dt, name: "Portal" }), s) : null;
1908
- });
1909
- function xo(e, t) {
1910
- let n = _e(t), { enabled: o = !0, ...r } = e;
1911
- return o ? ke.createElement(vo, { ...r, ref: n }) : Ye({ ourProps: { ref: n }, theirProps: r, slot: {}, defaultTag: Dt, name: "Portal" });
1912
- }
1913
- let yo = dt, $t = me(null);
1914
- function bo(e, t) {
1915
- let { target: n, ...o } = e, r = { ref: _e(t) };
1916
- return ke.createElement($t.Provider, { value: n }, Ye({ ourProps: r, theirProps: o, defaultTag: yo, name: "Popover.Group" }));
1917
- }
1918
- let We = me(null);
1919
- function ko() {
1920
- let e = X(We), t = ne([]), n = ae((i) => (t.current.push(i), e && e.register(i), () => o(i))), o = ae((i) => {
1921
- let l = t.current.indexOf(i);
1922
- l !== -1 && t.current.splice(l, 1), e && e.unregister(i);
1923
- }), r = Y(() => ({ register: n, unregister: o, portals: t }), [n, o, t]);
1924
- return [t, Y(() => function({ children: i }) {
1925
- return ke.createElement(We.Provider, { value: r }, i);
1926
- }, [r])];
1927
- }
1928
- let Ro = Ve(xo), Eo = Ve(bo), Bo = Object.assign(Ro, { Group: Eo });
1929
- export {
1930
- Do as E,
1931
- Wo as M,
1932
- Lo as R,
1933
- Io as a,
1934
- No as b,
1935
- ht as c,
1936
- To as d,
1937
- ko as e,
1938
- $o as f,
1939
- qt as g,
1940
- Mo as m,
1941
- wt as n,
1942
- Gt as s,
1943
- Bo as t,
1944
- Fo as x,
1945
- Ho as y
1946
- };