/**
 * collaboration.ts — Real-time collaborative editing, comments, and version history.
 *
 * Uses a provider-agnostic architecture so consumers can plug in
 * WebSocket, WebRTC, or any custom transport.
 */
export interface CollaborationUser {
    id: string;
    name: string;
    color: string;
    cursor?: {
        x: number;
        y: number;
    };
    selection?: {
        x: number;
        y: number;
        w: number;
        h: number;
    };
}
export interface CollaborationOperation {
    type: "insert" | "update" | "delete";
    path: string[];
    value?: unknown;
    timestamp: number;
    userId: string;
}
export interface Comment {
    id: string;
    userId: string;
    userName: string;
    text: string;
    x: number;
    y: number;
    timestamp: number;
    resolved: boolean;
    replies: CommentReply[];
}
export interface CommentReply {
    id: string;
    userId: string;
    userName: string;
    text: string;
    timestamp: number;
}
export interface VersionSnapshot {
    id: string;
    name: string;
    timestamp: number;
    userId: string;
    data: unknown;
    thumbnail?: string;
}
export interface CollaborationTransport {
    connect(roomId: string, userId: string): void;
    disconnect(): void;
    send(message: CollaborationMessage): void;
    onMessage(handler: (message: CollaborationMessage) => void): () => void;
}
export type CollaborationMessage = {
    type: "join";
    user: CollaborationUser;
} | {
    type: "leave";
    userId: string;
} | {
    type: "cursor";
    userId: string;
    x: number;
    y: number;
} | {
    type: "selection";
    userId: string;
    x: number;
    y: number;
    w: number;
    h: number;
} | {
    type: "operation";
    operation: CollaborationOperation;
} | {
    type: "comment-add";
    comment: Comment;
} | {
    type: "comment-resolve";
    commentId: string;
} | {
    type: "comment-reply";
    commentId: string;
    reply: CommentReply;
} | {
    type: "snapshot";
    snapshot: VersionSnapshot;
} | {
    type: "sync-request";
    userId: string;
} | {
    type: "sync-response";
    data: unknown;
    userId: string;
};
export declare class WebSocketTransport implements CollaborationTransport {
    private serverUrl;
    private maxReconnectMs;
    private ws;
    private handlers;
    private reconnectTimer;
    private roomId;
    private userId;
    constructor(serverUrl: string, maxReconnectMs?: number);
    connect(roomId: string, userId: string): void;
    disconnect(): void;
    send(message: CollaborationMessage): void;
    onMessage(handler: (message: CollaborationMessage) => void): () => void;
    private doConnect;
}
export declare class VersionHistory {
    private snapshots;
    /** Create a new version snapshot. */
    create(name: string, userId: string, data: unknown, thumbnail?: string): VersionSnapshot;
    /** Get all snapshots ordered by timestamp. */
    getAll(): VersionSnapshot[];
    /** Get a specific snapshot. */
    get(id: string): VersionSnapshot | undefined;
    /** Remove a snapshot. */
    remove(id: string): boolean;
    /** Import snapshots from JSON. */
    import(data: VersionSnapshot[]): void;
    /** Export snapshots to JSON. */
    export(): VersionSnapshot[];
}
export declare class CommentManager {
    private comments;
    add(userId: string, userName: string, text: string, x: number, y: number): Comment;
    reply(commentId: string, userId: string, userName: string, text: string): CommentReply | null;
    resolve(commentId: string): boolean;
    getAll(): Comment[];
    getUnresolved(): Comment[];
    remove(commentId: string): boolean;
}
/** Hook for real-time collaboration. */
export declare function useCollaboration(transport: CollaborationTransport, roomId: string, currentUser: CollaborationUser): {
    users: CollaborationUser[];
    connected: boolean;
    sendCursor: (x: number, y: number) => void;
    sendOperation: (op: Omit<CollaborationOperation, "timestamp" | "userId">) => void;
    onOperation: (handler: (op: CollaborationOperation) => void) => () => void;
};
/** Hook for managing comments. */
export declare function useComments(): {
    comments: Comment[];
    addComment: (userId: string, userName: string, text: string, x: number, y: number) => Comment;
    replyToComment: (commentId: string, userId: string, userName: string, text: string) => CommentReply | null;
    resolveComment: (commentId: string) => void;
    removeComment: (commentId: string) => void;
};
/** Hook for version history. */
export declare function useVersionHistory(): {
    snapshots: VersionSnapshot[];
    createSnapshot: (name: string, userId: string, data: unknown, thumbnail?: string) => VersionSnapshot;
    removeSnapshot: (id: string) => void;
    getSnapshot: (id: string) => VersionSnapshot | undefined;
};
