storybook 9.0.0-alpha.1 → 9.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +31 -29
  2. package/assets/browser/favicon.svg +1 -0
  3. package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
  4. package/assets/browser/nunito-sans-bold.woff2 +0 -0
  5. package/assets/browser/nunito-sans-italic.woff2 +0 -0
  6. package/assets/browser/nunito-sans-regular.woff2 +0 -0
  7. package/assets/docs/message-reference.png +0 -0
  8. package/assets/server/addon.tsconfig.json +6 -0
  9. package/assets/server/base-preview-body.html +119 -0
  10. package/assets/server/base-preview-head.html +451 -0
  11. package/assets/server/template.ejs +87 -0
  12. package/bin/index.cjs +1 -1
  13. package/dist/babel/index.cjs +54034 -0
  14. package/dist/babel/index.d.ts +7488 -0
  15. package/dist/babel/index.js +54044 -0
  16. package/dist/bin/index.cjs +123 -0
  17. package/dist/bin/index.js +117 -0
  18. package/dist/builder-manager/index.cjs +2167 -0
  19. package/dist/builder-manager/index.d.ts +19 -0
  20. package/dist/builder-manager/index.js +2189 -0
  21. package/dist/channels/index.cjs +1936 -0
  22. package/dist/channels/index.d.ts +108 -0
  23. package/dist/channels/index.js +1883 -0
  24. package/dist/cli/bin/index.cjs +2687 -0
  25. package/dist/cli/bin/index.d.ts +2 -0
  26. package/dist/cli/bin/index.js +2707 -0
  27. package/dist/cli/index.cjs +17327 -0
  28. package/dist/cli/index.d.ts +209 -0
  29. package/dist/cli/index.js +17349 -0
  30. package/dist/client-logger/index.cjs +112 -0
  31. package/dist/client-logger/index.d.ts +29 -0
  32. package/dist/client-logger/index.js +70 -0
  33. package/dist/common/index.cjs +20560 -0
  34. package/dist/common/index.d.ts +954 -0
  35. package/dist/common/index.js +20645 -0
  36. package/dist/components/index.cjs +30056 -0
  37. package/dist/components/index.d.ts +1423 -0
  38. package/dist/components/index.js +25416 -0
  39. package/dist/core-events/index.cjs +167 -0
  40. package/dist/core-events/index.d.ts +313 -0
  41. package/dist/core-events/index.js +149 -0
  42. package/dist/core-server/index.cjs +37870 -0
  43. package/dist/core-server/index.d.ts +462 -0
  44. package/dist/core-server/index.js +37964 -0
  45. package/dist/core-server/presets/common-manager.js +28 -0
  46. package/dist/core-server/presets/common-override-preset.cjs +4824 -0
  47. package/dist/core-server/presets/common-override-preset.js +4829 -0
  48. package/dist/core-server/presets/common-preset.cjs +10228 -0
  49. package/dist/core-server/presets/common-preset.js +10306 -0
  50. package/dist/csf/index.cjs +223 -0
  51. package/dist/csf/index.d.ts +752 -0
  52. package/dist/csf/index.js +216 -0
  53. package/dist/csf-tools/index.cjs +1422 -0
  54. package/dist/csf-tools/index.d.ts +250 -0
  55. package/dist/csf-tools/index.js +1439 -0
  56. package/dist/docs-tools/index.cjs +923 -0
  57. package/dist/docs-tools/index.d.ts +162 -0
  58. package/dist/docs-tools/index.js +909 -0
  59. package/dist/index.cjs +17 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +2 -7
  62. package/dist/instrumenter/index.cjs +3273 -0
  63. package/dist/instrumenter/index.d.ts +104 -0
  64. package/dist/instrumenter/index.js +4800 -0
  65. package/dist/manager/globals-module-info.cjs +666 -0
  66. package/dist/manager/globals-module-info.d.ts +36 -0
  67. package/dist/manager/globals-module-info.js +653 -0
  68. package/dist/manager/globals-runtime.js +41565 -0
  69. package/dist/manager/globals.cjs +43 -0
  70. package/dist/manager/globals.d.ts +21 -0
  71. package/dist/manager/globals.js +30 -0
  72. package/dist/manager/runtime.js +12043 -0
  73. package/dist/manager-api/index.cjs +10770 -0
  74. package/dist/manager-api/index.d.ts +1211 -0
  75. package/dist/manager-api/index.js +4545 -0
  76. package/dist/manager-errors.d.ts +65 -0
  77. package/dist/manager-errors.js +83 -0
  78. package/dist/node-logger/index.cjs +1642 -0
  79. package/dist/node-logger/index.d.ts +117 -0
  80. package/dist/node-logger/index.js +1652 -0
  81. package/dist/preview/globals.cjs +34 -0
  82. package/dist/preview/globals.d.ts +12 -0
  83. package/dist/preview/globals.js +21 -0
  84. package/dist/preview/runtime.js +7721 -0
  85. package/dist/preview-api/index.cjs +5656 -0
  86. package/dist/preview-api/index.d.ts +1356 -0
  87. package/dist/preview-api/index.js +5663 -0
  88. package/dist/preview-errors.cjs +486 -0
  89. package/dist/preview-errors.d.ts +188 -0
  90. package/dist/preview-errors.js +433 -0
  91. package/dist/router/index.cjs +3320 -0
  92. package/dist/router/index.d.ts +385 -0
  93. package/dist/router/index.js +1849 -0
  94. package/dist/server-errors.cjs +710 -0
  95. package/dist/server-errors.d.ts +272 -0
  96. package/dist/server-errors.js +711 -0
  97. package/dist/telemetry/index.cjs +3683 -0
  98. package/dist/telemetry/index.d.ts +112 -0
  99. package/dist/telemetry/index.js +3720 -0
  100. package/dist/test/index.cjs +34915 -0
  101. package/dist/test/index.d.ts +186 -0
  102. package/dist/test/index.js +32798 -0
  103. package/dist/theming/create.cjs +2422 -0
  104. package/dist/theming/create.d.ts +50 -0
  105. package/dist/theming/create.js +990 -0
  106. package/dist/theming/index.cjs +4832 -0
  107. package/dist/theming/index.d.ts +11939 -0
  108. package/dist/theming/index.js +3253 -0
  109. package/dist/types/index.cjs +27 -0
  110. package/dist/types/index.d.ts +2541 -0
  111. package/dist/types/index.js +7 -0
  112. package/package.json +329 -212
  113. package/.eslintrc.cjs +0 -31
  114. package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
  115. package/core/babel/index.cjs +0 -1
  116. package/core/babel/index.d.ts +0 -2
  117. package/core/babel/index.js +0 -1
  118. package/core/builder-manager/index.cjs +0 -1
  119. package/core/builder-manager/index.d.ts +0 -2
  120. package/core/builder-manager/index.js +0 -1
  121. package/core/channels/index.cjs +0 -1
  122. package/core/channels/index.d.ts +0 -2
  123. package/core/channels/index.js +0 -1
  124. package/core/cli/bin/index.cjs +0 -1
  125. package/core/cli/bin/index.d.ts +0 -2
  126. package/core/cli/bin/index.js +0 -1
  127. package/core/cli/index.cjs +0 -1
  128. package/core/cli/index.d.ts +0 -2
  129. package/core/cli/index.js +0 -1
  130. package/core/client-logger/index.cjs +0 -1
  131. package/core/client-logger/index.d.ts +0 -2
  132. package/core/client-logger/index.js +0 -1
  133. package/core/common/index.cjs +0 -1
  134. package/core/common/index.d.ts +0 -2
  135. package/core/common/index.js +0 -1
  136. package/core/components/index.cjs +0 -1
  137. package/core/components/index.d.ts +0 -2
  138. package/core/components/index.js +0 -1
  139. package/core/core-events/index.cjs +0 -1
  140. package/core/core-events/index.d.ts +0 -2
  141. package/core/core-events/index.js +0 -1
  142. package/core/core-server/index.cjs +0 -1
  143. package/core/core-server/index.d.ts +0 -2
  144. package/core/core-server/index.js +0 -1
  145. package/core/core-server/presets/common-manager.js +0 -1
  146. package/core/core-server/presets/common-override-preset.cjs +0 -1
  147. package/core/core-server/presets/common-override-preset.js +0 -1
  148. package/core/core-server/presets/common-preset.cjs +0 -1
  149. package/core/core-server/presets/common-preset.js +0 -1
  150. package/core/csf/index.cjs +0 -1
  151. package/core/csf/index.d.ts +0 -2
  152. package/core/csf/index.js +0 -1
  153. package/core/csf-tools/index.cjs +0 -1
  154. package/core/csf-tools/index.d.ts +0 -2
  155. package/core/csf-tools/index.js +0 -1
  156. package/core/docs-tools/index.cjs +0 -1
  157. package/core/docs-tools/index.d.ts +0 -2
  158. package/core/docs-tools/index.js +0 -1
  159. package/core/index.cjs +0 -1
  160. package/core/index.d.ts +0 -2
  161. package/core/index.js +0 -1
  162. package/core/manager/globals-module-info.cjs +0 -1
  163. package/core/manager/globals-module-info.d.ts +0 -2
  164. package/core/manager/globals-module-info.js +0 -1
  165. package/core/manager/globals-runtime.js +0 -1
  166. package/core/manager/globals.cjs +0 -1
  167. package/core/manager/globals.d.ts +0 -2
  168. package/core/manager/globals.js +0 -1
  169. package/core/manager-api/index.cjs +0 -1
  170. package/core/manager-api/index.d.ts +0 -2
  171. package/core/manager-api/index.js +0 -1
  172. package/core/manager-errors.d.ts +0 -2
  173. package/core/manager-errors.js +0 -1
  174. package/core/node-logger/index.cjs +0 -1
  175. package/core/node-logger/index.d.ts +0 -2
  176. package/core/node-logger/index.js +0 -1
  177. package/core/preview/globals.cjs +0 -1
  178. package/core/preview/globals.d.ts +0 -2
  179. package/core/preview/globals.js +0 -1
  180. package/core/preview/runtime.js +0 -1
  181. package/core/preview-api/index.cjs +0 -1
  182. package/core/preview-api/index.d.ts +0 -2
  183. package/core/preview-api/index.js +0 -1
  184. package/core/preview-errors.cjs +0 -1
  185. package/core/preview-errors.d.ts +0 -2
  186. package/core/preview-errors.js +0 -1
  187. package/core/router/index.cjs +0 -1
  188. package/core/router/index.d.ts +0 -2
  189. package/core/router/index.js +0 -1
  190. package/core/server-errors.cjs +0 -1
  191. package/core/server-errors.d.ts +0 -2
  192. package/core/server-errors.js +0 -1
  193. package/core/telemetry/index.cjs +0 -1
  194. package/core/telemetry/index.d.ts +0 -2
  195. package/core/telemetry/index.js +0 -1
  196. package/core/theming/create.cjs +0 -1
  197. package/core/theming/create.d.ts +0 -2
  198. package/core/theming/create.js +0 -1
  199. package/core/theming/index.cjs +0 -1
  200. package/core/theming/index.d.ts +0 -2
  201. package/core/theming/index.js +0 -1
  202. package/core/types/index.cjs +0 -1
  203. package/core/types/index.d.ts +0 -2
  204. package/core/types/index.js +0 -1
  205. package/core.cjs +0 -0
  206. package/core.d.ts +0 -0
  207. package/core.js +0 -1
  208. package/dist/chunk-OWLSIX54.js +0 -8
  209. package/dist/core-path.cjs +0 -1
  210. package/dist/core-path.d.ts +0 -3
  211. package/dist/core-path.js +0 -9
  212. package/dist/proxy.cjs +0 -1
  213. package/dist/proxy.d.ts +0 -2
  214. package/dist/proxy.js +0 -9
@@ -0,0 +1,1883 @@
1
+ var ae = Object.create;
2
+ var ut = Object.defineProperty;
3
+ var se = Object.getOwnPropertyDescriptor;
4
+ var le = Object.getOwnPropertyNames;
5
+ var ce = Object.getPrototypeOf, pe = Object.prototype.hasOwnProperty;
6
+ var a = (r, t) => ut(r, "name", { value: t, configurable: !0 }), H = /* @__PURE__ */ ((r) => typeof require < "u" ? require : typeof Proxy <
7
+ "u" ? new Proxy(r, {
8
+ get: (t, e) => (typeof require < "u" ? require : t)[e]
9
+ }) : r)(function(r) {
10
+ if (typeof require < "u") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + r + '" is not supported');
12
+ });
13
+ var ue = (r, t) => () => (t || r((t = { exports: {} }).exports, t), t.exports);
14
+ var fe = (r, t, e, n) => {
15
+ if (t && typeof t == "object" || typeof t == "function")
16
+ for (let o of le(t))
17
+ !pe.call(r, o) && o !== e && ut(r, o, { get: () => t[o], enumerable: !(n = se(t, o)) || n.enumerable });
18
+ return r;
19
+ };
20
+ var he = (r, t, e) => (e = r != null ? ae(ce(r)) : {}, fe(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ t || !r || !r.__esModule ? ut(e, "default", { value: r, enumerable: !0 }) : e,
26
+ r
27
+ ));
28
+
29
+ // ../node_modules/memoizerific/memoizerific.js
30
+ var xt = ue((It, yt) => {
31
+ (function(r) {
32
+ if (typeof It == "object" && typeof yt < "u")
33
+ yt.exports = r();
34
+ else if (typeof define == "function" && define.amd)
35
+ define([], r);
36
+ else {
37
+ var t;
38
+ typeof window < "u" ? t = window : typeof global < "u" ? t = global : typeof self < "u" ? t = self : t = this, t.memoizerific = r();
39
+ }
40
+ })(function() {
41
+ var r, t, e;
42
+ return (/* @__PURE__ */ a(function n(o, s, l) {
43
+ function c(p, u) {
44
+ if (!s[p]) {
45
+ if (!o[p]) {
46
+ var y = typeof H == "function" && H;
47
+ if (!u && y) return y(p, !0);
48
+ if (i) return i(p, !0);
49
+ var v = new Error("Cannot find module '" + p + "'");
50
+ throw v.code = "MODULE_NOT_FOUND", v;
51
+ }
52
+ var d = s[p] = { exports: {} };
53
+ o[p][0].call(d.exports, function(m) {
54
+ var E = o[p][1][m];
55
+ return c(E || m);
56
+ }, d, d.exports, n, o, s, l);
57
+ }
58
+ return s[p].exports;
59
+ }
60
+ a(c, "s");
61
+ for (var i = typeof H == "function" && H, g = 0; g < l.length; g++) c(l[g]);
62
+ return c;
63
+ }, "e"))({ 1: [function(n, o, s) {
64
+ o.exports = function(l) {
65
+ if (typeof Map != "function" || l) {
66
+ var c = n("./similar");
67
+ return new c();
68
+ } else
69
+ return /* @__PURE__ */ new Map();
70
+ };
71
+ }, { "./similar": 2 }], 2: [function(n, o, s) {
72
+ function l() {
73
+ return this.list = [], this.lastItem = void 0, this.size = 0, this;
74
+ }
75
+ a(l, "Similar"), l.prototype.get = function(c) {
76
+ var i;
77
+ if (this.lastItem && this.isEqual(this.lastItem.key, c))
78
+ return this.lastItem.val;
79
+ if (i = this.indexOf(c), i >= 0)
80
+ return this.lastItem = this.list[i], this.list[i].val;
81
+ }, l.prototype.set = function(c, i) {
82
+ var g;
83
+ return this.lastItem && this.isEqual(this.lastItem.key, c) ? (this.lastItem.val = i, this) : (g = this.indexOf(c), g >= 0 ? (this.lastItem =
84
+ this.list[g], this.list[g].val = i, this) : (this.lastItem = { key: c, val: i }, this.list.push(this.lastItem), this.size++, this));
85
+ }, l.prototype.delete = function(c) {
86
+ var i;
87
+ if (this.lastItem && this.isEqual(this.lastItem.key, c) && (this.lastItem = void 0), i = this.indexOf(c), i >= 0)
88
+ return this.size--, this.list.splice(i, 1)[0];
89
+ }, l.prototype.has = function(c) {
90
+ var i;
91
+ return this.lastItem && this.isEqual(this.lastItem.key, c) ? !0 : (i = this.indexOf(c), i >= 0 ? (this.lastItem = this.list[i], !0) :
92
+ !1);
93
+ }, l.prototype.forEach = function(c, i) {
94
+ var g;
95
+ for (g = 0; g < this.size; g++)
96
+ c.call(i || this, this.list[g].val, this.list[g].key, this);
97
+ }, l.prototype.indexOf = function(c) {
98
+ var i;
99
+ for (i = 0; i < this.size; i++)
100
+ if (this.isEqual(this.list[i].key, c))
101
+ return i;
102
+ return -1;
103
+ }, l.prototype.isEqual = function(c, i) {
104
+ return c === i || c !== c && i !== i;
105
+ }, o.exports = l;
106
+ }, {}], 3: [function(n, o, s) {
107
+ var l = n("map-or-similar");
108
+ o.exports = function(p) {
109
+ var u = new l(!1), y = [];
110
+ return function(v) {
111
+ var d = /* @__PURE__ */ a(function() {
112
+ var m = u, E, I, T = arguments.length - 1, R = Array(T + 1), C = !0, N;
113
+ if ((d.numArgs || d.numArgs === 0) && d.numArgs !== T + 1)
114
+ throw new Error("Memoizerific functions should always be called with the same number of arguments");
115
+ for (N = 0; N < T; N++) {
116
+ if (R[N] = {
117
+ cacheItem: m,
118
+ arg: arguments[N]
119
+ }, m.has(arguments[N])) {
120
+ m = m.get(arguments[N]);
121
+ continue;
122
+ }
123
+ C = !1, E = new l(!1), m.set(arguments[N], E), m = E;
124
+ }
125
+ return C && (m.has(arguments[T]) ? I = m.get(arguments[T]) : C = !1), C || (I = v.apply(null, arguments), m.set(arguments[T], I)),
126
+ p > 0 && (R[T] = {
127
+ cacheItem: m,
128
+ arg: arguments[T]
129
+ }, C ? c(y, R) : y.push(R), y.length > p && i(y.shift())), d.wasMemoized = C, d.numArgs = T + 1, I;
130
+ }, "memoizerific");
131
+ return d.limit = p, d.wasMemoized = !1, d.cache = u, d.lru = y, d;
132
+ };
133
+ };
134
+ function c(p, u) {
135
+ var y = p.length, v = u.length, d, m, E;
136
+ for (m = 0; m < y; m++) {
137
+ for (d = !0, E = 0; E < v; E++)
138
+ if (!g(p[m][E].arg, u[E].arg)) {
139
+ d = !1;
140
+ break;
141
+ }
142
+ if (d)
143
+ break;
144
+ }
145
+ p.push(p.splice(m, 1)[0]);
146
+ }
147
+ a(c, "moveToMostRecentLru");
148
+ function i(p) {
149
+ var u = p.length, y = p[u - 1], v, d;
150
+ for (y.cacheItem.delete(y.arg), d = u - 2; d >= 0 && (y = p[d], v = y.cacheItem.get(y.arg), !v || !v.size); d--)
151
+ y.cacheItem.delete(y.arg);
152
+ }
153
+ a(i, "removeCachedResult");
154
+ function g(p, u) {
155
+ return p === u || p !== p && u !== u;
156
+ }
157
+ a(g, "isEqual");
158
+ }, { "map-or-similar": 1 }] }, {}, [3])(3);
159
+ });
160
+ });
161
+
162
+ // ../node_modules/@storybook/global/dist/index.mjs
163
+ var S = (() => {
164
+ let r;
165
+ return typeof window < "u" ? r = window : typeof globalThis < "u" ? r = globalThis : typeof global < "u" ? r = global : typeof self < "u" ?
166
+ r = self : r = {}, r;
167
+ })();
168
+
169
+ // ../node_modules/ts-dedent/esm/index.js
170
+ function F(r) {
171
+ for (var t = [], e = 1; e < arguments.length; e++)
172
+ t[e - 1] = arguments[e];
173
+ var n = Array.from(typeof r == "string" ? [r] : r);
174
+ n[n.length - 1] = n[n.length - 1].replace(/\r?\n([\t ]*)$/, "");
175
+ var o = n.reduce(function(c, i) {
176
+ var g = i.match(/\n([\t ]+|(?!\s).)/g);
177
+ return g ? c.concat(g.map(function(p) {
178
+ var u, y;
179
+ return (y = (u = p.match(/[\t ]/g)) === null || u === void 0 ? void 0 : u.length) !== null && y !== void 0 ? y : 0;
180
+ })) : c;
181
+ }, []);
182
+ if (o.length) {
183
+ var s = new RegExp(`
184
+ [ ]{` + Math.min.apply(Math, o) + "}", "g");
185
+ n = n.map(function(c) {
186
+ return c.replace(s, `
187
+ `);
188
+ });
189
+ }
190
+ n[0] = n[0].replace(/^\r?\n/, "");
191
+ var l = n[0];
192
+ return t.forEach(function(c, i) {
193
+ var g = l.match(/(?:^|\n)( *)$/), p = g ? g[1] : "", u = c;
194
+ typeof c == "string" && c.includes(`
195
+ `) && (u = String(c).split(`
196
+ `).map(function(y, v) {
197
+ return v === 0 ? y : "" + p + y;
198
+ }).join(`
199
+ `)), l += u + n[i + 1];
200
+ }), l;
201
+ }
202
+ a(F, "dedent");
203
+
204
+ // src/shared/universal-store/instances.ts
205
+ var ft = /* @__PURE__ */ new Map();
206
+
207
+ // src/shared/universal-store/index.ts
208
+ var ye = "UNIVERSAL_STORE:", x = {
209
+ PENDING: "PENDING",
210
+ RESOLVED: "RESOLVED",
211
+ REJECTED: "REJECTED"
212
+ }, h = class h {
213
+ constructor(t, e) {
214
+ /** Enable debug logs for this store */
215
+ this.debugging = !1;
216
+ // TODO: narrow type of listeners based on event type
217
+ this.listeners = /* @__PURE__ */ new Map([["*", /* @__PURE__ */ new Set()]]);
218
+ /** Gets the current state */
219
+ this.getState = /* @__PURE__ */ a(() => (this.debug("getState", { state: this.state }), this.state), "getState");
220
+ /**
221
+ * Subscribes to store events
222
+ *
223
+ * @returns A function to unsubscribe
224
+ */
225
+ this.subscribe = /* @__PURE__ */ a((t, e) => {
226
+ let n = typeof t == "function", o = n ? "*" : t, s = n ? t : e;
227
+ if (this.debug("subscribe", { eventType: o, listener: s }), !s)
228
+ throw new TypeError(
229
+ `Missing first subscribe argument, or second if first is the event type, when subscribing to a UniversalStore with id '${this.id}'`
230
+ );
231
+ return this.listeners.has(o) || this.listeners.set(o, /* @__PURE__ */ new Set()), this.listeners.get(o).add(s), () => {
232
+ this.debug("unsubscribe", { eventType: o, listener: s }), this.listeners.has(o) && (this.listeners.get(o).delete(s), this.listeners.
233
+ get(o)?.size === 0 && this.listeners.delete(o));
234
+ };
235
+ }, "subscribe");
236
+ /** Sends a custom event to the other stores */
237
+ this.send = /* @__PURE__ */ a((t) => {
238
+ if (this.debug("send", { event: t }), this.status !== h.Status.READY)
239
+ throw new TypeError(
240
+ F`Cannot send event before store is ready. You can get the current status with store.status,
241
+ or await store.readyPromise to wait for the store to be ready before sending events.
242
+ ${JSON.stringify(
243
+ {
244
+ event: t,
245
+ id: this.id,
246
+ actor: this.actor,
247
+ environment: this.environment
248
+ },
249
+ null,
250
+ 2
251
+ )}`
252
+ );
253
+ this.emitToListeners(t, { actor: this.actor }), this.emitToChannel(t, { actor: this.actor });
254
+ }, "send");
255
+ if (this.debugging = t.debug ?? !1, !h.isInternalConstructing)
256
+ throw new TypeError(
257
+ "UniversalStore is not constructable - use UniversalStore.create() instead"
258
+ );
259
+ if (h.isInternalConstructing = !1, this.id = t.id, this.actorId = Date.now().toString(36) + Math.random().toString(36).substring(2), this.
260
+ actorType = t.leader ? h.ActorType.LEADER : h.ActorType.FOLLOWER, this.state = t.initialState, this.channelEventName = `${ye}${this.id}`,
261
+ this.debug("constructor", {
262
+ options: t,
263
+ environmentOverrides: e,
264
+ channelEventName: this.channelEventName
265
+ }), this.actor.type === h.ActorType.LEADER)
266
+ this.syncing = {
267
+ state: x.RESOLVED,
268
+ promise: Promise.resolve()
269
+ };
270
+ else {
271
+ let n, o, s = new Promise((l, c) => {
272
+ n = /* @__PURE__ */ a(() => {
273
+ this.syncing.state === x.PENDING && (this.syncing.state = x.RESOLVED, l());
274
+ }, "syncingResolve"), o = /* @__PURE__ */ a((i) => {
275
+ this.syncing.state === x.PENDING && (this.syncing.state = x.REJECTED, c(i));
276
+ }, "syncingReject");
277
+ });
278
+ this.syncing = {
279
+ state: x.PENDING,
280
+ promise: s,
281
+ resolve: n,
282
+ reject: o
283
+ };
284
+ }
285
+ this.getState = this.getState.bind(this), this.setState = this.setState.bind(this), this.subscribe = this.subscribe.bind(this), this.onStateChange =
286
+ this.onStateChange.bind(this), this.send = this.send.bind(this), this.emitToChannel = this.emitToChannel.bind(this), this.prepareThis = this.
287
+ prepareThis.bind(this), this.emitToListeners = this.emitToListeners.bind(this), this.handleChannelEvents = this.handleChannelEvents.bind(
288
+ this), this.debug = this.debug.bind(this), this.channel = e?.channel ?? h.preparation.channel, this.environment = e?.environment ?? h.preparation.
289
+ environment, this.channel && this.environment ? this.prepareThis({ channel: this.channel, environment: this.environment }) : h.preparation.
290
+ promise.then(this.prepareThis);
291
+ }
292
+ static setupPreparationPromise() {
293
+ let t, e, n = new Promise(
294
+ (o, s) => {
295
+ t = /* @__PURE__ */ a((l) => {
296
+ o(l);
297
+ }, "resolveRef"), e = /* @__PURE__ */ a((...l) => {
298
+ s(l);
299
+ }, "rejectRef");
300
+ }
301
+ );
302
+ h.preparation = {
303
+ resolve: t,
304
+ reject: e,
305
+ promise: n
306
+ };
307
+ }
308
+ /** The actor object representing the store instance with a unique ID and a type */
309
+ get actor() {
310
+ return Object.freeze({
311
+ id: this.actorId,
312
+ type: this.actorType,
313
+ environment: this.environment ?? h.Environment.UNKNOWN
314
+ });
315
+ }
316
+ /**
317
+ * The current state of the store, that signals both if the store is prepared by Storybook and
318
+ * also - in the case of a follower - if the state has been synced with the leader's state.
319
+ */
320
+ get status() {
321
+ if (!this.channel || !this.environment)
322
+ return h.Status.UNPREPARED;
323
+ switch (this.syncing?.state) {
324
+ case x.PENDING:
325
+ case void 0:
326
+ return h.Status.SYNCING;
327
+ case x.REJECTED:
328
+ return h.Status.ERROR;
329
+ case x.RESOLVED:
330
+ default:
331
+ return h.Status.READY;
332
+ }
333
+ }
334
+ /**
335
+ * A promise that resolves when the store is fully ready. A leader will be ready when the store
336
+ * has been prepared by Storybook, which is almost instantly.
337
+ *
338
+ * A follower will be ready when the state has been synced with the leader's state, within a few
339
+ * hundred milliseconds.
340
+ */
341
+ untilReady() {
342
+ return Promise.all([h.preparation.promise, this.syncing?.promise]);
343
+ }
344
+ /** Creates a new instance of UniversalStore */
345
+ static create(t) {
346
+ if (!t || typeof t?.id != "string")
347
+ throw new TypeError("id is required and must be a string, when creating a UniversalStore");
348
+ t.debug && console.debug(
349
+ F`[UniversalStore]
350
+ create`,
351
+ { options: t }
352
+ );
353
+ let e = ft.get(t.id);
354
+ if (e)
355
+ return console.warn(F`UniversalStore with id "${t.id}" already exists in this environment, re-using existing.
356
+ You should reuse the existing instance instead of trying to create a new one.`), e;
357
+ h.isInternalConstructing = !0;
358
+ let n = new h(t);
359
+ return ft.set(t.id, n), n;
360
+ }
361
+ /**
362
+ * Used by Storybook to set the channel for all instances of UniversalStore in the given
363
+ * environment.
364
+ *
365
+ * @internal
366
+ */
367
+ static __prepare(t, e) {
368
+ h.preparation.channel = t, h.preparation.environment = e, h.preparation.resolve({ channel: t, environment: e });
369
+ }
370
+ /**
371
+ * Updates the store's state
372
+ *
373
+ * Either a new state or a state updater function can be passed to the method.
374
+ */
375
+ setState(t) {
376
+ let e = this.state, n = typeof t == "function" ? t(e) : t;
377
+ if (this.debug("setState", { newState: n, previousState: e, updater: t }), this.status !== h.Status.READY)
378
+ throw new TypeError(
379
+ F`Cannot set state before store is ready. You can get the current status with store.status,
380
+ or await store.readyPromise to wait for the store to be ready before sending events.
381
+ ${JSON.stringify(
382
+ {
383
+ newState: n,
384
+ id: this.id,
385
+ actor: this.actor,
386
+ environment: this.environment
387
+ },
388
+ null,
389
+ 2
390
+ )}`
391
+ );
392
+ this.state = n;
393
+ let o = {
394
+ type: h.InternalEventType.SET_STATE,
395
+ payload: {
396
+ state: n,
397
+ previousState: e
398
+ }
399
+ };
400
+ this.emitToChannel(o, { actor: this.actor }), this.emitToListeners(o, { actor: this.actor });
401
+ }
402
+ /**
403
+ * Subscribes to state changes
404
+ *
405
+ * @returns Unsubscribe function
406
+ */
407
+ onStateChange(t) {
408
+ return this.debug("onStateChange", { listener: t }), this.subscribe(
409
+ h.InternalEventType.SET_STATE,
410
+ ({ payload: e }, n) => {
411
+ t(e.state, e.previousState, n);
412
+ }
413
+ );
414
+ }
415
+ emitToChannel(t, e) {
416
+ this.debug("emitToChannel", { event: t, eventInfo: e, channel: !!this.channel }), this.channel?.emit(this.channelEventName, {
417
+ event: t,
418
+ eventInfo: e
419
+ });
420
+ }
421
+ prepareThis({
422
+ channel: t,
423
+ environment: e
424
+ }) {
425
+ this.channel = t, this.environment = e, this.debug("prepared", { channel: !!t, environment: e }), this.channel.on(this.channelEventName,
426
+ this.handleChannelEvents), this.actor.type === h.ActorType.LEADER ? this.emitToChannel(
427
+ { type: h.InternalEventType.LEADER_CREATED },
428
+ { actor: this.actor }
429
+ ) : (this.emitToChannel(
430
+ { type: h.InternalEventType.FOLLOWER_CREATED },
431
+ { actor: this.actor }
432
+ ), this.emitToChannel(
433
+ { type: h.InternalEventType.EXISTING_STATE_REQUEST },
434
+ { actor: this.actor }
435
+ ), setTimeout(() => {
436
+ this.syncing.reject(
437
+ new TypeError(
438
+ `No existing state found for follower with id: '${this.id}'. Make sure a leader with the same id exists before creating a follower\
439
+ .`
440
+ )
441
+ );
442
+ }, 1e3));
443
+ }
444
+ emitToListeners(t, e) {
445
+ let n = this.listeners.get(t.type), o = this.listeners.get("*");
446
+ this.debug("emitToListeners", {
447
+ event: t,
448
+ eventInfo: e,
449
+ eventTypeListeners: n,
450
+ everythingListeners: o
451
+ }), [...n ?? [], ...o ?? []].forEach(
452
+ (s) => s(t, e)
453
+ );
454
+ }
455
+ handleChannelEvents(t) {
456
+ let { event: e, eventInfo: n } = t;
457
+ if ([n.actor.id, n.forwardingActor?.id].includes(this.actor.id)) {
458
+ this.debug("handleChannelEvents: Ignoring event from self", { channelEvent: t });
459
+ return;
460
+ } else if (this.syncing?.state === x.PENDING && e.type !== h.InternalEventType.EXISTING_STATE_RESPONSE) {
461
+ this.debug("handleChannelEvents: Ignoring event while syncing", { channelEvent: t });
462
+ return;
463
+ }
464
+ if (this.debug("handleChannelEvents", { channelEvent: t }), this.actor.type === h.ActorType.LEADER) {
465
+ let o = !0;
466
+ switch (e.type) {
467
+ case h.InternalEventType.EXISTING_STATE_REQUEST:
468
+ o = !1;
469
+ let s = {
470
+ type: h.InternalEventType.EXISTING_STATE_RESPONSE,
471
+ payload: this.state
472
+ };
473
+ this.debug("handleChannelEvents: responding to existing state request", {
474
+ responseEvent: s
475
+ }), this.emitToChannel(s, { actor: this.actor });
476
+ break;
477
+ case h.InternalEventType.LEADER_CREATED:
478
+ o = !1, this.syncing.state = x.REJECTED, this.debug("handleChannelEvents: erroring due to second leader being created", {
479
+ event: e
480
+ }), console.error(
481
+ F`Detected multiple UniversalStore leaders created with the same id "${this.id}".
482
+ Only one leader can exists at a time, your stores are now in an invalid state.
483
+ Leaders detected:
484
+ this: ${JSON.stringify(this.actor, null, 2)}
485
+ other: ${JSON.stringify(n.actor, null, 2)}`
486
+ );
487
+ break;
488
+ }
489
+ o && (this.debug("handleChannelEvents: forwarding event", { channelEvent: t }), this.emitToChannel(e, { actor: n.actor, forwardingActor: this.
490
+ actor }));
491
+ }
492
+ if (this.actor.type === h.ActorType.FOLLOWER)
493
+ switch (e.type) {
494
+ case h.InternalEventType.EXISTING_STATE_RESPONSE:
495
+ if (this.debug("handleChannelEvents: Setting state from leader's existing state response", {
496
+ event: e
497
+ }), this.syncing?.state !== x.PENDING)
498
+ break;
499
+ this.syncing.resolve?.();
500
+ let o = {
501
+ type: h.InternalEventType.SET_STATE,
502
+ payload: {
503
+ state: e.payload,
504
+ previousState: this.state
505
+ }
506
+ };
507
+ this.state = e.payload, this.emitToListeners(o, n);
508
+ break;
509
+ }
510
+ switch (e.type) {
511
+ case h.InternalEventType.SET_STATE:
512
+ this.debug("handleChannelEvents: Setting state", { event: e }), this.state = e.payload.state;
513
+ break;
514
+ }
515
+ this.emitToListeners(e, { actor: n.actor });
516
+ }
517
+ debug(t, e) {
518
+ this.debugging && console.debug(
519
+ F`[UniversalStore::${this.id}::${this.environment ?? h.Environment.UNKNOWN}]
520
+ ${t}`,
521
+ JSON.stringify(
522
+ {
523
+ data: e,
524
+ actor: this.actor,
525
+ state: this.state,
526
+ status: this.status
527
+ },
528
+ null,
529
+ 2
530
+ )
531
+ );
532
+ }
533
+ /**
534
+ * Used to reset the static fields of the UniversalStore class when cleaning up tests
535
+ *
536
+ * @internal
537
+ */
538
+ static __reset() {
539
+ h.preparation.reject(new Error("reset")), h.setupPreparationPromise(), h.isInternalConstructing = !1;
540
+ }
541
+ };
542
+ a(h, "UniversalStore"), /**
543
+ * Defines the possible actor types in the store system
544
+ *
545
+ * @readonly
546
+ */
547
+ h.ActorType = {
548
+ LEADER: "LEADER",
549
+ FOLLOWER: "FOLLOWER"
550
+ }, /**
551
+ * Defines the possible environments the store can run in
552
+ *
553
+ * @readonly
554
+ */
555
+ h.Environment = {
556
+ SERVER: "SERVER",
557
+ MANAGER: "MANAGER",
558
+ PREVIEW: "PREVIEW",
559
+ UNKNOWN: "UNKNOWN",
560
+ MOCK: "MOCK"
561
+ }, /**
562
+ * Internal event types used for store synchronization
563
+ *
564
+ * @readonly
565
+ */
566
+ h.InternalEventType = {
567
+ EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST",
568
+ EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE",
569
+ SET_STATE: "__SET_STATE",
570
+ LEADER_CREATED: "__LEADER_CREATED",
571
+ FOLLOWER_CREATED: "__FOLLOWER_CREATED"
572
+ }, h.Status = {
573
+ UNPREPARED: "UNPREPARED",
574
+ SYNCING: "SYNCING",
575
+ READY: "READY",
576
+ ERROR: "ERROR"
577
+ }, // This is used to check if constructor was called from the static factory create()
578
+ h.isInternalConstructing = !1, h.setupPreparationPromise();
579
+ var $ = h;
580
+
581
+ // src/channels/main.ts
582
+ var de = /* @__PURE__ */ a((r) => r.transports !== void 0, "isMulti"), ge = /* @__PURE__ */ a(() => Math.random().toString(16).slice(2), "ge\
583
+ nerateRandomId"), ht = class ht {
584
+ constructor(t = {}) {
585
+ this.sender = ge();
586
+ this.events = {};
587
+ this.data = {};
588
+ this.transports = [];
589
+ this.isAsync = t.async || !1, de(t) ? (this.transports = t.transports || [], this.transports.forEach((e) => {
590
+ e.setHandler((n) => this.handleEvent(n));
591
+ })) : this.transports = t.transport ? [t.transport] : [], this.transports.forEach((e) => {
592
+ e.setHandler((n) => this.handleEvent(n));
593
+ });
594
+ }
595
+ get hasTransport() {
596
+ return this.transports.length > 0;
597
+ }
598
+ addListener(t, e) {
599
+ this.events[t] = this.events[t] || [], this.events[t].push(e);
600
+ }
601
+ emit(t, ...e) {
602
+ let n = { type: t, args: e, from: this.sender }, o = {};
603
+ e.length >= 1 && e[0] && e[0].options && (o = e[0].options);
604
+ let s = /* @__PURE__ */ a(() => {
605
+ this.transports.forEach((l) => {
606
+ l.send(n, o);
607
+ }), this.handleEvent(n);
608
+ }, "handler");
609
+ this.isAsync ? setImmediate(s) : s();
610
+ }
611
+ last(t) {
612
+ return this.data[t];
613
+ }
614
+ eventNames() {
615
+ return Object.keys(this.events);
616
+ }
617
+ listenerCount(t) {
618
+ let e = this.listeners(t);
619
+ return e ? e.length : 0;
620
+ }
621
+ listeners(t) {
622
+ return this.events[t] || void 0;
623
+ }
624
+ once(t, e) {
625
+ let n = this.onceListener(t, e);
626
+ this.addListener(t, n);
627
+ }
628
+ removeAllListeners(t) {
629
+ t ? this.events[t] && delete this.events[t] : this.events = {};
630
+ }
631
+ removeListener(t, e) {
632
+ let n = this.listeners(t);
633
+ n && (this.events[t] = n.filter((o) => o !== e));
634
+ }
635
+ on(t, e) {
636
+ this.addListener(t, e);
637
+ }
638
+ off(t, e) {
639
+ this.removeListener(t, e);
640
+ }
641
+ handleEvent(t) {
642
+ let e = this.listeners(t.type);
643
+ e && e.length && e.forEach((n) => {
644
+ n.apply(t, t.args);
645
+ }), this.data[t.type] = t.args;
646
+ }
647
+ onceListener(t, e) {
648
+ let n = /* @__PURE__ */ a((...o) => (this.removeListener(t, n), e(...o)), "onceListener");
649
+ return n;
650
+ }
651
+ };
652
+ a(ht, "Channel");
653
+ var B = ht;
654
+
655
+ // src/channels/postmessage/index.ts
656
+ import { logger as Kt, pretty as Yt } from "storybook/internal/client-logger";
657
+ import * as so from "storybook/internal/core-events";
658
+
659
+ // ../node_modules/telejson/dist/chunk-465TF3XA.mjs
660
+ var ve = Object.create, Ot = Object.defineProperty, me = Object.getOwnPropertyDescriptor, Ct = Object.getOwnPropertyNames, Ee = Object.getPrototypeOf,
661
+ be = Object.prototype.hasOwnProperty, P = /* @__PURE__ */ a((r, t) => /* @__PURE__ */ a(function() {
662
+ return t || (0, r[Ct(r)[0]])((t = { exports: {} }).exports, t), t.exports;
663
+ }, "__require"), "__commonJS"), Se = /* @__PURE__ */ a((r, t, e, n) => {
664
+ if (t && typeof t == "object" || typeof t == "function")
665
+ for (let o of Ct(t))
666
+ !be.call(r, o) && o !== e && Ot(r, o, { get: /* @__PURE__ */ a(() => t[o], "get"), enumerable: !(n = me(t, o)) || n.enumerable });
667
+ return r;
668
+ }, "__copyProps"), ot = /* @__PURE__ */ a((r, t, e) => (e = r != null ? ve(Ee(r)) : {}, Se(
669
+ t || !r || !r.__esModule ? Ot(e, "default", { value: r, enumerable: !0 }) : e,
670
+ r
671
+ )), "__toESM"), _e = [
672
+ "bubbles",
673
+ "cancelBubble",
674
+ "cancelable",
675
+ "composed",
676
+ "currentTarget",
677
+ "defaultPrevented",
678
+ "eventPhase",
679
+ "isTrusted",
680
+ "returnValue",
681
+ "srcElement",
682
+ "target",
683
+ "timeStamp",
684
+ "type"
685
+ ], Te = ["detail"];
686
+ function Pt(r) {
687
+ let t = _e.filter((e) => r[e] !== void 0).reduce((e, n) => ({ ...e, [n]: r[n] }), {});
688
+ return r instanceof CustomEvent && Te.filter((e) => r[e] !== void 0).forEach((e) => {
689
+ t[e] = r[e];
690
+ }), t;
691
+ }
692
+ a(Pt, "extractEventHiddenProperties");
693
+
694
+ // ../node_modules/telejson/dist/index.mjs
695
+ var Bt = he(xt(), 1);
696
+ var Ft = P({
697
+ "node_modules/has-symbols/shams.js"(r, t) {
698
+ "use strict";
699
+ t.exports = /* @__PURE__ */ a(function() {
700
+ if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function")
701
+ return !1;
702
+ if (typeof Symbol.iterator == "symbol")
703
+ return !0;
704
+ var n = {}, o = Symbol("test"), s = Object(o);
705
+ if (typeof o == "string" || Object.prototype.toString.call(o) !== "[object Symbol]" || Object.prototype.toString.call(s) !== "[object \
706
+ Symbol]")
707
+ return !1;
708
+ var l = 42;
709
+ n[o] = l;
710
+ for (o in n)
711
+ return !1;
712
+ if (typeof Object.keys == "function" && Object.keys(n).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(
713
+ n).length !== 0)
714
+ return !1;
715
+ var c = Object.getOwnPropertySymbols(n);
716
+ if (c.length !== 1 || c[0] !== o || !Object.prototype.propertyIsEnumerable.call(n, o))
717
+ return !1;
718
+ if (typeof Object.getOwnPropertyDescriptor == "function") {
719
+ var i = Object.getOwnPropertyDescriptor(n, o);
720
+ if (i.value !== l || i.enumerable !== !0)
721
+ return !1;
722
+ }
723
+ return !0;
724
+ }, "hasSymbols");
725
+ }
726
+ }), Mt = P({
727
+ "node_modules/has-symbols/index.js"(r, t) {
728
+ "use strict";
729
+ var e = typeof Symbol < "u" && Symbol, n = Ft();
730
+ t.exports = /* @__PURE__ */ a(function() {
731
+ return typeof e != "function" || typeof Symbol != "function" || typeof e("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 :
732
+ n();
733
+ }, "hasNativeSymbols");
734
+ }
735
+ }), Ae = P({
736
+ "node_modules/function-bind/implementation.js"(r, t) {
737
+ "use strict";
738
+ var e = "Function.prototype.bind called on incompatible ", n = Array.prototype.slice, o = Object.prototype.toString, s = "[object Functi\
739
+ on]";
740
+ t.exports = /* @__PURE__ */ a(function(c) {
741
+ var i = this;
742
+ if (typeof i != "function" || o.call(i) !== s)
743
+ throw new TypeError(e + i);
744
+ for (var g = n.call(arguments, 1), p, u = /* @__PURE__ */ a(function() {
745
+ if (this instanceof p) {
746
+ var E = i.apply(
747
+ this,
748
+ g.concat(n.call(arguments))
749
+ );
750
+ return Object(E) === E ? E : this;
751
+ } else
752
+ return i.apply(
753
+ c,
754
+ g.concat(n.call(arguments))
755
+ );
756
+ }, "binder"), y = Math.max(0, i.length - g.length), v = [], d = 0; d < y; d++)
757
+ v.push("$" + d);
758
+ if (p = Function("binder", "return function (" + v.join(",") + "){ return binder.apply(this,arguments); }")(u), i.prototype) {
759
+ var m = /* @__PURE__ */ a(function() {
760
+ }, "Empty2");
761
+ m.prototype = i.prototype, p.prototype = new m(), m.prototype = null;
762
+ }
763
+ return p;
764
+ }, "bind");
765
+ }
766
+ }), gt = P({
767
+ "node_modules/function-bind/index.js"(r, t) {
768
+ "use strict";
769
+ var e = Ae();
770
+ t.exports = Function.prototype.bind || e;
771
+ }
772
+ }), we = P({
773
+ "node_modules/has/src/index.js"(r, t) {
774
+ "use strict";
775
+ var e = gt();
776
+ t.exports = e.call(Function.call, Object.prototype.hasOwnProperty);
777
+ }
778
+ }), $t = P({
779
+ "node_modules/get-intrinsic/index.js"(r, t) {
780
+ "use strict";
781
+ var e, n = SyntaxError, o = Function, s = TypeError, l = /* @__PURE__ */ a(function(j) {
782
+ try {
783
+ return o('"use strict"; return (' + j + ").constructor;")();
784
+ } catch {
785
+ }
786
+ }, "getEvalledConstructor"), c = Object.getOwnPropertyDescriptor;
787
+ if (c)
788
+ try {
789
+ c({}, "");
790
+ } catch {
791
+ c = null;
792
+ }
793
+ var i = /* @__PURE__ */ a(function() {
794
+ throw new s();
795
+ }, "throwTypeError"), g = c ? function() {
796
+ try {
797
+ return arguments.callee, i;
798
+ } catch {
799
+ try {
800
+ return c(arguments, "callee").get;
801
+ } catch {
802
+ return i;
803
+ }
804
+ }
805
+ }() : i, p = Mt()(), u = Object.getPrototypeOf || function(j) {
806
+ return j.__proto__;
807
+ }, y = {}, v = typeof Uint8Array > "u" ? e : u(Uint8Array), d = {
808
+ "%AggregateError%": typeof AggregateError > "u" ? e : AggregateError,
809
+ "%Array%": Array,
810
+ "%ArrayBuffer%": typeof ArrayBuffer > "u" ? e : ArrayBuffer,
811
+ "%ArrayIteratorPrototype%": p ? u([][Symbol.iterator]()) : e,
812
+ "%AsyncFromSyncIteratorPrototype%": e,
813
+ "%AsyncFunction%": y,
814
+ "%AsyncGenerator%": y,
815
+ "%AsyncGeneratorFunction%": y,
816
+ "%AsyncIteratorPrototype%": y,
817
+ "%Atomics%": typeof Atomics > "u" ? e : Atomics,
818
+ "%BigInt%": typeof BigInt > "u" ? e : BigInt,
819
+ "%Boolean%": Boolean,
820
+ "%DataView%": typeof DataView > "u" ? e : DataView,
821
+ "%Date%": Date,
822
+ "%decodeURI%": decodeURI,
823
+ "%decodeURIComponent%": decodeURIComponent,
824
+ "%encodeURI%": encodeURI,
825
+ "%encodeURIComponent%": encodeURIComponent,
826
+ "%Error%": Error,
827
+ "%eval%": eval,
828
+ "%EvalError%": EvalError,
829
+ "%Float32Array%": typeof Float32Array > "u" ? e : Float32Array,
830
+ "%Float64Array%": typeof Float64Array > "u" ? e : Float64Array,
831
+ "%FinalizationRegistry%": typeof FinalizationRegistry > "u" ? e : FinalizationRegistry,
832
+ "%Function%": o,
833
+ "%GeneratorFunction%": y,
834
+ "%Int8Array%": typeof Int8Array > "u" ? e : Int8Array,
835
+ "%Int16Array%": typeof Int16Array > "u" ? e : Int16Array,
836
+ "%Int32Array%": typeof Int32Array > "u" ? e : Int32Array,
837
+ "%isFinite%": isFinite,
838
+ "%isNaN%": isNaN,
839
+ "%IteratorPrototype%": p ? u(u([][Symbol.iterator]())) : e,
840
+ "%JSON%": typeof JSON == "object" ? JSON : e,
841
+ "%Map%": typeof Map > "u" ? e : Map,
842
+ "%MapIteratorPrototype%": typeof Map > "u" || !p ? e : u((/* @__PURE__ */ new Map())[Symbol.iterator]()),
843
+ "%Math%": Math,
844
+ "%Number%": Number,
845
+ "%Object%": Object,
846
+ "%parseFloat%": parseFloat,
847
+ "%parseInt%": parseInt,
848
+ "%Promise%": typeof Promise > "u" ? e : Promise,
849
+ "%Proxy%": typeof Proxy > "u" ? e : Proxy,
850
+ "%RangeError%": RangeError,
851
+ "%ReferenceError%": ReferenceError,
852
+ "%Reflect%": typeof Reflect > "u" ? e : Reflect,
853
+ "%RegExp%": RegExp,
854
+ "%Set%": typeof Set > "u" ? e : Set,
855
+ "%SetIteratorPrototype%": typeof Set > "u" || !p ? e : u((/* @__PURE__ */ new Set())[Symbol.iterator]()),
856
+ "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? e : SharedArrayBuffer,
857
+ "%String%": String,
858
+ "%StringIteratorPrototype%": p ? u(""[Symbol.iterator]()) : e,
859
+ "%Symbol%": p ? Symbol : e,
860
+ "%SyntaxError%": n,
861
+ "%ThrowTypeError%": g,
862
+ "%TypedArray%": v,
863
+ "%TypeError%": s,
864
+ "%Uint8Array%": typeof Uint8Array > "u" ? e : Uint8Array,
865
+ "%Uint8ClampedArray%": typeof Uint8ClampedArray > "u" ? e : Uint8ClampedArray,
866
+ "%Uint16Array%": typeof Uint16Array > "u" ? e : Uint16Array,
867
+ "%Uint32Array%": typeof Uint32Array > "u" ? e : Uint32Array,
868
+ "%URIError%": URIError,
869
+ "%WeakMap%": typeof WeakMap > "u" ? e : WeakMap,
870
+ "%WeakRef%": typeof WeakRef > "u" ? e : WeakRef,
871
+ "%WeakSet%": typeof WeakSet > "u" ? e : WeakSet
872
+ }, m = /* @__PURE__ */ a(function j(b) {
873
+ var A;
874
+ if (b === "%AsyncFunction%")
875
+ A = l("async function () {}");
876
+ else if (b === "%GeneratorFunction%")
877
+ A = l("function* () {}");
878
+ else if (b === "%AsyncGeneratorFunction%")
879
+ A = l("async function* () {}");
880
+ else if (b === "%AsyncGenerator%") {
881
+ var _ = j("%AsyncGeneratorFunction%");
882
+ _ && (A = _.prototype);
883
+ } else if (b === "%AsyncIteratorPrototype%") {
884
+ var w = j("%AsyncGenerator%");
885
+ w && (A = u(w.prototype));
886
+ }
887
+ return d[b] = A, A;
888
+ }, "doEval2"), E = {
889
+ "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
890
+ "%ArrayPrototype%": ["Array", "prototype"],
891
+ "%ArrayProto_entries%": ["Array", "prototype", "entries"],
892
+ "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
893
+ "%ArrayProto_keys%": ["Array", "prototype", "keys"],
894
+ "%ArrayProto_values%": ["Array", "prototype", "values"],
895
+ "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
896
+ "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
897
+ "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
898
+ "%BooleanPrototype%": ["Boolean", "prototype"],
899
+ "%DataViewPrototype%": ["DataView", "prototype"],
900
+ "%DatePrototype%": ["Date", "prototype"],
901
+ "%ErrorPrototype%": ["Error", "prototype"],
902
+ "%EvalErrorPrototype%": ["EvalError", "prototype"],
903
+ "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
904
+ "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
905
+ "%FunctionPrototype%": ["Function", "prototype"],
906
+ "%Generator%": ["GeneratorFunction", "prototype"],
907
+ "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
908
+ "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
909
+ "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
910
+ "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
911
+ "%JSONParse%": ["JSON", "parse"],
912
+ "%JSONStringify%": ["JSON", "stringify"],
913
+ "%MapPrototype%": ["Map", "prototype"],
914
+ "%NumberPrototype%": ["Number", "prototype"],
915
+ "%ObjectPrototype%": ["Object", "prototype"],
916
+ "%ObjProto_toString%": ["Object", "prototype", "toString"],
917
+ "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
918
+ "%PromisePrototype%": ["Promise", "prototype"],
919
+ "%PromiseProto_then%": ["Promise", "prototype", "then"],
920
+ "%Promise_all%": ["Promise", "all"],
921
+ "%Promise_reject%": ["Promise", "reject"],
922
+ "%Promise_resolve%": ["Promise", "resolve"],
923
+ "%RangeErrorPrototype%": ["RangeError", "prototype"],
924
+ "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
925
+ "%RegExpPrototype%": ["RegExp", "prototype"],
926
+ "%SetPrototype%": ["Set", "prototype"],
927
+ "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
928
+ "%StringPrototype%": ["String", "prototype"],
929
+ "%SymbolPrototype%": ["Symbol", "prototype"],
930
+ "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
931
+ "%TypedArrayPrototype%": ["TypedArray", "prototype"],
932
+ "%TypeErrorPrototype%": ["TypeError", "prototype"],
933
+ "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
934
+ "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
935
+ "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
936
+ "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
937
+ "%URIErrorPrototype%": ["URIError", "prototype"],
938
+ "%WeakMapPrototype%": ["WeakMap", "prototype"],
939
+ "%WeakSetPrototype%": ["WeakSet", "prototype"]
940
+ }, I = gt(), T = we(), R = I.call(Function.call, Array.prototype.concat), C = I.call(Function.apply, Array.prototype.splice), N = I.call(
941
+ Function.call, String.prototype.replace), Q = I.call(Function.call, String.prototype.slice), ee = I.call(Function.call, RegExp.prototype.
942
+ exec), re = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, ne = /\\(\\)?/g, oe = /* @__PURE__ */ a(
943
+ function(b) {
944
+ var A = Q(b, 0, 1), _ = Q(b, -1);
945
+ if (A === "%" && _ !== "%")
946
+ throw new n("invalid intrinsic syntax, expected closing `%`");
947
+ if (_ === "%" && A !== "%")
948
+ throw new n("invalid intrinsic syntax, expected opening `%`");
949
+ var w = [];
950
+ return N(b, re, function(L, M, O, Z) {
951
+ w[w.length] = O ? N(Z, ne, "$1") : M || L;
952
+ }), w;
953
+ }, "stringToPath3"), ie = /* @__PURE__ */ a(function(b, A) {
954
+ var _ = b, w;
955
+ if (T(E, _) && (w = E[_], _ = "%" + w[0] + "%"), T(d, _)) {
956
+ var L = d[_];
957
+ if (L === y && (L = m(_)), typeof L > "u" && !A)
958
+ throw new s("intrinsic " + b + " exists, but is not available. Please file an issue!");
959
+ return {
960
+ alias: w,
961
+ name: _,
962
+ value: L
963
+ };
964
+ }
965
+ throw new n("intrinsic " + b + " does not exist!");
966
+ }, "getBaseIntrinsic2");
967
+ t.exports = /* @__PURE__ */ a(function(b, A) {
968
+ if (typeof b != "string" || b.length === 0)
969
+ throw new s("intrinsic name must be a non-empty string");
970
+ if (arguments.length > 1 && typeof A != "boolean")
971
+ throw new s('"allowMissing" argument must be a boolean');
972
+ if (ee(/^%?[^%]*%?$/, b) === null)
973
+ throw new n("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
974
+ var _ = oe(b), w = _.length > 0 ? _[0] : "", L = ie("%" + w + "%", A), M = L.name, O = L.value, Z = !1, pt = L.alias;
975
+ pt && (w = pt[0], C(_, R([0, 1], pt)));
976
+ for (var tt = 1, z = !0; tt < _.length; tt += 1) {
977
+ var D = _[tt], et = Q(D, 0, 1), rt = Q(D, -1);
978
+ if ((et === '"' || et === "'" || et === "`" || rt === '"' || rt === "'" || rt === "`") && et !== rt)
979
+ throw new n("property names with quotes must have matching quotes");
980
+ if ((D === "constructor" || !z) && (Z = !0), w += "." + D, M = "%" + w + "%", T(d, M))
981
+ O = d[M];
982
+ else if (O != null) {
983
+ if (!(D in O)) {
984
+ if (!A)
985
+ throw new s("base intrinsic for " + b + " exists, but the property is not available.");
986
+ return;
987
+ }
988
+ if (c && tt + 1 >= _.length) {
989
+ var nt = c(O, D);
990
+ z = !!nt, z && "get" in nt && !("originalValue" in nt.get) ? O = nt.get : O = O[D];
991
+ } else
992
+ z = T(O, D), O = O[D];
993
+ z && !Z && (d[M] = O);
994
+ }
995
+ }
996
+ return O;
997
+ }, "GetIntrinsic");
998
+ }
999
+ }), Oe = P({
1000
+ "node_modules/call-bind/index.js"(r, t) {
1001
+ "use strict";
1002
+ var e = gt(), n = $t(), o = n("%Function.prototype.apply%"), s = n("%Function.prototype.call%"), l = n("%Reflect.apply%", !0) || e.call(
1003
+ s, o), c = n("%Object.getOwnPropertyDescriptor%", !0), i = n("%Object.defineProperty%", !0), g = n("%Math.max%");
1004
+ if (i)
1005
+ try {
1006
+ i({}, "a", { value: 1 });
1007
+ } catch {
1008
+ i = null;
1009
+ }
1010
+ t.exports = /* @__PURE__ */ a(function(y) {
1011
+ var v = l(e, s, arguments);
1012
+ if (c && i) {
1013
+ var d = c(v, "length");
1014
+ d.configurable && i(
1015
+ v,
1016
+ "length",
1017
+ { value: 1 + g(0, y.length - (arguments.length - 1)) }
1018
+ );
1019
+ }
1020
+ return v;
1021
+ }, "callBind");
1022
+ var p = /* @__PURE__ */ a(function() {
1023
+ return l(e, o, arguments);
1024
+ }, "applyBind2");
1025
+ i ? i(t.exports, "apply", { value: p }) : t.exports.apply = p;
1026
+ }
1027
+ }), Ce = P({
1028
+ "node_modules/call-bind/callBound.js"(r, t) {
1029
+ "use strict";
1030
+ var e = $t(), n = Oe(), o = n(e("String.prototype.indexOf"));
1031
+ t.exports = /* @__PURE__ */ a(function(l, c) {
1032
+ var i = e(l, !!c);
1033
+ return typeof i == "function" && o(l, ".prototype.") > -1 ? n(i) : i;
1034
+ }, "callBoundIntrinsic");
1035
+ }
1036
+ }), Pe = P({
1037
+ "node_modules/has-tostringtag/shams.js"(r, t) {
1038
+ "use strict";
1039
+ var e = Ft();
1040
+ t.exports = /* @__PURE__ */ a(function() {
1041
+ return e() && !!Symbol.toStringTag;
1042
+ }, "hasToStringTagShams");
1043
+ }
1044
+ }), Ie = P({
1045
+ "node_modules/is-regex/index.js"(r, t) {
1046
+ "use strict";
1047
+ var e = Ce(), n = Pe()(), o, s, l, c;
1048
+ n && (o = e("Object.prototype.hasOwnProperty"), s = e("RegExp.prototype.exec"), l = {}, i = /* @__PURE__ */ a(function() {
1049
+ throw l;
1050
+ }, "throwRegexMarker"), c = {
1051
+ toString: i,
1052
+ valueOf: i
1053
+ }, typeof Symbol.toPrimitive == "symbol" && (c[Symbol.toPrimitive] = i));
1054
+ var i, g = e("Object.prototype.toString"), p = Object.getOwnPropertyDescriptor, u = "[object RegExp]";
1055
+ t.exports = /* @__PURE__ */ a(n ? function(v) {
1056
+ if (!v || typeof v != "object")
1057
+ return !1;
1058
+ var d = p(v, "lastIndex"), m = d && o(d, "value");
1059
+ if (!m)
1060
+ return !1;
1061
+ try {
1062
+ s(v, c);
1063
+ } catch (E) {
1064
+ return E === l;
1065
+ }
1066
+ } : function(v) {
1067
+ return !v || typeof v != "object" && typeof v != "function" ? !1 : g(v) === u;
1068
+ }, "isRegex");
1069
+ }
1070
+ }), xe = P({
1071
+ "node_modules/is-function/index.js"(r, t) {
1072
+ t.exports = n;
1073
+ var e = Object.prototype.toString;
1074
+ function n(o) {
1075
+ if (!o)
1076
+ return !1;
1077
+ var s = e.call(o);
1078
+ return s === "[object Function]" || typeof o == "function" && s !== "[object RegExp]" || typeof window < "u" && (o === window.setTimeout ||
1079
+ o === window.alert || o === window.confirm || o === window.prompt);
1080
+ }
1081
+ a(n, "isFunction3");
1082
+ }
1083
+ }), Re = P({
1084
+ "node_modules/is-symbol/index.js"(r, t) {
1085
+ "use strict";
1086
+ var e = Object.prototype.toString, n = Mt()();
1087
+ n ? (o = Symbol.prototype.toString, s = /^Symbol\(.*\)$/, l = /* @__PURE__ */ a(function(i) {
1088
+ return typeof i.valueOf() != "symbol" ? !1 : s.test(o.call(i));
1089
+ }, "isRealSymbolObject"), t.exports = /* @__PURE__ */ a(function(i) {
1090
+ if (typeof i == "symbol")
1091
+ return !0;
1092
+ if (e.call(i) !== "[object Symbol]")
1093
+ return !1;
1094
+ try {
1095
+ return l(i);
1096
+ } catch {
1097
+ return !1;
1098
+ }
1099
+ }, "isSymbol3")) : t.exports = /* @__PURE__ */ a(function(i) {
1100
+ return !1;
1101
+ }, "isSymbol3");
1102
+ var o, s, l;
1103
+ }
1104
+ }), Ne = ot(Ie()), je = ot(xe()), Le = ot(Re());
1105
+ function De(r) {
1106
+ return r != null && typeof r == "object" && Array.isArray(r) === !1;
1107
+ }
1108
+ a(De, "isObject");
1109
+ var Fe = typeof global == "object" && global && global.Object === Object && global, Me = Fe, $e = typeof self == "object" && self && self.Object ===
1110
+ Object && self, Ue = Me || $e || Function("return this")(), vt = Ue, ke = vt.Symbol, U = ke, Ut = Object.prototype, Ge = Ut.hasOwnProperty, We = Ut.
1111
+ toString, q = U ? U.toStringTag : void 0;
1112
+ function ze(r) {
1113
+ var t = Ge.call(r, q), e = r[q];
1114
+ try {
1115
+ r[q] = void 0;
1116
+ var n = !0;
1117
+ } catch {
1118
+ }
1119
+ var o = We.call(r);
1120
+ return n && (t ? r[q] = e : delete r[q]), o;
1121
+ }
1122
+ a(ze, "getRawTag");
1123
+ var He = ze, Be = Object.prototype, qe = Be.toString;
1124
+ function Ve(r) {
1125
+ return qe.call(r);
1126
+ }
1127
+ a(Ve, "objectToString");
1128
+ var Je = Ve, Ke = "[object Null]", Ye = "[object Undefined]", Rt = U ? U.toStringTag : void 0;
1129
+ function Xe(r) {
1130
+ return r == null ? r === void 0 ? Ye : Ke : Rt && Rt in Object(r) ? He(r) : Je(r);
1131
+ }
1132
+ a(Xe, "baseGetTag");
1133
+ var kt = Xe;
1134
+ function Qe(r) {
1135
+ return r != null && typeof r == "object";
1136
+ }
1137
+ a(Qe, "isObjectLike");
1138
+ var Ze = Qe, tr = "[object Symbol]";
1139
+ function er(r) {
1140
+ return typeof r == "symbol" || Ze(r) && kt(r) == tr;
1141
+ }
1142
+ a(er, "isSymbol");
1143
+ var mt = er;
1144
+ function rr(r, t) {
1145
+ for (var e = -1, n = r == null ? 0 : r.length, o = Array(n); ++e < n; )
1146
+ o[e] = t(r[e], e, r);
1147
+ return o;
1148
+ }
1149
+ a(rr, "arrayMap");
1150
+ var nr = rr, or = Array.isArray, Et = or, ir = 1 / 0, Nt = U ? U.prototype : void 0, jt = Nt ? Nt.toString : void 0;
1151
+ function Gt(r) {
1152
+ if (typeof r == "string")
1153
+ return r;
1154
+ if (Et(r))
1155
+ return nr(r, Gt) + "";
1156
+ if (mt(r))
1157
+ return jt ? jt.call(r) : "";
1158
+ var t = r + "";
1159
+ return t == "0" && 1 / r == -ir ? "-0" : t;
1160
+ }
1161
+ a(Gt, "baseToString");
1162
+ var ar = Gt;
1163
+ function sr(r) {
1164
+ var t = typeof r;
1165
+ return r != null && (t == "object" || t == "function");
1166
+ }
1167
+ a(sr, "isObject2");
1168
+ var Wt = sr, lr = "[object AsyncFunction]", cr = "[object Function]", pr = "[object GeneratorFunction]", ur = "[object Proxy]";
1169
+ function fr(r) {
1170
+ if (!Wt(r))
1171
+ return !1;
1172
+ var t = kt(r);
1173
+ return t == cr || t == pr || t == lr || t == ur;
1174
+ }
1175
+ a(fr, "isFunction");
1176
+ var hr = fr, yr = vt["__core-js_shared__"], dt = yr, Lt = function() {
1177
+ var r = /[^.]+$/.exec(dt && dt.keys && dt.keys.IE_PROTO || "");
1178
+ return r ? "Symbol(src)_1." + r : "";
1179
+ }();
1180
+ function dr(r) {
1181
+ return !!Lt && Lt in r;
1182
+ }
1183
+ a(dr, "isMasked");
1184
+ var gr = dr, vr = Function.prototype, mr = vr.toString;
1185
+ function Er(r) {
1186
+ if (r != null) {
1187
+ try {
1188
+ return mr.call(r);
1189
+ } catch {
1190
+ }
1191
+ try {
1192
+ return r + "";
1193
+ } catch {
1194
+ }
1195
+ }
1196
+ return "";
1197
+ }
1198
+ a(Er, "toSource");
1199
+ var br = Er, Sr = /[\\^$.*+?()[\]{}|]/g, _r = /^\[object .+?Constructor\]$/, Tr = Function.prototype, Ar = Object.prototype, wr = Tr.toString,
1200
+ Or = Ar.hasOwnProperty, Cr = RegExp(
1201
+ "^" + wr.call(Or).replace(Sr, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
1202
+ );
1203
+ function Pr(r) {
1204
+ if (!Wt(r) || gr(r))
1205
+ return !1;
1206
+ var t = hr(r) ? Cr : _r;
1207
+ return t.test(br(r));
1208
+ }
1209
+ a(Pr, "baseIsNative");
1210
+ var Ir = Pr;
1211
+ function xr(r, t) {
1212
+ return r?.[t];
1213
+ }
1214
+ a(xr, "getValue");
1215
+ var Rr = xr;
1216
+ function Nr(r, t) {
1217
+ var e = Rr(r, t);
1218
+ return Ir(e) ? e : void 0;
1219
+ }
1220
+ a(Nr, "getNative");
1221
+ var zt = Nr;
1222
+ function jr(r, t) {
1223
+ return r === t || r !== r && t !== t;
1224
+ }
1225
+ a(jr, "eq");
1226
+ var Lr = jr, Dr = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Fr = /^\w*$/;
1227
+ function Mr(r, t) {
1228
+ if (Et(r))
1229
+ return !1;
1230
+ var e = typeof r;
1231
+ return e == "number" || e == "symbol" || e == "boolean" || r == null || mt(r) ? !0 : Fr.test(r) || !Dr.test(r) || t != null && r in Object(
1232
+ t);
1233
+ }
1234
+ a(Mr, "isKey");
1235
+ var $r = Mr, Ur = zt(Object, "create"), V = Ur;
1236
+ function kr() {
1237
+ this.__data__ = V ? V(null) : {}, this.size = 0;
1238
+ }
1239
+ a(kr, "hashClear");
1240
+ var Gr = kr;
1241
+ function Wr(r) {
1242
+ var t = this.has(r) && delete this.__data__[r];
1243
+ return this.size -= t ? 1 : 0, t;
1244
+ }
1245
+ a(Wr, "hashDelete");
1246
+ var zr = Wr, Hr = "__lodash_hash_undefined__", Br = Object.prototype, qr = Br.hasOwnProperty;
1247
+ function Vr(r) {
1248
+ var t = this.__data__;
1249
+ if (V) {
1250
+ var e = t[r];
1251
+ return e === Hr ? void 0 : e;
1252
+ }
1253
+ return qr.call(t, r) ? t[r] : void 0;
1254
+ }
1255
+ a(Vr, "hashGet");
1256
+ var Jr = Vr, Kr = Object.prototype, Yr = Kr.hasOwnProperty;
1257
+ function Xr(r) {
1258
+ var t = this.__data__;
1259
+ return V ? t[r] !== void 0 : Yr.call(t, r);
1260
+ }
1261
+ a(Xr, "hashHas");
1262
+ var Qr = Xr, Zr = "__lodash_hash_undefined__";
1263
+ function tn(r, t) {
1264
+ var e = this.__data__;
1265
+ return this.size += this.has(r) ? 0 : 1, e[r] = V && t === void 0 ? Zr : t, this;
1266
+ }
1267
+ a(tn, "hashSet");
1268
+ var en = tn;
1269
+ function k(r) {
1270
+ var t = -1, e = r == null ? 0 : r.length;
1271
+ for (this.clear(); ++t < e; ) {
1272
+ var n = r[t];
1273
+ this.set(n[0], n[1]);
1274
+ }
1275
+ }
1276
+ a(k, "Hash");
1277
+ k.prototype.clear = Gr;
1278
+ k.prototype.delete = zr;
1279
+ k.prototype.get = Jr;
1280
+ k.prototype.has = Qr;
1281
+ k.prototype.set = en;
1282
+ var Dt = k;
1283
+ function rn() {
1284
+ this.__data__ = [], this.size = 0;
1285
+ }
1286
+ a(rn, "listCacheClear");
1287
+ var nn = rn;
1288
+ function on(r, t) {
1289
+ for (var e = r.length; e--; )
1290
+ if (Lr(r[e][0], t))
1291
+ return e;
1292
+ return -1;
1293
+ }
1294
+ a(on, "assocIndexOf");
1295
+ var at = on, an = Array.prototype, sn = an.splice;
1296
+ function ln(r) {
1297
+ var t = this.__data__, e = at(t, r);
1298
+ if (e < 0)
1299
+ return !1;
1300
+ var n = t.length - 1;
1301
+ return e == n ? t.pop() : sn.call(t, e, 1), --this.size, !0;
1302
+ }
1303
+ a(ln, "listCacheDelete");
1304
+ var cn = ln;
1305
+ function pn(r) {
1306
+ var t = this.__data__, e = at(t, r);
1307
+ return e < 0 ? void 0 : t[e][1];
1308
+ }
1309
+ a(pn, "listCacheGet");
1310
+ var un = pn;
1311
+ function fn(r) {
1312
+ return at(this.__data__, r) > -1;
1313
+ }
1314
+ a(fn, "listCacheHas");
1315
+ var hn = fn;
1316
+ function yn(r, t) {
1317
+ var e = this.__data__, n = at(e, r);
1318
+ return n < 0 ? (++this.size, e.push([r, t])) : e[n][1] = t, this;
1319
+ }
1320
+ a(yn, "listCacheSet");
1321
+ var dn = yn;
1322
+ function G(r) {
1323
+ var t = -1, e = r == null ? 0 : r.length;
1324
+ for (this.clear(); ++t < e; ) {
1325
+ var n = r[t];
1326
+ this.set(n[0], n[1]);
1327
+ }
1328
+ }
1329
+ a(G, "ListCache");
1330
+ G.prototype.clear = nn;
1331
+ G.prototype.delete = cn;
1332
+ G.prototype.get = un;
1333
+ G.prototype.has = hn;
1334
+ G.prototype.set = dn;
1335
+ var gn = G, vn = zt(vt, "Map"), mn = vn;
1336
+ function En() {
1337
+ this.size = 0, this.__data__ = {
1338
+ hash: new Dt(),
1339
+ map: new (mn || gn)(),
1340
+ string: new Dt()
1341
+ };
1342
+ }
1343
+ a(En, "mapCacheClear");
1344
+ var bn = En;
1345
+ function Sn(r) {
1346
+ var t = typeof r;
1347
+ return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? r !== "__proto__" : r === null;
1348
+ }
1349
+ a(Sn, "isKeyable");
1350
+ var _n = Sn;
1351
+ function Tn(r, t) {
1352
+ var e = r.__data__;
1353
+ return _n(t) ? e[typeof t == "string" ? "string" : "hash"] : e.map;
1354
+ }
1355
+ a(Tn, "getMapData");
1356
+ var st = Tn;
1357
+ function An(r) {
1358
+ var t = st(this, r).delete(r);
1359
+ return this.size -= t ? 1 : 0, t;
1360
+ }
1361
+ a(An, "mapCacheDelete");
1362
+ var wn = An;
1363
+ function On(r) {
1364
+ return st(this, r).get(r);
1365
+ }
1366
+ a(On, "mapCacheGet");
1367
+ var Cn = On;
1368
+ function Pn(r) {
1369
+ return st(this, r).has(r);
1370
+ }
1371
+ a(Pn, "mapCacheHas");
1372
+ var In = Pn;
1373
+ function xn(r, t) {
1374
+ var e = st(this, r), n = e.size;
1375
+ return e.set(r, t), this.size += e.size == n ? 0 : 1, this;
1376
+ }
1377
+ a(xn, "mapCacheSet");
1378
+ var Rn = xn;
1379
+ function W(r) {
1380
+ var t = -1, e = r == null ? 0 : r.length;
1381
+ for (this.clear(); ++t < e; ) {
1382
+ var n = r[t];
1383
+ this.set(n[0], n[1]);
1384
+ }
1385
+ }
1386
+ a(W, "MapCache");
1387
+ W.prototype.clear = bn;
1388
+ W.prototype.delete = wn;
1389
+ W.prototype.get = Cn;
1390
+ W.prototype.has = In;
1391
+ W.prototype.set = Rn;
1392
+ var Ht = W, Nn = "Expected a function";
1393
+ function bt(r, t) {
1394
+ if (typeof r != "function" || t != null && typeof t != "function")
1395
+ throw new TypeError(Nn);
1396
+ var e = /* @__PURE__ */ a(function() {
1397
+ var n = arguments, o = t ? t.apply(this, n) : n[0], s = e.cache;
1398
+ if (s.has(o))
1399
+ return s.get(o);
1400
+ var l = r.apply(this, n);
1401
+ return e.cache = s.set(o, l) || s, l;
1402
+ }, "memoized");
1403
+ return e.cache = new (bt.Cache || Ht)(), e;
1404
+ }
1405
+ a(bt, "memoize");
1406
+ bt.Cache = Ht;
1407
+ var jn = bt, Ln = 500;
1408
+ function Dn(r) {
1409
+ var t = jn(r, function(n) {
1410
+ return e.size === Ln && e.clear(), n;
1411
+ }), e = t.cache;
1412
+ return t;
1413
+ }
1414
+ a(Dn, "memoizeCapped");
1415
+ var Fn = Dn, Mn = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, $n = /\\(\\)?/g, Un = Fn(
1416
+ function(r) {
1417
+ var t = [];
1418
+ return r.charCodeAt(0) === 46 && t.push(""), r.replace(Mn, function(e, n, o, s) {
1419
+ t.push(o ? s.replace($n, "$1") : n || e);
1420
+ }), t;
1421
+ }), kn = Un;
1422
+ function Gn(r) {
1423
+ return r == null ? "" : ar(r);
1424
+ }
1425
+ a(Gn, "toString");
1426
+ var Wn = Gn;
1427
+ function zn(r, t) {
1428
+ return Et(r) ? r : $r(r, t) ? [r] : kn(Wn(r));
1429
+ }
1430
+ a(zn, "castPath");
1431
+ var Hn = zn, Bn = 1 / 0;
1432
+ function qn(r) {
1433
+ if (typeof r == "string" || mt(r))
1434
+ return r;
1435
+ var t = r + "";
1436
+ return t == "0" && 1 / r == -Bn ? "-0" : t;
1437
+ }
1438
+ a(qn, "toKey");
1439
+ var Vn = qn;
1440
+ function Jn(r, t) {
1441
+ t = Hn(t, r);
1442
+ for (var e = 0, n = t.length; r != null && e < n; )
1443
+ r = r[Vn(t[e++])];
1444
+ return e && e == n ? r : void 0;
1445
+ }
1446
+ a(Jn, "baseGet");
1447
+ var Kn = Jn;
1448
+ function Yn(r, t, e) {
1449
+ var n = r == null ? void 0 : Kn(r, t);
1450
+ return n === void 0 ? e : n;
1451
+ }
1452
+ a(Yn, "get");
1453
+ var Xn = Yn, it = De, Qn = /* @__PURE__ */ a((r) => {
1454
+ let t = null, e = !1, n = !1, o = !1, s = "";
1455
+ if (r.indexOf("//") >= 0 || r.indexOf("/*") >= 0)
1456
+ for (let l = 0; l < r.length; l += 1)
1457
+ !t && !e && !n && !o ? r[l] === '"' || r[l] === "'" || r[l] === "`" ? t = r[l] : r[l] === "/" && r[l + 1] === "*" ? e = !0 : r[l] === "\
1458
+ /" && r[l + 1] === "/" ? n = !0 : r[l] === "/" && r[l + 1] !== "/" && (o = !0) : (t && (r[l] === t && r[l - 1] !== "\\" || r[l] === `
1459
+ ` && t !== "`") && (t = null), o && (r[l] === "/" && r[l - 1] !== "\\" || r[l] === `
1460
+ `) && (o = !1), e && r[l - 1] === "/" && r[l - 2] === "*" && (e = !1), n && r[l] === `
1461
+ ` && (n = !1)), !e && !n && (s += r[l]);
1462
+ else
1463
+ s = r;
1464
+ return s;
1465
+ }, "removeCodeComments"), Zn = (0, Bt.default)(1e4)(
1466
+ (r) => Qn(r).replace(/\n\s*/g, "").trim()
1467
+ ), to = /* @__PURE__ */ a(function(t, e) {
1468
+ let n = e.slice(0, e.indexOf("{")), o = e.slice(e.indexOf("{"));
1469
+ if (n.includes("=>") || n.includes("function"))
1470
+ return e;
1471
+ let s = n;
1472
+ return s = s.replace(t, "function"), s + o;
1473
+ }, "convertShorthandMethods2"), eo = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/, J = /* @__PURE__ */ a((r) => r.match(/^[\[\{\"\}].*[\]\}\"]$/),
1474
+ "isJSON");
1475
+ function qt(r) {
1476
+ if (!it(r))
1477
+ return r;
1478
+ let t = r, e = !1;
1479
+ return typeof Event < "u" && r instanceof Event && (t = Pt(t), e = !0), t = Object.keys(t).reduce((n, o) => {
1480
+ try {
1481
+ t[o] && t[o].toJSON, n[o] = t[o];
1482
+ } catch {
1483
+ e = !0;
1484
+ }
1485
+ return n;
1486
+ }, {}), e ? t : r;
1487
+ }
1488
+ a(qt, "convertUnconventionalData");
1489
+ var ro = /* @__PURE__ */ a(function(t) {
1490
+ let e, n, o, s;
1491
+ return /* @__PURE__ */ a(function(c, i) {
1492
+ try {
1493
+ if (c === "")
1494
+ return s = [], e = /* @__PURE__ */ new Map([[i, "[]"]]), n = /* @__PURE__ */ new Map(), o = [], i;
1495
+ let g = n.get(this) || this;
1496
+ for (; o.length && g !== o[0]; )
1497
+ o.shift(), s.pop();
1498
+ if (typeof i == "boolean")
1499
+ return i;
1500
+ if (i === void 0)
1501
+ return t.allowUndefined ? "_undefined_" : void 0;
1502
+ if (i === null)
1503
+ return null;
1504
+ if (typeof i == "number")
1505
+ return i === -1 / 0 ? "_-Infinity_" : i === 1 / 0 ? "_Infinity_" : Number.isNaN(i) ? "_NaN_" : i;
1506
+ if (typeof i == "bigint")
1507
+ return `_bigint_${i.toString()}`;
1508
+ if (typeof i == "string")
1509
+ return eo.test(i) ? t.allowDate ? `_date_${i}` : void 0 : i;
1510
+ if ((0, Ne.default)(i))
1511
+ return t.allowRegExp ? `_regexp_${i.flags}|${i.source}` : void 0;
1512
+ if ((0, je.default)(i)) {
1513
+ if (!t.allowFunction)
1514
+ return;
1515
+ let { name: u } = i, y = i.toString();
1516
+ return y.match(
1517
+ /(\[native code\]|WEBPACK_IMPORTED_MODULE|__webpack_exports__|__webpack_require__)/
1518
+ ) ? `_function_${u}|${(() => {
1519
+ }).toString()}` : `_function_${u}|${Zn(to(c, y))}`;
1520
+ }
1521
+ if ((0, Le.default)(i)) {
1522
+ if (!t.allowSymbol)
1523
+ return;
1524
+ let u = Symbol.keyFor(i);
1525
+ return u !== void 0 ? `_gsymbol_${u}` : `_symbol_${i.toString().slice(7, -1)}`;
1526
+ }
1527
+ if (o.length >= t.maxDepth)
1528
+ return Array.isArray(i) ? `[Array(${i.length})]` : "[Object]";
1529
+ if (i === this)
1530
+ return `_duplicate_${JSON.stringify(s)}`;
1531
+ if (i instanceof Error && t.allowError)
1532
+ return {
1533
+ __isConvertedError__: !0,
1534
+ errorProperties: {
1535
+ ...i.cause ? { cause: i.cause } : {},
1536
+ ...i,
1537
+ name: i.name,
1538
+ message: i.message,
1539
+ stack: i.stack,
1540
+ "_constructor-name_": i.constructor.name
1541
+ }
1542
+ };
1543
+ if (i.constructor && i.constructor.name && i.constructor.name !== "Object" && !Array.isArray(i) && !t.allowClass)
1544
+ return;
1545
+ let p = e.get(i);
1546
+ if (!p) {
1547
+ let u = Array.isArray(i) ? i : qt(i);
1548
+ if (i.constructor && i.constructor.name && i.constructor.name !== "Object" && !Array.isArray(i) && t.allowClass)
1549
+ try {
1550
+ Object.assign(u, { "_constructor-name_": i.constructor.name });
1551
+ } catch {
1552
+ }
1553
+ return s.push(c), o.unshift(u), e.set(i, JSON.stringify(s)), i !== u && n.set(i, u), u;
1554
+ }
1555
+ return `_duplicate_${p}`;
1556
+ } catch {
1557
+ return;
1558
+ }
1559
+ }, "replace");
1560
+ }, "replacer2"), no = /* @__PURE__ */ a(function reviver(options) {
1561
+ let refs = [], root;
1562
+ return /* @__PURE__ */ a(function revive(key, value) {
1563
+ if (key === "" && (root = value, refs.forEach(({ target: r, container: t, replacement: e }) => {
1564
+ let n = J(e) ? JSON.parse(e) : e.split(".");
1565
+ n.length === 0 ? t[r] = root : t[r] = Xn(root, n);
1566
+ })), key === "_constructor-name_")
1567
+ return value;
1568
+ if (it(value) && value.__isConvertedError__) {
1569
+ let { message: r, ...t } = value.errorProperties, e = new Error(r);
1570
+ return Object.assign(e, t), e;
1571
+ }
1572
+ if (it(value) && value["_constructor-name_"] && options.allowFunction) {
1573
+ let r = value["_constructor-name_"];
1574
+ if (r !== "Object") {
1575
+ let t = new Function(`return function ${r.replace(/[^a-zA-Z0-9$_]+/g, "")}(){}`)();
1576
+ Object.setPrototypeOf(value, new t());
1577
+ }
1578
+ return delete value["_constructor-name_"], value;
1579
+ }
1580
+ if (typeof value == "string" && value.startsWith("_function_") && options.allowFunction) {
1581
+ let [, name, source] = value.match(/_function_([^|]*)\|(.*)/) || [], sourceSanitized = source.replace(/[(\(\))|\\| |\]|`]*$/, "");
1582
+ if (!options.lazyEval)
1583
+ return eval(`(${sourceSanitized})`);
1584
+ let result = /* @__PURE__ */ a((...args) => {
1585
+ let f = eval(`(${sourceSanitized})`);
1586
+ return f(...args);
1587
+ }, "result");
1588
+ return Object.defineProperty(result, "toString", {
1589
+ value: /* @__PURE__ */ a(() => sourceSanitized, "value")
1590
+ }), Object.defineProperty(result, "name", {
1591
+ value: name
1592
+ }), result;
1593
+ }
1594
+ if (typeof value == "string" && value.startsWith("_regexp_") && options.allowRegExp) {
1595
+ let [, r, t] = value.match(/_regexp_([^|]*)\|(.*)/) || [];
1596
+ return new RegExp(t, r);
1597
+ }
1598
+ return typeof value == "string" && value.startsWith("_date_") && options.allowDate ? new Date(value.replace("_date_", "")) : typeof value ==
1599
+ "string" && value.startsWith("_duplicate_") ? (refs.push({ target: key, container: this, replacement: value.replace(/^_duplicate_/, "") }),
1600
+ null) : typeof value == "string" && value.startsWith("_symbol_") && options.allowSymbol ? Symbol(value.replace("_symbol_", "")) : typeof value ==
1601
+ "string" && value.startsWith("_gsymbol_") && options.allowSymbol ? Symbol.for(value.replace("_gsymbol_", "")) : typeof value == "string" &&
1602
+ value === "_-Infinity_" ? -1 / 0 : typeof value == "string" && value === "_Infinity_" ? 1 / 0 : typeof value == "string" && value === "_\
1603
+ NaN_" ? NaN : typeof value == "string" && value.startsWith("_bigint_") && typeof BigInt == "function" ? BigInt(value.replace("_bigint_", "")) :
1604
+ value;
1605
+ }, "revive");
1606
+ }, "reviver"), Vt = {
1607
+ maxDepth: 10,
1608
+ space: void 0,
1609
+ allowFunction: !0,
1610
+ allowRegExp: !0,
1611
+ allowDate: !0,
1612
+ allowClass: !0,
1613
+ allowError: !0,
1614
+ allowUndefined: !0,
1615
+ allowSymbol: !0,
1616
+ lazyEval: !0
1617
+ }, lt = /* @__PURE__ */ a((r, t = {}) => {
1618
+ let e = { ...Vt, ...t };
1619
+ return JSON.stringify(qt(r), ro(e), t.space);
1620
+ }, "stringify"), oo = /* @__PURE__ */ a(() => {
1621
+ let r = /* @__PURE__ */ new Map();
1622
+ return /* @__PURE__ */ a(function t(e) {
1623
+ it(e) && Object.entries(e).forEach(([n, o]) => {
1624
+ o === "_undefined_" ? e[n] = void 0 : r.get(o) || (r.set(o, !0), t(o));
1625
+ }), Array.isArray(e) && e.forEach((n, o) => {
1626
+ n === "_undefined_" ? (r.set(n, !0), e[o] = void 0) : r.get(n) || (r.set(n, !0), t(n));
1627
+ });
1628
+ }, "mutateUndefined");
1629
+ }, "mutator"), ct = /* @__PURE__ */ a((r, t = {}) => {
1630
+ let e = { ...Vt, ...t }, n = JSON.parse(r, no(e));
1631
+ return oo()(n), n;
1632
+ }, "parse");
1633
+
1634
+ // ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
1635
+ var io = !1, St = "Invariant failed";
1636
+ function K(r, t) {
1637
+ if (!r) {
1638
+ if (io)
1639
+ throw new Error(St);
1640
+ var e = typeof t == "function" ? t() : t, n = e ? "".concat(St, ": ").concat(e) : St;
1641
+ throw new Error(n);
1642
+ }
1643
+ }
1644
+ a(K, "invariant");
1645
+
1646
+ // src/channels/postmessage/getEventSourceUrl.ts
1647
+ import { logger as ao } from "storybook/internal/client-logger";
1648
+ var Jt = /* @__PURE__ */ a((r) => {
1649
+ let t = Array.from(
1650
+ document.querySelectorAll("iframe[data-is-storybook]")
1651
+ ), [e, ...n] = t.filter((s) => {
1652
+ try {
1653
+ return s.contentWindow?.location.origin === r.source.location.origin && s.contentWindow?.location.pathname === r.source.location.pathname;
1654
+ } catch {
1655
+ }
1656
+ try {
1657
+ return s.contentWindow === r.source;
1658
+ } catch {
1659
+ }
1660
+ let l = s.getAttribute("src"), c;
1661
+ try {
1662
+ if (!l)
1663
+ return !1;
1664
+ ({ origin: c } = new URL(l, document.location.toString()));
1665
+ } catch {
1666
+ return !1;
1667
+ }
1668
+ return c === r.origin;
1669
+ }), o = e?.getAttribute("src");
1670
+ if (o && n.length === 0) {
1671
+ let { protocol: s, host: l, pathname: c } = new URL(o, document.location.toString());
1672
+ return `${s}//${l}${c}`;
1673
+ }
1674
+ return n.length > 0 && ao.error("found multiple candidates for event source"), null;
1675
+ }, "getEventSourceUrl");
1676
+
1677
+ // src/channels/postmessage/index.ts
1678
+ var { document: _t, location: Tt } = S, Xt = "storybook-channel", lo = { allowFunction: !1, maxDepth: 25 }, At = class At {
1679
+ constructor(t) {
1680
+ this.config = t;
1681
+ this.connected = !1;
1682
+ if (this.buffer = [], typeof S?.addEventListener == "function" && S.addEventListener("message", this.handleEvent.bind(this), !1), t.page !==
1683
+ "manager" && t.page !== "preview")
1684
+ throw new Error(`postmsg-channel: "config.page" cannot be "${t.page}"`);
1685
+ }
1686
+ setHandler(t) {
1687
+ this.handler = (...e) => {
1688
+ t.apply(this, e), !this.connected && this.getLocalFrame().length && (this.flush(), this.connected = !0);
1689
+ };
1690
+ }
1691
+ /**
1692
+ * Sends `event` to the associated window. If the window does not yet exist the event will be
1693
+ * stored in a buffer and sent when the window exists.
1694
+ *
1695
+ * @param event
1696
+ */
1697
+ send(t, e) {
1698
+ let {
1699
+ target: n,
1700
+ // telejson options
1701
+ allowRegExp: o,
1702
+ allowFunction: s,
1703
+ allowSymbol: l,
1704
+ allowDate: c,
1705
+ allowError: i,
1706
+ allowUndefined: g,
1707
+ allowClass: p,
1708
+ maxDepth: u,
1709
+ space: y,
1710
+ lazyEval: v
1711
+ } = e || {}, d = Object.fromEntries(
1712
+ Object.entries({
1713
+ allowRegExp: o,
1714
+ allowFunction: s,
1715
+ allowSymbol: l,
1716
+ allowDate: c,
1717
+ allowError: i,
1718
+ allowUndefined: g,
1719
+ allowClass: p,
1720
+ maxDepth: u,
1721
+ space: y,
1722
+ lazyEval: v
1723
+ }).filter(([R, C]) => typeof C < "u")
1724
+ ), m = {
1725
+ ...lo,
1726
+ ...S.CHANNEL_OPTIONS || {},
1727
+ ...d
1728
+ }, E = this.getFrames(n), I = new URLSearchParams(Tt?.search || ""), T = lt(
1729
+ {
1730
+ key: Xt,
1731
+ event: t,
1732
+ refId: I.get("refId")
1733
+ },
1734
+ m
1735
+ );
1736
+ return E.length ? (this.buffer.length && this.flush(), E.forEach((R) => {
1737
+ try {
1738
+ R.postMessage(T, "*");
1739
+ } catch {
1740
+ Kt.error("sending over postmessage fail");
1741
+ }
1742
+ }), Promise.resolve(null)) : new Promise((R, C) => {
1743
+ this.buffer.push({ event: t, resolve: R, reject: C });
1744
+ });
1745
+ }
1746
+ flush() {
1747
+ let { buffer: t } = this;
1748
+ this.buffer = [], t.forEach((e) => {
1749
+ this.send(e.event).then(e.resolve).catch(e.reject);
1750
+ });
1751
+ }
1752
+ getFrames(t) {
1753
+ if (this.config.page === "manager") {
1754
+ let n = Array.from(
1755
+ _t.querySelectorAll("iframe[data-is-storybook][data-is-loaded]")
1756
+ ).flatMap((o) => {
1757
+ try {
1758
+ return o.contentWindow && o.dataset.isStorybook !== void 0 && o.id === t ? [o.contentWindow] : [];
1759
+ } catch {
1760
+ return [];
1761
+ }
1762
+ });
1763
+ return n?.length ? n : this.getCurrentFrames();
1764
+ }
1765
+ return S && S.parent && S.parent !== S.self ? [S.parent] : [];
1766
+ }
1767
+ getCurrentFrames() {
1768
+ return this.config.page === "manager" ? Array.from(
1769
+ _t.querySelectorAll('[data-is-storybook="true"]')
1770
+ ).flatMap((e) => e.contentWindow ? [e.contentWindow] : []) : S && S.parent ? [S.parent] : [];
1771
+ }
1772
+ getLocalFrame() {
1773
+ return this.config.page === "manager" ? Array.from(
1774
+ _t.querySelectorAll("#storybook-preview-iframe")
1775
+ ).flatMap((e) => e.contentWindow ? [e.contentWindow] : []) : S && S.parent ? [S.parent] : [];
1776
+ }
1777
+ handleEvent(t) {
1778
+ try {
1779
+ let { data: e } = t, { key: n, event: o, refId: s } = typeof e == "string" && J(e) ? ct(e, S.CHANNEL_OPTIONS || {}) : e;
1780
+ if (n === Xt) {
1781
+ let l = this.config.page === "manager" ? '<span style="color: #37D5D3; background: black"> manager </span>' : '<span style="color: #\
1782
+ 1EA7FD; background: black"> preview </span>', c = Object.values(so).includes(o.type) ? `<span style="color: #FF4785">${o.type}</span>` : `<s\
1783
+ pan style="color: #FFAE00">${o.type}</span>`;
1784
+ if (s && (o.refId = s), o.source = this.config.page === "preview" ? t.origin : Jt(t), !o.source) {
1785
+ Yt.error(
1786
+ `${l} received ${c} but was unable to determine the source of the event`
1787
+ );
1788
+ return;
1789
+ }
1790
+ let i = `${l} received ${c} (${e.length})`;
1791
+ Yt.debug(
1792
+ Tt.origin !== o.source ? i : `${i} <span style="color: gray">(on ${Tt.origin} from ${o.source})</span>`,
1793
+ ...o.args
1794
+ ), K(this.handler, "ChannelHandler should be set"), this.handler(o);
1795
+ }
1796
+ } catch (e) {
1797
+ Kt.error(e);
1798
+ }
1799
+ }
1800
+ };
1801
+ a(At, "PostMessageTransport");
1802
+ var Y = At;
1803
+
1804
+ // src/channels/websocket/index.ts
1805
+ import * as Qt from "storybook/internal/core-events";
1806
+ var { WebSocket: co } = S, Zt = 15e3, te = 5e3, wt = class wt {
1807
+ constructor({ url: t, onError: e, page: n }) {
1808
+ this.buffer = [];
1809
+ this.isReady = !1;
1810
+ this.isClosed = !1;
1811
+ this.pingTimeout = 0;
1812
+ this.socket = new co(t), this.socket.onopen = () => {
1813
+ this.isReady = !0, this.heartbeat(), this.flush();
1814
+ }, this.socket.onmessage = ({ data: o }) => {
1815
+ let s = typeof o == "string" && J(o) ? ct(o) : o;
1816
+ K(this.handler, "WebsocketTransport handler should be set"), this.handler(s), s.type === "ping" && (this.heartbeat(), this.send({ type: "\
1817
+ pong" }));
1818
+ }, this.socket.onerror = (o) => {
1819
+ e && e(o);
1820
+ }, this.socket.onclose = (o) => {
1821
+ K(this.handler, "WebsocketTransport handler should be set"), this.handler({
1822
+ type: Qt.CHANNEL_WS_DISCONNECT,
1823
+ args: [{ reason: o.reason, code: o.code }],
1824
+ from: n || "preview"
1825
+ }), this.isClosed = !0, clearTimeout(this.pingTimeout);
1826
+ };
1827
+ }
1828
+ heartbeat() {
1829
+ clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => {
1830
+ this.socket.close(3008, "timeout");
1831
+ }, Zt + te);
1832
+ }
1833
+ setHandler(t) {
1834
+ this.handler = t;
1835
+ }
1836
+ send(t) {
1837
+ this.isClosed || (this.isReady ? this.sendNow(t) : this.sendLater(t));
1838
+ }
1839
+ sendLater(t) {
1840
+ this.buffer.push(t);
1841
+ }
1842
+ sendNow(t) {
1843
+ let e = lt(t, {
1844
+ maxDepth: 15,
1845
+ allowFunction: !1,
1846
+ ...S.CHANNEL_OPTIONS
1847
+ });
1848
+ this.socket.send(e);
1849
+ }
1850
+ flush() {
1851
+ let { buffer: t } = this;
1852
+ this.buffer = [], t.forEach((e) => this.send(e));
1853
+ }
1854
+ };
1855
+ a(wt, "WebsocketTransport");
1856
+ var X = wt;
1857
+
1858
+ // src/channels/index.ts
1859
+ var { CONFIG_TYPE: po } = S, Xo = B;
1860
+ function Qo({ page: r, extraTransports: t = [] }) {
1861
+ let e = [new Y({ page: r }), ...t];
1862
+ if (po === "DEVELOPMENT") {
1863
+ let o = window.location.protocol === "http:" ? "ws" : "wss", { hostname: s, port: l } = window.location, c = `${o}://${s}:${l}/storybook\
1864
+ -server-channel`;
1865
+ e.push(new X({ url: c, onError: /* @__PURE__ */ a(() => {
1866
+ }, "onError"), page: r }));
1867
+ }
1868
+ let n = new B({ transports: e });
1869
+ return $.__prepare(
1870
+ n,
1871
+ r === "manager" ? $.Environment.MANAGER : $.Environment.PREVIEW
1872
+ ), n;
1873
+ }
1874
+ a(Qo, "createBrowserChannel");
1875
+ export {
1876
+ B as Channel,
1877
+ Zt as HEARTBEAT_INTERVAL,
1878
+ te as HEARTBEAT_MAX_LATENCY,
1879
+ Y as PostMessageTransport,
1880
+ X as WebsocketTransport,
1881
+ Qo as createBrowserChannel,
1882
+ Xo as default
1883
+ };