/**
 * @file Environment variable rewiring utilities for testing. Uses
 *   AsyncLocalStorage for context-isolated overrides that work with concurrent
 *   tests. Features:
 *
 *   - Context-isolated overrides via withEnv() for advanced use cases
 *   - Test-friendly setEnv/clearEnv/resetEnv that work in beforeEach/afterEach
 *   - Compatible with vi.stubEnv() - reads from process.env as final fallback
 *   - Thread-safe for concurrent test execution
 */
/**
 * Lazily load the async_hooks module to avoid Webpack errors.
 *
 * @private
 */
export declare function getAsyncHooks(): typeof import('node:async_hooks');
/**
 * Clear a specific environment variable override.
 *
 * @example
 *   ;```typescript
 *   import { setEnv, clearEnv } from '@socketsecurity/lib/env/rewire'
 *
 *   setEnv('CI', '1')
 *   clearEnv('CI')
 *   ```
 *
 * @param key - The environment variable name to clear.
 */
export declare function clearEnv(key: string): void;
/**
 * Get an environment variable value, checking overrides first.
 *
 * Resolution order: 1. Isolated overrides (temporary - set via
 * withEnv/withEnvSync) 2. Shared overrides (persistent - set via setEnv in
 * beforeEach) 3. process.env (including vi.stubEnv modifications)
 *
 * @example
 *   ;```typescript
 *   import { getEnvValue } from '@socketsecurity/lib/env/rewire'
 *
 *   const value = getEnvValue('NODE_ENV')
 *   // e.g. 'production' or undefined
 *   ```
 *
 * @internal Used by env getters to support test rewiring
 */
export declare function getEnvValue(key: string): string | undefined;
/**
 * Check if an environment variable has been overridden.
 *
 * @example
 *   ;```typescript
 *   import { setEnv, hasOverride } from '@socketsecurity/lib/env/rewire'
 *
 *   hasOverride('CI') // false
 *   setEnv('CI', '1')
 *   hasOverride('CI') // true
 *   ```
 *
 * @param key - The environment variable name to check.
 *
 * @returns `true` if the variable has been overridden, `false` otherwise
 */
export declare function hasOverride(key: string): boolean;
/**
 * Check if an environment variable exists (has a key), checking overrides
 * first.
 *
 * Resolution order: 1. Isolated overrides (temporary - set via
 * withEnv/withEnvSync) 2. Shared overrides (persistent - set via setEnv in
 * beforeEach) 3. process.env (including vi.stubEnv modifications)
 *
 * @example
 *   ;```typescript
 *   import { isInEnv } from '@socketsecurity/lib/env/rewire'
 *
 *   isInEnv('PATH') // true (usually set)
 *   isInEnv('MISSING') // false
 *   ```
 *
 * @internal Used by env getters to check for key presence (not value truthiness)
 */
export declare function isInEnv(key: string): boolean;
/**
 * Clear all environment variable overrides. Useful in afterEach hooks to ensure
 * clean test state.
 *
 * @example
 *   ;```typescript
 *   import { resetEnv } from './rewire'
 *
 *   afterEach(() => {
 *     resetEnv()
 *   })
 *   ```
 */
export declare function resetEnv(): void;
/**
 * Set an environment variable override for testing. This does not modify
 * process.env, only affects env getters.
 *
 * Works in test hooks (beforeEach) without needing AsyncLocalStorage context.
 * Vitest's module isolation ensures each test file has independent overrides.
 *
 * @example
 *   ;```typescript
 *   import { setEnv, resetEnv } from './rewire'
 *   import { getCI } from './ci'
 *
 *   beforeEach(() => {
 *     setEnv('CI', '1')
 *   })
 *
 *   afterEach(() => {
 *     resetEnv()
 *   })
 *
 *   it('should detect CI environment', () => {
 *     expect(getCI()).toBe(true)
 *   })
 *   ```
 */
export declare function setEnv(key: string, value: string | undefined): void;
/**
 * Run code with environment overrides in an isolated AsyncLocalStorage context.
 * Creates true context isolation - overrides don't leak to concurrent code.
 *
 * Useful for tests that need temporary overrides without affecting other tests
 * or for nested override scenarios.
 *
 * @example
 *   ;```typescript
 *   import { withEnv } from './rewire'
 *   import { getCI } from './ci'
 *
 *   // Temporary override in isolated context
 *   await withEnv({ CI: '1' }, async () => {
 *     expect(getCI()).toBe(true)
 *   })
 *   expect(getCI()).toBe(false) // Override is gone
 *   ```
 *
 * @example
 *   ;```typescript
 *   // Nested overrides work correctly
 *   setEnv('CI', '1') // Shared override (persistent)
 *
 *   await withEnv({ CI: '0' }, async () => {
 *     expect(getCI()).toBe(false) // Isolated override takes precedence
 *   })
 *
 *   expect(getCI()).toBe(true) // Back to shared override
 *   ```
 */
export declare function withEnv<T>(overrides: Record<string, string | undefined>, fn: () => T | Promise<T>): Promise<T>;
/**
 * Synchronous version of withEnv for non-async code.
 *
 * @example
 *   ;```typescript
 *   import { withEnvSync } from './rewire'
 *   import { getCI } from './ci'
 *
 *   const result = withEnvSync({ CI: '1' }, () => {
 *     return getCI()
 *   })
 *   expect(result).toBe(true)
 *   ```
 */
export declare function withEnvSync<T>(overrides: Record<string, string | undefined>, fn: () => T): T;
