@withbuddi/buddi 0.1.0-pre.16 → 0.1.0-pre.18

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 (816) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +27 -26
  3. package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
  4. package/node_modules/@buddi/cli/dist/args.d.ts +9 -3
  5. package/node_modules/@buddi/cli/dist/args.d.ts.map +1 -1
  6. package/node_modules/@buddi/cli/dist/args.js +25 -89
  7. package/node_modules/@buddi/cli/dist/args.js.map +1 -1
  8. package/node_modules/@buddi/cli/dist/backup/index.d.ts +2 -0
  9. package/node_modules/@buddi/cli/dist/backup/index.d.ts.map +1 -1
  10. package/node_modules/@buddi/cli/dist/backup/index.js +13 -4
  11. package/node_modules/@buddi/cli/dist/backup/index.js.map +1 -1
  12. package/node_modules/@buddi/cli/dist/commands.d.ts +94 -0
  13. package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -0
  14. package/node_modules/@buddi/cli/dist/commands.js +993 -0
  15. package/node_modules/@buddi/cli/dist/commands.js.map +1 -0
  16. package/node_modules/@buddi/cli/dist/index.d.ts +3 -1
  17. package/node_modules/@buddi/cli/dist/index.d.ts.map +1 -1
  18. package/node_modules/@buddi/cli/dist/index.js +3 -1
  19. package/node_modules/@buddi/cli/dist/index.js.map +1 -1
  20. package/node_modules/@buddi/cli/dist/jobs-cmd.d.ts +4 -0
  21. package/node_modules/@buddi/cli/dist/jobs-cmd.d.ts.map +1 -1
  22. package/node_modules/@buddi/cli/dist/jobs-cmd.js +26 -7
  23. package/node_modules/@buddi/cli/dist/jobs-cmd.js.map +1 -1
  24. package/node_modules/@buddi/cli/dist/main.d.ts +9 -2
  25. package/node_modules/@buddi/cli/dist/main.d.ts.map +1 -1
  26. package/node_modules/@buddi/cli/dist/main.js +246 -30
  27. package/node_modules/@buddi/cli/dist/main.js.map +1 -1
  28. package/node_modules/@buddi/cli/dist/mcp/gateway-client.d.ts +1 -1
  29. package/node_modules/@buddi/cli/dist/mcp/gateway-client.js +1 -1
  30. package/node_modules/@buddi/cli/dist/mcp/secrets.d.ts +1 -1
  31. package/node_modules/@buddi/cli/dist/mcp/secrets.js +1 -1
  32. package/node_modules/@buddi/cli/dist/mcp/server.d.ts +1 -1
  33. package/node_modules/@buddi/cli/dist/mcp/server.js +1 -1
  34. package/node_modules/@buddi/cli/dist/mcp/tools.d.ts +1 -1
  35. package/node_modules/@buddi/cli/dist/mcp/tools.js +1 -1
  36. package/node_modules/@buddi/cli/dist/paths.d.ts +8 -5
  37. package/node_modules/@buddi/cli/dist/paths.d.ts.map +1 -1
  38. package/node_modules/@buddi/cli/dist/paths.js +36 -10
  39. package/node_modules/@buddi/cli/dist/paths.js.map +1 -1
  40. package/node_modules/@buddi/cli/dist/status.d.ts +70 -0
  41. package/node_modules/@buddi/cli/dist/status.d.ts.map +1 -0
  42. package/node_modules/@buddi/cli/dist/status.js +122 -0
  43. package/node_modules/@buddi/cli/dist/status.js.map +1 -0
  44. package/node_modules/@buddi/cli/dist/style.d.ts +13 -0
  45. package/node_modules/@buddi/cli/dist/style.d.ts.map +1 -0
  46. package/node_modules/@buddi/cli/dist/style.js +10 -0
  47. package/node_modules/@buddi/cli/dist/style.js.map +1 -0
  48. package/node_modules/@buddi/cli/dist/telegram-cmd.d.ts +1 -1
  49. package/node_modules/@buddi/cli/dist/telegram-cmd.d.ts.map +1 -1
  50. package/node_modules/@buddi/cli/dist/telegram-cmd.js +23 -6
  51. package/node_modules/@buddi/cli/dist/telegram-cmd.js.map +1 -1
  52. package/node_modules/@buddi/cli/dist/vault-cmd.js +3 -3
  53. package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
  54. package/node_modules/@buddi/core/dist/actions/approvals.d.ts +0 -17
  55. package/node_modules/@buddi/core/dist/actions/approvals.d.ts.map +1 -1
  56. package/node_modules/@buddi/core/dist/actions/approvals.js +21 -0
  57. package/node_modules/@buddi/core/dist/actions/approvals.js.map +1 -1
  58. package/node_modules/@buddi/core/dist/actions/execute.d.ts +1 -1
  59. package/node_modules/@buddi/core/dist/actions/jobs.d.ts +1 -1
  60. package/node_modules/@buddi/core/dist/actions/types.js +1 -1
  61. package/node_modules/@buddi/core/dist/agents/provider-from-env.d.ts +1 -1
  62. package/node_modules/@buddi/core/dist/agents/provider-from-env.js +1 -1
  63. package/node_modules/@buddi/core/dist/agents/skills.js +1 -1
  64. package/node_modules/@buddi/core/dist/goals/types.d.ts +1 -1
  65. package/node_modules/@buddi/core/dist/goals/types.js +1 -1
  66. package/node_modules/@buddi/core/dist/host/build.d.ts +15 -1
  67. package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
  68. package/node_modules/@buddi/core/dist/host/build.js +101 -3
  69. package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
  70. package/node_modules/@buddi/core/dist/host/http.d.ts +1 -1
  71. package/node_modules/@buddi/core/dist/host/http.d.ts.map +1 -1
  72. package/node_modules/@buddi/core/dist/host/http.js +1 -1
  73. package/node_modules/@buddi/core/dist/host/http.js.map +1 -1
  74. package/node_modules/@buddi/core/dist/host/types.d.ts +92 -5
  75. package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
  76. package/node_modules/@buddi/core/dist/index.d.ts +1 -0
  77. package/node_modules/@buddi/core/dist/index.d.ts.map +1 -1
  78. package/node_modules/@buddi/core/dist/index.js +1 -0
  79. package/node_modules/@buddi/core/dist/index.js.map +1 -1
  80. package/node_modules/@buddi/core/dist/learning/echoes.d.ts +1 -1
  81. package/node_modules/@buddi/core/dist/learning/echoes.js +1 -1
  82. package/node_modules/@buddi/core/dist/learning/policies.d.ts +1 -1
  83. package/node_modules/@buddi/core/dist/learning/skill-files.js +1 -1
  84. package/node_modules/@buddi/core/dist/learning/types.d.ts +2 -2
  85. package/node_modules/@buddi/core/dist/notifications/channels.d.ts +37 -0
  86. package/node_modules/@buddi/core/dist/notifications/channels.d.ts.map +1 -0
  87. package/node_modules/@buddi/core/dist/notifications/channels.js +87 -0
  88. package/node_modules/@buddi/core/dist/notifications/channels.js.map +1 -0
  89. package/node_modules/@buddi/core/dist/notifications/index.d.ts +5 -0
  90. package/node_modules/@buddi/core/dist/notifications/index.d.ts.map +1 -0
  91. package/node_modules/@buddi/core/dist/notifications/index.js +5 -0
  92. package/node_modules/@buddi/core/dist/notifications/index.js.map +1 -0
  93. package/node_modules/@buddi/core/dist/notifications/notify.d.ts +35 -0
  94. package/node_modules/@buddi/core/dist/notifications/notify.d.ts.map +1 -0
  95. package/node_modules/@buddi/core/dist/notifications/notify.js +262 -0
  96. package/node_modules/@buddi/core/dist/notifications/notify.js.map +1 -0
  97. package/node_modules/@buddi/core/dist/notifications/store.d.ts +48 -0
  98. package/node_modules/@buddi/core/dist/notifications/store.d.ts.map +1 -0
  99. package/node_modules/@buddi/core/dist/notifications/store.js +207 -0
  100. package/node_modules/@buddi/core/dist/notifications/store.js.map +1 -0
  101. package/node_modules/@buddi/core/dist/notifications/types.d.ts +136 -0
  102. package/node_modules/@buddi/core/dist/notifications/types.d.ts.map +1 -0
  103. package/node_modules/@buddi/core/dist/notifications/types.js +5 -0
  104. package/node_modules/@buddi/core/dist/notifications/types.js.map +1 -0
  105. package/node_modules/@buddi/core/dist/owner.js +1 -1
  106. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js +1 -1
  107. package/node_modules/@buddi/core/dist/pages.d.ts +4 -4
  108. package/node_modules/@buddi/core/dist/pages.js +1 -1
  109. package/node_modules/@buddi/core/dist/plugin/index.d.ts +2 -2
  110. package/node_modules/@buddi/core/dist/plugin/index.d.ts.map +1 -1
  111. package/node_modules/@buddi/core/dist/plugin/index.js +1 -1
  112. package/node_modules/@buddi/core/dist/plugin/search.d.ts +1 -1
  113. package/node_modules/@buddi/core/dist/plugin/search.js +1 -1
  114. package/node_modules/@buddi/core/dist/plugin/url.js +1 -1
  115. package/node_modules/@buddi/core/dist/plugin/uses.d.ts +2 -2
  116. package/node_modules/@buddi/core/dist/plugin/uses.d.ts.map +1 -1
  117. package/node_modules/@buddi/core/dist/plugin/uses.js +5 -1
  118. package/node_modules/@buddi/core/dist/plugin/uses.js.map +1 -1
  119. package/node_modules/@buddi/core/dist/plugin/version.d.ts +2 -2
  120. package/node_modules/@buddi/core/dist/plugin/version.js +2 -2
  121. package/node_modules/@buddi/core/dist/provider.d.ts +1 -1
  122. package/node_modules/@buddi/core/dist/provider.js +1 -1
  123. package/node_modules/@buddi/core/dist/queue/retry-policy.d.ts +1 -1
  124. package/node_modules/@buddi/core/dist/queue/retry-policy.js +1 -1
  125. package/node_modules/@buddi/core/dist/registry.d.ts.map +1 -1
  126. package/node_modules/@buddi/core/dist/registry.js +4 -5
  127. package/node_modules/@buddi/core/dist/registry.js.map +1 -1
  128. package/node_modules/@buddi/core/dist/reminders/store.d.ts +1 -1
  129. package/node_modules/@buddi/core/dist/reminders/store.js +1 -1
  130. package/node_modules/@buddi/core/dist/reminders/types.d.ts +1 -1
  131. package/node_modules/@buddi/core/dist/reminders/types.js +1 -1
  132. package/node_modules/@buddi/core/dist/secrets/approval.d.ts +1 -1
  133. package/node_modules/@buddi/core/dist/secrets/approval.js +1 -1
  134. package/node_modules/@buddi/core/dist/secrets/destinations.d.ts +1 -1
  135. package/node_modules/@buddi/core/dist/secrets/scrub.js +1 -1
  136. package/node_modules/@buddi/core/dist/secrets/settings.js +1 -1
  137. package/node_modules/@buddi/core/dist/secrets/store.d.ts +1 -1
  138. package/node_modules/@buddi/core/dist/secrets/totp.js +1 -1
  139. package/node_modules/@buddi/core/dist/secrets/use.d.ts +1 -1
  140. package/node_modules/@buddi/core/dist/sentinels/types.d.ts +1 -1
  141. package/node_modules/@buddi/core/dist/testing/index.d.ts +1 -1
  142. package/node_modules/@buddi/core/dist/testing/index.js +1 -1
  143. package/node_modules/@buddi/core/dist/time.d.ts +12 -0
  144. package/node_modules/@buddi/core/dist/time.d.ts.map +1 -1
  145. package/node_modules/@buddi/core/dist/time.js +46 -0
  146. package/node_modules/@buddi/core/dist/time.js.map +1 -1
  147. package/node_modules/@buddi/core/dist/tools.d.ts +10 -10
  148. package/node_modules/@buddi/core/dist/vault/file.js +2 -2
  149. package/node_modules/@buddi/core/dist/vault/keychain.js +1 -1
  150. package/node_modules/@buddi/core/dist/vault/keychain.js.map +1 -1
  151. package/node_modules/@buddi/core/dist/vault/resolve.d.ts +3 -3
  152. package/node_modules/@buddi/core/dist/vault/resolve.js +3 -3
  153. package/node_modules/@buddi/core/dist/vault/types.d.ts +1 -1
  154. package/node_modules/@buddi/core/dist/vault/types.js +2 -2
  155. package/node_modules/@buddi/core/migrations/003_owner_surfaces.sql +1 -1
  156. package/node_modules/@buddi/core/migrations/005_artifacts.sql +1 -1
  157. package/node_modules/@buddi/core/migrations/009_queue.sql +1 -2
  158. package/node_modules/@buddi/core/migrations/010_actions.sql +1 -1
  159. package/node_modules/@buddi/core/migrations/043_owner_notifications.sql +77 -0
  160. package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
  161. package/node_modules/@buddi/gateway/dist/agents/catalog.d.ts.map +1 -1
  162. package/node_modules/@buddi/gateway/dist/agents/catalog.js +5 -6
  163. package/node_modules/@buddi/gateway/dist/agents/catalog.js.map +1 -1
  164. package/node_modules/@buddi/gateway/dist/agents/learned-skills.js +1 -1
  165. package/node_modules/@buddi/gateway/dist/agents/learning-digest.d.ts +1 -1
  166. package/node_modules/@buddi/gateway/dist/agents/learning-digest.js +1 -1
  167. package/node_modules/@buddi/gateway/dist/agents/learning.d.ts +1 -1
  168. package/node_modules/@buddi/gateway/dist/agents/learning.js +1 -1
  169. package/node_modules/@buddi/gateway/dist/agents-cli.d.ts +25 -1
  170. package/node_modules/@buddi/gateway/dist/agents-cli.d.ts.map +1 -1
  171. package/node_modules/@buddi/gateway/dist/agents-cli.js +91 -27
  172. package/node_modules/@buddi/gateway/dist/agents-cli.js.map +1 -1
  173. package/node_modules/@buddi/gateway/dist/bootstrap.d.ts.map +1 -1
  174. package/node_modules/@buddi/gateway/dist/bootstrap.js +10 -2
  175. package/node_modules/@buddi/gateway/dist/bootstrap.js.map +1 -1
  176. package/node_modules/@buddi/gateway/dist/channels/local-notification.d.ts +39 -0
  177. package/node_modules/@buddi/gateway/dist/channels/local-notification.d.ts.map +1 -0
  178. package/node_modules/@buddi/gateway/dist/channels/local-notification.js +154 -0
  179. package/node_modules/@buddi/gateway/dist/channels/local-notification.js.map +1 -0
  180. package/node_modules/@buddi/gateway/dist/chat/approvals.d.ts +3 -3
  181. package/node_modules/@buddi/gateway/dist/chat/approvals.js +3 -3
  182. package/node_modules/@buddi/gateway/dist/cli.d.ts +14 -0
  183. package/node_modules/@buddi/gateway/dist/cli.d.ts.map +1 -1
  184. package/node_modules/@buddi/gateway/dist/cli.js +208 -37
  185. package/node_modules/@buddi/gateway/dist/cli.js.map +1 -1
  186. package/node_modules/@buddi/gateway/dist/db-ready.d.ts +2 -1
  187. package/node_modules/@buddi/gateway/dist/db-ready.d.ts.map +1 -1
  188. package/node_modules/@buddi/gateway/dist/db-ready.js +3 -2
  189. package/node_modules/@buddi/gateway/dist/db-ready.js.map +1 -1
  190. package/node_modules/@buddi/gateway/dist/index.d.ts +4 -1
  191. package/node_modules/@buddi/gateway/dist/index.d.ts.map +1 -1
  192. package/node_modules/@buddi/gateway/dist/index.js +5 -1
  193. package/node_modules/@buddi/gateway/dist/index.js.map +1 -1
  194. package/node_modules/@buddi/gateway/dist/mcp/requests.d.ts +1 -1
  195. package/node_modules/@buddi/gateway/dist/mcp/requests.js +1 -1
  196. package/node_modules/@buddi/gateway/dist/missions/agent-run.d.ts.map +1 -1
  197. package/node_modules/@buddi/gateway/dist/missions/agent-run.js +10 -1
  198. package/node_modules/@buddi/gateway/dist/missions/agent-run.js.map +1 -1
  199. package/node_modules/@buddi/gateway/dist/missions/execute.d.ts +16 -2
  200. package/node_modules/@buddi/gateway/dist/missions/execute.d.ts.map +1 -1
  201. package/node_modules/@buddi/gateway/dist/missions/execute.js +6 -1
  202. package/node_modules/@buddi/gateway/dist/missions/execute.js.map +1 -1
  203. package/node_modules/@buddi/gateway/dist/missions/goals-page.d.ts +1 -1
  204. package/node_modules/@buddi/gateway/dist/missions/goals-page.js +1 -1
  205. package/node_modules/@buddi/gateway/dist/missions/goals.d.ts +1 -1
  206. package/node_modules/@buddi/gateway/dist/missions/goals.js +1 -1
  207. package/node_modules/@buddi/gateway/dist/missions/watcher-mail.d.ts +1 -1
  208. package/node_modules/@buddi/gateway/dist/missions/watcher-mail.js +1 -1
  209. package/node_modules/@buddi/gateway/dist/missions-cli.d.ts +2 -0
  210. package/node_modules/@buddi/gateway/dist/missions-cli.d.ts.map +1 -1
  211. package/node_modules/@buddi/gateway/dist/missions-cli.js +53 -8
  212. package/node_modules/@buddi/gateway/dist/missions-cli.js.map +1 -1
  213. package/node_modules/@buddi/gateway/dist/owner-notify.d.ts +43 -0
  214. package/node_modules/@buddi/gateway/dist/owner-notify.d.ts.map +1 -0
  215. package/node_modules/@buddi/gateway/dist/owner-notify.js +87 -0
  216. package/node_modules/@buddi/gateway/dist/owner-notify.js.map +1 -0
  217. package/node_modules/@buddi/gateway/dist/owner-secrets.d.ts +3 -3
  218. package/node_modules/@buddi/gateway/dist/owner-secrets.js +3 -3
  219. package/node_modules/@buddi/gateway/dist/plugins/load.d.ts +1 -1
  220. package/node_modules/@buddi/gateway/dist/plugins/load.js +1 -1
  221. package/node_modules/@buddi/gateway/dist/plugins/scaffold.js +1 -1
  222. package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts +2 -2
  223. package/node_modules/@buddi/gateway/dist/plugins/stage.js +1 -1
  224. package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts +3 -1
  225. package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts.map +1 -1
  226. package/node_modules/@buddi/gateway/dist/plugins-cli.js +11 -4
  227. package/node_modules/@buddi/gateway/dist/plugins-cli.js.map +1 -1
  228. package/node_modules/@buddi/gateway/dist/provider-accounts.js +1 -1
  229. package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
  230. package/node_modules/@buddi/gateway/dist/reminders-cli.d.ts +3 -1
  231. package/node_modules/@buddi/gateway/dist/reminders-cli.d.ts.map +1 -1
  232. package/node_modules/@buddi/gateway/dist/reminders-cli.js +21 -2
  233. package/node_modules/@buddi/gateway/dist/reminders-cli.js.map +1 -1
  234. package/node_modules/@buddi/gateway/dist/serve.d.ts +2 -0
  235. package/node_modules/@buddi/gateway/dist/serve.d.ts.map +1 -1
  236. package/node_modules/@buddi/gateway/dist/serve.js +62 -15
  237. package/node_modules/@buddi/gateway/dist/serve.js.map +1 -1
  238. package/node_modules/@buddi/gateway/dist/telegram/approvals.d.ts +3 -3
  239. package/node_modules/@buddi/gateway/dist/telegram/approvals.js +3 -3
  240. package/node_modules/@buddi/gateway/dist/telegram/channel.d.ts +30 -0
  241. package/node_modules/@buddi/gateway/dist/telegram/channel.d.ts.map +1 -0
  242. package/node_modules/@buddi/gateway/dist/telegram/channel.js +49 -0
  243. package/node_modules/@buddi/gateway/dist/telegram/channel.js.map +1 -0
  244. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
  245. package/node_modules/@buddi/gateway/dist/telegram/surface.js +4 -1
  246. package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
  247. package/node_modules/@buddi/gateway/dist/web/config.js +3 -3
  248. package/node_modules/@buddi/gateway/dist/web/http.d.ts +16 -3
  249. package/node_modules/@buddi/gateway/dist/web/http.d.ts.map +1 -1
  250. package/node_modules/@buddi/gateway/dist/web/http.js +39 -3
  251. package/node_modules/@buddi/gateway/dist/web/http.js.map +1 -1
  252. package/node_modules/@buddi/gateway/dist/web/notifications.d.ts +36 -0
  253. package/node_modules/@buddi/gateway/dist/web/notifications.d.ts.map +1 -0
  254. package/node_modules/@buddi/gateway/dist/web/notifications.js +63 -0
  255. package/node_modules/@buddi/gateway/dist/web/notifications.js.map +1 -0
  256. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +1 -1
  257. package/node_modules/@buddi/gateway/dist/web/onboarding.js +1 -1
  258. package/node_modules/@buddi/gateway/dist/web/pages.js +1 -1
  259. package/node_modules/@buddi/gateway/dist/web/read.js +3 -3
  260. package/node_modules/@buddi/gateway/dist/web/secrets.d.ts +1 -1
  261. package/node_modules/@buddi/gateway/dist/web/server.d.ts +1 -1
  262. package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
  263. package/node_modules/@buddi/gateway/dist/web/server.js +37 -25
  264. package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
  265. package/node_modules/@buddi/gateway/dist/web/version.d.ts +1 -0
  266. package/node_modules/@buddi/gateway/dist/web/version.d.ts.map +1 -1
  267. package/node_modules/@buddi/gateway/dist/web/version.js +2 -1
  268. package/node_modules/@buddi/gateway/dist/web/version.js.map +1 -1
  269. package/node_modules/@buddi/gateway/dist/web/write.js +1 -1
  270. package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
  271. package/node_modules/@buddi/install/dist/environment.d.ts +29 -0
  272. package/node_modules/@buddi/install/dist/environment.d.ts.map +1 -1
  273. package/node_modules/@buddi/install/dist/environment.js +50 -1
  274. package/node_modules/@buddi/install/dist/environment.js.map +1 -1
  275. package/node_modules/@buddi/install/dist/launcher.d.ts +3 -1
  276. package/node_modules/@buddi/install/dist/launcher.d.ts.map +1 -1
  277. package/node_modules/@buddi/install/dist/launcher.js +93 -12
  278. package/node_modules/@buddi/install/dist/launcher.js.map +1 -1
  279. package/node_modules/@buddi/install/dist/upgrade.d.ts +16 -3
  280. package/node_modules/@buddi/install/dist/upgrade.d.ts.map +1 -1
  281. package/node_modules/@buddi/install/dist/upgrade.js +21 -7
  282. package/node_modules/@buddi/install/dist/upgrade.js.map +1 -1
  283. package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
  284. package/node_modules/@buddi/runtime/dist/anthropic.d.ts +35 -2
  285. package/node_modules/@buddi/runtime/dist/anthropic.d.ts.map +1 -1
  286. package/node_modules/@buddi/runtime/dist/anthropic.js +36 -12
  287. package/node_modules/@buddi/runtime/dist/anthropic.js.map +1 -1
  288. package/node_modules/@buddi/runtime/dist/delegate.js +1 -1
  289. package/node_modules/@buddi/runtime/dist/loop.d.ts +13 -1
  290. package/node_modules/@buddi/runtime/dist/loop.d.ts.map +1 -1
  291. package/node_modules/@buddi/runtime/dist/loop.js +70 -3
  292. package/node_modules/@buddi/runtime/dist/loop.js.map +1 -1
  293. package/node_modules/@buddi/runtime/dist/openai.d.ts.map +1 -1
  294. package/node_modules/@buddi/runtime/dist/openai.js +9 -6
  295. package/node_modules/@buddi/runtime/dist/openai.js.map +1 -1
  296. package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
  297. package/node_modules/@buddi/tool-artifacts/dist/index.d.ts +1 -1
  298. package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
  299. package/node_modules/@buddi/tool-browser/dist/availability.d.ts +34 -8
  300. package/node_modules/@buddi/tool-browser/dist/availability.d.ts.map +1 -1
  301. package/node_modules/@buddi/tool-browser/dist/availability.js +44 -5
  302. package/node_modules/@buddi/tool-browser/dist/availability.js.map +1 -1
  303. package/node_modules/@buddi/tool-browser/dist/controller.d.ts +2 -2
  304. package/node_modules/@buddi/tool-browser/dist/controller.d.ts.map +1 -1
  305. package/node_modules/@buddi/tool-browser/dist/controller.js +7 -6
  306. package/node_modules/@buddi/tool-browser/dist/controller.js.map +1 -1
  307. package/node_modules/@buddi/tool-browser/dist/extension.d.ts +1 -1
  308. package/node_modules/@buddi/tool-browser/dist/extension.js +1 -1
  309. package/node_modules/@buddi/tool-browser/dist/host.d.ts +3 -1
  310. package/node_modules/@buddi/tool-browser/dist/host.d.ts.map +1 -1
  311. package/node_modules/@buddi/tool-browser/dist/host.js +5 -1
  312. package/node_modules/@buddi/tool-browser/dist/host.js.map +1 -1
  313. package/node_modules/@buddi/tool-browser/dist/index.d.ts +1 -1
  314. package/node_modules/@buddi/tool-browser/dist/index.d.ts.map +1 -1
  315. package/node_modules/@buddi/tool-browser/dist/index.js +1 -1
  316. package/node_modules/@buddi/tool-browser/dist/index.js.map +1 -1
  317. package/node_modules/@buddi/tool-browser/dist/secrets.d.ts +2 -2
  318. package/node_modules/@buddi/tool-browser/dist/service.d.ts +4 -4
  319. package/node_modules/@buddi/tool-browser/dist/service.d.ts.map +1 -1
  320. package/node_modules/@buddi/tool-browser/dist/service.js +1 -1
  321. package/node_modules/@buddi/tool-browser/dist/types.d.ts +1 -1
  322. package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
  323. package/node_modules/@buddi/tool-email/dist/attachments/safety.d.ts +1 -1
  324. package/node_modules/@buddi/tool-email/dist/attachments/safety.js +1 -1
  325. package/node_modules/@buddi/tool-email/dist/channel.d.ts +43 -0
  326. package/node_modules/@buddi/tool-email/dist/channel.d.ts.map +1 -0
  327. package/node_modules/@buddi/tool-email/dist/channel.js +99 -0
  328. package/node_modules/@buddi/tool-email/dist/channel.js.map +1 -0
  329. package/node_modules/@buddi/tool-email/dist/credentials.d.ts +1 -1
  330. package/node_modules/@buddi/tool-email/dist/dates.d.ts +1 -1
  331. package/node_modules/@buddi/tool-email/dist/dates.js +1 -1
  332. package/node_modules/@buddi/tool-email/dist/drafts.d.ts +2 -2
  333. package/node_modules/@buddi/tool-email/dist/drafts.js +1 -1
  334. package/node_modules/@buddi/tool-email/dist/index.d.ts +1 -0
  335. package/node_modules/@buddi/tool-email/dist/index.d.ts.map +1 -1
  336. package/node_modules/@buddi/tool-email/dist/index.js +13 -6
  337. package/node_modules/@buddi/tool-email/dist/index.js.map +1 -1
  338. package/node_modules/@buddi/tool-email/dist/mail.d.ts +4 -4
  339. package/node_modules/@buddi/tool-email/dist/mail.js +4 -4
  340. package/node_modules/@buddi/tool-email/dist/pages/accounts.d.ts +2 -2
  341. package/node_modules/@buddi/tool-email/dist/pages/descriptors.js +7 -7
  342. package/node_modules/@buddi/tool-email/dist/pages/descriptors.js.map +1 -1
  343. package/node_modules/@buddi/tool-email/dist/pages/drafts-tools.d.ts +1 -1
  344. package/node_modules/@buddi/tool-email/dist/pages/index.d.ts +1 -1
  345. package/node_modules/@buddi/tool-email/dist/pages/policies-tools.d.ts +2 -2
  346. package/node_modules/@buddi/tool-email/dist/pages/policies-tools.js +1 -1
  347. package/node_modules/@buddi/tool-email/dist/pages/queries.d.ts +2 -2
  348. package/node_modules/@buddi/tool-email/dist/pages/queries.d.ts.map +1 -1
  349. package/node_modules/@buddi/tool-email/dist/pages/queries.js +3 -3
  350. package/node_modules/@buddi/tool-email/dist/pages/queries.js.map +1 -1
  351. package/node_modules/@buddi/tool-email/dist/phrases.d.ts +2 -2
  352. package/node_modules/@buddi/tool-email/dist/phrases.js +2 -2
  353. package/node_modules/@buddi/tool-email/dist/policies/gate.js +2 -2
  354. package/node_modules/@buddi/tool-email/dist/policies/learn.d.ts +3 -3
  355. package/node_modules/@buddi/tool-email/dist/policies/learn.js +1 -1
  356. package/node_modules/@buddi/tool-email/dist/policies/learned.d.ts +1 -1
  357. package/node_modules/@buddi/tool-email/dist/ports.d.ts +4 -4
  358. package/node_modules/@buddi/tool-email/dist/ports.js +1 -1
  359. package/node_modules/@buddi/tool-email/dist/rows.d.ts +1 -1
  360. package/node_modules/@buddi/tool-email/dist/rows.js +1 -1
  361. package/node_modules/@buddi/tool-email/dist/search.js +2 -2
  362. package/node_modules/@buddi/tool-email/dist/sentinels/date-stated.d.ts +1 -1
  363. package/node_modules/@buddi/tool-email/dist/sentinels/index.d.ts +1 -1
  364. package/node_modules/@buddi/tool-email/dist/sentinels/index.js +1 -1
  365. package/node_modules/@buddi/tool-email/dist/sentinels/index.js.map +1 -1
  366. package/node_modules/@buddi/tool-email/dist/sentinels/promised-reply.d.ts +1 -1
  367. package/node_modules/@buddi/tool-email/dist/sentinels/receipt-or-bill.d.ts +1 -1
  368. package/node_modules/@buddi/tool-email/dist/sentinels/suspicious-sender.d.ts +1 -1
  369. package/node_modules/@buddi/tool-email/dist/sentinels/unanswered-by-them.d.ts +1 -1
  370. package/node_modules/@buddi/tool-email/dist/sentinels/waiting-on-me.d.ts +2 -2
  371. package/node_modules/@buddi/tool-email/dist/sentinels/waiting-on-me.d.ts.map +1 -1
  372. package/node_modules/@buddi/tool-email/dist/sentinels/waiting-on-me.js +1 -1
  373. package/node_modules/@buddi/tool-email/dist/sources/inbox-poll.js +5 -5
  374. package/node_modules/@buddi/tool-email/dist/sources/inbox-poll.js.map +1 -1
  375. package/node_modules/@buddi/tool-email/dist/sources/retention.js +1 -1
  376. package/node_modules/@buddi/tool-email/dist/sources/retention.js.map +1 -1
  377. package/node_modules/@buddi/tool-email/dist/suspicions-store.d.ts +1 -1
  378. package/node_modules/@buddi/tool-email/dist/tools/attachments.d.ts +1 -1
  379. package/node_modules/@buddi/tool-email/dist/tools/attachments.js +1 -1
  380. package/node_modules/@buddi/tool-email/dist/tools/drafts.d.ts +1 -1
  381. package/node_modules/@buddi/tool-email/dist/tools/drafts.js +3 -3
  382. package/node_modules/@buddi/tool-email/dist/tools/drafts.js.map +1 -1
  383. package/node_modules/@buddi/tool-email/dist/tools/policies.d.ts +1 -1
  384. package/node_modules/@buddi/tool-email/dist/tools/send.d.ts +1 -1
  385. package/node_modules/@buddi/tool-email/dist/tools/send.js +4 -4
  386. package/node_modules/@buddi/tool-email/dist/tools/send.js.map +1 -1
  387. package/node_modules/@buddi/tool-email/dist/tools/settings.d.ts +1 -1
  388. package/node_modules/@buddi/tool-email/dist/tools/triage.js +2 -2
  389. package/node_modules/@buddi/tool-email/dist/watchers.d.ts +1 -1
  390. package/node_modules/@buddi/tool-email/dist/watchers.js +1 -1
  391. package/node_modules/@buddi/tool-email/dist/watchers.js.map +1 -1
  392. package/node_modules/@buddi/tool-email/migrations/001_email.sql +3 -2
  393. package/node_modules/@buddi/tool-email/package.json +2 -1
  394. package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
  395. package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
  396. package/node_modules/@buddi/tool-memory/dist/index.js +1 -1
  397. package/node_modules/@buddi/tool-memory/migrations/001_memory.sql +1 -1
  398. package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
  399. package/node_modules/@buddi/tool-web/dist/guard.d.ts +1 -1
  400. package/node_modules/@buddi/tool-web/dist/guard.js +1 -1
  401. package/package.json +6 -2
  402. package/packages/cli/dist/.tsbuildinfo +1 -1
  403. package/packages/cli/dist/args.d.ts +9 -3
  404. package/packages/cli/dist/args.d.ts.map +1 -1
  405. package/packages/cli/dist/args.js +25 -89
  406. package/packages/cli/dist/args.js.map +1 -1
  407. package/packages/cli/dist/backup/index.d.ts +2 -0
  408. package/packages/cli/dist/backup/index.d.ts.map +1 -1
  409. package/packages/cli/dist/backup/index.js +13 -4
  410. package/packages/cli/dist/backup/index.js.map +1 -1
  411. package/packages/cli/dist/commands.d.ts +94 -0
  412. package/packages/cli/dist/commands.d.ts.map +1 -0
  413. package/packages/cli/dist/commands.js +993 -0
  414. package/packages/cli/dist/commands.js.map +1 -0
  415. package/packages/cli/dist/index.d.ts +3 -1
  416. package/packages/cli/dist/index.d.ts.map +1 -1
  417. package/packages/cli/dist/index.js +3 -1
  418. package/packages/cli/dist/index.js.map +1 -1
  419. package/packages/cli/dist/jobs-cmd.d.ts +4 -0
  420. package/packages/cli/dist/jobs-cmd.d.ts.map +1 -1
  421. package/packages/cli/dist/jobs-cmd.js +26 -7
  422. package/packages/cli/dist/jobs-cmd.js.map +1 -1
  423. package/packages/cli/dist/main.d.ts +9 -2
  424. package/packages/cli/dist/main.d.ts.map +1 -1
  425. package/packages/cli/dist/main.js +246 -30
  426. package/packages/cli/dist/main.js.map +1 -1
  427. package/packages/cli/dist/mcp/gateway-client.d.ts +1 -1
  428. package/packages/cli/dist/mcp/gateway-client.js +1 -1
  429. package/packages/cli/dist/mcp/secrets.d.ts +1 -1
  430. package/packages/cli/dist/mcp/secrets.js +1 -1
  431. package/packages/cli/dist/mcp/server.d.ts +1 -1
  432. package/packages/cli/dist/mcp/server.js +1 -1
  433. package/packages/cli/dist/mcp/tools.d.ts +1 -1
  434. package/packages/cli/dist/mcp/tools.js +1 -1
  435. package/packages/cli/dist/paths.d.ts +8 -5
  436. package/packages/cli/dist/paths.d.ts.map +1 -1
  437. package/packages/cli/dist/paths.js +36 -10
  438. package/packages/cli/dist/paths.js.map +1 -1
  439. package/packages/cli/dist/status.d.ts +70 -0
  440. package/packages/cli/dist/status.d.ts.map +1 -0
  441. package/packages/cli/dist/status.js +122 -0
  442. package/packages/cli/dist/status.js.map +1 -0
  443. package/packages/cli/dist/style.d.ts +13 -0
  444. package/packages/cli/dist/style.d.ts.map +1 -0
  445. package/packages/cli/dist/style.js +10 -0
  446. package/packages/cli/dist/style.js.map +1 -0
  447. package/packages/cli/dist/telegram-cmd.d.ts +1 -1
  448. package/packages/cli/dist/telegram-cmd.d.ts.map +1 -1
  449. package/packages/cli/dist/telegram-cmd.js +23 -6
  450. package/packages/cli/dist/telegram-cmd.js.map +1 -1
  451. package/packages/cli/dist/vault-cmd.js +3 -3
  452. package/packages/core/dist/.tsbuildinfo +1 -1
  453. package/packages/core/dist/actions/approvals.d.ts +0 -17
  454. package/packages/core/dist/actions/approvals.d.ts.map +1 -1
  455. package/packages/core/dist/actions/approvals.js +21 -0
  456. package/packages/core/dist/actions/approvals.js.map +1 -1
  457. package/packages/core/dist/actions/execute.d.ts +1 -1
  458. package/packages/core/dist/actions/jobs.d.ts +1 -1
  459. package/packages/core/dist/actions/types.js +1 -1
  460. package/packages/core/dist/agents/provider-from-env.d.ts +1 -1
  461. package/packages/core/dist/agents/provider-from-env.js +1 -1
  462. package/packages/core/dist/agents/skills.js +1 -1
  463. package/packages/core/dist/goals/types.d.ts +1 -1
  464. package/packages/core/dist/goals/types.js +1 -1
  465. package/packages/core/dist/host/build.d.ts +15 -1
  466. package/packages/core/dist/host/build.d.ts.map +1 -1
  467. package/packages/core/dist/host/build.js +101 -3
  468. package/packages/core/dist/host/build.js.map +1 -1
  469. package/packages/core/dist/host/http.d.ts +1 -1
  470. package/packages/core/dist/host/http.d.ts.map +1 -1
  471. package/packages/core/dist/host/http.js +1 -1
  472. package/packages/core/dist/host/http.js.map +1 -1
  473. package/packages/core/dist/host/types.d.ts +92 -5
  474. package/packages/core/dist/host/types.d.ts.map +1 -1
  475. package/packages/core/dist/index.d.ts +1 -0
  476. package/packages/core/dist/index.d.ts.map +1 -1
  477. package/packages/core/dist/index.js +1 -0
  478. package/packages/core/dist/index.js.map +1 -1
  479. package/packages/core/dist/learning/echoes.d.ts +1 -1
  480. package/packages/core/dist/learning/echoes.js +1 -1
  481. package/packages/core/dist/learning/policies.d.ts +1 -1
  482. package/packages/core/dist/learning/skill-files.js +1 -1
  483. package/packages/core/dist/learning/types.d.ts +2 -2
  484. package/packages/core/dist/notifications/channels.d.ts +37 -0
  485. package/packages/core/dist/notifications/channels.d.ts.map +1 -0
  486. package/packages/core/dist/notifications/channels.js +87 -0
  487. package/packages/core/dist/notifications/channels.js.map +1 -0
  488. package/packages/core/dist/notifications/index.d.ts +5 -0
  489. package/packages/core/dist/notifications/index.d.ts.map +1 -0
  490. package/packages/core/dist/notifications/index.js +5 -0
  491. package/packages/core/dist/notifications/index.js.map +1 -0
  492. package/packages/core/dist/notifications/notify.d.ts +35 -0
  493. package/packages/core/dist/notifications/notify.d.ts.map +1 -0
  494. package/packages/core/dist/notifications/notify.js +262 -0
  495. package/packages/core/dist/notifications/notify.js.map +1 -0
  496. package/packages/core/dist/notifications/store.d.ts +48 -0
  497. package/packages/core/dist/notifications/store.d.ts.map +1 -0
  498. package/packages/core/dist/notifications/store.js +207 -0
  499. package/packages/core/dist/notifications/store.js.map +1 -0
  500. package/packages/core/dist/notifications/types.d.ts +136 -0
  501. package/packages/core/dist/notifications/types.d.ts.map +1 -0
  502. package/packages/core/dist/notifications/types.js +5 -0
  503. package/packages/core/dist/notifications/types.js.map +1 -0
  504. package/packages/core/dist/owner.js +1 -1
  505. package/packages/core/dist/pages/__fixtures__/demo.js +1 -1
  506. package/packages/core/dist/pages.d.ts +4 -4
  507. package/packages/core/dist/pages.js +1 -1
  508. package/packages/core/dist/plugin/index.d.ts +2 -2
  509. package/packages/core/dist/plugin/index.d.ts.map +1 -1
  510. package/packages/core/dist/plugin/index.js +1 -1
  511. package/packages/core/dist/plugin/search.d.ts +1 -1
  512. package/packages/core/dist/plugin/search.js +1 -1
  513. package/packages/core/dist/plugin/url.js +1 -1
  514. package/packages/core/dist/plugin/uses.d.ts +2 -2
  515. package/packages/core/dist/plugin/uses.d.ts.map +1 -1
  516. package/packages/core/dist/plugin/uses.js +5 -1
  517. package/packages/core/dist/plugin/uses.js.map +1 -1
  518. package/packages/core/dist/plugin/version.d.ts +2 -2
  519. package/packages/core/dist/plugin/version.js +2 -2
  520. package/packages/core/dist/provider.d.ts +1 -1
  521. package/packages/core/dist/provider.js +1 -1
  522. package/packages/core/dist/queue/retry-policy.d.ts +1 -1
  523. package/packages/core/dist/queue/retry-policy.js +1 -1
  524. package/packages/core/dist/registry.d.ts.map +1 -1
  525. package/packages/core/dist/registry.js +4 -5
  526. package/packages/core/dist/registry.js.map +1 -1
  527. package/packages/core/dist/reminders/store.d.ts +1 -1
  528. package/packages/core/dist/reminders/store.js +1 -1
  529. package/packages/core/dist/reminders/types.d.ts +1 -1
  530. package/packages/core/dist/reminders/types.js +1 -1
  531. package/packages/core/dist/secrets/approval.d.ts +1 -1
  532. package/packages/core/dist/secrets/approval.js +1 -1
  533. package/packages/core/dist/secrets/destinations.d.ts +1 -1
  534. package/packages/core/dist/secrets/scrub.js +1 -1
  535. package/packages/core/dist/secrets/settings.js +1 -1
  536. package/packages/core/dist/secrets/store.d.ts +1 -1
  537. package/packages/core/dist/secrets/totp.js +1 -1
  538. package/packages/core/dist/secrets/use.d.ts +1 -1
  539. package/packages/core/dist/sentinels/types.d.ts +1 -1
  540. package/packages/core/dist/testing/index.d.ts +1 -1
  541. package/packages/core/dist/testing/index.js +1 -1
  542. package/packages/core/dist/time.d.ts +12 -0
  543. package/packages/core/dist/time.d.ts.map +1 -1
  544. package/packages/core/dist/time.js +46 -0
  545. package/packages/core/dist/time.js.map +1 -1
  546. package/packages/core/dist/tools.d.ts +10 -10
  547. package/packages/core/dist/vault/file.js +2 -2
  548. package/packages/core/dist/vault/keychain.js +1 -1
  549. package/packages/core/dist/vault/keychain.js.map +1 -1
  550. package/packages/core/dist/vault/resolve.d.ts +3 -3
  551. package/packages/core/dist/vault/resolve.js +3 -3
  552. package/packages/core/dist/vault/types.d.ts +1 -1
  553. package/packages/core/dist/vault/types.js +2 -2
  554. package/packages/core/migrations/003_owner_surfaces.sql +1 -1
  555. package/packages/core/migrations/005_artifacts.sql +1 -1
  556. package/packages/core/migrations/009_queue.sql +1 -2
  557. package/packages/core/migrations/010_actions.sql +1 -1
  558. package/packages/core/migrations/043_owner_notifications.sql +77 -0
  559. package/packages/gateway/dist/.tsbuildinfo +1 -1
  560. package/packages/gateway/dist/agents/catalog.d.ts.map +1 -1
  561. package/packages/gateway/dist/agents/catalog.js +5 -6
  562. package/packages/gateway/dist/agents/catalog.js.map +1 -1
  563. package/packages/gateway/dist/agents/learned-skills.js +1 -1
  564. package/packages/gateway/dist/agents/learning-digest.d.ts +1 -1
  565. package/packages/gateway/dist/agents/learning-digest.js +1 -1
  566. package/packages/gateway/dist/agents/learning.d.ts +1 -1
  567. package/packages/gateway/dist/agents/learning.js +1 -1
  568. package/packages/gateway/dist/agents-cli.d.ts +25 -1
  569. package/packages/gateway/dist/agents-cli.d.ts.map +1 -1
  570. package/packages/gateway/dist/agents-cli.js +91 -27
  571. package/packages/gateway/dist/agents-cli.js.map +1 -1
  572. package/packages/gateway/dist/bootstrap.d.ts.map +1 -1
  573. package/packages/gateway/dist/bootstrap.js +10 -2
  574. package/packages/gateway/dist/bootstrap.js.map +1 -1
  575. package/packages/gateway/dist/channels/local-notification.d.ts +39 -0
  576. package/packages/gateway/dist/channels/local-notification.d.ts.map +1 -0
  577. package/packages/gateway/dist/channels/local-notification.js +154 -0
  578. package/packages/gateway/dist/channels/local-notification.js.map +1 -0
  579. package/packages/gateway/dist/chat/approvals.d.ts +3 -3
  580. package/packages/gateway/dist/chat/approvals.js +3 -3
  581. package/packages/gateway/dist/cli.d.ts +14 -0
  582. package/packages/gateway/dist/cli.d.ts.map +1 -1
  583. package/packages/gateway/dist/cli.js +208 -37
  584. package/packages/gateway/dist/cli.js.map +1 -1
  585. package/packages/gateway/dist/db-ready.d.ts +2 -1
  586. package/packages/gateway/dist/db-ready.d.ts.map +1 -1
  587. package/packages/gateway/dist/db-ready.js +3 -2
  588. package/packages/gateway/dist/db-ready.js.map +1 -1
  589. package/packages/gateway/dist/index.d.ts +4 -1
  590. package/packages/gateway/dist/index.d.ts.map +1 -1
  591. package/packages/gateway/dist/index.js +5 -1
  592. package/packages/gateway/dist/index.js.map +1 -1
  593. package/packages/gateway/dist/mcp/requests.d.ts +1 -1
  594. package/packages/gateway/dist/mcp/requests.js +1 -1
  595. package/packages/gateway/dist/missions/agent-run.d.ts.map +1 -1
  596. package/packages/gateway/dist/missions/agent-run.js +10 -1
  597. package/packages/gateway/dist/missions/agent-run.js.map +1 -1
  598. package/packages/gateway/dist/missions/execute.d.ts +16 -2
  599. package/packages/gateway/dist/missions/execute.d.ts.map +1 -1
  600. package/packages/gateway/dist/missions/execute.js +6 -1
  601. package/packages/gateway/dist/missions/execute.js.map +1 -1
  602. package/packages/gateway/dist/missions/goals-page.d.ts +1 -1
  603. package/packages/gateway/dist/missions/goals-page.js +1 -1
  604. package/packages/gateway/dist/missions/goals.d.ts +1 -1
  605. package/packages/gateway/dist/missions/goals.js +1 -1
  606. package/packages/gateway/dist/missions/watcher-mail.d.ts +1 -1
  607. package/packages/gateway/dist/missions/watcher-mail.js +1 -1
  608. package/packages/gateway/dist/missions-cli.d.ts +2 -0
  609. package/packages/gateway/dist/missions-cli.d.ts.map +1 -1
  610. package/packages/gateway/dist/missions-cli.js +53 -8
  611. package/packages/gateway/dist/missions-cli.js.map +1 -1
  612. package/packages/gateway/dist/owner-notify.d.ts +43 -0
  613. package/packages/gateway/dist/owner-notify.d.ts.map +1 -0
  614. package/packages/gateway/dist/owner-notify.js +87 -0
  615. package/packages/gateway/dist/owner-notify.js.map +1 -0
  616. package/packages/gateway/dist/owner-secrets.d.ts +3 -3
  617. package/packages/gateway/dist/owner-secrets.js +3 -3
  618. package/packages/gateway/dist/plugins/load.d.ts +1 -1
  619. package/packages/gateway/dist/plugins/load.js +1 -1
  620. package/packages/gateway/dist/plugins/scaffold.js +1 -1
  621. package/packages/gateway/dist/plugins/stage.d.ts +2 -2
  622. package/packages/gateway/dist/plugins/stage.js +1 -1
  623. package/packages/gateway/dist/plugins-cli.d.ts +3 -1
  624. package/packages/gateway/dist/plugins-cli.d.ts.map +1 -1
  625. package/packages/gateway/dist/plugins-cli.js +11 -4
  626. package/packages/gateway/dist/plugins-cli.js.map +1 -1
  627. package/packages/gateway/dist/provider-accounts.js +1 -1
  628. package/packages/gateway/dist/provider-accounts.js.map +1 -1
  629. package/packages/gateway/dist/reminders-cli.d.ts +3 -1
  630. package/packages/gateway/dist/reminders-cli.d.ts.map +1 -1
  631. package/packages/gateway/dist/reminders-cli.js +21 -2
  632. package/packages/gateway/dist/reminders-cli.js.map +1 -1
  633. package/packages/gateway/dist/serve.d.ts +2 -0
  634. package/packages/gateway/dist/serve.d.ts.map +1 -1
  635. package/packages/gateway/dist/serve.js +62 -15
  636. package/packages/gateway/dist/serve.js.map +1 -1
  637. package/packages/gateway/dist/telegram/approvals.d.ts +3 -3
  638. package/packages/gateway/dist/telegram/approvals.js +3 -3
  639. package/packages/gateway/dist/telegram/channel.d.ts +30 -0
  640. package/packages/gateway/dist/telegram/channel.d.ts.map +1 -0
  641. package/packages/gateway/dist/telegram/channel.js +49 -0
  642. package/packages/gateway/dist/telegram/channel.js.map +1 -0
  643. package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
  644. package/packages/gateway/dist/telegram/surface.js +4 -1
  645. package/packages/gateway/dist/telegram/surface.js.map +1 -1
  646. package/packages/gateway/dist/web/config.js +3 -3
  647. package/packages/gateway/dist/web/http.d.ts +16 -3
  648. package/packages/gateway/dist/web/http.d.ts.map +1 -1
  649. package/packages/gateway/dist/web/http.js +39 -3
  650. package/packages/gateway/dist/web/http.js.map +1 -1
  651. package/packages/gateway/dist/web/notifications.d.ts +36 -0
  652. package/packages/gateway/dist/web/notifications.d.ts.map +1 -0
  653. package/packages/gateway/dist/web/notifications.js +63 -0
  654. package/packages/gateway/dist/web/notifications.js.map +1 -0
  655. package/packages/gateway/dist/web/onboarding.d.ts +1 -1
  656. package/packages/gateway/dist/web/onboarding.js +1 -1
  657. package/packages/gateway/dist/web/pages.js +1 -1
  658. package/packages/gateway/dist/web/read.js +3 -3
  659. package/packages/gateway/dist/web/secrets.d.ts +1 -1
  660. package/packages/gateway/dist/web/server.d.ts +1 -1
  661. package/packages/gateway/dist/web/server.d.ts.map +1 -1
  662. package/packages/gateway/dist/web/server.js +37 -25
  663. package/packages/gateway/dist/web/server.js.map +1 -1
  664. package/packages/gateway/dist/web/version.d.ts +1 -0
  665. package/packages/gateway/dist/web/version.d.ts.map +1 -1
  666. package/packages/gateway/dist/web/version.js +2 -1
  667. package/packages/gateway/dist/web/version.js.map +1 -1
  668. package/packages/gateway/dist/web/write.js +1 -1
  669. package/packages/install/dist/.tsbuildinfo +1 -1
  670. package/packages/install/dist/environment.d.ts +29 -0
  671. package/packages/install/dist/environment.d.ts.map +1 -1
  672. package/packages/install/dist/environment.js +50 -1
  673. package/packages/install/dist/environment.js.map +1 -1
  674. package/packages/install/dist/launcher.d.ts +3 -1
  675. package/packages/install/dist/launcher.d.ts.map +1 -1
  676. package/packages/install/dist/launcher.js +93 -12
  677. package/packages/install/dist/launcher.js.map +1 -1
  678. package/packages/install/dist/upgrade.d.ts +16 -3
  679. package/packages/install/dist/upgrade.d.ts.map +1 -1
  680. package/packages/install/dist/upgrade.js +21 -7
  681. package/packages/install/dist/upgrade.js.map +1 -1
  682. package/packages/runtime/dist/.tsbuildinfo +1 -1
  683. package/packages/runtime/dist/anthropic.d.ts +35 -2
  684. package/packages/runtime/dist/anthropic.d.ts.map +1 -1
  685. package/packages/runtime/dist/anthropic.js +36 -12
  686. package/packages/runtime/dist/anthropic.js.map +1 -1
  687. package/packages/runtime/dist/delegate.js +1 -1
  688. package/packages/runtime/dist/loop.d.ts +13 -1
  689. package/packages/runtime/dist/loop.d.ts.map +1 -1
  690. package/packages/runtime/dist/loop.js +70 -3
  691. package/packages/runtime/dist/loop.js.map +1 -1
  692. package/packages/runtime/dist/openai.d.ts.map +1 -1
  693. package/packages/runtime/dist/openai.js +9 -6
  694. package/packages/runtime/dist/openai.js.map +1 -1
  695. package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
  696. package/packages/tools/artifacts/dist/index.d.ts +1 -1
  697. package/packages/tools/browser/dist/.tsbuildinfo +1 -1
  698. package/packages/tools/browser/dist/availability.d.ts +34 -8
  699. package/packages/tools/browser/dist/availability.d.ts.map +1 -1
  700. package/packages/tools/browser/dist/availability.js +44 -5
  701. package/packages/tools/browser/dist/availability.js.map +1 -1
  702. package/packages/tools/browser/dist/controller.d.ts +2 -2
  703. package/packages/tools/browser/dist/controller.d.ts.map +1 -1
  704. package/packages/tools/browser/dist/controller.js +7 -6
  705. package/packages/tools/browser/dist/controller.js.map +1 -1
  706. package/packages/tools/browser/dist/extension.d.ts +1 -1
  707. package/packages/tools/browser/dist/extension.js +1 -1
  708. package/packages/tools/browser/dist/host.d.ts +3 -1
  709. package/packages/tools/browser/dist/host.d.ts.map +1 -1
  710. package/packages/tools/browser/dist/host.js +5 -1
  711. package/packages/tools/browser/dist/host.js.map +1 -1
  712. package/packages/tools/browser/dist/index.d.ts +1 -1
  713. package/packages/tools/browser/dist/index.d.ts.map +1 -1
  714. package/packages/tools/browser/dist/index.js +1 -1
  715. package/packages/tools/browser/dist/index.js.map +1 -1
  716. package/packages/tools/browser/dist/secrets.d.ts +2 -2
  717. package/packages/tools/browser/dist/service.d.ts +4 -4
  718. package/packages/tools/browser/dist/service.d.ts.map +1 -1
  719. package/packages/tools/browser/dist/service.js +1 -1
  720. package/packages/tools/browser/dist/types.d.ts +1 -1
  721. package/packages/tools/email/dist/.tsbuildinfo +1 -1
  722. package/packages/tools/email/dist/attachments/safety.d.ts +1 -1
  723. package/packages/tools/email/dist/attachments/safety.js +1 -1
  724. package/packages/tools/email/dist/channel.d.ts +43 -0
  725. package/packages/tools/email/dist/channel.d.ts.map +1 -0
  726. package/packages/tools/email/dist/channel.js +99 -0
  727. package/packages/tools/email/dist/channel.js.map +1 -0
  728. package/packages/tools/email/dist/credentials.d.ts +1 -1
  729. package/packages/tools/email/dist/dates.d.ts +1 -1
  730. package/packages/tools/email/dist/dates.js +1 -1
  731. package/packages/tools/email/dist/drafts.d.ts +2 -2
  732. package/packages/tools/email/dist/drafts.js +1 -1
  733. package/packages/tools/email/dist/index.d.ts +1 -0
  734. package/packages/tools/email/dist/index.d.ts.map +1 -1
  735. package/packages/tools/email/dist/index.js +13 -6
  736. package/packages/tools/email/dist/index.js.map +1 -1
  737. package/packages/tools/email/dist/mail.d.ts +4 -4
  738. package/packages/tools/email/dist/mail.js +4 -4
  739. package/packages/tools/email/dist/pages/accounts.d.ts +2 -2
  740. package/packages/tools/email/dist/pages/descriptors.js +7 -7
  741. package/packages/tools/email/dist/pages/descriptors.js.map +1 -1
  742. package/packages/tools/email/dist/pages/drafts-tools.d.ts +1 -1
  743. package/packages/tools/email/dist/pages/index.d.ts +1 -1
  744. package/packages/tools/email/dist/pages/policies-tools.d.ts +2 -2
  745. package/packages/tools/email/dist/pages/policies-tools.js +1 -1
  746. package/packages/tools/email/dist/pages/queries.d.ts +2 -2
  747. package/packages/tools/email/dist/pages/queries.d.ts.map +1 -1
  748. package/packages/tools/email/dist/pages/queries.js +3 -3
  749. package/packages/tools/email/dist/pages/queries.js.map +1 -1
  750. package/packages/tools/email/dist/phrases.d.ts +2 -2
  751. package/packages/tools/email/dist/phrases.js +2 -2
  752. package/packages/tools/email/dist/policies/gate.js +2 -2
  753. package/packages/tools/email/dist/policies/learn.d.ts +3 -3
  754. package/packages/tools/email/dist/policies/learn.js +1 -1
  755. package/packages/tools/email/dist/policies/learned.d.ts +1 -1
  756. package/packages/tools/email/dist/ports.d.ts +4 -4
  757. package/packages/tools/email/dist/ports.js +1 -1
  758. package/packages/tools/email/dist/rows.d.ts +1 -1
  759. package/packages/tools/email/dist/rows.js +1 -1
  760. package/packages/tools/email/dist/search.js +2 -2
  761. package/packages/tools/email/dist/sentinels/date-stated.d.ts +1 -1
  762. package/packages/tools/email/dist/sentinels/index.d.ts +1 -1
  763. package/packages/tools/email/dist/sentinels/index.js +1 -1
  764. package/packages/tools/email/dist/sentinels/index.js.map +1 -1
  765. package/packages/tools/email/dist/sentinels/promised-reply.d.ts +1 -1
  766. package/packages/tools/email/dist/sentinels/receipt-or-bill.d.ts +1 -1
  767. package/packages/tools/email/dist/sentinels/suspicious-sender.d.ts +1 -1
  768. package/packages/tools/email/dist/sentinels/unanswered-by-them.d.ts +1 -1
  769. package/packages/tools/email/dist/sentinels/waiting-on-me.d.ts +2 -2
  770. package/packages/tools/email/dist/sentinels/waiting-on-me.d.ts.map +1 -1
  771. package/packages/tools/email/dist/sentinels/waiting-on-me.js +1 -1
  772. package/packages/tools/email/dist/sources/inbox-poll.js +5 -5
  773. package/packages/tools/email/dist/sources/inbox-poll.js.map +1 -1
  774. package/packages/tools/email/dist/sources/retention.js +1 -1
  775. package/packages/tools/email/dist/sources/retention.js.map +1 -1
  776. package/packages/tools/email/dist/suspicions-store.d.ts +1 -1
  777. package/packages/tools/email/dist/tools/attachments.d.ts +1 -1
  778. package/packages/tools/email/dist/tools/attachments.js +1 -1
  779. package/packages/tools/email/dist/tools/drafts.d.ts +1 -1
  780. package/packages/tools/email/dist/tools/drafts.js +3 -3
  781. package/packages/tools/email/dist/tools/drafts.js.map +1 -1
  782. package/packages/tools/email/dist/tools/policies.d.ts +1 -1
  783. package/packages/tools/email/dist/tools/send.d.ts +1 -1
  784. package/packages/tools/email/dist/tools/send.js +4 -4
  785. package/packages/tools/email/dist/tools/send.js.map +1 -1
  786. package/packages/tools/email/dist/tools/settings.d.ts +1 -1
  787. package/packages/tools/email/dist/tools/triage.js +2 -2
  788. package/packages/tools/email/dist/watchers.d.ts +1 -1
  789. package/packages/tools/email/dist/watchers.js +1 -1
  790. package/packages/tools/email/dist/watchers.js.map +1 -1
  791. package/packages/tools/email/migrations/001_email.sql +3 -2
  792. package/packages/tools/email/package.json +2 -1
  793. package/packages/tools/host/dist/.tsbuildinfo +1 -1
  794. package/packages/tools/memory/dist/.tsbuildinfo +1 -1
  795. package/packages/tools/memory/dist/index.js +1 -1
  796. package/packages/tools/memory/migrations/001_memory.sql +1 -1
  797. package/packages/tools/web/dist/.tsbuildinfo +1 -1
  798. package/packages/tools/web/dist/guard.d.ts +1 -1
  799. package/packages/tools/web/dist/guard.js +1 -1
  800. package/packages/web/dist/assets/dm-mono-latin-400-normal--0xN8mdc.woff +0 -0
  801. package/packages/web/dist/assets/dm-mono-latin-400-normal-4GdczIuU.woff2 +0 -0
  802. package/packages/web/dist/assets/dm-mono-latin-500-normal-CN8Miw6E.woff +0 -0
  803. package/packages/web/dist/assets/dm-mono-latin-500-normal-DRMDZjhP.woff2 +0 -0
  804. package/packages/web/dist/assets/dm-mono-latin-ext-400-normal-1aZr6b2b.woff +0 -0
  805. package/packages/web/dist/assets/dm-mono-latin-ext-400-normal-C2zvOubV.woff2 +0 -0
  806. package/packages/web/dist/assets/dm-mono-latin-ext-500-normal-BtRyHRi6.woff2 +0 -0
  807. package/packages/web/dist/assets/dm-mono-latin-ext-500-normal-Dw3M13d8.woff +0 -0
  808. package/packages/web/dist/assets/dm-sans-latin-ext-standard-italic-DNX9AbKj.woff2 +0 -0
  809. package/packages/web/dist/assets/dm-sans-latin-ext-standard-normal-oos9povj.woff2 +0 -0
  810. package/packages/web/dist/assets/dm-sans-latin-standard-italic-C8i6y2Ft.woff2 +0 -0
  811. package/packages/web/dist/assets/dm-sans-latin-standard-normal-Bf69Tn_J.woff2 +0 -0
  812. package/packages/web/dist/assets/index-BRkIoT-q.js +123 -0
  813. package/packages/web/dist/assets/index-DCn0vN58.css +1 -0
  814. package/packages/web/dist/index.html +2 -2
  815. package/packages/web/dist/assets/index-CxaF2koC.js +0 -122
  816. package/packages/web/dist/assets/index-DEho_xyR.css +0 -1
@@ -1,122 +0,0 @@
1
- var pg=e=>{throw TypeError(e)};var mg=(e,t,n)=>t.has(e)||pg("Cannot "+n);var Et=(e,t,n)=>(mg(e,t,"read from private field"),n?n.call(e):t.get(e)),gg=(e,t,n)=>t.has(e)?pg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ku=(e,t,n,r)=>(mg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function u1(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(r,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const o of l.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function d1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ij={exports:{}},Tc={},lj={exports:{}},ke={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var ao=Symbol.for("react.element"),f1=Symbol.for("react.portal"),h1=Symbol.for("react.fragment"),p1=Symbol.for("react.strict_mode"),m1=Symbol.for("react.profiler"),g1=Symbol.for("react.provider"),x1=Symbol.for("react.context"),v1=Symbol.for("react.forward_ref"),j1=Symbol.for("react.suspense"),y1=Symbol.for("react.memo"),w1=Symbol.for("react.lazy"),xg=Symbol.iterator;function b1(e){return e===null||typeof e!="object"?null:(e=xg&&e[xg]||e["@@iterator"],typeof e=="function"?e:null)}var oj={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},aj=Object.assign,cj={};function Hi(e,t,n){this.props=e,this.context=t,this.refs=cj,this.updater=n||oj}Hi.prototype.isReactComponent={};Hi.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Hi.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function uj(){}uj.prototype=Hi.prototype;function _h(e,t,n){this.props=e,this.context=t,this.refs=cj,this.updater=n||oj}var Oh=_h.prototype=new uj;Oh.constructor=_h;aj(Oh,Hi.prototype);Oh.isPureReactComponent=!0;var vg=Array.isArray,dj=Object.prototype.hasOwnProperty,Dh={current:null},fj={key:!0,ref:!0,__self:!0,__source:!0};function hj(e,t,n){var r,i={},l=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(l=""+t.key),t)dj.call(t,r)&&!fj.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){for(var c=Array(a),u=0;u<a;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)i[r]===void 0&&(i[r]=a[r]);return{$$typeof:ao,type:e,key:l,ref:o,props:i,_owner:Dh.current}}function k1(e,t){return{$$typeof:ao,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Lh(e){return typeof e=="object"&&e!==null&&e.$$typeof===ao}function S1(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var jg=/\/+/g;function Su(e,t){return typeof e=="object"&&e!==null&&e.key!=null?S1(""+e.key):t.toString(36)}function va(e,t,n,r,i){var l=typeof e;(l==="undefined"||l==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(l){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case ao:case f1:o=!0}}if(o)return o=e,i=i(o),e=r===""?"."+Su(o,0):r,vg(i)?(n="",e!=null&&(n=e.replace(jg,"$&/")+"/"),va(i,t,n,"",function(u){return u})):i!=null&&(Lh(i)&&(i=k1(i,n+(!i.key||o&&o.key===i.key?"":(""+i.key).replace(jg,"$&/")+"/")+e)),t.push(i)),1;if(o=0,r=r===""?".":r+":",vg(e))for(var a=0;a<e.length;a++){l=e[a];var c=r+Su(l,a);o+=va(l,t,n,c,i)}else if(c=b1(e),typeof c=="function")for(e=c.call(e),a=0;!(l=e.next()).done;)l=l.value,c=r+Su(l,a++),o+=va(l,t,n,c,i);else if(l==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function Io(e,t,n){if(e==null)return e;var r=[],i=0;return va(e,r,"","",function(l){return t.call(n,l,i++)}),r}function N1(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Bt={current:null},ja={transition:null},C1={ReactCurrentDispatcher:Bt,ReactCurrentBatchConfig:ja,ReactCurrentOwner:Dh};function pj(){throw Error("act(...) is not supported in production builds of React.")}ke.Children={map:Io,forEach:function(e,t,n){Io(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Io(e,function(){t++}),t},toArray:function(e){return Io(e,function(t){return t})||[]},only:function(e){if(!Lh(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ke.Component=Hi;ke.Fragment=h1;ke.Profiler=m1;ke.PureComponent=_h;ke.StrictMode=p1;ke.Suspense=j1;ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=C1;ke.act=pj;ke.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=aj({},e.props),i=e.key,l=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(l=t.ref,o=Dh.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(c in t)dj.call(t,c)&&!fj.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&a!==void 0?a[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){a=Array(c);for(var u=0;u<c;u++)a[u]=arguments[u+2];r.children=a}return{$$typeof:ao,type:e.type,key:i,ref:l,props:r,_owner:o}};ke.createContext=function(e){return e={$$typeof:x1,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:g1,_context:e},e.Consumer=e};ke.createElement=hj;ke.createFactory=function(e){var t=hj.bind(null,e);return t.type=e,t};ke.createRef=function(){return{current:null}};ke.forwardRef=function(e){return{$$typeof:v1,render:e}};ke.isValidElement=Lh;ke.lazy=function(e){return{$$typeof:w1,_payload:{_status:-1,_result:e},_init:N1}};ke.memo=function(e,t){return{$$typeof:y1,type:e,compare:t===void 0?null:t}};ke.startTransition=function(e){var t=ja.transition;ja.transition={};try{e()}finally{ja.transition=t}};ke.unstable_act=pj;ke.useCallback=function(e,t){return Bt.current.useCallback(e,t)};ke.useContext=function(e){return Bt.current.useContext(e)};ke.useDebugValue=function(){};ke.useDeferredValue=function(e){return Bt.current.useDeferredValue(e)};ke.useEffect=function(e,t){return Bt.current.useEffect(e,t)};ke.useId=function(){return Bt.current.useId()};ke.useImperativeHandle=function(e,t,n){return Bt.current.useImperativeHandle(e,t,n)};ke.useInsertionEffect=function(e,t){return Bt.current.useInsertionEffect(e,t)};ke.useLayoutEffect=function(e,t){return Bt.current.useLayoutEffect(e,t)};ke.useMemo=function(e,t){return Bt.current.useMemo(e,t)};ke.useReducer=function(e,t,n){return Bt.current.useReducer(e,t,n)};ke.useRef=function(e){return Bt.current.useRef(e)};ke.useState=function(e){return Bt.current.useState(e)};ke.useSyncExternalStore=function(e,t,n){return Bt.current.useSyncExternalStore(e,t,n)};ke.useTransition=function(){return Bt.current.useTransition()};ke.version="18.3.1";lj.exports=ke;var d=lj.exports;const E1=d1(d),Ki=u1({__proto__:null,default:E1},[d]);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var A1=d,R1=Symbol.for("react.element"),T1=Symbol.for("react.fragment"),P1=Object.prototype.hasOwnProperty,I1=A1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,M1={key:!0,ref:!0,__self:!0,__source:!0};function mj(e,t,n){var r,i={},l=null,o=null;n!==void 0&&(l=""+n),t.key!==void 0&&(l=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)P1.call(t,r)&&!M1.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:R1,type:e,key:l,ref:o,props:i,_owner:I1.current}}Tc.Fragment=T1;Tc.jsx=mj;Tc.jsxs=mj;ij.exports=Tc;var s=ij.exports,gj={exports:{}},dn={},xj={exports:{}},vj={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t(M,V){var $=M.length;M.push(V);e:for(;0<$;){var _=$-1>>>1,ne=M[_];if(0<i(ne,V))M[_]=V,M[$]=ne,$=_;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var V=M[0],$=M.pop();if($!==V){M[0]=$;e:for(var _=0,ne=M.length,X=ne>>>1;_<X;){var ue=2*(_+1)-1,ye=M[ue],Ne=ue+1,ce=M[Ne];if(0>i(ye,$))Ne<ne&&0>i(ce,ye)?(M[_]=ce,M[Ne]=$,_=Ne):(M[_]=ye,M[ue]=$,_=ue);else if(Ne<ne&&0>i(ce,$))M[_]=ce,M[Ne]=$,_=Ne;else break e}}return V}function i(M,V){var $=M.sortIndex-V.sortIndex;return $!==0?$:M.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var c=[],u=[],h=1,f=null,p=3,m=!1,j=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(M){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=M)r(u),V.sortIndex=V.expirationTime,t(c,V);else break;V=n(u)}}function g(M){if(w=!1,y(M),!j)if(n(c)!==null)j=!0,K(S);else{var V=n(u);V!==null&&L(g,V.startTime-M)}}function S(M,V){j=!1,w&&(w=!1,x(C),C=-1),m=!0;var $=p;try{for(y(V),f=n(c);f!==null&&(!(f.expirationTime>V)||M&&!U());){var _=f.callback;if(typeof _=="function"){f.callback=null,p=f.priorityLevel;var ne=_(f.expirationTime<=V);V=e.unstable_now(),typeof ne=="function"?f.callback=ne:f===n(c)&&r(c),y(V)}else r(c);f=n(c)}if(f!==null)var X=!0;else{var ue=n(u);ue!==null&&L(g,ue.startTime-V),X=!1}return X}finally{f=null,p=$,m=!1}}var k=!1,N=null,C=-1,T=5,E=-1;function U(){return!(e.unstable_now()-E<T)}function H(){if(N!==null){var M=e.unstable_now();E=M;var V=!0;try{V=N(!0,M)}finally{V?O():(k=!1,N=null)}}else k=!1}var O;if(typeof v=="function")O=function(){v(H)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,F=R.port2;R.port1.onmessage=H,O=function(){F.postMessage(null)}}else O=function(){b(H,0)};function K(M){N=M,k||(k=!0,O())}function L(M,V){C=b(function(){M(e.unstable_now())},V)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){j||m||(j=!0,K(S))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(M){switch(p){case 1:case 2:case 3:var V=3;break;default:V=p}var $=p;p=V;try{return M()}finally{p=$}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,V){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var $=p;p=M;try{return V()}finally{p=$}},e.unstable_scheduleCallback=function(M,V,$){var _=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?_+$:_):$=_,M){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=$+ne,M={id:h++,callback:V,priorityLevel:M,startTime:$,expirationTime:ne,sortIndex:-1},$>_?(M.sortIndex=$,t(u,M),n(c)===null&&M===n(u)&&(w?(x(C),C=-1):w=!0,L(g,$-_))):(M.sortIndex=ne,t(c,M),j||m||(j=!0,K(S))),M},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(M){var V=p;return function(){var $=p;p=V;try{return M.apply(this,arguments)}finally{p=$}}}})(vj);xj.exports=vj;var $1=xj.exports;/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var _1=d,cn=$1;function Q(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var jj=new Set,_l={};function Fr(e,t){Ei(e,t),Ei(e+"Capture",t)}function Ei(e,t){for(_l[e]=t,e=0;e<t.length;e++)jj.add(t[e])}var ys=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fd=Object.prototype.hasOwnProperty,O1=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,yg={},wg={};function D1(e){return Fd.call(wg,e)?!0:Fd.call(yg,e)?!1:O1.test(e)?wg[e]=!0:(yg[e]=!0,!1)}function L1(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function F1(e,t,n,r){if(t===null||typeof t>"u"||L1(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function zt(e,t,n,r,i,l,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=l,this.removeEmptyString=o}var St={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){St[e]=new zt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];St[t]=new zt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){St[e]=new zt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){St[e]=new zt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){St[e]=new zt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){St[e]=new zt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){St[e]=new zt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){St[e]=new zt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){St[e]=new zt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Fh=/[\-:]([a-z])/g;function Uh(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Fh,Uh);St[t]=new zt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Fh,Uh);St[t]=new zt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Fh,Uh);St[t]=new zt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){St[e]=new zt(e,1,!1,e.toLowerCase(),null,!1,!1)});St.xlinkHref=new zt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){St[e]=new zt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Bh(e,t,n,r){var i=St.hasOwnProperty(t)?St[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(F1(t,n,i,r)&&(n=null),r||i===null?D1(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Rs=_1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Mo=Symbol.for("react.element"),ri=Symbol.for("react.portal"),ii=Symbol.for("react.fragment"),zh=Symbol.for("react.strict_mode"),Ud=Symbol.for("react.profiler"),yj=Symbol.for("react.provider"),wj=Symbol.for("react.context"),Wh=Symbol.for("react.forward_ref"),Bd=Symbol.for("react.suspense"),zd=Symbol.for("react.suspense_list"),Vh=Symbol.for("react.memo"),Ds=Symbol.for("react.lazy"),bj=Symbol.for("react.offscreen"),bg=Symbol.iterator;function al(e){return e===null||typeof e!="object"?null:(e=bg&&e[bg]||e["@@iterator"],typeof e=="function"?e:null)}var Ye=Object.assign,Nu;function yl(e){if(Nu===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Nu=t&&t[1]||""}return`
34
- `+Nu+e}var Cu=!1;function Eu(e,t){if(!e||Cu)return"";Cu=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(`
35
- `),l=r.stack.split(`
36
- `),o=i.length-1,a=l.length-1;1<=o&&0<=a&&i[o]!==l[a];)a--;for(;1<=o&&0<=a;o--,a--)if(i[o]!==l[a]){if(o!==1||a!==1)do if(o--,a--,0>a||i[o]!==l[a]){var c=`
37
- `+i[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=a);break}}}finally{Cu=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?yl(e):""}function U1(e){switch(e.tag){case 5:return yl(e.type);case 16:return yl("Lazy");case 13:return yl("Suspense");case 19:return yl("SuspenseList");case 0:case 2:case 15:return e=Eu(e.type,!1),e;case 11:return e=Eu(e.type.render,!1),e;case 1:return e=Eu(e.type,!0),e;default:return""}}function Wd(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ii:return"Fragment";case ri:return"Portal";case Ud:return"Profiler";case zh:return"StrictMode";case Bd:return"Suspense";case zd:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case wj:return(e.displayName||"Context")+".Consumer";case yj:return(e._context.displayName||"Context")+".Provider";case Wh:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Vh:return t=e.displayName||null,t!==null?t:Wd(e.type)||"Memo";case Ds:t=e._payload,e=e._init;try{return Wd(e(t))}catch{}}return null}function B1(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Wd(t);case 8:return t===zh?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function tr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function kj(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function z1(e){var t=kj(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,l=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,l.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function $o(e){e._valueTracker||(e._valueTracker=z1(e))}function Sj(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=kj(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ba(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Vd(e,t){var n=t.checked;return Ye({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function kg(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=tr(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Nj(e,t){t=t.checked,t!=null&&Bh(e,"checked",t,!1)}function Hd(e,t){Nj(e,t);var n=tr(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Kd(e,t.type,n):t.hasOwnProperty("defaultValue")&&Kd(e,t.type,tr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Sg(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Kd(e,t,n){(t!=="number"||Ba(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var wl=Array.isArray;function xi(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+tr(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Gd(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Q(91));return Ye({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ng(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Q(92));if(wl(n)){if(1<n.length)throw Error(Q(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:tr(n)}}function Cj(e,t){var n=tr(t.value),r=tr(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Cg(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Ej(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Yd(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Ej(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var _o,Aj=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(_o=_o||document.createElement("div"),_o.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=_o.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ol(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Sl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},W1=["Webkit","ms","Moz","O"];Object.keys(Sl).forEach(function(e){W1.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Sl[t]=Sl[e]})});function Rj(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Sl.hasOwnProperty(e)&&Sl[e]?(""+t).trim():t+"px"}function Tj(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Rj(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var V1=Ye({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function qd(e,t){if(t){if(V1[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Q(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Q(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Q(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Q(62))}}function Qd(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Jd=null;function Hh(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xd=null,vi=null,ji=null;function Eg(e){if(e=fo(e)){if(typeof Xd!="function")throw Error(Q(280));var t=e.stateNode;t&&(t=_c(t),Xd(e.stateNode,e.type,t))}}function Pj(e){vi?ji?ji.push(e):ji=[e]:vi=e}function Ij(){if(vi){var e=vi,t=ji;if(ji=vi=null,Eg(e),t)for(e=0;e<t.length;e++)Eg(t[e])}}function Mj(e,t){return e(t)}function $j(){}var Au=!1;function _j(e,t,n){if(Au)return e(t,n);Au=!0;try{return Mj(e,t,n)}finally{Au=!1,(vi!==null||ji!==null)&&($j(),Ij())}}function Dl(e,t){var n=e.stateNode;if(n===null)return null;var r=_c(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Q(231,t,typeof n));return n}var Zd=!1;if(ys)try{var cl={};Object.defineProperty(cl,"passive",{get:function(){Zd=!0}}),window.addEventListener("test",cl,cl),window.removeEventListener("test",cl,cl)}catch{Zd=!1}function H1(e,t,n,r,i,l,o,a,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(h){this.onError(h)}}var Nl=!1,za=null,Wa=!1,ef=null,K1={onError:function(e){Nl=!0,za=e}};function G1(e,t,n,r,i,l,o,a,c){Nl=!1,za=null,H1.apply(K1,arguments)}function Y1(e,t,n,r,i,l,o,a,c){if(G1.apply(this,arguments),Nl){if(Nl){var u=za;Nl=!1,za=null}else throw Error(Q(198));Wa||(Wa=!0,ef=u)}}function Ur(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Oj(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Ag(e){if(Ur(e)!==e)throw Error(Q(188))}function q1(e){var t=e.alternate;if(!t){if(t=Ur(e),t===null)throw Error(Q(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var l=i.alternate;if(l===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===l.child){for(l=i.child;l;){if(l===n)return Ag(i),e;if(l===r)return Ag(i),t;l=l.sibling}throw Error(Q(188))}if(n.return!==r.return)n=i,r=l;else{for(var o=!1,a=i.child;a;){if(a===n){o=!0,n=i,r=l;break}if(a===r){o=!0,r=i,n=l;break}a=a.sibling}if(!o){for(a=l.child;a;){if(a===n){o=!0,n=l,r=i;break}if(a===r){o=!0,r=l,n=i;break}a=a.sibling}if(!o)throw Error(Q(189))}}if(n.alternate!==r)throw Error(Q(190))}if(n.tag!==3)throw Error(Q(188));return n.stateNode.current===n?e:t}function Dj(e){return e=q1(e),e!==null?Lj(e):null}function Lj(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Lj(e);if(t!==null)return t;e=e.sibling}return null}var Fj=cn.unstable_scheduleCallback,Rg=cn.unstable_cancelCallback,Q1=cn.unstable_shouldYield,J1=cn.unstable_requestPaint,et=cn.unstable_now,X1=cn.unstable_getCurrentPriorityLevel,Kh=cn.unstable_ImmediatePriority,Uj=cn.unstable_UserBlockingPriority,Va=cn.unstable_NormalPriority,Z1=cn.unstable_LowPriority,Bj=cn.unstable_IdlePriority,Pc=null,Zn=null;function eN(e){if(Zn&&typeof Zn.onCommitFiberRoot=="function")try{Zn.onCommitFiberRoot(Pc,e,void 0,(e.current.flags&128)===128)}catch{}}var _n=Math.clz32?Math.clz32:sN,tN=Math.log,nN=Math.LN2;function sN(e){return e>>>=0,e===0?32:31-(tN(e)/nN|0)|0}var Oo=64,Do=4194304;function bl(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ha(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,l=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=bl(a):(l&=o,l!==0&&(r=bl(l)))}else o=n&~i,o!==0?r=bl(o):l!==0&&(r=bl(l));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,l=t&-t,i>=l||i===16&&(l&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-_n(t),i=1<<n,r|=e[n],t&=~i;return r}function rN(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function iN(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,l=e.pendingLanes;0<l;){var o=31-_n(l),a=1<<o,c=i[o];c===-1?(!(a&n)||a&r)&&(i[o]=rN(a,t)):c<=t&&(e.expiredLanes|=a),l&=~a}}function tf(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function zj(){var e=Oo;return Oo<<=1,!(Oo&4194240)&&(Oo=64),e}function Ru(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function co(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-_n(t),e[t]=n}function lN(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-_n(n),l=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~l}}function Gh(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-_n(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var Ie=0;function Wj(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Vj,Yh,Hj,Kj,Gj,nf=!1,Lo=[],Vs=null,Hs=null,Ks=null,Ll=new Map,Fl=new Map,Fs=[],oN="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Tg(e,t){switch(e){case"focusin":case"focusout":Vs=null;break;case"dragenter":case"dragleave":Hs=null;break;case"mouseover":case"mouseout":Ks=null;break;case"pointerover":case"pointerout":Ll.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fl.delete(t.pointerId)}}function ul(e,t,n,r,i,l){return e===null||e.nativeEvent!==l?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:l,targetContainers:[i]},t!==null&&(t=fo(t),t!==null&&Yh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function aN(e,t,n,r,i){switch(t){case"focusin":return Vs=ul(Vs,e,t,n,r,i),!0;case"dragenter":return Hs=ul(Hs,e,t,n,r,i),!0;case"mouseover":return Ks=ul(Ks,e,t,n,r,i),!0;case"pointerover":var l=i.pointerId;return Ll.set(l,ul(Ll.get(l)||null,e,t,n,r,i)),!0;case"gotpointercapture":return l=i.pointerId,Fl.set(l,ul(Fl.get(l)||null,e,t,n,r,i)),!0}return!1}function Yj(e){var t=yr(e.target);if(t!==null){var n=Ur(t);if(n!==null){if(t=n.tag,t===13){if(t=Oj(n),t!==null){e.blockedOn=t,Gj(e.priority,function(){Hj(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ya(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=sf(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Jd=r,n.target.dispatchEvent(r),Jd=null}else return t=fo(n),t!==null&&Yh(t),e.blockedOn=n,!1;t.shift()}return!0}function Pg(e,t,n){ya(e)&&n.delete(t)}function cN(){nf=!1,Vs!==null&&ya(Vs)&&(Vs=null),Hs!==null&&ya(Hs)&&(Hs=null),Ks!==null&&ya(Ks)&&(Ks=null),Ll.forEach(Pg),Fl.forEach(Pg)}function dl(e,t){e.blockedOn===t&&(e.blockedOn=null,nf||(nf=!0,cn.unstable_scheduleCallback(cn.unstable_NormalPriority,cN)))}function Ul(e){function t(i){return dl(i,e)}if(0<Lo.length){dl(Lo[0],e);for(var n=1;n<Lo.length;n++){var r=Lo[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Vs!==null&&dl(Vs,e),Hs!==null&&dl(Hs,e),Ks!==null&&dl(Ks,e),Ll.forEach(t),Fl.forEach(t),n=0;n<Fs.length;n++)r=Fs[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Fs.length&&(n=Fs[0],n.blockedOn===null);)Yj(n),n.blockedOn===null&&Fs.shift()}var yi=Rs.ReactCurrentBatchConfig,Ka=!0;function uN(e,t,n,r){var i=Ie,l=yi.transition;yi.transition=null;try{Ie=1,qh(e,t,n,r)}finally{Ie=i,yi.transition=l}}function dN(e,t,n,r){var i=Ie,l=yi.transition;yi.transition=null;try{Ie=4,qh(e,t,n,r)}finally{Ie=i,yi.transition=l}}function qh(e,t,n,r){if(Ka){var i=sf(e,t,n,r);if(i===null)Fu(e,t,r,Ga,n),Tg(e,r);else if(aN(i,e,t,n,r))r.stopPropagation();else if(Tg(e,r),t&4&&-1<oN.indexOf(e)){for(;i!==null;){var l=fo(i);if(l!==null&&Vj(l),l=sf(e,t,n,r),l===null&&Fu(e,t,r,Ga,n),l===i)break;i=l}i!==null&&r.stopPropagation()}else Fu(e,t,r,null,n)}}var Ga=null;function sf(e,t,n,r){if(Ga=null,e=Hh(r),e=yr(e),e!==null)if(t=Ur(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Oj(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Ga=e,null}function qj(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(X1()){case Kh:return 1;case Uj:return 4;case Va:case Z1:return 16;case Bj:return 536870912;default:return 16}default:return 16}}var Bs=null,Qh=null,wa=null;function Qj(){if(wa)return wa;var e,t=Qh,n=t.length,r,i="value"in Bs?Bs.value:Bs.textContent,l=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[l-r];r++);return wa=i.slice(e,1<r?1-r:void 0)}function ba(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Fo(){return!0}function Ig(){return!1}function fn(e){function t(n,r,i,l,o){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=l,this.target=o,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(l):l[a]);return this.isDefaultPrevented=(l.defaultPrevented!=null?l.defaultPrevented:l.returnValue===!1)?Fo:Ig,this.isPropagationStopped=Ig,this}return Ye(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Fo)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Fo)},persist:function(){},isPersistent:Fo}),t}var Gi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Jh=fn(Gi),uo=Ye({},Gi,{view:0,detail:0}),fN=fn(uo),Tu,Pu,fl,Ic=Ye({},uo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Xh,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==fl&&(fl&&e.type==="mousemove"?(Tu=e.screenX-fl.screenX,Pu=e.screenY-fl.screenY):Pu=Tu=0,fl=e),Tu)},movementY:function(e){return"movementY"in e?e.movementY:Pu}}),Mg=fn(Ic),hN=Ye({},Ic,{dataTransfer:0}),pN=fn(hN),mN=Ye({},uo,{relatedTarget:0}),Iu=fn(mN),gN=Ye({},Gi,{animationName:0,elapsedTime:0,pseudoElement:0}),xN=fn(gN),vN=Ye({},Gi,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),jN=fn(vN),yN=Ye({},Gi,{data:0}),$g=fn(yN),wN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},bN={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},kN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function SN(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=kN[e])?!!t[e]:!1}function Xh(){return SN}var NN=Ye({},uo,{key:function(e){if(e.key){var t=wN[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ba(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?bN[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Xh,charCode:function(e){return e.type==="keypress"?ba(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ba(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),CN=fn(NN),EN=Ye({},Ic,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_g=fn(EN),AN=Ye({},uo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Xh}),RN=fn(AN),TN=Ye({},Gi,{propertyName:0,elapsedTime:0,pseudoElement:0}),PN=fn(TN),IN=Ye({},Ic,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),MN=fn(IN),$N=[9,13,27,32],Zh=ys&&"CompositionEvent"in window,Cl=null;ys&&"documentMode"in document&&(Cl=document.documentMode);var _N=ys&&"TextEvent"in window&&!Cl,Jj=ys&&(!Zh||Cl&&8<Cl&&11>=Cl),Og=" ",Dg=!1;function Xj(e,t){switch(e){case"keyup":return $N.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zj(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var li=!1;function ON(e,t){switch(e){case"compositionend":return Zj(t);case"keypress":return t.which!==32?null:(Dg=!0,Og);case"textInput":return e=t.data,e===Og&&Dg?null:e;default:return null}}function DN(e,t){if(li)return e==="compositionend"||!Zh&&Xj(e,t)?(e=Qj(),wa=Qh=Bs=null,li=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Jj&&t.locale!=="ko"?null:t.data;default:return null}}var LN={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Lg(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!LN[e.type]:t==="textarea"}function ey(e,t,n,r){Pj(r),t=Ya(t,"onChange"),0<t.length&&(n=new Jh("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var El=null,Bl=null;function FN(e){dy(e,0)}function Mc(e){var t=ci(e);if(Sj(t))return e}function UN(e,t){if(e==="change")return t}var ty=!1;if(ys){var Mu;if(ys){var $u="oninput"in document;if(!$u){var Fg=document.createElement("div");Fg.setAttribute("oninput","return;"),$u=typeof Fg.oninput=="function"}Mu=$u}else Mu=!1;ty=Mu&&(!document.documentMode||9<document.documentMode)}function Ug(){El&&(El.detachEvent("onpropertychange",ny),Bl=El=null)}function ny(e){if(e.propertyName==="value"&&Mc(Bl)){var t=[];ey(t,Bl,e,Hh(e)),_j(FN,t)}}function BN(e,t,n){e==="focusin"?(Ug(),El=t,Bl=n,El.attachEvent("onpropertychange",ny)):e==="focusout"&&Ug()}function zN(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Mc(Bl)}function WN(e,t){if(e==="click")return Mc(t)}function VN(e,t){if(e==="input"||e==="change")return Mc(t)}function HN(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Dn=typeof Object.is=="function"?Object.is:HN;function zl(e,t){if(Dn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Fd.call(t,i)||!Dn(e[i],t[i]))return!1}return!0}function Bg(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function zg(e,t){var n=Bg(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Bg(n)}}function sy(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?sy(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ry(){for(var e=window,t=Ba();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ba(e.document)}return t}function ep(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function KN(e){var t=ry(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&sy(n.ownerDocument.documentElement,n)){if(r!==null&&ep(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,l=Math.min(r.start,i);r=r.end===void 0?l:Math.min(r.end,i),!e.extend&&l>r&&(i=r,r=l,l=i),i=zg(n,l);var o=zg(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),l>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var GN=ys&&"documentMode"in document&&11>=document.documentMode,oi=null,rf=null,Al=null,lf=!1;function Wg(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;lf||oi==null||oi!==Ba(r)||(r=oi,"selectionStart"in r&&ep(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Al&&zl(Al,r)||(Al=r,r=Ya(rf,"onSelect"),0<r.length&&(t=new Jh("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=oi)))}function Uo(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ai={animationend:Uo("Animation","AnimationEnd"),animationiteration:Uo("Animation","AnimationIteration"),animationstart:Uo("Animation","AnimationStart"),transitionend:Uo("Transition","TransitionEnd")},_u={},iy={};ys&&(iy=document.createElement("div").style,"AnimationEvent"in window||(delete ai.animationend.animation,delete ai.animationiteration.animation,delete ai.animationstart.animation),"TransitionEvent"in window||delete ai.transitionend.transition);function $c(e){if(_u[e])return _u[e];if(!ai[e])return e;var t=ai[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in iy)return _u[e]=t[n];return e}var ly=$c("animationend"),oy=$c("animationiteration"),ay=$c("animationstart"),cy=$c("transitionend"),uy=new Map,Vg="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function or(e,t){uy.set(e,t),Fr(t,[e])}for(var Ou=0;Ou<Vg.length;Ou++){var Du=Vg[Ou],YN=Du.toLowerCase(),qN=Du[0].toUpperCase()+Du.slice(1);or(YN,"on"+qN)}or(ly,"onAnimationEnd");or(oy,"onAnimationIteration");or(ay,"onAnimationStart");or("dblclick","onDoubleClick");or("focusin","onFocus");or("focusout","onBlur");or(cy,"onTransitionEnd");Ei("onMouseEnter",["mouseout","mouseover"]);Ei("onMouseLeave",["mouseout","mouseover"]);Ei("onPointerEnter",["pointerout","pointerover"]);Ei("onPointerLeave",["pointerout","pointerover"]);Fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Fr("onBeforeInput",["compositionend","keypress","textInput","paste"]);Fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Fr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var kl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),QN=new Set("cancel close invalid load scroll toggle".split(" ").concat(kl));function Hg(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Y1(r,t,void 0,e),e.currentTarget=null}function dy(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var l=void 0;if(t)for(var o=r.length-1;0<=o;o--){var a=r[o],c=a.instance,u=a.currentTarget;if(a=a.listener,c!==l&&i.isPropagationStopped())break e;Hg(i,a,u),l=c}else for(o=0;o<r.length;o++){if(a=r[o],c=a.instance,u=a.currentTarget,a=a.listener,c!==l&&i.isPropagationStopped())break e;Hg(i,a,u),l=c}}}if(Wa)throw e=ef,Wa=!1,ef=null,e}function Ue(e,t){var n=t[df];n===void 0&&(n=t[df]=new Set);var r=e+"__bubble";n.has(r)||(fy(t,e,2,!1),n.add(r))}function Lu(e,t,n){var r=0;t&&(r|=4),fy(n,e,r,t)}var Bo="_reactListening"+Math.random().toString(36).slice(2);function Wl(e){if(!e[Bo]){e[Bo]=!0,jj.forEach(function(n){n!=="selectionchange"&&(QN.has(n)||Lu(n,!1,e),Lu(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Bo]||(t[Bo]=!0,Lu("selectionchange",!1,t))}}function fy(e,t,n,r){switch(qj(t)){case 1:var i=uN;break;case 4:i=dN;break;default:i=qh}n=i.bind(null,t,n,e),i=void 0,!Zd||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Fu(e,t,n,r,i){var l=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;o=o.return}for(;a!==null;){if(o=yr(a),o===null)return;if(c=o.tag,c===5||c===6){r=l=o;continue e}a=a.parentNode}}r=r.return}_j(function(){var u=l,h=Hh(n),f=[];e:{var p=uy.get(e);if(p!==void 0){var m=Jh,j=e;switch(e){case"keypress":if(ba(n)===0)break e;case"keydown":case"keyup":m=CN;break;case"focusin":j="focus",m=Iu;break;case"focusout":j="blur",m=Iu;break;case"beforeblur":case"afterblur":m=Iu;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=Mg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=pN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=RN;break;case ly:case oy:case ay:m=xN;break;case cy:m=PN;break;case"scroll":m=fN;break;case"wheel":m=MN;break;case"copy":case"cut":case"paste":m=jN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=_g}var w=(t&4)!==0,b=!w&&e==="scroll",x=w?p!==null?p+"Capture":null:p;w=[];for(var v=u,y;v!==null;){y=v;var g=y.stateNode;if(y.tag===5&&g!==null&&(y=g,x!==null&&(g=Dl(v,x),g!=null&&w.push(Vl(v,g,y)))),b)break;v=v.return}0<w.length&&(p=new m(p,j,null,n,h),f.push({event:p,listeners:w}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&n!==Jd&&(j=n.relatedTarget||n.fromElement)&&(yr(j)||j[ws]))break e;if((m||p)&&(p=h.window===h?h:(p=h.ownerDocument)?p.defaultView||p.parentWindow:window,m?(j=n.relatedTarget||n.toElement,m=u,j=j?yr(j):null,j!==null&&(b=Ur(j),j!==b||j.tag!==5&&j.tag!==6)&&(j=null)):(m=null,j=u),m!==j)){if(w=Mg,g="onMouseLeave",x="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(w=_g,g="onPointerLeave",x="onPointerEnter",v="pointer"),b=m==null?p:ci(m),y=j==null?p:ci(j),p=new w(g,v+"leave",m,n,h),p.target=b,p.relatedTarget=y,g=null,yr(h)===u&&(w=new w(x,v+"enter",j,n,h),w.target=y,w.relatedTarget=b,g=w),b=g,m&&j)t:{for(w=m,x=j,v=0,y=w;y;y=Jr(y))v++;for(y=0,g=x;g;g=Jr(g))y++;for(;0<v-y;)w=Jr(w),v--;for(;0<y-v;)x=Jr(x),y--;for(;v--;){if(w===x||x!==null&&w===x.alternate)break t;w=Jr(w),x=Jr(x)}w=null}else w=null;m!==null&&Kg(f,p,m,w,!1),j!==null&&b!==null&&Kg(f,b,j,w,!0)}}e:{if(p=u?ci(u):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var S=UN;else if(Lg(p))if(ty)S=VN;else{S=zN;var k=BN}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(S=WN);if(S&&(S=S(e,u))){ey(f,S,n,h);break e}k&&k(e,p,u),e==="focusout"&&(k=p._wrapperState)&&k.controlled&&p.type==="number"&&Kd(p,"number",p.value)}switch(k=u?ci(u):window,e){case"focusin":(Lg(k)||k.contentEditable==="true")&&(oi=k,rf=u,Al=null);break;case"focusout":Al=rf=oi=null;break;case"mousedown":lf=!0;break;case"contextmenu":case"mouseup":case"dragend":lf=!1,Wg(f,n,h);break;case"selectionchange":if(GN)break;case"keydown":case"keyup":Wg(f,n,h)}var N;if(Zh)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else li?Xj(e,n)&&(C="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(Jj&&n.locale!=="ko"&&(li||C!=="onCompositionStart"?C==="onCompositionEnd"&&li&&(N=Qj()):(Bs=h,Qh="value"in Bs?Bs.value:Bs.textContent,li=!0)),k=Ya(u,C),0<k.length&&(C=new $g(C,e,null,n,h),f.push({event:C,listeners:k}),N?C.data=N:(N=Zj(n),N!==null&&(C.data=N)))),(N=_N?ON(e,n):DN(e,n))&&(u=Ya(u,"onBeforeInput"),0<u.length&&(h=new $g("onBeforeInput","beforeinput",null,n,h),f.push({event:h,listeners:u}),h.data=N))}dy(f,t)})}function Vl(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ya(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,l=i.stateNode;i.tag===5&&l!==null&&(i=l,l=Dl(e,n),l!=null&&r.unshift(Vl(e,l,i)),l=Dl(e,t),l!=null&&r.push(Vl(e,l,i))),e=e.return}return r}function Jr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Kg(e,t,n,r,i){for(var l=t._reactName,o=[];n!==null&&n!==r;){var a=n,c=a.alternate,u=a.stateNode;if(c!==null&&c===r)break;a.tag===5&&u!==null&&(a=u,i?(c=Dl(n,l),c!=null&&o.unshift(Vl(n,c,a))):i||(c=Dl(n,l),c!=null&&o.push(Vl(n,c,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var JN=/\r\n?/g,XN=/\u0000|\uFFFD/g;function Gg(e){return(typeof e=="string"?e:""+e).replace(JN,`
38
- `).replace(XN,"")}function zo(e,t,n){if(t=Gg(t),Gg(e)!==t&&n)throw Error(Q(425))}function qa(){}var of=null,af=null;function cf(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var uf=typeof setTimeout=="function"?setTimeout:void 0,ZN=typeof clearTimeout=="function"?clearTimeout:void 0,Yg=typeof Promise=="function"?Promise:void 0,eC=typeof queueMicrotask=="function"?queueMicrotask:typeof Yg<"u"?function(e){return Yg.resolve(null).then(e).catch(tC)}:uf;function tC(e){setTimeout(function(){throw e})}function Uu(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),Ul(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);Ul(t)}function Gs(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function qg(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Yi=Math.random().toString(36).slice(2),qn="__reactFiber$"+Yi,Hl="__reactProps$"+Yi,ws="__reactContainer$"+Yi,df="__reactEvents$"+Yi,nC="__reactListeners$"+Yi,sC="__reactHandles$"+Yi;function yr(e){var t=e[qn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ws]||n[qn]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=qg(e);e!==null;){if(n=e[qn])return n;e=qg(e)}return t}e=n,n=e.parentNode}return null}function fo(e){return e=e[qn]||e[ws],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ci(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Q(33))}function _c(e){return e[Hl]||null}var ff=[],ui=-1;function ar(e){return{current:e}}function Be(e){0>ui||(e.current=ff[ui],ff[ui]=null,ui--)}function Le(e,t){ui++,ff[ui]=e.current,e.current=t}var nr={},$t=ar(nr),Gt=ar(!1),Er=nr;function Ai(e,t){var n=e.type.contextTypes;if(!n)return nr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},l;for(l in n)i[l]=t[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Yt(e){return e=e.childContextTypes,e!=null}function Qa(){Be(Gt),Be($t)}function Qg(e,t,n){if($t.current!==nr)throw Error(Q(168));Le($t,t),Le(Gt,n)}function hy(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(Q(108,B1(e)||"Unknown",i));return Ye({},n,r)}function Ja(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||nr,Er=$t.current,Le($t,e),Le(Gt,Gt.current),!0}function Jg(e,t,n){var r=e.stateNode;if(!r)throw Error(Q(169));n?(e=hy(e,t,Er),r.__reactInternalMemoizedMergedChildContext=e,Be(Gt),Be($t),Le($t,e)):Be(Gt),Le(Gt,n)}var hs=null,Oc=!1,Bu=!1;function py(e){hs===null?hs=[e]:hs.push(e)}function rC(e){Oc=!0,py(e)}function cr(){if(!Bu&&hs!==null){Bu=!0;var e=0,t=Ie;try{var n=hs;for(Ie=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}hs=null,Oc=!1}catch(i){throw hs!==null&&(hs=hs.slice(e+1)),Fj(Kh,cr),i}finally{Ie=t,Bu=!1}}return null}var di=[],fi=0,Xa=null,Za=0,vn=[],jn=0,Ar=null,ps=1,ms="";function vr(e,t){di[fi++]=Za,di[fi++]=Xa,Xa=e,Za=t}function my(e,t,n){vn[jn++]=ps,vn[jn++]=ms,vn[jn++]=Ar,Ar=e;var r=ps;e=ms;var i=32-_n(r)-1;r&=~(1<<i),n+=1;var l=32-_n(t)+i;if(30<l){var o=i-i%5;l=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ps=1<<32-_n(t)+i|n<<i|r,ms=l+e}else ps=1<<l|n<<i|r,ms=e}function tp(e){e.return!==null&&(vr(e,1),my(e,1,0))}function np(e){for(;e===Xa;)Xa=di[--fi],di[fi]=null,Za=di[--fi],di[fi]=null;for(;e===Ar;)Ar=vn[--jn],vn[jn]=null,ms=vn[--jn],vn[jn]=null,ps=vn[--jn],vn[jn]=null}var an=null,ln=null,We=!1,Mn=null;function gy(e,t){var n=wn(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Xg(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,an=e,ln=Gs(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,an=e,ln=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ar!==null?{id:ps,overflow:ms}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=wn(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,an=e,ln=null,!0):!1;default:return!1}}function hf(e){return(e.mode&1)!==0&&(e.flags&128)===0}function pf(e){if(We){var t=ln;if(t){var n=t;if(!Xg(e,t)){if(hf(e))throw Error(Q(418));t=Gs(n.nextSibling);var r=an;t&&Xg(e,t)?gy(r,n):(e.flags=e.flags&-4097|2,We=!1,an=e)}}else{if(hf(e))throw Error(Q(418));e.flags=e.flags&-4097|2,We=!1,an=e}}}function Zg(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;an=e}function Wo(e){if(e!==an)return!1;if(!We)return Zg(e),We=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!cf(e.type,e.memoizedProps)),t&&(t=ln)){if(hf(e))throw xy(),Error(Q(418));for(;t;)gy(e,t),t=Gs(t.nextSibling)}if(Zg(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Q(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ln=Gs(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ln=null}}else ln=an?Gs(e.stateNode.nextSibling):null;return!0}function xy(){for(var e=ln;e;)e=Gs(e.nextSibling)}function Ri(){ln=an=null,We=!1}function sp(e){Mn===null?Mn=[e]:Mn.push(e)}var iC=Rs.ReactCurrentBatchConfig;function hl(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Q(309));var r=n.stateNode}if(!r)throw Error(Q(147,e));var i=r,l=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===l?t.ref:(t=function(o){var a=i.refs;o===null?delete a[l]:a[l]=o},t._stringRef=l,t)}if(typeof e!="string")throw Error(Q(284));if(!n._owner)throw Error(Q(290,e))}return e}function Vo(e,t){throw e=Object.prototype.toString.call(t),Error(Q(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ex(e){var t=e._init;return t(e._payload)}function vy(e){function t(x,v){if(e){var y=x.deletions;y===null?(x.deletions=[v],x.flags|=16):y.push(v)}}function n(x,v){if(!e)return null;for(;v!==null;)t(x,v),v=v.sibling;return null}function r(x,v){for(x=new Map;v!==null;)v.key!==null?x.set(v.key,v):x.set(v.index,v),v=v.sibling;return x}function i(x,v){return x=Js(x,v),x.index=0,x.sibling=null,x}function l(x,v,y){return x.index=y,e?(y=x.alternate,y!==null?(y=y.index,y<v?(x.flags|=2,v):y):(x.flags|=2,v)):(x.flags|=1048576,v)}function o(x){return e&&x.alternate===null&&(x.flags|=2),x}function a(x,v,y,g){return v===null||v.tag!==6?(v=Yu(y,x.mode,g),v.return=x,v):(v=i(v,y),v.return=x,v)}function c(x,v,y,g){var S=y.type;return S===ii?h(x,v,y.props.children,g,y.key):v!==null&&(v.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Ds&&ex(S)===v.type)?(g=i(v,y.props),g.ref=hl(x,v,y),g.return=x,g):(g=Ra(y.type,y.key,y.props,null,x.mode,g),g.ref=hl(x,v,y),g.return=x,g)}function u(x,v,y,g){return v===null||v.tag!==4||v.stateNode.containerInfo!==y.containerInfo||v.stateNode.implementation!==y.implementation?(v=qu(y,x.mode,g),v.return=x,v):(v=i(v,y.children||[]),v.return=x,v)}function h(x,v,y,g,S){return v===null||v.tag!==7?(v=Sr(y,x.mode,g,S),v.return=x,v):(v=i(v,y),v.return=x,v)}function f(x,v,y){if(typeof v=="string"&&v!==""||typeof v=="number")return v=Yu(""+v,x.mode,y),v.return=x,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Mo:return y=Ra(v.type,v.key,v.props,null,x.mode,y),y.ref=hl(x,null,v),y.return=x,y;case ri:return v=qu(v,x.mode,y),v.return=x,v;case Ds:var g=v._init;return f(x,g(v._payload),y)}if(wl(v)||al(v))return v=Sr(v,x.mode,y,null),v.return=x,v;Vo(x,v)}return null}function p(x,v,y,g){var S=v!==null?v.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return S!==null?null:a(x,v,""+y,g);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Mo:return y.key===S?c(x,v,y,g):null;case ri:return y.key===S?u(x,v,y,g):null;case Ds:return S=y._init,p(x,v,S(y._payload),g)}if(wl(y)||al(y))return S!==null?null:h(x,v,y,g,null);Vo(x,y)}return null}function m(x,v,y,g,S){if(typeof g=="string"&&g!==""||typeof g=="number")return x=x.get(y)||null,a(v,x,""+g,S);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Mo:return x=x.get(g.key===null?y:g.key)||null,c(v,x,g,S);case ri:return x=x.get(g.key===null?y:g.key)||null,u(v,x,g,S);case Ds:var k=g._init;return m(x,v,y,k(g._payload),S)}if(wl(g)||al(g))return x=x.get(y)||null,h(v,x,g,S,null);Vo(v,g)}return null}function j(x,v,y,g){for(var S=null,k=null,N=v,C=v=0,T=null;N!==null&&C<y.length;C++){N.index>C?(T=N,N=null):T=N.sibling;var E=p(x,N,y[C],g);if(E===null){N===null&&(N=T);break}e&&N&&E.alternate===null&&t(x,N),v=l(E,v,C),k===null?S=E:k.sibling=E,k=E,N=T}if(C===y.length)return n(x,N),We&&vr(x,C),S;if(N===null){for(;C<y.length;C++)N=f(x,y[C],g),N!==null&&(v=l(N,v,C),k===null?S=N:k.sibling=N,k=N);return We&&vr(x,C),S}for(N=r(x,N);C<y.length;C++)T=m(N,x,C,y[C],g),T!==null&&(e&&T.alternate!==null&&N.delete(T.key===null?C:T.key),v=l(T,v,C),k===null?S=T:k.sibling=T,k=T);return e&&N.forEach(function(U){return t(x,U)}),We&&vr(x,C),S}function w(x,v,y,g){var S=al(y);if(typeof S!="function")throw Error(Q(150));if(y=S.call(y),y==null)throw Error(Q(151));for(var k=S=null,N=v,C=v=0,T=null,E=y.next();N!==null&&!E.done;C++,E=y.next()){N.index>C?(T=N,N=null):T=N.sibling;var U=p(x,N,E.value,g);if(U===null){N===null&&(N=T);break}e&&N&&U.alternate===null&&t(x,N),v=l(U,v,C),k===null?S=U:k.sibling=U,k=U,N=T}if(E.done)return n(x,N),We&&vr(x,C),S;if(N===null){for(;!E.done;C++,E=y.next())E=f(x,E.value,g),E!==null&&(v=l(E,v,C),k===null?S=E:k.sibling=E,k=E);return We&&vr(x,C),S}for(N=r(x,N);!E.done;C++,E=y.next())E=m(N,x,C,E.value,g),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?C:E.key),v=l(E,v,C),k===null?S=E:k.sibling=E,k=E);return e&&N.forEach(function(H){return t(x,H)}),We&&vr(x,C),S}function b(x,v,y,g){if(typeof y=="object"&&y!==null&&y.type===ii&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Mo:e:{for(var S=y.key,k=v;k!==null;){if(k.key===S){if(S=y.type,S===ii){if(k.tag===7){n(x,k.sibling),v=i(k,y.props.children),v.return=x,x=v;break e}}else if(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Ds&&ex(S)===k.type){n(x,k.sibling),v=i(k,y.props),v.ref=hl(x,k,y),v.return=x,x=v;break e}n(x,k);break}else t(x,k);k=k.sibling}y.type===ii?(v=Sr(y.props.children,x.mode,g,y.key),v.return=x,x=v):(g=Ra(y.type,y.key,y.props,null,x.mode,g),g.ref=hl(x,v,y),g.return=x,x=g)}return o(x);case ri:e:{for(k=y.key;v!==null;){if(v.key===k)if(v.tag===4&&v.stateNode.containerInfo===y.containerInfo&&v.stateNode.implementation===y.implementation){n(x,v.sibling),v=i(v,y.children||[]),v.return=x,x=v;break e}else{n(x,v);break}else t(x,v);v=v.sibling}v=qu(y,x.mode,g),v.return=x,x=v}return o(x);case Ds:return k=y._init,b(x,v,k(y._payload),g)}if(wl(y))return j(x,v,y,g);if(al(y))return w(x,v,y,g);Vo(x,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,v!==null&&v.tag===6?(n(x,v.sibling),v=i(v,y),v.return=x,x=v):(n(x,v),v=Yu(y,x.mode,g),v.return=x,x=v),o(x)):n(x,v)}return b}var Ti=vy(!0),jy=vy(!1),ec=ar(null),tc=null,hi=null,rp=null;function ip(){rp=hi=tc=null}function lp(e){var t=ec.current;Be(ec),e._currentValue=t}function mf(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function wi(e,t){tc=e,rp=hi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Kt=!0),e.firstContext=null)}function Sn(e){var t=e._currentValue;if(rp!==e)if(e={context:e,memoizedValue:t,next:null},hi===null){if(tc===null)throw Error(Q(308));hi=e,tc.dependencies={lanes:0,firstContext:e}}else hi=hi.next=e;return t}var wr=null;function op(e){wr===null?wr=[e]:wr.push(e)}function yy(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,op(t)):(n.next=i.next,i.next=n),t.interleaved=n,bs(e,r)}function bs(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ls=!1;function ap(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wy(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function gs(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ys(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ae&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,bs(e,n)}return i=r.interleaved,i===null?(t.next=t,op(r)):(t.next=i.next,i.next=t),r.interleaved=t,bs(e,n)}function ka(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Gh(e,n)}}function tx(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?i=l=o:l=l.next=o,n=n.next}while(n!==null);l===null?i=l=t:l=l.next=t}else i=l=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:l,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function nc(e,t,n,r){var i=e.updateQueue;Ls=!1;var l=i.firstBaseUpdate,o=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var c=a,u=c.next;c.next=null,o===null?l=u:o.next=u,o=c;var h=e.alternate;h!==null&&(h=h.updateQueue,a=h.lastBaseUpdate,a!==o&&(a===null?h.firstBaseUpdate=u:a.next=u,h.lastBaseUpdate=c))}if(l!==null){var f=i.baseState;o=0,h=u=c=null,a=l;do{var p=a.lane,m=a.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:m,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var j=e,w=a;switch(p=t,m=n,w.tag){case 1:if(j=w.payload,typeof j=="function"){f=j.call(m,f,p);break e}f=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=w.payload,p=typeof j=="function"?j.call(m,f,p):j,p==null)break e;f=Ye({},f,p);break e;case 2:Ls=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,p=i.effects,p===null?i.effects=[a]:p.push(a))}else m={eventTime:m,lane:p,tag:a.tag,payload:a.payload,callback:a.callback,next:null},h===null?(u=h=m,c=f):h=h.next=m,o|=p;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;p=a,a=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(!0);if(h===null&&(c=f),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=h,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else l===null&&(i.shared.lanes=0);Tr|=o,e.lanes=o,e.memoizedState=f}}function nx(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(Q(191,i));i.call(r)}}}var ho={},es=ar(ho),Kl=ar(ho),Gl=ar(ho);function br(e){if(e===ho)throw Error(Q(174));return e}function cp(e,t){switch(Le(Gl,t),Le(Kl,e),Le(es,ho),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Yd(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Yd(t,e)}Be(es),Le(es,t)}function Pi(){Be(es),Be(Kl),Be(Gl)}function by(e){br(Gl.current);var t=br(es.current),n=Yd(t,e.type);t!==n&&(Le(Kl,e),Le(es,n))}function up(e){Kl.current===e&&(Be(es),Be(Kl))}var He=ar(0);function sc(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var zu=[];function dp(){for(var e=0;e<zu.length;e++)zu[e]._workInProgressVersionPrimary=null;zu.length=0}var Sa=Rs.ReactCurrentDispatcher,Wu=Rs.ReactCurrentBatchConfig,Rr=0,Ke=null,lt=null,ut=null,rc=!1,Rl=!1,Yl=0,lC=0;function At(){throw Error(Q(321))}function fp(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Dn(e[n],t[n]))return!1;return!0}function hp(e,t,n,r,i,l){if(Rr=l,Ke=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Sa.current=e===null||e.memoizedState===null?uC:dC,e=n(r,i),Rl){l=0;do{if(Rl=!1,Yl=0,25<=l)throw Error(Q(301));l+=1,ut=lt=null,t.updateQueue=null,Sa.current=fC,e=n(r,i)}while(Rl)}if(Sa.current=ic,t=lt!==null&&lt.next!==null,Rr=0,ut=lt=Ke=null,rc=!1,t)throw Error(Q(300));return e}function pp(){var e=Yl!==0;return Yl=0,e}function Yn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ut===null?Ke.memoizedState=ut=e:ut=ut.next=e,ut}function Nn(){if(lt===null){var e=Ke.alternate;e=e!==null?e.memoizedState:null}else e=lt.next;var t=ut===null?Ke.memoizedState:ut.next;if(t!==null)ut=t,lt=e;else{if(e===null)throw Error(Q(310));lt=e,e={memoizedState:lt.memoizedState,baseState:lt.baseState,baseQueue:lt.baseQueue,queue:lt.queue,next:null},ut===null?Ke.memoizedState=ut=e:ut=ut.next=e}return ut}function ql(e,t){return typeof t=="function"?t(e):t}function Vu(e){var t=Nn(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=lt,i=r.baseQueue,l=n.pending;if(l!==null){if(i!==null){var o=i.next;i.next=l.next,l.next=o}r.baseQueue=i=l,n.pending=null}if(i!==null){l=i.next,r=r.baseState;var a=o=null,c=null,u=l;do{var h=u.lane;if((Rr&h)===h)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:h,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(a=c=f,o=r):c=c.next=f,Ke.lanes|=h,Tr|=h}u=u.next}while(u!==null&&u!==l);c===null?o=r:c.next=a,Dn(r,t.memoizedState)||(Kt=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do l=i.lane,Ke.lanes|=l,Tr|=l,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Hu(e){var t=Nn(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,l=t.memoizedState;if(i!==null){n.pending=null;var o=i=i.next;do l=e(l,o.action),o=o.next;while(o!==i);Dn(l,t.memoizedState)||(Kt=!0),t.memoizedState=l,t.baseQueue===null&&(t.baseState=l),n.lastRenderedState=l}return[l,r]}function ky(){}function Sy(e,t){var n=Ke,r=Nn(),i=t(),l=!Dn(r.memoizedState,i);if(l&&(r.memoizedState=i,Kt=!0),r=r.queue,mp(Ey.bind(null,n,r,e),[e]),r.getSnapshot!==t||l||ut!==null&&ut.memoizedState.tag&1){if(n.flags|=2048,Ql(9,Cy.bind(null,n,r,i,t),void 0,null),pt===null)throw Error(Q(349));Rr&30||Ny(n,t,i)}return i}function Ny(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ke.updateQueue,t===null?(t={lastEffect:null,stores:null},Ke.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Cy(e,t,n,r){t.value=n,t.getSnapshot=r,Ay(t)&&Ry(e)}function Ey(e,t,n){return n(function(){Ay(t)&&Ry(e)})}function Ay(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Dn(e,n)}catch{return!0}}function Ry(e){var t=bs(e,1);t!==null&&On(t,e,1,-1)}function sx(e){var t=Yn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ql,lastRenderedState:e},t.queue=e,e=e.dispatch=cC.bind(null,Ke,e),[t.memoizedState,e]}function Ql(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ke.updateQueue,t===null?(t={lastEffect:null,stores:null},Ke.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Ty(){return Nn().memoizedState}function Na(e,t,n,r){var i=Yn();Ke.flags|=e,i.memoizedState=Ql(1|t,n,void 0,r===void 0?null:r)}function Dc(e,t,n,r){var i=Nn();r=r===void 0?null:r;var l=void 0;if(lt!==null){var o=lt.memoizedState;if(l=o.destroy,r!==null&&fp(r,o.deps)){i.memoizedState=Ql(t,n,l,r);return}}Ke.flags|=e,i.memoizedState=Ql(1|t,n,l,r)}function rx(e,t){return Na(8390656,8,e,t)}function mp(e,t){return Dc(2048,8,e,t)}function Py(e,t){return Dc(4,2,e,t)}function Iy(e,t){return Dc(4,4,e,t)}function My(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function $y(e,t,n){return n=n!=null?n.concat([e]):null,Dc(4,4,My.bind(null,t,e),n)}function gp(){}function _y(e,t){var n=Nn();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&fp(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Oy(e,t){var n=Nn();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&fp(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Dy(e,t,n){return Rr&21?(Dn(n,t)||(n=zj(),Ke.lanes|=n,Tr|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Kt=!0),e.memoizedState=n)}function oC(e,t){var n=Ie;Ie=n!==0&&4>n?n:4,e(!0);var r=Wu.transition;Wu.transition={};try{e(!1),t()}finally{Ie=n,Wu.transition=r}}function Ly(){return Nn().memoizedState}function aC(e,t,n){var r=Qs(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Fy(e))Uy(t,n);else if(n=yy(e,t,n,r),n!==null){var i=Ft();On(n,e,r,i),By(n,t,r)}}function cC(e,t,n){var r=Qs(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Fy(e))Uy(t,i);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=t.lastRenderedReducer,l!==null))try{var o=t.lastRenderedState,a=l(o,n);if(i.hasEagerState=!0,i.eagerState=a,Dn(a,o)){var c=t.interleaved;c===null?(i.next=i,op(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=yy(e,t,i,r),n!==null&&(i=Ft(),On(n,e,r,i),By(n,t,r))}}function Fy(e){var t=e.alternate;return e===Ke||t!==null&&t===Ke}function Uy(e,t){Rl=rc=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function By(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Gh(e,n)}}var ic={readContext:Sn,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useInsertionEffect:At,useLayoutEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useMutableSource:At,useSyncExternalStore:At,useId:At,unstable_isNewReconciler:!1},uC={readContext:Sn,useCallback:function(e,t){return Yn().memoizedState=[e,t===void 0?null:t],e},useContext:Sn,useEffect:rx,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Na(4194308,4,My.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Na(4194308,4,e,t)},useInsertionEffect:function(e,t){return Na(4,2,e,t)},useMemo:function(e,t){var n=Yn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Yn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=aC.bind(null,Ke,e),[r.memoizedState,e]},useRef:function(e){var t=Yn();return e={current:e},t.memoizedState=e},useState:sx,useDebugValue:gp,useDeferredValue:function(e){return Yn().memoizedState=e},useTransition:function(){var e=sx(!1),t=e[0];return e=oC.bind(null,e[1]),Yn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ke,i=Yn();if(We){if(n===void 0)throw Error(Q(407));n=n()}else{if(n=t(),pt===null)throw Error(Q(349));Rr&30||Ny(r,t,n)}i.memoizedState=n;var l={value:n,getSnapshot:t};return i.queue=l,rx(Ey.bind(null,r,l,e),[e]),r.flags|=2048,Ql(9,Cy.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=Yn(),t=pt.identifierPrefix;if(We){var n=ms,r=ps;n=(r&~(1<<32-_n(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Yl++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=lC++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},dC={readContext:Sn,useCallback:_y,useContext:Sn,useEffect:mp,useImperativeHandle:$y,useInsertionEffect:Py,useLayoutEffect:Iy,useMemo:Oy,useReducer:Vu,useRef:Ty,useState:function(){return Vu(ql)},useDebugValue:gp,useDeferredValue:function(e){var t=Nn();return Dy(t,lt.memoizedState,e)},useTransition:function(){var e=Vu(ql)[0],t=Nn().memoizedState;return[e,t]},useMutableSource:ky,useSyncExternalStore:Sy,useId:Ly,unstable_isNewReconciler:!1},fC={readContext:Sn,useCallback:_y,useContext:Sn,useEffect:mp,useImperativeHandle:$y,useInsertionEffect:Py,useLayoutEffect:Iy,useMemo:Oy,useReducer:Hu,useRef:Ty,useState:function(){return Hu(ql)},useDebugValue:gp,useDeferredValue:function(e){var t=Nn();return lt===null?t.memoizedState=e:Dy(t,lt.memoizedState,e)},useTransition:function(){var e=Hu(ql)[0],t=Nn().memoizedState;return[e,t]},useMutableSource:ky,useSyncExternalStore:Sy,useId:Ly,unstable_isNewReconciler:!1};function Pn(e,t){if(e&&e.defaultProps){t=Ye({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function gf(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ye({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Lc={isMounted:function(e){return(e=e._reactInternals)?Ur(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ft(),i=Qs(e),l=gs(r,i);l.payload=t,n!=null&&(l.callback=n),t=Ys(e,l,i),t!==null&&(On(t,e,i,r),ka(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ft(),i=Qs(e),l=gs(r,i);l.tag=1,l.payload=t,n!=null&&(l.callback=n),t=Ys(e,l,i),t!==null&&(On(t,e,i,r),ka(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ft(),r=Qs(e),i=gs(n,r);i.tag=2,t!=null&&(i.callback=t),t=Ys(e,i,r),t!==null&&(On(t,e,r,n),ka(t,e,r))}};function ix(e,t,n,r,i,l,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,l,o):t.prototype&&t.prototype.isPureReactComponent?!zl(n,r)||!zl(i,l):!0}function zy(e,t,n){var r=!1,i=nr,l=t.contextType;return typeof l=="object"&&l!==null?l=Sn(l):(i=Yt(t)?Er:$t.current,r=t.contextTypes,l=(r=r!=null)?Ai(e,i):nr),t=new t(n,l),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Lc,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=l),t}function lx(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Lc.enqueueReplaceState(t,t.state,null)}function xf(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},ap(e);var l=t.contextType;typeof l=="object"&&l!==null?i.context=Sn(l):(l=Yt(t)?Er:$t.current,i.context=Ai(e,l)),i.state=e.memoizedState,l=t.getDerivedStateFromProps,typeof l=="function"&&(gf(e,t,l,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&Lc.enqueueReplaceState(i,i.state,null),nc(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Ii(e,t){try{var n="",r=t;do n+=U1(r),r=r.return;while(r);var i=n}catch(l){i=`
39
- Error generating stack: `+l.message+`
40
- `+l.stack}return{value:e,source:t,stack:i,digest:null}}function Ku(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function vf(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var hC=typeof WeakMap=="function"?WeakMap:Map;function Wy(e,t,n){n=gs(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){oc||(oc=!0,Af=r),vf(e,t)},n}function Vy(e,t,n){n=gs(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){vf(e,t)}}var l=e.stateNode;return l!==null&&typeof l.componentDidCatch=="function"&&(n.callback=function(){vf(e,t),typeof r!="function"&&(qs===null?qs=new Set([this]):qs.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function ox(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new hC;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=EC.bind(null,e,t,n),t.then(e,e))}function ax(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function cx(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=gs(-1,1),t.tag=2,Ys(n,t,1))),n.lanes|=1),e)}var pC=Rs.ReactCurrentOwner,Kt=!1;function Ot(e,t,n,r){t.child=e===null?jy(t,null,n,r):Ti(t,e.child,n,r)}function ux(e,t,n,r,i){n=n.render;var l=t.ref;return wi(t,i),r=hp(e,t,n,r,l,i),n=pp(),e!==null&&!Kt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ks(e,t,i)):(We&&n&&tp(t),t.flags|=1,Ot(e,t,r,i),t.child)}function dx(e,t,n,r,i){if(e===null){var l=n.type;return typeof l=="function"&&!Sp(l)&&l.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=l,Hy(e,t,l,r,i)):(e=Ra(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(l=e.child,!(e.lanes&i)){var o=l.memoizedProps;if(n=n.compare,n=n!==null?n:zl,n(o,r)&&e.ref===t.ref)return ks(e,t,i)}return t.flags|=1,e=Js(l,r),e.ref=t.ref,e.return=t,t.child=e}function Hy(e,t,n,r,i){if(e!==null){var l=e.memoizedProps;if(zl(l,r)&&e.ref===t.ref)if(Kt=!1,t.pendingProps=r=l,(e.lanes&i)!==0)e.flags&131072&&(Kt=!0);else return t.lanes=e.lanes,ks(e,t,i)}return jf(e,t,n,r,i)}function Ky(e,t,n){var r=t.pendingProps,i=r.children,l=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Le(mi,sn),sn|=n;else{if(!(n&1073741824))return e=l!==null?l.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Le(mi,sn),sn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=l!==null?l.baseLanes:n,Le(mi,sn),sn|=r}else l!==null?(r=l.baseLanes|n,t.memoizedState=null):r=n,Le(mi,sn),sn|=r;return Ot(e,t,i,n),t.child}function Gy(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function jf(e,t,n,r,i){var l=Yt(n)?Er:$t.current;return l=Ai(t,l),wi(t,i),n=hp(e,t,n,r,l,i),r=pp(),e!==null&&!Kt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ks(e,t,i)):(We&&r&&tp(t),t.flags|=1,Ot(e,t,n,i),t.child)}function fx(e,t,n,r,i){if(Yt(n)){var l=!0;Ja(t)}else l=!1;if(wi(t,i),t.stateNode===null)Ca(e,t),zy(t,n,r),xf(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var c=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Sn(u):(u=Yt(n)?Er:$t.current,u=Ai(t,u));var h=n.getDerivedStateFromProps,f=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function";f||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||c!==u)&&lx(t,o,r,u),Ls=!1;var p=t.memoizedState;o.state=p,nc(t,r,o,i),c=t.memoizedState,a!==r||p!==c||Gt.current||Ls?(typeof h=="function"&&(gf(t,n,h,r),c=t.memoizedState),(a=Ls||ix(t,n,a,r,p,c,u))?(f||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,wy(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Pn(t.type,a),o.props=u,f=t.pendingProps,p=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=Sn(c):(c=Yt(n)?Er:$t.current,c=Ai(t,c));var m=n.getDerivedStateFromProps;(h=typeof m=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==f||p!==c)&&lx(t,o,r,c),Ls=!1,p=t.memoizedState,o.state=p,nc(t,r,o,i);var j=t.memoizedState;a!==f||p!==j||Gt.current||Ls?(typeof m=="function"&&(gf(t,n,m,r),j=t.memoizedState),(u=Ls||ix(t,n,u,r,p,j,c)||!1)?(h||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,j,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,j,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),o.props=r,o.state=j,o.context=c,r=u):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return yf(e,t,n,r,l,i)}function yf(e,t,n,r,i,l){Gy(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return i&&Jg(t,n,!1),ks(e,t,l);r=t.stateNode,pC.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Ti(t,e.child,null,l),t.child=Ti(t,null,a,l)):Ot(e,t,a,l),t.memoizedState=r.state,i&&Jg(t,n,!0),t.child}function Yy(e){var t=e.stateNode;t.pendingContext?Qg(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Qg(e,t.context,!1),cp(e,t.containerInfo)}function hx(e,t,n,r,i){return Ri(),sp(i),t.flags|=256,Ot(e,t,n,r),t.child}var wf={dehydrated:null,treeContext:null,retryLane:0};function bf(e){return{baseLanes:e,cachePool:null,transitions:null}}function qy(e,t,n){var r=t.pendingProps,i=He.current,l=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(l=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Le(He,i&1),e===null)return pf(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,l?(r=t.mode,l=t.child,o={mode:"hidden",children:o},!(r&1)&&l!==null?(l.childLanes=0,l.pendingProps=o):l=Bc(o,r,0,null),e=Sr(e,r,n,null),l.return=t,e.return=t,l.sibling=e,t.child=l,t.child.memoizedState=bf(n),t.memoizedState=wf,e):xp(t,o));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return mC(e,t,o,r,a,i,n);if(l){l=r.fallback,o=t.mode,i=e.child,a=i.sibling;var c={mode:"hidden",children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Js(i,c),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?l=Js(a,l):(l=Sr(l,o,n,null),l.flags|=2),l.return=t,r.return=t,r.sibling=l,t.child=r,r=l,l=t.child,o=e.child.memoizedState,o=o===null?bf(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},l.memoizedState=o,l.childLanes=e.childLanes&~n,t.memoizedState=wf,r}return l=e.child,e=l.sibling,r=Js(l,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function xp(e,t){return t=Bc({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ho(e,t,n,r){return r!==null&&sp(r),Ti(t,e.child,null,n),e=xp(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function mC(e,t,n,r,i,l,o){if(n)return t.flags&256?(t.flags&=-257,r=Ku(Error(Q(422))),Ho(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(l=r.fallback,i=t.mode,r=Bc({mode:"visible",children:r.children},i,0,null),l=Sr(l,i,o,null),l.flags|=2,r.return=t,l.return=t,r.sibling=l,t.child=r,t.mode&1&&Ti(t,e.child,null,o),t.child.memoizedState=bf(o),t.memoizedState=wf,l);if(!(t.mode&1))return Ho(e,t,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,l=Error(Q(419)),r=Ku(l,r,void 0),Ho(e,t,o,r)}if(a=(o&e.childLanes)!==0,Kt||a){if(r=pt,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==l.retryLane&&(l.retryLane=i,bs(e,i),On(r,e,i,-1))}return kp(),r=Ku(Error(Q(421))),Ho(e,t,o,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=AC.bind(null,e),i._reactRetry=t,null):(e=l.treeContext,ln=Gs(i.nextSibling),an=t,We=!0,Mn=null,e!==null&&(vn[jn++]=ps,vn[jn++]=ms,vn[jn++]=Ar,ps=e.id,ms=e.overflow,Ar=t),t=xp(t,r.children),t.flags|=4096,t)}function px(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),mf(e.return,t,n)}function Gu(e,t,n,r,i){var l=e.memoizedState;l===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(l.isBackwards=t,l.rendering=null,l.renderingStartTime=0,l.last=r,l.tail=n,l.tailMode=i)}function Qy(e,t,n){var r=t.pendingProps,i=r.revealOrder,l=r.tail;if(Ot(e,t,r.children,n),r=He.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&px(e,n,t);else if(e.tag===19)px(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Le(He,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&sc(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Gu(t,!1,i,n,l);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&sc(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Gu(t,!0,n,null,l);break;case"together":Gu(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ca(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ks(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Tr|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Q(153));if(t.child!==null){for(e=t.child,n=Js(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Js(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function gC(e,t,n){switch(t.tag){case 3:Yy(t),Ri();break;case 5:by(t);break;case 1:Yt(t.type)&&Ja(t);break;case 4:cp(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Le(ec,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Le(He,He.current&1),t.flags|=128,null):n&t.child.childLanes?qy(e,t,n):(Le(He,He.current&1),e=ks(e,t,n),e!==null?e.sibling:null);Le(He,He.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Qy(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Le(He,He.current),r)break;return null;case 22:case 23:return t.lanes=0,Ky(e,t,n)}return ks(e,t,n)}var Jy,kf,Xy,Zy;Jy=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};kf=function(){};Xy=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,br(es.current);var l=null;switch(n){case"input":i=Vd(e,i),r=Vd(e,r),l=[];break;case"select":i=Ye({},i,{value:void 0}),r=Ye({},r,{value:void 0}),l=[];break;case"textarea":i=Gd(e,i),r=Gd(e,r),l=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=qa)}qd(n,r);var o;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var a=i[u];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(_l.hasOwnProperty(u)?l||(l=[]):(l=l||[]).push(u,null));for(u in r){var c=r[u];if(a=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==a&&(c!=null||a!=null))if(u==="style")if(a){for(o in a)!a.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&a[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(l||(l=[]),l.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,a=a?a.__html:void 0,c!=null&&a!==c&&(l=l||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(l=l||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(_l.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Ue("scroll",e),l||a===c||(l=[])):(l=l||[]).push(u,c))}n&&(l=l||[]).push("style",n);var u=l;(t.updateQueue=u)&&(t.flags|=4)}};Zy=function(e,t,n,r){n!==r&&(t.flags|=4)};function pl(e,t){if(!We)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Rt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function xC(e,t,n){var r=t.pendingProps;switch(np(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rt(t),null;case 1:return Yt(t.type)&&Qa(),Rt(t),null;case 3:return r=t.stateNode,Pi(),Be(Gt),Be($t),dp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Wo(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Mn!==null&&(Pf(Mn),Mn=null))),kf(e,t),Rt(t),null;case 5:up(t);var i=br(Gl.current);if(n=t.type,e!==null&&t.stateNode!=null)Xy(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Q(166));return Rt(t),null}if(e=br(es.current),Wo(t)){r=t.stateNode,n=t.type;var l=t.memoizedProps;switch(r[qn]=t,r[Hl]=l,e=(t.mode&1)!==0,n){case"dialog":Ue("cancel",r),Ue("close",r);break;case"iframe":case"object":case"embed":Ue("load",r);break;case"video":case"audio":for(i=0;i<kl.length;i++)Ue(kl[i],r);break;case"source":Ue("error",r);break;case"img":case"image":case"link":Ue("error",r),Ue("load",r);break;case"details":Ue("toggle",r);break;case"input":kg(r,l),Ue("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!l.multiple},Ue("invalid",r);break;case"textarea":Ng(r,l),Ue("invalid",r)}qd(n,l),i=null;for(var o in l)if(l.hasOwnProperty(o)){var a=l[o];o==="children"?typeof a=="string"?r.textContent!==a&&(l.suppressHydrationWarning!==!0&&zo(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(l.suppressHydrationWarning!==!0&&zo(r.textContent,a,e),i=["children",""+a]):_l.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&Ue("scroll",r)}switch(n){case"input":$o(r),Sg(r,l,!0);break;case"textarea":$o(r),Cg(r);break;case"select":case"option":break;default:typeof l.onClick=="function"&&(r.onclick=qa)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Ej(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[qn]=t,e[Hl]=r,Jy(e,t,!1,!1),t.stateNode=e;e:{switch(o=Qd(n,r),n){case"dialog":Ue("cancel",e),Ue("close",e),i=r;break;case"iframe":case"object":case"embed":Ue("load",e),i=r;break;case"video":case"audio":for(i=0;i<kl.length;i++)Ue(kl[i],e);i=r;break;case"source":Ue("error",e),i=r;break;case"img":case"image":case"link":Ue("error",e),Ue("load",e),i=r;break;case"details":Ue("toggle",e),i=r;break;case"input":kg(e,r),i=Vd(e,r),Ue("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=Ye({},r,{value:void 0}),Ue("invalid",e);break;case"textarea":Ng(e,r),i=Gd(e,r),Ue("invalid",e);break;default:i=r}qd(n,i),a=i;for(l in a)if(a.hasOwnProperty(l)){var c=a[l];l==="style"?Tj(e,c):l==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Aj(e,c)):l==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Ol(e,c):typeof c=="number"&&Ol(e,""+c):l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&l!=="autoFocus"&&(_l.hasOwnProperty(l)?c!=null&&l==="onScroll"&&Ue("scroll",e):c!=null&&Bh(e,l,c,o))}switch(n){case"input":$o(e),Sg(e,r,!1);break;case"textarea":$o(e),Cg(e);break;case"option":r.value!=null&&e.setAttribute("value",""+tr(r.value));break;case"select":e.multiple=!!r.multiple,l=r.value,l!=null?xi(e,!!r.multiple,l,!1):r.defaultValue!=null&&xi(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=qa)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Rt(t),null;case 6:if(e&&t.stateNode!=null)Zy(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Q(166));if(n=br(Gl.current),br(es.current),Wo(t)){if(r=t.stateNode,n=t.memoizedProps,r[qn]=t,(l=r.nodeValue!==n)&&(e=an,e!==null))switch(e.tag){case 3:zo(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&zo(r.nodeValue,n,(e.mode&1)!==0)}l&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[qn]=t,t.stateNode=r}return Rt(t),null;case 13:if(Be(He),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(We&&ln!==null&&t.mode&1&&!(t.flags&128))xy(),Ri(),t.flags|=98560,l=!1;else if(l=Wo(t),r!==null&&r.dehydrated!==null){if(e===null){if(!l)throw Error(Q(318));if(l=t.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(Q(317));l[qn]=t}else Ri(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Rt(t),l=!1}else Mn!==null&&(Pf(Mn),Mn=null),l=!0;if(!l)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||He.current&1?at===0&&(at=3):kp())),t.updateQueue!==null&&(t.flags|=4),Rt(t),null);case 4:return Pi(),kf(e,t),e===null&&Wl(t.stateNode.containerInfo),Rt(t),null;case 10:return lp(t.type._context),Rt(t),null;case 17:return Yt(t.type)&&Qa(),Rt(t),null;case 19:if(Be(He),l=t.memoizedState,l===null)return Rt(t),null;if(r=(t.flags&128)!==0,o=l.rendering,o===null)if(r)pl(l,!1);else{if(at!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=sc(e),o!==null){for(t.flags|=128,pl(l,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)l=n,e=r,l.flags&=14680066,o=l.alternate,o===null?(l.childLanes=0,l.lanes=e,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=o.childLanes,l.lanes=o.lanes,l.child=o.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=o.memoizedProps,l.memoizedState=o.memoizedState,l.updateQueue=o.updateQueue,l.type=o.type,e=o.dependencies,l.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Le(He,He.current&1|2),t.child}e=e.sibling}l.tail!==null&&et()>Mi&&(t.flags|=128,r=!0,pl(l,!1),t.lanes=4194304)}else{if(!r)if(e=sc(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),pl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!o.alternate&&!We)return Rt(t),null}else 2*et()-l.renderingStartTime>Mi&&n!==1073741824&&(t.flags|=128,r=!0,pl(l,!1),t.lanes=4194304);l.isBackwards?(o.sibling=t.child,t.child=o):(n=l.last,n!==null?n.sibling=o:t.child=o,l.last=o)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=et(),t.sibling=null,n=He.current,Le(He,r?n&1|2:n&1),t):(Rt(t),null);case 22:case 23:return bp(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?sn&1073741824&&(Rt(t),t.subtreeFlags&6&&(t.flags|=8192)):Rt(t),null;case 24:return null;case 25:return null}throw Error(Q(156,t.tag))}function vC(e,t){switch(np(t),t.tag){case 1:return Yt(t.type)&&Qa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Pi(),Be(Gt),Be($t),dp(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return up(t),null;case 13:if(Be(He),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Q(340));Ri()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Be(He),null;case 4:return Pi(),null;case 10:return lp(t.type._context),null;case 22:case 23:return bp(),null;case 24:return null;default:return null}}var Ko=!1,Pt=!1,jC=typeof WeakSet=="function"?WeakSet:Set,re=null;function pi(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Qe(e,t,r)}else n.current=null}function Sf(e,t,n){try{n()}catch(r){Qe(e,t,r)}}var mx=!1;function yC(e,t){if(of=Ka,e=ry(),ep(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var o=0,a=-1,c=-1,u=0,h=0,f=e,p=null;t:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(a=o+i),f!==l||r!==0&&f.nodeType!==3||(c=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break t;if(p===n&&++u===i&&(a=o),p===l&&++h===r&&(c=o),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(af={focusedElem:e,selectionRange:n},Ka=!1,re=t;re!==null;)if(t=re,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,re=e;else for(;re!==null;){t=re;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var w=j.memoizedProps,b=j.memoizedState,x=t.stateNode,v=x.getSnapshotBeforeUpdate(t.elementType===t.type?w:Pn(t.type,w),b);x.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Q(163))}}catch(g){Qe(t,t.return,g)}if(e=t.sibling,e!==null){e.return=t.return,re=e;break}re=t.return}return j=mx,mx=!1,j}function Tl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var l=i.destroy;i.destroy=void 0,l!==void 0&&Sf(t,n,l)}i=i.next}while(i!==r)}}function Fc(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Nf(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function ew(e){var t=e.alternate;t!==null&&(e.alternate=null,ew(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[qn],delete t[Hl],delete t[df],delete t[nC],delete t[sC])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function tw(e){return e.tag===5||e.tag===3||e.tag===4}function gx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||tw(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Cf(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=qa));else if(r!==4&&(e=e.child,e!==null))for(Cf(e,t,n),e=e.sibling;e!==null;)Cf(e,t,n),e=e.sibling}function Ef(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ef(e,t,n),e=e.sibling;e!==null;)Ef(e,t,n),e=e.sibling}var yt=null,In=!1;function _s(e,t,n){for(n=n.child;n!==null;)nw(e,t,n),n=n.sibling}function nw(e,t,n){if(Zn&&typeof Zn.onCommitFiberUnmount=="function")try{Zn.onCommitFiberUnmount(Pc,n)}catch{}switch(n.tag){case 5:Pt||pi(n,t);case 6:var r=yt,i=In;yt=null,_s(e,t,n),yt=r,In=i,yt!==null&&(In?(e=yt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):yt.removeChild(n.stateNode));break;case 18:yt!==null&&(In?(e=yt,n=n.stateNode,e.nodeType===8?Uu(e.parentNode,n):e.nodeType===1&&Uu(e,n),Ul(e)):Uu(yt,n.stateNode));break;case 4:r=yt,i=In,yt=n.stateNode.containerInfo,In=!0,_s(e,t,n),yt=r,In=i;break;case 0:case 11:case 14:case 15:if(!Pt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var l=i,o=l.destroy;l=l.tag,o!==void 0&&(l&2||l&4)&&Sf(n,t,o),i=i.next}while(i!==r)}_s(e,t,n);break;case 1:if(!Pt&&(pi(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Qe(n,t,a)}_s(e,t,n);break;case 21:_s(e,t,n);break;case 22:n.mode&1?(Pt=(r=Pt)||n.memoizedState!==null,_s(e,t,n),Pt=r):_s(e,t,n);break;default:_s(e,t,n)}}function xx(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new jC),t.forEach(function(r){var i=RC.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Rn(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var l=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:yt=a.stateNode,In=!1;break e;case 3:yt=a.stateNode.containerInfo,In=!0;break e;case 4:yt=a.stateNode.containerInfo,In=!0;break e}a=a.return}if(yt===null)throw Error(Q(160));nw(l,o,i),yt=null,In=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){Qe(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)sw(t,e),t=t.sibling}function sw(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Rn(t,e),Kn(e),r&4){try{Tl(3,e,e.return),Fc(3,e)}catch(w){Qe(e,e.return,w)}try{Tl(5,e,e.return)}catch(w){Qe(e,e.return,w)}}break;case 1:Rn(t,e),Kn(e),r&512&&n!==null&&pi(n,n.return);break;case 5:if(Rn(t,e),Kn(e),r&512&&n!==null&&pi(n,n.return),e.flags&32){var i=e.stateNode;try{Ol(i,"")}catch(w){Qe(e,e.return,w)}}if(r&4&&(i=e.stateNode,i!=null)){var l=e.memoizedProps,o=n!==null?n.memoizedProps:l,a=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{a==="input"&&l.type==="radio"&&l.name!=null&&Nj(i,l),Qd(a,o);var u=Qd(a,l);for(o=0;o<c.length;o+=2){var h=c[o],f=c[o+1];h==="style"?Tj(i,f):h==="dangerouslySetInnerHTML"?Aj(i,f):h==="children"?Ol(i,f):Bh(i,h,f,u)}switch(a){case"input":Hd(i,l);break;case"textarea":Cj(i,l);break;case"select":var p=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!l.multiple;var m=l.value;m!=null?xi(i,!!l.multiple,m,!1):p!==!!l.multiple&&(l.defaultValue!=null?xi(i,!!l.multiple,l.defaultValue,!0):xi(i,!!l.multiple,l.multiple?[]:"",!1))}i[Hl]=l}catch(w){Qe(e,e.return,w)}}break;case 6:if(Rn(t,e),Kn(e),r&4){if(e.stateNode===null)throw Error(Q(162));i=e.stateNode,l=e.memoizedProps;try{i.nodeValue=l}catch(w){Qe(e,e.return,w)}}break;case 3:if(Rn(t,e),Kn(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ul(t.containerInfo)}catch(w){Qe(e,e.return,w)}break;case 4:Rn(t,e),Kn(e);break;case 13:Rn(t,e),Kn(e),i=e.child,i.flags&8192&&(l=i.memoizedState!==null,i.stateNode.isHidden=l,!l||i.alternate!==null&&i.alternate.memoizedState!==null||(yp=et())),r&4&&xx(e);break;case 22:if(h=n!==null&&n.memoizedState!==null,e.mode&1?(Pt=(u=Pt)||h,Rn(t,e),Pt=u):Rn(t,e),Kn(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!h&&e.mode&1)for(re=e,h=e.child;h!==null;){for(f=re=h;re!==null;){switch(p=re,m=p.child,p.tag){case 0:case 11:case 14:case 15:Tl(4,p,p.return);break;case 1:pi(p,p.return);var j=p.stateNode;if(typeof j.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(w){Qe(r,n,w)}}break;case 5:pi(p,p.return);break;case 22:if(p.memoizedState!==null){jx(f);continue}}m!==null?(m.return=p,re=m):jx(f)}h=h.sibling}e:for(h=null,f=e;;){if(f.tag===5){if(h===null){h=f;try{i=f.stateNode,u?(l=i.style,typeof l.setProperty=="function"?l.setProperty("display","none","important"):l.display="none"):(a=f.stateNode,c=f.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,a.style.display=Rj("display",o))}catch(w){Qe(e,e.return,w)}}}else if(f.tag===6){if(h===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(w){Qe(e,e.return,w)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;h===f&&(h=null),f=f.return}h===f&&(h=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Rn(t,e),Kn(e),r&4&&xx(e);break;case 21:break;default:Rn(t,e),Kn(e)}}function Kn(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(tw(n)){var r=n;break e}n=n.return}throw Error(Q(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Ol(i,""),r.flags&=-33);var l=gx(e);Ef(e,l,i);break;case 3:case 4:var o=r.stateNode.containerInfo,a=gx(e);Cf(e,a,o);break;default:throw Error(Q(161))}}catch(c){Qe(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wC(e,t,n){re=e,rw(e)}function rw(e,t,n){for(var r=(e.mode&1)!==0;re!==null;){var i=re,l=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||Ko;if(!o){var a=i.alternate,c=a!==null&&a.memoizedState!==null||Pt;a=Ko;var u=Pt;if(Ko=o,(Pt=c)&&!u)for(re=i;re!==null;)o=re,c=o.child,o.tag===22&&o.memoizedState!==null?yx(i):c!==null?(c.return=o,re=c):yx(i);for(;l!==null;)re=l,rw(l),l=l.sibling;re=i,Ko=a,Pt=u}vx(e)}else i.subtreeFlags&8772&&l!==null?(l.return=i,re=l):vx(e)}}function vx(e){for(;re!==null;){var t=re;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Pt||Fc(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Pt)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Pn(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var l=t.updateQueue;l!==null&&nx(t,l,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}nx(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var h=u.memoizedState;if(h!==null){var f=h.dehydrated;f!==null&&Ul(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Q(163))}Pt||t.flags&512&&Nf(t)}catch(p){Qe(t,t.return,p)}}if(t===e){re=null;break}if(n=t.sibling,n!==null){n.return=t.return,re=n;break}re=t.return}}function jx(e){for(;re!==null;){var t=re;if(t===e){re=null;break}var n=t.sibling;if(n!==null){n.return=t.return,re=n;break}re=t.return}}function yx(e){for(;re!==null;){var t=re;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Fc(4,t)}catch(c){Qe(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){Qe(t,i,c)}}var l=t.return;try{Nf(t)}catch(c){Qe(t,l,c)}break;case 5:var o=t.return;try{Nf(t)}catch(c){Qe(t,o,c)}}}catch(c){Qe(t,t.return,c)}if(t===e){re=null;break}var a=t.sibling;if(a!==null){a.return=t.return,re=a;break}re=t.return}}var bC=Math.ceil,lc=Rs.ReactCurrentDispatcher,vp=Rs.ReactCurrentOwner,kn=Rs.ReactCurrentBatchConfig,Ae=0,pt=null,nt=null,wt=0,sn=0,mi=ar(0),at=0,Jl=null,Tr=0,Uc=0,jp=0,Pl=null,Vt=null,yp=0,Mi=1/0,ds=null,oc=!1,Af=null,qs=null,Go=!1,zs=null,ac=0,Il=0,Rf=null,Ea=-1,Aa=0;function Ft(){return Ae&6?et():Ea!==-1?Ea:Ea=et()}function Qs(e){return e.mode&1?Ae&2&&wt!==0?wt&-wt:iC.transition!==null?(Aa===0&&(Aa=zj()),Aa):(e=Ie,e!==0||(e=window.event,e=e===void 0?16:qj(e.type)),e):1}function On(e,t,n,r){if(50<Il)throw Il=0,Rf=null,Error(Q(185));co(e,n,r),(!(Ae&2)||e!==pt)&&(e===pt&&(!(Ae&2)&&(Uc|=n),at===4&&Us(e,wt)),qt(e,r),n===1&&Ae===0&&!(t.mode&1)&&(Mi=et()+500,Oc&&cr()))}function qt(e,t){var n=e.callbackNode;iN(e,t);var r=Ha(e,e===pt?wt:0);if(r===0)n!==null&&Rg(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Rg(n),t===1)e.tag===0?rC(wx.bind(null,e)):py(wx.bind(null,e)),eC(function(){!(Ae&6)&&cr()}),n=null;else{switch(Wj(r)){case 1:n=Kh;break;case 4:n=Uj;break;case 16:n=Va;break;case 536870912:n=Bj;break;default:n=Va}n=fw(n,iw.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function iw(e,t){if(Ea=-1,Aa=0,Ae&6)throw Error(Q(327));var n=e.callbackNode;if(bi()&&e.callbackNode!==n)return null;var r=Ha(e,e===pt?wt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=cc(e,r);else{t=r;var i=Ae;Ae|=2;var l=ow();(pt!==e||wt!==t)&&(ds=null,Mi=et()+500,kr(e,t));do try{NC();break}catch(a){lw(e,a)}while(!0);ip(),lc.current=l,Ae=i,nt!==null?t=0:(pt=null,wt=0,t=at)}if(t!==0){if(t===2&&(i=tf(e),i!==0&&(r=i,t=Tf(e,i))),t===1)throw n=Jl,kr(e,0),Us(e,r),qt(e,et()),n;if(t===6)Us(e,r);else{if(i=e.current.alternate,!(r&30)&&!kC(i)&&(t=cc(e,r),t===2&&(l=tf(e),l!==0&&(r=l,t=Tf(e,l))),t===1))throw n=Jl,kr(e,0),Us(e,r),qt(e,et()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(Q(345));case 2:jr(e,Vt,ds);break;case 3:if(Us(e,r),(r&130023424)===r&&(t=yp+500-et(),10<t)){if(Ha(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Ft(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=uf(jr.bind(null,e,Vt,ds),t);break}jr(e,Vt,ds);break;case 4:if(Us(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var o=31-_n(r);l=1<<o,o=t[o],o>i&&(i=o),r&=~l}if(r=i,r=et()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*bC(r/1960))-r,10<r){e.timeoutHandle=uf(jr.bind(null,e,Vt,ds),r);break}jr(e,Vt,ds);break;case 5:jr(e,Vt,ds);break;default:throw Error(Q(329))}}}return qt(e,et()),e.callbackNode===n?iw.bind(null,e):null}function Tf(e,t){var n=Pl;return e.current.memoizedState.isDehydrated&&(kr(e,t).flags|=256),e=cc(e,t),e!==2&&(t=Vt,Vt=n,t!==null&&Pf(t)),e}function Pf(e){Vt===null?Vt=e:Vt.push.apply(Vt,e)}function kC(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],l=i.getSnapshot;i=i.value;try{if(!Dn(l(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Us(e,t){for(t&=~jp,t&=~Uc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-_n(t),r=1<<n;e[n]=-1,t&=~r}}function wx(e){if(Ae&6)throw Error(Q(327));bi();var t=Ha(e,0);if(!(t&1))return qt(e,et()),null;var n=cc(e,t);if(e.tag!==0&&n===2){var r=tf(e);r!==0&&(t=r,n=Tf(e,r))}if(n===1)throw n=Jl,kr(e,0),Us(e,t),qt(e,et()),n;if(n===6)throw Error(Q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,jr(e,Vt,ds),qt(e,et()),null}function wp(e,t){var n=Ae;Ae|=1;try{return e(t)}finally{Ae=n,Ae===0&&(Mi=et()+500,Oc&&cr())}}function Pr(e){zs!==null&&zs.tag===0&&!(Ae&6)&&bi();var t=Ae;Ae|=1;var n=kn.transition,r=Ie;try{if(kn.transition=null,Ie=1,e)return e()}finally{Ie=r,kn.transition=n,Ae=t,!(Ae&6)&&cr()}}function bp(){sn=mi.current,Be(mi)}function kr(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,ZN(n)),nt!==null)for(n=nt.return;n!==null;){var r=n;switch(np(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Qa();break;case 3:Pi(),Be(Gt),Be($t),dp();break;case 5:up(r);break;case 4:Pi();break;case 13:Be(He);break;case 19:Be(He);break;case 10:lp(r.type._context);break;case 22:case 23:bp()}n=n.return}if(pt=e,nt=e=Js(e.current,null),wt=sn=t,at=0,Jl=null,jp=Uc=Tr=0,Vt=Pl=null,wr!==null){for(t=0;t<wr.length;t++)if(n=wr[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,l=n.pending;if(l!==null){var o=l.next;l.next=i,r.next=o}n.pending=r}wr=null}return e}function lw(e,t){do{var n=nt;try{if(ip(),Sa.current=ic,rc){for(var r=Ke.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}rc=!1}if(Rr=0,ut=lt=Ke=null,Rl=!1,Yl=0,vp.current=null,n===null||n.return===null){at=1,Jl=t,nt=null;break}e:{var l=e,o=n.return,a=n,c=t;if(t=wt,a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,h=a,f=h.tag;if(!(h.mode&1)&&(f===0||f===11||f===15)){var p=h.alternate;p?(h.updateQueue=p.updateQueue,h.memoizedState=p.memoizedState,h.lanes=p.lanes):(h.updateQueue=null,h.memoizedState=null)}var m=ax(o);if(m!==null){m.flags&=-257,cx(m,o,a,l,t),m.mode&1&&ox(l,u,t),t=m,c=u;var j=t.updateQueue;if(j===null){var w=new Set;w.add(c),t.updateQueue=w}else j.add(c);break e}else{if(!(t&1)){ox(l,u,t),kp();break e}c=Error(Q(426))}}else if(We&&a.mode&1){var b=ax(o);if(b!==null){!(b.flags&65536)&&(b.flags|=256),cx(b,o,a,l,t),sp(Ii(c,a));break e}}l=c=Ii(c,a),at!==4&&(at=2),Pl===null?Pl=[l]:Pl.push(l),l=o;do{switch(l.tag){case 3:l.flags|=65536,t&=-t,l.lanes|=t;var x=Wy(l,c,t);tx(l,x);break e;case 1:a=c;var v=l.type,y=l.stateNode;if(!(l.flags&128)&&(typeof v.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(qs===null||!qs.has(y)))){l.flags|=65536,t&=-t,l.lanes|=t;var g=Vy(l,a,t);tx(l,g);break e}}l=l.return}while(l!==null)}cw(n)}catch(S){t=S,nt===n&&n!==null&&(nt=n=n.return);continue}break}while(!0)}function ow(){var e=lc.current;return lc.current=ic,e===null?ic:e}function kp(){(at===0||at===3||at===2)&&(at=4),pt===null||!(Tr&268435455)&&!(Uc&268435455)||Us(pt,wt)}function cc(e,t){var n=Ae;Ae|=2;var r=ow();(pt!==e||wt!==t)&&(ds=null,kr(e,t));do try{SC();break}catch(i){lw(e,i)}while(!0);if(ip(),Ae=n,lc.current=r,nt!==null)throw Error(Q(261));return pt=null,wt=0,at}function SC(){for(;nt!==null;)aw(nt)}function NC(){for(;nt!==null&&!Q1();)aw(nt)}function aw(e){var t=dw(e.alternate,e,sn);e.memoizedProps=e.pendingProps,t===null?cw(e):nt=t,vp.current=null}function cw(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=vC(n,t),n!==null){n.flags&=32767,nt=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{at=6,nt=null;return}}else if(n=xC(n,t,sn),n!==null){nt=n;return}if(t=t.sibling,t!==null){nt=t;return}nt=t=e}while(t!==null);at===0&&(at=5)}function jr(e,t,n){var r=Ie,i=kn.transition;try{kn.transition=null,Ie=1,CC(e,t,n,r)}finally{kn.transition=i,Ie=r}return null}function CC(e,t,n,r){do bi();while(zs!==null);if(Ae&6)throw Error(Q(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Q(177));e.callbackNode=null,e.callbackPriority=0;var l=n.lanes|n.childLanes;if(lN(e,l),e===pt&&(nt=pt=null,wt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Go||(Go=!0,fw(Va,function(){return bi(),null})),l=(n.flags&15990)!==0,n.subtreeFlags&15990||l){l=kn.transition,kn.transition=null;var o=Ie;Ie=1;var a=Ae;Ae|=4,vp.current=null,yC(e,n),sw(n,e),KN(af),Ka=!!of,af=of=null,e.current=n,wC(n),J1(),Ae=a,Ie=o,kn.transition=l}else e.current=n;if(Go&&(Go=!1,zs=e,ac=i),l=e.pendingLanes,l===0&&(qs=null),eN(n.stateNode),qt(e,et()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(oc)throw oc=!1,e=Af,Af=null,e;return ac&1&&e.tag!==0&&bi(),l=e.pendingLanes,l&1?e===Rf?Il++:(Il=0,Rf=e):Il=0,cr(),null}function bi(){if(zs!==null){var e=Wj(ac),t=kn.transition,n=Ie;try{if(kn.transition=null,Ie=16>e?16:e,zs===null)var r=!1;else{if(e=zs,zs=null,ac=0,Ae&6)throw Error(Q(331));var i=Ae;for(Ae|=4,re=e.current;re!==null;){var l=re,o=l.child;if(re.flags&16){var a=l.deletions;if(a!==null){for(var c=0;c<a.length;c++){var u=a[c];for(re=u;re!==null;){var h=re;switch(h.tag){case 0:case 11:case 15:Tl(8,h,l)}var f=h.child;if(f!==null)f.return=h,re=f;else for(;re!==null;){h=re;var p=h.sibling,m=h.return;if(ew(h),h===u){re=null;break}if(p!==null){p.return=m,re=p;break}re=m}}}var j=l.alternate;if(j!==null){var w=j.child;if(w!==null){j.child=null;do{var b=w.sibling;w.sibling=null,w=b}while(w!==null)}}re=l}}if(l.subtreeFlags&2064&&o!==null)o.return=l,re=o;else e:for(;re!==null;){if(l=re,l.flags&2048)switch(l.tag){case 0:case 11:case 15:Tl(9,l,l.return)}var x=l.sibling;if(x!==null){x.return=l.return,re=x;break e}re=l.return}}var v=e.current;for(re=v;re!==null;){o=re;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,re=y;else e:for(o=v;re!==null;){if(a=re,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Fc(9,a)}}catch(S){Qe(a,a.return,S)}if(a===o){re=null;break e}var g=a.sibling;if(g!==null){g.return=a.return,re=g;break e}re=a.return}}if(Ae=i,cr(),Zn&&typeof Zn.onPostCommitFiberRoot=="function")try{Zn.onPostCommitFiberRoot(Pc,e)}catch{}r=!0}return r}finally{Ie=n,kn.transition=t}}return!1}function bx(e,t,n){t=Ii(n,t),t=Wy(e,t,1),e=Ys(e,t,1),t=Ft(),e!==null&&(co(e,1,t),qt(e,t))}function Qe(e,t,n){if(e.tag===3)bx(e,e,n);else for(;t!==null;){if(t.tag===3){bx(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(qs===null||!qs.has(r))){e=Ii(n,e),e=Vy(t,e,1),t=Ys(t,e,1),e=Ft(),t!==null&&(co(t,1,e),qt(t,e));break}}t=t.return}}function EC(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Ft(),e.pingedLanes|=e.suspendedLanes&n,pt===e&&(wt&n)===n&&(at===4||at===3&&(wt&130023424)===wt&&500>et()-yp?kr(e,0):jp|=n),qt(e,t)}function uw(e,t){t===0&&(e.mode&1?(t=Do,Do<<=1,!(Do&130023424)&&(Do=4194304)):t=1);var n=Ft();e=bs(e,t),e!==null&&(co(e,t,n),qt(e,n))}function AC(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),uw(e,n)}function RC(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Q(314))}r!==null&&r.delete(t),uw(e,n)}var dw;dw=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Gt.current)Kt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Kt=!1,gC(e,t,n);Kt=!!(e.flags&131072)}else Kt=!1,We&&t.flags&1048576&&my(t,Za,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ca(e,t),e=t.pendingProps;var i=Ai(t,$t.current);wi(t,n),i=hp(null,t,r,e,i,n);var l=pp();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Yt(r)?(l=!0,Ja(t)):l=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,ap(t),i.updater=Lc,t.stateNode=i,i._reactInternals=t,xf(t,r,e,n),t=yf(null,t,r,!0,l,n)):(t.tag=0,We&&l&&tp(t),Ot(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ca(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=PC(r),e=Pn(r,e),i){case 0:t=jf(null,t,r,e,n);break e;case 1:t=fx(null,t,r,e,n);break e;case 11:t=ux(null,t,r,e,n);break e;case 14:t=dx(null,t,r,Pn(r.type,e),n);break e}throw Error(Q(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Pn(r,i),jf(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Pn(r,i),fx(e,t,r,i,n);case 3:e:{if(Yy(t),e===null)throw Error(Q(387));r=t.pendingProps,l=t.memoizedState,i=l.element,wy(e,t),nc(t,r,null,n);var o=t.memoizedState;if(r=o.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=l,t.memoizedState=l,t.flags&256){i=Ii(Error(Q(423)),t),t=hx(e,t,r,n,i);break e}else if(r!==i){i=Ii(Error(Q(424)),t),t=hx(e,t,r,n,i);break e}else for(ln=Gs(t.stateNode.containerInfo.firstChild),an=t,We=!0,Mn=null,n=jy(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ri(),r===i){t=ks(e,t,n);break e}Ot(e,t,r,n)}t=t.child}return t;case 5:return by(t),e===null&&pf(t),r=t.type,i=t.pendingProps,l=e!==null?e.memoizedProps:null,o=i.children,cf(r,i)?o=null:l!==null&&cf(r,l)&&(t.flags|=32),Gy(e,t),Ot(e,t,o,n),t.child;case 6:return e===null&&pf(t),null;case 13:return qy(e,t,n);case 4:return cp(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ti(t,null,r,n):Ot(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Pn(r,i),ux(e,t,r,i,n);case 7:return Ot(e,t,t.pendingProps,n),t.child;case 8:return Ot(e,t,t.pendingProps.children,n),t.child;case 12:return Ot(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,l=t.memoizedProps,o=i.value,Le(ec,r._currentValue),r._currentValue=o,l!==null)if(Dn(l.value,o)){if(l.children===i.children&&!Gt.current){t=ks(e,t,n);break e}}else for(l=t.child,l!==null&&(l.return=t);l!==null;){var a=l.dependencies;if(a!==null){o=l.child;for(var c=a.firstContext;c!==null;){if(c.context===r){if(l.tag===1){c=gs(-1,n&-n),c.tag=2;var u=l.updateQueue;if(u!==null){u=u.shared;var h=u.pending;h===null?c.next=c:(c.next=h.next,h.next=c),u.pending=c}}l.lanes|=n,c=l.alternate,c!==null&&(c.lanes|=n),mf(l.return,n,t),a.lanes|=n;break}c=c.next}}else if(l.tag===10)o=l.type===t.type?null:l.child;else if(l.tag===18){if(o=l.return,o===null)throw Error(Q(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),mf(o,n,t),o=l.sibling}else o=l.child;if(o!==null)o.return=l;else for(o=l;o!==null;){if(o===t){o=null;break}if(l=o.sibling,l!==null){l.return=o.return,o=l;break}o=o.return}l=o}Ot(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,wi(t,n),i=Sn(i),r=r(i),t.flags|=1,Ot(e,t,r,n),t.child;case 14:return r=t.type,i=Pn(r,t.pendingProps),i=Pn(r.type,i),dx(e,t,r,i,n);case 15:return Hy(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Pn(r,i),Ca(e,t),t.tag=1,Yt(r)?(e=!0,Ja(t)):e=!1,wi(t,n),zy(t,r,i),xf(t,r,i,n),yf(null,t,r,!0,e,n);case 19:return Qy(e,t,n);case 22:return Ky(e,t,n)}throw Error(Q(156,t.tag))};function fw(e,t){return Fj(e,t)}function TC(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wn(e,t,n,r){return new TC(e,t,n,r)}function Sp(e){return e=e.prototype,!(!e||!e.isReactComponent)}function PC(e){if(typeof e=="function")return Sp(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Wh)return 11;if(e===Vh)return 14}return 2}function Js(e,t){var n=e.alternate;return n===null?(n=wn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ra(e,t,n,r,i,l){var o=2;if(r=e,typeof e=="function")Sp(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ii:return Sr(n.children,i,l,t);case zh:o=8,i|=8;break;case Ud:return e=wn(12,n,t,i|2),e.elementType=Ud,e.lanes=l,e;case Bd:return e=wn(13,n,t,i),e.elementType=Bd,e.lanes=l,e;case zd:return e=wn(19,n,t,i),e.elementType=zd,e.lanes=l,e;case bj:return Bc(n,i,l,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case yj:o=10;break e;case wj:o=9;break e;case Wh:o=11;break e;case Vh:o=14;break e;case Ds:o=16,r=null;break e}throw Error(Q(130,e==null?e:typeof e,""))}return t=wn(o,n,t,i),t.elementType=e,t.type=r,t.lanes=l,t}function Sr(e,t,n,r){return e=wn(7,e,r,t),e.lanes=n,e}function Bc(e,t,n,r){return e=wn(22,e,r,t),e.elementType=bj,e.lanes=n,e.stateNode={isHidden:!1},e}function Yu(e,t,n){return e=wn(6,e,null,t),e.lanes=n,e}function qu(e,t,n){return t=wn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function IC(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ru(0),this.expirationTimes=Ru(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ru(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Np(e,t,n,r,i,l,o,a,c){return e=new IC(e,t,n,a,c),t===1?(t=1,l===!0&&(t|=8)):t=0,l=wn(3,null,null,t),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ap(l),e}function MC(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ri,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function hw(e){if(!e)return nr;e=e._reactInternals;e:{if(Ur(e)!==e||e.tag!==1)throw Error(Q(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Yt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Q(171))}if(e.tag===1){var n=e.type;if(Yt(n))return hy(e,n,t)}return t}function pw(e,t,n,r,i,l,o,a,c){return e=Np(n,r,!0,e,i,l,o,a,c),e.context=hw(null),n=e.current,r=Ft(),i=Qs(n),l=gs(r,i),l.callback=t??null,Ys(n,l,i),e.current.lanes=i,co(e,i,r),qt(e,r),e}function zc(e,t,n,r){var i=t.current,l=Ft(),o=Qs(i);return n=hw(n),t.context===null?t.context=n:t.pendingContext=n,t=gs(l,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Ys(i,t,o),e!==null&&(On(e,i,o,l),ka(e,i,o)),o}function uc(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function kx(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Cp(e,t){kx(e,t),(e=e.alternate)&&kx(e,t)}function $C(){return null}var mw=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ep(e){this._internalRoot=e}Wc.prototype.render=Ep.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Q(409));zc(e,t,null,null)};Wc.prototype.unmount=Ep.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Pr(function(){zc(null,e,null,null)}),t[ws]=null}};function Wc(e){this._internalRoot=e}Wc.prototype.unstable_scheduleHydration=function(e){if(e){var t=Kj();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Fs.length&&t!==0&&t<Fs[n].priority;n++);Fs.splice(n,0,e),n===0&&Yj(e)}};function Ap(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Vc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Sx(){}function _C(e,t,n,r,i){if(i){if(typeof r=="function"){var l=r;r=function(){var u=uc(o);l.call(u)}}var o=pw(t,r,e,0,null,!1,!1,"",Sx);return e._reactRootContainer=o,e[ws]=o.current,Wl(e.nodeType===8?e.parentNode:e),Pr(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var u=uc(c);a.call(u)}}var c=Np(e,0,!1,null,null,!1,!1,"",Sx);return e._reactRootContainer=c,e[ws]=c.current,Wl(e.nodeType===8?e.parentNode:e),Pr(function(){zc(t,c,n,r)}),c}function Hc(e,t,n,r,i){var l=n._reactRootContainer;if(l){var o=l;if(typeof i=="function"){var a=i;i=function(){var c=uc(o);a.call(c)}}zc(t,o,e,i)}else o=_C(n,t,e,i,r);return uc(o)}Vj=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=bl(t.pendingLanes);n!==0&&(Gh(t,n|1),qt(t,et()),!(Ae&6)&&(Mi=et()+500,cr()))}break;case 13:Pr(function(){var r=bs(e,1);if(r!==null){var i=Ft();On(r,e,1,i)}}),Cp(e,1)}};Yh=function(e){if(e.tag===13){var t=bs(e,134217728);if(t!==null){var n=Ft();On(t,e,134217728,n)}Cp(e,134217728)}};Hj=function(e){if(e.tag===13){var t=Qs(e),n=bs(e,t);if(n!==null){var r=Ft();On(n,e,t,r)}Cp(e,t)}};Kj=function(){return Ie};Gj=function(e,t){var n=Ie;try{return Ie=e,t()}finally{Ie=n}};Xd=function(e,t,n){switch(t){case"input":if(Hd(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=_c(r);if(!i)throw Error(Q(90));Sj(r),Hd(r,i)}}}break;case"textarea":Cj(e,n);break;case"select":t=n.value,t!=null&&xi(e,!!n.multiple,t,!1)}};Mj=wp;$j=Pr;var OC={usingClientEntryPoint:!1,Events:[fo,ci,_c,Pj,Ij,wp]},ml={findFiberByHostInstance:yr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},DC={bundleType:ml.bundleType,version:ml.version,rendererPackageName:ml.rendererPackageName,rendererConfig:ml.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Rs.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Dj(e),e===null?null:e.stateNode},findFiberByHostInstance:ml.findFiberByHostInstance||$C,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yo.isDisabled&&Yo.supportsFiber)try{Pc=Yo.inject(DC),Zn=Yo}catch{}}dn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=OC;dn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ap(t))throw Error(Q(200));return MC(e,t,null,n)};dn.createRoot=function(e,t){if(!Ap(e))throw Error(Q(299));var n=!1,r="",i=mw;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Np(e,1,!1,null,null,n,!1,r,i),e[ws]=t.current,Wl(e.nodeType===8?e.parentNode:e),new Ep(t)};dn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Q(188)):(e=Object.keys(e).join(","),Error(Q(268,e)));return e=Dj(t),e=e===null?null:e.stateNode,e};dn.flushSync=function(e){return Pr(e)};dn.hydrate=function(e,t,n){if(!Vc(t))throw Error(Q(200));return Hc(null,e,t,!0,n)};dn.hydrateRoot=function(e,t,n){if(!Ap(e))throw Error(Q(405));var r=n!=null&&n.hydratedSources||null,i=!1,l="",o=mw;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=pw(t,null,e,1,n??null,i,!1,l,o),e[ws]=t.current,Wl(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Wc(t)};dn.render=function(e,t,n){if(!Vc(t))throw Error(Q(200));return Hc(null,e,t,!1,n)};dn.unmountComponentAtNode=function(e){if(!Vc(e))throw Error(Q(40));return e._reactRootContainer?(Pr(function(){Hc(null,null,e,!1,function(){e._reactRootContainer=null,e[ws]=null})}),!0):!1};dn.unstable_batchedUpdates=wp;dn.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Vc(n))throw Error(Q(200));if(e==null||e._reactInternals===void 0)throw Error(Q(38));return Hc(e,t,n,!1,r)};dn.version="18.3.1-next-f1338f8080-20240426";function gw(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(gw)}catch(e){console.error(e)}}gw(),gj.exports=dn;var $i=gj.exports,xw,Nx=$i;xw=Nx.createRoot,Nx.hydrateRoot;var LC=Object.defineProperty,qi=(e,t)=>LC(e,"name",{value:t,configurable:!0}),vw=!!(typeof window<"u"&&window.document&&window.document.createElement);function je(e,t,{checkForDefaultPrevented:n=!0}={}){return qi(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}qi(je,"composeEventHandlers");function FC(e){var t;if(!vw)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}qi(FC,"getOwnerWindow");function If(e){if(!vw)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}qi(If,"getOwnerDocument");function jw(e,t=!1){const{activeElement:n}=If(e);if(!(n!=null&&n.nodeName))return null;if(yw(n)&&n.contentDocument)return jw(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=If(n).getElementById(r);if(i)return i}}return n}qi(jw,"getActiveElement");function yw(e){return e.tagName==="IFRAME"}qi(yw,"isFrame");var UC=Object.defineProperty,Rp=(e,t)=>UC(e,"name",{value:t,configurable:!0});function Mf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Rp(Mf,"setRef");function ww(...e){return t=>{let n=!1;const r=e.map(i=>{const l=Mf(i,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let i=0;i<r.length;i++){const l=r[i];typeof l=="function"?l():Mf(e[i],null)}}}}Rp(ww,"composeRefs");function Ge(...e){return d.useCallback(ww(...e),e)}Rp(Ge,"useComposedRefs");var BC=Object.defineProperty,yn=(e,t)=>BC(e,"name",{value:t,configurable:!0});function zC(e,t){const n=d.createContext(t);n.displayName=e+"Context";const r=yn(l=>{const{children:o,...a}=l,c=d.useMemo(()=>a,Object.values(a));return s.jsx(n.Provider,{value:c,children:o})},"Provider");r.displayName=e+"Provider";function i(l,o={}){const{optional:a=!1}=o,c=d.useContext(n);if(c)return c;if(t!==void 0)return t;if(!a)throw new Error(`\`${l}\` must be used within \`${e}\``)}return yn(i,"useContext"),[r,i]}yn(zC,"createContext");function Un(e,t=[]){let n=[];function r(l,o){const a=d.createContext(o);a.displayName=l+"Context";const c=n.length;n=[...n,o];const u=yn(f=>{var x;const{scope:p,children:m,...j}=f,w=((x=p==null?void 0:p[e])==null?void 0:x[c])||a,b=d.useMemo(()=>j,Object.values(j));return s.jsx(w.Provider,{value:b,children:m})},"Provider");u.displayName=l+"Provider";function h(f,p,m={}){var x;const{optional:j=!1}=m,w=((x=p==null?void 0:p[e])==null?void 0:x[c])||a,b=d.useContext(w);if(b)return b;if(o!==void 0)return o;if(!j)throw new Error(`\`${f}\` must be used within \`${l}\``)}return yn(h,"useContext"),[u,h]}yn(r,"createContext");const i=yn(()=>{const l=n.map(o=>d.createContext(o));return yn(function(a){const c=(a==null?void 0:a[e])||l;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])},"useScope")},"createScope");return i.scopeName=e,[r,bw(i,...t)]}yn(Un,"createContextScope");function bw(...e){const t=e[0];if(e.length===1)return t;const n=yn(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return yn(function(l){const o=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(l)[`__scope${u}`];return{...a,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}yn(bw,"composeContextScopes");var WC=Object.defineProperty,Bn=(e,t)=>WC(e,"name",{value:t,configurable:!0});function sr(e){const t=d.forwardRef((n,r)=>{let{children:i,...l}=n,o=null,a=!1;const c=[];$f(i)&&typeof qo=="function"&&(i=qo(i._payload)),d.Children.forEach(i,p=>{var m;if(Ew(p)){a=!0;const j=p;let w="child"in j.props?j.props.child:j.props.children;$f(w)&&typeof qo=="function"&&(w=qo(w._payload)),o=VC(j,w),c.push((m=o==null?void 0:o.props)==null?void 0:m.children)}else c.push(p)}),o?o=d.cloneElement(o,void 0,c):!a&&d.Children.count(i)===1&&d.isValidElement(i)&&(o=i);const u=o?Cw(o):void 0,h=Ge(r,u);if(!o){if(i||i===0)throw new Error(a?GC(e):KC(e));return i}const f=Nw(l,o.props??{});return o.type!==d.Fragment&&(f.ref=r?h:u),d.cloneElement(o,f)});return t.displayName=`${e}.Slot`,t}Bn(sr,"createSlot");var kw=Symbol.for("radix.slottable");function Sw(e){const t=Bn(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=kw,t}Bn(Sw,"createSlottable");var VC=Bn((e,t)=>{if("child"in e.props){const n=e.props.child;return d.isValidElement(n)?d.cloneElement(n,void 0,e.props.children(n.props.children)):null}return d.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Nw(e,t){const n={...t};for(const r in t){const i=e[r],l=t[r];/^on[A-Z]/.test(r)?i&&l?n[r]=(...a)=>{const c=l(...a);return i(...a),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...l}:r==="className"&&(n[r]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}Bn(Nw,"mergeProps");function Cw(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Bn(Cw,"getElementRef");function Ew(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kw}Bn(Ew,"isSlottable");var HC=Symbol.for("react.lazy");function $f(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===HC&&"_payload"in e&&Aw(e._payload)}Bn($f,"isLazyComponent");function Aw(e){return typeof e=="object"&&e!==null&&"then"in e}Bn(Aw,"isPromiseLike");var KC=Bn(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),GC=Bn(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),qo=Ki[" use ".trim().toString()],YC=Object.defineProperty,dt=(e,t)=>YC(e,"name",{value:t,configurable:!0});function Kc(e){const t=e+"CollectionProvider",[n,r]=Un(t),[i,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=dt(w=>{const{scope:b,children:x}=w,v=d.useRef(null),y=d.useRef(new Map).current;return s.jsx(i,{scope:b,itemMap:y,collectionRef:v,children:x})},"CollectionProvider");o.displayName=t;const a=e+"CollectionSlot",c=sr(a),u=d.forwardRef((w,b)=>{const{scope:x,children:v}=w,y=l(a,x),g=Ge(b,y.collectionRef);return s.jsx(c,{ref:g,children:v})});u.displayName=a;const h=e+"CollectionItemSlot",f="data-radix-collection-item",p=sr(h),m=d.forwardRef((w,b)=>{const{scope:x,children:v,...y}=w,g=d.useRef(null),S=Ge(b,g),k=l(h,x);return d.useEffect(()=>(k.itemMap.set(g,{ref:g,...y}),()=>void k.itemMap.delete(g))),s.jsx(p,{[f]:"",ref:S,children:v})});m.displayName=h;function j(w){const b=l(e+"CollectionConsumer",w);return d.useCallback(()=>{const v=b.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((k,N)=>y.indexOf(k.ref.current)-y.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return dt(j,"useCollection"),[{Provider:o,Slot:u,ItemSlot:m},j,r]}dt(Kc,"createCollection");var Cx=new WeakMap,tt,rn,Qu=(rn=class extends Map{constructor(n){super(n);gg(this,tt);ku(this,tt,[...super.keys()]),Cx.set(this,!0)}set(n,r){return Cx.get(this)&&(this.has(n)?Et(this,tt)[Et(this,tt).indexOf(n)]=n:Et(this,tt).push(n)),super.set(n,r),this}insert(n,r,i){const l=this.has(r),o=Et(this,tt).length,a=Tp(n);let c=a>=0?a:o+a;const u=c<0||c>=o?-1:c;if(u===this.size||l&&u===this.size-1||u===-1)return this.set(r,i),this;const h=this.size+(l?0:1);a<0&&c++;const f=[...Et(this,tt)];let p,m=!1;for(let j=c;j<h;j++)if(c===j){let w=f[j];f[j]===r&&(w=f[j+1]),l&&this.delete(r),p=this.get(w),this.set(r,i)}else{!m&&f[j-1]===r&&(m=!0);const w=f[m?j:j-1],b=p;p=this.get(w),this.delete(w),this.set(w,b)}return this}with(n,r,i){const l=new rn(this);return l.insert(n,r,i),l}before(n){const r=Et(this,tt).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,i){const l=Et(this,tt).indexOf(n);return l===-1?this:this.insert(l,r,i)}after(n){let r=Et(this,tt).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,i){const l=Et(this,tt).indexOf(n);return l===-1?this:this.insert(l+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return ku(this,tt,[]),super.clear()}delete(n){const r=super.delete(n);return r&&Et(this,tt).splice(Et(this,tt).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=Ta(Et(this,tt),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=Ta(Et(this,tt),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return Et(this,tt).indexOf(n)}keyAt(n){return Ta(Et(this,tt),n)}from(n,r){const i=this.indexOf(n);if(i===-1)return;let l=i+r;return l<0&&(l=0),l>=this.size&&(l=this.size-1),this.at(l)}keyFrom(n,r){const i=this.indexOf(n);if(i===-1)return;let l=i+r;return l<0&&(l=0),l>=this.size&&(l=this.size-1),this.keyAt(l)}find(n,r){let i=0;for(const l of this){if(Reflect.apply(n,r,[l,i,this]))return l;i++}}findIndex(n,r){let i=0;for(const l of this){if(Reflect.apply(n,r,[l,i,this]))return i;i++}return-1}filter(n,r){const i=[];let l=0;for(const o of this)Reflect.apply(n,r,[o,l,this])&&i.push(o),l++;return new rn(i)}map(n,r){const i=[];let l=0;for(const o of this)i.push([o[0],Reflect.apply(n,r,[o,l,this])]),l++;return new rn(i)}reduce(...n){const[r,i]=n;let l=0,o=i??this.at(0);for(const a of this)l===0&&n.length===1?o=a:o=Reflect.apply(r,this,[o,a,l,this]),l++;return o}reduceRight(...n){const[r,i]=n;let l=i??this.at(-1);for(let o=this.size-1;o>=0;o--){const a=this.at(o);o===this.size-1&&n.length===1?l=a:l=Reflect.apply(r,this,[l,a,o,this])}return l}toSorted(n){const r=[...this.entries()].sort(n);return new rn(r)}toReversed(){const n=new rn;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),l=this.get(i);n.set(i,l)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new rn(r)}slice(n,r){const i=new rn;let l=this.size-1;if(n===void 0)return i;n<0&&(n=n+this.size),r!==void 0&&r>0&&(l=r-1);for(let o=n;o<=l;o++){const a=this.keyAt(o),c=this.get(a);i.set(a,c)}return i}every(n,r){let i=0;for(const l of this){if(!Reflect.apply(n,r,[l,i,this]))return!1;i++}return!0}some(n,r){let i=0;for(const l of this){if(Reflect.apply(n,r,[l,i,this]))return!0;i++}return!1}},tt=new WeakMap,dt(rn,"OrderedDict"),rn);function Ta(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Rw(e,t);return n===-1?void 0:e[n]}dt(Ta,"at");function Rw(e,t){const n=e.length,r=Tp(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}dt(Rw,"toSafeIndex");function Tp(e){return e!==e||e===0?0:Math.trunc(e)}dt(Tp,"toSafeInteger");function qC(e){const t=e+"CollectionProvider",[n,r]=Un(t),[i,l]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Qu,setItemMap:dt(()=>{},"setItemMap")}),o=dt(({state:y,...g})=>y?s.jsx(c,{...g,state:y}):s.jsx(a,{...g}),"CollectionProvider");o.displayName=t;const a=dt(y=>{const g=b();return s.jsx(c,{...y,state:g})},"CollectionInit");a.displayName=t+"Init";const c=dt(y=>{const{scope:g,children:S,state:k}=y,N=d.useRef(null),[C,T]=d.useState(null),E=Ge(N,T),[U,H]=k;return d.useEffect(()=>{if(!C)return;const O=Iw(()=>{});return O.observe(C,{childList:!0,subtree:!0}),()=>{O.disconnect()}},[C]),s.jsx(i,{scope:g,itemMap:U,setItemMap:H,collectionRef:E,collectionRefObject:N,collectionElement:C,children:S})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",h=sr(u),f=d.forwardRef((y,g)=>{const{scope:S,children:k}=y,N=l(u,S),C=Ge(g,N.collectionRef);return s.jsx(h,{ref:C,children:k})});f.displayName=u;const p=e+"CollectionItemSlot",m="data-radix-collection-item",j=sr(p),w=d.forwardRef((y,g)=>{const{scope:S,children:k,...N}=y,C=d.useRef(null),[T,E]=d.useState(null),U=Ge(g,C,E),H=l(p,S),{setItemMap:O}=H,R=d.useRef(N);Tw(R.current,N)||(R.current=N);const F=R.current;return d.useEffect(()=>{const K=F;return O(L=>T?L.has(T)?L.set(T,{...K,element:T}).toSorted(_f):(L.set(T,{...K,element:T}),L.toSorted(_f)):L),()=>{O(L=>!T||!L.has(T)?L:(L.delete(T),new Qu(L)))}},[T,F,O]),s.jsx(j,{[m]:"",ref:U,children:k})});w.displayName=p;function b(){return d.useState(new Qu)}dt(b,"useInitCollection");function x(y){const{itemMap:g}=l(e+"CollectionConsumer",y);return g}return dt(x,"useCollection"),[{Provider:o,Slot:f,ItemSlot:w},{createCollectionScope:r,useCollection:x,useInitCollection:b}]}dt(qC,"createCollection");function Tw(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}dt(Tw,"shallowEqual");function Pw(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}dt(Pw,"isElementPreceding");function _f(e,t){return!e[1].element||!t[1].element?0:Pw(e[1].element,t[1].element)?-1:1}dt(_f,"sortByDocumentPosition");function Iw(e){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){e();return}})}dt(Iw,"getChildListObserver");var QC=Object.defineProperty,JC=(e,t)=>QC(e,"name",{value:t,configurable:!0}),XC=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qe=XC.reduce((e,t)=>{const n=sr(`Primitive.${t}`),r=d.forwardRef((i,l)=>{const{asChild:o,...a}=i,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...a,ref:l})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Gc(e,t){e&&$i.flushSync(()=>e.dispatchEvent(t))}JC(Gc,"dispatchDiscreteCustomEvent");var ZC=Object.defineProperty,eE=(e,t)=>ZC(e,"name",{value:t,configurable:!0});function Ln(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}eE(Ln,"useCallbackRef");var tE=Object.defineProperty,ot=(e,t)=>tE(e,"name",{value:t,configurable:!0}),Of="dismissableLayer.update",nE="dismissableLayer.pointerDownOutside",sE="dismissableLayer.focusOutside",Ex,Pp=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ip=d.forwardRef(ot(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:c,onDismiss:u,...h}=t,f=d.useContext(Pp),[p,m]=d.useState(null),j=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=d.useState({}),b=Ge(n,m),x=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=v?x.indexOf(v):-1,g=p?x.indexOf(p):-1,S=f.layersWithOutsidePointerEventsDisabled.size>0,k=g>=y,N=d.useRef(!1),C=$w(H=>{o==null||o(H),c==null||c(H),H.defaultPrevented||u==null||u()},{ownerDocument:j,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:N,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(H=>{if(!(H instanceof Node))return!1;const O=[...f.branches].some(R=>R.contains(H));return k&&!O},[f.branches,k])}),T=_w(H=>{if(i&&N.current)return;const O=H.target;[...f.branches].some(F=>F.contains(O))||(a==null||a(H),c==null||c(H),H.defaultPrevented||u==null||u())},j),E=p?g===x.length-1:!1,U=Ln(H=>{H.key==="Escape"&&(l==null||l(H),!H.defaultPrevented&&u&&(H.preventDefault(),u()))});return d.useEffect(()=>{if(E)return j.addEventListener("keydown",U,{capture:!0}),()=>j.removeEventListener("keydown",U,{capture:!0})},[j,E,U]),d.useEffect(()=>{if(p)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Ex=j.body.style.pointerEvents,j.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),Df(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(j.body.style.pointerEvents=Ex))}},[p,j,r,f]),d.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),Df())},[p,f]),d.useEffect(()=>{const H=ot(()=>w({}),"handleUpdate");return document.addEventListener(Of,H),()=>document.removeEventListener(Of,H)},[]),s.jsx(qe.div,{...h,ref:b,style:{pointerEvents:S?k?"auto":"none":void 0,...t.style},onFocusCapture:je(t.onFocusCapture,T.onFocusCapture),onBlurCapture:je(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:je(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),rE=d.forwardRef(ot(function(t,n){const r=d.useContext(Pp),i=d.useRef(null),l=Ge(n,i);return d.useEffect(()=>{const o=i.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),s.jsx(qe.div,{...t,ref:l})},"DismissableLayerBranch"));function Mw(){const e=d.useContext(Pp),[t,n]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}ot(Mw,"useDismissableLayerSurface");var iE=ot(()=>!0,"IS_TRUE");function $w(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:l,shouldHandlePointerDownOutside:o=iE}=t,a=Ln(e),c=d.useRef(!1),u=d.useRef(!1),h=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function p(){u.current=!1,i.current=!1,h.current.clear()}ot(p,"resetOutsideInteraction");function m(){return Array.from(h.current.values()).some(Boolean)}ot(m,"isOutsideInteractionIntercepted");function j(y){if(!u.current)return;const g=y.target;g instanceof Node&&[...l].some(k=>k.contains(g))||h.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}ot(j,"handleInteractionCapture");function w(y){u.current&&h.current.set(y.type,!1)}ot(w,"handleInteractionBubble");const b=ot(y=>{if(y.target&&!c.current){let g=function(){n.removeEventListener("click",f.current);const k=m();p(),k||Mp(nE,a,S,{discrete:!0})};if(ot(g,"handleAndDispatchPointerDownOutsideEvent"),!o(y.target)){n.removeEventListener("click",f.current),p(),c.current=!1;return}const S={originalEvent:y};u.current=!0,i.current=r&&y.button===0,h.current.clear(),!r||y.button!==0?g():(n.removeEventListener("click",f.current),f.current=g,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),p();c.current=!1},"handlePointerDown"),x=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of x)n.addEventListener(y,j,!0),n.addEventListener(y,w);const v=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",b),n.removeEventListener("click",f.current);for(const y of x)n.removeEventListener(y,j,!0),n.removeEventListener(y,w)}},[n,a,r,i,l,o]),{onPointerDownCapture:ot(()=>c.current=!0,"onPointerDownCapture")}}ot($w,"usePointerDownOutside");function _w(e,t=globalThis==null?void 0:globalThis.document){const n=Ln(e),r=d.useRef(!1);return d.useEffect(()=>{const i=ot(l=>{l.target&&!r.current&&Mp(sE,n,{originalEvent:l},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:ot(()=>r.current=!0,"onFocusCapture"),onBlurCapture:ot(()=>r.current=!1,"onBlurCapture")}}ot(_w,"useFocusOutside");function Df(){const e=new CustomEvent(Of);document.dispatchEvent(e)}ot(Df,"dispatchUpdate");function Mp(e,t,n,{discrete:r}){const i=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Gc(i,l):i.dispatchEvent(l)}ot(Mp,"handleAndDispatchCustomEvent");var lE=rE,Qt=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},oE=Object.defineProperty,aE=(e,t)=>oE(e,"name",{value:t,configurable:!0}),$p=d.forwardRef(aE(function(t,n){var c;const{container:r,...i}=t,[l,o]=d.useState(!1);Qt(()=>o(!0),[]);const a=r||l&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?$i.createPortal(s.jsx(qe.div,{...i,ref:n}),a):null},"Portal")),cE=Object.defineProperty,Ss=(e,t)=>cE(e,"name",{value:t,configurable:!0});function Ow(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}Ss(Ow,"useStateMachine");var ur=Ss(e=>{const{present:t,children:n}=e,r=Dw(t),i=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),l=Lw(r.ref,Fw(i));return typeof n=="function"||r.isPresent?d.cloneElement(i,{ref:l}):null},"Presence");function Dw(e){const[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),l=d.useRef("none"),o=d.useRef(void 0),a=e?"mounted":"unmounted",[c,u]=Ow(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{c==="mounted"?(l.current=o.current??si(r.current),o.current=void 0):l.current="none"},[c]),Qt(()=>{const h=r.current,f=i.current;if(f!==e){const m=l.current,j=si(h);e?(o.current=j,u("MOUNT")):j==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&m!==j?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Qt(()=>{if(t){let h;const f=t.ownerDocument.defaultView??window,p=Ss(j=>{const b=si(r.current).includes(CSS.escape(j.animationName));if(j.target===t&&b&&(u("ANIMATION_END"),!i.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",h=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},"handleAnimationEnd"),m=Ss(j=>{j.target===t&&(l.current=si(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(h),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:d.useCallback(h=>{if(h){const f=getComputedStyle(h);r.current=f,o.current=si(f)}else r.current=null;n(h)},[])}}Ss(Dw,"usePresence");function Lf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Ss(Lf,"setRef");function Lw(...e){const t=d.useRef(e);return t.current=e,d.useCallback(n=>{const r=t.current;let i=!1;const l=r.map(o=>{const a=Lf(o,n);return!i&&typeof a=="function"&&(i=!0),a});if(i)return()=>{for(let o=0;o<l.length;o++){const a=l[o];typeof a=="function"?a():Lf(r[o],null)}}},[])}Ss(Lw,"useStableComposedRefs");function si(e){return(e==null?void 0:e.animationName)||"none"}Ss(si,"getAnimationName");function Fw(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Ss(Fw,"getElementRef");var uE=Object.defineProperty,dE=(e,t)=>uE(e,"name",{value:t,configurable:!0}),Ax=Ki[" useEffectEvent ".trim().toString()],Rx=Ki[" useInsertionEffect ".trim().toString()];function Uw(e){if(typeof Ax=="function")return Ax(e);const t=d.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Rx=="function"?Rx(()=>{t.current=e}):Qt(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}dE(Uw,"useEffectEvent");var fE=Object.defineProperty,po=(e,t)=>fE(e,"name",{value:t,configurable:!0}),hE=Ki[" useInsertionEffect ".trim().toString()]||Qt;function Qi({prop:e,defaultProp:t,onChange:n=po(()=>{},"onChange"),caller:r}){const[i,l,o]=Bw({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:i,u=d.useCallback(h=>{var f;if(a){const p=zw(h)?h(e):h;p!==e&&((f=o.current)==null||f.call(o,p))}else l(h)},[a,e,l,o]);return[c,u]}po(Qi,"useControllableState");function Bw({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),i=d.useRef(n),l=d.useRef(t);return hE(()=>{l.current=t},[t]),d.useEffect(()=>{var o;i.current!==n&&((o=l.current)==null||o.call(l,n),i.current=n)},[n,i]),[n,r,l]}po(Bw,"useUncontrolledState");function zw(e){return typeof e=="function"}po(zw,"isFunction");var Tx=Symbol("RADIX:SYNC_STATE");function pE(e,t,n,r){const{prop:i,defaultProp:l,onChange:o,caller:a}=t,c=i!==void 0,u=Uw(o),h=[{...n,state:l}];r&&h.push(r);const[f,p]=d.useReducer((b,x)=>{if(x.type===Tx)return{...b,state:x.state};const v=e(b,x);return c&&!Object.is(v.state,b.state)&&u(v.state),v},...h),m=f.state,j=d.useRef(m);d.useEffect(()=>{j.current!==m&&(j.current=m,c||u(m))},[m,j,c]);const w=d.useMemo(()=>i!==void 0?{...f,state:i}:f,[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&p({type:Tx,state:i})},[i,f.state,c]),[w,p]}po(pE,"useControllableStateReducer");var mE=Object.defineProperty,gE=(e,t)=>mE(e,"name",{value:t,configurable:!0}),xE=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Ww=d.forwardRef(gE(function(t,n){return s.jsx(qe.span,{...t,ref:n,style:{...xE,...t.style}})},"VisuallyHidden")),vE=Ww,jE=Object.defineProperty,Tt=(e,t)=>jE(e,"name",{value:t,configurable:!0}),Vw="ToastProvider",[Hw,yE,wE]=Kc("Toast"),[Kw,s3]=Un("Toast",[wE]),[bE,Gw]=Kw(Vw),kE=Tt(e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:l=50,announcerContainer:o,children:a}=e,[c,u]=d.useState(null),[h,f]=d.useState(0),p=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Vw}\`. Expected non-empty \`string\`.`),s.jsx(Hw.Provider,{scope:t,children:s.jsx(bE,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:l,toastCount:h,viewport:c,onViewportChange:u,onToastAdd:d.useCallback(()=>f(m=>m+1),[]),onToastRemove:d.useCallback(()=>f(m=>m-1),[]),isClosePausedRef:p,announcerContainer:o,children:a})})},"ToastProvider"),SE="ToastViewport",NE=["F8"],CE="toast.viewportPause",EE="toast.viewportResume",AE=d.forwardRef(Tt(function(t,n){const{__scopeToast:r,hotkey:i=NE,label:l="Notifications ({hotkey})",...o}=t,a=Gw(SE,r),c=yE(r),u=d.useRef(null),h=d.useRef(null),f=d.useRef(null),p=d.useRef(null),m=Ge(n,p,a.onViewportChange),j=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=a.toastCount>0;d.useEffect(()=>{const x=Tt(v=>{var g;i.length!==0&&i.every(S=>v[S]||v.code===S)&&((g=p.current)==null||g.focus())},"handleKeyDown");return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[i]),d.useEffect(()=>{const x=u.current,v=p.current;if(w&&x&&v){const y=Tt(()=>{if(!a.isClosePausedRef.current){const N=new CustomEvent(CE);v.dispatchEvent(N),a.isClosePausedRef.current=!0}},"handlePause"),g=Tt(()=>{if(a.isClosePausedRef.current){const N=new CustomEvent(EE);v.dispatchEvent(N),a.isClosePausedRef.current=!1}},"handleResume"),S=Tt(N=>{!x.contains(N.relatedTarget)&&g()},"handleFocusOutResume"),k=Tt(()=>{x.contains(document.activeElement)||g()},"handlePointerLeaveResume");return x.addEventListener("focusin",y),x.addEventListener("focusout",S),x.addEventListener("pointermove",y),x.addEventListener("pointerleave",k),window.addEventListener("blur",y),window.addEventListener("focus",g),()=>{x.removeEventListener("focusin",y),x.removeEventListener("focusout",S),x.removeEventListener("pointermove",y),x.removeEventListener("pointerleave",k),window.removeEventListener("blur",y),window.removeEventListener("focus",g)}}},[w,a.isClosePausedRef]);const b=d.useCallback(({tabbingDirection:x})=>{const y=c().map(g=>{const S=g.ref.current,k=[S,...Qw(S)];return x==="forwards"?k:k.reverse()});return(x==="forwards"?y.reverse():y).flat()},[c]);return d.useEffect(()=>{const x=p.current;if(x){const v=Tt(y=>{var k,N,C;const g=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!g){const T=document.activeElement,E=y.shiftKey;if(y.target===x&&E){(k=h.current)==null||k.focus();return}const O=b({tabbingDirection:E?"backwards":"forwards"}),R=O.findIndex(F=>F===T);Pa(O.slice(R+1))?y.preventDefault():E?(N=h.current)==null||N.focus():(C=f.current)==null||C.focus()}},"handleKeyDown");return x.addEventListener("keydown",v),()=>x.removeEventListener("keydown",v)}},[c,b]),s.jsxs(lE,{ref:u,role:"region","aria-label":l.replace("{hotkey}",j),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&s.jsx(Px,{ref:h,onFocusFromOutsideViewport:()=>{const x=b({tabbingDirection:"forwards"});Pa(x)}}),s.jsx(Hw.Slot,{scope:r,children:s.jsx(qe.ol,{tabIndex:-1,...o,ref:m})}),w&&s.jsx(Px,{ref:f,onFocusFromOutsideViewport:()=>{const x=b({tabbingDirection:"backwards"});Pa(x)}})]})},"ToastViewport")),RE="ToastFocusProxy",Px=d.forwardRef(Tt(function(t,n){const{__scopeToast:r,onFocusFromOutsideViewport:i,...l}=t,o=Gw(RE,r);return s.jsx(Ww,{tabIndex:0,...l,ref:n,style:{position:"fixed"},onFocus:a=>{var h;const c=a.relatedTarget;!((h=o.viewport)!=null&&h.contains(c))&&i()}})},"ToastFocusProxy")),TE="Toast",[r3,i3]=Kw(TE,{onClose(){}});function Yw(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),qw(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",l=r.dataset.radixToastAnnounceExclude==="";if(!i)if(l){const o=r.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...Yw(r))}}),t}Tt(Yw,"getAnnounceTextContent");function PE(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,l=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Gc(i,l):i.dispatchEvent(l)}Tt(PE,"handleAndDispatchCustomEvent");function IE(e=()=>{}){const t=Ln(e);Qt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}Tt(IE,"useNextFrame");function qw(e){return e.nodeType===e.ELEMENT_NODE}Tt(qw,"isHTMLElement");function Qw(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Tt(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Tt(Qw,"getTabbableCandidates");function Pa(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}Tt(Pa,"focusFirst");var Ix=kE,Mx=AE,ME=Object.defineProperty,$E=(e,t)=>ME(e,"name",{value:t,configurable:!0}),_E=Ki[" useId ".trim().toString()]||(()=>{}),OE=0;function xs(e){const[t,n]=d.useState(_E());return Qt(()=>{e||n(r=>r??String(OE++))},[e]),e||(t?`radix-${t}`:"")}$E(xs,"useId");const DE=["top","right","bottom","left"],rr=Math.min,vs=Math.max,dc=Math.round,Qo=Math.floor,js=e=>({x:e,y:e}),LE={left:"right",right:"left",bottom:"top",top:"bottom"};function Jw(e,t,n){return vs(e,rr(t,n))}function Ns(e,t){return typeof e=="function"?e(t):e}function ir(e){return e.split("-")[0]}function Ji(e){return e.split("-")[1]}function _p(e){return e==="x"?"y":"x"}function Op(e){return e==="y"?"height":"width"}function Jn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Dp(e){return _p(Jn(e))}function FE(e,t,n){n===void 0&&(n=!1);const r=Ji(e),i=Dp(e),l=Op(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(o=fc(o)),[o,fc(o)]}function UE(e){const t=fc(e);return[Ff(e),t,Ff(t)]}function Ff(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const $x=["left","right"],_x=["right","left"],BE=["top","bottom"],zE=["bottom","top"];function WE(e,t,n){switch(e){case"top":case"bottom":return n?t?_x:$x:t?$x:_x;case"left":case"right":return t?BE:zE;default:return[]}}function VE(e,t,n,r){const i=Ji(e);let l=WE(ir(e),n==="start",r);return i&&(l=l.map(o=>o+"-"+i),t&&(l=l.concat(l.map(Ff)))),l}function fc(e){const t=ir(e);return LE[t]+e.slice(t.length)}function HE(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function Xw(e){return typeof e!="number"?HE(e):{top:e,right:e,bottom:e,left:e}}function hc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ox(e,t,n){let{reference:r,floating:i}=e;const l=Jn(t),o=Dp(t),a=Op(o),c=ir(t),u=l==="y",h=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,p=r[a]/2-i[a]/2;let m;switch(c){case"top":m={x:h,y:r.y-i.height};break;case"bottom":m={x:h,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-i.width,y:f};break;default:m={x:r.x,y:r.y}}const j=Ji(t);return j&&(m[o]+=p*(j==="end"?1:-1)*(n&&u?-1:1)),m}async function KE(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:l,rects:o,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=Ns(t,e),j=Xw(m),b=a[p?f==="floating"?"reference":"floating":f],x=hc(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(b)))==null||n?b:b.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(a.floating)),boundary:u,rootBoundary:h,strategy:c})),v=f==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(l.getOffsetParent==null?void 0:l.getOffsetParent(a.floating)),g=await(l.isElement==null?void 0:l.isElement(y))&&await(l.getScale==null?void 0:l.getScale(y))||{x:1,y:1},S=hc(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:c}):v);return{top:(x.top-S.top+j.top)/g.y,bottom:(S.bottom-x.bottom+j.bottom)/g.y,left:(x.left-S.left+j.left)/g.x,right:(S.right-x.right+j.right)/g.x}}const GE=50,YE=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:l=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:KE},c=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:f}=Ox(u,r,c),p=r,m=0;const j={};for(let w=0;w<l.length;w++){const b=l[w];if(!b)continue;const{name:x,fn:v}=b,{x:y,y:g,data:S,reset:k}=await v({x:h,y:f,initialPlacement:r,placement:p,strategy:i,middlewareData:j,rects:u,platform:a,elements:{reference:e,floating:t}});h=y??h,f=g??f,j[x]={...j[x],...S},k&&m<GE&&(m++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(u=k.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:h,y:f}=Ox(u,p,c)),w=-1)}return{x:h,y:f,placement:p,strategy:i,middlewareData:j}},qE=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:l,platform:o,elements:a,middlewareData:c}=t,{element:u,padding:h=0}=Ns(e,t)||{};if(u==null)return{};const f=Xw(h),p={x:n,y:r},m=Dp(i),j=Op(m),w=await o.getDimensions(u),b=m==="y",x=b?"top":"left",v=b?"bottom":"right",y=b?"clientHeight":"clientWidth",g=l.reference[j]+l.reference[m]-p[m]-l.floating[j],S=p[m]-l.reference[m],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let N=k?k[y]:0;(!N||!await(o.isElement==null?void 0:o.isElement(k)))&&(N=a.floating[y]||l.floating[j]);const C=g/2-S/2,T=N/2-w[j]/2-1,E=rr(f[x],T),U=rr(f[v],T),H=N-w[j]-U,O=N/2-w[j]/2+C,R=Jw(E,O,H),F=!c.arrow&&Ji(i)!=null&&O!==R&&l.reference[j]/2-(O<E?E:U)-w[j]/2<0,K=F?O<E?O-E:O-H:0;return{[m]:p[m]+K,data:{[m]:R,centerOffset:O-R-K,...F&&{alignmentOffset:K}},reset:F}}}),QE=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:l,rects:o,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:w=!0,...b}=Ns(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const x=ir(i),v=Jn(a),y=ir(a)===a,g=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(y||!w?[fc(a)]:UE(a)),k=j!=="none";!p&&k&&S.push(...VE(a,w,j,g));const N=[a,...S],C=await c.detectOverflow(t,b),T=[];let E=((r=l.flip)==null?void 0:r.overflows)||[];if(h&&T.push(C[x]),f){const R=FE(i,o,g);T.push(C[R[0]],C[R[1]])}if(E=[...E,{placement:i,overflows:T}],!T.every(R=>R<=0)){var U,H;const R=(((U=l.flip)==null?void 0:U.index)||0)+1,F=N[R];if(F&&(!(f==="alignment"?v!==Jn(F):!1)||E.every(M=>Jn(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:R,overflows:E},reset:{placement:F}};let K=(H=E.filter(L=>L.overflows[0]<=0).sort((L,M)=>L.overflows[1]-M.overflows[1])[0])==null?void 0:H.placement;if(!K)switch(m){case"bestFit":{var O;const L=(O=E.filter(M=>{if(k){const V=Jn(M.placement);return V===v||V==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(V=>V>0).reduce((V,$)=>V+$,0)]).sort((M,V)=>M[1]-V[1])[0])==null?void 0:O[0];L&&(K=L);break}case"initialPlacement":K=a;break}if(i!==K)return{reset:{placement:K}}}return{}}}};function Dx(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Lx(e){return DE.some(t=>e[t]>=0)}const JE=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...l}=Ns(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...l,elementContext:"reference"}),a=Dx(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Lx(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...l,altBoundary:!0}),a=Dx(o,n.floating);return{data:{escapedOffsets:a,escaped:Lx(a)}}}default:return{}}}}},Zw=new Set(["left","top"]);async function XE(e,t){const{placement:n,platform:r,elements:i}=e,l=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ir(n),a=Ji(n),c=Jn(n)==="y",u=Zw.has(o)?-1:1,h=l&&c?-1:1,f=Ns(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:j}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof j=="number"&&(m=a==="end"?j*-1:j),c?{x:m*h,y:p*u}:{x:p*u,y:m*h}}const ZE=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:l,placement:o,middlewareData:a}=t,c=await XE(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:l+c.y,data:{...c,placement:o}}}}},eA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:l}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:c={fn:v=>{let{x:y,y:g}=v;return{x:y,y:g}}},...u}=Ns(e,t),h={x:n,y:r},f=await l.detectOverflow(t,u),p=Jn(i),m=_p(p);let j=h[m],w=h[p];const b=(v,y)=>Jw(y+f[v==="y"?"top":"left"],y,y-f[v==="y"?"bottom":"right"]);o&&(j=b(m,j)),a&&(w=b(p,w));const x=c.fn({...t,[m]:j,[p]:w});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[m]:o,[p]:a}}}}}},tA=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:l,placement:o,rects:a,middlewareData:c}=t,{offset:u=0,mainAxis:h=!0,crossAxis:f=!0}=Ns(e,t),p={x:i,y:l},m=Jn(o),j=_p(m);let w=p[j],b=p[m];const x=Ns(u,t),v=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:(n=x.mainAxis)!=null?n:0,crossAxis:(r=x.crossAxis)!=null?r:0};if(h){const S=j==="y"?"height":"width",k=a.reference[j]-a.floating[S]+v.mainAxis,N=a.reference[j]+a.reference[S]-v.mainAxis;w<k?w=k:w>N&&(w=N)}if(f){var y,g;const S=j==="y"?"width":"height",k=Zw.has(ir(o)),N=a.reference[m]-a.floating[S]+(k&&((y=c.offset)==null?void 0:y[m])||0)+(k?0:v.crossAxis),C=a.reference[m]+a.reference[S]+(k?0:((g=c.offset)==null?void 0:g[m])||0)-(k?v.crossAxis:0);b<N?b=N:b>C&&(b=C)}return{[j]:w,[m]:b}}}},nA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:l}=t,{apply:o=()=>{},...a}=Ns(e,t),c=await i.detectOverflow(t,a),u=ir(n),h=Ji(n),f=Jn(n)==="y",{width:p,height:m}=r.floating;let j,w;u==="top"||u==="bottom"?(j=u,w=h===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(w=u,j=h==="end"?"top":"bottom");const b=m-c.top-c.bottom,x=p-c.left-c.right,v=rr(m-c[j],b),y=rr(p-c[w],x),g=t.middlewareData.shift,S=!g;let k=v,N=y;g!=null&&g.enabled.x&&(N=x),g!=null&&g.enabled.y&&(k=b),S&&!h&&(f?N=p-2*vs(c.left,c.right):k=m-2*vs(c.top,c.bottom)),await o({...t,availableWidth:N,availableHeight:k});const C=await i.getDimensions(l.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}};function Yc(){return typeof window<"u"}function Xi(e){return eb(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ts(e){var t;return(t=(eb(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function eb(e){return Yc()?e instanceof Node||e instanceof Jt(e).Node:!1}function ss(e){return Yc()?e instanceof Element||e instanceof Jt(e).Element:!1}function dr(e){return Yc()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function Fx(e){return!Yc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}function qc(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=rs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function sA(e){return/^(table|td|th)$/.test(Xi(e))}function Qc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const rA=/transform|translate|scale|rotate|perspective|filter/,iA=/paint|layout|strict|content/,xr=e=>!!e&&e!=="none";let Ju;function Lp(e){const t=ss(e)?rs(e):e;return xr(t.transform)||xr(t.translate)||xr(t.scale)||xr(t.rotate)||xr(t.perspective)||!Fp()&&(xr(t.backdropFilter)||xr(t.filter))||rA.test(t.willChange||"")||iA.test(t.contain||"")}function lA(e){let t=Ir(e);for(;dr(t)&&!Xl(t);){if(Lp(t))return t;if(Qc(t))return null;t=Ir(t)}return null}function Fp(){return Ju==null&&(Ju=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ju}function Xl(e){return/^(html|body|#document)$/.test(Xi(e))}function rs(e){return Jt(e).getComputedStyle(e)}function Jc(e){return ss(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ir(e){if(Xi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Fx(e)&&e.host||Ts(e);return Fx(t)?t.host:t}function tb(e){const t=Ir(e);return Xl(t)?(e.ownerDocument||e).body:dr(t)&&qc(t)?t:tb(t)}function Zl(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=tb(e),l=i===((r=e.ownerDocument)==null?void 0:r.body),o=Jt(i);if(l){const a=Uf(o);return t.concat(o,o.visualViewport||[],qc(i)?i:[],a&&n?Zl(a):[])}else return t.concat(i,Zl(i,[],n))}function Uf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nb(e){const t=rs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=dr(e),l=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=dc(n)!==l||dc(r)!==o;return a&&(n=l,r=o),{width:n,height:r,$:a}}function Up(e){return ss(e)?e:e.contextElement}function ki(e){const t=Up(e);if(!dr(t))return js(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:l}=nb(t);let o=(l?dc(n.width):n.width)/r,a=(l?dc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const oA=js(0);function sb(e){const t=Jt(e);return!Fp()||!t.visualViewport?oA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function aA(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Jt(e)}function Mr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),l=Up(e);let o=js(1);t&&(r?ss(r)&&(o=ki(r)):o=ki(e));const a=aA(l,n,r)?sb(l):js(0);let c=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,h=i.width/o.x,f=i.height/o.y;if(l&&r){const p=Jt(l),m=ss(r)?Jt(r):r;let j=p,w=Uf(j);for(;w&&m!==j;){const b=ki(w),x=w.getBoundingClientRect(),v=rs(w),y=x.left+(w.clientLeft+parseFloat(v.paddingLeft))*b.x,g=x.top+(w.clientTop+parseFloat(v.paddingTop))*b.y;c*=b.x,u*=b.y,h*=b.x,f*=b.y,c+=y,u+=g,j=Jt(w),w=Uf(j)}}return hc({width:h,height:f,x:c,y:u})}function Xc(e,t){const n=Jc(e).scrollLeft;return t?t.left+n:Mr(Ts(e)).left+n}function rb(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Xc(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function cA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const l=i==="fixed",o=Ts(r),a=t?Qc(t.floating):!1;if(r===o||a&&l)return n;let c={scrollLeft:0,scrollTop:0},u=js(1);const h=js(0),f=dr(r);if((f||!l)&&((Xi(r)!=="body"||qc(o))&&(c=Jc(r)),f)){const m=Mr(r);u=ki(r),h.x=m.x+r.clientLeft,h.y=m.y+r.clientTop}const p=o&&!f&&!l?rb(o,c):js(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+h.x+p.x,y:n.y*u.y-c.scrollTop*u.y+h.y+p.y}}function uA(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function dA(e){const t=Jc(e),n=e.ownerDocument.body,r=vs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=vs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let l=-t.scrollLeft+Xc(e);const o=-t.scrollTop;return rs(n).direction==="rtl"&&(l+=vs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:l,y:o}}const fA=25;function hA(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=Jt(e),l=Ts(e),o=i.visualViewport;let a=l.clientWidth,c=l.clientHeight,u=0,h=0;if(o){const p=!Fp()||t==="fixed";r?p||(u=-o.offsetLeft,h=-o.offsetTop):(a=o.width,c=o.height,p&&(u=o.offsetLeft,h=o.offsetTop))}if(Xc(l)<=0){const p=l.ownerDocument,m=p.body,j=getComputedStyle(m),w=p.compatMode==="CSS1Compat"&&parseFloat(j.marginLeft)+parseFloat(j.marginRight)||0,b=Math.abs(l.clientWidth-m.clientWidth-w),x=getComputedStyle(l).scrollbarGutter==="stable both-edges"?b/2:b;x<=fA&&(a-=x)}return{width:a,height:c,x:u,y:h}}function pA(e,t){const n=Mr(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,l=ki(e),o=e.clientWidth*l.x,a=e.clientHeight*l.y,c=i*l.x,u=r*l.y;return{width:o,height:a,x:c,y:u}}function Ux(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=hA(e,n,t);else if(t==="document")r=dA(Ts(e));else if(ss(t))r=pA(t,n);else{const i=sb(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return hc(r)}function mA(e,t){const n=t.get(e);if(n)return n;let r=Zl(e,[],!1).filter(a=>ss(a)&&Xi(a)!=="body"),i=null;const l=rs(e).position==="fixed";let o=l?Ir(e):e;for(;ss(o)&&!Xl(o);){const a=rs(o),c=Lp(o),u=i?i.position:l?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&a.position==="static")?r=r.filter(f=>f!==o):i=a,o=Ir(o)}return t.set(e,r),r}function gA(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Qc(t)?[]:mA(t,this._c):[].concat(n),r],a=Ux(t,o[0],i);let c=a.top,u=a.right,h=a.bottom,f=a.left;for(let p=1;p<o.length;p++){const m=Ux(t,o[p],i);c=vs(m.top,c),u=rr(m.right,u),h=rr(m.bottom,h),f=vs(m.left,f)}return{width:u-f,height:h-c,x:f,y:c}}function xA(e){const{width:t,height:n}=nb(e);return{width:t,height:n}}function vA(e,t,n){const r=dr(t),i=Ts(t),l=n==="fixed",o=Mr(e,!0,l,t);let a={scrollLeft:0,scrollTop:0};const c=js(0);if((r||!l)&&((Xi(t)!=="body"||qc(i))&&(a=Jc(t)),r)){const p=Mr(t,!0,l,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}!r&&i&&(c.x=Xc(i));const u=i&&!r&&!l?rb(i,a):js(0),h=o.left+a.scrollLeft-c.x-u.x,f=o.top+a.scrollTop-c.y-u.y;return{x:h,y:f,width:o.width,height:o.height}}function Xu(e){return rs(e).position==="static"}function Bx(e,t){if(!dr(e)||rs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ts(e)===n&&(n=n.ownerDocument.body),n}function ib(e,t){const n=Jt(e);if(Qc(e))return n;if(!dr(e)){let i=Ir(e);for(;i&&!Xl(i);){if(ss(i)&&!Xu(i))return i;i=Ir(i)}return n}let r=Bx(e,t);for(;r&&sA(r)&&Xu(r);)r=Bx(r,t);return r&&Xl(r)&&Xu(r)&&!Lp(r)?n:r||lA(e)||n}const jA=async function(e){const t=this.getOffsetParent||ib,n=this.getDimensions,r=await n(e.floating);return{reference:vA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yA(e){return rs(e).direction==="rtl"}const wA={convertOffsetParentRelativeRectToViewportRelativeRect:cA,getDocumentElement:Ts,getClippingRect:gA,getOffsetParent:ib,getElementRects:jA,getClientRects:uA,getDimensions:xA,getScale:ki,isElement:ss,isRTL:yA};function lb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function bA(e,t,n){let r=null,i;const l=Ts(e);function o(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function a(h,f){h===void 0&&(h=!1),f===void 0&&(f=1),o();const p=e.getBoundingClientRect(),{left:m,top:j,width:w,height:b}=p;if(h||t(),!w||!b)return;const x=Qo(j),v=Qo(l.clientWidth-(m+w)),y=Qo(l.clientHeight-(j+b)),g=Qo(m),k={rootMargin:-x+"px "+-v+"px "+-y+"px "+-g+"px",threshold:vs(0,rr(1,f))||1};let N=!0;function C(T){const E=T[0].intersectionRatio;if(!lb(p,e.getBoundingClientRect()))return a();if(E!==f){if(!N)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}N=!1}try{r=new IntersectionObserver(C,{...k,root:l.ownerDocument})}catch{r=new IntersectionObserver(C,k)}r.observe(e)}const c=Jt(e),u=()=>a(n);return c.addEventListener("resize",u),a(!0),()=>{c.removeEventListener("resize",u),o()}}function kA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:l=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Up(e),h=i||l?[...u?Zl(u):[],...t?Zl(t):[]]:[];h.forEach(x=>{i&&x.addEventListener("scroll",n),l&&x.addEventListener("resize",n)});const f=u&&a?bA(u,n,l):null;let p=-1,m=null;o&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),t&&m.observe(t));let j,w=c?Mr(e):null;c&&b();function b(){const x=Mr(e);w&&!lb(w,x)&&n(),w=x,j=requestAnimationFrame(b)}return n(),()=>{var x;h.forEach(v=>{i&&v.removeEventListener("scroll",n),l&&v.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(j)}}const SA=ZE,NA=eA,CA=QE,EA=nA,AA=JE,zx=qE,RA=tA,TA=(e,t,n)=>{const r=new Map,i=n??{},l={...wA,...i.platform,_c:r};return YE(e,t,{...i,platform:l})};var PA=typeof document<"u",IA=function(){},Ia=PA?d.useLayoutEffect:IA;function pc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!pc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const l=i[r];if(!(l==="_owner"&&e.$$typeof)&&!pc(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function ob(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wx(e,t){const n=ob(e);return Math.round(t*n)/n}function Zu(e){const t=d.useRef(e);return Ia(()=>{t.current=e}),t}function MA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:l,floating:o}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[h,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=d.useState(r);pc(p,r)||m(r);const[j,w]=d.useState(null),[b,x]=d.useState(null),v=d.useCallback(M=>{M!==k.current&&(k.current=M,w(M))},[]),y=d.useCallback(M=>{M!==N.current&&(N.current=M,x(M))},[]),g=l||j,S=o||b,k=d.useRef(null),N=d.useRef(null),C=d.useRef(h),T=c!=null,E=Zu(c),U=Zu(i),H=Zu(u),O=d.useCallback(()=>{if(!k.current||!N.current)return;const M={placement:t,strategy:n,middleware:p};U.current&&(M.platform=U.current),TA(k.current,N.current,M).then(V=>{const $={...V,isPositioned:H.current!==!1};R.current&&!pc(C.current,$)&&(C.current=$,$i.flushSync(()=>{f($)}))})},[p,t,n,U,H]);Ia(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const R=d.useRef(!1);Ia(()=>(R.current=!0,()=>{R.current=!1}),[]),Ia(()=>{if(g&&(k.current=g),S&&(N.current=S),g&&S){if(E.current)return E.current(g,S,O);O()}},[g,S,O,E,T]);const F=d.useMemo(()=>({reference:k,floating:N,setReference:v,setFloating:y}),[v,y]),K=d.useMemo(()=>({reference:g,floating:S}),[g,S]),L=d.useMemo(()=>{const M={position:n,left:0,top:0};if(!K.floating)return M;const V=Wx(K.floating,h.x),$=Wx(K.floating,h.y);return a?{...M,transform:"translate("+V+"px, "+$+"px)",...ob(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:$}},[n,a,K.floating,h.x,h.y]);return d.useMemo(()=>({...h,update:O,refs:F,elements:K,floatingStyles:L}),[h,O,F,K,L])}const $A=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?zx({element:r.current,padding:i}).fn(n):{}:r?zx({element:r,padding:i}).fn(n):{}}}},_A=(e,t)=>{const n=SA(e);return{name:n.name,fn:n.fn,options:[e,t]}},OA=(e,t)=>{const n=NA(e);return{name:n.name,fn:n.fn,options:[e,t]}},DA=(e,t)=>({fn:RA(e).fn,options:[e,t]}),LA=(e,t)=>{const n=CA(e);return{name:n.name,fn:n.fn,options:[e,t]}},FA=(e,t)=>{const n=EA(e);return{name:n.name,fn:n.fn,options:[e,t]}},UA=(e,t)=>{const n=AA(e);return{name:n.name,fn:n.fn,options:[e,t]}},BA=(e,t)=>{const n=$A(e);return{name:n.name,fn:n.fn,options:[e,t]}};var zA=Object.defineProperty,WA=(e,t)=>zA(e,"name",{value:t,configurable:!0});function ab(e){const[t,n]=d.useState(void 0);return Qt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const l=i[0];let o,a;if("borderBoxSize"in l){const c=l.borderBoxSize,u=Array.isArray(c)?c[0]:c;o=u.inlineSize,a=u.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}WA(ab,"useSize");var VA=Object.defineProperty,Xs=(e,t)=>VA(e,"name",{value:t,configurable:!0}),cb="Popper",[ub,Zc]=Un(cb),[HA,db]=ub(cb),KA=Xs(e=>{const{__scopePopper:t,children:n}=e,[r,i]=d.useState(null),[l,o]=d.useState(void 0);return s.jsx(HA,{scope:t,anchor:r,onAnchorChange:i,placementState:l,setPlacementState:o,children:n})},"Popper"),GA="PopperAnchor",YA=d.forwardRef(Xs(function(t,n){const{__scopePopper:r,virtualRef:i,...l}=t,o=db(GA,r),a=d.useRef(null),c=o.onAnchorChange,u=d.useCallback(w=>{a.current=w,w&&c(w)},[c]),h=Ge(n,u),f=d.useRef(null);d.useEffect(()=>{if(!i)return;const w=f.current;f.current=i.current,w!==f.current&&c(f.current)});const p=o.placementState&&eu(o.placementState),m=p==null?void 0:p[0],j=p==null?void 0:p[1];return i?null:s.jsx(qe.div,{"data-radix-popper-side":m,"data-radix-popper-align":j,...l,ref:h})},"PopperAnchor")),fb="PopperContent",[qA,l3]=ub(fb),QA=d.forwardRef(Xs(function(t,n){var B,te,ge,Ee,Ve,ve,ct;const{__scopePopper:r,side:i="bottom",sideOffset:l=0,align:o="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:j="optimized",onPlaced:w,...b}=t,x=db(fb,r),[v,y]=d.useState(null),g=Ge(n,y),[S,k]=d.useState(null),N=ab(S),C=(N==null?void 0:N.width)??0,T=(N==null?void 0:N.height)??0,E=i+(o!=="center"?"-"+o:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},H=Array.isArray(h)?h:[h],O=H.length>0,R={padding:U,boundary:H.filter(hb),altBoundary:O},{refs:F,floatingStyles:K,placement:L,isPositioned:M,middlewareData:V}=MA({strategy:"fixed",placement:E,whileElementsMounted:Xs((...vt)=>kA(...vt,{animationFrame:j==="always"}),"whileElementsMounted"),elements:{reference:x.anchor},middleware:[_A({mainAxis:l+T,alignmentAxis:a}),u&&OA({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?DA():void 0,...R}),u&&LA({...R}),FA({...R,apply:Xs(({elements:vt,rects:Fe,availableWidth:cs,availableHeight:pn})=>{const{width:Wn,height:tn}=Fe.reference,mn=vt.floating.style;mn.setProperty("--radix-popper-available-width",`${cs}px`),mn.setProperty("--radix-popper-available-height",`${pn}px`),mn.setProperty("--radix-popper-anchor-width",`${Wn}px`),mn.setProperty("--radix-popper-anchor-height",`${tn}px`)},"apply")}),S&&BA({element:S,padding:c}),JA({arrowWidth:C,arrowHeight:T}),m&&UA({strategy:"referenceHidden",...R,boundary:O?R.boundary:void 0})]}),$=x.setPlacementState;Qt(()=>($(L),()=>{$(void 0)}),[L,$]);const[_,ne]=eu(L),X=Ln(w);Qt(()=>{M&&(X==null||X())},[M,X]);const ue=(B=V.arrow)==null?void 0:B.x,ye=(te=V.arrow)==null?void 0:te.y,Ne=((ge=V.arrow)==null?void 0:ge.centerOffset)!==0,[ce,we]=d.useState();return Qt(()=>{v&&we(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:M?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[(Ee=V.transformOrigin)==null?void 0:Ee.x,(Ve=V.transformOrigin)==null?void 0:Ve.y].join(" "),...((ve=V.hide)==null?void 0:ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(qA,{scope:r,placedSide:_,placedAlign:ne,onArrowChange:k,arrowX:ue,arrowY:ye,shouldHideArrow:Ne,children:s.jsx(qe.div,{"data-side":_,"data-align":ne,...b,ref:g,style:{...b.style,animation:M?(ct=b.style)==null?void 0:ct.animation:"none"}})})})},"PopperContent"));function hb(e){return e!==null}Xs(hb,"isNotNull");var JA=Xs(e=>({name:"transformOrigin",options:e,fn(t){var b,x,v;const{placement:n,rects:r,middlewareData:i}=t,o=((b=i.arrow)==null?void 0:b.centerOffset)!==0,a=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[u,h]=eu(n),f={start:"0%",center:"50%",end:"100%"}[h],p=(((x=i.arrow)==null?void 0:x.x)??0)+a/2,m=(((v=i.arrow)==null?void 0:v.y)??0)+c/2;let j="",w="";return u==="bottom"?(j=o?f:`${p}px`,w=`${-c}px`):u==="top"?(j=o?f:`${p}px`,w=`${r.floating.height+c}px`):u==="right"?(j=`${-c}px`,w=o?f:`${m}px`):u==="left"&&(j=`${r.floating.width+c}px`,w=o?f:`${m}px`),{data:{x:j,y:w}}}}),"transformOrigin");function eu(e){const[t,n="center"]=e.split("-");return[t,n]}Xs(eu,"getSideAndAlignFromPlacement");var pb=KA,mb=YA,gb=QA,XA=Object.defineProperty,ft=(e,t)=>XA(e,"name",{value:t,configurable:!0}),[Bp,o3]=Un("Tooltip",[Zc]),zp=Zc(),ZA="TooltipProvider",eR=700,Bf="tooltip.open",[tR,Wp]=Bp(ZA),nR=ft(e=>{const{__scopeTooltip:t,delayDuration:n=eR,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:l}=e,o=d.useRef(!0),a=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(tR,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:d.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:l})},"TooltipProvider"),zf="Tooltip",[sR,mo]=Bp(zf),rR=ft(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:l,disableHoverableContent:o,delayDuration:a}=e,c=Wp(zf,e.__scopeTooltip),u=zp(t),[h,f]=d.useState(null),[p,m]=d.useState(void 0),j=xs(),w=d.useRef(0),b=o??c.disableHoverableContent,x=a??c.delayDuration,v=d.useRef(!1),[y,g]=Qi({prop:r,defaultProp:i??!1,onChange:ft(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(Bf))):c.onClose(),l==null||l(E)},"onChange"),caller:zf}),S=d.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),k=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,v.current=!1,g(!0)},[g]),N=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,g(!1)},[g]),C=d.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{v.current=!0,g(!0),w.current=0},x)},[x,g]);d.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const T=p??j;return s.jsx(pb,{...u,children:s.jsx(sR,{scope:t,contentId:T,setContentId:m,open:y,stateAttribute:S,trigger:h,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?C():k()},[c.isOpenDelayedRef,C,k]),onTriggerLeave:d.useCallback(()=>{b?N():(window.clearTimeout(w.current),w.current=0)},[N,b]),onOpen:k,onClose:N,disableHoverableContent:b,children:n})})},"Tooltip"),Vx="TooltipTrigger",iR=d.forwardRef(ft(function(t,n){const{__scopeTooltip:r,...i}=t,l=mo(Vx,r),o=Wp(Vx,r),a=zp(r),c=d.useRef(null),u=Ge(n,c,l.onTriggerChange),h=d.useRef(!1),f=d.useRef(!1),p=d.useCallback(()=>h.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),s.jsx(mb,{asChild:!0,...a,children:s.jsx(qe.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...i,ref:u,onPointerMove:je(t.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!o.isPointerInTransitRef.current&&(l.onTriggerEnter(),f.current=!0)}),onPointerLeave:je(t.onPointerLeave,()=>{l.onTriggerLeave(),f.current=!1}),onPointerDown:je(t.onPointerDown,()=>{l.open&&l.onClose(),h.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:je(t.onFocus,()=>{h.current||l.onOpen()}),onBlur:je(t.onBlur,l.onClose),onClick:je(t.onClick,l.onClose)})})},"TooltipTrigger")),xb="TooltipPortal",[lR,oR]=Bp(xb,{forceMount:void 0}),aR=ft(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,l=mo(xb,t);return s.jsx(lR,{scope:t,forceMount:n,children:s.jsx(ur,{present:n||l.open,children:s.jsx($p,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),eo="TooltipContent",cR=d.forwardRef(ft(function(t,n){const r=oR(eo,t.__scopeTooltip),{forceMount:i=r.forceMount,side:l="top",...o}=t,a=mo(eo,t.__scopeTooltip);return s.jsx(ur,{present:i||a.open,children:a.disableHoverableContent?s.jsx(vb,{side:l,...o,ref:n}):s.jsx(uR,{side:l,...o,ref:n})})},"TooltipContent")),uR=d.forwardRef(ft(function(t,n){const r=mo(eo,t.__scopeTooltip),i=Wp(eo,t.__scopeTooltip),l=d.useRef(null),o=Ge(n,l),[a,c]=d.useState(null),{trigger:u,onClose:h}=r,f=l.current,{onPointerInTransitChange:p}=i,m=d.useCallback(()=>{c(null),p(!1)},[p]),j=d.useCallback((w,b)=>{const x=w.currentTarget,v={x:w.clientX,y:w.clientY},y=jb(v,x.getBoundingClientRect()),g=yb(v,y),S=wb(b.getBoundingClientRect()),k=kb([...g,...S]);c(k),p(!0)},[p]);return d.useEffect(()=>()=>m(),[m]),d.useEffect(()=>{if(u&&f){const w=ft(x=>j(x,f),"handleTriggerLeave"),b=ft(x=>j(x,u),"handleContentLeave");return u.addEventListener("pointerleave",w),f.addEventListener("pointerleave",b),()=>{u.removeEventListener("pointerleave",w),f.removeEventListener("pointerleave",b)}}},[u,f,j,m]),d.useEffect(()=>{if(a){const w=ft(b=>{const x=b.target,v={x:b.clientX,y:b.clientY},y=(u==null?void 0:u.contains(x))||(f==null?void 0:f.contains(x)),g=!bb(v,a);y?m():g&&(m(),h())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,f,a,h,m]),s.jsx(vb,{...t,ref:o})},"TooltipContentHoverable")),dR=Sw("TooltipContent"),vb=d.forwardRef(ft(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":l,id:o,onEscapeKeyDown:a,onPointerDownOutside:c,...u}=t,h=mo(eo,r),f=zp(r),{onClose:p}=h;d.useEffect(()=>(document.addEventListener(Bf,p),()=>document.removeEventListener(Bf,p)),[p]),d.useEffect(()=>{if(h.trigger){const j=ft(w=>{w.target instanceof Node&&w.target.contains(h.trigger)&&p()},"handleScroll");return window.addEventListener("scroll",j,{capture:!0}),()=>window.removeEventListener("scroll",j,{capture:!0})}},[h.trigger,p]);const{setContentId:m}=h;return Qt(()=>(m(o),()=>{m(void 0)}),[o,m]),s.jsx(Ip,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:j=>j.preventDefault(),onDismiss:p,children:s.jsxs(gb,{"data-state":h.stateAttribute,role:l?void 0:"tooltip",id:l?void 0:h.contentId,...f,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(dR,{children:i}),l?s.jsx(vE,{id:h.contentId,role:"tooltip",children:l}):null]})})},"TooltipContentImpl"));function jb(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,r,i,l)){case l:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}ft(jb,"getExitSideFromRect");function yb(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}ft(yb,"getPaddedExitPoints");function wb(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}ft(wb,"getPointsFromRect");function bb(e,t){const{x:n,y:r}=e;let i=!1;for(let l=0,o=t.length-1;l<t.length;o=l++){const a=t[l],c=t[o],u=a.x,h=a.y,f=c.x,p=c.y;h>r!=p>r&&n<(f-u)*(r-h)/(p-h)+u&&(i=!i)}return i}ft(bb,"isPointInPolygon");function kb(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Sb(t)}ft(kb,"getHull");function Sb(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const l=t[t.length-1],o=t[t.length-2];if((l.x-o.x)*(i.y-o.y)>=(l.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const l=n[n.length-1],o=n[n.length-2];if((l.x-o.x)*(i.y-o.y)>=(l.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}ft(Sb,"getHullPresorted");var Hx=nR,mc=rR,gc=iR,xc=aR,vc=cR;const Kx="buddi_csrf",Zi="x-buddi-csrf",to="buddi:agents-changed";class pe extends Error{constructor(t,n,r){super(n),this.status=t,this.detail=r,this.name="ApiError"}}function Br(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${Kx}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const n=[...document.cookie.matchAll(new RegExp(`(?:^|; )${Kx}(?:_\\d+)?=([^;]*)`,"g"))];return n.length===1&&((r=n[0])!=null&&r[1])?decodeURIComponent(n[0][1]):""}async function zr(e,t={}){const n=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}});if(n.status===401)throw new pe(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await n.text(),i=r===""?null:fR(r);if(!n.ok){const l=i&&typeof i=="object"&&"error"in i?String(i.error):`request failed (${n.status})`;throw new pe(n.status,l,i)}return i}function fR(e){try{return JSON.parse(e)}catch{return null}}function ae(e,t={}){const n=new URLSearchParams;for(const[i,l]of Object.entries(t))l!==void 0&&l!==""&&n.set(i,String(l));const r=n.toString();return zr(`/api${e}${r?`?${r}`:""}`)}function Nb(e,t){return zr(`/api${e}`,{method:"POST",headers:{[Zi]:Br()},body:t})}function jc(e){return zr(`/api${e}`,{method:"DELETE",headers:{[Zi]:Br()}})}function se(e,t={}){return zr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[Zi]:Br()},body:JSON.stringify(t??{})})}function Cb(e,t,n,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||n;return zr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[Zi]:Br(),"X-Filename":i,...r},body:t})}function Gx(e,t,n){return Cb(e,t,"backup.tar.gz",{...n.passphrase?{"X-Backup-Passphrase":n.passphrase}:{},...n.confirm?{"X-Backup-Confirm":n.confirm}:{}})}function hR(e,t={}){return zr(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[Zi]:Br()},body:JSON.stringify(t??{})})}function Jo(e,t={}){return zr(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[Zi]:Br()},body:JSON.stringify(t??{})})}function pR(e){if(e.dismissedAt)return"You said no to this one.";switch(e.lapseReason){case"owner-moved-on":return"The conversation moved on.";case"rolled-over":return"That conversation ended.";case"agent-removed":return"That agent is no longer here.";default:return"It lapsed."}}const _e={agents:()=>ae("/chat/agents"),views:()=>ae("/chat/views"),conversations:(e,t)=>ae(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>se(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>ae(`/chat/conversations/${encodeURIComponent(e)}`),send:(e,t)=>se(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>se(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>se(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),Nb("/chat/attachments",t)},discardAttachment:e=>jc(`/artifacts/${encodeURIComponent(e)}`),groups:()=>ae("/groups"),group:e=>ae(`/groups/${encodeURIComponent(e)}`),createGroup:e=>se("/groups",e),updateGroup:(e,t)=>hR(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>jc(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>ae(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>se(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>se(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`},A={providers:()=>ae("/providers"),providerAccounts:()=>ae("/provider-accounts"),probeModels:e=>se("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>se(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>se("/provider-accounts/save",e),testProviderAccount:e=>se(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>se(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,n)=>se(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:n}),anthropicAccountAction:(e,t,n,r)=>se(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:n,...r}),assignProviderAccount:(e,t,n)=>se(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:n}),configureProvider:(e,t)=>se(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>se(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>se(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>se(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>ae("/host/browser-profiles",{app:e}),installedApps:()=>ae("/host/apps"),browser:e=>ae(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>se(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>se("/browser/settings",e),computerPermissions:(e=!1)=>se("/browser/permissions",{prompt:e}),browserInstall:()=>se("/browser/install",{}),browserCheck:()=>se("/browser/check",{}),previewLink:(e,t)=>ae(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>ae(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>ae("/extension"),pairExtension:e=>se("/extension/pair",{code:e}),forgetExtension:()=>jc("/extension/pair"),session:()=>ae("/session"),overview:()=>ae("/overview"),events:e=>ae("/events",e),eventKinds:()=>ae("/events/kinds"),conversations:()=>ae("/conversations"),conversation:e=>ae(`/conversations/${encodeURIComponent(e)}`),missions:()=>ae("/missions"),jobs:(e={})=>ae("/jobs",e),approvals:()=>ae("/approvals"),approval:e=>ae(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>ae("/offers"),dismissOffer:e=>se(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>se("/offers/dismiss-all",{ids:e}),agentOffers:()=>ae("/agent-offers"),dismissAgentOffer:(e,t)=>se(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>ae("/proposals"),setDigestSchedule:(e,t)=>se("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>se(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),discardProposal:(e,t)=>se(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>ae("/reminders"),sentinels:()=>ae("/sentinels"),setSentinelEnabled:(e,t)=>se(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),snoozeAlert:(e,t)=>se(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>ae("/agents"),library:e=>ae("/artifacts",e),libraryEntry:(e,t=0)=>ae(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>ae("/onboarding"),onboardingStep:(e,t={})=>se("/onboarding/step",{step:e,...t}),completeOnboarding:()=>se("/onboarding/complete"),skipOnboarding:()=>se("/onboarding/skip"),createFirstAgent:e=>se("/onboarding/agent",e),ollama:()=>ae("/onboarding/ollama"),firstAgentPersona:()=>ae("/onboarding/agent"),updateFirstAgent:e=>se("/onboarding/agent/update",e),bindBrain:e=>se("/onboarding/brain",e),pages:()=>ae("/pages"),pageQuery:(e,t,n={})=>ae(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n),pageFileUrl:(e,t,n={})=>{const r=new URLSearchParams(Object.entries(n).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>se(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>ae("/telegram"),saveTelegramToken:e=>se("/telegram/token",{token:e}),telegramPairing:()=>se("/telegram/pairing"),owner:()=>ae("/owner"),setOwner:e=>se("/owner",e),memory:e=>ae(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>se("/memory/preferences",e),forgetPreference:e=>se("/memory/preferences/forget",e),updateNote:(e,t)=>se(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>se(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>se(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>ae(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>ae(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>se(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>ae("/host",{agentId:e,conversationId:t}),secrets:()=>ae("/secrets"),secretUses:(e,t)=>ae("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>se("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>se("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>se("/host/revoke",{id:e}),decide:(e,t,n,r)=>se(`/approvals/${encodeURIComponent(e)}/${t}`,n||r?{...n?{permissionScope:n}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>se("/pause",{paused:e}),service:()=>ae("/service"),serviceAction:e=>se(`/service/${e}`),version:()=>ae("/version"),checkVersion:()=>se("/version/check"),setVersionCheck:e=>Jo("/version/check",{enabled:e}),tailscale:()=>ae("/tailscale"),setTailscale:e=>Jo("/tailscale",e),startUpgrade:e=>se("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>ae(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>ae("/backups"),startBackup:e=>se("/backups",{encrypt:e}),verifyArchive:e=>se("/backups/verify",{name:e}),restoreArchive:e=>se("/backups/restore",e),restoreUpload:(e,t)=>Gx("/backups/restore",e,t),backupJob:e=>ae(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>ae("/backups/schedule"),setBackupSchedule:e=>Jo("/backups/schedule",e),backupPassphrase:()=>ae("/backups/passphrase"),setBackupPassphrase:e=>Jo("/backups/passphrase",{passphrase:e}),plugins:()=>ae("/plugins"),stagePlugin:e=>se("/plugins/stage",{spec:e}),uploadPlugin:e=>Cb("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>ae(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>se(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>se(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>se(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),uninstallPlugin:(e,t)=>se(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>se(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>ae("/recovery"),leaveRecovery:e=>se("/recovery/leave",e),firstRunRestore:(e,t)=>Gx("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>se(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,n)=>se(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...n===void 0?{}:{deadlineMinutes:n}}),retryJob:e=>se(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>se(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>se("/agents/default",{agentId:e}),agentTools:e=>ae(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>ae(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const n=new FormData;return n.append("file",t,t.name),Nb(`/agents/${encodeURIComponent(e)}/avatar`,n)},removeAgentPicture:e=>jc(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>se(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>se(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>se(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>se(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};var mR=Object.defineProperty,gR=(e,t)=>mR(e,"name",{value:t,configurable:!0}),xR=d.createContext(void 0);function tu(e){const t=d.useContext(xR);return e||t||"ltr"}gR(tu,"useDirection");var vR=Object.defineProperty,Vp=(e,t)=>vR(e,"name",{value:t,configurable:!0}),Xo=0,Gn=null;function jR(e){return nu(),e.children}Vp(jR,"FocusGuards");function nu(){d.useEffect(()=>{Gn||(Gn={start:Wf(),end:Wf()});const{start:e,end:t}=Gn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Xo++,()=>{Xo===1&&(Gn==null||Gn.start.remove(),Gn==null||Gn.end.remove(),Gn=null),Xo=Math.max(0,Xo-1)}},[])}Vp(nu,"useFocusGuards");function Wf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}Vp(Wf,"createFocusGuard");var yR=Object.defineProperty,Dt=(e,t)=>yR(e,"name",{value:t,configurable:!0}),ed="focusScope.autoFocusOnMount",td="focusScope.autoFocusOnUnmount",Yx={bubbles:!1,cancelable:!0},Eb=d.forwardRef(Dt(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:l,onUnmountAutoFocus:o,...a}=t,[c,u]=d.useState(null),h=Ln(l),f=Ln(o),p=d.useRef(null),m=Ge(n,u),j=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let b=function(g){if(j.paused||!c)return;const S=g.target;c.contains(S)?p.current=S:fs(p.current,{select:!0})},x=function(g){if(j.paused||!c)return;const S=g.relatedTarget;S!==null&&(c.contains(S)||fs(p.current,{select:!0}))},v=function(g){if(document.activeElement===document.body)for(const k of g)k.removedNodes.length>0&&fs(c)};Dt(b,"handleFocusIn"),Dt(x,"handleFocusOut"),Dt(v,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",x);const y=new MutationObserver(v);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",x),y.disconnect()}}},[i,c,j.paused]),d.useEffect(()=>{if(c){qx.add(j);const b=document.activeElement;if(!c.contains(b)){const v=new CustomEvent(ed,Yx);c.addEventListener(ed,h),c.dispatchEvent(v),v.defaultPrevented||(Ab(Mb(Hp(c)),{select:!0}),document.activeElement===b&&fs(c))}return()=>{c.removeEventListener(ed,h),setTimeout(()=>{const v=new CustomEvent(td,Yx);c.addEventListener(td,f),c.dispatchEvent(v),v.defaultPrevented||fs(b??document.body,{select:!0}),c.removeEventListener(td,f),qx.remove(j)},0)}}},[c,h,f,j]);const w=d.useCallback(b=>{if(!r&&!i||j.paused)return;const x=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,v=document.activeElement;if(x&&v){const y=b.currentTarget,[g,S]=Rb(y);g&&S?!b.shiftKey&&v===S?(b.preventDefault(),r&&fs(g,{select:!0})):b.shiftKey&&v===g&&(b.preventDefault(),r&&fs(S,{select:!0})):v===y&&b.preventDefault()}},[r,i,j.paused]);return s.jsx(qe.div,{tabIndex:-1,...a,ref:m,onKeyDown:w})},"FocusScope"));function Ab(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(fs(r,{select:t}),document.activeElement!==n)return}Dt(Ab,"focusFirst");function Rb(e){const t=Hp(e),n=Vf(t,e),r=Vf(t.reverse(),e);return[n,r]}Dt(Rb,"getTabbableEdges");function Hp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Dt(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Dt(Hp,"getTabbableCandidates");function Vf(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Tb(r,{upTo:t})))return r}Dt(Vf,"findVisible");function Tb(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}Dt(Tb,"isHidden");function Pb(e){return e instanceof HTMLInputElement&&"select"in e}Dt(Pb,"isSelectableInput");function fs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Pb(e)&&t&&e.select()}}Dt(fs,"focus");var qx=Ib();function Ib(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Hf(e,t),e.unshift(t)},remove(t){var n;e=Hf(e,t),(n=e[0])==null||n.resume()}}}Dt(Ib,"createFocusScopesStack");function Hf(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Dt(Hf,"arrayRemove");function Mb(e){return e.filter(t=>t.tagName!=="A")}Dt(Mb,"removeLinks");var wR=Object.defineProperty,Kp=(e,t)=>wR(e,"name",{value:t,configurable:!0}),nd=!1;function $b(){const[e,t]=d.useState(nd);return d.useEffect(()=>{nd||(nd=!0,t(!0))},[]),e}Kp($b,"useIsHydrated");var _b=Ki[" useSyncExternalStore ".trim().toString()];function Ob(){return()=>{}}Kp(Ob,"subscribe");function Db(){return _b(Ob,()=>!0,()=>!1)}Kp(Db,"useIsHydratedModern");var bR=typeof _b=="function"?Db:$b,kR=Object.defineProperty,Wr=(e,t)=>kR(e,"name",{value:t,configurable:!0}),sd="rovingFocusGroup.onEntryFocus",SR={bubbles:!1,cancelable:!0},su="RovingFocusGroup",[Kf,Lb,NR]=Kc(su),[CR,ru]=Un(su,[NR]),[ER,AR]=CR(su),RR=d.forwardRef(Wr(function(t,n){return s.jsx(Kf.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Kf.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(TR,{...t,ref:n})})})},"RovingFocusGroup")),TR=d.forwardRef(Wr(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:l=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...p}=t,m=d.useRef(null),j=Ge(n,m),w=tu(o),[b,x]=Qi({prop:a,defaultProp:c??null,onChange:u,caller:su}),[v,y]=d.useState(!1),g=Ln(h),S=Lb(r),k=d.useRef(!1),[N,C]=d.useState(0);return d.useEffect(()=>{const T=m.current;if(T)return T.addEventListener(sd,g),()=>T.removeEventListener(sd,g)},[g]),s.jsx(ER,{scope:r,orientation:i,dir:w,loop:l,currentTabStopId:b,onItemFocus:d.useCallback(T=>x(T),[x]),onItemShiftTab:d.useCallback(()=>y(!0),[]),onFocusableItemAdd:d.useCallback(()=>C(T=>T+1),[]),onFocusableItemRemove:d.useCallback(()=>C(T=>T-1),[]),children:s.jsx(qe.div,{tabIndex:v||N===0?-1:0,"data-orientation":i,...p,ref:j,style:{outline:"none",...t.style},onMouseDown:je(t.onMouseDown,()=>{k.current=!0}),onFocus:je(t.onFocus,T=>{const E=!k.current;if(T.target===T.currentTarget&&E&&!v){const U=new CustomEvent(sd,SR);if(T.currentTarget.dispatchEvent(U),!U.defaultPrevented){const H=S().filter(L=>L.focusable),O=H.find(L=>L.active),R=H.find(L=>L.id===b),K=[O,R,...H].filter(Boolean).map(L=>L.ref.current);Gp(K,f)}}k.current=!1}),onBlur:je(t.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),PR="RovingFocusGroupItem",IR=d.forwardRef(Wr(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:l=!1,tabStopId:o,children:a,...c}=t,u=xs(),h=o||u,f=AR(PR,r),p=f.currentTabStopId===h,m=Lb(r),{onFocusableItemAdd:j,onFocusableItemRemove:w,currentTabStopId:b}=f,x=bR();return Qt(()=>{if(!(!x||!i))return j(),()=>w()},[x,i,j,w]),d.useEffect(()=>{if(!(x||!i))return j(),()=>w()},[x,i,j,w]),s.jsx(Kf.ItemSlot,{scope:r,id:h,focusable:i,active:l,children:s.jsx(qe.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:je(t.onMouseDown,v=>{i?f.onItemFocus(h):v.preventDefault()}),onFocus:je(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:je(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=Ub(v,f.orientation,f.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(v.currentTarget);S=f.loop?Bb(S,k+1):S.slice(k+1)}setTimeout(()=>Gp(S))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:b!=null}):a})})},"RovingFocusGroupItem")),MR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Fb(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Wr(Fb,"getDirectionAwareKey");function Ub(e,t,n){const r=Fb(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return MR[r]}Wr(Ub,"getFocusIntent");function Gp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Wr(Gp,"focusFirst");function Bb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Wr(Bb,"wrapArray");var zb=RR,Wb=IR,$R=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Xr=new WeakMap,Zo=new WeakMap,ea={},rd=0,Vb=function(e){return e&&(e.host||Vb(e.parentNode))},_R=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Vb(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},OR=function(e,t,n,r){var i=_R(t,Array.isArray(e)?e:[e]);ea[n]||(ea[n]=new WeakMap);var l=ea[n],o=[],a=new Set,c=new Set(i),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};i.forEach(u);var h=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))h(p);else try{var m=p.getAttribute(r),j=m!==null&&m!=="false",w=(Xr.get(p)||0)+1,b=(l.get(p)||0)+1;Xr.set(p,w),l.set(p,b),o.push(p),w===1&&j&&Zo.set(p,!0),b===1&&p.setAttribute(n,"true"),j||p.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",p,x)}})};return h(t),a.clear(),rd++,function(){o.forEach(function(f){var p=Xr.get(f)-1,m=l.get(f)-1;Xr.set(f,p),l.set(f,m),p||(Zo.has(f)||f.removeAttribute(r),Zo.delete(f)),m||f.removeAttribute(n)}),rd--,rd||(Xr=new WeakMap,Xr=new WeakMap,Zo=new WeakMap,ea={})}},Hb=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=$R(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),OR(r,i,n,"aria-hidden")):function(){return null}},Qn=function(){return Qn=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])}return t},Qn.apply(this,arguments)};function Kb(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function DR(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,l;r<i;r++)(l||!(r in t))&&(l||(l=Array.prototype.slice.call(t,0,r)),l[r]=t[r]);return e.concat(l||Array.prototype.slice.call(t))}var Ma="right-scroll-bar-position",$a="width-before-scroll-bar",LR="with-scroll-bars-hidden",FR="--removed-body-scroll-bar-size";function id(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function UR(e,t){var n=d.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var BR=typeof window<"u"?d.useLayoutEffect:d.useEffect,Qx=new WeakMap;function zR(e,t){var n=UR(null,function(r){return e.forEach(function(i){return id(i,r)})});return BR(function(){var r=Qx.get(n);if(r){var i=new Set(r),l=new Set(e),o=n.current;i.forEach(function(a){l.has(a)||id(a,null)}),l.forEach(function(a){i.has(a)||id(a,o)})}Qx.set(n,e)},[e]),n}function WR(e){return e}function VR(e,t){t===void 0&&(t=WR);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(l){var o=t(l,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(l){for(r=!0;n.length;){var o=n;n=[],o.forEach(l)}n={push:function(a){return l(a)},filter:function(){return n}}},assignMedium:function(l){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(l),o=n}var c=function(){var h=o;o=[],h.forEach(l)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(h){o.push(h),u()},filter:function(h){return o=o.filter(h),n}}}};return i}function HR(e){e===void 0&&(e={});var t=VR(null);return t.options=Qn({async:!0,ssr:!1},e),t}var Gb=function(e){var t=e.sideCar,n=Kb(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,Qn({},n))};Gb.isSideCarExport=!0;function KR(e,t){return e.useMedium(t),Gb}var Yb=HR(),ld=function(){},iu=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:ld,onWheelCapture:ld,onTouchMoveCapture:ld}),i=r[0],l=r[1],o=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,h=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,j=e.noIsolation,w=e.inert,b=e.allowPinchZoom,x=e.as,v=x===void 0?"div":x,y=e.gapMode,g=Kb(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=p,k=zR([n,t]),N=Qn(Qn({},g),i);return d.createElement(d.Fragment,null,h&&d.createElement(S,{sideCar:Yb,removeScrollBar:u,shards:f,noRelative:m,noIsolation:j,inert:w,setCallbacks:l,allowPinchZoom:!!b,lockRef:n,gapMode:y}),o?d.cloneElement(d.Children.only(a),Qn(Qn({},N),{ref:k})):d.createElement(v,Qn({},N,{className:c,ref:k}),a))});iu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};iu.classNames={fullWidth:$a,zeroRight:Ma};var GR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function YR(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=GR();return t&&e.setAttribute("nonce",t),e}function qR(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function QR(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var JR=function(){var e=0,t=null;return{add:function(n){e==0&&(t=YR())&&(qR(t,n),QR(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},XR=function(){var e=JR();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},qb=function(){var e=XR(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},ZR={left:0,top:0,right:0,gap:0},od=function(e){return parseInt(e||"",10)||0},eT=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[od(n),od(r),od(i)]},tT=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ZR;var t=eT(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},nT=qb(),Si="data-scroll-locked",sT=function(e,t,n,r){var i=e.left,l=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
41
- .`.concat(LR,` {
42
- overflow: hidden `).concat(r,`;
43
- padding-right: `).concat(a,"px ").concat(r,`;
44
- }
45
- body[`).concat(Si,`] {
46
- overflow: hidden `).concat(r,`;
47
- overscroll-behavior: contain;
48
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
49
- padding-left: `.concat(i,`px;
50
- padding-top: `).concat(l,`px;
51
- padding-right: `).concat(o,`px;
52
- margin-left:0;
53
- margin-top:0;
54
- margin-right: `).concat(a,"px ").concat(r,`;
55
- `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
56
- }
57
-
58
- .`).concat(Ma,` {
59
- right: `).concat(a,"px ").concat(r,`;
60
- }
61
-
62
- .`).concat($a,` {
63
- margin-right: `).concat(a,"px ").concat(r,`;
64
- }
65
-
66
- .`).concat(Ma," .").concat(Ma,` {
67
- right: 0 `).concat(r,`;
68
- }
69
-
70
- .`).concat($a," .").concat($a,` {
71
- margin-right: 0 `).concat(r,`;
72
- }
73
-
74
- body[`).concat(Si,`] {
75
- `).concat(FR,": ").concat(a,`px;
76
- }
77
- `)},Jx=function(){var e=parseInt(document.body.getAttribute(Si)||"0",10);return isFinite(e)?e:0},rT=function(){d.useEffect(function(){return document.body.setAttribute(Si,(Jx()+1).toString()),function(){var e=Jx()-1;e<=0?document.body.removeAttribute(Si):document.body.setAttribute(Si,e.toString())}},[])},iT=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;rT();var l=d.useMemo(function(){return tT(i)},[i]);return d.createElement(nT,{styles:sT(l,!t,i,n?"":"!important")})},Gf=!1;if(typeof window<"u")try{var ta=Object.defineProperty({},"passive",{get:function(){return Gf=!0,!0}});window.addEventListener("test",ta,ta),window.removeEventListener("test",ta,ta)}catch{Gf=!1}var Zr=Gf?{passive:!1}:!1,lT=function(e){return e.tagName==="TEXTAREA"},Qb=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!lT(e)&&n[t]==="visible")},oT=function(e){return Qb(e,"overflowY")},aT=function(e){return Qb(e,"overflowX")},Xx=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=Jb(e,r);if(i){var l=Xb(e,r),o=l[1],a=l[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},cT=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},uT=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Jb=function(e,t){return e==="v"?oT(t):aT(t)},Xb=function(e,t){return e==="v"?cT(t):uT(t)},dT=function(e,t){return e==="h"&&t==="rtl"?-1:1},fT=function(e,t,n,r,i){var l=dT(e,window.getComputedStyle(t).direction),o=l*r,a=n.target,c=t.contains(a),u=!1,h=o>0,f=0,p=0;do{if(!a)break;var m=Xb(e,a),j=m[0],w=m[1],b=m[2],x=w-b-l*j;(j||x)&&Jb(e,a)&&(f+=x,p+=j);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(h&&Math.abs(f)<1||!h&&Math.abs(p)<1)&&(u=!0),u},na=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Zx=function(e){return[e.deltaX,e.deltaY]},ev=function(e){return e&&"current"in e?e.current:e},hT=function(e,t){return e[0]===t[0]&&e[1]===t[1]},pT=function(e){return`
78
- .block-interactivity-`.concat(e,` {pointer-events: none;}
79
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
80
- `)},mT=0,ei=[];function gT(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),i=d.useState(mT++)[0],l=d.useState(qb)[0],o=d.useRef(e);d.useEffect(function(){o.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var w=DR([e.lockRef.current],(e.shards||[]).map(ev),!0).filter(Boolean);return w.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=d.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var x=na(w),v=n.current,y="deltaX"in w?w.deltaX:v[0]-x[0],g="deltaY"in w?w.deltaY:v[1]-x[1],S,k=w.target,N=Math.abs(y)>Math.abs(g)?"h":"v";if("touches"in w&&N==="h"&&k.type==="range")return!1;var C=window.getSelection(),T=C&&C.anchorNode,E=T?T===k||T.contains(k):!1;if(E)return!1;var U=Xx(N,k);if(!U)return!0;if(U?S=N:(S=N==="v"?"h":"v",U=Xx(N,k)),!U)return!1;if(!r.current&&"changedTouches"in w&&(y||g)&&(r.current=S),!S)return!0;var H=r.current||S;return fT(H,b,w,H==="h"?y:g)},[]),c=d.useCallback(function(w){var b=w;if(!(!ei.length||ei[ei.length-1]!==l)){var x="deltaY"in b?Zx(b):na(b),v=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&hT(S.delta,x)})[0];if(v&&v.should){b.cancelable&&b.preventDefault();return}if(!v){var y=(o.current.shards||[]).map(ev).filter(Boolean).filter(function(S){return S.contains(b.target)}),g=y.length>0?a(b,y[0]):!o.current.noIsolation;g&&b.cancelable&&b.preventDefault()}}},[]),u=d.useCallback(function(w,b,x,v){var y={name:w,delta:b,target:x,should:v,shadowParent:xT(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(g){return g!==y})},1)},[]),h=d.useCallback(function(w){n.current=na(w),r.current=void 0},[]),f=d.useCallback(function(w){u(w.type,Zx(w),w.target,a(w,e.lockRef.current))},[]),p=d.useCallback(function(w){u(w.type,na(w),w.target,a(w,e.lockRef.current))},[]);d.useEffect(function(){return ei.push(l),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Zr),document.addEventListener("touchmove",c,Zr),document.addEventListener("touchstart",h,Zr),function(){ei=ei.filter(function(w){return w!==l}),document.removeEventListener("wheel",c,Zr),document.removeEventListener("touchmove",c,Zr),document.removeEventListener("touchstart",h,Zr)}},[]);var m=e.removeScrollBar,j=e.inert;return d.createElement(d.Fragment,null,j?d.createElement(l,{styles:pT(i)}):null,m?d.createElement(iT,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function xT(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vT=KR(Yb,gT);var Yp=d.forwardRef(function(e,t){return d.createElement(iu,Qn({},e,{ref:t,sideCar:vT}))});Yp.classNames=iu.classNames;var jT=Object.defineProperty,Re=(e,t)=>jT(e,"name",{value:t,configurable:!0}),yT=["Enter"," "],wT=["ArrowDown","PageUp","Home"],Zb=["ArrowUp","PageDown","End"],bT=[...wT,...Zb],lu="Menu",[Yf,kT,ST]=Kc(lu),[Vr,e0]=Un(lu,[ST,Zc,ru]),qp=Zc(),t0=ru(),[NT,go]=Vr(lu),[CT,Qp]=Vr(lu),ET=Re(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:l,modal:o=!0}=e,a=qp(t),[c,u]=d.useState(null),h=d.useRef(!1),f=Ln(l),p=tu(i);return d.useEffect(()=>{const m=Re(()=>{h.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},"handleKeyDown"),j=Re(()=>h.current=!1,"handlePointer");return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),d.useEffect(()=>{if(!n)return;const m=Re(()=>f(!1),"handleBlur");return window.addEventListener("blur",m),()=>window.removeEventListener("blur",m)},[n,f]),s.jsx(pb,{...a,children:s.jsx(NT,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:s.jsx(CT,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:p,modal:o,children:r})})})},"Menu"),AT=d.forwardRef(Re(function(t,n){const{__scopeMenu:r,...i}=t,l=qp(r);return s.jsx(mb,{...l,...i,ref:n})},"MenuAnchor")),n0="MenuPortal",[RT,TT]=Vr(n0,{forceMount:void 0}),PT=Re(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,l=go(n0,t);return s.jsx(RT,{scope:t,forceMount:n,children:s.jsx(ur,{present:n||l.open,children:s.jsx($p,{asChild:!0,container:i,children:r})})})},"MenuPortal"),Zs="MenuContent",[IT,s0]=Vr(Zs),MT=d.forwardRef(Re(function(t,n){const r=TT(Zs,t.__scopeMenu),{forceMount:i=r.forceMount,...l}=t,o=go(Zs,t.__scopeMenu),a=Qp(Zs,t.__scopeMenu);return s.jsx(Yf.Provider,{scope:t.__scopeMenu,children:s.jsx(ur,{present:i||o.open,children:s.jsx(Yf.Slot,{scope:t.__scopeMenu,children:a.modal?s.jsx($T,{...l,ref:n}):s.jsx(_T,{...l,ref:n})})})})},"MenuContent")),$T=d.forwardRef(Re(function(t,n){const r=go(Zs,t.__scopeMenu),i=d.useRef(null),l=Ge(n,i);return d.useEffect(()=>{const o=i.current;if(o)return Hb(o)},[]),s.jsx(r0,{...t,ref:l,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:je(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),_T=d.forwardRef(Re(function(t,n){const r=go(Zs,t.__scopeMenu);return s.jsx(r0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),OT=sr("MenuContent.ScrollLock"),r0=d.forwardRef(Re(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:l,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:j,disableOutsideScroll:w,...b}=t,x=go(Zs,r),v=Qp(Zs,r),y=qp(r),g=t0(r),S=kT(r),[k,N]=d.useState(null),C=d.useRef(null),T=Ge(n,C,x.onContentChange),E=d.useRef(0),U=d.useRef(""),H=d.useRef(0),O=d.useRef(null),R=d.useRef("right"),F=d.useRef(0),K=w?Yp:d.Fragment,L=w?{as:OT,allowPinchZoom:!0}:void 0,M=Re($=>{var we,B;const _=U.current+$,ne=S().filter(te=>!te.disabled),X=document.activeElement,ue=(we=ne.find(te=>te.ref.current===X))==null?void 0:we.textValue,ye=ne.map(te=>te.textValue),Ne=f0(ye,_,ue),ce=(B=ne.find(te=>te.textValue===Ne))==null?void 0:B.ref.current;Re(function te(ge){U.current=ge,window.clearTimeout(E.current),ge!==""&&(E.current=window.setTimeout(()=>te(""),1e3))},"updateSearch")(_),ce&&setTimeout(()=>ce.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(E.current),[]),nu();const V=d.useCallback($=>{var ne,X;return R.current===((ne=O.current)==null?void 0:ne.side)&&p0($,(X=O.current)==null?void 0:X.area)},[]);return s.jsx(IT,{scope:r,searchRef:U,onItemEnter:d.useCallback($=>{V($)&&$.preventDefault()},[V]),onItemLeave:d.useCallback($=>{var _;V($)||((_=C.current)==null||_.focus(),N(null))},[V]),onTriggerLeave:d.useCallback($=>{V($)&&$.preventDefault()},[V]),pointerGraceTimerRef:H,onPointerGraceIntentChange:d.useCallback($=>{O.current=$},[]),children:s.jsx(K,{...L,children:s.jsx(Eb,{asChild:!0,trapped:l,onMountAutoFocus:je(o,$=>{var _;$.preventDefault(),(_=C.current)==null||_.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:s.jsx(Ip,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:j,children:s.jsx(zb,{asChild:!0,...g,dir:v.dir,orientation:"vertical",loop:i,currentTabStopId:k,onCurrentTabStopIdChange:N,onEntryFocus:je(u,$=>{v.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(gb,{role:"menu","aria-orientation":"vertical","data-state":o0(x.open),"data-radix-menu-content":"",dir:v.dir,...y,...b,ref:T,style:{outline:"none",...b.style},onKeyDown:je(b.onKeyDown,$=>{const ne=$.target.closest("[data-radix-menu-content]")===$.currentTarget,X=$.ctrlKey||$.altKey||$.metaKey,ue=$.key.length===1;ne&&($.key==="Tab"&&$.preventDefault(),!X&&ue&&M($.key));const ye=C.current;if($.target!==ye||!bT.includes($.key))return;$.preventDefault();const ce=S().filter(we=>!we.disabled).map(we=>we.ref.current);Zb.includes($.key)&&ce.reverse(),u0(ce)}),onBlur:je(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(E.current),U.current="")}),onPointerMove:je(t.onPointerMove,yc($=>{const _=$.target,ne=F.current!==$.clientX;if($.currentTarget.contains(_)&&ne){const X=$.clientX>F.current?"right":"left";R.current=X,F.current=$.clientX}}))})})})})})})},"MenuContentImpl")),i0=d.forwardRef(Re(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(qe.div,{role:"group",...i,ref:n})},"MenuGroup")),DT=d.forwardRef(Re(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(qe.div,{...i,ref:n})},"MenuLabel")),qf="MenuItem",tv="menu.itemSelect",l0=d.forwardRef(Re(function(t,n){const{disabled:r=!1,onSelect:i,...l}=t,o=d.useRef(null),a=Qp(qf,t.__scopeMenu),c=s0(qf,t.__scopeMenu),u=Ge(n,o),h=d.useRef(!1),f=Re(()=>{const p=o.current;if(!r&&p){const m=new CustomEvent(tv,{bubbles:!0,cancelable:!0});p.addEventListener(tv,j=>i==null?void 0:i(j),{once:!0}),Gc(p,m),m.defaultPrevented?h.current=!1:a.onClose()}},"handleSelect");return s.jsx(LT,{...l,ref:u,disabled:r,onClick:je(t.onClick,f),onPointerDown:p=>{var m;(m=t.onPointerDown)==null||m.call(t,p),h.current=!0},onPointerUp:je(t.onPointerUp,p=>{var m;h.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:je(t.onKeyDown,p=>{r||p.target!==p.currentTarget||c.searchRef.current!==""&&p.key===" "||yT.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),LT=d.forwardRef(Re(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:l,...o}=t,a=s0(qf,r),c=t0(r),u=d.useRef(null),h=Ge(n,u),[f,p]=d.useState(!1),[m,j]=d.useState("");return d.useEffect(()=>{const w=u.current;w&&j((w.textContent??"").trim())},[o.children]),s.jsx(Yf.ItemSlot,{scope:r,disabled:i,textValue:l??m,children:s.jsx(Wb,{asChild:!0,...c,focusable:!i,children:s.jsx(qe.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:h,onPointerMove:je(t.onPointerMove,yc(w=>{i?a.onItemLeave(w):(a.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:je(t.onPointerLeave,yc(w=>a.onItemLeave(w))),onFocus:je(t.onFocus,()=>p(!0)),onBlur:je(t.onBlur,()=>p(!1))})})})},"MenuItemImpl")),FT="MenuRadioGroup",[UT,BT]=Vr(FT,{value:void 0,onValueChange:Re(()=>{},"onValueChange")}),zT=d.forwardRef(Re(function(t,n){const{value:r,onValueChange:i,...l}=t,o=Ln(i);return s.jsx(UT,{scope:t.__scopeMenu,value:r,onValueChange:o,children:s.jsx(i0,{...l,ref:n})})},"MenuRadioGroup")),WT="MenuRadioItem",VT=d.forwardRef(Re(function(t,n){const{value:r,...i}=t,l=BT(WT,t.__scopeMenu),o=r===l.value;return s.jsx(KT,{scope:t.__scopeMenu,checked:o,children:s.jsx(l0,{role:"menuitemradio","aria-checked":o,...i,ref:n,"data-state":c0(o),onSelect:je(i.onSelect,()=>{var a;return(a=l.onValueChange)==null?void 0:a.call(l,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),HT="MenuItemIndicator",[KT,a3]=Vr(HT,{checked:!1}),GT=d.forwardRef(Re(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(qe.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),YT="MenuSub",[c3,u3]=Vr(YT);function o0(e){return e?"open":"closed"}Re(o0,"getOpenState");function a0(e){return e==="indeterminate"}Re(a0,"isIndeterminate");function c0(e){return a0(e)?"indeterminate":e?"checked":"unchecked"}Re(c0,"getCheckedState");function u0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Re(u0,"focusFirst");function d0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Re(d0,"wrapArray");function f0(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let o=d0(e,Math.max(l,0));i.length===1&&(o=o.filter(u=>u!==n));const c=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}Re(f0,"getNextMatch");function h0(e,t){const{x:n,y:r}=e;let i=!1;for(let l=0,o=t.length-1;l<t.length;o=l++){const a=t[l],c=t[o],u=a.x,h=a.y,f=c.x,p=c.y;h>r!=p>r&&n<(f-u)*(r-h)/(p-h)+u&&(i=!i)}return i}Re(h0,"isPointInPolygon");function p0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return h0(n,t)}Re(p0,"isPointerInGraceArea");function yc(e){return t=>t.pointerType==="mouse"?e(t):void 0}Re(yc,"whenMouse");var qT=ET,QT=AT,JT=PT,XT=MT,ZT=i0,eP=DT,tP=l0,nP=zT,sP=VT,rP=GT,iP=Object.defineProperty,is=(e,t)=>iP(e,"name",{value:t,configurable:!0}),Jp="DropdownMenu",[lP,d3]=Un(Jp,[e0]),ls=e0(),[oP,m0]=lP(Jp),aP=is(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:l,onOpenChange:o,modal:a=!0}=e,c=ls(t),u=d.useRef(null),[h,f]=Qi({prop:i,defaultProp:l??!1,onChange:o,caller:Jp});return s.jsx(oP,{scope:t,triggerId:xs(),triggerRef:u,contentId:xs(),open:h,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(p=>!p),[f]),modal:a,children:s.jsx(qT,{...c,open:h,onOpenChange:f,dir:r,modal:a,children:n})})},"DropdownMenu"),cP="DropdownMenuTrigger",uP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...l}=t,o=m0(cP,r),a=ls(r),c=Ge(n,o.triggerRef);return s.jsx(QT,{asChild:!0,...a,children:s.jsx(qe.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...l,ref:c,onPointerDown:je(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(o.onOpenToggle(),o.open||u.preventDefault())}),onKeyDown:je(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&o.onOpenToggle(),u.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),dP=is(e=>{const{__scopeDropdownMenu:t,...n}=e,r=ls(t);return s.jsx(JT,{...r,...n})},"DropdownMenuPortal"),fP="DropdownMenuContent",hP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=m0(fP,r),o=ls(r),a=d.useRef(!1);return s.jsx(XT,{id:l.contentId,"aria-labelledby":l.triggerId,...o,...i,ref:n,onCloseAutoFocus:je(t.onCloseAutoFocus,c=>{var u;a.current||(u=l.triggerRef.current)==null||u.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:je(t.onInteractOutside,c=>{const u=c.detail.originalEvent,h=u.button===0&&u.ctrlKey===!0,f=u.button===2||h;(!l.modal||f)&&(a.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),pP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(ZT,{...l,...i,ref:n})},"DropdownMenuGroup")),mP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(eP,{...l,...i,ref:n})},"DropdownMenuLabel")),gP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(tP,{...l,...i,ref:n})},"DropdownMenuItem")),xP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(nP,{...l,...i,ref:n})},"DropdownMenuRadioGroup")),vP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(sP,{...l,...i,ref:n})},"DropdownMenuRadioItem")),jP=d.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(rP,{...l,...i,ref:n})},"DropdownMenuSeparator")),Xp=aP,Zp=uP,em=dP,tm=hP,yP=pP,nm=mP,Qf=gP,wP=xP,bP=vP,Jf=jP,kP=Object.defineProperty,el=(e,t)=>kP(e,"name",{value:t,configurable:!0}),sm="Tabs",[SP,f3]=Un(sm,[ru]),g0=ru(),[NP,rm]=SP(sm),CP=d.forwardRef(el(function(t,n){const{__scopeTabs:r,value:i,onValueChange:l,defaultValue:o,orientation:a="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=tu(c),[p,m]=Qi({prop:i,onChange:l,defaultProp:o??"",caller:sm});return s.jsx(NP,{scope:r,baseId:xs(),value:p,onValueChange:m,orientation:a,dir:f,activationMode:u,children:s.jsx(qe.div,{dir:f,"data-orientation":a,...h,ref:n})})},"Tabs")),EP="TabsList",AP=d.forwardRef(el(function(t,n){const{__scopeTabs:r,loop:i=!0,...l}=t,o=rm(EP,r),a=g0(r);return s.jsx(zb,{asChild:!0,...a,orientation:o.orientation,dir:o.dir,loop:i,children:s.jsx(qe.div,{role:"tablist","aria-orientation":o.orientation,...l,ref:n})})},"TabsList")),RP="TabsTrigger",TP=d.forwardRef(el(function(t,n){const{__scopeTabs:r,value:i,disabled:l=!1,...o}=t,a=rm(RP,r),c=g0(r),u=im(a.baseId,i),h=lm(a.baseId,i),f=i===a.value;return s.jsx(Wb,{asChild:!0,...c,focusable:!l,active:f,children:s.jsx(qe.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:u,...o,ref:n,onMouseDown:je(t.onMouseDown,p=>{!l&&p.button===0&&p.ctrlKey===!1?a.onValueChange(i):p.preventDefault()}),onKeyDown:je(t.onKeyDown,p=>{l||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&a.onValueChange(i)}),onFocus:je(t.onFocus,()=>{const p=a.activationMode!=="manual";!f&&!l&&p&&a.onValueChange(i)})})})},"TabsTrigger")),PP="TabsContent",IP=d.forwardRef(el(function(t,n){const{__scopeTabs:r,value:i,forceMount:l,children:o,...a}=t,c=rm(PP,r),u=im(c.baseId,i),h=lm(c.baseId,i),f=i===c.value,p=d.useRef(f);return d.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),s.jsx(ur,{present:l||f,children:({present:m})=>s.jsx(qe.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:h,tabIndex:0,...a,ref:n,style:{...t.style,animationDuration:p.current?"0s":void 0},children:m&&o})})},"TabsContent"));function im(e,t){return`${e}-trigger-${t}`}el(im,"makeTriggerId");function lm(e,t){return`${e}-content-${t}`}el(lm,"makeContentId");var MP=CP,$P=AP,_P=TP,OP=IP;function Pe(e,t){if(!e)return"—";const n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function Se(e,t=Date.now()){if(!e)return"";const n=new Date(e).getTime();if(Number.isNaN(n))return"";const r=Math.round((n-t)/1e3),i=Math.abs(r),[l,o]=i<60?[r,"second"]:i<3600?[Math.round(r/60),"minute"]:i<86400?[Math.round(r/3600),"hour"]:[Math.round(r/86400),"day"];return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(l,o)}function DP(e,t){if(e==null||!Number.isFinite(e))return"—";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:0}).format(e)}catch{return e.toFixed(2)}}function Mt(e){return new Intl.NumberFormat("en-US").format(e)}function Xt(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function no(e,t=8){return e.length<=t?e:e.slice(0,t)}function Cs(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function _i(e){return e.replace(/<<<[^<>]*>>>/g,"")}function mt(e,t,n){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?LP(r,n):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${nv(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Mt(r):nv(r):String(e)}case"date":return Xf(String(e));default:return typeof e=="string"?e:typeof e=="number"?Mt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function LP(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return DP(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function Xf(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short"}).format(n)}function nv(e){return String(Math.round(e*100)/100)}function FP(e,t,n=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,n),i=10**Math.floor(Math.log10(r)),l=[1,2,2.5,5,10].map(a=>a*i).find(a=>a>=r)??i*10,o=[];for(let a=Math.ceil(e/l)*l;a<=t+l/1e3;a+=l)o.push(Math.round(a*1e6)/1e6);return o.filter(a=>a>=e&&a<=t)}function UP({props:e}){if(e.bars.length===0)return s.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(l=>l.value),n=Math.max(0,...t),r=Math.min(0,...t),i=n-r||1;return s.jsx("div",{className:"wb-bars",children:e.bars.map(l=>{const o=Math.abs(l.value)/i;return s.jsxs("div",{className:"wb-bar-row",children:[s.jsx("div",{className:"wb-bar-cat",title:l.category,children:l.category}),s.jsx("div",{className:"wb-bar-track",children:s.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,o*100)}%`,background:l.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),s.jsx("div",{className:"wb-bar-val",children:mt(l.value,e.unit,e.currency)})]},l.category)})})}const BP=/^(diff --git |index [0-9a-f]|--- (a\/|\/dev\/null)|\+\+\+ (b\/|\/dev\/null)|new file mode|deleted file mode|similarity index|rename (from|to) |old mode|new mode|Binary files )/,zP=/^(… |\.\.\. |\(no change\)$|\)/;function WP(e){return e.replace(/\n$/,"").split(`
81
- `).map(n=>({kind:VP(n),text:n}))}function VP(e){return e.startsWith("@@")?"hunk":BP.test(e)||zP.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function HP({text:e,marks:t}){const n=e.toLowerCase(),r=[];for(const o of t){const a=o.trim().toLowerCase();if(a!=="")for(let c=n.indexOf(a);c!==-1;c=n.indexOf(a,c+a.length))r.push([c,c+a.length])}if(r.length===0)return s.jsx(s.Fragment,{children:e===""?" ":e});r.sort((o,a)=>o[0]-a[0]);const i=[];let l=0;for(const[o,a]of r)o<l||(o>l&&i.push(s.jsx("span",{children:e.slice(l,o)},`t${l}`)),i.push(s.jsx("mark",{className:"wb-diff-mark",children:e.slice(o,a)},`m${o}`)),l=a);return l<e.length&&i.push(s.jsx("span",{children:e.slice(l)},`t${l}`)),s.jsx(s.Fragment,{children:i})}function wc({text:e,limit:t,more:n,label:r="Diff",marks:i}){const l=WP(e),o=t===void 0?l:l.slice(0,t),a=l.length-o.length;return s.jsxs("div",{className:"wb-diff-wrap",children:[s.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:o.map((c,u)=>s.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?s.jsx(HP,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),a>0?s.jsxs("p",{className:"wb-diff-more",children:[a," more line",a===1?"":"s",n?s.jsxs(s.Fragment,{children:[" · ",s.jsx("button",{type:"button",className:"wb-diff-open",onClick:n.onClick,children:n.label})]}):null]}):null]})}function KP({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:mt(t.value,t.unit,null)})]},t.label))}):null,e.diff?s.jsx(wc,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):s.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const Ut="#/",Oi="#/chat",Xe="#/agents",Je="#/activity",Ht="#/settings",$r="#/files",om="#/welcome";function sv(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function sa(e,t={}){const n=new URLSearchParams;t.q&&n.set("q",t.q),t.origin&&n.set("origin",t.origin),t.family&&n.set("family",t.family);const r=n.toString();return`${$r}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function GP(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[2]??""),r={};return n.get("q")&&(r.q=n.get("q")),n.get("origin")&&(r.origin=n.get("origin")),n.get("family")&&(r.family=n.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function De(e,t,n){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function YP(e){if(x0(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...n?{tab:n}:{}}}catch{return null}}function Ml(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function x0(e){const t=/^#\/chat\/g\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{groupId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{}}}catch{return null}}function It(e,t){return`${Xe}/${encodeURIComponent(e)}${t?`/${t}`:""}`}function qP(e){const t=/^#\/agents\/([^/]+)(?:\/([a-z-]+))?$/.exec(e);if(!t)return null;try{return{agentId:decodeURIComponent(t[1]),...t[2]?{tab:t[2]}:{}}}catch{return null}}function Di(e){return`${Je}/conversations/${encodeURIComponent(e)}`}const QP="#/p";function so(e,t,n){const r=`${QP}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return n?`${r}/${encodeURIComponent(n)}`:r}function am(e){const t=/^#\/p\/([^/?]+)\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{plugin:decodeURIComponent(t[1]),page:decodeURIComponent(t[2]),...t[3]?{item:decodeURIComponent(t[3])}:{}}}catch{return null}}const JP="p.";function cm(e,t){return`${Ht}/${encodeURIComponent(v0(e,t))}`}function XP(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const n=decodeURIComponent(t[1]);return{plugin:n,page:t[2]?decodeURIComponent(t[2]):n}}function v0(e,t){return`${JP}${e}${t===e?"":`.${t}`}`}function ht(e){return e?`${Ht}/${e}`:Ht}function ZP(e){return`${ht("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function eI(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}const tI=[{route:Ut,label:"Home"},{route:Oi,label:"Chat"},{route:Xe,label:"Agents"},{route:Je,label:"Activity"},{route:$r,label:"Files"},{route:Ht,label:"Settings"}],nI=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],sI=[{id:"you",label:"Profile",group:"you"},{id:"appearance",label:"Appearance",group:"you"},{id:"memory",label:"Memory",group:"you"},{id:"proposals",label:"Proposals",group:"you"},{id:"accounts",label:"Model accounts",group:"access"},{id:"computer",label:"Computer & browser",group:"access"},{id:"secrets",label:"Keys and secrets",group:"access"},{id:"watchers",label:"Watchers",group:"running"},{id:"backup",label:"Backup",group:"running"},{id:"system",label:"System",group:"running"},{id:"plugins",label:"All plugins",group:"plugins"}];function rI(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const rv=ht("backup");function iI(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return Di(decodeURIComponent(t[1]));const n=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(n)try{return so("email","mail",n[1]?decodeURIComponent(n[1]):null)}catch{return so("email","mail")}return e==="#/settings/email"?cm("email","settings"):{"#/overview":Ut,"#/approvals":Ut,"#/events":`${Je}/events`,"#/jobs":`${Je}/jobs`,"#/conversations":Je,"#/missions":`${Xe}?tab=missions`,"#/offers":`${Xe}?tab=offers`,"#/reminders":`${Xe}?tab=reminders`,"#/providers":ht("accounts"),"#/browser":ht("computer"),"#/sentinels":ht("watchers"),"#/settings/sentinels":ht("watchers")}[e]??null}function lI(e){if(e===""||e==="#"||e===Ut)return Ut;if(e.startsWith(Oi))return Oi;if(e.startsWith(Xe))return Xe;if(e.startsWith(Je))return Je;if(e.startsWith($r))return $r;if(e.startsWith(Ht))return Ht;const t=am(e);return t?so(t.plugin,t.page):Ut}const iv=["coding","finance","mail","research","calendar","files","memory"],oI={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory","front-desk":"buddi"},aI=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function cI(e){const t=new Set(e.map(n=>n.split(".")[0]??n));for(const[n,r]of aI)if(r.some(i=>t.has(i)))return n;return t.size>0&&[...t].every(n=>n==="memory")?"memory":null}let Zf=null;function uI(e){Zf=e}function xo(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const n of e.roles??[]){const r=oI[n];if(r)return{key:r}}const t=cI(e.tools??[]);return t?{key:t}:Zf!==null&&e.id===Zf?{key:"buddi"}:{key:iv[dI(e.id)%iv.length]??"coding"}}function vo(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function dI(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t}const fI=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function hI(e){const n=e.replace(/\r\n/g,`
82
- `).split(`
83
-
84
- `),r=n.pop()??"",i=[];for(const l of n){let o=null,a="message";const c=[];for(const u of l.split(`
85
- `)){if(u===""||u.startsWith(":"))continue;const h=u.indexOf(":"),f=h===-1?u:u.slice(0,h),p=h===-1?"":u.slice(h+1).replace(/^ /,"");f==="id"?o=p:f==="event"?a=p:f==="data"&&c.push(p)}c.length===0&&a==="message"||i.push({id:o,name:fI.includes(a)?a:"ping",data:pI(c.join(`
86
- `))})}return{events:i,rest:r}}function pI(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function j0(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),n=e.wait??(c=>new Promise(u=>setTimeout(u,c))),r=e.retryMs??1500;let i=e.lastEventId??null,l=!1,o=null;return(async()=>{var c,u,h,f;for(;!l;){(c=e.onStatus)==null||c.call(e,"connecting"),o=new AbortController;try{const p=await t(e.url,{credentials:"same-origin",signal:o.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!p.ok||!p.body)throw new Error(`stream ${p.status}`);(u=e.onStatus)==null||u.call(e,"open");const m=p.body.getReader(),j=new TextDecoder;let w="";for(;;){const{done:b,value:x}=await m.read();if(b)break;w+=j.decode(x,{stream:!0});const{events:v,rest:y}=hI(w);w=y;for(const g of v)e.onEvent(g),g.id!==null&&(i=g.id);if(l)break}}catch{}if(l)break;(h=e.onStatus)==null||h.call(e,"closed"),await n(r)}(f=e.onStatus)==null||f.call(e,"closed")})(),{close:()=>{l=!0,o==null||o.abort()},lastEventId:()=>i}}const mI="/api/chat/attention/stream";function y0(e,t){const n=(l,o)=>l.name.localeCompare(o.name),r=l=>e.filter(o=>o.anchor===l).sort(n),i=e.filter(l=>l.anchor!=="top"&&l.anchor!=="bottom").sort((l,o)=>l.id===t?o.id===t?0:-1:o.id===t?1:n(l,o));return{top:r("top"),middle:i,bottom:r("bottom")}}function w0(e,t){const n=y0(e,t);return[...n.top,...n.middle,...n.bottom]}function ou(e){if(!e)return null;const t=[];return e.approvals>0&&t.push(e.approvals===1?"one approval is waiting for you":`${e.approvals} approvals are waiting for you`),e.question&&t.push("asked you a question and is holding for the answer"),t.length===0?null:t.join(", and ")}function gI(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function xI(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function vI(){const[e,t]=d.useState(null);return d.useEffect(()=>{let n=!1;const r=()=>{ae("/chat/attention").then(l=>{n||t(l)}).catch(()=>{})};r();const i=j0({url:mI,onEvent:()=>r()});return()=>{n=!0,i.close()}},[]),xI(e)}const um="maker";function b0(e){return e.filter(t=>t.available&&!t.roles.includes(um))}function k0(e){return b0(e).length>=2}function jI(e){var t;return((t=e.find(n=>n.roles.includes(um)))==null?void 0:t.name)??"the agent maker"}const yI="{{default}}";function wI(e,t){return e.split(yI).join(t??"your assistant")}function bI(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(n=>wI(n,t))}function kI(e){var n,r;const t=(n=e==null?void 0:e.intro)==null?void 0:n.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function SI(e){const t=(e??"·").trim().split(/\s+/).filter(Boolean);return t.length===0?"·":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function S0(e){var r,i;const t=(r=e.heldBack)==null?void 0:r.message.trim();if(t!==void 0&&t!=="")return`${e.name??"This agent"} is held back. ${t}`;const n=(i=e.unavailableReason)==null?void 0:i.trim();return n&&n!==""?`${e.name??"This agent"} cannot run: ${n}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const NI="Settings → Model accounts",CI="Install it in Settings → Plugins";function eh(e){return e!=null&&e.heldBack?{section:"plugins",label:CI}:{section:"accounts",label:NI}}const EI={home:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),s.jsx("path",{d:"M5.2 8.4v7.4a1 1 0 0 0 1 1h2.6v-4.6h2.4v4.6h2.6a1 1 0 0 0 1-1V8.4"})]})],chat:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 10.6a4.9 4.9 0 0 1-4.9 4.9H7.8L3.6 18l.9-3A4.9 4.9 0 0 1 3 11V8.2A4.9 4.9 0 0 1 7.9 3.3h4.2A4.9 4.9 0 0 1 17 8.2Z"}),s.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),s.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),s.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),s.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,s.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 5.5h14M3 10h14M3 14.5h14"}),s.jsx("circle",{cx:"7.5",cy:"5.5",r:"1.7",fill:"var(--surface)"}),s.jsx("circle",{cx:"12.5",cy:"10",r:"1.7",fill:"var(--surface)"}),s.jsx("circle",{cx:"6.5",cy:"14.5",r:"1.7",fill:"var(--surface)"})]})],files:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 2.8h5.2L16.5 6.6v8.6a1.2 1.2 0 0 1-1.2 1.2H7.5a1.2 1.2 0 0 1-1.2-1.2V4a1.2 1.2 0 0 1 1.2-1.2z"}),s.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),s.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),s.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),s.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),s.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,s.jsx("path",{d:"M3.2 16.4V8.6M8.4 16.4V3.9M13.6 16.4v-5.8M3.2 16.4h13.6"})],bell:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),s.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),s.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),s.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),s.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),s.jsx("path",{d:"M2.9 10h14.2M10 2.9c3.4 3.7 3.4 10.5 0 14.2-3.4-3.7-3.4-10.5 0-14.2Z"})]})],person:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),s.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],sun:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),s.jsx("path",{d:"M10 2.6v1.6M10 15.8v1.6M2.6 10h1.6M15.8 10h1.6M4.8 4.8l1.1 1.1M14.1 14.1l1.1 1.1M4.8 15.2l1.1-1.1M14.1 5.9l1.1-1.1"})]})],notebook:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.5 3.2h8.3a1 1 0 0 1 1 1v11.6a1 1 0 0 1-1 1H5.5a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1Z"}),s.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),s.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),s.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],eye:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.4 10S5.2 4.8 10 4.8 17.6 10 17.6 10 14.8 15.2 10 15.2 2.4 10 2.4 10Z"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),s.jsx("path",{d:"M4 7.2v8a1.2 1.2 0 0 0 1.2 1.2h9.6a1.2 1.2 0 0 0 1.2-1.2v-8M8.2 10.4h3.6"})]})],chip:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),s.jsx("path",{d:"M8 2.8v2.6M12 2.8v2.6M8 14.6v2.6M12 14.6v2.6M2.8 8h2.6M2.8 12h2.6M14.6 8h2.6M14.6 12h2.6"})]})],clip:[17,1.5,s.jsx("path",{d:"M13.2 8 8.4 12.8a3 3 0 0 1-4.2-4.2l5.1-5.1a2 2 0 1 1 2.8 2.8l-5 5"})],send:[16,1.8,s.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],thought:[13,1.4,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),s.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,s.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],out:[12,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),s.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,s.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,s.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,s.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],"chevron-down":[14,1.4,s.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),s.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),s.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,s.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,s.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,s.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,s.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-document":[16,1.4,s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,s.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 11l3.6-3.4 2.6 2.4 2-1.8 3.4 3M10.6 6.2h.01"})],"shape-preview":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 6h11.6M4.1 4.7h.01M6 4.7h.01"})],"shape-envelope":[16,1.4,s.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],"shape-structured":[16,1.4,s.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function Oe({name:e,size:t,className:n,...r}){const[i,l,o,a]=EI[e],c=t??a??i;return s.jsx("svg",{className:n,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:l,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:o})}const N0="buddi.rosterCollapsed";function AI(){try{return window.localStorage.getItem(N0)==="1"}catch{return!1}}function RI(e){try{window.localStorage.setItem(N0,e?"1":"0")}catch{}}function C0({agents:e,currentId:t,attention:n,onSelect:r,orientation:i="vertical",lastActivity:l,groups:o=[],currentGroupId:a=null,onSelectGroup:c,onNewGroup:u}){const h=[...e.top,...e.middle,...e.bottom],f=i==="vertical"?"right":"bottom",[p,m]=d.useState(AI),j=w=>s.jsx(TI,{agent:w,active:w.id===t,attention:n.get(w.id),side:f,onSelect:r,lastAt:(l==null?void 0:l.get(w.id))??null},w.id);return s.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&p?"true":void 0,children:[e.top.map(j),e.top.length>0&&e.middle.length>0?s.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!p&&e.middle.length>0?s.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,s.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(j),c&&k0(h)?s.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[s.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),s.jsxs("div",{className:"wb-groups-head",children:[s.jsx("span",{className:"wb-groups-label",children:"Groups"}),u?s.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"New group",title:"A team of agents in one conversation",onClick:u,children:s.jsx(Oe,{name:"plus"})}):null]}),o.map(w=>s.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":w.id===a?"true":void 0,"aria-current":w.id===a?"true":void 0,"aria-label":`${w.name}, ${w.members.length} agents`,onClick:()=>c(w.id),children:[s.jsxs("span",{className:"wb-face-mark wb-group-stack","aria-hidden":"true",children:[w.members.slice(0,3).map(b=>{const x=h.find(v=>v.id===b);return s.jsx(dm,{className:"wb-group-chip",id:b,name:(x==null?void 0:x.name)??"?",face:x,initials:1},b)}),w.members.length>3?s.jsxs("span",{className:"wb-group-chip wb-group-more",children:["+",w.members.length-3]}):null]}),s.jsxs("span",{className:"wb-face-text",children:[s.jsx("span",{className:"wb-face-name",children:w.name}),s.jsx("span",{className:"wb-face-status",children:w.members.map(b=>{var x;return((x=h.find(v=>v.id===b))==null?void 0:x.name)??b}).join(", ")})]})]},w.id))]}):null]}),e.bottom.map(j),i==="vertical"?s.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":p?"Show agent names":"Hide agent names","aria-pressed":p,onClick:()=>m(w=>(RI(!w),!w)),children:s.jsx(Oe,{name:p?"chevron-right":"chevron-left"})}):null]})}function TI({agent:e,active:t,attention:n,side:r,onSelect:i,lastAt:l=null}){const o=ou(n),a=o?lv(o):e.available?l?`Last spoke ${Se(l)}`:e.description:e.unavailableReason??"Cannot run right now",c=gI(n),u=e.unavailableReason??"This agent cannot run on this machine right now.",h=[e.name,e.available?null:"unavailable",o,t?"current":null].filter(f=>f!==null&&f!=="").join(" — ");return s.jsxs(mc,{children:[s.jsx(gc,{asChild:!0,children:s.jsxs("button",{className:"wb-face",...vo(xo(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":h,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[s.jsx(dm,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),s.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[s.jsxs("span",{className:"wb-face-name",children:[e.name,s.jsxs("span",{className:"wb-face-handle",children:["@",e.handle]})]}),s.jsx("span",{className:"wb-face-status","data-tone":o?"critical":void 0,children:a})]}),c?s.jsx("span",{className:"wb-face-badge","data-kind":c.count===null?"dot":"count","data-testid":`agent-badge-${e.id}`,"aria-hidden":"true",children:c.count===null?"":c.count}):null,e.available?null:s.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:s.jsx(Oe,{name:"out"})})]})}),s.jsx(xc,{children:s.jsxs(vc,{className:"ui-tip",side:r,sideOffset:8,children:[s.jsx("span",{className:"ui-tip-title",children:e.name}),s.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:u}),o?s.jsx("span",{className:"ui-tip-alert",children:lv(o)}):null]})})]})}function lv(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function PI(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t%6+1}function dm({className:e,id:t,name:n,face:r,tint:i,size:l,unavailable:o,initials:a=2}){const[c,u]=d.useState(null),h=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,f=r==null?void 0:r.avatar,p=h?"image":f==null?void 0:f.kind,m=t?vo(xo({id:t,accent:r==null?void 0:r.accent,roles:r==null?void 0:r.roles,tools:r==null?void 0:r.tools})):void 0;return s.jsx("span",{className:e,"data-tint":m?void 0:i,"data-size":l,"data-kind":p,"data-unavailable":o?"true":void 0,...m,"aria-hidden":"true",children:h?s.jsx("img",{src:h,alt:"",onError:()=>u(h)}):(f==null?void 0:f.kind)==="image"?s.jsx("img",{src:f.url,alt:""}):(f==null?void 0:f.kind)==="emoji"?f.value:SI(n).slice(0,a)})}function Ps({id:e,name:t,size:n,unavailable:r,face:i}){return s.jsx(dm,{className:"ui-avatar",id:e,tint:PI(e),name:t,size:n,unavailable:r,face:i})}function bn({agents:e,id:t,size:n}){const r=e.find(i=>i.id===t);return s.jsx(Ps,{id:t,name:(r==null?void 0:r.name)??t,size:n,unavailable:r?!r.available:!1,face:r})}const E0=d.createContext(null);function II({picture:e,children:t}){return s.jsx(E0.Provider,{value:e??null,children:t})}function A0({size:e}){const t=d.useContext(E0),[n,r]=d.useState(null);return!t||t===n?null:s.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:s.jsx("img",{src:t,alt:"",onError:()=>r(t)})})}const R0=d.createContext([]);function _r({text:e,className:t}){const n=th(e.replace(/\r\n/g,`
87
- `).split(`
88
- `));return s.jsx("div",{className:t??"wb-md",children:n.map((r,i)=>s.jsx(nh,{block:r},i))})}const ov=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,av=/^(#{1,6})\s+(.*?)\s*#*\s*$/,cv=/^\s*([-*_])(\s*\1){2,}\s*$/,ra=/^(\s*)([-*+])\s+(.*)$/,gl=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,ia=/^\s*>\s?(.*)$/,ad=/^\s*\|.*\|\s*$/,uv=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function th(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r.trim()===""){n+=1;continue}const i=ov.exec(r);if(i){const a=i[2],c=[];for(n+=1;n<e.length&&!new RegExp(`^\\s*${a}\\s*$`).test(e[n]);)c.push(e[n]),n+=1;n+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
89
- `)});continue}const l=av.exec(r);if(l){t.push({type:"h",level:l[1].length,text:l[2]}),n+=1;continue}if(cv.test(r)){t.push({type:"hr"}),n+=1;continue}if(ia.test(r)){const a=[];for(;n<e.length&&ia.test(e[n]);)a.push(ia.exec(e[n])[1]),n+=1;t.push({type:"quote",blocks:th(a),raw:a.join(`
90
- `)});continue}if(ad.test(r)&&n+1<e.length&&uv.test(e[n+1])){const a=ud(r),c=ud(e[n+1]).map(h=>{const f=h.startsWith(":"),p=h.endsWith(":");return f&&p?"center":p?"right":f?"left":null});n+=2;const u=[];for(;n<e.length&&ad.test(e[n]);)u.push(ud(e[n])),n+=1;t.push({type:"table",head:a,rows:u,align:c});continue}if(ra.test(r)||gl.test(r)){const a=gl.exec(r)??ra.exec(r),c=gl.test(r),u=a[1].length,h=c?Number(a[2]):1,f=[];for(;n<e.length;){const p=c?gl.exec(e[n]):ra.exec(e[n]);if(!p||p[1].length!==u)break;const m=[p[3]];for(n+=1;n<e.length;){const j=e[n],w=j.trim()!==""&&cd(j)>u,b=j.trim()===""&&n+1<e.length&&e[n+1].trim()!==""&&cd(e[n+1])>u;if(!w&&!b)break;m.push(j.trim()===""?"":j.slice(Math.min(cd(j),u+2))),n+=1}f.push(th(m))}t.push({type:"list",ordered:c,start:h,items:f});continue}const o=[];for(;n<e.length;){const a=e[n];if(a.trim()===""||ov.test(a)||av.test(a)||cv.test(a)||ia.test(a)||ra.test(a)||gl.test(a)||ad.test(a)&&n+1<e.length&&uv.test(e[n+1]))break;o.push(a.trim()),n+=1}o.length>0&&t.push({type:"p",text:o.join(`
91
- `)})}return t}function cd(e){return e.length-e.trimStart().length}function ud(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="";for(let i=0;i<t.length;i+=1){const l=t[i];if(l==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(l==="|"){n.push(r.trim()),r="";continue}r+=l}return n.push(r.trim()),n}function nh({block:e}){switch(e.type){case"p":return s.jsx("p",{children:$n(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),n=`h${Math.min(t+2,6)}`;return s.jsx(n,{className:"wb-md-h","data-level":t,children:$n(e.text)})}case"code":return s.jsxs("div",{className:"wb-md-code-frame",children:[s.jsxs("div",{className:"wb-md-code-head",children:[s.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),s.jsx(dv,{text:e.text,what:"code",always:!0})]}),s.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:s.jsx("code",{children:e.text})})]});case"quote":return s.jsxs("div",{className:"wb-md-copyable",children:[s.jsx("blockquote",{children:e.blocks.map((t,n)=>s.jsx(nh,{block:t},n))}),s.jsx(dv,{text:e.raw,what:"quote"})]});case"hr":return s.jsx("hr",{});case"list":{const t=e.items.map((n,r)=>s.jsx("li",{children:n.map((i,l)=>i.type==="p"?s.jsx(d.Fragment,{children:$n(i.text)},l):s.jsx(nh,{block:i},l))},r));return e.ordered?s.jsx("ol",{start:e.start,children:t}):s.jsx("ul",{children:t})}case"table":return s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table wb-md-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.head.map((t,n)=>s.jsx("th",{style:e.align[n]?{textAlign:e.align[n]}:void 0,children:$n(t)},n))})}),s.jsx("tbody",{children:e.rows.map((t,n)=>s.jsx("tr",{children:t.map((r,i)=>s.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:$n(r)},i))},n))})]})})}}function dv({text:e,what:t,always:n=!1}){const[r,i]=d.useState("idle"),l=()=>{var o;if(!((o=navigator.clipboard)!=null&&o.writeText)){i("failed");return}navigator.clipboard.writeText(e).then(()=>i("done"),()=>i("failed")),window.setTimeout(()=>i("idle"),1500)};return s.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":n||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:l,children:r==="done"?"Copied":r==="failed"?"Select to copy":s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),s.jsx("path",{d:"M8.5 4.5V3a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4.5a1 1 0 0 0 1 1h1.5"})]})})}function MI({handle:e}){const n=d.useContext(R0).find(r=>r.handle.toLowerCase()===e.toLowerCase());return n?s.jsxs(mc,{children:[s.jsx(gc,{asChild:!0,children:s.jsxs("a",{className:"wb-mention-link",href:De(n.id),children:["@",n.handle]})}),s.jsx(xc,{children:s.jsxs(vc,{className:"wb-agent-card",sideOffset:6,children:[s.jsx(Ps,{id:n.id,name:n.name,face:n,unavailable:!n.available}),s.jsxs("span",{className:"wb-agent-card-text",children:[s.jsx("span",{className:"wb-agent-card-name",children:n.name}),s.jsx("span",{className:"wb-agent-card-desc",children:n.description}),s.jsxs("span",{className:"wb-agent-card-meta",children:[n.model,n.available?"":" · unavailable"]})]})]})})]}):s.jsxs(s.Fragment,{children:["@",e]})}const $I=new RegExp("(`+)([\\s\\S]*?[^`])\\1(?!`)|\\*\\*([^*]+?)\\*\\*|__([^_]+?)__|~~([^~]+?)~~|(?<![\\w*])\\*([^*\\n]+?)\\*(?![\\w*])|(?<![\\w_])_([^_\\n]+?)_(?![\\w_])|\\[([^\\]\\n]+)\\]\\((https?:\\/\\/[^\\s)]+)\\)|<?(https?:\\/\\/[^\\s<>)\\]]+[^\\s<>)\\].,;:!?'\"])>?|(?<![\\w@/])@([a-z0-9][a-z0-9_-]{0,63})(?![\\w-])","i");function $n(e){const t=[];let n=e,r=0;for(;n!=="";){const i=$I.exec(n);if(!i){t.push(...fv(n,r));break}i.index>0&&t.push(...fv(n.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(s.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(s.jsx("strong",{children:$n(i[3])},r)):i[4]!==void 0?t.push(s.jsx("strong",{children:$n(i[4])},r)):i[5]!==void 0?t.push(s.jsx("s",{children:$n(i[5])},r)):i[6]!==void 0?t.push(s.jsx("em",{children:$n(i[6])},r)):i[7]!==void 0?t.push(s.jsx("em",{children:$n(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(s.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:$n(i[8])},r)):i[10]!==void 0?t.push(s.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(s.jsx(MI,{handle:i[11]},r)),n=n.slice(i.index+i[0].length)}return t}function fv(e,t){return e.split(`
92
- `).flatMap((r,i)=>i===0?[r]:[s.jsx("br",{},`${t}-br-${i}`),r])}function _I({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:mt(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?s.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?s.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:s.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?s.jsx("div",{className:"wb-doc",children:s.jsx(_r,{text:e.text})}):s.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}function me(e,t){if(t===""||t==="$")return e;let n=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,l="",o=""]=i;if(l!==""){if(n===null||typeof n!="object")return;n=n[l]}for(const a of o.match(/\d+/g)??[]){if(!Array.isArray(n))return;n=n[Number(a)]}if(n===void 0)return}return n}function be(e,t){if(t)return"const"in t?t.const:me(e,t.path)}function er(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function ze(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Nr(e){return Array.isArray(e)?e:[]}function OI(e,t){const n=Nr(me(e,t.points)).map(i=>{const l=er(me(i,t.y)),o=ze(me(i,t.x));return l===null||o===null?null:{x:o,y:l}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const l=er(be(e,i.value));return l===null?null:{value:l,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:n,unit:t.unit??"number",currency:ze(be(e,t.currency)),label:ze(be(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:er(be(e,t.shadeBelow)),events:DI(e,t)}}function DI(e,t){const n=t.events;if(!n)return[];const r=[],i=(l,o)=>{const a=ze(me(l,n.label));if(a===null)return;const c=ze(me(l,n.at))??o;c!==null&&r.push({at:c,label:a,amount:n.amount?er(me(l,n.amount)):null})};if(n.parent){for(const l of Nr(me(e,t.points))){const o=ze(me(l,t.x));for(const a of Nr(me(l,n.parent)))i(a,o)}return r}for(const l of Nr(me(e,n.path??t.points)))i(l,null);return r}function LI(e,t){const n=(t.columns??[]).map(a=>({key:a.key,label:a.label,type:a.type??"text"})),r=a=>(t.columns??[]).map(c=>{const u=me(a,c.key);let h=null;if(c.bar){const f=er(be(a,c.bar.max))??er(be(e,c.bar.max)),p=er(u);if(f!==null&&f>0&&p!==null){const m=Math.max(0,Math.min(1,p/f));h={fraction:m,tone:UI(m*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:ze(be(a,c.currency))??ze(be(e,c.currency)),bar:h}}),i=Nr(me(e,t.rows)),l=t.groupBy?FI(i,t.groupBy,r):[{label:null,rows:i.map(r)}],o=(t.summary??[]).map(a=>({label:a.label,value:be(e,a.value),unit:a.unit??"text",currency:ze(be(e,a.currency)),tone:a.tone??"neutral"}));return{columns:n,groups:l,summary:o,empty:t.empty??"Nothing to show."}}function FI(e,t,n){const r=new Map;for(const i of e){const l=String(me(i,t.key)??""),o=r.get(l);o?o.push(i):r.set(l,[i])}return[...r.entries()].map(([i,l])=>{var o;return{label:((o=t.labels)==null?void 0:o[i])??i,rows:l.map(n)}})}function UI(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,l)=>l.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function BI(e,t){return{bars:Nr(me(e,t.bars)).map(r=>{const i=er(me(r,t.value)),l=ze(me(r,t.category));return i===null||l===null?null:{category:l,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:ze(be(e,t.currency))}}function zI(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:be(e,r.value),unit:r.unit??"text",currency:ze(be(e,r.currency)),tone:r.tone??"neutral"}))};const n=me(e,t.from??"$");return n===null||typeof n!="object"||Array.isArray(n)?{pairs:[]}:{pairs:Object.entries(n).map(([r,i])=>({label:Lt(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}function WI(e,t){const n=ze(be(e,t.kind)),r=n==="image"||n==="pdf"?n:"text",i=t.src?ze(me(e,t.src)):null;return{kind:r,text:t.text?ze(me(e,t.text)):null,src:i&&P0(i)?i:null,title:ze(be(e,t.title)),metadata:(t.metadata??[]).map(l=>({label:l.label,value:be(e,l.value),unit:l.unit??"text"}))}}function VI(e,t){const n=t.diff?me(e,t.diff):void 0;return{diff:typeof n=="string"&&n.trim()!==""?n:null,title:ze(be(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:be(e,r.value),unit:r.unit??"text"}))}}function HI(e,t){const n=t.output?me(e,t.output):void 0,r=o=>{const a=o?me(e,o):void 0;return typeof a=="number"&&Number.isInteger(a)?a:null},i=r(t.omittedBytes),l=t.elapsedMs?me(e,t.elapsedMs):void 0;return{command:ze(be(e,t.command)),output:typeof n=="string"?n:null,exitCode:r(t.exitCode),elapsedMs:typeof l=="number"&&Number.isFinite(l)&&l>=0?l:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(o=>({label:o.label,value:be(e,o.value),unit:o.unit??"text"}))}}const KI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function T0(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&KI.test(t)?t.toLowerCase():null}function GI(e,t){return{artifactId:t.src?T0(me(e,t.src)):null,title:ze(be(e,t.title)),caption:ze(be(e,t.caption)),...t.captionLabel?{captionLabel:ze(be(e,t.captionLabel))}:{}}}function hv(e){if(!P0(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const n=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return n?{plugin:n[1],name:n[2]}:null}function YI(e,t){const n=t.src?ze(me(e,t.src)):null,r=t.port?me(e,t.port):null,i=t.awaiting?ze(me(e,t.awaiting)):null;return{target:n?hv(n):null,title:ze(be(e,t.title)),output:t.output?ze(me(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?hv(i):null,reloadsItself:t.reloadsItself?me(e,t.reloadsItself)===!0:!1,ports:t.ports?qI(me(e,t.ports)):[]}}function qI(e){const t=Nr(e).filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>0&&n<=65535);return[...new Set(t)].sort((n,r)=>n-r)}function P0(e){return e.startsWith("/")&&!e.startsWith("//")}function Lt(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function I0(e,t){const n=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:OI(t,n)};case"table":return{renderer:"table",props:LI(t,n)};case"bars":return{renderer:"bars",props:BI(t,n)};case"keyvalue":return{renderer:"keyvalue",props:zI(t,n)};case"document":return{renderer:"document",props:WI(t,n)};case"diff":return{renderer:"diff",props:VI(t,n)};case"terminal":return{renderer:"terminal",props:HI(t,n)};case"image":return{renderer:"image",props:GI(t,n)};case"preview":return{renderer:"preview",props:YI(t,n)};default:return{renderer:"structured",props:{value:t}}}}var QI=Object.defineProperty,zn=(e,t)=>QI(e,"name",{value:t,configurable:!0}),fm="Dialog",[M0,h3]=Un(fm),[JI,Is]=M0(fm),XI=zn(e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:l,modal:o=!0}=e,a=d.useRef(null),c=d.useRef(null),[u,h]=Qi({prop:r,defaultProp:i??!1,onChange:l,caller:fm}),[f,p]=d.useState(0),[m,j]=d.useState(0);return s.jsx(JI,{scope:t,triggerRef:a,contentRef:c,contentId:xs(),titleId:xs(),descriptionId:xs(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:j,open:u,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(w=>!w),[h]),modal:o,children:n})},"Dialog"),$0="DialogPortal",[ZI,_0]=M0($0,{forceMount:void 0}),e2=zn(e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,l=Is($0,t);return s.jsx(ZI,{scope:t,forceMount:n,children:d.Children.map(r,o=>s.jsx(ur,{present:n||l.open,children:s.jsx($p,{asChild:!0,container:i,children:o})}))})},"DialogPortal"),sh="DialogOverlay",t2=d.forwardRef(zn(function(t,n){const r=_0(sh,t.__scopeDialog),{forceMount:i=r.forceMount,...l}=t,o=Is(sh,t.__scopeDialog);return o.modal?s.jsx(ur,{present:i||o.open,children:s.jsx(s2,{...l,ref:n})}):null},"DialogOverlay")),n2=sr("DialogOverlay.RemoveScroll"),s2=d.forwardRef(zn(function(t,n){const{__scopeDialog:r,...i}=t,l=Is(sh,r),o=Mw(),a=Ge(n,o);return s.jsx(Yp,{as:n2,allowPinchZoom:!0,shards:[l.contentRef],children:s.jsx(qe.div,{"data-state":hm(l.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),ro="DialogContent",r2=d.forwardRef(zn(function(t,n){const r=_0(ro,t.__scopeDialog),{forceMount:i=r.forceMount,...l}=t,o=Is(ro,t.__scopeDialog);return s.jsx(ur,{present:i||o.open,children:o.modal?s.jsx(i2,{...l,ref:n}):s.jsx(l2,{...l,ref:n})})},"DialogContent")),i2=d.forwardRef(zn(function(t,n){const r=Is(ro,t.__scopeDialog),i=d.useRef(null),l=Ge(n,r.contentRef,i);return d.useEffect(()=>{const o=i.current;if(o)return Hb(o)},[]),s.jsx(O0,{...t,ref:l,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:je(t.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:je(t.onPointerDownOutside,o=>{const a=o.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&o.preventDefault()}),onFocusOutside:je(t.onFocusOutside,o=>o.preventDefault())})},"DialogContentModal")),l2=d.forwardRef(zn(function(t,n){const r=Is(ro,t.__scopeDialog),i=d.useRef(!1),l=d.useRef(!1);return s.jsx(O0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,c;(a=t.onCloseAutoFocus)==null||a.call(t,o),o.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),o.preventDefault()),i.current=!1,l.current=!1},onInteractOutside:o=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const a=o.target;((h=r.triggerRef.current)==null?void 0:h.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&l.current&&o.preventDefault()}})},"DialogContentNonModal")),O0=d.forwardRef(zn(function(t,n){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:l,onCloseAutoFocus:o,...a}=t,c=Is(ro,r);return nu(),s.jsx(s.Fragment,{children:s.jsx(Eb,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:l,onUnmountAutoFocus:o,children:s.jsx(Ip,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":hm(c.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),o2="DialogTitle",a2=d.forwardRef(zn(function(t,n){const{__scopeDialog:r,...i}=t,l=Is(o2,r),{setTitleCount:o}=l;return Qt(()=>(o(a=>a+1),()=>o(a=>a-1)),[o]),s.jsx(qe.h2,{id:l.titleId,...i,ref:n})},"DialogTitle")),c2="DialogClose",u2=d.forwardRef(zn(function(t,n){const{__scopeDialog:r,...i}=t,l=Is(c2,r);return s.jsx(qe.button,{type:"button",...i,ref:n,onClick:je(t.onClick,()=>l.onOpenChange(!1))})},"DialogClose"));function hm(e){return e?"open":"closed"}zn(hm,"getState");const d2=5;function le(e,t,n){const[r,i]=d.useState(void 0),[l,o]=d.useState(null),[a,c]=d.useState(!0),[u,h]=d.useState(0),[f,p]=d.useState(0),m=d.useRef(e);return m.current=e,d.useEffect(()=>{let j=!1;return c(!0),m.current().then(w=>{j||(i(w),o(null),p(0))}).catch(w=>{j||(o(w instanceof pe?w.message:String(w)),p(b=>b+1))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[...t,u]),d.useEffect(()=>{if(!n||f>=d2)return;const j=window.setTimeout(()=>h(w=>w+1),n*2**f);return()=>window.clearTimeout(j)},[n,f,u]),{data:r,error:l,loading:a,reload:()=>{p(0),h(j=>j+1)}}}function Hr(...e){return e.filter(Boolean).join(" ")}function P({variant:e,size:t,className:n,type:r="button",...i}){return s.jsx("button",{type:r,className:Hr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function Fn({variant:e,size:t,className:n,...r}){return s.jsx("a",{className:Hr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function J({children:e,align:t,valign:n,className:r}){return s.jsx("div",{className:Hr("ui-toolbar",r),"data-align":t,"data-valign":n,children:e})}function tl(){return s.jsx("span",{className:"ui-toolbar-spacer"})}function ee({label:e,hint:t,inline:n,grow:r,wide:i,children:l}){return s.jsxs("div",{className:"ui-field","data-inline":n?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[s.jsxs("label",{className:"ui-field-control",children:[s.jsx("span",{className:"ui-field-label",children:e}),l]}),t?s.jsx("span",{className:"ui-field-hint",children:t}):null]})}function Es({children:e,dense:t}){return s.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,children:e})}function fe({tone:e,mono:t,dot:n,children:r,className:i,title:l}){return s.jsxs("span",{className:Hr("ui-pill",t&&"mono",i),"data-tone":e,title:l,children:[n?s.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function _a({children:e}){return s.jsx("span",{className:"ui-tag",children:e})}function au({state:e}){const t=e==="succeeded"||e==="approved"||e==="fired"||e==="running"||e==="leased"?"good":e==="failed"||e==="rejected"||e==="unknown"||e==="error"||e==="refused"?"critical":e==="pending"||e==="suspended"||e==="expired"||e==="paused"?"warning":void 0;return s.jsx(fe,{tone:t,children:e})}function G({tone:e,title:t,children:n,role:r}){return s.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?s.jsx("div",{className:"ui-notice-title",children:t}):null,n]})}function ie({message:e}){return e?s.jsx(G,{tone:"critical",role:"alert",children:e}):null}function oe({mascot:e,warm:t,title:n,action:r,children:i}){return t||n?s.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[n?s.jsx("div",{className:"ui-empty-title",children:n}):null,s.jsx("div",{children:i}),r]}):e?s.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[s.jsx(A0,{size:"sm"}),s.jsx("p",{children:i})]}):s.jsx("p",{className:"ui-empty",children:i})}function gt({icon:e,title:t,action:n,children:r}){return s.jsxs("div",{className:"ui-empty-state",children:[e?s.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?s.jsx(Oe,{name:e}):e}):null,s.jsx("div",{className:"ui-empty-state-title",children:t}),r?s.jsx("p",{className:"ui-empty-state-line",children:r}):null,n?s.jsx("div",{className:"ui-empty-state-action",children:n}):null]})}function f2({children:e}){return s.jsx("div",{className:"ui-page",children:e})}function pm({title:e,lede:t,actions:n,before:r}){return s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[r,s.jsx("span",{children:e})]}),n?s.jsx("div",{className:"ui-page-actions",children:n}):null]}),t?s.jsx("p",{className:"ui-page-lede",children:t}):null]})}function en({embedded:e,title:t,lede:n,actions:r,children:i}){return e?s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):s.jsxs(f2,{children:[s.jsx(pm,{title:t,lede:n,actions:r}),i]})}function Y({title:e,aside:t,actions:n,panel:r,flush:i,foot:l,children:o}){const a=e||t||n?s.jsxs("div",{className:"ui-section-head",children:[e?s.jsx("h3",{className:"ui-section-title",children:e}):s.jsx("span",{}),t||n?s.jsxs("div",{className:"ui-section-side",children:[t?s.jsx("span",{className:"ui-section-aside",children:t}):null,n?s.jsx("div",{className:"ui-section-actions",children:n}):null]}):null]}):null;return s.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[a,r?s.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[o,l?s.jsx("div",{className:"ui-panel-foot",children:l}):null]}):s.jsxs(s.Fragment,{children:[o,l?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:l}):null]})]})}function st({title:e,tool:t,actions:n,flush:r,children:i}){return s.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||n?s.jsxs("header",{className:"ui-panel-head",children:[e?s.jsx("h3",{className:"ui-panel-title",children:e}):s.jsx("span",{}),t?s.jsx("span",{className:"ui-panel-tool",children:t}):null,n?s.jsx("div",{className:"ui-panel-actions",children:n}):null]}):null,i]})}function Or({tone:e,title:t,meta:n,actions:r,children:i,foot:l,as:o="div"}){return s.jsxs(o,{className:"ui-card","data-tone":e,children:[t||n||r?s.jsxs("div",{className:"ui-card-head",children:[t?s.jsx("h3",{className:"ui-card-title",children:t}):null,n,r?s.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,l?s.jsx("div",{className:"ui-card-foot",children:l}):null]})}function q({gap:e,divided:t,children:n}){return s.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:n})}function rh({children:e}){return s.jsx("div",{className:"ui-row",children:e})}function cu({inline:e,children:t}){return s.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function Xn({label:e,value:t,note:n,tone:r,size:i}){return s.jsxs("div",{className:"ui-stat",children:[s.jsx("div",{className:"ui-stat-k",children:e}),s.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),n?s.jsx("div",{className:"ui-stat-n",children:n}):null]})}function bt({items:e}){return s.jsx("dl",{className:"ui-kv",children:e.map((t,n)=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:t.value})]},t.key??n))})}function Zt({children:e}){return s.jsx("div",{className:"ui-table-wrap",children:s.jsx("table",{className:"ui-table",children:e})})}function h2({value:e,label:t}){const n=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return s.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-valuetext":`${n}%`,children:s.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${n}%`}})})}function rt({children:e,label:t}){return s.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function Nt({summary:e,boxed:t,open:n,className:r,onToggle:i,children:l}){return s.jsxs("details",{className:Hr("ui-details",r),"data-boxed":t?"true":void 0,open:n,onToggle:i?o=>i(o.currentTarget.open):void 0,children:[s.jsx("summary",{children:e}),l]})}function Wt({title:e,onClose:t,size:n,children:r}){return s.jsx(XI,{open:!0,onOpenChange:i=>{i||t()},children:s.jsxs(e2,{children:[s.jsx(t2,{className:"ui-sheet-overlay"}),s.jsxs(r2,{className:"ui-sheet","data-size":n,"aria-describedby":void 0,children:[s.jsxs("div",{className:"ui-sheet-head",children:[s.jsx(a2,{className:"ui-sheet-title",children:e}),s.jsx(u2,{asChild:!0,children:s.jsx(P,{size:"sm",children:"Close"})})]}),r]})]})})}function mm({children:e}){return s.jsx("nav",{className:"ui-tabs",children:e})}function gm({href:e,active:t,count:n,onClick:r,children:i}){return s.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,n?s.jsx("span",{className:"ui-count",children:n}):null]})}function Oa({label:e,options:t,value:n,onChange:r}){return s.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>s.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===n,onClick:()=>r(i.value),children:i.label},i.value))})}function un({children:e}){return s.jsx("div",{className:"ui-list",children:e})}function Cn({href:e,onClick:t,lead:n,title:r,sub:i,side:l}){const o=s.jsxs(s.Fragment,{children:[n,s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:r}),i?s.jsx("span",{className:"ui-list-sub",children:i}):null]}),l?s.jsx("span",{className:"ui-list-side",children:l}):null]});return e?s.jsx("a",{className:"ui-list-row",href:e,onClick:t?a=>{a.preventDefault(),t()}:void 0,children:o}):s.jsx("div",{className:"ui-list-row",children:o})}function D0({href:e,onClick:t,current:n,lead:r,title:i,meta:l,sub:o,snippet:a,side:c}){return s.jsxs("a",{className:"ui-pick",href:e,"aria-current":n?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?s.jsx("span",{className:"ui-pick-lead",children:r}):null,s.jsxs("span",{className:"ui-pick-main",children:[s.jsxs("span",{className:"ui-pick-top",children:[s.jsx("span",{className:"ui-pick-title",children:i}),l?s.jsx("span",{className:"ui-pick-meta",children:l}):null]}),o||c?s.jsxs("span",{className:"ui-pick-line",children:[o?s.jsx("span",{className:"ui-pick-sub",children:o}):null,c?s.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,a?s.jsx("span",{className:"ui-pick-snippet",children:a}):null]})]})}function L0({list:e,detail:t,empty:n,label:r,className:i}){return s.jsxs("div",{className:Hr("ui-split",i),"data-open":t?"true":void 0,children:[s.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),s.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??s.jsx("p",{className:"ui-empty ui-split-empty",children:n})})]})}function ih({children:e,onRemove:t,label:n}){return s.jsxs("span",{className:"ui-chip",children:[e,s.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${n}`,onClick:t,children:"×"})]})}function F0({main:e,filters:t,filtersOpen:n,onToggleFilters:r,active:i,chips:l,actions:o,onSubmit:a,label:c}){return s.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),a()},children:[s.jsxs("div",{className:"ui-searchbar-row",children:[e?s.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?s.jsxs(P,{"aria-expanded":n===!0,"aria-pressed":n===!0,onClick:r,children:["Filters",i?s.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?s.jsx("div",{className:"ui-searchbar-inline",children:t}):null,o?s.jsx("div",{className:"ui-searchbar-actions",children:o}):null]}),t&&r&&n?s.jsx("div",{className:"ui-searchbar-filters",children:t}):null,l?s.jsx("div",{className:"ui-searchbar-chips",children:l}):null]})}function U0({size:e}){return s.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function p2({quiet:e,still:t,className:n,children:r}){return s.jsx("div",{className:Hr("ui-fieldbg",n),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function m2(e){const t={};for(const n of e??[])t[n.key]=n.default;return t}function xm(e){const[t,n]=d.useState({}),r=e??[],i={...m2(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:s.jsx("div",{className:"ui-choices",children:r.map(l=>s.jsx(ee,{label:l.label,inline:!0,children:s.jsx("select",{value:i[l.key],onChange:o=>n(a=>({...a,[l.key]:o.target.value})),children:l.options.map(o=>s.jsx("option",{value:o,children:o},o))})},l.key))})}}function g2({props:e,timezone:t="UTC",onDecided:n}){var v;const[r,i]=d.useState(null),[l,o]=d.useState(null),[a,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let y=!1;return i(null),o(null),A.approval(e.approvalId).then(g=>{y||i(g)}).catch(g=>{y||o(g instanceof pe?g.message:String(g))}),()=>{y=!0}},[e.approvalId]);const{values:f,controls:p}=xm(r==null?void 0:r.choices),m=(y,g)=>{h(y),o(null),(f&&y==="approve"?A.decide(e.approvalId,y,g,f):A.decide(e.approvalId,y,g)).then(S=>{i(S.action),n==null||n(S.action)}).catch(S=>o(S instanceof pe?S.message:String(S))).finally(()=>h(null))};if(l&&!r)return s.jsx("p",{className:"wb-empty",children:l});if(!r)return s.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const j=r.state==="pending",w=(v=r.permissionScopes)==null?void 0:v.includes("always"),b=x2(r),x=(r.preview??"").split(`
93
- `).length>12||(r.preview??"").length>900;return s.jsxs("div",{children:[s.jsxs("div",{className:"ui-stats","data-inline":"true",children:[s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"Tool"}),s.jsx("div",{className:"ui-stat-v mono",children:r.tool})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"State"}),s.jsx("div",{className:"ui-stat-v","data-tone":v2(r.state),children:r.state})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:j?"Expires":"Decided"}),s.jsx("div",{className:"ui-stat-v","data-size":"sm",children:Pe(j?r.expiresAt:r.decidedAt,t)})]})]}),s.jsx(ie,{message:l}),j?p:null,j?s.jsxs("div",{className:"wb-row-wrap wb-block",children:[s.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>m("approve"),children:u==="approve"?"Approving…":w?"Allow once":"Approve"}),w?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>m("approve","conversation"),children:"Auto: this conversation"}),s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>m("approve","always"),children:"Always: this agent"})]}):null,s.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>m("reject"),children:u==="reject"?"Rejecting…":"Reject"}),s.jsx("span",{className:"wb-hint",children:w?"Auto-mode and Always also approve future calls to this tool within that scope. Host permissions can be revoked under Host execution.":"This runs the action exactly as printed above."})]}):s.jsxs("p",{className:"muted",children:[r.state," ",r.decidedBy?`by ${r.decidedBy}`:""," ",r.decidedVia?`via ${r.decidedVia}`:""]}),s.jsx("h4",{className:"ui-stat-k wb-label",children:"Preview"}),s.jsxs("div",{className:"wb-doc wb-block","data-clamp":x&&!a?"true":void 0,children:[r.preview||"(this tool wrote no preview)",x&&!a?s.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]}),s.jsxs("details",{className:"ui-details wb-block",children:[s.jsx("summary",{children:"The envelope, field by field"}),s.jsx("dl",{className:"ui-kv",children:b.map(y=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:y.label}),s.jsx("dd",{className:y.mono?"mono":void 0,children:y.value})]},y.label))})]})]})}function x2(e){const t=[],n=e.envelope;if(n!==null&&typeof n=="object"&&!Array.isArray(n))for(const[i,l]of Object.entries(n))t.push({label:Lt(i),value:Da(l)});else n!=null&&t.push({label:"Envelope",value:Da(n)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,l]of Object.entries(r)){const o=`Argument · ${Lt(i)}`;t.some(a=>a.label===o)||t.push({label:o,value:Da(l)})}return t.push({label:"Action id",value:e.id,mono:!0},{label:"Tool version",value:e.toolVersion,mono:!0},{label:"Agent",value:e.agentId,mono:!0},{label:"Args hash",value:e.argsHash,mono:!0},{label:"Policy version",value:String(e.policyVersion)}),e.conversationId&&t.push({label:"Conversation",value:e.conversationId,mono:!0}),e.jobId&&t.push({label:"Job",value:e.jobId,mono:!0}),t}function Da(e){return e==null?"—":Array.isArray(e)?e.map(t=>Da(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):mt(e,"text",null)}function v2(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const j2=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function y2(e){return j2.has(e.toLowerCase())}function Dr(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function uu(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function En(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vm(e,t){const n=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return n.startsWith("image/")?"image":n==="application/pdf"?"pdf":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":n==="text/csv"||n==="text/tab-separated-values"||n.includes("spreadsheet")||n.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":n.includes("zip")||n.includes("tar")||n.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":n==="application/json"||n.includes("javascript")||n.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":n.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const Cr={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function La(e){return`artifact:${e}`}function w2(e){const t=vm(e.mime,e.filename);return{id:La(e.artifactId),tool:Cr[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function b2({props:e}){const t=T0(e.artifactId),[n,r]=d.useState(null),[i,l]=d.useState(null),[o,a]=d.useState(!1);if(d.useEffect(()=>{if(t===null)return;let h=!0;return r(null),l(null),a(!1),A.libraryEntry(t).then(f=>{h&&r({filename:f.entry.filename,sizeBytes:f.entry.sizeBytes})}).catch(()=>{}),()=>{h=!1}},[t]),t===null)return s.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(n==null?void 0:n.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,n!=null&&n.sizeBytes?En(n.sizeBytes):null].filter(h=>h!==null);return s.jsxs("figure",{className:"wb-image",children:[s.jsx("div",{className:"wb-image-frame",children:o?s.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):s.jsx("a",{href:Dr(t),className:"wb-image-link",title:"Open at full size",children:s.jsx("img",{src:Dr(t),alt:e.caption??c,onLoad:h=>{const f=h.currentTarget;f.naturalWidth>0&&l({width:f.naturalWidth,height:f.naturalHeight})},onError:()=>a(!0)})})}),s.jsxs("figcaption",{className:"wb-image-caption",children:[s.jsxs(J,{children:[s.jsx("span",{className:"wb-image-name",children:c}),u.length>0?s.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(Fn,{size:"sm",href:uu(t),download:(n==null?void 0:n.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?s.jsx(Nt,{summary:e.captionLabel,className:"wb-image-note",children:s.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?s.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function k2({props:e}){return e.pairs.length===0?s.jsx("p",{className:"wb-empty",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:mt(t.value,t.unit,t.currency)})]},t.label))})}const S2=8;function B0({text:e,label:t="Output",className:n}){const r=d.useRef(null),i=d.useRef(!0);return d.useLayoutEffect(()=>{const l=r.current;l&&i.current&&(l.scrollTop=l.scrollHeight)},[e]),s.jsx("pre",{ref:r,className:n?`wb-terminal-body ${n}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:l=>{const o=l.currentTarget;i.current=o.scrollHeight-o.scrollTop-o.clientHeight<=S2},children:e})}function N2(e){if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?1:0)} s`;const n=Math.floor(t/60);return`${n} min ${Math.round(t-n*60)} s`}function C2({text:e}){const[t,n]=d.useState("");return s.jsxs(s.Fragment,{children:[t?s.jsx("span",{role:"status",className:"wb-hint",children:t}):null,s.jsx(P,{size:"sm",onClick:()=>{var r;if(n(""),!((r=navigator.clipboard)!=null&&r.writeText)){n("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>n("Copied"),()=>n("Copy failed; select the text to copy."))},children:"Copy"})]})}function E2({props:e}){const t=e.output??"";return s.jsxs("div",{className:"wb-terminal",children:[s.jsxs(J,{className:"wb-terminal-head",children:[e.command!==null?s.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?s.jsxs(fe,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?s.jsx("span",{className:"wb-terminal-fact",children:N2(e.elapsedMs)}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?s.jsx(C2,{text:t}):null]}),e.omittedBytes!==null?s.jsxs("p",{className:"wb-terminal-note",children:["First ",En(e.omittedBytes)," not shown."]}):null,t!==""?s.jsx(B0,{text:t}):s.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(n=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:n.label}),s.jsx("dd",{children:mt(n.value,n.unit,null)})]},n.label))}):null]})}function A2(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function pv(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function R2(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((n,r)=>n-r)}function T2({props:e}){var S;const[t,n]=d.useState(null),[r,i]=d.useState(null),[l,o]=d.useState(null),[a,c]=d.useState(!1),u=((S=e.target)==null?void 0:S.plugin)??null,h=R2(e),[f,p]=d.useState(null),m=f!==null&&h.includes(f)?f:e.port,j=e.target?m!==null&&m!==e.port?`${e.target.name}.${m}`:e.target.name:null,w=e.changes??0,b=d.useRef(w),[x,v]=d.useState(0);d.useEffect(()=>{w<=b.current||(b.current=w,e.reloadsItself||v(k=>k+1))},[w,e.reloadsItself]),d.useEffect(()=>{if(u===null||j===null)return;let k=!0;return n(null),i(null),o(null),v(0),A.previewLink(u,j).then(N=>{k&&(n(N.url),i(pv(N.url)))}).catch(N=>{k&&o(N instanceof Error?N.message:"That preview could not be opened.")}),()=>{k=!1}},[u,j]);const y=()=>{u===null||j===null||A.previewLink(u,j).then(k=>i(k.url)).catch(()=>{})};if(e.target===null)return s.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",s.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const g=!(e.output===null||e.output==="");return s.jsxs("div",{className:"wb-preview","data-output":a||void 0,children:[s.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,h.length>1?s.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:m??"",onChange:k=>p(Number(k.target.value)),children:h.map(k=>s.jsxs("option",{value:k,children:[":",k]},k))}):null,g?s.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":a,onClick:()=>c(k=>!k),children:a?"Hide output":"Output"}):null,r?s.jsx("a",{className:"wb-preview-open",href:r,target:"_blank",rel:"noreferrer noopener",onPointerEnter:y,onFocus:y,title:"Through buddi: works from anywhere the dashboard does, including the tailnet.",children:"Open in a tab"}):null,m!==null&&A2()?s.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${m}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",m]}):null]}),s.jsxs("div",{className:"wb-preview-body",children:[t?s.jsx("iframe",{className:"wb-preview-frame",src:x===0?t:pv(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},x):s.jsx("p",{className:"wb-empty wb-preview-frame",children:l??"Opening the preview…"}),g&&a?s.jsx(B0,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const P2=50,I2=9,M2=24,$2=.6,_2=48,O2=/(amount|total|balance|price|cost|paid|pay|payment|net|spend|spent|due|limit|owed|fee|income|charge|burn|minimum|principal|interest|worth|cash|debt|deposit|credit|debit|value|revenue|budget|floor|avg|mean|median)/i,D2=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,L2=/^id$|(^|[a-z0-9])Id$|_id$/;function gi(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function on(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function z0(...e){for(const t of e)if(on(t))for(const n of["currency","currencyCode"]){const r=t[n];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function W0(e,t,n){const r=t.filter(i=>i!=null&&i!=="");return r.length===0?"text":r.every(i=>typeof i=="boolean")?"boolean":r.every(i=>typeof i=="number"&&Number.isFinite(i))?n!==null&&O2.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&D2.test(i))?"date":"text"}function F2(e,t){if(!L2.test(e))return!1;const n=t.filter(r=>!nl(r));return n.length<2?!1:new Set(n.map(r=>String(r))).size===n.length}function nl(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:on(e)?Object.keys(e).length===0:!1}function mv(e,t){const n=e.filter(on);if(n.length===0||n.length/e.length<.8)return null;const r=n.slice(0,P2),i=new Map,l=[];for(const h of r)for(const f of Object.keys(h))i.has(f)||l.push(f),i.set(f,(i.get(f)??0)+1);if(i.size===0||i.size>M2||[...i.values()].reduce((h,f)=>h+f,0)/(i.size*r.length)<$2)return null;const a=[...i.keys()].sort((h,f)=>{const p=(i.get(f)??0)-(i.get(h)??0);return p!==0?p:l.indexOf(h)-l.indexOf(f)}),c=[],u=[];for(const h of a){const f=r.map(w=>w[h]),p=f.filter(w=>!nl(w));if(p.length===0||F2(h,f))continue;const m=z0(r[0],t),j=W0(h,f,m);if(r.length>=4&&p.length===f.length&&f.every(w=>gi(w)&&w===f[0])){u.push({label:Lt(h),value:f[0],type:j,currency:m});continue}if(c.push({key:h,label:Lt(h),type:j,currency:j==="currency"?m:null}),c.length===I2)break}return c.length===0?null:{columns:c,rows:n,constants:u}}function U2(e,t,n){const r=z0(n);return{label:Lt(e),value:t,type:W0(e,[t],r),currency:r}}function V0(e){return typeof e=="string"&&e.length>_2}function B2(e){return e==null?"This tool returned nothing.":typeof e=="string"&&e.trim()===""?"This tool returned an empty string.":Array.isArray(e)&&e.length===0?"This tool returned no items.":on(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function lh(e){if(typeof e=="string"&&e.trim()!=="")return e;if(on(e))for(const t of["message","error","reason","detail","description"]){const n=e[t];if(typeof n=="string"&&n.trim()!=="")return n;if(on(n)){const r=lh(n);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function jm(e,t={}){if(t.failed){let f=e;if(typeof e=="string")try{const p=JSON.parse(e.replace(/^tool-error:\s*/,""));on(p)&&(f=p)}catch{}return{kind:"error",summary:lh(f),detail:gv(f)}}if(on(e)){const f=e.error,p=e.ok;if(typeof f=="string"&&f.trim()!==""||p===!1)return{kind:"error",summary:lh(e),detail:gv(e)}}const n=B2(e);if(n)return{kind:"empty",note:n,stats:[]};if(Array.isArray(e)){const f=mv(e,e);return f?{kind:"table",label:null,columns:f.columns,rows:f.rows,total:f.rows.length,stats:f.constants,notes:[],asides:[]}:e.every(gi)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!on(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,l=null;for(const[f,p]of r){if(!Array.isArray(p))continue;const m=mv(p,e);if(m){(!i||m.rows.length>i.candidate.rows.length)&&(i={key:f,candidate:m});continue}p.length>0&&p.every(gi)&&(!l||p.length>l.items.length)&&(l={key:f,items:p})}const o=(i==null?void 0:i.key)??(l==null?void 0:l.key)??null,a=[],c=[],u=[];for(const[f,p]of r)if(f!==o){if(V0(p)){c.push(p);continue}if(gi(p)){if(p==="")continue;a.push(U2(f,p,e));continue}p!==void 0&&u.push({label:Lt(f),value:p})}if(i)return{kind:"table",label:Lt(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...a,...i.candidate.constants],notes:c,asides:u};if(l)return{kind:"list",label:Lt(l.key),items:l.items,total:l.items.length,stats:a,notes:c,asides:u};const h=r.filter(([,f])=>Array.isArray(f)&&f.length===0);return h.length>0&&h.length===r.filter(([,f])=>Array.isArray(f)).length?{kind:"empty",note:`No ${h.map(([p])=>Lt(p).toLowerCase()).join(", ")} to show.`,stats:a}:r.every(([,f])=>gi(f)||on(f)||Array.isArray(f))?{kind:"record",pairs:a,notes:c,asides:u}:{kind:"tree",value:e}}function gv(e){if(!on(e))return null;const t=Object.entries(e).filter(([n])=>n!=="message"&&n!=="error");return t.length===0?null:Object.fromEntries(t)}const bc=25,z2=3,oh=8,H0=6;function ah(e,t=0){if(t>H0||nl(e)||V0(e))return 0;if(gi(e))return 1;if(Array.isArray(e)){let n=0;for(const r of e)if(n+=ah(r,t+1),n>=oh)return n;return n}if(on(e)){let n=0;for(const r of Object.values(e))if(n+=ah(r,t+1),n>=oh)return n;return n}return 0}function ch(e,t=0){if(t>H0)return!1;if(Array.isArray(e))return e.some(l=>ch(l,t+1));if(!on(e))return!1;const n=e.artifactId??e.artifact_id;if(typeof n=="string"&&n.trim()!=="")return!0;const r=e.mime??e.mimeType??e.contentType,i=e.url??e.src??e.downloadUrl??e.path;return typeof r=="string"&&r.includes("/")&&typeof i=="string"&&i.trim()!==""?!0:Object.values(e).some(l=>ch(l,t+1))}function W2(e){if(ch(e))return!0;const t=jm(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=z2;case"record":case"tree":return ah(e)>=oh;default:return!1}}function dd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function ym(e){const t=dd(e);if(!t)return null;const n=dd(t.output)??t;if(typeof n.state!="string"||typeof n.stdout!="string"||typeof n.stderr!="string"||!(n.exitCode===null||typeof n.exitCode=="number"&&Number.isFinite(n.exitCode)))return null;const r=n===t?null:dd(t.input),i=(r==null?void 0:r.command)??n.command;return{command:typeof i=="string"?i:null,input:r,result:n}}function V2({text:e,label:t}){const[n,r]=d.useState("");return s.jsxs("span",{className:"wb-command-copy",children:[s.jsx("button",{className:"ui-btn",onClick:()=>{var i;if(r(""),!((i=navigator.clipboard)!=null&&i.writeText)){r("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>r("Copied"),()=>r("Copy failed; select the text to copy."))},children:t}),n&&s.jsx("span",{role:"status",className:"wb-hint",children:n})]})}function fd({title:e,text:t,error:n=!1}){return s.jsxs("section",{className:"wb-command-stream","data-error":n||void 0,children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("h4",{children:e}),s.jsx(V2,{text:t,label:`Copy ${e.toLowerCase()}`})]}),s.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function H2({value:e,children:t}){const{result:n,command:r,input:i}=e,l=n.state==="completed"&&n.exitCode!==null&&n.exitCode!==0,o=typeof n.signal=="string"&&n.signal?n.signal:null,a=n.state==="completed"&&n.exitCode===0,c=Object.fromEntries(Object.entries(n).filter(([h,f])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(h)&&f!==null&&f!==void 0&&f!=="")),u=Array.isArray(n.outputErrors)?n.outputErrors.filter(h=>typeof h=="string"):[];return s.jsxs("div",{className:"wb-command-result",children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("span",{className:"ui-pill","data-tone":a?"good":"critical",children:l?"Failed":n.state==="completed"&&o?"Terminated":n.state}),n.exitCode!==null&&s.jsxs("span",{className:"mono",children:["Exit code ",n.exitCode]}),o&&s.jsxs("span",{className:"mono",children:["Signal ",o]}),s.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&s.jsx(fd,{title:"Command",text:r}),n.state==="output-limit"&&s.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),n.state==="timed-out"&&s.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),n.state==="cancelled"&&s.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),n.stdout?s.jsx(fd,{title:"Output",text:n.stdout}):s.jsx("p",{className:"wb-note",children:"No standard output."}),n.stderr?s.jsx(fd,{title:"Standard error",text:n.stderr,error:!0}):null,u.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"File export errors"}),u.map((h,f)=>s.jsx("p",{className:"wb-fail",children:h},f))]}),t,(Object.keys(c).length>0||i!==null)&&s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Execution details"}),s.jsx("pre",{children:Xt({...c,...i?{input:i}:{}})})]})]})}const la=2,xv=64;function K2({props:e}){const[t,n]=d.useState(!1),r=ym(e.value),i=G2((r==null?void 0:r.result)??e.value),l=d.useMemo(()=>jm(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return s.jsxs("div",{children:[!r&&s.jsx(vv,{files:i}),t?s.jsx("pre",{className:"ui-code",children:Xt(e.value)}):r?s.jsx(H2,{value:r,children:i.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"Generated files"}),s.jsx(vv,{files:i})]})}):i.length?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Tool details"}),s.jsx(jv,{shape:l})]}):s.jsx(jv,{shape:l}),s.jsx("div",{className:"wb-row-end wb-section",children:s.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>n(o=>!o),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function G2(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(n=>n&&typeof n.id=="string"&&/^[0-9a-f-]{36}$/i.test(n.id)&&typeof n.filename=="string"):[]}function vv({files:e}){return e.length?s.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var n;return s.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?s.jsx(Y2,{file:t}):null,s.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(n=t.mime)!=null&&n.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function Y2({file:e}){const[t,n]=d.useState(!1);return t?s.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):s.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>n(!0)})}function jv({shape:e}){switch(e.kind){case"error":return s.jsxs("div",{children:[s.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"What came back with it"}),s.jsx("div",{className:"wb-tree",children:io(e.detail,1)})]})]});case"empty":return s.jsxs("div",{children:[s.jsx(hd,{stats:e.stats}),s.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=eM(e.columns,e.rows);return s.jsxs("div",{children:[s.jsx(hd,{stats:e.stats}),s.jsx(pd,{notes:e.notes}),t?s.jsx(tM,{label:e.label,plan:t,rows:e.rows,total:e.total}):s.jsx(Q2,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),s.jsx(md,{asides:e.asides})]})}case"list":return s.jsxs("div",{children:[s.jsx(hd,{stats:e.stats}),s.jsx(pd,{notes:e.notes}),e.label?s.jsx("h4",{className:"wb-sub",children:e.label}):null,s.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,n)=>s.jsx("li",{children:mt(t,"text",null)},n))}),e.total>100?s.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,s.jsx(md,{asides:e.asides})]});case"record":return s.jsxs("div",{children:[s.jsx(pd,{notes:e.notes}),s.jsx(q2,{pairs:e.pairs}),s.jsx(md,{asides:e.asides})]});default:return s.jsx("div",{className:"wb-tree",children:io(e.value,0)})}}function hd({stats:e}){return e.length===0?null:s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:t.label}),s.jsx("div",{className:"ui-stat-v",children:wm(t.value,t.type,t.currency)})]},t.label))})}const yv=200;function pd({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=yv),n=e.filter(r=>r.length>yv);return s.jsxs(s.Fragment,{children:[t.map(r=>s.jsx("p",{className:"wb-note",children:r},r)),n.length>0?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:n.length===1?"A note that came with this result":`${n.length} notes that came with this result`}),n.map(r=>s.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function q2({pairs:e}){return e.length===0?s.jsx("p",{className:"wb-note",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:wm(t.value,t.type,t.currency)})]},t.label))})}function md({asides:e}){return e.length===0?null:s.jsx("div",{className:"wb-section",children:e.map(t=>s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:t.label}),s.jsx("div",{className:"wb-tree",children:io(t.value,1)})]},t.label))})}function Q2({label:e,columns:t,rows:n,total:r}){const[i,l]=d.useState(!1),o=r<=bc+5?r:bc,a=i?n:n.slice(0,o);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:t.map(c=>s.jsx("th",{className:G0(c.type)?"num":void 0,children:c.label},c.key))})}),s.jsx("tbody",{children:a.map((c,u)=>s.jsx("tr",{children:t.map(h=>s.jsx(nM,{value:c[h.key],column:h},h.key))},u))})]})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>l(!0),children:["Show all ",r]})]}):null]})}const J2=/^(title|name|headline|subject|label|heading)$/i,X2=/^(url|link|href|uri|permalink)$/i;function kc(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function Z2(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function K0(e,t=48){try{const n=new URL(e),r=n.pathname==="/"?"":n.pathname,i=`${n.hostname.replace(/^www\./,"")}${r}${n.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function oa(e,t){const n=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return n.length===0?0:n.reduce((r,i)=>r+i.length,0)/n.length}function eM(e,t){if(t.length===0)return null;const n=e.filter(h=>h.type==="text"),r=n.find(h=>X2.test(h.key)&&t.some(f=>kc(f[h.key])))??n.find(h=>{const f=t.map(p=>p[h.key]).filter(p=>!nl(p));return f.length>0&&f.filter(kc).length/f.length>=.6});if(!r)return null;const i=n.filter(h=>h.key!==r.key),l=i.find(h=>J2.test(h.key))??i.find(h=>oa(t,h.key)>0);if(!l)return null;const a=[...i.filter(h=>h.key!==l.key)].sort((h,f)=>oa(t,f.key)-oa(t,h.key)),c=a[0]&&oa(t,a[0].key)>40?a[0]:null,u=e.filter(h=>h.key!==r.key&&h.key!==l.key&&h.key!==(c==null?void 0:c.key)).map(h=>h.key);return{url:r.key,title:l.key,description:(c==null?void 0:c.key)??null,meta:u}}function tM({label:e,plan:t,rows:n,total:r}){const[i,l]=d.useState(!1),o=r<=bc+5?r:bc,a=i?n:n.slice(0,o);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("ol",{className:"wb-records",children:a.map((c,u)=>{const h=c[t.url],f=kc(h)?h.trim():null,p=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:f?K0(f):"Untitled",m=t.description&&typeof c[t.description]=="string"?c[t.description]:null,j=f?Z2(f):null,w=t.meta.map(b=>c[b]).filter(b=>!nl(b)&&typeof b!="object").map(b=>String(b)).filter(b=>j===null||b.replace(/^www\./,"")!==j);return s.jsxs("li",{className:"wb-record",children:[f?s.jsx("a",{className:"wb-record-title",href:f,target:"_blank",rel:"noopener noreferrer",children:p}):s.jsx("span",{className:"wb-record-title",children:p}),s.jsxs("div",{className:"wb-record-meta",children:[j?s.jsx("span",{className:"wb-record-host",title:f??void 0,children:j}):null,w.map((b,x)=>s.jsx("span",{children:b.length>60?`${b.slice(0,59)}…`:b},x))]}),m?s.jsx("p",{className:"wb-record-desc",children:m.length>280?`${m.slice(0,279)}…`:m}):null]},u)})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>l(!0),children:["Show all ",r]})]}):null]})}function nM({value:e,column:t}){if(nl(e))return s.jsx("td",{className:"wb-cell-soft",children:"—"});if(kc(e)){const i=e.trim();return s.jsx("td",{className:"wb-cell-link",children:s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:K0(i)})})}if(e!==null&&typeof e=="object"){const i=Array.isArray(e)?`${e.length} item${e.length===1?"":"s"}`:`${Object.keys(e).length} fields`;return s.jsx("td",{className:"wb-cell-soft",title:Xt(e),children:i})}const n=wm(e,t.type,t.currency),r=n.length>xv?`${n.slice(0,xv-1)}…`:n;return s.jsx("td",{className:G0(t.type)?"num":"wb-cell-text",...r===n?{}:{title:n},children:r})}function G0(e){return e==="number"||e==="currency"}function wm(e,t,n){return e==null?"—":t==="boolean"?e?"yes":"no":mt(e,t==="text"?"text":t,n)}function io(e,t){if(e===null)return s.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return s.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return s.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return s.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return s.jsx("span",{children:e===""?s.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return s.jsx("span",{className:"wb-tree-null",children:"none"});const i=s.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((l,o)=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[o,". "]}),io(l,t+1)]},o)),e.length>50?s.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=la?s.jsx(wv,{summary:`${e.length} items`,open:t===la,children:i}):i}const n=Object.entries(e);if(n.length===0)return s.jsx("span",{className:"wb-tree-null",children:"empty"});const r=s.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:n.map(([i,l])=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[Lt(i),": "]}),io(l,t+1)]},i))});return t>=la?s.jsx(wv,{summary:`${n.length} fields`,open:t===la,children:r}):r}function wv({summary:e,open:t,children:n}){return s.jsxs("details",{open:t,children:[s.jsx("summary",{className:"wb-tree-key",children:e}),n]})}function sM({props:e}){const t=e.groups.every(n=>n.rows.length===0);return s.jsxs("div",{children:[e.summary.length>0?s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(n=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:n.label}),s.jsx("div",{className:"ui-stat-v","data-tone":n.tone,children:mt(n.value,n.unit,n.currency)})]},n.label))}):null,t?s.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((n,r)=>s.jsxs("div",{className:r>0?"wb-section":void 0,children:[n.label?s.jsx("h4",{className:"ui-stat-k wb-label",children:n.label}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.columns.map(i=>s.jsx("th",{className:Y0(i.type)?"num":void 0,children:i.label},i.key))})}),s.jsx("tbody",{children:n.rows.map((i,l)=>s.jsx("tr",{children:i.map((o,a)=>{var c;return s.jsx(rM,{cell:o},((c=e.columns[a])==null?void 0:c.key)??a)})},l))})]})})]},n.label??r))]})}function rM({cell:e}){const t=mt(e.value,e.type,e.currency);return e.bar?s.jsx("td",{className:"num",children:s.jsxs("div",{className:"wb-row wb-row-end",children:[s.jsx("div",{className:"ui-meter",role:"meter","aria-valuenow":Math.round(e.bar.fraction*100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":t,children:s.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),s.jsx("span",{className:"tnum",children:t})]})}):s.jsx("td",{className:Y0(e.type)?"num":void 0,children:t})}function Y0(e){return e==="number"||e==="currency"||e==="percent"}const ti=760,gd=400,Ze={top:18,right:18,bottom:36,left:66},iM=5;function lM({props:e}){const{points:t,referenceLines:n,unit:r,currency:i}=e;if(t.length===0)return s.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const l=[...t.map(g=>g.y),...n.map(g=>g.value)],o=Math.min(...l),a=Math.max(...l),c=a-o||Math.abs(a)||1,u=o-c*.08,h=a+c*.08,f=ti-Ze.left-Ze.right,p=gd-Ze.top-Ze.bottom,m=g=>Ze.left+(t.length===1?f/2:g/(t.length-1)*f),j=g=>Ze.top+p-(g-u)/(h-u)*p,w=FP(o,a,4),b=aM(t.map(g=>g.y),e.mark),x=e.shadeBelow===null?[]:cM(t.map(g=>g.y),e.shadeBelow),v=t.map((g,S)=>`${S===0?"M":"L"}${m(S)},${j(g.y)}`).join(" "),y=g=>mt(g,r,i);return s.jsxs("div",{children:[e.label?s.jsx("p",{className:"ui-panel-sub",children:e.label}):null,s.jsxs("div",{className:"wb-chart-layout",children:[s.jsx("div",{className:"wb-chart-plot",children:s.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${ti} ${gd}`,role:"img","aria-label":oM(e,y),preserveAspectRatio:"xMidYMid meet",children:[x.map(g=>s.jsx("rect",{className:"wb-chart-breach",x:m(g.from),width:Math.max(2,m(g.to)-m(g.from)),y:Ze.top,height:p},`band-${g.from}`)),w.map(g=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-grid",x1:Ze.left,x2:ti-Ze.right,y1:j(g),y2:j(g)}),s.jsx("text",{x:Ze.left-8,y:j(g)+4,textAnchor:"end",children:y(g)})]},`tick-${g}`)),n.map(g=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-floor",x1:Ze.left,x2:ti-Ze.right,y1:j(g.value),y2:j(g.value)}),s.jsxs("text",{x:ti-Ze.right,y:j(g.value)-6,textAnchor:"end",children:[g.label," ",y(g.value)]})]},`rule-${g.label}`)),s.jsx("line",{className:"wb-chart-axis",x1:Ze.left,x2:Ze.left,y1:Ze.top,y2:Ze.top+p}),s.jsx("line",{className:"wb-chart-axis",x1:Ze.left,x2:ti-Ze.right,y1:Ze.top+p,y2:Ze.top+p}),s.jsx("path",{className:"wb-chart-series",d:v}),b!==null?s.jsxs("g",{children:[s.jsx("circle",{className:"wb-chart-min",cx:m(b),cy:j(t[b].y),r:4.5}),s.jsx("text",{x:m(b),y:j(t[b].y)+20,textAnchor:"middle",children:y(t[b].y)})]}):null,uM(t.length).map(g=>s.jsx("text",{x:m(g),y:gd-10,textAnchor:"middle",children:Xf(t[g].x)},`x-${g}`))]})}),e.events.length>0?s.jsxs("aside",{className:"wb-chart-events",children:[s.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),s.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((g,S)=>s.jsxs("li",{className:"wb-chart-event",children:[s.jsxs("span",{children:[s.jsx("span",{className:"wb-chart-event-day",children:Xf(g.at)}),g.label]}),g.amount===null?null:s.jsx("span",{className:g.amount<0?"tnum critical":"tnum good",children:mt(g.amount,r,i)})]},`${g.at}-${g.label}-${S}`))})]}):null]})]})}function oM(e,t){const n=e.points.map(o=>o.y),r=e.points[0],i=e.points[e.points.length-1],l=e.referenceLines.map(o=>`${o.label} at ${t(o.value)}`).join(", ");return[`${e.points.length} points from ${r==null?void 0:r.x} to ${i==null?void 0:i.x}`,`low ${t(Math.min(...n))}, high ${t(Math.max(...n))}`,l].filter(Boolean).join("; ")}function aM(e,t){if(!t||e.length===0)return null;let n=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[n]:e[r]>e[n])&&(n=r);return n}function cM(e,t){const n=[];let r=null;return e.forEach((i,l)=>{i<t?r===null&&(r=l):r!==null&&(n.push({from:r,to:l}),r=null)}),r!==null&&n.push({from:r,to:e.length-1}),n}function uM(e,t=iM){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const n=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*n));return[...r].sort((i,l)=>i-l)}const Tn=e=>e,uh={timeseries:Tn(lM),table:Tn(sM),bars:Tn(UP),keyvalue:Tn(k2),document:Tn(_I),diff:Tn(KP),terminal:Tn(E2),image:Tn(b2),preview:Tn(T2),envelope:Tn(g2),structured:Tn(K2)},dM="structured";function fM(e){return(Sc(e)?uh[e]:void 0)??uh[dM]}function Sc(e){return Object.prototype.hasOwnProperty.call(uh,e)}function hM({renderer:e,props:t,timezone:n,onDecided:r}){const i=fM(e),o=Sc(e)?t:{value:t};return s.jsx(i,{props:o,timezone:n,onDecided:r})}function pM({profile:e,onChange:t}){return s.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[s.jsx("p",{className:"wb-prof-lead",children:e.description}),s.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?s.jsx(xd,{children:"Opens by default"}):null,s.jsx(xd,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(n=>s.jsx(xd,{title:`A surface command that asks for "${n}" lands on this agent.`,children:Lt(n)},n))]}),e.available?null:s.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[s.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),s.jsx(xl,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:s.jsxs("ul",{className:"wb-prof-list",children:[s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),s.jsx("span",{className:"wb-prof-row-desc",children:"When it knows the likely answers, it can show one-tap choices in the dashboard and Telegram. You can still write a different answer when the question allows it."})]}),s.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),s.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),s.jsx("span",{className:"wb-prof-row-desc",children:"A request to send, spend, publish or otherwise affect the world appears in the conversation with the exact action. Answering a question never approves it."})]}),s.jsxs("span",{className:"wb-prof-gate",children:[s.jsx(q0,{}),"Exact action"]})]})]})}),s.jsx(xl,{title:"What it can do",note:mM(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?s.jsx("p",{className:"wb-prof-empty",children:"No tools at all. It answers from the conversation and from what it remembers, and it can change nothing."}):[...e.tools].sort((n,r)=>+(r.gated>0)-+(n.gated>0)).map(n=>s.jsx(gM,{family:n},n.family))}),s.jsx(xl,{title:"What it runs on",children:s.jsxs("dl",{className:"wb-prof-kv",children:[s.jsx(vl,{label:"Provider",children:e.engine.provider}),s.jsx(vl,{label:"Model",children:s.jsx("span",{className:"mono",children:e.engine.model})}),s.jsxs(vl,{label:"Credential",children:[e.engine.credentialKind," from"," ",s.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),s.jsxs(vl,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),s.jsx(vl,{label:"Language",children:wM(e.engine.language)})]})}),e.skills.length>0?s.jsx(xl,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:s.jsx("ul",{className:"wb-prof-list",children:e.skills.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:n.name}),n.description?s.jsx("span",{className:"wb-prof-row-desc",children:n.description}):null]}),s.jsxs("span",{className:"wb-prof-row-side",title:n.file,children:[n.scope==="private"?"its own":"shared"," · ",n.provenance]})]},n.file))})}):null,e.delegates.length>0?s.jsx(xl,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:s.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsxs("span",{className:"wb-prof-row-name mono",children:["@",n.handle]}),s.jsx("span",{className:"wb-prof-row-desc",children:n.description})]}),s.jsx("span",{className:"wb-prof-row-side",children:n.available?n.name:`${n.name} · cannot run`})]},n.id))})}):null,s.jsxs("footer",{className:"wb-prof-foot",children:[s.jsx("p",{className:"wb-prof-note",children:e.note}),s.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?s.jsxs("button",{className:"ui-btn","data-testid":"agent-profile-change",title:e.changeVia.prompt,onClick:()=>t({agentId:e.changeVia.agentId,prompt:e.changeVia.prompt}),children:["Ask @",e.changeVia.handle," to change this"]}):null]})]})}function mM(e){if(e.toolCount===0)return"Nothing. This agent holds no tools.";const t=`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`;if(e.gatedCount===0)return`${t}, every one of them running without asking you. None of them can send, spend or write to the world.`;const n=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${n}.`}function gM({family:e}){const t=[...e.tools].sort((n,r)=>Number(r.gated)-Number(n.gated));return s.jsxs("section",{className:"wb-prof-family",children:[s.jsxs("h4",{className:"wb-prof-family-head",children:[s.jsx("span",{className:"wb-prof-family-name",children:Lt(e.family)}),s.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),s.jsx("ul",{className:"wb-prof-list",children:t.map(n=>s.jsx(xM,{tool:n},n.name))})]})}function xM({tool:e}){return s.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:yM(e.name)}),s.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?s.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[s.jsx(q0,{}),"Needs your approval"]}):s.jsx("span",{className:"wb-prof-auto",title:jM(e.tier),children:vM(e.tier)})]})}function vM(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function jM(e){return e==="auto"?"Called during a run without asking you. It reads, or records something you can see.":`Tier "${e}" does not execute in this build; a call to it is refused.`}function yM(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function wM(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function xl({title:e,note:t,tone:n,children:r}){return s.jsxs("section",{className:"wb-prof-section",children:[s.jsx("h3",{className:"wb-prof-title",children:e}),t?s.jsx("p",{className:"wb-prof-note-lead","data-tone":n,children:t}):null,r]})}function vl({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"wb-prof-k",children:e}),s.jsx("dd",{className:"wb-prof-v",children:t})]})}function xd({children:e,title:t}){return s.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function q0(){return s.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),s.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const vd=1e5,jd=200,yd=30;function Q0({artifactId:e,filename:t,mime:n,family:r,available:i=!0}){const[l,o]=d.useState(!1);return i?r==="image"&&!l?s.jsx("figure",{className:"file-preview file-preview-image",children:s.jsx("img",{src:Dr(e),alt:t??"Image",onError:()=>o(!0)})}):r==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:Dr(e),type:"application/pdf","aria-label":t??"PDF",children:s.jsx(G,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?s.jsx(bM,{artifactId:e,filename:t,mime:n,family:r}):s.jsx(G,{children:"Preview not supported for this kind of file. Download it to open it."}):s.jsx(G,{children:"The file is no longer available; its record is kept."})}function bM({artifactId:e,filename:t,mime:n,family:r}){const[i,l]=d.useState("loading");if(d.useEffect(()=>{let a=!1;return l("loading"),fetch(Dr(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();a||l({text:u.slice(0,vd),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>vd})}).catch(()=>{a||l("failed")}),()=>{a=!0}},[e]),i==="loading")return s.jsx("div",{className:"file-preview",children:s.jsx(oe,{children:"Loading preview…"})});if(i==="failed")return s.jsx(G,{children:"The preview could not be loaded. Download the file to open it."});const o=r==="table"&&(/csv|tab-separated/.test(n)||/\.(csv|tsv)$/i.test(t??""));return s.jsxs("div",{className:"file-preview",children:[o?s.jsx(SM,{text:i.text,delimiter:/tab|\.tsv$/i.test(n+(t??""))?" ":","}):s.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?s.jsxs("p",{className:"muted",children:["Showing the first ",vd.toLocaleString()," characters. The download has the whole file."]}):null]})}function kM(e,t,n,r){const i=[];let l=[],o="",a=!1,c=!1,u=!1;const h=()=>{l.length<r?l.push(o):c=!0,o=""},f=()=>{h(),i.push(l),l=[]};let p=0;for(;p<e.length;p+=1){if(i.length>=n){u=e.slice(p).trim()!=="";break}const m=e[p];if(a){m==='"'?e[p+1]==='"'?(o+='"',p+=1):a=!1:o+=m;continue}if(m==='"'){a=!0;continue}if(m===t){h();continue}if(m!=="\r"){if(m===`
94
- `){f();continue}o+=m}}return i.length<n&&(o!==""||l.length>0)&&f(),{rows:i,truncatedRows:u,truncatedCols:c}}function SM({text:e,delimiter:t}){const n=d.useMemo(()=>kM(e,t,jd+1,yd),[e,t]),[r,...i]=n.rows;if(!r)return s.jsx("p",{className:"muted",children:"The file is empty."});const l=Math.min(yd,n.rows.reduce((a,c)=>Math.max(a,c.length),0)),o=Array.from({length:l},(a,c)=>c);return s.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:o.map(a=>s.jsx("th",{children:r[a]??""},a))})}),s.jsx("tbody",{children:i.slice(0,jd).map((a,c)=>s.jsx("tr",{children:o.map(u=>s.jsx("td",{children:a[u]??""},u))},c))})]}),n.truncatedRows||n.truncatedCols?s.jsxs("p",{className:"muted",children:["Showing the first ",jd," rows",n.truncatedCols?` and ${yd} columns`:"",". The download has the whole file."]}):null]})}function NM({attachment:e}){const t=vm(e.mime,e.filename),n=e.filename??"Untitled file";return s.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[s.jsx(Q0,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),s.jsxs("dl",{className:"ui-kv",children:[s.jsx("dt",{children:"Type"}),s.jsxs("dd",{children:[Cr[t],s.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Size"}),s.jsx("dd",{children:En(e.sizeBytes)})]}):null,s.jsx("dt",{children:"Id"}),s.jsx("dd",{className:"mono",children:e.artifactId})]}),s.jsx("div",{className:"ui-toolbar","data-align":"end",children:s.jsx("a",{className:"ui-btn",href:uu(e.artifactId),download:n,children:"Download"})})]})}const bv=80,CM=["query","path","url","dir"],EM=["message","task"];function bm(e,t){const n=AM(t);if(!n)return null;const r=ni(n.command);if(r!==null){const o=ni(n.name);return aa(o===null?r:`${o}: ${r}`)}for(const o of CM){const a=ni(n[o]);if(a!==null)return aa(a)}const i=ni(n.action);if(i!==null){const o=EM.map(a=>ni(n[a])).find(a=>a!==null)??null;return aa(o===null?i:`${i} · ${o}`)}const l=Object.values(n).filter(o=>typeof o=="string");return l.length===1?aa(ni(l[0])):null}function ni(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function aa(e){return e===null?null:e.length>bv?`${e.slice(0,bv-1)}…`:e}function AM(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Nc="agent.delegate";function RM(e){if(e===null||typeof e!="object")return null;const t=e,n=t.conversationId;if(typeof n!="string"||n==="")return null;const r=t.agentId??t.agent;return{conversationId:n,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function TM(e){if(typeof e=="string")return e;if(e===null||typeof e!="object")return null;const t=e.text;return typeof t=="string"?t:null}const dh="canvas.show",kv="canvas.clear",Sv=12;function Ni(e){return`${e.plugin}/${e.name}`}function PM(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function IM({messages:e,descriptors:t}){const n=new Map(t.filter(l=>l.renderer==="preview").map(l=>[l.tool,l]));if(n.size===0)return[];const r=new Map,i=[];for(const l of e)for(const o of l.blocks??[]){if(o.type==="tool_use"&&r.set(o.id,o.name),o.type!=="tool_result"||o.ok===!1)continue;const a=n.get(o.name||r.get(o.toolUseId)||"");if(!a)continue;const c=I0(a,J0(o.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:l.at??null})}return i}function MM({messages:e,descriptors:t,awaiting:n,folded:r,served:i}){var u;const l=new Map(t.map(h=>[h.tool,h])),o=new Map;let a=[],c=0;for(const h of e)for(const f of h.blocks??[]){if(f.type==="tool_use"){if(o.set(f.id,{name:f.name,input:f.input,at:h.at??null}),f.name===dh){const g=_M(f.id,f.input,h.at??null);g&&a.push(g)}if(f.name===kv&&(a=[]),f.name===Nc){const g=RM(f.input);g&&a.push({id:f.id,tool:Nc,title:"Delegation",renderer:"delegate",props:{...g,result:null},at:h.at??null,source:"delegate",substantial:!0})}continue}if(f.type!=="tool_result"||f.name===dh||f.name===kv)continue;const p=o.get(f.toolUseId),m=h.at??(p==null?void 0:p.at)??null,j=f.name||(p==null?void 0:p.name)||"tool",w=a.find(g=>g.source==="delegate"&&g.id===f.toolUseId);if(w&&((u=f.delegation)==null?void 0:u.state)==="waiting"){w.props={...w.props,result:null,waiting:{approvalId:f.delegation.approvalId}},f.delegation.approvalId&&(w.tone="warning");continue}if(w){w.props={...w.props,result:{ok:f.ok,text:TM(f.ok?f.output:f.error??f.output)}},f.ok||(w.tone="critical");continue}const b=f.approval?hh(f):(n==null?void 0:n.get(f.toolUseId))??hh(f);if(b){a.push({id:f.toolUseId,tool:j,title:"Approval",renderer:"envelope",props:{approvalId:b},at:m,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(j))continue;const x=J0(f.output);if(f.ok===!1){a.push({id:f.toolUseId,tool:j,title:ts(j),renderer:"structured",props:{value:f.error??x??null,failed:!0},at:m,tone:"critical",source:"fallback",substantial:!1});continue}PM(x)&&(c+=1);const v=l.get(j);if(v){const g=I0(v,x),{renderer:S}=g;let{props:k}=g;if(S==="preview"){const N=k,C=N.target??(N.awaiting&&(i!=null&&i.has(Ni(N.awaiting)))?N.awaiting:null);if(C===null)continue;k={...N,target:C,awaiting:null};const T=Ni(C);a=a.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&Ni(E.props.target)===T))}a.push({id:f.toolUseId,tool:j,title:v.title??ts(j),renderer:S,props:k,at:m,source:"descriptor",substantial:fh(S,k)});continue}const y={value:ym(x)?{input:p==null?void 0:p.input,output:x}:x};OM("structured",y)&&a.push({id:f.toolUseId,tool:j,title:ts(j),renderer:"structured",props:y,at:m,source:"fallback",substantial:fh("structured",y)})}for(const h of a)h.source==="descriptor"&&h.renderer==="preview"&&(h.props={...h.props,changes:c});return $M(a)}const Nv="forAgent";function J0(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(Nv in e))return e;const{[Nv]:t,...n}=e;return n}function $M(e){if(e.length<=Sv)return e;const t=e.length-Sv;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function _M(e,t,n){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:l}=t,o=typeof r=="string"&&Sc(r)?r:"structured";return{id:e,tool:dh,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:o,props:o==="structured"&&!Sc(String(r))?{value:l}:l,at:n,substantial:!0,source:"canvas"}}function OM(e,t){const n=t??{};return!!(n.failed===!0||fh(e,t)||jm(n.value).kind==="error")}function fh(e,t){const n=t??{};switch(e){case"timeseries":return ca(n.points)>0;case"bars":return ca(n.bars)>0;case"keyvalue":return ca(n.pairs)>0;case"document":return!!n.text||!!n.src;case"diff":return!!n.diff;case"terminal":return!!n.output||!!n.command;case"image":return!!n.artifactId;case"preview":return!!n.target;case"envelope":return!0;case"table":return(Array.isArray(n.groups)?n.groups:[]).some(i=>ca(i.rows)>0);default:return ym(n.value)?!0:n.failed===!0?!1:W2(n.value)}}function ca(e){return Array.isArray(e)?e.length:0}function hh(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const n=Z0(t,0);if(n)return n}return null}function DM(e,t,n={}){var a,c;const r=e.flatMap(u=>u.blocks),i=r.find(u=>u.type==="tool_use"&&u.id===t);if((i==null?void 0:i.type)!=="tool_use")return null;const l=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),o=(a=n.redactInputOf)!=null&&a.has(i.name)?X0(i.input):i.input;return{id:t,tool:i.name,title:ts(i.name),renderer:"structured",props:{value:{input:o,...(l==null?void 0:l.type)==="tool_result"?{status:((c=l.approval)==null?void 0:c.state)??(l.ok?"completed":"failed"),output:l.output,...l.error?{error:l.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const LM=new Set(["value","text","password","secret","code"]);function X0(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=LM.has(n)&&typeof r=="string"?"— withheld —":X0(r);return t}function Z0(e,t){if(t>3||e===null||typeof e!="object")return null;const n=e,r=n.reason,i=n.actionId??n.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const l of Object.values(n)){const o=Z0(l,t+1);if(o)return o}return null}function ts(e){const t=e.split(".");return t.length===1?Lt(e):t.map(n=>Lt(n)).join(" · ")}function ek({name:e,mime:t,sizeBytes:n,thumbnail:r,state:i,error:l,onOpen:o,onRemove:a,size:c="md"}){const u=vm(t,e),h=[Cr[u],En(n)].filter(Boolean).join(" · "),f=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wb-file-visual","data-family":u,children:r?s.jsx("img",{src:r,alt:""}):s.jsx(km,{family:u})}),s.jsxs("span",{className:"wb-file-text",children:[s.jsx("span",{className:"wb-file-name",title:e,children:e}),s.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":h})]})]});return s.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?l:void 0,children:[o?s.jsx("button",{type:"button",className:"wb-file-open",onClick:o,"aria-label":`Open ${e}`,children:f}):s.jsx("span",{className:"wb-file-open",children:f}),a?s.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:a,children:s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:s.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function km({family:e}){const t={width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"image":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),s.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),s.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),s.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),s.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),s.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"})]})}}function FM(e){const t=UM(e);if(!t)return null;const n=wd(t.diff);if(n!==null)return{kind:"diff",diff:n};const r=wd(t.command),i=wd(t.plain),l=bd(t.exitCode);return r!==null&&(i!==null||l!==null||bd(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:l,elapsedMs:bd(t.elapsedMs)}:null}function wd(e){return typeof e=="string"&&e.trim()!==""?e:null}function bd(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function UM(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Cv="offer:",tk="owner:interjection";function BM(e){return e===tk}function zM(e){if(typeof e!="string"||!e.startsWith(Cv))return null;const t=e.slice(Cv.length).trim();return t===""?null:t}function nk({messages:e,live:t,now:n,onOpen:r,working:i=!1,partial:l=null,agents:o,speakers:a,coordinatorId:c,workingAs:u,onOpenFile:h,children:f,agentName:p,emptyHint:m,empty:j,plain:w=!1,workingLine:b,runs:x}){var k,N;const v=d.useRef(null);d.useEffect(()=>{var C;(C=v.current)==null||C.scrollIntoView({block:"end"})},[e.length,t.length,i,l==null?void 0:l.text.length,l==null?void 0:l.thinking.length,!!f]);const y=l&&!l.settled&&(l.text!==""||l.thinking!==""),g=e.filter(C=>(C.blocks??[]).some(JM)),S=qM(g,x??[]);return s.jsx(R0.Provider,{value:o??a??[],children:s.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[g.length===0&&t.length===0?j??s.jsx("p",{className:"wb-chat-empty",children:m}):null,g.map((C,T)=>{const E=C.speaker??null,U=a?E==="owner"||E===null&&C.role==="user":C.role==="user",H=a&&E==="room",O=a&&E&&E!=="owner"&&E!=="room"?a.find(_=>_.id===E)??null:null,R=g[T-1],F=T===0||(a?((R==null?void 0:R.speaker)??null)!==E:R.role!==C.role);if(H)return s.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(C.blocks??[]).filter(_=>_.type==="text").map((_,ne)=>s.jsx("span",{children:_.text},ne))},C.id);const K=(C.blocks??[]).filter(_=>_.type==="approval_result");if(K.length>0)return s.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:K.map((_,ne)=>s.jsx(XM,{block:_},ne))},C.id);const L=C.role==="user"&&BM(E),M=C.role==="user"?zM(E):null;if(M){const _=(C.blocks??[]).filter(ne=>ne.type==="text").map(ne=>ne.text).join(`
95
- `);return s.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:s.jsx("div",{className:"wb-bubble wb-bubble-offer",title:_,children:M})},C.id)}const V=a&&O&&C.role==="user"?YM(C):null;if(V){const _=g.slice(T+1).find(X=>X.role==="assistant"&&X.speaker&&X.speaker!==O.id),ne=_!=null&&_.speaker?a.find(X=>X.id===_.speaker):void 0;return s.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[s.jsxs("summary",{children:[O.name," asked ",(ne==null?void 0:ne.name)??"a member",V.request?`: ${V.request.length>120?`${V.request.slice(0,119)}…`:V.request}`:""]}),V.request?s.jsx("p",{children:V.request}):null]},C.id)}const $=S.get(C.id)??null;return s.jsxs("div",{className:"wb-msg","data-role":U||L?"user":"assistant",children:[L?s.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,F&&!U&&!L?s.jsxs("div",{className:"wb-msg-who",children:[O&&a?s.jsx(bn,{agents:a,id:O.id,size:"sm"}):null,s.jsx("span",{children:O?O.name:p??"Assistant"}),O&&c===O.id?s.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null]}):null,Ev(C).length>0?s.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:Ev(C).map(_=>s.jsx("span",{role:"listitem",children:s.jsx(ek,{name:_.filename??"Untitled file",mime:_.mime,sizeBytes:_.sizeBytes,thumbnail:y2(_.mime)?Dr(_.artifactId):null,...h?{onOpen:()=>h(_)}:{}})},_.artifactId))}):null,(C.blocks??[]).map((_,ne)=>{const X=HM(C.blocks??[],ne,e);if(X==="inside")return null;if(X)return s.jsx(KM,{refusals:X.refusals},ne);if(_.type==="thinking")return w||_.text.trim()===""?null:s.jsx(ph,{text:_.text},ne);if(_.type==="text")return _.text.trim()===""?null:U?s.jsx("div",{className:"wb-bubble",children:_.text},ne):s.jsx("div",{className:"wb-bubble","data-rich":"true",children:s.jsx(_r,{text:_.text})},ne);if(_.type==="attachment")return null;if(_.type==="tool_use"){if(w)return null;const ue=sk(e,_.id),ye=ue?t$(ue):null;return s.jsx(mh,{label:ye&&!(ue!=null&&ue.delegation)?`Approval · ${_.name}`:ts(_.name),tool:_.name,ok:(ue==null?void 0:ue.ok)??null,running:ue===null,...ye?{status:ye.status,waiting:ye.waiting,approval:!0}:{},gist:bm(_.name,_.input),body:ue?FM(ue.output):null,opens:!0,onOpen:()=>r(_.id)},ne)}return null}),$?s.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:QM($)}):null]},C.id)}),y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[((k=g.at(-1))==null?void 0:k.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??p??"Assistant"}):null,l.thinking!==""&&!w?s.jsx(ph,{text:l.thinking,live:l.text==="",seconds:GM(l.thinkingStartedAt,l.textStartedAt??n)}):null,l.text!==""?s.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[s.jsx(_r,{text:l.text}),s.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null]}):null,i&&t.length===0&&!y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"working",children:[((N=g.at(-1))==null?void 0:N.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??p??"Assistant"}):null,s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[b??`${u??p??"The agent"} is working`,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})]}):null,t.map(C=>s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx(mh,{label:ts(C.name),tool:C.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((n-C.startedAt)/1e3)),opens:!1,onOpen:()=>r(C.toolUseId)})},C.toolUseId)),f,s.jsx("div",{ref:v})]})})}function WM(e){var t,n;return((n=(t=/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:n.trim())||null}const VM="delegation refused:";function HM(e,t,n){const r=l=>{const o=e[l];if(!o||o.type!=="tool_use"||o.name!==Nc)return null;const a=sk(n,o.id);if(!a||a.ok!==!1)return null;const c=typeof a.error=="string"?a.error:String(a.error??"");if(!c.trimStart().startsWith(VM))return null;const u=o.input??{};return{target:typeof u.agent=="string"&&u.agent!==""?u.agent:"a colleague",message:c}};if(!r(t))return null;if(r(t-1))return"inside";const i=[];for(let l=t;;l+=1){const o=r(l);if(!o)break;i.push(o)}return i.length<2?null:{refusals:i}}function KM({refusals:e}){const[t,n]=d.useState(!1),r=e.map(a=>WM(a.message)).find(a=>a!==null)??null,i=e.map(a=>a.target),l=i.slice(0,3),o=`Delegation refused ${e.length} times: ${l.join(", ")}${i.length>l.length?", …":""}`+(r?` (allowed: ${r})`:"");return s.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>n(a=>!a),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:o}),s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("div",{className:"wb-refusals-list",children:e.map((a,c)=>s.jsxs("div",{className:"wb-refusal",children:[s.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsxs("span",{className:"wb-tool-label",children:[ts(Nc)," · ",a.target]}),s.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),s.jsx("p",{className:"wb-refusal-why",children:a.message})]},c))}):null]})}function GM(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function ph({text:e,live:t=!1,seconds:n=null}){const[r,i]=d.useState(!1),l=t?`Thinking${n!==null&&n>0?` · ${n}s`:""}`:n!==null&&n>0?`Thought for ${n}s`:"Thoughts";return s.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[s.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(o=>!o),children:[t?s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}):s.jsx(Oe,{name:"thought"}),s.jsx("span",{children:l}),s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]}),r?s.jsx("div",{className:"wb-thought-text",children:s.jsx(_r,{text:e})}):null]})}function YM(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",n=/You are a member of the group "[^"]*"\. @([\w-]+), the coordinator, asks you now:\n\n([\s\S]*?)(?:\n\nAnswer for the room|$)/.exec(t);return n?{handle:n[1],request:n[2].trim()}:null}function Ev(e){return(e.blocks??[]).filter(t=>t.type==="attachment")}function qM(e,t){const n=t.filter(o=>o.startedAt!==null&&o.finishedAt!==null),r=(o,a)=>a.at!==""&&a.at>=o.startedAt&&a.at<=o.finishedAt,i=(o,a)=>o!==a&&o.startedAt>=a.startedAt&&o.finishedAt<=a.finishedAt&&(o.startedAt>a.startedAt||o.finishedAt<a.finishedAt),l=new Map;for(const o of n){if(o.stopped!=="max_turns"&&o.stopped!=="max_tokens"||o.noticed!==!0||o.runId===null)continue;let a=null;for(const c of e)c.role!=="assistant"||!r(o,c)||(a=c);a===null||n.some(c=>i(c,o)&&r(c,a))||l.has(a.id)||l.set(a.id,o)}return l}function QM(e){if(e.stopped==="max_tokens")return"Length limit reached · answer cut off";const t=e.turns;return t===null?"Turn budget reached":`Turn budget reached · ${t} ${t===1?"step":"steps"}`}function JM(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function XM({block:e}){const[t,n]=d.useState(!1),r=e.state==="succeeded";return s.jsxs("div",{className:"wb-approval","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":r,"aria-expanded":t,onClick:()=>n(i=>!i),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":r?"true":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":ts(e.name)}),s.jsx("span",{className:"wb-tool-elapsed",children:e.state}),s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("pre",{className:"wb-approval-output mono",children:ZM(e.output)}):null]})}function ZM(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const e$=40;function t$(e){var n,r;if(((n=e.delegation)==null?void 0:n.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(hh(e))return{status:"waiting",waiting:!0};const t=(r=e.approval)==null?void 0:r.state;return t?t==="approved"||t==="executing"?{status:"approved",waiting:!0}:t==="succeeded"?{status:"approved",waiting:!1}:{status:t,waiting:!1}:null}function mh({label:e,tool:t,ok:n,running:r,elapsed:i,opens:l,onOpen:o,status:a,waiting:c=!1,approval:u=!1,gist:h=null,body:f=null}){const[p,m]=d.useState(!1),j=s.jsxs(s.Fragment,{children:[r?s.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):s.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":n===!1?"false":"true","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e}),h?s.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:h}):null,i===void 0?null:s.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),a||n===!1?s.jsx("span",{className:"wb-tool-elapsed",children:a??"failed"}):null]}),w={"data-ok":n===null?void 0:n,"data-running":r,"data-gist":h?!0:void 0,"data-approval":u||void 0};return f?s.jsxs("div",{className:"wb-toolcall","data-open":p||void 0,children:[s.jsxs("div",{className:"wb-tool","data-split":"true",...w,children:[s.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":p,onClick:()=>m(b=>!b),children:[s.jsx(Oe,{name:"chevron",className:"wb-tool-chevron"}),j]}),l?s.jsxs(mc,{children:[s.jsx(gc,{asChild:!0,children:s.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:o,children:s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})})}),s.jsx(xc,{children:s.jsxs(vc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),p?s.jsx(n$,{body:f,onOpen:l?o:null}):null]}):l?s.jsxs(mc,{children:[s.jsx(gc,{asChild:!0,children:s.jsxs("button",{className:"wb-tool",...w,onClick:o,children:[j,s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]})}),s.jsx(xc,{children:s.jsxs(vc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):s.jsx("span",{className:"wb-tool","data-static":"true",...w,children:j})}function n$({body:e,onOpen:t}){const n=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return s.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:s.jsx(wc,{text:e.diff,limit:e$,...n?{more:n}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:s$(e.elapsedMs)].filter(i=>i!==null);return s.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[s.jsxs("div",{className:"wb-tool-command",children:[s.jsx("code",{className:"mono",children:e.command}),r.length>0?s.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?s.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function s$(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function sk(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}const rk="approval-dock";function r$(){var t;const e=document.getElementById(rk);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const i$=["workspace","cwd","workdir","root"];function l$({approvals:e,timezone:t,now:n,version:r,onDecided:i,onSay:l,onOpenFull:o}){const[a,c]=d.useState([]),u=e.filter(p=>!a.includes(p.approvalId)),h=u[0];if(!h)return null;const f=p=>c(m=>m.includes(p)?m:[...m,p]);return s.jsx(o$,{item:h,count:u.length,timezone:t,now:n,version:r,onSettled:p=>{f(h.approvalId),p&&i(p)},onSay:l,onOpenFull:()=>o(h.toolUseId)},h.approvalId)}function o$({item:e,count:t,timezone:n,now:r,version:i,onSettled:l,onSay:o,onOpenFull:a}){var C;const[c,u]=d.useState(null),[h,f]=d.useState(null),[p,m]=d.useState(null),[j,w]=d.useState("");d.useEffect(()=>{let T=!1;return A.approval(e.approvalId).then(E=>{T||(u(E),E.state!=="pending"&&l(E))}).catch(E=>{T||f(E instanceof pe?E.message:String(E))}),()=>{T=!0}},[e.approvalId,i]);const b=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;d.useEffect(()=>{b&&c&&l({...c,state:"expired"})},[b]);const{values:x,controls:v}=xm(c==null?void 0:c.choices),y=(T,E)=>{const U=j.trim();m(T),f(null),(x&&T==="approve"?A.decide(e.approvalId,T,E,x):A.decide(e.approvalId,T,E)).then(H=>{l(H.action),U&&o(U)}).catch(H=>{f(H instanceof pe?H.message:String(H)),m(null)})},g=p!==null||c===null||c.state!=="pending",S=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,k=c?bm(c.tool,c.canonicalArgs)??c$(c.preview):null,N=c?a$(c):null;return s.jsxs("section",{id:rk,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?s.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,s.jsx("strong",{children:c?ts(c.tool):"Loading the request…"}),e.askedBy?s.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),k||N?s.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[k?s.jsx("code",{className:"wb-dock-gist",children:k}):null,N?s.jsxs("span",{className:"wb-dock-where",children:["in ",s.jsx("span",{className:"mono",children:N})]}):null]}):null,v?s.jsx("div",{className:"wb-dock-section",children:v}):null,s.jsx(ie,{message:h}),s.jsx("div",{className:"wb-dock-section",children:s.jsx("input",{className:"wb-dock-instead",value:j,onChange:T=>w(T.target.value),onKeyDown:T=>{T.key==="Enter"&&T.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:p!==null})}),s.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[s.jsxs("span",{className:"wb-dock-meta",children:[c?s.jsxs(s.Fragment,{children:["Expires ",Pe(c.expiresAt,n)," · "]}):null,s.jsx("button",{type:"button",className:"wb-link",onClick:a,children:"See the full request on the Canvas"})]}),s.jsx(P,{variant:"ghost",size:"sm",disabled:g,onClick:()=>y("reject"),children:p==="reject"?"Rejecting…":"Reject"}),S?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",size:"sm",disabled:g,onClick:()=>y("approve","conversation"),children:"Auto: this conversation"}),s.jsx(P,{size:"sm",disabled:g,onClick:()=>y("approve","always"),children:"Always: this agent"})]}):null,s.jsx(P,{variant:"good",size:"sm",disabled:g,onClick:()=>y("approve"),children:p==="approve"?"Approving…":S?"Allow once":"Approve"})]})]})}function a$(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const n of i$){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function c$(e){const t=(e??"").split(`
96
- `).map(n=>n.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const u$=2e3;function d$({conversationId:e,agentId:t,runId:n=null,result:r=null,waiting:i=null,agents:l=[]}){const o=r!==null,[a,c]=d.useState(o),u=!a||i!==null,{data:h,error:f}=le(()=>_e.conversation(e),[e,a,(i==null?void 0:i.approvalId)??null],u?u$:void 0),p=(h==null?void 0:h.runs)??[],m=n===null?null:p.find(g=>g.runId===n)??null,j=o||i===null&&(n!==null?m!==null&&m.finishedAt!==null:p.length>0&&p.every(g=>g.finishedAt!==null));d.useEffect(()=>{j&&c(!0)},[j]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":j?"done":"working",b=l.find(g=>g.id===t)??null,x=(b==null?void 0:b.name)??(h==null?void 0:h.agentId)??t,v=(h==null?void 0:h.messages)??[],y=(r==null?void 0:r.text)??f$(v);return s.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":w,children:[s.jsxs("header",{className:"wb-delegate-head",children:[s.jsx(bn,{agents:l,id:t}),s.jsxs("div",{className:"wb-delegate-who",children:[s.jsx("strong",{children:x}),s.jsx("span",{className:"wb-delegate-status","data-status":w,role:"status",children:w==="working"?s.jsxs(s.Fragment,{children:["Working",s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]}):w==="waiting"?"Waiting for your approval":w==="failed"?"Failed":"Done"})]})]}),f?s.jsx("p",{className:"muted",children:f}):null,s.jsx("div",{className:"wb-delegate-work",children:v.map((g,S)=>s.jsx("div",{className:"wb-delegate-turn",children:(g.blocks??[]).map((k,N)=>{if(k.type==="thinking")return k.text.trim()===""?null:s.jsx(ph,{text:k.text},N);if(k.type==="tool_use"){const C=p$(h$(v,k.id));return s.jsx(mh,{label:ts(k.name),tool:k.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:bm(k.name,k.input),opens:!1,onOpen:()=>{}},N)}return null})},g.id??S))}),y?s.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:s.jsx(_r,{text:y})}):w==="working"||w==="waiting"?s.jsxs("p",{className:"muted",children:[x," has not answered yet."]}):null,s.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?s.jsx(P,{variant:"accent",onClick:()=>r$(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,s.jsx("a",{className:"ui-btn",href:De(t||(h==null?void 0:h.agentId)||"",e),children:"Open this conversation"})]})]})}function f$(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.role!=="assistant")continue;const r=(n.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
97
-
98
- `);if(r!=="")return r}return null}function h$(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function p$(e){var n;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(n=e.approval)==null?void 0:n.state;return t==="pending"?{running:!1,ok:null,waiting:!0,status:"waiting approval"}:t==="approved"||t==="executing"?{running:!0,ok:null,waiting:!1,status:"running"}:t==="succeeded"?{running:!1,ok:!0,waiting:!1,status:void 0}:t?{running:!1,ok:!1,waiting:!1,status:t}:{running:!1,ok:e.ok,waiting:!1,status:void 0}}const Av=1024*1024;function m$({files:e,agentId:t,root:n,revision:r}){const[i,l]=d.useState({kind:"dir",path:""});return d.useEffect(()=>l({kind:"dir",path:""}),[e.plugin,t]),s.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?s.jsx(g$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:l}):s.jsx(x$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:l})})}function ik({root:e,path:t,go:n}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((l,o)=>({label:l,path:r.slice(0,o+1).join("/")}))];return s.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((l,o)=>{const a=o===i.length-1;return s.jsxs("span",{className:"wb-files-crumb",children:[o>0?s.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,a?s.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:l.label}):s.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>n({kind:"dir",path:l.path}),children:l.label})]},l.path)})})}function g$({files:e,agentId:t,root:n,path:r,revision:i,go:l}){const[o,a]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1),[p,m]=d.useState(null);d.useEffect(()=>{let b=!1;return u(null),A.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(x=>{b||a(x.data)}).catch(x=>{b||u(x instanceof Error?x.message:String(x))}),()=>{b=!0}},[e.plugin,e.list,t,r,i]),d.useEffect(()=>m(null),[r]);const j=async()=>{f(!0),m(null);try{const b=await fetch(A.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!b.ok){const g=await b.json().catch(()=>null);m((g==null?void 0:g.error)??"The archive could not be made.");return}const x=await b.blob(),v=URL.createObjectURL(x),y=document.createElement("a");y.href=v,y.download=`${r===""?n:r.split("/").at(-1)}.zip`,y.click(),window.setTimeout(()=>URL.revokeObjectURL(v),1e4)}catch{m("The archive could not be made.")}finally{f(!1)}},w=o&&o.path===r?o.entries:null;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(ik,{root:n,path:r,go:l}),s.jsx(tl,{}),s.jsx(P,{size:"sm",onClick:()=>void j(),disabled:h||w===null||w.length===0,children:h?"Packing…":"Download as archive"})]}),p?s.jsx(G,{tone:"warning",role:"alert",children:p}):null,c?s.jsx(G,{tone:"critical",role:"alert",children:c}):null,w===null?c?null:s.jsx(oe,{children:"Reading the folder…"}):w.length===0?s.jsx(oe,{children:r===""?s.jsxs(s.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",s.jsx("a",{href:$r,children:"Files library"})," and mention it here."]}):"This folder is empty."}):s.jsx(un,{children:w.map(b=>s.jsx(Cn,{href:"#",onClick:()=>l({kind:b.kind,path:b.path}),lead:s.jsx(j$,{kind:b.kind}),title:s.jsxs("span",{className:"mono",children:[b.name,b.kind==="dir"?"/":""]}),side:b.kind==="file"?En(b.bytes):void 0},b.path))}),o&&o.path===r&&(o.skipped>0||o.truncated)?s.jsxs("p",{className:"wb-files-note",children:[o.truncated?`Only the first ${o.entries.length} entries are shown. `:"",o.skipped>0?`${o.skipped} ${o.skipped===1?"entry is":"entries are"} not shown: symbolic links and protected paths are never read.`:""]}):null]})}function x$({files:e,agentId:t,root:n,path:r,revision:i,go:l}){const[o,a]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1);d.useEffect(()=>{let x=!1;return u(null),A.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(v=>{x||a(v.data)}).catch(v=>{x||u(v instanceof Error?v.message:String(v))}),()=>{x=!0}},[e.plugin,e.stat,t,r,i]);const p=o&&o.path===r?o:null,m=p?`${p.bytes}-${Math.round(p.mtimeMs)}`:"",j=p?A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v:m}):"",w=A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),b=(p==null?void 0:p.type)==="text"&&p.bytes<=Av;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(ik,{root:n,path:r,go:l}),s.jsx(tl,{}),b?s.jsx(P,{size:"sm","aria-pressed":h,onClick:()=>f(x=>!x),children:"Wrap"}):null,s.jsx(Fn,{size:"sm",href:w,download:(p==null?void 0:p.name)??r.split("/").at(-1),children:"Download"})]}),c?s.jsx(G,{tone:"critical",role:"alert",children:c}):null,p===null?c?null:s.jsx(oe,{children:"Reading the file…"}):p.type==="image"?s.jsx("figure",{className:"wb-files-picture",children:s.jsx("img",{src:j,alt:p.name})}):p.type==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:j,type:"application/pdf","aria-label":p.name,children:s.jsx(G,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):b?s.jsx(v$,{src:j,wrap:h}):s.jsxs(s.Fragment,{children:[s.jsx(G,{children:p.type==="text"?`This file is over ${En(Av)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),s.jsx(bt,{items:[{label:"Size",value:En(p.bytes)},{label:"Type",value:s.jsx("span",{className:"mono",children:p.mime})}]})]})]})}function v$({src:e,wrap:t}){const[n,r]=d.useState(null),[i,l]=d.useState(!1);return d.useEffect(()=>{let o=!1;return l(!1),fetch(e,{credentials:"same-origin"}).then(async a=>{if(!a.ok)throw new Error(String(a.status));const c=await a.text();o||r(c)}).catch(()=>{o||l(!0)}),()=>{o=!0}},[e]),i?s.jsx(G,{tone:"critical",children:"The file could not be read."}):n===null?s.jsx(oe,{children:"Reading the file…"}):n===""?s.jsx(oe,{children:"This file is empty."}):s.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:n})}function j$({kind:e}){return s.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:e==="dir"?s.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}const y$=3,w$=152,b$=104,k$=100,S$=2,Rv=5;function N$({renderables:e,activeId:t,onActivate:n,timezone:r,onDecided:i,onChangeAgent:l,face:o,descriptors:a,grantedTools:c,agentName:u,maxTabs:h,browserPanel:f,agents:p,onClose:m,loading:j=!1}){const[w,b]=C$(h);if(e.length===0)return s.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[s.jsx("div",{className:"wb-canvas-tabs",ref:w,"aria-hidden":"true",children:s.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),s.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:j?null:s.jsxs("div",{className:"wb-empty",children:[o?s.jsx("span",{className:"wb-empty-face",children:o}):null,s.jsx("p",{className:"ui-empty wb-empty-line",children:P$(u,I$(a??[],c??[]))})]})})]});const x=e.some(g=>g.id===t)?t:e[e.length-1].id,{shown:v,hidden:y}=E$(e,x,b);return s.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:s.jsxs(MP,{value:x,onValueChange:n,className:"contents",children:[s.jsxs("div",{className:"wb-canvas-tabs",ref:w,children:[s.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),s.jsx($P,{className:"wb-tabstrip","aria-label":"Canvas",children:v.map(g=>s.jsxs("div",{className:"wb-tab-item",children:[s.jsxs(_P,{value:g.id,className:"wb-tab","data-tone":g.tone,onKeyDown:S=>{S.key==="Delete"&&m&&Tv(g)&&(S.preventDefault(),m(g.id))},children:[g.tone==="warning"||g.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":g.tone,"aria-hidden":"true"}):null,s.jsx("span",{className:"wb-tab-text",children:g.title})]}),m&&Tv(g)?s.jsx("button",{className:"wb-tab-close","aria-label":`Close ${g.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>m(g.id),children:"×"}):null]},g.id))}),s.jsx(A$,{items:y,onActivate:n,timezone:r})]}),e.map(g=>s.jsx(OP,{value:g.id,className:"wb-canvas-body","data-renderer":g.source==="descriptor"&&g.renderer==="preview"?"preview":void 0,"data-dense":$$.has(g.renderer)?"true":void 0,children:s.jsxs("section",{className:"ui-panel","data-flush":g.source==="descriptor"&&g.renderer==="preview"?"true":void 0,children:[g.source!=="browser"&&g.source!=="files"&&!(g.source==="descriptor"&&g.renderer==="preview")?s.jsxs("header",{className:"ui-panel-head",children:[s.jsx("h2",{className:"ui-panel-title",children:g.title}),s.jsx("span",{className:"ui-panel-tool mono",children:g.tool})]}):null,g.tone==="critical"?s.jsxs("p",{className:"muted",children:["Recorded tool failure",g.at?` · ${new Date(g.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,g.source==="browser"?f:g.source==="profile"?s.jsx(pM,{...g.props,...l?{onChange:l}:{}}):g.source==="artifact"?s.jsx(NM,{...g.props}):g.source==="files"?s.jsx(m$,{...g.props}):g.source==="delegate"?s.jsx(d$,{...g.props,agents:p??[]}):s.jsx(hM,{renderer:g.renderer,props:g.props,timezone:r,onDecided:i})]})},g.id))]})})}function Tv(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function C$(e){const[t,n]=d.useState(Rv),r=d.useRef(null);return[d.useCallback(l=>{var a;if((a=r.current)==null||a.disconnect(),r.current=null,!l||e!==void 0||typeof ResizeObserver>"u")return;const o=()=>{const c=l.clientWidth;if(c===0)return;const u=Math.floor((c-k$-b$)/w$);n(Math.max(S$,Math.min(Rv,u)))};o(),r.current=new ResizeObserver(o),r.current.observe(l)},[e]),e??t]}function E$(e,t,n){const r=new Set(e.filter(l=>l.id===t||l.source==="approval"||l.pinned===!0).map(l=>l.id)),i=new Set(r);for(let l=e.length-1;l>=0&&i.size<n;l-=1)i.add(e[l].id);return{shown:e.filter(l=>i.has(l.id)),hidden:e.filter(l=>!i.has(l.id))}}function A$({items:e,onActivate:t,timezone:n}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return s.jsxs(Xp,{modal:!1,children:[s.jsx(Zp,{asChild:!0,children:s.jsxs("button",{className:"wb-tab wb-tab-more","data-tone":r??void 0,"aria-label":`${e.length} more ${e.length===1?"view":"views"} in this conversation`,children:[r?s.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,s.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),s.jsx(Oe,{name:"chevron-down"})]})}),s.jsx(em,{children:s.jsxs(tm,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[s.jsx(nm,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>s.jsxs(Qf,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[s.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),s.jsx("span",{className:"ui-menu-note mono",children:R$(i.at,n)??i.tool})]},i.id))]})})]})}function R$(e,t){if(!e)return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit"}).format(n)}const T$={timeseries:"charts",table:"tables",bars:"comparisons",keyvalue:"figures",document:"pages it read",diff:"diffs",terminal:"command output",image:"pictures",preview:"running apps",envelope:"drafts",structured:"results"};function P$(e,t){const n=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>T$[i.renderer]??"results"))].slice(0,3);return r.length>0?`${n} lands here: ${r.join(", ")}.`:`${n} lands here.`}function I$(e,t){const n=new Set(t),r=new Set,i=e.filter(c=>{if(!n.has(c.tool))return!1;const u=M$(c);return r.has(u)?!1:(r.add(u),!0)}),l=new Set,o=i.filter(c=>l.has(c.renderer)?!1:(l.add(c.renderer),!0)),a=i.filter(c=>!o.includes(c));return[...o,...a].slice(0,y$)}function M$(e){return e.title&&e.title.trim()!==""?e.title:e.tool.split(".").map(t=>t.replace(/[_-]+/g," ")).join(" · ").replace(/\b\w/,t=>t.toUpperCase())}const $$=new Set(["table","diff","files"]),_$=3.5*6e4,O$=2e3;function D$(e,t,n={}){const[r,i]=d.useState({served:new Set,live:new Set,scope:t}),l=d.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};l.current=u.served,i(u)}const o=n.check??A.previewCheck,a=n.everyMs??O$,c=e.map(u=>`${Ni(u)}@${u.at??""}`).join("|");return d.useEffect(()=>{const u=new Map;for(const m of e){const j=Ni(m);if(l.current.has(j))continue;const w=m.at===null?Number.NaN:Date.parse(m.at),b=Number.isNaN(w)?0:w+_$,x=u.get(j);(!x||b>x.until)&&u.set(j,{plugin:m.plugin,name:m.name,until:b})}if(u.size===0)return;let h=!1,f;const p=async()=>{const m=Date.now();for(const[j,w]of[...u]){const b=await o(w.plugin,w.name).catch(()=>null);if(h)return;const x=m<=w.until;b!=null&&b.ok?(u.delete(j),i(v=>{const y={served:new Set(v.served).add(j),live:x?new Set(v.live).add(j):v.live,scope:v.scope};return l.current=y.served,y})):x||u.delete(j)}!h&&u.size>0&&(f=setTimeout(()=>void p(),a))};return p(),()=>{h=!0,f!==void 0&&clearTimeout(f)}},[c,t,o,a]),r}const gh="workspace-files";function L$(e){let t=0;for(const n of e)for(const r of n.blocks??[]){if(r.type!=="tool_result"||r.ok===!1)continue;const i=r.output;if(i===null||typeof i!="object"||Array.isArray(i))continue;const{diff:l,path:o}=i;typeof l=="string"&&l.trim()!==""&&typeof o=="string"&&o!==""&&(t+=1)}return t}function F$(e){const[t,n]=d.useState(null);return d.useEffect(()=>{if(n(null),!e)return;let r=!1;return(async()=>{var l;const i=await A.pages();for(const o of Array.isArray(i==null?void 0:i.files)?i.files:[]){const a=await A.pageQuery(o.plugin,o.workspace,{agent:e}).catch(()=>null),c=(l=a==null?void 0:a.data)==null?void 0:l.workspace;if(c&&typeof c.name=="string")return{files:o,agentId:e,root:c.name}}return null})().then(i=>{r||n(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function U$(e,t){return{id:gh,tool:"",title:"Files",renderer:"files",props:{files:e.files,agentId:e.agentId,root:e.root,revision:t},at:null,source:"files",pinned:!0,substantial:!1}}function xh(e){return`agent-properties:${e}`}function B$(e){return{id:xh(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function z$(e){return!e||e.download===0?"Fetching the browser…":e.phase==="downloading"?`Fetching ${e.what}… ${e.percent}%`:e.phase==="installing"?`Setting up ${e.what}…`:e.phase==="done"?"Installed.":"The install stopped."}function lk({progress:e}){return s.jsxs(q,{gap:"sm",children:[s.jsx("span",{role:"status",children:z$(e)}),s.jsx(h2,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function W$(e,t,n,r){const i=e.width||1,l=e.height||1,o=t.pageScaleFactor||1,a=(n-e.left)*(t.deviceWidth/i)/o,c=((r-e.top)*(t.deviceHeight/l)-t.offsetTop)/o,u=(h,f)=>Math.max(0,Math.min(Math.round(h),Math.round(f)));return{x:u(a,t.deviceWidth),y:u(c,t.deviceHeight)}}function kd(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function Pv(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const V$=4e3;function H$(e){return e.replace(/\r\n?/g,`
99
- `).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,V$)}const K$=["left","middle","right"],G$=33;function Y$(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function q$(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const n=t.getUint16(1);if(e.byteLength<3+n)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,n))),jpeg:new Blob([new Uint8Array(e,3+n)],{type:"image/jpeg"})}}catch{return null}}function Q$(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function J$({sessionId:e,csrf:t,onGiveBack:n,connect:r}){const[i,l]=d.useState("connecting"),[o,a]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState(!1),[j,w]=d.useState(0),b=d.useRef(null),x=d.useRef(null),v=d.useRef(null),y=d.useRef({at:0});d.useEffect(()=>{const R=r??(L=>new WebSocket(L));let F=!0,K;try{K=R(Q$())}catch{l("lost");return}return K.binaryType="arraybuffer",b.current=K,K.onopen=()=>K.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),K.onmessage=L=>{if(!F)return;if(typeof L.data!="string"){const V=q$(L.data);if(!V||(f($=>$&&Y$($,V.metadata)?$:V.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(V.jpeg).then($=>{var ne,X,ue;const _=x.current;if(!F||!_){(ne=$.close)==null||ne.call($);return}(_.width!==$.width||_.height!==$.height)&&(_.width=$.width,_.height=$.height),(X=_.getContext("2d"))==null||X.drawImage($,0,0),(ue=$.close)==null||ue.call($)}).catch(()=>{});return}const M=JSON.parse(L.data);if(M.type==="driving"){l("driving"),a(null);return}(M.type==="refused"||M.type==="ended")&&(a(M.error??"The screen cannot be driven from here."),l("refused"))},K.onclose=()=>{F&&l(L=>L==="refused"?L:"lost")},K.onerror=()=>{F&&l(L=>L==="refused"?L:"lost")},()=>{F=!1,b.current=null;try{K.close()}catch{}}},[e,t,j,r]),d.useEffect(()=>()=>{clearTimeout(y.current.timer)},[]);const g=d.useCallback(R=>{const F=b.current;if(F)try{F.send(JSON.stringify({type:"input",input:R}))}catch{}},[]),S=R=>{var L;const F=x.current;if(!F||!h)return null;const K=(L=F.getBoundingClientRect)==null?void 0:L.call(F);return K?W$(K,h,R.clientX,R.clientY):null},k=R=>{const F=y.current,K=Date.now();clearTimeout(F.timer),F.timer=void 0;const L=F.at+G$-K;if(L<=0){F.at=K,F.pending=void 0,g(R);return}F.pending=R,F.timer=setTimeout(()=>{const M=y.current.pending;y.current.timer=void 0,y.current.pending=void 0,y.current.at=Date.now(),M&&g(M)},L)},N=()=>{const R=y.current;clearTimeout(R.timer),R.timer=void 0;const F=R.pending;R.pending=void 0,F&&(R.at=Date.now(),g(F))},C=R=>F=>{var M,V;const K=S(F);if(!K)return;R==="mousePressed"&&(F.preventDefault(),(V=(M=x.current)==null?void 0:M.focus)==null||V.call(M));const L={kind:"mouse",type:R,x:K.x,y:K.y,button:K$[F.button]??"left",clickCount:R==="mouseMoved"?0:Math.min(3,Math.max(1,F.detail||1)),modifiers:kd(F)};if(R==="mouseMoved"){k(L);return}N(),g(L)},T=R=>{const F=S(R);F&&(N(),g({kind:"wheel",x:F.x,y:F.y,deltaX:Math.round(R.deltaX),deltaY:Math.round(R.deltaY)}))},E=R=>R.ctrlKey||R.metaKey||R.altKey,U=R=>{var K,L;if(R.key==="Escape"&&E(R)){m(!1),(L=(K=R.target).blur)==null||L.call(K);return}if(R.preventDefault(),(R.metaKey||R.ctrlKey)&&(R.key==="v"||R.key==="V"))return;const F=kd(R);if(Pv(R.key)&&!E(R)){g({kind:"key",type:"char",key:R.key,code:R.code,text:R.key,modifiers:F});return}g({kind:"key",type:"keyDown",key:R.key,code:R.code,modifiers:F})},H=R=>{R.key==="Escape"&&E(R)||(R.preventDefault(),!((R.metaKey||R.ctrlKey)&&(R.key==="v"||R.key==="V"))&&(Pv(R.key)&&!E(R)||g({kind:"key",type:"keyUp",key:R.key,code:R.code,modifiers:kd(R)})))},O=R=>{var K;R.preventDefault();const F=H$(((K=R.clipboardData)==null?void 0:K.getData("text/plain"))??"");F!==""&&g({kind:"text",text:F})};return s.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[s.jsxs("div",{className:"hand-bar",children:[s.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",variant:p?"accent":"ghost","aria-pressed":p,onClick:()=>{var F,K,L,M;const R=!p;m(R),R?(K=(F=v.current)==null?void 0:F.focus)==null||K.call(F):(M=(L=v.current)==null?void 0:L.blur)==null||M.call(L)},children:"Keyboard"}),s.jsx(P,{size:"sm",variant:"accent",onClick:n,children:"Give it back"})]})]}),i==="lost"?s.jsxs(G,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",s.jsx(J,{align:"end",children:s.jsx(P,{size:"sm",variant:"accent",onClick:()=>{l("connecting"),w(R=>R+1)},children:"Reconnect"})})]}):null,i==="refused"&&o?s.jsx(G,{tone:"warning",role:"status",children:o}):null,s.jsx("div",{className:"hand-screen",children:c?s.jsx("canvas",{ref:x,className:"hand-picture",role:"img","aria-label":"The host browser, live","data-testid":"hand-picture",tabIndex:0,onMouseDown:C("mousePressed"),onMouseUp:C("mouseReleased"),onMouseMove:C("mouseMoved"),onWheel:T,onKeyDown:U,onKeyUp:H,onPaste:O,onContextMenu:R=>R.preventDefault()}):s.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),s.jsx("input",{ref:v,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:U,onKeyUp:H,onPaste:O,onBlur:()=>m(!1)})]})}function X$(e){return e==="darwin"?"this Mac":"this computer"}let Sd=null;function Sm(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{let n=!0;return Sd??(Sd=A.session().then(r=>r.platform,()=>{Sd=null})),Sd.then(r=>{n&&t(r)}),()=>{n=!1}},[]),X$(e)}function Z$({embedded:e,timezone:t}={}){var c;const{data:n,error:r,reload:i}=le(()=>A.browser(),[],3e3),l=le(()=>A.session(),[]),o=(c=l.data)!=null&&c.platform?l.data.platform==="darwin":!0,a=!!l.data||!!l.error;return s.jsxs(en,{embedded:e,title:"Computer & browser",children:[s.jsx(ie,{message:r}),!n||!a?s.jsx(oe,{children:"Checking the host…"}):s.jsx(e_,{data:n,macOS:o,reload:i,timezone:t},JSON.stringify(n.settings??null))]})}function e_({data:e,macOS:t,reload:n,timezone:r}){var N,C,T;const[i,l]=d.useState(!1),[o,a]=d.useState(null),[c,u]=d.useState(!1),h=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,f=(h==null?void 0:h.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),p=f==="computer",m=(N=e.sessions)!=null&&N.length?e.sessions:e.session?[e]:[],j=m.length>0||e.busy,w=async E=>{l(!0),a(null);try{await E()}catch(U){a(U instanceof Error?U.message:String(U))}finally{l(!1),n()}},b=E=>void w(()=>A.browserSettings(E)),x=e.permissions,v=f==="playwright"?e.browser:void 0,y=((C=v==null?void 0:v.install)==null?void 0:C.state)==="running",g=(v==null?void 0:v.engine)==="none",S=!!e.enabled&&!g&&!(v!=null&&v.problem)&&(!p||!(x!=null&&x.supported)||x.accessibility&&x.screenRecording),k=p?"Ready. Agents can use your computer within the apps you allow below.":f==="extension"?"Ready. Agents work in your Chrome, in background tabs, through the buddi extension.":(v==null?void 0:v.engine)==="chrome"?"Ready. Agents work in their own browser, a separate Google Chrome profile. Your apps are never touched.":"Ready. Agents work in their own browser. Your apps are never touched.";return s.jsxs(q,{gap:"lg",children:[s.jsx(ie,{message:o}),s.jsx(Y,{title:"Status",panel:!0,actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",disabled:i,onClick:()=>void w(()=>A.computerPermissions(!1)),children:"Check again"}),p&&!S&&(x!=null&&x.supported)?s.jsx(P,{size:"sm",variant:"accent",disabled:i||j,onClick:()=>void w(()=>A.computerPermissions(!0)),children:"Request macOS permissions"}):null,g||y?s.jsx(P,{size:"sm",variant:"accent",disabled:i||y,onClick:()=>void w(()=>A.browserInstall()),children:y?"Installing…":"Install Chromium"}):null]}),children:s.jsxs(q,{children:[e.enabled?g?s.jsxs(G,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",s.jsx("code",{children:"buddi browser install"})," on this machine."]}):v!=null&&v.problem?s.jsx(G,{tone:"warning",children:v.message}):S?s.jsx(G,{tone:"good",children:k}):s.jsx(G,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):s.jsx(G,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),p?x!=null&&x.supported?s.jsxs("ul",{className:"perm-list",children:[s.jsxs("li",{className:"perm-row",children:[s.jsx(fe,{tone:x.accessibility?"good":"warning",children:x.accessibility?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Accessibility"}),s.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),s.jsxs("li",{className:"perm-row",children:[s.jsx(fe,{tone:x.screenRecording?"good":"warning",children:x.screenRecording?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Screen Recording"}),s.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):x?s.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,((T=v==null?void 0:v.install)==null?void 0:T.state)==="running"?s.jsx(lk,{progress:v.install.progress}):v!=null&&v.install?s.jsx("p",{className:"muted",role:"status",children:v.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${v.install.line??"no reason given"}`}):null,v!=null&&v.headless&&!g?s.jsx("p",{className:"muted",children:"The agents’ browser runs headless on this machine, since it has no display. Watch it and take over from the conversation’s Canvas."}):null,p&&(x!=null&&x.message)?s.jsx("p",{className:"muted",children:x.message}):null,p&&(x!=null&&x.supported)&&!S?s.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),s.jsx(Y,{title:"Who is driving",panel:!0,actions:m.length>0?s.jsx(P,{variant:"danger",size:"sm",disabled:i,onClick:()=>void w(()=>A.browserControl("stop")),children:p?"Stop computer control":"Stop all browsers"}):void 0,children:m.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nobody right now. Ask an agent to open a website or one of the allowed apps, and you will see it working on that conversation’s Canvas."}):s.jsx("div",{className:"ui-list",children:m.map(E=>s.jsxs("a",{className:"ui-list-row",href:De(E.session.agentId,E.session.conversationId),children:[s.jsx(Ps,{id:E.session.agentId,name:E.session.agentId,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:E.session.task}),s.jsxs("span",{className:"ui-list-sub",children:[E.session.agentId,", ",E.busy?"working":E.state,", ",E.session.steps," of ",E.session.maxSteps," steps"]})]}),s.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},E.session.id))})}),h?s.jsxs(s.Fragment,{children:[s.jsx(Y,{title:"How agents get a screen",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?s.jsx(Nd,{current:h.mode,value:"computer",disabled:i||j||!e.enabled,title:"Use my apps",body:"Agents work in your own windows, signed in as you, in the browser profile you choose below. One agent at a time. Releasing control leaves everything open.",onPick:()=>b({...h,mode:"computer"})}):null,s.jsx(Nd,{current:h.mode,value:"playwright",disabled:i||j||!e.enabled,title:"Give agents their own browser",body:"A separate browser profile with its own tabs, one per conversation. Your apps are never touched.",onPick:()=>b({...h,mode:"playwright"})}),s.jsx(Nd,{current:h.mode,value:"extension",disabled:i||j||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>b({...h,mode:"extension"})})]}),t?null:s.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),j?s.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,h.mode==="extension"?s.jsx(r_,{busy:i,timezone:r}):null]})}),t?s.jsx(Y,{title:"Apps agents may use",panel:!0,children:s.jsxs(q,{children:[h.mode!=="computer"?s.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,s.jsx(i_,{settings:h,disabled:i||j||!e.enabled,onChange:b,onAdd:()=>u(!0)}),s.jsx(Nt,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Agents see what is on screen in these apps, and what they see goes to the agent’s model provider. Allow only apps you want operated."}),s.jsx("p",{children:"Never type a password or a sign-in code in chat. Sign in yourself, in the app, while you have taken over."}),s.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?s.jsx(u_,{chosen:h.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),h.allowedApps.includes(E)||b({...h,allowedApps:[...h.allowedApps,E]})}}):null]}):null]})}const t_="kmbckpnnjfggeffkkbmkggojnolkdokb";async function n_(){var e;try{if(typeof chrome>"u"||!((e=chrome==null?void 0:chrome.runtime)!=null&&e.sendMessage))return null;const t=await chrome.runtime.sendMessage(t_,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function s_(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function r_({busy:e,timezone:t}){const{data:n,error:r,reload:i}=le(()=>A.extension(),[],3e3),l=Sm(),o=le(()=>n_(),[],3e3).data??null,[a,c]=d.useState(""),[u,h]=d.useState(!1),[f,p]=d.useState(null),m=(o==null?void 0:o.state)==="pairing"?o.code??"":"";d.useEffect(()=>{m&&c(m)},[m]);const j=async v=>{h(!0),p(null);try{await v()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(!1),i()}},w=e||u,b=t??Intl.DateTimeFormat().resolvedOptions().timeZone,x=s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),s.jsx(rt,{label:"The unpacked extension",children:(n==null?void 0:n.path)??"…"})]});return s.jsxs(q,{divided:!0,children:[s.jsx(ie,{message:r??f}),s.jsxs(J,{children:[s.jsx(fe,{tone:n!=null&&n.connected?"good":"warning",children:n!=null&&n.connected?"Connected":"Not connected"}),s.jsxs("span",{className:"muted",children:[n!=null&&n.connected&&n.pairedAt?`Paired with Chrome on ${l} since ${Pe(n.pairedAt,b)}`:n!=null&&n.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",n!=null&&n.extension?` · extension ${n.extension}`:""]})]}),s.jsxs(q,{children:[s.jsxs("p",{className:"muted",children:[o?`The browser you are reading this in has the extension, version ${o.version}.`:n!=null&&n.connected?"The browser you are reading this in has no buddi extension. You only need it here to pair this browser instead.":"The browser you are reading this in has no buddi extension yet.",(o==null?void 0:o.state)==="paired"?" It is already paired with a buddi.":"",(o==null?void 0:o.state)==="disconnected"?" It is not connected yet: press Connect in its popup.":""]}),o&&!s_(o.gateway)?s.jsx(G,{tone:"warning",children:`The extension is pointed at ${o.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),n!=null&&n.pending?s.jsxs(J,{valign:"end",children:[s.jsx(ee,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:s.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:a,onChange:v=>c(v.target.value)})}),s.jsx(tl,{}),s.jsx(P,{variant:"accent",disabled:w||a.replace(/[^0-9]/g,"").length!==6,onClick:()=>void j(async()=>{await A.pairExtension(a),c("")}),children:"Pair"})]}):null,n!=null&&n.connected?s.jsx(Nt,{summary:"Pair a different browser",children:x}):x,s.jsx(J,{align:"end",children:s.jsx(P,{variant:"danger",disabled:w||!(n!=null&&n.pairedAt),onClick:()=>void j(()=>A.forgetExtension()),children:"Forget this browser"})})]})}function Nd({current:e,value:t,title:n,body:r,disabled:i,onPick:l}){const o=e===t;return s.jsxs("button",{type:"button",role:"radio","aria-checked":o,className:"mode-option",disabled:i,onClick:()=>{o||l()},children:[s.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),s.jsxs("span",{className:"mode-option-text",children:[s.jsx("span",{className:"mode-option-title",children:n}),s.jsx("span",{className:"mode-option-body",children:r})]})]})}function i_({settings:e,disabled:t,onChange:n,onAdd:r}){const i=le(()=>A.installedApps(),[]),l=o=>{var a,c;return((c=(a=i.data)==null?void 0:a.apps.find(u=>u.id===o))==null?void 0:c.name)??o};return s.jsxs(s.Fragment,{children:[e.allowedApps.length===0?s.jsx(oe,{children:"No apps yet. Agents cannot touch anything until you add one."}):s.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(o=>s.jsxs("li",{className:"ui-list-row",children:[s.jsx(Ps,{id:o,name:l(o),size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[l(o),o===e.browserApp?s.jsx(fe,{tone:"accent",className:"app-role",children:"browser"}):null]}),s.jsx("span",{className:"ui-list-sub mono",children:o})]}),s.jsxs(J,{children:[o!==e.browserApp&&c_(o)?s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,browserApp:o}),children:"Use as browser"}):null,o===e.browserApp?s.jsx("span",{className:"muted",children:"In use as the browser"}):s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,allowedApps:e.allowedApps.filter(a=>a!==o)}),children:"Remove"})]})]},o))}),s.jsxs(J,{children:[s.jsx(P,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),s.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&l_.includes(e.browserApp)?s.jsx(o_,{settings:e,disabled:t,onChange:n}):null]})}const l_=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function o_({settings:e,disabled:t,onChange:n}){var o;const i=((o=le(()=>A.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:o.profiles)??[],l=e.browserProfile?i.some(a=>a.directory===e.browserProfile):!0;return s.jsx(ee,{label:"Browser profile",hint:e.browserProfile?"Websites open in this profile, signed in as it is.":"Not chosen: websites open in whichever profile’s window is in front, or the last one you used.",children:s.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:a=>{const{browserProfile:c,...u}=e;n(a.target.value?{...u,browserProfile:a.target.value}:u)},children:[s.jsx("option",{value:"",children:"Whichever is in front"}),!l&&e.browserProfile?s.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(a=>s.jsxs("option",{value:a.directory,children:[a.name,a.directory==="Default"?"":` (${a.directory})`]},a.directory))]})})}const a_=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function c_(e){return a_.includes(e)}function u_({chosen:e,onClose:t,onPick:n}){const r=le(()=>A.installedApps(),[]),[i,l]=d.useState(""),[o,a]=d.useState(""),c=d.useMemo(()=>{var f;const u=((f=r.data)==null?void 0:f.apps)??[],h=i.trim().toLowerCase();return u.filter(p=>!h||p.name.toLowerCase().includes(h)||p.id.toLowerCase().includes(h)).slice(0,60)},[r.data,i]);return s.jsxs(Wt,{title:"Add an app",onClose:t,children:[s.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>l(u.target.value)}),s.jsx(ie,{message:r.error}),r.data?c.length===0?s.jsx(oe,{children:"No app matches."}):s.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const h=e.includes(u.id);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx(Ps,{id:u.id,name:u.name,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:u.name}),s.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),s.jsx(P,{size:"sm",disabled:h,onClick:()=>n(u.id),children:h?"Allowed":"Allow"})]},u.id)})}):s.jsx(oe,{children:"Reading your Applications folder…"}),s.jsx(Nt,{summary:"Add by bundle identifier instead",children:s.jsxs(J,{children:[s.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:o,onChange:u=>a(u.target.value)}),s.jsx(P,{disabled:!o.trim(),onClick:()=>n(o.trim()),children:"Allow this identifier"})]})})]})}function d_({data:e,error:t,reload:n,compact:r=!1,refresh:i,screenshotSrc:l,onScreenshotError:o,onScreenshotLoad:a,controls:c=!0}){var T,E,U;const[u,h]=d.useState(!1),[f,p]=d.useState(null),[m,j]=d.useState(null),[w,b]=d.useState(null),x=async H=>{h(!0),p(null),b(null);try{const O=H!=="stop"&&(e!=null&&e.session)?await A.browserControl(H,e.session.id):await A.browserControl(H);H==="takeover"?O.hand&&O.session?j(O.session.id):b(O.handMessage??null):j(null)}catch(O){p(O instanceof Error?O.message:String(O))}finally{h(!1),n()}},v=m&&((T=e==null?void 0:e.session)==null?void 0:T.id)===m&&e.state==="paused"?m:null,y=!!(e!=null&&e.enabled)&&!u,g=(e==null?void 0:e.mode)==="computer",S=(e==null?void 0:e.mode)==="extension",k=g?"Stop computer control interrupts native input and revokes access. Take over pauses agent input. Release ends this conversation’s control without closing your apps. Already dispatched actions cannot be undone. Avoid using the same mouse and keyboard while the agent is working.":"Stop all browsers closes every session and revokes access until you resume. Take over, Resume and Close & release affect only the selected conversation. An in-flight action is interrupted by closing its tabs. Actions already submitted cannot be undone.",N=e!=null&&e.busy?"Working":(e==null?void 0:e.state)==="running"?"Ready":(e==null?void 0:e.state)??"Connecting",C=e!=null&&e.busy||(e==null?void 0:e.state)==="running"?"good":(e==null?void 0:e.state)==="stopped"||(e==null?void 0:e.state)==="error"?"critical":void 0;return s.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[s.jsxs("div",{className:"browser-heading",children:[s.jsxs("div",{children:[r?null:s.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),s.jsx("h2",{className:"browser-title",children:g?"Computer":S?"Your browser":"Browser"})]}),s.jsx(fe,{tone:C,children:s.jsx("span",{role:"status",children:N})})]}),r?s.jsx("a",{className:"browser-full-view",href:"#/browser",children:g?"Open computer view & settings ↗":"Open full browser view ↗"}):s.jsx("p",{className:"ui-page-lede",children:g?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":S?"Your own Chrome, signed in as you, working in background tabs grouped as “buddi”. You keep browsing.":"A real browser window, driven by your assistant. You stay in control."}),s.jsx(ie,{message:t??f}),c?s.jsxs(J,{children:[s.jsx(P,{variant:"danger",disabled:!y||(e==null?void 0:e.state)==="stopped",onClick:()=>void x("stop"),children:g?"Stop computer control":"Stop all browsers"}),s.jsx(P,{disabled:!y||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void x("takeover"),children:"Take over"}),s.jsx(P,{disabled:!y||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void x("resume"),children:"Resume access"}),s.jsx(P,{disabled:!y||!(e!=null&&e.session),onClick:()=>void x("release"),children:g?"Release control":"Close & release"})]}):null,c?r?s.jsx(Nt,{summary:"About these controls",children:s.jsx("p",{className:"muted",children:k})}):s.jsx("p",{className:"muted",children:k}):null,w?s.jsx(G,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!v?s.jsx(G,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?s.jsxs("div",{className:"browser-task",children:[s.jsxs("div",{className:"ui-row",children:[s.jsx("strong",{children:e.session.agentId}),s.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:s.jsx("p",{children:e.session.task}),s.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",new Date(e.session.expiresAt).toLocaleTimeString()]})]}):s.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?g?"No agent is driving. Ask an agent granted browser.* to open a website or an allowed native app.":"No agent is driving. Ask an agent granted browser.* to open a website.":"The host browser is unavailable. Start buddi serve on a machine with a desktop session."}),v?s.jsx(J$,{sessionId:v,csrf:Br(),onGiveBack:()=>void x("resume")}):null,s.jsxs("div",{className:"browser-window",hidden:!!v,children:[s.jsxs("div",{className:"browser-address",children:[s.jsx("span",{"aria-hidden":"true",children:"◉"}),s.jsx("span",{children:((E=e==null?void 0:e.page)==null?void 0:E.url)??(g?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?s.jsxs("figure",{children:[s.jsx("img",{src:l??`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:""}${i?`&tick=${i}`:""}`,alt:`Last browser observation: ${e.page.title||e.page.url}`,...o?{onError:o}:{},...a?{onLoad:a}:{}},l??e.page.id),s.jsxs("figcaption",{children:["Last observation · ",new Date(e.page.capturedAt).toLocaleTimeString()," · ",e.page.title||"Untitled page"]})]}):s.jsxs("div",{className:"browser-empty",children:[s.jsx("strong",{children:g?"Your selected app will appear here":"Your browser activity will appear here"}),s.jsx("p",{children:g?"Only the selected app window is captured, not the whole desktop. This preview is not interactive.":"This is a view of the host browser, not a second browser or a remote desktop."})]})]}),(((U=e==null?void 0:e.page)==null?void 0:U.tabs.length)??0)>1?s.jsx(Nt,{summary:`${e.page.tabs.length} open tabs`,children:s.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(H=>s.jsxs("li",{children:[H.title||H.id," — ",H.url]},H.id))})}):null,s.jsxs("p",{className:"muted",children:[g?"Sign in directly in the host app during takeover. Don’t send passwords or MFA codes in chat. Native apps retain your existing logins and documents. Secure accessibility fields are masked; other sensitive window content can still appear in screenshots.":"Sign in directly in this conversation’s host tab during takeover. Don’t send passwords or MFA codes in chat. Agent tabs share saved logins and cookies."," ",v?"While you are driving this is a live view of the page; nothing you type is kept.":"Screenshots update after agent actions; this is not a live video feed."]})]})}const f_=2e3,h_=5;function p_(e,t){if(!e.hasScreenshot||!e.page)return null;const n=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${n}`}function m_({status:e,error:t,reload:n,steps:r,live:i,focusedStepId:l=null}){var y;const[o,a]=d.useState(0),[c,u]=d.useState(0),h=c>=h_;d.useEffect(()=>{if(!i||h)return;const g=window.setInterval(()=>{typeof document<"u"&&document.hidden||a(S=>S+1)},f_);return()=>window.clearInterval(g)},[i,h]);const f=d.useRef(null);i&&(e!=null&&e.session)&&(f.current=e);const[p,m]=d.useState(null),j=d.useRef(null),w=((y=e==null?void 0:e.page)==null?void 0:y.id)??null;d.useEffect(()=>{const g=i&&e?p_(e):null;if(!g||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let S=!1;return(async()=>{try{const k=await fetch(g);if(!k.ok||S)return;const N=await k.blob();if(S)return;const C=URL.createObjectURL(N);j.current&&URL.revokeObjectURL(j.current),j.current=C,m(C)}catch{}})(),()=>{S=!0}},[i,w]),d.useEffect(()=>()=>{j.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(j.current)},[]);const b=f.current,x=i?e:b?p?b:{...b,hasScreenshot:!1}:e,v=r.at(-1)??null;return s.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[s.jsx(d_,{data:x,error:t,reload:n,compact:!0,controls:i,...i?{refresh:o}:{},...!i&&p?{screenshotSrc:p}:{},onScreenshotError:()=>u(g=>g+1),onScreenshotLoad:()=>u(0)}),i?h?s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"This session has ended. What is on this panel is the last thing it showed."}),s.jsx(g_,{steps:r,newestId:(v==null?void 0:v.id)??null,focusedId:l??null,live:i})]})}function g_({steps:e,newestId:t,focusedId:n,live:r}){const i=d.useRef(null);return d.useEffect(()=>{var o;if(!n||!i.current)return;const l=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(n):n}"]`);(o=l==null?void 0:l.scrollIntoView)==null||o.call(l,{block:"nearest"})},[n]),e.length===0?s.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):s.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:s.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((l,o)=>{const a=l.awaiting?"awaiting":l.ok===null?"running":l.ok?"ok":"failed";return s.jsxs("li",{"data-step":l.id,className:"wb-browser-step","data-state":a,"data-newest":l.id===t?"true":void 0,"data-focused":l.id===n?"true":void 0,children:[s.jsx("span",{className:"wb-browser-index mono",children:o+1}),s.jsxs("span",{className:"wb-browser-what",children:[s.jsx("strong",{children:l.action}),l.target?s.jsx("span",{className:"muted wb-browser-target",children:l.target}):null,l.error?s.jsx("span",{className:"wb-browser-error",children:l.error}):null]}),s.jsx("span",{className:"wb-browser-outcome","data-state":a,children:a==="awaiting"?"Awaiting approval":a==="running"?"Working":a==="ok"?"Done":"Failed"})]},l.id)})})})}function x_({agentId:e,conversationId:t}){const{data:n,error:r,reload:i}=le(()=>A.host(e,t),[e,t],2e3),[l,o]=d.useState(null),[a,c]=d.useState(!1),u=async m=>{c(!0),o(null);try{await m(),i()}catch(j){o(j instanceof Error?j.message:String(j))}finally{c(!1)}},h=(n==null?void 0:n.permissions)??[],f=(n==null?void 0:n.runs)??[],p=h.some(m=>!m.conversationId)?"Always allowed":h.length?"Conversation auto-mode":"Ask each time";return s.jsx(Nt,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":p}${f.length?` · ${f.length} running`:""}`,children:s.jsxs(q,{gap:"sm",children:[s.jsx("p",{className:"muted",children:"Commands run as your user, not in a sandbox. Auto-mode covers all commands within its scope. Stop interrupts a command; revoke also ends the permission. Neither undoes completed changes."}),s.jsx(ie,{message:l??r}),h.map(m=>s.jsxs(J,{children:[s.jsxs("span",{children:[m.agentId,": ",m.conversationId?"conversation auto-mode":"always allowed"]}),s.jsx(P,{size:"sm",disabled:a,onClick:()=>void u(()=>A.revokeHost(m.id)),children:"Revoke permission"})]},m.id)),h.length?null:s.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),f.map(m=>s.jsxs(q,{gap:"sm",children:[s.jsxs("p",{children:[m.agentId," · ",s.jsx("span",{className:"mono",children:m.cwd})]}),s.jsx(rt,{children:m.command}),s.jsx(rt,{label:"Command output",children:m.stdout||m.stderr?`${m.stdout}
100
- ${m.stderr}`:"Waiting for output…"}),s.jsx(J,{children:s.jsx(P,{size:"sm",variant:"danger",disabled:a,onClick:()=>void u(()=>A.stopHost(m.agentId,m.conversationId)),children:"Stop command"})})]},m.actionId))]})})}const ok="browser.act",v_="browser.status",Fa=new Set([ok,v_]);function j_(e,t,n){const r=e==null?void 0:e.session;return!r||!t||!n||r.agentId!==t||r.conversationId!==n?null:{id:`host-browser:${r.id}`,title:e.mode==="computer"?"Computer":"Browser",tool:"Host browser",renderer:"browser",source:"browser",pinned:!0,props:{},at:null,substantial:!1}}function y_(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function w_(e){var r;const t=[],n=new Map;for(const i of e)for(const l of i.blocks??[]){if(l.type==="tool_use"&&l.name===ok){const a={id:l.id,action:b_(l.input)??"act",target:k_(l.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(a),n.set(l.id,a);continue}if(l.type!=="tool_result")continue;const o=n.get(l.toolUseId);if(o){if(((r=l.approval)==null?void 0:r.state)==="pending"){o.awaiting=!0,o.ok=null,o.error=null;continue}o.awaiting=!1,o.ok=l.ok,o.error=l.ok?null:S_(l)}}return t}function Iv(e,t){var r;let n=!1;for(const i of e)for(const l of i.blocks??[])if(l.type==="tool_use"&&l.id===t&&(n=Fa.has(l.name)),l.type==="tool_result"&&l.toolUseId===t&&((r=l.approval)==null?void 0:r.state)==="pending")return null;return n?t:null}function b_(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function k_(e){if(e===null||typeof e!="object")return null;const t=e;for(const r of["url","appId","direction","key","tabId"]){const i=t[r];if(typeof i=="string"&&i!=="")return i}const n=t.target;if(n!==null&&typeof n=="object"){const r=n,i=r.name;if(typeof i=="string"&&i!=="")return i;const l=r.ref;if(typeof l=="string"&&l!=="")return l;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function S_(e){for(const t of[e.error,e.output]){if(typeof t=="string"&&t.trim()!=="")return t.trim();if(t!==null&&typeof t=="object")for(const n of["message","error","reason"]){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function N_({agentId:e,groupId:t,currentId:n,timezone:r,onSelect:i,onNew:l}){const[o,a]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(0);return d.useEffect(()=>{let p=!1;return a(null),u(null),(t?_e.groupConversations(t):_e.conversations(e,100)).then(m=>{p||a(m.conversations)}).catch(m=>{p||u(m instanceof Error?m.message:String(m))}),()=>{p=!0}},[e,t,h]),s.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[s.jsxs("div",{className:"ui-toolbar",children:[s.jsx("strong",{children:"Past conversations"}),s.jsx("button",{className:"ui-btn",onClick:l,children:"New conversation"})]}),c?s.jsxs("p",{role:"alert",children:[c," ",s.jsx("button",{className:"ui-btn",onClick:()=>f(p=>p+1),children:"Retry"})]}):o===null?s.jsx("p",{className:"muted",children:"Loading conversations…"}):o.length===0?s.jsx("p",{className:"muted",children:"No conversations yet."}):s.jsx("ul",{children:o.map(p=>s.jsx("li",{children:s.jsxs("a",{href:t?Ml(t,p.id):De(e,p.id),"aria-current":p.id===n?"page":void 0,onClick:m=>{m.button===0&&!m.metaKey&&!m.ctrlKey&&!m.shiftKey&&!m.altKey&&(m.preventDefault(),i(p.id))},children:[s.jsx("span",{children:p.preview||p.opening||"Untitled conversation"}),s.jsxs("small",{children:[Pe(p.lastMessageAt??p.startedAt??p.createdAt??null,r)," · ",p.messageCount," messages",p.id===n?" · Current":""]})]})},p.id))}),s.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(o==null?void 0:o.length)===100?s.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const ak="buddi.dismissedTabs";function C_(){try{const e=JSON.parse(sessionStorage.getItem(ak)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(n=>typeof n=="string")))}catch{return{}}}function Mv(e){try{sessionStorage.setItem(ak,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const $v="Send files once the agent has answered.",E_=d.forwardRef(function({disabled:t,running:n,onSend:r,onStop:i,agentName:l,draft:o,model:a,setupHref:c,thinking:u,onThinking:h,onOpenFile:f,mentions:p,history:m,threadKey:j},w){var mn;const b=j?`buddi.draft.${j}`:null,x=D=>{if(!D)return"";try{return window.localStorage.getItem(D)??""}catch{return""}},[v,y]=d.useState(()=>x(b)),[g,S]=d.useState([]),[k,N]=d.useState(!1),C=d.useRef(null),T=d.useRef(null),[E,U]=d.useState(null),[H,O]=d.useState(0),R=E&&p?p.filter(D=>D.handle.toLowerCase().startsWith(E.query.toLowerCase())||D.name.toLowerCase().startsWith(E.query.toLowerCase())).slice(0,6):[],F=(D,he)=>{if(!p||p.length===0){U(null);return}const it=D.slice(0,he),_t=/(^|\s)@([\w-]*)$/.exec(it);if(!_t){U(null);return}U({start:he-_t[2].length-1,query:_t[2]}),O(0)},K=D=>{if(!E)return;const he=T.current,it=he?he.selectionStart:v.length,_t=`${v.slice(0,E.start)}@${D} ${v.slice(it)}`;y(_t),M<0&&ne(_t),U(null),window.requestAnimationFrame(()=>{if(!he)return;const gn=E.start+D.length+2;he.focus(),he.setSelectionRange(gn,gn),vt()})},L=m??[],[M,V]=d.useState(-1),$=d.useRef(v),_=d.useRef(b);if(_.current!==b){_.current=b;const D=x(b);$.current=D,D!==v&&(y(D),V(-1),U(null))}const ne=D=>{if($.current=D,!!b)try{D===""?window.localStorage.removeItem(b):window.localStorage.setItem(b,D)}catch{}},X=D=>{y(D),U(null);const he=T.current;he&&(he.value=D,he.setSelectionRange(D.length,D.length)),window.requestAnimationFrame(vt)},ue=D=>!D.value.slice(0,D.selectionStart??D.value.length).includes(`
101
- `),ye=()=>v===""||M>=0&&v===L[M],Ne=()=>{M<0||(V(-1),X($.current))},ce=g.some(D=>D.state==="uploading"),we=g.length>0,B=n&&we,te=!t&&!ce&&!B&&v.trim()!=="",ge=D=>{for(const he of Array.from(D??[])){const it=`${he.name}:${he.size}:${Math.random().toString(36).slice(2,8)}`,_t=he.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(he):null;S(gn=>[...gn,{key:it,filename:he.name||"Pasted image",mime:he.type||"application/octet-stream",sizeBytes:he.size,thumbnail:_t,state:"uploading"}]),_e.attach(he).then(gn=>S(Vn=>Vn.map(An=>An.key===it?{...An,state:"ready",uploaded:gn}:An))).catch(gn=>S(Vn=>Vn.map(An=>An.key===it?{...An,state:"failed",error:gn instanceof pe?gn.message:String(gn)}:An)))}},Ee=D=>{D.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(D.thumbnail)},Ve=D=>{const he=g.find(it=>it.key===D);he&&(Ee(he),he.state==="ready"&&he.uploaded&&_e.discardAttachment(he.uploaded.artifactId).catch(()=>{})),S(it=>it.filter(_t=>_t.key!==D))};d.useImperativeHandle(w,()=>({addFiles:D=>{var he;ge(D),(he=T.current)==null||he.focus()},focus:()=>{var D;return(D=T.current)==null?void 0:D.focus()}}));const ve=d.useRef(g);ve.current=g,d.useEffect(()=>()=>ve.current.forEach(Ee),[]);const ct=d.useRef(0);d.useEffect(()=>{if(!o||o.at===ct.current)return;ct.current=o.at,y(he=>he.trim()===""?o.text:he),M<0&&v.trim()===""&&ne(o.text);const D=T.current;D&&(D.focus(),window.requestAnimationFrame(()=>{D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,200)}px`,D.setSelectionRange(D.value.length,D.value.length)}))},[o]);const vt=()=>{const D=T.current;D&&(D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,200)}px`)},Fe=()=>{if(!te)return;const D=g.filter(he=>he.state==="ready"&&he.uploaded).map(he=>he.uploaded);r(v.trim(),D),g.forEach(Ee),V(-1),ne(""),y(""),S([]),window.requestAnimationFrame(vt)},cs=D=>{if(E&&R.length>0){if(D.key==="ArrowDown"){D.preventDefault(),O(he=>(he+1)%R.length);return}if(D.key==="ArrowUp"){D.preventDefault(),O(he=>(he-1+R.length)%R.length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault(),K(R[H].handle);return}if(D.key==="Escape"){D.preventDefault(),U(null);return}}if(D.key==="ArrowUp"&&!D.shiftKey&&!D.altKey&&!D.metaKey&&!D.ctrlKey){const he=D.currentTarget;if(L.length>0&&M+1<L.length&&ue(he)&&ye()){D.preventDefault(),M<0&&($.current=v),V(M+1),X(L[M+1]);return}}if(D.key==="ArrowDown"&&!D.shiftKey&&!D.altKey&&!D.metaKey&&!D.ctrlKey&&M>=0&&v===L[M]){if(D.preventDefault(),M===0){Ne();return}V(M-1),X(L[M-1]);return}if(D.key==="Escape"&&M>=0){D.preventDefault(),Ne();return}D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Fe())},pn=D=>{var it;const he=Array.from(((it=D.clipboardData)==null?void 0:it.files)??[]);he.length!==0&&(D.preventDefault(),ge(he))},Wn=g.filter(D=>D.state==="failed"),tn=Wn.length;return s.jsx("div",{className:"wb-composer","data-testid":"composer",children:s.jsxs("div",{className:"wb-composer-box","data-focused":k,"data-disabled":t,children:[g.length>0?s.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:g.map(D=>s.jsx("span",{role:"listitem",children:s.jsx(ek,{name:D.filename,mime:D.mime,sizeBytes:D.sizeBytes,thumbnail:D.thumbnail,state:D.state,error:D.error,onRemove:()=>Ve(D.key),...f&&D.state==="ready"&&D.uploaded?{onOpen:()=>f(A_(D.uploaded))}:{},size:"sm"})},D.key))}):null,s.jsxs("label",{className:"sr-only",htmlFor:"wb-composer-input",children:["Message ",l]}),s.jsx("textarea",{id:"wb-composer-input",ref:T,value:v,rows:2,placeholder:n?`${l} is working…`:`Message ${l}`,onChange:D=>{y(D.target.value),M<0&&ne(D.target.value),F(D.target.value,D.target.selectionStart??D.target.value.length),vt()},onFocus:()=>N(!0),onBlur:()=>N(!1),onKeyDown:cs,onPaste:pn,disabled:t}),E&&R.length>0?s.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:R.map((D,he)=>s.jsxs("button",{type:"button",role:"option","aria-selected":he===H,className:"wb-mention","data-active":he===H||void 0,onMouseDown:it=>{it.preventDefault(),K(D.handle)},children:[s.jsxs("span",{className:"wb-mention-handle",children:["@",D.handle]}),s.jsx("span",{className:"wb-mention-name",children:D.name})]},D.handle))}):null,s.jsxs("div",{className:"wb-composer-row",children:[s.jsx("input",{ref:C,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:D=>{ge(D.target.files),D.target.value=""}}),s.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Attach a file",title:"Attach a file — or paste one, or drop it anywhere on the chat",onClick:()=>{var D;return(D=C.current)==null?void 0:D.click()},disabled:t,children:s.jsx(Oe,{name:"clip"})}),a?c?s.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):s.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):null,h?s.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":ua(u),disabled:t||n,title:n?`Wait for ${l} to finish — this run started with thinking ${ua(u)?"on":"off"}`:ua(u)?"Reasoning before the answer is on. Click to turn it off — answers come back faster.":"Reasoning before the answer is off. Click to turn it on.",onClick:()=>h(ua(u)?"off":"on"),children:[s.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,s.jsx("span",{className:"wb-hint","data-shown":v!==""&&!n||tn>0||B,"data-tone":tn>0?"critical":void 0,children:tn>0?tn===1&&((mn=Wn[0])!=null&&mn.error)?Wn[0].error:`${tn} files failed to upload and will not be sent`:B?$v:"Enter sends, Shift+Enter for a new line"}),n?s.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,s.jsx("button",{className:"wb-send","aria-label":"Send",title:B?$v:ce?"Waiting for the upload to finish":n?`Send — ${l} picks it up between steps`:"Send",onClick:Fe,disabled:!te,children:s.jsx(Oe,{name:"send"})})]})]})})});function ua(e){return(e??"on")==="on"}function A_(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function R_({question:e,disabled:t,onAnswer:n,onSkip:r}){const[i,l]=d.useState("");return d.useEffect(()=>{if(t)return;const o=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),r())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,r]),s.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),s.jsx(P,{className:"wb-question-skip",variant:"ghost",size:"sm",disabled:t,onClick:r,title:"Skip this question (Esc). The agent carries on without an answer.",children:"Skip"}),s.jsx("strong",{children:e.question})]}),e.options.length>0?s.jsx("div",{className:"wb-question-options",children:e.options.map((o,a)=>s.jsxs("button",{className:"wb-question-option","data-recommended":o.recommended||void 0,disabled:t,onClick:()=>n(o.label,o.id),children:[s.jsx("span",{className:"wb-question-number",children:a+1}),s.jsxs("span",{children:[s.jsxs("span",{className:"wb-question-label",children:[o.label,o.recommended?s.jsx("em",{children:"Recommended"}):null]}),o.hint?s.jsx("small",{children:o.hint}):null]})]},o.id))}):null,e.allowOther?s.jsxs("form",{className:"wb-question-other",onSubmit:o=>{o.preventDefault(),i.trim()&&n(i.trim())},children:[s.jsx("input",{value:i,onChange:o=>l(o.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),s.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,s.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function T_(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function P_(e){const t=e/36e5;if(t>=1&&Number.isInteger(t))return`${t} hour${t===1?"":"s"}`;const n=Math.round(e/6e4);return`${n} minute${n===1?"":"s"}`}function I_(e){const{lifetime:t,startedAt:n,now:r,timezone:i}=e;if(!t||t.messages<=0)return{text:"New conversation",title:"Nothing has been said in this one yet.",tone:"quiet"};const l=`A conversation ends after ${P_(t.idleTimeoutMs)} idle, or once its transcript grows past ${Math.round(t.maxChars/1e3)}k characters. What the agent remembers about you carries over.`,o=`${t.messages} message${t.messages===1?"":"s"}`;if(T_(t,r))return{text:`${o} · your next message starts a fresh one`,title:l,tone:"note"};const a=n?Se(n,r):"";return{text:a===""?o:`${o} · started ${a}`,title:n?`Started ${Pe(n,i)}. ${l}`:l,tone:"quiet"}}const Ua=320,ck="buddi.chatWidth";function M_({timezone:e,agents:t,agentId:n,defaultAgentId:r=null,group:i=null,onEditGroup:l,onSelectAgent:o,attention:a,agentsInHeader:c,narrow:u,canvasOpen:h,onOpenCanvas:f,onCloseCanvas:p,newConversationSignal:m,requestedConversationId:j,requestedTab:w,onConversationOpened:b}){var ag,cg,ug,dg,fg,hg;const x=Sm(),[v,y]=d.useState([]),[g,S]=d.useState(null),[k,N]=d.useState(null),[C,T]=d.useState(null),[E,U]=d.useState([]),[H,O]=d.useState([]),[R,F]=d.useState(null),[K,L]=d.useState(!1),[M,V]=d.useState(new Map),[$,_]=d.useState(null),[ne,X]=d.useState(C_),[ue,ye]=d.useState([]),[Ne,ce]=d.useState(!1),we=d.useRef(0),B=d.useRef(null),[te,ge]=d.useState(!1),Ee=d.useRef(m??0),Ve=d.useRef(n),ve=d.useRef({agentId:n,conversationId:g});ve.current={agentId:n,conversationId:g};const ct=ne[g??""]??[],[vt,Fe]=d.useState(null),[cs,pn]=d.useState(null),[Wn,tn]=d.useState(null),[mn,D]=d.useState([]),[he,it]=d.useState(!1),[_t,gn]=d.useState(()=>Date.now()),[Vn,An]=d.useState($_),Bm=d.useRef(null),[hr,ko]=d.useState(null),[VS,zm]=d.useState(!1),[HS,xu]=d.useState(null),[KS,GS]=d.useState(null),[YS,Wm]=d.useState(null);d.useEffect(()=>{if(!n)return;const I=L_(n);I&&xu({text:I,at:Date.now()})},[n]);const pr=i?`group:${i.id}`:n??null,xn=[...t.top,...t.middle,...t.bottom],de=xn.find(I=>I.id===n)??null,Kr=i?i.members.map(I=>xn.find(W=>W.id===I)).filter(I=>!!I):[],[vu,Vm]=d.useState(null);d.useEffect(()=>{let I=!1;return _e.views().then(W=>{I||y(W.views??[])}).catch(()=>{}),()=>{I=!0}},[]),d.useEffect(()=>{if(!n)return;const I=Ve.current===n;if(Ve.current=n,I&&j&&j===ve.current.conversationId)return;let W=!1;return S(null),N(null),T(null),U([]),Fe(null),L(!1),_(null),ye([]),No(null),ge(!1),ko(null),j?(j!=="new"?S(j):T(pr),()=>{W=!0}):((i?_e.groupConversations(i.id):_e.conversations(n)).then(Z=>{if(W)return;const xe=[...Z.conversations??[]].sort(__)[0];xe?(S(xe.id),b==null||b(n,xe.id)):T(pr)}).catch(()=>{W||T(pr)}),()=>{W=!0})},[n,i==null?void 0:i.id,pr,j,b]);const Hn=d.useCallback(I=>_e.conversation(I).then(W=>{if(ve.current.conversationId===I){if(W.agentId!==ve.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(W),U(Z=>Z.filter(xe=>!Cd(W,xe)))}}).catch(W=>{ve.current.conversationId===I&&Fe(Os(W))}),[]);d.useEffect(()=>{if(!g)return;let I=!1;return V(new Map),O([]),_e.conversation(g).then(W=>{if(!I){if(W.agentId!==n)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(W),U(Z=>Z.filter(xe=>!Cd(W,xe)))}}).catch(W=>{I||Fe(Os(W))}),()=>{I=!0}},[g,n]),d.useEffect(()=>{if(!g)return;let I=!1;const W=window.setInterval(()=>{_e.conversation(g).then(Z=>{I||Z.agentId!==ve.current.agentId||(N(Z),U(xe=>xe.filter(Ce=>!Cd(Z,Ce))))}).catch(()=>{})},3e3);return()=>{I=!0,window.clearInterval(W)}},[g,n]),d.useEffect(()=>{if(!g)return;const I=j0({url:_e.streamUrl(g),onEvent:W=>{switch(W.name){case"run.started":L(!0),F(null),Vm(jt(W.data.agentId));break;case"live":{const Z=jt(W.data.runId)??"",xe=Number(W.data.turn??0),Ce=W.data.kind==="thinking"?"thinking":"text",Me=jt(W.data.text)??"",us=Date.now();F($s=>{const Qr=$s&&$s.runId===Z&&$s.turn===xe?$s:{runId:Z,turn:xe,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return Ce==="thinking"?{...Qr,thinking:Qr.thinking+Me,thinkingStartedAt:Qr.thinkingStartedAt??us}:{...Qr,text:Qr.text+Me,textStartedAt:Qr.textStartedAt??us}});break}case"live.snapshot":{const Z=jt(W.data.runId)??"",xe=Number(W.data.turn??0),Ce=jt(W.data.text)??"",Me=jt(W.data.thinking)??"",us=Number(W.data.startedAt??Date.now());F({runId:Z,turn:xe,text:Ce,thinking:Me,thinkingStartedAt:Me?us:null,textStartedAt:Ce?us:null,settled:!1});break}case"live.settle":{const Z=jt(W.data.runId)??"",xe=Number(W.data.turn??0);F(Ce=>Ce&&Ce.runId===Z&&Ce.turn===xe?{...Ce,settled:!0}:Ce);break}case"tool.called":{const Z=jt(W.data.toolUseId)??jt(W.data.id),xe=jt(W.data.name)??jt(W.data.tool)??"tool";Z&&O(Ce=>[...Ce.filter(Me=>Me.toolUseId!==Z),{toolUseId:Z,name:xe,startedAt:Date.now()}]);break}case"tool.result":{const Z=jt(W.data.toolUseId)??jt(W.data.id);Z&&O(xe=>xe.filter(Ce=>Ce.toolUseId!==Z)),Hn(g);break}case"message.appended":Hn(g).then(()=>{F(Z=>Z!=null&&Z.settled?null:Z)});break;case"awaiting-approval":{const Z=jt(W.data.approvalId)??jt(W.data.actionId),xe=jt(W.data.toolUseId);Z&&xe&&V(Ce=>new Map(Ce).set(xe,Z)),O(Ce=>Ce.filter(Me=>Me.toolUseId!==xe)),Hn(g);break}case"run.finished":{L(!1),O([]),F(null),Vm(null);const Z=jt(W.data.message);Fe(Z??null),Hn(g);break}}}});return()=>I.close()},[g,Hn]),d.useEffect(()=>{const I=window.setInterval(()=>gn(Date.now()),H.length===0?6e4:1e3);return()=>window.clearInterval(I)},[H.length]);const So=le(()=>n&&g?A.browser({agentId:n,conversationId:g}):Promise.resolve(void 0),[n,g],1500),Gr=So.error?void 0:So.data,rl=Gr!=null&&Gr.session&&Gr.session.agentId===n&&Gr.session.conversationId===g?Gr:void 0,mr=j_(rl,n,g),gr=(mr==null?void 0:mr.id)??null,[il,qS]=d.useState(null),Hm=rl==null?void 0:rl.mode;d.useEffect(()=>{mr&&n&&g&&qS({agentId:n,conversationId:g,tab:y_(mr,Hm)})},[gr,Hm,n,g]);const QS=il&&il.agentId===n&&il.conversationId===g&&!ct.includes(il.tab.id)?il.tab:null,Ct=mr??QS,JS=d.useMemo(()=>w_((k==null?void 0:k.messages)??[]),[k]),[XS,No]=d.useState(null),ZS=d.useMemo(()=>IM({messages:(k==null?void 0:k.messages)??[],descriptors:v}),[k,v]),Yr=D$(ZS,g??null),ju=F$(i?null:n),Km=d.useMemo(()=>L$((k==null?void 0:k.messages)??[]),[k]),nn=d.useMemo(()=>{const W=MM({messages:(k==null?void 0:k.messages)??[],descriptors:v,awaiting:M,served:Yr.served,...Ct?{folded:Fa}:{}}).filter(Z=>Z.source==="approval"||!ct.includes(Z.id));if($&&!ct.includes($)&&!W.some(Z=>Z.id===$)){const Z=DM((k==null?void 0:k.messages)??[],$,{redactInputOf:Fa});Z&&!Fa.has(Z.tool)&&W.push(Z)}Ct&&W.push(Ct);for(const Z of ue)W.push(w2(Z));return ju&&W.unshift(U$(ju,Km)),hr?[...W,B$(hr)]:W},[k,v,M,hr,gr,Ct==null?void 0:Ct.title,$,ne,g,ue,Yr.served,ju,Km]),e1=d.useMemo(()=>{var W;const I=[];for(const Z of(k==null?void 0:k.messages)??[]){if(Z.role!=="user"||Z.speaker&&Z.speaker!=="owner")continue;const xe=(W=Z.blocks.find(Ce=>Ce.type==="text"))==null?void 0:W.text.trim();xe&&I.unshift(xe)}return I},[k]),yu=d.useMemo(()=>nn.filter(I=>I.source==="approval"),[nn]),Co=yu.at(-1)??null,Eo=d.useMemo(()=>[...yu.map(I=>({approvalId:I.props.approvalId,toolUseId:I.id})),...((k==null?void 0:k.delegatedApprovals)??[]).map(I=>({approvalId:I.approvalId,toolUseId:I.toolUseId??"",askedBy:z_(I.chain,xn)}))],[yu,k==null?void 0:k.delegatedApprovals]),ll=d.useMemo(()=>{for(let I=nn.length-1;I>=0;I-=1){const W=nn[I];if(W!=null&&W.substantial)return W.id}return null},[nn]),Ao=d.useRef(null),wu=((ag=nn.filter(I=>(I.source!=="browser"||I.pinned===!0)&&I.id!==gh).at(-1))==null?void 0:ag.id)??((cg=nn.filter(I=>I.id!==gh).at(-1))==null?void 0:cg.id)??null;d.useEffect(()=>{if(ll&&ll!==Ao.current){Ao.current=ll,_(ll);return}$===null&&wu&&_(wu)},[ll,$,wu]);const Gm=d.useRef(Yr.live);d.useEffect(()=>{const I=Gm.current;Gm.current=Yr.live;const W=[...Yr.live].filter(Ce=>!I.has(Ce));if(W.length===0||Co||$!==null&&$!==Ao.current)return;const xe=[...nn].reverse().find(Ce=>Ce.source==="descriptor"&&Ce.renderer==="preview"&&Ce.props.target!==null&&W.includes(Ni(Ce.props.target)));xe&&_(xe.id)},[Yr.live,nn,Co,$]);const Ym=d.useRef(null);d.useEffect(()=>{gr!==Ym.current&&(Ym.current=gr,gr&&!Co&&_(gr))},[gr,Co]);const qm=d.useRef(null),ol=w==="browser"?(Ct==null?void 0:Ct.id)??null:null;d.useEffect(()=>{!ol||qm.current===ol||(qm.current=ol,_(ol))},[ol]);const bu=(Ct==null?void 0:Ct.id)??null;d.useEffect(()=>{!bu||!$||Iv((k==null?void 0:k.messages)??[],$)!==null&&(No($),_(bu))},[bu,$,k]);const Qm=I=>{ye(W=>W.some(Z=>Z.artifactId===I.artifactId)?W:[...W,I]),_(La(I.artifactId)),u&&(f==null||f())},Ro=!i&&de&&!de.available?S0(de):null,Jm=eh(i?null:de),Xm=((k==null?void 0:k.offers)??[]).filter(I=>!mn.includes(I.id)&&Date.parse(I.expiresAt)>_t),t1=de&&YS===de.id?KS:(de==null?void 0:de.thinking)??null,n1=I=>{if(!de)return;const W=de.id;Wm(W),GS(I),A.setAgentEngine(W,{thinking:I}).catch(Z=>{Wm(null),Fe(Z instanceof pe?Z.message:String(Z))})},Zm=(I,W)=>{if(!n)return;const Z=W.map(Me=>Me.artifactId),xe=K,Ce={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:I},...W.map(Me=>({type:"attachment",artifactId:Me.artifactId,filename:Me.filename,mime:Me.mime,kind:Me.kind,sizeBytes:Me.sizeBytes}))],...xe?{speaker:tk}:{}};U(Me=>xe?[...Me,Ce]:[Ce]),Fe(null),pn(null),L(!0),(i?_e.sendToGroup(i.id,{...g?{conversationId:g}:{},text:I,attachmentIds:Z}):_e.send(n,{...g?{conversationId:g}:{},text:I,attachmentIds:Z})).then(async Me=>{ve.current.agentId!==n||ve.current.conversationId!==g||(pn(Me.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),Me.conversationId!==g?(N(null),S(Me.conversationId)):await Hn(Me.conversationId),Me.queued===!0&&U(us=>us.filter($s=>$s.id!==Ce.id)),b==null||b(n,Me.conversationId))}).catch(Me=>{U(us=>us.filter($s=>$s.id!==Ce.id)),Fe(Os(Me)),L(!1)})},s1=I=>{Fe(null),tn(I),D(W=>[...W,I]),A.takeOffer(I,g??void 0).then(W=>{W.runId&&(pn(null),L(!0)),g&&Hn(g)}).catch(W=>{D(Z=>Z.filter(xe=>xe!==I)),Fe(Os(W)),g&&Hn(g)}).finally(()=>tn(null))},r1=(I,W)=>eg({answer:I,...W?{optionId:W}:{}}),i1=()=>eg({answer:"",skipped:!0}),eg=I=>{const W=k==null?void 0:k.question;W&&(Fe(null),it(!0),L(!0),_e.answerQuestion(W.id,I).then(()=>{if(g)return Hn(g)}).catch(Z=>{Fe(Os(Z)),L(!1)}).finally(()=>it(!1)))},l1=()=>{if(n){if(hr){ko(null);return}zm(!0),A.agentProfile(n).then(I=>{ko(I),_(xh(I.id)),u&&(f==null||f())}).catch(I=>Fe(Os(I))).finally(()=>zm(!1))}},o1=I=>{xu({text:I.prompt,at:Date.now()}),o(I.agentId),u&&(p==null||p())},a1=()=>{g&&_e.cancel(g).catch(I=>Fe(Os(I))).finally(()=>{L(!1),O([])})},To=d.useCallback(()=>{if(S(null),N(null),U([]),L(!1),Fe(null),pn(null),O([]),V(new Map),_(null),ye([]),No(null),Ao.current=null,i){_e.startGroupConversation(i.id).then(({conversationId:I})=>{S(I),n&&(b==null||b(n,I))}).catch(I=>Fe(Os(I)));return}T(pr),n&&(b==null||b(n,"new"))},[n,i,pr,b]);d.useEffect(()=>{m&&m!==Ee.current&&(Ee.current=m,To())},[m,To]);const tg=I=>{g&&Hn(g),A.overview().catch(()=>{}),I.state!=="pending"&&V(W=>new Map([...W].filter(([,Z])=>Z!==I.id)))},Po=d.useRef(!1);d.useEffect(()=>{const I=Z=>{if(!Po.current)return;const xe=Math.max(Ua,Math.min(720,Z.clientX-52));An(xe)},W=()=>{if(Po.current){Po.current=!1;try{Vn!==null&&window.localStorage.setItem(ck,String(Vn))}catch{}}};return window.addEventListener("pointermove",I),window.addEventListener("pointerup",W),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",W)}},[Vn]);const c1=((ug=xn.find(I=>I.id===r))==null?void 0:ug.name)??null,ng=i?[]:bI(de,c1),sg=!(k&&k.conversationId===g)&&!(!g&&C!==null&&C===pr),rg=sg?s.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&de?s.jsx(p2,{quiet:!0,still:!0,className:"wb-chat-field",children:s.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[s.jsx(bn,{agents:xn,id:de.id,size:"xl"}),s.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${de.name}.`}),s.jsx("p",{className:"wb-chat-intro",children:kI(de)}),ng.length>0?s.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${de.name}`,children:ng.map(I=>s.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var W;xu({text:I,at:Date.now()}),(W=B.current)==null||W.focus()},children:I},I))}):null]})}):null,ig=s.jsx(N$,{renderables:nn,activeId:$,onActivate:_,onClose:I=>{hr&&I===xh(hr.id)?ko(null):ue.some(W=>La(W.artifactId)===I)?ye(W=>W.filter(Z=>La(Z.artifactId)!==I)):g&&X(W=>{const Z={...W,[g]:[...new Set([...W[g]??[],I])]};return Mv(Z),Z}),$===I&&_(null)},timezone:e,onDecided:tg,onChangeAgent:o1,agents:xn,browserPanel:Ct?s.jsx(m_,{status:rl,error:So.error,reload:So.reload,steps:JS,live:mr!==null,focusedStepId:XS},Ct.id):null,descriptors:v,grantedTools:i?Kr.flatMap(I=>I.tools??[]):(de==null?void 0:de.tools)??[],...de?{agentName:de.name}:{},loading:sg,...!i&&de?{face:s.jsx(bn,{agents:xn,id:de.id,size:"xl"})}:{}}),lg=(fg=(dg=[...(k==null?void 0:k.messages)??[],...E].find(I=>I.role==="user"))==null?void 0:dg.blocks.find(I=>I.type==="text"))==null?void 0:fg.text.trim(),og=lg?lg.split(`
102
- `)[0]:"New conversation",qr=I_({lifetime:(k==null?void 0:k.lifetime)??null,startedAt:(k==null?void 0:k.startedAt)??null,now:_t,timezone:e});return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"wb-chat",ref:Bm,style:u||Vn===null?void 0:{width:Vn},"data-sized":!u&&Vn!==null?"true":void 0,"data-testid":"chat-column","data-dropping":Ne||void 0,onDragEnter:I=>{da(I)&&(I.preventDefault(),we.current+=1,ce(!0))},onDragOver:I=>{da(I)&&(I.preventDefault(),I.dataTransfer.dropEffect="copy")},onDragLeave:I=>{da(I)&&(we.current=Math.max(0,we.current-1),we.current===0&&ce(!1))},onDrop:I=>{var W;da(I)&&(I.preventDefault(),we.current=0,ce(!1),n&&((W=B.current)==null||W.addFiles(I.dataTransfer.files)))},children:[Ne?s.jsx("div",{className:"wb-drop","aria-hidden":"true",children:s.jsxs("div",{className:"wb-drop-card",children:[s.jsx(O_,{}),s.jsx("strong",{children:"Drop to attach"}),s.jsx("span",{children:de?`It goes with your next message to ${de.name}`:"Pick an agent first"})]})}):null,s.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&de?vo(xo(de)):{},children:[s.jsxs("div",{className:"wb-head-row",children:[i?s.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:Kr.slice(0,3).map(I=>s.jsx(bn,{agents:xn,id:I.id,size:"sm"},I.id))}):de?s.jsx("a",{className:"wb-head-face",href:It(de.id),"aria-label":`${de.name}'s page`,children:s.jsx(bn,{agents:xn,id:de.id})}):null,s.jsxs("div",{className:"wb-head-text",children:[i?s.jsx("span",{className:"wb-head-title",children:i.name}):s.jsx("span",{className:"wb-head-title",title:og,children:og}),s.jsx("span",{className:"wb-head-meta","data-tone":qr.tone,title:i?`${Kr.map(I=>I.name).join(", ")}. Coordinator: ${(de==null?void 0:de.name)??i.coordinator}.`:qr.title,children:i?`${Kr.map(I=>I.name).join(", ")} · ${qr.text}`:de?s.jsxs(s.Fragment,{children:[s.jsx("a",{className:"wb-head-name",href:It(de.id),title:`${de.name}'s page`,children:de.name})," ",s.jsxs("span",{className:"wb-head-handle",children:["@",de.handle]}),` · ${qr.tone==="quiet"&&qr.text==="New conversation"?`on ${x}`:qr.text}`]}):"No agent"})]}),s.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!n,onClick:()=>{ge(!1),To()},children:s.jsx(Oe,{name:"plus",size:16})}),s.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":te,"data-open":te?"true":void 0,disabled:!n,onClick:()=>ge(I=>!I),children:s.jsx(F_,{})}),u?s.jsxs("button",{className:"ui-btn",onClick:f,disabled:nn.length===0,children:["Canvas",nn.length>0?` (${nn.length})`:""]}):null,s.jsx(B_,{disabled:!n,items:i?[...Kr.map(I=>({label:I.name,hint:I.id===i.coordinator?"Coordinator · open page":"Member · open page",href:It(I.id)})),...l?[{label:"Members…",hint:"Name, coordinator, who is in the room",testId:"group-members",onSelect:l}]:[]]:[{label:hr?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:VS,onSelect:l1},...de?[{label:"Set up",hint:"Account, model, tools and skills",href:It(de.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:It(de.id)}]:[]]})]}),c?s.jsx(C0,{agents:t,currentId:n,attention:a,onSelect:o,orientation:"horizontal"}):null]}),te&&n?s.jsx(N_,{agentId:n,...i?{groupId:i.id}:{},currentId:g,timezone:e,onNew:()=>{ge(!1),To()},onSelect:I=>{if(I===g){ge(!1);return}ge(!1),N(null),U([]),L(!1),_(null),Fe(null),pn(null),ye([]),S(I),b==null||b(n,I,!1)}}):null,n&&g?s.jsx(x_,{agentId:n,conversationId:g},`${n}:${g}`):null,vt?s.jsx("div",{className:"wb-chat-notice",children:s.jsx(ie,{message:vt})}):null,cs?s.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:cs}):null,k!=null&&k.carriedOver?s.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:k.carriedOver}):null,s.jsx(nk,{messages:[...(k==null?void 0:k.messages)??[],...E],live:H,now:_t,working:K,partial:R,agents:xn,...k!=null&&k.runs?{runs:k.runs}:{},...i?{speakers:xn,coordinatorId:i.coordinator}:{},...vu?{workingAs:((hg=xn.find(I=>I.id===vu))==null?void 0:hg.name)??vu}:{},onOpenFile:Qm,onOpen:I=>{if(Ct){const W=Iv([...(k==null?void 0:k.messages)??[],...E],I);if(W){No(W),_(Ct.id),u&&(f==null||f());return}}g&&X(W=>{const Z={...W,[g]:(W[g]??[]).filter(xe=>xe!==I)};return Mv(Z),Z}),_(I),u&&(f==null||f())},...de?{agentName:de.name}:{},...rg?{empty:rg}:{},emptyHint:de?`Nothing here yet. Ask ${de.name} for something.`:"Loading agents…"}),Xm.length>0?s.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:Xm.map(I=>s.jsx("button",{className:"ui-btn",disabled:Wn!==null,title:I.prompt,onClick:()=>s1(I.id),children:I.label},I.id))}):null,Ro?s.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:s.jsxs(G,{tone:"warning",role:"status",children:[Ro," ",s.jsx("a",{href:ht(Jm.section),children:Jm.label})]})}):Eo.length>0?s.jsx(l$,{approvals:Eo,timezone:e,now:_t,version:k,onDecided:tg,onSay:I=>Zm(I,[]),onOpenFull:I=>{_(I),u&&(f==null||f())}}):null,Ro||Eo.length>0?null:k!=null&&k.question?s.jsx(R_,{question:k.question,disabled:he||K,onAnswer:r1,onSkip:i1},k.question.id):null,Ro?null:s.jsx("div",{hidden:Eo.length>0||!!(k!=null&&k.question),"data-testid":"composer-slot",children:s.jsx(E_,{ref:B,disabled:!n,running:K,onSend:Zm,onStop:a1,agentName:i?i.name:(de==null?void 0:de.name)??"the agent",draft:HS,history:e1,threadKey:g??(i?`group:${i.id}`:n),model:i?null:(de==null?void 0:de.model)??null,setupHref:i?null:de?It(de.id,"setup"):null,thinking:t1,...!i&&de?{onThinking:n1}:{},...i?{mentions:Kr.map(I=>({handle:I.handle,name:I.name}))}:{},onOpenFile:Qm})})]}),u?h?s.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[s.jsxs("div",{className:"wb-sheet-head",children:[s.jsx("strong",{children:"Canvas"}),s.jsx("button",{className:"ui-btn",onClick:p,children:"Close"})]}),ig]}):null:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:I=>{var W,Z;Po.current=!0,(Z=(W=I.currentTarget).setPointerCapture)==null||Z.call(W,I.pointerId)},onKeyDown:I=>{const W=Z=>{var xe;return Z??((xe=Bm.current)==null?void 0:xe.offsetWidth)??Ua};I.key==="ArrowLeft"&&An(Z=>Math.max(Ua,W(Z)-16)),I.key==="ArrowRight"&&An(Z=>Math.min(720,W(Z)+16))}}),ig]})]})}function $_(){try{const e=window.localStorage.getItem(ck),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Ua?t:null}catch{return null}}function __(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function jt(e){return typeof e=="string"&&e!==""?e:null}function Os(e){return e instanceof pe||e instanceof Error?e.message:String(e)}function Cd(e,t){var r;const n=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!n)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const l=e.messages[i];if(l.role!=="user")continue;const o=l.blocks.find(a=>a.type==="text");if(o)return o.text.trim()===n}return!1}function da(e){var n;const t=(n=e.dataTransfer)==null?void 0:n.types;return!!(t&&Array.from(t).includes("Files"))}function O_(){return s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),s.jsx("path",{d:"M5 19.5v2a2.5 2.5 0 0 0 2.5 2.5h13a2.5 2.5 0 0 0 2.5-2.5v-2"})]})}const vh="buddi.chatDraft";function D_(e,t){try{window.sessionStorage.setItem(vh,JSON.stringify({agentId:e,text:t}))}catch{}}function L_(e){try{const t=window.sessionStorage.getItem(vh);if(!t)return null;const n=JSON.parse(t);return n.agentId!==e||typeof n.text!="string"?null:(window.sessionStorage.removeItem(vh),n.text)}catch{return null}}function F_(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),s.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function U_(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[s.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function B_({items:e,disabled:t}){const[n,r]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!n)return;const l=a=>{i.current&&!i.current.contains(a.target)&&r(!1)},o=a=>{a.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",o),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",o)}},[n]),s.jsxs("div",{className:"wb-head-menu",ref:i,children:[s.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":"More about this agent","aria-haspopup":"menu","aria-expanded":n,"data-open":n?"true":void 0,disabled:t,onClick:()=>r(l=>!l),children:s.jsx(U_,{})}),n?s.jsx("div",{className:"ui-menu wb-head-menu-list",role:"menu",children:e.map(l=>l.href?s.jsxs("a",{className:"ui-menu-item",role:"menuitem",href:l.href,onClick:()=>r(!1),children:[s.jsx("span",{className:"ui-menu-item-text",children:l.label}),l.hint?s.jsx("span",{className:"ui-menu-item-hint",children:l.hint}):null]},l.label):s.jsxs("button",{className:"ui-menu-item",role:"menuitem","data-testid":l.testId,disabled:l.disabled,onClick:()=>{var o;r(!1),(o=l.onSelect)==null||o.call(l)},children:[s.jsx("span",{className:"ui-menu-item-text",children:l.label}),l.hint?s.jsx("span",{className:"ui-menu-item-hint",children:l.hint}):null]},l.label))}):null]})}function z_(e,t){const n=l=>{var o;return`@${((o=t.find(a=>a.id===l))==null?void 0:o.handle)??l}`},[r,...i]=e;return r===void 0?"":[n(r),...i.map(l=>`asked by ${n(l)}`)].join(", ")}function _v({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:l}){return!t&&!k0(e)?s.jsx(Wt,{title:"A new group",onClose:n,children:s.jsxs(G,{children:["A group needs two agents. Make another one with ",jI(e)," first."]})}):s.jsx(V_,{agents:W_(e,t),group:t??null,onClose:n,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...l?{onArchived:l}:{}})}function W_(e,t){const n=b0(e),r=((t==null?void 0:t.members)??[]).filter(i=>!n.some(l=>l.id===i)).map(i=>e.find(l=>l.id===i)).filter(i=>i!==void 0);return[...n,...r]}function V_({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:l}){var C,T;const o=t!==null,[a,c]=d.useState((t==null?void 0:t.name)??""),[u,h]=d.useState((t==null?void 0:t.members)??[]),[f,p]=d.useState((t==null?void 0:t.coordinator)??((C=e.find(E=>E.roles.includes("front-desk")))==null?void 0:C.id)??((T=e[0])==null?void 0:T.id)??""),[m,j]=d.useState(!1),[w,b]=d.useState(!1),[x,v]=d.useState(null),y=[...new Set([f,...u])].filter(Boolean),g=a.trim()!==""&&f!==""&&y.length>=2,S=E=>h(U=>U.includes(E)?U.filter(H=>H!==E):[...U,E]),k=async()=>{j(!0),v(null);try{t?i==null||i(await _e.updateGroup(t.id,{name:a.trim(),coordinator:f,members:y})):r==null||r(await _e.createGroup({name:a.trim(),coordinator:f,members:y.filter(E=>E!==f)}))}catch(E){v(E instanceof pe?E.message:String(E))}finally{j(!1)}},N=async()=>{if(t){j(!0),v(null);try{await _e.archiveGroup(t.id),l==null||l(t.id)}catch(E){v(E instanceof pe?E.message:String(E)),j(!1)}}};return s.jsx(Wt,{title:o?`${t.name}: members`:"A new group",onClose:n,children:s.jsxs(q,{children:[s.jsx(ee,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:s.jsx("input",{value:a,autoFocus:!0,maxLength:80,onChange:E=>c(E.target.value),placeholder:"Household finances"})}),s.jsx(ee,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:s.jsx("select",{value:f,onChange:E=>p(E.target.value),children:e.map(E=>s.jsx("option",{value:E.id,children:E.name},E.id))})}),s.jsx(ee,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:s.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(E=>E.id!==f).map(E=>s.jsxs("label",{className:"group-pick-row","data-on":u.includes(E.id)||void 0,children:[s.jsx("input",{type:"checkbox",checked:u.includes(E.id),onChange:()=>S(E.id)}),s.jsx(bn,{agents:e,id:E.id,size:"sm"}),s.jsxs("span",{className:"group-pick-text",children:[s.jsx("span",{className:"group-pick-name",children:E.name}),s.jsx("span",{className:"group-pick-desc",children:E.description})]})]},E.id))})}),s.jsx(G,{children:"Members read what is said in this group and what they recall from shared and group memory. Nothing an agent knows privately is brought in on its own: what enters the room is seen by the room."}),o?s.jsx(G,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,x?s.jsx(G,{tone:"critical",children:x}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!g||m,onClick:()=>void k(),children:m?o?"Saving…":"Creating…":o?"Save":"Create group"})]}),o?s.jsx("div",{className:"group-archive",children:w?s.jsxs(q,{children:[s.jsxs(G,{tone:"warning",children:["Archive ",t.name,"? It leaves the rail and takes no new requests. Everything said in it stays readable."]}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:()=>b(!1),children:"Keep it"}),s.jsx(P,{variant:"danger",disabled:m,"data-testid":"group-archive-confirm",onClick:()=>void N(),children:"Archive group"})]})]}):s.jsx(P,{variant:"ghost",disabled:m,"data-testid":"group-archive",onClick:()=>b(!0),children:"Archive group"})}):null]})})}function Nm(e){const[t,n]=d.useState(null),[r,i]=d.useState(null),[l,o]=d.useState(null);return{busy:t,note:r,failure:l,decide:async(c,u,h,f)=>{var m,j,w,b;n(c),o(null),i(null);let p;try{const x=f?await A.decide(c,u,h,f):await A.decide(c,u,h);p={decision:u,...(m=x.execution)!=null&&m.state?{state:x.execution.state}:{},...x.execution&&"result"in x.execution?{result:x.execution.result}:{}},i(u==="reject"?`Rejected ${x.action.tool}.`:((j=x.execution)==null?void 0:j.state)==="succeeded"?`Approved and done: ${x.action.tool}.`:`Approved ${x.action.tool}: ${((w=x.execution)==null?void 0:w.state)??"no execution"}${(b=x.execution)!=null&&b.message?` (${x.execution.message})`:""}`)}catch(x){o(x instanceof Error?x.message:String(x))}finally{n(null),e(p)}}}}function Cm({action:e,timezone:t,busy:n,onDecide:r,agentName:i}){var h,f;const[l,o]=d.useState(!1),{values:a,controls:c}=xm(e.choices),u=p=>a?r(e.id,"approve",p,a):r(e.id,"approve",p);return s.jsxs(Or,{tone:"accent",title:e.tool,meta:s.jsxs(s.Fragment,{children:[s.jsxs(fe,{children:["v",e.toolVersion]}),s.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[s.jsx(rt,{children:e.preview}),s.jsxs("p",{className:"ui-card-meta",children:["Expires ",Pe(e.expiresAt,t)," (",Se(e.expiresAt),"). Policy v",e.policyVersion,", args ",no(e.argsHash,12),e.jobId?`, job ${no(e.jobId)}`:"","."]}),c,s.jsxs(J,{children:[s.jsx(P,{variant:"good",disabled:n,onClick:()=>u(),children:(h=e.permissionScopes)!=null&&h.length?"Allow once":"Approve"}),(f=e.permissionScopes)!=null&&f.length?s.jsxs(s.Fragment,{children:[s.jsx(P,{disabled:n,onClick:()=>u("conversation"),children:"Auto: this conversation"}),s.jsx(P,{disabled:n,onClick:()=>u("always"),children:"Always: this agent"})]}):null,s.jsx(P,{variant:"danger",disabled:n,onClick:()=>r(e.id,"reject"),children:"Reject"}),s.jsx(P,{variant:"ghost",onClick:()=>o(p=>!p),"aria-expanded":l,children:l?"Hide envelope":"Show envelope"})]}),l?s.jsxs("div",{className:"ui-card-foot",children:[s.jsx(Y,{title:"Envelope: everything that decides what the world will see",children:s.jsx(rt,{children:Xt(e.envelope)})}),s.jsx(Y,{title:"Canonical arguments",children:s.jsx(rt,{children:Xt(e.canonicalArgs)})})]}):null]})}function uk(e,t,n){const[r,i]=d.useState(!1),[l,o]=d.useState(null),[a,c]=d.useState(null);return{accept:()=>{e&&(i(!0),c(null),A.acceptPluginAgent(e,t).then(h=>{o(h.agent)}).catch(h=>c(h instanceof pe?h.message:String(h))).finally(()=>i(!1)))},busy:r,created:l,failure:a}}function dk({agent:e}){return s.jsxs(G,{tone:"good",role:"status",children:["@",e.handle," is ready. ",s.jsxs("a",{href:De(e.id),children:["Talk to @",e.handle]})]})}function fk(e,t,n){const r=e.canonicalArgs;return e.tool==="platform.accept_plugin_agent"&&(r==null?void 0:r.plugin)===t&&typeof r.agent=="string"&&r.agent.toLowerCase()===n.toLowerCase()}function H_(e,t){var i;const n=le(()=>A.approvals(),[e,t],15e3);return{action:((i=n.data)==null?void 0:i.pending.find(l=>fk(l,e,t)))??null,reload:n.reload}}function K_({action:e,onDecided:t}){const{busy:n,failure:r,decide:i}=Nm(l=>t(l));return s.jsxs(q,{gap:"sm",children:[s.jsx(Cm,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:n===e.id,onDecide:(l,o,a,c)=>{i(l,o,a,c)}}),s.jsx(ie,{message:r})]})}function Em({plugin:e,agent:t,text:n,label:r,handle:i,onDismiss:l}){var f;const o=uk(e,t),a=H_(e,t),[c,u]=d.useState(null),h=o.created??c;if(h)return s.jsx(dk,{agent:h});if(a.action){const p=i??((f=/@(\S+)/.exec(r))==null?void 0:f[1])??t;return s.jsxs(q,{gap:"sm",children:[s.jsx("span",{children:n}),s.jsx(K_,{action:a.action,onDecided:m=>{(m==null?void 0:m.decision)==="approve"&&m.state==="succeeded"?u({id:t,handle:p,name:p}):a.reload()}})]})}return s.jsxs(q,{gap:"sm",children:[s.jsxs(J,{children:[s.jsx("span",{children:n}),s.jsx(tl,{}),l?s.jsx(P,{variant:"ghost",disabled:o.busy,onClick:l,children:"Not now"}):null,s.jsx(P,{variant:"accent",disabled:o.busy,onClick:o.accept,children:r})]}),s.jsx(ie,{message:o.failure})]})}function hk(){var t;const e=le(()=>A.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function pk({offers:e,reload:t}){return e.length===0?null:s.jsx(Y,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:s.jsx(q,{gap:"sm",divided:!0,children:e.map(n=>s.jsx(Em,{plugin:n.plugin,agent:n.agent,text:n.text,label:`Create @${n.handle}`,handle:n.handle,onDismiss:()=>{A.dismissAgentOffer(n.plugin,n.agent).then(t,t)}},`${n.plugin}/${n.agent}`))})})}const Am=d.createContext(null),Cc=d.createContext(!1);function xt(){const e=d.useContext(Am);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function jh(e,t=new Set){if(Array.isArray(e))for(const n of e)jh(n,t);else if(e&&typeof e=="object"){const n=e.query;typeof n=="string"&&t.add(n);for(const r of Object.values(e))jh(r,t)}return t}function mk(e,t){if(t.size===0)return!1;for(const n of jh(e))if(t.has(n))return!0;return!1}function gk(){const[e,t]=d.useState(!1);return d.useEffect(()=>{if(!e)return;const n=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",n),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",n),window.removeEventListener("blur",n)}},[e]),[e,()=>t(n=>!n)]}function xk({revealed:e,onToggle:t}){return s.jsx(P,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function vk(){return s.jsx("p",{className:"muted",children:"Hidden until you show it."})}function jk({children:e}){const[t,n]=gk();return s.jsxs(q,{gap:"sm",children:[s.jsx(J,{align:"end",children:s.jsx(xk,{revealed:t,onToggle:n})}),t?s.jsx(Cc.Provider,{value:!0,children:e}):s.jsx(vk,{})]})}function Rm(e){return e===void 0||e==="neutral"?void 0:e}function yh(e){return Rm(e)}function G_(e){const t=Rm(e);return t==="accent"?void 0:t}function ns(e,t){if(!t)return!0;const n=me(e,t.path),r=t.in!==void 0?t.in.includes(n):n===t.equals;return t.not===!0?!r:r}function Tm(e,t,n){if("chat"in t){const l=be(n,t.chat);return l==null?"":De(String(l))}if("proposals"in t)return ZP(e.plugin);const r=e.pages.find(l=>l.id===t.page);if((r==null?void 0:r.place)==="settings")return cm(e.plugin,t.page);const i=t.item===void 0?null:be(n,t.item);return so(e.plugin,t.page,i==null?null:String(i))}function Y_(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(n,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(n,r)=>{const i=me(t.row,r);return i==null?"":String(i)})}function wh(e,t){if(e===void 0)return;if(typeof e=="string")return e;const n=be(t,e);return n==="good"||n==="warning"||n==="critical"||n==="neutral"?n:void 0}function yk(e,t,n){const r={};for(const[i,l]of Object.entries(e??{})){let o;"param"in l?o=n.params[l.param]:"route"in l?o=l.route==="plugin"?n.plugin:l.route==="page"?n.page:n.item:o=be(t,l),!(o==null||o==="")&&(r[i]=String(o))}return r}function Li(e,t){var r,i,l;const n={};for(const[o,a]of Object.entries(e??{}))if("row"in a)n[o]=me(t.row,a.row);else if("field"in a){if((r=t.omit)!=null&&r.has(a.field))continue;const c=(i=t.fields)==null?void 0:i[a.field],u=(l=t.shape)==null?void 0:l.find(h=>h.name===a.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;n[o]=c}else"selected"in a?n[o]=t.selected??[]:"param"in a?n[o]=t.scope.params[a.param]:n[o]=be(t.data,a);return n}function os(e,t){const n=xt(),r=e?yk(e.params,t,n):{},i=JSON.stringify([(e==null?void 0:e.query)??null,r,n.version]),l=le(()=>e?A.pageQuery(n.plugin,e.query,r).then(o=>o.data):Promise.resolve(void 0),[i]);return{data:l.data,error:l.error,loading:l.loading}}function jo(){const e=xt(),[t,n]=d.useState(null),[r,i]=d.useState(null),[l,o]=d.useState(null),[a,c]=d.useState(null),[u,h]=d.useState(null),f=(w,b)=>{if(w.done===void 0)return null;if(typeof w.done=="string")return w.done;const x=be(b,w.done);return x==null?null:String(x)},p=(w,b,x)=>{const v=w??"refresh";if(typeof v=="object"){const y=Tm(e,v.route,b);y===""?e.refresh():e.navigate(y);return}v==="close"&&(x==null||x()),e.refresh()},m=async(w,b,x)=>{n(w.tool),i(null),o(null);try{const v=await A.pageAct(e.plugin,{tool:w.tool,args:b});if(v.approvalId){c(v.approvalId),h({then:w.then,ref:w,...x?{onDone:x}:{}});return}c(null),h(null),o(f(w,v.result)),p(w.then,v.result,x)}catch(v){i(v instanceof Error?v.message:String(v)),e.refresh()}finally{n(null)}},j=w=>{if(!w){e.refresh();return}const b=u;if(c(null),h(null),b&&w.decision==="approve"&&w.state==="succeeded"){o(f(b.ref,w.result)),p(b.then,void 0,b.onDone);return}e.refresh()};return{running:t,busy:t!==null,error:r,done:l,approvalId:a,waiting:(u==null?void 0:u.ref.pending)??null,settle:j,run:m}}function Fi({action:e,args:t,disabled:n,running:r,count:i,row:l,onRun:o}){const[a,c]=d.useState(!1),u=f=>Y_(f,{...i===void 0?{}:{count:i},row:l}),h=u(e.label);return a&&e.confirm?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),s.jsx(P,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsxs(P,{variant:e.tone==="danger"?"danger":"accent",disabled:n,onClick:()=>{c(!1),o(e,t)},children:["Yes, ",h.toLowerCase()]})]}):s.jsx(P,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:n,onClick:()=>e.confirm?c(!0):o(e,t),children:r&&e.busy?e.busy:h})}function bh({id:e,onDecided:t}){const n=xt(),r=le(()=>A.approval(e),[e,n.version]),{busy:i,note:l,failure:o,decide:a}=Nm(c=>{t?t(c):n.refresh()});return r.error?s.jsx(ie,{message:r.error}):r.data?s.jsxs(q,{children:[s.jsx(Cm,{action:r.data,timezone:n.timezone,busy:i===e,onDecide:(c,u,h,f)=>{a(c,u,h,f)}}),l?s.jsx(G,{tone:"good",role:"status",children:l}):null,s.jsx(ie,{message:o})]}):s.jsx(oe,{children:"Loading the approval…"})}function sl({act:e}){return e.error?s.jsx(ie,{message:e.error}):e.approvalId?e.waiting?s.jsxs(q,{children:[s.jsx(G,{role:"status",children:e.waiting}),s.jsx(bh,{id:e.approvalId,onDecided:e.settle})]}):s.jsx(bh,{id:e.approvalId,onDecided:e.settle}):e.done?s.jsx(G,{tone:"good",role:"status",children:e.done}):null}function Ec(e,t){const n={};for(const r of e){const i=r.from===void 0?void 0:me(t,r.from);n[r.name]=i!==void 0?i:r.type==="checkbox"?!1:(r.type==="number","")}return n}function q_(e,t,n){const r=xt(),i=e.optionsFrom,l=i?{...yk(i.query.params,n,r),...Object.fromEntries((i.dependsOn??[]).map(c=>[c,String(t[c]??"")]).filter(([,c])=>c!==""))}:{},o=JSON.stringify([(i==null?void 0:i.query.query)??null,l,r.version]),a=le(()=>i?A.pageQuery(r.plugin,i.query.query,l).then(c=>c.data):Promise.resolve(void 0),[o]);return i?{options:Ui(a.data,i.rows).map(c=>({value:String(me(c,i.value)??""),label:String(me(c,i.label)??"")})),loading:a.loading}:{options:e.options??[],loading:!1}}function Q_({field:e,value:t,values:n,data:r,disabled:i,compact:l,onChange:o}){const a=q_(e,n,r),c={id:`f-${e.name}`,required:e.required,name:e.name,disabled:i,...l&&e.hint?{title:e.hint}:{}},u=l?void 0:e.hint;if(e.type==="select")return s.jsx(ee,{label:e.label,hint:u,children:s.jsxs("select",{...c,value:String(t??""),onChange:f=>o(f.target.value),children:[s.jsx("option",{value:"",children:a.loading?"Loading…":"—"}),a.options.map(f=>s.jsx("option",{value:f.value,children:f.label},f.value))]})});if(e.type==="textarea")return s.jsx(ee,{label:e.label,hint:u,wide:!0,children:s.jsx("textarea",{...c,value:String(t??""),onChange:f=>o(f.target.value),rows:6})});if(e.type==="checkbox")return s.jsx(ee,{label:e.label,hint:u,inline:!0,wide:!l,children:s.jsx("input",{...c,type:"checkbox",checked:t===!0,onChange:f=>o(f.target.checked)})});const h=e.type==="secret"?"password":e.type==="number"?"number":e.type;return s.jsx(ee,{label:e.label,hint:u,children:s.jsx("input",{...c,type:h,value:t==null?"":String(t),min:e.min,max:e.max,step:e.step,...l&&e.hint?{placeholder:e.hint}:{},onChange:f=>o(e.type==="number"?J_(f.target.value):f.target.value)})})}function J_(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function wk(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function bk(e,t,n){const r=wk(t,n);return new Set(e.filter(i=>i.when!==void 0&&!ns(r,i.when)||i.disabledWhen!==void 0&&ns(r,i.disabledWhen)).map(i=>i.name))}function Pm({fields:e,values:t,data:n,disabled:r,compact:i,onChange:l}){const o=wk(t,n);return s.jsx(Es,{dense:i,children:e.filter(a=>a.when===void 0||ns(o,a.when)).map(a=>s.jsx(Q_,{field:a,compact:i,value:t[a.name],values:t,data:n,disabled:r===!0||a.disabledWhen!==void 0&&ns(o,a.disabledWhen),onChange:c=>l(a.name,c)},a.name))})}const lo=d.createContext(!1),kk=d.createContext(!1),Sk=d.createContext(!1);function Ms({title:e,note:t,actions:n,children:r}){const i=d.useContext(lo);return s.jsx(Y,{title:e,aside:t,actions:n,panel:i,children:s.jsx(lo.Provider,{value:!1,children:s.jsx(kk.Provider,{value:i,children:r})})})}function As({component:e,data:t,choose:n,chosen:r}){const i=xt(),l=d.useContext(Cc);if(!ns(t,e.when))return null;if(e.kind!=="section"&&!l&&mk(e,i.sensitive))return s.jsx(jk,{children:s.jsx(As,{component:e,data:t,...n?{choose:n}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return s.jsx(X_,{component:e,data:t});case"notice":return s.jsx(G,{tone:Rm(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(be(t,e.text)??"")});case"link":return s.jsx(Z_,{component:e,data:t});case"stats":return s.jsx(eO,{component:e,data:t});case"list":return s.jsx(nO,{component:e,data:t,...n?{onChoose:n}:{},...r===void 0?{}:{chosen:r}});case"table":return s.jsx(sO,{component:e,data:t});case"detail":return s.jsx(lO,{component:e,data:t});case"form":return s.jsx(oO,{component:e,data:t});case"search":return s.jsx(uO,{component:e,data:t});case"list-detail":return s.jsx(dO,{component:e,data:t});case"repeat":return s.jsx(fO,{component:e,data:t});case"expand":return s.jsx(hO,{component:e,data:t});case"button":return s.jsx(pO,{component:e,data:t});case"approval":return s.jsx(gO,{component:e,data:t});case"artifact":return s.jsx(xO,{component:e,data:t});case"editor":return s.jsx(vO,{component:e,data:t});case"agent-offer":return s.jsx(mO,{component:e});default:return null}}function X_({component:e,data:t}){const n=xt(),r=d.useContext(Cc),[i,l]=gk(),o=!r&&mk(e.body,n.sensitive),a=o&&!i,c=d.useContext(lo);let u=e.body.length;const h=m=>m.kind==="button"||m.kind==="link"||m.kind==="form"&&m.drawer!==void 0&&!m.title;for(;c&&u>0&&h(e.body[u-1]);)u-=1;const f=e.body.slice(0,u),p=[...e.actions??[],...e.body.slice(u)];return s.jsx(Ms,{title:e.title,note:e.note,actions:p.length>0||o?s.jsxs(s.Fragment,{children:[p.map((m,j)=>s.jsx(As,{component:m,data:t},j)),o?s.jsx(xk,{revealed:i,onToggle:l}):null]}):void 0,children:s.jsx(q,{gap:"lg",divided:c,children:a?s.jsx(vk,{}):s.jsx(Cc.Provider,{value:r||o,children:f.map((m,j)=>s.jsx(As,{component:m,data:t},j))})})})}function Z_({component:e,data:t}){const n=xt(),r=Tm(n,e.to,t);return r===""?null:s.jsx(J,{children:s.jsx(Fn,{href:r,onClick:i=>{i.preventDefault(),n.navigate(r)},children:e.label})})}function eO({component:e,data:t}){const n=os(e.query,t);return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(ie,{message:n.error}),n.data===void 0?s.jsx(oe,{children:e.empty??"Loading…"}):s.jsx(cu,{children:e.items.map((r,i)=>s.jsx(Xn,{label:r.label,value:mt(be(n.data,r.value),r.unit??"text",null),tone:G_(r.tone)},i))})]})}function Nk(e,t,n,r){const i=(t.meta??[]).map(u=>String(be(n,u)??"")).filter(u=>u!==""),l=String(be(n,t.title)??""),o=t.to&&!r?Tm(e,t.to,n):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,h)=>{const f=be(n,u.value);if(f==null||f==="")return null;const p=tO(u,f,n);return s.jsx(fe,{tone:yh(p.tone),children:p.text},h)});return{text:l,href:o,pills:s.jsx(s.Fragment,{children:c}),meta:i.join(" · "),title:o?s.jsx("a",{href:o,onClick:u=>{u.preventDefault(),e.navigate(o)},children:l}):l,sub:t.sub?String(be(n,t.sub)??""):null,side:s.jsxs(s.Fragment,{children:[c,i.length>0?s.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function tO(e,t,n){const r=String(t),i=e.labels??{},l=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(l,r)?l[r]:wh(e.tone,n)}}function Ui(e,t){const n=me(e,t);return Array.isArray(n)?n:[]}function Ck(e,t,n){const r=[],i=new Set;return e.forEach((l,o)=>{const a=t===void 0?void 0:me(l,t),c=a==null||a===""?null:String(a);if(c===null){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: row ${o} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:l})}),r}function nO({component:e,data:t,onChoose:n,chosen:r}){var S;const i=xt(),l=d.useContext(Sk),o=os(e.query,t),a=jo(),[c,u]=d.useState([]),h=l&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,f=Ui(o.data,e.rows),p=e.collapsed?Ui(o.data,e.collapsed.rows):[],m={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},j=Ck([...f,...p],e.key??((S=e.select)==null?void 0:S.key),m),w=new Map(j.map(k=>[k.row,k.key])),b=new Set(j.map(k=>k.row)),x=new Set(j.filter(({row:k})=>{var N;return((N=e.select)==null?void 0:N.disabledWhen)===void 0||!ns(k,e.select.disabledWhen)}).map(({key:k})=>k)),v=c.filter(k=>x.has(k)),y=d.useMemo(()=>{const k=f.filter(C=>b.has(C));if(!e.groupBy)return[{label:null,rows:k}];const N=new Map;for(const C of k){const T=String(me(C,e.groupBy.key)??"");N.set(T,[...N.get(T)??[],C])}return[...N].map(([C,T])=>{var E,U;return{label:((U=(E=e.groupBy)==null?void 0:E.labels)==null?void 0:U[C])??C,rows:T}})},[f,e.groupBy,j.length]),g=k=>k.map(N=>{var H;const C=Nk(i,e.item,N,n),T=w.get(N);if(h&&(n||C.href))return s.jsx(D0,{href:C.href??"#",current:r===T,onClick:()=>n?n(T):i.navigate(C.href),title:C.text,meta:C.meta,sub:C.sub,side:C.pills},T);const E=((H=e.select)==null?void 0:H.disabledWhen)!==void 0&&ns(N,e.select.disabledWhen),U=(e.actions??[]).filter(O=>ns(N,O.when));return s.jsx(Cn,{lead:e.select?s.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(T),onClick:O=>O.stopPropagation(),onChange:O=>u(R=>O.target.checked?[...R,T]:R.filter(F=>F!==T))}):void 0,title:n?s.jsx("a",{href:"#","aria-current":r===T?"true":void 0,onClick:O=>{O.preventDefault(),n(T)},children:C.text}):C.title,sub:C.sub,side:s.jsxs(s.Fragment,{children:[C.side,U.map((O,R)=>s.jsx(Fi,{action:O,args:Li(O.args,{data:o.data,row:N,scope:i}),disabled:a.busy,running:a.running===O.tool,row:N,onRun:(F,K)=>void a.run(F,K)},R))]})},T)});return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(ie,{message:o.error}),s.jsx(sl,{act:a}),y.every(k=>k.rows.length===0)?o.loading?s.jsx(oe,{children:"Loading…"}):s.jsx(Im,{text:e.empty??"Nothing here yet."}):s.jsxs(un,{children:[e.select?s.jsx(Cn,{lead:s.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:x.size>0&&v.length===x.size,disabled:x.size===0,onChange:k=>u(k.target.checked?[...x]:[])}),title:s.jsxs("span",{className:"muted",children:[x.size," to choose from"]})}):null,y.map((k,N)=>s.jsxs("div",{children:[k.label?s.jsx("div",{className:"ui-list-group",children:k.label}):null,g(k.rows)]},N))]}),e.collapsed&&p.some(k=>b.has(k))?s.jsx(Nt,{summary:`${e.collapsed.label} (${p.filter(k=>b.has(k)).length})`,children:s.jsx(un,{children:g(p.filter(k=>b.has(k)))})}):null,e.bulk&&e.bulk.length>0?s.jsxs(J,{align:"end",children:[s.jsxs("span",{className:"ui-toolbar-note",children:[v.length," selected"]}),e.bulk.map((k,N)=>{const C=v.length>0||k.all!==!0?v:[...x];return s.jsx(Fi,{action:k,args:Li(k.args,{data:o.data,selected:C,scope:i}),count:C.length,disabled:a.busy||C.length===0,running:a.running===k.tool,onRun:(T,E)=>{u([]),a.run(T,E)}},N)})]}):null]})}function sO({component:e,data:t}){const n=xt(),r=os(e.query,t),i=jo(),l=Ui(r.data,e.rows);return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(ie,{message:r.error}),s.jsx(sl,{act:i}),l.length===0?r.loading?s.jsx(oe,{children:"Loading…"}):s.jsx(Im,{text:e.empty??"Nothing here yet."}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[e.columns.map(o=>s.jsx("th",{children:o.label},o.key)),e.actions&&e.actions.length>0?s.jsx("th",{"aria-label":"Actions"}):null]})}),s.jsx("tbody",{children:l.map((o,a)=>s.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:mt(me(o,c.key),c.type??"text",null);return s.jsx("td",{"data-fit":c.fit,title:rO(c,o,u),children:c.pill?s.jsx(iO,{column:c,row:o}):c.fit==="truncate"?s.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?s.jsx("td",{children:s.jsx(J,{align:"end",children:e.actions.filter(c=>ns(o,c.when)).map((c,u)=>s.jsx(Fi,{action:c,args:Li(c.args,{data:r.data,row:o,scope:n}),disabled:i.busy,running:i.running===c.tool,row:o,onRun:(h,f)=>void i.run(h,f)},u))})}):null]},a))})]})]})}function rO(e,t,n){if(e.hint){const r=me(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&n?n:void 0}function iO({column:e,row:t}){var o,a;const n=me(t,e.key);if(Array.isArray(n))return s.jsx(s.Fragment,{children:n.map((c,u)=>{var w;const h=c,f=typeof h=="object"&&h!==null?h.value:c;if(f==null||f==="")return null;const p=typeof h=="object"&&h!==null?h.tone:void 0,m=(w=e.pill)==null?void 0:w.labels,j=m&&Object.prototype.hasOwnProperty.call(m,String(f))?m[String(f)]:mt(f,e.type??"text",null);return s.jsx(fe,{tone:yh(wh(typeof p=="string"?p:void 0,t)),children:j},u)})});const r=(o=e.pill)==null?void 0:o.labels,i=String(n),l=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:mt(n,e.type??"text",null);return s.jsx(fe,{tone:yh(wh((a=e.pill)==null?void 0:a.tone,t)),children:l})}function lO({component:e,data:t}){const n=os(e.query,t);return n.error?s.jsx(ie,{message:n.error}):n.data===void 0?s.jsx(oe,{children:e.empty??"Loading…"}):s.jsx(Ms,{title:e.title,note:e.note,children:s.jsxs(q,{gap:"lg",children:[e.fields.length>0?s.jsx(bt,{items:e.fields.map(r=>({key:r.label,label:r.label,value:mt(be(n.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>s.jsx(As,{component:r,data:n.data},i))]})})}function oO({component:e,data:t}){const n=xt(),r=os(e.initial,t),i=jo(),[l,o]=d.useState(!1),a=JSON.stringify([r.data??null,n.version]),c=s.jsx(aO,{component:e,data:t,initialData:r.data,act:i,onDone:()=>o(!1)},a);return e.drawer?s.jsxs(Y,{title:e.title,aside:e.note,actions:s.jsx(P,{variant:"accent",onClick:()=>o(!0),children:e.drawer.button}),children:[s.jsx(sl,{act:i}),l?s.jsx(Wt,{title:e.drawer.title,onClose:()=>o(!1),children:c}):null]}):s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(ie,{message:r.error}),c]})}function aO({component:e,data:t,initialData:n,act:r,onDone:i}){const l=d.useContext(kk),o=xt(),[a,c]=d.useState(()=>Ec(e.fields,n)),u=bk(e.fields,a,n),h=e.fields.some(f=>f.required&&!u.has(f.name)&&(a[f.name]===""||a[f.name]===void 0));return s.jsxs(q,{children:[s.jsx(Pm,{fields:e.fields,values:a,data:n,onChange:(f,p)=>c(m=>({...m,[f]:p}))}),e.drawer?null:s.jsx(sl,{act:r}),s.jsx(J,{align:"end",className:l?"ui-panel-foot":void 0,children:s.jsx(Fi,{action:e.submit,args:Li(e.submit.args,{data:t,fields:a,shape:e.fields,omit:u,scope:o}),disabled:r.busy||h,running:r.running===e.submit.tool,onRun:(f,p)=>void r.run(f,p,i)})})]})}function cO(e,t){var r;if(e.type==="checkbox")return e.label;const n=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${n?n.label:t}`}function Ov(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function uO({component:e,data:t}){const n=xt(),[r,i]=d.useState(()=>Ec(e.fields,t)),[l,o]=d.useState(e.auto===!0),[a,c]=d.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),h=os(l&&u?e.query:void 0,t),f=Ui(h.data,e.rows),p=e.count===void 0?void 0:me(h.data,e.count),m=e.note===void 0?void 0:me(h.data,e.note),j=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==j),b=C=>{n.setParams(Object.fromEntries(e.fields.map(T=>[T.name,String(C[T.name]??"")||null]))),o(!0)},x=(C,T)=>{const E={...r,[C]:T};i(E),e.auto&&b(E)},v=()=>{const C=Ec(e.fields,null);i(C),e.auto?b(C):(n.setParams(Object.fromEntries(e.fields.map(T=>[T.name,null]))),o(!1))},y=l?w.filter(C=>Ov(n.params[C.name])):[],g=j?y.map(C=>s.jsx(ih,{label:C.label,onRemove:()=>{const T={...r,[C.name]:C.type==="checkbox"?!1:""};i(T),b(T)},children:cO(C,String(n.params[C.name]))},C.name)):[],S=w.filter(C=>Ov(r[C.name])).length,k=e.auto&&!e.reset?null:s.jsxs(s.Fragment,{children:[e.reset?s.jsx(P,{variant:"ghost",onClick:v,children:"Clear"}):null,e.auto?null:s.jsx(P,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),N=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return s.jsx(Ms,{title:e.title,children:s.jsxs(q,{children:[s.jsx(F0,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&b(r)},main:j?s.jsx("input",{id:`f-${j.name}`,name:j.name,type:j.type==="email"?"email":"search","aria-label":j.label,placeholder:j.hint??j.label,title:j.hint,required:j.required,value:String(r[j.name]??""),onChange:C=>x(j.name,C.target.value)}):void 0,filters:w.length>0?s.jsx(Pm,{fields:w,values:r,data:t,compact:!0,onChange:x}):void 0,...j&&w.length>0?{filtersOpen:a,onToggleFilters:()=>c(C=>!C),active:S}:{},chips:g.length>0?g:void 0,actions:k}),s.jsx(ie,{message:h.error}),l&&(p!==void 0||m!==void 0)?s.jsxs("p",{className:"ui-card-meta",children:[p===void 0?"":`${mt(p,"number",null)} in all. `,m===void 0?"":String(m)]}):null,l?f.length===0?s.jsx(oe,{children:h.loading?"Searching…":e.empty??"Nothing matches."}):s.jsx("div",{className:"ui-panel","data-flush":"true",children:s.jsx(un,{children:f.map((C,T)=>{const E=Nk(n,N,C);return s.jsx(Cn,{title:E.title,sub:E.sub,side:E.side},T)})})}):null]})})}function dO({component:e,data:t}){const n=xt(),r=e.selection==="local",[i,l]=d.useState(null),o=r?i:n.params[e.param]??n.item,a=r&&i!==null?{...n,params:{...n.params,[e.param]:i}}:null,c=s.jsx(q,{gap:"lg",divided:!0,children:e.detail.map((u,h)=>s.jsx(As,{component:u,data:t},h))});return s.jsx(lo.Provider,{value:!1,children:s.jsx(L0,{list:s.jsx(Sk.Provider,{value:!0,children:s.jsx(As,{component:e.list,data:t,chosen:o??null,...r?{choose:l}:{}})}),detail:o?a?s.jsx(Am.Provider,{value:a,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function fO({component:e,data:t}){const n=xt(),r=os(e.query,t),i=Ui(r.data,e.rows);return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(ie,{message:r.error}),i.length===0?r.loading?s.jsx(oe,{children:"Loading…"}):s.jsx(Im,{text:e.empty??"Nothing here yet."}):s.jsx(q,{gap:"lg",divided:!0,children:Ck(i,e.key,{plugin:n.plugin,page:n.page,component:`repeat "${e.title??e.rows}"`}).map(({key:l,row:o})=>s.jsx(Y,{children:s.jsx(q,{children:e.body.map((a,c)=>s.jsx(As,{component:a,data:o},c))})},l))})]})}function hO({component:e,data:t}){const[n,r]=d.useState(!1),i=os(n?e.query:void 0,t),l=typeof e.label=="string"?e.label:String(be(t,e.label)??"");return s.jsxs(Nt,{summary:l,boxed:!0,onToggle:o=>r(o),children:[s.jsx(ie,{message:i.error}),i.data===void 0?s.jsx(oe,{children:"Loading…"}):s.jsx(q,{children:e.body.map((o,a)=>s.jsx(As,{component:o,data:i.data},a))})]})}function pO({component:e,data:t}){const n=xt(),r=jo();return s.jsxs(s.Fragment,{children:[s.jsx(J,{align:"end",children:s.jsx(Fi,{action:e.action,args:Li(e.action.args,{data:t,row:t,scope:n}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,l)=>void r.run(i,l)})}),s.jsx(sl,{act:r})]})}function mO({component:e}){const t=xt();return s.jsx(Em,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function gO({component:e,data:t}){const n=me(t,e.path);return typeof n!="string"||n===""?null:s.jsx(bh,{id:n})}function xO({component:e,data:t}){const n=me(t,e.path);return typeof n!="string"||n===""?null:s.jsx(J,{children:s.jsx("a",{href:uu(n),children:e.label})})}function vO({component:e,data:t}){const n=os(e.query,t),r=jo();return n.error?s.jsx(ie,{message:n.error}):n.data===void 0?s.jsx(oe,{children:e.empty??"Loading…"}):s.jsxs(s.Fragment,{children:[s.jsx(sl,{act:r}),s.jsx(jO,{component:e,data:t,loaded:n.data,act:r},JSON.stringify(n.data))]})}function jO({component:e,data:t,loaded:n,act:r}){const i=xt(),[l,o]=d.useState(()=>Ec(e.fields,n)),a={...l,version:me(n,e.version)},c=bk(e.fields,l,n),u=e.readOnlyWhen!==void 0&&ns(n,e.readOnlyWhen),h=(e.actions??[]).filter(m=>m.placement==="leading"),f=(e.actions??[]).filter(m=>m.placement!=="leading"),p=(m,j)=>s.jsx(Fi,{action:m,args:Li(m.args,{data:t,fields:a,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===m.tool,onRun:(w,b)=>void r.run(w,b)},`${m.tool}-${j}`);return s.jsx(Ms,{title:e.title,note:e.note,children:s.jsxs(q,{children:[s.jsx(Pm,{fields:e.fields,values:l,data:n,disabled:u,onChange:(m,j)=>o(w=>({...w,[m]:j}))}),u?null:s.jsxs(J,{align:"end",children:[h.map(p),h.length>0?s.jsx(tl,{}):null,p(e.save,-1),f.map(p)]}),e.footnote?s.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function Ek({page:e,item:t,navigate:n,timezone:r,embedded:i,siblings:l}){const[o,a]=d.useState({}),[c,u]=d.useState(0),h={plugin:e.plugin,page:e.id,pages:l??[e],item:t??null,params:{...o,...t?{item:t}:{},...wO(e,t)},setParams:j=>a(w=>{const b={...w};for(const[x,v]of Object.entries(j))v===null?delete b[x]:b[x]=v;return b}),navigate:n,timezone:r,version:c,refresh:()=>u(j=>j+1),sensitive:new Set(e.sensitive??[])},f=e.body[0],p=!i&&(f==null?void 0:f.kind)==="notice"&&typeof f.text=="string"&&f.when===void 0&&f.title===void 0&&(f.tone===void 0||f.tone==="neutral")?f.text:void 0,m=p===void 0?e:{...e,body:e.body.slice(1)};return s.jsx(Am.Provider,{value:h,children:s.jsx(en,{embedded:i,title:e.title,lede:p,children:s.jsx(yO,{page:m,boxed:i===!0})})})}function yO({page:e,boxed:t}){const n=xt();return e.data&&n.sensitive.has(e.data.query)?s.jsx(jk,{children:s.jsx(Dv,{page:e,boxed:t})}):s.jsx(Dv,{page:e,boxed:t})}function Dv({page:e,boxed:t}){const n=os(e.data,null);return s.jsxs(q,{gap:"lg",divided:!t,children:[s.jsx(ie,{message:n.error}),s.jsx(lo.Provider,{value:t,children:e.body.map((r,i)=>s.jsx(As,{component:r,data:n.data??null},i))})]})}function wO(e,t){if(!t)return{};const n=[],r=i=>{for(const l of i)l.kind==="list-detail"?(n.push(l.param),r(l.detail)):(l.kind==="section"||l.kind==="detail"||l.kind==="expand")&&r(l.body)};return r(e.body),Object.fromEntries(n.map(i=>[i,t]))}function bO(e){return s.jsx(Ek,{...e,embedded:!0})}function Im({text:e}){const t=e.search(/[.!?]\s/),n=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return s.jsx(gt,{title:n,children:r||null})}function Lv(e,t){return(e??[]).filter(n=>n.place===t).map((n,r)=>({page:n,index:r})).sort((n,r)=>(n.page.order??0)-(r.page.order??0)||n.index-r.index).map(n=>n.page)}function Ak(e=!1){const[t,n]=d.useState([]);return d.useEffect(()=>{if(e)return;let r=!1;return Promise.resolve().then(()=>A.pages()).then(i=>{r||n(Array.isArray(i==null?void 0:i.pages)?i.pages:[])}).catch(()=>{}),()=>{r=!0}},[e]),{all:t,rail:Lv(t,"rail"),settings:Lv(t,"settings"),find:(r,i)=>t.find(l=>l.plugin===r&&l.id===i)}}const Fv=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],kO=["","image","pdf","table","text","code","audio","video","archive","file"];function SO({hash:e,timezone:t,navigate:n,agents:r}){var O;const i=GP(e),l=(i==null?void 0:i.artifactId)??null,o=(i==null?void 0:i.filters.origin)??"",a=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,h]=d.useState(c);d.useEffect(()=>{h(c)},[c]);const f=(R,F=!1)=>n(sa(l,{q:c,origin:o,family:a,...R}),F);d.useEffect(()=>{if(u===c)return;const R=window.setTimeout(()=>f({q:u},!0),250);return()=>window.clearTimeout(R)},[u]);const[p,m]=d.useState(null),[j,w]=d.useState(null),[b,x]=d.useState(null),[v,y]=d.useState(!1),[g,S]=d.useState(!1),k=R=>{var F;return R?((F=r.find(K=>K.id===R))==null?void 0:F.name)??R:""},N=d.useRef(0);d.useEffect(()=>{const R=++N.current;m(null),w(null),y(!1),x(null),A.library({...c?{q:c}:{},...o?{origin:o}:{},...a?{family:a}:{}}).then(F=>{N.current===R&&(m(F.entries),w(F.next))}).catch(F=>{N.current===R&&x(F instanceof pe?F.message:String(F))})},[c,o,a]);const C=()=>{if(!j||v)return;y(!0);const R=N.current;A.library({...c?{q:c}:{},...o?{origin:o}:{},...a?{family:a}:{},cursor:j}).then(F=>{N.current===R&&(m(K=>{const L=new Set((K??[]).map(M=>M.id));return[...K??[],...F.entries.filter(M=>!L.has(M.id))]}),w(F.next))}).catch(F=>{N.current===R&&x(F instanceof pe?F.message:String(F))}).finally(()=>{N.current===R&&y(!1)})},T=(o?1:0)+(a?1:0),E=((O=Fv.find(R=>R.id===o))==null?void 0:O.label)??o,U=s.jsxs(s.Fragment,{children:[p===null?s.jsx(oe,{children:"Loading…"}):p.length===0?s.jsx(oe,{children:"No file matches that."}):s.jsx(un,{children:p.map(R=>s.jsx(D0,{href:sa(R.id,{q:c,origin:o,family:a}),current:R.id===l,onClick:()=>n(sa(R.id,{q:c,origin:o,family:a})),lead:s.jsx("span",{className:"files-row-visual","data-family":R.family,children:R.family==="image"&&!R.deleted?s.jsx("img",{src:Dr(R.id),alt:"",loading:"lazy"}):s.jsx(km,{family:R.family})}),title:R.filename??"Untitled file",meta:s.jsx("span",{title:Pe(R.createdAt,t),children:Se(R.createdAt)}),sub:`${Cr[R.family]} · ${En(R.sizeBytes)} · ${Rk(R,k)}${NO(R,k)}`},R.id))}),j?s.jsx("div",{className:"files-more",children:s.jsx(P,{size:"sm",onClick:C,disabled:v,children:v?"Loading…":"Show more"})}):null]}),H=p!==null&&p.length===0&&!c&&!o&&!a&&!u;return s.jsxs("div",{className:"ui-page files","data-selected":l?"true":void 0,children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Files"}),s.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),H?s.jsx(gt,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):s.jsxs(s.Fragment,{children:[s.jsx(F0,{label:"Files",onSubmit:()=>f({q:u},!0),main:s.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:R=>h(R.target.value)}),filters:s.jsxs(Es,{dense:!0,children:[s.jsx(ee,{label:"Origin",children:s.jsx("select",{value:o,"aria-label":"Origin",onChange:R=>f({origin:R.target.value}),children:Fv.map(R=>s.jsx("option",{value:R.id,children:R.label},R.id))})}),s.jsx(ee,{label:"Kind",children:s.jsx("select",{value:a,"aria-label":"Kind",onChange:R=>f({family:R.target.value}),children:kO.map(R=>s.jsx("option",{value:R,children:R===""?"Any kind":Cr[R]},R))})})]}),filtersOpen:g,onToggleFilters:()=>S(R=>!R),active:T,chips:T>0?s.jsxs(s.Fragment,{children:[o?s.jsx(ih,{label:"Origin",onRemove:()=>f({origin:""}),children:E}):null,a?s.jsx(ih,{label:"Kind",onRemove:()=>f({family:""}),children:Cr[a]}):null]}):void 0}),s.jsx(ie,{message:b}),s.jsx(L0,{className:"files-split",label:"Files",list:U,detail:l?s.jsx(CO,{id:l,timezone:t,agents:r,navigate:n,onBack:()=>n(sa(null,{q:c,origin:o,family:a}))},l):void 0,empty:"Choose a file to see it here."})]})]})}function NO(e,t){var i,l;const n=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(l=e.context)!=null&&l.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[n,r].filter(Boolean).map(o=>` · ${o}`).join("")}function Rk(e,t){return e.origin==="uploaded"?"You sent it":e.origin==="produced"?`Made by ${t(e.agentId)||"an agent"}`:e.agentId?`Saved by ${t(e.agentId)}`:"Origin unknown"}function CO({id:e,timezone:t,agents:n,navigate:r,onBack:i}){const[l,o]=d.useState(null),[a,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let v=!1;return o(null),h(null),A.libraryEntry(e).then(y=>{v||o(y)}).catch(y=>{v||h(y instanceof pe&&y.status===404?"This file is no longer in the library.":y instanceof pe?y.message:String(y))}),()=>{v=!0}},[e]);const f=v=>{var y;return v?((y=n.find(g=>g.id===v))==null?void 0:y.name)??v:""};if(u)return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(P,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsx(G,{tone:"critical",children:u})]});if(!l)return s.jsx("div",{className:"files-detail-body",children:s.jsx(oe,{children:"Loading…"})});const{entry:p,contexts:m,contextsTotal:j,available:w}=l,b=p.filename??"Untitled file",x=()=>{c(!0),A.libraryEntry(e,m.length).then(v=>o(y=>y&&{...y,contexts:[...y.contexts,...v.contexts],contextsTotal:v.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(P,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsxs("header",{className:"files-detail-head",children:[s.jsx("span",{className:"files-detail-mark","data-family":p.family,"aria-hidden":"true",children:s.jsx(km,{family:p.family})}),s.jsxs("div",{className:"files-detail-text",children:[s.jsx("h3",{className:"files-detail-name",children:b}),s.jsxs("p",{className:"files-detail-meta",children:[Cr[p.family]," · ",En(p.sizeBytes)," · ",Pe(p.createdAt,t)]})]}),w?s.jsx("a",{className:"ui-btn","data-variant":"accent",href:uu(p.id),download:b,children:"Download"}):null]}),w?null:s.jsx(G,{tone:"warning",children:"The file's bytes are no longer on this machine. What is known about it stays here; the download will not work."}),s.jsx(Q0,{artifactId:p.id,filename:p.filename,mime:p.mime,family:p.family,available:w}),s.jsx(bt,{items:[{label:"Origin",value:Rk(p,f)},...p.agentId&&p.origin==="produced"?[{label:"Made by",value:s.jsxs("span",{className:"files-agent",children:[s.jsx(bn,{agents:n,id:p.agentId,size:"sm"}),f(p.agentId)]})}]:[],{label:"Type",value:s.jsx("span",{className:"mono",children:p.mime})},{label:"Id",value:s.jsx("span",{className:"mono",children:p.id})}]}),s.jsxs("section",{className:"files-conversations",children:[s.jsx("h4",{className:"ui-section-title",children:"Conversations"}),m.length===0?s.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):s.jsx("ul",{className:"files-ctx",role:"list",children:m.map(v=>{const y=v.groupId?Ml(v.groupId,v.conversationId):De(v.conversationAgentId,v.conversationId),g=v.groupId?v.groupName??"a group":f(v.conversationAgentId);return s.jsxs("li",{className:"files-ctx-row",children:[s.jsxs("span",{className:"files-ctx-text",children:[s.jsx("span",{children:v.groupId?`Group: ${g}`:g}),s.jsxs("span",{className:"muted",children:[" · ",v.kind==="produced"?`made by ${f(v.agentId)||"an agent"}`:v.kind==="reused"?"sent again":"sent by you"," · ",Se(v.at)]})]}),s.jsx("a",{className:"ui-btn","data-size":"sm",href:y,onClick:S=>{S.preventDefault(),r(y)},children:"Open conversation"})]},`${v.conversationId}:${v.kind}`)})}),m.length<j?s.jsx(J,{align:"end",children:s.jsx(P,{size:"sm",onClick:x,disabled:a,children:a?"Loading…":`Show ${j-m.length} more`})}):null]})]})}const EO={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe"};function Tk(e){return e&&EO[e]||"plug"}function AO({attention:e,place:t,onNavigate:n,theme:r,onTheme:i,plugins:l=[]}){return s.jsxs("nav",{className:"rail","aria-label":"Places",children:[s.jsx("a",{className:"rail-mark",href:Ut,onClick:o=>{o.preventDefault(),n(Ut)},"aria-label":"buddi home",children:s.jsx(U0,{})}),tI.filter(o=>o.route!==Ht).map(o=>s.jsx(Ed,{label:o.label,href:o.route,active:t===o.route,badge:o.route===Ut?e:0,onClick:()=>n(o.route),children:Uv[o.route]},o.route)),l.map(o=>{const a=so(o.plugin,o.id);return s.jsx(Ed,{label:o.title,href:a,active:t===a,badge:0,onClick:()=>n(a),children:s.jsx(Oe,{name:Tk(o.icon)})},a)}),s.jsx("div",{className:"rail-spacer"}),s.jsx(Ed,{label:"Settings",href:Ht,active:t===Ht,badge:0,onClick:()=>n(Ht),children:Uv[Ht]}),s.jsx(TO,{theme:r,onTheme:i,onNavigate:n})]})}const RO=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function TO({theme:e,onTheme:t,onNavigate:n}){var o,a;const i=((a=(o=le(()=>A.owner(),[]).data)==null?void 0:o.preferredName)==null?void 0:a.trim())||null,l=(i??"You").slice(0,1).toUpperCase();return s.jsx("div",{className:"rail-owner",children:s.jsxs(Xp,{modal:!1,children:[s.jsx(Zp,{asChild:!0,children:s.jsx("button",{type:"button",className:"rail-owner-btn","aria-label":i?`You: ${i}`:"You",children:s.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:l})})}),s.jsx(em,{children:s.jsxs(tm,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[s.jsxs("div",{className:"rail-owner-head",children:[s.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:l}),s.jsxs("span",{className:"rail-owner-who",children:[s.jsx("span",{className:"rail-owner-name",children:i??"You"}),s.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),s.jsx(Jf,{className:"ui-menu-sep"}),s.jsx(nm,{className:"ui-menu-label",children:"Theme"}),s.jsx("div",{className:"rail-owner-theme",children:s.jsx(Oa,{label:"Theme",options:RO,value:e,onChange:t})}),s.jsx(Jf,{className:"ui-menu-sep"}),s.jsx(Qf,{className:"ui-menu-item",onSelect:()=>n(ht("appearance")),children:"Change appearance"}),s.jsx(Qf,{className:"ui-menu-item",onSelect:()=>n(om),children:"Run setup again"})]})})]})})}function Ed({label:e,href:t,active:n,badge:r,onClick:i,children:l}){return s.jsxs("a",{className:"rail-link",href:t,"data-active":n?"true":void 0,"aria-current":n?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:e,onClick:o=>{o.preventDefault(),i()},children:[s.jsxs("span",{className:"rail-icon",children:[l,r>0?s.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null]}),s.jsx("span",{className:"rail-label",children:e})]})}const Uv={[$r]:s.jsx(Oe,{name:"files"}),[Ut]:s.jsx(Oe,{name:"home"}),[Oi]:s.jsx(Oe,{name:"chat"}),[Xe]:s.jsx(Oe,{name:"agents"}),[Je]:s.jsx(Oe,{name:"activity"}),[Ht]:s.jsx(Oe,{name:"settings"})},Pk="buddi.theme";function PO(e=Ik()){try{const t=e==null?void 0:e.getItem(Pk);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function IO(e,t=Ik()){try{t==null||t.setItem(Pk,e)}catch{}}function MO(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function Ik(){try{return window.localStorage}catch{return}}const Mk="buddi.ground",$k="buddi.pageWidth";function $O(e=Dk()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},n=t(Mk),r=t($k);return{theme:PO(e),ground:n==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function _k(e,t=document.documentElement){t&&(MO(e.theme,t),e.ground==="sand"?t.setAttribute("data-ground","sand"):t.removeAttribute("data-ground"),e.width==="wide"?t.removeAttribute("data-width"):t.setAttribute("data-width",e.width))}function _O(e,t=Dk()){IO(e.theme,t);try{t==null||t.setItem(Mk,e.ground),t==null||t.setItem($k,e.width)}catch{}}let Ci=null;const kh=new Set;function Sh(){return Ci||(Ci=$O()),Ci}function OO(e){return kh.add(e),()=>kh.delete(e)}function DO(e){Ci={...Sh(),...e},_k(Ci),_O(Ci);for(const t of kh)t()}function Ok(){return[d.useSyncExternalStore(OO,Sh,Sh),DO]}function Dk(){try{return window.localStorage}catch{return}}function LO({timezone:e,embedded:t}){var p,m;const{data:n,error:r,reload:i}=le(()=>A.sentinels(),[],3e4),l=le(()=>A.missions(),[]),[o,a]=d.useState(null),c=((m=(p=l.data)==null?void 0:p.missions.find(j=>j.id==="sentinel-wake"))==null?void 0:m.agentId)??null,u=async(j,w)=>{a(null);try{await A.snoozeAlert(j,w),i()}catch(b){a(b instanceof Error?b.message:String(b))}},h=((n==null?void 0:n.open)??[]).filter(j=>!j.snoozedAt),f=((n==null?void 0:n.open)??[]).filter(j=>j.snoozedAt);return s.jsxs(en,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[s.jsx(ie,{message:r??o}),s.jsx(G,{children:"An alert closes on its own once the fact behind it changes: record the payment, update the balance, and the watcher clears it on its next run. Snooze one you have decided to live with; it stays quiet until it resolves."}),s.jsx(Ad,{title:"Open",findings:h,timezone:e,askAgentId:c,onSnooze:j=>u(j,!0),empty:"Nothing open. Your watchers are quiet."}),f.length>0?s.jsx(Ad,{title:"Snoozed",findings:f,timezone:e,askAgentId:c,onSnooze:j=>u(j,!1),empty:""}):null,s.jsx(Ad,{title:"Resolved",findings:(n==null?void 0:n.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),s.jsx(st,{title:"Waiting for the weekly recap",flush:!0,children:!n||n.digest.length===0?s.jsx(gt,{icon:"bell",title:"Nothing waiting for the recap"}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Title"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Noted"})]})}),s.jsx("tbody",{children:n.digest.map(j=>s.jsxs("tr",{children:[s.jsxs("td",{children:[_i(j.title),s.jsx(Fk,{text:_i(j.detail)})]}),s.jsx("td",{children:s.jsx(Lk,{severity:j.severity})}),s.jsx("td",{className:"nowrap",children:Pe(j.createdAt,e)})]},j.id))})]})})]})}function Lk({severity:e}){return s.jsx(fe,{tone:e==="urgent"?"critical":void 0,children:e})}function Fk({text:e}){const[t,n]=d.useState(!1),r=e.length>240||e.split(`
103
- `).length>3;return s.jsxs("div",{className:"sub alert-detail","data-clamp":r&&!t?"true":void 0,children:[e,r?s.jsx("button",{type:"button",className:"wb-link alert-more",onClick:()=>n(i=>!i),children:t?"Less":"More"}):null]})}function FO(e){return`About this alert: "${_i(e.title)}". ${_i(e.detail)}
104
-
105
- What should I do about it, and what do you need from me to clear it?`}function Ad({title:e,findings:t,timezone:n,askAgentId:r,onSnooze:i,empty:l}){const o=e==="Snoozed";return s.jsx(st,{title:e,flush:!0,children:t.length===0?s.jsx(oe,{children:l}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Finding"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Since"}),i?s.jsx("th",{}):null]})}),s.jsx("tbody",{children:t.map(a=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:_i(a.title)}),s.jsx(Fk,{text:_i(a.detail)}),a.data?s.jsx(Nt,{summary:"evidence",children:s.jsx(rt,{children:Xt(a.data)})}):null]}),s.jsx("td",{children:s.jsx(Lk,{severity:a.severity})}),s.jsxs("td",{className:"nowrap",children:[Pe(a.firstSeenAt,n),s.jsxs("div",{className:"sub",title:Pe(a.lastSeenAt,n),children:["last seen ",Se(a.lastSeenAt)]})]}),i?s.jsx("td",{children:s.jsxs(J,{align:"end",children:[r?s.jsx(Fn,{size:"sm",href:De(r,"new"),onClick:()=>D_(r,FO(a)),children:"Ask about it"}):null,s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(a.key),children:o?"Wake":"Snooze"})]})}):null]},a.key))})]})})}const Bv=5e3,zv=50;function UO({timezone:e,embedded:t}){var x;const[n,r]=d.useState(""),[i,l]=d.useState(""),[o,a]=d.useState(null),c=le(()=>A.eventKinds(),[]),{data:u,error:h}=le(()=>A.events({kind:n||void 0,q:i||void 0,limit:zv}),[n,i],Bv),[f,p]=d.useState({events:[],cursor:null,busy:!1,error:null});d.useEffect(()=>{p({events:[],cursor:null,busy:!1,error:null})},[n,i]);const m=f.events.length>0?f.cursor:(u==null?void 0:u.nextCursor)??null,j=async()=>{if(m){p(v=>({...v,busy:!0,error:null}));try{const v=await A.events({kind:n||void 0,q:i||void 0,before:m,limit:zv});p(y=>({events:[...y.events,...v.events],cursor:v.nextCursor,busy:!1,error:null}))}catch(v){p(y=>({...y,busy:!1,error:v instanceof Error?v.message:String(v)}))}}},w=new Set(((u==null?void 0:u.events)??[]).map(v=>v.id)),b=[...(u==null?void 0:u.events)??[],...f.events.filter(v=>!w.has(v.id))];return s.jsxs(en,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[s.jsxs(J,{children:[s.jsxs("select",{"aria-label":"Event kind",value:n,onChange:v=>r(v.target.value),children:[s.jsx("option",{value:"",children:"every kind"}),(((x=c.data)==null?void 0:x.kinds)??[]).map(v=>s.jsxs("option",{value:v.kind,children:[v.kind," (",v.count,")"]},v.kind))]}),s.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:v=>l(v.target.value),size:28}),n||i?s.jsx(P,{onClick:()=>{r(""),l("")},children:"Clear"}):null,s.jsxs("span",{className:"muted",children:["refreshes every ",Bv/1e3,"s"]})]}),s.jsx(ie,{message:h}),s.jsx(st,{flush:!0,children:!u||b.length===0?s.jsx(oe,{children:"No events match."}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"#"}),s.jsx("th",{children:"When"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Payload"})]})}),s.jsx("tbody",{children:b.map(v=>s.jsxs("tr",{"data-clickable":"true",onClick:()=>a(v),children:[s.jsx("td",{className:"mono muted",children:v.id}),s.jsxs("td",{className:"nowrap",children:[Pe(v.createdAt,e),s.jsx("div",{className:"sub",children:Se(v.createdAt)})]}),s.jsx("td",{className:"mono nowrap",children:v.kind}),s.jsx("td",{className:"mono muted",children:Cs(Xt(v.payload).replace(/\s+/g," "),120)})]},v.id))})]})}),m||f.error?s.jsxs(J,{children:[s.jsxs("span",{className:"muted",children:[b.length," shown",m?", older ones are kept":"","."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),f.error?s.jsx("span",{className:"critical",children:f.error}):null,m?s.jsx(P,{disabled:f.busy,onClick:()=>void j(),children:f.busy?"Loading…":"Load older"}):null]}):null,o?s.jsxs(Wt,{title:o.kind,onClose:()=>a(null),children:[s.jsxs("p",{className:"muted",children:["Event ",o.id," · ",Pe(o.createdAt,e),o.conversationId?s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:`#/conversations/${o.conversationId}`,children:"conversation"})]}):null]}),s.jsx(rt,{children:Xt(o.payload)})]}):null]})}const BO=["pending","leased","suspended","failed","succeeded","cancelled"],jl=50;function zO({timezone:e,embedded:t,initialState:n}){const[r,i]=d.useState(n??""),[l,o]=d.useState(null),[a,c]=d.useState(null),{data:u,error:h,reload:f}=le(()=>A.jobs({...r?{state:r}:{},limit:String(jl)}),[r],1e4),[p,m]=d.useState({jobs:[],done:!1,busy:!1});d.useEffect(()=>{m({jobs:[],done:!1,busy:!1})},[r]);const j=async()=>{m(N=>({...N,busy:!0}));try{const N=await A.jobs({...r?{state:r}:{},limit:String(jl),offset:String(jl+p.jobs.length)});m(C=>({jobs:[...C.jobs,...N.jobs],done:N.jobs.length<jl,busy:!1}))}catch(N){c(N instanceof Error?N.message:String(N)),m(C=>({...C,busy:!1}))}},w=new Set(((u==null?void 0:u.jobs)??[]).map(N=>N.id)),b=[...(u==null?void 0:u.jobs)??[],...p.jobs.filter(N=>!w.has(N.id))],x=r?(u==null?void 0:u.counts[r])??0:Object.values((u==null?void 0:u.counts)??{}).reduce((N,C)=>N+C,0),v=!p.done&&b.length<x&&((u==null?void 0:u.jobs.length)??0)>=jl,[y,g]=d.useState(null),S=async N=>{c(null),g(N);try{const C=(await A.jobs({state:"failed",limit:"500"})).jobs;for(const T of C)await(N==="retry"?A.retryJob(T.id):A.cancelJob(T.id));f()}catch(C){c(C instanceof Error?C.message:String(C))}finally{g(null)}},k=async N=>{c(null);try{await N,o(null),f()}catch(C){c(C instanceof Error?C.message:String(C))}};return s.jsxs(en,{embedded:t,title:"Jobs",lede:`${u!=null&&u.paused?"Paused: nothing is being claimed. ":""}Bounded retries with backoff; past the budget a job waits for you.`,actions:t?void 0:s.jsx(P,{size:"sm",variant:u!=null&&u.paused?"accent":void 0,onClick:()=>k(A.setPaused(!((u==null?void 0:u.paused)??!1))),children:u!=null&&u.paused?"Resume the queue":"Pause the queue"}),children:[s.jsxs(J,{children:[s.jsxs("select",{"aria-label":"Job state",value:r,onChange:N=>i(N.target.value),children:[s.jsx("option",{value:"",children:"every state"}),BO.map(N=>s.jsxs("option",{value:N,children:[N," (",(u==null?void 0:u.counts[N])??0,")"]},N))]}),((u==null?void 0:u.counts.failed)??0)>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("span",{className:"muted",children:[u.counts.failed," failed."]}),s.jsx(P,{size:"sm",disabled:y!==null,onClick:()=>void S("retry"),children:y==="retry"?"Retrying…":"Retry all failed"}),s.jsx(P,{size:"sm",variant:"danger",disabled:y!==null,onClick:()=>void S("cancel"),children:y==="cancel"?"Cancelling…":"Cancel all failed"})]}):null]}),s.jsx(ie,{message:h??a}),s.jsx(st,{flush:!0,children:!u||b.length===0?s.jsx(oe,{children:"No jobs match."}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"State"}),s.jsx("th",{className:"num",children:"Attempts"}),s.jsx("th",{children:"Last error"}),s.jsx("th",{children:"Updated"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:b.map(N=>s.jsxs("tr",{children:[s.jsxs("td",{className:"clickable",onClick:()=>o(N),children:[N.kind,s.jsx("div",{className:"sub mono",children:no(N.id)})]}),s.jsxs("td",{children:[s.jsx(au,{state:N.state}),N.suspendedReason?s.jsx("div",{className:"sub",children:Cs(N.suspendedReason,40)}):null]}),s.jsxs("td",{className:"num",children:[N.attempts,"/",N.maxAttempts]}),s.jsx("td",{className:N.lastError?"critical":"muted",children:N.lastError?Cs(N.lastError,80):"—"}),s.jsxs("td",{className:"nowrap",children:[Pe(N.updatedAt,e),s.jsx("div",{className:"sub",children:Se(N.updatedAt)})]}),s.jsx("td",{children:s.jsxs(J,{align:"end",children:[["failed","cancelled","suspended"].includes(N.state)?s.jsx(P,{size:"sm",onClick:()=>k(A.retryJob(N.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(N.state)?s.jsx(P,{size:"sm",variant:"danger",onClick:()=>k(A.cancelJob(N.id)),children:"Cancel"}):null]})})]},N.id))})]})}),v?s.jsxs(J,{children:[s.jsxs("span",{className:"muted",children:[b.length," of ",x," shown."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{disabled:p.busy,onClick:()=>void j(),children:p.busy?"Loading…":"Load older"})]}):null,l?s.jsxs(Wt,{title:l.kind,onClose:()=>o(null),children:[s.jsx("p",{className:"muted mono",children:l.id}),s.jsx(Y,{title:"Payload",children:s.jsx(rt,{children:Xt(l.payload)})}),s.jsx(Y,{title:"Result",children:s.jsx(rt,{children:Xt(l.result)})}),l.conversationId?s.jsx("p",{children:s.jsx("a",{href:`#/conversations/${l.conversationId}`,children:"open the transcript"})}):null]}):null]})}const WO=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function VO({hash:e,timezone:t,navigate:n,agents:r}){var u,h;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),l=f=>{var p;return((p=r.find(m=>m.id===f))==null?void 0:p.name)??f};if(i){let f=i[1];try{f=decodeURIComponent(f)}catch{}return s.jsx(GO,{id:f,timezone:t,navigate:n,nameOf:l})}const o=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",a=(h=/[?&]state=([a-z]+)/.exec(e))==null?void 0:h[1],c=f=>p=>{p.preventDefault(),n(f)};return s.jsxs("div",{className:"ui-page",children:[s.jsx(pm,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:s.jsx(QO,{})}),s.jsx(JO,{}),s.jsx(mm,{children:WO.map(f=>{const p=f.id==="conversations"?Je:`${Je}/${f.id}`;return s.jsx(gm,{href:p,active:o===f.id,onClick:c(p),children:f.label},f.id)})}),o==="conversations"?s.jsx(HO,{timezone:t,navigate:n,nameOf:l,agents:r}):null,o==="jobs"?s.jsx(zO,{timezone:t,embedded:!0,initialState:a},a??""):null,o==="approvals"?s.jsx(KO,{timezone:t,nameOf:l}):null,o==="alerts"?s.jsx(LO,{timezone:t,embedded:!0}):null,o==="events"?s.jsx(UO,{timezone:t,embedded:!0}):null]})}function HO({timezone:e,navigate:t,nameOf:n,agents:r}){const{data:i,error:l}=le(()=>A.conversations(),[],3e4);return s.jsxs(s.Fragment,{children:[s.jsx(ie,{message:l}),s.jsx(st,{flush:!0,children:i?i.conversations.length===0?s.jsx(gt,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):s.jsx(un,{children:i.conversations.map(o=>s.jsx(Cn,{href:Di(o.id),onClick:()=>t(Di(o.id)),lead:s.jsx(bn,{agents:r,id:o.agentId,size:"sm"}),title:o.opening?Cs(o.opening,100):"Untitled conversation",sub:`${n(o.agentId)}, ${o.messageCount} message${o.messageCount===1?"":"s"}, ${o.runs} run${o.runs===1?"":"s"}, ${Mt(o.usage.input)} in / ${Mt(o.usage.output)} out`,side:s.jsx("span",{title:Pe(o.lastMessageAt??o.createdAt,e),children:Se(o.lastMessageAt??o.createdAt)})},o.id))}):s.jsx(oe,{children:"Loading…"})})]})}function KO({timezone:e,nameOf:t}){const{data:n,error:r}=le(()=>A.approvals(),[],1e4),i=[...(n==null?void 0:n.pending)??[],...(n==null?void 0:n.recent)??[]];return s.jsxs(s.Fragment,{children:[s.jsx(ie,{message:r}),s.jsx(st,{flush:!0,children:n?i.length===0?s.jsx(gt,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Tool"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Asked by"}),s.jsx("th",{children:"Decided"}),s.jsx("th",{children:"Created"})]})}),s.jsx("tbody",{children:i.map(l=>s.jsxs("tr",{children:[s.jsxs("td",{children:[l.tool,s.jsx("div",{className:"sub mono",children:no(l.id)})]}),s.jsx("td",{children:s.jsx(au,{state:l.state})}),s.jsx("td",{children:t(l.agentId)}),s.jsx("td",{className:"nowrap",children:l.decidedAt?s.jsxs(s.Fragment,{children:[Pe(l.decidedAt,e),s.jsxs("div",{className:"sub",children:["via ",l.decidedVia??"—"]})]}):s.jsx("span",{className:"muted",children:"—"})}),s.jsxs("td",{className:"nowrap",children:[Pe(l.createdAt,e),s.jsx("div",{className:"sub",children:Se(l.createdAt)})]})]},l.id))})]}):s.jsx(oe,{children:"Loading…"})})]})}function GO({id:e,timezone:t,navigate:n,nameOf:r}){const[i,l]=d.useState(null),[o,a]=d.useState(null);d.useEffect(()=>{let u=!1;return A.conversation(e).then(h=>{u||l(h)}).catch(h=>{u||a(h instanceof Error?h.message:String(h))}),()=>{u=!0}},[e]);const c=u=>h=>{h.preventDefault(),n(u)};return s.jsxs("div",{className:"ui-page",children:[s.jsx("p",{className:"page-crumbs",children:s.jsx("a",{href:Je,onClick:c(Je),children:"Activity"})}),s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[s.jsx(P,{size:"sm",onClick:()=>n(Je),children:"← Back"}),s.jsx("span",{children:"Transcript"})]}),i?s.jsx("div",{className:"ui-page-actions",children:s.jsx(Fn,{size:"sm",href:De(i.agentId,e),onClick:c(De(i.agentId,e)),children:"Open in chat"})}):null]}),s.jsx("p",{className:"ui-page-lede mono",children:e})]}),s.jsx(ie,{message:o}),i?s.jsxs(s.Fragment,{children:[s.jsxs(cu,{children:[s.jsx(Xn,{label:"Agent",value:r(i.agentId),size:"sm"}),s.jsx(Xn,{label:"Runs",value:i.runs.length}),s.jsx(Xn,{label:"Tokens",value:`${Mt(i.usage.input)} / ${Mt(i.usage.output)}`,note:"input / output"}),s.jsx(Xn,{label:"Started",value:Pe(i.createdAt,t),size:"sm"})]}),i.runs.length>0?s.jsx(st,{title:"Runs",flush:!0,children:s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{className:"num",children:"Turns"}),s.jsx("th",{children:"Stopped"}),s.jsx("th",{className:"num",children:"Tokens"})]})}),s.jsx("tbody",{children:i.runs.map((u,h)=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Pe(u.startedAt,t)," ",u.resumed?s.jsx(fe,{children:"resumed"}):null]}),s.jsx("td",{className:"nowrap",children:Pe(u.finishedAt,t)}),s.jsx("td",{className:"num",children:u.turns??"—"}),s.jsxs("td",{children:[u.stopped??"—",u.actionId?s.jsxs("div",{className:"sub mono",children:["action ",no(u.actionId)]}):null]}),s.jsxs("td",{className:"num muted nowrap",children:[Mt(u.usage.input)," / ",Mt(u.usage.output)]})]},h))})]})}):null,s.jsx(Y,{title:"Messages",children:s.jsx(q,{children:i.messages.map(u=>s.jsxs("article",{className:"transcript-msg",children:[s.jsxs("header",{className:"transcript-who",children:[u.speaker===Wv?"approved action, result":u.role,", ",Pe(u.createdAt,t)]}),s.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?s.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===Wv?u.blocks.map((h,f)=>s.jsx(YO,{block:h},f)):u.blocks.map((h,f)=>s.jsx(qO,{block:h},f))]})]},u.id))})})]}):s.jsx(oe,{children:"Loading…"})]})}const Wv="approval:resume";function YO({block:e}){return s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),s.jsx(rt,{children:e.type==="text"?e.text??"":Xt(e)})]})}function qO({block:e}){return e.type==="text"?s.jsx("div",{className:"transcript-text",children:s.jsx(_r,{text:e.text??""})}):e.type==="thinking"?s.jsxs("details",{className:"transcript-thinking",children:[s.jsx("summary",{children:"Thoughts"}),s.jsx("div",{className:"transcript-thinking-text",children:s.jsx(_r,{text:e.text??""})})]}):e.type==="tool_use"?s.jsxs("div",{className:"transcript-tool",children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),s.jsx(rt,{children:Xt(e.input)})]}):e.type==="tool_result"?s.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),s.jsx(rt,{children:e.content??""})]}):s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:e.type}),s.jsx(rt,{children:Xt(e.ref)})]})}function QO(){const{data:e,reload:t}=le(()=>A.overview(),[],1e4),[n,r]=d.useState(!1);if(!e)return null;const i=()=>{r(!0),A.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return s.jsx(P,{size:"sm",variant:e.paused?"accent":void 0,disabled:n,onClick:i,children:e.paused?"Resume all":"Pause all"})}function JO(){const{data:e}=le(()=>A.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,n=t("leased");return s.jsxs(cu,{children:[s.jsx(Xn,{label:"Jobs done",value:Mt(t("succeeded"))}),s.jsx(Xn,{label:"Failed",value:Mt(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),s.jsx(Xn,{label:"Queued",value:Mt(t("pending")),note:`${n} running`}),s.jsx(Xn,{label:"Approvals",value:Mt(e.approvals.pending),note:"waiting for you"})]})}const XO=["replay-all","coalesce","latest-only","skip-after-deadline"];function Uk({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:l}=le(()=>A.missions(),[],3e4),o=((r==null?void 0:r.missions)??[]).filter(h=>!n||h.agentId===n),[a,c]=d.useState(null),u=async h=>{c(null);try{await h,l()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.jsxs(en,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[s.jsx(ie,{message:i??a}),!r||o.length===0?s.jsxs(gt,{icon:"calendar",title:"No missions yet",children:["Run ",s.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):s.jsx(q,{children:o.map(h=>s.jsx(ZO,{mission:h,timezone:e,onRun:u},h.id))})]})}function ZO({mission:e,timezone:t,onRun:n}){const[r,i]=d.useState(!1);return s.jsxs(Or,{tone:e.enabled?"good":"muted",title:s.jsxs(s.Fragment,{children:[e.name," ",s.jsx("span",{className:"mono muted",children:e.id})]}),meta:s.jsxs(s.Fragment,{children:[s.jsx(fe,{mono:!0,children:e.agentId}),e.alwaysDeliver?s.jsx(fe,{children:"always delivers"}):null,e.enabled?null:s.jsx(fe,{tone:"warning",children:"disabled"})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",onClick:()=>n(A.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(l=>!l),"aria-expanded":r,children:r?"Less":"More"})]}),children:[s.jsxs("p",{className:"ui-card-meta",children:[e.schedule?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${Pe(e.nextRun,t)} (${Se(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",s.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${Se(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?s.jsxs("div",{className:"ui-card-foot",children:[e.schedule?s.jsxs(J,{children:[s.jsx(ee,{inline:!0,label:"Misfire policy",children:s.jsx("select",{value:e.schedule.misfirePolicy,onChange:l=>n(A.setMisfirePolicy(e.id,l.target.value)),children:XO.map(l=>s.jsx("option",{value:l,children:l},l))})}),s.jsx("span",{className:"muted",children:"What a week asleep does: replay every instant, coalesce into one, keep only the latest, or skip past a deadline."})]}):null,s.jsx(Y,{title:"Prompt",children:s.jsx(rt,{children:e.prompt})}),s.jsx(Y,{title:"Recent occurrences",children:s.jsx(st,{flush:!0,children:e.occurrences.length===0?s.jsx(oe,{children:"Never run."}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Scheduled"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{children:"Detail"})]})}),s.jsx("tbody",{children:e.occurrences.map(l=>s.jsxs("tr",{children:[s.jsx("td",{className:"nowrap",children:Pe(l.scheduledAt,t)}),s.jsx("td",{children:s.jsx(au,{state:l.state})}),s.jsx("td",{className:"nowrap",children:Pe(l.finishedAt,t)}),s.jsxs("td",{className:l.error?"critical":"muted",children:[l.error?Cs(l.error,120):null,l.runConversationId?s.jsx("a",{href:`#/conversations/${l.runConversationId}`,children:"transcript"}):null]})]},l.id))})]})})})]}):null]})}function eD(e,t){const n=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${n}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function Bk({ids:e,agentName:t,onDone:n}){const r=e.length,[i,l]=d.useState(!1),[o,a]=d.useState(!1);return r<=0?null:i?s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:eD(r,t)}),s.jsx(P,{size:"sm",variant:"danger",disabled:o,onClick:()=>{a(!0),A.dismissOffers(e).then(()=>{l(!1),n()}).finally(()=>a(!1))},children:`Dismiss ${r}`}),s.jsx(P,{size:"sm",variant:"ghost",disabled:o,onClick:()=>l(!1),children:"Keep them"})]}):s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>l(!0),children:"Dismiss all"})}function zk({embedded:e,agentId:t,agentName:n}){const{data:r,error:i,reload:l}=le(()=>A.offers(),[],2e4),o=x=>!t||x.agentId===t,a=((r==null?void 0:r.offers)??[]).filter(o),c=((r==null?void 0:r.closed)??[]).filter(o),[u,h]=d.useState(null),[f,p]=d.useState(null),[m,j]=d.useState(null),w=async(x,v)=>{h(null),p(x);try{const y=await A.takeOffer(x);j(y.jobId?`On it — ${v}. Started as job ${y.jobId}.`:`Taken — ${v}. No worker is running here, so nothing has started yet.`),l()}catch(y){h(y instanceof Error?y.message:String(y))}finally{p(null)}},b=async(x,v)=>{h(null),p(x);try{await A.dismissOffer(x),j(`Dismissed — ${v}. It will not come back.`),l()}catch(y){h(y instanceof Error?y.message:String(y))}finally{p(null)}};return s.jsxs(en,{embedded:e,title:"Offers",lede:"Things an agent already worked out that you might want done. Taking one asks that agent the sentence it wrote. It authorizes nothing, and anything that would leave this machine still comes back to you as an approval.",children:[s.jsx(ie,{message:i??u}),m?s.jsx(G,{tone:"good",role:"status",children:m}):null,a.length>0?s.jsxs(J,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(Bk,{ids:a.map(x=>x.id),agentName:n,onDone:()=>{j(null),l()}})]}):null,!r||a.length===0?s.jsx(gt,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):s.jsx(q,{children:a.map(x=>s.jsx(Or,{tone:"accent",title:x.label,meta:s.jsxs(s.Fragment,{children:[s.jsx(fe,{mono:!0,children:x.agentId}),s.jsxs("span",{className:"muted",children:["expires ",Se(x.expiresAt)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",variant:"ghost",disabled:f===x.id,onClick:()=>void b(x.id,x.label),children:"Not now"}),s.jsx(P,{variant:"accent",size:"sm",disabled:f===x.id,onClick:()=>void w(x.id,x.label),children:"Take"})]}),children:s.jsx("p",{className:"ui-card-meta",children:x.prompt})},x.id))}),c.length>0?s.jsxs(Nt,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[s.jsx(st,{flush:!0,children:s.jsx(un,{children:c.map(x=>s.jsx(Cn,{title:x.label,sub:`${x.agentId} — ${pR(x)}`,side:Se(x.dismissedAt??x.lapsedAt??x.createdAt)},x.id))})}),s.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const tD=["fact","observation","todo"];function Wk({embedded:e,agents:t,timezone:n,agentId:r}){const{data:i,error:l,reload:o}=le(()=>A.memory(r),[r],3e4),[a,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),m=g=>{var S;return g==="shared"?"Everyone":((S=t.find(k=>k.id===g))==null?void 0:S.name)??g},j=async g=>{p(null);try{await g,o()}catch(S){p(S instanceof pe?S.message:String(S))}},w={nameOf:m,timezone:n,onChangePreference:g=>c({key:g.key,scope:g.scope}),onForgetPreference:g=>void j(A.forgetPreference({key:g.key,scope:g.scope})),onEditNote:g=>h(g),onForgetNote:g=>void j(A.forgetNote(g.id))},b=r?m(r):"",x=r&&i?{preferences:i.preferences.filter(g=>g.scope===r),notes:i.notes.filter(g=>g.scope===r)}:null,v=r&&i?{preferences:i.preferences.filter(g=>g.scope==="shared"),notes:i.notes.filter(g=>g.scope==="shared")}:null,y=s.jsx(P,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return s.jsxs(en,{embedded:e,title:"Memory",lede:"What your agents have kept about you. Correct anything here; they see the change on their next turn.",children:[s.jsx(ie,{message:l??f}),x&&v?s.jsxs(q,{gap:"lg",children:[s.jsx(Y,{title:"Preferences",aside:`what you told ${b} alone`,actions:y,panel:!0,flush:!0,children:s.jsx(Rd,{preferences:x.preferences,empty:`Nothing stated to ${b} alone yet.`,...w})}),s.jsx(Y,{title:"Notes",aside:`what ${b} wrote down for itself`,panel:!0,flush:!0,children:s.jsx(Td,{notes:x.notes,empty:`${b} has kept no private notes yet.`,...w})}),s.jsx(Nt,{summary:`Shared with every agent, which ${b} also reads · ${v.preferences.length} preferences, ${v.notes.length} notes`,children:s.jsxs(q,{gap:"lg",children:[s.jsx(Y,{title:"Shared preferences",panel:!0,flush:!0,children:s.jsx(Rd,{preferences:v.preferences,empty:"No shared preferences.",...w})}),s.jsx(Y,{title:"Shared notes",panel:!0,flush:!0,children:s.jsx(Td,{notes:v.notes,empty:"No shared notes.",...w})})]})})]}):s.jsxs(q,{gap:"lg",children:[s.jsx(Y,{title:"Preferences",aside:"what you said you want, one current value each",actions:y,panel:!0,flush:!0,children:i?s.jsx(Rd,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...w}):s.jsx(oe,{children:"Loading…"})}),s.jsx(Y,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?s.jsx(Td,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...w}):s.jsx(oe,{children:"Loading…"})})]}),a?s.jsx(nD,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:a,onClose:()=>c(null),onSave:async g=>{await j((async()=>{await A.setPreference(g),a.key===g.key&&a.scope!==g.scope&&await A.forgetPreference({key:a.key,scope:a.scope})})()),c(null)}}):null,u?s.jsx(sD,{note:u,agents:t,onClose:()=>h(null),onSave:g=>j(A.updateNote(u.id,g)).then(()=>h(null))}):null]})}function Rd({preferences:e,empty:t,nameOf:n,onChangePreference:r,onForgetPreference:i}){return e.length===0?s.jsx(oe,{children:t}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Preference"}),s.jsx("th",{children:"Value"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{className:"num",children:"Since"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:l.key}),s.jsx("td",{children:l.value}),s.jsx("td",{children:s.jsx(Vk,{scope:l.scope,name:n(l.scope)})}),s.jsxs("td",{className:"num muted",title:l.updatedAt??"",children:[l.updatedAt?Se(l.updatedAt,Date.now()):"",l.revision>1?` · rev ${l.revision}`:""]}),s.jsx("td",{className:"num",children:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",onClick:()=>r(l),title:"Store a new value for this key",children:"Change"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(l),children:"Forget"})]})})]},`${l.scope}:${l.key}`))})]})}function Td({notes:e,empty:t,nameOf:n,timezone:r,onEditNote:i,onForgetNote:l}){return e.length===0?s.jsx(oe,{children:t}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Note"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{children:"Written by"}),s.jsx("th",{className:"num",children:"When"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"memory-note",children:o.content}),s.jsx("td",{children:s.jsx(fe,{tone:o.kind==="todo"?"warning":o.kind==="fact"?"good":void 0,children:o.kind})}),s.jsx("td",{children:s.jsx(Vk,{scope:o.scope,name:n(o.scope)})}),s.jsx("td",{className:"muted",children:o.createdByAgent?n(o.createdByAgent):""}),s.jsxs("td",{className:"num muted",title:o.createdAt??"",children:[o.createdAt?Se(o.createdAt,Date.now()):"",o.expiresAt?s.jsxs("span",{className:"memory-expires",children:[" · until ",new Date(o.expiresAt).toLocaleDateString(void 0,{timeZone:r})]}):null]}),s.jsx("td",{className:"num",children:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",onClick:()=>i(o),children:"Edit"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>l(o),children:"Forget"})]})})]},o.id))})]})}function Vk({scope:e,name:t}){return s.jsx(fe,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function Hk({value:e,agents:t,onChange:n}){return s.jsxs("select",{value:e,onChange:r=>n(r.target.value),children:[s.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>s.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function nD({agents:e,existing:t,initial:n,onClose:r,onSave:i}){const l=t.find(v=>v.key===n.key&&v.scope===n.scope),[o,a]=d.useState(n.key),[c,u]=d.useState((l==null?void 0:l.value)??""),[h,f]=d.useState(n.scope),[p,m]=d.useState(!1),j=o.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(v=>v.key===j&&v.scope===h),b=!l||j!==l.key||c.trim()!==l.value||h!==l.scope,x=j!==""&&c.trim()!==""&&b;return s.jsx(Wt,{title:"A preference",onClose:r,children:s.jsxs(q,{children:[s.jsx(G,{children:'A preference is a standing choice, in your words: "paid biweekly on Thursdays", "answers short, numbers first". Storing the same key again records a correction and keeps the old value in the history.'}),s.jsx(ee,{label:"Key",hint:j&&j!==o?`Stored as ${j}`:"Short and stable, like reporting_currency or tone.",children:s.jsx("input",{value:o,autoFocus:n.key==="",onChange:v=>a(v.target.value),placeholder:"reporting_currency"})}),s.jsx(ee,{label:"Value",children:s.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:n.key!=="",onChange:v=>u(v.target.value),placeholder:"EUR"})}),s.jsx(ee,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:s.jsx(Hk,{value:h,agents:e,onChange:f})}),w&&w!==l?s.jsxs(G,{tone:"warning",children:['This replaces the value already stored for this key here, "',w.value,'" (revision ',w.revision,")."]}):null,l&&h!==l.scope?s.jsxs(G,{children:["It moves: the copy for ",l.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:r,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!x||p,onClick:()=>{m(!0),i({key:j,value:c.trim(),scope:h}).finally(()=>m(!1))},children:l?"Save change":"Save"})]})]})})}function sD({note:e,agents:t,onClose:n,onSave:r}){var m;const[i,l]=d.useState(e.content),[o,a]=d.useState(e.scope),[c,u]=d.useState(e.kind),[h,f]=d.useState(!1),p=i.trim()!==e.content||o!==e.scope||c!==e.kind;return s.jsx(Wt,{title:"A note",onClose:n,children:s.jsxs(q,{children:[s.jsx(ee,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:s.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:j=>l(j.target.value)})}),s.jsxs(Es,{children:[s.jsx(ee,{label:"Kind",children:s.jsx("select",{value:c,onChange:j=>u(j.target.value),children:tD.map(j=>s.jsx("option",{value:j,children:j},j))})}),s.jsx(ee,{label:"Who sees it",children:s.jsx(Hk,{value:o,agents:t,onChange:a})})]}),e.createdByAgent?s.jsxs("p",{className:"muted",children:["Written by ",((m=t.find(j=>j.id===e.createdByAgent))==null?void 0:m.name)??e.createdByAgent,e.createdAt?`, ${Se(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!p||i.trim()===""||h,onClick:()=>{f(!0);const j={};i.trim()!==e.content&&(j.content=i.trim()),o!==e.scope&&(j.scope=o),c!==e.kind&&(j.kind=c),r(j).finally(()=>f(!1))},children:"Save"})]})]})})}function rD({agentId:e,agentName:t}){const{data:n,error:r,reload:i}=le(()=>A.agentSkills(e),[e],3e4),[l,o]=d.useState(null),[a,c]=d.useState(null),[u,h]=d.useState(null),f=async j=>{o(null),c(null),h(j.name);try{const w=await A.removeSkill(e,j.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){o(w instanceof pe?w.message:String(w))}finally{h(null)}};if(!n)return r?s.jsx(ie,{message:r}):s.jsx(oe,{children:"Loading…"});const p=n.skills.filter(j=>j.learned!==null),m=n.skills.filter(j=>j.learned===null);return s.jsxs(q,{divided:!0,children:[s.jsx(ie,{message:r??l}),a?s.jsx(G,{tone:"good",role:"status",children:a}):null,s.jsx(Y,{title:"Learned",aside:s.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:p.length===0?s.jsx(gt,{icon:"bulb",title:"Nothing learned yet",children:n.writable?`When ${t} proposes a procedure and you keep it on Settings → Proposals, it appears here.`:`${t} ships with buddi, so it keeps no learned skills of its own until it is yours.`}):s.jsx(st,{flush:!0,children:s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"Version"}),s.jsx("th",{children:"Came from"}),s.jsx("th",{className:"num",children:"Kept"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:p.map(j=>s.jsx(lD,{skill:j,busy:u===j.name,onRemove:()=>void f(j)},j.name))})]})})}),s.jsx(Y,{title:"From files and plugins",aside:s.jsx("span",{className:"muted",children:"read-only here"}),children:m.length===0?s.jsx(oe,{children:"No other skills."}):s.jsx(st,{flush:!0,children:s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"What it is for"}),s.jsx("th",{children:"Whose"})]})}),s.jsx("tbody",{children:m.map(j=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(Nt,{summary:s.jsx("span",{className:"mono",children:j.name}),children:[s.jsx(rt,{children:j.body}),s.jsx("p",{className:"muted mono skill-file",children:j.file})]})}),s.jsx("td",{children:j.description}),s.jsx("td",{children:s.jsxs(q,{gap:"sm",children:[s.jsx(fe,{children:j.scope==="shared"?"shared":`${t} only`}),s.jsx("span",{className:"muted",children:iD(j)})]})})]},`${j.scope}:${j.name}`))})]})})})]})}function iD(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function lD({skill:e,busy:t,onRemove:n}){const r=e.learned;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(Nt,{summary:s.jsxs("span",{children:[r.title," ",s.jsx("span",{className:"muted mono",children:e.name})]}),children:[s.jsxs("p",{className:"muted",children:["When: ",e.description]}),s.jsx(rt,{children:e.body}),s.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),s.jsx("td",{children:s.jsxs(q,{gap:"sm",children:[s.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?s.jsx(fe,{tone:"warning",children:"untrusted text in view"}):null]})}),s.jsx("td",{children:s.jsxs(q,{gap:"sm",children:[r.conversation?s.jsx("a",{href:Di(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):s.jsx("span",{className:"muted",children:"no conversation"}),s.jsx("a",{href:ht("proposals"),children:"the proposal"}),r.sources.length>0?s.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>s.jsx("li",{className:"mono",children:i},i))}):null]})}),s.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?Se(r.keptAt,Date.now()):""}),s.jsx("td",{className:"num",children:s.jsx(J,{align:"end",children:s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:n,children:"Remove"})})})]})}function Kk({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:l}=le(()=>A.reminders(),[],3e4),o=((r==null?void 0:r.reminders)??[]).filter(h=>!n||h.agentId===n),[a,c]=d.useState(null),u=async h=>{c(null);try{await A.cancelReminder(h),l()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.jsxs(en,{embedded:t,title:"Reminders",lede:"A reminder wakes an agent with a note and the instruction to check before it speaks, never a message queued for delivery.",children:[s.jsx(ie,{message:i??a}),s.jsx(st,{flush:!0,children:r?o.length===0?s.jsx(gt,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Due"}),s.jsx("th",{children:"Agent"}),s.jsx("th",{children:"Note"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:o.map(h=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Pe(h.dueAt,e),s.jsx("div",{className:"sub",children:Se(h.dueAt)})]}),s.jsx("td",{className:"mono",children:h.agentId}),s.jsxs("td",{children:[h.text,h.context?s.jsx(Nt,{summary:"context",children:s.jsx(rt,{children:Xt(h.context)})}):null]}),s.jsxs("td",{children:[s.jsx(au,{state:h.state}),h.cancelReason?s.jsx("div",{className:"sub",children:h.cancelReason}):null]}),s.jsx("td",{children:h.state==="pending"?s.jsx(P,{size:"sm",variant:"danger",onClick:()=>u(h.id),children:"Cancel"}):null})]},h.id))})]}):s.jsx(oe,{children:"Loading…"})})]})}function Mm({accountId:e,label:t,value:n,onChange:r,disabled:i=!1}){const[l,o]=d.useState(null),[a,c]=d.useState(!1),[u,h]=d.useState(""),[f,p]=d.useState(!1),m=d.useRef(0),j=async v=>{if(!e)return;const y=++m.current;c(!0),h("");try{const g=await A.accountModels(e,v);y===m.current&&o(g)}catch(g){y===m.current&&h(g instanceof Error?g.message:"Could not load models. Custom entry is still available.")}finally{y===m.current&&c(!1)}};if(d.useEffect(()=>(o(null),p(!1),h(""),j(!1),()=>{m.current++}),[e]),!e)return s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:t,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:v=>r(v.target.value)})}),s.jsx("p",{className:"ui-toolbar-note",children:"Save and connect the account to load its model list. You can enter a model manually now."})]});const w=(l==null?void 0:l.models)??[],b=!!n&&!w.some(v=>v.id===n),x=[l&&!w.length?"This account returned no models. You can enter a custom model.":null,l!=null&&l.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,l?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:t,children:s.jsxs("select",{value:f?"__buddi_custom__":n,disabled:i,onChange:v=>{v.target.value==="__buddi_custom__"?p(!0):(p(!1),r(v.target.value))},children:[s.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),b&&s.jsxs("option",{value:n,children:[n," (current",l?", not listed":"",")"]}),w.map(v=>s.jsxs("option",{value:v.id,children:[v.name===v.id?v.id:`${v.name} — ${v.id}`,v.isDefault?" (provider default)":""]},v.id)),s.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),s.jsx(P,{disabled:i||a,onClick:()=>void j(!0),children:a?"Loading models…":"Refresh models"}),f&&s.jsx(ee,{label:`Custom ${t.toLowerCase()}`,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:v=>r(v.target.value)})}),u&&s.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),x.length>0&&s.jsx("p",{className:"ui-toolbar-note",children:x.join(" ")})]})}function oD(e,t){const n=new Set(t),r=[],i=new Set;for(const l of e){for(const a of l.tools)i.add(a.name);const o=l.tools.filter(a=>n.has(a.name));o.length!==0&&(l.glob&&o.length===l.tools.length?r.push(l.glob):r.push(...o.map(a=>a.name)))}return r.push(...t.filter(l=>!i.has(l))),r}function aD(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const cD="This agent will not remember anything between conversations.";function uD({view:e,chosen:t,onChange:n,disabled:r}){var S;const[i,l]=d.useState(""),[o,a]=d.useState(null),[c,u]=d.useState(()=>new Set),h=k=>u(N=>{const C=new Set(N);return C.has(k)?C.delete(k):C.add(k),C}),f=k=>{l(k),u(new Set)},p=d.useId(),m=new Set(t),j=new Set(e.groups.flatMap(k=>k.tools.filter(N=>N.core).map(N=>N.name))),w=(k,N)=>{const C=N.filter(T=>m.has(T));if(C.length!==0){if(C.some(T=>j.has(T))){a({plugin:k,names:C});return}n(t.filter(T=>!C.includes(T)))}},b=k=>{n([...t,...k.filter(N=>!m.has(N))])},x=i.trim().toLowerCase(),v=(k,N)=>x===""||k.toLowerCase().includes(x)||N.toLowerCase().includes(x),y=e.groups.map(k=>({group:k,tools:k.tools.filter(N=>v(N.name,N.description))})).filter(k=>k.tools.length>0),g=(((S=e.suggested)==null?void 0:S.tools)??[]).filter(k=>!m.has(k.name));return s.jsxs("div",{className:"tool-picker",children:[e.suggested&&g.length>0?s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${p}-suggested`,children:[s.jsx("div",{className:"tool-picker-head",children:s.jsx("span",{id:`${p}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),s.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:g.map(k=>s.jsxs("li",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title mono",children:k.name}),s.jsx("span",{className:"ui-list-sub",children:k.description})]}),s.jsx(P,{size:"sm",disabled:r,"aria-label":`Add ${k.name}`,onClick:()=>b([k.name]),children:"Add"})]},k.name))})]}):null,s.jsxs("label",{className:"tool-picker-search",children:[s.jsx("span",{className:"ui-field-label",children:"Find a tool"}),s.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:k=>f(k.target.value)})]}),y.length===0?s.jsxs(oe,{children:["No installed tool matches “",i.trim(),"”."]}):null,y.map(({group:k,tools:N})=>{const C=k.tools.filter(R=>R.grantable).map(R=>R.name),T=k.tools.filter(R=>m.has(R.name)).length,E=!!k.glob&&T===k.tools.length,U=`${p}-${k.plugin}`,H=`${p}-${k.plugin}-list`,O=x!==""?!c.has(k.plugin):c.has(k.plugin);return s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":U,"data-open":O?"true":void 0,children:[s.jsxs("div",{className:"tool-picker-head",children:[s.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":O,"aria-controls":H,onClick:()=>h(k.plugin),children:[s.jsx(dD,{}),s.jsx("span",{id:U,className:"tool-picker-plugin",children:k.plugin}),s.jsx("span",{className:"muted",children:E?`all ${k.tools.length}`:`${T} of ${k.tools.length} granted`})]}),s.jsx(P,{size:"sm",variant:"ghost","aria-label":`All ${k.plugin} tools`,disabled:r||C.every(R=>m.has(R)),onClick:()=>b(C),children:"all"}),s.jsx(P,{size:"sm",variant:"ghost","aria-label":`No ${k.plugin} tools`,disabled:r||!C.some(R=>m.has(R)),onClick:()=>w(k.plugin,C),children:"none"})]}),(o==null?void 0:o.plugin)===k.plugin?s.jsx(G,{tone:"warning",role:"alert",children:s.jsxs("div",{className:"tool-picker-confirm",children:[s.jsx("span",{children:cD}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{size:"sm",onClick:()=>a(null),children:"Keep"}),s.jsx(P,{size:"sm",variant:"danger",onClick:()=>{n(t.filter(R=>!o.names.includes(R))),a(null)},children:"Remove"})]})}):null,s.jsx("ul",{id:H,className:"ui-list tool-picker-list",hidden:!O,children:N.map(R=>{const F=`${p}-${R.name}`;return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:F,checked:m.has(R.name),disabled:r||!R.grantable,onChange:K=>K.target.checked?b([R.name]):w(k.plugin,[R.name])}),s.jsxs("label",{htmlFor:F,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[s.jsx("span",{className:"mono",children:R.name}),R.core?s.jsx(fe,{tone:"accent",children:"core"}):null,R.gated?s.jsx(fe,{tone:"warning",children:"asks you"}):null]}),s.jsx("span",{className:"ui-list-sub",children:R.grantable?R.description:`${R.description} Granted only by editing the file by hand.`})]})]},R.name)})})]},k.plugin)})]})}function dD(){return s.jsx("svg",{className:"tool-picker-chevron",viewBox:"0 0 11 11","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const fD="buddi",hD=["core","coding","finance","garage","mail","maker","playground","research"],du=e=>`./mascot/${e}.png`,pD=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],mD="Introduce yourself by name, say one thing you can do today, and ask one question.",z={opening:["Hi. I'm buddi. I live on this computer, and I'm about to introduce you to your first assistant.","Nothing you tell me leaves this machine, except what your assistant sends to the AI you pick in a minute."],later:"Set up later",name:{ask:"First, what should we call you?",placeholder:"Your first name",submit:"That's me"},clock:{ask:(e,t)=>`Nice to meet you, ${e}. I'll set your clock to ${t}, which is what this browser says. Right?`,yes:"Yes",another:"Pick another",label:"Your clock",answer:e=>e},brain:{ask:"Your assistant needs a brain: an AI it thinks with. Which of these do you already have?",cards:{claude:{title:"Claude",line:"I pay for Claude"},key:{title:"A key from Anthropic or OpenAI",line:"I have an API key"},ollama:{title:"Ollama",line:"Free, on this computer"},service:{title:"Ollama Cloud, or another service",line:"I have an address and a key"}},claude:{start:"Sign in with Claude",open:"Open the Claude sign-in page",paste:"Paste what Claude gave you",finish:"Done",waiting:"Sign in, then paste the code Claude shows you."},key:{field:"Your key",placeholder:"Paste it here",submit:"Use this key",which:"Not right?",anthropic:"Anthropic",openai:"OpenAI",refused:"That key was refused. Check it and paste it again."},ollama:{found:"Found it, running now",missing:"Install Ollama, then come back",connect:"Use Ollama",download:"Get Ollama",looking:"Looking for it on this computer…"},model:{ask:"Which one should it think with?",label:"The model",submit:"Use this one"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking Ollama…",claude:"Checking with Claude…"},back:"Back",service:{address:"Address",addressPlaceholder:"The address they gave you",key:"Key",submit:"Connect it"},works:e=>`That works. Your assistant will think with ${e}.`,refused:e=>e,answer:e=>e},browser:{chrome:"Your assistant will browse with Google Chrome.",chromium:"Your assistant will browse with its own Chromium.",needs:"Your assistant needs a browser of its own to look at websites. I am fetching one now, about 150 MB.",installing:"Fetching the browser…",launching:"Making sure it opens…",installed:"Installed.",skip:"Skip for now",skipped:"Skipped. Settings → Computer & browser can install it whenever you like.",missing:"No browser for your assistant yet. Settings → Computer & browser can install one.",failed:e=>`That did not work: ${e}`,retry:"Try again"},assistant:{ask:"Last thing: your assistant. I've picked a name and a face; change either, or keep them.",name:"Name",face:"A face",mascot:e=>e==="core"?"Buddi Blob":`Buddi Blob, ${e}`,purpose:"What should it help you with?",purposeValue:["You're not a chatbot. You're becoming someone this person can count on.","","Some starting truths:","",`- Help for real. No "Great question", no "I'd be happy to". Do the thing, then say what you did.`,"- Have a view. Prefer things, disagree when you should, say when something is a bad idea. A search engine with manners is not a colleague.","- Look before you ask. Read the file, check what you remember, try it. Come back with an answer and one question at most.","- You are a guest here. You can see messages, files and a calendar. Treat that with care, keep what you learn to yourself, and never lecture.","- Remember what matters. Names, preferences, the things they said once and expect you to keep.","- When you change how you work, say so. This file is yours to grow, and the owner should always know what it says."].join(`
106
- `),submit:"Introduce us"},restore:{offer:"I have a backup from another buddi",file:"The backup file",passphrase:"Its passphrase",passphraseHint:"Only if it was locked with one.",submit:"Restore",cancel:"Never mind",started:"Right. Give me a couple of minutes.",phases:{stopping:"Putting everything down for a moment.",snapshot:"Keeping a copy of what is here now, just in case.",database:"Bringing back your conversations and everything you told it to remember.",recovery:"Almost there. Nothing will run on its own until you say so.",files:"Bringing back your files.",starting:"Starting back up.",done:"That is everything.","rolled-back":"That did not work, so I put everything back the way it was.",failed:"That did not work."},welcome:e=>`Welcome back, ${e}.`,keys:"A backup never carries keys, so the AI you think with needs its key one more time."},tagline:"Setting up, on this Mac.",taglineElsewhere:"Setting up, on this computer.",handover:{waiting:"One moment.",looking:e=>`${e} is looking around…`,slow:"Still waking up. A brain on this computer takes a minute the first time.",silent:"Your assistant isn't answering. The AI you picked may be down; try again, or pick another brain above.",again:"Pick another brain"},offers:{phone:"Talk to me from your phone",notNow:"Not now"},done:{said:"You're all set. This conversation carries on in your dashboard.",leaving:"Opening buddi…",ready:"Ready when you are.",open:"Open buddi"},telegram:{how:"Two minutes: open Telegram, message @BotFather, send /newbot, paste the token it gives you here.",field:"The token",submit:"Save it",restart:"Saved. It will be ready the next time buddi starts.",scan:"Scan this with your phone and press Start.",expired:"That code has run out. I can make you another one.",newCode:"Show a new code",paired:"That is your phone, talking to me. You can close this and carry on there."},change:"change"},gD=(e,t)=>!!e&&!!t&&e.kind===t.kind&&(e.kind==="mascot"?e.role===t.role:e.kind==="emoji"?e.value===t.value:!0);async function Gk(e){const t=await fetch(du(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const n=await t.blob();return new File([n],`buddi-blob-${e}.png`,{type:"image/png"})}function Yk({face:e,onPick:t,label:n=z.assistant.face,kept:r,disabled:i,disableEmoji:l,children:o}){return s.jsxs("div",{className:"meet-faces",role:"group","aria-label":n,children:[s.jsxs("div",{className:"meet-face-row",children:[r?s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":(e==null?void 0:e.kind)==="kept"?"true":void 0,"aria-pressed":(e==null?void 0:e.kind)==="kept","aria-label":"The current picture",disabled:i,onClick:()=>t({kind:"kept",url:r}),children:s.jsx("img",{src:r,alt:""})}):null,hD.map(a=>{const c={kind:"mascot",role:a},u=gD(e,c);return s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":z.assistant.mascot(a),disabled:i,onClick:()=>t(c),children:s.jsx("img",{src:du(a),alt:""})},a)})]}),s.jsx("div",{className:"meet-face-row",children:pD.map(a=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===a;return s.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||l,onClick:()=>t({kind:"emoji",value:a}),children:a},a)})}),o]})}const xD=["mirror","en","fr"];function vD({agentId:e}){var h,f,p;const{data:t,error:n,reload:r}=le(()=>A.agents(),[]),[i,l]=d.useState(null),[o,a]=d.useState(null),c=async m=>{l(null),a(null);try{const j=await m;a(j.changed.length===0?`No file change needed. ${j.note}.`:`Changed ${j.changed.join(", ")}. ${j.note}.`),r()}catch(j){l(j instanceof Error?j.message:String(j))}},u=t==null?void 0:t.agents.find(m=>m.id===e);return s.jsxs(q,{gap:"lg",children:[s.jsx(ie,{message:n??i}),o?s.jsx(G,{tone:"good",role:"status",children:o}):null,t?u?s.jsx(jD,{agent:u,all:t.agents,engine:t.engines.find(m=>m.id===u.id),providers:t.providers,accounts:t.providerAccounts,onRun:c,onSaved:r},`${u.id}:${(h=t.engines.find(m=>m.id===u.id))==null?void 0:h.model}:${(p=(f=t.providerAccounts)==null?void 0:f.bindings.find(m=>m.agentId===u.id))==null?void 0:p.accountId}`):s.jsx(oe,{children:"This agent is not installed as a file."}):s.jsx(oe,{children:"Loading…"})]})}function jD({agent:e,all:t,engine:n,providers:r,accounts:i,onRun:l,onSaved:o}){const a=(n==null?void 0:n.provider)??e.provider.kind,c=r.find(x=>x.kind===a),u=(n==null?void 0:n.model)??e.model,[h,f]=d.useState(String((n==null?void 0:n.maxTurns)??e.maxTurns));i==null||i.bindings.find(x=>x.agentId===e.id);const p=x=>{l(A.setAgentEngine(e.id,x))},m=x=>{const v=r.find(y=>y.kind===x);p({provider:x,model:(v==null?void 0:v.defaultModel)??u})},j=(c==null?void 0:c.models.map(x=>x.id))??[],w=j.includes(u)?j:[u,...j],b=n?n.available:!0;return s.jsxs(q,{gap:"lg",children:[b?null:s.jsxs(G,{tone:"warning",children:["This agent cannot run right now: ",(n==null?void 0:n.unavailableReason)??"no credential","."]}),s.jsx(yD,{agent:e,onSaved:o}),s.jsxs(Y,{title:"Runs on",panel:!0,children:[i?s.jsx(SD,{agentId:e.id,accounts:i,onRun:l}):s.jsxs(Es,{children:[s.jsx(ee,{label:"Provider",children:s.jsx("select",{value:a,onChange:x=>m(x.target.value),children:r.map(x=>s.jsxs("option",{value:x.kind,children:[x.kind,x.usable?"":" (no credential)"]},x.kind))})}),s.jsxs(ee,{label:"Model",children:[s.jsx("input",{list:`models-${e.id}`,defaultValue:u,onBlur:x=>{x.target.value.trim()!==""&&x.target.value.trim()!==u&&p({model:x.target.value.trim()})}}),s.jsx("datalist",{id:`models-${e.id}`,children:w.map(x=>s.jsx("option",{value:x},x))})]})]}),i?null:s.jsxs("p",{className:"ui-card-meta",children:[(n==null?void 0:n.credentialKind)??e.provider.credentialKind," from"," ",s.jsx("span",{className:"mono",children:(n==null?void 0:n.credentialEnv)??e.provider.credentialEnv}),c&&!c.usable?` · default model ${c.defaultModel} (${c.defaultFrom})`:""]}),n&&!n.available?s.jsxs("p",{className:"warning",children:["unavailable: ",n.unavailableReason??"no credential"]}):null,n!=null&&n.restartRequired?s.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),s.jsx(Y,{title:"Behaviour",aside:"saved as you change them",panel:!0,children:s.jsxs(Es,{children:[s.jsx(ee,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:s.jsx("input",{type:"number",min:1,value:h,onChange:x=>f(x.target.value),onBlur:()=>{const x=Number(h);Number.isInteger(x)&&x>=1&&x!==((n==null?void 0:n.maxTurns)??e.maxTurns)&&p({maxTurns:x})}})}),s.jsx(ee,{label:"Language",hint:"Mirror answers in whatever language you write.",children:s.jsx("select",{value:(n==null?void 0:n.language)??e.language,onChange:x=>p({language:x.target.value}),children:xD.map(x=>s.jsx("option",{value:x,children:x},x))})}),s.jsx(ee,{label:"Thinking",hint:"Reasoning before the answer. Off is faster; the model's default is usually on for local models.",children:s.jsxs("select",{"aria-label":"Thinking",value:(n==null?void 0:n.thinking)??"default",onChange:x=>p({thinking:x.target.value==="default"?null:x.target.value}),children:[s.jsx("option",{value:"default",children:"Model default"}),s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})})]})}),s.jsx(ED,{agent:e,all:t,onSaved:o}),s.jsx(Y,{title:"What it carries",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{title:"Built-in context",children:s.jsx("p",{className:"ui-card-meta",children:"Every agent receives current time, owner timezone and server-host information. system.time and system.info are always available, without grants or approval. Host and browser access still require their own permissions."})}),s.jsx(Y,{title:`Granted tools (${e.tools.length})`,children:e.tools.length===0?s.jsx("span",{className:"muted",children:"none"}):s.jsx(rh,{children:e.tools.map(x=>s.jsx(fe,{mono:!0,children:x},x))})}),s.jsx(Y,{title:`Skills (${e.skills.length})`,children:e.skills.length===0?s.jsx("span",{className:"muted",children:"none"}):s.jsx(rh,{children:e.skills.map(x=>s.jsxs(fe,{children:[x.name," · ",x.provenance]},x.file))})})]})})]})}function yD({agent:e,onSaved:t}){var V,$;const[n,r]=d.useState(e.name),[i,l]=d.useState(e.handle),[o,a]=d.useState(e.description),c=le(()=>A.agentTools(e.id),[e.id]),[u,h]=d.useState(null),[f,p]=d.useState((e.roles??[]).join(", ")),[m,j]=d.useState(e.avatar??""),w=le(()=>A.agentFile(e.id),[e.id]),[b,x]=d.useState(null),v=((V=w.data)==null?void 0:V.persona.trim())??"",y=b??v,g=w.data!==void 0&&b!==null&&b.trim()!==v,[S,k]=d.useState(!1),[N,C]=d.useState(null),[T,E]=d.useState(null),U=(_,ne)=>_.split(ne).map(X=>X.trim()).filter(X=>X!==""),H=(($=c.data)==null?void 0:$.granted)??e.tools,O=u??H,R=c.data!==void 0&&!aD(O,H),F=U(f,/[\n,]/),K=(_,ne)=>_.join(",")===ne.join(","),L=n.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||o.trim()!==e.description||m.trim()!==(e.avatar??"")||g||R||!K(F,e.roles??[]),M=async()=>{k(!0),C(null),E(null);try{const _=await A.updateAgentFile(e.id,{name:n.trim(),handle:i.trim().replace(/^@/,""),description:o.trim(),...R&&c.data?{tools:oD(c.data.groups,O)}:{},roles:F,...m.trim()===""?{}:{avatar:m.trim()},...g&&y.trim()!==""?{persona:y.trim()}:{}});e.picture&&m.trim()!==""&&m.trim()!==(e.avatar??"")&&(await A.removeAgentPicture(e.id),window.dispatchEvent(new Event(to))),x(null),w.reload(),E(_.message),h(null),c.reload(),t()}catch(_){C(_ instanceof Error?_.message:String(_))}finally{k(!1)}};return s.jsx(Y,{title:"Who it is",aside:s.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:s.jsxs(s.Fragment,{children:[N?s.jsx("span",{className:"critical save-error",role:"alert",children:N}):s.jsx("span",{className:L?"warning":"muted",children:L?"Not saved yet.":"Saved. Applies to new runs."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:!L||S,onClick:()=>void M(),children:"Save who it is"})]}),children:s.jsxs(q,{children:[e.isExample?s.jsx(G,{tone:"warning",children:"This agent ships with buddi, so its file is read-only here. Ask Agent Father to make it yours, then these fields can change."}):null,T?s.jsx(G,{tone:"good",role:"status",children:T}):null,s.jsxs(Es,{children:[s.jsx(ee,{label:"Name",hint:"What it is called, everywhere.",children:s.jsx("input",{value:n,disabled:S||e.isExample,onChange:_=>r(_.target.value)})}),s.jsx(ee,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:s.jsx("input",{value:i,disabled:S||e.isExample,onChange:_=>l(_.target.value)})}),s.jsx(ee,{label:"Roles",hint:"Capabilities it answers for, comma separated.",children:s.jsx("input",{value:f,disabled:S||e.isExample,onChange:_=>p(_.target.value)})})]}),s.jsx(bD,{agent:e,avatar:m,onEmoji:j,onChanged:t,disabled:S}),s.jsx(ee,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:s.jsx("textarea",{rows:2,value:o,disabled:S||e.isExample,onChange:_=>a(_.target.value)})}),s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Tools"}),c.error?s.jsx(ie,{message:c.error}):c.data?s.jsx(uD,{view:c.data,chosen:O,onChange:h,disabled:S||e.isExample}):s.jsx(oe,{children:"Loading the installed tools…"})]}),s.jsx(ee,{label:"Persona",hint:s.jsxs(s.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",s.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:w.error?s.jsx(ie,{message:w.error}):w.data?s.jsx("textarea",{className:"setup-persona",value:y,rows:Math.max(6,y.split(`
107
- `).length+1),disabled:S||e.isExample,onChange:_=>x(_.target.value)}):s.jsx(oe,{children:"Reading its file…"})})]})})}function wD(e){if(e.avatar)return/^[A-Za-z0-9_-]+\.(png|jpe?g|gif|webp)$/i.test(e.avatar)?{kind:"image",url:`/api/agents/${encodeURIComponent(e.id)}/avatar`}:{kind:"emoji",value:e.avatar.slice(0,8)}}function bD({agent:e,avatar:t,onEmoji:n,onChanged:r,disabled:i}){const[l,o]=d.useState(null),[a,c]=d.useState(!1),[u,h]=d.useState(null),f=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),p=l??(f?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),m=async j=>{if(h(null),j.kind==="emoji"){n(j.value);return}if(j.kind==="kept"){n(e.avatar??"");return}o(j),c(!0);try{await A.uploadAgentPicture(e.id,await Gk(j.role)),n(e.avatar??""),r(),window.dispatchEvent(new Event(to))}catch(w){h(w instanceof Error?w.message:String(w))}finally{o(null),c(!1)}};return s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Face"}),s.jsx(Yk,{face:p,label:"Face",kept:e.picture,disabled:i||a,disableEmoji:e.isExample,onPick:j=>void m(j),children:s.jsx(kD,{agent:e,onChanged:r})}),u?s.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function kD({agent:e,onChanged:t}){const[n,r]=d.useState(null),[i,l]=d.useState(null),[o,a]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[p,m]=d.useState(0);d.useEffect(()=>{if(!n)return l(null);const N=URL.createObjectURL(n);return l(N),()=>URL.revokeObjectURL(N)},[n]);const j=N=>{r(null),m(C=>C+1),f(N),t(),window.dispatchEvent(new Event(to))},w=async N=>{a(!0),u(null),f(null);try{j(await N())}catch(C){u(C instanceof Error?C.message:String(C))}finally{a(!1)}},b=()=>w(async()=>(await A.uploadAgentPicture(e.id,n)).note??null),x=()=>w(async()=>(await A.removeAgentPicture(e.id),null)),v={avatar:wD(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[y,g]=d.useState(!1),S=d.useRef(null),k=N=>{u(null),f(null),r(N??null)};return s.jsxs("div",{className:"setup-upload","data-dragging":y?"true":void 0,onDragOver:N=>{N.preventDefault(),o||g(!0)},onDragLeave:()=>g(!1),onDrop:N=>{var C;N.preventDefault(),g(!1),o||k((C=N.dataTransfer.files)==null?void 0:C[0])},children:[s.jsxs(J,{children:[s.jsx(Ps,{id:e.id,name:e.name,size:"xl",face:v}),s.jsx("input",{ref:S,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:o,onChange:N=>{var C;return k((C=N.target.files)==null?void 0:C[0])}},p),s.jsx(P,{disabled:o,onClick:()=>{var N;return(N=S.current)==null?void 0:N.click()},children:"Upload a picture"}),s.jsx("span",{className:"setup-upload-name",children:n?n.name:"or drop one here"}),s.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!n?s.jsx(P,{variant:"ghost",disabled:o,onClick:()=>void x(),children:"Remove picture"}):null,s.jsx(P,{variant:"accent",disabled:!n||o,onClick:()=>void b(),children:"Save picture"})]}),c?s.jsx("span",{className:"critical save-error",role:"alert",children:c}):s.jsx("span",{className:"ui-field-hint",children:h??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function SD({agentId:e,accounts:t,onRun:n}){const r=t.bindings.find(m=>m.agentId===e),[i,l]=d.useState((r==null?void 0:r.accountId)??""),[o,a]=d.useState((r==null?void 0:r.model)??""),[c,u]=d.useState(!1),h=t.accounts.find(m=>m.id===i),f=i!==((r==null?void 0:r.accountId)??"")||o!==((r==null?void 0:r.model)??""),p=t.accounts.find(m=>m.id===(r==null?void 0:r.accountId));return s.jsxs("div",{className:"ui-stack",children:[s.jsxs(J,{valign:"end",children:[s.jsx(ee,{label:"Account",children:s.jsxs("select",{value:i,disabled:c,onChange:m=>{var j;l(m.target.value),a(((j=t.accounts.find(w=>w.id===m.target.value))==null?void 0:j.defaultModel)??"")},children:[s.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(m=>s.jsxs("option",{value:m.id,disabled:!m.enabled,children:[m.label,m.enabled?m.configured?"":" (needs credential)":" (disabled)"]},m.id))]})}),s.jsx(Mm,{accountId:h!=null&&h.configured?i:void 0,label:"Model",value:o,onChange:a,disabled:c},`${i}:${h==null?void 0:h.revision}`)]}),s.jsxs(J,{children:[f&&i&&o.trim()?s.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",p?`${p.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):s.jsx("span",{className:"muted",children:p?`Running on ${p.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:c||!i||!o.trim()||!f,onClick:()=>{u(!0),n(A.assignProviderAccount(e,i,o).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const ND=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],CD=e=>e.tools.some(t=>ND.includes(t));function ED({agent:e,all:t,onSaved:n}){const[r,i]=d.useState(e.delegates),[l,o]=d.useState(!1),[a,c]=d.useState(null),[u,h]=d.useState(!1),[f,p]=d.useState(e.delegates),m=t.filter(v=>v.id!==e.id),j=[...r].sort().join(",")!==[...f].sort().join(","),w=t.filter(v=>v.id!==e.id&&v.delegates.includes(e.id)),b=v=>i(y=>y.includes(v)?y.filter(g=>g!==v):[...y,v]),x=async()=>{o(!0),c(null),h(!1);try{const v=await A.setDelegates(e.id,r);p(v.delegates),i(v.delegates),h(!0),n()}catch(v){c(v instanceof Error?v.message:String(v))}finally{o(!1)}};return s.jsx(Y,{title:"Delegation",aside:e.tools.includes("agent.delegate")?"holds agent.delegate":"no agent.delegate tool: it cannot ask anyone until granted",panel:!0,foot:e.isExample?void 0:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:j?"warning":"muted",children:j?"Not saved yet.":u?"Saved. Applies to the next run.":r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:!j||l,onClick:()=>void x(),children:"Save who it can ask"})]}),children:s.jsxs(q,{divided:!0,children:[s.jsxs(Y,{title:"Can ask",children:[e.isExample?s.jsx(G,{tone:"warning",children:"This agent ships with buddi, so its allowlist is read-only here. Ask Agent Father to make it yours, then it can change."}):null,s.jsx(ie,{message:a}),m.length===0?s.jsx(oe,{children:"Nobody else is installed."}):s.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:m.map(v=>{const y=CD(v);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${v.id}`,checked:r.includes(v.id),disabled:y||e.isExample||l,onChange:()=>b(v.id)}),s.jsxs("label",{htmlFor:`can-ask-${e.id}-${v.id}`,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[v.name," ",s.jsxs("span",{className:"mono muted",children:["@",v.handle]})]}),s.jsx("span",{className:"ui-list-sub",children:y?"Makes and changes agents. Never reachable by delegation.":v.description})]})]},v.id)})})]}),s.jsx(Y,{title:"Asked by",children:w.length===0?s.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):s.jsx(rh,{children:w.map(v=>s.jsx(fe,{children:v.name},v.id))})})]})})}const AD=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],RD=[{id:"conversations",label:"Conversations"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"},{id:"memory",label:"Memory"},{id:"skills",label:"Skills"},{id:"setup",label:"Setup"}];function TD({hash:e,timezone:t,navigate:n,agents:r,attention:i,defaultAgentId:l}){var b,x,v,y,g;const o=qP(e),a=((b=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:b[1])??"team",c=S=>k=>{k.preventDefault(),n(S)},u=le(()=>A.agents(),[]),h=Sm(),f=le(()=>A.offers(),[],2e4),p=hk(),m=(((x=f.data)==null?void 0:x.offers.length)??0)+p.offers.length,j=((y=(v=u.data)==null?void 0:v.default)==null?void 0:y.defaultAgentId)??l??null,w=r.find(S=>S.roles.includes(um));return s.jsxs("div",{className:"ui-page",children:[s.jsx(pm,{title:"Agents",lede:`Your team. Each one is a file on ${h} — what it can reach is listed on its page.`,actions:w?s.jsx(Fn,{variant:"accent",href:De(w.id),onClick:c(De(w.id)),children:"Add an agent"}):null}),s.jsx(mm,{children:AD.map(S=>s.jsx(gm,{href:S.id==="team"?Xe:`${Xe}?tab=${S.id}`,active:a===S.id,count:S.id==="offers"?m:void 0,onClick:c(S.id==="team"?Xe:`${Xe}?tab=${S.id}`),children:S.label},S.id))}),a==="missions"?s.jsx(Uk,{timezone:t,embedded:!0}):null,a==="offers"?s.jsx(pk,{offers:p.offers,reload:p.reload}):null,a==="offers"?s.jsx(zk,{embedded:!0}):null,a==="reminders"?s.jsx(Kk,{timezone:t,embedded:!0}):null,a==="team"?s.jsx(PD,{data:u.data,error:u.error,reload:u.reload}):null,a==="team"?r.length===0?s.jsx(gt,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):s.jsx("div",{className:"agents-grid",children:w0(r,j).map(S=>{const k=ou(i.get(S.id));return s.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...vo(xo(S)),"data-unavailable":S.available?void 0:"true",children:[s.jsx("div",{className:"agent-card-top"}),s.jsx("div",{className:"agent-card-face",children:s.jsx(Ps,{id:S.id,name:S.name,size:"xl",unavailable:!S.available,face:S})}),s.jsxs("div",{children:[s.jsxs("div",{className:"ui-card-title",children:[s.jsx("a",{className:"agent-card-link",href:It(S.id,"conversations"),onClick:c(It(S.id,"conversations")),children:S.name}),s.jsxs("span",{className:"agent-card-handle mono faint",children:["@",S.handle]})]}),s.jsx("p",{className:"ui-card-meta agent-card-desc",children:S.description})]}),s.jsxs("div",{className:"ui-row",children:[S.id===j?s.jsx(_a,{children:"front desk"}):null,k?s.jsx(fe,{tone:"critical",dot:!0,children:"waiting for you"}):S.available?s.jsx(fe,{tone:"good",dot:!0,children:"ready"}):s.jsx(fe,{tone:"warning",children:Cs(S.unavailableReason??"cannot run",60)}),s.jsx(fe,{mono:!0,children:S.model}),s.jsx(Fn,{className:"agent-card-talk",size:"sm",href:De(S.id),onClick:c(De(S.id)),"aria-label":`Talk to ${S.name}`,children:"Talk"})]})]},S.id)})}):null,o?s.jsx(Wt,{title:((g=r.find(S=>S.id===o.agentId))==null?void 0:g.name)??o.agentId,size:"wide",onClose:()=>n(Xe),children:s.jsx(ID,{agentId:o.agentId,agent:r.find(S=>S.id===o.agentId),agents:r,tab:o.tab??"conversations",timezone:t,navigate:n,attention:i})}):null]})}function PD({data:e,error:t,reload:n}){const r=e==null?void 0:e.default,[i,l]=d.useState(null),[o,a]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null);if(t)return s.jsx(ie,{message:t});if(!r||r.choices.length===0)return null;const p=r.defaultAgentId,m=i??p??"",j=m!==""&&m!==p,w=r.problem,b=v=>v.map(y=>{var g;return((g=r.choices.find(S=>S.id===y))==null?void 0:g.name)??y}).join(" and "),x=async()=>{a(!0),u(null),f(null);try{const v=await A.setDefaultAgent(m);f(v.note),l(null),n()}catch(v){u(v instanceof Error?v.message:String(v))}finally{a(!1)}};return s.jsx(st,{children:s.jsxs("div",{className:"ui-stack",children:[s.jsx(ie,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?s.jsx(G,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${b(w.agents)}. The one chosen here wins.`}):(w==null?void 0:w.code)==="no-default-agent"?s.jsx(G,{tone:"warning",role:"status",children:"No agent file claims the default and this installation has not recorded one. Choose who answers when you name nobody."}):null,h?s.jsx(G,{tone:"good",role:"status",children:h}):null,s.jsxs(J,{children:[s.jsxs("div",{className:"default-agent-text",children:[s.jsx("h3",{className:"default-agent-title",children:"Default agent"}),s.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("select",{"aria-label":"Default agent",value:m,disabled:o,onChange:v=>l(v.target.value),children:[m===""?s.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(v=>s.jsxs("option",{value:v.id,disabled:!v.available,children:[v.name," @",v.handle,v.available?"":" (cannot run)"]},v.id))]}),s.jsx(P,{variant:"accent",disabled:o||!j,onClick:()=>void x(),children:"Save"})]})]})})}function ID({agentId:e,agent:t,agents:n,tab:r,timezone:i,navigate:l,attention:o}){const a=h=>f=>{f.preventDefault(),l(h)},c=ou(o.get(e)),u=(t==null?void 0:t.name)??e;return s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[s.jsxs("header",{className:"agent-head",children:[s.jsx(Ps,{id:e,name:u,size:"xl",unavailable:t?!t.available:!1,face:t}),s.jsxs("div",{className:"agent-head-text",children:[s.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),s.jsxs("div",{className:"ui-row",children:[t?s.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?s.jsx("span",{className:"muted",children:t.model}):null,c?s.jsx(fe,{tone:"critical",children:c}):t&&!t.available?s.jsx(fe,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),s.jsx("div",{className:"ui-page-actions",children:s.jsxs(Fn,{variant:"accent",href:De(e),onClick:a(De(e)),children:["Talk to ",u]})})]}),t&&!t.available?s.jsxs(G,{tone:"warning",role:"status",children:[S0(t)," ",s.jsx("a",{href:ht(eh(t).section),children:eh(t).label})]}):null,s.jsx(mm,{children:RD.map(h=>s.jsx(gm,{href:It(e,h.id),active:r===h.id,onClick:a(It(e,h.id)),children:h.label},h.id))}),r==="conversations"?s.jsx(MD,{agentId:e,navigate:l}):null,r==="missions"?s.jsx(Uk,{timezone:i,embedded:!0,agentId:e}):null,r==="offers"?s.jsx(zk,{embedded:!0,agentId:e,agentName:u}):null,r==="reminders"?s.jsx(Kk,{timezone:i,embedded:!0,agentId:e}):null,r==="memory"?s.jsx(Wk,{embedded:!0,agents:n,timezone:i,agentId:e}):null,r==="skills"?s.jsx(rD,{agentId:e,agentName:u}):null,r==="setup"?s.jsx(vD,{agentId:e}):null]})}function MD({agentId:e,navigate:t}){const{data:n,error:r}=le(()=>_e.conversations(e,50),[e]);if(r)return s.jsx(oe,{children:r});const i=(n==null?void 0:n.conversations)??[];return s.jsx(st,{flush:!0,children:n?i.length===0?s.jsx(gt,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):s.jsx(un,{children:i.map(l=>s.jsx(Cn,{href:De(e,l.id),onClick:()=>t(De(e,l.id)),title:Cs(l.preview||l.opening||"Untitled conversation",90),sub:`${l.messageCount} message${l.messageCount===1?"":"s"}`,side:Se(l.lastMessageAt??l.startedAt??l.createdAt??null)},l.id))}):s.jsx(oe,{children:"Loading…"})})}function $D({timezone:e,navigate:t,agents:n,defaultAgentId:r,attention:i}){var L,M,V,$,_,ne,X,ue,ye,Ne,ce,we;const l=le(()=>A.overview(),[],15e3),o=le(()=>A.approvals(),[],1e4),a=le(()=>A.missions(),[],6e4),c=le(()=>A.reminders(),[],6e4),u=le(()=>A.conversations(),[],3e4),h=le(()=>A.offers(),[],3e4),f=le(()=>A.proposals(),[],6e4),p=le(()=>A.agentOffers(),[],6e4),m=le(()=>A.owner(),[]),j=d.useMemo(()=>w0(n,r??null),[n,r]),{busy:w,note:b,failure:x,decide:v}=Nm(()=>{o.reload(),l.reload()}),y=l.data,g=B=>{var te;return((te=n.find(ge=>ge.id===B))==null?void 0:te.name)??B},S=B=>te=>{te.preventDefault(),t(B)},k=((L=o.data)==null?void 0:L.pending)??[],N=((M=y==null?void 0:y.jobs)==null?void 0:M.failed)??0,C=((V=y==null?void 0:y.sentinels)==null?void 0:V.openUrgent)??0,T=(($=f.data)==null?void 0:$.open.length)??0,E=(((_=p.data)==null?void 0:_.offers)??[]).filter(B=>!k.some(te=>fk(te,B.plugin,B.agent))),U=k.length+(N>0?1:0)+(C>0?1:0)+(y!=null&&y.paused?1:0)+(T>0?1:0)+E.length,H=d.useMemo(()=>{var B,te;return LD(((B=a.data)==null?void 0:B.missions)??[],((te=c.data)==null?void 0:te.reminders)??[])},[a.data,c.data]),O=(((ne=u.data)==null?void 0:ne.conversations)??[]).slice(0,5),R=((X=h.data)==null?void 0:X.offers)??[],F=R.slice(0,_D),K=R.length-F.length;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"home-band",children:s.jsxs("header",{className:"home-hero",children:[s.jsxs("div",{className:"home-hero-text",children:[s.jsx("p",{className:"home-date",children:BD(y==null?void 0:y.now,e)}),s.jsx("h1",{className:"home-greeting",children:UD(y==null?void 0:y.now,e,((ue=m.data)==null?void 0:ue.preferredName)||((ye=m.data)==null?void 0:ye.displayName))}),s.jsx("p",{className:"home-lede",children:WD(U,k.length,N,C,(y==null?void 0:y.paused)??!1,T,E.length)})]}),s.jsx(A0,{size:"lg"})]})}),s.jsxs("div",{className:"home",children:[s.jsx(ie,{message:l.error??o.error??x}),b?s.jsx(G,{tone:"good",role:"status",children:b}):null,U>0?s.jsx(Y,{title:"Needs you",children:s.jsxs(q,{children:[y!=null&&y.paused?s.jsxs(G,{tone:"warning",title:"The installation is paused.",children:["Nothing is being claimed until you resume it."," ",s.jsx(P,{size:"sm",onClick:()=>{A.setPaused(!1).then(()=>l.reload())},children:"Resume"})]}):null,k.map(B=>s.jsx(Cm,{action:B,timezone:e,busy:w===B.id,onDecide:v,agentName:g(B.agentId)},B.id)),N>0?s.jsx(G,{tone:"critical",children:s.jsxs("a",{href:`${Je}/jobs?state=failed`,onClick:S(`${Je}/jobs?state=failed`),children:[N," failed job",N===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,C>0?s.jsx(G,{tone:"critical",children:s.jsxs("a",{href:`${Je}/alerts`,onClick:S(`${Je}/alerts`),children:[C," urgent alert",C===1?"":"s"," from your watchers."]})}):null,E.map(B=>s.jsx(st,{children:s.jsx(Em,{plugin:B.plugin,agent:B.agent,text:B.text,label:`Create @${B.handle}`,handle:B.handle,onDismiss:()=>{A.dismissAgentOffer(B.plugin,B.agent).then(()=>p.reload())}})},`${B.plugin}/${B.agent}`)),T>0?s.jsx(G,{tone:"accent",children:s.jsxs("a",{href:ht("proposals"),onClick:S(ht("proposals")),children:[T," proposal",T===1?"":"s"," from your agents to keep or discard."]})}):null,(((Ne=y==null?void 0:y.sentinels)==null?void 0:Ne.errors)??[]).map(B=>s.jsxs(G,{tone:"warning",children:["Watcher ",B.sentinelId," failed: ",B.error]},B.sentinelId)),((y==null?void 0:y.mail)??[]).filter(B=>B.lastError).map(B=>s.jsxs(G,{tone:"warning",children:["Source ",B.sourceId,": ",B.lastError]},B.sourceId))]})}):null,s.jsx(Y,{title:"Your team",aside:s.jsx("a",{href:Xe,onClick:S(Xe),children:"All agents"}),children:n.length===0?s.jsx(oe,{mascot:!0,children:"No agents yet. Add one under Agents."}):s.jsx("div",{className:"home-team",children:j.map(B=>{const te=ou(i.get(B.id));return s.jsxs("a",{className:"home-face",...vo(xo(B)),href:De(B.id),onClick:S(De(B.id)),"data-waiting":te?"true":void 0,"data-unavailable":B.available?void 0:"true",children:[s.jsx(Ps,{id:B.id,name:B.name,size:"lg",unavailable:!B.available,face:B}),s.jsxs("span",{className:"home-face-text",children:[s.jsx("span",{className:"home-face-name",children:B.name}),s.jsx("span",{className:"home-face-status",children:te?qk(te):B.available?Cs(B.description,60):B.unavailableReason??"Cannot run right now."})]})]},B.id)})})}),F.length>0?s.jsx(Y,{title:"On offer",aside:s.jsxs("span",{className:"ui-row",children:[K>0?s.jsxs("a",{href:`${Xe}?tab=offers`,onClick:S(`${Xe}?tab=offers`),children:[K," more"]}):null,s.jsx(Bk,{ids:R.map(B=>B.id),onDone:()=>h.reload()})]}),children:s.jsx("div",{className:"home-offers",children:F.map(B=>s.jsx(DD,{offer:B,agents:n,open:S(It(B.agentId,"offers")),onDismissed:()=>h.reload()},B.id))})}):null,(we=(ce=f.data)==null?void 0:ce.digest)!=null&&we.latest?s.jsx(zD,{digest:f.data.digest.latest,go:S}):null,s.jsxs("div",{className:"home-columns",children:[s.jsx(Y,{title:"Coming up",aside:s.jsx("a",{href:`${Xe}?tab=missions`,onClick:S(`${Xe}?tab=missions`),children:"All missions"}),children:s.jsx(st,{flush:!0,children:H.length===0?s.jsx(oe,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):s.jsx(un,{children:H.map(B=>s.jsx(Cn,{href:B.route,onClick:()=>t(B.route),lead:s.jsx(bn,{agents:n,id:B.agentId,size:"sm"}),title:B.title,sub:`${B.kind} for ${g(B.agentId)}`,side:Se(B.at)},B.key))})})}),s.jsx(Y,{title:"Lately",aside:s.jsx("a",{href:Je,onClick:S(Je),children:"All activity"}),children:s.jsx(st,{flush:!0,children:O.length===0?s.jsx(oe,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):s.jsx(un,{children:O.map(B=>s.jsx(Cn,{href:De(B.agentId,B.id),onClick:()=>t(De(B.agentId,B.id)),lead:s.jsx(bn,{agents:n,id:B.agentId,size:"sm"}),title:B.opening?Cs(B.opening,80):"Untitled conversation",sub:`${g(B.agentId)}, ${B.messageCount} message${B.messageCount===1?"":"s"}`,side:Se(B.lastMessageAt??B.createdAt)},B.id))})})})]}),((y==null?void 0:y.home)??[]).map(B=>s.jsx(VD,{block:B},B.id)),y!=null&&y.jobs&&y.missions?s.jsxs("p",{className:"home-foot muted",children:[Mt(y.jobs.pending??0)," queued, ",Mt(y.jobs.leased??0)," running, ",Mt(y.missions.enabled)," of ",Mt(y.missions.total)," missions on."," ",y.paused?s.jsx(fe,{tone:"warning",children:"paused"}):s.jsx(fe,{tone:"good",children:"running"})," ",s.jsx("a",{href:Di("").replace(/\/conversations\/$/,""),onClick:S(Je),children:"Activity"})," · ",s.jsx("a",{href:ht("system"),onClick:S(ht("system")),children:"System"})]}):null]})]})}const _D=6,OD=500;function DD({offer:e,agents:t,open:n,onDismissed:r}){const[i,l]=d.useState(!1),o=d.useRef(null),a=d.useRef(!1),c=()=>{i||(l(!0),A.dismissOffer(e.id).then(r).finally(()=>l(!1)))},u=()=>{o.current!==null&&clearTimeout(o.current),o.current=null};return s.jsxs("span",{className:"home-offer-chip",children:[s.jsxs("a",{className:"home-offer",href:It(e.agentId,"offers"),onClick:h=>{if(a.current){a.current=!1,h.preventDefault();return}n(h)},title:e.prompt,onTouchStart:()=>{a.current=!1,u(),o.current=setTimeout(()=>{a.current=!0,c()},OD)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[s.jsx(bn,{agents:t,id:e.agentId,size:"sm"}),s.jsx("span",{children:e.label})]}),s.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function LD(e,t){const n=[];for(const r of e)r.enabled&&r.nextRun&&n.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:It(r.agentId,"missions")});for(const r of t)r.state==="pending"&&n.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:It(r.agentId,"reminders")});return n.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function FD(e,t){try{const n=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(n)}catch{return new Date().getHours()}}function UD(e,t,n){const r=FD(e,t),i=n!=null&&n.trim()?`, ${n.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function BD(e,t){try{const n=e?new Date(e):new Date,r=new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:t}).format(n),i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",timeZone:t}).format(n);return`${r}, ${i}`}catch{return Pe(e??null,t)}}function fa(e,t,n){return e.count===0?null:`${e.count} ${e.count===1?t:n}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function zD({digest:e,go:t}){const n=[fa(e.memory,"memory note","memory notes"),fa(e.skills,"skill kept","skills kept"),fa(e.rules,"rule kept","rules kept"),fa(e.changes,"change to an agent kept","changes to agents kept")].filter(i=>i!==null),r=e.stopped===null?"Not measured yet.":e.stopped.total>0?`Rules you kept acted ${e.stopped.total} time${e.stopped.total===1?"":"s"} (${Object.entries(e.stopped.byPlugin).filter(([,i])=>i>0).map(([i,l])=>`${i} ${l}`).join(", ")}).`:"No rule you kept acted this week.";return s.jsx(Y,{title:"What buddi learned this week",aside:s.jsx("span",{className:"muted",children:Se(e.at)}),children:s.jsx(st,{children:s.jsxs(q,{divided:!0,children:[s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Learned"}),n.length===0?s.jsx("p",{children:"Nothing new."}):s.jsx("ul",{className:"home-digest-list",children:n.map(i=>s.jsx("li",{children:i},i))})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Proposes"}),s.jsx("p",{children:e.open>0?s.jsxs("a",{href:ht("proposals"),onClick:t(ht("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),s.jsx("p",{children:r})]})]})})})}function WD(e,t,n,r,i,l=0,o=0){if(e===0)return"Nothing needs you. Your agents are on it.";const a=[];t>0&&a.push(`${t} approval${t===1?"":"s"} waiting`),n>0&&a.push(`${n} failed job${n===1?"":"s"}`),r>0&&a.push(`${r} urgent alert${r===1?"":"s"}`),i&&a.push("the installation is paused"),l>0&&a.push(`${l} proposal${l===1?"":"s"} to review`),o>0&&a.push(`${o===1?"an agent":`${o} agents`} to set up`);const c=a.length<=1?a.join(""):`${a.slice(0,-1).join(", ")} and ${a[a.length-1]}`;return`${qk(c)}.`}function qk(e){return e.charAt(0).toUpperCase()+e.slice(1)}function VD({block:e}){const[t,n]=d.useState(!1),r=e.sensitive===!0&&!t;d.useEffect(()=>{if(!e.sensitive||!t)return;const l=()=>{document.visibilityState==="hidden"&&n(!1)};return document.addEventListener("visibilitychange",l),window.addEventListener("blur",l),()=>{document.removeEventListener("visibilitychange",l),window.removeEventListener("blur",l)}},[e.sensitive,t]);const i=s.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?s.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?s.jsx(P,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>n(l=>!l),children:r?"Show":"Hide"}):null]});return s.jsxs(Y,{title:e.title,aside:i,children:[e.note?s.jsx(G,{tone:"warning",children:e.note}):null,e.stats.length>0?s.jsx(cu,{children:e.stats.map(l=>s.jsx(Xn,{label:l.label,value:r?"••••":l.value,note:r?void 0:l.note,tone:r?void 0:l.tone},l.label))}):null,e.rows.length>0?r?s.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):s.jsx(st,{flush:!0,children:s.jsx(un,{children:e.rows.map((l,o)=>s.jsx(Cn,{title:l.title,sub:l.sub,side:l.side?s.jsx("span",{className:l.tone==="critical"?"critical":l.tone==="good"?"good":void 0,children:l.side}):void 0},`${l.title}-${o}`))})}):null]})}const Qk="(max-width: 900px)";function Nh(e){const[t,n]=d.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return d.useEffect(()=>{var l;let r;try{r=window.matchMedia(e)}catch{return}const i=o=>n(o.matches);return(l=r.addEventListener)==null||l.call(r,"change",i),()=>{var o;return(o=r.removeEventListener)==null?void 0:o.call(r,"change",i)}},[e]),t}const HD=3e4;function Jk(){const{data:e,reload:t}=le(()=>A.recovery(),[],HD);return{data:e,reload:t}}const KD="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function GD({active:e,onNavigate:t}){return e?s.jsxs("div",{className:"recovery-banner",role:"status",children:[s.jsx("span",{children:KD}),s.jsx("a",{href:rv,onClick:n=>{n.preventDefault(),t(rv)},children:"Finish the checklist"})]}):null}function YD({view:e,onLeft:t}){const{secrets:n,plugins:r,pending:i,grants:l}=e.checklist,[o,a]=d.useState(!0),[c,u]=d.useState([]),[h,f]=d.useState(!1),[p,m]=d.useState(null),[j,w]=d.useState(!1),b=r.filter(g=>!g.installed),x=i.jobs+i.missions+i.approvals+i.telegramChats,v=g=>{u(S=>S.includes(g)?S.filter(k=>k!==g):[...S,g])},y=()=>{f(!0),m(null),A.leaveRecovery({dropPending:o,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(g=>m(g instanceof pe?g.message:String(g))).finally(()=>f(!1))};return s.jsx(st,{title:"Back from a backup",children:s.jsxs(q,{divided:!0,children:[s.jsxs(Y,{children:[s.jsx(bt,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:s.jsx("span",{className:"mono",children:e.archive??"—"})}]}),s.jsx("p",{className:"ui-card-meta",children:"Nothing runs on its own yet: no schedules, no watchers, no phone. Chat works. Go through what is below, then turn this buddi back on."})]}),s.jsx(Y,{title:"Keys to paste again",children:n.length===0?s.jsx(oe,{children:"Nothing is missing."}):s.jsx("ul",{className:"recovery-list",children:n.map(g=>s.jsxs("li",{children:[g.settingsRoute?s.jsx("a",{href:g.settingsRoute,children:g.name}):g.name," ",s.jsx("span",{className:"ui-card-meta",children:g.kind})]},`${g.kind}:${g.name}`))})}),s.jsx(Y,{title:"Add-ons to install again",children:b.length===0?s.jsx(oe,{children:"Everything the backup named is installed."}):s.jsx("ul",{className:"recovery-list",children:b.map(g=>s.jsxs("li",{children:[s.jsx("span",{className:"mono",children:g.name})," ",g.version," ",s.jsx("span",{className:"ui-card-meta",children:g.source})]},g.name))})}),s.jsx(Y,{title:"Work that was waiting",children:x===0?s.jsx(oe,{children:"Nothing was in flight when the backup was taken."}):s.jsxs(q,{gap:"sm",children:[s.jsx(bt,{items:[{label:"Jobs",value:String(i.jobs)},{label:"Missions",value:String(i.missions)},{label:"Waiting for an answer",value:String(i.approvals)},{label:"Phones",value:String(i.telegramChats)}]}),s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:o,onChange:g=>a(g.target.checked)}),s.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),s.jsx(Y,{title:"Standing permissions",children:l.length===0?s.jsx(oe,{children:"No agent had a standing permission."}):s.jsxs(q,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),s.jsx("ul",{className:"recovery-list",children:l.map(g=>s.jsx("li",{children:s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:c.includes(g.id),onChange:()=>v(g.id),"aria-label":`Keep ${g.tool} for ${g.agent}`}),s.jsxs("span",{children:[s.jsx("span",{className:"mono",children:g.tool})," for ",g.agent," ",s.jsx("span",{className:"ui-card-meta",children:g.scope}),g.description?s.jsxs("span",{className:"ui-card-meta",children:[" — ",g.description]}):null]})]})},g.id))})]})}),s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:p}),j?s.jsx(G,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):s.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:h||j,onClick:y,children:"Leave recovery mode"})})]})})]})})}const qD=2e3,QD={queued:"Getting started.",stopping:"Stopping the gateway. The database stays up.",snapshot:"Taking a copy of what is here now, first.",database:"Putting the database back.",recovery:"Marking this installation as restored.",files:"Putting the files back.",starting:"Starting back up.",encrypt:"Locking it with your passphrase.",done:"Done.",failed:"That did not work.","rolled-back":"That did not work, so everything was put back as it was."};function Vv(e){return QD[e.phase]??e.detail??e.phase}const JD=new Set(["done","failed","rolled-back"]);function Xk(e){return e!==void 0&&(JD.has(e.phase)||!!e.finishedAt)}function XD(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(!1),[l,o]=d.useState(null),a=d.useRef(!1);return d.useEffect(()=>{if(!e){n(void 0),i(!1),a.current=!1;return}let c=!1;const u=()=>{A.backupJob(e).then(f=>{if(!c){if(a.current){window.location.reload();return}n(f),o(null),Xk(f)&&(c=!0)}}).catch(f=>{if(!c){if(f instanceof pe&&f.status!==0&&f.status<500){o(f.message);return}a.current=!0,i(!0)}})};u();const h=window.setInterval(u,qD);return()=>{c=!0,window.clearInterval(h)}},[e]),{job:t,away:r,error:l}}function ZD({job:e,away:t,error:n}){return n?s.jsx(ie,{message:n}):t?s.jsx(G,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="rolled-back"||e.phase==="failed"?s.jsxs(G,{tone:"critical",role:"alert",children:[Vv(e)," ",e.error??""]}):s.jsxs(G,{tone:e.phase==="done"?"good":void 0,role:"status",children:[Vv(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function eL(){var b,x,v,y,g,S,k;const e=le(()=>A.backups(),[],3e4),t=Jk(),n=le(()=>A.service(),[]),[r,i]=d.useState(null),l=XD(r),[o,a]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),p=((b=e.data)==null?void 0:b.supervised)??((x=n.data)==null?void 0:x.supervised),m=h!==null||p===!1,j=((v=e.data)==null?void 0:v.archives)??[],w=N=>{u(!0),a(null),N.then(C=>{var T;return i(((T=C.job)==null?void 0:T.id)??null)}).catch(C=>{C instanceof pe&&C.status===409?f(C.message):a(C instanceof pe?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return d.useEffect(()=>{Xk(l.job)&&e.reload()},[(y=l.job)==null?void 0:y.phase]),s.jsxs(q,{gap:"lg",children:[(g=t.data)!=null&&g.active?s.jsx(YD,{view:t.data,onLeft:t.reload}):null,s.jsx(ie,{message:e.error??o}),s.jsx(ZD,{...l}),s.jsx(nL,{onSaved:()=>e.reload()}),s.jsx(Y,{title:"Backups",panel:!0,actions:s.jsx(P,{variant:"accent",size:"sm",disabled:c,onClick:()=>w(A.startBackup(!0)),children:"Back up now"}),children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsxs("p",{className:"ui-card-meta",children:["Kept in ",s.jsx("span",{className:"mono",children:((S=e.data)==null?void 0:S.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),s.jsx(Y,{children:e.data&&j.length===0?s.jsx(gt,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?s.jsxs(Zt,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Taken"}),s.jsx("th",{children:"Size"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:j.map(N=>{var C;return s.jsx(sL,{archive:N,busy:c,database:(C=e.data)==null?void 0:C.database,checkout:m,onVerify:()=>w(A.verifyArchive(N.name)),onRestore:(T,E)=>w(A.restoreArchive({name:N.name,...T?{passphrase:T}:{},...E?{confirm:E}:{}}))},N.name)})})]}):s.jsx(oe,{children:"Loading…"})})]})}),s.jsx(rL,{}),s.jsx(iL,{busy:c,checkout:m,checkoutSaid:h,database:(k=e.data)==null?void 0:k.database,onRestore:(N,C,T)=>w(A.restoreUpload(N,{passphrase:C,confirm:T}))})]})}const tL={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function nL({onSaved:e}){var m;const t=le(()=>A.backupSchedule(),[]),[n,r]=d.useState(null),[i,l]=d.useState(!1),[o,a]=d.useState(null),[c,u]=d.useState(!1);d.useEffect(()=>{t.data&&r(t.data)},[t.data]);const h={...tL,...n??t.data??{}};if(((m=t.data)==null?void 0:m.supervised)===!1)return s.jsx(Y,{title:"Every night",panel:!0,children:s.jsx(Y,{children:s.jsx(G,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const f=j=>{u(!1),r({...h,...j})},p=()=>{l(!0),a(null),A.setBackupSchedule(h).then(j=>{r(j),u(!0),e()}).catch(j=>a(j instanceof pe?j.message:String(j))).finally(()=>l(!1))};return s.jsx(Y,{title:"Every night",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:i,onClick:p,children:"Save"}),children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:o}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:h.enabled,onChange:j=>f({enabled:j.target.checked})}),s.jsx("span",{children:"Back this buddi up on its own"})]}),s.jsxs(Es,{children:[s.jsx(ee,{label:"At",children:s.jsx("input",{type:"time",value:h.time,onChange:j=>f({time:j.target.value})})}),s.jsx(ee,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:s.jsx("input",{type:"number",min:1,max:365,value:h.keep,onChange:j=>f({keep:Number(j.target.value)||1})})})]}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:h.encryptLocal,onChange:j=>f({encryptLocal:j.target.checked})}),s.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ee,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:s.jsx("input",{type:"text",value:h.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:j=>f({copyTo:j.target.value===""?null:j.target.value})})}),c?s.jsxs(G,{tone:"good",role:"status",children:["Saved.",h.lastRunAt?` Last run ${Se(h.lastRunAt)}.`:""]}):null]})})]})})}function sL({archive:e,busy:t,database:n,checkout:r,onVerify:i,onRestore:l}){const[o,a]=d.useState(!1),[c,u]=d.useState(""),[h,f]=d.useState("");return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:e.name}),s.jsx("td",{children:Se(e.createdAt)}),s.jsx("td",{children:En(e.bytes)}),s.jsxs("td",{children:[e.encrypted?s.jsx(fe,{tone:"good",children:"locked"}):s.jsx(fe,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?s.jsx(fe,{tone:"critical",children:"damaged"}):null]}),s.jsx("td",{children:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",disabled:t,onClick:i,children:"Verify"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>a(!o),children:"Restore…"})]})})]}),o?s.jsx("tr",{children:s.jsx("td",{colSpan:5,children:r?s.jsx(G,{tone:"warning",children:Zk}):s.jsx(eS,{what:`${e.name}, taken ${Se(e.createdAt)}, ${En(e.bytes)}`,database:n,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:h,onConfirm:f,busy:t,onCancel:()=>a(!1),onGo:()=>l(c,h)})})}):null]})}const Zk="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function eS({what:e,database:t,needsPassphrase:n,passphrase:r,onPassphrase:i,confirm:l,onConfirm:o,busy:a,onCancel:c,onGo:u}){const h=t??"",f=h===""?l.trim()!=="":l.trim()===h;return s.jsxs(q,{gap:"sm",children:[s.jsxs(G,{tone:"warning",children:["This replaces everything in this buddi with ",e,". What is here now is copied first, so a restore that fails puts it back."]}),n?s.jsx(ee,{label:"The passphrase this one was locked with",children:s.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:p=>i(p.target.value)})}):null,s.jsx(ee,{label:h?`Type ${h} to confirm`:"Type the name of this database to confirm",hint:h?void 0:"The same name buddi shows on the System tab.",children:s.jsx("input",{value:l,onChange:p=>o(p.target.value)})}),s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(P,{variant:"danger",disabled:a||!f||n&&r==="",onClick:u,children:"Restore"})]})]})}function rL(){const[e,t]=d.useState(null),[n,r]=d.useState(""),[i,l]=d.useState(!1),[o,a]=d.useState(null),[c,u]=d.useState(!1),h=()=>{l(!0),a(null),A.backupPassphrase().then(p=>t(p.passphrase)).catch(p=>a(p instanceof pe?p.message:String(p))).finally(()=>l(!1))},f=()=>{l(!0),a(null),A.setBackupPassphrase(n.trim()).then(p=>{t(p.passphrase),r(""),u(!0)}).catch(p=>a(p instanceof pe?p.message:String(p))).finally(()=>l(!1))};return s.jsx(Y,{title:"The passphrase",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:o}),s.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?s.jsx("p",{className:"backup-phrase mono",children:e}):s.jsx(J,{align:"end",children:s.jsx(P,{disabled:i,onClick:h,children:"Show it"})}),c?s.jsx(G,{tone:"good",role:"status",children:"Saved. Backups made from now on use it; older ones keep the one they were made with."}):null]})}),s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ee,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:s.jsx("input",{type:"text",autoComplete:"off",value:n,onChange:p=>{u(!1),r(p.target.value)}})}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:i||n.trim()==="",onClick:f,children:"Use this one"})})]})})]})})}function iL({busy:e,checkout:t,checkoutSaid:n,database:r,onRestore:i}){const[l,o]=d.useState(null),[a,c]=d.useState(""),[u,h]=d.useState(""),[f,p]=d.useState(!1);return t?s.jsx(Y,{title:"Restore from a file",panel:!0,children:s.jsx(Y,{children:s.jsx(G,{tone:"warning",children:n??Zk})})}):s.jsx(Y,{title:"Restore from a file",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),s.jsxs(Es,{children:[s.jsx(ee,{label:"The backup file",children:s.jsx("input",{type:"file",onChange:m=>{var j;p(!1),o(((j=m.target.files)==null?void 0:j[0])??null)}})}),s.jsx(ee,{label:"Its passphrase",hint:"Only if it was locked with one.",children:s.jsx("input",{type:"password",autoComplete:"off",value:a,onChange:m=>c(m.target.value)})})]}),f?null:s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||!l,onClick:()=>p(!0),children:"Restore"})})]})}),f&&l?s.jsx(Y,{children:s.jsx(eS,{what:`${l.name}, ${En(l.size)}`,database:r,needsPassphrase:!1,passphrase:a,onPassphrase:c,confirm:u,onConfirm:h,busy:e,onCancel:()=>p(!1),onGo:()=>i(l,a,u)})}):null]})})}function lL({embedded:e}={}){const{data:t,error:n,reload:r,loading:i}=le(()=>A.providerAccounts(),[]),[l,o]=d.useState(!1),[a,c]=d.useState(null),[u,h]=d.useState(""),[f,p]=d.useState(!1),[m,j]=d.useState(!1),[w,b]=d.useState(null),x=t==null?void 0:t.accounts.some(S=>{var k;return((k=S.login)==null?void 0:k.state)==="pending"&&S.login.expiresAt&&Date.parse(S.login.expiresAt)>Date.now()});d.useEffect(()=>{if(!x)return;const S=setInterval(r,2e3);return()=>clearInterval(S)},[x,r]);const v=async(S,k)=>{o(!0),c(null),h(""),j(!1);try{const N=await S();return h((N==null?void 0:N.warning)??k),r(),!0}catch(N){return c(N instanceof Error?N.message:"Could not apply change."),r(),!1}finally{o(!1)}},y=(t==null?void 0:t.accounts)??[],g=y.find(S=>S.id===w)??y[0];return s.jsxs(en,{embedded:e,title:"Model accounts",lede:"Give each API key or subscription a name, then pick one per agent. An account never falls back to another credential on its own.",children:[s.jsx(ie,{message:n??a}),u&&s.jsx(G,{tone:"good",role:"status",children:u}),m&&s.jsx(G,{role:"status",children:i?"Refreshing account status…":n?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!t&&!n&&s.jsx(oe,{children:"Loading accounts…"}),n&&s.jsx(J,{children:s.jsx(P,{onClick:r,children:"Retry"})}),t&&s.jsxs(s.Fragment,{children:[(t.vault.locked||t.vault.kind==="none")&&s.jsx(G,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),f&&s.jsx(Wt,{title:"Add an account",onClose:()=>p(!1),children:s.jsx("div",{id:"new-provider-account",children:s.jsx(fL,{accounts:y,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:l,run:v,onDone:S=>{p(!1),S&&b(S)}})})}),s.jsx(Y,{title:"Accounts",aside:`Secrets live in the ${oL(t.vault.kind)}; Postgres holds names and assignments only.`,actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",size:"sm",disabled:l||i,onClick:()=>{c(null),h(""),j(!0),r()},children:i?"Refreshing…":"Refresh status"}),s.jsx(P,{variant:"accent",size:"sm",disabled:l,"aria-expanded":f,"aria-controls":"new-provider-account",onClick:()=>p(!f),children:"Add account"})]}),panel:!0,flush:!0,children:y.length===0?s.jsx(gt,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):s.jsxs("div",{className:"accounts",children:[s.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:y.map(S=>s.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(g==null?void 0:g.id)===S.id,onClick:()=>b(S.id),children:[s.jsx(aL,{kind:S.kind,auth:S.auth}),s.jsxs("span",{className:"accounts-row-text",children:[s.jsx("span",{className:"accounts-row-name",children:S.label}),s.jsxs("span",{className:"accounts-row-sub",children:[$m(S)," · ",S.assignedAgents.length===0?"no agents":`${S.assignedAgents.length} agent${S.assignedAgents.length===1?"":"s"}`]})]}),s.jsx(tS,{account:S})]},S.id))}),g?s.jsx(uL,{account:g,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:l,run:v},`${g.id}:${g.revision}`):null]})})]})]})}function oL(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function $m(e){return e.kind==="codex"?"ChatGPT subscription":e.kind==="anthropic"?e.auth==="anthropic-oauth"?"Claude subscription":e.auth==="legacy-subscription-token"?"Claude setup token":"Anthropic API":e.kind==="openai"?"OpenAI API":"OpenAI-compatible"}function aL({kind:e,auth:t}){const n=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return s.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:n})}function cL(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function tS({account:e}){const t=e.enabled?e.configured?"good":"warning":void 0,n=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return s.jsx(fe,{tone:t,children:n})}function nS(e){return{id:e.id,revision:e.revision,label:e.label,kind:e.kind,auth:e.auth,baseUrl:e.baseUrl,defaultModel:e.defaultModel,enabled:e.enabled,contextWindowTokens:e.contextWindowTokens??null}}function uL({account:e,busy:t,run:n,anthropicOAuthEnabled:r}){const[i,l]=d.useState(!1),[o,a]=d.useState(!1);return s.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:e.label}),s.jsx(tS,{account:e})]}),s.jsx(bt,{items:[{label:"Provider",value:$m(e)},{label:"Default model",value:s.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:s.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":" (detected)"}`})},...e.baseUrl?[{label:"Endpoint",value:s.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?s.jsx("span",{className:"ui-row",children:e.assignedAgents.map(c=>s.jsx("a",{href:It(c,"setup"),children:c},c))}):s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:"No agents"}),s.jsx("a",{href:Xe,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${new Date(e.tokenExpiresAt).toLocaleString()} (not your subscription renewal date)`}]:[]]}),e.removalPending&&s.jsx(G,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&s.jsx(G,{tone:"warning",children:"Token refresh did not finish. Reconnect this Claude account."}),e.auth==="anthropic-oauth"&&s.jsx(rS,{account:e,enabled:!!r,busy:t,run:n}),e.kind==="codex"&&s.jsx(sS,{account:e,busy:t,run:n}),s.jsxs(J,{children:[s.jsx(P,{disabled:t||e.removalPending,onClick:()=>l(!0),children:"Edit account"}),s.jsx(P,{disabled:t||e.removalPending,onClick:()=>void n(()=>A.saveProviderAccount({...nS(e),enabled:!e.enabled}),e.enabled?"Account disabled. Subsequent model calls will stop; already-sent requests cannot be recalled.":"Account enabled."),children:e.enabled?"Disable":"Enable"}),e.kind!=="codex"&&s.jsx(P,{disabled:t||!e.enabled||!e.configured,onClick:()=>void n(()=>A.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),s.jsx(P,{variant:"danger",disabled:t||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>a(!0),children:"Remove account"})]}),e.test&&s.jsxs(s.Fragment,{children:[s.jsxs(G,{role:"status",tone:cL(e.test.state),children:[s.jsx("p",{children:e.test.message}),e.test.retryAt?s.jsxs("p",{children:["Provider suggested retry time: ",new Date(e.test.retryAt).toLocaleString(),". This is retry advice, not a guaranteed quota reset."]}):["rate-limited","quota-exhausted"].includes(e.test.state)&&s.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),s.jsxs("p",{className:"muted",children:["Tested at ",new Date(e.test.checkedAt).toLocaleString(),e.test.httpStatus?` · HTTP ${e.test.httpStatus}`:"",". This is not a quota reset or subscription renewal date."]})]}),i&&s.jsx(Wt,{title:`Edit ${e.label}`,onClose:()=>l(!1),children:s.jsx(dL,{account:e,busy:t,run:n,onDone:()=>l(!1)})}),o&&s.jsxs(G,{tone:"critical",children:[s.jsxs("p",{children:["Remove “",e.label,"” and its stored credential from Buddi? This does not revoke it at the provider or remove it from backups."]}),s.jsxs(J,{children:[s.jsx(P,{variant:"danger",disabled:t,onClick:()=>void n(()=>A.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),s.jsx(P,{disabled:t,onClick:()=>a(!1),children:"Cancel"})]})]}),s.jsx(Nt,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[e.auth==="legacy-subscription-token"&&s.jsx("p",{children:"Legacy subscription token: not refreshable, token expiry and subscription renewal date unknown."}),e.kind==="codex"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Experimental Codex App Server. Credentials stay in Buddi’s vault and are staged in a private temporary file during native sessions. Codex manages refresh. Subscription renewal date is unknown."}),s.jsx("p",{children:"Native tool-step usage reporting is incomplete. Do not use Buddi’s token or API-cost estimates as subscription billing or remaining quota."}),s.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):s.jsx("p",{children:"Testing sends a small fixed prompt and may incur a charge. No conversation or files are sent. Configured does not mean verified."}),e.auth==="anthropic-oauth"&&s.jsx("p",{children:"Experimental Claude subscription sign-in. Tokens remain in Buddi’s vault and refresh before use. Subscription renewal and remaining quota are unknown."}),s.jsx("p",{children:"Subscription login is separate from API-key access. Existing Claude setup tokens remain legacy accounts, without automatic refresh or a known expiry."})]})})]})}function sS({account:e,busy:t,run:n}){var r,i,l;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(P,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void n(()=>A.codexAccountAction(e.id,"login",e.revision),"Complete device sign-in below."),children:e.configured?"Reconnect ChatGPT":"Connect ChatGPT"}),((i=e.login)==null?void 0:i.state)==="pending"&&s.jsx(P,{disabled:t,onClick:()=>void n(()=>A.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),s.jsx(P,{disabled:t||!e.configured,onClick:()=>void n(()=>A.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((l=e.login)==null?void 0:l.state)==="pending"&&s.jsxs(G,{tone:"accent",role:"status",children:[s.jsxs("p",{children:["Open ",s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:e.login.verificationUrl})," and enter ",s.jsx("code",{children:e.login.userCode}),"."]}),s.jsxs("p",{className:"muted",children:["Buddi stops waiting at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),". This is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&s.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function dL({account:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:l}){const[o,a]=d.useState((e==null?void 0:e.label)??""),[c,u]=d.useState((e==null?void 0:e.kind)??"anthropic"),[h,f]=d.useState((e==null?void 0:e.auth)??"api-key"),[p,m]=d.useState((e==null?void 0:e.baseUrl)??""),[j,w]=d.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[b,x]=d.useState(""),[v,y]=d.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),g=k=>{u(k),f(k==="codex"?"chatgpt":"api-key"),x(""),m(k==="openai-compatible"?"http://localhost:11434/v1":""),w(k==="anthropic"?"claude-sonnet-5":k==="openai"?"gpt-5":"")},S=!o.trim()||!j.trim();return s.jsxs("form",{className:"ui-stack",onSubmit:k=>{k.preventDefault();const N=b;x(""),n(()=>A.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:o,kind:c,auth:h,baseUrl:p,defaultModel:j,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:v.trim()?Number(v):null,...N.trim()?{secret:N}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(ee,{label:"Account name",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:o,onChange:k=>a(k.target.value),placeholder:"Anthropic — Personal"})}),s.jsx(ee,{label:"Provider",children:s.jsxs("select",{disabled:!!e,value:h==="anthropic-oauth"?"anthropic-oauth":c,onChange:k=>{k.target.value==="anthropic-oauth"?(g("anthropic"),f("anthropic-oauth")):g(k.target.value)},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(l||(e==null?void 0:e.auth)==="anthropic-oauth")&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription (experimental)"}),(i||(e==null?void 0:e.kind)==="codex")&&s.jsx("option",{value:"codex",children:"ChatGPT subscription via Codex (experimental)"})]})}),c==="openai-compatible"&&s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:p,onChange:k=>m(k.target.value)})}),s.jsx(ee,{label:"Authentication",children:s.jsxs("select",{disabled:!!e,value:h,onChange:k=>{f(k.target.value),x("")},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),s.jsx(J,{valign:"end",children:s.jsx(Mm,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:j,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),s.jsx(ee,{label:"Context window",hint:"Tokens this endpoint actually serves. Leave blank unless you run the model yourself and set a window of your own — a conversation is ended once its history would fill half of this.",children:s.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:v,placeholder:e!=null&&e.detectedContextWindowTokens?String(e.detectedContextWindowTokens):"detected from the model",onChange:k=>y(k.target.value)})}),c==="codex"&&s.jsx("p",{className:"muted",children:"Enter a model available to your Codex subscription. API model availability is different; there is no automatic model fallback."}),h==="anthropic-oauth"&&s.jsx("p",{className:"muted",children:"Save this account, then choose Connect Claude. You will approve in your browser and paste the authorization code here, not in chat. No existing agent assignment changes."}),h==="api-key"&&s.jsx(ee,{label:e?"Replacement API key (leave blank to keep)":"API key",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:b,onChange:k=>x(k.target.value)})}),e&&s.jsx("p",{className:"muted",children:"Saving changes stops an active run at its next model call. Start a new turn afterward. Changing the default model does not change existing agent assignments."}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:r,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:S,children:"Save account"})]})]}),S&&s.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function rS({account:e,enabled:t,busy:n,run:r}){var o,a,c,u,h;const[i,l]=d.useState("");return d.useEffect(()=>{l("")},[(o=e.login)==null?void 0:o.attemptId,(a=e.login)==null?void 0:a.state]),s.jsxs(s.Fragment,{children:[!t&&s.jsx(G,{tone:"warning",children:"Claude OAuth is disabled on this host."}),s.jsxs(J,{children:[s.jsx(P,{disabled:n||!t||!e.enabled||e.removalPending||((c=e.login)==null?void 0:c.state)==="pending",onClick:()=>void r(()=>A.anthropicAccountAction(e.id,"login",e.revision),"Open the Claude consent link below. Existing credentials remain until sign-in succeeds."),children:e.configured?"Reconnect Claude":"Connect Claude"}),((u=e.login)==null?void 0:u.state)==="pending"&&s.jsx(P,{disabled:n,onClick:()=>{l(""),r(()=>A.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),s.jsx(P,{disabled:n||!e.configured||e.removalPending,onClick:()=>{l(""),r(()=>A.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((h=e.login)==null?void 0:h.state)==="pending"&&s.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:f=>{f.preventDefault();const p=i;l(""),r(()=>A.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:p}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[s.jsx("p",{children:s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),s.jsxs("p",{className:"muted",children:["Use the Claude account you want to connect. Paste the entire code including #state. This attempt expires at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),"; restarting Buddi also ends it."]}),s.jsx(ee,{label:"Claude authorization code",children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:f=>l(f.target.value),disabled:n})}),s.jsx(J,{align:"end",children:s.jsx(P,{type:"submit",variant:"accent",disabled:n||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const Pd={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5"};function Hv(e,t,n){const r=e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":"Local endpoint",i=new Set(n.map(l=>l.trim().toLowerCase()));if(!i.has(r.toLowerCase()))return r;for(let l=2;l<100;l+=1)if(!i.has(`${r} ${l}`.toLowerCase()))return`${r} ${l}`;return r}function fL({accounts:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:l}){const o=e.map(X=>X.label),[a,c]=d.useState(null),[u,h]=d.useState("anthropic"),[f,p]=d.useState("api-key"),[m,j]=d.useState(()=>Hv("anthropic","api-key",o)),[w,b]=d.useState(!1),[x,v]=d.useState(""),[y,g]=d.useState(""),[S,k]=d.useState(null),[N,C]=d.useState(!1),[T,E]=d.useState(""),[U,H]=d.useState(""),[O,R]=d.useState(!1),F=(X,ue)=>{h(X),p(ue),g(""),k(null),E(""),H(""),R(!1),v(X==="openai-compatible"?"http://localhost:11434/v1":""),w||j(Hv(X,ue,o))},K=a?e.find(X=>X.id===a):void 0;if(a)return K?s.jsx(hL,{account:K,busy:t,run:n,anthropicOAuthEnabled:l,onDone:()=>r(K.id)}):s.jsx(oe,{children:"Saving…"});const L=u==="openai-compatible",M=u==="codex"||f==="anthropic-oauth",V=!M&&(f==="none"||y.trim()!=="")&&(!L||x.trim()!==""),$=async()=>{var X,ue;C(!0),E("");try{const ye=await A.probeModels({kind:u,auth:f,...L?{baseUrl:x}:{},...y.trim()?{secret:y}:{}});k(ye),U||H(((X=ye.models.find(Ne=>Ne.isDefault))==null?void 0:X.id)??((ue=ye.models[0])==null?void 0:ue.id)??"")}catch(ye){E(ye instanceof Error?ye.message:"Could not load models. You can still enter a custom model.")}finally{C(!1)}},_=U.trim(),ne=!m.trim()||L&&!x.trim()||L&&!_;return s.jsxs("form",{className:"ui-stack",onSubmit:X=>{X.preventDefault();const ue=y;g("");const ye=_||Pd[u]||"claude-sonnet-5";(async()=>{let Ne;!await n(async()=>(Ne=await A.saveProviderAccount({label:m,kind:u,auth:f,baseUrl:x,defaultModel:ye,enabled:!0,...ue.trim()?{secret:ue}:{}}),Ne),"Account saved.")||!Ne||(_||!M?r(Ne.id):c(Ne.id))})()},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(ee,{label:"Provider",children:s.jsxs("select",{value:f==="anthropic-oauth"?"anthropic-oauth":u,onChange:X=>{if(X.target.value==="anthropic-oauth")F("anthropic","anthropic-oauth");else{const ue=X.target.value;F(ue,ue==="codex"?"chatgpt":"api-key")}},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),l&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription (experimental)"}),i&&s.jsx("option",{value:"codex",children:"ChatGPT subscription via Codex (experimental)"})]})}),s.jsx(ee,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:m,onChange:X=>{j(X.target.value),b(!0)},placeholder:"Anthropic — Personal"})}),L&&s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:x,onChange:X=>{v(X.target.value),k(null)}})}),s.jsx(ee,{label:"Authentication",children:s.jsxs("select",{value:f,onChange:X=>{p(X.target.value),g(""),k(null)},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),f==="api-key"&&s.jsx(ee,{label:"API key",hint:"Stored in the vault, never shown again.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:y,onChange:X=>{g(X.target.value),k(null)}})}),M?s.jsx("p",{className:"muted",children:u==="codex"?"You will connect your ChatGPT subscription on the next step, with a device code, and pick a model then.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Model"}),S?s.jsxs("div",{className:"ui-row",children:[s.jsxs("select",{"aria-label":"Model",value:O?"__custom__":U,onChange:X=>{X.target.value==="__custom__"?(R(!0),H("")):(R(!1),H(X.target.value))},children:[S.models.map(X=>s.jsxs("option",{value:X.id,children:[X.name===X.id?X.id:`${X.name} — ${X.id}`,X.isDefault?" (provider default)":"",X.thinks?" · thinks":""]},X.id)),s.jsx("option",{value:"__custom__",children:"Custom model…"})]}),s.jsx(P,{size:"sm",disabled:N||!V,onClick:()=>void $(),children:N?"Loading…":"Reload"})]}):s.jsxs("div",{className:"ui-row",children:[s.jsx(P,{disabled:N||!V,onClick:()=>void $(),children:N?"Loading models…":"Load models"}),L?s.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):s.jsxs("span",{className:"muted",children:["Optional now: ",Pd[u]," is used until you pick one."]})]}),O||L&&!S?s.jsx("input",{"aria-label":"Custom model",required:L,maxLength:150,value:U,onChange:X=>H(X.target.value),placeholder:L?"qwen3:8b":Pd[u]}):null,T?s.jsx("span",{className:"ui-field-hint critical",role:"alert",children:T}):null,S!=null&&S.truncated?s.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:()=>r(),children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:ne,children:"Save account"})]})]}),ne&&s.jsxs("p",{className:"muted",children:["Enter an account name",L?", an endpoint and a model":""," to enable Save account."]})]})}function hL({account:e,busy:t,run:n,anthropicOAuthEnabled:r,onDone:i}){const[l,o]=d.useState(e.defaultModel),a=e.configured;return s.jsxs(q,{gap:"lg",children:[s.jsxs(G,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!a?s.jsx(rS,{account:e,enabled:!!r,busy:t,run:n}):null,e.kind==="codex"&&!a?s.jsx(sS,{account:e,busy:t,run:n}):null,a?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-page-lede",children:"Pick the model this account offers by default. An agent can still choose another when you assign it."}),s.jsx(J,{valign:"end",children:s.jsx(Mm,{accountId:e.enabled?e.id:void 0,label:"Default model",value:l,onChange:o,disabled:t},`${e.id}:${e.revision}`)}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:i,children:"Skip for now"}),s.jsx(P,{variant:"accent",disabled:t||!l.trim(),onClick:()=>{if(l===e.defaultModel){i();return}n(()=>A.saveProviderAccount({...nS(e),defaultModel:l}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):s.jsx(J,{children:s.jsx(P,{onClick:i,children:"Finish later"})})]})}const Kv=["every-time","first-time","pre-approved"],iS={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function pL(e){const t=Kv.indexOf(e);return Kv.slice(0,t<0?1:t+1)}function lS(e){return e.endsWith(".account")}const mL="This account’s process holds the value for as long as its connection lives.",_m="Stored, not usable until it has a binding.";function gL(e){return e==="browser.field"?"the exact origin — scheme, host and port — e.g. https://localhost:8443":e==="browser.form.data"?"the origin, then the field name — e.g. https://localhost:8443 card-number":e==="browser.native.type"?"the app’s bundle id, e.g. com.bank.app":e==="http.header"?"the host, then the header name — e.g. localhost:9200 Authorization":e==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":lS(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const oS={"browser.form.data":{hint:"an origin, then the field name",build:(e,t)=>({origin:e,field:t})},"http.header":{hint:"a host, then the header name",build:(e,t)=>({host:e,header:t})},"developer.env":{hint:"a workspace, then the variable name",build:(e,t)=>({workspace:e,variable:t})}};function xL(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const n=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&n?[r,n]:null}function aS(e,t){const n=t.trim();if(n==="")return{ok:!1,error:"Give the exact place this value may go."};if(n.startsWith("{"))try{const l=JSON.parse(n);return l!==null&&typeof l=="object"&&!Array.isArray(l)?{ok:!0,target:l}:{ok:!1,error:'A target in JSON is an object, like {"host":"localhost","header":"Authorization"}.'}}catch{return{ok:!1,error:"That opens like JSON but does not parse."}}if(e==="browser.field"||e==="browser.native.type"||lS(e))return{ok:!0,target:n};const r=oS[e];if(r===void 0)return{ok:!0,target:n};const i=xL(n);return i===null?{ok:!1,error:`${e} needs both: ${r.hint}.`}:{ok:!0,target:r.build(i[0],i[1])}}function vL(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function jL(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const n=t,r=oS[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),l=i.map(o=>n[o]);if(i.every(o=>typeof n[o]=="string"))return l.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const cS="accounts.provider";function yL(e,t){for(const n of e)if(n.kind===cS&&typeof n.target=="string"){const r=t.get(n.target);if(r)return r}}function Ch(e,t,n){if(e===cS&&typeof t=="string"){const r=n.get(t);if(r)return r.label}return jL(e,t)}function uS(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function dS(e,t){if(typeof e!="object"||e===null)return[];const n=e[t];return Array.isArray(n)?n.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,l=r.count;return typeof i!="string"||typeof l!="number"||!(l>0)?[]:[{place:i,count:l}]}):[]}function fS(e){const t=e.map(({place:n,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?n.replace(/s$/,""):n}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function wL(e){const t=dS(e,"found");return t.length?`The value already sits in ${fS(t)}.`:""}function bL(e){const t=dS(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${fS(t)}.`:""}async function Lr(e,t,n,r){n(!0),r(null);try{return(await A.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{n(!1)}}function kL({embedded:e,timezone:t}={}){const n=le(()=>A.secrets(),[]),r=le(()=>A.providerAccounts(),[]),i=d.useMemo(()=>{var c;return new Map((((c=r.data)==null?void 0:c.accounts)??[]).map(u=>[u.id,{label:u.label,provider:$m(u)}]))},[r.data]),[l,o]=d.useState(!1),a=n.data;return s.jsxs(en,{embedded:e,title:"Keys and secrets",lede:"What the agents may use and never see: a name, a value buddi keeps, and the exact places the value may go.",children:[s.jsxs(q,{gap:"lg",children:[!a&&!n.error?s.jsx(oe,{children:"Opening the vault…"}):null,n.error?s.jsx(J,{children:s.jsx(P,{onClick:n.reload,children:"Retry"})}):null,a?s.jsx(Y,{title:"Secrets",aside:"A value the agents use and never see: bound to where it may go, never shown again.",actions:s.jsx(P,{variant:"accent",size:"sm",onClick:()=>o(!0),children:"Add a secret"}),panel:!0,children:s.jsx(q,{divided:!0,children:a.secrets.length===0?s.jsx(gt,{icon:"key",title:"Nothing stored yet",children:"Add one — a site password, an API token — and bind it to the places an agent may use it."}):a.secrets.map(c=>s.jsx(SL,{secret:c,accounts:i,destinations:a.destinations,timezone:t,onChanged:n.reload},c.name))})}):null,a?s.jsx(Y,{title:"buddi’s own keys",aside:"Read-only.",children:s.jsxs(q,{gap:"sm",children:[a.ownKeys.length===0?s.jsx(oe,{children:"No keys of buddi’s own right now."}):s.jsx("div",{className:"ui-list",children:a.ownKeys.map(c=>s.jsx("div",{className:"ui-list-row",children:s.jsx("span",{className:"ui-list-main",children:s.jsx("span",{className:"mono",children:c})})},c))}),s.jsx("p",{className:"ui-card-meta",children:"These are the keys buddi itself runs on. They cannot be bound or replaced here, and the scrubber replaces them in what buddi sends out, exactly like your own secrets."})]})}):null]}),l&&a?s.jsx(CL,{destinations:a.destinations,onClose:()=>o(!1),onChanged:n.reload}):null]})}function SL({secret:e,accounts:t,destinations:n,timezone:r,onChanged:i}){const[l,o]=d.useState(!1),[a,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(!1),[m,j]=d.useState(!1),w=async()=>{await Lr("secrets.delete",{name:e.name},o,c)!==null&&(p(!1),i())},b=e.lastUse,x=yL(e.bindings,t);return s.jsxs(q,{gap:"sm",children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:x?x.label:e.name}),x?s.jsx(_a,{children:x.provider}):null,e.totp?s.jsx(_a,{children:"TOTP"}):null,b?s.jsx(fe,{tone:uS(b.outcome),children:b.outcome}):null]}),x?s.jsx("p",{className:"ui-card-meta mono",children:e.name}):null,e.bindings.length===0?s.jsx("p",{className:"ui-card-meta",children:_m}):s.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((v,y)=>s.jsxs("div",{className:"ui-row",children:[s.jsx(_a,{children:v.kind}),s.jsx("span",{className:"mono",children:Ch(v.kind,v.target,t)}),s.jsx(fe,{tone:"muted",children:iS[v.rule]??v.rule})]},y))}),e.bindings.some(v=>v.heldByPlugin)?s.jsx("p",{className:"ui-card-meta",children:mL}):null,s.jsx("p",{className:"ui-card-meta",children:b?`Last used ${Se(b.at)}${b.agentId?` by ${b.agentId}`:""} — ${b.kind}, ${Ch(b.kind,b.target,t)}.`:"Never used."}),s.jsx(ie,{message:a}),f?s.jsxs(G,{tone:"critical",role:"alert",children:[s.jsxs("p",{children:["Delete “",e.name,"”? The value and its bindings go; the use log stays, under the name."]}),s.jsxs(J,{children:[s.jsx(P,{variant:"danger",disabled:l,onClick:()=>void w(),children:"Delete it"}),s.jsx(P,{disabled:l,onClick:()=>p(!1),children:"Cancel"})]})]}):null,s.jsxs(J,{children:[s.jsx(P,{size:"sm",disabled:l,onClick:()=>h("replace"),children:"Replace value"}),s.jsx(P,{size:"sm",disabled:l,onClick:()=>h("rename"),children:"Rename"}),s.jsx(P,{size:"sm",disabled:l,onClick:()=>h("rebind"),children:e.bindings.length===0?"Add a binding":"Rebind"}),s.jsx(P,{size:"sm",variant:"danger",disabled:l,onClick:()=>p(!0),children:"Delete"}),s.jsx(P,{size:"sm",variant:"ghost","aria-expanded":m,onClick:()=>j(!m),children:"Use log"})]}),m?s.jsx(NL,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?s.jsx(EL,{secret:e,onClose:()=>h(null),onChanged:i}):null,u==="rename"?s.jsx(AL,{secret:e,onClose:()=>h(null),onChanged:i}):null,u==="rebind"?s.jsx(RL,{secret:e,destinations:n,onClose:()=>h(null),onChanged:i}):null]})}function NL({name:e,accounts:t,timezone:n}){const r=le(()=>A.secretUses(e,50),[e]);if(r.error)return s.jsx(ie,{message:r.error});if(!r.data)return s.jsx(oe,{children:"Reading the log…"});const i=r.data.uses;return i.length===0?s.jsx(oe,{children:"No uses yet."}):s.jsx("div",{className:"ui-list",children:i.map((l,o)=>s.jsxs("div",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[Pe(l.at,n??"UTC")," — ",l.kind,", ",Ch(l.kind,l.target,t)]}),s.jsxs("span",{className:"ui-list-sub",children:[l.agent?l.agent:"the owner",l.plugin?` · ${l.plugin}`:"",l.detail?` · ${l.detail}`:""]})]}),s.jsx("span",{className:"ui-list-side",children:s.jsx(fe,{tone:uS(l.outcome),children:l.outcome})})]},o))})}function hS({name:e,result:t,scrubbed:n,busy:r,failure:i,onScrub:l,onDone:o}){const a=wL(t);return s.jsxs(q,{gap:"sm",children:[s.jsxs(G,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),s.jsx("p",{className:"ui-card-meta",children:a||"Nothing of the value sits where buddi already holds text."}),s.jsx(ie,{message:i}),a?s.jsx(J,{children:s.jsx(P,{variant:"accent",disabled:r||n!==null,onClick:l,children:n===null?"Scrub the history":bL(n)||"Nothing of it was left to replace."})}):null,s.jsx(J,{align:"end",children:s.jsx(P,{onClick:o,children:"Done"})})]})}function pS({destinations:e,bindings:t,disabled:n,onChange:r}){const i=(l,o)=>{r(t.map((a,c)=>c===l?{...a,...o}:a))};return s.jsx(q,{gap:"sm",children:t.map((l,o)=>{const a=e.find(u=>u.kind===l.kind),c=(a==null?void 0:a.maxRule)??l.rule;return s.jsxs(J,{valign:"end",children:[s.jsx(ee,{label:"Kind",inline:!0,children:s.jsx("select",{value:l.kind,disabled:n,onChange:u=>{var f;const h=u.target.value;i(o,{kind:h,rule:((f=e.find(p=>p.kind===h))==null?void 0:f.maxRule)??l.rule})},children:(a?e:[...e,{kind:l.kind,plugin:"",maxRule:l.rule}]).map(u=>s.jsx("option",{value:u.kind,children:u.kind},u.kind))})}),s.jsx(ee,{label:"Target",inline:!0,grow:!0,children:s.jsx("input",{type:"text",spellCheck:!1,disabled:n,value:l.target,placeholder:gL(l.kind),onChange:u=>i(o,{target:u.target.value})})}),s.jsx(ee,{label:"Rule",inline:!0,children:s.jsx("select",{value:l.rule,disabled:n,onChange:u=>i(o,{rule:u.target.value}),children:pL(c).map(u=>s.jsx("option",{value:u,children:iS[u]},u))})}),s.jsx(P,{size:"sm",variant:"ghost",disabled:n,onClick:()=>r(t.filter((u,h)=>h!==o)),children:"Remove"})]},o)})})}function CL({destinations:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[l,o]=d.useState(""),[a,c]=d.useState(!1),[u,h]=d.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:e[0].maxRule}]:[]),[f,p]=d.useState(!1),[m,j]=d.useState(null),[w,b]=d.useState(null),[x,v]=d.useState(null),y=async()=>{const S=u.map(T=>aS(T.kind,T.target)),k=S.findIndex(T=>!T.ok);if(k!==-1){j(`Binding ${k+1}: ${S[k].error}`);return}const N=l;o("");const C=await Lr("secrets.put",{name:r.trim(),value:N,totp:a,bindings:u.map((T,E)=>({kind:T.kind,target:S[E].target,rule:T.rule}))},p,j);C!==null&&(b({name:r.trim(),result:C}),n())},g=async()=>{const S=await Lr("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},p,j);S!==null&&(v(S),n())};return s.jsx(Wt,{title:"Add a secret",onClose:t,children:w?s.jsx(hS,{name:w.name,result:w.result,scrubbed:x,busy:f,failure:m,onScrub:()=>void g(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:S=>{S.preventDefault(),y()},children:s.jsxs("fieldset",{disabled:f,className:"ui-stack","data-gap":"sm",children:[s.jsx(ee,{label:"Name",hint:"What an agent calls it. Saving a name that exists replaces that secret’s value.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:S=>i(S.target.value),placeholder:"PNC password"})}),s.jsx(ee,{label:"Value",hint:"Kept in the vault, never shown again — not even here.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:l,onChange:S=>o(S.target.value)})}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:S=>c(S.target.checked)}),s.jsx("span",{children:"The code comes from this secret"})]}),s.jsx("p",{className:"ui-field-hint",children:"The seed and the code are one thing buddi holds — the owner’s explicit choice per secret."}),s.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[s.jsx("span",{className:"ui-field-label",children:"Bindings — the places this value may go"}),s.jsx(pS,{destinations:e,bindings:u,disabled:f,onChange:h}),u.length===0?s.jsx("p",{className:"ui-field-hint",children:_m}):null,e.length?s.jsx(J,{children:s.jsx(P,{size:"sm",onClick:()=>h([...u,{kind:e[0].kind,target:"",rule:e[0].maxRule}]),children:"Add a binding"})}):s.jsx("p",{className:"ui-field-hint",children:"No destination is registered on this installation yet, so there is nothing to bind to."})]}),m?s.jsx(G,{tone:"critical",role:"alert",children:m}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save secret"})]})]})})})}function EL({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[l,o]=d.useState(!1),[a,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),m=async()=>{const w=r;i("");const b=await Lr("secrets.put",{name:e.name,value:w,totp:e.totp,bindings:e.bindings.map(({kind:x,target:v,rule:y})=>({kind:x,target:v,rule:y}))},o,c);b!==null&&(h(b),n())},j=async()=>{const w=await Lr("secrets.scrub_history",{name:e.name},o,c);w!==null&&(p(w),n())};return s.jsx(Wt,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?s.jsx(hS,{name:e.name,result:u,scrubbed:f,busy:l,failure:a,onScrub:()=>void j(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:w=>{w.preventDefault(),m()},children:s.jsxs("fieldset",{disabled:l,className:"ui-stack","data-gap":"sm",children:[s.jsx(ee,{label:"New value",hint:"Replaces what is stored. The bindings stay as they are.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,value:r,onChange:w=>i(w.target.value)})}),a?s.jsx(G,{tone:"critical",role:"alert",children:a}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save value"})]})]})})})}function AL({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(e.name),[l,o]=d.useState(!1),[a,c]=d.useState(null),u=async()=>{await Lr("secrets.rename",{name:e.name,to:r.trim()},o,c)!==null&&(n(),t())};return s.jsx(Wt,{title:`Rename “${e.name}”`,onClose:t,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:h=>{h.preventDefault(),u()},children:s.jsxs("fieldset",{disabled:l,className:"ui-stack","data-gap":"sm",children:[s.jsx(ee,{label:"New name",hint:"The vault entry never moves; only the name the agents ask for does.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:h=>i(h.target.value)})}),a?s.jsx(G,{tone:"critical",role:"alert",children:a}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:!r.trim()||r.trim()===e.name,children:"Save name"})]})]})})})}function RL({secret:e,destinations:t,onClose:n,onChanged:r}){const[i,l]=d.useState(()=>e.bindings.map(f=>({kind:f.kind,target:vL(f.target),rule:f.rule}))),[o,a]=d.useState(!1),[c,u]=d.useState(null),h=async()=>{const f=i.map(j=>aS(j.kind,j.target)),p=f.findIndex(j=>!j.ok);if(p!==-1){u(`Binding ${p+1}: ${f[p].error}`);return}await Lr("secrets.rebind",{name:e.name,bindings:i.map((j,w)=>({kind:j.kind,target:f[w].target,rule:j.rule}))},a,u)!==null&&(r(),n())};return s.jsx(Wt,{title:`Rebind “${e.name}”`,onClose:n,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:f=>{f.preventDefault(),h()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(pS,{destinations:t,bindings:i,disabled:o,onChange:l}),i.length===0?s.jsx("p",{className:"ui-field-hint",children:_m}):null,t.length?s.jsx(J,{children:s.jsx(P,{size:"sm",onClick:()=>l([...i,{kind:t[0].kind,target:"",rule:t[0].maxRule}]),children:"Add a binding"})}):null,c?s.jsx(G,{tone:"critical",role:"alert",children:c}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save bindings"})]})]})})})}function TL({timezone:e,embedded:t}){const{data:n,error:r,reload:i}=le(()=>A.sentinels(),[],3e4),[l,o]=d.useState(null),[a,c]=d.useState(null),u=(n==null?void 0:n.installed)??[],h=((n==null?void 0:n.runs)??[]).filter(m=>m.lastError),f=u.filter(m=>!m.enabled),p=(m,j)=>{o(m),c(null),A.setSentinelEnabled(m,j).catch(w=>c(w instanceof pe?w.message:String(w))).finally(()=>{o(null),i()})};return s.jsxs(en,{embedded:t,title:"Watchers",children:[s.jsx(ie,{message:r??a}),s.jsx(G,{children:"Watchers are small checks that run on their own, with no model involved. An urgent finding wakes an agent, which verifies it before it tells you. The rest waits for the weekly recap."}),h.length>0?s.jsx(G,{tone:"warning",children:h.length===1?"One watcher failed on its last run.":`${h.length} watchers failed on their last run.`}):null,f.length>0?s.jsxs(G,{tone:"warning",children:[f.length===1?"One watcher is off.":`${f.length} watchers are off.`," A watcher that is off does not run, and what it already found stays as it was."]}):null,s.jsx(Y,{title:"Installed",aside:s.jsx("a",{href:`${Je}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:n?u.length===0?s.jsx(gt,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):s.jsx(un,{children:u.map(m=>{const j=n.runs.find(w=>w.sentinelId===m.id);return s.jsx(Cn,{lead:s.jsx(fe,{tone:m.enabled?j!=null&&j.lastError?"critical":j?"good":void 0:"muted",children:m.enabled?j!=null&&j.lastError?"failed":j?"ok":"never ran":"off"}),title:m.description,sub:`${m.id}, every ${PL(m.every)}${j!=null&&j.lastError?`. ${j.lastError}`:""}`,side:s.jsxs(s.Fragment,{children:[s.jsx("span",{title:j?Pe(j.lastRunAt,e):void 0,children:j?Se(j.lastRunAt):"never ran"}),s.jsx(P,{size:"sm",disabled:l===m.id,onClick:()=>p(m.id,!m.enabled),children:m.enabled?"Turn off":"Turn on"})]})},m.id)})}):s.jsx(oe,{children:"Loading…"})})]})}function PL(e){if(e%86400===0){const n=e/86400;return n===1?"day":`${n} days`}if(e%3600===0){const n=e/3600;return n===1?"hour":`${n} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}function IL({embedded:e}){const{data:t,error:n,reload:r}=le(()=>A.owner(),[]);return s.jsxs(en,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[s.jsx(ie,{message:n}),t?s.jsx(ML,{initial:t,onSaved:r}):null]})}function ML({initial:e,onSaved:t}){const[n,r]=d.useState(e.preferredName??""),[i,l]=d.useState(e.timezone??""),[o,a]=d.useState(e.language??""),[c,u]=d.useState(e.about??""),[h,f]=d.useState(!1),[p,m]=d.useState(!1),[j,w]=d.useState(null);d.useEffect(()=>{r(e.preferredName??""),l(e.timezone??""),a(e.language??""),u(e.about??"")},[e]);const b=n.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||o.trim()!==(e.language??"")||c.trim()!==(e.about??""),x=async()=>{f(!0),w(null);try{await A.setOwner({preferredName:n.trim()===""?null:n.trim(),timezone:i===""?null:i,language:o.trim()===""?null:o.trim(),about:c.trim()===""?null:c.trim()}),m(!0),t()}catch(y){w(y instanceof pe?y.message:String(y))}finally{f(!1)}},v=e.zones.length>0?e.zones:[e.detectedTimezone];return s.jsx(Y,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:s.jsxs(s.Fragment,{children:[p&&!b?s.jsx("span",{className:"muted",children:"Saved"}):null,s.jsx(P,{variant:"accent",disabled:!b||h,onClick:()=>void x(),children:h?"Saving…":"Save"})]}),children:s.jsxs(q,{divided:!0,gap:"lg",children:[s.jsx(Y,{title:"Name and place",children:s.jsxs(Es,{children:[s.jsx(ee,{label:"What the agents call you",children:s.jsx("input",{value:n,maxLength:80,placeholder:e.displayName??"Your name",onChange:y=>{m(!1),r(y.target.value)}})}),s.jsx(ee,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:s.jsxs("select",{value:i,onChange:y=>{m(!1),l(y.target.value)},children:[s.jsx("option",{value:"",children:"Not set (use the host's)"}),v.map(y=>s.jsx("option",{value:y,children:y},y))]})}),s.jsx(ee,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:s.jsx("input",{value:o,maxLength:40,placeholder:"English, français…",onChange:y=>{m(!1),a(y.target.value)}})})]})}),s.jsxs(Y,{title:"About you",children:[s.jsx(ee,{label:"In your own words",hint:"Who you are, how you like answers, anything every agent should keep in mind. A few lines is plenty.",children:s.jsx("textarea",{rows:4,maxLength:1e3,value:c,placeholder:"I run a small studio and prefer short answers with the numbers first. Call me by my first name.",onChange:y=>{m(!1),u(y.target.value)}})}),j?s.jsx(G,{tone:"critical",children:j}):null]})]})})}const $L=2e6;function Gv(e,t){const n=e.replace(/\r\n/g,`
108
- `).replace(/\n+$/,"").split(`
109
- `),r=t.replace(/\r\n/g,`
110
- `).replace(/\n+$/,"").split(`
111
- `);if(e.trim()===t.trim())return"(no change)";if(n.length*r.length>$L)return[...n.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
112
- `);const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let c=n.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=n[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const l=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(l.push(` ${n[o]}`),o++,a++):i[o+1][a]>=i[o][a+1]?l.push(`-${n[o++]}`):l.push(`+${r[a++]}`);for(;o<n.length;)l.push(`-${n[o++]}`);for(;a<r.length;)l.push(`+${r[a++]}`);return l.join(`
113
- `)}const _L={skill:"skill",policy:"rule",change:"change to itself"};function OL(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,n])=>!/Id$/.test(t)&&n!==null&&n!==void 0&&n!=="").map(([t,n])=>`${t} ${typeof n=="object"?JSON.stringify(n):String(n)}`).join(" · ")}function Eh(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function DL(e,t){const n=e.change;if(!n||n.part!=="tools")return[];if(t===e.editable)return n.added;const r=new Set(Eh(n.current??""));return Eh(t).filter(i=>!r.has(i))}function Yv(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function LL({embedded:e,plugin:t}){const{data:n,error:r,reload:i}=le(()=>A.proposals(),[],3e4),[l,o]=d.useState(null),[a,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState({}),m=async(x,v,y=!1)=>{o(null),c(null),h(x),p(({[x]:g,...S})=>S);try{c(await v()),i()}catch(g){const S=g instanceof Error?g.message:String(g);y?p(k=>({...k,[x]:S})):o(S)}finally{h(null)}},j=hk(),w=((n==null?void 0:n.open)??[]).filter(x=>Yv(x,t)),b=((n==null?void 0:n.closed)??[]).filter(x=>Yv(x,t));return s.jsxs(en,{embedded:e,title:"Proposals",lede:"What your agents learned and would like to keep: a procedure, a rule, a change to their own instructions. Nothing here applies itself. Keep what is right, correct what is nearly right, discard the rest.",children:[s.jsx(ie,{message:r??l}),t?s.jsxs(G,{role:"status",children:["Showing the rules ",t," proposes. ",s.jsx("a",{href:ht("proposals"),children:"Show every proposal"})]}):null,a?s.jsx(G,{tone:"good",role:"status",children:a}):null,t?null:s.jsx(pk,{offers:j.offers,reload:j.reload}),!n||w.length===0?s.jsx(Y,{title:"Waiting",panel:!0,children:n?t?s.jsx(gt,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):s.jsx(gt,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):s.jsx(oe,{children:"Loading…"})}):s.jsx(Y,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(x=>s.jsx(zL,{proposal:x,busy:u===x.id,refusal:f[x.id]??null,onKeep:v=>void m(x.id,async()=>{const y=await A.keepProposal(x.id,v);return`${x.title}: ${y.note}`},!0),onDiscard:v=>void m(x.id,async()=>(await A.discardProposal(x.id,v),`Discarded: ${x.title}. ${x.agent} will be told once and will not propose it again for 90 days.`))},x.id))}),b.length>0?s.jsx(Y,{title:`Kept, discarded and expired (${b.length})`,aside:"These stop being shown a week after they were decided.",panel:!0,flush:!0,children:s.jsx(un,{children:b.map(x=>{var v;return s.jsx(Cn,{title:x.title,sub:`${x.agent}: ${FL(x)}`,side:x.kind==="skill"&&x.state==="kept"&&((v=x.skill)!=null&&v.live)?s.jsxs(J,{align:"end",children:[s.jsx("span",{className:"muted",children:Se(x.decidedAt??x.createdAt)}),s.jsx(P,{size:"sm",variant:"ghost",disabled:u===x.id,onClick:()=>void m(x.id,async()=>{const y=x.skill;return await A.removeSkill(x.agent,y.name),`Removed ${y.name} from ${x.agent}. Its versions are kept, and ${x.agent} will not propose it again for 90 days.`}),children:"Remove this skill"})]}):Se(x.decidedAt??x.createdAt)},x.id)})})}):null,!t&&(n!=null&&n.digest)?s.jsx(BL,{schedule:n.digest.schedule,onSaved:i}):null]})}function FL(e){switch(e.state){case"kept":return e.kind==="skill"&&e.skill?e.skill.live?`Kept as ${e.skill.name}, version ${e.skill.version}; it loads on the agent's next run.`:`Kept; ${e.skill.name} has a newer version now (${e.skill.version}).`:e.note??"Kept.";case"discarded":return e.reason?`Discarded: ${e.reason}`:"Discarded.";case"expired":return`Expired: ${e.reason??"not decided in 30 days"}.`;default:return"Waiting."}}const UL=Array.from({length:24},(e,t)=>t),qv=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function BL({schedule:e,onSaved:t}){const[n,r]=d.useState(e.day),[i,l]=d.useState(e.hour),[o,a]=d.useState(!1),[c,u]=d.useState(null),h=n!==e.day||i!==e.hour,f=async()=>{a(!0),u(null);try{await A.setDigestSchedule(n,i),u({tone:"good",text:`The digest now runs on ${qv[n]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(p){u({tone:"critical",text:p instanceof Error?p.message:String(p)})}finally{a(!1)}};return s.jsx(Y,{title:"Weekly digest",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:o||!h,onClick:()=>void f(),children:"Save"}),children:s.jsxs(q,{children:[s.jsxs("p",{className:"muted",children:["Once a week, one message on Telegram and a card on Home: what your agents learned, what waits here, and what the rules you kept stopped them doing. No message when nothing was learned and nothing waits.",e.next?` Next: ${Se(e.next)}.`:""]}),s.jsxs(J,{children:[s.jsx(ee,{label:"Day",children:s.jsx("select",{value:n,disabled:o,onChange:p=>r(Number(p.target.value)),children:qv.map((p,m)=>s.jsx("option",{value:m,children:p},p))})}),s.jsx(ee,{label:`Hour (${e.timezone})`,children:s.jsx("select",{value:i,disabled:o,onChange:p=>l(Number(p.target.value)),children:UL.map(p=>s.jsxs("option",{value:p,children:[String(p).padStart(2,"0"),":00"]},p))})})]}),c?s.jsx(G,{tone:c.tone,role:"status",children:c.text}):null]})})}function Qv(e,t){return e==="tools"?Eh(t).join(`
114
- `):t}function zL({proposal:e,busy:t,refusal:n,onKeep:r,onDiscard:i}){const[l,o]=d.useState(e.editable??""),[a,c]=d.useState(""),u=e.editable!==null&&l!==e.editable,h=e.payload,f=e.echoes??[],p=e.kind==="change"?e.change??null:null,m=DL(e,l);return s.jsx(Or,{tone:e.untrusted?"warning":"accent",title:e.title,meta:s.jsxs(s.Fragment,{children:[s.jsx(fe,{children:_L[e.kind]}),s.jsx(fe,{mono:!0,children:e.agent}),e.untrusted?s.jsx(fe,{tone:"warning",children:"untrusted text in view"}):null,m.length>0?s.jsx(fe,{tone:"warning",children:"widens its tools"}):null]}),foot:s.jsxs(J,{align:"end",children:[n?s.jsx("span",{className:"proposal-refusal",role:"alert",children:n}):null,s.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:a,maxLength:300,disabled:t,onChange:j=>c(j.target.value)}),s.jsx(P,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(a.trim()||void 0),children:"Discard"}),s.jsx(P,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&l.trim()==="",onClick:()=>r(u?l:void 0),children:u?"Keep my version":"Keep"})]}),children:s.jsxs(q,{gap:"sm",children:[e.why?s.jsx("p",{children:e.why}):null,s.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",Se(e.createdAt),e.conversationId?s.jsxs(s.Fragment,{children:[" in ",s.jsx("a",{href:Di(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?s.jsxs(G,{tone:"warning",title:e.kind==="policy"?"Learned from mail you received.":"Made with untrusted text in view.",children:[e.kind==="policy"?"The plugin counted this rule from your own triage decisions; no instruction in that mail can change what it does.":"Something written by someone other than you was in the agent's context when it proposed this. Read it for instructions that came from there rather than from you.",s.jsx("ul",{className:"proposal-sources",children:e.sources.map(j=>s.jsx("li",{className:"mono",children:j},j))}),f.length>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),s.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:f.map(j=>s.jsx("li",{children:s.jsx("mark",{className:"wb-diff-mark",children:j})},j))})]}):null]}):null,e.kind==="skill"?s.jsxs(s.Fragment,{children:[typeof h.when=="string"?s.jsxs("p",{className:"ui-card-meta",children:["When: ",h.when]}):null,e.skill?s.jsxs(q,{gap:"sm",children:[s.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",s.jsxs("a",{href:It(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),s.jsx(wc,{text:Gv(e.skill.steps,l),marks:f,label:`Version ${e.skill.version} against this proposal`})]}):null,s.jsx(ee,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:s.jsx("textarea",{rows:8,value:l,disabled:t,onChange:j=>o(j.target.value)})})]}):null,e.kind==="change"?s.jsxs(s.Fragment,{children:[m.length>0?s.jsxs(G,{tone:"warning",title:`Adds: ${m.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,p!=null&&p.refusal&&!u?s.jsx(G,{tone:"warning",title:"Keeping this as proposed will be refused.",children:p.refusal}):null,p&&p.current!==null?s.jsx(wc,{text:Gv(Qv(p.part,p.current),Qv(p.part,l)),marks:f,label:`${e.agent}'s ${p.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof h.before=="string"?s.jsx(Nt,{summary:`What its ${h.part==="tools"?"tool list":"instructions"} said when proposed`,children:s.jsx(rt,{children:h.before})}):null,s.jsx(ee,{label:h.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:s.jsx("textarea",{rows:8,value:l,disabled:t,onChange:j=>o(j.target.value)})})]}):null,e.kind==="policy"?s.jsx(bt,{items:[{label:"Plugin",value:s.jsx("span",{className:"mono",children:String(h.plugin??"")})},{label:"Matches",value:s.jsx("span",{className:"mono",children:OL(h.matcher??{})})},{label:"Does",value:String(h.action??"")},{label:"Learned from",value:(()=>{const j=Array.isArray(h.verdicts)?h.verdicts.length:0;return`${j} ${j===1?"decision":"decisions"}`})()}]}):null]})})}const WL=1500,VL={fetching:"Fetching the package.","installing-dependencies":"Installing its dependencies. Nothing of the plugin has run.",reading:"Reading what it says it is.",done:"Read. Nothing has been imported yet.",failed:"That did not work."},HL="Restart buddi to load it. In a checkout, stop it and run: buddi serve",mS=[{id:"npm",label:"From npm"},{id:"file",label:"A file"},{id:"directory",label:"A directory I built"}],gS="buddi.plugins.install-mode";function KL(){try{const e=window.localStorage.getItem(gS);if(mS.some(t=>t.id===e))return e}catch{}return"npm"}function GL(e){try{window.localStorage.setItem(gS,e)}catch{}}const ha=".tgz";function YL(e){const t=[],n=(r,i,l)=>{r>0&&t.push(`${r} ${r===1?i:l}`)};return n(e.tools,"tool","tools"),n(e.sentinels,"watcher","watchers"),n(e.views,"view","views"),n(e.agents,"agent","agents"),t.length===0?"nothing on its own":t.join(", ")}function xS(e){return e.kind==="registry"?`npm · ${e.name}@${e.version}`:e.kind==="tarball"?`a file on this machine · ${e.path}`:`a directory on this machine · ${e.path}`}function qL(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function QL(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(null);return d.useEffect(()=>{if(!e){n(void 0),i(null);return}let l=!1;const o=()=>{A.pluginJob(e).then(c=>{l||(n(c),(c.phase==="done"||c.phase==="failed")&&(l=!0))}).catch(c=>{l||(i(c instanceof pe?c.message:String(c)),l=!0)})};o();const a=window.setInterval(o,WL);return()=>{l=!0,window.clearInterval(a)}},[e]),{job:t,error:r}}function JL(){const e=le(()=>A.plugins(),[],2e4),[t,n]=d.useState(null),{job:r,error:i}=QL(t),[l,o]=d.useState(null),[a,c]=d.useState(null);d.useEffect(()=>{((r==null?void 0:r.phase)==="done"||(r==null?void 0:r.phase)==="failed")&&e.reload()},[r==null?void 0:r.phase]);const u=e.data,h=(u==null?void 0:u.checkout)??!0;return s.jsxs(q,{gap:"lg",children:[s.jsx(ie,{message:e.error??l??i}),u!=null&&u.unavailable?s.jsx(G,{tone:"warning",children:u.unavailable}):null,s.jsx(Y,{title:"Plugins",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsx(G,{tone:"warning",children:(u==null?void 0:u.trust)??""})}),s.jsx(Y,{children:s.jsx(ZL,{busy:r!==void 0&&r.phase!=="done"&&r.phase!=="failed",onStaged:f=>{o(null),c(null),n(f)},onFailed:o})}),r?s.jsx(Y,{children:s.jsxs(G,{tone:r.phase==="failed"?"critical":r.phase==="done"?"good":void 0,role:"status",children:[VL[r.phase]," ",r.error??""]})}):null]})}),((u==null?void 0:u.staged)??[]).map(f=>s.jsx(tF,{staged:f,onInstalled:p=>{c(p),n(null),e.reload()},onGone:()=>e.reload()},f.id)),a||u!=null&&u.restartNeeded?s.jsx(nF,{checkout:h,name:a}):null,s.jsx(Y,{title:"Installed",panel:!0,children:u?u.installed.length===0?s.jsx(gt,{icon:"plug",title:"Nothing installed yet",children:"Only what buddi ships with is here."}):s.jsx(q,{divided:!0,children:u.installed.map(f=>s.jsx(Y,{children:s.jsx(rF,{plugin:f,onChanged:()=>e.reload(),onFailed:o})},f.name))}):s.jsx(oe,{children:"Loading…"})}),((u==null?void 0:u.builtIn)??[]).length>0?s.jsx(Y,{title:"Ships with buddi",panel:!0,children:s.jsx(q,{divided:!0,children:((u==null?void 0:u.builtIn)??[]).map(f=>s.jsx(Y,{children:s.jsx(XL,{plugin:f})},f.name))})}):null]})}function XL({plugin:e}){return s.jsxs(q,{gap:"sm",children:[s.jsx(bt,{items:[{label:s.jsx("span",{children:e.name}),value:s.jsxs("span",{children:[e.version," · ",YL(e.contribution)]})}]}),e.description?s.jsx("p",{className:"ui-card-meta",children:e.description}):null]})}function ZL({busy:e,onStaged:t,onFailed:n}){const[r,i]=d.useState(KL),[l,o]=d.useState(""),[a,c]=d.useState(!1),[u,h]=d.useState(null),[f,p]=d.useState(null),[m,j]=d.useState(!1),w=d.useRef(null),b=g=>n(g instanceof pe?g.message:String(g)),x=g=>{i(g),GL(g),p(null)},v=()=>{c(!0),A.stagePlugin(l.trim()).then(g=>{t(g.job.id),o("")}).catch(b).finally(()=>c(!1))},y=g=>{if(g){if(!g.name.toLowerCase().endsWith(ha)){h(null),p(`${g.name} is not a ${ha}. A packed plugin is the file npm pack writes.`);return}p(null),h(g.name),c(!0),A.uploadPlugin(g).then(S=>t(S.job.id)).catch(b).finally(()=>c(!1))}};return s.jsxs(q,{gap:"sm",children:[s.jsx("div",{className:"plugin-modes",role:"radiogroup","aria-label":"Where it comes from",children:mS.map(g=>s.jsx("button",{type:"button",role:"radio","aria-checked":r===g.id,className:"plugin-mode","data-chosen":r===g.id?"true":void 0,onClick:()=>x(g.id),children:g.label},g.id))}),r==="file"?s.jsxs("div",{className:"plugin-drop",role:"group","aria-label":"A plugin file","data-state":m?"over":f?"refused":u?"chosen":void 0,onDragOver:g=>{g.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:g=>{var S,k;g.preventDefault(),j(!1),y((k=(S=g.dataTransfer)==null?void 0:S.files)==null?void 0:k[0])},children:[s.jsx("p",{className:"ui-card-meta",children:f??(u?`${u} — reading it.`:`Drop a ${ha} here, or choose one.`)}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||a,onClick:()=>{var g;return(g=w.current)==null?void 0:g.click()},children:"Choose a file"})}),s.jsx("input",{ref:w,type:"file",accept:ha,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:g=>{var S;y((S=g.target.files)==null?void 0:S[0]),g.target.value=""}})]}):s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:r==="npm"?"Install a plugin":"The directory it is in",hint:r==="npm"?"A package name, or a name@version.":"The folder with its package.json, already built.",children:s.jsx("input",{type:"text",value:l,placeholder:r==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:g=>o(g.target.value)})}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||a||l.trim()==="",onClick:v,children:"Read it first"})})]})]})}function eF({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],n=((i=e.uses)==null?void 0:i.dropped)??[];return s.jsx(Y,{title:"What it reaches in buddi",children:s.jsxs(q,{gap:"sm",children:[t.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nothing beyond its own tables, its own folder and its own tools' approvals."}):s.jsx("ul",{className:"plugin-uses",children:t.map(l=>s.jsxs("li",{children:["It ",l.words,"."," ",l.added?s.jsxs(fe,{tone:"warning",children:["new in ",e.version]}):null]},l.use))}),n.length>0?s.jsxs("p",{className:"ui-card-meta",children:["No longer: ",n.map(l=>l.words).join("; "),"."]}):null]})})}function tF({staged:e,onInstalled:t,onGone:n}){const[r,i]=d.useState(e.plan??null),[l,o]=d.useState(!1),[a,c]=d.useState(null),u=p=>{o(!0),c(null),A.approveStaged(e.id,{integrity:e.integrity??"",...p?{acknowledgeDrift:!0}:{}}).then(m=>{m.installed?t(e.name):m.plan&&i(m.plan)}).catch(m=>c(m instanceof pe?m.message:String(m))).finally(()=>o(!1))},h=()=>{o(!0),c(null),A.rejectStaged(e.id).then(()=>n()).catch(p=>c(p instanceof pe?p.message:String(p))).finally(()=>o(!1))},f=(r==null?void 0:r.drift)??[];return s.jsxs(q,{gap:"lg",children:[s.jsx(Or,{tone:"accent",title:`${e.name} ${e.version}`,meta:s.jsx(fe,{tone:"muted",children:"read, not installed"}),children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:a}),s.jsx(bt,{items:[{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:xS(e.source)},{label:"Published by",value:e.publisher??"nobody npm will name"},{label:"Integrity",value:s.jsx("span",{className:"mono",children:e.integrity===void 0||e.integrity===""?"none — this came off a disk":e.integrity})},...e.stagedHash?[{label:"Files on disk",value:s.jsx("span",{className:"mono",children:e.stagedHash})}]:[],{label:"Dependencies",value:e.dependencies.count===0?"none":`${e.dependencies.count}${e.dependencies.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${e.dependencies.withScripts.join(", ")}`}`}]}),s.jsx(eF,{staged:e}),s.jsx(Y,{title:"What the package says about itself",children:s.jsxs(q,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"This is its claim, taken from its own buddi.md. Nothing has checked it yet."}),s.jsx(bt,{items:[{label:"Schema it owns",value:e.claims.schema??"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":e.claims.hosts.join(", ")}]}),e.claims.missing?s.jsx("p",{className:"ui-card-meta",children:"It ships no buddi.md, so it says nothing about itself at all."}):s.jsx("p",{className:"ui-card-meta",children:e.claims.text})]})}),s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:l,onClick:h,children:"Not this one"}),s.jsx(P,{variant:"accent",disabled:l||f.length>0,onClick:()=>u(!1),children:"Install"})]})]})}),f.length>0?s.jsx(Or,{tone:"warning",title:"What it said, and what it does",meta:s.jsx(fe,{tone:"warning",children:"read this first"}),children:s.jsxs(q,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),s.jsx("ul",{className:"plugin-drift",children:f.map(p=>s.jsx("li",{children:p},p))}),s.jsx(vS,{unlocks:(r==null?void 0:r.agents)??[]}),s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:l,onClick:h,children:"Not this one"}),s.jsx(P,{variant:"danger",disabled:l,onClick:()=>u(!0),children:"Install anyway"})]})]})}):null]})}function nF({checkout:e,name:t}){const[n,r]=d.useState(!1),[i,l]=d.useState(null),o=t?`${t} is installed.`:"Something is installed that this buddi has not loaded.";return s.jsx(Y,{title:"Restart to load it",panel:!0,children:s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:i}),s.jsxs(G,{tone:e?"warning":void 0,role:"status",children:[o," ",e?HL:"Its tools appear once buddi restarts. That closes this dashboard for a few seconds."]}),e?null:s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:n,onClick:()=>{r(!0),l(null),A.serviceAction("restart").catch(a=>l(a instanceof pe?a.message:String(a))).finally(()=>r(!1))},children:"Restart to load it"})})]})})})}function vS({plugin:e,unlocks:t}){return t.length===0?null:s.jsx(Y,{title:"Agents it would unlock",children:s.jsxs(q,{gap:"sm",divided:!0,children:[t.map(n=>s.jsx(sF,{plugin:e,unlock:n},n.id)),s.jsxs("p",{className:"ui-card-meta",children:["Nothing here is created by installing. Accept creates the agent with the tools listed. You can change or remove it ",s.jsx("a",{href:Xe,children:"on the Agents page"}),"."]})]})})}function sF({plugin:e,unlock:t}){const n=uk(e,t.id),r=t.drift.state!=="not-accepted";return s.jsxs(q,{gap:"sm",children:[s.jsxs(J,{children:[s.jsxs("span",{className:"mono",children:["@",t.handle]}),s.jsx(fe,{tone:t.drift.state==="up-to-date"?"good":"warning",children:t.drift.state}),s.jsx("span",{className:"ui-card-meta",children:t.drift.message}),s.jsx(tl,{}),e&&!r&&!n.created?s.jsx(P,{size:"sm",disabled:n.busy,onClick:n.accept,children:"Accept"}):null]}),s.jsx(ie,{message:n.failure}),n.created?s.jsx(dk,{agent:n.created}):null]})}function rF({plugin:e,onChanged:t,onFailed:n}){const[r,i]=d.useState(!1),[l,o]=d.useState(!1),[a,c]=d.useState(""),[u,h]=d.useState(!1),f=m=>{h(!0),m.then(()=>{i(!1),o(!1),c(""),t()}).catch(j=>n(j instanceof pe?j.message:String(j))).finally(()=>h(!1))},p=e.contribution;return s.jsxs(q,{gap:"sm",children:[s.jsx(Or,{tone:e.loaded?void 0:"critical",title:`${e.name} ${e.version}`,meta:e.loaded?s.jsx(fe,{tone:"good",children:"loaded"}):s.jsx(fe,{tone:"critical",children:"did not load"}),actions:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",variant:"ghost",disabled:u,onClick:()=>i(!r),children:"Remove…"}),s.jsx(P,{size:"sm",disabled:u,onClick:()=>f(A.updatePlugin(e.name)),children:"Update"})]}),children:s.jsxs(q,{gap:"sm",children:[e.error?s.jsx(G,{tone:"critical",children:e.error}):null,s.jsx(bt,{items:[{label:"From",value:xS(e.source)},{label:"Published by",value:qL(e.source,e.publisher)},{label:"Installed",value:Se(e.installedAt)},{label:"Contributes",value:`${p.tools} tool${p.tools===1?"":"s"}, ${p.sentinels} on a timer, ${p.views} view${p.views===1?"":"s"}, ${p.agents} agent${p.agents===1?"":"s"} proposed`}]}),s.jsx(vS,{plugin:e.name,unlocks:e.unlocks})]})}),r?s.jsxs(q,{gap:"sm",children:[s.jsx(G,{tone:"warning",children:"Removing it stops its code loading and leaves its tables exactly where they are, so installing it again picks up where it left off."}),s.jsxs("label",{className:"plugin-check",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:m=>{o(m.target.checked),c("")}}),s.jsx("span",{children:"Also drop its data. Its tables are not recoverable afterwards."})]}),l?s.jsx(ee,{label:`Type ${e.name} to confirm`,children:s.jsx("input",{value:a,onChange:m=>c(m.target.value)})}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:u,onClick:()=>{i(!1),o(!1),c("")},children:"Cancel"}),s.jsx(P,{variant:"danger",disabled:u||l&&a.trim()!==e.name,onClick:()=>f(A.uninstallPlugin(e.name,l?{purge:!0,confirm:a.trim()}:{})),children:l?"Remove and drop its data":"Remove"})]})]}):null]})}const iF={you:"person",appearance:"sun",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function lF(e){const t=sI.map(r=>({id:r.id,route:ht(r.id),label:r.label,icon:iF[r.id],group:r.group})),n=[...e].sort((r,i)=>r.title.localeCompare(i.title,void 0,{sensitivity:"base"})||r.plugin.localeCompare(i.plugin)||r.id.localeCompare(i.id)).map(r=>({id:v0(r.plugin,r.id),route:cm(r.plugin,r.id),label:r.title,icon:Tk(r.icon),group:"plugins"}));return[...t,...n]}function jS(e){return nI.map(t=>({id:t.id,label:t.label,entries:e.filter(n=>n.group===t.id)})).filter(t=>t.entries.length>0)}function yS(e,t){return t?`${e}, ${t} open`:e}function oF({entries:e,active:t,counts:n={},navigate:r}){var c;const i=d.useRef(null),l=jS(e),o=e.some(u=>u.id===t)?t:(c=e[0])==null?void 0:c.id,a=u=>{var m;const h=[...((m=i.current)==null?void 0:m.querySelectorAll("a.settings-nav-link"))??[]],f=h.indexOf(document.activeElement);if(f===-1)return;const p=j=>{var w;u.preventDefault(),(w=h[Math.max(0,Math.min(h.length-1,j))])==null||w.focus()};if(u.key==="ArrowDown")p(f+1);else if(u.key==="ArrowUp")p(f-1);else if(u.key==="Home")p(0);else if(u.key==="End")p(h.length-1);else if(u.key==="Enter"||u.key===" "){u.preventDefault();const j=h[f].getAttribute("href");j&&r(j)}};return s.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:i,onKeyDown:a,children:l.map(u=>s.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${u.id}`,children:[s.jsx("div",{className:"settings-nav-label",id:`settings-nav-${u.id}`,children:u.label}),u.entries.map(h=>{const f=h.id===t,p=n[h.id];return s.jsxs("a",{className:"settings-nav-link",href:h.route,"data-active":f?"true":void 0,"aria-current":f?"page":void 0,"aria-label":p?yS(h.label,p):void 0,tabIndex:h.id===o?0:-1,onClick:m=>{m.preventDefault(),r(h.route)},children:[s.jsx(Oe,{name:h.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:h.label}),p?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:p>99?"99+":p}):null]},h.id)})]},u.id))})}function aF({entries:e,active:t,counts:n={},navigate:r}){const i=jS(e),l=e.find(o=>o.id===t)??e[0];return s.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:s.jsxs(Xp,{modal:!1,children:[s.jsx(Zp,{asChild:!0,children:s.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(l==null?void 0:l.label)??""}`,children:[l?s.jsx(Oe,{name:l.icon,className:"settings-nav-icon"}):null,s.jsx("span",{className:"settings-nav-text",children:l==null?void 0:l.label}),s.jsx(Oe,{name:"chevron-down",className:"settings-menu-chevron"})]})}),s.jsx(em,{children:s.jsx(tm,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:s.jsx(wP,{value:t,onValueChange:o=>{const a=e.find(c=>c.id===o);a&&r(a.route)},children:i.map((o,a)=>s.jsxs(yP,{children:[a>0?s.jsx(Jf,{className:"ui-menu-sep"}):null,s.jsx(nm,{className:"ui-menu-label",children:o.label}),o.entries.map(c=>{const u=n[c.id];return s.jsxs(bP,{value:c.id,className:"ui-menu-item settings-menu-item","data-active":c.id===t?"true":void 0,"aria-label":u?yS(c.label,u):void 0,children:[s.jsxs("span",{className:"settings-menu-entry",children:[s.jsx(Oe,{name:c.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:c.label})]}),u?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:u>99?"99+":u}):null]},c.id)})]},o.id))})})})]})})}function cF({hash:e,timezone:t,navigate:n,agents:r,pluginPages:i}){var w,b;const l=rI(e),o=Ak(i!==void 0),a=i??o,c=XP(e),u=c?a.find(c.plugin,c.page):void 0,h=Nh(Qk),f=lF(a.settings),m={proposals:((b=(w=le(()=>Promise.resolve().then(()=>A.proposals()),[],3e4).data)==null?void 0:w.open)==null?void 0:b.length)??0},j={entries:f,active:l,counts:m,navigate:x=>n(x)};return s.jsxs("div",{className:"settings",children:[h?null:s.jsx(oF,{...j}),s.jsx("div",{className:"settings-body",children:s.jsxs("div",{className:"ui-page",children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Settings"}),s.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),h?s.jsx(aF,{...j}):null,u?s.jsx(bO,{page:u,navigate:n,timezone:t,siblings:a.all.filter(x=>x.plugin===u.plugin)}):null,l==="you"?s.jsx(IL,{embedded:!0}):null,l==="appearance"?s.jsx(uF,{}):null,l==="memory"?s.jsx(Wk,{embedded:!0,agents:r,timezone:t}):null,l==="proposals"?s.jsx(LL,{embedded:!0,plugin:eI(e)}):null,l==="accounts"?s.jsx(lL,{embedded:!0}):null,l==="computer"?s.jsx(Z$,{embedded:!0,timezone:t}):null,l==="secrets"?s.jsx(kL,{embedded:!0,timezone:t}):null,l==="watchers"?s.jsx(TL,{timezone:t,embedded:!0}):null,l==="backup"?s.jsx(eL,{}):null,l==="plugins"?s.jsx(JL,{}):null,l==="system"?s.jsx(dF,{timezone:t}):null]})})]})}function uF(){const[e,t]=Ok();return s.jsx(Y,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:s.jsxs(q,{divided:!0,gap:"lg",children:[s.jsx(Id,{label:"Theme",hint:"System follows your Mac.",children:s.jsx(Oa,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:e.theme,onChange:n=>t({theme:n})})}),s.jsx(Id,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:s.jsx(Oa,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:e.ground,onChange:n=>t({ground:n})})}),s.jsx(Id,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:s.jsx(Oa,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:e.width,onChange:n=>t({width:n})})})]})})}function Id({label:e,hint:t,children:n}){return s.jsxs("div",{className:"pref-row ui-section",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:e}),s.jsx("span",{className:"ui-field-hint",children:t})]}),n]})}function dF({timezone:e}){const t=le(()=>A.overview(),[],15e3),n=le(()=>A.session(),[]),r=le(()=>A.providerAccounts(),[]),i=t.data;return s.jsxs(q,{gap:"lg",children:[s.jsx(ie,{message:t.error}),s.jsx(NF,{}),i?s.jsx(Y,{title:"The queue",panel:!0,actions:s.jsx(P,{size:"sm",variant:i.paused?"accent":void 0,onClick:()=>{A.setPaused(!i.paused).then(()=>t.reload())},children:i.paused?"Resume the queue":"Pause the queue"}),children:s.jsxs("p",{className:"ui-card-meta",children:[i.paused?"Paused. Nothing is being claimed until you resume.":"Running. Jobs are claimed as they come due."," ",i.paused?s.jsx(fe,{tone:"warning",children:"paused"}):s.jsx(fe,{tone:"good",children:"running"})]})}):null,s.jsxs(Y,{title:"This host",panel:!0,children:[s.jsx(bt,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?Pe(i.now,e):"…"},{label:"Bound to",value:n.data?`${n.data.host}:${n.data.port}`:"…"},{label:"Credential vault",value:r.data?mF(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?s.jsx(G,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),s.jsx(Y,{title:"First run",panel:!0,children:s.jsxs("p",{className:"ui-card-meta",children:["The setup screens — you, a model account, an agent — are always there."," ",s.jsx("a",{href:om,children:"Run setup again"}),". Nothing is undone by opening them; each screen saves what you change and leaves the rest alone."]})}),s.jsx(pF,{}),s.jsx(fF,{}),s.jsx(Y,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?s.jsx(oe,{children:"No sources are installed."}):s.jsx(bt,{items:i.mail.map(l=>({key:l.sourceId,label:s.jsx("span",{className:"mono",children:l.sourceId}),value:l.lastError?s.jsx("span",{className:"critical",children:l.lastError}):s.jsxs("span",{children:["polled ",Se(l.lastRunAt)]})}))}):s.jsx(oe,{children:"Loading…"})})]})}function fF(){var m;const e=le(()=>A.tailscale(),[]),[t,n]=d.useState(null),[r,i]=d.useState(!1),[l,o]=d.useState(null),[a,c]=d.useState(!1),u=e.data,h=t??((u==null?void 0:u.login)||((m=u==null?void 0:u.self)==null?void 0:m.login)||""),f=(u==null?void 0:u.proxied)===!0,p=j=>{i(!0),o(null),c(!1),A.setTailscale({enabled:j,login:h.trim()}).then(()=>{c(!0)}).catch(w=>o(w instanceof pe?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return s.jsx(Y,{title:"Sign in through Tailscale",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:r||!u||f,onClick:()=>p((u==null?void 0:u.enabled)??!1),children:"Save"}),children:s.jsx(q,{divided:!0,children:s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:e.error??l}),s.jsx("p",{className:"ui-card-meta",children:u?u.available&&u.self?`Tailscale is running on this machine as ${u.self.login}.`:u.available?"Tailscale is running on this machine.":"Tailscale is not running here.":"…"}),f?s.jsxs(s.Fragment,{children:[s.jsx(G,{tone:"warning",children:"Change this from the computer buddi runs on."}),s.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${h}`:"Off"})]}):null,s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||f,onChange:j=>p(j.target.checked)}),s.jsx("span",{children:"Let this Tailscale login sign in"})]}),s.jsx(ee,{label:"Tailscale login",children:s.jsx("input",{type:"text",value:h,placeholder:"you@example.com",disabled:r||!u||f,onChange:j=>n(j.target.value)})}),s.jsx("p",{className:"ui-card-meta",children:"Anyone signed in to Tailscale as this login, on any device in your tailnet, is signed in to buddi. The proxy must run on this machine:"}),s.jsxs("div",{className:"tailscale-command",children:[s.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),s.jsx(P,{size:"sm",disabled:r||!u,onClick:()=>{hF((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),s.jsx("p",{className:"ui-card-meta",children:"This gives your tailnet the trust this machine already has: buddi cannot tell the Tailscale proxy from another program running here, and any program that can reach the dashboard on this machine can already read buddi’s files."}),a?s.jsx(G,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function hF(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function pF(){var u;const e=le(()=>A.service(),[],1e4),[t,n]=d.useState(null),[r,i]=d.useState(!1),[l,o]=d.useState(null),a=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!a)return null;const c=h=>{i(!0),o(null),A.serviceAction(h).then(()=>{n(null)}).catch(f=>{o(f.message)}).finally(()=>{i(!1),e.reload()})};return s.jsx(Y,{title:"Service",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsx(bt,{items:[{label:"Database",value:s.jsx(Jv,{state:a.database,pid:a.databasePid})},{label:"Gateway",value:s.jsx(Jv,{state:a.gateway,pid:a.gatewayPid})},{label:"Supervisor",value:s.jsxs("span",{className:"mono",children:["pid ",a.supervisorPid]})}]})}),s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:l}),t?s.jsx(G,{tone:"warning",role:"alert",children:t==="stop"?"Stopping the gateway closes this dashboard. The database keeps running; run buddi in a terminal to bring the dashboard back.":"Restarting the gateway closes this dashboard for a few seconds. If it does not come back on its own, run buddi in a terminal."}):s.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),s.jsx(J,{align:"end",children:t?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",disabled:r,onClick:()=>{n(null),o(null)},children:"Cancel"}),s.jsx(P,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>{n("stop")},children:"Stop gateway"}),s.jsx(P,{variant:"accent",onClick:()=>{n("restart")},children:"Restart gateway"})]})})]})})]})})}function Jv({state:e,pid:t}){return s.jsxs("span",{children:[s.jsx(fe,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?s.jsx("span",{className:"ui-card-meta",children:"no process"}):s.jsxs("span",{className:"mono",children:["pid ",t]})]})}function mF(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const gF=2e3,Xv={starting:"Getting started.",backup:"Taking a backup first, so there is a way back.",stopping:"Stopping the gateway. The database stays up.",installing:"Installing the new version.",restarting:"Restarting buddi on the new version.",migrating:"Bringing the database up to date.",done:"Done.",failed:"That did not work."},xF=new Set(["done","failed","rolled-back"]),vF="The check asks the npm registry for the newest version and sends nothing else.",jF="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",yF="A checkout upgrades with git pull, then buddi upgrade in a terminal.",wF=10*6e4,bF="buddi did not come back. Run buddi doctor in a terminal.";function kF(e){const t=e.step==="starting"?"while starting":`at ${e.step??"an unknown step"}`;return`The upgrade to ${e.to} failed ${t}: ${e.error??"no reason given"}. The backup taken first is ${e.backup??"not available"}. Run buddi doctor in a terminal; it prints the way back.`}function SF(e,t,n,r){const[i,l]=d.useState(void 0),[o,a]=d.useState(!1),[c,u]=d.useState(null),h=d.useRef(!1),f=d.useRef(n),p=d.useRef(r);return f.current=n,p.current=r,d.useEffect(()=>{if(!e){l(void 0),a(!1),h.current=!1;return}let m=!1,j=0;const w=()=>{h.current=!0,j=Date.now()+wF,a(!0)},b=()=>{if(Date.now()<j){A.session().then(y=>{m||y.version!==void 0&&y.version===t||(m=!0,f.current())}).catch(()=>{}),A.version().then(y=>{const g=y.history[y.history.length-1];m||(g==null?void 0:g.outcome)!=="failed"||(m=!0,a(!1),u(kF(g)))}).catch(()=>{});return}m=!0,a(!1),u(bF)},x=()=>{if(!m){if(h.current)return b();A.upgradeJob(e).then(y=>{var g;m||(l(y),u(null),(xF.has(y.phase)||y.finishedAt)&&(m=!0,y.phase==="failed"&&((g=p.current)==null||g.call(p,y))))}).catch(y=>{m||(y instanceof pe&&y.status!==0&&y.status<500?u(y.message):w())})}};x();const v=window.setInterval(x,gF);return()=>{m=!0,window.clearInterval(v)}},[e,t]),{job:i,away:o,error:c}}function NF({reload:e}){var g;const t=le(()=>A.version(),[]),[n,r]=d.useState(null),[i,l]=d.useState(!1),[o,a]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),p=(g=t.data)==null?void 0:g.current,m=e??(()=>window.location.reload()),j=d.useCallback(S=>{r(null),f(S)},[]),w=SF(n,p,m,j),b=t.data,x=()=>{a(!0),u(null),A.checkVersion().catch(S=>u(S instanceof pe?S.message:String(S))).finally(()=>{a(!1),t.reload()})},v=S=>{a(!0),u(null),A.setVersionCheck(S).catch(k=>u(k instanceof pe?k.message:String(k))).finally(()=>{a(!1),t.reload()})},y=()=>{a(!0),u(null),f(null),A.startUpgrade(b==null?void 0:b.latest).then(S=>{var k;l(!1),r(((k=S.job)==null?void 0:k.id)??null)}).catch(S=>u(S instanceof pe?S.message:String(S))).finally(()=>a(!1))};return b!=null&&b.checkout?s.jsx(Y,{title:"Version",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsx(bt,{items:[{label:"Running",value:s.jsx("span",{className:"mono",children:b.current})}]})}),s.jsx(Y,{children:s.jsx("p",{className:"ui-card-meta",children:yF})})]})}):s.jsx(Y,{title:"Version",panel:!0,children:s.jsxs(q,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(ie,{message:t.error??c}),s.jsx(bt,{items:[{label:"Running",value:b?s.jsx("span",{className:"mono",children:b.current}):"…"},{label:"Newest",value:b?b.updateAvailable&&b.latest?s.jsxs("span",{children:["A newer buddi is available: ",s.jsx("span",{className:"mono",children:b.latest})]}):b.checkedAt?s.jsxs("span",{children:["This is the latest, as of ",Se(b.checkedAt),"."]}):s.jsx("span",{children:"Not checked yet."}):"…"}]}),b!=null&&b.error?s.jsxs(G,{tone:"warning",children:["The last check did not get an answer: ",b.error]}):null,s.jsx(J,{align:"end",children:s.jsx(P,{disabled:o,onClick:x,children:"Check now"})})]})}),s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(b==null?void 0:b.checkEnabled)??!1,disabled:o||!b,onChange:S=>v(S.target.checked)}),s.jsx("span",{children:"Check once a day"})]}),s.jsx("p",{className:"ui-card-meta",children:vF})]})}),s.jsx(Y,{children:s.jsxs(q,{gap:"sm",children:[s.jsx(CF,{...w,job:w.job??h??void 0}),i?s.jsx(G,{tone:"warning",role:"alert",children:jF}):null,s.jsx(J,{align:"end",children:i?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",disabled:o,onClick:()=>l(!1),children:"Cancel"}),s.jsxs(P,{variant:"accent",disabled:o,onClick:y,children:["Upgrade to ",b==null?void 0:b.latest]})]}):s.jsx(P,{variant:"accent",disabled:o||n!==null||!(b!=null&&b.updateAvailable),onClick:()=>l(!0),children:b!=null&&b.updateAvailable&&b.latest?`Upgrade to ${b.latest}`:"Upgrade"})})]})}),b&&b.history.length>0?s.jsx(Y,{title:"Upgrades so far",children:s.jsx(bt,{items:b.history.slice().reverse().map(S=>({key:S.startedAt,label:s.jsxs("span",{className:"mono",children:[S.from," → ",S.to]}),value:s.jsx(EF,{attempt:S})}))})}):null]})})}function CF({job:e,away:t,error:n}){return n?s.jsx(ie,{message:n}):t?s.jsx(G,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="failed"?s.jsxs(G,{tone:"critical",role:"alert",children:[Xv.failed," ",e.error??""," buddi is still running on the version it had."]}):s.jsx(G,{tone:e.phase==="done"?"good":void 0,role:"status",children:Xv[e.phase]??e.detail??e.phase}):null}function EF({attempt:e}){return s.jsxs("span",{children:[s.jsx(fe,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",Se(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?s.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",s.jsx("span",{className:"mono",children:e.backup})]}):null]})}const Ah=["name","clock","brain","browser","assistant","handover"],wS={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function AF(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function RF(e){var l,o,a;const t=AF(e.accounts),n=e.assistant?(((l=e.accounts)==null?void 0:l.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(n==null?void 0:n.accountId)??((a=(o=e.onboarding)==null?void 0:o.details)==null?void 0:a.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(n==null?void 0:n.model)??i.defaultModel}}function bS(e){var r,i,l;const t=RF(e),n=e.onboarding&&!e.onboarding.needs.agent?e.assistant:void 0;return{...(r=e.owner)!=null&&r.preferredName?{name:e.owner.preferredName}:{},...(i=e.owner)!=null&&i.timezone?{clock:e.owner.timezone}:{},...t?{brain:t}:{},...(l=e.onboarding)!=null&&l.stepsDone.includes("browser")||n?{browser:e.browser??"other"}:{},...n?{assistant:n}:{}}}function TF(e,t){return t==="name"?typeof e.name=="string"&&e.name!=="":t==="clock"?typeof e.clock=="string"&&e.clock!=="":t==="brain"?e.brain!==void 0:t==="browser"?e.browser!==void 0:t==="assistant"?e.assistant!==void 0:!1}function Rh(e){return Ah.find(t=>!TF(e,t))??"handover"}function PF(e,t){const n=Ah.indexOf(t);return Ah.filter((r,i)=>i<n||r===t)}function IF(e,t){const n={...e};return delete n[t],n}const Th="buddi.firstRun.restore";function Md(e){try{e===null?window.sessionStorage.removeItem(Th):window.sessionStorage.setItem(Th,e)}catch{}}function kS(){try{return window.sessionStorage.getItem(Th)}catch{return null}}function MF(e){const t=bS(e),n=Rh(t);return{answers:t,open:n,stay:n!=="handover"}}function $F(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function _F(e){const t=e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,20).replace(/-+$/,"");return t===""?"assistant":t}var yo={},OF=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},SS={},hn={};let Om;const DF=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];hn.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};hn.getSymbolTotalCodewords=function(t){return DF[t]};hn.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};hn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Om=t};hn.isKanjiModeEnabled=function(){return typeof Om<"u"};hn.toSJIS=function(t){return Om(t)};var fu={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(fu);function NS(){this.buffer=[],this.length=0}NS.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var LF=NS;function wo(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}wo.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};wo.prototype.get=function(e,t){return this.data[e*this.size+t]};wo.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};wo.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var FF=wo,CS={};(function(e){const t=hn.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,l=t(r),o=l===145?26:Math.ceil((l-13)/(2*i-2))*2,a=[l-7];for(let c=1;c<i-1;c++)a[c]=a[c-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],l=e.getRowColCoords(r),o=l.length;for(let a=0;a<o;a++)for(let c=0;c<o;c++)a===0&&c===0||a===0&&c===o-1||a===o-1&&c===0||i.push([l[a],l[c]]);return i}})(CS);var ES={};const UF=hn.getSymbolSize,Zv=7;ES.getPositions=function(t){const n=UF(t);return[[0,0],[n-Zv,0],[0,n-Zv]]};var AS={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const l=i.size;let o=0,a=0,c=0,u=null,h=null;for(let f=0;f<l;f++){a=c=0,u=h=null;for(let p=0;p<l;p++){let m=i.get(f,p);m===u?a++:(a>=5&&(o+=t.N1+(a-5)),u=m,a=1),m=i.get(p,f),m===h?c++:(c>=5&&(o+=t.N1+(c-5)),h=m,c=1)}a>=5&&(o+=t.N1+(a-5)),c>=5&&(o+=t.N1+(c-5))}return o},e.getPenaltyN2=function(i){const l=i.size;let o=0;for(let a=0;a<l-1;a++)for(let c=0;c<l-1;c++){const u=i.get(a,c)+i.get(a,c+1)+i.get(a+1,c)+i.get(a+1,c+1);(u===4||u===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const l=i.size;let o=0,a=0,c=0;for(let u=0;u<l;u++){a=c=0;for(let h=0;h<l;h++)a=a<<1&2047|i.get(u,h),h>=10&&(a===1488||a===93)&&o++,c=c<<1&2047|i.get(h,u),h>=10&&(c===1488||c===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let l=0;const o=i.data.length;for(let c=0;c<o;c++)l+=i.data[c];return Math.abs(Math.ceil(l*100/o/5)-10)*t.N4};function n(r,i,l){switch(r){case e.Patterns.PATTERN000:return(i+l)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(i+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return i*l%2+i*l%3===0;case e.Patterns.PATTERN110:return(i*l%2+i*l%3)%2===0;case e.Patterns.PATTERN111:return(i*l%3+(i+l)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,l){const o=l.size;for(let a=0;a<o;a++)for(let c=0;c<o;c++)l.isReserved(c,a)||l.xor(c,a,n(i,c,a))},e.getBestMask=function(i,l){const o=Object.keys(e.Patterns).length;let a=0,c=1/0;for(let u=0;u<o;u++){l(u),e.applyMask(u,i);const h=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),h<c&&(c=h,a=u)}return a}})(AS);var hu={};const Ws=fu,pa=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],ma=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];hu.getBlocksCount=function(t,n){switch(n){case Ws.L:return pa[(t-1)*4+0];case Ws.M:return pa[(t-1)*4+1];case Ws.Q:return pa[(t-1)*4+2];case Ws.H:return pa[(t-1)*4+3];default:return}};hu.getTotalCodewordsCount=function(t,n){switch(n){case Ws.L:return ma[(t-1)*4+0];case Ws.M:return ma[(t-1)*4+1];case Ws.Q:return ma[(t-1)*4+2];case Ws.H:return ma[(t-1)*4+3];default:return}};var RS={},pu={};const $l=new Uint8Array(512),Ac=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)$l[n]=t,Ac[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)$l[n]=$l[n-255]})();pu.log=function(t){if(t<1)throw new Error("log("+t+")");return Ac[t]};pu.exp=function(t){return $l[t]};pu.mul=function(t,n){return t===0||n===0?0:$l[Ac[t]+Ac[n]]};(function(e){const t=pu;e.mul=function(r,i){const l=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)l[o+a]^=t.mul(r[o],i[a]);return l},e.mod=function(r,i){let l=new Uint8Array(r);for(;l.length-i.length>=0;){const o=l[0];for(let c=0;c<i.length;c++)l[c]^=t.mul(i[c],o);let a=0;for(;a<l.length&&l[a]===0;)a++;l=l.slice(a)}return l},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let l=0;l<r;l++)i=e.mul(i,new Uint8Array([1,t.exp(l)]));return i}})(RS);const TS=RS;function Dm(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Dm.prototype.initialize=function(t){this.degree=t,this.genPoly=TS.generateECPolynomial(this.degree)};Dm.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=TS.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const l=new Uint8Array(this.degree);return l.set(r,i),l}return r};var BF=Dm,PS={},fr={},Lm={};Lm.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var as={};const IS="[0-9]+",zF="[A-Z $%*+\\-./:]+";let oo="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";oo=oo.replace(/u/g,"\\u");const WF="(?:(?![A-Z0-9 $%*+\\-./:]|"+oo+`)(?:.|[\r
115
- ]))+`;as.KANJI=new RegExp(oo,"g");as.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");as.BYTE=new RegExp(WF,"g");as.NUMERIC=new RegExp(IS,"g");as.ALPHANUMERIC=new RegExp(zF,"g");const VF=new RegExp("^"+oo+"$"),HF=new RegExp("^"+IS+"$"),KF=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");as.testKanji=function(t){return VF.test(t)};as.testNumeric=function(t){return HF.test(t)};as.testAlphanumeric=function(t){return KF.test(t)};(function(e){const t=Lm,n=as;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(l,o){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?l.ccBits[0]:o<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return n.testNumeric(l)?e.NUMERIC:n.testAlphanumeric(l)?e.ALPHANUMERIC:n.testKanji(l)?e.KANJI:e.BYTE},e.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},e.isValid=function(l){return l&&l.bit&&l.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(l,o){if(e.isValid(l))return l;try{return r(l)}catch{return o}}})(fr);(function(e){const t=hn,n=hu,r=fu,i=fr,l=Lm,o=7973,a=t.getBCHDigit(o);function c(p,m,j){for(let w=1;w<=40;w++)if(m<=e.getCapacity(w,j,p))return w}function u(p,m){return i.getCharCountIndicator(p,m)+4}function h(p,m){let j=0;return p.forEach(function(w){const b=u(w.mode,m);j+=b+w.getBitsLength()}),j}function f(p,m){for(let j=1;j<=40;j++)if(h(p,j)<=e.getCapacity(j,m,i.MIXED))return j}e.from=function(m,j){return l.isValid(m)?parseInt(m,10):j},e.getCapacity=function(m,j,w){if(!l.isValid(m))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=i.BYTE);const b=t.getSymbolTotalCodewords(m),x=n.getTotalCodewordsCount(m,j),v=(b-x)*8;if(w===i.MIXED)return v;const y=v-u(w,m);switch(w){case i.NUMERIC:return Math.floor(y/10*3);case i.ALPHANUMERIC:return Math.floor(y/11*2);case i.KANJI:return Math.floor(y/13);case i.BYTE:default:return Math.floor(y/8)}},e.getBestVersionForData=function(m,j){let w;const b=r.from(j,r.M);if(Array.isArray(m)){if(m.length>1)return f(m,b);if(m.length===0)return 1;w=m[0]}else w=m;return c(w.mode,w.getLength(),b)},e.getEncodedBits=function(m){if(!l.isValid(m)||m<7)throw new Error("Invalid QR Code version");let j=m<<12;for(;t.getBCHDigit(j)-a>=0;)j^=o<<t.getBCHDigit(j)-a;return m<<12|j}})(PS);var MS={};const Ph=hn,$S=1335,GF=21522,ej=Ph.getBCHDigit($S);MS.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;Ph.getBCHDigit(i)-ej>=0;)i^=$S<<Ph.getBCHDigit(i)-ej;return(r<<10|i)^GF};var _S={};const YF=fr;function Bi(e){this.mode=YF.NUMERIC,this.data=e.toString()}Bi.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Bi.prototype.getLength=function(){return this.data.length};Bi.prototype.getBitsLength=function(){return Bi.getBitsLength(this.data.length)};Bi.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const l=this.data.length-n;l>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,l*3+1))};var qF=Bi;const QF=fr,$d=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function zi(e){this.mode=QF.ALPHANUMERIC,this.data=e}zi.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};zi.prototype.getLength=function(){return this.data.length};zi.prototype.getBitsLength=function(){return zi.getBitsLength(this.data.length)};zi.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=$d.indexOf(this.data[n])*45;r+=$d.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put($d.indexOf(this.data[n]),6)};var JF=zi;const XF=fr;function Wi(e){this.mode=XF.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Wi.getBitsLength=function(t){return t*8};Wi.prototype.getLength=function(){return this.data.length};Wi.prototype.getBitsLength=function(){return Wi.getBitsLength(this.data.length)};Wi.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var ZF=Wi;const e4=fr,t4=hn;function Vi(e){this.mode=e4.KANJI,this.data=e}Vi.getBitsLength=function(t){return t*13};Vi.prototype.getLength=function(){return this.data.length};Vi.prototype.getBitsLength=function(){return Vi.getBitsLength(this.data.length)};Vi.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=t4.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
116
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var n4=Vi,OS={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var l={},o={};o[r]=0;var a=t.PriorityQueue.make();a.push(r,0);for(var c,u,h,f,p,m,j,w,b;!a.empty();){c=a.pop(),u=c.value,f=c.cost,p=n[u]||{};for(h in p)p.hasOwnProperty(h)&&(m=p[h],j=f+m,w=o[h],b=typeof o[h]>"u",(b||w>j)&&(o[h]=j,a.push(h,j),l[h]=u))}if(typeof i<"u"&&typeof o[i]>"u"){var x=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(x)}return l},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],l=r;l;)i.push(l),n[l],l=n[l];return i.reverse(),i},find_path:function(n,r,i){var l=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(l,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},l;n=n||{};for(l in r)r.hasOwnProperty(l)&&(i[l]=r[l]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(OS);var s4=OS.exports;(function(e){const t=fr,n=qF,r=JF,i=ZF,l=n4,o=as,a=hn,c=s4;function u(x){return unescape(encodeURIComponent(x)).length}function h(x,v,y){const g=[];let S;for(;(S=x.exec(y))!==null;)g.push({data:S[0],index:S.index,mode:v,length:S[0].length});return g}function f(x){const v=h(o.NUMERIC,t.NUMERIC,x),y=h(o.ALPHANUMERIC,t.ALPHANUMERIC,x);let g,S;return a.isKanjiModeEnabled()?(g=h(o.BYTE,t.BYTE,x),S=h(o.KANJI,t.KANJI,x)):(g=h(o.BYTE_KANJI,t.BYTE,x),S=[]),v.concat(y,g,S).sort(function(N,C){return N.index-C.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function p(x,v){switch(v){case t.NUMERIC:return n.getBitsLength(x);case t.ALPHANUMERIC:return r.getBitsLength(x);case t.KANJI:return l.getBitsLength(x);case t.BYTE:return i.getBitsLength(x)}}function m(x){return x.reduce(function(v,y){const g=v.length-1>=0?v[v.length-1]:null;return g&&g.mode===y.mode?(v[v.length-1].data+=y.data,v):(v.push(y),v)},[])}function j(x){const v=[];for(let y=0;y<x.length;y++){const g=x[y];switch(g.mode){case t.NUMERIC:v.push([g,{data:g.data,mode:t.ALPHANUMERIC,length:g.length},{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.ALPHANUMERIC:v.push([g,{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.KANJI:v.push([g,{data:g.data,mode:t.BYTE,length:u(g.data)}]);break;case t.BYTE:v.push([{data:g.data,mode:t.BYTE,length:u(g.data)}])}}return v}function w(x,v){const y={},g={start:{}};let S=["start"];for(let k=0;k<x.length;k++){const N=x[k],C=[];for(let T=0;T<N.length;T++){const E=N[T],U=""+k+T;C.push(U),y[U]={node:E,lastCount:0},g[U]={};for(let H=0;H<S.length;H++){const O=S[H];y[O]&&y[O].node.mode===E.mode?(g[O][U]=p(y[O].lastCount+E.length,E.mode)-p(y[O].lastCount,E.mode),y[O].lastCount+=E.length):(y[O]&&(y[O].lastCount=E.length),g[O][U]=p(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,v))}}S=C}for(let k=0;k<S.length;k++)g[S[k]].end=0;return{map:g,table:y}}function b(x,v){let y;const g=t.getBestModeForData(x);if(y=t.from(v,g),y!==t.BYTE&&y.bit<g.bit)throw new Error('"'+x+'" cannot be encoded with mode '+t.toString(y)+`.
117
- Suggested mode is: `+t.toString(g));switch(y===t.KANJI&&!a.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new n(x);case t.ALPHANUMERIC:return new r(x);case t.KANJI:return new l(x);case t.BYTE:return new i(x)}}e.fromArray=function(v){return v.reduce(function(y,g){return typeof g=="string"?y.push(b(g,null)):g.data&&y.push(b(g.data,g.mode)),y},[])},e.fromString=function(v,y){const g=f(v,a.isKanjiModeEnabled()),S=j(g),k=w(S,y),N=c.find_path(k.map,"start","end"),C=[];for(let T=1;T<N.length-1;T++)C.push(k.table[N[T]].node);return e.fromArray(m(C))},e.rawSplit=function(v){return e.fromArray(f(v,a.isKanjiModeEnabled()))}})(_S);const mu=hn,_d=fu,r4=LF,i4=FF,l4=CS,o4=ES,Ih=AS,Mh=hu,a4=BF,Rc=PS,c4=MS,u4=fr,Od=_S;function d4(e,t){const n=e.size,r=o4.getPositions(t);for(let i=0;i<r.length;i++){const l=r[i][0],o=r[i][1];for(let a=-1;a<=7;a++)if(!(l+a<=-1||n<=l+a))for(let c=-1;c<=7;c++)o+c<=-1||n<=o+c||(a>=0&&a<=6&&(c===0||c===6)||c>=0&&c<=6&&(a===0||a===6)||a>=2&&a<=4&&c>=2&&c<=4?e.set(l+a,o+c,!0,!0):e.set(l+a,o+c,!1,!0))}}function f4(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function h4(e,t){const n=l4.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],l=n[r][1];for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?e.set(i+o,l+a,!0,!0):e.set(i+o,l+a,!1,!0)}}function p4(e,t){const n=e.size,r=Rc.getEncodedBits(t);let i,l,o;for(let a=0;a<18;a++)i=Math.floor(a/3),l=a%3+n-8-3,o=(r>>a&1)===1,e.set(i,l,o,!0),e.set(l,i,o,!0)}function Dd(e,t,n){const r=e.size,i=c4.getEncodedBits(t,n);let l,o;for(l=0;l<15;l++)o=(i>>l&1)===1,l<6?e.set(l,8,o,!0):l<8?e.set(l+1,8,o,!0):e.set(r-15+l,8,o,!0),l<8?e.set(8,r-l-1,o,!0):l<9?e.set(8,15-l-1+1,o,!0):e.set(8,15-l-1,o,!0);e.set(r-8,8,1,!0)}function m4(e,t){const n=e.size;let r=-1,i=n-1,l=7,o=0;for(let a=n-1;a>0;a-=2)for(a===6&&a--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,a-c)){let u=!1;o<t.length&&(u=(t[o]>>>l&1)===1),e.set(i,a-c,u),l--,l===-1&&(o++,l=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function g4(e,t,n){const r=new r4;n.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),u4.getCharCountIndicator(c.mode,e)),c.write(r)});const i=mu.getSymbolTotalCodewords(e),l=Mh.getTotalCodewordsCount(e,t),o=(i-l)*8;for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const a=(o-r.getLengthInBits())/8;for(let c=0;c<a;c++)r.put(c%2?17:236,8);return x4(r,e,t)}function x4(e,t,n){const r=mu.getSymbolTotalCodewords(t),i=Mh.getTotalCodewordsCount(t,n),l=r-i,o=Mh.getBlocksCount(t,n),a=r%o,c=o-a,u=Math.floor(r/o),h=Math.floor(l/o),f=h+1,p=u-h,m=new a4(p);let j=0;const w=new Array(o),b=new Array(o);let x=0;const v=new Uint8Array(e.buffer);for(let N=0;N<o;N++){const C=N<c?h:f;w[N]=v.slice(j,j+C),b[N]=m.encode(w[N]),j+=C,x=Math.max(x,C)}const y=new Uint8Array(r);let g=0,S,k;for(S=0;S<x;S++)for(k=0;k<o;k++)S<w[k].length&&(y[g++]=w[k][S]);for(S=0;S<p;S++)for(k=0;k<o;k++)y[g++]=b[k][S];return y}function v4(e,t,n,r){let i;if(Array.isArray(e))i=Od.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const h=Od.rawSplit(e);u=Rc.getBestVersionForData(h,n)}i=Od.fromString(e,u||40)}else throw new Error("Invalid data");const l=Rc.getBestVersionForData(i,n);if(!l)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=l;else if(t<l)throw new Error(`
118
- The chosen QR Code version cannot contain this amount of data.
119
- Minimum version required to store current data is: `+l+`.
120
- `);const o=g4(t,n,i),a=mu.getSymbolSize(t),c=new i4(a);return d4(c,t),f4(c),h4(c,t),Dd(c,n,0),t>=7&&p4(c,t),m4(c,o),isNaN(r)&&(r=Ih.getBestMask(c,Dd.bind(null,c,n))),Ih.applyMask(r,c),Dd(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}SS.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=_d.M,i,l;return typeof n<"u"&&(r=_d.from(n.errorCorrectionLevel,_d.M),i=Rc.from(n.version),l=Ih.from(n.maskPattern),n.toSJISFunc&&mu.setToSJISFunction(n.toSJISFunc)),v4(t,i,r,l)};var DS={},Fm={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(l){return[l,l]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,l=r.width&&r.width>=21?r.width:void 0,o=r.scale||4;return{width:l,scale:l?4:o,margin:i,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},e.getImageWidth=function(r,i){const l=e.getScale(r,i);return Math.floor((r+i.margin*2)*l)},e.qrToImageData=function(r,i,l){const o=i.modules.size,a=i.modules.data,c=e.getScale(o,l),u=Math.floor((o+l.margin*2)*c),h=l.margin*c,f=[l.color.light,l.color.dark];for(let p=0;p<u;p++)for(let m=0;m<u;m++){let j=(p*u+m)*4,w=l.color.light;if(p>=h&&m>=h&&p<u-h&&m<u-h){const b=Math.floor((p-h)/c),x=Math.floor((m-h)/c);w=f[a[b*o+x]?1:0]}r[j++]=w.r,r[j++]=w.g,r[j++]=w.b,r[j]=w.a}}})(Fm);(function(e){const t=Fm;function n(i,l,o){i.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=o,l.width=o,l.style.height=o+"px",l.style.width=o+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(l,o,a){let c=a,u=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(u=r()),c=t.getOptions(c);const h=t.getImageWidth(l.modules.size,c),f=u.getContext("2d"),p=f.createImageData(h,h);return t.qrToImageData(p.data,l,c),n(f,u,h),f.putImageData(p,0,0),u},e.renderToDataURL=function(l,o,a){let c=a;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const u=e.render(l,o,c),h=c.type||"image/png",f=c.rendererOpts||{};return u.toDataURL(h,f.quality)}})(DS);var LS={};const j4=Fm;function tj(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function Ld(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function y4(e,t,n){let r="",i=0,l=!1,o=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),u=Math.floor(a/t);!c&&!l&&(l=!0),e[a]?(o++,a>0&&c>0&&e[a-1]||(r+=l?Ld("M",c+n,.5+u+n):Ld("m",i,0),i=0,l=!1),c+1<t&&e[a+1]||(r+=Ld("h",o),o=0)):i++}return r}LS.render=function(t,n,r){const i=j4.getOptions(n),l=t.modules.size,o=t.modules.data,a=l+i.margin*2,c=i.color.light.a?"<path "+tj(i.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",u="<path "+tj(i.color.dark,"stroke")+' d="'+y4(o,l,i.margin)+'"/>',h='viewBox="0 0 '+a+" "+a+'"',p='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+h+' shape-rendering="crispEdges">'+c+u+`</svg>
121
- `;return typeof r=="function"&&r(null,p),p};const w4=OF,$h=SS,FS=DS,b4=LS;function Um(e,t,n,r,i){const l=[].slice.call(arguments,1),o=l.length,a=typeof l[o-1]=="function";if(!a&&!w4())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(i=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(c,u){try{const h=$h.create(n,r);c(e(h,t,r))}catch(h){u(h)}})}try{const c=$h.create(n,r);i(null,e(c,t,r))}catch(c){i(c)}}yo.create=$h.create;yo.toCanvas=Um.bind(null,FS.render);yo.toDataURL=Um.bind(null,FS.renderToDataURL);yo.toString=Um.bind(null,function(e,t,n){return b4.render(e,n)});async function k4(e){const t=await yo.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const S4=550,N4=6e4,C4=5*6e4,US=1500,E4=3e3,nj=10*6e4;function bo(){const e=d.useRef(null);return d.useEffect(()=>{let t=0,n=0;const r=o=>{const a=o.ownerDocument.activeElement;return a===null||a===o.ownerDocument.body||a===o.ownerDocument.documentElement},i=()=>{const o=e.current;o&&r(o)&&o.focus()},l=()=>{i(),n=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(l):l(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(n),window.removeEventListener("focus",i)}},[]),e}function BS(){const[e,t]=d.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}});return d.useEffect(()=>{var i;let n;try{n=window.matchMedia("(prefers-reduced-motion: reduce)")}catch{return}const r=l=>t(l.matches);return(i=n.addEventListener)==null||i.call(n,"change",r),()=>{var l;return(l=n.removeEventListener)==null?void 0:l.call(n,"change",r)}},[]),e}function $e({children:e,at:t=0}){const n=BS(),[r,i]=d.useState(n||t===0);return d.useEffect(()=>{if(n){i(!0);return}const l=window.setTimeout(()=>i(!0),S4*t);return()=>window.clearTimeout(l)},[n,t]),r?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:e})}):s.jsx(lr,{})}function lr({line:e}){return s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[e,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})})}function Te({children:e}){return s.jsxs("div",{className:"meet-turn",children:[s.jsxs("div",{className:"wb-msg-who",children:[s.jsx(U0,{size:"sm"}),s.jsx("span",{children:"buddi"})]}),e]})}const zS=d.createContext({body:null,actions:null});function WS({children:e,actions:t}){const n=d.useContext(zS),r=e==null?null:n.body?$i.createPortal(e,n.body):e,i=t==null?null:n.actions?$i.createPortal(t,n.actions):t;return s.jsxs(s.Fragment,{children:[r,i]})}function ga({text:e,onChange:t}){return s.jsxs("div",{className:"wb-msg","data-role":"user",children:[s.jsx("div",{className:"wb-bubble",children:e}),s.jsx("button",{type:"button",className:"meet-change",onClick:t,children:z.change})]})}function kt({children:e,actions:t}){return s.jsx(WS,{actions:t?s.jsx("span",{className:"meet-actions",children:t}):null,children:e?s.jsx("div",{className:"meet-ask",children:e}):null})}function gu({onClick:e,disabled:t}){return s.jsxs(P,{variant:"ghost",onClick:e,disabled:t,children:[s.jsx(Oe,{name:"chevron-left"}),z.brain.back]})}function A4({navigate:e,timezone:t}){const[n,r]=d.useState(void 0);d.useEffect(()=>{A.session().then(ce=>r(ce.platform)).catch(()=>{})},[]);const[i,l]=d.useState({}),[o,a]=d.useState(null),[c,u]=d.useState(void 0),[h,f]=d.useState([]),[p,m]=d.useState(null),[j,w]=d.useState(null),[b,x]=d.useState(!1),[v,y]=d.useState(null),[g,S]=d.useState(null),[k,N]=d.useState(null),[C,T]=d.useState(null),E=d.useMemo(()=>({body:k,actions:C}),[k,C]),[U,H]=d.useState(null),[O,R]=d.useState(!1),F=d.useCallback(()=>R(!0),[]),[K,L]=d.useState(()=>kS()?"running":"idle"),M=d.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),V=d.useRef(e);V.current=e;const $=d.useCallback(async(ce=!0,we=!1)=>{var Fe,cs,pn,Wn,tn,mn;const[B,te,ge,Ee,Ve]=await Promise.all([A.onboarding().catch(()=>{}),A.owner().catch(()=>{}),A.providerAccounts().catch(()=>{}),_e.agents().catch(()=>{}),A.browser().catch(()=>{})]);u(ge),f((te==null?void 0:te.zones)??[]),y(((Fe=B==null?void 0:B.details)==null?void 0:Fe.conversationId)??null);const ve=(Ee==null?void 0:Ee.agents.find(D=>D.id===Ee.defaultAgentId))??(Ee==null?void 0:Ee.agents[0]);ve&&m(ve),S(B&&!B.needs.agent&&ve?{id:ve.id,name:ve.name,avatar:((cs=ve.avatar)==null?void 0:cs.kind)==="emoji"?ve.avatar.value:"",description:ve.description,...ve.picture?{picture:ve.picture}:{}}:null);const ct={onboarding:B,owner:te,accounts:ge,browser:(pn=Ve==null?void 0:Ve.browser)==null?void 0:pn.engine,...ve?{assistant:{id:ve.id,name:ve.name,avatar:((Wn=ve.avatar)==null?void 0:Wn.kind)==="emoji"?ve.avatar.value:""}}:{}},vt=bS(ct);if(we){const D=MF(ct);if(l(D.answers),a(D.open),!D.stay){const he=(tn=B==null?void 0:B.details)==null?void 0:tn.conversationId;V.current(he&&ve?De(ve.id,he):Ut,!0)}return}if(ce&&(B==null?void 0:B.state)==="done"){const D=(mn=B.details)==null?void 0:mn.conversationId;V.current(D&&ve?De(ve.id,D):Ut,!0);return}ce&&(l(vt),a(D=>D??Rh(vt)))},[]);d.useEffect(()=>{$()},[$]);const _=(ce,we={})=>{A.onboardingStep(wS[ce],we).catch(()=>{})},ne=(ce,we)=>{w(null),l(we),_(ce,ce==="brain"&&we.brain?{accountId:we.brain.accountId}:{}),a(Rh(we))},X=ce=>{w(null),l(we=>IF(we,ce)),a(ce)},ue=()=>{x(!0),A.skipOnboarding().then(()=>e(Ut)).catch(ce=>w(ce instanceof pe?ce.message:String(ce))).finally(()=>x(!1))},ye=K==="form"||K==="running"?[]:o?PF(i,o):[],Ne=d.useRef(null);return d.useEffect(()=>{const ce=Ne.current;if(!ce)return;const we=()=>{ce.scrollTop=ce.scrollHeight};we();let B;try{B=new ResizeObserver(we),ce.firstElementChild&&B.observe(ce.firstElementChild)}catch{}return()=>B==null?void 0:B.disconnect()},[ye.length,o,i,j]),s.jsx(zS.Provider,{value:E,children:s.jsx("div",{className:"meet",children:s.jsxs("div",{className:"meet-stack",children:[s.jsxs("header",{className:"meet-head",children:[s.jsx("img",{className:"meet-head-mascot",src:du("core"),alt:"","aria-hidden":"true"}),s.jsxs("span",{className:"meet-head-who",children:[s.jsx("span",{className:"meet-head-name",children:"buddi"}),s.jsx("span",{className:"meet-head-line",children:n===void 0||n==="darwin"?z.tagline:z.taglineElsewhere})]})]}),s.jsxs("div",{className:"meet-board",children:[s.jsx("div",{className:"meet-scroll thin-scroll",ref:Ne,children:s.jsxs("div",{className:"meet-thread","data-testid":"meet-thread",children:[s.jsx(Te,{children:z.opening.map((ce,we)=>s.jsx($e,{at:we,children:ce},ce))}),s.jsx(R4,{state:K,offered:o==="name"&&i.name===void 0,name:i.name,onState:L,onDone:()=>{L("idle"),$(!0,!0)},onTrouble:w}),ye.map(ce=>s.jsx(T4,{id:ce,openNow:o===ce,answers:i,accounts:c,zones:h,browserZone:M,assistantAgent:p,met:v,onMet:y,existing:g,navigate:e,onCarriesOn:H,onClosed:F,onSettled:we=>ne(ce,we),onChange:()=>X(ce),onTrouble:w,onReload:()=>void $(!1),onPickAnotherBrain:()=>X("brain")},ce)),j?s.jsx(Te,{children:s.jsx($e,{children:j})}):null]})}),s.jsxs("footer",{className:"meet-dock",children:[s.jsx("div",{className:"meet-dock-ask",ref:N}),s.jsxs("div",{className:"meet-dock-row",children:[O?s.jsx("span",{}):U?s.jsx("a",{className:"meet-later",href:U,onClick:ce=>{ce.preventDefault(),e(U,!0)},children:z.done.open}):s.jsx("button",{className:"meet-later",type:"button",disabled:b,onClick:ue,children:z.later}),s.jsx("div",{className:"meet-dock-actions",ref:T})]})]})]})]})})})}function R4({state:e,offered:t,name:n,onState:r,onDone:i,onTrouble:l}){const[o,a]=d.useState(()=>kS()),[c,u]=d.useState([]),[h,f]=d.useState(!1),[p,m]=d.useState(null),[j,w]=d.useState(""),[b,x]=d.useState(!1);d.useEffect(()=>{if(!o)return;let g=!1;const S=()=>{A.backupJob(o).then(N=>{g||(u(C=>C.includes(N.phase)?C:[...C,N.phase]),N.phase==="done"?(g=!0,Md(null),f(!0),i()):(N.phase==="rolled-back"||N.phase==="failed")&&(g=!0,Md(null),a(null),l(N.error??z.restore.phases[N.phase]),r("idle")))}).catch(()=>{})};S();const k=window.setInterval(S,US);return()=>{g=!0,window.clearInterval(k)}},[o]);const v=()=>{!p||b||(x(!0),l(null),A.firstRunRestore(p,j.trim()).then(g=>{Md(g.job.id),a(g.job.id),r("running")}).catch(g=>l(g instanceof pe?g.message:String(g))).finally(()=>x(!1)))},y=c.filter(g=>g in z.restore.phases);return s.jsxs(s.Fragment,{children:[t&&e==="idle"&&!h?s.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:z.restore.offer}):null,e==="form"?s.jsxs(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>r("idle"),children:z.restore.cancel}),s.jsx(P,{variant:"accent",disabled:b||!p,onClick:v,children:z.restore.submit})]}),children:[s.jsx(ee,{label:z.restore.file,grow:!0,children:s.jsx("input",{type:"file",onChange:g=>{var S;return m(((S=g.target.files)==null?void 0:S[0])??null)}})}),s.jsx(ee,{label:z.restore.passphrase,hint:z.restore.passphraseHint,children:s.jsx("input",{type:"password",autoComplete:"off",value:j,onChange:g=>w(g.target.value)})})]}):null,e==="running"||h?s.jsxs(Te,{children:[s.jsx($e,{children:z.restore.started}),y.map(g=>s.jsx($e,{children:z.restore.phases[g]},g))]}):null,h?s.jsxs(Te,{children:[n?s.jsx($e,{children:z.restore.welcome(n)}):null,s.jsx($e,{children:z.restore.keys})]}):null]})}function T4(e){var l,o,a,c;const{id:t,openNow:n,answers:r,onChange:i}=e;if(t==="name")return s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{at:1,children:z.name.ask})}),n?s.jsx(P4,{...e}):s.jsx(ga,{text:r.name??"",onChange:i})]});if(t==="clock")return s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{at:1,children:z.clock.ask(r.name??"",r.clock??e.browserZone)})}),n?s.jsx(I4,{...e}):s.jsx(ga,{text:z.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{at:1,children:z.brain.ask})}),n?s.jsx(M4,{...e}):s.jsxs(s.Fragment,{children:[s.jsx(ga,{text:z.brain.answer(((l=r.brain)==null?void 0:l.label)??""),onChange:i}),s.jsx(Te,{children:s.jsx($e,{children:z.brain.works(((o=r.brain)==null?void 0:o.model)??"")})})]})]});if(t==="browser"){if(n)return s.jsx(H4,{...e});const u=V4(r.browser);return u?s.jsx(Te,{children:s.jsx($e,{children:u})}):null}return t==="assistant"?s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{at:1,children:z.assistant.ask})}),n?s.jsx(G4,{...e}):s.jsx(ga,{text:`${((a=r.assistant)==null?void 0:a.avatar)??""} ${((c=r.assistant)==null?void 0:c.name)??""}`.trim(),onChange:i})]}):s.jsx(Y4,{...e})}function P4({answers:e,onSettled:t,onTrouble:n}){const r=bo(),[i,l]=d.useState(e.name??""),[o,a]=d.useState(!1),c=()=>{const u=i.trim();u===""||o||(a(!0),A.setOwner({preferredName:u}).then(()=>t({...e,name:u})).catch(h=>n(h instanceof pe?h.message:String(h))).finally(()=>a(!1)))};return s.jsx(kt,{actions:s.jsx(P,{variant:"accent",disabled:o||i.trim()==="",onClick:c,children:z.name.submit}),children:s.jsx("input",{ref:r,className:"meet-input","aria-label":z.name.placeholder,placeholder:z.name.placeholder,maxLength:80,value:i,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function I4({answers:e,zones:t,browserZone:n,onSettled:r,onTrouble:i}){const[l,o]=d.useState(!1),[a,c]=d.useState(n),[u,h]=d.useState(!1),f=p=>{h(!0),A.setOwner({timezone:p}).then(()=>r({...e,clock:p})).catch(m=>i(m instanceof pe?m.message:String(m))).finally(()=>h(!1))};return l?s.jsx(kt,{actions:s.jsx(P,{variant:"accent",disabled:u,onClick:()=>f(a),children:z.clock.yes}),children:s.jsx("select",{className:"meet-input","aria-label":z.clock.label,value:a,onChange:p=>c(p.target.value),children:(t.includes(a)?t:[a,...t]).map(p=>s.jsx("option",{value:p,children:p},p))})}):s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>o(!0),children:z.clock.another}),s.jsx(P,{variant:"accent",disabled:u,onClick:()=>f(n),children:z.clock.yes})]})})}function M4(e){const{accounts:t,answers:n,onSettled:r,onReload:i}=e,[l,o]=d.useState(null),[a,c]=d.useState(null),[u,h]=d.useState(!1),[f,p]=d.useState(null),[m,j]=d.useState(null),w=(t==null?void 0:t.anthropicOAuthEnabled)===!0;d.useEffect(()=>{let y=!1;const g=()=>{A.ollama().then(k=>{y||p(k)}).catch(()=>{})};g();const S=window.setInterval(g,4e3);return()=>{y=!0,window.clearInterval(S)}},[]);const b=async y=>{if(n.assistant)try{await A.bindBrain({accountId:y.accountId,model:y.model})}catch(S){return S instanceof pe?S.message:String(S)}return i(),r({...n,brain:y}),null},x=async(y,g)=>{h(!0),c(null);try{const S=await A.saveProviderAccount(y),k=await A.testProviderAccount(S.id);if(k.state!=="connected"){try{const C=(await A.providerAccounts()).accounts.find(T=>T.id===S.id);C&&await A.removeProviderAccount(S.id,C.revision)}catch{}c(k.message);return}const N=await b({accountId:S.id,label:g,model:y.defaultModel});N&&c(N)}catch(S){c(S instanceof pe?S.message:String(S))}finally{h(!1)}},v=(y,g,S)=>{if(y.length<=1){x(g(y[0]??""),S);return}j({models:y,make:g,label:S})};return m?s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{children:z.brain.model.ask})}),u?s.jsx(Te,{children:s.jsx(lr,{line:z.brain.checking.service})}):a?s.jsx(Te,{children:s.jsx($e,{children:a})}):null,s.jsx(L4,{busy:u,models:m.models,onUse:y=>void x(m.make(y),m.label)})]}):l==="key"?s.jsx(F4,{busy:u,problem:a,onBack:()=>o(null),onUse:x}):l==="service"?s.jsx(B4,{busy:u,problem:a,address:(f==null?void 0:f.cloudBaseUrl)??"",onBack:()=>o(null),onOffer:v}):l==="ollama"?s.jsx(U4,{busy:u,problem:a,probe:f,onBack:()=>o(null),onOffer:v}):l==="claude"?s.jsx(z4,{busy:u,problem:a,onBack:()=>o(null),onConnected:b,...e}):s.jsx(WS,{children:s.jsxs("div",{className:"meet-cards",role:"group","aria-label":z.brain.ask,children:[w?s.jsx(xa,{mark:s.jsx($4,{}),card:z.brain.cards.claude,onPick:()=>o("claude")}):null,s.jsx(xa,{mark:s.jsx(_4,{}),card:z.brain.cards.key,onPick:()=>o("key")}),s.jsx(xa,{mark:s.jsx(O4,{}),card:z.brain.cards.ollama,note:f===null?z.brain.ollama.looking:f.running?z.brain.ollama.found:z.brain.ollama.missing,onPick:()=>o("ollama")}),s.jsx(xa,{mark:s.jsx(D4,{}),card:z.brain.cards.service,onPick:()=>o("service")})]})})}function xa({mark:e,card:t,note:n,onPick:r}){return s.jsxs("button",{type:"button",className:"meet-card",onClick:r,children:[s.jsx("span",{className:"meet-card-mark","aria-hidden":"true",children:e}),s.jsxs("span",{className:"meet-card-words",children:[s.jsx("span",{className:"meet-card-title",children:t.title}),s.jsx("span",{className:"meet-card-line",children:n??t.line})]})]})}function $4(){const e=[0,45,90,135,180,225,270,315];return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",children:e.map(t=>s.jsx("rect",{x:"11.1",y:"2.6",width:"1.8",height:"8.6",rx:"0.9",fill:"currentColor",transform:`rotate(${t} 12 12)`},t))})}function _4(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"8",cy:"8",r:"3.6"}),s.jsx("path",{d:"M10.6 10.6 19.4 19.4"}),s.jsx("path",{d:"M13.8 13.8 11.9 15.7"}),s.jsx("path",{d:"M16.6 16.6 14.7 18.5"})]})}function O4(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3.2",y:"4.6",width:"17.6",height:"11.2",rx:"2"}),s.jsx("path",{d:"M9.4 19.4h5.2"}),s.jsx("path",{d:"M12 15.8v3.6"})]})}function D4(){return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7.2 18.3h9.6a3.8 3.8 0 0 0 .5-7.6 5.4 5.4 0 0 0-10.3-1.2 3.9 3.9 0 0 0 .2 8.8Z"})})}function L4({busy:e,models:t,onUse:n}){const[r,i]=d.useState(t[0]??"");return s.jsx(kt,{actions:s.jsx(P,{variant:"accent",disabled:e||r==="",onClick:()=>n(r),children:z.brain.model.submit}),children:s.jsx(ee,{label:z.brain.model.label,grow:!0,children:s.jsx("select",{value:r,onChange:l=>i(l.target.value),children:t.map(l=>s.jsx("option",{value:l,children:l},l))})})})}function F4({busy:e,problem:t,onBack:n,onUse:r}){const i=bo(),[l,o]=d.useState(""),[a,c]=d.useState(null),[u,h]=d.useState(!1),f=e||u,p=a??$F(l),m=()=>{const j=l.trim();j===""||f||(h(!0),(async()=>{var b;let w=p==="anthropic"?"claude-sonnet-5":"gpt-5";try{w=((b=(await A.probeModels({kind:p,auth:"api-key",secret:j})).models.find(v=>v.isDefault))==null?void 0:b.id)??w}catch{}h(!1),await r({label:p==="anthropic"?z.brain.key.anthropic:z.brain.key.openai,kind:p,auth:"api-key",baseUrl:"",defaultModel:w,enabled:!0,secret:j},p==="anthropic"?z.brain.key.anthropic:z.brain.key.openai)})())};return s.jsxs(s.Fragment,{children:[f?s.jsx(Te,{children:s.jsx(lr,{line:z.brain.checking.key})}):t?s.jsx(Te,{children:s.jsx($e,{children:z.brain.key.refused})}):null,s.jsxs(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(gu,{onClick:n,disabled:f}),s.jsx(P,{variant:"accent",disabled:f||l.trim()==="",onClick:m,children:z.brain.key.submit})]}),children:[s.jsx(ee,{label:z.brain.key.field,grow:!0,children:s.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:z.brain.key.placeholder,value:l,onChange:j=>o(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),m())}})}),s.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(p==="anthropic"?"openai":"anthropic"),children:[p==="anthropic"?z.brain.key.anthropic:z.brain.key.openai," · ",z.brain.key.which]})]})]})}function U4({busy:e,problem:t,probe:n,onBack:r,onOffer:i}){const l=(n==null?void 0:n.models)??[],o=()=>{n&&i(l,a=>({label:z.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:n.baseUrl,defaultModel:a,enabled:!0}),z.brain.cards.ollama.title)};return s.jsxs(s.Fragment,{children:[e?s.jsx(Te,{children:s.jsx(lr,{line:z.brain.checking.ollama})}):t?s.jsx(Te,{children:s.jsx($e,{children:t})}):null,s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(gu,{onClick:r,disabled:e}),n!=null&&n.running?s.jsx(P,{variant:"accent",disabled:e||l.length===0,onClick:o,children:z.brain.ollama.connect}):n?s.jsx(Fn,{variant:"accent",href:n.downloadUrl,target:"_blank",rel:"noreferrer",children:z.brain.ollama.download}):null]}),children:s.jsx("span",{className:"meet-line",children:n===null?z.brain.ollama.looking:n.running?z.brain.ollama.found:z.brain.ollama.missing})})]})}function B4({busy:e,problem:t,address:n,onBack:r,onOffer:i}){const l=bo(),[o,a]=d.useState(n),[c,u]=d.useState(""),[h,f]=d.useState(!1),p=e||h,m=()=>{o.trim()===""||p||(f(!0),(async()=>{var v;const j=c.trim()?"api-key":"none",w=y=>({label:z.brain.cards.service.title,kind:"openai-compatible",auth:j,baseUrl:o.trim(),defaultModel:y,enabled:!0,...c.trim()?{secret:c.trim()}:{}});let b=[],x;try{const y=await A.probeModels({kind:"openai-compatible",auth:j,baseUrl:o.trim(),...c.trim()?{secret:c.trim()}:{}});b=y.models.map(g=>g.id),x=(v=y.models.find(g=>g.isDefault))==null?void 0:v.id}catch{}f(!1),i(x?[x]:b,w,z.brain.cards.service.title)})())};return s.jsxs(s.Fragment,{children:[p?s.jsx(Te,{children:s.jsx(lr,{line:z.brain.checking.service})}):t?s.jsx(Te,{children:s.jsx($e,{children:t})}):null,s.jsxs(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(gu,{onClick:r,disabled:p}),s.jsx(P,{variant:"accent",disabled:p||o.trim()==="",onClick:m,children:z.brain.service.submit})]}),children:[s.jsx(ee,{label:z.brain.service.address,grow:!0,children:s.jsx("input",{ref:l,value:o,placeholder:z.brain.service.addressPlaceholder,onChange:j=>a(j.target.value)})}),s.jsx(ee,{label:z.brain.service.key,children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:c,onChange:j=>u(j.target.value)})})]})]})}function z4({busy:e,problem:t,onBack:n,onConnected:r,accounts:i}){const[l,o]=d.useState(!1),[a,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(""),m="claude-sonnet-5",j=()=>{o(!0),c(null),(async()=>{try{const b=((i==null?void 0:i.accounts)??[]).find(S=>S.auth==="anthropic-oauth"),x=b?{id:b.id}:await A.saveProviderAccount({label:z.brain.cards.claude.title,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:m,enabled:!0}),y=(await A.providerAccounts()).accounts.find(S=>S.id===x.id),g=await A.anthropicAccountAction(y.id,"login",y.revision);h({id:y.id,revision:y.revision+1,url:g.verificationUrl??"",attemptId:g.attemptId??""})}catch(b){c(b instanceof pe?b.message:String(b))}finally{o(!1)}})()},w=()=>{!u||f.trim()===""||(o(!0),(async()=>{try{await A.anthropicAccountAction(u.id,"complete-login",u.revision,{attemptId:u.attemptId,code:f.trim()});const b=await A.testProviderAccount(u.id);if(b.state!=="connected"){c(b.message);return}c(await r({accountId:u.id,label:z.brain.cards.claude.title,model:m}))}catch(b){c(b instanceof pe?b.message:String(b))}finally{o(!1)}})())};return s.jsxs(s.Fragment,{children:[l||e?s.jsx(Te,{children:s.jsx(lr,{line:z.brain.checking.claude})}):t??a?s.jsx(Te,{children:s.jsx($e,{children:t??a})}):null,u?s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{children:z.brain.claude.waiting})}),s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(Fn,{href:u.url,target:"_blank",rel:"noreferrer",children:z.brain.claude.open}),s.jsx(P,{variant:"accent",disabled:l||f.trim()==="",onClick:w,children:z.brain.claude.finish})]}),children:s.jsx(ee,{label:z.brain.claude.paste,grow:!0,children:s.jsx(W4,{value:f,onChange:p})})})]}):s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(gu,{onClick:n,disabled:e||l}),s.jsx(P,{variant:"accent",disabled:e||l,onClick:j,children:z.brain.claude.start})]})})]})}function W4({value:e,onChange:t}){const n=bo();return s.jsx("input",{ref:n,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function V4(e){switch(e){case"chrome":return z.browser.chrome;case"chromium":return z.browser.chromium;case"installed":return z.browser.installed;case"skipped":return z.browser.skipped;case"none":return z.browser.missing;default:return null}}function H4({answers:e,onSettled:t}){const[n,r]=d.useState("checking"),[i,l]=d.useState(null),[o,a]=d.useState(null),[c,u]=d.useState(void 0),[h,f]=d.useState(0),p=d.useRef(!1),m=d.useRef(!1),j=d.useRef(()=>{});if(j.current=b=>{m.current||(m.current=!0,t({...e,browser:b}))},d.useEffect(()=>{let b=!1,x;const v=k=>{b||j.current(k)},y=(k,N)=>{b||(p.current=!1,r("failed"),l(k),a(N??null))},g=async k=>{r("launching");let N;try{N=await A.browserCheck()}catch(C){return y(C instanceof pe?C.message:String(C))}if(!b)return N.ok?v(p.current?"installed":k):y(N.message,N.command)},S=async()=>{var C,T;let k;try{k=await A.browser()}catch{return v("other")}if(b)return;const N=k.browser;if(!N)return v("other");if(((C=N.install)==null?void 0:C.state)==="running"){r("installing"),u(N.install.progress),x=window.setTimeout(()=>void S(),1e3);return}if(N.engine!=="none")return g(N.engine);if(p.current)return y(((T=N.install)==null?void 0:T.line)??"");p.current=!0,r("installing"),u(void 0);try{await A.browserInstall()}catch(E){return y(E instanceof pe?E.message:String(E))}b||(x=window.setTimeout(()=>void S(),1e3))};return S(),()=>{b=!0,window.clearTimeout(x)}},[h]),n==="checking")return s.jsx(lr,{});const w=n==="installing"||n==="launching";return s.jsxs(s.Fragment,{children:[s.jsxs(Te,{children:[p.current||n==="installing"?s.jsx($e,{children:z.browser.needs}):null,n==="installing"?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:s.jsx(lk,{progress:c})})}):n==="launching"?s.jsx(lr,{line:z.browser.launching}):s.jsx($e,{children:z.browser.failed(i??"")})]}),s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>j.current("skipped"),children:z.browser.skip}),s.jsx(P,{variant:"accent",disabled:w,onClick:()=>{r("launching"),a(null),f(b=>b+1)},children:w?z.browser.installing:z.browser.retry})]}),children:n==="failed"&&o?s.jsx(K4,{command:o}):null})]})}function K4({command:e}){const[t,n]=d.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("failed");return}navigator.clipboard.writeText(e).then(()=>n("done"),()=>n("failed"))};return s.jsxs(q,{gap:"sm",children:[s.jsx(rt,{label:"The command to run",children:e}),s.jsxs(J,{align:"end",children:[t==="failed"?s.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,s.jsx(P,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function G4({answers:e,existing:t,onSettled:n,onTrouble:r,onReload:i}){const[l,o]=d.useState(()=>(t==null?void 0:t.name)??fD),[a,c]=d.useState(()=>t!=null&&t.picture?{kind:"kept",url:t.picture}:t!=null&&t.avatar?{kind:"emoji",value:t.avatar}:{kind:"mascot",role:"core"}),[u,h]=d.useState(t?null:z.assistant.purposeValue),[f,p]=d.useState(t?"":z.assistant.purposeValue);d.useEffect(()=>{if(!t)return;let b=!1;return A.firstAgentPersona().then(x=>{b||(h(x.persona),p(x.persona))},x=>{b||r(x instanceof pe?x.message:String(x))}),()=>{b=!0}},[t==null?void 0:t.id]);const[m,j]=d.useState(!1),w=()=>{if(l.trim()===""||m)return;j(!0);const b=a.kind==="emoji"?{avatar:a.value}:{},x=!t||u!==null&&f.trim()!==""&&f.trim()!==u.trim()?{instructions:f.trim()}:{},v=t?A.updateFirstAgent({name:l.trim(),...x,...b}):A.createFirstAgent({name:l.trim(),handle:_F(l),description:"",...x,...b,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let y;try{y=await v}catch(S){r(S instanceof pe?S.message:String(S)),j(!1);return}let g=null;try{a.kind==="mascot"?await A.uploadAgentPicture(y.id,await Gk(a.role)):a.kind==="emoji"&&(t!=null&&t.picture)&&await A.removeAgentPicture(y.id)}catch(S){g=S instanceof pe?S.message:String(S)}j(!1),i(),n({...e,assistant:{id:y.id,name:l.trim(),avatar:a.kind==="emoji"?a.value:""}}),g&&r(g)})()};return s.jsxs(kt,{actions:s.jsx(P,{variant:"accent",disabled:m||l.trim()===""||u===null,onClick:w,children:z.assistant.submit}),children:[s.jsx("span",{className:"meet-chosen-face","data-kind":a.kind==="emoji"?"emoji":"image","aria-hidden":"true",children:a.kind==="emoji"?a.value:s.jsx("img",{src:a.kind==="mascot"?du(a.role):a.url,alt:""})}),s.jsx(ee,{label:z.assistant.name,children:s.jsx("input",{value:l,maxLength:60,onChange:b=>o(b.target.value)})}),s.jsx(Yk,{face:a,onPick:c}),s.jsx(ee,{label:z.assistant.purpose,wide:!0,children:s.jsx("textarea",{className:"meet-purpose",value:f,maxLength:8e3,rows:Math.max(4,f.split(`
122
- `).length+1),onChange:b=>p(b.target.value)})})]})}function Y4({answers:e,assistantAgent:t,met:n,onMet:r,onCarriesOn:i,onClosed:l,navigate:o,onPickAnotherBrain:a}){const c=e.assistant,[u,h]=d.useState(n),[f,p]=d.useState([]),[m,j]=d.useState(!1),[w,b]=d.useState(!1),[x,v]=d.useState(!0),[y,g]=d.useState("open"),[S,k]=d.useState(!1),N=BS(),C=d.useRef(!1),T=d.useMemo(()=>t?[t]:[],[t]);d.useEffect(()=>{if(!c||C.current)return;if(C.current=!0,n){h(n);return}let O=!1;return(async()=>{try{const R=await _e.startConversation(c.id);if(O)return;h(R.conversationId),r(R.conversationId),await A.onboardingStep(wS.handover,{conversationId:R.conversationId}).catch(()=>{}),await _e.send(c.id,{conversationId:R.conversationId,text:mD,opening:!0})}catch{O||(v(!1),j(!0))}})(),()=>{O=!0}},[c==null?void 0:c.id,n]),d.useEffect(()=>{if(!u)return;let O=!1;const R=Date.now(),F=()=>{_e.conversation(u).then(L=>{if(O)return;p(L.messages);const M=Date.now()-R;if(L.messages.some(sj)){v(!1),j(!1),b(!1);return}const V=L.runs??[],$=V.some(ne=>ne.finishedAt===null),_=V.length>0&&!$;b($&&M>=N4),(_||M>=C4)&&(v(!1),j(!0))}).catch(()=>{})};F();const K=window.setInterval(F,US);return()=>{O=!0,window.clearInterval(K)}},[u]);const E=c&&u?De(c.id,u):null,U=f.some(sj);d.useEffect(()=>{U&&E&&i(E)},[U,E,i]),d.useEffect(()=>{if(!S||!E||N)return;const O=window.setTimeout(()=>o(E,!0),E4);return()=>window.clearTimeout(O)},[S,E,N,o]);const H=S&&E!==null;return d.useEffect(()=>{H&&l()},[H,l]),s.jsxs(s.Fragment,{children:[s.jsx(nk,{messages:f,live:[],now:Date.now(),onOpen:()=>{},working:x,agents:T,agentName:(c==null?void 0:c.name)??"",emptyHint:z.handover.waiting,plain:!0,workingLine:z.handover.looking((c==null?void 0:c.name)??"")}),w&&!m?s.jsx(Te,{children:s.jsx($e,{children:z.handover.slow})}):null,m?s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{children:z.handover.silent})}),s.jsx(kt,{actions:s.jsx(P,{variant:"accent",onClick:a,children:z.handover.again})})]}):null,S?s.jsx(Te,{children:s.jsx($e,{children:z.done.said})}):null,U&&y==="open"?s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{onClick:()=>g("phone"),children:z.offers.phone}),s.jsx(P,{variant:"accent",onClick:()=>{g("gone"),k(!0)},children:z.offers.notNow})]})}):null,U&&y==="phone"?s.jsx(q4,{onPaired:()=>k(!0),onDismiss:()=>{g("gone"),k(!0)}}):null,H&&E?s.jsx(kt,{actions:s.jsx(Fn,{variant:"accent",href:E,onClick:O=>{O.preventDefault(),o(E,!0)},children:z.done.open}),children:s.jsx("span",{className:"meet-line",children:N?z.done.ready:z.done.leaving})}):null]})}function sj(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function q4({onPaired:e,onDismiss:t}){const n=bo(),[r,i]=d.useState(""),[l,o]=d.useState(!1),[a,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),[m,j]=d.useState(!1),[w,b]=d.useState(!1),x=async()=>{const g=await A.telegramPairing();h(g),b(!1),p(await k4(g.link).catch(()=>""))},v=()=>{r.trim()===""||l||(o(!0),c(null),(async()=>{try{const g=await A.saveTelegramToken(r.trim());if(i(""),g.restartNeeded){c(g.note??z.telegram.restart);return}await x()}catch(g){c(g instanceof pe?g.message:String(g))}finally{o(!1)}})())},y=()=>{c(null),x().catch(g=>c(g instanceof pe?g.message:String(g)))};return d.useEffect(()=>{if(!u||m||w)return;let g=!1;const S=Math.min(Date.parse(u.expiresAt)||Date.now()+nj,Date.now()+nj),k=window.setInterval(()=>{if(Date.now()>=S){b(!0);return}A.telegram().then(N=>{g||!N.paired||(j(!0),e())}).catch(()=>{})},2e3);return()=>{g=!0,window.clearInterval(k)}},[u,m,w]),m?s.jsx(Te,{children:s.jsx($e,{children:z.telegram.paired})}):u?s.jsxs(s.Fragment,{children:[s.jsx(Te,{children:s.jsx($e,{children:w?z.telegram.expired:z.telegram.scan})}),s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:t,children:z.offers.notNow}),w?s.jsx(P,{variant:"accent",onClick:y,children:z.telegram.newCode}):null]}),children:w?null:s.jsxs("div",{className:"meet-pair",children:[f?s.jsx("img",{className:"meet-qr",src:f,alt:u.link}):null,s.jsx("a",{className:"meet-link",href:u.link,target:"_blank",rel:"noreferrer",children:u.link})]})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Te,{children:[s.jsx($e,{children:z.telegram.how}),a?s.jsx($e,{children:a}):null]}),s.jsx(kt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:t,children:z.offers.notNow}),s.jsx(P,{variant:"accent",disabled:l||r.trim()==="",onClick:v,children:z.telegram.submit})]}),children:s.jsx(ee,{label:z.telegram.field,grow:!0,children:s.jsx("input",{ref:n,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:g=>i(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),v())}})})})]})}const Q4="(max-width: 1080px)";function J4(){const[e,t]=d.useState(()=>window.location.hash||Ut);d.useEffect(()=>{const r=()=>t(window.location.hash||Ut);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const n=d.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,n]}function X4(){const[e,t]=Ok();d.useEffect(()=>{_k(e)},[e]);const n=d.useCallback(r=>t({theme:r}),[t]);return[e.theme,n]}function Z4(){var we,B;const[e,t]=J4(),[n,r]=d.useState("UTC"),[i,l]=d.useState({approvals:0,failed:0}),[o,a]=X4(),c=Nh(Qk),[u,h]=d.useState(!1),[f,p]=d.useState([]),[m,j]=d.useState(null),[w,b]=d.useState(null),[x,v]=d.useState([]),[y,g]=d.useState(!1),[S,k]=d.useState(null),N=vI(),C=Nh(Q4),T=Jk(),E=Ak(),[U,H]=d.useState(new Map);d.useEffect(()=>{const te=()=>{A.conversations().then(Ee=>{const Ve=new Map;for(const ve of Ee.conversations){const ct=ve.lastMessageAt??ve.createdAt,vt=Ve.get(ve.agentId);(!vt||ct>vt)&&Ve.set(ve.agentId,ct)}H(Ve)}).catch(()=>{})};te();const ge=window.setInterval(te,3e4);return()=>window.clearInterval(ge)},[e]);const[O,R]=d.useState(!1);d.useEffect(()=>{if(O)return;let te=!1;return A.onboarding().then(ge=>{te||(R(!0),ge.state==="pending"&&ge.needs.model&&!sv(window.location.hash)&&t(om,!0))}).catch(()=>{te||R(!0)}),()=>{te=!0}},[O,t]),d.useEffect(()=>{const te=iI(e);te&&t(te,!0)},[e,t]),d.useEffect(()=>{let te=!1;const ge=()=>{_e.agents().then(Ve=>{te||(p(Ve.agents),uI(Ve.defaultAgentId??null),j(Ve.defaultAgentId??null),b(ve=>{var ct;return ve??Ve.defaultAgentId??((ct=Ve.agents[0])==null?void 0:ct.id)??null}))}).catch(()=>{})};ge();const Ee=window.setInterval(ge,15e3);return window.addEventListener("focus",ge),window.addEventListener(to,ge),()=>{te=!0,window.clearInterval(Ee),window.removeEventListener("focus",ge),window.removeEventListener(to,ge)}},[e]),d.useEffect(()=>{let te=!1;const ge=()=>{_e.groups().then(Ve=>{te||v(Ve.groups)}).catch(()=>{})};ge();const Ee=window.setInterval(ge,3e4);return()=>{te=!0,window.clearInterval(Ee)}},[e]);const F=y0(f,m),K=YP(e),L=x0(e),M=L?x.find(te=>te.id===L.groupId)??null:null,V=L?null:(K==null?void 0:K.agentId)??w;d.useEffect(()=>{K&&b(K.agentId)},[K==null?void 0:K.agentId]);const $=te=>{b(te),t(De(te))},_=te=>t(Ml(te)),ne=d.useCallback((te,ge,Ee=!0)=>t(L?Ml(L.groupId,ge):De(te,ge),Ee),[t,L==null?void 0:L.groupId]);d.useEffect(()=>{A.session().then(te=>r(te.timezone)).catch(()=>{})},[]),d.useEffect(()=>{const te=()=>{A.overview().then(Ee=>l({approvals:Ee.approvals.pending,failed:Ee.jobs.failed??0})).catch(()=>{})};te();const ge=window.setInterval(te,2e4);return()=>window.clearInterval(ge)},[]);const X=sv(e),ue=lI(e),ye=ue===Oi,Ne=S?x.find(te=>te.id===S)??null:null,ce=y?s.jsx(_v,{agents:f,onClose:()=>g(!1),onCreated:te=>{v(ge=>[...ge,te]),g(!1),t(Ml(te.id))}}):Ne?s.jsx(_v,{agents:f,group:Ne,onClose:()=>k(null),onSaved:te=>{v(ge=>ge.map(Ee=>Ee.id===te.id?te:Ee)),k(null)},onArchived:te=>{v(ge=>ge.filter(Ee=>Ee.id!==te)),k(null),t(Oi)}}):null;return X?s.jsx(Hx,{delayDuration:400,children:s.jsxs(Ix,{swipeDirection:"right",children:[s.jsx(A4,{navigate:t,timezone:n}),s.jsx(Mx,{className:"ui-toasts"})]})}):s.jsx(II,{picture:(we=f.find(te=>te.id===m))==null?void 0:we.picture,children:s.jsx(Hx,{delayDuration:400,children:s.jsxs(Ix,{swipeDirection:"right",children:[ce,s.jsxs("div",{className:"wb-shell",children:[s.jsx(GD,{active:((B=T.data)==null?void 0:B.active)===!0,onNavigate:t}),s.jsxs("div",{className:"wb",children:[s.jsx(AO,{attention:i.approvals+i.failed,place:ue,onNavigate:t,theme:o,onTheme:a,plugins:E.rail}),ye&&!C?s.jsx(C0,{agents:F,currentId:V,attention:N,onSelect:$,lastActivity:U,groups:x,currentGroupId:(M==null?void 0:M.id)??null,onSelectGroup:_,onNewGroup:()=>g(!0)}):null,ye?s.jsx(M_,{timezone:n,agents:F,agentId:M?M.coordinator:V,defaultAgentId:m,group:M,onEditGroup:M?()=>k(M.id):void 0,requestedConversationId:(L==null?void 0:L.conversationId)??(K==null?void 0:K.conversationId),requestedTab:K==null?void 0:K.tab,onConversationOpened:ne,onSelectAgent:$,attention:N,agentsInHeader:C,narrow:c,canvasOpen:u,onOpenCanvas:()=>h(!0),onCloseCanvas:()=>h(!1)}):s.jsx("main",{"data-ground":e3(ue,e)?"plain":void 0,"data-layout":ue===Ht?"split":void 0,children:s.jsx(t3,{hash:e,place:ue,timezone:n,navigate:t,agents:f,defaultAgentId:m,attention:N,pluginPages:E})})]})]}),s.jsx(Mx,{className:"ui-toasts"})]})})})}function e3(e,t){return am(t)!==null}function t3({place:e,pluginPages:t,...n}){const r={...n,pluginPages:t},i=am(n.hash);if(i){const l=t.find(i.plugin,i.page);if(l)return s.jsx(Ek,{page:l,item:i.item??null,navigate:n.navigate,timezone:n.timezone,siblings:t.all.filter(o=>o.plugin===i.plugin)});if(t.all.length===0)return s.jsx(s.Fragment,{})}switch(e){case Xe:return s.jsx(TD,{...n});case Je:return s.jsx(VO,{...n});case Ht:return s.jsx(cF,{...r});case $r:return s.jsx(SO,{...n});default:return s.jsx($D,{...n})}}const rj=document.getElementById("root");rj&&xw(rj).render(s.jsx(d.StrictMode,{children:s.jsx(Z4,{})}));