import { execFile } from "node:child_process";
import { promisify } from "node:util";
const execFileAsync = promisify(execFile);
export async function resolveTailscaleIpv4() {
    try {
        const { stdout } = await execFileAsync("tailscale", ["ip", "-4"], {
            windowsHide: true,
        });
        const ipv4 = stdout.trim().split("\n")[0]?.trim() ?? null;
        if (!ipv4) {
            return { available: true, ipv4: null, error: "No Tailscale IPv4 address" };
        }
        return { available: true, ipv4, error: null };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        return { available: false, ipv4: null, error: message };
    }
}
