"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_string = require('../../../primordials/string.js');

//#region src/eco/npm/pnpm/parse-pnpm-package-id-v6-v9.ts
/**
* @file `parsePnpmPackageIdV6V9(pkgId)` — extracts `{ name, version }` from a
*   pnpm v6/v9 package key. Spec forms handled:
*
*   - `name@version` → unscoped
*   - `@scope/name@version` → scoped (last `@` is the splitter)
*   - `name@version(peer)` → peer-dep suffix stripped Returns `{ name: pkgId,
*     version: '0.0.0' }` for unparseable input.
*/
function parsePnpmPackageIdV6V9(pkgId) {
	const parenIdx = require_primordials_string.StringPrototypeIndexOf(pkgId, "(");
	const withoutPeerSuffix = parenIdx !== -1 ? require_primordials_string.StringPrototypeSlice(pkgId, 0, parenIdx) : pkgId;
	if (withoutPeerSuffix[0] === "@") {
		const lastAtIdx = require_primordials_string.StringPrototypeLastIndexOf(withoutPeerSuffix, "@");
		if (lastAtIdx > 0) return {
			name: require_primordials_string.StringPrototypeSlice(withoutPeerSuffix, 0, lastAtIdx),
			version: require_primordials_string.StringPrototypeSlice(withoutPeerSuffix, lastAtIdx + 1)
		};
	} else {
		const atIdx = require_primordials_string.StringPrototypeIndexOf(withoutPeerSuffix, "@");
		if (atIdx > 0) return {
			name: require_primordials_string.StringPrototypeSlice(withoutPeerSuffix, 0, atIdx),
			version: require_primordials_string.StringPrototypeSlice(withoutPeerSuffix, atIdx + 1)
		};
	}
	return {
		name: pkgId,
		version: "0.0.0"
	};
}

//#endregion
exports.parsePnpmPackageIdV6V9 = parsePnpmPackageIdV6V9;