/**
 * A type-safe wrapper around {@link LiveQuery} that carries the data type `T`
 * through initial snapshot records and real-time change events.
 *
 * `TypedLiveQuery<T>` wraps a `LiveQuery` so that:
 * - `.records` returns `TypedRecord<T>[]` instead of `Record[]`.
 * - `.on('create', handler)` provides `TypedRecord<T>` in the callback.
 * - `.on('change', handler)` provides `TypedRecordChange<T>` in the callback.
 * - `.on('disconnected' | 'reconnecting' | 'reconnected' | 'eose' | 'error', handler)`
 *   forwards transport lifecycle events from the underlying `LiveQuery`.
 *
 * @example
 * ```ts
 * const { liveQuery } = await typed.records.subscribe('friend');
 * // liveQuery is TypedLiveQuery<FriendData>
 *
 * for (const record of liveQuery.records) {
 *   const data = await record.data.json(); // FriendData
 * }
 *
 * liveQuery.on('create', async (record) => {
 *   const data = await record.data.json(); // FriendData
 * });
 *
 * // Connection lifecycle events
 * liveQuery.on('disconnected', () => showOfflineIndicator());
 * liveQuery.on('reconnected', () => hideOfflineIndicator());
 * liveQuery.on('eose', () => console.log('catch-up complete'));
 * ```
 */
import type { PaginationCursor } from '@enbox/dwn-sdk-js';
import type { LiveQuery, LiveQueryError, RecordChange } from './live-query.js';
import { TypedRecord } from './typed-record.js';
/**
 * Describes a change to a record in a {@link TypedLiveQuery}.
 *
 * Same shape as {@link RecordChange} but with the record wrapped
 * in a {@link TypedRecord}.
 */
export type TypedRecordChange<T> = {
    /** Whether the record was created, updated, or deleted. */
    type: RecordChange['type'];
    /** The typed record affected by the change. */
    record: TypedRecord<T>;
};
/**
 * A type-safe wrapper around {@link LiveQuery} that preserves the data type `T`
 * through the initial snapshot and all subsequent change events.
 *
 * Obtain instances through `TypedEnbox.records.subscribe()` — never construct
 * directly.
 */
export declare class TypedLiveQuery<T> {
    /** The underlying untyped LiveQuery instance. */
    private readonly _liveQuery;
    /** Cached typed record array, built lazily from the underlying records. */
    private _typedRecords?;
    constructor(liveQuery: LiveQuery);
    /** Access the underlying untyped {@link LiveQuery} for advanced use cases. */
    get rawLiveQuery(): LiveQuery;
    /** The initial snapshot of matching records, typed as `TypedRecord<T>[]`. */
    get records(): TypedRecord<T>[];
    /**
     * Pagination cursor for fetching the next page of initial results.
     *
     * `undefined` when there are no more results.
     */
    get cursor(): PaginationCursor | undefined;
    /**
     * Whether the transport connection is currently active.
     * Delegates to the underlying `LiveQuery.isConnected`.
     */
    get isConnected(): boolean;
    /**
     * Register a typed event handler. Returns an unsubscribe function.
     *
     * Supports both record change events (`change`, `create`, `update`, `delete`)
     * and transport lifecycle events (`disconnected`, `reconnecting`,
     * `reconnected`, `eose`, `error`).
     *
     * @param event - The event type to listen for.
     * @param handler - The handler function with typed record(s) or lifecycle data.
     * @returns A function that removes the handler when called.
     *
     * @example
     * ```ts
     * const off = liveQuery.on('create', (record) => {
     *   // record is TypedRecord<T>
     * });
     * off(); // stop listening
     *
     * liveQuery.on('disconnected', () => showOfflineIndicator());
     * liveQuery.on('reconnected', () => hideOfflineIndicator());
     * ```
     */
    on(event: 'change', handler: (change: TypedRecordChange<T>) => void): () => void;
    on(event: 'create', handler: (record: TypedRecord<T>) => void): () => void;
    on(event: 'update', handler: (record: TypedRecord<T>) => void): () => void;
    on(event: 'delete', handler: (record: TypedRecord<T>) => void): () => void;
    on(event: 'disconnected', handler: () => void): () => void;
    on(event: 'reconnecting', handler: (detail: {
        attempt: number;
    }) => void): () => void;
    on(event: 'reconnected', handler: () => void): () => void;
    on(event: 'eose', handler: () => void): () => void;
    on(event: 'error', handler: (error: LiveQueryError) => void): () => void;
    /**
     * Close the underlying subscription and stop dispatching events.
     */
    close(): Promise<void>;
}
//# sourceMappingURL=typed-live-query.d.ts.map