storybook 9.1.12 → 9.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/babel/index.cjs +22495 -21246
  2. package/dist/babel/index.d.ts +672 -336
  3. package/dist/babel/index.js +22534 -21285
  4. package/dist/bin/index.cjs +42 -43
  5. package/dist/bin/index.js +42 -43
  6. package/dist/cli/bin/index.cjs +1 -1
  7. package/dist/cli/bin/index.js +1 -1
  8. package/dist/cli/index.cjs +27120 -25868
  9. package/dist/cli/index.js +27267 -26015
  10. package/dist/common/index.cjs +42 -43
  11. package/dist/common/index.d.ts +0 -1
  12. package/dist/common/index.js +42 -43
  13. package/dist/components/index.cjs +4464 -4353
  14. package/dist/components/index.js +3290 -3181
  15. package/dist/core-server/index.cjs +7388 -7318
  16. package/dist/core-server/index.js +7597 -7529
  17. package/dist/core-server/presets/common-preset.cjs +20127 -19935
  18. package/dist/core-server/presets/common-preset.js +20203 -20011
  19. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.cjs +306 -518
  20. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +302 -525
  21. package/dist/csf-tools/index.cjs +150 -144
  22. package/dist/csf-tools/index.js +401 -395
  23. package/dist/manager/globals-runtime.js +16578 -16469
  24. package/dist/manager-api/index.cjs +1 -1
  25. package/dist/manager-api/index.js +1 -1
  26. package/dist/node-logger/index.cjs +71 -71
  27. package/dist/node-logger/index.js +71 -71
  28. package/dist/preview/runtime.js +240 -240
  29. package/dist/telemetry/index.cjs +1 -1
  30. package/dist/telemetry/index.js +1 -1
  31. package/dist/test/index.cjs +267 -267
  32. package/dist/test/index.js +240 -240
  33. package/package.json +1 -1
@@ -1,308 +1,93 @@
1
1
  "use strict";
2
- var wt = Object.create;
3
- var H = Object.defineProperty;
4
- var _t = Object.getOwnPropertyDescriptor;
5
- var vt = Object.getOwnPropertyNames;
6
- var Ct = Object.getPrototypeOf, St = Object.prototype.hasOwnProperty;
7
- var d = (u, t) => H(u, "name", { value: t, configurable: !0 });
8
- var xt = (u, t) => () => (t || u((t = { exports: {} }).exports, t), t.exports), kt = (u, t) => {
2
+ var E = Object.defineProperty;
3
+ var K = Object.getOwnPropertyDescriptor;
4
+ var z = Object.getOwnPropertyNames;
5
+ var H = Object.prototype.hasOwnProperty;
6
+ var u = (o, t) => E(o, "name", { value: t, configurable: !0 });
7
+ var V = (o, t) => {
9
8
  for (var e in t)
10
- H(u, e, { get: t[e], enumerable: !0 });
11
- }, lt = (u, t, e, i) => {
9
+ E(o, e, { get: t[e], enumerable: !0 });
10
+ }, Y = (o, t, e, i) => {
12
11
  if (t && typeof t == "object" || typeof t == "function")
13
- for (let n of vt(t))
14
- !St.call(u, n) && n !== e && H(u, n, { get: () => t[n], enumerable: !(i = _t(t, n)) || i.enumerable });
15
- return u;
12
+ for (let n of z(t))
13
+ !H.call(o, n) && n !== e && E(o, n, { get: () => t[n], enumerable: !(i = K(t, n)) || i.enumerable });
14
+ return o;
16
15
  };
17
- var Et = (u, t, e) => (e = u != null ? wt(Ct(u)) : {}, lt(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- t || !u || !u.__esModule ? H(e, "default", { value: u, enumerable: !0 }) : e,
23
- u
24
- )), It = (u) => lt(H({}, "__esModule", { value: !0 }), u);
25
-
26
- // ../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
27
- var ht = xt((Q, at) => {
28
- (function(u, t) {
29
- typeof Q == "object" && typeof at < "u" ? t(Q) : typeof define == "function" && define.amd ? define(["exports"], t) : (u = typeof globalThis <
30
- "u" ? globalThis : u || self, t(u.sourcemapCodec = {}));
31
- })(Q, function(u) {
32
- "use strict";
33
- let i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", n = new Uint8Array(64), o = new Uint8Array(128);
34
- for (let f = 0; f < i.length; f++) {
35
- let a = i.charCodeAt(f);
36
- n[f] = a, o[a] = f;
37
- }
38
- function r(f, a) {
39
- let s = 0, h = 0, g = 0;
40
- do {
41
- let _ = f.next();
42
- g = o[_], s |= (g & 31) << h, h += 5;
43
- } while (g & 32);
44
- let m = s & 1;
45
- return s >>>= 1, m && (s = -2147483648 | -s), a + s;
46
- }
47
- d(r, "decodeInteger");
48
- function l(f, a, s) {
49
- let h = a - s;
50
- h = h < 0 ? -h << 1 | 1 : h << 1;
51
- do {
52
- let g = h & 31;
53
- h >>>= 5, h > 0 && (g |= 32), f.write(n[g]);
54
- } while (h > 0);
55
- return a;
56
- }
57
- d(l, "encodeInteger");
58
- function c(f, a) {
59
- return f.pos >= a ? !1 : f.peek() !== 44;
60
- }
61
- d(c, "hasMoreVlq");
62
- let p = 1024 * 16, R = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
63
- decode(f) {
64
- return Buffer.from(f.buffer, f.byteOffset, f.byteLength).toString();
65
- }
66
- } : {
67
- decode(f) {
68
- let a = "";
69
- for (let s = 0; s < f.length; s++)
70
- a += String.fromCharCode(f[s]);
71
- return a;
72
- }
73
- };
74
- class D {
75
- static {
76
- d(this, "StringWriter");
77
- }
78
- constructor() {
79
- this.pos = 0, this.out = "", this.buffer = new Uint8Array(p);
80
- }
81
- write(a) {
82
- let { buffer: s } = this;
83
- s[this.pos++] = a, this.pos === p && (this.out += R.decode(s), this.pos = 0);
84
- }
85
- flush() {
86
- let { buffer: a, out: s, pos: h } = this;
87
- return h > 0 ? s + R.decode(a.subarray(0, h)) : s;
88
- }
89
- }
90
- class W {
91
- static {
92
- d(this, "StringReader");
93
- }
94
- constructor(a) {
95
- this.pos = 0, this.buffer = a;
96
- }
97
- next() {
98
- return this.buffer.charCodeAt(this.pos++);
99
- }
100
- peek() {
101
- return this.buffer.charCodeAt(this.pos);
102
- }
103
- indexOf(a) {
104
- let { buffer: s, pos: h } = this, g = s.indexOf(a, h);
105
- return g === -1 ? s.length : g;
106
- }
107
- }
108
- let it = [];
109
- function P(f) {
110
- let { length: a } = f, s = new W(f), h = [], g = [], m = 0;
111
- for (; s.pos < a; s.pos++) {
112
- m = r(s, m);
113
- let _ = r(s, 0);
114
- if (!c(s, a)) {
115
- let k = g.pop();
116
- k[2] = m, k[3] = _;
117
- continue;
118
- }
119
- let b = r(s, 0), w = r(s, 0) & 1 ? [m, _, 0, 0, b, r(s, 0)] : [m, _, 0, 0, b], x = it;
120
- if (c(s, a)) {
121
- x = [];
122
- do {
123
- let k = r(s, 0);
124
- x.push(k);
125
- } while (c(s, a));
126
- }
127
- w.vars = x, h.push(w), g.push(w);
128
- }
129
- return h;
130
- }
131
- d(P, "decodeOriginalScopes");
132
- function I(f) {
133
- let a = new D();
134
- for (let s = 0; s < f.length; )
135
- s = L(f, s, a, [0]);
136
- return a.flush();
137
- }
138
- d(I, "encodeOriginalScopes");
139
- function L(f, a, s, h) {
140
- let g = f[a], { 0: m, 1: _, 2: b, 3: S, 4: C, vars: w } = g;
141
- a > 0 && s.write(44), h[0] = l(s, m, h[0]), l(s, _, 0), l(s, C, 0);
142
- let x = g.length === 6 ? 1 : 0;
143
- l(s, x, 0), g.length === 6 && l(s, g[5], 0);
144
- for (let k of w)
145
- l(s, k, 0);
146
- for (a++; a < f.length; ) {
147
- let k = f[a], { 0: y, 1: E } = k;
148
- if (y > b || y === b && E >= S)
149
- break;
150
- a = L(f, a, s, h);
151
- }
152
- return s.write(44), h[0] = l(s, b, h[0]), l(s, S, 0), a;
153
- }
154
- d(L, "_encodeOriginalScopes");
155
- function j(f) {
156
- let { length: a } = f, s = new W(f), h = [], g = [], m = 0, _ = 0, b = 0, S = 0, C = 0, w = 0, x = 0, k = 0;
157
- do {
158
- let y = s.indexOf(";"), E = 0;
159
- for (; s.pos < y; s.pos++) {
160
- if (E = r(s, E), !c(s, y)) {
161
- let O = g.pop();
162
- O[2] = m, O[3] = E;
163
- continue;
164
- }
165
- let A = r(s, 0), J = A & 1, G = A & 2, K = A & 4, ot = null, nt = it, M;
166
- if (J) {
167
- let O = r(s, _);
168
- b = r(s, _ === O ? b : 0), _ = O, M = [m, E, 0, 0, O, b];
169
- } else
170
- M = [m, E, 0, 0];
171
- if (M.isScope = !!K, G) {
172
- let O = S, U = C;
173
- S = r(s, S);
174
- let z = O === S;
175
- C = r(s, z ? C : 0), w = r(s, z && U === C ? w : 0), ot = [S, C, w];
176
- }
177
- if (M.callsite = ot, c(s, y)) {
178
- nt = [];
179
- do {
180
- x = m, k = E;
181
- let O = r(s, 0), U;
182
- if (O < -1) {
183
- U = [[r(s, 0)]];
184
- for (let z = -1; z > O; z--) {
185
- let yt = x;
186
- x = r(s, x), k = r(s, x === yt ? k : 0);
187
- let bt = r(s, 0);
188
- U.push([bt, x, k]);
189
- }
190
- } else
191
- U = [[O]];
192
- nt.push(U);
193
- } while (c(s, y));
194
- }
195
- M.bindings = nt, h.push(M), g.push(M);
196
- }
197
- m++, s.pos = y + 1;
198
- } while (s.pos < a);
199
- return h;
200
- }
201
- d(j, "decodeGeneratedRanges");
202
- function $(f) {
203
- if (f.length === 0)
204
- return "";
205
- let a = new D();
206
- for (let s = 0; s < f.length; )
207
- s = T(f, s, a, [0, 0, 0, 0, 0, 0, 0]);
208
- return a.flush();
209
- }
210
- d($, "encodeGeneratedRanges");
211
- function T(f, a, s, h) {
212
- let g = f[a], { 0: m, 1: _, 2: b, 3: S, isScope: C, callsite: w, bindings: x } = g;
213
- h[0] < m ? (v(s, h[0], m), h[0] = m, h[1] = 0) : a > 0 && s.write(44), h[1] = l(s, g[1], h[1]);
214
- let k = (g.length === 6 ? 1 : 0) | (w ? 2 : 0) | (C ? 4 : 0);
215
- if (l(s, k, 0), g.length === 6) {
216
- let { 4: y, 5: E } = g;
217
- y !== h[2] && (h[3] = 0), h[2] = l(s, y, h[2]), h[3] = l(s, E, h[3]);
218
- }
219
- if (w) {
220
- let { 0: y, 1: E, 2: A } = g.callsite;
221
- y !== h[4] ? (h[5] = 0, h[6] = 0) : E !== h[5] && (h[6] = 0), h[4] = l(s, y, h[4]), h[5] = l(s, E, h[5]), h[6] = l(s, A, h[6]);
222
- }
223
- if (x)
224
- for (let y of x) {
225
- y.length > 1 && l(s, -y.length, 0);
226
- let E = y[0][0];
227
- l(s, E, 0);
228
- let A = m, J = _;
229
- for (let G = 1; G < y.length; G++) {
230
- let K = y[G];
231
- A = l(s, K[1], A), J = l(s, K[2], J), l(s, K[0], 0);
232
- }
233
- }
234
- for (a++; a < f.length; ) {
235
- let y = f[a], { 0: E, 1: A } = y;
236
- if (E > b || E === b && A >= S)
237
- break;
238
- a = T(f, a, s, h);
239
- }
240
- return h[0] < b ? (v(s, h[0], b), h[0] = b, h[1] = 0) : s.write(44), h[1] = l(s, S, h[1]), a;
241
- }
242
- d(T, "_encodeGeneratedRanges");
243
- function v(f, a, s) {
244
- do
245
- f.write(59);
246
- while (++a < s);
247
- }
248
- d(v, "catchupLine");
249
- function N(f) {
250
- let { length: a } = f, s = new W(f), h = [], g = 0, m = 0, _ = 0, b = 0, S = 0;
251
- do {
252
- let C = s.indexOf(";"), w = [], x = !0, k = 0;
253
- for (g = 0; s.pos < C; ) {
254
- let y;
255
- g = r(s, g), g < k && (x = !1), k = g, c(s, C) ? (m = r(s, m), _ = r(s, _), b = r(s, b), c(s, C) ? (S = r(s, S), y = [g, m, _, b, S]) :
256
- y = [g, m, _, b]) : y = [g], w.push(y), s.pos++;
257
- }
258
- x || B(w), h.push(w), s.pos = C + 1;
259
- } while (s.pos <= a);
260
- return h;
261
- }
262
- d(N, "decode");
263
- function B(f) {
264
- f.sort(F);
265
- }
266
- d(B, "sort");
267
- function F(f, a) {
268
- return f[0] - a[0];
269
- }
270
- d(F, "sortComparator");
271
- function mt(f) {
272
- let a = new D(), s = 0, h = 0, g = 0, m = 0;
273
- for (let _ = 0; _ < f.length; _++) {
274
- let b = f[_];
275
- if (_ > 0 && a.write(59), b.length === 0)
276
- continue;
277
- let S = 0;
278
- for (let C = 0; C < b.length; C++) {
279
- let w = b[C];
280
- C > 0 && a.write(44), S = l(a, w[0], S), w.length !== 1 && (s = l(a, w[1], s), h = l(a, w[2], h), g = l(a, w[3], g), w.length !== 4 &&
281
- (m = l(a, w[4], m)));
282
- }
283
- }
284
- return a.flush();
285
- }
286
- d(mt, "encode"), u.decode = N, u.decodeGeneratedRanges = j, u.decodeOriginalScopes = P, u.encode = mt, u.encodeGeneratedRanges = $, u.encodeOriginalScopes =
287
- I, Object.defineProperty(u, "__esModule", { value: !0 });
288
- });
289
- });
16
+ var J = (o) => Y(E({}, "__esModule", { value: !0 }), o);
290
17
 
291
18
  // src/core-server/presets/webpack/loaders/webpack-automock-loader.ts
292
- var qt = {};
293
- kt(qt, {
294
- default: () => gt
19
+ var gt = {};
20
+ V(gt, {
21
+ default: () => W
295
22
  });
296
- module.exports = It(qt);
23
+ module.exports = J(gt);
24
+
25
+ // ../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
26
+ var Q = 44, X = 59, D = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", $ = new Uint8Array(64), Z = new Uint8Array(128);
27
+ for (let o = 0; o < D.length; o++) {
28
+ let t = D.charCodeAt(o);
29
+ $[o] = t, Z[t] = o;
30
+ }
31
+ function w(o, t, e) {
32
+ let i = t - e;
33
+ i = i < 0 ? -i << 1 | 1 : i << 1;
34
+ do {
35
+ let n = i & 31;
36
+ i >>>= 5, i > 0 && (n |= 32), o.write($[n]);
37
+ } while (i > 0);
38
+ return t;
39
+ }
40
+ u(w, "encodeInteger");
41
+ var j = 1024 * 16, M = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
42
+ decode(o) {
43
+ return Buffer.from(o.buffer, o.byteOffset, o.byteLength).toString();
44
+ }
45
+ } : {
46
+ decode(o) {
47
+ let t = "";
48
+ for (let e = 0; e < o.length; e++)
49
+ t += String.fromCharCode(o[e]);
50
+ return t;
51
+ }
52
+ }, tt = class {
53
+ static {
54
+ u(this, "StringWriter");
55
+ }
56
+ constructor() {
57
+ this.pos = 0, this.out = "", this.buffer = new Uint8Array(j);
58
+ }
59
+ write(o) {
60
+ let { buffer: t } = this;
61
+ t[this.pos++] = o, this.pos === j && (this.out += M.decode(t), this.pos = 0);
62
+ }
63
+ flush() {
64
+ let { buffer: o, out: t, pos: e } = this;
65
+ return e > 0 ? t + M.decode(o.subarray(0, e)) : t;
66
+ }
67
+ };
68
+ function T(o) {
69
+ let t = new tt(), e = 0, i = 0, n = 0, r = 0;
70
+ for (let s = 0; s < o.length; s++) {
71
+ let l = o[s];
72
+ if (s > 0 && t.write(X), l.length === 0) continue;
73
+ let a = 0;
74
+ for (let h = 0; h < l.length; h++) {
75
+ let f = l[h];
76
+ h > 0 && t.write(Q), a = w(t, f[0], a), f.length !== 1 && (e = w(t, f[1], e), i = w(t, f[2], i), n = w(t, f[3], n), f.length !== 4 && (r =
77
+ w(t, f[4], r)));
78
+ }
79
+ }
80
+ return t.flush();
81
+ }
82
+ u(T, "encode");
297
83
 
298
84
  // ../node_modules/magic-string/dist/magic-string.es.mjs
299
- var ct = Et(ht(), 1);
300
- var X = class u {
85
+ var I = class o {
301
86
  static {
302
- d(this, "BitSet");
87
+ u(this, "BitSet");
303
88
  }
304
89
  constructor(t) {
305
- this.bits = t instanceof u ? t.bits.slice() : [];
90
+ this.bits = t instanceof o ? t.bits.slice() : [];
306
91
  }
307
92
  add(t) {
308
93
  this.bits[t >> 5] |= 1 << (t & 31);
@@ -310,9 +95,9 @@ var X = class u {
310
95
  has(t) {
311
96
  return !!(this.bits[t >> 5] & 1 << (t & 31));
312
97
  }
313
- }, Z = class u {
98
+ }, L = class o {
314
99
  static {
315
- d(this, "Chunk");
100
+ u(this, "Chunk");
316
101
  }
317
102
  constructor(t, e, i) {
318
103
  this.start = t, this.end = e, this.original = i, this.intro = "", this.outro = "", this.content = i, this.storeName = !1, this.edited = !1,
@@ -325,7 +110,7 @@ var X = class u {
325
110
  this.intro = this.intro + t;
326
111
  }
327
112
  clone() {
328
- let t = new u(this.start, this.end, this.original);
113
+ let t = new o(this.start, this.end, this.original);
329
114
  return t.intro = this.intro, t.outro = this.outro, t.content = this.content, t.storeName = this.storeName, t.edited = this.edited, t;
330
115
  }
331
116
  contains(t) {
@@ -356,9 +141,9 @@ var X = class u {
356
141
  split(t) {
357
142
  let e = t - this.start, i = this.original.slice(0, e), n = this.original.slice(e);
358
143
  this.original = i;
359
- let o = new u(t, this.end, n);
360
- return o.outro = this.outro, this.outro = "", this.end = t, this.edited ? (o.edit("", !1), this.content = "") : this.content = i, o.next =
361
- this.next, o.next && (o.next.previous = o), o.previous = this, this.next = o, o;
144
+ let r = new o(t, this.end, n);
145
+ return r.outro = this.outro, this.outro = "", this.end = t, this.edited ? (r.edit("", !1), this.content = "") : this.content = i, r.next =
146
+ this.next, r.next && (r.next.previous = r), r.previous = this, this.next = r, r;
362
147
  }
363
148
  toString() {
364
149
  return this.intro + this.content + this.outro;
@@ -383,45 +168,45 @@ var X = class u {
383
168
  } else if (this.edit("", void 0, !0), this.outro = this.outro.replace(t, ""), this.outro.length) return !0;
384
169
  }
385
170
  };
386
- function Lt() {
387
- return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (u) => globalThis.btoa(unescape(encodeURIComponent(u))) : typeof Buffer ==
388
- "function" ? (u) => Buffer.from(u, "utf-8").toString("base64") : () => {
171
+ function et() {
172
+ return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (o) => globalThis.btoa(unescape(encodeURIComponent(o))) : typeof Buffer ==
173
+ "function" ? (o) => Buffer.from(o, "utf-8").toString("base64") : () => {
389
174
  throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
390
175
  };
391
176
  }
392
- d(Lt, "getBtoa");
393
- var Pt = /* @__PURE__ */ Lt(), st = class {
177
+ u(et, "getBtoa");
178
+ var it = /* @__PURE__ */ et(), R = class {
394
179
  static {
395
- d(this, "SourceMap");
180
+ u(this, "SourceMap");
396
181
  }
397
182
  constructor(t) {
398
183
  this.version = 3, this.file = t.file, this.sources = t.sources, this.sourcesContent = t.sourcesContent, this.names = t.names, this.mappings =
399
- (0, ct.encode)(t.mappings), typeof t.x_google_ignoreList < "u" && (this.x_google_ignoreList = t.x_google_ignoreList), typeof t.debugId <
400
- "u" && (this.debugId = t.debugId);
184
+ T(t.mappings), typeof t.x_google_ignoreList < "u" && (this.x_google_ignoreList = t.x_google_ignoreList), typeof t.debugId < "u" && (this.
185
+ debugId = t.debugId);
401
186
  }
402
187
  toString() {
403
188
  return JSON.stringify(this);
404
189
  }
405
190
  toUrl() {
406
- return "data:application/json;charset=utf-8;base64," + Pt(this.toString());
191
+ return "data:application/json;charset=utf-8;base64," + it(this.toString());
407
192
  }
408
193
  };
409
- function Nt(u) {
410
- let t = u.split(`
411
- `), e = t.filter((o) => /^\t+/.test(o)), i = t.filter((o) => /^ {2,}/.test(o));
194
+ function nt(o) {
195
+ let t = o.split(`
196
+ `), e = t.filter((r) => /^\t+/.test(r)), i = t.filter((r) => /^ {2,}/.test(r));
412
197
  if (e.length === 0 && i.length === 0)
413
198
  return null;
414
199
  if (e.length >= i.length)
415
200
  return " ";
416
- let n = i.reduce((o, r) => {
417
- let l = /^ +/.exec(r)[0].length;
418
- return Math.min(l, o);
201
+ let n = i.reduce((r, s) => {
202
+ let l = /^ +/.exec(s)[0].length;
203
+ return Math.min(l, r);
419
204
  }, 1 / 0);
420
205
  return new Array(n + 1).join(" ");
421
206
  }
422
- d(Nt, "guessIndent");
423
- function Ot(u, t) {
424
- let e = u.split(/[/\\]/), i = t.split(/[/\\]/);
207
+ u(nt, "guessIndent");
208
+ function rt(o, t) {
209
+ let e = o.split(/[/\\]/), i = t.split(/[/\\]/);
425
210
  for (e.pop(); e[0] === i[0]; )
426
211
  e.shift(), i.shift();
427
212
  if (e.length) {
@@ -430,31 +215,31 @@ function Ot(u, t) {
430
215
  }
431
216
  return e.concat(i).join("/");
432
217
  }
433
- d(Ot, "getRelativePath");
434
- var Rt = Object.prototype.toString;
435
- function At(u) {
436
- return Rt.call(u) === "[object Object]";
218
+ u(rt, "getRelativePath");
219
+ var st = Object.prototype.toString;
220
+ function ot(o) {
221
+ return st.call(o) === "[object Object]";
437
222
  }
438
- d(At, "isObject");
439
- function ut(u) {
440
- let t = u.split(`
223
+ u(ot, "isObject");
224
+ function B(o) {
225
+ let t = o.split(`
441
226
  `), e = [];
442
227
  for (let i = 0, n = 0; i < t.length; i++)
443
228
  e.push(n), n += t[i].length + 1;
444
- return /* @__PURE__ */ d(function(n) {
445
- let o = 0, r = e.length;
446
- for (; o < r; ) {
447
- let p = o + r >> 1;
448
- n < e[p] ? r = p : o = p + 1;
449
- }
450
- let l = o - 1, c = n - e[l];
451
- return { line: l, column: c };
229
+ return /* @__PURE__ */ u(function(n) {
230
+ let r = 0, s = e.length;
231
+ for (; r < s; ) {
232
+ let h = r + s >> 1;
233
+ n < e[h] ? s = h : r = h + 1;
234
+ }
235
+ let l = r - 1, a = n - e[l];
236
+ return { line: l, column: a };
452
237
  }, "locate");
453
238
  }
454
- d(ut, "getLocator");
455
- var Dt = /\w/, rt = class {
239
+ u(B, "getLocator");
240
+ var lt = /\w/, A = class {
456
241
  static {
457
- d(this, "Mappings");
242
+ u(this, "Mappings");
458
243
  }
459
244
  constructor(t) {
460
245
  this.hires = t, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] =
@@ -462,35 +247,35 @@ var Dt = /\w/, rt = class {
462
247
  }
463
248
  addEdit(t, e, i, n) {
464
249
  if (e.length) {
465
- let o = e.length - 1, r = e.indexOf(`
250
+ let r = e.length - 1, s = e.indexOf(`
466
251
  `, 0), l = -1;
467
- for (; r >= 0 && o > r; ) {
468
- let p = [this.generatedCodeColumn, t, i.line, i.column];
469
- n >= 0 && p.push(n), this.rawSegments.push(p), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [],
470
- this.generatedCodeColumn = 0, l = r, r = e.indexOf(`
471
- `, r + 1);
252
+ for (; s >= 0 && r > s; ) {
253
+ let h = [this.generatedCodeColumn, t, i.line, i.column];
254
+ n >= 0 && h.push(n), this.rawSegments.push(h), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [],
255
+ this.generatedCodeColumn = 0, l = s, s = e.indexOf(`
256
+ `, s + 1);
472
257
  }
473
- let c = [this.generatedCodeColumn, t, i.line, i.column];
474
- n >= 0 && c.push(n), this.rawSegments.push(c), this.advance(e.slice(l + 1));
258
+ let a = [this.generatedCodeColumn, t, i.line, i.column];
259
+ n >= 0 && a.push(n), this.rawSegments.push(a), this.advance(e.slice(l + 1));
475
260
  } else this.pending && (this.rawSegments.push(this.pending), this.advance(e));
476
261
  this.pending = null;
477
262
  }
478
- addUneditedChunk(t, e, i, n, o) {
479
- let r = e.start, l = !0, c = !1;
480
- for (; r < e.end; ) {
481
- if (i[r] === `
263
+ addUneditedChunk(t, e, i, n, r) {
264
+ let s = e.start, l = !0, a = !1;
265
+ for (; s < e.end; ) {
266
+ if (i[s] === `
482
267
  `)
483
268
  n.line += 1, n.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn =
484
- 0, l = !0, c = !1;
269
+ 0, l = !0, a = !1;
485
270
  else {
486
- if (this.hires || l || o.has(r)) {
487
- let p = [this.generatedCodeColumn, t, n.line, n.column];
488
- this.hires === "boundary" ? Dt.test(i[r]) ? c || (this.rawSegments.push(p), c = !0) : (this.rawSegments.push(p), c = !1) : this.rawSegments.
489
- push(p);
271
+ if (this.hires || l || r.has(s)) {
272
+ let h = [this.generatedCodeColumn, t, n.line, n.column];
273
+ this.hires === "boundary" ? lt.test(i[s]) ? a || (this.rawSegments.push(h), a = !0) : (this.rawSegments.push(h), a = !1) : this.rawSegments.
274
+ push(h);
490
275
  }
491
276
  n.column += 1, this.generatedCodeColumn += 1, l = !1;
492
277
  }
493
- r += 1;
278
+ s += 1;
494
279
  }
495
280
  this.pending = null;
496
281
  }
@@ -505,17 +290,17 @@ var Dt = /\w/, rt = class {
505
290
  }
506
291
  this.generatedCodeColumn += e[e.length - 1].length;
507
292
  }
508
- }, V = `
509
- `, q = {
293
+ }, _ = `
294
+ `, b = {
510
295
  insertLeft: !1,
511
296
  insertRight: !1,
512
297
  storeName: !1
513
- }, tt = class u {
298
+ }, N = class o {
514
299
  static {
515
- d(this, "MagicString");
300
+ u(this, "MagicString");
516
301
  }
517
302
  constructor(t, e = {}) {
518
- let i = new Z(0, t.length, t);
303
+ let i = new L(0, t.length, t);
519
304
  Object.defineProperties(this, {
520
305
  original: { writable: !0, value: t },
521
306
  outro: { writable: !0, value: "" },
@@ -527,7 +312,7 @@ var Dt = /\w/, rt = class {
527
312
  byEnd: { writable: !0, value: {} },
528
313
  filename: { writable: !0, value: e.filename },
529
314
  indentExclusionRanges: { writable: !0, value: e.indentExclusionRanges },
530
- sourcemapLocations: { writable: !0, value: new X() },
315
+ sourcemapLocations: { writable: !0, value: new I() },
531
316
  storedNames: { writable: !0, value: {} },
532
317
  indentStr: { writable: !0, value: void 0 },
533
318
  ignoreList: { writable: !0, value: e.ignoreList },
@@ -554,31 +339,31 @@ var Dt = /\w/, rt = class {
554
339
  return i ? i.appendRight(e) : this.outro += e, this;
555
340
  }
556
341
  clone() {
557
- let t = new u(this.original, { filename: this.filename, offset: this.offset }), e = this.firstChunk, i = t.firstChunk = t.lastSearchedChunk =
342
+ let t = new o(this.original, { filename: this.filename, offset: this.offset }), e = this.firstChunk, i = t.firstChunk = t.lastSearchedChunk =
558
343
  e.clone();
559
344
  for (; e; ) {
560
345
  t.byStart[i.start] = i, t.byEnd[i.end] = i;
561
- let n = e.next, o = n && n.clone();
562
- o && (i.next = o, o.previous = i, i = o), e = n;
346
+ let n = e.next, r = n && n.clone();
347
+ r && (i.next = r, r.previous = i, i = r), e = n;
563
348
  }
564
349
  return t.lastChunk = i, this.indentExclusionRanges && (t.indentExclusionRanges = this.indentExclusionRanges.slice()), t.sourcemapLocations =
565
- new X(this.sourcemapLocations), t.intro = this.intro, t.outro = this.outro, t;
350
+ new I(this.sourcemapLocations), t.intro = this.intro, t.outro = this.outro, t;
566
351
  }
567
352
  generateDecodedMap(t) {
568
353
  t = t || {};
569
- let e = 0, i = Object.keys(this.storedNames), n = new rt(t.hires), o = ut(this.original);
570
- return this.intro && n.advance(this.intro), this.firstChunk.eachNext((r) => {
571
- let l = o(r.start);
572
- r.intro.length && n.advance(r.intro), r.edited ? n.addEdit(
354
+ let e = 0, i = Object.keys(this.storedNames), n = new A(t.hires), r = B(this.original);
355
+ return this.intro && n.advance(this.intro), this.firstChunk.eachNext((s) => {
356
+ let l = r(s.start);
357
+ s.intro.length && n.advance(s.intro), s.edited ? n.addEdit(
573
358
  e,
574
- r.content,
359
+ s.content,
575
360
  l,
576
- r.storeName ? i.indexOf(r.original) : -1
577
- ) : n.addUneditedChunk(e, r, this.original, l, this.sourcemapLocations), r.outro.length && n.advance(r.outro);
578
- }), {
361
+ s.storeName ? i.indexOf(s.original) : -1
362
+ ) : n.addUneditedChunk(e, s, this.original, l, this.sourcemapLocations), s.outro.length && n.advance(s.outro);
363
+ }), this.outro && n.advance(this.outro), {
579
364
  file: t.file ? t.file.split(/[/\\]/).pop() : void 0,
580
365
  sources: [
581
- t.source ? Ot(t.file || "", t.source) : t.file || ""
366
+ t.source ? rt(t.file || "", t.source) : t.file || ""
582
367
  ],
583
368
  sourcesContent: t.includeContent ? [this.original] : void 0,
584
369
  names: i,
@@ -587,10 +372,10 @@ var Dt = /\w/, rt = class {
587
372
  };
588
373
  }
589
374
  generateMap(t) {
590
- return new st(this.generateDecodedMap(t));
375
+ return new R(this.generateDecodedMap(t));
591
376
  }
592
377
  _ensureindentStr() {
593
- this.indentStr === void 0 && (this.indentStr = Nt(this.original));
378
+ this.indentStr === void 0 && (this.indentStr = nt(this.original));
594
379
  }
595
380
  _getRawIndentString() {
596
381
  return this._ensureindentStr(), this.indentStr;
@@ -600,33 +385,33 @@ var Dt = /\w/, rt = class {
600
385
  }
601
386
  indent(t, e) {
602
387
  let i = /^[^\r\n]/gm;
603
- if (At(t) && (e = t, t = void 0), t === void 0 && (this._ensureindentStr(), t = this.indentStr || " "), t === "") return this;
388
+ if (ot(t) && (e = t, t = void 0), t === void 0 && (this._ensureindentStr(), t = this.indentStr || " "), t === "") return this;
604
389
  e = e || {};
605
390
  let n = {};
606
- e.exclude && (typeof e.exclude[0] == "number" ? [e.exclude] : e.exclude).forEach((R) => {
607
- for (let D = R[0]; D < R[1]; D += 1)
608
- n[D] = !0;
391
+ e.exclude && (typeof e.exclude[0] == "number" ? [e.exclude] : e.exclude).forEach((f) => {
392
+ for (let C = f[0]; C < f[1]; C += 1)
393
+ n[C] = !0;
609
394
  });
610
- let o = e.indentStart !== !1, r = /* @__PURE__ */ d((p) => o ? `${t}${p}` : (o = !0, p), "replacer");
611
- this.intro = this.intro.replace(i, r);
612
- let l = 0, c = this.firstChunk;
613
- for (; c; ) {
614
- let p = c.end;
615
- if (c.edited)
616
- n[l] || (c.content = c.content.replace(i, r), c.content.length && (o = c.content[c.content.length - 1] === `
395
+ let r = e.indentStart !== !1, s = /* @__PURE__ */ u((h) => r ? `${t}${h}` : (r = !0, h), "replacer");
396
+ this.intro = this.intro.replace(i, s);
397
+ let l = 0, a = this.firstChunk;
398
+ for (; a; ) {
399
+ let h = a.end;
400
+ if (a.edited)
401
+ n[l] || (a.content = a.content.replace(i, s), a.content.length && (r = a.content[a.content.length - 1] === `
617
402
  `));
618
403
  else
619
- for (l = c.start; l < p; ) {
404
+ for (l = a.start; l < h; ) {
620
405
  if (!n[l]) {
621
- let R = this.original[l];
622
- R === `
623
- ` ? o = !0 : R !== "\r" && o && (o = !1, l === c.start || (this._splitChunk(c, l), c = c.next), c.prependRight(t));
406
+ let f = this.original[l];
407
+ f === `
408
+ ` ? r = !0 : f !== "\r" && r && (r = !1, l === a.start || (this._splitChunk(a, l), a = a.next), a.prependRight(t));
624
409
  }
625
410
  l += 1;
626
411
  }
627
- l = c.end, c = c.next;
412
+ l = a.end, a = a.next;
628
413
  }
629
- return this.outro = this.outro.replace(i, r), this;
414
+ return this.outro = this.outro.replace(i, s), this;
630
415
  }
631
416
  insert() {
632
417
  throw new Error(
@@ -634,25 +419,25 @@ var Dt = /\w/, rt = class {
634
419
  );
635
420
  }
636
421
  insertLeft(t, e) {
637
- return q.insertLeft || (console.warn(
422
+ return b.insertLeft || (console.warn(
638
423
  "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
639
- ), q.insertLeft = !0), this.appendLeft(t, e);
424
+ ), b.insertLeft = !0), this.appendLeft(t, e);
640
425
  }
641
426
  insertRight(t, e) {
642
- return q.insertRight || (console.warn(
427
+ return b.insertRight || (console.warn(
643
428
  "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
644
- ), q.insertRight = !0), this.prependRight(t, e);
429
+ ), b.insertRight = !0), this.prependRight(t, e);
645
430
  }
646
431
  move(t, e, i) {
647
432
  if (t = t + this.offset, e = e + this.offset, i = i + this.offset, i >= t && i <= e) throw new Error("Cannot move a selection inside its\
648
433
  elf");
649
434
  this._split(t), this._split(e), this._split(i);
650
- let n = this.byStart[t], o = this.byEnd[e], r = n.previous, l = o.next, c = this.byStart[i];
651
- if (!c && o === this.lastChunk) return this;
652
- let p = c ? c.previous : this.lastChunk;
653
- return r && (r.next = l), l && (l.previous = r), p && (p.next = n), c && (c.previous = o), n.previous || (this.firstChunk = o.next), o.next ||
654
- (this.lastChunk = n.previous, this.lastChunk.next = null), n.previous = p, o.next = c || null, p || (this.firstChunk = n), c || (this.lastChunk =
655
- o), this;
435
+ let n = this.byStart[t], r = this.byEnd[e], s = n.previous, l = r.next, a = this.byStart[i];
436
+ if (!a && r === this.lastChunk) return this;
437
+ let h = a ? a.previous : this.lastChunk;
438
+ return s && (s.next = l), l && (l.previous = s), h && (h.next = n), a && (a.previous = r), n.previous || (this.firstChunk = r.next), r.next ||
439
+ (this.lastChunk = n.previous, this.lastChunk.next = null), n.previous = h, r.next = a || null, h || (this.firstChunk = n), a || (this.lastChunk =
440
+ r), this;
656
441
  }
657
442
  overwrite(t, e, i, n) {
658
443
  return n = n || {}, this.update(t, e, i, { ...n, overwrite: !n.contentOnly });
@@ -668,30 +453,30 @@ elf");
668
453
  throw new Error(
669
454
  "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
670
455
  );
671
- this._split(t), this._split(e), n === !0 && (q.storeName || (console.warn(
456
+ this._split(t), this._split(e), n === !0 && (b.storeName || (console.warn(
672
457
  "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
673
- ), q.storeName = !0), n = { storeName: !0 });
674
- let o = n !== void 0 ? n.storeName : !1, r = n !== void 0 ? n.overwrite : !1;
675
- if (o) {
676
- let p = this.original.slice(t, e);
677
- Object.defineProperty(this.storedNames, p, {
458
+ ), b.storeName = !0), n = { storeName: !0 });
459
+ let r = n !== void 0 ? n.storeName : !1, s = n !== void 0 ? n.overwrite : !1;
460
+ if (r) {
461
+ let h = this.original.slice(t, e);
462
+ Object.defineProperty(this.storedNames, h, {
678
463
  writable: !0,
679
464
  value: !0,
680
465
  enumerable: !0
681
466
  });
682
467
  }
683
- let l = this.byStart[t], c = this.byEnd[e];
468
+ let l = this.byStart[t], a = this.byEnd[e];
684
469
  if (l) {
685
- let p = l;
686
- for (; p !== c; ) {
687
- if (p.next !== this.byStart[p.end])
470
+ let h = l;
471
+ for (; h !== a; ) {
472
+ if (h.next !== this.byStart[h.end])
688
473
  throw new Error("Cannot overwrite across a split point");
689
- p = p.next, p.edit("", !1);
474
+ h = h.next, h.edit("", !1);
690
475
  }
691
- l.edit(i, o, !r);
476
+ l.edit(i, r, !s);
692
477
  } else {
693
- let p = new Z(t, e, "").edit(i, o);
694
- c.next = p, p.previous = c;
478
+ let h = new L(t, e, "").edit(i, r);
479
+ a.next = h, h.previous = a;
695
480
  }
696
481
  return this;
697
482
  }
@@ -750,24 +535,24 @@ elf");
750
535
  return this.intro.length ? this.intro[this.intro.length - 1] : "";
751
536
  }
752
537
  lastLine() {
753
- let t = this.outro.lastIndexOf(V);
538
+ let t = this.outro.lastIndexOf(_);
754
539
  if (t !== -1) return this.outro.substr(t + 1);
755
540
  let e = this.outro, i = this.lastChunk;
756
541
  do {
757
542
  if (i.outro.length > 0) {
758
- if (t = i.outro.lastIndexOf(V), t !== -1) return i.outro.substr(t + 1) + e;
543
+ if (t = i.outro.lastIndexOf(_), t !== -1) return i.outro.substr(t + 1) + e;
759
544
  e = i.outro + e;
760
545
  }
761
546
  if (i.content.length > 0) {
762
- if (t = i.content.lastIndexOf(V), t !== -1) return i.content.substr(t + 1) + e;
547
+ if (t = i.content.lastIndexOf(_), t !== -1) return i.content.substr(t + 1) + e;
763
548
  e = i.content + e;
764
549
  }
765
550
  if (i.intro.length > 0) {
766
- if (t = i.intro.lastIndexOf(V), t !== -1) return i.intro.substr(t + 1) + e;
551
+ if (t = i.intro.lastIndexOf(_), t !== -1) return i.intro.substr(t + 1) + e;
767
552
  e = i.intro + e;
768
553
  }
769
554
  } while (i = i.previous);
770
- return t = this.intro.lastIndexOf(V), t !== -1 ? this.intro.substr(t + 1) + e : this.intro + e;
555
+ return t = this.intro.lastIndexOf(_), t !== -1 ? this.intro.substr(t + 1) + e : this.intro + e;
771
556
  }
772
557
  slice(t = 0, e = this.original.length - this.offset) {
773
558
  if (t = t + this.offset, e = e + this.offset, this.original.length !== 0) {
@@ -782,14 +567,14 @@ elf");
782
567
  }
783
568
  if (n && n.edited && n.start !== t)
784
569
  throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);
785
- let o = n;
570
+ let r = n;
786
571
  for (; n; ) {
787
- n.intro && (o !== n || n.start === t) && (i += n.intro);
788
- let r = n.start < e && n.end >= e;
789
- if (r && n.edited && n.end !== e)
572
+ n.intro && (r !== n || n.start === t) && (i += n.intro);
573
+ let s = n.start < e && n.end >= e;
574
+ if (s && n.edited && n.end !== e)
790
575
  throw new Error(`Cannot use replaced character ${e} as slice end anchor.`);
791
- let l = o === n ? t - n.start : 0, c = r ? n.content.length + e - n.end : n.content.length;
792
- if (i += n.content.slice(l, c), n.outro && (!r || n.end === e) && (i += n.outro), r)
576
+ let l = r === n ? t - n.start : 0, a = s ? n.content.length + e - n.end : n.content.length;
577
+ if (i += n.content.slice(l, a), n.outro && (!s || n.end === e) && (i += n.outro), s)
793
578
  break;
794
579
  n = n.next;
795
580
  }
@@ -802,15 +587,16 @@ elf");
802
587
  }
803
588
  _split(t) {
804
589
  if (this.byStart[t] || this.byEnd[t]) return;
805
- let e = this.lastSearchedChunk, i = t > e.end;
590
+ let e = this.lastSearchedChunk, i = e, n = t > e.end;
806
591
  for (; e; ) {
807
592
  if (e.contains(t)) return this._splitChunk(e, t);
808
- e = i ? this.byStart[e.end] : this.byEnd[e.start];
593
+ if (e = n ? this.byStart[e.end] : this.byEnd[e.start], e === i) return;
594
+ i = e;
809
595
  }
810
596
  }
811
597
  _splitChunk(t, e) {
812
598
  if (t.edited && t.content.length) {
813
- let n = ut(this.original)(e);
599
+ let n = B(this.original)(e);
814
600
  throw new Error(
815
601
  `Cannot split a chunk that has already been edited (${n.line}:${n.column} \u2013 "${t.original}")`
816
602
  );
@@ -851,9 +637,9 @@ elf");
851
637
  if (this.outro = this.outro.replace(e, ""), this.outro.length) return !0;
852
638
  let i = this.lastChunk;
853
639
  do {
854
- let n = i.end, o = i.trimEnd(e);
640
+ let n = i.end, r = i.trimEnd(e);
855
641
  if (i.end !== n && (this.lastChunk === i && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.
856
- byEnd[i.next.end] = i.next), o) return !0;
642
+ byEnd[i.next.end] = i.next), r) return !0;
857
643
  i = i.previous;
858
644
  } while (i);
859
645
  return !1;
@@ -866,9 +652,9 @@ elf");
866
652
  if (this.intro = this.intro.replace(e, ""), this.intro.length) return !0;
867
653
  let i = this.firstChunk;
868
654
  do {
869
- let n = i.end, o = i.trimStart(e);
655
+ let n = i.end, r = i.trimStart(e);
870
656
  if (i.end !== n && (i === this.lastChunk && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.
871
- byEnd[i.next.end] = i.next), o) return !0;
657
+ byEnd[i.next.end] = i.next), r) return !0;
872
658
  i = i.next;
873
659
  } while (i);
874
660
  return !1;
@@ -880,44 +666,46 @@ elf");
880
666
  return this.original !== this.toString();
881
667
  }
882
668
  _replaceRegexp(t, e) {
883
- function i(o, r) {
884
- return typeof e == "string" ? e.replace(/\$(\$|&|\d+)/g, (l, c) => c === "$" ? "$" : c === "&" ? o[0] : +c < o.length ? o[+c] : `$${c}`) :
885
- e(...o, o.index, r, o.groups);
886
- }
887
- d(i, "getReplacement");
888
- function n(o, r) {
889
- let l, c = [];
890
- for (; l = o.exec(r); )
891
- c.push(l);
892
- return c;
669
+ function i(r, s) {
670
+ return typeof e == "string" ? e.replace(/\$(\$|&|\d+)/g, (l, a) => a === "$" ? "$" : a === "&" ? r[0] : +a < r.length ? r[+a] : `$${a}`) :
671
+ e(...r, r.index, s, r.groups);
672
+ }
673
+ u(i, "getReplacement");
674
+ function n(r, s) {
675
+ let l, a = [];
676
+ for (; l = r.exec(s); )
677
+ a.push(l);
678
+ return a;
893
679
  }
894
- if (d(n, "matchAll"), t.global)
895
- n(t, this.original).forEach((r) => {
896
- if (r.index != null) {
897
- let l = i(r, this.original);
898
- l !== r[0] && this.overwrite(r.index, r.index + r[0].length, l);
680
+ if (u(n, "matchAll"), t.global)
681
+ n(t, this.original).forEach((s) => {
682
+ if (s.index != null) {
683
+ let l = i(s, this.original);
684
+ l !== s[0] && this.overwrite(s.index, s.index + s[0].length, l);
899
685
  }
900
686
  });
901
687
  else {
902
- let o = this.original.match(t);
903
- if (o && o.index != null) {
904
- let r = i(o, this.original);
905
- r !== o[0] && this.overwrite(o.index, o.index + o[0].length, r);
688
+ let r = this.original.match(t);
689
+ if (r && r.index != null) {
690
+ let s = i(r, this.original);
691
+ s !== r[0] && this.overwrite(r.index, r.index + r[0].length, s);
906
692
  }
907
693
  }
908
694
  return this;
909
695
  }
910
696
  _replaceString(t, e) {
911
697
  let { original: i } = this, n = i.indexOf(t);
912
- return n !== -1 && this.overwrite(n, n + t.length, e), this;
698
+ return n !== -1 && (typeof e == "function" && (e = e(t, n, i)), t !== e && this.overwrite(n, n + t.length, e)), this;
913
699
  }
914
700
  replace(t, e) {
915
701
  return typeof t == "string" ? this._replaceString(t, e) : this._replaceRegexp(t, e);
916
702
  }
917
703
  _replaceAllString(t, e) {
918
704
  let { original: i } = this, n = t.length;
919
- for (let o = i.indexOf(t); o !== -1; o = i.indexOf(t, o + n))
920
- i.slice(o, o + n) !== e && this.overwrite(o, o + n, e);
705
+ for (let r = i.indexOf(t); r !== -1; r = i.indexOf(t, r + n)) {
706
+ let s = i.slice(r, r + n), l = e;
707
+ typeof e == "function" && (l = e(s, r, i)), s !== l && this.overwrite(r, r + n, l);
708
+ }
921
709
  return this;
922
710
  }
923
711
  replaceAll(t, e) {
@@ -932,103 +720,103 @@ elf");
932
720
  };
933
721
 
934
722
  // src/core-server/presets/vitePlugins/vite-inject-mocker/constants.ts
935
- var ft = "__vitest_mocker__";
723
+ var F = "__vitest_mocker__";
936
724
 
937
725
  // src/core-server/mocking-utils/esmWalker.ts
938
- function Y(u) {
939
- return u.type === "Identifier" ? u.name : u.raw;
726
+ function v(o) {
727
+ return o.type === "Identifier" ? o.name : o.raw;
940
728
  }
941
- d(Y, "getArbitraryModuleIdentifier");
729
+ u(v, "getArbitraryModuleIdentifier");
942
730
 
943
731
  // src/core-server/mocking-utils/automock.ts
944
- function dt(u, t, e) {
945
- return $t(u, t ? "autospy" : "automock", e, {
946
- globalThisAccessor: JSON.stringify(ft)
732
+ function U(o, t, e) {
733
+ return ut(o, t ? "autospy" : "automock", e, {
734
+ globalThisAccessor: JSON.stringify(F)
947
735
  });
948
736
  }
949
- d(dt, "getAutomockCode");
950
- function $t(u, t, e, i = {}) {
951
- let n = i.globalThisAccessor || '"__vitest_mocker__"', o = e(u), r = new tt(u), l = [], c = 0;
952
- for (let P of o.body) {
953
- if (P.type === "ExportAllDeclaration")
737
+ u(U, "getAutomockCode");
738
+ function ut(o, t, e, i = {}) {
739
+ let n = i.globalThisAccessor || '"__vitest_mocker__"', r = e(o), s = new N(o), l = [], a = 0;
740
+ for (let g of r.body) {
741
+ if (g.type === "ExportAllDeclaration")
954
742
  throw new Error(
955
743
  "automocking files with `export *` is not supported in browser mode because it cannot be statically analysed"
956
744
  );
957
- if (P.type === "ExportNamedDeclaration") {
958
- let j = function(v) {
959
- if (v.type === "Identifier")
960
- l.push({ name: v.name });
961
- else if (v.type === "ArrayPattern")
962
- v.elements.forEach((N) => {
963
- N && j(N);
745
+ if (g.type === "ExportNamedDeclaration") {
746
+ let y = function(c) {
747
+ if (c.type === "Identifier")
748
+ l.push({ name: c.name });
749
+ else if (c.type === "ArrayPattern")
750
+ c.elements.forEach((m) => {
751
+ m && y(m);
964
752
  });
965
- else if (v.type === "ObjectPattern")
966
- v.properties.forEach((N) => {
967
- N.type === "RestElement" ? j(N) : N.type === "Property" && j(N.value);
753
+ else if (c.type === "ObjectPattern")
754
+ c.properties.forEach((m) => {
755
+ m.type === "RestElement" ? y(m) : m.type === "Property" && y(m.value);
968
756
  });
969
- else if (v.type === "RestElement")
970
- j(v.argument);
757
+ else if (c.type === "RestElement")
758
+ y(c.argument);
971
759
  else {
972
- if (v.type === "AssignmentPattern")
760
+ if (c.type === "AssignmentPattern")
973
761
  throw new Error("AssignmentPattern is not supported. Please open a new bug report.");
974
- if (v.type === "MemberExpression")
762
+ if (c.type === "MemberExpression")
975
763
  throw new Error("MemberExpression is not supported. Please open a new bug report.");
976
764
  }
977
765
  };
978
- var it = j;
979
- d(j, "traversePattern");
980
- let I = P, L = I.declaration;
981
- L && (L.type === "FunctionDeclaration" ? l.push({ name: L.id.name }) : L.type === "VariableDeclaration" ? L.declarations.forEach((v) => {
982
- j(v.id);
983
- }) : L.type === "ClassDeclaration" && l.push({ name: L.id.name }), r.remove(I.start, L.start));
984
- let $ = I.specifiers || [], T = I.source;
985
- if (!T && $.length)
986
- $.forEach((v) => {
766
+ var mt = y;
767
+ u(y, "traversePattern");
768
+ let d = g, p = d.declaration;
769
+ p && (p.type === "FunctionDeclaration" ? l.push({ name: p.id.name }) : p.type === "VariableDeclaration" ? p.declarations.forEach((c) => {
770
+ y(c.id);
771
+ }) : p.type === "ClassDeclaration" && l.push({ name: p.id.name }), s.remove(d.start, p.start));
772
+ let x = d.specifiers || [], O = d.source;
773
+ if (!O && x.length)
774
+ x.forEach((c) => {
987
775
  l.push({
988
- alias: Y(v.exported),
989
- name: Y(v.local)
776
+ alias: v(c.exported),
777
+ name: v(c.local)
990
778
  });
991
- }), r.remove(I.start, I.end);
992
- else if (T && $.length) {
993
- let v = [];
994
- $.forEach((B) => {
995
- let F = `__vitest_imported_${c++}__`;
996
- v.push([Y(B.local), F]), l.push({
997
- name: F,
998
- alias: Y(B.exported)
779
+ }), s.remove(d.start, d.end);
780
+ else if (O && x.length) {
781
+ let c = [];
782
+ x.forEach((S) => {
783
+ let k = `__vitest_imported_${a++}__`;
784
+ c.push([v(S.local), k]), l.push({
785
+ name: k,
786
+ alias: v(S.exported)
999
787
  });
1000
788
  });
1001
- let N = `import { ${v.map(([B, F]) => `${B} as ${F}`).join(", ")} } from '${T.value}'`;
1002
- r.overwrite(I.start, I.end, N);
789
+ let m = `import { ${c.map(([S, k]) => `${S} as ${k}`).join(", ")} } from '${O.value}'`;
790
+ s.overwrite(d.start, d.end, m);
1003
791
  }
1004
792
  }
1005
- if (P.type === "ExportDefaultDeclaration") {
1006
- let I = P, L = I.declaration;
1007
- l.push({ name: "__vitest_default", alias: "default" }), r.overwrite(I.start, L.start, "const __vitest_default = ");
793
+ if (g.type === "ExportDefaultDeclaration") {
794
+ let d = g, p = d.declaration;
795
+ l.push({ name: "__vitest_default", alias: "default" }), s.overwrite(d.start, p.start, "const __vitest_default = ");
1008
796
  }
1009
797
  }
1010
- let p = `
798
+ let h = `
1011
799
  const __vitest_current_es_module__ = {
1012
800
  __esModule: true,
1013
- ${l.map(({ name: P }) => `["${P}"]: ${P},`).join(`
801
+ ${l.map(({ name: g }) => `["${g}"]: ${g},`).join(`
1014
802
  `)}
1015
803
  }
1016
804
  const __vitest_mocked_module__ = globalThis[${n}].mockObject(__vitest_current_es_module__, "${t}")
1017
- `, R = l.map(({ name: P }, I) => `const __vitest_mocked_${I}__ = __vitest_mocked_module__["${P}"]`).join(`
1018
- `), W = `
805
+ `, f = l.map(({ name: g }, d) => `const __vitest_mocked_${d}__ = __vitest_mocked_module__["${g}"]`).join(`
806
+ `), G = `
1019
807
  export {
1020
- ${l.map(({ name: P, alias: I }, L) => ` __vitest_mocked_${L}__ as ${I || P},`).join(`
808
+ ${l.map(({ name: g, alias: d }, p) => ` __vitest_mocked_${p}__ as ${d || g},`).join(`
1021
809
  `)}
1022
810
  }
1023
811
  `;
1024
- return r.append(p + R + W), r;
812
+ return s.append(h + f + G), s;
1025
813
  }
1026
- d($t, "automockModule");
814
+ u(ut, "automockModule");
1027
815
 
1028
816
  // src/core-server/mocking-utils/extract.ts
1029
- var Tt = require("node:fs"), et = require("storybook/internal/babel"), Bt = require("storybook/internal/node-logger"), Ft = require("storybook/internal/telemetry"),
1030
- Ut = require("esbuild");
1031
- var pt = /* @__PURE__ */ d((u) => et.parser.parse(u, {
817
+ var ct = require("node:fs"), P = require("storybook/internal/babel"), ft = require("storybook/internal/node-logger"), dt = require("storybook/internal/telemetry"),
818
+ pt = require("esbuild");
819
+ var q = /* @__PURE__ */ u((o) => P.parser.parse(o, {
1032
820
  sourceType: "module",
1033
821
  // Enable plugins to handle modern JavaScript features, including TSX.
1034
822
  plugins: ["typescript", "jsx", "classProperties", "objectRestSpread"],
@@ -1036,8 +824,8 @@ var pt = /* @__PURE__ */ d((u) => et.parser.parse(u, {
1036
824
  }).program, "babelParser");
1037
825
 
1038
826
  // src/core-server/presets/webpack/loaders/webpack-automock-loader.ts
1039
- function gt(u) {
827
+ function W(o) {
1040
828
  let e = this.getOptions().spy === "true";
1041
- return dt(u, e, pt).toString();
829
+ return U(o, e, q).toString();
1042
830
  }
1043
- d(gt, "webpackAutomockLoader");
831
+ u(W, "webpackAutomockLoader");