storybook 10.1.0-alpha.8 → 10.1.0-beta.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.
Files changed (198) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
  5. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  6. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  7. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  8. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  9. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  15. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  16. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  17. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  18. package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
  19. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  20. package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
  26. package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
  27. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  28. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  29. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  30. package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
  31. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  32. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  33. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-57OYTFQ5.js → builder-manager-BDAQHXFI.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
  41. package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
  42. package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
  43. package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
  44. package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
  45. package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
  46. package/dist/_node-chunks/{chunk-2GK7NW46.js → chunk-BG4RDXG7.js} +8 -10
  47. package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
  48. package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
  49. package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
  50. package/dist/_node-chunks/{chunk-RG4Z25PY.js → chunk-D6ND3TVY.js} +116 -276
  51. package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
  52. package/dist/_node-chunks/{chunk-EBYCXVVR.js → chunk-EVK2SBW5.js} +292 -688
  53. package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
  54. package/dist/_node-chunks/{chunk-6F6CCOXH.js → chunk-KVRF22SH.js} +469 -983
  55. package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
  56. package/dist/_node-chunks/{chunk-C4KEDJ6O.js → chunk-MMVV6DGG.js} +8133 -8887
  57. package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
  58. package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
  59. package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
  60. package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
  61. package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
  62. package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
  63. package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
  64. package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
  65. package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
  66. package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
  67. package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
  68. package/dist/_node-chunks/{chunk-RSHLCHYY.js → chunk-YWV55YW3.js} +15 -24
  69. package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
  70. package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
  71. package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
  73. package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
  74. package/dist/actions/decorator.js +21 -42
  75. package/dist/actions/index.js +3 -3
  76. package/dist/babel/index.d.ts +671 -335
  77. package/dist/babel/index.js +10 -11
  78. package/dist/bin/core.js +601 -1548
  79. package/dist/bin/dispatcher.js +36 -36
  80. package/dist/bin/loader.js +24 -38
  81. package/dist/channels/index.js +98 -234
  82. package/dist/cli/index.d.ts +1479 -133
  83. package/dist/cli/index.js +30 -8540
  84. package/dist/client-logger/index.js +31 -61
  85. package/dist/common/index.d.ts +139 -62
  86. package/dist/common/index.js +66 -51
  87. package/dist/components/index.d.ts +575 -273
  88. package/dist/components/index.js +14863 -4313
  89. package/dist/core-events/index.js +2 -66
  90. package/dist/core-server/index.d.ts +3 -2
  91. package/dist/core-server/index.js +2910 -8519
  92. package/dist/core-server/presets/common-manager.css +2 -2
  93. package/dist/core-server/presets/common-manager.js +2521 -5233
  94. package/dist/core-server/presets/common-override-preset.js +31 -60
  95. package/dist/core-server/presets/common-preset.js +663 -962
  96. package/dist/csf/index.js +534 -1179
  97. package/dist/csf-tools/index.js +9 -9
  98. package/dist/docs-tools/index.js +6 -6
  99. package/dist/highlight/index.js +2 -2
  100. package/dist/instrumenter/index.js +199 -415
  101. package/dist/manager/globals-runtime.js +59044 -67141
  102. package/dist/manager/globals.js +2 -3
  103. package/dist/manager/manager-stores.d.ts +1 -0
  104. package/dist/manager/manager-stores.js +23 -0
  105. package/dist/manager/runtime.js +11511 -10953
  106. package/dist/manager-api/index.d.ts +1811 -2
  107. package/dist/manager-api/index.js +1348 -2401
  108. package/dist/manager-errors.d.ts +9 -0
  109. package/dist/manager-errors.js +3 -3
  110. package/dist/mocking-utils/index.d.ts +1126 -0
  111. package/dist/mocking-utils/index.js +1181 -0
  112. package/dist/node-logger/index.d.ts +192 -24
  113. package/dist/node-logger/index.js +23 -4471
  114. package/dist/preview/globals.js +2 -3
  115. package/dist/preview/runtime.js +10799 -22393
  116. package/dist/preview-api/index.d.ts +1 -1
  117. package/dist/preview-api/index.js +13 -13
  118. package/dist/preview-errors.d.ts +9 -0
  119. package/dist/preview-errors.js +4 -4
  120. package/dist/router/index.js +347 -899
  121. package/dist/server-errors.d.ts +34 -1
  122. package/dist/server-errors.js +17 -10
  123. package/dist/telemetry/index.d.ts +24 -3
  124. package/dist/telemetry/index.js +25 -24
  125. package/dist/test/index.js +6131 -11916
  126. package/dist/theming/create.d.ts +1 -0
  127. package/dist/theming/create.js +4 -4
  128. package/dist/theming/index.d.ts +3366 -2599
  129. package/dist/theming/index.js +501 -1091
  130. package/dist/types/index.d.ts +72 -8
  131. package/dist/types/index.js +27 -12
  132. package/dist/viewport/index.js +3 -3
  133. package/package.json +26 -17
  134. package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
  135. package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
  136. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  137. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  138. package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
  139. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  140. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  141. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  142. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  143. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  144. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  145. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  146. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  147. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  148. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  149. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  150. package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
  151. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  152. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  153. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  154. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  155. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  156. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  157. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  158. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  159. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  160. package/dist/_node-chunks/camelcase-2KEDZHZ2.js +0 -18
  161. package/dist/_node-chunks/chunk-34NNXTBR.js +0 -28
  162. package/dist/_node-chunks/chunk-3N2A3KZX.js +0 -420
  163. package/dist/_node-chunks/chunk-5P7P5KDN.js +0 -90
  164. package/dist/_node-chunks/chunk-5WBRBDXI.js +0 -79
  165. package/dist/_node-chunks/chunk-7PWTU7T2.js +0 -697
  166. package/dist/_node-chunks/chunk-CHRHQ7AZ.js +0 -4272
  167. package/dist/_node-chunks/chunk-D4EGQLJI.js +0 -64656
  168. package/dist/_node-chunks/chunk-EKCURTKU.js +0 -1544
  169. package/dist/_node-chunks/chunk-GBVPPW4H.js +0 -1657
  170. package/dist/_node-chunks/chunk-J6VOKT2F.js +0 -220
  171. package/dist/_node-chunks/chunk-JLBYSGXS.js +0 -69
  172. package/dist/_node-chunks/chunk-LLCELSUL.js +0 -1198
  173. package/dist/_node-chunks/chunk-NS4OCQ4F.js +0 -61
  174. package/dist/_node-chunks/chunk-NXVLFYDR.js +0 -1518
  175. package/dist/_node-chunks/chunk-NZPWAJOZ.js +0 -304
  176. package/dist/_node-chunks/chunk-OYFSIV3I.js +0 -6712
  177. package/dist/_node-chunks/chunk-OZ43LMDF.js +0 -5029
  178. package/dist/_node-chunks/chunk-Q5HJHFF2.js +0 -61
  179. package/dist/_node-chunks/chunk-QHER4CEN.js +0 -34
  180. package/dist/_node-chunks/chunk-RF2PJM54.js +0 -1531
  181. package/dist/_node-chunks/chunk-S3OHGEE3.js +0 -101
  182. package/dist/_node-chunks/chunk-S5XOMVSV.js +0 -2256
  183. package/dist/_node-chunks/chunk-SGXQZ47H.js +0 -1586
  184. package/dist/_node-chunks/chunk-TDU6OVUH.js +0 -111
  185. package/dist/_node-chunks/chunk-TYQQFNQX.js +0 -1250
  186. package/dist/_node-chunks/chunk-WNGLARN2.js +0 -4741
  187. package/dist/_node-chunks/chunk-YUOVDCXL.js +0 -18
  188. package/dist/_node-chunks/dist-O5FB7YUW.js +0 -175
  189. package/dist/_node-chunks/globby-3NMV7WHX.js +0 -5222
  190. package/dist/_node-chunks/lib-VZD7BRSA.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-3RP7RKKU.js +0 -22017
  192. package/dist/_node-chunks/p-limit-LIKBTXEJ.js +0 -168
  193. package/dist/_node-chunks/plugin-2NYZBK4A.js +0 -129
  194. package/dist/_node-chunks/plugin-6QGMO7J7.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-Z2JI6J2H.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-D4BE2SSI.js +0 -124
  197. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
  198. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
@@ -0,0 +1,765 @@
1
+ import CJS_COMPAT_NODE_URL_hjmvusgt1gv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_hjmvusgt1gv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_hjmvusgt1gv from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_hjmvusgt1gv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_hjmvusgt1gv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_hjmvusgt1gv.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-IXWEUXJ2.js";
16
+
17
+ // ../node_modules/exsolve/dist/index.mjs
18
+ import fs, { lstatSync, realpathSync, statSync } from "node:fs";
19
+ import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
20
+ import path, { isAbsolute } from "node:path";
21
+ import assert from "node:assert";
22
+ import process$1 from "node:process";
23
+ import v8 from "node:v8";
24
+ import { format, inspect } from "node:util";
25
+ var nodeBuiltins = [
26
+ "_http_agent",
27
+ "_http_client",
28
+ "_http_common",
29
+ "_http_incoming",
30
+ "_http_outgoing",
31
+ "_http_server",
32
+ "_stream_duplex",
33
+ "_stream_passthrough",
34
+ "_stream_readable",
35
+ "_stream_transform",
36
+ "_stream_wrap",
37
+ "_stream_writable",
38
+ "_tls_common",
39
+ "_tls_wrap",
40
+ "assert",
41
+ "assert/strict",
42
+ "async_hooks",
43
+ "buffer",
44
+ "child_process",
45
+ "cluster",
46
+ "console",
47
+ "constants",
48
+ "crypto",
49
+ "dgram",
50
+ "diagnostics_channel",
51
+ "dns",
52
+ "dns/promises",
53
+ "domain",
54
+ "events",
55
+ "fs",
56
+ "fs/promises",
57
+ "http",
58
+ "http2",
59
+ "https",
60
+ "inspector",
61
+ "inspector/promises",
62
+ "module",
63
+ "net",
64
+ "os",
65
+ "path",
66
+ "path/posix",
67
+ "path/win32",
68
+ "perf_hooks",
69
+ "process",
70
+ "punycode",
71
+ "querystring",
72
+ "readline",
73
+ "readline/promises",
74
+ "repl",
75
+ "stream",
76
+ "stream/consumers",
77
+ "stream/promises",
78
+ "stream/web",
79
+ "string_decoder",
80
+ "sys",
81
+ "timers",
82
+ "timers/promises",
83
+ "tls",
84
+ "trace_events",
85
+ "tty",
86
+ "url",
87
+ "util",
88
+ "util/types",
89
+ "v8",
90
+ "vm",
91
+ "wasi",
92
+ "worker_threads",
93
+ "zlib"
94
+ ], own$1 = {}.hasOwnProperty, classRegExp = /^([A-Z][a-z\d]*)+$/, kTypes = /* @__PURE__ */ new Set([
95
+ "string",
96
+ "function",
97
+ "number",
98
+ "object",
99
+ "Function",
100
+ "Object",
101
+ "boolean",
102
+ "bigint",
103
+ "symbol"
104
+ ]), messages = /* @__PURE__ */ new Map(), nodeInternalPrefix = "__node_internal_", userStackTraceLimit;
105
+ function formatList(array, type = "and") {
106
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
107
+ }
108
+ function createError(sym, value, constructor) {
109
+ return messages.set(sym, value), makeNodeErrorWithCode(constructor, sym);
110
+ }
111
+ function makeNodeErrorWithCode(Base, key) {
112
+ return function(...parameters) {
113
+ let limit = Error.stackTraceLimit;
114
+ isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = 0);
115
+ let error = new Base();
116
+ isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = limit);
117
+ let message = getMessage(key, parameters, error);
118
+ return Object.defineProperties(error, {
119
+ message: {
120
+ value: message,
121
+ enumerable: !1,
122
+ writable: !0,
123
+ configurable: !0
124
+ },
125
+ toString: {
126
+ value() {
127
+ return `${this.name} [${key}]: ${this.message}`;
128
+ },
129
+ enumerable: !1,
130
+ writable: !0,
131
+ configurable: !0
132
+ }
133
+ }), captureLargerStackTrace(error), error.code = key, error;
134
+ };
135
+ }
136
+ function isErrorStackTraceLimitWritable() {
137
+ try {
138
+ if (v8.startupSnapshot.isBuildingSnapshot()) return !1;
139
+ } catch {
140
+ }
141
+ let desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
142
+ return desc === void 0 ? Object.isExtensible(Error) : own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
143
+ }
144
+ function hideStackFrames(wrappedFunction) {
145
+ let hidden = nodeInternalPrefix + wrappedFunction.name;
146
+ return Object.defineProperty(wrappedFunction, "name", { value: hidden }), wrappedFunction;
147
+ }
148
+ var captureLargerStackTrace = hideStackFrames(function(error) {
149
+ let stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
150
+ return stackTraceLimitIsWritable && (userStackTraceLimit = Error.stackTraceLimit, Error.stackTraceLimit = Number.POSITIVE_INFINITY), Error.captureStackTrace(error), stackTraceLimitIsWritable && (Error.stackTraceLimit = userStackTraceLimit), error;
151
+ });
152
+ function getMessage(key, parameters, self) {
153
+ let message = messages.get(key);
154
+ if (assert.ok(message !== void 0, "expected `message` to be found"), typeof message == "function")
155
+ return assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`), Reflect.apply(message, self, parameters);
156
+ let regex = /%[dfijoOs]/g, expectedLength = 0;
157
+ for (; regex.exec(message) !== null; ) expectedLength++;
158
+ return assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`), parameters.length === 0 ? message : (parameters.unshift(message), Reflect.apply(format, null, parameters));
159
+ }
160
+ function determineSpecificType(value) {
161
+ if (value == null) return String(value);
162
+ if (typeof value == "function" && value.name) return `function ${value.name}`;
163
+ if (typeof value == "object")
164
+ return value.constructor && value.constructor.name ? `an instance of ${value.constructor.name}` : `${inspect(value, { depth: -1 })}`;
165
+ let inspected = inspect(value, { colors: !1 });
166
+ return inspected.length > 28 && (inspected = `${inspected.slice(0, 25)}...`), `type ${typeof value} (${inspected})`;
167
+ }
168
+ var ERR_INVALID_ARG_TYPE = createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
169
+ assert.ok(typeof name == "string", "'name' must be a string"), Array.isArray(expected) || (expected = [expected]);
170
+ let message = "The ";
171
+ if (name.endsWith(" argument")) message += `${name} `;
172
+ else {
173
+ let type = name.includes(".") ? "property" : "argument";
174
+ message += `"${name}" ${type} `;
175
+ }
176
+ message += "must be ";
177
+ let types = [], instances = [], other = [];
178
+ for (let value of expected)
179
+ assert.ok(typeof value == "string", "All expected entries have to be of type string"), kTypes.has(value) ? types.push(value.toLowerCase()) : classRegExp.exec(value) === null ? (assert.ok(value !== "object", 'The value "object" should be written as "Object"'), other.push(value)) : instances.push(value);
180
+ if (instances.length > 0) {
181
+ let pos = types.indexOf("object");
182
+ pos !== -1 && (types.slice(pos, 1), instances.push("Object"));
183
+ }
184
+ return types.length > 0 && (message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`, (instances.length > 0 || other.length > 0) && (message += " or ")), instances.length > 0 && (message += `an instance of ${formatList(instances, "or")}`, other.length > 0 && (message += " or ")), other.length > 0 && (other.length > 1 ? message += `one of ${formatList(other, "or")}` : (other[0]?.toLowerCase() !== other[0] && (message += "an "), message += `${other[0]}`)), message += `. Received ${determineSpecificType(actual)}`, message;
185
+ }, TypeError), ERR_INVALID_MODULE_SPECIFIER = createError(
186
+ "ERR_INVALID_MODULE_SPECIFIER",
187
+ /**
188
+ * @param {string} request
189
+ * @param {string} reason
190
+ * @param {string} [base]
191
+ */
192
+ (request, reason, base) => `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`,
193
+ TypeError
194
+ ), ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path$1, base, message) => `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`, Error), ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = !1, base) => {
195
+ let relatedError = typeof target == "string" && !isImport && target.length > 0 && !target.startsWith("./");
196
+ return key === "." ? (assert.ok(isImport === !1), `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`) : `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 "./"' : ""}`;
197
+ }, Error), ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path$1, base, exactUrl = !1) => `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`, Error), ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error), ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`, TypeError), ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
198
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
199
+ /**
200
+ * @param {string} packagePath
201
+ * @param {string} subpath
202
+ * @param {string} [base]
203
+ */
204
+ (packagePath, subpath, base) => subpath === "." ? `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}` : `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`,
205
+ Error
206
+ ), ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error), 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), ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path$1) => `Unknown file extension "${extension}" for ${path$1}`, TypeError), ERR_INVALID_ARG_VALUE = createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
207
+ let inspected = inspect(value);
208
+ return inspected.length > 128 && (inspected = `${inspected.slice(0, 128)}...`), `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
209
+ }, TypeError), hasOwnProperty$1 = {}.hasOwnProperty, cache = /* @__PURE__ */ new Map();
210
+ function read(jsonPath, { base, specifier }) {
211
+ let existing = cache.get(jsonPath);
212
+ if (existing) return existing;
213
+ let string;
214
+ try {
215
+ string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
216
+ } catch (error) {
217
+ let exception = error;
218
+ if (exception.code !== "ENOENT") throw exception;
219
+ }
220
+ let result = {
221
+ exists: !1,
222
+ pjsonPath: jsonPath,
223
+ main: void 0,
224
+ name: void 0,
225
+ type: "none",
226
+ exports: void 0,
227
+ imports: void 0
228
+ };
229
+ if (string !== void 0) {
230
+ let parsed;
231
+ try {
232
+ parsed = JSON.parse(string);
233
+ } catch (error_) {
234
+ let error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), error_.message);
235
+ throw error.cause = error_, error;
236
+ }
237
+ result.exists = !0, hasOwnProperty$1.call(parsed, "name") && typeof parsed.name == "string" && (result.name = parsed.name), hasOwnProperty$1.call(parsed, "main") && typeof parsed.main == "string" && (result.main = parsed.main), hasOwnProperty$1.call(parsed, "exports") && (result.exports = parsed.exports), hasOwnProperty$1.call(parsed, "imports") && (result.imports = parsed.imports), hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module") && (result.type = parsed.type);
238
+ }
239
+ return cache.set(jsonPath, result), result;
240
+ }
241
+ function getPackageScopeConfig(resolved) {
242
+ let packageJSONUrl = new URL("package.json", resolved);
243
+ for (; !packageJSONUrl.pathname.endsWith("node_modules/package.json"); ) {
244
+ let packageConfig = read(fileURLToPath(packageJSONUrl), { specifier: resolved });
245
+ if (packageConfig.exists) return packageConfig;
246
+ let lastPackageJSONUrl = packageJSONUrl;
247
+ if (packageJSONUrl = new URL("../package.json", packageJSONUrl), packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
248
+ }
249
+ return {
250
+ pjsonPath: fileURLToPath(packageJSONUrl),
251
+ exists: !1,
252
+ type: "none"
253
+ };
254
+ }
255
+ var hasOwnProperty = {}.hasOwnProperty, extensionFormatMap = {
256
+ __proto__: null,
257
+ ".json": "json",
258
+ ".cjs": "commonjs",
259
+ ".cts": "commonjs",
260
+ ".js": "module",
261
+ ".ts": "module",
262
+ ".mts": "module",
263
+ ".mjs": "module"
264
+ }, protocolHandlers = {
265
+ __proto__: null,
266
+ "data:": getDataProtocolModuleFormat,
267
+ "file:": getFileProtocolModuleFormat,
268
+ "node:": () => "builtin"
269
+ };
270
+ function mimeToFormat(mime) {
271
+ return mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime) ? "module" : mime === "application/json" ? "json" : null;
272
+ }
273
+ function getDataProtocolModuleFormat(parsed) {
274
+ let { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
275
+ null,
276
+ null,
277
+ null
278
+ ];
279
+ return mimeToFormat(mime);
280
+ }
281
+ function extname(url) {
282
+ let pathname = url.pathname, index = pathname.length;
283
+ for (; index--; ) {
284
+ let code = pathname.codePointAt(index);
285
+ if (code === 47) return "";
286
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
287
+ }
288
+ return "";
289
+ }
290
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
291
+ let ext = extname(url);
292
+ if (ext === ".js") {
293
+ let { type: packageType } = getPackageScopeConfig(url);
294
+ return packageType !== "none" ? packageType : "commonjs";
295
+ }
296
+ if (ext === "") {
297
+ let { type: packageType } = getPackageScopeConfig(url);
298
+ return packageType === "none" || packageType === "commonjs" ? "commonjs" : "module";
299
+ }
300
+ let format$1 = extensionFormatMap[ext];
301
+ if (format$1) return format$1;
302
+ if (!ignoreErrors)
303
+ throw new ERR_UNKNOWN_FILE_EXTENSION(ext, fileURLToPath(url));
304
+ }
305
+ function defaultGetFormatWithoutErrors(url, context) {
306
+ let protocol = url.protocol;
307
+ return hasOwnProperty.call(protocolHandlers, protocol) && protocolHandlers[protocol](url, context, !0) || null;
308
+ }
309
+ var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.hasOwnProperty, 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, 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, invalidPackageNameRegEx = /^\.|%|\\/, patternRegEx = /\*/g, encodedSeparatorRegEx = /%2f|%5c/i, emittedPackageWarnings = /* @__PURE__ */ new Set(), doubleSlashRegEx = /[/\\]{2}/;
310
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
311
+ if (process$1.noDeprecation) return;
312
+ let pjsonPath = fileURLToPath(packageJsonUrl), double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
313
+ 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");
314
+ }
315
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
316
+ if (process$1.noDeprecation || defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
317
+ let urlPath = fileURLToPath(url.href), packagePath = fileURLToPath(new URL$1(".", packageJsonUrl)), basePath = fileURLToPath(base);
318
+ main ? 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}.
319
+ Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151") : 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}.
320
+ Default "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
321
+ }
322
+ function tryStatSync(path$1) {
323
+ try {
324
+ return statSync(path$1);
325
+ } catch {
326
+ }
327
+ }
328
+ function fileExists(url) {
329
+ let stats = statSync(url, { throwIfNoEntry: !1 }), isFile = stats ? stats.isFile() : void 0;
330
+ return isFile ?? !1;
331
+ }
332
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
333
+ let guess;
334
+ if (packageConfig.main !== void 0) {
335
+ if (guess = new URL$1(packageConfig.main, packageJsonUrl), fileExists(guess)) return guess;
336
+ let tries$1 = [
337
+ `./${packageConfig.main}.js`,
338
+ `./${packageConfig.main}.json`,
339
+ `./${packageConfig.main}.node`,
340
+ `./${packageConfig.main}/index.js`,
341
+ `./${packageConfig.main}/index.json`,
342
+ `./${packageConfig.main}/index.node`
343
+ ], i$1 = -1;
344
+ for (; ++i$1 < tries$1.length && (guess = new URL$1(tries$1[i$1], packageJsonUrl), !fileExists(guess)); )
345
+ guess = void 0;
346
+ if (guess)
347
+ return emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main), guess;
348
+ }
349
+ let tries = [
350
+ "./index.js",
351
+ "./index.json",
352
+ "./index.node"
353
+ ], i = -1;
354
+ for (; ++i < tries.length && (guess = new URL$1(tries[i], packageJsonUrl), !fileExists(guess)); )
355
+ guess = void 0;
356
+ if (guess)
357
+ return emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main), guess;
358
+ throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
359
+ }
360
+ function finalizeResolution(resolved, base, preserveSymlinks) {
361
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, String.raw`must not include encoded "/" or "\" characters`, fileURLToPath(base));
362
+ let filePath;
363
+ try {
364
+ filePath = fileURLToPath(resolved);
365
+ } catch (error) {
366
+ throw Object.defineProperty(error, "input", { value: String(resolved) }), Object.defineProperty(error, "module", { value: String(base) }), error;
367
+ }
368
+ let stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
369
+ if (stats && stats.isDirectory()) {
370
+ let error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
371
+ throw error.url = String(resolved), error;
372
+ }
373
+ if (!stats || !stats.isFile()) {
374
+ let error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), !0);
375
+ throw error.url = String(resolved), error;
376
+ }
377
+ if (!preserveSymlinks) {
378
+ let real = realpathSync(filePath), { search, hash } = resolved;
379
+ resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : "")), resolved.search = search, resolved.hash = hash;
380
+ }
381
+ return resolved;
382
+ }
383
+ function importNotDefined(specifier, packageJsonUrl, base) {
384
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
385
+ }
386
+ function exportsNotFound(subpath, packageJsonUrl, base) {
387
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, base && fileURLToPath(base));
388
+ }
389
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
390
+ 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));
391
+ }
392
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
393
+ return target = typeof target == "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`, new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath(base));
394
+ }
395
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
396
+ if (subpath !== "" && !pattern && target.at(-1) !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
397
+ if (!target.startsWith("./")) {
398
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
399
+ let isURL = !1;
400
+ try {
401
+ new URL$1(target), isURL = !0;
402
+ } catch {
403
+ }
404
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
405
+ }
406
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
407
+ }
408
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
409
+ if (!isPathMap) {
410
+ let request = pattern ? match.replace("*", () => subpath) : match + subpath;
411
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, !0);
412
+ }
413
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
414
+ let resolved = new URL$1(target, packageJsonUrl), resolvedPath = resolved.pathname, packagePath = new URL$1(".", packageJsonUrl).pathname;
415
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
416
+ if (subpath === "") return resolved;
417
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
418
+ let request = pattern ? match.replace("*", () => subpath) : match + subpath;
419
+ deprecatedInvalidSegmentRegEx.exec(subpath) === null ? isPathMap || emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, !1) : throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
420
+ }
421
+ return pattern ? new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath)) : new URL$1(subpath, resolved);
422
+ }
423
+ function isArrayIndex(key) {
424
+ let keyNumber = Number(key);
425
+ return `${keyNumber}` !== key ? !1 : keyNumber >= 0 && keyNumber < 4294967295;
426
+ }
427
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
428
+ if (typeof target == "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
429
+ if (Array.isArray(target)) {
430
+ let targetList = target;
431
+ if (targetList.length === 0) return null;
432
+ let lastException, i = -1;
433
+ for (; ++i < targetList.length; ) {
434
+ let targetItem = targetList[i], resolveResult;
435
+ try {
436
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
437
+ } catch (error) {
438
+ let exception = error;
439
+ if (lastException = exception, exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
440
+ throw error;
441
+ }
442
+ if (resolveResult !== void 0) {
443
+ if (resolveResult === null) {
444
+ lastException = null;
445
+ continue;
446
+ }
447
+ return resolveResult;
448
+ }
449
+ }
450
+ if (lastException == null) return null;
451
+ throw lastException;
452
+ }
453
+ if (typeof target == "object" && target !== null) {
454
+ let keys = Object.getOwnPropertyNames(target), i = -1;
455
+ for (; ++i < keys.length; ) {
456
+ let key = keys[i];
457
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), '"exports" cannot contain numeric property keys.');
458
+ }
459
+ for (i = -1; ++i < keys.length; ) {
460
+ let key = keys[i];
461
+ if (key === "default" || conditions && conditions.has(key)) {
462
+ let conditionalTarget = target[key], resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
463
+ if (resolveResult === void 0) continue;
464
+ return resolveResult;
465
+ }
466
+ }
467
+ return null;
468
+ }
469
+ if (target === null) return null;
470
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
471
+ }
472
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
473
+ if (typeof exports == "string" || Array.isArray(exports)) return !0;
474
+ if (typeof exports != "object" || exports === null) return !1;
475
+ let keys = Object.getOwnPropertyNames(exports), isConditionalSugar = !1, i = 0, keyIndex = -1;
476
+ for (; ++keyIndex < keys.length; ) {
477
+ let key = keys[keyIndex], currentIsConditionalSugar = key === "" || key[0] !== ".";
478
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
479
+ 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.`);
480
+ }
481
+ return isConditionalSugar;
482
+ }
483
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
484
+ if (process$1.noDeprecation) return;
485
+ let pjsonPath = fileURLToPath(pjsonUrl);
486
+ emittedPackageWarnings.has(pjsonPath + "|" + match) || (emittedPackageWarnings.add(pjsonPath + "|" + match), 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"));
487
+ }
488
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
489
+ let exports = packageConfig.exports;
490
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base) && (exports = { ".": exports }), own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
491
+ let target = exports[packageSubpath], resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, !1, !1, !1, conditions);
492
+ if (resolveResult == null) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
493
+ return resolveResult;
494
+ }
495
+ let bestMatch = "", bestMatchSubpath = "", keys = Object.getOwnPropertyNames(exports), i = -1;
496
+ for (; ++i < keys.length; ) {
497
+ let key = keys[i], patternIndex = key.indexOf("*");
498
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
499
+ packageSubpath.endsWith("/") && emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
500
+ let patternTrailer = key.slice(patternIndex + 1);
501
+ packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex && (bestMatch = key, bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length));
502
+ }
503
+ }
504
+ if (bestMatch) {
505
+ let target = exports[bestMatch], resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, !0, !1, packageSubpath.endsWith("/"), conditions);
506
+ if (resolveResult == null) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
507
+ return resolveResult;
508
+ }
509
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
510
+ }
511
+ function patternKeyCompare(a, b) {
512
+ let aPatternIndex = a.indexOf("*"), bPatternIndex = b.indexOf("*"), baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1, baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
513
+ return baseLengthA > baseLengthB ? -1 : baseLengthB > baseLengthA || aPatternIndex === -1 ? 1 : bPatternIndex === -1 || a.length > b.length ? -1 : b.length > a.length ? 1 : 0;
514
+ }
515
+ function packageImportsResolve(name, base, conditions) {
516
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", fileURLToPath(base));
517
+ let packageJsonUrl, packageConfig = getPackageScopeConfig(base);
518
+ if (packageConfig.exists) {
519
+ packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
520
+ let imports = packageConfig.imports;
521
+ if (imports) if (own.call(imports, name) && !name.includes("*")) {
522
+ let resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, !1, !0, !1, conditions);
523
+ if (resolveResult != null) return resolveResult;
524
+ } else {
525
+ let bestMatch = "", bestMatchSubpath = "", keys = Object.getOwnPropertyNames(imports), i = -1;
526
+ for (; ++i < keys.length; ) {
527
+ let key = keys[i], patternIndex = key.indexOf("*");
528
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
529
+ let patternTrailer = key.slice(patternIndex + 1);
530
+ name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex && (bestMatch = key, bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length));
531
+ }
532
+ }
533
+ if (bestMatch) {
534
+ let target = imports[bestMatch], resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, !0, !0, !1, conditions);
535
+ if (resolveResult != null) return resolveResult;
536
+ }
537
+ }
538
+ }
539
+ throw importNotDefined(name, packageJsonUrl, base);
540
+ }
541
+ function parsePackageName(specifier, base) {
542
+ let separatorIndex = specifier.indexOf("/"), validPackageName = !0, isScoped = !1;
543
+ specifier[0] === "@" && (isScoped = !0, separatorIndex === -1 || specifier.length === 0 ? validPackageName = !1 : separatorIndex = specifier.indexOf("/", separatorIndex + 1));
544
+ let packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
545
+ if (invalidPackageNameRegEx.exec(packageName) !== null && (validPackageName = !1), !validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath(base));
546
+ return {
547
+ packageName,
548
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
549
+ isScoped
550
+ };
551
+ }
552
+ function packageResolve(specifier, base, conditions) {
553
+ if (nodeBuiltins.includes(specifier)) return new URL$1("node:" + specifier);
554
+ let { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base), packageConfig = getPackageScopeConfig(base);
555
+ if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(pathToFileURL(packageConfig.pjsonPath), packageSubpath, packageConfig, base, conditions);
556
+ let packageJsonUrl = new URL$1("./node_modules/" + packageName + "/package.json", base), packageJsonPath = fileURLToPath(packageJsonUrl), lastPath;
557
+ do {
558
+ let stat = tryStatSync(packageJsonPath.slice(0, -13));
559
+ if (!stat || !stat.isDirectory()) {
560
+ lastPath = packageJsonPath, packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl), packageJsonPath = fileURLToPath(packageJsonUrl);
561
+ continue;
562
+ }
563
+ let packageConfig$1 = read(packageJsonPath, {
564
+ base,
565
+ specifier
566
+ });
567
+ return packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null ? packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions) : packageSubpath === "." ? legacyMainResolve(packageJsonUrl, packageConfig$1, base) : new URL$1(packageSubpath, packageJsonUrl);
568
+ } while (packageJsonPath.length !== lastPath.length);
569
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), !1);
570
+ }
571
+ function isRelativeSpecifier(specifier) {
572
+ return specifier[0] === "." && (specifier.length === 1 || specifier[1] === "/" || specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/"));
573
+ }
574
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
575
+ return specifier === "" ? !1 : specifier[0] === "/" ? !0 : isRelativeSpecifier(specifier);
576
+ }
577
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
578
+ let protocol = base.protocol, isData = protocol === "data:", resolved;
579
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
580
+ resolved = new URL$1(specifier, base);
581
+ } catch (error_) {
582
+ let error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
583
+ throw error.cause = error_, error;
584
+ }
585
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
586
+ else try {
587
+ resolved = new URL$1(specifier);
588
+ } catch (error_) {
589
+ if (isData && !nodeBuiltins.includes(specifier)) {
590
+ let error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
591
+ throw error.cause = error_, error;
592
+ }
593
+ resolved = packageResolve(specifier, base, conditions);
594
+ }
595
+ return assert.ok(resolved !== void 0, "expected to be defined"), resolved.protocol !== "file:" ? resolved : finalizeResolution(resolved, base, preserveSymlinks);
596
+ }
597
+ var DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]), isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
598
+ function resolveModuleURL(input, options) {
599
+ let parsedInput = _parseInput(input);
600
+ if ("external" in parsedInput) return parsedInput.external;
601
+ let specifier = parsedInput.specifier, url = parsedInput.url, absolutePath = parsedInput.absolutePath, cacheKey, cacheObj;
602
+ if (options?.cache !== !1 && (cacheKey = _cacheKey(absolutePath || specifier, options), cacheObj = options?.cache && typeof options?.cache == "object" ? options.cache : globalCache), cacheObj) {
603
+ let cached = cacheObj.get(cacheKey);
604
+ if (typeof cached == "string") return cached;
605
+ if (cached instanceof Error) {
606
+ if (options?.try) return;
607
+ throw cached;
608
+ }
609
+ }
610
+ if (absolutePath) try {
611
+ let stat = lstatSync(absolutePath);
612
+ if (stat.isSymbolicLink() && (absolutePath = realpathSync(absolutePath), url = pathToFileURL(absolutePath)), stat.isFile())
613
+ return cacheObj && cacheObj.set(cacheKey, url.href), url.href;
614
+ } catch (error) {
615
+ if (error?.code !== "ENOENT")
616
+ throw cacheObj && cacheObj.set(cacheKey, error), error;
617
+ }
618
+ let conditionsSet = options?.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET, target = specifier || url.href, bases = _normalizeBases(options?.from), suffixes = options?.suffixes || [""], extensions = options?.extensions ? ["", ...options.extensions] : [""], resolved;
619
+ for (let base of bases) {
620
+ for (let suffix of suffixes) {
621
+ let name = _join(target, suffix);
622
+ name === "." && (name += "/.");
623
+ for (let extension of extensions)
624
+ if (resolved = _tryModuleResolve(name + extension, base, conditionsSet), resolved) break;
625
+ if (resolved) break;
626
+ }
627
+ if (resolved) break;
628
+ }
629
+ if (!resolved) {
630
+ let error = new Error(`Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`);
631
+ if (error.code = "ERR_MODULE_NOT_FOUND", cacheObj && cacheObj.set(cacheKey, error), options?.try) return;
632
+ throw error;
633
+ }
634
+ return cacheObj && cacheObj.set(cacheKey, resolved.href), resolved.href;
635
+ }
636
+ function resolveModulePath(id, options) {
637
+ let resolved = resolveModuleURL(id, options);
638
+ if (!resolved || !resolved.startsWith("file://") && options?.try) return;
639
+ let absolutePath = fileURLToPath(resolved);
640
+ return isWindows ? _normalizeWinPath(absolutePath) : absolutePath;
641
+ }
642
+ function _tryModuleResolve(specifier, base, conditions) {
643
+ try {
644
+ return moduleResolve(specifier, base, conditions);
645
+ } catch {
646
+ }
647
+ }
648
+ function _normalizeBases(inputs) {
649
+ let urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap((input) => _normalizeBase(input));
650
+ return urls.length === 0 ? [pathToFileURL("./")] : urls;
651
+ }
652
+ function _normalizeBase(input) {
653
+ if (!input) return [];
654
+ if (_isURL(input)) return [input];
655
+ if (typeof input != "string") return [];
656
+ if (/^(?:node|data|http|https|file):/.test(input)) return new URL(input);
657
+ try {
658
+ return input.endsWith("/") || statSync(input).isDirectory() ? pathToFileURL(input + "/") : pathToFileURL(input);
659
+ } catch {
660
+ return [pathToFileURL(input + "/"), pathToFileURL(input)];
661
+ }
662
+ }
663
+ function _fmtPath(input) {
664
+ try {
665
+ return fileURLToPath(input);
666
+ } catch {
667
+ return input;
668
+ }
669
+ }
670
+ function _cacheKey(id, opts) {
671
+ return JSON.stringify([
672
+ id,
673
+ (opts?.conditions || ["node", "import"]).sort(),
674
+ opts?.extensions,
675
+ opts?.from,
676
+ opts?.suffixes
677
+ ]);
678
+ }
679
+ function _join(a, b) {
680
+ return !a || !b || b === "/" ? a : (a.endsWith("/") ? a : a + "/") + (b.startsWith("/") ? b.slice(1) : b);
681
+ }
682
+ function _normalizeWinPath(path$1) {
683
+ return path$1.replace(/\\/g, "/").replace(/^[a-z]:\//, (r) => r.toUpperCase());
684
+ }
685
+ function _isURL(input) {
686
+ return input instanceof URL || input?.constructor?.name === "URL";
687
+ }
688
+ function _parseInput(input) {
689
+ if (typeof input == "string") {
690
+ if (input.startsWith("file:")) {
691
+ let url = new URL(input);
692
+ return {
693
+ url,
694
+ absolutePath: fileURLToPath(url)
695
+ };
696
+ }
697
+ return isAbsolute(input) ? {
698
+ url: pathToFileURL(input),
699
+ absolutePath: input
700
+ } : /^(?:node|data|http|https):/.test(input) ? { external: input } : nodeBuiltins.includes(input) && !input.includes(":") ? { external: `node:${input}` } : { specifier: input };
701
+ }
702
+ if (_isURL(input))
703
+ return input.protocol === "file:" ? {
704
+ url: input,
705
+ absolutePath: fileURLToPath(input)
706
+ } : { external: input.href };
707
+ throw new TypeError("id must be a `string` or `URL`");
708
+ }
709
+
710
+ // src/shared/utils/module.ts
711
+ import { statSync as statSync2 } from "node:fs";
712
+ import { createRequire, register } from "node:module";
713
+ import { win32 } from "node:path/win32";
714
+ import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
715
+ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
716
+ "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"
717
+ ), pathToFileURL2(args[0]).href) : import.meta.resolve(...args), resolvePackageDir = (pkg, parent) => {
718
+ try {
719
+ return dirname(fileURLToPath2(importMetaResolve(join(pkg, "package.json"), parent)));
720
+ } catch {
721
+ return dirname(fileURLToPath2(importMetaResolve(join(pkg, "package.json"))));
722
+ }
723
+ }, isTypescriptLoaderRegistered = !1;
724
+ async function importModule(path2, { skipCache = !1 } = {}) {
725
+ if (!isTypescriptLoaderRegistered) {
726
+ let typescriptLoaderUrl = importMetaResolve("storybook/internal/bin/loader");
727
+ register(typescriptLoaderUrl, import.meta.url), isTypescriptLoaderRegistered = !0;
728
+ }
729
+ let mod;
730
+ try {
731
+ let resolvedPath = win32.isAbsolute(path2) ? pathToFileURL2(path2).href : path2;
732
+ mod = await import(skipCache ? `${resolvedPath}?${Date.now()}` : resolvedPath);
733
+ } catch (importError) {
734
+ try {
735
+ let require2 = createRequire(import.meta.url);
736
+ skipCache && delete require2.cache[require2.resolve(path2)], mod = require2(path2);
737
+ } catch {
738
+ throw importError;
739
+ }
740
+ }
741
+ return mod.default ?? mod;
742
+ }
743
+ var safeResolveModule = ({
744
+ specifier,
745
+ parent,
746
+ extensions = [".mjs", ".js", ".cjs"]
747
+ }) => {
748
+ try {
749
+ let resolvedPath = resolveModulePath(specifier, {
750
+ from: parent,
751
+ extensions: [""].concat(extensions)
752
+ });
753
+ if (statSync2(resolvedPath).isFile())
754
+ return resolvedPath;
755
+ } catch {
756
+ }
757
+ };
758
+
759
+ export {
760
+ resolveModulePath,
761
+ importMetaResolve,
762
+ resolvePackageDir,
763
+ importModule,
764
+ safeResolveModule
765
+ };