import { existsSync } from 'node:fs';
import { platform } from 'node:os';
import { basename } from 'node:path';
const MUX_SHELL_NAMES = new Set(['byobu', 'tmux', 'screen']);
function isMuxWrapper(shell) {
    return MUX_SHELL_NAMES.has(basename(shell));
}
export function detectShell() {
    const envShell = process.env.SHELL;
    if (envShell && !isMuxWrapper(envShell) && existsSync(envShell))
        return envShell;
    if (platform() === 'win32') {
        return process.env.ComSpec || 'powershell.exe';
    }
    for (const candidate of ['/bin/zsh', '/bin/bash', '/bin/sh']) {
        if (existsSync(candidate))
            return candidate;
    }
    return '/bin/sh';
}
export function shellArgs(shell) {
    if (platform() === 'win32')
        return [];
    if (shell.endsWith('zsh'))
        return ['-i'];
    if (shell.endsWith('bash'))
        return ['-i'];
    return [];
}
//# sourceMappingURL=shell-detect.js.map