import type { ExtensionWidgetOptions } from "./types.ts";
export interface ReactiveWidgetComponent {
    render(width: number): string[];
    invalidate?(): void;
    dispose?(): void;
}
export type ReactiveWidgetFactory<TTheme> = (tui: unknown, theme: TTheme) => ReactiveWidgetComponent;
export interface ReactiveWidgetUi<TTheme> {
    setWidget(key: string, factory: ReactiveWidgetFactory<TTheme> | undefined, options?: ExtensionWidgetOptions): void;
    requestRender?: () => void;
}
export interface ReactiveWidgetTimerHandle {
    unref?: () => void;
}
export interface ReactiveWidgetTimerApi {
    setTimeout(handler: () => void, delayMs: number): ReactiveWidgetTimerHandle;
    clearTimeout(handle: ReactiveWidgetTimerHandle): void;
}
export interface ReactiveWidgetScheduler {
    queueMicrotask(handler: () => void): void;
}
export type ReactiveWidgetAction = "mount" | "unmount" | "update" | "none";
export type ReactiveWidgetRefreshReason = "initial" | "state" | "clock" | "manual";
export interface ReactiveWidgetRenderState {
    readonly mounted: boolean;
    readonly lines: readonly string[];
}
export interface ReactiveWidgetRenderContext<TTheme> {
    theme: TTheme;
    width: number;
    now: number;
}
export interface ReactiveWidgetController {
    refresh(reason?: ReactiveWidgetRefreshReason): void;
    dispose(): void;
    isMounted(): boolean;
}
export interface InstallReactiveWidgetOptions<TSnapshot, TTheme> {
    ui: ReactiveWidgetUi<TTheme>;
    key: string;
    placement?: ExtensionWidgetOptions["placement"];
    getSnapshot(): TSnapshot;
    subscribe?(listener: () => void): () => void;
    getPreviewLines(snapshot: TSnapshot, now: number): readonly string[];
    render(snapshot: TSnapshot, context: ReactiveWidgetRenderContext<TTheme>): readonly string[];
    getNextRefreshDelayMs?(snapshot: TSnapshot, now: number): number | undefined;
    now?: () => number;
    timers?: ReactiveWidgetTimerApi;
    scheduler?: ReactiveWidgetScheduler;
    coalesceRenderRequests?: boolean;
    requestRenderOnMount?: boolean;
    requestRenderOnUnmount?: boolean;
    requestRenderOnStateNoop?: boolean;
    isStaleError?: (error: unknown) => boolean;
}
export declare function decideReactiveWidgetAction(prev: ReactiveWidgetRenderState, nextLines: readonly string[]): ReactiveWidgetAction;
export declare function installReactiveWidget<TSnapshot, TTheme = object>(options: InstallReactiveWidgetOptions<TSnapshot, TTheme>): ReactiveWidgetController;
//# sourceMappingURL=reactive-widget.d.ts.map