"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
const require_paths_socket = require('../../paths/socket.js');
const require_external_tools_from_download = require('../from-download.js');
const require_external_tools_uv_asset_names = require('./asset-names.js');
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path);
let node_process = require("node:process");
node_process = require_runtime.__toESM(node_process);

//#region src/external-tools/uv/from-download.ts
/**
* @file `uvFromDownload()` — fetches upstream uv and returns a `ResolvedUv`
*   pointing at the extracted binary. uv tarballs wrap the binary in a
*   `<asset-stem>/` directory; the extractor strips that level so the binary
*   sits at the cache-dir root.
*/
async function uvFromDownload(opts) {
	const { cacheDir, downloader, integrity, platformArch, version } = opts;
	const url = require_external_tools_uv_asset_names.getUvDownloadUrl({
		version,
		platformArch
	});
	const entry = require_external_tools_uv_asset_names.getUvAssetEntry(platformArch);
	if (!url || !entry) return;
	const archiveExt = entry.asset.endsWith(".zip") ? ".zip" : ".tar.gz";
	const extractedDir = cacheDir ?? node_path.default.join(require_paths_socket.getSocketDlxDir(), "uv", version, platformArch);
	const archive = await require_external_tools_from_download.downloadAndExtractTool({
		url,
		name: `uv-${version}-${platformArch}${archiveExt}`,
		integrity,
		extractedDir,
		extractOptions: { strip: 1 },
		downloader
	});
	const binary = node_process.default.platform === "win32" ? "uv.exe" : "uv";
	return {
		path: node_path.default.join(extractedDir, binary),
		source: "download",
		integrity: archive.integrity
	};
}

//#endregion
exports.uvFromDownload = uvFromDownload;