import { ReactNode } from 'react'; import { RenderMode } from '../types/index.js'; import { RegnaApiClient } from './api-client.js'; interface RegnaContextValue { client: RegnaApiClient | null; renderMode: RenderMode; theme: 'light' | 'dark'; /** True when the value was supplied by an actual . The * default context value (no provider mounted) sets this to false so * customer-facing widgets can distinguish "rendered standalone with * a publishableKey prop" (active) from "rendered under a provider * that resolved to preview" (preview). Without this flag a widget * rendered with no provider would always read renderMode='preview' * from the context default and short-circuit a real publishableKey. */ hasProvider: boolean; } export interface RegnaProviderProps { /** * v1.2: browser-safe API key. Format: `rk_public_.` or * the grandfathered legacy `rk_live_*` (valid until 2026-07-22 UTC). * NEVER pass a `rk_secret_*` here — the provider refuses and logs. */ publishableKey?: string; baseUrl?: string; /** * v1.2 phase 12: proxy mode. When set, API requests go here and no * Authorization header is attached; the proxy owns key injection. */ proxyBaseUrl?: string; /** * Dev shortcut for the regna-api / regna-ui maintainers. When `true`, * routes every request to the Django runserver at * `http://localhost:8765/api/v1` instead of `baseUrl`. When a string, * uses that URL verbatim. Wins over `baseUrl` but not over * `proxyBaseUrl`. Logs a one-time console.warn so a dev build that * accidentally ships with `devMode={true}` is loud, not silent. */ devMode?: boolean | string; theme?: 'light' | 'dark'; children: ReactNode; } export declare function RegnaProvider({ publishableKey, baseUrl, proxyBaseUrl, devMode, theme, children, }: RegnaProviderProps): import("react/jsx-runtime").JSX.Element; export declare function useRegnaContext(): RegnaContextValue; export declare function useRegnaClient(): RegnaApiClient; export declare function useRegnaRenderMode(): RenderMode; /** * Hook used by every customer-facing widget to get a RegnaApiClient * for its data calls. * * - When mounted under : returns the provider's * instrumented client. A 401/402 from any widget call fires the * provider's onAuthFailure observer, which flips the whole subtree * to the inactive tombstone. * * - When mounted standalone (no provider - today's Storybook stories * and ad-hoc embeds): falls back to a fresh RegnaApiClient * constructed from the widget's own publishableKey prop. The widget * continues to work, but a 401 surfaces as a raw error string in * the widget instead of a tombstone (the documented trade-off). * * The fallback client is memoized per (publishableKey, baseUrl) pair * so re-renders with the same key reuse the same client and the same * dedupe scope. */ export declare function useRegnaWidgetClient(publishableKey: string): RegnaApiClient; export {}; //# sourceMappingURL=regna-provider.d.ts.map