/* tslint:disable */
/* eslint-disable */
/**
 * A bezier path segment in frame-content coordinates (points).
 */
export type ScenePathSeg = { op: "moveTo"; x: number; y: number } | { op: "lineTo"; x: number; y: number } | { op: "cubicTo"; cx1: number; cy1: number; cx2: number; cy2: number; x: number; y: number } | { op: "close" };

/**
 * A plugin-submitted vector layer in frame-content coordinates. Keyed
 * (on the wire) by the host element id of the frame it renders into.
 */
export interface SceneLayer {
    items: SceneItem[];
}

/**
 * A single-line text run in frame-content coordinates (C-1.1).
 */
export interface SceneTextItem {
    /**
     * Baseline origin x in frame-content points.
     */
    x: number;
    /**
     * Baseline origin y in frame-content points (the text baseline).
     */
    y: number;
    /**
     * The run\'s text (single line — newlines are not laid out).
     */
    text: string;
    /**
     * Point size.
     */
    size: number;
    paint: ScenePaint;
    /**
     * Reserved face hints (v1 renders in the document default font).
     */
    family?: string;
    style?: string;
}

/**
 * A solid paint in **sRGB** (0..=1 per channel; alpha is linear). Core
 * converts to the display list\'s linear-light [`Color`] so plugin
 * colours composite identically to document colours.
 */
export interface ScenePaint {
    r: number;
    g: number;
    b: number;
    a: number;
}

/**
 * Continuous-layout geometry for every page, so the TS wrapper
 * computes fit / goToPage / currentPage / scroll extents without
 * wasm round-trips. `y_pt` is the page top in doc space (vertical
 * stack with `gap_pt` between pages — the same offsets
 * `present()` uses).
 */
export interface PagesLayout {
    gapPt: number;
    pages: PageRect[];
}

/**
 * One drawable in a [`SceneLayer`]. Coordinates are frame-content points.
 */
export type SceneItem = { kind: "fillPath"; path: ScenePathSeg[]; paint: ScenePaint } | { kind: "strokePath"; path: ScenePathSeg[]; paint: ScenePaint; width: number } | ({ kind: "text" } & SceneTextItem) | { kind: "image"; rgba: number[]; width: number; height: number; x: number; y: number; w: number; h: number };

/**
 * Stable page identity, independent of position in the page vector.
 *
 * Derived from the IDML `<Page Self=\"...\">` attribute where present;
 * synthesised as `\"page-<spread_idx>-<local_idx>\"` when missing
 * (older / synthetic fixtures without `Self`). The canvas keys
 * display-list caches and LOD tiles by `PageId`, so the value must
 * stay stable across re-layouts — only document-structural edits
 * (insert/delete page) should ever change the set of `PageId`s.
 */
export type PageId = string;

/**
 * Structured, JSON-serialisable result of `load` / `render_*`. Unlike
 * the legacy free functions, recoverable parse/layout problems are
 * reported here (so the docs preview can surface them inline) rather
 * than thrown as an opaque `JsError`.
 */
export interface Diagnostics {
    ok: boolean;
    messages: Diagnostic[];
}

export interface Diagnostic {
    /**
     * `\"error\" | \"warning\" | \"info\"`.
     */
    severity: string;
    /**
     * Short machine code, e.g. `\"open\"`, `\"build\"`, `\"no_gpu\"`.
     */
    code: string;
    message: string;
    /**
     * IDML part the problem originates from, when known.
     */
    part?: string;
    line?: number;
}

export interface PageRect {
    index: number;
    yPt: number;
    widthPt: number;
    heightPt: number;
}


/**
 * Headless readback result. `rgba` is tightly-packed RGBA8
 * (`width * height * 4`), surfaced to JS as a `Uint8Array`.
 */
export class RenderedRaster {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    height: number;
    rgba: Uint8Array;
    width: number;
}

/**
 * Renderer-core session. Holds the parsed+laid-out document and a
 * lazily-created WebGPU presenter (device + surface). One per viewer
 * instance / preview component.
 */
export class ViewerSession {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Parse + build a complete IDML package. `font` is optional. Caches
     * the built document and resets the current page to 0. Returns
     * structured diagnostics; does not throw on recoverable problems.
     */
    load(idml: Uint8Array, font?: Uint8Array | null): Diagnostics;
    /**
     * Acquire the session, gating on WebGPU availability. Rejects when
     * `navigator.gpu` is absent so the consumer can map that to the
     * WebGPU-absent note. Exposed to JS as `ViewerSession.new()`
     * returning a `Promise`.
     */
    static new(): Promise<ViewerSession>;
    page_count(): number;
    /**
     * Continuous-layout page geometry (doc-space pt, vertical
     * stack with `PAGE_GAP_PT` between pages). Empty until `load`
     * succeeds. The TS wrapper derives fit zoom, scroll extents,
     * `goToPage` targets and the current page from this — no
     * per-frame wasm round-trips.
     */
    page_layout(): PagesLayout;
    /**
     * Camera-transformed present of the continuous page stack —
     * the viewer's per-frame paint (ports the editor canvas's
     * `presentFrame`). `zoom` is CSS px per pt; `scroll_x` /
     * `scroll_y` place the doc origin in CSS px (positive moves
     * content right/down); `dpr` brings CSS px to device px.
     * Off-viewport pages are culled; per-page scenes build once
     * and cache. `only_page` restricts the pass to one page laid
     * out at y = 0 (the wrapper's `"single"` layout mode).
     *
     * Requires a bound presenter (any `render_to_canvas*` call
     * binds one).
     */
    present(zoom: number, scroll_x: number, scroll_y: number, dpr: number, only_page?: number | null): Diagnostics;
    /**
     * Register a font for an IDML `AppliedFont` family (and optional
     * style such as `"Bold"` / `"Italic"`). Accumulates across calls
     * and is consulted on the next `load`; real documents reference
     * many faces, so call this once per face before `load`. Mirrors
     * the editor's `RegisterFont` and `paged-inspect`'s
     * `--font-family "Family[/Style]=PATH"`.
     */
    register_font(family: string, style: string | null | undefined, bytes: Uint8Array): void;
    /**
     * Headless render of ONE page scaled to `target_width_px`
     * (thumbnails / page strips). Aspect ratio preserved.
     */
    render_page_to_bytes(index: number, target_width_px: number): Promise<RenderedRaster>;
    /**
     * Headless path: render the current page off-surface and read it
     * back as RGBA8 (replaces the legacy `render_to_png`). For
     * screenshots / SSR. `dpi` controls resolution (72 = 1px per pt).
     */
    render_to_bytes(dpi: number): Promise<RenderedRaster>;
    /**
     * Present the current page to a worker-owned `OffscreenCanvas` via
     * WebGPU. The presenter is created (bound to `canvas`) on the first
     * call; later calls reuse it and re-present — pass the same canvas.
     */
    render_to_canvas(canvas: OffscreenCanvas): Promise<Diagnostics>;
    /**
     * Main-thread variant of [`Self::render_to_canvas`] for embedders
     * that render on an `HtmlCanvasElement` instead of a worker
     * `OffscreenCanvas`.
     */
    render_to_canvas_main(canvas: HTMLCanvasElement): Promise<Diagnostics>;
    /**
     * Resize the bound GPU surface. `width`/`height` are CSS pixels;
     * `device_pixel_ratio` brings them to device pixels. No-op until a
     * presenter exists.
     */
    resize(width: number, height: number, device_pixel_ratio: number): void;
    set_page(index: number): void;
}

export function on_start(): void;

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
    readonly memory: WebAssembly.Memory;
    readonly __wbg_get_renderedraster_height: (a: number) => number;
    readonly __wbg_get_renderedraster_rgba: (a: number) => [number, number];
    readonly __wbg_get_renderedraster_width: (a: number) => number;
    readonly __wbg_renderedraster_free: (a: number, b: number) => void;
    readonly __wbg_set_renderedraster_height: (a: number, b: number) => void;
    readonly __wbg_set_renderedraster_rgba: (a: number, b: number, c: number) => void;
    readonly __wbg_set_renderedraster_width: (a: number, b: number) => void;
    readonly __wbg_viewersession_free: (a: number, b: number) => void;
    readonly viewersession_load: (a: number, b: number, c: number, d: number, e: number) => any;
    readonly viewersession_new: () => any;
    readonly viewersession_page_count: (a: number) => number;
    readonly viewersession_page_layout: (a: number) => any;
    readonly viewersession_present: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
    readonly viewersession_register_font: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
    readonly viewersession_render_page_to_bytes: (a: number, b: number, c: number) => any;
    readonly viewersession_render_to_bytes: (a: number, b: number) => any;
    readonly viewersession_render_to_canvas: (a: number, b: any) => any;
    readonly viewersession_render_to_canvas_main: (a: number, b: any) => any;
    readonly viewersession_resize: (a: number, b: number, c: number, d: number) => void;
    readonly viewersession_set_page: (a: number, b: number) => void;
    readonly on_start: () => void;
    readonly qcms_enable_iccv4: () => void;
    readonly qcms_profile_precache_output_transform: (a: number) => void;
    readonly qcms_transform_data_bgra_out_lut: (a: number, b: number, c: number, d: number) => void;
    readonly qcms_transform_data_bgra_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
    readonly qcms_transform_data_rgb_out_lut: (a: number, b: number, c: number, d: number) => void;
    readonly qcms_transform_data_rgb_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
    readonly qcms_transform_data_rgba_out_lut: (a: number, b: number, c: number, d: number) => void;
    readonly qcms_transform_data_rgba_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
    readonly qcms_transform_release: (a: number) => void;
    readonly qcms_profile_is_bogus: (a: number) => number;
    readonly qcms_white_point_sRGB: (a: number) => void;
    readonly lut_inverse_interp16: (a: number, b: number, c: number) => number;
    readonly lut_interp_linear16: (a: number, b: number, c: number) => number;
    readonly wasm_bindgen__convert__closures_____invoke__h0cde11723d429dba: (a: number, b: number, c: any) => [number, number];
    readonly wasm_bindgen__convert__closures_____invoke__h59cb846e76c2acc2: (a: number, b: number, c: any, d: any) => void;
    readonly wasm_bindgen__convert__closures_____invoke__h9534aa66f81a191a: (a: number, b: number, c: any) => void;
    readonly __wbindgen_malloc: (a: number, b: number) => number;
    readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
    readonly __wbindgen_exn_store: (a: number) => void;
    readonly __externref_table_alloc: () => number;
    readonly __wbindgen_externrefs: WebAssembly.Table;
    readonly __wbindgen_free: (a: number, b: number, c: number) => void;
    readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
    readonly __externref_table_dealloc: (a: number) => void;
    readonly __wbindgen_start: () => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;

/**
 * Instantiates the given `module`, which can either be bytes or
 * a precompiled `WebAssembly.Module`.
 *
 * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
 *
 * @returns {InitOutput}
 */
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;

/**
 * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
 * for everything else, calls `WebAssembly.instantiate` directly.
 *
 * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
 *
 * @returns {Promise<InitOutput>}
 */
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
