/**
 * Browser entry point for Circle-IR
 *
 * This module provides a browser-compatible API for code analysis.
 */
import { initAnalyzer, analyze, analyzeForAPI, isAnalyzerInitialized, } from './analyzer.js';
/**
 * Initialize the analyzer for browser/worker usage.
 */
export async function init(options) {
    const initOptions = {
        taintConfig: options.taintConfig,
    };
    if (typeof options.wasmUrl === 'string') {
        initOptions.wasmPath = options.wasmUrl;
    }
    else {
        initOptions.wasmModule = options.wasmUrl;
    }
    if (options.languageUrls) {
        const paths = {};
        const modules = {};
        for (const [lang, value] of Object.entries(options.languageUrls)) {
            if (typeof value === 'string') {
                paths[lang] = value;
            }
            else if (value) {
                modules[lang] = value;
            }
        }
        if (Object.keys(paths).length > 0)
            initOptions.languagePaths = paths;
        if (Object.keys(modules).length > 0)
            initOptions.languageModules = modules;
    }
    await initAnalyzer(initOptions);
}
/**
 * Analyze source code and return full Circle-IR output.
 */
export async function analyzeCode(code, options = {}) {
    const filePath = options.filePath ?? 'input.java';
    const language = options.language ?? 'java';
    if (!isAnalyzerInitialized()) {
        throw new Error('Analyzer not initialized. Call init() first.');
    }
    return analyze(code, filePath, language);
}
/**
 * Analyze source code and return simplified API response.
 */
export async function analyzeCodeForAPI(code, options = {}) {
    const filePath = options.filePath ?? 'input.java';
    const language = options.language ?? 'java';
    if (!isAnalyzerInitialized()) {
        throw new Error('Analyzer not initialized. Call init() first.');
    }
    return analyzeForAPI(code, filePath, language);
}
//# sourceMappingURL=browser.js.map