@drmhse/authos-vue 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1272 @@
1
+ import { x, h } from './chunk-SW2YRXFK.mjs';
2
+ import fs, { promises, lstatSync, realpathSync, statSync } from 'fs';
3
+ import { fileURLToPath, pathToFileURL, URL as URL$1 } from 'url';
4
+ import path, { isAbsolute as isAbsolute$1 } from 'path';
5
+ import assert from 'assert';
6
+ import process$1 from 'process';
7
+ import v8 from 'v8';
8
+ import { format, inspect } from 'util';
9
+ import 'fs/promises';
10
+
11
+ // node_modules/defu/dist/defu.mjs
12
+ function isPlainObject(value) {
13
+ if (value === null || typeof value !== "object") {
14
+ return false;
15
+ }
16
+ const prototype = Object.getPrototypeOf(value);
17
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
18
+ return false;
19
+ }
20
+ if (Symbol.iterator in value) {
21
+ return false;
22
+ }
23
+ if (Symbol.toStringTag in value) {
24
+ return Object.prototype.toString.call(value) === "[object Module]";
25
+ }
26
+ return true;
27
+ }
28
+ function _defu(baseObject, defaults, namespace = ".", merger) {
29
+ if (!isPlainObject(defaults)) {
30
+ return _defu(baseObject, {}, namespace, merger);
31
+ }
32
+ const object = Object.assign({}, defaults);
33
+ for (const key in baseObject) {
34
+ if (key === "__proto__" || key === "constructor") {
35
+ continue;
36
+ }
37
+ const value = baseObject[key];
38
+ if (value === null || value === void 0) {
39
+ continue;
40
+ }
41
+ if (merger && merger(object, key, value, namespace)) {
42
+ continue;
43
+ }
44
+ if (Array.isArray(value) && Array.isArray(object[key])) {
45
+ object[key] = [...value, ...object[key]];
46
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
47
+ object[key] = _defu(
48
+ value,
49
+ object[key],
50
+ (namespace ? `${namespace}.` : "") + key.toString(),
51
+ merger
52
+ );
53
+ } else {
54
+ object[key] = value;
55
+ }
56
+ }
57
+ return object;
58
+ }
59
+ function createDefu(merger) {
60
+ return (...arguments_) => (
61
+ // eslint-disable-next-line unicorn/no-array-reduce
62
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
63
+ );
64
+ }
65
+ var defu = createDefu();
66
+
67
+ // node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
68
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
69
+ function normalizeWindowsPath(input = "") {
70
+ if (!input) {
71
+ return input;
72
+ }
73
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
74
+ }
75
+ var _UNC_REGEX = /^[/\\]{2}/;
76
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
77
+ var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
78
+ var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
79
+ var normalize = function(path2) {
80
+ if (path2.length === 0) {
81
+ return ".";
82
+ }
83
+ path2 = normalizeWindowsPath(path2);
84
+ const isUNCPath = path2.match(_UNC_REGEX);
85
+ const isPathAbsolute = isAbsolute(path2);
86
+ const trailingSeparator = path2[path2.length - 1] === "/";
87
+ path2 = normalizeString(path2, !isPathAbsolute);
88
+ if (path2.length === 0) {
89
+ if (isPathAbsolute) {
90
+ return "/";
91
+ }
92
+ return trailingSeparator ? "./" : ".";
93
+ }
94
+ if (trailingSeparator) {
95
+ path2 += "/";
96
+ }
97
+ if (_DRIVE_LETTER_RE.test(path2)) {
98
+ path2 += "/";
99
+ }
100
+ if (isUNCPath) {
101
+ if (!isPathAbsolute) {
102
+ return `//./${path2}`;
103
+ }
104
+ return `//${path2}`;
105
+ }
106
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
107
+ };
108
+ var join = function(...segments) {
109
+ let path2 = "";
110
+ for (const seg of segments) {
111
+ if (!seg) {
112
+ continue;
113
+ }
114
+ if (path2.length > 0) {
115
+ const pathTrailing = path2[path2.length - 1] === "/";
116
+ const segLeading = seg[0] === "/";
117
+ const both = pathTrailing && segLeading;
118
+ if (both) {
119
+ path2 += seg.slice(1);
120
+ } else {
121
+ path2 += pathTrailing || segLeading ? seg : `/${seg}`;
122
+ }
123
+ } else {
124
+ path2 += seg;
125
+ }
126
+ }
127
+ return normalize(path2);
128
+ };
129
+ function cwd() {
130
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
131
+ return process.cwd().replace(/\\/g, "/");
132
+ }
133
+ return "/";
134
+ }
135
+ var resolve = function(...arguments_) {
136
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
137
+ let resolvedPath = "";
138
+ let resolvedAbsolute = false;
139
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
140
+ const path2 = index >= 0 ? arguments_[index] : cwd();
141
+ if (!path2 || path2.length === 0) {
142
+ continue;
143
+ }
144
+ resolvedPath = `${path2}/${resolvedPath}`;
145
+ resolvedAbsolute = isAbsolute(path2);
146
+ }
147
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
148
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
149
+ return `/${resolvedPath}`;
150
+ }
151
+ return resolvedPath.length > 0 ? resolvedPath : ".";
152
+ };
153
+ function normalizeString(path2, allowAboveRoot) {
154
+ let res = "";
155
+ let lastSegmentLength = 0;
156
+ let lastSlash = -1;
157
+ let dots = 0;
158
+ let char = null;
159
+ for (let index = 0; index <= path2.length; ++index) {
160
+ if (index < path2.length) {
161
+ char = path2[index];
162
+ } else if (char === "/") {
163
+ break;
164
+ } else {
165
+ char = "/";
166
+ }
167
+ if (char === "/") {
168
+ if (lastSlash === index - 1 || dots === 1) ;
169
+ else if (dots === 2) {
170
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
171
+ if (res.length > 2) {
172
+ const lastSlashIndex = res.lastIndexOf("/");
173
+ if (lastSlashIndex === -1) {
174
+ res = "";
175
+ lastSegmentLength = 0;
176
+ } else {
177
+ res = res.slice(0, lastSlashIndex);
178
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
179
+ }
180
+ lastSlash = index;
181
+ dots = 0;
182
+ continue;
183
+ } else if (res.length > 0) {
184
+ res = "";
185
+ lastSegmentLength = 0;
186
+ lastSlash = index;
187
+ dots = 0;
188
+ continue;
189
+ }
190
+ }
191
+ if (allowAboveRoot) {
192
+ res += res.length > 0 ? "/.." : "..";
193
+ lastSegmentLength = 2;
194
+ }
195
+ } else {
196
+ if (res.length > 0) {
197
+ res += `/${path2.slice(lastSlash + 1, index)}`;
198
+ } else {
199
+ res = path2.slice(lastSlash + 1, index);
200
+ }
201
+ lastSegmentLength = index - lastSlash - 1;
202
+ }
203
+ lastSlash = index;
204
+ dots = 0;
205
+ } else if (char === "." && dots !== -1) {
206
+ ++dots;
207
+ } else {
208
+ dots = -1;
209
+ }
210
+ }
211
+ return res;
212
+ }
213
+ var isAbsolute = function(p) {
214
+ return _IS_ABSOLUTE_RE.test(p);
215
+ };
216
+ var relative = function(from, to) {
217
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
218
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
219
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
220
+ return _to.join("/");
221
+ }
222
+ const _fromCopy = [..._from];
223
+ for (const segment of _fromCopy) {
224
+ if (_to[0] !== segment) {
225
+ break;
226
+ }
227
+ _from.shift();
228
+ _to.shift();
229
+ }
230
+ return [..._from.map(() => ".."), ..._to].join("/");
231
+ };
232
+ var dirname = function(p) {
233
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
234
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
235
+ segments[0] += "/";
236
+ }
237
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
238
+ };
239
+ var basename = function(p, extension) {
240
+ const segments = normalizeWindowsPath(p).split("/");
241
+ let lastSegment = "";
242
+ for (let i = segments.length - 1; i >= 0; i--) {
243
+ const val = segments[i];
244
+ if (val) {
245
+ lastSegment = val;
246
+ break;
247
+ }
248
+ }
249
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
250
+ };
251
+ var nodeBuiltins = [
252
+ "_http_agent",
253
+ "_http_client",
254
+ "_http_common",
255
+ "_http_incoming",
256
+ "_http_outgoing",
257
+ "_http_server",
258
+ "_stream_duplex",
259
+ "_stream_passthrough",
260
+ "_stream_readable",
261
+ "_stream_transform",
262
+ "_stream_wrap",
263
+ "_stream_writable",
264
+ "_tls_common",
265
+ "_tls_wrap",
266
+ "assert",
267
+ "assert/strict",
268
+ "async_hooks",
269
+ "buffer",
270
+ "child_process",
271
+ "cluster",
272
+ "console",
273
+ "constants",
274
+ "crypto",
275
+ "dgram",
276
+ "diagnostics_channel",
277
+ "dns",
278
+ "dns/promises",
279
+ "domain",
280
+ "events",
281
+ "fs",
282
+ "fs/promises",
283
+ "http",
284
+ "http2",
285
+ "https",
286
+ "inspector",
287
+ "inspector/promises",
288
+ "module",
289
+ "net",
290
+ "os",
291
+ "path",
292
+ "path/posix",
293
+ "path/win32",
294
+ "perf_hooks",
295
+ "process",
296
+ "punycode",
297
+ "querystring",
298
+ "readline",
299
+ "readline/promises",
300
+ "repl",
301
+ "stream",
302
+ "stream/consumers",
303
+ "stream/promises",
304
+ "stream/web",
305
+ "string_decoder",
306
+ "sys",
307
+ "timers",
308
+ "timers/promises",
309
+ "tls",
310
+ "trace_events",
311
+ "tty",
312
+ "url",
313
+ "util",
314
+ "util/types",
315
+ "v8",
316
+ "vm",
317
+ "wasi",
318
+ "worker_threads",
319
+ "zlib"
320
+ ];
321
+ var own$1 = {}.hasOwnProperty;
322
+ var classRegExp = /^([A-Z][a-z\d]*)+$/;
323
+ var kTypes = /* @__PURE__ */ new Set([
324
+ "string",
325
+ "function",
326
+ "number",
327
+ "object",
328
+ "Function",
329
+ "Object",
330
+ "boolean",
331
+ "bigint",
332
+ "symbol"
333
+ ]);
334
+ var messages = /* @__PURE__ */ new Map();
335
+ var nodeInternalPrefix = "__node_internal_";
336
+ var userStackTraceLimit;
337
+ function formatList(array, type = "and") {
338
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
339
+ }
340
+ function createError(sym, value, constructor) {
341
+ messages.set(sym, value);
342
+ return makeNodeErrorWithCode(constructor, sym);
343
+ }
344
+ function makeNodeErrorWithCode(Base, key) {
345
+ return function NodeError(...parameters) {
346
+ const limit = Error.stackTraceLimit;
347
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
348
+ const error = new Base();
349
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
350
+ const message = getMessage(key, parameters, error);
351
+ Object.defineProperties(error, {
352
+ message: {
353
+ value: message,
354
+ enumerable: false,
355
+ writable: true,
356
+ configurable: true
357
+ },
358
+ toString: {
359
+ value() {
360
+ return `${this.name} [${key}]: ${this.message}`;
361
+ },
362
+ enumerable: false,
363
+ writable: true,
364
+ configurable: true
365
+ }
366
+ });
367
+ captureLargerStackTrace(error);
368
+ error.code = key;
369
+ return error;
370
+ };
371
+ }
372
+ function isErrorStackTraceLimitWritable() {
373
+ try {
374
+ if (v8.startupSnapshot.isBuildingSnapshot()) return false;
375
+ } catch {
376
+ }
377
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
378
+ if (desc === void 0) return Object.isExtensible(Error);
379
+ return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
380
+ }
381
+ function hideStackFrames(wrappedFunction) {
382
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
383
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
384
+ return wrappedFunction;
385
+ }
386
+ var captureLargerStackTrace = hideStackFrames(function(error) {
387
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
388
+ if (stackTraceLimitIsWritable) {
389
+ userStackTraceLimit = Error.stackTraceLimit;
390
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
391
+ }
392
+ Error.captureStackTrace(error);
393
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
394
+ return error;
395
+ });
396
+ function getMessage(key, parameters, self) {
397
+ const message = messages.get(key);
398
+ assert.ok(message !== void 0, "expected `message` to be found");
399
+ if (typeof message === "function") {
400
+ assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
401
+ return Reflect.apply(message, self, parameters);
402
+ }
403
+ const regex = /%[dfijoOs]/g;
404
+ let expectedLength = 0;
405
+ while (regex.exec(message) !== null) expectedLength++;
406
+ assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
407
+ if (parameters.length === 0) return message;
408
+ parameters.unshift(message);
409
+ return Reflect.apply(format, null, parameters);
410
+ }
411
+ function determineSpecificType(value) {
412
+ if (value === null || value === void 0) return String(value);
413
+ if (typeof value === "function" && value.name) return `function ${value.name}`;
414
+ if (typeof value === "object") {
415
+ if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
416
+ return `${inspect(value, { depth: -1 })}`;
417
+ }
418
+ let inspected = inspect(value, { colors: false });
419
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
420
+ return `type ${typeof value} (${inspected})`;
421
+ }
422
+ createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
423
+ assert.ok(typeof name === "string", "'name' must be a string");
424
+ if (!Array.isArray(expected)) expected = [expected];
425
+ let message = "The ";
426
+ if (name.endsWith(" argument")) message += `${name} `;
427
+ else {
428
+ const type = name.includes(".") ? "property" : "argument";
429
+ message += `"${name}" ${type} `;
430
+ }
431
+ message += "must be ";
432
+ const types = [];
433
+ const instances = [];
434
+ const other = [];
435
+ for (const value of expected) {
436
+ assert.ok(typeof value === "string", "All expected entries have to be of type string");
437
+ if (kTypes.has(value)) types.push(value.toLowerCase());
438
+ else if (classRegExp.exec(value) === null) {
439
+ assert.ok(value !== "object", 'The value "object" should be written as "Object"');
440
+ other.push(value);
441
+ } else instances.push(value);
442
+ }
443
+ if (instances.length > 0) {
444
+ const pos = types.indexOf("object");
445
+ if (pos !== -1) {
446
+ types.slice(pos, 1);
447
+ instances.push("Object");
448
+ }
449
+ }
450
+ if (types.length > 0) {
451
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
452
+ if (instances.length > 0 || other.length > 0) message += " or ";
453
+ }
454
+ if (instances.length > 0) {
455
+ message += `an instance of ${formatList(instances, "or")}`;
456
+ if (other.length > 0) message += " or ";
457
+ }
458
+ if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
459
+ else {
460
+ if (other[0]?.toLowerCase() !== other[0]) message += "an ";
461
+ message += `${other[0]}`;
462
+ }
463
+ message += `. Received ${determineSpecificType(actual)}`;
464
+ return message;
465
+ }, TypeError);
466
+ var ERR_INVALID_MODULE_SPECIFIER = createError(
467
+ "ERR_INVALID_MODULE_SPECIFIER",
468
+ /**
469
+ * @param {string} request
470
+ * @param {string} reason
471
+ * @param {string} [base]
472
+ */
473
+ (request, reason, base) => {
474
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
475
+ },
476
+ TypeError
477
+ );
478
+ var ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path$1, base, message) => {
479
+ return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
480
+ }, Error);
481
+ var ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = false, base) => {
482
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
483
+ if (key === ".") {
484
+ assert.ok(isImport === false);
485
+ return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
486
+ }
487
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
488
+ }, Error);
489
+ var ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path$1, base, exactUrl = false) => {
490
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
491
+ }, Error);
492
+ createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
493
+ var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
494
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
495
+ }, TypeError);
496
+ var ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
497
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
498
+ /**
499
+ * @param {string} packagePath
500
+ * @param {string} subpath
501
+ * @param {string} [base]
502
+ */
503
+ (packagePath, subpath, base) => {
504
+ if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
505
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
506
+ },
507
+ Error
508
+ );
509
+ var ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
510
+ var ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.', TypeError);
511
+ var ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path$1) => {
512
+ return `Unknown file extension "${extension}" for ${path$1}`;
513
+ }, TypeError);
514
+ createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
515
+ let inspected = inspect(value);
516
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
517
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
518
+ }, TypeError);
519
+ var hasOwnProperty$1 = {}.hasOwnProperty;
520
+ var cache = /* @__PURE__ */ new Map();
521
+ function read(jsonPath, { base, specifier }) {
522
+ const existing = cache.get(jsonPath);
523
+ if (existing) return existing;
524
+ let string;
525
+ try {
526
+ string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
527
+ } catch (error) {
528
+ const exception = error;
529
+ if (exception.code !== "ENOENT") throw exception;
530
+ }
531
+ const result = {
532
+ exists: false,
533
+ pjsonPath: jsonPath,
534
+ main: void 0,
535
+ name: void 0,
536
+ type: "none",
537
+ exports: void 0,
538
+ imports: void 0
539
+ };
540
+ if (string !== void 0) {
541
+ let parsed;
542
+ try {
543
+ parsed = JSON.parse(string);
544
+ } catch (error_) {
545
+ const error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), error_.message);
546
+ error.cause = error_;
547
+ throw error;
548
+ }
549
+ result.exists = true;
550
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
551
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
552
+ if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
553
+ if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
554
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
555
+ }
556
+ cache.set(jsonPath, result);
557
+ return result;
558
+ }
559
+ function getPackageScopeConfig(resolved) {
560
+ let packageJSONUrl = new URL("package.json", resolved);
561
+ while (true) {
562
+ if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
563
+ const packageConfig = read(fileURLToPath(packageJSONUrl), { specifier: resolved });
564
+ if (packageConfig.exists) return packageConfig;
565
+ const lastPackageJSONUrl = packageJSONUrl;
566
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
567
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
568
+ }
569
+ return {
570
+ pjsonPath: fileURLToPath(packageJSONUrl),
571
+ exists: false,
572
+ type: "none"
573
+ };
574
+ }
575
+ var hasOwnProperty = {}.hasOwnProperty;
576
+ var extensionFormatMap = {
577
+ __proto__: null,
578
+ ".json": "json",
579
+ ".cjs": "commonjs",
580
+ ".cts": "commonjs",
581
+ ".js": "module",
582
+ ".ts": "module",
583
+ ".mts": "module",
584
+ ".mjs": "module"
585
+ };
586
+ var protocolHandlers = {
587
+ __proto__: null,
588
+ "data:": getDataProtocolModuleFormat,
589
+ "file:": getFileProtocolModuleFormat,
590
+ "node:": () => "builtin"
591
+ };
592
+ function mimeToFormat(mime) {
593
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
594
+ if (mime === "application/json") return "json";
595
+ return null;
596
+ }
597
+ function getDataProtocolModuleFormat(parsed) {
598
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
599
+ null,
600
+ null,
601
+ null
602
+ ];
603
+ return mimeToFormat(mime);
604
+ }
605
+ function extname2(url) {
606
+ const pathname = url.pathname;
607
+ let index = pathname.length;
608
+ while (index--) {
609
+ const code = pathname.codePointAt(index);
610
+ if (code === 47) return "";
611
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
612
+ }
613
+ return "";
614
+ }
615
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
616
+ const ext = extname2(url);
617
+ if (ext === ".js") {
618
+ const { type: packageType } = getPackageScopeConfig(url);
619
+ if (packageType !== "none") return packageType;
620
+ return "commonjs";
621
+ }
622
+ if (ext === "") {
623
+ const { type: packageType } = getPackageScopeConfig(url);
624
+ if (packageType === "none" || packageType === "commonjs") return "commonjs";
625
+ return "module";
626
+ }
627
+ const format$1 = extensionFormatMap[ext];
628
+ if (format$1) return format$1;
629
+ if (ignoreErrors) return;
630
+ throw new ERR_UNKNOWN_FILE_EXTENSION(ext, fileURLToPath(url));
631
+ }
632
+ function defaultGetFormatWithoutErrors(url, context) {
633
+ const protocol = url.protocol;
634
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
635
+ return protocolHandlers[protocol](url, context, true) || null;
636
+ }
637
+ var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
638
+ var own = {}.hasOwnProperty;
639
+ var invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
640
+ var deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
641
+ var invalidPackageNameRegEx = /^\.|%|\\/;
642
+ var patternRegEx = /\*/g;
643
+ var encodedSeparatorRegEx = /%2f|%5c/i;
644
+ var emittedPackageWarnings = /* @__PURE__ */ new Set();
645
+ var doubleSlashRegEx = /[/\\]{2}/;
646
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
647
+ if (process$1.noDeprecation) return;
648
+ const pjsonPath = fileURLToPath(packageJsonUrl);
649
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
650
+ process$1.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
651
+ }
652
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
653
+ if (process$1.noDeprecation) return;
654
+ if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
655
+ const urlPath = fileURLToPath(url.href);
656
+ const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
657
+ const basePath = fileURLToPath(base);
658
+ if (!main) process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.
659
+ Default "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
660
+ else if (path.resolve(packagePath, main) !== urlPath) process$1.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.
661
+ Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
662
+ }
663
+ function tryStatSync(path$1) {
664
+ try {
665
+ return statSync(path$1);
666
+ } catch {
667
+ }
668
+ }
669
+ function fileExists(url) {
670
+ const stats = statSync(url, { throwIfNoEntry: false });
671
+ const isFile = stats ? stats.isFile() : void 0;
672
+ return isFile === null || isFile === void 0 ? false : isFile;
673
+ }
674
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
675
+ let guess;
676
+ if (packageConfig.main !== void 0) {
677
+ guess = new URL$1(packageConfig.main, packageJsonUrl);
678
+ if (fileExists(guess)) return guess;
679
+ const tries$1 = [
680
+ `./${packageConfig.main}.js`,
681
+ `./${packageConfig.main}.json`,
682
+ `./${packageConfig.main}.node`,
683
+ `./${packageConfig.main}/index.js`,
684
+ `./${packageConfig.main}/index.json`,
685
+ `./${packageConfig.main}/index.node`
686
+ ];
687
+ let i$1 = -1;
688
+ while (++i$1 < tries$1.length) {
689
+ guess = new URL$1(tries$1[i$1], packageJsonUrl);
690
+ if (fileExists(guess)) break;
691
+ guess = void 0;
692
+ }
693
+ if (guess) {
694
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
695
+ return guess;
696
+ }
697
+ }
698
+ const tries = [
699
+ "./index.js",
700
+ "./index.json",
701
+ "./index.node"
702
+ ];
703
+ let i = -1;
704
+ while (++i < tries.length) {
705
+ guess = new URL$1(tries[i], packageJsonUrl);
706
+ if (fileExists(guess)) break;
707
+ guess = void 0;
708
+ }
709
+ if (guess) {
710
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
711
+ return guess;
712
+ }
713
+ throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
714
+ }
715
+ function finalizeResolution(resolved, base, preserveSymlinks) {
716
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, String.raw`must not include encoded "/" or "\" characters`, fileURLToPath(base));
717
+ let filePath;
718
+ try {
719
+ filePath = fileURLToPath(resolved);
720
+ } catch (error) {
721
+ Object.defineProperty(error, "input", { value: String(resolved) });
722
+ Object.defineProperty(error, "module", { value: String(base) });
723
+ throw error;
724
+ }
725
+ const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
726
+ if (stats && stats.isDirectory()) {
727
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
728
+ error.url = String(resolved);
729
+ throw error;
730
+ }
731
+ if (!stats || !stats.isFile()) {
732
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), true);
733
+ error.url = String(resolved);
734
+ throw error;
735
+ }
736
+ {
737
+ const real = realpathSync(filePath);
738
+ const { search, hash } = resolved;
739
+ resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
740
+ resolved.search = search;
741
+ resolved.hash = hash;
742
+ }
743
+ return resolved;
744
+ }
745
+ function importNotDefined(specifier, packageJsonUrl, base) {
746
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
747
+ }
748
+ function exportsNotFound(subpath, packageJsonUrl, base) {
749
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, base && fileURLToPath(base));
750
+ }
751
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
752
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`, base && fileURLToPath(base));
753
+ }
754
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
755
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
756
+ return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath(base));
757
+ }
758
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
759
+ if (subpath !== "" && !pattern && target.at(-1) !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
760
+ if (!target.startsWith("./")) {
761
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
762
+ let isURL = false;
763
+ try {
764
+ new URL$1(target);
765
+ isURL = true;
766
+ } catch {
767
+ }
768
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
769
+ }
770
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
771
+ }
772
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
773
+ if (!isPathMap) {
774
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
775
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
776
+ }
777
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
778
+ const resolved = new URL$1(target, packageJsonUrl);
779
+ const resolvedPath = resolved.pathname;
780
+ const packagePath = new URL$1(".", packageJsonUrl).pathname;
781
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
782
+ if (subpath === "") return resolved;
783
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
784
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
785
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
786
+ if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
787
+ } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
788
+ }
789
+ if (pattern) return new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
790
+ return new URL$1(subpath, resolved);
791
+ }
792
+ function isArrayIndex(key) {
793
+ const keyNumber = Number(key);
794
+ if (`${keyNumber}` !== key) return false;
795
+ return keyNumber >= 0 && keyNumber < 4294967295;
796
+ }
797
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
798
+ if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
799
+ if (Array.isArray(target)) {
800
+ const targetList = target;
801
+ if (targetList.length === 0) return null;
802
+ let lastException;
803
+ let i = -1;
804
+ while (++i < targetList.length) {
805
+ const targetItem = targetList[i];
806
+ let resolveResult;
807
+ try {
808
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
809
+ } catch (error) {
810
+ const exception = error;
811
+ lastException = exception;
812
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
813
+ throw error;
814
+ }
815
+ if (resolveResult === void 0) continue;
816
+ if (resolveResult === null) {
817
+ lastException = null;
818
+ continue;
819
+ }
820
+ return resolveResult;
821
+ }
822
+ if (lastException === void 0 || lastException === null) return null;
823
+ throw lastException;
824
+ }
825
+ if (typeof target === "object" && target !== null) {
826
+ const keys = Object.getOwnPropertyNames(target);
827
+ let i = -1;
828
+ while (++i < keys.length) {
829
+ const key = keys[i];
830
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), '"exports" cannot contain numeric property keys.');
831
+ }
832
+ i = -1;
833
+ while (++i < keys.length) {
834
+ const key = keys[i];
835
+ if (key === "default" || conditions && conditions.has(key)) {
836
+ const conditionalTarget = target[key];
837
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
838
+ if (resolveResult === void 0) continue;
839
+ return resolveResult;
840
+ }
841
+ }
842
+ return null;
843
+ }
844
+ if (target === null) return null;
845
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
846
+ }
847
+ function isConditionalExportsMainSugar(exports$1, packageJsonUrl, base) {
848
+ if (typeof exports$1 === "string" || Array.isArray(exports$1)) return true;
849
+ if (typeof exports$1 !== "object" || exports$1 === null) return false;
850
+ const keys = Object.getOwnPropertyNames(exports$1);
851
+ let isConditionalSugar = false;
852
+ let i = 0;
853
+ let keyIndex = -1;
854
+ while (++keyIndex < keys.length) {
855
+ const key = keys[keyIndex];
856
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
857
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
858
+ else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`);
859
+ }
860
+ return isConditionalSugar;
861
+ }
862
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
863
+ if (process$1.noDeprecation) return;
864
+ const pjsonPath = fileURLToPath(pjsonUrl);
865
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
866
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
867
+ process$1.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
868
+ }
869
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
870
+ let exports$1 = packageConfig.exports;
871
+ if (isConditionalExportsMainSugar(exports$1, packageJsonUrl, base)) exports$1 = { ".": exports$1 };
872
+ if (own.call(exports$1, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
873
+ const target = exports$1[packageSubpath];
874
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
875
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
876
+ return resolveResult;
877
+ }
878
+ let bestMatch = "";
879
+ let bestMatchSubpath = "";
880
+ const keys = Object.getOwnPropertyNames(exports$1);
881
+ let i = -1;
882
+ while (++i < keys.length) {
883
+ const key = keys[i];
884
+ const patternIndex = key.indexOf("*");
885
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
886
+ if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
887
+ const patternTrailer = key.slice(patternIndex + 1);
888
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
889
+ bestMatch = key;
890
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
891
+ }
892
+ }
893
+ }
894
+ if (bestMatch) {
895
+ const target = exports$1[bestMatch];
896
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
897
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
898
+ return resolveResult;
899
+ }
900
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
901
+ }
902
+ function patternKeyCompare(a, b) {
903
+ const aPatternIndex = a.indexOf("*");
904
+ const bPatternIndex = b.indexOf("*");
905
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
906
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
907
+ if (baseLengthA > baseLengthB) return -1;
908
+ if (baseLengthB > baseLengthA) return 1;
909
+ if (aPatternIndex === -1) return 1;
910
+ if (bPatternIndex === -1) return -1;
911
+ if (a.length > b.length) return -1;
912
+ if (b.length > a.length) return 1;
913
+ return 0;
914
+ }
915
+ function packageImportsResolve(name, base, conditions) {
916
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", fileURLToPath(base));
917
+ let packageJsonUrl;
918
+ const packageConfig = getPackageScopeConfig(base);
919
+ if (packageConfig.exists) {
920
+ packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
921
+ const imports = packageConfig.imports;
922
+ if (imports) if (own.call(imports, name) && !name.includes("*")) {
923
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
924
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
925
+ } else {
926
+ let bestMatch = "";
927
+ let bestMatchSubpath = "";
928
+ const keys = Object.getOwnPropertyNames(imports);
929
+ let i = -1;
930
+ while (++i < keys.length) {
931
+ const key = keys[i];
932
+ const patternIndex = key.indexOf("*");
933
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
934
+ const patternTrailer = key.slice(patternIndex + 1);
935
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
936
+ bestMatch = key;
937
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
938
+ }
939
+ }
940
+ }
941
+ if (bestMatch) {
942
+ const target = imports[bestMatch];
943
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
944
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
945
+ }
946
+ }
947
+ }
948
+ throw importNotDefined(name, packageJsonUrl, base);
949
+ }
950
+ function parsePackageName(specifier, base) {
951
+ let separatorIndex = specifier.indexOf("/");
952
+ let validPackageName = true;
953
+ let isScoped = false;
954
+ if (specifier[0] === "@") {
955
+ isScoped = true;
956
+ if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
957
+ else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
958
+ }
959
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
960
+ if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
961
+ if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath(base));
962
+ return {
963
+ packageName,
964
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
965
+ isScoped
966
+ };
967
+ }
968
+ function packageResolve(specifier, base, conditions) {
969
+ if (nodeBuiltins.includes(specifier)) return new URL$1("node:" + specifier);
970
+ const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
971
+ const packageConfig = getPackageScopeConfig(base);
972
+ if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(pathToFileURL(packageConfig.pjsonPath), packageSubpath, packageConfig, base, conditions);
973
+ let packageJsonUrl = new URL$1("./node_modules/" + packageName + "/package.json", base);
974
+ let packageJsonPath = fileURLToPath(packageJsonUrl);
975
+ let lastPath;
976
+ do {
977
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
978
+ if (!stat || !stat.isDirectory()) {
979
+ lastPath = packageJsonPath;
980
+ packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
981
+ packageJsonPath = fileURLToPath(packageJsonUrl);
982
+ continue;
983
+ }
984
+ const packageConfig$1 = read(packageJsonPath, {
985
+ base,
986
+ specifier
987
+ });
988
+ if (packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions);
989
+ if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig$1, base);
990
+ return new URL$1(packageSubpath, packageJsonUrl);
991
+ } while (packageJsonPath.length !== lastPath.length);
992
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
993
+ }
994
+ function isRelativeSpecifier(specifier) {
995
+ if (specifier[0] === ".") {
996
+ if (specifier.length === 1 || specifier[1] === "/") return true;
997
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
998
+ }
999
+ return false;
1000
+ }
1001
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1002
+ if (specifier === "") return false;
1003
+ if (specifier[0] === "/") return true;
1004
+ return isRelativeSpecifier(specifier);
1005
+ }
1006
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1007
+ const protocol = base.protocol;
1008
+ const isData = protocol === "data:";
1009
+ let resolved;
1010
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
1011
+ resolved = new URL$1(specifier, base);
1012
+ } catch (error_) {
1013
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1014
+ error.cause = error_;
1015
+ throw error;
1016
+ }
1017
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
1018
+ else try {
1019
+ resolved = new URL$1(specifier);
1020
+ } catch (error_) {
1021
+ if (isData && !nodeBuiltins.includes(specifier)) {
1022
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1023
+ error.cause = error_;
1024
+ throw error;
1025
+ }
1026
+ resolved = packageResolve(specifier, base, conditions);
1027
+ }
1028
+ assert.ok(resolved !== void 0, "expected to be defined");
1029
+ if (resolved.protocol !== "file:") return resolved;
1030
+ return finalizeResolution(resolved, base);
1031
+ }
1032
+ var DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
1033
+ var isWindows = /* @__PURE__ */ (() => process.platform === "win32")();
1034
+ var globalCache = /* @__PURE__ */ (() => globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map())();
1035
+ function resolveModuleURL(input, options) {
1036
+ const parsedInput = _parseInput(input);
1037
+ if ("external" in parsedInput) return parsedInput.external;
1038
+ const specifier = parsedInput.specifier;
1039
+ let url = parsedInput.url;
1040
+ let absolutePath = parsedInput.absolutePath;
1041
+ let cacheKey;
1042
+ let cacheObj;
1043
+ if (options?.cache !== false) {
1044
+ cacheKey = _cacheKey(absolutePath || specifier, options);
1045
+ cacheObj = options?.cache && typeof options?.cache === "object" ? options.cache : globalCache;
1046
+ }
1047
+ if (cacheObj) {
1048
+ const cached = cacheObj.get(cacheKey);
1049
+ if (typeof cached === "string") return cached;
1050
+ if (cached instanceof Error) {
1051
+ if (options?.try) return;
1052
+ throw cached;
1053
+ }
1054
+ }
1055
+ if (absolutePath) try {
1056
+ const stat = lstatSync(absolutePath);
1057
+ if (stat.isSymbolicLink()) {
1058
+ absolutePath = realpathSync(absolutePath);
1059
+ url = pathToFileURL(absolutePath);
1060
+ }
1061
+ if (stat.isFile()) {
1062
+ if (cacheObj) cacheObj.set(cacheKey, url.href);
1063
+ return url.href;
1064
+ }
1065
+ } catch (error) {
1066
+ if (error?.code !== "ENOENT") {
1067
+ if (cacheObj) cacheObj.set(cacheKey, error);
1068
+ throw error;
1069
+ }
1070
+ }
1071
+ const conditionsSet = options?.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
1072
+ const target = specifier || url.href;
1073
+ const bases = _normalizeBases(options?.from);
1074
+ const suffixes = options?.suffixes || [""];
1075
+ const extensions = options?.extensions ? ["", ...options.extensions] : [""];
1076
+ let resolved;
1077
+ for (const base of bases) {
1078
+ for (const suffix of suffixes) {
1079
+ let name = _join(target, suffix);
1080
+ if (name === ".") name += "/.";
1081
+ for (const extension of extensions) {
1082
+ resolved = _tryModuleResolve(name + extension, base, conditionsSet);
1083
+ if (resolved) break;
1084
+ }
1085
+ if (resolved) break;
1086
+ }
1087
+ if (resolved) break;
1088
+ }
1089
+ if (!resolved) {
1090
+ const error = /* @__PURE__ */ new Error(`Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`);
1091
+ error.code = "ERR_MODULE_NOT_FOUND";
1092
+ if (cacheObj) cacheObj.set(cacheKey, error);
1093
+ if (options?.try) return;
1094
+ throw error;
1095
+ }
1096
+ if (cacheObj) cacheObj.set(cacheKey, resolved.href);
1097
+ return resolved.href;
1098
+ }
1099
+ function resolveModulePath(id, options) {
1100
+ const resolved = resolveModuleURL(id, options);
1101
+ if (!resolved) return;
1102
+ if (!resolved.startsWith("file://") && options?.try) return;
1103
+ const absolutePath = fileURLToPath(resolved);
1104
+ return isWindows ? _normalizeWinPath(absolutePath) : absolutePath;
1105
+ }
1106
+ function _tryModuleResolve(specifier, base, conditions) {
1107
+ try {
1108
+ return moduleResolve(specifier, base, conditions);
1109
+ } catch {
1110
+ }
1111
+ }
1112
+ function _normalizeBases(inputs) {
1113
+ const urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap((input) => _normalizeBase(input));
1114
+ if (urls.length === 0) return [pathToFileURL("./")];
1115
+ return urls;
1116
+ }
1117
+ function _normalizeBase(input) {
1118
+ if (!input) return [];
1119
+ if (_isURL(input)) return [input];
1120
+ if (typeof input !== "string") return [];
1121
+ if (/^(?:node|data|http|https|file):/.test(input)) return new URL(input);
1122
+ try {
1123
+ if (input.endsWith("/") || statSync(input).isDirectory()) return pathToFileURL(input + "/");
1124
+ return pathToFileURL(input);
1125
+ } catch {
1126
+ return [pathToFileURL(input + "/"), pathToFileURL(input)];
1127
+ }
1128
+ }
1129
+ function _fmtPath(input) {
1130
+ try {
1131
+ return fileURLToPath(input);
1132
+ } catch {
1133
+ return input;
1134
+ }
1135
+ }
1136
+ function _cacheKey(id, opts) {
1137
+ return JSON.stringify([
1138
+ id,
1139
+ (opts?.conditions || ["node", "import"]).sort(),
1140
+ opts?.extensions,
1141
+ opts?.from,
1142
+ opts?.suffixes
1143
+ ]);
1144
+ }
1145
+ function _join(a, b) {
1146
+ if (!a || !b || b === "/") return a;
1147
+ return (a.endsWith("/") ? a : a + "/") + (b.startsWith("/") ? b.slice(1) : b);
1148
+ }
1149
+ function _normalizeWinPath(path$1) {
1150
+ return path$1.replace(/\\/g, "/").replace(/^[a-z]:\//, (r) => r.toUpperCase());
1151
+ }
1152
+ function _isURL(input) {
1153
+ return input instanceof URL || input?.constructor?.name === "URL";
1154
+ }
1155
+ function _parseInput(input) {
1156
+ if (typeof input === "string") {
1157
+ if (input.startsWith("file:")) {
1158
+ const url = new URL(input);
1159
+ return {
1160
+ url,
1161
+ absolutePath: fileURLToPath(url)
1162
+ };
1163
+ }
1164
+ if (isAbsolute$1(input)) return {
1165
+ url: pathToFileURL(input),
1166
+ absolutePath: input
1167
+ };
1168
+ if (/^(?:node|data|http|https):/.test(input)) return { external: input };
1169
+ if (nodeBuiltins.includes(input) && !input.includes(":")) return { external: `node:${input}` };
1170
+ return { specifier: input };
1171
+ }
1172
+ if (_isURL(input)) {
1173
+ if (input.protocol === "file:") return {
1174
+ url: input,
1175
+ absolutePath: fileURLToPath(input)
1176
+ };
1177
+ return { external: input.href };
1178
+ }
1179
+ throw new TypeError("id must be a `string` or `URL`");
1180
+ }
1181
+ var defaultFindOptions = {
1182
+ startingFrom: ".",
1183
+ rootPattern: /^node_modules$/,
1184
+ reverse: false,
1185
+ test: (filePath) => {
1186
+ try {
1187
+ if (statSync(filePath).isFile()) {
1188
+ return true;
1189
+ }
1190
+ } catch {
1191
+ }
1192
+ }
1193
+ };
1194
+ async function findFile(filename, _options = {}) {
1195
+ const filenames = Array.isArray(filename) ? filename : [filename];
1196
+ const options = { ...defaultFindOptions, ..._options };
1197
+ const basePath = resolve(options.startingFrom);
1198
+ const leadingSlash = basePath[0] === "/";
1199
+ const segments = basePath.split("/").filter(Boolean);
1200
+ if (filenames.includes(segments.at(-1)) && await options.test(basePath)) {
1201
+ return basePath;
1202
+ }
1203
+ if (leadingSlash) {
1204
+ segments[0] = "/" + segments[0];
1205
+ }
1206
+ let root = segments.findIndex((r) => r.match(options.rootPattern));
1207
+ if (root === -1) {
1208
+ root = 0;
1209
+ }
1210
+ if (options.reverse) {
1211
+ for (let index = root + 1; index <= segments.length; index++) {
1212
+ for (const filename2 of filenames) {
1213
+ const filePath = join(...segments.slice(0, index), filename2);
1214
+ if (await options.test(filePath)) {
1215
+ return filePath;
1216
+ }
1217
+ }
1218
+ }
1219
+ } else {
1220
+ for (let index = segments.length; index > root; index--) {
1221
+ for (const filename2 of filenames) {
1222
+ const filePath = join(...segments.slice(0, index), filename2);
1223
+ if (await options.test(filePath)) {
1224
+ return filePath;
1225
+ }
1226
+ }
1227
+ }
1228
+ }
1229
+ throw new Error(
1230
+ `Cannot find matching ${filename} in ${options.startingFrom} or parent directories`
1231
+ );
1232
+ }
1233
+ function findNearestFile(filename, options = {}) {
1234
+ return findFile(filename, options);
1235
+ }
1236
+ function _resolvePath(id, opts = {}) {
1237
+ if (id instanceof URL || id.startsWith("file://")) {
1238
+ return normalize(fileURLToPath(id));
1239
+ }
1240
+ if (isAbsolute(id)) {
1241
+ return normalize(id);
1242
+ }
1243
+ return resolveModulePath(id, {
1244
+ ...opts,
1245
+ from: opts.from || opts.parent || opts.url
1246
+ });
1247
+ }
1248
+ var FileCache = /* @__PURE__ */ new Map();
1249
+ async function readPackageJSON(id, options = {}) {
1250
+ const resolvedPath = await resolvePackageJSON(id, options);
1251
+ const cache2 = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
1252
+ if (options.cache && cache2.has(resolvedPath)) {
1253
+ return cache2.get(resolvedPath);
1254
+ }
1255
+ const blob = await promises.readFile(resolvedPath, "utf8");
1256
+ let parsed;
1257
+ try {
1258
+ parsed = x(blob);
1259
+ } catch {
1260
+ parsed = h(blob);
1261
+ }
1262
+ cache2.set(resolvedPath, parsed);
1263
+ return parsed;
1264
+ }
1265
+ async function resolvePackageJSON(id = process.cwd(), options = {}) {
1266
+ return findNearestFile("package.json", {
1267
+ ...options,
1268
+ startingFrom: _resolvePath(id, options)
1269
+ });
1270
+ }
1271
+
1272
+ export { basename, defu, dirname, isAbsolute, join, normalize, normalizeWindowsPath, readPackageJSON, relative, resolve, resolveModulePath };