"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_sbt_asset_names = require('./asset-names.js');
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path);

//#region src/external-tools/sbt/from-download.ts
/**
* @file `sbtFromDownload()` — fetches the SBT launcher tarball, extracts it,
*   and returns a `ResolvedSbt` pointing at the `bin/sbt` script. SBT
*   distributes a single platform-agnostic tgz containing a `bin/sbt` script
*   plus `bin/sbt-launch.jar`. The `bin/sbt` form is directly invocable (it
*   shells out to `java -jar` internally), so `isJar: false` even though the
*   underlying machinery is a JAR. Default cache layout:
*   `<dlxDir>/sbt/<version>/`. Trust-on-first-use: pass `integrity` from
*   `external-tools.json` when available.
*/
/**
* Resolve SBT by downloading and extracting the upstream tgz. Returns the
* standard `ResolvedSbt` shape with `source: 'download'`.
*
* @example
*   ;```typescript
*   const sbt = await sbtFromDownload({ version: '1.10.7' })
*   // → { path: '/.../bin/sbt', isJar: false, source: 'download' }
*   ```
*/
async function sbtFromDownload(opts) {
	const { cacheDir, downloader, integrity, version } = opts;
	const url = require_external_tools_sbt_asset_names.getSbtDownloadUrl({ version });
	const extractedDir = cacheDir ?? node_path.default.join(require_paths_socket.getSocketDlxDir(), "sbt", version);
	const archive = await require_external_tools_from_download.downloadAndExtractTool({
		url,
		name: `sbt-${version}.tgz`,
		integrity,
		extractedDir,
		extractOptions: { strip: 1 },
		downloader
	});
	return {
		path: node_path.default.join(extractedDir, "bin", "sbt"),
		isJar: false,
		source: "download",
		integrity: archive.integrity
	};
}

//#endregion
exports.sbtFromDownload = sbtFromDownload;