import { jsx as w } from "react/jsx-runtime";
import { ChakraProvider as H } from "@chakra-ui/react/styled-system";
import { N as K } from "./nimbus-i18n-provider-C-ceyXCZ.es.js";
import { s as V } from "./index-N3Xxo-X9.es.js";
import * as t from "react";
import { d as W } from "./openLink-m90p5mer.es.js";
var _ = (e, a, r, d, m, l, u, h) => {
  let c = document.documentElement, p = ["light", "dark"];
  function f(n) {
    (Array.isArray(e) ? e : [e]).forEach((y) => {
      let C = y === "class", L = C && l ? m.map((v) => l[v] || v) : m;
      C ? (c.classList.remove(...L), c.classList.add(l && l[n] ? l[n] : n)) : c.setAttribute(y, n);
    }), k(n);
  }
  function k(n) {
    h && p.includes(n) && (c.style.colorScheme = n);
  }
  function i() {
    return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
  }
  if (d) f(d);
  else try {
    let n = localStorage.getItem(a) || r, y = u && n === "system" ? i() : n;
    f(y);
  } catch {
  }
}, M = ["light", "dark"], $ = "(prefers-color-scheme: dark)", j = typeof window > "u", P = /* @__PURE__ */ t.createContext(void 0), z = { setTheme: (e) => {
}, themes: [] }, ee = () => {
  var e;
  return (e = t.useContext(P)) != null ? e : z;
}, J = (e) => t.useContext(P) ? t.createElement(t.Fragment, null, e.children) : t.createElement(D, { ...e }), R = ["light", "dark"], D = ({ forcedTheme: e, disableTransitionOnChange: a = !1, enableSystem: r = !0, enableColorScheme: d = !0, storageKey: m = "theme", themes: l = R, defaultTheme: u = r ? "system" : "light", attribute: h = "data-theme", value: c, children: p, nonce: f, scriptProps: k }) => {
  let [i, n] = t.useState(() => Q(m, u)), [y, C] = t.useState(() => i === "system" ? A() : i), L = c ? Object.values(c) : l, v = t.useCallback((o) => {
    let s = o;
    if (!s) return;
    o === "system" && r && (s = A());
    let g = c ? c[s] : s, x = a ? U(f) : null, S = document.documentElement, N = (b) => {
      b === "class" ? (S.classList.remove(...L), g && S.classList.add(g)) : b.startsWith("data-") && (g ? S.setAttribute(b, g) : S.removeAttribute(b));
    };
    if (Array.isArray(h) ? h.forEach(N) : N(h), d) {
      let b = M.includes(u) ? u : null, O = M.includes(s) ? s : b;
      S.style.colorScheme = O;
    }
    x?.();
  }, [f]), T = t.useCallback((o) => {
    let s = typeof o == "function" ? o(i) : o;
    n(s);
    try {
      localStorage.setItem(m, s);
    } catch {
    }
  }, [i]), E = t.useCallback((o) => {
    let s = A(o);
    C(s), i === "system" && r && !e && v("system");
  }, [i, e]);
  t.useEffect(() => {
    let o = window.matchMedia($);
    return o.addListener(E), E(o), () => o.removeListener(E);
  }, [E]), t.useEffect(() => {
    let o = (s) => {
      s.key === m && (s.newValue ? n(s.newValue) : T(u));
    };
    return window.addEventListener("storage", o), () => window.removeEventListener("storage", o);
  }, [T]), t.useEffect(() => {
    v(e ?? i);
  }, [e, i]);
  let I = t.useMemo(() => ({ theme: i, setTheme: T, forcedTheme: e, resolvedTheme: i === "system" ? y : i, themes: r ? [...l, "system"] : l, systemTheme: r ? y : void 0 }), [i, T, e, y, r, l]);
  return t.createElement(P.Provider, { value: I }, t.createElement(F, { forcedTheme: e, storageKey: m, attribute: h, enableSystem: r, enableColorScheme: d, defaultTheme: u, value: c, themes: l, nonce: f, scriptProps: k }), p);
}, F = /* @__PURE__ */ t.memo(({ forcedTheme: e, storageKey: a, attribute: r, enableSystem: d, enableColorScheme: m, defaultTheme: l, value: u, themes: h, nonce: c, scriptProps: p }) => {
  let f = JSON.stringify([r, a, l, e, h, u, d, m]).slice(1, -1);
  return t.createElement("script", { ...p, suppressHydrationWarning: !0, nonce: typeof window > "u" ? c : "", dangerouslySetInnerHTML: { __html: `(${_.toString()})(${f})` } });
}), Q = (e, a) => {
  if (j) return;
  let r;
  try {
    r = localStorage.getItem(e) || void 0;
  } catch {
  }
  return r || a;
}, U = (e) => {
  let a = document.createElement("style");
  return e && a.setAttribute("nonce", e), a.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")), document.head.appendChild(a), () => {
    window.getComputedStyle(document.body), setTimeout(() => {
      document.head.removeChild(a);
    }, 1);
  };
}, A = (e) => (e || (e = window.matchMedia($)), e.matches ? "dark" : "light");
const q = (e) => /* @__PURE__ */ w(J, { attribute: "class", disableTransitionOnChange: !0, ...e });
function te({
  children: e,
  locale: a,
  router: r,
  ...d
}) {
  const m = /* @__PURE__ */ w(H, { value: V, children: /* @__PURE__ */ w(q, { enableSystem: !1, ...d, children: /* @__PURE__ */ w(K, { locale: a, children: e }) }) });
  return r ? /* @__PURE__ */ w(W, { ...r, children: m }) : m;
}
export {
  te as N,
  ee as z
};
//# sourceMappingURL=nimbus-provider-jT9Us430.es.js.map
