storybook
Version:
Storybook: Develop, document, and test UI components in isolation
1,182 lines (1,160 loc) • 989 kB
JavaScript
import CJS_COMPAT_NODE_URL_ret6ivvuly from 'node:url';
import CJS_COMPAT_NODE_PATH_ret6ivvuly from 'node:path';
import CJS_COMPAT_NODE_MODULE_ret6ivvuly from "node:module";
var __filename = CJS_COMPAT_NODE_URL_ret6ivvuly.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_ret6ivvuly.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_ret6ivvuly.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
require_picomatch,
toPath,
traversePathUp
} from "./chunk-2W743EA3.js";
import {
versions_default
} from "./chunk-BV2M6I75.js";
import {
logger
} from "./chunk-3BPHYDN5.js";
import {
BUN_LOCKFILE,
BUN_LOCKFILE_BINARY,
NPM_LOCKFILE,
PNPM_LOCKFILE,
YARN_LOCKFILE,
findFilesUp,
getProjectRoot,
normalizeStoryPath
} from "./chunk-ZJMC6JVU.js";
import {
any,
detectIndent,
from,
invariant,
up,
up2
} from "./chunk-XQ72YXLB.js";
import {
importModule,
resolveModulePath,
resolvePackageDir,
safeResolveModule
} from "./chunk-UHVMRW65.js";
import {
join,
parse,
resolve
} from "./chunk-TGEJ6REI.js";
import {
require_dist
} from "./chunk-XSYEGQMM.js";
import {
require_picocolors
} from "./chunk-BV5YQP4B.js";
import {
slash
} from "./chunk-JQXQP7A4.js";
import {
glob,
globSync
} from "./chunk-2E2JVUNS.js";
import {
__commonJS,
__esm,
__export,
__require,
__toCommonJS,
__toESM
} from "./chunk-5IHDTMLC.js";
// ../../node_modules/resolve/lib/homedir.js
var require_homedir = __commonJS({
"../../node_modules/resolve/lib/homedir.js"(exports, module) {
"use strict";
var os2 = __require("os");
module.exports = os2.homedir || function() {
var home = process.env.HOME, user = process.env.LOGNAME || process.env.USER || process.env.LNAME || process.env.USERNAME;
return process.platform === "win32" ? process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || home || null : process.platform === "darwin" ? home || (user ? "/Users/" + user : null) : process.platform === "linux" ? home || (process.getuid() === 0 ? "/root" : user ? "/home/" + user : null) : home || null;
};
}
});
// ../../node_modules/resolve/lib/caller.js
var require_caller = __commonJS({
"../../node_modules/resolve/lib/caller.js"(exports, module) {
module.exports = function() {
var origPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack2) {
return stack2;
};
var stack = new Error().stack;
return Error.prepareStackTrace = origPrepareStackTrace, stack[2].getFileName();
};
}
});
// ../../node_modules/path-parse/index.js
var require_path_parse = __commonJS({
"../../node_modules/path-parse/index.js"(exports, module) {
"use strict";
var isWindows = process.platform === "win32", splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/, win32 = {};
function win32SplitPath(filename) {
return splitWindowsRe.exec(filename).slice(1);
}
win32.parse = function(pathString) {
if (typeof pathString != "string")
throw new TypeError(
"Parameter 'pathString' must be a string, not " + typeof pathString
);
var allParts = win32SplitPath(pathString);
if (!allParts || allParts.length !== 5)
throw new TypeError("Invalid path '" + pathString + "'");
return {
root: allParts[1],
dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1),
base: allParts[2],
ext: allParts[4],
name: allParts[3]
};
};
var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/, posix4 = {};
function posixSplitPath(filename) {
return splitPathRe.exec(filename).slice(1);
}
posix4.parse = function(pathString) {
if (typeof pathString != "string")
throw new TypeError(
"Parameter 'pathString' must be a string, not " + typeof pathString
);
var allParts = posixSplitPath(pathString);
if (!allParts || allParts.length !== 5)
throw new TypeError("Invalid path '" + pathString + "'");
return {
root: allParts[1],
dir: allParts[0].slice(0, -1),
base: allParts[2],
ext: allParts[4],
name: allParts[3]
};
};
isWindows ? module.exports = win32.parse : module.exports = posix4.parse;
module.exports.posix = posix4.parse;
module.exports.win32 = win32.parse;
}
});
// ../../node_modules/resolve/lib/node-modules-paths.js
var require_node_modules_paths = __commonJS({
"../../node_modules/resolve/lib/node-modules-paths.js"(exports, module) {
var path5 = __require("path"), parse4 = path5.parse || require_path_parse(), driveLetterRegex = /^([A-Za-z]:)/, uncPathRegex = /^\\\\/, getNodeModulesDirs = function(absoluteStart, modules) {
var prefix = "/";
driveLetterRegex.test(absoluteStart) ? prefix = "" : uncPathRegex.test(absoluteStart) && (prefix = "\\\\");
for (var paths = [absoluteStart], parsed = parse4(absoluteStart); parsed.dir !== paths[paths.length - 1]; )
paths.push(parsed.dir), parsed = parse4(parsed.dir);
return paths.reduce(function(dirs, aPath) {
return dirs.concat(modules.map(function(moduleDir) {
return path5.resolve(prefix, aPath, moduleDir);
}));
}, []);
};
module.exports = function(start, opts, request) {
var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ["node_modules"];
if (opts && typeof opts.paths == "function")
return opts.paths(
request,
start,
function() {
return getNodeModulesDirs(start, modules);
},
opts
);
var dirs = getNodeModulesDirs(start, modules);
return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
};
}
});
// ../../node_modules/resolve/lib/normalize-options.js
var require_normalize_options = __commonJS({
"../../node_modules/resolve/lib/normalize-options.js"(exports, module) {
var path5 = __require("path");
module.exports = function(_, opts) {
if (opts = opts || {}, opts.forceNodeResolution || !process.versions.pnp)
return opts;
let { findPnpApi } = __require("module"), runPnpResolution = (request, basedir) => {
let parts = request.match(/^((?:@[^/]+\/)?[^/]+)(\/.*)?/);
if (!parts)
throw new Error(`Assertion failed: Expected the "resolve" package to call the "paths" callback with package names only (got "${request}")`);
basedir.charAt(basedir.length - 1) !== "/" && (basedir = path5.join(basedir, "/"));
let api = findPnpApi(basedir);
if (api === null)
return;
let manifestPath;
try {
manifestPath = api.resolveToUnqualified(`${parts[1]}/package.json`, basedir, { considerBuiltins: !1 });
} catch {
return null;
}
if (manifestPath === null)
throw new Error(`Assertion failed: The resolution thinks that "${parts[1]}" is a Node builtin`);
let packagePath = path5.dirname(manifestPath), unqualifiedPath = typeof parts[2] < "u" ? path5.join(packagePath, parts[2]) : packagePath;
return { packagePath, unqualifiedPath };
}, runPnpResolutionOnArray = (request, paths2) => {
for (let i2 = 0; i2 < paths2.length; i2++) {
let resolution = runPnpResolution(request, paths2[i2]);
if (resolution || i2 === paths2.length - 1)
return resolution;
}
return null;
}, originalPaths = Array.isArray(opts.paths) ? opts.paths : [], packageIterator = (request, basedir, getCandidates, opts2) => {
let pathsToTest = [basedir].concat(originalPaths), resolution = runPnpResolutionOnArray(request, pathsToTest);
return resolution == null ? getCandidates() : [resolution.unqualifiedPath];
}, paths = (request, basedir, getNodeModulePaths, opts2) => {
let pathsToTest = [basedir].concat(originalPaths), resolution = runPnpResolutionOnArray(request, pathsToTest);
if (resolution == null)
return getNodeModulePaths().concat(originalPaths);
let nodeModules = path5.dirname(resolution.packagePath);
return request.match(/^@[^/]+\//) && (nodeModules = path5.dirname(nodeModules)), [nodeModules];
}, isInsideIterator = !1;
return opts.__skipPackageIterator || (opts.packageIterator = function(request, basedir, getCandidates, opts2) {
isInsideIterator = !0;
try {
return packageIterator(request, basedir, getCandidates, opts2);
} finally {
isInsideIterator = !1;
}
}), opts.paths = function(request, basedir, getNodeModulePaths, opts2) {
return isInsideIterator ? getNodeModulePaths().concat(originalPaths) : paths(request, basedir, getNodeModulePaths, opts2);
}, opts;
};
}
});
// ../../node_modules/function-bind/implementation.js
var require_implementation = __commonJS({
"../../node_modules/function-bind/implementation.js"(exports, module) {
"use strict";
var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ", toStr = Object.prototype.toString, max = Math.max, funcType = "[object Function]", concatty = function(a2, b) {
for (var arr = [], i2 = 0; i2 < a2.length; i2 += 1)
arr[i2] = a2[i2];
for (var j = 0; j < b.length; j += 1)
arr[j + a2.length] = b[j];
return arr;
}, slicy = function(arrLike, offset) {
for (var arr = [], i2 = offset || 0, j = 0; i2 < arrLike.length; i2 += 1, j += 1)
arr[j] = arrLike[i2];
return arr;
}, joiny = function(arr, joiner) {
for (var str = "", i2 = 0; i2 < arr.length; i2 += 1)
str += arr[i2], i2 + 1 < arr.length && (str += joiner);
return str;
};
module.exports = function(that) {
var target = this;
if (typeof target != "function" || toStr.apply(target) !== funcType)
throw new TypeError(ERROR_MESSAGE + target);
for (var args = slicy(arguments, 1), bound, binder = function() {
if (this instanceof bound) {
var result = target.apply(
this,
concatty(args, arguments)
);
return Object(result) === result ? result : this;
}
return target.apply(
that,
concatty(args, arguments)
);
}, boundLength = max(0, target.length - args.length), boundArgs = [], i2 = 0; i2 < boundLength; i2++)
boundArgs[i2] = "$" + i2;
if (bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder), target.prototype) {
var Empty = function() {
};
Empty.prototype = target.prototype, bound.prototype = new Empty(), Empty.prototype = null;
}
return bound;
};
}
});
// ../../node_modules/function-bind/index.js
var require_function_bind = __commonJS({
"../../node_modules/function-bind/index.js"(exports, module) {
"use strict";
var implementation = require_implementation();
module.exports = Function.prototype.bind || implementation;
}
});
// ../../node_modules/hasown/index.js
var require_hasown = __commonJS({
"../../node_modules/hasown/index.js"(exports, module) {
"use strict";
var call = Function.prototype.call, $hasOwn = Object.prototype.hasOwnProperty, bind = require_function_bind();
module.exports = bind.call(call, $hasOwn);
}
});
// ../../node_modules/is-core-module/core.json
var require_core = __commonJS({
"../../node_modules/is-core-module/core.json"(exports, module) {
module.exports = {
assert: !0,
"node:assert": [">= 14.18 && < 15", ">= 16"],
"assert/strict": ">= 15",
"node:assert/strict": ">= 16",
async_hooks: ">= 8",
"node:async_hooks": [">= 14.18 && < 15", ">= 16"],
buffer_ieee754: ">= 0.5 && < 0.9.7",
buffer: !0,
"node:buffer": [">= 14.18 && < 15", ">= 16"],
child_process: !0,
"node:child_process": [">= 14.18 && < 15", ">= 16"],
cluster: ">= 0.5",
"node:cluster": [">= 14.18 && < 15", ">= 16"],
console: !0,
"node:console": [">= 14.18 && < 15", ">= 16"],
constants: !0,
"node:constants": [">= 14.18 && < 15", ">= 16"],
crypto: !0,
"node:crypto": [">= 14.18 && < 15", ">= 16"],
_debug_agent: ">= 1 && < 8",
_debugger: "< 8",
dgram: !0,
"node:dgram": [">= 14.18 && < 15", ">= 16"],
diagnostics_channel: [">= 14.17 && < 15", ">= 15.1"],
"node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"],
dns: !0,
"node:dns": [">= 14.18 && < 15", ">= 16"],
"dns/promises": ">= 15",
"node:dns/promises": ">= 16",
domain: ">= 0.7.12",
"node:domain": [">= 14.18 && < 15", ">= 16"],
events: !0,
"node:events": [">= 14.18 && < 15", ">= 16"],
freelist: "< 6",
fs: !0,
"node:fs": [">= 14.18 && < 15", ">= 16"],
"fs/promises": [">= 10 && < 10.1", ">= 14"],
"node:fs/promises": [">= 14.18 && < 15", ">= 16"],
_http_agent: ">= 0.11.1",
"node:_http_agent": [">= 14.18 && < 15", ">= 16"],
_http_client: ">= 0.11.1",
"node:_http_client": [">= 14.18 && < 15", ">= 16"],
_http_common: ">= 0.11.1",
"node:_http_common": [">= 14.18 && < 15", ">= 16"],
_http_incoming: ">= 0.11.1",
"node:_http_incoming": [">= 14.18 && < 15", ">= 16"],
_http_outgoing: ">= 0.11.1",
"node:_http_outgoing": [">= 14.18 && < 15", ">= 16"],
_http_server: ">= 0.11.1",
"node:_http_server": [">= 14.18 && < 15", ">= 16"],
http: !0,
"node:http": [">= 14.18 && < 15", ">= 16"],
http2: ">= 8.8",
"node:http2": [">= 14.18 && < 15", ">= 16"],
https: !0,
"node:https": [">= 14.18 && < 15", ">= 16"],
inspector: ">= 8",
"node:inspector": [">= 14.18 && < 15", ">= 16"],
"inspector/promises": [">= 19"],
"node:inspector/promises": [">= 19"],
_linklist: "< 8",
module: !0,
"node:module": [">= 14.18 && < 15", ">= 16"],
net: !0,
"node:net": [">= 14.18 && < 15", ">= 16"],
"node-inspect/lib/_inspect": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
os: !0,
"node:os": [">= 14.18 && < 15", ">= 16"],
path: !0,
"node:path": [">= 14.18 && < 15", ">= 16"],
"path/posix": ">= 15.3",
"node:path/posix": ">= 16",
"path/win32": ">= 15.3",
"node:path/win32": ">= 16",
perf_hooks: ">= 8.5",
"node:perf_hooks": [">= 14.18 && < 15", ">= 16"],
process: ">= 1",
"node:process": [">= 14.18 && < 15", ">= 16"],
punycode: ">= 0.5",
"node:punycode": [">= 14.18 && < 15", ">= 16"],
querystring: !0,
"node:querystring": [">= 14.18 && < 15", ">= 16"],
readline: !0,
"node:readline": [">= 14.18 && < 15", ">= 16"],
"readline/promises": ">= 17",
"node:readline/promises": ">= 17",
repl: !0,
"node:repl": [">= 14.18 && < 15", ">= 16"],
"node:sea": [">= 20.12 && < 21", ">= 21.7"],
smalloc: ">= 0.11.5 && < 3",
"node:sqlite": [">= 22.13 && < 23", ">= 23.4"],
_stream_duplex: ">= 0.9.4",
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
_stream_transform: ">= 0.9.4",
"node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
_stream_wrap: ">= 1.4.1",
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
_stream_passthrough: ">= 0.9.4",
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
_stream_readable: ">= 0.9.4",
"node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
_stream_writable: ">= 0.9.4",
"node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
stream: !0,
"node:stream": [">= 14.18 && < 15", ">= 16"],
"stream/consumers": ">= 16.7",
"node:stream/consumers": ">= 16.7",
"stream/promises": ">= 15",
"node:stream/promises": ">= 16",
"stream/web": ">= 16.5",
"node:stream/web": ">= 16.5",
string_decoder: !0,
"node:string_decoder": [">= 14.18 && < 15", ">= 16"],
sys: [">= 0.4 && < 0.7", ">= 0.8"],
"node:sys": [">= 14.18 && < 15", ">= 16"],
"test/reporters": ">= 19.9 && < 20.2",
"node:test/reporters": [">= 18.17 && < 19", ">= 19.9", ">= 20"],
"test/mock_loader": ">= 22.3 && < 22.7",
"node:test/mock_loader": ">= 22.3 && < 22.7",
"node:test": [">= 16.17 && < 17", ">= 18"],
timers: !0,
"node:timers": [">= 14.18 && < 15", ">= 16"],
"timers/promises": ">= 15",
"node:timers/promises": ">= 16",
_tls_common: ">= 0.11.13",
"node:_tls_common": [">= 14.18 && < 15", ">= 16"],
_tls_legacy: ">= 0.11.3 && < 10",
_tls_wrap: ">= 0.11.3",
"node:_tls_wrap": [">= 14.18 && < 15", ">= 16"],
tls: !0,
"node:tls": [">= 14.18 && < 15", ">= 16"],
trace_events: ">= 10",
"node:trace_events": [">= 14.18 && < 15", ">= 16"],
tty: !0,
"node:tty": [">= 14.18 && < 15", ">= 16"],
url: !0,
"node:url": [">= 14.18 && < 15", ">= 16"],
util: !0,
"node:util": [">= 14.18 && < 15", ">= 16"],
"util/types": ">= 15.3",
"node:util/types": ">= 16",
"v8/tools/arguments": ">= 10 && < 12",
"v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
v8: ">= 1",
"node:v8": [">= 14.18 && < 15", ">= 16"],
vm: !0,
"node:vm": [">= 14.18 && < 15", ">= 16"],
wasi: [">= 13.4 && < 13.5", ">= 18.17 && < 19", ">= 20"],
"node:wasi": [">= 18.17 && < 19", ">= 20"],
worker_threads: ">= 11.7",
"node:worker_threads": [">= 14.18 && < 15", ">= 16"],
zlib: ">= 0.5",
"node:zlib": [">= 14.18 && < 15", ">= 16"]
};
}
});
// ../../node_modules/is-core-module/index.js
var require_is_core_module = __commonJS({
"../../node_modules/is-core-module/index.js"(exports, module) {
"use strict";
var hasOwn = require_hasown();
function specifierIncluded(current, specifier) {
for (var nodeParts = current.split("."), parts = specifier.split(" "), op = parts.length > 1 ? parts[0] : "=", versionParts = (parts.length > 1 ? parts[1] : parts[0]).split("."), i2 = 0; i2 < 3; ++i2) {
var cur = parseInt(nodeParts[i2] || 0, 10), ver = parseInt(versionParts[i2] || 0, 10);
if (cur !== ver)
return op === "<" ? cur < ver : op === ">=" ? cur >= ver : !1;
}
return op === ">=";
}
function matchesRange(current, range) {
var specifiers = range.split(/ ?&& ?/);
if (specifiers.length === 0)
return !1;
for (var i2 = 0; i2 < specifiers.length; ++i2)
if (!specifierIncluded(current, specifiers[i2]))
return !1;
return !0;
}
function versionIncluded(nodeVersion, specifierValue) {
if (typeof specifierValue == "boolean")
return specifierValue;
var current = typeof nodeVersion > "u" ? process.versions && process.versions.node : nodeVersion;
if (typeof current != "string")
throw new TypeError(typeof nodeVersion > "u" ? "Unable to determine current node version" : "If provided, a valid node version is required");
if (specifierValue && typeof specifierValue == "object") {
for (var i2 = 0; i2 < specifierValue.length; ++i2)
if (matchesRange(current, specifierValue[i2]))
return !0;
return !1;
}
return matchesRange(current, specifierValue);
}
var data = require_core();
module.exports = function(x, nodeVersion) {
return hasOwn(data, x) && versionIncluded(nodeVersion, data[x]);
};
}
});
// ../../node_modules/resolve/lib/async.js
var require_async = __commonJS({
"../../node_modules/resolve/lib/async.js"(exports, module) {
var fs = __require("fs"), getHomedir = require_homedir(), path5 = __require("path"), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions2 = require_normalize_options(), isCore = require_is_core_module(), realpathFS = process.platform !== "win32" && fs.realpath && typeof fs.realpath.native == "function" ? fs.realpath.native : fs.realpath, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir(), defaultPaths = function() {
return [
path5.join(homedir, ".node_modules"),
path5.join(homedir, ".node_libraries")
];
}, defaultIsFile = function(file, cb) {
fs.stat(file, function(err, stat) {
return err ? err.code === "ENOENT" || err.code === "ENOTDIR" ? cb(null, !1) : cb(err) : cb(null, stat.isFile() || stat.isFIFO());
});
}, defaultIsDir = function(dir, cb) {
fs.stat(dir, function(err, stat) {
return err ? err.code === "ENOENT" || err.code === "ENOTDIR" ? cb(null, !1) : cb(err) : cb(null, stat.isDirectory());
});
}, defaultRealpath = function(x, cb) {
realpathFS(x, function(realpathErr, realPath) {
realpathErr && realpathErr.code !== "ENOENT" ? cb(realpathErr) : cb(null, realpathErr ? x : realPath);
});
}, maybeRealpath = function(realpath2, x, opts, cb) {
opts && opts.preserveSymlinks === !1 ? realpath2(x, cb) : cb(null, x);
}, defaultReadPackage = function(readFile7, pkgfile, cb) {
readFile7(pkgfile, function(readFileErr, body) {
if (readFileErr) cb(readFileErr);
else
try {
var pkg = JSON.parse(body);
cb(null, pkg);
} catch {
cb(null);
}
});
}, getPackageCandidates = function(x, start, opts) {
for (var dirs = nodeModulesPaths(start, opts, x), i2 = 0; i2 < dirs.length; i2++)
dirs[i2] = path5.join(dirs[i2], x);
return dirs;
};
module.exports = function(x, options, callback) {
var cb = callback, opts = options;
if (typeof options == "function" && (cb = opts, opts = {}), typeof x != "string") {
var err = new TypeError("Path must be a string.");
return process.nextTick(function() {
cb(err);
});
}
opts = normalizeOptions2(x, opts);
var isFile = opts.isFile || defaultIsFile, isDirectory2 = opts.isDirectory || defaultIsDir, readFile7 = opts.readFile || fs.readFile, realpath2 = opts.realpath || defaultRealpath, readPackage = opts.readPackage || defaultReadPackage;
if (opts.readFile && opts.readPackage) {
var conflictErr = new TypeError("`readFile` and `readPackage` are mutually exclusive.");
return process.nextTick(function() {
cb(conflictErr);
});
}
var packageIterator = opts.packageIterator, extensions = opts.extensions || [".js"], includeCoreModules = opts.includeCoreModules !== !1, basedir = opts.basedir || path5.dirname(caller()), parent = opts.filename || basedir;
opts.paths = opts.paths || defaultPaths();
var absoluteStart = path5.resolve(basedir);
maybeRealpath(
realpath2,
absoluteStart,
opts,
function(err2, realStart) {
err2 ? cb(err2) : init(realStart);
}
);
var res;
function init(basedir2) {
if (relativePathRegex.test(x))
res = path5.resolve(basedir2, x), (x === "." || x === ".." || x.slice(-1) === "/") && (res += "/"), x.slice(-1) === "/" && res === basedir2 ? loadAsDirectory(res, opts.package, onfile) : loadAsFile(res, opts.package, onfile);
else {
if (includeCoreModules && isCore(x))
return cb(null, x);
loadNodeModules(x, basedir2, function(err2, n2, pkg) {
if (err2) cb(err2);
else {
if (n2)
return maybeRealpath(realpath2, n2, opts, function(err3, realN) {
err3 ? cb(err3) : cb(null, realN, pkg);
});
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
moduleError.code = "MODULE_NOT_FOUND", cb(moduleError);
}
});
}
}
function onfile(err2, m, pkg) {
err2 ? cb(err2) : m ? cb(null, m, pkg) : loadAsDirectory(res, function(err3, d, pkg2) {
if (err3) cb(err3);
else if (d)
maybeRealpath(realpath2, d, opts, function(err4, realD) {
err4 ? cb(err4) : cb(null, realD, pkg2);
});
else {
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
moduleError.code = "MODULE_NOT_FOUND", cb(moduleError);
}
});
}
function loadAsFile(x2, thePackage, callback2) {
var loadAsFilePackage = thePackage, cb2 = callback2;
typeof loadAsFilePackage == "function" && (cb2 = loadAsFilePackage, loadAsFilePackage = void 0);
var exts = [""].concat(extensions);
load2(exts, x2, loadAsFilePackage);
function load2(exts2, x3, loadPackage) {
if (exts2.length === 0) return cb2(null, void 0, loadPackage);
var file = x3 + exts2[0], pkg = loadPackage;
pkg ? onpkg(null, pkg) : loadpkg(path5.dirname(file), onpkg);
function onpkg(err2, pkg_, dir) {
if (pkg = pkg_, err2) return cb2(err2);
if (dir && pkg && opts.pathFilter) {
var rfile = path5.relative(dir, file), rel = rfile.slice(0, rfile.length - exts2[0].length), r = opts.pathFilter(pkg, x3, rel);
if (r) return load2(
[""].concat(extensions.slice()),
path5.resolve(dir, r),
pkg
);
}
isFile(file, onex);
}
function onex(err2, ex) {
if (err2) return cb2(err2);
if (ex) return cb2(null, file, pkg);
load2(exts2.slice(1), x3, pkg);
}
}
}
function loadpkg(dir, cb2) {
if (dir === "" || dir === "/" || process.platform === "win32" && windowsDriveRegex.test(dir) || nodeModulesRegex.test(dir)) return cb2(null);
maybeRealpath(realpath2, dir, opts, function(unwrapErr, pkgdir) {
if (unwrapErr) return loadpkg(path5.dirname(dir), cb2);
var pkgfile = path5.join(pkgdir, "package.json");
isFile(pkgfile, function(err2, ex) {
if (!ex) return loadpkg(path5.dirname(dir), cb2);
readPackage(readFile7, pkgfile, function(err3, pkgParam) {
err3 && cb2(err3);
var pkg = pkgParam;
pkg && opts.packageFilter && (pkg = opts.packageFilter(pkg, pkgfile)), cb2(null, pkg, dir);
});
});
});
}
function loadAsDirectory(x2, loadAsDirectoryPackage, callback2) {
var cb2 = callback2, fpkg = loadAsDirectoryPackage;
typeof fpkg == "function" && (cb2 = fpkg, fpkg = opts.package), maybeRealpath(realpath2, x2, opts, function(unwrapErr, pkgdir) {
if (unwrapErr) return cb2(unwrapErr);
var pkgfile = path5.join(pkgdir, "package.json");
isFile(pkgfile, function(err2, ex) {
if (err2) return cb2(err2);
if (!ex) return loadAsFile(path5.join(x2, "index"), fpkg, cb2);
readPackage(readFile7, pkgfile, function(err3, pkgParam) {
if (err3) return cb2(err3);
var pkg = pkgParam;
if (pkg && opts.packageFilter && (pkg = opts.packageFilter(pkg, pkgfile)), pkg && pkg.main) {
if (typeof pkg.main != "string") {
var mainError = new TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
return mainError.code = "INVALID_PACKAGE_MAIN", cb2(mainError);
}
(pkg.main === "." || pkg.main === "./") && (pkg.main = "index"), loadAsFile(path5.resolve(x2, pkg.main), pkg, function(err4, m, pkg2) {
if (err4) return cb2(err4);
if (m) return cb2(null, m, pkg2);
if (!pkg2) return loadAsFile(path5.join(x2, "index"), pkg2, cb2);
var dir = path5.resolve(x2, pkg2.main);
loadAsDirectory(dir, pkg2, function(err5, n2, pkg3) {
if (err5) return cb2(err5);
if (n2) return cb2(null, n2, pkg3);
loadAsFile(path5.join(x2, "index"), pkg3, cb2);
});
});
return;
}
loadAsFile(path5.join(x2, "/index"), pkg, cb2);
});
});
});
}
function processDirs(cb2, dirs) {
if (dirs.length === 0) return cb2(null, void 0);
var dir = dirs[0];
isDirectory2(path5.dirname(dir), isdir);
function isdir(err2, isdir2) {
if (err2) return cb2(err2);
if (!isdir2) return processDirs(cb2, dirs.slice(1));
loadAsFile(dir, opts.package, onfile2);
}
function onfile2(err2, m, pkg) {
if (err2) return cb2(err2);
if (m) return cb2(null, m, pkg);
loadAsDirectory(dir, opts.package, ondir);
}
function ondir(err2, n2, pkg) {
if (err2) return cb2(err2);
if (n2) return cb2(null, n2, pkg);
processDirs(cb2, dirs.slice(1));
}
}
function loadNodeModules(x2, start, cb2) {
var thunk = function() {
return getPackageCandidates(x2, start, opts);
};
processDirs(
cb2,
packageIterator ? packageIterator(x2, start, thunk, opts) : thunk()
);
}
};
}
});
// ../../node_modules/resolve/lib/core.json
var require_core2 = __commonJS({
"../../node_modules/resolve/lib/core.json"(exports, module) {
module.exports = {
assert: !0,
"node:assert": [">= 14.18 && < 15", ">= 16"],
"assert/strict": ">= 15",
"node:assert/strict": ">= 16",
async_hooks: ">= 8",
"node:async_hooks": [">= 14.18 && < 15", ">= 16"],
buffer_ieee754: ">= 0.5 && < 0.9.7",
buffer: !0,
"node:buffer": [">= 14.18 && < 15", ">= 16"],
child_process: !0,
"node:child_process": [">= 14.18 && < 15", ">= 16"],
cluster: ">= 0.5",
"node:cluster": [">= 14.18 && < 15", ">= 16"],
console: !0,
"node:console": [">= 14.18 && < 15", ">= 16"],
constants: !0,
"node:constants": [">= 14.18 && < 15", ">= 16"],
crypto: !0,
"node:crypto": [">= 14.18 && < 15", ">= 16"],
_debug_agent: ">= 1 && < 8",
_debugger: "< 8",
dgram: !0,
"node:dgram": [">= 14.18 && < 15", ">= 16"],
diagnostics_channel: [">= 14.17 && < 15", ">= 15.1"],
"node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"],
dns: !0,
"node:dns": [">= 14.18 && < 15", ">= 16"],
"dns/promises": ">= 15",
"node:dns/promises": ">= 16",
domain: ">= 0.7.12",
"node:domain": [">= 14.18 && < 15", ">= 16"],
events: !0,
"node:events": [">= 14.18 && < 15", ">= 16"],
freelist: "< 6",
fs: !0,
"node:fs": [">= 14.18 && < 15", ">= 16"],
"fs/promises": [">= 10 && < 10.1", ">= 14"],
"node:fs/promises": [">= 14.18 && < 15", ">= 16"],
_http_agent: ">= 0.11.1",
"node:_http_agent": [">= 14.18 && < 15", ">= 16"],
_http_client: ">= 0.11.1",
"node:_http_client": [">= 14.18 && < 15", ">= 16"],
_http_common: ">= 0.11.1",
"node:_http_common": [">= 14.18 && < 15", ">= 16"],
_http_incoming: ">= 0.11.1",
"node:_http_incoming": [">= 14.18 && < 15", ">= 16"],
_http_outgoing: ">= 0.11.1",
"node:_http_outgoing": [">= 14.18 && < 15", ">= 16"],
_http_server: ">= 0.11.1",
"node:_http_server": [">= 14.18 && < 15", ">= 16"],
http: !0,
"node:http": [">= 14.18 && < 15", ">= 16"],
http2: ">= 8.8",
"node:http2": [">= 14.18 && < 15", ">= 16"],
https: !0,
"node:https": [">= 14.18 && < 15", ">= 16"],
inspector: ">= 8",
"node:inspector": [">= 14.18 && < 15", ">= 16"],
"inspector/promises": [">= 19"],
"node:inspector/promises": [">= 19"],
_linklist: "< 8",
module: !0,
"node:module": [">= 14.18 && < 15", ">= 16"],
net: !0,
"node:net": [">= 14.18 && < 15", ">= 16"],
"node-inspect/lib/_inspect": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
os: !0,
"node:os": [">= 14.18 && < 15", ">= 16"],
path: !0,
"node:path": [">= 14.18 && < 15", ">= 16"],
"path/posix": ">= 15.3",
"node:path/posix": ">= 16",
"path/win32": ">= 15.3",
"node:path/win32": ">= 16",
perf_hooks: ">= 8.5",
"node:perf_hooks": [">= 14.18 && < 15", ">= 16"],
process: ">= 1",
"node:process": [">= 14.18 && < 15", ">= 16"],
punycode: ">= 0.5",
"node:punycode": [">= 14.18 && < 15", ">= 16"],
querystring: !0,
"node:querystring": [">= 14.18 && < 15", ">= 16"],
readline: !0,
"node:readline": [">= 14.18 && < 15", ">= 16"],
"readline/promises": ">= 17",
"node:readline/promises": ">= 17",
repl: !0,
"node:repl": [">= 14.18 && < 15", ">= 16"],
"node:sea": [">= 20.12 && < 21", ">= 21.7"],
smalloc: ">= 0.11.5 && < 3",
"node:sqlite": [">= 22.13 && < 23", ">= 23.4"],
_stream_duplex: ">= 0.9.4",
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
_stream_transform: ">= 0.9.4",
"node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
_stream_wrap: ">= 1.4.1",
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
_stream_passthrough: ">= 0.9.4",
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
_stream_readable: ">= 0.9.4",
"node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
_stream_writable: ">= 0.9.4",
"node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
stream: !0,
"node:stream": [">= 14.18 && < 15", ">= 16"],
"stream/consumers": ">= 16.7",
"node:stream/consumers": ">= 16.7",
"stream/promises": ">= 15",
"node:stream/promises": ">= 16",
"stream/web": ">= 16.5",
"node:stream/web": ">= 16.5",
string_decoder: !0,
"node:string_decoder": [">= 14.18 && < 15", ">= 16"],
sys: [">= 0.4 && < 0.7", ">= 0.8"],
"node:sys": [">= 14.18 && < 15", ">= 16"],
"test/reporters": ">= 19.9 && < 20.2",
"node:test/reporters": [">= 18.17 && < 19", ">= 19.9", ">= 20"],
"test/mock_loader": ">= 22.3 && < 22.7",
"node:test/mock_loader": ">= 22.3 && < 22.7",
"node:test": [">= 16.17 && < 17", ">= 18"],
timers: !0,
"node:timers": [">= 14.18 && < 15", ">= 16"],
"timers/promises": ">= 15",
"node:timers/promises": ">= 16",
_tls_common: ">= 0.11.13",
"node:_tls_common": [">= 14.18 && < 15", ">= 16"],
_tls_legacy: ">= 0.11.3 && < 10",
_tls_wrap: ">= 0.11.3",
"node:_tls_wrap": [">= 14.18 && < 15", ">= 16"],
tls: !0,
"node:tls": [">= 14.18 && < 15", ">= 16"],
trace_events: ">= 10",
"node:trace_events": [">= 14.18 && < 15", ">= 16"],
tty: !0,
"node:tty": [">= 14.18 && < 15", ">= 16"],
url: !0,
"node:url": [">= 14.18 && < 15", ">= 16"],
util: !0,
"node:util": [">= 14.18 && < 15", ">= 16"],
"util/types": ">= 15.3",
"node:util/types": ">= 16",
"v8/tools/arguments": ">= 10 && < 12",
"v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
v8: ">= 1",
"node:v8": [">= 14.18 && < 15", ">= 16"],
vm: !0,
"node:vm": [">= 14.18 && < 15", ">= 16"],
wasi: [">= 13.4 && < 13.5", ">= 18.17 && < 19", ">= 20"],
"node:wasi": [">= 18.17 && < 19", ">= 20"],
worker_threads: ">= 11.7",
"node:worker_threads": [">= 14.18 && < 15", ">= 16"],
zlib: ">= 0.5",
"node:zlib": [">= 14.18 && < 15", ">= 16"]
};
}
});
// ../../node_modules/resolve/lib/core.js
var require_core3 = __commonJS({
"../../node_modules/resolve/lib/core.js"(exports, module) {
"use strict";
var isCoreModule = require_is_core_module(), data = require_core2(), core = {};
for (mod in data)
Object.prototype.hasOwnProperty.call(data, mod) && (core[mod] = isCoreModule(mod));
var mod;
module.exports = core;
}
});
// ../../node_modules/resolve/lib/is-core.js
var require_is_core = __commonJS({
"../../node_modules/resolve/lib/is-core.js"(exports, module) {
var isCoreModule = require_is_core_module();
module.exports = function(x) {
return isCoreModule(x);
};
}
});
// ../../node_modules/resolve/lib/sync.js
var require_sync = __commonJS({
"../../node_modules/resolve/lib/sync.js"(exports, module) {
var isCore = require_is_core_module(), fs = __require("fs"), path5 = __require("path"), getHomedir = require_homedir(), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions2 = require_normalize_options(), realpathFS = process.platform !== "win32" && fs.realpathSync && typeof fs.realpathSync.native == "function" ? fs.realpathSync.native : fs.realpathSync, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir(), defaultPaths = function() {
return [
path5.join(homedir, ".node_modules"),
path5.join(homedir, ".node_libraries")
];
}, defaultIsFile = function(file) {
try {
var stat = fs.statSync(file, { throwIfNoEntry: !1 });
} catch (e) {
if (e && (e.code === "ENOENT" || e.code === "ENOTDIR")) return !1;
throw e;
}
return !!stat && (stat.isFile() || stat.isFIFO());
}, defaultIsDir = function(dir) {
try {
var stat = fs.statSync(dir, { throwIfNoEntry: !1 });
} catch (e) {
if (e && (e.code === "ENOENT" || e.code === "ENOTDIR")) return !1;
throw e;
}
return !!stat && stat.isDirectory();
}, defaultRealpathSync = function(x) {
try {
return realpathFS(x);
} catch (realpathErr) {
if (realpathErr.code !== "ENOENT")
throw realpathErr;
}
return x;
}, maybeRealpathSync = function(realpathSync, x, opts) {
return opts && opts.preserveSymlinks === !1 ? realpathSync(x) : x;
}, defaultReadPackageSync = function(readFileSync13, pkgfile) {
var body = readFileSync13(pkgfile);
try {
var pkg = JSON.parse(body);
return pkg;
} catch {
}
}, getPackageCandidates = function(x, start, opts) {
for (var dirs = nodeModulesPaths(start, opts, x), i2 = 0; i2 < dirs.length; i2++)
dirs[i2] = path5.join(dirs[i2], x);
return dirs;
};
module.exports = function(x, options) {
if (typeof x != "string")
throw new TypeError("Path must be a string.");
var opts = normalizeOptions2(x, options), isFile = opts.isFile || defaultIsFile, readFileSync13 = opts.readFileSync || fs.readFileSync, isDirectory2 = opts.isDirectory || defaultIsDir, realpathSync = opts.realpathSync || defaultRealpathSync, readPackageSync = opts.readPackageSync || defaultReadPackageSync;
if (opts.readFileSync && opts.readPackageSync)
throw new TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");
var packageIterator = opts.packageIterator, extensions = opts.extensions || [".js"], includeCoreModules = opts.includeCoreModules !== !1, basedir = opts.basedir || path5.dirname(caller()), parent = opts.filename || basedir;
opts.paths = opts.paths || defaultPaths();
var absoluteStart = maybeRealpathSync(realpathSync, path5.resolve(basedir), opts);
if (relativePathRegex.test(x)) {
var res = path5.resolve(absoluteStart, x);
(x === "." || x === ".." || x.slice(-1) === "/") && (res += "/");
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
if (m) return maybeRealpathSync(realpathSync, m, opts);
} else {
if (includeCoreModules && isCore(x))
return x;
var n2 = loadNodeModulesSync(x, absoluteStart);
if (n2) return maybeRealpathSync(realpathSync, n2, opts);
}
var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
throw err.code = "MODULE_NOT_FOUND", err;
function loadAsFileSync(x2) {
var pkg = loadpkg(path5.dirname(x2));
if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
var rfile = path5.relative(pkg.dir, x2), r = opts.pathFilter(pkg.pkg, x2, rfile);
r && (x2 = path5.resolve(pkg.dir, r));
}
if (isFile(x2))
return x2;
for (var i2 = 0; i2 < extensions.length; i2++) {
var file = x2 + extensions[i2];
if (isFile(file))
return file;
}
}
function loadpkg(dir) {
if (!(dir === "" || dir === "/") && !(process.platform === "win32" && windowsDriveRegex.test(dir)) && !nodeModulesRegex.test(dir)) {
var pkgfile = path5.join(maybeRealpathSync(realpathSync, dir, opts), "package.json");
if (!isFile(pkgfile))
return loadpkg(path5.dirname(dir));
var pkg = readPackageSync(readFileSync13, pkgfile);
return pkg && opts.packageFilter && (pkg = opts.packageFilter(
pkg,
/*pkgfile,*/
dir
)), { pkg, dir };
}
}
function loadAsDirectorySync(x2) {
var pkgfile = path5.join(maybeRealpathSync(realpathSync, x2, opts), "/package.json");
if (isFile(pkgfile)) {
try {
var pkg = readPackageSync(readFileSync13, pkgfile);
} catch {
}
if (pkg && opts.packageFilter && (pkg = opts.packageFilter(
pkg,
/*pkgfile,*/
x2
)), pkg && pkg.main) {
if (typeof pkg.main != "string") {
var mainError = new TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
throw mainError.code = "INVALID_PACKAGE_MAIN", mainError;
}
(pkg.main === "." || pkg.main === "./") && (pkg.main = "index");
try {
var m2 = loadAsFileSync(path5.resolve(x2, pkg.main));
if (m2) return m2;
var n3 = loadAsDirectorySync(path5.resolve(x2, pkg.main));
if (n3) return n3;
} catch {
}
}
}
return loadAsFileSync(path5.join(x2, "/index"));
}
function loadNodeModulesSync(x2, start) {
for (var thunk = function() {
return getPackageCandidates(x2, start, opts);
}, dirs = packageIterator ? packageIterator(x2, start, thunk, opts) : thunk(), i2 = 0; i2 < dirs.length; i2++) {
var dir = dirs[i2];
if (isDirectory2(path5.dirname(dir))) {
var m2 = loadAsFileSync(dir);
if (m2) return m2;
var n3 = loadAsDirectorySync(dir);
if (n3) return n3;
}
}
}
};
}
});
// ../../node_modules/resolve/index.js
var require_resolve = __commonJS({
"../../node_modules/resolve/index.js"(exports, module) {
var async = require_async();
async.core = require_core3();
async.isCore = require_is_core();
async.sync = require_sync();
module.exports = async;
}
});
// ../../node_modules/isexe/windows.js
var require_windows = __commonJS({
"../../node_modules/isexe/windows.js"(exports, module) {
module.exports = isexe;
isexe.sync = sync;
var fs = __require("fs");
function checkPathExt(path5, options) {
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
if (!pathext || (pathext = pathext.split(";"), pathext.indexOf("") !== -1))
return !0;
for (var i2 = 0; i2 < pathext.length; i2++) {
var p = pathext[i2].toLowerCase();
if (p && path5.substr(-p.length).toLowerCase() === p)
return !0;
}
return !1;
}
function checkStat(stat, path5, options) {
return !stat.isSymbolicLink() && !stat.isFile() ? !1 : checkPathExt(path5, options);
}
function isexe(path5, options, cb) {
fs.stat(path5, function(er, stat) {
cb(er, er ? !1 : checkStat(stat, path5, options));
});
}
function sync(path5, options) {
return checkStat(fs.statSync(path5), path5, options);
}
}
});
// ../../node_modules/isexe/mode.js
var require_mode = __commonJS({
"../../node_modules/isexe/mode.js"(exports, module) {
module.exports = isexe;
isexe.sync = sync;
var fs = __require("fs");
function isexe(path5, options, cb) {
fs.stat(path5, function(er, stat) {
cb(er, er ? !1 : checkStat(stat, options));
});
}
function sync(path5, options) {
return checkStat(fs.statSync(path5), options);
}
function checkStat(stat, options) {
return stat.isFile() && checkMode(stat, options);
}
function checkMode(stat, options) {
var mod = stat.mode, uid = stat.uid, gid = stat.gid, myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid(), myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid(), u2 = parseInt("100", 8), g = parseInt("010", 8), o2 = parseInt("001", 8), ug = u2 | g, ret = mod & o2 || mod & g && gid === myGid || mod & u2 && uid === myUid || mod & ug && myUid === 0;
return ret;
}
}
});
// ../../node_modules/isexe/index.js
var require_isexe = __commonJS({
"../../node_modules/isexe/index.js"(exports, module) {
var fs = __require("fs"), core;
process.platform === "win32" || global.TESTING_WINDOWS ? core = require_windows() : core = require_mode();
module.exports = isexe;
isexe.sync = sync;
function isexe(path5, options, cb) {
if (typeof options == "function" && (cb = options, options = {}), !cb) {
if (typeof Promise != "function")
throw new TypeError("callback not provided");
return new Promise(function(resolve9, reject) {
isexe(path5, options || {}, function(er, is) {
er ? reject(er) : resolve9(is);
});
});
}
core(path5, options || {}, function(er, is) {
er && (er.code === "EACCES" || options && options.ignoreErrors) && (er = null, is = !1), cb(er, is);
});
}
function sync(path5, options) {
try {
return core.sync(path5, options || {});
} catch (er) {
if (options && options.ignoreErrors || er.code === "EACCES")
return !1;
throw er;
}
}
}
});
// ../../node_modules/which/which.js
var require_which = __commonJS({
"../../node_modules/which/which.js"(exports, module) {
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", path5 = __require("path"), COLON = isWindows ? ";" : ":", isexe = require_isexe(), getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" }), getPathInfo = (cmd, opt) => {
let colon = opt.colon || COLON, pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
// windows always checks the cwd first
...isWindows ? [process.cwd()] : [],
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
"").split(colon)
], pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", pathExt = isWindows ? pathExtExe.split(colon) : [""];
return isWindows && cmd.indexOf(".") !== -1 && pathExt[0] !== "" && pathExt.unshift(""), {
pathEnv,
pathExt,
pathExtExe
};
}, which = (cmd, opt, cb) => {
typeof opt == "function" && (cb = opt, opt = {}), opt || (opt = {});
let { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt), found = [], step = (i2) => new Promise((resolve9, reject) => {
if (i2 === pathEnv.length)
return opt.all && found.length ? resolve9(found) : reject(getNotFoundError(cmd));
let ppRaw = pathEnv[i2], pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw, pCmd = path5.join(pathPart, cmd), p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
resolve9(subStep(p, i2, 0));
}), subStep = (p, i2, ii) => new Promise((resolve9, reject) => {
if (ii === pathExt.length)
return resolve9(step(i2 + 1));
let ext = pathExt[ii];
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
if (!er && is)
if (opt.all)
found.push(p + ext);
else
return resolve9(p + ext);
return resolve9(subStep(p, i