import { AnyCircuitElement } from 'circuit-json';
import { RootCircuitEventName, RootCircuit } from '@tscircuit/core';

interface CircuitRunnerConfiguration {
    snippetsApiBaseUrl: string;
    cjsRegistryUrl: string;
    verbose?: boolean;
}
interface WebWorkerConfiguration extends CircuitRunnerConfiguration {
    evalVersion?: string;
    /**
     * @deprecated, renamed to webWorkerBlobUrl
     */
    webWorkerUrl?: URL | string;
    webWorkerBlobUrl?: URL | string;
}
/**
 * API for the CircuitRunner class, used for eval'ing circuits
 */
interface CircuitRunnerApi {
    execute: (code: string, opts?: {
        name?: string;
    }) => Promise<void>;
    executeWithFsMap(opts: {
        entrypoint?: string;
        fsMap: Record<string, string>;
        name?: string;
    }): Promise<void>;
    renderUntilSettled: () => Promise<void>;
    getCircuitJson: () => Promise<AnyCircuitElement[]>;
    setSnippetsApiBaseUrl: (baseUrl: string) => Promise<void>;
    on: (event: RootCircuitEventName, callback: (...args: any[]) => void) => void;
    clearEventListeners: () => void;
    kill: () => Promise<void>;
}

interface ExecutionContext extends WebWorkerConfiguration {
    fsMap: Record<string, string>;
    entrypoint: string;
    preSuppliedImports: Record<string, any>;
    circuit: RootCircuit;
}
declare function createExecutionContext(webWorkerConfiguration: WebWorkerConfiguration, opts?: {
    name?: string;
}): ExecutionContext;

declare class CircuitRunner implements CircuitRunnerApi {
    _executionContext: ReturnType<typeof createExecutionContext> | null;
    _circuitRunnerConfiguration: CircuitRunnerConfiguration;
    _eventListeners: Record<string, ((...args: any[]) => void)[]>;
    executeWithFsMap(ogOpts: {
        entrypoint?: string;
        mainComponentPath?: string;
        mainComponentName?: string;
        fsMap: Record<string, string>;
        name?: string;
        mainComponentProps?: Record<string, any>;
    }): Promise<void>;
    execute(code: string, opts?: {
        name?: string;
    }): Promise<void>;
    on(event: string, callback: (...args: any[]) => void): void;
    renderUntilSettled(): Promise<void>;
    getCircuitJson(): Promise<AnyCircuitElement[]>;
    clearEventListeners(): void;
    kill(): Promise<void>;
    setSnippetsApiBaseUrl(baseUrl: string): Promise<void>;
    private _bindEventListeners;
}

export { CircuitRunner };
