storybook 10.0.0-beta.0 → 10.0.0-beta.10

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.
Files changed (126) hide show
  1. package/assets/server/openBrowser.applescript +94 -0
  2. package/dist/_browser-chunks/Color-KPLIACXP.js +1569 -0
  3. package/dist/_browser-chunks/{WithTooltip-2E62HIBN.js → WithTooltip-SK46ZJ2J.js} +1 -1
  4. package/dist/_browser-chunks/{chunk-YY5GICNT.js → chunk-6E2SHJSL.js} +175 -32
  5. package/dist/_browser-chunks/{chunk-FWKO3E35.js → chunk-BOOOPFZF.js} +10 -3
  6. package/dist/_browser-chunks/{chunk-YWDKX534.js → chunk-FA42P6MO.js} +49 -4
  7. package/dist/_browser-chunks/chunk-G33S6YM3.js +521 -0
  8. package/dist/_browser-chunks/{chunk-MZNYTCNT.js → chunk-HMIIJ6UD.js} +6 -6
  9. package/dist/_browser-chunks/{chunk-4QPX7WIQ.js → chunk-JJZMHC3A.js} +57 -166
  10. package/dist/_browser-chunks/{chunk-MD2FTHCZ.js → chunk-JVSKG4YS.js} +3 -16
  11. package/dist/_browser-chunks/{chunk-E7VLET3C.js → chunk-KSCAWCCE.js} +3947 -4291
  12. package/dist/_browser-chunks/{chunk-PYK5ZTFK.js → chunk-PS3AOQI4.js} +48 -25
  13. package/dist/_browser-chunks/chunk-QK3L5AXO.js +372 -0
  14. package/dist/_browser-chunks/chunk-SHR3NNR3.js +5810 -0
  15. package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
  16. package/dist/_browser-chunks/chunk-VUAFL5XK.js +20 -0
  17. package/dist/_browser-chunks/{chunk-T7RCAJIX.js → chunk-Y3M7TW6K.js} +43 -47
  18. package/dist/_browser-chunks/{syntaxhighlighter-YYAA4CS4.js → syntaxhighlighter-R46XOLMC.js} +1 -1
  19. package/dist/_node-chunks/{builder-manager-OW6YGKXV.js → builder-manager-SJGIDEN6.js} +45 -155
  20. package/dist/_node-chunks/camelcase-VZHWABQV.js +18 -0
  21. package/dist/_node-chunks/{chunk-6JSVPEAU.js → chunk-6CZW7AGN.js} +7 -7
  22. package/dist/_node-chunks/{chunk-CD3IP6HA.js → chunk-6XT5OLNL.js} +12 -12
  23. package/dist/_node-chunks/{chunk-2H7LZ2SD.js → chunk-AHRH5RPR.js} +7 -7
  24. package/dist/_node-chunks/{chunk-5HLANIBM.js → chunk-AOH6ABSV.js} +7 -7
  25. package/dist/_node-chunks/chunk-C5V22GP7.js +79 -0
  26. package/dist/_node-chunks/{chunk-IBXERYDG.js → chunk-FIROF4DV.js} +7 -7
  27. package/dist/_node-chunks/{chunk-I3YCPGZJ.js → chunk-GUJVZUYI.js} +7 -7
  28. package/dist/_node-chunks/chunk-IHPLRRAR.js +4741 -0
  29. package/dist/_node-chunks/{chunk-7TISOZS6.js → chunk-JMXKCRWR.js} +30 -21
  30. package/dist/_node-chunks/{chunk-YWGNEBRO.js → chunk-JUMUXWEV.js} +162 -103
  31. package/dist/_node-chunks/{chunk-UIREEOC7.js → chunk-KGX33KXX.js} +7 -7
  32. package/dist/_node-chunks/{chunk-3QB3ZG6H.js → chunk-KLVABNEU.js} +7 -7
  33. package/dist/_node-chunks/{chunk-H5LTFJHQ.js → chunk-OL6DY6BT.js} +631 -752
  34. package/dist/_node-chunks/{chunk-X5GAZ3EW.js → chunk-ONJV3K2L.js} +399 -116
  35. package/dist/_node-chunks/{chunk-LKB7KRSV.js → chunk-PTHTD4RO.js} +223 -243
  36. package/dist/_node-chunks/{chunk-UHHZPSP7.js → chunk-QQ3Z5KGJ.js} +6 -6
  37. package/dist/_node-chunks/{chunk-MUD3GH3L.js → chunk-QRTDDTZJ.js} +9 -9
  38. package/dist/_node-chunks/chunk-R54K4KSM.js +1540 -0
  39. package/dist/_node-chunks/{chunk-IQAUGVYR.js → chunk-S2LZC6JK.js} +8 -8
  40. package/dist/_node-chunks/chunk-SFJFSPRT.js +62 -0
  41. package/dist/_node-chunks/{chunk-LH3BEEIR.js → chunk-SSN5PKIY.js} +6 -6
  42. package/dist/_node-chunks/{chunk-NOQITS3C.js → chunk-SXR2DITB.js} +7 -7
  43. package/dist/_node-chunks/{chunk-FWUE7SRE.js → chunk-TH5QVQRL.js} +7 -7
  44. package/dist/_node-chunks/chunk-U34NWAU2.js +18 -0
  45. package/dist/_node-chunks/{chunk-FBMMEEO4.js → chunk-UV3CZ3KS.js} +7 -7
  46. package/dist/_node-chunks/{chunk-NZGJJABJ.js → chunk-UVUGJDAI.js} +60 -102
  47. package/dist/_node-chunks/{chunk-GZUNYRFU.js → chunk-VOUNSD2E.js} +7 -7
  48. package/dist/_node-chunks/chunk-WFCPBKQJ.js +64656 -0
  49. package/dist/_node-chunks/{chunk-BFXER3XW.js → chunk-XHF3WWNP.js} +623 -750
  50. package/dist/_node-chunks/{chunk-ANEKBWDX.js → chunk-XU45KXNQ.js} +16 -25
  51. package/dist/_node-chunks/{camelcase-2K3EMR6G.js → chunk-YHO6XR7U.js} +9 -8
  52. package/dist/_node-chunks/{dist-465RSKRC.js → dist-IIC5PBL7.js} +9 -9
  53. package/dist/_node-chunks/{globby-LJ3MVB6M.js → globby-CJACC3HJ.js} +17 -13
  54. package/dist/_node-chunks/{lib-OW3DENXB.js → lib-ZY4TKSOR.js} +40 -16
  55. package/dist/_node-chunks/{mdx-N42X6CFJ-PYX2IFUO.js → mdx-N42X6CFJ-3XNW3DFO.js} +8 -8
  56. package/dist/_node-chunks/{p-limit-X4OG45RB.js → p-limit-R2OFT5HE.js} +76 -10
  57. package/dist/_node-chunks/{plugin-ALTIQMDE.js → plugin-5XD5R2KD.js} +10 -10
  58. package/dist/_node-chunks/{plugin-GE36R32R.js → plugin-WAWVQMVR.js} +10 -12
  59. package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-NLCAF7S6.js → webpack-inject-mocker-runtime-plugin-SCRGJLIS.js} +1307 -847
  60. package/dist/_node-chunks/{webpack-mock-plugin-BRYODMCC.js → webpack-mock-plugin-3VAXEGG2.js} +9 -11
  61. package/dist/babel/index.d.ts +1 -1
  62. package/dist/babel/index.js +11 -12
  63. package/dist/bin/core.js +638 -187
  64. package/dist/bin/dispatcher.js +11 -11
  65. package/dist/bin/loader.js +8 -8
  66. package/dist/cli/index.d.ts +62 -75
  67. package/dist/cli/index.js +66 -56
  68. package/dist/common/index.d.ts +3 -1
  69. package/dist/common/index.js +22 -22
  70. package/dist/components/index.d.ts +234 -2
  71. package/dist/components/index.js +74 -5741
  72. package/dist/core-events/index.d.ts +18 -2
  73. package/dist/core-events/index.js +7 -1
  74. package/dist/core-server/index.d.ts +540 -39
  75. package/dist/core-server/index.js +4647 -4182
  76. package/dist/core-server/presets/common-manager.js +1570 -1272
  77. package/dist/core-server/presets/common-override-preset.js +9 -9
  78. package/dist/core-server/presets/common-preset.js +691 -38
  79. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -11
  80. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -12
  81. package/dist/csf/index.d.ts +9 -4
  82. package/dist/csf/index.js +50 -15
  83. package/dist/csf-tools/index.d.ts +47 -6
  84. package/dist/csf-tools/index.js +9 -9
  85. package/dist/docs-tools/index.js +4 -4
  86. package/dist/instrumenter/index.js +1 -1
  87. package/dist/manager/globals-runtime.js +9233 -18113
  88. package/dist/manager/globals.d.ts +0 -4
  89. package/dist/manager/globals.js +1 -6
  90. package/dist/manager/runtime.js +13396 -11518
  91. package/dist/manager-api/index.d.ts +540 -32
  92. package/dist/manager-api/index.js +364 -90
  93. package/dist/manager-errors.d.ts +527 -0
  94. package/dist/node-logger/index.d.ts +1 -1
  95. package/dist/node-logger/index.js +1136 -662
  96. package/dist/preview/globals.js +1 -1
  97. package/dist/preview/runtime.js +12103 -21579
  98. package/dist/preview-api/index.d.ts +3 -3
  99. package/dist/preview-api/index.js +10 -10
  100. package/dist/preview-errors.d.ts +527 -0
  101. package/dist/router/index.d.ts +668 -10
  102. package/dist/router/index.js +2 -2
  103. package/dist/server-errors.d.ts +527 -0
  104. package/dist/server-errors.js +10 -10
  105. package/dist/telemetry/index.d.ts +1 -1
  106. package/dist/telemetry/index.js +23 -25
  107. package/dist/test/index.js +1874 -4024
  108. package/dist/theming/index.d.ts +2 -2
  109. package/dist/theming/index.js +6 -6
  110. package/dist/types/index.d.ts +553 -16
  111. package/dist/viewport/index.d.ts +36 -4
  112. package/dist/viewport/index.js +1 -1
  113. package/package.json +9 -46
  114. package/dist/_browser-chunks/Color-SFYJJKWL.js +0 -605
  115. package/dist/_browser-chunks/chunk-DHO2SA6L.js +0 -12
  116. package/dist/_browser-chunks/chunk-WPHPDNUA.js +0 -974
  117. package/dist/_node-chunks/chunk-27W2Z6VL.js +0 -28502
  118. package/dist/_node-chunks/chunk-G46DWX7Z.js +0 -266
  119. package/dist/_node-chunks/chunk-GZZDIJIB.js +0 -80
  120. package/dist/_node-chunks/chunk-JDKH3XYB.js +0 -9845
  121. package/dist/_node-chunks/chunk-R7RKO2DC.js +0 -35783
  122. package/dist/_node-chunks/chunk-T23YQHYB.js +0 -62
  123. package/dist/_node-chunks/chunk-VKKLKNFC.js +0 -2377
  124. package/dist/_node-chunks/chunk-W6GKFQ7F.js +0 -87
  125. package/dist/_node-chunks/chunk-YUYBO6S7.js +0 -18
  126. package/dist/_node-chunks/default-browser-id-Z6WQ7DZA.js +0 -1719
@@ -0,0 +1,1540 @@
1
+ import CJS_COMPAT_NODE_URL_kzg6jc8bd2 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_kzg6jc8bd2 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_kzg6jc8bd2 from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_kzg6jc8bd2.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_kzg6jc8bd2.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_kzg6jc8bd2.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ dirname,
14
+ join
15
+ } from "./chunk-AOH6ABSV.js";
16
+ import {
17
+ __name
18
+ } from "./chunk-SSN5PKIY.js";
19
+
20
+ // ../node_modules/exsolve/dist/index.mjs
21
+ import fs, { realpathSync, statSync, lstatSync } from "node:fs";
22
+ import { fileURLToPath, URL as URL$1, pathToFileURL } from "node:url";
23
+ import path, { isAbsolute } from "node:path";
24
+ import assert from "node:assert";
25
+ import process$1 from "node:process";
26
+ import v8 from "node:v8";
27
+ import { format, inspect } from "node:util";
28
+ var nodeBuiltins = [
29
+ "_http_agent",
30
+ "_http_client",
31
+ "_http_common",
32
+ "_http_incoming",
33
+ "_http_outgoing",
34
+ "_http_server",
35
+ "_stream_duplex",
36
+ "_stream_passthrough",
37
+ "_stream_readable",
38
+ "_stream_transform",
39
+ "_stream_wrap",
40
+ "_stream_writable",
41
+ "_tls_common",
42
+ "_tls_wrap",
43
+ "assert",
44
+ "assert/strict",
45
+ "async_hooks",
46
+ "buffer",
47
+ "child_process",
48
+ "cluster",
49
+ "console",
50
+ "constants",
51
+ "crypto",
52
+ "dgram",
53
+ "diagnostics_channel",
54
+ "dns",
55
+ "dns/promises",
56
+ "domain",
57
+ "events",
58
+ "fs",
59
+ "fs/promises",
60
+ "http",
61
+ "http2",
62
+ "https",
63
+ "inspector",
64
+ "inspector/promises",
65
+ "module",
66
+ "net",
67
+ "os",
68
+ "path",
69
+ "path/posix",
70
+ "path/win32",
71
+ "perf_hooks",
72
+ "process",
73
+ "punycode",
74
+ "querystring",
75
+ "readline",
76
+ "readline/promises",
77
+ "repl",
78
+ "stream",
79
+ "stream/consumers",
80
+ "stream/promises",
81
+ "stream/web",
82
+ "string_decoder",
83
+ "sys",
84
+ "timers",
85
+ "timers/promises",
86
+ "tls",
87
+ "trace_events",
88
+ "tty",
89
+ "url",
90
+ "util",
91
+ "util/types",
92
+ "v8",
93
+ "vm",
94
+ "wasi",
95
+ "worker_threads",
96
+ "zlib"
97
+ ];
98
+ var own$1 = {}.hasOwnProperty;
99
+ var classRegExp = /^([A-Z][a-z\d]*)+$/;
100
+ var kTypes = /* @__PURE__ */ new Set([
101
+ "string",
102
+ "function",
103
+ "number",
104
+ "object",
105
+ // Accept 'Function' and 'Object' as alternative to the lower cased version.
106
+ "Function",
107
+ "Object",
108
+ "boolean",
109
+ "bigint",
110
+ "symbol"
111
+ ]);
112
+ var messages = /* @__PURE__ */ new Map();
113
+ var nodeInternalPrefix = "__node_internal_";
114
+ var userStackTraceLimit;
115
+ function formatList(array, type = "and") {
116
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
117
+ }
118
+ __name(formatList, "formatList");
119
+ function createError(sym, value, constructor) {
120
+ messages.set(sym, value);
121
+ return makeNodeErrorWithCode(constructor, sym);
122
+ }
123
+ __name(createError, "createError");
124
+ function makeNodeErrorWithCode(Base, key) {
125
+ return /* @__PURE__ */ __name(function NodeError(...parameters) {
126
+ const limit = Error.stackTraceLimit;
127
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
128
+ const error = new Base();
129
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
130
+ const message = getMessage(key, parameters, error);
131
+ Object.defineProperties(error, {
132
+ // Note: no need to implement `kIsNodeError` symbol, would be hard,
133
+ // probably.
134
+ message: {
135
+ value: message,
136
+ enumerable: false,
137
+ writable: true,
138
+ configurable: true
139
+ },
140
+ toString: {
141
+ /** @this {Error} */
142
+ value() {
143
+ return `${this.name} [${key}]: ${this.message}`;
144
+ },
145
+ enumerable: false,
146
+ writable: true,
147
+ configurable: true
148
+ }
149
+ });
150
+ captureLargerStackTrace(error);
151
+ error.code = key;
152
+ return error;
153
+ }, "NodeError");
154
+ }
155
+ __name(makeNodeErrorWithCode, "makeNodeErrorWithCode");
156
+ function isErrorStackTraceLimitWritable() {
157
+ try {
158
+ if (v8.startupSnapshot.isBuildingSnapshot()) {
159
+ return false;
160
+ }
161
+ } catch {
162
+ }
163
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
164
+ if (desc === void 0) {
165
+ return Object.isExtensible(Error);
166
+ }
167
+ return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
168
+ }
169
+ __name(isErrorStackTraceLimitWritable, "isErrorStackTraceLimitWritable");
170
+ function hideStackFrames(wrappedFunction) {
171
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
172
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
173
+ return wrappedFunction;
174
+ }
175
+ __name(hideStackFrames, "hideStackFrames");
176
+ var captureLargerStackTrace = hideStackFrames(function(error) {
177
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
178
+ if (stackTraceLimitIsWritable) {
179
+ userStackTraceLimit = Error.stackTraceLimit;
180
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
181
+ }
182
+ Error.captureStackTrace(error);
183
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
184
+ return error;
185
+ });
186
+ function getMessage(key, parameters, self) {
187
+ const message = messages.get(key);
188
+ assert(message !== void 0, "expected `message` to be found");
189
+ if (typeof message === "function") {
190
+ assert(
191
+ message.length <= parameters.length,
192
+ // Default options do not count.
193
+ `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
194
+ );
195
+ return Reflect.apply(message, self, parameters);
196
+ }
197
+ const regex = /%[dfijoOs]/g;
198
+ let expectedLength = 0;
199
+ while (regex.exec(message) !== null) expectedLength++;
200
+ assert(
201
+ expectedLength === parameters.length,
202
+ `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
203
+ );
204
+ if (parameters.length === 0) return message;
205
+ parameters.unshift(message);
206
+ return Reflect.apply(format, null, parameters);
207
+ }
208
+ __name(getMessage, "getMessage");
209
+ function determineSpecificType(value) {
210
+ if (value === null || value === void 0) {
211
+ return String(value);
212
+ }
213
+ if (typeof value === "function" && value.name) {
214
+ return `function ${value.name}`;
215
+ }
216
+ if (typeof value === "object") {
217
+ if (value.constructor && value.constructor.name) {
218
+ return `an instance of ${value.constructor.name}`;
219
+ }
220
+ return `${inspect(value, { depth: -1 })}`;
221
+ }
222
+ let inspected = inspect(value, { colors: false });
223
+ if (inspected.length > 28) {
224
+ inspected = `${inspected.slice(0, 25)}...`;
225
+ }
226
+ return `type ${typeof value} (${inspected})`;
227
+ }
228
+ __name(determineSpecificType, "determineSpecificType");
229
+ createError(
230
+ "ERR_INVALID_ARG_TYPE",
231
+ (name, expected, actual) => {
232
+ assert(typeof name === "string", "'name' must be a string");
233
+ if (!Array.isArray(expected)) {
234
+ expected = [expected];
235
+ }
236
+ let message = "The ";
237
+ if (name.endsWith(" argument")) {
238
+ message += `${name} `;
239
+ } else {
240
+ const type = name.includes(".") ? "property" : "argument";
241
+ message += `"${name}" ${type} `;
242
+ }
243
+ message += "must be ";
244
+ const types = [];
245
+ const instances = [];
246
+ const other = [];
247
+ for (const value of expected) {
248
+ assert(
249
+ typeof value === "string",
250
+ "All expected entries have to be of type string"
251
+ );
252
+ if (kTypes.has(value)) {
253
+ types.push(value.toLowerCase());
254
+ } else if (classRegExp.exec(value) === null) {
255
+ assert(
256
+ value !== "object",
257
+ 'The value "object" should be written as "Object"'
258
+ );
259
+ other.push(value);
260
+ } else {
261
+ instances.push(value);
262
+ }
263
+ }
264
+ if (instances.length > 0) {
265
+ const pos = types.indexOf("object");
266
+ if (pos !== -1) {
267
+ types.slice(pos, 1);
268
+ instances.push("Object");
269
+ }
270
+ }
271
+ if (types.length > 0) {
272
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
273
+ types,
274
+ "or"
275
+ )}`;
276
+ if (instances.length > 0 || other.length > 0) message += " or ";
277
+ }
278
+ if (instances.length > 0) {
279
+ message += `an instance of ${formatList(instances, "or")}`;
280
+ if (other.length > 0) message += " or ";
281
+ }
282
+ if (other.length > 0) {
283
+ if (other.length > 1) {
284
+ message += `one of ${formatList(other, "or")}`;
285
+ } else {
286
+ if (other[0]?.toLowerCase() !== other[0]) message += "an ";
287
+ message += `${other[0]}`;
288
+ }
289
+ }
290
+ message += `. Received ${determineSpecificType(actual)}`;
291
+ return message;
292
+ },
293
+ TypeError
294
+ );
295
+ var ERR_INVALID_MODULE_SPECIFIER = createError(
296
+ "ERR_INVALID_MODULE_SPECIFIER",
297
+ /**
298
+ * @param {string} request
299
+ * @param {string} reason
300
+ * @param {string} [base]
301
+ */
302
+ (request, reason, base) => {
303
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
304
+ },
305
+ TypeError
306
+ );
307
+ var ERR_INVALID_PACKAGE_CONFIG = createError(
308
+ "ERR_INVALID_PACKAGE_CONFIG",
309
+ (path2, base, message) => {
310
+ return `Invalid package config ${path2}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
311
+ },
312
+ Error
313
+ );
314
+ var ERR_INVALID_PACKAGE_TARGET = createError(
315
+ "ERR_INVALID_PACKAGE_TARGET",
316
+ (packagePath, key, target, isImport = false, base) => {
317
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
318
+ if (key === ".") {
319
+ assert(isImport === false);
320
+ 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 "./"' : ""}`;
321
+ }
322
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
323
+ target
324
+ )} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
325
+ },
326
+ Error
327
+ );
328
+ var ERR_MODULE_NOT_FOUND = createError(
329
+ "ERR_MODULE_NOT_FOUND",
330
+ (path2, base, exactUrl = false) => {
331
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path2}' imported from ${base}`;
332
+ },
333
+ Error
334
+ );
335
+ createError(
336
+ "ERR_NETWORK_IMPORT_DISALLOWED",
337
+ "import of '%s' by %s is not supported: %s",
338
+ Error
339
+ );
340
+ var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
341
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
342
+ (specifier, packagePath, base) => {
343
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
344
+ },
345
+ TypeError
346
+ );
347
+ var ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
348
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
349
+ /**
350
+ * @param {string} packagePath
351
+ * @param {string} subpath
352
+ * @param {string} [base]
353
+ */
354
+ (packagePath, subpath, base) => {
355
+ if (subpath === ".")
356
+ return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
357
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
358
+ },
359
+ Error
360
+ );
361
+ var ERR_UNSUPPORTED_DIR_IMPORT = createError(
362
+ "ERR_UNSUPPORTED_DIR_IMPORT",
363
+ "Directory import '%s' is not supported resolving ES modules imported from %s",
364
+ Error
365
+ );
366
+ var ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
367
+ "ERR_UNSUPPORTED_RESOLVE_REQUEST",
368
+ 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
369
+ TypeError
370
+ );
371
+ var ERR_UNKNOWN_FILE_EXTENSION = createError(
372
+ "ERR_UNKNOWN_FILE_EXTENSION",
373
+ (extension, path2) => {
374
+ return `Unknown file extension "${extension}" for ${path2}`;
375
+ },
376
+ TypeError
377
+ );
378
+ createError(
379
+ "ERR_INVALID_ARG_VALUE",
380
+ (name, value, reason = "is invalid") => {
381
+ let inspected = inspect(value);
382
+ if (inspected.length > 128) {
383
+ inspected = `${inspected.slice(0, 128)}...`;
384
+ }
385
+ const type = name.includes(".") ? "property" : "argument";
386
+ return `The ${type} '${name}' ${reason}. Received ${inspected}`;
387
+ },
388
+ TypeError
389
+ // Note: extra classes have been shaken out.
390
+ // , RangeError
391
+ );
392
+ var hasOwnProperty$1 = {}.hasOwnProperty;
393
+ var cache = /* @__PURE__ */ new Map();
394
+ function read(jsonPath, { base, specifier }) {
395
+ const existing = cache.get(jsonPath);
396
+ if (existing) {
397
+ return existing;
398
+ }
399
+ let string;
400
+ try {
401
+ string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
402
+ } catch (error) {
403
+ const exception = error;
404
+ if (exception.code !== "ENOENT") {
405
+ throw exception;
406
+ }
407
+ }
408
+ const result = {
409
+ exists: false,
410
+ pjsonPath: jsonPath,
411
+ main: void 0,
412
+ name: void 0,
413
+ type: "none",
414
+ // Ignore unknown types for forwards compatibility
415
+ exports: void 0,
416
+ imports: void 0
417
+ };
418
+ if (string !== void 0) {
419
+ let parsed;
420
+ try {
421
+ parsed = JSON.parse(string);
422
+ } catch (error_) {
423
+ const error = new ERR_INVALID_PACKAGE_CONFIG(
424
+ jsonPath,
425
+ (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier),
426
+ error_.message
427
+ );
428
+ error.cause = error_;
429
+ throw error;
430
+ }
431
+ result.exists = true;
432
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") {
433
+ result.name = parsed.name;
434
+ }
435
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") {
436
+ result.main = parsed.main;
437
+ }
438
+ if (hasOwnProperty$1.call(parsed, "exports")) {
439
+ result.exports = parsed.exports;
440
+ }
441
+ if (hasOwnProperty$1.call(parsed, "imports")) {
442
+ result.imports = parsed.imports;
443
+ }
444
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
445
+ result.type = parsed.type;
446
+ }
447
+ }
448
+ cache.set(jsonPath, result);
449
+ return result;
450
+ }
451
+ __name(read, "read");
452
+ function getPackageScopeConfig(resolved) {
453
+ let packageJSONUrl = new URL("package.json", resolved);
454
+ while (true) {
455
+ const packageJSONPath2 = packageJSONUrl.pathname;
456
+ if (packageJSONPath2.endsWith("node_modules/package.json")) {
457
+ break;
458
+ }
459
+ const packageConfig = read(fileURLToPath(packageJSONUrl), {
460
+ specifier: resolved
461
+ });
462
+ if (packageConfig.exists) {
463
+ return packageConfig;
464
+ }
465
+ const lastPackageJSONUrl = packageJSONUrl;
466
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
467
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
468
+ break;
469
+ }
470
+ }
471
+ const packageJSONPath = fileURLToPath(packageJSONUrl);
472
+ return {
473
+ pjsonPath: packageJSONPath,
474
+ exists: false,
475
+ type: "none"
476
+ };
477
+ }
478
+ __name(getPackageScopeConfig, "getPackageScopeConfig");
479
+ var hasOwnProperty = {}.hasOwnProperty;
480
+ var extensionFormatMap = {
481
+ __proto__: null,
482
+ ".json": "json",
483
+ ".cjs": "commonjs",
484
+ ".cts": "commonjs",
485
+ ".js": "module",
486
+ ".ts": "module",
487
+ ".mts": "module",
488
+ ".mjs": "module"
489
+ };
490
+ var protocolHandlers = {
491
+ __proto__: null,
492
+ "data:": getDataProtocolModuleFormat,
493
+ "file:": getFileProtocolModuleFormat,
494
+ "node:": /* @__PURE__ */ __name(() => "builtin", "node:")
495
+ };
496
+ function mimeToFormat(mime) {
497
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
498
+ return "module";
499
+ if (mime === "application/json") return "json";
500
+ return null;
501
+ }
502
+ __name(mimeToFormat, "mimeToFormat");
503
+ function getDataProtocolModuleFormat(parsed) {
504
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
505
+ parsed.pathname
506
+ ) || [null, null, null];
507
+ return mimeToFormat(mime);
508
+ }
509
+ __name(getDataProtocolModuleFormat, "getDataProtocolModuleFormat");
510
+ function extname(url) {
511
+ const pathname = url.pathname;
512
+ let index = pathname.length;
513
+ while (index--) {
514
+ const code = pathname.codePointAt(index);
515
+ if (code === 47) {
516
+ return "";
517
+ }
518
+ if (code === 46) {
519
+ return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
520
+ }
521
+ }
522
+ return "";
523
+ }
524
+ __name(extname, "extname");
525
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
526
+ const ext = extname(url);
527
+ if (ext === ".js") {
528
+ const { type: packageType } = getPackageScopeConfig(url);
529
+ if (packageType !== "none") {
530
+ return packageType;
531
+ }
532
+ return "commonjs";
533
+ }
534
+ if (ext === "") {
535
+ const { type: packageType } = getPackageScopeConfig(url);
536
+ if (packageType === "none" || packageType === "commonjs") {
537
+ return "commonjs";
538
+ }
539
+ return "module";
540
+ }
541
+ const format2 = extensionFormatMap[ext];
542
+ if (format2) return format2;
543
+ if (ignoreErrors) {
544
+ return void 0;
545
+ }
546
+ const filepath = fileURLToPath(url);
547
+ throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
548
+ }
549
+ __name(getFileProtocolModuleFormat, "getFileProtocolModuleFormat");
550
+ function defaultGetFormatWithoutErrors(url, context) {
551
+ const protocol = url.protocol;
552
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) {
553
+ return null;
554
+ }
555
+ return protocolHandlers[protocol](url, context, true) || null;
556
+ }
557
+ __name(defaultGetFormatWithoutErrors, "defaultGetFormatWithoutErrors");
558
+ var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
559
+ var own = {}.hasOwnProperty;
560
+ 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;
561
+ 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;
562
+ var invalidPackageNameRegEx = /^\.|%|\\/;
563
+ var patternRegEx = /\*/g;
564
+ var encodedSeparatorRegEx = /%2f|%5c/i;
565
+ var emittedPackageWarnings = /* @__PURE__ */ new Set();
566
+ var doubleSlashRegEx = /[/\\]{2}/;
567
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
568
+ if (process$1.noDeprecation) {
569
+ return;
570
+ }
571
+ const pjsonPath = fileURLToPath(packageJsonUrl);
572
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
573
+ process$1.emitWarning(
574
+ `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)}` : ""}.`,
575
+ "DeprecationWarning",
576
+ "DEP0166"
577
+ );
578
+ }
579
+ __name(emitInvalidSegmentDeprecation, "emitInvalidSegmentDeprecation");
580
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
581
+ if (process$1.noDeprecation) {
582
+ return;
583
+ }
584
+ const format2 = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
585
+ if (format2 !== "module") return;
586
+ const urlPath = fileURLToPath(url.href);
587
+ const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
588
+ const basePath = fileURLToPath(base);
589
+ if (!main) {
590
+ process$1.emitWarning(
591
+ `No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
592
+ packagePath.length
593
+ )}", imported from ${basePath}.
594
+ Default "index" lookups for the main are deprecated for ES modules.`,
595
+ "DeprecationWarning",
596
+ "DEP0151"
597
+ );
598
+ } else if (path.resolve(packagePath, main) !== urlPath) {
599
+ process$1.emitWarning(
600
+ `Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
601
+ packagePath.length
602
+ )}", imported from ${basePath}.
603
+ Automatic extension resolution of the "main" field is deprecated for ES modules.`,
604
+ "DeprecationWarning",
605
+ "DEP0151"
606
+ );
607
+ }
608
+ }
609
+ __name(emitLegacyIndexDeprecation, "emitLegacyIndexDeprecation");
610
+ function tryStatSync(path2) {
611
+ try {
612
+ return statSync(path2);
613
+ } catch {
614
+ }
615
+ }
616
+ __name(tryStatSync, "tryStatSync");
617
+ function fileExists(url) {
618
+ const stats = statSync(url, { throwIfNoEntry: false });
619
+ const isFile = stats ? stats.isFile() : void 0;
620
+ return isFile === null || isFile === void 0 ? false : isFile;
621
+ }
622
+ __name(fileExists, "fileExists");
623
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
624
+ let guess;
625
+ if (packageConfig.main !== void 0) {
626
+ guess = new URL$1(packageConfig.main, packageJsonUrl);
627
+ if (fileExists(guess)) return guess;
628
+ const tries2 = [
629
+ `./${packageConfig.main}.js`,
630
+ `./${packageConfig.main}.json`,
631
+ `./${packageConfig.main}.node`,
632
+ `./${packageConfig.main}/index.js`,
633
+ `./${packageConfig.main}/index.json`,
634
+ `./${packageConfig.main}/index.node`
635
+ ];
636
+ let i2 = -1;
637
+ while (++i2 < tries2.length) {
638
+ guess = new URL$1(tries2[i2], packageJsonUrl);
639
+ if (fileExists(guess)) break;
640
+ guess = void 0;
641
+ }
642
+ if (guess) {
643
+ emitLegacyIndexDeprecation(
644
+ guess,
645
+ packageJsonUrl,
646
+ base,
647
+ packageConfig.main
648
+ );
649
+ return guess;
650
+ }
651
+ }
652
+ const tries = ["./index.js", "./index.json", "./index.node"];
653
+ let i = -1;
654
+ while (++i < tries.length) {
655
+ guess = new URL$1(tries[i], packageJsonUrl);
656
+ if (fileExists(guess)) break;
657
+ guess = void 0;
658
+ }
659
+ if (guess) {
660
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
661
+ return guess;
662
+ }
663
+ throw new ERR_MODULE_NOT_FOUND(
664
+ fileURLToPath(new URL$1(".", packageJsonUrl)),
665
+ fileURLToPath(base)
666
+ );
667
+ }
668
+ __name(legacyMainResolve, "legacyMainResolve");
669
+ function finalizeResolution(resolved, base, preserveSymlinks) {
670
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
671
+ throw new ERR_INVALID_MODULE_SPECIFIER(
672
+ resolved.pathname,
673
+ String.raw`must not include encoded "/" or "\" characters`,
674
+ fileURLToPath(base)
675
+ );
676
+ }
677
+ let filePath;
678
+ try {
679
+ filePath = fileURLToPath(resolved);
680
+ } catch (error) {
681
+ Object.defineProperty(error, "input", { value: String(resolved) });
682
+ Object.defineProperty(error, "module", { value: String(base) });
683
+ throw error;
684
+ }
685
+ const stats = tryStatSync(
686
+ filePath.endsWith("/") ? filePath.slice(-1) : filePath
687
+ );
688
+ if (stats && stats.isDirectory()) {
689
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
690
+ error.url = String(resolved);
691
+ throw error;
692
+ }
693
+ if (!stats || !stats.isFile()) {
694
+ const error = new ERR_MODULE_NOT_FOUND(
695
+ filePath || resolved.pathname,
696
+ base && fileURLToPath(base),
697
+ true
698
+ );
699
+ error.url = String(resolved);
700
+ throw error;
701
+ }
702
+ {
703
+ const real = realpathSync(filePath);
704
+ const { search, hash } = resolved;
705
+ resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
706
+ resolved.search = search;
707
+ resolved.hash = hash;
708
+ }
709
+ return resolved;
710
+ }
711
+ __name(finalizeResolution, "finalizeResolution");
712
+ function importNotDefined(specifier, packageJsonUrl, base) {
713
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
714
+ specifier,
715
+ packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)),
716
+ fileURLToPath(base)
717
+ );
718
+ }
719
+ __name(importNotDefined, "importNotDefined");
720
+ function exportsNotFound(subpath, packageJsonUrl, base) {
721
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(
722
+ fileURLToPath(new URL$1(".", packageJsonUrl)),
723
+ subpath,
724
+ base && fileURLToPath(base)
725
+ );
726
+ }
727
+ __name(exportsNotFound, "exportsNotFound");
728
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
729
+ const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`;
730
+ throw new ERR_INVALID_MODULE_SPECIFIER(
731
+ request,
732
+ reason,
733
+ base && fileURLToPath(base)
734
+ );
735
+ }
736
+ __name(throwInvalidSubpath, "throwInvalidSubpath");
737
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
738
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
739
+ return new ERR_INVALID_PACKAGE_TARGET(
740
+ fileURLToPath(new URL$1(".", packageJsonUrl)),
741
+ subpath,
742
+ target,
743
+ internal,
744
+ base && fileURLToPath(base)
745
+ );
746
+ }
747
+ __name(invalidPackageTarget, "invalidPackageTarget");
748
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
749
+ if (subpath !== "" && !pattern && target.at(-1) !== "/")
750
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
751
+ if (!target.startsWith("./")) {
752
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
753
+ let isURL = false;
754
+ try {
755
+ new URL$1(target);
756
+ isURL = true;
757
+ } catch {
758
+ }
759
+ if (!isURL) {
760
+ const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
761
+ patternRegEx,
762
+ target,
763
+ () => subpath
764
+ ) : target + subpath;
765
+ return packageResolve(exportTarget, packageJsonUrl, conditions);
766
+ }
767
+ }
768
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
769
+ }
770
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
771
+ if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
772
+ if (!isPathMap) {
773
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
774
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
775
+ patternRegEx,
776
+ target,
777
+ () => subpath
778
+ ) : target;
779
+ emitInvalidSegmentDeprecation(
780
+ resolvedTarget,
781
+ request,
782
+ match,
783
+ packageJsonUrl,
784
+ internal,
785
+ base,
786
+ true
787
+ );
788
+ }
789
+ } else {
790
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
791
+ }
792
+ }
793
+ const resolved = new URL$1(target, packageJsonUrl);
794
+ const resolvedPath = resolved.pathname;
795
+ const packagePath = new URL$1(".", packageJsonUrl).pathname;
796
+ if (!resolvedPath.startsWith(packagePath))
797
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
798
+ if (subpath === "") return resolved;
799
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
800
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
801
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
802
+ if (!isPathMap) {
803
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
804
+ patternRegEx,
805
+ target,
806
+ () => subpath
807
+ ) : target;
808
+ emitInvalidSegmentDeprecation(
809
+ resolvedTarget,
810
+ request,
811
+ match,
812
+ packageJsonUrl,
813
+ internal,
814
+ base,
815
+ false
816
+ );
817
+ }
818
+ } else {
819
+ throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
820
+ }
821
+ }
822
+ if (pattern) {
823
+ return new URL$1(
824
+ RegExpPrototypeSymbolReplace.call(
825
+ patternRegEx,
826
+ resolved.href,
827
+ () => subpath
828
+ )
829
+ );
830
+ }
831
+ return new URL$1(subpath, resolved);
832
+ }
833
+ __name(resolvePackageTargetString, "resolvePackageTargetString");
834
+ function isArrayIndex(key) {
835
+ const keyNumber = Number(key);
836
+ if (`${keyNumber}` !== key) return false;
837
+ return keyNumber >= 0 && keyNumber < 4294967295;
838
+ }
839
+ __name(isArrayIndex, "isArrayIndex");
840
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
841
+ if (typeof target === "string") {
842
+ return resolvePackageTargetString(
843
+ target,
844
+ subpath,
845
+ packageSubpath,
846
+ packageJsonUrl,
847
+ base,
848
+ pattern,
849
+ internal,
850
+ isPathMap,
851
+ conditions
852
+ );
853
+ }
854
+ if (Array.isArray(target)) {
855
+ const targetList = target;
856
+ if (targetList.length === 0) return null;
857
+ let lastException;
858
+ let i = -1;
859
+ while (++i < targetList.length) {
860
+ const targetItem = targetList[i];
861
+ let resolveResult;
862
+ try {
863
+ resolveResult = resolvePackageTarget(
864
+ packageJsonUrl,
865
+ targetItem,
866
+ subpath,
867
+ packageSubpath,
868
+ base,
869
+ pattern,
870
+ internal,
871
+ isPathMap,
872
+ conditions
873
+ );
874
+ } catch (error) {
875
+ const exception = error;
876
+ lastException = exception;
877
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
878
+ throw error;
879
+ }
880
+ if (resolveResult === void 0) continue;
881
+ if (resolveResult === null) {
882
+ lastException = null;
883
+ continue;
884
+ }
885
+ return resolveResult;
886
+ }
887
+ if (lastException === void 0 || lastException === null) {
888
+ return null;
889
+ }
890
+ throw lastException;
891
+ }
892
+ if (typeof target === "object" && target !== null) {
893
+ const keys = Object.getOwnPropertyNames(target);
894
+ let i = -1;
895
+ while (++i < keys.length) {
896
+ const key = keys[i];
897
+ if (isArrayIndex(key)) {
898
+ throw new ERR_INVALID_PACKAGE_CONFIG(
899
+ fileURLToPath(packageJsonUrl),
900
+ fileURLToPath(base),
901
+ '"exports" cannot contain numeric property keys.'
902
+ );
903
+ }
904
+ }
905
+ i = -1;
906
+ while (++i < keys.length) {
907
+ const key = keys[i];
908
+ if (key === "default" || conditions && conditions.has(key)) {
909
+ const conditionalTarget = target[key];
910
+ const resolveResult = resolvePackageTarget(
911
+ packageJsonUrl,
912
+ conditionalTarget,
913
+ subpath,
914
+ packageSubpath,
915
+ base,
916
+ pattern,
917
+ internal,
918
+ isPathMap,
919
+ conditions
920
+ );
921
+ if (resolveResult === void 0) continue;
922
+ return resolveResult;
923
+ }
924
+ }
925
+ return null;
926
+ }
927
+ if (target === null) {
928
+ return null;
929
+ }
930
+ throw invalidPackageTarget(
931
+ packageSubpath,
932
+ target,
933
+ packageJsonUrl,
934
+ internal,
935
+ base
936
+ );
937
+ }
938
+ __name(resolvePackageTarget, "resolvePackageTarget");
939
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
940
+ if (typeof exports === "string" || Array.isArray(exports)) return true;
941
+ if (typeof exports !== "object" || exports === null) return false;
942
+ const keys = Object.getOwnPropertyNames(exports);
943
+ let isConditionalSugar = false;
944
+ let i = 0;
945
+ let keyIndex = -1;
946
+ while (++keyIndex < keys.length) {
947
+ const key = keys[keyIndex];
948
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
949
+ if (i++ === 0) {
950
+ isConditionalSugar = currentIsConditionalSugar;
951
+ } else if (isConditionalSugar !== currentIsConditionalSugar) {
952
+ throw new ERR_INVALID_PACKAGE_CONFIG(
953
+ fileURLToPath(packageJsonUrl),
954
+ fileURLToPath(base),
955
+ `"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.`
956
+ );
957
+ }
958
+ }
959
+ return isConditionalSugar;
960
+ }
961
+ __name(isConditionalExportsMainSugar, "isConditionalExportsMainSugar");
962
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
963
+ if (process$1.noDeprecation) {
964
+ return;
965
+ }
966
+ const pjsonPath = fileURLToPath(pjsonUrl);
967
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
968
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
969
+ process$1.emitWarning(
970
+ `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.`,
971
+ "DeprecationWarning",
972
+ "DEP0155"
973
+ );
974
+ }
975
+ __name(emitTrailingSlashPatternDeprecation, "emitTrailingSlashPatternDeprecation");
976
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
977
+ let exports = packageConfig.exports;
978
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
979
+ exports = { ".": exports };
980
+ }
981
+ if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
982
+ const target = exports[packageSubpath];
983
+ const resolveResult = resolvePackageTarget(
984
+ packageJsonUrl,
985
+ target,
986
+ "",
987
+ packageSubpath,
988
+ base,
989
+ false,
990
+ false,
991
+ false,
992
+ conditions
993
+ );
994
+ if (resolveResult === null || resolveResult === void 0) {
995
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
996
+ }
997
+ return resolveResult;
998
+ }
999
+ let bestMatch = "";
1000
+ let bestMatchSubpath = "";
1001
+ const keys = Object.getOwnPropertyNames(exports);
1002
+ let i = -1;
1003
+ while (++i < keys.length) {
1004
+ const key = keys[i];
1005
+ const patternIndex = key.indexOf("*");
1006
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
1007
+ if (packageSubpath.endsWith("/")) {
1008
+ emitTrailingSlashPatternDeprecation(
1009
+ packageSubpath,
1010
+ packageJsonUrl,
1011
+ base
1012
+ );
1013
+ }
1014
+ const patternTrailer = key.slice(patternIndex + 1);
1015
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1016
+ bestMatch = key;
1017
+ bestMatchSubpath = packageSubpath.slice(
1018
+ patternIndex,
1019
+ packageSubpath.length - patternTrailer.length
1020
+ );
1021
+ }
1022
+ }
1023
+ }
1024
+ if (bestMatch) {
1025
+ const target = exports[bestMatch];
1026
+ const resolveResult = resolvePackageTarget(
1027
+ packageJsonUrl,
1028
+ target,
1029
+ bestMatchSubpath,
1030
+ bestMatch,
1031
+ base,
1032
+ true,
1033
+ false,
1034
+ packageSubpath.endsWith("/"),
1035
+ conditions
1036
+ );
1037
+ if (resolveResult === null || resolveResult === void 0) {
1038
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
1039
+ }
1040
+ return resolveResult;
1041
+ }
1042
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
1043
+ }
1044
+ __name(packageExportsResolve, "packageExportsResolve");
1045
+ function patternKeyCompare(a, b) {
1046
+ const aPatternIndex = a.indexOf("*");
1047
+ const bPatternIndex = b.indexOf("*");
1048
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
1049
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
1050
+ if (baseLengthA > baseLengthB) return -1;
1051
+ if (baseLengthB > baseLengthA) return 1;
1052
+ if (aPatternIndex === -1) return 1;
1053
+ if (bPatternIndex === -1) return -1;
1054
+ if (a.length > b.length) return -1;
1055
+ if (b.length > a.length) return 1;
1056
+ return 0;
1057
+ }
1058
+ __name(patternKeyCompare, "patternKeyCompare");
1059
+ function packageImportsResolve(name, base, conditions) {
1060
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
1061
+ const reason = "is not a valid internal imports specifier name";
1062
+ throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base));
1063
+ }
1064
+ let packageJsonUrl;
1065
+ const packageConfig = getPackageScopeConfig(base);
1066
+ if (packageConfig.exists) {
1067
+ packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
1068
+ const imports = packageConfig.imports;
1069
+ if (imports) {
1070
+ if (own.call(imports, name) && !name.includes("*")) {
1071
+ const resolveResult = resolvePackageTarget(
1072
+ packageJsonUrl,
1073
+ imports[name],
1074
+ "",
1075
+ name,
1076
+ base,
1077
+ false,
1078
+ true,
1079
+ false,
1080
+ conditions
1081
+ );
1082
+ if (resolveResult !== null && resolveResult !== void 0) {
1083
+ return resolveResult;
1084
+ }
1085
+ } else {
1086
+ let bestMatch = "";
1087
+ let bestMatchSubpath = "";
1088
+ const keys = Object.getOwnPropertyNames(imports);
1089
+ let i = -1;
1090
+ while (++i < keys.length) {
1091
+ const key = keys[i];
1092
+ const patternIndex = key.indexOf("*");
1093
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
1094
+ const patternTrailer = key.slice(patternIndex + 1);
1095
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1096
+ bestMatch = key;
1097
+ bestMatchSubpath = name.slice(
1098
+ patternIndex,
1099
+ name.length - patternTrailer.length
1100
+ );
1101
+ }
1102
+ }
1103
+ }
1104
+ if (bestMatch) {
1105
+ const target = imports[bestMatch];
1106
+ const resolveResult = resolvePackageTarget(
1107
+ packageJsonUrl,
1108
+ target,
1109
+ bestMatchSubpath,
1110
+ bestMatch,
1111
+ base,
1112
+ true,
1113
+ true,
1114
+ false,
1115
+ conditions
1116
+ );
1117
+ if (resolveResult !== null && resolveResult !== void 0) {
1118
+ return resolveResult;
1119
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+ }
1124
+ throw importNotDefined(name, packageJsonUrl, base);
1125
+ }
1126
+ __name(packageImportsResolve, "packageImportsResolve");
1127
+ function parsePackageName(specifier, base) {
1128
+ let separatorIndex = specifier.indexOf("/");
1129
+ let validPackageName = true;
1130
+ let isScoped = false;
1131
+ if (specifier[0] === "@") {
1132
+ isScoped = true;
1133
+ if (separatorIndex === -1 || specifier.length === 0) {
1134
+ validPackageName = false;
1135
+ } else {
1136
+ separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1137
+ }
1138
+ }
1139
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
1140
+ if (invalidPackageNameRegEx.exec(packageName) !== null) {
1141
+ validPackageName = false;
1142
+ }
1143
+ if (!validPackageName) {
1144
+ throw new ERR_INVALID_MODULE_SPECIFIER(
1145
+ specifier,
1146
+ "is not a valid package name",
1147
+ fileURLToPath(base)
1148
+ );
1149
+ }
1150
+ const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
1151
+ return { packageName, packageSubpath, isScoped };
1152
+ }
1153
+ __name(parsePackageName, "parsePackageName");
1154
+ function packageResolve(specifier, base, conditions) {
1155
+ if (nodeBuiltins.includes(specifier)) {
1156
+ return new URL$1("node:" + specifier);
1157
+ }
1158
+ const { packageName, packageSubpath, isScoped } = parsePackageName(
1159
+ specifier,
1160
+ base
1161
+ );
1162
+ const packageConfig = getPackageScopeConfig(base);
1163
+ if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
1164
+ const packageJsonUrl2 = pathToFileURL(packageConfig.pjsonPath);
1165
+ return packageExportsResolve(
1166
+ packageJsonUrl2,
1167
+ packageSubpath,
1168
+ packageConfig,
1169
+ base,
1170
+ conditions
1171
+ );
1172
+ }
1173
+ let packageJsonUrl = new URL$1(
1174
+ "./node_modules/" + packageName + "/package.json",
1175
+ base
1176
+ );
1177
+ let packageJsonPath = fileURLToPath(packageJsonUrl);
1178
+ let lastPath;
1179
+ do {
1180
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
1181
+ if (!stat || !stat.isDirectory()) {
1182
+ lastPath = packageJsonPath;
1183
+ packageJsonUrl = new URL$1(
1184
+ (isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
1185
+ packageJsonUrl
1186
+ );
1187
+ packageJsonPath = fileURLToPath(packageJsonUrl);
1188
+ continue;
1189
+ }
1190
+ const packageConfig2 = read(packageJsonPath, { base, specifier });
1191
+ if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
1192
+ return packageExportsResolve(
1193
+ packageJsonUrl,
1194
+ packageSubpath,
1195
+ packageConfig2,
1196
+ base,
1197
+ conditions
1198
+ );
1199
+ }
1200
+ if (packageSubpath === ".") {
1201
+ return legacyMainResolve(packageJsonUrl, packageConfig2, base);
1202
+ }
1203
+ return new URL$1(packageSubpath, packageJsonUrl);
1204
+ } while (packageJsonPath.length !== lastPath.length);
1205
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
1206
+ }
1207
+ __name(packageResolve, "packageResolve");
1208
+ function isRelativeSpecifier(specifier) {
1209
+ if (specifier[0] === ".") {
1210
+ if (specifier.length === 1 || specifier[1] === "/") return true;
1211
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
1212
+ return true;
1213
+ }
1214
+ }
1215
+ return false;
1216
+ }
1217
+ __name(isRelativeSpecifier, "isRelativeSpecifier");
1218
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1219
+ if (specifier === "") return false;
1220
+ if (specifier[0] === "/") return true;
1221
+ return isRelativeSpecifier(specifier);
1222
+ }
1223
+ __name(shouldBeTreatedAsRelativeOrAbsolutePath, "shouldBeTreatedAsRelativeOrAbsolutePath");
1224
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1225
+ const protocol = base.protocol;
1226
+ const isData = protocol === "data:";
1227
+ let resolved;
1228
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
1229
+ try {
1230
+ resolved = new URL$1(specifier, base);
1231
+ } catch (error_) {
1232
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1233
+ error.cause = error_;
1234
+ throw error;
1235
+ }
1236
+ } else if (protocol === "file:" && specifier[0] === "#") {
1237
+ resolved = packageImportsResolve(specifier, base, conditions);
1238
+ } else {
1239
+ try {
1240
+ resolved = new URL$1(specifier);
1241
+ } catch (error_) {
1242
+ if (isData && !nodeBuiltins.includes(specifier)) {
1243
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1244
+ error.cause = error_;
1245
+ throw error;
1246
+ }
1247
+ resolved = packageResolve(specifier, base, conditions);
1248
+ }
1249
+ }
1250
+ assert(resolved !== void 0, "expected to be defined");
1251
+ if (resolved.protocol !== "file:") {
1252
+ return resolved;
1253
+ }
1254
+ return finalizeResolution(resolved, base);
1255
+ }
1256
+ __name(moduleResolve, "moduleResolve");
1257
+ var DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
1258
+ var isWindows = (() => process.platform === "win32")();
1259
+ var NOT_FOUND_ERRORS = /* @__PURE__ */ new Set([
1260
+ "ERR_MODULE_NOT_FOUND",
1261
+ "ERR_UNSUPPORTED_DIR_IMPORT",
1262
+ "MODULE_NOT_FOUND",
1263
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
1264
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED"
1265
+ ]);
1266
+ var globalCache = (() => (
1267
+ // eslint-disable-next-line unicorn/no-unreadable-iife
1268
+ globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map()
1269
+ ))();
1270
+ function resolveModuleURL(input, options) {
1271
+ const parsedInput = _parseInput(input);
1272
+ if ("external" in parsedInput) {
1273
+ return parsedInput.external;
1274
+ }
1275
+ const specifier = parsedInput.specifier;
1276
+ let url = parsedInput.url;
1277
+ let absolutePath = parsedInput.absolutePath;
1278
+ let cacheKey;
1279
+ let cacheObj;
1280
+ if (options?.cache !== false) {
1281
+ cacheKey = _cacheKey(absolutePath || specifier, options);
1282
+ cacheObj = options?.cache && typeof options?.cache === "object" ? options.cache : globalCache;
1283
+ }
1284
+ if (cacheObj) {
1285
+ const cached = cacheObj.get(cacheKey);
1286
+ if (typeof cached === "string") {
1287
+ return cached;
1288
+ }
1289
+ if (cached instanceof Error) {
1290
+ if (options?.try) {
1291
+ return void 0;
1292
+ }
1293
+ throw cached;
1294
+ }
1295
+ }
1296
+ if (absolutePath) {
1297
+ try {
1298
+ const stat = lstatSync(absolutePath);
1299
+ if (stat.isSymbolicLink()) {
1300
+ absolutePath = realpathSync(absolutePath);
1301
+ url = pathToFileURL(absolutePath);
1302
+ }
1303
+ if (stat.isFile()) {
1304
+ if (cacheObj) {
1305
+ cacheObj.set(cacheKey, url.href);
1306
+ }
1307
+ return url.href;
1308
+ }
1309
+ } catch (error) {
1310
+ if (error?.code !== "ENOENT") {
1311
+ if (cacheObj) {
1312
+ cacheObj.set(cacheKey, error);
1313
+ }
1314
+ throw error;
1315
+ }
1316
+ }
1317
+ }
1318
+ const conditionsSet = options?.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
1319
+ const target = specifier || url.href;
1320
+ const bases = _normalizeBases(options?.from);
1321
+ const suffixes = options?.suffixes || [""];
1322
+ const extensions = options?.extensions ? ["", ...options.extensions] : [""];
1323
+ let resolved;
1324
+ for (const base of bases) {
1325
+ for (const suffix of suffixes) {
1326
+ let name = _join(target, suffix);
1327
+ if (name === ".") {
1328
+ name += "/.";
1329
+ }
1330
+ for (const extension of extensions) {
1331
+ resolved = _tryModuleResolve(name + extension, base, conditionsSet);
1332
+ if (resolved) {
1333
+ break;
1334
+ }
1335
+ }
1336
+ if (resolved) {
1337
+ break;
1338
+ }
1339
+ }
1340
+ if (resolved) {
1341
+ break;
1342
+ }
1343
+ }
1344
+ if (!resolved) {
1345
+ const error = new Error(
1346
+ `Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`
1347
+ );
1348
+ error.code = "ERR_MODULE_NOT_FOUND";
1349
+ if (cacheObj) {
1350
+ cacheObj.set(cacheKey, error);
1351
+ }
1352
+ if (options?.try) {
1353
+ return void 0;
1354
+ }
1355
+ throw error;
1356
+ }
1357
+ if (cacheObj) {
1358
+ cacheObj.set(cacheKey, resolved.href);
1359
+ }
1360
+ return resolved.href;
1361
+ }
1362
+ __name(resolveModuleURL, "resolveModuleURL");
1363
+ function resolveModulePath(id, options) {
1364
+ const resolved = resolveModuleURL(id, options);
1365
+ if (!resolved) {
1366
+ return void 0;
1367
+ }
1368
+ if (!resolved.startsWith("file://") && options?.try) {
1369
+ return void 0;
1370
+ }
1371
+ const absolutePath = fileURLToPath(resolved);
1372
+ return isWindows ? _normalizeWinPath(absolutePath) : absolutePath;
1373
+ }
1374
+ __name(resolveModulePath, "resolveModulePath");
1375
+ function _tryModuleResolve(specifier, base, conditions) {
1376
+ try {
1377
+ return moduleResolve(specifier, base, conditions);
1378
+ } catch (error) {
1379
+ if (!NOT_FOUND_ERRORS.has(error?.code)) {
1380
+ throw error;
1381
+ }
1382
+ }
1383
+ }
1384
+ __name(_tryModuleResolve, "_tryModuleResolve");
1385
+ function _normalizeBases(inputs) {
1386
+ const urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap(
1387
+ (input) => _normalizeBase(input)
1388
+ );
1389
+ if (urls.length === 0) {
1390
+ return [pathToFileURL("./")];
1391
+ }
1392
+ return urls;
1393
+ }
1394
+ __name(_normalizeBases, "_normalizeBases");
1395
+ function _normalizeBase(input) {
1396
+ if (!input) {
1397
+ return [];
1398
+ }
1399
+ if (_isURL(input)) {
1400
+ return [input];
1401
+ }
1402
+ if (typeof input !== "string") {
1403
+ return [];
1404
+ }
1405
+ if (/^(?:node|data|http|https|file):/.test(input)) {
1406
+ return new URL(input);
1407
+ }
1408
+ try {
1409
+ if (input.endsWith("/") || statSync(input).isDirectory()) {
1410
+ return pathToFileURL(input + "/");
1411
+ }
1412
+ return pathToFileURL(input);
1413
+ } catch {
1414
+ return [pathToFileURL(input + "/"), pathToFileURL(input)];
1415
+ }
1416
+ }
1417
+ __name(_normalizeBase, "_normalizeBase");
1418
+ function _fmtPath(input) {
1419
+ try {
1420
+ return fileURLToPath(input);
1421
+ } catch {
1422
+ return input;
1423
+ }
1424
+ }
1425
+ __name(_fmtPath, "_fmtPath");
1426
+ function _cacheKey(id, opts) {
1427
+ return JSON.stringify([
1428
+ id,
1429
+ (opts?.conditions || ["node", "import"]).sort(),
1430
+ opts?.extensions,
1431
+ opts?.from,
1432
+ opts?.suffixes
1433
+ ]);
1434
+ }
1435
+ __name(_cacheKey, "_cacheKey");
1436
+ function _join(a, b) {
1437
+ if (!a || !b || b === "/") {
1438
+ return a;
1439
+ }
1440
+ return (a.endsWith("/") ? a : a + "/") + (b.startsWith("/") ? b.slice(1) : b);
1441
+ }
1442
+ __name(_join, "_join");
1443
+ function _normalizeWinPath(path2) {
1444
+ return path2.replace(/\\/g, "/").replace(/^[a-z]:\//, (r) => r.toUpperCase());
1445
+ }
1446
+ __name(_normalizeWinPath, "_normalizeWinPath");
1447
+ function _isURL(input) {
1448
+ return input instanceof URL || input?.constructor?.name === "URL";
1449
+ }
1450
+ __name(_isURL, "_isURL");
1451
+ function _parseInput(input) {
1452
+ if (typeof input === "string") {
1453
+ if (input.startsWith("file:")) {
1454
+ const url = new URL(input);
1455
+ return { url, absolutePath: fileURLToPath(url) };
1456
+ }
1457
+ if (isAbsolute(input)) {
1458
+ return { url: pathToFileURL(input), absolutePath: input };
1459
+ }
1460
+ if (/^(?:node|data|http|https):/.test(input)) {
1461
+ return { external: input };
1462
+ }
1463
+ if (nodeBuiltins.includes(input) && !input.includes(":")) {
1464
+ return { external: `node:${input}` };
1465
+ }
1466
+ return { specifier: input };
1467
+ }
1468
+ if (_isURL(input)) {
1469
+ if (input.protocol === "file:") {
1470
+ return { url: input, absolutePath: fileURLToPath(input) };
1471
+ }
1472
+ return { external: input.href };
1473
+ }
1474
+ throw new TypeError("id must be a `string` or `URL`");
1475
+ }
1476
+ __name(_parseInput, "_parseInput");
1477
+
1478
+ // src/shared/utils/module.ts
1479
+ import { statSync as statSync2 } from "node:fs";
1480
+ import { createRequire, register } from "node:module";
1481
+ import { win32 } from "node:path/win32";
1482
+ import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
1483
+ var importMetaResolve = /* @__PURE__ */ __name((...args) => {
1484
+ if (typeof import.meta.resolve !== "function" && process.env.VITEST === "true") {
1485
+ console.warn(
1486
+ "importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
1487
+ );
1488
+ return pathToFileURL2(args[0]).href;
1489
+ }
1490
+ return import.meta.resolve(...args);
1491
+ }, "importMetaResolve");
1492
+ var resolvePackageDir = /* @__PURE__ */ __name((pkg, parent) => {
1493
+ return dirname(fileURLToPath2(importMetaResolve(join(pkg, "package.json"), parent)));
1494
+ }, "resolvePackageDir");
1495
+ var isTypescriptLoaderRegistered = false;
1496
+ async function importModule(path2) {
1497
+ if (!isTypescriptLoaderRegistered) {
1498
+ const typescriptLoaderUrl = importMetaResolve("storybook/internal/bin/loader");
1499
+ register(typescriptLoaderUrl, import.meta.url);
1500
+ isTypescriptLoaderRegistered = true;
1501
+ }
1502
+ let mod;
1503
+ try {
1504
+ const resolvedPath = win32.isAbsolute(path2) ? pathToFileURL2(path2).href : path2;
1505
+ mod = await import(resolvedPath);
1506
+ } catch (importError) {
1507
+ try {
1508
+ const require2 = createRequire(import.meta.url);
1509
+ mod = require2(path2);
1510
+ } catch (requireError) {
1511
+ throw importError;
1512
+ }
1513
+ }
1514
+ return mod.default ?? mod;
1515
+ }
1516
+ __name(importModule, "importModule");
1517
+ var safeResolveModule = /* @__PURE__ */ __name(({
1518
+ specifier,
1519
+ parent,
1520
+ extensions = [".mjs", ".js", ".cjs"]
1521
+ }) => {
1522
+ try {
1523
+ const resolvedPath = resolveModulePath(specifier, {
1524
+ from: parent,
1525
+ extensions: [""].concat(extensions)
1526
+ });
1527
+ if (statSync2(resolvedPath).isFile()) {
1528
+ return resolvedPath;
1529
+ }
1530
+ } catch (e) {
1531
+ }
1532
+ }, "safeResolveModule");
1533
+
1534
+ export {
1535
+ resolveModulePath,
1536
+ importMetaResolve,
1537
+ resolvePackageDir,
1538
+ importModule,
1539
+ safeResolveModule
1540
+ };