/**
 * CollabSync — orchestrates multi-doc CRDT sync between local workbooks
 * and a remote collaboration server.
 *
 * Each workbook in the SheetEnginePool gets a SyncBridge. Local mutations
 * are debounced and pushed as Yrs diffs. Incoming binary frames from the
 * server are routed to the correct bridge by doc ID.
 *
 * Engine creation uses `createHeadlessEngine({ yrsState })` which calls
 * `compute_init_from_yrs_state` in Rust — this preserves exact Yrs item
 * identities so that subsequent `syncApply` diffs merge correctly.
 * (See mog/plans/active/colab/round-7/root-cause.md for why the JSON
 * snapshot path is broken.)
 */
import type { SheetEnginePool } from '../new-sheet/sheet-engine.js';
import type { CollabClient } from './collab-client.js';
export declare class CollabSync {
    private client;
    private pool;
    private bridges;
    private debounceTimers;
    private unsubscribers;
    private workbookEventUnsubs;
    private destroyed;
    /** Frames that arrived while handleInitialState was in progress. */
    private pendingUpdates;
    /** Docs currently being initialized (guards against concurrent handleInitialState). */
    private initializing;
    constructor(client: CollabClient, pool: SheetEnginePool);
    /**
     * Start syncing all current workbooks in the pool.
     * Called after creating/joining a room.
     */
    startSyncing(): Promise<void>;
    /**
     * Handle initial state for a doc received from server (late joiner).
     * Creates a new engine from raw Yrs state bytes, registers it in the pool,
     * and starts syncing.
     */
    handleInitialState(docId: string, state: Uint8Array): Promise<void>;
    /**
     * Handle incoming binary from server — apply remote update to the correct bridge.
     */
    handleRemoteUpdate(docId: string, data: Uint8Array): Promise<void>;
    destroy(): void;
    /**
     * Share a local workbook with the room — create a bridge, send full state,
     * subscribe to mutation events.
     */
    private shareWorkbook;
    /**
     * Subscribe to workbook mutation events for outbound sync.
     * Synchronous — uses activeSheet property to avoid async gaps where
     * cell changes could be missed.
     */
    private subscribeToWorkbookEvents;
    /**
     * Push local Yrs changes to the server for a specific doc.
     */
    private pushLocalChanges;
}
//# sourceMappingURL=collab-sync.d.ts.map