import * as c from "react";
import * as R from "react-dom";
import { jsx as p, Fragment as E } from "react/jsx-runtime";
import { g as O } from "./_commonjsHelpers.BCwc0xb5.js";
function N(e, t) {
  typeof e == "function" ? e(t) : e != null && (e.current = t);
}
function y(...e) {
  return (t) => e.forEach((n) => N(n, t));
}
function k(...e) {
  return c.useCallback(y(...e), e);
}
var b = c.forwardRef((e, t) => {
  const { children: n, ...r } = e, o = c.Children.toArray(n), s = o.find(z);
  if (s) {
    const i = s.props.children, u = o.map((a) => a === s ? c.Children.count(i) > 1 ? c.Children.only(null) : c.isValidElement(i) ? i.props.children : null : a);
    return /* @__PURE__ */ p(S, { ...r, ref: t, children: c.isValidElement(i) ? c.cloneElement(i, void 0, u) : null });
  }
  return /* @__PURE__ */ p(S, { ...r, ref: t, children: n });
});
b.displayName = "Slot";
var S = c.forwardRef((e, t) => {
  const { children: n, ...r } = e;
  if (c.isValidElement(n)) {
    const o = V(n);
    return c.cloneElement(n, {
      ...A(r, n.props),
      // @ts-ignore
      ref: t ? y(t, o) : o
    });
  }
  return c.Children.count(n) > 1 ? c.Children.only(null) : null;
});
S.displayName = "SlotClone";
var j = ({ children: e }) => /* @__PURE__ */ p(E, { children: e });
function z(e) {
  return c.isValidElement(e) && e.type === j;
}
function A(e, t) {
  const n = { ...t };
  for (const r in t) {
    const o = e[r], s = t[r];
    /^on[A-Z]/.test(r) ? o && s ? n[r] = (...u) => {
      s(...u), o(...u);
    } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...s } : r === "className" && (n[r] = [o, s].filter(Boolean).join(" "));
  }
  return { ...e, ...n };
}
function V(e) {
  var r, o;
  let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
  return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
var W = [
  "a",
  "button",
  "div",
  "form",
  "h2",
  "h3",
  "img",
  "input",
  "label",
  "li",
  "nav",
  "ol",
  "p",
  "span",
  "svg",
  "ul"
], $ = W.reduce((e, t) => {
  const n = c.forwardRef((r, o) => {
    const { asChild: s, ...i } = r, u = s ? b : t;
    return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ p(u, { ...i, ref: o });
  });
  return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
}, {});
function Z(e, t) {
  e && R.flushSync(() => e.dispatchEvent(t));
}
var M = "VisuallyHidden", C = c.forwardRef(
  (e, t) => /* @__PURE__ */ p(
    $.span,
    {
      ...e,
      ref: t,
      style: {
        // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
        position: "absolute",
        border: 0,
        width: 1,
        height: 1,
        padding: 0,
        margin: -1,
        overflow: "hidden",
        clip: "rect(0, 0, 0, 0)",
        whiteSpace: "nowrap",
        wordWrap: "normal",
        ...e.style
      }
    }
  )
);
C.displayName = M;
var q = C, x = { exports: {} };
/*!
	Copyright (c) 2018 Jed Watson.
	Licensed under the MIT License (MIT), see
	http://jedwatson.github.io/classnames
*/
(function(e) {
  (function() {
    var t = {}.hasOwnProperty;
    function n() {
      for (var r = [], o = 0; o < arguments.length; o++) {
        var s = arguments[o];
        if (s) {
          var i = typeof s;
          if (i === "string" || i === "number")
            r.push(s);
          else if (Array.isArray(s)) {
            if (s.length) {
              var u = n.apply(null, s);
              u && r.push(u);
            }
          } else if (i === "object") {
            if (s.toString !== Object.prototype.toString && !s.toString.toString().includes("[native code]")) {
              r.push(s.toString());
              continue;
            }
            for (var a in s)
              t.call(s, a) && s[a] && r.push(a);
          }
        }
      }
      return r.join(" ");
    }
    e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
  })();
})(x);
var D = x.exports;
const G = /* @__PURE__ */ O(D);
function H(e, t) {
  const n = c.createContext(t);
  function r(s) {
    const { children: i, ...u } = s, a = c.useMemo(() => u, Object.values(u));
    return /* @__PURE__ */ p(n.Provider, { value: a, children: i });
  }
  function o(s) {
    const i = c.useContext(n);
    if (i) return i;
    if (t !== void 0) return t;
    throw new Error(`\`${s}\` must be used within \`${e}\``);
  }
  return r.displayName = e + "Provider", [r, o];
}
function I(e, t = []) {
  let n = [];
  function r(s, i) {
    const u = c.createContext(i), a = n.length;
    n = [...n, i];
    function l(f) {
      const { scope: d, children: m, ...h } = f, P = (d == null ? void 0 : d[e][a]) || u, g = c.useMemo(() => h, Object.values(h));
      return /* @__PURE__ */ p(P.Provider, { value: g, children: m });
    }
    function v(f, d) {
      const m = (d == null ? void 0 : d[e][a]) || u, h = c.useContext(m);
      if (h) return h;
      if (i !== void 0) return i;
      throw new Error(`\`${f}\` must be used within \`${s}\``);
    }
    return l.displayName = s + "Provider", [l, v];
  }
  const o = () => {
    const s = n.map((i) => c.createContext(i));
    return function(u) {
      const a = (u == null ? void 0 : u[e]) || s;
      return c.useMemo(
        () => ({ [`__scope${e}`]: { ...u, [e]: a } }),
        [u, a]
      );
    };
  };
  return o.scopeName = e, [r, _(o, ...t)];
}
function _(...e) {
  const t = e[0];
  if (e.length === 1) return t;
  const n = () => {
    const r = e.map((o) => ({
      useScope: o(),
      scopeName: o.scopeName
    }));
    return function(s) {
      const i = r.reduce((u, { useScope: a, scopeName: l }) => {
        const f = a(s)[`__scope${l}`];
        return { ...u, ...f };
      }, {});
      return c.useMemo(() => ({ [`__scope${t.scopeName}`]: i }), [i]);
    };
  };
  return n.scopeName = t.scopeName, n;
}
function J(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
  return function(o) {
    if (e == null || e(o), n === !1 || !o.defaultPrevented)
      return t == null ? void 0 : t(o);
  };
}
var B = globalThis != null && globalThis.document ? c.useLayoutEffect : () => {
};
function w(e) {
  const t = c.useRef(e);
  return c.useEffect(() => {
    t.current = e;
  }), c.useMemo(() => (...n) => {
    var r;
    return (r = t.current) == null ? void 0 : r.call(t, ...n);
  }, []);
}
function K({
  prop: e,
  defaultProp: t,
  onChange: n = () => {
  }
}) {
  const [r, o] = F({ defaultProp: t, onChange: n }), s = e !== void 0, i = s ? e : r, u = w(n), a = c.useCallback(
    (l) => {
      if (s) {
        const f = typeof l == "function" ? l(e) : l;
        f !== e && u(f);
      } else
        o(l);
    },
    [s, e, o, u]
  );
  return [i, a];
}
function F({
  defaultProp: e,
  onChange: t
}) {
  const n = c.useState(e), [r] = n, o = c.useRef(r), s = w(t);
  return c.useEffect(() => {
    o.current !== r && (s(r), o.current = r);
  }, [r, o, s]), n;
}
function Q(e) {
  const [t, n] = c.useState(void 0);
  return B(() => {
    if (e) {
      n({ width: e.offsetWidth, height: e.offsetHeight });
      const r = new ResizeObserver((o) => {
        if (!Array.isArray(o) || !o.length)
          return;
        const s = o[0];
        let i, u;
        if ("borderBoxSize" in s) {
          const a = s.borderBoxSize, l = Array.isArray(a) ? a[0] : a;
          i = l.inlineSize, u = l.blockSize;
        } else
          i = e.offsetWidth, u = e.offsetHeight;
        n({ width: i, height: u });
      });
      return r.observe(e, { box: "border-box" }), () => r.unobserve(e);
    } else
      n(void 0);
  }, [e]), t;
}
export {
  $ as P,
  q as R,
  b as S,
  C as V,
  K as a,
  J as b,
  I as c,
  Q as d,
  H as e,
  y as f,
  w as g,
  j as h,
  B as i,
  Z as j,
  k as u,
  G as y
};
//# sourceMappingURL=index.DaRbhbpm.js.map
