import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
function detectarRuntime() {
    const globalAny = globalThis;
    const proc = globalAny.process;
    if (typeof proc !== 'undefined' && proc?.versions?.node) {
        return { tipo: 'node', versao: proc.versions.node };
    }
    if (typeof globalAny.Deno !== 'undefined') {
        return { tipo: 'deno', versao: 'desconhecida' };
    }
    if (typeof globalAny.Bun !== 'undefined') {
        return { tipo: 'bun', versao: 'desconhecida' };
    }
    return { tipo: 'node', versao: process.version };
}
function criarFileSystem() {
    return {
        readFile: (caminho, encoding) => fs.promises.readFile(caminho, encoding),
        readFileSync: (caminho, encoding) => fs.readFileSync(caminho, encoding),
        writeFile: (caminho, conteudo) => fs.promises.writeFile(caminho, conteudo, 'utf-8'),
        writeFileSync: (caminho, conteudo) => fs.writeFileSync(caminho, conteudo, 'utf-8'),
        readdir: caminho => fs.promises.readdir(caminho),
        readdirSync: caminho => fs.readdirSync(caminho),
        mkdir: (caminho, opcoes) => fs.promises.mkdir(caminho, { recursive: opcoes?.recursive }).then(() => undefined),
        mkdirSync: (caminho, opcoes) => fs.mkdirSync(caminho, { recursive: opcoes?.recursive }),
        statSync: caminho => fs.statSync(caminho),
        existsSync: caminho => fs.existsSync(caminho),
        access: (caminho, mode) => fs.promises.access(caminho, mode),
    };
}
function criarPath() {
    return {
        join: path.join,
        resolve: path.resolve,
        basename: path.basename,
        dirname: path.dirname,
        extname: path.extname,
        relative: path.relative,
        sep: path.sep,
    };
}
function criarProcess() {
    return {
        cwd: () => process.cwd(),
        chdir: dir => process.chdir(dir),
        env: process.env,
        exit: (code) => process.exit(code),
        argv: process.argv,
        on: (evento, listener) => process.on(evento, listener),
        memoryUsage: () => process.memoryUsage(),
        uptime: () => process.uptime(),
    };
}
export function criarAdapterNode() {
    const runtime = detectarRuntime();
    return {
        tipo: runtime.tipo,
        info: runtime,
        fs: criarFileSystem(),
        path: criarPath(),
        process: criarProcess(),
    };
}
//# sourceMappingURL=node-adapter.js.map