"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');
let node_process = require("node:process");
node_process = require_runtime.__toESM(node_process);

//#region src/shadow/skip.ts
/**
* @file Shadow binary installation utilities for Socket ecosystem. Provides
*   logic to determine when shadow binary installation should be skipped.
*/
/**
* Determines if shadow binaries should be installed. Shadows should NOT be
* installed when: - Running in a temporary execution context (exec/npx/dlx) -
* On Windows with an existing binary path (required for Windows to function)
*
* @example
*   ;```typescript
*   if (shouldSkipShadow(binPath, { cwd: process.cwd() })) {
*     console.log('Skipping shadow binary installation')
*   }
*   ```
*
* @param binPath - Path to the binary being shadowed.
* @param options - Configuration options.
* @param options.cwd - Current working directory path to check.
* @param options.win32 - Whether running on Windows.
*
* @returns True if shadow installation should be skipped
*/
function shouldSkipShadow(binPath, options) {
	const { cwd = node_process.default.cwd(), win32 = false } = {
		__proto__: null,
		...options
	};
	if (win32 && binPath) return true;
	const userAgent = node_process.default.env["npm_config_user_agent"];
	if (userAgent?.includes("exec") || userAgent?.includes("npx") || userAgent?.includes("dlx")) return true;
	const normalizedCwd = /* @__PURE__ */ require_paths_normalize.normalizePath(cwd);
	const npmCache = node_process.default.env["npm_config_cache"];
	if (npmCache && normalizedCwd.includes(/* @__PURE__ */ require_paths_normalize.normalizePath(npmCache))) return true;
	return [
		"_npx",
		".pnpm-store",
		"dlx-",
		".yarn/$$",
		"AppData/Local/Temp/xfs-"
	].some((pattern) => normalizedCwd.includes(pattern));
}

//#endregion
exports.shouldSkipShadow = shouldSkipShadow;