'use client';
import { jsx as s } from "react/jsx-runtime";
import { AuthProvider as g, useAuth as u } from "./auth-provider.js";
import { useAuthGuard as U } from "./auth-provider.js";
import { HeroUIProvider as f } from "@heroui/react";
import n from "react";
import { ThemeProvider as y } from "../theme/provider.js";
import { ConfigProvider as A, useConfig as h } from "./config-provider.js";
import { useComponentOverrides as B, useFeatures as N, useOrganizationConfig as $, withConfig as G } from "./config-provider.js";
import { ThemeProvider as P, useTheme as l } from "./theme-provider.js";
import { ThemeSwitcher as M, useOrganizationBranding as R, useThemeMode as V, useThemeVariables as W, withTheme as D } from "./theme-provider.js";
function F({
  children: r,
  config: e,
  onError: t,
  onSignIn: i,
  onSignOut: o,
  onConfigChange: a,
  onThemeChange: m,
  customTheme: d,
  enableSystem: p,
  enableLocalStorage: c,
  defaultMode: v = "light",
  storageKey: b
}) {
  if (!e.publishableKey)
    throw new Error("publishableKey is required in FrankAuthProvider config");
  if (!e.userType)
    throw new Error("userType is required in FrankAuthProvider config");
  return /* @__PURE__ */ s(f, { children: /* @__PURE__ */ s(A, { config: e, onConfigChange: a, children: /* @__PURE__ */ s(
    y,
    {
      customTheme: d,
      enableSystem: p,
      enableLocalStorage: c,
      defaultMode: v,
      storageKey: b,
      children: /* @__PURE__ */ s(
        P,
        {
          theme: e.theme,
          mode: e.theme?.mode,
          organizationBranding: e.organization?.settings?.branding ? {
            primaryColor: e.organization.settings.branding.primaryColor,
            secondaryColor: e.organization.settings.branding.secondaryColor,
            logo: e.organization.settings.branding.logo,
            customCSS: e.organization.settings.branding.customCSS
          } : void 0,
          onThemeChange: m,
          children: /* @__PURE__ */ s(
            g,
            {
              publishableKey: e.publishableKey,
              secretKey: e.secretKey,
              userType: e.userType,
              apiUrl: e.apiUrl,
              projectId: e.projectId,
              onError: t,
              onSignIn: i,
              onSignOut: o,
              debug: e.debug,
              children: r
            }
          )
        }
      )
    }
  ) }) });
}
function j() {
  const [r, e] = n.useState(!1), [t, i] = n.useState(!1), [o, a] = n.useState(!1);
  return n.useEffect(() => {
    try {
      u(), e(!0);
    } catch {
      e(!1);
    }
    try {
      h(), i(!0);
    } catch {
      i(!1);
    }
    try {
      l(), a(!0);
    } catch {
      a(!1);
    }
  }, []), {
    auth: r,
    config: t,
    theme: o,
    allAvailable: r && t && o
  };
}
function k(r) {
  const e = (t) => {
    const i = u(), o = h(), a = l();
    return /* @__PURE__ */ s(r, { ...t, auth: i, config: o, theme: a });
  };
  return e.displayName = `withProviders(${r.displayName || r.name})`, e;
}
function E() {
  const r = u(), e = h(), t = l();
  return {
    auth: r,
    config: e,
    theme: t
  };
}
export {
  g as AuthProvider,
  A as ConfigProvider,
  F as FrankAuthProvider,
  P as ThemeProvider,
  M as ThemeSwitcher,
  E as useAllProviders,
  u as useAuth,
  U as useAuthGuard,
  B as useComponentOverrides,
  h as useConfig,
  N as useFeatures,
  R as useOrganizationBranding,
  $ as useOrganizationConfig,
  j as useProviderStatus,
  l as useTheme,
  V as useThemeMode,
  W as useThemeVariables,
  G as withConfig,
  k as withProviders,
  D as withTheme
};
//# sourceMappingURL=index.js.map
