storybook 9.0.0-alpha.14 → 9.0.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,96 +1,96 @@
1
1
  "use strict";
2
2
  var We = Object.create;
3
- var V = Object.defineProperty;
3
+ var A = Object.defineProperty;
4
4
  var Ge = Object.getOwnPropertyDescriptor;
5
5
  var ze = Object.getOwnPropertyNames;
6
6
  var Xe = Object.getPrototypeOf, Ke = Object.prototype.hasOwnProperty;
7
- var p = (s, e) => V(s, "name", { value: e, configurable: !0 });
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
9
  for (var t in e)
10
- V(s, t, { get: e[t], enumerable: !0 });
11
- }, le = (s, e, t, r) => {
10
+ A(s, t, { get: e[t], enumerable: !0 });
11
+ }, ce = (s, e, t, r) => {
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 && V(s, i, { get: () => e[i], enumerable: !(r = Ge(e, i)) || r.enumerable });
14
+ !Ke.call(s, i) && i !== t && A(s, i, { get: () => e[i], enumerable: !(r = Ge(e, i)) || r.enumerable });
15
15
  return s;
16
16
  };
17
- var G = (s, e, t) => (t = s != null ? We(Xe(s)) : {}, le(
17
+ var z = (s, e, t) => (t = 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 ? V(t, "default", { value: s, enumerable: !0 }) : t,
22
+ e || !s || !s.__esModule ? A(t, "default", { value: s, enumerable: !0 }) : t,
23
23
  s
24
- )), He = (s) => le(V({}, "__esModule", { value: !0 }), s);
24
+ )), He = (s) => ce(A({}, "__esModule", { value: !0 }), s);
25
25
 
26
26
  // ../node_modules/ts-dedent/dist/index.js
27
- var $ = Je((A) => {
27
+ var R = Je(($) => {
28
28
  "use strict";
29
- Object.defineProperty(A, "__esModule", { value: !0 });
30
- A.dedent = void 0;
31
- function ce(s) {
29
+ Object.defineProperty($, "__esModule", { value: !0 });
30
+ $.dedent = void 0;
31
+ function pe(s) {
32
32
  for (var e = [], t = 1; t < arguments.length; t++)
33
33
  e[t - 1] = arguments[t];
34
34
  var r = Array.from(typeof s == "string" ? [s] : s);
35
35
  r[r.length - 1] = r[r.length - 1].replace(/\r?\n([\t ]*)$/, "");
36
- var i = r.reduce(function(l, f) {
37
- var m = f.match(/\n([\t ]+|(?!\s).)/g);
38
- return m ? l.concat(m.map(function(g) {
36
+ var i = r.reduce(function(a, p) {
37
+ var d = p.match(/\n([\t ]+|(?!\s).)/g);
38
+ return d ? a.concat(d.map(function(g) {
39
39
  var x, E;
40
40
  return (E = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && E !== void 0 ? E : 0;
41
- })) : l;
41
+ })) : a;
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(l) {
47
- return l.replace(o, `
46
+ r = r.map(function(a) {
47
+ return a.replace(o, `
48
48
  `);
49
49
  });
50
50
  }
51
51
  r[0] = r[0].replace(/^\r?\n/, "");
52
- var a = r[0];
53
- return e.forEach(function(l, f) {
54
- var m = a.match(/(?:^|\n)( *)$/), g = m ? m[1] : "", x = l;
55
- typeof l == "string" && l.includes(`
56
- `) && (x = String(l).split(`
52
+ var l = r[0];
53
+ return e.forEach(function(a, p) {
54
+ var d = l.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = a;
55
+ typeof a == "string" && a.includes(`
56
+ `) && (x = String(a).split(`
57
57
  `).map(function(E, b) {
58
58
  return b === 0 ? E : "" + g + E;
59
59
  }).join(`
60
- `)), a += x + r[f + 1];
61
- }), a;
60
+ `)), l += x + r[p + 1];
61
+ }), l;
62
62
  }
63
- p(ce, "dedent");
64
- A.dedent = ce;
65
- A.default = ce;
63
+ f(pe, "dedent");
64
+ $.dedent = pe;
65
+ $.default = pe;
66
66
  });
67
67
 
68
68
  // src/csf-tools/index.ts
69
69
  var dt = {};
70
70
  Qe(dt, {
71
- BadMetaError: () => M,
72
- ConfigFile: () => H,
73
- CsfFile: () => X,
74
- MixedFactoryError: () => L,
75
- MultipleMetaError: () => z,
76
- NoMetaError: () => R,
71
+ BadMetaError: () => U,
72
+ ConfigFile: () => Z,
73
+ CsfFile: () => K,
74
+ MixedFactoryError: () => M,
75
+ MultipleMetaError: () => X,
76
+ NoMetaError: () => L,
77
77
  babelParse: () => Ae.babelParse,
78
- babelParseFile: () => xe,
78
+ babelParseFile: () => ye,
79
79
  enrichCsf: () => pt,
80
80
  enrichCsfMeta: () => we,
81
81
  enrichCsfStory: () => Ne,
82
- extractDescription: () => ne,
82
+ extractDescription: () => oe,
83
83
  extractSource: () => Fe,
84
84
  formatConfig: () => Se,
85
- formatCsf: () => Z,
85
+ formatCsf: () => te,
86
86
  getStorySortParameter: () => ct,
87
87
  isCsfFactoryPreview: () => at,
88
- isModuleMock: () => ge,
89
- isValidPreviewPath: () => ue,
88
+ isModuleMock: () => xe,
89
+ isValidPreviewPath: () => ge,
90
90
  loadConfig: () => je,
91
- loadCsf: () => J,
92
- printConfig: () => Pe,
93
- printCsf: () => ye,
91
+ loadCsf: () => Q,
92
+ printConfig: () => Oe,
93
+ printCsf: () => be,
94
94
  readConfig: () => nt,
95
95
  readCsf: () => it,
96
96
  vitestTransform: () => Ve,
@@ -100,11 +100,11 @@ Qe(dt, {
100
100
  module.exports = He(dt);
101
101
 
102
102
  // src/csf-tools/CsfFile.ts
103
- var K = require("node:fs/promises"), c = require("storybook/internal/babel"), I = require("storybook/internal/csf"), O = G($(), 1);
103
+ var J = require("node:fs/promises"), c = require("storybook/internal/babel"), I = require("storybook/internal/csf"), P = z(R(), 1);
104
104
 
105
105
  // src/csf-tools/findVarInitialization.ts
106
106
  var w = require("storybook/internal/babel");
107
- var P = /* @__PURE__ */ p((s, e) => {
107
+ var O = /* @__PURE__ */ f((s, e) => {
108
108
  let t = null, r = null;
109
109
  return e.body.find((i) => (w.types.isVariableDeclaration(i) ? r = i.declarations : w.types.isExportNamedDeclaration(i) && w.types.isVariableDeclaration(
110
110
  i.declaration) && (r = i.declaration.declarations), r && r.find((o) => w.types.isVariableDeclarator(o) && w.types.isIdentifier(o.id) && o.
@@ -112,7 +112,7 @@ var P = /* @__PURE__ */ p((s, e) => {
112
112
  }, "findVarInitialization");
113
113
 
114
114
  // src/csf-tools/CsfFile.ts
115
- var pe = console, Ye = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, ue = /* @__PURE__ */ p((s) => Ye.test(s), "isValidPreviewPath");
115
+ var fe = console, Ye = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, ge = /* @__PURE__ */ f((s) => Ye.test(s), "isValidPreviewPath");
116
116
  function Ze(s) {
117
117
  if (c.types.isArrayExpression(s))
118
118
  return s.elements.map((e) => {
@@ -126,8 +126,8 @@ function Ze(s) {
126
126
  return new RegExp(s.pattern, s.flags);
127
127
  throw new Error(`Unknown include/exclude: ${s}`);
128
128
  }
129
- p(Ze, "parseIncludeExclude");
130
- function fe(s) {
129
+ f(Ze, "parseIncludeExclude");
130
+ function de(s) {
131
131
  if (!c.types.isArrayExpression(s))
132
132
  throw new Error("CSF: Expected tags array");
133
133
  return s.elements.map((e) => {
@@ -136,26 +136,26 @@ function fe(s) {
136
136
  throw new Error("CSF: Expected tag to be string literal");
137
137
  });
138
138
  }
139
- p(fe, "parseTags");
140
- var D = /* @__PURE__ */ p((s, e) => {
139
+ f(de, "parseTags");
140
+ var D = /* @__PURE__ */ f((s, e) => {
141
141
  let t = "";
142
142
  if (s.loc) {
143
143
  let { line: r, column: i } = s.loc?.start || {};
144
144
  t = `(line ${r}, col ${i})`;
145
145
  }
146
146
  return `${e || ""} ${t}`.trim();
147
- }, "formatLocation"), ge = /* @__PURE__ */ p((s) => rt.test(s), "isModuleMock"), de = /* @__PURE__ */ p((s, e, t) => {
147
+ }, "formatLocation"), xe = /* @__PURE__ */ f((s) => rt.test(s), "isModuleMock"), me = /* @__PURE__ */ f((s, e, t) => {
148
148
  let r = 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 a = i.object.name, l = P(a, e);
154
- l && (t._templates[a] = l, r = l);
153
+ let l = i.object.name, a = O(l, e);
154
+ a && (t._templates[l] = a, r = a);
155
155
  }
156
156
  }
157
157
  return c.types.isArrowFunctionExpression(r) || c.types.isFunctionDeclaration(r) ? r.params.length > 0 : !1;
158
- }, "isArgsStory"), et = /* @__PURE__ */ p((s) => {
158
+ }, "isArgsStory"), et = /* @__PURE__ */ f((s) => {
159
159
  if (c.types.isArrayExpression(s))
160
160
  return s.elements.map((e) => {
161
161
  if (c.types.isStringLiteral(e))
@@ -163,13 +163,13 @@ var D = /* @__PURE__ */ p((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"), me = /* @__PURE__ */ p((s, e) => e.reduce(
166
+ }, "parseExportsOrder"), ue = /* @__PURE__ */ f((s, e) => e.reduce(
167
167
  (t, r) => {
168
168
  let i = s[r];
169
169
  return i && (t[r] = i), t;
170
170
  },
171
171
  {}
172
- ), "sortExports"), tt = /* @__PURE__ */ p((s) => {
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) {
@@ -182,55 +182,55 @@ var D = /* @__PURE__ */ p((s, e) => {
182
182
  }
183
183
  }
184
184
  return !1;
185
- }, "hasMount"), rt = /^[.\/#].*\.mock($|\.[^.]*$)/i, R = class extends Error {
185
+ }, "hasMount"), rt = /^[.\/#].*\.mock($|\.[^.]*$)/i, L = class extends Error {
186
186
  static {
187
- p(this, "NoMetaError");
187
+ f(this, "NoMetaError");
188
188
  }
189
189
  constructor(e, t, r) {
190
190
  let i = "".trim();
191
- super(O.dedent`
191
+ super(P.dedent`
192
192
  CSF: ${e} ${D(t, r)}
193
193
 
194
194
  More info: https://storybook.js.org/docs/writing-stories#default-export
195
195
  `), this.name = this.constructor.name;
196
196
  }
197
- }, z = class extends Error {
197
+ }, X = class extends Error {
198
198
  static {
199
- p(this, "MultipleMetaError");
199
+ f(this, "MultipleMetaError");
200
200
  }
201
201
  constructor(e, t, r) {
202
202
  let i = `${e} ${D(t, r)}`.trim();
203
- super(O.dedent`
203
+ super(P.dedent`
204
204
  CSF: ${e} ${D(t, r)}
205
205
 
206
206
  More info: https://storybook.js.org/docs/writing-stories#default-export
207
207
  `), this.name = this.constructor.name;
208
208
  }
209
- }, L = class extends Error {
209
+ }, M = class extends Error {
210
210
  static {
211
- p(this, "MixedFactoryError");
211
+ f(this, "MixedFactoryError");
212
212
  }
213
213
  constructor(e, t, r) {
214
214
  let i = `${e} ${D(t, r)}`.trim();
215
- super(O.dedent`
215
+ super(P.dedent`
216
216
  CSF: ${e} ${D(t, r)}
217
217
 
218
218
  More info: https://storybook.js.org/docs/writing-stories#default-export
219
219
  `), this.name = this.constructor.name;
220
220
  }
221
- }, M = class extends Error {
221
+ }, U = class extends Error {
222
222
  static {
223
- p(this, "BadMetaError");
223
+ f(this, "BadMetaError");
224
224
  }
225
225
  constructor(e, t, r) {
226
226
  let i = "".trim();
227
- super(O.dedent`
227
+ super(P.dedent`
228
228
  CSF: ${e} ${D(t, r)}
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
- }, X = class {
233
+ }, K = class {
234
234
  constructor(e, t, r) {
235
235
  this._stories = {};
236
236
  this._metaAnnotations = {};
@@ -242,15 +242,15 @@ var D = /* @__PURE__ */ p((s, e) => {
242
242
  this._ast = e, this._file = r, this._options = t, this.imports = [];
243
243
  }
244
244
  static {
245
- p(this, "CsfFile");
245
+ f(this, "CsfFile");
246
246
  }
247
247
  _parseTitle(e) {
248
- let t = c.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
248
+ let t = c.types.isIdentifier(e) ? O(e.name, this._ast.program) : e;
249
249
  if (c.types.isStringLiteral(t))
250
250
  return t.value;
251
251
  if (c.types.isTSSatisfiesExpression(t) && c.types.isStringLiteral(t.expression))
252
252
  return t.expression.value;
253
- throw new Error(O.dedent`
253
+ throw new Error(P.dedent`
254
254
  CSF: unexpected dynamic title ${D(t, this._options.fileName)}
255
255
 
256
256
  More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
@@ -258,7 +258,7 @@ var D = /* @__PURE__ */ p((s, e) => {
258
258
  }
259
259
  _parseMeta(e, t) {
260
260
  if (this._metaNode)
261
- throw new z("multiple meta objects", e, this._options.fileName);
261
+ throw new X("multiple meta objects", e, this._options.fileName);
262
262
  this._metaNode = e;
263
263
  let r = {};
264
264
  e.properties.forEach((i) => {
@@ -270,19 +270,19 @@ var D = /* @__PURE__ */ p((s, e) => {
270
270
  else if (i.key.name === "component") {
271
271
  let o = i.value;
272
272
  if (c.types.isIdentifier(o)) {
273
- let l = o.name, f = t.body.find(
274
- (m) => c.types.isImportDeclaration(m) && m.specifiers.find((g) => g.local.name === l)
273
+ let a = o.name, p = t.body.find(
274
+ (d) => c.types.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === a)
275
275
  );
276
- if (f) {
277
- let { source: m } = f;
278
- c.types.isStringLiteral(m) && (this._rawComponentPath = m.value);
276
+ if (p) {
277
+ let { source: d } = p;
278
+ c.types.isStringLiteral(d) && (this._rawComponentPath = d.value);
279
279
  }
280
280
  }
281
- let { code: a } = c.recast.print(i.value, {});
282
- r.component = a;
281
+ let { code: l } = c.recast.print(i.value, {});
282
+ r.component = l;
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 = fe(o);
285
+ c.types.isIdentifier(o) && (o = O(o.name, this._ast.program)), r.tags = de(o);
286
286
  } else if (i.key.name === "id")
287
287
  if (c.types.isStringLiteral(i.value))
288
288
  r.id = i.value.value;
@@ -308,34 +308,34 @@ var D = /* @__PURE__ */ p((s, e) => {
308
308
  if ((0, c.traverse)(this._ast, {
309
309
  ExportDefaultDeclaration: {
310
310
  enter(r) {
311
- let { node: i, parent: o } = r, a = c.types.isIdentifier(i.declaration) && c.types.isProgram(o);
312
- if (e._options.transformInlineMeta && !a && c.types.isExpression(i.declaration)) {
313
- let m = r.scope.generateUidIdentifier("meta");
314
- e._metaVariableName = m.name;
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 d = r.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
319
  g.forEach((x) => x.loc = r.node.loc), r.replaceWithMultiple(g);
320
320
  return;
321
321
  }
322
- let l, f;
323
- if (a) {
324
- let m = i.declaration.name;
325
- e._metaVariableName = m;
326
- let g = /* @__PURE__ */ p((x) => c.types.isIdentifier(x.id) && x.id.name === m, "isVariableDeclarator");
322
+ let a, p;
323
+ if (l) {
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
- ), f = (e?._metaStatement?.declarations || []).find(
329
+ ), p = (e?._metaStatement?.declarations || []).find(
330
330
  g
331
331
  )?.init;
332
332
  } else
333
- e._metaStatement = i, f = i.declaration;
334
- if (c.types.isObjectExpression(f) ? l = f : (
333
+ e._metaStatement = i, p = i.declaration;
334
+ if (c.types.isObjectExpression(p) ? a = p : (
335
335
  // export default { ... } as Meta<...>
336
- (c.types.isTSAsExpression(f) || c.types.isTSSatisfiesExpression(f)) && c.types.isObjectExpression(f.expression) && (l = f.expression)
337
- ), l && c.types.isProgram(o) && e._parseMeta(l, o), e._metaStatement && !e._metaNode)
338
- throw new R(
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)
338
+ throw new L(
339
339
  "default export must be an object",
340
340
  e._metaStatement,
341
341
  e._options.fileName
@@ -345,35 +345,35 @@ var D = /* @__PURE__ */ p((s, e) => {
345
345
  },
346
346
  ExportNamedDeclaration: {
347
347
  enter(r) {
348
- let { node: i, parent: o } = r, 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 f = !1, { name: m } = l.id;
353
- if (m === "__namedExportsOrder" && c.types.isVariableDeclarator(l)) {
354
- e._namedExportsOrder = et(l.init);
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: d } = a.id;
353
+ if (d === "__namedExportsOrder" && c.types.isVariableDeclarator(a)) {
354
+ e._namedExportsOrder = et(a.init);
355
355
  return;
356
356
  }
357
- e._storyExports[m] = l, e._storyPaths[m] = r, e._storyStatements[m] = i;
358
- let g = (0, I.storyNameFromExport)(m);
359
- e._storyAnnotations[m] ? pe.warn(
360
- `Unexpected annotations for "${m}" before story declaration`
361
- ) : e._storyAnnotations[m] = {};
357
+ e._storyExports[d] = a, e._storyPaths[d] = r, e._storyStatements[d] = i;
358
+ let g = (0, I.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(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
- property) && x.callee.property.name === "story" && (f = !0, x = x.arguments[0]), e._metaIsFactory && !f)
366
- throw new L(
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.
365
+ property) && x.callee.property.name === "story" && (p = !0, x = x.arguments[0]), e._metaIsFactory && !p)
366
+ throw new M(
367
367
  "expected factory story",
368
368
  x,
369
369
  e._options.fileName
370
370
  );
371
- if (!e._metaIsFactory && f)
372
- throw e._metaNode ? new L(
371
+ if (!e._metaIsFactory && p)
372
+ throw e._metaNode ? new M(
373
373
  "expected non-factory story",
374
374
  x,
375
375
  e._options.fileName
376
- ) : new M(
376
+ ) : new U(
377
377
  "meta() factory must be imported from .storybook/preview configuration",
378
378
  x,
379
379
  e._options.fileName
@@ -382,7 +382,7 @@ var D = /* @__PURE__ */ p((s, e) => {
382
382
  c.types.isObjectExpression(x) ? (E.__isArgsStory = !0, x.properties.forEach((b) => {
383
383
  if (c.types.isIdentifier(b.key)) {
384
384
  if (b.key.name === "render")
385
- E.__isArgsStory = de(
385
+ E.__isArgsStory = me(
386
386
  b.value,
387
387
  o,
388
388
  e
@@ -390,8 +390,8 @@ var D = /* @__PURE__ */ p((s, e) => {
390
390
  else if (b.key.name === "name" && c.types.isStringLiteral(b.value))
391
391
  g = b.value.value;
392
392
  else if (b.key.name === "storyName" && c.types.isStringLiteral(b.value))
393
- pe.warn(
394
- `Unexpected usage of "storyName" in "${m}". Please use "name" instead.`
393
+ fe.warn(
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
397
  let h = b.value.properties.find(
@@ -399,31 +399,31 @@ var D = /* @__PURE__ */ p((s, e) => {
399
399
  );
400
400
  h && (E.__id = h.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 = de(x, o, e), e._stories[m] = {
404
+ })) : E.__isArgsStory = me(x, o, e), e._stories[d] = {
405
405
  id: "FIXME",
406
406
  name: g,
407
407
  parameters: E,
408
408
  __stats: {
409
- factory: f
409
+ factory: p
410
410
  }
411
411
  };
412
412
  }
413
- }) : i.specifiers.length > 0 && i.specifiers.forEach((l) => {
414
- if (c.types.isExportSpecifier(l) && c.types.isIdentifier(l.exported)) {
415
- let { name: f } = l.exported, { name: m } = l.local, g = c.types.isProgram(o) ? P(l.local.name, o) : l.local;
416
- if (f === "default") {
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: d } = a.local, g = c.types.isProgram(o) ? O(a.local.name, o) : a.local;
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
422
  } else
423
- e._storyAnnotations[f] = {}, e._storyStatements[f] = g, e._storyPaths[f] = r, e._stories[f] = {
423
+ e._storyAnnotations[p] = {}, e._storyStatements[p] = g, e._storyPaths[p] = r, e._stories[p] = {
424
424
  id: "FIXME",
425
- name: f,
426
- localName: m,
425
+ name: p,
426
+ localName: d,
427
427
  parameters: {},
428
428
  __stats: {}
429
429
  };
@@ -436,14 +436,14 @@ var D = /* @__PURE__ */ p((s, e) => {
436
436
  let { expression: o } = r;
437
437
  if (c.types.isProgram(i) && c.types.isAssignmentExpression(o) && c.types.isMemberExpression(o.left) && c.types.isIdentifier(o.left.
438
438
  object) && c.types.isIdentifier(o.left.property)) {
439
- let a = o.left.object.name, l = o.left.property.name, f = o.right;
440
- if (e._storyAnnotations[a] && (l === "story" && c.types.isObjectExpression(f) ? f.properties.forEach((m) => {
441
- c.types.isIdentifier(m.key) && (e._storyAnnotations[a][m.key.name] = m.value);
442
- }) : e._storyAnnotations[a][l] = f), l === "storyName" && c.types.isStringLiteral(f)) {
443
- let m = f.value, g = e._stories[a];
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((d) => {
441
+ c.types.isIdentifier(d.key) && (e._storyAnnotations[l][d.key.name] = d.value);
442
+ }) : e._storyAnnotations[l][a] = p), a === "storyName" && c.types.isStringLiteral(p)) {
443
+ let d = p.value, g = e._stories[l];
444
444
  if (!g)
445
445
  return;
446
- g.name = m;
446
+ g.name = d;
447
447
  }
448
448
  }
449
449
  }
@@ -452,22 +452,22 @@ var D = /* @__PURE__ */ p((s, e) => {
452
452
  enter(r) {
453
453
  let { node: i } = r, { callee: o } = i;
454
454
  if (c.types.isIdentifier(o) && o.name === "storiesOf")
455
- throw new Error(O.dedent`
455
+ throw new Error(P.dedent`
456
456
  Unexpected \`storiesOf\` usage: ${D(i, e._options.fileName)}.
457
457
 
458
458
  SB8 does not support \`storiesOf\`.
459
459
  `);
460
460
  if (c.types.isMemberExpression(o) && c.types.isIdentifier(o.property) && o.property.name === "meta" && c.types.isIdentifier(o.object) &&
461
461
  i.arguments.length > 0) {
462
- let l = r.scope.getBinding(o.object.name)?.path?.parentPath?.node;
463
- if (c.types.isImportDeclaration(l))
464
- if (ue(l.source.value)) {
465
- let f = i.arguments[0];
466
- e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(f, e._ast.program);
462
+ let a = r.scope.getBinding(o.object.name)?.path?.parentPath?.node;
463
+ if (c.types.isImportDeclaration(a))
464
+ if (ge(a.source.value)) {
465
+ let p = i.arguments[0];
466
+ e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
467
467
  } else
468
- throw new M(
468
+ throw new U(
469
469
  "meta() factory must be imported from .storybook/preview configuration",
470
- l,
470
+ a,
471
471
  e._options.fileName
472
472
  );
473
473
  }
@@ -483,36 +483,36 @@ var D = /* @__PURE__ */ p((s, e) => {
483
483
  }
484
484
  }
485
485
  }), !e._meta)
486
- throw new R("missing default export", e._ast, e._options.fileName);
486
+ throw new L("missing default export", e._ast, e._options.fileName);
487
487
  let t = Object.entries(e._stories);
488
488
  if (e._meta.title = this._options.makeTitle(e._meta?.title), e._metaAnnotations.play && (e._meta.tags = [...e._meta.tags || [], "play-fn"]),
489
489
  e._stories = t.reduce(
490
490
  (r, [i, o]) => {
491
491
  if (!(0, I.isExportStory)(i, e._meta))
492
492
  return r;
493
- let a = o.parameters?.__id ?? (0, I.toId)(e._meta?.id || e._meta?.title, (0, I.storyNameFromExport)(i)), l = { ...o.parameters, __id: a },
494
- { includeStories: f } = e._meta || {};
495
- i === "__page" && (t.length === 1 || Array.isArray(f) && f.length === 1) && (l.docsOnly = !0), r[i] = { ...o, id: a, parameters: l };
496
- let m = e._storyAnnotations[i], { tags: g, play: x } = m;
493
+ let l = o.parameters?.__id ?? (0, I.toId)(e._meta?.id || e._meta?.title, (0, I.storyNameFromExport)(i)), a = { ...o.parameters, __id: l },
494
+ { 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 d = e._storyAnnotations[i], { tags: g, play: x } = d;
497
497
  if (g) {
498
- let h = c.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
499
- r[i].tags = fe(h);
498
+ let h = c.types.isIdentifier(g) ? O(g.name, this._ast.program) : g;
499
+ r[i].tags = de(h);
500
500
  }
501
501
  x && (r[i].tags = [...r[i].tags || [], "play-fn"]);
502
502
  let E = r[i].__stats;
503
503
  ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((h) => {
504
- E[h] = !!m[h] || !!e._metaAnnotations[h];
504
+ E[h] = !!d[h] || !!e._metaAnnotations[h];
505
505
  });
506
506
  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) => ge(h)), r;
507
+ return E.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), E.mount = tt(d.play ?? e._metaAnnotations.
508
+ play), E.moduleMock = !!e.imports.find((h) => xe(h)), r;
509
509
  },
510
510
  {}
511
511
  ), Object.keys(e._storyExports).forEach((r) => {
512
512
  (0, I.isExportStory)(r, e._meta) || (delete e._storyExports[r], delete e._storyAnnotations[r], delete e._storyStatements[r]);
513
513
  }), e._namedExportsOrder) {
514
514
  let r = Object.keys(e._storyExports);
515
- e._storyExports = me(e._storyExports, e._namedExportsOrder), e._stories = me(e._stories, e._namedExportsOrder);
515
+ e._storyExports = ue(e._storyExports, e._namedExportsOrder), e._stories = ue(e._stories, e._namedExportsOrder);
516
516
  let i = Object.keys(e._storyExports);
517
517
  if (r.length !== i.length)
518
518
  throw new Error(
@@ -533,7 +533,7 @@ var D = /* @__PURE__ */ p((s, e) => {
533
533
  let { fileName: e } = this._options;
534
534
  if (!e)
535
535
  throw new Error(
536
- O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
536
+ P.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
537
537
  Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
538
538
  );
539
539
  return Object.entries(this._stories).map(([t, r]) => {
@@ -552,72 +552,72 @@ var D = /* @__PURE__ */ p((s, e) => {
552
552
  };
553
553
  });
554
554
  }
555
- }, xe = /* @__PURE__ */ p(({
555
+ }, ye = /* @__PURE__ */ f(({
556
556
  code: s,
557
557
  filename: e = "",
558
558
  ast: t
559
- }) => new c.BabelFileClass({ filename: e }, { code: s, ast: t ?? (0, c.babelParse)(s) }), "babelParseFile"), J = /* @__PURE__ */ p((s, e) => {
560
- let t = (0, c.babelParse)(s), r = xe({ code: s, filename: e.fileName, ast: t });
561
- return new X(t, e, r);
562
- }, "loadCsf"), Z = /* @__PURE__ */ p((s, e = { sourceMaps: !1 }, 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
563
  let r = (0, c.generate)(s._ast, e, t);
564
564
  return e.sourceMaps ? r : r.code;
565
- }, "formatCsf"), ye = /* @__PURE__ */ p((s, e = {}) => c.recast.print(s._ast, e), "printCsf"), it = /* @__PURE__ */ p(async (s, e) => {
566
- let t = (await (0, K.readFile)(s, "utf-8")).toString();
567
- return J(t, { ...e, fileName: s });
568
- }, "readCsf"), st = /* @__PURE__ */ p(async (s, e) => {
565
+ }, "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 });
568
+ }, "readCsf"), st = /* @__PURE__ */ f(async (s, e) => {
569
569
  if (!(e || s._options.fileName))
570
570
  throw new Error("Please specify a fileName for writeCsf");
571
- await (0, K.writeFile)(e, ye(s).code);
571
+ await (0, J.writeFile)(e, be(s).code);
572
572
  }, "writeCsf");
573
573
 
574
574
  // src/csf-tools/ConfigFile.ts
575
- var Y = require("node:fs/promises"), n = require("storybook/internal/babel"), be = G($(), 1);
576
- var ee = console, te = /* @__PURE__ */ p(({
575
+ var ee = require("node:fs/promises"), n = require("storybook/internal/babel"), Ee = z(R(), 1);
576
+ var re = console, ie = /* @__PURE__ */ f(({
577
577
  expectedType: s,
578
578
  foundType: e,
579
579
  node: t
580
- }) => be.dedent`
580
+ }) => Ee.dedent`
581
581
  CSF Parsing error: Expected '${s}' but found '${e}' instead in '${t?.type}'.
582
- `, "getCsfParsingErrorMessage"), U = /* @__PURE__ */ p((s) => n.types.isIdentifier(s.key) ? s.key.name : n.types.isStringLiteral(s.key) ?
583
- s.key.value : null, "propKey"), Q = /* @__PURE__ */ p((s) => n.types.isTSAsExpression(s) || n.types.isTSSatisfiesExpression(s) ? Q(s.expression) :
584
- s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
582
+ `, "getCsfParsingErrorMessage"), C = /* @__PURE__ */ f((s) => n.types.isIdentifier(s.key) ? s.key.name : n.types.isStringLiteral(s.key) ?
583
+ 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) => {
585
585
  if (s.length === 0)
586
586
  return e;
587
587
  if (n.types.isObjectExpression(e)) {
588
- let [t, ...r] = s, i = e.properties.find((o) => U(o) === t);
588
+ let [t, ...r] = s, i = e.properties.find((o) => C(o) === t);
589
589
  if (i)
590
- return Ee(r, i.value);
590
+ return he(r, i.value);
591
591
  }
592
- }, "_getPath"), he = /* @__PURE__ */ p((s, e) => {
592
+ }, "_getPath"), _e = /* @__PURE__ */ f((s, e) => {
593
593
  if (s.length === 0) {
594
594
  if (n.types.isObjectExpression(e))
595
595
  return e.properties;
596
596
  throw new Error("Expected object expression");
597
597
  }
598
598
  if (n.types.isObjectExpression(e)) {
599
- let [t, ...r] = s, i = e.properties.find((o) => U(o) === t);
599
+ let [t, ...r] = s, i = e.properties.find((o) => C(o) === t);
600
600
  if (i)
601
- return r.length === 0 ? e.properties : he(r, i.value);
601
+ return r.length === 0 ? e.properties : _e(r, i.value);
602
602
  }
603
- }, "_getPathProperties"), _e = /* @__PURE__ */ p((s, e) => {
603
+ }, "_getPathProperties"), Y = /* @__PURE__ */ f((s, e) => {
604
604
  let t = null, r = null;
605
605
  return e.body.find((i) => (n.types.isVariableDeclaration(i) ? r = i.declarations : n.types.isExportNamedDeclaration(i) && n.types.isVariableDeclaration(
606
606
  i.declaration) && (r = i.declaration.declarations), r && r.find((o) => n.types.isVariableDeclarator(o) && n.types.isIdentifier(o.id) && o.
607
607
  id.name === s ? (t = o, !0) : !1))), t;
608
- }, "_findVarDeclarator"), F = /* @__PURE__ */ p((s, e) => _e(s, e)?.init, "_findVarInitialization"), q = /* @__PURE__ */ p((s, e) => {
608
+ }, "_findVarDeclarator"), F = /* @__PURE__ */ f((s, e) => Y(s, e)?.init, "_findVarInitialization"), B = /* @__PURE__ */ f((s, e) => {
609
609
  if (s.length === 0)
610
610
  return e;
611
- let [t, ...r] = s, i = q(r, e);
611
+ let [t, ...r] = s, i = B(r, e);
612
612
  return n.types.objectExpression([n.types.objectProperty(n.types.identifier(t), i)]);
613
- }, "_makeObjectExpression"), re = /* @__PURE__ */ p((s, e, t) => {
613
+ }, "_makeObjectExpression"), q = /* @__PURE__ */ f((s, e, t) => {
614
614
  let [r, ...i] = s, o = t.properties.find(
615
- (a) => U(a) === r
615
+ (l) => C(l) === r
616
616
  );
617
- o ? n.types.isObjectExpression(o.value) && i.length > 0 ? re(i, e, o.value) : o.value = q(i, e) : t.properties.push(
618
- n.types.objectProperty(n.types.identifier(r), q(i, e))
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))
619
619
  );
620
- }, "_updateExportNode"), H = class {
620
+ }, "_updateExportNode"), Z = class {
621
621
  constructor(e, t, r) {
622
622
  this._exports = {};
623
623
  // FIXME: this is a hack. this is only used in the case where the user is
@@ -628,11 +628,11 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
628
628
  this._ast = e, this._code = t, this.fileName = r;
629
629
  }
630
630
  static {
631
- p(this, "ConfigFile");
631
+ f(this, "ConfigFile");
632
632
  }
633
633
  _parseExportsObject(e) {
634
634
  this._exportsObject = e, e.properties.forEach((t) => {
635
- let r = U(t);
635
+ let r = C(t);
636
636
  if (r) {
637
637
  let i = t.value;
638
638
  n.types.isIdentifier(i) && (i = F(i.name, this._ast.program)), this._exports[r] = i;
@@ -646,9 +646,9 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
646
646
  enter({ node: t, parent: r }) {
647
647
  e.hasDefaultExport = !0;
648
648
  let i = n.types.isIdentifier(t.declaration) && n.types.isProgram(r) ? F(t.declaration.name, r) : t.declaration;
649
- i = Q(i), n.types.isCallExpression(i) && n.types.isObjectExpression(i.arguments[0]) && (i = i.arguments[0]), n.types.isObjectExpression(
650
- i) ? e._parseExportsObject(i) : ee.warn(
651
- te({
649
+ i = H(i), n.types.isCallExpression(i) && n.types.isObjectExpression(i.arguments[0]) && (i = i.arguments[0]), n.types.isObjectExpression(
650
+ i) ? e._parseExportsObject(i) : re.warn(
651
+ ie({
652
652
  expectedType: "ObjectExpression",
653
653
  foundType: i?.type,
654
654
  node: i || t.declaration
@@ -661,8 +661,8 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
661
661
  if (n.types.isVariableDeclaration(t.declaration))
662
662
  t.declaration.declarations.forEach((i) => {
663
663
  if (n.types.isVariableDeclarator(i) && n.types.isIdentifier(i.id)) {
664
- let { name: o } = i.id, a = i.init;
665
- n.types.isIdentifier(a) && (a = F(a.name, r)), e._exports[o] = a, e._exportDecls[o] = i;
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;
666
666
  }
667
667
  });
668
668
  else if (n.types.isFunctionDeclaration(t.declaration)) {
@@ -673,11 +673,11 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
673
673
  }
674
674
  } else t.specifiers ? t.specifiers.forEach((i) => {
675
675
  if (n.types.isExportSpecifier(i) && n.types.isIdentifier(i.local) && n.types.isIdentifier(i.exported)) {
676
- let { name: o } = i.local, { name: a } = i.exported, l = _e(o, r);
677
- l && (e._exports[a] = l.init, e._exportDecls[a] = l);
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);
678
678
  }
679
- }) : ee.warn(
680
- te({
679
+ }) : re.warn(
680
+ ie({
681
681
  expectedType: "VariableDeclaration",
682
682
  foundType: t.declaration?.type,
683
683
  node: t.declaration
@@ -691,22 +691,22 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
691
691
  let { left: i, right: o } = t.expression;
692
692
  if (n.types.isMemberExpression(i) && n.types.isIdentifier(i.object) && i.object.name === "module" && n.types.isIdentifier(i.property) &&
693
693
  i.property.name === "exports") {
694
- let a = o;
695
- n.types.isIdentifier(o) && (a = F(o.name, r)), a = Q(a), n.types.isObjectExpression(a) ? (e._exportsObject = a, a.properties.forEach(
696
- (l) => {
697
- let f = U(l);
698
- if (f) {
699
- let m = l.value;
700
- n.types.isIdentifier(m) && (m = F(
701
- m.name,
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
+ if (p) {
699
+ let d = a.value;
700
+ n.types.isIdentifier(d) && (d = F(
701
+ d.name,
702
702
  r
703
- )), e._exports[f] = m;
703
+ )), e._exports[p] = d;
704
704
  }
705
- })) : ee.warn(
706
- te({
705
+ })) : re.warn(
706
+ ie({
707
707
  expectedType: "ObjectExpression",
708
- foundType: a?.type,
709
- node: a
708
+ foundType: l?.type,
709
+ node: l
710
710
  })
711
711
  );
712
712
  }
@@ -714,7 +714,7 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
714
714
  }
715
715
  },
716
716
  CallExpression: {
717
- enter: /* @__PURE__ */ p(({ node: t }) => {
717
+ enter: /* @__PURE__ */ f(({ node: t }) => {
718
718
  n.types.isIdentifier(t.callee) && t.callee.name === "definePreview" && t.arguments.length === 1 && n.types.isObjectExpression(t.arguments[0]) &&
719
719
  e._parseExportsObject(t.arguments[0]);
720
720
  }, "enter")
@@ -724,12 +724,12 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
724
724
  getFieldNode(e) {
725
725
  let [t, ...r] = e, i = this._exports[t];
726
726
  if (i)
727
- return Ee(r, i);
727
+ return he(r, i);
728
728
  }
729
729
  getFieldProperties(e) {
730
730
  let [t, ...r] = e, i = this._exports[t];
731
731
  if (i)
732
- return he(r, i);
732
+ return _e(r, i);
733
733
  }
734
734
  getFieldValue(e) {
735
735
  let t = this.getFieldNode(e);
@@ -746,13 +746,30 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
746
746
  }
747
747
  setFieldNode(e, t) {
748
748
  let [r, ...i] = e, o = this._exports[r];
749
- if (this._exportsObject)
750
- re(e, t, this._exportsObject), this._exports[e[0]] = t;
751
- else if (o && n.types.isObjectExpression(o) && i.length > 0)
752
- re(i, t, o);
753
- else if (o && i.length === 0 && this._exportDecls[e[0]]) {
749
+ if (this._exportsObject) {
750
+ let p = this._exportsObject.properties.find((d) => C(d) === r);
751
+ if (p && n.types.isIdentifier(p.value)) {
752
+ let d = Y(p.value.name, this._ast.program);
753
+ if (d && n.types.isObjectExpression(d.init)) {
754
+ q(i, t, d.init);
755
+ return;
756
+ }
757
+ }
758
+ q(e, t, this._exportsObject), this._exports[e[0]] = t;
759
+ return;
760
+ }
761
+ if (o && n.types.isObjectExpression(o) && i.length > 0) {
762
+ q(i, t, o);
763
+ return;
764
+ }
765
+ let l = Y(r, this._ast.program);
766
+ if (l && n.types.isObjectExpression(l.init)) {
767
+ q(i, t, l.init);
768
+ return;
769
+ }
770
+ if (o && i.length === 0 && this._exportDecls[e[0]]) {
754
771
  let a = this._exportDecls[e[0]];
755
- n.types.isVariableDeclarator(a) && (a.init = q([], t));
772
+ n.types.isVariableDeclarator(a) && (a.init = B([], t));
756
773
  } else {
757
774
  if (this.hasDefaultExport)
758
775
  throw new Error(
@@ -761,10 +778,10 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
761
778
  )}" field as the default export is not an object in this file.`
762
779
  );
763
780
  {
764
- let a = q(i, t), l = n.types.exportNamedDeclaration(
781
+ let a = B(i, t), p = n.types.exportNamedDeclaration(
765
782
  n.types.variableDeclaration("const", [n.types.variableDeclarator(n.types.identifier(r), a)])
766
783
  );
767
- this._exports[r] = a, this._ast.program.body.push(l);
784
+ this._exports[r] = a, this._ast.program.body.push(p);
768
785
  }
769
786
  }
770
787
  }
@@ -832,31 +849,31 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
832
849
  return r;
833
850
  }
834
851
  removeField(e) {
835
- let t = /* @__PURE__ */ p((i, o) => {
836
- let a = i.findIndex(
837
- (l) => n.types.isIdentifier(l.key) && l.key.name === o || n.types.isStringLiteral(l.key) && l.key.value === o
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
838
855
  );
839
- a >= 0 && i.splice(a, 1);
856
+ l >= 0 && i.splice(l, 1);
840
857
  }, "removeProperty");
841
858
  if (e.length === 1) {
842
859
  let i = !1;
843
860
  if (this._ast.program.body.forEach((o) => {
844
861
  if (n.types.isExportNamedDeclaration(o) && n.types.isVariableDeclaration(o.declaration)) {
845
- let a = o.declaration.declarations[0];
846
- n.types.isIdentifier(a.id) && a.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), i = !0);
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);
847
864
  }
848
865
  if (n.types.isExportDefaultDeclaration(o)) {
849
- let a = o.declaration;
850
- if (n.types.isIdentifier(a) && (a = F(a.name, this._ast.program)), a = Q(a), n.types.isObjectExpression(a)) {
851
- let l = a.properties;
852
- t(l, e[0]), i = !0;
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;
853
870
  }
854
871
  }
855
872
  if (n.types.isExpressionStatement(o) && n.types.isAssignmentExpression(o.expression) && n.types.isMemberExpression(o.expression.left) &&
856
873
  n.types.isIdentifier(o.expression.left.object) && o.expression.left.object.name === "module" && n.types.isIdentifier(o.expression.left.
857
874
  property) && o.expression.left.property.name === "exports" && n.types.isObjectExpression(o.expression.right)) {
858
- let a = o.expression.right.properties;
859
- t(a, e[0]), i = !0;
875
+ let l = o.expression.right.properties;
876
+ t(l, e[0]), i = !0;
860
877
  }
861
878
  }), i)
862
879
  return;
@@ -913,9 +930,9 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
913
930
  let { code: i } = (0, n.generate)(n.types.valueToNode(e), { jsescOption: { quotes: t } }), o = (0, n.babelParse)(`const __x = ${i}`);
914
931
  (0, n.traverse)(o, {
915
932
  VariableDeclaration: {
916
- enter({ node: a }) {
917
- a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) && n.types.isIdentifier(a.declarations[0].id) && a.
918
- declarations[0].id.name === "__x" && (r = a.declarations[0].init);
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);
919
936
  }
920
937
  }
921
938
  });
@@ -954,15 +971,15 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
954
971
  */
955
972
  setRequireImport(e, t) {
956
973
  let r = this._ast.program.body.find(
957
- (a) => n.types.isVariableDeclaration(a) && a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) && n.types.isCallExpression(
958
- a.declarations[0].init) && n.types.isIdentifier(a.declarations[0].init.callee) && a.declarations[0].init.callee.name === "require" && n.types.
959
- isStringLiteral(a.declarations[0].init.arguments[0]) && a.declarations[0].init.arguments[0].value === t
960
- ), i = /* @__PURE__ */ p((a) => n.types.isObjectPattern(r?.declarations[0].id) && r?.declarations[0].id.properties.find(
961
- (l) => n.types.isObjectProperty(l) && n.types.isIdentifier(l.key) && l.key.name === a
962
- ), "hasRequireSpecifier"), o = /* @__PURE__ */ p((a, l) => a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) &&
963
- n.types.isIdentifier(a.declarations[0].id) && a.declarations[0].id.name === l, "hasDefaultRequireSpecifier");
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");
964
981
  if (typeof e == "string") {
965
- let a = /* @__PURE__ */ p(() => {
982
+ let l = /* @__PURE__ */ f(() => {
966
983
  this._ast.program.body.unshift(
967
984
  n.types.variableDeclaration("const", [
968
985
  n.types.variableDeclarator(
@@ -972,17 +989,17 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
972
989
  ])
973
990
  );
974
991
  }, "addDefaultRequireSpecifier");
975
- r && o(r, e) || a();
976
- } else r ? e.forEach((a) => {
977
- i(a) || r.declarations[0].id.properties.push(
978
- n.types.objectProperty(n.types.identifier(a), n.types.identifier(a), void 0, !0)
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)
979
996
  );
980
997
  }) : this._ast.program.body.unshift(
981
998
  n.types.variableDeclaration("const", [
982
999
  n.types.variableDeclarator(
983
1000
  n.types.objectPattern(
984
1001
  e.map(
985
- (a) => n.types.objectProperty(n.types.identifier(a), n.types.identifier(a), void 0, !0)
1002
+ (l) => n.types.objectProperty(n.types.identifier(l), n.types.identifier(l), void 0, !0)
986
1003
  )
987
1004
  ),
988
1005
  n.types.callExpression(n.types.identifier("require"), [n.types.stringLiteral(t)])
@@ -1016,32 +1033,32 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
1016
1033
  * @param fromImport - The module to import from
1017
1034
  */
1018
1035
  setImport(e, t) {
1019
- let r = /* @__PURE__ */ p((f) => n.types.importSpecifier(n.types.identifier(f), n.types.identifier(f)), "getNewImportSpecifier"), i = /* @__PURE__ */ p(
1020
- (f, m) => f.specifiers.find(
1021
- (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === m
1022
- ), "hasImportSpecifier"), o = /* @__PURE__ */ p((f, m) => f.specifiers.find(
1023
- (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
1024
- ), "hasNamespaceImportSpecifier"), a = /* @__PURE__ */ p((f, m) => f.specifiers.find(
1025
- (g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
1026
- ), "hasDefaultImportSpecifier"), l = this._ast.program.body.find(
1027
- (f) => n.types.isImportDeclaration(f) && f.source.value === t
1036
+ let r = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), i = /* @__PURE__ */ f(
1037
+ (p, d) => p.specifiers.find(
1038
+ (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === d
1039
+ ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1040
+ (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1041
+ ), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1042
+ (g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1043
+ ), "hasDefaultImportSpecifier"), a = this._ast.program.body.find(
1044
+ (p) => n.types.isImportDeclaration(p) && p.source.value === t
1028
1045
  );
1029
- e === null ? l || this._ast.program.body.unshift(n.types.importDeclaration([], n.types.stringLiteral(t))) : typeof e == "string" ? l ? a(
1030
- l, e) || l.specifiers.push(
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(
1031
1048
  n.types.importDefaultSpecifier(n.types.identifier(e))
1032
1049
  ) : this._ast.program.body.unshift(
1033
1050
  n.types.importDeclaration(
1034
1051
  [n.types.importDefaultSpecifier(n.types.identifier(e))],
1035
1052
  n.types.stringLiteral(t)
1036
1053
  )
1037
- ) : Array.isArray(e) ? l ? e.forEach((f) => {
1038
- i(l, f) || l.specifiers.push(r(f));
1054
+ ) : Array.isArray(e) ? a ? e.forEach((p) => {
1055
+ i(a, p) || a.specifiers.push(r(p));
1039
1056
  }) : this._ast.program.body.unshift(
1040
1057
  n.types.importDeclaration(
1041
1058
  e.map(r),
1042
1059
  n.types.stringLiteral(t)
1043
1060
  )
1044
- ) : e.namespace && (l ? o(l, e.namespace) || l.specifiers.push(
1061
+ ) : e.namespace && (a ? o(a, e.namespace) || a.specifiers.push(
1045
1062
  n.types.importNamespaceSpecifier(n.types.identifier(e.namespace))
1046
1063
  ) : this._ast.program.body.unshift(
1047
1064
  n.types.importDeclaration(
@@ -1050,41 +1067,41 @@ s, "unwrap"), Ee = /* @__PURE__ */ p((s, e) => {
1050
1067
  )
1051
1068
  ));
1052
1069
  }
1053
- }, je = /* @__PURE__ */ p((s, e) => {
1070
+ }, je = /* @__PURE__ */ f((s, e) => {
1054
1071
  let t = (0, n.babelParse)(s);
1055
- return new H(t, s, e);
1056
- }, "loadConfig"), Se = /* @__PURE__ */ p((s) => Pe(s).code, "formatConfig"), Pe = /* @__PURE__ */ p((s, e = {}) => n.recast.print(s._ast, e),
1057
- "printConfig"), nt = /* @__PURE__ */ p(async (s) => {
1058
- let e = (await (0, Y.readFile)(s, "utf-8")).toString();
1072
+ return new Z(t, s, e);
1073
+ }, "loadConfig"), Se = /* @__PURE__ */ f((s) => Oe(s).code, "formatConfig"), Oe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
1074
+ "printConfig"), nt = /* @__PURE__ */ f(async (s) => {
1075
+ let e = (await (0, ee.readFile)(s, "utf-8")).toString();
1059
1076
  return je(e, s).parse();
1060
- }, "readConfig"), ot = /* @__PURE__ */ p(async (s, e) => {
1077
+ }, "readConfig"), ot = /* @__PURE__ */ f(async (s, e) => {
1061
1078
  let t = e || s.fileName;
1062
1079
  if (!t)
1063
1080
  throw new Error("Please specify a fileName for writeConfig");
1064
- await (0, Y.writeFile)(t, Se(s));
1065
- }, "writeConfig"), at = /* @__PURE__ */ p((s) => !!s._ast.program.body.find((t) => n.types.isImportDeclaration(t) && t.source.value.includes(
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(
1066
1083
  "@storybook") && t.specifiers.some((r) => n.types.isImportSpecifier(r) && n.types.isIdentifier(r.imported) && r.imported.name === "definePre\
1067
1084
  view")), "isCsfFactoryPreview");
1068
1085
 
1069
1086
  // src/csf-tools/getStorySortParameter.ts
1070
- var y = require("storybook/internal/babel"), Ie = G($(), 1);
1071
- var lt = console, ie = /* @__PURE__ */ p((s, e) => {
1087
+ var y = require("storybook/internal/babel"), Ie = z(R(), 1);
1088
+ var lt = console, se = /* @__PURE__ */ f((s, e) => {
1072
1089
  let t;
1073
1090
  return s.properties.forEach((r) => {
1074
1091
  y.types.isIdentifier(r.key) && r.key.name === e && (t = r.value);
1075
1092
  }), t;
1076
- }, "getValue"), se = /* @__PURE__ */ p((s) => {
1077
- let e = B(s);
1093
+ }, "getValue"), ne = /* @__PURE__ */ f((s) => {
1094
+ let e = W(s);
1078
1095
  if (y.types.isArrayExpression(e))
1079
- return e.elements.map((t) => se(t));
1096
+ return e.elements.map((t) => ne(t));
1080
1097
  if (y.types.isObjectExpression(e))
1081
- return e.properties.reduce((t, r) => (y.types.isIdentifier(r.key) && (t[r.key.name] = se(r.value)), t), {});
1098
+ return e.properties.reduce((t, r) => (y.types.isIdentifier(r.key) && (t[r.key.name] = ne(r.value)), t), {});
1082
1099
  if (y.types.isLiteral(e))
1083
1100
  return e.value;
1084
1101
  if (y.types.isIdentifier(e))
1085
- return C(e.name, !0);
1102
+ return T(e.name, !0);
1086
1103
  throw new Error(`Unknown node type ${e.type}`);
1087
- }, "parseValue"), C = /* @__PURE__ */ p((s, e) => {
1104
+ }, "parseValue"), T = /* @__PURE__ */ f((s, e) => {
1088
1105
  let t = Ie.dedent`
1089
1106
  Unexpected '${s}'. Parameter 'options.storySort' should be defined inline e.g.:
1090
1107
 
@@ -1099,26 +1116,26 @@ var lt = console, ie = /* @__PURE__ */ p((s, e) => {
1099
1116
  if (e)
1100
1117
  throw new Error(t);
1101
1118
  lt.info(t);
1102
- }, "unsupported"), B = /* @__PURE__ */ p((s) => y.types.isTSAsExpression(s) || y.types.isTSSatisfiesExpression(s) ? s.expression : s, "strip\
1103
- TSModifiers"), De = /* @__PURE__ */ p((s) => {
1104
- let e = B(s);
1119
+ }, "unsupported"), W = /* @__PURE__ */ f((s) => y.types.isTSAsExpression(s) || y.types.isTSSatisfiesExpression(s) ? s.expression : s, "strip\
1120
+ TSModifiers"), De = /* @__PURE__ */ f((s) => {
1121
+ let e = W(s);
1105
1122
  if (y.types.isObjectExpression(e)) {
1106
- let t = ie(e, "options");
1123
+ let t = se(e, "options");
1107
1124
  if (t) {
1108
1125
  if (y.types.isObjectExpression(t))
1109
- return ie(t, "storySort");
1110
- C("options", !0);
1126
+ return se(t, "storySort");
1127
+ T("options", !0);
1111
1128
  }
1112
1129
  }
1113
- }, "parseParameters"), Oe = /* @__PURE__ */ p((s, e) => {
1114
- let t = B(s);
1130
+ }, "parseParameters"), Pe = /* @__PURE__ */ f((s, e) => {
1131
+ let t = W(s);
1115
1132
  if (y.types.isObjectExpression(t)) {
1116
- let r = ie(t, "parameters");
1117
- if (y.types.isIdentifier(r) && (r = P(r.name, e)), r)
1133
+ let r = se(t, "parameters");
1134
+ if (y.types.isIdentifier(r) && (r = O(r.name, e)), r)
1118
1135
  return De(r);
1119
1136
  } else
1120
- C("default", !0);
1121
- }, "parseDefault"), ct = /* @__PURE__ */ p((s) => {
1137
+ T("default", !0);
1138
+ }, "parseDefault"), ct = /* @__PURE__ */ f((s) => {
1122
1139
  if (!s.includes("storySort"))
1123
1140
  return;
1124
1141
  let e, t = (0, y.babelParse)(s);
@@ -1129,20 +1146,20 @@ TSModifiers"), De = /* @__PURE__ */ p((s) => {
1129
1146
  if (y.types.isVariableDeclarator(i) && y.types.isIdentifier(i.id)) {
1130
1147
  let { name: o } = i.id;
1131
1148
  if (o === "parameters" && i.init) {
1132
- let a = B(i.init);
1133
- e = De(a);
1149
+ let l = W(i.init);
1150
+ e = De(l);
1134
1151
  }
1135
1152
  }
1136
1153
  }) : r.specifiers.forEach((i) => {
1137
- y.types.isIdentifier(i.exported) && i.exported.name === "parameters" && C("parameters", !1);
1154
+ y.types.isIdentifier(i.exported) && i.exported.name === "parameters" && T("parameters", !1);
1138
1155
  });
1139
1156
  }
1140
1157
  },
1141
1158
  ExportDefaultDeclaration: {
1142
1159
  enter({ node: r }) {
1143
1160
  let i = r.declaration;
1144
- y.types.isIdentifier(i) && (i = P(i.name, t.program)), i = B(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1145
- e = Oe(i.arguments[0], t.program) : y.types.isObjectExpression(i) ? e = Oe(i, t.program) : C("default", !1);
1161
+ y.types.isIdentifier(i) && (i = O(i.name, t.program)), i = W(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1162
+ e = Pe(i.arguments[0], t.program) : y.types.isObjectExpression(i) ? e = Pe(i, t.program) : T("default", !1);
1146
1163
  }
1147
1164
  }
1148
1165
  }), !!e) {
@@ -1157,25 +1174,25 @@ TSModifiers"), De = /* @__PURE__ */ p((s) => {
1157
1174
  }`;
1158
1175
  return (0, eval)(o);
1159
1176
  }
1160
- return y.types.isLiteral(e) || y.types.isArrayExpression(e) || y.types.isObjectExpression(e) ? se(e) : C("storySort", !0);
1177
+ return y.types.isLiteral(e) || y.types.isArrayExpression(e) || y.types.isObjectExpression(e) ? ne(e) : T("storySort", !0);
1161
1178
  }
1162
1179
  }, "getStorySortParameter");
1163
1180
 
1164
1181
  // src/csf-tools/enrichCsf.ts
1165
1182
  var u = require("storybook/internal/babel");
1166
- var Ne = /* @__PURE__ */ p((s, e, t, r) => {
1183
+ var Ne = /* @__PURE__ */ f((s, e, t, r) => {
1167
1184
  let i = e.getStoryExport(t), o = u.types.isCallExpression(i) && u.types.isMemberExpression(i.callee) && u.types.isIdentifier(i.callee.object) &&
1168
- i.callee.object.name === "meta", a = !r?.disableSource && Fe(i), l = !r?.disableDescription && ne(e._storyStatements[t]), f = [], m = o ? u.types.
1169
- memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(m, u.types.identifier(
1185
+ i.callee.object.name === "meta", l = !r?.disableSource && Fe(i), a = !r?.disableDescription && oe(e._storyStatements[t]), p = [], d = o ? u.types.
1186
+ memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(d, u.types.identifier(
1170
1187
  "parameters"));
1171
- f.push(u.types.spreadElement(g));
1188
+ p.push(u.types.spreadElement(g));
1172
1189
  let x = u.types.optionalMemberExpression(
1173
1190
  g,
1174
1191
  u.types.identifier("docs"),
1175
1192
  !1,
1176
1193
  !0
1177
1194
  ), E = [];
1178
- if (a) {
1195
+ if (l) {
1179
1196
  let b = u.types.optionalMemberExpression(
1180
1197
  x,
1181
1198
  u.types.identifier("source"),
@@ -1186,13 +1203,13 @@ var Ne = /* @__PURE__ */ p((s, e, t, r) => {
1186
1203
  u.types.objectProperty(
1187
1204
  u.types.identifier("source"),
1188
1205
  u.types.objectExpression([
1189
- u.types.objectProperty(u.types.identifier("originalSource"), u.types.stringLiteral(a)),
1206
+ u.types.objectProperty(u.types.identifier("originalSource"), u.types.stringLiteral(l)),
1190
1207
  u.types.spreadElement(b)
1191
1208
  ])
1192
1209
  )
1193
1210
  );
1194
1211
  }
1195
- if (l) {
1212
+ if (a) {
1196
1213
  let b = u.types.optionalMemberExpression(
1197
1214
  x,
1198
1215
  u.types.identifier("description"),
@@ -1203,37 +1220,37 @@ var Ne = /* @__PURE__ */ p((s, e, t, r) => {
1203
1220
  u.types.objectProperty(
1204
1221
  u.types.identifier("description"),
1205
1222
  u.types.objectExpression([
1206
- u.types.objectProperty(u.types.identifier("story"), u.types.stringLiteral(l)),
1223
+ u.types.objectProperty(u.types.identifier("story"), u.types.stringLiteral(a)),
1207
1224
  u.types.spreadElement(b)
1208
1225
  ])
1209
1226
  )
1210
1227
  );
1211
1228
  }
1212
1229
  if (E.length > 0) {
1213
- f.push(
1230
+ p.push(
1214
1231
  u.types.objectProperty(
1215
1232
  u.types.identifier("docs"),
1216
1233
  u.types.objectExpression([u.types.spreadElement(x), ...E])
1217
1234
  )
1218
1235
  );
1219
1236
  let b = u.types.expressionStatement(
1220
- u.types.assignmentExpression("=", g, u.types.objectExpression(f))
1237
+ u.types.assignmentExpression("=", g, u.types.objectExpression(p))
1221
1238
  );
1222
1239
  s._ast.program.body.push(b);
1223
1240
  }
1224
- }, "enrichCsfStory"), ve = /* @__PURE__ */ p((s, e, t) => {
1241
+ }, "enrichCsfStory"), ve = /* @__PURE__ */ f((s, e, t) => {
1225
1242
  if (!e.length) {
1226
1243
  s.properties.find(
1227
- (f) => u.types.isObjectProperty(f) && u.types.isIdentifier(f.key) && f.key.name === "component"
1244
+ (p) => u.types.isObjectProperty(p) && u.types.isIdentifier(p.key) && p.key.name === "component"
1228
1245
  ) || s.properties.unshift(t);
1229
1246
  return;
1230
1247
  }
1231
1248
  let [r, ...i] = e, o = s.properties.find(
1232
- (l) => u.types.isObjectProperty(l) && u.types.isIdentifier(l.key) && l.key.name === r && u.types.isObjectExpression(l.value)
1233
- ), a;
1234
- o ? a = o.value : (a = u.types.objectExpression([]), s.properties.push(u.types.objectProperty(u.types.identifier(r), a))), ve(a, i, t);
1235
- }, "addComponentDescription"), we = /* @__PURE__ */ p((s, e, t) => {
1236
- let r = !t?.disableDescription && ne(e._metaStatement);
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))), ve(l, i, t);
1252
+ }, "addComponentDescription"), we = /* @__PURE__ */ f((s, e, t) => {
1253
+ let r = !t?.disableDescription && oe(e._metaStatement);
1237
1254
  if (r) {
1238
1255
  let i = s._metaNode;
1239
1256
  i && u.types.isObjectExpression(i) && ve(
@@ -1242,14 +1259,14 @@ var Ne = /* @__PURE__ */ p((s, e, t, r) => {
1242
1259
  u.types.objectProperty(u.types.identifier("component"), u.types.stringLiteral(r))
1243
1260
  );
1244
1261
  }
1245
- }, "enrichCsfMeta"), pt = /* @__PURE__ */ p((s, e, t) => {
1262
+ }, "enrichCsfMeta"), pt = /* @__PURE__ */ f((s, e, t) => {
1246
1263
  we(s, e, t), Object.keys(s._storyExports).forEach((r) => {
1247
1264
  Ne(s, e, r, t);
1248
1265
  });
1249
- }, "enrichCsf"), Fe = /* @__PURE__ */ p((s) => {
1266
+ }, "enrichCsf"), Fe = /* @__PURE__ */ f((s) => {
1250
1267
  let e = u.types.isVariableDeclarator(s) ? s.init : s, { code: t } = (0, u.generate)(e, {});
1251
1268
  return t;
1252
- }, "extractSource"), ne = /* @__PURE__ */ p((s) => s?.leadingComments ? s.leadingComments.map((t) => t.type === "CommentLine" || !t.value.startsWith(
1269
+ }, "extractSource"), oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((t) => t.type === "CommentLine" || !t.value.startsWith(
1253
1270
  "*") ? null : t.value.split(`
1254
1271
  `).map((r) => r.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
1255
1272
  `).trim()).filter(Boolean).join(`
@@ -1259,8 +1276,8 @@ var Ne = /* @__PURE__ */ p((s, e, t, r) => {
1259
1276
  var Ae = require("storybook/internal/babel");
1260
1277
 
1261
1278
  // src/csf-tools/vitest-plugin/transformer.ts
1262
- var d = require("storybook/internal/babel"), Te = require("storybook/internal/common"), ke = require("storybook/internal/csf"), oe = G($(), 1);
1263
- var Ce = console, ft = /* @__PURE__ */ p((s, e) => !(e.include.length && !e.include.some((t) => s?.includes(t)) || e.exclude.some((t) => s?.
1279
+ var m = 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?.
1264
1281
  includes(t))), "isValidTest");
1265
1282
  async function Ve({
1266
1283
  code: s,
@@ -1272,10 +1289,10 @@ async function Ve({
1272
1289
  }) {
1273
1290
  if (!/\.stor(y|ies)\./.test(e))
1274
1291
  return s;
1275
- let l = J(s, {
1292
+ let a = Q(s, {
1276
1293
  fileName: e,
1277
1294
  transformInlineMeta: !0,
1278
- makeTitle: /* @__PURE__ */ p((_) => {
1295
+ makeTitle: /* @__PURE__ */ f((_) => {
1279
1296
  let S = (0, Te.getStoryTitle)({
1280
1297
  storyFilePath: e,
1281
1298
  configDir: t,
@@ -1283,16 +1300,16 @@ async function Ve({
1283
1300
  userTitle: _
1284
1301
  }) || "unknown";
1285
1302
  return S === "unknown" && Ce.warn(
1286
- oe.dedent`
1303
+ ae.dedent`
1287
1304
  [Storybook]: Could not calculate story title for "${e}".
1288
1305
  Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${t}".
1289
1306
  `
1290
1307
  ), S;
1291
1308
  }, "makeTitle")
1292
- }).parse(), f = l._ast, m = l._metaVariableName, g = l._metaNode, x = g.properties.find(
1293
- (_) => d.types.isObjectProperty(_) && d.types.isIdentifier(_.key) && _.key.name === "title"
1294
- ), E = d.types.stringLiteral(l._meta?.title || "unknown");
1295
- if (x ? d.types.isObjectProperty(x) && (x.value = E) : g.properties.push(d.types.objectProperty(d.types.identifier("title"), E)), !g || !l.
1309
+ }).parse(), p = a._ast, d = a._metaVariableName, g = a._metaNode, x = g.properties.find(
1310
+ (_) => m.types.isObjectProperty(_) && m.types.isIdentifier(_.key) && _.key.name === "title"
1311
+ ), E = m.types.stringLiteral(a._meta?.title || "unknown");
1312
+ if (x ? m.types.isObjectProperty(x) && (x.value = E) : g.properties.push(m.types.objectProperty(m.types.identifier("title"), E)), !g || !a.
1296
1313
  _meta)
1297
1314
  throw new Error(
1298
1315
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
@@ -1301,114 +1318,114 @@ Please make sure you have a default export with the meta object. If you are usin
1301
1318
  le an issue with details about your use case.`
1302
1319
  );
1303
1320
  let b = {};
1304
- Object.keys(l._stories).map((_) => {
1321
+ Object.keys(a._stories).map((_) => {
1305
1322
  let S = (0, ke.combineTags)(
1306
1323
  "test",
1307
1324
  "dev",
1308
1325
  ...o,
1309
- ...l.meta?.tags || [],
1310
- ...l._stories[_].tags || []
1326
+ ...a.meta?.tags || [],
1327
+ ...a._stories[_].tags || []
1311
1328
  );
1312
- ft(S, i) && (b[_] = l._storyStatements[_]);
1329
+ ft(S, i) && (b[_] = a._storyStatements[_]);
1313
1330
  });
1314
- let h = l._file.path.scope.generateUidIdentifier("test"), N = l._file.path.scope.generateUidIdentifier("describe");
1331
+ let h = a._file.path.scope.generateUidIdentifier("test"), N = a._file.path.scope.generateUidIdentifier("describe");
1315
1332
  if (Object.keys(b).length === 0) {
1316
- let _ = d.types.expressionStatement(
1317
- d.types.callExpression(d.types.memberExpression(N, d.types.identifier("skip")), [
1318
- d.types.stringLiteral("No valid tests found")
1333
+ let _ = m.types.expressionStatement(
1334
+ m.types.callExpression(m.types.memberExpression(N, m.types.identifier("skip")), [
1335
+ m.types.stringLiteral("No valid tests found")
1319
1336
  ])
1320
1337
  );
1321
- f.program.body.push(_);
1338
+ p.program.body.push(_);
1322
1339
  let S = [
1323
- d.types.importDeclaration(
1340
+ m.types.importDeclaration(
1324
1341
  [
1325
- d.types.importSpecifier(h, d.types.identifier("test")),
1326
- d.types.importSpecifier(N, d.types.identifier("describe"))
1342
+ m.types.importSpecifier(h, m.types.identifier("test")),
1343
+ m.types.importSpecifier(N, m.types.identifier("describe"))
1327
1344
  ],
1328
- d.types.stringLiteral("vitest")
1345
+ m.types.stringLiteral("vitest")
1329
1346
  )
1330
1347
  ];
1331
- f.program.body.unshift(...S);
1348
+ p.program.body.unshift(...S);
1332
1349
  } else {
1333
- let ae = function() {
1334
- let j = l._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), v = d.types.memberExpression(
1335
- d.types.callExpression(d.types.memberExpression(_, d.types.identifier("getState")), []),
1336
- d.types.identifier("testPath")
1337
- ), T = d.types.memberExpression(
1338
- d.types.memberExpression(d.types.identifier("globalThis"), d.types.identifier("__vitest_worker__")),
1339
- d.types.identifier("filepath")
1340
- ), k = d.types.logicalExpression(
1350
+ let le = function() {
1351
+ let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), v = m.types.memberExpression(
1352
+ m.types.callExpression(m.types.memberExpression(_, m.types.identifier("getState")), []),
1353
+ m.types.identifier("testPath")
1354
+ ), k = m.types.memberExpression(
1355
+ m.types.memberExpression(m.types.identifier("globalThis"), m.types.identifier("__vitest_worker__")),
1356
+ m.types.identifier("filepath")
1357
+ ), V = m.types.logicalExpression(
1341
1358
  "??",
1342
1359
  // TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
1343
1360
  // https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
1344
- T,
1361
+ k,
1345
1362
  v
1346
- ), W = d.types.callExpression(
1347
- d.types.memberExpression(
1348
- d.types.memberExpression(
1349
- d.types.memberExpression(d.types.identifier("import"), d.types.identifier("meta")),
1350
- d.types.identifier("url")
1363
+ ), G = m.types.callExpression(
1364
+ m.types.memberExpression(
1365
+ m.types.memberExpression(
1366
+ m.types.memberExpression(m.types.identifier("import"), m.types.identifier("meta")),
1367
+ m.types.identifier("url")
1351
1368
  ),
1352
- d.types.identifier("includes")
1369
+ m.types.identifier("includes")
1353
1370
  ),
1354
- [k]
1371
+ [V]
1355
1372
  );
1356
- return { isRunningFromThisFileDeclaration: d.types.variableDeclaration("const", [
1357
- d.types.variableDeclarator(j, W)
1373
+ return { isRunningFromThisFileDeclaration: m.types.variableDeclaration("const", [
1374
+ m.types.variableDeclarator(j, G)
1358
1375
  ]), isRunningFromThisFileId: j };
1359
1376
  };
1360
- var mt = ae;
1361
- p(ae, "getTestGuardDeclaration");
1362
- let _ = l._file.path.scope.generateUidIdentifier("expect"), S = l._file.path.scope.generateUidIdentifier("testStory"), $e = d.types.identifier(
1363
- JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Re, isRunningFromThisFileId: Le } = ae();
1364
- f.program.body.push(Re);
1365
- let Me = /* @__PURE__ */ p(({
1377
+ var mt = le;
1378
+ f(le, "getTestGuardDeclaration");
1379
+ let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), $e = m.types.identifier(
1380
+ JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Re, isRunningFromThisFileId: Le } = le();
1381
+ p.program.body.push(Re);
1382
+ let Me = /* @__PURE__ */ f(({
1366
1383
  localName: j,
1367
1384
  exportName: v,
1368
- testTitle: T,
1369
- node: k
1385
+ testTitle: k,
1386
+ node: V
1370
1387
  }) => {
1371
- let W = d.types.expressionStatement(
1372
- d.types.callExpression(h, [
1373
- d.types.stringLiteral(T),
1374
- d.types.callExpression(S, [
1375
- d.types.stringLiteral(v),
1376
- d.types.identifier(j),
1377
- d.types.identifier(m),
1388
+ let G = m.types.expressionStatement(
1389
+ m.types.callExpression(h, [
1390
+ m.types.stringLiteral(k),
1391
+ m.types.callExpression(S, [
1392
+ m.types.stringLiteral(v),
1393
+ m.types.identifier(j),
1394
+ m.types.identifier(d),
1378
1395
  $e
1379
1396
  ])
1380
1397
  ])
1381
1398
  );
1382
- return W.loc = k.loc, W;
1399
+ return G.loc = V.loc, G;
1383
1400
  }, "getTestStatementForStory"), Ue = Object.entries(b).map(([j, v]) => {
1384
1401
  if (v === null) {
1385
1402
  Ce.warn(
1386
- oe.dedent`
1403
+ ae.dedent`
1387
1404
  [Storybook]: Could not transform "${j}" story into test at "${e}".
1388
1405
  Please make sure to define stories in the same file and not re-export stories coming from other files".
1389
1406
  `
1390
1407
  );
1391
1408
  return;
1392
1409
  }
1393
- let T = l._stories[j].localName ?? j, k = l._stories[j].name ?? j;
1394
- return Me({ testTitle: k, localName: T, exportName: j, node: v });
1395
- }).filter((j) => !!j), qe = d.types.ifStatement(Le, d.types.blockStatement(Ue));
1396
- f.program.body.push(qe);
1410
+ let k = a._stories[j].localName ?? j, V = a._stories[j].name ?? j;
1411
+ return Me({ testTitle: V, localName: k, exportName: j, node: v });
1412
+ }).filter((j) => !!j), qe = m.types.ifStatement(Le, m.types.blockStatement(Ue));
1413
+ p.program.body.push(qe);
1397
1414
  let Be = [
1398
- d.types.importDeclaration(
1415
+ m.types.importDeclaration(
1399
1416
  [
1400
- d.types.importSpecifier(h, d.types.identifier("test")),
1401
- d.types.importSpecifier(_, d.types.identifier("expect"))
1417
+ m.types.importSpecifier(h, m.types.identifier("test")),
1418
+ m.types.importSpecifier(_, m.types.identifier("expect"))
1402
1419
  ],
1403
- d.types.stringLiteral("vitest")
1420
+ m.types.stringLiteral("vitest")
1404
1421
  ),
1405
- d.types.importDeclaration(
1406
- [d.types.importSpecifier(S, d.types.identifier("testStory"))],
1407
- d.types.stringLiteral("@storybook/addon-test/internal/test-utils")
1422
+ m.types.importDeclaration(
1423
+ [m.types.importSpecifier(S, m.types.identifier("testStory"))],
1424
+ m.types.stringLiteral("@storybook/addon-test/internal/test-utils")
1408
1425
  )
1409
1426
  ];
1410
- f.program.body.unshift(...Be);
1427
+ p.program.body.unshift(...Be);
1411
1428
  }
1412
- return Z(l, { sourceMaps: !0, sourceFileName: e }, s);
1429
+ return te(a, { sourceMaps: !0, sourceFileName: e }, s);
1413
1430
  }
1414
- p(Ve, "vitestTransform");
1431
+ f(Ve, "vitestTransform");