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

//#region src/paths/predicates.ts
/**
* @file Path predicates — `is*` checks for path shape and kind. Split out of
*   `paths/normalize.ts` for file-size hygiene. Pure boolean predicates over
*   paths and character codes.
*
*   - `isAbsolute`, `isRelative` — root-anchoring shape
*   - `isPath` — file-path vs package-spec vs URL discriminator
*   - `isNodeModules`, `isUnixPath` — content-pattern checks
*   - `isPathSeparator`, `isWindowsDeviceRoot` — char-code primitives
*/
/**
* Check if a path is absolute.
*
* Handles both POSIX (`/...`) and Windows (drive-letter, UNC, device) absolute
* path shapes.
*
* @example
*   ;```typescript
*   isAbsolute('/home/user') // true
*   isAbsolute('C:\\Windows') // true on Windows
*   isAbsolute('../relative') // false
*   ```
*
* @param {string | Buffer | URL} pathLike - The path to check.
*
* @returns {boolean} `true` if absolute, `false` otherwise
*/
/*@__NO_SIDE_EFFECTS__*/
function isAbsolute(pathLike) {
	const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
	const { length } = filepath;
	if (length === 0) return false;
	const code = require_primordials_string.StringPrototypeCharCodeAt(filepath, 0);
	if (code === 47) return true;
	if (code === 92) return true;
	/* c8 ignore start - Windows drive-letter detection. */
	if (require_constants_platform.WIN32 && length > 2) {
		if (/* @__PURE__ */ isWindowsDeviceRoot(code) && require_primordials_string.StringPrototypeCharCodeAt(filepath, 1) === 58 && /* @__PURE__ */ isPathSeparator(require_primordials_string.StringPrototypeCharCodeAt(filepath, 2))) return true;
	}
	/* c8 ignore stop */
	return false;
}
/**
* Check if a path contains a `node_modules` directory segment.
*
* Matches `node_modules` only as a complete path segment.
*
* @example
*   ;```typescript
*   isNodeModules('/project/node_modules/package') // true
*   isNodeModules('/src/my_node_modules_backup') // false
*   ```
*
* @param {string | Buffer | URL} pathLike - The path to check.
*
* @returns {boolean} `true` if the path contains `node_modules`
*/
/*@__NO_SIDE_EFFECTS__*/
function isNodeModules(pathLike) {
	return require_primordials_regexp.RegExpPrototypeTest(require_paths__internal.nodeModulesPathRegExp, /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike));
}
/**
* Check if a value is a valid file path (absolute or relative).
*
* Distinguishes between file paths and other string formats like package names,
* URLs, or bare module specifiers.
*
* @example
*   ;```typescript
*   isPath('/absolute/path') // true
*   isPath('./relative/path') // true
*   isPath('@scope/name/subpath') // true
*   isPath('lodash') // false
*   isPath('http://example.com') // false
*   ```
*
* @param {string | Buffer | URL} pathLike - The value to check.
*
* @returns {boolean} `true` if the value is a valid file path
*/
/*@__NO_SIDE_EFFECTS__*/
function isPath(pathLike) {
	const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
	if (typeof filepath !== "string" || filepath.length === 0) return false;
	if (/^[a-z][a-z0-9+.-]+:/i.test(filepath)) return false;
	if (filepath === "." || filepath === "..") return true;
	if (/* @__PURE__ */ isAbsolute(filepath)) return true;
	if (filepath.includes("/") || filepath.includes("\\")) {
		if (require_primordials_string.StringPrototypeStartsWith(filepath, "@") && !require_primordials_string.StringPrototypeStartsWith(filepath, "@/")) {
			const parts = filepath.split("/");
			if (parts.length <= 2 && !parts[1]?.includes("\\")) return false;
		}
		return true;
	}
	return false;
}
/**
* Check if a character code is a path separator (`/` or `\`).
*
* @example
*   ;```typescript
*   isPathSeparator(47) // true — '/'
*   isPathSeparator(92) // true — '\'
*   isPathSeparator(65) // false — 'A'
*   ```
*
* @param {number} code - The character code to check.
*
* @returns {boolean} `true` if separator
*/
/*@__NO_SIDE_EFFECTS__*/
function isPathSeparator(code) {
	return code === 47 || code === 92;
}
/**
* Check if a path is relative (i.e., not absolute).
*
* Empty strings are treated as relative.
*
* @example
*   ;```typescript
*   isRelative('./src/index.js') // true
*   isRelative('src/file.js') // true
*   isRelative('/home/user') // false
*   ```
*
* @param {string | Buffer | URL} pathLike - The path to check.
*
* @returns {boolean} `true` if the path is relative
*/
/*@__NO_SIDE_EFFECTS__*/
function isRelative(pathLike) {
	const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
	/* c8 ignore start */
	if (typeof filepath !== "string") return false;
	/* c8 ignore stop */
	if (filepath.length === 0) return true;
	return !/* @__PURE__ */ isAbsolute(filepath);
}
/**
* Check if a path uses MSYS/Git Bash Unix-style drive letter notation.
*
* Detects paths in the format `/c/...` where a single letter after the leading
* slash represents a Windows drive letter.
*
* @example
*   ;```typescript
*   isUnixPath('/c/tools/bin') // true
*   isUnixPath('/tmp/build') // false
*   isUnixPath('C:/Windows') // false
*   ```
*
* @param {string | Buffer | URL} pathLike - The path to check.
*
* @returns {boolean} `true` if the path uses MSYS drive letter notation
*/
/*@__NO_SIDE_EFFECTS__*/
function isUnixPath(pathLike) {
	const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
	return typeof filepath === "string" && require_primordials_regexp.RegExpPrototypeTest(require_paths__internal.msysDriveRegExp, filepath);
}
/**
* Check if a character code is a Windows device root letter (A-Z / a-z).
*
* @example
*   ;```typescript
*   isWindowsDeviceRoot(67) // true  — 'C'
*   isWindowsDeviceRoot(99) // true  — 'c'
*   isWindowsDeviceRoot(58) // false — ':'
*   ```
*
* @param {number} code - The character code to check.
*
* @returns {boolean} `true` if valid drive-letter code
*/
/* c8 ignore start - Only called from Windows-only branches. */
/*@__NO_SIDE_EFFECTS__*/
function isWindowsDeviceRoot(code) {
	return code >= 65 && code <= 90 || code >= 97 && code <= 122;
}
/* c8 ignore stop */

//#endregion
exports.isAbsolute = isAbsolute;
exports.isNodeModules = isNodeModules;
exports.isPath = isPath;
exports.isPathSeparator = isPathSeparator;
exports.isRelative = isRelative;
exports.isUnixPath = isUnixPath;
exports.isWindowsDeviceRoot = isWindowsDeviceRoot;