import fs from "node:fs";
import path from "node:path";
export function resolveElectronHelperPath() {
    if (process.platform !== "darwin" || !process.versions["electron"]) {
        return null;
    }
    const contentsDir = path.dirname(path.dirname(process.execPath));
    const appName = path.basename(process.execPath);
    const helperPath = path.join(contentsDir, "Frameworks", `${appName} Helper.app`, "Contents", "MacOS", `${appName} Helper`);
    return fs.existsSync(helperPath) ? helperPath : null;
}
/**
 * Returns a node-compatible runtime path that works when the user's PATH does
 * not include `node`. Inside packaged Electron apps we reuse the bundled
 * runtime: the Helper binary on macOS (avoids Dock icons), or the main exe on
 * Windows/Linux. Spawning these requires `ELECTRON_RUN_AS_NODE=1` in env.
 *
 * Returns null when not running inside Electron — callers should keep the
 * caller-resolved command as-is in that case.
 */
export function resolveElectronNodeRuntime() {
    if (!process.versions["electron"]) {
        return null;
    }
    return resolveElectronHelperPath() ?? process.execPath;
}
//# sourceMappingURL=electron-helper.js.map