@storybook/builder-vite 11.0.0-beta.0 → 11.0.0-beta.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.
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_3a6f3307qob from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_3a6f3307qob from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_3a6f3307qob from "node:module";
1
+ import CJS_COMPAT_NODE_URL_9iuamdqi3ma from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_9iuamdqi3ma from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_9iuamdqi3ma from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_3a6f3307qob.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_3a6f3307qob.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_3a6f3307qob.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_9iuamdqi3ma.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_9iuamdqi3ma.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_9iuamdqi3ma.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -36,1190 +36,46 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  mod
37
37
  ));
38
38
 
39
- // ../../../node_modules/semver/internal/constants.js
40
- var require_constants = __commonJS({
41
- "../../../node_modules/semver/internal/constants.js"(exports, module) {
39
+ // ../../../node_modules/ts-dedent/dist/index.js
40
+ var require_dist = __commonJS({
41
+ "../../../node_modules/ts-dedent/dist/index.js"(exports) {
42
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;
43
+ Object.defineProperty(exports, "__esModule", { value: !0 });
44
+ exports.dedent = void 0;
45
+ function dedent5(templ) {
46
+ for (var values = [], _i = 1; _i < arguments.length; _i++)
47
+ values[_i - 1] = arguments[_i];
48
+ var strings = Array.from(typeof templ == "string" ? [templ] : templ);
49
+ strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
50
+ var indentLengths = strings.reduce(function(arr, str) {
51
+ var matches = str.match(/\n([\t ]+|(?!\s).)/g);
52
+ return matches ? arr.concat(matches.map(function(match) {
53
+ var _a, _b;
54
+ return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
55
+ })) : arr;
56
+ }, []);
57
+ if (indentLengths.length) {
58
+ var pattern_1 = new RegExp(`
59
+ [ ]{` + Math.min.apply(Math, indentLengths) + "}", "g");
60
+ strings = strings.map(function(str) {
61
+ return str.replace(pattern_1, `
62
+ `);
63
+ });
1153
64
  }
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
- };
65
+ strings[0] = strings[0].replace(/^\r?\n/, "");
66
+ var string = strings[0];
67
+ return values.forEach(function(value, i) {
68
+ var endentations = string.match(/(?:^|\n)( *)$/), endentation = endentations ? endentations[1] : "", indentedValue = value;
69
+ typeof value == "string" && value.includes(`
70
+ `) && (indentedValue = String(value).split(`
71
+ `).map(function(str, i2) {
72
+ return i2 === 0 ? str : "" + endentation + str;
73
+ }).join(`
74
+ `)), string += indentedValue + strings[i + 1];
75
+ }), string;
76
+ }
77
+ exports.dedent = dedent5;
78
+ exports.default = dedent5;
1223
79
  }
1224
80
  });
1225
81
 
@@ -1550,7 +406,7 @@ function filename(path3) {
1550
406
  }
1551
407
 
1552
408
  // src/codegen-project-annotations.ts
1553
- import { dedent } from "ts-dedent";
409
+ var import_ts_dedent = __toESM(require_dist(), 1);
1554
410
  async function generateProjectAnnotationsCode(options, projectRoot) {
1555
411
  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(
1556
412
  "previewAnnotations",
@@ -1571,7 +427,7 @@ function generateProjectAnnotationsCodeFromPreviews(options) {
1571
427
  variables.push(variable), imports.push(genImport(previewAnnotation, { name: "*", as: variable }));
1572
428
  }
1573
429
  let previewFileURL = previewAnnotationURLs[previewAnnotationURLs.length - 1], previewFileVariable = variables[variables.length - 1], previewFileImport = imports[imports.length - 1];
1574
- return options.isCsf4 ? dedent`
430
+ return options.isCsf4 ? import_ts_dedent.dedent`
1575
431
  ${previewFileImport}
1576
432
 
1577
433
  export function getProjectAnnotations(hmrPreviewAnnotationModules = []) {
@@ -1587,7 +443,7 @@ function generateProjectAnnotationsCodeFromPreviews(options) {
1587
443
  });
1588
444
  });
1589
445
  }
1590
- `.trim() : dedent`
446
+ `.trim() : import_ts_dedent.dedent`
1591
447
  import { composeConfigs } from 'storybook/preview-api';
1592
448
 
1593
449
  ${imports.join(`
@@ -1721,7 +577,7 @@ var ENTRY_PATH = "/vite-inject-mocker-entry.js", viteInjectMockerRuntime = (opti
1721
577
  transformIndexHtml(html) {
1722
578
  let headTag = html.match(/<head[^>]*>/);
1723
579
  if (headTag) {
1724
- let entryCode = `<script type="module" src="${viteConfig.command === "build" ? `.${ENTRY_PATH}` : ENTRY_PATH}"></script>`, headTagIndex = html.indexOf(headTag[0]);
580
+ let entryCode = `<script type="module" src="${viteConfig.command === "build" ? `.${ENTRY_PATH}` : `${viteConfig.base}${ENTRY_PATH.slice(1)}`}"></script>`, headTagIndex = html.indexOf(headTag[0]);
1725
581
  return html.slice(0, headTagIndex + headTag[0].length) + entryCode + html.slice(headTagIndex + headTag[0].length);
1726
582
  }
1727
583
  }
@@ -1889,7 +745,7 @@ function any(names, options) {
1889
745
  }
1890
746
 
1891
747
  // src/vite-config.ts
1892
- import { dedent as dedent4 } from "ts-dedent";
748
+ var import_ts_dedent4 = __toESM(require_dist(), 1);
1893
749
 
1894
750
  // src/plugins/code-generator-plugin.ts
1895
751
  import { readFileSync as readFileSync2 } from "node:fs";
@@ -2023,13 +879,12 @@ var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.ha
2023
879
  var isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
2024
880
 
2025
881
  // ../../core/src/shared/utils/module.ts
2026
- var import_semver = __toESM(require_semver2(), 1);
2027
882
  var importMetaResolve = (...args) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
2028
883
  "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"
2029
884
  ), pathToFileURL(args[0]).href) : import.meta.resolve(...args);
2030
885
 
2031
886
  // src/codegen-importfn-script.ts
2032
- import { dedent as dedent2 } from "ts-dedent";
887
+ var import_ts_dedent2 = __toESM(require_dist(), 1);
2033
888
  function generateImportFnScriptCode(index) {
2034
889
  let objectEntries = getUniqueImportPaths(index).map(
2035
890
  (importPath) => {
@@ -2039,7 +894,7 @@ function generateImportFnScriptCode(index) {
2039
894
  return [normalizedRelativePath, genDynamicImport(absolutePath)];
2040
895
  }
2041
896
  );
2042
- return dedent2`
897
+ return import_ts_dedent2.dedent`
2043
898
  const importers = ${genObjectFromRawEntries(objectEntries)};
2044
899
 
2045
900
  export async function importFn(path) {
@@ -2049,9 +904,9 @@ function generateImportFnScriptCode(index) {
2049
904
  }
2050
905
 
2051
906
  // src/codegen-modern-iframe-script.ts
907
+ var import_ts_dedent3 = __toESM(require_dist(), 1);
2052
908
  import { getFrameworkName as getFrameworkName2 } from "storybook/internal/common";
2053
909
  import { STORY_HOT_UPDATED } from "storybook/internal/core-events";
2054
- import { dedent as dedent3 } from "ts-dedent";
2055
910
  async function generateModernIframeScriptCode(options) {
2056
911
  let frameworkName = await getFrameworkName2(options);
2057
912
  return generateModernIframeScriptCodeFromPreviews({
@@ -2059,10 +914,10 @@ async function generateModernIframeScriptCode(options) {
2059
914
  });
2060
915
  }
2061
916
  async function generateModernIframeScriptCodeFromPreviews(options) {
2062
- let { frameworkName } = options, generateHMRHandler = () => frameworkName === "@storybook/web-components-vite" ? dedent3`
917
+ let { frameworkName } = options, generateHMRHandler = () => frameworkName === "@storybook/web-components-vite" ? import_ts_dedent3.dedent`
2063
918
  if (import.meta.hot) {
2064
919
  import.meta.hot.decline();
2065
- }`.trim() : dedent3`
920
+ }`.trim() : import_ts_dedent3.dedent`
2066
921
  if (import.meta.hot) {
2067
922
  import.meta.hot.on('vite:afterUpdate', () => {
2068
923
  window.__STORYBOOK_PREVIEW__.channel.emit('${STORY_HOT_UPDATED}');
@@ -2073,7 +928,7 @@ async function generateModernIframeScriptCodeFromPreviews(options) {
2073
928
  window.__STORYBOOK_PREVIEW__.onStoriesChanged({ importFn: newModule.importFn });
2074
929
  });
2075
930
  }`.trim();
2076
- return dedent3`
931
+ return import_ts_dedent3.dedent`
2077
932
  import { setup } from '${previewRuntimePath}';
2078
933
 
2079
934
  import '${SB_VIRTUAL_FILES.VIRTUAL_ADDON_SETUP_FILE}';
@@ -2110,7 +965,7 @@ async function generateAddonSetupCode() {
2110
965
 
2111
966
  // src/transform-iframe-html.ts
2112
967
  import { normalizeStories } from "storybook/internal/common";
2113
- async function transformIframeHtml(html, options) {
968
+ async function transformIframeHtml(html, options, base = "/") {
2114
969
  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"), security = await presets.apply("security"), coreOptions = await presets.apply("core"), stories = normalizeStories(await options.presets.apply("stories", [], options), {
2115
970
  configDir: options.configDir,
2116
971
  workingDir: process.cwd()
@@ -2129,7 +984,7 @@ async function transformIframeHtml(html, options) {
2129
984
  ).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 || "");
2130
985
  return configType === "DEVELOPMENT" ? transformedHtml.replace(
2131
986
  "virtual:/@storybook/builder-vite/vite-app.js",
2132
- `/@id/__x00__${SB_VIRTUAL_FILES.VIRTUAL_APP_FILE}`
987
+ `${base}@id/__x00__${SB_VIRTUAL_FILES.VIRTUAL_APP_FILE}`
2133
988
  ) : transformedHtml;
2134
989
  }
2135
990
 
@@ -2182,7 +1037,7 @@ function applyChunkedPreviewRuntime(config, useRolldown = shouldUseRolldownOptio
2182
1037
 
2183
1038
  // src/plugins/code-generator-plugin.ts
2184
1039
  function codeGeneratorPlugin(options) {
2185
- let iframePath = fileURLToPath3(importMetaResolve("@storybook/builder-vite/input/iframe.html")), iframeId, storyIndexGeneratorPromise = options.presets.apply("storyIndexGenerator");
1040
+ let iframePath = fileURLToPath3(importMetaResolve("@storybook/builder-vite/input/iframe.html")), iframeId, base = "/", storyIndexGeneratorPromise = options.presets.apply("storyIndexGenerator");
2186
1041
  return {
2187
1042
  name: "storybook:code-generator-plugin",
2188
1043
  enforce: "pre",
@@ -2205,7 +1060,7 @@ function codeGeneratorPlugin(options) {
2205
1060
  }
2206
1061
  },
2207
1062
  configResolved(config) {
2208
- iframeId = `${config.root}/iframe.html`;
1063
+ iframeId = `${config.root}/iframe.html`, base = config.base;
2209
1064
  },
2210
1065
  resolveId(source) {
2211
1066
  if (SB_VIRTUAL_FILE_IDS.includes(source))
@@ -2232,7 +1087,7 @@ function codeGeneratorPlugin(options) {
2232
1087
  },
2233
1088
  async transformIndexHtml(html, ctx) {
2234
1089
  if (ctx.path === "/iframe.html")
2235
- return transformIframeHtml(html, options);
1090
+ return transformIframeHtml(html, options, base);
2236
1091
  }
2237
1092
  };
2238
1093
  }
@@ -2353,7 +1208,7 @@ function encode(decoded) {
2353
1208
  return writer.flush();
2354
1209
  }
2355
1210
 
2356
- // node_modules/magic-string/dist/index.mjs
1211
+ // ../../../node_modules/magic-string/dist/index.mjs
2357
1212
  var BitSet = class BitSet2 {
2358
1213
  constructor(arg) {
2359
1214
  this.bits = arg instanceof BitSet2 ? arg.bits.slice() : [];
@@ -2364,9 +1219,19 @@ var BitSet = class BitSet2 {
2364
1219
  has(n2) {
2365
1220
  return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
2366
1221
  }
1222
+ forEach(fn) {
1223
+ let bits = this.bits;
1224
+ for (let w = 0; w < bits.length; w++) {
1225
+ let word = bits[w];
1226
+ for (; word; ) {
1227
+ let lowest = word & -word;
1228
+ fn((w << 5) + 31 - Math.clz32(lowest)), word ^= lowest;
1229
+ }
1230
+ }
1231
+ }
2367
1232
  }, Chunk = class Chunk2 {
2368
1233
  constructor(start, end, content) {
2369
- 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;
1234
+ this.start = start, this.end = end, this.original = content, this.intro = "", this.outro = "", this.content = content, this.storeName = !1, this.edited = !1, this.replacesUntil = -1, this.replacedFrom = -1, this.previous = null, this.next = null;
2370
1235
  }
2371
1236
  appendLeft(content) {
2372
1237
  this.outro += content;
@@ -2376,7 +1241,7 @@ var BitSet = class BitSet2 {
2376
1241
  }
2377
1242
  clone() {
2378
1243
  let chunk = new Chunk2(this.start, this.end, this.original);
2379
- return chunk.intro = this.intro, chunk.outro = this.outro, chunk.content = this.content, chunk.storeName = this.storeName, chunk.edited = this.edited, chunk;
1244
+ return chunk.intro = this.intro, chunk.outro = this.outro, chunk.content = this.content, chunk.storeName = this.storeName, chunk.edited = this.edited, chunk.replacesUntil = this.replacesUntil, chunk.replacedFrom = this.replacedFrom, chunk;
2380
1245
  }
2381
1246
  contains(index) {
2382
1247
  return this.start < index && index < this.end;
@@ -2403,13 +1268,13 @@ var BitSet = class BitSet2 {
2403
1268
  this.intro = content + this.intro;
2404
1269
  }
2405
1270
  reset() {
2406
- this.intro = "", this.outro = "", this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
1271
+ this.intro = "", this.outro = "", this.replacesUntil = -1, this.replacedFrom = -1, this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
2407
1272
  }
2408
1273
  split(index) {
2409
1274
  let sliceIndex = index - this.start, originalBefore = this.original.slice(0, sliceIndex), originalAfter = this.original.slice(sliceIndex);
2410
1275
  this.original = originalBefore;
2411
1276
  let newChunk = new Chunk2(index, this.end, originalAfter);
2412
- return newChunk.outro = this.outro, this.outro = "", this.end = index, this.edited ? (newChunk.edit("", !1, !0), this.content = "") : this.content = originalBefore, newChunk.next = this.next, newChunk.next && (newChunk.next.previous = newChunk), newChunk.previous = this, this.next = newChunk, newChunk;
1277
+ return newChunk.outro = this.outro, this.outro = "", this.end = index, this.edited ? (newChunk.edit("", !1, !0), newChunk.replacedFrom = this.replacedFrom) : this.content = originalBefore, newChunk.next = this.next, newChunk.next && (newChunk.next.previous = newChunk), newChunk.previous = this, this.next = newChunk, newChunk;
2413
1278
  }
2414
1279
  toString() {
2415
1280
  return this.intro + this.content + this.outro;
@@ -2558,10 +1423,27 @@ function isWordCode(code) {
2558
1423
  }
2559
1424
  var Mappings = class {
2560
1425
  constructor(hires, encoder = null) {
2561
- this.hires = hires, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.rawRangeMappings = [], this.rawRangeMappingsIndices = this.rawRangeMappings[this.generatedCodeLine] = [], this.encoder = encoder;
1426
+ this.hires = hires, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.rawRangeMappingsIndices = [], this.rawRangeMappings = hires === "experimental-range" ? [this.rawRangeMappingsIndices] : void 0, this.encoder = encoder;
2562
1427
  }
2563
1428
  nextLine() {
2564
- this.encoder === null ? (this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = []) : (this.encoder.endLine(this.rawSegments), this.rawSegments = [], this.generatedCodeLine += 1), this.generatedCodeColumn = 0, this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
1429
+ this.encoder === null ? (this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = []) : (this.encoder.endLine(this.rawSegments), this.rawSegments = [], this.generatedCodeLine += 1), this.generatedCodeColumn = 0, this.rawRangeMappings && (this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = []);
1430
+ }
1431
+ /**
1432
+ * Emits the mappings for one MagicString: its intro, every chunk (with the
1433
+ * chunk's own intro/outro) and its outro. `sourceIndex === -1` means the
1434
+ * string has no source of its own, so its content only advances the
1435
+ * generated position without mapping anything.
1436
+ */
1437
+ addMagicString(magicString, sourceIndex, nameIndex) {
1438
+ let { original } = magicString, locate = getLocator(original);
1439
+ magicString.intro && this.advance(magicString.intro), magicString.firstChunk.eachNext((chunk) => {
1440
+ if (chunk.intro.length && this.advance(chunk.intro), sourceIndex === -1) this.advance(chunk.content);
1441
+ else if (chunk.edited) {
1442
+ let name = chunk.storeName ? nameIndex.get(original.slice(chunk.start, chunk.replacesUntil)) : void 0;
1443
+ this.addEdit(sourceIndex, chunk.content, locate(chunk.start), name ?? -1);
1444
+ } else this.addUneditedChunk(sourceIndex, chunk, original, locate(chunk.start), magicString.sourcemapLocations);
1445
+ chunk.outro.length && this.advance(chunk.outro);
1446
+ }), magicString.outro && this.advance(magicString.outro);
2565
1447
  }
2566
1448
  addEdit(sourceIndex, content, loc, nameIndex) {
2567
1449
  if (content.length) {
@@ -2702,6 +1584,9 @@ function expandReplacement(replacement, matched, position, str, captures, namedC
2702
1584
  return result;
2703
1585
  }
2704
1586
  var MagicString = class MagicString2 {
1587
+ /**
1588
+ * Wraps `string` for editing; every index passed to the editing methods refers to this original string.
1589
+ */
2705
1590
  constructor(string, options = {}) {
2706
1591
  let chunk = new Chunk(0, string.length, string);
2707
1592
  Object.defineProperties(this, {
@@ -2751,7 +1636,7 @@ var MagicString = class MagicString2 {
2751
1636
  },
2752
1637
  storedNames: {
2753
1638
  writable: !0,
2754
- value: {}
1639
+ value: /* @__PURE__ */ new Set()
2755
1640
  },
2756
1641
  indentStr: {
2757
1642
  writable: !0,
@@ -2790,7 +1675,8 @@ var MagicString = class MagicString2 {
2790
1675
  * See also `s.prependLeft(...)`.
2791
1676
  */
2792
1677
  appendLeft(index, content) {
2793
- if (index = index + this.offset, typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
1678
+ if (index = this._resolveIndex(index), index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
1679
+ if (typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
2794
1680
  this._split(index);
2795
1681
  let chunk = this.byEnd.get(index);
2796
1682
  return chunk ? chunk.appendLeft(content) : this.intro += content, this;
@@ -2801,13 +1687,17 @@ var MagicString = class MagicString2 {
2801
1687
  * See also `s.prependRight(...)`.
2802
1688
  */
2803
1689
  appendRight(index, content) {
2804
- if (index = index + this.offset, typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
1690
+ if (index = this._resolveIndex(index), index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
1691
+ if (typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
2805
1692
  this._split(index);
2806
1693
  let chunk = this.byStart.get(index);
2807
1694
  return chunk ? chunk.appendRight(content) : this.outro += content, this;
2808
1695
  }
2809
1696
  /**
2810
- * Does what you'd expect.
1697
+ * Returns an independent copy: the chunk list, string-level intro/outro,
1698
+ * sourcemap locations, stored names, indent exclusion ranges, `offset`,
1699
+ * `filename` and `ignoreList` are all copied; later edits to either string
1700
+ * do not affect the other.
2811
1701
  */
2812
1702
  clone() {
2813
1703
  let cloned = new MagicString2(this.original, {
@@ -2820,7 +1710,7 @@ var MagicString = class MagicString2 {
2820
1710
  let nextOriginalChunk = originalChunk.next, nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
2821
1711
  nextClonedChunk && (clonedChunk.next = nextClonedChunk, nextClonedChunk.previous = clonedChunk, clonedChunk = nextClonedChunk), originalChunk = nextOriginalChunk;
2822
1712
  }
2823
- return cloned.lastChunk = clonedChunk, this.indentExclusionRanges && (cloned.indentExclusionRanges = this.indentExclusionRanges.slice()), cloned.sourcemapLocations = new BitSet(this.sourcemapLocations), cloned.storedNames = { ...this.storedNames }, cloned.intro = this.intro, cloned.outro = this.outro, cloned.hasMovedChunks = this.hasMovedChunks, cloned;
1713
+ return cloned.lastChunk = clonedChunk, this.indentExclusionRanges && (cloned.indentExclusionRanges = this.indentExclusionRanges.slice()), cloned.sourcemapLocations = new BitSet(this.sourcemapLocations), cloned.storedNames = new Set(this.storedNames), cloned.intro = this.intro, cloned.outro = this.outro, cloned.hasMovedChunks = this.hasMovedChunks, cloned;
2824
1714
  }
2825
1715
  /**
2826
1716
  * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
@@ -2849,11 +1739,8 @@ var MagicString = class MagicString2 {
2849
1739
  }
2850
1740
  /** @internal */
2851
1741
  _generateMappings(mappings) {
2852
- let names = Object.keys(this.storedNames), locate = getLocator(this.original);
2853
- return this.intro && mappings.advance(this.intro), this.firstChunk.eachNext((chunk) => {
2854
- let loc = locate(chunk.start);
2855
- chunk.intro.length && mappings.advance(chunk.intro), chunk.edited ? mappings.addEdit(0, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1) : mappings.addUneditedChunk(0, chunk, this.original, loc, this.sourcemapLocations), chunk.outro.length && mappings.advance(chunk.outro);
2856
- }), this.outro && mappings.advance(this.outro), names;
1742
+ let names = [...this.storedNames];
1743
+ return mappings.addMagicString(this, 0, new Map(names.map((name, i) => [name, i]))), names;
2857
1744
  }
2858
1745
  /** @internal */
2859
1746
  _mapProperties(options, names) {
@@ -2873,17 +1760,21 @@ var MagicString = class MagicString2 {
2873
1760
  _getRawIndentString() {
2874
1761
  return this._ensureindentStr(), this.indentStr;
2875
1762
  }
1763
+ /**
1764
+ * Returns the indentation string guessed from the original content, falling back to a single tab character.
1765
+ * This is the value `s.indent()` uses when no prefix is supplied.
1766
+ */
2876
1767
  getIndentString() {
2877
- return this._ensureindentStr(), this.indentStr === null ? " " : this.indentStr;
1768
+ return this._ensureindentStr(), this.indentStr ?? " ";
2878
1769
  }
2879
1770
  indent(indentStr, options) {
2880
1771
  let pattern = /^[^\r\n]/gm;
2881
1772
  if (isObject(indentStr) && (options = indentStr, indentStr = void 0), indentStr === void 0 && (this._ensureindentStr(), indentStr = this.indentStr || " "), indentStr === "") return this;
2882
1773
  let resolvedIndentStr = indentStr;
2883
1774
  options = options || {};
2884
- let isExcluded = {};
1775
+ let isExcluded = new BitSet();
2885
1776
  options.exclude && (typeof options.exclude[0] == "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
2886
- for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = !0;
1777
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded.add(i);
2887
1778
  });
2888
1779
  let shouldIndentNextCharacter = options.indentStart !== !1, indentPiece = (str) => {
2889
1780
  if (str === "") return str;
@@ -2897,11 +1788,12 @@ var MagicString = class MagicString2 {
2897
1788
  };
2898
1789
  for (; chunk; ) {
2899
1790
  let end = chunk.end;
2900
- if (isExcluded[chunk.start] || (chunk.intro = indentPiece(chunk.intro)), chunk.edited)
2901
- isExcluded[charIndex] || (chunk.content = indentPiece(chunk.content));
1791
+ if (isExcluded.has(chunk.start) || (chunk.intro = indentPiece(chunk.intro)), chunk.edited)
1792
+ isExcluded.has(chunk.start) ? chunk.content && (shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === `
1793
+ `) : chunk.content = indentPiece(chunk.content);
2902
1794
  else if (options.exclude)
2903
1795
  for (charIndex = chunk.start; charIndex < end; ) {
2904
- if (!isExcluded[charIndex]) {
1796
+ if (!isExcluded.has(charIndex)) {
2905
1797
  let char = this.original.charCodeAt(charIndex);
2906
1798
  char === NEWLINE_CHAR ? shouldIndentNextCharacter = !0 : char !== CR_CHAR && shouldIndentNextCharacter && indentAt(charIndex);
2907
1799
  }
@@ -2922,7 +1814,7 @@ var MagicString = class MagicString2 {
2922
1814
  }
2923
1815
  indentAt(charIndex), charIndex += 1;
2924
1816
  }
2925
- isExcluded[chunk.end - 1] || (chunk.outro = indentPiece(chunk.outro)), charIndex = chunk.end, chunk = chunk.next;
1817
+ isExcluded.has(chunk.end - 1) || (chunk.outro = indentPiece(chunk.outro)), charIndex = chunk.end, chunk = chunk.next;
2926
1818
  }
2927
1819
  return this.outro = indentPiece(this.outro), this;
2928
1820
  }
@@ -2948,10 +1840,13 @@ var MagicString = class MagicString2 {
2948
1840
  * mirroring the `appendLeft`/`appendRight` distinction.
2949
1841
  */
2950
1842
  move(start, end, index, affinity = "right") {
2951
- if (start = start + this.offset, end = end + this.offset, index = index + this.offset, start === end) return this;
1843
+ if (start = this._resolveIndex(start), end = this._resolveIndex(end), index = this._resolveIndex(index), start === end) return this;
1844
+ if (start < 0 || end > this.original.length || index < 0 || index > this.original.length) throw new MagicStringError(`range ${start}\u2013${end} is out of bounds`);
1845
+ if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
2952
1846
  if (index >= start && index <= end) throw new MagicStringError("cannot move a selection inside itself");
2953
1847
  this._split(start), this._split(end), this._split(index);
2954
1848
  let first = this.byStart.get(start), last = this.byEnd.get(end);
1849
+ if (!first || !last) throw new MagicStringError(`range ${start}\u2013${end} is out of bounds`);
2955
1850
  if (this.hasMovedChunks) {
2956
1851
  let cursor = first;
2957
1852
  for (; cursor !== last; )
@@ -2973,7 +1868,7 @@ var MagicString = class MagicString2 {
2973
1868
  if (last === this.lastChunk) return this;
2974
1869
  newLeft = this.lastChunk;
2975
1870
  }
2976
- 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.hasMovedChunks = !0, this;
1871
+ return oldLeft && (oldLeft.next = oldRight), oldRight && (oldRight.previous = oldLeft), newLeft && (newLeft.next = first), newRight && (newRight.previous = last), oldLeft || (this.firstChunk = oldRight), oldRight || (this.lastChunk = oldLeft, this.lastChunk.next = null), first.previous = newLeft, last.next = newRight || null, newLeft || (this.firstChunk = first), newRight || (this.lastChunk = last), this.hasMovedChunks = !0, this;
2977
1872
  }
2978
1873
  /**
2979
1874
  * Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
@@ -2986,6 +1881,11 @@ var MagicString = class MagicString2 {
2986
1881
  * It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
2987
1882
  */
2988
1883
  overwrite(start, end, content, options) {
1884
+ if (options === !0)
1885
+ return 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), this.update(start, end, content, {
1886
+ storeName: !0,
1887
+ overwrite: !0
1888
+ });
2989
1889
  let optionObject = typeof options == "object" && options ? options : {};
2990
1890
  return this.update(start, end, content, {
2991
1891
  ...optionObject,
@@ -3000,34 +1900,23 @@ var MagicString = class MagicString2 {
3000
1900
  * the content is overwritten, or anything that was appended/prepended to the range as well.
3001
1901
  */
3002
1902
  update(start, end, content, options) {
3003
- if (start = start + this.offset, end = end + this.offset, typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
3004
- if (this.original.length !== 0 && (start < 0 && (start = Math.max(0, start + this.original.length)), end < 0 && (end = Math.max(0, end + this.original.length))), start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
1903
+ if (start = this._resolveIndex(start), end = this._resolveIndex(end), typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
1904
+ if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
3005
1905
  if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
3006
1906
  if (start === end) throw new MagicStringError(`cannot overwrite a zero-length range at ${start}, use appendLeft() or prependRight()`);
3007
1907
  if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
3008
1908
  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 });
3009
1909
  let optionObject = typeof options == "object" && options ? options : {}, storeName = optionObject.storeName || !1, overwrite = optionObject.overwrite || !1;
3010
- if (storeName) {
3011
- let original = this.original.slice(start, end);
3012
- Object.defineProperty(this.storedNames, original, {
3013
- writable: !0,
3014
- value: !0,
3015
- enumerable: !0
3016
- });
3017
- }
3018
- let first = this.byStart.get(start), last = this.byEnd.get(end);
3019
- if (first) {
3020
- let chunk = first;
3021
- for (; chunk !== last; ) {
3022
- if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
3023
- chunk = chunk.next, chunk.edit("", !1);
3024
- }
3025
- first.edit(content, storeName, !overwrite);
3026
- } else {
3027
- let newChunk = new Chunk(start, end, "").edit(content, storeName);
3028
- last.next = newChunk, newChunk.previous = last;
1910
+ storeName && this.storedNames.add(this.original.slice(start, end));
1911
+ let first = this.byStart.get(start);
1912
+ for (let chunk = first; chunk.end < end; ) {
1913
+ let next = chunk.next;
1914
+ if (next === null || next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
1915
+ chunk = next;
3029
1916
  }
3030
- return this;
1917
+ for (let chunk = first.next; chunk !== null && chunk.start < end; chunk = chunk.next)
1918
+ chunk.edit("", !1, !overwrite), chunk.replacesUntil = -1, chunk.replacedFrom = start;
1919
+ return first.edit(content, storeName, !overwrite), first.replacesUntil = end, first.replacedFrom = -1, this;
3031
1920
  }
3032
1921
  /**
3033
1922
  * Prepends the string with the specified content.
@@ -3040,7 +1929,8 @@ var MagicString = class MagicString2 {
3040
1929
  * Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
3041
1930
  */
3042
1931
  prependLeft(index, content) {
3043
- if (index = index + this.offset, typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
1932
+ if (index = this._resolveIndex(index), index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
1933
+ if (typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
3044
1934
  this._split(index);
3045
1935
  let chunk = this.byEnd.get(index);
3046
1936
  return chunk ? chunk.prependLeft(content) : this.intro = content + this.intro, this;
@@ -3049,7 +1939,8 @@ var MagicString = class MagicString2 {
3049
1939
  * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
3050
1940
  */
3051
1941
  prependRight(index, content) {
3052
- if (index = index + this.offset, typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
1942
+ if (index = this._resolveIndex(index), index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
1943
+ if (typeof content != "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
3053
1944
  this._split(index);
3054
1945
  let chunk = this.byStart.get(index);
3055
1946
  return chunk ? chunk.prependRight(content) : this.outro = content + this.outro, this;
@@ -3062,28 +1953,31 @@ var MagicString = class MagicString2 {
3062
1953
  * Repeated removals and removals with partially overlapping ranges are allowed.
3063
1954
  */
3064
1955
  remove(start, end) {
3065
- if (start = start + this.offset, end = end + this.offset, this.original.length !== 0 && (start < 0 && (start = Math.max(0, start + this.original.length)), end < 0 && (end = Math.max(0, end + this.original.length))), start === end) return this;
1956
+ if (start = this._resolveIndex(start), end = this._resolveIndex(end), start === end) return this;
3066
1957
  if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}\u2013${end} is out of bounds`);
3067
1958
  if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
3068
1959
  this._split(start), this._split(end);
3069
1960
  let chunk = this.byStart.get(start);
3070
1961
  for (; chunk; )
3071
- chunk.start > start && (chunk.intro = ""), chunk.end < end && (chunk.outro = ""), chunk.edit("", !1, !0), chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
1962
+ chunk.start > start && (chunk.intro = ""), chunk.end < end && (chunk.outro = ""), chunk.edit("", !1, !0), chunk.replacesUntil = -1, chunk.replacedFrom = -1, chunk = end > chunk.end ? this.byStart.get(chunk.end) : void 0;
3072
1963
  return this;
3073
1964
  }
3074
1965
  /**
3075
1966
  * Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
3076
1967
  */
3077
1968
  reset(start, end) {
3078
- if (start = start + this.offset, end = end + this.offset, this.original.length !== 0 && (start < 0 && (start = Math.max(0, start + this.original.length)), end < 0 && (end = Math.max(0, end + this.original.length))), start === end) return this;
1969
+ if (start = this._resolveIndex(start), end = this._resolveIndex(end), start === end) return this;
3079
1970
  if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}\u2013${end} is out of bounds`);
3080
1971
  if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
3081
1972
  this._split(start), this._split(end);
3082
1973
  let chunk = this.byStart.get(start);
3083
1974
  for (; chunk; )
3084
- chunk.reset(), chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
1975
+ chunk.reset(), chunk = end > chunk.end ? this.byStart.get(chunk.end) : void 0;
3085
1976
  return this;
3086
1977
  }
1978
+ /**
1979
+ * Returns the last character of the generated string, or `''` if it is empty.
1980
+ */
3087
1981
  lastChar() {
3088
1982
  if (this.outro.length) return this.outro[this.outro.length - 1];
3089
1983
  let chunk = this.lastChunk;
@@ -3095,37 +1989,48 @@ var MagicString = class MagicString2 {
3095
1989
  }
3096
1990
  return this.intro.length ? this.intro[this.intro.length - 1] : "";
3097
1991
  }
1992
+ /**
1993
+ * Returns everything after the last newline in the generated string, or the whole string if there is no newline.
1994
+ */
3098
1995
  lastLine() {
3099
1996
  let lineIndex = this.outro.lastIndexOf(n);
3100
- if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
1997
+ if (lineIndex !== -1) return this.outro.slice(lineIndex + 1);
3101
1998
  let lineStr = this.outro, chunk = this.lastChunk;
3102
1999
  for (; chunk; ) {
3103
2000
  if (chunk.outro.length > 0) {
3104
- if (lineIndex = chunk.outro.lastIndexOf(n), lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
2001
+ if (lineIndex = chunk.outro.lastIndexOf(n), lineIndex !== -1) return chunk.outro.slice(lineIndex + 1) + lineStr;
3105
2002
  lineStr = chunk.outro + lineStr;
3106
2003
  }
3107
2004
  if (chunk.content.length > 0) {
3108
- if (lineIndex = chunk.content.lastIndexOf(n), lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
2005
+ if (lineIndex = chunk.content.lastIndexOf(n), lineIndex !== -1) return chunk.content.slice(lineIndex + 1) + lineStr;
3109
2006
  lineStr = chunk.content + lineStr;
3110
2007
  }
3111
2008
  if (chunk.intro.length > 0) {
3112
- if (lineIndex = chunk.intro.lastIndexOf(n), lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
2009
+ if (lineIndex = chunk.intro.lastIndexOf(n), lineIndex !== -1) return chunk.intro.slice(lineIndex + 1) + lineStr;
3113
2010
  lineStr = chunk.intro + lineStr;
3114
2011
  }
3115
2012
  chunk = chunk.previous;
3116
2013
  }
3117
- return lineIndex = this.intro.lastIndexOf(n), lineIndex !== -1 ? this.intro.substr(lineIndex + 1) + lineStr : this.intro + lineStr;
2014
+ return lineIndex = this.intro.lastIndexOf(n), lineIndex !== -1 ? this.intro.slice(lineIndex + 1) + lineStr : this.intro + lineStr;
3118
2015
  }
3119
2016
  /**
3120
- * Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
3121
- * Throws error if the indices are for characters that were already removed.
2017
+ * Returns the content of the generated string that corresponds to the slice
2018
+ * between `start` and `end` of the original string, walking the generated
2019
+ * string from the chunk holding `start` to the chunk holding `end`. Throws
2020
+ * if either index falls inside replaced content. After `move()`, a range
2021
+ * whose end now comes before its start in the output yields `''`.
3122
2022
  */
3123
2023
  slice(start = 0, end = this.original.length - this.offset) {
3124
- start = start + this.offset, end = end + this.offset, this.original.length !== 0 && (start < 0 && (start = Math.max(0, start + this.original.length)), end < 0 && (end = Math.max(0, end + this.original.length)));
3125
- let result = "", chunk = this.firstChunk;
3126
- for (; chunk && (chunk.start > start || chunk.end <= start); ) {
3127
- if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0) return result;
3128
- chunk = chunk.next;
2024
+ start = this._resolveIndex(start), end = this._resolveIndex(end);
2025
+ let result = "", chunk;
2026
+ if (this.hasMovedChunks)
2027
+ for (chunk = this.firstChunk; chunk && (chunk.start > start || chunk.end <= start); ) {
2028
+ if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0) return result;
2029
+ chunk = chunk.next;
2030
+ }
2031
+ else {
2032
+ if (start >= end) return result;
2033
+ chunk = this._chunkAt(start);
3129
2034
  }
3130
2035
  if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
3131
2036
  let startChunk = chunk;
@@ -3144,7 +2049,34 @@ var MagicString = class MagicString2 {
3144
2049
  */
3145
2050
  snip(start, end) {
3146
2051
  let clone = this.clone();
3147
- return clone.remove(0, start), clone.remove(end, clone.original.length), clone;
2052
+ return clone.remove(-clone.offset, start), clone.remove(end, clone.original.length - clone.offset), clone;
2053
+ }
2054
+ /**
2055
+ * Applies `offset`, resolves a negative index from the end of `original` as
2056
+ * `update`/`remove` always have, and rejects anything that is not an integer.
2057
+ * Bounds are checked by the caller, because the methods report them differently.
2058
+ *
2059
+ * @internal
2060
+ */
2061
+ _resolveIndex(index) {
2062
+ let resolved = index + this.offset;
2063
+ if (!Number.isInteger(resolved)) throw new MagicStringError(`index must be an integer, got ${index}`);
2064
+ return resolved < 0 && this.original.length !== 0 ? Math.max(0, resolved + this.original.length) : resolved;
2065
+ }
2066
+ /**
2067
+ * The chunk whose original range holds `index` (`chunk.start <= index < chunk.end`),
2068
+ * or `undefined` when `index` is at or past the end. Searches from the last
2069
+ * visited chunk so that scans over nearby indices stay cheap.
2070
+ *
2071
+ * @internal
2072
+ */
2073
+ _chunkAt(index) {
2074
+ let chunk = this.byStart.get(index);
2075
+ if (chunk) return chunk;
2076
+ chunk = this.lastSearchedChunk;
2077
+ let searchForward = index >= chunk.end;
2078
+ for (; chunk && !chunk.contains(index); ) chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
2079
+ return chunk && (this.lastSearchedChunk = chunk), chunk;
3148
2080
  }
3149
2081
  /** @internal */
3150
2082
  _split(index) {
@@ -3186,6 +2118,11 @@ var MagicString = class MagicString2 {
3186
2118
  }
3187
2119
  return !(this.outro.length && this.outro.trim());
3188
2120
  }
2121
+ /**
2122
+ * Returns the length of the generated string, counting only content attached to the original characters.
2123
+ * Content outside the string body (`s.prepend()`/`s.append()`, and inserts before the first or after the last
2124
+ * character) is not counted, so this can differ from `s.toString().length`.
2125
+ */
3189
2126
  length() {
3190
2127
  let chunk = this.firstChunk, length = 0;
3191
2128
  for (; chunk; )
@@ -3211,7 +2148,11 @@ var MagicString = class MagicString2 {
3211
2148
  let chunk = this.lastChunk;
3212
2149
  do {
3213
2150
  let end = chunk.end, aborted = chunk.trimEnd(rx);
3214
- 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;
2151
+ if (chunk.end !== end) {
2152
+ let next = chunk.next;
2153
+ this.lastChunk === chunk && (this.lastChunk = next), this.byEnd.set(chunk.end, chunk), this.byStart.set(next.start, next), this.byEnd.set(next.end, next);
2154
+ }
2155
+ if (aborted) return !0;
3215
2156
  chunk = chunk.previous;
3216
2157
  } while (chunk);
3217
2158
  return this.intro = this.intro.replace(rx, ""), this.intro.length > 0;
@@ -3229,7 +2170,11 @@ var MagicString = class MagicString2 {
3229
2170
  let chunk = this.firstChunk;
3230
2171
  do {
3231
2172
  let end = chunk.end, aborted = chunk.trimStart(rx);
3232
- 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;
2173
+ if (chunk.end !== end) {
2174
+ let next = chunk.next;
2175
+ chunk === this.lastChunk && (this.lastChunk = next), this.byEnd.set(chunk.end, chunk), this.byStart.set(next.start, next), this.byEnd.set(next.end, next);
2176
+ }
2177
+ if (aborted) return !0;
3233
2178
  chunk = chunk.next;
3234
2179
  } while (chunk);
3235
2180
  return this.outro = this.outro.replace(rx, ""), this.outro.length > 0;
@@ -3266,28 +2211,27 @@ var MagicString = class MagicString2 {
3266
2211
  * @internal
3267
2212
  */
3268
2213
  _hasRemovedContent(start, end) {
3269
- let chunk = this.byStart.get(start);
3270
- if (!chunk) {
3271
- chunk = this.lastSearchedChunk;
3272
- let searchForward = start >= chunk.end;
3273
- for (; chunk && !chunk.contains(start); ) chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
3274
- chunk && (this.lastSearchedChunk = chunk);
2214
+ let atBoundary = this.byStart.get(start);
2215
+ if (atBoundary && start === end) {
2216
+ let previous = this.byEnd.get(start);
2217
+ return !!previous && previous.content === "" && atBoundary.content === "";
3275
2218
  }
2219
+ let chunk = this._chunkAt(start);
3276
2220
  for (; chunk && chunk.start < end; ) {
3277
- if (chunk.content === "") return !0;
2221
+ if (chunk.content === "" && (chunk.replacedFrom < start || this.byStart.get(chunk.replacedFrom).replacesUntil < chunk.end)) return !0;
3278
2222
  chunk = this.byStart.get(chunk.end);
3279
2223
  }
3280
2224
  return !1;
3281
2225
  }
3282
2226
  /** @internal */
3283
2227
  _replaceRegexp(searchValue, replacement) {
3284
- function getReplacement(match, str) {
3285
- return typeof replacement == "string" ? expandReplacement(replacement, match[0], match.index, str, match.slice(1), match.groups) : match.groups === void 0 ? replacement(match[0], ...match.slice(1), match.index, str) : replacement(match[0], ...match.slice(1), match.index, str, match.groups);
2228
+ function getReplacement(match, index, str) {
2229
+ return typeof replacement == "string" ? expandReplacement(replacement, match[0], index, str, match.slice(1), match.groups) : match.groups === void 0 ? replacement(match[0], ...match.slice(1), index, str) : replacement(match[0], ...match.slice(1), index, str, match.groups);
3286
2230
  }
3287
2231
  let replaceMatch = (match) => {
3288
2232
  if (match.index == null || this._hasRemovedContent(match.index, match.index + match[0].length)) return !1;
3289
- let replacement2 = getReplacement(match, this.original);
3290
- return replacement2 === match[0] || (match[0].length === 0 ? this.appendRight(match.index, replacement2) : this.overwrite(match.index, match.index + match[0].length, replacement2)), !0;
2233
+ let replacement2 = getReplacement(match, match.index, this.original);
2234
+ return replacement2 === match[0] || (match[0].length === 0 ? this.appendRight(match.index - this.offset, replacement2) : this.overwrite(match.index - this.offset, match.index + match[0].length - this.offset, replacement2)), !0;
3291
2235
  };
3292
2236
  if (searchValue.global) {
3293
2237
  searchValue.lastIndex = 0;
@@ -3309,7 +2253,7 @@ var MagicString = class MagicString2 {
3309
2253
  index = original.indexOf(string, index + string.length);
3310
2254
  continue;
3311
2255
  }
3312
- typeof replacement == "function" ? replacement = replacement(string, index, original) : replacement = expandReplacement(replacement, string, index, original, [], void 0), string !== replacement && (string.length === 0 ? this.appendRight(index, replacement) : this.overwrite(index, index + string.length, replacement));
2256
+ typeof replacement == "function" ? replacement = replacement(string, index, original) : replacement = expandReplacement(replacement, string, index, original, [], void 0), string !== replacement && (string.length === 0 ? this.appendRight(index - this.offset, replacement) : this.overwrite(index - this.offset, index + string.length - this.offset, replacement));
3313
2257
  break;
3314
2258
  }
3315
2259
  return this;
@@ -3327,14 +2271,14 @@ var MagicString = class MagicString2 {
3327
2271
  for (let index = 0; index <= original.length; index += 1) {
3328
2272
  if (this._hasRemovedContent(index, index)) continue;
3329
2273
  let _replacement = typeof replacement == "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
3330
- _replacement !== "" && this.appendRight(index, _replacement);
2274
+ _replacement !== "" && this.appendRight(index - this.offset, _replacement);
3331
2275
  }
3332
2276
  return this;
3333
2277
  }
3334
2278
  for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
3335
2279
  if (this._hasRemovedContent(index, index + stringLength)) continue;
3336
2280
  let previous = original.slice(index, index + stringLength), _replacement = typeof replacement == "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
3337
- previous !== _replacement && this.overwrite(index, index + stringLength, _replacement);
2281
+ previous !== _replacement && this.overwrite(index - this.offset, index + stringLength - this.offset, _replacement);
3338
2282
  }
3339
2283
  return this;
3340
2284
  }
@@ -3619,7 +2563,7 @@ function reportUnloadedUserViteConfig(configDir, projectRoot) {
3619
2563
  return;
3620
2564
  let unloadedConfig = normalize(found);
3621
2565
  warnOnce(
3622
- dedent4`
2566
+ import_ts_dedent4.dedent`
3623
2567
  No user Vite config was loaded: Storybook auto-discovers a Vite config file in "${projectRoot}" (the directory above your Storybook config dir "${configDir}"), and none was found there.
3624
2568
  A Vite config was found at "${unloadedConfig}", but it is outside of that directory and was not loaded.
3625
2569
  To load it, point the "viteConfigPath" builder option at it, e.g. core: { builder: { options: { viteConfigPath: '${unloadedConfig}' } } }.
@@ -3708,6 +2652,7 @@ var staticDirs = async (values = [], options) => {
3708
2652
  export {
3709
2653
  __commonJS,
3710
2654
  __toESM,
2655
+ require_dist,
3711
2656
  bundlerOptionsKey,
3712
2657
  normalize,
3713
2658
  optimizeViteDeps,