import * as fs from 'fs';

type WingCompilerFunction = "wingc_compile" | "wingc_generate_docs" | "wingc_on_did_open_text_document" | "wingc_on_did_change_text_document" | "wingc_on_completion" | "wingc_on_signature_help" | "wingc_on_goto_definition" | "wingc_on_document_symbol" | "wingc_on_rename" | "wingc_on_prepare_rename" | "wingc_on_semantic_tokens" | "wingc_on_hover" | "wingc_on_code_action";
interface WingCompilerLoadOptions {
    /**
     * Additional imports to pass to the WASI instance. Imports objects/functions that WASM code can invoke.
     *
     * @default `{ wasi_snapshot_preview1: wasi.wasiImport, env: { send_diagnostic: () => {} }`
     */
    imports?: Record<string, any>;
    /**
     * Preopen directories for the WASI instance.
     * These are directories that the sandboxed WASI instance can access.
     * The also represent mappings from the WASI instance's filesystem to the host filesystem. (map key -> value)
     *
     * The following directories are always preopened:
     * - The `@winglang/sdk` module directory
     * - All local and global node_modules directories (module.paths)
     *
     * @default - No additional preopens are added other than the above
     */
    preopens?: Record<string, string>;
    /**
     * Environment variables to pass to the WASI instance.
     *
     * The following variables are always set:
     *
     * - Current process environment variables
     * - `RUST_BACKTRACE`=`full`
     * - `WINGSDK_MANIFEST_ROOT`=The path to the `@winglang/sdk` module
     *
     *
     * @default - No additional envs are added other than the above
     */
    env?: Record<string, string>;
    /**
     * A filesystem for the WASI instance to use.
     *
     * @default - The `fs` module from Node.js
     */
    fs?: typeof fs;
    /**
     * The bytes of the `wingc.wasm` data loaded into memory.
     *
     * @default - The wingc.wasm bundled with this package is read from disk.
     */
    wingcWASMData?: Uint8Array;
    /**
     * The path to a directory containing the `@winglang/sdk` module
     *
     * @default - The `@winglang/sdk` module is resolved via `require.resolve()`.
     */
    wingsdkManifestRoot?: string;
    readonly log?: (...args: any[]) => void;
}
declare function load(options: WingCompilerLoadOptions): Promise<WebAssembly.Instance>;
interface WingDiagnostic {
    message: string;
    span?: WingSpan;
    annotations: {
        message: string;
        span: WingSpan;
    }[];
    hints: string[];
    severity: "error" | "warning";
}
interface WingSpan {
    start: {
        line: number;
        col: number;
    };
    end: {
        line: number;
        col: number;
    };
    file_id: string;
    start_offset: number;
    end_offset: number;
}
/**
 * Runs the given WASM function in the Wing Compiler WASM instance.
 *
 * ### IMPORTANT
 * For Windows support, ensure all paths provided by args or env are normalized to use forward slashes.
 *
 * ### Assumptions
 * 1. The called WASM function is expecting a pointer and a length representing a string
 * 2. The string will be UTF-8 encoded
 * 3. The string will be less than 2^32 bytes long  (4GB)
 * 4. The WASI instance has already been initialized
 * 5. The returned value is a pointer to a UTF-8 string and a length encoded in a single
 *    64 bit value or 0 (indicating no return value or error).
 */
declare function invoke(instance: WebAssembly.Instance, func: WingCompilerFunction, arg: string): number | string;

declare class CompileError extends Error {
    readonly diagnostics: WingDiagnostic[];
    constructor(diagnostics: WingDiagnostic[]);
}

declare class PreflightError extends Error {
    readonly causedBy: Error;
    readonly artifactPath: string;
    readonly artifact: string;
    constructor(causedBy: Error, artifactPath: string, artifact: string);
}

/**
 * Compile options for the `compile` command.
 * This is passed from Commander to the `compile` function.
 */
interface CompileOptions {
    readonly platform: string[];
    readonly rootId?: string;
    readonly value?: string;
    readonly values?: string;
    /**
     * Whether to run the compiler in `wing test` mode. This may create multiple
     * copies of the application resources in order to run tests in parallel.
     */
    readonly testing?: boolean;
    readonly log?: (...args: any[]) => void;
    readonly preflightLog?: (...args: any[]) => void;
    readonly color?: boolean;
    readonly targetDir?: string;
    readonly output?: string;
}
/**
 * Determines the model for a given list of platforms.
 *
 * @param platforms list of wing platforms
 * @returns the resolved model
 */
declare function determineTargetFromPlatforms(platforms: string[]): string;
interface CompileOutput {
    readonly outputDir?: string;
    readonly wingcErrors: WingDiagnostic[];
    readonly preflightError?: PreflightError;
}
/**
 * Compiles a Wing program. Throws an error if compilation fails.
 * @param entrypoint The program .w entrypoint.
 * @param options Compile options.
 * @returns the output directory
 */
declare function compile(entrypoint: string, options: CompileOptions): Promise<CompileOutput>;

/**
 * Available builtin platforms for compilation.
 * This is passed from Commander to the `compile` function.
 */
declare const BuiltinPlatform: {
    TF_AWS: string;
    TF_AZURE: string;
    TF_GCP: string;
    SIM: string;
    AWSCDK: string;
};

interface GenerateWingDocsOutput {
    docsContents: string;
    diagnostics: WingDiagnostic[];
}
declare function generateWingDocs(props: {
    projectDir: string;
    color?: boolean;
    log?: (...args: any[]) => void;
}): Promise<GenerateWingDocsOutput>;

export { BuiltinPlatform, CompileError, type CompileOptions, type CompileOutput, type GenerateWingDocsOutput, PreflightError, type WingCompilerFunction, type WingCompilerLoadOptions, type WingDiagnostic, type WingSpan, compile, determineTargetFromPlatforms, generateWingDocs, invoke, load };
