import { x as FlagMap, n as DetailedFlagMap, u as FlagContext } from './types-DdEZ8iqq.mjs'; import './core/metrics.mjs'; import './core/flag-types.mjs'; interface RolleaseClientConfig { /** Base URL of the mounted Rollease handler (e.g. '/api/rollease'). */ baseUrl: string; /** * User context sent with every evaluation request. * Can be a static object or a sync/async factory called before each fetch. */ context?: FlagContext | (() => FlagContext | Promise); /** * Enable SSE streaming for real-time flag updates. * Falls back to polling when the environment doesn't support EventSource. * @default false */ streaming?: boolean; /** * Polling interval in milliseconds. Set to 0 to disable polling. * When streaming is true, polling is the reconnect fallback only. * @default 0 (disabled) */ refreshInterval?: number; /** * Cache evaluated flags in localStorage so the client starts with values * on the next page load before the first fetch completes. * @default false */ localStorage?: boolean; /** Key used to persist flags in localStorage. @default 'rollease:flags' */ localStorageKey?: string; /** Extra headers added to every request. */ headers?: Record; /** Public client key configured on the Rollease handler. */ clientKey?: string; /** Number of analytics events to batch before flushing. @default 10 */ eventBatchSize?: number; /** Maximum delay before flushing analytics events. @default 5000 */ eventFlushIntervalMs?: number; /** Stable anonymous identifier used for tracking before sign-in. */ anonymousId?: string; /** Called after flags are refreshed. */ onFlagsChange?: (flags: DetailedFlagMap) => void; /** Called when a fetch/stream error occurs. */ onError?: (err: Error) => void; } interface RolleaseBrowserClient { /** * Returns a flag's evaluated value synchronously. * Returns `defaultValue` before `ready()` resolves. */ flag(key: string, defaultValue: T): T; /** Current evaluated FlagMap (key → value). */ flags(): FlagMap; /** Current detailed evaluation results (key → { value, variant, reason }). */ flagDetails(): DetailedFlagMap; /** Resolves when the first fetch completes. */ ready(): Promise; /** Force an immediate refetch from the server. */ refetch(): Promise; /** * Update the user context (e.g. after sign-in) and refetch flags. * Also reconnects the SSE stream with the new context. */ identify(context: FlagContext): Promise; /** * Send an analytics event to the server. * Fire-and-forget — does not block the UI. */ track(event: string, props?: { value?: number; metadata?: Record; }): void; /** Flush queued analytics events immediately. */ flush(): Promise; /** * Subscribe to any flag change. * Returns an unsubscribe function. */ onChange(listener: () => void): () => void; /** * Subscribe to changes on a specific flag key. * Returns an unsubscribe function. */ onFlagChange(key: string, listener: (value: unknown) => void): () => void; /** Tear down SSE / polling / timers. Call on component unmount or page navigation. */ destroy(): void; } declare function createRolleaseClient(config: RolleaseClientConfig): RolleaseBrowserClient; export { type RolleaseBrowserClient, type RolleaseClientConfig, createRolleaseClient };