import type { SelectQueryBuilder } from "kysely";
import type { Lix } from "../lix/open-lix.js";
import type { DiffRow } from "../version/select-version-diff.js";
import type { LixDatabaseSchema } from "../database/schema.js";
/**
 * Returns the diff between the working state and the last checkpoint.
 *
 * The working state contains all changes made since the last checkpoint. This function
 * compares these changes against the checkpoint to show what has been created, updated,
 * or deleted. Optimized for real-time UI updates during active editing.
 *
 * Unlike {@link selectVersionDiff} which compares two complete versions, this operates
 * directly on change sets for better performance.
 *
 * ## Diff Status Meanings
 *
 * | Status      | Description                                  | Before | After  |
 * |-------------|----------------------------------------------|--------|--------|
 * | `created`   | Entity added since checkpoint                | null   | exists |
 * | `updated`   | Entity modified since checkpoint             | exists | exists |
 * | `deleted`   | Entity removed since checkpoint (tombstone)  | exists | null   |
 * | `unchanged` | Entity not modified in working state         | same   | same   |
 *
 * ## Performance
 *
 * - Queries only two change sets (working + latest checkpoint)
 * - No graph traversal or recursion
 * - Returns same shape as `selectVersionDiff` for compatibility
 *
 * @example
 * // Get all changes since the last checkpoint
 * const changes = await selectWorkingDiff({ lix })
 *   .where('status', '!=', 'unchanged')
 *   .execute();
 *
 * console.log(`${changes.length} changes since checkpoint`);
 *
 * @example
 * // Monitor changes to a specific file
 * const fileChanges = await selectWorkingDiff({ lix })
 *   .where('file_id', '=', 'config.json')
 *   .where('status', '!=', 'unchanged')
 *   .orderBy('entity_id')
 *   .execute();
 *
 * @example
 * // Check if specific entities have changed since checkpoint
 * const entityIds = ['user-1', 'user-2', 'user-3'];
 * const entityChanges = await selectWorkingDiff({ lix })
 *   .where('entity_id', 'in', entityIds)
 *   .where('status', '!=', 'unchanged')
 *   .execute();
 *
 * @example
 * // Count changes by status
 * const allChanges = await selectWorkingDiff({ lix })
 *   .where('status', '!=', 'unchanged')
 *   .execute();
 *
 * const stats = allChanges.reduce((acc, change) => {
 *   acc[change.status] = (acc[change.status] || 0) + 1;
 *   return acc;
 * }, {} as Record<string, number>);
 *
 * console.log('Changes:', stats);
 * // Output: { created: 5, updated: 3, deleted: 1 }
 *
 * @param args - Configuration object
 * @param args.lix - Lix instance with database connection
 *
 * @returns A Kysely query builder for `DiffRow` results that can be further filtered,
 * sorted, or executed.
 *
 * @see createCheckpoint - Convert working state into a checkpoint
 * @see selectVersionDiff - Compare two complete version states
 *
 * @example
 * // Fetch before/after snapshots by joining the `change` table
 * // Tip: apply filters (file_id, schema_key, status) before joining to keep it fast.
 * const rows = await selectWorkingDiff({ lix })
 *   .where('file_id', '=', 'lix')
 *   .where('schema_key', '=', 'lix_key_value')
 *   .where('status', '!=', 'unchanged')
 *   .leftJoin('change as before', 'before.id', 'before_change_id')
 *   .leftJoin('change as after', 'after.id', 'after_change_id')
 *   .select([
 *     'entity_id',
 *     'schema_key',
 *     'file_id',
 *     'status',
 *     'before.snapshot_content',
 *     'after.snapshot_content',
 *   ])
 *   .execute();
 *
 * // rows[i].before_snapshot_content / after_snapshot_content are JSON objects (or null)
 */
type DiffDB = {
    diff: DiffRow;
};
export declare function selectWorkingDiff(args: {
    lix: Lix;
}): SelectQueryBuilder<LixDatabaseSchema & DiffDB, "diff", DiffRow>;
export {};
//# sourceMappingURL=select-working-diff.d.ts.map