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