@ontoui/react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3580 @@
1
+ var co = Object.defineProperty;
2
+ var uo = (e, t, n) => t in e ? co(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var $ = (e, t, n) => uo(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { jsx as q, jsxs as Xe } from "react/jsx-runtime";
5
+ import * as a from "react";
6
+ import mt, { createElement as gn } from "react";
7
+ import * as jt from "react-dom";
8
+ function ht() {
9
+ return typeof window < "u";
10
+ }
11
+ function de(e) {
12
+ return Ht(e) ? (e.nodeName || "").toLowerCase() : "#document";
13
+ }
14
+ function Re(e) {
15
+ var t;
16
+ return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
17
+ }
18
+ function ao(e) {
19
+ var t;
20
+ return (t = (Ht(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
21
+ }
22
+ function Ht(e) {
23
+ return ht() ? e instanceof Node || e instanceof Re(e).Node : !1;
24
+ }
25
+ function Ye(e) {
26
+ return ht() ? e instanceof Element || e instanceof Re(e).Element : !1;
27
+ }
28
+ function ce(e) {
29
+ return ht() ? e instanceof HTMLElement || e instanceof Re(e).HTMLElement : !1;
30
+ }
31
+ function Ue(e) {
32
+ return !ht() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof Re(e).ShadowRoot;
33
+ }
34
+ function Yt(e) {
35
+ const {
36
+ overflow: t,
37
+ overflowX: n,
38
+ overflowY: r,
39
+ display: o
40
+ } = bt(e);
41
+ return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && o !== "inline" && o !== "contents";
42
+ }
43
+ let St;
44
+ function lo() {
45
+ return St == null && (St = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), St;
46
+ }
47
+ function Rt(e) {
48
+ return /^(html|body|#document)$/.test(de(e));
49
+ }
50
+ function bt(e) {
51
+ return Re(e).getComputedStyle(e);
52
+ }
53
+ function fo(e) {
54
+ if (de(e) === "html")
55
+ return e;
56
+ const t = (
57
+ // Step into the shadow DOM of the parent of a slotted node.
58
+ e.assignedSlot || // DOM Element detected.
59
+ e.parentNode || // ShadowRoot detected.
60
+ Ue(e) && e.host || // Fallback.
61
+ ao(e)
62
+ );
63
+ return Ue(t) ? t.host : t;
64
+ }
65
+ const mn = {};
66
+ function we(e, t) {
67
+ const n = a.useRef(mn);
68
+ return n.current === mn && (n.current = e(t)), n;
69
+ }
70
+ const vt = a[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)], po = (
71
+ // React 17 doesn't have useInsertionEffect.
72
+ vt && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
73
+ vt !== a.useLayoutEffect ? vt : (e) => e()
74
+ );
75
+ function X(e) {
76
+ const t = we(go).current;
77
+ return t.next = e, po(t.effect), t.trampoline;
78
+ }
79
+ function go() {
80
+ const e = {
81
+ next: void 0,
82
+ callback: mo,
83
+ trampoline: (...t) => {
84
+ var n;
85
+ return (n = e.callback) == null ? void 0 : n.call(e, ...t);
86
+ },
87
+ effect: () => {
88
+ e.callback = e.next;
89
+ }
90
+ };
91
+ return e;
92
+ }
93
+ function mo() {
94
+ if (process.env.NODE_ENV !== "production")
95
+ throw (
96
+ /* minify-error-disabled */
97
+ new Error("Base UI: Cannot call an event handler while rendering.")
98
+ );
99
+ }
100
+ let Mt;
101
+ process.env.NODE_ENV !== "production" && (Mt = /* @__PURE__ */ new Set());
102
+ function hn(...e) {
103
+ if (process.env.NODE_ENV !== "production") {
104
+ const t = e.join(" ");
105
+ Mt.has(t) || (Mt.add(t), console.error(`Base UI: ${t}`));
106
+ }
107
+ }
108
+ const Pe = {
109
+ ...a
110
+ }, ho = () => {
111
+ }, Y = typeof document < "u" ? a.useLayoutEffect : ho;
112
+ function Bt(e, t) {
113
+ if (e && !t)
114
+ return e;
115
+ if (!e && t)
116
+ return t;
117
+ if (e || t)
118
+ return {
119
+ ...e,
120
+ ...t
121
+ };
122
+ }
123
+ const qt = {};
124
+ function Xt(e, t, n, r, o) {
125
+ if (!n && !r && !e)
126
+ return ft(t);
127
+ let s = ft(e);
128
+ return t && (s = lt(s, t)), n && (s = lt(s, n)), r && (s = lt(s, r)), s;
129
+ }
130
+ function bo(e) {
131
+ if (e.length === 0)
132
+ return qt;
133
+ if (e.length === 1)
134
+ return ft(e[0]);
135
+ let t = ft(e[0]);
136
+ for (let n = 1; n < e.length; n += 1)
137
+ t = lt(t, e[n]);
138
+ return t;
139
+ }
140
+ function ft(e) {
141
+ return zt(e) ? {
142
+ ...Kn(e, qt)
143
+ } : Eo(e);
144
+ }
145
+ function lt(e, t) {
146
+ return zt(t) ? Kn(t, e) : yo(e, t);
147
+ }
148
+ function Eo(e) {
149
+ const t = {
150
+ ...e
151
+ };
152
+ for (const n in t) {
153
+ const r = t[n];
154
+ $n(n, r) && (t[n] = Gn(r));
155
+ }
156
+ return t;
157
+ }
158
+ function yo(e, t) {
159
+ if (!t)
160
+ return e;
161
+ for (const n in t) {
162
+ const r = t[n];
163
+ switch (n) {
164
+ case "style": {
165
+ e[n] = Bt(e.style, r);
166
+ break;
167
+ }
168
+ case "className": {
169
+ e[n] = jn(e.className, r);
170
+ break;
171
+ }
172
+ default:
173
+ $n(n, r) ? e[n] = So(e[n], r) : e[n] = r;
174
+ }
175
+ }
176
+ return e;
177
+ }
178
+ function $n(e, t) {
179
+ const n = e.charCodeAt(0), r = e.charCodeAt(1), o = e.charCodeAt(2);
180
+ return n === 111 && r === 110 && o >= 65 && o <= 90 && (typeof t == "function" || typeof t > "u");
181
+ }
182
+ function zt(e) {
183
+ return typeof e == "function";
184
+ }
185
+ function Kn(e, t) {
186
+ return zt(e) ? e(t) : e ?? qt;
187
+ }
188
+ function So(e, t) {
189
+ return t ? e ? (...n) => {
190
+ const r = n[0];
191
+ if (Hn(r)) {
192
+ const s = r;
193
+ dt(s);
194
+ const i = t(...n);
195
+ return s.baseUIHandlerPrevented || e == null || e(...n), i;
196
+ }
197
+ const o = t(...n);
198
+ return e == null || e(...n), o;
199
+ } : Gn(t) : e;
200
+ }
201
+ function Gn(e) {
202
+ return e && ((...t) => {
203
+ const n = t[0];
204
+ return Hn(n) && dt(n), e(...t);
205
+ });
206
+ }
207
+ function dt(e) {
208
+ return e.preventBaseUIHandler = () => {
209
+ e.baseUIHandlerPrevented = !0;
210
+ }, e;
211
+ }
212
+ function jn(e, t) {
213
+ return t ? e ? t + " " + e : t : e;
214
+ }
215
+ function Hn(e) {
216
+ return e != null && typeof e == "object" && "nativeEvent" in e;
217
+ }
218
+ function Ro(e, t) {
219
+ return function(r, ...o) {
220
+ const s = new URL(e);
221
+ return s.searchParams.set("code", r.toString()), o.forEach((i) => s.searchParams.append("args[]", i)), `${t} error #${r}; visit ${s} for the full message.`;
222
+ };
223
+ }
224
+ const $e = Ro("https://base-ui.com/production-error", "Base UI"), Yn = /* @__PURE__ */ a.createContext(void 0);
225
+ process.env.NODE_ENV !== "production" && (Yn.displayName = "CompositeRootContext");
226
+ function vo(e = !1) {
227
+ const t = a.useContext(Yn);
228
+ if (t === void 0 && !e)
229
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : $e(16));
230
+ return t;
231
+ }
232
+ function Oo(e) {
233
+ const {
234
+ focusableWhenDisabled: t,
235
+ disabled: n,
236
+ composite: r = !1,
237
+ tabIndex: o = 0,
238
+ isNativeButton: s
239
+ } = e, i = r && t !== !1, c = r && t === !1;
240
+ return {
241
+ props: a.useMemo(() => {
242
+ const u = {
243
+ // allow Tabbing away from focusableWhenDisabled elements
244
+ onKeyDown(f) {
245
+ n && t && f.key !== "Tab" && f.preventDefault();
246
+ }
247
+ };
248
+ return r || (u.tabIndex = o, !s && n && (u.tabIndex = t ? o : -1)), (s && (t || i) || !s && n) && (u["aria-disabled"] = n), s && (!t || c) && (u.disabled = n), u;
249
+ }, [r, n, t, i, c, s, o])
250
+ };
251
+ }
252
+ function Zt(e = {}) {
253
+ const {
254
+ disabled: t = !1,
255
+ focusableWhenDisabled: n,
256
+ tabIndex: r = 0,
257
+ native: o = !0,
258
+ composite: s
259
+ } = e, i = a.useRef(null), c = vo(!0), d = s ?? c !== void 0, {
260
+ props: u
261
+ } = Oo({
262
+ focusableWhenDisabled: n,
263
+ disabled: t,
264
+ composite: d,
265
+ tabIndex: r,
266
+ isNativeButton: o
267
+ });
268
+ process.env.NODE_ENV !== "production" && a.useEffect(() => {
269
+ var p, l;
270
+ if (!i.current)
271
+ return;
272
+ const h = nt(i.current);
273
+ if (o) {
274
+ if (!h) {
275
+ const g = ((p = Pe.captureOwnerStack) == null ? void 0 : p.call(Pe)) || "";
276
+ hn(`A component that acts as a button expected a native <button> because the \`nativeButton\` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the \`render\` prop, or set \`nativeButton\` to \`false\`.${g}`);
277
+ }
278
+ } else if (h) {
279
+ const g = ((l = Pe.captureOwnerStack) == null ? void 0 : l.call(Pe)) || "";
280
+ hn(`A component that acts as a button expected a non-<button> because the \`nativeButton\` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as \`role\` or \`aria-disabled\`). Use a non-<button> in the \`render\` prop, or set \`nativeButton\` to \`true\`.${g}`);
281
+ }
282
+ }, [o]);
283
+ const f = a.useCallback(() => {
284
+ const h = i.current;
285
+ nt(h) && d && t && u.disabled === void 0 && h.disabled && (h.disabled = !1);
286
+ }, [t, u.disabled, d]);
287
+ Y(f, [f]);
288
+ const m = a.useCallback((h = {}) => {
289
+ const {
290
+ onClick: p,
291
+ onMouseDown: l,
292
+ onKeyUp: g,
293
+ onKeyDown: y,
294
+ onPointerDown: E,
295
+ ..._
296
+ } = h;
297
+ return Xt({
298
+ type: o ? "button" : void 0,
299
+ onClick(b) {
300
+ if (t) {
301
+ b.preventDefault();
302
+ return;
303
+ }
304
+ p == null || p(b);
305
+ },
306
+ onMouseDown(b) {
307
+ t || l == null || l(b);
308
+ },
309
+ onKeyDown(b) {
310
+ if (t || (dt(b), y == null || y(b), b.baseUIHandlerPrevented))
311
+ return;
312
+ const I = b.target === b.currentTarget, O = b.currentTarget, w = nt(O), M = !o && To(O), G = I && (o ? w : !M), F = b.key === "Enter", B = b.key === " ", S = O.getAttribute("role"), Q = (S == null ? void 0 : S.startsWith("menuitem")) || S === "option" || S === "gridcell";
313
+ if (I && d && B) {
314
+ if (b.defaultPrevented && Q)
315
+ return;
316
+ b.preventDefault(), M || o && w ? (O.click(), b.preventBaseUIHandler()) : G && (p == null || p(b), b.preventBaseUIHandler());
317
+ return;
318
+ }
319
+ G && (!o && (B || F) && b.preventDefault(), !o && F && (p == null || p(b)));
320
+ },
321
+ onKeyUp(b) {
322
+ if (!t) {
323
+ if (dt(b), g == null || g(b), b.target === b.currentTarget && o && d && nt(b.currentTarget) && b.key === " ") {
324
+ b.preventDefault();
325
+ return;
326
+ }
327
+ b.baseUIHandlerPrevented || b.target === b.currentTarget && !o && !d && b.key === " " && (p == null || p(b));
328
+ }
329
+ },
330
+ onPointerDown(b) {
331
+ if (t) {
332
+ b.preventDefault();
333
+ return;
334
+ }
335
+ E == null || E(b);
336
+ }
337
+ }, o ? void 0 : {
338
+ role: "button"
339
+ }, u, _);
340
+ }, [t, u, d, o]), v = X((h) => {
341
+ i.current = h, f();
342
+ });
343
+ return {
344
+ getButtonProps: m,
345
+ buttonRef: v
346
+ };
347
+ }
348
+ function nt(e) {
349
+ return ce(e) && e.tagName === "BUTTON";
350
+ }
351
+ function To(e) {
352
+ return !!((e == null ? void 0 : e.tagName) === "A" && (e != null && e.href));
353
+ }
354
+ function pt(e, t, n, r) {
355
+ const o = we(qn).current;
356
+ return Co(o, e, t, n, r) && Xn(o, [e, t, n, r]), o.callback;
357
+ }
358
+ function wo(e) {
359
+ const t = we(qn).current;
360
+ return Io(t, e) && Xn(t, e), t.callback;
361
+ }
362
+ function qn() {
363
+ return {
364
+ callback: null,
365
+ cleanup: null,
366
+ refs: []
367
+ };
368
+ }
369
+ function Co(e, t, n, r, o) {
370
+ return e.refs[0] !== t || e.refs[1] !== n || e.refs[2] !== r || e.refs[3] !== o;
371
+ }
372
+ function Io(e, t) {
373
+ return e.refs.length !== t.length || e.refs.some((n, r) => n !== t[r]);
374
+ }
375
+ function Xn(e, t) {
376
+ if (e.refs = t, t.every((n) => n == null)) {
377
+ e.callback = null;
378
+ return;
379
+ }
380
+ e.callback = (n) => {
381
+ if (e.cleanup && (e.cleanup(), e.cleanup = null), n != null) {
382
+ const r = Array(t.length).fill(null);
383
+ for (let o = 0; o < t.length; o += 1) {
384
+ const s = t[o];
385
+ if (s != null)
386
+ switch (typeof s) {
387
+ case "function": {
388
+ const i = s(n);
389
+ typeof i == "function" && (r[o] = i);
390
+ break;
391
+ }
392
+ case "object": {
393
+ s.current = n;
394
+ break;
395
+ }
396
+ }
397
+ }
398
+ e.cleanup = () => {
399
+ for (let o = 0; o < t.length; o += 1) {
400
+ const s = t[o];
401
+ if (s != null)
402
+ switch (typeof s) {
403
+ case "function": {
404
+ const i = r[o];
405
+ typeof i == "function" ? i() : s(null);
406
+ break;
407
+ }
408
+ case "object": {
409
+ s.current = null;
410
+ break;
411
+ }
412
+ }
413
+ }
414
+ };
415
+ }
416
+ };
417
+ }
418
+ const _o = parseInt(a.version, 10);
419
+ function Jt(e) {
420
+ return _o >= e;
421
+ }
422
+ function bn(e) {
423
+ if (!/* @__PURE__ */ a.isValidElement(e))
424
+ return null;
425
+ const t = e, n = t.props;
426
+ return (Jt(19) ? n == null ? void 0 : n.ref : t.ref) ?? null;
427
+ }
428
+ let Vt;
429
+ process.env.NODE_ENV !== "production" && (Vt = /* @__PURE__ */ new Set());
430
+ function Po(...e) {
431
+ if (process.env.NODE_ENV !== "production") {
432
+ const t = e.join(" ");
433
+ Vt.has(t) || (Vt.add(t), console.warn(`Base UI: ${t}`));
434
+ }
435
+ }
436
+ function Qt() {
437
+ }
438
+ const fe = Object.freeze({});
439
+ function No(e, t) {
440
+ const n = {};
441
+ for (const r in e) {
442
+ const o = e[r];
443
+ if (t != null && t.hasOwnProperty(r)) {
444
+ const s = t[r](o);
445
+ s != null && Object.assign(n, s);
446
+ continue;
447
+ }
448
+ o === !0 ? n[`data-${r.toLowerCase()}`] = "" : o && (n[`data-${r.toLowerCase()}`] = o.toString());
449
+ }
450
+ return n;
451
+ }
452
+ function Do(e, t) {
453
+ return typeof e == "function" ? e(t) : e;
454
+ }
455
+ function xo(e, t) {
456
+ return typeof e == "function" ? e(t) : e;
457
+ }
458
+ function Ce(e, t, n = {}) {
459
+ const r = t.render, o = ko(t, n);
460
+ if (n.enabled === !1)
461
+ return null;
462
+ const s = n.state ?? fe;
463
+ return Fo(e, r, o, s);
464
+ }
465
+ function ko(e, t = {}) {
466
+ const {
467
+ className: n,
468
+ style: r,
469
+ render: o
470
+ } = e, {
471
+ state: s = fe,
472
+ ref: i,
473
+ props: c,
474
+ stateAttributesMapping: d,
475
+ enabled: u = !0
476
+ } = t, f = u ? Do(n, s) : void 0, m = u ? xo(r, s) : void 0, v = u ? No(s, d) : fe, h = u && c ? Ao(c) : void 0, p = u ? Bt(v, h) ?? {} : fe;
477
+ return typeof document < "u" && (u ? Array.isArray(i) ? p.ref = wo([p.ref, bn(o), ...i]) : p.ref = pt(p.ref, bn(o), i) : pt(null, null)), u ? (f !== void 0 && (p.className = jn(p.className, f)), m !== void 0 && (p.style = Bt(p.style, m)), p) : fe;
478
+ }
479
+ function Ao(e) {
480
+ return Array.isArray(e) ? bo(e) : Xt(void 0, e);
481
+ }
482
+ const Mo = Symbol.for("react.lazy"), Bo = /^[A-Z][A-Za-z0-9$]*$/, Vo = /[a-z]/;
483
+ function Fo(e, t, n, r) {
484
+ if (t) {
485
+ if (typeof t == "function")
486
+ return process.env.NODE_ENV !== "production" && Lo(t), t(n, r);
487
+ const o = Xt(n, t.props);
488
+ o.ref = n.ref;
489
+ let s = t;
490
+ if ((s == null ? void 0 : s.$$typeof) === Mo && (s = a.Children.toArray(t)[0]), process.env.NODE_ENV !== "production" && !/* @__PURE__ */ a.isValidElement(s))
491
+ throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join(`
492
+ `));
493
+ return /* @__PURE__ */ a.cloneElement(s, o);
494
+ }
495
+ if (e && typeof e == "string")
496
+ return Wo(e, n);
497
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : $e(8));
498
+ }
499
+ function Lo(e) {
500
+ const t = e.name;
501
+ t.length !== 0 && Bo.test(t) && Vo.test(t) && Po(`The \`render\` prop received a function named \`${t}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
502
+ }
503
+ function Wo(e, t) {
504
+ return e === "button" ? /* @__PURE__ */ gn("button", {
505
+ type: "button",
506
+ ...t,
507
+ key: t.key
508
+ }) : e === "img" ? /* @__PURE__ */ gn("img", {
509
+ alt: "",
510
+ ...t,
511
+ key: t.key
512
+ }) : /* @__PURE__ */ a.createElement(e, t);
513
+ }
514
+ const zn = /* @__PURE__ */ a.forwardRef(function(t, n) {
515
+ const {
516
+ render: r,
517
+ className: o,
518
+ disabled: s = !1,
519
+ focusableWhenDisabled: i = !1,
520
+ nativeButton: c = !0,
521
+ style: d,
522
+ ...u
523
+ } = t, {
524
+ getButtonProps: f,
525
+ buttonRef: m
526
+ } = Zt({
527
+ disabled: s,
528
+ focusableWhenDisabled: i,
529
+ native: c
530
+ });
531
+ return Ce("button", t, {
532
+ state: {
533
+ disabled: s
534
+ },
535
+ ref: [n, m],
536
+ props: [u, f]
537
+ });
538
+ });
539
+ process.env.NODE_ENV !== "production" && (zn.displayName = "Button");
540
+ const Uo = "_Button_tp3a5_1", $o = "_Button_variant_primary_tp3a5_34", Ko = "_Button_variant_secondary_tp3a5_47", En = {
541
+ Button: Uo,
542
+ Button_variant_primary: $o,
543
+ Button_variant_secondary: Ko
544
+ }, en = a.forwardRef(function({ children: t, id: n, className: r, variant: o = "primary", disabled: s = !1, onClick: i, onFocus: c, onBlur: d }, u) {
545
+ const f = [En.Button, En[`Button_variant_${o}`], r].filter(Boolean).join(" ");
546
+ return /* @__PURE__ */ q(
547
+ zn,
548
+ {
549
+ ref: u,
550
+ id: n,
551
+ className: f,
552
+ disabled: s,
553
+ onClick: i,
554
+ onFocus: c,
555
+ onBlur: d,
556
+ children: t
557
+ }
558
+ );
559
+ });
560
+ en.displayName = "Button";
561
+ const tn = /* @__PURE__ */ a.createContext(void 0);
562
+ process.env.NODE_ENV !== "production" && (tn.displayName = "DialogRootContext");
563
+ function Ie(e) {
564
+ const t = a.useContext(tn);
565
+ if (e === !1 && t === void 0)
566
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: DialogRootContext is missing. Dialog parts must be placed within <Dialog.Root>." : $e(27));
567
+ return t;
568
+ }
569
+ let ze = /* @__PURE__ */ (function(e) {
570
+ return e.startingStyle = "data-starting-style", e.endingStyle = "data-ending-style", e;
571
+ })({});
572
+ const Go = {
573
+ [ze.startingStyle]: ""
574
+ }, jo = {
575
+ [ze.endingStyle]: ""
576
+ }, Zn = {
577
+ transitionStatus(e) {
578
+ return e === "starting" ? Go : e === "ending" ? jo : null;
579
+ }
580
+ };
581
+ let De = (function(e) {
582
+ return e.open = "data-open", e.closed = "data-closed", e[e.startingStyle = ze.startingStyle] = "startingStyle", e[e.endingStyle = ze.endingStyle] = "endingStyle", e.anchorHidden = "data-anchor-hidden", e.side = "data-side", e.align = "data-align", e;
583
+ })({}), Ho = /* @__PURE__ */ (function(e) {
584
+ return e.popupOpen = "data-popup-open", e.pressed = "data-pressed", e;
585
+ })({});
586
+ const Yo = {
587
+ [Ho.popupOpen]: ""
588
+ }, qo = {
589
+ [De.open]: ""
590
+ }, Xo = {
591
+ [De.closed]: ""
592
+ }, zo = {
593
+ [De.anchorHidden]: ""
594
+ }, Zo = {
595
+ open(e) {
596
+ return e ? Yo : null;
597
+ }
598
+ }, Jn = {
599
+ open(e) {
600
+ return e ? qo : Xo;
601
+ },
602
+ anchorHidden(e) {
603
+ return e ? zo : null;
604
+ }
605
+ }, Jo = {
606
+ ...Jn,
607
+ ...Zn
608
+ }, Qn = /* @__PURE__ */ a.forwardRef(function(t, n) {
609
+ const {
610
+ render: r,
611
+ className: o,
612
+ style: s,
613
+ forceRender: i = !1,
614
+ ...c
615
+ } = t, {
616
+ store: d
617
+ } = Ie(), u = d.useState("open"), f = d.useState("nested"), m = d.useState("mounted"), v = d.useState("transitionStatus");
618
+ return Ce("div", t, {
619
+ state: {
620
+ open: u,
621
+ transitionStatus: v
622
+ },
623
+ ref: [d.context.backdropRef, n],
624
+ stateAttributesMapping: Jo,
625
+ props: [{
626
+ role: "presentation",
627
+ hidden: !m,
628
+ style: {
629
+ userSelect: "none",
630
+ WebkitUserSelect: "none"
631
+ }
632
+ }, c],
633
+ enabled: i || !f
634
+ });
635
+ });
636
+ process.env.NODE_ENV !== "production" && (Qn.displayName = "DialogBackdrop");
637
+ const Ft = "trigger-press", Qo = "trigger-hover", er = "outside-press", es = "close-press", tr = "focus-out", ts = "escape-key", ns = "imperative-action";
638
+ function he(e, t, n, r) {
639
+ let o = !1, s = !1;
640
+ const i = fe;
641
+ return {
642
+ reason: e,
643
+ event: t ?? new Event("base-ui"),
644
+ cancel() {
645
+ o = !0;
646
+ },
647
+ allowPropagation() {
648
+ s = !0;
649
+ },
650
+ get isCanceled() {
651
+ return o;
652
+ },
653
+ get isPropagationAllowed() {
654
+ return s;
655
+ },
656
+ trigger: n,
657
+ ...i
658
+ };
659
+ }
660
+ const nr = /* @__PURE__ */ a.forwardRef(function(t, n) {
661
+ const {
662
+ render: r,
663
+ className: o,
664
+ disabled: s = !1,
665
+ nativeButton: i = !0,
666
+ style: c,
667
+ ...d
668
+ } = t, {
669
+ store: u
670
+ } = Ie(), f = u.useState("open");
671
+ function m(l) {
672
+ f && u.setOpen(!1, he(es, l.nativeEvent));
673
+ }
674
+ const {
675
+ getButtonProps: v,
676
+ buttonRef: h
677
+ } = Zt({
678
+ disabled: s,
679
+ native: i
680
+ });
681
+ return Ce("button", t, {
682
+ state: {
683
+ disabled: s
684
+ },
685
+ ref: [n, h],
686
+ props: [{
687
+ onClick: m
688
+ }, d, v]
689
+ });
690
+ });
691
+ process.env.NODE_ENV !== "production" && (nr.displayName = "DialogClose");
692
+ let yn = 0;
693
+ function rs(e, t = "mui") {
694
+ const [n, r] = a.useState(e), o = e || n;
695
+ return a.useEffect(() => {
696
+ n == null && (yn += 1, r(`${t}-${yn}`));
697
+ }, [n, t]), o;
698
+ }
699
+ const Sn = Pe.useId;
700
+ function Et(e, t) {
701
+ if (Sn !== void 0) {
702
+ const n = Sn();
703
+ return e ?? (t ? `${t}-${n}` : n);
704
+ }
705
+ return rs(e, t);
706
+ }
707
+ function nn(e) {
708
+ return Et(e, "base-ui");
709
+ }
710
+ const rr = /* @__PURE__ */ a.forwardRef(function(t, n) {
711
+ const {
712
+ render: r,
713
+ className: o,
714
+ style: s,
715
+ id: i,
716
+ ...c
717
+ } = t, {
718
+ store: d
719
+ } = Ie(), u = nn(i);
720
+ return d.useSyncedValueWithCleanup("descriptionElementId", u), Ce("p", t, {
721
+ ref: n,
722
+ props: [{
723
+ id: u
724
+ }, c]
725
+ });
726
+ });
727
+ process.env.NODE_ENV !== "production" && (rr.displayName = "DialogDescription");
728
+ const os = [];
729
+ function or(e) {
730
+ a.useEffect(e, os);
731
+ }
732
+ const je = 0;
733
+ class xe {
734
+ constructor() {
735
+ $(this, "currentId", je);
736
+ $(this, "clear", () => {
737
+ this.currentId !== je && (clearTimeout(this.currentId), this.currentId = je);
738
+ });
739
+ $(this, "disposeEffect", () => this.clear);
740
+ }
741
+ static create() {
742
+ return new xe();
743
+ }
744
+ /**
745
+ * Executes `fn` after `delay`, clearing any previously scheduled call.
746
+ */
747
+ start(t, n) {
748
+ this.clear(), this.currentId = setTimeout(() => {
749
+ this.currentId = je, n();
750
+ }, t);
751
+ }
752
+ isStarted() {
753
+ return this.currentId !== je;
754
+ }
755
+ }
756
+ function Ze() {
757
+ const e = we(xe.create).current;
758
+ return or(e.disposeEffect), e;
759
+ }
760
+ const Ke = typeof navigator < "u", Ot = cs(), sr = as(), ir = us(), cr = typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter:none"), ur = (
761
+ // iPads can claim to be MacIntel
762
+ Ot.platform === "MacIntel" && Ot.maxTouchPoints > 1 ? !0 : /iP(hone|ad|od)|iOS/.test(Ot.platform)
763
+ ), ss = Ke && /apple/i.test(navigator.vendor), Lt = Ke && /android/i.test(sr) || /android/i.test(ir);
764
+ Ke && sr.toLowerCase().startsWith("mac") && navigator.maxTouchPoints;
765
+ const is = ir.includes("jsdom/");
766
+ function cs() {
767
+ if (!Ke)
768
+ return {
769
+ platform: "",
770
+ maxTouchPoints: -1
771
+ };
772
+ const e = navigator.userAgentData;
773
+ return e != null && e.platform ? {
774
+ platform: e.platform,
775
+ maxTouchPoints: navigator.maxTouchPoints
776
+ } : {
777
+ platform: navigator.platform ?? "",
778
+ maxTouchPoints: navigator.maxTouchPoints ?? -1
779
+ };
780
+ }
781
+ function us() {
782
+ if (!Ke)
783
+ return "";
784
+ const e = navigator.userAgentData;
785
+ return e && Array.isArray(e.brands) ? e.brands.map(({
786
+ brand: t,
787
+ version: n
788
+ }) => `${t}/${n}`).join(" ") : navigator.userAgent;
789
+ }
790
+ function as() {
791
+ if (!Ke)
792
+ return "";
793
+ const e = navigator.userAgentData;
794
+ return e != null && e.platform ? e.platform : navigator.platform ?? "";
795
+ }
796
+ function ls(e) {
797
+ e.preventDefault(), e.stopPropagation();
798
+ }
799
+ function fs(e) {
800
+ return "nativeEvent" in e;
801
+ }
802
+ function ds(e) {
803
+ return e.pointerType === "" && e.isTrusted ? !0 : Lt && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
804
+ }
805
+ function ps(e) {
806
+ return is ? !1 : !Lt && e.width === 0 && e.height === 0 || Lt && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
807
+ e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
808
+ }
809
+ function Rn(e, t) {
810
+ return ["mouse", "pen"].includes(e);
811
+ }
812
+ function ar(e) {
813
+ const t = e.type;
814
+ return t === "click" || t === "mousedown" || t === "keydown" || t === "keyup";
815
+ }
816
+ function U(e, t, n, r) {
817
+ return e.addEventListener(t, n, r), () => {
818
+ e.removeEventListener(t, n, r);
819
+ };
820
+ }
821
+ function Le(...e) {
822
+ return () => {
823
+ for (let t = 0; t < e.length; t += 1) {
824
+ const n = e[t];
825
+ n && n();
826
+ }
827
+ };
828
+ }
829
+ function Tt(e) {
830
+ const t = we(gs, e).current;
831
+ return t.next = e, Y(t.effect), t;
832
+ }
833
+ function gs(e) {
834
+ const t = {
835
+ current: e,
836
+ next: e,
837
+ effect: () => {
838
+ t.current = t.next;
839
+ }
840
+ };
841
+ return t;
842
+ }
843
+ const rt = null;
844
+ let vn = globalThis.requestAnimationFrame;
845
+ class ms {
846
+ constructor() {
847
+ /* This implementation uses an array as a backing data-structure for frame callbacks.
848
+ * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
849
+ * never calls the native `cancelAnimationFrame` if there are no frames left. This can
850
+ * be much more efficient if there is a call pattern that alterns as
851
+ * "request-cancel-request-cancel-…".
852
+ * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
853
+ * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
854
+ $(this, "callbacks", []);
855
+ $(this, "callbacksCount", 0);
856
+ $(this, "nextId", 1);
857
+ $(this, "startId", 1);
858
+ $(this, "isScheduled", !1);
859
+ $(this, "tick", (t) => {
860
+ var o;
861
+ this.isScheduled = !1;
862
+ const n = this.callbacks, r = this.callbacksCount;
863
+ if (this.callbacks = [], this.callbacksCount = 0, this.startId = this.nextId, r > 0)
864
+ for (let s = 0; s < n.length; s += 1)
865
+ (o = n[s]) == null || o.call(n, t);
866
+ });
867
+ }
868
+ request(t) {
869
+ const n = this.nextId;
870
+ this.nextId += 1, this.callbacks.push(t), this.callbacksCount += 1;
871
+ const r = process.env.NODE_ENV !== "production" && vn !== requestAnimationFrame && (vn = requestAnimationFrame, !0);
872
+ return (!this.isScheduled || r) && (requestAnimationFrame(this.tick), this.isScheduled = !0), n;
873
+ }
874
+ cancel(t) {
875
+ const n = t - this.startId;
876
+ n < 0 || n >= this.callbacks.length || (this.callbacks[n] = null, this.callbacksCount -= 1);
877
+ }
878
+ }
879
+ const ot = new ms();
880
+ class Ee {
881
+ constructor() {
882
+ $(this, "currentId", rt);
883
+ $(this, "cancel", () => {
884
+ this.currentId !== rt && (ot.cancel(this.currentId), this.currentId = rt);
885
+ });
886
+ $(this, "disposeEffect", () => this.cancel);
887
+ }
888
+ static create() {
889
+ return new Ee();
890
+ }
891
+ static request(t) {
892
+ return ot.request(t);
893
+ }
894
+ static cancel(t) {
895
+ return ot.cancel(t);
896
+ }
897
+ /**
898
+ * Executes `fn` after `delay`, clearing any previously scheduled call.
899
+ */
900
+ request(t) {
901
+ this.cancel(), this.currentId = ot.request(() => {
902
+ this.currentId = rt, t();
903
+ });
904
+ }
905
+ }
906
+ function rn() {
907
+ const e = we(Ee.create).current;
908
+ return or(e.disposeEffect), e;
909
+ }
910
+ function Z(e) {
911
+ return (e == null ? void 0 : e.ownerDocument) || document;
912
+ }
913
+ const hs = {
914
+ clipPath: "inset(50%)",
915
+ overflow: "hidden",
916
+ whiteSpace: "nowrap",
917
+ border: 0,
918
+ padding: 0,
919
+ width: 1,
920
+ height: 1,
921
+ margin: -1
922
+ }, bs = {
923
+ ...hs,
924
+ position: "fixed",
925
+ top: 0,
926
+ left: 0
927
+ }, Je = /* @__PURE__ */ a.forwardRef(function(t, n) {
928
+ const [r, o] = a.useState();
929
+ return Y(() => {
930
+ ss && o("button");
931
+ }, []), /* @__PURE__ */ q("span", {
932
+ ...t,
933
+ ref: n,
934
+ style: bs,
935
+ "aria-hidden": r ? void 0 : !0,
936
+ ...{
937
+ tabIndex: 0,
938
+ // Role is only for VoiceOver
939
+ role: r
940
+ },
941
+ "data-base-ui-focus-guard": ""
942
+ });
943
+ });
944
+ process.env.NODE_ENV !== "production" && (Je.displayName = "FocusGuard");
945
+ const Wt = "data-base-ui-focusable", lr = "active", fr = "selected", Es = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
946
+ function Ne(e) {
947
+ var n;
948
+ let t = e.activeElement;
949
+ for (; ((n = t == null ? void 0 : t.shadowRoot) == null ? void 0 : n.activeElement) != null; )
950
+ t = t.shadowRoot.activeElement;
951
+ return t;
952
+ }
953
+ function K(e, t) {
954
+ var r;
955
+ if (!e || !t)
956
+ return !1;
957
+ const n = (r = t.getRootNode) == null ? void 0 : r.call(t);
958
+ if (e.contains(t))
959
+ return !0;
960
+ if (n && Ue(n)) {
961
+ let o = t;
962
+ for (; o; ) {
963
+ if (e === o)
964
+ return !0;
965
+ o = o.parentNode || o.host;
966
+ }
967
+ }
968
+ return !1;
969
+ }
970
+ function Se(e) {
971
+ return "composedPath" in e ? e.composedPath()[0] : e.target;
972
+ }
973
+ function me(e, t) {
974
+ if (t == null)
975
+ return !1;
976
+ if ("composedPath" in e)
977
+ return e.composedPath().includes(t);
978
+ const n = e;
979
+ return n.target != null && t.contains(n.target);
980
+ }
981
+ function ys(e) {
982
+ return e.matches("html,body");
983
+ }
984
+ function on(e) {
985
+ return ce(e) && e.matches(Es);
986
+ }
987
+ function On(e) {
988
+ return e ? e.getAttribute("role") === "combobox" && on(e) : !1;
989
+ }
990
+ function Ut(e) {
991
+ return e ? e.hasAttribute(Wt) ? e : e.querySelector(`[${Wt}]`) || e : null;
992
+ }
993
+ function Ss(e) {
994
+ return e.visibility === "hidden" || e.visibility === "collapse";
995
+ }
996
+ function dr(e, t = e ? bt(e) : null) {
997
+ return !e || !e.isConnected || !t || Ss(t) ? !1 : typeof e.checkVisibility == "function" ? e.checkVisibility() : t.display !== "none" && t.display !== "contents";
998
+ }
999
+ const Rs = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
1000
+ function vs(e) {
1001
+ const t = e.assignedSlot;
1002
+ if (t)
1003
+ return t;
1004
+ if (e.parentElement)
1005
+ return e.parentElement;
1006
+ const n = e.getRootNode();
1007
+ return Ue(n) ? n.host : null;
1008
+ }
1009
+ function $t(e) {
1010
+ for (const t of Array.from(e.children))
1011
+ if (de(t) === "summary")
1012
+ return t;
1013
+ return null;
1014
+ }
1015
+ function Os(e, t) {
1016
+ const n = $t(t);
1017
+ return !!n && (e === n || K(n, e));
1018
+ }
1019
+ function pr(e) {
1020
+ const t = e ? de(e) : "";
1021
+ return e != null && e.matches(Rs) && (t !== "summary" || e.parentElement != null && de(e.parentElement) === "details" && $t(e.parentElement) === e) && (t !== "details" || $t(e) == null) && (t !== "input" || e.type !== "hidden");
1022
+ }
1023
+ function gr(e) {
1024
+ if (!pr(e) || !e.isConnected || e.matches(":disabled"))
1025
+ return !1;
1026
+ for (let t = e; t; t = vs(t)) {
1027
+ const n = t !== e, r = de(t) === "slot";
1028
+ if (t.hasAttribute("inert") || n && de(t) === "details" && !t.open && !Os(e, t) || t.hasAttribute("hidden") || !r && !Ts(t, n))
1029
+ return !1;
1030
+ }
1031
+ return !0;
1032
+ }
1033
+ function Ts(e, t) {
1034
+ const n = bt(e);
1035
+ return t ? n.display !== "none" : dr(e, n);
1036
+ }
1037
+ function mr(e) {
1038
+ const t = e.tabIndex;
1039
+ if (t < 0) {
1040
+ const n = de(e);
1041
+ if (n === "details" || n === "audio" || n === "video" || ce(e) && e.isContentEditable)
1042
+ return 0;
1043
+ }
1044
+ return t;
1045
+ }
1046
+ function wt(e) {
1047
+ if (de(e) !== "input")
1048
+ return null;
1049
+ const t = e;
1050
+ return t.type === "radio" && t.name !== "" ? t : null;
1051
+ }
1052
+ function ws(e, t) {
1053
+ const n = wt(e);
1054
+ if (!n)
1055
+ return !0;
1056
+ const r = t.find((o) => {
1057
+ const s = wt(o);
1058
+ return (s == null ? void 0 : s.name) === n.name && s.form === n.form && s.checked;
1059
+ });
1060
+ return r ? r === n : t.find((o) => {
1061
+ const s = wt(o);
1062
+ return (s == null ? void 0 : s.name) === n.name && s.form === n.form;
1063
+ }) === n;
1064
+ }
1065
+ function hr(e) {
1066
+ if (ce(e) && de(e) === "slot") {
1067
+ const t = e.assignedElements({
1068
+ flatten: !0
1069
+ });
1070
+ if (t.length > 0)
1071
+ return t;
1072
+ }
1073
+ return ce(e) && e.shadowRoot ? Array.from(e.shadowRoot.children) : Array.from(e.children);
1074
+ }
1075
+ function br(e, t) {
1076
+ hr(e).forEach((n) => {
1077
+ pr(n) && t.push(n), br(n, t);
1078
+ });
1079
+ }
1080
+ function Er(e, t, n) {
1081
+ hr(e).forEach((r) => {
1082
+ ce(r) && r.matches(t) && n.push(r), Er(r, t, n);
1083
+ });
1084
+ }
1085
+ function sn(e) {
1086
+ return gr(e) && mr(e) >= 0;
1087
+ }
1088
+ function yr(e) {
1089
+ const t = [];
1090
+ return br(e, t), t.filter(gr);
1091
+ }
1092
+ function yt(e) {
1093
+ const t = yr(e);
1094
+ return t.filter((n) => mr(n) >= 0 && ws(n, t));
1095
+ }
1096
+ function Sr(e, t) {
1097
+ const n = yt(e), r = n.length;
1098
+ if (r === 0)
1099
+ return;
1100
+ const o = Ne(Z(e)), s = n.indexOf(o), i = s === -1 ? t === 1 ? 0 : r - 1 : s + t;
1101
+ return n[i];
1102
+ }
1103
+ function Rr(e) {
1104
+ return Sr(Z(e).body, 1) || e;
1105
+ }
1106
+ function vr(e) {
1107
+ return Sr(Z(e).body, -1) || e;
1108
+ }
1109
+ function qe(e, t) {
1110
+ const n = t || e.currentTarget, r = e.relatedTarget;
1111
+ return !r || !K(n, r);
1112
+ }
1113
+ function Cs(e) {
1114
+ yt(e).forEach((n) => {
1115
+ n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
1116
+ });
1117
+ }
1118
+ function Tn(e) {
1119
+ const t = [];
1120
+ Er(e, "[data-tabindex]", t), t.forEach((n) => {
1121
+ const r = n.dataset.tabindex;
1122
+ delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
1123
+ });
1124
+ }
1125
+ function We(e, t, n = !0) {
1126
+ return e.filter((o) => o.parentId === t).flatMap((o) => {
1127
+ var s;
1128
+ return [...!n || (s = o.context) != null && s.open ? [o] : [], ...We(e, o.id, n)];
1129
+ });
1130
+ }
1131
+ function wn(e, t) {
1132
+ var o;
1133
+ let n = [], r = (o = e.find((s) => s.id === t)) == null ? void 0 : o.parentId;
1134
+ for (; r; ) {
1135
+ const s = e.find((i) => i.id === r);
1136
+ r = s == null ? void 0 : s.parentId, s && (n = n.concat(s));
1137
+ }
1138
+ return n;
1139
+ }
1140
+ function gt(e) {
1141
+ return `data-base-ui-${e}`;
1142
+ }
1143
+ let st = 0;
1144
+ function Ct(e, t = {}) {
1145
+ const {
1146
+ preventScroll: n = !1,
1147
+ cancelPrevious: r = !0,
1148
+ sync: o = !1
1149
+ } = t;
1150
+ r && cancelAnimationFrame(st);
1151
+ const s = () => e == null ? void 0 : e.focus({
1152
+ preventScroll: n
1153
+ });
1154
+ if (o)
1155
+ return s(), Qt;
1156
+ const i = requestAnimationFrame(s);
1157
+ return st = i, () => {
1158
+ st === i && (cancelAnimationFrame(i), st = 0);
1159
+ };
1160
+ }
1161
+ const It = {
1162
+ inert: /* @__PURE__ */ new WeakMap(),
1163
+ "aria-hidden": /* @__PURE__ */ new WeakMap()
1164
+ }, Cn = "data-base-ui-inert", Kt = {
1165
+ inert: /* @__PURE__ */ new WeakSet(),
1166
+ "aria-hidden": /* @__PURE__ */ new WeakSet()
1167
+ };
1168
+ let He = /* @__PURE__ */ new WeakMap(), _t = 0;
1169
+ function Is(e) {
1170
+ return Kt[e];
1171
+ }
1172
+ function Or(e) {
1173
+ return e ? Ue(e) ? e.host : Or(e.parentNode) : null;
1174
+ }
1175
+ const Pt = (e, t) => t.map((n) => {
1176
+ if (e.contains(n))
1177
+ return n;
1178
+ const r = Or(n);
1179
+ return e.contains(r) ? r : null;
1180
+ }).filter((n) => n != null), In = (e) => {
1181
+ const t = /* @__PURE__ */ new Set();
1182
+ return e.forEach((n) => {
1183
+ let r = n;
1184
+ for (; r && !t.has(r); )
1185
+ t.add(r), r = r.parentNode;
1186
+ }), t;
1187
+ }, _n = (e, t, n) => {
1188
+ const r = [], o = (s) => {
1189
+ !s || n.has(s) || Array.from(s.children).forEach((i) => {
1190
+ de(i) !== "script" && (t.has(i) ? o(i) : r.push(i));
1191
+ });
1192
+ };
1193
+ return o(e), r;
1194
+ };
1195
+ function _s(e, t, n, r, {
1196
+ mark: o = !0,
1197
+ markerIgnoreElements: s = []
1198
+ }) {
1199
+ const i = r ? "inert" : n ? "aria-hidden" : null;
1200
+ let c = null, d = null;
1201
+ const u = Pt(t, e), f = o ? Pt(t, s) : [], m = new Set(f), v = o ? _n(t, In(u), new Set(u)).filter((l) => !m.has(l)) : [], h = [], p = [];
1202
+ if (i) {
1203
+ const l = It[i], g = Is(i);
1204
+ d = g, c = l;
1205
+ const y = Pt(t, Array.from(t.querySelectorAll("[aria-live]"))), E = u.concat(y);
1206
+ _n(t, In(E), new Set(E)).forEach((C) => {
1207
+ const b = C.getAttribute(i), I = b !== null && b !== "false", O = (l.get(C) || 0) + 1;
1208
+ l.set(C, O), h.push(C), O === 1 && I && g.add(C), I || C.setAttribute(i, i === "inert" ? "" : "true");
1209
+ });
1210
+ }
1211
+ return o && v.forEach((l) => {
1212
+ const g = (He.get(l) || 0) + 1;
1213
+ He.set(l, g), p.push(l), g === 1 && l.setAttribute(Cn, "");
1214
+ }), _t += 1, () => {
1215
+ c && h.forEach((l) => {
1216
+ const y = (c.get(l) || 0) - 1;
1217
+ c.set(l, y), y || (!(d != null && d.has(l)) && i && l.removeAttribute(i), d == null || d.delete(l));
1218
+ }), o && p.forEach((l) => {
1219
+ const g = (He.get(l) || 0) - 1;
1220
+ He.set(l, g), g || l.removeAttribute(Cn);
1221
+ }), _t -= 1, _t || (It.inert = /* @__PURE__ */ new WeakMap(), It["aria-hidden"] = /* @__PURE__ */ new WeakMap(), Kt.inert = /* @__PURE__ */ new WeakSet(), Kt["aria-hidden"] = /* @__PURE__ */ new WeakSet(), He = /* @__PURE__ */ new WeakMap());
1222
+ };
1223
+ }
1224
+ function Pn(e, t = {}) {
1225
+ const {
1226
+ ariaHidden: n = !1,
1227
+ inert: r = !1,
1228
+ mark: o = !0,
1229
+ markerIgnoreElements: s = []
1230
+ } = t, i = Z(e[0]).body;
1231
+ return _s(e, i, n, r, {
1232
+ mark: o,
1233
+ markerIgnoreElements: s
1234
+ });
1235
+ }
1236
+ const Tr = "data-base-ui-click-trigger", Ps = {
1237
+ clipPath: "inset(50%)",
1238
+ position: "fixed",
1239
+ top: 0,
1240
+ left: 0
1241
+ }, cn = /* @__PURE__ */ a.createContext(null);
1242
+ process.env.NODE_ENV !== "production" && (cn.displayName = "PortalContext");
1243
+ const wr = () => a.useContext(cn), Ns = gt("portal");
1244
+ function Ds(e = {}) {
1245
+ const {
1246
+ ref: t,
1247
+ container: n,
1248
+ componentProps: r = fe,
1249
+ elementProps: o
1250
+ } = e, s = Et(), i = wr(), c = i == null ? void 0 : i.portalNode, [d, u] = a.useState(null), [f, m] = a.useState(null), v = X((g) => {
1251
+ g !== null && m(g);
1252
+ }), h = a.useRef(null);
1253
+ Y(() => {
1254
+ if (n === null) {
1255
+ h.current && (h.current = null, m(null), u(null));
1256
+ return;
1257
+ }
1258
+ if (s == null)
1259
+ return;
1260
+ const g = (n && (Ht(n) ? n : n.current)) ?? c ?? document.body;
1261
+ if (g == null) {
1262
+ h.current && (h.current = null, m(null), u(null));
1263
+ return;
1264
+ }
1265
+ h.current !== g && (h.current = g, m(null), u(g));
1266
+ }, [n, c, s]);
1267
+ const p = Ce("div", r, {
1268
+ ref: [t, v],
1269
+ props: [{
1270
+ id: s,
1271
+ [Ns]: ""
1272
+ }, o]
1273
+ });
1274
+ return {
1275
+ portalNode: f,
1276
+ portalSubtree: d && p ? /* @__PURE__ */ jt.createPortal(p, d) : null
1277
+ };
1278
+ }
1279
+ const Cr = /* @__PURE__ */ a.forwardRef(function(t, n) {
1280
+ const {
1281
+ children: r,
1282
+ container: o,
1283
+ className: s,
1284
+ render: i,
1285
+ renderGuards: c,
1286
+ style: d,
1287
+ ...u
1288
+ } = t, {
1289
+ portalNode: f,
1290
+ portalSubtree: m
1291
+ } = Ds({
1292
+ container: o,
1293
+ ref: n,
1294
+ componentProps: t,
1295
+ elementProps: u
1296
+ }), v = a.useRef(null), h = a.useRef(null), p = a.useRef(null), l = a.useRef(null), [g, y] = a.useState(null), E = a.useRef(!1), _ = g == null ? void 0 : g.modal, C = g == null ? void 0 : g.open, b = typeof c == "boolean" ? c : !!g && !g.modal && g.open && !!f;
1297
+ a.useEffect(() => {
1298
+ if (!f || _)
1299
+ return;
1300
+ function O(w) {
1301
+ f && w.relatedTarget && qe(w) && (w.type === "focusin" ? E.current && (Tn(f), E.current = !1) : (Cs(f), E.current = !0));
1302
+ }
1303
+ return Le(U(f, "focusin", O, !0), U(f, "focusout", O, !0));
1304
+ }, [f, _]), a.useEffect(() => {
1305
+ !f || C !== !1 || (Tn(f), E.current = !1);
1306
+ }, [C, f]);
1307
+ const I = a.useMemo(() => ({
1308
+ beforeOutsideRef: v,
1309
+ afterOutsideRef: h,
1310
+ beforeInsideRef: p,
1311
+ afterInsideRef: l,
1312
+ portalNode: f,
1313
+ setFocusManagerState: y
1314
+ }), [f]);
1315
+ return /* @__PURE__ */ Xe(a.Fragment, {
1316
+ children: [m, /* @__PURE__ */ Xe(cn.Provider, {
1317
+ value: I,
1318
+ children: [b && f && /* @__PURE__ */ q(Je, {
1319
+ "data-type": "outside",
1320
+ ref: v,
1321
+ onFocus: (O) => {
1322
+ var w;
1323
+ if (qe(O, f))
1324
+ (w = p.current) == null || w.focus();
1325
+ else {
1326
+ const M = g ? g.domReference : null, G = vr(M);
1327
+ G == null || G.focus();
1328
+ }
1329
+ }
1330
+ }), b && f && /* @__PURE__ */ q("span", {
1331
+ "aria-owns": f.id,
1332
+ style: Ps
1333
+ }), f && /* @__PURE__ */ jt.createPortal(r, f), b && f && /* @__PURE__ */ q(Je, {
1334
+ "data-type": "outside",
1335
+ ref: h,
1336
+ onFocus: (O) => {
1337
+ var w;
1338
+ if (qe(O, f))
1339
+ (w = l.current) == null || w.focus();
1340
+ else {
1341
+ const M = g ? g.domReference : null, G = Rr(M);
1342
+ G == null || G.focus(), g != null && g.closeOnFocusOut && (g == null || g.onOpenChange(!1, he(tr, O.nativeEvent)));
1343
+ }
1344
+ }
1345
+ })]
1346
+ })]
1347
+ });
1348
+ });
1349
+ process.env.NODE_ENV !== "production" && (Cr.displayName = "FloatingPortal");
1350
+ function xs() {
1351
+ const e = /* @__PURE__ */ new Map();
1352
+ return {
1353
+ emit(t, n) {
1354
+ var r;
1355
+ (r = e.get(t)) == null || r.forEach((o) => o(n));
1356
+ },
1357
+ on(t, n) {
1358
+ e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n);
1359
+ },
1360
+ off(t, n) {
1361
+ var r;
1362
+ (r = e.get(t)) == null || r.delete(n);
1363
+ }
1364
+ };
1365
+ }
1366
+ const Ir = /* @__PURE__ */ a.createContext(null);
1367
+ process.env.NODE_ENV !== "production" && (Ir.displayName = "FloatingNodeContext");
1368
+ const _r = /* @__PURE__ */ a.createContext(null);
1369
+ process.env.NODE_ENV !== "production" && (_r.displayName = "FloatingTreeContext");
1370
+ const Pr = () => {
1371
+ var e;
1372
+ return ((e = a.useContext(Ir)) == null ? void 0 : e.id) || null;
1373
+ }, Nr = (e) => {
1374
+ const t = a.useContext(_r);
1375
+ return e ?? t;
1376
+ };
1377
+ function ye(e) {
1378
+ return e == null ? e : "current" in e ? e.current : e;
1379
+ }
1380
+ function ks(e, t) {
1381
+ const n = Re(Se(e));
1382
+ return e instanceof n.KeyboardEvent ? "keyboard" : e instanceof n.FocusEvent ? t || "keyboard" : "pointerType" in e ? e.pointerType || "keyboard" : "touches" in e ? "touch" : e instanceof n.MouseEvent ? t || (e.detail === 0 ? "keyboard" : "mouse") : "";
1383
+ }
1384
+ const Nn = 20;
1385
+ let Te = [];
1386
+ function un() {
1387
+ Te = Te.filter((e) => {
1388
+ var t;
1389
+ return (t = e.deref()) == null ? void 0 : t.isConnected;
1390
+ });
1391
+ }
1392
+ function As(e) {
1393
+ un(), e && de(e) !== "body" && (Te.push(new WeakRef(e)), Te.length > Nn && (Te = Te.slice(-Nn)));
1394
+ }
1395
+ function Nt() {
1396
+ var e;
1397
+ return un(), (e = Te[Te.length - 1]) == null ? void 0 : e.deref();
1398
+ }
1399
+ function Ms(e) {
1400
+ return e ? sn(e) ? e : yt(e)[0] || e : null;
1401
+ }
1402
+ function Dn(e, t) {
1403
+ var s;
1404
+ if (e.hasAttribute("tabindex") && !e.hasAttribute("data-tabindex") || !t.current.includes("floating") && !((s = e.getAttribute("role")) != null && s.includes("dialog")))
1405
+ return;
1406
+ const r = yr(e).filter((i) => {
1407
+ const c = i.getAttribute("data-tabindex") || "";
1408
+ return sn(i) || i.hasAttribute("data-tabindex") && !c.startsWith("-");
1409
+ }), o = e.getAttribute("tabindex");
1410
+ t.current.includes("floating") || r.length === 0 ? o !== "0" && e.setAttribute("tabindex", "0") : (o !== "-1" || e.hasAttribute("data-tabindex") && e.getAttribute("data-tabindex") !== "-1") && (e.setAttribute("tabindex", "-1"), e.setAttribute("data-tabindex", "-1"));
1411
+ }
1412
+ function Bs(e) {
1413
+ const {
1414
+ context: t,
1415
+ children: n,
1416
+ disabled: r = !1,
1417
+ initialFocus: o = !0,
1418
+ returnFocus: s = !0,
1419
+ restoreFocus: i = !1,
1420
+ modal: c = !0,
1421
+ closeOnFocusOut: d = !0,
1422
+ openInteractionType: u = "",
1423
+ nextFocusableElement: f,
1424
+ previousFocusableElement: m,
1425
+ beforeContentFocusGuardRef: v,
1426
+ externalTree: h,
1427
+ getInsideElements: p
1428
+ } = e, l = "rootStore" in t ? t.rootStore : t, g = l.useState("open"), y = l.useState("domReferenceElement"), E = l.useState("floatingElement"), {
1429
+ events: _,
1430
+ dataRef: C
1431
+ } = l.context, b = X(() => {
1432
+ var N;
1433
+ return (N = C.current.floatingContext) == null ? void 0 : N.nodeId;
1434
+ }), I = o === !1, O = On(y) && I, w = a.useRef(["content"]), M = Tt(o), G = Tt(s), F = Tt(u), B = Nr(h), S = wr(), Q = a.useRef(!1), pe = a.useRef(!1), ge = a.useRef(!1), ke = a.useRef(null), Ae = a.useRef(""), _e = a.useRef(""), Me = a.useRef(null), L = a.useRef(null), be = pt(Me, v, S == null ? void 0 : S.beforeInsideRef), Be = pt(L, S == null ? void 0 : S.afterInsideRef), Ve = Ze(), ve = Ze(), Oe = rn(), ue = S != null, D = Ut(E), re = X((N = D) => N ? yt(N) : []), se = X(() => (p == null ? void 0 : p().filter((N) => N != null)) ?? []);
1435
+ a.useEffect(() => {
1436
+ if (r || !c)
1437
+ return;
1438
+ function N(V) {
1439
+ V.key === "Tab" && K(D, Ne(Z(D))) && re().length === 0 && !O && ls(V);
1440
+ }
1441
+ const H = Z(D);
1442
+ return U(H, "keydown", N);
1443
+ }, [r, y, D, c, w, O, re]), a.useEffect(() => {
1444
+ if (r || !g)
1445
+ return;
1446
+ const N = Z(D);
1447
+ function H() {
1448
+ ge.current = !1;
1449
+ }
1450
+ function V(k) {
1451
+ const x = Se(k), z = se(), P = K(E, x) || K(y, x) || K(S == null ? void 0 : S.portalNode, x) || z.some((ae) => ae === x || K(ae, x));
1452
+ ge.current = !P, _e.current = k.pointerType || "keyboard", x != null && x.closest(`[${Tr}]`) && (pe.current = !0);
1453
+ }
1454
+ function J() {
1455
+ _e.current = "keyboard";
1456
+ }
1457
+ return Le(U(N, "pointerdown", V, !0), U(N, "pointerup", H, !0), U(N, "pointercancel", H, !0), U(N, "keydown", J, !0));
1458
+ }, [r, E, y, D, g, S, se]), a.useEffect(() => {
1459
+ if (r || !d)
1460
+ return;
1461
+ const N = Z(D);
1462
+ function H() {
1463
+ pe.current = !0, ve.start(0, () => {
1464
+ pe.current = !1;
1465
+ });
1466
+ }
1467
+ function V(z) {
1468
+ const P = Se(z);
1469
+ sn(P) && (ke.current = P);
1470
+ }
1471
+ function J(z) {
1472
+ const P = z.relatedTarget, ae = z.currentTarget, W = Se(z);
1473
+ queueMicrotask(() => {
1474
+ const le = b(), R = l.context.triggerElements, T = se(), te = (P == null ? void 0 : P.hasAttribute(gt("focus-guard"))) && [Me.current, L.current, S == null ? void 0 : S.beforeInsideRef.current, S == null ? void 0 : S.afterInsideRef.current, S == null ? void 0 : S.beforeOutsideRef.current, S == null ? void 0 : S.afterOutsideRef.current, ye(m), ye(f)].includes(P), ee = !(K(y, P) || K(E, P) || K(P, E) || K(S == null ? void 0 : S.portalNode, P) || T.some((j) => j === P || K(j, P)) || P != null && R.hasElement(P) || R.hasMatchingElement((j) => K(j, P)) || te || B && (We(B.nodesRef.current, le).find((j) => {
1475
+ var ne, oe;
1476
+ return K((ne = j.context) == null ? void 0 : ne.elements.floating, P) || K((oe = j.context) == null ? void 0 : oe.elements.domReference, P);
1477
+ }) || wn(B.nodesRef.current, le).find((j) => {
1478
+ var ne, oe, tt;
1479
+ return [(ne = j.context) == null ? void 0 : ne.elements.floating, Ut((oe = j.context) == null ? void 0 : oe.elements.floating)].includes(P) || ((tt = j.context) == null ? void 0 : tt.elements.domReference) === P;
1480
+ })));
1481
+ if (ae === y && D && Dn(D, w), i && ae !== y && !dr(W) && Ne(N) === N.body) {
1482
+ if (ce(D) && (D.focus(), i === "popup")) {
1483
+ Oe.request(() => {
1484
+ D.focus();
1485
+ });
1486
+ return;
1487
+ }
1488
+ const j = re(), ne = ke.current, oe = (ne && j.includes(ne) ? ne : null) || j[j.length - 1] || D;
1489
+ ce(oe) && oe.focus();
1490
+ }
1491
+ if (C.current.insideReactTree) {
1492
+ C.current.insideReactTree = !1;
1493
+ return;
1494
+ }
1495
+ (O || !c) && P && ee && !pe.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
1496
+ // For an "untrapped" typeable combobox (input role=combobox with
1497
+ // initialFocus=false), re-opening the popup and tabbing out should still close it even
1498
+ // when the previously focused element (e.g. the next tabbable outside the popup) is
1499
+ // focused again. Otherwise, the popup remains open on the second Tab sequence:
1500
+ // click input -> Tab (closes) -> click input -> Tab.
1501
+ // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element.
1502
+ (O || P !== Nt()) && (Q.current = !0, l.setOpen(!1, he(tr, z)));
1503
+ });
1504
+ }
1505
+ function k() {
1506
+ ge.current || (C.current.insideReactTree = !0, Ve.start(0, () => {
1507
+ C.current.insideReactTree = !1;
1508
+ }));
1509
+ }
1510
+ const x = ce(y) ? y : null;
1511
+ if (!(!E && !x))
1512
+ return Le(x && U(x, "focusout", J), x && U(x, "pointerdown", H), E && U(E, "focusin", V), E && U(E, "focusout", J), E && S && U(E, "focusout", k, !0));
1513
+ }, [r, y, E, D, c, B, S, l, d, i, re, O, b, w, C, Ve, ve, Oe, f, m, se]), a.useEffect(() => {
1514
+ var ae, W, le;
1515
+ if (r || !E || !g)
1516
+ return;
1517
+ const N = Array.from(((ae = S == null ? void 0 : S.portalNode) == null ? void 0 : ae.querySelectorAll(`[${gt("portal")}]`)) || []), V = (le = (W = (B ? wn(B.nodesRef.current, b()) : []).find((R) => {
1518
+ var T;
1519
+ return On(((T = R.context) == null ? void 0 : T.elements.domReference) || null);
1520
+ })) == null ? void 0 : W.context) == null ? void 0 : le.elements.domReference, k = [...[E, ...N, Me.current, L.current, S == null ? void 0 : S.beforeOutsideRef.current, S == null ? void 0 : S.afterOutsideRef.current, ...se()], V, ye(m), ye(f), O ? y : null].filter((R) => R != null), x = Pn(k, {
1521
+ ariaHidden: c || O,
1522
+ mark: !1
1523
+ }), z = [E, ...N].filter((R) => R != null), P = Pn(z);
1524
+ return () => {
1525
+ P(), x();
1526
+ };
1527
+ }, [g, r, y, E, c, w, S, O, B, b, f, m, se]), Y(() => {
1528
+ if (!g || r || !ce(D))
1529
+ return;
1530
+ const N = Z(D), H = Ne(N);
1531
+ queueMicrotask(() => {
1532
+ const V = M.current, J = typeof V == "function" ? V(F.current || "") : V;
1533
+ if (J === void 0 || J === !1 || K(D, H))
1534
+ return;
1535
+ let x = null;
1536
+ const z = () => (x == null && (x = re(D)), x[0] || D);
1537
+ let P;
1538
+ J === !0 || J === null ? P = z() : P = ye(J), P = P || z(), Ct(P, {
1539
+ preventScroll: P === D
1540
+ });
1541
+ });
1542
+ }, [r, g, D, I, re, M, F]), Y(() => {
1543
+ if (r || !D)
1544
+ return;
1545
+ const N = Z(D), H = Ne(N);
1546
+ As(H);
1547
+ function V(k) {
1548
+ if (k.open || (Ae.current = ks(k.nativeEvent, _e.current)), k.reason === Qo && k.nativeEvent.type === "mouseleave" && (Q.current = !0), k.reason === er)
1549
+ if (k.nested)
1550
+ Q.current = !1;
1551
+ else if (ds(k.nativeEvent) || ps(k.nativeEvent))
1552
+ Q.current = !1;
1553
+ else {
1554
+ let x = !1;
1555
+ Z(D).createElement("div").focus({
1556
+ get preventScroll() {
1557
+ return x = !0, !1;
1558
+ }
1559
+ }), x ? Q.current = !1 : Q.current = !0;
1560
+ }
1561
+ }
1562
+ _.on("openchange", V);
1563
+ function J() {
1564
+ const k = G.current;
1565
+ let x = typeof k == "function" ? k(Ae.current) : k;
1566
+ if (x === void 0 || x === !1)
1567
+ return null;
1568
+ if (x === null && (x = !0), typeof x == "boolean") {
1569
+ const P = y || Nt();
1570
+ return P && P.isConnected ? P : null;
1571
+ }
1572
+ const z = y || Nt();
1573
+ return ye(x) || z || null;
1574
+ }
1575
+ return () => {
1576
+ _.off("openchange", V);
1577
+ const k = Ne(N), x = se(), z = K(E, k) || x.some((W) => W === k || K(W, k)) || B && We(B.nodesRef.current, b(), !1).some((W) => {
1578
+ var le;
1579
+ return K((le = W.context) == null ? void 0 : le.elements.floating, k);
1580
+ }), P = G.current, ae = J();
1581
+ queueMicrotask(() => {
1582
+ const W = Ms(ae), le = typeof P != "boolean";
1583
+ P && !Q.current && ce(W) && // If the focus moved somewhere else after mount, avoid returning focus
1584
+ // since it likely entered a different element which should be
1585
+ // respected: https://github.com/floating-ui/floating-ui/issues/2607
1586
+ (!(!le && W !== k && k !== N.body) || z) && W.focus({
1587
+ preventScroll: !0
1588
+ }), Q.current = !1;
1589
+ });
1590
+ };
1591
+ }, [r, E, D, G, C, _, B, y, b, se]), Y(() => {
1592
+ if (!cr || g || !E)
1593
+ return;
1594
+ const N = Ne(Z(E));
1595
+ !ce(N) || !on(N) || K(E, N) && N.blur();
1596
+ }, [g, E]), Y(() => {
1597
+ if (!(r || !S))
1598
+ return S.setFocusManagerState({
1599
+ modal: c,
1600
+ closeOnFocusOut: d,
1601
+ open: g,
1602
+ onOpenChange: l.setOpen,
1603
+ domReference: y
1604
+ }), () => {
1605
+ S.setFocusManagerState(null);
1606
+ };
1607
+ }, [r, S, c, g, l, d, y]), Y(() => {
1608
+ if (!(r || !D))
1609
+ return Dn(D, w), () => {
1610
+ queueMicrotask(un);
1611
+ };
1612
+ }, [r, D, w]);
1613
+ const et = !r && (c ? !O : !0) && (ue || c);
1614
+ return /* @__PURE__ */ Xe(a.Fragment, {
1615
+ children: [et && /* @__PURE__ */ q(Je, {
1616
+ "data-type": "inside",
1617
+ ref: be,
1618
+ onFocus: (N) => {
1619
+ var H;
1620
+ if (c) {
1621
+ const V = re();
1622
+ Ct(V[V.length - 1]);
1623
+ } else if (S != null && S.portalNode)
1624
+ if (Q.current = !1, qe(N, S.portalNode)) {
1625
+ const V = Rr(y);
1626
+ V == null || V.focus();
1627
+ } else
1628
+ (H = ye(m ?? S.beforeOutsideRef)) == null || H.focus();
1629
+ }
1630
+ }), n, et && /* @__PURE__ */ q(Je, {
1631
+ "data-type": "inside",
1632
+ ref: Be,
1633
+ onFocus: (N) => {
1634
+ var H;
1635
+ if (c)
1636
+ Ct(re()[0]);
1637
+ else if (S != null && S.portalNode)
1638
+ if (d && (Q.current = !0), qe(N, S.portalNode)) {
1639
+ const V = vr(y);
1640
+ V == null || V.focus();
1641
+ } else
1642
+ (H = ye(f ?? S.afterOutsideRef)) == null || H.focus();
1643
+ }
1644
+ })]
1645
+ });
1646
+ }
1647
+ function Vs(e, t = {}) {
1648
+ const n = "rootStore" in e ? e.rootStore : e, r = n.context.dataRef, {
1649
+ enabled: o = !0,
1650
+ event: s = "click",
1651
+ toggle: i = !0,
1652
+ ignoreMouse: c = !1,
1653
+ stickIfOpen: d = !0,
1654
+ touchOpenDelay: u = 0,
1655
+ reason: f = Ft
1656
+ } = t, m = a.useRef(void 0), v = rn(), h = Ze(), p = a.useMemo(() => ({
1657
+ onPointerDown(l) {
1658
+ m.current = l.pointerType;
1659
+ },
1660
+ onMouseDown(l) {
1661
+ const g = m.current, y = l.nativeEvent, E = n.select("open");
1662
+ if (l.button !== 0 || s === "click" || Rn(g) && c)
1663
+ return;
1664
+ const _ = r.current.openEvent, C = _ == null ? void 0 : _.type, b = n.select("domReferenceElement") !== l.currentTarget, I = E && b || !(E && i && (!(_ && d) || C === "click" || C === "mousedown")), O = Se(y);
1665
+ if (on(O)) {
1666
+ const M = he(f, y, O);
1667
+ I && g === "touch" && u > 0 ? h.start(u, () => {
1668
+ n.setOpen(!0, M);
1669
+ }) : n.setOpen(I, M);
1670
+ return;
1671
+ }
1672
+ const w = l.currentTarget;
1673
+ v.request(() => {
1674
+ const M = he(f, y, w);
1675
+ I && g === "touch" && u > 0 ? h.start(u, () => {
1676
+ n.setOpen(!0, M);
1677
+ }) : n.setOpen(I, M);
1678
+ });
1679
+ },
1680
+ onClick(l) {
1681
+ if (s === "mousedown-only")
1682
+ return;
1683
+ const g = m.current;
1684
+ if (s === "mousedown" && g) {
1685
+ m.current = void 0;
1686
+ return;
1687
+ }
1688
+ if (Rn(g) && c)
1689
+ return;
1690
+ const y = n.select("open"), E = r.current.openEvent, _ = n.select("domReferenceElement") !== l.currentTarget, C = y && _ || !(y && i && (!(E && d) || ar(E))), b = he(f, l.nativeEvent, l.currentTarget);
1691
+ C && g === "touch" && u > 0 ? h.start(u, () => {
1692
+ n.setOpen(!0, b);
1693
+ }) : n.setOpen(C, b);
1694
+ },
1695
+ onKeyDown() {
1696
+ m.current = void 0;
1697
+ }
1698
+ }), [r, s, c, n, d, i, v, h, u, f]);
1699
+ return a.useMemo(() => o ? {
1700
+ reference: p
1701
+ } : fe, [o, p]);
1702
+ }
1703
+ const Fs = {
1704
+ intentional: "onClick",
1705
+ sloppy: "onPointerDown"
1706
+ };
1707
+ function Ls() {
1708
+ return !1;
1709
+ }
1710
+ function Ws(e) {
1711
+ return {
1712
+ escapeKey: typeof e == "boolean" ? e : (e == null ? void 0 : e.escapeKey) ?? !1,
1713
+ outsidePress: typeof e == "boolean" ? e : (e == null ? void 0 : e.outsidePress) ?? !0
1714
+ };
1715
+ }
1716
+ function Us(e, t = {}) {
1717
+ const n = "rootStore" in e ? e.rootStore : e, r = n.useState("open"), o = n.useState("floatingElement"), {
1718
+ dataRef: s
1719
+ } = n.context, {
1720
+ enabled: i = !0,
1721
+ escapeKey: c = !0,
1722
+ outsidePress: d = !0,
1723
+ outsidePressEvent: u = "sloppy",
1724
+ referencePress: f = Ls,
1725
+ referencePressEvent: m = "sloppy",
1726
+ bubbles: v,
1727
+ externalTree: h
1728
+ } = t, p = Nr(h), l = X(typeof d == "function" ? d : () => !1), g = typeof d == "function" ? l : d, y = g !== !1, E = X(() => u), _ = a.useRef(!1), C = a.useRef(!1), b = a.useRef(!1), {
1729
+ escapeKey: I,
1730
+ outsidePress: O
1731
+ } = Ws(v), w = a.useRef(null), M = Ze(), G = Ze(), F = X(() => {
1732
+ G.clear(), s.current.insideReactTree = !1;
1733
+ }), B = a.useRef(!1), S = a.useRef(""), Q = X(f), pe = X((L) => {
1734
+ var Oe;
1735
+ if (!r || !i || !c || L.key !== "Escape" || B.current)
1736
+ return;
1737
+ const be = (Oe = s.current.floatingContext) == null ? void 0 : Oe.nodeId, Be = p ? We(p.nodesRef.current, be) : [];
1738
+ if (!I && Be.length > 0) {
1739
+ let ue = !0;
1740
+ if (Be.forEach((D) => {
1741
+ var re;
1742
+ (re = D.context) != null && re.open && !D.context.dataRef.current.__escapeKeyBubbles && (ue = !1);
1743
+ }), !ue)
1744
+ return;
1745
+ }
1746
+ const Ve = fs(L) ? L.nativeEvent : L, ve = he(ts, Ve);
1747
+ n.setOpen(!1, ve), !I && !ve.isPropagationAllowed && L.stopPropagation();
1748
+ }), ge = X(() => {
1749
+ s.current.insideReactTree = !0, G.start(0, F);
1750
+ });
1751
+ a.useEffect(() => {
1752
+ if (!r || !i)
1753
+ return;
1754
+ s.current.__escapeKeyBubbles = I, s.current.__outsidePressBubbles = O;
1755
+ const L = new xe(), be = new xe();
1756
+ function Be() {
1757
+ L.clear(), B.current = !0;
1758
+ }
1759
+ function Ve() {
1760
+ L.start(
1761
+ // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
1762
+ // Only apply to WebKit for the test to remain 0ms.
1763
+ lo() ? 5 : 0,
1764
+ () => {
1765
+ B.current = !1;
1766
+ }
1767
+ );
1768
+ }
1769
+ function ve() {
1770
+ b.current = !0, be.start(0, () => {
1771
+ b.current = !1;
1772
+ });
1773
+ }
1774
+ function Oe() {
1775
+ _.current = !1, C.current = !1;
1776
+ }
1777
+ function ue() {
1778
+ const R = S.current, T = R === "pen" || !R ? "mouse" : R, te = E(), ee = typeof te == "function" ? te() : te;
1779
+ return typeof ee == "string" ? ee : ee[T];
1780
+ }
1781
+ function D(R) {
1782
+ const T = ue();
1783
+ return T === "intentional" && R.type !== "click" || T === "sloppy" && R.type === "click";
1784
+ }
1785
+ function re(R) {
1786
+ var ee;
1787
+ const T = (ee = s.current.floatingContext) == null ? void 0 : ee.nodeId, te = p && We(p.nodesRef.current, T).some((j) => {
1788
+ var ne;
1789
+ return me(R, (ne = j.context) == null ? void 0 : ne.elements.floating);
1790
+ });
1791
+ return me(R, n.select("floatingElement")) || me(R, n.select("domReferenceElement")) || te;
1792
+ }
1793
+ function se(R) {
1794
+ var pn;
1795
+ if (D(R)) {
1796
+ F();
1797
+ return;
1798
+ }
1799
+ if (s.current.insideReactTree) {
1800
+ F();
1801
+ return;
1802
+ }
1803
+ const T = Se(R), te = `[${gt("inert")}]`, ee = Ye(T) ? T.getRootNode() : null, j = Array.from((Ue(ee) ? ee : Z(n.select("floatingElement"))).querySelectorAll(te)), ne = n.context.triggerElements;
1804
+ if (T && (ne.hasElement(T) || ne.hasMatchingElement((ie) => K(ie, T))))
1805
+ return;
1806
+ let oe = Ye(T) ? T : null;
1807
+ for (; oe && !Rt(oe); ) {
1808
+ const ie = fo(oe);
1809
+ if (Rt(ie) || !Ye(ie))
1810
+ break;
1811
+ oe = ie;
1812
+ }
1813
+ if (j.length && Ye(T) && !ys(T) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
1814
+ !K(T, n.select("floatingElement")) && // If the target root element contains none of the markers, then the
1815
+ // element was injected after the floating element rendered.
1816
+ j.every((ie) => !K(oe, ie)))
1817
+ return;
1818
+ if (ce(T) && !("touches" in R)) {
1819
+ const ie = Rt(T), Fe = bt(T), Ge = /auto|scroll/, eo = ie || Ge.test(Fe.overflowX), to = ie || Ge.test(Fe.overflowY), no = eo && T.clientWidth > 0 && T.scrollWidth > T.clientWidth, ro = to && T.clientHeight > 0 && T.scrollHeight > T.clientHeight, oo = Fe.direction === "rtl", so = ro && (oo ? R.offsetX <= T.offsetWidth - T.clientWidth : R.offsetX > T.clientWidth), io = no && R.offsetY > T.clientHeight;
1820
+ if (so || io)
1821
+ return;
1822
+ }
1823
+ if (re(R))
1824
+ return;
1825
+ if (ue() === "intentional" && b.current) {
1826
+ be.clear(), b.current = !1;
1827
+ return;
1828
+ }
1829
+ if (typeof g == "function" && !g(R))
1830
+ return;
1831
+ const tt = (pn = s.current.floatingContext) == null ? void 0 : pn.nodeId, dn = p ? We(p.nodesRef.current, tt) : [];
1832
+ if (dn.length > 0) {
1833
+ let ie = !0;
1834
+ if (dn.forEach((Fe) => {
1835
+ var Ge;
1836
+ (Ge = Fe.context) != null && Ge.open && !Fe.context.dataRef.current.__outsidePressBubbles && (ie = !1);
1837
+ }), !ie)
1838
+ return;
1839
+ }
1840
+ n.setOpen(!1, he(er, R)), F();
1841
+ }
1842
+ function et(R) {
1843
+ ue() !== "sloppy" || R.pointerType === "touch" || !n.select("open") || !i || me(R, n.select("floatingElement")) || me(R, n.select("domReferenceElement")) || se(R);
1844
+ }
1845
+ function N(R) {
1846
+ if (ue() !== "sloppy" || !n.select("open") || !i || me(R, n.select("floatingElement")) || me(R, n.select("domReferenceElement")))
1847
+ return;
1848
+ const T = R.touches[0];
1849
+ T && (w.current = {
1850
+ startTime: Date.now(),
1851
+ startX: T.clientX,
1852
+ startY: T.clientY,
1853
+ dismissOnTouchEnd: !1,
1854
+ dismissOnMouseDown: !0
1855
+ }, M.start(1e3, () => {
1856
+ w.current && (w.current.dismissOnTouchEnd = !1, w.current.dismissOnMouseDown = !1);
1857
+ }));
1858
+ }
1859
+ function H(R, T) {
1860
+ const te = Se(R);
1861
+ if (!te)
1862
+ return;
1863
+ const ee = U(te, R.type, () => {
1864
+ T(R), ee();
1865
+ });
1866
+ }
1867
+ function V(R) {
1868
+ S.current = "touch", H(R, N);
1869
+ }
1870
+ function J(R) {
1871
+ M.clear(), R.type === "pointerdown" && (S.current = R.pointerType), !(R.type === "mousedown" && w.current && !w.current.dismissOnMouseDown) && H(R, (T) => {
1872
+ T.type === "pointerdown" ? et(T) : se(T);
1873
+ });
1874
+ }
1875
+ function k(R) {
1876
+ if (!_.current)
1877
+ return;
1878
+ const T = C.current;
1879
+ if (Oe(), ue() === "intentional") {
1880
+ if (R.type === "pointercancel") {
1881
+ T && ve();
1882
+ return;
1883
+ }
1884
+ if (!re(R)) {
1885
+ if (T) {
1886
+ ve();
1887
+ return;
1888
+ }
1889
+ typeof g == "function" && !g(R) || (be.clear(), b.current = !0, F());
1890
+ }
1891
+ }
1892
+ }
1893
+ function x(R) {
1894
+ if (ue() !== "sloppy" || !w.current || me(R, n.select("floatingElement")) || me(R, n.select("domReferenceElement")))
1895
+ return;
1896
+ const T = R.touches[0];
1897
+ if (!T)
1898
+ return;
1899
+ const te = Math.abs(T.clientX - w.current.startX), ee = Math.abs(T.clientY - w.current.startY), j = Math.sqrt(te * te + ee * ee);
1900
+ j > 5 && (w.current.dismissOnTouchEnd = !0), j > 10 && (se(R), M.clear(), w.current = null);
1901
+ }
1902
+ function z(R) {
1903
+ H(R, x);
1904
+ }
1905
+ function P(R) {
1906
+ ue() !== "sloppy" || !w.current || me(R, n.select("floatingElement")) || me(R, n.select("domReferenceElement")) || (w.current.dismissOnTouchEnd && se(R), M.clear(), w.current = null);
1907
+ }
1908
+ function ae(R) {
1909
+ H(R, P);
1910
+ }
1911
+ const W = Z(o), le = Le(c && Le(U(W, "keydown", pe), U(W, "compositionstart", Be), U(W, "compositionend", Ve)), y && Le(U(W, "click", J, !0), U(W, "pointerdown", J, !0), U(W, "pointerup", k, !0), U(W, "pointercancel", k, !0), U(W, "mousedown", J, !0), U(W, "mouseup", k, !0), U(W, "touchstart", V, !0), U(W, "touchmove", z, !0), U(W, "touchend", ae, !0)));
1912
+ return () => {
1913
+ le(), L.clear(), be.clear(), Oe(), b.current = !1;
1914
+ };
1915
+ }, [s, o, c, y, g, r, i, I, O, pe, F, E, p, n, M]), a.useEffect(F, [g, F]);
1916
+ const ke = a.useMemo(() => ({
1917
+ onKeyDown: pe,
1918
+ [Fs[m]]: (L) => {
1919
+ Q() && n.setOpen(!1, he(Ft, L.nativeEvent));
1920
+ },
1921
+ ...m !== "intentional" && {
1922
+ onClick(L) {
1923
+ Q() && n.setOpen(!1, he(Ft, L.nativeEvent));
1924
+ }
1925
+ }
1926
+ }), [pe, n, m, Q]), Ae = X((L) => {
1927
+ if (!r || !i || L.button !== 0)
1928
+ return;
1929
+ const be = Se(L.nativeEvent);
1930
+ K(n.select("floatingElement"), be) && (_.current || (_.current = !0, C.current = !1));
1931
+ }), _e = X((L) => {
1932
+ !r || !i || (L.defaultPrevented || L.nativeEvent.defaultPrevented) && _.current && (C.current = !0);
1933
+ }), Me = a.useMemo(() => ({
1934
+ onKeyDown: pe,
1935
+ // `onMouseDown` may be blocked if `event.preventDefault()` is called in
1936
+ // `onPointerDown`, such as with <NumberField.ScrubArea>.
1937
+ // See https://github.com/mui/base-ui/pull/3379
1938
+ onPointerDown: _e,
1939
+ onMouseDown: _e,
1940
+ onClickCapture: ge,
1941
+ onMouseDownCapture(L) {
1942
+ ge(), Ae(L);
1943
+ },
1944
+ onPointerDownCapture(L) {
1945
+ ge(), Ae(L);
1946
+ },
1947
+ onMouseUpCapture: ge,
1948
+ onTouchEndCapture: ge,
1949
+ onTouchMoveCapture: ge
1950
+ }), [pe, ge, Ae, _e]);
1951
+ return a.useMemo(() => i ? {
1952
+ reference: ke,
1953
+ floating: Me,
1954
+ trigger: ke
1955
+ } : {}, [i, ke, Me]);
1956
+ }
1957
+ const A = (e, t, n, r, o, s, ...i) => {
1958
+ if (i.length > 0)
1959
+ throw new Error(process.env.NODE_ENV !== "production" ? "Unsupported number of selectors" : $e(1));
1960
+ let c;
1961
+ if (e)
1962
+ c = e;
1963
+ else
1964
+ throw (
1965
+ /* minify-error-disabled */
1966
+ new Error("Missing arguments")
1967
+ );
1968
+ return c;
1969
+ };
1970
+ var it = { exports: {} }, Dt = {};
1971
+ /**
1972
+ * @license React
1973
+ * use-sync-external-store-shim.production.js
1974
+ *
1975
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1976
+ *
1977
+ * This source code is licensed under the MIT license found in the
1978
+ * LICENSE file in the root directory of this source tree.
1979
+ */
1980
+ var xn;
1981
+ function $s() {
1982
+ if (xn) return Dt;
1983
+ xn = 1;
1984
+ var e = mt;
1985
+ function t(m, v) {
1986
+ return m === v && (m !== 0 || 1 / m === 1 / v) || m !== m && v !== v;
1987
+ }
1988
+ var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, o = e.useEffect, s = e.useLayoutEffect, i = e.useDebugValue;
1989
+ function c(m, v) {
1990
+ var h = v(), p = r({ inst: { value: h, getSnapshot: v } }), l = p[0].inst, g = p[1];
1991
+ return s(
1992
+ function() {
1993
+ l.value = h, l.getSnapshot = v, d(l) && g({ inst: l });
1994
+ },
1995
+ [m, h, v]
1996
+ ), o(
1997
+ function() {
1998
+ return d(l) && g({ inst: l }), m(function() {
1999
+ d(l) && g({ inst: l });
2000
+ });
2001
+ },
2002
+ [m]
2003
+ ), i(h), h;
2004
+ }
2005
+ function d(m) {
2006
+ var v = m.getSnapshot;
2007
+ m = m.value;
2008
+ try {
2009
+ var h = v();
2010
+ return !n(m, h);
2011
+ } catch {
2012
+ return !0;
2013
+ }
2014
+ }
2015
+ function u(m, v) {
2016
+ return v();
2017
+ }
2018
+ var f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : c;
2019
+ return Dt.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : f, Dt;
2020
+ }
2021
+ var xt = {};
2022
+ /**
2023
+ * @license React
2024
+ * use-sync-external-store-shim.development.js
2025
+ *
2026
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2027
+ *
2028
+ * This source code is licensed under the MIT license found in the
2029
+ * LICENSE file in the root directory of this source tree.
2030
+ */
2031
+ var kn;
2032
+ function Ks() {
2033
+ return kn || (kn = 1, process.env.NODE_ENV !== "production" && (function() {
2034
+ function e(h, p) {
2035
+ return h === p && (h !== 0 || 1 / h === 1 / p) || h !== h && p !== p;
2036
+ }
2037
+ function t(h, p) {
2038
+ f || o.startTransition === void 0 || (f = !0, console.error(
2039
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
2040
+ ));
2041
+ var l = p();
2042
+ if (!m) {
2043
+ var g = p();
2044
+ s(l, g) || (console.error(
2045
+ "The result of getSnapshot should be cached to avoid an infinite loop"
2046
+ ), m = !0);
2047
+ }
2048
+ g = i({
2049
+ inst: { value: l, getSnapshot: p }
2050
+ });
2051
+ var y = g[0].inst, E = g[1];
2052
+ return d(
2053
+ function() {
2054
+ y.value = l, y.getSnapshot = p, n(y) && E({ inst: y });
2055
+ },
2056
+ [h, l, p]
2057
+ ), c(
2058
+ function() {
2059
+ return n(y) && E({ inst: y }), h(function() {
2060
+ n(y) && E({ inst: y });
2061
+ });
2062
+ },
2063
+ [h]
2064
+ ), u(l), l;
2065
+ }
2066
+ function n(h) {
2067
+ var p = h.getSnapshot;
2068
+ h = h.value;
2069
+ try {
2070
+ var l = p();
2071
+ return !s(h, l);
2072
+ } catch {
2073
+ return !0;
2074
+ }
2075
+ }
2076
+ function r(h, p) {
2077
+ return p();
2078
+ }
2079
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
2080
+ var o = mt, s = typeof Object.is == "function" ? Object.is : e, i = o.useState, c = o.useEffect, d = o.useLayoutEffect, u = o.useDebugValue, f = !1, m = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : t;
2081
+ xt.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : v, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
2082
+ })()), xt;
2083
+ }
2084
+ var An;
2085
+ function an() {
2086
+ return An || (An = 1, process.env.NODE_ENV === "production" ? it.exports = $s() : it.exports = Ks()), it.exports;
2087
+ }
2088
+ var Gs = an(), ct = { exports: {} }, kt = {};
2089
+ /**
2090
+ * @license React
2091
+ * use-sync-external-store-shim/with-selector.production.js
2092
+ *
2093
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2094
+ *
2095
+ * This source code is licensed under the MIT license found in the
2096
+ * LICENSE file in the root directory of this source tree.
2097
+ */
2098
+ var Mn;
2099
+ function js() {
2100
+ if (Mn) return kt;
2101
+ Mn = 1;
2102
+ var e = mt, t = an();
2103
+ function n(u, f) {
2104
+ return u === f && (u !== 0 || 1 / u === 1 / f) || u !== u && f !== f;
2105
+ }
2106
+ var r = typeof Object.is == "function" ? Object.is : n, o = t.useSyncExternalStore, s = e.useRef, i = e.useEffect, c = e.useMemo, d = e.useDebugValue;
2107
+ return kt.useSyncExternalStoreWithSelector = function(u, f, m, v, h) {
2108
+ var p = s(null);
2109
+ if (p.current === null) {
2110
+ var l = { hasValue: !1, value: null };
2111
+ p.current = l;
2112
+ } else l = p.current;
2113
+ p = c(
2114
+ function() {
2115
+ function y(I) {
2116
+ if (!E) {
2117
+ if (E = !0, _ = I, I = v(I), h !== void 0 && l.hasValue) {
2118
+ var O = l.value;
2119
+ if (h(O, I))
2120
+ return C = O;
2121
+ }
2122
+ return C = I;
2123
+ }
2124
+ if (O = C, r(_, I)) return O;
2125
+ var w = v(I);
2126
+ return h !== void 0 && h(O, w) ? (_ = I, O) : (_ = I, C = w);
2127
+ }
2128
+ var E = !1, _, C, b = m === void 0 ? null : m;
2129
+ return [
2130
+ function() {
2131
+ return y(f());
2132
+ },
2133
+ b === null ? void 0 : function() {
2134
+ return y(b());
2135
+ }
2136
+ ];
2137
+ },
2138
+ [f, m, v, h]
2139
+ );
2140
+ var g = o(u, p[0], p[1]);
2141
+ return i(
2142
+ function() {
2143
+ l.hasValue = !0, l.value = g;
2144
+ },
2145
+ [g]
2146
+ ), d(g), g;
2147
+ }, kt;
2148
+ }
2149
+ var At = {};
2150
+ /**
2151
+ * @license React
2152
+ * use-sync-external-store-shim/with-selector.development.js
2153
+ *
2154
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2155
+ *
2156
+ * This source code is licensed under the MIT license found in the
2157
+ * LICENSE file in the root directory of this source tree.
2158
+ */
2159
+ var Bn;
2160
+ function Hs() {
2161
+ return Bn || (Bn = 1, process.env.NODE_ENV !== "production" && (function() {
2162
+ function e(u, f) {
2163
+ return u === f && (u !== 0 || 1 / u === 1 / f) || u !== u && f !== f;
2164
+ }
2165
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
2166
+ var t = mt, n = an(), r = typeof Object.is == "function" ? Object.is : e, o = n.useSyncExternalStore, s = t.useRef, i = t.useEffect, c = t.useMemo, d = t.useDebugValue;
2167
+ At.useSyncExternalStoreWithSelector = function(u, f, m, v, h) {
2168
+ var p = s(null);
2169
+ if (p.current === null) {
2170
+ var l = { hasValue: !1, value: null };
2171
+ p.current = l;
2172
+ } else l = p.current;
2173
+ p = c(
2174
+ function() {
2175
+ function y(I) {
2176
+ if (!E) {
2177
+ if (E = !0, _ = I, I = v(I), h !== void 0 && l.hasValue) {
2178
+ var O = l.value;
2179
+ if (h(O, I))
2180
+ return C = O;
2181
+ }
2182
+ return C = I;
2183
+ }
2184
+ if (O = C, r(_, I))
2185
+ return O;
2186
+ var w = v(I);
2187
+ return h !== void 0 && h(O, w) ? (_ = I, O) : (_ = I, C = w);
2188
+ }
2189
+ var E = !1, _, C, b = m === void 0 ? null : m;
2190
+ return [
2191
+ function() {
2192
+ return y(f());
2193
+ },
2194
+ b === null ? void 0 : function() {
2195
+ return y(b());
2196
+ }
2197
+ ];
2198
+ },
2199
+ [f, m, v, h]
2200
+ );
2201
+ var g = o(u, p[0], p[1]);
2202
+ return i(
2203
+ function() {
2204
+ l.hasValue = !0, l.value = g;
2205
+ },
2206
+ [g]
2207
+ ), d(g), g;
2208
+ }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
2209
+ })()), At;
2210
+ }
2211
+ var Vn;
2212
+ function Ys() {
2213
+ return Vn || (Vn = 1, process.env.NODE_ENV === "production" ? ct.exports = js() : ct.exports = Hs()), ct.exports;
2214
+ }
2215
+ var qs = Ys();
2216
+ const Xs = Jt(19), zs = Xs ? Js : Qs;
2217
+ function Dr(e, t, n, r, o) {
2218
+ return zs(e, t, n, r, o);
2219
+ }
2220
+ function Zs(e, t, n, r, o) {
2221
+ const s = a.useCallback(() => t(e.getSnapshot(), n, r, o), [e, t, n, r, o]);
2222
+ return Gs.useSyncExternalStore(e.subscribe, s, s);
2223
+ }
2224
+ function Js(e, t, n, r, o) {
2225
+ return Zs(e, t, n, r, o);
2226
+ }
2227
+ function Qs(e, t, n, r, o) {
2228
+ return qs.useSyncExternalStoreWithSelector(e.subscribe, e.getSnapshot, e.getSnapshot, (s) => t(s, n, r, o));
2229
+ }
2230
+ class ei {
2231
+ /**
2232
+ * The current state of the store.
2233
+ * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
2234
+ * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
2235
+ * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
2236
+ *
2237
+ * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
2238
+ */
2239
+ // Internal state to handle recursive `setState()` calls
2240
+ constructor(t) {
2241
+ /**
2242
+ * Registers a listener that will be called whenever the store's state changes.
2243
+ *
2244
+ * @param fn The listener function to be called on state changes.
2245
+ * @returns A function to unsubscribe the listener.
2246
+ */
2247
+ $(this, "subscribe", (t) => (this.listeners.add(t), () => {
2248
+ this.listeners.delete(t);
2249
+ }));
2250
+ /**
2251
+ * Returns the current state of the store.
2252
+ */
2253
+ $(this, "getSnapshot", () => this.state);
2254
+ this.state = t, this.listeners = /* @__PURE__ */ new Set(), this.updateTick = 0;
2255
+ }
2256
+ /**
2257
+ * Updates the entire store's state and notifies all registered listeners.
2258
+ *
2259
+ * @param newState The new state to set for the store.
2260
+ */
2261
+ setState(t) {
2262
+ if (this.state === t)
2263
+ return;
2264
+ this.state = t, this.updateTick += 1;
2265
+ const n = this.updateTick;
2266
+ for (const r of this.listeners) {
2267
+ if (n !== this.updateTick)
2268
+ return;
2269
+ r(t);
2270
+ }
2271
+ }
2272
+ /**
2273
+ * Merges the provided changes into the current state and notifies listeners if there are changes.
2274
+ *
2275
+ * @param changes An object containing the changes to apply to the current state.
2276
+ */
2277
+ update(t) {
2278
+ for (const n in t)
2279
+ if (!Object.is(this.state[n], t[n])) {
2280
+ this.setState({
2281
+ ...this.state,
2282
+ ...t
2283
+ });
2284
+ return;
2285
+ }
2286
+ }
2287
+ /**
2288
+ * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
2289
+ *
2290
+ * @param key The key in the store's state to update.
2291
+ * @param value The new value to set for the specified key.
2292
+ */
2293
+ set(t, n) {
2294
+ Object.is(this.state[t], n) || this.setState({
2295
+ ...this.state,
2296
+ [t]: n
2297
+ });
2298
+ }
2299
+ /**
2300
+ * Gives the state a new reference and updates all registered listeners.
2301
+ */
2302
+ notifyAll() {
2303
+ const t = {
2304
+ ...this.state
2305
+ };
2306
+ this.setState(t);
2307
+ }
2308
+ use(t, n, r, o) {
2309
+ return Dr(this, t, n, r, o);
2310
+ }
2311
+ }
2312
+ class xr extends ei {
2313
+ /**
2314
+ * Creates a new ReactStore instance.
2315
+ *
2316
+ * @param state Initial state of the store.
2317
+ * @param context Non-reactive context values.
2318
+ * @param selectors Optional selectors for use with `useState`.
2319
+ */
2320
+ constructor(t, n = {}, r) {
2321
+ super(t), this.context = n, this.selectors = r;
2322
+ }
2323
+ /**
2324
+ * Non-reactive values such as refs, callbacks, etc.
2325
+ */
2326
+ /**
2327
+ * Synchronizes a single external value into the store.
2328
+ *
2329
+ * Note that the while the value in `state` is updated immediately, the value returned
2330
+ * by `useState` is updated before the next render (similarly to React's `useState`).
2331
+ */
2332
+ useSyncedValue(t, n) {
2333
+ a.useDebugValue(t), Y(() => {
2334
+ this.state[t] !== n && this.set(t, n);
2335
+ }, [t, n]);
2336
+ }
2337
+ /**
2338
+ * Synchronizes a single external value into the store and
2339
+ * cleans it up (sets to `undefined`) on unmount.
2340
+ *
2341
+ * Note that the while the value in `state` is updated immediately, the value returned
2342
+ * by `useState` is updated before the next render (similarly to React's `useState`).
2343
+ */
2344
+ useSyncedValueWithCleanup(t, n) {
2345
+ const r = this;
2346
+ Y(() => (r.state[t] !== n && r.set(t, n), () => {
2347
+ r.set(t, void 0);
2348
+ }), [r, t, n]);
2349
+ }
2350
+ /**
2351
+ * Synchronizes multiple external values into the store.
2352
+ *
2353
+ * Note that the while the values in `state` are updated immediately, the values returned
2354
+ * by `useState` are updated before the next render (similarly to React's `useState`).
2355
+ */
2356
+ useSyncedValues(t) {
2357
+ const n = this;
2358
+ if (process.env.NODE_ENV !== "production") {
2359
+ a.useDebugValue(t, (i) => Object.keys(i));
2360
+ const o = a.useRef(Object.keys(t)).current, s = Object.keys(t);
2361
+ (o.length !== s.length || o.some((i, c) => i !== s[c])) && console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
2362
+ }
2363
+ const r = Object.values(t);
2364
+ Y(() => {
2365
+ n.update(t);
2366
+ }, [n, ...r]);
2367
+ }
2368
+ /**
2369
+ * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
2370
+ * is non-undefined, the store's state at `key` is updated to match `controlled`.
2371
+ */
2372
+ useControlledProp(t, n) {
2373
+ a.useDebugValue(t);
2374
+ const r = n !== void 0;
2375
+ if (Y(() => {
2376
+ r && !Object.is(this.state[t], n) && super.setState({
2377
+ ...this.state,
2378
+ [t]: n
2379
+ });
2380
+ }, [t, n, r]), process.env.NODE_ENV !== "production") {
2381
+ const o = this.controlledValues ?? (this.controlledValues = /* @__PURE__ */ new Map());
2382
+ o.has(t) || o.set(t, r);
2383
+ const s = o.get(t);
2384
+ s !== void 0 && s !== r && console.error(`A component is changing the ${r ? "" : "un"}controlled state of ${t.toString()} to be ${r ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
2385
+ }
2386
+ }
2387
+ /** Gets the current value from the store using a selector with the provided key.
2388
+ *
2389
+ * @param key Key of the selector to use.
2390
+ */
2391
+ select(t, n, r, o) {
2392
+ const s = this.selectors[t];
2393
+ return s(this.state, n, r, o);
2394
+ }
2395
+ /**
2396
+ * Returns a value from the store's state using a selector function.
2397
+ * Used to subscribe to specific parts of the state.
2398
+ * This methods causes a rerender whenever the selected state changes.
2399
+ *
2400
+ * @param key Key of the selector to use.
2401
+ */
2402
+ useState(t, n, r, o) {
2403
+ return a.useDebugValue(t), Dr(this, this.selectors[t], n, r, o);
2404
+ }
2405
+ /**
2406
+ * Wraps a function with `useStableCallback` to ensure it has a stable reference
2407
+ * and assigns it to the context.
2408
+ *
2409
+ * @param key Key of the event callback. Must be a function in the context.
2410
+ * @param fn Function to assign.
2411
+ */
2412
+ useContextCallback(t, n) {
2413
+ a.useDebugValue(t);
2414
+ const r = X(n ?? Qt);
2415
+ this.context[t] = r;
2416
+ }
2417
+ /**
2418
+ * Returns a stable setter function for a specific key in the store's state.
2419
+ * It's commonly used to pass as a ref callback to React elements.
2420
+ *
2421
+ * @param key Key of the state to set.
2422
+ */
2423
+ useStateSetter(t) {
2424
+ const n = a.useRef(void 0);
2425
+ return n.current === void 0 && (n.current = (r) => {
2426
+ this.set(t, r);
2427
+ }), n.current;
2428
+ }
2429
+ /**
2430
+ * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
2431
+ *
2432
+ * @param key Key of the selector to observe.
2433
+ * @param listener Listener function called when the selector result changes.
2434
+ */
2435
+ observe(t, n) {
2436
+ let r;
2437
+ typeof t == "function" ? r = t : r = this.selectors[t];
2438
+ let o = r(this.state);
2439
+ return n(o, o, this), this.subscribe((s) => {
2440
+ const i = r(s);
2441
+ if (!Object.is(o, i)) {
2442
+ const c = o;
2443
+ o = i, n(i, c, this);
2444
+ }
2445
+ });
2446
+ }
2447
+ }
2448
+ const ti = {
2449
+ open: A((e) => e.open),
2450
+ transitionStatus: A((e) => e.transitionStatus),
2451
+ domReferenceElement: A((e) => e.domReferenceElement),
2452
+ referenceElement: A((e) => e.positionReference ?? e.referenceElement),
2453
+ floatingElement: A((e) => e.floatingElement),
2454
+ floatingId: A((e) => e.floatingId)
2455
+ };
2456
+ class kr extends xr {
2457
+ constructor(n) {
2458
+ const {
2459
+ syncOnly: r,
2460
+ nested: o,
2461
+ onOpenChange: s,
2462
+ triggerElements: i,
2463
+ ...c
2464
+ } = n;
2465
+ super({
2466
+ ...c,
2467
+ positionReference: c.referenceElement,
2468
+ domReferenceElement: c.referenceElement
2469
+ }, {
2470
+ onOpenChange: s,
2471
+ dataRef: {
2472
+ current: {}
2473
+ },
2474
+ events: xs(),
2475
+ nested: o,
2476
+ triggerElements: i
2477
+ }, ti);
2478
+ /**
2479
+ * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
2480
+ */
2481
+ $(this, "syncOpenEvent", (n, r) => {
2482
+ (!n || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
2483
+ // click events to upgrade a hover-open.
2484
+ r != null && ar(r)) && (this.context.dataRef.current.openEvent = n ? r : void 0);
2485
+ });
2486
+ /**
2487
+ * Runs the root-owned side effects for an open state change.
2488
+ */
2489
+ $(this, "dispatchOpenChange", (n, r) => {
2490
+ this.syncOpenEvent(n, r.event);
2491
+ const o = {
2492
+ open: n,
2493
+ reason: r.reason,
2494
+ nativeEvent: r.event,
2495
+ nested: this.context.nested,
2496
+ triggerElement: r.trigger
2497
+ };
2498
+ this.context.events.emit("openchange", o);
2499
+ });
2500
+ /**
2501
+ * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
2502
+ *
2503
+ * @param newOpen The new open state.
2504
+ * @param eventDetails Details about the event that triggered the open state change.
2505
+ */
2506
+ $(this, "setOpen", (n, r) => {
2507
+ var o, s, i, c;
2508
+ if (this.syncOnly) {
2509
+ (s = (o = this.context).onOpenChange) == null || s.call(o, n, r);
2510
+ return;
2511
+ }
2512
+ this.dispatchOpenChange(n, r), (c = (i = this.context).onOpenChange) == null || c.call(i, n, r);
2513
+ });
2514
+ this.syncOnly = r;
2515
+ }
2516
+ }
2517
+ function ni(e, t = !1, n = !1) {
2518
+ const [r, o] = a.useState(e && t ? "idle" : void 0), [s, i] = a.useState(e);
2519
+ return e && !s && (i(!0), o("starting")), !e && s && r !== "ending" && !n && o("ending"), !e && !s && r === "ending" && o(void 0), Y(() => {
2520
+ if (!e && s && r !== "ending" && n) {
2521
+ const c = Ee.request(() => {
2522
+ o("ending");
2523
+ });
2524
+ return () => {
2525
+ Ee.cancel(c);
2526
+ };
2527
+ }
2528
+ }, [e, s, r, n]), Y(() => {
2529
+ if (!e || t)
2530
+ return;
2531
+ const c = Ee.request(() => {
2532
+ o(void 0);
2533
+ });
2534
+ return () => {
2535
+ Ee.cancel(c);
2536
+ };
2537
+ }, [t, e]), Y(() => {
2538
+ if (!e || !t)
2539
+ return;
2540
+ e && s && r !== "idle" && o("starting");
2541
+ const c = Ee.request(() => {
2542
+ o("idle");
2543
+ });
2544
+ return () => {
2545
+ Ee.cancel(c);
2546
+ };
2547
+ }, [t, e, s, r]), {
2548
+ mounted: s,
2549
+ setMounted: i,
2550
+ transitionStatus: r
2551
+ };
2552
+ }
2553
+ function ri(e, t = !1, n = !0) {
2554
+ const r = rn();
2555
+ return X((o, s = null) => {
2556
+ r.cancel();
2557
+ const i = ye(e);
2558
+ if (i == null)
2559
+ return;
2560
+ const c = i, d = () => {
2561
+ jt.flushSync(o);
2562
+ };
2563
+ if (typeof c.getAnimations != "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2564
+ o();
2565
+ return;
2566
+ }
2567
+ function u() {
2568
+ Promise.all(c.getAnimations().map((f) => f.finished)).then(() => {
2569
+ s != null && s.aborted || d();
2570
+ }).catch(() => {
2571
+ if (n) {
2572
+ s != null && s.aborted || d();
2573
+ return;
2574
+ }
2575
+ const f = c.getAnimations();
2576
+ !(s != null && s.aborted) && f.length > 0 && f.some((m) => m.pending || m.playState !== "finished") && u();
2577
+ });
2578
+ }
2579
+ if (t) {
2580
+ const f = ze.startingStyle;
2581
+ if (!c.hasAttribute(f)) {
2582
+ r.request(u);
2583
+ return;
2584
+ }
2585
+ const m = new MutationObserver(() => {
2586
+ c.hasAttribute(f) || (m.disconnect(), u());
2587
+ });
2588
+ m.observe(c, {
2589
+ attributes: !0,
2590
+ attributeFilter: [f]
2591
+ }), s == null || s.addEventListener("abort", () => m.disconnect(), {
2592
+ once: !0
2593
+ });
2594
+ return;
2595
+ }
2596
+ r.request(u);
2597
+ });
2598
+ }
2599
+ function Ar(e) {
2600
+ const {
2601
+ enabled: t = !0,
2602
+ open: n,
2603
+ ref: r,
2604
+ onComplete: o
2605
+ } = e, s = X(o), i = ri(r, n, !1);
2606
+ a.useEffect(() => {
2607
+ if (!t)
2608
+ return;
2609
+ const c = new AbortController();
2610
+ return i(s, c.signal), () => {
2611
+ c.abort();
2612
+ };
2613
+ }, [t, n, s, i]);
2614
+ }
2615
+ function oi(e, t) {
2616
+ const n = a.useRef(null), r = a.useRef(null);
2617
+ return a.useCallback((o) => {
2618
+ if (e !== void 0) {
2619
+ if (n.current !== null) {
2620
+ const s = n.current, i = r.current, c = t.context.triggerElements.getById(s);
2621
+ i && c === i && t.context.triggerElements.delete(s), n.current = null, r.current = null;
2622
+ }
2623
+ o !== null && (n.current = e, r.current = o, t.context.triggerElements.add(e, o));
2624
+ }
2625
+ }, [t, e]);
2626
+ }
2627
+ function si(e, t, n, r) {
2628
+ const o = n.useState("isMountedByTrigger", e), s = oi(e, n), i = X((c) => {
2629
+ if (s(c), !c || !n.select("open"))
2630
+ return;
2631
+ const d = n.select("activeTriggerId");
2632
+ if (d === e) {
2633
+ n.update({
2634
+ activeTriggerElement: c,
2635
+ ...r
2636
+ });
2637
+ return;
2638
+ }
2639
+ d == null && n.update({
2640
+ activeTriggerId: e,
2641
+ activeTriggerElement: c,
2642
+ ...r
2643
+ });
2644
+ });
2645
+ return Y(() => {
2646
+ o && n.update({
2647
+ activeTriggerElement: t.current,
2648
+ ...r
2649
+ });
2650
+ }, [o, n, t, ...Object.values(r)]), {
2651
+ registerTrigger: i,
2652
+ isMountedByThisTrigger: o
2653
+ };
2654
+ }
2655
+ function ii(e) {
2656
+ const t = e.useState("open");
2657
+ Y(() => {
2658
+ if (t && !e.select("activeTriggerId") && e.context.triggerElements.size === 1) {
2659
+ const n = e.context.triggerElements.entries().next();
2660
+ if (!n.done) {
2661
+ const [r, o] = n.value;
2662
+ e.update({
2663
+ activeTriggerId: r,
2664
+ activeTriggerElement: o
2665
+ });
2666
+ }
2667
+ }
2668
+ }, [t, e]);
2669
+ }
2670
+ function ci(e, t, n) {
2671
+ const {
2672
+ mounted: r,
2673
+ setMounted: o,
2674
+ transitionStatus: s
2675
+ } = ni(e);
2676
+ t.useSyncedValues({
2677
+ mounted: r,
2678
+ transitionStatus: s
2679
+ });
2680
+ const i = X(() => {
2681
+ var d, u;
2682
+ o(!1), t.update({
2683
+ activeTriggerId: null,
2684
+ activeTriggerElement: null,
2685
+ mounted: !1
2686
+ }), (u = (d = t.context).onOpenChangeComplete) == null || u.call(d, !1);
2687
+ }), c = t.useState("preventUnmountingOnClose");
2688
+ return Ar({
2689
+ enabled: !c,
2690
+ open: e,
2691
+ ref: t.context.popupRef,
2692
+ onComplete() {
2693
+ e || i();
2694
+ }
2695
+ }), {
2696
+ forceUnmount: i,
2697
+ transitionStatus: s
2698
+ };
2699
+ }
2700
+ class Mr {
2701
+ constructor() {
2702
+ this.elementsSet = /* @__PURE__ */ new Set(), this.idMap = /* @__PURE__ */ new Map();
2703
+ }
2704
+ /**
2705
+ * Adds a trigger element with the given ID.
2706
+ *
2707
+ * Note: The provided element is assumed to not be registered under multiple IDs.
2708
+ */
2709
+ add(t, n) {
2710
+ const r = this.idMap.get(t);
2711
+ if (r !== n && (r !== void 0 && this.elementsSet.delete(r), this.elementsSet.add(n), this.idMap.set(t, n), process.env.NODE_ENV !== "production" && this.elementsSet.size !== this.idMap.size))
2712
+ throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
2713
+ }
2714
+ /**
2715
+ * Removes the trigger element with the given ID.
2716
+ */
2717
+ delete(t) {
2718
+ const n = this.idMap.get(t);
2719
+ n && (this.elementsSet.delete(n), this.idMap.delete(t));
2720
+ }
2721
+ /**
2722
+ * Whether the given element is registered as a trigger.
2723
+ */
2724
+ hasElement(t) {
2725
+ return this.elementsSet.has(t);
2726
+ }
2727
+ /**
2728
+ * Whether there is a registered trigger element matching the given predicate.
2729
+ */
2730
+ hasMatchingElement(t) {
2731
+ for (const n of this.elementsSet)
2732
+ if (t(n))
2733
+ return !0;
2734
+ return !1;
2735
+ }
2736
+ /**
2737
+ * Returns the trigger element associated with the given ID, or undefined if no such element exists.
2738
+ */
2739
+ getById(t) {
2740
+ return this.idMap.get(t);
2741
+ }
2742
+ /**
2743
+ * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
2744
+ */
2745
+ entries() {
2746
+ return this.idMap.entries();
2747
+ }
2748
+ /**
2749
+ * Returns an iterable of all registered trigger elements.
2750
+ */
2751
+ elements() {
2752
+ return this.elementsSet.values();
2753
+ }
2754
+ /**
2755
+ * Returns the number of registered trigger elements.
2756
+ */
2757
+ get size() {
2758
+ return this.idMap.size;
2759
+ }
2760
+ }
2761
+ function ui() {
2762
+ return new kr({
2763
+ open: !1,
2764
+ transitionStatus: void 0,
2765
+ floatingElement: null,
2766
+ referenceElement: null,
2767
+ triggerElements: new Mr(),
2768
+ floatingId: "",
2769
+ syncOnly: !1,
2770
+ nested: !1,
2771
+ onOpenChange: void 0
2772
+ });
2773
+ }
2774
+ function ai() {
2775
+ return {
2776
+ open: !1,
2777
+ openProp: void 0,
2778
+ mounted: !1,
2779
+ transitionStatus: void 0,
2780
+ floatingRootContext: ui(),
2781
+ preventUnmountingOnClose: !1,
2782
+ payload: void 0,
2783
+ activeTriggerId: null,
2784
+ activeTriggerElement: null,
2785
+ triggerIdProp: void 0,
2786
+ popupElement: null,
2787
+ positionerElement: null,
2788
+ activeTriggerProps: fe,
2789
+ inactiveTriggerProps: fe,
2790
+ popupProps: fe
2791
+ };
2792
+ }
2793
+ const ut = A((e) => e.triggerIdProp ?? e.activeTriggerId), li = {
2794
+ open: A((e) => e.openProp ?? e.open),
2795
+ mounted: A((e) => e.mounted),
2796
+ transitionStatus: A((e) => e.transitionStatus),
2797
+ floatingRootContext: A((e) => e.floatingRootContext),
2798
+ preventUnmountingOnClose: A((e) => e.preventUnmountingOnClose),
2799
+ payload: A((e) => e.payload),
2800
+ activeTriggerId: ut,
2801
+ activeTriggerElement: A((e) => e.mounted ? e.activeTriggerElement : null),
2802
+ /**
2803
+ * Whether the trigger with the given ID was used to open the popup.
2804
+ */
2805
+ isTriggerActive: A((e, t) => t !== void 0 && ut(e) === t),
2806
+ /**
2807
+ * Whether the popup is open and was activated by a trigger with the given ID.
2808
+ */
2809
+ isOpenedByTrigger: A((e, t) => t !== void 0 && ut(e) === t && e.open),
2810
+ /**
2811
+ * Whether the popup is mounted and was activated by a trigger with the given ID.
2812
+ */
2813
+ isMountedByTrigger: A((e, t) => t !== void 0 && ut(e) === t && e.mounted),
2814
+ triggerProps: A((e, t) => t ? e.activeTriggerProps : e.inactiveTriggerProps),
2815
+ popupProps: A((e) => e.popupProps),
2816
+ popupElement: A((e) => e.popupElement),
2817
+ positionerElement: A((e) => e.positionerElement)
2818
+ };
2819
+ function fi(e) {
2820
+ const {
2821
+ popupStore: t,
2822
+ treatPopupAsFloatingElement: n = !1,
2823
+ onOpenChange: r
2824
+ } = e, o = Et(), s = Pr() != null, i = t.useState("open"), c = t.useState("activeTriggerElement"), d = t.useState(n ? "popupElement" : "positionerElement"), u = t.context.triggerElements, f = we(() => new kr({
2825
+ open: i,
2826
+ transitionStatus: void 0,
2827
+ referenceElement: c,
2828
+ floatingElement: d,
2829
+ triggerElements: u,
2830
+ onOpenChange: r,
2831
+ floatingId: o,
2832
+ syncOnly: !0,
2833
+ nested: s
2834
+ })).current;
2835
+ return Y(() => {
2836
+ const m = {
2837
+ open: i,
2838
+ floatingId: o,
2839
+ referenceElement: c,
2840
+ floatingElement: d
2841
+ };
2842
+ Ye(c) && (m.domReferenceElement = c), f.state.positionReference === f.state.referenceElement && (m.positionReference = c), f.update(m);
2843
+ }, [i, o, c, d, f]), f.context.onOpenChange = r, f.context.nested = s, f;
2844
+ }
2845
+ function Br(e = []) {
2846
+ const t = e.map((u) => u == null ? void 0 : u.reference), n = e.map((u) => u == null ? void 0 : u.floating), r = e.map((u) => u == null ? void 0 : u.item), o = e.map((u) => u == null ? void 0 : u.trigger), s = a.useCallback(
2847
+ (u) => at(u, e, "reference"),
2848
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2849
+ t
2850
+ ), i = a.useCallback(
2851
+ (u) => at(u, e, "floating"),
2852
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2853
+ n
2854
+ ), c = a.useCallback(
2855
+ (u) => at(u, e, "item"),
2856
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2857
+ r
2858
+ ), d = a.useCallback(
2859
+ (u) => at(u, e, "trigger"),
2860
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2861
+ o
2862
+ );
2863
+ return a.useMemo(() => ({
2864
+ getReferenceProps: s,
2865
+ getFloatingProps: i,
2866
+ getItemProps: c,
2867
+ getTriggerProps: d
2868
+ }), [s, i, c, d]);
2869
+ }
2870
+ function at(e, t, n) {
2871
+ var i;
2872
+ const r = /* @__PURE__ */ new Map(), o = n === "item", s = {};
2873
+ n === "floating" && (s.tabIndex = -1, s[Wt] = "");
2874
+ for (const c in e)
2875
+ o && e && (c === lr || c === fr) || (s[c] = e[c]);
2876
+ for (let c = 0; c < t.length; c += 1) {
2877
+ let d;
2878
+ const u = (i = t[c]) == null ? void 0 : i[n];
2879
+ typeof u == "function" ? d = e ? u(e) : null : d = u, d && Fn(s, d, o, r);
2880
+ }
2881
+ return Fn(s, e, o, r), s;
2882
+ }
2883
+ function Fn(e, t, n, r) {
2884
+ var o;
2885
+ for (const s in t) {
2886
+ const i = t[s];
2887
+ n && (s === lr || s === fr) || (s.startsWith("on") ? (r.has(s) || r.set(s, []), typeof i == "function" && ((o = r.get(s)) == null || o.push(i), e[s] = (...c) => {
2888
+ var d;
2889
+ return (d = r.get(s)) == null ? void 0 : d.map((u) => u(...c)).find((u) => u !== void 0);
2890
+ })) : e[s] = i);
2891
+ }
2892
+ }
2893
+ const di = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
2894
+ function pi(e, t = {}) {
2895
+ const n = "rootStore" in e ? e.rootStore : e, r = n.useState("open"), o = n.useState("floatingId"), s = n.useState("domReferenceElement"), i = n.useState("floatingElement"), {
2896
+ role: c = "dialog"
2897
+ } = t, d = Et(), u = (s == null ? void 0 : s.id) || d, f = a.useMemo(() => {
2898
+ var E;
2899
+ return ((E = Ut(i)) == null ? void 0 : E.id) || o;
2900
+ }, [i, o]), m = di.get(c) ?? c, h = Pr() != null, p = a.useMemo(() => m === "tooltip" || c === "label" ? fe : {
2901
+ "aria-haspopup": m === "alertdialog" ? "dialog" : m,
2902
+ "aria-expanded": "false",
2903
+ ...m === "listbox" && {
2904
+ role: "combobox"
2905
+ },
2906
+ ...m === "menu" && h && {
2907
+ role: "menuitem"
2908
+ },
2909
+ ...c === "select" && {
2910
+ "aria-autocomplete": "none"
2911
+ },
2912
+ ...c === "combobox" && {
2913
+ "aria-autocomplete": "list"
2914
+ }
2915
+ }, [m, h, c]), l = a.useMemo(() => m === "tooltip" || c === "label" ? {
2916
+ [`aria-${c === "label" ? "labelledby" : "describedby"}`]: r ? f : void 0
2917
+ } : {
2918
+ ...p,
2919
+ "aria-expanded": r ? "true" : "false",
2920
+ "aria-controls": r ? f : void 0,
2921
+ ...m === "menu" && {
2922
+ id: u
2923
+ }
2924
+ }, [m, f, r, u, c, p]), g = a.useMemo(() => {
2925
+ const E = {
2926
+ id: f,
2927
+ ...m && {
2928
+ role: m
2929
+ }
2930
+ };
2931
+ return m === "tooltip" || c === "label" ? E : {
2932
+ ...E,
2933
+ ...m === "menu" && {
2934
+ "aria-labelledby": u
2935
+ }
2936
+ };
2937
+ }, [m, f, u, c]), y = a.useCallback(({
2938
+ active: E,
2939
+ selected: _
2940
+ }) => {
2941
+ const C = {
2942
+ role: "option",
2943
+ ...E && {
2944
+ id: `${f}-fui-option`
2945
+ }
2946
+ };
2947
+ switch (c) {
2948
+ case "select":
2949
+ case "combobox":
2950
+ return {
2951
+ ...C,
2952
+ "aria-selected": _
2953
+ };
2954
+ }
2955
+ return {};
2956
+ }, [f, c]);
2957
+ return a.useMemo(() => ({
2958
+ reference: l,
2959
+ floating: g,
2960
+ item: y,
2961
+ trigger: p
2962
+ }), [l, g, p, y]);
2963
+ }
2964
+ let gi = /* @__PURE__ */ (function(e) {
2965
+ return e.nestedDialogs = "--nested-dialogs", e;
2966
+ })({}), mi = (function(e) {
2967
+ return e[e.open = De.open] = "open", e[e.closed = De.closed] = "closed", e[e.startingStyle = De.startingStyle] = "startingStyle", e[e.endingStyle = De.endingStyle] = "endingStyle", e.nested = "data-nested", e.nestedDialogOpen = "data-nested-dialog-open", e;
2968
+ })({});
2969
+ const ln = /* @__PURE__ */ a.createContext(void 0);
2970
+ process.env.NODE_ENV !== "production" && (ln.displayName = "DialogPortalContext");
2971
+ function hi() {
2972
+ const e = a.useContext(ln);
2973
+ if (e === void 0)
2974
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Dialog.Portal> is missing." : $e(26));
2975
+ return e;
2976
+ }
2977
+ const Vr = "ArrowUp", Fr = "ArrowDown", Lr = "ArrowLeft", Wr = "ArrowRight", Ur = "Home", $r = "End", bi = /* @__PURE__ */ new Set([Lr, Wr]), Ei = /* @__PURE__ */ new Set([Vr, Fr]), yi = /* @__PURE__ */ new Set([...bi, ...Ei]);
2978
+ [...yi];
2979
+ const Si = /* @__PURE__ */ new Set([Vr, Fr, Lr, Wr, Ur, $r]), Ri = {
2980
+ ...Jn,
2981
+ ...Zn,
2982
+ nestedDialogOpen(e) {
2983
+ return e ? {
2984
+ [mi.nestedDialogOpen]: ""
2985
+ } : null;
2986
+ }
2987
+ }, Kr = /* @__PURE__ */ a.forwardRef(function(t, n) {
2988
+ const {
2989
+ className: r,
2990
+ finalFocus: o,
2991
+ initialFocus: s,
2992
+ render: i,
2993
+ style: c,
2994
+ ...d
2995
+ } = t, {
2996
+ store: u
2997
+ } = Ie(), f = u.useState("descriptionElementId"), m = u.useState("disablePointerDismissal"), v = u.useState("floatingRootContext"), h = u.useState("popupProps"), p = u.useState("modal"), l = u.useState("mounted"), g = u.useState("nested"), y = u.useState("nestedOpenDialogCount"), E = u.useState("open"), _ = u.useState("openMethod"), C = u.useState("titleElementId"), b = u.useState("transitionStatus"), I = u.useState("role");
2998
+ hi(), Ar({
2999
+ open: E,
3000
+ ref: u.context.popupRef,
3001
+ onComplete() {
3002
+ var B, S;
3003
+ E && ((S = (B = u.context).onOpenChangeComplete) == null || S.call(B, !0));
3004
+ }
3005
+ });
3006
+ function O(B) {
3007
+ return B === "touch" ? u.context.popupRef.current : !0;
3008
+ }
3009
+ const w = s === void 0 ? O : s, M = y > 0, F = Ce("div", t, {
3010
+ state: {
3011
+ open: E,
3012
+ nested: g,
3013
+ transitionStatus: b,
3014
+ nestedDialogOpen: M
3015
+ },
3016
+ props: [h, {
3017
+ "aria-labelledby": C ?? void 0,
3018
+ "aria-describedby": f ?? void 0,
3019
+ role: I,
3020
+ tabIndex: -1,
3021
+ hidden: !l,
3022
+ onKeyDown(B) {
3023
+ Si.has(B.key) && B.stopPropagation();
3024
+ },
3025
+ style: {
3026
+ [gi.nestedDialogs]: y
3027
+ }
3028
+ }, d],
3029
+ ref: [n, u.context.popupRef, u.useStateSetter("popupElement")],
3030
+ stateAttributesMapping: Ri
3031
+ });
3032
+ return /* @__PURE__ */ q(Bs, {
3033
+ context: v,
3034
+ openInteractionType: _,
3035
+ disabled: !l,
3036
+ closeOnFocusOut: !m,
3037
+ initialFocus: w,
3038
+ returnFocus: o,
3039
+ modal: p !== !1,
3040
+ restoreFocus: "popup",
3041
+ children: F
3042
+ });
3043
+ });
3044
+ process.env.NODE_ENV !== "production" && (Kr.displayName = "DialogPopup");
3045
+ function vi(e) {
3046
+ return Jt(19) ? e : e ? "true" : void 0;
3047
+ }
3048
+ const Gr = /* @__PURE__ */ a.forwardRef(function(t, n) {
3049
+ const {
3050
+ cutout: r,
3051
+ ...o
3052
+ } = t;
3053
+ let s;
3054
+ if (r) {
3055
+ const i = r.getBoundingClientRect();
3056
+ s = `polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`;
3057
+ }
3058
+ return /* @__PURE__ */ q("div", {
3059
+ ref: n,
3060
+ role: "presentation",
3061
+ "data-base-ui-inert": "",
3062
+ ...o,
3063
+ style: {
3064
+ position: "fixed",
3065
+ inset: 0,
3066
+ userSelect: "none",
3067
+ WebkitUserSelect: "none",
3068
+ clipPath: s
3069
+ }
3070
+ });
3071
+ });
3072
+ process.env.NODE_ENV !== "production" && (Gr.displayName = "InternalBackdrop");
3073
+ const jr = /* @__PURE__ */ a.forwardRef(function(t, n) {
3074
+ const {
3075
+ keepMounted: r = !1,
3076
+ ...o
3077
+ } = t, {
3078
+ store: s
3079
+ } = Ie(), i = s.useState("mounted"), c = s.useState("modal"), d = s.useState("open");
3080
+ return i || r ? /* @__PURE__ */ q(ln.Provider, {
3081
+ value: r,
3082
+ children: /* @__PURE__ */ Xe(Cr, {
3083
+ ref: n,
3084
+ ...o,
3085
+ children: [i && c === !0 && /* @__PURE__ */ q(Gr, {
3086
+ ref: s.context.internalBackdropRef,
3087
+ inert: vi(!d)
3088
+ }), t.children]
3089
+ })
3090
+ }) : null;
3091
+ });
3092
+ process.env.NODE_ENV !== "production" && (jr.displayName = "DialogPortal");
3093
+ function Oi(e) {
3094
+ const t = a.useRef(!0);
3095
+ t.current && (t.current = !1, e());
3096
+ }
3097
+ let Ln = {}, Wn = {}, Un = "";
3098
+ function Ti(e) {
3099
+ if (typeof document > "u")
3100
+ return !1;
3101
+ const t = Z(e);
3102
+ return Re(t).innerWidth - t.documentElement.clientWidth > 0;
3103
+ }
3104
+ function wi(e) {
3105
+ if (!(typeof CSS < "u" && CSS.supports && CSS.supports("scrollbar-gutter", "stable")) || typeof document > "u")
3106
+ return !1;
3107
+ const n = Z(e), r = n.documentElement, o = n.body, s = Yt(r) ? r : o, i = s.style.overflowY, c = r.style.scrollbarGutter;
3108
+ r.style.scrollbarGutter = "stable", s.style.overflowY = "scroll";
3109
+ const d = s.offsetWidth;
3110
+ s.style.overflowY = "hidden";
3111
+ const u = s.offsetWidth;
3112
+ return s.style.overflowY = i, r.style.scrollbarGutter = c, d === u;
3113
+ }
3114
+ function Ci(e) {
3115
+ const t = Z(e), n = t.documentElement, r = t.body, o = Yt(n) ? n : r, s = {
3116
+ overflowY: o.style.overflowY,
3117
+ overflowX: o.style.overflowX
3118
+ };
3119
+ return Object.assign(o.style, {
3120
+ overflowY: "hidden",
3121
+ overflowX: "hidden"
3122
+ }), () => {
3123
+ Object.assign(o.style, s);
3124
+ };
3125
+ }
3126
+ function Ii(e) {
3127
+ var h;
3128
+ const t = Z(e), n = t.documentElement, r = t.body, o = Re(n);
3129
+ let s = 0, i = 0, c = !1;
3130
+ const d = Ee.create();
3131
+ if (cr && (((h = o.visualViewport) == null ? void 0 : h.scale) ?? 1) !== 1)
3132
+ return () => {
3133
+ };
3134
+ function u() {
3135
+ const p = o.getComputedStyle(n), l = o.getComputedStyle(r), E = (p.scrollbarGutter || "").includes("both-edges") ? "stable both-edges" : "stable";
3136
+ s = n.scrollTop, i = n.scrollLeft, Ln = {
3137
+ scrollbarGutter: n.style.scrollbarGutter,
3138
+ overflowY: n.style.overflowY,
3139
+ overflowX: n.style.overflowX
3140
+ }, Un = n.style.scrollBehavior, Wn = {
3141
+ position: r.style.position,
3142
+ height: r.style.height,
3143
+ width: r.style.width,
3144
+ boxSizing: r.style.boxSizing,
3145
+ overflowY: r.style.overflowY,
3146
+ overflowX: r.style.overflowX,
3147
+ scrollBehavior: r.style.scrollBehavior
3148
+ };
3149
+ const _ = n.scrollHeight > n.clientHeight, C = n.scrollWidth > n.clientWidth, b = p.overflowY === "scroll" || l.overflowY === "scroll", I = p.overflowX === "scroll" || l.overflowX === "scroll", O = Math.max(0, o.innerWidth - r.clientWidth), w = Math.max(0, o.innerHeight - r.clientHeight), M = parseFloat(l.marginTop) + parseFloat(l.marginBottom), G = parseFloat(l.marginLeft) + parseFloat(l.marginRight), F = Yt(n) ? n : r;
3150
+ if (c = wi(e), c) {
3151
+ n.style.scrollbarGutter = E, F.style.overflowY = "hidden", F.style.overflowX = "hidden";
3152
+ return;
3153
+ }
3154
+ Object.assign(n.style, {
3155
+ scrollbarGutter: E,
3156
+ overflowY: "hidden",
3157
+ overflowX: "hidden"
3158
+ }), (_ || b) && (n.style.overflowY = "scroll"), (C || I) && (n.style.overflowX = "scroll"), Object.assign(r.style, {
3159
+ position: "relative",
3160
+ height: M || w ? `calc(100dvh - ${M + w}px)` : "100dvh",
3161
+ width: G || O ? `calc(100vw - ${G + O}px)` : "100vw",
3162
+ boxSizing: "border-box",
3163
+ overflow: "hidden",
3164
+ scrollBehavior: "unset"
3165
+ }), r.scrollTop = s, r.scrollLeft = i, n.setAttribute("data-base-ui-scroll-locked", ""), n.style.scrollBehavior = "unset";
3166
+ }
3167
+ function f() {
3168
+ Object.assign(n.style, Ln), Object.assign(r.style, Wn), c || (n.scrollTop = s, n.scrollLeft = i, n.removeAttribute("data-base-ui-scroll-locked"), n.style.scrollBehavior = Un);
3169
+ }
3170
+ function m() {
3171
+ f(), d.request(u);
3172
+ }
3173
+ u();
3174
+ const v = U(o, "resize", m);
3175
+ return () => {
3176
+ d.cancel(), f(), typeof o.removeEventListener == "function" && v();
3177
+ };
3178
+ }
3179
+ class _i {
3180
+ constructor() {
3181
+ $(this, "lockCount", 0);
3182
+ $(this, "restore", null);
3183
+ $(this, "timeoutLock", xe.create());
3184
+ $(this, "timeoutUnlock", xe.create());
3185
+ $(this, "release", () => {
3186
+ this.lockCount -= 1, this.lockCount === 0 && this.restore && this.timeoutUnlock.start(0, this.unlock);
3187
+ });
3188
+ $(this, "unlock", () => {
3189
+ var t;
3190
+ this.lockCount === 0 && this.restore && ((t = this.restore) == null || t.call(this), this.restore = null);
3191
+ });
3192
+ }
3193
+ acquire(t) {
3194
+ return this.lockCount += 1, this.lockCount === 1 && this.restore === null && this.timeoutLock.start(0, () => this.lock(t)), this.release;
3195
+ }
3196
+ lock(t) {
3197
+ if (this.lockCount === 0 || this.restore !== null)
3198
+ return;
3199
+ const r = Z(t).documentElement, o = Re(r).getComputedStyle(r).overflowY;
3200
+ if (o === "hidden" || o === "clip") {
3201
+ this.restore = Qt;
3202
+ return;
3203
+ }
3204
+ const s = ur || !Ti(t);
3205
+ this.restore = s ? Ci(t) : Ii(t);
3206
+ }
3207
+ }
3208
+ const Pi = new _i();
3209
+ function Ni(e = !0, t = null) {
3210
+ Y(() => {
3211
+ if (e)
3212
+ return Pi.acquire(t);
3213
+ }, [e, t]);
3214
+ }
3215
+ function Di(e) {
3216
+ const t = a.useRef(""), n = a.useCallback((o) => {
3217
+ o.defaultPrevented || (t.current = o.pointerType, e(o, o.pointerType));
3218
+ }, [e]);
3219
+ return {
3220
+ onClick: a.useCallback((o) => {
3221
+ if (o.detail === 0) {
3222
+ e(o, "keyboard");
3223
+ return;
3224
+ }
3225
+ "pointerType" in o ? e(o, o.pointerType) : e(o, t.current), t.current = "";
3226
+ }, [e]),
3227
+ onPointerDown: n
3228
+ };
3229
+ }
3230
+ function xi(e, t) {
3231
+ const n = a.useRef(e), r = X(t);
3232
+ Y(() => {
3233
+ n.current !== e && r(n.current);
3234
+ }, [e, r]), Y(() => {
3235
+ n.current = e;
3236
+ }, [e]);
3237
+ }
3238
+ function ki(e) {
3239
+ const [t, n] = a.useState(null), r = X((i, c) => {
3240
+ e || n(c || // On iOS Safari, the hitslop around touch targets means tapping outside an element's
3241
+ // bounds does not fire `pointerdown` but does fire `mousedown`. The `interactionType`
3242
+ // will be "" in that case.
3243
+ (ur ? "touch" : ""));
3244
+ });
3245
+ xi(e, (i) => {
3246
+ i && !e && n(null);
3247
+ });
3248
+ const {
3249
+ onClick: o,
3250
+ onPointerDown: s
3251
+ } = Di(r);
3252
+ return a.useMemo(() => ({
3253
+ openMethod: t,
3254
+ triggerProps: {
3255
+ onClick: o,
3256
+ onPointerDown: s
3257
+ }
3258
+ }), [t, o, s]);
3259
+ }
3260
+ function Ai(e) {
3261
+ const {
3262
+ store: t,
3263
+ parentContext: n,
3264
+ actionsRef: r,
3265
+ isDrawer: o
3266
+ } = e, s = t.useState("open"), i = t.useState("disablePointerDismissal"), c = t.useState("modal"), d = t.useState("popupElement"), {
3267
+ openMethod: u,
3268
+ triggerProps: f
3269
+ } = ki(s);
3270
+ ii(t);
3271
+ const {
3272
+ forceUnmount: m
3273
+ } = ci(s, t), v = a.useCallback(() => {
3274
+ t.setOpen(!1, he(ns));
3275
+ }, [t]);
3276
+ a.useImperativeHandle(r, () => ({
3277
+ unmount: m,
3278
+ close: v
3279
+ }), [m, v]);
3280
+ const h = fi({
3281
+ popupStore: t,
3282
+ onOpenChange: t.setOpen,
3283
+ treatPopupAsFloatingElement: !0
3284
+ }), [p, l] = a.useState(0), [g, y] = a.useState(0), E = p === 0, _ = pi(h), C = Us(h, {
3285
+ outsidePressEvent() {
3286
+ return t.context.internalBackdropRef.current || t.context.backdropRef.current ? "intentional" : {
3287
+ mouse: c === "trap-focus" ? "sloppy" : "intentional",
3288
+ touch: "sloppy"
3289
+ };
3290
+ },
3291
+ outsidePress(F) {
3292
+ if (!t.context.outsidePressEnabledRef.current || "button" in F && F.button !== 0 || "touches" in F && F.touches.length !== 1)
3293
+ return !1;
3294
+ const B = Se(F);
3295
+ if (E && !i) {
3296
+ const S = B;
3297
+ return c && (t.context.internalBackdropRef.current || t.context.backdropRef.current) ? t.context.internalBackdropRef.current === S || t.context.backdropRef.current === S || K(S, d) && !(S != null && S.hasAttribute("data-base-ui-portal")) : !0;
3298
+ }
3299
+ return !1;
3300
+ },
3301
+ escapeKey: E
3302
+ });
3303
+ Ni(s && c === !0, d);
3304
+ const {
3305
+ getReferenceProps: b,
3306
+ getFloatingProps: I,
3307
+ getTriggerProps: O
3308
+ } = Br([_, C]);
3309
+ t.useContextCallback("onNestedDialogOpen", (F, B) => {
3310
+ l(F), y(B);
3311
+ }), t.useContextCallback("onNestedDialogClose", () => {
3312
+ l(0), y(0);
3313
+ }), a.useEffect(() => (n != null && n.onNestedDialogOpen && s && n.onNestedDialogOpen(p + 1, g + (o ? 1 : 0)), n != null && n.onNestedDialogClose && !s && n.onNestedDialogClose(), () => {
3314
+ n != null && n.onNestedDialogClose && s && n.onNestedDialogClose();
3315
+ }), [o, s, p, g, n]);
3316
+ const w = a.useMemo(() => b(f), [b, f]), M = a.useMemo(() => O(f), [O, f]), G = a.useMemo(() => I(), [I]);
3317
+ t.useSyncedValues({
3318
+ openMethod: u,
3319
+ activeTriggerProps: w,
3320
+ inactiveTriggerProps: M,
3321
+ popupProps: G,
3322
+ floatingRootContext: h,
3323
+ nestedOpenDialogCount: p,
3324
+ nestedOpenDrawerCount: g
3325
+ });
3326
+ }
3327
+ const Mi = {
3328
+ ...li,
3329
+ modal: A((e) => e.modal),
3330
+ nested: A((e) => e.nested),
3331
+ nestedOpenDialogCount: A((e) => e.nestedOpenDialogCount),
3332
+ nestedOpenDrawerCount: A((e) => e.nestedOpenDrawerCount),
3333
+ disablePointerDismissal: A((e) => e.disablePointerDismissal),
3334
+ openMethod: A((e) => e.openMethod),
3335
+ descriptionElementId: A((e) => e.descriptionElementId),
3336
+ titleElementId: A((e) => e.titleElementId),
3337
+ viewportElement: A((e) => e.viewportElement),
3338
+ role: A((e) => e.role)
3339
+ };
3340
+ class fn extends xr {
3341
+ constructor(n) {
3342
+ super(Bi(n), {
3343
+ popupRef: /* @__PURE__ */ a.createRef(),
3344
+ backdropRef: /* @__PURE__ */ a.createRef(),
3345
+ internalBackdropRef: /* @__PURE__ */ a.createRef(),
3346
+ outsidePressEnabledRef: {
3347
+ current: !0
3348
+ },
3349
+ triggerElements: new Mr(),
3350
+ onOpenChange: void 0,
3351
+ onOpenChangeComplete: void 0
3352
+ }, Mi);
3353
+ $(this, "setOpen", (n, r) => {
3354
+ var i, c, d;
3355
+ if (r.preventUnmountOnClose = () => {
3356
+ this.set("preventUnmountingOnClose", !0);
3357
+ }, !n && r.trigger == null && this.state.activeTriggerId != null && (r.trigger = this.state.activeTriggerElement ?? void 0), (c = (i = this.context).onOpenChange) == null || c.call(i, n, r), r.isCanceled)
3358
+ return;
3359
+ this.state.floatingRootContext.dispatchOpenChange(n, r);
3360
+ const o = {
3361
+ open: n
3362
+ }, s = ((d = r.trigger) == null ? void 0 : d.id) ?? null;
3363
+ (s || n) && (o.activeTriggerId = s, o.activeTriggerElement = r.trigger ?? null), this.update(o);
3364
+ });
3365
+ }
3366
+ static useStore(n, r) {
3367
+ const o = we(() => new fn(r)).current;
3368
+ return n ?? o;
3369
+ }
3370
+ }
3371
+ function Bi(e = {}) {
3372
+ return {
3373
+ ...ai(),
3374
+ modal: !0,
3375
+ disablePointerDismissal: !1,
3376
+ popupElement: null,
3377
+ viewportElement: null,
3378
+ descriptionElementId: void 0,
3379
+ titleElementId: void 0,
3380
+ openMethod: null,
3381
+ nested: !1,
3382
+ nestedOpenDialogCount: 0,
3383
+ nestedOpenDrawerCount: 0,
3384
+ role: "dialog",
3385
+ ...e
3386
+ };
3387
+ }
3388
+ const Gt = /* @__PURE__ */ a.createContext(!1);
3389
+ process.env.NODE_ENV !== "production" && (Gt.displayName = "IsDrawerContext");
3390
+ function Vi(e) {
3391
+ const {
3392
+ children: t,
3393
+ open: n,
3394
+ defaultOpen: r = !1,
3395
+ onOpenChange: o,
3396
+ onOpenChangeComplete: s,
3397
+ disablePointerDismissal: i = !1,
3398
+ modal: c = !0,
3399
+ actionsRef: d,
3400
+ handle: u,
3401
+ triggerId: f,
3402
+ defaultTriggerId: m = null
3403
+ } = e, v = Ie(!0), h = a.useContext(Gt), p = !!v, l = fn.useStore(u == null ? void 0 : u.store, {
3404
+ open: r,
3405
+ openProp: n,
3406
+ activeTriggerId: m,
3407
+ triggerIdProp: f,
3408
+ modal: c,
3409
+ disablePointerDismissal: i,
3410
+ nested: p
3411
+ });
3412
+ Oi(() => {
3413
+ n === void 0 && l.state.open === !1 && r === !0 && l.update({
3414
+ open: !0,
3415
+ activeTriggerId: m
3416
+ });
3417
+ }), l.useControlledProp("openProp", n), l.useControlledProp("triggerIdProp", f), l.useSyncedValues({
3418
+ disablePointerDismissal: i,
3419
+ nested: p,
3420
+ modal: c
3421
+ }), l.useContextCallback("onOpenChange", o), l.useContextCallback("onOpenChangeComplete", s);
3422
+ const g = l.useState("payload");
3423
+ Ai({
3424
+ store: l,
3425
+ actionsRef: d,
3426
+ parentContext: v == null ? void 0 : v.store.context,
3427
+ isDrawer: h
3428
+ });
3429
+ const y = a.useMemo(() => ({
3430
+ store: l
3431
+ }), [l]);
3432
+ return /* @__PURE__ */ q(Gt.Provider, {
3433
+ value: !1,
3434
+ children: /* @__PURE__ */ q(tn.Provider, {
3435
+ value: y,
3436
+ children: typeof t == "function" ? t({
3437
+ payload: g
3438
+ }) : t
3439
+ })
3440
+ });
3441
+ }
3442
+ const Hr = /* @__PURE__ */ a.forwardRef(function(t, n) {
3443
+ const {
3444
+ render: r,
3445
+ className: o,
3446
+ style: s,
3447
+ id: i,
3448
+ ...c
3449
+ } = t, {
3450
+ store: d
3451
+ } = Ie(), u = nn(i);
3452
+ return d.useSyncedValueWithCleanup("titleElementId", u), Ce("h2", t, {
3453
+ ref: n,
3454
+ props: [{
3455
+ id: u
3456
+ }, c]
3457
+ });
3458
+ });
3459
+ process.env.NODE_ENV !== "production" && (Hr.displayName = "DialogTitle");
3460
+ const Yr = /* @__PURE__ */ a.forwardRef(function(t, n) {
3461
+ const {
3462
+ render: r,
3463
+ className: o,
3464
+ disabled: s = !1,
3465
+ nativeButton: i = !0,
3466
+ id: c,
3467
+ payload: d,
3468
+ handle: u,
3469
+ style: f,
3470
+ ...m
3471
+ } = t, v = Ie(!0), h = (u == null ? void 0 : u.store) ?? (v == null ? void 0 : v.store);
3472
+ if (!h)
3473
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Dialog.Trigger> must be used within <Dialog.Root> or provided with a handle." : $e(79));
3474
+ const p = nn(c), l = h.useState("floatingRootContext"), g = h.useState("isOpenedByTrigger", p), y = a.useRef(null), {
3475
+ registerTrigger: E,
3476
+ isMountedByThisTrigger: _
3477
+ } = si(p, y, h, {
3478
+ payload: d
3479
+ }), {
3480
+ getButtonProps: C,
3481
+ buttonRef: b
3482
+ } = Zt({
3483
+ disabled: s,
3484
+ native: i
3485
+ }), I = Vs(l, {
3486
+ enabled: l != null
3487
+ }), O = Br([I]), w = {
3488
+ disabled: s,
3489
+ open: g
3490
+ }, M = h.useState("triggerProps", _);
3491
+ return Ce("button", t, {
3492
+ state: w,
3493
+ ref: [b, n, E, y],
3494
+ props: [O.getReferenceProps(), M, {
3495
+ [Tr]: "",
3496
+ id: p
3497
+ }, m, C],
3498
+ stateAttributesMapping: Zo
3499
+ });
3500
+ });
3501
+ process.env.NODE_ENV !== "production" && (Yr.displayName = "DialogTrigger");
3502
+ const Qe = {
3503
+ "Modal-Backdrop": "_Modal-Backdrop_1gbjc_1",
3504
+ "Modal-Panel": "_Modal-Panel_1gbjc_17",
3505
+ "Modal-Title": "_Modal-Title_1gbjc_53",
3506
+ "Modal-Description": "_Modal-Description_1gbjc_62"
3507
+ }, qr = function({ children: t, open: n, onOpenChange: r }) {
3508
+ return /* @__PURE__ */ q(Vi, { open: n, onOpenChange: r, children: t });
3509
+ };
3510
+ qr.displayName = "Modal.Root";
3511
+ const Xr = function({ children: t, render: n = /* @__PURE__ */ q(en, {}) }) {
3512
+ return /* @__PURE__ */ q(Yr, { render: n, children: t });
3513
+ };
3514
+ Xr.displayName = "Modal.Trigger";
3515
+ const zr = a.forwardRef(function({ children: t, className: n, ...r }, o) {
3516
+ return /* @__PURE__ */ Xe(jr, { children: [
3517
+ /* @__PURE__ */ q(Qn, { className: [Qe["Modal-Backdrop"]].filter(Boolean).join(" ") }),
3518
+ /* @__PURE__ */ q(
3519
+ Kr,
3520
+ {
3521
+ ref: o,
3522
+ className: [Qe["Modal-Panel"], n].filter(Boolean).join(" "),
3523
+ ...r,
3524
+ children: t
3525
+ }
3526
+ )
3527
+ ] });
3528
+ });
3529
+ zr.displayName = "Modal.Panel";
3530
+ const Zr = a.forwardRef(function({ children: t, className: n, ...r }, o) {
3531
+ return /* @__PURE__ */ q(
3532
+ Hr,
3533
+ {
3534
+ ref: o,
3535
+ className: [Qe["Modal-Title"], n].filter(Boolean).join(" "),
3536
+ ...r,
3537
+ children: t
3538
+ }
3539
+ );
3540
+ });
3541
+ Zr.displayName = "Modal.Title";
3542
+ const Jr = a.forwardRef(
3543
+ function({ children: t, className: n, ...r }, o) {
3544
+ return /* @__PURE__ */ q(
3545
+ rr,
3546
+ {
3547
+ ref: o,
3548
+ className: [Qe["Modal-Description"], n].filter(Boolean).join(" "),
3549
+ ...r,
3550
+ children: t
3551
+ }
3552
+ );
3553
+ }
3554
+ );
3555
+ Jr.displayName = "Modal.Description";
3556
+ const Qr = a.forwardRef(function({ children: t, className: n, render: r = /* @__PURE__ */ q(en, { variant: "secondary" }), ...o }, s) {
3557
+ return /* @__PURE__ */ q(
3558
+ nr,
3559
+ {
3560
+ ref: s,
3561
+ className: [Qe["Modal-Close"], n].filter(Boolean).join(" "),
3562
+ render: r,
3563
+ ...o,
3564
+ children: t
3565
+ }
3566
+ );
3567
+ });
3568
+ Qr.displayName = "Modal.Close";
3569
+ const Ui = {
3570
+ Root: qr,
3571
+ Trigger: Xr,
3572
+ Panel: zr,
3573
+ Title: Zr,
3574
+ Description: Jr,
3575
+ Close: Qr
3576
+ };
3577
+ export {
3578
+ en as Button,
3579
+ Ui as Modal
3580
+ };