@storybook/builder-vite 11.0.0-alpha.0 → 11.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3395 @@
1
+ import CJS_COMPAT_NODE_URL_h8sjn8ghzhs from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_h8sjn8ghzhs from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_h8sjn8ghzhs from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_h8sjn8ghzhs.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_h8sjn8ghzhs.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_h8sjn8ghzhs.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __commonJS = (cb, mod) => function() {
18
+ try {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ } catch (e) {
21
+ throw mod = 0, e;
22
+ }
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from == "object" || typeof from == "function")
26
+ for (let key of __getOwnPropNames(from))
27
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ return to;
29
+ };
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
+ // If the importer is in node compatibility mode or this is not an ESM
32
+ // file that has been converted to a CommonJS file using a Babel-
33
+ // compatible transform (i.e. "__esModule" has not been set), then set
34
+ // "default" to the CommonJS "module.exports" for node compatibility.
35
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
36
+ mod
37
+ ));
38
+
39
+ // ../../../node_modules/semver/internal/constants.js
40
+ var require_constants = __commonJS({
41
+ "../../../node_modules/semver/internal/constants.js"(exports, module) {
42
+ "use strict";
43
+ var SEMVER_SPEC_VERSION = "2.0.0", MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
44
+ 9007199254740991, MAX_SAFE_COMPONENT_LENGTH = 16, MAX_SAFE_BUILD_LENGTH = 250, RELEASE_TYPES = [
45
+ "major",
46
+ "premajor",
47
+ "minor",
48
+ "preminor",
49
+ "patch",
50
+ "prepatch",
51
+ "prerelease"
52
+ ];
53
+ module.exports = {
54
+ MAX_LENGTH: 256,
55
+ MAX_SAFE_COMPONENT_LENGTH,
56
+ MAX_SAFE_BUILD_LENGTH,
57
+ MAX_SAFE_INTEGER,
58
+ RELEASE_TYPES,
59
+ SEMVER_SPEC_VERSION,
60
+ FLAG_INCLUDE_PRERELEASE: 1,
61
+ FLAG_LOOSE: 2
62
+ };
63
+ }
64
+ });
65
+
66
+ // ../../../node_modules/semver/internal/debug.js
67
+ var require_debug = __commonJS({
68
+ "../../../node_modules/semver/internal/debug.js"(exports, module) {
69
+ "use strict";
70
+ var debug = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
71
+ };
72
+ module.exports = debug;
73
+ }
74
+ });
75
+
76
+ // ../../../node_modules/semver/internal/re.js
77
+ var require_re = __commonJS({
78
+ "../../../node_modules/semver/internal/re.js"(exports, module) {
79
+ "use strict";
80
+ var {
81
+ MAX_SAFE_COMPONENT_LENGTH,
82
+ MAX_SAFE_BUILD_LENGTH,
83
+ MAX_LENGTH
84
+ } = require_constants(), debug = require_debug();
85
+ exports = module.exports = {};
86
+ var re = exports.re = [], safeRe = exports.safeRe = [], src = exports.src = [], safeSrc = exports.safeSrc = [], t = exports.t = {}, R = 0, LETTERDASHNUMBER = "[a-zA-Z0-9-]", safeRegexReplacements = [
87
+ ["\\s", 1],
88
+ ["\\d", MAX_LENGTH],
89
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
90
+ ], makeSafeRegex = (value) => {
91
+ for (let [token, max] of safeRegexReplacements)
92
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
93
+ return value;
94
+ }, createToken = (name, value, isGlobal) => {
95
+ let safe = makeSafeRegex(value), index = R++;
96
+ debug(name, index, value), t[name] = index, src[index] = value, safeSrc[index] = safe, re[index] = new RegExp(value, isGlobal ? "g" : void 0), safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
97
+ };
98
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
99
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
100
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
101
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
102
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
103
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
104
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
105
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
106
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
107
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
108
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
109
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
110
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
111
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
112
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
113
+ createToken("GTLT", "((?:<|>)?=?)");
114
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
115
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
116
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
117
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
118
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
119
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
120
+ createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
121
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
122
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
123
+ createToken("COERCERTL", src[t.COERCE], !0);
124
+ createToken("COERCERTLFULL", src[t.COERCEFULL], !0);
125
+ createToken("LONETILDE", "(?:~>?)");
126
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, !0);
127
+ exports.tildeTrimReplace = "$1~";
128
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
129
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
130
+ createToken("LONECARET", "(?:\\^)");
131
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, !0);
132
+ exports.caretTrimReplace = "$1^";
133
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
134
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
135
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
136
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
137
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, !0);
138
+ exports.comparatorTrimReplace = "$1$2$3";
139
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
140
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
141
+ createToken("STAR", "(<|>)?=?\\s*\\*");
142
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
143
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
144
+ }
145
+ });
146
+
147
+ // ../../../node_modules/semver/internal/parse-options.js
148
+ var require_parse_options = __commonJS({
149
+ "../../../node_modules/semver/internal/parse-options.js"(exports, module) {
150
+ "use strict";
151
+ var looseOption = Object.freeze({ loose: !0 }), emptyOpts = Object.freeze({}), parseOptions = (options) => options ? typeof options != "object" ? looseOption : options : emptyOpts;
152
+ module.exports = parseOptions;
153
+ }
154
+ });
155
+
156
+ // ../../../node_modules/semver/internal/identifiers.js
157
+ var require_identifiers = __commonJS({
158
+ "../../../node_modules/semver/internal/identifiers.js"(exports, module) {
159
+ "use strict";
160
+ var numeric = /^[0-9]+$/, compareIdentifiers = (a, b) => {
161
+ if (typeof a == "number" && typeof b == "number")
162
+ return a === b ? 0 : a < b ? -1 : 1;
163
+ let anum = numeric.test(a), bnum = numeric.test(b);
164
+ return anum && bnum && (a = +a, b = +b), a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
165
+ }, rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
166
+ module.exports = {
167
+ compareIdentifiers,
168
+ rcompareIdentifiers
169
+ };
170
+ }
171
+ });
172
+
173
+ // ../../../node_modules/semver/classes/semver.js
174
+ var require_semver = __commonJS({
175
+ "../../../node_modules/semver/classes/semver.js"(exports, module) {
176
+ "use strict";
177
+ var debug = require_debug(), { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(), { safeRe: re, t } = require_re(), parseOptions = require_parse_options(), { compareIdentifiers } = require_identifiers(), isPrereleaseIdentifier = (prerelease, identifier) => {
178
+ let identifiers = identifier.split(".");
179
+ if (identifiers.length > prerelease.length)
180
+ return !1;
181
+ for (let i = 0; i < identifiers.length; i++)
182
+ if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0)
183
+ return !1;
184
+ return !0;
185
+ }, SemVer = class _SemVer {
186
+ constructor(version2, options) {
187
+ if (options = parseOptions(options), version2 instanceof _SemVer) {
188
+ if (version2.loose === !!options.loose && version2.includePrerelease === !!options.includePrerelease)
189
+ return version2;
190
+ version2 = version2.version;
191
+ } else if (typeof version2 != "string")
192
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version2}".`);
193
+ if (version2.length > MAX_LENGTH)
194
+ throw new TypeError(
195
+ `version is longer than ${MAX_LENGTH} characters`
196
+ );
197
+ debug("SemVer", version2, options), this.options = options, this.loose = !!options.loose, this.includePrerelease = !!options.includePrerelease;
198
+ let m = version2.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
199
+ if (!m)
200
+ throw new TypeError(`Invalid Version: ${version2}`);
201
+ if (this.raw = version2, this.major = +m[1], this.minor = +m[2], this.patch = +m[3], this.major > MAX_SAFE_INTEGER || this.major < 0)
202
+ throw new TypeError("Invalid major version");
203
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0)
204
+ throw new TypeError("Invalid minor version");
205
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0)
206
+ throw new TypeError("Invalid patch version");
207
+ m[4] ? this.prerelease = m[4].split(".").map((id) => {
208
+ if (/^[0-9]+$/.test(id)) {
209
+ let num = +id;
210
+ if (num >= 0 && num < MAX_SAFE_INTEGER)
211
+ return num;
212
+ }
213
+ return id;
214
+ }) : this.prerelease = [], this.build = m[5] ? m[5].split(".") : [], this.format();
215
+ }
216
+ format() {
217
+ return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version;
218
+ }
219
+ toString() {
220
+ return this.version;
221
+ }
222
+ compare(other) {
223
+ if (debug("SemVer.compare", this.version, this.options, other), !(other instanceof _SemVer)) {
224
+ if (typeof other == "string" && other === this.version)
225
+ return 0;
226
+ other = new _SemVer(other, this.options);
227
+ }
228
+ return other.version === this.version ? 0 : this.compareMain(other) || this.comparePre(other);
229
+ }
230
+ compareMain(other) {
231
+ return other instanceof _SemVer || (other = new _SemVer(other, this.options)), this.major < other.major ? -1 : this.major > other.major ? 1 : this.minor < other.minor ? -1 : this.minor > other.minor ? 1 : this.patch < other.patch ? -1 : this.patch > other.patch ? 1 : 0;
232
+ }
233
+ comparePre(other) {
234
+ if (other instanceof _SemVer || (other = new _SemVer(other, this.options)), this.prerelease.length && !other.prerelease.length)
235
+ return -1;
236
+ if (!this.prerelease.length && other.prerelease.length)
237
+ return 1;
238
+ if (!this.prerelease.length && !other.prerelease.length)
239
+ return 0;
240
+ let i = 0;
241
+ do {
242
+ let a = this.prerelease[i], b = other.prerelease[i];
243
+ if (debug("prerelease compare", i, a, b), a === void 0 && b === void 0)
244
+ return 0;
245
+ if (b === void 0)
246
+ return 1;
247
+ if (a === void 0)
248
+ return -1;
249
+ if (a === b)
250
+ continue;
251
+ return compareIdentifiers(a, b);
252
+ } while (++i);
253
+ }
254
+ compareBuild(other) {
255
+ other instanceof _SemVer || (other = new _SemVer(other, this.options));
256
+ let i = 0;
257
+ do {
258
+ let a = this.build[i], b = other.build[i];
259
+ if (debug("build compare", i, a, b), a === void 0 && b === void 0)
260
+ return 0;
261
+ if (b === void 0)
262
+ return 1;
263
+ if (a === void 0)
264
+ return -1;
265
+ if (a === b)
266
+ continue;
267
+ return compareIdentifiers(a, b);
268
+ } while (++i);
269
+ }
270
+ // preminor will bump the version up to the next minor release, and immediately
271
+ // down to pre-release. premajor and prepatch work the same way.
272
+ inc(release, identifier, identifierBase) {
273
+ if (release.startsWith("pre")) {
274
+ if (!identifier && identifierBase === !1)
275
+ throw new Error("invalid increment argument: identifier is empty");
276
+ if (identifier) {
277
+ let match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
278
+ if (!match || match[1] !== identifier)
279
+ throw new Error(`invalid identifier: ${identifier}`);
280
+ }
281
+ }
282
+ switch (release) {
283
+ case "premajor":
284
+ this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", identifier, identifierBase);
285
+ break;
286
+ case "preminor":
287
+ this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", identifier, identifierBase);
288
+ break;
289
+ case "prepatch":
290
+ this.prerelease.length = 0, this.inc("patch", identifier, identifierBase), this.inc("pre", identifier, identifierBase);
291
+ break;
292
+ // If the input is a non-prerelease version, this acts the same as
293
+ // prepatch.
294
+ case "prerelease":
295
+ this.prerelease.length === 0 && this.inc("patch", identifier, identifierBase), this.inc("pre", identifier, identifierBase);
296
+ break;
297
+ case "release":
298
+ if (this.prerelease.length === 0)
299
+ throw new Error(`version ${this.raw} is not a prerelease`);
300
+ this.prerelease.length = 0;
301
+ break;
302
+ case "major":
303
+ (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) && this.major++, this.minor = 0, this.patch = 0, this.prerelease = [];
304
+ break;
305
+ case "minor":
306
+ (this.patch !== 0 || this.prerelease.length === 0) && this.minor++, this.patch = 0, this.prerelease = [];
307
+ break;
308
+ case "patch":
309
+ this.prerelease.length === 0 && this.patch++, this.prerelease = [];
310
+ break;
311
+ // This probably shouldn't be used publicly.
312
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
313
+ case "pre": {
314
+ let base = Number(identifierBase) ? 1 : 0;
315
+ if (this.prerelease.length === 0)
316
+ this.prerelease = [base];
317
+ else {
318
+ let i = this.prerelease.length;
319
+ for (; --i >= 0; )
320
+ typeof this.prerelease[i] == "number" && (this.prerelease[i]++, i = -2);
321
+ if (i === -1) {
322
+ if (identifier === this.prerelease.join(".") && identifierBase === !1)
323
+ throw new Error("invalid increment argument: identifier already exists");
324
+ this.prerelease.push(base);
325
+ }
326
+ }
327
+ if (identifier) {
328
+ let prerelease = [identifier, base];
329
+ if (identifierBase === !1 && (prerelease = [identifier]), isPrereleaseIdentifier(this.prerelease, identifier)) {
330
+ let prereleaseBase = this.prerelease[identifier.split(".").length];
331
+ isNaN(prereleaseBase) && (this.prerelease = prerelease);
332
+ } else
333
+ this.prerelease = prerelease;
334
+ }
335
+ break;
336
+ }
337
+ default:
338
+ throw new Error(`invalid increment argument: ${release}`);
339
+ }
340
+ return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this;
341
+ }
342
+ };
343
+ module.exports = SemVer;
344
+ }
345
+ });
346
+
347
+ // ../../../node_modules/semver/functions/parse.js
348
+ var require_parse = __commonJS({
349
+ "../../../node_modules/semver/functions/parse.js"(exports, module) {
350
+ "use strict";
351
+ var SemVer = require_semver(), parse4 = (version2, options, throwErrors = !1) => {
352
+ if (version2 instanceof SemVer)
353
+ return version2;
354
+ try {
355
+ return new SemVer(version2, options);
356
+ } catch (er) {
357
+ if (!throwErrors)
358
+ return null;
359
+ throw er;
360
+ }
361
+ };
362
+ module.exports = parse4;
363
+ }
364
+ });
365
+
366
+ // ../../../node_modules/semver/functions/valid.js
367
+ var require_valid = __commonJS({
368
+ "../../../node_modules/semver/functions/valid.js"(exports, module) {
369
+ "use strict";
370
+ var parse4 = require_parse(), valid = (version2, options) => {
371
+ let v = parse4(version2, options);
372
+ return v ? v.version : null;
373
+ };
374
+ module.exports = valid;
375
+ }
376
+ });
377
+
378
+ // ../../../node_modules/semver/functions/clean.js
379
+ var require_clean = __commonJS({
380
+ "../../../node_modules/semver/functions/clean.js"(exports, module) {
381
+ "use strict";
382
+ var parse4 = require_parse(), clean = (version2, options) => {
383
+ let s = parse4(version2.trim().replace(/^[=v]+/, ""), options);
384
+ return s ? s.version : null;
385
+ };
386
+ module.exports = clean;
387
+ }
388
+ });
389
+
390
+ // ../../../node_modules/semver/functions/inc.js
391
+ var require_inc = __commonJS({
392
+ "../../../node_modules/semver/functions/inc.js"(exports, module) {
393
+ "use strict";
394
+ var SemVer = require_semver(), inc = (version2, release, options, identifier, identifierBase) => {
395
+ typeof options == "string" && (identifierBase = identifier, identifier = options, options = void 0);
396
+ try {
397
+ return new SemVer(
398
+ version2 instanceof SemVer ? version2.version : version2,
399
+ options
400
+ ).inc(release, identifier, identifierBase).version;
401
+ } catch {
402
+ return null;
403
+ }
404
+ };
405
+ module.exports = inc;
406
+ }
407
+ });
408
+
409
+ // ../../../node_modules/semver/functions/diff.js
410
+ var require_diff = __commonJS({
411
+ "../../../node_modules/semver/functions/diff.js"(exports, module) {
412
+ "use strict";
413
+ var parse4 = require_parse(), diff = (version1, version2) => {
414
+ let v1 = parse4(version1, null, !0), v2 = parse4(version2, null, !0), comparison = v1.compare(v2);
415
+ if (comparison === 0)
416
+ return null;
417
+ let v1Higher = comparison > 0, highVersion = v1Higher ? v1 : v2, lowVersion = v1Higher ? v2 : v1, highHasPre = !!highVersion.prerelease.length;
418
+ if (!!lowVersion.prerelease.length && !highHasPre) {
419
+ if (!lowVersion.patch && !lowVersion.minor)
420
+ return "major";
421
+ if (lowVersion.compareMain(highVersion) === 0)
422
+ return lowVersion.minor && !lowVersion.patch ? "minor" : "patch";
423
+ }
424
+ let prefix = highHasPre ? "pre" : "";
425
+ return v1.major !== v2.major ? prefix + "major" : v1.minor !== v2.minor ? prefix + "minor" : v1.patch !== v2.patch ? prefix + "patch" : "prerelease";
426
+ };
427
+ module.exports = diff;
428
+ }
429
+ });
430
+
431
+ // ../../../node_modules/semver/functions/major.js
432
+ var require_major = __commonJS({
433
+ "../../../node_modules/semver/functions/major.js"(exports, module) {
434
+ "use strict";
435
+ var SemVer = require_semver(), major = (a, loose) => new SemVer(a, loose).major;
436
+ module.exports = major;
437
+ }
438
+ });
439
+
440
+ // ../../../node_modules/semver/functions/minor.js
441
+ var require_minor = __commonJS({
442
+ "../../../node_modules/semver/functions/minor.js"(exports, module) {
443
+ "use strict";
444
+ var SemVer = require_semver(), minor = (a, loose) => new SemVer(a, loose).minor;
445
+ module.exports = minor;
446
+ }
447
+ });
448
+
449
+ // ../../../node_modules/semver/functions/patch.js
450
+ var require_patch = __commonJS({
451
+ "../../../node_modules/semver/functions/patch.js"(exports, module) {
452
+ "use strict";
453
+ var SemVer = require_semver(), patch = (a, loose) => new SemVer(a, loose).patch;
454
+ module.exports = patch;
455
+ }
456
+ });
457
+
458
+ // ../../../node_modules/semver/functions/prerelease.js
459
+ var require_prerelease = __commonJS({
460
+ "../../../node_modules/semver/functions/prerelease.js"(exports, module) {
461
+ "use strict";
462
+ var parse4 = require_parse(), prerelease = (version2, options) => {
463
+ let parsed = parse4(version2, options);
464
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
465
+ };
466
+ module.exports = prerelease;
467
+ }
468
+ });
469
+
470
+ // ../../../node_modules/semver/functions/compare.js
471
+ var require_compare = __commonJS({
472
+ "../../../node_modules/semver/functions/compare.js"(exports, module) {
473
+ "use strict";
474
+ var SemVer = require_semver(), compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
475
+ module.exports = compare;
476
+ }
477
+ });
478
+
479
+ // ../../../node_modules/semver/functions/rcompare.js
480
+ var require_rcompare = __commonJS({
481
+ "../../../node_modules/semver/functions/rcompare.js"(exports, module) {
482
+ "use strict";
483
+ var compare = require_compare(), rcompare = (a, b, loose) => compare(b, a, loose);
484
+ module.exports = rcompare;
485
+ }
486
+ });
487
+
488
+ // ../../../node_modules/semver/functions/compare-loose.js
489
+ var require_compare_loose = __commonJS({
490
+ "../../../node_modules/semver/functions/compare-loose.js"(exports, module) {
491
+ "use strict";
492
+ var compare = require_compare(), compareLoose = (a, b) => compare(a, b, !0);
493
+ module.exports = compareLoose;
494
+ }
495
+ });
496
+
497
+ // ../../../node_modules/semver/functions/compare-build.js
498
+ var require_compare_build = __commonJS({
499
+ "../../../node_modules/semver/functions/compare-build.js"(exports, module) {
500
+ "use strict";
501
+ var SemVer = require_semver(), compareBuild = (a, b, loose) => {
502
+ let versionA = new SemVer(a, loose), versionB = new SemVer(b, loose);
503
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
504
+ };
505
+ module.exports = compareBuild;
506
+ }
507
+ });
508
+
509
+ // ../../../node_modules/semver/functions/sort.js
510
+ var require_sort = __commonJS({
511
+ "../../../node_modules/semver/functions/sort.js"(exports, module) {
512
+ "use strict";
513
+ var compareBuild = require_compare_build(), sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
514
+ module.exports = sort;
515
+ }
516
+ });
517
+
518
+ // ../../../node_modules/semver/functions/rsort.js
519
+ var require_rsort = __commonJS({
520
+ "../../../node_modules/semver/functions/rsort.js"(exports, module) {
521
+ "use strict";
522
+ var compareBuild = require_compare_build(), rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
523
+ module.exports = rsort;
524
+ }
525
+ });
526
+
527
+ // ../../../node_modules/semver/functions/gt.js
528
+ var require_gt = __commonJS({
529
+ "../../../node_modules/semver/functions/gt.js"(exports, module) {
530
+ "use strict";
531
+ var compare = require_compare(), gt = (a, b, loose) => compare(a, b, loose) > 0;
532
+ module.exports = gt;
533
+ }
534
+ });
535
+
536
+ // ../../../node_modules/semver/functions/lt.js
537
+ var require_lt = __commonJS({
538
+ "../../../node_modules/semver/functions/lt.js"(exports, module) {
539
+ "use strict";
540
+ var compare = require_compare(), lt = (a, b, loose) => compare(a, b, loose) < 0;
541
+ module.exports = lt;
542
+ }
543
+ });
544
+
545
+ // ../../../node_modules/semver/functions/eq.js
546
+ var require_eq = __commonJS({
547
+ "../../../node_modules/semver/functions/eq.js"(exports, module) {
548
+ "use strict";
549
+ var compare = require_compare(), eq = (a, b, loose) => compare(a, b, loose) === 0;
550
+ module.exports = eq;
551
+ }
552
+ });
553
+
554
+ // ../../../node_modules/semver/functions/neq.js
555
+ var require_neq = __commonJS({
556
+ "../../../node_modules/semver/functions/neq.js"(exports, module) {
557
+ "use strict";
558
+ var compare = require_compare(), neq = (a, b, loose) => compare(a, b, loose) !== 0;
559
+ module.exports = neq;
560
+ }
561
+ });
562
+
563
+ // ../../../node_modules/semver/functions/gte.js
564
+ var require_gte = __commonJS({
565
+ "../../../node_modules/semver/functions/gte.js"(exports, module) {
566
+ "use strict";
567
+ var compare = require_compare(), gte = (a, b, loose) => compare(a, b, loose) >= 0;
568
+ module.exports = gte;
569
+ }
570
+ });
571
+
572
+ // ../../../node_modules/semver/functions/lte.js
573
+ var require_lte = __commonJS({
574
+ "../../../node_modules/semver/functions/lte.js"(exports, module) {
575
+ "use strict";
576
+ var compare = require_compare(), lte = (a, b, loose) => compare(a, b, loose) <= 0;
577
+ module.exports = lte;
578
+ }
579
+ });
580
+
581
+ // ../../../node_modules/semver/functions/cmp.js
582
+ var require_cmp = __commonJS({
583
+ "../../../node_modules/semver/functions/cmp.js"(exports, module) {
584
+ "use strict";
585
+ var eq = require_eq(), neq = require_neq(), gt = require_gt(), gte = require_gte(), lt = require_lt(), lte = require_lte(), cmp = (a, op, b, loose) => {
586
+ switch (op) {
587
+ case "===":
588
+ return typeof a == "object" && (a = a.version), typeof b == "object" && (b = b.version), a === b;
589
+ case "!==":
590
+ return typeof a == "object" && (a = a.version), typeof b == "object" && (b = b.version), a !== b;
591
+ case "":
592
+ case "=":
593
+ case "==":
594
+ return eq(a, b, loose);
595
+ case "!=":
596
+ return neq(a, b, loose);
597
+ case ">":
598
+ return gt(a, b, loose);
599
+ case ">=":
600
+ return gte(a, b, loose);
601
+ case "<":
602
+ return lt(a, b, loose);
603
+ case "<=":
604
+ return lte(a, b, loose);
605
+ default:
606
+ throw new TypeError(`Invalid operator: ${op}`);
607
+ }
608
+ };
609
+ module.exports = cmp;
610
+ }
611
+ });
612
+
613
+ // ../../../node_modules/semver/functions/coerce.js
614
+ var require_coerce = __commonJS({
615
+ "../../../node_modules/semver/functions/coerce.js"(exports, module) {
616
+ "use strict";
617
+ var SemVer = require_semver(), parse4 = require_parse(), { safeRe: re, t } = require_re(), coerce = (version2, options) => {
618
+ if (version2 instanceof SemVer)
619
+ return version2;
620
+ if (typeof version2 == "number" && (version2 = String(version2)), typeof version2 != "string")
621
+ return null;
622
+ options = options || {};
623
+ let match = null;
624
+ if (!options.rtl)
625
+ match = version2.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
626
+ else {
627
+ let coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL], next;
628
+ for (; (next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length); )
629
+ (!match || next.index + next[0].length !== match.index + match[0].length) && (match = next), coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
630
+ coerceRtlRegex.lastIndex = -1;
631
+ }
632
+ if (match === null)
633
+ return null;
634
+ let major = match[2], minor = match[3] || "0", patch = match[4] || "0", prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "", build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
635
+ return parse4(`${major}.${minor}.${patch}${prerelease}${build}`, options);
636
+ };
637
+ module.exports = coerce;
638
+ }
639
+ });
640
+
641
+ // ../../../node_modules/semver/functions/truncate.js
642
+ var require_truncate = __commonJS({
643
+ "../../../node_modules/semver/functions/truncate.js"(exports, module) {
644
+ "use strict";
645
+ var parse4 = require_parse(), constants2 = require_constants(), SemVer = require_semver(), truncate = (version2, truncation, options) => {
646
+ if (!constants2.RELEASE_TYPES.includes(truncation))
647
+ return null;
648
+ let clonedVersion = cloneInputVersion(version2, options);
649
+ return clonedVersion && doTruncation(clonedVersion, truncation);
650
+ }, cloneInputVersion = (version2, options) => {
651
+ let versionStringToParse = version2 instanceof SemVer ? version2.version : version2;
652
+ return parse4(versionStringToParse, options);
653
+ }, doTruncation = (version2, truncation) => {
654
+ if (isPrerelease(truncation))
655
+ return version2.version;
656
+ switch (version2.prerelease = [], truncation) {
657
+ case "major":
658
+ version2.minor = 0, version2.patch = 0;
659
+ break;
660
+ case "minor":
661
+ version2.patch = 0;
662
+ break;
663
+ }
664
+ return version2.format();
665
+ }, isPrerelease = (type) => type.startsWith("pre");
666
+ module.exports = truncate;
667
+ }
668
+ });
669
+
670
+ // ../../../node_modules/semver/internal/lrucache.js
671
+ var require_lrucache = __commonJS({
672
+ "../../../node_modules/semver/internal/lrucache.js"(exports, module) {
673
+ "use strict";
674
+ var LRUCache = class {
675
+ constructor() {
676
+ this.max = 1e3, this.map = /* @__PURE__ */ new Map();
677
+ }
678
+ get(key) {
679
+ let value = this.map.get(key);
680
+ if (value !== void 0)
681
+ return this.map.delete(key), this.map.set(key, value), value;
682
+ }
683
+ delete(key) {
684
+ return this.map.delete(key);
685
+ }
686
+ set(key, value) {
687
+ if (!this.delete(key) && value !== void 0) {
688
+ if (this.map.size >= this.max) {
689
+ let firstKey = this.map.keys().next().value;
690
+ this.delete(firstKey);
691
+ }
692
+ this.map.set(key, value);
693
+ }
694
+ return this;
695
+ }
696
+ };
697
+ module.exports = LRUCache;
698
+ }
699
+ });
700
+
701
+ // ../../../node_modules/semver/classes/range.js
702
+ var require_range = __commonJS({
703
+ "../../../node_modules/semver/classes/range.js"(exports, module) {
704
+ "use strict";
705
+ var SPACE_CHARACTERS = /\s+/g, Range = class _Range {
706
+ constructor(range, options) {
707
+ if (options = parseOptions(options), range instanceof _Range)
708
+ return range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease ? range : new _Range(range.raw, options);
709
+ if (range instanceof Comparator)
710
+ return this.raw = range.value, this.set = [[range]], this.formatted = void 0, this;
711
+ if (this.options = options, this.loose = !!options.loose, this.includePrerelease = !!options.includePrerelease, this.raw = range.trim().replace(SPACE_CHARACTERS, " "), this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length), !this.set.length)
712
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
713
+ if (this.set.length > 1) {
714
+ let first = this.set[0];
715
+ if (this.set = this.set.filter((c) => !isNullSet(c[0])), this.set.length === 0)
716
+ this.set = [first];
717
+ else if (this.set.length > 1) {
718
+ for (let c of this.set)
719
+ if (c.length === 1 && isAny(c[0])) {
720
+ this.set = [c];
721
+ break;
722
+ }
723
+ }
724
+ }
725
+ this.formatted = void 0;
726
+ }
727
+ get range() {
728
+ if (this.formatted === void 0) {
729
+ this.formatted = "";
730
+ for (let i = 0; i < this.set.length; i++) {
731
+ i > 0 && (this.formatted += "||");
732
+ let comps = this.set[i];
733
+ for (let k = 0; k < comps.length; k++)
734
+ k > 0 && (this.formatted += " "), this.formatted += comps[k].toString().trim();
735
+ }
736
+ }
737
+ return this.formatted;
738
+ }
739
+ format() {
740
+ return this.range;
741
+ }
742
+ toString() {
743
+ return this.range;
744
+ }
745
+ parseRange(range) {
746
+ range = range.replace(BUILDSTRIPRE, "");
747
+ let memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range, cached = cache2.get(memoKey);
748
+ if (cached)
749
+ return cached;
750
+ let loose = this.options.loose, hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
751
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease)), debug("hyphen replace", range), range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace), debug("comparator trim", range), range = range.replace(re[t.TILDETRIM], tildeTrimReplace), debug("tilde trim", range), range = range.replace(re[t.CARETTRIM], caretTrimReplace), debug("caret trim", range);
752
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
753
+ loose && (rangeList = rangeList.filter((comp) => (debug("loose invalid filter", comp, this.options), !!comp.match(re[t.COMPARATORLOOSE])))), debug("range list", rangeList);
754
+ let rangeMap = /* @__PURE__ */ new Map(), comparators = rangeList.map((comp) => new Comparator(comp, this.options));
755
+ for (let comp of comparators) {
756
+ if (isNullSet(comp))
757
+ return [comp];
758
+ rangeMap.set(comp.value, comp);
759
+ }
760
+ rangeMap.size > 1 && rangeMap.has("") && rangeMap.delete("");
761
+ let result = [...rangeMap.values()];
762
+ return cache2.set(memoKey, result), result;
763
+ }
764
+ intersects(range, options) {
765
+ if (!(range instanceof _Range))
766
+ throw new TypeError("a Range is required");
767
+ return this.set.some((thisComparators) => isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => rangeComparators.every((rangeComparator) => thisComparator.intersects(rangeComparator, options)))));
768
+ }
769
+ // if ANY of the sets match ALL of its comparators, then pass
770
+ test(version2) {
771
+ if (!version2)
772
+ return !1;
773
+ if (typeof version2 == "string")
774
+ try {
775
+ version2 = new SemVer(version2, this.options);
776
+ } catch {
777
+ return !1;
778
+ }
779
+ for (let i = 0; i < this.set.length; i++)
780
+ if (testSet(this.set[i], version2, this.options))
781
+ return !0;
782
+ return !1;
783
+ }
784
+ };
785
+ module.exports = Range;
786
+ var LRU = require_lrucache(), cache2 = new LRU(), parseOptions = require_parse_options(), Comparator = require_comparator(), debug = require_debug(), SemVer = require_semver(), {
787
+ safeRe: re,
788
+ src,
789
+ t,
790
+ comparatorTrimReplace,
791
+ tildeTrimReplace,
792
+ caretTrimReplace
793
+ } = require_re(), { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants(), BUILDSTRIPRE = new RegExp(src[t.BUILD], "g"), isNullSet = (c) => c.value === "<0.0.0-0", isAny = (c) => c.value === "", isSatisfiable = (comparators, options) => {
794
+ let result = !0, remainingComparators = comparators.slice(), testComparator = remainingComparators.pop();
795
+ for (; result && remainingComparators.length; )
796
+ result = remainingComparators.every((otherComparator) => testComparator.intersects(otherComparator, options)), testComparator = remainingComparators.pop();
797
+ return result;
798
+ }, parseComparator = (comp, options) => (comp = comp.replace(re[t.BUILD], ""), debug("comp", comp, options), comp = replaceCarets(comp, options), debug("caret", comp), comp = replaceTildes(comp, options), debug("tildes", comp), comp = replaceXRanges(comp, options), debug("xrange", comp), comp = replaceStars(comp, options), debug("stars", comp), comp), isX = (id) => !id || id.toLowerCase() === "x" || id === "*", invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p), replaceTildes = (comp, options) => comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" "), replaceTilde = (comp, options) => {
799
+ let r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE], z = options.includePrerelease ? "-0" : "";
800
+ return comp.replace(r, (_, M, m, p, pr) => {
801
+ debug("tilde", comp, _, M, m, p, pr);
802
+ let ret;
803
+ return isX(M) ? ret = "" : isX(m) ? ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` : isX(p) ? ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` : pr ? (debug("replaceTilde pr", pr), ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`) : ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`, debug("tilde return", ret), ret;
804
+ });
805
+ }, replaceCarets = (comp, options) => comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" "), replaceCaret = (comp, options) => {
806
+ debug("caret", comp, options);
807
+ let r = options.loose ? re[t.CARETLOOSE] : re[t.CARET], z = options.includePrerelease ? "-0" : "";
808
+ return comp.replace(r, (_, M, m, p, pr) => {
809
+ debug("caret", comp, _, M, m, p, pr);
810
+ let ret;
811
+ return isX(M) ? ret = "" : isX(m) ? ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` : isX(p) ? M === "0" ? ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` : ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` : pr ? (debug("replaceCaret pr", pr), M === "0" ? m === "0" ? ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0` : ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0` : ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`) : (debug("no pr"), M === "0" ? m === "0" ? ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0` : ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0` : ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`), debug("caret return", ret), ret;
812
+ });
813
+ }, replaceXRanges = (comp, options) => (debug("replaceXRanges", comp, options), comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ")), replaceXRange = (comp, options) => {
814
+ comp = comp.trim();
815
+ let r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
816
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
817
+ if (debug("xRange", comp, ret, gtlt, M, m, p, pr), invalidXRangeOrder(M, m, p))
818
+ return comp;
819
+ let xM = isX(M), xm = xM || isX(m), xp = xm || isX(p), anyX = xp;
820
+ return gtlt === "=" && anyX && (gtlt = ""), pr = options.includePrerelease ? "-0" : "", xM ? gtlt === ">" || gtlt === "<" ? ret = "<0.0.0-0" : ret = "*" : gtlt && anyX ? (xm && (m = 0), p = 0, gtlt === ">" ? (gtlt = ">=", xm ? (M = +M + 1, m = 0, p = 0) : (m = +m + 1, p = 0)) : gtlt === "<=" && (gtlt = "<", xm ? M = +M + 1 : m = +m + 1), gtlt === "<" && (pr = "-0"), ret = `${gtlt + M}.${m}.${p}${pr}`) : xm ? ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` : xp && (ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`), debug("xRange return", ret), ret;
821
+ });
822
+ }, replaceStars = (comp, options) => (debug("replaceStars", comp, options), comp.trim().replace(re[t.STAR], "")), replaceGTE0 = (comp, options) => (debug("replaceGTE0", comp, options), comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "")), hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => (isX(fM) ? from = "" : isX(fm) ? from = `>=${fM}.0.0${incPr ? "-0" : ""}` : isX(fp) ? from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}` : fpr ? from = `>=${from}` : from = `>=${from}${incPr ? "-0" : ""}`, isX(tM) ? to = "" : isX(tm) ? to = `<${+tM + 1}.0.0-0` : isX(tp) ? to = `<${tM}.${+tm + 1}.0-0` : tpr ? to = `<=${tM}.${tm}.${tp}-${tpr}` : incPr ? to = `<${tM}.${tm}.${+tp + 1}-0` : to = `<=${to}`, `${from} ${to}`.trim()), testSet = (set, version2, options) => {
823
+ for (let i = 0; i < set.length; i++)
824
+ if (!set[i].test(version2))
825
+ return !1;
826
+ if (version2.prerelease.length && !options.includePrerelease) {
827
+ for (let i = 0; i < set.length; i++)
828
+ if (debug(set[i].semver), set[i].semver !== Comparator.ANY && set[i].semver.prerelease.length > 0) {
829
+ let allowed = set[i].semver;
830
+ if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch)
831
+ return !0;
832
+ }
833
+ return !1;
834
+ }
835
+ return !0;
836
+ };
837
+ }
838
+ });
839
+
840
+ // ../../../node_modules/semver/classes/comparator.js
841
+ var require_comparator = __commonJS({
842
+ "../../../node_modules/semver/classes/comparator.js"(exports, module) {
843
+ "use strict";
844
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY"), Comparator = class _Comparator {
845
+ static get ANY() {
846
+ return ANY;
847
+ }
848
+ constructor(comp, options) {
849
+ if (options = parseOptions(options), comp instanceof _Comparator) {
850
+ if (comp.loose === !!options.loose)
851
+ return comp;
852
+ comp = comp.value;
853
+ }
854
+ comp = comp.trim().split(/\s+/).join(" "), debug("comparator", comp, options), this.options = options, this.loose = !!options.loose, this.parse(comp), this.semver === ANY ? this.value = "" : this.value = this.operator + this.semver.version, debug("comp", this);
855
+ }
856
+ parse(comp) {
857
+ let r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR], m = comp.match(r);
858
+ if (!m)
859
+ throw new TypeError(`Invalid comparator: ${comp}`);
860
+ this.operator = m[1] !== void 0 ? m[1] : "", this.operator === "=" && (this.operator = ""), m[2] ? this.semver = new SemVer(m[2], this.options.loose) : this.semver = ANY;
861
+ }
862
+ toString() {
863
+ return this.value;
864
+ }
865
+ test(version2) {
866
+ if (debug("Comparator.test", version2, this.options.loose), this.semver === ANY || version2 === ANY)
867
+ return !0;
868
+ if (typeof version2 == "string")
869
+ try {
870
+ version2 = new SemVer(version2, this.options);
871
+ } catch {
872
+ return !1;
873
+ }
874
+ return cmp(version2, this.operator, this.semver, this.options);
875
+ }
876
+ intersects(comp, options) {
877
+ if (!(comp instanceof _Comparator))
878
+ throw new TypeError("a Comparator is required");
879
+ return this.operator === "" ? this.value === "" ? !0 : new Range(comp.value, options).test(this.value) : comp.operator === "" ? comp.value === "" ? !0 : new Range(this.value, options).test(comp.semver) : (options = parseOptions(options), options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0") || !options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0")) ? !1 : !!(this.operator.startsWith(">") && comp.operator.startsWith(">") || this.operator.startsWith("<") && comp.operator.startsWith("<") || this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=") || cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<") || cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")));
880
+ }
881
+ };
882
+ module.exports = Comparator;
883
+ var parseOptions = require_parse_options(), { safeRe: re, t } = require_re(), cmp = require_cmp(), debug = require_debug(), SemVer = require_semver(), Range = require_range();
884
+ }
885
+ });
886
+
887
+ // ../../../node_modules/semver/functions/satisfies.js
888
+ var require_satisfies = __commonJS({
889
+ "../../../node_modules/semver/functions/satisfies.js"(exports, module) {
890
+ "use strict";
891
+ var Range = require_range(), satisfies = (version2, range, options) => {
892
+ try {
893
+ range = new Range(range, options);
894
+ } catch {
895
+ return !1;
896
+ }
897
+ return range.test(version2);
898
+ };
899
+ module.exports = satisfies;
900
+ }
901
+ });
902
+
903
+ // ../../../node_modules/semver/ranges/to-comparators.js
904
+ var require_to_comparators = __commonJS({
905
+ "../../../node_modules/semver/ranges/to-comparators.js"(exports, module) {
906
+ "use strict";
907
+ var Range = require_range(), toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
908
+ module.exports = toComparators;
909
+ }
910
+ });
911
+
912
+ // ../../../node_modules/semver/ranges/max-satisfying.js
913
+ var require_max_satisfying = __commonJS({
914
+ "../../../node_modules/semver/ranges/max-satisfying.js"(exports, module) {
915
+ "use strict";
916
+ var SemVer = require_semver(), Range = require_range(), maxSatisfying = (versions, range, options) => {
917
+ let max = null, maxSV = null, rangeObj = null;
918
+ try {
919
+ rangeObj = new Range(range, options);
920
+ } catch {
921
+ return null;
922
+ }
923
+ return versions.forEach((v) => {
924
+ rangeObj.test(v) && (!max || maxSV.compare(v) === -1) && (max = v, maxSV = new SemVer(max, options));
925
+ }), max;
926
+ };
927
+ module.exports = maxSatisfying;
928
+ }
929
+ });
930
+
931
+ // ../../../node_modules/semver/ranges/min-satisfying.js
932
+ var require_min_satisfying = __commonJS({
933
+ "../../../node_modules/semver/ranges/min-satisfying.js"(exports, module) {
934
+ "use strict";
935
+ var SemVer = require_semver(), Range = require_range(), minSatisfying = (versions, range, options) => {
936
+ let min = null, minSV = null, rangeObj = null;
937
+ try {
938
+ rangeObj = new Range(range, options);
939
+ } catch {
940
+ return null;
941
+ }
942
+ return versions.forEach((v) => {
943
+ rangeObj.test(v) && (!min || minSV.compare(v) === 1) && (min = v, minSV = new SemVer(min, options));
944
+ }), min;
945
+ };
946
+ module.exports = minSatisfying;
947
+ }
948
+ });
949
+
950
+ // ../../../node_modules/semver/ranges/min-version.js
951
+ var require_min_version = __commonJS({
952
+ "../../../node_modules/semver/ranges/min-version.js"(exports, module) {
953
+ "use strict";
954
+ var SemVer = require_semver(), Range = require_range(), gt = require_gt(), minVersion = (range, loose) => {
955
+ range = new Range(range, loose);
956
+ let minver = new SemVer("0.0.0");
957
+ if (range.test(minver) || (minver = new SemVer("0.0.0-0"), range.test(minver)))
958
+ return minver;
959
+ minver = null;
960
+ for (let i = 0; i < range.set.length; ++i) {
961
+ let comparators = range.set[i], setMin = null;
962
+ comparators.forEach((comparator) => {
963
+ let compver = new SemVer(comparator.semver.version);
964
+ switch (comparator.operator) {
965
+ case ">":
966
+ compver.prerelease.length === 0 ? compver.patch++ : compver.prerelease.push(0), compver.raw = compver.format();
967
+ /* fallthrough */
968
+ case "":
969
+ case ">=":
970
+ (!setMin || gt(compver, setMin)) && (setMin = compver);
971
+ break;
972
+ case "<":
973
+ case "<=":
974
+ break;
975
+ /* istanbul ignore next */
976
+ default:
977
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
978
+ }
979
+ }), setMin && (!minver || gt(minver, setMin)) && (minver = setMin);
980
+ }
981
+ return minver && range.test(minver) ? minver : null;
982
+ };
983
+ module.exports = minVersion;
984
+ }
985
+ });
986
+
987
+ // ../../../node_modules/semver/ranges/valid.js
988
+ var require_valid2 = __commonJS({
989
+ "../../../node_modules/semver/ranges/valid.js"(exports, module) {
990
+ "use strict";
991
+ var Range = require_range(), validRange = (range, options) => {
992
+ try {
993
+ return new Range(range, options).range || "*";
994
+ } catch {
995
+ return null;
996
+ }
997
+ };
998
+ module.exports = validRange;
999
+ }
1000
+ });
1001
+
1002
+ // ../../../node_modules/semver/ranges/outside.js
1003
+ var require_outside = __commonJS({
1004
+ "../../../node_modules/semver/ranges/outside.js"(exports, module) {
1005
+ "use strict";
1006
+ var SemVer = require_semver(), Comparator = require_comparator(), { ANY } = Comparator, Range = require_range(), satisfies = require_satisfies(), gt = require_gt(), lt = require_lt(), lte = require_lte(), gte = require_gte(), outside = (version2, range, hilo, options) => {
1007
+ version2 = new SemVer(version2, options), range = new Range(range, options);
1008
+ let gtfn, ltefn, ltfn, comp, ecomp;
1009
+ switch (hilo) {
1010
+ case ">":
1011
+ gtfn = gt, ltefn = lte, ltfn = lt, comp = ">", ecomp = ">=";
1012
+ break;
1013
+ case "<":
1014
+ gtfn = lt, ltefn = gte, ltfn = gt, comp = "<", ecomp = "<=";
1015
+ break;
1016
+ default:
1017
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1018
+ }
1019
+ if (satisfies(version2, range, options))
1020
+ return !1;
1021
+ for (let i = 0; i < range.set.length; ++i) {
1022
+ let comparators = range.set[i], high = null, low = null;
1023
+ if (comparators.forEach((comparator) => {
1024
+ comparator.semver === ANY && (comparator = new Comparator(">=0.0.0")), high = high || comparator, low = low || comparator, gtfn(comparator.semver, high.semver, options) ? high = comparator : ltfn(comparator.semver, low.semver, options) && (low = comparator);
1025
+ }), high.operator === comp || high.operator === ecomp || (!low.operator || low.operator === comp) && ltefn(version2, low.semver))
1026
+ return !1;
1027
+ if (low.operator === ecomp && ltfn(version2, low.semver))
1028
+ return !1;
1029
+ }
1030
+ return !0;
1031
+ };
1032
+ module.exports = outside;
1033
+ }
1034
+ });
1035
+
1036
+ // ../../../node_modules/semver/ranges/gtr.js
1037
+ var require_gtr = __commonJS({
1038
+ "../../../node_modules/semver/ranges/gtr.js"(exports, module) {
1039
+ "use strict";
1040
+ var outside = require_outside(), gtr = (version2, range, options) => outside(version2, range, ">", options);
1041
+ module.exports = gtr;
1042
+ }
1043
+ });
1044
+
1045
+ // ../../../node_modules/semver/ranges/ltr.js
1046
+ var require_ltr = __commonJS({
1047
+ "../../../node_modules/semver/ranges/ltr.js"(exports, module) {
1048
+ "use strict";
1049
+ var outside = require_outside(), ltr = (version2, range, options) => outside(version2, range, "<", options);
1050
+ module.exports = ltr;
1051
+ }
1052
+ });
1053
+
1054
+ // ../../../node_modules/semver/ranges/intersects.js
1055
+ var require_intersects = __commonJS({
1056
+ "../../../node_modules/semver/ranges/intersects.js"(exports, module) {
1057
+ "use strict";
1058
+ var Range = require_range(), intersects = (r1, r2, options) => (r1 = new Range(r1, options), r2 = new Range(r2, options), r1.intersects(r2, options));
1059
+ module.exports = intersects;
1060
+ }
1061
+ });
1062
+
1063
+ // ../../../node_modules/semver/ranges/simplify.js
1064
+ var require_simplify = __commonJS({
1065
+ "../../../node_modules/semver/ranges/simplify.js"(exports, module) {
1066
+ "use strict";
1067
+ var satisfies = require_satisfies(), compare = require_compare();
1068
+ module.exports = (versions, range, options) => {
1069
+ let set = [], first = null, prev = null, v = versions.sort((a, b) => compare(a, b, options));
1070
+ for (let version2 of v)
1071
+ satisfies(version2, range, options) ? (prev = version2, first || (first = version2)) : (prev && set.push([first, prev]), prev = null, first = null);
1072
+ first && set.push([first, null]);
1073
+ let ranges = [];
1074
+ for (let [min, max] of set)
1075
+ min === max ? ranges.push(min) : !max && min === v[0] ? ranges.push("*") : max ? min === v[0] ? ranges.push(`<=${max}`) : ranges.push(`${min} - ${max}`) : ranges.push(`>=${min}`);
1076
+ let simplified = ranges.join(" || "), original = typeof range.raw == "string" ? range.raw : String(range);
1077
+ return simplified.length < original.length ? simplified : range;
1078
+ };
1079
+ }
1080
+ });
1081
+
1082
+ // ../../../node_modules/semver/ranges/subset.js
1083
+ var require_subset = __commonJS({
1084
+ "../../../node_modules/semver/ranges/subset.js"(exports, module) {
1085
+ "use strict";
1086
+ var Range = require_range(), Comparator = require_comparator(), { ANY } = Comparator, satisfies = require_satisfies(), compare = require_compare(), subset = (sub, dom, options = {}) => {
1087
+ if (sub === dom)
1088
+ return !0;
1089
+ sub = new Range(sub, options), dom = new Range(dom, options);
1090
+ let sawNonNull = !1;
1091
+ OUTER: for (let simpleSub of sub.set) {
1092
+ for (let simpleDom of dom.set) {
1093
+ let isSub = simpleSubset(simpleSub, simpleDom, options);
1094
+ if (sawNonNull = sawNonNull || isSub !== null, isSub)
1095
+ continue OUTER;
1096
+ }
1097
+ if (sawNonNull)
1098
+ return !1;
1099
+ }
1100
+ return !0;
1101
+ }, minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")], minimumVersion = [new Comparator(">=0.0.0")], simpleSubset = (sub, dom, options) => {
1102
+ if (sub === dom)
1103
+ return !0;
1104
+ if (sub.length === 1 && sub[0].semver === ANY) {
1105
+ if (dom.length === 1 && dom[0].semver === ANY)
1106
+ return !0;
1107
+ options.includePrerelease ? sub = minimumVersionWithPreRelease : sub = minimumVersion;
1108
+ }
1109
+ if (dom.length === 1 && dom[0].semver === ANY) {
1110
+ if (options.includePrerelease)
1111
+ return !0;
1112
+ dom = minimumVersion;
1113
+ }
1114
+ let eqSet = /* @__PURE__ */ new Set(), gt, lt;
1115
+ for (let c of sub)
1116
+ c.operator === ">" || c.operator === ">=" ? gt = higherGT(gt, c, options) : c.operator === "<" || c.operator === "<=" ? lt = lowerLT(lt, c, options) : eqSet.add(c.semver);
1117
+ if (eqSet.size > 1)
1118
+ return null;
1119
+ let gtltComp;
1120
+ if (gt && lt) {
1121
+ if (gtltComp = compare(gt.semver, lt.semver, options), gtltComp > 0)
1122
+ return null;
1123
+ if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<="))
1124
+ return null;
1125
+ }
1126
+ for (let eq of eqSet) {
1127
+ if (gt && !satisfies(eq, String(gt), options) || lt && !satisfies(eq, String(lt), options))
1128
+ return null;
1129
+ for (let c of dom)
1130
+ if (!satisfies(eq, String(c), options))
1131
+ return !1;
1132
+ return !0;
1133
+ }
1134
+ let higher, lower, hasDomLT, hasDomGT, needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : !1, needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : !1;
1135
+ needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0 && (needDomLTPre = !1);
1136
+ for (let c of dom) {
1137
+ if (hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=", hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=", gt) {
1138
+ if (needDomGTPre && c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch && (needDomGTPre = !1), c.operator === ">" || c.operator === ">=") {
1139
+ if (higher = higherGT(gt, c, options), higher === c && higher !== gt)
1140
+ return !1;
1141
+ } else if (gt.operator === ">=" && !c.test(gt.semver))
1142
+ return !1;
1143
+ }
1144
+ if (lt) {
1145
+ if (needDomLTPre && c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch && (needDomLTPre = !1), c.operator === "<" || c.operator === "<=") {
1146
+ if (lower = lowerLT(lt, c, options), lower === c && lower !== lt)
1147
+ return !1;
1148
+ } else if (lt.operator === "<=" && !c.test(lt.semver))
1149
+ return !1;
1150
+ }
1151
+ if (!c.operator && (lt || gt) && gtltComp !== 0)
1152
+ return !1;
1153
+ }
1154
+ return !(gt && hasDomLT && !lt && gtltComp !== 0 || lt && hasDomGT && !gt && gtltComp !== 0 || needDomGTPre || needDomLTPre);
1155
+ }, higherGT = (a, b, options) => {
1156
+ if (!a)
1157
+ return b;
1158
+ let comp = compare(a.semver, b.semver, options);
1159
+ return comp > 0 ? a : comp < 0 || b.operator === ">" && a.operator === ">=" ? b : a;
1160
+ }, lowerLT = (a, b, options) => {
1161
+ if (!a)
1162
+ return b;
1163
+ let comp = compare(a.semver, b.semver, options);
1164
+ return comp < 0 ? a : comp > 0 || b.operator === "<" && a.operator === "<=" ? b : a;
1165
+ };
1166
+ module.exports = subset;
1167
+ }
1168
+ });
1169
+
1170
+ // ../../../node_modules/semver/index.js
1171
+ var require_semver2 = __commonJS({
1172
+ "../../../node_modules/semver/index.js"(exports, module) {
1173
+ "use strict";
1174
+ var internalRe = require_re(), constants2 = require_constants(), SemVer = require_semver(), identifiers = require_identifiers(), parse4 = require_parse(), valid = require_valid(), clean = require_clean(), inc = require_inc(), diff = require_diff(), major = require_major(), minor = require_minor(), patch = require_patch(), prerelease = require_prerelease(), compare = require_compare(), rcompare = require_rcompare(), compareLoose = require_compare_loose(), compareBuild = require_compare_build(), sort = require_sort(), rsort = require_rsort(), gt = require_gt(), lt = require_lt(), eq = require_eq(), neq = require_neq(), gte = require_gte(), lte = require_lte(), cmp = require_cmp(), coerce = require_coerce(), truncate = require_truncate(), Comparator = require_comparator(), Range = require_range(), satisfies = require_satisfies(), toComparators = require_to_comparators(), maxSatisfying = require_max_satisfying(), minSatisfying = require_min_satisfying(), minVersion = require_min_version(), validRange = require_valid2(), outside = require_outside(), gtr = require_gtr(), ltr = require_ltr(), intersects = require_intersects(), simplifyRange = require_simplify(), subset = require_subset();
1175
+ module.exports = {
1176
+ parse: parse4,
1177
+ valid,
1178
+ clean,
1179
+ inc,
1180
+ diff,
1181
+ major,
1182
+ minor,
1183
+ patch,
1184
+ prerelease,
1185
+ compare,
1186
+ rcompare,
1187
+ compareLoose,
1188
+ compareBuild,
1189
+ sort,
1190
+ rsort,
1191
+ gt,
1192
+ lt,
1193
+ eq,
1194
+ neq,
1195
+ gte,
1196
+ lte,
1197
+ cmp,
1198
+ coerce,
1199
+ truncate,
1200
+ Comparator,
1201
+ Range,
1202
+ satisfies,
1203
+ toComparators,
1204
+ maxSatisfying,
1205
+ minSatisfying,
1206
+ minVersion,
1207
+ validRange,
1208
+ outside,
1209
+ gtr,
1210
+ ltr,
1211
+ intersects,
1212
+ simplifyRange,
1213
+ subset,
1214
+ SemVer,
1215
+ re: internalRe.re,
1216
+ src: internalRe.src,
1217
+ tokens: internalRe.t,
1218
+ SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
1219
+ RELEASE_TYPES: constants2.RELEASE_TYPES,
1220
+ compareIdentifiers: identifiers.compareIdentifiers,
1221
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
1222
+ };
1223
+ }
1224
+ });
1225
+
1226
+ // src/preset.ts
1227
+ import { findConfigFile } from "storybook/internal/common";
1228
+
1229
+ // src/plugins/storybook-config-plugin.ts
1230
+ import { isPreservingSymlinks } from "storybook/internal/common";
1231
+ function storybookConfigPlugin(options) {
1232
+ return [
1233
+ {
1234
+ name: "storybook:config-plugin",
1235
+ enforce: "pre",
1236
+ async config(config) {
1237
+ let { defaultClientConditions = [] } = await import("vite"), existingEnvPrefix = config.envPrefix, mergedEnvPrefix = existingEnvPrefix ? Array.from(
1238
+ /* @__PURE__ */ new Set([
1239
+ ...Array.isArray(existingEnvPrefix) ? existingEnvPrefix : [existingEnvPrefix],
1240
+ "STORYBOOK_"
1241
+ ])
1242
+ ) : ["VITE_", "STORYBOOK_"];
1243
+ return {
1244
+ resolve: {
1245
+ conditions: ["storybook", "stories", "test", ...defaultClientConditions],
1246
+ preserveSymlinks: isPreservingSymlinks()
1247
+ },
1248
+ envPrefix: mergedEnvPrefix
1249
+ };
1250
+ }
1251
+ },
1252
+ {
1253
+ name: "storybook:allow-storybook-dir",
1254
+ enforce: "post",
1255
+ config(config) {
1256
+ config?.server?.fs?.allow && config.server.fs.allow.push(options.configDir);
1257
+ }
1258
+ }
1259
+ ];
1260
+ }
1261
+
1262
+ // src/plugins/storybook-optimize-deps-plugin.ts
1263
+ import { loadPreviewOrConfigFile } from "storybook/internal/common";
1264
+ import { babelParser, extractMockCalls, findMockRedirect } from "storybook/internal/mocking-utils";
1265
+
1266
+ // node_modules/pathe/dist/shared/pathe.ff20891b.mjs
1267
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
1268
+ function normalizeWindowsPath(input = "") {
1269
+ return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
1270
+ }
1271
+ var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
1272
+ var normalize = function(path3) {
1273
+ if (path3.length === 0)
1274
+ return ".";
1275
+ path3 = normalizeWindowsPath(path3);
1276
+ let isUNCPath = path3.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path3), trailingSeparator = path3[path3.length - 1] === "/";
1277
+ return path3 = normalizeString(path3, !isPathAbsolute), path3.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path3 += "/"), _DRIVE_LETTER_RE.test(path3) && (path3 += "/"), isUNCPath ? isPathAbsolute ? `//${path3}` : `//./${path3}` : isPathAbsolute && !isAbsolute(path3) ? `/${path3}` : path3);
1278
+ }, join = function(...arguments_) {
1279
+ if (arguments_.length === 0)
1280
+ return ".";
1281
+ let joined;
1282
+ for (let argument of arguments_)
1283
+ argument && argument.length > 0 && (joined === void 0 ? joined = argument : joined += `/${argument}`);
1284
+ return joined === void 0 ? "." : normalize(joined.replace(/\/\/+/g, "/"));
1285
+ };
1286
+ function cwd() {
1287
+ return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
1288
+ }
1289
+ var resolve = function(...arguments_) {
1290
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
1291
+ let resolvedPath = "", resolvedAbsolute = !1;
1292
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
1293
+ let path3 = index >= 0 ? arguments_[index] : cwd();
1294
+ !path3 || path3.length === 0 || (resolvedPath = `${path3}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path3));
1295
+ }
1296
+ return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
1297
+ };
1298
+ function normalizeString(path3, allowAboveRoot) {
1299
+ let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
1300
+ for (let index = 0; index <= path3.length; ++index) {
1301
+ if (index < path3.length)
1302
+ char = path3[index];
1303
+ else {
1304
+ if (char === "/")
1305
+ break;
1306
+ char = "/";
1307
+ }
1308
+ if (char === "/") {
1309
+ if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
1310
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
1311
+ if (res.length > 2) {
1312
+ let lastSlashIndex = res.lastIndexOf("/");
1313
+ lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
1314
+ continue;
1315
+ } else if (res.length > 0) {
1316
+ res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
1317
+ continue;
1318
+ }
1319
+ }
1320
+ allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
1321
+ } else
1322
+ res.length > 0 ? res += `/${path3.slice(lastSlash + 1, index)}` : res = path3.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
1323
+ lastSlash = index, dots = 0;
1324
+ } else char === "." && dots !== -1 ? ++dots : dots = -1;
1325
+ }
1326
+ return res;
1327
+ }
1328
+ var isAbsolute = function(p) {
1329
+ return _IS_ABSOLUTE_RE.test(p);
1330
+ };
1331
+ var relative = function(from, to) {
1332
+ let _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
1333
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
1334
+ return _to.join("/");
1335
+ let _fromCopy = [..._from];
1336
+ for (let segment of _fromCopy) {
1337
+ if (_to[0] !== segment)
1338
+ break;
1339
+ _from.shift(), _to.shift();
1340
+ }
1341
+ return [..._from.map(() => ".."), ..._to].join("/");
1342
+ };
1343
+
1344
+ // src/utils/process-preview-annotation.ts
1345
+ function processPreviewAnnotation(path3, projectRoot) {
1346
+ return typeof path3 == "object" ? path3.bare != null && path3.absolute === "" ? path3.bare : normalize(path3.absolute) : isAbsolute(path3) ? normalize(path3) : normalize(resolve(projectRoot, path3));
1347
+ }
1348
+
1349
+ // src/utils/unique-import-paths.ts
1350
+ function getUniqueImportPaths(index) {
1351
+ return [...new Set(Object.values(index.entries).map((entry) => entry.importPath))];
1352
+ }
1353
+
1354
+ // src/plugins/storybook-optimize-deps-plugin.ts
1355
+ function escapeGlobPath(filePath) {
1356
+ return filePath.replace(/[()[\]{}!*?|+@]/g, "\\$&");
1357
+ }
1358
+ function getMockRedirectIncludeEntries(mockCalls) {
1359
+ return Array.from(
1360
+ new Set(
1361
+ mockCalls.map((mockCall) => mockCall.redirectPath).filter((redirectPath) => redirectPath !== null).map(escapeGlobPath)
1362
+ )
1363
+ );
1364
+ }
1365
+ function storybookOptimizeDepsPlugin(options) {
1366
+ return {
1367
+ name: "storybook:optimize-deps-plugin",
1368
+ async config(config, { command }) {
1369
+ if (command !== "serve")
1370
+ return;
1371
+ let projectRoot = resolve(options.configDir, ".."), [extraOptimizeDeps, storyIndexGenerator, previewAnnotations] = await Promise.all([
1372
+ options.presets.apply("optimizeViteDeps", []),
1373
+ options.presets.apply("storyIndexGenerator"),
1374
+ options.presets.apply("previewAnnotations", [], options)
1375
+ ]), index = await storyIndexGenerator.getIndex(), previewOrConfigFile = loadPreviewOrConfigFile({ configDir: options.configDir }), mockRedirectIncludeEntries = previewOrConfigFile ? getMockRedirectIncludeEntries(
1376
+ extractMockCalls(
1377
+ {
1378
+ previewConfigPath: previewOrConfigFile,
1379
+ coreOptions: { disableTelemetry: !0 },
1380
+ configDir: options.configDir
1381
+ },
1382
+ babelParser,
1383
+ projectRoot,
1384
+ findMockRedirect
1385
+ )
1386
+ ) : [], previewAnnotationEntries = [...previewAnnotations, previewOrConfigFile].filter((path3) => path3 !== void 0).map((path3) => processPreviewAnnotation(path3, projectRoot));
1387
+ return {
1388
+ optimizeDeps: {
1389
+ // Story files + preview annotation files as entry points for the dep optimizer.
1390
+ // Vite will crawl these to discover all transitive CJS dependencies that need
1391
+ // pre-bundling, removing the need for a hard-coded include list.
1392
+ // Paths are escaped so that special glob characters (e.g. parentheses in Next.js route
1393
+ // group directories) are treated as literal characters, not glob syntax.
1394
+ entries: [
1395
+ ...typeof config.optimizeDeps?.entries == "string" ? [config.optimizeDeps.entries] : config.optimizeDeps?.entries ?? [],
1396
+ ...mockRedirectIncludeEntries,
1397
+ ...getUniqueImportPaths(index).map(escapeGlobPath),
1398
+ ...previewAnnotationEntries.map(escapeGlobPath)
1399
+ ],
1400
+ // Extra deps explicitly included by Storybook presets (e.g. framework-specific packages).
1401
+ include: [...extraOptimizeDeps, ...config.optimizeDeps?.include ?? []]
1402
+ }
1403
+ };
1404
+ }
1405
+ };
1406
+ }
1407
+
1408
+ // src/codegen-project-annotations.ts
1409
+ import { getFrameworkName, loadPreviewOrConfigFile as loadPreviewOrConfigFile2 } from "storybook/internal/common";
1410
+ import { isCsfFactoryPreview, readConfig } from "storybook/internal/csf-tools";
1411
+
1412
+ // ../../../node_modules/knitwork/dist/index.mjs
1413
+ function genString(input, options = {}) {
1414
+ let str = JSON.stringify(input);
1415
+ return options.singleQuotes ? `'${escapeString(str).slice(1, -1)}'` : str;
1416
+ }
1417
+ var NEEDS_ESCAPE_RE = /[\n\r'\\\u2028\u2029]/, QUOTE_NEWLINE_RE = /([\n\r'\u2028\u2029])/g, BACKSLASH_RE = /\\/g;
1418
+ function escapeString(id) {
1419
+ return NEEDS_ESCAPE_RE.test(id) ? id.replace(BACKSLASH_RE, "\\\\").replace(QUOTE_NEWLINE_RE, "\\$1") : id;
1420
+ }
1421
+ function genSafeVariableName(name) {
1422
+ return reservedNames.has(name) ? `_${name}` : name.replace(/^\d/, (r) => `_${r}`).replace(/\W/g, (r) => "_" + r.charCodeAt(0));
1423
+ }
1424
+ var reservedNames = /* @__PURE__ */ new Set([
1425
+ "Infinity",
1426
+ "NaN",
1427
+ "arguments",
1428
+ "await",
1429
+ "break",
1430
+ "case",
1431
+ "catch",
1432
+ "class",
1433
+ "const",
1434
+ "continue",
1435
+ "debugger",
1436
+ "default",
1437
+ "delete",
1438
+ "do",
1439
+ "else",
1440
+ "enum",
1441
+ "eval",
1442
+ "export",
1443
+ "extends",
1444
+ "false",
1445
+ "finally",
1446
+ "for",
1447
+ "function",
1448
+ "if",
1449
+ "implements",
1450
+ "import",
1451
+ "in",
1452
+ "instanceof",
1453
+ "interface",
1454
+ "let",
1455
+ "new",
1456
+ "null",
1457
+ "package",
1458
+ "private",
1459
+ "protected",
1460
+ "public",
1461
+ "return",
1462
+ "static",
1463
+ "super",
1464
+ "switch",
1465
+ "this",
1466
+ "throw",
1467
+ "true",
1468
+ "try",
1469
+ "typeof",
1470
+ "undefined",
1471
+ "var",
1472
+ "void",
1473
+ "while",
1474
+ "with",
1475
+ "yield"
1476
+ ]), VALID_IDENTIFIER_RE = /^[$_]?([A-Z_a-z]\w*|\d)$/;
1477
+ function _genStatement(type, specifier, names, options = {}) {
1478
+ let specifierString = genString(specifier, options);
1479
+ if (!names)
1480
+ return `${type} ${specifierString};`;
1481
+ let nameArray = Array.isArray(names), namesString = (nameArray ? names : [names]).map((index) => typeof index == "string" ? { name: index } : (index.name === index.as && (index = { name: index.name }), index)).map((index) => index.as ? `${index.name} as ${index.as}` : index.name).join(", ");
1482
+ return nameArray ? `${type} { ${namesString} } from ${genString(
1483
+ specifier,
1484
+ options
1485
+ )}${_genImportAttributes(type, options)};` : `${type} ${namesString} from ${genString(
1486
+ specifier,
1487
+ options
1488
+ )}${_genImportAttributes(type, options)};`;
1489
+ }
1490
+ function _genImportAttributes(type, options) {
1491
+ return type === "import type" || type === "export type" ? "" : typeof options.attributes?.type == "string" ? ` with { type: ${genString(options.attributes.type)} }` : typeof options.assert?.type == "string" ? ` assert { type: ${genString(options.assert.type)} }` : "";
1492
+ }
1493
+ function genImport(specifier, imports, options = {}) {
1494
+ return _genStatement("import", specifier, imports, options);
1495
+ }
1496
+ function genDynamicImport(specifier, options = {}) {
1497
+ let commentString = options.comment ? ` /* ${options.comment} */` : "", wrapperString = options.wrapper === !1 ? "" : "() => ", interopString = options.interopDefault ? ".then(m => m.default || m)" : "", optionsString = _genDynamicImportAttributes(options);
1498
+ return `${wrapperString}import(${genString(
1499
+ specifier,
1500
+ options
1501
+ )}${commentString}${optionsString})${interopString}`;
1502
+ }
1503
+ function _genDynamicImportAttributes(options = {}) {
1504
+ return typeof options.assert?.type == "string" ? `, { assert: { type: ${genString(options.assert.type)} } }` : typeof options.attributes?.type == "string" ? `, { with: { type: ${genString(options.attributes.type)} } }` : "";
1505
+ }
1506
+ function wrapInDelimiters(lines, indent = "", delimiters = "{}", withComma = !0) {
1507
+ if (lines.length === 0)
1508
+ return delimiters;
1509
+ let [start, end] = delimiters;
1510
+ return `${start}
1511
+ ` + lines.join(withComma ? `,
1512
+ ` : `
1513
+ `) + `
1514
+ ${indent}${end}`;
1515
+ }
1516
+ function genObjectKey(key) {
1517
+ return VALID_IDENTIFIER_RE.test(key) ? key : genString(key);
1518
+ }
1519
+ function genObjectFromRaw(object, indent = "", options = {}) {
1520
+ return genObjectFromRawEntries(Object.entries(object), indent, options);
1521
+ }
1522
+ function genArrayFromRaw(array, indent = "", options = {}) {
1523
+ let newIdent = indent + " ";
1524
+ return wrapInDelimiters(
1525
+ array.map((index) => `${newIdent}${genRawValue(index, newIdent, options)}`),
1526
+ indent,
1527
+ "[]"
1528
+ );
1529
+ }
1530
+ function genObjectFromRawEntries(array, indent = "", options = {}) {
1531
+ let newIdent = indent + " ";
1532
+ return wrapInDelimiters(
1533
+ array.map(
1534
+ ([key, value]) => `${newIdent}${genObjectKey(key)}: ${genRawValue(value, newIdent, options)}`
1535
+ ),
1536
+ indent,
1537
+ "{}"
1538
+ );
1539
+ }
1540
+ function genRawValue(value, indent = "", options = {}) {
1541
+ return value === void 0 ? "undefined" : value === null ? "null" : Array.isArray(value) ? genArrayFromRaw(value, indent, options) : value && typeof value == "object" ? genObjectFromRaw(value, indent, options) : options.preserveTypes && typeof value != "function" ? JSON.stringify(value) : value.toString();
1542
+ }
1543
+
1544
+ // node_modules/pathe/dist/utils.mjs
1545
+ var FILENAME_RE = /(^|[/\\])([^/\\]+?)(?=(\.[^.]+)?$)/;
1546
+ function filename(path3) {
1547
+ return path3.match(FILENAME_RE)?.[2];
1548
+ }
1549
+
1550
+ // src/codegen-project-annotations.ts
1551
+ import { dedent } from "ts-dedent";
1552
+ async function generateProjectAnnotationsCode(options, projectRoot) {
1553
+ let { presets, configDir } = options, frameworkName = await getFrameworkName(options), previewOrConfigFile = loadPreviewOrConfigFile2({ configDir }), previewConfig = previewOrConfigFile ? await readConfig(previewOrConfigFile) : void 0, isCsf4 = previewConfig ? isCsfFactoryPreview(previewConfig) : !1, previewAnnotations = await presets.apply(
1554
+ "previewAnnotations",
1555
+ [],
1556
+ options
1557
+ );
1558
+ return generateProjectAnnotationsCodeFromPreviews({
1559
+ previewAnnotations: [...previewAnnotations, previewOrConfigFile],
1560
+ projectRoot,
1561
+ frameworkName,
1562
+ isCsf4
1563
+ });
1564
+ }
1565
+ function generateProjectAnnotationsCodeFromPreviews(options) {
1566
+ let { projectRoot } = options, previewAnnotationURLs = options.previewAnnotations.filter((path3) => path3 !== void 0).map((path3) => processPreviewAnnotation(path3, projectRoot)), variables = [], imports = [];
1567
+ for (let previewAnnotation of previewAnnotationURLs) {
1568
+ let variable = genSafeVariableName(filename(previewAnnotation)).replace(/_(45|46|47)/g, "_") + "_" + hash(previewAnnotation);
1569
+ variables.push(variable), imports.push(genImport(previewAnnotation, { name: "*", as: variable }));
1570
+ }
1571
+ let previewFileURL = previewAnnotationURLs[previewAnnotationURLs.length - 1], previewFileVariable = variables[variables.length - 1], previewFileImport = imports[imports.length - 1];
1572
+ return options.isCsf4 ? dedent`
1573
+ ${previewFileImport}
1574
+
1575
+ export function getProjectAnnotations(hmrPreviewAnnotationModules = []) {
1576
+ const preview = hmrPreviewAnnotationModules[0] ?? ${previewFileVariable};
1577
+ return preview.default.composed;
1578
+ }
1579
+
1580
+ if (import.meta.hot) {
1581
+ import.meta.hot.accept([${JSON.stringify(previewFileURL)}], (previewAnnotationModules) => {
1582
+ // getProjectAnnotations has changed so we need to patch the new one in
1583
+ window?.__STORYBOOK_PREVIEW__?.onGetProjectAnnotationsChanged({
1584
+ getProjectAnnotations: () => getProjectAnnotations(previewAnnotationModules),
1585
+ });
1586
+ });
1587
+ }
1588
+ `.trim() : dedent`
1589
+ import { composeConfigs } from 'storybook/preview-api';
1590
+
1591
+ ${imports.join(`
1592
+ `)}
1593
+
1594
+ export function getProjectAnnotations(hmrPreviewAnnotationModules = []) {
1595
+ const configs = ${genArrayFromRaw(
1596
+ variables.map(
1597
+ (previewAnnotation, index) => (
1598
+ // Prefer the updated module from an HMR update, otherwise the original module
1599
+ `hmrPreviewAnnotationModules[${index}] ?? ${previewAnnotation}`
1600
+ )
1601
+ ),
1602
+ " "
1603
+ )};
1604
+ return composeConfigs(configs);
1605
+ }
1606
+
1607
+ if (import.meta.hot) {
1608
+ import.meta.hot.accept(${JSON.stringify(previewAnnotationURLs)}, (previewAnnotationModules) => {
1609
+ // getProjectAnnotations has changed so we need to patch the new one in
1610
+ window?.__STORYBOOK_PREVIEW__?.onGetProjectAnnotationsChanged({
1611
+ getProjectAnnotations: () => getProjectAnnotations(previewAnnotationModules),
1612
+ });
1613
+ });
1614
+ }
1615
+ `.trim();
1616
+ }
1617
+ function hash(value) {
1618
+ let acc = 5381;
1619
+ for (let i = 0; i < value.length; i++)
1620
+ acc = (acc << 5) + acc + value.charCodeAt(i) >>> 0;
1621
+ return acc;
1622
+ }
1623
+
1624
+ // src/virtual-file-names.ts
1625
+ var SB_VIRTUAL_FILES = {
1626
+ VIRTUAL_APP_FILE: "virtual:/@storybook/builder-vite/vite-app.js",
1627
+ VIRTUAL_STORIES_FILE: "virtual:/@storybook/builder-vite/storybook-stories.js",
1628
+ VIRTUAL_ADDON_SETUP_FILE: "virtual:/@storybook/builder-vite/setup-addons.js"
1629
+ }, SB_VIRTUAL_FILE_IDS = Object.values(SB_VIRTUAL_FILES);
1630
+ function getResolvedVirtualModuleId(virtualModuleId) {
1631
+ return `\0${virtualModuleId}`;
1632
+ }
1633
+ function getOriginalVirtualModuleId(resolvedVirtualModuleId) {
1634
+ return resolvedVirtualModuleId.slice(1);
1635
+ }
1636
+
1637
+ // src/plugins/storybook-project-annotations-plugin.ts
1638
+ var VIRTUAL_ID = "virtual:/@storybook/builder-vite/project-annotations.js", RESOLVED_VIRTUAL_ID = getResolvedVirtualModuleId(VIRTUAL_ID);
1639
+ function storybookProjectAnnotationsPlugin(options) {
1640
+ let projectRoot;
1641
+ return {
1642
+ name: "storybook:project-annotations-plugin",
1643
+ enforce: "pre",
1644
+ configResolved(config) {
1645
+ projectRoot = config.root;
1646
+ },
1647
+ resolveId(source) {
1648
+ if (source === VIRTUAL_ID)
1649
+ return RESOLVED_VIRTUAL_ID;
1650
+ },
1651
+ async load(id) {
1652
+ if (id === RESOLVED_VIRTUAL_ID)
1653
+ return generateProjectAnnotationsCode(options, projectRoot);
1654
+ }
1655
+ };
1656
+ }
1657
+
1658
+ // src/envs.ts
1659
+ import { stringifyEnvs } from "storybook/internal/common";
1660
+ var allowedEnvVariables = [
1661
+ "STORYBOOK",
1662
+ // Vite `import.meta.env` default variables
1663
+ // @see https://github.com/vitejs/vite/blob/6b8d94dca2a1a8b4952e3e3fcd0aed1aedb94215/packages/vite/types/importMeta.d.ts#L68-L75
1664
+ "BASE_URL",
1665
+ "MODE",
1666
+ "DEV",
1667
+ "PROD",
1668
+ "SSR"
1669
+ ];
1670
+ function stringifyProcessEnvs(raw, envPrefix) {
1671
+ let updatedRaw = {}, envs = Object.entries(raw).reduce((acc, [key, value]) => ((allowedEnvVariables.includes(key) || Array.isArray(envPrefix) && envPrefix.find((prefix) => key.startsWith(prefix)) || typeof envPrefix == "string" && key.startsWith(envPrefix)) && (acc[`import.meta.env.${key}`] = JSON.stringify(value), updatedRaw[key] = value), acc), {});
1672
+ return envs["import.meta.env"] = JSON.stringify(stringifyEnvs(updatedRaw)), envs;
1673
+ }
1674
+
1675
+ // src/plugins/storybook-runtime-plugin.ts
1676
+ async function storybookSanitizeEnvs(options) {
1677
+ let plugins = [], envs = await options.presets.apply("env");
1678
+ return envs && Object.keys(envs).length > 0 && plugins.push({
1679
+ name: "storybook:env-plugin",
1680
+ config(config) {
1681
+ return {
1682
+ define: stringifyProcessEnvs(envs, config.envPrefix)
1683
+ };
1684
+ }
1685
+ }), plugins;
1686
+ }
1687
+
1688
+ // src/plugins/vite-inject-mocker/plugin.ts
1689
+ import { fileURLToPath } from "node:url";
1690
+ var ENTRY_PATH = "/vite-inject-mocker-entry.js", viteInjectMockerRuntime = (options) => {
1691
+ let mockerRuntimePath = fileURLToPath(
1692
+ import.meta.resolve("storybook/internal/mocking-utils/mocker-runtime")
1693
+ ), viteConfig;
1694
+ return {
1695
+ name: "vite:storybook-inject-mocker-runtime",
1696
+ enforce: "pre",
1697
+ buildStart() {
1698
+ viteConfig.command === "build" && this.emitFile({
1699
+ type: "chunk",
1700
+ id: mockerRuntimePath,
1701
+ fileName: ENTRY_PATH.slice(1)
1702
+ });
1703
+ },
1704
+ configResolved(config) {
1705
+ viteConfig = config;
1706
+ },
1707
+ configureServer(server) {
1708
+ options.previewConfigPath && server.watcher.on("change", (file) => {
1709
+ file === options.previewConfigPath && server.ws.send({
1710
+ type: "custom",
1711
+ event: "invalidate-mocker"
1712
+ });
1713
+ });
1714
+ },
1715
+ resolveId: {
1716
+ filter: { id: /\/vite-inject-mocker-entry\.js/ },
1717
+ handler(source) {
1718
+ if (source === ENTRY_PATH)
1719
+ return mockerRuntimePath;
1720
+ }
1721
+ },
1722
+ transformIndexHtml(html) {
1723
+ let headTag = html.match(/<head[^>]*>/);
1724
+ if (headTag) {
1725
+ let entryCode = `<script type="module" src="${viteConfig.command === "build" ? `.${ENTRY_PATH}` : ENTRY_PATH}"></script>`, headTagIndex = html.indexOf(headTag[0]);
1726
+ return html.slice(0, headTagIndex + headTag[0].length) + entryCode + html.slice(headTagIndex + headTag[0].length);
1727
+ }
1728
+ }
1729
+ };
1730
+ };
1731
+
1732
+ // src/plugins/vite-mock/plugin.ts
1733
+ import { readFileSync } from "node:fs";
1734
+ import {
1735
+ babelParser as babelParser2,
1736
+ extractMockCalls as extractMockCalls2,
1737
+ findMockRedirect as findMockRedirect2,
1738
+ getAutomockCode,
1739
+ getRealPath,
1740
+ rewriteSbMockImportCalls
1741
+ } from "storybook/internal/mocking-utils";
1742
+ import { logger } from "storybook/internal/node-logger";
1743
+
1744
+ // src/plugins/vite-mock/utils.ts
1745
+ function getCleanId(id) {
1746
+ return id.replace(/^.*\/deps\//, "").replace(/\.js.*$/, "").replace(/_/g, "/");
1747
+ }
1748
+ function invalidateAllRelatedModules(server, absPath, pkgName) {
1749
+ for (let mod of server.moduleGraph.idToModuleMap.values())
1750
+ (mod.id === absPath || mod.id && getCleanId(mod.id) === pkgName) && server.moduleGraph.invalidateModule(mod);
1751
+ }
1752
+
1753
+ // src/plugins/vite-mock/plugin.ts
1754
+ function viteMockPlugin(options) {
1755
+ let viteConfig, mockCalls = [], normalizedPreviewConfigPath = normalize(options.previewConfigPath);
1756
+ return [
1757
+ {
1758
+ name: "storybook:mock-loader",
1759
+ configResolved(config) {
1760
+ viteConfig = config;
1761
+ },
1762
+ buildStart() {
1763
+ mockCalls = extractMockCalls2(options, babelParser2, viteConfig.root, findMockRedirect2);
1764
+ },
1765
+ configureServer(server) {
1766
+ async function invalidateAffectedFiles(file) {
1767
+ if (file === options.previewConfigPath || file.includes("__mocks__")) {
1768
+ let oldMockCalls = mockCalls;
1769
+ mockCalls = extractMockCalls2(options, babelParser2, viteConfig.root, findMockRedirect2);
1770
+ let previewMod = server.moduleGraph.getModuleById(options.previewConfigPath);
1771
+ previewMod && server.moduleGraph.invalidateModule(previewMod);
1772
+ for (let call of mockCalls)
1773
+ invalidateAllRelatedModules(server, call.absolutePath, call.path);
1774
+ let newAbsPaths = new Set(mockCalls.map((c) => c.absolutePath));
1775
+ for (let oldCall of oldMockCalls)
1776
+ newAbsPaths.has(oldCall.absolutePath) || invalidateAllRelatedModules(server, oldCall.absolutePath, oldCall.path);
1777
+ return server.ws.send({ type: "full-reload" }), [];
1778
+ }
1779
+ }
1780
+ server.watcher.on("change", invalidateAffectedFiles), server.watcher.on("add", invalidateAffectedFiles), server.watcher.on("unlink", invalidateAffectedFiles);
1781
+ },
1782
+ load: {
1783
+ order: "pre",
1784
+ handler(id) {
1785
+ let preserveSymlinks = viteConfig.resolve.preserveSymlinks, idNorm = getRealPath(id, preserveSymlinks), cleanId = getCleanId(idNorm);
1786
+ for (let call of mockCalls)
1787
+ if (!(getRealPath(call.absolutePath, preserveSymlinks) !== idNorm && call.path !== cleanId) && call.redirectPath)
1788
+ return this.addWatchFile(call.redirectPath), readFileSync(call.redirectPath, "utf-8");
1789
+ return null;
1790
+ }
1791
+ },
1792
+ transform: {
1793
+ order: "pre",
1794
+ handler(code, id) {
1795
+ for (let call of mockCalls) {
1796
+ let preserveSymlinks = viteConfig.resolve.preserveSymlinks, idNorm = getRealPath(id, preserveSymlinks), callNorm = getRealPath(call.absolutePath, preserveSymlinks);
1797
+ if (viteConfig.command !== "serve") {
1798
+ if (callNorm !== idNorm)
1799
+ continue;
1800
+ } else {
1801
+ let cleanId = getCleanId(idNorm);
1802
+ if (call.path !== cleanId && callNorm !== idNorm)
1803
+ continue;
1804
+ }
1805
+ try {
1806
+ if (!call.redirectPath) {
1807
+ let automockedCode = getAutomockCode(code, call.spy, babelParser2);
1808
+ return {
1809
+ code: automockedCode.toString(),
1810
+ map: automockedCode.generateMap().toString()
1811
+ };
1812
+ }
1813
+ } catch (e) {
1814
+ return logger.error(`Error automocking ${id}: ${e}`), null;
1815
+ }
1816
+ }
1817
+ return null;
1818
+ }
1819
+ }
1820
+ },
1821
+ {
1822
+ name: "storybook:mock-loader-preview",
1823
+ transform: {
1824
+ filter: { id: normalizedPreviewConfigPath },
1825
+ handler(code, id) {
1826
+ if (id === normalizedPreviewConfigPath)
1827
+ try {
1828
+ return rewriteSbMockImportCalls(code);
1829
+ } catch (e) {
1830
+ return logger.debug(`Could not transform sb.mock(import(...)) calls in ${id}: ${e}`), null;
1831
+ }
1832
+ return null;
1833
+ }
1834
+ }
1835
+ }
1836
+ ];
1837
+ }
1838
+
1839
+ // src/vite-config.ts
1840
+ import { existsSync as existsSync4 } from "node:fs";
1841
+ import { resolve as resolve4 } from "node:path";
1842
+ import { getBuilderOptions, resolvePathInStorybookCache } from "storybook/internal/common";
1843
+
1844
+ // src/plugins/code-generator-plugin.ts
1845
+ import { readFileSync as readFileSync2 } from "node:fs";
1846
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
1847
+
1848
+ // ../../core/src/shared/utils/module.ts
1849
+ import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
1850
+
1851
+ // ../../../node_modules/exsolve/dist/index.mjs
1852
+ import assert from "node:assert";
1853
+ import v8 from "node:v8";
1854
+ import { format as format2, inspect } from "node:util";
1855
+ var own$1 = {}.hasOwnProperty, classRegExp = /^([A-Z][a-z\d]*)+$/, kTypes = /* @__PURE__ */ new Set([
1856
+ "string",
1857
+ "function",
1858
+ "number",
1859
+ "object",
1860
+ "Function",
1861
+ "Object",
1862
+ "boolean",
1863
+ "bigint",
1864
+ "symbol"
1865
+ ]), messages = /* @__PURE__ */ new Map(), nodeInternalPrefix = "__node_internal_", userStackTraceLimit;
1866
+ function formatList(array, type = "and") {
1867
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
1868
+ }
1869
+ function createError(sym, value, constructor) {
1870
+ return messages.set(sym, value), makeNodeErrorWithCode(constructor, sym);
1871
+ }
1872
+ function makeNodeErrorWithCode(Base, key) {
1873
+ return function(...parameters) {
1874
+ let limit = Error.stackTraceLimit;
1875
+ isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = 0);
1876
+ let error = new Base();
1877
+ isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = limit);
1878
+ let message = getMessage(key, parameters, error);
1879
+ return Object.defineProperties(error, {
1880
+ message: {
1881
+ value: message,
1882
+ enumerable: !1,
1883
+ writable: !0,
1884
+ configurable: !0
1885
+ },
1886
+ toString: {
1887
+ value() {
1888
+ return `${this.name} [${key}]: ${this.message}`;
1889
+ },
1890
+ enumerable: !1,
1891
+ writable: !0,
1892
+ configurable: !0
1893
+ }
1894
+ }), captureLargerStackTrace(error), error.code = key, error;
1895
+ };
1896
+ }
1897
+ function isErrorStackTraceLimitWritable() {
1898
+ try {
1899
+ if (v8.startupSnapshot.isBuildingSnapshot()) return !1;
1900
+ } catch {
1901
+ }
1902
+ let desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
1903
+ return desc === void 0 ? Object.isExtensible(Error) : own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
1904
+ }
1905
+ function hideStackFrames(wrappedFunction) {
1906
+ let hidden = nodeInternalPrefix + wrappedFunction.name;
1907
+ return Object.defineProperty(wrappedFunction, "name", { value: hidden }), wrappedFunction;
1908
+ }
1909
+ var captureLargerStackTrace = hideStackFrames(function(error) {
1910
+ let stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
1911
+ return stackTraceLimitIsWritable && (userStackTraceLimit = Error.stackTraceLimit, Error.stackTraceLimit = Number.POSITIVE_INFINITY), Error.captureStackTrace(error), stackTraceLimitIsWritable && (Error.stackTraceLimit = userStackTraceLimit), error;
1912
+ });
1913
+ function getMessage(key, parameters, self) {
1914
+ let message = messages.get(key);
1915
+ if (assert.ok(message !== void 0, "expected `message` to be found"), typeof message == "function")
1916
+ 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);
1917
+ let regex = /%[dfijoOs]/g, expectedLength = 0;
1918
+ for (; regex.exec(message) !== null; ) expectedLength++;
1919
+ 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(format2, null, parameters));
1920
+ }
1921
+ function determineSpecificType(value) {
1922
+ if (value == null) return String(value);
1923
+ if (typeof value == "function" && value.name) return `function ${value.name}`;
1924
+ if (typeof value == "object")
1925
+ return value.constructor && value.constructor.name ? `an instance of ${value.constructor.name}` : `${inspect(value, { depth: -1 })}`;
1926
+ let inspected = inspect(value, { colors: !1 });
1927
+ return inspected.length > 28 && (inspected = `${inspected.slice(0, 25)}...`), `type ${typeof value} (${inspected})`;
1928
+ }
1929
+ var ERR_INVALID_ARG_TYPE = createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
1930
+ assert.ok(typeof name == "string", "'name' must be a string"), Array.isArray(expected) || (expected = [expected]);
1931
+ let message = "The ";
1932
+ if (name.endsWith(" argument")) message += `${name} `;
1933
+ else {
1934
+ let type = name.includes(".") ? "property" : "argument";
1935
+ message += `"${name}" ${type} `;
1936
+ }
1937
+ message += "must be ";
1938
+ let types = [], instances = [], other = [];
1939
+ for (let value of expected)
1940
+ 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);
1941
+ if (instances.length > 0) {
1942
+ let pos = types.indexOf("object");
1943
+ pos !== -1 && (types.slice(pos, 1), instances.push("Object"));
1944
+ }
1945
+ 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;
1946
+ }, TypeError), ERR_INVALID_MODULE_SPECIFIER = createError(
1947
+ "ERR_INVALID_MODULE_SPECIFIER",
1948
+ /**
1949
+ * @param {string} request
1950
+ * @param {string} reason
1951
+ * @param {string} [base]
1952
+ */
1953
+ (request, reason, base) => `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`,
1954
+ TypeError
1955
+ ), 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) => {
1956
+ let relatedError = typeof target == "string" && !isImport && target.length > 0 && !target.startsWith("./");
1957
+ 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 "./"' : ""}`;
1958
+ }, 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(
1959
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
1960
+ /**
1961
+ * @param {string} packagePath
1962
+ * @param {string} subpath
1963
+ * @param {string} [base]
1964
+ */
1965
+ (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}` : ""}`,
1966
+ Error
1967
+ ), 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") => {
1968
+ let inspected = inspect(value);
1969
+ return inspected.length > 128 && (inspected = `${inspected.slice(0, 128)}...`), `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
1970
+ }, TypeError), hasOwnProperty$1 = {}.hasOwnProperty;
1971
+ var hasOwnProperty = {}.hasOwnProperty;
1972
+ var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.hasOwnProperty;
1973
+ var isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
1974
+
1975
+ // ../../core/src/shared/utils/module.ts
1976
+ var import_semver = __toESM(require_semver2(), 1);
1977
+ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
1978
+ "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"
1979
+ ), pathToFileURL(args[0]).href) : import.meta.resolve(...args);
1980
+
1981
+ // src/codegen-importfn-script.ts
1982
+ import { dedent as dedent2 } from "ts-dedent";
1983
+ function generateImportFnScriptCode(index) {
1984
+ let objectEntries = getUniqueImportPaths(index).map(
1985
+ (importPath) => {
1986
+ if (importPath.startsWith("virtual:"))
1987
+ return [importPath, genDynamicImport(importPath)];
1988
+ let relativePath = normalize(relative(process.cwd(), importPath)), normalizedRelativePath = relativePath.startsWith("../") ? relativePath : `./${relativePath}`, absolutePath = normalize(join(process.cwd(), importPath));
1989
+ return [normalizedRelativePath, genDynamicImport(absolutePath)];
1990
+ }
1991
+ );
1992
+ return dedent2`
1993
+ const importers = ${genObjectFromRawEntries(objectEntries)};
1994
+
1995
+ export async function importFn(path) {
1996
+ return await importers[path]();
1997
+ }
1998
+ `;
1999
+ }
2000
+
2001
+ // src/codegen-modern-iframe-script.ts
2002
+ import { getFrameworkName as getFrameworkName2 } from "storybook/internal/common";
2003
+ import { STORY_HOT_UPDATED } from "storybook/internal/core-events";
2004
+ import { dedent as dedent3 } from "ts-dedent";
2005
+ async function generateModernIframeScriptCode(options) {
2006
+ let frameworkName = await getFrameworkName2(options);
2007
+ return generateModernIframeScriptCodeFromPreviews({
2008
+ frameworkName
2009
+ });
2010
+ }
2011
+ async function generateModernIframeScriptCodeFromPreviews(options) {
2012
+ let { frameworkName } = options, generateHMRHandler = () => frameworkName === "@storybook/web-components-vite" ? dedent3`
2013
+ if (import.meta.hot) {
2014
+ import.meta.hot.decline();
2015
+ }`.trim() : dedent3`
2016
+ if (import.meta.hot) {
2017
+ import.meta.hot.on('vite:afterUpdate', () => {
2018
+ window.__STORYBOOK_PREVIEW__.channel.emit('${STORY_HOT_UPDATED}');
2019
+ });
2020
+
2021
+ import.meta.hot.accept('${SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE}', (newModule) => {
2022
+ // importFn has changed so we need to patch the new one in
2023
+ window.__STORYBOOK_PREVIEW__.onStoriesChanged({ importFn: newModule.importFn });
2024
+ });
2025
+ }`.trim();
2026
+ return dedent3`
2027
+ import { setup } from 'storybook/internal/preview/runtime';
2028
+
2029
+ import '${SB_VIRTUAL_FILES.VIRTUAL_ADDON_SETUP_FILE}';
2030
+
2031
+ setup();
2032
+
2033
+ import { PreviewWeb } from 'storybook/preview-api';
2034
+ import { importFn } from '${SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE}';
2035
+ import { getProjectAnnotations } from '${VIRTUAL_ID}';
2036
+
2037
+ window.__STORYBOOK_PREVIEW__ = window.__STORYBOOK_PREVIEW__ || new PreviewWeb(importFn, getProjectAnnotations);
2038
+
2039
+ window.__STORYBOOK_STORY_STORE__ = window.__STORYBOOK_STORY_STORE__ || window.__STORYBOOK_PREVIEW__.storyStore;
2040
+
2041
+ ${generateHMRHandler()};
2042
+
2043
+ `.trim();
2044
+ }
2045
+
2046
+ // src/codegen-set-addon-channel.ts
2047
+ async function generateAddonSetupCode() {
2048
+ return `
2049
+ import { createBrowserChannel } from 'storybook/internal/channels';
2050
+ import { addons } from 'storybook/preview-api';
2051
+
2052
+ const channel = createBrowserChannel({ page: 'preview' });
2053
+ addons.setChannel(channel);
2054
+
2055
+ if (window.CONFIG_TYPE === 'DEVELOPMENT'){
2056
+ window.__STORYBOOK_SERVER_CHANNEL__ = channel;
2057
+ }
2058
+ `.trim();
2059
+ }
2060
+
2061
+ // src/transform-iframe-html.ts
2062
+ import { normalizeStories } from "storybook/internal/common";
2063
+ async function transformIframeHtml(html, options) {
2064
+ let { configType, features, presets } = options, build = await presets.apply("build"), frameworkOptions = await presets.apply("frameworkOptions"), headHtmlSnippet = await presets.apply("previewHead"), bodyHtmlSnippet = await presets.apply("previewBody"), logLevel = await presets.apply("logLevel", void 0), docsOptions = await presets.apply("docs"), tagsOptions = await presets.apply("tags"), coreOptions = await presets.apply("core"), stories = normalizeStories(await options.presets.apply("stories", [], options), {
2065
+ configDir: options.configDir,
2066
+ workingDir: process.cwd()
2067
+ }).map((specifier) => ({
2068
+ ...specifier,
2069
+ importPathMatcher: specifier.importPathMatcher.source
2070
+ })), otherGlobals = {
2071
+ ...build?.test?.disableBlocks ? { __STORYBOOK_BLOCKS_EMPTY_MODULE__: {} } : {}
2072
+ }, transformedHtml = html.replace("[CONFIG_TYPE HERE]", configType || "").replace("[LOGLEVEL HERE]", logLevel || "").replace("'[FRAMEWORK_OPTIONS HERE]'", JSON.stringify(frameworkOptions)).replace(
2073
+ "('OTHER_GLOBALS HERE');",
2074
+ Object.entries(otherGlobals).map(([k, v]) => `window["${k}"] = ${JSON.stringify(v)};`).join("")
2075
+ ).replace(
2076
+ "'[CHANNEL_OPTIONS HERE]'",
2077
+ JSON.stringify(coreOptions && coreOptions.channelOptions ? coreOptions.channelOptions : {})
2078
+ ).replace("'[FEATURES HERE]'", JSON.stringify(features || {})).replace("'[STORIES HERE]'", JSON.stringify(stories || {})).replace("'[DOCS_OPTIONS HERE]'", JSON.stringify(docsOptions || {})).replace("'[TAGS_OPTIONS HERE]'", JSON.stringify(tagsOptions || {})).replace("<!-- [HEAD HTML SNIPPET HERE] -->", headHtmlSnippet || "").replace("<!-- [BODY HTML SNIPPET HERE] -->", bodyHtmlSnippet || "");
2079
+ return configType === "DEVELOPMENT" ? transformedHtml.replace(
2080
+ "virtual:/@storybook/builder-vite/vite-app.js",
2081
+ `/@id/__x00__${SB_VIRTUAL_FILES.VIRTUAL_APP_FILE}`
2082
+ ) : transformedHtml;
2083
+ }
2084
+
2085
+ // src/utils/vite-features.ts
2086
+ import { version } from "vite";
2087
+ var shouldUseRolldownOptions = () => {
2088
+ try {
2089
+ return Number(version.split(".")[0]) >= 8;
2090
+ } catch {
2091
+ return !1;
2092
+ }
2093
+ }, bundlerOptionsKey = shouldUseRolldownOptions() ? "rolldownOptions" : "rollupOptions";
2094
+ function ensureRolldownOptions(config) {
2095
+ if (!shouldUseRolldownOptions())
2096
+ return;
2097
+ config.build ??= {};
2098
+ let rolldown = config.build.rolldownOptions ??= {}, output = rolldown.output ??= {};
2099
+ output.strictExecutionOrder = !0;
2100
+ }
2101
+
2102
+ // src/plugins/code-generator-plugin.ts
2103
+ function codeGeneratorPlugin(options) {
2104
+ let iframePath = fileURLToPath3(importMetaResolve("@storybook/builder-vite/input/iframe.html")), iframeId, storyIndexGeneratorPromise = options.presets.apply("storyIndexGenerator");
2105
+ return {
2106
+ name: "storybook:code-generator-plugin",
2107
+ enforce: "pre",
2108
+ async configureServer(server) {
2109
+ (await storyIndexGeneratorPromise).onInvalidated(() => {
2110
+ server.watcher.emit(
2111
+ "change",
2112
+ getResolvedVirtualModuleId(SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE)
2113
+ );
2114
+ });
2115
+ },
2116
+ config(config, { command }) {
2117
+ if (command === "build") {
2118
+ config.build || (config.build = {});
2119
+ let build = config.build;
2120
+ build[bundlerOptionsKey] = {
2121
+ ...build[bundlerOptionsKey],
2122
+ input: iframePath
2123
+ }, ensureRolldownOptions(config);
2124
+ }
2125
+ },
2126
+ configResolved(config) {
2127
+ iframeId = `${config.root}/iframe.html`;
2128
+ },
2129
+ resolveId(source) {
2130
+ if (SB_VIRTUAL_FILE_IDS.includes(source))
2131
+ return getResolvedVirtualModuleId(source);
2132
+ if (source === iframePath)
2133
+ return iframeId;
2134
+ },
2135
+ async load(id) {
2136
+ switch (id) {
2137
+ case getResolvedVirtualModuleId(SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE): {
2138
+ let index = await (await storyIndexGeneratorPromise)?.getIndex();
2139
+ return generateImportFnScriptCode(index);
2140
+ }
2141
+ case getResolvedVirtualModuleId(SB_VIRTUAL_FILES.VIRTUAL_ADDON_SETUP_FILE):
2142
+ return generateAddonSetupCode();
2143
+ case getResolvedVirtualModuleId(SB_VIRTUAL_FILES.VIRTUAL_APP_FILE):
2144
+ return generateModernIframeScriptCode(options);
2145
+ case iframeId:
2146
+ return readFileSync2(
2147
+ fileURLToPath3(importMetaResolve("@storybook/builder-vite/input/iframe.html")),
2148
+ "utf-8"
2149
+ );
2150
+ }
2151
+ },
2152
+ async transformIndexHtml(html, ctx) {
2153
+ if (ctx.path === "/iframe.html")
2154
+ return transformIframeHtml(html, options);
2155
+ }
2156
+ };
2157
+ }
2158
+
2159
+ // ../../../node_modules/es-module-lexer/dist/lexer.js
2160
+ var ImportType;
2161
+ (function(A2) {
2162
+ A2[A2.Static = 1] = "Static", A2[A2.Dynamic = 2] = "Dynamic", A2[A2.ImportMeta = 3] = "ImportMeta", A2[A2.StaticSourcePhase = 4] = "StaticSourcePhase", A2[A2.DynamicSourcePhase = 5] = "DynamicSourcePhase", A2[A2.StaticDeferPhase = 6] = "StaticDeferPhase", A2[A2.DynamicDeferPhase = 7] = "DynamicDeferPhase";
2163
+ })(ImportType || (ImportType = {}));
2164
+ var A = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
2165
+ function parse3(E2, g = "@") {
2166
+ if (!C) return init.then((() => parse3(E2)));
2167
+ let I = E2.length + 1, w = (C.__heap_base.value || C.__heap_base) + 4 * I - C.memory.buffer.byteLength;
2168
+ w > 0 && C.memory.grow(Math.ceil(w / 65536));
2169
+ let K = C.sa(I - 1);
2170
+ if ((A ? B : Q)(E2, new Uint16Array(C.memory.buffer, K, I)), !C.parse()) throw Object.assign(new Error(`Parse error ${g}:${E2.slice(0, C.e()).split(`
2171
+ `).length}:${C.e() - E2.lastIndexOf(`
2172
+ `, C.e() - 1)}`), { idx: C.e() });
2173
+ let o = [], D = [];
2174
+ for (; C.ri(); ) {
2175
+ let A2 = C.is(), Q2 = C.ie(), B2 = C.it(), g2 = C.ai(), I2 = C.id(), w2 = C.ss(), K2 = C.se(), D2;
2176
+ C.ip() && (D2 = k(E2.slice(I2 === -1 ? A2 - 1 : A2, I2 === -1 ? Q2 + 1 : Q2))), o.push({ n: D2, t: B2, s: A2, e: Q2, ss: w2, se: K2, d: I2, a: g2 });
2177
+ }
2178
+ for (; C.re(); ) {
2179
+ let A2 = C.es(), Q2 = C.ee(), B2 = C.els(), g2 = C.ele(), I2 = E2.slice(A2, Q2), w2 = I2[0], K2 = B2 < 0 ? void 0 : E2.slice(B2, g2), o2 = K2 ? K2[0] : "";
2180
+ D.push({ s: A2, e: Q2, ls: B2, le: g2, n: w2 === '"' || w2 === "'" ? k(I2) : I2, ln: o2 === '"' || o2 === "'" ? k(K2) : K2 });
2181
+ }
2182
+ function k(A2) {
2183
+ try {
2184
+ return (0, eval)(A2);
2185
+ } catch {
2186
+ }
2187
+ }
2188
+ return [o, D, !!C.f(), !!C.ms()];
2189
+ }
2190
+ function Q(A2, Q2) {
2191
+ let B2 = A2.length, C2 = 0;
2192
+ for (; C2 < B2; ) {
2193
+ let B3 = A2.charCodeAt(C2);
2194
+ Q2[C2++] = (255 & B3) << 8 | B3 >>> 8;
2195
+ }
2196
+ }
2197
+ function B(A2, Q2) {
2198
+ let B2 = A2.length, C2 = 0;
2199
+ for (; C2 < B2; ) Q2[C2] = A2.charCodeAt(C2++);
2200
+ }
2201
+ var C, E = () => {
2202
+ return A2 = "AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKzkQwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0wEBA39BACgC8AkhBEEAQQAoAogKIgU2AvAJQQAgBDYC9AlBACAFQSRqNgKICiAEQSBqQeAJIAQbIAU2AgBBACgC1AkhBEEAKALQCSEGIAUgATYCACAFIAA2AgggBSACIAJBAmpBACAGIANGIgAbIAQgA0YiBBs2AgwgBSADNgIUIAVBADYCECAFIAI2AgQgBUEANgIgIAVBA0EBQQIgABsgBBs2AhwgBUEAKALQCSADRiICOgAYAkACQCACDQBBACgC1AkgA0cNAQtBAEEBOgCMCgsLXgEBf0EAKAL4CSIEQRBqQeQJIAQbQQAoAogKIgQ2AgBBACAENgL4CUEAIARBFGo2AogKQQBBAToAjAogBEEANgIQIAQgAzYCDCAEIAI2AgggBCABNgIEIAQgADYCAAsIAEEAKAKQCgsVAEEAKALoCSgCAEEAKALcCWtBAXULHgEBf0EAKALoCSgCBCIAQQAoAtwJa0E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0AgAC0AACIEIAEtAAAiBUcNASABQQFqIQEgAEEBaiEAIAJBf2oiAg0ADAILCyAEIAVrIQMLIAMLC+wBAgBBgAgLzgEAAHgAcABvAHIAdABtAHAAbwByAHQAZgBvAHIAZQB0AGEAbwB1AHIAYwBlAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=", typeof Buffer < "u" ? Buffer.from(A2, "base64") : Uint8Array.from(atob(A2), ((A3) => A3.charCodeAt(0)));
2203
+ var A2;
2204
+ }, init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({ exports: A2 }) => {
2205
+ C = A2;
2206
+ }));
2207
+
2208
+ // ../../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
2209
+ var comma = 44, semicolon = 59, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
2210
+ for (let i = 0; i < chars.length; i++) {
2211
+ let c = chars.charCodeAt(i);
2212
+ intToChar[i] = c, charToInt[c] = i;
2213
+ }
2214
+ function encodeInteger(builder, num, relative4) {
2215
+ let delta = num - relative4;
2216
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
2217
+ do {
2218
+ let clamped = delta & 31;
2219
+ delta >>>= 5, delta > 0 && (clamped |= 32), builder.write(intToChar[clamped]);
2220
+ } while (delta > 0);
2221
+ return num;
2222
+ }
2223
+ var bufLength = 1024 * 16, td = typeof TextDecoder < "u" ? new TextDecoder() : typeof Buffer < "u" ? {
2224
+ decode(buf) {
2225
+ return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
2226
+ }
2227
+ } : {
2228
+ decode(buf) {
2229
+ let out = "";
2230
+ for (let i = 0; i < buf.length; i++)
2231
+ out += String.fromCharCode(buf[i]);
2232
+ return out;
2233
+ }
2234
+ }, StringWriter = class {
2235
+ constructor() {
2236
+ this.pos = 0, this.out = "", this.buffer = new Uint8Array(bufLength);
2237
+ }
2238
+ write(v) {
2239
+ let { buffer } = this;
2240
+ buffer[this.pos++] = v, this.pos === bufLength && (this.out += td.decode(buffer), this.pos = 0);
2241
+ }
2242
+ flush() {
2243
+ let { buffer, out, pos } = this;
2244
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
2245
+ }
2246
+ };
2247
+ function encode(decoded) {
2248
+ let writer = new StringWriter(), sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;
2249
+ for (let i = 0; i < decoded.length; i++) {
2250
+ let line = decoded[i];
2251
+ if (i > 0 && writer.write(semicolon), line.length === 0) continue;
2252
+ let genColumn = 0;
2253
+ for (let j = 0; j < line.length; j++) {
2254
+ let segment = line[j];
2255
+ j > 0 && writer.write(comma), genColumn = encodeInteger(writer, segment[0], genColumn), segment.length !== 1 && (sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex), sourceLine = encodeInteger(writer, segment[2], sourceLine), sourceColumn = encodeInteger(writer, segment[3], sourceColumn), segment.length !== 4 && (namesIndex = encodeInteger(writer, segment[4], namesIndex)));
2256
+ }
2257
+ }
2258
+ return writer.flush();
2259
+ }
2260
+
2261
+ // node_modules/magic-string/dist/index.mjs
2262
+ var BitSet = class BitSet2 {
2263
+ constructor(arg) {
2264
+ this.bits = arg instanceof BitSet2 ? arg.bits.slice() : [];
2265
+ }
2266
+ add(n2) {
2267
+ this.bits[n2 >> 5] |= 1 << (n2 & 31);
2268
+ }
2269
+ has(n2) {
2270
+ return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
2271
+ }
2272
+ }, Chunk = class Chunk2 {
2273
+ constructor(start, end, content) {
2274
+ this.start = start, this.end = end, this.original = content, this.intro = "", this.outro = "", this.content = content, this.storeName = !1, this.edited = !1, this.previous = null, this.next = null;
2275
+ }
2276
+ appendLeft(content) {
2277
+ this.outro += content;
2278
+ }
2279
+ appendRight(content) {
2280
+ this.intro = this.intro + content;
2281
+ }
2282
+ clone() {
2283
+ let chunk = new Chunk2(this.start, this.end, this.original);
2284
+ return chunk.intro = this.intro, chunk.outro = this.outro, chunk.content = this.content, chunk.storeName = this.storeName, chunk.edited = this.edited, chunk;
2285
+ }
2286
+ contains(index) {
2287
+ return this.start < index && index < this.end;
2288
+ }
2289
+ eachNext(fn) {
2290
+ fn(this);
2291
+ let chunk = this.next;
2292
+ for (; chunk; )
2293
+ fn(chunk), chunk = chunk.next;
2294
+ }
2295
+ eachPrevious(fn) {
2296
+ fn(this);
2297
+ let chunk = this.previous;
2298
+ for (; chunk; )
2299
+ fn(chunk), chunk = chunk.previous;
2300
+ }
2301
+ edit(content, storeName, contentOnly) {
2302
+ return this.content = content, contentOnly || (this.intro = "", this.outro = ""), this.storeName = storeName, this.edited = !0, this;
2303
+ }
2304
+ prependLeft(content) {
2305
+ this.outro = content + this.outro;
2306
+ }
2307
+ prependRight(content) {
2308
+ this.intro = content + this.intro;
2309
+ }
2310
+ reset() {
2311
+ this.intro = "", this.outro = "", this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
2312
+ }
2313
+ split(index) {
2314
+ let sliceIndex = index - this.start, originalBefore = this.original.slice(0, sliceIndex), originalAfter = this.original.slice(sliceIndex);
2315
+ this.original = originalBefore;
2316
+ let newChunk = new Chunk2(index, this.end, originalAfter);
2317
+ return newChunk.outro = this.outro, this.outro = "", this.end = index, this.edited ? (newChunk.edit("", !1), this.content = "") : this.content = originalBefore, newChunk.next = this.next, newChunk.next && (newChunk.next.previous = newChunk), newChunk.previous = this, this.next = newChunk, newChunk;
2318
+ }
2319
+ toString() {
2320
+ return this.intro + this.content + this.outro;
2321
+ }
2322
+ trimEnd(rx) {
2323
+ if (this.outro = this.outro.replace(rx, ""), this.outro.length) return !0;
2324
+ let trimmed = this.content.replace(rx, "");
2325
+ if (trimmed.length)
2326
+ return trimmed !== this.content && (this.edited ? this.edit(trimmed, this.storeName, !0) : this.split(this.start + trimmed.length).edit("", void 0, !0)), !0;
2327
+ if (this.edit("", void 0, !0), this.intro = this.intro.replace(rx, ""), this.intro.length) return !0;
2328
+ }
2329
+ trimStart(rx) {
2330
+ if (this.intro = this.intro.replace(rx, ""), this.intro.length) return !0;
2331
+ let trimmed = this.content.replace(rx, "");
2332
+ if (trimmed.length)
2333
+ return trimmed !== this.content && (this.edited ? this.edit(trimmed, this.storeName, !0) : (this.split(this.end - trimmed.length), this.edit("", void 0, !0))), !0;
2334
+ if (this.edit("", void 0, !0), this.outro = this.outro.replace(rx, ""), this.outro.length) return !0;
2335
+ }
2336
+ };
2337
+ function getBtoa() {
2338
+ if (typeof globalThis < "u" && typeof globalThis.btoa == "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
2339
+ let buffer = globalThis.Buffer;
2340
+ return buffer ? (str) => buffer.from(str, "utf-8").toString("base64") : () => {
2341
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
2342
+ };
2343
+ }
2344
+ var btoa = getBtoa(), SourceMap = class {
2345
+ constructor(properties) {
2346
+ this.version = 3, this.file = properties.file, this.sources = properties.sources, this.sourcesContent = properties.sourcesContent, this.names = properties.names, this.mappings = encode(properties.mappings), typeof properties.x_google_ignoreList < "u" && (this.x_google_ignoreList = properties.x_google_ignoreList), typeof properties.debugId < "u" && (this.debugId = properties.debugId);
2347
+ }
2348
+ /**
2349
+ * Returns the equivalent of `JSON.stringify(map)`
2350
+ */
2351
+ toString() {
2352
+ return JSON.stringify(this);
2353
+ }
2354
+ /**
2355
+ * Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
2356
+ * `generateMap(options?: SourceMapOptions): SourceMap;`
2357
+ */
2358
+ toUrl() {
2359
+ return `data:application/json;charset=utf-8;base64,${btoa(this.toString())}`;
2360
+ }
2361
+ };
2362
+ function getLocator(source) {
2363
+ let originalLines = source.split(`
2364
+ `), lineOffsets = [];
2365
+ for (let i = 0, pos = 0; i < originalLines.length; i++)
2366
+ lineOffsets.push(pos), pos += originalLines[i].length + 1;
2367
+ return function(index) {
2368
+ let i = 0, j = lineOffsets.length;
2369
+ for (; i < j; ) {
2370
+ let m = i + j >> 1;
2371
+ index < lineOffsets[m] ? j = m : i = m + 1;
2372
+ }
2373
+ let line = i - 1;
2374
+ return {
2375
+ line,
2376
+ column: index - lineOffsets[line]
2377
+ };
2378
+ };
2379
+ }
2380
+ function getRelativePath(from, to) {
2381
+ let fromParts = from.split(/[/\\]/), toParts = to.split(/[/\\]/);
2382
+ for (fromParts.pop(); fromParts[0] === toParts[0]; )
2383
+ fromParts.shift(), toParts.shift();
2384
+ if (fromParts.length) {
2385
+ let i = fromParts.length;
2386
+ for (; i--; ) fromParts[i] = "..";
2387
+ }
2388
+ return fromParts.concat(toParts).join("/");
2389
+ }
2390
+ function guessIndent(code) {
2391
+ let lines = code.split(`
2392
+ `), tabbed = lines.filter((line) => /^\t+/.test(line)), spaced = lines.filter((line) => /^ {2,}/.test(line));
2393
+ if (tabbed.length === 0 && spaced.length === 0) return null;
2394
+ if (tabbed.length >= spaced.length) return " ";
2395
+ let min = spaced.reduce((previous, current) => {
2396
+ let numSpaces = /^ +/.exec(current)[0].length;
2397
+ return Math.min(numSpaces, previous);
2398
+ }, 1 / 0);
2399
+ return " ".repeat(min);
2400
+ }
2401
+ var toString = Object.prototype.toString;
2402
+ function isObject(thing) {
2403
+ return toString.call(thing) === "[object Object]";
2404
+ }
2405
+ var wordRegex = /\w/, Mappings = class {
2406
+ constructor(hires) {
2407
+ this.hires = hires, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.pending = null;
2408
+ }
2409
+ addEdit(sourceIndex, content, loc, nameIndex) {
2410
+ if (content.length) {
2411
+ let contentLengthMinusOne = content.length - 1, contentLineEnd = content.indexOf(`
2412
+ `, 0), previousContentLineEnd = -1;
2413
+ for (; contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd; ) {
2414
+ let segment2 = [
2415
+ this.generatedCodeColumn,
2416
+ sourceIndex,
2417
+ loc.line,
2418
+ loc.column
2419
+ ];
2420
+ nameIndex >= 0 && segment2.push(nameIndex), this.rawSegments.push(segment2), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, previousContentLineEnd = contentLineEnd, contentLineEnd = content.indexOf(`
2421
+ `, contentLineEnd + 1);
2422
+ }
2423
+ let segment = [
2424
+ this.generatedCodeColumn,
2425
+ sourceIndex,
2426
+ loc.line,
2427
+ loc.column
2428
+ ];
2429
+ nameIndex >= 0 && segment.push(nameIndex), this.rawSegments.push(segment), this.advance(content.slice(previousContentLineEnd + 1));
2430
+ } else this.pending && (this.rawSegments.push(this.pending), this.advance(content));
2431
+ this.pending = null;
2432
+ }
2433
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
2434
+ let originalCharIndex = chunk.start, first = !0, charInHiresBoundary = !1;
2435
+ for (; originalCharIndex < chunk.end; ) {
2436
+ if (original[originalCharIndex] === `
2437
+ `)
2438
+ loc.line += 1, loc.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, first = !0, charInHiresBoundary = !1;
2439
+ else {
2440
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
2441
+ let segment = [
2442
+ this.generatedCodeColumn,
2443
+ sourceIndex,
2444
+ loc.line,
2445
+ loc.column
2446
+ ];
2447
+ this.hires === "boundary" ? wordRegex.test(original[originalCharIndex]) ? charInHiresBoundary || (this.rawSegments.push(segment), charInHiresBoundary = !0) : (this.rawSegments.push(segment), charInHiresBoundary = !1) : this.rawSegments.push(segment);
2448
+ }
2449
+ loc.column += 1, this.generatedCodeColumn += 1, first = !1;
2450
+ }
2451
+ originalCharIndex += 1;
2452
+ }
2453
+ this.pending = null;
2454
+ }
2455
+ advance(str) {
2456
+ if (!str) return;
2457
+ let lines = str.split(`
2458
+ `);
2459
+ if (lines.length > 1) {
2460
+ for (let i = 0; i < lines.length - 1; i++)
2461
+ this.generatedCodeLine++, this.raw[this.generatedCodeLine] = this.rawSegments = [];
2462
+ this.generatedCodeColumn = 0;
2463
+ }
2464
+ this.generatedCodeColumn += lines[lines.length - 1].length;
2465
+ }
2466
+ }, n = `
2467
+ `, NEWLINE_CHAR = 10, CR_CHAR = 13, warned = {
2468
+ insertLeft: !1,
2469
+ insertRight: !1,
2470
+ storeName: !1
2471
+ }, MagicString = class MagicString2 {
2472
+ constructor(string, options = {}) {
2473
+ let chunk = new Chunk(0, string.length, string);
2474
+ Object.defineProperties(this, {
2475
+ original: {
2476
+ writable: !0,
2477
+ value: string
2478
+ },
2479
+ outro: {
2480
+ writable: !0,
2481
+ value: ""
2482
+ },
2483
+ intro: {
2484
+ writable: !0,
2485
+ value: ""
2486
+ },
2487
+ firstChunk: {
2488
+ writable: !0,
2489
+ value: chunk
2490
+ },
2491
+ lastChunk: {
2492
+ writable: !0,
2493
+ value: chunk
2494
+ },
2495
+ lastSearchedChunk: {
2496
+ writable: !0,
2497
+ value: chunk
2498
+ },
2499
+ byStart: {
2500
+ writable: !0,
2501
+ value: {}
2502
+ },
2503
+ byEnd: {
2504
+ writable: !0,
2505
+ value: {}
2506
+ },
2507
+ filename: {
2508
+ writable: !0,
2509
+ value: options.filename
2510
+ },
2511
+ indentExclusionRanges: {
2512
+ writable: !0,
2513
+ value: options.indentExclusionRanges
2514
+ },
2515
+ sourcemapLocations: {
2516
+ writable: !0,
2517
+ value: new BitSet()
2518
+ },
2519
+ storedNames: {
2520
+ writable: !0,
2521
+ value: {}
2522
+ },
2523
+ indentStr: {
2524
+ writable: !0,
2525
+ value: void 0
2526
+ },
2527
+ ignoreList: {
2528
+ writable: !0,
2529
+ value: options.ignoreList
2530
+ },
2531
+ offset: {
2532
+ writable: !0,
2533
+ value: options.offset || 0
2534
+ }
2535
+ }), this.byStart = /* @__PURE__ */ new Map([[0, chunk]]), this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
2536
+ }
2537
+ /**
2538
+ * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
2539
+ */
2540
+ addSourcemapLocation(char) {
2541
+ this.sourcemapLocations.add(char);
2542
+ }
2543
+ /**
2544
+ * Appends the specified content to the end of the string.
2545
+ */
2546
+ append(content) {
2547
+ if (typeof content != "string") throw new TypeError("outro content must be a string");
2548
+ return this.outro += content, this;
2549
+ }
2550
+ /**
2551
+ * Appends the specified content at the index in the original string.
2552
+ * If a range *ending* with index is subsequently moved, the insert will be moved with it.
2553
+ * See also `s.prependLeft(...)`.
2554
+ */
2555
+ appendLeft(index, content) {
2556
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
2557
+ this._split(index);
2558
+ let chunk = this.byEnd.get(index);
2559
+ return chunk ? chunk.appendLeft(content) : this.intro += content, this;
2560
+ }
2561
+ /**
2562
+ * Appends the specified content at the index in the original string.
2563
+ * If a range *starting* with index is subsequently moved, the insert will be moved with it.
2564
+ * See also `s.prependRight(...)`.
2565
+ */
2566
+ appendRight(index, content) {
2567
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
2568
+ this._split(index);
2569
+ let chunk = this.byStart.get(index);
2570
+ return chunk ? chunk.appendRight(content) : this.outro += content, this;
2571
+ }
2572
+ /**
2573
+ * Does what you'd expect.
2574
+ */
2575
+ clone() {
2576
+ let cloned = new MagicString2(this.original, {
2577
+ filename: this.filename,
2578
+ offset: this.offset
2579
+ }), originalChunk = this.firstChunk, clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
2580
+ for (; originalChunk; ) {
2581
+ cloned.byStart.set(clonedChunk.start, clonedChunk), cloned.byEnd.set(clonedChunk.end, clonedChunk);
2582
+ let nextOriginalChunk = originalChunk.next, nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
2583
+ nextClonedChunk && (clonedChunk.next = nextClonedChunk, nextClonedChunk.previous = clonedChunk, clonedChunk = nextClonedChunk), originalChunk = nextOriginalChunk;
2584
+ }
2585
+ return cloned.lastChunk = clonedChunk, this.indentExclusionRanges && (cloned.indentExclusionRanges = this.indentExclusionRanges.slice()), cloned.sourcemapLocations = new BitSet(this.sourcemapLocations), cloned.intro = this.intro, cloned.outro = this.outro, cloned;
2586
+ }
2587
+ /**
2588
+ * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
2589
+ * Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
2590
+ */
2591
+ generateDecodedMap(options) {
2592
+ options = options || {};
2593
+ let sourceIndex = 0, names = Object.keys(this.storedNames), mappings = new Mappings(options.hires), locate = getLocator(this.original);
2594
+ return this.intro && mappings.advance(this.intro), this.firstChunk.eachNext((chunk) => {
2595
+ let loc = locate(chunk.start);
2596
+ chunk.intro.length && mappings.advance(chunk.intro), chunk.edited ? mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1) : mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations), chunk.outro.length && mappings.advance(chunk.outro);
2597
+ }), this.outro && mappings.advance(this.outro), {
2598
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
2599
+ sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
2600
+ sourcesContent: options.includeContent ? [this.original] : void 0,
2601
+ names,
2602
+ mappings: mappings.raw,
2603
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
2604
+ };
2605
+ }
2606
+ /**
2607
+ * Generates a version 3 sourcemap.
2608
+ */
2609
+ generateMap(options) {
2610
+ return new SourceMap(this.generateDecodedMap(options));
2611
+ }
2612
+ /** @internal */
2613
+ _ensureindentStr() {
2614
+ this.indentStr === void 0 && (this.indentStr = guessIndent(this.original));
2615
+ }
2616
+ /** @internal */
2617
+ _getRawIndentString() {
2618
+ return this._ensureindentStr(), this.indentStr;
2619
+ }
2620
+ getIndentString() {
2621
+ return this._ensureindentStr(), this.indentStr === null ? " " : this.indentStr;
2622
+ }
2623
+ indent(indentStr, options) {
2624
+ let pattern = /^[^\r\n]/gm;
2625
+ if (isObject(indentStr) && (options = indentStr, indentStr = void 0), indentStr === void 0 && (this._ensureindentStr(), indentStr = this.indentStr || " "), indentStr === "") return this;
2626
+ let resolvedIndentStr = indentStr;
2627
+ options = options || {};
2628
+ let isExcluded = {};
2629
+ options.exclude && (typeof options.exclude[0] == "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
2630
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = !0;
2631
+ });
2632
+ let shouldIndentNextCharacter = options.indentStart !== !1, replacer = (match) => shouldIndentNextCharacter ? `${resolvedIndentStr}${match}` : (shouldIndentNextCharacter = !0, match);
2633
+ this.intro = this.intro.replace(pattern, replacer);
2634
+ let charIndex = 0, chunk = this.firstChunk, indentAt = (index) => {
2635
+ shouldIndentNextCharacter = !1, index === chunk.start || (this._splitChunk(chunk, index), chunk = chunk.next), chunk.prependRight(resolvedIndentStr);
2636
+ };
2637
+ for (; chunk; ) {
2638
+ let end = chunk.end;
2639
+ if (chunk.edited)
2640
+ isExcluded[charIndex] || (chunk.content = chunk.content.replace(pattern, replacer), chunk.content.length && (shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === `
2641
+ `));
2642
+ else if (options.exclude)
2643
+ for (charIndex = chunk.start; charIndex < end; ) {
2644
+ if (!isExcluded[charIndex]) {
2645
+ let char = this.original.charCodeAt(charIndex);
2646
+ char === NEWLINE_CHAR ? shouldIndentNextCharacter = !0 : char !== CR_CHAR && shouldIndentNextCharacter && indentAt(charIndex);
2647
+ }
2648
+ charIndex += 1;
2649
+ }
2650
+ else
2651
+ for (charIndex = chunk.start; charIndex < end; ) {
2652
+ if (!shouldIndentNextCharacter) {
2653
+ let nextLine = this.original.indexOf(n, charIndex);
2654
+ if (nextLine === -1 || nextLine >= end) break;
2655
+ shouldIndentNextCharacter = !0, charIndex = nextLine + 1;
2656
+ continue;
2657
+ }
2658
+ let char = this.original.charCodeAt(charIndex);
2659
+ if (char === NEWLINE_CHAR || char === CR_CHAR) {
2660
+ charIndex += 1;
2661
+ continue;
2662
+ }
2663
+ indentAt(charIndex), charIndex += 1;
2664
+ }
2665
+ charIndex = chunk.end, chunk = chunk.next;
2666
+ }
2667
+ return this.outro = this.outro.replace(pattern, replacer), this;
2668
+ }
2669
+ /** @internal */
2670
+ insert() {
2671
+ throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
2672
+ }
2673
+ /** @internal */
2674
+ insertLeft(index, content) {
2675
+ return warned.insertLeft || (console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"), warned.insertLeft = !0), this.appendLeft(index, content);
2676
+ }
2677
+ /** @internal */
2678
+ insertRight(index, content) {
2679
+ return warned.insertRight || (console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"), warned.insertRight = !0), this.prependRight(index, content);
2680
+ }
2681
+ /**
2682
+ * Moves the characters from `start` and `end` to `index`.
2683
+ */
2684
+ move(start, end, index) {
2685
+ if (start = start + this.offset, end = end + this.offset, index = index + this.offset, start === end) return this;
2686
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
2687
+ this._split(start), this._split(end), this._split(index);
2688
+ let first = this.byStart.get(start), last = this.byEnd.get(end), oldLeft = first.previous, oldRight = last.next, newRight = this.byStart.get(index);
2689
+ if (!newRight && last === this.lastChunk) return this;
2690
+ let newLeft = newRight ? newRight.previous : this.lastChunk;
2691
+ return oldLeft && (oldLeft.next = oldRight), oldRight && (oldRight.previous = oldLeft), newLeft && (newLeft.next = first), newRight && (newRight.previous = last), first.previous || (this.firstChunk = last.next), last.next || (this.lastChunk = first.previous, this.lastChunk.next = null), first.previous = newLeft, last.next = newRight || null, newLeft || (this.firstChunk = first), newRight || (this.lastChunk = last), this;
2692
+ }
2693
+ /**
2694
+ * Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
2695
+ * that range. The same restrictions as `s.remove()` apply.
2696
+ *
2697
+ * The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
2698
+ * for later inclusion in a sourcemap's names array - and a contentOnly property which determines whether only
2699
+ * the content is overwritten, or anything that was appended/prepended to the range as well.
2700
+ *
2701
+ * It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
2702
+ */
2703
+ overwrite(start, end, content, options) {
2704
+ let optionObject = typeof options == "object" && options ? options : {};
2705
+ return this.update(start, end, content, {
2706
+ ...optionObject,
2707
+ overwrite: !optionObject.contentOnly
2708
+ });
2709
+ }
2710
+ /**
2711
+ * Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
2712
+ *
2713
+ * The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
2714
+ * for later inclusion in a sourcemap's names array - and an overwrite property which determines whether only
2715
+ * the content is overwritten, or anything that was appended/prepended to the range as well.
2716
+ */
2717
+ update(start, end, content, options) {
2718
+ if (start = start + this.offset, end = end + this.offset, typeof content != "string") throw new TypeError("replacement content must be a string");
2719
+ if (this.original.length !== 0) {
2720
+ for (; start < 0; ) start += this.original.length;
2721
+ for (; end < 0; ) end += this.original.length;
2722
+ }
2723
+ if (end > this.original.length) throw new Error("end is out of bounds");
2724
+ if (start === end) throw new Error("Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead");
2725
+ this._split(start), this._split(end), options === !0 && (warned.storeName || (console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"), warned.storeName = !0), options = { storeName: !0 });
2726
+ let optionObject = typeof options == "object" && options ? options : {}, storeName = optionObject.storeName || !1, overwrite = optionObject.overwrite || !1;
2727
+ if (storeName) {
2728
+ let original = this.original.slice(start, end);
2729
+ Object.defineProperty(this.storedNames, original, {
2730
+ writable: !0,
2731
+ value: !0,
2732
+ enumerable: !0
2733
+ });
2734
+ }
2735
+ let first = this.byStart.get(start), last = this.byEnd.get(end);
2736
+ if (first) {
2737
+ let chunk = first;
2738
+ for (; chunk !== last; ) {
2739
+ if (chunk.next !== this.byStart.get(chunk.end)) throw new Error("Cannot overwrite across a split point");
2740
+ chunk = chunk.next, chunk.edit("", !1);
2741
+ }
2742
+ first.edit(content, storeName, !overwrite);
2743
+ } else {
2744
+ let newChunk = new Chunk(start, end, "").edit(content, storeName);
2745
+ last.next = newChunk, newChunk.previous = last;
2746
+ }
2747
+ return this;
2748
+ }
2749
+ /**
2750
+ * Prepends the string with the specified content.
2751
+ */
2752
+ prepend(content) {
2753
+ if (typeof content != "string") throw new TypeError("outro content must be a string");
2754
+ return this.intro = content + this.intro, this;
2755
+ }
2756
+ /**
2757
+ * Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
2758
+ */
2759
+ prependLeft(index, content) {
2760
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
2761
+ this._split(index);
2762
+ let chunk = this.byEnd.get(index);
2763
+ return chunk ? chunk.prependLeft(content) : this.intro = content + this.intro, this;
2764
+ }
2765
+ /**
2766
+ * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
2767
+ */
2768
+ prependRight(index, content) {
2769
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
2770
+ this._split(index);
2771
+ let chunk = this.byStart.get(index);
2772
+ return chunk ? chunk.prependRight(content) : this.outro = content + this.outro, this;
2773
+ }
2774
+ /**
2775
+ * Removes the characters from `start` to `end` (of the original string, **not** the generated string).
2776
+ * Removing the same content twice, or making removals that partially overlap, will cause an error.
2777
+ */
2778
+ remove(start, end) {
2779
+ if (start = start + this.offset, end = end + this.offset, this.original.length !== 0) {
2780
+ for (; start < 0; ) start += this.original.length;
2781
+ for (; end < 0; ) end += this.original.length;
2782
+ }
2783
+ if (start === end) return this;
2784
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
2785
+ if (start > end) throw new Error("end must be greater than start");
2786
+ this._split(start), this._split(end);
2787
+ let chunk = this.byStart.get(start);
2788
+ for (; chunk; )
2789
+ chunk.intro = "", chunk.outro = "", chunk.edit(""), chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
2790
+ return this;
2791
+ }
2792
+ /**
2793
+ * Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
2794
+ */
2795
+ reset(start, end) {
2796
+ if (start = start + this.offset, end = end + this.offset, this.original.length !== 0) {
2797
+ for (; start < 0; ) start += this.original.length;
2798
+ for (; end < 0; ) end += this.original.length;
2799
+ }
2800
+ if (start === end) return this;
2801
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
2802
+ if (start > end) throw new Error("end must be greater than start");
2803
+ this._split(start), this._split(end);
2804
+ let chunk = this.byStart.get(start);
2805
+ for (; chunk; )
2806
+ chunk.reset(), chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
2807
+ return this;
2808
+ }
2809
+ lastChar() {
2810
+ if (this.outro.length) return this.outro[this.outro.length - 1];
2811
+ let chunk = this.lastChunk;
2812
+ for (; chunk; ) {
2813
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
2814
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
2815
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
2816
+ chunk = chunk.previous;
2817
+ }
2818
+ return this.intro.length ? this.intro[this.intro.length - 1] : "";
2819
+ }
2820
+ lastLine() {
2821
+ let lineIndex = this.outro.lastIndexOf(n);
2822
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
2823
+ let lineStr = this.outro, chunk = this.lastChunk;
2824
+ for (; chunk; ) {
2825
+ if (chunk.outro.length > 0) {
2826
+ if (lineIndex = chunk.outro.lastIndexOf(n), lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
2827
+ lineStr = chunk.outro + lineStr;
2828
+ }
2829
+ if (chunk.content.length > 0) {
2830
+ if (lineIndex = chunk.content.lastIndexOf(n), lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
2831
+ lineStr = chunk.content + lineStr;
2832
+ }
2833
+ if (chunk.intro.length > 0) {
2834
+ if (lineIndex = chunk.intro.lastIndexOf(n), lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
2835
+ lineStr = chunk.intro + lineStr;
2836
+ }
2837
+ chunk = chunk.previous;
2838
+ }
2839
+ return lineIndex = this.intro.lastIndexOf(n), lineIndex !== -1 ? this.intro.substr(lineIndex + 1) + lineStr : this.intro + lineStr;
2840
+ }
2841
+ /**
2842
+ * Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
2843
+ * Throws error if the indices are for characters that were already removed.
2844
+ */
2845
+ slice(start = 0, end = this.original.length - this.offset) {
2846
+ if (start = start + this.offset, end = end + this.offset, this.original.length !== 0) {
2847
+ for (; start < 0; ) start += this.original.length;
2848
+ for (; end < 0; ) end += this.original.length;
2849
+ }
2850
+ let result = "", chunk = this.firstChunk;
2851
+ for (; chunk && (chunk.start > start || chunk.end <= start); ) {
2852
+ if (chunk.start < end && chunk.end >= end) return result;
2853
+ chunk = chunk.next;
2854
+ }
2855
+ if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
2856
+ let startChunk = chunk;
2857
+ for (; chunk; ) {
2858
+ chunk.intro && (startChunk !== chunk || chunk.start === start) && (result += chunk.intro);
2859
+ let containsEnd = chunk.start < end && chunk.end >= end;
2860
+ if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
2861
+ let sliceStart = startChunk === chunk ? start - chunk.start : 0, sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
2862
+ if (result += chunk.content.slice(sliceStart, sliceEnd), chunk.outro && (!containsEnd || chunk.end === end) && (result += chunk.outro), containsEnd) break;
2863
+ chunk = chunk.next;
2864
+ }
2865
+ return result;
2866
+ }
2867
+ /**
2868
+ * Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
2869
+ */
2870
+ snip(start, end) {
2871
+ let clone = this.clone();
2872
+ return clone.remove(0, start), clone.remove(end, clone.original.length), clone;
2873
+ }
2874
+ /** @internal */
2875
+ _split(index) {
2876
+ if (this.byStart.get(index) || this.byEnd.get(index)) return;
2877
+ let chunk = this.lastSearchedChunk, previousChunk = chunk, searchForward = index > chunk.end;
2878
+ for (; chunk; ) {
2879
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
2880
+ if (chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start), chunk === previousChunk) return;
2881
+ previousChunk = chunk;
2882
+ }
2883
+ }
2884
+ /** @internal */
2885
+ _splitChunk(chunk, index) {
2886
+ if (chunk.edited && chunk.content.length) {
2887
+ let loc = getLocator(this.original)(index);
2888
+ throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`);
2889
+ }
2890
+ let newChunk = chunk.split(index);
2891
+ return this.byEnd.set(index, chunk), this.byStart.set(index, newChunk), this.byEnd.set(newChunk.end, newChunk), chunk === this.lastChunk && (this.lastChunk = newChunk), this.lastSearchedChunk = chunk, !0;
2892
+ }
2893
+ /**
2894
+ * Returns the generated string.
2895
+ */
2896
+ toString() {
2897
+ let str = this.intro, chunk = this.firstChunk;
2898
+ for (; chunk; )
2899
+ str += chunk.toString(), chunk = chunk.next;
2900
+ return str + this.outro;
2901
+ }
2902
+ /**
2903
+ * Returns true if the resulting source is empty (disregarding white space).
2904
+ */
2905
+ isEmpty() {
2906
+ let chunk = this.firstChunk;
2907
+ for (; chunk; ) {
2908
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return !1;
2909
+ chunk = chunk.next;
2910
+ }
2911
+ return !0;
2912
+ }
2913
+ length() {
2914
+ let chunk = this.firstChunk, length = 0;
2915
+ for (; chunk; )
2916
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length, chunk = chunk.next;
2917
+ return length;
2918
+ }
2919
+ /**
2920
+ * Removes empty lines from the start and end.
2921
+ */
2922
+ trimLines() {
2923
+ return this.trim("[\\r\\n]");
2924
+ }
2925
+ /**
2926
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
2927
+ */
2928
+ trim(charType) {
2929
+ return this.trimStart(charType).trimEnd(charType);
2930
+ }
2931
+ /** @internal */
2932
+ trimEndAborted(charType) {
2933
+ let rx = new RegExp(`${charType || "\\s"}+$`);
2934
+ if (this.outro = this.outro.replace(rx, ""), this.outro.length) return !0;
2935
+ let chunk = this.lastChunk;
2936
+ do {
2937
+ let end = chunk.end, aborted = chunk.trimEnd(rx);
2938
+ if (chunk.end !== end && (this.lastChunk === chunk && (this.lastChunk = chunk.next), this.byEnd.set(chunk.end, chunk), this.byStart.set(chunk.next.start, chunk.next), this.byEnd.set(chunk.next.end, chunk.next)), aborted) return !0;
2939
+ chunk = chunk.previous;
2940
+ } while (chunk);
2941
+ return !1;
2942
+ }
2943
+ /**
2944
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
2945
+ */
2946
+ trimEnd(charType) {
2947
+ return this.trimEndAborted(charType), this;
2948
+ }
2949
+ /** @internal */
2950
+ trimStartAborted(charType) {
2951
+ let rx = new RegExp(`^${charType || "\\s"}+`);
2952
+ if (this.intro = this.intro.replace(rx, ""), this.intro.length) return !0;
2953
+ let chunk = this.firstChunk;
2954
+ do {
2955
+ let end = chunk.end, aborted = chunk.trimStart(rx);
2956
+ if (chunk.end !== end && (chunk === this.lastChunk && (this.lastChunk = chunk.next), this.byEnd.set(chunk.end, chunk), this.byStart.set(chunk.next.start, chunk.next), this.byEnd.set(chunk.next.end, chunk.next)), aborted) return !0;
2957
+ chunk = chunk.next;
2958
+ } while (chunk);
2959
+ return !1;
2960
+ }
2961
+ /**
2962
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
2963
+ */
2964
+ trimStart(charType) {
2965
+ return this.trimStartAborted(charType), this;
2966
+ }
2967
+ /**
2968
+ * Indicates if the string has been changed.
2969
+ */
2970
+ hasChanged() {
2971
+ return this.original !== this.toString();
2972
+ }
2973
+ /** @internal */
2974
+ _replaceRegexp(searchValue, replacement) {
2975
+ function getReplacement(match, str) {
2976
+ return typeof replacement == "string" ? replacement.replace(/\$(\$|&|\d+)/g, (_, i) => i === "$" ? "$" : i === "&" ? match[0] : +i < match.length ? match[+i] : `$${i}`) : replacement(match[0], ...match.slice(1), match.index, str, match.groups);
2977
+ }
2978
+ function matchAll(re, str) {
2979
+ let matches = [];
2980
+ for (; ; ) {
2981
+ let match = re.exec(str);
2982
+ if (!match) break;
2983
+ matches.push(match);
2984
+ }
2985
+ return matches;
2986
+ }
2987
+ if (searchValue.global) matchAll(searchValue, this.original).forEach((match) => {
2988
+ if (match.index != null) {
2989
+ let replacement2 = getReplacement(match, this.original);
2990
+ replacement2 !== match[0] && this.overwrite(match.index, match.index + match[0].length, replacement2);
2991
+ }
2992
+ });
2993
+ else {
2994
+ let match = this.original.match(searchValue);
2995
+ if (match && match.index != null) {
2996
+ let replacement2 = getReplacement(match, this.original);
2997
+ replacement2 !== match[0] && this.overwrite(match.index, match.index + match[0].length, replacement2);
2998
+ }
2999
+ }
3000
+ return this;
3001
+ }
3002
+ /** @internal */
3003
+ _replaceString(string, replacement) {
3004
+ let { original } = this, index = original.indexOf(string);
3005
+ return index !== -1 && (typeof replacement == "function" && (replacement = replacement(string, index, original)), string !== replacement && this.overwrite(index, index + string.length, replacement)), this;
3006
+ }
3007
+ /**
3008
+ * String replacement with RegExp or string.
3009
+ */
3010
+ replace(searchValue, replacement) {
3011
+ return typeof searchValue == "string" ? this._replaceString(searchValue, replacement) : this._replaceRegexp(searchValue, replacement);
3012
+ }
3013
+ /** @internal */
3014
+ _replaceAllString(string, replacement) {
3015
+ let { original } = this, stringLength = string.length;
3016
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
3017
+ let previous = original.slice(index, index + stringLength), _replacement = typeof replacement == "function" ? replacement(previous, index, original) : replacement;
3018
+ previous !== _replacement && this.overwrite(index, index + stringLength, _replacement);
3019
+ }
3020
+ return this;
3021
+ }
3022
+ /**
3023
+ * Same as `s.replace`, but replace all matched strings instead of just one.
3024
+ */
3025
+ replaceAll(searchValue, replacement) {
3026
+ if (typeof searchValue == "string") return this._replaceAllString(searchValue, replacement);
3027
+ if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
3028
+ return this._replaceRegexp(searchValue, replacement);
3029
+ }
3030
+ };
3031
+
3032
+ // src/plugins/inject-export-order-plugin.ts
3033
+ async function injectExportOrderPlugin() {
3034
+ let { createFilter } = await import("vite"), include = [/\.stories\.([tj])sx?$/, /(stories|story).mdx$/], filter = createFilter(include);
3035
+ return {
3036
+ name: "storybook:inject-export-order-plugin",
3037
+ // This should only run after the typescript has been transpiled
3038
+ enforce: "post",
3039
+ transform: {
3040
+ filter: { id: include },
3041
+ async handler(code, id) {
3042
+ if (!filter(id))
3043
+ return;
3044
+ let [, exports] = await parse3(code), exportNames = exports.map((e) => code.substring(e.s, e.e));
3045
+ if (exportNames.includes("__namedExportsOrder"))
3046
+ return;
3047
+ let s = new MagicString(code), orderedExports = exportNames.filter((e) => e !== "default");
3048
+ return s.append(`;export const __namedExportsOrder = ${JSON.stringify(orderedExports)};`), {
3049
+ code: s.toString(),
3050
+ map: s.generateMap({ hires: !0, source: id }).toString()
3051
+ };
3052
+ }
3053
+ }
3054
+ };
3055
+ }
3056
+
3057
+ // src/plugins/strip-story-hmr-boundaries.ts
3058
+ async function stripStoryHMRBoundary() {
3059
+ let { createFilter } = await import("vite"), include = /\.stories\.(tsx?|jsx?|svelte|vue)$/, filter = createFilter(include);
3060
+ return {
3061
+ name: "storybook:strip-hmr-boundary-plugin",
3062
+ enforce: "post",
3063
+ transform: {
3064
+ filter: { id: include },
3065
+ async handler(src, id) {
3066
+ if (!filter(id))
3067
+ return;
3068
+ let s = new MagicString(src);
3069
+ return s.replace(/import\.meta\.hot\.accept\w*/, "(function hmrBoundaryNoop(){})"), {
3070
+ code: s.toString(),
3071
+ map: s.generateMap({ hires: !0, source: id }).toString()
3072
+ };
3073
+ }
3074
+ }
3075
+ };
3076
+ }
3077
+
3078
+ // src/plugins/storybook-entry-plugin.ts
3079
+ async function storybookEntryPlugin(options) {
3080
+ return [
3081
+ // Pre-enforcement: handles virtual module resolution and loading (must run first)
3082
+ codeGeneratorPlugin(options),
3083
+ // Post-enforcement: injects __namedExportsOrder after TypeScript transpilation
3084
+ await injectExportOrderPlugin(),
3085
+ // Post-enforcement: removes import.meta.hot.accept() from story files
3086
+ await stripStoryHMRBoundary()
3087
+ ];
3088
+ }
3089
+
3090
+ // src/plugins/webpack-stats-plugin.ts
3091
+ import { relative as relative3 } from "node:path";
3092
+
3093
+ // ../../../node_modules/slash/index.js
3094
+ function slash(path3) {
3095
+ return path3.startsWith("\\\\?\\") ? path3 : path3.replace(/\\/g, "/");
3096
+ }
3097
+
3098
+ // src/plugins/webpack-stats-plugin.ts
3099
+ function stripQueryParams(filePath) {
3100
+ return filePath.split("?")[0];
3101
+ }
3102
+ function isUserCode(moduleName) {
3103
+ return moduleName ? Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(moduleName)) ? !0 : !moduleName.startsWith("vite/") && !moduleName.startsWith("\0") && moduleName !== "react/jsx-runtime" : !1;
3104
+ }
3105
+ function pluginWebpackStats({ workingDir }) {
3106
+ function normalize3(filename2) {
3107
+ if (filename2.startsWith("virtual:"))
3108
+ return `/${filename2}`;
3109
+ if (Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(filename2)))
3110
+ return `/${getOriginalVirtualModuleId(filename2)}`;
3111
+ {
3112
+ let relativePath = relative3(workingDir, stripQueryParams(filename2));
3113
+ return `./${slash(relativePath)}`;
3114
+ }
3115
+ }
3116
+ function createReasons(importers) {
3117
+ return (importers || []).map((i) => ({ moduleName: normalize3(i) }));
3118
+ }
3119
+ function createStatsMapModule(filename2, importers) {
3120
+ return {
3121
+ id: filename2,
3122
+ name: filename2,
3123
+ reasons: createReasons(importers)
3124
+ };
3125
+ }
3126
+ let statsMap = /* @__PURE__ */ new Map();
3127
+ return {
3128
+ name: "storybook:rollup-plugin-webpack-stats",
3129
+ // We want this to run after the vite build plugins (https://vitejs.dev/guide/api-plugin.html#plugin-ordering)
3130
+ enforce: "post",
3131
+ moduleParsed: function(mod) {
3132
+ isUserCode(mod.id) && mod.importedIds.concat(mod.dynamicallyImportedIds).filter((name) => isUserCode(name)).forEach((depIdUnsafe) => {
3133
+ let depId = normalize3(depIdUnsafe);
3134
+ if (!statsMap.has(depId)) {
3135
+ statsMap.set(depId, createStatsMapModule(depId, [mod.id]));
3136
+ return;
3137
+ }
3138
+ let m = statsMap.get(depId);
3139
+ m && (m.reasons = (m.reasons ?? []).concat(createReasons([mod.id])).filter((r) => r.moduleName !== depId), statsMap.set(depId, m));
3140
+ });
3141
+ },
3142
+ storybookGetStats() {
3143
+ let stats = { modules: Array.from(statsMap.values()) };
3144
+ return { ...stats, toJson: () => stats };
3145
+ }
3146
+ };
3147
+ }
3148
+
3149
+ // src/plugins/storybook-external-globals-plugin.ts
3150
+ import { existsSync as existsSync3 } from "node:fs";
3151
+ import { mkdir, writeFile } from "node:fs/promises";
3152
+ import { dirname as dirname5, join as join6 } from "node:path";
3153
+ import { globalsNameReferenceMap } from "storybook/internal/preview/globals";
3154
+
3155
+ // ../../../node_modules/empathic/package.mjs
3156
+ import { env } from "node:process";
3157
+ import { dirname as dirname4, join as join5 } from "node:path";
3158
+ import { existsSync as existsSync2, mkdirSync } from "node:fs";
3159
+
3160
+ // ../../../node_modules/empathic/access.mjs
3161
+ import { accessSync, constants } from "node:fs";
3162
+ function ok(path3, mode) {
3163
+ try {
3164
+ return accessSync(path3, mode), !0;
3165
+ } catch {
3166
+ return !1;
3167
+ }
3168
+ }
3169
+ function writable(path3) {
3170
+ return ok(path3, constants.W_OK);
3171
+ }
3172
+
3173
+ // ../../../node_modules/empathic/find.mjs
3174
+ import { join as join4 } from "node:path";
3175
+ import { existsSync, statSync } from "node:fs";
3176
+
3177
+ // ../../../node_modules/empathic/walk.mjs
3178
+ import { dirname as dirname3 } from "node:path";
3179
+
3180
+ // ../../../node_modules/empathic/resolve.mjs
3181
+ import { isAbsolute as isAbsolute3, join as join3, resolve as resolve3 } from "node:path";
3182
+ function absolute(input, root) {
3183
+ return isAbsolute3(input) ? input : resolve3(root || ".", input);
3184
+ }
3185
+
3186
+ // ../../../node_modules/empathic/walk.mjs
3187
+ function up(base, options) {
3188
+ let { last, cwd: cwd2 } = options || {}, tmp = absolute(base, cwd2), root = absolute(last || "/", cwd2), prev, arr = [];
3189
+ for (; prev !== root && (arr.push(tmp), tmp = dirname3(prev = tmp), tmp !== prev); )
3190
+ ;
3191
+ return arr;
3192
+ }
3193
+
3194
+ // ../../../node_modules/empathic/find.mjs
3195
+ function up2(name, options) {
3196
+ let dir, tmp, start = options && options.cwd || "";
3197
+ for (dir of up(start, options))
3198
+ if (tmp = join4(dir, name), existsSync(tmp)) return tmp;
3199
+ }
3200
+
3201
+ // ../../../node_modules/empathic/package.mjs
3202
+ function up3(options) {
3203
+ return up2("package.json", options);
3204
+ }
3205
+ function cache(name, options) {
3206
+ options = options || {};
3207
+ let dir = env.CACHE_DIR;
3208
+ if (!dir || /^(1|0|true|false)$/.test(dir)) {
3209
+ let pkg = up3(options);
3210
+ if (dir = pkg && dirname4(pkg)) {
3211
+ let mods = join5(dir, "node_modules"), exists = existsSync2(mods);
3212
+ if (!writable(exists ? mods : dir)) return;
3213
+ dir = join5(mods, ".cache");
3214
+ }
3215
+ }
3216
+ if (dir)
3217
+ return dir = join5(dir, name), options.create && !existsSync2(dir) && mkdirSync(dir, { recursive: !0 }), dir;
3218
+ }
3219
+
3220
+ // src/plugins/storybook-external-globals-plugin.ts
3221
+ var escapeKeys = (key) => key.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), defaultImportRegExp = "import ([^*{}]+) from", emptyImportRegExp = /^import(?:\s*\{\s*\}\s*from)?\s*['"][^'"]+['"]\s*;?$/, replacementMap = /* @__PURE__ */ new Map([
3222
+ ["import ", "const "],
3223
+ ["import{", "const {"],
3224
+ ["* as ", ""],
3225
+ [" as ", ": "],
3226
+ [" from ", " = "],
3227
+ ["}from", "} ="]
3228
+ ]);
3229
+ async function storybookExternalGlobalsPlugin(options) {
3230
+ let build = await options.presets.apply("build"), externals = globalsNameReferenceMap;
3231
+ build?.test?.disableBlocks && (externals["@storybook/addon-docs/blocks"] = "__STORYBOOK_BLOCKS_EMPTY_MODULE__"), await init;
3232
+ let { mergeAlias } = await import("vite"), globalsList = Object.keys(externals), globalsCodeFilter = new RegExp(globalsList.map(escapeKeys).join("|"));
3233
+ return {
3234
+ name: "storybook:external-globals-plugin",
3235
+ enforce: "post",
3236
+ // In dev (serve), we set up aliases to files that we write into node_modules/.cache.
3237
+ async config(config, { command }) {
3238
+ if (command !== "serve")
3239
+ return;
3240
+ let newAlias = mergeAlias([], config.resolve?.alias), cachePath = cache("sb-vite-plugin-externals", { create: !0 }) ?? join6(process.cwd(), "node_modules", ".cache", "sb-vite-plugin-externals");
3241
+ return await Promise.all(
3242
+ Object.keys(externals).map(async (externalKey) => {
3243
+ let externalCachePath = join6(cachePath, `${externalKey}.js`);
3244
+ if (newAlias.push({ find: new RegExp(`^${externalKey}$`), replacement: externalCachePath }), !existsSync3(externalCachePath)) {
3245
+ let directory = dirname5(externalCachePath);
3246
+ await mkdir(directory, { recursive: !0 });
3247
+ }
3248
+ await writeFile(externalCachePath, `module.exports = ${externals[externalKey]};`);
3249
+ })
3250
+ ), {
3251
+ resolve: {
3252
+ alias: newAlias
3253
+ }
3254
+ };
3255
+ },
3256
+ // Replace imports with variables destructured from global scope
3257
+ transform: {
3258
+ filter: { code: globalsCodeFilter },
3259
+ async handler(code, id) {
3260
+ if (globalsList.every((glob) => !code.includes(glob)))
3261
+ return;
3262
+ let [imports] = parse3(code), src = new MagicString(code);
3263
+ return imports.forEach(({ n: path3, ss: startPosition, se: endPosition }) => {
3264
+ let packageName = path3;
3265
+ if (packageName && globalsList.includes(packageName)) {
3266
+ let importStatement = src.slice(startPosition, endPosition), transformedImport = rewriteImport(importStatement, externals, packageName);
3267
+ src.update(startPosition, endPosition, transformedImport);
3268
+ }
3269
+ }), {
3270
+ code: src.toString(),
3271
+ map: null
3272
+ };
3273
+ }
3274
+ }
3275
+ };
3276
+ }
3277
+ function getDefaultImportReplacement(match) {
3278
+ let matched = match.match(defaultImportRegExp);
3279
+ return matched && `const {default: ${matched[1]}} =`;
3280
+ }
3281
+ function getEmptyImportReplacement(importStatement, globalReference) {
3282
+ if (!emptyImportRegExp.test(importStatement.trim()))
3283
+ return;
3284
+ let statementTerminator = importStatement.trimEnd().endsWith(";") ? ";" : "";
3285
+ return `void ${globalReference}${statementTerminator}`;
3286
+ }
3287
+ function getSearchRegExp(packageName) {
3288
+ let staticKeys = [...replacementMap.keys()].map(escapeKeys), packageNameLiteral = `.${packageName}.`, dynamicImportExpression = `await import\\(.${packageName}.\\)`, lookup = [defaultImportRegExp, ...staticKeys, packageNameLiteral, dynamicImportExpression];
3289
+ return new RegExp(`(${lookup.join("|")})`, "g");
3290
+ }
3291
+ function rewriteImport(importStatement, globs, packageName) {
3292
+ let emptyImportReplacement = getEmptyImportReplacement(importStatement, globs[packageName]);
3293
+ if (emptyImportReplacement)
3294
+ return emptyImportReplacement;
3295
+ let search = getSearchRegExp(packageName);
3296
+ return importStatement.replace(
3297
+ search,
3298
+ (match) => replacementMap.get(match) ?? getDefaultImportReplacement(match) ?? globs[packageName]
3299
+ );
3300
+ }
3301
+
3302
+ // src/vite-config.ts
3303
+ var configEnvServe = {
3304
+ mode: "development",
3305
+ command: "serve",
3306
+ isSsrBuild: !1
3307
+ }, configEnvBuild = {
3308
+ mode: "production",
3309
+ command: "build",
3310
+ isSsrBuild: !1
3311
+ };
3312
+ async function loadUserViteConfig(options, type) {
3313
+ let configEnv = type === "development" ? configEnvServe : configEnvBuild, { loadConfigFromFile } = await import("vite"), { viteConfigPath, configLoader } = await getBuilderOptions(options), projectRoot = resolve4(options.configDir, "..");
3314
+ return (await loadConfigFromFile(
3315
+ configEnv,
3316
+ viteConfigPath,
3317
+ projectRoot,
3318
+ void 0,
3319
+ void 0,
3320
+ configLoader
3321
+ ))?.config ?? {};
3322
+ }
3323
+ async function resolveVitePublicDir(options, type) {
3324
+ let { publicDir } = await loadUserViteConfig(options, type);
3325
+ if (publicDir === !1 || publicDir === "")
3326
+ return;
3327
+ let resolved = resolve4(options.configDir, "..", publicDir ?? "public");
3328
+ return existsSync4(resolved) ? resolved : void 0;
3329
+ }
3330
+ async function commonConfig(options, _type) {
3331
+ let { mergeConfig } = await import("vite"), projectRoot = resolve4(options.configDir, ".."), { build: buildProperty = void 0, ...userConfig } = await loadUserViteConfig(
3332
+ options,
3333
+ _type
3334
+ ), sbConfig = {
3335
+ configFile: !1,
3336
+ plugins: await pluginConfig(options),
3337
+ root: projectRoot,
3338
+ // Allow storybook deployed as subfolder. See https://github.com/storybookjs/builder-vite/issues/238
3339
+ base: "./",
3340
+ ...options.cacheKey ? { cacheDir: resolvePathInStorybookCache("sb-vite", options.cacheKey) } : {},
3341
+ // Pass build.target option from user's vite config
3342
+ build: {
3343
+ target: buildProperty?.target
3344
+ }
3345
+ };
3346
+ return mergeConfig(userConfig, sbConfig);
3347
+ }
3348
+ async function pluginConfig(options) {
3349
+ return [
3350
+ // Shared core plugins (resolve conditions, envPrefix, fs.allow, externals, env vars, etc.)
3351
+ ...await viteCorePlugins([], options),
3352
+ await storybookExternalGlobalsPlugin(options),
3353
+ // Entry plugin: virtual modules for stories, addon setup, and main app entry
3354
+ ...await storybookEntryPlugin(options),
3355
+ // Builder-specific: webpack-compatible stats for turbosnap/chromatic
3356
+ pluginWebpackStats({ workingDir: process.cwd() })
3357
+ ];
3358
+ }
3359
+
3360
+ // src/preset.ts
3361
+ var optimizeViteDeps = ["storybook/internal/preview/runtime"];
3362
+ async function viteCorePlugins(_, options) {
3363
+ let previewConfigPath = findConfigFile("preview", options.configDir);
3364
+ return [
3365
+ storybookProjectAnnotationsPlugin(options),
3366
+ ...storybookConfigPlugin({ configDir: options.configDir }),
3367
+ storybookOptimizeDepsPlugin(options),
3368
+ ...await storybookSanitizeEnvs(options),
3369
+ ...previewConfigPath ? [
3370
+ viteInjectMockerRuntime({ previewConfigPath }),
3371
+ viteMockPlugin({
3372
+ previewConfigPath,
3373
+ coreOptions: await options.presets.apply("core"),
3374
+ configDir: options.configDir
3375
+ })
3376
+ ] : []
3377
+ ];
3378
+ }
3379
+ var staticDirs = async (values = [], options) => {
3380
+ if (options.configType !== "PRODUCTION")
3381
+ return values;
3382
+ let publicDir = await resolveVitePublicDir(options, "build");
3383
+ return publicDir ? [...values, { from: publicDir, to: "/" }] : values;
3384
+ };
3385
+
3386
+ export {
3387
+ __commonJS,
3388
+ __toESM,
3389
+ bundlerOptionsKey,
3390
+ normalize,
3391
+ optimizeViteDeps,
3392
+ viteCorePlugins,
3393
+ staticDirs,
3394
+ commonConfig
3395
+ };