'use client';
import { jsx as s } from "react/jsx-runtime";
import { AuthProvider as m, useAuth as u } from "./auth-provider.js";
import { useAuthGuard as x } from "./auth-provider.js";
import { HeroUIProvider as p } from "@heroui/react";
import n from "react";
import { ConfigProvider as c, useConfig as l } from "./config-provider.js";
import { useComponentOverrides as j, useFeatures as k, useOrganizationConfig as E, withConfig as I } from "./config-provider.js";
import { ThemeProvider as b, useTheme as h } from "./theme-provider.js";
import { ThemeSwitcher as U, useOrganizationBranding as q, useThemeMode as B, useThemeVariables as N, withTheme as G } from "./theme-provider.js";
function C({
  children: r,
  config: e,
  onError: t,
  onSignIn: i,
  onSignOut: o,
  onConfigChange: a,
  onThemeChange: d
}) {
  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(p, { children: /* @__PURE__ */ s(
    c,
    {
      config: e,
      onConfigChange: a,
      children: /* @__PURE__ */ s(
        b,
        {
          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: d,
          children: /* @__PURE__ */ s(
            m,
            {
              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 T() {
  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 {
      l(), i(!0);
    } catch {
      i(!1);
    }
    try {
      h(), a(!0);
    } catch {
      a(!1);
    }
  }, []), {
    auth: r,
    config: t,
    theme: o,
    allAvailable: r && t && o
  };
}
function w(r) {
  const e = (t) => {
    const i = u(), o = l(), a = h();
    return /* @__PURE__ */ s(
      r,
      {
        ...t,
        auth: i,
        config: o,
        theme: a
      }
    );
  };
  return e.displayName = `withProviders(${r.displayName || r.name})`, e;
}
function S() {
  const r = u(), e = l(), t = h();
  return {
    auth: r,
    config: e,
    theme: t
  };
}
export {
  m as AuthProvider,
  c as ConfigProvider,
  C as FrankAuthProvider,
  b as ThemeProvider,
  U as ThemeSwitcher,
  S as useAllProviders,
  u as useAuth,
  x as useAuthGuard,
  j as useComponentOverrides,
  l as useConfig,
  k as useFeatures,
  q as useOrganizationBranding,
  E as useOrganizationConfig,
  T as useProviderStatus,
  h as useTheme,
  B as useThemeMode,
  N as useThemeVariables,
  I as withConfig,
  w as withProviders,
  G as withTheme
};
//# sourceMappingURL=index.js.map
