/* tslint:disable */
/* eslint-disable */

export function registerDynamicLanguage(map: Record<string, {libraryPath: string, expandoChar?: string}>): Promise<void>;



export class Pos {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    /**
     * column number starting from 0
     */
    column: number;
    /**
     * character offset of the position
     */
    index: number;
    /**
     * line number starting from 0
     */
    line: number;
}

export class Range {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    /**
     * ending position of the range
     */
    end: Pos;
    /**
     * starting position of the range
     */
    start: Pos;
}

/**
 * Represents a single AST node.
 */
export class SgNode {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    ancestors(): SgNode[];
    child(nth: number): SgNode | undefined;
    children_nodes(): SgNode[];
    commitEdits(edits: any): string;
    field(name: string): SgNode | undefined;
    fieldChildren(name: string): SgNode[];
    find(matcher: any): SgNode | undefined;
    findAll(matcher: any): SgNode[];
    follows(m: any): boolean;
    getMatch(m: string): SgNode | undefined;
    getMultipleMatches(m: string): SgNode[];
    getTransformed(m: string): string | undefined;
    has(m: any): boolean;
    id(): number;
    inside(m: any): boolean;
    is(kind: string): boolean;
    isLeaf(): boolean;
    isNamed(): boolean;
    isNamedLeaf(): boolean;
    kind(): string;
    matches(m: any): boolean;
    next(): SgNode | undefined;
    nextAll(): SgNode[];
    parent_node(): SgNode | undefined;
    precedes(m: any): boolean;
    prev(): SgNode | undefined;
    prevAll(): SgNode[];
    range(): Range;
    replace(text: string): WasmEdit;
    text(): string;
}

/**
 * Represents the parsed tree of code.
 */
export class SgRoot {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Returns the path of the file if it is discovered by ast-grep's `findInFiles`.
     * Returns `"anonymous"` if the instance is created by `parse`.
     */
    filename(): string;
    /**
     * This method is mainly for debugging tree parsing result.
     */
    getInnerTree(): any;
    /**
     * Returns the root SgNode of the ast-grep instance.
     */
    root(): SgNode;
}

export class WasmEdit {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    /**
     * The end position of the edit (character offset)
     */
    end_pos: number;
    /**
     * The text to be inserted
     */
    inserted_text: string;
    /**
     * The start position of the edit (character offset)
     */
    start_pos: number;
}

/**
 * Dump a pattern's internal structure for inspection.
 * `selector` is an optional kind name for contextual patterns.
 * `strictness` is one of: "cst", "smart", "ast", "relaxed", "signature", "template".
 * Returns a tree structure showing how ast-grep parses the pattern, including source positions.
 */
export function dumpPattern(lang: string, pattern_str: string, selector?: string | null, strictness?: string | null): any;

/**
 * Initialize the tree-sitter WASM runtime.
 * Must be called before any other function.
 */
export function initializeTreeSitter(): Promise<void>;

/**
 * Get the `kind` number from its string name.
 */
export function kind(lang: string, kind_name: string): number;

/**
 * Parse a string to an ast-grep instance.
 */
export function parse(lang: string, src: string): SgRoot;

/**
 * Compile a string to ast-grep Pattern config.
 */
export function pattern(lang: string, pattern_str: string): any;

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

export interface InitOutput {
    readonly memory: WebAssembly.Memory;
    readonly dumpPattern: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
    readonly initializeTreeSitter: () => any;
    readonly kind: (a: number, b: number, c: number, d: number) => [number, number, number];
    readonly parse: (a: number, b: number, c: number, d: number) => [number, number, number];
    readonly pattern: (a: number, b: number, c: number, d: number) => [number, number, number];
    readonly registerDynamicLanguage: (a: any) => any;
    readonly __wbg_get_pos_column: (a: number) => number;
    readonly __wbg_get_pos_index: (a: number) => number;
    readonly __wbg_get_pos_line: (a: number) => number;
    readonly __wbg_get_range_end: (a: number) => number;
    readonly __wbg_get_range_start: (a: number) => number;
    readonly __wbg_get_wasmedit_end_pos: (a: number) => number;
    readonly __wbg_get_wasmedit_inserted_text: (a: number) => [number, number];
    readonly __wbg_get_wasmedit_start_pos: (a: number) => number;
    readonly __wbg_pos_free: (a: number, b: number) => void;
    readonly __wbg_range_free: (a: number, b: number) => void;
    readonly __wbg_set_pos_column: (a: number, b: number) => void;
    readonly __wbg_set_pos_index: (a: number, b: number) => void;
    readonly __wbg_set_pos_line: (a: number, b: number) => void;
    readonly __wbg_set_range_end: (a: number, b: number) => void;
    readonly __wbg_set_range_start: (a: number, b: number) => void;
    readonly __wbg_set_wasmedit_end_pos: (a: number, b: number) => void;
    readonly __wbg_set_wasmedit_inserted_text: (a: number, b: number, c: number) => void;
    readonly __wbg_set_wasmedit_start_pos: (a: number, b: number) => void;
    readonly __wbg_sgnode_free: (a: number, b: number) => void;
    readonly __wbg_sgroot_free: (a: number, b: number) => void;
    readonly __wbg_wasmedit_free: (a: number, b: number) => void;
    readonly sgnode_ancestors: (a: number) => [number, number];
    readonly sgnode_child: (a: number, b: number) => number;
    readonly sgnode_children_nodes: (a: number) => [number, number];
    readonly sgnode_commitEdits: (a: number, b: any) => [number, number, number, number];
    readonly sgnode_field: (a: number, b: number, c: number) => number;
    readonly sgnode_fieldChildren: (a: number, b: number, c: number) => [number, number];
    readonly sgnode_find: (a: number, b: any) => [number, number, number];
    readonly sgnode_findAll: (a: number, b: any) => [number, number, number, number];
    readonly sgnode_follows: (a: number, b: any) => [number, number, number];
    readonly sgnode_getMatch: (a: number, b: number, c: number) => number;
    readonly sgnode_getMultipleMatches: (a: number, b: number, c: number) => [number, number];
    readonly sgnode_getTransformed: (a: number, b: number, c: number) => [number, number];
    readonly sgnode_has: (a: number, b: any) => [number, number, number];
    readonly sgnode_id: (a: number) => number;
    readonly sgnode_inside: (a: number, b: any) => [number, number, number];
    readonly sgnode_is: (a: number, b: number, c: number) => number;
    readonly sgnode_isLeaf: (a: number) => number;
    readonly sgnode_isNamed: (a: number) => number;
    readonly sgnode_isNamedLeaf: (a: number) => number;
    readonly sgnode_kind: (a: number) => [number, number];
    readonly sgnode_matches: (a: number, b: any) => [number, number, number];
    readonly sgnode_next: (a: number) => number;
    readonly sgnode_nextAll: (a: number) => [number, number];
    readonly sgnode_parent_node: (a: number) => number;
    readonly sgnode_precedes: (a: number, b: any) => [number, number, number];
    readonly sgnode_prev: (a: number) => number;
    readonly sgnode_prevAll: (a: number) => [number, number];
    readonly sgnode_range: (a: number) => number;
    readonly sgnode_replace: (a: number, b: number, c: number) => number;
    readonly sgnode_text: (a: number) => [number, number];
    readonly sgroot_filename: (a: number) => [number, number];
    readonly sgroot_getInnerTree: (a: number) => any;
    readonly sgroot_root: (a: number) => number;
    readonly wasm_bindgen__convert__closures_____invoke__hec385d26368cade7: (a: number, b: number, c: any) => [number, number];
    readonly wasm_bindgen__convert__closures_____invoke__h28c4d526cef7fb77: (a: number, b: number, c: any, d: 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_destroy_closure: (a: number, b: number) => void;
    readonly __externref_table_dealloc: (a: number) => void;
    readonly __wbindgen_free: (a: number, b: number, c: number) => void;
    readonly __externref_drop_slice: (a: number, b: 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>;
