"use client";
import { j as l } from "./index.esm38.js";
import { useMemo as a, createContext as x, useContext as g } from "react";
import { themeToCssVars as c } from "./index.esm4.js";
import { mergeTheme as j } from "./index.esm3.js";
import v from "./index.esm39.js";
import { lightTheme as s } from "./index.esm6.js";
import { darkTheme as n } from "./index.esm7.js";
const u = x(void 0);
function i(e) {
  return Object.entries(e).map(([m, r]) => `${m}:${r}`).join(";");
}
const y = i(c(s)), k = i(c(n)), b = ({ theme: e = "light", children: m }) => {
  const { fullTheme: r, themeName: d, themeStyles: h } = a(() => {
    let t, o;
    e === "light" ? (t = s, o = "light") : e === "dark" ? (t = n, o = "dark") : e && typeof e == "object" && "palette" in e && e.palette && "primary" in e.palette ? (t = e, o = e === s ? "light" : e === n ? "dark" : "custom") : (t = j(s, e), o = "custom");
    const f = o === "custom" ? `[data-color-scheme="custom"]{${i(c(t))}}` : "", T = `[data-color-scheme="light"]{${y}}[data-color-scheme="dark"]{${k}}${f}`;
    return { fullTheme: t, themeName: o, themeStyles: T };
  }, [e]), p = a(() => ({ theme: r }), [r]);
  return /* @__PURE__ */ l.jsxs("div", { "data-color-scheme": d, className: v.wrapper, children: [
    /* @__PURE__ */ l.jsx("style", { dangerouslySetInnerHTML: { __html: h } }),
    /* @__PURE__ */ l.jsx(u.Provider, { value: p, children: m })
  ] });
};
function A() {
  const e = g(u);
  if (e === void 0)
    throw new Error("useThemeContext must be used within a ThemeProvider");
  return e;
}
export {
  b as ThemeProvider,
  A as useThemeContext
};
//# sourceMappingURL=index.esm36.js.map
