storybook 9.0.0-alpha.1 → 9.0.0-alpha.10

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 (259) 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/addon-controls-args-annotated.png +0 -0
  8. package/assets/docs/addon-controls-args-background-color.png +0 -0
  9. package/assets/docs/addon-controls-args-background-string.png +0 -0
  10. package/assets/docs/addon-controls-args-docs.png +0 -0
  11. package/assets/docs/addon-controls-args-logging.png +0 -0
  12. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  13. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  14. package/assets/docs/addon-controls-args-reflow.png +0 -0
  15. package/assets/docs/addon-controls-args-template.png +0 -0
  16. package/assets/docs/addon-controls-expanded.png +0 -0
  17. package/assets/docs/addon-controls-hero.gif +0 -0
  18. package/assets/docs/addon-controls-install.png +0 -0
  19. package/assets/docs/hero.gif +0 -0
  20. package/assets/docs/message-reference.png +0 -0
  21. package/assets/docs/viewport.png +0 -0
  22. package/assets/server/addon.tsconfig.json +6 -0
  23. package/assets/server/base-preview-body.html +119 -0
  24. package/assets/server/base-preview-head.html +451 -0
  25. package/assets/server/template.ejs +87 -0
  26. package/bin/index.cjs +1 -1
  27. package/dist/actions/decorator.d.ts +6 -0
  28. package/dist/actions/decorator.js +139 -0
  29. package/dist/actions/index.cjs +127 -0
  30. package/dist/actions/index.d.ts +105 -0
  31. package/dist/actions/index.js +112 -0
  32. package/dist/actions/manager.js +1196 -0
  33. package/dist/actions/preview.cjs +165 -0
  34. package/dist/actions/preview.d.ts +55 -0
  35. package/dist/actions/preview.js +156 -0
  36. package/dist/babel/index.cjs +54034 -0
  37. package/dist/babel/index.d.ts +7488 -0
  38. package/dist/babel/index.js +54044 -0
  39. package/dist/bin/index.cjs +119 -0
  40. package/dist/bin/index.js +113 -0
  41. package/dist/builder-manager/index.cjs +2140 -0
  42. package/dist/builder-manager/index.d.ts +19 -0
  43. package/dist/builder-manager/index.js +2162 -0
  44. package/dist/channels/index.cjs +1913 -0
  45. package/dist/channels/index.d.ts +108 -0
  46. package/dist/channels/index.js +1881 -0
  47. package/dist/cli/bin/index.cjs +2687 -0
  48. package/dist/cli/bin/index.d.ts +2 -0
  49. package/dist/cli/bin/index.js +2707 -0
  50. package/dist/cli/index.cjs +17327 -0
  51. package/dist/cli/index.d.ts +209 -0
  52. package/dist/cli/index.js +17349 -0
  53. package/dist/client-logger/index.cjs +80 -0
  54. package/dist/client-logger/index.d.ts +29 -0
  55. package/dist/client-logger/index.js +64 -0
  56. package/dist/common/index.cjs +20569 -0
  57. package/dist/common/index.d.ts +949 -0
  58. package/dist/common/index.js +20654 -0
  59. package/dist/components/index.cjs +27924 -0
  60. package/dist/components/index.d.ts +1423 -0
  61. package/dist/components/index.js +24673 -0
  62. package/dist/controls/decorator.d.ts +5 -0
  63. package/dist/controls/decorator.js +8 -0
  64. package/dist/controls/index.cjs +26 -0
  65. package/dist/controls/index.d.ts +39 -0
  66. package/dist/controls/index.js +6 -0
  67. package/dist/controls/manager.js +5545 -0
  68. package/dist/controls/preview.cjs +26 -0
  69. package/dist/controls/preview.d.ts +55 -0
  70. package/dist/controls/preview.js +9 -0
  71. package/dist/core-events/index.cjs +167 -0
  72. package/dist/core-events/index.d.ts +426 -0
  73. package/dist/core-events/index.js +149 -0
  74. package/dist/core-server/index.cjs +38183 -0
  75. package/dist/core-server/index.d.ts +720 -0
  76. package/dist/core-server/index.js +38272 -0
  77. package/dist/core-server/presets/common-manager.js +20 -0
  78. package/dist/core-server/presets/common-override-preset.cjs +4824 -0
  79. package/dist/core-server/presets/common-override-preset.js +4829 -0
  80. package/dist/core-server/presets/common-preset.cjs +10231 -0
  81. package/dist/core-server/presets/common-preset.js +10309 -0
  82. package/dist/csf/index.cjs +179 -0
  83. package/dist/csf/index.d.ts +750 -0
  84. package/dist/csf/index.js +172 -0
  85. package/dist/csf-tools/index.cjs +1422 -0
  86. package/dist/csf-tools/index.d.ts +250 -0
  87. package/dist/csf-tools/index.js +1439 -0
  88. package/dist/docs-tools/index.cjs +2891 -0
  89. package/dist/docs-tools/index.d.ts +162 -0
  90. package/dist/docs-tools/index.js +2876 -0
  91. package/dist/index.cjs +17 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +2 -7
  94. package/dist/instrumenter/index.cjs +3485 -0
  95. package/dist/instrumenter/index.d.ts +104 -0
  96. package/dist/instrumenter/index.js +4965 -0
  97. package/dist/manager/globals-module-info.cjs +817 -0
  98. package/dist/manager/globals-module-info.d.ts +36 -0
  99. package/dist/manager/globals-module-info.js +804 -0
  100. package/dist/manager/globals-runtime.js +77536 -0
  101. package/dist/manager/globals.cjs +47 -0
  102. package/dist/manager/globals.d.ts +24 -0
  103. package/dist/manager/globals.js +34 -0
  104. package/dist/manager/runtime.js +12323 -0
  105. package/dist/manager-api/index.cjs +11074 -0
  106. package/dist/manager-api/index.d.ts +1512 -0
  107. package/dist/manager-api/index.js +4835 -0
  108. package/dist/manager-errors.d.ts +89 -0
  109. package/dist/manager-errors.js +99 -0
  110. package/dist/node-logger/index.cjs +1642 -0
  111. package/dist/node-logger/index.d.ts +117 -0
  112. package/dist/node-logger/index.js +1652 -0
  113. package/dist/preview/globals.cjs +38 -0
  114. package/dist/preview/globals.d.ts +15 -0
  115. package/dist/preview/globals.js +25 -0
  116. package/dist/preview/runtime.js +43629 -0
  117. package/dist/preview-api/index.cjs +5224 -0
  118. package/dist/preview-api/index.d.ts +1093 -0
  119. package/dist/preview-api/index.js +5292 -0
  120. package/dist/preview-errors.cjs +503 -0
  121. package/dist/preview-errors.d.ts +212 -0
  122. package/dist/preview-errors.js +449 -0
  123. package/dist/router/index.cjs +3296 -0
  124. package/dist/router/index.d.ts +385 -0
  125. package/dist/router/index.js +1843 -0
  126. package/dist/server-errors.cjs +727 -0
  127. package/dist/server-errors.d.ts +296 -0
  128. package/dist/server-errors.js +728 -0
  129. package/dist/telemetry/index.cjs +2756 -0
  130. package/dist/telemetry/index.d.ts +133 -0
  131. package/dist/telemetry/index.js +2797 -0
  132. package/dist/test/index.cjs +35685 -0
  133. package/dist/test/index.d.ts +186 -0
  134. package/dist/test/index.js +33751 -0
  135. package/dist/test/preview.cjs +15869 -0
  136. package/dist/test/preview.d.ts +54 -0
  137. package/dist/test/preview.js +14440 -0
  138. package/dist/test/spy.cjs +257 -0
  139. package/dist/test/spy.d.ts +66 -0
  140. package/dist/test/spy.js +239 -0
  141. package/dist/theming/create.cjs +232 -0
  142. package/dist/theming/create.d.ts +50 -0
  143. package/dist/theming/create.js +216 -0
  144. package/dist/theming/index.cjs +2665 -0
  145. package/dist/theming/index.d.ts +11939 -0
  146. package/dist/theming/index.js +2485 -0
  147. package/dist/types/index.cjs +27 -0
  148. package/dist/types/index.d.ts +2795 -0
  149. package/dist/types/index.js +7 -0
  150. package/dist/viewport/index.cjs +310 -0
  151. package/dist/viewport/index.d.ts +320 -0
  152. package/dist/viewport/index.js +290 -0
  153. package/dist/viewport/manager.js +400 -0
  154. package/dist/viewport/preview.cjs +35 -0
  155. package/dist/viewport/preview.d.ts +69 -0
  156. package/dist/viewport/preview.js +19 -0
  157. package/package.json +518 -209
  158. package/.eslintrc.cjs +0 -31
  159. package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
  160. package/core/babel/index.cjs +0 -1
  161. package/core/babel/index.d.ts +0 -2
  162. package/core/babel/index.js +0 -1
  163. package/core/builder-manager/index.cjs +0 -1
  164. package/core/builder-manager/index.d.ts +0 -2
  165. package/core/builder-manager/index.js +0 -1
  166. package/core/channels/index.cjs +0 -1
  167. package/core/channels/index.d.ts +0 -2
  168. package/core/channels/index.js +0 -1
  169. package/core/cli/bin/index.cjs +0 -1
  170. package/core/cli/bin/index.d.ts +0 -2
  171. package/core/cli/bin/index.js +0 -1
  172. package/core/cli/index.cjs +0 -1
  173. package/core/cli/index.d.ts +0 -2
  174. package/core/cli/index.js +0 -1
  175. package/core/client-logger/index.cjs +0 -1
  176. package/core/client-logger/index.d.ts +0 -2
  177. package/core/client-logger/index.js +0 -1
  178. package/core/common/index.cjs +0 -1
  179. package/core/common/index.d.ts +0 -2
  180. package/core/common/index.js +0 -1
  181. package/core/components/index.cjs +0 -1
  182. package/core/components/index.d.ts +0 -2
  183. package/core/components/index.js +0 -1
  184. package/core/core-events/index.cjs +0 -1
  185. package/core/core-events/index.d.ts +0 -2
  186. package/core/core-events/index.js +0 -1
  187. package/core/core-server/index.cjs +0 -1
  188. package/core/core-server/index.d.ts +0 -2
  189. package/core/core-server/index.js +0 -1
  190. package/core/core-server/presets/common-manager.js +0 -1
  191. package/core/core-server/presets/common-override-preset.cjs +0 -1
  192. package/core/core-server/presets/common-override-preset.js +0 -1
  193. package/core/core-server/presets/common-preset.cjs +0 -1
  194. package/core/core-server/presets/common-preset.js +0 -1
  195. package/core/csf/index.cjs +0 -1
  196. package/core/csf/index.d.ts +0 -2
  197. package/core/csf/index.js +0 -1
  198. package/core/csf-tools/index.cjs +0 -1
  199. package/core/csf-tools/index.d.ts +0 -2
  200. package/core/csf-tools/index.js +0 -1
  201. package/core/docs-tools/index.cjs +0 -1
  202. package/core/docs-tools/index.d.ts +0 -2
  203. package/core/docs-tools/index.js +0 -1
  204. package/core/index.cjs +0 -1
  205. package/core/index.d.ts +0 -2
  206. package/core/index.js +0 -1
  207. package/core/manager/globals-module-info.cjs +0 -1
  208. package/core/manager/globals-module-info.d.ts +0 -2
  209. package/core/manager/globals-module-info.js +0 -1
  210. package/core/manager/globals-runtime.js +0 -1
  211. package/core/manager/globals.cjs +0 -1
  212. package/core/manager/globals.d.ts +0 -2
  213. package/core/manager/globals.js +0 -1
  214. package/core/manager-api/index.cjs +0 -1
  215. package/core/manager-api/index.d.ts +0 -2
  216. package/core/manager-api/index.js +0 -1
  217. package/core/manager-errors.d.ts +0 -2
  218. package/core/manager-errors.js +0 -1
  219. package/core/node-logger/index.cjs +0 -1
  220. package/core/node-logger/index.d.ts +0 -2
  221. package/core/node-logger/index.js +0 -1
  222. package/core/preview/globals.cjs +0 -1
  223. package/core/preview/globals.d.ts +0 -2
  224. package/core/preview/globals.js +0 -1
  225. package/core/preview/runtime.js +0 -1
  226. package/core/preview-api/index.cjs +0 -1
  227. package/core/preview-api/index.d.ts +0 -2
  228. package/core/preview-api/index.js +0 -1
  229. package/core/preview-errors.cjs +0 -1
  230. package/core/preview-errors.d.ts +0 -2
  231. package/core/preview-errors.js +0 -1
  232. package/core/router/index.cjs +0 -1
  233. package/core/router/index.d.ts +0 -2
  234. package/core/router/index.js +0 -1
  235. package/core/server-errors.cjs +0 -1
  236. package/core/server-errors.d.ts +0 -2
  237. package/core/server-errors.js +0 -1
  238. package/core/telemetry/index.cjs +0 -1
  239. package/core/telemetry/index.d.ts +0 -2
  240. package/core/telemetry/index.js +0 -1
  241. package/core/theming/create.cjs +0 -1
  242. package/core/theming/create.d.ts +0 -2
  243. package/core/theming/create.js +0 -1
  244. package/core/theming/index.cjs +0 -1
  245. package/core/theming/index.d.ts +0 -2
  246. package/core/theming/index.js +0 -1
  247. package/core/types/index.cjs +0 -1
  248. package/core/types/index.d.ts +0 -2
  249. package/core/types/index.js +0 -1
  250. package/core.cjs +0 -0
  251. package/core.d.ts +0 -0
  252. package/core.js +0 -1
  253. package/dist/chunk-OWLSIX54.js +0 -8
  254. package/dist/core-path.cjs +0 -1
  255. package/dist/core-path.d.ts +0 -3
  256. package/dist/core-path.js +0 -9
  257. package/dist/proxy.cjs +0 -1
  258. package/dist/proxy.d.ts +0 -2
  259. package/dist/proxy.js +0 -9
@@ -0,0 +1,2876 @@
1
+ var mr = Object.create;
2
+ var Ae = Object.defineProperty;
3
+ var yr = Object.getOwnPropertyDescriptor;
4
+ var fr = Object.getOwnPropertyNames;
5
+ var dr = Object.getPrototypeOf, Tr = Object.prototype.hasOwnProperty;
6
+ var r = (n, s) => Ae(n, "name", { value: s, configurable: !0 });
7
+ var gr = (n, s) => () => (s || n((s = { exports: {} }).exports, s), s.exports);
8
+ var hr = (n, s, a, p) => {
9
+ if (s && typeof s == "object" || typeof s == "function")
10
+ for (let c of fr(s))
11
+ !Tr.call(n, c) && c !== a && Ae(n, c, { get: () => s[c], enumerable: !(p = yr(s, c)) || p.enumerable });
12
+ return n;
13
+ };
14
+ var xr = (n, s, a) => (a = n != null ? mr(dr(n)) : {}, hr(
15
+ // If the importer is in node compatibility mode or this is not an ESM
16
+ // file that has been converted to a CommonJS file using a Babel-
17
+ // compatible transform (i.e. "__esModule" has not been set), then set
18
+ // "default" to the CommonJS "module.exports" for node compatibility.
19
+ s || !n || !n.__esModule ? Ae(a, "default", { value: n, enumerable: !0 }) : a,
20
+ n
21
+ ));
22
+
23
+ // ../node_modules/jsdoc-type-pratt-parser/dist/index.js
24
+ var yt = gr((me, mt) => {
25
+ (function(n, s) {
26
+ typeof me == "object" && typeof mt < "u" ? s(me) : typeof define == "function" && define.amd ? define(["exports"], s) : (n = typeof globalThis <
27
+ "u" ? globalThis : n || self, s(n.jtpp = {}));
28
+ })(me, function(n) {
29
+ "use strict";
30
+ function s(e) {
31
+ return e.text !== void 0 && e.text !== "" ? `'${e.type}' with value '${e.text}'` : `'${e.type}'`;
32
+ }
33
+ r(s, "tokenToString");
34
+ let re = class re extends Error {
35
+ constructor(t) {
36
+ super(`No parslet found for token: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, re.prototype);
37
+ }
38
+ getToken() {
39
+ return this.token;
40
+ }
41
+ };
42
+ r(re, "NoParsletFoundError");
43
+ let a = re, ne = class ne extends Error {
44
+ constructor(t) {
45
+ super(`The parsing ended early. The next token was: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, ne.prototype);
46
+ }
47
+ getToken() {
48
+ return this.token;
49
+ }
50
+ };
51
+ r(ne, "EarlyEndOfParseError");
52
+ let p = ne, oe = class oe extends Error {
53
+ constructor(t, o) {
54
+ let i = `Unexpected type: '${t.type}'.`;
55
+ o !== void 0 && (i += ` Message: ${o}`), super(i), Object.setPrototypeOf(this, oe.prototype);
56
+ }
57
+ };
58
+ r(oe, "UnexpectedTypeError");
59
+ let c = oe;
60
+ function u(e) {
61
+ return (t) => t.startsWith(e) ? { type: e, text: e } : null;
62
+ }
63
+ r(u, "makePunctuationRule");
64
+ function y(e) {
65
+ let t = 0, o, i = e[0], l = !1;
66
+ if (i !== "'" && i !== '"')
67
+ return null;
68
+ for (; t < e.length; ) {
69
+ if (t++, o = e[t], !l && o === i) {
70
+ t++;
71
+ break;
72
+ }
73
+ l = !l && o === "\\";
74
+ }
75
+ if (o !== i)
76
+ throw new Error("Unterminated String");
77
+ return e.slice(0, t);
78
+ }
79
+ r(y, "getQuoted");
80
+ let T = /[$_\p{ID_Start}]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u, g = /[$\-\p{ID_Continue}\u200C\u200D]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u;
81
+ function P(e) {
82
+ let t = e[0];
83
+ if (!T.test(t))
84
+ return null;
85
+ let o = 1;
86
+ do {
87
+ if (t = e[o], !g.test(t))
88
+ break;
89
+ o++;
90
+ } while (o < e.length);
91
+ return e.slice(0, o);
92
+ }
93
+ r(P, "getIdentifier");
94
+ let b = /^(NaN|-?((\d*\.\d+|\d+)([Ee][+-]?\d+)?|Infinity))/;
95
+ function fe(e) {
96
+ var t, o;
97
+ return (o = (t = b.exec(e)) === null || t === void 0 ? void 0 : t[0]) !== null && o !== void 0 ? o : null;
98
+ }
99
+ r(fe, "getNumber");
100
+ let q = /* @__PURE__ */ r((e) => {
101
+ let t = P(e);
102
+ return t == null ? null : {
103
+ type: "Identifier",
104
+ text: t
105
+ };
106
+ }, "identifierRule");
107
+ function E(e) {
108
+ return (t) => {
109
+ if (!t.startsWith(e))
110
+ return null;
111
+ let o = t[e.length];
112
+ return o !== void 0 && g.test(o) ? null : {
113
+ type: e,
114
+ text: e
115
+ };
116
+ };
117
+ }
118
+ r(E, "makeKeyWordRule");
119
+ let z = /* @__PURE__ */ r((e) => {
120
+ let t = y(e);
121
+ return t == null ? null : {
122
+ type: "StringValue",
123
+ text: t
124
+ };
125
+ }, "stringValueRule"), de = /* @__PURE__ */ r((e) => e.length > 0 ? null : {
126
+ type: "EOF",
127
+ text: ""
128
+ }, "eofRule"), Te = /* @__PURE__ */ r((e) => {
129
+ let t = fe(e);
130
+ return t === null ? null : {
131
+ type: "Number",
132
+ text: t
133
+ };
134
+ }, "numberRule"), At = [
135
+ de,
136
+ u("=>"),
137
+ u("("),
138
+ u(")"),
139
+ u("{"),
140
+ u("}"),
141
+ u("["),
142
+ u("]"),
143
+ u("|"),
144
+ u("&"),
145
+ u("<"),
146
+ u(">"),
147
+ u(","),
148
+ u(";"),
149
+ u("*"),
150
+ u("?"),
151
+ u("!"),
152
+ u("="),
153
+ u(":"),
154
+ u("..."),
155
+ u("."),
156
+ u("#"),
157
+ u("~"),
158
+ u("/"),
159
+ u("@"),
160
+ E("undefined"),
161
+ E("null"),
162
+ E("function"),
163
+ E("this"),
164
+ E("new"),
165
+ E("module"),
166
+ E("event"),
167
+ E("external"),
168
+ E("typeof"),
169
+ E("keyof"),
170
+ E("readonly"),
171
+ E("import"),
172
+ E("is"),
173
+ E("in"),
174
+ Te,
175
+ q,
176
+ z
177
+ ], Rt = /^\s*\n\s*/, U = class U {
178
+ static create(t) {
179
+ let o = this.read(t);
180
+ t = o.text;
181
+ let i = this.read(t);
182
+ return t = i.text, new U(t, void 0, o.token, i.token);
183
+ }
184
+ constructor(t, o, i, l) {
185
+ this.text = "", this.text = t, this.previous = o, this.current = i, this.next = l;
186
+ }
187
+ static read(t, o = !1) {
188
+ o = o || Rt.test(t), t = t.trim();
189
+ for (let i of At) {
190
+ let l = i(t);
191
+ if (l !== null) {
192
+ let m = Object.assign(Object.assign({}, l), { startOfLine: o });
193
+ return t = t.slice(m.text.length), { text: t, token: m };
194
+ }
195
+ }
196
+ throw new Error("Unexpected Token " + t);
197
+ }
198
+ advance() {
199
+ let t = U.read(this.text);
200
+ return new U(t.text, this.current, this.next, t.token);
201
+ }
202
+ };
203
+ r(U, "Lexer");
204
+ let ge = U;
205
+ function w(e) {
206
+ if (e === void 0)
207
+ throw new Error("Unexpected undefined");
208
+ if (e.type === "JsdocTypeKeyValue" || e.type === "JsdocTypeParameterList" || e.type === "JsdocTypeProperty" || e.type === "JsdocTypeRe\
209
+ adonlyProperty" || e.type === "JsdocTypeObjectField" || e.type === "JsdocTypeJsdocObjectField" || e.type === "JsdocTypeIndexSignature" || e.
210
+ type === "JsdocTypeMappedType")
211
+ throw new c(e);
212
+ return e;
213
+ }
214
+ r(w, "assertRootResult");
215
+ function he(e) {
216
+ return e.type === "JsdocTypeKeyValue" ? X(e) : w(e);
217
+ }
218
+ r(he, "assertPlainKeyValueOrRootResult");
219
+ function It(e) {
220
+ return e.type === "JsdocTypeName" ? e : X(e);
221
+ }
222
+ r(It, "assertPlainKeyValueOrNameResult");
223
+ function X(e) {
224
+ if (e.type !== "JsdocTypeKeyValue")
225
+ throw new c(e);
226
+ return e;
227
+ }
228
+ r(X, "assertPlainKeyValueResult");
229
+ function Ft(e) {
230
+ var t;
231
+ if (e.type === "JsdocTypeVariadic") {
232
+ if (((t = e.element) === null || t === void 0 ? void 0 : t.type) === "JsdocTypeName")
233
+ return e;
234
+ throw new c(e);
235
+ }
236
+ if (e.type !== "JsdocTypeNumber" && e.type !== "JsdocTypeName")
237
+ throw new c(e);
238
+ return e;
239
+ }
240
+ r(Ft, "assertNumberOrVariadicNameResult");
241
+ function xe(e) {
242
+ return e.type === "JsdocTypeIndexSignature" || e.type === "JsdocTypeMappedType";
243
+ }
244
+ r(xe, "isSquaredProperty");
245
+ var f;
246
+ (function(e) {
247
+ e[e.ALL = 0] = "ALL", e[e.PARAMETER_LIST = 1] = "PARAMETER_LIST", e[e.OBJECT = 2] = "OBJECT", e[e.KEY_VALUE = 3] = "KEY_VALUE", e[e.UNION =
248
+ 4] = "UNION", e[e.INTERSECTION = 5] = "INTERSECTION", e[e.PREFIX = 6] = "PREFIX", e[e.INFIX = 7] = "INFIX", e[e.TUPLE = 8] = "TUPLE", e[e.
249
+ SYMBOL = 9] = "SYMBOL", e[e.OPTIONAL = 10] = "OPTIONAL", e[e.NULLABLE = 11] = "NULLABLE", e[e.KEY_OF_TYPE_OF = 12] = "KEY_OF_TYPE_OF",
250
+ e[e.FUNCTION = 13] = "FUNCTION", e[e.ARROW = 14] = "ARROW", e[e.ARRAY_BRACKETS = 15] = "ARRAY_BRACKETS", e[e.GENERIC = 16] = "GENERIC",
251
+ e[e.NAME_PATH = 17] = "NAME_PATH", e[e.PARENTHESIS = 18] = "PARENTHESIS", e[e.SPECIAL_TYPES = 19] = "SPECIAL_TYPES";
252
+ })(f || (f = {}));
253
+ let ke = class ke {
254
+ constructor(t, o, i) {
255
+ this.grammar = t, typeof o == "string" ? this._lexer = ge.create(o) : this._lexer = o, this.baseParser = i;
256
+ }
257
+ get lexer() {
258
+ return this._lexer;
259
+ }
260
+ /**
261
+ * Parses a given string and throws an error if the parse ended before the end of the string.
262
+ */
263
+ parse() {
264
+ let t = this.parseType(f.ALL);
265
+ if (this.lexer.current.type !== "EOF")
266
+ throw new p(this.lexer.current);
267
+ return t;
268
+ }
269
+ /**
270
+ * Parses with the current lexer and asserts that the result is a {@link RootResult}.
271
+ */
272
+ parseType(t) {
273
+ return w(this.parseIntermediateType(t));
274
+ }
275
+ /**
276
+ * The main parsing function. First it tries to parse the current state in the prefix step, and then it continues
277
+ * to parse the state in the infix step.
278
+ */
279
+ parseIntermediateType(t) {
280
+ let o = this.tryParslets(null, t);
281
+ if (o === null)
282
+ throw new a(this.lexer.current);
283
+ return this.parseInfixIntermediateType(o, t);
284
+ }
285
+ /**
286
+ * In the infix parsing step the parser continues to parse the current state with all parslets until none returns
287
+ * a result.
288
+ */
289
+ parseInfixIntermediateType(t, o) {
290
+ let i = this.tryParslets(t, o);
291
+ for (; i !== null; )
292
+ t = i, i = this.tryParslets(t, o);
293
+ return t;
294
+ }
295
+ /**
296
+ * Tries to parse the current state with all parslets in the grammar and returns the first non null result.
297
+ */
298
+ tryParslets(t, o) {
299
+ for (let i of this.grammar) {
300
+ let l = i(this, o, t);
301
+ if (l !== null)
302
+ return l;
303
+ }
304
+ return null;
305
+ }
306
+ /**
307
+ * If the given type equals the current type of the {@link Lexer} advance the lexer. Return true if the lexer was
308
+ * advanced.
309
+ */
310
+ consume(t) {
311
+ return Array.isArray(t) || (t = [t]), t.includes(this.lexer.current.type) ? (this._lexer = this.lexer.advance(), !0) : !1;
312
+ }
313
+ acceptLexerState(t) {
314
+ this._lexer = t.lexer;
315
+ }
316
+ };
317
+ r(ke, "Parser");
318
+ let R = ke;
319
+ function $e(e) {
320
+ return e === "EOF" || e === "|" || e === "," || e === ")" || e === ">";
321
+ }
322
+ r($e, "isQuestionMarkUnknownType");
323
+ let Je = /* @__PURE__ */ r((e, t, o) => {
324
+ let i = e.lexer.current.type, l = e.lexer.next.type;
325
+ return o == null && i === "?" && !$e(l) || o != null && i === "?" ? (e.consume("?"), o == null ? {
326
+ type: "JsdocTypeNullable",
327
+ element: e.parseType(f.NULLABLE),
328
+ meta: {
329
+ position: "prefix"
330
+ }
331
+ } : {
332
+ type: "JsdocTypeNullable",
333
+ element: w(o),
334
+ meta: {
335
+ position: "suffix"
336
+ }
337
+ }) : null;
338
+ }, "nullableParslet");
339
+ function h(e) {
340
+ let t = /* @__PURE__ */ r((o, i, l) => {
341
+ let m = o.lexer.current.type, d = o.lexer.next.type;
342
+ if (l === null) {
343
+ if ("parsePrefix" in e && e.accept(m, d))
344
+ return e.parsePrefix(o);
345
+ } else if ("parseInfix" in e && e.precedence > i && e.accept(m, d))
346
+ return e.parseInfix(o, l);
347
+ return null;
348
+ }, "parslet");
349
+ return Object.defineProperty(t, "name", {
350
+ value: e.name
351
+ }), t;
352
+ }
353
+ r(h, "composeParslet");
354
+ let H = h({
355
+ name: "optionalParslet",
356
+ accept: /* @__PURE__ */ r((e) => e === "=", "accept"),
357
+ precedence: f.OPTIONAL,
358
+ parsePrefix: /* @__PURE__ */ r((e) => (e.consume("="), {
359
+ type: "JsdocTypeOptional",
360
+ element: e.parseType(f.OPTIONAL),
361
+ meta: {
362
+ position: "prefix"
363
+ }
364
+ }), "parsePrefix"),
365
+ parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("="), {
366
+ type: "JsdocTypeOptional",
367
+ element: w(t),
368
+ meta: {
369
+ position: "suffix"
370
+ }
371
+ }), "parseInfix")
372
+ }), Q = h({
373
+ name: "numberParslet",
374
+ accept: /* @__PURE__ */ r((e) => e === "Number", "accept"),
375
+ parsePrefix: /* @__PURE__ */ r((e) => {
376
+ let t = parseFloat(e.lexer.current.text);
377
+ return e.consume("Number"), {
378
+ type: "JsdocTypeNumber",
379
+ value: t
380
+ };
381
+ }, "parsePrefix")
382
+ }), jt = h({
383
+ name: "parenthesisParslet",
384
+ accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
385
+ parsePrefix: /* @__PURE__ */ r((e) => {
386
+ if (e.consume("("), e.consume(")"))
387
+ return {
388
+ type: "JsdocTypeParameterList",
389
+ elements: []
390
+ };
391
+ let t = e.parseIntermediateType(f.ALL);
392
+ if (!e.consume(")"))
393
+ throw new Error("Unterminated parenthesis");
394
+ return t.type === "JsdocTypeParameterList" ? t : t.type === "JsdocTypeKeyValue" ? {
395
+ type: "JsdocTypeParameterList",
396
+ elements: [t]
397
+ } : {
398
+ type: "JsdocTypeParenthesis",
399
+ element: w(t)
400
+ };
401
+ }, "parsePrefix")
402
+ }), Lt = h({
403
+ name: "specialTypesParslet",
404
+ accept: /* @__PURE__ */ r((e, t) => e === "?" && $e(t) || e === "null" || e === "undefined" || e === "*", "accept"),
405
+ parsePrefix: /* @__PURE__ */ r((e) => {
406
+ if (e.consume("null"))
407
+ return {
408
+ type: "JsdocTypeNull"
409
+ };
410
+ if (e.consume("undefined"))
411
+ return {
412
+ type: "JsdocTypeUndefined"
413
+ };
414
+ if (e.consume("*"))
415
+ return {
416
+ type: "JsdocTypeAny"
417
+ };
418
+ if (e.consume("?"))
419
+ return {
420
+ type: "JsdocTypeUnknown"
421
+ };
422
+ throw new Error("Unacceptable token: " + e.lexer.current.text);
423
+ }, "parsePrefix")
424
+ }), _t = h({
425
+ name: "notNullableParslet",
426
+ accept: /* @__PURE__ */ r((e) => e === "!", "accept"),
427
+ precedence: f.NULLABLE,
428
+ parsePrefix: /* @__PURE__ */ r((e) => (e.consume("!"), {
429
+ type: "JsdocTypeNotNullable",
430
+ element: e.parseType(f.NULLABLE),
431
+ meta: {
432
+ position: "prefix"
433
+ }
434
+ }), "parsePrefix"),
435
+ parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("!"), {
436
+ type: "JsdocTypeNotNullable",
437
+ element: w(t),
438
+ meta: {
439
+ position: "suffix"
440
+ }
441
+ }), "parseInfix")
442
+ });
443
+ function Vt({ allowTrailingComma: e }) {
444
+ return h({
445
+ name: "parameterListParslet",
446
+ accept: /* @__PURE__ */ r((t) => t === ",", "accept"),
447
+ precedence: f.PARAMETER_LIST,
448
+ parseInfix: /* @__PURE__ */ r((t, o) => {
449
+ let i = [
450
+ he(o)
451
+ ];
452
+ t.consume(",");
453
+ do
454
+ try {
455
+ let l = t.parseIntermediateType(f.PARAMETER_LIST);
456
+ i.push(he(l));
457
+ } catch (l) {
458
+ if (e && l instanceof a)
459
+ break;
460
+ throw l;
461
+ }
462
+ while (t.consume(","));
463
+ if (i.length > 0 && i.slice(0, -1).some((l) => l.type === "JsdocTypeVariadic"))
464
+ throw new Error("Only the last parameter may be a rest parameter");
465
+ return {
466
+ type: "JsdocTypeParameterList",
467
+ elements: i
468
+ };
469
+ }, "parseInfix")
470
+ });
471
+ }
472
+ r(Vt, "createParameterListParslet");
473
+ let Ut = h({
474
+ name: "genericParslet",
475
+ accept: /* @__PURE__ */ r((e, t) => e === "<" || e === "." && t === "<", "accept"),
476
+ precedence: f.GENERIC,
477
+ parseInfix: /* @__PURE__ */ r((e, t) => {
478
+ let o = e.consume(".");
479
+ e.consume("<");
480
+ let i = [];
481
+ do
482
+ i.push(e.parseType(f.PARAMETER_LIST));
483
+ while (e.consume(","));
484
+ if (!e.consume(">"))
485
+ throw new Error("Unterminated generic parameter list");
486
+ return {
487
+ type: "JsdocTypeGeneric",
488
+ left: w(t),
489
+ elements: i,
490
+ meta: {
491
+ brackets: "angle",
492
+ dot: o
493
+ }
494
+ };
495
+ }, "parseInfix")
496
+ }), Bt = h({
497
+ name: "unionParslet",
498
+ accept: /* @__PURE__ */ r((e) => e === "|", "accept"),
499
+ precedence: f.UNION,
500
+ parseInfix: /* @__PURE__ */ r((e, t) => {
501
+ e.consume("|");
502
+ let o = [];
503
+ do
504
+ o.push(e.parseType(f.UNION));
505
+ while (e.consume("|"));
506
+ return {
507
+ type: "JsdocTypeUnion",
508
+ elements: [w(t), ...o]
509
+ };
510
+ }, "parseInfix")
511
+ }), we = [
512
+ Je,
513
+ H,
514
+ Q,
515
+ jt,
516
+ Lt,
517
+ _t,
518
+ Vt({
519
+ allowTrailingComma: !0
520
+ }),
521
+ Ut,
522
+ Bt,
523
+ H
524
+ ];
525
+ function Z({ allowSquareBracketsOnAnyType: e, allowJsdocNamePaths: t, pathGrammar: o }) {
526
+ return /* @__PURE__ */ r(function(l, m, d) {
527
+ if (d == null || m >= f.NAME_PATH)
528
+ return null;
529
+ let x = l.lexer.current.type, N = l.lexer.next.type;
530
+ if (!(x === "." && N !== "<" || x === "[" && (e || d.type === "JsdocTypeName") || t && (x === "~" || x === "#")))
531
+ return null;
532
+ let O, se = !1;
533
+ l.consume(".") ? O = "property" : l.consume("[") ? (O = "property-brackets", se = !0) : l.consume("~") ? O = "inner" : (l.consume("#"),
534
+ O = "instance");
535
+ let et = o !== null ? new R(o, l.lexer, l) : l, k = et.parseIntermediateType(f.NAME_PATH);
536
+ l.acceptLexerState(et);
537
+ let G;
538
+ switch (k.type) {
539
+ case "JsdocTypeName":
540
+ G = {
541
+ type: "JsdocTypeProperty",
542
+ value: k.value,
543
+ meta: {
544
+ quote: void 0
545
+ }
546
+ };
547
+ break;
548
+ case "JsdocTypeNumber":
549
+ G = {
550
+ type: "JsdocTypeProperty",
551
+ value: k.value.toString(10),
552
+ meta: {
553
+ quote: void 0
554
+ }
555
+ };
556
+ break;
557
+ case "JsdocTypeStringValue":
558
+ G = {
559
+ type: "JsdocTypeProperty",
560
+ value: k.value,
561
+ meta: {
562
+ quote: k.meta.quote
563
+ }
564
+ };
565
+ break;
566
+ case "JsdocTypeSpecialNamePath":
567
+ if (k.specialType === "event")
568
+ G = k;
569
+ else
570
+ throw new c(k, "Type 'JsdocTypeSpecialNamePath' is only allowed with specialType 'event'");
571
+ break;
572
+ default:
573
+ throw new c(k, "Expecting 'JsdocTypeName', 'JsdocTypeNumber', 'JsdocStringValue' or 'JsdocTypeSpecialNamePath'");
574
+ }
575
+ if (se && !l.consume("]")) {
576
+ let tt = l.lexer.current;
577
+ throw new Error(`Unterminated square brackets. Next token is '${tt.type}' with text '${tt.text}'`);
578
+ }
579
+ return {
580
+ type: "JsdocTypeNamePath",
581
+ left: w(d),
582
+ right: G,
583
+ pathType: O
584
+ };
585
+ }, "namePathParslet");
586
+ }
587
+ r(Z, "createNamePathParslet");
588
+ function I({ allowedAdditionalTokens: e }) {
589
+ return h({
590
+ name: "nameParslet",
591
+ accept: /* @__PURE__ */ r((t) => t === "Identifier" || t === "this" || t === "new" || e.includes(t), "accept"),
592
+ parsePrefix: /* @__PURE__ */ r((t) => {
593
+ let { type: o, text: i } = t.lexer.current;
594
+ return t.consume(o), {
595
+ type: "JsdocTypeName",
596
+ value: i
597
+ };
598
+ }, "parsePrefix")
599
+ });
600
+ }
601
+ r(I, "createNameParslet");
602
+ let Y = h({
603
+ name: "stringValueParslet",
604
+ accept: /* @__PURE__ */ r((e) => e === "StringValue", "accept"),
605
+ parsePrefix: /* @__PURE__ */ r((e) => {
606
+ let t = e.lexer.current.text;
607
+ return e.consume("StringValue"), {
608
+ type: "JsdocTypeStringValue",
609
+ value: t.slice(1, -1),
610
+ meta: {
611
+ quote: t[0] === "'" ? "single" : "double"
612
+ }
613
+ };
614
+ }, "parsePrefix")
615
+ });
616
+ function ee({ pathGrammar: e, allowedTypes: t }) {
617
+ return h({
618
+ name: "specialNamePathParslet",
619
+ accept: /* @__PURE__ */ r((o) => t.includes(o), "accept"),
620
+ parsePrefix: /* @__PURE__ */ r((o) => {
621
+ let i = o.lexer.current.type;
622
+ if (o.consume(i), !o.consume(":"))
623
+ return {
624
+ type: "JsdocTypeName",
625
+ value: i
626
+ };
627
+ let l, m = o.lexer.current;
628
+ if (o.consume("StringValue"))
629
+ l = {
630
+ type: "JsdocTypeSpecialNamePath",
631
+ value: m.text.slice(1, -1),
632
+ specialType: i,
633
+ meta: {
634
+ quote: m.text[0] === "'" ? "single" : "double"
635
+ }
636
+ };
637
+ else {
638
+ let N = "", S = ["Identifier", "@", "/"];
639
+ for (; S.some((O) => o.consume(O)); )
640
+ N += m.text, m = o.lexer.current;
641
+ l = {
642
+ type: "JsdocTypeSpecialNamePath",
643
+ value: N,
644
+ specialType: i,
645
+ meta: {
646
+ quote: void 0
647
+ }
648
+ };
649
+ }
650
+ let d = new R(e, o.lexer, o), x = d.parseInfixIntermediateType(l, f.ALL);
651
+ return o.acceptLexerState(d), w(x);
652
+ }, "parsePrefix")
653
+ });
654
+ }
655
+ r(ee, "createSpecialNamePathParslet");
656
+ let qe = [
657
+ I({
658
+ allowedAdditionalTokens: ["external", "module"]
659
+ }),
660
+ Y,
661
+ Q,
662
+ Z({
663
+ allowSquareBracketsOnAnyType: !1,
664
+ allowJsdocNamePaths: !0,
665
+ pathGrammar: null
666
+ })
667
+ ], V = [
668
+ ...qe,
669
+ ee({
670
+ allowedTypes: ["event"],
671
+ pathGrammar: qe
672
+ })
673
+ ];
674
+ function Pe(e) {
675
+ let t;
676
+ if (e.type === "JsdocTypeParameterList")
677
+ t = e.elements;
678
+ else if (e.type === "JsdocTypeParenthesis")
679
+ t = [e.element];
680
+ else
681
+ throw new c(e);
682
+ return t.map((o) => he(o));
683
+ }
684
+ r(Pe, "getParameters");
685
+ function Ct(e) {
686
+ let t = Pe(e);
687
+ if (t.some((o) => o.type === "JsdocTypeKeyValue"))
688
+ throw new Error("No parameter should be named");
689
+ return t;
690
+ }
691
+ r(Ct, "getUnnamedParameters");
692
+ function be({ allowNamedParameters: e, allowNoReturnType: t, allowWithoutParenthesis: o, allowNewAsFunctionKeyword: i }) {
693
+ return h({
694
+ name: "functionParslet",
695
+ accept: /* @__PURE__ */ r((l, m) => l === "function" || i && l === "new" && m === "(", "accept"),
696
+ parsePrefix: /* @__PURE__ */ r((l) => {
697
+ let m = l.consume("new");
698
+ l.consume("function");
699
+ let d = l.lexer.current.type === "(";
700
+ if (!d) {
701
+ if (!o)
702
+ throw new Error("function is missing parameter list");
703
+ return {
704
+ type: "JsdocTypeName",
705
+ value: "function"
706
+ };
707
+ }
708
+ let x = {
709
+ type: "JsdocTypeFunction",
710
+ parameters: [],
711
+ arrow: !1,
712
+ constructor: m,
713
+ parenthesis: d
714
+ }, N = l.parseIntermediateType(f.FUNCTION);
715
+ if (e === void 0)
716
+ x.parameters = Ct(N);
717
+ else {
718
+ if (m && N.type === "JsdocTypeFunction" && N.arrow)
719
+ return x = N, x.constructor = !0, x;
720
+ x.parameters = Pe(N);
721
+ for (let S of x.parameters)
722
+ if (S.type === "JsdocTypeKeyValue" && !e.includes(S.key))
723
+ throw new Error(`only allowed named parameters are ${e.join(", ")} but got ${S.type}`);
724
+ }
725
+ if (l.consume(":"))
726
+ x.returnType = l.parseType(f.PREFIX);
727
+ else if (!t)
728
+ throw new Error("function is missing return type");
729
+ return x;
730
+ }, "parsePrefix")
731
+ });
732
+ }
733
+ r(be, "createFunctionParslet");
734
+ function Ee({ allowPostfix: e, allowEnclosingBrackets: t }) {
735
+ return h({
736
+ name: "variadicParslet",
737
+ accept: /* @__PURE__ */ r((o) => o === "...", "accept"),
738
+ precedence: f.PREFIX,
739
+ parsePrefix: /* @__PURE__ */ r((o) => {
740
+ o.consume("...");
741
+ let i = t && o.consume("[");
742
+ try {
743
+ let l = o.parseType(f.PREFIX);
744
+ if (i && !o.consume("]"))
745
+ throw new Error("Unterminated variadic type. Missing ']'");
746
+ return {
747
+ type: "JsdocTypeVariadic",
748
+ element: w(l),
749
+ meta: {
750
+ position: "prefix",
751
+ squareBrackets: i
752
+ }
753
+ };
754
+ } catch (l) {
755
+ if (l instanceof a) {
756
+ if (i)
757
+ throw new Error("Empty square brackets for variadic are not allowed.");
758
+ return {
759
+ type: "JsdocTypeVariadic",
760
+ meta: {
761
+ position: void 0,
762
+ squareBrackets: !1
763
+ }
764
+ };
765
+ } else
766
+ throw l;
767
+ }
768
+ }, "parsePrefix"),
769
+ parseInfix: e ? (o, i) => (o.consume("..."), {
770
+ type: "JsdocTypeVariadic",
771
+ element: w(i),
772
+ meta: {
773
+ position: "suffix",
774
+ squareBrackets: !1
775
+ }
776
+ }) : void 0
777
+ });
778
+ }
779
+ r(Ee, "createVariadicParslet");
780
+ let Ye = h({
781
+ name: "symbolParslet",
782
+ accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
783
+ precedence: f.SYMBOL,
784
+ parseInfix: /* @__PURE__ */ r((e, t) => {
785
+ if (t.type !== "JsdocTypeName")
786
+ throw new Error("Symbol expects a name on the left side. (Reacting on '(')");
787
+ e.consume("(");
788
+ let o = {
789
+ type: "JsdocTypeSymbol",
790
+ value: t.value
791
+ };
792
+ if (!e.consume(")")) {
793
+ let i = e.parseIntermediateType(f.SYMBOL);
794
+ if (o.element = Ft(i), !e.consume(")"))
795
+ throw new Error("Symbol does not end after value");
796
+ }
797
+ return o;
798
+ }, "parseInfix")
799
+ }), We = h({
800
+ name: "arrayBracketsParslet",
801
+ precedence: f.ARRAY_BRACKETS,
802
+ accept: /* @__PURE__ */ r((e, t) => e === "[" && t === "]", "accept"),
803
+ parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("["), e.consume("]"), {
804
+ type: "JsdocTypeGeneric",
805
+ left: {
806
+ type: "JsdocTypeName",
807
+ value: "Array"
808
+ },
809
+ elements: [
810
+ w(t)
811
+ ],
812
+ meta: {
813
+ brackets: "square",
814
+ dot: !1
815
+ }
816
+ }), "parseInfix")
817
+ });
818
+ function Se({ objectFieldGrammar: e, allowKeyTypes: t }) {
819
+ return h({
820
+ name: "objectParslet",
821
+ accept: /* @__PURE__ */ r((o) => o === "{", "accept"),
822
+ parsePrefix: /* @__PURE__ */ r((o) => {
823
+ o.consume("{");
824
+ let i = {
825
+ type: "JsdocTypeObject",
826
+ meta: {
827
+ separator: "comma"
828
+ },
829
+ elements: []
830
+ };
831
+ if (!o.consume("}")) {
832
+ let l, m = new R(e, o.lexer, o);
833
+ for (; ; ) {
834
+ m.acceptLexerState(o);
835
+ let d = m.parseIntermediateType(f.OBJECT);
836
+ o.acceptLexerState(m), d === void 0 && t && (d = o.parseIntermediateType(f.OBJECT));
837
+ let x = !1;
838
+ if (d.type === "JsdocTypeNullable" && (x = !0, d = d.element), d.type === "JsdocTypeNumber" || d.type === "JsdocTypeName" || d.
839
+ type === "JsdocTypeStringValue") {
840
+ let S;
841
+ d.type === "JsdocTypeStringValue" && (S = d.meta.quote), i.elements.push({
842
+ type: "JsdocTypeObjectField",
843
+ key: d.value.toString(),
844
+ right: void 0,
845
+ optional: x,
846
+ readonly: !1,
847
+ meta: {
848
+ quote: S
849
+ }
850
+ });
851
+ } else if (d.type === "JsdocTypeObjectField" || d.type === "JsdocTypeJsdocObjectField")
852
+ i.elements.push(d);
853
+ else
854
+ throw new c(d);
855
+ if (o.lexer.current.startOfLine)
856
+ l = "linebreak";
857
+ else if (o.consume(","))
858
+ l = "comma";
859
+ else if (o.consume(";"))
860
+ l = "semicolon";
861
+ else
862
+ break;
863
+ if (o.lexer.current.type === "}")
864
+ break;
865
+ }
866
+ if (i.meta.separator = l ?? "comma", !o.consume("}"))
867
+ throw new Error("Unterminated record type. Missing '}'");
868
+ }
869
+ return i;
870
+ }, "parsePrefix")
871
+ });
872
+ }
873
+ r(Se, "createObjectParslet");
874
+ function Ne({ allowSquaredProperties: e, allowKeyTypes: t, allowReadonly: o, allowOptional: i }) {
875
+ return h({
876
+ name: "objectFieldParslet",
877
+ precedence: f.KEY_VALUE,
878
+ accept: /* @__PURE__ */ r((l) => l === ":", "accept"),
879
+ parseInfix: /* @__PURE__ */ r((l, m) => {
880
+ var d;
881
+ let x = !1, N = !1;
882
+ i && m.type === "JsdocTypeNullable" && (x = !0, m = m.element), o && m.type === "JsdocTypeReadonlyProperty" && (N = !0, m = m.element);
883
+ let S = (d = l.baseParser) !== null && d !== void 0 ? d : l;
884
+ if (S.acceptLexerState(l), m.type === "JsdocTypeNumber" || m.type === "JsdocTypeName" || m.type === "JsdocTypeStringValue" || xe(m)) {
885
+ if (xe(m) && !e)
886
+ throw new c(m);
887
+ S.consume(":");
888
+ let O;
889
+ m.type === "JsdocTypeStringValue" && (O = m.meta.quote);
890
+ let se = S.parseType(f.KEY_VALUE);
891
+ return l.acceptLexerState(S), {
892
+ type: "JsdocTypeObjectField",
893
+ key: xe(m) ? m : m.value.toString(),
894
+ right: se,
895
+ optional: x,
896
+ readonly: N,
897
+ meta: {
898
+ quote: O
899
+ }
900
+ };
901
+ } else {
902
+ if (!t)
903
+ throw new c(m);
904
+ S.consume(":");
905
+ let O = S.parseType(f.KEY_VALUE);
906
+ return l.acceptLexerState(S), {
907
+ type: "JsdocTypeJsdocObjectField",
908
+ left: w(m),
909
+ right: O
910
+ };
911
+ }
912
+ }, "parseInfix")
913
+ });
914
+ }
915
+ r(Ne, "createObjectFieldParslet");
916
+ function De({ allowOptional: e, allowVariadic: t }) {
917
+ return h({
918
+ name: "keyValueParslet",
919
+ precedence: f.KEY_VALUE,
920
+ accept: /* @__PURE__ */ r((o) => o === ":", "accept"),
921
+ parseInfix: /* @__PURE__ */ r((o, i) => {
922
+ let l = !1, m = !1;
923
+ if (e && i.type === "JsdocTypeNullable" && (l = !0, i = i.element), t && i.type === "JsdocTypeVariadic" && i.element !== void 0 &&
924
+ (m = !0, i = i.element), i.type !== "JsdocTypeName")
925
+ throw new c(i);
926
+ o.consume(":");
927
+ let d = o.parseType(f.KEY_VALUE);
928
+ return {
929
+ type: "JsdocTypeKeyValue",
930
+ key: i.value,
931
+ right: d,
932
+ optional: l,
933
+ variadic: m
934
+ };
935
+ }, "parseInfix")
936
+ });
937
+ }
938
+ r(De, "createKeyValueParslet");
939
+ let Ge = [
940
+ ...we,
941
+ be({
942
+ allowWithoutParenthesis: !0,
943
+ allowNamedParameters: ["this", "new"],
944
+ allowNoReturnType: !0,
945
+ allowNewAsFunctionKeyword: !1
946
+ }),
947
+ Y,
948
+ ee({
949
+ allowedTypes: ["module", "external", "event"],
950
+ pathGrammar: V
951
+ }),
952
+ Ee({
953
+ allowEnclosingBrackets: !0,
954
+ allowPostfix: !0
955
+ }),
956
+ I({
957
+ allowedAdditionalTokens: ["keyof"]
958
+ }),
959
+ Ye,
960
+ We,
961
+ Z({
962
+ allowSquareBracketsOnAnyType: !1,
963
+ allowJsdocNamePaths: !0,
964
+ pathGrammar: V
965
+ })
966
+ ], Mt = [
967
+ ...Ge,
968
+ Se({
969
+ // jsdoc syntax allows full types as keys, so we need to pull in the full grammar here
970
+ // we leave out the object type deliberately
971
+ objectFieldGrammar: [
972
+ I({
973
+ allowedAdditionalTokens: ["module", "in"]
974
+ }),
975
+ Ne({
976
+ allowSquaredProperties: !1,
977
+ allowKeyTypes: !0,
978
+ allowOptional: !1,
979
+ allowReadonly: !1
980
+ }),
981
+ ...Ge
982
+ ],
983
+ allowKeyTypes: !0
984
+ }),
985
+ De({
986
+ allowOptional: !0,
987
+ allowVariadic: !0
988
+ })
989
+ ], ze = h({
990
+ name: "typeOfParslet",
991
+ accept: /* @__PURE__ */ r((e) => e === "typeof", "accept"),
992
+ parsePrefix: /* @__PURE__ */ r((e) => (e.consume("typeof"), {
993
+ type: "JsdocTypeTypeof",
994
+ element: w(e.parseType(f.KEY_OF_TYPE_OF))
995
+ }), "parsePrefix")
996
+ }), Kt = [
997
+ I({
998
+ allowedAdditionalTokens: ["module", "keyof", "event", "external", "in"]
999
+ }),
1000
+ Je,
1001
+ H,
1002
+ Y,
1003
+ Q,
1004
+ Ne({
1005
+ allowSquaredProperties: !1,
1006
+ allowKeyTypes: !1,
1007
+ allowOptional: !1,
1008
+ allowReadonly: !1
1009
+ })
1010
+ ], $t = [
1011
+ ...we,
1012
+ Se({
1013
+ allowKeyTypes: !1,
1014
+ objectFieldGrammar: Kt
1015
+ }),
1016
+ I({
1017
+ allowedAdditionalTokens: ["event", "external", "in"]
1018
+ }),
1019
+ ze,
1020
+ be({
1021
+ allowWithoutParenthesis: !1,
1022
+ allowNamedParameters: ["this", "new"],
1023
+ allowNoReturnType: !0,
1024
+ allowNewAsFunctionKeyword: !1
1025
+ }),
1026
+ Ee({
1027
+ allowEnclosingBrackets: !1,
1028
+ allowPostfix: !1
1029
+ }),
1030
+ // additional name parslet is needed for some special cases
1031
+ I({
1032
+ allowedAdditionalTokens: ["keyof"]
1033
+ }),
1034
+ ee({
1035
+ allowedTypes: ["module"],
1036
+ pathGrammar: V
1037
+ }),
1038
+ Z({
1039
+ allowSquareBracketsOnAnyType: !1,
1040
+ allowJsdocNamePaths: !0,
1041
+ pathGrammar: V
1042
+ }),
1043
+ De({
1044
+ allowOptional: !1,
1045
+ allowVariadic: !1
1046
+ }),
1047
+ Ye
1048
+ ];
1049
+ function qt({ allowQuestionMark: e }) {
1050
+ return h({
1051
+ name: "tupleParslet",
1052
+ accept: /* @__PURE__ */ r((t) => t === "[", "accept"),
1053
+ parsePrefix: /* @__PURE__ */ r((t) => {
1054
+ t.consume("[");
1055
+ let o = {
1056
+ type: "JsdocTypeTuple",
1057
+ elements: []
1058
+ };
1059
+ if (t.consume("]"))
1060
+ return o;
1061
+ let i = t.parseIntermediateType(f.ALL);
1062
+ if (i.type === "JsdocTypeParameterList" ? i.elements[0].type === "JsdocTypeKeyValue" ? o.elements = i.elements.map(X) : o.elements =
1063
+ i.elements.map(w) : i.type === "JsdocTypeKeyValue" ? o.elements = [X(i)] : o.elements = [w(i)], !t.consume("]"))
1064
+ throw new Error("Unterminated '['");
1065
+ if (!e && o.elements.some((l) => l.type === "JsdocTypeUnknown"))
1066
+ throw new Error("Question mark in tuple not allowed");
1067
+ return o;
1068
+ }, "parsePrefix")
1069
+ });
1070
+ }
1071
+ r(qt, "createTupleParslet");
1072
+ let Yt = h({
1073
+ name: "keyOfParslet",
1074
+ accept: /* @__PURE__ */ r((e) => e === "keyof", "accept"),
1075
+ parsePrefix: /* @__PURE__ */ r((e) => (e.consume("keyof"), {
1076
+ type: "JsdocTypeKeyof",
1077
+ element: w(e.parseType(f.KEY_OF_TYPE_OF))
1078
+ }), "parsePrefix")
1079
+ }), Wt = h({
1080
+ name: "importParslet",
1081
+ accept: /* @__PURE__ */ r((e) => e === "import", "accept"),
1082
+ parsePrefix: /* @__PURE__ */ r((e) => {
1083
+ if (e.consume("import"), !e.consume("("))
1084
+ throw new Error("Missing parenthesis after import keyword");
1085
+ let t = e.parseType(f.PREFIX);
1086
+ if (t.type !== "JsdocTypeStringValue")
1087
+ throw new Error("Only string values are allowed as paths for imports");
1088
+ if (!e.consume(")"))
1089
+ throw new Error("Missing closing parenthesis after import keyword");
1090
+ return {
1091
+ type: "JsdocTypeImport",
1092
+ element: t
1093
+ };
1094
+ }, "parsePrefix")
1095
+ }), Gt = h({
1096
+ name: "readonlyPropertyParslet",
1097
+ accept: /* @__PURE__ */ r((e) => e === "readonly", "accept"),
1098
+ parsePrefix: /* @__PURE__ */ r((e) => (e.consume("readonly"), {
1099
+ type: "JsdocTypeReadonlyProperty",
1100
+ element: e.parseType(f.KEY_VALUE)
1101
+ }), "parsePrefix")
1102
+ }), zt = h({
1103
+ name: "arrowFunctionParslet",
1104
+ precedence: f.ARROW,
1105
+ accept: /* @__PURE__ */ r((e) => e === "=>", "accept"),
1106
+ parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("=>"), {
1107
+ type: "JsdocTypeFunction",
1108
+ parameters: Pe(t).map(It),
1109
+ arrow: !0,
1110
+ constructor: !1,
1111
+ parenthesis: !0,
1112
+ returnType: e.parseType(f.OBJECT)
1113
+ }), "parseInfix")
1114
+ }), Xt = h({
1115
+ name: "intersectionParslet",
1116
+ accept: /* @__PURE__ */ r((e) => e === "&", "accept"),
1117
+ precedence: f.INTERSECTION,
1118
+ parseInfix: /* @__PURE__ */ r((e, t) => {
1119
+ e.consume("&");
1120
+ let o = [];
1121
+ do
1122
+ o.push(e.parseType(f.INTERSECTION));
1123
+ while (e.consume("&"));
1124
+ return {
1125
+ type: "JsdocTypeIntersection",
1126
+ elements: [w(t), ...o]
1127
+ };
1128
+ }, "parseInfix")
1129
+ }), Ht = h({
1130
+ name: "predicateParslet",
1131
+ precedence: f.INFIX,
1132
+ accept: /* @__PURE__ */ r((e) => e === "is", "accept"),
1133
+ parseInfix: /* @__PURE__ */ r((e, t) => {
1134
+ if (t.type !== "JsdocTypeName")
1135
+ throw new c(t, "A typescript predicate always has to have a name on the left side.");
1136
+ return e.consume("is"), {
1137
+ type: "JsdocTypePredicate",
1138
+ left: t,
1139
+ right: w(e.parseIntermediateType(f.INFIX))
1140
+ };
1141
+ }, "parseInfix")
1142
+ }), Qt = h({
1143
+ name: "objectSquareBracketPropertyParslet",
1144
+ accept: /* @__PURE__ */ r((e) => e === "[", "accept"),
1145
+ parsePrefix: /* @__PURE__ */ r((e) => {
1146
+ if (e.baseParser === void 0)
1147
+ throw new Error("Only allowed inside object grammar");
1148
+ e.consume("[");
1149
+ let t = e.lexer.current.text;
1150
+ e.consume("Identifier");
1151
+ let o;
1152
+ if (e.consume(":")) {
1153
+ let i = e.baseParser;
1154
+ i.acceptLexerState(e), o = {
1155
+ type: "JsdocTypeIndexSignature",
1156
+ key: t,
1157
+ right: i.parseType(f.ARRAY_BRACKETS)
1158
+ }, e.acceptLexerState(i);
1159
+ } else if (e.consume("in")) {
1160
+ let i = e.baseParser;
1161
+ i.acceptLexerState(e), o = {
1162
+ type: "JsdocTypeMappedType",
1163
+ key: t,
1164
+ right: i.parseType(f.ARRAY_BRACKETS)
1165
+ }, e.acceptLexerState(i);
1166
+ } else
1167
+ throw new Error("Missing ':' or 'in' inside square bracketed property.");
1168
+ if (!e.consume("]"))
1169
+ throw new Error("Unterminated square brackets");
1170
+ return o;
1171
+ }, "parsePrefix")
1172
+ }), Zt = [
1173
+ Gt,
1174
+ I({
1175
+ allowedAdditionalTokens: ["module", "event", "keyof", "event", "external", "in"]
1176
+ }),
1177
+ Je,
1178
+ H,
1179
+ Y,
1180
+ Q,
1181
+ Ne({
1182
+ allowSquaredProperties: !0,
1183
+ allowKeyTypes: !1,
1184
+ allowOptional: !0,
1185
+ allowReadonly: !0
1186
+ }),
1187
+ Qt
1188
+ ], er = [
1189
+ ...we,
1190
+ Se({
1191
+ allowKeyTypes: !1,
1192
+ objectFieldGrammar: Zt
1193
+ }),
1194
+ ze,
1195
+ Yt,
1196
+ Wt,
1197
+ Y,
1198
+ be({
1199
+ allowWithoutParenthesis: !0,
1200
+ allowNoReturnType: !1,
1201
+ allowNamedParameters: ["this", "new", "args"],
1202
+ allowNewAsFunctionKeyword: !0
1203
+ }),
1204
+ qt({
1205
+ allowQuestionMark: !1
1206
+ }),
1207
+ Ee({
1208
+ allowEnclosingBrackets: !1,
1209
+ allowPostfix: !1
1210
+ }),
1211
+ I({
1212
+ allowedAdditionalTokens: ["event", "external", "in"]
1213
+ }),
1214
+ ee({
1215
+ allowedTypes: ["module"],
1216
+ pathGrammar: V
1217
+ }),
1218
+ We,
1219
+ zt,
1220
+ Z({
1221
+ allowSquareBracketsOnAnyType: !0,
1222
+ allowJsdocNamePaths: !1,
1223
+ pathGrammar: V
1224
+ }),
1225
+ Xt,
1226
+ Ht,
1227
+ De({
1228
+ allowVariadic: !0,
1229
+ allowOptional: !0
1230
+ })
1231
+ ];
1232
+ function Xe(e, t) {
1233
+ switch (t) {
1234
+ case "closure":
1235
+ return new R($t, e).parse();
1236
+ case "jsdoc":
1237
+ return new R(Mt, e).parse();
1238
+ case "typescript":
1239
+ return new R(er, e).parse();
1240
+ }
1241
+ }
1242
+ r(Xe, "parse");
1243
+ function tr(e, t = ["typescript", "closure", "jsdoc"]) {
1244
+ let o;
1245
+ for (let i of t)
1246
+ try {
1247
+ return Xe(e, i);
1248
+ } catch (l) {
1249
+ o = l;
1250
+ }
1251
+ throw o;
1252
+ }
1253
+ r(tr, "tryParse");
1254
+ function W(e, t) {
1255
+ let o = e[t.type];
1256
+ if (o === void 0)
1257
+ throw new Error(`In this set of transform rules exists no rule for type ${t.type}.`);
1258
+ return o(t, (i) => W(e, i));
1259
+ }
1260
+ r(W, "transform");
1261
+ function D(e) {
1262
+ throw new Error("This transform is not available. Are you trying the correct parsing mode?");
1263
+ }
1264
+ r(D, "notAvailableTransform");
1265
+ function He(e) {
1266
+ let t = {
1267
+ params: []
1268
+ };
1269
+ for (let o of e.parameters)
1270
+ o.type === "JsdocTypeKeyValue" ? o.key === "this" ? t.this = o.right : o.key === "new" ? t.new = o.right : t.params.push(o) : t.params.
1271
+ push(o);
1272
+ return t;
1273
+ }
1274
+ r(He, "extractSpecialParams");
1275
+ function te(e, t, o) {
1276
+ return e === "prefix" ? o + t : t + o;
1277
+ }
1278
+ r(te, "applyPosition");
1279
+ function F(e, t) {
1280
+ switch (t) {
1281
+ case "double":
1282
+ return `"${e}"`;
1283
+ case "single":
1284
+ return `'${e}'`;
1285
+ case void 0:
1286
+ return e;
1287
+ }
1288
+ }
1289
+ r(F, "quote");
1290
+ function Qe() {
1291
+ return {
1292
+ JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => `(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeParenthesis"),
1293
+ JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => `keyof ${t(e.element)}`, "JsdocTypeKeyof"),
1294
+ JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
1295
+ if (e.arrow) {
1296
+ if (e.returnType === void 0)
1297
+ throw new Error("Arrow function needs a return type.");
1298
+ let o = `(${e.parameters.map(t).join(", ")}) => ${t(e.returnType)}`;
1299
+ return e.constructor && (o = "new " + o), o;
1300
+ } else {
1301
+ let o = e.constructor ? "new" : "function";
1302
+ return e.parenthesis && (o += `(${e.parameters.map(t).join(", ")})`, e.returnType !== void 0 && (o += `: ${t(e.returnType)}`)), o;
1303
+ }
1304
+ }, "JsdocTypeFunction"),
1305
+ JsdocTypeName: /* @__PURE__ */ r((e) => e.value, "JsdocTypeName"),
1306
+ JsdocTypeTuple: /* @__PURE__ */ r((e, t) => `[${e.elements.map(t).join(", ")}]`, "JsdocTypeTuple"),
1307
+ JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => e.meta.position === void 0 ? "..." : te(e.meta.position, t(e.element), "..."), "Jsdoc\
1308
+ TypeVariadic"),
1309
+ JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
1310
+ let o = t(e.left), i = t(e.right);
1311
+ switch (e.pathType) {
1312
+ case "inner":
1313
+ return `${o}~${i}`;
1314
+ case "instance":
1315
+ return `${o}#${i}`;
1316
+ case "property":
1317
+ return `${o}.${i}`;
1318
+ case "property-brackets":
1319
+ return `${o}[${i}]`;
1320
+ }
1321
+ }, "JsdocTypeNamePath"),
1322
+ JsdocTypeStringValue: /* @__PURE__ */ r((e) => F(e.value, e.meta.quote), "JsdocTypeStringValue"),
1323
+ JsdocTypeAny: /* @__PURE__ */ r(() => "*", "JsdocTypeAny"),
1324
+ JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
1325
+ if (e.meta.brackets === "square") {
1326
+ let o = e.elements[0], i = t(o);
1327
+ return o.type === "JsdocTypeUnion" || o.type === "JsdocTypeIntersection" ? `(${i})[]` : `${i}[]`;
1328
+ } else
1329
+ return `${t(e.left)}${e.meta.dot ? "." : ""}<${e.elements.map(t).join(", ")}>`;
1330
+ }, "JsdocTypeGeneric"),
1331
+ JsdocTypeImport: /* @__PURE__ */ r((e, t) => `import(${t(e.element)})`, "JsdocTypeImport"),
1332
+ JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
1333
+ let o = "";
1334
+ return e.readonly && (o += "readonly "), typeof e.key == "string" ? o += F(e.key, e.meta.quote) : o += t(e.key), e.optional && (o +=
1335
+ "?"), e.right === void 0 ? o : o + `: ${t(e.right)}`;
1336
+ }, "JsdocTypeObjectField"),
1337
+ JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => `${t(e.left)}: ${t(e.right)}`, "JsdocTypeJsdocObjectField"),
1338
+ JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
1339
+ let o = e.key;
1340
+ return e.optional && (o += "?"), e.variadic && (o = "..." + o), e.right === void 0 ? o : o + `: ${t(e.right)}`;
1341
+ }, "JsdocTypeKeyValue"),
1342
+ JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => `${e.specialType}:${F(e.value, e.meta.quote)}`, "JsdocTypeSpecialNamePath"),
1343
+ JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => te(e.meta.position, t(e.element), "!"), "JsdocTypeNotNullable"),
1344
+ JsdocTypeNull: /* @__PURE__ */ r(() => "null", "JsdocTypeNull"),
1345
+ JsdocTypeNullable: /* @__PURE__ */ r((e, t) => te(e.meta.position, t(e.element), "?"), "JsdocTypeNullable"),
1346
+ JsdocTypeNumber: /* @__PURE__ */ r((e) => e.value.toString(), "JsdocTypeNumber"),
1347
+ JsdocTypeObject: /* @__PURE__ */ r((e, t) => `{${e.elements.map(t).join((e.meta.separator === "comma" ? "," : ";") + " ")}}`, "Jsdoc\
1348
+ TypeObject"),
1349
+ JsdocTypeOptional: /* @__PURE__ */ r((e, t) => te(e.meta.position, t(e.element), "="), "JsdocTypeOptional"),
1350
+ JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => `${e.value}(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeSymbol"),
1351
+ JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => `typeof ${t(e.element)}`, "JsdocTypeTypeof"),
1352
+ JsdocTypeUndefined: /* @__PURE__ */ r(() => "undefined", "JsdocTypeUndefined"),
1353
+ JsdocTypeUnion: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" | "), "JsdocTypeUnion"),
1354
+ JsdocTypeUnknown: /* @__PURE__ */ r(() => "?", "JsdocTypeUnknown"),
1355
+ JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" & "), "JsdocTypeIntersection"),
1356
+ JsdocTypeProperty: /* @__PURE__ */ r((e) => F(e.value, e.meta.quote), "JsdocTypeProperty"),
1357
+ JsdocTypePredicate: /* @__PURE__ */ r((e, t) => `${t(e.left)} is ${t(e.right)}`, "JsdocTypePredicate"),
1358
+ JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => `[${e.key}: ${t(e.right)}]`, "JsdocTypeIndexSignature"),
1359
+ JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => `[${e.key} in ${t(e.right)}]`, "JsdocTypeMappedType")
1360
+ };
1361
+ }
1362
+ r(Qe, "stringifyRules");
1363
+ let rr = Qe();
1364
+ function nr(e) {
1365
+ return W(rr, e);
1366
+ }
1367
+ r(nr, "stringify");
1368
+ let or = [
1369
+ "null",
1370
+ "true",
1371
+ "false",
1372
+ "break",
1373
+ "case",
1374
+ "catch",
1375
+ "class",
1376
+ "const",
1377
+ "continue",
1378
+ "debugger",
1379
+ "default",
1380
+ "delete",
1381
+ "do",
1382
+ "else",
1383
+ "export",
1384
+ "extends",
1385
+ "finally",
1386
+ "for",
1387
+ "function",
1388
+ "if",
1389
+ "import",
1390
+ "in",
1391
+ "instanceof",
1392
+ "new",
1393
+ "return",
1394
+ "super",
1395
+ "switch",
1396
+ "this",
1397
+ "throw",
1398
+ "try",
1399
+ "typeof",
1400
+ "var",
1401
+ "void",
1402
+ "while",
1403
+ "with",
1404
+ "yield"
1405
+ ];
1406
+ function j(e) {
1407
+ let t = {
1408
+ type: "NameExpression",
1409
+ name: e
1410
+ };
1411
+ return or.includes(e) && (t.reservedWord = !0), t;
1412
+ }
1413
+ r(j, "makeName");
1414
+ let sr = {
1415
+ JsdocTypeOptional: /* @__PURE__ */ r((e, t) => {
1416
+ let o = t(e.element);
1417
+ return o.optional = !0, o;
1418
+ }, "JsdocTypeOptional"),
1419
+ JsdocTypeNullable: /* @__PURE__ */ r((e, t) => {
1420
+ let o = t(e.element);
1421
+ return o.nullable = !0, o;
1422
+ }, "JsdocTypeNullable"),
1423
+ JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => {
1424
+ let o = t(e.element);
1425
+ return o.nullable = !1, o;
1426
+ }, "JsdocTypeNotNullable"),
1427
+ JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
1428
+ if (e.element === void 0)
1429
+ throw new Error("dots without value are not allowed in catharsis mode");
1430
+ let o = t(e.element);
1431
+ return o.repeatable = !0, o;
1432
+ }, "JsdocTypeVariadic"),
1433
+ JsdocTypeAny: /* @__PURE__ */ r(() => ({
1434
+ type: "AllLiteral"
1435
+ }), "JsdocTypeAny"),
1436
+ JsdocTypeNull: /* @__PURE__ */ r(() => ({
1437
+ type: "NullLiteral"
1438
+ }), "JsdocTypeNull"),
1439
+ JsdocTypeStringValue: /* @__PURE__ */ r((e) => j(F(e.value, e.meta.quote)), "JsdocTypeStringValue"),
1440
+ JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
1441
+ type: "UndefinedLiteral"
1442
+ }), "JsdocTypeUndefined"),
1443
+ JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
1444
+ type: "UnknownLiteral"
1445
+ }), "JsdocTypeUnknown"),
1446
+ JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
1447
+ let o = He(e), i = {
1448
+ type: "FunctionType",
1449
+ params: o.params.map(t)
1450
+ };
1451
+ return o.this !== void 0 && (i.this = t(o.this)), o.new !== void 0 && (i.new = t(o.new)), e.returnType !== void 0 && (i.result = t(e.
1452
+ returnType)), i;
1453
+ }, "JsdocTypeFunction"),
1454
+ JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
1455
+ type: "TypeApplication",
1456
+ applications: e.elements.map((o) => t(o)),
1457
+ expression: t(e.left)
1458
+ }), "JsdocTypeGeneric"),
1459
+ JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => j(e.specialType + ":" + F(e.value, e.meta.quote)), "JsdocTypeSpecialNamePath"),
1460
+ JsdocTypeName: /* @__PURE__ */ r((e) => e.value !== "function" ? j(e.value) : {
1461
+ type: "FunctionType",
1462
+ params: []
1463
+ }, "JsdocTypeName"),
1464
+ JsdocTypeNumber: /* @__PURE__ */ r((e) => j(e.value.toString()), "JsdocTypeNumber"),
1465
+ JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
1466
+ let o = {
1467
+ type: "RecordType",
1468
+ fields: []
1469
+ };
1470
+ for (let i of e.elements)
1471
+ i.type !== "JsdocTypeObjectField" && i.type !== "JsdocTypeJsdocObjectField" ? o.fields.push({
1472
+ type: "FieldType",
1473
+ key: t(i),
1474
+ value: void 0
1475
+ }) : o.fields.push(t(i));
1476
+ return o;
1477
+ }, "JsdocTypeObject"),
1478
+ JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
1479
+ if (typeof e.key != "string")
1480
+ throw new Error("Index signatures and mapped types are not supported");
1481
+ return {
1482
+ type: "FieldType",
1483
+ key: j(F(e.key, e.meta.quote)),
1484
+ value: e.right === void 0 ? void 0 : t(e.right)
1485
+ };
1486
+ }, "JsdocTypeObjectField"),
1487
+ JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
1488
+ type: "FieldType",
1489
+ key: t(e.left),
1490
+ value: t(e.right)
1491
+ }), "JsdocTypeJsdocObjectField"),
1492
+ JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
1493
+ type: "TypeUnion",
1494
+ elements: e.elements.map((o) => t(o))
1495
+ }), "JsdocTypeUnion"),
1496
+ JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
1497
+ type: "FieldType",
1498
+ key: j(e.key),
1499
+ value: e.right === void 0 ? void 0 : t(e.right)
1500
+ }), "JsdocTypeKeyValue"),
1501
+ JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
1502
+ let o = t(e.left), i;
1503
+ e.right.type === "JsdocTypeSpecialNamePath" ? i = t(e.right).name : i = F(e.right.value, e.right.meta.quote);
1504
+ let l = e.pathType === "inner" ? "~" : e.pathType === "instance" ? "#" : ".";
1505
+ return j(`${o.name}${l}${i}`);
1506
+ }, "JsdocTypeNamePath"),
1507
+ JsdocTypeSymbol: /* @__PURE__ */ r((e) => {
1508
+ let t = "", o = e.element, i = !1;
1509
+ return o?.type === "JsdocTypeVariadic" && (o.meta.position === "prefix" ? t = "..." : i = !0, o = o.element), o?.type === "JsdocType\
1510
+ Name" ? t += o.value : o?.type === "JsdocTypeNumber" && (t += o.value.toString()), i && (t += "..."), j(`${e.value}(${t})`);
1511
+ }, "JsdocTypeSymbol"),
1512
+ JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => t(w(e.element)), "JsdocTypeParenthesis"),
1513
+ JsdocTypeMappedType: D,
1514
+ JsdocTypeIndexSignature: D,
1515
+ JsdocTypeImport: D,
1516
+ JsdocTypeKeyof: D,
1517
+ JsdocTypeTuple: D,
1518
+ JsdocTypeTypeof: D,
1519
+ JsdocTypeIntersection: D,
1520
+ JsdocTypeProperty: D,
1521
+ JsdocTypePredicate: D
1522
+ };
1523
+ function ar(e) {
1524
+ return W(sr, e);
1525
+ }
1526
+ r(ar, "catharsisTransform");
1527
+ function _(e) {
1528
+ switch (e) {
1529
+ case void 0:
1530
+ return "none";
1531
+ case "single":
1532
+ return "single";
1533
+ case "double":
1534
+ return "double";
1535
+ }
1536
+ }
1537
+ r(_, "getQuoteStyle");
1538
+ function ir(e) {
1539
+ switch (e) {
1540
+ case "inner":
1541
+ return "INNER_MEMBER";
1542
+ case "instance":
1543
+ return "INSTANCE_MEMBER";
1544
+ case "property":
1545
+ return "MEMBER";
1546
+ case "property-brackets":
1547
+ return "MEMBER";
1548
+ }
1549
+ }
1550
+ r(ir, "getMemberType");
1551
+ function Oe(e, t) {
1552
+ return t.length === 2 ? {
1553
+ type: e,
1554
+ left: t[0],
1555
+ right: t[1]
1556
+ } : {
1557
+ type: e,
1558
+ left: t[0],
1559
+ right: Oe(e, t.slice(1))
1560
+ };
1561
+ }
1562
+ r(Oe, "nestResults");
1563
+ let pr = {
1564
+ JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
1565
+ type: "OPTIONAL",
1566
+ value: t(e.element),
1567
+ meta: {
1568
+ syntax: e.meta.position === "prefix" ? "PREFIX_EQUAL_SIGN" : "SUFFIX_EQUALS_SIGN"
1569
+ }
1570
+ }), "JsdocTypeOptional"),
1571
+ JsdocTypeNullable: /* @__PURE__ */ r((e, t) => ({
1572
+ type: "NULLABLE",
1573
+ value: t(e.element),
1574
+ meta: {
1575
+ syntax: e.meta.position === "prefix" ? "PREFIX_QUESTION_MARK" : "SUFFIX_QUESTION_MARK"
1576
+ }
1577
+ }), "JsdocTypeNullable"),
1578
+ JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
1579
+ type: "NOT_NULLABLE",
1580
+ value: t(e.element),
1581
+ meta: {
1582
+ syntax: e.meta.position === "prefix" ? "PREFIX_BANG" : "SUFFIX_BANG"
1583
+ }
1584
+ }), "JsdocTypeNotNullable"),
1585
+ JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
1586
+ let o = {
1587
+ type: "VARIADIC",
1588
+ meta: {
1589
+ syntax: e.meta.position === "prefix" ? "PREFIX_DOTS" : e.meta.position === "suffix" ? "SUFFIX_DOTS" : "ONLY_DOTS"
1590
+ }
1591
+ };
1592
+ return e.element !== void 0 && (o.value = t(e.element)), o;
1593
+ }, "JsdocTypeVariadic"),
1594
+ JsdocTypeName: /* @__PURE__ */ r((e) => ({
1595
+ type: "NAME",
1596
+ name: e.value
1597
+ }), "JsdocTypeName"),
1598
+ JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
1599
+ type: "TYPE_QUERY",
1600
+ name: t(e.element)
1601
+ }), "JsdocTypeTypeof"),
1602
+ JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
1603
+ type: "TUPLE",
1604
+ entries: e.elements.map(t)
1605
+ }), "JsdocTypeTuple"),
1606
+ JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
1607
+ type: "KEY_QUERY",
1608
+ value: t(e.element)
1609
+ }), "JsdocTypeKeyof"),
1610
+ JsdocTypeImport: /* @__PURE__ */ r((e) => ({
1611
+ type: "IMPORT",
1612
+ path: {
1613
+ type: "STRING_VALUE",
1614
+ quoteStyle: _(e.element.meta.quote),
1615
+ string: e.element.value
1616
+ }
1617
+ }), "JsdocTypeImport"),
1618
+ JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
1619
+ type: "NAME",
1620
+ name: "undefined"
1621
+ }), "JsdocTypeUndefined"),
1622
+ JsdocTypeAny: /* @__PURE__ */ r(() => ({
1623
+ type: "ANY"
1624
+ }), "JsdocTypeAny"),
1625
+ JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
1626
+ let o = He(e), i = {
1627
+ type: e.arrow ? "ARROW" : "FUNCTION",
1628
+ params: o.params.map((l) => {
1629
+ if (l.type === "JsdocTypeKeyValue") {
1630
+ if (l.right === void 0)
1631
+ throw new Error("Function parameter without ':' is not expected to be 'KEY_VALUE'");
1632
+ return {
1633
+ type: "NAMED_PARAMETER",
1634
+ name: l.key,
1635
+ typeName: t(l.right)
1636
+ };
1637
+ } else
1638
+ return t(l);
1639
+ }),
1640
+ new: null,
1641
+ returns: null
1642
+ };
1643
+ return o.this !== void 0 ? i.this = t(o.this) : e.arrow || (i.this = null), o.new !== void 0 && (i.new = t(o.new)), e.returnType !==
1644
+ void 0 && (i.returns = t(e.returnType)), i;
1645
+ }, "JsdocTypeFunction"),
1646
+ JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
1647
+ let o = {
1648
+ type: "GENERIC",
1649
+ subject: t(e.left),
1650
+ objects: e.elements.map(t),
1651
+ meta: {
1652
+ syntax: e.meta.brackets === "square" ? "SQUARE_BRACKET" : e.meta.dot ? "ANGLE_BRACKET_WITH_DOT" : "ANGLE_BRACKET"
1653
+ }
1654
+ };
1655
+ return e.meta.brackets === "square" && e.elements[0].type === "JsdocTypeFunction" && !e.elements[0].parenthesis && (o.objects[0] = {
1656
+ type: "NAME",
1657
+ name: "function"
1658
+ }), o;
1659
+ }, "JsdocTypeGeneric"),
1660
+ JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
1661
+ if (typeof e.key != "string")
1662
+ throw new Error("Index signatures and mapped types are not supported");
1663
+ if (e.right === void 0)
1664
+ return {
1665
+ type: "RECORD_ENTRY",
1666
+ key: e.key,
1667
+ quoteStyle: _(e.meta.quote),
1668
+ value: null,
1669
+ readonly: !1
1670
+ };
1671
+ let o = t(e.right);
1672
+ return e.optional && (o = {
1673
+ type: "OPTIONAL",
1674
+ value: o,
1675
+ meta: {
1676
+ syntax: "SUFFIX_KEY_QUESTION_MARK"
1677
+ }
1678
+ }), {
1679
+ type: "RECORD_ENTRY",
1680
+ key: e.key.toString(),
1681
+ quoteStyle: _(e.meta.quote),
1682
+ value: o,
1683
+ readonly: !1
1684
+ };
1685
+ }, "JsdocTypeObjectField"),
1686
+ JsdocTypeJsdocObjectField: /* @__PURE__ */ r(() => {
1687
+ throw new Error("Keys may not be typed in jsdoctypeparser.");
1688
+ }, "JsdocTypeJsdocObjectField"),
1689
+ JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
1690
+ if (e.right === void 0)
1691
+ return {
1692
+ type: "RECORD_ENTRY",
1693
+ key: e.key,
1694
+ quoteStyle: "none",
1695
+ value: null,
1696
+ readonly: !1
1697
+ };
1698
+ let o = t(e.right);
1699
+ return e.optional && (o = {
1700
+ type: "OPTIONAL",
1701
+ value: o,
1702
+ meta: {
1703
+ syntax: "SUFFIX_KEY_QUESTION_MARK"
1704
+ }
1705
+ }), {
1706
+ type: "RECORD_ENTRY",
1707
+ key: e.key,
1708
+ quoteStyle: "none",
1709
+ value: o,
1710
+ readonly: !1
1711
+ };
1712
+ }, "JsdocTypeKeyValue"),
1713
+ JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
1714
+ let o = [];
1715
+ for (let i of e.elements)
1716
+ (i.type === "JsdocTypeObjectField" || i.type === "JsdocTypeJsdocObjectField") && o.push(t(i));
1717
+ return {
1718
+ type: "RECORD",
1719
+ entries: o
1720
+ };
1721
+ }, "JsdocTypeObject"),
1722
+ JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => {
1723
+ if (e.specialType !== "module")
1724
+ throw new Error(`jsdoctypeparser does not support type ${e.specialType} at this point.`);
1725
+ return {
1726
+ type: "MODULE",
1727
+ value: {
1728
+ type: "FILE_PATH",
1729
+ quoteStyle: _(e.meta.quote),
1730
+ path: e.value
1731
+ }
1732
+ };
1733
+ }, "JsdocTypeSpecialNamePath"),
1734
+ JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
1735
+ let o = !1, i, l;
1736
+ e.right.type === "JsdocTypeSpecialNamePath" && e.right.specialType === "event" ? (o = !0, i = e.right.value, l = _(e.right.meta.quote)) :
1737
+ (i = e.right.value, l = _(e.right.meta.quote));
1738
+ let m = {
1739
+ type: ir(e.pathType),
1740
+ owner: t(e.left),
1741
+ name: i,
1742
+ quoteStyle: l,
1743
+ hasEventPrefix: o
1744
+ };
1745
+ if (m.owner.type === "MODULE") {
1746
+ let d = m.owner;
1747
+ return m.owner = m.owner.value, d.value = m, d;
1748
+ } else
1749
+ return m;
1750
+ }, "JsdocTypeNamePath"),
1751
+ JsdocTypeUnion: /* @__PURE__ */ r((e, t) => Oe("UNION", e.elements.map(t)), "JsdocTypeUnion"),
1752
+ JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
1753
+ type: "PARENTHESIS",
1754
+ value: t(w(e.element))
1755
+ }), "JsdocTypeParenthesis"),
1756
+ JsdocTypeNull: /* @__PURE__ */ r(() => ({
1757
+ type: "NAME",
1758
+ name: "null"
1759
+ }), "JsdocTypeNull"),
1760
+ JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
1761
+ type: "UNKNOWN"
1762
+ }), "JsdocTypeUnknown"),
1763
+ JsdocTypeStringValue: /* @__PURE__ */ r((e) => ({
1764
+ type: "STRING_VALUE",
1765
+ quoteStyle: _(e.meta.quote),
1766
+ string: e.value
1767
+ }), "JsdocTypeStringValue"),
1768
+ JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => Oe("INTERSECTION", e.elements.map(t)), "JsdocTypeIntersection"),
1769
+ JsdocTypeNumber: /* @__PURE__ */ r((e) => ({
1770
+ type: "NUMBER_VALUE",
1771
+ number: e.value.toString()
1772
+ }), "JsdocTypeNumber"),
1773
+ JsdocTypeSymbol: D,
1774
+ JsdocTypeProperty: D,
1775
+ JsdocTypePredicate: D,
1776
+ JsdocTypeMappedType: D,
1777
+ JsdocTypeIndexSignature: D
1778
+ };
1779
+ function cr(e) {
1780
+ return W(pr, e);
1781
+ }
1782
+ r(cr, "jtpTransform");
1783
+ function lr() {
1784
+ return {
1785
+ JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => ({
1786
+ type: "JsdocTypeIntersection",
1787
+ elements: e.elements.map(t)
1788
+ }), "JsdocTypeIntersection"),
1789
+ JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
1790
+ type: "JsdocTypeGeneric",
1791
+ left: t(e.left),
1792
+ elements: e.elements.map(t),
1793
+ meta: {
1794
+ dot: e.meta.dot,
1795
+ brackets: e.meta.brackets
1796
+ }
1797
+ }), "JsdocTypeGeneric"),
1798
+ JsdocTypeNullable: /* @__PURE__ */ r((e) => e, "JsdocTypeNullable"),
1799
+ JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
1800
+ type: "JsdocTypeUnion",
1801
+ elements: e.elements.map(t)
1802
+ }), "JsdocTypeUnion"),
1803
+ JsdocTypeUnknown: /* @__PURE__ */ r((e) => e, "JsdocTypeUnknown"),
1804
+ JsdocTypeUndefined: /* @__PURE__ */ r((e) => e, "JsdocTypeUndefined"),
1805
+ JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
1806
+ type: "JsdocTypeTypeof",
1807
+ element: t(e.element)
1808
+ }), "JsdocTypeTypeof"),
1809
+ JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => {
1810
+ let o = {
1811
+ type: "JsdocTypeSymbol",
1812
+ value: e.value
1813
+ };
1814
+ return e.element !== void 0 && (o.element = t(e.element)), o;
1815
+ }, "JsdocTypeSymbol"),
1816
+ JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
1817
+ type: "JsdocTypeOptional",
1818
+ element: t(e.element),
1819
+ meta: {
1820
+ position: e.meta.position
1821
+ }
1822
+ }), "JsdocTypeOptional"),
1823
+ JsdocTypeObject: /* @__PURE__ */ r((e, t) => ({
1824
+ type: "JsdocTypeObject",
1825
+ meta: {
1826
+ separator: "comma"
1827
+ },
1828
+ elements: e.elements.map(t)
1829
+ }), "JsdocTypeObject"),
1830
+ JsdocTypeNumber: /* @__PURE__ */ r((e) => e, "JsdocTypeNumber"),
1831
+ JsdocTypeNull: /* @__PURE__ */ r((e) => e, "JsdocTypeNull"),
1832
+ JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
1833
+ type: "JsdocTypeNotNullable",
1834
+ element: t(e.element),
1835
+ meta: {
1836
+ position: e.meta.position
1837
+ }
1838
+ }), "JsdocTypeNotNullable"),
1839
+ JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeSpecialNamePath"),
1840
+ JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => ({
1841
+ type: "JsdocTypeObjectField",
1842
+ key: e.key,
1843
+ right: e.right === void 0 ? void 0 : t(e.right),
1844
+ optional: e.optional,
1845
+ readonly: e.readonly,
1846
+ meta: e.meta
1847
+ }), "JsdocTypeObjectField"),
1848
+ JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
1849
+ type: "JsdocTypeJsdocObjectField",
1850
+ left: t(e.left),
1851
+ right: t(e.right)
1852
+ }), "JsdocTypeJsdocObjectField"),
1853
+ JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
1854
+ type: "JsdocTypeKeyValue",
1855
+ key: e.key,
1856
+ right: e.right === void 0 ? void 0 : t(e.right),
1857
+ optional: e.optional,
1858
+ variadic: e.variadic
1859
+ }), "JsdocTypeKeyValue"),
1860
+ JsdocTypeImport: /* @__PURE__ */ r((e, t) => ({
1861
+ type: "JsdocTypeImport",
1862
+ element: t(e.element)
1863
+ }), "JsdocTypeImport"),
1864
+ JsdocTypeAny: /* @__PURE__ */ r((e) => e, "JsdocTypeAny"),
1865
+ JsdocTypeStringValue: /* @__PURE__ */ r((e) => e, "JsdocTypeStringValue"),
1866
+ JsdocTypeNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeNamePath"),
1867
+ JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
1868
+ let o = {
1869
+ type: "JsdocTypeVariadic",
1870
+ meta: {
1871
+ position: e.meta.position,
1872
+ squareBrackets: e.meta.squareBrackets
1873
+ }
1874
+ };
1875
+ return e.element !== void 0 && (o.element = t(e.element)), o;
1876
+ }, "JsdocTypeVariadic"),
1877
+ JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
1878
+ type: "JsdocTypeTuple",
1879
+ elements: e.elements.map(t)
1880
+ }), "JsdocTypeTuple"),
1881
+ JsdocTypeName: /* @__PURE__ */ r((e) => e, "JsdocTypeName"),
1882
+ JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
1883
+ let o = {
1884
+ type: "JsdocTypeFunction",
1885
+ arrow: e.arrow,
1886
+ parameters: e.parameters.map(t),
1887
+ constructor: e.constructor,
1888
+ parenthesis: e.parenthesis
1889
+ };
1890
+ return e.returnType !== void 0 && (o.returnType = t(e.returnType)), o;
1891
+ }, "JsdocTypeFunction"),
1892
+ JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
1893
+ type: "JsdocTypeKeyof",
1894
+ element: t(e.element)
1895
+ }), "JsdocTypeKeyof"),
1896
+ JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
1897
+ type: "JsdocTypeParenthesis",
1898
+ element: t(e.element)
1899
+ }), "JsdocTypeParenthesis"),
1900
+ JsdocTypeProperty: /* @__PURE__ */ r((e) => e, "JsdocTypeProperty"),
1901
+ JsdocTypePredicate: /* @__PURE__ */ r((e, t) => ({
1902
+ type: "JsdocTypePredicate",
1903
+ left: t(e.left),
1904
+ right: t(e.right)
1905
+ }), "JsdocTypePredicate"),
1906
+ JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => ({
1907
+ type: "JsdocTypeIndexSignature",
1908
+ key: e.key,
1909
+ right: t(e.right)
1910
+ }), "JsdocTypeIndexSignature"),
1911
+ JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => ({
1912
+ type: "JsdocTypeMappedType",
1913
+ key: e.key,
1914
+ right: t(e.right)
1915
+ }), "JsdocTypeMappedType")
1916
+ };
1917
+ }
1918
+ r(lr, "identityTransformRules");
1919
+ let Ze = {
1920
+ JsdocTypeAny: [],
1921
+ JsdocTypeFunction: ["parameters", "returnType"],
1922
+ JsdocTypeGeneric: ["left", "elements"],
1923
+ JsdocTypeImport: [],
1924
+ JsdocTypeIndexSignature: ["right"],
1925
+ JsdocTypeIntersection: ["elements"],
1926
+ JsdocTypeKeyof: ["element"],
1927
+ JsdocTypeKeyValue: ["right"],
1928
+ JsdocTypeMappedType: ["right"],
1929
+ JsdocTypeName: [],
1930
+ JsdocTypeNamePath: ["left", "right"],
1931
+ JsdocTypeNotNullable: ["element"],
1932
+ JsdocTypeNull: [],
1933
+ JsdocTypeNullable: ["element"],
1934
+ JsdocTypeNumber: [],
1935
+ JsdocTypeObject: ["elements"],
1936
+ JsdocTypeObjectField: ["right"],
1937
+ JsdocTypeJsdocObjectField: ["left", "right"],
1938
+ JsdocTypeOptional: ["element"],
1939
+ JsdocTypeParenthesis: ["element"],
1940
+ JsdocTypeSpecialNamePath: [],
1941
+ JsdocTypeStringValue: [],
1942
+ JsdocTypeSymbol: ["element"],
1943
+ JsdocTypeTuple: ["elements"],
1944
+ JsdocTypeTypeof: ["element"],
1945
+ JsdocTypeUndefined: [],
1946
+ JsdocTypeUnion: ["elements"],
1947
+ JsdocTypeUnknown: [],
1948
+ JsdocTypeVariadic: ["element"],
1949
+ JsdocTypeProperty: [],
1950
+ JsdocTypePredicate: ["left", "right"]
1951
+ };
1952
+ function ve(e, t, o, i, l) {
1953
+ i?.(e, t, o);
1954
+ let m = Ze[e.type];
1955
+ for (let d of m) {
1956
+ let x = e[d];
1957
+ if (x !== void 0)
1958
+ if (Array.isArray(x))
1959
+ for (let N of x)
1960
+ ve(N, e, d, i, l);
1961
+ else
1962
+ ve(x, e, d, i, l);
1963
+ }
1964
+ l?.(e, t, o);
1965
+ }
1966
+ r(ve, "_traverse");
1967
+ function ur(e, t, o) {
1968
+ ve(e, void 0, void 0, t, o);
1969
+ }
1970
+ r(ur, "traverse"), n.catharsisTransform = ar, n.identityTransformRules = lr, n.jtpTransform = cr, n.parse = Xe, n.stringify = nr, n.stringifyRules =
1971
+ Qe, n.transform = W, n.traverse = ur, n.tryParse = tr, n.visitorKeys = Ze;
1972
+ });
1973
+ });
1974
+
1975
+ // src/docs-tools/argTypes/convert/flow/convert.ts
1976
+ import { UnknownArgTypesError as Jr } from "storybook/internal/preview-errors";
1977
+ var wr = /* @__PURE__ */ r((n) => n.name === "literal", "isLiteral"), Pr = /* @__PURE__ */ r((n) => n.value.replace(/['|"]/g, ""), "toEnumOp\
1978
+ tion"), br = /* @__PURE__ */ r((n) => {
1979
+ switch (n.type) {
1980
+ case "function":
1981
+ return { name: "function" };
1982
+ case "object":
1983
+ let s = {};
1984
+ return n.signature.properties.forEach((a) => {
1985
+ s[a.key] = B(a.value);
1986
+ }), {
1987
+ name: "object",
1988
+ value: s
1989
+ };
1990
+ default:
1991
+ throw new Jr({ type: n, language: "Flow" });
1992
+ }
1993
+ }, "convertSig"), B = /* @__PURE__ */ r((n) => {
1994
+ let { name: s, raw: a } = n, p = {};
1995
+ switch (typeof a < "u" && (p.raw = a), n.name) {
1996
+ case "literal":
1997
+ return { ...p, name: "other", value: n.value };
1998
+ case "string":
1999
+ case "number":
2000
+ case "symbol":
2001
+ case "boolean":
2002
+ return { ...p, name: s };
2003
+ case "Array":
2004
+ return { ...p, name: "array", value: n.elements.map(B) };
2005
+ case "signature":
2006
+ return { ...p, ...br(n) };
2007
+ case "union":
2008
+ return n.elements?.every(wr) ? { ...p, name: "enum", value: n.elements?.map(Pr) } : { ...p, name: s, value: n.elements?.map(B) };
2009
+ case "intersection":
2010
+ return { ...p, name: s, value: n.elements?.map(B) };
2011
+ default:
2012
+ return { ...p, name: "other", value: s };
2013
+ }
2014
+ }, "convert");
2015
+
2016
+ // ../node_modules/es-toolkit/dist/object/mapValues.mjs
2017
+ function Re(n, s) {
2018
+ let a = {}, p = Object.keys(n);
2019
+ for (let c = 0; c < p.length; c++) {
2020
+ let u = p[c], y = n[u];
2021
+ a[u] = s(y, u, n);
2022
+ }
2023
+ return a;
2024
+ }
2025
+ r(Re, "mapValues");
2026
+
2027
+ // src/docs-tools/argTypes/convert/utils.ts
2028
+ var rt = /^['"]|['"]$/g, Er = /* @__PURE__ */ r((n) => n.replace(rt, ""), "trimQuotes"), Sr = /* @__PURE__ */ r((n) => rt.test(n), "includes\
2029
+ Quotes"), ae = /* @__PURE__ */ r((n) => {
2030
+ let s = Er(n);
2031
+ return Sr(n) || Number.isNaN(Number(s)) ? s : Number(s);
2032
+ }, "parseLiteral");
2033
+
2034
+ // src/docs-tools/argTypes/convert/proptypes/convert.ts
2035
+ var Nr = /^\(.*\) => /, C = /* @__PURE__ */ r((n) => {
2036
+ let { name: s, raw: a, computed: p, value: c } = n, u = {};
2037
+ switch (typeof a < "u" && (u.raw = a), s) {
2038
+ case "enum": {
2039
+ let T = p ? c : c.map((g) => ae(g.value));
2040
+ return { ...u, name: s, value: T };
2041
+ }
2042
+ case "string":
2043
+ case "number":
2044
+ case "symbol":
2045
+ return { ...u, name: s };
2046
+ case "func":
2047
+ return { ...u, name: "function" };
2048
+ case "bool":
2049
+ case "boolean":
2050
+ return { ...u, name: "boolean" };
2051
+ case "arrayOf":
2052
+ case "array":
2053
+ return { ...u, name: "array", value: c && C(c) };
2054
+ case "object":
2055
+ return { ...u, name: s };
2056
+ case "objectOf":
2057
+ return { ...u, name: s, value: C(c) };
2058
+ case "shape":
2059
+ case "exact":
2060
+ let y = Re(c, (T) => C(T));
2061
+ return { ...u, name: "object", value: y };
2062
+ case "union":
2063
+ return { ...u, name: "union", value: c.map((T) => C(T)) };
2064
+ case "instanceOf":
2065
+ case "element":
2066
+ case "elementType":
2067
+ default: {
2068
+ if (s?.indexOf("|") > 0)
2069
+ try {
2070
+ let P = s.split("|").map((b) => JSON.parse(b));
2071
+ return { ...u, name: "enum", value: P };
2072
+ } catch {
2073
+ }
2074
+ let T = c ? `${s}(${c})` : s, g = Nr.test(s) ? "function" : "other";
2075
+ return { ...u, name: g, value: T };
2076
+ }
2077
+ }
2078
+ }, "convert");
2079
+
2080
+ // src/docs-tools/argTypes/convert/typescript/convert.ts
2081
+ import { UnknownArgTypesError as Dr } from "storybook/internal/preview-errors";
2082
+ var Or = /* @__PURE__ */ r((n) => {
2083
+ switch (n.type) {
2084
+ case "function":
2085
+ return { name: "function" };
2086
+ case "object":
2087
+ let s = {};
2088
+ return n.signature.properties.forEach((a) => {
2089
+ s[a.key] = M(a.value);
2090
+ }), {
2091
+ name: "object",
2092
+ value: s
2093
+ };
2094
+ default:
2095
+ throw new Dr({ type: n, language: "Typescript" });
2096
+ }
2097
+ }, "convertSig"), M = /* @__PURE__ */ r((n) => {
2098
+ let { name: s, raw: a } = n, p = {};
2099
+ switch (typeof a < "u" && (p.raw = a), n.name) {
2100
+ case "string":
2101
+ case "number":
2102
+ case "symbol":
2103
+ case "boolean":
2104
+ return { ...p, name: s };
2105
+ case "Array":
2106
+ return { ...p, name: "array", value: n.elements.map(M) };
2107
+ case "signature":
2108
+ return { ...p, ...Or(n) };
2109
+ case "union":
2110
+ let c;
2111
+ return n.elements?.every((u) => u.name === "literal") ? c = {
2112
+ ...p,
2113
+ name: "enum",
2114
+ // @ts-expect-error fix types
2115
+ value: n.elements?.map((u) => ae(u.value))
2116
+ } : c = { ...p, name: s, value: n.elements?.map(M) }, c;
2117
+ case "intersection":
2118
+ return { ...p, name: s, value: n.elements?.map(M) };
2119
+ default:
2120
+ return { ...p, name: "other", value: s };
2121
+ }
2122
+ }, "convert");
2123
+
2124
+ // src/docs-tools/argTypes/convert/index.ts
2125
+ var ie = /* @__PURE__ */ r((n) => {
2126
+ let { type: s, tsType: a, flowType: p } = n;
2127
+ try {
2128
+ if (s != null)
2129
+ return C(s);
2130
+ if (a != null)
2131
+ return M(a);
2132
+ if (p != null)
2133
+ return B(p);
2134
+ } catch (c) {
2135
+ console.error(c);
2136
+ }
2137
+ return null;
2138
+ }, "convert");
2139
+
2140
+ // src/docs-tools/argTypes/docgen/types.ts
2141
+ var vr = /* @__PURE__ */ ((c) => (c.JAVASCRIPT = "JavaScript", c.FLOW = "Flow", c.TYPESCRIPT = "TypeScript", c.UNKNOWN = "Unknown", c))(vr ||
2142
+ {});
2143
+
2144
+ // src/docs-tools/argTypes/docgen/utils/defaultValue.ts
2145
+ var kr = ["null", "undefined"];
2146
+ function K(n) {
2147
+ return kr.some((s) => s === n);
2148
+ }
2149
+ r(K, "isDefaultValueBlacklisted");
2150
+
2151
+ // src/docs-tools/argTypes/docgen/utils/string.ts
2152
+ var nt = /* @__PURE__ */ r((n) => {
2153
+ if (!n)
2154
+ return "";
2155
+ if (typeof n == "string")
2156
+ return n;
2157
+ throw new Error(`Description: expected string, got: ${JSON.stringify(n)}`);
2158
+ }, "str");
2159
+
2160
+ // src/docs-tools/argTypes/docgen/utils/docgenInfo.ts
2161
+ function ot(n) {
2162
+ return !!n.__docgenInfo;
2163
+ }
2164
+ r(ot, "hasDocgen");
2165
+ function st(n) {
2166
+ return n != null && Object.keys(n).length > 0;
2167
+ }
2168
+ r(st, "isValidDocgenSection");
2169
+ function at(n, s) {
2170
+ return ot(n) ? n.__docgenInfo[s] : null;
2171
+ }
2172
+ r(at, "getDocgenSection");
2173
+ function it(n) {
2174
+ return ot(n) ? nt(n.__docgenInfo.description) : "";
2175
+ }
2176
+ r(it, "getDocgenDescription");
2177
+
2178
+ // ../node_modules/comment-parser/es6/primitives.js
2179
+ var v;
2180
+ (function(n) {
2181
+ n.start = "/**", n.nostart = "/***", n.delim = "*", n.end = "*/";
2182
+ })(v = v || (v = {}));
2183
+
2184
+ // ../node_modules/comment-parser/es6/util.js
2185
+ function Ie(n) {
2186
+ return /^\s+$/.test(n);
2187
+ }
2188
+ r(Ie, "isSpace");
2189
+ function pt(n) {
2190
+ let s = n.match(/\r+$/);
2191
+ return s == null ? ["", n] : [n.slice(-s[0].length), n.slice(0, -s[0].length)];
2192
+ }
2193
+ r(pt, "splitCR");
2194
+ function A(n) {
2195
+ let s = n.match(/^\s+/);
2196
+ return s == null ? ["", n] : [n.slice(0, s[0].length), n.slice(s[0].length)];
2197
+ }
2198
+ r(A, "splitSpace");
2199
+ function ct(n) {
2200
+ return n.split(/\n/);
2201
+ }
2202
+ r(ct, "splitLines");
2203
+ function lt(n = {}) {
2204
+ return Object.assign({ tag: "", name: "", type: "", optional: !1, description: "", problems: [], source: [] }, n);
2205
+ }
2206
+ r(lt, "seedSpec");
2207
+ function Fe(n = {}) {
2208
+ return Object.assign({ start: "", delimiter: "", postDelimiter: "", tag: "", postTag: "", name: "", postName: "", type: "", postType: "", description: "",
2209
+ end: "", lineEnd: "" }, n);
2210
+ }
2211
+ r(Fe, "seedTokens");
2212
+
2213
+ // ../node_modules/comment-parser/es6/parser/block-parser.js
2214
+ var Ar = /^@\S+/;
2215
+ function je({ fence: n = "```" } = {}) {
2216
+ let s = Rr(n), a = /* @__PURE__ */ r((p, c) => s(p) ? !c : c, "toggleFence");
2217
+ return /* @__PURE__ */ r(function(c) {
2218
+ let u = [[]], y = !1;
2219
+ for (let T of c)
2220
+ Ar.test(T.tokens.description) && !y ? u.push([T]) : u[u.length - 1].push(T), y = a(T.tokens.description, y);
2221
+ return u;
2222
+ }, "parseBlock");
2223
+ }
2224
+ r(je, "getParser");
2225
+ function Rr(n) {
2226
+ return typeof n == "string" ? (s) => s.split(n).length % 2 === 0 : n;
2227
+ }
2228
+ r(Rr, "getFencer");
2229
+
2230
+ // ../node_modules/comment-parser/es6/parser/source-parser.js
2231
+ function Le({ startLine: n = 0, markers: s = v } = {}) {
2232
+ let a = null, p = n;
2233
+ return /* @__PURE__ */ r(function(u) {
2234
+ let y = u, T = Fe();
2235
+ if ([T.lineEnd, y] = pt(y), [T.start, y] = A(y), a === null && y.startsWith(s.start) && !y.startsWith(s.nostart) && (a = [], T.delimiter =
2236
+ y.slice(0, s.start.length), y = y.slice(s.start.length), [T.postDelimiter, y] = A(y)), a === null)
2237
+ return p++, null;
2238
+ let g = y.trimRight().endsWith(s.end);
2239
+ if (T.delimiter === "" && y.startsWith(s.delim) && !y.startsWith(s.end) && (T.delimiter = s.delim, y = y.slice(s.delim.length), [T.postDelimiter,
2240
+ y] = A(y)), g) {
2241
+ let P = y.trimRight();
2242
+ T.end = y.slice(P.length - s.end.length), y = P.slice(0, -s.end.length);
2243
+ }
2244
+ if (T.description = y, a.push({ number: p, source: u, tokens: T }), p++, g) {
2245
+ let P = a.slice();
2246
+ return a = null, P;
2247
+ }
2248
+ return null;
2249
+ }, "parseSource");
2250
+ }
2251
+ r(Le, "getParser");
2252
+
2253
+ // ../node_modules/comment-parser/es6/parser/spec-parser.js
2254
+ function _e({ tokenizers: n }) {
2255
+ return /* @__PURE__ */ r(function(a) {
2256
+ var p;
2257
+ let c = lt({ source: a });
2258
+ for (let u of n)
2259
+ if (c = u(c), !((p = c.problems[c.problems.length - 1]) === null || p === void 0) && p.critical)
2260
+ break;
2261
+ return c;
2262
+ }, "parseSpec");
2263
+ }
2264
+ r(_e, "getParser");
2265
+
2266
+ // ../node_modules/comment-parser/es6/parser/tokenizers/tag.js
2267
+ function pe() {
2268
+ return (n) => {
2269
+ let { tokens: s } = n.source[0], a = s.description.match(/\s*(@(\S+))(\s*)/);
2270
+ return a === null ? (n.problems.push({
2271
+ code: "spec:tag:prefix",
2272
+ message: 'tag should start with "@" symbol',
2273
+ line: n.source[0].number,
2274
+ critical: !0
2275
+ }), n) : (s.tag = a[1], s.postTag = a[3], s.description = s.description.slice(a[0].length), n.tag = a[2], n);
2276
+ };
2277
+ }
2278
+ r(pe, "tagTokenizer");
2279
+
2280
+ // ../node_modules/comment-parser/es6/parser/tokenizers/type.js
2281
+ function ce(n = "compact") {
2282
+ let s = Fr(n);
2283
+ return (a) => {
2284
+ let p = 0, c = [];
2285
+ for (let [T, { tokens: g }] of a.source.entries()) {
2286
+ let P = "";
2287
+ if (T === 0 && g.description[0] !== "{")
2288
+ return a;
2289
+ for (let b of g.description)
2290
+ if (b === "{" && p++, b === "}" && p--, P += b, p === 0)
2291
+ break;
2292
+ if (c.push([g, P]), p === 0)
2293
+ break;
2294
+ }
2295
+ if (p !== 0)
2296
+ return a.problems.push({
2297
+ code: "spec:type:unpaired-curlies",
2298
+ message: "unpaired curlies",
2299
+ line: a.source[0].number,
2300
+ critical: !0
2301
+ }), a;
2302
+ let u = [], y = c[0][0].postDelimiter.length;
2303
+ for (let [T, [g, P]] of c.entries())
2304
+ g.type = P, T > 0 && (g.type = g.postDelimiter.slice(y) + P, g.postDelimiter = g.postDelimiter.slice(0, y)), [g.postType, g.description] =
2305
+ A(g.description.slice(P.length)), u.push(g.type);
2306
+ return u[0] = u[0].slice(1), u[u.length - 1] = u[u.length - 1].slice(0, -1), a.type = s(u), a;
2307
+ };
2308
+ }
2309
+ r(ce, "typeTokenizer");
2310
+ var Ir = /* @__PURE__ */ r((n) => n.trim(), "trim");
2311
+ function Fr(n) {
2312
+ return n === "compact" ? (s) => s.map(Ir).join("") : n === "preserve" ? (s) => s.join(`
2313
+ `) : n;
2314
+ }
2315
+ r(Fr, "getJoiner");
2316
+
2317
+ // ../node_modules/comment-parser/es6/parser/tokenizers/name.js
2318
+ var jr = /* @__PURE__ */ r((n) => n && n.startsWith('"') && n.endsWith('"'), "isQuoted");
2319
+ function le() {
2320
+ let n = /* @__PURE__ */ r((s, { tokens: a }, p) => a.type === "" ? s : p, "typeEnd");
2321
+ return (s) => {
2322
+ let { tokens: a } = s.source[s.source.reduce(n, 0)], p = a.description.trimLeft(), c = p.split('"');
2323
+ if (c.length > 1 && c[0] === "" && c.length % 2 === 1)
2324
+ return s.name = c[1], a.name = `"${c[1]}"`, [a.postName, a.description] = A(p.slice(a.name.length)), s;
2325
+ let u = 0, y = "", T = !1, g;
2326
+ for (let b of p) {
2327
+ if (u === 0 && Ie(b))
2328
+ break;
2329
+ b === "[" && u++, b === "]" && u--, y += b;
2330
+ }
2331
+ if (u !== 0)
2332
+ return s.problems.push({
2333
+ code: "spec:name:unpaired-brackets",
2334
+ message: "unpaired brackets",
2335
+ line: s.source[0].number,
2336
+ critical: !0
2337
+ }), s;
2338
+ let P = y;
2339
+ if (y[0] === "[" && y[y.length - 1] === "]") {
2340
+ T = !0, y = y.slice(1, -1);
2341
+ let b = y.split("=");
2342
+ if (y = b[0].trim(), b[1] !== void 0 && (g = b.slice(1).join("=").trim()), y === "")
2343
+ return s.problems.push({
2344
+ code: "spec:name:empty-name",
2345
+ message: "empty name",
2346
+ line: s.source[0].number,
2347
+ critical: !0
2348
+ }), s;
2349
+ if (g === "")
2350
+ return s.problems.push({
2351
+ code: "spec:name:empty-default",
2352
+ message: "empty default value",
2353
+ line: s.source[0].number,
2354
+ critical: !0
2355
+ }), s;
2356
+ if (!jr(g) && /=(?!>)/.test(g))
2357
+ return s.problems.push({
2358
+ code: "spec:name:invalid-default",
2359
+ message: "invalid default value syntax",
2360
+ line: s.source[0].number,
2361
+ critical: !0
2362
+ }), s;
2363
+ }
2364
+ return s.optional = T, s.name = y, a.name = P, g !== void 0 && (s.default = g), [a.postName, a.description] = A(p.slice(a.name.length)),
2365
+ s;
2366
+ };
2367
+ }
2368
+ r(le, "nameTokenizer");
2369
+
2370
+ // ../node_modules/comment-parser/es6/parser/tokenizers/description.js
2371
+ function ue(n = "compact", s = v) {
2372
+ let a = Ve(n);
2373
+ return (p) => (p.description = a(p.source, s), p);
2374
+ }
2375
+ r(ue, "descriptionTokenizer");
2376
+ function Ve(n) {
2377
+ return n === "compact" ? Lr : n === "preserve" ? Ur : n;
2378
+ }
2379
+ r(Ve, "getJoiner");
2380
+ function Lr(n, s = v) {
2381
+ return n.map(({ tokens: { description: a } }) => a.trim()).filter((a) => a !== "").join(" ");
2382
+ }
2383
+ r(Lr, "compactJoiner");
2384
+ var _r = /* @__PURE__ */ r((n, { tokens: s }, a) => s.type === "" ? n : a, "lineNo"), Vr = /* @__PURE__ */ r(({ tokens: n }) => (n.delimiter ===
2385
+ "" ? n.start : n.postDelimiter.slice(1)) + n.description, "getDescription");
2386
+ function Ur(n, s = v) {
2387
+ if (n.length === 0)
2388
+ return "";
2389
+ n[0].tokens.description === "" && n[0].tokens.delimiter === s.start && (n = n.slice(1));
2390
+ let a = n[n.length - 1];
2391
+ return a !== void 0 && a.tokens.description === "" && a.tokens.end.endsWith(s.end) && (n = n.slice(0, -1)), n = n.slice(n.reduce(_r, 0)), n.
2392
+ map(Vr).join(`
2393
+ `);
2394
+ }
2395
+ r(Ur, "preserveJoiner");
2396
+
2397
+ // ../node_modules/comment-parser/es6/parser/index.js
2398
+ function Ue({ startLine: n = 0, fence: s = "```", spacing: a = "compact", markers: p = v, tokenizers: c = [
2399
+ pe(),
2400
+ ce(a),
2401
+ le(),
2402
+ ue(a)
2403
+ ] } = {}) {
2404
+ if (n < 0 || n % 1 > 0)
2405
+ throw new Error("Invalid startLine");
2406
+ let u = Le({ startLine: n, markers: p }), y = je({ fence: s }), T = _e({ tokenizers: c }), g = Ve(a);
2407
+ return function(P) {
2408
+ let b = [];
2409
+ for (let fe of ct(P)) {
2410
+ let q = u(fe);
2411
+ if (q === null)
2412
+ continue;
2413
+ let E = y(q), z = E.slice(1).map(T);
2414
+ b.push({
2415
+ description: g(E[0], p),
2416
+ tags: z,
2417
+ source: q,
2418
+ problems: z.reduce((de, Te) => de.concat(Te.problems), [])
2419
+ });
2420
+ }
2421
+ return b;
2422
+ };
2423
+ }
2424
+ r(Ue, "getParser");
2425
+
2426
+ // ../node_modules/comment-parser/es6/stringifier/index.js
2427
+ function Br(n) {
2428
+ return n.start + n.delimiter + n.postDelimiter + n.tag + n.postTag + n.type + n.postType + n.name + n.postName + n.description + n.end + n.
2429
+ lineEnd;
2430
+ }
2431
+ r(Br, "join");
2432
+ function Be() {
2433
+ return (n) => n.source.map(({ tokens: s }) => Br(s)).join(`
2434
+ `);
2435
+ }
2436
+ r(Be, "getStringifier");
2437
+
2438
+ // ../node_modules/comment-parser/es6/stringifier/inspect.js
2439
+ var Cr = {
2440
+ line: 0,
2441
+ start: 0,
2442
+ delimiter: 0,
2443
+ postDelimiter: 0,
2444
+ tag: 0,
2445
+ postTag: 0,
2446
+ name: 0,
2447
+ postName: 0,
2448
+ type: 0,
2449
+ postType: 0,
2450
+ description: 0,
2451
+ end: 0,
2452
+ lineEnd: 0
2453
+ };
2454
+ var Ko = Object.keys(Cr);
2455
+
2456
+ // ../node_modules/comment-parser/es6/index.js
2457
+ function ut(n, s = {}) {
2458
+ return Ue(s)(n);
2459
+ }
2460
+ r(ut, "parse");
2461
+ var ls = Be();
2462
+
2463
+ // src/docs-tools/argTypes/jsdocParser.ts
2464
+ var $ = xr(yt(), 1);
2465
+ function Mr(n) {
2466
+ return n != null && n.includes("@");
2467
+ }
2468
+ r(Mr, "containsJsDoc");
2469
+ function Kr(n) {
2470
+ let p = `/**
2471
+ ` + (n ?? "").split(`
2472
+ `).map((u) => ` * ${u}`).join(`
2473
+ `) + `
2474
+ */`, c = ut(p, {
2475
+ spacing: "preserve"
2476
+ });
2477
+ if (!c || c.length === 0)
2478
+ throw new Error("Cannot parse JSDoc tags.");
2479
+ return c[0];
2480
+ }
2481
+ r(Kr, "parse");
2482
+ var $r = {
2483
+ tags: ["param", "arg", "argument", "returns", "ignore", "deprecated"]
2484
+ }, ft = /* @__PURE__ */ r((n, s = $r) => {
2485
+ if (!Mr(n))
2486
+ return {
2487
+ includesJsDoc: !1,
2488
+ ignore: !1
2489
+ };
2490
+ let a = Kr(n), p = qr(a, s.tags);
2491
+ return p.ignore ? {
2492
+ includesJsDoc: !0,
2493
+ ignore: !0
2494
+ } : {
2495
+ includesJsDoc: !0,
2496
+ ignore: !1,
2497
+ // Always use the parsed description to ensure JSDoc is removed from the description.
2498
+ description: a.description.trim(),
2499
+ extractedTags: p
2500
+ };
2501
+ }, "parseJsDoc");
2502
+ function qr(n, s) {
2503
+ let a = {
2504
+ params: null,
2505
+ deprecated: null,
2506
+ returns: null,
2507
+ ignore: !1
2508
+ };
2509
+ for (let p of n.tags)
2510
+ if (!(s !== void 0 && !s.includes(p.tag)))
2511
+ if (p.tag === "ignore") {
2512
+ a.ignore = !0;
2513
+ break;
2514
+ } else
2515
+ switch (p.tag) {
2516
+ // arg & argument are aliases for param.
2517
+ case "param":
2518
+ case "arg":
2519
+ case "argument": {
2520
+ let c = Wr(p);
2521
+ c != null && (a.params == null && (a.params = []), a.params.push(c));
2522
+ break;
2523
+ }
2524
+ case "deprecated": {
2525
+ let c = Gr(p);
2526
+ c != null && (a.deprecated = c);
2527
+ break;
2528
+ }
2529
+ case "returns": {
2530
+ let c = zr(p);
2531
+ c != null && (a.returns = c);
2532
+ break;
2533
+ }
2534
+ default:
2535
+ break;
2536
+ }
2537
+ return a;
2538
+ }
2539
+ r(qr, "extractJsDocTags");
2540
+ function Yr(n) {
2541
+ return n.replace(/[\.-]$/, "");
2542
+ }
2543
+ r(Yr, "normaliseParamName");
2544
+ function Wr(n) {
2545
+ if (!n.name || n.name === "-")
2546
+ return null;
2547
+ let s = gt(n.type);
2548
+ return {
2549
+ name: n.name,
2550
+ type: s,
2551
+ description: Tt(n.description),
2552
+ getPrettyName: /* @__PURE__ */ r(() => Yr(n.name), "getPrettyName"),
2553
+ getTypeName: /* @__PURE__ */ r(() => s ? ht(s) : null, "getTypeName")
2554
+ };
2555
+ }
2556
+ r(Wr, "extractParam");
2557
+ function Gr(n) {
2558
+ return n.name ? dt(n.name, n.description) : null;
2559
+ }
2560
+ r(Gr, "extractDeprecated");
2561
+ function dt(n, s) {
2562
+ let a = n === "" ? s : `${n} ${s}`;
2563
+ return Tt(a);
2564
+ }
2565
+ r(dt, "joinNameAndDescription");
2566
+ function Tt(n) {
2567
+ let s = n.replace(/^- /g, "").trim();
2568
+ return s === "" ? null : s;
2569
+ }
2570
+ r(Tt, "normaliseDescription");
2571
+ function zr(n) {
2572
+ let s = gt(n.type);
2573
+ return s ? {
2574
+ type: s,
2575
+ description: dt(n.name, n.description),
2576
+ getTypeName: /* @__PURE__ */ r(() => ht(s), "getTypeName")
2577
+ } : null;
2578
+ }
2579
+ r(zr, "extractReturns");
2580
+ var L = (0, $.stringifyRules)(), Xr = L.JsdocTypeObject;
2581
+ L.JsdocTypeAny = () => "any";
2582
+ L.JsdocTypeObject = (n, s) => `(${Xr(n, s)})`;
2583
+ L.JsdocTypeOptional = (n, s) => s(n.element);
2584
+ L.JsdocTypeNullable = (n, s) => s(n.element);
2585
+ L.JsdocTypeNotNullable = (n, s) => s(n.element);
2586
+ L.JsdocTypeUnion = (n, s) => n.elements.map(s).join("|");
2587
+ function gt(n) {
2588
+ try {
2589
+ return (0, $.parse)(n, "typescript");
2590
+ } catch {
2591
+ return null;
2592
+ }
2593
+ }
2594
+ r(gt, "extractType");
2595
+ function ht(n) {
2596
+ return (0, $.transform)(L, n);
2597
+ }
2598
+ r(ht, "extractTypeName");
2599
+
2600
+ // src/docs-tools/argTypes/utils.ts
2601
+ var xs = 90, Js = 50;
2602
+ function Me(n) {
2603
+ return n.length > 90;
2604
+ }
2605
+ r(Me, "isTooLongForTypeSummary");
2606
+ function xt(n) {
2607
+ return n.length > 50;
2608
+ }
2609
+ r(xt, "isTooLongForDefaultValueSummary");
2610
+ function J(n, s) {
2611
+ return n === s ? { summary: n } : { summary: n, detail: s };
2612
+ }
2613
+ r(J, "createSummaryValue");
2614
+ var ws = /* @__PURE__ */ r((n) => n.replace(/\\r\\n/g, "\\n"), "normalizeNewlines");
2615
+
2616
+ // src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts
2617
+ function Jt(n, s) {
2618
+ if (n != null) {
2619
+ let { value: a } = n;
2620
+ if (!K(a))
2621
+ return xt(a) ? J(s?.name, a) : J(a);
2622
+ }
2623
+ return null;
2624
+ }
2625
+ r(Jt, "createDefaultValue");
2626
+
2627
+ // src/docs-tools/argTypes/docgen/flow/createType.ts
2628
+ function wt({ name: n, value: s, elements: a, raw: p }) {
2629
+ return s ?? (a != null ? a.map(wt).join(" | ") : p ?? n);
2630
+ }
2631
+ r(wt, "generateUnionElement");
2632
+ function Hr({ name: n, raw: s, elements: a }) {
2633
+ return a != null ? J(a.map(wt).join(" | ")) : s != null ? J(s.replace(/^\|\s*/, "")) : J(n);
2634
+ }
2635
+ r(Hr, "generateUnion");
2636
+ function Qr({ type: n, raw: s }) {
2637
+ return s != null ? J(s) : J(n);
2638
+ }
2639
+ r(Qr, "generateFuncSignature");
2640
+ function Zr({ type: n, raw: s }) {
2641
+ return s != null ? Me(s) ? J(n, s) : J(s) : J(n);
2642
+ }
2643
+ r(Zr, "generateObjectSignature");
2644
+ function en(n) {
2645
+ let { type: s } = n;
2646
+ return s === "object" ? Zr(n) : Qr(n);
2647
+ }
2648
+ r(en, "generateSignature");
2649
+ function tn({ name: n, raw: s }) {
2650
+ return s != null ? Me(s) ? J(n, s) : J(s) : J(n);
2651
+ }
2652
+ r(tn, "generateDefault");
2653
+ function Pt(n) {
2654
+ if (n == null)
2655
+ return null;
2656
+ switch (n.name) {
2657
+ case "union":
2658
+ return Hr(n);
2659
+ case "signature":
2660
+ return en(n);
2661
+ default:
2662
+ return tn(n);
2663
+ }
2664
+ }
2665
+ r(Pt, "createType");
2666
+
2667
+ // src/docs-tools/argTypes/docgen/flow/createPropDef.ts
2668
+ var bt = /* @__PURE__ */ r((n, s) => {
2669
+ let { flowType: a, description: p, required: c, defaultValue: u } = s;
2670
+ return {
2671
+ name: n,
2672
+ type: Pt(a),
2673
+ required: c,
2674
+ description: p,
2675
+ defaultValue: Jt(u ?? null, a ?? null)
2676
+ };
2677
+ }, "createFlowPropDef");
2678
+
2679
+ // src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts
2680
+ function Et({ defaultValue: n }) {
2681
+ if (n != null) {
2682
+ let { value: s } = n;
2683
+ if (!K(s))
2684
+ return J(s);
2685
+ }
2686
+ return null;
2687
+ }
2688
+ r(Et, "createDefaultValue");
2689
+
2690
+ // src/docs-tools/argTypes/docgen/typeScript/createType.ts
2691
+ function St({ tsType: n, required: s }) {
2692
+ if (n == null)
2693
+ return null;
2694
+ let a = n.name;
2695
+ return s || (a = a.replace(" | undefined", "")), J(
2696
+ ["Array", "Record", "signature"].includes(n.name) ? n.raw : a
2697
+ );
2698
+ }
2699
+ r(St, "createType");
2700
+
2701
+ // src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts
2702
+ var Nt = /* @__PURE__ */ r((n, s) => {
2703
+ let { description: a, required: p } = s;
2704
+ return {
2705
+ name: n,
2706
+ type: St(s),
2707
+ required: p,
2708
+ description: a,
2709
+ defaultValue: Et(s)
2710
+ };
2711
+ }, "createTsPropDef");
2712
+
2713
+ // src/docs-tools/argTypes/docgen/createPropDef.ts
2714
+ function rn(n) {
2715
+ return n != null ? J(n.name) : null;
2716
+ }
2717
+ r(rn, "createType");
2718
+ function nn(n) {
2719
+ let { computed: s, func: a } = n;
2720
+ return typeof s > "u" && typeof a > "u";
2721
+ }
2722
+ r(nn, "isReactDocgenTypescript");
2723
+ function on(n) {
2724
+ return n ? n.name === "string" ? !0 : n.name === "enum" ? Array.isArray(n.value) && n.value.every(
2725
+ ({ value: s }) => typeof s == "string" && s[0] === '"' && s[s.length - 1] === '"'
2726
+ ) : !1 : !1;
2727
+ }
2728
+ r(on, "isStringValued");
2729
+ function sn(n, s) {
2730
+ if (n != null) {
2731
+ let { value: a } = n;
2732
+ if (!K(a))
2733
+ return nn(n) && on(s) ? J(JSON.stringify(a)) : J(a);
2734
+ }
2735
+ return null;
2736
+ }
2737
+ r(sn, "createDefaultValue");
2738
+ function Dt(n, s, a) {
2739
+ let { description: p, required: c, defaultValue: u } = a;
2740
+ return {
2741
+ name: n,
2742
+ type: rn(s),
2743
+ required: c,
2744
+ description: p,
2745
+ defaultValue: sn(u, s)
2746
+ };
2747
+ }
2748
+ r(Dt, "createBasicPropDef");
2749
+ function ye(n, s) {
2750
+ if (s?.includesJsDoc) {
2751
+ let { description: a, extractedTags: p } = s;
2752
+ a != null && (n.description = s.description);
2753
+ let c = {
2754
+ ...p,
2755
+ params: p?.params?.map(
2756
+ (u) => ({
2757
+ name: u.getPrettyName(),
2758
+ description: u.description
2759
+ })
2760
+ )
2761
+ };
2762
+ Object.values(c).filter(Boolean).length > 0 && (n.jsDocTags = c);
2763
+ }
2764
+ return n;
2765
+ }
2766
+ r(ye, "applyJsDocResult");
2767
+ var an = /* @__PURE__ */ r((n, s, a) => {
2768
+ let p = Dt(n, s.type, s);
2769
+ return p.sbType = ie(s), ye(p, a);
2770
+ }, "javaScriptFactory"), pn = /* @__PURE__ */ r((n, s, a) => {
2771
+ let p = Nt(n, s);
2772
+ return p.sbType = ie(s), ye(p, a);
2773
+ }, "tsFactory"), cn = /* @__PURE__ */ r((n, s, a) => {
2774
+ let p = bt(n, s);
2775
+ return p.sbType = ie(s), ye(p, a);
2776
+ }, "flowFactory"), ln = /* @__PURE__ */ r((n, s, a) => {
2777
+ let p = Dt(n, { name: "unknown" }, s);
2778
+ return ye(p, a);
2779
+ }, "unknownFactory"), Ke = /* @__PURE__ */ r((n) => {
2780
+ switch (n) {
2781
+ case "JavaScript":
2782
+ return an;
2783
+ case "TypeScript":
2784
+ return pn;
2785
+ case "Flow":
2786
+ return cn;
2787
+ default:
2788
+ return ln;
2789
+ }
2790
+ }, "getPropDefFactory");
2791
+
2792
+ // src/docs-tools/argTypes/docgen/extractDocgenProps.ts
2793
+ var Ot = /* @__PURE__ */ r((n) => n.type != null ? "JavaScript" : n.flowType != null ? "Flow" : n.tsType != null ? "TypeScript" : "Unknown",
2794
+ "getTypeSystem"), un = /* @__PURE__ */ r((n) => {
2795
+ let s = Ot(n[0]), a = Ke(s);
2796
+ return n.map((p) => {
2797
+ let c = p;
2798
+ return p.type?.elements && (c = {
2799
+ ...p,
2800
+ type: {
2801
+ ...p.type,
2802
+ value: p.type.elements
2803
+ }
2804
+ }), vt(c.name, c, s, a);
2805
+ });
2806
+ }, "extractComponentSectionArray"), mn = /* @__PURE__ */ r((n) => {
2807
+ let s = Object.keys(n), a = Ot(n[s[0]]), p = Ke(a);
2808
+ return s.map((c) => {
2809
+ let u = n[c];
2810
+ return u != null ? vt(c, u, a, p) : null;
2811
+ }).filter(Boolean);
2812
+ }, "extractComponentSectionObject"), ra = /* @__PURE__ */ r((n, s) => {
2813
+ let a = at(n, s);
2814
+ return st(a) ? Array.isArray(a) ? un(a) : mn(a) : [];
2815
+ }, "extractComponentProps");
2816
+ function vt(n, s, a, p) {
2817
+ let c = ft(s.description);
2818
+ return c.includesJsDoc && c.ignore ? null : {
2819
+ propDef: p(n, s, c),
2820
+ jsDocTags: c.extractedTags,
2821
+ docgenInfo: s,
2822
+ typeSystem: a
2823
+ };
2824
+ }
2825
+ r(vt, "extractProp");
2826
+ function na(n) {
2827
+ return n != null ? it(n) : "";
2828
+ }
2829
+ r(na, "extractComponentDescription");
2830
+
2831
+ // src/docs-tools/argTypes/enhanceArgTypes.ts
2832
+ import { combineParameters as yn } from "storybook/preview-api";
2833
+ var ia = /* @__PURE__ */ r((n) => {
2834
+ let {
2835
+ component: s,
2836
+ argTypes: a,
2837
+ parameters: { docs: p = {} }
2838
+ } = n, { extractArgTypes: c } = p, u = c && s ? c(s) : {};
2839
+ return u ? yn(u, a) : a;
2840
+ }, "enhanceArgTypes");
2841
+
2842
+ // src/docs-tools/shared.ts
2843
+ var kt = "storybook/docs", la = `${kt}/panel`, ua = "docs", ma = `${kt}/snippet-rendered`, fn = /* @__PURE__ */ ((p) => (p.AUTO = "auto", p.
2844
+ CODE = "code", p.DYNAMIC = "dynamic", p))(fn || {});
2845
+
2846
+ // src/docs-tools/hasDocsOrControls.ts
2847
+ var dn = /(addons\/|addon-|addon-essentials\/)(docs|controls)/, fa = /* @__PURE__ */ r((n) => n.presetsList?.some((s) => dn.test(s.name)), "\
2848
+ hasDocsOrControls");
2849
+ export {
2850
+ kt as ADDON_ID,
2851
+ Js as MAX_DEFAULT_VALUE_SUMMARY_LENGTH,
2852
+ xs as MAX_TYPE_SUMMARY_LENGTH,
2853
+ la as PANEL_ID,
2854
+ ua as PARAM_KEY,
2855
+ ma as SNIPPET_RENDERED,
2856
+ fn as SourceType,
2857
+ vr as TypeSystem,
2858
+ ie as convert,
2859
+ J as createSummaryValue,
2860
+ ia as enhanceArgTypes,
2861
+ na as extractComponentDescription,
2862
+ ra as extractComponentProps,
2863
+ un as extractComponentSectionArray,
2864
+ mn as extractComponentSectionObject,
2865
+ it as getDocgenDescription,
2866
+ at as getDocgenSection,
2867
+ ot as hasDocgen,
2868
+ fa as hasDocsOrControls,
2869
+ K as isDefaultValueBlacklisted,
2870
+ xt as isTooLongForDefaultValueSummary,
2871
+ Me as isTooLongForTypeSummary,
2872
+ st as isValidDocgenSection,
2873
+ ws as normalizeNewlines,
2874
+ ft as parseJsDoc,
2875
+ nt as str
2876
+ };