import { type FSWatcher } from 'chokidar';
import type { B2CInstance } from '../../instance/index.js';
import { type CartridgeMapping, type FindCartridgesOptions } from './cartridges.js';
/**
 * Options for watching cartridges.
 */
export interface WatchOptions extends FindCartridgesOptions {
    /** Debounce time in ms for batching file changes */
    debounceTime?: number;
    /** Callback when files are uploaded */
    onUpload?: (files: string[]) => void;
    /** Callback when files are deleted */
    onDelete?: (files: string[]) => void;
    /** Callback on error */
    onError?: (error: Error) => void;
}
/**
 * Result of starting a watcher.
 */
export interface WatchResult {
    /** The chokidar watcher instance */
    watcher: FSWatcher;
    /** Cartridges being watched */
    cartridges: CartridgeMapping[];
    /** Code version being deployed to */
    codeVersion: string;
    /** Stop watching */
    stop: () => Promise<void>;
}
/**
 * Watches cartridge directories and syncs changes to an instance.
 *
 * This function:
 * 1. Finds cartridges in the specified directory
 * 2. Sets up file watchers on those directories
 * 3. Batches file changes and uploads them via WebDAV
 * 4. Handles file deletions
 *
 * The watcher uses debouncing to batch rapid changes into single uploads.
 *
 * @param instance - B2C instance to sync to
 * @param directory - Directory containing cartridges
 * @param options - Watch options (filters, callbacks, debounce)
 * @returns Watch result with control methods
 * @throws Error if no cartridges found or watch setup fails
 *
 * @example
 * ```typescript
 * const result = await watchCartridges(instance, './cartridges', {
 *   onUpload: (files) => console.log('Uploaded:', files),
 *   onError: (error) => console.error('Error:', error),
 * });
 *
 * // Later, to stop watching:
 * await result.stop();
 * ```
 */
export declare function watchCartridges(instance: B2CInstance, directory: string, options?: WatchOptions): Promise<WatchResult>;
