"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_trivy_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/trivy/from-download.ts
/**
* @file `trivyFromDownload()` — fetches upstream Trivy and returns a
*   `ResolvedTrivy` pointing at the extracted binary. macOS/Linux ship tar.gz,
*   Windows ships zip; `downloadAndExtractTool` auto-detects the format from
*   the archive name.
*/
async function trivyFromDownload(opts) {
	const { cacheDir, downloader, integrity, platformArch, version } = opts;
	const url = require_external_tools_trivy_asset_names.getTrivyDownloadUrl({
		version,
		platformArch
	});
	if (!url) return;
	const archiveExt = require_external_tools_trivy_asset_names.getTrivyAssetEntry(platformArch)?.suffix.endsWith(".zip") ? ".zip" : ".tar.gz";
	const extractedDir = cacheDir ?? node_path.default.join(require_paths_socket.getSocketDlxDir(), "trivy", version, platformArch);
	const archive = await require_external_tools_from_download.downloadAndExtractTool({
		url,
		name: `trivy-${version}-${platformArch}${archiveExt}`,
		integrity,
		extractedDir,
		downloader
	});
	const binary = node_process.default.platform === "win32" ? "trivy.exe" : "trivy";
	return {
		path: node_path.default.join(extractedDir, binary),
		source: "download",
		integrity: archive.integrity
	};
}

//#endregion
exports.trivyFromDownload = trivyFromDownload;