import { ServerFrame } from "./index.js";
//#region src/client.d.ts
type RealtimeClientStatus = 'idle' | 'connecting' | 'open' | 'reconnecting' | 'closed';
interface ReconnectPolicy {
  initialDelayMs?: number;
  maxDelayMs?: number;
  factor?: number;
  /** Symmetric jitter fraction in the range 0..1. `0.2` means ±20%. */
  jitter?: number;
}
interface RealtimeClientOptions<F extends ServerFrame> {
  url: string;
  protocols?: string | string[];
  reconnect?: false | ReconnectPolicy;
  parse?: (data: unknown) => F | null;
  createWebSocket?: (url: string, protocols?: string | string[]) => WebSocket;
  /** Injectable random source for deterministic jitter tests. Must return a value in [0, 1]. */
  random?: () => number;
}
type RealtimeSendData = string | ArrayBuffer | ArrayBufferView<ArrayBuffer> | Blob;
interface RealtimeClient<F extends ServerFrame> {
  /** Acquire connection ownership. First owner connects; returned release is idempotent. */
  retain(): () => void;
  /** Local frame fan-out subscription. Does not define any wire-level subscription protocol. */
  subscribe(listener: (frame: F) => void): () => void;
  subscribeStatus(listener: (status: RealtimeClientStatus) => void): () => void;
  getStatus(): RealtimeClientStatus;
  getLastFrame(): F | null;
  /** Returns false unless the underlying socket is OPEN. */
  send(data: RealtimeSendData): boolean;
  /** Terminal shutdown. A closed client instance never reconnects or reopens. */
  close(): void;
}
declare function createRealtimeClient(options: RealtimeClientOptions<ServerFrame> & {
  parse?: undefined;
}): RealtimeClient<ServerFrame>;
declare function createRealtimeClient<F extends ServerFrame>(options: RealtimeClientOptions<F> & {
  parse: (data: unknown) => F | null;
}): RealtimeClient<F>;
//#endregion
export { RealtimeClient, RealtimeClientOptions, RealtimeClientStatus, RealtimeSendData, ReconnectPolicy, createRealtimeClient };