storybook 9.0.0-alpha.9 → 9.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/assets/docs/addon-backgrounds.gif +0 -0
  2. package/assets/docs/addon-controls-args-annotated.png +0 -0
  3. package/assets/docs/addon-controls-args-background-color.png +0 -0
  4. package/assets/docs/addon-controls-args-background-string.png +0 -0
  5. package/assets/docs/addon-controls-args-docs.png +0 -0
  6. package/assets/docs/addon-controls-args-logging.png +0 -0
  7. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  8. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  9. package/assets/docs/addon-controls-args-reflow.png +0 -0
  10. package/assets/docs/addon-controls-args-template.png +0 -0
  11. package/assets/docs/addon-controls-expanded.png +0 -0
  12. package/assets/docs/addon-controls-hero.gif +0 -0
  13. package/assets/docs/addon-controls-install.png +0 -0
  14. package/assets/docs/hero.gif +0 -0
  15. package/assets/docs/highlight.png +0 -0
  16. package/assets/docs/viewport.png +0 -0
  17. package/assets/server/base-preview-head.html +1 -3
  18. package/bin/index.cjs +2 -2
  19. package/dist/actions/decorator.js +67 -72
  20. package/dist/actions/index.cjs +27 -31
  21. package/dist/actions/index.d.ts +0 -3
  22. package/dist/actions/index.js +27 -31
  23. package/dist/actions/preview.cjs +23 -27
  24. package/dist/actions/preview.d.ts +0 -1
  25. package/dist/actions/preview.js +19 -23
  26. package/dist/babel/index.cjs +822 -816
  27. package/dist/babel/index.js +822 -816
  28. package/dist/backgrounds/index.cjs +148 -0
  29. package/dist/backgrounds/index.d.ts +91 -0
  30. package/dist/backgrounds/index.js +130 -0
  31. package/dist/backgrounds/preview.cjs +143 -0
  32. package/dist/backgrounds/preview.d.ts +54 -0
  33. package/dist/backgrounds/preview.js +127 -0
  34. package/dist/bin/index.cjs +73 -92
  35. package/dist/bin/index.js +66 -85
  36. package/dist/builder-manager/index.cjs +316 -296
  37. package/dist/builder-manager/index.js +567 -547
  38. package/dist/channels/index.cjs +1020 -950
  39. package/dist/channels/index.js +1256 -1201
  40. package/dist/cli/bin/index.cjs +198 -198
  41. package/dist/cli/bin/index.js +204 -204
  42. package/dist/cli/index.cjs +61734 -7589
  43. package/dist/cli/index.d.ts +24 -20
  44. package/dist/cli/index.js +61775 -7630
  45. package/dist/common/index.cjs +16133 -9095
  46. package/dist/common/index.d.ts +32 -24
  47. package/dist/common/index.js +16227 -9183
  48. package/dist/component-testing/index.cjs +23 -0
  49. package/dist/component-testing/index.d.ts +3 -0
  50. package/dist/component-testing/index.js +5 -0
  51. package/dist/component-testing/preview.cjs +40 -0
  52. package/dist/component-testing/preview.d.ts +5 -0
  53. package/dist/component-testing/preview.js +25 -0
  54. package/dist/components/index.cjs +6479 -13005
  55. package/dist/components/index.d.ts +8 -257
  56. package/dist/components/index.js +6160 -18689
  57. package/dist/controls/decorator.d.ts +5 -0
  58. package/dist/controls/decorator.js +8 -0
  59. package/dist/controls/index.cjs +26 -0
  60. package/dist/controls/index.d.ts +39 -0
  61. package/dist/controls/index.js +6 -0
  62. package/dist/controls/preview.cjs +26 -0
  63. package/dist/controls/preview.d.ts +54 -0
  64. package/dist/controls/preview.js +9 -0
  65. package/dist/core-events/index.cjs +91 -106
  66. package/dist/core-events/index.d.ts +2 -80
  67. package/dist/core-events/index.js +79 -94
  68. package/dist/core-server/index.cjs +12409 -12231
  69. package/dist/core-server/index.d.ts +32 -23
  70. package/dist/core-server/index.js +12567 -12389
  71. package/dist/core-server/presets/common-manager.css +170 -0
  72. package/dist/core-server/presets/common-manager.js +12153 -12
  73. package/dist/core-server/presets/common-preset.cjs +3004 -3151
  74. package/dist/core-server/presets/common-preset.js +2833 -2981
  75. package/dist/csf/index.d.ts +1 -3
  76. package/dist/csf-tools/index.cjs +412 -403
  77. package/dist/csf-tools/index.d.ts +0 -4
  78. package/dist/csf-tools/index.js +410 -401
  79. package/dist/docs-tools/index.cjs +2569 -575
  80. package/dist/docs-tools/index.js +2565 -564
  81. package/dist/highlight/index.cjs +27 -0
  82. package/dist/highlight/index.d.ts +61 -0
  83. package/dist/highlight/index.js +7 -0
  84. package/dist/highlight/preview.cjs +535 -0
  85. package/dist/highlight/preview.d.ts +54 -0
  86. package/dist/highlight/preview.js +519 -0
  87. package/dist/instrumenter/index.cjs +1411 -1758
  88. package/dist/instrumenter/index.d.ts +8 -7
  89. package/dist/instrumenter/index.js +1325 -1663
  90. package/dist/manager/globals-module-info.cjs +22 -33
  91. package/dist/manager/globals-module-info.js +7 -18
  92. package/dist/manager/globals-runtime.js +45452 -49541
  93. package/dist/manager/runtime.js +4392 -3774
  94. package/dist/manager-api/index.cjs +2622 -2529
  95. package/dist/manager-api/index.d.ts +109 -114
  96. package/dist/manager-api/index.js +2603 -2475
  97. package/dist/manager-errors.js +41 -37
  98. package/dist/measure/index.cjs +476 -0
  99. package/dist/measure/index.d.ts +66 -0
  100. package/dist/measure/index.js +464 -0
  101. package/dist/measure/preview.cjs +466 -0
  102. package/dist/measure/preview.d.ts +59 -0
  103. package/dist/measure/preview.js +450 -0
  104. package/dist/outline/index.cjs +528 -0
  105. package/dist/outline/index.d.ts +66 -0
  106. package/dist/outline/index.js +500 -0
  107. package/dist/outline/preview.cjs +518 -0
  108. package/dist/outline/preview.d.ts +59 -0
  109. package/dist/outline/preview.js +486 -0
  110. package/dist/preview/runtime.js +41973 -38159
  111. package/dist/preview-api/index.cjs +1204 -1293
  112. package/dist/preview-api/index.d.ts +126 -178
  113. package/dist/preview-api/index.js +1614 -1685
  114. package/dist/preview-errors.cjs +65 -51
  115. package/dist/preview-errors.d.ts +6 -2
  116. package/dist/preview-errors.js +176 -142
  117. package/dist/server-errors.cjs +160 -113
  118. package/dist/server-errors.d.ts +12 -2
  119. package/dist/server-errors.js +157 -110
  120. package/dist/telemetry/index.cjs +374 -370
  121. package/dist/telemetry/index.d.ts +1 -1
  122. package/dist/telemetry/index.js +460 -456
  123. package/dist/test/index.cjs +1553 -1552
  124. package/dist/test/index.js +9603 -9514
  125. package/dist/test/preview.cjs +1906 -1905
  126. package/dist/test/preview.d.ts +0 -6
  127. package/dist/test/preview.js +3664 -3603
  128. package/dist/test/spy.cjs +65 -64
  129. package/dist/test/spy.js +59 -58
  130. package/dist/types/index.cjs +11 -12
  131. package/dist/types/index.d.ts +601 -334
  132. package/dist/types/index.js +1 -2
  133. package/dist/viewport/index.cjs +310 -0
  134. package/dist/viewport/index.d.ts +320 -0
  135. package/dist/viewport/index.js +290 -0
  136. package/dist/viewport/preview.cjs +35 -0
  137. package/dist/viewport/preview.d.ts +68 -0
  138. package/dist/viewport/preview.js +19 -0
  139. package/package.json +207 -12
  140. package/dist/actions/manager.js +0 -1196
@@ -5,93 +5,93 @@ const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
5
5
  const __dirname = ESM_COMPAT_dirname(__filename);
6
6
  const require = ESM_COMPAT_Module.createRequire(import.meta.url);
7
7
  var ke = Object.create;
8
- var G = Object.defineProperty;
8
+ var X = Object.defineProperty;
9
9
  var Ve = Object.getOwnPropertyDescriptor;
10
10
  var Ae = Object.getOwnPropertyNames;
11
11
  var $e = Object.getPrototypeOf, Re = Object.prototype.hasOwnProperty;
12
- var p = (s, e) => G(s, "name", { value: e, configurable: !0 });
12
+ var f = (s, e) => X(s, "name", { value: e, configurable: !0 });
13
13
  var Le = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports);
14
14
  var Me = (s, e, i, t) => {
15
15
  if (e && typeof e == "object" || typeof e == "function")
16
16
  for (let r of Ae(e))
17
- !Re.call(s, r) && r !== i && G(s, r, { get: () => e[r], enumerable: !(t = Ve(e, r)) || t.enumerable });
17
+ !Re.call(s, r) && r !== i && X(s, r, { get: () => e[r], enumerable: !(t = Ve(e, r)) || t.enumerable });
18
18
  return s;
19
19
  };
20
- var M = (s, e, i) => (i = s != null ? ke($e(s)) : {}, Me(
20
+ var U = (s, e, i) => (i = s != null ? ke($e(s)) : {}, Me(
21
21
  // If the importer is in node compatibility mode or this is not an ESM
22
22
  // file that has been converted to a CommonJS file using a Babel-
23
23
  // compatible transform (i.e. "__esModule" has not been set), then set
24
24
  // "default" to the CommonJS "module.exports" for node compatibility.
25
- e || !s || !s.__esModule ? G(i, "default", { value: s, enumerable: !0 }) : i,
25
+ e || !s || !s.__esModule ? X(i, "default", { value: s, enumerable: !0 }) : i,
26
26
  s
27
27
  ));
28
28
 
29
29
  // ../node_modules/ts-dedent/dist/index.js
30
- var k = Le((T) => {
30
+ var V = Le((k) => {
31
31
  "use strict";
32
- Object.defineProperty(T, "__esModule", { value: !0 });
33
- T.dedent = void 0;
34
- function ie(s) {
32
+ Object.defineProperty(k, "__esModule", { value: !0 });
33
+ k.dedent = void 0;
34
+ function se(s) {
35
35
  for (var e = [], i = 1; i < arguments.length; i++)
36
36
  e[i - 1] = arguments[i];
37
37
  var t = Array.from(typeof s == "string" ? [s] : s);
38
38
  t[t.length - 1] = t[t.length - 1].replace(/\r?\n([\t ]*)$/, "");
39
- var r = t.reduce(function(l, f) {
40
- var m = f.match(/\n([\t ]+|(?!\s).)/g);
41
- return m ? l.concat(m.map(function(g) {
39
+ var r = t.reduce(function(a, p) {
40
+ var d = p.match(/\n([\t ]+|(?!\s).)/g);
41
+ return d ? a.concat(d.map(function(g) {
42
42
  var x, b;
43
43
  return (b = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && b !== void 0 ? b : 0;
44
- })) : l;
44
+ })) : a;
45
45
  }, []);
46
46
  if (r.length) {
47
47
  var o = new RegExp(`
48
48
  [ ]{` + Math.min.apply(Math, r) + "}", "g");
49
- t = t.map(function(l) {
50
- return l.replace(o, `
49
+ t = t.map(function(a) {
50
+ return a.replace(o, `
51
51
  `);
52
52
  });
53
53
  }
54
54
  t[0] = t[0].replace(/^\r?\n/, "");
55
- var a = t[0];
56
- return e.forEach(function(l, f) {
57
- var m = a.match(/(?:^|\n)( *)$/), g = m ? m[1] : "", x = l;
58
- typeof l == "string" && l.includes(`
59
- `) && (x = String(l).split(`
55
+ var l = t[0];
56
+ return e.forEach(function(a, p) {
57
+ var d = l.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = a;
58
+ typeof a == "string" && a.includes(`
59
+ `) && (x = String(a).split(`
60
60
  `).map(function(b, y) {
61
61
  return y === 0 ? b : "" + g + b;
62
62
  }).join(`
63
- `)), a += x + t[f + 1];
64
- }), a;
63
+ `)), l += x + t[p + 1];
64
+ }), l;
65
65
  }
66
- p(ie, "dedent");
67
- T.dedent = ie;
68
- T.default = ie;
66
+ f(se, "dedent");
67
+ k.dedent = se;
68
+ k.default = se;
69
69
  });
70
70
 
71
71
  // src/csf-tools/CsfFile.ts
72
- var O = M(k(), 1);
72
+ var P = U(V(), 1);
73
73
  import { readFile as Ue, writeFile as qe } from "node:fs/promises";
74
74
  import {
75
75
  BabelFileClass as Be,
76
- babelParse as pe,
76
+ babelParse as fe,
77
77
  generate as We,
78
- recast as fe,
78
+ recast as de,
79
79
  types as c,
80
80
  traverse as Ge
81
81
  } from "storybook/internal/babel";
82
- import { isExportStory as se, storyNameFromExport as ne, toId as ze } from "storybook/internal/csf";
82
+ import { isExportStory as ne, storyNameFromExport as oe, toId as ze } from "storybook/internal/csf";
83
83
 
84
84
  // src/csf-tools/findVarInitialization.ts
85
- import { types as V } from "storybook/internal/babel";
86
- var P = /* @__PURE__ */ p((s, e) => {
85
+ import { types as A } from "storybook/internal/babel";
86
+ var O = /* @__PURE__ */ f((s, e) => {
87
87
  let i = null, t = null;
88
- return e.body.find((r) => (V.isVariableDeclaration(r) ? t = r.declarations : V.isExportNamedDeclaration(r) && V.isVariableDeclaration(r.declaration) &&
89
- (t = r.declaration.declarations), t && t.find((o) => V.isVariableDeclarator(o) && V.isIdentifier(o.id) && o.id.name === s ? (i = o.init, !0) :
88
+ return e.body.find((r) => (A.isVariableDeclaration(r) ? t = r.declarations : A.isExportNamedDeclaration(r) && A.isVariableDeclaration(r.declaration) &&
89
+ (t = r.declaration.declarations), t && t.find((o) => A.isVariableDeclarator(o) && A.isIdentifier(o.id) && o.id.name === s ? (i = o.init, !0) :
90
90
  !1))), i;
91
91
  }, "findVarInitialization");
92
92
 
93
93
  // src/csf-tools/CsfFile.ts
94
- var oe = console, Xe = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, Ke = /* @__PURE__ */ p((s) => Xe.test(s), "isValidPreviewPath");
94
+ var ae = console, Xe = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, Ke = /* @__PURE__ */ f((s) => Xe.test(s), "isValidPreviewPath");
95
95
  function Je(s) {
96
96
  if (c.isArrayExpression(s))
97
97
  return s.elements.map((e) => {
@@ -105,8 +105,8 @@ function Je(s) {
105
105
  return new RegExp(s.pattern, s.flags);
106
106
  throw new Error(`Unknown include/exclude: ${s}`);
107
107
  }
108
- p(Je, "parseIncludeExclude");
109
- function ae(s) {
108
+ f(Je, "parseIncludeExclude");
109
+ function le(s) {
110
110
  if (!c.isArrayExpression(s))
111
111
  throw new Error("CSF: Expected tags array");
112
112
  return s.elements.map((e) => {
@@ -115,26 +115,26 @@ function ae(s) {
115
115
  throw new Error("CSF: Expected tag to be string literal");
116
116
  });
117
117
  }
118
- p(ae, "parseTags");
119
- var I = /* @__PURE__ */ p((s, e) => {
118
+ f(le, "parseTags");
119
+ var I = /* @__PURE__ */ f((s, e) => {
120
120
  let i = "";
121
121
  if (s.loc) {
122
122
  let { line: t, column: r } = s.loc?.start || {};
123
123
  i = `(line ${t}, col ${r})`;
124
124
  }
125
125
  return `${e || ""} ${i}`.trim();
126
- }, "formatLocation"), Qe = /* @__PURE__ */ p((s) => Ze.test(s), "isModuleMock"), le = /* @__PURE__ */ p((s, e, i) => {
126
+ }, "formatLocation"), Qe = /* @__PURE__ */ f((s) => Ze.test(s), "isModuleMock"), ce = /* @__PURE__ */ f((s, e, i) => {
127
127
  let t = s;
128
128
  if (c.isCallExpression(s)) {
129
129
  let { callee: r, arguments: o } = s;
130
130
  if (c.isProgram(e) && c.isMemberExpression(r) && c.isIdentifier(r.object) && c.isIdentifier(r.property) && r.property.name === "bind" &&
131
131
  (o.length === 0 || o.length === 1 && c.isObjectExpression(o[0]) && o[0].properties.length === 0)) {
132
- let a = r.object.name, l = P(a, e);
133
- l && (i._templates[a] = l, t = l);
132
+ let l = r.object.name, a = O(l, e);
133
+ a && (i._templates[l] = a, t = a);
134
134
  }
135
135
  }
136
136
  return c.isArrowFunctionExpression(t) || c.isFunctionDeclaration(t) ? t.params.length > 0 : !1;
137
- }, "isArgsStory"), He = /* @__PURE__ */ p((s) => {
137
+ }, "isArgsStory"), He = /* @__PURE__ */ f((s) => {
138
138
  if (c.isArrayExpression(s))
139
139
  return s.elements.map((e) => {
140
140
  if (c.isStringLiteral(e))
@@ -142,13 +142,13 @@ var I = /* @__PURE__ */ p((s, e) => {
142
142
  throw new Error(`Expected string literal named export: ${e}`);
143
143
  });
144
144
  throw new Error(`Expected array of string literals: ${s}`);
145
- }, "parseExportsOrder"), ce = /* @__PURE__ */ p((s, e) => e.reduce(
145
+ }, "parseExportsOrder"), pe = /* @__PURE__ */ f((s, e) => e.reduce(
146
146
  (i, t) => {
147
147
  let r = s[t];
148
148
  return r && (i[t] = r), i;
149
149
  },
150
150
  {}
151
- ), "sortExports"), Ye = /* @__PURE__ */ p((s) => {
151
+ ), "sortExports"), Ye = /* @__PURE__ */ f((s) => {
152
152
  if (c.isArrowFunctionExpression(s) || c.isFunctionDeclaration(s)) {
153
153
  let e = s.params;
154
154
  if (e.length >= 1) {
@@ -161,55 +161,55 @@ var I = /* @__PURE__ */ p((s, e) => {
161
161
  }
162
162
  }
163
163
  return !1;
164
- }, "hasMount"), Ze = /^[.\/#].*\.mock($|\.[^.]*$)/i, U = class extends Error {
164
+ }, "hasMount"), Ze = /^[.\/#].*\.mock($|\.[^.]*$)/i, q = class extends Error {
165
165
  static {
166
- p(this, "NoMetaError");
166
+ f(this, "NoMetaError");
167
167
  }
168
168
  constructor(e, i, t) {
169
169
  let r = "".trim();
170
- super(O.dedent`
170
+ super(P.dedent`
171
171
  CSF: ${e} ${I(i, t)}
172
172
 
173
173
  More info: https://storybook.js.org/docs/writing-stories#default-export
174
174
  `), this.name = this.constructor.name;
175
175
  }
176
- }, z = class extends Error {
176
+ }, K = class extends Error {
177
177
  static {
178
- p(this, "MultipleMetaError");
178
+ f(this, "MultipleMetaError");
179
179
  }
180
180
  constructor(e, i, t) {
181
181
  let r = `${e} ${I(i, t)}`.trim();
182
- super(O.dedent`
182
+ super(P.dedent`
183
183
  CSF: ${e} ${I(i, t)}
184
184
 
185
185
  More info: https://storybook.js.org/docs/writing-stories#default-export
186
186
  `), this.name = this.constructor.name;
187
187
  }
188
- }, q = class extends Error {
188
+ }, B = class extends Error {
189
189
  static {
190
- p(this, "MixedFactoryError");
190
+ f(this, "MixedFactoryError");
191
191
  }
192
192
  constructor(e, i, t) {
193
193
  let r = `${e} ${I(i, t)}`.trim();
194
- super(O.dedent`
194
+ super(P.dedent`
195
195
  CSF: ${e} ${I(i, t)}
196
196
 
197
197
  More info: https://storybook.js.org/docs/writing-stories#default-export
198
198
  `), this.name = this.constructor.name;
199
199
  }
200
- }, B = class extends Error {
200
+ }, W = class extends Error {
201
201
  static {
202
- p(this, "BadMetaError");
202
+ f(this, "BadMetaError");
203
203
  }
204
204
  constructor(e, i, t) {
205
205
  let r = "".trim();
206
- super(O.dedent`
206
+ super(P.dedent`
207
207
  CSF: ${e} ${I(i, t)}
208
208
 
209
209
  More info: https://storybook.js.org/docs/writing-stories#default-export
210
210
  `), this.name = this.constructor.name;
211
211
  }
212
- }, X = class {
212
+ }, J = class {
213
213
  constructor(e, i, t) {
214
214
  this._stories = {};
215
215
  this._metaAnnotations = {};
@@ -221,23 +221,15 @@ var I = /* @__PURE__ */ p((s, e) => {
221
221
  this._ast = e, this._file = t, this._options = i, this.imports = [];
222
222
  }
223
223
  static {
224
- p(this, "CsfFile");
225
- }
226
- /** @deprecated Use `_options.fileName` instead */
227
- get _fileName() {
228
- return this._options.fileName;
229
- }
230
- /** @deprecated Use `_options.makeTitle` instead */
231
- get _makeTitle() {
232
- return this._options.makeTitle;
224
+ f(this, "CsfFile");
233
225
  }
234
226
  _parseTitle(e) {
235
- let i = c.isIdentifier(e) ? P(e.name, this._ast.program) : e;
227
+ let i = c.isIdentifier(e) ? O(e.name, this._ast.program) : e;
236
228
  if (c.isStringLiteral(i))
237
229
  return i.value;
238
230
  if (c.isTSSatisfiesExpression(i) && c.isStringLiteral(i.expression))
239
231
  return i.expression.value;
240
- throw new Error(O.dedent`
232
+ throw new Error(P.dedent`
241
233
  CSF: unexpected dynamic title ${I(i, this._options.fileName)}
242
234
 
243
235
  More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
@@ -245,7 +237,7 @@ var I = /* @__PURE__ */ p((s, e) => {
245
237
  }
246
238
  _parseMeta(e, i) {
247
239
  if (this._metaNode)
248
- throw new z("multiple meta objects", e, this._options.fileName);
240
+ throw new K("multiple meta objects", e, this._options.fileName);
249
241
  this._metaNode = e;
250
242
  let t = {};
251
243
  e.properties.forEach((r) => {
@@ -257,19 +249,19 @@ var I = /* @__PURE__ */ p((s, e) => {
257
249
  else if (r.key.name === "component") {
258
250
  let o = r.value;
259
251
  if (c.isIdentifier(o)) {
260
- let l = o.name, f = i.body.find(
261
- (m) => c.isImportDeclaration(m) && m.specifiers.find((g) => g.local.name === l)
252
+ let a = o.name, p = i.body.find(
253
+ (d) => c.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === a)
262
254
  );
263
- if (f) {
264
- let { source: m } = f;
265
- c.isStringLiteral(m) && (this._rawComponentPath = m.value);
255
+ if (p) {
256
+ let { source: d } = p;
257
+ c.isStringLiteral(d) && (this._rawComponentPath = d.value);
266
258
  }
267
259
  }
268
- let { code: a } = fe.print(r.value, {});
269
- t.component = a;
260
+ let { code: l } = de.print(r.value, {});
261
+ t.component = l;
270
262
  } else if (r.key.name === "tags") {
271
263
  let o = r.value;
272
- c.isIdentifier(o) && (o = P(o.name, this._ast.program)), t.tags = ae(o);
264
+ c.isIdentifier(o) && (o = O(o.name, this._ast.program)), t.tags = le(o);
273
265
  } else if (r.key.name === "id")
274
266
  if (c.isStringLiteral(r.value))
275
267
  t.id = r.value.value;
@@ -295,34 +287,34 @@ var I = /* @__PURE__ */ p((s, e) => {
295
287
  if (Ge(this._ast, {
296
288
  ExportDefaultDeclaration: {
297
289
  enter(t) {
298
- let { node: r, parent: o } = t, a = c.isIdentifier(r.declaration) && c.isProgram(o);
299
- if (e._options.transformInlineMeta && !a && c.isExpression(r.declaration)) {
300
- let m = t.scope.generateUidIdentifier("meta");
301
- e._metaVariableName = m.name;
290
+ let { node: r, parent: o } = t, l = c.isIdentifier(r.declaration) && c.isProgram(o);
291
+ if (e._options.transformInlineMeta && !l && c.isExpression(r.declaration)) {
292
+ let d = t.scope.generateUidIdentifier("meta");
293
+ e._metaVariableName = d.name;
302
294
  let g = [
303
- c.variableDeclaration("const", [c.variableDeclarator(m, r.declaration)]),
304
- c.exportDefaultDeclaration(m)
295
+ c.variableDeclaration("const", [c.variableDeclarator(d, r.declaration)]),
296
+ c.exportDefaultDeclaration(d)
305
297
  ];
306
298
  g.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(g);
307
299
  return;
308
300
  }
309
- let l, f;
310
- if (a) {
311
- let m = r.declaration.name;
312
- e._metaVariableName = m;
313
- let g = /* @__PURE__ */ p((x) => c.isIdentifier(x.id) && x.id.name === m, "isVariableDeclarator");
301
+ let a, p;
302
+ if (l) {
303
+ let d = r.declaration.name;
304
+ e._metaVariableName = d;
305
+ let g = /* @__PURE__ */ f((x) => c.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
314
306
  e._metaStatement = e._ast.program.body.find(
315
307
  (x) => c.isVariableDeclaration(x) && x.declarations.find(g)
316
- ), f = (e?._metaStatement?.declarations || []).find(
308
+ ), p = (e?._metaStatement?.declarations || []).find(
317
309
  g
318
310
  )?.init;
319
311
  } else
320
- e._metaStatement = r, f = r.declaration;
321
- if (c.isObjectExpression(f) ? l = f : (
312
+ e._metaStatement = r, p = r.declaration;
313
+ if (c.isObjectExpression(p) ? a = p : (
322
314
  // export default { ... } as Meta<...>
323
- (c.isTSAsExpression(f) || c.isTSSatisfiesExpression(f)) && c.isObjectExpression(f.expression) && (l = f.expression)
324
- ), l && c.isProgram(o) && e._parseMeta(l, o), e._metaStatement && !e._metaNode)
325
- throw new U(
315
+ (c.isTSAsExpression(p) || c.isTSSatisfiesExpression(p)) && c.isObjectExpression(p.expression) && (a = p.expression)
316
+ ), a && c.isProgram(o) && e._parseMeta(a, o), e._metaStatement && !e._metaNode)
317
+ throw new q(
326
318
  "default export must be an object",
327
319
  e._metaStatement,
328
320
  e._options.fileName
@@ -332,35 +324,35 @@ var I = /* @__PURE__ */ p((s, e) => {
332
324
  },
333
325
  ExportNamedDeclaration: {
334
326
  enter(t) {
335
- let { node: r, parent: o } = t, a;
336
- c.isVariableDeclaration(r.declaration) ? a = r.declaration.declarations.filter((l) => c.isVariableDeclarator(l)) : c.isFunctionDeclaration(
337
- r.declaration) && (a = [r.declaration]), a ? a.forEach((l) => {
338
- if (c.isIdentifier(l.id)) {
339
- let f = !1, { name: m } = l.id;
340
- if (m === "__namedExportsOrder" && c.isVariableDeclarator(l)) {
341
- e._namedExportsOrder = He(l.init);
327
+ let { node: r, parent: o } = t, l;
328
+ c.isVariableDeclaration(r.declaration) ? l = r.declaration.declarations.filter((a) => c.isVariableDeclarator(a)) : c.isFunctionDeclaration(
329
+ r.declaration) && (l = [r.declaration]), l ? l.forEach((a) => {
330
+ if (c.isIdentifier(a.id)) {
331
+ let p = !1, { name: d } = a.id;
332
+ if (d === "__namedExportsOrder" && c.isVariableDeclarator(a)) {
333
+ e._namedExportsOrder = He(a.init);
342
334
  return;
343
335
  }
344
- e._storyExports[m] = l, e._storyPaths[m] = t, e._storyStatements[m] = r;
345
- let g = ne(m);
346
- e._storyAnnotations[m] ? oe.warn(
347
- `Unexpected annotations for "${m}" before story declaration`
348
- ) : e._storyAnnotations[m] = {};
336
+ e._storyExports[d] = a, e._storyPaths[d] = t, e._storyStatements[d] = r;
337
+ let g = oe(d);
338
+ e._storyAnnotations[d] ? ae.warn(
339
+ `Unexpected annotations for "${d}" before story declaration`
340
+ ) : e._storyAnnotations[d] = {};
349
341
  let x;
350
- if (c.isVariableDeclarator(l) ? x = c.isTSAsExpression(l.init) || c.isTSSatisfiesExpression(l.init) ? l.init.expression : l.init :
351
- x = l, c.isCallExpression(x) && c.isMemberExpression(x.callee) && c.isIdentifier(x.callee.property) && x.callee.property.name ===
352
- "story" && (f = !0, x = x.arguments[0]), e._metaIsFactory && !f)
353
- throw new q(
342
+ if (c.isVariableDeclarator(a) ? x = c.isTSAsExpression(a.init) || c.isTSSatisfiesExpression(a.init) ? a.init.expression : a.init :
343
+ x = a, c.isCallExpression(x) && c.isMemberExpression(x.callee) && c.isIdentifier(x.callee.property) && x.callee.property.name ===
344
+ "story" && (p = !0, x = x.arguments[0]), e._metaIsFactory && !p)
345
+ throw new B(
354
346
  "expected factory story",
355
347
  x,
356
348
  e._options.fileName
357
349
  );
358
- if (!e._metaIsFactory && f)
359
- throw e._metaNode ? new q(
350
+ if (!e._metaIsFactory && p)
351
+ throw e._metaNode ? new B(
360
352
  "expected non-factory story",
361
353
  x,
362
354
  e._options.fileName
363
- ) : new B(
355
+ ) : new W(
364
356
  "meta() factory must be imported from .storybook/preview configuration",
365
357
  x,
366
358
  e._options.fileName
@@ -369,7 +361,7 @@ var I = /* @__PURE__ */ p((s, e) => {
369
361
  c.isObjectExpression(x) ? (b.__isArgsStory = !0, x.properties.forEach((y) => {
370
362
  if (c.isIdentifier(y.key)) {
371
363
  if (y.key.name === "render")
372
- b.__isArgsStory = le(
364
+ b.__isArgsStory = ce(
373
365
  y.value,
374
366
  o,
375
367
  e
@@ -377,8 +369,8 @@ var I = /* @__PURE__ */ p((s, e) => {
377
369
  else if (y.key.name === "name" && c.isStringLiteral(y.value))
378
370
  g = y.value.value;
379
371
  else if (y.key.name === "storyName" && c.isStringLiteral(y.value))
380
- oe.warn(
381
- `Unexpected usage of "storyName" in "${m}". Please use "name" instead.`
372
+ ae.warn(
373
+ `Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
382
374
  );
383
375
  else if (y.key.name === "parameters" && c.isObjectExpression(y.value)) {
384
376
  let h = y.value.properties.find(
@@ -386,31 +378,31 @@ var I = /* @__PURE__ */ p((s, e) => {
386
378
  );
387
379
  h && (b.__id = h.value.value);
388
380
  }
389
- e._storyAnnotations[m][y.key.name] = y.value;
381
+ e._storyAnnotations[d][y.key.name] = y.value;
390
382
  }
391
- })) : b.__isArgsStory = le(x, o, e), e._stories[m] = {
383
+ })) : b.__isArgsStory = ce(x, o, e), e._stories[d] = {
392
384
  id: "FIXME",
393
385
  name: g,
394
386
  parameters: b,
395
387
  __stats: {
396
- factory: f
388
+ factory: p
397
389
  }
398
390
  };
399
391
  }
400
- }) : r.specifiers.length > 0 && r.specifiers.forEach((l) => {
401
- if (c.isExportSpecifier(l) && c.isIdentifier(l.exported)) {
402
- let { name: f } = l.exported, { name: m } = l.local, g = c.isProgram(o) ? P(l.local.name, o) : l.local;
403
- if (f === "default") {
392
+ }) : r.specifiers.length > 0 && r.specifiers.forEach((a) => {
393
+ if (c.isExportSpecifier(a) && c.isIdentifier(a.exported)) {
394
+ let { name: p } = a.exported, { name: d } = a.local, g = c.isProgram(o) ? O(a.local.name, o) : a.local;
395
+ if (p === "default") {
404
396
  let x;
405
397
  c.isObjectExpression(g) ? x = g : (
406
398
  // export default { ... } as Meta<...>
407
399
  c.isTSAsExpression(g) && c.isObjectExpression(g.expression) && (x = g.expression)
408
400
  ), x && c.isProgram(o) && e._parseMeta(x, o);
409
401
  } else
410
- e._storyAnnotations[f] = {}, e._storyStatements[f] = g, e._storyPaths[f] = t, e._stories[f] = {
402
+ e._storyAnnotations[p] = {}, e._storyStatements[p] = g, e._storyPaths[p] = t, e._stories[p] = {
411
403
  id: "FIXME",
412
- name: f,
413
- localName: m,
404
+ name: p,
405
+ localName: d,
414
406
  parameters: {},
415
407
  __stats: {}
416
408
  };
@@ -423,14 +415,14 @@ var I = /* @__PURE__ */ p((s, e) => {
423
415
  let { expression: o } = t;
424
416
  if (c.isProgram(r) && c.isAssignmentExpression(o) && c.isMemberExpression(o.left) && c.isIdentifier(o.left.object) && c.isIdentifier(
425
417
  o.left.property)) {
426
- let a = o.left.object.name, l = o.left.property.name, f = o.right;
427
- if (e._storyAnnotations[a] && (l === "story" && c.isObjectExpression(f) ? f.properties.forEach((m) => {
428
- c.isIdentifier(m.key) && (e._storyAnnotations[a][m.key.name] = m.value);
429
- }) : e._storyAnnotations[a][l] = f), l === "storyName" && c.isStringLiteral(f)) {
430
- let m = f.value, g = e._stories[a];
418
+ let l = o.left.object.name, a = o.left.property.name, p = o.right;
419
+ if (e._storyAnnotations[l] && (a === "story" && c.isObjectExpression(p) ? p.properties.forEach((d) => {
420
+ c.isIdentifier(d.key) && (e._storyAnnotations[l][d.key.name] = d.value);
421
+ }) : e._storyAnnotations[l][a] = p), a === "storyName" && c.isStringLiteral(p)) {
422
+ let d = p.value, g = e._stories[l];
431
423
  if (!g)
432
424
  return;
433
- g.name = m;
425
+ g.name = d;
434
426
  }
435
427
  }
436
428
  }
@@ -439,22 +431,22 @@ var I = /* @__PURE__ */ p((s, e) => {
439
431
  enter(t) {
440
432
  let { node: r } = t, { callee: o } = r;
441
433
  if (c.isIdentifier(o) && o.name === "storiesOf")
442
- throw new Error(O.dedent`
434
+ throw new Error(P.dedent`
443
435
  Unexpected \`storiesOf\` usage: ${I(r, e._options.fileName)}.
444
436
 
445
437
  SB8 does not support \`storiesOf\`.
446
438
  `);
447
439
  if (c.isMemberExpression(o) && c.isIdentifier(o.property) && o.property.name === "meta" && c.isIdentifier(o.object) && r.arguments.
448
440
  length > 0) {
449
- let l = t.scope.getBinding(o.object.name)?.path?.parentPath?.node;
450
- if (c.isImportDeclaration(l))
451
- if (Ke(l.source.value)) {
452
- let f = r.arguments[0];
453
- e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(f, e._ast.program);
441
+ let a = t.scope.getBinding(o.object.name)?.path?.parentPath?.node;
442
+ if (c.isImportDeclaration(a))
443
+ if (Ke(a.source.value)) {
444
+ let p = r.arguments[0];
445
+ e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
454
446
  } else
455
- throw new B(
447
+ throw new W(
456
448
  "meta() factory must be imported from .storybook/preview configuration",
457
- l,
449
+ a,
458
450
  e._options.fileName
459
451
  );
460
452
  }
@@ -470,36 +462,36 @@ var I = /* @__PURE__ */ p((s, e) => {
470
462
  }
471
463
  }
472
464
  }), !e._meta)
473
- throw new U("missing default export", e._ast, e._options.fileName);
465
+ throw new q("missing default export", e._ast, e._options.fileName);
474
466
  let i = Object.entries(e._stories);
475
467
  if (e._meta.title = this._options.makeTitle(e._meta?.title), e._metaAnnotations.play && (e._meta.tags = [...e._meta.tags || [], "play-fn"]),
476
468
  e._stories = i.reduce(
477
469
  (t, [r, o]) => {
478
- if (!se(r, e._meta))
470
+ if (!ne(r, e._meta))
479
471
  return t;
480
- let a = o.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, ne(r)), l = { ...o.parameters, __id: a }, { includeStories: f } = e.
472
+ let l = o.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, oe(r)), a = { ...o.parameters, __id: l }, { includeStories: p } = e.
481
473
  _meta || {};
482
- r === "__page" && (i.length === 1 || Array.isArray(f) && f.length === 1) && (l.docsOnly = !0), t[r] = { ...o, id: a, parameters: l };
483
- let m = e._storyAnnotations[r], { tags: g, play: x } = m;
474
+ r === "__page" && (i.length === 1 || Array.isArray(p) && p.length === 1) && (a.docsOnly = !0), t[r] = { ...o, id: l, parameters: a };
475
+ let d = e._storyAnnotations[r], { tags: g, play: x } = d;
484
476
  if (g) {
485
- let h = c.isIdentifier(g) ? P(g.name, this._ast.program) : g;
486
- t[r].tags = ae(h);
477
+ let h = c.isIdentifier(g) ? O(g.name, this._ast.program) : g;
478
+ t[r].tags = le(h);
487
479
  }
488
480
  x && (t[r].tags = [...t[r].tags || [], "play-fn"]);
489
481
  let b = t[r].__stats;
490
482
  ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((h) => {
491
- b[h] = !!m[h] || !!e._metaAnnotations[h];
483
+ b[h] = !!d[h] || !!e._metaAnnotations[h];
492
484
  });
493
485
  let y = e.getStoryExport(r);
494
- return b.storyFn = !!(c.isArrowFunctionExpression(y) || c.isFunctionDeclaration(y)), b.mount = Ye(m.play ?? e._metaAnnotations.play),
486
+ return b.storyFn = !!(c.isArrowFunctionExpression(y) || c.isFunctionDeclaration(y)), b.mount = Ye(d.play ?? e._metaAnnotations.play),
495
487
  b.moduleMock = !!e.imports.find((h) => Qe(h)), t;
496
488
  },
497
489
  {}
498
490
  ), Object.keys(e._storyExports).forEach((t) => {
499
- se(t, e._meta) || (delete e._storyExports[t], delete e._storyAnnotations[t], delete e._storyStatements[t]);
491
+ ne(t, e._meta) || (delete e._storyExports[t], delete e._storyAnnotations[t], delete e._storyStatements[t]);
500
492
  }), e._namedExportsOrder) {
501
493
  let t = Object.keys(e._storyExports);
502
- e._storyExports = ce(e._storyExports, e._namedExportsOrder), e._stories = ce(e._stories, e._namedExportsOrder);
494
+ e._storyExports = pe(e._storyExports, e._namedExportsOrder), e._stories = pe(e._stories, e._namedExportsOrder);
503
495
  let r = Object.keys(e._storyExports);
504
496
  if (t.length !== r.length)
505
497
  throw new Error(
@@ -520,7 +512,7 @@ var I = /* @__PURE__ */ p((s, e) => {
520
512
  let { fileName: e } = this._options;
521
513
  if (!e)
522
514
  throw new Error(
523
- O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
515
+ P.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
524
516
  Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
525
517
  );
526
518
  return Object.entries(this._stories).map(([i, t]) => {
@@ -539,80 +531,80 @@ var I = /* @__PURE__ */ p((s, e) => {
539
531
  };
540
532
  });
541
533
  }
542
- }, et = /* @__PURE__ */ p(({
534
+ }, et = /* @__PURE__ */ f(({
543
535
  code: s,
544
536
  filename: e = "",
545
537
  ast: i
546
- }) => new Be({ filename: e }, { code: s, ast: i ?? pe(s) }), "babelParseFile"), K = /* @__PURE__ */ p((s, e) => {
547
- let i = pe(s), t = et({ code: s, filename: e.fileName, ast: i });
548
- return new X(i, e, t);
549
- }, "loadCsf"), de = /* @__PURE__ */ p((s, e = { sourceMaps: !1 }, i) => {
538
+ }) => new Be({ filename: e }, { code: s, ast: i ?? fe(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
539
+ let i = fe(s), t = et({ code: s, filename: e.fileName, ast: i });
540
+ return new J(i, e, t);
541
+ }, "loadCsf"), me = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, i) => {
550
542
  let t = We(s._ast, e, i);
551
543
  return e.sourceMaps ? t : t.code;
552
- }, "formatCsf"), tt = /* @__PURE__ */ p((s, e = {}) => fe.print(s._ast, e), "printCsf"), Ft = /* @__PURE__ */ p(async (s, e) => {
544
+ }, "formatCsf"), tt = /* @__PURE__ */ f((s, e = {}) => de.print(s._ast, e), "printCsf"), Ft = /* @__PURE__ */ f(async (s, e) => {
553
545
  let i = (await Ue(s, "utf-8")).toString();
554
- return K(i, { ...e, fileName: s });
555
- }, "readCsf"), Ct = /* @__PURE__ */ p(async (s, e) => {
546
+ return Q(i, { ...e, fileName: s });
547
+ }, "readCsf"), Ct = /* @__PURE__ */ f(async (s, e) => {
556
548
  if (!(e || s._options.fileName))
557
549
  throw new Error("Please specify a fileName for writeCsf");
558
550
  await qe(e, tt(s).code);
559
551
  }, "writeCsf");
560
552
 
561
553
  // src/csf-tools/ConfigFile.ts
562
- var xe = M(k(), 1);
554
+ var ye = U(V(), 1);
563
555
  import { readFile as rt, writeFile as it } from "node:fs/promises";
564
556
  import {
565
- babelParse as ge,
566
- generate as me,
557
+ babelParse as xe,
558
+ generate as ue,
567
559
  recast as st,
568
560
  types as n,
569
- traverse as ue
561
+ traverse as ge
570
562
  } from "storybook/internal/babel";
571
- var J = console, Q = /* @__PURE__ */ p(({
563
+ var H = console, Y = /* @__PURE__ */ f(({
572
564
  expectedType: s,
573
565
  foundType: e,
574
566
  node: i
575
- }) => xe.dedent`
567
+ }) => ye.dedent`
576
568
  CSF Parsing error: Expected '${s}' but found '${e}' instead in '${i?.type}'.
577
- `, "getCsfParsingErrorMessage"), A = /* @__PURE__ */ p((s) => n.isIdentifier(s.key) ? s.key.name : n.isStringLiteral(s.key) ? s.key.value :
578
- null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSatisfiesExpression(s) ? W(s.expression) : s, "unwrap"), ye = /* @__PURE__ */ p(
569
+ `, "getCsfParsingErrorMessage"), w = /* @__PURE__ */ f((s) => n.isIdentifier(s.key) ? s.key.name : n.isStringLiteral(s.key) ? s.key.value :
570
+ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSatisfiesExpression(s) ? G(s.expression) : s, "unwrap"), be = /* @__PURE__ */ f(
579
571
  (s, e) => {
580
572
  if (s.length === 0)
581
573
  return e;
582
574
  if (n.isObjectExpression(e)) {
583
- let [i, ...t] = s, r = e.properties.find((o) => A(o) === i);
575
+ let [i, ...t] = s, r = e.properties.find((o) => w(o) === i);
584
576
  if (r)
585
- return ye(t, r.value);
577
+ return be(t, r.value);
586
578
  }
587
- }, "_getPath"), be = /* @__PURE__ */ p((s, e) => {
579
+ }, "_getPath"), Ee = /* @__PURE__ */ f((s, e) => {
588
580
  if (s.length === 0) {
589
581
  if (n.isObjectExpression(e))
590
582
  return e.properties;
591
583
  throw new Error("Expected object expression");
592
584
  }
593
585
  if (n.isObjectExpression(e)) {
594
- let [i, ...t] = s, r = e.properties.find((o) => A(o) === i);
586
+ let [i, ...t] = s, r = e.properties.find((o) => w(o) === i);
595
587
  if (r)
596
- return t.length === 0 ? e.properties : be(t, r.value);
588
+ return t.length === 0 ? e.properties : Ee(t, r.value);
597
589
  }
598
- }, "_getPathProperties"), Ee = /* @__PURE__ */ p((s, e) => {
590
+ }, "_getPathProperties"), z = /* @__PURE__ */ f((s, e) => {
599
591
  let i = null, t = null;
600
592
  return e.body.find((r) => (n.isVariableDeclaration(r) ? t = r.declarations : n.isExportNamedDeclaration(r) && n.isVariableDeclaration(r.declaration) &&
601
593
  (t = r.declaration.declarations), t && t.find((o) => n.isVariableDeclarator(o) && n.isIdentifier(o.id) && o.id.name === s ? (i = o, !0) : !1))),
602
594
  i;
603
- }, "_findVarDeclarator"), v = /* @__PURE__ */ p((s, e) => Ee(s, e)?.init, "_findVarInitialization"), $ = /* @__PURE__ */ p((s, e) => {
595
+ }, "_findVarDeclarator"), N = /* @__PURE__ */ f((s, e) => z(s, e)?.init, "_findVarInitialization"), R = /* @__PURE__ */ f((s, e) => {
604
596
  if (s.length === 0)
605
597
  return e;
606
- let [i, ...t] = s, r = $(t, e);
598
+ let [i, ...t] = s, r = R(t, e);
607
599
  return n.objectExpression([n.objectProperty(n.identifier(i), r)]);
608
- }, "_makeObjectExpression"), H = /* @__PURE__ */ p((s, e, i) => {
600
+ }, "_makeObjectExpression"), $ = /* @__PURE__ */ f((s, e, i) => {
609
601
  let [t, ...r] = s, o = i.properties.find(
610
- (a) => A(a) === t
602
+ (l) => w(l) === t
611
603
  );
612
- o ? n.isObjectExpression(o.value) && r.length > 0 ? H(r, e, o.value) : o.value = $(r, e) : i.properties.push(
613
- n.objectProperty(n.identifier(t), $(r, e))
604
+ o ? n.isObjectExpression(o.value) && r.length > 0 ? $(r, e, o.value) : o.value = R(r, e) : i.properties.push(
605
+ n.objectProperty(n.identifier(t), R(r, e))
614
606
  );
615
- }, "_updateExportNode"), Y = class {
607
+ }, "_updateExportNode"), Z = class {
616
608
  constructor(e, i, t) {
617
609
  this._exports = {};
618
610
  // FIXME: this is a hack. this is only used in the case where the user is
@@ -623,27 +615,27 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
623
615
  this._ast = e, this._code = i, this.fileName = t;
624
616
  }
625
617
  static {
626
- p(this, "ConfigFile");
618
+ f(this, "ConfigFile");
627
619
  }
628
620
  _parseExportsObject(e) {
629
621
  this._exportsObject = e, e.properties.forEach((i) => {
630
- let t = A(i);
622
+ let t = w(i);
631
623
  if (t) {
632
624
  let r = i.value;
633
- n.isIdentifier(r) && (r = v(r.name, this._ast.program)), this._exports[t] = r;
625
+ n.isIdentifier(r) && (r = N(r.name, this._ast.program)), this._exports[t] = r;
634
626
  }
635
627
  });
636
628
  }
637
629
  parse() {
638
630
  let e = this;
639
- return ue(this._ast, {
631
+ return ge(this._ast, {
640
632
  ExportDefaultDeclaration: {
641
633
  enter({ node: i, parent: t }) {
642
634
  e.hasDefaultExport = !0;
643
- let r = n.isIdentifier(i.declaration) && n.isProgram(t) ? v(i.declaration.name, t) : i.declaration;
644
- r = W(r), n.isCallExpression(r) && n.isObjectExpression(r.arguments[0]) && (r = r.arguments[0]), n.isObjectExpression(r) ? e._parseExportsObject(
645
- r) : J.warn(
646
- Q({
635
+ let r = n.isIdentifier(i.declaration) && n.isProgram(t) ? N(i.declaration.name, t) : i.declaration;
636
+ r = G(r), n.isCallExpression(r) && n.isObjectExpression(r.arguments[0]) && (r = r.arguments[0]), n.isObjectExpression(r) ? e._parseExportsObject(
637
+ r) : H.warn(
638
+ Y({
647
639
  expectedType: "ObjectExpression",
648
640
  foundType: r?.type,
649
641
  node: r || i.declaration
@@ -656,8 +648,8 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
656
648
  if (n.isVariableDeclaration(i.declaration))
657
649
  i.declaration.declarations.forEach((r) => {
658
650
  if (n.isVariableDeclarator(r) && n.isIdentifier(r.id)) {
659
- let { name: o } = r.id, a = r.init;
660
- n.isIdentifier(a) && (a = v(a.name, t)), e._exports[o] = a, e._exportDecls[o] = r;
651
+ let { name: o } = r.id, l = r.init;
652
+ n.isIdentifier(l) && (l = N(l.name, t)), e._exports[o] = l, e._exportDecls[o] = r;
661
653
  }
662
654
  });
663
655
  else if (n.isFunctionDeclaration(i.declaration)) {
@@ -668,11 +660,11 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
668
660
  }
669
661
  } else i.specifiers ? i.specifiers.forEach((r) => {
670
662
  if (n.isExportSpecifier(r) && n.isIdentifier(r.local) && n.isIdentifier(r.exported)) {
671
- let { name: o } = r.local, { name: a } = r.exported, l = Ee(o, t);
672
- l && (e._exports[a] = l.init, e._exportDecls[a] = l);
663
+ let { name: o } = r.local, { name: l } = r.exported, a = z(o, t);
664
+ a && (e._exports[l] = a.init, e._exportDecls[l] = a);
673
665
  }
674
- }) : J.warn(
675
- Q({
666
+ }) : H.warn(
667
+ Y({
676
668
  expectedType: "VariableDeclaration",
677
669
  foundType: i.declaration?.type,
678
670
  node: i.declaration
@@ -686,21 +678,21 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
686
678
  let { left: r, right: o } = i.expression;
687
679
  if (n.isMemberExpression(r) && n.isIdentifier(r.object) && r.object.name === "module" && n.isIdentifier(r.property) && r.property.
688
680
  name === "exports") {
689
- let a = o;
690
- n.isIdentifier(o) && (a = v(o.name, t)), a = W(a), n.isObjectExpression(a) ? (e._exportsObject = a, a.properties.forEach((l) => {
691
- let f = A(l);
692
- if (f) {
693
- let m = l.value;
694
- n.isIdentifier(m) && (m = v(
695
- m.name,
681
+ let l = o;
682
+ n.isIdentifier(o) && (l = N(o.name, t)), l = G(l), n.isObjectExpression(l) ? (e._exportsObject = l, l.properties.forEach((a) => {
683
+ let p = w(a);
684
+ if (p) {
685
+ let d = a.value;
686
+ n.isIdentifier(d) && (d = N(
687
+ d.name,
696
688
  t
697
- )), e._exports[f] = m;
689
+ )), e._exports[p] = d;
698
690
  }
699
- })) : J.warn(
700
- Q({
691
+ })) : H.warn(
692
+ Y({
701
693
  expectedType: "ObjectExpression",
702
- foundType: a?.type,
703
- node: a
694
+ foundType: l?.type,
695
+ node: l
704
696
  })
705
697
  );
706
698
  }
@@ -708,7 +700,7 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
708
700
  }
709
701
  },
710
702
  CallExpression: {
711
- enter: /* @__PURE__ */ p(({ node: i }) => {
703
+ enter: /* @__PURE__ */ f(({ node: i }) => {
712
704
  n.isIdentifier(i.callee) && i.callee.name === "definePreview" && i.arguments.length === 1 && n.isObjectExpression(i.arguments[0]) &&
713
705
  e._parseExportsObject(i.arguments[0]);
714
706
  }, "enter")
@@ -718,17 +710,17 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
718
710
  getFieldNode(e) {
719
711
  let [i, ...t] = e, r = this._exports[i];
720
712
  if (r)
721
- return ye(t, r);
713
+ return be(t, r);
722
714
  }
723
715
  getFieldProperties(e) {
724
716
  let [i, ...t] = e, r = this._exports[i];
725
717
  if (r)
726
- return be(t, r);
718
+ return Ee(t, r);
727
719
  }
728
720
  getFieldValue(e) {
729
721
  let i = this.getFieldNode(e);
730
722
  if (i) {
731
- let { code: t } = me(i, {});
723
+ let { code: t } = ue(i, {});
732
724
  return (0, eval)(`(() => (${t}))()`);
733
725
  }
734
726
  }
@@ -740,13 +732,30 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
740
732
  }
741
733
  setFieldNode(e, i) {
742
734
  let [t, ...r] = e, o = this._exports[t];
743
- if (this._exportsObject)
744
- H(e, i, this._exportsObject), this._exports[e[0]] = i;
745
- else if (o && n.isObjectExpression(o) && r.length > 0)
746
- H(r, i, o);
747
- else if (o && r.length === 0 && this._exportDecls[e[0]]) {
735
+ if (this._exportsObject) {
736
+ let p = this._exportsObject.properties.find((d) => w(d) === t);
737
+ if (p && n.isIdentifier(p.value)) {
738
+ let d = z(p.value.name, this._ast.program);
739
+ if (d && n.isObjectExpression(d.init)) {
740
+ $(r, i, d.init);
741
+ return;
742
+ }
743
+ }
744
+ $(e, i, this._exportsObject), this._exports[e[0]] = i;
745
+ return;
746
+ }
747
+ if (o && n.isObjectExpression(o) && r.length > 0) {
748
+ $(r, i, o);
749
+ return;
750
+ }
751
+ let l = z(t, this._ast.program);
752
+ if (l && n.isObjectExpression(l.init)) {
753
+ $(r, i, l.init);
754
+ return;
755
+ }
756
+ if (o && r.length === 0 && this._exportDecls[e[0]]) {
748
757
  let a = this._exportDecls[e[0]];
749
- n.isVariableDeclarator(a) && (a.init = $([], i));
758
+ n.isVariableDeclarator(a) && (a.init = R([], i));
750
759
  } else {
751
760
  if (this.hasDefaultExport)
752
761
  throw new Error(
@@ -755,10 +764,10 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
755
764
  )}" field as the default export is not an object in this file.`
756
765
  );
757
766
  {
758
- let a = $(r, i), l = n.exportNamedDeclaration(
767
+ let a = R(r, i), p = n.exportNamedDeclaration(
759
768
  n.variableDeclaration("const", [n.variableDeclarator(n.identifier(t), a)])
760
769
  );
761
- this._exports[t] = a, this._ast.program.body.push(l);
770
+ this._exports[t] = a, this._ast.program.body.push(p);
762
771
  }
763
772
  }
764
773
  }
@@ -825,31 +834,31 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
825
834
  return t;
826
835
  }
827
836
  removeField(e) {
828
- let i = /* @__PURE__ */ p((r, o) => {
829
- let a = r.findIndex(
830
- (l) => n.isIdentifier(l.key) && l.key.name === o || n.isStringLiteral(l.key) && l.key.value === o
837
+ let i = /* @__PURE__ */ f((r, o) => {
838
+ let l = r.findIndex(
839
+ (a) => n.isIdentifier(a.key) && a.key.name === o || n.isStringLiteral(a.key) && a.key.value === o
831
840
  );
832
- a >= 0 && r.splice(a, 1);
841
+ l >= 0 && r.splice(l, 1);
833
842
  }, "removeProperty");
834
843
  if (e.length === 1) {
835
844
  let r = !1;
836
845
  if (this._ast.program.body.forEach((o) => {
837
846
  if (n.isExportNamedDeclaration(o) && n.isVariableDeclaration(o.declaration)) {
838
- let a = o.declaration.declarations[0];
839
- n.isIdentifier(a.id) && a.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), r = !0);
847
+ let l = o.declaration.declarations[0];
848
+ n.isIdentifier(l.id) && l.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), r = !0);
840
849
  }
841
850
  if (n.isExportDefaultDeclaration(o)) {
842
- let a = o.declaration;
843
- if (n.isIdentifier(a) && (a = v(a.name, this._ast.program)), a = W(a), n.isObjectExpression(a)) {
844
- let l = a.properties;
845
- i(l, e[0]), r = !0;
851
+ let l = o.declaration;
852
+ if (n.isIdentifier(l) && (l = N(l.name, this._ast.program)), l = G(l), n.isObjectExpression(l)) {
853
+ let a = l.properties;
854
+ i(a, e[0]), r = !0;
846
855
  }
847
856
  }
848
857
  if (n.isExpressionStatement(o) && n.isAssignmentExpression(o.expression) && n.isMemberExpression(o.expression.left) && n.isIdentifier(
849
858
  o.expression.left.object) && o.expression.left.object.name === "module" && n.isIdentifier(o.expression.left.property) && o.expression.
850
859
  left.property.name === "exports" && n.isObjectExpression(o.expression.right)) {
851
- let a = o.expression.right.properties;
852
- i(a, e[0]), r = !0;
860
+ let l = o.expression.right.properties;
861
+ i(l, e[0]), r = !0;
853
862
  }
854
863
  }), r)
855
864
  return;
@@ -903,12 +912,12 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
903
912
  valueToNode(e) {
904
913
  let i = this._inferQuotes(), t;
905
914
  if (i === "single") {
906
- let { code: r } = me(n.valueToNode(e), { jsescOption: { quotes: i } }), o = ge(`const __x = ${r}`);
907
- ue(o, {
915
+ let { code: r } = ue(n.valueToNode(e), { jsescOption: { quotes: i } }), o = xe(`const __x = ${r}`);
916
+ ge(o, {
908
917
  VariableDeclaration: {
909
- enter({ node: a }) {
910
- a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.isIdentifier(a.declarations[0].id) && a.declarations[0].
911
- id.name === "__x" && (t = a.declarations[0].init);
918
+ enter({ node: l }) {
919
+ l.declarations.length === 1 && n.isVariableDeclarator(l.declarations[0]) && n.isIdentifier(l.declarations[0].id) && l.declarations[0].
920
+ id.name === "__x" && (t = l.declarations[0].init);
912
921
  }
913
922
  }
914
923
  });
@@ -947,15 +956,15 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
947
956
  */
948
957
  setRequireImport(e, i) {
949
958
  let t = this._ast.program.body.find(
950
- (a) => n.isVariableDeclaration(a) && a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.isCallExpression(a.
951
- declarations[0].init) && n.isIdentifier(a.declarations[0].init.callee) && a.declarations[0].init.callee.name === "require" && n.isStringLiteral(
952
- a.declarations[0].init.arguments[0]) && a.declarations[0].init.arguments[0].value === i
953
- ), r = /* @__PURE__ */ p((a) => n.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
954
- (l) => n.isObjectProperty(l) && n.isIdentifier(l.key) && l.key.name === a
955
- ), "hasRequireSpecifier"), o = /* @__PURE__ */ p((a, l) => a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.
956
- isIdentifier(a.declarations[0].id) && a.declarations[0].id.name === l, "hasDefaultRequireSpecifier");
959
+ (l) => n.isVariableDeclaration(l) && l.declarations.length === 1 && n.isVariableDeclarator(l.declarations[0]) && n.isCallExpression(l.
960
+ declarations[0].init) && n.isIdentifier(l.declarations[0].init.callee) && l.declarations[0].init.callee.name === "require" && n.isStringLiteral(
961
+ l.declarations[0].init.arguments[0]) && l.declarations[0].init.arguments[0].value === i
962
+ ), r = /* @__PURE__ */ f((l) => n.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
963
+ (a) => n.isObjectProperty(a) && n.isIdentifier(a.key) && a.key.name === l
964
+ ), "hasRequireSpecifier"), o = /* @__PURE__ */ f((l, a) => l.declarations.length === 1 && n.isVariableDeclarator(l.declarations[0]) && n.
965
+ isIdentifier(l.declarations[0].id) && l.declarations[0].id.name === a, "hasDefaultRequireSpecifier");
957
966
  if (typeof e == "string") {
958
- let a = /* @__PURE__ */ p(() => {
967
+ let l = /* @__PURE__ */ f(() => {
959
968
  this._ast.program.body.unshift(
960
969
  n.variableDeclaration("const", [
961
970
  n.variableDeclarator(
@@ -965,17 +974,17 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
965
974
  ])
966
975
  );
967
976
  }, "addDefaultRequireSpecifier");
968
- t && o(t, e) || a();
969
- } else t ? e.forEach((a) => {
970
- r(a) || t.declarations[0].id.properties.push(
971
- n.objectProperty(n.identifier(a), n.identifier(a), void 0, !0)
977
+ t && o(t, e) || l();
978
+ } else t ? e.forEach((l) => {
979
+ r(l) || t.declarations[0].id.properties.push(
980
+ n.objectProperty(n.identifier(l), n.identifier(l), void 0, !0)
972
981
  );
973
982
  }) : this._ast.program.body.unshift(
974
983
  n.variableDeclaration("const", [
975
984
  n.variableDeclarator(
976
985
  n.objectPattern(
977
986
  e.map(
978
- (a) => n.objectProperty(n.identifier(a), n.identifier(a), void 0, !0)
987
+ (l) => n.objectProperty(n.identifier(l), n.identifier(l), void 0, !0)
979
988
  )
980
989
  ),
981
990
  n.callExpression(n.identifier("require"), [n.stringLiteral(i)])
@@ -1009,17 +1018,17 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
1009
1018
  * @param fromImport - The module to import from
1010
1019
  */
1011
1020
  setImport(e, i) {
1012
- let t = /* @__PURE__ */ p((f) => n.importSpecifier(n.identifier(f), n.identifier(f)), "getNewImportSpecifier"), r = /* @__PURE__ */ p((f, m) => f.
1021
+ let t = /* @__PURE__ */ f((p) => n.importSpecifier(n.identifier(p), n.identifier(p)), "getNewImportSpecifier"), r = /* @__PURE__ */ f((p, d) => p.
1013
1022
  specifiers.find(
1014
- (g) => n.isImportSpecifier(g) && n.isIdentifier(g.imported) && g.imported.name === m
1015
- ), "hasImportSpecifier"), o = /* @__PURE__ */ p((f, m) => f.specifiers.find(
1016
- (g) => n.isImportNamespaceSpecifier(g) && n.isIdentifier(g.local) && g.local.name === m
1017
- ), "hasNamespaceImportSpecifier"), a = /* @__PURE__ */ p((f, m) => f.specifiers.find(
1018
- (g) => n.isImportDefaultSpecifier(g) && n.isIdentifier(g.local) && g.local.name === m
1019
- ), "hasDefaultImportSpecifier"), l = this._ast.program.body.find(
1020
- (f) => n.isImportDeclaration(f) && f.source.value === i
1023
+ (g) => n.isImportSpecifier(g) && n.isIdentifier(g.imported) && g.imported.name === d
1024
+ ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1025
+ (g) => n.isImportNamespaceSpecifier(g) && n.isIdentifier(g.local) && g.local.name === d
1026
+ ), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1027
+ (g) => n.isImportDefaultSpecifier(g) && n.isIdentifier(g.local) && g.local.name === d
1028
+ ), "hasDefaultImportSpecifier"), a = this._ast.program.body.find(
1029
+ (p) => n.isImportDeclaration(p) && p.source.value === i
1021
1030
  );
1022
- e === null ? l || this._ast.program.body.unshift(n.importDeclaration([], n.stringLiteral(i))) : typeof e == "string" ? l ? a(l, e) || l.
1031
+ e === null ? a || this._ast.program.body.unshift(n.importDeclaration([], n.stringLiteral(i))) : typeof e == "string" ? a ? l(a, e) || a.
1023
1032
  specifiers.push(
1024
1033
  n.importDefaultSpecifier(n.identifier(e))
1025
1034
  ) : this._ast.program.body.unshift(
@@ -1027,14 +1036,14 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
1027
1036
  [n.importDefaultSpecifier(n.identifier(e))],
1028
1037
  n.stringLiteral(i)
1029
1038
  )
1030
- ) : Array.isArray(e) ? l ? e.forEach((f) => {
1031
- r(l, f) || l.specifiers.push(t(f));
1039
+ ) : Array.isArray(e) ? a ? e.forEach((p) => {
1040
+ r(a, p) || a.specifiers.push(t(p));
1032
1041
  }) : this._ast.program.body.unshift(
1033
1042
  n.importDeclaration(
1034
1043
  e.map(t),
1035
1044
  n.stringLiteral(i)
1036
1045
  )
1037
- ) : e.namespace && (l ? o(l, e.namespace) || l.specifiers.push(
1046
+ ) : e.namespace && (a ? o(a, e.namespace) || a.specifiers.push(
1038
1047
  n.importNamespaceSpecifier(n.identifier(e.namespace))
1039
1048
  ) : this._ast.program.body.unshift(
1040
1049
  n.importDeclaration(
@@ -1043,42 +1052,42 @@ null, "propKey"), W = /* @__PURE__ */ p((s) => n.isTSAsExpression(s) || n.isTSSa
1043
1052
  )
1044
1053
  ));
1045
1054
  }
1046
- }, nt = /* @__PURE__ */ p((s, e) => {
1047
- let i = ge(s);
1048
- return new Y(i, s, e);
1049
- }, "loadConfig"), ot = /* @__PURE__ */ p((s) => at(s).code, "formatConfig"), at = /* @__PURE__ */ p((s, e = {}) => st.print(s._ast, e), "pri\
1050
- ntConfig"), $t = /* @__PURE__ */ p(async (s) => {
1055
+ }, nt = /* @__PURE__ */ f((s, e) => {
1056
+ let i = xe(s);
1057
+ return new Z(i, s, e);
1058
+ }, "loadConfig"), ot = /* @__PURE__ */ f((s) => at(s).code, "formatConfig"), at = /* @__PURE__ */ f((s, e = {}) => st.print(s._ast, e), "pri\
1059
+ ntConfig"), $t = /* @__PURE__ */ f(async (s) => {
1051
1060
  let e = (await rt(s, "utf-8")).toString();
1052
1061
  return nt(e, s).parse();
1053
- }, "readConfig"), Rt = /* @__PURE__ */ p(async (s, e) => {
1062
+ }, "readConfig"), Rt = /* @__PURE__ */ f(async (s, e) => {
1054
1063
  let i = e || s.fileName;
1055
1064
  if (!i)
1056
1065
  throw new Error("Please specify a fileName for writeConfig");
1057
1066
  await it(i, ot(s));
1058
- }, "writeConfig"), Lt = /* @__PURE__ */ p((s) => !!s._ast.program.body.find((i) => n.isImportDeclaration(i) && i.source.value.includes("@sto\
1067
+ }, "writeConfig"), Lt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((i) => n.isImportDeclaration(i) && i.source.value.includes("@sto\
1059
1068
  rybook") && i.specifiers.some((t) => n.isImportSpecifier(t) && n.isIdentifier(t.imported) && t.imported.name === "definePreview")), "isCsfFa\
1060
1069
  ctoryPreview");
1061
1070
 
1062
1071
  // src/csf-tools/getStorySortParameter.ts
1063
- var je = M(k(), 1);
1072
+ var je = U(V(), 1);
1064
1073
  import { babelParse as lt, generate as he, types as E, traverse as ct } from "storybook/internal/babel";
1065
- var pt = console, Z = /* @__PURE__ */ p((s, e) => {
1074
+ var pt = console, ee = /* @__PURE__ */ f((s, e) => {
1066
1075
  let i;
1067
1076
  return s.properties.forEach((t) => {
1068
1077
  E.isIdentifier(t.key) && t.key.name === e && (i = t.value);
1069
1078
  }), i;
1070
- }, "getValue"), ee = /* @__PURE__ */ p((s) => {
1071
- let e = R(s);
1079
+ }, "getValue"), te = /* @__PURE__ */ f((s) => {
1080
+ let e = L(s);
1072
1081
  if (E.isArrayExpression(e))
1073
- return e.elements.map((i) => ee(i));
1082
+ return e.elements.map((i) => te(i));
1074
1083
  if (E.isObjectExpression(e))
1075
- return e.properties.reduce((i, t) => (E.isIdentifier(t.key) && (i[t.key.name] = ee(t.value)), i), {});
1084
+ return e.properties.reduce((i, t) => (E.isIdentifier(t.key) && (i[t.key.name] = te(t.value)), i), {});
1076
1085
  if (E.isLiteral(e))
1077
1086
  return e.value;
1078
1087
  if (E.isIdentifier(e))
1079
- return w(e.name, !0);
1088
+ return F(e.name, !0);
1080
1089
  throw new Error(`Unknown node type ${e.type}`);
1081
- }, "parseValue"), w = /* @__PURE__ */ p((s, e) => {
1090
+ }, "parseValue"), F = /* @__PURE__ */ f((s, e) => {
1082
1091
  let i = je.dedent`
1083
1092
  Unexpected '${s}'. Parameter 'options.storySort' should be defined inline e.g.:
1084
1093
 
@@ -1093,26 +1102,26 @@ var pt = console, Z = /* @__PURE__ */ p((s, e) => {
1093
1102
  if (e)
1094
1103
  throw new Error(i);
1095
1104
  pt.info(i);
1096
- }, "unsupported"), R = /* @__PURE__ */ p((s) => E.isTSAsExpression(s) || E.isTSSatisfiesExpression(s) ? s.expression : s, "stripTSModifiers"),
1097
- Se = /* @__PURE__ */ p((s) => {
1098
- let e = R(s);
1105
+ }, "unsupported"), L = /* @__PURE__ */ f((s) => E.isTSAsExpression(s) || E.isTSSatisfiesExpression(s) ? s.expression : s, "stripTSModifiers"),
1106
+ Se = /* @__PURE__ */ f((s) => {
1107
+ let e = L(s);
1099
1108
  if (E.isObjectExpression(e)) {
1100
- let i = Z(e, "options");
1109
+ let i = ee(e, "options");
1101
1110
  if (i) {
1102
1111
  if (E.isObjectExpression(i))
1103
- return Z(i, "storySort");
1104
- w("options", !0);
1112
+ return ee(i, "storySort");
1113
+ F("options", !0);
1105
1114
  }
1106
1115
  }
1107
- }, "parseParameters"), _e = /* @__PURE__ */ p((s, e) => {
1108
- let i = R(s);
1116
+ }, "parseParameters"), _e = /* @__PURE__ */ f((s, e) => {
1117
+ let i = L(s);
1109
1118
  if (E.isObjectExpression(i)) {
1110
- let t = Z(i, "parameters");
1111
- if (E.isIdentifier(t) && (t = P(t.name, e)), t)
1119
+ let t = ee(i, "parameters");
1120
+ if (E.isIdentifier(t) && (t = O(t.name, e)), t)
1112
1121
  return Se(t);
1113
1122
  } else
1114
- w("default", !0);
1115
- }, "parseDefault"), Wt = /* @__PURE__ */ p((s) => {
1123
+ F("default", !0);
1124
+ }, "parseDefault"), Wt = /* @__PURE__ */ f((s) => {
1116
1125
  if (!s.includes("storySort"))
1117
1126
  return;
1118
1127
  let e, i = lt(s);
@@ -1123,20 +1132,20 @@ Se = /* @__PURE__ */ p((s) => {
1123
1132
  if (E.isVariableDeclarator(r) && E.isIdentifier(r.id)) {
1124
1133
  let { name: o } = r.id;
1125
1134
  if (o === "parameters" && r.init) {
1126
- let a = R(r.init);
1127
- e = Se(a);
1135
+ let l = L(r.init);
1136
+ e = Se(l);
1128
1137
  }
1129
1138
  }
1130
1139
  }) : t.specifiers.forEach((r) => {
1131
- E.isIdentifier(r.exported) && r.exported.name === "parameters" && w("parameters", !1);
1140
+ E.isIdentifier(r.exported) && r.exported.name === "parameters" && F("parameters", !1);
1132
1141
  });
1133
1142
  }
1134
1143
  },
1135
1144
  ExportDefaultDeclaration: {
1136
1145
  enter({ node: t }) {
1137
1146
  let r = t.declaration;
1138
- E.isIdentifier(r) && (r = P(r.name, i.program)), r = R(r), E.isCallExpression(r) && E.isObjectExpression(r.arguments?.[0]) ? e = _e(
1139
- r.arguments[0], i.program) : E.isObjectExpression(r) ? e = _e(r, i.program) : w("default", !1);
1147
+ E.isIdentifier(r) && (r = O(r.name, i.program)), r = L(r), E.isCallExpression(r) && E.isObjectExpression(r.arguments?.[0]) ? e = _e(
1148
+ r.arguments[0], i.program) : E.isObjectExpression(r) ? e = _e(r, i.program) : F("default", !1);
1140
1149
  }
1141
1150
  }
1142
1151
  }), !!e) {
@@ -1151,24 +1160,24 @@ Se = /* @__PURE__ */ p((s) => {
1151
1160
  }`;
1152
1161
  return (0, eval)(o);
1153
1162
  }
1154
- return E.isLiteral(e) || E.isArrayExpression(e) || E.isObjectExpression(e) ? ee(e) : w("storySort", !0);
1163
+ return E.isLiteral(e) || E.isArrayExpression(e) || E.isObjectExpression(e) ? te(e) : F("storySort", !0);
1155
1164
  }
1156
1165
  }, "getStorySortParameter");
1157
1166
 
1158
1167
  // src/csf-tools/enrichCsf.ts
1159
1168
  import { generate as ft, types as u } from "storybook/internal/babel";
1160
- var dt = /* @__PURE__ */ p((s, e, i, t) => {
1169
+ var dt = /* @__PURE__ */ f((s, e, i, t) => {
1161
1170
  let r = e.getStoryExport(i), o = u.isCallExpression(r) && u.isMemberExpression(r.callee) && u.isIdentifier(r.callee.object) && r.callee.object.
1162
- name === "meta", a = !t?.disableSource && ut(r), l = !t?.disableDescription && Oe(e._storyStatements[i]), f = [], m = o ? u.memberExpression(
1163
- u.identifier(i), u.identifier("input")) : u.identifier(i), g = u.memberExpression(m, u.identifier("parameters"));
1164
- f.push(u.spreadElement(g));
1171
+ name === "meta", l = !t?.disableSource && ut(r), a = !t?.disableDescription && Pe(e._storyStatements[i]), p = [], d = o ? u.memberExpression(
1172
+ u.identifier(i), u.identifier("input")) : u.identifier(i), g = u.memberExpression(d, u.identifier("parameters"));
1173
+ p.push(u.spreadElement(g));
1165
1174
  let x = u.optionalMemberExpression(
1166
1175
  g,
1167
1176
  u.identifier("docs"),
1168
1177
  !1,
1169
1178
  !0
1170
1179
  ), b = [];
1171
- if (a) {
1180
+ if (l) {
1172
1181
  let y = u.optionalMemberExpression(
1173
1182
  x,
1174
1183
  u.identifier("source"),
@@ -1179,13 +1188,13 @@ var dt = /* @__PURE__ */ p((s, e, i, t) => {
1179
1188
  u.objectProperty(
1180
1189
  u.identifier("source"),
1181
1190
  u.objectExpression([
1182
- u.objectProperty(u.identifier("originalSource"), u.stringLiteral(a)),
1191
+ u.objectProperty(u.identifier("originalSource"), u.stringLiteral(l)),
1183
1192
  u.spreadElement(y)
1184
1193
  ])
1185
1194
  )
1186
1195
  );
1187
1196
  }
1188
- if (l) {
1197
+ if (a) {
1189
1198
  let y = u.optionalMemberExpression(
1190
1199
  x,
1191
1200
  u.identifier("description"),
@@ -1196,53 +1205,53 @@ var dt = /* @__PURE__ */ p((s, e, i, t) => {
1196
1205
  u.objectProperty(
1197
1206
  u.identifier("description"),
1198
1207
  u.objectExpression([
1199
- u.objectProperty(u.identifier("story"), u.stringLiteral(l)),
1208
+ u.objectProperty(u.identifier("story"), u.stringLiteral(a)),
1200
1209
  u.spreadElement(y)
1201
1210
  ])
1202
1211
  )
1203
1212
  );
1204
1213
  }
1205
1214
  if (b.length > 0) {
1206
- f.push(
1215
+ p.push(
1207
1216
  u.objectProperty(
1208
1217
  u.identifier("docs"),
1209
1218
  u.objectExpression([u.spreadElement(x), ...b])
1210
1219
  )
1211
1220
  );
1212
1221
  let y = u.expressionStatement(
1213
- u.assignmentExpression("=", g, u.objectExpression(f))
1222
+ u.assignmentExpression("=", g, u.objectExpression(p))
1214
1223
  );
1215
1224
  s._ast.program.body.push(y);
1216
1225
  }
1217
- }, "enrichCsfStory"), Pe = /* @__PURE__ */ p((s, e, i) => {
1226
+ }, "enrichCsfStory"), Oe = /* @__PURE__ */ f((s, e, i) => {
1218
1227
  if (!e.length) {
1219
1228
  s.properties.find(
1220
- (f) => u.isObjectProperty(f) && u.isIdentifier(f.key) && f.key.name === "component"
1229
+ (p) => u.isObjectProperty(p) && u.isIdentifier(p.key) && p.key.name === "component"
1221
1230
  ) || s.properties.unshift(i);
1222
1231
  return;
1223
1232
  }
1224
1233
  let [t, ...r] = e, o = s.properties.find(
1225
- (l) => u.isObjectProperty(l) && u.isIdentifier(l.key) && l.key.name === t && u.isObjectExpression(l.value)
1226
- ), a;
1227
- o ? a = o.value : (a = u.objectExpression([]), s.properties.push(u.objectProperty(u.identifier(t), a))), Pe(a, r, i);
1228
- }, "addComponentDescription"), mt = /* @__PURE__ */ p((s, e, i) => {
1229
- let t = !i?.disableDescription && Oe(e._metaStatement);
1234
+ (a) => u.isObjectProperty(a) && u.isIdentifier(a.key) && a.key.name === t && u.isObjectExpression(a.value)
1235
+ ), l;
1236
+ o ? l = o.value : (l = u.objectExpression([]), s.properties.push(u.objectProperty(u.identifier(t), l))), Oe(l, r, i);
1237
+ }, "addComponentDescription"), mt = /* @__PURE__ */ f((s, e, i) => {
1238
+ let t = !i?.disableDescription && Pe(e._metaStatement);
1230
1239
  if (t) {
1231
1240
  let r = s._metaNode;
1232
- r && u.isObjectExpression(r) && Pe(
1241
+ r && u.isObjectExpression(r) && Oe(
1233
1242
  r,
1234
1243
  ["parameters", "docs", "description"],
1235
1244
  u.objectProperty(u.identifier("component"), u.stringLiteral(t))
1236
1245
  );
1237
1246
  }
1238
- }, "enrichCsfMeta"), Kt = /* @__PURE__ */ p((s, e, i) => {
1247
+ }, "enrichCsfMeta"), Kt = /* @__PURE__ */ f((s, e, i) => {
1239
1248
  mt(s, e, i), Object.keys(s._storyExports).forEach((t) => {
1240
1249
  dt(s, e, t, i);
1241
1250
  });
1242
- }, "enrichCsf"), ut = /* @__PURE__ */ p((s) => {
1251
+ }, "enrichCsf"), ut = /* @__PURE__ */ f((s) => {
1243
1252
  let e = u.isVariableDeclarator(s) ? s.init : s, { code: i } = ft(e, {});
1244
1253
  return i;
1245
- }, "extractSource"), Oe = /* @__PURE__ */ p((s) => s?.leadingComments ? s.leadingComments.map((i) => i.type === "CommentLine" || !i.value.startsWith(
1254
+ }, "extractSource"), Pe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((i) => i.type === "CommentLine" || !i.value.startsWith(
1246
1255
  "*") ? null : i.value.split(`
1247
1256
  `).map((t) => t.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
1248
1257
  `).trim()).filter(Boolean).join(`
@@ -1252,11 +1261,11 @@ var dt = /* @__PURE__ */ p((s, e, i, t) => {
1252
1261
  import { babelParse as cr } from "storybook/internal/babel";
1253
1262
 
1254
1263
  // src/csf-tools/vitest-plugin/transformer.ts
1255
- var te = M(k(), 1);
1256
- import { types as d } from "storybook/internal/babel";
1264
+ var re = U(V(), 1);
1265
+ import { types as m } from "storybook/internal/babel";
1257
1266
  import { getStoryTitle as gt } from "storybook/internal/common";
1258
1267
  import { combineTags as xt } from "storybook/internal/csf";
1259
- var Ie = console, yt = /* @__PURE__ */ p((s, e) => !(e.include.length && !e.include.some((i) => s?.includes(i)) || e.exclude.some((i) => s?.
1268
+ var Ie = console, yt = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((i) => s?.includes(i)) || e.exclude.some((i) => s?.
1260
1269
  includes(i))), "isValidTest");
1261
1270
  async function bt({
1262
1271
  code: s,
@@ -1268,10 +1277,10 @@ async function bt({
1268
1277
  }) {
1269
1278
  if (!/\.stor(y|ies)\./.test(e))
1270
1279
  return s;
1271
- let l = K(s, {
1280
+ let a = Q(s, {
1272
1281
  fileName: e,
1273
1282
  transformInlineMeta: !0,
1274
- makeTitle: /* @__PURE__ */ p((_) => {
1283
+ makeTitle: /* @__PURE__ */ f((_) => {
1275
1284
  let S = gt({
1276
1285
  storyFilePath: e,
1277
1286
  configDir: i,
@@ -1279,16 +1288,16 @@ async function bt({
1279
1288
  userTitle: _
1280
1289
  }) || "unknown";
1281
1290
  return S === "unknown" && Ie.warn(
1282
- te.dedent`
1291
+ re.dedent`
1283
1292
  [Storybook]: Could not calculate story title for "${e}".
1284
1293
  Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${i}".
1285
1294
  `
1286
1295
  ), S;
1287
1296
  }, "makeTitle")
1288
- }).parse(), f = l._ast, m = l._metaVariableName, g = l._metaNode, x = g.properties.find(
1289
- (_) => d.isObjectProperty(_) && d.isIdentifier(_.key) && _.key.name === "title"
1290
- ), b = d.stringLiteral(l._meta?.title || "unknown");
1291
- if (x ? d.isObjectProperty(x) && (x.value = b) : g.properties.push(d.objectProperty(d.identifier("title"), b)), !g || !l._meta)
1297
+ }).parse(), p = a._ast, d = a._metaVariableName, g = a._metaNode, x = g.properties.find(
1298
+ (_) => m.isObjectProperty(_) && m.isIdentifier(_.key) && _.key.name === "title"
1299
+ ), b = m.stringLiteral(a._meta?.title || "unknown");
1300
+ if (x ? m.isObjectProperty(x) && (x.value = b) : g.properties.push(m.objectProperty(m.identifier("title"), b)), !g || !a._meta)
1292
1301
  throw new Error(
1293
1302
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
1294
1303
 
@@ -1296,139 +1305,139 @@ Please make sure you have a default export with the meta object. If you are usin
1296
1305
  le an issue with details about your use case.`
1297
1306
  );
1298
1307
  let y = {};
1299
- Object.keys(l._stories).map((_) => {
1308
+ Object.keys(a._stories).map((_) => {
1300
1309
  let S = xt(
1301
1310
  "test",
1302
1311
  "dev",
1303
1312
  ...o,
1304
- ...l.meta?.tags || [],
1305
- ...l._stories[_].tags || []
1313
+ ...a.meta?.tags || [],
1314
+ ...a._stories[_].tags || []
1306
1315
  );
1307
- yt(S, r) && (y[_] = l._storyStatements[_]);
1316
+ yt(S, r) && (y[_] = a._storyStatements[_]);
1308
1317
  });
1309
- let h = l._file.path.scope.generateUidIdentifier("test"), D = l._file.path.scope.generateUidIdentifier("describe");
1318
+ let h = a._file.path.scope.generateUidIdentifier("test"), D = a._file.path.scope.generateUidIdentifier("describe");
1310
1319
  if (Object.keys(y).length === 0) {
1311
- let _ = d.expressionStatement(
1312
- d.callExpression(d.memberExpression(D, d.identifier("skip")), [
1313
- d.stringLiteral("No valid tests found")
1320
+ let _ = m.expressionStatement(
1321
+ m.callExpression(m.memberExpression(D, m.identifier("skip")), [
1322
+ m.stringLiteral("No valid tests found")
1314
1323
  ])
1315
1324
  );
1316
- f.program.body.push(_);
1325
+ p.program.body.push(_);
1317
1326
  let S = [
1318
- d.importDeclaration(
1327
+ m.importDeclaration(
1319
1328
  [
1320
- d.importSpecifier(h, d.identifier("test")),
1321
- d.importSpecifier(D, d.identifier("describe"))
1329
+ m.importSpecifier(h, m.identifier("test")),
1330
+ m.importSpecifier(D, m.identifier("describe"))
1322
1331
  ],
1323
- d.stringLiteral("vitest")
1332
+ m.stringLiteral("vitest")
1324
1333
  )
1325
1334
  ];
1326
- f.program.body.unshift(...S);
1335
+ p.program.body.unshift(...S);
1327
1336
  } else {
1328
- let re = function() {
1329
- let j = l._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = d.memberExpression(
1330
- d.callExpression(d.memberExpression(_, d.identifier("getState")), []),
1331
- d.identifier("testPath")
1332
- ), F = d.memberExpression(
1333
- d.memberExpression(d.identifier("globalThis"), d.identifier("__vitest_worker__")),
1334
- d.identifier("filepath")
1335
- ), C = d.logicalExpression(
1337
+ let ie = function() {
1338
+ let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), v = m.memberExpression(
1339
+ m.callExpression(m.memberExpression(_, m.identifier("getState")), []),
1340
+ m.identifier("testPath")
1341
+ ), C = m.memberExpression(
1342
+ m.memberExpression(m.identifier("globalThis"), m.identifier("__vitest_worker__")),
1343
+ m.identifier("filepath")
1344
+ ), T = m.logicalExpression(
1336
1345
  "??",
1337
1346
  // TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
1338
1347
  // https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
1339
- F,
1340
- N
1341
- ), L = d.callExpression(
1342
- d.memberExpression(
1343
- d.memberExpression(
1344
- d.memberExpression(d.identifier("import"), d.identifier("meta")),
1345
- d.identifier("url")
1348
+ C,
1349
+ v
1350
+ ), M = m.callExpression(
1351
+ m.memberExpression(
1352
+ m.memberExpression(
1353
+ m.memberExpression(m.identifier("import"), m.identifier("meta")),
1354
+ m.identifier("url")
1346
1355
  ),
1347
- d.identifier("includes")
1356
+ m.identifier("includes")
1348
1357
  ),
1349
- [C]
1358
+ [T]
1350
1359
  );
1351
- return { isRunningFromThisFileDeclaration: d.variableDeclaration("const", [
1352
- d.variableDeclarator(j, L)
1360
+ return { isRunningFromThisFileDeclaration: m.variableDeclaration("const", [
1361
+ m.variableDeclarator(j, M)
1353
1362
  ]), isRunningFromThisFileId: j };
1354
1363
  };
1355
- var Et = re;
1356
- p(re, "getTestGuardDeclaration");
1357
- let _ = l._file.path.scope.generateUidIdentifier("expect"), S = l._file.path.scope.generateUidIdentifier("testStory"), De = d.identifier(
1358
- JSON.stringify(r.skip)), { isRunningFromThisFileDeclaration: Ne, isRunningFromThisFileId: ve } = re();
1359
- f.program.body.push(Ne);
1360
- let we = /* @__PURE__ */ p(({
1364
+ var Et = ie;
1365
+ f(ie, "getTestGuardDeclaration");
1366
+ let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), De = m.identifier(
1367
+ JSON.stringify(r.skip)), { isRunningFromThisFileDeclaration: ve, isRunningFromThisFileId: Ne } = ie();
1368
+ p.program.body.push(ve);
1369
+ let we = /* @__PURE__ */ f(({
1361
1370
  localName: j,
1362
- exportName: N,
1363
- testTitle: F,
1364
- node: C
1371
+ exportName: v,
1372
+ testTitle: C,
1373
+ node: T
1365
1374
  }) => {
1366
- let L = d.expressionStatement(
1367
- d.callExpression(h, [
1368
- d.stringLiteral(F),
1369
- d.callExpression(S, [
1370
- d.stringLiteral(N),
1371
- d.identifier(j),
1372
- d.identifier(m),
1375
+ let M = m.expressionStatement(
1376
+ m.callExpression(h, [
1377
+ m.stringLiteral(C),
1378
+ m.callExpression(S, [
1379
+ m.stringLiteral(v),
1380
+ m.identifier(j),
1381
+ m.identifier(d),
1373
1382
  De
1374
1383
  ])
1375
1384
  ])
1376
1385
  );
1377
- return L.loc = C.loc, L;
1378
- }, "getTestStatementForStory"), Fe = Object.entries(y).map(([j, N]) => {
1379
- if (N === null) {
1386
+ return M.loc = T.loc, M;
1387
+ }, "getTestStatementForStory"), Fe = Object.entries(y).map(([j, v]) => {
1388
+ if (v === null) {
1380
1389
  Ie.warn(
1381
- te.dedent`
1390
+ re.dedent`
1382
1391
  [Storybook]: Could not transform "${j}" story into test at "${e}".
1383
1392
  Please make sure to define stories in the same file and not re-export stories coming from other files".
1384
1393
  `
1385
1394
  );
1386
1395
  return;
1387
1396
  }
1388
- let F = l._stories[j].localName ?? j, C = l._stories[j].name ?? j;
1389
- return we({ testTitle: C, localName: F, exportName: j, node: N });
1390
- }).filter((j) => !!j), Ce = d.ifStatement(ve, d.blockStatement(Fe));
1391
- f.program.body.push(Ce);
1397
+ let C = a._stories[j].localName ?? j, T = a._stories[j].name ?? j;
1398
+ return we({ testTitle: T, localName: C, exportName: j, node: v });
1399
+ }).filter((j) => !!j), Ce = m.ifStatement(Ne, m.blockStatement(Fe));
1400
+ p.program.body.push(Ce);
1392
1401
  let Te = [
1393
- d.importDeclaration(
1402
+ m.importDeclaration(
1394
1403
  [
1395
- d.importSpecifier(h, d.identifier("test")),
1396
- d.importSpecifier(_, d.identifier("expect"))
1404
+ m.importSpecifier(h, m.identifier("test")),
1405
+ m.importSpecifier(_, m.identifier("expect"))
1397
1406
  ],
1398
- d.stringLiteral("vitest")
1407
+ m.stringLiteral("vitest")
1399
1408
  ),
1400
- d.importDeclaration(
1401
- [d.importSpecifier(S, d.identifier("testStory"))],
1402
- d.stringLiteral("@storybook/addon-test/internal/test-utils")
1409
+ m.importDeclaration(
1410
+ [m.importSpecifier(S, m.identifier("testStory"))],
1411
+ m.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1403
1412
  )
1404
1413
  ];
1405
- f.program.body.unshift(...Te);
1414
+ p.program.body.unshift(...Te);
1406
1415
  }
1407
- return de(l, { sourceMaps: !0, sourceFileName: e }, s);
1416
+ return me(a, { sourceMaps: !0, sourceFileName: e }, s);
1408
1417
  }
1409
- p(bt, "vitestTransform");
1418
+ f(bt, "vitestTransform");
1410
1419
  export {
1411
- B as BadMetaError,
1412
- Y as ConfigFile,
1413
- X as CsfFile,
1414
- q as MixedFactoryError,
1415
- z as MultipleMetaError,
1416
- U as NoMetaError,
1420
+ W as BadMetaError,
1421
+ Z as ConfigFile,
1422
+ J as CsfFile,
1423
+ B as MixedFactoryError,
1424
+ K as MultipleMetaError,
1425
+ q as NoMetaError,
1417
1426
  cr as babelParse,
1418
1427
  et as babelParseFile,
1419
1428
  Kt as enrichCsf,
1420
1429
  mt as enrichCsfMeta,
1421
1430
  dt as enrichCsfStory,
1422
- Oe as extractDescription,
1431
+ Pe as extractDescription,
1423
1432
  ut as extractSource,
1424
1433
  ot as formatConfig,
1425
- de as formatCsf,
1434
+ me as formatCsf,
1426
1435
  Wt as getStorySortParameter,
1427
1436
  Lt as isCsfFactoryPreview,
1428
1437
  Qe as isModuleMock,
1429
1438
  Ke as isValidPreviewPath,
1430
1439
  nt as loadConfig,
1431
- K as loadCsf,
1440
+ Q as loadCsf,
1432
1441
  at as printConfig,
1433
1442
  tt as printCsf,
1434
1443
  $t as readConfig,