import { CollectionSubscription } from '../../collection/subscription.js';
import { LazyCollectionCallbacks, LazyDemandPlan } from '../compiler/joins.js';
export type DemandUpdate = {
    changed: boolean;
    empty: boolean;
    ready: Promise<Array<unknown>> | true;
};
/**
 * Keeps lazy subset requests aligned with the current relation of demanded
 * keys. Growth loads only new keys. Churn replaces fragmented coverage after
 * the replacement applies, so prior coverage remains live in the meantime.
 */
export declare class SubsetDemandController {
    private readonly onKeyOutcome?;
    private readonly states;
    /**
     * `onKeyOutcome`: the latest load of a key the plan needs failed with
     * `error`; without one, a load of the key succeeded or the plan no longer
     * needs it. A request error belongs to the key's failed request.
     */
    constructor(onKeyOutcome?: ((planId: string, key: string, error?: Error) => void) | undefined);
    private readonly warnedPlans;
    private valueIdentity;
    /**
     * A truncate's or a reload's replay was judged: its verdict decides every
     * request error of the demand it replayed. Its success clears them, and
     * its failure replaces them with the replay's own failures, which the
     * query reports for the replay.
     */
    clearRequestErrors(): void;
    setDemand(subscription: CollectionSubscription, plan: LazyDemandPlan, keys: Set<unknown>): DemandUpdate;
    private recordOutcome;
    clear(): void;
    hasPendingDemand(planId: string): boolean;
    private finishReplacement;
    private warnUnoptimized;
}
/** An ordered filter waits only for demand on its joined source. */
export declare function hasPendingJoinedWork(joinedSourceId: string, lazySourcesCallbacks: Record<string, LazyCollectionCallbacks>, subscriptions: Record<string, CollectionSubscription>, isPendingPlan: (planId: string) => boolean): boolean;
