storybook 9.0.0-rc.2 → 9.0.0-rc.3

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.
@@ -6,20 +6,20 @@ var ze = Object.getOwnPropertyNames;
6
6
  var Xe = Object.getPrototypeOf, Ke = Object.prototype.hasOwnProperty;
7
7
  var f = (s, e) => A(s, "name", { value: e, configurable: !0 });
8
8
  var Je = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports), Qe = (s, e) => {
9
- for (var t in e)
10
- A(s, t, { get: e[t], enumerable: !0 });
11
- }, ce = (s, e, t, r) => {
9
+ for (var r in e)
10
+ A(s, r, { get: e[r], enumerable: !0 });
11
+ }, ce = (s, e, r, t) => {
12
12
  if (e && typeof e == "object" || typeof e == "function")
13
13
  for (let i of ze(e))
14
- !Ke.call(s, i) && i !== t && A(s, i, { get: () => e[i], enumerable: !(r = Ge(e, i)) || r.enumerable });
14
+ !Ke.call(s, i) && i !== r && A(s, i, { get: () => e[i], enumerable: !(t = Ge(e, i)) || t.enumerable });
15
15
  return s;
16
16
  };
17
- var z = (s, e, t) => (t = s != null ? We(Xe(s)) : {}, ce(
17
+ var z = (s, e, r) => (r = s != null ? We(Xe(s)) : {}, ce(
18
18
  // If the importer is in node compatibility mode or this is not an ESM
19
19
  // file that has been converted to a CommonJS file using a Babel-
20
20
  // compatible transform (i.e. "__esModule" has not been set), then set
21
21
  // "default" to the CommonJS "module.exports" for node compatibility.
22
- e || !s || !s.__esModule ? A(t, "default", { value: s, enumerable: !0 }) : t,
22
+ e || !s || !s.__esModule ? A(r, "default", { value: s, enumerable: !0 }) : r,
23
23
  s
24
24
  )), He = (s) => ce(A({}, "__esModule", { value: !0 }), s);
25
25
 
@@ -29,36 +29,36 @@ var R = Je(($) => {
29
29
  Object.defineProperty($, "__esModule", { value: !0 });
30
30
  $.dedent = void 0;
31
31
  function pe(s) {
32
- for (var e = [], t = 1; t < arguments.length; t++)
33
- e[t - 1] = arguments[t];
34
- var r = Array.from(typeof s == "string" ? [s] : s);
35
- r[r.length - 1] = r[r.length - 1].replace(/\r?\n([\t ]*)$/, "");
36
- var i = r.reduce(function(a, p) {
37
- var m = p.match(/\n([\t ]+|(?!\s).)/g);
38
- return m ? a.concat(m.map(function(g) {
39
- var x, E;
40
- return (E = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && E !== void 0 ? E : 0;
41
- })) : a;
32
+ for (var e = [], r = 1; r < arguments.length; r++)
33
+ e[r - 1] = arguments[r];
34
+ var t = Array.from(typeof s == "string" ? [s] : s);
35
+ t[t.length - 1] = t[t.length - 1].replace(/\r?\n([\t ]*)$/, "");
36
+ var i = t.reduce(function(l, p) {
37
+ var d = p.match(/\n([\t ]+|(?!\s).)/g);
38
+ return d ? l.concat(d.map(function(g) {
39
+ var x, h;
40
+ return (h = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && h !== void 0 ? h : 0;
41
+ })) : l;
42
42
  }, []);
43
43
  if (i.length) {
44
44
  var o = new RegExp(`
45
45
  [ ]{` + Math.min.apply(Math, i) + "}", "g");
46
- r = r.map(function(a) {
47
- return a.replace(o, `
46
+ t = t.map(function(l) {
47
+ return l.replace(o, `
48
48
  `);
49
49
  });
50
50
  }
51
- r[0] = r[0].replace(/^\r?\n/, "");
52
- var l = r[0];
53
- return e.forEach(function(a, p) {
54
- var m = l.match(/(?:^|\n)( *)$/), g = m ? m[1] : "", x = a;
55
- typeof a == "string" && a.includes(`
56
- `) && (x = String(a).split(`
57
- `).map(function(E, b) {
58
- return b === 0 ? E : "" + g + E;
51
+ t[0] = t[0].replace(/^\r?\n/, "");
52
+ var a = t[0];
53
+ return e.forEach(function(l, p) {
54
+ var d = a.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = l;
55
+ typeof l == "string" && l.includes(`
56
+ `) && (x = String(l).split(`
57
+ `).map(function(h, b) {
58
+ return b === 0 ? h : "" + g + h;
59
59
  }).join(`
60
- `)), l += x + r[p + 1];
61
- }), l;
60
+ `)), a += x + t[p + 1];
61
+ }), a;
62
62
  }
63
63
  f(pe, "dedent");
64
64
  $.dedent = pe;
@@ -78,7 +78,7 @@ Qe(dt, {
78
78
  babelParseFile: () => ye,
79
79
  enrichCsf: () => pt,
80
80
  enrichCsfMeta: () => we,
81
- enrichCsfStory: () => ve,
81
+ enrichCsfStory: () => Ie,
82
82
  extractDescription: () => oe,
83
83
  extractSource: () => Fe,
84
84
  formatConfig: () => Se,
@@ -100,15 +100,15 @@ Qe(dt, {
100
100
  module.exports = He(dt);
101
101
 
102
102
  // src/csf-tools/CsfFile.ts
103
- var J = require("node:fs/promises"), c = require("storybook/internal/babel"), I = require("storybook/internal/csf"), O = z(R(), 1);
103
+ var J = require("node:fs/promises"), c = require("storybook/internal/babel"), v = require("storybook/internal/csf"), O = z(R(), 1);
104
104
 
105
105
  // src/csf-tools/findVarInitialization.ts
106
106
  var w = require("storybook/internal/babel");
107
107
  var P = /* @__PURE__ */ f((s, e) => {
108
- let t = null, r = null;
109
- return e.body.find((i) => (w.types.isVariableDeclaration(i) ? r = i.declarations : w.types.isExportNamedDeclaration(i) && w.types.isVariableDeclaration(
110
- i.declaration) && (r = i.declaration.declarations), r && r.find((o) => w.types.isVariableDeclarator(o) && w.types.isIdentifier(o.id) && o.
111
- id.name === s ? (t = o.init, !0) : !1))), t;
108
+ let r = null, t = null;
109
+ return e.body.find((i) => (w.types.isVariableDeclaration(i) ? t = i.declarations : w.types.isExportNamedDeclaration(i) && w.types.isVariableDeclaration(
110
+ i.declaration) && (t = i.declaration.declarations), t && t.find((o) => w.types.isVariableDeclarator(o) && w.types.isIdentifier(o.id) && o.
111
+ id.name === s ? (r = o.init, !0) : !1))), r;
112
112
  }, "findVarInitialization");
113
113
 
114
114
  // src/csf-tools/CsfFile.ts
@@ -138,23 +138,23 @@ function de(s) {
138
138
  }
139
139
  f(de, "parseTags");
140
140
  var D = /* @__PURE__ */ f((s, e) => {
141
- let t = "";
141
+ let r = "";
142
142
  if (s.loc) {
143
- let { line: r, column: i } = s.loc?.start || {};
144
- t = `(line ${r}, col ${i})`;
143
+ let { line: t, column: i } = s.loc?.start || {};
144
+ r = `(line ${t}, col ${i})`;
145
145
  }
146
- return `${e || ""} ${t}`.trim();
147
- }, "formatLocation"), xe = /* @__PURE__ */ f((s) => rt.test(s), "isModuleMock"), me = /* @__PURE__ */ f((s, e, t) => {
148
- let r = s;
146
+ return `${e || ""} ${r}`.trim();
147
+ }, "formatLocation"), xe = /* @__PURE__ */ f((s) => rt.test(s), "isModuleMock"), ue = /* @__PURE__ */ f((s, e, r) => {
148
+ let t = s;
149
149
  if (c.types.isCallExpression(s)) {
150
150
  let { callee: i, arguments: o } = s;
151
151
  if (c.types.isProgram(e) && c.types.isMemberExpression(i) && c.types.isIdentifier(i.object) && c.types.isIdentifier(i.property) && i.property.
152
152
  name === "bind" && (o.length === 0 || o.length === 1 && c.types.isObjectExpression(o[0]) && o[0].properties.length === 0)) {
153
- let l = i.object.name, a = P(l, e);
154
- a && (t._templates[l] = a, r = a);
153
+ let a = i.object.name, l = P(a, e);
154
+ l && (r._templates[a] = l, t = l);
155
155
  }
156
156
  }
157
- return c.types.isArrowFunctionExpression(r) || c.types.isFunctionDeclaration(r) ? r.params.length > 0 : !1;
157
+ return c.types.isArrowFunctionExpression(t) || c.types.isFunctionDeclaration(t) ? t.params.length > 0 : !1;
158
158
  }, "isArgsStory"), et = /* @__PURE__ */ f((s) => {
159
159
  if (c.types.isArrayExpression(s))
160
160
  return s.elements.map((e) => {
@@ -163,21 +163,21 @@ var D = /* @__PURE__ */ f((s, e) => {
163
163
  throw new Error(`Expected string literal named export: ${e}`);
164
164
  });
165
165
  throw new Error(`Expected array of string literals: ${s}`);
166
- }, "parseExportsOrder"), ue = /* @__PURE__ */ f((s, e) => e.reduce(
167
- (t, r) => {
168
- let i = s[r];
169
- return i && (t[r] = i), t;
166
+ }, "parseExportsOrder"), me = /* @__PURE__ */ f((s, e) => e.reduce(
167
+ (r, t) => {
168
+ let i = s[t];
169
+ return i && (r[t] = i), r;
170
170
  },
171
171
  {}
172
172
  ), "sortExports"), tt = /* @__PURE__ */ f((s) => {
173
173
  if (c.types.isArrowFunctionExpression(s) || c.types.isFunctionDeclaration(s)) {
174
174
  let e = s.params;
175
175
  if (e.length >= 1) {
176
- let [t] = e;
177
- if (c.types.isObjectPattern(t))
178
- return !!t.properties.find((r) => {
179
- if (c.types.isObjectProperty(r) && c.types.isIdentifier(r.key))
180
- return r.key.name === "mount";
176
+ let [r] = e;
177
+ if (c.types.isObjectPattern(r))
178
+ return !!r.properties.find((t) => {
179
+ if (c.types.isObjectProperty(t) && c.types.isIdentifier(t.key))
180
+ return t.key.name === "mount";
181
181
  });
182
182
  }
183
183
  }
@@ -186,10 +186,10 @@ var D = /* @__PURE__ */ f((s, e) => {
186
186
  static {
187
187
  f(this, "NoMetaError");
188
188
  }
189
- constructor(e, t, r) {
189
+ constructor(e, r, t) {
190
190
  let i = "".trim();
191
191
  super(O.dedent`
192
- CSF: ${e} ${D(t, r)}
192
+ CSF: ${e} ${D(r, t)}
193
193
 
194
194
  More info: https://storybook.js.org/docs/writing-stories#default-export
195
195
  `), this.name = this.constructor.name;
@@ -198,10 +198,10 @@ var D = /* @__PURE__ */ f((s, e) => {
198
198
  static {
199
199
  f(this, "MultipleMetaError");
200
200
  }
201
- constructor(e, t, r) {
202
- let i = `${e} ${D(t, r)}`.trim();
201
+ constructor(e, r, t) {
202
+ let i = `${e} ${D(r, t)}`.trim();
203
203
  super(O.dedent`
204
- CSF: ${e} ${D(t, r)}
204
+ CSF: ${e} ${D(r, t)}
205
205
 
206
206
  More info: https://storybook.js.org/docs/writing-stories#default-export
207
207
  `), this.name = this.constructor.name;
@@ -210,10 +210,10 @@ var D = /* @__PURE__ */ f((s, e) => {
210
210
  static {
211
211
  f(this, "MixedFactoryError");
212
212
  }
213
- constructor(e, t, r) {
214
- let i = `${e} ${D(t, r)}`.trim();
213
+ constructor(e, r, t) {
214
+ let i = `${e} ${D(r, t)}`.trim();
215
215
  super(O.dedent`
216
- CSF: ${e} ${D(t, r)}
216
+ CSF: ${e} ${D(r, t)}
217
217
 
218
218
  More info: https://storybook.js.org/docs/writing-stories#default-export
219
219
  `), this.name = this.constructor.name;
@@ -222,16 +222,16 @@ var D = /* @__PURE__ */ f((s, e) => {
222
222
  static {
223
223
  f(this, "BadMetaError");
224
224
  }
225
- constructor(e, t, r) {
225
+ constructor(e, r, t) {
226
226
  let i = "".trim();
227
227
  super(O.dedent`
228
- CSF: ${e} ${D(t, r)}
228
+ CSF: ${e} ${D(r, t)}
229
229
 
230
230
  More info: https://storybook.js.org/docs/writing-stories#default-export
231
231
  `), this.name = this.constructor.name;
232
232
  }
233
233
  }, K = class {
234
- constructor(e, t, r) {
234
+ constructor(e, r, t) {
235
235
  this._stories = {};
236
236
  this._metaAnnotations = {};
237
237
  this._storyExports = {};
@@ -239,91 +239,91 @@ var D = /* @__PURE__ */ f((s, e) => {
239
239
  this._storyStatements = {};
240
240
  this._storyAnnotations = {};
241
241
  this._templates = {};
242
- this._ast = e, this._file = r, this._options = t, this.imports = [];
242
+ this._ast = e, this._file = t, this._options = r, this.imports = [];
243
243
  }
244
244
  static {
245
245
  f(this, "CsfFile");
246
246
  }
247
247
  _parseTitle(e) {
248
- let t = c.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
249
- if (c.types.isStringLiteral(t))
250
- return t.value;
251
- if (c.types.isTSSatisfiesExpression(t) && c.types.isStringLiteral(t.expression))
252
- return t.expression.value;
248
+ let r = c.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
249
+ if (c.types.isStringLiteral(r))
250
+ return r.value;
251
+ if (c.types.isTSSatisfiesExpression(r) && c.types.isStringLiteral(r.expression))
252
+ return r.expression.value;
253
253
  throw new Error(O.dedent`
254
- CSF: unexpected dynamic title ${D(t, this._options.fileName)}
254
+ CSF: unexpected dynamic title ${D(r, this._options.fileName)}
255
255
 
256
256
  More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
257
257
  `);
258
258
  }
259
- _parseMeta(e, t) {
259
+ _parseMeta(e, r) {
260
260
  if (this._metaNode)
261
261
  throw new X("multiple meta objects", e, this._options.fileName);
262
262
  this._metaNode = e;
263
- let r = {};
263
+ let t = {};
264
264
  e.properties.forEach((i) => {
265
265
  if (c.types.isIdentifier(i.key)) {
266
266
  if (this._metaAnnotations[i.key.name] = i.value, i.key.name === "title")
267
- r.title = this._parseTitle(i.value);
267
+ t.title = this._parseTitle(i.value);
268
268
  else if (["includeStories", "excludeStories"].includes(i.key.name))
269
- r[i.key.name] = Ze(i.value);
269
+ t[i.key.name] = Ze(i.value);
270
270
  else if (i.key.name === "component") {
271
271
  let o = i.value;
272
272
  if (c.types.isIdentifier(o)) {
273
- let a = o.name, p = t.body.find(
274
- (m) => c.types.isImportDeclaration(m) && m.specifiers.find((g) => g.local.name === a)
273
+ let l = o.name, p = r.body.find(
274
+ (d) => c.types.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === l)
275
275
  );
276
276
  if (p) {
277
- let { source: m } = p;
278
- c.types.isStringLiteral(m) && (this._rawComponentPath = m.value);
277
+ let { source: d } = p;
278
+ c.types.isStringLiteral(d) && (this._rawComponentPath = d.value);
279
279
  }
280
280
  }
281
- let { code: l } = c.recast.print(i.value, {});
282
- r.component = l;
281
+ let { code: a } = c.recast.print(i.value, {});
282
+ t.component = a;
283
283
  } else if (i.key.name === "tags") {
284
284
  let o = i.value;
285
- c.types.isIdentifier(o) && (o = P(o.name, this._ast.program)), r.tags = de(o);
285
+ c.types.isIdentifier(o) && (o = P(o.name, this._ast.program)), t.tags = de(o);
286
286
  } else if (i.key.name === "id")
287
287
  if (c.types.isStringLiteral(i.value))
288
- r.id = i.value.value;
288
+ t.id = i.value.value;
289
289
  else
290
290
  throw new Error(`Unexpected component id: ${i.value}`);
291
291
  }
292
- }), this._meta = r;
292
+ }), this._meta = t;
293
293
  }
294
294
  getStoryExport(e) {
295
- let t = this._storyExports[e];
296
- if (t = c.types.isVariableDeclarator(t) ? t.init : t, c.types.isCallExpression(t)) {
297
- let { callee: r, arguments: i } = t;
298
- if (c.types.isMemberExpression(r) && c.types.isIdentifier(r.object) && c.types.isIdentifier(r.property) && r.property.name === "bind" &&
295
+ let r = this._storyExports[e];
296
+ if (r = c.types.isVariableDeclarator(r) ? r.init : r, c.types.isCallExpression(r)) {
297
+ let { callee: t, arguments: i } = r;
298
+ if (c.types.isMemberExpression(t) && c.types.isIdentifier(t.object) && c.types.isIdentifier(t.property) && t.property.name === "bind" &&
299
299
  (i.length === 0 || i.length === 1 && c.types.isObjectExpression(i[0]) && i[0].properties.length === 0)) {
300
- let { name: o } = r.object;
301
- t = this._templates[o];
300
+ let { name: o } = t.object;
301
+ r = this._templates[o];
302
302
  }
303
303
  }
304
- return t;
304
+ return r;
305
305
  }
306
306
  parse() {
307
307
  let e = this;
308
308
  if ((0, c.traverse)(this._ast, {
309
309
  ExportDefaultDeclaration: {
310
- enter(r) {
311
- let { node: i, parent: o } = r, l = c.types.isIdentifier(i.declaration) && c.types.isProgram(o);
312
- if (e._options.transformInlineMeta && !l && c.types.isExpression(i.declaration)) {
313
- let m = r.scope.generateUidIdentifier("meta");
314
- e._metaVariableName = m.name;
310
+ enter(t) {
311
+ let { node: i, parent: o } = t, a = c.types.isIdentifier(i.declaration) && c.types.isProgram(o);
312
+ if (e._options.transformInlineMeta && !a && c.types.isExpression(i.declaration)) {
313
+ let d = t.scope.generateUidIdentifier("meta");
314
+ e._metaVariableName = d.name;
315
315
  let g = [
316
- c.types.variableDeclaration("const", [c.types.variableDeclarator(m, i.declaration)]),
317
- c.types.exportDefaultDeclaration(m)
316
+ c.types.variableDeclaration("const", [c.types.variableDeclarator(d, i.declaration)]),
317
+ c.types.exportDefaultDeclaration(d)
318
318
  ];
319
- g.forEach((x) => x.loc = r.node.loc), r.replaceWithMultiple(g);
319
+ g.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(g);
320
320
  return;
321
321
  }
322
- let a, p;
323
- if (l) {
324
- let m = i.declaration.name;
325
- e._metaVariableName = m;
326
- let g = /* @__PURE__ */ f((x) => c.types.isIdentifier(x.id) && x.id.name === m, "isVariableDeclarator");
322
+ let l, p;
323
+ if (a) {
324
+ let d = i.declaration.name;
325
+ e._metaVariableName = d;
326
+ let g = /* @__PURE__ */ f((x) => c.types.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
327
327
  e._metaStatement = e._ast.program.body.find(
328
328
  (x) => c.types.isVariableDeclaration(x) && x.declarations.find(g)
329
329
  ), p = (e?._metaStatement?.declarations || []).find(
@@ -331,37 +331,37 @@ var D = /* @__PURE__ */ f((s, e) => {
331
331
  )?.init;
332
332
  } else
333
333
  e._metaStatement = i, p = i.declaration;
334
- if (c.types.isObjectExpression(p) ? a = p : (
334
+ if (c.types.isObjectExpression(p) ? l = p : (
335
335
  // export default { ... } as Meta<...>
336
- (c.types.isTSAsExpression(p) || c.types.isTSSatisfiesExpression(p)) && c.types.isObjectExpression(p.expression) && (a = p.expression)
337
- ), a && c.types.isProgram(o) && e._parseMeta(a, o), e._metaStatement && !e._metaNode)
336
+ (c.types.isTSAsExpression(p) || c.types.isTSSatisfiesExpression(p)) && c.types.isObjectExpression(p.expression) && (l = p.expression)
337
+ ), l && c.types.isProgram(o) && e._parseMeta(l, o), e._metaStatement && !e._metaNode)
338
338
  throw new L(
339
339
  "default export must be an object",
340
340
  e._metaStatement,
341
341
  e._options.fileName
342
342
  );
343
- e._metaPath = r;
343
+ e._metaPath = t;
344
344
  }
345
345
  },
346
346
  ExportNamedDeclaration: {
347
- enter(r) {
348
- let { node: i, parent: o } = r, l;
349
- c.types.isVariableDeclaration(i.declaration) ? l = i.declaration.declarations.filter((a) => c.types.isVariableDeclarator(a)) : c.types.
350
- isFunctionDeclaration(i.declaration) && (l = [i.declaration]), l ? l.forEach((a) => {
351
- if (c.types.isIdentifier(a.id)) {
352
- let p = !1, { name: m } = a.id;
353
- if (m === "__namedExportsOrder" && c.types.isVariableDeclarator(a)) {
354
- e._namedExportsOrder = et(a.init);
347
+ enter(t) {
348
+ let { node: i, parent: o } = t, a;
349
+ c.types.isVariableDeclaration(i.declaration) ? a = i.declaration.declarations.filter((l) => c.types.isVariableDeclarator(l)) : c.types.
350
+ isFunctionDeclaration(i.declaration) && (a = [i.declaration]), a ? a.forEach((l) => {
351
+ if (c.types.isIdentifier(l.id)) {
352
+ let p = !1, { name: d } = l.id;
353
+ if (d === "__namedExportsOrder" && c.types.isVariableDeclarator(l)) {
354
+ e._namedExportsOrder = et(l.init);
355
355
  return;
356
356
  }
357
- e._storyExports[m] = a, e._storyPaths[m] = r, e._storyStatements[m] = i;
358
- let g = (0, I.storyNameFromExport)(m);
359
- e._storyAnnotations[m] ? fe.warn(
360
- `Unexpected annotations for "${m}" before story declaration`
361
- ) : e._storyAnnotations[m] = {};
357
+ e._storyExports[d] = l, e._storyPaths[d] = t, e._storyStatements[d] = i;
358
+ let g = (0, v.storyNameFromExport)(d);
359
+ e._storyAnnotations[d] ? fe.warn(
360
+ `Unexpected annotations for "${d}" before story declaration`
361
+ ) : e._storyAnnotations[d] = {};
362
362
  let x;
363
- if (c.types.isVariableDeclarator(a) ? x = c.types.isTSAsExpression(a.init) || c.types.isTSSatisfiesExpression(a.init) ? a.init.
364
- expression : a.init : x = a, c.types.isCallExpression(x) && c.types.isMemberExpression(x.callee) && c.types.isIdentifier(x.callee.
363
+ if (c.types.isVariableDeclarator(l) ? x = c.types.isTSAsExpression(l.init) || c.types.isTSSatisfiesExpression(l.init) ? l.init.
364
+ expression : l.init : x = l, c.types.isCallExpression(x) && c.types.isMemberExpression(x.callee) && c.types.isIdentifier(x.callee.
365
365
  property) && x.callee.property.name === "story" && (p = !0, x = x.arguments[0]), e._metaIsFactory && !p)
366
366
  throw new M(
367
367
  "expected factory story",
@@ -378,11 +378,11 @@ var D = /* @__PURE__ */ f((s, e) => {
378
378
  x,
379
379
  e._options.fileName
380
380
  );
381
- let E = {};
382
- c.types.isObjectExpression(x) ? (E.__isArgsStory = !0, x.properties.forEach((b) => {
381
+ let h = {};
382
+ c.types.isObjectExpression(x) ? (h.__isArgsStory = !0, x.properties.forEach((b) => {
383
383
  if (c.types.isIdentifier(b.key)) {
384
384
  if (b.key.name === "render")
385
- E.__isArgsStory = me(
385
+ h.__isArgsStory = ue(
386
386
  b.value,
387
387
  o,
388
388
  e
@@ -391,66 +391,70 @@ var D = /* @__PURE__ */ f((s, e) => {
391
391
  g = b.value.value;
392
392
  else if (b.key.name === "storyName" && c.types.isStringLiteral(b.value))
393
393
  fe.warn(
394
- `Unexpected usage of "storyName" in "${m}". Please use "name" instead.`
394
+ `Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
395
395
  );
396
396
  else if (b.key.name === "parameters" && c.types.isObjectExpression(b.value)) {
397
- let h = b.value.properties.find(
398
- (v) => c.types.isObjectProperty(v) && c.types.isIdentifier(v.key) && v.key.name === "__id"
397
+ let E = b.value.properties.find(
398
+ (I) => c.types.isObjectProperty(I) && c.types.isIdentifier(I.key) && I.key.name === "__id"
399
399
  );
400
- h && (E.__id = h.value.value);
400
+ E && (h.__id = E.value.value);
401
401
  }
402
- e._storyAnnotations[m][b.key.name] = b.value;
402
+ e._storyAnnotations[d][b.key.name] = b.value;
403
403
  }
404
- })) : E.__isArgsStory = me(x, o, e), e._stories[m] = {
404
+ })) : h.__isArgsStory = ue(x, o, e), e._stories[d] = {
405
405
  id: "FIXME",
406
406
  name: g,
407
- parameters: E,
407
+ parameters: h,
408
408
  __stats: {
409
409
  factory: p
410
410
  }
411
411
  };
412
412
  }
413
- }) : i.specifiers.length > 0 && i.specifiers.forEach((a) => {
414
- if (c.types.isExportSpecifier(a) && c.types.isIdentifier(a.exported)) {
415
- let { name: p } = a.exported, { name: m } = a.local, g = c.types.isProgram(o) ? P(a.local.name, o) : a.local;
413
+ }) : i.specifiers.length > 0 && i.specifiers.forEach((l) => {
414
+ if (c.types.isExportSpecifier(l) && c.types.isIdentifier(l.exported)) {
415
+ let { name: p } = l.exported, { name: d } = l.local, g = c.types.isProgram(o) ? P(d, o) : l.local;
416
416
  if (p === "default") {
417
417
  let x;
418
418
  c.types.isObjectExpression(g) ? x = g : (
419
419
  // export default { ... } as Meta<...>
420
420
  c.types.isTSAsExpression(g) && c.types.isObjectExpression(g.expression) && (x = g.expression)
421
421
  ), x && c.types.isProgram(o) && e._parseMeta(x, o);
422
- } else
423
- e._storyAnnotations[p] = {}, e._storyStatements[p] = g, e._storyPaths[p] = r, e._stories[p] = {
422
+ } else {
423
+ let x = {}, h = g;
424
+ c.types.isObjectExpression(h) && h.properties.forEach((b) => {
425
+ c.types.isIdentifier(b.key) && (x[b.key.name] = b.value);
426
+ }), e._storyAnnotations[p] = x, e._storyStatements[p] = g, e._storyPaths[p] = t, e._stories[p] = {
424
427
  id: "FIXME",
425
428
  name: p,
426
- localName: m,
429
+ localName: d,
427
430
  parameters: {},
428
431
  __stats: {}
429
432
  };
433
+ }
430
434
  }
431
435
  });
432
436
  }
433
437
  },
434
438
  ExpressionStatement: {
435
- enter({ node: r, parent: i }) {
436
- let { expression: o } = r;
439
+ enter({ node: t, parent: i }) {
440
+ let { expression: o } = t;
437
441
  if (c.types.isProgram(i) && c.types.isAssignmentExpression(o) && c.types.isMemberExpression(o.left) && c.types.isIdentifier(o.left.
438
442
  object) && c.types.isIdentifier(o.left.property)) {
439
- let l = o.left.object.name, a = o.left.property.name, p = o.right;
440
- if (e._storyAnnotations[l] && (a === "story" && c.types.isObjectExpression(p) ? p.properties.forEach((m) => {
441
- c.types.isIdentifier(m.key) && (e._storyAnnotations[l][m.key.name] = m.value);
442
- }) : e._storyAnnotations[l][a] = p), a === "storyName" && c.types.isStringLiteral(p)) {
443
- let m = p.value, g = e._stories[l];
443
+ let a = o.left.object.name, l = o.left.property.name, p = o.right;
444
+ if (e._storyAnnotations[a] && (l === "story" && c.types.isObjectExpression(p) ? p.properties.forEach((d) => {
445
+ c.types.isIdentifier(d.key) && (e._storyAnnotations[a][d.key.name] = d.value);
446
+ }) : e._storyAnnotations[a][l] = p), l === "storyName" && c.types.isStringLiteral(p)) {
447
+ let d = p.value, g = e._stories[a];
444
448
  if (!g)
445
449
  return;
446
- g.name = m;
450
+ g.name = d;
447
451
  }
448
452
  }
449
453
  }
450
454
  },
451
455
  CallExpression: {
452
- enter(r) {
453
- let { node: i } = r, { callee: o } = i;
456
+ enter(t) {
457
+ let { node: i } = t, { callee: o } = i;
454
458
  if (c.types.isIdentifier(o) && o.name === "storiesOf")
455
459
  throw new Error(O.dedent`
456
460
  Unexpected \`storiesOf\` usage: ${D(i, e._options.fileName)}.
@@ -459,23 +463,23 @@ var D = /* @__PURE__ */ f((s, e) => {
459
463
  `);
460
464
  if (c.types.isMemberExpression(o) && c.types.isIdentifier(o.property) && o.property.name === "meta" && c.types.isIdentifier(o.object) &&
461
465
  i.arguments.length > 0) {
462
- let a = r.scope.getBinding(o.object.name)?.path?.parentPath?.node;
463
- if (c.types.isImportDeclaration(a))
464
- if (ge(a.source.value)) {
466
+ let l = t.scope.getBinding(o.object.name)?.path?.parentPath?.node;
467
+ if (c.types.isImportDeclaration(l))
468
+ if (ge(l.source.value)) {
465
469
  let p = i.arguments[0];
466
470
  e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
467
471
  } else
468
472
  throw new U(
469
473
  "meta() factory must be imported from .storybook/preview configuration",
470
- a,
474
+ l,
471
475
  e._options.fileName
472
476
  );
473
477
  }
474
478
  }
475
479
  },
476
480
  ImportDeclaration: {
477
- enter({ node: r }) {
478
- let { source: i } = r;
481
+ enter({ node: t }) {
482
+ let { source: i } = t;
479
483
  if (c.types.isStringLiteral(i))
480
484
  e.imports.push(i.value);
481
485
  else
@@ -484,39 +488,39 @@ var D = /* @__PURE__ */ f((s, e) => {
484
488
  }
485
489
  }), !e._meta)
486
490
  throw new L("missing default export", e._ast, e._options.fileName);
487
- let t = Object.entries(e._stories);
491
+ let r = Object.entries(e._stories);
488
492
  if (e._meta.title = this._options.makeTitle(e._meta?.title), e._metaAnnotations.play && (e._meta.tags = [...e._meta.tags || [], "play-fn"]),
489
- e._stories = t.reduce(
490
- (r, [i, o]) => {
491
- if (!(0, I.isExportStory)(i, e._meta))
492
- return r;
493
- let l = o.parameters?.__id ?? (0, I.toId)(e._meta?.id || e._meta?.title, (0, I.storyNameFromExport)(i)), a = { ...o.parameters, __id: l },
493
+ e._stories = r.reduce(
494
+ (t, [i, o]) => {
495
+ if (!(0, v.isExportStory)(i, e._meta))
496
+ return t;
497
+ let a = o.parameters?.__id ?? (0, v.toId)(e._meta?.id || e._meta?.title, (0, v.storyNameFromExport)(i)), l = { ...o.parameters, __id: a },
494
498
  { includeStories: p } = e._meta || {};
495
- i === "__page" && (t.length === 1 || Array.isArray(p) && p.length === 1) && (a.docsOnly = !0), r[i] = { ...o, id: l, parameters: a };
496
- let m = e._storyAnnotations[i], { tags: g, play: x } = m;
499
+ i === "__page" && (r.length === 1 || Array.isArray(p) && p.length === 1) && (l.docsOnly = !0), t[i] = { ...o, id: a, parameters: l };
500
+ let d = e._storyAnnotations[i], { tags: g, play: x } = d;
497
501
  if (g) {
498
- let h = c.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
499
- r[i].tags = de(h);
502
+ let E = c.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
503
+ t[i].tags = de(E);
500
504
  }
501
- x && (r[i].tags = [...r[i].tags || [], "play-fn"]);
502
- let E = r[i].__stats;
503
- ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((h) => {
504
- E[h] = !!m[h] || !!e._metaAnnotations[h];
505
+ x && (t[i].tags = [...t[i].tags || [], "play-fn"]);
506
+ let h = t[i].__stats;
507
+ ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((E) => {
508
+ h[E] = !!d[E] || !!e._metaAnnotations[E];
505
509
  });
506
510
  let b = e.getStoryExport(i);
507
- return E.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), E.mount = tt(m.play ?? e._metaAnnotations.
508
- play), E.moduleMock = !!e.imports.find((h) => xe(h)), r;
511
+ return h.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), h.mount = tt(d.play ?? e._metaAnnotations.
512
+ play), h.moduleMock = !!e.imports.find((E) => xe(E)), t;
509
513
  },
510
514
  {}
511
- ), Object.keys(e._storyExports).forEach((r) => {
512
- (0, I.isExportStory)(r, e._meta) || (delete e._storyExports[r], delete e._storyAnnotations[r], delete e._storyStatements[r]);
515
+ ), Object.keys(e._storyExports).forEach((t) => {
516
+ (0, v.isExportStory)(t, e._meta) || (delete e._storyExports[t], delete e._storyAnnotations[t], delete e._storyStatements[t]);
513
517
  }), e._namedExportsOrder) {
514
- let r = Object.keys(e._storyExports);
515
- e._storyExports = ue(e._storyExports, e._namedExportsOrder), e._stories = ue(e._stories, e._namedExportsOrder);
518
+ let t = Object.keys(e._storyExports);
519
+ e._storyExports = me(e._storyExports, e._namedExportsOrder), e._stories = me(e._stories, e._namedExportsOrder);
516
520
  let i = Object.keys(e._storyExports);
517
- if (r.length !== i.length)
521
+ if (t.length !== i.length)
518
522
  throw new Error(
519
- `Missing exports after sort: ${r.filter(
523
+ `Missing exports after sort: ${t.filter(
520
524
  (o) => !i.includes(o)
521
525
  )}`
522
526
  );
@@ -536,35 +540,35 @@ var D = /* @__PURE__ */ f((s, e) => {
536
540
  O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
537
541
  Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
538
542
  );
539
- return Object.entries(this._stories).map(([t, r]) => {
540
- let i = [...this._meta?.tags ?? [], ...r.tags ?? []];
543
+ return Object.entries(this._stories).map(([r, t]) => {
544
+ let i = [...this._meta?.tags ?? [], ...t.tags ?? []];
541
545
  return {
542
546
  type: "story",
543
547
  importPath: e,
544
548
  rawComponentPath: this._rawComponentPath,
545
- exportName: t,
546
- name: r.name,
549
+ exportName: r,
550
+ name: t.name,
547
551
  title: this.meta?.title,
548
552
  metaId: this.meta?.id,
549
553
  tags: i,
550
- __id: r.id,
551
- __stats: r.__stats
554
+ __id: t.id,
555
+ __stats: t.__stats
552
556
  };
553
557
  });
554
558
  }
555
559
  }, ye = /* @__PURE__ */ f(({
556
560
  code: s,
557
561
  filename: e = "",
558
- ast: t
559
- }) => new c.BabelFileClass({ filename: e }, { code: s, ast: t ?? (0, c.babelParse)(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
560
- let t = (0, c.babelParse)(s), r = ye({ code: s, filename: e.fileName, ast: t });
561
- return new K(t, e, r);
562
- }, "loadCsf"), te = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, t) => {
563
- let r = (0, c.generate)(s._ast, e, t);
564
- return e.sourceMaps ? r : r.code;
562
+ ast: r
563
+ }) => new c.BabelFileClass({ filename: e }, { code: s, ast: r ?? (0, c.babelParse)(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
564
+ let r = (0, c.babelParse)(s), t = ye({ code: s, filename: e.fileName, ast: r });
565
+ return new K(r, e, t);
566
+ }, "loadCsf"), te = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, r) => {
567
+ let t = (0, c.generate)(s._ast, e, r);
568
+ return e.sourceMaps ? t : t.code;
565
569
  }, "formatCsf"), be = /* @__PURE__ */ f((s, e = {}) => c.recast.print(s._ast, e), "printCsf"), it = /* @__PURE__ */ f(async (s, e) => {
566
- let t = (await (0, J.readFile)(s, "utf-8")).toString();
567
- return Q(t, { ...e, fileName: s });
570
+ let r = (await (0, J.readFile)(s, "utf-8")).toString();
571
+ return Q(r, { ...e, fileName: s });
568
572
  }, "readCsf"), st = /* @__PURE__ */ f(async (s, e) => {
569
573
  if (!(e || s._options.fileName))
570
574
  throw new Error("Please specify a fileName for writeCsf");
@@ -572,22 +576,22 @@ var D = /* @__PURE__ */ f((s, e) => {
572
576
  }, "writeCsf");
573
577
 
574
578
  // src/csf-tools/ConfigFile.ts
575
- var ee = require("node:fs/promises"), n = require("storybook/internal/babel"), Ee = z(R(), 1);
579
+ var ee = require("node:fs/promises"), n = require("storybook/internal/babel"), he = z(R(), 1);
576
580
  var re = console, ie = /* @__PURE__ */ f(({
577
581
  expectedType: s,
578
582
  foundType: e,
579
- node: t
580
- }) => Ee.dedent`
581
- CSF Parsing error: Expected '${s}' but found '${e}' instead in '${t?.type}'.
583
+ node: r
584
+ }) => he.dedent`
585
+ CSF Parsing error: Expected '${s}' but found '${e}' instead in '${r?.type}'.
582
586
  `, "getCsfParsingErrorMessage"), C = /* @__PURE__ */ f((s) => n.types.isIdentifier(s.key) ? s.key.name : n.types.isStringLiteral(s.key) ?
583
587
  s.key.value : null, "propKey"), H = /* @__PURE__ */ f((s) => n.types.isTSAsExpression(s) || n.types.isTSSatisfiesExpression(s) ? H(s.expression) :
584
- s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
588
+ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
585
589
  if (s.length === 0)
586
590
  return e;
587
591
  if (n.types.isObjectExpression(e)) {
588
- let [t, ...r] = s, i = e.properties.find((o) => C(o) === t);
592
+ let [r, ...t] = s, i = e.properties.find((o) => C(o) === r);
589
593
  if (i)
590
- return he(r, i.value);
594
+ return Ee(t, i.value);
591
595
  }
592
596
  }, "_getPath"), _e = /* @__PURE__ */ f((s, e) => {
593
597
  if (s.length === 0) {
@@ -596,46 +600,46 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
596
600
  throw new Error("Expected object expression");
597
601
  }
598
602
  if (n.types.isObjectExpression(e)) {
599
- let [t, ...r] = s, i = e.properties.find((o) => C(o) === t);
603
+ let [r, ...t] = s, i = e.properties.find((o) => C(o) === r);
600
604
  if (i)
601
- return r.length === 0 ? e.properties : _e(r, i.value);
605
+ return t.length === 0 ? e.properties : _e(t, i.value);
602
606
  }
603
607
  }, "_getPathProperties"), Y = /* @__PURE__ */ f((s, e) => {
604
- let t = null, r = null;
605
- return e.body.find((i) => (n.types.isVariableDeclaration(i) ? r = i.declarations : n.types.isExportNamedDeclaration(i) && n.types.isVariableDeclaration(
606
- i.declaration) && (r = i.declaration.declarations), r && r.find((o) => n.types.isVariableDeclarator(o) && n.types.isIdentifier(o.id) && o.
607
- id.name === s ? (t = o, !0) : !1))), t;
608
+ let r = null, t = null;
609
+ return e.body.find((i) => (n.types.isVariableDeclaration(i) ? t = i.declarations : n.types.isExportNamedDeclaration(i) && n.types.isVariableDeclaration(
610
+ i.declaration) && (t = i.declaration.declarations), t && t.find((o) => n.types.isVariableDeclarator(o) && n.types.isIdentifier(o.id) && o.
611
+ id.name === s ? (r = o, !0) : !1))), r;
608
612
  }, "_findVarDeclarator"), F = /* @__PURE__ */ f((s, e) => Y(s, e)?.init, "_findVarInitialization"), B = /* @__PURE__ */ f((s, e) => {
609
613
  if (s.length === 0)
610
614
  return e;
611
- let [t, ...r] = s, i = B(r, e);
612
- return n.types.objectExpression([n.types.objectProperty(n.types.identifier(t), i)]);
613
- }, "_makeObjectExpression"), q = /* @__PURE__ */ f((s, e, t) => {
614
- let [r, ...i] = s, o = t.properties.find(
615
- (l) => C(l) === r
615
+ let [r, ...t] = s, i = B(t, e);
616
+ return n.types.objectExpression([n.types.objectProperty(n.types.identifier(r), i)]);
617
+ }, "_makeObjectExpression"), q = /* @__PURE__ */ f((s, e, r) => {
618
+ let [t, ...i] = s, o = r.properties.find(
619
+ (a) => C(a) === t
616
620
  );
617
- o ? n.types.isObjectExpression(o.value) && i.length > 0 ? q(i, e, o.value) : o.value = B(i, e) : t.properties.push(
618
- n.types.objectProperty(n.types.identifier(r), B(i, e))
621
+ o ? n.types.isObjectExpression(o.value) && i.length > 0 ? q(i, e, o.value) : o.value = B(i, e) : r.properties.push(
622
+ n.types.objectProperty(n.types.identifier(t), B(i, e))
619
623
  );
620
624
  }, "_updateExportNode"), Z = class {
621
- constructor(e, t, r) {
625
+ constructor(e, r, t) {
622
626
  this._exports = {};
623
627
  // FIXME: this is a hack. this is only used in the case where the user is
624
628
  // modifying a named export that's a scalar. The _exports map is not suitable
625
629
  // for that. But rather than refactor the whole thing, we just use this as a stopgap.
626
630
  this._exportDecls = {};
627
631
  this.hasDefaultExport = !1;
628
- this._ast = e, this._code = t, this.fileName = r;
632
+ this._ast = e, this._code = r, this.fileName = t;
629
633
  }
630
634
  static {
631
635
  f(this, "ConfigFile");
632
636
  }
633
637
  _parseExportsObject(e) {
634
- this._exportsObject = e, e.properties.forEach((t) => {
635
- let r = C(t);
636
- if (r) {
637
- let i = t.value;
638
- n.types.isIdentifier(i) && (i = F(i.name, this._ast.program)), this._exports[r] = i;
638
+ this._exportsObject = e, e.properties.forEach((r) => {
639
+ let t = C(r);
640
+ if (t) {
641
+ let i = r.value;
642
+ n.types.isIdentifier(i) && (i = F(i.name, this._ast.program)), this._exports[t] = i;
639
643
  }
640
644
  });
641
645
  }
@@ -643,70 +647,70 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
643
647
  let e = this;
644
648
  return (0, n.traverse)(this._ast, {
645
649
  ExportDefaultDeclaration: {
646
- enter({ node: t, parent: r }) {
650
+ enter({ node: r, parent: t }) {
647
651
  e.hasDefaultExport = !0;
648
- let i = n.types.isIdentifier(t.declaration) && n.types.isProgram(r) ? F(t.declaration.name, r) : t.declaration;
652
+ let i = n.types.isIdentifier(r.declaration) && n.types.isProgram(t) ? F(r.declaration.name, t) : r.declaration;
649
653
  i = H(i), n.types.isCallExpression(i) && n.types.isObjectExpression(i.arguments[0]) && (i = i.arguments[0]), n.types.isObjectExpression(
650
654
  i) ? e._parseExportsObject(i) : re.warn(
651
655
  ie({
652
656
  expectedType: "ObjectExpression",
653
657
  foundType: i?.type,
654
- node: i || t.declaration
658
+ node: i || r.declaration
655
659
  })
656
660
  );
657
661
  }
658
662
  },
659
663
  ExportNamedDeclaration: {
660
- enter({ node: t, parent: r }) {
661
- if (n.types.isVariableDeclaration(t.declaration))
662
- t.declaration.declarations.forEach((i) => {
664
+ enter({ node: r, parent: t }) {
665
+ if (n.types.isVariableDeclaration(r.declaration))
666
+ r.declaration.declarations.forEach((i) => {
663
667
  if (n.types.isVariableDeclarator(i) && n.types.isIdentifier(i.id)) {
664
- let { name: o } = i.id, l = i.init;
665
- n.types.isIdentifier(l) && (l = F(l.name, r)), e._exports[o] = l, e._exportDecls[o] = i;
668
+ let { name: o } = i.id, a = i.init;
669
+ n.types.isIdentifier(a) && (a = F(a.name, t)), e._exports[o] = a, e._exportDecls[o] = i;
666
670
  }
667
671
  });
668
- else if (n.types.isFunctionDeclaration(t.declaration)) {
669
- let i = t.declaration;
672
+ else if (n.types.isFunctionDeclaration(r.declaration)) {
673
+ let i = r.declaration;
670
674
  if (n.types.isIdentifier(i.id)) {
671
675
  let { name: o } = i.id;
672
676
  e._exportDecls[o] = i;
673
677
  }
674
- } else t.specifiers ? t.specifiers.forEach((i) => {
678
+ } else r.specifiers ? r.specifiers.forEach((i) => {
675
679
  if (n.types.isExportSpecifier(i) && n.types.isIdentifier(i.local) && n.types.isIdentifier(i.exported)) {
676
- let { name: o } = i.local, { name: l } = i.exported, a = Y(o, r);
677
- a && (e._exports[l] = a.init, e._exportDecls[l] = a);
680
+ let { name: o } = i.local, { name: a } = i.exported, l = Y(o, t);
681
+ l && (e._exports[a] = l.init, e._exportDecls[a] = l);
678
682
  }
679
683
  }) : re.warn(
680
684
  ie({
681
685
  expectedType: "VariableDeclaration",
682
- foundType: t.declaration?.type,
683
- node: t.declaration
686
+ foundType: r.declaration?.type,
687
+ node: r.declaration
684
688
  })
685
689
  );
686
690
  }
687
691
  },
688
692
  ExpressionStatement: {
689
- enter({ node: t, parent: r }) {
690
- if (n.types.isAssignmentExpression(t.expression) && t.expression.operator === "=") {
691
- let { left: i, right: o } = t.expression;
693
+ enter({ node: r, parent: t }) {
694
+ if (n.types.isAssignmentExpression(r.expression) && r.expression.operator === "=") {
695
+ let { left: i, right: o } = r.expression;
692
696
  if (n.types.isMemberExpression(i) && n.types.isIdentifier(i.object) && i.object.name === "module" && n.types.isIdentifier(i.property) &&
693
697
  i.property.name === "exports") {
694
- let l = o;
695
- n.types.isIdentifier(o) && (l = F(o.name, r)), l = H(l), n.types.isObjectExpression(l) ? (e._exportsObject = l, l.properties.forEach(
696
- (a) => {
697
- let p = C(a);
698
+ let a = o;
699
+ n.types.isIdentifier(o) && (a = F(o.name, t)), a = H(a), n.types.isObjectExpression(a) ? (e._exportsObject = a, a.properties.forEach(
700
+ (l) => {
701
+ let p = C(l);
698
702
  if (p) {
699
- let m = a.value;
700
- n.types.isIdentifier(m) && (m = F(
701
- m.name,
702
- r
703
- )), e._exports[p] = m;
703
+ let d = l.value;
704
+ n.types.isIdentifier(d) && (d = F(
705
+ d.name,
706
+ t
707
+ )), e._exports[p] = d;
704
708
  }
705
709
  })) : re.warn(
706
710
  ie({
707
711
  expectedType: "ObjectExpression",
708
- foundType: l?.type,
709
- node: l
712
+ foundType: a?.type,
713
+ node: a
710
714
  })
711
715
  );
712
716
  }
@@ -714,28 +718,28 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
714
718
  }
715
719
  },
716
720
  CallExpression: {
717
- enter: /* @__PURE__ */ f(({ node: t }) => {
718
- n.types.isIdentifier(t.callee) && t.callee.name === "definePreview" && t.arguments.length === 1 && n.types.isObjectExpression(t.arguments[0]) &&
719
- e._parseExportsObject(t.arguments[0]);
721
+ enter: /* @__PURE__ */ f(({ node: r }) => {
722
+ n.types.isIdentifier(r.callee) && r.callee.name === "definePreview" && r.arguments.length === 1 && n.types.isObjectExpression(r.arguments[0]) &&
723
+ e._parseExportsObject(r.arguments[0]);
720
724
  }, "enter")
721
725
  }
722
726
  }), e;
723
727
  }
724
728
  getFieldNode(e) {
725
- let [t, ...r] = e, i = this._exports[t];
729
+ let [r, ...t] = e, i = this._exports[r];
726
730
  if (i)
727
- return he(r, i);
731
+ return Ee(t, i);
728
732
  }
729
733
  getFieldProperties(e) {
730
- let [t, ...r] = e, i = this._exports[t];
734
+ let [r, ...t] = e, i = this._exports[r];
731
735
  if (i)
732
- return _e(r, i);
736
+ return _e(t, i);
733
737
  }
734
738
  getFieldValue(e) {
735
- let t = this.getFieldNode(e);
736
- if (t) {
737
- let { code: r } = (0, n.generate)(t, {});
738
- return (0, eval)(`(() => (${r}))()`);
739
+ let r = this.getFieldNode(e);
740
+ if (r) {
741
+ let { code: t } = (0, n.generate)(r, {});
742
+ return (0, eval)(`(() => (${t}))()`);
739
743
  }
740
744
  }
741
745
  getSafeFieldValue(e) {
@@ -744,32 +748,32 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
744
748
  } catch {
745
749
  }
746
750
  }
747
- setFieldNode(e, t) {
748
- let [r, ...i] = e, o = this._exports[r];
751
+ setFieldNode(e, r) {
752
+ let [t, ...i] = e, o = this._exports[t];
749
753
  if (this._exportsObject) {
750
- let p = this._exportsObject.properties.find((m) => C(m) === r);
754
+ let p = this._exportsObject.properties.find((d) => C(d) === t);
751
755
  if (p && n.types.isIdentifier(p.value)) {
752
- let m = Y(p.value.name, this._ast.program);
753
- if (m && n.types.isObjectExpression(m.init)) {
754
- q(i, t, m.init);
756
+ let d = Y(p.value.name, this._ast.program);
757
+ if (d && n.types.isObjectExpression(d.init)) {
758
+ q(i, r, d.init);
755
759
  return;
756
760
  }
757
761
  }
758
- q(e, t, this._exportsObject), this._exports[e[0]] = t;
762
+ q(e, r, this._exportsObject), this._exports[e[0]] = r;
759
763
  return;
760
764
  }
761
765
  if (o && n.types.isObjectExpression(o) && i.length > 0) {
762
- q(i, t, o);
766
+ q(i, r, o);
763
767
  return;
764
768
  }
765
- let l = Y(r, this._ast.program);
766
- if (l && n.types.isObjectExpression(l.init)) {
767
- q(i, t, l.init);
769
+ let a = Y(t, this._ast.program);
770
+ if (a && n.types.isObjectExpression(a.init)) {
771
+ q(i, r, a.init);
768
772
  return;
769
773
  }
770
774
  if (o && i.length === 0 && this._exportDecls[e[0]]) {
771
- let a = this._exportDecls[e[0]];
772
- n.types.isVariableDeclarator(a) && (a.init = B([], t));
775
+ let l = this._exportDecls[e[0]];
776
+ n.types.isVariableDeclarator(l) && (l.init = B([], r));
773
777
  } else {
774
778
  if (this.hasDefaultExport)
775
779
  throw new Error(
@@ -778,10 +782,10 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
778
782
  )}" field as the default export is not an object in this file.`
779
783
  );
780
784
  {
781
- let a = B(i, t), p = n.types.exportNamedDeclaration(
782
- n.types.variableDeclaration("const", [n.types.variableDeclarator(n.types.identifier(r), a)])
785
+ let l = B(i, r), p = n.types.exportNamedDeclaration(
786
+ n.types.variableDeclaration("const", [n.types.variableDeclarator(n.types.identifier(t), l)])
783
787
  );
784
- this._exports[r] = a, this._ast.program.body.push(p);
788
+ this._exports[t] = l, this._ast.program.body.push(p);
785
789
  }
786
790
  }
787
791
  }
@@ -797,9 +801,9 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
797
801
  * @returns The name of a node in a given path, supporting the following formats:
798
802
  */
799
803
  getNameFromPath(e) {
800
- let t = this.getFieldNode(e);
801
- if (t)
802
- return this._getPresetValue(t, "name");
804
+ let r = this.getFieldNode(e);
805
+ if (r)
806
+ return this._getPresetValue(r, "name");
803
807
  }
804
808
  /**
805
809
  * Returns an array of names of a node in a given path, supporting the following formats:
@@ -815,19 +819,19 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
815
819
  * ```
816
820
  */
817
821
  getNamesFromPath(e) {
818
- let t = this.getFieldNode(e);
819
- if (!t)
822
+ let r = this.getFieldNode(e);
823
+ if (!r)
820
824
  return;
821
- let r = [];
822
- return n.types.isArrayExpression(t) && t.elements.forEach((i) => {
823
- r.push(this._getPresetValue(i, "name"));
824
- }), r;
825
+ let t = [];
826
+ return n.types.isArrayExpression(r) && r.elements.forEach((i) => {
827
+ t.push(this._getPresetValue(i, "name"));
828
+ }), t;
825
829
  }
826
830
  _getPnpWrappedValue(e) {
827
831
  if (n.types.isCallExpression(e)) {
828
- let t = e.arguments[0];
829
- if (n.types.isStringLiteral(t))
830
- return t.value;
832
+ let r = e.arguments[0];
833
+ if (n.types.isStringLiteral(r))
834
+ return r.value;
831
835
  }
832
836
  }
833
837
  /**
@@ -836,88 +840,88 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
836
840
  * 1. `{ node: 'value' }`
837
841
  * 2. `{ node: { fallbackProperty: 'value' } }`
838
842
  */
839
- _getPresetValue(e, t) {
840
- let r;
841
- if (n.types.isStringLiteral(e) ? r = e.value : n.types.isObjectExpression(e) ? e.properties.forEach((i) => {
842
- n.types.isObjectProperty(i) && n.types.isIdentifier(i.key) && i.key.name === t && (n.types.isStringLiteral(i.value) ? r = i.value.value :
843
- r = this._getPnpWrappedValue(i.value)), n.types.isObjectProperty(i) && n.types.isStringLiteral(i.key) && i.key.value === "name" && n.types.
844
- isStringLiteral(i.value) && (r = i.value.value);
845
- }) : n.types.isCallExpression(e) && (r = this._getPnpWrappedValue(e)), !r)
843
+ _getPresetValue(e, r) {
844
+ let t;
845
+ if (n.types.isStringLiteral(e) ? t = e.value : n.types.isObjectExpression(e) ? e.properties.forEach((i) => {
846
+ n.types.isObjectProperty(i) && n.types.isIdentifier(i.key) && i.key.name === r && (n.types.isStringLiteral(i.value) ? t = i.value.value :
847
+ t = this._getPnpWrappedValue(i.value)), n.types.isObjectProperty(i) && n.types.isStringLiteral(i.key) && i.key.value === "name" && n.types.
848
+ isStringLiteral(i.value) && (t = i.value.value);
849
+ }) : n.types.isCallExpression(e) && (t = this._getPnpWrappedValue(e)), !t)
846
850
  throw new Error(
847
- `The given node must be a string literal or an object expression with a "${t}" property that is a string literal.`
851
+ `The given node must be a string literal or an object expression with a "${r}" property that is a string literal.`
848
852
  );
849
- return r;
853
+ return t;
850
854
  }
851
855
  removeField(e) {
852
- let t = /* @__PURE__ */ f((i, o) => {
853
- let l = i.findIndex(
854
- (a) => n.types.isIdentifier(a.key) && a.key.name === o || n.types.isStringLiteral(a.key) && a.key.value === o
856
+ let r = /* @__PURE__ */ f((i, o) => {
857
+ let a = i.findIndex(
858
+ (l) => n.types.isIdentifier(l.key) && l.key.name === o || n.types.isStringLiteral(l.key) && l.key.value === o
855
859
  );
856
- l >= 0 && i.splice(l, 1);
860
+ a >= 0 && i.splice(a, 1);
857
861
  }, "removeProperty");
858
862
  if (e.length === 1) {
859
863
  let i = !1;
860
864
  if (this._ast.program.body.forEach((o) => {
861
865
  if (n.types.isExportNamedDeclaration(o) && n.types.isVariableDeclaration(o.declaration)) {
862
- let l = o.declaration.declarations[0];
863
- n.types.isIdentifier(l.id) && l.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), i = !0);
866
+ let a = o.declaration.declarations[0];
867
+ n.types.isIdentifier(a.id) && a.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), i = !0);
864
868
  }
865
869
  if (n.types.isExportDefaultDeclaration(o)) {
866
- let l = o.declaration;
867
- if (n.types.isIdentifier(l) && (l = F(l.name, this._ast.program)), l = H(l), n.types.isObjectExpression(l)) {
868
- let a = l.properties;
869
- t(a, e[0]), i = !0;
870
+ let a = o.declaration;
871
+ if (n.types.isIdentifier(a) && (a = F(a.name, this._ast.program)), a = H(a), n.types.isObjectExpression(a)) {
872
+ let l = a.properties;
873
+ r(l, e[0]), i = !0;
870
874
  }
871
875
  }
872
876
  if (n.types.isExpressionStatement(o) && n.types.isAssignmentExpression(o.expression) && n.types.isMemberExpression(o.expression.left) &&
873
877
  n.types.isIdentifier(o.expression.left.object) && o.expression.left.object.name === "module" && n.types.isIdentifier(o.expression.left.
874
878
  property) && o.expression.left.property.name === "exports" && n.types.isObjectExpression(o.expression.right)) {
875
- let l = o.expression.right.properties;
876
- t(l, e[0]), i = !0;
879
+ let a = o.expression.right.properties;
880
+ r(a, e[0]), i = !0;
877
881
  }
878
882
  }), i)
879
883
  return;
880
884
  }
881
- let r = this.getFieldProperties(e);
882
- if (r) {
885
+ let t = this.getFieldProperties(e);
886
+ if (t) {
883
887
  let i = e.at(-1);
884
- t(r, i);
888
+ r(t, i);
885
889
  }
886
890
  }
887
- appendValueToArray(e, t) {
888
- let r = this.valueToNode(t);
889
- r && this.appendNodeToArray(e, r);
891
+ appendValueToArray(e, r) {
892
+ let t = this.valueToNode(r);
893
+ t && this.appendNodeToArray(e, t);
890
894
  }
891
- appendNodeToArray(e, t) {
892
- let r = this.getFieldNode(e);
893
- if (!r)
894
- this.setFieldNode(e, n.types.arrayExpression([t]));
895
- else if (n.types.isArrayExpression(r))
896
- r.elements.push(t);
895
+ appendNodeToArray(e, r) {
896
+ let t = this.getFieldNode(e);
897
+ if (!t)
898
+ this.setFieldNode(e, n.types.arrayExpression([r]));
899
+ else if (n.types.isArrayExpression(t))
900
+ t.elements.push(r);
897
901
  else
898
- throw new Error(`Expected array at '${e.join(".")}', got '${r.type}'`);
902
+ throw new Error(`Expected array at '${e.join(".")}', got '${t.type}'`);
899
903
  }
900
904
  /**
901
905
  * Specialized helper to remove addons or other array entries that can either be strings or
902
906
  * objects with a name property.
903
907
  */
904
- removeEntryFromArray(e, t) {
905
- let r = this.getFieldNode(e);
906
- if (r)
907
- if (n.types.isArrayExpression(r)) {
908
- let i = r.elements.findIndex((o) => n.types.isStringLiteral(o) ? o.value === t : n.types.isObjectExpression(o) ? this._getPresetValue(
909
- o, "name") === t : this._getPnpWrappedValue(o) === t);
908
+ removeEntryFromArray(e, r) {
909
+ let t = this.getFieldNode(e);
910
+ if (t)
911
+ if (n.types.isArrayExpression(t)) {
912
+ let i = t.elements.findIndex((o) => n.types.isStringLiteral(o) ? o.value === r : n.types.isObjectExpression(o) ? this._getPresetValue(
913
+ o, "name") === r : this._getPnpWrappedValue(o) === r);
910
914
  if (i >= 0)
911
- r.elements.splice(i, 1);
915
+ t.elements.splice(i, 1);
912
916
  else
913
- throw new Error(`Could not find '${t}' in array at '${e.join(".")}'`);
917
+ throw new Error(`Could not find '${r}' in array at '${e.join(".")}'`);
914
918
  } else
915
- throw new Error(`Expected array at '${e.join(".")}', got '${r.type}'`);
919
+ throw new Error(`Expected array at '${e.join(".")}', got '${t.type}'`);
916
920
  }
917
921
  _inferQuotes() {
918
922
  if (!this._quotes) {
919
923
  let e = (this._ast.tokens || []).slice(0, 500).reduce(
920
- (t, r) => (r.type.label === "string" && (t[this._code[r.start]] += 1), t),
924
+ (r, t) => (t.type.label === "string" && (r[this._code[t.start]] += 1), r),
921
925
  { "'": 0, '"': 0 }
922
926
  );
923
927
  this._quotes = e["'"] > e['"'] ? "single" : "double";
@@ -925,26 +929,26 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
925
929
  return this._quotes;
926
930
  }
927
931
  valueToNode(e) {
928
- let t = this._inferQuotes(), r;
929
- if (t === "single") {
930
- let { code: i } = (0, n.generate)(n.types.valueToNode(e), { jsescOption: { quotes: t } }), o = (0, n.babelParse)(`const __x = ${i}`);
932
+ let r = this._inferQuotes(), t;
933
+ if (r === "single") {
934
+ let { code: i } = (0, n.generate)(n.types.valueToNode(e), { jsescOption: { quotes: r } }), o = (0, n.babelParse)(`const __x = ${i}`);
931
935
  (0, n.traverse)(o, {
932
936
  VariableDeclaration: {
933
- enter({ node: l }) {
934
- l.declarations.length === 1 && n.types.isVariableDeclarator(l.declarations[0]) && n.types.isIdentifier(l.declarations[0].id) && l.
935
- declarations[0].id.name === "__x" && (r = l.declarations[0].init);
937
+ enter({ node: a }) {
938
+ a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) && n.types.isIdentifier(a.declarations[0].id) && a.
939
+ declarations[0].id.name === "__x" && (t = a.declarations[0].init);
936
940
  }
937
941
  }
938
942
  });
939
943
  } else
940
- r = n.types.valueToNode(e);
941
- return r;
944
+ t = n.types.valueToNode(e);
945
+ return t;
942
946
  }
943
- setFieldValue(e, t) {
944
- let r = this.valueToNode(t);
945
- if (!r)
946
- throw new Error(`Unexpected value ${JSON.stringify(t)}`);
947
- this.setFieldNode(e, r);
947
+ setFieldValue(e, r) {
948
+ let t = this.valueToNode(r);
949
+ if (!t)
950
+ throw new Error(`Unexpected value ${JSON.stringify(r)}`);
951
+ this.setFieldNode(e, t);
948
952
  }
949
953
  getBodyDeclarations() {
950
954
  return this._ast.program.body;
@@ -969,40 +973,42 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
969
973
  * import will be set. Otherwise, an array of named imports will be set
970
974
  * @param fromImport - The module to import from
971
975
  */
972
- setRequireImport(e, t) {
973
- let r = this._ast.program.body.find(
974
- (l) => n.types.isVariableDeclaration(l) && l.declarations.length === 1 && n.types.isVariableDeclarator(l.declarations[0]) && n.types.isCallExpression(
975
- l.declarations[0].init) && n.types.isIdentifier(l.declarations[0].init.callee) && l.declarations[0].init.callee.name === "require" && n.types.
976
- isStringLiteral(l.declarations[0].init.arguments[0]) && l.declarations[0].init.arguments[0].value === t
977
- ), i = /* @__PURE__ */ f((l) => n.types.isObjectPattern(r?.declarations[0].id) && r?.declarations[0].id.properties.find(
978
- (a) => n.types.isObjectProperty(a) && n.types.isIdentifier(a.key) && a.key.name === l
979
- ), "hasRequireSpecifier"), o = /* @__PURE__ */ f((l, a) => l.declarations.length === 1 && n.types.isVariableDeclarator(l.declarations[0]) &&
980
- n.types.isIdentifier(l.declarations[0].id) && l.declarations[0].id.name === a, "hasDefaultRequireSpecifier");
976
+ setRequireImport(e, r) {
977
+ let t = this._ast.program.body.find((a) => {
978
+ let l = n.types.isVariableDeclaration(a) && a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) && n.types.
979
+ isCallExpression(a.declarations[0].init) && n.types.isIdentifier(a.declarations[0].init.callee) && a.declarations[0].init.callee.name ===
980
+ "require" && n.types.isStringLiteral(a.declarations[0].init.arguments[0]) && (a.declarations[0].init.arguments[0].value === r || a.declarations[0].
981
+ init.arguments[0].value === r.split("node:")[1]);
982
+ return l && (r = a.declarations[0].init.arguments[0].value), l;
983
+ }), i = /* @__PURE__ */ f((a) => n.types.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
984
+ (l) => n.types.isObjectProperty(l) && n.types.isIdentifier(l.key) && l.key.name === a
985
+ ), "hasRequireSpecifier"), o = /* @__PURE__ */ f((a, l) => a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) &&
986
+ n.types.isIdentifier(a.declarations[0].id) && a.declarations[0].id.name === l, "hasDefaultRequireSpecifier");
981
987
  if (typeof e == "string") {
982
- let l = /* @__PURE__ */ f(() => {
988
+ let a = /* @__PURE__ */ f(() => {
983
989
  this._ast.program.body.unshift(
984
990
  n.types.variableDeclaration("const", [
985
991
  n.types.variableDeclarator(
986
992
  n.types.identifier(e),
987
- n.types.callExpression(n.types.identifier("require"), [n.types.stringLiteral(t)])
993
+ n.types.callExpression(n.types.identifier("require"), [n.types.stringLiteral(r)])
988
994
  )
989
995
  ])
990
996
  );
991
997
  }, "addDefaultRequireSpecifier");
992
- r && o(r, e) || l();
993
- } else r ? e.forEach((l) => {
994
- i(l) || r.declarations[0].id.properties.push(
995
- n.types.objectProperty(n.types.identifier(l), n.types.identifier(l), void 0, !0)
998
+ t && o(t, e) || a();
999
+ } else t ? e.forEach((a) => {
1000
+ i(a) || t.declarations[0].id.properties.push(
1001
+ n.types.objectProperty(n.types.identifier(a), n.types.identifier(a), void 0, !0)
996
1002
  );
997
1003
  }) : this._ast.program.body.unshift(
998
1004
  n.types.variableDeclaration("const", [
999
1005
  n.types.variableDeclarator(
1000
1006
  n.types.objectPattern(
1001
1007
  e.map(
1002
- (l) => n.types.objectProperty(n.types.identifier(l), n.types.identifier(l), void 0, !0)
1008
+ (a) => n.types.objectProperty(n.types.identifier(a), n.types.identifier(a), void 0, !0)
1003
1009
  )
1004
1010
  ),
1005
- n.types.callExpression(n.types.identifier("require"), [n.types.stringLiteral(t)])
1011
+ n.types.callExpression(n.types.identifier("require"), [n.types.stringLiteral(r)])
1006
1012
  )
1007
1013
  ])
1008
1014
  );
@@ -1032,77 +1038,78 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
1032
1038
  * import will be set. Otherwise, an array of named imports will be set
1033
1039
  * @param fromImport - The module to import from
1034
1040
  */
1035
- setImport(e, t) {
1036
- let r = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), i = /* @__PURE__ */ f(
1037
- (p, m) => p.specifiers.find(
1038
- (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === m
1039
- ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, m) => p.specifiers.find(
1040
- (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
1041
- ), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p, m) => p.specifiers.find(
1042
- (g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
1043
- ), "hasDefaultImportSpecifier"), a = this._ast.program.body.find(
1044
- (p) => n.types.isImportDeclaration(p) && p.source.value === t
1045
- );
1046
- e === null ? a || this._ast.program.body.unshift(n.types.importDeclaration([], n.types.stringLiteral(t))) : typeof e == "string" ? a ? l(
1047
- a, e) || a.specifiers.push(
1041
+ setImport(e, r) {
1042
+ let t = this._ast.program.body.find((p) => {
1043
+ let d = n.types.isImportDeclaration(p) && (p.source.value === r || p.source.value === r.split("node:")[1]);
1044
+ return d && (r = p.source.value), d;
1045
+ }), i = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), o = /* @__PURE__ */ f(
1046
+ (p, d) => p.specifiers.find(
1047
+ (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === d
1048
+ ), "hasImportSpecifier"), a = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1049
+ (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1050
+ ), "hasNamespaceImportSpecifier");
1051
+ e === null ? t || this._ast.program.body.unshift(n.types.importDeclaration([], n.types.stringLiteral(r))) : typeof e == "string" ? t ? (/* @__PURE__ */ f(
1052
+ (p, d) => p.specifiers.find(
1053
+ (g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1054
+ ), "hasDefaultImportSpecifier"))(t, e) || t.specifiers.push(
1048
1055
  n.types.importDefaultSpecifier(n.types.identifier(e))
1049
1056
  ) : this._ast.program.body.unshift(
1050
1057
  n.types.importDeclaration(
1051
1058
  [n.types.importDefaultSpecifier(n.types.identifier(e))],
1052
- n.types.stringLiteral(t)
1059
+ n.types.stringLiteral(r)
1053
1060
  )
1054
- ) : Array.isArray(e) ? a ? e.forEach((p) => {
1055
- i(a, p) || a.specifiers.push(r(p));
1061
+ ) : Array.isArray(e) ? t ? e.forEach((p) => {
1062
+ o(t, p) || t.specifiers.push(i(p));
1056
1063
  }) : this._ast.program.body.unshift(
1057
1064
  n.types.importDeclaration(
1058
- e.map(r),
1059
- n.types.stringLiteral(t)
1065
+ e.map(i),
1066
+ n.types.stringLiteral(r)
1060
1067
  )
1061
- ) : e.namespace && (a ? o(a, e.namespace) || a.specifiers.push(
1068
+ ) : e.namespace && (t ? a(t, e.namespace) || t.specifiers.push(
1062
1069
  n.types.importNamespaceSpecifier(n.types.identifier(e.namespace))
1063
1070
  ) : this._ast.program.body.unshift(
1064
1071
  n.types.importDeclaration(
1065
1072
  [n.types.importNamespaceSpecifier(n.types.identifier(e.namespace))],
1066
- n.types.stringLiteral(t)
1073
+ n.types.stringLiteral(r)
1067
1074
  )
1068
1075
  ));
1069
1076
  }
1070
1077
  }, je = /* @__PURE__ */ f((s, e) => {
1071
- let t = (0, n.babelParse)(s);
1072
- return new Z(t, s, e);
1078
+ let r = (0, n.babelParse)(s);
1079
+ return new Z(r, s, e);
1073
1080
  }, "loadConfig"), Se = /* @__PURE__ */ f((s) => Pe(s).code, "formatConfig"), Pe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
1074
1081
  "printConfig"), nt = /* @__PURE__ */ f(async (s) => {
1075
1082
  let e = (await (0, ee.readFile)(s, "utf-8")).toString();
1076
1083
  return je(e, s).parse();
1077
1084
  }, "readConfig"), ot = /* @__PURE__ */ f(async (s, e) => {
1078
- let t = e || s.fileName;
1079
- if (!t)
1085
+ let r = e || s.fileName;
1086
+ if (!r)
1080
1087
  throw new Error("Please specify a fileName for writeConfig");
1081
- await (0, ee.writeFile)(t, Se(s));
1082
- }, "writeConfig"), at = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((t) => n.types.isImportDeclaration(t) && t.source.value.includes(
1083
- "@storybook") && t.specifiers.some((r) => n.types.isImportSpecifier(r) && n.types.isIdentifier(r.imported) && r.imported.name === "definePre\
1088
+ await (0, ee.writeFile)(r, Se(s));
1089
+ }, "writeConfig"), at = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((r) => n.types.isImportDeclaration(r) && r.source.value.includes(
1090
+ "@storybook") && r.specifiers.some((t) => n.types.isImportSpecifier(t) && n.types.isIdentifier(t.imported) && t.imported.name === "definePre\
1084
1091
  view")), "isCsfFactoryPreview");
1085
1092
 
1086
1093
  // src/csf-tools/getStorySortParameter.ts
1087
- var y = require("storybook/internal/babel"), Ie = z(R(), 1);
1094
+ var y = require("storybook/internal/babel"), ve = z(R(), 1);
1088
1095
  var lt = console, se = /* @__PURE__ */ f((s, e) => {
1089
- let t;
1090
- return s.properties.forEach((r) => {
1091
- y.types.isIdentifier(r.key) && r.key.name === e && (t = r.value);
1092
- }), t;
1096
+ let r;
1097
+ return s.properties.forEach((t) => {
1098
+ y.types.isIdentifier(t.key) && t.key.name === e && (r = t.value);
1099
+ }), r;
1093
1100
  }, "getValue"), ne = /* @__PURE__ */ f((s) => {
1094
1101
  let e = W(s);
1095
1102
  if (y.types.isArrayExpression(e))
1096
- return e.elements.map((t) => ne(t));
1103
+ return e.elements.map((r) => ne(r));
1097
1104
  if (y.types.isObjectExpression(e))
1098
- return e.properties.reduce((t, r) => (y.types.isIdentifier(r.key) && (t[r.key.name] = ne(r.value)), t), {});
1105
+ return e.properties.reduce((r, t) => (y.types.isIdentifier(t.key) && (r[t.key.name] = ne(t.value)), r), {});
1099
1106
  if (y.types.isLiteral(e))
1100
1107
  return e.value;
1101
1108
  if (y.types.isIdentifier(e))
1102
1109
  return T(e.name, !0);
1103
1110
  throw new Error(`Unknown node type ${e.type}`);
1104
1111
  }, "parseValue"), T = /* @__PURE__ */ f((s, e) => {
1105
- let t = Ie.dedent`
1112
+ let r = ve.dedent`
1106
1113
  Unexpected '${s}'. Parameter 'options.storySort' should be defined inline e.g.:
1107
1114
 
1108
1115
  export default {
@@ -1114,62 +1121,62 @@ var lt = console, se = /* @__PURE__ */ f((s, e) => {
1114
1121
  };
1115
1122
  `;
1116
1123
  if (e)
1117
- throw new Error(t);
1118
- lt.info(t);
1124
+ throw new Error(r);
1125
+ lt.info(r);
1119
1126
  }, "unsupported"), W = /* @__PURE__ */ f((s) => y.types.isTSAsExpression(s) || y.types.isTSSatisfiesExpression(s) ? s.expression : s, "strip\
1120
1127
  TSModifiers"), De = /* @__PURE__ */ f((s) => {
1121
1128
  let e = W(s);
1122
1129
  if (y.types.isObjectExpression(e)) {
1123
- let t = se(e, "options");
1124
- if (t) {
1125
- if (y.types.isObjectExpression(t))
1126
- return se(t, "storySort");
1130
+ let r = se(e, "options");
1131
+ if (r) {
1132
+ if (y.types.isObjectExpression(r))
1133
+ return se(r, "storySort");
1127
1134
  T("options", !0);
1128
1135
  }
1129
1136
  }
1130
1137
  }, "parseParameters"), Oe = /* @__PURE__ */ f((s, e) => {
1131
- let t = W(s);
1132
- if (y.types.isObjectExpression(t)) {
1133
- let r = se(t, "parameters");
1134
- if (y.types.isIdentifier(r) && (r = P(r.name, e)), r)
1135
- return De(r);
1138
+ let r = W(s);
1139
+ if (y.types.isObjectExpression(r)) {
1140
+ let t = se(r, "parameters");
1141
+ if (y.types.isIdentifier(t) && (t = P(t.name, e)), t)
1142
+ return De(t);
1136
1143
  } else
1137
1144
  T("default", !0);
1138
1145
  }, "parseDefault"), ct = /* @__PURE__ */ f((s) => {
1139
1146
  if (!s.includes("storySort"))
1140
1147
  return;
1141
- let e, t = (0, y.babelParse)(s);
1142
- if ((0, y.traverse)(t, {
1148
+ let e, r = (0, y.babelParse)(s);
1149
+ if ((0, y.traverse)(r, {
1143
1150
  ExportNamedDeclaration: {
1144
- enter({ node: r }) {
1145
- y.types.isVariableDeclaration(r.declaration) ? r.declaration.declarations.forEach((i) => {
1151
+ enter({ node: t }) {
1152
+ y.types.isVariableDeclaration(t.declaration) ? t.declaration.declarations.forEach((i) => {
1146
1153
  if (y.types.isVariableDeclarator(i) && y.types.isIdentifier(i.id)) {
1147
1154
  let { name: o } = i.id;
1148
1155
  if (o === "parameters" && i.init) {
1149
- let l = W(i.init);
1150
- e = De(l);
1156
+ let a = W(i.init);
1157
+ e = De(a);
1151
1158
  }
1152
1159
  }
1153
- }) : r.specifiers.forEach((i) => {
1160
+ }) : t.specifiers.forEach((i) => {
1154
1161
  y.types.isIdentifier(i.exported) && i.exported.name === "parameters" && T("parameters", !1);
1155
1162
  });
1156
1163
  }
1157
1164
  },
1158
1165
  ExportDefaultDeclaration: {
1159
- enter({ node: r }) {
1160
- let i = r.declaration;
1161
- y.types.isIdentifier(i) && (i = P(i.name, t.program)), i = W(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1162
- e = Oe(i.arguments[0], t.program) : y.types.isObjectExpression(i) ? e = Oe(i, t.program) : T("default", !1);
1166
+ enter({ node: t }) {
1167
+ let i = t.declaration;
1168
+ y.types.isIdentifier(i) && (i = P(i.name, r.program)), i = W(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1169
+ e = Oe(i.arguments[0], r.program) : y.types.isObjectExpression(i) ? e = Oe(i, r.program) : T("default", !1);
1163
1170
  }
1164
1171
  }
1165
1172
  }), !!e) {
1166
1173
  if (y.types.isArrowFunctionExpression(e)) {
1167
- let { code: r } = (0, y.generate)(e, {});
1168
- return (0, eval)(r);
1174
+ let { code: t } = (0, y.generate)(e, {});
1175
+ return (0, eval)(t);
1169
1176
  }
1170
1177
  if (y.types.isFunctionExpression(e)) {
1171
- let { code: r } = (0, y.generate)(e, {}), i = e.id?.name, o = `(a, b) => {
1172
- ${r};
1178
+ let { code: t } = (0, y.generate)(e, {}), i = e.id?.name, o = `(a, b) => {
1179
+ ${t};
1173
1180
  return ${i}(a, b)
1174
1181
  }`;
1175
1182
  return (0, eval)(o);
@@ -1179,96 +1186,96 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
1179
1186
  }, "getStorySortParameter");
1180
1187
 
1181
1188
  // src/csf-tools/enrichCsf.ts
1182
- var u = require("storybook/internal/babel");
1183
- var ve = /* @__PURE__ */ f((s, e, t, r) => {
1184
- let i = e.getStoryExport(t), o = u.types.isCallExpression(i) && u.types.isMemberExpression(i.callee) && u.types.isIdentifier(i.callee.object) &&
1185
- i.callee.object.name === "meta", l = !r?.disableSource && Fe(i), a = !r?.disableDescription && oe(e._storyStatements[t]), p = [], m = o ? u.types.
1186
- memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(m, u.types.identifier(
1189
+ var m = require("storybook/internal/babel");
1190
+ var Ie = /* @__PURE__ */ f((s, e, r, t) => {
1191
+ let i = e.getStoryExport(r), o = m.types.isCallExpression(i) && m.types.isMemberExpression(i.callee) && m.types.isIdentifier(i.callee.object) &&
1192
+ i.callee.object.name === "meta", a = !t?.disableSource && Fe(i), l = !t?.disableDescription && oe(e._storyStatements[r]), p = [], d = o ? m.types.
1193
+ memberExpression(m.types.identifier(r), m.types.identifier("input")) : m.types.identifier(r), g = m.types.memberExpression(d, m.types.identifier(
1187
1194
  "parameters"));
1188
- p.push(u.types.spreadElement(g));
1189
- let x = u.types.optionalMemberExpression(
1195
+ p.push(m.types.spreadElement(g));
1196
+ let x = m.types.optionalMemberExpression(
1190
1197
  g,
1191
- u.types.identifier("docs"),
1198
+ m.types.identifier("docs"),
1192
1199
  !1,
1193
1200
  !0
1194
- ), E = [];
1195
- if (l) {
1196
- let b = u.types.optionalMemberExpression(
1201
+ ), h = [];
1202
+ if (a) {
1203
+ let b = m.types.optionalMemberExpression(
1197
1204
  x,
1198
- u.types.identifier("source"),
1205
+ m.types.identifier("source"),
1199
1206
  !1,
1200
1207
  !0
1201
1208
  );
1202
- E.push(
1203
- u.types.objectProperty(
1204
- u.types.identifier("source"),
1205
- u.types.objectExpression([
1206
- u.types.objectProperty(u.types.identifier("originalSource"), u.types.stringLiteral(l)),
1207
- u.types.spreadElement(b)
1209
+ h.push(
1210
+ m.types.objectProperty(
1211
+ m.types.identifier("source"),
1212
+ m.types.objectExpression([
1213
+ m.types.objectProperty(m.types.identifier("originalSource"), m.types.stringLiteral(a)),
1214
+ m.types.spreadElement(b)
1208
1215
  ])
1209
1216
  )
1210
1217
  );
1211
1218
  }
1212
- if (a) {
1213
- let b = u.types.optionalMemberExpression(
1219
+ if (l) {
1220
+ let b = m.types.optionalMemberExpression(
1214
1221
  x,
1215
- u.types.identifier("description"),
1222
+ m.types.identifier("description"),
1216
1223
  !1,
1217
1224
  !0
1218
1225
  );
1219
- E.push(
1220
- u.types.objectProperty(
1221
- u.types.identifier("description"),
1222
- u.types.objectExpression([
1223
- u.types.objectProperty(u.types.identifier("story"), u.types.stringLiteral(a)),
1224
- u.types.spreadElement(b)
1226
+ h.push(
1227
+ m.types.objectProperty(
1228
+ m.types.identifier("description"),
1229
+ m.types.objectExpression([
1230
+ m.types.objectProperty(m.types.identifier("story"), m.types.stringLiteral(l)),
1231
+ m.types.spreadElement(b)
1225
1232
  ])
1226
1233
  )
1227
1234
  );
1228
1235
  }
1229
- if (E.length > 0) {
1236
+ if (h.length > 0) {
1230
1237
  p.push(
1231
- u.types.objectProperty(
1232
- u.types.identifier("docs"),
1233
- u.types.objectExpression([u.types.spreadElement(x), ...E])
1238
+ m.types.objectProperty(
1239
+ m.types.identifier("docs"),
1240
+ m.types.objectExpression([m.types.spreadElement(x), ...h])
1234
1241
  )
1235
1242
  );
1236
- let b = u.types.expressionStatement(
1237
- u.types.assignmentExpression("=", g, u.types.objectExpression(p))
1243
+ let b = m.types.expressionStatement(
1244
+ m.types.assignmentExpression("=", g, m.types.objectExpression(p))
1238
1245
  );
1239
1246
  s._ast.program.body.push(b);
1240
1247
  }
1241
- }, "enrichCsfStory"), Ne = /* @__PURE__ */ f((s, e, t) => {
1248
+ }, "enrichCsfStory"), Ne = /* @__PURE__ */ f((s, e, r) => {
1242
1249
  if (!e.length) {
1243
1250
  s.properties.find(
1244
- (p) => u.types.isObjectProperty(p) && u.types.isIdentifier(p.key) && p.key.name === "component"
1245
- ) || s.properties.unshift(t);
1251
+ (p) => m.types.isObjectProperty(p) && m.types.isIdentifier(p.key) && p.key.name === "component"
1252
+ ) || s.properties.unshift(r);
1246
1253
  return;
1247
1254
  }
1248
- let [r, ...i] = e, o = s.properties.find(
1249
- (a) => u.types.isObjectProperty(a) && u.types.isIdentifier(a.key) && a.key.name === r && u.types.isObjectExpression(a.value)
1250
- ), l;
1251
- o ? l = o.value : (l = u.types.objectExpression([]), s.properties.push(u.types.objectProperty(u.types.identifier(r), l))), Ne(l, i, t);
1252
- }, "addComponentDescription"), we = /* @__PURE__ */ f((s, e, t) => {
1253
- let r = !t?.disableDescription && oe(e._metaStatement);
1254
- if (r) {
1255
+ let [t, ...i] = e, o = s.properties.find(
1256
+ (l) => m.types.isObjectProperty(l) && m.types.isIdentifier(l.key) && l.key.name === t && m.types.isObjectExpression(l.value)
1257
+ ), a;
1258
+ o ? a = o.value : (a = m.types.objectExpression([]), s.properties.push(m.types.objectProperty(m.types.identifier(t), a))), Ne(a, i, r);
1259
+ }, "addComponentDescription"), we = /* @__PURE__ */ f((s, e, r) => {
1260
+ let t = !r?.disableDescription && oe(e._metaStatement);
1261
+ if (t) {
1255
1262
  let i = s._metaNode;
1256
- i && u.types.isObjectExpression(i) && Ne(
1263
+ i && m.types.isObjectExpression(i) && Ne(
1257
1264
  i,
1258
1265
  ["parameters", "docs", "description"],
1259
- u.types.objectProperty(u.types.identifier("component"), u.types.stringLiteral(r))
1266
+ m.types.objectProperty(m.types.identifier("component"), m.types.stringLiteral(t))
1260
1267
  );
1261
1268
  }
1262
- }, "enrichCsfMeta"), pt = /* @__PURE__ */ f((s, e, t) => {
1263
- we(s, e, t), Object.keys(s._storyExports).forEach((r) => {
1264
- ve(s, e, r, t);
1269
+ }, "enrichCsfMeta"), pt = /* @__PURE__ */ f((s, e, r) => {
1270
+ we(s, e, r), Object.keys(s._storyExports).forEach((t) => {
1271
+ Ie(s, e, t, r);
1265
1272
  });
1266
1273
  }, "enrichCsf"), Fe = /* @__PURE__ */ f((s) => {
1267
- let e = u.types.isVariableDeclarator(s) ? s.init : s, { code: t } = (0, u.generate)(e, {});
1268
- return t;
1269
- }, "extractSource"), oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((t) => t.type === "CommentLine" || !t.value.startsWith(
1270
- "*") ? null : t.value.split(`
1271
- `).map((r) => r.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
1274
+ let e = m.types.isVariableDeclarator(s) ? s.init : s, { code: r } = (0, m.generate)(e, {});
1275
+ return r;
1276
+ }, "extractSource"), oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((r) => r.type === "CommentLine" || !r.value.startsWith(
1277
+ "*") ? null : r.value.split(`
1278
+ `).map((t) => t.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
1272
1279
  `).trim()).filter(Boolean).join(`
1273
1280
  `) : "", "extractDescription");
1274
1281
 
@@ -1276,40 +1283,40 @@ var ve = /* @__PURE__ */ f((s, e, t, r) => {
1276
1283
  var Ae = require("storybook/internal/babel");
1277
1284
 
1278
1285
  // src/csf-tools/vitest-plugin/transformer.ts
1279
- var d = require("storybook/internal/babel"), Te = require("storybook/internal/common"), ke = require("storybook/internal/csf"), ae = z(R(), 1);
1280
- var Ce = console, ft = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((t) => s?.includes(t)) || e.exclude.some((t) => s?.
1281
- includes(t))), "isValidTest");
1286
+ var u = require("storybook/internal/babel"), Te = require("storybook/internal/common"), ke = require("storybook/internal/csf"), ae = z(R(), 1);
1287
+ var Ce = console, ft = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((r) => s?.includes(r)) || e.exclude.some((r) => s?.
1288
+ includes(r))), "isValidTest");
1282
1289
  async function Ve({
1283
1290
  code: s,
1284
1291
  fileName: e,
1285
- configDir: t,
1286
- stories: r,
1292
+ configDir: r,
1293
+ stories: t,
1287
1294
  tagsFilter: i,
1288
1295
  previewLevelTags: o = []
1289
1296
  }) {
1290
1297
  if (!/\.stor(y|ies)\./.test(e))
1291
1298
  return s;
1292
- let a = Q(s, {
1299
+ let l = Q(s, {
1293
1300
  fileName: e,
1294
1301
  transformInlineMeta: !0,
1295
1302
  makeTitle: /* @__PURE__ */ f((_) => {
1296
1303
  let S = (0, Te.getStoryTitle)({
1297
1304
  storyFilePath: e,
1298
- configDir: t,
1299
- stories: r,
1305
+ configDir: r,
1306
+ stories: t,
1300
1307
  userTitle: _
1301
1308
  }) || "unknown";
1302
1309
  return S === "unknown" && Ce.warn(
1303
1310
  ae.dedent`
1304
1311
  [Storybook]: Could not calculate story title for "${e}".
1305
- Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${t}".
1312
+ Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${r}".
1306
1313
  `
1307
1314
  ), S;
1308
1315
  }, "makeTitle")
1309
- }).parse(), p = a._ast, m = a._metaVariableName, g = a._metaNode, x = g.properties.find(
1310
- (_) => d.types.isObjectProperty(_) && d.types.isIdentifier(_.key) && _.key.name === "title"
1311
- ), E = d.types.stringLiteral(a._meta?.title || "unknown");
1312
- if (x ? d.types.isObjectProperty(x) && (x.value = E) : g.properties.push(d.types.objectProperty(d.types.identifier("title"), E)), !g || !a.
1316
+ }).parse(), p = l._ast, d = l._metaVariableName, g = l._metaNode, x = g.properties.find(
1317
+ (_) => u.types.isObjectProperty(_) && u.types.isIdentifier(_.key) && _.key.name === "title"
1318
+ ), h = u.types.stringLiteral(l._meta?.title || "unknown");
1319
+ if (x ? u.types.isObjectProperty(x) && (x.value = h) : g.properties.push(u.types.objectProperty(u.types.identifier("title"), h)), !g || !l.
1313
1320
  _meta)
1314
1321
  throw new Error(
1315
1322
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
@@ -1318,67 +1325,67 @@ Please make sure you have a default export with the meta object. If you are usin
1318
1325
  le an issue with details about your use case.`
1319
1326
  );
1320
1327
  let b = {};
1321
- Object.keys(a._stories).map((_) => {
1328
+ Object.keys(l._stories).map((_) => {
1322
1329
  let S = (0, ke.combineTags)(
1323
1330
  "test",
1324
1331
  "dev",
1325
1332
  ...o,
1326
- ...a.meta?.tags || [],
1327
- ...a._stories[_].tags || []
1333
+ ...l.meta?.tags || [],
1334
+ ...l._stories[_].tags || []
1328
1335
  );
1329
- ft(S, i) && (b[_] = a._storyStatements[_]);
1336
+ ft(S, i) && (b[_] = l._storyStatements[_]);
1330
1337
  });
1331
- let h = a._file.path.scope.generateUidIdentifier("test"), v = a._file.path.scope.generateUidIdentifier("describe");
1338
+ let E = l._file.path.scope.generateUidIdentifier("test"), I = l._file.path.scope.generateUidIdentifier("describe");
1332
1339
  if (Object.keys(b).length === 0) {
1333
- let _ = d.types.expressionStatement(
1334
- d.types.callExpression(d.types.memberExpression(v, d.types.identifier("skip")), [
1335
- d.types.stringLiteral("No valid tests found")
1340
+ let _ = u.types.expressionStatement(
1341
+ u.types.callExpression(u.types.memberExpression(I, u.types.identifier("skip")), [
1342
+ u.types.stringLiteral("No valid tests found")
1336
1343
  ])
1337
1344
  );
1338
1345
  p.program.body.push(_);
1339
1346
  let S = [
1340
- d.types.importDeclaration(
1347
+ u.types.importDeclaration(
1341
1348
  [
1342
- d.types.importSpecifier(h, d.types.identifier("test")),
1343
- d.types.importSpecifier(v, d.types.identifier("describe"))
1349
+ u.types.importSpecifier(E, u.types.identifier("test")),
1350
+ u.types.importSpecifier(I, u.types.identifier("describe"))
1344
1351
  ],
1345
- d.types.stringLiteral("vitest")
1352
+ u.types.stringLiteral("vitest")
1346
1353
  )
1347
1354
  ];
1348
1355
  p.program.body.unshift(...S);
1349
1356
  } else {
1350
1357
  let le = function() {
1351
- let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = d.types.memberExpression(
1352
- d.types.callExpression(d.types.memberExpression(_, d.types.identifier("getState")), []),
1353
- d.types.identifier("testPath")
1354
- ), k = d.types.memberExpression(
1355
- d.types.memberExpression(d.types.identifier("globalThis"), d.types.identifier("__vitest_worker__")),
1356
- d.types.identifier("filepath")
1357
- ), V = d.types.logicalExpression(
1358
+ let j = l._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = u.types.memberExpression(
1359
+ u.types.callExpression(u.types.memberExpression(_, u.types.identifier("getState")), []),
1360
+ u.types.identifier("testPath")
1361
+ ), k = u.types.memberExpression(
1362
+ u.types.memberExpression(u.types.identifier("globalThis"), u.types.identifier("__vitest_worker__")),
1363
+ u.types.identifier("filepath")
1364
+ ), V = u.types.logicalExpression(
1358
1365
  "??",
1359
1366
  // TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
1360
1367
  // https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
1361
1368
  k,
1362
1369
  N
1363
- ), G = d.types.callExpression(
1364
- d.types.memberExpression(
1365
- d.types.callExpression(d.types.identifier("convertToFilePath"), [
1366
- d.types.memberExpression(
1367
- d.types.memberExpression(d.types.identifier("import"), d.types.identifier("meta")),
1368
- d.types.identifier("url")
1370
+ ), G = u.types.callExpression(
1371
+ u.types.memberExpression(
1372
+ u.types.callExpression(u.types.identifier("convertToFilePath"), [
1373
+ u.types.memberExpression(
1374
+ u.types.memberExpression(u.types.identifier("import"), u.types.identifier("meta")),
1375
+ u.types.identifier("url")
1369
1376
  )
1370
1377
  ]),
1371
- d.types.identifier("includes")
1378
+ u.types.identifier("includes")
1372
1379
  ),
1373
1380
  [V]
1374
1381
  );
1375
- return { isRunningFromThisFileDeclaration: d.types.variableDeclaration("const", [
1376
- d.types.variableDeclarator(j, G)
1382
+ return { isRunningFromThisFileDeclaration: u.types.variableDeclaration("const", [
1383
+ u.types.variableDeclarator(j, G)
1377
1384
  ]), isRunningFromThisFileId: j };
1378
1385
  };
1379
- var mt = le;
1386
+ var ut = le;
1380
1387
  f(le, "getTestGuardDeclaration");
1381
- let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), $e = d.types.identifier(
1388
+ let _ = l._file.path.scope.generateUidIdentifier("expect"), S = l._file.path.scope.generateUidIdentifier("testStory"), $e = u.types.identifier(
1382
1389
  JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Re, isRunningFromThisFileId: Le } = le();
1383
1390
  p.program.body.push(Re);
1384
1391
  let Me = /* @__PURE__ */ f(({
@@ -1387,13 +1394,13 @@ le an issue with details about your use case.`
1387
1394
  testTitle: k,
1388
1395
  node: V
1389
1396
  }) => {
1390
- let G = d.types.expressionStatement(
1391
- d.types.callExpression(h, [
1392
- d.types.stringLiteral(k),
1393
- d.types.callExpression(S, [
1394
- d.types.stringLiteral(N),
1395
- d.types.identifier(j),
1396
- d.types.identifier(m),
1397
+ let G = u.types.expressionStatement(
1398
+ u.types.callExpression(E, [
1399
+ u.types.stringLiteral(k),
1400
+ u.types.callExpression(S, [
1401
+ u.types.stringLiteral(N),
1402
+ u.types.identifier(j),
1403
+ u.types.identifier(d),
1397
1404
  $e
1398
1405
  ])
1399
1406
  ])
@@ -1409,28 +1416,28 @@ le an issue with details about your use case.`
1409
1416
  );
1410
1417
  return;
1411
1418
  }
1412
- let k = a._stories[j].localName ?? j, V = a._stories[j].name ?? j;
1419
+ let k = l._stories[j].localName ?? j, V = l._stories[j].name ?? j;
1413
1420
  return Me({ testTitle: V, localName: k, exportName: j, node: N });
1414
- }).filter((j) => !!j), qe = d.types.ifStatement(Le, d.types.blockStatement(Ue));
1421
+ }).filter((j) => !!j), qe = u.types.ifStatement(Le, u.types.blockStatement(Ue));
1415
1422
  p.program.body.push(qe);
1416
1423
  let Be = [
1417
- d.types.importDeclaration(
1424
+ u.types.importDeclaration(
1418
1425
  [
1419
- d.types.importSpecifier(h, d.types.identifier("test")),
1420
- d.types.importSpecifier(_, d.types.identifier("expect"))
1426
+ u.types.importSpecifier(E, u.types.identifier("test")),
1427
+ u.types.importSpecifier(_, u.types.identifier("expect"))
1421
1428
  ],
1422
- d.types.stringLiteral("vitest")
1429
+ u.types.stringLiteral("vitest")
1423
1430
  ),
1424
- d.types.importDeclaration(
1431
+ u.types.importDeclaration(
1425
1432
  [
1426
- d.types.importSpecifier(S, d.types.identifier("testStory")),
1427
- d.types.importSpecifier(d.types.identifier("convertToFilePath"), d.types.identifier("convertToFilePath"))
1433
+ u.types.importSpecifier(S, u.types.identifier("testStory")),
1434
+ u.types.importSpecifier(u.types.identifier("convertToFilePath"), u.types.identifier("convertToFilePath"))
1428
1435
  ],
1429
- d.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1436
+ u.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1430
1437
  )
1431
1438
  ];
1432
1439
  p.program.body.unshift(...Be);
1433
1440
  }
1434
- return te(a, { sourceMaps: !0, sourceFileName: e }, s);
1441
+ return te(l, { sourceMaps: !0, sourceFileName: e }, s);
1435
1442
  }
1436
1443
  f(Ve, "vitestTransform");