import { R as RealtimeConnectionState, A as AuthUser, a as RealtimePayload, C as Chat, b as ChatMember, F as FlagsView, c as ChatMessage } from '../analytics-facade-CyeTfT28.cjs'; import { F } from './pooled-flags-ByrxSmnn.js'; import '../index.d-CS4ceNwT.cjs'; import '../storage-Nj6JAWej.cjs'; /** The session slice `useSession` exposes. */ interface SessionState { signedIn: boolean; user: AuthUser | null; } /** * Current authenticated user, or `null` when signed out. Re-renders on BOTH * auth-state transitions (sign-in adopts a user, sign-out clears it) and * user-profile changes (e.g. an email-verified flip via `refreshUser`). * * `getSnapshot` is guarded: before the generated `palbe.gen.ts` runs * `__configure`, `pb.auth` throws `notConfigured` — a tree rendered that early * gets `null`, never a render crash. Once `__configure` runs the hook * self-heals: it re-subscribes to the new runtime's auth facade and notifies * React to re-read the snapshot. */ declare function useUser(): AuthUser | null; /** * Session slice: `{ signedIn, user }`. Re-renders on auth-state transitions. * * `getSnapshot` MUST be referentially stable when nothing changed — returning a * fresh object every call would put `useSyncExternalStore` into an infinite * render loop. A per-component ref caches the last value and returns the SAME * object until `signedIn` or `user` actually changes. * * Self-heals when `__configure` runs after mount (same as `useUser`). */ declare function useSession(): SessionState; /** * Subscribe to ONE flag. Re-renders only when THIS key's value changes * (`pb.flags.subscribeKey` is the per-key source — structural compare for * objects), returning `fallback` until the key has a value. * * The value is read at the dynamic flag boundary where the concrete type `T` * is caller-asserted (the cached value is whatever the server sent); the * contained `as T` is the documented escape hatch — flags are untyped on the * wire, and the caller owns the `fallback`'s type. * * NOTE: passing an inline-object `fallback` for an absent key defeats snapshot * caching (a new object reference each render re-enters the last-value ref). * Memoize the fallback (e.g. a module-level const or `useMemo`) if it matters. * * Self-heals when `__configure` runs after mount (same as `useUser`). */ declare function useFlag(key: string, fallback: T): T; /** * Subscribe to the whole flag set. Re-renders on any change. `pb.flags.all()` * returns a frozen, identity-stable view (a NEW frozen object only when the set * actually changes), so it is `useSyncExternalStore`-safe as-is. * * Self-heals when `__configure` runs after mount (same as `useUser`). */ declare function useFlags(): FlagsView; /** The reported channel status: the shared-socket connection state, plus * `'unavailable'` when `pb.realtime.channel()` is not usable in this * environment (no WebSocket / SSR). */ type ChannelStatus = RealtimeConnectionState | 'unavailable'; /** * Subscribe a `handler` to one realtime `event` on `channel(name)` for the * lifetime of the component. Returns the live connection `{ status }`. * * The handler is held in a ref and refreshed every render, so passing a fresh * closure each render (the common case — callers needn't `useCallback`) does * NOT tear down and re-create the subscription. The subscription itself is * keyed on `[name, event]`: only a name/event change re-subscribes. * * StrictMode-safe: the facade refcounts joins, so React's mount→cleanup→ * remount (double-invoke in dev) nets to exactly one live subscription via the * effect's `cancel()` cleanup — NO once-guard (a once-guard would leave the * subscription dead after the first cleanup; that was the P4 live-smoke bug). * * SSR / no-WebSocket: `pb.realtime.channel()` throws; the effect catches it and * reports `status: 'unavailable'` instead of crashing. (Effects don't run on * the server, so the initial server status is the idle default.) */ declare function useChannel(name: string, event: string, handler: (payload: RealtimePayload) => void): { status: ChannelStatus; }; /** * The observable chat list (DMs + groups, active only). Re-renders when a chat * is added (you start one / a peer DMs you and the Welcome drains), removed, or * the list hydrates from the durable catalog on launch. * * Self-heals when `__configure` runs after mount (same as `useUser`). */ declare function useChats(): readonly Chat[]; /** * Bind to one `Chat`'s changes. Re-renders whenever the chat's observable state * changes (a new message, members refresh, typing, materialize draft→active). * Returns the SAME `chat` instance for ergonomic access to `chat.messages`, * `chat.send(...)`, etc. */ declare function useChat(chat: Chat): Chat; /** * The ordered message transcript for a chat (newest last). Re-renders on a new * message / history page / own-send echo. A cached snapshot keeps the array * reference stable until the list actually changes. */ declare function useMessages(chat: Chat): readonly ChatMessage[]; /** The members of a chat (users). Re-renders when the roster changes. */ declare function useChatMembers(chat: Chat): readonly ChatMember[]; /** The users currently typing in a chat. Re-renders on typing start/stop. */ declare function useTyping(chat: Chat): readonly ChatMember[]; export { type ChannelStatus, type SessionState, useChannel, useChat, useChatMembers, useChats, useFlag, useFlags, useMessages, useSession, useTyping, useUser };