UNPKG

welcome-ui

Version:

Customizable design system with react • styled-components • styled-system and ariakit.

967 lines (966 loc) 25.7 kB
"use client"; import { H as P, P as q, Y as C, f as W, h as K, c as Q, E as L, d as D, g as y, a3 as pe, a9 as ht, x as mt, F as Ue, af as bt, ag as Et, a7 as Se, ah as xt, b as Je, ai as yt, _ as we, D as U, aj as Pt, e as Qe, ak as Be, al as te, am as ve, an as qe, ao as St, ap as wt, a5 as Ft, w as Dt, V as Ze, k as Ot, u as ge, aq as Tt, ar as re, m as At, r as Rt, as as Ct, L as _t } from "./LVA2YJMS-C-kJ1lkr.mjs"; import { g as jt, h as Lt, e as Ht, f as et, a as Fe, i as Nt, D as Mt, j as Vt, k as It } from "./VGCJ63VH-C0UPBY-5.mjs"; import { a as $t, u as B, d as kt } from "./YV4JVR4I-DPC8mMuG.mjs"; import { useRef as H, useEffect as F, isValidElement as Bt, useCallback as le, useContext as De, createContext as Oe, useState as X, useMemo as qt } from "react"; import { j as m } from "./jsx-runtime-B7I4PJ0H.mjs"; import { r as Ee } from "./index-CBBbX29m.mjs"; function Wt(e = {}) { return jt(e); } function Yt(e, t, r) { return Lt(e, t, r); } function Xt(e = {}) { const [t, r] = $t(Wt, e); return Yt(t, r, e); } function tt(e, ...t) { if (!e) return !1; const r = e.getAttribute("data-backdrop"); return r == null ? !1 : r === "" || r === "true" || !t.length ? !0 : t.some((n) => r === n); } var he = /* @__PURE__ */ new WeakMap(); function ne(e, t, r) { he.has(e) || he.set(e, /* @__PURE__ */ new Map()); const n = he.get(e), o = n.get(t); if (!o) return n.set(t, r()), () => { var u; (u = n.get(t)) == null || u(), n.delete(t); }; const s = r(), i = () => { s(), o(), n.delete(t); }; return n.set(t, i), () => { n.get(t) === i && (s(), n.set(t, o)); }; } function Te(e, t, r) { return ne(e, t, () => { const o = e.getAttribute(t); return e.setAttribute(t, r), () => { o == null ? e.removeAttribute(t) : e.setAttribute(t, o); }; }); } function z(e, t, r) { return ne(e, t, () => { const o = t in e, s = e[t]; return e[t] = r, () => { o ? e[t] = s : delete e[t]; }; }); } function xe(e, t) { return e ? ne(e, "style", () => { const n = e.style.cssText; return Object.assign(e.style, t), () => { e.style.cssText = n; }; }) : () => { }; } function zt(e, t, r) { return e ? ne(e, t, () => { const o = e.style.getPropertyValue(t); return e.style.setProperty(t, r), () => { o ? e.style.setProperty(t, o) : e.style.removeProperty(t); }; }) : () => { }; } var Kt = ["SCRIPT", "STYLE"]; function ye(e) { return `__ariakit-dialog-snapshot-${e}`; } function Gt(e, t) { const r = P(t), n = ye(e); if (!r.body[n]) return !0; do { if (t === r.body) return !1; if (t[n]) return !0; if (!t.parentElement) return !1; t = t.parentElement; } while (!0); } function Ut(e, t, r) { return Kt.includes(t.tagName) || !Gt(e, t) ? !1 : !r.some( (n) => n && C(t, n) ); } function Ae(e, t, r, n) { for (let o of t) { if (!(o != null && o.isConnected)) continue; const s = t.some((c) => !c || c === o ? !1 : c.contains(o)), i = P(o), u = o; for (; o.parentElement && o !== i.body; ) { if (n == null || n(o.parentElement, u), !s) for (const c of o.parentElement.children) Ut(e, c, t) && r(c, u); o = o.parentElement; } } } function Jt(e, t) { const { body: r } = P(t[0]), n = []; return Ae(e, t, (s) => { n.push(z(s, ye(e), !0)); }), q(z(r, ye(e), !0), () => { for (const s of n) s(); }); } function J(e = "", t = !1) { return `__ariakit-dialog-${t ? "ancestor" : "outside"}${e ? `-${e}` : ""}`; } function Qt(e, t = "") { return q( z(e, J(), !0), z(e, J(t), !0) ); } function rt(e, t = "") { return q( z(e, J("", !0), !0), z(e, J(t, !0), !0) ); } function Re(e, t) { const r = J(t, !0); if (e[r]) return !0; const n = J(t); do { if (e[n]) return !0; if (!e.parentElement) return !1; e = e.parentElement; } while (!0); } function We(e, t) { const r = [], n = t.map((s) => s == null ? void 0 : s.id); return Ae( e, t, (s) => { tt(s, ...n) || r.unshift(Qt(s, e)); }, (s, i) => { i.hasAttribute("data-dialog") && i.id !== e || r.unshift(rt(s, e)); } ), () => { for (const s of r) s(); }; } var Zt = "div", er = [ "a", "button", "details", "dialog", "div", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "img", "input", "label", "li", "nav", "ol", "p", "section", "select", "span", "summary", "textarea", "ul", "svg" ]; Q( function(t) { return t; } ); var Pe = W( // @ts-expect-error function(t) { return K(Zt, t); } ); Object.assign( Pe, er.reduce((e, t) => (e[t] = W(function(n) { return K(t, n); }), e), {}) ); function tr({ store: e, backdrop: t, alwaysVisible: r, hidden: n }) { const o = H(null), s = Ht({ disclosure: e }), i = B(e, "contentElement"); F(() => { const h = o.current, E = i; h && E && (h.style.zIndex = getComputedStyle(E).zIndex); }, [i]), L(() => { const h = i == null ? void 0 : i.id; if (!h) return; const E = o.current; if (E) return rt(E, h); }, [i]); const u = et({ ref: o, store: s, role: "presentation", "data-backdrop": (i == null ? void 0 : i.id) || "", alwaysVisible: r, hidden: n ?? void 0, style: { position: "fixed", top: 0, right: 0, bottom: 0, left: 0 } }); if (!t) return null; if (Bt(t)) return /* @__PURE__ */ m.jsx(Pe, D(y({}, u), { render: t })); const c = typeof t != "boolean" ? t : "div"; return /* @__PURE__ */ m.jsx(Pe, D(y({}, u), { render: /* @__PURE__ */ m.jsx(c, {}) })); } function rr(e, ...t) { if (!e) return !1; const r = e.getAttribute("data-focus-trap"); return r == null ? !1 : t.length ? r === "" ? !1 : t.some((n) => r === n) : !0; } function nr(e) { return Te(e, "aria-hidden", "true"); } function nt() { return "inert" in HTMLElement.prototype; } function ot(e, t) { if (!("style" in e)) return pe; if (nt()) return z(e, "inert", !0); const n = ht(e, !0).map((o) => { if (t != null && t.some((i) => i && C(i, o))) return pe; const s = ne(o, "focus", () => (o.focus = pe, () => { delete o.focus; })); return q(Te(o, "tabindex", "-1"), s); }); return q( ...n, nr(e), xe(e, { pointerEvents: "none", userSelect: "none", cursor: "default" }) ); } function or(e, t) { const r = [], n = t.map((s) => s == null ? void 0 : s.id); return Ae( e, t, (s) => { tt(s, ...n) || rr(s, ...n) || r.unshift(ot(s, t)); }, (s) => { s.hasAttribute("role") && (t.some((i) => i && C(i, s)) || r.unshift(Te(s, "role", "none"))); } ), () => { for (const s of r) s(); }; } function sr({ attribute: e, contentId: t, contentElement: r, enabled: n }) { const [o, s] = mt(), i = le(() => { if (!n || !r) return !1; const { body: u } = P(r), c = u.getAttribute(e); return !c || c === t; }, [o, n, r, e, t]); return F(() => { if (!n || !t || !r) return; const { body: u } = P(r); if (i()) return u.setAttribute(e, t), () => u.removeAttribute(e); const c = new MutationObserver(() => Ee.flushSync(s)); return c.observe(u, { attributeFilter: [e] }), () => c.disconnect(); }, [o, n, t, r, i, e]), i; } function ur(e) { const t = e.getBoundingClientRect().left; return Math.round(t) + e.scrollLeft ? "paddingLeft" : "paddingRight"; } function ir(e, t, r) { const n = sr({ attribute: "data-dialog-prevent-body-scroll", contentElement: e, contentId: t, enabled: r }); F(() => { if (!n() || !e) return; const o = P(e), s = Ue(e), { documentElement: i, body: u } = o, c = i.style.getPropertyValue("--scrollbar-width"), h = c ? Number.parseInt(c) : s.innerWidth - i.clientWidth, E = () => zt( i, "--scrollbar-width", `${h}px` ), O = ur(i), f = () => xe(u, { overflow: "hidden", [O]: `${h}px` }), M = () => { var I, $; const { scrollX: N, scrollY: G, visualViewport: T } = s, l = (I = T == null ? void 0 : T.offsetLeft) != null ? I : 0, b = ($ = T == null ? void 0 : T.offsetTop) != null ? $ : 0, v = xe(u, { position: "fixed", overflow: "hidden", top: `${-(G - Math.floor(b))}px`, left: `${-(N - Math.floor(l))}px`, right: "0", [O]: `${h}px` }); return () => { v(), process.env.NODE_ENV !== "test" && s.scrollTo({ left: N, top: G, behavior: "instant" }); }; }, V = bt() && !Et(); return q( E(), V ? M() : f() ); }, [n, e]); } var Ye = Oe({}); function ar(e) { const t = De(Ye), [r, n] = X([]), o = le( (u) => { var c; return n((h) => [...h, u]), q((c = t.add) == null ? void 0 : c.call(t, u), () => { n((h) => h.filter((E) => E !== u)); }); }, [t] ); L(() => kt(e, ["open", "contentElement"], (u) => { var c; if (u.open && u.contentElement) return (c = t.add) == null ? void 0 : c.call(t, e); }), [e, t]); const s = qt(() => ({ store: e, add: o }), [e, o]); return { wrapElement: le( (u) => /* @__PURE__ */ m.jsx(Ye.Provider, { value: s, children: u }), [s] ), nestedDialogs: r }; } function cr(e) { const t = H(); return F(() => { if (!e) { t.current = null; return; } return Se("mousedown", (n) => { t.current = n.target; }, !0); }, [e]), t; } function lr(e) { return e.tagName === "HTML" ? !0 : C(P(e).body, e); } function fr(e, t) { if (!e) return !1; if (C(e, t)) return !0; const r = t.getAttribute("aria-activedescendant"); if (r) { const n = P(e).getElementById(r); if (n) return C(e, n); } return !1; } function dr(e, t) { if (!("clientY" in e)) return !1; const r = t.getBoundingClientRect(); return r.width === 0 || r.height === 0 ? !1 : r.top <= e.clientY && e.clientY <= r.top + r.height && r.left <= e.clientX && e.clientX <= r.left + r.width; } function me({ store: e, type: t, listener: r, capture: n, domReady: o }) { const s = Je(r), i = B(e, "open"), u = H(!1); L(() => { if (!i || !o) return; const { contentElement: c } = e.getState(); if (!c) return; const h = () => { u.current = !0; }; return c.addEventListener("focusin", h, !0), () => c.removeEventListener("focusin", h, !0); }, [e, i, o]), F(() => i ? Se(t, (h) => { const { contentElement: E, disclosureElement: O } = e.getState(), f = h.target; !E || !f || !lr(f) || C(E, f) || fr(O, f) || f.hasAttribute("data-focus-trap") || dr(h, E) || u.current && !Re(f, E.id) || yt(f) || s(h); }, n) : void 0, [i, n]); } function be(e, t) { return typeof e == "function" ? e(t) : !!e; } function pr(e, t, r) { const n = B(e, "open"), o = cr(n), s = { store: e, domReady: r, capture: !0 }; me(D(y({}, s), { type: "click", listener: (i) => { const { contentElement: u } = e.getState(), c = o.current; c && xt(c) && Re(c, u == null ? void 0 : u.id) && be(t, i) && e.hide(); } })), me(D(y({}, s), { type: "focusin", listener: (i) => { const { contentElement: u } = e.getState(); u && i.target !== P(u) && be(t, i) && e.hide(); } })), me(D(y({}, s), { type: "contextmenu", listener: (i) => { be(t, i) && e.hide(); } })); } function vr(e, t) { const n = P(e).createElement("button"); return n.type = "button", n.tabIndex = -1, n.textContent = "Dismiss popup", Object.assign(n.style, { border: "0px", clip: "rect(0 0 0 0)", height: "1px", margin: "-1px", overflow: "hidden", padding: "0px", position: "absolute", whiteSpace: "nowrap", width: "1px" }), n.addEventListener("click", t), e.prepend(n), () => { n.removeEventListener("click", t), n.remove(); }; } var gr = "div", st = Q(function(t) { var r = t, { autoFocusOnShow: n = !0 } = r, o = we(r, ["autoFocusOnShow"]); return o = U( o, (s) => /* @__PURE__ */ m.jsx(Pt.Provider, { value: n, children: s }), [n] ), o; }); W(function(t) { const r = st(t); return K(gr, r); }); var Xe = Oe(0); function hr({ level: e, children: t }) { const r = De(Xe), n = Math.max( Math.min(e || r + 1, 6), 1 ); return /* @__PURE__ */ m.jsx(Xe.Provider, { value: n, children: t }); } var mr = "span", ut = Q( function(t) { return t = D(y({}, t), { style: y({ border: 0, clip: "rect(0 0 0 0)", height: "1px", margin: "-1px", overflow: "hidden", padding: 0, position: "absolute", whiteSpace: "nowrap", width: "1px" }, t.style) }), t; } ); W(function(t) { const r = ut(t); return K(mr, r); }); var br = "span", Er = Q( function(t) { return t = D(y({ "data-focus-trap": "", tabIndex: 0, "aria-hidden": !0 }, t), { style: y({ // Prevents unintended scroll jumps. position: "fixed", top: 0, left: 0 }, t.style) }), t = ut(t), t; } ), ce = W(function(t) { const r = Er(t); return K(br, r); }), ze = Oe(null), xr = "div"; function yr(e) { return P(e).body; } function Pr(e, t) { return t ? typeof t == "function" ? t(e) : t : P(e).createElement("div"); } function Sr(e = "id") { return `${e ? `${e}-` : ""}${Math.random().toString(36).slice(2, 8)}`; } function k(e) { queueMicrotask(() => { e == null || e.focus(); }); } var it = Q(function(t) { var r = t, { preserveTabOrder: n, preserveTabOrderAnchor: o, portalElement: s, portalRef: i, portal: u = !0 } = r, c = we(r, [ "preserveTabOrder", "preserveTabOrderAnchor", "portalElement", "portalRef", "portal" ]); const h = H(null), E = Qe(h, c.ref), O = De(ze), [f, M] = X(null), [V, I] = X( null ), $ = H(null), N = H(null), G = H(null), T = H(null); return L(() => { const l = h.current; if (!l || !u) { M(null); return; } const b = Pr(l, s); if (!b) { M(null); return; } const v = b.isConnected; if (v || (O || yr(l)).appendChild(b), b.id || (b.id = l.id ? `portal/${l.id}` : Sr()), M(b), Be(i, b), !v) return () => { b.remove(), Be(i, null); }; }, [u, s, O, i]), L(() => { if (!u || !n || !o) return; const b = P(o).createElement("span"); return b.style.position = "fixed", o.insertAdjacentElement("afterend", b), I(b), () => { b.remove(), I(null); }; }, [u, n, o]), F(() => { if (!f || !n) return; let l = 0; const b = (v) => { if (!te(v)) return; const d = v.type === "focusin"; if (cancelAnimationFrame(l), d) return St(f); l = requestAnimationFrame(() => { wt(f, !0); }); }; return f.addEventListener("focusin", b, !0), f.addEventListener("focusout", b, !0), () => { cancelAnimationFrame(l), f.removeEventListener("focusin", b, !0), f.removeEventListener("focusout", b, !0); }; }, [f, n]), c = U( c, (l) => { if (l = // While the portal node is not in the DOM, we need to pass the // current context to the portal context, otherwise it's going to // reset to the body element on nested portals. /* @__PURE__ */ m.jsx(ze.Provider, { value: f || O, children: l }), !u) return l; if (!f) return /* @__PURE__ */ m.jsx( "span", { ref: E, id: c.id, style: { position: "fixed" }, hidden: !0 } ); l = /* @__PURE__ */ m.jsxs(m.Fragment, { children: [ n && f && /* @__PURE__ */ m.jsx( ce, { ref: N, "data-focus-trap": c.id, className: "__focus-trap-inner-before", onFocus: (v) => { te(v, f) ? k(ve()) : k($.current); } } ), l, n && f && /* @__PURE__ */ m.jsx( ce, { ref: G, "data-focus-trap": c.id, className: "__focus-trap-inner-after", onFocus: (v) => { te(v, f) ? k(qe()) : k(T.current); } } ) ] }), f && (l = Ee.createPortal(l, f)); let b = /* @__PURE__ */ m.jsxs(m.Fragment, { children: [ n && f && /* @__PURE__ */ m.jsx( ce, { ref: $, "data-focus-trap": c.id, className: "__focus-trap-outer-before", onFocus: (v) => { !(v.relatedTarget === T.current) && te(v, f) ? k(N.current) : k(qe()); } } ), n && // We're using position: fixed here so that the browser doesn't // add margin to the element when setting gap on a parent element. /* @__PURE__ */ m.jsx("span", { "aria-owns": f == null ? void 0 : f.id, style: { position: "fixed" } }), n && f && /* @__PURE__ */ m.jsx( ce, { ref: T, "data-focus-trap": c.id, className: "__focus-trap-outer-after", onFocus: (v) => { if (te(v, f)) k(G.current); else { const d = ve(); if (d === N.current) { requestAnimationFrame(() => { var oe; return (oe = ve()) == null ? void 0 : oe.focus(); }); return; } k(d); } } } ) ] }); return V && n && (b = Ee.createPortal( b, V )), /* @__PURE__ */ m.jsxs(m.Fragment, { children: [ b, l ] }); }, [f, O, u, c.id, n, V] ), c = D(y({}, c), { ref: E }), c; }); W(function(t) { const r = it(t); return K(xr, r); }); var wr = "div", Ke = _t(); function Fr(e) { const t = Ze(); return !t || e && C(e, t) ? !1 : !!re(t); } function Ge(e, t = !1) { if (!e) return null; const r = "current" in e ? e.current : e; return r ? t ? re(r) ? r : null : r : null; } var Dr = Q(function(t) { var r = t, { store: n, open: o, onClose: s, focusable: i = !0, modal: u = !0, portal: c = !!u, backdrop: h = !!u, hideOnEscape: E = !0, hideOnInteractOutside: O = !0, getPersistentElements: f, preventBodyScroll: M = !!u, autoFocusOnShow: V = !0, autoFocusOnHide: I = !0, initialFocus: $, finalFocus: N, unmountOnHide: G, unstable_treeSnapshotKey: T } = r, l = we(r, [ "store", "open", "onClose", "focusable", "modal", "portal", "backdrop", "hideOnEscape", "hideOnInteractOutside", "getPersistentElements", "preventBodyScroll", "autoFocusOnShow", "autoFocusOnHide", "initialFocus", "finalFocus", "unmountOnHide", "unstable_treeSnapshotKey" ]); const b = Fe(), v = H(null), d = Xt({ store: n || b, open: o, setOpen(a) { if (a) return; const g = v.current; if (!g) return; const x = new Event("close", { bubbles: !1, cancelable: !0 }); s && g.addEventListener("close", s, { once: !0 }), g.dispatchEvent(x), x.defaultPrevented && d.setOpen(!0); } }), { portalRef: oe, domReady: S } = Ft(c, l.portalRef), at = l.preserveTabOrder, fe = B( d, (a) => at && !u && a.mounted ), _ = Dt(l.id), A = B(d, "open"), R = B(d, "mounted"), Y = B(d, "contentElement"), ct = Nt(R, l.hidden, l.alwaysVisible); ir(Y, _, M && !ct), pr(d, O, S); const { wrapElement: Ce, nestedDialogs: _e } = ar(d); l = U(l, Ce, [Ce]), L(() => { if (!A) return; const a = v.current, g = Ze(a, !0); g && g.tagName !== "BODY" && (a && C(a, g) || d.setDisclosureElement(g)); }, [d, A]), Ke && F(() => { if (!R) return; const { disclosureElement: a } = d.getState(); if (!a || !Ot(a)) return; const g = () => { let x = !1; const p = () => { x = !0; }, w = { capture: !0, once: !0 }; a.addEventListener("focusin", p, w), Rt(a, "mouseup", () => { a.removeEventListener("focusin", p, !0), !x && Ct(a); }); }; return a.addEventListener("mousedown", g), () => { a.removeEventListener("mousedown", g); }; }, [d, R]), F(() => { if (!R || !S) return; const a = v.current; if (!a) return; const g = Ue(a), x = g.visualViewport || g, p = () => { var w, j; const ee = (j = (w = g.visualViewport) == null ? void 0 : w.height) != null ? j : g.innerHeight; a.style.setProperty("--dialog-viewport-height", `${ee}px`); }; return p(), x.addEventListener("resize", p), () => { x.removeEventListener("resize", p); }; }, [R, S]), F(() => { if (!u || !R || !S) return; const a = v.current; if (!(!a || a.querySelector("[data-dialog-dismiss]"))) return vr(a, d.hide); }, [d, u, R, S]), L(() => { if (!nt() || A || !R || !S) return; const a = v.current; if (a) return ot(a); }, [A, R, S]); const se = A && S; L(() => { if (!_ || !se) return; const a = v.current; return Jt(_, [a]); }, [_, se, T]); const je = Je(f); L(() => { if (!_ || !se) return; const { disclosureElement: a } = d.getState(), g = v.current, x = je() || [], p = [ g, ...x, ..._e.map((w) => w.getState().contentElement) ]; return u ? q( We(_, p), or(_, p) ) : We(_, [a, ...p]); }, [ _, d, se, je, _e, u, T ]); const Le = !!V, He = ge(V), [lt, ft] = X(!1); F(() => { if (!A || !Le || !S || !(Y != null && Y.isConnected)) return; const a = Ge($, !0) || // If no initial focus is specified, we try to focus the first element // with the autofocus attribute. If it's an Ariakit component, the // Focusable component will consume the autoFocus prop and add the // data-autofocus attribute to the element instead. Y.querySelector( "[data-autofocus=true],[autofocus]" ) || // We have to fallback to the first focusable element otherwise portaled // dialogs with preserveTabOrder set to true will not receive focus // properly because the elements aren't tabbable until the dialog receives // focus. Tt(Y, !0, c && fe) || // Finally, we fallback to the dialog element itself. Y, g = re(a); He(g ? a : null) && (ft(!0), queueMicrotask(() => { a.focus(), Ke && a.scrollIntoView({ block: "nearest", inline: "nearest" }); })); }, [ A, Le, S, Y, $, c, fe, He ]); const ue = !!I, Ne = ge(I), [ie, Me] = X(!1); F(() => { if (A) return Me(!0), () => Me(!1); }, [A]); const Z = le( (a, g = !0) => { const { disclosureElement: x } = d.getState(); if (Fr(a)) return; let p = Ge(N) || x; if (p != null && p.id) { const j = P(p), ee = `[aria-activedescendant="${p.id}"]`, ae = j.querySelector(ee); ae && (p = ae); } if (p && !re(p)) { const j = p.closest("[data-dialog]"); if (j != null && j.id) { const ee = P(j), ae = `[aria-controls~="${j.id}"]`, ke = ee.querySelector(ae); ke && (p = ke); } } const w = p && re(p); if (!w && g) { requestAnimationFrame(() => Z(a, !1)); return; } Ne(w ? p : null) && w && (p == null || p.focus()); }, [d, N, Ne] ), de = H(!1); L(() => { if (A || !ie || !ue) return; const a = v.current; de.current = !0, Z(a); }, [A, ie, S, ue, Z]), F(() => { if (!ie || !ue) return; const a = v.current; return () => { if (de.current) { de.current = !1; return; } Z(a); }; }, [ie, ue, Z]); const Ve = ge(E); F(() => !S || !R ? void 0 : Se("keydown", (g) => { if (g.key !== "Escape" || g.defaultPrevented) return; const x = v.current; if (!x || Re(x)) return; const p = g.target; if (!p) return; const { disclosureElement: w } = d.getState(); !!(p.tagName === "BODY" || C(x, p) || !w || C(w, p)) && Ve(g) && d.hide(); }, !0), [d, S, R, Ve]), l = U( l, (a) => /* @__PURE__ */ m.jsx(hr, { level: u ? 1 : void 0, children: a }), [u] ); const Ie = l.hidden, $e = l.alwaysVisible; l = U( l, (a) => h ? /* @__PURE__ */ m.jsxs(m.Fragment, { children: [ /* @__PURE__ */ m.jsx( tr, { store: d, backdrop: h, hidden: Ie, alwaysVisible: $e } ), a ] }) : a, [d, h, Ie, $e] ); const [dt, pt] = X(), [vt, gt] = X(); return l = U( l, (a) => /* @__PURE__ */ m.jsx(Mt, { value: d, children: /* @__PURE__ */ m.jsx(Vt.Provider, { value: pt, children: /* @__PURE__ */ m.jsx(It.Provider, { value: gt, children: a }) }) }), [d] ), l = D(y({ id: _, "data-dialog": "", role: "dialog", tabIndex: i ? -1 : void 0, "aria-labelledby": dt, "aria-describedby": vt }, l), { ref: Qe(v, l.ref) }), l = st(D(y({}, l), { autoFocusOnShow: lt })), l = et(y({ store: d }, l)), l = At(D(y({}, l), { focusable: i })), l = it(D(y({ portal: c }, l), { portalRef: oe, preserveTabOrder: fe })), l; }); function Or(e, t = Fe) { return W(function(n) { const o = t(), s = n.store || o; return B( s, (u) => !n.unmountOnHide || (u == null ? void 0 : u.mounted) || !!n.open ) ? /* @__PURE__ */ m.jsx(e, y({}, n)) : null; }); } var Lr = Or( W(function(t) { const r = Dr(t); return K(wr, r); }), Fe ); export { Lr as D, Pe as R, Wt as a, Yt as b, Or as c, Dr as d, Xt as u };