storybook 10.1.0-alpha.10 → 10.1.0-alpha.11

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 (192) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  5. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  6. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  7. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  8. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  9. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-74YHFU5B.js} +44 -109
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/chunk-BE2DAXKJ.js +2966 -0
  15. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  16. package/dist/_browser-chunks/chunk-EBHB6RPS.js +61 -0
  17. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  18. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  19. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  20. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-QMY4G4R2.js → chunk-L4RMQ7D7.js} +17 -64
  26. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  27. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  28. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  29. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  30. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  31. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  32. package/dist/_browser-chunks/chunk-WXP2XJ3O.js +950 -0
  33. package/dist/_browser-chunks/chunk-X3DUQ5RA.js +47 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-RJZASWHL.js → syntaxhighlighter-WKBQ5RC7.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-HA7CYFCK.js → builder-manager-PMPHOSM2.js} +475 -1013
  40. package/dist/_node-chunks/camelcase-K3IOOFQW.js +18 -0
  41. package/dist/_node-chunks/{chunk-X4XU27M6.js → chunk-32NE3UE3.js} +15 -24
  42. package/dist/_node-chunks/chunk-4GZCFQFG.js +58 -0
  43. package/dist/_node-chunks/chunk-5QK5MSOI.js +943 -0
  44. package/dist/_node-chunks/{chunk-VPR5IBMG.js → chunk-6ZOLETQK.js} +8 -10
  45. package/dist/_node-chunks/chunk-7I22Y76Z.js +1047 -0
  46. package/dist/_node-chunks/chunk-AKTRSR3O.js +72 -0
  47. package/dist/_node-chunks/chunk-BBOP3XCK.js +119 -0
  48. package/dist/_node-chunks/chunk-C2GQVDWI.js +34 -0
  49. package/dist/_node-chunks/{chunk-ZHSCUGNP.js → chunk-GG2WQZSG.js} +3799 -7849
  50. package/dist/_node-chunks/chunk-GQJOWVVR.js +3214 -0
  51. package/dist/_node-chunks/chunk-JCRM2YVK.js +3009 -0
  52. package/dist/_node-chunks/chunk-KK4AT5F3.js +1029 -0
  53. package/dist/_node-chunks/chunk-L7MYXJUM.js +1114 -0
  54. package/dist/_node-chunks/{chunk-F3XOPI6H.js → chunk-LCZO45L7.js} +469 -983
  55. package/dist/_node-chunks/chunk-LR3QITDI.js +209 -0
  56. package/dist/_node-chunks/chunk-LXG4DK35.js +3171 -0
  57. package/dist/_node-chunks/chunk-MJ3WOS6F.js +37 -0
  58. package/dist/_node-chunks/chunk-PHOZWZZO.js +61 -0
  59. package/dist/_node-chunks/chunk-QECOQWRJ.js +936 -0
  60. package/dist/_node-chunks/chunk-QH4V5YDB.js +20 -0
  61. package/dist/_node-chunks/chunk-R6HWGZWD.js +26 -0
  62. package/dist/_node-chunks/chunk-SPQXMU2Q.js +759 -0
  63. package/dist/_node-chunks/chunk-TXZY6V6O.js +1564 -0
  64. package/dist/_node-chunks/chunk-UGDPX5LE.js +756 -0
  65. package/dist/_node-chunks/chunk-UY26MQLT.js +603 -0
  66. package/dist/_node-chunks/chunk-WK3EMYK6.js +61 -0
  67. package/dist/_node-chunks/{chunk-OVXB5GGT.js → chunk-WLHMN7AP.js} +292 -688
  68. package/dist/_node-chunks/chunk-XGVLB4UJ.js +54 -0
  69. package/dist/_node-chunks/{chunk-RMHAL25C.js → chunk-YHRFI6BE.js} +87 -227
  70. package/dist/_node-chunks/chunk-YK4KVMFW.js +18 -0
  71. package/dist/_node-chunks/chunk-ZZALGOA6.js +4523 -0
  72. package/dist/_node-chunks/chunk-ZZPBSYA5.js +301 -0
  73. package/dist/_node-chunks/chunk-ZZSRFAC6.js +45571 -0
  74. package/dist/_node-chunks/dist-4DWOCZUD.js +121 -0
  75. package/dist/_node-chunks/globby-AAARUKEU.js +3452 -0
  76. package/dist/_node-chunks/lib-HEUKGL62.js +366 -0
  77. package/dist/_node-chunks/mdx-N42X6CFJ-DCVRPS6N.js +14329 -0
  78. package/dist/_node-chunks/p-limit-F5ZKJ6WZ.js +116 -0
  79. package/dist/_node-chunks/plugin-7YY7JXCH.js +123 -0
  80. package/dist/_node-chunks/{plugin-6ZPCS4LI.js → plugin-SZP3CW6W.js} +36 -56
  81. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-TGKNDPO6.js +46623 -0
  82. package/dist/_node-chunks/webpack-mock-plugin-LNTZZFBE.js +92 -0
  83. package/dist/actions/decorator.js +21 -42
  84. package/dist/actions/index.js +3 -3
  85. package/dist/babel/index.d.ts +671 -335
  86. package/dist/babel/index.js +11 -11
  87. package/dist/bin/core.js +592 -1546
  88. package/dist/bin/dispatcher.js +26 -37
  89. package/dist/bin/loader.js +23 -34
  90. package/dist/channels/index.js +98 -234
  91. package/dist/cli/index.js +1951 -5308
  92. package/dist/client-logger/index.js +31 -61
  93. package/dist/common/index.js +20 -20
  94. package/dist/components/index.js +4211 -8586
  95. package/dist/core-events/index.js +2 -66
  96. package/dist/core-server/index.js +3054 -7290
  97. package/dist/core-server/presets/common-manager.css +2 -2
  98. package/dist/core-server/presets/common-manager.js +1806 -3427
  99. package/dist/core-server/presets/common-override-preset.js +31 -60
  100. package/dist/core-server/presets/common-preset.js +434 -924
  101. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +15 -19
  102. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +12 -17
  103. package/dist/csf/index.js +534 -1179
  104. package/dist/csf-tools/index.js +9 -9
  105. package/dist/docs-tools/index.js +6 -6
  106. package/dist/highlight/index.js +2 -2
  107. package/dist/instrumenter/index.js +199 -415
  108. package/dist/manager/globals-runtime.js +24150 -47364
  109. package/dist/manager/globals.js +2 -3
  110. package/dist/manager/runtime.js +3961 -8373
  111. package/dist/manager-api/index.js +1231 -2425
  112. package/dist/manager-errors.d.ts +3 -0
  113. package/dist/manager-errors.js +3 -3
  114. package/dist/node-logger/index.js +1253 -2601
  115. package/dist/preview/globals.js +2 -3
  116. package/dist/preview/runtime.js +10364 -21990
  117. package/dist/preview-api/index.d.ts +67 -68
  118. package/dist/preview-api/index.js +13 -13
  119. package/dist/preview-errors.d.ts +3 -0
  120. package/dist/preview-errors.js +4 -4
  121. package/dist/router/index.js +347 -899
  122. package/dist/server-errors.d.ts +3 -0
  123. package/dist/server-errors.js +10 -10
  124. package/dist/telemetry/index.js +24 -24
  125. package/dist/test/index.js +5860 -11645
  126. package/dist/theming/create.js +4 -4
  127. package/dist/theming/index.d.ts +3363 -2597
  128. package/dist/theming/index.js +490 -1086
  129. package/dist/types/index.js +2 -11
  130. package/dist/viewport/index.js +3 -3
  131. package/package.json +5 -5
  132. package/dist/_browser-chunks/Color-FQNEU7YS.js +0 -1695
  133. package/dist/_browser-chunks/WithTooltip-6NHN2GXF.js +0 -2343
  134. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  135. package/dist/_browser-chunks/chunk-AW46NMGV.js +0 -1308
  136. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  137. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  138. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  139. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  140. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  141. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  142. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  143. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  144. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  145. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  146. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  147. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  148. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  149. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  150. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  151. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  152. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  153. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  154. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  155. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  156. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  157. package/dist/_node-chunks/camelcase-QALD4XFE.js +0 -18
  158. package/dist/_node-chunks/chunk-2XY53ALL.js +0 -420
  159. package/dist/_node-chunks/chunk-3CBQMG2A.js +0 -6712
  160. package/dist/_node-chunks/chunk-3WDAPZYQ.js +0 -28
  161. package/dist/_node-chunks/chunk-4ZB555EJ.js +0 -697
  162. package/dist/_node-chunks/chunk-52DXKXY3.js +0 -4272
  163. package/dist/_node-chunks/chunk-5OVB4A6F.js +0 -69
  164. package/dist/_node-chunks/chunk-AGHGNXGH.js +0 -18
  165. package/dist/_node-chunks/chunk-B23X5ZCK.js +0 -1531
  166. package/dist/_node-chunks/chunk-B2DAHWJK.js +0 -220
  167. package/dist/_node-chunks/chunk-CC4PW5MJ.js +0 -34
  168. package/dist/_node-chunks/chunk-D7NIZELR.js +0 -2256
  169. package/dist/_node-chunks/chunk-DO5Q3H4L.js +0 -1250
  170. package/dist/_node-chunks/chunk-ECK7WVFX.js +0 -304
  171. package/dist/_node-chunks/chunk-EUH3NHXA.js +0 -79
  172. package/dist/_node-chunks/chunk-FOQHPHCV.js +0 -1657
  173. package/dist/_node-chunks/chunk-G6EL47NS.js +0 -111
  174. package/dist/_node-chunks/chunk-GFLS4TJB.js +0 -90
  175. package/dist/_node-chunks/chunk-J3XZKWHE.js +0 -1586
  176. package/dist/_node-chunks/chunk-LE63EHJ5.js +0 -1518
  177. package/dist/_node-chunks/chunk-M47XA42S.js +0 -4741
  178. package/dist/_node-chunks/chunk-OOI74AL3.js +0 -61
  179. package/dist/_node-chunks/chunk-PRJHT3GJ.js +0 -61
  180. package/dist/_node-chunks/chunk-Q52PVUSU.js +0 -101
  181. package/dist/_node-chunks/chunk-SDCF5RNN.js +0 -1198
  182. package/dist/_node-chunks/chunk-UJ5SJ23M.js +0 -5029
  183. package/dist/_node-chunks/chunk-UPHK4ETU.js +0 -64658
  184. package/dist/_node-chunks/chunk-V7VURIPB.js +0 -1544
  185. package/dist/_node-chunks/dist-6TXHNR5C.js +0 -175
  186. package/dist/_node-chunks/globby-PBTV6PX6.js +0 -5222
  187. package/dist/_node-chunks/lib-4RTDZVGX.js +0 -518
  188. package/dist/_node-chunks/mdx-N42X6CFJ-COWEH7KR.js +0 -22017
  189. package/dist/_node-chunks/p-limit-PBVZQOFY.js +0 -168
  190. package/dist/_node-chunks/plugin-EOZKYZAG.js +0 -159
  191. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-35HMSMR5.js +0 -69102
  192. package/dist/_node-chunks/webpack-mock-plugin-GT3MA5E2.js +0 -124
@@ -2,62 +2,57 @@ import {
2
2
  UniversalStore,
3
3
  parse,
4
4
  stringify
5
- } from "../_browser-chunks/chunk-XDGMHOV7.js";
5
+ } from "../_browser-chunks/chunk-UD6FQLAF.js";
6
6
  import {
7
7
  StatusTypeIdMismatchError
8
- } from "../_browser-chunks/chunk-6A7OIVEL.js";
8
+ } from "../_browser-chunks/chunk-X3DUQ5RA.js";
9
9
  import {
10
10
  StatusTypeIdMismatchError as StatusTypeIdMismatchError2
11
- } from "../_browser-chunks/chunk-FDWKXLBI.js";
11
+ } from "../_browser-chunks/chunk-74YHFU5B.js";
12
12
  import {
13
13
  StorybookError
14
- } from "../_browser-chunks/chunk-LASUB7TL.js";
14
+ } from "../_browser-chunks/chunk-EBHB6RPS.js";
15
15
  import {
16
16
  countBy,
17
17
  dequal,
18
18
  partition
19
- } from "../_browser-chunks/chunk-SYS437NN.js";
19
+ } from "../_browser-chunks/chunk-XJNX76GA.js";
20
20
  import {
21
21
  require_picocolors_browser
22
- } from "../_browser-chunks/chunk-VUAFL5XK.js";
22
+ } from "../_browser-chunks/chunk-EZSQOHRI.js";
23
23
  import {
24
24
  isEqual
25
- } from "../_browser-chunks/chunk-ZNRFDIVA.js";
26
- import "../_browser-chunks/chunk-AB7OOPUX.js";
25
+ } from "../_browser-chunks/chunk-3IAH5M2U.js";
26
+ import "../_browser-chunks/chunk-QKODTO7K.js";
27
27
  import {
28
28
  mapValues,
29
29
  mergeWith,
30
30
  pick,
31
31
  toMerged
32
- } from "../_browser-chunks/chunk-UTNZYD2N.js";
33
- import "../_browser-chunks/chunk-FSBVR7H5.js";
32
+ } from "../_browser-chunks/chunk-AIOS4NGK.js";
33
+ import "../_browser-chunks/chunk-GFLS4VP3.js";
34
34
  import {
35
35
  require_memoizerific
36
- } from "../_browser-chunks/chunk-NVV6MIOE.js";
36
+ } from "../_browser-chunks/chunk-WJYERY3R.js";
37
37
  import {
38
38
  dedent
39
- } from "../_browser-chunks/chunk-OPCDBBL3.js";
39
+ } from "../_browser-chunks/chunk-JP7NCOJX.js";
40
40
  import {
41
41
  __commonJS,
42
42
  __export,
43
- __name,
44
43
  __toESM
45
- } from "../_browser-chunks/chunk-MM7DTO55.js";
44
+ } from "../_browser-chunks/chunk-A242L54C.js";
46
45
 
47
46
  // ../node_modules/toggle-selection/index.js
48
47
  var require_toggle_selection = __commonJS({
49
48
  "../node_modules/toggle-selection/index.js"(exports, module) {
50
49
  module.exports = function() {
51
50
  var selection = document.getSelection();
52
- if (!selection.rangeCount) {
51
+ if (!selection.rangeCount)
53
52
  return function() {
54
53
  };
55
- }
56
- var active = document.activeElement;
57
- var ranges = [];
58
- for (var i = 0; i < selection.rangeCount; i++) {
54
+ for (var active = document.activeElement, ranges = [], i = 0; i < selection.rangeCount; i++)
59
55
  ranges.push(selection.getRangeAt(i));
60
- }
61
56
  switch (active.tagName.toUpperCase()) {
62
57
  // .toUpperCase handles XHTML
63
58
  case "INPUT":
@@ -68,15 +63,10 @@ var require_toggle_selection = __commonJS({
68
63
  active = null;
69
64
  break;
70
65
  }
71
- selection.removeAllRanges();
72
- return function() {
73
- selection.type === "Caret" && selection.removeAllRanges();
74
- if (!selection.rangeCount) {
75
- ranges.forEach(function(range) {
76
- selection.addRange(range);
77
- });
78
- }
79
- active && active.focus();
66
+ return selection.removeAllRanges(), function() {
67
+ selection.type === "Caret" && selection.removeAllRanges(), selection.rangeCount || ranges.forEach(function(range) {
68
+ selection.addRange(range);
69
+ }), active && active.focus();
80
70
  };
81
71
  };
82
72
  }
@@ -86,97 +76,45 @@ var require_toggle_selection = __commonJS({
86
76
  var require_copy_to_clipboard = __commonJS({
87
77
  "../node_modules/copy-to-clipboard/index.js"(exports, module) {
88
78
  "use strict";
89
- var deselectCurrent = require_toggle_selection();
90
- var clipboardToIE11Formatting = {
79
+ var deselectCurrent = require_toggle_selection(), clipboardToIE11Formatting = {
91
80
  "text/plain": "Text",
92
81
  "text/html": "Url",
93
- "default": "Text"
94
- };
95
- var defaultMessage = "Copy to clipboard: #{key}, Enter";
82
+ default: "Text"
83
+ }, defaultMessage = "Copy to clipboard: #{key}, Enter";
96
84
  function format(message) {
97
85
  var copyKey = (/mac os x/i.test(navigator.userAgent) ? "\u2318" : "Ctrl") + "+C";
98
86
  return message.replace(/#{\s*key\s*}/g, copyKey);
99
87
  }
100
- __name(format, "format");
101
88
  function copy2(text, options) {
102
- var debug, message, reselectPrevious, range, selection, mark, success = false;
103
- if (!options) {
104
- options = {};
105
- }
106
- debug = options.debug || false;
89
+ var debug, message, reselectPrevious, range, selection, mark, success = !1;
90
+ options || (options = {}), debug = options.debug || !1;
107
91
  try {
108
- reselectPrevious = deselectCurrent();
109
- range = document.createRange();
110
- selection = document.getSelection();
111
- mark = document.createElement("span");
112
- mark.textContent = text;
113
- mark.ariaHidden = "true";
114
- mark.style.all = "unset";
115
- mark.style.position = "fixed";
116
- mark.style.top = 0;
117
- mark.style.clip = "rect(0, 0, 0, 0)";
118
- mark.style.whiteSpace = "pre";
119
- mark.style.webkitUserSelect = "text";
120
- mark.style.MozUserSelect = "text";
121
- mark.style.msUserSelect = "text";
122
- mark.style.userSelect = "text";
123
- mark.addEventListener("copy", function(e) {
124
- e.stopPropagation();
125
- if (options.format) {
126
- e.preventDefault();
127
- if (typeof e.clipboardData === "undefined") {
128
- debug && console.warn("unable to use e.clipboardData");
129
- debug && console.warn("trying IE specific stuff");
130
- window.clipboardData.clearData();
131
- var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
92
+ reselectPrevious = deselectCurrent(), range = document.createRange(), selection = document.getSelection(), mark = document.createElement("span"), mark.textContent = text, mark.ariaHidden = "true", mark.style.all = "unset", mark.style.position = "fixed", mark.style.top = 0, mark.style.clip = "rect(0, 0, 0, 0)", mark.style.whiteSpace = "pre", mark.style.webkitUserSelect = "text", mark.style.MozUserSelect = "text", mark.style.msUserSelect = "text", mark.style.userSelect = "text", mark.addEventListener("copy", function(e) {
93
+ if (e.stopPropagation(), options.format)
94
+ if (e.preventDefault(), typeof e.clipboardData > "u") {
95
+ debug && console.warn("unable to use e.clipboardData"), debug && console.warn("trying IE specific stuff"), window.clipboardData.clearData();
96
+ var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting.default;
132
97
  window.clipboardData.setData(format2, text);
133
- } else {
134
- e.clipboardData.clearData();
135
- e.clipboardData.setData(options.format, text);
136
- }
137
- }
138
- if (options.onCopy) {
139
- e.preventDefault();
140
- options.onCopy(e.clipboardData);
141
- }
142
- });
143
- document.body.appendChild(mark);
144
- range.selectNodeContents(mark);
145
- selection.addRange(range);
98
+ } else
99
+ e.clipboardData.clearData(), e.clipboardData.setData(options.format, text);
100
+ options.onCopy && (e.preventDefault(), options.onCopy(e.clipboardData));
101
+ }), document.body.appendChild(mark), range.selectNodeContents(mark), selection.addRange(range);
146
102
  var successful = document.execCommand("copy");
147
- if (!successful) {
103
+ if (!successful)
148
104
  throw new Error("copy command was unsuccessful");
149
- }
150
- success = true;
105
+ success = !0;
151
106
  } catch (err) {
152
- debug && console.error("unable to copy using execCommand: ", err);
153
- debug && console.warn("trying IE specific stuff");
107
+ debug && console.error("unable to copy using execCommand: ", err), debug && console.warn("trying IE specific stuff");
154
108
  try {
155
- window.clipboardData.setData(options.format || "text", text);
156
- options.onCopy && options.onCopy(window.clipboardData);
157
- success = true;
109
+ window.clipboardData.setData(options.format || "text", text), options.onCopy && options.onCopy(window.clipboardData), success = !0;
158
110
  } catch (err2) {
159
- debug && console.error("unable to copy using clipboardData: ", err2);
160
- debug && console.error("falling back to prompt");
161
- message = format("message" in options ? options.message : defaultMessage);
162
- window.prompt(message, text);
111
+ debug && console.error("unable to copy using clipboardData: ", err2), debug && console.error("falling back to prompt"), message = format("message" in options ? options.message : defaultMessage), window.prompt(message, text);
163
112
  }
164
113
  } finally {
165
- if (selection) {
166
- if (typeof selection.removeRange == "function") {
167
- selection.removeRange(range);
168
- } else {
169
- selection.removeAllRanges();
170
- }
171
- }
172
- if (mark) {
173
- document.body.removeChild(mark);
174
- }
175
- reselectPrevious();
114
+ selection && (typeof selection.removeRange == "function" ? selection.removeRange(range) : selection.removeAllRanges()), mark && document.body.removeChild(mark), reselectPrevious();
176
115
  }
177
116
  return success;
178
117
  }
179
- __name(copy2, "copy");
180
118
  module.exports = copy2;
181
119
  }
182
120
  });
@@ -191,331 +129,212 @@ var require_store2 = __commonJS({
191
129
  apis: {},
192
130
  nsdelim: ".",
193
131
  // utilities
194
- inherit: /* @__PURE__ */ __name(function(api, o) {
195
- for (var p in api) {
196
- if (!o.hasOwnProperty(p)) {
197
- Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
198
- }
199
- }
132
+ inherit: function(api, o) {
133
+ for (var p in api)
134
+ o.hasOwnProperty(p) || Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
200
135
  return o;
201
- }, "inherit"),
202
- stringify: /* @__PURE__ */ __name(function(d, fn) {
203
- return d === void 0 || typeof d === "function" ? d + "" : JSON.stringify(d, fn || _.replace);
204
- }, "stringify"),
205
- parse: /* @__PURE__ */ __name(function(s, fn) {
136
+ },
137
+ stringify: function(d, fn) {
138
+ return d === void 0 || typeof d == "function" ? d + "" : JSON.stringify(d, fn || _.replace);
139
+ },
140
+ parse: function(s, fn) {
206
141
  try {
207
142
  return JSON.parse(s, fn || _.revive);
208
- } catch (e) {
143
+ } catch {
209
144
  return s;
210
145
  }
211
- }, "parse"),
146
+ },
212
147
  // extension hooks
213
- fn: /* @__PURE__ */ __name(function(name, fn) {
148
+ fn: function(name, fn) {
214
149
  _.storeAPI[name] = fn;
215
- for (var api in _.apis) {
150
+ for (var api in _.apis)
216
151
  _.apis[api][name] = fn;
217
- }
218
- }, "fn"),
219
- get: /* @__PURE__ */ __name(function(area, key) {
152
+ },
153
+ get: function(area, key) {
220
154
  return area.getItem(key);
221
- }, "get"),
222
- set: /* @__PURE__ */ __name(function(area, key, string) {
155
+ },
156
+ set: function(area, key, string) {
223
157
  area.setItem(key, string);
224
- }, "set"),
225
- remove: /* @__PURE__ */ __name(function(area, key) {
158
+ },
159
+ remove: function(area, key) {
226
160
  area.removeItem(key);
227
- }, "remove"),
228
- key: /* @__PURE__ */ __name(function(area, i) {
161
+ },
162
+ key: function(area, i) {
229
163
  return area.key(i);
230
- }, "key"),
231
- length: /* @__PURE__ */ __name(function(area) {
164
+ },
165
+ length: function(area) {
232
166
  return area.length;
233
- }, "length"),
234
- clear: /* @__PURE__ */ __name(function(area) {
167
+ },
168
+ clear: function(area) {
235
169
  area.clear();
236
- }, "clear"),
170
+ },
237
171
  // core functions
238
- Store: /* @__PURE__ */ __name(function(id, area, namespace) {
172
+ Store: function(id, area, namespace) {
239
173
  var store3 = _.inherit(_.storeAPI, function(key, data, overwrite) {
240
- if (arguments.length === 0) {
241
- return store3.getAll();
242
- }
243
- if (typeof data === "function") {
244
- return store3.transact(key, data, overwrite);
245
- }
246
- if (data !== void 0) {
247
- return store3.set(key, data, overwrite);
248
- }
249
- if (typeof key === "string" || typeof key === "number") {
250
- return store3.get(key);
251
- }
252
- if (typeof key === "function") {
253
- return store3.each(key);
254
- }
255
- if (!key) {
256
- return store3.clear();
257
- }
258
- return store3.setAll(key, data);
174
+ return arguments.length === 0 ? store3.getAll() : typeof data == "function" ? store3.transact(key, data, overwrite) : data !== void 0 ? store3.set(key, data, overwrite) : typeof key == "string" || typeof key == "number" ? store3.get(key) : typeof key == "function" ? store3.each(key) : key ? store3.setAll(key, data) : store3.clear();
259
175
  });
260
176
  store3._id = id;
261
177
  try {
262
178
  var testKey = "__store2_test";
263
- area.setItem(testKey, "ok");
264
- store3._area = area;
265
- area.removeItem(testKey);
266
- } catch (e) {
179
+ area.setItem(testKey, "ok"), store3._area = area, area.removeItem(testKey);
180
+ } catch {
267
181
  store3._area = _.storage("fake");
268
182
  }
269
- store3._ns = namespace || "";
270
- if (!_.areas[id]) {
271
- _.areas[id] = store3._area;
272
- }
273
- if (!_.apis[store3._ns + store3._id]) {
274
- _.apis[store3._ns + store3._id] = store3;
275
- }
276
- return store3;
277
- }, "Store"),
183
+ return store3._ns = namespace || "", _.areas[id] || (_.areas[id] = store3._area), _.apis[store3._ns + store3._id] || (_.apis[store3._ns + store3._id] = store3), store3;
184
+ },
278
185
  storeAPI: {
279
186
  // admin functions
280
- area: /* @__PURE__ */ __name(function(id, area) {
187
+ area: function(id, area) {
281
188
  var store3 = this[id];
282
- if (!store3 || !store3.area) {
283
- store3 = _.Store(id, area, this._ns);
284
- if (!this[id]) {
285
- this[id] = store3;
286
- }
287
- }
288
- return store3;
289
- }, "area"),
290
- namespace: /* @__PURE__ */ __name(function(namespace, singleArea, delim) {
291
- delim = delim || this._delim || _.nsdelim;
292
- if (!namespace) {
189
+ return (!store3 || !store3.area) && (store3 = _.Store(id, area, this._ns), this[id] || (this[id] = store3)), store3;
190
+ },
191
+ namespace: function(namespace, singleArea, delim) {
192
+ if (delim = delim || this._delim || _.nsdelim, !namespace)
293
193
  return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : "";
294
- }
295
194
  var ns = namespace, store3 = this[ns];
296
- if (!store3 || !store3.namespace) {
297
- store3 = _.Store(this._id, this._area, this._ns + ns + delim);
298
- store3._delim = delim;
299
- if (!this[ns]) {
300
- this[ns] = store3;
301
- }
302
- if (!singleArea) {
303
- for (var name in _.areas) {
304
- store3.area(name, _.areas[name]);
305
- }
306
- }
307
- }
195
+ if ((!store3 || !store3.namespace) && (store3 = _.Store(this._id, this._area, this._ns + ns + delim), store3._delim = delim, this[ns] || (this[ns] = store3), !singleArea))
196
+ for (var name in _.areas)
197
+ store3.area(name, _.areas[name]);
308
198
  return store3;
309
- }, "namespace"),
310
- isFake: /* @__PURE__ */ __name(function(force) {
311
- if (force) {
312
- this._real = this._area;
313
- this._area = _.storage("fake");
314
- } else if (force === false) {
315
- this._area = this._real || this._area;
316
- }
317
- return this._area.name === "fake";
318
- }, "isFake"),
319
- toString: /* @__PURE__ */ __name(function() {
199
+ },
200
+ isFake: function(force) {
201
+ return force ? (this._real = this._area, this._area = _.storage("fake")) : force === !1 && (this._area = this._real || this._area), this._area.name === "fake";
202
+ },
203
+ toString: function() {
320
204
  return "store" + (this._ns ? "." + this.namespace() : "") + "[" + this._id + "]";
321
- }, "toString"),
205
+ },
322
206
  // storage functions
323
- has: /* @__PURE__ */ __name(function(key) {
324
- if (this._area.has) {
325
- return this._area.has(this._in(key));
326
- }
327
- return !!(this._in(key) in this._area);
328
- }, "has"),
329
- size: /* @__PURE__ */ __name(function() {
207
+ has: function(key) {
208
+ return this._area.has ? this._area.has(this._in(key)) : this._in(key) in this._area;
209
+ },
210
+ size: function() {
330
211
  return this.keys().length;
331
- }, "size"),
332
- each: /* @__PURE__ */ __name(function(fn, fill) {
212
+ },
213
+ each: function(fn, fill) {
333
214
  for (var i = 0, m = _.length(this._area); i < m; i++) {
334
215
  var key = this._out(_.key(this._area, i));
335
- if (key !== void 0) {
336
- if (fn.call(this, key, this.get(key), fill) === false) {
337
- break;
338
- }
339
- }
340
- if (m > _.length(this._area)) {
341
- m--;
342
- i--;
343
- }
216
+ if (key !== void 0 && fn.call(this, key, this.get(key), fill) === !1)
217
+ break;
218
+ m > _.length(this._area) && (m--, i--);
344
219
  }
345
220
  return fill || this;
346
- }, "each"),
347
- keys: /* @__PURE__ */ __name(function(fillList) {
221
+ },
222
+ keys: function(fillList) {
348
223
  return this.each(function(k, v, list) {
349
224
  list.push(k);
350
225
  }, fillList || []);
351
- }, "keys"),
352
- get: /* @__PURE__ */ __name(function(key, alt) {
226
+ },
227
+ get: function(key, alt) {
353
228
  var s = _.get(this._area, this._in(key)), fn;
354
- if (typeof alt === "function") {
355
- fn = alt;
356
- alt = null;
357
- }
358
- return s !== null ? _.parse(s, fn) : alt != null ? alt : s;
359
- }, "get"),
360
- getAll: /* @__PURE__ */ __name(function(fillObj) {
229
+ return typeof alt == "function" && (fn = alt, alt = null), s !== null ? _.parse(s, fn) : alt ?? s;
230
+ },
231
+ getAll: function(fillObj) {
361
232
  return this.each(function(k, v, all) {
362
233
  all[k] = v;
363
234
  }, fillObj || {});
364
- }, "getAll"),
365
- transact: /* @__PURE__ */ __name(function(key, fn, alt) {
235
+ },
236
+ transact: function(key, fn, alt) {
366
237
  var val = this.get(key, alt), ret = fn(val);
367
- this.set(key, ret === void 0 ? val : ret);
368
- return this;
369
- }, "transact"),
370
- set: /* @__PURE__ */ __name(function(key, data, overwrite) {
238
+ return this.set(key, ret === void 0 ? val : ret), this;
239
+ },
240
+ set: function(key, data, overwrite) {
371
241
  var d = this.get(key), replacer;
372
- if (d != null && overwrite === false) {
373
- return data;
374
- }
375
- if (typeof overwrite === "function") {
376
- replacer = overwrite;
377
- overwrite = void 0;
378
- }
379
- return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
380
- }, "set"),
381
- setAll: /* @__PURE__ */ __name(function(data, overwrite) {
242
+ return d != null && overwrite === !1 ? data : (typeof overwrite == "function" && (replacer = overwrite, overwrite = void 0), _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d);
243
+ },
244
+ setAll: function(data, overwrite) {
382
245
  var changed, val;
383
- for (var key in data) {
384
- val = data[key];
385
- if (this.set(key, val, overwrite) !== val) {
386
- changed = true;
387
- }
388
- }
246
+ for (var key in data)
247
+ val = data[key], this.set(key, val, overwrite) !== val && (changed = !0);
389
248
  return changed;
390
- }, "setAll"),
391
- add: /* @__PURE__ */ __name(function(key, data, replacer) {
249
+ },
250
+ add: function(key, data, replacer) {
392
251
  var d = this.get(key);
393
- if (d instanceof Array) {
252
+ if (d instanceof Array)
394
253
  data = d.concat(data);
395
- } else if (d !== null) {
254
+ else if (d !== null) {
396
255
  var type = typeof d;
397
256
  if (type === typeof data && type === "object") {
398
- for (var k in data) {
257
+ for (var k in data)
399
258
  d[k] = data[k];
400
- }
401
259
  data = d;
402
- } else {
260
+ } else
403
261
  data = d + data;
404
- }
405
262
  }
406
- _.set(this._area, this._in(key), _.stringify(data, replacer));
407
- return data;
408
- }, "add"),
409
- remove: /* @__PURE__ */ __name(function(key, alt) {
263
+ return _.set(this._area, this._in(key), _.stringify(data, replacer)), data;
264
+ },
265
+ remove: function(key, alt) {
410
266
  var d = this.get(key, alt);
411
- _.remove(this._area, this._in(key));
412
- return d;
413
- }, "remove"),
414
- clear: /* @__PURE__ */ __name(function() {
415
- if (!this._ns) {
416
- _.clear(this._area);
417
- } else {
418
- this.each(function(k) {
419
- _.remove(this._area, this._in(k));
420
- }, 1);
421
- }
422
- return this;
423
- }, "clear"),
424
- clearAll: /* @__PURE__ */ __name(function() {
267
+ return _.remove(this._area, this._in(key)), d;
268
+ },
269
+ clear: function() {
270
+ return this._ns ? this.each(function(k) {
271
+ _.remove(this._area, this._in(k));
272
+ }, 1) : _.clear(this._area), this;
273
+ },
274
+ clearAll: function() {
425
275
  var area = this._area;
426
- for (var id in _.areas) {
427
- if (_.areas.hasOwnProperty(id)) {
428
- this._area = _.areas[id];
429
- this.clear();
430
- }
431
- }
432
- this._area = area;
433
- return this;
434
- }, "clearAll"),
276
+ for (var id in _.areas)
277
+ _.areas.hasOwnProperty(id) && (this._area = _.areas[id], this.clear());
278
+ return this._area = area, this;
279
+ },
435
280
  // internal use functions
436
- _in: /* @__PURE__ */ __name(function(k) {
437
- if (typeof k !== "string") {
438
- k = _.stringify(k);
439
- }
440
- return this._ns ? this._ns + k : k;
441
- }, "_in"),
442
- _out: /* @__PURE__ */ __name(function(k) {
281
+ _in: function(k) {
282
+ return typeof k != "string" && (k = _.stringify(k)), this._ns ? this._ns + k : k;
283
+ },
284
+ _out: function(k) {
443
285
  return this._ns ? k && k.indexOf(this._ns) === 0 ? k.substring(this._ns.length) : void 0 : (
444
286
  // so each() knows to skip it
445
287
  k
446
288
  );
447
- }, "_out")
289
+ }
448
290
  },
449
291
  // end _.storeAPI
450
- storage: /* @__PURE__ */ __name(function(name) {
292
+ storage: function(name) {
451
293
  return _.inherit(_.storageAPI, { items: {}, name });
452
- }, "storage"),
294
+ },
453
295
  storageAPI: {
454
296
  length: 0,
455
- has: /* @__PURE__ */ __name(function(k) {
297
+ has: function(k) {
456
298
  return this.items.hasOwnProperty(k);
457
- }, "has"),
458
- key: /* @__PURE__ */ __name(function(i) {
299
+ },
300
+ key: function(i) {
459
301
  var c = 0;
460
- for (var k in this.items) {
461
- if (this.has(k) && i === c++) {
302
+ for (var k in this.items)
303
+ if (this.has(k) && i === c++)
462
304
  return k;
463
- }
464
- }
465
- }, "key"),
466
- setItem: /* @__PURE__ */ __name(function(k, v) {
467
- if (!this.has(k)) {
468
- this.length++;
469
- }
470
- this.items[k] = v;
471
- }, "setItem"),
472
- removeItem: /* @__PURE__ */ __name(function(k) {
473
- if (this.has(k)) {
474
- delete this.items[k];
475
- this.length--;
476
- }
477
- }, "removeItem"),
478
- getItem: /* @__PURE__ */ __name(function(k) {
305
+ },
306
+ setItem: function(k, v) {
307
+ this.has(k) || this.length++, this.items[k] = v;
308
+ },
309
+ removeItem: function(k) {
310
+ this.has(k) && (delete this.items[k], this.length--);
311
+ },
312
+ getItem: function(k) {
479
313
  return this.has(k) ? this.items[k] : null;
480
- }, "getItem"),
481
- clear: /* @__PURE__ */ __name(function() {
482
- for (var k in this.items) {
314
+ },
315
+ clear: function() {
316
+ for (var k in this.items)
483
317
  this.removeItem(k);
484
- }
485
- }, "clear")
318
+ }
486
319
  }
487
320
  // end _.storageAPI
488
- };
489
- var store2 = (
321
+ }, store2 = (
490
322
  // safely set this up (throws error in IE10/32bit mode for local files)
491
- _.Store("local", function() {
323
+ _.Store("local", (function() {
492
324
  try {
493
325
  return localStorage;
494
- } catch (e) {
326
+ } catch {
495
327
  }
496
- }())
328
+ })())
497
329
  );
498
- store2.local = store2;
499
- store2._ = _;
500
- store2.area("session", function() {
330
+ store2.local = store2, store2._ = _, store2.area("session", (function() {
501
331
  try {
502
332
  return sessionStorage;
503
- } catch (e) {
333
+ } catch {
504
334
  }
505
- }());
506
- store2.area("page", _.storage("page"));
507
- if (typeof define === "function" && define.amd !== void 0) {
508
- define("store2", [], function() {
509
- return store2;
510
- });
511
- } else if (typeof module !== "undefined" && module.exports) {
512
- module.exports = store2;
513
- } else {
514
- if (window2.store) {
515
- _.conflict = window2.store;
516
- }
517
- window2.store = store2;
518
- }
335
+ })()), store2.area("page", _.storage("page")), typeof define == "function" && define.amd !== void 0 ? define("store2", [], function() {
336
+ return store2;
337
+ }) : typeof module < "u" && module.exports ? module.exports = store2 : (window2.store && (_.conflict = window2.store), window2.store = store2);
519
338
  })(exports, exports && exports.define);
520
339
  }
521
340
  });
@@ -542,74 +361,54 @@ import {
542
361
 
543
362
  // src/manager-api/context.ts
544
363
  import { createContext as ReactCreateContext } from "react";
545
- var createContext = /* @__PURE__ */ __name(({ api, state }) => ReactCreateContext({ api, state }), "createContext");
364
+ var createContext = ({ api, state }) => ReactCreateContext({ api, state });
546
365
 
547
366
  // src/manager-api/lib/merge.ts
548
367
  import { logger } from "storybook/internal/client-logger";
549
- var merge_default = /* @__PURE__ */ __name((a, ...b) => {
368
+ var merge_default = (a, ...b) => {
550
369
  let target = {};
551
370
  target = mergeWith(
552
371
  {},
553
372
  a,
554
373
  (objValue, srcValue) => {
555
- if (Array.isArray(srcValue) && Array.isArray(objValue)) {
556
- srcValue.forEach((s) => {
557
- const existing = objValue.find((o) => o === s || isEqual(o, s));
558
- if (!existing) {
559
- objValue.push(s);
560
- }
561
- });
562
- return objValue;
563
- }
564
- if (Array.isArray(objValue)) {
565
- logger.log(["the types mismatch, picking", objValue]);
566
- return objValue;
567
- }
374
+ if (Array.isArray(srcValue) && Array.isArray(objValue))
375
+ return srcValue.forEach((s) => {
376
+ objValue.find((o) => o === s || isEqual(o, s)) || objValue.push(s);
377
+ }), objValue;
378
+ if (Array.isArray(objValue))
379
+ return logger.log(["the types mismatch, picking", objValue]), objValue;
568
380
  }
569
381
  );
570
- for (const obj of b) {
382
+ for (let obj of b)
571
383
  target = mergeWith(target, obj, (objValue, srcValue) => {
572
- if (Array.isArray(srcValue) && Array.isArray(objValue)) {
573
- srcValue.forEach((s) => {
574
- const existing = objValue.find((o) => o === s || isEqual(o, s));
575
- if (!existing) {
576
- objValue.push(s);
577
- }
578
- });
579
- return objValue;
580
- }
581
- if (Array.isArray(objValue)) {
582
- logger.log(["the types mismatch, picking", objValue]);
583
- return objValue;
584
- }
384
+ if (Array.isArray(srcValue) && Array.isArray(objValue))
385
+ return srcValue.forEach((s) => {
386
+ objValue.find((o) => o === s || isEqual(o, s)) || objValue.push(s);
387
+ }), objValue;
388
+ if (Array.isArray(objValue))
389
+ return logger.log(["the types mismatch, picking", objValue]), objValue;
585
390
  });
586
- }
587
391
  return target;
588
- }, "default");
589
- var noArrayMerge = /* @__PURE__ */ __name((a, ...b) => {
392
+ }, noArrayMerge = (a, ...b) => {
590
393
  let target = {};
591
394
  target = mergeWith(
592
395
  {},
593
396
  a,
594
397
  (objValue, srcValue) => {
595
- if (Array.isArray(srcValue)) {
398
+ if (Array.isArray(srcValue))
596
399
  return srcValue;
597
- }
598
400
  }
599
401
  );
600
- for (const obj of b) {
402
+ for (let obj of b)
601
403
  target = mergeWith(target, obj, (objValue, srcValue) => {
602
- if (Array.isArray(srcValue)) {
404
+ if (Array.isArray(srcValue))
603
405
  return srcValue;
604
- }
605
406
  });
606
- }
607
407
  return target;
608
- }, "noArrayMerge");
408
+ };
609
409
 
610
410
  // src/manager-api/initial-state.ts
611
- var main = /* @__PURE__ */ __name((...additions) => additions.reduce((acc, item) => merge_default(acc, item), {}), "main");
612
- var initial_state_default = main;
411
+ var main = (...additions) => additions.reduce((acc, item) => merge_default(acc, item), {}), initial_state_default = main;
613
412
 
614
413
  // src/manager-api/lib/addons.ts
615
414
  import { logger as logger2 } from "storybook/internal/client-logger";
@@ -620,45 +419,33 @@ import { global } from "@storybook/global";
620
419
  // src/manager-api/lib/storybook-channel-mock.ts
621
420
  import { Channel } from "storybook/internal/channels";
622
421
  function mockChannel() {
623
- const transport = {
624
- setHandler: /* @__PURE__ */ __name(() => {
625
- }, "setHandler"),
626
- send: /* @__PURE__ */ __name(() => {
627
- }, "send")
422
+ let transport = {
423
+ setHandler: () => {
424
+ },
425
+ send: () => {
426
+ }
628
427
  };
629
428
  return new Channel({ transport });
630
429
  }
631
- __name(mockChannel, "mockChannel");
632
430
 
633
431
  // src/manager-api/lib/addons.ts
634
- var _AddonStore = class _AddonStore {
432
+ var AddonStore = class {
635
433
  constructor() {
636
434
  this.loaders = {};
637
435
  this.elements = {};
638
436
  this.config = {};
639
- this.getChannel = /* @__PURE__ */ __name(() => {
640
- if (!this.channel) {
641
- this.setChannel(mockChannel());
642
- }
643
- return this.channel;
644
- }, "getChannel");
645
- this.ready = /* @__PURE__ */ __name(() => this.promise, "ready");
646
- this.hasChannel = /* @__PURE__ */ __name(() => !!this.channel, "hasChannel");
647
- this.setChannel = /* @__PURE__ */ __name((channel) => {
648
- this.channel = channel;
649
- this.resolve();
650
- }, "setChannel");
651
- this.setConfig = /* @__PURE__ */ __name((value) => {
652
- Object.assign(this.config, value);
653
- if (this.hasChannel()) {
654
- this.getChannel().emit(SET_CONFIG, this.config);
655
- } else {
656
- this.ready().then((channel) => {
657
- channel.emit(SET_CONFIG, this.config);
658
- });
659
- }
660
- }, "setConfig");
661
- this.getConfig = /* @__PURE__ */ __name(() => this.config, "getConfig");
437
+ this.getChannel = () => (this.channel || this.setChannel(mockChannel()), this.channel);
438
+ this.ready = () => this.promise;
439
+ this.hasChannel = () => !!this.channel;
440
+ this.setChannel = (channel) => {
441
+ this.channel = channel, this.resolve();
442
+ };
443
+ this.setConfig = (value) => {
444
+ Object.assign(this.config, value), this.hasChannel() ? this.getChannel().emit(SET_CONFIG, this.config) : this.ready().then((channel) => {
445
+ channel.emit(SET_CONFIG, this.config);
446
+ });
447
+ };
448
+ this.getConfig = () => this.config;
662
449
  /**
663
450
  * Registers an addon loader function.
664
451
  *
@@ -666,24 +453,18 @@ var _AddonStore = class _AddonStore {
666
453
  * @param {(api: API) => void} callback - The function that will be called to register the addon.
667
454
  * @returns {void}
668
455
  */
669
- this.register = /* @__PURE__ */ __name((id, callback) => {
670
- if (this.loaders[id]) {
671
- logger2.warn(`${id} was loaded twice, this could have bad side-effects`);
672
- }
673
- this.loaders[id] = callback;
674
- }, "register");
675
- this.loadAddons = /* @__PURE__ */ __name((api) => {
456
+ this.register = (id, callback) => {
457
+ this.loaders[id] && logger2.warn(`${id} was loaded twice, this could have bad side-effects`), this.loaders[id] = callback;
458
+ };
459
+ this.loadAddons = (api) => {
676
460
  Object.values(this.loaders).forEach((value) => value(api));
677
- }, "loadAddons");
461
+ };
678
462
  this.promise = new Promise((res) => {
679
463
  this.resolve = () => res(this.getChannel());
680
464
  });
681
465
  }
682
466
  getElements(type) {
683
- if (!this.elements[type]) {
684
- this.elements[type] = {};
685
- }
686
- return this.elements[type];
467
+ return this.elements[type] || (this.elements[type] = {}), this.elements[type];
687
468
  }
688
469
  /**
689
470
  * Adds an addon to the addon store.
@@ -693,24 +474,16 @@ var _AddonStore = class _AddonStore {
693
474
  * @returns {void}
694
475
  */
695
476
  add(id, addon) {
696
- const { type } = addon;
697
- const collection = this.getElements(type);
477
+ let { type } = addon, collection = this.getElements(type);
698
478
  collection[id] = { ...addon, id };
699
479
  }
700
480
  experimental_getRegisteredAddons() {
701
481
  return Object.keys(this.loaders);
702
482
  }
703
- };
704
- __name(_AddonStore, "AddonStore");
705
- var AddonStore = _AddonStore;
706
- var KEY = "__STORYBOOK_ADDONS_MANAGER";
483
+ }, KEY = "__STORYBOOK_ADDONS_MANAGER";
707
484
  function getAddonsStore() {
708
- if (!global[KEY]) {
709
- global[KEY] = new AddonStore();
710
- }
711
- return global[KEY];
485
+ return global[KEY] || (global[KEY] = new AddonStore()), global[KEY];
712
486
  }
713
- __name(getAddonsStore, "getAddonsStore");
714
487
  var addons = getAddonsStore();
715
488
 
716
489
  // src/manager-api/modules/addons.ts
@@ -721,36 +494,27 @@ __export(addons_exports, {
721
494
  });
722
495
  import { Addon_TypesEnum as Addon_TypesEnum2 } from "storybook/internal/types";
723
496
  function ensurePanel(panels, selectedPanel, currentPanel) {
724
- const keys2 = Object.keys(panels);
725
- if (keys2.indexOf(selectedPanel) >= 0) {
726
- return selectedPanel;
727
- }
728
- if (keys2.length) {
729
- return keys2[0];
730
- }
731
- return currentPanel;
497
+ let keys2 = Object.keys(panels);
498
+ return keys2.indexOf(selectedPanel) >= 0 ? selectedPanel : keys2.length ? keys2[0] : currentPanel;
732
499
  }
733
- __name(ensurePanel, "ensurePanel");
734
- var init = /* @__PURE__ */ __name(({ provider, store: store2, fullAPI }) => {
735
- const api = {
736
- getElements: /* @__PURE__ */ __name((type) => provider.getElements(type), "getElements"),
737
- getSelectedPanel: /* @__PURE__ */ __name(() => {
738
- const { selectedPanel } = store2.getState();
500
+ var init = ({ provider, store: store2, fullAPI }) => {
501
+ let api = {
502
+ getElements: (type) => provider.getElements(type),
503
+ getSelectedPanel: () => {
504
+ let { selectedPanel } = store2.getState();
739
505
  return ensurePanel(api.getElements(Addon_TypesEnum2.PANEL), selectedPanel, selectedPanel);
740
- }, "getSelectedPanel"),
741
- setSelectedPanel: /* @__PURE__ */ __name((panelName) => {
506
+ },
507
+ setSelectedPanel: (panelName) => {
742
508
  store2.setState({ selectedPanel: panelName }, { persistence: "session" });
743
- }, "setSelectedPanel"),
509
+ },
744
510
  setAddonState(addonId, newStateOrMerger, options) {
745
- const merger = typeof newStateOrMerger === "function" ? newStateOrMerger : () => newStateOrMerger;
511
+ let merger = typeof newStateOrMerger == "function" ? newStateOrMerger : () => newStateOrMerger;
746
512
  return store2.setState(
747
513
  (s) => ({ ...s, addons: { ...s.addons, [addonId]: merger(s.addons[addonId]) } }),
748
514
  options
749
515
  ).then(() => api.getAddonState(addonId));
750
516
  },
751
- getAddonState: /* @__PURE__ */ __name((addonId) => {
752
- return store2.getState().addons[addonId] || globalThis?.STORYBOOK_ADDON_STATE[addonId];
753
- }, "getAddonState")
517
+ getAddonState: (addonId) => store2.getState().addons[addonId] || globalThis?.STORYBOOK_ADDON_STATE[addonId]
754
518
  };
755
519
  return {
756
520
  api,
@@ -762,31 +526,22 @@ var init = /* @__PURE__ */ __name(({ provider, store: store2, fullAPI }) => {
762
526
  addons: {}
763
527
  }
764
528
  };
765
- }, "init");
529
+ };
766
530
 
767
531
  // src/manager-api/modules/channel.ts
768
532
  var channel_exports = {};
769
533
  __export(channel_exports, {
770
534
  init: () => init2
771
535
  });
772
- var init2 = /* @__PURE__ */ __name(({ provider }) => {
773
- const api = {
774
- getChannel: /* @__PURE__ */ __name(() => provider.channel, "getChannel"),
775
- on: /* @__PURE__ */ __name((type, handler) => {
776
- provider.channel?.on(type, handler);
777
- return () => provider.channel?.off(type, handler);
778
- }, "on"),
779
- off: /* @__PURE__ */ __name((type, handler) => provider.channel?.off(type, handler), "off"),
780
- once: /* @__PURE__ */ __name((type, handler) => provider.channel?.once(type, handler), "once"),
781
- emit: /* @__PURE__ */ __name((type, data, ...args) => {
782
- if (data?.options?.target && data.options.target !== "storybook-preview-iframe" && !data.options.target.startsWith("storybook-ref-")) {
783
- data.options.target = data.options.target !== "storybook_internal" ? `storybook-ref-${data.options.target}` : "storybook-preview-iframe";
784
- }
785
- provider.channel?.emit(type, data, ...args);
786
- }, "emit")
787
- };
788
- return { api, state: {} };
789
- }, "init");
536
+ var init2 = ({ provider }) => ({ api: {
537
+ getChannel: () => provider.channel,
538
+ on: (type, handler) => (provider.channel?.on(type, handler), () => provider.channel?.off(type, handler)),
539
+ off: (type, handler) => provider.channel?.off(type, handler),
540
+ once: (type, handler) => provider.channel?.once(type, handler),
541
+ emit: (type, data, ...args) => {
542
+ data?.options?.target && data.options.target !== "storybook-preview-iframe" && !data.options.target.startsWith("storybook-ref-") && (data.options.target = data.options.target !== "storybook_internal" ? `storybook-ref-${data.options.target}` : "storybook-preview-iframe"), provider.channel?.emit(type, data, ...args);
543
+ }
544
+ }, state: {} });
790
545
 
791
546
  // src/manager-api/modules/globals.ts
792
547
  var globals_exports = {};
@@ -813,167 +568,104 @@ import { sanitize } from "storybook/internal/csf";
813
568
  var import_memoizerific = __toESM(require_memoizerific(), 1);
814
569
 
815
570
  // src/manager-api/lib/intersect.ts
816
- var intersect_default = /* @__PURE__ */ __name((a, b) => {
817
- if (!Array.isArray(a) || !Array.isArray(b) || !a.length || !b.length) {
818
- return [];
819
- }
820
- return a.reduce((acc, aValue) => {
821
- if (b.includes(aValue)) {
822
- acc.push(aValue);
823
- }
824
- return acc;
825
- }, []);
826
- }, "default");
571
+ var intersect_default = (a, b) => !Array.isArray(a) || !Array.isArray(b) || !a.length || !b.length ? [] : a.reduce((acc, aValue) => (b.includes(aValue) && acc.push(aValue), acc), []);
827
572
 
828
573
  // src/manager-api/lib/stories.ts
829
- var TITLE_PATH_SEPARATOR = /\s*\/\s*/;
830
- var denormalizeStoryParameters = /* @__PURE__ */ __name(({
574
+ var TITLE_PATH_SEPARATOR = /\s*\/\s*/, denormalizeStoryParameters = ({
831
575
  globalParameters,
832
576
  kindParameters,
833
577
  stories
834
- }) => {
835
- return mapValues(stories, (storyData) => ({
836
- ...storyData,
837
- parameters: combineParameters(
838
- globalParameters,
839
- kindParameters[storyData.kind],
840
- storyData.parameters
841
- )
842
- }));
843
- }, "denormalizeStoryParameters");
844
- var transformSetStoriesStoryDataToPreparedStoryIndex = /* @__PURE__ */ __name((stories) => {
845
- const entries = Object.entries(stories).reduce(
846
- (acc, [id, story]) => {
847
- if (!story) {
848
- return acc;
849
- }
850
- const { docsOnly, fileName, ...parameters } = story.parameters;
851
- const base = {
852
- title: story.kind,
853
- id,
854
- name: story.name,
855
- importPath: fileName
856
- };
857
- if (docsOnly) {
858
- acc[id] = {
859
- type: "docs",
860
- tags: ["stories-mdx"],
861
- storiesImports: [],
862
- ...base
863
- };
864
- } else {
865
- const { argTypes, args, initialArgs } = story;
866
- acc[id] = {
867
- type: "story",
868
- subtype: "story",
869
- ...base,
870
- parameters,
871
- argTypes,
872
- args,
873
- initialArgs
874
- };
875
- }
578
+ }) => mapValues(stories, (storyData) => ({
579
+ ...storyData,
580
+ parameters: combineParameters(
581
+ globalParameters,
582
+ kindParameters[storyData.kind],
583
+ storyData.parameters
584
+ )
585
+ })), transformSetStoriesStoryDataToPreparedStoryIndex = (stories) => ({ v: 5, entries: Object.entries(stories).reduce(
586
+ (acc, [id, story]) => {
587
+ if (!story)
876
588
  return acc;
877
- },
589
+ let { docsOnly, fileName, ...parameters } = story.parameters, base = {
590
+ title: story.kind,
591
+ id,
592
+ name: story.name,
593
+ importPath: fileName
594
+ };
595
+ if (docsOnly)
596
+ acc[id] = {
597
+ type: "docs",
598
+ tags: ["stories-mdx"],
599
+ storiesImports: [],
600
+ ...base
601
+ };
602
+ else {
603
+ let { argTypes, args, initialArgs } = story;
604
+ acc[id] = {
605
+ type: "story",
606
+ subtype: "story",
607
+ ...base,
608
+ parameters,
609
+ argTypes,
610
+ args,
611
+ initialArgs
612
+ };
613
+ }
614
+ return acc;
615
+ },
616
+ {}
617
+ ) }), transformStoryIndexV2toV3 = (index) => ({
618
+ v: 3,
619
+ stories: Object.values(index.stories).reduce(
620
+ (acc, entry) => (acc[entry.id] = {
621
+ ...entry,
622
+ title: entry.kind,
623
+ name: entry.name || entry.story,
624
+ importPath: entry.parameters.fileName || ""
625
+ }, acc),
878
626
  {}
879
- );
880
- return { v: 5, entries };
881
- }, "transformSetStoriesStoryDataToPreparedStoryIndex");
882
- var transformStoryIndexV2toV3 = /* @__PURE__ */ __name((index) => {
883
- return {
884
- v: 3,
885
- stories: Object.values(index.stories).reduce(
886
- (acc, entry) => {
887
- acc[entry.id] = {
888
- ...entry,
889
- title: entry.kind,
890
- name: entry.name || entry.story,
891
- importPath: entry.parameters.fileName || ""
892
- };
893
- return acc;
894
- },
895
- {}
896
- )
897
- };
898
- }, "transformStoryIndexV2toV3");
899
- var transformStoryIndexV3toV4 = /* @__PURE__ */ __name((index) => {
900
- const countByTitle = countBy(Object.values(index.stories), (item) => item.title);
627
+ )
628
+ }), transformStoryIndexV3toV4 = (index) => {
629
+ let countByTitle = countBy(Object.values(index.stories), (item) => item.title);
901
630
  return {
902
631
  v: 4,
903
632
  entries: Object.values(index.stories).reduce(
904
633
  (acc, entry) => {
905
634
  let type = "story";
906
- if (entry.parameters?.docsOnly || entry.name === "Page" && countByTitle[entry.title] === 1) {
907
- type = "docs";
908
- }
909
- acc[entry.id] = {
635
+ return (entry.parameters?.docsOnly || entry.name === "Page" && countByTitle[entry.title] === 1) && (type = "docs"), acc[entry.id] = {
910
636
  type,
911
637
  ...type === "docs" && { tags: ["stories-mdx"], storiesImports: [] },
912
638
  ...entry
913
- };
914
- delete acc[entry.id].story;
915
- delete acc[entry.id].kind;
916
- return acc;
639
+ }, delete acc[entry.id].story, delete acc[entry.id].kind, acc;
917
640
  },
918
641
  {}
919
642
  )
920
643
  };
921
- }, "transformStoryIndexV3toV4");
922
- var transformStoryIndexV4toV5 = /* @__PURE__ */ __name((index) => {
923
- return {
924
- v: 5,
925
- entries: Object.values(index.entries).reduce(
926
- (acc, entry) => {
927
- acc[entry.id] = {
928
- ...entry,
929
- tags: entry.tags ? ["dev", "test", ...entry.tags] : ["dev"]
930
- };
931
- return acc;
932
- },
933
- {}
934
- )
935
- };
936
- }, "transformStoryIndexV4toV5");
937
- var transformStoryIndexToStoriesHash = /* @__PURE__ */ __name((input, { provider, docsOptions, filters, allStatuses }) => {
938
- if (!input.v) {
644
+ }, transformStoryIndexV4toV5 = (index) => ({
645
+ v: 5,
646
+ entries: Object.values(index.entries).reduce(
647
+ (acc, entry) => (acc[entry.id] = {
648
+ ...entry,
649
+ tags: entry.tags ? ["dev", "test", ...entry.tags] : ["dev"]
650
+ }, acc),
651
+ {}
652
+ )
653
+ }), transformStoryIndexToStoriesHash = (input, { provider, docsOptions, filters, allStatuses }) => {
654
+ if (!input.v)
939
655
  throw new Error("Composition: Missing stories.json version");
940
- }
941
656
  let index = input;
942
- index = index.v === 2 ? transformStoryIndexV2toV3(index) : index;
943
- index = index.v === 3 ? transformStoryIndexV3toV4(index) : index;
944
- index = index.v === 4 ? transformStoryIndexV4toV5(index) : index;
945
- index = index;
946
- const indexEntries = Object.values(index.entries);
947
- const filterFunctions = Object.values(filters);
948
- const entryValues = indexEntries.filter((entry) => {
949
- const statuses = allStatuses[entry.id] ?? {};
950
- if (Object.values(statuses).some(({ value }) => value === "status-value:error")) {
951
- return true;
952
- }
953
- if (filterFunctions.every((fn) => fn({ ...entry, statuses }))) {
954
- return true;
955
- }
956
- const children = indexEntries.filter((item) => "parent" in item && item.parent === entry.id);
957
- return children.some((child) => filterFunctions.every((fn) => fn({ ...child, statuses })));
958
- });
959
- const { sidebar = {} } = provider.getConfig();
960
- const { showRoots, collapsedRoots = [], renderLabel } = sidebar;
961
- const setShowRoots = typeof showRoots !== "undefined";
962
- const storiesHashOutOfOrder = entryValues.reduce((acc, item) => {
963
- if (docsOptions.docsMode && item.type !== "docs") {
657
+ index = index.v === 2 ? transformStoryIndexV2toV3(index) : index, index = index.v === 3 ? transformStoryIndexV3toV4(index) : index, index = index.v === 4 ? transformStoryIndexV4toV5(index) : index, index = index;
658
+ let indexEntries = Object.values(index.entries), filterFunctions = Object.values(filters), entryValues = indexEntries.filter((entry) => {
659
+ let statuses = allStatuses[entry.id] ?? {};
660
+ return Object.values(statuses).some(({ value }) => value === "status-value:error") || filterFunctions.every((fn) => fn({ ...entry, statuses })) ? !0 : indexEntries.filter((item) => "parent" in item && item.parent === entry.id).some((child) => filterFunctions.every((fn) => fn({ ...child, statuses })));
661
+ }), { sidebar = {} } = provider.getConfig(), { showRoots, collapsedRoots = [], renderLabel } = sidebar, setShowRoots = typeof showRoots < "u", storiesHashOutOfOrder = entryValues.reduce((acc, item) => {
662
+ if (docsOptions.docsMode && item.type !== "docs")
964
663
  return acc;
965
- }
966
- const { title } = item;
967
- const groups = title.trim().split(TITLE_PATH_SEPARATOR);
968
- const root = (!setShowRoots || showRoots) && groups.length > 1 ? [groups.shift()] : [];
969
- const names = [...root, ...groups];
970
- const paths = names.reduce((list, name, idx) => {
971
- const parent = idx > 0 && list[idx - 1];
972
- const id = sanitize(parent ? `${parent}-${name}` : name);
973
- if (name.trim() === "") {
664
+ let { title } = item, groups = title.trim().split(TITLE_PATH_SEPARATOR), root = (!setShowRoots || showRoots) && groups.length > 1 ? [groups.shift()] : [], names = [...root, ...groups], paths = names.reduce((list, name, idx) => {
665
+ let parent = idx > 0 && list[idx - 1], id = sanitize(parent ? `${parent}-${name}` : name);
666
+ if (name.trim() === "")
974
667
  throw new Error(dedent`Invalid title ${title} ending in slash.`);
975
- }
976
- if (parent === id) {
668
+ if (parent === id)
977
669
  throw new Error(
978
670
  dedent`
979
671
  Invalid part '${name}', leading to id === parentId ('${id}'), inside title '${title}'
@@ -981,249 +673,150 @@ var transformStoryIndexToStoriesHash = /* @__PURE__ */ __name((input, { provider
981
673
  Did you create a path that uses the separator char accidentally, such as 'Vue <docs/>' where '/' is a separator char? See https://github.com/storybookjs/storybook/issues/6128
982
674
  `
983
675
  );
984
- }
985
- list.push(id);
986
- return list;
676
+ return list.push(id), list;
987
677
  }, []);
988
- paths.forEach((id, idx) => {
989
- const childId = paths[idx + 1] || item.id;
990
- if (root.length && idx === 0) {
991
- acc[id] = merge_default(acc[id] || {}, {
992
- type: "root",
993
- id,
994
- name: names[idx],
995
- tags: [],
996
- depth: idx,
997
- renderLabel,
998
- startCollapsed: collapsedRoots.includes(id),
999
- // Note that this will later get appended to the previous list of children (see below)
678
+ return paths.forEach((id, idx) => {
679
+ let childId = paths[idx + 1] || item.id;
680
+ root.length && idx === 0 ? acc[id] = merge_default(acc[id] || {}, {
681
+ type: "root",
682
+ id,
683
+ name: names[idx],
684
+ tags: [],
685
+ depth: idx,
686
+ renderLabel,
687
+ startCollapsed: collapsedRoots.includes(id),
688
+ // Note that this will later get appended to the previous list of children (see below)
689
+ children: [childId]
690
+ }) : (!acc[id] || acc[id].type === "component") && idx === paths.length - 1 ? acc[id] = merge_default(acc[id] || {}, {
691
+ type: "component",
692
+ id,
693
+ name: names[idx],
694
+ tags: [],
695
+ parent: paths[idx - 1],
696
+ depth: idx,
697
+ renderLabel,
698
+ ...childId && {
1000
699
  children: [childId]
1001
- });
1002
- } else if ((!acc[id] || acc[id].type === "component") && idx === paths.length - 1) {
1003
- acc[id] = merge_default(acc[id] || {}, {
1004
- type: "component",
1005
- id,
1006
- name: names[idx],
1007
- tags: [],
1008
- parent: paths[idx - 1],
1009
- depth: idx,
1010
- renderLabel,
1011
- ...childId && {
1012
- children: [childId]
1013
- }
1014
- });
1015
- } else {
1016
- acc[id] = merge_default(acc[id] || {}, {
1017
- type: "group",
1018
- id,
1019
- name: names[idx],
1020
- tags: [],
1021
- parent: paths[idx - 1],
1022
- depth: idx,
1023
- renderLabel,
1024
- ...childId && {
1025
- children: [childId]
1026
- }
1027
- });
1028
- }
1029
- });
1030
- acc[item.id] = {
700
+ }
701
+ }) : acc[id] = merge_default(acc[id] || {}, {
702
+ type: "group",
703
+ id,
704
+ name: names[idx],
705
+ tags: [],
706
+ parent: paths[idx - 1],
707
+ depth: idx,
708
+ renderLabel,
709
+ ...childId && {
710
+ children: [childId]
711
+ }
712
+ });
713
+ }), acc[item.id] = {
1031
714
  tags: [],
1032
715
  ...item,
1033
716
  depth: paths.length,
1034
717
  parent: "parent" in item ? item.parent : paths[paths.length - 1],
1035
718
  renderLabel,
1036
719
  prepared: !!item.parameters
1037
- };
1038
- return acc;
720
+ }, acc;
1039
721
  }, {});
1040
722
  function addItem(acc, item) {
1041
- if (!acc[item.id]) {
1042
- acc[item.id] = item;
1043
- if ("children" in item && item.children) {
1044
- item.children.forEach((childId) => addItem(acc, storiesHashOutOfOrder[childId]));
1045
- item.tags = item.children.reduce((currentTags, childId) => {
1046
- return currentTags === null ? acc[childId].tags : intersect_default(currentTags, acc[childId].tags);
1047
- }, null) || [];
1048
- }
1049
- }
1050
- if (item.type === "component") {
1051
- const firstChild = acc[item.children[0]];
1052
- if (firstChild && "importPath" in firstChild) {
1053
- item.importPath = firstChild.importPath;
1054
- }
723
+ if (acc[item.id] || (acc[item.id] = item, "children" in item && item.children && (item.children.forEach((childId) => addItem(acc, storiesHashOutOfOrder[childId])), item.tags = item.children.reduce((currentTags, childId) => currentTags === null ? acc[childId].tags : intersect_default(currentTags, acc[childId].tags), null) || [])), item.type === "component") {
724
+ let firstChild = acc[item.children[0]];
725
+ firstChild && "importPath" in firstChild && (item.importPath = firstChild.importPath);
1055
726
  }
1056
727
  return acc;
1057
728
  }
1058
- __name(addItem, "addItem");
1059
729
  let storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type !== "root" && !i.parent).reduce((acc, item) => addItem(acc, item), {});
1060
- storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type === "root").reduce(addItem, storiesHash);
1061
- storiesHash = Object.values(storiesHash).reduce((acc, item) => {
730
+ return storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type === "root").reduce(addItem, storiesHash), storiesHash = Object.values(storiesHash).reduce((acc, item) => {
1062
731
  if (item.type === "story" && item.subtype === "test") {
1063
- const story = acc[item.parent];
1064
- const component = acc[story.parent];
732
+ let story = acc[item.parent], component = acc[story.parent];
1065
733
  acc[component.id] = {
1066
734
  ...component,
1067
735
  // Remove test from the component node as it will be attached to the story node instead
1068
736
  children: component.children && component.children.filter((id) => id !== item.id)
1069
- };
1070
- acc[story.id] = {
737
+ }, acc[story.id] = {
1071
738
  ...story,
1072
739
  // Add test to the story node
1073
740
  children: (story.children || []).concat(item.id)
1074
- };
1075
- acc[item.id] = {
741
+ }, acc[item.id] = {
1076
742
  ...item,
1077
743
  depth: item.depth + 1
1078
744
  };
1079
- } else {
745
+ } else
1080
746
  acc[item.id] = item;
1081
- }
1082
747
  return acc;
1083
- }, {});
1084
- return storiesHash;
1085
- }, "transformStoryIndexToStoriesHash");
1086
- var addPreparedStories = /* @__PURE__ */ __name((newHash, oldHash) => {
1087
- if (!oldHash) {
1088
- return newHash;
1089
- }
1090
- return Object.fromEntries(
1091
- Object.entries(newHash).map(([id, newEntry]) => {
1092
- const oldEntry = oldHash[id];
1093
- if (newEntry.type === "story" && oldEntry?.type === "story" && oldEntry.prepared) {
1094
- if ("children" in oldEntry) {
1095
- delete oldEntry.children;
1096
- }
1097
- return [id, { ...oldEntry, ...newEntry, prepared: true }];
1098
- }
1099
- return [id, newEntry];
1100
- })
1101
- );
1102
- }, "addPreparedStories");
1103
- var getComponentLookupList = (0, import_memoizerific.default)(1)((hash) => {
1104
- return Object.entries(hash).reduce((acc, i) => {
1105
- const value = i[1];
1106
- if (value.type === "component") {
1107
- acc.push([...value.children]);
1108
- }
1109
- return acc;
1110
- }, []);
1111
- });
1112
- var getStoriesLookupList = (0, import_memoizerific.default)(1)((hash) => {
1113
- return Object.keys(hash).filter((k) => ["story", "docs"].includes(hash[k].type));
1114
- });
748
+ }, {}), storiesHash;
749
+ }, addPreparedStories = (newHash, oldHash) => oldHash ? Object.fromEntries(
750
+ Object.entries(newHash).map(([id, newEntry]) => {
751
+ let oldEntry = oldHash[id];
752
+ return newEntry.type === "story" && oldEntry?.type === "story" && oldEntry.prepared ? ("children" in oldEntry && delete oldEntry.children, [id, { ...oldEntry, ...newEntry, prepared: !0 }]) : [id, newEntry];
753
+ })
754
+ ) : newHash, getComponentLookupList = (0, import_memoizerific.default)(1)((hash) => Object.entries(hash).reduce((acc, i) => {
755
+ let value = i[1];
756
+ return value.type === "component" && acc.push([...value.children]), acc;
757
+ }, [])), getStoriesLookupList = (0, import_memoizerific.default)(1)((hash) => Object.keys(hash).filter((k) => ["story", "docs"].includes(hash[k].type)));
1115
758
 
1116
759
  // src/manager-api/modules/refs.ts
1117
- var { location, fetch } = global2;
1118
- var getSourceType = /* @__PURE__ */ __name((source, refId) => {
1119
- const { origin: localOrigin, pathname: localPathname } = location;
1120
- const { origin: sourceOrigin, pathname: sourcePathname } = new URL(source);
1121
- const localFull = `${localOrigin + localPathname}`.replace("/iframe.html", "").replace(/\/$/, "");
1122
- const sourceFull = `${sourceOrigin + sourcePathname}`.replace("/iframe.html", "").replace(/\/$/, "");
1123
- if (localFull === sourceFull) {
1124
- return ["local", sourceFull];
1125
- }
1126
- if (refId || source) {
1127
- return ["external", sourceFull];
1128
- }
1129
- return [null, null];
1130
- }, "getSourceType");
1131
- var defaultStoryMapper = /* @__PURE__ */ __name((b, a) => {
1132
- return { ...a, kind: a.kind.replace("|", "/") };
1133
- }, "defaultStoryMapper");
1134
- var addRefIds = /* @__PURE__ */ __name((input, ref) => {
1135
- return Object.entries(input).reduce((acc, [id, item]) => {
1136
- return { ...acc, [id]: { ...item, refId: ref.id } };
1137
- }, {});
1138
- }, "addRefIds");
760
+ var { location, fetch } = global2, getSourceType = (source, refId) => {
761
+ let { origin: localOrigin, pathname: localPathname } = location, { origin: sourceOrigin, pathname: sourcePathname } = new URL(source), localFull = `${localOrigin + localPathname}`.replace("/iframe.html", "").replace(/\/$/, ""), sourceFull = `${sourceOrigin + sourcePathname}`.replace("/iframe.html", "").replace(/\/$/, "");
762
+ return localFull === sourceFull ? ["local", sourceFull] : refId || source ? ["external", sourceFull] : [null, null];
763
+ }, defaultStoryMapper = (b, a) => ({ ...a, kind: a.kind.replace("|", "/") }), addRefIds = (input, ref) => Object.entries(input).reduce((acc, [id, item]) => ({ ...acc, [id]: { ...item, refId: ref.id } }), {});
1139
764
  async function handleRequest(request) {
1140
- if (!request) {
765
+ if (!request)
1141
766
  return {};
1142
- }
1143
767
  try {
1144
- const response = await request;
1145
- if (response === false || response === true) {
768
+ let response = await request;
769
+ if (response === !1 || response === !0)
1146
770
  throw new Error("Unexpected boolean response");
1147
- }
1148
- if (!response.ok) {
771
+ if (!response.ok)
1149
772
  throw new Error(`Unexpected response not OK: ${response.statusText}`);
1150
- }
1151
- const json = await response.json();
1152
- if (json.entries || json.stories) {
1153
- return { storyIndex: json };
1154
- }
1155
- return json;
773
+ let json = await response.json();
774
+ return json.entries || json.stories ? { storyIndex: json } : json;
1156
775
  } catch (err) {
1157
776
  return { indexError: err };
1158
777
  }
1159
778
  }
1160
- __name(handleRequest, "handleRequest");
1161
- var parseUrl = /* @__PURE__ */ __name((url) => {
1162
- const credentialsRegex = /https?:\/\/(.+:.+)@/;
1163
- let cleanUrl = url;
1164
- let authorization;
1165
- const [, credentials] = url.match(credentialsRegex) || [];
1166
- if (credentials) {
1167
- cleanUrl = url.replace(`${credentials}@`, "");
1168
- authorization = btoa(`${credentials}`);
1169
- }
1170
- return {
779
+ var parseUrl = (url) => {
780
+ let credentialsRegex = /https?:\/\/(.+:.+)@/, cleanUrl = url, authorization, [, credentials] = url.match(credentialsRegex) || [];
781
+ return credentials && (cleanUrl = url.replace(`${credentials}@`, ""), authorization = btoa(`${credentials}`)), {
1171
782
  url: cleanUrl,
1172
783
  authorization
1173
784
  };
1174
- }, "parseUrl");
1175
- var map = /* @__PURE__ */ __name((input, ref, options) => {
1176
- const { storyMapper } = options;
1177
- if (storyMapper) {
1178
- return Object.entries(input).reduce((acc, [id, item]) => {
1179
- return { ...acc, [id]: storyMapper(ref, item) };
1180
- }, {});
1181
- }
1182
- return input;
1183
- }, "map");
1184
- var init3 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory, docsOptions = {} }, { runCheck = true } = {}) => {
1185
- const api = {
1186
- findRef: /* @__PURE__ */ __name((source) => {
1187
- const refs2 = api.getRefs();
785
+ }, map = (input, ref, options) => {
786
+ let { storyMapper } = options;
787
+ return storyMapper ? Object.entries(input).reduce((acc, [id, item]) => ({ ...acc, [id]: storyMapper(ref, item) }), {}) : input;
788
+ }, init3 = ({ store: store2, provider, singleStory, docsOptions = {} }, { runCheck = !0 } = {}) => {
789
+ let api = {
790
+ findRef: (source) => {
791
+ let refs2 = api.getRefs();
1188
792
  return Object.values(refs2).find(({ url }) => url.match(source));
1189
- }, "findRef"),
1190
- changeRefVersion: /* @__PURE__ */ __name(async (id, url) => {
1191
- const { versions, title } = api.getRefs()[id];
1192
- const ref = {
793
+ },
794
+ changeRefVersion: async (id, url) => {
795
+ let { versions, title } = api.getRefs()[id], ref = {
1193
796
  id,
1194
797
  url,
1195
798
  versions,
1196
799
  title,
1197
800
  index: {},
1198
801
  filteredIndex: {},
1199
- expanded: true
802
+ expanded: !0
1200
803
  };
1201
- await api.setRef(id, { ...ref, type: "unknown" }, false);
1202
- await api.checkRef(ref);
1203
- }, "changeRefVersion"),
1204
- changeRefState: /* @__PURE__ */ __name((id, previewInitialized) => {
1205
- const { [id]: ref, ...updated } = api.getRefs();
1206
- updated[id] = { ...ref, previewInitialized };
1207
- store2.setState({
804
+ await api.setRef(id, { ...ref, type: "unknown" }, !1), await api.checkRef(ref);
805
+ },
806
+ changeRefState: (id, previewInitialized) => {
807
+ let { [id]: ref, ...updated } = api.getRefs();
808
+ updated[id] = { ...ref, previewInitialized }, store2.setState({
1208
809
  refs: updated
1209
810
  });
1210
- }, "changeRefState"),
1211
- checkRef: /* @__PURE__ */ __name(async (ref) => {
1212
- const { id, url, version: version2, type } = ref;
1213
- const isPublic = type === "server-checked";
1214
- const loadedData = {};
1215
- const query = version2 ? `?version=${version2}` : "";
1216
- const credentials = isPublic ? "omit" : "include";
1217
- const urlParseResult = parseUrl(url);
1218
- const headers = {
811
+ },
812
+ checkRef: async (ref) => {
813
+ let { id, url, version: version2, type } = ref, isPublic = type === "server-checked", loadedData = {}, query = version2 ? `?version=${version2}` : "", credentials = isPublic ? "omit" : "include", urlParseResult = parseUrl(url), headers = {
1219
814
  Accept: "application/json"
1220
815
  };
1221
- if (urlParseResult.authorization) {
1222
- Object.assign(headers, {
1223
- Authorization: `Basic ${urlParseResult.authorization}`
1224
- });
1225
- }
1226
- const [indexResult, storiesResult] = await Promise.all(
816
+ urlParseResult.authorization && Object.assign(headers, {
817
+ Authorization: `Basic ${urlParseResult.authorization}`
818
+ });
819
+ let [indexResult, storiesResult] = await Promise.all(
1227
820
  ["index.json", "stories.json"].map(
1228
821
  async (file) => handleRequest(
1229
822
  fetch(`${urlParseResult.url}/${file}${query}`, {
@@ -1234,20 +827,19 @@ var init3 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory, docs
1234
827
  )
1235
828
  );
1236
829
  if (!indexResult.indexError || !storiesResult.indexError) {
1237
- const metadata = await handleRequest(
830
+ let metadata = await handleRequest(
1238
831
  fetch(`${urlParseResult.url}/metadata.json${query}`, {
1239
832
  headers,
1240
833
  credentials,
1241
834
  cache: "no-cache"
1242
- }).catch(() => false)
835
+ }).catch(() => !1)
1243
836
  );
1244
837
  Object.assign(loadedData, {
1245
838
  ...indexResult.indexError ? storiesResult : indexResult,
1246
839
  ...!metadata.indexError && metadata
1247
840
  });
1248
- } else if (!isPublic) {
1249
- loadedData.indexError = {
1250
- message: dedent`
841
+ } else isPublic || (loadedData.indexError = {
842
+ message: dedent`
1251
843
  Error: Loading of ref failed
1252
844
  at fetch (lib/api/src/modules/refs.ts)
1253
845
 
@@ -1258,95 +850,64 @@ var init3 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory, docs
1258
850
 
1259
851
  Please check your dev-tools network tab.
1260
852
  `
1261
- };
1262
- }
1263
- const versions = ref.versions && Object.keys(ref.versions).length ? ref.versions : loadedData.versions;
853
+ });
854
+ let versions = ref.versions && Object.keys(ref.versions).length ? ref.versions : loadedData.versions;
1264
855
  await api.setRef(id, {
1265
856
  id,
1266
857
  url: urlParseResult.url,
1267
858
  ...loadedData,
1268
859
  ...versions ? { versions } : {},
1269
- type: !loadedData.storyIndex ? "auto-inject" : "lazy"
860
+ type: loadedData.storyIndex ? "lazy" : "auto-inject"
1270
861
  });
1271
- }, "checkRef"),
1272
- getRefs: /* @__PURE__ */ __name(() => {
1273
- const { refs: refs2 = {} } = store2.getState();
862
+ },
863
+ getRefs: () => {
864
+ let { refs: refs2 = {} } = store2.getState();
1274
865
  return refs2;
1275
- }, "getRefs"),
1276
- setRef: /* @__PURE__ */ __name(async (id, { storyIndex, setStoriesData, ...rest }, ready = false) => {
1277
- if (singleStory) {
866
+ },
867
+ setRef: async (id, { storyIndex, setStoriesData, ...rest }, ready = !1) => {
868
+ if (singleStory)
1278
869
  return;
1279
- }
1280
- let internal_index;
1281
- let index;
1282
- let filteredIndex;
1283
- const { filters } = store2.getState();
1284
- const { storyMapper = defaultStoryMapper } = provider.getConfig();
1285
- const ref = api.getRefs()[id];
1286
- if (storyIndex || setStoriesData) {
1287
- internal_index = setStoriesData ? transformSetStoriesStoryDataToPreparedStoryIndex(
1288
- map(setStoriesData, ref, { storyMapper })
1289
- ) : storyIndex;
1290
- filteredIndex = transformStoryIndexToStoriesHash(storyIndex, {
1291
- provider,
1292
- docsOptions,
1293
- filters,
1294
- allStatuses: {}
1295
- });
1296
- index = transformStoryIndexToStoriesHash(storyIndex, {
1297
- provider,
1298
- docsOptions,
1299
- filters: {},
1300
- allStatuses: {}
1301
- });
1302
- }
1303
- if (index) {
1304
- index = addRefIds(index, ref);
1305
- }
1306
- if (filteredIndex) {
1307
- filteredIndex = addRefIds(filteredIndex, ref);
1308
- }
1309
- await api.updateRef(id, { ...ref, ...rest, index, filteredIndex, internal_index });
1310
- }, "setRef"),
1311
- updateRef: /* @__PURE__ */ __name(async (id, data) => {
1312
- const { [id]: ref, ...updated } = api.getRefs();
870
+ let internal_index, index, filteredIndex, { filters } = store2.getState(), { storyMapper = defaultStoryMapper } = provider.getConfig(), ref = api.getRefs()[id];
871
+ (storyIndex || setStoriesData) && (internal_index = setStoriesData ? transformSetStoriesStoryDataToPreparedStoryIndex(
872
+ map(setStoriesData, ref, { storyMapper })
873
+ ) : storyIndex, filteredIndex = transformStoryIndexToStoriesHash(storyIndex, {
874
+ provider,
875
+ docsOptions,
876
+ filters,
877
+ allStatuses: {}
878
+ }), index = transformStoryIndexToStoriesHash(storyIndex, {
879
+ provider,
880
+ docsOptions,
881
+ filters: {},
882
+ allStatuses: {}
883
+ })), index && (index = addRefIds(index, ref)), filteredIndex && (filteredIndex = addRefIds(filteredIndex, ref)), await api.updateRef(id, { ...ref, ...rest, index, filteredIndex, internal_index });
884
+ },
885
+ updateRef: async (id, data) => {
886
+ let { [id]: ref, ...updated } = api.getRefs();
1313
887
  updated[id] = { ...ref, ...data };
1314
- const ordered = Object.keys(initialState).reduce((obj, key) => {
1315
- obj[key] = updated[key];
1316
- return obj;
1317
- }, {});
888
+ let ordered = Object.keys(initialState).reduce((obj, key) => (obj[key] = updated[key], obj), {});
1318
889
  await store2.setState({
1319
890
  refs: ordered
1320
891
  });
1321
- }, "updateRef")
1322
- };
1323
- const refs = !singleStory && global2.REFS || {};
1324
- const initialState = refs;
1325
- if (runCheck) {
1326
- new Promise(async (resolve) => {
1327
- for (const ref of Object.values(refs)) {
1328
- await api.checkRef({ ...ref, stories: {} });
1329
- }
1330
- resolve(void 0);
1331
- });
1332
- }
1333
- return {
892
+ }
893
+ }, refs = !singleStory && global2.REFS || {}, initialState = refs;
894
+ return runCheck && new Promise(async (resolve) => {
895
+ for (let ref of Object.values(refs))
896
+ await api.checkRef({ ...ref, stories: {} });
897
+ resolve(void 0);
898
+ }), {
1334
899
  api,
1335
900
  state: {
1336
901
  refs: initialState
1337
902
  }
1338
903
  };
1339
- }, "init");
904
+ };
1340
905
 
1341
906
  // src/manager-api/lib/events.ts
1342
- var getEventMetadata = /* @__PURE__ */ __name((context, fullAPI) => {
1343
- const { source, refId, type } = context;
1344
- const [sourceType, sourceLocation] = getSourceType(source, refId);
1345
- let ref;
1346
- if (refId || sourceType === "external") {
1347
- ref = refId && fullAPI.getRefs()[refId] ? fullAPI.getRefs()[refId] : fullAPI.findRef(sourceLocation);
1348
- }
1349
- const meta = {
907
+ var getEventMetadata = (context, fullAPI) => {
908
+ let { source, refId, type } = context, [sourceType, sourceLocation] = getSourceType(source, refId), ref;
909
+ (refId || sourceType === "external") && (ref = refId && fullAPI.getRefs()[refId] ? fullAPI.getRefs()[refId] : fullAPI.findRef(sourceLocation));
910
+ let meta = {
1350
911
  source,
1351
912
  sourceType,
1352
913
  sourceLocation,
@@ -1354,23 +915,20 @@ var getEventMetadata = /* @__PURE__ */ __name((context, fullAPI) => {
1354
915
  ref,
1355
916
  type
1356
917
  };
1357
- switch (true) {
1358
- case typeof refId === "string":
918
+ switch (!0) {
919
+ case typeof refId == "string":
1359
920
  case sourceType === "local":
1360
- case sourceType === "external": {
921
+ case sourceType === "external":
1361
922
  return meta;
1362
- }
1363
923
  // if we couldn't find the source, something risky happened, we ignore the input, and log a warning
1364
- default: {
1365
- logger3.warn(`Received a ${type} frame that was not configured as a ref`);
1366
- return null;
1367
- }
924
+ default:
925
+ return logger3.warn(`Received a ${type} frame that was not configured as a ref`), null;
1368
926
  }
1369
- }, "getEventMetadata");
927
+ };
1370
928
 
1371
929
  // src/manager-api/modules/globals.ts
1372
- var init4 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
1373
- const api = {
930
+ var init4 = ({ store: store2, fullAPI, provider }) => {
931
+ let api = {
1374
932
  getGlobals() {
1375
933
  return store2.getState().globals;
1376
934
  },
@@ -1391,66 +949,42 @@ var init4 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
1391
949
  }
1392
950
  });
1393
951
  }
1394
- };
1395
- const state = {
952
+ }, state = {
1396
953
  globals: {},
1397
954
  userGlobals: {},
1398
955
  storyGlobals: {},
1399
956
  globalTypes: {}
1400
- };
1401
- const updateGlobals = /* @__PURE__ */ __name(({
957
+ }, updateGlobals = ({
1402
958
  globals,
1403
959
  storyGlobals,
1404
960
  userGlobals
1405
961
  }) => {
1406
- const {
962
+ let {
1407
963
  globals: currentGlobals,
1408
964
  userGlobals: currentUserGlobals,
1409
965
  storyGlobals: currentStoryGlobals
1410
966
  } = store2.getState();
1411
- if (!dequal(globals, currentGlobals)) {
1412
- store2.setState({ globals });
1413
- }
1414
- if (!dequal(userGlobals, currentUserGlobals)) {
1415
- store2.setState({ userGlobals });
1416
- }
1417
- if (!dequal(storyGlobals, currentStoryGlobals)) {
1418
- store2.setState({ storyGlobals });
1419
- }
1420
- }, "updateGlobals");
1421
- provider.channel?.on(
967
+ dequal(globals, currentGlobals) || store2.setState({ globals }), dequal(userGlobals, currentUserGlobals) || store2.setState({ userGlobals }), dequal(storyGlobals, currentStoryGlobals) || store2.setState({ storyGlobals });
968
+ };
969
+ return provider.channel?.on(
1422
970
  GLOBALS_UPDATED,
1423
- /* @__PURE__ */ __name(function handleGlobalsUpdated({ globals, storyGlobals, userGlobals }) {
1424
- const { ref } = getEventMetadata(this, fullAPI);
1425
- if (!ref) {
1426
- updateGlobals({ globals, storyGlobals, userGlobals });
1427
- } else {
1428
- logger4.warn(
1429
- "received a GLOBALS_UPDATED from a non-local ref. This is not currently supported."
1430
- );
1431
- }
1432
- }, "handleGlobalsUpdated")
1433
- );
1434
- provider.channel?.on(
971
+ function({ globals, storyGlobals, userGlobals }) {
972
+ let { ref } = getEventMetadata(this, fullAPI);
973
+ ref ? logger4.warn(
974
+ "received a GLOBALS_UPDATED from a non-local ref. This is not currently supported."
975
+ ) : updateGlobals({ globals, storyGlobals, userGlobals });
976
+ }
977
+ ), provider.channel?.on(
1435
978
  SET_GLOBALS,
1436
- /* @__PURE__ */ __name(function handleSetGlobals({ globals, globalTypes }) {
1437
- const { ref } = getEventMetadata(this, fullAPI);
1438
- const currentGlobals = store2.getState()?.globals;
1439
- if (!ref) {
1440
- store2.setState({ globals, userGlobals: globals, globalTypes });
1441
- } else if (Object.keys(globals).length > 0) {
1442
- logger4.warn("received globals from a non-local ref. This is not currently supported.");
1443
- }
1444
- if (currentGlobals && Object.keys(currentGlobals).length !== 0 && !dequal(globals, currentGlobals)) {
1445
- api.updateGlobals(currentGlobals);
1446
- }
1447
- }, "handleSetGlobals")
1448
- );
1449
- return {
979
+ function({ globals, globalTypes }) {
980
+ let { ref } = getEventMetadata(this, fullAPI), currentGlobals = store2.getState()?.globals;
981
+ ref ? Object.keys(globals).length > 0 && logger4.warn("received globals from a non-local ref. This is not currently supported.") : store2.setState({ globals, userGlobals: globals, globalTypes }), currentGlobals && Object.keys(currentGlobals).length !== 0 && !dequal(globals, currentGlobals) && api.updateGlobals(currentGlobals);
982
+ }
983
+ ), {
1450
984
  api,
1451
985
  state
1452
986
  };
1453
- }, "init");
987
+ };
1454
988
 
1455
989
  // src/manager-api/modules/layout.ts
1456
990
  var layout_exports = {};
@@ -1463,20 +997,17 @@ __export(layout_exports, {
1463
997
  import { SET_CONFIG as SET_CONFIG2 } from "storybook/internal/core-events";
1464
998
  import { global as global3 } from "@storybook/global";
1465
999
  import { create } from "storybook/theming/create";
1466
- var { document: document2 } = global3;
1467
- var isFunction = /* @__PURE__ */ __name((val) => typeof val === "function", "isFunction");
1468
- var ActiveTabs = {
1000
+ var { document: document2 } = global3, isFunction = (val) => typeof val == "function", ActiveTabs = {
1469
1001
  SIDEBAR: "sidebar",
1470
1002
  CANVAS: "canvas",
1471
1003
  ADDONS: "addons"
1472
- };
1473
- var defaultLayoutState = {
1004
+ }, defaultLayoutState = {
1474
1005
  ui: {
1475
- enableShortcuts: true
1006
+ enableShortcuts: !0
1476
1007
  },
1477
1008
  layout: {
1478
1009
  initialActive: ActiveTabs.CANVAS,
1479
- showToolbar: true,
1010
+ showToolbar: !0,
1480
1011
  navSize: 300,
1481
1012
  bottomPanelHeight: 300,
1482
1013
  rightPanelWidth: 400,
@@ -1486,7 +1017,7 @@ var defaultLayoutState = {
1486
1017
  rightPanelWidth: 400
1487
1018
  },
1488
1019
  panelPosition: "bottom",
1489
- showTabs: true
1020
+ showTabs: !0
1490
1021
  },
1491
1022
  layoutCustomisations: {
1492
1023
  showSidebar: void 0,
@@ -1494,40 +1025,24 @@ var defaultLayoutState = {
1494
1025
  },
1495
1026
  selectedPanel: void 0,
1496
1027
  theme: create()
1497
- };
1498
- var focusableUIElements = {
1028
+ }, focusableUIElements = {
1499
1029
  storySearchField: "storybook-explorer-searchfield",
1500
1030
  storyListMenu: "storybook-explorer-menu",
1501
1031
  storyPanelRoot: "storybook-panel-root"
1502
- };
1503
- var getIsNavShown = /* @__PURE__ */ __name((state) => {
1504
- return state.layout.navSize > 0;
1505
- }, "getIsNavShown");
1506
- var getIsPanelShown = /* @__PURE__ */ __name((state) => {
1507
- const { bottomPanelHeight, rightPanelWidth, panelPosition } = state.layout;
1032
+ }, getIsNavShown = (state) => state.layout.navSize > 0, getIsPanelShown = (state) => {
1033
+ let { bottomPanelHeight, rightPanelWidth, panelPosition } = state.layout;
1508
1034
  return panelPosition === "bottom" && bottomPanelHeight > 0 || panelPosition === "right" && rightPanelWidth > 0;
1509
- }, "getIsPanelShown");
1510
- var getIsFullscreen = /* @__PURE__ */ __name((state) => {
1511
- return !getIsNavShown(state) && !getIsPanelShown(state);
1512
- }, "getIsFullscreen");
1513
- var getRecentVisibleSizes = /* @__PURE__ */ __name((layoutState) => {
1514
- return {
1515
- navSize: layoutState.navSize > 0 ? layoutState.navSize : layoutState.recentVisibleSizes.navSize,
1516
- bottomPanelHeight: layoutState.bottomPanelHeight > 0 ? layoutState.bottomPanelHeight : layoutState.recentVisibleSizes.bottomPanelHeight,
1517
- rightPanelWidth: layoutState.rightPanelWidth > 0 ? layoutState.rightPanelWidth : layoutState.recentVisibleSizes.rightPanelWidth
1518
- };
1519
- }, "getRecentVisibleSizes");
1520
- var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) => {
1521
- const api = {
1035
+ }, getIsFullscreen = (state) => !getIsNavShown(state) && !getIsPanelShown(state), getRecentVisibleSizes = (layoutState) => ({
1036
+ navSize: layoutState.navSize > 0 ? layoutState.navSize : layoutState.recentVisibleSizes.navSize,
1037
+ bottomPanelHeight: layoutState.bottomPanelHeight > 0 ? layoutState.bottomPanelHeight : layoutState.recentVisibleSizes.bottomPanelHeight,
1038
+ rightPanelWidth: layoutState.rightPanelWidth > 0 ? layoutState.rightPanelWidth : layoutState.recentVisibleSizes.rightPanelWidth
1039
+ }), init5 = ({ store: store2, provider, singleStory }) => {
1040
+ let api = {
1522
1041
  toggleFullscreen(nextState) {
1523
1042
  return store2.setState(
1524
1043
  (state) => {
1525
- const isFullscreen = getIsFullscreen(state);
1526
- const shouldFullscreen = typeof nextState === "boolean" ? nextState : !isFullscreen;
1527
- if (shouldFullscreen === isFullscreen) {
1528
- return { layout: state.layout };
1529
- }
1530
- return shouldFullscreen ? {
1044
+ let isFullscreen = getIsFullscreen(state), shouldFullscreen = typeof nextState == "boolean" ? nextState : !isFullscreen;
1045
+ return shouldFullscreen === isFullscreen ? { layout: state.layout } : shouldFullscreen ? {
1531
1046
  layout: {
1532
1047
  ...state.layout,
1533
1048
  navSize: 0,
@@ -1550,12 +1065,8 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1550
1065
  togglePanel(nextState) {
1551
1066
  return store2.setState(
1552
1067
  (state) => {
1553
- const isPanelShown = getIsPanelShown(state);
1554
- const shouldShowPanel = typeof nextState === "boolean" ? nextState : !isPanelShown;
1555
- if (shouldShowPanel === isPanelShown) {
1556
- return { layout: state.layout };
1557
- }
1558
- return shouldShowPanel ? {
1068
+ let isPanelShown = getIsPanelShown(state), shouldShowPanel = typeof nextState == "boolean" ? nextState : !isPanelShown;
1069
+ return shouldShowPanel === isPanelShown ? { layout: state.layout } : shouldShowPanel ? {
1559
1070
  layout: {
1560
1071
  ...state.layout,
1561
1072
  bottomPanelHeight: state.layout.recentVisibleSizes.bottomPanelHeight,
@@ -1576,7 +1087,7 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1576
1087
  togglePanelPosition(position) {
1577
1088
  return store2.setState(
1578
1089
  (state) => {
1579
- const nextPosition = position || (state.layout.panelPosition === "right" ? "bottom" : "right");
1090
+ let nextPosition = position || (state.layout.panelPosition === "right" ? "bottom" : "right");
1580
1091
  return {
1581
1092
  layout: {
1582
1093
  ...state.layout,
@@ -1592,15 +1103,10 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1592
1103
  toggleNav(nextState) {
1593
1104
  return store2.setState(
1594
1105
  (state) => {
1595
- if (state.singleStory) {
1106
+ if (state.singleStory)
1596
1107
  return { layout: state.layout };
1597
- }
1598
- const isNavShown = getIsNavShown(state);
1599
- const shouldShowNav = typeof nextState === "boolean" ? nextState : !isNavShown;
1600
- if (shouldShowNav === isNavShown) {
1601
- return { layout: state.layout };
1602
- }
1603
- return shouldShowNav ? {
1108
+ let isNavShown = getIsNavShown(state), shouldShowNav = typeof nextState == "boolean" ? nextState : !isNavShown;
1109
+ return shouldShowNav === isNavShown ? { layout: state.layout } : shouldShowNav ? {
1604
1110
  layout: {
1605
1111
  ...state.layout,
1606
1112
  navSize: state.layout.recentVisibleSizes.navSize
@@ -1619,7 +1125,7 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1619
1125
  toggleToolbar(toggled) {
1620
1126
  return store2.setState(
1621
1127
  (state) => {
1622
- const value = typeof toggled !== "undefined" ? toggled : !state.layout.showToolbar;
1128
+ let value = typeof toggled < "u" ? toggled : !state.layout.showToolbar;
1623
1129
  return {
1624
1130
  layout: {
1625
1131
  ...state.layout,
@@ -1637,7 +1143,7 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1637
1143
  }) {
1638
1144
  return store2.setState(
1639
1145
  (state) => {
1640
- const nextLayoutState = {
1146
+ let nextLayoutState = {
1641
1147
  ...state.layout,
1642
1148
  navSize: navSize ?? state.layout.navSize,
1643
1149
  bottomPanelHeight: bottomPanelHeight ?? state.layout.bottomPanelHeight,
@@ -1664,42 +1170,24 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1664
1170
  * @param select Whether to call select() on the element after focusing it.
1665
1171
  */
1666
1172
  focusOnUIElement(elementId, select) {
1667
- if (!elementId) {
1173
+ if (!elementId)
1668
1174
  return;
1669
- }
1670
- const startTime = Date.now();
1671
- const maxDuration = 500;
1672
- const pollInterval = 50;
1673
- const attemptFocus = /* @__PURE__ */ __name(() => {
1674
- const element = document2.getElementById(elementId);
1675
- if (!element) {
1676
- return false;
1677
- }
1678
- element.focus();
1679
- if (element !== document2.activeElement) {
1680
- return false;
1681
- }
1682
- if (select) {
1683
- element.select?.();
1684
- }
1685
- return true;
1686
- }, "attemptFocus");
1687
- if (attemptFocus()) {
1175
+ let startTime = Date.now(), maxDuration = 500, pollInterval = 50, attemptFocus = () => {
1176
+ let element = document2.getElementById(elementId);
1177
+ return !element || (element.focus(), element !== document2.activeElement) ? !1 : (select && element.select?.(), !0);
1178
+ };
1179
+ if (attemptFocus())
1688
1180
  return;
1689
- }
1690
- const intervalId = setInterval(() => {
1691
- const elapsed = Date.now() - startTime;
1692
- if (elapsed >= maxDuration) {
1181
+ let intervalId = setInterval(() => {
1182
+ if (Date.now() - startTime >= maxDuration) {
1693
1183
  clearInterval(intervalId);
1694
1184
  return;
1695
1185
  }
1696
- if (attemptFocus()) {
1697
- clearInterval(intervalId);
1698
- }
1186
+ attemptFocus() && clearInterval(intervalId);
1699
1187
  }, pollInterval);
1700
1188
  },
1701
1189
  getInitialOptions() {
1702
- const { theme, selectedPanel, layoutCustomisations, ...options } = provider.getConfig();
1190
+ let { theme, selectedPanel, layoutCustomisations, ...options } = provider.getConfig();
1703
1191
  return {
1704
1192
  ...defaultLayoutState,
1705
1193
  layout: {
@@ -1728,115 +1216,78 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1728
1216
  return getIsNavShown(store2.getState());
1729
1217
  },
1730
1218
  getShowToolbarWithCustomisations(showToolbar) {
1731
- const state = store2.getState();
1732
- if (isFunction(state.layoutCustomisations.showToolbar)) {
1733
- return state.layoutCustomisations.showToolbar(state, showToolbar) ?? showToolbar;
1734
- }
1735
- return showToolbar;
1219
+ let state = store2.getState();
1220
+ return isFunction(state.layoutCustomisations.showToolbar) ? state.layoutCustomisations.showToolbar(state, showToolbar) ?? showToolbar : showToolbar;
1736
1221
  },
1737
1222
  getShowPanelWithCustomisations(showPanel) {
1738
- const state = store2.getState();
1739
- if (isFunction(state.layoutCustomisations.showPanel)) {
1740
- return state.layoutCustomisations.showPanel(state, showPanel) ?? showPanel;
1741
- }
1742
- return showPanel;
1223
+ let state = store2.getState();
1224
+ return isFunction(state.layoutCustomisations.showPanel) ? state.layoutCustomisations.showPanel(state, showPanel) ?? showPanel : showPanel;
1743
1225
  },
1744
1226
  getNavSizeWithCustomisations(navSize) {
1745
- const state = store2.getState();
1227
+ let state = store2.getState();
1746
1228
  if (isFunction(state.layoutCustomisations.showSidebar)) {
1747
- const shouldShowNav = state.layoutCustomisations.showSidebar(state, navSize !== 0);
1748
- if (navSize === 0 && shouldShowNav === true) {
1229
+ let shouldShowNav = state.layoutCustomisations.showSidebar(state, navSize !== 0);
1230
+ if (navSize === 0 && shouldShowNav === !0)
1749
1231
  return state.layout.recentVisibleSizes.navSize;
1750
- } else if (navSize !== 0 && shouldShowNav === false) {
1232
+ if (navSize !== 0 && shouldShowNav === !1)
1751
1233
  return 0;
1752
- }
1753
1234
  }
1754
1235
  return navSize;
1755
1236
  },
1756
- setOptions: /* @__PURE__ */ __name((options) => {
1757
- const { layout, ui, selectedPanel, theme } = store2.getState();
1758
- if (!options) {
1237
+ setOptions: (options) => {
1238
+ let { layout, ui, selectedPanel, theme } = store2.getState();
1239
+ if (!options)
1759
1240
  return;
1760
- }
1761
- const updatedLayout = {
1241
+ let updatedLayout = {
1762
1242
  ...layout,
1763
1243
  ...options.layout || {},
1764
1244
  ...pick(options, Object.keys(layout)),
1765
1245
  ...singleStory && { navSize: 0 }
1766
- };
1767
- const updatedUi = {
1246
+ }, updatedUi = {
1768
1247
  ...ui,
1769
1248
  ...options.ui,
1770
1249
  ...toMerged(options.ui || {}, pick(options, Object.keys(ui)))
1771
- };
1772
- const updatedTheme = {
1250
+ }, updatedTheme = {
1773
1251
  ...theme,
1774
1252
  ...options.theme
1775
- };
1776
- const modification = {};
1777
- if (!isEqual(ui, updatedUi)) {
1778
- modification.ui = updatedUi;
1779
- }
1780
- if (!isEqual(layout, updatedLayout)) {
1781
- modification.layout = updatedLayout;
1782
- }
1783
- if (options.selectedPanel && !isEqual(selectedPanel, options.selectedPanel)) {
1784
- modification.selectedPanel = options.selectedPanel;
1785
- }
1786
- if (Object.keys(modification).length) {
1787
- store2.setState(modification, { persistence: "permanent" });
1788
- }
1789
- if (!isEqual(theme, updatedTheme)) {
1790
- store2.setState({ theme: updatedTheme });
1791
- }
1792
- }, "setOptions")
1793
- };
1794
- const persisted = pick(store2.getState(), ["layout", "selectedPanel"]);
1795
- provider.channel?.on(SET_CONFIG2, () => {
1253
+ }, modification = {};
1254
+ isEqual(ui, updatedUi) || (modification.ui = updatedUi), isEqual(layout, updatedLayout) || (modification.layout = updatedLayout), options.selectedPanel && !isEqual(selectedPanel, options.selectedPanel) && (modification.selectedPanel = options.selectedPanel), Object.keys(modification).length && store2.setState(modification, { persistence: "permanent" }), isEqual(theme, updatedTheme) || store2.setState({ theme: updatedTheme });
1255
+ }
1256
+ }, persisted = pick(store2.getState(), ["layout", "selectedPanel"]);
1257
+ return provider.channel?.on(SET_CONFIG2, () => {
1796
1258
  api.setOptions(merge_default(api.getInitialOptions(), persisted));
1797
- });
1798
- return {
1259
+ }), {
1799
1260
  api,
1800
1261
  state: merge_default(api.getInitialOptions(), persisted)
1801
1262
  };
1802
- }, "init");
1263
+ };
1803
1264
 
1804
1265
  // src/manager-api/modules/notifications.ts
1805
1266
  var notifications_exports = {};
1806
1267
  __export(notifications_exports, {
1807
1268
  init: () => init6
1808
1269
  });
1809
- var init6 = /* @__PURE__ */ __name(({ store: store2 }) => {
1810
- const api = {
1811
- addNotification: /* @__PURE__ */ __name((newNotification) => {
1270
+ var init6 = ({ store: store2 }) => ({
1271
+ api: {
1272
+ addNotification: (newNotification) => {
1812
1273
  store2.setState(({ notifications }) => {
1813
- const [existing, others] = partition(notifications, (n) => n.id === newNotification.id);
1814
- existing.forEach((notification) => {
1815
- if (notification.onClear) {
1816
- notification.onClear({ dismissed: false, timeout: false });
1817
- }
1818
- });
1819
- return { notifications: [...others, newNotification] };
1274
+ let [existing, others] = partition(notifications, (n) => n.id === newNotification.id);
1275
+ return existing.forEach((notification) => {
1276
+ notification.onClear && notification.onClear({ dismissed: !1, timeout: !1 });
1277
+ }), { notifications: [...others, newNotification] };
1820
1278
  });
1821
- }, "addNotification"),
1822
- clearNotification: /* @__PURE__ */ __name((notificationId) => {
1279
+ },
1280
+ clearNotification: (notificationId) => {
1823
1281
  store2.setState(({ notifications }) => {
1824
- const [matching, others] = partition(notifications, (n) => n.id === notificationId);
1825
- matching.forEach((notification) => {
1826
- if (notification.onClear) {
1827
- notification.onClear({ dismissed: false, timeout: false });
1828
- }
1829
- });
1830
- return { notifications: others };
1282
+ let [matching, others] = partition(notifications, (n) => n.id === notificationId);
1283
+ return matching.forEach((notification) => {
1284
+ notification.onClear && notification.onClear({ dismissed: !1, timeout: !1 });
1285
+ }), { notifications: others };
1831
1286
  });
1832
- }, "clearNotification")
1833
- };
1834
- const state = { notifications: [] };
1835
- return {
1836
- api,
1837
- state
1838
- };
1839
- }, "init");
1287
+ }
1288
+ },
1289
+ state: { notifications: [] }
1290
+ });
1840
1291
 
1841
1292
  // src/manager-api/modules/open-in-editor.tsx
1842
1293
  var open_in_editor_exports = {};
@@ -1849,101 +1300,80 @@ import {
1849
1300
  OPEN_IN_EDITOR_RESPONSE
1850
1301
  } from "storybook/internal/core-events";
1851
1302
  import { FailedIcon } from "@storybook/icons";
1852
- var init7 = /* @__PURE__ */ __name(({ provider, fullAPI }) => {
1853
- const api = {
1303
+ var init7 = ({ provider, fullAPI }) => ({
1304
+ api: {
1854
1305
  openInEditor(payload) {
1855
1306
  return new Promise((resolve) => {
1856
- const { file, line, column } = payload;
1857
- const handler = /* @__PURE__ */ __name((res) => {
1858
- if (res.file === file && res.line === line && res.column === column) {
1859
- provider.channel?.off(OPEN_IN_EDITOR_RESPONSE, handler);
1860
- resolve(res);
1861
- }
1862
- }, "handler");
1863
- provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, handler);
1864
- provider.channel?.emit(OPEN_IN_EDITOR_REQUEST, payload);
1307
+ let { file, line, column } = payload, handler = (res) => {
1308
+ res.file === file && res.line === line && res.column === column && (provider.channel?.off(OPEN_IN_EDITOR_RESPONSE, handler), resolve(res));
1309
+ };
1310
+ provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, handler), provider.channel?.emit(OPEN_IN_EDITOR_REQUEST, payload);
1865
1311
  });
1866
1312
  }
1867
- };
1868
- const state = { notifications: [] };
1869
- return {
1870
- api,
1871
- state,
1872
- init: /* @__PURE__ */ __name(async () => {
1873
- const { color } = await import("../theming/index.js");
1874
- provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, (payload) => {
1875
- if (payload.error !== null) {
1876
- fullAPI.addNotification({
1877
- id: "open-in-editor-error",
1878
- content: {
1879
- headline: "Failed to open in editor",
1880
- subHeadline: payload.error || "Check the Storybook process on the command line for more details."
1881
- },
1882
- icon: React.createElement(FailedIcon, { color: color.negative }),
1883
- duration: 8e3
1884
- });
1885
- }
1313
+ },
1314
+ state: { notifications: [] },
1315
+ init: async () => {
1316
+ let { color } = await import("../theming/index.js");
1317
+ provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, (payload) => {
1318
+ payload.error !== null && fullAPI.addNotification({
1319
+ id: "open-in-editor-error",
1320
+ content: {
1321
+ headline: "Failed to open in editor",
1322
+ subHeadline: payload.error || "Check the Storybook process on the command line for more details."
1323
+ },
1324
+ icon: React.createElement(FailedIcon, { color: color.negative }),
1325
+ duration: 8e3
1886
1326
  });
1887
- }, "init")
1888
- };
1889
- }, "init");
1327
+ });
1328
+ }
1329
+ });
1890
1330
 
1891
1331
  // src/manager-api/modules/provider.ts
1892
1332
  var provider_exports = {};
1893
1333
  __export(provider_exports, {
1894
1334
  init: () => init8
1895
1335
  });
1896
- var init8 = /* @__PURE__ */ __name(({ provider, fullAPI }) => {
1897
- return {
1898
- api: provider.renderPreview ? { renderPreview: provider.renderPreview } : {},
1899
- state: {},
1900
- init: /* @__PURE__ */ __name(() => {
1901
- provider.handleAPI(fullAPI);
1902
- }, "init")
1903
- };
1904
- }, "init");
1336
+ var init8 = ({ provider, fullAPI }) => ({
1337
+ api: provider.renderPreview ? { renderPreview: provider.renderPreview } : {},
1338
+ state: {},
1339
+ init: () => {
1340
+ provider.handleAPI(fullAPI);
1341
+ }
1342
+ });
1905
1343
 
1906
1344
  // src/manager-api/modules/settings.ts
1907
1345
  var settings_exports = {};
1908
1346
  __export(settings_exports, {
1909
1347
  init: () => init9
1910
1348
  });
1911
- var init9 = /* @__PURE__ */ __name(({ store: store2, navigate, fullAPI }) => {
1912
- const isSettingsScreenActive = /* @__PURE__ */ __name(() => {
1913
- const { path } = fullAPI.getUrlState();
1914
- return !!(path || "").match(/^\/settings/);
1915
- }, "isSettingsScreenActive");
1916
- const api = {
1917
- closeSettings: /* @__PURE__ */ __name(() => {
1918
- const {
1349
+ var init9 = ({ store: store2, navigate, fullAPI }) => ({
1350
+ state: { settings: { lastTrackedStoryId: null } },
1351
+ api: {
1352
+ closeSettings: () => {
1353
+ let {
1919
1354
  settings: { lastTrackedStoryId }
1920
1355
  } = store2.getState();
1921
- if (lastTrackedStoryId) {
1922
- fullAPI.selectStory(lastTrackedStoryId);
1923
- } else {
1924
- fullAPI.selectFirstStory();
1925
- }
1926
- }, "closeSettings"),
1927
- changeSettingsTab: /* @__PURE__ */ __name((path) => {
1356
+ lastTrackedStoryId ? fullAPI.selectStory(lastTrackedStoryId) : fullAPI.selectFirstStory();
1357
+ },
1358
+ changeSettingsTab: (path) => {
1928
1359
  navigate(`/settings/${path}`);
1929
- }, "changeSettingsTab"),
1930
- isSettingsScreenActive,
1360
+ },
1361
+ isSettingsScreenActive: () => {
1362
+ let { path } = fullAPI.getUrlState();
1363
+ return !!(path || "").match(/^\/settings/);
1364
+ },
1931
1365
  retrieveSelection() {
1932
- const { settings } = store2.getState();
1366
+ let { settings } = store2.getState();
1933
1367
  return settings.lastTrackedStoryId;
1934
1368
  },
1935
- storeSelection: /* @__PURE__ */ __name(async () => {
1936
- const { storyId, settings } = store2.getState();
1369
+ storeSelection: async () => {
1370
+ let { storyId, settings } = store2.getState();
1937
1371
  await store2.setState({
1938
1372
  settings: { ...settings, lastTrackedStoryId: storyId }
1939
1373
  });
1940
- }, "storeSelection")
1941
- };
1942
- return {
1943
- state: { settings: { lastTrackedStoryId: null } },
1944
- api
1945
- };
1946
- }, "init");
1374
+ }
1375
+ }
1376
+ });
1947
1377
 
1948
1378
  // src/manager-api/modules/shortcuts.ts
1949
1379
  var shortcuts_exports = {};
@@ -1965,33 +1395,15 @@ import { global as global5 } from "@storybook/global";
1965
1395
 
1966
1396
  // src/manager-api/lib/platform.ts
1967
1397
  import { global as global4 } from "@storybook/global";
1968
- var { navigator: navigator2 } = global4;
1969
- var isMacLike = /* @__PURE__ */ __name(() => navigator2 && navigator2.platform ? !!navigator2.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false, "isMacLike");
1398
+ var { navigator: navigator2 } = global4, isMacLike = () => navigator2 && navigator2.platform ? !!navigator2.platform.match(/(Mac|iPhone|iPod|iPad)/i) : !1;
1970
1399
 
1971
1400
  // src/manager-api/lib/shortcut.ts
1972
- var controlOrMetaSymbol = /* @__PURE__ */ __name(() => isMacLike() ? "\u2318" : "ctrl", "controlOrMetaSymbol");
1973
- var controlOrMetaKey = /* @__PURE__ */ __name(() => isMacLike() ? "meta" : "control", "controlOrMetaKey");
1974
- var optionOrAltSymbol = /* @__PURE__ */ __name(() => isMacLike() ? "\u2325" : "alt", "optionOrAltSymbol");
1975
- var isShortcutTaken = /* @__PURE__ */ __name((arr1, arr2) => JSON.stringify(arr1) === JSON.stringify(arr2), "isShortcutTaken");
1976
- var eventToShortcut = /* @__PURE__ */ __name((e) => {
1977
- if (["Meta", "Alt", "Control", "Shift", "Tab"].includes(e.key)) {
1401
+ var controlOrMetaSymbol = () => isMacLike() ? "\u2318" : "ctrl", controlOrMetaKey = () => isMacLike() ? "meta" : "control", optionOrAltSymbol = () => isMacLike() ? "\u2325" : "alt", isShortcutTaken = (arr1, arr2) => JSON.stringify(arr1) === JSON.stringify(arr2), eventToShortcut = (e) => {
1402
+ if (["Meta", "Alt", "Control", "Shift", "Tab"].includes(e.key))
1978
1403
  return null;
1979
- }
1980
- const keys2 = [];
1981
- if (e.altKey) {
1982
- keys2.push("alt");
1983
- }
1984
- if (e.ctrlKey) {
1985
- keys2.push("control");
1986
- }
1987
- if (e.metaKey) {
1988
- keys2.push("meta");
1989
- }
1990
- if (e.shiftKey) {
1991
- keys2.push("shift");
1992
- }
1993
- const codeUpper = e.code?.toUpperCase();
1994
- const codeToCharMap = {
1404
+ let keys2 = [];
1405
+ e.altKey && keys2.push("alt"), e.ctrlKey && keys2.push("control"), e.metaKey && keys2.push("meta"), e.shiftKey && keys2.push("shift");
1406
+ let codeUpper = e.code?.toUpperCase(), codeToCharMap = {
1995
1407
  MINUS: "-",
1996
1408
  EQUAL: "=",
1997
1409
  BRACKETLEFT: "[",
@@ -2003,115 +1415,21 @@ var eventToShortcut = /* @__PURE__ */ __name((e) => {
2003
1415
  COMMA: ",",
2004
1416
  PERIOD: ".",
2005
1417
  SLASH: "/"
2006
- };
2007
- const codeChar = codeUpper ? codeUpper.startsWith("KEY") && codeUpper.length === 4 ? codeUpper.replace("KEY", "") : codeUpper.startsWith("DIGIT") ? codeUpper.replace("DIGIT", "") : codeToCharMap[codeUpper] : void 0;
1418
+ }, codeChar = codeUpper ? codeUpper.startsWith("KEY") && codeUpper.length === 4 ? codeUpper.replace("KEY", "") : codeUpper.startsWith("DIGIT") ? codeUpper.replace("DIGIT", "") : codeToCharMap[codeUpper] : void 0;
2008
1419
  if (e.key && e.key.length === 1 && e.key !== " ") {
2009
- const key = e.key.toUpperCase();
2010
- const code = codeChar;
2011
- if (code && code.length === 1 && code !== key) {
2012
- keys2.push([key, code]);
2013
- } else {
2014
- keys2.push(key);
2015
- }
2016
- } else if (e.key === "Dead" && codeChar) {
2017
- keys2.push(codeChar);
2018
- }
2019
- if (e.key === " ") {
2020
- keys2.push("space");
2021
- }
2022
- if (e.key === "Escape") {
2023
- keys2.push("escape");
2024
- }
2025
- if (e.key === "ArrowRight") {
2026
- keys2.push("ArrowRight");
2027
- }
2028
- if (e.key === "ArrowDown") {
2029
- keys2.push("ArrowDown");
2030
- }
2031
- if (e.key === "ArrowUp") {
2032
- keys2.push("ArrowUp");
2033
- }
2034
- if (e.key === "ArrowLeft") {
2035
- keys2.push("ArrowLeft");
2036
- }
2037
- return keys2.length > 0 ? keys2 : null;
2038
- }, "eventToShortcut");
2039
- var shortcutMatchesShortcut = /* @__PURE__ */ __name((inputShortcut, shortcut) => {
2040
- if (!inputShortcut || !shortcut) {
2041
- return false;
2042
- }
2043
- if (inputShortcut.join("").startsWith("shift/")) {
2044
- inputShortcut.shift();
2045
- }
2046
- if (inputShortcut.length !== shortcut.length) {
2047
- return false;
2048
- }
2049
- return !inputShortcut.find(
2050
- (input, i) => Array.isArray(input) ? !input.includes(shortcut[i]) : input !== shortcut[i]
2051
- );
2052
- }, "shortcutMatchesShortcut");
2053
- var eventMatchesShortcut = /* @__PURE__ */ __name((e, shortcut) => {
2054
- return shortcutMatchesShortcut(eventToShortcut(e), shortcut);
2055
- }, "eventMatchesShortcut");
2056
- var keyToSymbol = /* @__PURE__ */ __name((key) => {
2057
- if (key === "alt") {
2058
- return optionOrAltSymbol();
2059
- }
2060
- if (key === "control") {
2061
- return "\u2303";
2062
- }
2063
- if (key === "meta") {
2064
- return "\u2318";
2065
- }
2066
- if (key === "shift") {
2067
- return "\u21E7\u200B";
2068
- }
2069
- if (key === "Enter" || key === "Backspace" || key === "Esc") {
2070
- return "";
2071
- }
2072
- if (key === "escape") {
2073
- return "";
2074
- }
2075
- if (key === " ") {
2076
- return "SPACE";
2077
- }
2078
- if (key === "ArrowUp") {
2079
- return "\u2191";
2080
- }
2081
- if (key === "ArrowDown") {
2082
- return "\u2193";
2083
- }
2084
- if (key === "ArrowLeft") {
2085
- return "\u2190";
2086
- }
2087
- if (key === "ArrowRight") {
2088
- return "\u2192";
2089
- }
2090
- return key?.toUpperCase();
2091
- }, "keyToSymbol");
2092
- var shortcutToHumanString = /* @__PURE__ */ __name((shortcut) => {
2093
- return shortcut.map(keyToSymbol).join(" ");
2094
- }, "shortcutToHumanString");
2095
- var shortcutToAriaKeyshortcuts = /* @__PURE__ */ __name((shortcut) => {
2096
- return shortcut.map((shortcut2) => {
2097
- if (shortcut2 === "+") {
2098
- return "plus";
2099
- }
2100
- if (shortcut2 === " ") {
2101
- return "space";
2102
- }
2103
- return shortcut2;
2104
- }).join("+");
2105
- }, "shortcutToAriaKeyshortcuts");
1420
+ let key = e.key.toUpperCase(), code = codeChar;
1421
+ code && code.length === 1 && code !== key ? keys2.push([key, code]) : keys2.push(key);
1422
+ } else e.key === "Dead" && codeChar && keys2.push(codeChar);
1423
+ return e.key === " " && keys2.push("space"), e.key === "Escape" && keys2.push("escape"), e.key === "ArrowRight" && keys2.push("ArrowRight"), e.key === "ArrowDown" && keys2.push("ArrowDown"), e.key === "ArrowUp" && keys2.push("ArrowUp"), e.key === "ArrowLeft" && keys2.push("ArrowLeft"), keys2.length > 0 ? keys2 : null;
1424
+ }, shortcutMatchesShortcut = (inputShortcut, shortcut) => !inputShortcut || !shortcut || (inputShortcut.join("").startsWith("shift/") && inputShortcut.shift(), inputShortcut.length !== shortcut.length) ? !1 : !inputShortcut.find(
1425
+ (input, i) => Array.isArray(input) ? !input.includes(shortcut[i]) : input !== shortcut[i]
1426
+ ), eventMatchesShortcut = (e, shortcut) => shortcutMatchesShortcut(eventToShortcut(e), shortcut), keyToSymbol = (key) => key === "alt" ? optionOrAltSymbol() : key === "control" ? "\u2303" : key === "meta" ? "\u2318" : key === "shift" ? "\u21E7\u200B" : key === "Enter" || key === "Backspace" || key === "Esc" || key === "escape" ? "" : key === " " ? "SPACE" : key === "ArrowUp" ? "\u2191" : key === "ArrowDown" ? "\u2193" : key === "ArrowLeft" ? "\u2190" : key === "ArrowRight" ? "\u2192" : key?.toUpperCase(), shortcutToHumanString = (shortcut) => shortcut.map(keyToSymbol).join(" "), shortcutToAriaKeyshortcuts = (shortcut) => shortcut.map((shortcut2) => shortcut2 === "+" ? "plus" : shortcut2 === " " ? "space" : shortcut2).join("+");
2106
1427
 
2107
1428
  // src/manager-api/modules/shortcuts.ts
2108
- var { navigator: navigator3, document: document3 } = global5;
2109
- var isMacLike2 = /* @__PURE__ */ __name(() => navigator3 && navigator3.platform ? !!navigator3.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false, "isMacLike");
2110
- var controlOrMetaKey2 = /* @__PURE__ */ __name(() => isMacLike2() ? "meta" : "control", "controlOrMetaKey");
1429
+ var { navigator: navigator3, document: document3 } = global5, isMacLike2 = () => navigator3 && navigator3.platform ? !!navigator3.platform.match(/(Mac|iPhone|iPod|iPad)/i) : !1, controlOrMetaKey2 = () => isMacLike2() ? "meta" : "control";
2111
1430
  function keys(o) {
2112
1431
  return Object.keys(o);
2113
1432
  }
2114
- __name(keys, "keys");
2115
1433
  var defaultShortcuts = Object.freeze({
2116
1434
  fullScreen: ["alt", "F"],
2117
1435
  togglePanel: ["alt", "A"],
@@ -2137,22 +1455,13 @@ var defaultShortcuts = Object.freeze({
2137
1455
  copyStoryLink: ["alt", "shift", "L"]
2138
1456
  // TODO: bring this back once we want to add shortcuts for this
2139
1457
  // copyStoryName: ['alt', 'shift', 'C'],
2140
- });
2141
- var addonsShortcuts = {};
1458
+ }), addonsShortcuts = {};
2142
1459
  function shouldSkipShortcut(event) {
2143
- const target = event.target;
2144
- if (/input|textarea/i.test(target.tagName) || target.getAttribute("contenteditable") !== null) {
2145
- return true;
2146
- }
2147
- const dialogElement = target.closest("dialog[open]");
2148
- if (dialogElement) {
2149
- return true;
2150
- }
2151
- return false;
1460
+ let target = event.target;
1461
+ return !!(/input|textarea/i.test(target.tagName) || target.getAttribute("contenteditable") !== null || target.closest("dialog[open]"));
2152
1462
  }
2153
- __name(shouldSkipShortcut, "shouldSkipShortcut");
2154
- var init10 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
2155
- const api = {
1463
+ var init10 = ({ store: store2, fullAPI, provider }) => {
1464
+ let api = {
2156
1465
  // Getting and setting shortcuts
2157
1466
  getShortcutKeys() {
2158
1467
  return store2.getState().shortcuts;
@@ -2167,227 +1476,174 @@ var init10 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
2167
1476
  return addonsShortcuts;
2168
1477
  },
2169
1478
  getAddonsShortcutLabels() {
2170
- const labels = {};
2171
- Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { label }]) => {
1479
+ let labels = {};
1480
+ return Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { label }]) => {
2172
1481
  labels[actionName] = label;
2173
- });
2174
- return labels;
1482
+ }), labels;
2175
1483
  },
2176
1484
  getAddonsShortcutDefaults() {
2177
- const defaults = {};
2178
- Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { defaultShortcut }]) => {
1485
+ let defaults = {};
1486
+ return Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { defaultShortcut }]) => {
2179
1487
  defaults[actionName] = defaultShortcut;
2180
- });
2181
- return defaults;
1488
+ }), defaults;
2182
1489
  },
2183
1490
  async setShortcuts(shortcuts) {
2184
- await store2.setState({ shortcuts }, { persistence: "permanent" });
2185
- return shortcuts;
1491
+ return await store2.setState({ shortcuts }, { persistence: "permanent" }), shortcuts;
2186
1492
  },
2187
1493
  async restoreAllDefaultShortcuts() {
2188
1494
  return api.setShortcuts(api.getDefaultShortcuts());
2189
1495
  },
2190
1496
  async setShortcut(action, value) {
2191
- const shortcuts = api.getShortcutKeys();
2192
- await api.setShortcuts({ ...shortcuts, [action]: value });
2193
- return value;
1497
+ let shortcuts = api.getShortcutKeys();
1498
+ return await api.setShortcuts({ ...shortcuts, [action]: value }), value;
2194
1499
  },
2195
1500
  async setAddonShortcut(addon, shortcut) {
2196
- const shortcuts = api.getShortcutKeys();
2197
- await api.setShortcuts({
1501
+ let shortcuts = api.getShortcutKeys();
1502
+ return await api.setShortcuts({
2198
1503
  ...shortcuts,
2199
1504
  [`${addon}-${shortcut.actionName}`]: shortcut.defaultShortcut
2200
- });
2201
- addonsShortcuts[`${addon}-${shortcut.actionName}`] = shortcut;
2202
- return shortcut;
1505
+ }), addonsShortcuts[`${addon}-${shortcut.actionName}`] = shortcut, shortcut;
2203
1506
  },
2204
1507
  async restoreDefaultShortcut(action) {
2205
- const defaultShortcut = api.getDefaultShortcuts()[action];
1508
+ let defaultShortcut = api.getDefaultShortcuts()[action];
2206
1509
  return api.setShortcut(action, defaultShortcut);
2207
1510
  },
2208
1511
  // Listening to shortcut events
2209
1512
  handleKeydownEvent(event) {
2210
- const shortcut = eventToShortcut(event);
2211
- const shortcuts = api.getShortcutKeys();
2212
- const actions = keys(shortcuts);
2213
- const matchedFeature = actions.find(
1513
+ let shortcut = eventToShortcut(event), shortcuts = api.getShortcutKeys(), matchedFeature = keys(shortcuts).find(
2214
1514
  (feature) => shortcutMatchesShortcut(shortcut, shortcuts[feature])
2215
1515
  );
2216
- if (matchedFeature) {
2217
- api.handleShortcutFeature(matchedFeature, event);
2218
- }
1516
+ matchedFeature && api.handleShortcutFeature(matchedFeature, event);
2219
1517
  },
2220
1518
  // warning: event might not have a full prototype chain because it may originate from the channel
2221
1519
  handleShortcutFeature(feature, event) {
2222
- const {
1520
+ let {
2223
1521
  ui: { enableShortcuts },
2224
1522
  storyId
2225
1523
  } = store2.getState();
2226
- if (!enableShortcuts) {
2227
- return;
2228
- }
2229
- if (event?.preventDefault) {
2230
- event.preventDefault();
2231
- }
2232
- switch (feature) {
2233
- case "escape": {
2234
- if (fullAPI.getIsFullscreen()) {
2235
- fullAPI.toggleFullscreen(false);
2236
- } else if (fullAPI.getIsNavShown()) {
2237
- fullAPI.toggleNav(true);
1524
+ if (enableShortcuts)
1525
+ switch (event?.preventDefault && event.preventDefault(), feature) {
1526
+ case "escape": {
1527
+ fullAPI.getIsFullscreen() ? fullAPI.toggleFullscreen(!1) : fullAPI.getIsNavShown() && fullAPI.toggleNav(!0);
1528
+ break;
2238
1529
  }
2239
- break;
2240
- }
2241
- case "focusNav": {
2242
- if (fullAPI.getIsFullscreen()) {
2243
- fullAPI.toggleFullscreen(false);
1530
+ case "focusNav": {
1531
+ fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsNavShown() || fullAPI.toggleNav(!0), fullAPI.focusOnUIElement(focusableUIElements.storyListMenu);
1532
+ break;
2244
1533
  }
2245
- if (!fullAPI.getIsNavShown()) {
2246
- fullAPI.toggleNav(true);
1534
+ case "search": {
1535
+ fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsNavShown() || fullAPI.toggleNav(!0), setTimeout(() => {
1536
+ fullAPI.focusOnUIElement(focusableUIElements.storySearchField, !0);
1537
+ }, 0);
1538
+ break;
2247
1539
  }
2248
- fullAPI.focusOnUIElement(focusableUIElements.storyListMenu);
2249
- break;
2250
- }
2251
- case "search": {
2252
- if (fullAPI.getIsFullscreen()) {
2253
- fullAPI.toggleFullscreen(false);
1540
+ case "focusIframe": {
1541
+ let element = document3.getElementById("storybook-preview-iframe");
1542
+ if (element)
1543
+ try {
1544
+ element.contentWindow.focus();
1545
+ } catch {
1546
+ }
1547
+ break;
2254
1548
  }
2255
- if (!fullAPI.getIsNavShown()) {
2256
- fullAPI.toggleNav(true);
1549
+ case "focusPanel": {
1550
+ fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsPanelShown() || fullAPI.togglePanel(!0), fullAPI.focusOnUIElement(focusableUIElements.storyPanelRoot);
1551
+ break;
2257
1552
  }
2258
- setTimeout(() => {
2259
- fullAPI.focusOnUIElement(focusableUIElements.storySearchField, true);
2260
- }, 0);
2261
- break;
2262
- }
2263
- case "focusIframe": {
2264
- const element = document3.getElementById("storybook-preview-iframe");
2265
- if (element) {
2266
- try {
2267
- element.contentWindow.focus();
2268
- } catch (e) {
2269
- }
1553
+ case "nextStory": {
1554
+ fullAPI.jumpToStory(1);
1555
+ break;
2270
1556
  }
2271
- break;
2272
- }
2273
- case "focusPanel": {
2274
- if (fullAPI.getIsFullscreen()) {
2275
- fullAPI.toggleFullscreen(false);
1557
+ case "prevStory": {
1558
+ fullAPI.jumpToStory(-1);
1559
+ break;
2276
1560
  }
2277
- if (!fullAPI.getIsPanelShown()) {
2278
- fullAPI.togglePanel(true);
1561
+ case "nextComponent": {
1562
+ fullAPI.jumpToComponent(1);
1563
+ break;
2279
1564
  }
2280
- fullAPI.focusOnUIElement(focusableUIElements.storyPanelRoot);
2281
- break;
2282
- }
2283
- case "nextStory": {
2284
- fullAPI.jumpToStory(1);
2285
- break;
2286
- }
2287
- case "prevStory": {
2288
- fullAPI.jumpToStory(-1);
2289
- break;
2290
- }
2291
- case "nextComponent": {
2292
- fullAPI.jumpToComponent(1);
2293
- break;
2294
- }
2295
- case "prevComponent": {
2296
- fullAPI.jumpToComponent(-1);
2297
- break;
2298
- }
2299
- case "fullScreen": {
2300
- fullAPI.toggleFullscreen();
2301
- break;
2302
- }
2303
- case "togglePanel": {
2304
- fullAPI.togglePanel();
2305
- break;
2306
- }
2307
- case "toggleNav": {
2308
- fullAPI.toggleNav();
2309
- break;
2310
- }
2311
- case "toolbar": {
2312
- fullAPI.toggleToolbar();
2313
- break;
2314
- }
2315
- case "panelPosition": {
2316
- if (fullAPI.getIsFullscreen()) {
2317
- fullAPI.toggleFullscreen(false);
1565
+ case "prevComponent": {
1566
+ fullAPI.jumpToComponent(-1);
1567
+ break;
2318
1568
  }
2319
- if (!fullAPI.getIsPanelShown()) {
2320
- fullAPI.togglePanel(true);
1569
+ case "fullScreen": {
1570
+ fullAPI.toggleFullscreen();
1571
+ break;
2321
1572
  }
2322
- fullAPI.togglePanelPosition();
2323
- break;
2324
- }
2325
- case "aboutPage": {
2326
- fullAPI.navigate("/settings/about");
2327
- break;
2328
- }
2329
- case "shortcutsPage": {
2330
- fullAPI.navigate("/settings/shortcuts");
2331
- break;
2332
- }
2333
- case "collapseAll": {
2334
- fullAPI.emit(STORIES_COLLAPSE_ALL);
2335
- break;
2336
- }
2337
- case "expandAll": {
2338
- fullAPI.emit(STORIES_EXPAND_ALL);
2339
- break;
2340
- }
2341
- case "remount": {
2342
- fullAPI.emit(FORCE_REMOUNT, { storyId });
2343
- break;
2344
- }
2345
- case "openInEditor": {
2346
- if (global5.CONFIG_TYPE === "DEVELOPMENT") {
2347
- fullAPI.openInEditor({
1573
+ case "togglePanel": {
1574
+ fullAPI.togglePanel();
1575
+ break;
1576
+ }
1577
+ case "toggleNav": {
1578
+ fullAPI.toggleNav();
1579
+ break;
1580
+ }
1581
+ case "toolbar": {
1582
+ fullAPI.toggleToolbar();
1583
+ break;
1584
+ }
1585
+ case "panelPosition": {
1586
+ fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsPanelShown() || fullAPI.togglePanel(!0), fullAPI.togglePanelPosition();
1587
+ break;
1588
+ }
1589
+ case "aboutPage": {
1590
+ fullAPI.navigate("/settings/about");
1591
+ break;
1592
+ }
1593
+ case "shortcutsPage": {
1594
+ fullAPI.navigate("/settings/shortcuts");
1595
+ break;
1596
+ }
1597
+ case "collapseAll": {
1598
+ fullAPI.emit(STORIES_COLLAPSE_ALL);
1599
+ break;
1600
+ }
1601
+ case "expandAll": {
1602
+ fullAPI.emit(STORIES_EXPAND_ALL);
1603
+ break;
1604
+ }
1605
+ case "remount": {
1606
+ fullAPI.emit(FORCE_REMOUNT, { storyId });
1607
+ break;
1608
+ }
1609
+ case "openInEditor": {
1610
+ global5.CONFIG_TYPE === "DEVELOPMENT" && fullAPI.openInEditor({
2348
1611
  file: fullAPI.getCurrentStoryData().importPath
2349
1612
  });
1613
+ break;
2350
1614
  }
2351
- break;
2352
- }
2353
- // TODO: bring this back once we want to add shortcuts for this
2354
- // case 'copyStoryName': {
2355
- // const storyData = fullAPI.getCurrentStoryData();
2356
- // if (storyData.type === 'story') {
2357
- // copy(storyData.exportName);
2358
- // }
2359
- // break;
2360
- // }
2361
- case "copyStoryLink": {
2362
- (0, import_copy_to_clipboard.default)(window.location.href);
2363
- break;
1615
+ // TODO: bring this back once we want to add shortcuts for this
1616
+ // case 'copyStoryName': {
1617
+ // const storyData = fullAPI.getCurrentStoryData();
1618
+ // if (storyData.type === 'story') {
1619
+ // copy(storyData.exportName);
1620
+ // }
1621
+ // break;
1622
+ // }
1623
+ case "copyStoryLink": {
1624
+ (0, import_copy_to_clipboard.default)(window.location.href);
1625
+ break;
1626
+ }
1627
+ default:
1628
+ addonsShortcuts[feature].action();
1629
+ break;
2364
1630
  }
2365
- default:
2366
- addonsShortcuts[feature].action();
2367
- break;
2368
- }
2369
1631
  }
2370
- };
2371
- const { shortcuts: persistedShortcuts = defaultShortcuts } = store2.getState();
2372
- const state = {
1632
+ }, { shortcuts: persistedShortcuts = defaultShortcuts } = store2.getState(), state = {
2373
1633
  // Any saved shortcuts that are still in our set of defaults
2374
1634
  shortcuts: keys(defaultShortcuts).reduce(
2375
1635
  (acc, key) => ({ ...acc, [key]: persistedShortcuts[key] || defaultShortcuts[key] }),
2376
1636
  defaultShortcuts
2377
1637
  )
2378
1638
  };
2379
- const initModule = /* @__PURE__ */ __name(() => {
1639
+ return { api, state, init: () => {
2380
1640
  document3.addEventListener("keydown", (event) => {
2381
- if (!shouldSkipShortcut(event)) {
2382
- api.handleKeydownEvent(event);
2383
- }
2384
- });
2385
- provider.channel?.on(PREVIEW_KEYDOWN, (data) => {
1641
+ shouldSkipShortcut(event) || api.handleKeydownEvent(event);
1642
+ }), provider.channel?.on(PREVIEW_KEYDOWN, (data) => {
2386
1643
  api.handleKeydownEvent(data.event);
2387
1644
  });
2388
- }, "initModule");
2389
- return { api, state, init: initModule };
2390
- }, "init");
1645
+ } };
1646
+ };
2391
1647
 
2392
1648
  // src/manager-api/modules/stories.ts
2393
1649
  var stories_exports = {};
@@ -2420,9 +1676,10 @@ import { global as global6 } from "@storybook/global";
2420
1676
 
2421
1677
  // src/server-errors.ts
2422
1678
  var import_picocolors = __toESM(require_picocolors_browser(), 1);
2423
- var _StatusTypeIdMismatchError = class _StatusTypeIdMismatchError extends StorybookError {
1679
+ var StatusTypeIdMismatchError3 = class extends StorybookError {
2424
1680
  constructor(data) {
2425
1681
  super({
1682
+ name: "StatusTypeIdMismatchError",
2426
1683
  category: "CORE-SERVER" /* CORE_SERVER */,
2427
1684
  code: 16,
2428
1685
  message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
@@ -2434,16 +1691,13 @@ var _StatusTypeIdMismatchError = class _StatusTypeIdMismatchError extends Storyb
2434
1691
  this.data = data;
2435
1692
  }
2436
1693
  };
2437
- __name(_StatusTypeIdMismatchError, "StatusTypeIdMismatchError");
2438
- var StatusTypeIdMismatchError3 = _StatusTypeIdMismatchError;
2439
1694
 
2440
1695
  // src/shared/status-store/index.ts
2441
1696
  var UNIVERSAL_STATUS_STORE_OPTIONS = {
2442
1697
  id: "storybook/status",
2443
- leader: true,
1698
+ leader: !0,
2444
1699
  initialState: {}
2445
- };
2446
- var StatusStoreEventType = {
1700
+ }, StatusStoreEventType = {
2447
1701
  SELECT: "select"
2448
1702
  };
2449
1703
  function createStatusStore({
@@ -2451,15 +1705,15 @@ function createStatusStore({
2451
1705
  useUniversalStore: useUniversalStore2,
2452
1706
  environment
2453
1707
  }) {
2454
- const fullStatusStore2 = {
1708
+ let fullStatusStore2 = {
2455
1709
  getAll() {
2456
1710
  return universalStatusStore2.getState();
2457
1711
  },
2458
1712
  set(statuses) {
2459
1713
  universalStatusStore2.setState((state) => {
2460
- const newState = { ...state };
2461
- for (const status of statuses) {
2462
- const { storyId, typeId } = status;
1714
+ let newState = { ...state };
1715
+ for (let status of statuses) {
1716
+ let { storyId, typeId } = status;
2463
1717
  newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
2464
1718
  }
2465
1719
  return newState;
@@ -2475,32 +1729,30 @@ function createStatusStore({
2475
1729
  listener(event.payload);
2476
1730
  });
2477
1731
  },
2478
- selectStatuses: /* @__PURE__ */ __name((statuses) => {
1732
+ selectStatuses: (statuses) => {
2479
1733
  universalStatusStore2.send({ type: StatusStoreEventType.SELECT, payload: statuses });
2480
- }, "selectStatuses"),
1734
+ },
2481
1735
  unset(storyIds) {
2482
1736
  if (!storyIds) {
2483
1737
  universalStatusStore2.setState({});
2484
1738
  return;
2485
1739
  }
2486
1740
  universalStatusStore2.setState((state) => {
2487
- const newState = { ...state };
2488
- for (const storyId of storyIds) {
1741
+ let newState = { ...state };
1742
+ for (let storyId of storyIds)
2489
1743
  delete newState[storyId];
2490
- }
2491
1744
  return newState;
2492
1745
  });
2493
1746
  },
2494
1747
  typeId: void 0
2495
- };
2496
- const getStatusStoreByTypeId2 = /* @__PURE__ */ __name((typeId) => ({
1748
+ }, getStatusStoreByTypeId2 = (typeId) => ({
2497
1749
  getAll: fullStatusStore2.getAll,
2498
1750
  set(statuses) {
2499
1751
  universalStatusStore2.setState((state) => {
2500
- const newState = { ...state };
2501
- for (const status of statuses) {
2502
- const { storyId } = status;
2503
- if (status.typeId !== typeId) {
1752
+ let newState = { ...state };
1753
+ for (let status of statuses) {
1754
+ let { storyId } = status;
1755
+ if (status.typeId !== typeId)
2504
1756
  switch (environment) {
2505
1757
  case "server":
2506
1758
  throw new StatusTypeIdMismatchError3({
@@ -2519,7 +1771,6 @@ function createStatusStore({
2519
1771
  typeId
2520
1772
  });
2521
1773
  }
2522
- }
2523
1774
  newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
2524
1775
  }
2525
1776
  return newState;
@@ -2528,72 +1779,51 @@ function createStatusStore({
2528
1779
  onAllStatusChange: fullStatusStore2.onAllStatusChange,
2529
1780
  onSelect(listener) {
2530
1781
  return universalStatusStore2.subscribe(StatusStoreEventType.SELECT, (event) => {
2531
- if (event.payload.some((status) => status.typeId === typeId)) {
2532
- listener(event.payload);
2533
- }
1782
+ event.payload.some((status) => status.typeId === typeId) && listener(event.payload);
2534
1783
  });
2535
1784
  },
2536
1785
  unset(storyIds) {
2537
1786
  universalStatusStore2.setState((state) => {
2538
- const newState = { ...state };
2539
- for (const storyId in newState) {
1787
+ let newState = { ...state };
1788
+ for (let storyId in newState)
2540
1789
  if (newState[storyId]?.[typeId] && (!storyIds || storyIds?.includes(storyId))) {
2541
- const { [typeId]: omittedStatus, ...storyStatusesWithoutTypeId } = newState[storyId];
1790
+ let { [typeId]: omittedStatus, ...storyStatusesWithoutTypeId } = newState[storyId];
2542
1791
  newState[storyId] = storyStatusesWithoutTypeId;
2543
1792
  }
2544
- }
2545
1793
  return newState;
2546
1794
  });
2547
1795
  },
2548
1796
  typeId
2549
- }), "getStatusStoreByTypeId");
2550
- if (!useUniversalStore2) {
2551
- return { getStatusStoreByTypeId: getStatusStoreByTypeId2, fullStatusStore: fullStatusStore2, universalStatusStore: universalStatusStore2 };
2552
- }
2553
- return {
1797
+ });
1798
+ return useUniversalStore2 ? {
2554
1799
  getStatusStoreByTypeId: getStatusStoreByTypeId2,
2555
1800
  fullStatusStore: fullStatusStore2,
2556
1801
  universalStatusStore: universalStatusStore2,
2557
- useStatusStore: /* @__PURE__ */ __name((selector) => useUniversalStore2(universalStatusStore2, selector)[0], "useStatusStore")
2558
- };
1802
+ useStatusStore: (selector) => useUniversalStore2(universalStatusStore2, selector)[0]
1803
+ } : { getStatusStoreByTypeId: getStatusStoreByTypeId2, fullStatusStore: fullStatusStore2, universalStatusStore: universalStatusStore2 };
2559
1804
  }
2560
- __name(createStatusStore, "createStatusStore");
2561
1805
 
2562
1806
  // src/shared/universal-store/use-universal-store-manager.ts
2563
1807
  import * as React2 from "react";
2564
- var useUniversalStore = /* @__PURE__ */ __name((universalStore, selector) => {
2565
- const snapshotRef = React2.useRef(
1808
+ var useUniversalStore = (universalStore, selector) => {
1809
+ let snapshotRef = React2.useRef(
2566
1810
  selector ? selector(universalStore.getState()) : universalStore.getState()
2567
- );
2568
- const subscribe = React2.useCallback(
1811
+ ), subscribe = React2.useCallback(
2569
1812
  (listener) => universalStore.onStateChange((state2, previousState) => {
2570
1813
  if (!selector) {
2571
- snapshotRef.current = state2;
2572
- listener();
1814
+ snapshotRef.current = state2, listener();
2573
1815
  return;
2574
1816
  }
2575
- const selectedState = selector(state2);
2576
- const selectedPreviousState = selector(previousState);
2577
- const hasChanges = !isEqual(selectedState, selectedPreviousState);
2578
- if (hasChanges) {
2579
- snapshotRef.current = selectedState;
2580
- listener();
2581
- }
1817
+ let selectedState = selector(state2), selectedPreviousState = selector(previousState);
1818
+ !isEqual(selectedState, selectedPreviousState) && (snapshotRef.current = selectedState, listener());
2582
1819
  }),
2583
1820
  [universalStore, selector]
2584
- );
2585
- const getSnapshot = React2.useCallback(() => {
2586
- const currentState = universalStore.getState();
2587
- const selectedState = selector ? selector(currentState) : currentState;
2588
- if (isEqual(selectedState, snapshotRef.current)) {
2589
- return snapshotRef.current;
2590
- }
2591
- snapshotRef.current = selectedState;
2592
- return snapshotRef.current;
1821
+ ), getSnapshot = React2.useCallback(() => {
1822
+ let currentState = universalStore.getState(), selectedState = selector ? selector(currentState) : currentState;
1823
+ return isEqual(selectedState, snapshotRef.current) || (snapshotRef.current = selectedState), snapshotRef.current;
2593
1824
  }, [universalStore, selector]);
2594
- const state = React2.useSyncExternalStore(subscribe, getSnapshot);
2595
- return [state, universalStore.setState];
2596
- }, "useUniversalStore");
1825
+ return [React2.useSyncExternalStore(subscribe, getSnapshot), universalStore.setState];
1826
+ };
2597
1827
 
2598
1828
  // src/manager-api/stores/status.ts
2599
1829
  var statusStore = createStatusStore({
@@ -2603,27 +1833,19 @@ var statusStore = createStatusStore({
2603
1833
  }),
2604
1834
  useUniversalStore,
2605
1835
  environment: "manager"
2606
- });
2607
- var { fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore } = statusStore;
1836
+ }), { fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore } = statusStore;
2608
1837
 
2609
1838
  // src/manager-api/modules/stories.ts
2610
- var { fetch: fetch2 } = global6;
2611
- var STORY_INDEX_PATH = "./index.json";
2612
- var removedOptions = ["enableShortcuts", "theme", "showRoots"];
1839
+ var { fetch: fetch2 } = global6, STORY_INDEX_PATH = "./index.json", removedOptions = ["enableShortcuts", "theme", "showRoots"];
2613
1840
  function removeRemovedOptions(options) {
2614
- if (!options || typeof options === "string") {
1841
+ if (!options || typeof options == "string")
2615
1842
  return options;
2616
- }
2617
- const result = { ...options };
2618
- removedOptions.forEach((option) => {
2619
- if (option in result) {
2620
- delete result[option];
2621
- }
2622
- });
2623
- return result;
1843
+ let result = { ...options };
1844
+ return removedOptions.forEach((option) => {
1845
+ option in result && delete result[option];
1846
+ }), result;
2624
1847
  }
2625
- __name(removeRemovedOptions, "removeRemovedOptions");
2626
- var init11 = /* @__PURE__ */ __name(({
1848
+ var init11 = ({
2627
1849
  fullAPI,
2628
1850
  store: store2,
2629
1851
  navigate,
@@ -2632,213 +1854,146 @@ var init11 = /* @__PURE__ */ __name(({
2632
1854
  viewMode: initialViewMode,
2633
1855
  docsOptions = {}
2634
1856
  }) => {
2635
- const api = {
1857
+ let api = {
2636
1858
  storyId: toId,
2637
- getData: /* @__PURE__ */ __name((storyId, refId) => {
2638
- const result = api.resolveStory(storyId, refId);
2639
- if (result?.type === "story" || result?.type === "docs") {
1859
+ getData: (storyId, refId) => {
1860
+ let result = api.resolveStory(storyId, refId);
1861
+ if (result?.type === "story" || result?.type === "docs")
2640
1862
  return result;
2641
- }
2642
- return void 0;
2643
- }, "getData"),
2644
- isPrepared: /* @__PURE__ */ __name((storyId, refId) => {
2645
- const data = api.getData(storyId, refId);
2646
- if (!data) {
2647
- return false;
2648
- }
2649
- return data.type === "story" ? data.prepared : true;
2650
- }, "isPrepared"),
2651
- resolveStory: /* @__PURE__ */ __name((storyId, refId) => {
2652
- const { refs, index } = store2.getState();
2653
- if (refId && !refs[refId]) {
2654
- return void 0;
2655
- }
2656
- if (refId) {
2657
- return refs?.[refId]?.index?.[storyId] ?? void 0;
2658
- }
2659
- return index ? index[storyId] : void 0;
2660
- }, "resolveStory"),
2661
- getCurrentStoryData: /* @__PURE__ */ __name(() => {
2662
- const { storyId, refId } = store2.getState();
1863
+ },
1864
+ isPrepared: (storyId, refId) => {
1865
+ let data = api.getData(storyId, refId);
1866
+ return data ? data.type === "story" ? data.prepared : !0 : !1;
1867
+ },
1868
+ resolveStory: (storyId, refId) => {
1869
+ let { refs, index } = store2.getState();
1870
+ if (!(refId && !refs[refId]))
1871
+ return refId ? refs?.[refId]?.index?.[storyId] ?? void 0 : index ? index[storyId] : void 0;
1872
+ },
1873
+ getCurrentStoryData: () => {
1874
+ let { storyId, refId } = store2.getState();
2663
1875
  return api.getData(storyId, refId);
2664
- }, "getCurrentStoryData"),
2665
- getParameters: /* @__PURE__ */ __name((storyIdOrCombo, parameterName) => {
2666
- const { storyId, refId } = typeof storyIdOrCombo === "string" ? { storyId: storyIdOrCombo, refId: void 0 } : storyIdOrCombo;
2667
- const data = api.getData(storyId, refId);
1876
+ },
1877
+ getParameters: (storyIdOrCombo, parameterName) => {
1878
+ let { storyId, refId } = typeof storyIdOrCombo == "string" ? { storyId: storyIdOrCombo, refId: void 0 } : storyIdOrCombo, data = api.getData(storyId, refId);
2668
1879
  if (["story", "docs"].includes(data?.type)) {
2669
- const { parameters } = data;
2670
- if (parameters) {
1880
+ let { parameters } = data;
1881
+ if (parameters)
2671
1882
  return parameterName ? parameters[parameterName] : parameters;
2672
- }
2673
1883
  }
2674
1884
  return null;
2675
- }, "getParameters"),
2676
- getCurrentParameter: /* @__PURE__ */ __name((parameterName) => {
2677
- const { storyId, refId } = store2.getState();
2678
- const parameters = api.getParameters({ storyId, refId }, parameterName);
2679
- return parameters || void 0;
2680
- }, "getCurrentParameter"),
2681
- jumpToComponent: /* @__PURE__ */ __name((direction) => {
2682
- const { filteredIndex, storyId, refs, refId } = store2.getState();
2683
- const story = api.getData(storyId, refId);
2684
- if (!story) {
1885
+ },
1886
+ getCurrentParameter: (parameterName) => {
1887
+ let { storyId, refId } = store2.getState();
1888
+ return api.getParameters({ storyId, refId }, parameterName) || void 0;
1889
+ },
1890
+ jumpToComponent: (direction) => {
1891
+ let { filteredIndex, storyId, refs, refId } = store2.getState();
1892
+ if (!api.getData(storyId, refId))
2685
1893
  return;
2686
- }
2687
- const hash = refId ? refs[refId].filteredIndex || {} : filteredIndex;
2688
- if (!hash) {
1894
+ let hash = refId ? refs[refId].filteredIndex || {} : filteredIndex;
1895
+ if (!hash)
2689
1896
  return;
2690
- }
2691
- const result = api.findSiblingStoryId(storyId, hash, direction, true);
2692
- if (result) {
2693
- api.selectStory(result, void 0, { ref: refId });
2694
- }
2695
- }, "jumpToComponent"),
2696
- jumpToStory: /* @__PURE__ */ __name((direction) => {
2697
- const { filteredIndex, storyId, refs, refId } = store2.getState();
2698
- const story = api.getData(storyId, refId);
2699
- if (!story) {
1897
+ let result = api.findSiblingStoryId(storyId, hash, direction, !0);
1898
+ result && api.selectStory(result, void 0, { ref: refId });
1899
+ },
1900
+ jumpToStory: (direction) => {
1901
+ let { filteredIndex, storyId, refs, refId } = store2.getState(), story = api.getData(storyId, refId);
1902
+ if (!story)
2700
1903
  return;
2701
- }
2702
- const hash = story.refId ? refs[story.refId].filteredIndex : filteredIndex;
2703
- if (!hash) {
1904
+ let hash = story.refId ? refs[story.refId].filteredIndex : filteredIndex;
1905
+ if (!hash)
2704
1906
  return;
2705
- }
2706
- const result = api.findSiblingStoryId(storyId, hash, direction, false);
2707
- if (result) {
2708
- api.selectStory(result, void 0, { ref: refId });
2709
- }
2710
- }, "jumpToStory"),
2711
- selectFirstStory: /* @__PURE__ */ __name(() => {
2712
- const { index } = store2.getState();
2713
- if (!index) {
1907
+ let result = api.findSiblingStoryId(storyId, hash, direction, !1);
1908
+ result && api.selectStory(result, void 0, { ref: refId });
1909
+ },
1910
+ selectFirstStory: () => {
1911
+ let { index } = store2.getState();
1912
+ if (!index)
2714
1913
  return;
2715
- }
2716
- const firstStory = Object.keys(index).find((id) => index[id].type === "story");
1914
+ let firstStory = Object.keys(index).find((id) => index[id].type === "story");
2717
1915
  if (firstStory) {
2718
1916
  api.selectStory(firstStory);
2719
1917
  return;
2720
1918
  }
2721
1919
  navigate("/");
2722
- }, "selectFirstStory"),
2723
- selectStory: /* @__PURE__ */ __name((titleOrId = void 0, name = void 0, options = {}) => {
2724
- const { ref } = options;
2725
- const { storyId, index, filteredIndex, refs, settings } = store2.getState();
2726
- const gotoStory = /* @__PURE__ */ __name((entry) => {
2727
- if (entry?.type === "docs" || entry?.type === "story") {
2728
- store2.setState({ settings: { ...settings, lastTrackedStoryId: entry.id } });
2729
- navigate(`/${entry.type}/${entry.refId ? `${entry.refId}_${entry.id}` : entry.id}`);
2730
- return true;
2731
- }
2732
- return false;
2733
- }, "gotoStory");
2734
- const kindSlug = storyId?.split("--", 2)[0];
2735
- const hash = ref ? refs[ref].index : index;
2736
- const filteredHash = ref ? refs[ref].filteredIndex : filteredIndex;
2737
- if (!hash || !filteredHash) {
2738
- return;
2739
- }
2740
- if (!name) {
2741
- const entry = titleOrId ? hash[titleOrId] || hash[sanitize2(titleOrId)] : hash[kindSlug];
2742
- if (!entry) {
2743
- throw new Error(`Unknown id or title: '${titleOrId}'`);
2744
- }
2745
- if (!gotoStory(entry)) {
2746
- gotoStory(api.findLeafEntry(filteredHash, entry.id));
2747
- }
2748
- } else if (!titleOrId) {
2749
- gotoStory(hash[toId(kindSlug, name)]);
2750
- } else {
2751
- const id = ref ? `${ref}_${toId(titleOrId, name)}` : toId(titleOrId, name);
2752
- if (hash[id]) {
2753
- gotoStory(hash[id]);
2754
- } else {
2755
- const entry = hash[sanitize2(titleOrId)];
2756
- if (entry?.type === "component") {
2757
- const foundId = entry.children.find((childId) => hash[childId].name === name);
2758
- gotoStory(foundId ? hash[foundId] : void 0);
1920
+ },
1921
+ selectStory: (titleOrId = void 0, name = void 0, options = {}) => {
1922
+ let { ref } = options, { storyId, index, filteredIndex, refs, settings } = store2.getState(), gotoStory = (entry) => entry?.type === "docs" || entry?.type === "story" ? (store2.setState({ settings: { ...settings, lastTrackedStoryId: entry.id } }), navigate(`/${entry.type}/${entry.refId ? `${entry.refId}_${entry.id}` : entry.id}`), !0) : !1, kindSlug = storyId?.split("--", 2)[0], hash = ref ? refs[ref].index : index, filteredHash = ref ? refs[ref].filteredIndex : filteredIndex;
1923
+ if (!(!hash || !filteredHash))
1924
+ if (name)
1925
+ if (!titleOrId)
1926
+ gotoStory(hash[toId(kindSlug, name)]);
1927
+ else {
1928
+ let id = ref ? `${ref}_${toId(titleOrId, name)}` : toId(titleOrId, name);
1929
+ if (hash[id])
1930
+ gotoStory(hash[id]);
1931
+ else {
1932
+ let entry = hash[sanitize2(titleOrId)];
1933
+ if (entry?.type === "component") {
1934
+ let foundId = entry.children.find((childId) => hash[childId].name === name);
1935
+ gotoStory(foundId ? hash[foundId] : void 0);
1936
+ }
1937
+ }
2759
1938
  }
1939
+ else {
1940
+ let entry = titleOrId ? hash[titleOrId] || hash[sanitize2(titleOrId)] : hash[kindSlug];
1941
+ if (!entry)
1942
+ throw new Error(`Unknown id or title: '${titleOrId}'`);
1943
+ gotoStory(entry) || gotoStory(api.findLeafEntry(filteredHash, entry.id));
2760
1944
  }
2761
- }
2762
- }, "selectStory"),
1945
+ },
2763
1946
  findLeafEntry(index, storyId) {
2764
- const entry = index[storyId];
2765
- if (entry.type === "docs" || entry.type === "story") {
1947
+ let entry = index[storyId];
1948
+ if (entry.type === "docs" || entry.type === "story")
2766
1949
  return entry;
2767
- }
2768
- const childStoryId = entry.children.find((childId) => index[childId]) || entry.children[0];
1950
+ let childStoryId = entry.children.find((childId) => index[childId]) || entry.children[0];
2769
1951
  return api.findLeafEntry(index, childStoryId);
2770
1952
  },
2771
1953
  findLeafStoryId(index, storyId) {
2772
1954
  return api.findLeafEntry(index, storyId)?.id;
2773
1955
  },
2774
1956
  findAllLeafStoryIds(entryId) {
2775
- const { index } = store2.getState();
2776
- if (!index) {
1957
+ let { index } = store2.getState();
1958
+ if (!index)
2777
1959
  return [];
2778
- }
2779
- const findChildEntriesRecursively = /* @__PURE__ */ __name((currentEntryId, results = []) => {
2780
- const node = index[currentEntryId];
2781
- if (!node) {
2782
- return results;
2783
- }
2784
- if (node.type === "story") {
2785
- results.push(node.id);
2786
- }
2787
- if ("children" in node) {
2788
- node.children?.forEach((childId) => findChildEntriesRecursively(childId, results));
2789
- }
2790
- return results;
2791
- }, "findChildEntriesRecursively");
1960
+ let findChildEntriesRecursively = (currentEntryId, results = []) => {
1961
+ let node = index[currentEntryId];
1962
+ return node && (node.type === "story" && results.push(node.id), "children" in node && node.children?.forEach((childId) => findChildEntriesRecursively(childId, results))), results;
1963
+ };
2792
1964
  return findChildEntriesRecursively(entryId, []);
2793
1965
  },
2794
1966
  findSiblingStoryId(storyId, index, direction, toSiblingGroup) {
2795
1967
  if (toSiblingGroup) {
2796
- const lookupList2 = getComponentLookupList(index);
2797
- const position2 = lookupList2.findIndex((i) => i.includes(storyId));
2798
- if (position2 === lookupList2.length - 1 && direction > 0) {
2799
- return;
2800
- }
2801
- if (position2 === 0 && direction < 0) {
2802
- return;
2803
- }
2804
- if (lookupList2[position2 + direction]) {
2805
- return lookupList2[position2 + direction][0];
2806
- }
2807
- return;
2808
- }
2809
- const lookupList = getStoriesLookupList(index);
2810
- const position = lookupList.indexOf(storyId);
2811
- if (position === lookupList.length - 1 && direction > 0) {
2812
- return;
2813
- }
2814
- if (position === 0 && direction < 0) {
2815
- return;
1968
+ let lookupList2 = getComponentLookupList(index), position2 = lookupList2.findIndex((i) => i.includes(storyId));
1969
+ return position2 === lookupList2.length - 1 && direction > 0 || position2 === 0 && direction < 0 ? void 0 : lookupList2[position2 + direction] ? lookupList2[position2 + direction][0] : void 0;
2816
1970
  }
2817
- return lookupList[position + direction];
1971
+ let lookupList = getStoriesLookupList(index), position = lookupList.indexOf(storyId);
1972
+ if (!(position === lookupList.length - 1 && direction > 0) && !(position === 0 && direction < 0))
1973
+ return lookupList[position + direction];
2818
1974
  },
2819
- updateStoryArgs: /* @__PURE__ */ __name((story, updatedArgs) => {
2820
- const { id: storyId, refId } = story;
1975
+ updateStoryArgs: (story, updatedArgs) => {
1976
+ let { id: storyId, refId } = story;
2821
1977
  provider.channel?.emit(UPDATE_STORY_ARGS, {
2822
1978
  storyId,
2823
1979
  updatedArgs,
2824
1980
  options: { target: refId }
2825
1981
  });
2826
- }, "updateStoryArgs"),
2827
- resetStoryArgs: /* @__PURE__ */ __name((story, argNames) => {
2828
- const { id: storyId, refId } = story;
1982
+ },
1983
+ resetStoryArgs: (story, argNames) => {
1984
+ let { id: storyId, refId } = story;
2829
1985
  provider.channel?.emit(RESET_STORY_ARGS, {
2830
1986
  storyId,
2831
1987
  argNames,
2832
1988
  options: { target: refId }
2833
1989
  });
2834
- }, "resetStoryArgs"),
2835
- fetchIndex: /* @__PURE__ */ __name(async () => {
1990
+ },
1991
+ fetchIndex: async () => {
2836
1992
  try {
2837
- const result = await fetch2(STORY_INDEX_PATH);
2838
- if (result.status !== 200) {
1993
+ let result = await fetch2(STORY_INDEX_PATH);
1994
+ if (result.status !== 200)
2839
1995
  throw new Error(await result.text());
2840
- }
2841
- const storyIndex = await result.json();
1996
+ let storyIndex = await result.json();
2842
1997
  if (storyIndex.v < 3) {
2843
1998
  logger5.warn(`Skipping story index with version v${storyIndex.v}, awaiting SET_STORIES.`);
2844
1999
  return;
@@ -2847,20 +2002,17 @@ var init11 = /* @__PURE__ */ __name(({
2847
2002
  } catch (err) {
2848
2003
  await store2.setState({ indexError: err });
2849
2004
  }
2850
- }, "fetchIndex"),
2005
+ },
2851
2006
  // The story index we receive on SET_INDEX is "prepared" in that it has parameters
2852
2007
  // The story index we receive on fetchStoryIndex is not, but all the prepared fields are optional
2853
2008
  // so we can cast one to the other easily enough
2854
- setIndex: /* @__PURE__ */ __name(async (input) => {
2855
- const { filteredIndex: oldFilteredHash, index: oldHash, filters } = store2.getState();
2856
- const allStatuses = fullStatusStore.getAll();
2857
- const newFilteredHash = transformStoryIndexToStoriesHash(input, {
2009
+ setIndex: async (input) => {
2010
+ let { filteredIndex: oldFilteredHash, index: oldHash, filters } = store2.getState(), allStatuses = fullStatusStore.getAll(), newFilteredHash = transformStoryIndexToStoriesHash(input, {
2858
2011
  provider,
2859
2012
  docsOptions,
2860
2013
  filters,
2861
2014
  allStatuses
2862
- });
2863
- const newHash = transformStoryIndexToStoriesHash(input, {
2015
+ }), newHash = transformStoryIndexToStoriesHash(input, {
2864
2016
  provider,
2865
2017
  docsOptions,
2866
2018
  filters: {},
@@ -2872,152 +2024,105 @@ var init11 = /* @__PURE__ */ __name(({
2872
2024
  index: addPreparedStories(newHash, oldHash),
2873
2025
  indexError: void 0
2874
2026
  });
2875
- }, "setIndex"),
2027
+ },
2876
2028
  // FIXME: is there a bug where filtered stories get added back in on updateStory???
2877
- updateStory: /* @__PURE__ */ __name(async (storyId, update2, ref) => {
2878
- if (!ref) {
2879
- const { index, filteredIndex } = store2.getState();
2880
- if (index) {
2881
- index[storyId] = {
2882
- ...index[storyId],
2883
- ...update2
2884
- };
2885
- }
2886
- if (filteredIndex) {
2887
- filteredIndex[storyId] = {
2888
- ...filteredIndex[storyId],
2889
- ...update2
2890
- };
2891
- }
2892
- if (index || filteredIndex) {
2893
- await store2.setState({ index, filteredIndex });
2894
- }
2895
- } else {
2896
- const { id: refId, index, filteredIndex } = ref;
2029
+ updateStory: async (storyId, update2, ref) => {
2030
+ if (ref) {
2031
+ let { id: refId, index, filteredIndex } = ref;
2897
2032
  index[storyId] = {
2898
2033
  ...index[storyId],
2899
2034
  ...update2
2900
- };
2901
- filteredIndex[storyId] = {
2035
+ }, filteredIndex[storyId] = {
2902
2036
  ...filteredIndex[storyId],
2903
2037
  ...update2
2904
- };
2905
- await fullAPI.updateRef(refId, { index, filteredIndex });
2906
- }
2907
- }, "updateStory"),
2908
- updateDocs: /* @__PURE__ */ __name(async (docsId, update2, ref) => {
2909
- if (!ref) {
2910
- const { index, filteredIndex } = store2.getState();
2911
- if (index) {
2912
- index[docsId] = {
2913
- ...index[docsId],
2914
- ...update2
2915
- };
2916
- }
2917
- if (filteredIndex) {
2918
- filteredIndex[docsId] = {
2919
- ...filteredIndex[docsId],
2920
- ...update2
2921
- };
2922
- }
2923
- if (index || filteredIndex) {
2924
- await store2.setState({ index, filteredIndex });
2925
- }
2038
+ }, await fullAPI.updateRef(refId, { index, filteredIndex });
2926
2039
  } else {
2927
- const { id: refId, index, filteredIndex } = ref;
2040
+ let { index, filteredIndex } = store2.getState();
2041
+ index && (index[storyId] = {
2042
+ ...index[storyId],
2043
+ ...update2
2044
+ }), filteredIndex && (filteredIndex[storyId] = {
2045
+ ...filteredIndex[storyId],
2046
+ ...update2
2047
+ }), (index || filteredIndex) && await store2.setState({ index, filteredIndex });
2048
+ }
2049
+ },
2050
+ updateDocs: async (docsId, update2, ref) => {
2051
+ if (ref) {
2052
+ let { id: refId, index, filteredIndex } = ref;
2928
2053
  index[docsId] = {
2929
2054
  ...index[docsId],
2930
2055
  ...update2
2931
- };
2932
- filteredIndex[docsId] = {
2056
+ }, filteredIndex[docsId] = {
2933
2057
  ...filteredIndex[docsId],
2934
2058
  ...update2
2935
- };
2936
- await fullAPI.updateRef(refId, { index, filteredIndex });
2937
- }
2938
- }, "updateDocs"),
2939
- setPreviewInitialized: /* @__PURE__ */ __name(async (ref) => {
2940
- if (!ref) {
2941
- store2.setState({ previewInitialized: true });
2059
+ }, await fullAPI.updateRef(refId, { index, filteredIndex });
2942
2060
  } else {
2943
- fullAPI.updateRef(ref.id, { previewInitialized: true });
2061
+ let { index, filteredIndex } = store2.getState();
2062
+ index && (index[docsId] = {
2063
+ ...index[docsId],
2064
+ ...update2
2065
+ }), filteredIndex && (filteredIndex[docsId] = {
2066
+ ...filteredIndex[docsId],
2067
+ ...update2
2068
+ }), (index || filteredIndex) && await store2.setState({ index, filteredIndex });
2944
2069
  }
2945
- }, "setPreviewInitialized"),
2946
- experimental_setFilter: /* @__PURE__ */ __name(async (id, filterFunction) => {
2070
+ },
2071
+ setPreviewInitialized: async (ref) => {
2072
+ ref ? fullAPI.updateRef(ref.id, { previewInitialized: !0 }) : store2.setState({ previewInitialized: !0 });
2073
+ },
2074
+ experimental_setFilter: async (id, filterFunction) => {
2947
2075
  await store2.setState({ filters: { ...store2.getState().filters, [id]: filterFunction } });
2948
- const { internal_index: index } = store2.getState();
2949
- if (!index) {
2076
+ let { internal_index: index } = store2.getState();
2077
+ if (!index)
2950
2078
  return;
2951
- }
2952
2079
  await api.setIndex(index);
2953
- const refs = await fullAPI.getRefs();
2080
+ let refs = await fullAPI.getRefs();
2954
2081
  Object.entries(refs).forEach(([refId, { internal_index, ...ref }]) => {
2955
- fullAPI.setRef(refId, { ...ref, storyIndex: internal_index }, true);
2956
- });
2957
- provider.channel?.emit(SET_FILTER, { id });
2958
- }, "experimental_setFilter")
2082
+ fullAPI.setRef(refId, { ...ref, storyIndex: internal_index }, !0);
2083
+ }), provider.channel?.emit(SET_FILTER, { id });
2084
+ }
2959
2085
  };
2960
2086
  provider.channel?.on(
2961
2087
  STORY_SPECIFIED,
2962
- /* @__PURE__ */ __name(function handler({
2088
+ function({
2963
2089
  storyId,
2964
2090
  viewMode
2965
2091
  }) {
2966
- const { sourceType } = getEventMetadata(this, fullAPI);
2092
+ let { sourceType } = getEventMetadata(this, fullAPI);
2967
2093
  if (sourceType === "local") {
2968
- const state = store2.getState();
2969
- const isCanvasRoute = state.path === "/" || state.viewMode === "story" || state.viewMode === "docs";
2970
- const stateHasSelection = state.viewMode && state.storyId;
2971
- const stateSelectionDifferent = state.viewMode !== viewMode || state.storyId !== storyId;
2972
- const { type } = state.index?.[state.storyId] || {};
2973
- const isStory = !(type === "root" || type === "component" || type === "group");
2974
- if (isCanvasRoute) {
2975
- if (stateHasSelection && stateSelectionDifferent && isStory) {
2976
- provider.channel?.emit(SET_CURRENT_STORY, {
2977
- storyId: state.storyId,
2978
- viewMode: state.viewMode
2979
- });
2980
- } else if (stateSelectionDifferent) {
2981
- navigate(`/${viewMode}/${storyId}`);
2982
- }
2983
- }
2094
+ let state = store2.getState(), isCanvasRoute = state.path === "/" || state.viewMode === "story" || state.viewMode === "docs", stateHasSelection = state.viewMode && state.storyId, stateSelectionDifferent = state.viewMode !== viewMode || state.storyId !== storyId, { type } = state.index?.[state.storyId] || {};
2095
+ isCanvasRoute && (stateHasSelection && stateSelectionDifferent && !(type === "root" || type === "component" || type === "group") ? provider.channel?.emit(SET_CURRENT_STORY, {
2096
+ storyId: state.storyId,
2097
+ viewMode: state.viewMode
2098
+ }) : stateSelectionDifferent && navigate(`/${viewMode}/${storyId}`));
2984
2099
  }
2985
- }, "handler")
2986
- );
2987
- provider.channel?.on(CURRENT_STORY_WAS_SET, /* @__PURE__ */ __name(function handler() {
2988
- const { ref } = getEventMetadata(this, fullAPI);
2100
+ }
2101
+ ), provider.channel?.on(CURRENT_STORY_WAS_SET, function() {
2102
+ let { ref } = getEventMetadata(this, fullAPI);
2989
2103
  api.setPreviewInitialized(ref);
2990
- }, "handler"));
2991
- provider.channel?.on(STORY_CHANGED, /* @__PURE__ */ __name(function handler() {
2992
- const { sourceType } = getEventMetadata(this, fullAPI);
2104
+ }), provider.channel?.on(STORY_CHANGED, function() {
2105
+ let { sourceType } = getEventMetadata(this, fullAPI);
2993
2106
  if (sourceType === "local") {
2994
- const options = api.getCurrentParameter("options");
2995
- if (options) {
2996
- fullAPI.setOptions(removeRemovedOptions(options));
2997
- }
2107
+ let options = api.getCurrentParameter("options");
2108
+ options && fullAPI.setOptions(removeRemovedOptions(options));
2998
2109
  }
2999
- }, "handler"));
3000
- provider.channel?.on(
2110
+ }), provider.channel?.on(
3001
2111
  STORY_PREPARED,
3002
- /* @__PURE__ */ __name(function handler({ id, ...update2 }) {
3003
- const { ref, sourceType } = getEventMetadata(this, fullAPI);
3004
- api.updateStory(id, { ...update2, prepared: true }, ref);
3005
- if (!ref) {
3006
- if (!store2.getState().hasCalledSetOptions) {
3007
- const { options } = update2.parameters;
3008
- fullAPI.setOptions(removeRemovedOptions(options));
3009
- store2.setState({ hasCalledSetOptions: true });
3010
- }
2112
+ function({ id, ...update2 }) {
2113
+ let { ref, sourceType } = getEventMetadata(this, fullAPI);
2114
+ if (api.updateStory(id, { ...update2, prepared: !0 }, ref), !ref && !store2.getState().hasCalledSetOptions) {
2115
+ let { options } = update2.parameters;
2116
+ fullAPI.setOptions(removeRemovedOptions(options)), store2.setState({ hasCalledSetOptions: !0 });
3011
2117
  }
3012
2118
  if (sourceType === "local") {
3013
- const { storyId, index, refId } = store2.getState();
3014
- if (!index) {
2119
+ let { storyId, index, refId } = store2.getState();
2120
+ if (!index)
3015
2121
  return;
3016
- }
3017
- const toBePreloaded = Array.from(
2122
+ let toBePreloaded = Array.from(
3018
2123
  /* @__PURE__ */ new Set([
3019
- api.findSiblingStoryId(storyId, index, 1, true),
3020
- api.findSiblingStoryId(storyId, index, -1, true)
2124
+ api.findSiblingStoryId(storyId, index, 1, !0),
2125
+ api.findSiblingStoryId(storyId, index, -1, !0)
3021
2126
  ])
3022
2127
  ).filter(Boolean);
3023
2128
  provider.channel?.emit(PRELOAD_ENTRIES, {
@@ -3025,37 +2130,31 @@ var init11 = /* @__PURE__ */ __name(({
3025
2130
  options: { target: refId }
3026
2131
  });
3027
2132
  }
3028
- }, "handler")
3029
- );
3030
- provider.channel?.on(
2133
+ }
2134
+ ), provider.channel?.on(
3031
2135
  DOCS_PREPARED,
3032
- /* @__PURE__ */ __name(function handler({ id, ...update2 }) {
3033
- const { ref } = getEventMetadata(this, fullAPI);
3034
- api.updateStory(id, { ...update2, prepared: true }, ref);
3035
- }, "handler")
3036
- );
3037
- provider.channel?.on(SET_INDEX, /* @__PURE__ */ __name(function handler(index) {
3038
- const { ref } = getEventMetadata(this, fullAPI);
3039
- if (!ref) {
2136
+ function({ id, ...update2 }) {
2137
+ let { ref } = getEventMetadata(this, fullAPI);
2138
+ api.updateStory(id, { ...update2, prepared: !0 }, ref);
2139
+ }
2140
+ ), provider.channel?.on(SET_INDEX, function(index) {
2141
+ let { ref } = getEventMetadata(this, fullAPI);
2142
+ if (ref)
2143
+ fullAPI.setRef(ref.id, { ...ref, storyIndex: index }, !0);
2144
+ else {
3040
2145
  api.setIndex(index);
3041
- const options = api.getCurrentParameter("options");
2146
+ let options = api.getCurrentParameter("options");
3042
2147
  fullAPI.setOptions(removeRemovedOptions(options));
3043
- } else {
3044
- fullAPI.setRef(ref.id, { ...ref, storyIndex: index }, true);
3045
2148
  }
3046
- }, "handler"));
3047
- provider.channel?.on(SET_STORIES, /* @__PURE__ */ __name(function handler(data) {
3048
- const { ref } = getEventMetadata(this, fullAPI);
3049
- const setStoriesData = data.v ? denormalizeStoryParameters(data) : data.stories;
3050
- if (!ref) {
2149
+ }), provider.channel?.on(SET_STORIES, function(data) {
2150
+ let { ref } = getEventMetadata(this, fullAPI), setStoriesData = data.v ? denormalizeStoryParameters(data) : data.stories;
2151
+ if (ref)
2152
+ fullAPI.setRef(ref.id, { ...ref, setStoriesData }, !0);
2153
+ else
3051
2154
  throw new Error("Cannot call SET_STORIES for local frame");
3052
- } else {
3053
- fullAPI.setRef(ref.id, { ...ref, setStoriesData }, true);
3054
- }
3055
- }, "handler"));
3056
- provider.channel?.on(
2155
+ }), provider.channel?.on(
3057
2156
  SELECT_STORY,
3058
- /* @__PURE__ */ __name(function handler({
2157
+ function({
3059
2158
  kind,
3060
2159
  title = kind,
3061
2160
  story,
@@ -3063,67 +2162,54 @@ var init11 = /* @__PURE__ */ __name(({
3063
2162
  storyId,
3064
2163
  ...rest
3065
2164
  }) {
3066
- const { ref } = getEventMetadata(this, fullAPI);
3067
- if (!ref) {
3068
- fullAPI.selectStory(storyId || title, name, rest);
3069
- } else {
3070
- fullAPI.selectStory(storyId || title, name, { ...rest, ref: ref.id });
3071
- }
3072
- }, "handler")
3073
- );
3074
- provider.channel?.on(
2165
+ let { ref } = getEventMetadata(this, fullAPI);
2166
+ ref ? fullAPI.selectStory(storyId || title, name, { ...rest, ref: ref.id }) : fullAPI.selectStory(storyId || title, name, rest);
2167
+ }
2168
+ ), provider.channel?.on(
3075
2169
  STORY_ARGS_UPDATED,
3076
- /* @__PURE__ */ __name(function handleStoryArgsUpdated({ storyId, args }) {
3077
- const { ref } = getEventMetadata(this, fullAPI);
2170
+ function({ storyId, args }) {
2171
+ let { ref } = getEventMetadata(this, fullAPI);
3078
2172
  api.updateStory(storyId, { args }, ref);
3079
- }, "handleStoryArgsUpdated")
3080
- );
3081
- provider.channel?.on(CONFIG_ERROR, /* @__PURE__ */ __name(function handleConfigError(err) {
3082
- const { ref } = getEventMetadata(this, fullAPI);
2173
+ }
2174
+ ), provider.channel?.on(CONFIG_ERROR, function(err) {
2175
+ let { ref } = getEventMetadata(this, fullAPI);
3083
2176
  api.setPreviewInitialized(ref);
3084
- }, "handleConfigError"));
3085
- provider.channel?.on(STORY_MISSING, /* @__PURE__ */ __name(function handleConfigError(err) {
3086
- const { ref } = getEventMetadata(this, fullAPI);
2177
+ }), provider.channel?.on(STORY_MISSING, function(err) {
2178
+ let { ref } = getEventMetadata(this, fullAPI);
3087
2179
  api.setPreviewInitialized(ref);
3088
- }, "handleConfigError"));
3089
- provider.channel?.on(SET_CONFIG3, () => {
3090
- const config2 = provider.getConfig();
3091
- if (config2?.sidebar?.filters) {
3092
- store2.setState({
3093
- filters: {
3094
- ...store2.getState().filters,
3095
- ...config2?.sidebar?.filters
3096
- }
3097
- });
3098
- }
3099
- });
3100
- fullStatusStore.onAllStatusChange(async () => {
3101
- const { internal_index: index } = store2.getState();
3102
- if (!index) {
2180
+ }), provider.channel?.on(SET_CONFIG3, () => {
2181
+ let config2 = provider.getConfig();
2182
+ config2?.sidebar?.filters && store2.setState({
2183
+ filters: {
2184
+ ...store2.getState().filters,
2185
+ ...config2?.sidebar?.filters
2186
+ }
2187
+ });
2188
+ }), fullStatusStore.onAllStatusChange(async () => {
2189
+ let { internal_index: index } = store2.getState();
2190
+ if (!index)
3103
2191
  return;
3104
- }
3105
2192
  await api.setIndex(index);
3106
- const refs = await fullAPI.getRefs();
2193
+ let refs = await fullAPI.getRefs();
3107
2194
  Object.entries(refs).forEach(([refId, { internal_index, ...ref }]) => {
3108
- fullAPI.setRef(refId, { ...ref, storyIndex: internal_index }, true);
2195
+ fullAPI.setRef(refId, { ...ref, storyIndex: internal_index }, !0);
3109
2196
  });
3110
2197
  });
3111
- const config = provider.getConfig();
2198
+ let config = provider.getConfig();
3112
2199
  return {
3113
2200
  api,
3114
2201
  state: {
3115
2202
  storyId: initialStoryId,
3116
2203
  viewMode: initialViewMode,
3117
- hasCalledSetOptions: false,
3118
- previewInitialized: false,
2204
+ hasCalledSetOptions: !1,
2205
+ previewInitialized: !1,
3119
2206
  filters: config?.sidebar?.filters || {}
3120
2207
  },
3121
- init: /* @__PURE__ */ __name(async () => {
3122
- provider.channel?.on(STORY_INDEX_INVALIDATED, () => api.fetchIndex());
3123
- await api.fetchIndex();
3124
- }, "init")
2208
+ init: async () => {
2209
+ provider.channel?.on(STORY_INDEX_INVALIDATED, () => api.fetchIndex()), await api.fetchIndex();
2210
+ }
3125
2211
  };
3126
- }, "init");
2212
+ };
3127
2213
 
3128
2214
  // src/manager-api/modules/url.ts
3129
2215
  var url_exports = {};
@@ -3139,22 +2225,16 @@ import {
3139
2225
  } from "storybook/internal/core-events";
3140
2226
  import { buildArgsParam, queryFromLocation } from "storybook/internal/router";
3141
2227
  import { global as global7 } from "@storybook/global";
3142
- var { window: globalWindow } = global7;
3143
- var parseBoolean = /* @__PURE__ */ __name((value) => {
3144
- if (value === "true" || value === "1") {
3145
- return true;
3146
- }
3147
- if (value === "false" || value === "0") {
3148
- return false;
3149
- }
3150
- return void 0;
3151
- }, "parseBoolean");
3152
- var prevParams;
3153
- var initialUrlSupport = /* @__PURE__ */ __name(({
2228
+ var { window: globalWindow } = global7, parseBoolean = (value) => {
2229
+ if (value === "true" || value === "1")
2230
+ return !0;
2231
+ if (value === "false" || value === "0")
2232
+ return !1;
2233
+ }, prevParams, initialUrlSupport = ({
3154
2234
  state: { location: location2, path, viewMode, storyId: storyIdFromUrl },
3155
2235
  singleStory
3156
2236
  }) => {
3157
- const {
2237
+ let {
3158
2238
  full,
3159
2239
  panel,
3160
2240
  nav,
@@ -3164,61 +2244,29 @@ var initialUrlSupport = /* @__PURE__ */ __name(({
3164
2244
  path: queryPath,
3165
2245
  ...otherParams
3166
2246
  // the rest gets passed to the iframe
3167
- } = queryFromLocation(location2);
3168
- let navSize;
3169
- let bottomPanelHeight;
3170
- let rightPanelWidth;
3171
- if (parseBoolean(full) === true) {
3172
- navSize = 0;
3173
- bottomPanelHeight = 0;
3174
- rightPanelWidth = 0;
3175
- } else if (parseBoolean(full) === false) {
3176
- navSize = defaultLayoutState.layout.navSize;
3177
- bottomPanelHeight = defaultLayoutState.layout.bottomPanelHeight;
3178
- rightPanelWidth = defaultLayoutState.layout.rightPanelWidth;
3179
- }
3180
- if (!singleStory) {
3181
- if (parseBoolean(nav) === true) {
3182
- navSize = defaultLayoutState.layout.navSize;
3183
- }
3184
- if (parseBoolean(nav) === false) {
3185
- navSize = 0;
3186
- }
3187
- }
3188
- if (parseBoolean(panel) === false) {
3189
- bottomPanelHeight = 0;
3190
- rightPanelWidth = 0;
3191
- }
3192
- const layout = {
2247
+ } = queryFromLocation(location2), navSize, bottomPanelHeight, rightPanelWidth;
2248
+ parseBoolean(full) === !0 ? (navSize = 0, bottomPanelHeight = 0, rightPanelWidth = 0) : parseBoolean(full) === !1 && (navSize = defaultLayoutState.layout.navSize, bottomPanelHeight = defaultLayoutState.layout.bottomPanelHeight, rightPanelWidth = defaultLayoutState.layout.rightPanelWidth), singleStory || (parseBoolean(nav) === !0 && (navSize = defaultLayoutState.layout.navSize), parseBoolean(nav) === !1 && (navSize = 0)), parseBoolean(panel) === !1 && (bottomPanelHeight = 0, rightPanelWidth = 0);
2249
+ let layout = {
3193
2250
  navSize,
3194
2251
  bottomPanelHeight,
3195
2252
  rightPanelWidth,
3196
2253
  panelPosition: ["right", "bottom"].includes(panel) ? panel : void 0,
3197
2254
  showTabs: parseBoolean(tabs)
3198
- };
3199
- const ui = {
2255
+ }, ui = {
3200
2256
  enableShortcuts: parseBoolean(shortcuts)
3201
- };
3202
- const selectedPanel = addonPanel || void 0;
3203
- const storyId = storyIdFromUrl;
3204
- const customQueryParams = dequal(prevParams, otherParams) ? prevParams : otherParams;
3205
- prevParams = customQueryParams;
3206
- return { viewMode, layout, ui, selectedPanel, location: location2, path, customQueryParams, storyId };
3207
- }, "initialUrlSupport");
3208
- var init12 = /* @__PURE__ */ __name((moduleArgs) => {
3209
- const { store: store2, navigate, provider, fullAPI } = moduleArgs;
3210
- const navigateTo = /* @__PURE__ */ __name((path, queryParams = {}, options = {}) => {
3211
- const params = Object.entries(queryParams).filter(([, v]) => v).sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${k}=${v}`);
3212
- const to = [path, ...params].join("&");
2257
+ }, selectedPanel = addonPanel || void 0, storyId = storyIdFromUrl, customQueryParams = dequal(prevParams, otherParams) ? prevParams : otherParams;
2258
+ return prevParams = customQueryParams, { viewMode, layout, ui, selectedPanel, location: location2, path, customQueryParams, storyId };
2259
+ }, init12 = (moduleArgs) => {
2260
+ let { store: store2, navigate, provider, fullAPI } = moduleArgs, navigateTo = (path, queryParams = {}, options = {}) => {
2261
+ let params = Object.entries(queryParams).filter(([, v]) => v).sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${k}=${v}`), to = [path, ...params].join("&");
3213
2262
  return navigate(to, options);
3214
- }, "navigateTo");
3215
- const api = {
2263
+ }, api = {
3216
2264
  getQueryParam(key) {
3217
- const { customQueryParams } = store2.getState();
2265
+ let { customQueryParams } = store2.getState();
3218
2266
  return customQueryParams ? customQueryParams[key] : void 0;
3219
2267
  },
3220
2268
  getUrlState() {
3221
- const { location: location2, path, customQueryParams, storyId, url, viewMode } = store2.getState();
2269
+ let { location: location2, path, customQueryParams, storyId, url, viewMode } = store2.getState();
3222
2270
  return {
3223
2271
  path,
3224
2272
  hash: location2.hash ?? "",
@@ -3229,74 +2277,43 @@ var init12 = /* @__PURE__ */ __name((moduleArgs) => {
3229
2277
  };
3230
2278
  },
3231
2279
  setQueryParams(input) {
3232
- const { customQueryParams } = store2.getState();
3233
- const queryParams = {};
3234
- const update2 = {
2280
+ let { customQueryParams } = store2.getState(), queryParams = {}, update2 = {
3235
2281
  ...customQueryParams,
3236
- ...Object.entries(input).reduce((acc, [key, value]) => {
3237
- if (value !== null) {
3238
- acc[key] = value;
3239
- }
3240
- return acc;
3241
- }, queryParams)
2282
+ ...Object.entries(input).reduce((acc, [key, value]) => (value !== null && (acc[key] = value), acc), queryParams)
3242
2283
  };
3243
- if (!dequal(customQueryParams, update2)) {
3244
- store2.setState({ customQueryParams: update2 });
3245
- provider.channel?.emit(UPDATE_QUERY_PARAMS, update2);
3246
- }
2284
+ dequal(customQueryParams, update2) || (store2.setState({ customQueryParams: update2 }), provider.channel?.emit(UPDATE_QUERY_PARAMS, update2));
3247
2285
  },
3248
2286
  applyQueryParams(input, options) {
3249
- const { path, hash = "", queryParams } = api.getUrlState();
3250
- navigateTo(`${path}${hash}`, { ...queryParams, ...input }, options);
3251
- api.setQueryParams(input);
2287
+ let { path, hash = "", queryParams } = api.getUrlState();
2288
+ navigateTo(`${path}${hash}`, { ...queryParams, ...input }, options), api.setQueryParams(input);
3252
2289
  },
3253
2290
  navigateUrl(url, options) {
3254
- navigate(url, { plain: true, ...options });
2291
+ navigate(url, { plain: !0, ...options });
3255
2292
  }
3256
- };
3257
- const updateArgsParam = /* @__PURE__ */ __name(() => {
3258
- const { path, hash = "", queryParams, viewMode } = api.getUrlState();
3259
- if (viewMode !== "story") {
2293
+ }, updateArgsParam = () => {
2294
+ let { path, hash = "", queryParams, viewMode } = api.getUrlState();
2295
+ if (viewMode !== "story")
3260
2296
  return;
3261
- }
3262
- const currentStory = fullAPI.getCurrentStoryData();
3263
- if (currentStory?.type !== "story") {
2297
+ let currentStory = fullAPI.getCurrentStoryData();
2298
+ if (currentStory?.type !== "story")
3264
2299
  return;
3265
- }
3266
- const { args, initialArgs } = currentStory;
3267
- const argsString = buildArgsParam(initialArgs, args);
3268
- navigateTo(`${path}${hash}`, { ...queryParams, args: argsString }, { replace: true });
3269
- api.setQueryParams({ args: argsString });
3270
- }, "updateArgsParam");
2300
+ let { args, initialArgs } = currentStory, argsString = buildArgsParam(initialArgs, args);
2301
+ navigateTo(`${path}${hash}`, { ...queryParams, args: argsString }, { replace: !0 }), api.setQueryParams({ args: argsString });
2302
+ };
3271
2303
  provider.channel?.on(SET_CURRENT_STORY2, () => updateArgsParam());
3272
2304
  let handleOrId;
3273
- provider.channel?.on(STORY_ARGS_UPDATED2, () => {
3274
- if ("requestIdleCallback" in globalWindow) {
3275
- if (handleOrId) {
3276
- globalWindow.cancelIdleCallback(handleOrId);
3277
- }
3278
- handleOrId = globalWindow.requestIdleCallback(updateArgsParam, { timeout: 1e3 });
3279
- } else {
3280
- if (handleOrId) {
3281
- clearTimeout(handleOrId);
3282
- }
3283
- setTimeout(updateArgsParam, 100);
3284
- }
3285
- });
3286
- provider.channel?.on(GLOBALS_UPDATED2, ({ userGlobals, initialGlobals }) => {
3287
- const { path, hash = "", queryParams } = api.getUrlState();
3288
- const globalsString = buildArgsParam(initialGlobals, userGlobals);
3289
- navigateTo(`${path}${hash}`, { ...queryParams, globals: globalsString }, { replace: true });
3290
- api.setQueryParams({ globals: globalsString });
3291
- });
3292
- provider.channel?.on(NAVIGATE_URL, (url, options) => {
2305
+ return provider.channel?.on(STORY_ARGS_UPDATED2, () => {
2306
+ "requestIdleCallback" in globalWindow ? (handleOrId && globalWindow.cancelIdleCallback(handleOrId), handleOrId = globalWindow.requestIdleCallback(updateArgsParam, { timeout: 1e3 })) : (handleOrId && clearTimeout(handleOrId), setTimeout(updateArgsParam, 100));
2307
+ }), provider.channel?.on(GLOBALS_UPDATED2, ({ userGlobals, initialGlobals }) => {
2308
+ let { path, hash = "", queryParams } = api.getUrlState(), globalsString = buildArgsParam(initialGlobals, userGlobals);
2309
+ navigateTo(`${path}${hash}`, { ...queryParams, globals: globalsString }, { replace: !0 }), api.setQueryParams({ globals: globalsString });
2310
+ }), provider.channel?.on(NAVIGATE_URL, (url, options) => {
3293
2311
  api.navigateUrl(url, options);
3294
- });
3295
- return {
2312
+ }), {
3296
2313
  api,
3297
2314
  state: initialUrlSupport(moduleArgs)
3298
2315
  };
3299
- }, "init");
2316
+ };
3300
2317
 
3301
2318
  // src/manager-api/modules/versions.ts
3302
2319
  var versions_exports = {};
@@ -3308,26 +2325,17 @@ import { global as global8 } from "@storybook/global";
3308
2325
  import semver from "semver";
3309
2326
 
3310
2327
  // src/manager-api/version.ts
3311
- var version = "10.1.0-alpha.10";
2328
+ var version = "10.1.0-alpha.11";
3312
2329
 
3313
2330
  // src/manager-api/modules/versions.ts
3314
- var { VERSIONCHECK } = global8;
3315
- var getVersionCheckData = (0, import_memoizerific2.default)(1)(() => {
2331
+ var { VERSIONCHECK } = global8, getVersionCheckData = (0, import_memoizerific2.default)(1)(() => {
3316
2332
  try {
3317
2333
  return { ...JSON.parse(VERSIONCHECK).data || {} };
3318
- } catch (e) {
2334
+ } catch {
3319
2335
  return {};
3320
2336
  }
3321
- });
3322
- var normalizeRendererName = /* @__PURE__ */ __name((renderer) => {
3323
- if (renderer.includes("vue")) {
3324
- return "vue";
3325
- }
3326
- return renderer;
3327
- }, "normalizeRendererName");
3328
- var init13 = /* @__PURE__ */ __name(({ store: store2 }) => {
3329
- const { dismissedVersionNotification } = store2.getState();
3330
- const state = {
2337
+ }), normalizeRendererName = (renderer) => renderer.includes("vue") ? "vue" : renderer, init13 = ({ store: store2 }) => {
2338
+ let { dismissedVersionNotification } = store2.getState(), state = {
3331
2339
  versions: {
3332
2340
  current: {
3333
2341
  version
@@ -3335,81 +2343,56 @@ var init13 = /* @__PURE__ */ __name(({ store: store2 }) => {
3335
2343
  ...getVersionCheckData()
3336
2344
  },
3337
2345
  dismissedVersionNotification
3338
- };
3339
- const api = {
3340
- getCurrentVersion: /* @__PURE__ */ __name(() => {
3341
- const {
2346
+ }, api = {
2347
+ getCurrentVersion: () => {
2348
+ let {
3342
2349
  versions: { current }
3343
2350
  } = store2.getState();
3344
2351
  return current;
3345
- }, "getCurrentVersion"),
3346
- getLatestVersion: /* @__PURE__ */ __name(() => {
3347
- const {
2352
+ },
2353
+ getLatestVersion: () => {
2354
+ let {
3348
2355
  versions: { latest, next, current }
3349
2356
  } = store2.getState();
3350
- if (current && semver.prerelease(current.version) && next) {
3351
- return latest && semver.gt(latest.version, next.version) ? latest : next;
3352
- }
3353
- return latest;
3354
- }, "getLatestVersion"),
2357
+ return current && semver.prerelease(current.version) && next ? latest && semver.gt(latest.version, next.version) ? latest : next : latest;
2358
+ },
3355
2359
  // TODO: Move this to it's own "info" module later
3356
- getDocsUrl: /* @__PURE__ */ __name(({ subpath, versioned, renderer }) => {
3357
- const {
2360
+ getDocsUrl: ({ subpath, versioned, renderer }) => {
2361
+ let {
3358
2362
  versions: { latest, current }
3359
- } = store2.getState();
3360
- let url = "https://storybook.js.org/docs/";
2363
+ } = store2.getState(), url = "https://storybook.js.org/docs/";
3361
2364
  if (versioned && current?.version && latest?.version) {
3362
- const versionDiff = semver.diff(latest.version, current.version);
3363
- const isLatestDocs = versionDiff === "patch" || versionDiff === null || // assume latest version when current version is a 0.0.0 canary
3364
- semver.satisfies(current.version, "0.0.0", { includePrerelease: true });
3365
- if (!isLatestDocs) {
3366
- url += `${semver.major(current.version)}.${semver.minor(current.version)}/`;
3367
- }
2365
+ let versionDiff = semver.diff(latest.version, current.version);
2366
+ versionDiff === "patch" || versionDiff === null || // assume latest version when current version is a 0.0.0 canary
2367
+ semver.satisfies(current.version, "0.0.0", { includePrerelease: !0 }) || (url += `${semver.major(current.version)}.${semver.minor(current.version)}/`);
3368
2368
  }
3369
- const [cleanedSubpath, hash] = subpath?.split("#") || [];
3370
- if (cleanedSubpath) {
3371
- url += `${cleanedSubpath}/`;
2369
+ let [cleanedSubpath, hash] = subpath?.split("#") || [];
2370
+ if (cleanedSubpath && (url += `${cleanedSubpath}/`), renderer && typeof global8.STORYBOOK_RENDERER < "u") {
2371
+ let rendererName = global8.STORYBOOK_RENDERER;
2372
+ rendererName && (url += `?renderer=${normalizeRendererName(rendererName)}`);
3372
2373
  }
3373
- if (renderer && typeof global8.STORYBOOK_RENDERER !== "undefined") {
3374
- const rendererName = global8.STORYBOOK_RENDERER;
3375
- if (rendererName) {
3376
- url += `?renderer=${normalizeRendererName(rendererName)}`;
3377
- }
3378
- }
3379
- if (hash) {
3380
- url += `#${hash}`;
3381
- }
3382
- return url;
3383
- }, "getDocsUrl"),
3384
- versionUpdateAvailable: /* @__PURE__ */ __name(() => {
3385
- const latest = api.getLatestVersion();
3386
- const current = api.getCurrentVersion();
2374
+ return hash && (url += `#${hash}`), url;
2375
+ },
2376
+ versionUpdateAvailable: () => {
2377
+ let latest = api.getLatestVersion(), current = api.getCurrentVersion();
3387
2378
  if (latest) {
3388
- if (!latest.version) {
3389
- return true;
3390
- }
3391
- if (!current.version) {
3392
- return true;
3393
- }
3394
- const onPrerelease = !!semver.prerelease(current.version);
3395
- const actualCurrent = onPrerelease ? `${semver.major(current.version)}.${semver.minor(current.version)}.${semver.patch(
2379
+ if (!latest.version || !current.version)
2380
+ return !0;
2381
+ let actualCurrent = !!semver.prerelease(current.version) ? `${semver.major(current.version)}.${semver.minor(current.version)}.${semver.patch(
3396
2382
  current.version
3397
- )}` : current.version;
3398
- const diff = semver.diff(actualCurrent, latest.version);
2383
+ )}` : current.version, diff = semver.diff(actualCurrent, latest.version);
3399
2384
  return semver.gt(latest.version, actualCurrent) && diff !== "patch" && !diff.includes("pre");
3400
2385
  }
3401
- return false;
3402
- }, "versionUpdateAvailable")
2386
+ return !1;
2387
+ }
3403
2388
  };
3404
- const initModule = /* @__PURE__ */ __name(async () => {
3405
- const { versions = {} } = store2.getState();
3406
- const { latest, next } = getVersionCheckData();
2389
+ return { init: async () => {
2390
+ let { versions = {} } = store2.getState(), { latest, next } = getVersionCheckData();
3407
2391
  await store2.setState({
3408
2392
  versions: { ...versions, latest, next }
3409
2393
  });
3410
- }, "initModule");
3411
- return { init: initModule, state, api };
3412
- }, "init");
2394
+ }, state, api };
2395
+ };
3413
2396
 
3414
2397
  // src/manager-api/modules/whatsnew.tsx
3415
2398
  var whatsnew_exports = {};
@@ -3424,107 +2407,84 @@ import {
3424
2407
  TOGGLE_WHATS_NEW_NOTIFICATIONS
3425
2408
  } from "storybook/internal/core-events";
3426
2409
  import { global as global9 } from "@storybook/global";
3427
- var WHATS_NEW_NOTIFICATION_ID = "whats-new";
3428
- var StorybookIcon = /* @__PURE__ */ __name(({ color = "currentColor", size = 14 }) => {
3429
- return React3.createElement(
3430
- "svg",
2410
+ var WHATS_NEW_NOTIFICATION_ID = "whats-new", StorybookIcon = ({ color = "currentColor", size = 14 }) => React3.createElement(
2411
+ "svg",
2412
+ {
2413
+ width: size,
2414
+ height: size,
2415
+ viewBox: "0 0 14 14",
2416
+ fill: "none",
2417
+ xmlns: "http://www.w3.org/2000/svg"
2418
+ },
2419
+ React3.createElement(
2420
+ "path",
3431
2421
  {
3432
- width: size,
3433
- height: size,
3434
- viewBox: "0 0 14 14",
3435
- fill: "none",
3436
- xmlns: "http://www.w3.org/2000/svg"
3437
- },
3438
- React3.createElement(
3439
- "path",
3440
- {
3441
- fillRule: "evenodd",
3442
- clipRule: "evenodd",
3443
- d: "M2.042.616a.704.704 0 00-.66.729L1.816 12.9c.014.367.306.66.672.677l9.395.422h.032a.704.704 0 00.704-.703V.704c0-.015 0-.03-.002-.044a.704.704 0 00-.746-.659l-.773.049.057 1.615a.105.105 0 01-.17.086l-.52-.41-.617.468a.105.105 0 01-.168-.088L9.746.134 2.042.616zm8.003 4.747c-.247.192-2.092.324-2.092.05.04-1.045-.429-1.091-.689-1.091-.247 0-.662.075-.662.634 0 .57.607.893 1.32 1.27 1.014.538 2.24 1.188 2.24 2.823 0 1.568-1.273 2.433-2.898 2.433-1.676 0-3.141-.678-2.976-3.03.065-.275 2.197-.21 2.197 0-.026.971.195 1.256.753 1.256.43 0 .624-.236.624-.634 0-.602-.633-.958-1.361-1.367-.987-.554-2.148-1.205-2.148-2.7 0-1.494 1.027-2.489 2.86-2.489 1.832 0 2.832.98 2.832 2.845z",
3444
- fill: color
3445
- }
3446
- )
3447
- );
3448
- }, "StorybookIcon");
3449
- var init14 = /* @__PURE__ */ __name(({ fullAPI, store: store2, provider }) => {
3450
- const state = {
2422
+ fillRule: "evenodd",
2423
+ clipRule: "evenodd",
2424
+ d: "M2.042.616a.704.704 0 00-.66.729L1.816 12.9c.014.367.306.66.672.677l9.395.422h.032a.704.704 0 00.704-.703V.704c0-.015 0-.03-.002-.044a.704.704 0 00-.746-.659l-.773.049.057 1.615a.105.105 0 01-.17.086l-.52-.41-.617.468a.105.105 0 01-.168-.088L9.746.134 2.042.616zm8.003 4.747c-.247.192-2.092.324-2.092.05.04-1.045-.429-1.091-.689-1.091-.247 0-.662.075-.662.634 0 .57.607.893 1.32 1.27 1.014.538 2.24 1.188 2.24 2.823 0 1.568-1.273 2.433-2.898 2.433-1.676 0-3.141-.678-2.976-3.03.065-.275 2.197-.21 2.197 0-.026.971.195 1.256.753 1.256.43 0 .624-.236.624-.634 0-.602-.633-.958-1.361-1.367-.987-.554-2.148-1.205-2.148-2.7 0-1.494 1.027-2.489 2.86-2.489 1.832 0 2.832.98 2.832 2.845z",
2425
+ fill: color
2426
+ }
2427
+ )
2428
+ ), init14 = ({ fullAPI, store: store2, provider }) => {
2429
+ let state = {
3451
2430
  whatsNewData: void 0
3452
2431
  };
3453
2432
  function setWhatsNewState(newState) {
3454
- store2.setState({ whatsNewData: newState });
3455
- state.whatsNewData = newState;
2433
+ store2.setState({ whatsNewData: newState }), state.whatsNewData = newState;
3456
2434
  }
3457
- __name(setWhatsNewState, "setWhatsNewState");
3458
- const api = {
2435
+ let api = {
3459
2436
  isWhatsNewUnread() {
3460
2437
  return state.whatsNewData?.status === "SUCCESS" && !state.whatsNewData.postIsRead;
3461
2438
  },
3462
2439
  whatsNewHasBeenRead() {
3463
- if (state.whatsNewData?.status === "SUCCESS") {
3464
- setWhatsNewCache({ lastReadPost: state.whatsNewData.url });
3465
- setWhatsNewState({ ...state.whatsNewData, postIsRead: true });
3466
- fullAPI.clearNotification(WHATS_NEW_NOTIFICATION_ID);
3467
- }
2440
+ state.whatsNewData?.status === "SUCCESS" && (setWhatsNewCache({ lastReadPost: state.whatsNewData.url }), setWhatsNewState({ ...state.whatsNewData, postIsRead: !0 }), fullAPI.clearNotification(WHATS_NEW_NOTIFICATION_ID));
3468
2441
  },
3469
2442
  toggleWhatsNewNotifications() {
3470
- if (state.whatsNewData?.status === "SUCCESS") {
3471
- setWhatsNewState({
3472
- ...state.whatsNewData,
3473
- disableWhatsNewNotifications: !state.whatsNewData.disableWhatsNewNotifications
3474
- });
3475
- provider.channel?.emit(TOGGLE_WHATS_NEW_NOTIFICATIONS, {
3476
- disableWhatsNewNotifications: state.whatsNewData.disableWhatsNewNotifications
3477
- });
3478
- }
2443
+ state.whatsNewData?.status === "SUCCESS" && (setWhatsNewState({
2444
+ ...state.whatsNewData,
2445
+ disableWhatsNewNotifications: !state.whatsNewData.disableWhatsNewNotifications
2446
+ }), provider.channel?.emit(TOGGLE_WHATS_NEW_NOTIFICATIONS, {
2447
+ disableWhatsNewNotifications: state.whatsNewData.disableWhatsNewNotifications
2448
+ }));
3479
2449
  }
3480
2450
  };
3481
2451
  function getLatestWhatsNewPost() {
3482
- provider.channel?.emit(REQUEST_WHATS_NEW_DATA);
3483
- return new Promise(
2452
+ return provider.channel?.emit(REQUEST_WHATS_NEW_DATA), new Promise(
3484
2453
  (resolve) => provider.channel?.once(
3485
2454
  RESULT_WHATS_NEW_DATA,
3486
2455
  ({ data }) => resolve(data)
3487
2456
  )
3488
2457
  );
3489
2458
  }
3490
- __name(getLatestWhatsNewPost, "getLatestWhatsNewPost");
3491
2459
  function setWhatsNewCache(cache) {
3492
2460
  provider.channel?.emit(SET_WHATS_NEW_CACHE, cache);
3493
2461
  }
3494
- __name(setWhatsNewCache, "setWhatsNewCache");
3495
- const initModule = /* @__PURE__ */ __name(async () => {
3496
- if (global9.CONFIG_TYPE !== "DEVELOPMENT") {
2462
+ return { init: async () => {
2463
+ if (global9.CONFIG_TYPE !== "DEVELOPMENT")
3497
2464
  return;
3498
- }
3499
- const whatsNewData = await getLatestWhatsNewPost();
2465
+ let whatsNewData = await getLatestWhatsNewPost();
3500
2466
  setWhatsNewState(whatsNewData);
3501
- const urlState = fullAPI.getUrlState();
3502
- const isOnboardingView = urlState?.path === "/onboarding" || urlState.queryParams?.onboarding === "true";
3503
- if (!isOnboardingView && whatsNewData.status === "SUCCESS" && !whatsNewData.disableWhatsNewNotifications && whatsNewData.showNotification) {
3504
- fullAPI.addNotification({
3505
- id: WHATS_NEW_NOTIFICATION_ID,
3506
- link: "/settings/whats-new",
3507
- content: {
3508
- headline: whatsNewData.title,
3509
- subHeadline: "Learn what's new in Storybook"
3510
- },
3511
- icon: React3.createElement(StorybookIcon, null),
3512
- onClear({ dismissed }) {
3513
- if (dismissed) {
3514
- setWhatsNewCache({ lastDismissedPost: whatsNewData.url });
3515
- }
3516
- }
3517
- });
3518
- }
3519
- }, "initModule");
3520
- return { init: initModule, state, api };
3521
- }, "init");
2467
+ let urlState = fullAPI.getUrlState();
2468
+ !(urlState?.path === "/onboarding" || urlState.queryParams?.onboarding === "true") && whatsNewData.status === "SUCCESS" && !whatsNewData.disableWhatsNewNotifications && whatsNewData.showNotification && fullAPI.addNotification({
2469
+ id: WHATS_NEW_NOTIFICATION_ID,
2470
+ link: "/settings/whats-new",
2471
+ content: {
2472
+ headline: whatsNewData.title,
2473
+ subHeadline: "Learn what's new in Storybook"
2474
+ },
2475
+ icon: React3.createElement(StorybookIcon, null),
2476
+ onClear({ dismissed }) {
2477
+ dismissed && setWhatsNewCache({ lastDismissedPost: whatsNewData.url });
2478
+ }
2479
+ });
2480
+ }, state, api };
2481
+ };
3522
2482
 
3523
2483
  // src/manager-api/store.ts
3524
2484
  var import_store2 = __toESM(require_store2(), 1);
3525
2485
 
3526
2486
  // src/manager-api/lib/store-setup.ts
3527
- var store_setup_default = /* @__PURE__ */ __name((_) => {
2487
+ var store_setup_default = (_) => {
3528
2488
  _.fn("set", function(key, data) {
3529
2489
  return _.set(
3530
2490
  // @ts-expect-error('this' implicitly has type 'any')
@@ -3533,34 +2493,28 @@ var store_setup_default = /* @__PURE__ */ __name((_) => {
3533
2493
  this._in(key),
3534
2494
  stringify(data, { maxDepth: 50 })
3535
2495
  );
3536
- });
3537
- _.fn("get", function(key, alt) {
3538
- const value = _.get(this._area, this._in(key));
2496
+ }), _.fn("get", function(key, alt) {
2497
+ let value = _.get(this._area, this._in(key));
3539
2498
  return value !== null ? parse(value) : alt || value;
3540
2499
  });
3541
- }, "default");
2500
+ };
3542
2501
 
3543
2502
  // src/manager-api/store.ts
3544
2503
  store_setup_default(import_store2.default._);
3545
2504
  var STORAGE_KEY = "@storybook/manager/store";
3546
2505
  function get(storage) {
3547
- const data = storage.get(STORAGE_KEY);
3548
- return data || {};
2506
+ return storage.get(STORAGE_KEY) || {};
3549
2507
  }
3550
- __name(get, "get");
3551
2508
  function set(storage, value) {
3552
2509
  return storage.set(STORAGE_KEY, value);
3553
2510
  }
3554
- __name(set, "set");
3555
2511
  function update(storage, patch) {
3556
- const previous = get(storage);
2512
+ let previous = get(storage);
3557
2513
  return set(storage, { ...previous, ...patch });
3558
2514
  }
3559
- __name(update, "update");
3560
- var _Store = class _Store {
2515
+ var Store = class {
3561
2516
  constructor({ setState, getState }) {
3562
- this.upstreamSetState = setState;
3563
- this.upstreamGetState = getState;
2517
+ this.upstreamSetState = setState, this.upstreamGetState = getState;
3564
2518
  }
3565
2519
  // The assumption is that this will be called once, to initialize the React state
3566
2520
  // when the module is instantiated
@@ -3571,99 +2525,57 @@ var _Store = class _Store {
3571
2525
  return this.upstreamGetState();
3572
2526
  }
3573
2527
  async setState(inputPatch, cbOrOptions, inputOptions) {
3574
- let callback;
3575
- let options;
3576
- if (typeof cbOrOptions === "function") {
3577
- callback = cbOrOptions;
3578
- options = inputOptions;
3579
- } else {
3580
- options = cbOrOptions;
3581
- }
3582
- const { persistence = "none" } = options || {};
3583
- let patch = {};
3584
- let delta = {};
3585
- if (typeof inputPatch === "function") {
3586
- patch = /* @__PURE__ */ __name((state) => {
3587
- const getDelta = inputPatch;
3588
- delta = getDelta(state);
3589
- return delta;
3590
- }, "patch");
3591
- } else {
3592
- patch = inputPatch;
3593
- delta = patch;
3594
- }
3595
- const newState = await new Promise((resolve) => {
2528
+ let callback, options;
2529
+ typeof cbOrOptions == "function" ? (callback = cbOrOptions, options = inputOptions) : options = cbOrOptions;
2530
+ let { persistence = "none" } = options || {}, patch = {}, delta = {};
2531
+ typeof inputPatch == "function" ? patch = (state) => (delta = inputPatch(state), delta) : (patch = inputPatch, delta = patch);
2532
+ let newState = await new Promise((resolve) => {
3596
2533
  this.upstreamSetState(patch, () => {
3597
2534
  resolve(this.getState());
3598
2535
  });
3599
2536
  });
3600
2537
  if (persistence !== "none") {
3601
- const storage = persistence === "session" ? import_store2.default.session : import_store2.default.local;
2538
+ let storage = persistence === "session" ? import_store2.default.session : import_store2.default.local;
3602
2539
  await update(storage, delta);
3603
2540
  }
3604
- if (callback) {
3605
- callback(newState);
3606
- }
3607
- return newState;
2541
+ return callback && callback(newState), newState;
3608
2542
  }
3609
2543
  };
3610
- __name(_Store, "Store");
3611
- var Store = _Store;
3612
2544
 
3613
2545
  // src/manager-api/lib/request-response.ts
3614
- var _RequestResponseError = class _RequestResponseError extends Error {
2546
+ var RequestResponseError = class extends Error {
3615
2547
  constructor(message, payload) {
3616
2548
  super(message);
3617
2549
  this.payload = void 0;
3618
2550
  this.payload = payload;
3619
2551
  }
3620
- };
3621
- __name(_RequestResponseError, "RequestResponseError");
3622
- var RequestResponseError = _RequestResponseError;
3623
- var experimental_requestResponse = /* @__PURE__ */ __name((channel, requestEvent, responseEvent, payload, timeout = 5e3) => {
2552
+ }, experimental_requestResponse = (channel, requestEvent, responseEvent, payload, timeout = 5e3) => {
3624
2553
  let timeoutId;
3625
2554
  return new Promise((resolve, reject) => {
3626
- const request = {
2555
+ let request = {
3627
2556
  id: Math.random().toString(16).slice(2),
3628
2557
  payload
2558
+ }, responseHandler = (response) => {
2559
+ response.id === request.id && (clearTimeout(timeoutId), channel.off(responseEvent, responseHandler), response.success ? resolve(response.payload) : reject(new RequestResponseError(response.error, response.payload)));
3629
2560
  };
3630
- const responseHandler = /* @__PURE__ */ __name((response) => {
3631
- if (response.id !== request.id) {
3632
- return;
3633
- }
3634
- clearTimeout(timeoutId);
3635
- channel.off(responseEvent, responseHandler);
3636
- if (response.success) {
3637
- resolve(response.payload);
3638
- } else {
3639
- reject(new RequestResponseError(response.error, response.payload));
3640
- }
3641
- }, "responseHandler");
3642
- channel.emit(requestEvent, request);
3643
- channel.on(responseEvent, responseHandler);
3644
- timeoutId = setTimeout(() => {
3645
- channel.off(responseEvent, responseHandler);
3646
- reject(new RequestResponseError("Timed out waiting for response"));
2561
+ channel.emit(requestEvent, request), channel.on(responseEvent, responseHandler), timeoutId = setTimeout(() => {
2562
+ channel.off(responseEvent, responseHandler), reject(new RequestResponseError("Timed out waiting for response"));
3647
2563
  }, timeout);
3648
2564
  });
3649
- }, "experimental_requestResponse");
2565
+ };
3650
2566
 
3651
2567
  // src/manager-api/root.tsx
3652
2568
  var { ActiveTabs: ActiveTabs2 } = layout_exports;
3653
- var ManagerContext = createContext({ api: void 0, state: initial_state_default({}) });
3654
- var combineParameters = /* @__PURE__ */ __name((...parameterSets) => noArrayMerge({}, ...parameterSets), "combineParameters");
3655
- var _ManagerProvider = class _ManagerProvider extends Component {
2569
+ var ManagerContext = createContext({ api: void 0, state: initial_state_default({}) }), combineParameters = (...parameterSets) => noArrayMerge({}, ...parameterSets), ManagerProvider = class extends Component {
3656
2570
  constructor(props) {
3657
2571
  super(props);
3658
2572
  this.api = {};
3659
- this.initModules = /* @__PURE__ */ __name(() => {
2573
+ this.initModules = () => {
3660
2574
  this.modules.forEach((module) => {
3661
- if ("init" in module) {
3662
- module.init();
3663
- }
2575
+ "init" in module && module.init();
3664
2576
  });
3665
- }, "initModules");
3666
- const {
2577
+ };
2578
+ let {
3667
2579
  location: location2,
3668
2580
  path,
3669
2581
  refId,
@@ -3672,18 +2584,12 @@ var _ManagerProvider = class _ManagerProvider extends Component {
3672
2584
  storyId,
3673
2585
  docsOptions,
3674
2586
  navigate
3675
- } = props;
3676
- const store2 = new Store({
3677
- getState: /* @__PURE__ */ __name(() => this.state, "getState"),
3678
- setState: /* @__PURE__ */ __name((stateChange, callback) => {
3679
- this.setState(stateChange, () => callback(this.state));
3680
- return this.state;
3681
- }, "setState")
3682
- });
3683
- const routeData = { location: location2, path, viewMode, singleStory, storyId, refId };
3684
- const optionsData = { docsOptions };
2587
+ } = props, store2 = new Store({
2588
+ getState: () => this.state,
2589
+ setState: (stateChange, callback) => (this.setState(stateChange, () => callback(this.state)), this.state)
2590
+ }), routeData = { location: location2, path, viewMode, singleStory, storyId, refId }, optionsData = { docsOptions };
3685
2591
  this.state = store2.getInitialState(initial_state_default({ ...routeData, ...optionsData }));
3686
- const apiData = {
2592
+ let apiData = {
3687
2593
  navigate,
3688
2594
  store: store2,
3689
2595
  provider: props.provider
@@ -3706,347 +2612,248 @@ var _ManagerProvider = class _ManagerProvider extends Component {
3706
2612
  ].map(
3707
2613
  (m) => m.init({ ...routeData, ...optionsData, ...apiData, state: this.state, fullAPI: this.api })
3708
2614
  );
3709
- const state = initial_state_default(this.state, ...this.modules.map((m) => m.state));
3710
- const api = Object.assign(this.api, { navigate }, ...this.modules.map((m) => m.api));
3711
- this.state = state;
3712
- this.api = api;
2615
+ let state = initial_state_default(this.state, ...this.modules.map((m) => m.state)), api = Object.assign(this.api, { navigate }, ...this.modules.map((m) => m.api));
2616
+ this.state = state, this.api = api;
3713
2617
  }
3714
2618
  static getDerivedStateFromProps(props, state) {
3715
- if (state.path !== props.path) {
3716
- return {
3717
- ...state,
3718
- location: props.location,
3719
- path: props.path,
3720
- refId: props.refId,
3721
- viewMode: props.viewMode,
3722
- storyId: props.storyId
3723
- };
3724
- }
3725
- return null;
2619
+ return state.path !== props.path ? {
2620
+ ...state,
2621
+ location: props.location,
2622
+ path: props.path,
2623
+ refId: props.refId,
2624
+ viewMode: props.viewMode,
2625
+ storyId: props.storyId
2626
+ } : null;
3726
2627
  }
3727
2628
  shouldComponentUpdate(nextProps, nextState) {
3728
- const prevProps = this.props;
3729
- const prevState = this.state;
2629
+ let prevProps = this.props, prevState = this.state;
3730
2630
  return prevProps.path !== nextProps.path || !isEqual(prevState, nextState);
3731
2631
  }
3732
2632
  render() {
3733
- const { children } = this.props;
3734
- const value = {
2633
+ let { children } = this.props, value = {
3735
2634
  state: this.state,
3736
2635
  api: this.api
3737
2636
  };
3738
2637
  return React4.createElement(EffectOnMount, { effect: this.initModules }, React4.createElement(ManagerContext.Provider, { value }, React4.createElement(ManagerConsumer, null, children)));
3739
2638
  }
3740
2639
  };
3741
- __name(_ManagerProvider, "ManagerProvider");
3742
- _ManagerProvider.displayName = "Manager";
3743
- var ManagerProvider = _ManagerProvider;
3744
- var EffectOnMount = /* @__PURE__ */ __name(({ children, effect }) => {
3745
- React4.useEffect(effect, []);
3746
- return children;
3747
- }, "EffectOnMount");
3748
- var defaultFilter = /* @__PURE__ */ __name((c) => c, "defaultFilter");
2640
+ ManagerProvider.displayName = "Manager";
2641
+ var EffectOnMount = ({ children, effect }) => (React4.useEffect(effect, []), children), defaultFilter = (c) => c;
3749
2642
  function ManagerConsumer({
3750
2643
  // @ts-expect-error (Converted from ts-ignore)
3751
2644
  filter = defaultFilter,
3752
2645
  children
3753
2646
  }) {
3754
- const managerContext = useContext(ManagerContext);
3755
- const renderer = useRef2(children);
3756
- const filterer = useRef2(filter);
3757
- if (typeof renderer.current !== "function") {
2647
+ let managerContext = useContext(ManagerContext), renderer = useRef2(children), filterer = useRef2(filter);
2648
+ if (typeof renderer.current != "function")
3758
2649
  return React4.createElement(Fragment, null, renderer.current);
3759
- }
3760
- const comboData = filterer.current(managerContext);
3761
- const comboDataArray = useMemo(() => {
3762
- return [...Object.entries(comboData).reduce((acc, keyval) => acc.concat(keyval), [])];
3763
- }, [managerContext.state]);
2650
+ let comboData = filterer.current(managerContext), comboDataArray = useMemo(() => [...Object.entries(comboData).reduce((acc, keyval) => acc.concat(keyval), [])], [managerContext.state]);
3764
2651
  return useMemo(() => {
3765
- const Child = renderer.current;
2652
+ let Child = renderer.current;
3766
2653
  return React4.createElement(Child, { ...comboData });
3767
2654
  }, comboDataArray);
3768
2655
  }
3769
- __name(ManagerConsumer, "ManagerConsumer");
3770
2656
  function useStorybookState() {
3771
- const { state } = useContext(ManagerContext);
2657
+ let { state } = useContext(ManagerContext);
3772
2658
  return state;
3773
2659
  }
3774
- __name(useStorybookState, "useStorybookState");
3775
2660
  function useStorybookApi() {
3776
- const { api } = useContext(ManagerContext);
2661
+ let { api } = useContext(ManagerContext);
3777
2662
  return api;
3778
2663
  }
3779
- __name(useStorybookApi, "useStorybookApi");
3780
2664
  function orDefault(fromStore, defaultState) {
3781
- if (typeof fromStore === "undefined") {
3782
- return defaultState;
3783
- }
3784
- return fromStore;
2665
+ return typeof fromStore > "u" ? defaultState : fromStore;
3785
2666
  }
3786
- __name(orDefault, "orDefault");
3787
- var useChannel = /* @__PURE__ */ __name((eventMap, deps = []) => {
3788
- const api = useStorybookApi();
3789
- useEffect(() => {
3790
- Object.entries(eventMap).forEach(([type, listener]) => api.on(type, listener));
3791
- return () => {
3792
- Object.entries(eventMap).forEach(([type, listener]) => api.off(type, listener));
3793
- };
3794
- }, deps);
3795
- return api.emit;
3796
- }, "useChannel");
2667
+ var useChannel = (eventMap, deps = []) => {
2668
+ let api = useStorybookApi();
2669
+ return useEffect(() => (Object.entries(eventMap).forEach(([type, listener]) => api.on(type, listener)), () => {
2670
+ Object.entries(eventMap).forEach(([type, listener]) => api.off(type, listener));
2671
+ }), deps), api.emit;
2672
+ };
3797
2673
  function useStoryPrepared(storyId) {
3798
- const api = useStorybookApi();
3799
- return api.isPrepared(storyId);
2674
+ return useStorybookApi().isPrepared(storyId);
3800
2675
  }
3801
- __name(useStoryPrepared, "useStoryPrepared");
3802
2676
  function useParameter(parameterKey, defaultValue) {
3803
- const api = useStorybookApi();
3804
- const [parameter, setParameter] = useState(api.getCurrentParameter(parameterKey));
3805
- const handleParameterChange = useCallback2(() => {
3806
- const newParameter = api.getCurrentParameter(parameterKey);
2677
+ let api = useStorybookApi(), [parameter, setParameter] = useState(api.getCurrentParameter(parameterKey)), handleParameterChange = useCallback2(() => {
2678
+ let newParameter = api.getCurrentParameter(parameterKey);
3807
2679
  setParameter(newParameter);
3808
2680
  }, [api, parameterKey]);
3809
- useChannel(
2681
+ return useChannel(
3810
2682
  {
3811
2683
  [STORY_PREPARED2]: handleParameterChange,
3812
2684
  [DOCS_PREPARED2]: handleParameterChange
3813
2685
  },
3814
2686
  [handleParameterChange]
3815
- );
3816
- return orDefault(parameter, defaultValue);
2687
+ ), orDefault(parameter, defaultValue);
3817
2688
  }
3818
- __name(useParameter, "useParameter");
3819
2689
  globalThis.STORYBOOK_ADDON_STATE = {};
3820
2690
  var { STORYBOOK_ADDON_STATE } = globalThis;
3821
2691
  function useSharedState(stateId, defaultState) {
3822
- const api = useStorybookApi();
3823
- const existingState = api.getAddonState(stateId) || STORYBOOK_ADDON_STATE[stateId];
3824
- const state = orDefault(
2692
+ let api = useStorybookApi(), existingState = api.getAddonState(stateId) || STORYBOOK_ADDON_STATE[stateId], state = orDefault(
3825
2693
  existingState,
3826
2694
  STORYBOOK_ADDON_STATE[stateId] ? STORYBOOK_ADDON_STATE[stateId] : defaultState
3827
- );
3828
- let quicksync = false;
3829
- if (state === defaultState && defaultState !== void 0) {
3830
- STORYBOOK_ADDON_STATE[stateId] = defaultState;
3831
- quicksync = true;
3832
- }
3833
- useEffect(() => {
3834
- if (quicksync) {
3835
- api.setAddonState(stateId, defaultState);
3836
- }
2695
+ ), quicksync = !1;
2696
+ state === defaultState && defaultState !== void 0 && (STORYBOOK_ADDON_STATE[stateId] = defaultState, quicksync = !0), useEffect(() => {
2697
+ quicksync && api.setAddonState(stateId, defaultState);
3837
2698
  }, [quicksync]);
3838
- const setState = useCallback2(
2699
+ let setState = useCallback2(
3839
2700
  async (s, options) => {
3840
2701
  await api.setAddonState(stateId, s, options);
3841
- const result = api.getAddonState(stateId);
3842
- STORYBOOK_ADDON_STATE[stateId] = result;
3843
- return result;
2702
+ let result = api.getAddonState(stateId);
2703
+ return STORYBOOK_ADDON_STATE[stateId] = result, result;
3844
2704
  },
3845
2705
  [api, stateId]
3846
- );
3847
- const allListeners = useMemo(() => {
3848
- const stateChangeHandlers = {
2706
+ ), allListeners = useMemo(() => {
2707
+ let stateChangeHandlers = {
3849
2708
  [`${SHARED_STATE_CHANGED}-client-${stateId}`]: setState,
3850
2709
  [`${SHARED_STATE_SET}-client-${stateId}`]: setState
3851
- };
3852
- const stateInitializationHandlers = {
2710
+ }, stateInitializationHandlers = {
3853
2711
  [SET_STORIES2]: async () => {
3854
- const currentState = api.getAddonState(stateId);
3855
- if (currentState) {
3856
- STORYBOOK_ADDON_STATE[stateId] = currentState;
3857
- api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
3858
- } else if (STORYBOOK_ADDON_STATE[stateId]) {
3859
- await setState(STORYBOOK_ADDON_STATE[stateId]);
3860
- api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, STORYBOOK_ADDON_STATE[stateId]);
3861
- } else if (defaultState !== void 0) {
3862
- await setState(defaultState);
3863
- STORYBOOK_ADDON_STATE[stateId] = defaultState;
3864
- api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, defaultState);
3865
- }
2712
+ let currentState = api.getAddonState(stateId);
2713
+ currentState ? (STORYBOOK_ADDON_STATE[stateId] = currentState, api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState)) : STORYBOOK_ADDON_STATE[stateId] ? (await setState(STORYBOOK_ADDON_STATE[stateId]), api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, STORYBOOK_ADDON_STATE[stateId])) : defaultState !== void 0 && (await setState(defaultState), STORYBOOK_ADDON_STATE[stateId] = defaultState, api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, defaultState));
3866
2714
  },
3867
2715
  [STORY_CHANGED2]: () => {
3868
- const currentState = api.getAddonState(stateId);
3869
- if (currentState !== void 0) {
3870
- api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
3871
- }
2716
+ let currentState = api.getAddonState(stateId);
2717
+ currentState !== void 0 && api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
3872
2718
  }
3873
2719
  };
3874
2720
  return {
3875
2721
  ...stateChangeHandlers,
3876
2722
  ...stateInitializationHandlers
3877
2723
  };
3878
- }, [stateId]);
3879
- const emit = useChannel(allListeners);
3880
- const stateSetter = useCallback2(
2724
+ }, [stateId]), emit = useChannel(allListeners), stateSetter = useCallback2(
3881
2725
  async (newStateOrMerger, options) => {
3882
2726
  await setState(newStateOrMerger, options);
3883
- const result = api.getAddonState(stateId);
2727
+ let result = api.getAddonState(stateId);
3884
2728
  emit(`${SHARED_STATE_CHANGED}-manager-${stateId}`, result);
3885
2729
  },
3886
2730
  [api, emit, setState, stateId]
3887
2731
  );
3888
2732
  return [state, stateSetter];
3889
2733
  }
3890
- __name(useSharedState, "useSharedState");
3891
2734
  function useAddonState(addonId, defaultState) {
3892
2735
  return useSharedState(addonId, defaultState);
3893
2736
  }
3894
- __name(useAddonState, "useAddonState");
3895
2737
  function useArgs() {
3896
- const { getCurrentStoryData, updateStoryArgs, resetStoryArgs } = useStorybookApi();
3897
- const data = getCurrentStoryData();
3898
- const args = data?.type === "story" ? data.args : {};
3899
- const initialArgs = data?.type === "story" ? data.initialArgs : {};
3900
- const updateArgs = useCallback2(
2738
+ let { getCurrentStoryData, updateStoryArgs, resetStoryArgs } = useStorybookApi(), data = getCurrentStoryData(), args = data?.type === "story" ? data.args : {}, initialArgs = data?.type === "story" ? data.initialArgs : {}, updateArgs = useCallback2(
3901
2739
  (newArgs) => updateStoryArgs(data, newArgs),
3902
2740
  [data, updateStoryArgs]
3903
- );
3904
- const resetArgs = useCallback2(
2741
+ ), resetArgs = useCallback2(
3905
2742
  (argNames) => resetStoryArgs(data, argNames),
3906
2743
  [data, resetStoryArgs]
3907
2744
  );
3908
2745
  return [args, updateArgs, resetArgs, initialArgs];
3909
2746
  }
3910
- __name(useArgs, "useArgs");
3911
2747
  function useGlobals() {
3912
- const api = useStorybookApi();
2748
+ let api = useStorybookApi();
3913
2749
  return [api.getGlobals(), api.updateGlobals, api.getStoryGlobals(), api.getUserGlobals()];
3914
2750
  }
3915
- __name(useGlobals, "useGlobals");
3916
2751
  function useGlobalTypes() {
3917
2752
  return useStorybookApi().getGlobalTypes();
3918
2753
  }
3919
- __name(useGlobalTypes, "useGlobalTypes");
3920
2754
  function useCurrentStory() {
3921
- const { getCurrentStoryData } = useStorybookApi();
2755
+ let { getCurrentStoryData } = useStorybookApi();
3922
2756
  return getCurrentStoryData();
3923
2757
  }
3924
- __name(useCurrentStory, "useCurrentStory");
3925
2758
  function useArgTypes() {
3926
- const current = useCurrentStory();
2759
+ let current = useCurrentStory();
3927
2760
  return current?.type === "story" && current.argTypes || {};
3928
2761
  }
3929
- __name(useArgTypes, "useArgTypes");
3930
2762
  var typesX = Addon_TypesEnum;
3931
2763
 
3932
2764
  // src/shared/universal-store/mock.ts
3933
2765
  import { Channel as Channel2 } from "storybook/internal/channels";
3934
- var _MockUniversalStore = class _MockUniversalStore extends UniversalStore {
2766
+ var MockUniversalStore = class _MockUniversalStore extends UniversalStore {
3935
2767
  constructor(options, testUtils) {
3936
- UniversalStore.isInternalConstructing = true;
3937
- super(
3938
- { ...options, leader: true },
2768
+ UniversalStore.isInternalConstructing = !0, super(
2769
+ { ...options, leader: !0 },
3939
2770
  { channel: new Channel2({}), environment: UniversalStore.Environment.MOCK }
3940
- );
3941
- UniversalStore.isInternalConstructing = false;
3942
- if (typeof testUtils?.fn !== "function") {
3943
- return;
3944
- }
3945
- this.testUtils = testUtils;
3946
- this.getState = testUtils.fn(this.getState);
3947
- this.setState = testUtils.fn(this.setState);
3948
- this.subscribe = testUtils.fn(this.subscribe);
3949
- this.onStateChange = testUtils.fn(this.onStateChange);
3950
- this.send = testUtils.fn(this.send);
2771
+ ), UniversalStore.isInternalConstructing = !1, typeof testUtils?.fn == "function" && (this.testUtils = testUtils, this.getState = testUtils.fn(this.getState), this.setState = testUtils.fn(this.setState), this.subscribe = testUtils.fn(this.subscribe), this.onStateChange = testUtils.fn(this.onStateChange), this.send = testUtils.fn(this.send));
3951
2772
  }
3952
2773
  /** Create a mock universal store. This is just an alias for the constructor */
3953
2774
  static create(options, testUtils) {
3954
2775
  return new _MockUniversalStore(options, testUtils);
3955
2776
  }
3956
2777
  unsubscribeAll() {
3957
- if (!this.testUtils) {
2778
+ if (!this.testUtils)
3958
2779
  throw new Error(
3959
2780
  dedent`Cannot call unsubscribeAll on a store that does not have testUtils.
3960
2781
  Please provide testUtils as the second argument when creating the store.`
3961
2782
  );
3962
- }
3963
- const callReturnedUnsubscribeFn = /* @__PURE__ */ __name((result) => {
2783
+ let callReturnedUnsubscribeFn = (result) => {
3964
2784
  try {
3965
2785
  result.value();
3966
- } catch (e) {
2786
+ } catch {
3967
2787
  }
3968
- }, "callReturnedUnsubscribeFn");
3969
- this.subscribe.mock?.results.forEach(callReturnedUnsubscribeFn);
3970
- this.onStateChange.mock?.results.forEach(callReturnedUnsubscribeFn);
2788
+ };
2789
+ this.subscribe.mock?.results.forEach(callReturnedUnsubscribeFn), this.onStateChange.mock?.results.forEach(callReturnedUnsubscribeFn);
3971
2790
  }
3972
2791
  };
3973
- __name(_MockUniversalStore, "MockUniversalStore");
3974
- var MockUniversalStore = _MockUniversalStore;
3975
2792
 
3976
2793
  // src/shared/test-provider-store/index.ts
3977
2794
  var UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS = {
3978
2795
  id: "storybook/test-provider",
3979
- leader: true,
2796
+ leader: !0,
3980
2797
  initialState: {}
3981
2798
  };
3982
2799
  function createTestProviderStore({
3983
2800
  universalTestProviderStore: universalTestProviderStore2,
3984
2801
  useUniversalStore: useUniversalStore2
3985
2802
  }) {
3986
- const baseStore = {
3987
- settingsChanged: /* @__PURE__ */ __name(() => {
2803
+ let baseStore = {
2804
+ settingsChanged: () => {
3988
2805
  universalTestProviderStore2.untilReady().then(() => {
3989
2806
  universalTestProviderStore2.send({ type: "settings-changed" });
3990
2807
  });
3991
- }, "settingsChanged"),
3992
- onRunAll: /* @__PURE__ */ __name((listener) => universalTestProviderStore2.subscribe("run-all", listener), "onRunAll"),
3993
- onClearAll: /* @__PURE__ */ __name((listener) => universalTestProviderStore2.subscribe("clear-all", listener), "onClearAll")
3994
- };
3995
- const fullTestProviderStore2 = {
2808
+ },
2809
+ onRunAll: (listener) => universalTestProviderStore2.subscribe("run-all", listener),
2810
+ onClearAll: (listener) => universalTestProviderStore2.subscribe("clear-all", listener)
2811
+ }, fullTestProviderStore2 = {
3996
2812
  ...baseStore,
3997
2813
  getFullState: universalTestProviderStore2.getState,
3998
2814
  setFullState: universalTestProviderStore2.setState,
3999
- onSettingsChanged: /* @__PURE__ */ __name((listener) => universalTestProviderStore2.subscribe("settings-changed", listener), "onSettingsChanged"),
4000
- runAll: /* @__PURE__ */ __name(async () => {
4001
- await universalTestProviderStore2.untilReady();
4002
- universalTestProviderStore2.send({ type: "run-all" });
4003
- }, "runAll"),
4004
- clearAll: /* @__PURE__ */ __name(async () => {
4005
- await universalTestProviderStore2.untilReady();
4006
- universalTestProviderStore2.send({ type: "clear-all" });
4007
- }, "clearAll")
4008
- };
4009
- const getTestProviderStoreById2 = /* @__PURE__ */ __name((testProviderId) => {
4010
- const getStateForTestProvider = /* @__PURE__ */ __name(() => universalTestProviderStore2.getState()[testProviderId] ?? "test-provider-state:pending", "getStateForTestProvider");
4011
- const setStateForTestProvider = /* @__PURE__ */ __name((state) => {
2815
+ onSettingsChanged: (listener) => universalTestProviderStore2.subscribe("settings-changed", listener),
2816
+ runAll: async () => {
2817
+ await universalTestProviderStore2.untilReady(), universalTestProviderStore2.send({ type: "run-all" });
2818
+ },
2819
+ clearAll: async () => {
2820
+ await universalTestProviderStore2.untilReady(), universalTestProviderStore2.send({ type: "clear-all" });
2821
+ }
2822
+ }, getTestProviderStoreById2 = (testProviderId) => {
2823
+ let getStateForTestProvider = () => universalTestProviderStore2.getState()[testProviderId] ?? "test-provider-state:pending", setStateForTestProvider = (state) => {
4012
2824
  universalTestProviderStore2.untilReady().then(() => {
4013
2825
  universalTestProviderStore2.setState((currentState) => ({
4014
2826
  ...currentState,
4015
2827
  [testProviderId]: state
4016
2828
  }));
4017
2829
  });
4018
- }, "setStateForTestProvider");
2830
+ };
4019
2831
  return {
4020
2832
  ...baseStore,
4021
2833
  testProviderId,
4022
2834
  getState: getStateForTestProvider,
4023
2835
  setState: setStateForTestProvider,
4024
- runWithState: /* @__PURE__ */ __name(async (callback) => {
2836
+ runWithState: async (callback) => {
4025
2837
  setStateForTestProvider("test-provider-state:running");
4026
2838
  try {
4027
- await callback();
4028
- setStateForTestProvider("test-provider-state:succeeded");
4029
- } catch (error) {
2839
+ await callback(), setStateForTestProvider("test-provider-state:succeeded");
2840
+ } catch {
4030
2841
  setStateForTestProvider("test-provider-state:crashed");
4031
2842
  }
4032
- }, "runWithState")
4033
- };
4034
- }, "getTestProviderStoreById");
4035
- if (useUniversalStore2) {
4036
- return {
4037
- getTestProviderStoreById: getTestProviderStoreById2,
4038
- fullTestProviderStore: fullTestProviderStore2,
4039
- universalTestProviderStore: universalTestProviderStore2,
4040
- useTestProviderStore: /* @__PURE__ */ __name((selector) => useUniversalStore2(universalTestProviderStore2, selector)[0], "useTestProviderStore")
2843
+ }
4041
2844
  };
4042
- }
4043
- return {
2845
+ };
2846
+ return useUniversalStore2 ? {
2847
+ getTestProviderStoreById: getTestProviderStoreById2,
2848
+ fullTestProviderStore: fullTestProviderStore2,
2849
+ universalTestProviderStore: universalTestProviderStore2,
2850
+ useTestProviderStore: (selector) => useUniversalStore2(universalTestProviderStore2, selector)[0]
2851
+ } : {
4044
2852
  getTestProviderStoreById: getTestProviderStoreById2,
4045
2853
  fullTestProviderStore: fullTestProviderStore2,
4046
2854
  universalTestProviderStore: universalTestProviderStore2
4047
2855
  };
4048
2856
  }
4049
- __name(createTestProviderStore, "createTestProviderStore");
4050
2857
 
4051
2858
  // src/manager-api/stores/test-provider.ts
4052
2859
  var testProviderStore = createTestProviderStore({
@@ -4055,8 +2862,7 @@ var testProviderStore = createTestProviderStore({
4055
2862
  leader: globalThis.CONFIG_TYPE === "PRODUCTION"
4056
2863
  }),
4057
2864
  useUniversalStore
4058
- });
4059
- var {
2865
+ }), {
4060
2866
  fullTestProviderStore,
4061
2867
  getTestProviderStoreById,
4062
2868
  useTestProviderStore,