clawmini 0.0.1

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 (469) hide show
  1. package/.gemini/settings.json +46 -0
  2. package/.prettierrc +7 -0
  3. package/GEMINI.md +11 -0
  4. package/README.md +137 -0
  5. package/dist/adapter-discord/index.d.mts +5 -0
  6. package/dist/adapter-discord/index.d.mts.map +1 -0
  7. package/dist/adapter-discord/index.mjs +456 -0
  8. package/dist/adapter-discord/index.mjs.map +1 -0
  9. package/dist/chats-DKgTeU7i.mjs +91 -0
  10. package/dist/chats-DKgTeU7i.mjs.map +1 -0
  11. package/dist/chats-Zd_HXDHx.mjs +29 -0
  12. package/dist/chats-Zd_HXDHx.mjs.map +1 -0
  13. package/dist/cli/index.d.mts +1 -0
  14. package/dist/cli/index.mjs +850 -0
  15. package/dist/cli/index.mjs.map +1 -0
  16. package/dist/cli/lite.d.mts +1 -0
  17. package/dist/cli/lite.mjs +4434 -0
  18. package/dist/cli/lite.mjs.map +1 -0
  19. package/dist/daemon/index.d.mts +5 -0
  20. package/dist/daemon/index.d.mts.map +1 -0
  21. package/dist/daemon/index.mjs +1222 -0
  22. package/dist/daemon/index.mjs.map +1 -0
  23. package/dist/fetch-BjZVyU3Z.mjs +37 -0
  24. package/dist/fetch-BjZVyU3Z.mjs.map +1 -0
  25. package/dist/fs-B5wW0oaH.mjs +14 -0
  26. package/dist/fs-B5wW0oaH.mjs.map +1 -0
  27. package/dist/lite-Dl7WXyaH.mjs +80 -0
  28. package/dist/lite-Dl7WXyaH.mjs.map +1 -0
  29. package/dist/rolldown-runtime-95iHPtFO.mjs +18 -0
  30. package/dist/web/_app/env.js +1 -0
  31. package/dist/web/_app/immutable/assets/0.GI4C4dpV.css +1 -0
  32. package/dist/web/_app/immutable/chunks/B5abRDXp.js +1 -0
  33. package/dist/web/_app/immutable/chunks/B8yYFADm.js +1 -0
  34. package/dist/web/_app/immutable/chunks/BPy8HLo7.js +5 -0
  35. package/dist/web/_app/immutable/chunks/Bi0jeV7Q.js +1 -0
  36. package/dist/web/_app/immutable/chunks/BmUXQ3wy.js +2 -0
  37. package/dist/web/_app/immutable/chunks/C3k55nDF.js +1 -0
  38. package/dist/web/_app/immutable/chunks/COekwvP2.js +1 -0
  39. package/dist/web/_app/immutable/chunks/CSvS_NwK.js +1 -0
  40. package/dist/web/_app/immutable/chunks/CpaGRn9L.js +1 -0
  41. package/dist/web/_app/immutable/chunks/CyNaE55B.js +1 -0
  42. package/dist/web/_app/immutable/chunks/DG5RZBw-.js +2 -0
  43. package/dist/web/_app/immutable/chunks/Dc-UOHw9.js +1 -0
  44. package/dist/web/_app/immutable/chunks/DcrmIfTj.js +1 -0
  45. package/dist/web/_app/immutable/chunks/ZkLyk0mE.js +1 -0
  46. package/dist/web/_app/immutable/entry/app.B-vZe7PN.js +2 -0
  47. package/dist/web/_app/immutable/entry/start.oP1AgKhs.js +1 -0
  48. package/dist/web/_app/immutable/nodes/0.B5WFN0zw.js +1 -0
  49. package/dist/web/_app/immutable/nodes/1.D1wtJb2k.js +1 -0
  50. package/dist/web/_app/immutable/nodes/2.CK3CLC0f.js +1 -0
  51. package/dist/web/_app/immutable/nodes/3.BB5wCoBf.js +4 -0
  52. package/dist/web/_app/immutable/nodes/4.Dr2jvAXK.js +1 -0
  53. package/dist/web/_app/immutable/nodes/5.BJl7oM3b.js +1 -0
  54. package/dist/web/_app/version.json +1 -0
  55. package/dist/web/index.html +37 -0
  56. package/dist/web/robots.txt +3 -0
  57. package/dist/workspace-CSgfo_2J.mjs +383 -0
  58. package/dist/workspace-CSgfo_2J.mjs.map +1 -0
  59. package/docs/01_chats/development_log.md +36 -0
  60. package/docs/01_chats/notes.md +27 -0
  61. package/docs/01_chats/prd.md +47 -0
  62. package/docs/01_chats/questions.md +19 -0
  63. package/docs/01_chats/tickets.md +67 -0
  64. package/docs/02_sessions/development_log.md +79 -0
  65. package/docs/02_sessions/notes.md +40 -0
  66. package/docs/02_sessions/prd.md +75 -0
  67. package/docs/02_sessions/questions.md +7 -0
  68. package/docs/02_sessions/tickets.md +68 -0
  69. package/docs/03_web_interface/development_log.md +60 -0
  70. package/docs/03_web_interface/notes.md +29 -0
  71. package/docs/03_web_interface/prd.md +42 -0
  72. package/docs/03_web_interface/questions.md +8 -0
  73. package/docs/03_web_interface/tickets.md +59 -0
  74. package/docs/04_agents/development_log.md +54 -0
  75. package/docs/04_agents/notes.md +45 -0
  76. package/docs/04_agents/prd.md +47 -0
  77. package/docs/04_agents/questions.md +13 -0
  78. package/docs/04_agents/tickets.md +107 -0
  79. package/docs/05_routers/development_log.md +13 -0
  80. package/docs/05_routers/notes.md +40 -0
  81. package/docs/05_routers/prd.md +55 -0
  82. package/docs/05_routers/questions.md +21 -0
  83. package/docs/05_routers/tickets.md +109 -0
  84. package/docs/06_agent_templates/development_log.md +38 -0
  85. package/docs/06_agent_templates/notes.md +25 -0
  86. package/docs/06_agent_templates/prd.md +34 -0
  87. package/docs/06_agent_templates/questions.md +11 -0
  88. package/docs/06_agent_templates/tickets.md +49 -0
  89. package/docs/06_cron/development_log.md +51 -0
  90. package/docs/06_cron/notes.md +14 -0
  91. package/docs/06_cron/prd.md +92 -0
  92. package/docs/06_cron/questions.md +15 -0
  93. package/docs/06_cron/tickets.md +75 -0
  94. package/docs/07_web_chat_ux/development_log.md +30 -0
  95. package/docs/07_web_chat_ux/notes.md +25 -0
  96. package/docs/07_web_chat_ux/prd.md +46 -0
  97. package/docs/07_web_chat_ux/questions.md +7 -0
  98. package/docs/07_web_chat_ux/tickets.md +48 -0
  99. package/docs/08_agent_api/development_log.md +52 -0
  100. package/docs/08_agent_api/notes.md +31 -0
  101. package/docs/08_agent_api/prd.md +56 -0
  102. package/docs/08_agent_api/questions.md +14 -0
  103. package/docs/08_agent_api/tickets.md +104 -0
  104. package/docs/09_agent_fallbacks/development_log.md +52 -0
  105. package/docs/09_agent_fallbacks/notes.md +40 -0
  106. package/docs/09_agent_fallbacks/prd.md +55 -0
  107. package/docs/09_agent_fallbacks/questions.md +10 -0
  108. package/docs/09_agent_fallbacks/tickets.md +88 -0
  109. package/docs/09_discord_adapter/development_log.md +95 -0
  110. package/docs/09_discord_adapter/notes.md +18 -0
  111. package/docs/09_discord_adapter/prd.md +57 -0
  112. package/docs/09_discord_adapter/questions.md +16 -0
  113. package/docs/09_discord_adapter/tickets.md +116 -0
  114. package/docs/10_file_attachments/development_log.md +55 -0
  115. package/docs/10_file_attachments/notes.md +59 -0
  116. package/docs/10_file_attachments/prd.md +73 -0
  117. package/docs/10_file_attachments/questions.md +15 -0
  118. package/docs/10_file_attachments/tickets.md +88 -0
  119. package/docs/11_message_verbosity/development_log.md +43 -0
  120. package/docs/11_message_verbosity/notes.md +26 -0
  121. package/docs/11_message_verbosity/prd.md +44 -0
  122. package/docs/11_message_verbosity/questions.md +8 -0
  123. package/docs/11_message_verbosity/tickets.md +33 -0
  124. package/docs/12_environments/development_log.md +43 -0
  125. package/docs/12_environments/notes.md +45 -0
  126. package/docs/12_environments/prd.md +113 -0
  127. package/docs/12_environments/questions.md +17 -0
  128. package/docs/12_environments/tickets.md +87 -0
  129. package/docs/12_setup_flow_improvements/development_log.md +40 -0
  130. package/docs/12_setup_flow_improvements/notes.md +34 -0
  131. package/docs/12_setup_flow_improvements/prd.md +35 -0
  132. package/docs/12_setup_flow_improvements/questions.md +8 -0
  133. package/docs/12_setup_flow_improvements/tickets.md +122 -0
  134. package/docs/13_discord_typing_indicators/development_log.md +38 -0
  135. package/docs/13_discord_typing_indicators/notes.md +18 -0
  136. package/docs/13_discord_typing_indicators/prd.md +41 -0
  137. package/docs/13_discord_typing_indicators/questions.md +6 -0
  138. package/docs/13_discord_typing_indicators/tickets.md +60 -0
  139. package/docs/14_interruptions/development_log.md +50 -0
  140. package/docs/14_interruptions/notes.md +38 -0
  141. package/docs/14_interruptions/prd.md +46 -0
  142. package/docs/14_interruptions/questions.md +12 -0
  143. package/docs/14_interruptions/tickets.md +69 -0
  144. package/docs/15_sandbox_policies/development_log.md +95 -0
  145. package/docs/15_sandbox_policies/notes.md +33 -0
  146. package/docs/15_sandbox_policies/prd.md +163 -0
  147. package/docs/15_sandbox_policies/questions.md +10 -0
  148. package/docs/15_sandbox_policies/tickets.md +196 -0
  149. package/docs/CHECKS.md +9 -0
  150. package/docs/guides/discord_adapter_setup.md +69 -0
  151. package/docs/guides/sandbox_policies.md +76 -0
  152. package/eslint.config.js +47 -0
  153. package/napkin.md +21 -0
  154. package/package.json +50 -0
  155. package/scripts/create_worktree.sh +49 -0
  156. package/scripts/get_pr_comments.sh +36 -0
  157. package/src/adapter-discord/client.test.ts +65 -0
  158. package/src/adapter-discord/client.ts +41 -0
  159. package/src/adapter-discord/config.test.ts +156 -0
  160. package/src/adapter-discord/config.ts +61 -0
  161. package/src/adapter-discord/forwarder.test.ts +493 -0
  162. package/src/adapter-discord/forwarder.ts +246 -0
  163. package/src/adapter-discord/index.test.ts +399 -0
  164. package/src/adapter-discord/index.ts +147 -0
  165. package/src/adapter-discord/state.test.ts +65 -0
  166. package/src/adapter-discord/state.ts +44 -0
  167. package/src/cli/client.ts +46 -0
  168. package/src/cli/commands/agents.ts +138 -0
  169. package/src/cli/commands/chats.ts +79 -0
  170. package/src/cli/commands/down.ts +32 -0
  171. package/src/cli/commands/environments.ts +39 -0
  172. package/src/cli/commands/export-lite.ts +62 -0
  173. package/src/cli/commands/init.ts +79 -0
  174. package/src/cli/commands/jobs.ts +141 -0
  175. package/src/cli/commands/messages.ts +103 -0
  176. package/src/cli/commands/up.ts +26 -0
  177. package/src/cli/commands/web-api/agents.ts +138 -0
  178. package/src/cli/commands/web-api/chats.ts +213 -0
  179. package/src/cli/commands/web-api/utils.ts +27 -0
  180. package/src/cli/commands/web.ts +105 -0
  181. package/src/cli/e2e/adapter-discord.test.ts +76 -0
  182. package/src/cli/e2e/agents.test.ts +140 -0
  183. package/src/cli/e2e/basic.test.ts +43 -0
  184. package/src/cli/e2e/cron.test.ts +132 -0
  185. package/src/cli/e2e/daemon.test.ts +293 -0
  186. package/src/cli/e2e/environments.test.ts +66 -0
  187. package/src/cli/e2e/export-lite-func.test.ts +155 -0
  188. package/src/cli/e2e/export-lite.test.ts +51 -0
  189. package/src/cli/e2e/fallbacks.test.ts +169 -0
  190. package/src/cli/e2e/global-setup.ts +15 -0
  191. package/src/cli/e2e/init.test.ts +70 -0
  192. package/src/cli/e2e/messages.test.ts +294 -0
  193. package/src/cli/e2e/requests.test.ts +165 -0
  194. package/src/cli/e2e/utils.ts +66 -0
  195. package/src/cli/index.test.ts +7 -0
  196. package/src/cli/index.ts +29 -0
  197. package/src/cli/lite.ts +247 -0
  198. package/src/cli/utils.ts +4 -0
  199. package/src/daemon/auth.test.ts +50 -0
  200. package/src/daemon/auth.ts +69 -0
  201. package/src/daemon/chats.ts +26 -0
  202. package/src/daemon/cron.test.ts +28 -0
  203. package/src/daemon/cron.ts +159 -0
  204. package/src/daemon/events.ts +15 -0
  205. package/src/daemon/index.ts +212 -0
  206. package/src/daemon/message-agent.test.ts +132 -0
  207. package/src/daemon/message-extraction.test.ts +166 -0
  208. package/src/daemon/message-fallbacks.test.ts +313 -0
  209. package/src/daemon/message-interruption.test.ts +125 -0
  210. package/src/daemon/message-queue.test.ts +143 -0
  211. package/src/daemon/message-router.test.ts +106 -0
  212. package/src/daemon/message-session.test.ts +127 -0
  213. package/src/daemon/message-test-utils.ts +41 -0
  214. package/src/daemon/message-typing.test.ts +93 -0
  215. package/src/daemon/message-verbosity.test.ts +127 -0
  216. package/src/daemon/message.ts +600 -0
  217. package/src/daemon/observation.test.ts +118 -0
  218. package/src/daemon/policy-request-service.test.ts +87 -0
  219. package/src/daemon/policy-request-service.ts +62 -0
  220. package/src/daemon/policy-utils.test.ts +138 -0
  221. package/src/daemon/policy-utils.ts +152 -0
  222. package/src/daemon/queue.test.ts +89 -0
  223. package/src/daemon/queue.ts +87 -0
  224. package/src/daemon/request-store.test.ts +103 -0
  225. package/src/daemon/request-store.ts +96 -0
  226. package/src/daemon/router-policy-request.test.ts +99 -0
  227. package/src/daemon/router.test.ts +380 -0
  228. package/src/daemon/router.ts +510 -0
  229. package/src/daemon/routers/slash-command.test.ts +145 -0
  230. package/src/daemon/routers/slash-command.ts +58 -0
  231. package/src/daemon/routers/slash-interrupt.test.ts +30 -0
  232. package/src/daemon/routers/slash-interrupt.ts +7 -0
  233. package/src/daemon/routers/slash-new.test.ts +59 -0
  234. package/src/daemon/routers/slash-new.ts +14 -0
  235. package/src/daemon/routers/slash-policies.test.ts +167 -0
  236. package/src/daemon/routers/slash-policies.ts +131 -0
  237. package/src/daemon/routers/slash-stop.test.ts +30 -0
  238. package/src/daemon/routers/slash-stop.ts +3 -0
  239. package/src/daemon/routers/types.ts +10 -0
  240. package/src/daemon/routers/utils.ts +22 -0
  241. package/src/daemon/routers.test.ts +141 -0
  242. package/src/daemon/routers.ts +115 -0
  243. package/src/daemon/utils/spawn.ts +61 -0
  244. package/src/shared/agent-utils.ts +30 -0
  245. package/src/shared/chats.test.ts +112 -0
  246. package/src/shared/chats.ts +164 -0
  247. package/src/shared/config.test.ts +90 -0
  248. package/src/shared/config.ts +100 -0
  249. package/src/shared/event-source.ts +121 -0
  250. package/src/shared/fetch.ts +45 -0
  251. package/src/shared/lite.ts +129 -0
  252. package/src/shared/policies.ts +24 -0
  253. package/src/shared/utils/env.ts +27 -0
  254. package/src/shared/utils/fs.ts +13 -0
  255. package/src/shared/workspace.test.ts +345 -0
  256. package/src/shared/workspace.ts +500 -0
  257. package/templates/environments/cladding/env.json +7 -0
  258. package/templates/environments/macos/env.json +8 -0
  259. package/templates/environments/macos/sandbox.sb +21 -0
  260. package/templates/environments/macos-proxy/allowlist.txt +1 -0
  261. package/templates/environments/macos-proxy/env.json +14 -0
  262. package/templates/environments/macos-proxy/proxy.mjs +86 -0
  263. package/templates/environments/macos-proxy/sandbox.sb +34 -0
  264. package/templates/gemini/settings.json +11 -0
  265. package/templates/gemini-claw/.gemini/hooks/clawmini-logging.sh +17 -0
  266. package/templates/gemini-claw/.gemini/settings.json +24 -0
  267. package/templates/gemini-claw/.gemini/skills/clawmini-jobs/SKILL.md +40 -0
  268. package/templates/gemini-claw/.gemini/system.md +98 -0
  269. package/templates/gemini-claw/BOOTSTRAP.md +54 -0
  270. package/templates/gemini-claw/GEMINI.md +107 -0
  271. package/templates/gemini-claw/HEARTBEAT.md +3 -0
  272. package/templates/gemini-claw/MEMORY.md +2 -0
  273. package/templates/gemini-claw/SOUL.md +42 -0
  274. package/templates/gemini-claw/TOOLS.md +38 -0
  275. package/templates/gemini-claw/USER.md +15 -0
  276. package/templates/gemini-claw/memory/.gitkeep +0 -0
  277. package/templates/gemini-claw/settings.json +24 -0
  278. package/templates/opencode/settings.json +11 -0
  279. package/tsconfig.json +42 -0
  280. package/tsdown.config.ts +19 -0
  281. package/vitest.config.ts +9 -0
  282. package/web/.svelte-kit/ambient.d.ts +382 -0
  283. package/web/.svelte-kit/generated/client/app.js +35 -0
  284. package/web/.svelte-kit/generated/client/matchers.js +1 -0
  285. package/web/.svelte-kit/generated/client/nodes/0.js +3 -0
  286. package/web/.svelte-kit/generated/client/nodes/1.js +1 -0
  287. package/web/.svelte-kit/generated/client/nodes/2.js +1 -0
  288. package/web/.svelte-kit/generated/client/nodes/3.js +1 -0
  289. package/web/.svelte-kit/generated/client/nodes/4.js +3 -0
  290. package/web/.svelte-kit/generated/client/nodes/5.js +3 -0
  291. package/web/.svelte-kit/generated/client-optimized/app.js +35 -0
  292. package/web/.svelte-kit/generated/client-optimized/matchers.js +1 -0
  293. package/web/.svelte-kit/generated/client-optimized/nodes/0.js +3 -0
  294. package/web/.svelte-kit/generated/client-optimized/nodes/1.js +1 -0
  295. package/web/.svelte-kit/generated/client-optimized/nodes/2.js +1 -0
  296. package/web/.svelte-kit/generated/client-optimized/nodes/3.js +1 -0
  297. package/web/.svelte-kit/generated/client-optimized/nodes/4.js +3 -0
  298. package/web/.svelte-kit/generated/client-optimized/nodes/5.js +3 -0
  299. package/web/.svelte-kit/generated/root.js +3 -0
  300. package/web/.svelte-kit/generated/root.svelte +68 -0
  301. package/web/.svelte-kit/generated/server/internal.js +53 -0
  302. package/web/.svelte-kit/non-ambient.d.ts +46 -0
  303. package/web/.svelte-kit/output/client/.vite/manifest.json +251 -0
  304. package/web/.svelte-kit/output/client/_app/immutable/assets/0.GI4C4dpV.css +1 -0
  305. package/web/.svelte-kit/output/client/_app/immutable/chunks/B5abRDXp.js +1 -0
  306. package/web/.svelte-kit/output/client/_app/immutable/chunks/B8yYFADm.js +1 -0
  307. package/web/.svelte-kit/output/client/_app/immutable/chunks/BPy8HLo7.js +5 -0
  308. package/web/.svelte-kit/output/client/_app/immutable/chunks/Bi0jeV7Q.js +1 -0
  309. package/web/.svelte-kit/output/client/_app/immutable/chunks/BmUXQ3wy.js +2 -0
  310. package/web/.svelte-kit/output/client/_app/immutable/chunks/C3k55nDF.js +1 -0
  311. package/web/.svelte-kit/output/client/_app/immutable/chunks/COekwvP2.js +1 -0
  312. package/web/.svelte-kit/output/client/_app/immutable/chunks/CSvS_NwK.js +1 -0
  313. package/web/.svelte-kit/output/client/_app/immutable/chunks/CpaGRn9L.js +1 -0
  314. package/web/.svelte-kit/output/client/_app/immutable/chunks/CyNaE55B.js +1 -0
  315. package/web/.svelte-kit/output/client/_app/immutable/chunks/DG5RZBw-.js +2 -0
  316. package/web/.svelte-kit/output/client/_app/immutable/chunks/Dc-UOHw9.js +1 -0
  317. package/web/.svelte-kit/output/client/_app/immutable/chunks/DcrmIfTj.js +1 -0
  318. package/web/.svelte-kit/output/client/_app/immutable/chunks/ZkLyk0mE.js +1 -0
  319. package/web/.svelte-kit/output/client/_app/immutable/entry/app.B-vZe7PN.js +2 -0
  320. package/web/.svelte-kit/output/client/_app/immutable/entry/start.oP1AgKhs.js +1 -0
  321. package/web/.svelte-kit/output/client/_app/immutable/nodes/0.B5WFN0zw.js +1 -0
  322. package/web/.svelte-kit/output/client/_app/immutable/nodes/1.D1wtJb2k.js +1 -0
  323. package/web/.svelte-kit/output/client/_app/immutable/nodes/2.CK3CLC0f.js +1 -0
  324. package/web/.svelte-kit/output/client/_app/immutable/nodes/3.BB5wCoBf.js +4 -0
  325. package/web/.svelte-kit/output/client/_app/immutable/nodes/4.Dr2jvAXK.js +1 -0
  326. package/web/.svelte-kit/output/client/_app/immutable/nodes/5.BJl7oM3b.js +1 -0
  327. package/web/.svelte-kit/output/client/_app/version.json +1 -0
  328. package/web/.svelte-kit/output/client/robots.txt +3 -0
  329. package/web/.svelte-kit/output/prerendered/dependencies/_app/env.js +1 -0
  330. package/web/.svelte-kit/output/server/.vite/manifest.json +215 -0
  331. package/web/.svelte-kit/output/server/_app/immutable/assets/_layout.GI4C4dpV.css +1 -0
  332. package/web/.svelte-kit/output/server/chunks/Icon.js +153 -0
  333. package/web/.svelte-kit/output/server/chunks/bot.js +2753 -0
  334. package/web/.svelte-kit/output/server/chunks/client.js +47 -0
  335. package/web/.svelte-kit/output/server/chunks/environment.js +34 -0
  336. package/web/.svelte-kit/output/server/chunks/exports.js +231 -0
  337. package/web/.svelte-kit/output/server/chunks/false.js +4 -0
  338. package/web/.svelte-kit/output/server/chunks/index-server.js +20 -0
  339. package/web/.svelte-kit/output/server/chunks/index.js +24 -0
  340. package/web/.svelte-kit/output/server/chunks/internal.js +133 -0
  341. package/web/.svelte-kit/output/server/chunks/plus.js +81 -0
  342. package/web/.svelte-kit/output/server/chunks/root.js +4076 -0
  343. package/web/.svelte-kit/output/server/chunks/shared.js +789 -0
  344. package/web/.svelte-kit/output/server/chunks/utils.js +43 -0
  345. package/web/.svelte-kit/output/server/entries/fallbacks/error.svelte.js +11 -0
  346. package/web/.svelte-kit/output/server/entries/pages/_layout.svelte.js +3944 -0
  347. package/web/.svelte-kit/output/server/entries/pages/_layout.ts.js +28 -0
  348. package/web/.svelte-kit/output/server/entries/pages/_page.svelte.js +7 -0
  349. package/web/.svelte-kit/output/server/entries/pages/agents/_page.svelte.js +379 -0
  350. package/web/.svelte-kit/output/server/entries/pages/chats/_id_/_page.svelte.js +292 -0
  351. package/web/.svelte-kit/output/server/entries/pages/chats/_id_/_page.ts.js +17 -0
  352. package/web/.svelte-kit/output/server/entries/pages/chats/_id_/settings/_page.svelte.js +259 -0
  353. package/web/.svelte-kit/output/server/entries/pages/chats/_id_/settings/_page.ts.js +17 -0
  354. package/web/.svelte-kit/output/server/index.js +3748 -0
  355. package/web/.svelte-kit/output/server/internal.js +14 -0
  356. package/web/.svelte-kit/output/server/manifest-full.js +63 -0
  357. package/web/.svelte-kit/output/server/manifest.js +63 -0
  358. package/web/.svelte-kit/output/server/nodes/0.js +13 -0
  359. package/web/.svelte-kit/output/server/nodes/1.js +8 -0
  360. package/web/.svelte-kit/output/server/nodes/2.js +8 -0
  361. package/web/.svelte-kit/output/server/nodes/3.js +8 -0
  362. package/web/.svelte-kit/output/server/nodes/4.js +13 -0
  363. package/web/.svelte-kit/output/server/nodes/5.js +13 -0
  364. package/web/.svelte-kit/output/server/remote-entry.js +557 -0
  365. package/web/.svelte-kit/tsconfig.json +67 -0
  366. package/web/.svelte-kit/types/route_meta_data.json +17 -0
  367. package/web/.svelte-kit/types/src/routes/$types.d.ts +26 -0
  368. package/web/.svelte-kit/types/src/routes/agents/$types.d.ts +18 -0
  369. package/web/.svelte-kit/types/src/routes/chats/[id]/$types.d.ts +21 -0
  370. package/web/.svelte-kit/types/src/routes/chats/[id]/proxy+page.ts +20 -0
  371. package/web/.svelte-kit/types/src/routes/chats/[id]/settings/$types.d.ts +21 -0
  372. package/web/.svelte-kit/types/src/routes/chats/[id]/settings/proxy+page.ts +19 -0
  373. package/web/.svelte-kit/types/src/routes/proxy+layout.ts +35 -0
  374. package/web/README.md +42 -0
  375. package/web/components.json +16 -0
  376. package/web/package.json +41 -0
  377. package/web/src/app.css +121 -0
  378. package/web/src/app.d.ts +13 -0
  379. package/web/src/app.html +11 -0
  380. package/web/src/demo.spec.ts +7 -0
  381. package/web/src/lib/app-state.svelte.ts +3 -0
  382. package/web/src/lib/assets/favicon.svg +1 -0
  383. package/web/src/lib/components/app/app-sidebar-test-wrapper.svelte +10 -0
  384. package/web/src/lib/components/app/app-sidebar.svelte +171 -0
  385. package/web/src/lib/components/app/app-sidebar.svelte.spec.ts +13 -0
  386. package/web/src/lib/components/ui/button/button.svelte +82 -0
  387. package/web/src/lib/components/ui/button/index.ts +17 -0
  388. package/web/src/lib/components/ui/dialog/dialog-close.svelte +7 -0
  389. package/web/src/lib/components/ui/dialog/dialog-content.svelte +45 -0
  390. package/web/src/lib/components/ui/dialog/dialog-description.svelte +17 -0
  391. package/web/src/lib/components/ui/dialog/dialog-footer.svelte +20 -0
  392. package/web/src/lib/components/ui/dialog/dialog-header.svelte +20 -0
  393. package/web/src/lib/components/ui/dialog/dialog-overlay.svelte +20 -0
  394. package/web/src/lib/components/ui/dialog/dialog-portal.svelte +7 -0
  395. package/web/src/lib/components/ui/dialog/dialog-title.svelte +17 -0
  396. package/web/src/lib/components/ui/dialog/dialog-trigger.svelte +7 -0
  397. package/web/src/lib/components/ui/dialog/dialog.svelte +7 -0
  398. package/web/src/lib/components/ui/dialog/index.ts +34 -0
  399. package/web/src/lib/components/ui/input/index.ts +7 -0
  400. package/web/src/lib/components/ui/input/input.svelte +52 -0
  401. package/web/src/lib/components/ui/separator/index.ts +7 -0
  402. package/web/src/lib/components/ui/separator/separator.svelte +21 -0
  403. package/web/src/lib/components/ui/sheet/index.ts +34 -0
  404. package/web/src/lib/components/ui/sheet/sheet-close.svelte +7 -0
  405. package/web/src/lib/components/ui/sheet/sheet-content.svelte +60 -0
  406. package/web/src/lib/components/ui/sheet/sheet-description.svelte +17 -0
  407. package/web/src/lib/components/ui/sheet/sheet-footer.svelte +20 -0
  408. package/web/src/lib/components/ui/sheet/sheet-header.svelte +20 -0
  409. package/web/src/lib/components/ui/sheet/sheet-overlay.svelte +20 -0
  410. package/web/src/lib/components/ui/sheet/sheet-portal.svelte +7 -0
  411. package/web/src/lib/components/ui/sheet/sheet-title.svelte +17 -0
  412. package/web/src/lib/components/ui/sheet/sheet-trigger.svelte +7 -0
  413. package/web/src/lib/components/ui/sheet/sheet.svelte +7 -0
  414. package/web/src/lib/components/ui/sidebar/constants.ts +6 -0
  415. package/web/src/lib/components/ui/sidebar/context.svelte.ts +79 -0
  416. package/web/src/lib/components/ui/sidebar/index.ts +75 -0
  417. package/web/src/lib/components/ui/sidebar/sidebar-content.svelte +24 -0
  418. package/web/src/lib/components/ui/sidebar/sidebar-footer.svelte +21 -0
  419. package/web/src/lib/components/ui/sidebar/sidebar-group-action.svelte +36 -0
  420. package/web/src/lib/components/ui/sidebar/sidebar-group-content.svelte +21 -0
  421. package/web/src/lib/components/ui/sidebar/sidebar-group-label.svelte +34 -0
  422. package/web/src/lib/components/ui/sidebar/sidebar-group.svelte +21 -0
  423. package/web/src/lib/components/ui/sidebar/sidebar-header.svelte +21 -0
  424. package/web/src/lib/components/ui/sidebar/sidebar-input.svelte +21 -0
  425. package/web/src/lib/components/ui/sidebar/sidebar-inset.svelte +24 -0
  426. package/web/src/lib/components/ui/sidebar/sidebar-menu-action.svelte +43 -0
  427. package/web/src/lib/components/ui/sidebar/sidebar-menu-badge.svelte +29 -0
  428. package/web/src/lib/components/ui/sidebar/sidebar-menu-button.svelte +103 -0
  429. package/web/src/lib/components/ui/sidebar/sidebar-menu-item.svelte +21 -0
  430. package/web/src/lib/components/ui/sidebar/sidebar-menu-skeleton.svelte +36 -0
  431. package/web/src/lib/components/ui/sidebar/sidebar-menu-sub-button.svelte +43 -0
  432. package/web/src/lib/components/ui/sidebar/sidebar-menu-sub-item.svelte +21 -0
  433. package/web/src/lib/components/ui/sidebar/sidebar-menu-sub.svelte +25 -0
  434. package/web/src/lib/components/ui/sidebar/sidebar-menu.svelte +21 -0
  435. package/web/src/lib/components/ui/sidebar/sidebar-provider.svelte +53 -0
  436. package/web/src/lib/components/ui/sidebar/sidebar-rail.svelte +36 -0
  437. package/web/src/lib/components/ui/sidebar/sidebar-separator.svelte +19 -0
  438. package/web/src/lib/components/ui/sidebar/sidebar-trigger.svelte +35 -0
  439. package/web/src/lib/components/ui/sidebar/sidebar.svelte +104 -0
  440. package/web/src/lib/components/ui/skeleton/index.ts +7 -0
  441. package/web/src/lib/components/ui/skeleton/skeleton.svelte +17 -0
  442. package/web/src/lib/components/ui/switch/index.ts +7 -0
  443. package/web/src/lib/components/ui/switch/switch.svelte +29 -0
  444. package/web/src/lib/components/ui/textarea/index.ts +7 -0
  445. package/web/src/lib/components/ui/textarea/textarea.svelte +23 -0
  446. package/web/src/lib/components/ui/tooltip/index.ts +19 -0
  447. package/web/src/lib/components/ui/tooltip/tooltip-content.svelte +52 -0
  448. package/web/src/lib/components/ui/tooltip/tooltip-portal.svelte +7 -0
  449. package/web/src/lib/components/ui/tooltip/tooltip-provider.svelte +7 -0
  450. package/web/src/lib/components/ui/tooltip/tooltip-trigger.svelte +7 -0
  451. package/web/src/lib/components/ui/tooltip/tooltip.svelte +7 -0
  452. package/web/src/lib/hooks/is-mobile.svelte.ts +9 -0
  453. package/web/src/lib/index.ts +1 -0
  454. package/web/src/lib/types.ts +23 -0
  455. package/web/src/lib/utils.ts +13 -0
  456. package/web/src/routes/+layout.svelte +67 -0
  457. package/web/src/routes/+layout.ts +34 -0
  458. package/web/src/routes/+page.svelte +7 -0
  459. package/web/src/routes/agents/+page.svelte +206 -0
  460. package/web/src/routes/chats/[id]/+page.svelte +406 -0
  461. package/web/src/routes/chats/[id]/+page.ts +19 -0
  462. package/web/src/routes/chats/[id]/page.svelte.spec.ts +102 -0
  463. package/web/src/routes/chats/[id]/settings/+page.svelte +165 -0
  464. package/web/src/routes/chats/[id]/settings/+page.ts +18 -0
  465. package/web/src/routes/page.svelte.spec.ts +13 -0
  466. package/web/static/robots.txt +3 -0
  467. package/web/svelte.config.js +21 -0
  468. package/web/tsconfig.json +20 -0
  469. package/web/vite.config.ts +41 -0
@@ -0,0 +1,4076 @@
1
+ import { B as BROWSER } from "./false.js";
2
+ import { clsx as clsx$1 } from "clsx";
3
+ import * as devalue from "devalue";
4
+ var is_array = Array.isArray;
5
+ var index_of = Array.prototype.indexOf;
6
+ var includes = Array.prototype.includes;
7
+ var array_from = Array.from;
8
+ var define_property = Object.defineProperty;
9
+ var get_descriptor = Object.getOwnPropertyDescriptor;
10
+ var object_prototype = Object.prototype;
11
+ var array_prototype = Array.prototype;
12
+ var get_prototype_of = Object.getPrototypeOf;
13
+ var is_extensible = Object.isExtensible;
14
+ var has_own_property = Object.prototype.hasOwnProperty;
15
+ const noop = () => {
16
+ };
17
+ function run(fn) {
18
+ return fn();
19
+ }
20
+ function run_all(arr) {
21
+ for (var i = 0; i < arr.length; i++) {
22
+ arr[i]();
23
+ }
24
+ }
25
+ function deferred() {
26
+ var resolve;
27
+ var reject;
28
+ var promise = new Promise((res, rej) => {
29
+ resolve = res;
30
+ reject = rej;
31
+ });
32
+ return { promise, resolve, reject };
33
+ }
34
+ function fallback(value, fallback2, lazy = false) {
35
+ return value === void 0 ? lazy ? (
36
+ /** @type {() => V} */
37
+ fallback2()
38
+ ) : (
39
+ /** @type {V} */
40
+ fallback2
41
+ ) : value;
42
+ }
43
+ function equals(value) {
44
+ return value === this.v;
45
+ }
46
+ function safe_not_equal(a, b) {
47
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
48
+ }
49
+ function safe_equals(value) {
50
+ return !safe_not_equal(value, this.v);
51
+ }
52
+ const DERIVED = 1 << 1;
53
+ const EFFECT = 1 << 2;
54
+ const RENDER_EFFECT = 1 << 3;
55
+ const MANAGED_EFFECT = 1 << 24;
56
+ const BLOCK_EFFECT = 1 << 4;
57
+ const BRANCH_EFFECT = 1 << 5;
58
+ const ROOT_EFFECT = 1 << 6;
59
+ const BOUNDARY_EFFECT = 1 << 7;
60
+ const CONNECTED = 1 << 9;
61
+ const CLEAN = 1 << 10;
62
+ const DIRTY = 1 << 11;
63
+ const MAYBE_DIRTY = 1 << 12;
64
+ const INERT = 1 << 13;
65
+ const DESTROYED = 1 << 14;
66
+ const REACTION_RAN = 1 << 15;
67
+ const EFFECT_TRANSPARENT = 1 << 16;
68
+ const EAGER_EFFECT = 1 << 17;
69
+ const HEAD_EFFECT = 1 << 18;
70
+ const EFFECT_PRESERVED = 1 << 19;
71
+ const USER_EFFECT = 1 << 20;
72
+ const WAS_MARKED = 1 << 16;
73
+ const REACTION_IS_UPDATING = 1 << 21;
74
+ const ASYNC = 1 << 22;
75
+ const ERROR_VALUE = 1 << 23;
76
+ const STATE_SYMBOL = /* @__PURE__ */ Symbol("$state");
77
+ const LEGACY_PROPS = /* @__PURE__ */ Symbol("legacy props");
78
+ const STALE_REACTION = new class StaleReactionError extends Error {
79
+ name = "StaleReactionError";
80
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
81
+ }();
82
+ const COMMENT_NODE = 8;
83
+ function lifecycle_outside_component(name) {
84
+ {
85
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
86
+ }
87
+ }
88
+ function effect_update_depth_exceeded() {
89
+ {
90
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
91
+ }
92
+ }
93
+ function hydration_failed() {
94
+ {
95
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
96
+ }
97
+ }
98
+ function state_descriptors_fixed() {
99
+ {
100
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
101
+ }
102
+ }
103
+ function state_prototype_fixed() {
104
+ {
105
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
106
+ }
107
+ }
108
+ function state_unsafe_mutation() {
109
+ {
110
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
111
+ }
112
+ }
113
+ function svelte_boundary_reset_onerror() {
114
+ {
115
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
116
+ }
117
+ }
118
+ const HYDRATION_START = "[";
119
+ const HYDRATION_START_ELSE = "[!";
120
+ const HYDRATION_START_FAILED = "[?";
121
+ const HYDRATION_END = "]";
122
+ const HYDRATION_ERROR = {};
123
+ const ELEMENT_IS_NAMESPACED = 1;
124
+ const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1;
125
+ const ELEMENT_IS_INPUT = 1 << 2;
126
+ const UNINITIALIZED = /* @__PURE__ */ Symbol();
127
+ const ATTACHMENT_KEY = "@attach";
128
+ function hydration_mismatch(location) {
129
+ {
130
+ console.warn(`https://svelte.dev/e/hydration_mismatch`);
131
+ }
132
+ }
133
+ function svelte_boundary_reset_noop() {
134
+ {
135
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
136
+ }
137
+ }
138
+ let hydrating = false;
139
+ function set_hydrating(value) {
140
+ hydrating = value;
141
+ }
142
+ let hydrate_node;
143
+ function set_hydrate_node(node) {
144
+ if (node === null) {
145
+ hydration_mismatch();
146
+ throw HYDRATION_ERROR;
147
+ }
148
+ return hydrate_node = node;
149
+ }
150
+ function hydrate_next() {
151
+ return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node));
152
+ }
153
+ function next(count = 1) {
154
+ if (hydrating) {
155
+ var i = count;
156
+ var node = hydrate_node;
157
+ while (i--) {
158
+ node = /** @type {TemplateNode} */
159
+ /* @__PURE__ */ get_next_sibling(node);
160
+ }
161
+ hydrate_node = node;
162
+ }
163
+ }
164
+ function skip_nodes(remove = true) {
165
+ var depth = 0;
166
+ var node = hydrate_node;
167
+ while (true) {
168
+ if (node.nodeType === COMMENT_NODE) {
169
+ var data = (
170
+ /** @type {Comment} */
171
+ node.data
172
+ );
173
+ if (data === HYDRATION_END) {
174
+ if (depth === 0) return node;
175
+ depth -= 1;
176
+ } else if (data === HYDRATION_START || data === HYDRATION_START_ELSE || // "[1", "[2", etc. for if blocks
177
+ data[0] === "[" && !isNaN(Number(data.slice(1)))) {
178
+ depth += 1;
179
+ }
180
+ }
181
+ var next2 = (
182
+ /** @type {TemplateNode} */
183
+ /* @__PURE__ */ get_next_sibling(node)
184
+ );
185
+ if (remove) node.remove();
186
+ node = next2;
187
+ }
188
+ }
189
+ let tracing_mode_flag = false;
190
+ let component_context = null;
191
+ function set_component_context(context) {
192
+ component_context = context;
193
+ }
194
+ function push$1(props, runes = false, fn) {
195
+ component_context = {
196
+ p: component_context,
197
+ i: false,
198
+ c: null,
199
+ e: null,
200
+ s: props,
201
+ x: null,
202
+ l: null
203
+ };
204
+ }
205
+ function pop$1(component) {
206
+ var context = (
207
+ /** @type {ComponentContext} */
208
+ component_context
209
+ );
210
+ var effects = context.e;
211
+ if (effects !== null) {
212
+ context.e = null;
213
+ for (var fn of effects) {
214
+ create_user_effect(fn);
215
+ }
216
+ }
217
+ context.i = true;
218
+ component_context = context.p;
219
+ return (
220
+ /** @type {T} */
221
+ {}
222
+ );
223
+ }
224
+ function is_runes() {
225
+ return true;
226
+ }
227
+ let micro_tasks = [];
228
+ function run_micro_tasks() {
229
+ var tasks = micro_tasks;
230
+ micro_tasks = [];
231
+ run_all(tasks);
232
+ }
233
+ function queue_micro_task(fn) {
234
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
235
+ var tasks = micro_tasks;
236
+ queueMicrotask(() => {
237
+ if (tasks === micro_tasks) run_micro_tasks();
238
+ });
239
+ }
240
+ micro_tasks.push(fn);
241
+ }
242
+ function flush_tasks() {
243
+ while (micro_tasks.length > 0) {
244
+ run_micro_tasks();
245
+ }
246
+ }
247
+ function handle_error(error) {
248
+ var effect = active_effect;
249
+ if (effect === null) {
250
+ active_reaction.f |= ERROR_VALUE;
251
+ return error;
252
+ }
253
+ if ((effect.f & REACTION_RAN) === 0 && (effect.f & EFFECT) === 0) {
254
+ throw error;
255
+ }
256
+ invoke_error_boundary(error, effect);
257
+ }
258
+ function invoke_error_boundary(error, effect) {
259
+ while (effect !== null) {
260
+ if ((effect.f & BOUNDARY_EFFECT) !== 0) {
261
+ if ((effect.f & REACTION_RAN) === 0) {
262
+ throw error;
263
+ }
264
+ try {
265
+ effect.b.error(error);
266
+ return;
267
+ } catch (e) {
268
+ error = e;
269
+ }
270
+ }
271
+ effect = effect.parent;
272
+ }
273
+ throw error;
274
+ }
275
+ const STATUS_MASK = -7169;
276
+ function set_signal_status(signal, status) {
277
+ signal.f = signal.f & STATUS_MASK | status;
278
+ }
279
+ function update_derived_status(derived2) {
280
+ if ((derived2.f & CONNECTED) !== 0 || derived2.deps === null) {
281
+ set_signal_status(derived2, CLEAN);
282
+ } else {
283
+ set_signal_status(derived2, MAYBE_DIRTY);
284
+ }
285
+ }
286
+ function clear_marked(deps) {
287
+ if (deps === null) return;
288
+ for (const dep of deps) {
289
+ if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) {
290
+ continue;
291
+ }
292
+ dep.f ^= WAS_MARKED;
293
+ clear_marked(
294
+ /** @type {Derived} */
295
+ dep.deps
296
+ );
297
+ }
298
+ }
299
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
300
+ if ((effect.f & DIRTY) !== 0) {
301
+ dirty_effects.add(effect);
302
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
303
+ maybe_dirty_effects.add(effect);
304
+ }
305
+ clear_marked(effect.deps);
306
+ set_signal_status(effect, CLEAN);
307
+ }
308
+ const batches = /* @__PURE__ */ new Set();
309
+ let current_batch = null;
310
+ let batch_values = null;
311
+ let queued_root_effects = [];
312
+ let last_scheduled_effect = null;
313
+ let is_flushing_sync = false;
314
+ let collected_effects = null;
315
+ let uid = 1;
316
+ class Batch {
317
+ // for debugging. TODO remove once async is stable
318
+ id = uid++;
319
+ /**
320
+ * The current values of any sources that are updated in this batch
321
+ * They keys of this map are identical to `this.#previous`
322
+ * @type {Map<Source, any>}
323
+ */
324
+ current = /* @__PURE__ */ new Map();
325
+ /**
326
+ * The values of any sources that are updated in this batch _before_ those updates took place.
327
+ * They keys of this map are identical to `this.#current`
328
+ * @type {Map<Source, any>}
329
+ */
330
+ previous = /* @__PURE__ */ new Map();
331
+ /**
332
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
333
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
334
+ * @type {Set<(batch: Batch) => void>}
335
+ */
336
+ #commit_callbacks = /* @__PURE__ */ new Set();
337
+ /**
338
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
339
+ * @type {Set<(batch: Batch) => void>}
340
+ */
341
+ #discard_callbacks = /* @__PURE__ */ new Set();
342
+ /**
343
+ * The number of async effects that are currently in flight
344
+ */
345
+ #pending = 0;
346
+ /**
347
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
348
+ */
349
+ #blocking_pending = 0;
350
+ /**
351
+ * A deferred that resolves when the batch is committed, used with `settled()`
352
+ * TODO replace with Promise.withResolvers once supported widely enough
353
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
354
+ */
355
+ #deferred = null;
356
+ /**
357
+ * Deferred effects (which run after async work has completed) that are DIRTY
358
+ * @type {Set<Effect>}
359
+ */
360
+ #dirty_effects = /* @__PURE__ */ new Set();
361
+ /**
362
+ * Deferred effects that are MAYBE_DIRTY
363
+ * @type {Set<Effect>}
364
+ */
365
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
366
+ /**
367
+ * A map of branches that still exist, but will be destroyed when this batch
368
+ * is committed — we skip over these during `process`.
369
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
370
+ * so they can be rescheduled if the branch survives.
371
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
372
+ */
373
+ #skipped_branches = /* @__PURE__ */ new Map();
374
+ is_fork = false;
375
+ #decrement_queued = false;
376
+ #is_deferred() {
377
+ return this.is_fork || this.#blocking_pending > 0;
378
+ }
379
+ /**
380
+ * Add an effect to the #skipped_branches map and reset its children
381
+ * @param {Effect} effect
382
+ */
383
+ skip_effect(effect) {
384
+ if (!this.#skipped_branches.has(effect)) {
385
+ this.#skipped_branches.set(effect, { d: [], m: [] });
386
+ }
387
+ }
388
+ /**
389
+ * Remove an effect from the #skipped_branches map and reschedule
390
+ * any tracked dirty/maybe_dirty child effects
391
+ * @param {Effect} effect
392
+ */
393
+ unskip_effect(effect) {
394
+ var tracked = this.#skipped_branches.get(effect);
395
+ if (tracked) {
396
+ this.#skipped_branches.delete(effect);
397
+ for (var e of tracked.d) {
398
+ set_signal_status(e, DIRTY);
399
+ schedule_effect(e);
400
+ }
401
+ for (e of tracked.m) {
402
+ set_signal_status(e, MAYBE_DIRTY);
403
+ schedule_effect(e);
404
+ }
405
+ }
406
+ }
407
+ /**
408
+ *
409
+ * @param {Effect[]} root_effects
410
+ */
411
+ process(root_effects) {
412
+ queued_root_effects = [];
413
+ this.apply();
414
+ var effects = collected_effects = [];
415
+ var render_effects = [];
416
+ for (const root2 of root_effects) {
417
+ this.#traverse_effect_tree(root2, effects, render_effects);
418
+ }
419
+ collected_effects = null;
420
+ if (this.#is_deferred()) {
421
+ this.#defer_effects(render_effects);
422
+ this.#defer_effects(effects);
423
+ for (const [e, t] of this.#skipped_branches) {
424
+ reset_branch(e, t);
425
+ }
426
+ } else {
427
+ current_batch = null;
428
+ for (const fn of this.#commit_callbacks) fn(this);
429
+ this.#commit_callbacks.clear();
430
+ if (this.#pending === 0) {
431
+ this.#commit();
432
+ }
433
+ flush_queued_effects(render_effects);
434
+ flush_queued_effects(effects);
435
+ this.#dirty_effects.clear();
436
+ this.#maybe_dirty_effects.clear();
437
+ this.#deferred?.resolve();
438
+ }
439
+ batch_values = null;
440
+ }
441
+ /**
442
+ * Traverse the effect tree, executing effects or stashing
443
+ * them for later execution as appropriate
444
+ * @param {Effect} root
445
+ * @param {Effect[]} effects
446
+ * @param {Effect[]} render_effects
447
+ */
448
+ #traverse_effect_tree(root2, effects, render_effects) {
449
+ root2.f ^= CLEAN;
450
+ var effect = root2.first;
451
+ while (effect !== null) {
452
+ var flags2 = effect.f;
453
+ var is_branch = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
454
+ var is_skippable_branch = is_branch && (flags2 & CLEAN) !== 0;
455
+ var inert = (flags2 & INERT) !== 0;
456
+ var skip = is_skippable_branch || this.#skipped_branches.has(effect);
457
+ if (!skip && effect.fn !== null) {
458
+ if (is_branch) {
459
+ if (!inert) effect.f ^= CLEAN;
460
+ } else if ((flags2 & EFFECT) !== 0) {
461
+ effects.push(effect);
462
+ } else if ((flags2 & (RENDER_EFFECT | MANAGED_EFFECT)) !== 0 && inert) {
463
+ render_effects.push(effect);
464
+ } else if (is_dirty(effect)) {
465
+ update_effect(effect);
466
+ if ((flags2 & BLOCK_EFFECT) !== 0) {
467
+ this.#maybe_dirty_effects.add(effect);
468
+ if (inert) set_signal_status(effect, DIRTY);
469
+ }
470
+ }
471
+ var child = effect.first;
472
+ if (child !== null) {
473
+ effect = child;
474
+ continue;
475
+ }
476
+ }
477
+ while (effect !== null) {
478
+ var next2 = effect.next;
479
+ if (next2 !== null) {
480
+ effect = next2;
481
+ break;
482
+ }
483
+ effect = effect.parent;
484
+ }
485
+ }
486
+ }
487
+ /**
488
+ * @param {Effect[]} effects
489
+ */
490
+ #defer_effects(effects) {
491
+ for (var i = 0; i < effects.length; i += 1) {
492
+ defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
493
+ }
494
+ }
495
+ /**
496
+ * Associate a change to a given source with the current
497
+ * batch, noting its previous and current values
498
+ * @param {Source} source
499
+ * @param {any} value
500
+ */
501
+ capture(source2, value) {
502
+ if (value !== UNINITIALIZED && !this.previous.has(source2)) {
503
+ this.previous.set(source2, value);
504
+ }
505
+ if ((source2.f & ERROR_VALUE) === 0) {
506
+ this.current.set(source2, source2.v);
507
+ batch_values?.set(source2, source2.v);
508
+ }
509
+ }
510
+ activate() {
511
+ current_batch = this;
512
+ this.apply();
513
+ }
514
+ deactivate() {
515
+ if (current_batch !== this) return;
516
+ current_batch = null;
517
+ batch_values = null;
518
+ }
519
+ flush() {
520
+ if (queued_root_effects.length > 0) {
521
+ current_batch = this;
522
+ flush_effects();
523
+ } else if (this.#pending === 0 && !this.is_fork) {
524
+ for (const fn of this.#commit_callbacks) fn(this);
525
+ this.#commit_callbacks.clear();
526
+ this.#commit();
527
+ this.#deferred?.resolve();
528
+ }
529
+ this.deactivate();
530
+ }
531
+ discard() {
532
+ for (const fn of this.#discard_callbacks) fn(this);
533
+ this.#discard_callbacks.clear();
534
+ }
535
+ #commit() {
536
+ if (batches.size > 1) {
537
+ this.previous.clear();
538
+ var previous_batch = current_batch;
539
+ var previous_batch_values = batch_values;
540
+ var is_earlier = true;
541
+ for (const batch of batches) {
542
+ if (batch === this) {
543
+ is_earlier = false;
544
+ continue;
545
+ }
546
+ const sources = [];
547
+ for (const [source2, value] of this.current) {
548
+ if (batch.current.has(source2)) {
549
+ if (is_earlier && value !== batch.current.get(source2)) {
550
+ batch.current.set(source2, value);
551
+ } else {
552
+ continue;
553
+ }
554
+ }
555
+ sources.push(source2);
556
+ }
557
+ if (sources.length === 0) {
558
+ continue;
559
+ }
560
+ const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
561
+ if (others.length > 0) {
562
+ var prev_queued_root_effects = queued_root_effects;
563
+ queued_root_effects = [];
564
+ const marked = /* @__PURE__ */ new Set();
565
+ const checked = /* @__PURE__ */ new Map();
566
+ for (const source2 of sources) {
567
+ mark_effects(source2, others, marked, checked);
568
+ }
569
+ if (queued_root_effects.length > 0) {
570
+ current_batch = batch;
571
+ batch.apply();
572
+ for (const root2 of queued_root_effects) {
573
+ batch.#traverse_effect_tree(root2, [], []);
574
+ }
575
+ batch.deactivate();
576
+ }
577
+ queued_root_effects = prev_queued_root_effects;
578
+ }
579
+ }
580
+ current_batch = previous_batch;
581
+ batch_values = previous_batch_values;
582
+ }
583
+ this.#skipped_branches.clear();
584
+ batches.delete(this);
585
+ }
586
+ /**
587
+ *
588
+ * @param {boolean} blocking
589
+ */
590
+ increment(blocking) {
591
+ this.#pending += 1;
592
+ if (blocking) this.#blocking_pending += 1;
593
+ }
594
+ /**
595
+ *
596
+ * @param {boolean} blocking
597
+ */
598
+ decrement(blocking) {
599
+ this.#pending -= 1;
600
+ if (blocking) this.#blocking_pending -= 1;
601
+ if (this.#decrement_queued) return;
602
+ this.#decrement_queued = true;
603
+ queue_micro_task(() => {
604
+ this.#decrement_queued = false;
605
+ if (!this.#is_deferred()) {
606
+ this.revive();
607
+ } else if (queued_root_effects.length > 0) {
608
+ this.flush();
609
+ }
610
+ });
611
+ }
612
+ revive() {
613
+ for (const e of this.#dirty_effects) {
614
+ this.#maybe_dirty_effects.delete(e);
615
+ set_signal_status(e, DIRTY);
616
+ schedule_effect(e);
617
+ }
618
+ for (const e of this.#maybe_dirty_effects) {
619
+ set_signal_status(e, MAYBE_DIRTY);
620
+ schedule_effect(e);
621
+ }
622
+ this.flush();
623
+ }
624
+ /** @param {(batch: Batch) => void} fn */
625
+ oncommit(fn) {
626
+ this.#commit_callbacks.add(fn);
627
+ }
628
+ /** @param {(batch: Batch) => void} fn */
629
+ ondiscard(fn) {
630
+ this.#discard_callbacks.add(fn);
631
+ }
632
+ settled() {
633
+ return (this.#deferred ??= deferred()).promise;
634
+ }
635
+ static ensure() {
636
+ if (current_batch === null) {
637
+ const batch = current_batch = new Batch();
638
+ batches.add(current_batch);
639
+ if (!is_flushing_sync) {
640
+ queue_micro_task(() => {
641
+ if (current_batch !== batch) {
642
+ return;
643
+ }
644
+ batch.flush();
645
+ });
646
+ }
647
+ }
648
+ return current_batch;
649
+ }
650
+ apply() {
651
+ return;
652
+ }
653
+ }
654
+ function flushSync(fn) {
655
+ var was_flushing_sync = is_flushing_sync;
656
+ is_flushing_sync = true;
657
+ try {
658
+ var result;
659
+ if (fn) ;
660
+ while (true) {
661
+ flush_tasks();
662
+ if (queued_root_effects.length === 0) {
663
+ current_batch?.flush();
664
+ if (queued_root_effects.length === 0) {
665
+ last_scheduled_effect = null;
666
+ return (
667
+ /** @type {T} */
668
+ result
669
+ );
670
+ }
671
+ }
672
+ flush_effects();
673
+ }
674
+ } finally {
675
+ is_flushing_sync = was_flushing_sync;
676
+ }
677
+ }
678
+ function flush_effects() {
679
+ var source_stacks = null;
680
+ try {
681
+ var flush_count = 0;
682
+ while (queued_root_effects.length > 0) {
683
+ var batch = Batch.ensure();
684
+ if (flush_count++ > 1e3) {
685
+ var updates, entry;
686
+ if (BROWSER) ;
687
+ infinite_loop_guard();
688
+ }
689
+ batch.process(queued_root_effects);
690
+ old_values.clear();
691
+ if (BROWSER) ;
692
+ }
693
+ } finally {
694
+ queued_root_effects = [];
695
+ last_scheduled_effect = null;
696
+ collected_effects = null;
697
+ }
698
+ }
699
+ function infinite_loop_guard() {
700
+ try {
701
+ effect_update_depth_exceeded();
702
+ } catch (error) {
703
+ invoke_error_boundary(error, last_scheduled_effect);
704
+ }
705
+ }
706
+ let eager_block_effects = null;
707
+ function flush_queued_effects(effects) {
708
+ var length = effects.length;
709
+ if (length === 0) return;
710
+ var i = 0;
711
+ while (i < length) {
712
+ var effect = effects[i++];
713
+ if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
714
+ eager_block_effects = /* @__PURE__ */ new Set();
715
+ update_effect(effect);
716
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) {
717
+ unlink_effect(effect);
718
+ }
719
+ if (eager_block_effects?.size > 0) {
720
+ old_values.clear();
721
+ for (const e of eager_block_effects) {
722
+ if ((e.f & (DESTROYED | INERT)) !== 0) continue;
723
+ const ordered_effects = [e];
724
+ let ancestor = e.parent;
725
+ while (ancestor !== null) {
726
+ if (eager_block_effects.has(ancestor)) {
727
+ eager_block_effects.delete(ancestor);
728
+ ordered_effects.push(ancestor);
729
+ }
730
+ ancestor = ancestor.parent;
731
+ }
732
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
733
+ const e2 = ordered_effects[j];
734
+ if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
735
+ update_effect(e2);
736
+ }
737
+ }
738
+ eager_block_effects.clear();
739
+ }
740
+ }
741
+ }
742
+ eager_block_effects = null;
743
+ }
744
+ function mark_effects(value, sources, marked, checked) {
745
+ if (marked.has(value)) return;
746
+ marked.add(value);
747
+ if (value.reactions !== null) {
748
+ for (const reaction of value.reactions) {
749
+ const flags2 = reaction.f;
750
+ if ((flags2 & DERIVED) !== 0) {
751
+ mark_effects(
752
+ /** @type {Derived} */
753
+ reaction,
754
+ sources,
755
+ marked,
756
+ checked
757
+ );
758
+ } else if ((flags2 & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags2 & DIRTY) === 0 && depends_on(reaction, sources, checked)) {
759
+ set_signal_status(reaction, DIRTY);
760
+ schedule_effect(
761
+ /** @type {Effect} */
762
+ reaction
763
+ );
764
+ }
765
+ }
766
+ }
767
+ }
768
+ function depends_on(reaction, sources, checked) {
769
+ const depends = checked.get(reaction);
770
+ if (depends !== void 0) return depends;
771
+ if (reaction.deps !== null) {
772
+ for (const dep of reaction.deps) {
773
+ if (includes.call(sources, dep)) {
774
+ return true;
775
+ }
776
+ if ((dep.f & DERIVED) !== 0 && depends_on(
777
+ /** @type {Derived} */
778
+ dep,
779
+ sources,
780
+ checked
781
+ )) {
782
+ checked.set(
783
+ /** @type {Derived} */
784
+ dep,
785
+ true
786
+ );
787
+ return true;
788
+ }
789
+ }
790
+ }
791
+ checked.set(reaction, false);
792
+ return false;
793
+ }
794
+ function schedule_effect(signal) {
795
+ var effect = last_scheduled_effect = signal;
796
+ var boundary2 = effect.b;
797
+ if (boundary2?.is_pending && (signal.f & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0 && (signal.f & REACTION_RAN) === 0) {
798
+ boundary2.defer_effect(signal);
799
+ return;
800
+ }
801
+ while (effect.parent !== null) {
802
+ effect = effect.parent;
803
+ var flags2 = effect.f;
804
+ if (collected_effects !== null && effect === active_effect) {
805
+ if ((signal.f & RENDER_EFFECT) === 0) {
806
+ return;
807
+ }
808
+ }
809
+ if ((flags2 & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
810
+ if ((flags2 & CLEAN) === 0) {
811
+ return;
812
+ }
813
+ effect.f ^= CLEAN;
814
+ }
815
+ }
816
+ queued_root_effects.push(effect);
817
+ }
818
+ function reset_branch(effect, tracked) {
819
+ if ((effect.f & BRANCH_EFFECT) !== 0 && (effect.f & CLEAN) !== 0) {
820
+ return;
821
+ }
822
+ if ((effect.f & DIRTY) !== 0) {
823
+ tracked.d.push(effect);
824
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
825
+ tracked.m.push(effect);
826
+ }
827
+ set_signal_status(effect, CLEAN);
828
+ var e = effect.first;
829
+ while (e !== null) {
830
+ reset_branch(e, tracked);
831
+ e = e.next;
832
+ }
833
+ }
834
+ function createSubscriber(start) {
835
+ let subscribers = 0;
836
+ let version = source(0);
837
+ let stop;
838
+ return () => {
839
+ if (effect_tracking()) {
840
+ get(version);
841
+ render_effect(() => {
842
+ if (subscribers === 0) {
843
+ stop = untrack(() => start(() => increment(version)));
844
+ }
845
+ subscribers += 1;
846
+ return () => {
847
+ queue_micro_task(() => {
848
+ subscribers -= 1;
849
+ if (subscribers === 0) {
850
+ stop?.();
851
+ stop = void 0;
852
+ increment(version);
853
+ }
854
+ });
855
+ };
856
+ });
857
+ }
858
+ };
859
+ }
860
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
861
+ function boundary(node, props, children, transform_error) {
862
+ new Boundary(node, props, children, transform_error);
863
+ }
864
+ class Boundary {
865
+ /** @type {Boundary | null} */
866
+ parent;
867
+ is_pending = false;
868
+ /**
869
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
870
+ * Inherited from parent boundary, or defaults to identity.
871
+ * @type {(error: unknown) => unknown}
872
+ */
873
+ transform_error;
874
+ /** @type {TemplateNode} */
875
+ #anchor;
876
+ /** @type {TemplateNode | null} */
877
+ #hydrate_open = hydrating ? hydrate_node : null;
878
+ /** @type {BoundaryProps} */
879
+ #props;
880
+ /** @type {((anchor: Node) => void)} */
881
+ #children;
882
+ /** @type {Effect} */
883
+ #effect;
884
+ /** @type {Effect | null} */
885
+ #main_effect = null;
886
+ /** @type {Effect | null} */
887
+ #pending_effect = null;
888
+ /** @type {Effect | null} */
889
+ #failed_effect = null;
890
+ /** @type {DocumentFragment | null} */
891
+ #offscreen_fragment = null;
892
+ #local_pending_count = 0;
893
+ #pending_count = 0;
894
+ #pending_count_update_queued = false;
895
+ /** @type {Set<Effect>} */
896
+ #dirty_effects = /* @__PURE__ */ new Set();
897
+ /** @type {Set<Effect>} */
898
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
899
+ /**
900
+ * A source containing the number of pending async deriveds/expressions.
901
+ * Only created if `$effect.pending()` is used inside the boundary,
902
+ * otherwise updating the source results in needless `Batch.ensure()`
903
+ * calls followed by no-op flushes
904
+ * @type {Source<number> | null}
905
+ */
906
+ #effect_pending = null;
907
+ #effect_pending_subscriber = createSubscriber(() => {
908
+ this.#effect_pending = source(this.#local_pending_count);
909
+ return () => {
910
+ this.#effect_pending = null;
911
+ };
912
+ });
913
+ /**
914
+ * @param {TemplateNode} node
915
+ * @param {BoundaryProps} props
916
+ * @param {((anchor: Node) => void)} children
917
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
918
+ */
919
+ constructor(node, props, children, transform_error) {
920
+ this.#anchor = node;
921
+ this.#props = props;
922
+ this.#children = (anchor) => {
923
+ var effect = (
924
+ /** @type {Effect} */
925
+ active_effect
926
+ );
927
+ effect.b = this;
928
+ effect.f |= BOUNDARY_EFFECT;
929
+ children(anchor);
930
+ };
931
+ this.parent = /** @type {Effect} */
932
+ active_effect.b;
933
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
934
+ this.#effect = block(() => {
935
+ if (hydrating) {
936
+ const comment = (
937
+ /** @type {Comment} */
938
+ this.#hydrate_open
939
+ );
940
+ hydrate_next();
941
+ const server_rendered_pending = comment.data === HYDRATION_START_ELSE;
942
+ const server_rendered_failed = comment.data.startsWith(HYDRATION_START_FAILED);
943
+ if (server_rendered_failed) {
944
+ const serialized_error = JSON.parse(comment.data.slice(HYDRATION_START_FAILED.length));
945
+ this.#hydrate_failed_content(serialized_error);
946
+ } else if (server_rendered_pending) {
947
+ this.#hydrate_pending_content();
948
+ } else {
949
+ this.#hydrate_resolved_content();
950
+ }
951
+ } else {
952
+ this.#render();
953
+ }
954
+ }, flags);
955
+ if (hydrating) {
956
+ this.#anchor = hydrate_node;
957
+ }
958
+ }
959
+ #hydrate_resolved_content() {
960
+ try {
961
+ this.#main_effect = branch(() => this.#children(this.#anchor));
962
+ } catch (error) {
963
+ this.error(error);
964
+ }
965
+ }
966
+ /**
967
+ * @param {unknown} error The deserialized error from the server's hydration comment
968
+ */
969
+ #hydrate_failed_content(error) {
970
+ const failed = this.#props.failed;
971
+ if (!failed) return;
972
+ this.#failed_effect = branch(() => {
973
+ failed(
974
+ this.#anchor,
975
+ () => error,
976
+ () => () => {
977
+ }
978
+ );
979
+ });
980
+ }
981
+ #hydrate_pending_content() {
982
+ const pending = this.#props.pending;
983
+ if (!pending) return;
984
+ this.is_pending = true;
985
+ this.#pending_effect = branch(() => pending(this.#anchor));
986
+ queue_micro_task(() => {
987
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
988
+ var anchor = create_text();
989
+ fragment.append(anchor);
990
+ this.#main_effect = this.#run(() => {
991
+ Batch.ensure();
992
+ return branch(() => this.#children(anchor));
993
+ });
994
+ if (this.#pending_count === 0) {
995
+ this.#anchor.before(fragment);
996
+ this.#offscreen_fragment = null;
997
+ pause_effect(
998
+ /** @type {Effect} */
999
+ this.#pending_effect,
1000
+ () => {
1001
+ this.#pending_effect = null;
1002
+ }
1003
+ );
1004
+ this.#resolve();
1005
+ }
1006
+ });
1007
+ }
1008
+ #render() {
1009
+ try {
1010
+ this.is_pending = this.has_pending_snippet();
1011
+ this.#pending_count = 0;
1012
+ this.#local_pending_count = 0;
1013
+ this.#main_effect = branch(() => {
1014
+ this.#children(this.#anchor);
1015
+ });
1016
+ if (this.#pending_count > 0) {
1017
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
1018
+ move_effect(this.#main_effect, fragment);
1019
+ const pending = (
1020
+ /** @type {(anchor: Node) => void} */
1021
+ this.#props.pending
1022
+ );
1023
+ this.#pending_effect = branch(() => pending(this.#anchor));
1024
+ } else {
1025
+ this.#resolve();
1026
+ }
1027
+ } catch (error) {
1028
+ this.error(error);
1029
+ }
1030
+ }
1031
+ #resolve() {
1032
+ this.is_pending = false;
1033
+ for (const e of this.#dirty_effects) {
1034
+ set_signal_status(e, DIRTY);
1035
+ schedule_effect(e);
1036
+ }
1037
+ for (const e of this.#maybe_dirty_effects) {
1038
+ set_signal_status(e, MAYBE_DIRTY);
1039
+ schedule_effect(e);
1040
+ }
1041
+ this.#dirty_effects.clear();
1042
+ this.#maybe_dirty_effects.clear();
1043
+ }
1044
+ /**
1045
+ * Defer an effect inside a pending boundary until the boundary resolves
1046
+ * @param {Effect} effect
1047
+ */
1048
+ defer_effect(effect) {
1049
+ defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
1050
+ }
1051
+ /**
1052
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1053
+ * @returns {boolean}
1054
+ */
1055
+ is_rendered() {
1056
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
1057
+ }
1058
+ has_pending_snippet() {
1059
+ return !!this.#props.pending;
1060
+ }
1061
+ /**
1062
+ * @template T
1063
+ * @param {() => T} fn
1064
+ */
1065
+ #run(fn) {
1066
+ var previous_effect = active_effect;
1067
+ var previous_reaction = active_reaction;
1068
+ var previous_ctx = component_context;
1069
+ set_active_effect(this.#effect);
1070
+ set_active_reaction(this.#effect);
1071
+ set_component_context(this.#effect.ctx);
1072
+ try {
1073
+ return fn();
1074
+ } catch (e) {
1075
+ handle_error(e);
1076
+ return null;
1077
+ } finally {
1078
+ set_active_effect(previous_effect);
1079
+ set_active_reaction(previous_reaction);
1080
+ set_component_context(previous_ctx);
1081
+ }
1082
+ }
1083
+ /**
1084
+ * Updates the pending count associated with the currently visible pending snippet,
1085
+ * if any, such that we can replace the snippet with content once work is done
1086
+ * @param {1 | -1} d
1087
+ */
1088
+ #update_pending_count(d) {
1089
+ if (!this.has_pending_snippet()) {
1090
+ if (this.parent) {
1091
+ this.parent.#update_pending_count(d);
1092
+ }
1093
+ return;
1094
+ }
1095
+ this.#pending_count += d;
1096
+ if (this.#pending_count === 0) {
1097
+ this.#resolve();
1098
+ if (this.#pending_effect) {
1099
+ pause_effect(this.#pending_effect, () => {
1100
+ this.#pending_effect = null;
1101
+ });
1102
+ }
1103
+ if (this.#offscreen_fragment) {
1104
+ this.#anchor.before(this.#offscreen_fragment);
1105
+ this.#offscreen_fragment = null;
1106
+ }
1107
+ }
1108
+ }
1109
+ /**
1110
+ * Update the source that powers `$effect.pending()` inside this boundary,
1111
+ * and controls when the current `pending` snippet (if any) is removed.
1112
+ * Do not call from inside the class
1113
+ * @param {1 | -1} d
1114
+ */
1115
+ update_pending_count(d) {
1116
+ this.#update_pending_count(d);
1117
+ this.#local_pending_count += d;
1118
+ if (!this.#effect_pending || this.#pending_count_update_queued) return;
1119
+ this.#pending_count_update_queued = true;
1120
+ queue_micro_task(() => {
1121
+ this.#pending_count_update_queued = false;
1122
+ if (this.#effect_pending) {
1123
+ internal_set(this.#effect_pending, this.#local_pending_count);
1124
+ }
1125
+ });
1126
+ }
1127
+ get_effect_pending() {
1128
+ this.#effect_pending_subscriber();
1129
+ return get(
1130
+ /** @type {Source<number>} */
1131
+ this.#effect_pending
1132
+ );
1133
+ }
1134
+ /** @param {unknown} error */
1135
+ error(error) {
1136
+ var onerror = this.#props.onerror;
1137
+ let failed = this.#props.failed;
1138
+ if (!onerror && !failed) {
1139
+ throw error;
1140
+ }
1141
+ if (this.#main_effect) {
1142
+ destroy_effect(this.#main_effect);
1143
+ this.#main_effect = null;
1144
+ }
1145
+ if (this.#pending_effect) {
1146
+ destroy_effect(this.#pending_effect);
1147
+ this.#pending_effect = null;
1148
+ }
1149
+ if (this.#failed_effect) {
1150
+ destroy_effect(this.#failed_effect);
1151
+ this.#failed_effect = null;
1152
+ }
1153
+ if (hydrating) {
1154
+ set_hydrate_node(
1155
+ /** @type {TemplateNode} */
1156
+ this.#hydrate_open
1157
+ );
1158
+ next();
1159
+ set_hydrate_node(skip_nodes());
1160
+ }
1161
+ var did_reset = false;
1162
+ var calling_on_error = false;
1163
+ const reset = () => {
1164
+ if (did_reset) {
1165
+ svelte_boundary_reset_noop();
1166
+ return;
1167
+ }
1168
+ did_reset = true;
1169
+ if (calling_on_error) {
1170
+ svelte_boundary_reset_onerror();
1171
+ }
1172
+ if (this.#failed_effect !== null) {
1173
+ pause_effect(this.#failed_effect, () => {
1174
+ this.#failed_effect = null;
1175
+ });
1176
+ }
1177
+ this.#run(() => {
1178
+ Batch.ensure();
1179
+ this.#render();
1180
+ });
1181
+ };
1182
+ const handle_error_result = (transformed_error) => {
1183
+ try {
1184
+ calling_on_error = true;
1185
+ onerror?.(transformed_error, reset);
1186
+ calling_on_error = false;
1187
+ } catch (error2) {
1188
+ invoke_error_boundary(error2, this.#effect && this.#effect.parent);
1189
+ }
1190
+ if (failed) {
1191
+ this.#failed_effect = this.#run(() => {
1192
+ Batch.ensure();
1193
+ try {
1194
+ return branch(() => {
1195
+ var effect = (
1196
+ /** @type {Effect} */
1197
+ active_effect
1198
+ );
1199
+ effect.b = this;
1200
+ effect.f |= BOUNDARY_EFFECT;
1201
+ failed(
1202
+ this.#anchor,
1203
+ () => transformed_error,
1204
+ () => reset
1205
+ );
1206
+ });
1207
+ } catch (error2) {
1208
+ invoke_error_boundary(
1209
+ error2,
1210
+ /** @type {Effect} */
1211
+ this.#effect.parent
1212
+ );
1213
+ return null;
1214
+ }
1215
+ });
1216
+ }
1217
+ };
1218
+ queue_micro_task(() => {
1219
+ var result;
1220
+ try {
1221
+ result = this.transform_error(error);
1222
+ } catch (e) {
1223
+ invoke_error_boundary(e, this.#effect && this.#effect.parent);
1224
+ return;
1225
+ }
1226
+ if (result !== null && typeof result === "object" && typeof /** @type {any} */
1227
+ result.then === "function") {
1228
+ result.then(
1229
+ handle_error_result,
1230
+ /** @param {unknown} e */
1231
+ (e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
1232
+ );
1233
+ } else {
1234
+ handle_error_result(result);
1235
+ }
1236
+ });
1237
+ }
1238
+ }
1239
+ function destroy_derived_effects(derived2) {
1240
+ var effects = derived2.effects;
1241
+ if (effects !== null) {
1242
+ derived2.effects = null;
1243
+ for (var i = 0; i < effects.length; i += 1) {
1244
+ destroy_effect(
1245
+ /** @type {Effect} */
1246
+ effects[i]
1247
+ );
1248
+ }
1249
+ }
1250
+ }
1251
+ function get_derived_parent_effect(derived2) {
1252
+ var parent = derived2.parent;
1253
+ while (parent !== null) {
1254
+ if ((parent.f & DERIVED) === 0) {
1255
+ return (parent.f & DESTROYED) === 0 ? (
1256
+ /** @type {Effect} */
1257
+ parent
1258
+ ) : null;
1259
+ }
1260
+ parent = parent.parent;
1261
+ }
1262
+ return null;
1263
+ }
1264
+ function execute_derived(derived2) {
1265
+ var value;
1266
+ var prev_active_effect = active_effect;
1267
+ set_active_effect(get_derived_parent_effect(derived2));
1268
+ {
1269
+ try {
1270
+ derived2.f &= ~WAS_MARKED;
1271
+ destroy_derived_effects(derived2);
1272
+ value = update_reaction(derived2);
1273
+ } finally {
1274
+ set_active_effect(prev_active_effect);
1275
+ }
1276
+ }
1277
+ return value;
1278
+ }
1279
+ function update_derived(derived2) {
1280
+ var value = execute_derived(derived2);
1281
+ if (!derived2.equals(value)) {
1282
+ derived2.wv = increment_write_version();
1283
+ if (!current_batch?.is_fork || derived2.deps === null) {
1284
+ derived2.v = value;
1285
+ if (derived2.deps === null) {
1286
+ set_signal_status(derived2, CLEAN);
1287
+ return;
1288
+ }
1289
+ }
1290
+ }
1291
+ if (is_destroying_effect) {
1292
+ return;
1293
+ }
1294
+ if (batch_values !== null) {
1295
+ if (effect_tracking() || current_batch?.is_fork) {
1296
+ batch_values.set(derived2, value);
1297
+ }
1298
+ } else {
1299
+ update_derived_status(derived2);
1300
+ }
1301
+ }
1302
+ function freeze_derived_effects(derived2) {
1303
+ if (derived2.effects === null) return;
1304
+ for (const e of derived2.effects) {
1305
+ if (e.teardown || e.ac) {
1306
+ e.teardown?.();
1307
+ e.ac?.abort(STALE_REACTION);
1308
+ e.teardown = noop;
1309
+ e.ac = null;
1310
+ remove_reactions(e, 0);
1311
+ destroy_effect_children(e);
1312
+ }
1313
+ }
1314
+ }
1315
+ function unfreeze_derived_effects(derived2) {
1316
+ if (derived2.effects === null) return;
1317
+ for (const e of derived2.effects) {
1318
+ if (e.teardown) {
1319
+ update_effect(e);
1320
+ }
1321
+ }
1322
+ }
1323
+ let eager_effects = /* @__PURE__ */ new Set();
1324
+ const old_values = /* @__PURE__ */ new Map();
1325
+ let eager_effects_deferred = false;
1326
+ function source(v, stack) {
1327
+ var signal = {
1328
+ f: 0,
1329
+ // TODO ideally we could skip this altogether, but it causes type errors
1330
+ v,
1331
+ reactions: null,
1332
+ equals,
1333
+ rv: 0,
1334
+ wv: 0
1335
+ };
1336
+ return signal;
1337
+ }
1338
+ // @__NO_SIDE_EFFECTS__
1339
+ function state(v, stack) {
1340
+ const s = source(v);
1341
+ push_reaction_value(s);
1342
+ return s;
1343
+ }
1344
+ // @__NO_SIDE_EFFECTS__
1345
+ function mutable_source(initial_value, immutable = false, trackable = true) {
1346
+ const s = source(initial_value);
1347
+ if (!immutable) {
1348
+ s.equals = safe_equals;
1349
+ }
1350
+ return s;
1351
+ }
1352
+ function set(source2, value, should_proxy = false) {
1353
+ if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1354
+ // to ensure we error if state is set inside an inspect effect
1355
+ (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && (current_sources === null || !includes.call(current_sources, source2))) {
1356
+ state_unsafe_mutation();
1357
+ }
1358
+ let new_value = should_proxy ? proxy(value) : value;
1359
+ return internal_set(source2, new_value);
1360
+ }
1361
+ function internal_set(source2, value) {
1362
+ if (!source2.equals(value)) {
1363
+ var old_value = source2.v;
1364
+ if (is_destroying_effect) {
1365
+ old_values.set(source2, value);
1366
+ } else {
1367
+ old_values.set(source2, old_value);
1368
+ }
1369
+ source2.v = value;
1370
+ var batch = Batch.ensure();
1371
+ batch.capture(source2, old_value);
1372
+ if ((source2.f & DERIVED) !== 0) {
1373
+ const derived2 = (
1374
+ /** @type {Derived} */
1375
+ source2
1376
+ );
1377
+ if ((source2.f & DIRTY) !== 0) {
1378
+ execute_derived(derived2);
1379
+ }
1380
+ update_derived_status(derived2);
1381
+ }
1382
+ source2.wv = increment_write_version();
1383
+ mark_reactions(source2, DIRTY);
1384
+ if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
1385
+ if (untracked_writes === null) {
1386
+ set_untracked_writes([source2]);
1387
+ } else {
1388
+ untracked_writes.push(source2);
1389
+ }
1390
+ }
1391
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
1392
+ flush_eager_effects();
1393
+ }
1394
+ }
1395
+ return value;
1396
+ }
1397
+ function flush_eager_effects() {
1398
+ eager_effects_deferred = false;
1399
+ for (const effect of eager_effects) {
1400
+ if ((effect.f & CLEAN) !== 0) {
1401
+ set_signal_status(effect, MAYBE_DIRTY);
1402
+ }
1403
+ if (is_dirty(effect)) {
1404
+ update_effect(effect);
1405
+ }
1406
+ }
1407
+ eager_effects.clear();
1408
+ }
1409
+ function increment(source2) {
1410
+ set(source2, source2.v + 1);
1411
+ }
1412
+ function mark_reactions(signal, status) {
1413
+ var reactions = signal.reactions;
1414
+ if (reactions === null) return;
1415
+ var length = reactions.length;
1416
+ for (var i = 0; i < length; i++) {
1417
+ var reaction = reactions[i];
1418
+ var flags2 = reaction.f;
1419
+ var not_dirty = (flags2 & DIRTY) === 0;
1420
+ if (not_dirty) {
1421
+ set_signal_status(reaction, status);
1422
+ }
1423
+ if ((flags2 & DERIVED) !== 0) {
1424
+ var derived2 = (
1425
+ /** @type {Derived} */
1426
+ reaction
1427
+ );
1428
+ batch_values?.delete(derived2);
1429
+ if ((flags2 & WAS_MARKED) === 0) {
1430
+ if (flags2 & CONNECTED) {
1431
+ reaction.f |= WAS_MARKED;
1432
+ }
1433
+ mark_reactions(derived2, MAYBE_DIRTY);
1434
+ }
1435
+ } else if (not_dirty) {
1436
+ if ((flags2 & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
1437
+ eager_block_effects.add(
1438
+ /** @type {Effect} */
1439
+ reaction
1440
+ );
1441
+ }
1442
+ schedule_effect(
1443
+ /** @type {Effect} */
1444
+ reaction
1445
+ );
1446
+ }
1447
+ }
1448
+ }
1449
+ function proxy(value) {
1450
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) {
1451
+ return value;
1452
+ }
1453
+ const prototype = get_prototype_of(value);
1454
+ if (prototype !== object_prototype && prototype !== array_prototype) {
1455
+ return value;
1456
+ }
1457
+ var sources = /* @__PURE__ */ new Map();
1458
+ var is_proxied_array = is_array(value);
1459
+ var version = /* @__PURE__ */ state(0);
1460
+ var parent_version = update_version;
1461
+ var with_parent = (fn) => {
1462
+ if (update_version === parent_version) {
1463
+ return fn();
1464
+ }
1465
+ var reaction = active_reaction;
1466
+ var version2 = update_version;
1467
+ set_active_reaction(null);
1468
+ set_update_version(parent_version);
1469
+ var result = fn();
1470
+ set_active_reaction(reaction);
1471
+ set_update_version(version2);
1472
+ return result;
1473
+ };
1474
+ if (is_proxied_array) {
1475
+ sources.set("length", /* @__PURE__ */ state(
1476
+ /** @type {any[]} */
1477
+ value.length
1478
+ ));
1479
+ }
1480
+ return new Proxy(
1481
+ /** @type {any} */
1482
+ value,
1483
+ {
1484
+ defineProperty(_, prop, descriptor) {
1485
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) {
1486
+ state_descriptors_fixed();
1487
+ }
1488
+ var s = sources.get(prop);
1489
+ if (s === void 0) {
1490
+ with_parent(() => {
1491
+ var s2 = /* @__PURE__ */ state(descriptor.value);
1492
+ sources.set(prop, s2);
1493
+ return s2;
1494
+ });
1495
+ } else {
1496
+ set(s, descriptor.value, true);
1497
+ }
1498
+ return true;
1499
+ },
1500
+ deleteProperty(target, prop) {
1501
+ var s = sources.get(prop);
1502
+ if (s === void 0) {
1503
+ if (prop in target) {
1504
+ const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1505
+ sources.set(prop, s2);
1506
+ increment(version);
1507
+ }
1508
+ } else {
1509
+ set(s, UNINITIALIZED);
1510
+ increment(version);
1511
+ }
1512
+ return true;
1513
+ },
1514
+ get(target, prop, receiver) {
1515
+ if (prop === STATE_SYMBOL) {
1516
+ return value;
1517
+ }
1518
+ var s = sources.get(prop);
1519
+ var exists = prop in target;
1520
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1521
+ s = with_parent(() => {
1522
+ var p = proxy(exists ? target[prop] : UNINITIALIZED);
1523
+ var s2 = /* @__PURE__ */ state(p);
1524
+ return s2;
1525
+ });
1526
+ sources.set(prop, s);
1527
+ }
1528
+ if (s !== void 0) {
1529
+ var v = get(s);
1530
+ return v === UNINITIALIZED ? void 0 : v;
1531
+ }
1532
+ return Reflect.get(target, prop, receiver);
1533
+ },
1534
+ getOwnPropertyDescriptor(target, prop) {
1535
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1536
+ if (descriptor && "value" in descriptor) {
1537
+ var s = sources.get(prop);
1538
+ if (s) descriptor.value = get(s);
1539
+ } else if (descriptor === void 0) {
1540
+ var source2 = sources.get(prop);
1541
+ var value2 = source2?.v;
1542
+ if (source2 !== void 0 && value2 !== UNINITIALIZED) {
1543
+ return {
1544
+ enumerable: true,
1545
+ configurable: true,
1546
+ value: value2,
1547
+ writable: true
1548
+ };
1549
+ }
1550
+ }
1551
+ return descriptor;
1552
+ },
1553
+ has(target, prop) {
1554
+ if (prop === STATE_SYMBOL) {
1555
+ return true;
1556
+ }
1557
+ var s = sources.get(prop);
1558
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
1559
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
1560
+ if (s === void 0) {
1561
+ s = with_parent(() => {
1562
+ var p = has ? proxy(target[prop]) : UNINITIALIZED;
1563
+ var s2 = /* @__PURE__ */ state(p);
1564
+ return s2;
1565
+ });
1566
+ sources.set(prop, s);
1567
+ }
1568
+ var value2 = get(s);
1569
+ if (value2 === UNINITIALIZED) {
1570
+ return false;
1571
+ }
1572
+ }
1573
+ return has;
1574
+ },
1575
+ set(target, prop, value2, receiver) {
1576
+ var s = sources.get(prop);
1577
+ var has = prop in target;
1578
+ if (is_proxied_array && prop === "length") {
1579
+ for (var i = value2; i < /** @type {Source<number>} */
1580
+ s.v; i += 1) {
1581
+ var other_s = sources.get(i + "");
1582
+ if (other_s !== void 0) {
1583
+ set(other_s, UNINITIALIZED);
1584
+ } else if (i in target) {
1585
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1586
+ sources.set(i + "", other_s);
1587
+ }
1588
+ }
1589
+ }
1590
+ if (s === void 0) {
1591
+ if (!has || get_descriptor(target, prop)?.writable) {
1592
+ s = with_parent(() => /* @__PURE__ */ state(void 0));
1593
+ set(s, proxy(value2));
1594
+ sources.set(prop, s);
1595
+ }
1596
+ } else {
1597
+ has = s.v !== UNINITIALIZED;
1598
+ var p = with_parent(() => proxy(value2));
1599
+ set(s, p);
1600
+ }
1601
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1602
+ if (descriptor?.set) {
1603
+ descriptor.set.call(receiver, value2);
1604
+ }
1605
+ if (!has) {
1606
+ if (is_proxied_array && typeof prop === "string") {
1607
+ var ls = (
1608
+ /** @type {Source<number>} */
1609
+ sources.get("length")
1610
+ );
1611
+ var n = Number(prop);
1612
+ if (Number.isInteger(n) && n >= ls.v) {
1613
+ set(ls, n + 1);
1614
+ }
1615
+ }
1616
+ increment(version);
1617
+ }
1618
+ return true;
1619
+ },
1620
+ ownKeys(target) {
1621
+ get(version);
1622
+ var own_keys = Reflect.ownKeys(target).filter((key2) => {
1623
+ var source3 = sources.get(key2);
1624
+ return source3 === void 0 || source3.v !== UNINITIALIZED;
1625
+ });
1626
+ for (var [key, source2] of sources) {
1627
+ if (source2.v !== UNINITIALIZED && !(key in target)) {
1628
+ own_keys.push(key);
1629
+ }
1630
+ }
1631
+ return own_keys;
1632
+ },
1633
+ setPrototypeOf() {
1634
+ state_prototype_fixed();
1635
+ }
1636
+ }
1637
+ );
1638
+ }
1639
+ var $window;
1640
+ var first_child_getter;
1641
+ var next_sibling_getter;
1642
+ function init_operations() {
1643
+ if ($window !== void 0) {
1644
+ return;
1645
+ }
1646
+ $window = window;
1647
+ var element_prototype = Element.prototype;
1648
+ var node_prototype = Node.prototype;
1649
+ var text_prototype = Text.prototype;
1650
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
1651
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
1652
+ if (is_extensible(element_prototype)) {
1653
+ element_prototype.__click = void 0;
1654
+ element_prototype.__className = void 0;
1655
+ element_prototype.__attributes = null;
1656
+ element_prototype.__style = void 0;
1657
+ element_prototype.__e = void 0;
1658
+ }
1659
+ if (is_extensible(text_prototype)) {
1660
+ text_prototype.__t = void 0;
1661
+ }
1662
+ }
1663
+ function create_text(value = "") {
1664
+ return document.createTextNode(value);
1665
+ }
1666
+ // @__NO_SIDE_EFFECTS__
1667
+ function get_first_child(node) {
1668
+ return (
1669
+ /** @type {TemplateNode | null} */
1670
+ first_child_getter.call(node)
1671
+ );
1672
+ }
1673
+ // @__NO_SIDE_EFFECTS__
1674
+ function get_next_sibling(node) {
1675
+ return (
1676
+ /** @type {TemplateNode | null} */
1677
+ next_sibling_getter.call(node)
1678
+ );
1679
+ }
1680
+ function clear_text_content(node) {
1681
+ node.textContent = "";
1682
+ }
1683
+ function without_reactive_context(fn) {
1684
+ var previous_reaction = active_reaction;
1685
+ var previous_effect = active_effect;
1686
+ set_active_reaction(null);
1687
+ set_active_effect(null);
1688
+ try {
1689
+ return fn();
1690
+ } finally {
1691
+ set_active_reaction(previous_reaction);
1692
+ set_active_effect(previous_effect);
1693
+ }
1694
+ }
1695
+ function push_effect(effect, parent_effect) {
1696
+ var parent_last = parent_effect.last;
1697
+ if (parent_last === null) {
1698
+ parent_effect.last = parent_effect.first = effect;
1699
+ } else {
1700
+ parent_last.next = effect;
1701
+ effect.prev = parent_last;
1702
+ parent_effect.last = effect;
1703
+ }
1704
+ }
1705
+ function create_effect(type, fn) {
1706
+ var parent = active_effect;
1707
+ if (parent !== null && (parent.f & INERT) !== 0) {
1708
+ type |= INERT;
1709
+ }
1710
+ var effect = {
1711
+ ctx: component_context,
1712
+ deps: null,
1713
+ nodes: null,
1714
+ f: type | DIRTY | CONNECTED,
1715
+ first: null,
1716
+ fn,
1717
+ last: null,
1718
+ next: null,
1719
+ parent,
1720
+ b: parent && parent.b,
1721
+ prev: null,
1722
+ teardown: null,
1723
+ wv: 0,
1724
+ ac: null
1725
+ };
1726
+ var e = effect;
1727
+ if ((type & EFFECT) !== 0) {
1728
+ if (collected_effects !== null) {
1729
+ collected_effects.push(effect);
1730
+ } else {
1731
+ schedule_effect(effect);
1732
+ }
1733
+ } else if (fn !== null) {
1734
+ try {
1735
+ update_effect(effect);
1736
+ } catch (e2) {
1737
+ destroy_effect(effect);
1738
+ throw e2;
1739
+ }
1740
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child
1741
+ (e.f & EFFECT_PRESERVED) === 0) {
1742
+ e = e.first;
1743
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
1744
+ e.f |= EFFECT_TRANSPARENT;
1745
+ }
1746
+ }
1747
+ }
1748
+ if (e !== null) {
1749
+ e.parent = parent;
1750
+ if (parent !== null) {
1751
+ push_effect(e, parent);
1752
+ }
1753
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
1754
+ var derived2 = (
1755
+ /** @type {Derived} */
1756
+ active_reaction
1757
+ );
1758
+ (derived2.effects ??= []).push(e);
1759
+ }
1760
+ }
1761
+ return effect;
1762
+ }
1763
+ function effect_tracking() {
1764
+ return active_reaction !== null && !untracking;
1765
+ }
1766
+ function create_user_effect(fn) {
1767
+ return create_effect(EFFECT | USER_EFFECT, fn);
1768
+ }
1769
+ function component_root(fn) {
1770
+ Batch.ensure();
1771
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn);
1772
+ return (options = {}) => {
1773
+ return new Promise((fulfil) => {
1774
+ if (options.outro) {
1775
+ pause_effect(effect, () => {
1776
+ destroy_effect(effect);
1777
+ fulfil(void 0);
1778
+ });
1779
+ } else {
1780
+ destroy_effect(effect);
1781
+ fulfil(void 0);
1782
+ }
1783
+ });
1784
+ };
1785
+ }
1786
+ function render_effect(fn, flags2 = 0) {
1787
+ return create_effect(RENDER_EFFECT | flags2, fn);
1788
+ }
1789
+ function block(fn, flags2 = 0) {
1790
+ var effect = create_effect(BLOCK_EFFECT | flags2, fn);
1791
+ return effect;
1792
+ }
1793
+ function branch(fn) {
1794
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn);
1795
+ }
1796
+ function execute_effect_teardown(effect) {
1797
+ var teardown = effect.teardown;
1798
+ if (teardown !== null) {
1799
+ const previously_destroying_effect = is_destroying_effect;
1800
+ const previous_reaction = active_reaction;
1801
+ set_is_destroying_effect(true);
1802
+ set_active_reaction(null);
1803
+ try {
1804
+ teardown.call(null);
1805
+ } finally {
1806
+ set_is_destroying_effect(previously_destroying_effect);
1807
+ set_active_reaction(previous_reaction);
1808
+ }
1809
+ }
1810
+ }
1811
+ function destroy_effect_children(signal, remove_dom = false) {
1812
+ var effect = signal.first;
1813
+ signal.first = signal.last = null;
1814
+ while (effect !== null) {
1815
+ const controller2 = effect.ac;
1816
+ if (controller2 !== null) {
1817
+ without_reactive_context(() => {
1818
+ controller2.abort(STALE_REACTION);
1819
+ });
1820
+ }
1821
+ var next2 = effect.next;
1822
+ if ((effect.f & ROOT_EFFECT) !== 0) {
1823
+ effect.parent = null;
1824
+ } else {
1825
+ destroy_effect(effect, remove_dom);
1826
+ }
1827
+ effect = next2;
1828
+ }
1829
+ }
1830
+ function destroy_block_effect_children(signal) {
1831
+ var effect = signal.first;
1832
+ while (effect !== null) {
1833
+ var next2 = effect.next;
1834
+ if ((effect.f & BRANCH_EFFECT) === 0) {
1835
+ destroy_effect(effect);
1836
+ }
1837
+ effect = next2;
1838
+ }
1839
+ }
1840
+ function destroy_effect(effect, remove_dom = true) {
1841
+ var removed = false;
1842
+ if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
1843
+ remove_effect_dom(
1844
+ effect.nodes.start,
1845
+ /** @type {TemplateNode} */
1846
+ effect.nodes.end
1847
+ );
1848
+ removed = true;
1849
+ }
1850
+ destroy_effect_children(effect, remove_dom && !removed);
1851
+ remove_reactions(effect, 0);
1852
+ set_signal_status(effect, DESTROYED);
1853
+ var transitions = effect.nodes && effect.nodes.t;
1854
+ if (transitions !== null) {
1855
+ for (const transition of transitions) {
1856
+ transition.stop();
1857
+ }
1858
+ }
1859
+ execute_effect_teardown(effect);
1860
+ var parent = effect.parent;
1861
+ if (parent !== null && parent.first !== null) {
1862
+ unlink_effect(effect);
1863
+ }
1864
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = null;
1865
+ }
1866
+ function remove_effect_dom(node, end) {
1867
+ while (node !== null) {
1868
+ var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1869
+ node.remove();
1870
+ node = next2;
1871
+ }
1872
+ }
1873
+ function unlink_effect(effect) {
1874
+ var parent = effect.parent;
1875
+ var prev = effect.prev;
1876
+ var next2 = effect.next;
1877
+ if (prev !== null) prev.next = next2;
1878
+ if (next2 !== null) next2.prev = prev;
1879
+ if (parent !== null) {
1880
+ if (parent.first === effect) parent.first = next2;
1881
+ if (parent.last === effect) parent.last = prev;
1882
+ }
1883
+ }
1884
+ function pause_effect(effect, callback, destroy = true) {
1885
+ var transitions = [];
1886
+ pause_children(effect, transitions, true);
1887
+ var fn = () => {
1888
+ if (destroy) destroy_effect(effect);
1889
+ if (callback) callback();
1890
+ };
1891
+ var remaining = transitions.length;
1892
+ if (remaining > 0) {
1893
+ var check = () => --remaining || fn();
1894
+ for (var transition of transitions) {
1895
+ transition.out(check);
1896
+ }
1897
+ } else {
1898
+ fn();
1899
+ }
1900
+ }
1901
+ function pause_children(effect, transitions, local) {
1902
+ if ((effect.f & INERT) !== 0) return;
1903
+ effect.f ^= INERT;
1904
+ var t = effect.nodes && effect.nodes.t;
1905
+ if (t !== null) {
1906
+ for (const transition of t) {
1907
+ if (transition.is_global || local) {
1908
+ transitions.push(transition);
1909
+ }
1910
+ }
1911
+ }
1912
+ var child = effect.first;
1913
+ while (child !== null) {
1914
+ var sibling = child.next;
1915
+ var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent,
1916
+ // it means the parent block effect was pruned. In that case,
1917
+ // transparency information was transferred to the branch effect.
1918
+ (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
1919
+ pause_children(child, transitions, transparent ? local : false);
1920
+ child = sibling;
1921
+ }
1922
+ }
1923
+ function move_effect(effect, fragment) {
1924
+ if (!effect.nodes) return;
1925
+ var node = effect.nodes.start;
1926
+ var end = effect.nodes.end;
1927
+ while (node !== null) {
1928
+ var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1929
+ fragment.append(node);
1930
+ node = next2;
1931
+ }
1932
+ }
1933
+ let is_updating_effect = false;
1934
+ let is_destroying_effect = false;
1935
+ function set_is_destroying_effect(value) {
1936
+ is_destroying_effect = value;
1937
+ }
1938
+ let active_reaction = null;
1939
+ let untracking = false;
1940
+ function set_active_reaction(reaction) {
1941
+ active_reaction = reaction;
1942
+ }
1943
+ let active_effect = null;
1944
+ function set_active_effect(effect) {
1945
+ active_effect = effect;
1946
+ }
1947
+ let current_sources = null;
1948
+ function push_reaction_value(value) {
1949
+ if (active_reaction !== null && true) {
1950
+ if (current_sources === null) {
1951
+ current_sources = [value];
1952
+ } else {
1953
+ current_sources.push(value);
1954
+ }
1955
+ }
1956
+ }
1957
+ let new_deps = null;
1958
+ let skipped_deps = 0;
1959
+ let untracked_writes = null;
1960
+ function set_untracked_writes(value) {
1961
+ untracked_writes = value;
1962
+ }
1963
+ let write_version = 1;
1964
+ let read_version = 0;
1965
+ let update_version = read_version;
1966
+ function set_update_version(value) {
1967
+ update_version = value;
1968
+ }
1969
+ function increment_write_version() {
1970
+ return ++write_version;
1971
+ }
1972
+ function is_dirty(reaction) {
1973
+ var flags2 = reaction.f;
1974
+ if ((flags2 & DIRTY) !== 0) {
1975
+ return true;
1976
+ }
1977
+ if (flags2 & DERIVED) {
1978
+ reaction.f &= ~WAS_MARKED;
1979
+ }
1980
+ if ((flags2 & MAYBE_DIRTY) !== 0) {
1981
+ var dependencies = (
1982
+ /** @type {Value[]} */
1983
+ reaction.deps
1984
+ );
1985
+ var length = dependencies.length;
1986
+ for (var i = 0; i < length; i++) {
1987
+ var dependency = dependencies[i];
1988
+ if (is_dirty(
1989
+ /** @type {Derived} */
1990
+ dependency
1991
+ )) {
1992
+ update_derived(
1993
+ /** @type {Derived} */
1994
+ dependency
1995
+ );
1996
+ }
1997
+ if (dependency.wv > reaction.wv) {
1998
+ return true;
1999
+ }
2000
+ }
2001
+ if ((flags2 & CONNECTED) !== 0 && // During time traveling we don't want to reset the status so that
2002
+ // traversal of the graph in the other batches still happens
2003
+ batch_values === null) {
2004
+ set_signal_status(reaction, CLEAN);
2005
+ }
2006
+ }
2007
+ return false;
2008
+ }
2009
+ function schedule_possible_effect_self_invalidation(signal, effect, root2 = true) {
2010
+ var reactions = signal.reactions;
2011
+ if (reactions === null) return;
2012
+ if (current_sources !== null && includes.call(current_sources, signal)) {
2013
+ return;
2014
+ }
2015
+ for (var i = 0; i < reactions.length; i++) {
2016
+ var reaction = reactions[i];
2017
+ if ((reaction.f & DERIVED) !== 0) {
2018
+ schedule_possible_effect_self_invalidation(
2019
+ /** @type {Derived} */
2020
+ reaction,
2021
+ effect,
2022
+ false
2023
+ );
2024
+ } else if (effect === reaction) {
2025
+ if (root2) {
2026
+ set_signal_status(reaction, DIRTY);
2027
+ } else if ((reaction.f & CLEAN) !== 0) {
2028
+ set_signal_status(reaction, MAYBE_DIRTY);
2029
+ }
2030
+ schedule_effect(
2031
+ /** @type {Effect} */
2032
+ reaction
2033
+ );
2034
+ }
2035
+ }
2036
+ }
2037
+ function update_reaction(reaction) {
2038
+ var previous_deps = new_deps;
2039
+ var previous_skipped_deps = skipped_deps;
2040
+ var previous_untracked_writes = untracked_writes;
2041
+ var previous_reaction = active_reaction;
2042
+ var previous_sources = current_sources;
2043
+ var previous_component_context = component_context;
2044
+ var previous_untracking = untracking;
2045
+ var previous_update_version = update_version;
2046
+ var flags2 = reaction.f;
2047
+ new_deps = /** @type {null | Value[]} */
2048
+ null;
2049
+ skipped_deps = 0;
2050
+ untracked_writes = null;
2051
+ active_reaction = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2052
+ current_sources = null;
2053
+ set_component_context(reaction.ctx);
2054
+ untracking = false;
2055
+ update_version = ++read_version;
2056
+ if (reaction.ac !== null) {
2057
+ without_reactive_context(() => {
2058
+ reaction.ac.abort(STALE_REACTION);
2059
+ });
2060
+ reaction.ac = null;
2061
+ }
2062
+ try {
2063
+ reaction.f |= REACTION_IS_UPDATING;
2064
+ var fn = (
2065
+ /** @type {Function} */
2066
+ reaction.fn
2067
+ );
2068
+ var result = fn();
2069
+ reaction.f |= REACTION_RAN;
2070
+ var deps = reaction.deps;
2071
+ var is_fork = current_batch?.is_fork;
2072
+ if (new_deps !== null) {
2073
+ var i;
2074
+ if (!is_fork) {
2075
+ remove_reactions(reaction, skipped_deps);
2076
+ }
2077
+ if (deps !== null && skipped_deps > 0) {
2078
+ deps.length = skipped_deps + new_deps.length;
2079
+ for (i = 0; i < new_deps.length; i++) {
2080
+ deps[skipped_deps + i] = new_deps[i];
2081
+ }
2082
+ } else {
2083
+ reaction.deps = deps = new_deps;
2084
+ }
2085
+ if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
2086
+ for (i = skipped_deps; i < deps.length; i++) {
2087
+ (deps[i].reactions ??= []).push(reaction);
2088
+ }
2089
+ }
2090
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2091
+ remove_reactions(reaction, skipped_deps);
2092
+ deps.length = skipped_deps;
2093
+ }
2094
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) {
2095
+ for (i = 0; i < /** @type {Source[]} */
2096
+ untracked_writes.length; i++) {
2097
+ schedule_possible_effect_self_invalidation(
2098
+ untracked_writes[i],
2099
+ /** @type {Effect} */
2100
+ reaction
2101
+ );
2102
+ }
2103
+ }
2104
+ if (previous_reaction !== null && previous_reaction !== reaction) {
2105
+ read_version++;
2106
+ if (previous_reaction.deps !== null) {
2107
+ for (let i2 = 0; i2 < previous_skipped_deps; i2 += 1) {
2108
+ previous_reaction.deps[i2].rv = read_version;
2109
+ }
2110
+ }
2111
+ if (previous_deps !== null) {
2112
+ for (const dep of previous_deps) {
2113
+ dep.rv = read_version;
2114
+ }
2115
+ }
2116
+ if (untracked_writes !== null) {
2117
+ if (previous_untracked_writes === null) {
2118
+ previous_untracked_writes = untracked_writes;
2119
+ } else {
2120
+ previous_untracked_writes.push(.../** @type {Source[]} */
2121
+ untracked_writes);
2122
+ }
2123
+ }
2124
+ }
2125
+ if ((reaction.f & ERROR_VALUE) !== 0) {
2126
+ reaction.f ^= ERROR_VALUE;
2127
+ }
2128
+ return result;
2129
+ } catch (error) {
2130
+ return handle_error(error);
2131
+ } finally {
2132
+ reaction.f ^= REACTION_IS_UPDATING;
2133
+ new_deps = previous_deps;
2134
+ skipped_deps = previous_skipped_deps;
2135
+ untracked_writes = previous_untracked_writes;
2136
+ active_reaction = previous_reaction;
2137
+ current_sources = previous_sources;
2138
+ set_component_context(previous_component_context);
2139
+ untracking = previous_untracking;
2140
+ update_version = previous_update_version;
2141
+ }
2142
+ }
2143
+ function remove_reaction(signal, dependency) {
2144
+ let reactions = dependency.reactions;
2145
+ if (reactions !== null) {
2146
+ var index = index_of.call(reactions, signal);
2147
+ if (index !== -1) {
2148
+ var new_length = reactions.length - 1;
2149
+ if (new_length === 0) {
2150
+ reactions = dependency.reactions = null;
2151
+ } else {
2152
+ reactions[index] = reactions[new_length];
2153
+ reactions.pop();
2154
+ }
2155
+ }
2156
+ }
2157
+ if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
2158
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
2159
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
2160
+ (new_deps === null || !includes.call(new_deps, dependency))) {
2161
+ var derived2 = (
2162
+ /** @type {Derived} */
2163
+ dependency
2164
+ );
2165
+ if ((derived2.f & CONNECTED) !== 0) {
2166
+ derived2.f ^= CONNECTED;
2167
+ derived2.f &= ~WAS_MARKED;
2168
+ }
2169
+ update_derived_status(derived2);
2170
+ freeze_derived_effects(derived2);
2171
+ remove_reactions(derived2, 0);
2172
+ }
2173
+ }
2174
+ function remove_reactions(signal, start_index) {
2175
+ var dependencies = signal.deps;
2176
+ if (dependencies === null) return;
2177
+ for (var i = start_index; i < dependencies.length; i++) {
2178
+ remove_reaction(signal, dependencies[i]);
2179
+ }
2180
+ }
2181
+ function update_effect(effect) {
2182
+ var flags2 = effect.f;
2183
+ if ((flags2 & DESTROYED) !== 0) {
2184
+ return;
2185
+ }
2186
+ set_signal_status(effect, CLEAN);
2187
+ var previous_effect = active_effect;
2188
+ var was_updating_effect = is_updating_effect;
2189
+ active_effect = effect;
2190
+ is_updating_effect = true;
2191
+ try {
2192
+ if ((flags2 & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
2193
+ destroy_block_effect_children(effect);
2194
+ } else {
2195
+ destroy_effect_children(effect);
2196
+ }
2197
+ execute_effect_teardown(effect);
2198
+ var teardown = update_reaction(effect);
2199
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2200
+ effect.wv = write_version;
2201
+ var dep;
2202
+ if (BROWSER && tracing_mode_flag && (effect.f & DIRTY) !== 0 && effect.deps !== null) ;
2203
+ } finally {
2204
+ is_updating_effect = was_updating_effect;
2205
+ active_effect = previous_effect;
2206
+ }
2207
+ }
2208
+ function get(signal) {
2209
+ var flags2 = signal.f;
2210
+ var is_derived = (flags2 & DERIVED) !== 0;
2211
+ if (active_reaction !== null && !untracking) {
2212
+ var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
2213
+ if (!destroyed && (current_sources === null || !includes.call(current_sources, signal))) {
2214
+ var deps = active_reaction.deps;
2215
+ if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
2216
+ if (signal.rv < read_version) {
2217
+ signal.rv = read_version;
2218
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
2219
+ skipped_deps++;
2220
+ } else if (new_deps === null) {
2221
+ new_deps = [signal];
2222
+ } else {
2223
+ new_deps.push(signal);
2224
+ }
2225
+ }
2226
+ } else {
2227
+ (active_reaction.deps ??= []).push(signal);
2228
+ var reactions = signal.reactions;
2229
+ if (reactions === null) {
2230
+ signal.reactions = [active_reaction];
2231
+ } else if (!includes.call(reactions, active_reaction)) {
2232
+ reactions.push(active_reaction);
2233
+ }
2234
+ }
2235
+ }
2236
+ }
2237
+ if (is_destroying_effect && old_values.has(signal)) {
2238
+ return old_values.get(signal);
2239
+ }
2240
+ if (is_derived) {
2241
+ var derived2 = (
2242
+ /** @type {Derived} */
2243
+ signal
2244
+ );
2245
+ if (is_destroying_effect) {
2246
+ var value = derived2.v;
2247
+ if ((derived2.f & CLEAN) === 0 && derived2.reactions !== null || depends_on_old_values(derived2)) {
2248
+ value = execute_derived(derived2);
2249
+ }
2250
+ old_values.set(derived2, value);
2251
+ return value;
2252
+ }
2253
+ var should_connect = (derived2.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0);
2254
+ var is_new = (derived2.f & REACTION_RAN) === 0;
2255
+ if (is_dirty(derived2)) {
2256
+ if (should_connect) {
2257
+ derived2.f |= CONNECTED;
2258
+ }
2259
+ update_derived(derived2);
2260
+ }
2261
+ if (should_connect && !is_new) {
2262
+ unfreeze_derived_effects(derived2);
2263
+ reconnect(derived2);
2264
+ }
2265
+ }
2266
+ if (batch_values?.has(signal)) {
2267
+ return batch_values.get(signal);
2268
+ }
2269
+ if ((signal.f & ERROR_VALUE) !== 0) {
2270
+ throw signal.v;
2271
+ }
2272
+ return signal.v;
2273
+ }
2274
+ function reconnect(derived2) {
2275
+ derived2.f |= CONNECTED;
2276
+ if (derived2.deps === null) return;
2277
+ for (const dep of derived2.deps) {
2278
+ (dep.reactions ??= []).push(derived2);
2279
+ if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) {
2280
+ unfreeze_derived_effects(
2281
+ /** @type {Derived} */
2282
+ dep
2283
+ );
2284
+ reconnect(
2285
+ /** @type {Derived} */
2286
+ dep
2287
+ );
2288
+ }
2289
+ }
2290
+ }
2291
+ function depends_on_old_values(derived2) {
2292
+ if (derived2.v === UNINITIALIZED) return true;
2293
+ if (derived2.deps === null) return false;
2294
+ for (const dep of derived2.deps) {
2295
+ if (old_values.has(dep)) {
2296
+ return true;
2297
+ }
2298
+ if ((dep.f & DERIVED) !== 0 && depends_on_old_values(
2299
+ /** @type {Derived} */
2300
+ dep
2301
+ )) {
2302
+ return true;
2303
+ }
2304
+ }
2305
+ return false;
2306
+ }
2307
+ function untrack(fn) {
2308
+ var previous_untracking = untracking;
2309
+ try {
2310
+ untracking = true;
2311
+ return fn();
2312
+ } finally {
2313
+ untracking = previous_untracking;
2314
+ }
2315
+ }
2316
+ const VOID_ELEMENT_NAMES = [
2317
+ "area",
2318
+ "base",
2319
+ "br",
2320
+ "col",
2321
+ "command",
2322
+ "embed",
2323
+ "hr",
2324
+ "img",
2325
+ "input",
2326
+ "keygen",
2327
+ "link",
2328
+ "meta",
2329
+ "param",
2330
+ "source",
2331
+ "track",
2332
+ "wbr"
2333
+ ];
2334
+ function is_void(name) {
2335
+ return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === "!doctype";
2336
+ }
2337
+ const DOM_BOOLEAN_ATTRIBUTES = [
2338
+ "allowfullscreen",
2339
+ "async",
2340
+ "autofocus",
2341
+ "autoplay",
2342
+ "checked",
2343
+ "controls",
2344
+ "default",
2345
+ "disabled",
2346
+ "formnovalidate",
2347
+ "indeterminate",
2348
+ "inert",
2349
+ "ismap",
2350
+ "loop",
2351
+ "multiple",
2352
+ "muted",
2353
+ "nomodule",
2354
+ "novalidate",
2355
+ "open",
2356
+ "playsinline",
2357
+ "readonly",
2358
+ "required",
2359
+ "reversed",
2360
+ "seamless",
2361
+ "selected",
2362
+ "webkitdirectory",
2363
+ "defer",
2364
+ "disablepictureinpicture",
2365
+ "disableremoteplayback"
2366
+ ];
2367
+ function is_boolean_attribute(name) {
2368
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
2369
+ }
2370
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
2371
+ function is_passive_event(name) {
2372
+ return PASSIVE_EVENTS.includes(name);
2373
+ }
2374
+ const RAW_TEXT_ELEMENTS = (
2375
+ /** @type {const} */
2376
+ ["textarea", "script", "style", "title"]
2377
+ );
2378
+ function is_raw_text_element(name) {
2379
+ return RAW_TEXT_ELEMENTS.includes(
2380
+ /** @type {typeof RAW_TEXT_ELEMENTS[number]} */
2381
+ name
2382
+ );
2383
+ }
2384
+ const REGEX_VALID_TAG_NAME = /^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]+)*$/u;
2385
+ const event_symbol = /* @__PURE__ */ Symbol("events");
2386
+ const all_registered_events = /* @__PURE__ */ new Set();
2387
+ const root_event_handles = /* @__PURE__ */ new Set();
2388
+ function create_event(event_name, dom, handler, options = {}) {
2389
+ function target_handler(event) {
2390
+ if (!options.capture) {
2391
+ handle_event_propagation.call(dom, event);
2392
+ }
2393
+ if (!event.cancelBubble) {
2394
+ return without_reactive_context(() => {
2395
+ return handler?.call(this, event);
2396
+ });
2397
+ }
2398
+ }
2399
+ if (event_name.startsWith("pointer") || event_name.startsWith("touch") || event_name === "wheel") {
2400
+ queue_micro_task(() => {
2401
+ dom.addEventListener(event_name, target_handler, options);
2402
+ });
2403
+ } else {
2404
+ dom.addEventListener(event_name, target_handler, options);
2405
+ }
2406
+ return target_handler;
2407
+ }
2408
+ function on(element2, type, handler, options = {}) {
2409
+ var target_handler = create_event(type, element2, handler, options);
2410
+ return () => {
2411
+ element2.removeEventListener(type, target_handler, options);
2412
+ };
2413
+ }
2414
+ let last_propagated_event = null;
2415
+ function handle_event_propagation(event) {
2416
+ var handler_element = this;
2417
+ var owner_document = (
2418
+ /** @type {Node} */
2419
+ handler_element.ownerDocument
2420
+ );
2421
+ var event_name = event.type;
2422
+ var path = event.composedPath?.() || [];
2423
+ var current_target = (
2424
+ /** @type {null | Element} */
2425
+ path[0] || event.target
2426
+ );
2427
+ last_propagated_event = event;
2428
+ var path_idx = 0;
2429
+ var handled_at = last_propagated_event === event && event[event_symbol];
2430
+ if (handled_at) {
2431
+ var at_idx = path.indexOf(handled_at);
2432
+ if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
2433
+ window)) {
2434
+ event[event_symbol] = handler_element;
2435
+ return;
2436
+ }
2437
+ var handler_idx = path.indexOf(handler_element);
2438
+ if (handler_idx === -1) {
2439
+ return;
2440
+ }
2441
+ if (at_idx <= handler_idx) {
2442
+ path_idx = at_idx;
2443
+ }
2444
+ }
2445
+ current_target = /** @type {Element} */
2446
+ path[path_idx] || event.target;
2447
+ if (current_target === handler_element) return;
2448
+ define_property(event, "currentTarget", {
2449
+ configurable: true,
2450
+ get() {
2451
+ return current_target || owner_document;
2452
+ }
2453
+ });
2454
+ var previous_reaction = active_reaction;
2455
+ var previous_effect = active_effect;
2456
+ set_active_reaction(null);
2457
+ set_active_effect(null);
2458
+ try {
2459
+ var throw_error;
2460
+ var other_errors = [];
2461
+ while (current_target !== null) {
2462
+ var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */
2463
+ current_target.host || null;
2464
+ try {
2465
+ var delegated = current_target[event_symbol]?.[event_name];
2466
+ if (delegated != null && (!/** @type {any} */
2467
+ current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
2468
+ // -> the target could not have been disabled because it emits the event in the first place
2469
+ event.target === current_target)) {
2470
+ delegated.call(current_target, event);
2471
+ }
2472
+ } catch (error) {
2473
+ if (throw_error) {
2474
+ other_errors.push(error);
2475
+ } else {
2476
+ throw_error = error;
2477
+ }
2478
+ }
2479
+ if (event.cancelBubble || parent_element === handler_element || parent_element === null) {
2480
+ break;
2481
+ }
2482
+ current_target = parent_element;
2483
+ }
2484
+ if (throw_error) {
2485
+ for (let error of other_errors) {
2486
+ queueMicrotask(() => {
2487
+ throw error;
2488
+ });
2489
+ }
2490
+ throw throw_error;
2491
+ }
2492
+ } finally {
2493
+ event[event_symbol] = handler_element;
2494
+ delete event.currentTarget;
2495
+ set_active_reaction(previous_reaction);
2496
+ set_active_effect(previous_effect);
2497
+ }
2498
+ }
2499
+ function assign_nodes(start, end) {
2500
+ var effect = (
2501
+ /** @type {Effect} */
2502
+ active_effect
2503
+ );
2504
+ if (effect.nodes === null) {
2505
+ effect.nodes = { start, end, a: null, t: null };
2506
+ }
2507
+ }
2508
+ function mount(component, options) {
2509
+ return _mount(component, options);
2510
+ }
2511
+ function hydrate(component, options) {
2512
+ init_operations();
2513
+ options.intro = options.intro ?? false;
2514
+ const target = options.target;
2515
+ const was_hydrating = hydrating;
2516
+ const previous_hydrate_node = hydrate_node;
2517
+ try {
2518
+ var anchor = /* @__PURE__ */ get_first_child(target);
2519
+ while (anchor && (anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */
2520
+ anchor.data !== HYDRATION_START)) {
2521
+ anchor = /* @__PURE__ */ get_next_sibling(anchor);
2522
+ }
2523
+ if (!anchor) {
2524
+ throw HYDRATION_ERROR;
2525
+ }
2526
+ set_hydrating(true);
2527
+ set_hydrate_node(
2528
+ /** @type {Comment} */
2529
+ anchor
2530
+ );
2531
+ const instance = _mount(component, { ...options, anchor });
2532
+ set_hydrating(false);
2533
+ return (
2534
+ /** @type {Exports} */
2535
+ instance
2536
+ );
2537
+ } catch (error) {
2538
+ if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) {
2539
+ throw error;
2540
+ }
2541
+ if (error !== HYDRATION_ERROR) {
2542
+ console.warn("Failed to hydrate: ", error);
2543
+ }
2544
+ if (options.recover === false) {
2545
+ hydration_failed();
2546
+ }
2547
+ init_operations();
2548
+ clear_text_content(target);
2549
+ set_hydrating(false);
2550
+ return mount(component, options);
2551
+ } finally {
2552
+ set_hydrating(was_hydrating);
2553
+ set_hydrate_node(previous_hydrate_node);
2554
+ }
2555
+ }
2556
+ const listeners = /* @__PURE__ */ new Map();
2557
+ function _mount(Component, { target, anchor, props = {}, events, context, intro = true, transformError }) {
2558
+ init_operations();
2559
+ var component = void 0;
2560
+ var unmount2 = component_root(() => {
2561
+ var anchor_node = anchor ?? target.appendChild(create_text());
2562
+ boundary(
2563
+ /** @type {TemplateNode} */
2564
+ anchor_node,
2565
+ {
2566
+ pending: () => {
2567
+ }
2568
+ },
2569
+ (anchor_node2) => {
2570
+ push$1({});
2571
+ var ctx = (
2572
+ /** @type {ComponentContext} */
2573
+ component_context
2574
+ );
2575
+ if (context) ctx.c = context;
2576
+ if (events) {
2577
+ props.$$events = events;
2578
+ }
2579
+ if (hydrating) {
2580
+ assign_nodes(
2581
+ /** @type {TemplateNode} */
2582
+ anchor_node2,
2583
+ null
2584
+ );
2585
+ }
2586
+ component = Component(anchor_node2, props) || {};
2587
+ if (hydrating) {
2588
+ active_effect.nodes.end = hydrate_node;
2589
+ if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
2590
+ hydrate_node.data !== HYDRATION_END) {
2591
+ hydration_mismatch();
2592
+ throw HYDRATION_ERROR;
2593
+ }
2594
+ }
2595
+ pop$1();
2596
+ },
2597
+ transformError
2598
+ );
2599
+ var registered_events = /* @__PURE__ */ new Set();
2600
+ var event_handle = (events2) => {
2601
+ for (var i = 0; i < events2.length; i++) {
2602
+ var event_name = events2[i];
2603
+ if (registered_events.has(event_name)) continue;
2604
+ registered_events.add(event_name);
2605
+ var passive = is_passive_event(event_name);
2606
+ for (const node of [target, document]) {
2607
+ var counts = listeners.get(node);
2608
+ if (counts === void 0) {
2609
+ counts = /* @__PURE__ */ new Map();
2610
+ listeners.set(node, counts);
2611
+ }
2612
+ var count = counts.get(event_name);
2613
+ if (count === void 0) {
2614
+ node.addEventListener(event_name, handle_event_propagation, { passive });
2615
+ counts.set(event_name, 1);
2616
+ } else {
2617
+ counts.set(event_name, count + 1);
2618
+ }
2619
+ }
2620
+ }
2621
+ };
2622
+ event_handle(array_from(all_registered_events));
2623
+ root_event_handles.add(event_handle);
2624
+ return () => {
2625
+ for (var event_name of registered_events) {
2626
+ for (const node of [target, document]) {
2627
+ var counts = (
2628
+ /** @type {Map<string, number>} */
2629
+ listeners.get(node)
2630
+ );
2631
+ var count = (
2632
+ /** @type {number} */
2633
+ counts.get(event_name)
2634
+ );
2635
+ if (--count == 0) {
2636
+ node.removeEventListener(event_name, handle_event_propagation);
2637
+ counts.delete(event_name);
2638
+ if (counts.size === 0) {
2639
+ listeners.delete(node);
2640
+ }
2641
+ } else {
2642
+ counts.set(event_name, count);
2643
+ }
2644
+ }
2645
+ }
2646
+ root_event_handles.delete(event_handle);
2647
+ if (anchor_node !== anchor) {
2648
+ anchor_node.parentNode?.removeChild(anchor_node);
2649
+ }
2650
+ };
2651
+ });
2652
+ mounted_components.set(component, unmount2);
2653
+ return component;
2654
+ }
2655
+ let mounted_components = /* @__PURE__ */ new WeakMap();
2656
+ function unmount(component, options) {
2657
+ const fn = mounted_components.get(component);
2658
+ if (fn) {
2659
+ mounted_components.delete(component);
2660
+ return fn(options);
2661
+ }
2662
+ return Promise.resolve();
2663
+ }
2664
+ const ATTR_REGEX = /[&"<]/g;
2665
+ const CONTENT_REGEX = /[&<]/g;
2666
+ function escape_html(value, is_attr) {
2667
+ const str = String(value ?? "");
2668
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
2669
+ pattern.lastIndex = 0;
2670
+ let escaped = "";
2671
+ let last = 0;
2672
+ while (pattern.test(str)) {
2673
+ const i = pattern.lastIndex - 1;
2674
+ const ch = str[i];
2675
+ escaped += str.substring(last, i) + (ch === "&" ? "&amp;" : ch === '"' ? "&quot;" : "&lt;");
2676
+ last = i + 1;
2677
+ }
2678
+ return escaped + str.substring(last);
2679
+ }
2680
+ const replacements = {
2681
+ translate: /* @__PURE__ */ new Map([
2682
+ [true, "yes"],
2683
+ [false, "no"]
2684
+ ])
2685
+ };
2686
+ function attr(name, value, is_boolean = false) {
2687
+ if (name === "hidden" && value !== "until-found") {
2688
+ is_boolean = true;
2689
+ }
2690
+ if (value == null || !value && is_boolean) return "";
2691
+ const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
2692
+ const assignment = is_boolean ? `=""` : `="${escape_html(normalized, true)}"`;
2693
+ return ` ${name}${assignment}`;
2694
+ }
2695
+ function clsx(value) {
2696
+ if (typeof value === "object") {
2697
+ return clsx$1(value);
2698
+ } else {
2699
+ return value ?? "";
2700
+ }
2701
+ }
2702
+ const whitespace = [..." \n\r\f \v\uFEFF"];
2703
+ function to_class(value, hash, directives) {
2704
+ var classname = value == null ? "" : "" + value;
2705
+ if (hash) {
2706
+ classname = classname ? classname + " " + hash : hash;
2707
+ }
2708
+ if (directives) {
2709
+ for (var key of Object.keys(directives)) {
2710
+ if (directives[key]) {
2711
+ classname = classname ? classname + " " + key : key;
2712
+ } else if (classname.length) {
2713
+ var len = key.length;
2714
+ var a = 0;
2715
+ while ((a = classname.indexOf(key, a)) >= 0) {
2716
+ var b = a + len;
2717
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
2718
+ classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
2719
+ } else {
2720
+ a = b;
2721
+ }
2722
+ }
2723
+ }
2724
+ }
2725
+ }
2726
+ return classname === "" ? null : classname;
2727
+ }
2728
+ function append_styles(styles, important = false) {
2729
+ var separator = important ? " !important;" : ";";
2730
+ var css = "";
2731
+ for (var key of Object.keys(styles)) {
2732
+ var value = styles[key];
2733
+ if (value != null && value !== "") {
2734
+ css += " " + key + ": " + value + separator;
2735
+ }
2736
+ }
2737
+ return css;
2738
+ }
2739
+ function to_css_name(name) {
2740
+ if (name[0] !== "-" || name[1] !== "-") {
2741
+ return name.toLowerCase();
2742
+ }
2743
+ return name;
2744
+ }
2745
+ function to_style(value, styles) {
2746
+ if (styles) {
2747
+ var new_style = "";
2748
+ var normal_styles;
2749
+ var important_styles;
2750
+ if (Array.isArray(styles)) {
2751
+ normal_styles = styles[0];
2752
+ important_styles = styles[1];
2753
+ } else {
2754
+ normal_styles = styles;
2755
+ }
2756
+ if (value) {
2757
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
2758
+ var in_str = false;
2759
+ var in_apo = 0;
2760
+ var in_comment = false;
2761
+ var reserved_names = [];
2762
+ if (normal_styles) {
2763
+ reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
2764
+ }
2765
+ if (important_styles) {
2766
+ reserved_names.push(...Object.keys(important_styles).map(to_css_name));
2767
+ }
2768
+ var start_index = 0;
2769
+ var name_index = -1;
2770
+ const len = value.length;
2771
+ for (var i = 0; i < len; i++) {
2772
+ var c = value[i];
2773
+ if (in_comment) {
2774
+ if (c === "/" && value[i - 1] === "*") {
2775
+ in_comment = false;
2776
+ }
2777
+ } else if (in_str) {
2778
+ if (in_str === c) {
2779
+ in_str = false;
2780
+ }
2781
+ } else if (c === "/" && value[i + 1] === "*") {
2782
+ in_comment = true;
2783
+ } else if (c === '"' || c === "'") {
2784
+ in_str = c;
2785
+ } else if (c === "(") {
2786
+ in_apo++;
2787
+ } else if (c === ")") {
2788
+ in_apo--;
2789
+ }
2790
+ if (!in_comment && in_str === false && in_apo === 0) {
2791
+ if (c === ":" && name_index === -1) {
2792
+ name_index = i;
2793
+ } else if (c === ";" || i === len - 1) {
2794
+ if (name_index !== -1) {
2795
+ var name = to_css_name(value.substring(start_index, name_index).trim());
2796
+ if (!reserved_names.includes(name)) {
2797
+ if (c !== ";") {
2798
+ i++;
2799
+ }
2800
+ var property = value.substring(start_index, i).trim();
2801
+ new_style += " " + property + ";";
2802
+ }
2803
+ }
2804
+ start_index = i + 1;
2805
+ name_index = -1;
2806
+ }
2807
+ }
2808
+ }
2809
+ }
2810
+ if (normal_styles) {
2811
+ new_style += append_styles(normal_styles);
2812
+ }
2813
+ if (important_styles) {
2814
+ new_style += append_styles(important_styles, true);
2815
+ }
2816
+ new_style = new_style.trim();
2817
+ return new_style === "" ? null : new_style;
2818
+ }
2819
+ return value == null ? null : String(value);
2820
+ }
2821
+ function asClassComponent$1(component) {
2822
+ return class extends Svelte4Component {
2823
+ /** @param {any} options */
2824
+ constructor(options) {
2825
+ super({
2826
+ component,
2827
+ ...options
2828
+ });
2829
+ }
2830
+ };
2831
+ }
2832
+ class Svelte4Component {
2833
+ /** @type {any} */
2834
+ #events;
2835
+ /** @type {Record<string, any>} */
2836
+ #instance;
2837
+ /**
2838
+ * @param {ComponentConstructorOptions & {
2839
+ * component: any;
2840
+ * }} options
2841
+ */
2842
+ constructor(options) {
2843
+ var sources = /* @__PURE__ */ new Map();
2844
+ var add_source = (key, value) => {
2845
+ var s = /* @__PURE__ */ mutable_source(value, false, false);
2846
+ sources.set(key, s);
2847
+ return s;
2848
+ };
2849
+ const props = new Proxy(
2850
+ { ...options.props || {}, $$events: {} },
2851
+ {
2852
+ get(target, prop) {
2853
+ return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2854
+ },
2855
+ has(target, prop) {
2856
+ if (prop === LEGACY_PROPS) return true;
2857
+ get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2858
+ return Reflect.has(target, prop);
2859
+ },
2860
+ set(target, prop, value) {
2861
+ set(sources.get(prop) ?? add_source(prop, value), value);
2862
+ return Reflect.set(target, prop, value);
2863
+ }
2864
+ }
2865
+ );
2866
+ this.#instance = (options.hydrate ? hydrate : mount)(options.component, {
2867
+ target: options.target,
2868
+ anchor: options.anchor,
2869
+ props,
2870
+ context: options.context,
2871
+ intro: options.intro ?? false,
2872
+ recover: options.recover,
2873
+ transformError: options.transformError
2874
+ });
2875
+ if (!options?.props?.$$host || options.sync === false) {
2876
+ flushSync();
2877
+ }
2878
+ this.#events = props.$$events;
2879
+ for (const key of Object.keys(this.#instance)) {
2880
+ if (key === "$set" || key === "$destroy" || key === "$on") continue;
2881
+ define_property(this, key, {
2882
+ get() {
2883
+ return this.#instance[key];
2884
+ },
2885
+ /** @param {any} value */
2886
+ set(value) {
2887
+ this.#instance[key] = value;
2888
+ },
2889
+ enumerable: true
2890
+ });
2891
+ }
2892
+ this.#instance.$set = /** @param {Record<string, any>} next */
2893
+ (next2) => {
2894
+ Object.assign(props, next2);
2895
+ };
2896
+ this.#instance.$destroy = () => {
2897
+ unmount(this.#instance);
2898
+ };
2899
+ }
2900
+ /** @param {Record<string, any>} props */
2901
+ $set(props) {
2902
+ this.#instance.$set(props);
2903
+ }
2904
+ /**
2905
+ * @param {string} event
2906
+ * @param {(...args: any[]) => any} callback
2907
+ * @returns {any}
2908
+ */
2909
+ $on(event, callback) {
2910
+ this.#events[event] = this.#events[event] || [];
2911
+ const cb = (...args) => callback.call(this, ...args);
2912
+ this.#events[event].push(cb);
2913
+ return () => {
2914
+ this.#events[event] = this.#events[event].filter(
2915
+ /** @param {any} fn */
2916
+ (fn) => fn !== cb
2917
+ );
2918
+ };
2919
+ }
2920
+ $destroy() {
2921
+ this.#instance.$destroy();
2922
+ }
2923
+ }
2924
+ const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
2925
+ const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
2926
+ const EMPTY_COMMENT = `<!---->`;
2927
+ let controller = null;
2928
+ function abort() {
2929
+ controller?.abort(STALE_REACTION);
2930
+ controller = null;
2931
+ }
2932
+ function await_invalid() {
2933
+ const error = new Error(`await_invalid
2934
+ Encountered asynchronous work while rendering synchronously.
2935
+ https://svelte.dev/e/await_invalid`);
2936
+ error.name = "Svelte error";
2937
+ throw error;
2938
+ }
2939
+ function dynamic_element_invalid_tag(tag) {
2940
+ const error = new Error(`dynamic_element_invalid_tag
2941
+ \`<svelte:element this="${tag}">\` is not a valid element name — the element will not be rendered
2942
+ https://svelte.dev/e/dynamic_element_invalid_tag`);
2943
+ error.name = "Svelte error";
2944
+ throw error;
2945
+ }
2946
+ function invalid_csp() {
2947
+ const error = new Error(`invalid_csp
2948
+ \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
2949
+ https://svelte.dev/e/invalid_csp`);
2950
+ error.name = "Svelte error";
2951
+ throw error;
2952
+ }
2953
+ function lifecycle_function_unavailable(name) {
2954
+ const error = new Error(`lifecycle_function_unavailable
2955
+ \`${name}(...)\` is not available on the server
2956
+ https://svelte.dev/e/lifecycle_function_unavailable`);
2957
+ error.name = "Svelte error";
2958
+ throw error;
2959
+ }
2960
+ function server_context_required() {
2961
+ const error = new Error(`server_context_required
2962
+ Could not resolve \`render\` context.
2963
+ https://svelte.dev/e/server_context_required`);
2964
+ error.name = "Svelte error";
2965
+ throw error;
2966
+ }
2967
+ var ssr_context = null;
2968
+ function set_ssr_context(v) {
2969
+ ssr_context = v;
2970
+ }
2971
+ function getContext(key) {
2972
+ const context_map = get_or_init_context_map();
2973
+ const result = (
2974
+ /** @type {T} */
2975
+ context_map.get(key)
2976
+ );
2977
+ return result;
2978
+ }
2979
+ function setContext(key, context) {
2980
+ get_or_init_context_map().set(key, context);
2981
+ return context;
2982
+ }
2983
+ function hasContext(key) {
2984
+ return get_or_init_context_map().has(key);
2985
+ }
2986
+ function getAllContexts() {
2987
+ return get_or_init_context_map();
2988
+ }
2989
+ function get_or_init_context_map(name) {
2990
+ if (ssr_context === null) {
2991
+ lifecycle_outside_component();
2992
+ }
2993
+ return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0);
2994
+ }
2995
+ function push(fn) {
2996
+ ssr_context = { p: ssr_context, c: null, r: null };
2997
+ }
2998
+ function pop() {
2999
+ ssr_context = /** @type {SSRContext} */
3000
+ ssr_context.p;
3001
+ }
3002
+ function get_parent_context(ssr_context2) {
3003
+ let parent = ssr_context2.p;
3004
+ while (parent !== null) {
3005
+ const context_map = parent.c;
3006
+ if (context_map !== null) {
3007
+ return context_map;
3008
+ }
3009
+ parent = parent.p;
3010
+ }
3011
+ return null;
3012
+ }
3013
+ function unresolved_hydratable(key, stack) {
3014
+ {
3015
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
3016
+ }
3017
+ }
3018
+ function get_render_context() {
3019
+ const store = als?.getStore();
3020
+ {
3021
+ server_context_required();
3022
+ }
3023
+ return store;
3024
+ }
3025
+ let als = null;
3026
+ let text_encoder;
3027
+ let crypto;
3028
+ const obfuscated_import = (module_name) => import(
3029
+ /* @vite-ignore */
3030
+ module_name
3031
+ );
3032
+ async function sha256(data) {
3033
+ text_encoder ??= new TextEncoder();
3034
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
3035
+ // @ts-ignore - we don't install node types in the prod build
3036
+ // don't use import('node:crypto') directly because static analysers will think we rely on node when we don't
3037
+ (await obfuscated_import("node:crypto")).webcrypto
3038
+ );
3039
+ const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
3040
+ return base64_encode(hash_buffer);
3041
+ }
3042
+ function base64_encode(bytes) {
3043
+ if (globalThis.Buffer) {
3044
+ return globalThis.Buffer.from(bytes).toString("base64");
3045
+ }
3046
+ let binary = "";
3047
+ for (let i = 0; i < bytes.length; i++) {
3048
+ binary += String.fromCharCode(bytes[i]);
3049
+ }
3050
+ return btoa(binary);
3051
+ }
3052
+ class Renderer {
3053
+ /**
3054
+ * The contents of the renderer.
3055
+ * @type {RendererItem[]}
3056
+ */
3057
+ #out = [];
3058
+ /**
3059
+ * Any `onDestroy` callbacks registered during execution of this renderer.
3060
+ * @type {(() => void)[] | undefined}
3061
+ */
3062
+ #on_destroy = void 0;
3063
+ /**
3064
+ * Whether this renderer is a component body.
3065
+ * @type {boolean}
3066
+ */
3067
+ #is_component_body = false;
3068
+ /**
3069
+ * If set, this renderer is an error boundary. When async collection
3070
+ * of the children fails, the failed snippet is rendered instead.
3071
+ * @type {{
3072
+ * failed: (renderer: Renderer, error: unknown, reset: () => void) => void;
3073
+ * transformError: (error: unknown) => unknown;
3074
+ * context: SSRContext | null;
3075
+ * } | null}
3076
+ */
3077
+ #boundary = null;
3078
+ /**
3079
+ * The type of string content that this renderer is accumulating.
3080
+ * @type {RendererType}
3081
+ */
3082
+ type;
3083
+ /** @type {Renderer | undefined} */
3084
+ #parent;
3085
+ /**
3086
+ * Asynchronous work associated with this renderer
3087
+ * @type {Promise<void> | undefined}
3088
+ */
3089
+ promise = void 0;
3090
+ /**
3091
+ * State which is associated with the content tree as a whole.
3092
+ * It will be re-exposed, uncopied, on all children.
3093
+ * @type {SSRState}
3094
+ * @readonly
3095
+ */
3096
+ global;
3097
+ /**
3098
+ * State that is local to the branch it is declared in.
3099
+ * It will be shallow-copied to all children.
3100
+ *
3101
+ * @type {{ select_value: string | undefined }}
3102
+ */
3103
+ local;
3104
+ /**
3105
+ * @param {SSRState} global
3106
+ * @param {Renderer | undefined} [parent]
3107
+ */
3108
+ constructor(global, parent) {
3109
+ this.#parent = parent;
3110
+ this.global = global;
3111
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
3112
+ this.type = parent ? parent.type : "body";
3113
+ }
3114
+ /**
3115
+ * @param {(renderer: Renderer) => void} fn
3116
+ */
3117
+ head(fn) {
3118
+ const head = new Renderer(this.global, this);
3119
+ head.type = "head";
3120
+ this.#out.push(head);
3121
+ head.child(fn);
3122
+ }
3123
+ /**
3124
+ * @param {Array<Promise<void>>} blockers
3125
+ * @param {(renderer: Renderer) => void} fn
3126
+ */
3127
+ async_block(blockers, fn) {
3128
+ this.#out.push(BLOCK_OPEN);
3129
+ this.async(blockers, fn);
3130
+ this.#out.push(BLOCK_CLOSE);
3131
+ }
3132
+ /**
3133
+ * @param {Array<Promise<void>>} blockers
3134
+ * @param {(renderer: Renderer) => void} fn
3135
+ */
3136
+ async(blockers, fn) {
3137
+ let callback = fn;
3138
+ if (blockers.length > 0) {
3139
+ const context = ssr_context;
3140
+ callback = (renderer) => {
3141
+ return Promise.all(blockers).then(() => {
3142
+ const previous_context = ssr_context;
3143
+ try {
3144
+ set_ssr_context(context);
3145
+ return fn(renderer);
3146
+ } finally {
3147
+ set_ssr_context(previous_context);
3148
+ }
3149
+ });
3150
+ };
3151
+ }
3152
+ this.child(callback);
3153
+ }
3154
+ /**
3155
+ * @param {Array<() => void>} thunks
3156
+ */
3157
+ run(thunks) {
3158
+ const context = ssr_context;
3159
+ let promise = Promise.resolve(thunks[0]());
3160
+ const promises = [promise];
3161
+ for (const fn of thunks.slice(1)) {
3162
+ promise = promise.then(() => {
3163
+ const previous_context = ssr_context;
3164
+ set_ssr_context(context);
3165
+ try {
3166
+ return fn();
3167
+ } finally {
3168
+ set_ssr_context(previous_context);
3169
+ }
3170
+ });
3171
+ promises.push(promise);
3172
+ }
3173
+ promise.catch(noop);
3174
+ this.promise = promise;
3175
+ return promises;
3176
+ }
3177
+ /**
3178
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
3179
+ */
3180
+ child_block(fn) {
3181
+ this.#out.push(BLOCK_OPEN);
3182
+ this.child(fn);
3183
+ this.#out.push(BLOCK_CLOSE);
3184
+ }
3185
+ /**
3186
+ * Create a child renderer. The child renderer inherits the state from the parent,
3187
+ * but has its own content.
3188
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
3189
+ */
3190
+ child(fn) {
3191
+ const child = new Renderer(this.global, this);
3192
+ this.#out.push(child);
3193
+ const parent = ssr_context;
3194
+ set_ssr_context({
3195
+ ...ssr_context,
3196
+ p: parent,
3197
+ c: null,
3198
+ r: child
3199
+ });
3200
+ const result = fn(child);
3201
+ set_ssr_context(parent);
3202
+ if (result instanceof Promise) {
3203
+ result.catch(noop);
3204
+ result.finally(() => set_ssr_context(null)).catch(noop);
3205
+ if (child.global.mode === "sync") {
3206
+ await_invalid();
3207
+ }
3208
+ child.promise = result;
3209
+ }
3210
+ return child;
3211
+ }
3212
+ /**
3213
+ * Render children inside an error boundary. If the children throw and the API-level
3214
+ * `transformError` transform handles the error (doesn't re-throw), the `failed` snippet is
3215
+ * rendered instead. Otherwise the error propagates.
3216
+ *
3217
+ * @param {{ failed?: (renderer: Renderer, error: unknown, reset: () => void) => void }} props
3218
+ * @param {(renderer: Renderer) => MaybePromise<void>} children_fn
3219
+ */
3220
+ boundary(props, children_fn) {
3221
+ const child = new Renderer(this.global, this);
3222
+ this.#out.push(child);
3223
+ const parent_context = ssr_context;
3224
+ if (props.failed) {
3225
+ child.#boundary = {
3226
+ failed: props.failed,
3227
+ transformError: this.global.transformError,
3228
+ context: parent_context
3229
+ };
3230
+ }
3231
+ set_ssr_context({
3232
+ ...ssr_context,
3233
+ p: parent_context,
3234
+ c: null,
3235
+ r: child
3236
+ });
3237
+ try {
3238
+ const result = children_fn(child);
3239
+ set_ssr_context(parent_context);
3240
+ if (result instanceof Promise) {
3241
+ if (child.global.mode === "sync") {
3242
+ await_invalid();
3243
+ }
3244
+ result.catch(noop);
3245
+ child.promise = result;
3246
+ }
3247
+ } catch (error) {
3248
+ set_ssr_context(parent_context);
3249
+ const failed_snippet = props.failed;
3250
+ if (!failed_snippet) throw error;
3251
+ const result = this.global.transformError(error);
3252
+ child.#out.length = 0;
3253
+ child.#boundary = null;
3254
+ if (result instanceof Promise) {
3255
+ if (this.global.mode === "sync") {
3256
+ await_invalid();
3257
+ }
3258
+ child.promise = /** @type {Promise<unknown>} */
3259
+ result.then((transformed) => {
3260
+ set_ssr_context(parent_context);
3261
+ child.#out.push(Renderer.#serialize_failed_boundary(transformed));
3262
+ failed_snippet(child, transformed, noop);
3263
+ child.#out.push(BLOCK_CLOSE);
3264
+ });
3265
+ child.promise.catch(noop);
3266
+ } else {
3267
+ child.#out.push(Renderer.#serialize_failed_boundary(result));
3268
+ failed_snippet(child, result, noop);
3269
+ child.#out.push(BLOCK_CLOSE);
3270
+ }
3271
+ }
3272
+ }
3273
+ /**
3274
+ * Create a component renderer. The component renderer inherits the state from the parent,
3275
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
3276
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
3277
+ * @param {Function} [component_fn]
3278
+ * @returns {void}
3279
+ */
3280
+ component(fn, component_fn) {
3281
+ push();
3282
+ const child = this.child(fn);
3283
+ child.#is_component_body = true;
3284
+ pop();
3285
+ }
3286
+ /**
3287
+ * @param {Record<string, any>} attrs
3288
+ * @param {(renderer: Renderer) => void} fn
3289
+ * @param {string | undefined} [css_hash]
3290
+ * @param {Record<string, boolean> | undefined} [classes]
3291
+ * @param {Record<string, string> | undefined} [styles]
3292
+ * @param {number | undefined} [flags]
3293
+ * @param {boolean | undefined} [is_rich]
3294
+ * @returns {void}
3295
+ */
3296
+ select(attrs, fn, css_hash, classes, styles, flags2, is_rich) {
3297
+ const { value, ...select_attrs } = attrs;
3298
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags2)}>`);
3299
+ this.child((renderer) => {
3300
+ renderer.local.select_value = value;
3301
+ fn(renderer);
3302
+ });
3303
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
3304
+ }
3305
+ /**
3306
+ * @param {Record<string, any>} attrs
3307
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
3308
+ * @param {string | undefined} [css_hash]
3309
+ * @param {Record<string, boolean> | undefined} [classes]
3310
+ * @param {Record<string, string> | undefined} [styles]
3311
+ * @param {number | undefined} [flags]
3312
+ * @param {boolean | undefined} [is_rich]
3313
+ */
3314
+ option(attrs, body, css_hash, classes, styles, flags2, is_rich) {
3315
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags2)}`);
3316
+ const close = (renderer, value, { head, body: body2 }) => {
3317
+ if (has_own_property.call(attrs, "value")) {
3318
+ value = attrs.value;
3319
+ }
3320
+ if (value === this.local.select_value) {
3321
+ renderer.#out.push(' selected=""');
3322
+ }
3323
+ renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
3324
+ if (head) {
3325
+ renderer.head((child) => child.push(head));
3326
+ }
3327
+ };
3328
+ if (typeof body === "function") {
3329
+ this.child((renderer) => {
3330
+ const r = new Renderer(this.global, this);
3331
+ body(r);
3332
+ if (this.global.mode === "async") {
3333
+ return r.#collect_content_async().then((content) => {
3334
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
3335
+ });
3336
+ } else {
3337
+ const content = r.#collect_content();
3338
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
3339
+ }
3340
+ });
3341
+ } else {
3342
+ close(this, body, { body: escape_html(body) });
3343
+ }
3344
+ }
3345
+ /**
3346
+ * @param {(renderer: Renderer) => void} fn
3347
+ */
3348
+ title(fn) {
3349
+ const path = this.get_path();
3350
+ const close = (head) => {
3351
+ this.global.set_title(head, path);
3352
+ };
3353
+ this.child((renderer) => {
3354
+ const r = new Renderer(renderer.global, renderer);
3355
+ fn(r);
3356
+ if (renderer.global.mode === "async") {
3357
+ return r.#collect_content_async().then((content) => {
3358
+ close(content.head);
3359
+ });
3360
+ } else {
3361
+ const content = r.#collect_content();
3362
+ close(content.head);
3363
+ }
3364
+ });
3365
+ }
3366
+ /**
3367
+ * @param {string | (() => Promise<string>)} content
3368
+ */
3369
+ push(content) {
3370
+ if (typeof content === "function") {
3371
+ this.child(async (renderer) => renderer.push(await content()));
3372
+ } else {
3373
+ this.#out.push(content);
3374
+ }
3375
+ }
3376
+ /**
3377
+ * @param {() => void} fn
3378
+ */
3379
+ on_destroy(fn) {
3380
+ (this.#on_destroy ??= []).push(fn);
3381
+ }
3382
+ /**
3383
+ * @returns {number[]}
3384
+ */
3385
+ get_path() {
3386
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
3387
+ }
3388
+ /**
3389
+ * @deprecated this is needed for legacy component bindings
3390
+ */
3391
+ copy() {
3392
+ const copy = new Renderer(this.global, this.#parent);
3393
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
3394
+ copy.promise = this.promise;
3395
+ return copy;
3396
+ }
3397
+ /**
3398
+ * @param {Renderer} other
3399
+ * @deprecated this is needed for legacy component bindings
3400
+ */
3401
+ subsume(other) {
3402
+ if (this.global.mode !== other.global.mode) {
3403
+ throw new Error(
3404
+ "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
3405
+ );
3406
+ }
3407
+ this.local = other.local;
3408
+ this.#out = other.#out.map((item) => {
3409
+ if (item instanceof Renderer) {
3410
+ item.subsume(item);
3411
+ }
3412
+ return item;
3413
+ });
3414
+ this.promise = other.promise;
3415
+ this.type = other.type;
3416
+ }
3417
+ get length() {
3418
+ return this.#out.length;
3419
+ }
3420
+ /**
3421
+ * Creates the hydration comment that marks the start of a failed boundary.
3422
+ * The error is JSON-serialized and embedded inside an HTML comment for the client
3423
+ * to parse during hydration. The JSON is escaped to prevent `-->` or `<!--` sequences
3424
+ * from breaking out of the comment (XSS). Uses unicode escapes which `JSON.parse()`
3425
+ * handles transparently.
3426
+ * @param {unknown} error
3427
+ * @returns {string}
3428
+ */
3429
+ static #serialize_failed_boundary(error) {
3430
+ var json = JSON.stringify(error);
3431
+ var escaped = json.replace(/>/g, "\\u003e").replace(/</g, "\\u003c");
3432
+ return `<!--${HYDRATION_START_FAILED}${escaped}-->`;
3433
+ }
3434
+ /**
3435
+ * Only available on the server and when compiling with the `server` option.
3436
+ * 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.
3437
+ * @template {Record<string, any>} Props
3438
+ * @param {Component<Props>} component
3439
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
3440
+ * @returns {RenderOutput}
3441
+ */
3442
+ static render(component, options = {}) {
3443
+ let sync;
3444
+ const result = (
3445
+ /** @type {RenderOutput} */
3446
+ {}
3447
+ );
3448
+ Object.defineProperties(result, {
3449
+ html: {
3450
+ get: () => {
3451
+ return (sync ??= Renderer.#render(component, options)).body;
3452
+ }
3453
+ },
3454
+ head: {
3455
+ get: () => {
3456
+ return (sync ??= Renderer.#render(component, options)).head;
3457
+ }
3458
+ },
3459
+ body: {
3460
+ get: () => {
3461
+ return (sync ??= Renderer.#render(component, options)).body;
3462
+ }
3463
+ },
3464
+ hashes: {
3465
+ value: {
3466
+ script: ""
3467
+ }
3468
+ },
3469
+ then: {
3470
+ value: (
3471
+ /**
3472
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
3473
+ *
3474
+ * @template TResult1
3475
+ * @template [TResult2=never]
3476
+ * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
3477
+ * @param { (reason: unknown) => TResult2 } onrejected
3478
+ */
3479
+ (onfulfilled, onrejected) => {
3480
+ {
3481
+ const result2 = sync ??= Renderer.#render(component, options);
3482
+ const user_result = onfulfilled({
3483
+ head: result2.head,
3484
+ body: result2.body,
3485
+ html: result2.body,
3486
+ hashes: { script: [] }
3487
+ });
3488
+ return Promise.resolve(user_result);
3489
+ }
3490
+ }
3491
+ )
3492
+ }
3493
+ });
3494
+ return result;
3495
+ }
3496
+ /**
3497
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
3498
+ * after awaiting `collect_async`.
3499
+ *
3500
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
3501
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
3502
+ * @returns {Iterable<() => void>}
3503
+ */
3504
+ *#collect_on_destroy() {
3505
+ for (const component of this.#traverse_components()) {
3506
+ yield* component.#collect_ondestroy();
3507
+ }
3508
+ }
3509
+ /**
3510
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
3511
+ * @returns {Iterable<Renderer>}
3512
+ */
3513
+ *#traverse_components() {
3514
+ for (const child of this.#out) {
3515
+ if (typeof child !== "string") {
3516
+ yield* child.#traverse_components();
3517
+ }
3518
+ }
3519
+ if (this.#is_component_body) {
3520
+ yield this;
3521
+ }
3522
+ }
3523
+ /**
3524
+ * @returns {Iterable<() => void>}
3525
+ */
3526
+ *#collect_ondestroy() {
3527
+ if (this.#on_destroy) {
3528
+ for (const fn of this.#on_destroy) {
3529
+ yield fn;
3530
+ }
3531
+ }
3532
+ for (const child of this.#out) {
3533
+ if (child instanceof Renderer && !child.#is_component_body) {
3534
+ yield* child.#collect_ondestroy();
3535
+ }
3536
+ }
3537
+ }
3538
+ /**
3539
+ * Render a component. Throws if any of the children are performing asynchronous work.
3540
+ *
3541
+ * @template {Record<string, any>} Props
3542
+ * @param {Component<Props>} component
3543
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
3544
+ * @returns {AccumulatedContent}
3545
+ */
3546
+ static #render(component, options) {
3547
+ var previous_context = ssr_context;
3548
+ try {
3549
+ const renderer = Renderer.#open_render("sync", component, options);
3550
+ const content = renderer.#collect_content();
3551
+ return Renderer.#close_render(content, renderer);
3552
+ } finally {
3553
+ abort();
3554
+ set_ssr_context(previous_context);
3555
+ }
3556
+ }
3557
+ /**
3558
+ * Render a component.
3559
+ *
3560
+ * @template {Record<string, any>} Props
3561
+ * @param {Component<Props>} component
3562
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
3563
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
3564
+ */
3565
+ static async #render_async(component, options) {
3566
+ const previous_context = ssr_context;
3567
+ try {
3568
+ const renderer = Renderer.#open_render("async", component, options);
3569
+ const content = await renderer.#collect_content_async();
3570
+ const hydratables = await renderer.#collect_hydratables();
3571
+ if (hydratables !== null) {
3572
+ content.head = hydratables + content.head;
3573
+ }
3574
+ return Renderer.#close_render(content, renderer);
3575
+ } finally {
3576
+ set_ssr_context(previous_context);
3577
+ abort();
3578
+ }
3579
+ }
3580
+ /**
3581
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
3582
+ * @param {AccumulatedContent} content
3583
+ * @returns {AccumulatedContent}
3584
+ */
3585
+ #collect_content(content = { head: "", body: "" }) {
3586
+ for (const item of this.#out) {
3587
+ if (typeof item === "string") {
3588
+ content[this.type] += item;
3589
+ } else if (item instanceof Renderer) {
3590
+ item.#collect_content(content);
3591
+ }
3592
+ }
3593
+ return content;
3594
+ }
3595
+ /**
3596
+ * Collect all of the code from the `out` array and return it as a string.
3597
+ * @param {AccumulatedContent} content
3598
+ * @returns {Promise<AccumulatedContent>}
3599
+ */
3600
+ async #collect_content_async(content = { head: "", body: "" }) {
3601
+ await this.promise;
3602
+ for (const item of this.#out) {
3603
+ if (typeof item === "string") {
3604
+ content[this.type] += item;
3605
+ } else if (item instanceof Renderer) {
3606
+ if (item.#boundary) {
3607
+ const boundary_content = { head: "", body: "" };
3608
+ try {
3609
+ await item.#collect_content_async(boundary_content);
3610
+ content.head += boundary_content.head;
3611
+ content.body += boundary_content.body;
3612
+ } catch (error) {
3613
+ const { context, failed, transformError } = item.#boundary;
3614
+ set_ssr_context(context);
3615
+ let transformed = await transformError(error);
3616
+ const failed_renderer = new Renderer(item.global, item);
3617
+ failed_renderer.type = item.type;
3618
+ failed_renderer.#out.push(Renderer.#serialize_failed_boundary(transformed));
3619
+ failed(failed_renderer, transformed, noop);
3620
+ failed_renderer.#out.push(BLOCK_CLOSE);
3621
+ await failed_renderer.#collect_content_async(content);
3622
+ }
3623
+ } else {
3624
+ await item.#collect_content_async(content);
3625
+ }
3626
+ }
3627
+ }
3628
+ return content;
3629
+ }
3630
+ async #collect_hydratables() {
3631
+ const ctx = get_render_context().hydratable;
3632
+ for (const [_, key] of ctx.unresolved_promises) {
3633
+ unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
3634
+ }
3635
+ for (const comparison of ctx.comparisons) {
3636
+ await comparison;
3637
+ }
3638
+ return await this.#hydratable_block(ctx);
3639
+ }
3640
+ /**
3641
+ * @template {Record<string, any>} Props
3642
+ * @param {'sync' | 'async'} mode
3643
+ * @param {import('svelte').Component<Props>} component
3644
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
3645
+ * @returns {Renderer}
3646
+ */
3647
+ static #open_render(mode, component, options) {
3648
+ var previous_context = ssr_context;
3649
+ try {
3650
+ const renderer = new Renderer(
3651
+ new SSRState(
3652
+ mode,
3653
+ options.idPrefix ? options.idPrefix + "-" : "",
3654
+ options.csp,
3655
+ options.transformError
3656
+ )
3657
+ );
3658
+ const context = { p: null, c: options.context ?? null, r: renderer };
3659
+ set_ssr_context(context);
3660
+ renderer.push(BLOCK_OPEN);
3661
+ component(renderer, options.props ?? {});
3662
+ renderer.push(BLOCK_CLOSE);
3663
+ return renderer;
3664
+ } finally {
3665
+ set_ssr_context(previous_context);
3666
+ }
3667
+ }
3668
+ /**
3669
+ * @param {AccumulatedContent} content
3670
+ * @param {Renderer} renderer
3671
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
3672
+ */
3673
+ static #close_render(content, renderer) {
3674
+ for (const cleanup of renderer.#collect_on_destroy()) {
3675
+ cleanup();
3676
+ }
3677
+ let head = content.head + renderer.global.get_title();
3678
+ let body = content.body;
3679
+ for (const { hash, code } of renderer.global.css) {
3680
+ head += `<style id="${hash}">${code}</style>`;
3681
+ }
3682
+ return {
3683
+ head,
3684
+ body,
3685
+ hashes: {
3686
+ script: renderer.global.csp.script_hashes
3687
+ }
3688
+ };
3689
+ }
3690
+ /**
3691
+ * @param {HydratableContext} ctx
3692
+ */
3693
+ async #hydratable_block(ctx) {
3694
+ if (ctx.lookup.size === 0) {
3695
+ return null;
3696
+ }
3697
+ let entries = [];
3698
+ let has_promises = false;
3699
+ for (const [k, v] of ctx.lookup) {
3700
+ if (v.promises) {
3701
+ has_promises = true;
3702
+ for (const p of v.promises) await p;
3703
+ }
3704
+ entries.push(`[${devalue.uneval(k)},${v.serialized}]`);
3705
+ }
3706
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
3707
+ if (has_promises) {
3708
+ prelude = `const r = (v) => Promise.resolve(v);
3709
+ ${prelude}`;
3710
+ }
3711
+ const body = `
3712
+ {
3713
+ ${prelude}
3714
+
3715
+ for (const [k, v] of [
3716
+ ${entries.join(",\n ")}
3717
+ ]) {
3718
+ h.set(k, v);
3719
+ }
3720
+ }
3721
+ `;
3722
+ let csp_attr = "";
3723
+ if (this.global.csp.nonce) {
3724
+ csp_attr = ` nonce="${this.global.csp.nonce}"`;
3725
+ } else if (this.global.csp.hash) {
3726
+ const hash = await sha256(body);
3727
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
3728
+ }
3729
+ return `
3730
+ <script${csp_attr}>${body}<\/script>`;
3731
+ }
3732
+ }
3733
+ class SSRState {
3734
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
3735
+ csp;
3736
+ /** @readonly @type {'sync' | 'async'} */
3737
+ mode;
3738
+ /** @readonly @type {() => string} */
3739
+ uid;
3740
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
3741
+ css = /* @__PURE__ */ new Set();
3742
+ /**
3743
+ * `transformError` passed to `render`. Called when an error boundary catches an error.
3744
+ * Throws by default if unset in `render`.
3745
+ * @type {(error: unknown) => unknown}
3746
+ */
3747
+ transformError;
3748
+ /** @type {{ path: number[], value: string }} */
3749
+ #title = { path: [], value: "" };
3750
+ /**
3751
+ * @param {'sync' | 'async'} mode
3752
+ * @param {string} id_prefix
3753
+ * @param {Csp} csp
3754
+ * @param {((error: unknown) => unknown) | undefined} [transformError]
3755
+ */
3756
+ constructor(mode, id_prefix = "", csp = { hash: false }, transformError) {
3757
+ this.mode = mode;
3758
+ this.csp = { ...csp, script_hashes: [] };
3759
+ this.transformError = transformError ?? ((error) => {
3760
+ throw error;
3761
+ });
3762
+ let uid2 = 1;
3763
+ this.uid = () => `${id_prefix}s${uid2++}`;
3764
+ }
3765
+ get_title() {
3766
+ return this.#title.value;
3767
+ }
3768
+ /**
3769
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
3770
+ * from earlier than or equal to the current value.
3771
+ * @param {string} value
3772
+ * @param {number[]} path
3773
+ */
3774
+ set_title(value, path) {
3775
+ const current = this.#title.path;
3776
+ let i = 0;
3777
+ let l = Math.min(path.length, current.length);
3778
+ while (i < l && path[i] === current[i]) i += 1;
3779
+ if (path[i] === void 0) return;
3780
+ if (current[i] === void 0 || path[i] > current[i]) {
3781
+ this.#title.path = path;
3782
+ this.#title.value = value;
3783
+ }
3784
+ }
3785
+ }
3786
+ 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;
3787
+ function element(renderer, tag, attributes_fn = noop, children_fn = noop) {
3788
+ renderer.push("<!---->");
3789
+ if (tag) {
3790
+ if (!REGEX_VALID_TAG_NAME.test(tag)) {
3791
+ dynamic_element_invalid_tag(tag);
3792
+ }
3793
+ renderer.push(`<${tag}`);
3794
+ attributes_fn();
3795
+ renderer.push(`>`);
3796
+ if (!is_void(tag)) {
3797
+ children_fn();
3798
+ if (!is_raw_text_element(tag)) {
3799
+ renderer.push(EMPTY_COMMENT);
3800
+ }
3801
+ renderer.push(`</${tag}>`);
3802
+ }
3803
+ }
3804
+ renderer.push("<!---->");
3805
+ }
3806
+ function render(component, options = {}) {
3807
+ if (options.csp?.hash && options.csp.nonce) {
3808
+ invalid_csp();
3809
+ }
3810
+ return Renderer.render(
3811
+ /** @type {Component<Props>} */
3812
+ component,
3813
+ options
3814
+ );
3815
+ }
3816
+ function attributes(attrs, css_hash, classes, styles, flags2 = 0) {
3817
+ if (styles) {
3818
+ attrs.style = to_style(attrs.style, styles);
3819
+ }
3820
+ if (attrs.class) {
3821
+ attrs.class = clsx(attrs.class);
3822
+ }
3823
+ if (css_hash || classes) {
3824
+ attrs.class = to_class(attrs.class, css_hash, classes);
3825
+ }
3826
+ let attr_str = "";
3827
+ let name;
3828
+ const is_html = (flags2 & ELEMENT_IS_NAMESPACED) === 0;
3829
+ const lowercase = (flags2 & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
3830
+ const is_input = (flags2 & ELEMENT_IS_INPUT) !== 0;
3831
+ for (name of Object.keys(attrs)) {
3832
+ if (typeof attrs[name] === "function") continue;
3833
+ if (name[0] === "$" && name[1] === "$") continue;
3834
+ if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
3835
+ var value = attrs[name];
3836
+ var lower = name.toLowerCase();
3837
+ if (lowercase) name = lower;
3838
+ if (lower.length > 2 && lower.startsWith("on")) continue;
3839
+ if (is_input) {
3840
+ if (name === "defaultvalue" || name === "defaultchecked") {
3841
+ name = name === "defaultvalue" ? "value" : "checked";
3842
+ if (attrs[name]) continue;
3843
+ }
3844
+ }
3845
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
3846
+ }
3847
+ return attr_str;
3848
+ }
3849
+ function spread_props(props) {
3850
+ const merged_props = {};
3851
+ let key;
3852
+ for (let i = 0; i < props.length; i++) {
3853
+ const obj = props[i];
3854
+ if (obj == null) continue;
3855
+ for (key of Object.keys(obj)) {
3856
+ const desc = Object.getOwnPropertyDescriptor(obj, key);
3857
+ if (desc) {
3858
+ Object.defineProperty(merged_props, key, desc);
3859
+ } else {
3860
+ merged_props[key] = obj[key];
3861
+ }
3862
+ }
3863
+ }
3864
+ return merged_props;
3865
+ }
3866
+ function stringify(value) {
3867
+ return typeof value === "string" ? value : value == null ? "" : value + "";
3868
+ }
3869
+ function attr_class(value, hash, directives) {
3870
+ var result = to_class(value, hash, directives);
3871
+ return result ? ` class="${escape_html(result, true)}"` : "";
3872
+ }
3873
+ function slot(renderer, $$props, name, slot_props, fallback_fn) {
3874
+ var slot_fn = $$props.$$slots?.[name];
3875
+ if (slot_fn === true) {
3876
+ slot_fn = $$props["children"];
3877
+ }
3878
+ if (slot_fn !== void 0) {
3879
+ slot_fn(renderer, slot_props);
3880
+ }
3881
+ }
3882
+ function rest_props(props, rest) {
3883
+ const rest_props2 = {};
3884
+ let key;
3885
+ for (key of Object.keys(props)) {
3886
+ if (!rest.includes(key)) {
3887
+ rest_props2[key] = props[key];
3888
+ }
3889
+ }
3890
+ return rest_props2;
3891
+ }
3892
+ function sanitize_props(props) {
3893
+ const { children, $$slots, ...sanitized } = props;
3894
+ return sanitized;
3895
+ }
3896
+ function bind_props(props_parent, props_now) {
3897
+ for (const key of Object.keys(props_now)) {
3898
+ const initial_value = props_parent[key];
3899
+ const value = props_now[key];
3900
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) {
3901
+ props_parent[key] = value;
3902
+ }
3903
+ }
3904
+ }
3905
+ function ensure_array_like(array_like_or_iterator) {
3906
+ if (array_like_or_iterator) {
3907
+ return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
3908
+ }
3909
+ return [];
3910
+ }
3911
+ function once(get_value) {
3912
+ let value = (
3913
+ /** @type {V} */
3914
+ UNINITIALIZED
3915
+ );
3916
+ return () => {
3917
+ if (value === UNINITIALIZED) {
3918
+ value = get_value();
3919
+ }
3920
+ return value;
3921
+ };
3922
+ }
3923
+ function props_id(renderer) {
3924
+ const uid2 = renderer.global.uid();
3925
+ renderer.push("<!--$" + uid2 + "-->");
3926
+ return uid2;
3927
+ }
3928
+ function derived(fn) {
3929
+ const get_value = ssr_context === null ? fn : once(fn);
3930
+ let updated_value;
3931
+ return function(new_value) {
3932
+ if (arguments.length === 0) {
3933
+ return updated_value ?? get_value();
3934
+ }
3935
+ updated_value = new_value;
3936
+ return updated_value;
3937
+ };
3938
+ }
3939
+ function asClassComponent(component) {
3940
+ const component_constructor = asClassComponent$1(component);
3941
+ const _render = (props, { context, csp, transformError } = {}) => {
3942
+ const result = render(component, { props, context, csp, transformError });
3943
+ const munged = Object.defineProperties(
3944
+ /** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
3945
+ {},
3946
+ {
3947
+ css: {
3948
+ value: { code: "", map: null }
3949
+ },
3950
+ head: {
3951
+ get: () => result.head
3952
+ },
3953
+ html: {
3954
+ get: () => result.body
3955
+ },
3956
+ then: {
3957
+ /**
3958
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
3959
+ *
3960
+ * @template TResult1
3961
+ * @template [TResult2=never]
3962
+ * @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
3963
+ * @param { (reason: unknown) => TResult2 } onrejected
3964
+ */
3965
+ value: (onfulfilled, onrejected) => {
3966
+ {
3967
+ const user_result = onfulfilled({
3968
+ css: munged.css,
3969
+ head: munged.head,
3970
+ html: munged.html
3971
+ });
3972
+ return Promise.resolve(user_result);
3973
+ }
3974
+ }
3975
+ }
3976
+ }
3977
+ );
3978
+ return munged;
3979
+ };
3980
+ component_constructor.render = _render;
3981
+ return component_constructor;
3982
+ }
3983
+ function Root($$renderer, $$props) {
3984
+ $$renderer.component(($$renderer2) => {
3985
+ let {
3986
+ stores,
3987
+ page,
3988
+ constructors,
3989
+ components = [],
3990
+ form,
3991
+ data_0 = null,
3992
+ data_1 = null
3993
+ } = $$props;
3994
+ {
3995
+ setContext("__svelte__", stores);
3996
+ }
3997
+ {
3998
+ stores.page.set(page);
3999
+ }
4000
+ const Pyramid_1 = derived(() => constructors[1]);
4001
+ if (constructors[1]) {
4002
+ $$renderer2.push("<!--[0-->");
4003
+ const Pyramid_0 = constructors[0];
4004
+ if (Pyramid_0) {
4005
+ $$renderer2.push("<!--[-->");
4006
+ Pyramid_0($$renderer2, {
4007
+ data: data_0,
4008
+ form,
4009
+ params: page.params,
4010
+ children: ($$renderer3) => {
4011
+ if (Pyramid_1()) {
4012
+ $$renderer3.push("<!--[-->");
4013
+ Pyramid_1()($$renderer3, { data: data_1, form, params: page.params });
4014
+ $$renderer3.push("<!--]-->");
4015
+ } else {
4016
+ $$renderer3.push("<!--[!-->");
4017
+ $$renderer3.push("<!--]-->");
4018
+ }
4019
+ },
4020
+ $$slots: { default: true }
4021
+ });
4022
+ $$renderer2.push("<!--]-->");
4023
+ } else {
4024
+ $$renderer2.push("<!--[!-->");
4025
+ $$renderer2.push("<!--]-->");
4026
+ }
4027
+ } else {
4028
+ $$renderer2.push("<!--[-1-->");
4029
+ const Pyramid_0 = constructors[0];
4030
+ if (Pyramid_0) {
4031
+ $$renderer2.push("<!--[-->");
4032
+ Pyramid_0($$renderer2, { data: data_0, form, params: page.params });
4033
+ $$renderer2.push("<!--]-->");
4034
+ } else {
4035
+ $$renderer2.push("<!--[!-->");
4036
+ $$renderer2.push("<!--]-->");
4037
+ }
4038
+ }
4039
+ $$renderer2.push(`<!--]--> `);
4040
+ {
4041
+ $$renderer2.push("<!--[-1-->");
4042
+ }
4043
+ $$renderer2.push(`<!--]-->`);
4044
+ });
4045
+ }
4046
+ const root = asClassComponent(Root);
4047
+ export {
4048
+ ATTACHMENT_KEY as A,
4049
+ safe_not_equal as B,
4050
+ attributes as a,
4051
+ bind_props as b,
4052
+ clsx as c,
4053
+ derived as d,
4054
+ attr as e,
4055
+ spread_props as f,
4056
+ getContext as g,
4057
+ escape_html as h,
4058
+ stringify as i,
4059
+ attr_class as j,
4060
+ sanitize_props as k,
4061
+ slot as l,
4062
+ ensure_array_like as m,
4063
+ hasContext as n,
4064
+ on as o,
4065
+ props_id as p,
4066
+ run as q,
4067
+ root as r,
4068
+ setContext as s,
4069
+ getAllContexts as t,
4070
+ element as u,
4071
+ ssr_context as v,
4072
+ lifecycle_function_unavailable as w,
4073
+ rest_props as x,
4074
+ fallback as y,
4075
+ noop as z
4076
+ };