"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_normalize = require('../paths/normalize.js');
const require_primordials_array = require('../primordials/array.js');
const require_primordials_object = require('../primordials/object.js');
const require_primordials_reflect = require('../primordials/reflect.js');
const require_constants_lifecycle_script_names = require('./lifecycle-script-names.js');
const require_constants_package_default_node_range = require('./package-default-node-range.js');
const require_constants_package_default_socket_categories = require('./package-default-socket-categories.js');
const require_pkg_ext_data = require('../pkg-ext/data.js');
let src_external_pacote = require("../external/pacote");
src_external_pacote = require_runtime.__toESM(src_external_pacote);

//#region src/constants/packages.ts
/**
* @file Package metadata, defaults, extensions, and lifecycle helpers. Exposes
*   lazily-memoized accessors for package defaults (Node range, Socket
*   categories), the pacote cache path, lifecycle script names, and known
*   package extensions used during manifest processing.
*/
let _lifecycleScriptNames;
let _packageDefaultNodeRange;
let _packageDefaultSocketCategories;
let _packageExtensions;
let _pacoteCachePath;
let _packumentCache;
const PACKAGE = "package";
const AT_LATEST = "@latest";
const LATEST = "latest";
const PACKAGE_DEFAULT_VERSION = "1.0.0";
/**
* Clear the packument cache. Useful for long-running processes that want to
* force a re-fetch of registry metadata.
*/
function clearPackumentCache() {
	/* c8 ignore next 3 */
	if (_packumentCache !== void 0) _packumentCache.clear();
}
/*@__NO_SIDE_EFFECTS__*/
function getLifecycleScriptNames() {
	if (_lifecycleScriptNames === void 0) _lifecycleScriptNames = require_primordials_array.ArrayFrom(require_constants_lifecycle_script_names.lifecycleScriptNames);
	return _lifecycleScriptNames;
}
/*@__NO_SIDE_EFFECTS__*/
function getPackageDefaultNodeRange() {
	if (_packageDefaultNodeRange === void 0) _packageDefaultNodeRange = require_constants_package_default_node_range.packageDefaultNodeRange;
	return _packageDefaultNodeRange;
}
/*@__NO_SIDE_EFFECTS__*/
function getPackageDefaultSocketCategories() {
	if (_packageDefaultSocketCategories === void 0) _packageDefaultSocketCategories = require_constants_package_default_socket_categories.packageDefaultSocketCategories;
	return _packageDefaultSocketCategories;
}
/*@__NO_SIDE_EFFECTS__*/
function getPackageExtensions() {
	if (_packageExtensions === void 0) _packageExtensions = require_primordials_object.ObjectEntries(require_pkg_ext_data.packageExtensions);
	return _packageExtensions;
}
const PACKUMENT_CACHE_MAX = 500;
var BoundedPackumentCache = class extends Map {
	set(key, value) {
		/* c8 ignore start */
		if (this.has(key)) this.delete(key);
		else if (this.size >= PACKUMENT_CACHE_MAX) {
			const oldest = this.keys().next().value;
			if (oldest !== void 0) this.delete(oldest);
		}
		/* c8 ignore stop */
		return super.set(key, value);
	}
};
/*@__NO_SIDE_EFFECTS__*/
function getPackumentCache() {
	if (_packumentCache === void 0) _packumentCache = new BoundedPackumentCache();
	return _packumentCache;
}
/*@__NO_SIDE_EFFECTS__*/
function getPacoteCachePath() {
	if (_pacoteCachePath === void 0) try {
		const PacoteFetcherBase = require_primordials_reflect.ReflectGetPrototypeOf(src_external_pacote.default.RegistryFetcher.prototype)?.constructor;
		/* c8 ignore start */
		const cachePath = PacoteFetcherBase ? new PacoteFetcherBase("x", {}).cache : "";
		_pacoteCachePath = cachePath ? /* @__PURE__ */ require_paths_normalize.normalizePath(cachePath) : "";
	} catch {
		_pacoteCachePath = "";
	}
	return _pacoteCachePath;
}

//#endregion
exports.AT_LATEST = AT_LATEST;
exports.LATEST = LATEST;
exports.PACKAGE = PACKAGE;
exports.PACKAGE_DEFAULT_VERSION = PACKAGE_DEFAULT_VERSION;
exports.clearPackumentCache = clearPackumentCache;
exports.getLifecycleScriptNames = getLifecycleScriptNames;
exports.getPackageDefaultNodeRange = getPackageDefaultNodeRange;
exports.getPackageDefaultSocketCategories = getPackageDefaultSocketCategories;
exports.getPackageExtensions = getPackageExtensions;
exports.getPackumentCache = getPackumentCache;
exports.getPacoteCachePath = getPacoteCachePath;