import { ValueIdentity } from "../equality-value-identity.cjs";
import { CompilationResult, IncludesCompilationResult, SourceInclude } from "./index.cjs";
import { BasicExpression, CollectionSourceRef, From, JoinClause, QueryIR, QueryRef } from "../ir.cjs";
import { Collection } from "../../collection/index.cjs";
import { KeyedStream, NamespacedAndKeyedStream } from "../../types.cjs";
import { QueryMapping } from "./types.cjs";
type CompileSubquery = (query: QueryIR, parentKeyStream?: KeyedStream) => CompilationResult;
export type LazyDemandPlan = {
    id: string;
    path: Array<string>;
    collectionId: string;
    initialKeys: Set<unknown>;
};
/** Callbacks for managing lazy-loaded collections in optimized joins */
export type LazyCollectionCallbacks = {
    plans?: Array<LazyDemandPlan>;
    setDemand?: (plan: LazyDemandPlan, keys: Set<unknown>) => void;
};
export declare function registerLazyDemandPlan(callbacks: Record<string, LazyCollectionCallbacks>, target: {
    sourceId: string;
    path: Array<string>;
    collection: Collection;
}, initialKeys?: Set<unknown>): LazyDemandPlan;
/**
 * Processes all join clauses, applying lazy loading optimizations and maintaining
 * alias tracking for per-alias subscriptions (enables self-joins).
 */
export declare function processJoins(pipeline: NamespacedAndKeyedStream, joinClauses: Array<JoinClause>, sources: Record<string, KeyedStream>, mainCollectionId: string, mainSource: string, allInputs: Record<string, KeyedStream>, queryMapping: QueryMapping, collections: Record<string, Collection>, callbacks: Record<string, LazyCollectionCallbacks>, lazySources: Set<string>, rawQuery: QueryIR, localFrom: From, onCompileSubquery: CompileSubquery, aliasToCollectionId: Record<string, string>, aliasRemapping: Record<string, string>, sourceWhereClauses: Map<string, BasicExpression<boolean>>, mainSourceIsParentFiltered: boolean, valueIdentity: ValueIdentity, sourceIncludes: Array<SourceInclude>, parentKeyStream?: KeyedStream): NamespacedAndKeyedStream;
/**
 * Compiles a FROM or JOIN source and propagates its source metadata.
 */
export declare function processSource(from: CollectionSourceRef | QueryRef, allInputs: Record<string, KeyedStream>, queryMapping: QueryMapping, onCompileSubquery: CompileSubquery, aliasToCollectionId: Record<string, string>, aliasRemapping: Record<string, string>, sourceWhereClauses: Map<string, BasicExpression<boolean>>, valueIdentity: ValueIdentity, sourceKind: `from` | `join`, parentKeyStream?: KeyedStream): {
    alias: string;
    input: KeyedStream;
    collectionId: string;
    includes?: Array<IncludesCompilationResult>;
};
export {};
