import { EventEmitter } from 'events';
export interface SyncState<T = unknown> {
    id: string;
    data: T;
    version: number;
    timestamp: number;
    vectorClock: VectorClock;
    hash: string;
    lastModifiedBy: string;
}
export interface VectorClock {
    [nodeId: string]: number;
}
export interface SyncOperation {
    id: string;
    type: 'create' | 'update' | 'delete';
    stateId: string;
    data?: unknown;
    timestamp: number;
    nodeId: string;
    vectorClock: VectorClock;
}
export interface SyncConflict<T = unknown> {
    stateId: string;
    localState: SyncState<T>;
    remoteState: SyncState<T>;
    conflictType: ConflictType;
    resolution?: ConflictResolution;
}
export type ConflictType = 'concurrent-update' | 'delete-update' | 'update-delete' | 'divergent-history';
export type ConflictResolution = 'local-wins' | 'remote-wins' | 'merge' | 'manual';
export interface ConflictResolutionStrategy<T = unknown> {
    canResolve(conflict: SyncConflict<T>): boolean;
    resolve(conflict: SyncConflict<T>): SyncState<T>;
}
export interface SyncConfig {
    nodeId?: string;
    conflictStrategy?: ConflictResolution;
    autoSync?: boolean;
    syncInterval?: number;
    maxRetries?: number;
    retryDelay?: number;
    persistPath?: string;
}
export type SyncStatus = 'idle' | 'syncing' | 'error' | 'conflict';
export interface ReconciliationResult<T = unknown> {
    success: boolean;
    reconciledStates: SyncState<T>[];
    conflicts: SyncConflict<T>[];
    operations: SyncOperation[];
}
export declare function createVectorClock(nodeId: string): VectorClock;
export declare function incrementVectorClock(clock: VectorClock, nodeId: string): VectorClock;
export declare function mergeVectorClocks(clock1: VectorClock, clock2: VectorClock): VectorClock;
export declare function compareVectorClocks(clock1: VectorClock, clock2: VectorClock): 'before' | 'after' | 'concurrent' | 'equal';
export declare function isVectorClockDominated(clock1: VectorClock, clock2: VectorClock): boolean;
export declare function createSyncState<T>(data: T, nodeId: string, existingClock?: VectorClock): SyncState<T>;
export declare function updateSyncState<T>(state: SyncState<T>, data: T, nodeId: string): SyncState<T>;
export declare function computeHash(data: unknown): string;
export declare function generateId(prefix: string): string;
export declare function detectConflict<T>(localState: SyncState<T>, remoteState: SyncState<T>): SyncConflict<T> | null;
export declare class LastWriteWinsStrategy<T> implements ConflictResolutionStrategy<T> {
    canResolve(_conflict: SyncConflict<T>): boolean;
    resolve(conflict: SyncConflict<T>): SyncState<T>;
}
export declare class LocalWinsStrategy<T> implements ConflictResolutionStrategy<T> {
    canResolve(_conflict: SyncConflict<T>): boolean;
    resolve(conflict: SyncConflict<T>): SyncState<T>;
}
export declare class RemoteWinsStrategy<T> implements ConflictResolutionStrategy<T> {
    canResolve(_conflict: SyncConflict<T>): boolean;
    resolve(conflict: SyncConflict<T>): SyncState<T>;
}
export declare class MergeStrategy<T extends object> implements ConflictResolutionStrategy<T> {
    canResolve(conflict: SyncConflict<T>): boolean;
    resolve(conflict: SyncConflict<T>): SyncState<T>;
    private mergeObjects;
}
export declare class SyncManager<T = unknown> extends EventEmitter {
    private config;
    private states;
    private pendingOperations;
    private conflictStrategy;
    private status;
    private syncTimer;
    private vfs;
    constructor(config?: SyncConfig);
    private createStrategy;
    getNodeId(): string;
    getStatus(): SyncStatus;
    setStatus(status: SyncStatus): void;
    private save;
    private load;
    createState(data: T): SyncState<T>;
    getState(stateId: string): SyncState<T> | undefined;
    getAllStates(): SyncState<T>[];
    updateState(stateId: string, data: T): SyncState<T> | null;
    deleteState(stateId: string): boolean;
    private addOperation;
    private getCurrentVectorClock;
    getPendingOperations(): SyncOperation[];
    clearPendingOperations(): void;
    applyRemoteState(remoteState: SyncState<T>): Promise<{
        applied: boolean;
        conflict?: SyncConflict<T>;
        resolvedState?: SyncState<T>;
    }>;
    reconcile(remoteStates: SyncState<T>[]): Promise<ReconciliationResult<T>>;
    resolveConflict(conflict: SyncConflict<T>, resolution: ConflictResolution, customData?: T): SyncState<T>;
    startAutoSync(): void;
    stopAutoSync(): void;
    exportState(): {
        states: SyncState<T>[];
        nodeId: string;
        timestamp: number;
    };
    importState(data: {
        states: SyncState<T>[];
        nodeId: string;
    }): void;
    dispose(): void;
}
export declare function getSyncManager<T = unknown>(config?: SyncConfig): SyncManager<T>;
export declare function resetSyncManager(): void;
export default SyncManager;
