"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_string = require('../primordials/string.js');
const require_paths_normalize = require('../paths/normalize.js');
const require_primordials_array = require('../primordials/array.js');
const require_primordials_map_set = require('../primordials/map-set.js');
const require_node_fs = require('../node/fs.js');
const require_globs_defaults = require('./defaults.js');
const require_node_fs_promises = require('../node/fs-promises.js');

//#region src/globs/_internal.ts
/**
* @file Private internals for `globs/*` modules — lazy module accessors,
*   normalization helpers, and the matcher LRU cache. The `defaultIgnore` list
*   lives in the public `defaults.ts` file; this file re-exports it so
*   co-located helpers can import everything through one path.
*/
const MATCHER_CACHE_MAX_SIZE = 100;
const matcherCache = new require_primordials_map_set.MapCtor();
let _fastGlob;
let _picomatch;
/*@__NO_SIDE_EFFECTS__*/
function getFastGlob() {
	if (_fastGlob === void 0) _fastGlob = /*@__PURE__*/ require("../external/fast-glob.js");
	return _fastGlob;
}
/*@__NO_SIDE_EFFECTS__*/
function getPicomatch() {
	if (_picomatch === void 0) _picomatch = /*@__PURE__*/ require("../external/picomatch.js");
	return _picomatch;
}
/**
* Glob results are normalized to forward slashes regardless of the backend
* (node:fs.glob returns native-OS separators on Windows; fast-glob already
* returns forward slashes). Single contract: callers don't have to think about
* separators per platform. Routes through `paths/normalize.normalizePath` so
* this stays consistent with every other path-shaped string in the lib.
*/
function normalizeGlobResults(out) {
	for (let i = 0; i < out.length; i += 1) out[i] = /* @__PURE__ */ require_paths_normalize.normalizePath(out[i]);
	return out;
}
/**
* Normalize a user-provided ignore array by running every entry through
* stripTrailingSlash. Returns undefined when `ignore` is not an array so
* callers can skip merging the option entirely.
*
* Uses a pre-sized for-loop instead of `.map`: socket-lib uses primordials (the
* prototype `Array.prototype.map` can be intercepted or replaced by user code
* at module load), and a hand-rolled loop is also marginally faster — no
* callback indirection, no growth of the result array.
*/
function normalizeIgnorePatterns(ignore) {
	if (!require_primordials_array.ArrayIsArray(ignore)) return;
	const source = ignore;
	const { length } = source;
	const normalized = new require_primordials_array.ArrayCtor(length);
	for (let i = 0; i < length; i++) normalized[i] = stripTrailingSlash(source[i]);
	return normalized;
}
/**
* Strip a trailing `/` from a glob pattern so fast-glob's deep filter matches
* it. See header comment in `glob.ts` for the full rationale — shortest
* summary: a `dist/` ignore pattern lets fast-glob walk the whole subtree
* before filtering, while `dist` (no slash) skips the walk entirely.
*
* CharCode 47 is `/`. Reading it that way avoids a per-call string allocation
* for the literal — primordials-friendly, no behavior change vs.
* `pattern.endsWith('/')`.
*/
function stripTrailingSlash(pattern) {
	if (pattern.length > 1 && require_primordials_string.StringPrototypeCharCodeAt(pattern, pattern.length - 1) === 47) return pattern.slice(0, -1);
	return pattern;
}

//#endregion
exports.MATCHER_CACHE_MAX_SIZE = MATCHER_CACHE_MAX_SIZE;
exports.defaultIgnore = require_globs_defaults.defaultIgnore;
exports.getFastGlob = getFastGlob;
exports.getFs = require_node_fs.getNodeFs;
exports.getFsPromises = require_node_fs_promises.getNodeFsPromises;
exports.getPicomatch = getPicomatch;
exports.matcherCache = matcherCache;
exports.normalizeGlobResults = normalizeGlobResults;
exports.normalizeIgnorePatterns = normalizeIgnorePatterns;
exports.stripTrailingSlash = stripTrailingSlash;