import { Blorb } from '../../blorb/blorb.js';
import * as protocol from '../../common/protocol.js';
import { TextInput } from './input.js';
import { DOM, type EventFunc } from './shared.js';
import WebGlkOte from './web.js';
export type Window = BufferWindow | GraphicsWindow | GridWindow;
type WindowCodes = 'buffer' | 'graphics' | 'grid';
interface WindowConstructorOptions {
    blorb?: Blorb;
    dom: DOM;
    id: number;
    manager: Windows;
    metrics: protocol.NormalisedMetrics;
    rock: number;
    styles?: protocol.WindowStyles;
    type: WindowCodes;
}
declare abstract class WindowBase {
    blorb?: Blorb;
    desired: boolean;
    dom: DOM;
    frameel: JQuery<HTMLElement>;
    id: number;
    inputs?: protocol.InputUpdate;
    manager: Windows;
    metrics: protocol.NormalisedMetrics;
    textinput: TextInput;
    type: WindowCodes;
    constructor(options: WindowConstructorOptions);
    destroy(remove_frame: boolean): void;
    measure_height(): void;
    protected onclick(ev: JQuery.ClickEvent): false | undefined;
    send_text_event(ev: Partial<protocol.CharEvent | protocol.LineEvent>): void;
}
export declare function apply_text_run_styles(orig_styles: protocol.CSSProperties, reverse: boolean, el: JQuery<HTMLElement>): void;
declare abstract class TextualWindow extends WindowBase {
    bg?: string;
    fg?: string;
    last_run_styles?: protocol.CSSProperties;
    styles?: protocol.WindowStyles;
    constructor(options: WindowConstructorOptions);
    /** Format CSS rules and add to the window */
    add_stylehints(): void;
    create_text_run(run: protocol.TextRun, split_words?: boolean): JQuery<HTMLElement>;
    onlink(target: HTMLElement): false | undefined;
    /** Refresh styles after a cleared window */
    refresh_styles(bg?: string, fg?: string): void;
}
export declare class BufferWindow extends TextualWindow {
    type: "buffer";
    /** How much height is available with the keyboard active */
    height_above_keyboard: number;
    innerel: JQuery<HTMLElement>;
    private is_scrolled_down;
    lastline?: JQuery<HTMLElement>;
    updatescrolltop: number;
    constructor(options: WindowConstructorOptions);
    destroy(remove_frame: boolean): void;
    /** Measure the height of the window that is currently visible (excluding virtual keyboards for example) */
    measure_height(): void;
    protected onclick(_: JQuery.ClickEvent): false | undefined;
    private onscroll;
    scroll_to_bottom(after_metrics_change?: boolean): void;
    update(data: protocol.BufferWindowContentUpdate): void;
}
export declare class GraphicsWindow extends WindowBase {
    type: "graphics";
    buffer: JQuery<HTMLCanvasElement>;
    canvas: JQuery<HTMLCanvasElement>;
    fillcolour: string;
    framequeue: protocol.GraphicsWindowOperation[][];
    /** Height in CSS pixels */
    height: number;
    image_cache: Map<string | number, HTMLImageElement>;
    /** Width in CSS pixels */
    width: number;
    constructor(options: WindowConstructorOptions);
    clear_cache: import("lodash").DebouncedFunc<() => void>;
    decode_image(key: number | string, url: string): Promise<void>;
    destroy(remove_frame: boolean): void;
    onclick(ev: JQuery.ClickEvent): false | undefined;
    set_dimensions(height: number, width: number): void;
    update(): Promise<void>;
}
declare class GridWindow extends TextualWindow {
    type: "grid";
    height: number;
    lines: JQuery<HTMLElement>[];
    width: number;
    constructor(options: WindowConstructorOptions);
    onclick(ev: JQuery.ClickEvent): false | undefined;
    update(data: protocol.GridWindowContentUpdate): void;
}
export default class Windows extends Map<number, Window> {
    active_window?: Window;
    blorb?: Blorb;
    canvasResizeObserver?: ResizeObserver;
    private dom;
    glkote: WebGlkOte;
    history: string[];
    private metrics;
    send_event: EventFunc;
    constructor(glkote: WebGlkOte);
    destroy(): void;
    cancel_inputs(windows: protocol.InputUpdate[]): void;
    private oncanvasresize;
    private onclick;
    private onkeydown;
    update(windows: protocol.WindowUpdate[]): void;
    update_content(content: protocol.ContentUpdate[]): void;
    update_inputs(windows: protocol.InputUpdate[]): void;
}
export {};
