import { AddFilterOptions, Filters } from '@carto/api-client';
import { Source } from '../../providers/sources/types';
type SourceWidgets = NonNullable<Source['widgets']>;
/**
 * A pre-read slice of `useSourceStore` for one source id. Threaded through by
 * the hook path so the values that drive the query key come from a real
 * subscription (re-rendering the caller when they change), while the
 * imperative path can omit it and fall back to a `getState()` read.
 */
export interface SourceStateSlice {
    source: Source | undefined;
    filters: Filters | undefined;
}
/**
 * Function that, given a source's widget model, returns the request method
 * for a particular widget kind (categories, formula, …).
 *
 * Identical shape to `ModelConfig['getWidgetMethod']` in `create-model.tsx` so
 * the same lambda can power both the imperative factory and the hook.
 */
export type GetWidgetMethod<TWidgetProps extends object, TResponse> = (widgetModel: SourceWidgets) => (params: TWidgetProps & {
    filters?: unknown;
    signal?: AbortSignal;
}) => Promise<TResponse>;
/**
 * React Query options object produced by per-model factories like
 * `getCategories`, `getFormula`, etc. Directly consumable by
 * `queryClient.prefetchQuery`, `queryClient.fetchQuery`,
 * `queryClient.ensureQueryData`, and `useQuery`.
 */
export interface ModelQueryOptions<TResponse> {
    queryKey: unknown[];
    queryFn: (ctx: {
        signal: AbortSignal;
    }) => Promise<TResponse>;
    enabled: boolean;
}
export interface GetModelQueryOptionsArgs<TWidgetProps extends object, TResponse> {
    queryKeyPrefix: string[];
    getWidgetMethod: GetWidgetMethod<TWidgetProps, TResponse>;
    accessToken: string;
    sourceId: string;
    widgetProps: TWidgetProps;
    additionalFilter?: AddFilterOptions[];
    /**
     * Position of this source within a multi-source call. Drives per-source
     * column / operation / operationExp / operationColumn / spatialFilter
     * resolution when the corresponding prop is an array. Defaults to 0
     * (single-source).
     */
    sourceIndex?: number;
    /**
     * Total number of sources in the call. Validated against array-prop lengths
     * by `resolvePropertyForSource`. Defaults to 1 (single-source).
     */
    totalSources?: number;
    /**
     * Pre-read store slice for this source. When provided, it is used as the
     * source of truth for `source` and `filters`; otherwise the function reads
     * `useSourceStore.getState()` directly. The hook path (`createModel`) passes
     * this so the values come from a real `useSourceStore` subscription
     * (`useSourceSlices`) — which is what makes `setSource(...)` and filter
     * mutations re-trigger query-key construction. The imperative path
     * (`queryClient.prefetchQuery(getXxx(...))`) omits it and falls back to a
     * fresh `getState()` read.
     */
    sourceState?: SourceStateSlice;
}
/**
 * Builds the React Query options for a single source.
 *
 * The `queryKey` shape is identical to what the `useXxx` hook (via
 * `createModel`) produces for the same inputs, which guarantees the
 * imperative path (e.g. `queryClient.prefetchQuery(getCategories(...))`)
 * and the reactive hook share the same cache entry.
 *
 * @remarks
 * The widget model's access token is mutated (`widgetModel.props.accessToken
 * = accessToken`) just before each request, mirroring `useWidgetModel`.
 * Concurrent calls for the same `sourceId` with **different** tokens may
 * race — the underlying `WidgetClient` is shared singleton state on the
 * source. Use distinct `sourceId`s if you need token isolation.
 */
export declare function getModelQueryOptions<TWidgetProps extends object, TResponse>({ queryKeyPrefix, getWidgetMethod, accessToken, sourceId, widgetProps, additionalFilter, sourceIndex, totalSources, sourceState, }: GetModelQueryOptionsArgs<TWidgetProps, TResponse>): ModelQueryOptions<TResponse>;
export {};
