@uasyraf/helm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/.claude-plugin/plugin.json +9 -0
  2. package/.mcp.json +8 -0
  3. package/LICENSE +21 -0
  4. package/README.md +114 -0
  5. package/dashboard/build/client/_app/immutable/assets/0.DPthOi2j.css +1 -0
  6. package/dashboard/build/client/_app/immutable/assets/0.DPthOi2j.css.br +0 -0
  7. package/dashboard/build/client/_app/immutable/assets/0.DPthOi2j.css.gz +0 -0
  8. package/dashboard/build/client/_app/immutable/chunks/B3NJzl7g.js +1 -0
  9. package/dashboard/build/client/_app/immutable/chunks/B3NJzl7g.js.br +0 -0
  10. package/dashboard/build/client/_app/immutable/chunks/B3NJzl7g.js.gz +0 -0
  11. package/dashboard/build/client/_app/immutable/chunks/Bvgn0Gys.js +1 -0
  12. package/dashboard/build/client/_app/immutable/chunks/Bvgn0Gys.js.br +0 -0
  13. package/dashboard/build/client/_app/immutable/chunks/Bvgn0Gys.js.gz +0 -0
  14. package/dashboard/build/client/_app/immutable/chunks/C72aErMY.js +3 -0
  15. package/dashboard/build/client/_app/immutable/chunks/C72aErMY.js.br +0 -0
  16. package/dashboard/build/client/_app/immutable/chunks/C72aErMY.js.gz +0 -0
  17. package/dashboard/build/client/_app/immutable/chunks/CjpPs8iz.js +1 -0
  18. package/dashboard/build/client/_app/immutable/chunks/CjpPs8iz.js.br +0 -0
  19. package/dashboard/build/client/_app/immutable/chunks/CjpPs8iz.js.gz +0 -0
  20. package/dashboard/build/client/_app/immutable/chunks/DNLp8810.js +1 -0
  21. package/dashboard/build/client/_app/immutable/chunks/DNLp8810.js.br +0 -0
  22. package/dashboard/build/client/_app/immutable/chunks/DNLp8810.js.gz +0 -0
  23. package/dashboard/build/client/_app/immutable/chunks/DYkFpqG7.js +1 -0
  24. package/dashboard/build/client/_app/immutable/chunks/DYkFpqG7.js.br +0 -0
  25. package/dashboard/build/client/_app/immutable/chunks/DYkFpqG7.js.gz +0 -0
  26. package/dashboard/build/client/_app/immutable/chunks/DsiL0ppy.js +2 -0
  27. package/dashboard/build/client/_app/immutable/chunks/DsiL0ppy.js.br +0 -0
  28. package/dashboard/build/client/_app/immutable/chunks/DsiL0ppy.js.gz +0 -0
  29. package/dashboard/build/client/_app/immutable/chunks/bJX5vhEj.js +1 -0
  30. package/dashboard/build/client/_app/immutable/chunks/bJX5vhEj.js.br +0 -0
  31. package/dashboard/build/client/_app/immutable/chunks/bJX5vhEj.js.gz +0 -0
  32. package/dashboard/build/client/_app/immutable/chunks/gQDp4_Ul.js +1 -0
  33. package/dashboard/build/client/_app/immutable/chunks/gQDp4_Ul.js.br +0 -0
  34. package/dashboard/build/client/_app/immutable/chunks/gQDp4_Ul.js.gz +0 -0
  35. package/dashboard/build/client/_app/immutable/entry/app.D4j9hUjJ.js +2 -0
  36. package/dashboard/build/client/_app/immutable/entry/app.D4j9hUjJ.js.br +0 -0
  37. package/dashboard/build/client/_app/immutable/entry/app.D4j9hUjJ.js.gz +0 -0
  38. package/dashboard/build/client/_app/immutable/entry/start.D59wIHuS.js +1 -0
  39. package/dashboard/build/client/_app/immutable/entry/start.D59wIHuS.js.br +2 -0
  40. package/dashboard/build/client/_app/immutable/entry/start.D59wIHuS.js.gz +0 -0
  41. package/dashboard/build/client/_app/immutable/nodes/0.HocD0HAQ.js +1 -0
  42. package/dashboard/build/client/_app/immutable/nodes/0.HocD0HAQ.js.br +0 -0
  43. package/dashboard/build/client/_app/immutable/nodes/0.HocD0HAQ.js.gz +0 -0
  44. package/dashboard/build/client/_app/immutable/nodes/1.xo_a-jPh.js +1 -0
  45. package/dashboard/build/client/_app/immutable/nodes/1.xo_a-jPh.js.br +0 -0
  46. package/dashboard/build/client/_app/immutable/nodes/1.xo_a-jPh.js.gz +0 -0
  47. package/dashboard/build/client/_app/immutable/nodes/2.BwywD4n3.js +1 -0
  48. package/dashboard/build/client/_app/immutable/nodes/2.BwywD4n3.js.br +0 -0
  49. package/dashboard/build/client/_app/immutable/nodes/2.BwywD4n3.js.gz +0 -0
  50. package/dashboard/build/client/_app/immutable/nodes/3.BGY0bNfC.js +1 -0
  51. package/dashboard/build/client/_app/immutable/nodes/3.BGY0bNfC.js.br +0 -0
  52. package/dashboard/build/client/_app/immutable/nodes/3.BGY0bNfC.js.gz +0 -0
  53. package/dashboard/build/client/_app/immutable/nodes/4.C7uIivCS.js +1 -0
  54. package/dashboard/build/client/_app/immutable/nodes/4.C7uIivCS.js.br +0 -0
  55. package/dashboard/build/client/_app/immutable/nodes/4.C7uIivCS.js.gz +0 -0
  56. package/dashboard/build/client/_app/immutable/nodes/5.YszfczJW.js +1 -0
  57. package/dashboard/build/client/_app/immutable/nodes/5.YszfczJW.js.br +0 -0
  58. package/dashboard/build/client/_app/immutable/nodes/5.YszfczJW.js.gz +0 -0
  59. package/dashboard/build/client/_app/immutable/nodes/6.7fhKcbBK.js +1 -0
  60. package/dashboard/build/client/_app/immutable/nodes/6.7fhKcbBK.js.br +0 -0
  61. package/dashboard/build/client/_app/immutable/nodes/6.7fhKcbBK.js.gz +0 -0
  62. package/dashboard/build/client/_app/version.json +1 -0
  63. package/dashboard/build/client/_app/version.json.br +0 -0
  64. package/dashboard/build/client/_app/version.json.gz +0 -0
  65. package/dashboard/build/env.js +94 -0
  66. package/dashboard/build/handler.js +1494 -0
  67. package/dashboard/build/index.js +345 -0
  68. package/dashboard/build/server/chunks/0-DUUsxI66.js +40 -0
  69. package/dashboard/build/server/chunks/0-DUUsxI66.js.map +1 -0
  70. package/dashboard/build/server/chunks/1-BDkdOGL6.js +9 -0
  71. package/dashboard/build/server/chunks/1-BDkdOGL6.js.map +1 -0
  72. package/dashboard/build/server/chunks/2-BLt1vNET.js +51 -0
  73. package/dashboard/build/server/chunks/2-BLt1vNET.js.map +1 -0
  74. package/dashboard/build/server/chunks/3-B-4sxMk4.js +41 -0
  75. package/dashboard/build/server/chunks/3-B-4sxMk4.js.map +1 -0
  76. package/dashboard/build/server/chunks/4-CRZIwHJO.js +39 -0
  77. package/dashboard/build/server/chunks/4-CRZIwHJO.js.map +1 -0
  78. package/dashboard/build/server/chunks/5-CwiVOtz6.js +30 -0
  79. package/dashboard/build/server/chunks/5-CwiVOtz6.js.map +1 -0
  80. package/dashboard/build/server/chunks/6-mID2_gX2.js +53 -0
  81. package/dashboard/build/server/chunks/6-mID2_gX2.js.map +1 -0
  82. package/dashboard/build/server/chunks/_layout.svelte-DeOKequ-.js +31 -0
  83. package/dashboard/build/server/chunks/_layout.svelte-DeOKequ-.js.map +1 -0
  84. package/dashboard/build/server/chunks/_page.svelte-BGS-bwra.js +65 -0
  85. package/dashboard/build/server/chunks/_page.svelte-BGS-bwra.js.map +1 -0
  86. package/dashboard/build/server/chunks/_page.svelte-BiRjdIbl.js +35 -0
  87. package/dashboard/build/server/chunks/_page.svelte-BiRjdIbl.js.map +1 -0
  88. package/dashboard/build/server/chunks/_page.svelte-C_NO0kPy.js +49 -0
  89. package/dashboard/build/server/chunks/_page.svelte-C_NO0kPy.js.map +1 -0
  90. package/dashboard/build/server/chunks/_page.svelte-DvSQBjcA.js +80 -0
  91. package/dashboard/build/server/chunks/_page.svelte-DvSQBjcA.js.map +1 -0
  92. package/dashboard/build/server/chunks/_page.svelte-ZUq8J-ew.js +33 -0
  93. package/dashboard/build/server/chunks/_page.svelte-ZUq8J-ew.js.map +1 -0
  94. package/dashboard/build/server/chunks/error.svelte-DJ3O9Tia.js +12 -0
  95. package/dashboard/build/server/chunks/error.svelte-DJ3O9Tia.js.map +1 -0
  96. package/dashboard/build/server/chunks/exports-BnaAAAnL.js +3262 -0
  97. package/dashboard/build/server/chunks/exports-BnaAAAnL.js.map +1 -0
  98. package/dashboard/build/server/chunks/index-DwR_KaNY.js +44 -0
  99. package/dashboard/build/server/chunks/index-DwR_KaNY.js.map +1 -0
  100. package/dashboard/build/server/chunks/index-lhTMmBNn.js +207 -0
  101. package/dashboard/build/server/chunks/index-lhTMmBNn.js.map +1 -0
  102. package/dashboard/build/server/chunks/queries-DGWi-KlP.js +198 -0
  103. package/dashboard/build/server/chunks/queries-DGWi-KlP.js.map +1 -0
  104. package/dashboard/build/server/chunks/renderer-DdMvhZZr.js +1930 -0
  105. package/dashboard/build/server/chunks/renderer-DdMvhZZr.js.map +1 -0
  106. package/dashboard/build/server/index.js +5911 -0
  107. package/dashboard/build/server/index.js.map +1 -0
  108. package/dashboard/build/server/manifest.js +78 -0
  109. package/dashboard/build/server/manifest.js.map +1 -0
  110. package/dashboard/build/shims.js +32 -0
  111. package/dashboard/package.json +29 -0
  112. package/dashboard/svelte.config.js +15 -0
  113. package/dist/bin/helm.d.ts +2 -0
  114. package/dist/bin/helm.js +167 -0
  115. package/dist/bin/helm.js.map +1 -0
  116. package/dist/server/src/banner.d.ts +1 -0
  117. package/dist/server/src/banner.js +34 -0
  118. package/dist/server/src/banner.js.map +1 -0
  119. package/dist/server/src/config/load.d.ts +14 -0
  120. package/dist/server/src/config/load.js +43 -0
  121. package/dist/server/src/config/load.js.map +1 -0
  122. package/dist/server/src/dashboard.d.ts +5 -0
  123. package/dist/server/src/dashboard.js +79 -0
  124. package/dist/server/src/dashboard.js.map +1 -0
  125. package/dist/server/src/db/bootstrap.d.ts +2 -0
  126. package/dist/server/src/db/bootstrap.js +106 -0
  127. package/dist/server/src/db/bootstrap.js.map +1 -0
  128. package/dist/server/src/db/client.d.ts +14 -0
  129. package/dist/server/src/db/client.js +32 -0
  130. package/dist/server/src/db/client.js.map +1 -0
  131. package/dist/server/src/db/open-project.d.ts +17 -0
  132. package/dist/server/src/db/open-project.js +27 -0
  133. package/dist/server/src/db/open-project.js.map +1 -0
  134. package/dist/server/src/db/open-repo.d.ts +8 -0
  135. package/dist/server/src/db/open-repo.js +45 -0
  136. package/dist/server/src/db/open-repo.js.map +1 -0
  137. package/dist/server/src/db/pg-bootstrap.d.ts +4 -0
  138. package/dist/server/src/db/pg-bootstrap.js +106 -0
  139. package/dist/server/src/db/pg-bootstrap.js.map +1 -0
  140. package/dist/server/src/db/pg-client.d.ts +10 -0
  141. package/dist/server/src/db/pg-client.js +42 -0
  142. package/dist/server/src/db/pg-client.js.map +1 -0
  143. package/dist/server/src/db/repo-pg.d.ts +3 -0
  144. package/dist/server/src/db/repo-pg.js +245 -0
  145. package/dist/server/src/db/repo-pg.js.map +1 -0
  146. package/dist/server/src/db/repo-sqlite.d.ts +3 -0
  147. package/dist/server/src/db/repo-sqlite.js +224 -0
  148. package/dist/server/src/db/repo-sqlite.js.map +1 -0
  149. package/dist/server/src/db/repo.d.ts +54 -0
  150. package/dist/server/src/db/repo.js +2 -0
  151. package/dist/server/src/db/repo.js.map +1 -0
  152. package/dist/server/src/db/schema-pg.d.ts +2712 -0
  153. package/dist/server/src/db/schema-pg.js +107 -0
  154. package/dist/server/src/db/schema-pg.js.map +1 -0
  155. package/dist/server/src/db/schema.d.ts +2721 -0
  156. package/dist/server/src/db/schema.js +107 -0
  157. package/dist/server/src/db/schema.js.map +1 -0
  158. package/dist/server/src/events/emit.d.ts +21 -0
  159. package/dist/server/src/events/emit.js +17 -0
  160. package/dist/server/src/events/emit.js.map +1 -0
  161. package/dist/server/src/http/server.d.ts +10 -0
  162. package/dist/server/src/http/server.js +119 -0
  163. package/dist/server/src/http/server.js.map +1 -0
  164. package/dist/server/src/index.d.ts +2 -0
  165. package/dist/server/src/index.js +13 -0
  166. package/dist/server/src/index.js.map +1 -0
  167. package/dist/server/src/init.d.ts +12 -0
  168. package/dist/server/src/init.js +59 -0
  169. package/dist/server/src/init.js.map +1 -0
  170. package/dist/server/src/install.d.ts +8 -0
  171. package/dist/server/src/install.js +100 -0
  172. package/dist/server/src/install.js.map +1 -0
  173. package/dist/server/src/project/bootstrap.d.ts +9 -0
  174. package/dist/server/src/project/bootstrap.js +83 -0
  175. package/dist/server/src/project/bootstrap.js.map +1 -0
  176. package/dist/server/src/project/detect.d.ts +10 -0
  177. package/dist/server/src/project/detect.js +82 -0
  178. package/dist/server/src/project/detect.js.map +1 -0
  179. package/dist/server/src/project/identity.d.ts +8 -0
  180. package/dist/server/src/project/identity.js +42 -0
  181. package/dist/server/src/project/identity.js.map +1 -0
  182. package/dist/server/src/server.d.ts +8 -0
  183. package/dist/server/src/server.js +22 -0
  184. package/dist/server/src/server.js.map +1 -0
  185. package/dist/server/src/tools/debt.d.ts +2 -0
  186. package/dist/server/src/tools/debt.js +88 -0
  187. package/dist/server/src/tools/debt.js.map +1 -0
  188. package/dist/server/src/tools/decision.d.ts +2 -0
  189. package/dist/server/src/tools/decision.js +39 -0
  190. package/dist/server/src/tools/decision.js.map +1 -0
  191. package/dist/server/src/tools/epic.d.ts +2 -0
  192. package/dist/server/src/tools/epic.js +95 -0
  193. package/dist/server/src/tools/epic.js.map +1 -0
  194. package/dist/server/src/tools/index.d.ts +3 -0
  195. package/dist/server/src/tools/index.js +21 -0
  196. package/dist/server/src/tools/index.js.map +1 -0
  197. package/dist/server/src/tools/nelson.d.ts +2 -0
  198. package/dist/server/src/tools/nelson.js +28 -0
  199. package/dist/server/src/tools/nelson.js.map +1 -0
  200. package/dist/server/src/tools/progress.d.ts +2 -0
  201. package/dist/server/src/tools/progress.js +45 -0
  202. package/dist/server/src/tools/progress.js.map +1 -0
  203. package/dist/server/src/tools/sprint.d.ts +2 -0
  204. package/dist/server/src/tools/sprint.js +98 -0
  205. package/dist/server/src/tools/sprint.js.map +1 -0
  206. package/dist/server/src/tools/status.d.ts +2 -0
  207. package/dist/server/src/tools/status.js +31 -0
  208. package/dist/server/src/tools/status.js.map +1 -0
  209. package/dist/server/src/tools/story.d.ts +2 -0
  210. package/dist/server/src/tools/story.js +155 -0
  211. package/dist/server/src/tools/story.js.map +1 -0
  212. package/dist/server/src/tools/task.d.ts +2 -0
  213. package/dist/server/src/tools/task.js +90 -0
  214. package/dist/server/src/tools/task.js.map +1 -0
  215. package/dist/server/src/tools/types.d.ts +15 -0
  216. package/dist/server/src/tools/types.js +11 -0
  217. package/dist/server/src/tools/types.js.map +1 -0
  218. package/dist/server/src/util/git.d.ts +8 -0
  219. package/dist/server/src/util/git.js +51 -0
  220. package/dist/server/src/util/git.js.map +1 -0
  221. package/dist/server/src/util/ids.d.ts +2 -0
  222. package/dist/server/src/util/ids.js +8 -0
  223. package/dist/server/src/util/ids.js.map +1 -0
  224. package/dist/server/src/util/paths.d.ts +2 -0
  225. package/dist/server/src/util/paths.js +9 -0
  226. package/dist/server/src/util/paths.js.map +1 -0
  227. package/dist/server/src/worker/client.d.ts +12 -0
  228. package/dist/server/src/worker/client.js +89 -0
  229. package/dist/server/src/worker/client.js.map +1 -0
  230. package/dist/server/src/worker/hook.d.ts +1 -0
  231. package/dist/server/src/worker/hook.js +36 -0
  232. package/dist/server/src/worker/hook.js.map +1 -0
  233. package/dist/server/src/worker/ingest.d.ts +14 -0
  234. package/dist/server/src/worker/ingest.js +86 -0
  235. package/dist/server/src/worker/ingest.js.map +1 -0
  236. package/dist/server/src/worker/markers/any-type.d.ts +6 -0
  237. package/dist/server/src/worker/markers/any-type.js +19 -0
  238. package/dist/server/src/worker/markers/any-type.js.map +1 -0
  239. package/dist/server/src/worker/markers/debt.d.ts +11 -0
  240. package/dist/server/src/worker/markers/debt.js +53 -0
  241. package/dist/server/src/worker/markers/debt.js.map +1 -0
  242. package/dist/server/src/worker/markers/file-size.d.ts +5 -0
  243. package/dist/server/src/worker/markers/file-size.js +32 -0
  244. package/dist/server/src/worker/markers/file-size.js.map +1 -0
  245. package/dist/server/src/worker/scanner.d.ts +23 -0
  246. package/dist/server/src/worker/scanner.js +23 -0
  247. package/dist/server/src/worker/scanner.js.map +1 -0
  248. package/dist/server/src/worker/server.d.ts +1 -0
  249. package/dist/server/src/worker/server.js +137 -0
  250. package/dist/server/src/worker/server.js.map +1 -0
  251. package/dist/server/src/worker/socket.d.ts +3 -0
  252. package/dist/server/src/worker/socket.js +12 -0
  253. package/dist/server/src/worker/socket.js.map +1 -0
  254. package/hooks/hooks.json +33 -0
  255. package/package.json +56 -0
  256. package/skills/backlog/SKILL.md +18 -0
  257. package/skills/debt/SKILL.md +39 -0
  258. package/skills/epic/SKILL.md +22 -0
  259. package/skills/nelson-integration/SKILL.md +44 -0
  260. package/skills/project-tracker/SKILL.md +60 -0
  261. package/skills/review/SKILL.md +27 -0
  262. package/skills/sprint/SKILL.md +23 -0
  263. package/skills/story/SKILL.md +29 -0
@@ -0,0 +1,1930 @@
1
+ const UNDEFINED = -1;
2
+ const HOLE = -2;
3
+ const NAN = -3;
4
+ const POSITIVE_INFINITY = -4;
5
+ const NEGATIVE_INFINITY = -5;
6
+ const NEGATIVE_ZERO = -6;
7
+ const SPARSE = -7;
8
+
9
+ // The largest valid value for a JavaScript array's `length` property,
10
+ // and the largest valid array index (one less than the max length).
11
+ const MAX_ARRAY_LEN = 2 ** 32 - 1;
12
+ const MAX_ARRAY_INDEX = MAX_ARRAY_LEN - 1;
13
+
14
+ /** @type {Record<string, string>} */
15
+ const escaped = {
16
+ '<': '\\u003C',
17
+ '\\': '\\\\',
18
+ '\b': '\\b',
19
+ '\f': '\\f',
20
+ '\n': '\\n',
21
+ '\r': '\\r',
22
+ '\t': '\\t',
23
+ '\u2028': '\\u2028',
24
+ '\u2029': '\\u2029'
25
+ };
26
+
27
+ class DevalueError extends Error {
28
+ /**
29
+ * @param {string} message
30
+ * @param {string[]} keys
31
+ * @param {any} [value] - The value that failed to be serialized
32
+ * @param {any} [root] - The root value being serialized
33
+ */
34
+ constructor(message, keys, value, root) {
35
+ super(message);
36
+ this.name = 'DevalueError';
37
+ this.path = keys.join('');
38
+ this.value = value;
39
+ this.root = root;
40
+ }
41
+ }
42
+
43
+ /** @param {any} thing */
44
+ function is_primitive(thing) {
45
+ return thing === null || (typeof thing !== 'object' && typeof thing !== 'function');
46
+ }
47
+
48
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype)
49
+ .sort()
50
+ .join('\0');
51
+
52
+ /** @param {any} thing */
53
+ function is_plain_object(thing) {
54
+ const proto = Object.getPrototypeOf(thing);
55
+
56
+ return (
57
+ proto === Object.prototype ||
58
+ proto === null ||
59
+ Object.getPrototypeOf(proto) === null ||
60
+ Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
61
+ );
62
+ }
63
+
64
+ /** @param {any} thing */
65
+ function get_type(thing) {
66
+ return Object.prototype.toString.call(thing).slice(8, -1);
67
+ }
68
+
69
+ /** @param {string} char */
70
+ function get_escaped_char(char) {
71
+ switch (char) {
72
+ case '"':
73
+ return '\\"';
74
+ case '<':
75
+ return '\\u003C';
76
+ case '\\':
77
+ return '\\\\';
78
+ case '\n':
79
+ return '\\n';
80
+ case '\r':
81
+ return '\\r';
82
+ case '\t':
83
+ return '\\t';
84
+ case '\b':
85
+ return '\\b';
86
+ case '\f':
87
+ return '\\f';
88
+ case '\u2028':
89
+ return '\\u2028';
90
+ case '\u2029':
91
+ return '\\u2029';
92
+ default:
93
+ return char < ' ' ? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}` : '';
94
+ }
95
+ }
96
+
97
+ /** @param {string} str */
98
+ function stringify_string(str) {
99
+ let result = '';
100
+ let last_pos = 0;
101
+ const len = str.length;
102
+
103
+ for (let i = 0; i < len; i += 1) {
104
+ const char = str[i];
105
+ const replacement = get_escaped_char(char);
106
+ if (replacement) {
107
+ result += str.slice(last_pos, i) + replacement;
108
+ last_pos = i + 1;
109
+ }
110
+ }
111
+
112
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
113
+ }
114
+
115
+ /** @param {Record<string | symbol, any>} object */
116
+ function enumerable_symbols(object) {
117
+ return Object.getOwnPropertySymbols(object).filter(
118
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
119
+ );
120
+ }
121
+
122
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
123
+
124
+ /** @param {string} key */
125
+ function stringify_key(key) {
126
+ return is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';
127
+ }
128
+
129
+ /** @param {number} n */
130
+ function is_valid_array_index(n) {
131
+ if (!Number.isInteger(n)) return false;
132
+ if (n < 0) return false;
133
+ if (n > MAX_ARRAY_INDEX) return false;
134
+ return true;
135
+ }
136
+
137
+ /** @param {number} n */
138
+ function is_valid_array_len(n) {
139
+ if (!Number.isInteger(n)) return false;
140
+ if (n < 0) return false;
141
+ if (n > MAX_ARRAY_LEN) return false;
142
+ return true;
143
+ }
144
+
145
+ /** @param {string} s */
146
+ function is_valid_array_index_string(s) {
147
+ if (s.length === 0) return false;
148
+ if (s.length > 1 && s.charCodeAt(0) === 48) return false; // leading zero
149
+ for (let i = 0; i < s.length; i++) {
150
+ const c = s.charCodeAt(i);
151
+ if (c < 48 || c > 57) return false;
152
+ }
153
+ // by this point we know it's a string of digits, but it has to be within
154
+ // the range of valid array indices
155
+ return is_valid_array_index(+s);
156
+ }
157
+
158
+ /**
159
+ * Finds the populated indices of an array.
160
+ * @param {unknown[]} array
161
+ */
162
+ function valid_array_indices(array) {
163
+ const keys = Object.keys(array);
164
+ for (var i = keys.length - 1; i >= 0; i--) {
165
+ if (is_valid_array_index_string(keys[i])) {
166
+ break;
167
+ }
168
+ }
169
+ keys.length = i + 1;
170
+ return keys;
171
+ }
172
+
173
+ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
174
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
175
+ const reserved =
176
+ /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
177
+
178
+ /**
179
+ * Turn a value into the JavaScript that creates an equivalent value
180
+ * @param {any} value
181
+ * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
182
+ */
183
+ function uneval(value, replacer) {
184
+ const counts = new Map();
185
+
186
+ /** @type {string[]} */
187
+ const keys = [];
188
+
189
+ const custom = new Map();
190
+
191
+ /** @param {any} thing */
192
+ function walk(thing) {
193
+ if (!is_primitive(thing)) {
194
+ if (counts.has(thing)) {
195
+ counts.set(thing, counts.get(thing) + 1);
196
+ return;
197
+ }
198
+
199
+ counts.set(thing, 1);
200
+
201
+ if (replacer) {
202
+ const str = replacer(thing, (value) => uneval(value, replacer));
203
+
204
+ if (typeof str === 'string') {
205
+ custom.set(thing, str);
206
+ return;
207
+ }
208
+ }
209
+
210
+ if (typeof thing === 'function') {
211
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
212
+ }
213
+
214
+ const type = get_type(thing);
215
+
216
+ switch (type) {
217
+ case 'Number':
218
+ case 'BigInt':
219
+ case 'String':
220
+ case 'Boolean':
221
+ case 'Date':
222
+ case 'RegExp':
223
+ case 'URL':
224
+ case 'URLSearchParams':
225
+ return;
226
+
227
+ case 'Array':
228
+ /** @type {any[]} */ (thing).forEach((value, i) => {
229
+ keys.push(`[${i}]`);
230
+ walk(value);
231
+ keys.pop();
232
+ });
233
+ break;
234
+
235
+ case 'Set':
236
+ Array.from(thing).forEach(walk);
237
+ break;
238
+
239
+ case 'Map':
240
+ for (const [key, value] of thing) {
241
+ keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`);
242
+ walk(value);
243
+ keys.pop();
244
+ }
245
+ break;
246
+
247
+ case 'Int8Array':
248
+ case 'Uint8Array':
249
+ case 'Uint8ClampedArray':
250
+ case 'Int16Array':
251
+ case 'Uint16Array':
252
+ case 'Float16Array':
253
+ case 'Int32Array':
254
+ case 'Uint32Array':
255
+ case 'Float32Array':
256
+ case 'Float64Array':
257
+ case 'BigInt64Array':
258
+ case 'BigUint64Array':
259
+ case 'DataView':
260
+ walk(thing.buffer);
261
+ return;
262
+
263
+ case 'ArrayBuffer':
264
+ return;
265
+
266
+ case 'Temporal.Duration':
267
+ case 'Temporal.Instant':
268
+ case 'Temporal.PlainDate':
269
+ case 'Temporal.PlainTime':
270
+ case 'Temporal.PlainDateTime':
271
+ case 'Temporal.PlainMonthDay':
272
+ case 'Temporal.PlainYearMonth':
273
+ case 'Temporal.ZonedDateTime':
274
+ return;
275
+
276
+ default:
277
+ if (!is_plain_object(thing)) {
278
+ throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
279
+ }
280
+
281
+ if (enumerable_symbols(thing).length > 0) {
282
+ throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
283
+ }
284
+
285
+ for (const key of Object.keys(thing)) {
286
+ if (key === '__proto__') {
287
+ throw new DevalueError(
288
+ `Cannot stringify objects with __proto__ keys`,
289
+ keys,
290
+ thing,
291
+ value
292
+ );
293
+ }
294
+
295
+ keys.push(stringify_key(key));
296
+ walk(thing[key]);
297
+ keys.pop();
298
+ }
299
+ }
300
+ } else if (typeof thing === 'symbol') {
301
+ throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
302
+ }
303
+ }
304
+
305
+ walk(value);
306
+
307
+ const names = new Map();
308
+
309
+ Array.from(counts)
310
+ .filter((entry) => entry[1] > 1)
311
+ .sort((a, b) => b[1] - a[1])
312
+ .forEach((entry, i) => {
313
+ names.set(entry[0], get_name(i));
314
+ });
315
+
316
+ /**
317
+ * @param {any} thing
318
+ * @returns {string}
319
+ */
320
+ function stringify(thing) {
321
+ if (names.has(thing)) {
322
+ return names.get(thing);
323
+ }
324
+
325
+ if (is_primitive(thing)) {
326
+ return stringify_primitive(thing);
327
+ }
328
+
329
+ if (custom.has(thing)) {
330
+ return custom.get(thing);
331
+ }
332
+
333
+ const type = get_type(thing);
334
+
335
+ switch (type) {
336
+ case 'Number':
337
+ case 'String':
338
+ case 'Boolean':
339
+ case 'BigInt':
340
+ return `Object(${stringify(thing.valueOf())})`;
341
+
342
+ case 'RegExp':
343
+ const { source, flags } = thing;
344
+ return flags
345
+ ? `new RegExp(${stringify_string(source)},"${flags}")`
346
+ : `new RegExp(${stringify_string(source)})`;
347
+
348
+ case 'Date':
349
+ return `new Date(${thing.getTime()})`;
350
+
351
+ case 'URL':
352
+ return `new URL(${stringify_string(thing.toString())})`;
353
+
354
+ case 'URLSearchParams':
355
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
356
+
357
+ case 'Array': {
358
+ // For dense arrays (no holes), we iterate normally.
359
+ // When we encounter the first hole, we call Object.keys
360
+ // to determine the sparseness, then decide between:
361
+ // - Array literal with holes: [,"a",,] (default)
362
+ // - Object.assign: Object.assign(Array(n),{...}) (for very sparse arrays)
363
+ // Only the Object.assign path avoids iterating every slot, which
364
+ // is what protects against the DoS of e.g. `arr[1000000] = 1`.
365
+ let has_holes = false;
366
+
367
+ let result = '[';
368
+
369
+ for (let i = 0; i < thing.length; i += 1) {
370
+ if (i > 0) result += ',';
371
+
372
+ if (Object.hasOwn(thing, i)) {
373
+ result += stringify(thing[i]);
374
+ } else if (!has_holes) {
375
+ // Decide between array literal and Object.assign.
376
+ //
377
+ // Array literal: holes are consecutive commas.
378
+ // For example, [, "a", ,] is written as [,"a",,].
379
+ // Each hole costs 1 char (a comma).
380
+ //
381
+ // Object.assign: populated indices are listed explicitly.
382
+ // For example, [, "a", ,] would be written as
383
+ // Object.assign(Array(3),{1:"a"}). This avoids paying
384
+ // per-hole, but has a large fixed overhead for the
385
+ // "Object.assign(Array(n),{...})" wrapper, and each
386
+ // element costs extra chars for its index and colon.
387
+ //
388
+ // The serialized values are the same size either way, so
389
+ // the choice comes down to the structural overhead:
390
+ //
391
+ // Array literal overhead:
392
+ // 1 char per element or hole (comma separators)
393
+ // + 2 chars for "[" and "]"
394
+ // = L + 2
395
+ //
396
+ // Object.assign overhead:
397
+ // "Object.assign(Array(" — 20 chars
398
+ // + length — d chars
399
+ // + "),{" — 3 chars
400
+ // + for each populated element:
401
+ // index + ":" + "," — (d + 2) chars
402
+ // + "})" — 2 chars
403
+ // = (25 + d) + P * (d + 2)
404
+ //
405
+ // where L is the array length, P is the number of
406
+ // populated elements, and d is the number of digits
407
+ // in L (an upper bound on the digits in any index).
408
+ //
409
+ // Object.assign is cheaper when:
410
+ // (25 + d) + P * (d + 2) < L + 2
411
+ const populated_keys = valid_array_indices(/** @type {any[]} */ (thing));
412
+ const population = populated_keys.length;
413
+ const d = String(thing.length).length;
414
+
415
+ const hole_cost = thing.length + 2;
416
+ const sparse_cost = 25 + d + population * (d + 2);
417
+
418
+ if (hole_cost > sparse_cost) {
419
+ const entries = populated_keys.map((k) => `${k}:${stringify(thing[k])}`).join(',');
420
+ return `Object.assign(Array(${thing.length}),{${entries}})`;
421
+ }
422
+
423
+ // Re-process this index as a hole in the array literal
424
+ has_holes = true;
425
+ i -= 1;
426
+ }
427
+ // else: already decided on array literal, hole is just an empty slot
428
+ // (the comma separator is all we need — no content for this position)
429
+ }
430
+
431
+ const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
432
+ return result + tail + ']';
433
+ }
434
+
435
+ case 'Set':
436
+ case 'Map':
437
+ return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
438
+
439
+ case 'Int8Array':
440
+ case 'Uint8Array':
441
+ case 'Uint8ClampedArray':
442
+ case 'Int16Array':
443
+ case 'Uint16Array':
444
+ case 'Float16Array':
445
+ case 'Int32Array':
446
+ case 'Uint32Array':
447
+ case 'Float32Array':
448
+ case 'Float64Array':
449
+ case 'BigInt64Array':
450
+ case 'BigUint64Array': {
451
+ let str = `new ${type}`;
452
+
453
+ if (!names.has(thing.buffer)) {
454
+ const array = new thing.constructor(thing.buffer);
455
+ str += `([${array}])`;
456
+ } else {
457
+ str += `(${stringify(thing.buffer)})`;
458
+ }
459
+
460
+ // handle subarrays
461
+ if (thing.byteLength !== thing.buffer.byteLength) {
462
+ const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
463
+ const end = start + thing.length;
464
+ str += `.subarray(${start},${end})`;
465
+ }
466
+
467
+ return str;
468
+ }
469
+
470
+ case 'DataView': {
471
+ let str = `new DataView`;
472
+
473
+ if (!names.has(thing.buffer)) {
474
+ str += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
475
+ } else {
476
+ str += `(${stringify(thing.buffer)}`;
477
+ }
478
+
479
+ // handle subviews
480
+ if (thing.byteLength !== thing.buffer.byteLength) {
481
+ str += `,${thing.startOffset},${thing.byteLength}`;
482
+ }
483
+
484
+ return str + ')';
485
+ }
486
+
487
+ case 'ArrayBuffer': {
488
+ const ui8 = new Uint8Array(thing);
489
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
490
+ }
491
+
492
+ case 'Temporal.Duration':
493
+ case 'Temporal.Instant':
494
+ case 'Temporal.PlainDate':
495
+ case 'Temporal.PlainTime':
496
+ case 'Temporal.PlainDateTime':
497
+ case 'Temporal.PlainMonthDay':
498
+ case 'Temporal.PlainYearMonth':
499
+ case 'Temporal.ZonedDateTime':
500
+ return `${type}.from(${stringify_string(thing.toString())})`;
501
+
502
+ default:
503
+ const keys = Object.keys(thing);
504
+ const obj = keys.map((key) => `${safe_key(key)}:${stringify(thing[key])}`).join(',');
505
+ const proto = Object.getPrototypeOf(thing);
506
+ if (proto === null) {
507
+ return keys.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
508
+ }
509
+
510
+ return `{${obj}}`;
511
+ }
512
+ }
513
+
514
+ const str = stringify(value);
515
+
516
+ if (names.size) {
517
+ /** @type {string[]} */
518
+ const params = [];
519
+
520
+ /** @type {string[]} */
521
+ const statements = [];
522
+
523
+ /** @type {string[]} */
524
+ const values = [];
525
+
526
+ names.forEach((name, thing) => {
527
+ params.push(name);
528
+
529
+ if (custom.has(thing)) {
530
+ values.push(/** @type {string} */ (custom.get(thing)));
531
+ return;
532
+ }
533
+
534
+ if (is_primitive(thing)) {
535
+ values.push(stringify_primitive(thing));
536
+ return;
537
+ }
538
+
539
+ const type = get_type(thing);
540
+
541
+ switch (type) {
542
+ case 'Number':
543
+ case 'String':
544
+ case 'Boolean':
545
+ case 'BigInt':
546
+ values.push(`Object(${stringify(thing.valueOf())})`);
547
+ break;
548
+
549
+ case 'RegExp':
550
+ const { source, flags } = thing;
551
+ const regexp = flags
552
+ ? `new RegExp(${stringify_string(source)},"${flags}")`
553
+ : `new RegExp(${stringify_string(source)})`;
554
+ values.push(regexp);
555
+ break;
556
+
557
+ case 'Date':
558
+ values.push(`new Date(${thing.getTime()})`);
559
+ break;
560
+
561
+ case 'URL':
562
+ values.push(`new URL(${stringify_string(thing.toString())})`);
563
+ break;
564
+
565
+ case 'URLSearchParams':
566
+ values.push(`new URLSearchParams(${stringify_string(thing.toString())})`);
567
+ break;
568
+
569
+ case 'Array':
570
+ values.push(`Array(${thing.length})`);
571
+ /** @type {any[]} */ (thing).forEach((v, i) => {
572
+ statements.push(`${name}[${i}]=${stringify(v)}`);
573
+ });
574
+ break;
575
+
576
+ case 'Set':
577
+ values.push(`new Set`);
578
+ statements.push(
579
+ `${name}.${Array.from(thing)
580
+ .map((v) => `add(${stringify(v)})`)
581
+ .join('.')}`
582
+ );
583
+ break;
584
+
585
+ case 'Map':
586
+ values.push(`new Map`);
587
+ statements.push(
588
+ `${name}.${Array.from(thing)
589
+ .map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)
590
+ .join('.')}`
591
+ );
592
+ break;
593
+
594
+ case 'Int8Array':
595
+ case 'Uint8Array':
596
+ case 'Uint8ClampedArray':
597
+ case 'Int16Array':
598
+ case 'Uint16Array':
599
+ case 'Float16Array':
600
+ case 'Int32Array':
601
+ case 'Uint32Array':
602
+ case 'Float32Array':
603
+ case 'Float64Array':
604
+ case 'BigInt64Array':
605
+ case 'BigUint64Array': {
606
+ let str = `new ${type}`;
607
+
608
+ if (!names.has(thing.buffer)) {
609
+ const array = new thing.constructor(thing.buffer);
610
+ str += `([${array}])`;
611
+ } else {
612
+ str += `(${stringify(thing.buffer)})`;
613
+ }
614
+
615
+ // handle subarrays
616
+ if (thing.byteLength !== thing.buffer.byteLength) {
617
+ const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
618
+ const end = start + thing.length;
619
+ str += `.subarray(${start},${end})`;
620
+ }
621
+
622
+ values.push(`{}`);
623
+ statements.push(`${name}=${str}`);
624
+ break;
625
+ }
626
+
627
+ case 'DataView': {
628
+ let str = `new DataView`;
629
+
630
+ if (!names.has(thing.buffer)) {
631
+ str += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
632
+ } else {
633
+ str += `(${stringify(thing.buffer)}`;
634
+ }
635
+
636
+ // handle subviews
637
+ if (thing.byteLength !== thing.buffer.byteLength) {
638
+ str += `,${thing.byteOffset},${thing.byteLength}`;
639
+ }
640
+
641
+ str += ')';
642
+
643
+ values.push(`{}`);
644
+ statements.push(`${name}=${str}`);
645
+ break;
646
+ }
647
+
648
+ case 'ArrayBuffer':
649
+ values.push(`new Uint8Array([${new Uint8Array(thing)}]).buffer`);
650
+ break;
651
+
652
+ default:
653
+ values.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}');
654
+ Object.keys(thing).forEach((key) => {
655
+ statements.push(`${name}${safe_prop(key)}=${stringify(thing[key])}`);
656
+ });
657
+ }
658
+ });
659
+
660
+ statements.push(`return ${str}`);
661
+
662
+ return `(function(${params.join(',')}){${statements.join(';')}}(${values.join(',')}))`;
663
+ } else {
664
+ return str;
665
+ }
666
+ }
667
+
668
+ /** @param {number} num */
669
+ function get_name(num) {
670
+ let name = '';
671
+
672
+ do {
673
+ name = chars[num % chars.length] + name;
674
+ num = ~~(num / chars.length) - 1;
675
+ } while (num >= 0);
676
+
677
+ return reserved.test(name) ? `${name}0` : name;
678
+ }
679
+
680
+ /** @param {string} c */
681
+ function escape_unsafe_char(c) {
682
+ return escaped[c] || c;
683
+ }
684
+
685
+ /** @param {string} str */
686
+ function escape_unsafe_chars(str) {
687
+ return str.replace(unsafe_chars, escape_unsafe_char);
688
+ }
689
+
690
+ /** @param {string} key */
691
+ function safe_key(key) {
692
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
693
+ }
694
+
695
+ /** @param {string} key */
696
+ function safe_prop(key) {
697
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
698
+ ? `.${key}`
699
+ : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
700
+ }
701
+
702
+ /** @param {any} thing */
703
+ function stringify_primitive(thing) {
704
+ const type = typeof thing;
705
+ if (type === 'string') return stringify_string(thing);
706
+ if (thing === void 0) return 'void 0';
707
+ if (thing === 0 && 1 / thing < 0) return '-0';
708
+ const str = String(thing);
709
+ if (type === 'number') return str.replace(/^(-)?0\./, '$1.');
710
+ if (type === 'bigint') return thing + 'n';
711
+ return str;
712
+ }
713
+
714
+ function lifecycle_outside_component(name) {
715
+ {
716
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
717
+ }
718
+ }
719
+ function await_invalid() {
720
+ const error = new Error(`await_invalid
721
+ Encountered asynchronous work while rendering synchronously.
722
+ https://svelte.dev/e/await_invalid`);
723
+ error.name = "Svelte error";
724
+ throw error;
725
+ }
726
+ function invalid_csp() {
727
+ const error = new Error(`invalid_csp
728
+ \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
729
+ https://svelte.dev/e/invalid_csp`);
730
+ error.name = "Svelte error";
731
+ throw error;
732
+ }
733
+ function invalid_id_prefix() {
734
+ const error = new Error(`invalid_id_prefix
735
+ The \`idPrefix\` option cannot include \`--\`.
736
+ https://svelte.dev/e/invalid_id_prefix`);
737
+ error.name = "Svelte error";
738
+ throw error;
739
+ }
740
+ function server_context_required() {
741
+ const error = new Error(`server_context_required
742
+ Could not resolve \`render\` context.
743
+ https://svelte.dev/e/server_context_required`);
744
+ error.name = "Svelte error";
745
+ throw error;
746
+ }
747
+ function get_render_context() {
748
+ const store = als?.getStore();
749
+ {
750
+ server_context_required();
751
+ }
752
+ return store;
753
+ }
754
+ let als = null;
755
+
756
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx$1(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
757
+
758
+ var ssr_context = null;
759
+ function set_ssr_context(v) {
760
+ ssr_context = v;
761
+ }
762
+ function getContext(key) {
763
+ const context_map = get_or_init_context_map();
764
+ const result = (
765
+ /** @type {T} */
766
+ context_map.get(key)
767
+ );
768
+ return result;
769
+ }
770
+ function setContext(key, context) {
771
+ get_or_init_context_map().set(key, context);
772
+ return context;
773
+ }
774
+ function get_or_init_context_map(name) {
775
+ if (ssr_context === null) {
776
+ lifecycle_outside_component();
777
+ }
778
+ return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0);
779
+ }
780
+ function push(fn) {
781
+ ssr_context = { p: ssr_context, c: null, r: null };
782
+ }
783
+ function pop() {
784
+ ssr_context = /** @type {SSRContext} */
785
+ ssr_context.p;
786
+ }
787
+ function get_parent_context(ssr_context2) {
788
+ let parent = ssr_context2.p;
789
+ while (parent !== null) {
790
+ const context_map = parent.c;
791
+ if (context_map !== null) {
792
+ return context_map;
793
+ }
794
+ parent = parent.p;
795
+ }
796
+ return null;
797
+ }
798
+ var is_array = Array.isArray;
799
+ var index_of = Array.prototype.indexOf;
800
+ var includes = Array.prototype.includes;
801
+ var array_from = Array.from;
802
+ var define_property = Object.defineProperty;
803
+ var get_descriptor = Object.getOwnPropertyDescriptor;
804
+ var object_prototype = Object.prototype;
805
+ var array_prototype = Array.prototype;
806
+ var get_prototype_of = Object.getPrototypeOf;
807
+ var is_extensible = Object.isExtensible;
808
+ var has_own_property = Object.prototype.hasOwnProperty;
809
+ const noop = () => {
810
+ };
811
+ function run_all(arr) {
812
+ for (var i = 0; i < arr.length; i++) {
813
+ arr[i]();
814
+ }
815
+ }
816
+ function deferred() {
817
+ var resolve;
818
+ var reject;
819
+ var promise = new Promise((res, rej) => {
820
+ resolve = res;
821
+ reject = rej;
822
+ });
823
+ return { promise, resolve, reject };
824
+ }
825
+ const DERIVED = 1 << 1;
826
+ const EFFECT = 1 << 2;
827
+ const RENDER_EFFECT = 1 << 3;
828
+ const MANAGED_EFFECT = 1 << 24;
829
+ const BLOCK_EFFECT = 1 << 4;
830
+ const BRANCH_EFFECT = 1 << 5;
831
+ const ROOT_EFFECT = 1 << 6;
832
+ const BOUNDARY_EFFECT = 1 << 7;
833
+ const CONNECTED = 1 << 9;
834
+ const CLEAN = 1 << 10;
835
+ const DIRTY = 1 << 11;
836
+ const MAYBE_DIRTY = 1 << 12;
837
+ const INERT = 1 << 13;
838
+ const DESTROYED = 1 << 14;
839
+ const REACTION_RAN = 1 << 15;
840
+ const DESTROYING = 1 << 25;
841
+ const EFFECT_TRANSPARENT = 1 << 16;
842
+ const EAGER_EFFECT = 1 << 17;
843
+ const HEAD_EFFECT = 1 << 18;
844
+ const EFFECT_PRESERVED = 1 << 19;
845
+ const USER_EFFECT = 1 << 20;
846
+ const WAS_MARKED = 1 << 16;
847
+ const REACTION_IS_UPDATING = 1 << 21;
848
+ const ASYNC = 1 << 22;
849
+ const ERROR_VALUE = 1 << 23;
850
+ const STATE_SYMBOL = Symbol("$state");
851
+ const LEGACY_PROPS = Symbol("legacy props");
852
+ const ATTRIBUTES_CACHE = Symbol("attributes");
853
+ const CLASS_CACHE = Symbol("class");
854
+ const STYLE_CACHE = Symbol("style");
855
+ const TEXT_CACHE = Symbol("text");
856
+ const STALE_REACTION = new class StaleReactionError extends Error {
857
+ name = "StaleReactionError";
858
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
859
+ }();
860
+ const COMMENT_NODE = 8;
861
+ let controller = null;
862
+ function abort() {
863
+ controller?.abort(STALE_REACTION);
864
+ controller = null;
865
+ }
866
+ const HYDRATION_START = "[";
867
+ const HYDRATION_START_ELSE = "[!";
868
+ const HYDRATION_START_FAILED = "[?";
869
+ const HYDRATION_END = "]";
870
+ const HYDRATION_ERROR = {};
871
+ const ELEMENT_IS_NAMESPACED = 1;
872
+ const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1;
873
+ const ELEMENT_IS_INPUT = 1 << 2;
874
+ const UNINITIALIZED = Symbol();
875
+ function unresolved_hydratable(key, stack) {
876
+ {
877
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
878
+ }
879
+ }
880
+ const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
881
+ const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
882
+ const ATTR_REGEX = /[&"<]/g;
883
+ const CONTENT_REGEX = /[&<]/g;
884
+ function escape_html(value, is_attr) {
885
+ const str = String(value ?? "");
886
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
887
+ pattern.lastIndex = 0;
888
+ let escaped = "";
889
+ let last = 0;
890
+ while (pattern.test(str)) {
891
+ const i = pattern.lastIndex - 1;
892
+ const ch = str[i];
893
+ escaped += str.substring(last, i) + (ch === "&" ? "&amp;" : ch === '"' ? "&quot;" : "&lt;");
894
+ last = i + 1;
895
+ }
896
+ return escaped + str.substring(last);
897
+ }
898
+ const replacements = {
899
+ translate: /* @__PURE__ */ new Map([
900
+ [true, "yes"],
901
+ [false, "no"]
902
+ ])
903
+ };
904
+ function attr(name, value, is_boolean = false) {
905
+ if (name === "hidden" && value !== "until-found") {
906
+ is_boolean = true;
907
+ }
908
+ if (value == null || !value && is_boolean) return "";
909
+ const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
910
+ const assignment = is_boolean ? `=""` : `="${escape_html(normalized, true)}"`;
911
+ return ` ${name}${assignment}`;
912
+ }
913
+ function clsx(value) {
914
+ if (typeof value === "object") {
915
+ return clsx$1(value);
916
+ } else {
917
+ return value ?? "";
918
+ }
919
+ }
920
+ const whitespace = [..." \n\r\f \v\uFEFF"];
921
+ function to_class(value, hash, directives) {
922
+ var classname = value == null ? "" : "" + value;
923
+ if (hash) {
924
+ classname = classname ? classname + " " + hash : hash;
925
+ }
926
+ if (directives) {
927
+ for (var key of Object.keys(directives)) {
928
+ if (directives[key]) {
929
+ classname = classname ? classname + " " + key : key;
930
+ } else if (classname.length) {
931
+ var len = key.length;
932
+ var a = 0;
933
+ while ((a = classname.indexOf(key, a)) >= 0) {
934
+ var b = a + len;
935
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
936
+ classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
937
+ } else {
938
+ a = b;
939
+ }
940
+ }
941
+ }
942
+ }
943
+ }
944
+ return classname === "" ? null : classname;
945
+ }
946
+ function append_styles(styles, important = false) {
947
+ var separator = important ? " !important;" : ";";
948
+ var css = "";
949
+ for (var key of Object.keys(styles)) {
950
+ var value = styles[key];
951
+ if (value != null && value !== "") {
952
+ css += " " + key + ": " + value + separator;
953
+ }
954
+ }
955
+ return css;
956
+ }
957
+ function to_css_name(name) {
958
+ if (name[0] !== "-" || name[1] !== "-") {
959
+ return name.toLowerCase();
960
+ }
961
+ return name;
962
+ }
963
+ function to_style(value, styles) {
964
+ if (styles) {
965
+ var new_style = "";
966
+ var normal_styles;
967
+ var important_styles;
968
+ if (Array.isArray(styles)) {
969
+ normal_styles = styles[0];
970
+ important_styles = styles[1];
971
+ } else {
972
+ normal_styles = styles;
973
+ }
974
+ if (value) {
975
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
976
+ var in_str = false;
977
+ var in_apo = 0;
978
+ var in_comment = false;
979
+ var reserved_names = [];
980
+ if (normal_styles) {
981
+ reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
982
+ }
983
+ if (important_styles) {
984
+ reserved_names.push(...Object.keys(important_styles).map(to_css_name));
985
+ }
986
+ var start_index = 0;
987
+ var name_index = -1;
988
+ const len = value.length;
989
+ for (var i = 0; i < len; i++) {
990
+ var c = value[i];
991
+ if (in_comment) {
992
+ if (c === "/" && value[i - 1] === "*") {
993
+ in_comment = false;
994
+ }
995
+ } else if (in_str) {
996
+ if (in_str === c) {
997
+ in_str = false;
998
+ }
999
+ } else if (c === "/" && value[i + 1] === "*") {
1000
+ in_comment = true;
1001
+ } else if (c === '"' || c === "'") {
1002
+ in_str = c;
1003
+ } else if (c === "(") {
1004
+ in_apo++;
1005
+ } else if (c === ")") {
1006
+ in_apo--;
1007
+ }
1008
+ if (!in_comment && in_str === false && in_apo === 0) {
1009
+ if (c === ":" && name_index === -1) {
1010
+ name_index = i;
1011
+ } else if (c === ";" || i === len - 1) {
1012
+ if (name_index !== -1) {
1013
+ var name = to_css_name(value.substring(start_index, name_index).trim());
1014
+ if (!reserved_names.includes(name)) {
1015
+ if (c !== ";") {
1016
+ i++;
1017
+ }
1018
+ var property = value.substring(start_index, i).trim();
1019
+ new_style += " " + property + ";";
1020
+ }
1021
+ }
1022
+ start_index = i + 1;
1023
+ name_index = -1;
1024
+ }
1025
+ }
1026
+ }
1027
+ }
1028
+ if (normal_styles) {
1029
+ new_style += append_styles(normal_styles);
1030
+ }
1031
+ if (important_styles) {
1032
+ new_style += append_styles(important_styles, true);
1033
+ }
1034
+ new_style = new_style.trim();
1035
+ return new_style === "" ? null : new_style;
1036
+ }
1037
+ return value == null ? null : String(value);
1038
+ }
1039
+ const DOM_BOOLEAN_ATTRIBUTES = [
1040
+ "allowfullscreen",
1041
+ "async",
1042
+ "autofocus",
1043
+ "autoplay",
1044
+ "checked",
1045
+ "controls",
1046
+ "default",
1047
+ "disabled",
1048
+ "formnovalidate",
1049
+ "indeterminate",
1050
+ "inert",
1051
+ "ismap",
1052
+ "loop",
1053
+ "multiple",
1054
+ "muted",
1055
+ "nomodule",
1056
+ "novalidate",
1057
+ "open",
1058
+ "playsinline",
1059
+ "readonly",
1060
+ "required",
1061
+ "reversed",
1062
+ "seamless",
1063
+ "selected",
1064
+ "webkitdirectory",
1065
+ "defer",
1066
+ "disablepictureinpicture",
1067
+ "disableremoteplayback"
1068
+ ];
1069
+ function is_boolean_attribute(name) {
1070
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
1071
+ }
1072
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
1073
+ function is_passive_event(name) {
1074
+ return PASSIVE_EVENTS.includes(name);
1075
+ }
1076
+ const INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1077
+ function render(component, options = {}) {
1078
+ if (options.csp?.hash && options.csp.nonce) {
1079
+ invalid_csp();
1080
+ }
1081
+ return Renderer.render(
1082
+ /** @type {Component<Props>} */
1083
+ component,
1084
+ options
1085
+ );
1086
+ }
1087
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
1088
+ if (styles) {
1089
+ attrs.style = to_style(attrs.style, styles);
1090
+ }
1091
+ if (attrs.class) {
1092
+ attrs.class = clsx(attrs.class);
1093
+ }
1094
+ if (css_hash || classes) {
1095
+ attrs.class = to_class(attrs.class, css_hash, classes);
1096
+ }
1097
+ let attr_str = "";
1098
+ let name;
1099
+ const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
1100
+ const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
1101
+ const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
1102
+ for (name of Object.keys(attrs)) {
1103
+ if (typeof attrs[name] === "function") continue;
1104
+ if (name[0] === "$" && name[1] === "$") continue;
1105
+ if (name === "" || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
1106
+ var value = attrs[name];
1107
+ var lower = name.toLowerCase();
1108
+ if (lowercase) name = lower;
1109
+ if (lower.length > 2 && lower.startsWith("on")) continue;
1110
+ if (is_input) {
1111
+ if (name === "defaultvalue" || name === "defaultchecked") {
1112
+ name = name === "defaultvalue" ? "value" : "checked";
1113
+ if (attrs[name]) continue;
1114
+ }
1115
+ }
1116
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
1117
+ }
1118
+ return attr_str;
1119
+ }
1120
+ function stringify(value) {
1121
+ return typeof value === "string" ? value : value == null ? "" : value + "";
1122
+ }
1123
+ function attr_class(value, hash, directives) {
1124
+ var result = to_class(value, hash, directives);
1125
+ return result ? ` class="${escape_html(result, true)}"` : "";
1126
+ }
1127
+ function attr_style(value, directives) {
1128
+ var result = to_style(value, directives);
1129
+ return result ? ` style="${escape_html(result, true)}"` : "";
1130
+ }
1131
+ function ensure_array_like(array_like_or_iterator) {
1132
+ if (array_like_or_iterator) {
1133
+ return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
1134
+ }
1135
+ return [];
1136
+ }
1137
+ function once(get_value) {
1138
+ let value = (
1139
+ /** @type {V} */
1140
+ UNINITIALIZED
1141
+ );
1142
+ return () => {
1143
+ if (value === UNINITIALIZED) {
1144
+ value = get_value();
1145
+ }
1146
+ return value;
1147
+ };
1148
+ }
1149
+ function derived(fn) {
1150
+ const get_value = ssr_context === null ? fn : once(fn);
1151
+ let updated_value;
1152
+ return function(new_value) {
1153
+ if (arguments.length === 0) {
1154
+ return updated_value ?? get_value();
1155
+ }
1156
+ updated_value = new_value;
1157
+ return updated_value;
1158
+ };
1159
+ }
1160
+ let text_encoder;
1161
+ let crypto;
1162
+ const obfuscated_import = (module_name) => import(
1163
+ /* @vite-ignore */
1164
+ module_name
1165
+ );
1166
+ async function sha256(data) {
1167
+ text_encoder ??= new TextEncoder();
1168
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
1169
+ // @ts-ignore - we don't install node types in the prod build
1170
+ // don't use import('node:crypto') directly because static analysers will think we rely on node when we don't
1171
+ (await obfuscated_import("node:crypto")).webcrypto
1172
+ );
1173
+ const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
1174
+ return base64_encode(hash_buffer);
1175
+ }
1176
+ function base64_encode(bytes) {
1177
+ if (globalThis.Buffer) {
1178
+ return globalThis.Buffer.from(bytes).toString("base64");
1179
+ }
1180
+ let binary = "";
1181
+ for (let i = 0; i < bytes.length; i++) {
1182
+ binary += String.fromCharCode(bytes[i]);
1183
+ }
1184
+ return btoa(binary);
1185
+ }
1186
+ class Renderer {
1187
+ /**
1188
+ * The contents of the renderer.
1189
+ * @type {RendererItem[]}
1190
+ */
1191
+ #out = [];
1192
+ /**
1193
+ * Any `onDestroy` callbacks registered during execution of this renderer.
1194
+ * @type {(() => void)[] | undefined}
1195
+ */
1196
+ #on_destroy = void 0;
1197
+ /**
1198
+ * Whether this renderer is a component body.
1199
+ * @type {boolean}
1200
+ */
1201
+ #is_component_body = false;
1202
+ /**
1203
+ * If set, this renderer is an error boundary. When async collection
1204
+ * of the children fails, the failed snippet is rendered instead.
1205
+ * @type {{
1206
+ * failed: (renderer: Renderer, error: unknown, reset: () => void) => void;
1207
+ * transformError: (error: unknown) => unknown;
1208
+ * context: SSRContext | null;
1209
+ * } | null}
1210
+ */
1211
+ #boundary = null;
1212
+ /**
1213
+ * The type of string content that this renderer is accumulating.
1214
+ * @type {RendererType}
1215
+ */
1216
+ type;
1217
+ /** @type {Renderer | undefined} */
1218
+ #parent;
1219
+ /**
1220
+ * Asynchronous work associated with this renderer
1221
+ * @type {Promise<void> | undefined}
1222
+ */
1223
+ promise = void 0;
1224
+ /**
1225
+ * State which is associated with the content tree as a whole.
1226
+ * It will be re-exposed, uncopied, on all children.
1227
+ * @type {SSRState}
1228
+ * @readonly
1229
+ */
1230
+ global;
1231
+ /**
1232
+ * State that is local to the branch it is declared in.
1233
+ * It will be shallow-copied to all children.
1234
+ *
1235
+ * @type {{ select_value: string | undefined }}
1236
+ */
1237
+ local;
1238
+ /**
1239
+ * @param {SSRState} global
1240
+ * @param {Renderer | undefined} [parent]
1241
+ */
1242
+ constructor(global, parent) {
1243
+ this.#parent = parent;
1244
+ this.global = global;
1245
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
1246
+ this.type = parent ? parent.type : "body";
1247
+ }
1248
+ /**
1249
+ * @param {(renderer: Renderer) => void} fn
1250
+ */
1251
+ head(fn) {
1252
+ const head = new Renderer(this.global, this);
1253
+ head.type = "head";
1254
+ this.#out.push(head);
1255
+ head.child(fn);
1256
+ }
1257
+ /**
1258
+ * @param {Array<Promise<void>>} blockers
1259
+ * @param {(renderer: Renderer) => void} fn
1260
+ */
1261
+ async_block(blockers, fn) {
1262
+ this.#out.push(BLOCK_OPEN);
1263
+ this.async(blockers, fn);
1264
+ this.#out.push(BLOCK_CLOSE);
1265
+ }
1266
+ /**
1267
+ * @param {Array<Promise<void>>} blockers
1268
+ * @param {(renderer: Renderer) => void} fn
1269
+ */
1270
+ async(blockers, fn) {
1271
+ let callback = fn;
1272
+ if (blockers.length > 0) {
1273
+ const context = ssr_context;
1274
+ callback = (renderer) => {
1275
+ return Promise.all(blockers).then(() => {
1276
+ const previous_context = ssr_context;
1277
+ try {
1278
+ set_ssr_context(context);
1279
+ return fn(renderer);
1280
+ } finally {
1281
+ set_ssr_context(previous_context);
1282
+ }
1283
+ });
1284
+ };
1285
+ }
1286
+ this.child(callback);
1287
+ }
1288
+ /**
1289
+ * @param {Array<() => void>} thunks
1290
+ */
1291
+ run(thunks) {
1292
+ const context = ssr_context;
1293
+ let promise = Promise.resolve(thunks[0]());
1294
+ const promises = [promise];
1295
+ for (const fn of thunks.slice(1)) {
1296
+ promise = promise.then(() => {
1297
+ const previous_context = ssr_context;
1298
+ set_ssr_context(context);
1299
+ try {
1300
+ return fn();
1301
+ } finally {
1302
+ set_ssr_context(previous_context);
1303
+ }
1304
+ });
1305
+ promises.push(promise);
1306
+ }
1307
+ promise.catch(noop);
1308
+ this.promise = promise;
1309
+ return promises;
1310
+ }
1311
+ /**
1312
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
1313
+ */
1314
+ child_block(fn) {
1315
+ this.#out.push(BLOCK_OPEN);
1316
+ this.child(fn);
1317
+ this.#out.push(BLOCK_CLOSE);
1318
+ }
1319
+ /**
1320
+ * Create a child renderer. The child renderer inherits the state from the parent,
1321
+ * but has its own content.
1322
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
1323
+ */
1324
+ child(fn) {
1325
+ const child = new Renderer(this.global, this);
1326
+ this.#out.push(child);
1327
+ const parent = ssr_context;
1328
+ set_ssr_context({
1329
+ ...ssr_context,
1330
+ p: parent,
1331
+ c: null,
1332
+ r: child
1333
+ });
1334
+ const result = fn(child);
1335
+ set_ssr_context(parent);
1336
+ if (result instanceof Promise) {
1337
+ result.catch(noop);
1338
+ result.finally(() => set_ssr_context(null)).catch(noop);
1339
+ if (child.global.mode === "sync") {
1340
+ await_invalid();
1341
+ }
1342
+ child.promise = result;
1343
+ }
1344
+ return child;
1345
+ }
1346
+ /**
1347
+ * Render children inside an error boundary. If the children throw and the API-level
1348
+ * `transformError` transform handles the error (doesn't re-throw), the `failed` snippet is
1349
+ * rendered instead. Otherwise the error propagates.
1350
+ *
1351
+ * @param {{ failed?: (renderer: Renderer, error: unknown, reset: () => void) => void }} props
1352
+ * @param {(renderer: Renderer) => MaybePromise<void>} children_fn
1353
+ */
1354
+ boundary(props, children_fn) {
1355
+ const child = new Renderer(this.global, this);
1356
+ this.#out.push(child);
1357
+ const parent_context = ssr_context;
1358
+ if (props.failed) {
1359
+ child.#boundary = {
1360
+ failed: props.failed,
1361
+ transformError: this.global.transformError,
1362
+ context: parent_context
1363
+ };
1364
+ }
1365
+ set_ssr_context({
1366
+ ...ssr_context,
1367
+ p: parent_context,
1368
+ c: null,
1369
+ r: child
1370
+ });
1371
+ try {
1372
+ const result = children_fn(child);
1373
+ set_ssr_context(parent_context);
1374
+ if (result instanceof Promise) {
1375
+ if (child.global.mode === "sync") {
1376
+ await_invalid();
1377
+ }
1378
+ result.catch(noop);
1379
+ child.promise = result;
1380
+ }
1381
+ } catch (error) {
1382
+ set_ssr_context(parent_context);
1383
+ const failed_snippet = props.failed;
1384
+ if (!failed_snippet) throw error;
1385
+ const result = this.global.transformError(error);
1386
+ child.#out.length = 0;
1387
+ child.#boundary = null;
1388
+ if (result instanceof Promise) {
1389
+ if (this.global.mode === "sync") {
1390
+ await_invalid();
1391
+ }
1392
+ child.promise = /** @type {Promise<unknown>} */
1393
+ result.then((transformed) => {
1394
+ set_ssr_context(parent_context);
1395
+ child.#out.push(Renderer.#serialize_failed_boundary(transformed));
1396
+ failed_snippet(child, transformed, noop);
1397
+ child.#out.push(BLOCK_CLOSE);
1398
+ });
1399
+ child.promise.catch(noop);
1400
+ } else {
1401
+ child.#out.push(Renderer.#serialize_failed_boundary(result));
1402
+ failed_snippet(child, result, noop);
1403
+ child.#out.push(BLOCK_CLOSE);
1404
+ }
1405
+ }
1406
+ }
1407
+ /**
1408
+ * Create a component renderer. The component renderer inherits the state from the parent,
1409
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
1410
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
1411
+ * @param {Function} [component_fn]
1412
+ * @returns {void}
1413
+ */
1414
+ component(fn, component_fn) {
1415
+ push();
1416
+ const child = this.child(fn);
1417
+ child.#is_component_body = true;
1418
+ pop();
1419
+ }
1420
+ /**
1421
+ * @param {Record<string, any>} attrs
1422
+ * @param {(renderer: Renderer) => void} fn
1423
+ * @param {string | undefined} [css_hash]
1424
+ * @param {Record<string, boolean> | undefined} [classes]
1425
+ * @param {Record<string, string> | undefined} [styles]
1426
+ * @param {number | undefined} [flags]
1427
+ * @param {boolean | undefined} [is_rich]
1428
+ * @returns {void}
1429
+ */
1430
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
1431
+ const { value, ...select_attrs } = attrs;
1432
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
1433
+ this.child((renderer) => {
1434
+ renderer.local.select_value = value;
1435
+ fn(renderer);
1436
+ });
1437
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
1438
+ }
1439
+ /**
1440
+ * @param {Record<string, any>} attrs
1441
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
1442
+ * @param {string | undefined} [css_hash]
1443
+ * @param {Record<string, boolean> | undefined} [classes]
1444
+ * @param {Record<string, string> | undefined} [styles]
1445
+ * @param {number | undefined} [flags]
1446
+ * @param {boolean | undefined} [is_rich]
1447
+ */
1448
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
1449
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
1450
+ const close = (renderer, value, { head, body: body2 }) => {
1451
+ if (has_own_property.call(attrs, "value")) {
1452
+ value = attrs.value;
1453
+ }
1454
+ if (value === this.local.select_value) {
1455
+ renderer.#out.push(' selected=""');
1456
+ }
1457
+ renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
1458
+ if (head) {
1459
+ renderer.head((child) => child.push(head));
1460
+ }
1461
+ };
1462
+ if (typeof body === "function") {
1463
+ this.child((renderer) => {
1464
+ const r = new Renderer(this.global, this);
1465
+ body(r);
1466
+ if (this.global.mode === "async") {
1467
+ return r.#collect_content_async().then((content) => {
1468
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
1469
+ });
1470
+ } else {
1471
+ const content = r.#collect_content();
1472
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
1473
+ }
1474
+ });
1475
+ } else {
1476
+ close(this, body, { body: escape_html(body) });
1477
+ }
1478
+ }
1479
+ /**
1480
+ * @param {(renderer: Renderer) => void} fn
1481
+ */
1482
+ title(fn) {
1483
+ const path = this.get_path();
1484
+ const close = (head) => {
1485
+ this.global.set_title(head, path);
1486
+ };
1487
+ this.child((renderer) => {
1488
+ const r = new Renderer(renderer.global, renderer);
1489
+ fn(r);
1490
+ if (renderer.global.mode === "async") {
1491
+ return r.#collect_content_async().then((content) => {
1492
+ close(content.head);
1493
+ });
1494
+ } else {
1495
+ const content = r.#collect_content();
1496
+ close(content.head);
1497
+ }
1498
+ });
1499
+ }
1500
+ /**
1501
+ * @param {string | (() => Promise<string>)} content
1502
+ */
1503
+ push(content) {
1504
+ if (typeof content === "function") {
1505
+ this.child(async (renderer) => renderer.push(await content()));
1506
+ } else {
1507
+ this.#out.push(content);
1508
+ }
1509
+ }
1510
+ /**
1511
+ * @param {() => void} fn
1512
+ */
1513
+ on_destroy(fn) {
1514
+ (this.#on_destroy ??= []).push(fn);
1515
+ }
1516
+ /**
1517
+ * @returns {number[]}
1518
+ */
1519
+ get_path() {
1520
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
1521
+ }
1522
+ /**
1523
+ * @deprecated this is needed for legacy component bindings
1524
+ */
1525
+ copy() {
1526
+ const copy = new Renderer(this.global, this.#parent);
1527
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
1528
+ copy.promise = this.promise;
1529
+ return copy;
1530
+ }
1531
+ /**
1532
+ * @param {Renderer} other
1533
+ * @deprecated this is needed for legacy component bindings
1534
+ */
1535
+ subsume(other) {
1536
+ if (this.global.mode !== other.global.mode) {
1537
+ throw new Error(
1538
+ "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
1539
+ );
1540
+ }
1541
+ this.local = other.local;
1542
+ this.#out = other.#out.map((item, i) => {
1543
+ const current = this.#out[i];
1544
+ if (current instanceof Renderer && item instanceof Renderer) {
1545
+ current.subsume(item);
1546
+ return current;
1547
+ }
1548
+ return item;
1549
+ });
1550
+ this.promise = other.promise;
1551
+ this.type = other.type;
1552
+ }
1553
+ get length() {
1554
+ return this.#out.length;
1555
+ }
1556
+ /**
1557
+ * Creates the hydration comment that marks the start of a failed boundary.
1558
+ * The error is JSON-serialized and embedded inside an HTML comment for the client
1559
+ * to parse during hydration. The JSON is escaped to prevent `-->` or `<!--` sequences
1560
+ * from breaking out of the comment (XSS). Uses unicode escapes which `JSON.parse()`
1561
+ * handles transparently.
1562
+ * @param {unknown} error
1563
+ * @returns {string}
1564
+ */
1565
+ static #serialize_failed_boundary(error) {
1566
+ var json = JSON.stringify(error);
1567
+ var escaped = json.replace(/>/g, "\\u003e").replace(/</g, "\\u003c");
1568
+ return `<!--${HYDRATION_START_FAILED}${escaped}-->`;
1569
+ }
1570
+ /**
1571
+ * Only available on the server and when compiling with the `server` option.
1572
+ * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
1573
+ * @template {Record<string, any>} Props
1574
+ * @param {Component<Props>} component
1575
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
1576
+ * @returns {RenderOutput}
1577
+ */
1578
+ static render(component, options = {}) {
1579
+ let sync;
1580
+ const result = (
1581
+ /** @type {RenderOutput} */
1582
+ {}
1583
+ );
1584
+ Object.defineProperties(result, {
1585
+ html: {
1586
+ get: () => {
1587
+ return (sync ??= Renderer.#render(component, options)).body;
1588
+ }
1589
+ },
1590
+ head: {
1591
+ get: () => {
1592
+ return (sync ??= Renderer.#render(component, options)).head;
1593
+ }
1594
+ },
1595
+ body: {
1596
+ get: () => {
1597
+ return (sync ??= Renderer.#render(component, options)).body;
1598
+ }
1599
+ },
1600
+ hashes: {
1601
+ value: {
1602
+ script: ""
1603
+ }
1604
+ },
1605
+ then: {
1606
+ value: (
1607
+ /**
1608
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
1609
+ *
1610
+ * @template TResult1
1611
+ * @template [TResult2=never]
1612
+ * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
1613
+ * @param { (reason: unknown) => TResult2 } onrejected
1614
+ */
1615
+ (onfulfilled, onrejected) => {
1616
+ {
1617
+ const result2 = sync ??= Renderer.#render(component, options);
1618
+ const user_result = onfulfilled({
1619
+ head: result2.head,
1620
+ body: result2.body,
1621
+ html: result2.body,
1622
+ hashes: { script: [] }
1623
+ });
1624
+ return Promise.resolve(user_result);
1625
+ }
1626
+ }
1627
+ )
1628
+ }
1629
+ });
1630
+ return result;
1631
+ }
1632
+ /**
1633
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
1634
+ * after awaiting `collect_async`.
1635
+ *
1636
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
1637
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
1638
+ * @returns {Iterable<() => void>}
1639
+ */
1640
+ *#collect_on_destroy() {
1641
+ for (const component of this.#traverse_components()) {
1642
+ yield* component.#collect_ondestroy();
1643
+ }
1644
+ }
1645
+ /**
1646
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
1647
+ * @returns {Iterable<Renderer>}
1648
+ */
1649
+ *#traverse_components() {
1650
+ for (const child of this.#out) {
1651
+ if (typeof child !== "string") {
1652
+ yield* child.#traverse_components();
1653
+ }
1654
+ }
1655
+ if (this.#is_component_body) {
1656
+ yield this;
1657
+ }
1658
+ }
1659
+ /**
1660
+ * @returns {Iterable<() => void>}
1661
+ */
1662
+ *#collect_ondestroy() {
1663
+ if (this.#on_destroy) {
1664
+ for (const fn of this.#on_destroy) {
1665
+ yield fn;
1666
+ }
1667
+ }
1668
+ for (const child of this.#out) {
1669
+ if (child instanceof Renderer && !child.#is_component_body) {
1670
+ yield* child.#collect_ondestroy();
1671
+ }
1672
+ }
1673
+ }
1674
+ /**
1675
+ * Render a component. Throws if any of the children are performing asynchronous work.
1676
+ *
1677
+ * @template {Record<string, any>} Props
1678
+ * @param {Component<Props>} component
1679
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
1680
+ * @returns {AccumulatedContent}
1681
+ */
1682
+ static #render(component, options) {
1683
+ var previous_context = ssr_context;
1684
+ try {
1685
+ const renderer = Renderer.#open_render("sync", component, options);
1686
+ const content = renderer.#collect_content();
1687
+ return Renderer.#close_render(content, renderer);
1688
+ } finally {
1689
+ abort();
1690
+ set_ssr_context(previous_context);
1691
+ }
1692
+ }
1693
+ /**
1694
+ * Render a component.
1695
+ *
1696
+ * @template {Record<string, any>} Props
1697
+ * @param {Component<Props>} component
1698
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
1699
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
1700
+ */
1701
+ static async #render_async(component, options) {
1702
+ const previous_context = ssr_context;
1703
+ try {
1704
+ const renderer = Renderer.#open_render("async", component, options);
1705
+ const content = await renderer.#collect_content_async();
1706
+ const hydratables = await renderer.#collect_hydratables();
1707
+ if (hydratables !== null) {
1708
+ content.head = hydratables + content.head;
1709
+ }
1710
+ return Renderer.#close_render(content, renderer);
1711
+ } finally {
1712
+ set_ssr_context(previous_context);
1713
+ abort();
1714
+ }
1715
+ }
1716
+ /**
1717
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
1718
+ * @param {AccumulatedContent} content
1719
+ * @returns {AccumulatedContent}
1720
+ */
1721
+ #collect_content(content = { head: "", body: "" }) {
1722
+ for (const item of this.#out) {
1723
+ if (typeof item === "string") {
1724
+ content[this.type] += item;
1725
+ } else if (item instanceof Renderer) {
1726
+ item.#collect_content(content);
1727
+ }
1728
+ }
1729
+ return content;
1730
+ }
1731
+ /**
1732
+ * Collect all of the code from the `out` array and return it as a string.
1733
+ * @param {AccumulatedContent} content
1734
+ * @returns {Promise<AccumulatedContent>}
1735
+ */
1736
+ async #collect_content_async(content = { head: "", body: "" }) {
1737
+ await this.promise;
1738
+ for (const item of this.#out) {
1739
+ if (typeof item === "string") {
1740
+ content[this.type] += item;
1741
+ } else if (item instanceof Renderer) {
1742
+ if (item.#boundary) {
1743
+ const boundary_content = { head: "", body: "" };
1744
+ try {
1745
+ await item.#collect_content_async(boundary_content);
1746
+ content.head += boundary_content.head;
1747
+ content.body += boundary_content.body;
1748
+ } catch (error) {
1749
+ const { context, failed, transformError } = item.#boundary;
1750
+ set_ssr_context(context);
1751
+ let promise = transformError(error);
1752
+ set_ssr_context(null);
1753
+ let transformed = await promise;
1754
+ set_ssr_context(context);
1755
+ const failed_renderer = new Renderer(item.global, item);
1756
+ failed_renderer.type = item.type;
1757
+ failed_renderer.#out.push(Renderer.#serialize_failed_boundary(transformed));
1758
+ failed(failed_renderer, transformed, noop);
1759
+ failed_renderer.#out.push(BLOCK_CLOSE);
1760
+ await failed_renderer.#collect_content_async(content);
1761
+ }
1762
+ } else {
1763
+ await item.#collect_content_async(content);
1764
+ }
1765
+ }
1766
+ }
1767
+ return content;
1768
+ }
1769
+ async #collect_hydratables() {
1770
+ const ctx = get_render_context().hydratable;
1771
+ for (const [_, key] of ctx.unresolved_promises) {
1772
+ unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
1773
+ }
1774
+ for (const comparison of ctx.comparisons) {
1775
+ await comparison;
1776
+ }
1777
+ return await this.#hydratable_block(ctx);
1778
+ }
1779
+ /**
1780
+ * @template {Record<string, any>} Props
1781
+ * @param {'sync' | 'async'} mode
1782
+ * @param {import('svelte').Component<Props>} component
1783
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
1784
+ * @returns {Renderer}
1785
+ */
1786
+ static #open_render(mode, component, options) {
1787
+ if (options.idPrefix?.includes("--")) {
1788
+ invalid_id_prefix();
1789
+ }
1790
+ var previous_context = ssr_context;
1791
+ try {
1792
+ const renderer = new Renderer(
1793
+ new SSRState(
1794
+ mode,
1795
+ options.idPrefix ? options.idPrefix + "-" : "",
1796
+ options.csp,
1797
+ options.transformError
1798
+ )
1799
+ );
1800
+ const context = { p: null, c: options.context ?? null, r: renderer };
1801
+ set_ssr_context(context);
1802
+ renderer.push(BLOCK_OPEN);
1803
+ component(renderer, options.props ?? {});
1804
+ renderer.push(BLOCK_CLOSE);
1805
+ return renderer;
1806
+ } finally {
1807
+ set_ssr_context(previous_context);
1808
+ }
1809
+ }
1810
+ /**
1811
+ * @param {AccumulatedContent} content
1812
+ * @param {Renderer} renderer
1813
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
1814
+ */
1815
+ static #close_render(content, renderer) {
1816
+ for (const cleanup of renderer.#collect_on_destroy()) {
1817
+ cleanup();
1818
+ }
1819
+ let head = content.head + renderer.global.get_title();
1820
+ let body = content.body;
1821
+ for (const { hash, code } of renderer.global.css) {
1822
+ head += `<style id="${hash}">${code}</style>`;
1823
+ }
1824
+ return {
1825
+ head,
1826
+ body,
1827
+ hashes: {
1828
+ script: renderer.global.csp.script_hashes
1829
+ }
1830
+ };
1831
+ }
1832
+ /**
1833
+ * @param {HydratableContext} ctx
1834
+ */
1835
+ async #hydratable_block(ctx) {
1836
+ if (ctx.lookup.size === 0) {
1837
+ return null;
1838
+ }
1839
+ let entries = [];
1840
+ let has_promises = false;
1841
+ for (const [k, v] of ctx.lookup) {
1842
+ if (v.promises) {
1843
+ has_promises = true;
1844
+ for (const p of v.promises) await p;
1845
+ }
1846
+ entries.push(`[${uneval(k)},${v.serialized}]`);
1847
+ }
1848
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
1849
+ if (has_promises) {
1850
+ prelude = `const r = (v) => Promise.resolve(v);
1851
+ ${prelude}`;
1852
+ }
1853
+ const body = `
1854
+ {
1855
+ ${prelude}
1856
+
1857
+ for (const [k, v] of [
1858
+ ${entries.join(",\n ")}
1859
+ ]) {
1860
+ h.set(k, v);
1861
+ }
1862
+ }
1863
+ `;
1864
+ let csp_attr = "";
1865
+ if (this.global.csp.nonce) {
1866
+ csp_attr = ` nonce="${this.global.csp.nonce}"`;
1867
+ } else if (this.global.csp.hash) {
1868
+ const hash = await sha256(body);
1869
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
1870
+ }
1871
+ return `
1872
+ <script${csp_attr}>${body}<\/script>`;
1873
+ }
1874
+ }
1875
+ class SSRState {
1876
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
1877
+ csp;
1878
+ /** @readonly @type {'sync' | 'async'} */
1879
+ mode;
1880
+ /** @readonly @type {() => string} */
1881
+ uid;
1882
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
1883
+ css = /* @__PURE__ */ new Set();
1884
+ /**
1885
+ * `transformError` passed to `render`. Called when an error boundary catches an error.
1886
+ * Throws by default if unset in `render`.
1887
+ * @type {(error: unknown) => unknown}
1888
+ */
1889
+ transformError;
1890
+ /** @type {{ path: number[], value: string }} */
1891
+ #title = { path: [], value: "" };
1892
+ /**
1893
+ * @param {'sync' | 'async'} mode
1894
+ * @param {string} id_prefix
1895
+ * @param {Csp} csp
1896
+ * @param {((error: unknown) => unknown) | undefined} [transformError]
1897
+ */
1898
+ constructor(mode, id_prefix = "", csp = { hash: false }, transformError) {
1899
+ this.mode = mode;
1900
+ this.csp = { ...csp, script_hashes: [] };
1901
+ this.transformError = transformError ?? ((error) => {
1902
+ throw error;
1903
+ });
1904
+ let uid = 1;
1905
+ this.uid = () => `${id_prefix}s${uid++}`;
1906
+ }
1907
+ get_title() {
1908
+ return this.#title.value;
1909
+ }
1910
+ /**
1911
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
1912
+ * from earlier than or equal to the current value.
1913
+ * @param {string} value
1914
+ * @param {number[]} path
1915
+ */
1916
+ set_title(value, path) {
1917
+ const current = this.#title.path;
1918
+ let i = 0;
1919
+ let l = Math.min(path.length, current.length);
1920
+ while (i < l && path[i] === current[i]) i += 1;
1921
+ if (path[i] === void 0) return;
1922
+ if (current[i] === void 0 || path[i] > current[i]) {
1923
+ this.#title.path = path;
1924
+ this.#title.value = value;
1925
+ }
1926
+ }
1927
+ }
1928
+
1929
+ export { clsx as $, ASYNC as A, BLOCK_EFFECT as B, CLASS_CACHE as C, DERIVED as D, EAGER_EFFECT as E, ROOT_EFFECT as F, STALE_REACTION as G, HEAD_EFFECT as H, INERT as I, STATE_SYMBOL as J, STYLE_CACHE as K, LEGACY_PROPS as L, MANAGED_EFFECT as M, NAN as N, UNINITIALIZED as O, POSITIVE_INFINITY as P, USER_EFFECT as Q, REACTION_IS_UPDATING as R, SPARSE as S, TEXT_CACHE as T, UNDEFINED as U, array_from as V, WAS_MARKED as W, array_prototype as X, attr as Y, attr_class as Z, attr_style as _, ATTRIBUTES_CACHE as a, deferred as a0, define_property as a1, derived as a2, ensure_array_like as a3, enumerable_symbols as a4, escape_html as a5, getContext as a6, get_descriptor as a7, get_prototype_of as a8, get_type as a9, includes as aa, index_of as ab, is_array as ac, is_extensible as ad, is_passive_event as ae, is_plain_object as af, is_primitive as ag, is_valid_array_index as ah, is_valid_array_len as ai, noop as aj, object_prototype as ak, render as al, run_all as am, setContext as an, stringify as ao, stringify_key as ap, stringify_string as aq, uneval as ar, valid_array_indices as as, BOUNDARY_EFFECT as b, BRANCH_EFFECT as c, CLEAN as d, COMMENT_NODE as e, CONNECTED as f, DESTROYED as g, DESTROYING as h, DIRTY as i, DevalueError as j, EFFECT as k, EFFECT_PRESERVED as l, EFFECT_TRANSPARENT as m, ERROR_VALUE as n, HOLE as o, HYDRATION_END as p, HYDRATION_ERROR as q, HYDRATION_START as r, HYDRATION_START_ELSE as s, HYDRATION_START_FAILED as t, MAX_ARRAY_INDEX as u, MAYBE_DIRTY as v, NEGATIVE_INFINITY as w, NEGATIVE_ZERO as x, REACTION_RAN as y, RENDER_EFFECT as z };
1930
+ //# sourceMappingURL=renderer-DdMvhZZr.js.map