import type { HtmlRequest, HtmlRequestOptions } from '../../../api/search/html/html-request.js';
import type { Result } from '../../../api/search/search/result.js';
import type { CoreEngine } from '../../../app/engine.js';
import type { StateNeededByHtmlEndpoint } from '../../../features/result-preview/result-preview-request-builder.js';
import { type Controller } from '../../controller/headless-controller.js';
export interface QuickviewProps {
/**
* The options for the `Quickview` controller.
*/
options: QuickviewOptions;
}
export interface QuickviewOptions {
/**
* The result to retrieve a quickview for.
*/
result: Result;
/**
* The maximum preview size to retrieve, in bytes. By default, the full preview is retrieved.
*/
maximumPreviewSize?: number;
/**
* Whether to only update the `contentURL` attribute when using `fetchResultContent` rather than updating `content`.
* Use this if you are using an iframe with `state.contentURL` as the source url.
*/
onlyContentURL?: boolean;
}
export interface Quickview extends Controller {
/**
* Retrieves the preview content for the configured result.
* If `options.onlyContentURL` is `true` this will update the `contentURL` state property rather than `content`.
*/
fetchResultContent(): void;
/**
* Retrieves the preview content for the next available result in the current result set.
*
* If it reaches the last available result in the current result set, it will not perform an additional query to fetch new results.
*
* Instead, it will loop back to the first available result.
*
* If `options.onlyContentURL` is `true` this will update the `contentURL` state property rather than `content`.
*/
next(): void;
/**
* Retrieves the preview content for the previous available result in the current result set.
*
* If it reaches the first available result in the current result set, it will not perform an additional query to fetch new results.
*
* Instead, it will loop back to the last available result.
*
* If `options.onlyContentURL` is `true` this will update the `contentURL` state property rather than `content`.
*/
previous(): void;
/**
* The state for the `Quickview` controller.
*/
state: QuickviewState;
}
export interface QuickviewState {
/**
* The result preview HTML content.
*
* @default ""
*/
content: string;
/**
* `true` if the configured result has a preview, and `false` otherwise.
*/
resultHasPreview: boolean;
/**
* `true` if content is being fetched, and `false` otherwise.
*/
isLoading: boolean;
/**
* The `src` path to use if rendering the quickview in an iframe.
*/
contentURL?: string;
/**
* The current result unique ID,
*/
currentResultUniqueId: string;
}
/**
* Creates a `Quickview` controller instance.
*
* @param engine - The headless engine.
* @param props - The configurable `Quickview` properties.
* @param fetchResultContentCallback - The callback to be triggered after executing fetchResultContent.
* @returns A `Quickview` controller instance.
*/
export declare function buildCoreQuickview(engine: CoreEngine, props: QuickviewProps, buildResultPreviewRequest: (state: StateNeededByHtmlEndpoint, options: HtmlRequestOptions) => Promise, path: string, fetchResultContentCallback?: () => void): Quickview;