/**
 * The question asked to the Overlay Services Engine when a consumer of state wishes to look up information.
 */
export interface LookupQuestion {
    /**
     * The identifier for a Lookup Service which the person asking the question wishes to use.
     */
    service: string;
    /**
     * The query which will be forwarded to the Lookup Service.
     * Its type depends on that prescribed by the Lookup Service employed.
     */
    query: unknown;
}
/**
 * How the Overlay Services Engine responds to a Lookup Question.
 * It may comprise either an output list or a freeform response from the Lookup Service.
 */
export type LookupAnswer = {
    type: 'output-list';
    outputs: Array<{
        beef: number[];
        outputIndex: number;
        context?: number[];
    }>;
};
/**
 * Per-call options for {@link LookupResolver.query} and {@link LookupResolver.query$}.
 * All optional; defaults preserve prior behavior.
 */
export interface LookupQueryOptions {
    /**
     * Override the grace window (ms) between the first valid response and the resolution of the query.
     * Late responders arriving within this window are merged into the result. Default 80 ms.
     * Raise for identity-style paths (e.g. ~300 ms) where divergence between hosts matters.
     */
    graceMs?: number;
    /**
     * Soft timeout (ms). When set:
     *  - `query()` resolves with whatever has arrived as soon as any host answers, or after this timeout.
     *  - `query$()` emits a (possibly empty) snapshot after this timeout if no host has answered yet,
     *    then continues yielding late-host enrichments until the iterator is broken or final emission.
     */
    softTimeoutMs?: number;
}
/**
 * One emission from {@link LookupResolver.query$}. Carries the cumulative output set discovered so far
 * plus a small envelope describing progress across hosts. Callers can render fast on the first emission
 * and refine in place as more hosts answer.
 */
export interface LookupAnswerProgress {
    type: 'output-list';
    outputs: Array<{
        beef: number[];
        outputIndex: number;
        context?: number[];
    }>;
    /** Parallel array of resolved tx ids for each output (same index as `outputs`). */
    txIds: string[];
    /** True only for the final emission, after every in-flight host has settled. */
    isFinal: boolean;
    /** Number of ranked hosts that were queried. */
    hostCount: number;
    /** Number of hosts that have settled (success / fail / timeout). */
    completedHosts: number;
}
/** Default SLAP trackers */
export declare const DEFAULT_SLAP_TRACKERS: string[];
/** Default testnet SLAP trackers */
export declare const DEFAULT_TESTNET_SLAP_TRACKERS: string[];
/** Internal cache options. Kept optional to preserve drop-in compatibility. */
interface CacheOptions {
    /** How long (ms) a hosts entry is considered fresh. Default 5 minutes. */
    hostsTtlMs?: number;
    /** How many distinct services’ hosts to cache before evicting. Default 128. */
    hostsMaxEntries?: number;
    /** How long (ms) to keep txId memoization. Default 10 minutes. */
    txMemoTtlMs?: number;
}
/** Configuration options for the Lookup resolver. */
export interface LookupResolverConfig {
    /**
     * The network preset to use, unless other options override it.
     * - mainnet: use mainnet SLAP trackers and HTTPS facilitator
     * - testnet: use testnet SLAP trackers and HTTPS facilitator
     * - local: directly query from localhost:8080 and a facilitator that permits plain HTTP
     */
    networkPreset?: 'mainnet' | 'testnet' | 'local';
    /** The facilitator used to make requests to Overlay Services hosts. */
    facilitator?: OverlayLookupFacilitator;
    /** The list of SLAP trackers queried to resolve Overlay Services hosts for a given lookup service. */
    slapTrackers?: string[];
    /** Map of lookup service names to arrays of hosts to use in place of resolving via SLAP. */
    hostOverrides?: Record<string, string[]>;
    /** Map of lookup service names to arrays of hosts to use in addition to resolving via SLAP. */
    additionalHosts?: Record<string, string[]>;
    /** Optional cache tuning. */
    cache?: CacheOptions;
    /** Optional storage for host reputation data. */
    reputationStorage?: 'localStorage' | {
        get: (key: string) => string | null | undefined;
        set: (key: string, value: string) => void;
    };
}
/** Facilitates lookups to URLs that return answers. */
export interface OverlayLookupFacilitator {
    /**
     * Returns a lookup answer for a lookup question
     * @param url - Overlay Service URL to send the lookup question to.
     * @param question - Lookup question to find an answer to.
     * @param timeout - Specifics how long to wait for a lookup answer in milliseconds.
     * @returns
     */
    lookup: (url: string, question: LookupQuestion, timeout?: number) => Promise<LookupAnswer>;
}
export declare class HTTPSOverlayLookupFacilitator implements OverlayLookupFacilitator {
    fetchClient: typeof fetch;
    allowHTTP: boolean;
    constructor(httpClient?: typeof fetch, allowHTTP?: boolean);
    lookup(url: string, question: LookupQuestion, timeout?: number): Promise<LookupAnswer>;
}
/**
 * Represents a Lookup Resolver.
 */
export default class LookupResolver {
    private readonly facilitator;
    private readonly slapTrackers;
    private readonly hostOverrides;
    private readonly additionalHosts;
    private readonly networkPreset;
    private readonly hostReputation;
    private readonly hostsCache;
    private readonly hostsInFlight;
    private readonly hostsTtlMs;
    private readonly hostsMaxEntries;
    private readonly txMemo;
    private readonly txMemoTtlMs;
    constructor(config?: LookupResolverConfig);
    /**
     * Given a LookupQuestion, returns a LookupAnswer. Aggregates across multiple services and supports resiliency.
     *
     * Optional `options.graceMs` overrides the per-call grace window (default 80 ms).
     * Optional `options.softTimeoutMs` resolves the query early with whatever has arrived once any host has
     * answered (or with an empty result if no host has answered by `softTimeoutMs`).
     */
    query(question: LookupQuestion, timeout?: number, options?: LookupQueryOptions): Promise<LookupAnswer>;
    /**
     * Iterable form of {@link query}. Emits partial results as hosts answer.
     *
     * Emission order:
     *  - First emission: after the grace window expires (or as soon as the soft timeout elapses), containing
     *    every output gathered from hosts that answered by then.
     *  - Subsequent emissions: re-emitted whenever a late host returns extra outputs that weren't in earlier
     *    emissions. Each emission contains the cumulative `outputs` set.
     *  - Final emission: `isFinal: true` once all in-flight hosts have settled (success / fail / timeout). The
     *    caller can `break` early; outstanding work is bounded by the per-host timeout.
     *
     * No host work runs past its per-host `timeout` — there is no leak risk on early break.
     */
    query$(question: LookupQuestion, timeout?: number, options?: LookupQueryOptions): AsyncIterable<LookupAnswerProgress>;
    /**
     * Cached wrapper for competent host discovery with stale-while-revalidate.
     */
    private getCompetentHostsCached;
    /**
     * Actually resolves competent hosts from SLAP trackers and updates cache.
     */
    private refreshHosts;
    /**
     * Extracts competent host domains from a SLAP tracker response.
     */
    private extractHostsFromAnswer;
    /**
     * Returns a list of competent hosts for a given lookup service.
     * Resolves as soon as the first SLAP tracker responds with valid hosts.
     * Remaining trackers continue in the background for reputation tracking.
     * @param service Service for which competent hosts are to be returned
     * @returns Array of hosts competent for resolving queries
     */
    private findCompetentHosts;
    /** Evict an arbitrary “oldest” entry from a Map (iteration order). */
    private evictOldest;
    private assertValidOverrideServices;
    private prepareHostsForQuery;
    private lookupHostWithTracking;
}
export {};
//# sourceMappingURL=LookupResolver.d.ts.map