@withbuddi/buddi 0.1.0-pre.24 → 0.1.0-pre.26

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 (716) hide show
  1. package/README.md +62 -47
  2. package/examples/agents/agent-father/agent.md +1 -0
  3. package/extension/background.js +24 -1
  4. package/extension/blob.png +0 -0
  5. package/extension/fonts/dm-mono-latin-400-normal.woff2 +0 -0
  6. package/extension/fonts/dm-mono-latin-500-normal.woff2 +0 -0
  7. package/extension/fonts/dm-sans-latin-ext-standard-normal.woff2 +0 -0
  8. package/extension/fonts/dm-sans-latin-standard-normal.woff2 +0 -0
  9. package/extension/icons/128.png +0 -0
  10. package/extension/icons/16.png +0 -0
  11. package/extension/icons/32.png +0 -0
  12. package/extension/icons/48.png +0 -0
  13. package/extension/manifest.json +4 -3
  14. package/extension/popup.css +199 -81
  15. package/extension/popup.html +39 -17
  16. package/extension/popup.js +133 -37
  17. package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
  18. package/node_modules/@buddi/cli/dist/args.d.ts +59 -0
  19. package/node_modules/@buddi/cli/dist/args.d.ts.map +1 -1
  20. package/node_modules/@buddi/cli/dist/args.js +141 -0
  21. package/node_modules/@buddi/cli/dist/args.js.map +1 -1
  22. package/node_modules/@buddi/cli/dist/commands.d.ts +2 -0
  23. package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
  24. package/node_modules/@buddi/cli/dist/commands.js +71 -1
  25. package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
  26. package/node_modules/@buddi/cli/dist/connections-cmd.d.ts +93 -0
  27. package/node_modules/@buddi/cli/dist/connections-cmd.d.ts.map +1 -0
  28. package/node_modules/@buddi/cli/dist/connections-cmd.js +657 -0
  29. package/node_modules/@buddi/cli/dist/connections-cmd.js.map +1 -0
  30. package/node_modules/@buddi/cli/dist/doctor-probes.d.ts.map +1 -1
  31. package/node_modules/@buddi/cli/dist/doctor-probes.js +82 -17
  32. package/node_modules/@buddi/cli/dist/doctor-probes.js.map +1 -1
  33. package/node_modules/@buddi/cli/dist/doctor.d.ts +9 -9
  34. package/node_modules/@buddi/cli/dist/doctor.d.ts.map +1 -1
  35. package/node_modules/@buddi/cli/dist/doctor.js +20 -17
  36. package/node_modules/@buddi/cli/dist/doctor.js.map +1 -1
  37. package/node_modules/@buddi/cli/dist/init-plan.d.ts +1 -2
  38. package/node_modules/@buddi/cli/dist/init-plan.d.ts.map +1 -1
  39. package/node_modules/@buddi/cli/dist/init-plan.js +2 -6
  40. package/node_modules/@buddi/cli/dist/init-plan.js.map +1 -1
  41. package/node_modules/@buddi/cli/dist/init.d.ts.map +1 -1
  42. package/node_modules/@buddi/cli/dist/init.js +5 -29
  43. package/node_modules/@buddi/cli/dist/init.js.map +1 -1
  44. package/node_modules/@buddi/cli/dist/main.d.ts.map +1 -1
  45. package/node_modules/@buddi/cli/dist/main.js +10 -1
  46. package/node_modules/@buddi/cli/dist/main.js.map +1 -1
  47. package/node_modules/@buddi/cli/dist/mcp/gateway-client.d.ts +5 -0
  48. package/node_modules/@buddi/cli/dist/mcp/gateway-client.d.ts.map +1 -1
  49. package/node_modules/@buddi/cli/dist/mcp/gateway-client.js +15 -4
  50. package/node_modules/@buddi/cli/dist/mcp/gateway-client.js.map +1 -1
  51. package/node_modules/@buddi/cli/dist/service/index.d.ts +4 -2
  52. package/node_modules/@buddi/cli/dist/service/index.d.ts.map +1 -1
  53. package/node_modules/@buddi/cli/dist/service/index.js +5 -7
  54. package/node_modules/@buddi/cli/dist/service/index.js.map +1 -1
  55. package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
  56. package/node_modules/@buddi/core/dist/agents/catalog.d.ts.map +1 -1
  57. package/node_modules/@buddi/core/dist/agents/catalog.js +11 -2
  58. package/node_modules/@buddi/core/dist/agents/catalog.js.map +1 -1
  59. package/node_modules/@buddi/core/dist/agents/provider-from-env.d.ts +7 -6
  60. package/node_modules/@buddi/core/dist/agents/provider-from-env.d.ts.map +1 -1
  61. package/node_modules/@buddi/core/dist/agents/provider-from-env.js +9 -12
  62. package/node_modules/@buddi/core/dist/agents/provider-from-env.js.map +1 -1
  63. package/node_modules/@buddi/core/dist/agents/skills.d.ts +4 -4
  64. package/node_modules/@buddi/core/dist/backup/load.d.ts.map +1 -1
  65. package/node_modules/@buddi/core/dist/backup/load.js +37 -0
  66. package/node_modules/@buddi/core/dist/backup/load.js.map +1 -1
  67. package/node_modules/@buddi/core/dist/backup/restore.js +2 -2
  68. package/node_modules/@buddi/core/dist/backup/restore.js.map +1 -1
  69. package/node_modules/@buddi/core/dist/connection-config.d.ts +96 -0
  70. package/node_modules/@buddi/core/dist/connection-config.d.ts.map +1 -0
  71. package/node_modules/@buddi/core/dist/connection-config.js +308 -0
  72. package/node_modules/@buddi/core/dist/connection-config.js.map +1 -0
  73. package/node_modules/@buddi/core/dist/failures/owner-message.d.ts.map +1 -1
  74. package/node_modules/@buddi/core/dist/failures/owner-message.js +37 -10
  75. package/node_modules/@buddi/core/dist/failures/owner-message.js.map +1 -1
  76. package/node_modules/@buddi/core/dist/notifications/agent.d.ts +54 -0
  77. package/node_modules/@buddi/core/dist/notifications/agent.d.ts.map +1 -0
  78. package/node_modules/@buddi/core/dist/notifications/agent.js +134 -0
  79. package/node_modules/@buddi/core/dist/notifications/agent.js.map +1 -0
  80. package/node_modules/@buddi/core/dist/notifications/index.d.ts +1 -0
  81. package/node_modules/@buddi/core/dist/notifications/index.d.ts.map +1 -1
  82. package/node_modules/@buddi/core/dist/notifications/index.js +1 -0
  83. package/node_modules/@buddi/core/dist/notifications/index.js.map +1 -1
  84. package/node_modules/@buddi/core/dist/notifications/notify.d.ts +4 -0
  85. package/node_modules/@buddi/core/dist/notifications/notify.d.ts.map +1 -1
  86. package/node_modules/@buddi/core/dist/notifications/notify.js +19 -7
  87. package/node_modules/@buddi/core/dist/notifications/notify.js.map +1 -1
  88. package/node_modules/@buddi/core/dist/notifications/store.d.ts +8 -1
  89. package/node_modules/@buddi/core/dist/notifications/store.d.ts.map +1 -1
  90. package/node_modules/@buddi/core/dist/notifications/store.js +55 -6
  91. package/node_modules/@buddi/core/dist/notifications/store.js.map +1 -1
  92. package/node_modules/@buddi/core/dist/notifications/types.d.ts +26 -2
  93. package/node_modules/@buddi/core/dist/notifications/types.d.ts.map +1 -1
  94. package/node_modules/@buddi/core/dist/notifications/types.js +1 -1
  95. package/node_modules/@buddi/core/dist/notifications/types.js.map +1 -1
  96. package/node_modules/@buddi/core/dist/onboarding/store.d.ts.map +1 -1
  97. package/node_modules/@buddi/core/dist/onboarding/store.js +17 -1
  98. package/node_modules/@buddi/core/dist/onboarding/store.js.map +1 -1
  99. package/node_modules/@buddi/core/dist/onboarding/types.d.ts +14 -0
  100. package/node_modules/@buddi/core/dist/onboarding/types.d.ts.map +1 -1
  101. package/node_modules/@buddi/core/dist/provider-accounts.d.ts +21 -1
  102. package/node_modules/@buddi/core/dist/provider-accounts.d.ts.map +1 -1
  103. package/node_modules/@buddi/core/dist/provider-accounts.js +31 -1
  104. package/node_modules/@buddi/core/dist/provider-accounts.js.map +1 -1
  105. package/node_modules/@buddi/core/dist/provider.d.ts +4 -3
  106. package/node_modules/@buddi/core/dist/provider.d.ts.map +1 -1
  107. package/node_modules/@buddi/core/dist/provider.js +7 -4
  108. package/node_modules/@buddi/core/dist/provider.js.map +1 -1
  109. package/node_modules/@buddi/core/dist/testing/accounts.d.ts +12 -0
  110. package/node_modules/@buddi/core/dist/testing/accounts.d.ts.map +1 -0
  111. package/node_modules/@buddi/core/dist/testing/accounts.js +7 -0
  112. package/node_modules/@buddi/core/dist/testing/accounts.js.map +1 -0
  113. package/node_modules/@buddi/core/dist/testing/index.d.ts +1 -0
  114. package/node_modules/@buddi/core/dist/testing/index.d.ts.map +1 -1
  115. package/node_modules/@buddi/core/dist/testing/index.js +1 -0
  116. package/node_modules/@buddi/core/dist/testing/index.js.map +1 -1
  117. package/node_modules/@buddi/core/dist/vault/resolve.d.ts.map +1 -1
  118. package/node_modules/@buddi/core/dist/vault/resolve.js +0 -3
  119. package/node_modules/@buddi/core/dist/vault/resolve.js.map +1 -1
  120. package/node_modules/@buddi/core/migrations/053_drop_legacy_anthropic_env.sql +31 -0
  121. package/node_modules/@buddi/core/migrations/054_agent_messages.sql +15 -0
  122. package/node_modules/@buddi/core/package.json +4 -0
  123. package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
  124. package/node_modules/@buddi/gateway/dist/agents/owner-tools.d.ts +34 -1
  125. package/node_modules/@buddi/gateway/dist/agents/owner-tools.d.ts.map +1 -1
  126. package/node_modules/@buddi/gateway/dist/agents/owner-tools.js +87 -4
  127. package/node_modules/@buddi/gateway/dist/agents/owner-tools.js.map +1 -1
  128. package/node_modules/@buddi/gateway/dist/agents-cli.js +1 -1
  129. package/node_modules/@buddi/gateway/dist/agents-cli.js.map +1 -1
  130. package/node_modules/@buddi/gateway/dist/bootstrap.d.ts +1 -3
  131. package/node_modules/@buddi/gateway/dist/bootstrap.d.ts.map +1 -1
  132. package/node_modules/@buddi/gateway/dist/bootstrap.js +16 -11
  133. package/node_modules/@buddi/gateway/dist/bootstrap.js.map +1 -1
  134. package/node_modules/@buddi/gateway/dist/cli.js +1 -1
  135. package/node_modules/@buddi/gateway/dist/mlxh.d.ts +44 -0
  136. package/node_modules/@buddi/gateway/dist/mlxh.d.ts.map +1 -0
  137. package/node_modules/@buddi/gateway/dist/mlxh.js +98 -0
  138. package/node_modules/@buddi/gateway/dist/mlxh.js.map +1 -0
  139. package/node_modules/@buddi/gateway/dist/owner-secrets.d.ts +98 -9
  140. package/node_modules/@buddi/gateway/dist/owner-secrets.d.ts.map +1 -1
  141. package/node_modules/@buddi/gateway/dist/owner-secrets.js +237 -15
  142. package/node_modules/@buddi/gateway/dist/owner-secrets.js.map +1 -1
  143. package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts +4 -0
  144. package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts.map +1 -1
  145. package/node_modules/@buddi/gateway/dist/plugins/stage.js +3 -0
  146. package/node_modules/@buddi/gateway/dist/plugins/stage.js.map +1 -1
  147. package/node_modules/@buddi/gateway/dist/plugins/update.d.ts +8 -0
  148. package/node_modules/@buddi/gateway/dist/plugins/update.d.ts.map +1 -1
  149. package/node_modules/@buddi/gateway/dist/plugins/update.js +8 -2
  150. package/node_modules/@buddi/gateway/dist/plugins/update.js.map +1 -1
  151. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts +6 -13
  152. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
  153. package/node_modules/@buddi/gateway/dist/provider-accounts.js +76 -16
  154. package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
  155. package/node_modules/@buddi/gateway/dist/providers.d.ts +3 -3
  156. package/node_modules/@buddi/gateway/dist/providers.d.ts.map +1 -1
  157. package/node_modules/@buddi/gateway/dist/providers.js +7 -7
  158. package/node_modules/@buddi/gateway/dist/providers.js.map +1 -1
  159. package/node_modules/@buddi/gateway/dist/serve.d.ts.map +1 -1
  160. package/node_modules/@buddi/gateway/dist/serve.js +26 -8
  161. package/node_modules/@buddi/gateway/dist/serve.js.map +1 -1
  162. package/node_modules/@buddi/gateway/dist/surfaces/context-budget.d.ts +1 -1
  163. package/node_modules/@buddi/gateway/dist/surfaces/context-budget.d.ts.map +1 -1
  164. package/node_modules/@buddi/gateway/dist/surfaces/context-budget.js +46 -3
  165. package/node_modules/@buddi/gateway/dist/surfaces/context-budget.js.map +1 -1
  166. package/node_modules/@buddi/gateway/dist/surfaces/pending-question.d.ts.map +1 -1
  167. package/node_modules/@buddi/gateway/dist/surfaces/pending-question.js +2 -1
  168. package/node_modules/@buddi/gateway/dist/surfaces/pending-question.js.map +1 -1
  169. package/node_modules/@buddi/gateway/dist/system-context.d.ts +2 -0
  170. package/node_modules/@buddi/gateway/dist/system-context.d.ts.map +1 -1
  171. package/node_modules/@buddi/gateway/dist/system-context.js +5 -1
  172. package/node_modules/@buddi/gateway/dist/system-context.js.map +1 -1
  173. package/node_modules/@buddi/gateway/dist/telegram/channel.d.ts +7 -0
  174. package/node_modules/@buddi/gateway/dist/telegram/channel.d.ts.map +1 -1
  175. package/node_modules/@buddi/gateway/dist/telegram/channel.js +14 -2
  176. package/node_modules/@buddi/gateway/dist/telegram/channel.js.map +1 -1
  177. package/node_modules/@buddi/gateway/dist/web/agents.d.ts.map +1 -1
  178. package/node_modules/@buddi/gateway/dist/web/agents.js +5 -1
  179. package/node_modules/@buddi/gateway/dist/web/agents.js.map +1 -1
  180. package/node_modules/@buddi/gateway/dist/web/connections.d.ts +18 -5
  181. package/node_modules/@buddi/gateway/dist/web/connections.d.ts.map +1 -1
  182. package/node_modules/@buddi/gateway/dist/web/connections.js +118 -8
  183. package/node_modules/@buddi/gateway/dist/web/connections.js.map +1 -1
  184. package/node_modules/@buddi/gateway/dist/web/extension.d.ts +6 -0
  185. package/node_modules/@buddi/gateway/dist/web/extension.d.ts.map +1 -1
  186. package/node_modules/@buddi/gateway/dist/web/extension.js +5 -1
  187. package/node_modules/@buddi/gateway/dist/web/extension.js.map +1 -1
  188. package/node_modules/@buddi/gateway/dist/web/market.d.ts +18 -0
  189. package/node_modules/@buddi/gateway/dist/web/market.d.ts.map +1 -1
  190. package/node_modules/@buddi/gateway/dist/web/market.js +20 -14
  191. package/node_modules/@buddi/gateway/dist/web/market.js.map +1 -1
  192. package/node_modules/@buddi/gateway/dist/web/notifications.d.ts +6 -0
  193. package/node_modules/@buddi/gateway/dist/web/notifications.d.ts.map +1 -1
  194. package/node_modules/@buddi/gateway/dist/web/notifications.js +14 -1
  195. package/node_modules/@buddi/gateway/dist/web/notifications.js.map +1 -1
  196. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +21 -7
  197. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
  198. package/node_modules/@buddi/gateway/dist/web/onboarding.js +64 -11
  199. package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
  200. package/node_modules/@buddi/gateway/dist/web/plugins.d.ts +5 -0
  201. package/node_modules/@buddi/gateway/dist/web/plugins.d.ts.map +1 -1
  202. package/node_modules/@buddi/gateway/dist/web/plugins.js +11 -1
  203. package/node_modules/@buddi/gateway/dist/web/plugins.js.map +1 -1
  204. package/node_modules/@buddi/gateway/dist/web/recovery.d.ts +10 -0
  205. package/node_modules/@buddi/gateway/dist/web/recovery.d.ts.map +1 -1
  206. package/node_modules/@buddi/gateway/dist/web/recovery.js +114 -34
  207. package/node_modules/@buddi/gateway/dist/web/recovery.js.map +1 -1
  208. package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
  209. package/node_modules/@buddi/gateway/dist/web/server.js +84 -8
  210. package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
  211. package/node_modules/@buddi/gateway/dist/web/sessions.d.ts +8 -0
  212. package/node_modules/@buddi/gateway/dist/web/sessions.d.ts.map +1 -1
  213. package/node_modules/@buddi/gateway/dist/web/sessions.js +24 -1
  214. package/node_modules/@buddi/gateway/dist/web/sessions.js.map +1 -1
  215. package/node_modules/@buddi/gateway/dist/web/static.d.ts +8 -0
  216. package/node_modules/@buddi/gateway/dist/web/static.d.ts.map +1 -1
  217. package/node_modules/@buddi/gateway/dist/web/static.js +21 -1
  218. package/node_modules/@buddi/gateway/dist/web/static.js.map +1 -1
  219. package/node_modules/@buddi/gateway/dist/web/take-on.d.ts +91 -0
  220. package/node_modules/@buddi/gateway/dist/web/take-on.d.ts.map +1 -0
  221. package/node_modules/@buddi/gateway/dist/web/take-on.js +287 -0
  222. package/node_modules/@buddi/gateway/dist/web/take-on.js.map +1 -0
  223. package/node_modules/@buddi/gateway/src/agents/starter/keeper/agent.md +2 -2
  224. package/node_modules/@buddi/gateway/src/agents/starter/planner/agent.md +1 -1
  225. package/node_modules/@buddi/gateway/src/agents/starter/scout/agent.md +1 -1
  226. package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
  227. package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
  228. package/node_modules/@buddi/runtime/dist/anthropic.d.ts +7 -0
  229. package/node_modules/@buddi/runtime/dist/anthropic.d.ts.map +1 -1
  230. package/node_modules/@buddi/runtime/dist/anthropic.js +29 -3
  231. package/node_modules/@buddi/runtime/dist/anthropic.js.map +1 -1
  232. package/node_modules/@buddi/runtime/dist/delegate.js +1 -1
  233. package/node_modules/@buddi/runtime/dist/delegate.js.map +1 -1
  234. package/node_modules/@buddi/runtime/dist/provider-models.d.ts +2 -0
  235. package/node_modules/@buddi/runtime/dist/provider-models.d.ts.map +1 -1
  236. package/node_modules/@buddi/runtime/dist/provider-models.js +22 -0
  237. package/node_modules/@buddi/runtime/dist/provider-models.js.map +1 -1
  238. package/node_modules/@buddi/runtime/dist/search.js +2 -2
  239. package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
  240. package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
  241. package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
  242. package/node_modules/@buddi/tool-email/dist/config.d.ts +13 -9
  243. package/node_modules/@buddi/tool-email/dist/config.d.ts.map +1 -1
  244. package/node_modules/@buddi/tool-email/dist/config.js +33 -40
  245. package/node_modules/@buddi/tool-email/dist/config.js.map +1 -1
  246. package/node_modules/@buddi/tool-email/dist/index.d.ts +1 -1
  247. package/node_modules/@buddi/tool-email/dist/index.d.ts.map +1 -1
  248. package/node_modules/@buddi/tool-email/dist/index.js +1 -1
  249. package/node_modules/@buddi/tool-email/dist/index.js.map +1 -1
  250. package/node_modules/@buddi/tool-email/dist/pages/accounts.d.ts +1 -2
  251. package/node_modules/@buddi/tool-email/dist/pages/accounts.d.ts.map +1 -1
  252. package/node_modules/@buddi/tool-email/dist/pages/accounts.js +42 -18
  253. package/node_modules/@buddi/tool-email/dist/pages/accounts.js.map +1 -1
  254. package/node_modules/@buddi/tool-email/dist/pages/queries.d.ts.map +1 -1
  255. package/node_modules/@buddi/tool-email/dist/pages/queries.js +7 -5
  256. package/node_modules/@buddi/tool-email/dist/pages/queries.js.map +1 -1
  257. package/node_modules/@buddi/tool-email/dist/ports.d.ts +5 -1
  258. package/node_modules/@buddi/tool-email/dist/ports.d.ts.map +1 -1
  259. package/node_modules/@buddi/tool-email/dist/tools/shared.js +1 -1
  260. package/node_modules/@buddi/tool-email/dist/tools/shared.js.map +1 -1
  261. package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
  262. package/node_modules/@buddi/tool-mcp/dist/.tsbuildinfo +1 -1
  263. package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts +32 -2
  264. package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts.map +1 -1
  265. package/node_modules/@buddi/tool-mcp/dist/catalog.js +41 -7
  266. package/node_modules/@buddi/tool-mcp/dist/catalog.js.map +1 -1
  267. package/node_modules/@buddi/tool-mcp/dist/device.d.ts +53 -0
  268. package/node_modules/@buddi/tool-mcp/dist/device.d.ts.map +1 -0
  269. package/node_modules/@buddi/tool-mcp/dist/device.js +100 -0
  270. package/node_modules/@buddi/tool-mcp/dist/device.js.map +1 -0
  271. package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts +10 -1
  272. package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts.map +1 -1
  273. package/node_modules/@buddi/tool-mcp/dist/fetch.js +7 -1
  274. package/node_modules/@buddi/tool-mcp/dist/fetch.js.map +1 -1
  275. package/node_modules/@buddi/tool-mcp/dist/index.d.ts +5 -3
  276. package/node_modules/@buddi/tool-mcp/dist/index.d.ts.map +1 -1
  277. package/node_modules/@buddi/tool-mcp/dist/index.js +7 -4
  278. package/node_modules/@buddi/tool-mcp/dist/index.js.map +1 -1
  279. package/node_modules/@buddi/tool-mcp/dist/ports.d.ts +31 -0
  280. package/node_modules/@buddi/tool-mcp/dist/ports.d.ts.map +1 -1
  281. package/node_modules/@buddi/tool-mcp/dist/preview.d.ts +16 -0
  282. package/node_modules/@buddi/tool-mcp/dist/preview.d.ts.map +1 -0
  283. package/node_modules/@buddi/tool-mcp/dist/preview.js +52 -0
  284. package/node_modules/@buddi/tool-mcp/dist/preview.js.map +1 -0
  285. package/node_modules/@buddi/tool-mcp/dist/program.d.ts +73 -0
  286. package/node_modules/@buddi/tool-mcp/dist/program.d.ts.map +1 -0
  287. package/node_modules/@buddi/tool-mcp/dist/program.js +306 -0
  288. package/node_modules/@buddi/tool-mcp/dist/program.js.map +1 -0
  289. package/node_modules/@buddi/tool-mcp/dist/service.d.ts +131 -22
  290. package/node_modules/@buddi/tool-mcp/dist/service.d.ts.map +1 -1
  291. package/node_modules/@buddi/tool-mcp/dist/service.js +717 -29
  292. package/node_modules/@buddi/tool-mcp/dist/service.js.map +1 -1
  293. package/node_modules/@buddi/tool-mcp/dist/session.d.ts +13 -1
  294. package/node_modules/@buddi/tool-mcp/dist/session.d.ts.map +1 -1
  295. package/node_modules/@buddi/tool-mcp/dist/session.js +27 -4
  296. package/node_modules/@buddi/tool-mcp/dist/session.js.map +1 -1
  297. package/node_modules/@buddi/tool-mcp/dist/store.d.ts +39 -1
  298. package/node_modules/@buddi/tool-mcp/dist/store.d.ts.map +1 -1
  299. package/node_modules/@buddi/tool-mcp/dist/store.js +24 -0
  300. package/node_modules/@buddi/tool-mcp/dist/store.js.map +1 -1
  301. package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts +6 -0
  302. package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts.map +1 -1
  303. package/node_modules/@buddi/tool-mcp/dist/testing/fake.js +26 -0
  304. package/node_modules/@buddi/tool-mcp/dist/testing/fake.js.map +1 -1
  305. package/node_modules/@buddi/tool-mcp/migrations/003_token_auth.sql +14 -0
  306. package/node_modules/@buddi/tool-mcp/migrations/004_programs.sql +26 -0
  307. package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
  308. package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
  309. package/node_modules/@buddi/tool-web/dist/providers/index.d.ts +1 -2
  310. package/node_modules/@buddi/tool-web/dist/providers/index.d.ts.map +1 -1
  311. package/node_modules/@buddi/tool-web/dist/providers/index.js +1 -2
  312. package/node_modules/@buddi/tool-web/dist/providers/index.js.map +1 -1
  313. package/node_modules/hono/dist/cjs/jsx/utils.js +1 -1
  314. package/node_modules/hono/dist/cjs/middleware/combine/index.js +3 -1
  315. package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -2
  316. package/node_modules/hono/dist/jsx/utils.js +1 -1
  317. package/node_modules/hono/dist/middleware/combine/index.js +3 -1
  318. package/node_modules/hono/dist/middleware/etag/index.js +2 -2
  319. package/node_modules/hono/dist/middleware/language/language.js +1 -1
  320. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +2 -1
  321. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +2 -1
  322. package/node_modules/hono/dist/types/adapter/bun/websocket.d.ts +2 -1
  323. package/node_modules/hono/dist/types/adapter/cloudflare-pages/handler.d.ts +2 -1
  324. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +2 -1
  325. package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +2 -1
  326. package/node_modules/hono/dist/types/adapter/service-worker/handler.d.ts +2 -1
  327. package/node_modules/hono/dist/types/adapter/service-worker/index.d.ts +2 -1
  328. package/node_modules/hono/dist/types/adapter/service-worker/types.d.ts +2 -1
  329. package/node_modules/hono/dist/types/client/types.d.ts +2 -1
  330. package/node_modules/hono/dist/types/context.d.ts +2 -1
  331. package/node_modules/hono/dist/types/helper/cookie/index.d.ts +2 -1
  332. package/node_modules/hono/dist/types/helper/css/common.d.ts +2 -1
  333. package/node_modules/hono/dist/types/helper/css/index.d.ts +2 -1
  334. package/node_modules/hono/dist/types/helper/dev/index.d.ts +2 -1
  335. package/node_modules/hono/dist/types/helper/factory/index.d.ts +2 -1
  336. package/node_modules/hono/dist/types/helper/proxy/index.d.ts +2 -1
  337. package/node_modules/hono/dist/types/helper/ssg/middleware.d.ts +2 -1
  338. package/node_modules/hono/dist/types/helper/ssg/utils.d.ts +2 -1
  339. package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
  340. package/node_modules/hono/dist/types/hono-base.d.ts +2 -1
  341. package/node_modules/hono/dist/types/http-exception.d.ts +2 -1
  342. package/node_modules/hono/dist/types/jsx/base.d.ts +4 -3
  343. package/node_modules/hono/dist/types/jsx/context.d.ts +2 -1
  344. package/node_modules/hono/dist/types/jsx/dom/client.d.ts +2 -1
  345. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -1
  346. package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +2 -1
  347. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +2 -1
  348. package/node_modules/hono/dist/types/jsx/dom/render.d.ts +2 -1
  349. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +2 -1
  350. package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +2 -1
  351. package/node_modules/hono/dist/types/jsx/index.d.ts +2 -1
  352. package/node_modules/hono/dist/types/jsx/types.d.ts +2 -1
  353. package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +2 -1
  354. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
  355. package/node_modules/hono/dist/types/middleware/body-limit/index.d.ts +2 -1
  356. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +2 -1
  357. package/node_modules/hono/dist/types/middleware/compress/index.d.ts +2 -1
  358. package/node_modules/hono/dist/types/middleware/cors/index.d.ts +2 -1
  359. package/node_modules/hono/dist/types/middleware/csrf/index.d.ts +2 -1
  360. package/node_modules/hono/dist/types/middleware/etag/index.d.ts +2 -1
  361. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +2 -1
  362. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +2 -1
  363. package/node_modules/hono/dist/types/middleware/jwt/index.d.ts +2 -1
  364. package/node_modules/hono/dist/types/middleware/language/index.d.ts +2 -1
  365. package/node_modules/hono/dist/types/middleware/logger/index.d.ts +2 -1
  366. package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +2 -1
  367. package/node_modules/hono/dist/types/middleware/method-override/index.d.ts +2 -1
  368. package/node_modules/hono/dist/types/middleware/powered-by/index.d.ts +2 -1
  369. package/node_modules/hono/dist/types/middleware/pretty-json/index.d.ts +2 -1
  370. package/node_modules/hono/dist/types/middleware/request-id/index.d.ts +2 -1
  371. package/node_modules/hono/dist/types/middleware/secure-headers/index.d.ts +2 -1
  372. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +2 -1
  373. package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +2 -1
  374. package/node_modules/hono/dist/types/middleware/timing/index.d.ts +2 -1
  375. package/node_modules/hono/dist/types/middleware/timing/timing.d.ts +2 -1
  376. package/node_modules/hono/dist/types/middleware/trailing-slash/index.d.ts +2 -1
  377. package/node_modules/hono/dist/types/request.d.ts +2 -1
  378. package/node_modules/hono/dist/types/router/reg-exp-router/prepared-router.d.ts +2 -1
  379. package/node_modules/hono/dist/types/types.d.ts +2 -1
  380. package/node_modules/hono/dist/types/utils/body.d.ts +2 -1
  381. package/node_modules/hono/dist/types/utils/buffer.d.ts +2 -1
  382. package/node_modules/hono/dist/types/utils/cookie.d.ts +2 -1
  383. package/node_modules/hono/dist/types/utils/crypto.d.ts +2 -1
  384. package/node_modules/hono/dist/types/utils/filepath.d.ts +2 -1
  385. package/node_modules/hono/dist/types/utils/html.d.ts +2 -1
  386. package/node_modules/hono/dist/types/utils/mime.d.ts +2 -1
  387. package/node_modules/hono/dist/types/utils/types.d.ts +2 -1
  388. package/node_modules/hono/dist/types/utils/url.d.ts +2 -1
  389. package/node_modules/hono/dist/types/validator/utils.d.ts +2 -1
  390. package/node_modules/hono/dist/types/validator/validator.d.ts +2 -1
  391. package/node_modules/hono/package.json +2 -2
  392. package/node_modules/pg/lib/client.js +18 -0
  393. package/node_modules/pg/lib/connection.js +8 -1
  394. package/node_modules/pg/lib/crypto/cert-signatures.js +1 -1
  395. package/node_modules/pg/lib/native/client.js +11 -3
  396. package/node_modules/pg/lib/native/query.js +3 -1
  397. package/node_modules/pg/lib/query.js +5 -1
  398. package/node_modules/pg/lib/utils.js +19 -1
  399. package/node_modules/pg/package.json +5 -5
  400. package/node_modules/pg-connection-string/index.js +1 -1
  401. package/node_modules/pg-connection-string/package.json +2 -3
  402. package/node_modules/pg-protocol/dist/buffer-writer.d.ts +5 -1
  403. package/node_modules/pg-protocol/dist/buffer-writer.js +10 -1
  404. package/node_modules/pg-protocol/dist/buffer-writer.js.map +1 -1
  405. package/node_modules/pg-protocol/dist/serializer.js +20 -18
  406. package/node_modules/pg-protocol/dist/serializer.js.map +1 -1
  407. package/node_modules/pg-protocol/package.json +2 -2
  408. package/node_modules/pg-protocol/src/buffer-writer.ts +12 -2
  409. package/node_modules/pg-protocol/src/serializer.ts +26 -20
  410. package/package.json +2 -2
  411. package/packages/cli/dist/.tsbuildinfo +1 -1
  412. package/packages/cli/dist/args.d.ts +59 -0
  413. package/packages/cli/dist/args.d.ts.map +1 -1
  414. package/packages/cli/dist/args.js +141 -0
  415. package/packages/cli/dist/args.js.map +1 -1
  416. package/packages/cli/dist/commands.d.ts +2 -0
  417. package/packages/cli/dist/commands.d.ts.map +1 -1
  418. package/packages/cli/dist/commands.js +71 -1
  419. package/packages/cli/dist/commands.js.map +1 -1
  420. package/packages/cli/dist/connections-cmd.d.ts +93 -0
  421. package/packages/cli/dist/connections-cmd.d.ts.map +1 -0
  422. package/packages/cli/dist/connections-cmd.js +657 -0
  423. package/packages/cli/dist/connections-cmd.js.map +1 -0
  424. package/packages/cli/dist/doctor-probes.d.ts.map +1 -1
  425. package/packages/cli/dist/doctor-probes.js +82 -17
  426. package/packages/cli/dist/doctor-probes.js.map +1 -1
  427. package/packages/cli/dist/doctor.d.ts +9 -9
  428. package/packages/cli/dist/doctor.d.ts.map +1 -1
  429. package/packages/cli/dist/doctor.js +20 -17
  430. package/packages/cli/dist/doctor.js.map +1 -1
  431. package/packages/cli/dist/init-plan.d.ts +1 -2
  432. package/packages/cli/dist/init-plan.d.ts.map +1 -1
  433. package/packages/cli/dist/init-plan.js +2 -6
  434. package/packages/cli/dist/init-plan.js.map +1 -1
  435. package/packages/cli/dist/init.d.ts.map +1 -1
  436. package/packages/cli/dist/init.js +5 -29
  437. package/packages/cli/dist/init.js.map +1 -1
  438. package/packages/cli/dist/main.d.ts.map +1 -1
  439. package/packages/cli/dist/main.js +10 -1
  440. package/packages/cli/dist/main.js.map +1 -1
  441. package/packages/cli/dist/mcp/gateway-client.d.ts +5 -0
  442. package/packages/cli/dist/mcp/gateway-client.d.ts.map +1 -1
  443. package/packages/cli/dist/mcp/gateway-client.js +15 -4
  444. package/packages/cli/dist/mcp/gateway-client.js.map +1 -1
  445. package/packages/cli/dist/service/index.d.ts +4 -2
  446. package/packages/cli/dist/service/index.d.ts.map +1 -1
  447. package/packages/cli/dist/service/index.js +5 -7
  448. package/packages/cli/dist/service/index.js.map +1 -1
  449. package/packages/core/dist/.tsbuildinfo +1 -1
  450. package/packages/core/dist/agents/catalog.d.ts.map +1 -1
  451. package/packages/core/dist/agents/catalog.js +11 -2
  452. package/packages/core/dist/agents/catalog.js.map +1 -1
  453. package/packages/core/dist/agents/provider-from-env.d.ts +7 -6
  454. package/packages/core/dist/agents/provider-from-env.d.ts.map +1 -1
  455. package/packages/core/dist/agents/provider-from-env.js +9 -12
  456. package/packages/core/dist/agents/provider-from-env.js.map +1 -1
  457. package/packages/core/dist/agents/skills.d.ts +4 -4
  458. package/packages/core/dist/backup/load.d.ts.map +1 -1
  459. package/packages/core/dist/backup/load.js +37 -0
  460. package/packages/core/dist/backup/load.js.map +1 -1
  461. package/packages/core/dist/backup/restore.js +2 -2
  462. package/packages/core/dist/backup/restore.js.map +1 -1
  463. package/packages/core/dist/connection-config.d.ts +96 -0
  464. package/packages/core/dist/connection-config.d.ts.map +1 -0
  465. package/packages/core/dist/connection-config.js +308 -0
  466. package/packages/core/dist/connection-config.js.map +1 -0
  467. package/packages/core/dist/failures/owner-message.d.ts.map +1 -1
  468. package/packages/core/dist/failures/owner-message.js +37 -10
  469. package/packages/core/dist/failures/owner-message.js.map +1 -1
  470. package/packages/core/dist/notifications/agent.d.ts +54 -0
  471. package/packages/core/dist/notifications/agent.d.ts.map +1 -0
  472. package/packages/core/dist/notifications/agent.js +134 -0
  473. package/packages/core/dist/notifications/agent.js.map +1 -0
  474. package/packages/core/dist/notifications/index.d.ts +1 -0
  475. package/packages/core/dist/notifications/index.d.ts.map +1 -1
  476. package/packages/core/dist/notifications/index.js +1 -0
  477. package/packages/core/dist/notifications/index.js.map +1 -1
  478. package/packages/core/dist/notifications/notify.d.ts +4 -0
  479. package/packages/core/dist/notifications/notify.d.ts.map +1 -1
  480. package/packages/core/dist/notifications/notify.js +19 -7
  481. package/packages/core/dist/notifications/notify.js.map +1 -1
  482. package/packages/core/dist/notifications/store.d.ts +8 -1
  483. package/packages/core/dist/notifications/store.d.ts.map +1 -1
  484. package/packages/core/dist/notifications/store.js +55 -6
  485. package/packages/core/dist/notifications/store.js.map +1 -1
  486. package/packages/core/dist/notifications/types.d.ts +26 -2
  487. package/packages/core/dist/notifications/types.d.ts.map +1 -1
  488. package/packages/core/dist/notifications/types.js +1 -1
  489. package/packages/core/dist/notifications/types.js.map +1 -1
  490. package/packages/core/dist/onboarding/store.d.ts.map +1 -1
  491. package/packages/core/dist/onboarding/store.js +17 -1
  492. package/packages/core/dist/onboarding/store.js.map +1 -1
  493. package/packages/core/dist/onboarding/types.d.ts +14 -0
  494. package/packages/core/dist/onboarding/types.d.ts.map +1 -1
  495. package/packages/core/dist/provider-accounts.d.ts +21 -1
  496. package/packages/core/dist/provider-accounts.d.ts.map +1 -1
  497. package/packages/core/dist/provider-accounts.js +31 -1
  498. package/packages/core/dist/provider-accounts.js.map +1 -1
  499. package/packages/core/dist/provider.d.ts +4 -3
  500. package/packages/core/dist/provider.d.ts.map +1 -1
  501. package/packages/core/dist/provider.js +7 -4
  502. package/packages/core/dist/provider.js.map +1 -1
  503. package/packages/core/dist/testing/accounts.d.ts +12 -0
  504. package/packages/core/dist/testing/accounts.d.ts.map +1 -0
  505. package/packages/core/dist/testing/accounts.js +7 -0
  506. package/packages/core/dist/testing/accounts.js.map +1 -0
  507. package/packages/core/dist/testing/index.d.ts +1 -0
  508. package/packages/core/dist/testing/index.d.ts.map +1 -1
  509. package/packages/core/dist/testing/index.js +1 -0
  510. package/packages/core/dist/testing/index.js.map +1 -1
  511. package/packages/core/dist/vault/resolve.d.ts.map +1 -1
  512. package/packages/core/dist/vault/resolve.js +0 -3
  513. package/packages/core/dist/vault/resolve.js.map +1 -1
  514. package/packages/core/migrations/053_drop_legacy_anthropic_env.sql +31 -0
  515. package/packages/core/migrations/054_agent_messages.sql +15 -0
  516. package/packages/core/package.json +4 -0
  517. package/packages/gateway/dist/.tsbuildinfo +1 -1
  518. package/packages/gateway/dist/agents/owner-tools.d.ts +34 -1
  519. package/packages/gateway/dist/agents/owner-tools.d.ts.map +1 -1
  520. package/packages/gateway/dist/agents/owner-tools.js +87 -4
  521. package/packages/gateway/dist/agents/owner-tools.js.map +1 -1
  522. package/packages/gateway/dist/agents-cli.js +1 -1
  523. package/packages/gateway/dist/agents-cli.js.map +1 -1
  524. package/packages/gateway/dist/bootstrap.d.ts +1 -3
  525. package/packages/gateway/dist/bootstrap.d.ts.map +1 -1
  526. package/packages/gateway/dist/bootstrap.js +16 -11
  527. package/packages/gateway/dist/bootstrap.js.map +1 -1
  528. package/packages/gateway/dist/cli.js +1 -1
  529. package/packages/gateway/dist/mlxh.d.ts +44 -0
  530. package/packages/gateway/dist/mlxh.d.ts.map +1 -0
  531. package/packages/gateway/dist/mlxh.js +98 -0
  532. package/packages/gateway/dist/mlxh.js.map +1 -0
  533. package/packages/gateway/dist/owner-secrets.d.ts +98 -9
  534. package/packages/gateway/dist/owner-secrets.d.ts.map +1 -1
  535. package/packages/gateway/dist/owner-secrets.js +237 -15
  536. package/packages/gateway/dist/owner-secrets.js.map +1 -1
  537. package/packages/gateway/dist/plugins/stage.d.ts +4 -0
  538. package/packages/gateway/dist/plugins/stage.d.ts.map +1 -1
  539. package/packages/gateway/dist/plugins/stage.js +3 -0
  540. package/packages/gateway/dist/plugins/stage.js.map +1 -1
  541. package/packages/gateway/dist/plugins/update.d.ts +8 -0
  542. package/packages/gateway/dist/plugins/update.d.ts.map +1 -1
  543. package/packages/gateway/dist/plugins/update.js +8 -2
  544. package/packages/gateway/dist/plugins/update.js.map +1 -1
  545. package/packages/gateway/dist/provider-accounts.d.ts +6 -13
  546. package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
  547. package/packages/gateway/dist/provider-accounts.js +76 -16
  548. package/packages/gateway/dist/provider-accounts.js.map +1 -1
  549. package/packages/gateway/dist/providers.d.ts +3 -3
  550. package/packages/gateway/dist/providers.d.ts.map +1 -1
  551. package/packages/gateway/dist/providers.js +7 -7
  552. package/packages/gateway/dist/providers.js.map +1 -1
  553. package/packages/gateway/dist/serve.d.ts.map +1 -1
  554. package/packages/gateway/dist/serve.js +26 -8
  555. package/packages/gateway/dist/serve.js.map +1 -1
  556. package/packages/gateway/dist/surfaces/context-budget.d.ts +1 -1
  557. package/packages/gateway/dist/surfaces/context-budget.d.ts.map +1 -1
  558. package/packages/gateway/dist/surfaces/context-budget.js +46 -3
  559. package/packages/gateway/dist/surfaces/context-budget.js.map +1 -1
  560. package/packages/gateway/dist/surfaces/pending-question.d.ts.map +1 -1
  561. package/packages/gateway/dist/surfaces/pending-question.js +2 -1
  562. package/packages/gateway/dist/surfaces/pending-question.js.map +1 -1
  563. package/packages/gateway/dist/system-context.d.ts +2 -0
  564. package/packages/gateway/dist/system-context.d.ts.map +1 -1
  565. package/packages/gateway/dist/system-context.js +5 -1
  566. package/packages/gateway/dist/system-context.js.map +1 -1
  567. package/packages/gateway/dist/telegram/channel.d.ts +7 -0
  568. package/packages/gateway/dist/telegram/channel.d.ts.map +1 -1
  569. package/packages/gateway/dist/telegram/channel.js +14 -2
  570. package/packages/gateway/dist/telegram/channel.js.map +1 -1
  571. package/packages/gateway/dist/web/agents.d.ts.map +1 -1
  572. package/packages/gateway/dist/web/agents.js +5 -1
  573. package/packages/gateway/dist/web/agents.js.map +1 -1
  574. package/packages/gateway/dist/web/connections.d.ts +18 -5
  575. package/packages/gateway/dist/web/connections.d.ts.map +1 -1
  576. package/packages/gateway/dist/web/connections.js +118 -8
  577. package/packages/gateway/dist/web/connections.js.map +1 -1
  578. package/packages/gateway/dist/web/extension.d.ts +6 -0
  579. package/packages/gateway/dist/web/extension.d.ts.map +1 -1
  580. package/packages/gateway/dist/web/extension.js +5 -1
  581. package/packages/gateway/dist/web/extension.js.map +1 -1
  582. package/packages/gateway/dist/web/market.d.ts +18 -0
  583. package/packages/gateway/dist/web/market.d.ts.map +1 -1
  584. package/packages/gateway/dist/web/market.js +20 -14
  585. package/packages/gateway/dist/web/market.js.map +1 -1
  586. package/packages/gateway/dist/web/notifications.d.ts +6 -0
  587. package/packages/gateway/dist/web/notifications.d.ts.map +1 -1
  588. package/packages/gateway/dist/web/notifications.js +14 -1
  589. package/packages/gateway/dist/web/notifications.js.map +1 -1
  590. package/packages/gateway/dist/web/onboarding.d.ts +21 -7
  591. package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
  592. package/packages/gateway/dist/web/onboarding.js +64 -11
  593. package/packages/gateway/dist/web/onboarding.js.map +1 -1
  594. package/packages/gateway/dist/web/plugins.d.ts +5 -0
  595. package/packages/gateway/dist/web/plugins.d.ts.map +1 -1
  596. package/packages/gateway/dist/web/plugins.js +11 -1
  597. package/packages/gateway/dist/web/plugins.js.map +1 -1
  598. package/packages/gateway/dist/web/recovery.d.ts +10 -0
  599. package/packages/gateway/dist/web/recovery.d.ts.map +1 -1
  600. package/packages/gateway/dist/web/recovery.js +114 -34
  601. package/packages/gateway/dist/web/recovery.js.map +1 -1
  602. package/packages/gateway/dist/web/server.d.ts.map +1 -1
  603. package/packages/gateway/dist/web/server.js +84 -8
  604. package/packages/gateway/dist/web/server.js.map +1 -1
  605. package/packages/gateway/dist/web/sessions.d.ts +8 -0
  606. package/packages/gateway/dist/web/sessions.d.ts.map +1 -1
  607. package/packages/gateway/dist/web/sessions.js +24 -1
  608. package/packages/gateway/dist/web/sessions.js.map +1 -1
  609. package/packages/gateway/dist/web/static.d.ts +8 -0
  610. package/packages/gateway/dist/web/static.d.ts.map +1 -1
  611. package/packages/gateway/dist/web/static.js +21 -1
  612. package/packages/gateway/dist/web/static.js.map +1 -1
  613. package/packages/gateway/dist/web/take-on.d.ts +91 -0
  614. package/packages/gateway/dist/web/take-on.d.ts.map +1 -0
  615. package/packages/gateway/dist/web/take-on.js +287 -0
  616. package/packages/gateway/dist/web/take-on.js.map +1 -0
  617. package/packages/gateway/src/agents/starter/keeper/agent.md +2 -2
  618. package/packages/gateway/src/agents/starter/planner/agent.md +1 -1
  619. package/packages/gateway/src/agents/starter/scout/agent.md +1 -1
  620. package/packages/install/dist/.tsbuildinfo +1 -1
  621. package/packages/runtime/dist/.tsbuildinfo +1 -1
  622. package/packages/runtime/dist/anthropic.d.ts +7 -0
  623. package/packages/runtime/dist/anthropic.d.ts.map +1 -1
  624. package/packages/runtime/dist/anthropic.js +29 -3
  625. package/packages/runtime/dist/anthropic.js.map +1 -1
  626. package/packages/runtime/dist/delegate.js +1 -1
  627. package/packages/runtime/dist/delegate.js.map +1 -1
  628. package/packages/runtime/dist/provider-models.d.ts +2 -0
  629. package/packages/runtime/dist/provider-models.d.ts.map +1 -1
  630. package/packages/runtime/dist/provider-models.js +22 -0
  631. package/packages/runtime/dist/provider-models.js.map +1 -1
  632. package/packages/runtime/dist/search.js +2 -2
  633. package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
  634. package/packages/tools/browser/dist/.tsbuildinfo +1 -1
  635. package/packages/tools/email/dist/.tsbuildinfo +1 -1
  636. package/packages/tools/email/dist/config.d.ts +13 -9
  637. package/packages/tools/email/dist/config.d.ts.map +1 -1
  638. package/packages/tools/email/dist/config.js +33 -40
  639. package/packages/tools/email/dist/config.js.map +1 -1
  640. package/packages/tools/email/dist/index.d.ts +1 -1
  641. package/packages/tools/email/dist/index.d.ts.map +1 -1
  642. package/packages/tools/email/dist/index.js +1 -1
  643. package/packages/tools/email/dist/index.js.map +1 -1
  644. package/packages/tools/email/dist/pages/accounts.d.ts +1 -2
  645. package/packages/tools/email/dist/pages/accounts.d.ts.map +1 -1
  646. package/packages/tools/email/dist/pages/accounts.js +42 -18
  647. package/packages/tools/email/dist/pages/accounts.js.map +1 -1
  648. package/packages/tools/email/dist/pages/queries.d.ts.map +1 -1
  649. package/packages/tools/email/dist/pages/queries.js +7 -5
  650. package/packages/tools/email/dist/pages/queries.js.map +1 -1
  651. package/packages/tools/email/dist/ports.d.ts +5 -1
  652. package/packages/tools/email/dist/ports.d.ts.map +1 -1
  653. package/packages/tools/email/dist/tools/shared.js +1 -1
  654. package/packages/tools/email/dist/tools/shared.js.map +1 -1
  655. package/packages/tools/host/dist/.tsbuildinfo +1 -1
  656. package/packages/tools/mcp/dist/.tsbuildinfo +1 -1
  657. package/packages/tools/mcp/dist/catalog.d.ts +32 -2
  658. package/packages/tools/mcp/dist/catalog.d.ts.map +1 -1
  659. package/packages/tools/mcp/dist/catalog.js +41 -7
  660. package/packages/tools/mcp/dist/catalog.js.map +1 -1
  661. package/packages/tools/mcp/dist/device.d.ts +53 -0
  662. package/packages/tools/mcp/dist/device.d.ts.map +1 -0
  663. package/packages/tools/mcp/dist/device.js +100 -0
  664. package/packages/tools/mcp/dist/device.js.map +1 -0
  665. package/packages/tools/mcp/dist/fetch.d.ts +10 -1
  666. package/packages/tools/mcp/dist/fetch.d.ts.map +1 -1
  667. package/packages/tools/mcp/dist/fetch.js +7 -1
  668. package/packages/tools/mcp/dist/fetch.js.map +1 -1
  669. package/packages/tools/mcp/dist/index.d.ts +5 -3
  670. package/packages/tools/mcp/dist/index.d.ts.map +1 -1
  671. package/packages/tools/mcp/dist/index.js +7 -4
  672. package/packages/tools/mcp/dist/index.js.map +1 -1
  673. package/packages/tools/mcp/dist/ports.d.ts +31 -0
  674. package/packages/tools/mcp/dist/ports.d.ts.map +1 -1
  675. package/packages/tools/mcp/dist/preview.d.ts +16 -0
  676. package/packages/tools/mcp/dist/preview.d.ts.map +1 -0
  677. package/packages/tools/mcp/dist/preview.js +52 -0
  678. package/packages/tools/mcp/dist/preview.js.map +1 -0
  679. package/packages/tools/mcp/dist/program.d.ts +73 -0
  680. package/packages/tools/mcp/dist/program.d.ts.map +1 -0
  681. package/packages/tools/mcp/dist/program.js +306 -0
  682. package/packages/tools/mcp/dist/program.js.map +1 -0
  683. package/packages/tools/mcp/dist/service.d.ts +131 -22
  684. package/packages/tools/mcp/dist/service.d.ts.map +1 -1
  685. package/packages/tools/mcp/dist/service.js +717 -29
  686. package/packages/tools/mcp/dist/service.js.map +1 -1
  687. package/packages/tools/mcp/dist/session.d.ts +13 -1
  688. package/packages/tools/mcp/dist/session.d.ts.map +1 -1
  689. package/packages/tools/mcp/dist/session.js +27 -4
  690. package/packages/tools/mcp/dist/session.js.map +1 -1
  691. package/packages/tools/mcp/dist/store.d.ts +39 -1
  692. package/packages/tools/mcp/dist/store.d.ts.map +1 -1
  693. package/packages/tools/mcp/dist/store.js +24 -0
  694. package/packages/tools/mcp/dist/store.js.map +1 -1
  695. package/packages/tools/mcp/dist/testing/fake.d.ts +6 -0
  696. package/packages/tools/mcp/dist/testing/fake.d.ts.map +1 -1
  697. package/packages/tools/mcp/dist/testing/fake.js +26 -0
  698. package/packages/tools/mcp/dist/testing/fake.js.map +1 -1
  699. package/packages/tools/mcp/migrations/003_token_auth.sql +14 -0
  700. package/packages/tools/mcp/migrations/004_programs.sql +26 -0
  701. package/packages/tools/memory/dist/.tsbuildinfo +1 -1
  702. package/packages/tools/web/dist/.tsbuildinfo +1 -1
  703. package/packages/tools/web/dist/providers/index.d.ts +1 -2
  704. package/packages/tools/web/dist/providers/index.d.ts.map +1 -1
  705. package/packages/tools/web/dist/providers/index.js +1 -2
  706. package/packages/tools/web/dist/providers/index.js.map +1 -1
  707. package/packages/web/dist/assets/index-BxbiKNMS.css +1 -0
  708. package/packages/web/dist/assets/index-Rrze3bGo.js +130 -0
  709. package/packages/web/dist/assets/{lottie_light-D7STH9tF.js → lottie_light-7wQnGwdw.js} +1 -1
  710. package/packages/web/dist/build.json +1 -1
  711. package/packages/web/dist/index.html +2 -2
  712. package/packages/web/dist/manifest.webmanifest +24 -5
  713. package/packages/web/dist/precache.json +4 -4
  714. package/packages/web/dist/sw.js +5 -3
  715. package/packages/web/dist/assets/index-C-NAQ_MT.css +0 -1
  716. package/packages/web/dist/assets/index-DzFS39N3.js +0 -125
@@ -1,125 +0,0 @@
1
- var yv=e=>{throw TypeError(e)};var wv=(e,t,s)=>t.has(e)||yv("Cannot "+s);var Qt=(e,t,s)=>(wv(e,t,"read from private field"),s?s.call(e):t.get(e)),bv=(e,t,s)=>t.has(e)?yv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Yd=(e,t,s,r)=>(wv(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s);function aA(e,t){for(var s=0;s<t.length;s++){const r=t[s];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(e,i,a.get?a:{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 a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function s(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=s(i);fetch(i.href,a)}})();var yH=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lA(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kw={exports:{}},Ku={},Gw={exports:{}},Ue={};/**
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 go=Symbol.for("react.element"),oA=Symbol.for("react.portal"),cA=Symbol.for("react.fragment"),uA=Symbol.for("react.strict_mode"),dA=Symbol.for("react.profiler"),hA=Symbol.for("react.provider"),fA=Symbol.for("react.context"),mA=Symbol.for("react.forward_ref"),pA=Symbol.for("react.suspense"),gA=Symbol.for("react.memo"),xA=Symbol.for("react.lazy"),kv=Symbol.iterator;function vA(e){return e===null||typeof e!="object"?null:(e=kv&&e[kv]||e["@@iterator"],typeof e=="function"?e:null)}var Yw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qw=Object.assign,Qw={};function _a(e,t,s){this.props=e,this.context=t,this.refs=Qw,this.updater=s||Yw}_a.prototype.isReactComponent={};_a.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")};_a.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Jw(){}Jw.prototype=_a.prototype;function Np(e,t,s){this.props=e,this.context=t,this.refs=Qw,this.updater=s||Yw}var Cp=Np.prototype=new Jw;Cp.constructor=Np;qw(Cp,_a.prototype);Cp.isPureReactComponent=!0;var Sv=Array.isArray,Xw=Object.prototype.hasOwnProperty,Ep={current:null},Zw={key:!0,ref:!0,__self:!0,__source:!0};function eb(e,t,s){var r,i={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)Xw.call(t,r)&&!Zw.hasOwnProperty(r)&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=s;else if(1<o){for(var c=Array(o),u=0;u<o;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return{$$typeof:go,type:e,key:a,ref:l,props:i,_owner:Ep.current}}function jA(e,t){return{$$typeof:go,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ap(e){return typeof e=="object"&&e!==null&&e.$$typeof===go}function yA(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var Nv=/\/+/g;function qd(e,t){return typeof e=="object"&&e!==null&&e.key!=null?yA(""+e.key):t.toString(36)}function Rc(e,t,s,r,i){var a=typeof e;(a==="undefined"||a==="boolean")&&(e=null);var l=!1;if(e===null)l=!0;else switch(a){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case go:case oA:l=!0}}if(l)return l=e,i=i(l),e=r===""?"."+qd(l,0):r,Sv(i)?(s="",e!=null&&(s=e.replace(Nv,"$&/")+"/"),Rc(i,t,s,"",function(u){return u})):i!=null&&(Ap(i)&&(i=jA(i,s+(!i.key||l&&l.key===i.key?"":(""+i.key).replace(Nv,"$&/")+"/")+e)),t.push(i)),1;if(l=0,r=r===""?".":r+":",Sv(e))for(var o=0;o<e.length;o++){a=e[o];var c=r+qd(a,o);l+=Rc(a,t,s,c,i)}else if(c=vA(e),typeof c=="function")for(e=c.call(e),o=0;!(a=e.next()).done;)a=a.value,c=r+qd(a,o++),l+=Rc(a,t,s,c,i);else if(a==="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 l}function Uo(e,t,s){if(e==null)return e;var r=[],i=0;return Rc(e,r,"","",function(a){return t.call(s,a,i++)}),r}function wA(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var hn={current:null},Ic={transition:null},bA={ReactCurrentDispatcher:hn,ReactCurrentBatchConfig:Ic,ReactCurrentOwner:Ep};function tb(){throw Error("act(...) is not supported in production builds of React.")}Ue.Children={map:Uo,forEach:function(e,t,s){Uo(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return Uo(e,function(){t++}),t},toArray:function(e){return Uo(e,function(t){return t})||[]},only:function(e){if(!Ap(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ue.Component=_a;Ue.Fragment=cA;Ue.Profiler=dA;Ue.PureComponent=Np;Ue.StrictMode=uA;Ue.Suspense=pA;Ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=bA;Ue.act=tb;Ue.cloneElement=function(e,t,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=qw({},e.props),i=e.key,a=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(a=t.ref,l=Ep.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(c in t)Xw.call(t,c)&&!Zw.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&o!==void 0?o[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=s;else if(1<c){o=Array(c);for(var u=0;u<c;u++)o[u]=arguments[u+2];r.children=o}return{$$typeof:go,type:e.type,key:i,ref:a,props:r,_owner:l}};Ue.createContext=function(e){return e={$$typeof:fA,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:hA,_context:e},e.Consumer=e};Ue.createElement=eb;Ue.createFactory=function(e){var t=eb.bind(null,e);return t.type=e,t};Ue.createRef=function(){return{current:null}};Ue.forwardRef=function(e){return{$$typeof:mA,render:e}};Ue.isValidElement=Ap;Ue.lazy=function(e){return{$$typeof:xA,_payload:{_status:-1,_result:e},_init:wA}};Ue.memo=function(e,t){return{$$typeof:gA,type:e,compare:t===void 0?null:t}};Ue.startTransition=function(e){var t=Ic.transition;Ic.transition={};try{e()}finally{Ic.transition=t}};Ue.unstable_act=tb;Ue.useCallback=function(e,t){return hn.current.useCallback(e,t)};Ue.useContext=function(e){return hn.current.useContext(e)};Ue.useDebugValue=function(){};Ue.useDeferredValue=function(e){return hn.current.useDeferredValue(e)};Ue.useEffect=function(e,t){return hn.current.useEffect(e,t)};Ue.useId=function(){return hn.current.useId()};Ue.useImperativeHandle=function(e,t,s){return hn.current.useImperativeHandle(e,t,s)};Ue.useInsertionEffect=function(e,t){return hn.current.useInsertionEffect(e,t)};Ue.useLayoutEffect=function(e,t){return hn.current.useLayoutEffect(e,t)};Ue.useMemo=function(e,t){return hn.current.useMemo(e,t)};Ue.useReducer=function(e,t,s){return hn.current.useReducer(e,t,s)};Ue.useRef=function(e){return hn.current.useRef(e)};Ue.useState=function(e){return hn.current.useState(e)};Ue.useSyncExternalStore=function(e,t,s){return hn.current.useSyncExternalStore(e,t,s)};Ue.useTransition=function(){return hn.current.useTransition()};Ue.version="18.3.1";Gw.exports=Ue;var h=Gw.exports;const kA=lA(h),La=aA({__proto__:null,default:kA},[h]);/**
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 SA=h,NA=Symbol.for("react.element"),CA=Symbol.for("react.fragment"),EA=Object.prototype.hasOwnProperty,AA=SA.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,TA={key:!0,ref:!0,__self:!0,__source:!0};function nb(e,t,s){var r,i={},a=null,l=null;s!==void 0&&(a=""+s),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(l=t.ref);for(r in t)EA.call(t,r)&&!TA.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:NA,type:e,key:a,ref:l,props:i,_owner:AA.current}}Ku.Fragment=CA;Ku.jsx=nb;Ku.jsxs=nb;Kw.exports=Ku;var n=Kw.exports,sb={exports:{}},_n={},rb={exports:{}},ib={};/**
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(D,Y){var B=D.length;D.push(Y);e:for(;0<B;){var V=B-1>>>1,de=D[V];if(0<i(de,Y))D[V]=Y,D[B]=de,B=V;else break e}}function s(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var Y=D[0],B=D.pop();if(B!==Y){D[0]=B;e:for(var V=0,de=D.length,ae=de>>>1;V<ae;){var le=2*(V+1)-1,Ce=D[le],ee=le+1,ce=D[ee];if(0>i(Ce,B))ee<de&&0>i(ce,Ce)?(D[V]=ce,D[ee]=B,V=ee):(D[V]=Ce,D[le]=B,V=le);else if(ee<de&&0>i(ce,B))D[V]=ce,D[ee]=B,V=ee;else break e}}return Y}function i(D,Y){var B=D.sortIndex-Y.sortIndex;return B!==0?B:D.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],f=1,d=null,m=3,p=!1,v=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=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(D){for(var Y=s(u);Y!==null;){if(Y.callback===null)r(u);else if(Y.startTime<=D)r(u),Y.sortIndex=Y.expirationTime,t(c,Y);else break;Y=s(u)}}function j(D){if(w=!1,y(D),!v)if(s(c)!==null)v=!0,_(N);else{var Y=s(u);Y!==null&&K(j,Y.startTime-D)}}function N(D,Y){v=!1,w&&(w=!1,g(C),C=-1),p=!0;var B=m;try{for(y(Y),d=s(c);d!==null&&(!(d.expirationTime>Y)||D&&!P());){var V=d.callback;if(typeof V=="function"){d.callback=null,m=d.priorityLevel;var de=V(d.expirationTime<=Y);Y=e.unstable_now(),typeof de=="function"?d.callback=de:d===s(c)&&r(c),y(Y)}else r(c);d=s(c)}if(d!==null)var ae=!0;else{var le=s(u);le!==null&&K(j,le.startTime-Y),ae=!1}return ae}finally{d=null,m=B,p=!1}}var b=!1,S=null,C=-1,R=5,E=-1;function P(){return!(e.unstable_now()-E<R)}function F(){if(S!==null){var D=e.unstable_now();E=D;var Y=!0;try{Y=S(!0,D)}finally{Y?M():(b=!1,S=null)}}else b=!1}var M;if(typeof x=="function")M=function(){x(F)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,$=T.port2;T.port1.onmessage=F,M=function(){$.postMessage(null)}}else M=function(){k(F,0)};function _(D){S=D,b||(b=!0,M())}function K(D,Y){C=k(function(){D(e.unstable_now())},Y)}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(D){D.callback=null},e.unstable_continueExecution=function(){v||p||(v=!0,_(N))},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return s(c)},e.unstable_next=function(D){switch(m){case 1:case 2:case 3:var Y=3;break;default:Y=m}var B=m;m=Y;try{return D()}finally{m=B}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(D,Y){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var B=m;m=D;try{return Y()}finally{m=B}},e.unstable_scheduleCallback=function(D,Y,B){var V=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?V+B:V):B=V,D){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=B+de,D={id:f++,callback:Y,priorityLevel:D,startTime:B,expirationTime:de,sortIndex:-1},B>V?(D.sortIndex=B,t(u,D),s(c)===null&&D===s(u)&&(w?(g(C),C=-1):w=!0,K(j,B-V))):(D.sortIndex=de,t(c,D),v||p||(v=!0,_(N))),D},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(D){var Y=m;return function(){var B=m;m=Y;try{return D.apply(this,arguments)}finally{m=B}}}})(ib);rb.exports=ib;var RA=rb.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 IA=h,Dn=RA;function re(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);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 ab=new Set,$l={};function Ni(e,t){ja(e,t),ja(e+"Capture",t)}function ja(e,t){for($l[e]=t,e=0;e<t.length;e++)ab.add(t[e])}var Qs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),mf=Object.prototype.hasOwnProperty,PA=/^[: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]*$/,Cv={},Ev={};function MA(e){return mf.call(Ev,e)?!0:mf.call(Cv,e)?!1:PA.test(e)?Ev[e]=!0:(Cv[e]=!0,!1)}function $A(e,t,s,r){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function DA(e,t,s,r){if(t===null||typeof t>"u"||$A(e,t,s,r))return!0;if(r)return!1;if(s!==null)switch(s.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 fn(e,t,s,r,i,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var Gt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Gt[e]=new fn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Gt[t]=new fn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Gt[e]=new fn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Gt[e]=new fn(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){Gt[e]=new fn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Gt[e]=new fn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Gt[e]=new fn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Gt[e]=new fn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Gt[e]=new fn(e,5,!1,e.toLowerCase(),null,!1,!1)});var Tp=/[\-:]([a-z])/g;function Rp(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(Tp,Rp);Gt[t]=new fn(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(Tp,Rp);Gt[t]=new fn(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(Tp,Rp);Gt[t]=new fn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Gt[e]=new fn(e,1,!1,e.toLowerCase(),null,!1,!1)});Gt.xlinkHref=new fn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Gt[e]=new fn(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ip(e,t,s,r){var i=Gt.hasOwnProperty(t)?Gt[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(DA(t,s,i,r)&&(s=null),r||i===null?MA(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):i.mustUseProperty?e[i.propertyName]=s===null?i.type===3?!1:"":s:(t=i.attributeName,r=i.attributeNamespace,s===null?e.removeAttribute(t):(i=i.type,s=i===3||i===4&&s===!0?"":""+s,r?e.setAttributeNS(r,t,s):e.setAttribute(t,s))))}var ir=IA.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Bo=Symbol.for("react.element"),qi=Symbol.for("react.portal"),Qi=Symbol.for("react.fragment"),Pp=Symbol.for("react.strict_mode"),pf=Symbol.for("react.profiler"),lb=Symbol.for("react.provider"),ob=Symbol.for("react.context"),Mp=Symbol.for("react.forward_ref"),gf=Symbol.for("react.suspense"),xf=Symbol.for("react.suspense_list"),$p=Symbol.for("react.memo"),dr=Symbol.for("react.lazy"),cb=Symbol.for("react.offscreen"),Av=Symbol.iterator;function tl(e){return e===null||typeof e!="object"?null:(e=Av&&e[Av]||e["@@iterator"],typeof e=="function"?e:null)}var ft=Object.assign,Qd;function ml(e){if(Qd===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);Qd=t&&t[1]||""}return`
34
- `+Qd+e}var Jd=!1;function Xd(e,t){if(!e||Jd)return"";Jd=!0;var s=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
- `),a=r.stack.split(`
36
- `),l=i.length-1,o=a.length-1;1<=l&&0<=o&&i[l]!==a[o];)o--;for(;1<=l&&0<=o;l--,o--)if(i[l]!==a[o]){if(l!==1||o!==1)do if(l--,o--,0>o||i[l]!==a[o]){var c=`
37
- `+i[l].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Jd=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?ml(e):""}function OA(e){switch(e.tag){case 5:return ml(e.type);case 16:return ml("Lazy");case 13:return ml("Suspense");case 19:return ml("SuspenseList");case 0:case 2:case 15:return e=Xd(e.type,!1),e;case 11:return e=Xd(e.type.render,!1),e;case 1:return e=Xd(e.type,!0),e;default:return""}}function vf(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 Qi:return"Fragment";case qi:return"Portal";case pf:return"Profiler";case Pp:return"StrictMode";case gf:return"Suspense";case xf:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ob:return(e.displayName||"Context")+".Consumer";case lb:return(e._context.displayName||"Context")+".Provider";case Mp:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $p:return t=e.displayName||null,t!==null?t:vf(e.type)||"Memo";case dr:t=e._payload,e=e._init;try{return vf(e(t))}catch{}}return null}function _A(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 vf(t);case 8:return t===Pp?"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 Pr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ub(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function LA(e){var t=ub(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var i=s.get,a=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function zo(e){e._valueTracker||(e._valueTracker=LA(e))}function db(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),r="";return e&&(r=ub(e)?e.checked?"true":"false":e.value),e=r,e!==s?(t.setValue(e),!0):!1}function tu(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 jf(e,t){var s=t.checked;return ft({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function Tv(e,t){var s=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;s=Pr(t.value!=null?t.value:s),e._wrapperState={initialChecked:r,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function hb(e,t){t=t.checked,t!=null&&Ip(e,"checked",t,!1)}function yf(e,t){hb(e,t);var s=Pr(t.value),r=t.type;if(s!=null)r==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?wf(e,t.type,s):t.hasOwnProperty("defaultValue")&&wf(e,t.type,Pr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Rv(e,t,s){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,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function wf(e,t,s){(t!=="number"||tu(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var pl=Array.isArray;function ca(e,t,s,r){if(e=e.options,t){t={};for(var i=0;i<s.length;i++)t["$"+s[i]]=!0;for(s=0;s<e.length;s++)i=t.hasOwnProperty("$"+e[s].value),e[s].selected!==i&&(e[s].selected=i),i&&r&&(e[s].defaultSelected=!0)}else{for(s=""+Pr(s),t=null,i=0;i<e.length;i++){if(e[i].value===s){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function bf(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(re(91));return ft({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Iv(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(re(92));if(pl(s)){if(1<s.length)throw Error(re(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:Pr(s)}}function fb(e,t){var s=Pr(t.value),r=Pr(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),r!=null&&(e.defaultValue=""+r)}function Pv(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function mb(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 kf(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?mb(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Wo,pb=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,s,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Wo=Wo||document.createElement("div"),Wo.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Wo.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Dl(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var yl={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},FA=["Webkit","ms","Moz","O"];Object.keys(yl).forEach(function(e){FA.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),yl[t]=yl[e]})});function gb(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||yl.hasOwnProperty(e)&&yl[e]?(""+t).trim():t+"px"}function xb(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var r=s.indexOf("--")===0,i=gb(s,t[s],r);s==="float"&&(s="cssFloat"),r?e.setProperty(s,i):e[s]=i}}var UA=ft({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 Sf(e,t){if(t){if(UA[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(re(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(re(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(re(61))}if(t.style!=null&&typeof t.style!="object")throw Error(re(62))}}function Nf(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 Cf=null;function Dp(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ef=null,ua=null,da=null;function Mv(e){if(e=jo(e)){if(typeof Ef!="function")throw Error(re(280));var t=e.stateNode;t&&(t=Ju(t),Ef(e.stateNode,e.type,t))}}function vb(e){ua?da?da.push(e):da=[e]:ua=e}function jb(){if(ua){var e=ua,t=da;if(da=ua=null,Mv(e),t)for(e=0;e<t.length;e++)Mv(t[e])}}function yb(e,t){return e(t)}function wb(){}var Zd=!1;function bb(e,t,s){if(Zd)return e(t,s);Zd=!0;try{return yb(e,t,s)}finally{Zd=!1,(ua!==null||da!==null)&&(wb(),jb())}}function Ol(e,t){var s=e.stateNode;if(s===null)return null;var r=Ju(s);if(r===null)return null;s=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(s&&typeof s!="function")throw Error(re(231,t,typeof s));return s}var Af=!1;if(Qs)try{var nl={};Object.defineProperty(nl,"passive",{get:function(){Af=!0}}),window.addEventListener("test",nl,nl),window.removeEventListener("test",nl,nl)}catch{Af=!1}function BA(e,t,s,r,i,a,l,o,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(s,u)}catch(f){this.onError(f)}}var wl=!1,nu=null,su=!1,Tf=null,zA={onError:function(e){wl=!0,nu=e}};function WA(e,t,s,r,i,a,l,o,c){wl=!1,nu=null,BA.apply(zA,arguments)}function HA(e,t,s,r,i,a,l,o,c){if(WA.apply(this,arguments),wl){if(wl){var u=nu;wl=!1,nu=null}else throw Error(re(198));su||(su=!0,Tf=u)}}function Ci(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function kb(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 $v(e){if(Ci(e)!==e)throw Error(re(188))}function VA(e){var t=e.alternate;if(!t){if(t=Ci(e),t===null)throw Error(re(188));return t!==e?null:e}for(var s=e,r=t;;){var i=s.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){s=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===s)return $v(i),e;if(a===r)return $v(i),t;a=a.sibling}throw Error(re(188))}if(s.return!==r.return)s=i,r=a;else{for(var l=!1,o=i.child;o;){if(o===s){l=!0,s=i,r=a;break}if(o===r){l=!0,r=i,s=a;break}o=o.sibling}if(!l){for(o=a.child;o;){if(o===s){l=!0,s=a,r=i;break}if(o===r){l=!0,r=a,s=i;break}o=o.sibling}if(!l)throw Error(re(189))}}if(s.alternate!==r)throw Error(re(190))}if(s.tag!==3)throw Error(re(188));return s.stateNode.current===s?e:t}function Sb(e){return e=VA(e),e!==null?Nb(e):null}function Nb(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Nb(e);if(t!==null)return t;e=e.sibling}return null}var Cb=Dn.unstable_scheduleCallback,Dv=Dn.unstable_cancelCallback,KA=Dn.unstable_shouldYield,GA=Dn.unstable_requestPaint,bt=Dn.unstable_now,YA=Dn.unstable_getCurrentPriorityLevel,Op=Dn.unstable_ImmediatePriority,Eb=Dn.unstable_UserBlockingPriority,ru=Dn.unstable_NormalPriority,qA=Dn.unstable_LowPriority,Ab=Dn.unstable_IdlePriority,Gu=null,As=null;function QA(e){if(As&&typeof As.onCommitFiberRoot=="function")try{As.onCommitFiberRoot(Gu,e,void 0,(e.current.flags&128)===128)}catch{}}var as=Math.clz32?Math.clz32:ZA,JA=Math.log,XA=Math.LN2;function ZA(e){return e>>>=0,e===0?32:31-(JA(e)/XA|0)|0}var Ho=64,Vo=4194304;function gl(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 iu(e,t){var s=e.pendingLanes;if(s===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,l=s&268435455;if(l!==0){var o=l&~i;o!==0?r=gl(o):(a&=l,a!==0&&(r=gl(a)))}else l=s&~i,l!==0?r=gl(l):a!==0&&(r=gl(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,a=t&-t,i>=a||i===16&&(a&4194240)!==0))return t;if(r&4&&(r|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)s=31-as(t),i=1<<s,r|=e[s],t&=~i;return r}function eT(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 tT(e,t){for(var s=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes;0<a;){var l=31-as(a),o=1<<l,c=i[l];c===-1?(!(o&s)||o&r)&&(i[l]=eT(o,t)):c<=t&&(e.expiredLanes|=o),a&=~o}}function Rf(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Tb(){var e=Ho;return Ho<<=1,!(Ho&4194240)&&(Ho=64),e}function eh(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function xo(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-as(t),e[t]=s}function nT(e,t){var s=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<s;){var i=31-as(s),a=1<<i;t[i]=0,r[i]=-1,e[i]=-1,s&=~a}}function _p(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var r=31-as(s),i=1<<r;i&t|e[r]&t&&(e[r]|=t),s&=~i}}var Je=0;function Rb(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Ib,Lp,Pb,Mb,$b,If=!1,Ko=[],jr=null,yr=null,wr=null,_l=new Map,Ll=new Map,fr=[],sT="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 Ov(e,t){switch(e){case"focusin":case"focusout":jr=null;break;case"dragenter":case"dragleave":yr=null;break;case"mouseover":case"mouseout":wr=null;break;case"pointerover":case"pointerout":_l.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ll.delete(t.pointerId)}}function sl(e,t,s,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:s,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=jo(t),t!==null&&Lp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function rT(e,t,s,r,i){switch(t){case"focusin":return jr=sl(jr,e,t,s,r,i),!0;case"dragenter":return yr=sl(yr,e,t,s,r,i),!0;case"mouseover":return wr=sl(wr,e,t,s,r,i),!0;case"pointerover":var a=i.pointerId;return _l.set(a,sl(_l.get(a)||null,e,t,s,r,i)),!0;case"gotpointercapture":return a=i.pointerId,Ll.set(a,sl(Ll.get(a)||null,e,t,s,r,i)),!0}return!1}function Db(e){var t=li(e.target);if(t!==null){var s=Ci(t);if(s!==null){if(t=s.tag,t===13){if(t=kb(s),t!==null){e.blockedOn=t,$b(e.priority,function(){Pb(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Pc(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=Pf(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var r=new s.constructor(s.type,s);Cf=r,s.target.dispatchEvent(r),Cf=null}else return t=jo(s),t!==null&&Lp(t),e.blockedOn=s,!1;t.shift()}return!0}function _v(e,t,s){Pc(e)&&s.delete(t)}function iT(){If=!1,jr!==null&&Pc(jr)&&(jr=null),yr!==null&&Pc(yr)&&(yr=null),wr!==null&&Pc(wr)&&(wr=null),_l.forEach(_v),Ll.forEach(_v)}function rl(e,t){e.blockedOn===t&&(e.blockedOn=null,If||(If=!0,Dn.unstable_scheduleCallback(Dn.unstable_NormalPriority,iT)))}function Fl(e){function t(i){return rl(i,e)}if(0<Ko.length){rl(Ko[0],e);for(var s=1;s<Ko.length;s++){var r=Ko[s];r.blockedOn===e&&(r.blockedOn=null)}}for(jr!==null&&rl(jr,e),yr!==null&&rl(yr,e),wr!==null&&rl(wr,e),_l.forEach(t),Ll.forEach(t),s=0;s<fr.length;s++)r=fr[s],r.blockedOn===e&&(r.blockedOn=null);for(;0<fr.length&&(s=fr[0],s.blockedOn===null);)Db(s),s.blockedOn===null&&fr.shift()}var ha=ir.ReactCurrentBatchConfig,au=!0;function aT(e,t,s,r){var i=Je,a=ha.transition;ha.transition=null;try{Je=1,Fp(e,t,s,r)}finally{Je=i,ha.transition=a}}function lT(e,t,s,r){var i=Je,a=ha.transition;ha.transition=null;try{Je=4,Fp(e,t,s,r)}finally{Je=i,ha.transition=a}}function Fp(e,t,s,r){if(au){var i=Pf(e,t,s,r);if(i===null)uh(e,t,r,lu,s),Ov(e,r);else if(rT(i,e,t,s,r))r.stopPropagation();else if(Ov(e,r),t&4&&-1<sT.indexOf(e)){for(;i!==null;){var a=jo(i);if(a!==null&&Ib(a),a=Pf(e,t,s,r),a===null&&uh(e,t,r,lu,s),a===i)break;i=a}i!==null&&r.stopPropagation()}else uh(e,t,r,null,s)}}var lu=null;function Pf(e,t,s,r){if(lu=null,e=Dp(r),e=li(e),e!==null)if(t=Ci(e),t===null)e=null;else if(s=t.tag,s===13){if(e=kb(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return lu=e,null}function Ob(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(YA()){case Op:return 1;case Eb:return 4;case ru:case qA:return 16;case Ab:return 536870912;default:return 16}default:return 16}}var pr=null,Up=null,Mc=null;function _b(){if(Mc)return Mc;var e,t=Up,s=t.length,r,i="value"in pr?pr.value:pr.textContent,a=i.length;for(e=0;e<s&&t[e]===i[e];e++);var l=s-e;for(r=1;r<=l&&t[s-r]===i[a-r];r++);return Mc=i.slice(e,1<r?1-r:void 0)}function $c(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 Go(){return!0}function Lv(){return!1}function Ln(e){function t(s,r,i,a,l){this._reactName=s,this._targetInst=i,this.type=r,this.nativeEvent=a,this.target=l,this.currentTarget=null;for(var o in e)e.hasOwnProperty(o)&&(s=e[o],this[o]=s?s(a):a[o]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?Go:Lv,this.isPropagationStopped=Lv,this}return ft(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Go)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Go)},persist:function(){},isPersistent:Go}),t}var Fa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bp=Ln(Fa),vo=ft({},Fa,{view:0,detail:0}),oT=Ln(vo),th,nh,il,Yu=ft({},vo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zp,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!==il&&(il&&e.type==="mousemove"?(th=e.screenX-il.screenX,nh=e.screenY-il.screenY):nh=th=0,il=e),th)},movementY:function(e){return"movementY"in e?e.movementY:nh}}),Fv=Ln(Yu),cT=ft({},Yu,{dataTransfer:0}),uT=Ln(cT),dT=ft({},vo,{relatedTarget:0}),sh=Ln(dT),hT=ft({},Fa,{animationName:0,elapsedTime:0,pseudoElement:0}),fT=Ln(hT),mT=ft({},Fa,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),pT=Ln(mT),gT=ft({},Fa,{data:0}),Uv=Ln(gT),xT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},vT={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"},jT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function yT(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=jT[e])?!!t[e]:!1}function zp(){return yT}var wT=ft({},vo,{key:function(e){if(e.key){var t=xT[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=$c(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?vT[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zp,charCode:function(e){return e.type==="keypress"?$c(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?$c(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),bT=Ln(wT),kT=ft({},Yu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bv=Ln(kT),ST=ft({},vo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zp}),NT=Ln(ST),CT=ft({},Fa,{propertyName:0,elapsedTime:0,pseudoElement:0}),ET=Ln(CT),AT=ft({},Yu,{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}),TT=Ln(AT),RT=[9,13,27,32],Wp=Qs&&"CompositionEvent"in window,bl=null;Qs&&"documentMode"in document&&(bl=document.documentMode);var IT=Qs&&"TextEvent"in window&&!bl,Lb=Qs&&(!Wp||bl&&8<bl&&11>=bl),zv=" ",Wv=!1;function Fb(e,t){switch(e){case"keyup":return RT.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ub(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ji=!1;function PT(e,t){switch(e){case"compositionend":return Ub(t);case"keypress":return t.which!==32?null:(Wv=!0,zv);case"textInput":return e=t.data,e===zv&&Wv?null:e;default:return null}}function MT(e,t){if(Ji)return e==="compositionend"||!Wp&&Fb(e,t)?(e=_b(),Mc=Up=pr=null,Ji=!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 Lb&&t.locale!=="ko"?null:t.data;default:return null}}var $T={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 Hv(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!$T[e.type]:t==="textarea"}function Bb(e,t,s,r){vb(r),t=ou(t,"onChange"),0<t.length&&(s=new Bp("onChange","change",null,s,r),e.push({event:s,listeners:t}))}var kl=null,Ul=null;function DT(e){Xb(e,0)}function qu(e){var t=ea(e);if(db(t))return e}function OT(e,t){if(e==="change")return t}var zb=!1;if(Qs){var rh;if(Qs){var ih="oninput"in document;if(!ih){var Vv=document.createElement("div");Vv.setAttribute("oninput","return;"),ih=typeof Vv.oninput=="function"}rh=ih}else rh=!1;zb=rh&&(!document.documentMode||9<document.documentMode)}function Kv(){kl&&(kl.detachEvent("onpropertychange",Wb),Ul=kl=null)}function Wb(e){if(e.propertyName==="value"&&qu(Ul)){var t=[];Bb(t,Ul,e,Dp(e)),bb(DT,t)}}function _T(e,t,s){e==="focusin"?(Kv(),kl=t,Ul=s,kl.attachEvent("onpropertychange",Wb)):e==="focusout"&&Kv()}function LT(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return qu(Ul)}function FT(e,t){if(e==="click")return qu(t)}function UT(e,t){if(e==="input"||e==="change")return qu(t)}function BT(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ds=typeof Object.is=="function"?Object.is:BT;function Bl(e,t){if(ds(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(r=0;r<s.length;r++){var i=s[r];if(!mf.call(t,i)||!ds(e[i],t[i]))return!1}return!0}function Gv(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Yv(e,t){var s=Gv(e);e=0;for(var r;s;){if(s.nodeType===3){if(r=e+s.textContent.length,e<=t&&r>=t)return{node:s,offset:t-e};e=r}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Gv(s)}}function Hb(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Hb(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vb(){for(var e=window,t=tu();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=tu(e.document)}return t}function Hp(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 zT(e){var t=Vb(),s=e.focusedElem,r=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Hb(s.ownerDocument.documentElement,s)){if(r!==null&&Hp(s)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=s.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Yv(s,a);var l=Yv(s,r);i&&l&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var WT=Qs&&"documentMode"in document&&11>=document.documentMode,Xi=null,Mf=null,Sl=null,$f=!1;function qv(e,t,s){var r=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;$f||Xi==null||Xi!==tu(r)||(r=Xi,"selectionStart"in r&&Hp(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}),Sl&&Bl(Sl,r)||(Sl=r,r=ou(Mf,"onSelect"),0<r.length&&(t=new Bp("onSelect","select",null,t,s),e.push({event:t,listeners:r}),t.target=Xi)))}function Yo(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Zi={animationend:Yo("Animation","AnimationEnd"),animationiteration:Yo("Animation","AnimationIteration"),animationstart:Yo("Animation","AnimationStart"),transitionend:Yo("Transition","TransitionEnd")},ah={},Kb={};Qs&&(Kb=document.createElement("div").style,"AnimationEvent"in window||(delete Zi.animationend.animation,delete Zi.animationiteration.animation,delete Zi.animationstart.animation),"TransitionEvent"in window||delete Zi.transitionend.transition);function Qu(e){if(ah[e])return ah[e];if(!Zi[e])return e;var t=Zi[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Kb)return ah[e]=t[s];return e}var Gb=Qu("animationend"),Yb=Qu("animationiteration"),qb=Qu("animationstart"),Qb=Qu("transitionend"),Jb=new Map,Qv="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 zr(e,t){Jb.set(e,t),Ni(t,[e])}for(var lh=0;lh<Qv.length;lh++){var oh=Qv[lh],HT=oh.toLowerCase(),VT=oh[0].toUpperCase()+oh.slice(1);zr(HT,"on"+VT)}zr(Gb,"onAnimationEnd");zr(Yb,"onAnimationIteration");zr(qb,"onAnimationStart");zr("dblclick","onDoubleClick");zr("focusin","onFocus");zr("focusout","onBlur");zr(Qb,"onTransitionEnd");ja("onMouseEnter",["mouseout","mouseover"]);ja("onMouseLeave",["mouseout","mouseover"]);ja("onPointerEnter",["pointerout","pointerover"]);ja("onPointerLeave",["pointerout","pointerover"]);Ni("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ni("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ni("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ni("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ni("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ni("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xl="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(" "),KT=new Set("cancel close invalid load scroll toggle".split(" ").concat(xl));function Jv(e,t,s){var r=e.type||"unknown-event";e.currentTarget=s,HA(r,t,void 0,e),e.currentTarget=null}function Xb(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var r=e[s],i=r.event;r=r.listeners;e:{var a=void 0;if(t)for(var l=r.length-1;0<=l;l--){var o=r[l],c=o.instance,u=o.currentTarget;if(o=o.listener,c!==a&&i.isPropagationStopped())break e;Jv(i,o,u),a=c}else for(l=0;l<r.length;l++){if(o=r[l],c=o.instance,u=o.currentTarget,o=o.listener,c!==a&&i.isPropagationStopped())break e;Jv(i,o,u),a=c}}}if(su)throw e=Tf,su=!1,Tf=null,e}function st(e,t){var s=t[Ff];s===void 0&&(s=t[Ff]=new Set);var r=e+"__bubble";s.has(r)||(Zb(t,e,2,!1),s.add(r))}function ch(e,t,s){var r=0;t&&(r|=4),Zb(s,e,r,t)}var qo="_reactListening"+Math.random().toString(36).slice(2);function zl(e){if(!e[qo]){e[qo]=!0,ab.forEach(function(s){s!=="selectionchange"&&(KT.has(s)||ch(s,!1,e),ch(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[qo]||(t[qo]=!0,ch("selectionchange",!1,t))}}function Zb(e,t,s,r){switch(Ob(t)){case 1:var i=aT;break;case 4:i=lT;break;default:i=Fp}s=i.bind(null,t,s,e),i=void 0,!Af||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,s,{capture:!0,passive:i}):e.addEventListener(t,s,!0):i!==void 0?e.addEventListener(t,s,{passive:i}):e.addEventListener(t,s,!1)}function uh(e,t,s,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var l=r.tag;if(l===3||l===4){var o=r.stateNode.containerInfo;if(o===i||o.nodeType===8&&o.parentNode===i)break;if(l===4)for(l=r.return;l!==null;){var c=l.tag;if((c===3||c===4)&&(c=l.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;l=l.return}for(;o!==null;){if(l=li(o),l===null)return;if(c=l.tag,c===5||c===6){r=a=l;continue e}o=o.parentNode}}r=r.return}bb(function(){var u=a,f=Dp(s),d=[];e:{var m=Jb.get(e);if(m!==void 0){var p=Bp,v=e;switch(e){case"keypress":if($c(s)===0)break e;case"keydown":case"keyup":p=bT;break;case"focusin":v="focus",p=sh;break;case"focusout":v="blur",p=sh;break;case"beforeblur":case"afterblur":p=sh;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=Fv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=uT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=NT;break;case Gb:case Yb:case qb:p=fT;break;case Qb:p=ET;break;case"scroll":p=oT;break;case"wheel":p=TT;break;case"copy":case"cut":case"paste":p=pT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Bv}var w=(t&4)!==0,k=!w&&e==="scroll",g=w?m!==null?m+"Capture":null:m;w=[];for(var x=u,y;x!==null;){y=x;var j=y.stateNode;if(y.tag===5&&j!==null&&(y=j,g!==null&&(j=Ol(x,g),j!=null&&w.push(Wl(x,j,y)))),k)break;x=x.return}0<w.length&&(m=new p(m,v,null,s,f),d.push({event:m,listeners:w}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",m&&s!==Cf&&(v=s.relatedTarget||s.fromElement)&&(li(v)||v[Js]))break e;if((p||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,p?(v=s.relatedTarget||s.toElement,p=u,v=v?li(v):null,v!==null&&(k=Ci(v),v!==k||v.tag!==5&&v.tag!==6)&&(v=null)):(p=null,v=u),p!==v)){if(w=Fv,j="onMouseLeave",g="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(w=Bv,j="onPointerLeave",g="onPointerEnter",x="pointer"),k=p==null?m:ea(p),y=v==null?m:ea(v),m=new w(j,x+"leave",p,s,f),m.target=k,m.relatedTarget=y,j=null,li(f)===u&&(w=new w(g,x+"enter",v,s,f),w.target=y,w.relatedTarget=k,j=w),k=j,p&&v)t:{for(w=p,g=v,x=0,y=w;y;y=Ui(y))x++;for(y=0,j=g;j;j=Ui(j))y++;for(;0<x-y;)w=Ui(w),x--;for(;0<y-x;)g=Ui(g),y--;for(;x--;){if(w===g||g!==null&&w===g.alternate)break t;w=Ui(w),g=Ui(g)}w=null}else w=null;p!==null&&Xv(d,m,p,w,!1),v!==null&&k!==null&&Xv(d,k,v,w,!0)}}e:{if(m=u?ea(u):window,p=m.nodeName&&m.nodeName.toLowerCase(),p==="select"||p==="input"&&m.type==="file")var N=OT;else if(Hv(m))if(zb)N=UT;else{N=LT;var b=_T}else(p=m.nodeName)&&p.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(N=FT);if(N&&(N=N(e,u))){Bb(d,N,s,f);break e}b&&b(e,m,u),e==="focusout"&&(b=m._wrapperState)&&b.controlled&&m.type==="number"&&wf(m,"number",m.value)}switch(b=u?ea(u):window,e){case"focusin":(Hv(b)||b.contentEditable==="true")&&(Xi=b,Mf=u,Sl=null);break;case"focusout":Sl=Mf=Xi=null;break;case"mousedown":$f=!0;break;case"contextmenu":case"mouseup":case"dragend":$f=!1,qv(d,s,f);break;case"selectionchange":if(WT)break;case"keydown":case"keyup":qv(d,s,f)}var S;if(Wp)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 Ji?Fb(e,s)&&(C="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(C="onCompositionStart");C&&(Lb&&s.locale!=="ko"&&(Ji||C!=="onCompositionStart"?C==="onCompositionEnd"&&Ji&&(S=_b()):(pr=f,Up="value"in pr?pr.value:pr.textContent,Ji=!0)),b=ou(u,C),0<b.length&&(C=new Uv(C,e,null,s,f),d.push({event:C,listeners:b}),S?C.data=S:(S=Ub(s),S!==null&&(C.data=S)))),(S=IT?PT(e,s):MT(e,s))&&(u=ou(u,"onBeforeInput"),0<u.length&&(f=new Uv("onBeforeInput","beforeinput",null,s,f),d.push({event:f,listeners:u}),f.data=S))}Xb(d,t)})}function Wl(e,t,s){return{instance:e,listener:t,currentTarget:s}}function ou(e,t){for(var s=t+"Capture",r=[];e!==null;){var i=e,a=i.stateNode;i.tag===5&&a!==null&&(i=a,a=Ol(e,s),a!=null&&r.unshift(Wl(e,a,i)),a=Ol(e,t),a!=null&&r.push(Wl(e,a,i))),e=e.return}return r}function Ui(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Xv(e,t,s,r,i){for(var a=t._reactName,l=[];s!==null&&s!==r;){var o=s,c=o.alternate,u=o.stateNode;if(c!==null&&c===r)break;o.tag===5&&u!==null&&(o=u,i?(c=Ol(s,a),c!=null&&l.unshift(Wl(s,c,o))):i||(c=Ol(s,a),c!=null&&l.push(Wl(s,c,o)))),s=s.return}l.length!==0&&e.push({event:t,listeners:l})}var GT=/\r\n?/g,YT=/\u0000|\uFFFD/g;function Zv(e){return(typeof e=="string"?e:""+e).replace(GT,`
38
- `).replace(YT,"")}function Qo(e,t,s){if(t=Zv(t),Zv(e)!==t&&s)throw Error(re(425))}function cu(){}var Df=null,Of=null;function _f(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 Lf=typeof setTimeout=="function"?setTimeout:void 0,qT=typeof clearTimeout=="function"?clearTimeout:void 0,ej=typeof Promise=="function"?Promise:void 0,QT=typeof queueMicrotask=="function"?queueMicrotask:typeof ej<"u"?function(e){return ej.resolve(null).then(e).catch(JT)}:Lf;function JT(e){setTimeout(function(){throw e})}function dh(e,t){var s=t,r=0;do{var i=s.nextSibling;if(e.removeChild(s),i&&i.nodeType===8)if(s=i.data,s==="/$"){if(r===0){e.removeChild(i),Fl(t);return}r--}else s!=="$"&&s!=="$?"&&s!=="$!"||r++;s=i}while(s);Fl(t)}function br(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 tj(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var Ua=Math.random().toString(36).slice(2),Ss="__reactFiber$"+Ua,Hl="__reactProps$"+Ua,Js="__reactContainer$"+Ua,Ff="__reactEvents$"+Ua,XT="__reactListeners$"+Ua,ZT="__reactHandles$"+Ua;function li(e){var t=e[Ss];if(t)return t;for(var s=e.parentNode;s;){if(t=s[Js]||s[Ss]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=tj(e);e!==null;){if(s=e[Ss])return s;e=tj(e)}return t}e=s,s=e.parentNode}return null}function jo(e){return e=e[Ss]||e[Js],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ea(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(re(33))}function Ju(e){return e[Hl]||null}var Uf=[],ta=-1;function Wr(e){return{current:e}}function rt(e){0>ta||(e.current=Uf[ta],Uf[ta]=null,ta--)}function nt(e,t){ta++,Uf[ta]=e.current,e.current=t}var Mr={},nn=Wr(Mr),jn=Wr(!1),pi=Mr;function ya(e,t){var s=e.type.contextTypes;if(!s)return Mr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in s)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function yn(e){return e=e.childContextTypes,e!=null}function uu(){rt(jn),rt(nn)}function nj(e,t,s){if(nn.current!==Mr)throw Error(re(168));nt(nn,t),nt(jn,s)}function e0(e,t,s){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return s;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(re(108,_A(e)||"Unknown",i));return ft({},s,r)}function du(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Mr,pi=nn.current,nt(nn,e),nt(jn,jn.current),!0}function sj(e,t,s){var r=e.stateNode;if(!r)throw Error(re(169));s?(e=e0(e,t,pi),r.__reactInternalMemoizedMergedChildContext=e,rt(jn),rt(nn),nt(nn,e)):rt(jn),nt(jn,s)}var Bs=null,Xu=!1,hh=!1;function t0(e){Bs===null?Bs=[e]:Bs.push(e)}function eR(e){Xu=!0,t0(e)}function Hr(){if(!hh&&Bs!==null){hh=!0;var e=0,t=Je;try{var s=Bs;for(Je=1;e<s.length;e++){var r=s[e];do r=r(!0);while(r!==null)}Bs=null,Xu=!1}catch(i){throw Bs!==null&&(Bs=Bs.slice(e+1)),Cb(Op,Hr),i}finally{Je=t,hh=!1}}return null}var na=[],sa=0,hu=null,fu=0,Kn=[],Gn=0,gi=null,Ws=1,Hs="";function si(e,t){na[sa++]=fu,na[sa++]=hu,hu=e,fu=t}function n0(e,t,s){Kn[Gn++]=Ws,Kn[Gn++]=Hs,Kn[Gn++]=gi,gi=e;var r=Ws;e=Hs;var i=32-as(r)-1;r&=~(1<<i),s+=1;var a=32-as(t)+i;if(30<a){var l=i-i%5;a=(r&(1<<l)-1).toString(32),r>>=l,i-=l,Ws=1<<32-as(t)+i|s<<i|r,Hs=a+e}else Ws=1<<a|s<<i|r,Hs=e}function Vp(e){e.return!==null&&(si(e,1),n0(e,1,0))}function Kp(e){for(;e===hu;)hu=na[--sa],na[sa]=null,fu=na[--sa],na[sa]=null;for(;e===gi;)gi=Kn[--Gn],Kn[Gn]=null,Hs=Kn[--Gn],Kn[Gn]=null,Ws=Kn[--Gn],Kn[Gn]=null}var Mn=null,In=null,lt=!1,rs=null;function s0(e,t){var s=Qn(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function rj(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Mn=e,In=br(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Mn=e,In=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=gi!==null?{id:Ws,overflow:Hs}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=Qn(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,Mn=e,In=null,!0):!1;default:return!1}}function Bf(e){return(e.mode&1)!==0&&(e.flags&128)===0}function zf(e){if(lt){var t=In;if(t){var s=t;if(!rj(e,t)){if(Bf(e))throw Error(re(418));t=br(s.nextSibling);var r=Mn;t&&rj(e,t)?s0(r,s):(e.flags=e.flags&-4097|2,lt=!1,Mn=e)}}else{if(Bf(e))throw Error(re(418));e.flags=e.flags&-4097|2,lt=!1,Mn=e}}}function ij(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Mn=e}function Jo(e){if(e!==Mn)return!1;if(!lt)return ij(e),lt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!_f(e.type,e.memoizedProps)),t&&(t=In)){if(Bf(e))throw r0(),Error(re(418));for(;t;)s0(e,t),t=br(t.nextSibling)}if(ij(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(re(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){In=br(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}In=null}}else In=Mn?br(e.stateNode.nextSibling):null;return!0}function r0(){for(var e=In;e;)e=br(e.nextSibling)}function wa(){In=Mn=null,lt=!1}function Gp(e){rs===null?rs=[e]:rs.push(e)}var tR=ir.ReactCurrentBatchConfig;function al(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(re(309));var r=s.stateNode}if(!r)throw Error(re(147,e));var i=r,a=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===a?t.ref:(t=function(l){var o=i.refs;l===null?delete o[a]:o[a]=l},t._stringRef=a,t)}if(typeof e!="string")throw Error(re(284));if(!s._owner)throw Error(re(290,e))}return e}function Xo(e,t){throw e=Object.prototype.toString.call(t),Error(re(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function aj(e){var t=e._init;return t(e._payload)}function i0(e){function t(g,x){if(e){var y=g.deletions;y===null?(g.deletions=[x],g.flags|=16):y.push(x)}}function s(g,x){if(!e)return null;for(;x!==null;)t(g,x),x=x.sibling;return null}function r(g,x){for(g=new Map;x!==null;)x.key!==null?g.set(x.key,x):g.set(x.index,x),x=x.sibling;return g}function i(g,x){return g=Cr(g,x),g.index=0,g.sibling=null,g}function a(g,x,y){return g.index=y,e?(y=g.alternate,y!==null?(y=y.index,y<x?(g.flags|=2,x):y):(g.flags|=2,x)):(g.flags|=1048576,x)}function l(g){return e&&g.alternate===null&&(g.flags|=2),g}function o(g,x,y,j){return x===null||x.tag!==6?(x=jh(y,g.mode,j),x.return=g,x):(x=i(x,y),x.return=g,x)}function c(g,x,y,j){var N=y.type;return N===Qi?f(g,x,y.props.children,j,y.key):x!==null&&(x.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===dr&&aj(N)===x.type)?(j=i(x,y.props),j.ref=al(g,x,y),j.return=g,j):(j=Bc(y.type,y.key,y.props,null,g.mode,j),j.ref=al(g,x,y),j.return=g,j)}function u(g,x,y,j){return x===null||x.tag!==4||x.stateNode.containerInfo!==y.containerInfo||x.stateNode.implementation!==y.implementation?(x=yh(y,g.mode,j),x.return=g,x):(x=i(x,y.children||[]),x.return=g,x)}function f(g,x,y,j,N){return x===null||x.tag!==7?(x=di(y,g.mode,j,N),x.return=g,x):(x=i(x,y),x.return=g,x)}function d(g,x,y){if(typeof x=="string"&&x!==""||typeof x=="number")return x=jh(""+x,g.mode,y),x.return=g,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Bo:return y=Bc(x.type,x.key,x.props,null,g.mode,y),y.ref=al(g,null,x),y.return=g,y;case qi:return x=yh(x,g.mode,y),x.return=g,x;case dr:var j=x._init;return d(g,j(x._payload),y)}if(pl(x)||tl(x))return x=di(x,g.mode,y,null),x.return=g,x;Xo(g,x)}return null}function m(g,x,y,j){var N=x!==null?x.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return N!==null?null:o(g,x,""+y,j);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Bo:return y.key===N?c(g,x,y,j):null;case qi:return y.key===N?u(g,x,y,j):null;case dr:return N=y._init,m(g,x,N(y._payload),j)}if(pl(y)||tl(y))return N!==null?null:f(g,x,y,j,null);Xo(g,y)}return null}function p(g,x,y,j,N){if(typeof j=="string"&&j!==""||typeof j=="number")return g=g.get(y)||null,o(x,g,""+j,N);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Bo:return g=g.get(j.key===null?y:j.key)||null,c(x,g,j,N);case qi:return g=g.get(j.key===null?y:j.key)||null,u(x,g,j,N);case dr:var b=j._init;return p(g,x,y,b(j._payload),N)}if(pl(j)||tl(j))return g=g.get(y)||null,f(x,g,j,N,null);Xo(x,j)}return null}function v(g,x,y,j){for(var N=null,b=null,S=x,C=x=0,R=null;S!==null&&C<y.length;C++){S.index>C?(R=S,S=null):R=S.sibling;var E=m(g,S,y[C],j);if(E===null){S===null&&(S=R);break}e&&S&&E.alternate===null&&t(g,S),x=a(E,x,C),b===null?N=E:b.sibling=E,b=E,S=R}if(C===y.length)return s(g,S),lt&&si(g,C),N;if(S===null){for(;C<y.length;C++)S=d(g,y[C],j),S!==null&&(x=a(S,x,C),b===null?N=S:b.sibling=S,b=S);return lt&&si(g,C),N}for(S=r(g,S);C<y.length;C++)R=p(S,g,C,y[C],j),R!==null&&(e&&R.alternate!==null&&S.delete(R.key===null?C:R.key),x=a(R,x,C),b===null?N=R:b.sibling=R,b=R);return e&&S.forEach(function(P){return t(g,P)}),lt&&si(g,C),N}function w(g,x,y,j){var N=tl(y);if(typeof N!="function")throw Error(re(150));if(y=N.call(y),y==null)throw Error(re(151));for(var b=N=null,S=x,C=x=0,R=null,E=y.next();S!==null&&!E.done;C++,E=y.next()){S.index>C?(R=S,S=null):R=S.sibling;var P=m(g,S,E.value,j);if(P===null){S===null&&(S=R);break}e&&S&&P.alternate===null&&t(g,S),x=a(P,x,C),b===null?N=P:b.sibling=P,b=P,S=R}if(E.done)return s(g,S),lt&&si(g,C),N;if(S===null){for(;!E.done;C++,E=y.next())E=d(g,E.value,j),E!==null&&(x=a(E,x,C),b===null?N=E:b.sibling=E,b=E);return lt&&si(g,C),N}for(S=r(g,S);!E.done;C++,E=y.next())E=p(S,g,C,E.value,j),E!==null&&(e&&E.alternate!==null&&S.delete(E.key===null?C:E.key),x=a(E,x,C),b===null?N=E:b.sibling=E,b=E);return e&&S.forEach(function(F){return t(g,F)}),lt&&si(g,C),N}function k(g,x,y,j){if(typeof y=="object"&&y!==null&&y.type===Qi&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Bo:e:{for(var N=y.key,b=x;b!==null;){if(b.key===N){if(N=y.type,N===Qi){if(b.tag===7){s(g,b.sibling),x=i(b,y.props.children),x.return=g,g=x;break e}}else if(b.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===dr&&aj(N)===b.type){s(g,b.sibling),x=i(b,y.props),x.ref=al(g,b,y),x.return=g,g=x;break e}s(g,b);break}else t(g,b);b=b.sibling}y.type===Qi?(x=di(y.props.children,g.mode,j,y.key),x.return=g,g=x):(j=Bc(y.type,y.key,y.props,null,g.mode,j),j.ref=al(g,x,y),j.return=g,g=j)}return l(g);case qi:e:{for(b=y.key;x!==null;){if(x.key===b)if(x.tag===4&&x.stateNode.containerInfo===y.containerInfo&&x.stateNode.implementation===y.implementation){s(g,x.sibling),x=i(x,y.children||[]),x.return=g,g=x;break e}else{s(g,x);break}else t(g,x);x=x.sibling}x=yh(y,g.mode,j),x.return=g,g=x}return l(g);case dr:return b=y._init,k(g,x,b(y._payload),j)}if(pl(y))return v(g,x,y,j);if(tl(y))return w(g,x,y,j);Xo(g,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,x!==null&&x.tag===6?(s(g,x.sibling),x=i(x,y),x.return=g,g=x):(s(g,x),x=jh(y,g.mode,j),x.return=g,g=x),l(g)):s(g,x)}return k}var ba=i0(!0),a0=i0(!1),mu=Wr(null),pu=null,ra=null,Yp=null;function qp(){Yp=ra=pu=null}function Qp(e){var t=mu.current;rt(mu),e._currentValue=t}function Wf(e,t,s){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===s)break;e=e.return}}function fa(e,t){pu=e,Yp=ra=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(xn=!0),e.firstContext=null)}function Xn(e){var t=e._currentValue;if(Yp!==e)if(e={context:e,memoizedValue:t,next:null},ra===null){if(pu===null)throw Error(re(308));ra=e,pu.dependencies={lanes:0,firstContext:e}}else ra=ra.next=e;return t}var oi=null;function Jp(e){oi===null?oi=[e]:oi.push(e)}function l0(e,t,s,r){var i=t.interleaved;return i===null?(s.next=s,Jp(t)):(s.next=i.next,i.next=s),t.interleaved=s,Xs(e,r)}function Xs(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var hr=!1;function Xp(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function o0(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 Vs(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function kr(e,t,s){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,We&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Xs(e,s)}return i=r.interleaved,i===null?(t.next=t,Jp(r)):(t.next=i.next,i.next=t),r.interleaved=t,Xs(e,s)}function Dc(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,_p(e,s)}}function lj(e,t){var s=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,s===r)){var i=null,a=null;if(s=s.firstBaseUpdate,s!==null){do{var l={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};a===null?i=a=l:a=a.next=l,s=s.next}while(s!==null);a===null?i=a=t:a=a.next=t}else i=a=t;s={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function gu(e,t,s,r){var i=e.updateQueue;hr=!1;var a=i.firstBaseUpdate,l=i.lastBaseUpdate,o=i.shared.pending;if(o!==null){i.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?a=u:l.next=u,l=c;var f=e.alternate;f!==null&&(f=f.updateQueue,o=f.lastBaseUpdate,o!==l&&(o===null?f.firstBaseUpdate=u:o.next=u,f.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;l=0,f=u=c=null,o=a;do{var m=o.lane,p=o.eventTime;if((r&m)===m){f!==null&&(f=f.next={eventTime:p,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var v=e,w=o;switch(m=t,p=s,w.tag){case 1:if(v=w.payload,typeof v=="function"){d=v.call(p,d,m);break e}d=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=w.payload,m=typeof v=="function"?v.call(p,d,m):v,m==null)break e;d=ft({},d,m);break e;case 2:hr=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=i.effects,m===null?i.effects=[o]:m.push(o))}else p={eventTime:p,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},f===null?(u=f=p,c=d):f=f.next=p,l|=m;if(o=o.next,o===null){if(o=i.shared.pending,o===null)break;m=o,o=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(!0);if(f===null&&(c=d),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=f,t=i.shared.interleaved,t!==null){i=t;do l|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);vi|=l,e.lanes=l,e.memoizedState=d}}function oj(e,t,s){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=s,typeof i!="function")throw Error(re(191,i));i.call(r)}}}var yo={},Ts=Wr(yo),Vl=Wr(yo),Kl=Wr(yo);function ci(e){if(e===yo)throw Error(re(174));return e}function Zp(e,t){switch(nt(Kl,t),nt(Vl,e),nt(Ts,yo),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:kf(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=kf(t,e)}rt(Ts),nt(Ts,t)}function ka(){rt(Ts),rt(Vl),rt(Kl)}function c0(e){ci(Kl.current);var t=ci(Ts.current),s=kf(t,e.type);t!==s&&(nt(Vl,e),nt(Ts,s))}function eg(e){Vl.current===e&&(rt(Ts),rt(Vl))}var ct=Wr(0);function xu(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.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 fh=[];function tg(){for(var e=0;e<fh.length;e++)fh[e]._workInProgressVersionPrimary=null;fh.length=0}var Oc=ir.ReactCurrentDispatcher,mh=ir.ReactCurrentBatchConfig,xi=0,ht=null,Rt=null,Ot=null,vu=!1,Nl=!1,Gl=0,nR=0;function Jt(){throw Error(re(321))}function ng(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!ds(e[s],t[s]))return!1;return!0}function sg(e,t,s,r,i,a){if(xi=a,ht=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Oc.current=e===null||e.memoizedState===null?aR:lR,e=s(r,i),Nl){a=0;do{if(Nl=!1,Gl=0,25<=a)throw Error(re(301));a+=1,Ot=Rt=null,t.updateQueue=null,Oc.current=oR,e=s(r,i)}while(Nl)}if(Oc.current=ju,t=Rt!==null&&Rt.next!==null,xi=0,Ot=Rt=ht=null,vu=!1,t)throw Error(re(300));return e}function rg(){var e=Gl!==0;return Gl=0,e}function bs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?ht.memoizedState=Ot=e:Ot=Ot.next=e,Ot}function Zn(){if(Rt===null){var e=ht.alternate;e=e!==null?e.memoizedState:null}else e=Rt.next;var t=Ot===null?ht.memoizedState:Ot.next;if(t!==null)Ot=t,Rt=e;else{if(e===null)throw Error(re(310));Rt=e,e={memoizedState:Rt.memoizedState,baseState:Rt.baseState,baseQueue:Rt.baseQueue,queue:Rt.queue,next:null},Ot===null?ht.memoizedState=Ot=e:Ot=Ot.next=e}return Ot}function Yl(e,t){return typeof t=="function"?t(e):t}function ph(e){var t=Zn(),s=t.queue;if(s===null)throw Error(re(311));s.lastRenderedReducer=e;var r=Rt,i=r.baseQueue,a=s.pending;if(a!==null){if(i!==null){var l=i.next;i.next=a.next,a.next=l}r.baseQueue=i=a,s.pending=null}if(i!==null){a=i.next,r=r.baseState;var o=l=null,c=null,u=a;do{var f=u.lane;if((xi&f)===f)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 d={lane:f,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(o=c=d,l=r):c=c.next=d,ht.lanes|=f,vi|=f}u=u.next}while(u!==null&&u!==a);c===null?l=r:c.next=o,ds(r,t.memoizedState)||(xn=!0),t.memoizedState=r,t.baseState=l,t.baseQueue=c,s.lastRenderedState=r}if(e=s.interleaved,e!==null){i=e;do a=i.lane,ht.lanes|=a,vi|=a,i=i.next;while(i!==e)}else i===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function gh(e){var t=Zn(),s=t.queue;if(s===null)throw Error(re(311));s.lastRenderedReducer=e;var r=s.dispatch,i=s.pending,a=t.memoizedState;if(i!==null){s.pending=null;var l=i=i.next;do a=e(a,l.action),l=l.next;while(l!==i);ds(a,t.memoizedState)||(xn=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),s.lastRenderedState=a}return[a,r]}function u0(){}function d0(e,t){var s=ht,r=Zn(),i=t(),a=!ds(r.memoizedState,i);if(a&&(r.memoizedState=i,xn=!0),r=r.queue,ig(m0.bind(null,s,r,e),[e]),r.getSnapshot!==t||a||Ot!==null&&Ot.memoizedState.tag&1){if(s.flags|=2048,ql(9,f0.bind(null,s,r,i,t),void 0,null),Ft===null)throw Error(re(349));xi&30||h0(s,t,i)}return i}function h0(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=ht.updateQueue,t===null?(t={lastEffect:null,stores:null},ht.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function f0(e,t,s,r){t.value=s,t.getSnapshot=r,p0(t)&&g0(e)}function m0(e,t,s){return s(function(){p0(t)&&g0(e)})}function p0(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!ds(e,s)}catch{return!0}}function g0(e){var t=Xs(e,1);t!==null&&ls(t,e,1,-1)}function cj(e){var t=bs();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Yl,lastRenderedState:e},t.queue=e,e=e.dispatch=iR.bind(null,ht,e),[t.memoizedState,e]}function ql(e,t,s,r){return e={tag:e,create:t,destroy:s,deps:r,next:null},t=ht.updateQueue,t===null?(t={lastEffect:null,stores:null},ht.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(r=s.next,s.next=e,e.next=r,t.lastEffect=e)),e}function x0(){return Zn().memoizedState}function _c(e,t,s,r){var i=bs();ht.flags|=e,i.memoizedState=ql(1|t,s,void 0,r===void 0?null:r)}function Zu(e,t,s,r){var i=Zn();r=r===void 0?null:r;var a=void 0;if(Rt!==null){var l=Rt.memoizedState;if(a=l.destroy,r!==null&&ng(r,l.deps)){i.memoizedState=ql(t,s,a,r);return}}ht.flags|=e,i.memoizedState=ql(1|t,s,a,r)}function uj(e,t){return _c(8390656,8,e,t)}function ig(e,t){return Zu(2048,8,e,t)}function v0(e,t){return Zu(4,2,e,t)}function j0(e,t){return Zu(4,4,e,t)}function y0(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 w0(e,t,s){return s=s!=null?s.concat([e]):null,Zu(4,4,y0.bind(null,t,e),s)}function ag(){}function b0(e,t){var s=Zn();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&ng(t,r[1])?r[0]:(s.memoizedState=[e,t],e)}function k0(e,t){var s=Zn();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&ng(t,r[1])?r[0]:(e=e(),s.memoizedState=[e,t],e)}function S0(e,t,s){return xi&21?(ds(s,t)||(s=Tb(),ht.lanes|=s,vi|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,xn=!0),e.memoizedState=s)}function sR(e,t){var s=Je;Je=s!==0&&4>s?s:4,e(!0);var r=mh.transition;mh.transition={};try{e(!1),t()}finally{Je=s,mh.transition=r}}function N0(){return Zn().memoizedState}function rR(e,t,s){var r=Nr(e);if(s={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null},C0(e))E0(t,s);else if(s=l0(e,t,s,r),s!==null){var i=dn();ls(s,e,r,i),A0(s,t,r)}}function iR(e,t,s){var r=Nr(e),i={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null};if(C0(e))E0(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,s);if(i.hasEagerState=!0,i.eagerState=o,ds(o,l)){var c=t.interleaved;c===null?(i.next=i,Jp(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}s=l0(e,t,i,r),s!==null&&(i=dn(),ls(s,e,r,i),A0(s,t,r))}}function C0(e){var t=e.alternate;return e===ht||t!==null&&t===ht}function E0(e,t){Nl=vu=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function A0(e,t,s){if(s&4194240){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,_p(e,s)}}var ju={readContext:Xn,useCallback:Jt,useContext:Jt,useEffect:Jt,useImperativeHandle:Jt,useInsertionEffect:Jt,useLayoutEffect:Jt,useMemo:Jt,useReducer:Jt,useRef:Jt,useState:Jt,useDebugValue:Jt,useDeferredValue:Jt,useTransition:Jt,useMutableSource:Jt,useSyncExternalStore:Jt,useId:Jt,unstable_isNewReconciler:!1},aR={readContext:Xn,useCallback:function(e,t){return bs().memoizedState=[e,t===void 0?null:t],e},useContext:Xn,useEffect:uj,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,_c(4194308,4,y0.bind(null,t,e),s)},useLayoutEffect:function(e,t){return _c(4194308,4,e,t)},useInsertionEffect:function(e,t){return _c(4,2,e,t)},useMemo:function(e,t){var s=bs();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var r=bs();return t=s!==void 0?s(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=rR.bind(null,ht,e),[r.memoizedState,e]},useRef:function(e){var t=bs();return e={current:e},t.memoizedState=e},useState:cj,useDebugValue:ag,useDeferredValue:function(e){return bs().memoizedState=e},useTransition:function(){var e=cj(!1),t=e[0];return e=sR.bind(null,e[1]),bs().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var r=ht,i=bs();if(lt){if(s===void 0)throw Error(re(407));s=s()}else{if(s=t(),Ft===null)throw Error(re(349));xi&30||h0(r,t,s)}i.memoizedState=s;var a={value:s,getSnapshot:t};return i.queue=a,uj(m0.bind(null,r,a,e),[e]),r.flags|=2048,ql(9,f0.bind(null,r,a,s,t),void 0,null),s},useId:function(){var e=bs(),t=Ft.identifierPrefix;if(lt){var s=Hs,r=Ws;s=(r&~(1<<32-as(r)-1)).toString(32)+s,t=":"+t+"R"+s,s=Gl++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=nR++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},lR={readContext:Xn,useCallback:b0,useContext:Xn,useEffect:ig,useImperativeHandle:w0,useInsertionEffect:v0,useLayoutEffect:j0,useMemo:k0,useReducer:ph,useRef:x0,useState:function(){return ph(Yl)},useDebugValue:ag,useDeferredValue:function(e){var t=Zn();return S0(t,Rt.memoizedState,e)},useTransition:function(){var e=ph(Yl)[0],t=Zn().memoizedState;return[e,t]},useMutableSource:u0,useSyncExternalStore:d0,useId:N0,unstable_isNewReconciler:!1},oR={readContext:Xn,useCallback:b0,useContext:Xn,useEffect:ig,useImperativeHandle:w0,useInsertionEffect:v0,useLayoutEffect:j0,useMemo:k0,useReducer:gh,useRef:x0,useState:function(){return gh(Yl)},useDebugValue:ag,useDeferredValue:function(e){var t=Zn();return Rt===null?t.memoizedState=e:S0(t,Rt.memoizedState,e)},useTransition:function(){var e=gh(Yl)[0],t=Zn().memoizedState;return[e,t]},useMutableSource:u0,useSyncExternalStore:d0,useId:N0,unstable_isNewReconciler:!1};function ns(e,t){if(e&&e.defaultProps){t=ft({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function Hf(e,t,s,r){t=e.memoizedState,s=s(r,t),s=s==null?t:ft({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var ed={isMounted:function(e){return(e=e._reactInternals)?Ci(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var r=dn(),i=Nr(e),a=Vs(r,i);a.payload=t,s!=null&&(a.callback=s),t=kr(e,a,i),t!==null&&(ls(t,e,i,r),Dc(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var r=dn(),i=Nr(e),a=Vs(r,i);a.tag=1,a.payload=t,s!=null&&(a.callback=s),t=kr(e,a,i),t!==null&&(ls(t,e,i,r),Dc(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=dn(),r=Nr(e),i=Vs(s,r);i.tag=2,t!=null&&(i.callback=t),t=kr(e,i,r),t!==null&&(ls(t,e,r,s),Dc(t,e,r))}};function dj(e,t,s,r,i,a,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,a,l):t.prototype&&t.prototype.isPureReactComponent?!Bl(s,r)||!Bl(i,a):!0}function T0(e,t,s){var r=!1,i=Mr,a=t.contextType;return typeof a=="object"&&a!==null?a=Xn(a):(i=yn(t)?pi:nn.current,r=t.contextTypes,a=(r=r!=null)?ya(e,i):Mr),t=new t(s,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ed,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function hj(e,t,s,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,r),t.state!==e&&ed.enqueueReplaceState(t,t.state,null)}function Vf(e,t,s,r){var i=e.stateNode;i.props=s,i.state=e.memoizedState,i.refs={},Xp(e);var a=t.contextType;typeof a=="object"&&a!==null?i.context=Xn(a):(a=yn(t)?pi:nn.current,i.context=ya(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a=="function"&&(Hf(e,t,a,s),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&&ed.enqueueReplaceState(i,i.state,null),gu(e,s,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Sa(e,t){try{var s="",r=t;do s+=OA(r),r=r.return;while(r);var i=s}catch(a){i=`
39
- Error generating stack: `+a.message+`
40
- `+a.stack}return{value:e,source:t,stack:i,digest:null}}function xh(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function Kf(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var cR=typeof WeakMap=="function"?WeakMap:Map;function R0(e,t,s){s=Vs(-1,s),s.tag=3,s.payload={element:null};var r=t.value;return s.callback=function(){wu||(wu=!0,nm=r),Kf(e,t)},s}function I0(e,t,s){s=Vs(-1,s),s.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;s.payload=function(){return r(i)},s.callback=function(){Kf(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(s.callback=function(){Kf(e,t),typeof r!="function"&&(Sr===null?Sr=new Set([this]):Sr.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),s}function fj(e,t,s){var r=e.pingCache;if(r===null){r=e.pingCache=new cR;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(s)||(i.add(s),e=kR.bind(null,e,t,s),t.then(e,e))}function mj(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 pj(e,t,s,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=Vs(-1,1),t.tag=2,kr(s,t,1))),s.lanes|=1),e)}var uR=ir.ReactCurrentOwner,xn=!1;function on(e,t,s,r){t.child=e===null?a0(t,null,s,r):ba(t,e.child,s,r)}function gj(e,t,s,r,i){s=s.render;var a=t.ref;return fa(t,i),r=sg(e,t,s,r,a,i),s=rg(),e!==null&&!xn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Zs(e,t,i)):(lt&&s&&Vp(t),t.flags|=1,on(e,t,r,i),t.child)}function xj(e,t,s,r,i){if(e===null){var a=s.type;return typeof a=="function"&&!mg(a)&&a.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=a,P0(e,t,a,r,i)):(e=Bc(s.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!(e.lanes&i)){var l=a.memoizedProps;if(s=s.compare,s=s!==null?s:Bl,s(l,r)&&e.ref===t.ref)return Zs(e,t,i)}return t.flags|=1,e=Cr(a,r),e.ref=t.ref,e.return=t,t.child=e}function P0(e,t,s,r,i){if(e!==null){var a=e.memoizedProps;if(Bl(a,r)&&e.ref===t.ref)if(xn=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(xn=!0);else return t.lanes=e.lanes,Zs(e,t,i)}return Gf(e,t,s,r,i)}function M0(e,t,s){var r=t.pendingProps,i=r.children,a=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},nt(aa,Tn),Tn|=s;else{if(!(s&1073741824))return e=a!==null?a.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,nt(aa,Tn),Tn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a!==null?a.baseLanes:s,nt(aa,Tn),Tn|=r}else a!==null?(r=a.baseLanes|s,t.memoizedState=null):r=s,nt(aa,Tn),Tn|=r;return on(e,t,i,s),t.child}function $0(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function Gf(e,t,s,r,i){var a=yn(s)?pi:nn.current;return a=ya(t,a),fa(t,i),s=sg(e,t,s,r,a,i),r=rg(),e!==null&&!xn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Zs(e,t,i)):(lt&&r&&Vp(t),t.flags|=1,on(e,t,s,i),t.child)}function vj(e,t,s,r,i){if(yn(s)){var a=!0;du(t)}else a=!1;if(fa(t,i),t.stateNode===null)Lc(e,t),T0(t,s,r),Vf(t,s,r,i),r=!0;else if(e===null){var l=t.stateNode,o=t.memoizedProps;l.props=o;var c=l.context,u=s.contextType;typeof u=="object"&&u!==null?u=Xn(u):(u=yn(s)?pi:nn.current,u=ya(t,u));var f=s.getDerivedStateFromProps,d=typeof f=="function"||typeof l.getSnapshotBeforeUpdate=="function";d||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==r||c!==u)&&hj(t,l,r,u),hr=!1;var m=t.memoizedState;l.state=m,gu(t,r,l,i),c=t.memoizedState,o!==r||m!==c||jn.current||hr?(typeof f=="function"&&(Hf(t,s,f,r),c=t.memoizedState),(o=hr||dj(t,s,o,r,m,c,u))?(d||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4194308)):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),l.props=r,l.state=c,l.context=u,r=o):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,o0(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:ns(t.type,o),l.props=u,d=t.pendingProps,m=l.context,c=s.contextType,typeof c=="object"&&c!==null?c=Xn(c):(c=yn(s)?pi:nn.current,c=ya(t,c));var p=s.getDerivedStateFromProps;(f=typeof p=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==d||m!==c)&&hj(t,l,r,c),hr=!1,m=t.memoizedState,l.state=m,gu(t,r,l,i);var v=t.memoizedState;o!==d||m!==v||jn.current||hr?(typeof p=="function"&&(Hf(t,s,p,r),v=t.memoizedState),(u=hr||dj(t,s,u,r,m,v,c)||!1)?(f||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,v,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,v,c)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=v),l.props=r,l.state=v,l.context=c,r=u):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return Yf(e,t,s,r,a,i)}function Yf(e,t,s,r,i,a){$0(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return i&&sj(t,s,!1),Zs(e,t,a);r=t.stateNode,uR.current=t;var o=l&&typeof s.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=ba(t,e.child,null,a),t.child=ba(t,null,o,a)):on(e,t,o,a),t.memoizedState=r.state,i&&sj(t,s,!0),t.child}function D0(e){var t=e.stateNode;t.pendingContext?nj(e,t.pendingContext,t.pendingContext!==t.context):t.context&&nj(e,t.context,!1),Zp(e,t.containerInfo)}function jj(e,t,s,r,i){return wa(),Gp(i),t.flags|=256,on(e,t,s,r),t.child}var qf={dehydrated:null,treeContext:null,retryLane:0};function Qf(e){return{baseLanes:e,cachePool:null,transitions:null}}function O0(e,t,s){var r=t.pendingProps,i=ct.current,a=!1,l=(t.flags&128)!==0,o;if((o=l)||(o=e!==null&&e.memoizedState===null?!1:(i&2)!==0),o?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),nt(ct,i&1),e===null)return zf(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):(l=r.children,e=r.fallback,a?(r=t.mode,a=t.child,l={mode:"hidden",children:l},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=l):a=sd(l,r,0,null),e=di(e,r,s,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Qf(s),t.memoizedState=qf,e):lg(t,l));if(i=e.memoizedState,i!==null&&(o=i.dehydrated,o!==null))return dR(e,t,l,r,o,i,s);if(a){a=r.fallback,l=t.mode,i=e.child,o=i.sibling;var c={mode:"hidden",children:r.children};return!(l&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Cr(i,c),r.subtreeFlags=i.subtreeFlags&14680064),o!==null?a=Cr(o,a):(a=di(a,l,s,null),a.flags|=2),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,l=e.child.memoizedState,l=l===null?Qf(s):{baseLanes:l.baseLanes|s,cachePool:null,transitions:l.transitions},a.memoizedState=l,a.childLanes=e.childLanes&~s,t.memoizedState=qf,r}return a=e.child,e=a.sibling,r=Cr(a,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=s),r.return=t,r.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=r,t.memoizedState=null,r}function lg(e,t){return t=sd({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Zo(e,t,s,r){return r!==null&&Gp(r),ba(t,e.child,null,s),e=lg(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function dR(e,t,s,r,i,a,l){if(s)return t.flags&256?(t.flags&=-257,r=xh(Error(re(422))),Zo(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(a=r.fallback,i=t.mode,r=sd({mode:"visible",children:r.children},i,0,null),a=di(a,i,l,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,t.mode&1&&ba(t,e.child,null,l),t.child.memoizedState=Qf(l),t.memoizedState=qf,a);if(!(t.mode&1))return Zo(e,t,l,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var o=r.dgst;return r=o,a=Error(re(419)),r=xh(a,r,void 0),Zo(e,t,l,r)}if(o=(l&e.childLanes)!==0,xn||o){if(r=Ft,r!==null){switch(l&-l){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|l)?0:i,i!==0&&i!==a.retryLane&&(a.retryLane=i,Xs(e,i),ls(r,e,i,-1))}return fg(),r=xh(Error(re(421))),Zo(e,t,l,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=SR.bind(null,e),i._reactRetry=t,null):(e=a.treeContext,In=br(i.nextSibling),Mn=t,lt=!0,rs=null,e!==null&&(Kn[Gn++]=Ws,Kn[Gn++]=Hs,Kn[Gn++]=gi,Ws=e.id,Hs=e.overflow,gi=t),t=lg(t,r.children),t.flags|=4096,t)}function yj(e,t,s){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Wf(e.return,t,s)}function vh(e,t,s,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:s,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=s,a.tailMode=i)}function _0(e,t,s){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(on(e,t,r.children,s),r=ct.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&&yj(e,s,t);else if(e.tag===19)yj(e,s,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(nt(ct,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(s=t.child,i=null;s!==null;)e=s.alternate,e!==null&&xu(e)===null&&(i=s),s=s.sibling;s=i,s===null?(i=t.child,t.child=null):(i=s.sibling,s.sibling=null),vh(t,!1,i,s,a);break;case"backwards":for(s=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&xu(e)===null){t.child=i;break}e=i.sibling,i.sibling=s,s=i,i=e}vh(t,!0,s,null,a);break;case"together":vh(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Lc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Zs(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),vi|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(re(153));if(t.child!==null){for(e=t.child,s=Cr(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Cr(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function hR(e,t,s){switch(t.tag){case 3:D0(t),wa();break;case 5:c0(t);break;case 1:yn(t.type)&&du(t);break;case 4:Zp(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;nt(mu,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(nt(ct,ct.current&1),t.flags|=128,null):s&t.child.childLanes?O0(e,t,s):(nt(ct,ct.current&1),e=Zs(e,t,s),e!==null?e.sibling:null);nt(ct,ct.current&1);break;case 19:if(r=(s&t.childLanes)!==0,e.flags&128){if(r)return _0(e,t,s);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),nt(ct,ct.current),r)break;return null;case 22:case 23:return t.lanes=0,M0(e,t,s)}return Zs(e,t,s)}var L0,Jf,F0,U0;L0=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};Jf=function(){};F0=function(e,t,s,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,ci(Ts.current);var a=null;switch(s){case"input":i=jf(e,i),r=jf(e,r),a=[];break;case"select":i=ft({},i,{value:void 0}),r=ft({},r,{value:void 0}),a=[];break;case"textarea":i=bf(e,i),r=bf(e,r),a=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=cu)}Sf(s,r);var l;s=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var o=i[u];for(l in o)o.hasOwnProperty(l)&&(s||(s={}),s[l]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&($l.hasOwnProperty(u)?a||(a=[]):(a=a||[]).push(u,null));for(u in r){var c=r[u];if(o=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==o&&(c!=null||o!=null))if(u==="style")if(o){for(l in o)!o.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(s||(s={}),s[l]="");for(l in c)c.hasOwnProperty(l)&&o[l]!==c[l]&&(s||(s={}),s[l]=c[l])}else s||(a||(a=[]),a.push(u,s)),s=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,o=o?o.__html:void 0,c!=null&&o!==c&&(a=a||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(a=a||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&($l.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&st("scroll",e),a||o===c||(a=[])):(a=a||[]).push(u,c))}s&&(a=a||[]).push("style",s);var u=a;(t.updateQueue=u)&&(t.flags|=4)}};U0=function(e,t,s,r){s!==r&&(t.flags|=4)};function ll(e,t){if(!lt)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var r=null;s!==null;)s.alternate!==null&&(r=s),s=s.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Xt(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,r=0;if(t)for(var i=e.child;i!==null;)s|=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;)s|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=s,t}function fR(e,t,s){var r=t.pendingProps;switch(Kp(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xt(t),null;case 1:return yn(t.type)&&uu(),Xt(t),null;case 3:return r=t.stateNode,ka(),rt(jn),rt(nn),tg(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Jo(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,rs!==null&&(im(rs),rs=null))),Jf(e,t),Xt(t),null;case 5:eg(t);var i=ci(Kl.current);if(s=t.type,e!==null&&t.stateNode!=null)F0(e,t,s,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(re(166));return Xt(t),null}if(e=ci(Ts.current),Jo(t)){r=t.stateNode,s=t.type;var a=t.memoizedProps;switch(r[Ss]=t,r[Hl]=a,e=(t.mode&1)!==0,s){case"dialog":st("cancel",r),st("close",r);break;case"iframe":case"object":case"embed":st("load",r);break;case"video":case"audio":for(i=0;i<xl.length;i++)st(xl[i],r);break;case"source":st("error",r);break;case"img":case"image":case"link":st("error",r),st("load",r);break;case"details":st("toggle",r);break;case"input":Tv(r,a),st("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},st("invalid",r);break;case"textarea":Iv(r,a),st("invalid",r)}Sf(s,a),i=null;for(var l in a)if(a.hasOwnProperty(l)){var o=a[l];l==="children"?typeof o=="string"?r.textContent!==o&&(a.suppressHydrationWarning!==!0&&Qo(r.textContent,o,e),i=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(a.suppressHydrationWarning!==!0&&Qo(r.textContent,o,e),i=["children",""+o]):$l.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&st("scroll",r)}switch(s){case"input":zo(r),Rv(r,a,!0);break;case"textarea":zo(r),Pv(r);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(r.onclick=cu)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{l=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=mb(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(s,{is:r.is}):(e=l.createElement(s),s==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,s),e[Ss]=t,e[Hl]=r,L0(e,t,!1,!1),t.stateNode=e;e:{switch(l=Nf(s,r),s){case"dialog":st("cancel",e),st("close",e),i=r;break;case"iframe":case"object":case"embed":st("load",e),i=r;break;case"video":case"audio":for(i=0;i<xl.length;i++)st(xl[i],e);i=r;break;case"source":st("error",e),i=r;break;case"img":case"image":case"link":st("error",e),st("load",e),i=r;break;case"details":st("toggle",e),i=r;break;case"input":Tv(e,r),i=jf(e,r),st("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=ft({},r,{value:void 0}),st("invalid",e);break;case"textarea":Iv(e,r),i=bf(e,r),st("invalid",e);break;default:i=r}Sf(s,i),o=i;for(a in o)if(o.hasOwnProperty(a)){var c=o[a];a==="style"?xb(e,c):a==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&pb(e,c)):a==="children"?typeof c=="string"?(s!=="textarea"||c!=="")&&Dl(e,c):typeof c=="number"&&Dl(e,""+c):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&($l.hasOwnProperty(a)?c!=null&&a==="onScroll"&&st("scroll",e):c!=null&&Ip(e,a,c,l))}switch(s){case"input":zo(e),Rv(e,r,!1);break;case"textarea":zo(e),Pv(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Pr(r.value));break;case"select":e.multiple=!!r.multiple,a=r.value,a!=null?ca(e,!!r.multiple,a,!1):r.defaultValue!=null&&ca(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=cu)}switch(s){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 Xt(t),null;case 6:if(e&&t.stateNode!=null)U0(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(re(166));if(s=ci(Kl.current),ci(Ts.current),Jo(t)){if(r=t.stateNode,s=t.memoizedProps,r[Ss]=t,(a=r.nodeValue!==s)&&(e=Mn,e!==null))switch(e.tag){case 3:Qo(r.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Qo(r.nodeValue,s,(e.mode&1)!==0)}a&&(t.flags|=4)}else r=(s.nodeType===9?s:s.ownerDocument).createTextNode(r),r[Ss]=t,t.stateNode=r}return Xt(t),null;case 13:if(rt(ct),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(lt&&In!==null&&t.mode&1&&!(t.flags&128))r0(),wa(),t.flags|=98560,a=!1;else if(a=Jo(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(re(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(re(317));a[Ss]=t}else wa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Xt(t),a=!1}else rs!==null&&(im(rs),rs=null),a=!0;if(!a)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||ct.current&1?Mt===0&&(Mt=3):fg())),t.updateQueue!==null&&(t.flags|=4),Xt(t),null);case 4:return ka(),Jf(e,t),e===null&&zl(t.stateNode.containerInfo),Xt(t),null;case 10:return Qp(t.type._context),Xt(t),null;case 17:return yn(t.type)&&uu(),Xt(t),null;case 19:if(rt(ct),a=t.memoizedState,a===null)return Xt(t),null;if(r=(t.flags&128)!==0,l=a.rendering,l===null)if(r)ll(a,!1);else{if(Mt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=xu(e),l!==null){for(t.flags|=128,ll(a,!1),r=l.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=s,s=t.child;s!==null;)a=s,e=r,a.flags&=14680066,l=a.alternate,l===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=l.childLanes,a.lanes=l.lanes,a.child=l.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=l.memoizedProps,a.memoizedState=l.memoizedState,a.updateQueue=l.updateQueue,a.type=l.type,e=l.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return nt(ct,ct.current&1|2),t.child}e=e.sibling}a.tail!==null&&bt()>Na&&(t.flags|=128,r=!0,ll(a,!1),t.lanes=4194304)}else{if(!r)if(e=xu(l),e!==null){if(t.flags|=128,r=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),ll(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!lt)return Xt(t),null}else 2*bt()-a.renderingStartTime>Na&&s!==1073741824&&(t.flags|=128,r=!0,ll(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(s=a.last,s!==null?s.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=bt(),t.sibling=null,s=ct.current,nt(ct,r?s&1|2:s&1),t):(Xt(t),null);case 22:case 23:return hg(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Tn&1073741824&&(Xt(t),t.subtreeFlags&6&&(t.flags|=8192)):Xt(t),null;case 24:return null;case 25:return null}throw Error(re(156,t.tag))}function mR(e,t){switch(Kp(t),t.tag){case 1:return yn(t.type)&&uu(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ka(),rt(jn),rt(nn),tg(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return eg(t),null;case 13:if(rt(ct),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(re(340));wa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return rt(ct),null;case 4:return ka(),null;case 10:return Qp(t.type._context),null;case 22:case 23:return hg(),null;case 24:return null;default:return null}}var ec=!1,en=!1,pR=typeof WeakSet=="function"?WeakSet:Set,ge=null;function ia(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(r){vt(e,t,r)}else s.current=null}function Xf(e,t,s){try{s()}catch(r){vt(e,t,r)}}var wj=!1;function gR(e,t){if(Df=au,e=Vb(),Hp(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var r=s.getSelection&&s.getSelection();if(r&&r.rangeCount!==0){s=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{s.nodeType,a.nodeType}catch{s=null;break e}var l=0,o=-1,c=-1,u=0,f=0,d=e,m=null;t:for(;;){for(var p;d!==s||i!==0&&d.nodeType!==3||(o=l+i),d!==a||r!==0&&d.nodeType!==3||(c=l+r),d.nodeType===3&&(l+=d.nodeValue.length),(p=d.firstChild)!==null;)m=d,d=p;for(;;){if(d===e)break t;if(m===s&&++u===i&&(o=l),m===a&&++f===r&&(c=l),(p=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=p}s=o===-1||c===-1?null:{start:o,end:c}}else s=null}s=s||{start:0,end:0}}else s=null;for(Of={focusedElem:e,selectionRange:s},au=!1,ge=t;ge!==null;)if(t=ge,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ge=e;else for(;ge!==null;){t=ge;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var w=v.memoizedProps,k=v.memoizedState,g=t.stateNode,x=g.getSnapshotBeforeUpdate(t.elementType===t.type?w:ns(t.type,w),k);g.__reactInternalSnapshotBeforeUpdate=x}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(re(163))}}catch(j){vt(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,ge=e;break}ge=t.return}return v=wj,wj=!1,v}function Cl(e,t,s){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 a=i.destroy;i.destroy=void 0,a!==void 0&&Xf(t,s,a)}i=i.next}while(i!==r)}}function td(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var r=s.create;s.destroy=r()}s=s.next}while(s!==t)}}function Zf(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function B0(e){var t=e.alternate;t!==null&&(e.alternate=null,B0(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ss],delete t[Hl],delete t[Ff],delete t[XT],delete t[ZT])),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 z0(e){return e.tag===5||e.tag===3||e.tag===4}function bj(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||z0(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 em(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=cu));else if(r!==4&&(e=e.child,e!==null))for(em(e,t,s),e=e.sibling;e!==null;)em(e,t,s),e=e.sibling}function tm(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(tm(e,t,s),e=e.sibling;e!==null;)tm(e,t,s),e=e.sibling}var Wt=null,ss=!1;function cr(e,t,s){for(s=s.child;s!==null;)W0(e,t,s),s=s.sibling}function W0(e,t,s){if(As&&typeof As.onCommitFiberUnmount=="function")try{As.onCommitFiberUnmount(Gu,s)}catch{}switch(s.tag){case 5:en||ia(s,t);case 6:var r=Wt,i=ss;Wt=null,cr(e,t,s),Wt=r,ss=i,Wt!==null&&(ss?(e=Wt,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):Wt.removeChild(s.stateNode));break;case 18:Wt!==null&&(ss?(e=Wt,s=s.stateNode,e.nodeType===8?dh(e.parentNode,s):e.nodeType===1&&dh(e,s),Fl(e)):dh(Wt,s.stateNode));break;case 4:r=Wt,i=ss,Wt=s.stateNode.containerInfo,ss=!0,cr(e,t,s),Wt=r,ss=i;break;case 0:case 11:case 14:case 15:if(!en&&(r=s.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&Xf(s,t,l),i=i.next}while(i!==r)}cr(e,t,s);break;case 1:if(!en&&(ia(s,t),r=s.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=s.memoizedProps,r.state=s.memoizedState,r.componentWillUnmount()}catch(o){vt(s,t,o)}cr(e,t,s);break;case 21:cr(e,t,s);break;case 22:s.mode&1?(en=(r=en)||s.memoizedState!==null,cr(e,t,s),en=r):cr(e,t,s);break;default:cr(e,t,s)}}function kj(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new pR),t.forEach(function(r){var i=NR.bind(null,e,r);s.has(r)||(s.add(r),r.then(i,i))})}}function ts(e,t){var s=t.deletions;if(s!==null)for(var r=0;r<s.length;r++){var i=s[r];try{var a=e,l=t,o=l;e:for(;o!==null;){switch(o.tag){case 5:Wt=o.stateNode,ss=!1;break e;case 3:Wt=o.stateNode.containerInfo,ss=!0;break e;case 4:Wt=o.stateNode.containerInfo,ss=!0;break e}o=o.return}if(Wt===null)throw Error(re(160));W0(a,l,i),Wt=null,ss=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){vt(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)H0(t,e),t=t.sibling}function H0(e,t){var s=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(ts(t,e),ys(e),r&4){try{Cl(3,e,e.return),td(3,e)}catch(w){vt(e,e.return,w)}try{Cl(5,e,e.return)}catch(w){vt(e,e.return,w)}}break;case 1:ts(t,e),ys(e),r&512&&s!==null&&ia(s,s.return);break;case 5:if(ts(t,e),ys(e),r&512&&s!==null&&ia(s,s.return),e.flags&32){var i=e.stateNode;try{Dl(i,"")}catch(w){vt(e,e.return,w)}}if(r&4&&(i=e.stateNode,i!=null)){var a=e.memoizedProps,l=s!==null?s.memoizedProps:a,o=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{o==="input"&&a.type==="radio"&&a.name!=null&&hb(i,a),Nf(o,l);var u=Nf(o,a);for(l=0;l<c.length;l+=2){var f=c[l],d=c[l+1];f==="style"?xb(i,d):f==="dangerouslySetInnerHTML"?pb(i,d):f==="children"?Dl(i,d):Ip(i,f,d,u)}switch(o){case"input":yf(i,a);break;case"textarea":fb(i,a);break;case"select":var m=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!a.multiple;var p=a.value;p!=null?ca(i,!!a.multiple,p,!1):m!==!!a.multiple&&(a.defaultValue!=null?ca(i,!!a.multiple,a.defaultValue,!0):ca(i,!!a.multiple,a.multiple?[]:"",!1))}i[Hl]=a}catch(w){vt(e,e.return,w)}}break;case 6:if(ts(t,e),ys(e),r&4){if(e.stateNode===null)throw Error(re(162));i=e.stateNode,a=e.memoizedProps;try{i.nodeValue=a}catch(w){vt(e,e.return,w)}}break;case 3:if(ts(t,e),ys(e),r&4&&s!==null&&s.memoizedState.isDehydrated)try{Fl(t.containerInfo)}catch(w){vt(e,e.return,w)}break;case 4:ts(t,e),ys(e);break;case 13:ts(t,e),ys(e),i=e.child,i.flags&8192&&(a=i.memoizedState!==null,i.stateNode.isHidden=a,!a||i.alternate!==null&&i.alternate.memoizedState!==null||(ug=bt())),r&4&&kj(e);break;case 22:if(f=s!==null&&s.memoizedState!==null,e.mode&1?(en=(u=en)||f,ts(t,e),en=u):ts(t,e),ys(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(ge=e,f=e.child;f!==null;){for(d=ge=f;ge!==null;){switch(m=ge,p=m.child,m.tag){case 0:case 11:case 14:case 15:Cl(4,m,m.return);break;case 1:ia(m,m.return);var v=m.stateNode;if(typeof v.componentWillUnmount=="function"){r=m,s=m.return;try{t=r,v.props=t.memoizedProps,v.state=t.memoizedState,v.componentWillUnmount()}catch(w){vt(r,s,w)}}break;case 5:ia(m,m.return);break;case 22:if(m.memoizedState!==null){Nj(d);continue}}p!==null?(p.return=m,ge=p):Nj(d)}f=f.sibling}e:for(f=null,d=e;;){if(d.tag===5){if(f===null){f=d;try{i=d.stateNode,u?(a=i.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(o=d.stateNode,c=d.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,o.style.display=gb("display",l))}catch(w){vt(e,e.return,w)}}}else if(d.tag===6){if(f===null)try{d.stateNode.nodeValue=u?"":d.memoizedProps}catch(w){vt(e,e.return,w)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;f===d&&(f=null),d=d.return}f===d&&(f=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:ts(t,e),ys(e),r&4&&kj(e);break;case 21:break;default:ts(t,e),ys(e)}}function ys(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(z0(s)){var r=s;break e}s=s.return}throw Error(re(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Dl(i,""),r.flags&=-33);var a=bj(e);tm(e,a,i);break;case 3:case 4:var l=r.stateNode.containerInfo,o=bj(e);em(e,o,l);break;default:throw Error(re(161))}}catch(c){vt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function xR(e,t,s){ge=e,V0(e)}function V0(e,t,s){for(var r=(e.mode&1)!==0;ge!==null;){var i=ge,a=i.child;if(i.tag===22&&r){var l=i.memoizedState!==null||ec;if(!l){var o=i.alternate,c=o!==null&&o.memoizedState!==null||en;o=ec;var u=en;if(ec=l,(en=c)&&!u)for(ge=i;ge!==null;)l=ge,c=l.child,l.tag===22&&l.memoizedState!==null?Cj(i):c!==null?(c.return=l,ge=c):Cj(i);for(;a!==null;)ge=a,V0(a),a=a.sibling;ge=i,ec=o,en=u}Sj(e)}else i.subtreeFlags&8772&&a!==null?(a.return=i,ge=a):Sj(e)}}function Sj(e){for(;ge!==null;){var t=ge;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:en||td(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!en)if(s===null)r.componentDidMount();else{var i=t.elementType===t.type?s.memoizedProps:ns(t.type,s.memoizedProps);r.componentDidUpdate(i,s.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;a!==null&&oj(t,a,r);break;case 3:var l=t.updateQueue;if(l!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}oj(t,l,s)}break;case 5:var o=t.stateNode;if(s===null&&t.flags&4){s=o;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&s.focus();break;case"img":c.src&&(s.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 f=u.memoizedState;if(f!==null){var d=f.dehydrated;d!==null&&Fl(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(re(163))}en||t.flags&512&&Zf(t)}catch(m){vt(t,t.return,m)}}if(t===e){ge=null;break}if(s=t.sibling,s!==null){s.return=t.return,ge=s;break}ge=t.return}}function Nj(e){for(;ge!==null;){var t=ge;if(t===e){ge=null;break}var s=t.sibling;if(s!==null){s.return=t.return,ge=s;break}ge=t.return}}function Cj(e){for(;ge!==null;){var t=ge;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{td(4,t)}catch(c){vt(t,s,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){vt(t,i,c)}}var a=t.return;try{Zf(t)}catch(c){vt(t,a,c)}break;case 5:var l=t.return;try{Zf(t)}catch(c){vt(t,l,c)}}}catch(c){vt(t,t.return,c)}if(t===e){ge=null;break}var o=t.sibling;if(o!==null){o.return=t.return,ge=o;break}ge=t.return}}var vR=Math.ceil,yu=ir.ReactCurrentDispatcher,og=ir.ReactCurrentOwner,Jn=ir.ReactCurrentBatchConfig,We=0,Ft=null,St=null,Ht=0,Tn=0,aa=Wr(0),Mt=0,Ql=null,vi=0,nd=0,cg=0,El=null,gn=null,ug=0,Na=1/0,Fs=null,wu=!1,nm=null,Sr=null,tc=!1,gr=null,bu=0,Al=0,sm=null,Fc=-1,Uc=0;function dn(){return We&6?bt():Fc!==-1?Fc:Fc=bt()}function Nr(e){return e.mode&1?We&2&&Ht!==0?Ht&-Ht:tR.transition!==null?(Uc===0&&(Uc=Tb()),Uc):(e=Je,e!==0||(e=window.event,e=e===void 0?16:Ob(e.type)),e):1}function ls(e,t,s,r){if(50<Al)throw Al=0,sm=null,Error(re(185));xo(e,s,r),(!(We&2)||e!==Ft)&&(e===Ft&&(!(We&2)&&(nd|=s),Mt===4&&mr(e,Ht)),wn(e,r),s===1&&We===0&&!(t.mode&1)&&(Na=bt()+500,Xu&&Hr()))}function wn(e,t){var s=e.callbackNode;tT(e,t);var r=iu(e,e===Ft?Ht:0);if(r===0)s!==null&&Dv(s),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(s!=null&&Dv(s),t===1)e.tag===0?eR(Ej.bind(null,e)):t0(Ej.bind(null,e)),QT(function(){!(We&6)&&Hr()}),s=null;else{switch(Rb(r)){case 1:s=Op;break;case 4:s=Eb;break;case 16:s=ru;break;case 536870912:s=Ab;break;default:s=ru}s=Z0(s,K0.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function K0(e,t){if(Fc=-1,Uc=0,We&6)throw Error(re(327));var s=e.callbackNode;if(ma()&&e.callbackNode!==s)return null;var r=iu(e,e===Ft?Ht:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=ku(e,r);else{t=r;var i=We;We|=2;var a=Y0();(Ft!==e||Ht!==t)&&(Fs=null,Na=bt()+500,ui(e,t));do try{wR();break}catch(o){G0(e,o)}while(!0);qp(),yu.current=a,We=i,St!==null?t=0:(Ft=null,Ht=0,t=Mt)}if(t!==0){if(t===2&&(i=Rf(e),i!==0&&(r=i,t=rm(e,i))),t===1)throw s=Ql,ui(e,0),mr(e,r),wn(e,bt()),s;if(t===6)mr(e,r);else{if(i=e.current.alternate,!(r&30)&&!jR(i)&&(t=ku(e,r),t===2&&(a=Rf(e),a!==0&&(r=a,t=rm(e,a))),t===1))throw s=Ql,ui(e,0),mr(e,r),wn(e,bt()),s;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(re(345));case 2:ri(e,gn,Fs);break;case 3:if(mr(e,r),(r&130023424)===r&&(t=ug+500-bt(),10<t)){if(iu(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){dn(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=Lf(ri.bind(null,e,gn,Fs),t);break}ri(e,gn,Fs);break;case 4:if(mr(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var l=31-as(r);a=1<<l,l=t[l],l>i&&(i=l),r&=~a}if(r=i,r=bt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*vR(r/1960))-r,10<r){e.timeoutHandle=Lf(ri.bind(null,e,gn,Fs),r);break}ri(e,gn,Fs);break;case 5:ri(e,gn,Fs);break;default:throw Error(re(329))}}}return wn(e,bt()),e.callbackNode===s?K0.bind(null,e):null}function rm(e,t){var s=El;return e.current.memoizedState.isDehydrated&&(ui(e,t).flags|=256),e=ku(e,t),e!==2&&(t=gn,gn=s,t!==null&&im(t)),e}function im(e){gn===null?gn=e:gn.push.apply(gn,e)}function jR(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var r=0;r<s.length;r++){var i=s[r],a=i.getSnapshot;i=i.value;try{if(!ds(a(),i))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;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 mr(e,t){for(t&=~cg,t&=~nd,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-as(t),r=1<<s;e[s]=-1,t&=~r}}function Ej(e){if(We&6)throw Error(re(327));ma();var t=iu(e,0);if(!(t&1))return wn(e,bt()),null;var s=ku(e,t);if(e.tag!==0&&s===2){var r=Rf(e);r!==0&&(t=r,s=rm(e,r))}if(s===1)throw s=Ql,ui(e,0),mr(e,t),wn(e,bt()),s;if(s===6)throw Error(re(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ri(e,gn,Fs),wn(e,bt()),null}function dg(e,t){var s=We;We|=1;try{return e(t)}finally{We=s,We===0&&(Na=bt()+500,Xu&&Hr())}}function ji(e){gr!==null&&gr.tag===0&&!(We&6)&&ma();var t=We;We|=1;var s=Jn.transition,r=Je;try{if(Jn.transition=null,Je=1,e)return e()}finally{Je=r,Jn.transition=s,We=t,!(We&6)&&Hr()}}function hg(){Tn=aa.current,rt(aa)}function ui(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,qT(s)),St!==null)for(s=St.return;s!==null;){var r=s;switch(Kp(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&uu();break;case 3:ka(),rt(jn),rt(nn),tg();break;case 5:eg(r);break;case 4:ka();break;case 13:rt(ct);break;case 19:rt(ct);break;case 10:Qp(r.type._context);break;case 22:case 23:hg()}s=s.return}if(Ft=e,St=e=Cr(e.current,null),Ht=Tn=t,Mt=0,Ql=null,cg=nd=vi=0,gn=El=null,oi!==null){for(t=0;t<oi.length;t++)if(s=oi[t],r=s.interleaved,r!==null){s.interleaved=null;var i=r.next,a=s.pending;if(a!==null){var l=a.next;a.next=i,r.next=l}s.pending=r}oi=null}return e}function G0(e,t){do{var s=St;try{if(qp(),Oc.current=ju,vu){for(var r=ht.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}vu=!1}if(xi=0,Ot=Rt=ht=null,Nl=!1,Gl=0,og.current=null,s===null||s.return===null){Mt=1,Ql=t,St=null;break}e:{var a=e,l=s.return,o=s,c=t;if(t=Ht,o.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,f=o,d=f.tag;if(!(f.mode&1)&&(d===0||d===11||d===15)){var m=f.alternate;m?(f.updateQueue=m.updateQueue,f.memoizedState=m.memoizedState,f.lanes=m.lanes):(f.updateQueue=null,f.memoizedState=null)}var p=mj(l);if(p!==null){p.flags&=-257,pj(p,l,o,a,t),p.mode&1&&fj(a,u,t),t=p,c=u;var v=t.updateQueue;if(v===null){var w=new Set;w.add(c),t.updateQueue=w}else v.add(c);break e}else{if(!(t&1)){fj(a,u,t),fg();break e}c=Error(re(426))}}else if(lt&&o.mode&1){var k=mj(l);if(k!==null){!(k.flags&65536)&&(k.flags|=256),pj(k,l,o,a,t),Gp(Sa(c,o));break e}}a=c=Sa(c,o),Mt!==4&&(Mt=2),El===null?El=[a]:El.push(a),a=l;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t;var g=R0(a,c,t);lj(a,g);break e;case 1:o=c;var x=a.type,y=a.stateNode;if(!(a.flags&128)&&(typeof x.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Sr===null||!Sr.has(y)))){a.flags|=65536,t&=-t,a.lanes|=t;var j=I0(a,o,t);lj(a,j);break e}}a=a.return}while(a!==null)}Q0(s)}catch(N){t=N,St===s&&s!==null&&(St=s=s.return);continue}break}while(!0)}function Y0(){var e=yu.current;return yu.current=ju,e===null?ju:e}function fg(){(Mt===0||Mt===3||Mt===2)&&(Mt=4),Ft===null||!(vi&268435455)&&!(nd&268435455)||mr(Ft,Ht)}function ku(e,t){var s=We;We|=2;var r=Y0();(Ft!==e||Ht!==t)&&(Fs=null,ui(e,t));do try{yR();break}catch(i){G0(e,i)}while(!0);if(qp(),We=s,yu.current=r,St!==null)throw Error(re(261));return Ft=null,Ht=0,Mt}function yR(){for(;St!==null;)q0(St)}function wR(){for(;St!==null&&!KA();)q0(St)}function q0(e){var t=X0(e.alternate,e,Tn);e.memoizedProps=e.pendingProps,t===null?Q0(e):St=t,og.current=null}function Q0(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=mR(s,t),s!==null){s.flags&=32767,St=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Mt=6,St=null;return}}else if(s=fR(s,t,Tn),s!==null){St=s;return}if(t=t.sibling,t!==null){St=t;return}St=t=e}while(t!==null);Mt===0&&(Mt=5)}function ri(e,t,s){var r=Je,i=Jn.transition;try{Jn.transition=null,Je=1,bR(e,t,s,r)}finally{Jn.transition=i,Je=r}return null}function bR(e,t,s,r){do ma();while(gr!==null);if(We&6)throw Error(re(327));s=e.finishedWork;var i=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(re(177));e.callbackNode=null,e.callbackPriority=0;var a=s.lanes|s.childLanes;if(nT(e,a),e===Ft&&(St=Ft=null,Ht=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||tc||(tc=!0,Z0(ru,function(){return ma(),null})),a=(s.flags&15990)!==0,s.subtreeFlags&15990||a){a=Jn.transition,Jn.transition=null;var l=Je;Je=1;var o=We;We|=4,og.current=null,gR(e,s),H0(s,e),zT(Of),au=!!Df,Of=Df=null,e.current=s,xR(s),GA(),We=o,Je=l,Jn.transition=a}else e.current=s;if(tc&&(tc=!1,gr=e,bu=i),a=e.pendingLanes,a===0&&(Sr=null),QA(s.stateNode),wn(e,bt()),t!==null)for(r=e.onRecoverableError,s=0;s<t.length;s++)i=t[s],r(i.value,{componentStack:i.stack,digest:i.digest});if(wu)throw wu=!1,e=nm,nm=null,e;return bu&1&&e.tag!==0&&ma(),a=e.pendingLanes,a&1?e===sm?Al++:(Al=0,sm=e):Al=0,Hr(),null}function ma(){if(gr!==null){var e=Rb(bu),t=Jn.transition,s=Je;try{if(Jn.transition=null,Je=16>e?16:e,gr===null)var r=!1;else{if(e=gr,gr=null,bu=0,We&6)throw Error(re(331));var i=We;for(We|=4,ge=e.current;ge!==null;){var a=ge,l=a.child;if(ge.flags&16){var o=a.deletions;if(o!==null){for(var c=0;c<o.length;c++){var u=o[c];for(ge=u;ge!==null;){var f=ge;switch(f.tag){case 0:case 11:case 15:Cl(8,f,a)}var d=f.child;if(d!==null)d.return=f,ge=d;else for(;ge!==null;){f=ge;var m=f.sibling,p=f.return;if(B0(f),f===u){ge=null;break}if(m!==null){m.return=p,ge=m;break}ge=p}}}var v=a.alternate;if(v!==null){var w=v.child;if(w!==null){v.child=null;do{var k=w.sibling;w.sibling=null,w=k}while(w!==null)}}ge=a}}if(a.subtreeFlags&2064&&l!==null)l.return=a,ge=l;else e:for(;ge!==null;){if(a=ge,a.flags&2048)switch(a.tag){case 0:case 11:case 15:Cl(9,a,a.return)}var g=a.sibling;if(g!==null){g.return=a.return,ge=g;break e}ge=a.return}}var x=e.current;for(ge=x;ge!==null;){l=ge;var y=l.child;if(l.subtreeFlags&2064&&y!==null)y.return=l,ge=y;else e:for(l=x;ge!==null;){if(o=ge,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:td(9,o)}}catch(N){vt(o,o.return,N)}if(o===l){ge=null;break e}var j=o.sibling;if(j!==null){j.return=o.return,ge=j;break e}ge=o.return}}if(We=i,Hr(),As&&typeof As.onPostCommitFiberRoot=="function")try{As.onPostCommitFiberRoot(Gu,e)}catch{}r=!0}return r}finally{Je=s,Jn.transition=t}}return!1}function Aj(e,t,s){t=Sa(s,t),t=R0(e,t,1),e=kr(e,t,1),t=dn(),e!==null&&(xo(e,1,t),wn(e,t))}function vt(e,t,s){if(e.tag===3)Aj(e,e,s);else for(;t!==null;){if(t.tag===3){Aj(t,e,s);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Sr===null||!Sr.has(r))){e=Sa(s,e),e=I0(t,e,1),t=kr(t,e,1),e=dn(),t!==null&&(xo(t,1,e),wn(t,e));break}}t=t.return}}function kR(e,t,s){var r=e.pingCache;r!==null&&r.delete(t),t=dn(),e.pingedLanes|=e.suspendedLanes&s,Ft===e&&(Ht&s)===s&&(Mt===4||Mt===3&&(Ht&130023424)===Ht&&500>bt()-ug?ui(e,0):cg|=s),wn(e,t)}function J0(e,t){t===0&&(e.mode&1?(t=Vo,Vo<<=1,!(Vo&130023424)&&(Vo=4194304)):t=1);var s=dn();e=Xs(e,t),e!==null&&(xo(e,t,s),wn(e,s))}function SR(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),J0(e,s)}function NR(e,t){var s=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(s=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(re(314))}r!==null&&r.delete(t),J0(e,s)}var X0;X0=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||jn.current)xn=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return xn=!1,hR(e,t,s);xn=!!(e.flags&131072)}else xn=!1,lt&&t.flags&1048576&&n0(t,fu,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Lc(e,t),e=t.pendingProps;var i=ya(t,nn.current);fa(t,s),i=sg(null,t,r,e,i,s);var a=rg();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,yn(r)?(a=!0,du(t)):a=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Xp(t),i.updater=ed,t.stateNode=i,i._reactInternals=t,Vf(t,r,e,s),t=Yf(null,t,r,!0,a,s)):(t.tag=0,lt&&a&&Vp(t),on(null,t,i,s),t=t.child),t;case 16:r=t.elementType;e:{switch(Lc(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=ER(r),e=ns(r,e),i){case 0:t=Gf(null,t,r,e,s);break e;case 1:t=vj(null,t,r,e,s);break e;case 11:t=gj(null,t,r,e,s);break e;case 14:t=xj(null,t,r,ns(r.type,e),s);break e}throw Error(re(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ns(r,i),Gf(e,t,r,i,s);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ns(r,i),vj(e,t,r,i,s);case 3:e:{if(D0(t),e===null)throw Error(re(387));r=t.pendingProps,a=t.memoizedState,i=a.element,o0(e,t),gu(t,r,null,s);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){i=Sa(Error(re(423)),t),t=jj(e,t,r,s,i);break e}else if(r!==i){i=Sa(Error(re(424)),t),t=jj(e,t,r,s,i);break e}else for(In=br(t.stateNode.containerInfo.firstChild),Mn=t,lt=!0,rs=null,s=a0(t,null,r,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(wa(),r===i){t=Zs(e,t,s);break e}on(e,t,r,s)}t=t.child}return t;case 5:return c0(t),e===null&&zf(t),r=t.type,i=t.pendingProps,a=e!==null?e.memoizedProps:null,l=i.children,_f(r,i)?l=null:a!==null&&_f(r,a)&&(t.flags|=32),$0(e,t),on(e,t,l,s),t.child;case 6:return e===null&&zf(t),null;case 13:return O0(e,t,s);case 4:return Zp(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ba(t,null,r,s):on(e,t,r,s),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ns(r,i),gj(e,t,r,i,s);case 7:return on(e,t,t.pendingProps,s),t.child;case 8:return on(e,t,t.pendingProps.children,s),t.child;case 12:return on(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,a=t.memoizedProps,l=i.value,nt(mu,r._currentValue),r._currentValue=l,a!==null)if(ds(a.value,l)){if(a.children===i.children&&!jn.current){t=Zs(e,t,s);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=Vs(-1,s&-s),c.tag=2;var u=a.updateQueue;if(u!==null){u=u.shared;var f=u.pending;f===null?c.next=c:(c.next=f.next,f.next=c),u.pending=c}}a.lanes|=s,c=a.alternate,c!==null&&(c.lanes|=s),Wf(a.return,s,t),o.lanes|=s;break}c=c.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(re(341));l.lanes|=s,o=l.alternate,o!==null&&(o.lanes|=s),Wf(l,s,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}on(e,t,i.children,s),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,fa(t,s),i=Xn(i),r=r(i),t.flags|=1,on(e,t,r,s),t.child;case 14:return r=t.type,i=ns(r,t.pendingProps),i=ns(r.type,i),xj(e,t,r,i,s);case 15:return P0(e,t,t.type,t.pendingProps,s);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ns(r,i),Lc(e,t),t.tag=1,yn(r)?(e=!0,du(t)):e=!1,fa(t,s),T0(t,r,i),Vf(t,r,i,s),Yf(null,t,r,!0,e,s);case 19:return _0(e,t,s);case 22:return M0(e,t,s)}throw Error(re(156,t.tag))};function Z0(e,t){return Cb(e,t)}function CR(e,t,s,r){this.tag=e,this.key=s,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 Qn(e,t,s,r){return new CR(e,t,s,r)}function mg(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ER(e){if(typeof e=="function")return mg(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Mp)return 11;if(e===$p)return 14}return 2}function Cr(e,t){var s=e.alternate;return s===null?(s=Qn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function Bc(e,t,s,r,i,a){var l=2;if(r=e,typeof e=="function")mg(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Qi:return di(s.children,i,a,t);case Pp:l=8,i|=8;break;case pf:return e=Qn(12,s,t,i|2),e.elementType=pf,e.lanes=a,e;case gf:return e=Qn(13,s,t,i),e.elementType=gf,e.lanes=a,e;case xf:return e=Qn(19,s,t,i),e.elementType=xf,e.lanes=a,e;case cb:return sd(s,i,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case lb:l=10;break e;case ob:l=9;break e;case Mp:l=11;break e;case $p:l=14;break e;case dr:l=16,r=null;break e}throw Error(re(130,e==null?e:typeof e,""))}return t=Qn(l,s,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function di(e,t,s,r){return e=Qn(7,e,r,t),e.lanes=s,e}function sd(e,t,s,r){return e=Qn(22,e,r,t),e.elementType=cb,e.lanes=s,e.stateNode={isHidden:!1},e}function jh(e,t,s){return e=Qn(6,e,null,t),e.lanes=s,e}function yh(e,t,s){return t=Qn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function AR(e,t,s,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=eh(0),this.expirationTimes=eh(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=eh(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function pg(e,t,s,r,i,a,l,o,c){return e=new AR(e,t,s,o,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=Qn(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xp(a),e}function TR(e,t,s){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:qi,key:r==null?null:""+r,children:e,containerInfo:t,implementation:s}}function ek(e){if(!e)return Mr;e=e._reactInternals;e:{if(Ci(e)!==e||e.tag!==1)throw Error(re(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(yn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(re(171))}if(e.tag===1){var s=e.type;if(yn(s))return e0(e,s,t)}return t}function tk(e,t,s,r,i,a,l,o,c){return e=pg(s,r,!0,e,i,a,l,o,c),e.context=ek(null),s=e.current,r=dn(),i=Nr(s),a=Vs(r,i),a.callback=t??null,kr(s,a,i),e.current.lanes=i,xo(e,i,r),wn(e,r),e}function rd(e,t,s,r){var i=t.current,a=dn(),l=Nr(i);return s=ek(s),t.context===null?t.context=s:t.pendingContext=s,t=Vs(a,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=kr(i,t,l),e!==null&&(ls(e,i,l,a),Dc(e,i,l)),l}function Su(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 Tj(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function gg(e,t){Tj(e,t),(e=e.alternate)&&Tj(e,t)}function RR(){return null}var nk=typeof reportError=="function"?reportError:function(e){console.error(e)};function xg(e){this._internalRoot=e}id.prototype.render=xg.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(re(409));rd(e,t,null,null)};id.prototype.unmount=xg.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ji(function(){rd(null,e,null,null)}),t[Js]=null}};function id(e){this._internalRoot=e}id.prototype.unstable_scheduleHydration=function(e){if(e){var t=Mb();e={blockedOn:null,target:e,priority:t};for(var s=0;s<fr.length&&t!==0&&t<fr[s].priority;s++);fr.splice(s,0,e),s===0&&Db(e)}};function vg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ad(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Rj(){}function IR(e,t,s,r,i){if(i){if(typeof r=="function"){var a=r;r=function(){var u=Su(l);a.call(u)}}var l=tk(t,r,e,0,null,!1,!1,"",Rj);return e._reactRootContainer=l,e[Js]=l.current,zl(e.nodeType===8?e.parentNode:e),ji(),l}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var o=r;r=function(){var u=Su(c);o.call(u)}}var c=pg(e,0,!1,null,null,!1,!1,"",Rj);return e._reactRootContainer=c,e[Js]=c.current,zl(e.nodeType===8?e.parentNode:e),ji(function(){rd(t,c,s,r)}),c}function ld(e,t,s,r,i){var a=s._reactRootContainer;if(a){var l=a;if(typeof i=="function"){var o=i;i=function(){var c=Su(l);o.call(c)}}rd(t,l,e,i)}else l=IR(s,t,e,i,r);return Su(l)}Ib=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=gl(t.pendingLanes);s!==0&&(_p(t,s|1),wn(t,bt()),!(We&6)&&(Na=bt()+500,Hr()))}break;case 13:ji(function(){var r=Xs(e,1);if(r!==null){var i=dn();ls(r,e,1,i)}}),gg(e,1)}};Lp=function(e){if(e.tag===13){var t=Xs(e,134217728);if(t!==null){var s=dn();ls(t,e,134217728,s)}gg(e,134217728)}};Pb=function(e){if(e.tag===13){var t=Nr(e),s=Xs(e,t);if(s!==null){var r=dn();ls(s,e,t,r)}gg(e,t)}};Mb=function(){return Je};$b=function(e,t){var s=Je;try{return Je=e,t()}finally{Je=s}};Ef=function(e,t,s){switch(t){case"input":if(yf(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var r=s[t];if(r!==e&&r.form===e.form){var i=Ju(r);if(!i)throw Error(re(90));db(r),yf(r,i)}}}break;case"textarea":fb(e,s);break;case"select":t=s.value,t!=null&&ca(e,!!s.multiple,t,!1)}};yb=dg;wb=ji;var PR={usingClientEntryPoint:!1,Events:[jo,ea,Ju,vb,jb,dg]},ol={findFiberByHostInstance:li,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},MR={bundleType:ol.bundleType,version:ol.version,rendererPackageName:ol.rendererPackageName,rendererConfig:ol.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ir.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Sb(e),e===null?null:e.stateNode},findFiberByHostInstance:ol.findFiberByHostInstance||RR,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 nc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nc.isDisabled&&nc.supportsFiber)try{Gu=nc.inject(MR),As=nc}catch{}}_n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=PR;_n.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vg(t))throw Error(re(200));return TR(e,t,null,s)};_n.createRoot=function(e,t){if(!vg(e))throw Error(re(299));var s=!1,r="",i=nk;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=pg(e,1,!1,null,null,s,!1,r,i),e[Js]=t.current,zl(e.nodeType===8?e.parentNode:e),new xg(t)};_n.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(re(188)):(e=Object.keys(e).join(","),Error(re(268,e)));return e=Sb(t),e=e===null?null:e.stateNode,e};_n.flushSync=function(e){return ji(e)};_n.hydrate=function(e,t,s){if(!ad(t))throw Error(re(200));return ld(null,e,t,!0,s)};_n.hydrateRoot=function(e,t,s){if(!vg(e))throw Error(re(405));var r=s!=null&&s.hydratedSources||null,i=!1,a="",l=nk;if(s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(l=s.onRecoverableError)),t=tk(t,null,e,1,s??null,i,!1,a,l),e[Js]=t.current,zl(e),r)for(e=0;e<r.length;e++)s=r[e],i=s._getVersion,i=i(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,i]:t.mutableSourceEagerHydrationData.push(s,i);return new id(t)};_n.render=function(e,t,s){if(!ad(t))throw Error(re(200));return ld(null,e,t,!1,s)};_n.unmountComponentAtNode=function(e){if(!ad(e))throw Error(re(40));return e._reactRootContainer?(ji(function(){ld(null,null,e,!1,function(){e._reactRootContainer=null,e[Js]=null})}),!0):!1};_n.unstable_batchedUpdates=dg;_n.unstable_renderSubtreeIntoContainer=function(e,t,s,r){if(!ad(s))throw Error(re(200));if(e==null||e._reactInternals===void 0)throw Error(re(38));return ld(e,t,s,!1,r)};_n.version="18.3.1-next-f1338f8080-20240426";function sk(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sk)}catch(e){console.error(e)}}sk(),sb.exports=_n;var Ca=sb.exports,rk,Ij=Ca;rk=Ij.createRoot,Ij.hydrateRoot;var $R=Object.defineProperty,Ba=(e,t)=>$R(e,"name",{value:t,configurable:!0}),ik=!!(typeof window<"u"&&window.document&&window.document.createElement);function Re(e,t,{checkForDefaultPrevented:s=!0}={}){return Ba(function(i){if(e==null||e(i),s===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}Ba(Re,"composeEventHandlers");function DR(e){var t;if(!ik)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Ba(DR,"getOwnerWindow");function am(e){if(!ik)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Ba(am,"getOwnerDocument");function ak(e,t=!1){const{activeElement:s}=am(e);if(!(s!=null&&s.nodeName))return null;if(lk(s)&&s.contentDocument)return ak(s.contentDocument.body,t);if(t){const r=s.getAttribute("aria-activedescendant");if(r){const i=am(s).getElementById(r);if(i)return i}}return s}Ba(ak,"getActiveElement");function lk(e){return e.tagName==="IFRAME"}Ba(lk,"isFrame");var OR=Object.defineProperty,jg=(e,t)=>OR(e,"name",{value:t,configurable:!0});function lm(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}jg(lm,"setRef");function ok(...e){return t=>{let s=!1;const r=e.map(i=>{const a=lm(i,t);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():lm(e[i],null)}}}}jg(ok,"composeRefs");function it(...e){return h.useCallback(ok(...e),e)}jg(it,"useComposedRefs");var _R=Object.defineProperty,qn=(e,t)=>_R(e,"name",{value:t,configurable:!0});function LR(e,t){const s=h.createContext(t);s.displayName=e+"Context";const r=qn(a=>{const{children:l,...o}=a,c=h.useMemo(()=>o,Object.values(o));return n.jsx(s.Provider,{value:c,children:l})},"Provider");r.displayName=e+"Provider";function i(a,l={}){const{optional:o=!1}=l,c=h.useContext(s);if(c)return c;if(t!==void 0)return t;if(!o)throw new Error(`\`${a}\` must be used within \`${e}\``)}return qn(i,"useContext"),[r,i]}qn(LR,"createContext");function fs(e,t=[]){let s=[];function r(a,l){const o=h.createContext(l);o.displayName=a+"Context";const c=s.length;s=[...s,l];const u=qn(d=>{var g;const{scope:m,children:p,...v}=d,w=((g=m==null?void 0:m[e])==null?void 0:g[c])||o,k=h.useMemo(()=>v,Object.values(v));return n.jsx(w.Provider,{value:k,children:p})},"Provider");u.displayName=a+"Provider";function f(d,m,p={}){var g;const{optional:v=!1}=p,w=((g=m==null?void 0:m[e])==null?void 0:g[c])||o,k=h.useContext(w);if(k)return k;if(l!==void 0)return l;if(!v)throw new Error(`\`${d}\` must be used within \`${a}\``)}return qn(f,"useContext"),[u,f]}qn(r,"createContext");const i=qn(()=>{const a=s.map(l=>h.createContext(l));return qn(function(o){const c=(o==null?void 0:o[e])||a;return h.useMemo(()=>({[`__scope${e}`]:{...o,[e]:c}}),[o,c])},"useScope")},"createScope");return i.scopeName=e,[r,ck(i,...t)]}qn(fs,"createContextScope");function ck(...e){const t=e[0];if(e.length===1)return t;const s=qn(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return qn(function(a){const l=r.reduce((o,{useScope:c,scopeName:u})=>{const d=c(a)[`__scope${u}`];return{...o,...d}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])},"useComposedScopes")},"createScope");return s.scopeName=t.scopeName,s}qn(ck,"composeContextScopes");var FR=Object.defineProperty,ms=(e,t)=>FR(e,"name",{value:t,configurable:!0});function $r(e){const t=h.forwardRef((s,r)=>{let{children:i,...a}=s,l=null,o=!1;const c=[];om(i)&&typeof sc=="function"&&(i=sc(i._payload)),h.Children.forEach(i,m=>{var p;if(mk(m)){o=!0;const v=m;let w="child"in v.props?v.props.child:v.props.children;om(w)&&typeof sc=="function"&&(w=sc(w._payload)),l=UR(v,w),c.push((p=l==null?void 0:l.props)==null?void 0:p.children)}else c.push(m)}),l?l=h.cloneElement(l,void 0,c):!o&&h.Children.count(i)===1&&h.isValidElement(i)&&(l=i);const u=l?fk(l):void 0,f=it(r,u);if(!l){if(i||i===0)throw new Error(o?WR(e):zR(e));return i}const d=hk(a,l.props??{});return l.type!==h.Fragment&&(d.ref=r?f:u),h.cloneElement(l,d)});return t.displayName=`${e}.Slot`,t}ms($r,"createSlot");var uk=Symbol.for("radix.slottable");function dk(e){const t=ms(s=>"child"in s?s.children(s.child):s.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=uk,t}ms(dk,"createSlottable");var UR=ms((e,t)=>{if("child"in e.props){const s=e.props.child;return h.isValidElement(s)?h.cloneElement(s,void 0,e.props.children(s.props.children)):null}return h.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function hk(e,t){const s={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?s[r]=(...o)=>{const c=a(...o);return i(...o),c}:i&&(s[r]=i):r==="style"?s[r]={...i,...a}:r==="className"&&(s[r]=[i,a].filter(Boolean).join(" "))}return{...e,...s}}ms(hk,"mergeProps");function fk(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}ms(fk,"getElementRef");function mk(e){return h.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===uk}ms(mk,"isSlottable");var BR=Symbol.for("react.lazy");function om(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===BR&&"_payload"in e&&pk(e._payload)}ms(om,"isLazyComponent");function pk(e){return typeof e=="object"&&e!==null&&"then"in e}ms(pk,"isPromiseLike");var zR=ms(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),WR=ms(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),sc=La[" use ".trim().toString()],HR=Object.defineProperty,_t=(e,t)=>HR(e,"name",{value:t,configurable:!0});function od(e){const t=e+"CollectionProvider",[s,r]=fs(t),[i,a]=s(t,{collectionRef:{current:null},itemMap:new Map}),l=_t(w=>{const{scope:k,children:g}=w,x=h.useRef(null),y=h.useRef(new Map).current;return n.jsx(i,{scope:k,itemMap:y,collectionRef:x,children:g})},"CollectionProvider");l.displayName=t;const o=e+"CollectionSlot",c=$r(o),u=h.forwardRef((w,k)=>{const{scope:g,children:x}=w,y=a(o,g),j=it(k,y.collectionRef);return n.jsx(c,{ref:j,children:x})});u.displayName=o;const f=e+"CollectionItemSlot",d="data-radix-collection-item",m=$r(f),p=h.forwardRef((w,k)=>{const{scope:g,children:x,...y}=w,j=h.useRef(null),N=it(k,j),b=a(f,g);return h.useEffect(()=>(b.itemMap.set(j,{ref:j,...y}),()=>void b.itemMap.delete(j))),n.jsx(m,{[d]:"",ref:N,children:x})});p.displayName=f;function v(w){const k=a(e+"CollectionConsumer",w);return h.useCallback(()=>{const x=k.collectionRef.current;if(!x)return[];const y=Array.from(x.querySelectorAll(`[${d}]`));return Array.from(k.itemMap.values()).sort((b,S)=>y.indexOf(b.ref.current)-y.indexOf(S.ref.current))},[k.collectionRef,k.itemMap])}return _t(v,"useCollection"),[{Provider:l,Slot:u,ItemSlot:p},v,r]}_t(od,"createCollection");var Pj=new WeakMap,kt,Rn,wh=(Rn=class extends Map{constructor(s){super(s);bv(this,kt);Yd(this,kt,[...super.keys()]),Pj.set(this,!0)}set(s,r){return Pj.get(this)&&(this.has(s)?Qt(this,kt)[Qt(this,kt).indexOf(s)]=s:Qt(this,kt).push(s)),super.set(s,r),this}insert(s,r,i){const a=this.has(r),l=Qt(this,kt).length,o=yg(s);let c=o>=0?o:l+o;const u=c<0||c>=l?-1:c;if(u===this.size||a&&u===this.size-1||u===-1)return this.set(r,i),this;const f=this.size+(a?0:1);o<0&&c++;const d=[...Qt(this,kt)];let m,p=!1;for(let v=c;v<f;v++)if(c===v){let w=d[v];d[v]===r&&(w=d[v+1]),a&&this.delete(r),m=this.get(w),this.set(r,i)}else{!p&&d[v-1]===r&&(p=!0);const w=d[p?v:v-1],k=m;m=this.get(w),this.delete(w),this.set(w,k)}return this}with(s,r,i){const a=new Rn(this);return a.insert(s,r,i),a}before(s){const r=Qt(this,kt).indexOf(s)-1;if(!(r<0))return this.entryAt(r)}setBefore(s,r,i){const a=Qt(this,kt).indexOf(s);return a===-1?this:this.insert(a,r,i)}after(s){let r=Qt(this,kt).indexOf(s);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(s,r,i){const a=Qt(this,kt).indexOf(s);return a===-1?this:this.insert(a+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Yd(this,kt,[]),super.clear()}delete(s){const r=super.delete(s);return r&&Qt(this,kt).splice(Qt(this,kt).indexOf(s),1),r}deleteAt(s){const r=this.keyAt(s);return r!==void 0?this.delete(r):!1}at(s){const r=zc(Qt(this,kt),s);if(r!==void 0)return this.get(r)}entryAt(s){const r=zc(Qt(this,kt),s);if(r!==void 0)return[r,this.get(r)]}indexOf(s){return Qt(this,kt).indexOf(s)}keyAt(s){return zc(Qt(this,kt),s)}from(s,r){const i=this.indexOf(s);if(i===-1)return;let a=i+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.at(a)}keyFrom(s,r){const i=this.indexOf(s);if(i===-1)return;let a=i+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.keyAt(a)}find(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return a;i++}}findIndex(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return i;i++}return-1}filter(s,r){const i=[];let a=0;for(const l of this)Reflect.apply(s,r,[l,a,this])&&i.push(l),a++;return new Rn(i)}map(s,r){const i=[];let a=0;for(const l of this)i.push([l[0],Reflect.apply(s,r,[l,a,this])]),a++;return new Rn(i)}reduce(...s){const[r,i]=s;let a=0,l=i??this.at(0);for(const o of this)a===0&&s.length===1?l=o:l=Reflect.apply(r,this,[l,o,a,this]),a++;return l}reduceRight(...s){const[r,i]=s;let a=i??this.at(-1);for(let l=this.size-1;l>=0;l--){const o=this.at(l);l===this.size-1&&s.length===1?a=o:a=Reflect.apply(r,this,[a,o,l,this])}return a}toSorted(s){const r=[...this.entries()].sort(s);return new Rn(r)}toReversed(){const s=new Rn;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),a=this.get(i);s.set(i,a)}return s}toSpliced(...s){const r=[...this.entries()];return r.splice(...s),new Rn(r)}slice(s,r){const i=new Rn;let a=this.size-1;if(s===void 0)return i;s<0&&(s=s+this.size),r!==void 0&&r>0&&(a=r-1);for(let l=s;l<=a;l++){const o=this.keyAt(l),c=this.get(o);i.set(o,c)}return i}every(s,r){let i=0;for(const a of this){if(!Reflect.apply(s,r,[a,i,this]))return!1;i++}return!0}some(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return!0;i++}return!1}},kt=new WeakMap,_t(Rn,"OrderedDict"),Rn);function zc(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const s=gk(e,t);return s===-1?void 0:e[s]}_t(zc,"at");function gk(e,t){const s=e.length,r=yg(t),i=r>=0?r:s+r;return i<0||i>=s?-1:i}_t(gk,"toSafeIndex");function yg(e){return e!==e||e===0?0:Math.trunc(e)}_t(yg,"toSafeInteger");function VR(e){const t=e+"CollectionProvider",[s,r]=fs(t),[i,a]=s(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new wh,setItemMap:_t(()=>{},"setItemMap")}),l=_t(({state:y,...j})=>y?n.jsx(c,{...j,state:y}):n.jsx(o,{...j}),"CollectionProvider");l.displayName=t;const o=_t(y=>{const j=k();return n.jsx(c,{...y,state:j})},"CollectionInit");o.displayName=t+"Init";const c=_t(y=>{const{scope:j,children:N,state:b}=y,S=h.useRef(null),[C,R]=h.useState(null),E=it(S,R),[P,F]=b;return h.useEffect(()=>{if(!C)return;const M=jk(()=>{});return M.observe(C,{childList:!0,subtree:!0}),()=>{M.disconnect()}},[C]),n.jsx(i,{scope:j,itemMap:P,setItemMap:F,collectionRef:E,collectionRefObject:S,collectionElement:C,children:N})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",f=$r(u),d=h.forwardRef((y,j)=>{const{scope:N,children:b}=y,S=a(u,N),C=it(j,S.collectionRef);return n.jsx(f,{ref:C,children:b})});d.displayName=u;const m=e+"CollectionItemSlot",p="data-radix-collection-item",v=$r(m),w=h.forwardRef((y,j)=>{const{scope:N,children:b,...S}=y,C=h.useRef(null),[R,E]=h.useState(null),P=it(j,C,E),F=a(m,N),{setItemMap:M}=F,T=h.useRef(S);xk(T.current,S)||(T.current=S);const $=T.current;return h.useEffect(()=>{const _=$;return M(K=>R?K.has(R)?K.set(R,{..._,element:R}).toSorted(cm):(K.set(R,{..._,element:R}),K.toSorted(cm)):K),()=>{M(K=>!R||!K.has(R)?K:(K.delete(R),new wh(K)))}},[R,$,M]),n.jsx(v,{[p]:"",ref:P,children:b})});w.displayName=m;function k(){return h.useState(new wh)}_t(k,"useInitCollection");function g(y){const{itemMap:j}=a(e+"CollectionConsumer",y);return j}return _t(g,"useCollection"),[{Provider:l,Slot:d,ItemSlot:w},{createCollectionScope:r,useCollection:g,useInitCollection:k}]}_t(VR,"createCollection");function xk(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}_t(xk,"shallowEqual");function vk(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}_t(vk,"isElementPreceding");function cm(e,t){return!e[1].element||!t[1].element?0:vk(e[1].element,t[1].element)?-1:1}_t(cm,"sortByDocumentPosition");function jk(e){return new MutationObserver(s=>{for(const r of s)if(r.type==="childList"){e();return}})}_t(jk,"getChildListObserver");var KR=Object.defineProperty,GR=(e,t)=>KR(e,"name",{value:t,configurable:!0}),YR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mt=YR.reduce((e,t)=>{const s=$r(`Primitive.${t}`),r=h.forwardRef((i,a)=>{const{asChild:l,...o}=i,c=l?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...o,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function cd(e,t){e&&Ca.flushSync(()=>e.dispatchEvent(t))}GR(cd,"dispatchDiscreteCustomEvent");var qR=Object.defineProperty,QR=(e,t)=>qR(e,"name",{value:t,configurable:!0});function es(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...s)=>{var r;return(r=t.current)==null?void 0:r.call(t,...s)},[])}QR(es,"useCallbackRef");var JR=Object.defineProperty,It=(e,t)=>JR(e,"name",{value:t,configurable:!0}),um="dismissableLayer.update",XR="dismissableLayer.pointerDownOutside",ZR="dismissableLayer.focusOutside",Mj,wg=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),bg=h.forwardRef(It(function(t,s){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:o,onInteractOutside:c,onDismiss:u,...f}=t,d=h.useContext(wg),[m,p]=h.useState(null),v=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=h.useState({}),k=it(s,p),g=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=x?g.indexOf(x):-1,j=m?g.indexOf(m):-1,N=d.layersWithOutsidePointerEventsDisabled.size>0,b=j>=y,S=h.useRef(!1),C=wk(F=>{l==null||l(F),c==null||c(F),F.defaultPrevented||u==null||u()},{ownerDocument:v,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(F=>{if(!(F instanceof Node))return!1;const M=[...d.branches].some(T=>T.contains(F));return b&&!M},[d.branches,b])}),R=bk(F=>{if(i&&S.current)return;const M=F.target;[...d.branches].some($=>$.contains(M))||(o==null||o(F),c==null||c(F),F.defaultPrevented||u==null||u())},v),E=m?j===g.length-1:!1,P=es(F=>{F.key==="Escape"&&(a==null||a(F),!F.defaultPrevented&&u&&(F.preventDefault(),u()))});return h.useEffect(()=>{if(E)return v.addEventListener("keydown",P,{capture:!0}),()=>v.removeEventListener("keydown",P,{capture:!0})},[v,E,P]),h.useEffect(()=>{if(m)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Mj=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),dm(),()=>{r&&(d.layersWithOutsidePointerEventsDisabled.delete(m),d.layersWithOutsidePointerEventsDisabled.size===0&&(v.body.style.pointerEvents=Mj))}},[m,v,r,d]),h.useEffect(()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),dm())},[m,d]),h.useEffect(()=>{const F=It(()=>w({}),"handleUpdate");return document.addEventListener(um,F),()=>document.removeEventListener(um,F)},[]),n.jsx(mt.div,{...f,ref:k,style:{pointerEvents:N?b?"auto":"none":void 0,...t.style},onFocusCapture:Re(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Re(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Re(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),e2=h.forwardRef(It(function(t,s){const r=h.useContext(wg),i=h.useRef(null),a=it(s,i);return h.useEffect(()=>{const l=i.current;if(l)return r.branches.add(l),()=>{r.branches.delete(l)}},[r.branches]),n.jsx(mt.div,{...t,ref:a})},"DismissableLayerBranch"));function yk(){const e=h.useContext(wg),[t,s]=h.useState(null);return h.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}It(yk,"useDismissableLayerSurface");var t2=It(()=>!0,"IS_TRUE");function wk(e,t){const{ownerDocument:s=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:l=t2}=t,o=es(e),c=h.useRef(!1),u=h.useRef(!1),f=h.useRef(new Map),d=h.useRef(()=>{});return h.useEffect(()=>{function m(){u.current=!1,i.current=!1,f.current.clear()}It(m,"resetOutsideInteraction");function p(){return Array.from(f.current.values()).some(Boolean)}It(p,"isOutsideInteractionIntercepted");function v(y){if(!u.current)return;const j=y.target;j instanceof Node&&[...a].some(b=>b.contains(j))||f.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{u.current&&d.current()},0)}It(v,"handleInteractionCapture");function w(y){u.current&&f.current.set(y.type,!1)}It(w,"handleInteractionBubble");const k=It(y=>{if(y.target&&!c.current){let j=function(){s.removeEventListener("click",d.current);const b=p();m(),b||kg(XR,o,N,{discrete:!0})};if(It(j,"handleAndDispatchPointerDownOutsideEvent"),!l(y.target)){s.removeEventListener("click",d.current),m(),c.current=!1;return}const N={originalEvent:y};u.current=!0,i.current=r&&y.button===0,f.current.clear(),!r||y.button!==0?j():(s.removeEventListener("click",d.current),d.current=j,s.addEventListener("click",d.current,{once:!0}))}else s.removeEventListener("click",d.current),m();c.current=!1},"handlePointerDown"),g=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of g)s.addEventListener(y,v,!0),s.addEventListener(y,w);const x=window.setTimeout(()=>{s.addEventListener("pointerdown",k)},0);return()=>{window.clearTimeout(x),s.removeEventListener("pointerdown",k),s.removeEventListener("click",d.current);for(const y of g)s.removeEventListener(y,v,!0),s.removeEventListener(y,w)}},[s,o,r,i,a,l]),{onPointerDownCapture:It(()=>c.current=!0,"onPointerDownCapture")}}It(wk,"usePointerDownOutside");function bk(e,t=globalThis==null?void 0:globalThis.document){const s=es(e),r=h.useRef(!1);return h.useEffect(()=>{const i=It(a=>{a.target&&!r.current&&kg(ZR,s,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,s]),{onFocusCapture:It(()=>r.current=!0,"onFocusCapture"),onBlurCapture:It(()=>r.current=!1,"onBlurCapture")}}It(bk,"useFocusOutside");function dm(){const e=new CustomEvent(um);document.dispatchEvent(e)}It(dm,"dispatchUpdate");function kg(e,t,s,{discrete:r}){const i=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&i.addEventListener(e,t,{once:!0}),r?cd(i,a):i.dispatchEvent(a)}It(kg,"handleAndDispatchCustomEvent");var n2=e2,bn=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},s2=Object.defineProperty,r2=(e,t)=>s2(e,"name",{value:t,configurable:!0}),Sg=h.forwardRef(r2(function(t,s){var c;const{container:r,...i}=t,[a,l]=h.useState(!1);bn(()=>l(!0),[]);const o=r||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Ca.createPortal(n.jsx(mt.div,{...i,ref:s}),o):null},"Portal")),i2=Object.defineProperty,er=(e,t)=>i2(e,"name",{value:t,configurable:!0});function kk(e,t){return h.useReducer((s,r)=>t[s][r]??s,e)}er(kk,"useStateMachine");var ar=er(e=>{const{present:t,children:s}=e,r=Sk(t),i=typeof s=="function"?s({present:r.isPresent}):h.Children.only(s),a=Nk(r.ref,Ck(i));return typeof s=="function"||r.isPresent?h.cloneElement(i,{ref:a}):null},"Presence");function Sk(e){const[t,s]=h.useState(),r=h.useRef(null),i=h.useRef(e),a=h.useRef("none"),l=h.useRef(void 0),o=e?"mounted":"unmounted",[c,u]=kk(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{c==="mounted"?(a.current=l.current??Gi(r.current),l.current=void 0):a.current="none"},[c]),bn(()=>{const f=r.current,d=i.current;if(d!==e){const p=a.current,v=Gi(f);e?(l.current=v,u("MOUNT")):v==="none"||(f==null?void 0:f.display)==="none"?u("UNMOUNT"):u(d&&p!==v?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),bn(()=>{if(t){let f;const d=t.ownerDocument.defaultView??window,m=er(v=>{const k=Gi(r.current).includes(CSS.escape(v.animationName));if(v.target===t&&k&&(u("ANIMATION_END"),!i.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",f=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},"handleAnimationEnd"),p=er(v=>{v.target===t&&(a.current=Gi(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{d.clearTimeout(f),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:h.useCallback(f=>{if(f){const d=getComputedStyle(f);r.current=d,l.current=Gi(d)}else r.current=null;s(f)},[])}}er(Sk,"usePresence");function hm(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}er(hm,"setRef");function Nk(...e){const t=h.useRef(e);return t.current=e,h.useCallback(s=>{const r=t.current;let i=!1;const a=r.map(l=>{const o=hm(l,s);return!i&&typeof o=="function"&&(i=!0),o});if(i)return()=>{for(let l=0;l<a.length;l++){const o=a[l];typeof o=="function"?o():hm(r[l],null)}}},[])}er(Nk,"useStableComposedRefs");function Gi(e){return(e==null?void 0:e.animationName)||"none"}er(Gi,"getAnimationName");function Ck(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}er(Ck,"getElementRef");var a2=Object.defineProperty,l2=(e,t)=>a2(e,"name",{value:t,configurable:!0}),$j=La[" useEffectEvent ".trim().toString()],Dj=La[" useInsertionEffect ".trim().toString()];function Ek(e){if(typeof $j=="function")return $j(e);const t=h.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Dj=="function"?Dj(()=>{t.current=e}):bn(()=>{t.current=e}),h.useMemo(()=>(...s)=>{var r;return(r=t.current)==null?void 0:r.call(t,...s)},[])}l2(Ek,"useEffectEvent");var o2=Object.defineProperty,wo=(e,t)=>o2(e,"name",{value:t,configurable:!0}),c2=La[" useInsertionEffect ".trim().toString()]||bn;function Ei({prop:e,defaultProp:t,onChange:s=wo(()=>{},"onChange"),caller:r}){const[i,a,l]=Ak({defaultProp:t,onChange:s}),o=e!==void 0,c=o?e:i,u=h.useCallback(f=>{var d;if(o){const m=Tk(f)?f(e):f;m!==e&&((d=l.current)==null||d.call(l,m))}else a(f)},[o,e,a,l]);return[c,u]}wo(Ei,"useControllableState");function Ak({defaultProp:e,onChange:t}){const[s,r]=h.useState(e),i=h.useRef(s),a=h.useRef(t);return c2(()=>{a.current=t},[t]),h.useEffect(()=>{var l;i.current!==s&&((l=a.current)==null||l.call(a,s),i.current=s)},[s,i]),[s,r,a]}wo(Ak,"useUncontrolledState");function Tk(e){return typeof e=="function"}wo(Tk,"isFunction");var Oj=Symbol("RADIX:SYNC_STATE");function u2(e,t,s,r){const{prop:i,defaultProp:a,onChange:l,caller:o}=t,c=i!==void 0,u=Ek(l),f=[{...s,state:a}];r&&f.push(r);const[d,m]=h.useReducer((k,g)=>{if(g.type===Oj)return{...k,state:g.state};const x=e(k,g);return c&&!Object.is(x.state,k.state)&&u(x.state),x},...f),p=d.state,v=h.useRef(p);h.useEffect(()=>{v.current!==p&&(v.current=p,c||u(p))},[p,v,c]);const w=h.useMemo(()=>i!==void 0?{...d,state:i}:d,[d,i]);return h.useEffect(()=>{c&&!Object.is(i,d.state)&&m({type:Oj,state:i})},[i,d.state,c]),[w,m]}wo(u2,"useControllableStateReducer");var d2=Object.defineProperty,h2=(e,t)=>d2(e,"name",{value:t,configurable:!0}),f2=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"}),Rk=h.forwardRef(h2(function(t,s){return n.jsx(mt.span,{...t,ref:s,style:{...f2,...t.style}})},"VisuallyHidden")),m2=Rk,p2=Object.defineProperty,Zt=(e,t)=>p2(e,"name",{value:t,configurable:!0}),Ik="ToastProvider",[Pk,g2,x2]=od("Toast"),[Mk,wH]=fs("Toast",[x2]),[v2,$k]=Mk(Ik),j2=Zt(e=>{const{__scopeToast:t,label:s="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:a=50,announcerContainer:l,children:o}=e,[c,u]=h.useState(null),[f,d]=h.useState(0),m=h.useRef(!1);return s.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ik}\`. Expected non-empty \`string\`.`),n.jsx(Pk.Provider,{scope:t,children:n.jsx(v2,{scope:t,label:s,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:f,viewport:c,onViewportChange:u,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isClosePausedRef:m,announcerContainer:l,children:o})})},"ToastProvider"),y2="ToastViewport",w2=["F8"],b2="toast.viewportPause",k2="toast.viewportResume",S2=h.forwardRef(Zt(function(t,s){const{__scopeToast:r,hotkey:i=w2,label:a="Notifications ({hotkey})",...l}=t,o=$k(y2,r),c=g2(r),u=h.useRef(null),f=h.useRef(null),d=h.useRef(null),m=h.useRef(null),p=it(s,m,o.onViewportChange),v=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=o.toastCount>0;h.useEffect(()=>{const g=Zt(x=>{var j;i.length!==0&&i.every(N=>x[N]||x.code===N)&&((j=m.current)==null||j.focus())},"handleKeyDown");return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]),h.useEffect(()=>{const g=u.current,x=m.current;if(w&&g&&x){const y=Zt(()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(b2);x.dispatchEvent(S),o.isClosePausedRef.current=!0}},"handlePause"),j=Zt(()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(k2);x.dispatchEvent(S),o.isClosePausedRef.current=!1}},"handleResume"),N=Zt(S=>{!g.contains(S.relatedTarget)&&j()},"handleFocusOutResume"),b=Zt(()=>{g.contains(document.activeElement)||j()},"handlePointerLeaveResume");return g.addEventListener("focusin",y),g.addEventListener("focusout",N),g.addEventListener("pointermove",y),g.addEventListener("pointerleave",b),window.addEventListener("blur",y),window.addEventListener("focus",j),()=>{g.removeEventListener("focusin",y),g.removeEventListener("focusout",N),g.removeEventListener("pointermove",y),g.removeEventListener("pointerleave",b),window.removeEventListener("blur",y),window.removeEventListener("focus",j)}}},[w,o.isClosePausedRef]);const k=h.useCallback(({tabbingDirection:g})=>{const y=c().map(j=>{const N=j.ref.current,b=[N,..._k(N)];return g==="forwards"?b:b.reverse()});return(g==="forwards"?y.reverse():y).flat()},[c]);return h.useEffect(()=>{const g=m.current;if(g){const x=Zt(y=>{var b,S,C;const j=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!j){const R=document.activeElement,E=y.shiftKey;if(y.target===g&&E){(b=f.current)==null||b.focus();return}const M=k({tabbingDirection:E?"backwards":"forwards"}),T=M.findIndex($=>$===R);Wc(M.slice(T+1))?y.preventDefault():E?(S=f.current)==null||S.focus():(C=d.current)==null||C.focus()}},"handleKeyDown");return g.addEventListener("keydown",x),()=>g.removeEventListener("keydown",x)}},[c,k]),n.jsxs(n2,{ref:u,role:"region","aria-label":a.replace("{hotkey}",v),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&n.jsx(_j,{ref:f,onFocusFromOutsideViewport:()=>{const g=k({tabbingDirection:"forwards"});Wc(g)}}),n.jsx(Pk.Slot,{scope:r,children:n.jsx(mt.ol,{tabIndex:-1,...l,ref:p})}),w&&n.jsx(_j,{ref:d,onFocusFromOutsideViewport:()=>{const g=k({tabbingDirection:"backwards"});Wc(g)}})]})},"ToastViewport")),N2="ToastFocusProxy",_j=h.forwardRef(Zt(function(t,s){const{__scopeToast:r,onFocusFromOutsideViewport:i,...a}=t,l=$k(N2,r);return n.jsx(Rk,{tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:o=>{var f;const c=o.relatedTarget;!((f=l.viewport)!=null&&f.contains(c))&&i()}})},"ToastFocusProxy")),C2="Toast",[bH,kH]=Mk(C2,{onClose(){}});function Dk(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Ok(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!i)if(a){const l=r.dataset.radixToastAnnounceAlt;l&&t.push(l)}else t.push(...Dk(r))}}),t}Zt(Dk,"getAnnounceTextContent");function E2(e,t,s,{discrete:r}){const i=s.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:s});t&&i.addEventListener(e,t,{once:!0}),r?cd(i,a):i.dispatchEvent(a)}Zt(E2,"handleAndDispatchCustomEvent");function A2(e=()=>{}){const t=es(e);bn(()=>{let s=0,r=0;return s=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(r)}},[t])}Zt(A2,"useNextFrame");function Ok(e){return e.nodeType===e.ELEMENT_NODE}Zt(Ok,"isHTMLElement");function _k(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Zt(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(;s.nextNode();)t.push(s.currentNode);return t}Zt(_k,"getTabbableCandidates");function Wc(e){const t=document.activeElement;return e.some(s=>s===t?!0:(s.focus(),document.activeElement!==t))}Zt(Wc,"focusFirst");var Lj=j2,Fj=S2,T2=Object.defineProperty,R2=(e,t)=>T2(e,"name",{value:t,configurable:!0}),I2=La[" useId ".trim().toString()]||(()=>{}),P2=0;function os(e){const[t,s]=h.useState(I2());return bn(()=>{e||s(r=>r??String(P2++))},[e]),e||(t?`radix-${t}`:"")}R2(os,"useId");const M2=["top","right","bottom","left"],Dr=Math.min,Ks=Math.max,Nu=Math.round,rc=Math.floor,Gs=e=>({x:e,y:e}),$2={left:"right",right:"left",bottom:"top",top:"bottom"};function Lk(e,t,s){return Ks(e,Dr(t,s))}function tr(e,t){return typeof e=="function"?e(t):e}function Or(e){return e.split("-")[0]}function za(e){return e.split("-")[1]}function Ng(e){return e==="x"?"y":"x"}function Cg(e){return e==="y"?"height":"width"}function Cs(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Eg(e){return Ng(Cs(e))}function D2(e,t,s){s===void 0&&(s=!1);const r=za(e),i=Eg(e),a=Cg(i);let l=i==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=Cu(l)),[l,Cu(l)]}function O2(e){const t=Cu(e);return[fm(e),t,fm(t)]}function fm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Uj=["left","right"],Bj=["right","left"],_2=["top","bottom"],L2=["bottom","top"];function F2(e,t,s){switch(e){case"top":case"bottom":return s?t?Bj:Uj:t?Uj:Bj;case"left":case"right":return t?_2:L2;default:return[]}}function U2(e,t,s,r){const i=za(e);let a=F2(Or(e),s==="start",r);return i&&(a=a.map(l=>l+"-"+i),t&&(a=a.concat(a.map(fm)))),a}function Cu(e){const t=Or(e);return $2[t]+e.slice(t.length)}function B2(e){var t,s,r,i;return{top:(t=e.top)!=null?t:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function Fk(e){return typeof e!="number"?B2(e):{top:e,right:e,bottom:e,left:e}}function Eu(e){const{x:t,y:s,width:r,height:i}=e;return{width:r,height:i,top:s,left:t,right:t+r,bottom:s+i,x:t,y:s}}function zj(e,t,s){let{reference:r,floating:i}=e;const a=Cs(t),l=Eg(t),o=Cg(l),c=Or(t),u=a==="y",f=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,m=r[o]/2-i[o]/2;let p;switch(c){case"top":p={x:f,y:r.y-i.height};break;case"bottom":p={x:f,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}const v=za(t);return v&&(p[l]+=m*(v==="end"?1:-1)*(s&&u?-1:1)),p}async function z2(e,t){var s;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:l,elements:o,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:m=!1,padding:p=0}=tr(t,e),v=Fk(p),k=o[m?d==="floating"?"reference":"floating":d],g=Eu(await a.getClippingRect({element:(s=await(a.isElement==null?void 0:a.isElement(k)))==null||s?k:k.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(o.floating)),boundary:u,rootBoundary:f,strategy:c})),x=d==="floating"?{x:r,y:i,width:l.floating.width,height:l.floating.height}:l.reference,y=await(a.getOffsetParent==null?void 0:a.getOffsetParent(o.floating)),j=await(a.isElement==null?void 0:a.isElement(y))&&await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1},N=Eu(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:x,offsetParent:y,strategy:c}):x);return{top:(g.top-N.top+v.top)/j.y,bottom:(N.bottom-g.bottom+v.bottom)/j.y,left:(g.left-N.left+v.left)/j.x,right:(N.right-g.right+v.right)/j.x}}const W2=50,H2=async(e,t,s)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:l}=s,o=l.detectOverflow?l:{...l,detectOverflow:z2},c=await(l.isRTL==null?void 0:l.isRTL(t));let u=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:d}=zj(u,r,c),m=r,p=0;const v={};for(let w=0;w<a.length;w++){const k=a[w];if(!k)continue;const{name:g,fn:x}=k,{x:y,y:j,data:N,reset:b}=await x({x:f,y:d,initialPlacement:r,placement:m,strategy:i,middlewareData:v,rects:u,platform:o,elements:{reference:e,floating:t}});f=y??f,d=j??d,v[g]={...v[g],...N},b&&p<W2&&(p++,typeof b=="object"&&(b.placement&&(m=b.placement),b.rects&&(u=b.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:i}):b.rects),{x:f,y:d}=zj(u,m,c)),w=-1)}return{x:f,y:d,placement:m,strategy:i,middlewareData:v}},V2=e=>({name:"arrow",options:e,async fn(t){const{x:s,y:r,placement:i,rects:a,platform:l,elements:o,middlewareData:c}=t,{element:u,padding:f=0}=tr(e,t)||{};if(u==null)return{};const d=Fk(f),m={x:s,y:r},p=Eg(i),v=Cg(p),w=await l.getDimensions(u),k=p==="y",g=k?"top":"left",x=k?"bottom":"right",y=k?"clientHeight":"clientWidth",j=a.reference[v]+a.reference[p]-m[p]-a.floating[v],N=m[p]-a.reference[p],b=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let S=b?b[y]:0;(!S||!await(l.isElement==null?void 0:l.isElement(b)))&&(S=o.floating[y]||a.floating[v]);const C=j/2-N/2,R=S/2-w[v]/2-1,E=Dr(d[g],R),P=Dr(d[x],R),F=S-w[v]-P,M=S/2-w[v]/2+C,T=Lk(E,M,F),$=!c.arrow&&za(i)!=null&&M!==T&&a.reference[v]/2-(M<E?E:P)-w[v]/2<0,_=$?M<E?M-E:M-F:0;return{[p]:m[p]+_,data:{[p]:T,centerOffset:M-T-_,...$&&{alignmentOffset:_}},reset:$}}}),K2=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,r;const{placement:i,middlewareData:a,rects:l,initialPlacement:o,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...k}=tr(e,t);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const g=Or(i),x=Cs(o),y=Or(o)===o,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),N=m||(y||!w?[Cu(o)]:O2(o)),b=v!=="none";!m&&b&&N.push(...U2(o,w,v,j));const S=[o,...N],C=await c.detectOverflow(t,k),R=[];let E=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&R.push(C[g]),d){const T=D2(i,l,j);R.push(C[T[0]],C[T[1]])}if(E=[...E,{placement:i,overflows:R}],!R.every(T=>T<=0)){var P,F;const T=(((P=a.flip)==null?void 0:P.index)||0)+1,$=S[T];if($&&(!(d==="alignment"?x!==Cs($):!1)||E.every(D=>Cs(D.placement)===x?D.overflows[0]>0:!0)))return{data:{index:T,overflows:E},reset:{placement:$}};let _=(F=E.filter(K=>K.overflows[0]<=0).sort((K,D)=>K.overflows[1]-D.overflows[1])[0])==null?void 0:F.placement;if(!_)switch(p){case"bestFit":{var M;const K=(M=E.filter(D=>{if(b){const Y=Cs(D.placement);return Y===x||Y==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(Y=>Y>0).reduce((Y,B)=>Y+B,0)]).sort((D,Y)=>D[1]-Y[1])[0])==null?void 0:M[0];K&&(_=K);break}case"initialPlacement":_=o;break}if(i!==_)return{reset:{placement:_}}}return{}}}};function Wj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Hj(e){return M2.some(t=>e[t]>=0)}const G2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:s,platform:r}=t,{strategy:i="referenceHidden",...a}=tr(e,t);switch(i){case"referenceHidden":{const l=await r.detectOverflow(t,{...a,elementContext:"reference"}),o=Wj(l,s.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Hj(o)}}}case"escaped":{const l=await r.detectOverflow(t,{...a,altBoundary:!0}),o=Wj(l,s.floating);return{data:{escapedOffsets:o,escaped:Hj(o)}}}default:return{}}}}},Uk=new Set(["left","top"]);async function Y2(e,t){const{placement:s,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),l=Or(s),o=za(s),c=Cs(s)==="y",u=Uk.has(l)?-1:1,f=a&&c?-1:1,d=tr(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return o&&typeof v=="number"&&(p=o==="end"?v*-1:v),c?{x:p*f,y:m*u}:{x:m*u,y:p*f}}const q2=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,r;const{x:i,y:a,placement:l,middlewareData:o}=t,c=await Y2(t,e);return l===((s=o.offset)==null?void 0:s.placement)&&(r=o.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:{...c,placement:l}}}}},Q2=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:r,placement:i,platform:a}=t,{mainAxis:l=!0,crossAxis:o=!1,limiter:c={fn:x=>{let{x:y,y:j}=x;return{x:y,y:j}}},...u}=tr(e,t),f={x:s,y:r},d=await a.detectOverflow(t,u),m=Cs(i),p=Ng(m);let v=f[p],w=f[m];const k=(x,y)=>Lk(y+d[x==="y"?"top":"left"],y,y-d[x==="y"?"bottom":"right"]);l&&(v=k(p,v)),o&&(w=k(m,w));const g=c.fn({...t,[p]:v,[m]:w});return{...g,data:{x:g.x-s,y:g.y-r,enabled:{[p]:l,[m]:o}}}}}},J2=function(e){return e===void 0&&(e={}),{options:e,fn(t){var s,r;const{x:i,y:a,placement:l,rects:o,middlewareData:c}=t,{offset:u=0,mainAxis:f=!0,crossAxis:d=!0}=tr(e,t),m={x:i,y:a},p=Cs(l),v=Ng(p);let w=m[v],k=m[p];const g=tr(u,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:(s=g.mainAxis)!=null?s:0,crossAxis:(r=g.crossAxis)!=null?r:0};if(f){const N=v==="y"?"height":"width",b=o.reference[v]-o.floating[N]+x.mainAxis,S=o.reference[v]+o.reference[N]-x.mainAxis;w<b?w=b:w>S&&(w=S)}if(d){var y,j;const N=v==="y"?"width":"height",b=Uk.has(Or(l)),S=o.reference[p]-o.floating[N]+(b&&((y=c.offset)==null?void 0:y[p])||0)+(b?0:x.crossAxis),C=o.reference[p]+o.reference[N]+(b?0:((j=c.offset)==null?void 0:j[p])||0)-(b?x.crossAxis:0);k<S?k=S:k>C&&(k=C)}return{[v]:w,[p]:k}}}},X2=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:s,rects:r,platform:i,elements:a}=t,{apply:l=()=>{},...o}=tr(e,t),c=await i.detectOverflow(t,o),u=Or(s),f=za(s),d=Cs(s)==="y",{width:m,height:p}=r.floating;let v,w;u==="top"||u==="bottom"?(v=u,w=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=u,v=f==="end"?"top":"bottom");const k=p-c.top-c.bottom,g=m-c.left-c.right,x=Dr(p-c[v],k),y=Dr(m-c[w],g),j=t.middlewareData.shift,N=!j;let b=x,S=y;j!=null&&j.enabled.x&&(S=g),j!=null&&j.enabled.y&&(b=k),N&&!f&&(d?S=m-2*Ks(c.left,c.right):b=p-2*Ks(c.top,c.bottom)),await l({...t,availableWidth:S,availableHeight:b});const C=await i.getDimensions(a.floating);return m!==C.width||p!==C.height?{reset:{rects:!0}}:{}}}};function ud(){return typeof window<"u"}function Wa(e){return Bk(e)?(e.nodeName||"").toLowerCase():"#document"}function kn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function lr(e){var t;return(t=(Bk(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Bk(e){return ud()?e instanceof Node||e instanceof kn(e).Node:!1}function Is(e){return ud()?e instanceof Element||e instanceof kn(e).Element:!1}function Vr(e){return ud()?e instanceof HTMLElement||e instanceof kn(e).HTMLElement:!1}function Vj(e){return!ud()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof kn(e).ShadowRoot}function dd(e){const{overflow:t,overflowX:s,overflowY:r,display:i}=Ps(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+s)&&i!=="inline"&&i!=="contents"}function Z2(e){return/^(table|td|th)$/.test(Wa(e))}function hd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const eI=/transform|translate|scale|rotate|perspective|filter/,tI=/paint|layout|strict|content/,Zr=e=>!!e&&e!=="none";let bh;function Ag(e){const t=Is(e)?Ps(e):e;return Zr(t.transform)||Zr(t.translate)||Zr(t.scale)||Zr(t.rotate)||Zr(t.perspective)||!Tg()&&(Zr(t.backdropFilter)||Zr(t.filter))||eI.test(t.willChange||"")||tI.test(t.contain||"")}function nI(e){let t=yi(e);for(;Vr(t)&&!Jl(t);){if(Ag(t))return t;if(hd(t))return null;t=yi(t)}return null}function Tg(){return bh==null&&(bh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),bh}function Jl(e){return/^(html|body|#document)$/.test(Wa(e))}function Ps(e){return kn(e).getComputedStyle(e)}function fd(e){return Is(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function yi(e){if(Wa(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Vj(e)&&e.host||lr(e);return Vj(t)?t.host:t}function zk(e){const t=yi(e);return Jl(t)?(e.ownerDocument||e).body:Vr(t)&&dd(t)?t:zk(t)}function Xl(e,t,s){var r;t===void 0&&(t=[]),s===void 0&&(s=!0);const i=zk(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),l=kn(i);if(a){const o=mm(l);return t.concat(l,l.visualViewport||[],dd(i)?i:[],o&&s?Xl(o):[])}else return t.concat(i,Xl(i,[],s))}function mm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Wk(e){const t=Ps(e);let s=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Vr(e),a=i?e.offsetWidth:s,l=i?e.offsetHeight:r,o=Nu(s)!==a||Nu(r)!==l;return o&&(s=a,r=l),{width:s,height:r,$:o}}function Rg(e){return Is(e)?e:e.contextElement}function pa(e){const t=Rg(e);if(!Vr(t))return Gs(1);const s=t.getBoundingClientRect(),{width:r,height:i,$:a}=Wk(t);let l=(a?Nu(s.width):s.width)/r,o=(a?Nu(s.height):s.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!o||!Number.isFinite(o))&&(o=1),{x:l,y:o}}const sI=Gs(0);function Hk(e){const t=kn(e);return!Tg()||!t.visualViewport?sI:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function rI(e,t,s){return t===void 0&&(t=!1),!!s&&t&&s===kn(e)}function wi(e,t,s,r){t===void 0&&(t=!1),s===void 0&&(s=!1);const i=e.getBoundingClientRect(),a=Rg(e);let l=Gs(1);t&&(r?Is(r)&&(l=pa(r)):l=pa(e));const o=rI(a,s,r)?Hk(a):Gs(0);let c=(i.left+o.x)/l.x,u=(i.top+o.y)/l.y,f=i.width/l.x,d=i.height/l.y;if(a&&r){const m=kn(a),p=Is(r)?kn(r):r;let v=m,w=mm(v);for(;w&&p!==v;){const k=pa(w),g=w.getBoundingClientRect(),x=Ps(w),y=g.left+(w.clientLeft+parseFloat(x.paddingLeft))*k.x,j=g.top+(w.clientTop+parseFloat(x.paddingTop))*k.y;c*=k.x,u*=k.y,f*=k.x,d*=k.y,c+=y,u+=j,v=kn(w),w=mm(v)}}return Eu({width:f,height:d,x:c,y:u})}function md(e,t){const s=fd(e).scrollLeft;return t?t.left+s:wi(lr(e)).left+s}function Vk(e,t){const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-md(e,s),i=s.top+t.scrollTop;return{x:r,y:i}}function iI(e){let{elements:t,rect:s,offsetParent:r,strategy:i}=e;const a=i==="fixed",l=lr(r),o=t?hd(t.floating):!1;if(r===l||o&&a)return s;let c={scrollLeft:0,scrollTop:0},u=Gs(1);const f=Gs(0),d=Vr(r);if((d||!a)&&((Wa(r)!=="body"||dd(l))&&(c=fd(r)),d)){const p=wi(r);u=pa(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const m=l&&!d&&!a?Vk(l,c):Gs(0);return{width:s.width*u.x,height:s.height*u.y,x:s.x*u.x-c.scrollLeft*u.x+f.x+m.x,y:s.y*u.y-c.scrollTop*u.y+f.y+m.y}}function aI(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function lI(e){const t=fd(e),s=e.ownerDocument.body,r=Ks(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=Ks(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let a=-t.scrollLeft+md(e);const l=-t.scrollTop;return Ps(s).direction==="rtl"&&(a+=Ks(e.clientWidth,s.clientWidth)-r),{width:r,height:i,x:a,y:l}}const oI=25;function cI(e,t,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",i=kn(e),a=lr(e),l=i.visualViewport;let o=a.clientWidth,c=a.clientHeight,u=0,f=0;if(l){const m=!Tg()||t==="fixed";r?m||(u=-l.offsetLeft,f=-l.offsetTop):(o=l.width,c=l.height,m&&(u=l.offsetLeft,f=l.offsetTop))}if(md(a)<=0){const m=a.ownerDocument,p=m.body,v=getComputedStyle(p),w=m.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,k=Math.abs(a.clientWidth-p.clientWidth-w),g=getComputedStyle(a).scrollbarGutter==="stable both-edges"?k/2:k;g<=oI&&(o-=g)}return{width:o,height:c,x:u,y:f}}function uI(e,t){const s=wi(e,!0,t==="fixed"),r=s.top+e.clientTop,i=s.left+e.clientLeft,a=pa(e),l=e.clientWidth*a.x,o=e.clientHeight*a.y,c=i*a.x,u=r*a.y;return{width:l,height:o,x:c,y:u}}function Kj(e,t,s){let r;if(t==="viewport"||t==="layoutViewport")r=cI(e,s,t);else if(t==="document")r=lI(lr(e));else if(Is(t))r=uI(t,s);else{const i=Hk(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Eu(r)}function dI(e,t){const s=t.get(e);if(s)return s;let r=Xl(e,[],!1).filter(o=>Is(o)&&Wa(o)!=="body"),i=null;const a=Ps(e).position==="fixed";let l=a?yi(e):e;for(;Is(l)&&!Jl(l);){const o=Ps(l),c=Ag(l),u=i?i.position:a?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&o.position==="static")?r=r.filter(d=>d!==l):i=o,l=yi(l)}return t.set(e,r),r}function hI(e){let{element:t,boundary:s,rootBoundary:r,strategy:i}=e;const l=[...s==="clippingAncestors"?hd(t)?[]:dI(t,this._c):[].concat(s),r],o=Kj(t,l[0],i);let c=o.top,u=o.right,f=o.bottom,d=o.left;for(let m=1;m<l.length;m++){const p=Kj(t,l[m],i);c=Ks(p.top,c),u=Dr(p.right,u),f=Dr(p.bottom,f),d=Ks(p.left,d)}return{width:u-d,height:f-c,x:d,y:c}}function fI(e){const{width:t,height:s}=Wk(e);return{width:t,height:s}}function mI(e,t,s){const r=Vr(t),i=lr(t),a=s==="fixed",l=wi(e,!0,a,t);let o={scrollLeft:0,scrollTop:0};const c=Gs(0);if((r||!a)&&((Wa(t)!=="body"||dd(i))&&(o=fd(t)),r)){const m=wi(t,!0,a,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}!r&&i&&(c.x=md(i));const u=i&&!r&&!a?Vk(i,o):Gs(0),f=l.left+o.scrollLeft-c.x-u.x,d=l.top+o.scrollTop-c.y-u.y;return{x:f,y:d,width:l.width,height:l.height}}function kh(e){return Ps(e).position==="static"}function Gj(e,t){if(!Vr(e)||Ps(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return lr(e)===s&&(s=s.ownerDocument.body),s}function Kk(e,t){const s=kn(e);if(hd(e))return s;if(!Vr(e)){let i=yi(e);for(;i&&!Jl(i);){if(Is(i)&&!kh(i))return i;i=yi(i)}return s}let r=Gj(e,t);for(;r&&Z2(r)&&kh(r);)r=Gj(r,t);return r&&Jl(r)&&kh(r)&&!Ag(r)?s:r||nI(e)||s}const pI=async function(e){const t=this.getOffsetParent||Kk,s=this.getDimensions,r=await s(e.floating);return{reference:mI(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function gI(e){return Ps(e).direction==="rtl"}const xI={convertOffsetParentRelativeRectToViewportRelativeRect:iI,getDocumentElement:lr,getClippingRect:hI,getOffsetParent:Kk,getElementRects:pI,getClientRects:aI,getDimensions:fI,getScale:pa,isElement:Is,isRTL:gI};function Gk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function vI(e,t,s){let r=null,i;const a=lr(e);function l(){var f;clearTimeout(i),(f=r)==null||f.disconnect(),r=null}function o(f,d){f===void 0&&(f=!1),d===void 0&&(d=1),l();const m=e.getBoundingClientRect(),{left:p,top:v,width:w,height:k}=m;if(f||t(),!w||!k)return;const g=rc(v),x=rc(a.clientWidth-(p+w)),y=rc(a.clientHeight-(v+k)),j=rc(p),b={rootMargin:-g+"px "+-x+"px "+-y+"px "+-j+"px",threshold:Ks(0,Dr(1,d))||1};let S=!0;function C(R){const E=R[0].intersectionRatio;if(!Gk(m,e.getBoundingClientRect()))return o();if(E!==d){if(!S)return o();E?o(!1,E):i=setTimeout(()=>{o(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...b,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,b)}r.observe(e)}const c=kn(e),u=()=>o(s);return c.addEventListener("resize",u),o(!0),()=>{c.removeEventListener("resize",u),l()}}function jI(e,t,s,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Rg(e),f=i||a?[...u?Xl(u):[],...t?Xl(t):[]]:[];f.forEach(g=>{i&&g.addEventListener("scroll",s),a&&g.addEventListener("resize",s)});const d=u&&o?vI(u,s,a):null;let m=-1,p=null;l&&(p=new ResizeObserver(g=>{let[x]=g;x&&x.target===u&&p&&t&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),s()}),u&&!c&&p.observe(u),t&&p.observe(t));let v,w=c?wi(e):null;c&&k();function k(){const g=wi(e);w&&!Gk(w,g)&&s(),w=g,v=requestAnimationFrame(k)}return s(),()=>{var g;f.forEach(x=>{i&&x.removeEventListener("scroll",s),a&&x.removeEventListener("resize",s)}),d==null||d(),(g=p)==null||g.disconnect(),p=null,c&&cancelAnimationFrame(v)}}const yI=q2,wI=Q2,bI=K2,kI=X2,SI=G2,Yj=V2,NI=J2,CI=(e,t,s)=>{const r=new Map,i=s??{},a={...xI,...i.platform,_c:r};return H2(e,t,{...i,platform:a})};var EI=typeof document<"u",AI=function(){},Hc=EI?h.useLayoutEffect:AI;function Au(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 s,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(r=s;r--!==0;)if(!Au(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),s=i.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=s;r--!==0;){const a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!Au(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Yk(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qj(e,t){const s=Yk(e);return Math.round(t*s)/s}function Sh(e){const t=h.useRef(e);return Hc(()=>{t.current=e}),t}function TI(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:l}={},transform:o=!0,whileElementsMounted:c,open:u}=e,[f,d]=h.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);Au(m,r)||p(r);const[v,w]=h.useState(null),[k,g]=h.useState(null),x=h.useCallback(D=>{D!==b.current&&(b.current=D,w(D))},[]),y=h.useCallback(D=>{D!==S.current&&(S.current=D,g(D))},[]),j=a||v,N=l||k,b=h.useRef(null),S=h.useRef(null),C=h.useRef(f),R=c!=null,E=Sh(c),P=Sh(i),F=Sh(u),M=h.useCallback(()=>{if(!b.current||!S.current)return;const D={placement:t,strategy:s,middleware:m};P.current&&(D.platform=P.current),CI(b.current,S.current,D).then(Y=>{const B={...Y,isPositioned:F.current!==!1};T.current&&!Au(C.current,B)&&(C.current=B,Ca.flushSync(()=>{d(B)}))})},[m,t,s,P,F]);Hc(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,d(D=>({...D,isPositioned:!1})))},[u]);const T=h.useRef(!1);Hc(()=>(T.current=!0,()=>{T.current=!1}),[]),Hc(()=>{if(j&&(b.current=j),N&&(S.current=N),j&&N){if(E.current)return E.current(j,N,M);M()}},[j,N,M,E,R]);const $=h.useMemo(()=>({reference:b,floating:S,setReference:x,setFloating:y}),[x,y]),_=h.useMemo(()=>({reference:j,floating:N}),[j,N]),K=h.useMemo(()=>{const D={position:s,left:0,top:0};if(!_.floating)return D;const Y=qj(_.floating,f.x),B=qj(_.floating,f.y);return o?{...D,transform:"translate("+Y+"px, "+B+"px)",...Yk(_.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:Y,top:B}},[s,o,_.floating,f.x,f.y]);return h.useMemo(()=>({...f,update:M,refs:$,elements:_,floatingStyles:K}),[f,M,$,_,K])}const RI=e=>{function t(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:r,padding:i}=typeof e=="function"?e(s):e;return r&&t(r)?r.current!=null?Yj({element:r.current,padding:i}).fn(s):{}:r?Yj({element:r,padding:i}).fn(s):{}}}},II=(e,t)=>{const s=yI(e);return{name:s.name,fn:s.fn,options:[e,t]}},PI=(e,t)=>{const s=wI(e);return{name:s.name,fn:s.fn,options:[e,t]}},MI=(e,t)=>({fn:NI(e).fn,options:[e,t]}),$I=(e,t)=>{const s=bI(e);return{name:s.name,fn:s.fn,options:[e,t]}},DI=(e,t)=>{const s=kI(e);return{name:s.name,fn:s.fn,options:[e,t]}},OI=(e,t)=>{const s=SI(e);return{name:s.name,fn:s.fn,options:[e,t]}},_I=(e,t)=>{const s=RI(e);return{name:s.name,fn:s.fn,options:[e,t]}};var LI=Object.defineProperty,FI=(e,t)=>LI(e,"name",{value:t,configurable:!0});function qk(e){const[t,s]=h.useState(void 0);return bn(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let l,o;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;l=u.inlineSize,o=u.blockSize}else l=e.offsetWidth,o=e.offsetHeight;s({width:l,height:o})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else s(void 0)},[e]),t}FI(qk,"useSize");var UI=Object.defineProperty,Er=(e,t)=>UI(e,"name",{value:t,configurable:!0}),Qk="Popper",[Jk,pd]=fs(Qk),[BI,Xk]=Jk(Qk),zI=Er(e=>{const{__scopePopper:t,children:s}=e,[r,i]=h.useState(null),[a,l]=h.useState(void 0);return n.jsx(BI,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:l,children:s})},"Popper"),WI="PopperAnchor",HI=h.forwardRef(Er(function(t,s){const{__scopePopper:r,virtualRef:i,...a}=t,l=Xk(WI,r),o=h.useRef(null),c=l.onAnchorChange,u=h.useCallback(w=>{o.current=w,w&&c(w)},[c]),f=it(s,u),d=h.useRef(null);h.useEffect(()=>{if(!i)return;const w=d.current;d.current=i.current,w!==d.current&&c(d.current)});const m=l.placementState&&gd(l.placementState),p=m==null?void 0:m[0],v=m==null?void 0:m[1];return i?null:n.jsx(mt.div,{"data-radix-popper-side":p,"data-radix-popper-align":v,...a,ref:f})},"PopperAnchor")),Zk="PopperContent",[VI,SH]=Jk(Zk),KI=h.forwardRef(Er(function(t,s){var je,X,be,Ee,qe,Ie,et;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:l="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:d=0,sticky:m="partial",hideWhenDetached:p=!1,updatePositionStrategy:v="optimized",onPlaced:w,...k}=t,g=Xk(Zk,r),[x,y]=h.useState(null),j=it(s,y),[N,b]=h.useState(null),S=qk(N),C=(S==null?void 0:S.width)??0,R=(S==null?void 0:S.height)??0,E=i+(l!=="center"?"-"+l:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(f)?f:[f],M=F.length>0,T={padding:P,boundary:F.filter(eS),altBoundary:M},{refs:$,floatingStyles:_,placement:K,isPositioned:D,middlewareData:Y}=TI({strategy:"fixed",placement:E,whileElementsMounted:Er((...z)=>jI(...z,{animationFrame:v==="always"}),"whileElementsMounted"),elements:{reference:g.anchor},middleware:[II({mainAxis:a+R,alignmentAxis:o}),u&&PI({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?MI():void 0,...T}),u&&$I({...T}),DI({...T,apply:Er(({elements:z,rects:se,availableWidth:Ae,availableHeight:Me})=>{const{width:ot,height:Ne}=se.reference,_e=z.floating.style;_e.setProperty("--radix-popper-available-width",`${Ae}px`),_e.setProperty("--radix-popper-available-height",`${Me}px`),_e.setProperty("--radix-popper-anchor-width",`${ot}px`),_e.setProperty("--radix-popper-anchor-height",`${Ne}px`)},"apply")}),N&&_I({element:N,padding:c}),GI({arrowWidth:C,arrowHeight:R}),p&&OI({strategy:"referenceHidden",...T,boundary:M?T.boundary:void 0})]}),B=g.setPlacementState;bn(()=>(B(K),()=>{B(void 0)}),[K,B]);const[V,de]=gd(K),ae=es(w);bn(()=>{D&&(ae==null||ae())},[D,ae]);const le=(je=Y.arrow)==null?void 0:je.x,Ce=(X=Y.arrow)==null?void 0:X.y,ee=((be=Y.arrow)==null?void 0:be.centerOffset)!==0,[ce,fe]=h.useState();return bn(()=>{x&&fe(window.getComputedStyle(x).zIndex)},[x]),n.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:D?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[(Ee=Y.transformOrigin)==null?void 0:Ee.x,(qe=Y.transformOrigin)==null?void 0:qe.y].join(" "),...((Ie=Y.hide)==null?void 0:Ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:n.jsx(VI,{scope:r,placedSide:V,placedAlign:de,onArrowChange:b,arrowX:le,arrowY:Ce,shouldHideArrow:ee,children:n.jsx(mt.div,{"data-side":V,"data-align":de,...k,ref:j,style:{...k.style,animation:D?(et=k.style)==null?void 0:et.animation:"none"}})})})},"PopperContent"));function eS(e){return e!==null}Er(eS,"isNotNull");var GI=Er(e=>({name:"transformOrigin",options:e,fn(t){var k,g,x;const{placement:s,rects:r,middlewareData:i}=t,l=((k=i.arrow)==null?void 0:k.centerOffset)!==0,o=l?0:e.arrowWidth,c=l?0:e.arrowHeight,[u,f]=gd(s),d={start:"0%",center:"50%",end:"100%"}[f],m=(((g=i.arrow)==null?void 0:g.x)??0)+o/2,p=(((x=i.arrow)==null?void 0:x.y)??0)+c/2;let v="",w="";return u==="bottom"?(v=l?d:`${m}px`,w=`${-c}px`):u==="top"?(v=l?d:`${m}px`,w=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,w=l?d:`${p}px`):u==="left"&&(v=`${r.floating.width+c}px`,w=l?d:`${p}px`),{data:{x:v,y:w}}}}),"transformOrigin");function gd(e){const[t,s="center"]=e.split("-");return[t,s]}Er(gd,"getSideAndAlignFromPlacement");var Ig=zI,tS=HI,nS=KI,YI=Object.defineProperty,Lt=(e,t)=>YI(e,"name",{value:t,configurable:!0}),[Pg,NH]=fs("Tooltip",[pd]),Mg=pd(),qI="TooltipProvider",QI=700,pm="tooltip.open",[JI,$g]=Pg(qI),XI=Lt(e=>{const{__scopeTooltip:t,delayDuration:s=QI,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,l=h.useRef(!0),o=h.useRef(!1),c=h.useRef(0);return h.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),n.jsx(JI,{scope:t,isOpenDelayedRef:l,delayDuration:s,onOpen:h.useCallback(()=>{r<=0||(window.clearTimeout(c.current),l.current=!1)},[r]),onClose:h.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,r))},[r]),isPointerInTransitRef:o,onPointerInTransitChange:h.useCallback(u=>{o.current=u},[]),disableHoverableContent:i,children:a})},"TooltipProvider"),gm="Tooltip",[ZI,bo]=Pg(gm),eP=Lt(e=>{const{__scopeTooltip:t,children:s,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:l,delayDuration:o}=e,c=$g(gm,e.__scopeTooltip),u=Mg(t),[f,d]=h.useState(null),[m,p]=h.useState(void 0),v=os(),w=h.useRef(0),k=l??c.disableHoverableContent,g=o??c.delayDuration,x=h.useRef(!1),[y,j]=Ei({prop:r,defaultProp:i??!1,onChange:Lt(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(pm))):c.onClose(),a==null||a(E)},"onChange"),caller:gm}),N=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),b=h.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x.current=!1,j(!0)},[j]),S=h.useCallback(()=>{window.clearTimeout(w.current),w.current=0,j(!1)},[j]),C=h.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{x.current=!0,j(!0),w.current=0},g)},[g,j]);h.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const R=m??v;return n.jsx(Ig,{...u,children:n.jsx(ZI,{scope:t,contentId:R,setContentId:p,open:y,stateAttribute:N,trigger:f,onTriggerChange:d,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?C():b()},[c.isOpenDelayedRef,C,b]),onTriggerLeave:h.useCallback(()=>{k?S():(window.clearTimeout(w.current),w.current=0)},[S,k]),onOpen:b,onClose:S,disableHoverableContent:k,children:s})})},"Tooltip"),Qj="TooltipTrigger",tP=h.forwardRef(Lt(function(t,s){const{__scopeTooltip:r,...i}=t,a=bo(Qj,r),l=$g(Qj,r),o=Mg(r),c=h.useRef(null),u=it(s,c,a.onTriggerChange),f=h.useRef(!1),d=h.useRef(!1),m=h.useCallback(()=>f.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),n.jsx(tS,{asChild:!0,...o,children:n.jsx(mt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:u,onPointerMove:Re(t.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),d.current=!0)}),onPointerLeave:Re(t.onPointerLeave,()=>{a.onTriggerLeave(),d.current=!1}),onPointerDown:Re(t.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:Re(t.onFocus,()=>{f.current||a.onOpen()}),onBlur:Re(t.onBlur,a.onClose),onClick:Re(t.onClick,a.onClose)})})},"TooltipTrigger")),sS="TooltipPortal",[nP,sP]=Pg(sS,{forceMount:void 0}),rP=Lt(e=>{const{__scopeTooltip:t,forceMount:s,children:r,container:i}=e,a=bo(sS,t);return n.jsx(nP,{scope:t,forceMount:s,children:n.jsx(ar,{present:s||a.open,children:n.jsx(Sg,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Zl="TooltipContent",iP=h.forwardRef(Lt(function(t,s){const r=sP(Zl,t.__scopeTooltip),{forceMount:i=r.forceMount,side:a="top",...l}=t,o=bo(Zl,t.__scopeTooltip);return n.jsx(ar,{present:i||o.open,children:o.disableHoverableContent?n.jsx(rS,{side:a,...l,ref:s}):n.jsx(aP,{side:a,...l,ref:s})})},"TooltipContent")),aP=h.forwardRef(Lt(function(t,s){const r=bo(Zl,t.__scopeTooltip),i=$g(Zl,t.__scopeTooltip),a=h.useRef(null),l=it(s,a),[o,c]=h.useState(null),{trigger:u,onClose:f}=r,d=a.current,{onPointerInTransitChange:m}=i,p=h.useCallback(()=>{c(null),m(!1)},[m]),v=h.useCallback((w,k)=>{const g=w.currentTarget,x={x:w.clientX,y:w.clientY},y=iS(x,g.getBoundingClientRect()),j=aS(x,y),N=lS(k.getBoundingClientRect()),b=cS([...j,...N]);c(b),m(!0)},[m]);return h.useEffect(()=>()=>p(),[p]),h.useEffect(()=>{if(u&&d){const w=Lt(g=>v(g,d),"handleTriggerLeave"),k=Lt(g=>v(g,u),"handleContentLeave");return u.addEventListener("pointerleave",w),d.addEventListener("pointerleave",k),()=>{u.removeEventListener("pointerleave",w),d.removeEventListener("pointerleave",k)}}},[u,d,v,p]),h.useEffect(()=>{if(o){const w=Lt(k=>{const g=k.target,x={x:k.clientX,y:k.clientY},y=(u==null?void 0:u.contains(g))||(d==null?void 0:d.contains(g)),j=!oS(x,o);y?p():j&&(p(),f())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,d,o,f,p]),n.jsx(rS,{...t,ref:l})},"TooltipContentHoverable")),lP=dk("TooltipContent"),rS=h.forwardRef(Lt(function(t,s){const{__scopeTooltip:r,children:i,"aria-label":a,id:l,onEscapeKeyDown:o,onPointerDownOutside:c,...u}=t,f=bo(Zl,r),d=Mg(r),{onClose:m}=f;h.useEffect(()=>(document.addEventListener(pm,m),()=>document.removeEventListener(pm,m)),[m]),h.useEffect(()=>{if(f.trigger){const v=Lt(w=>{w.target instanceof Node&&w.target.contains(f.trigger)&&m()},"handleScroll");return window.addEventListener("scroll",v,{capture:!0}),()=>window.removeEventListener("scroll",v,{capture:!0})}},[f.trigger,m]);const{setContentId:p}=f;return bn(()=>(p(l),()=>{p(void 0)}),[l,p]),n.jsx(bg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:v=>v.preventDefault(),onDismiss:m,children:n.jsxs(nS,{"data-state":f.stateAttribute,role:a?void 0:"tooltip",id:a?void 0:f.contentId,...d,...u,ref:s,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:[n.jsx(lP,{children:i}),a?n.jsx(m2,{id:f.contentId,role:"tooltip",children:a}):null]})})},"TooltipContentImpl"));function iS(e,t){const s=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(s,r,i,a)){case a:return"left";case i:return"right";case s:return"top";case r:return"bottom";default:throw new Error("unreachable")}}Lt(iS,"getExitSideFromRect");function aS(e,t,s=5){const r=[];switch(t){case"top":r.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":r.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":r.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":r.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return r}Lt(aS,"getPaddedExitPoints");function lS(e){const{top:t,right:s,bottom:r,left:i}=e;return[{x:i,y:t},{x:s,y:t},{x:s,y:r},{x:i,y:r}]}Lt(lS,"getPointsFromRect");function oS(e,t){const{x:s,y:r}=e;let i=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const o=t[a],c=t[l],u=o.x,f=o.y,d=c.x,m=c.y;f>r!=m>r&&s<(d-u)*(r-f)/(m-f)+u&&(i=!i)}return i}Lt(oS,"isPointInPolygon");function cS(e){const t=e.slice();return t.sort((s,r)=>s.x<r.x?-1:s.x>r.x?1:s.y<r.y?-1:s.y>r.y?1:0),uS(t)}Lt(cS,"getHull");function uS(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 a=t[t.length-1],l=t[t.length-2];if((a.x-l.x)*(i.y-l.y)>=(a.y-l.y)*(i.x-l.x))t.pop();else break}t.push(i)}t.pop();const s=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;s.length>=2;){const a=s[s.length-1],l=s[s.length-2];if((a.x-l.x)*(i.y-l.y)>=(a.y-l.y)*(i.x-l.x))s.pop();else break}s.push(i)}return s.pop(),t.length===1&&s.length===1&&t[0].x===s[0].x&&t[0].y===s[0].y?t:t.concat(s)}Lt(uS,"getHullPresorted");var Jj=XI,eo=eP,to=tP,no=rP,so=iP;const Xj="buddi_csrf",Ha="x-buddi-csrf",ro="buddi:agents-changed",oP="This page's sign-in no longer matches its cookies. Reload the page and try again.";class he extends Error{constructor(t,s,r){super(s),this.status=t,this.detail=r,this.name="ApiError"}}function Ai(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${Xj}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const s=[...document.cookie.matchAll(new RegExp(`(?:^|; )${Xj}(?:_\\d+)?=([^;]*)`,"g"))];return s.length===1&&((r=s[0])!=null&&r[1])?decodeURIComponent(s[0][1]):""}const Tu="buddi isn't answering.";let xm=null;const vm=new Set;function ic(e){if(e!==(xm===null)){xm=e?null:Date.now();for(const t of vm)t()}}function cP(){return xm}function uP(e){return vm.add(e),()=>vm.delete(e)}function dP(e){return e instanceof he&&(e.status===0||e.status===502||e.status===503)&&e.message===Tu}async function Ti(e,t={}){var l;let s;try{s=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}})}catch(o){throw(o==null?void 0:o.name)==="AbortError"||(l=t.signal)!=null&&l.aborted?o:(ic(!1),new he(0,Tu,o))}if(s.status===401)throw ic(!0),new he(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await s.text(),i=r===""?null:hP(r),a=i&&typeof i=="object"&&"error"in i?String(i.error):void 0;if((s.status===502||s.status===503)&&a===void 0)throw ic(!1),new he(s.status,Tu,i);if(ic(!0),!s.ok){const o=(t.method??"GET").toUpperCase(),c=a??(s.status===403&&o!=="GET"&&o!=="HEAD"?oP:`request failed (${s.status})`);throw new he(s.status,c,i)}return i}function hP(e){try{return JSON.parse(e)}catch{return null}}function ue(e,t={}){const s=new URLSearchParams;for(const[i,a]of Object.entries(t))a!==void 0&&a!==""&&s.set(i,String(a));const r=s.toString();return Ti(`/api${e}${r?`?${r}`:""}`)}function dS(e,t){return Ti(`/api${e}`,{method:"POST",headers:{[Ha]:Ai()},body:t})}function la(e){return Ti(`/api${e}`,{method:"DELETE",headers:{[Ha]:Ai()}})}function Z(e,t={}){return Ti(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[Ha]:Ai()},body:JSON.stringify(t??{})})}function hS(e,t,s,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||s;return Ti(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[Ha]:Ai(),"X-Filename":i,...r},body:t})}function Zj(e,t,s){return hS(e,t,"backup.tar.gz",{...s.passphrase?{"X-Backup-Passphrase":s.passphrase}:{},...s.confirm?{"X-Backup-Confirm":s.confirm}:{}})}function fP(e,t={}){return Ti(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[Ha]:Ai()},body:JSON.stringify(t??{})})}function ei(e,t={}){return Ti(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[Ha]:Ai()},body:JSON.stringify(t??{})})}function mP(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 Vc="gpt-oss:120b",pP=["approval","question","watcher","reminder","failure","recap","plugin"],jm=["mon","tue","wed","thu","fri","sat","sun"],Le={agents:()=>ue("/chat/agents"),views:()=>ue("/chat/views"),conversations:(e,t)=>ue(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>Z(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>ue(`/chat/conversations/${encodeURIComponent(e)}`),send:(e,t)=>Z(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>Z(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>Z(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),dS("/chat/attachments",t)},transcribe:e=>Z("/speech/transcribe",e),say:e=>Z("/speech/say",e),discardAttachment:e=>la(`/artifacts/${encodeURIComponent(e)}`),groups:()=>ue("/groups"),group:e=>ue(`/groups/${encodeURIComponent(e)}`),createGroup:e=>Z("/groups",e),updateGroup:(e,t)=>fP(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>la(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>ue(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>Z(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>Z(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`};function Dg(e){return e.httpStatus===401||e.httpStatus===403||e.state==="authentication-error"||e.state==="access-denied"}const A={providers:()=>ue("/providers"),providerAccounts:()=>ue("/provider-accounts"),probeModels:e=>Z("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>Z(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>Z("/provider-accounts/save",e),testProviderAccount:e=>Z(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,s)=>Z(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:s}),ollamaConnect:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/connect`,{revision:t}),ollamaPoll:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/poll`,{attemptId:t}),ollamaDisconnect:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/disconnect`,{revision:t}),anthropicAccountAction:(e,t,s,r)=>Z(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:s,...r}),assignProviderAccount:(e,t,s)=>Z(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:s}),configureProvider:(e,t)=>Z(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>Z(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>Z(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>Z(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>ue("/host/browser-profiles",{app:e}),installedApps:()=>ue("/host/apps"),browser:e=>ue(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>Z(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>Z("/browser/settings",e),computerPermissions:(e=!1)=>Z("/browser/permissions",{prompt:e}),browserInstall:()=>Z("/browser/install",{}),browserCheck:()=>Z("/browser/check",{}),previewLink:(e,t)=>ue(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>ue(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>ue("/extension"),pairExtension:e=>Z("/extension/pair",{code:e}),forgetExtension:()=>la("/extension/pair"),session:()=>ue("/session"),overview:()=>ue("/overview"),events:e=>ue("/events",e),eventKinds:()=>ue("/events/kinds"),conversations:()=>ue("/conversations"),conversation:e=>ue(`/conversations/${encodeURIComponent(e)}`),missions:()=>ue("/missions"),jobs:(e={})=>ue("/jobs",e),approvals:()=>ue("/approvals"),approval:e=>ue(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>ue("/offers"),dismissOffer:e=>Z(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>Z("/offers/dismiss-all",{ids:e}),agentOffers:()=>ue("/agent-offers"),teammates:()=>ue("/teammates"),dismissAgentOffer:(e,t)=>Z(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>ue("/proposals"),setDigestSchedule:(e,t)=>Z("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>Z(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),discardProposal:(e,t)=>Z(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>ue("/reminders"),sentinels:()=>ue("/sentinels"),setSentinelEnabled:(e,t)=>Z(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),setGlanceHidden:(e,t)=>Z(`/home/glances/${encodeURIComponent(e)}/hidden`,{hidden:t}),rail:()=>ue("/rail"),setRailHidden:(e,t,s)=>Z(`/rail/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}/hidden`,{hidden:s}),snoozeAlert:(e,t)=>Z(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>ue("/agents"),library:e=>ue("/artifacts",e),libraryEntry:(e,t=0)=>ue(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>ue("/onboarding"),onboardingStep:(e,t={})=>Z("/onboarding/step",{step:e,...t}),completeOnboarding:()=>Z("/onboarding/complete"),skipOnboarding:()=>Z("/onboarding/skip"),createFirstAgent:e=>Z("/onboarding/agent",e),ollama:()=>ue("/onboarding/ollama"),firstAgentPersona:()=>ue("/onboarding/agent"),updateFirstAgent:e=>Z("/onboarding/agent/update",e),bindBrain:e=>Z("/onboarding/brain",e),pages:()=>ue("/pages"),pageQuery:(e,t,s={})=>ue(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,s),pageFileUrl:(e,t,s={})=>{const r=new URLSearchParams(Object.entries(s).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>Z(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>ue("/telegram"),saveTelegramToken:e=>Z("/telegram/token",{token:e}),telegramPairing:()=>Z("/telegram/pairing"),telegramBot:()=>ue("/telegram/bot"),telegramDevices:()=>ue("/telegram/devices"),unpairTelegramDevice:e=>la(`/telegram/devices/${encodeURIComponent(e)}`),notifications:(e=20)=>ue("/notifications",{limit:e}),notificationSeen:e=>Z(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>ue("/notifications/settings"),saveNotificationSettings:e=>ei("/notifications/settings",e),focus:()=>ue("/notifications/focus"),setFocus:(e,t)=>ei("/notifications/focus",t?{mode:e,duration:t}:{mode:e}),testChannel:e=>Z("/notifications/test",{channel:e}),currentTip:e=>ue(e?`/tips/current?preview=${encodeURIComponent(e)}`:"/tips/current"),tips:()=>ue("/tips"),restoreTip:e=>Z(`/tips/${encodeURIComponent(e)}/restore`),dismissTip:e=>Z(`/tips/${encodeURIComponent(e)}/dismiss`),laterTip:e=>Z(`/tips/${encodeURIComponent(e)}/later`),tipsSeenPage:e=>Z("/tips/seen-page",{page:e}),tipsSettings:()=>ue("/tips/settings"),saveTipsSettings:e=>ei("/tips/settings",{enabled:e}),presence:e=>Z("/presence",{state:e}),owner:()=>ue("/owner"),setOwner:e=>Z("/owner",e),memory:e=>ue(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>Z("/memory/preferences",e),forgetPreference:e=>Z("/memory/preferences/forget",e),updateNote:(e,t)=>Z(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>Z(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>ue(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>ue(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>ue("/host",{agentId:e,conversationId:t}),connections:()=>ue("/connections"),connection:e=>ue(`/connections/${e}`),addConnection:(e,t)=>Z("/connections",{url:e,...t?{name:t}:{}}),connectionConsent:(e,t)=>Z(`/connections/${e}/consent`,t?{clientId:t}:{}),connectionCallback:e=>Z("/connections/callback",e),connectionReview:e=>ue(`/connections/${e}/review`),saveConnectionReview:(e,t)=>Z(`/connections/${e}/review`,t),grantConnection:(e,t)=>Z(`/connections/${e}/grant`,{agents:t}),disconnect:e=>la(`/connections/${e}`),connectionSignals:()=>ue("/connections/signals"),connectionTools:e=>ue(`/connections/${e}/tools`),rememberedApprovals:e=>ue(`/connections/remembered/${encodeURIComponent(e)}`),setRememberedApproval:(e,t,s)=>Z("/connections/remembered",{agent:e,tool:t,remember:s}),secrets:()=>ue("/secrets"),secretUses:(e,t)=>ue("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>Z("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>Z("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>Z("/host/revoke",{id:e}),decide:(e,t,s,r)=>Z(`/approvals/${encodeURIComponent(e)}/${t}`,s||r?{...s?{permissionScope:s}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>Z("/pause",{paused:e}),service:()=>ue("/service"),serviceAction:e=>Z(`/service/${e}`),version:()=>ue("/version"),checkVersion:()=>Z("/version/check"),setVersionCheck:e=>ei("/version/check",{enabled:e}),tailscale:()=>ue("/tailscale"),setTailscale:e=>ei("/tailscale",e),startUpgrade:e=>Z("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>ue(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>ue("/backups"),startBackup:e=>Z("/backups",{encrypt:e}),verifyArchive:e=>Z("/backups/verify",{name:e}),restoreArchive:e=>Z("/backups/restore",e),restoreUpload:(e,t)=>Zj("/backups/restore",e,t),backupJob:e=>ue(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>ue("/backups/schedule"),setBackupSchedule:e=>ei("/backups/schedule",e),backupPassphrase:()=>ue("/backups/passphrase"),setBackupPassphrase:e=>ei("/backups/passphrase",{passphrase:e}),plugins:()=>ue("/plugins"),market:(e=!1)=>ue(`/market${e?"?refresh=1":""}`),marketAssetUrl:e=>`/api/market/asset?url=${encodeURIComponent(e)}`,pluginFolders:e=>ue("/plugins/folders",e?{path:e}:{}),stagePlugin:e=>Z("/plugins/stage",{spec:e}),uploadPlugin:e=>hS("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>ue(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>Z(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>Z(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),setPluginEnabled:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/${t?"enable":"disable"}`,{}),uninstallPlugin:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>ue("/recovery"),leaveRecovery:e=>Z("/recovery/leave",e),firstRunRestore:(e,t)=>Zj("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>Z(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,s)=>Z(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...s===void 0?{}:{deadlineMinutes:s}}),retryJob:e=>Z(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>Z(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>Z("/agents/default",{agentId:e}),agentTools:e=>ue(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>ue(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const s=new FormData;return s.append("file",t,t.name),dS(`/agents/${encodeURIComponent(e)}/avatar`,s)},removeAgentPicture:e=>la(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>Z(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>Z(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};function fS(e){return e==="anthropic"||e==="openai"}function mS(e,t){var i,a;if(!e)return null;const s=e.credentialEnv&&(t!=null&&t.accounts.some(l=>l.id===e.credentialEnv))?e.credentialEnv:(a=(i=t==null?void 0:t.bindings)==null?void 0:i.find(l=>l.agentId===e.id))==null?void 0:a.accountId,r=s?t==null?void 0:t.accounts.find(l=>l.id===s):void 0;return(r==null?void 0:r.kind)??e.provider}const gP="Thinking is up to this model. What it writes while thinking is shown apart and kept out of the answer.";var xP=Object.defineProperty,vP=(e,t)=>xP(e,"name",{value:t,configurable:!0}),jP=h.createContext(void 0);function xd(e){const t=h.useContext(jP);return e||t||"ltr"}vP(xd,"useDirection");var yP=Object.defineProperty,Og=(e,t)=>yP(e,"name",{value:t,configurable:!0}),ac=0,ws=null;function wP(e){return vd(),e.children}Og(wP,"FocusGuards");function vd(){h.useEffect(()=>{ws||(ws={start:ym(),end:ym()});const{start:e,end:t}=ws;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ac++,()=>{ac===1&&(ws==null||ws.start.remove(),ws==null||ws.end.remove(),ws=null),ac=Math.max(0,ac-1)}},[])}Og(vd,"useFocusGuards");function ym(){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}Og(ym,"createFocusGuard");var bP=Object.defineProperty,cn=(e,t)=>bP(e,"name",{value:t,configurable:!0}),Nh="focusScope.autoFocusOnMount",Ch="focusScope.autoFocusOnUnmount",ey={bubbles:!1,cancelable:!0},pS=h.forwardRef(cn(function(t,s){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...o}=t,[c,u]=h.useState(null),f=es(a),d=es(l),m=h.useRef(null),p=it(s,u),v=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(i){let k=function(j){if(v.paused||!c)return;const N=j.target;c.contains(N)?m.current=N:Us(m.current,{select:!0})},g=function(j){if(v.paused||!c)return;const N=j.relatedTarget;N!==null&&(c.contains(N)||Us(m.current,{select:!0}))},x=function(j){if(document.activeElement===document.body)for(const b of j)b.removedNodes.length>0&&Us(c)};cn(k,"handleFocusIn"),cn(g,"handleFocusOut"),cn(x,"handleMutations"),document.addEventListener("focusin",k),document.addEventListener("focusout",g);const y=new MutationObserver(x);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",g),y.disconnect()}}},[i,c,v.paused]),h.useEffect(()=>{if(c){ty.add(v);const k=document.activeElement;if(!c.contains(k)){const x=new CustomEvent(Nh,ey);c.addEventListener(Nh,f),c.dispatchEvent(x),x.defaultPrevented||(gS(wS(_g(c)),{select:!0}),document.activeElement===k&&Us(c))}return()=>{c.removeEventListener(Nh,f),setTimeout(()=>{const x=new CustomEvent(Ch,ey);c.addEventListener(Ch,d),c.dispatchEvent(x),x.defaultPrevented||Us(k??document.body,{select:!0}),c.removeEventListener(Ch,d),ty.remove(v)},0)}}},[c,f,d,v]);const w=h.useCallback(k=>{if(!r&&!i||v.paused)return;const g=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,x=document.activeElement;if(g&&x){const y=k.currentTarget,[j,N]=xS(y);j&&N?!k.shiftKey&&x===N?(k.preventDefault(),r&&Us(j,{select:!0})):k.shiftKey&&x===j&&(k.preventDefault(),r&&Us(N,{select:!0})):x===y&&k.preventDefault()}},[r,i,v.paused]);return n.jsx(mt.div,{tabIndex:-1,...o,ref:p,onKeyDown:w})},"FocusScope"));function gS(e,{select:t=!1}={}){const s=document.activeElement;for(const r of e)if(Us(r,{select:t}),document.activeElement!==s)return}cn(gS,"focusFirst");function xS(e){const t=_g(e),s=wm(t,e),r=wm(t.reverse(),e);return[s,r]}cn(xS,"getTabbableEdges");function _g(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:cn(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(;s.nextNode();)t.push(s.currentNode);return t}cn(_g,"getTabbableCandidates");function wm(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(s?!r.checkVisibility({checkVisibilityCSS:!0}):vS(r,{upTo:t})))return r}cn(wm,"findVisible");function vS(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}cn(vS,"isHidden");function jS(e){return e instanceof HTMLInputElement&&"select"in e}cn(jS,"isSelectableInput");function Us(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&jS(e)&&t&&e.select()}}cn(Us,"focus");var ty=yS();function yS(){let e=[];return{add(t){const s=e[0];t!==s&&(s==null||s.pause()),e=bm(e,t),e.unshift(t)},remove(t){var s;e=bm(e,t),(s=e[0])==null||s.resume()}}}cn(yS,"createFocusScopesStack");function bm(e,t){const s=[...e],r=s.indexOf(t);return r!==-1&&s.splice(r,1),s}cn(bm,"arrayRemove");function wS(e){return e.filter(t=>t.tagName!=="A")}cn(wS,"removeLinks");var kP=Object.defineProperty,Lg=(e,t)=>kP(e,"name",{value:t,configurable:!0}),Eh=!1;function bS(){const[e,t]=h.useState(Eh);return h.useEffect(()=>{Eh||(Eh=!0,t(!0))},[]),e}Lg(bS,"useIsHydrated");var kS=La[" useSyncExternalStore ".trim().toString()];function SS(){return()=>{}}Lg(SS,"subscribe");function NS(){return kS(SS,()=>!0,()=>!1)}Lg(NS,"useIsHydratedModern");var SP=typeof kS=="function"?NS:bS,NP=Object.defineProperty,Ri=(e,t)=>NP(e,"name",{value:t,configurable:!0}),Ah="rovingFocusGroup.onEntryFocus",CP={bubbles:!1,cancelable:!0},jd="RovingFocusGroup",[km,CS,EP]=od(jd),[AP,yd]=fs(jd,[EP]),[TP,RP]=AP(jd),IP=h.forwardRef(Ri(function(t,s){return n.jsx(km.Provider,{scope:t.__scopeRovingFocusGroup,children:n.jsx(km.Slot,{scope:t.__scopeRovingFocusGroup,children:n.jsx(PP,{...t,ref:s})})})},"RovingFocusGroup")),PP=h.forwardRef(Ri(function(t,s){const{__scopeRovingFocusGroup:r,orientation:i,loop:a=!1,dir:l,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:d=!1,...m}=t,p=h.useRef(null),v=it(s,p),w=xd(l),[k,g]=Ei({prop:o,defaultProp:c??null,onChange:u,caller:jd}),[x,y]=h.useState(!1),j=es(f),N=CS(r),b=h.useRef(!1),[S,C]=h.useState(0);return h.useEffect(()=>{const R=p.current;if(R)return R.addEventListener(Ah,j),()=>R.removeEventListener(Ah,j)},[j]),n.jsx(TP,{scope:r,orientation:i,dir:w,loop:a,currentTabStopId:k,onItemFocus:h.useCallback(R=>g(R),[g]),onItemShiftTab:h.useCallback(()=>y(!0),[]),onFocusableItemAdd:h.useCallback(()=>C(R=>R+1),[]),onFocusableItemRemove:h.useCallback(()=>C(R=>R-1),[]),children:n.jsx(mt.div,{tabIndex:x||S===0?-1:0,"data-orientation":i,...m,ref:v,style:{outline:"none",...t.style},onMouseDown:Re(t.onMouseDown,()=>{b.current=!0}),onFocus:Re(t.onFocus,R=>{const E=!b.current;if(R.target===R.currentTarget&&E&&!x){const P=new CustomEvent(Ah,CP);if(R.currentTarget.dispatchEvent(P),!P.defaultPrevented){const F=N().filter(K=>K.focusable),M=F.find(K=>K.active),T=F.find(K=>K.id===k),_=[M,T,...F].filter(Boolean).map(K=>K.ref.current);Fg(_,d)}}b.current=!1}),onBlur:Re(t.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),MP="RovingFocusGroupItem",$P=h.forwardRef(Ri(function(t,s){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:a=!1,tabStopId:l,children:o,...c}=t,u=os(),f=l||u,d=RP(MP,r),m=d.currentTabStopId===f,p=CS(r),{onFocusableItemAdd:v,onFocusableItemRemove:w,currentTabStopId:k}=d,g=SP();return bn(()=>{if(!(!g||!i))return v(),()=>w()},[g,i,v,w]),h.useEffect(()=>{if(!(g||!i))return v(),()=>w()},[g,i,v,w]),n.jsx(km.ItemSlot,{scope:r,id:f,focusable:i,active:a,children:n.jsx(mt.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...c,ref:s,onMouseDown:Re(t.onMouseDown,x=>{i?d.onItemFocus(f):x.preventDefault()}),onFocus:Re(t.onFocus,()=>d.onItemFocus(f)),onKeyDown:Re(t.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=AS(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let N=p().filter(b=>b.focusable).map(b=>b.ref.current);if(y==="last")N.reverse();else if(y==="prev"||y==="next"){y==="prev"&&N.reverse();const b=N.indexOf(x.currentTarget);N=d.loop?TS(N,b+1):N.slice(b+1)}setTimeout(()=>Fg(N))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:k!=null}):o})})},"RovingFocusGroupItem")),DP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ES(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Ri(ES,"getDirectionAwareKey");function AS(e,t,s){const r=ES(e.key,s);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return DP[r]}Ri(AS,"getFocusIntent");function Fg(e,t=!1){const s=document.activeElement;for(const r of e)if(r===s||(r.focus({preventScroll:t}),document.activeElement!==s))return}Ri(Fg,"focusFirst");function TS(e,t){return e.map((s,r)=>e[(t+r)%e.length])}Ri(TS,"wrapArray");var RS=IP,IS=$P,OP=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Bi=new WeakMap,lc=new WeakMap,oc={},Th=0,PS=function(e){return e&&(e.host||PS(e.parentNode))},_P=function(e,t){return t.map(function(s){if(e.contains(s))return s;var r=PS(s);return r&&e.contains(r)?r:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},LP=function(e,t,s,r){var i=_P(t,Array.isArray(e)?e:[e]);oc[s]||(oc[s]=new WeakMap);var a=oc[s],l=[],o=new Set,c=new Set(i),u=function(d){!d||o.has(d)||(o.add(d),u(d.parentNode))};i.forEach(u);var f=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(m){if(o.has(m))f(m);else try{var p=m.getAttribute(r),v=p!==null&&p!=="false",w=(Bi.get(m)||0)+1,k=(a.get(m)||0)+1;Bi.set(m,w),a.set(m,k),l.push(m),w===1&&v&&lc.set(m,!0),k===1&&m.setAttribute(s,"true"),v||m.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",m,g)}})};return f(t),o.clear(),Th++,function(){l.forEach(function(d){var m=Bi.get(d)-1,p=a.get(d)-1;Bi.set(d,m),a.set(d,p),m||(lc.has(d)||d.removeAttribute(r),lc.delete(d)),p||d.removeAttribute(s)}),Th--,Th||(Bi=new WeakMap,Bi=new WeakMap,lc=new WeakMap,oc={})}},MS=function(e,t,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=OP(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),LP(r,i,s,"aria-hidden")):function(){return null}},Ns=function(){return Ns=Object.assign||function(t){for(var s,r=1,i=arguments.length;r<i;r++){s=arguments[r];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},Ns.apply(this,arguments)};function $S(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(s[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])&&(s[r[i]]=e[r[i]]);return s}function FP(e,t,s){if(s||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Kc="right-scroll-bar-position",Gc="width-before-scroll-bar",UP="with-scroll-bars-hidden",BP="--removed-body-scroll-bar-size";function Rh(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function zP(e,t){var s=h.useState(function(){return{value:e,callback:t,facade:{get current(){return s.value},set current(r){var i=s.value;i!==r&&(s.value=r,s.callback(r,i))}}}})[0];return s.callback=t,s.facade}var WP=typeof window<"u"?h.useLayoutEffect:h.useEffect,ny=new WeakMap;function HP(e,t){var s=zP(null,function(r){return e.forEach(function(i){return Rh(i,r)})});return WP(function(){var r=ny.get(s);if(r){var i=new Set(r),a=new Set(e),l=s.current;i.forEach(function(o){a.has(o)||Rh(o,null)}),a.forEach(function(o){i.has(o)||Rh(o,l)})}ny.set(s,e)},[e]),s}function VP(e){return e}function KP(e,t){t===void 0&&(t=VP);var s=[],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 s.length?s[s.length-1]:e},useMedium:function(a){var l=t(a,r);return s.push(l),function(){s=s.filter(function(o){return o!==l})}},assignSyncMedium:function(a){for(r=!0;s.length;){var l=s;s=[],l.forEach(a)}s={push:function(o){return a(o)},filter:function(){return s}}},assignMedium:function(a){r=!0;var l=[];if(s.length){var o=s;s=[],o.forEach(a),l=s}var c=function(){var f=l;l=[],f.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),s={push:function(f){l.push(f),u()},filter:function(f){return l=l.filter(f),s}}}};return i}function GP(e){e===void 0&&(e={});var t=KP(null);return t.options=Ns({async:!0,ssr:!1},e),t}var DS=function(e){var t=e.sideCar,s=$S(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 h.createElement(r,Ns({},s))};DS.isSideCarExport=!0;function YP(e,t){return e.useMedium(t),DS}var OS=GP(),Ih=function(){},wd=h.forwardRef(function(e,t){var s=h.useRef(null),r=h.useState({onScrollCapture:Ih,onWheelCapture:Ih,onTouchMoveCapture:Ih}),i=r[0],a=r[1],l=e.forwardProps,o=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,d=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,w=e.inert,k=e.allowPinchZoom,g=e.as,x=g===void 0?"div":g,y=e.gapMode,j=$S(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=m,b=HP([s,t]),S=Ns(Ns({},j),i);return h.createElement(h.Fragment,null,f&&h.createElement(N,{sideCar:OS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:v,inert:w,setCallbacks:a,allowPinchZoom:!!k,lockRef:s,gapMode:y}),l?h.cloneElement(h.Children.only(o),Ns(Ns({},S),{ref:b})):h.createElement(x,Ns({},S,{className:c,ref:b}),o))});wd.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};wd.classNames={fullWidth:Gc,zeroRight:Kc};var qP=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function QP(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=qP();return t&&e.setAttribute("nonce",t),e}function JP(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function XP(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ZP=function(){var e=0,t=null;return{add:function(s){e==0&&(t=QP())&&(JP(t,s),XP(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},eM=function(){var e=ZP();return function(t,s){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},_S=function(){var e=eM(),t=function(s){var r=s.styles,i=s.dynamic;return e(r,i),null};return t},tM={left:0,top:0,right:0,gap:0},Ph=function(e){return parseInt(e||"",10)||0},nM=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Ph(s),Ph(r),Ph(i)]},sM=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return tM;var t=nM(e),s=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-s+t[2]-t[0])}},rM=_S(),ga="data-scroll-locked",iM=function(e,t,s,r){var i=e.left,a=e.top,l=e.right,o=e.gap;return s===void 0&&(s="margin"),`
41
- .`.concat(UP,` {
42
- overflow: hidden `).concat(r,`;
43
- padding-right: `).concat(o,"px ").concat(r,`;
44
- }
45
- body[`).concat(ga,`] {
46
- overflow: hidden `).concat(r,`;
47
- overscroll-behavior: contain;
48
- `).concat([t&&"position: relative ".concat(r,";"),s==="margin"&&`
49
- padding-left: `.concat(i,`px;
50
- padding-top: `).concat(a,`px;
51
- padding-right: `).concat(l,`px;
52
- margin-left:0;
53
- margin-top:0;
54
- margin-right: `).concat(o,"px ").concat(r,`;
55
- `),s==="padding"&&"padding-right: ".concat(o,"px ").concat(r,";")].filter(Boolean).join(""),`
56
- }
57
-
58
- .`).concat(Kc,` {
59
- right: `).concat(o,"px ").concat(r,`;
60
- }
61
-
62
- .`).concat(Gc,` {
63
- margin-right: `).concat(o,"px ").concat(r,`;
64
- }
65
-
66
- .`).concat(Kc," .").concat(Kc,` {
67
- right: 0 `).concat(r,`;
68
- }
69
-
70
- .`).concat(Gc," .").concat(Gc,` {
71
- margin-right: 0 `).concat(r,`;
72
- }
73
-
74
- body[`).concat(ga,`] {
75
- `).concat(BP,": ").concat(o,`px;
76
- }
77
- `)},sy=function(){var e=parseInt(document.body.getAttribute(ga)||"0",10);return isFinite(e)?e:0},aM=function(){h.useEffect(function(){return document.body.setAttribute(ga,(sy()+1).toString()),function(){var e=sy()-1;e<=0?document.body.removeAttribute(ga):document.body.setAttribute(ga,e.toString())}},[])},lM=function(e){var t=e.noRelative,s=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;aM();var a=h.useMemo(function(){return sM(i)},[i]);return h.createElement(rM,{styles:iM(a,!t,i,s?"":"!important")})},Sm=!1;if(typeof window<"u")try{var cc=Object.defineProperty({},"passive",{get:function(){return Sm=!0,!0}});window.addEventListener("test",cc,cc),window.removeEventListener("test",cc,cc)}catch{Sm=!1}var zi=Sm?{passive:!1}:!1,oM=function(e){return e.tagName==="TEXTAREA"},LS=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!oM(e)&&s[t]==="visible")},cM=function(e){return LS(e,"overflowY")},uM=function(e){return LS(e,"overflowX")},ry=function(e,t){var s=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=FS(e,r);if(i){var a=US(e,r),l=a[1],o=a[2];if(l>o)return!0}r=r.parentNode}while(r&&r!==s.body);return!1},dM=function(e){var t=e.scrollTop,s=e.scrollHeight,r=e.clientHeight;return[t,s,r]},hM=function(e){var t=e.scrollLeft,s=e.scrollWidth,r=e.clientWidth;return[t,s,r]},FS=function(e,t){return e==="v"?cM(t):uM(t)},US=function(e,t){return e==="v"?dM(t):hM(t)},fM=function(e,t){return e==="h"&&t==="rtl"?-1:1},mM=function(e,t,s,r,i){var a=fM(e,window.getComputedStyle(t).direction),l=a*r,o=s.target,c=t.contains(o),u=!1,f=l>0,d=0,m=0;do{if(!o)break;var p=US(e,o),v=p[0],w=p[1],k=p[2],g=w-k-a*v;(v||g)&&FS(e,o)&&(d+=g,m+=v);var x=o.parentNode;o=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!c&&o!==document.body||c&&(t.contains(o)||t===o));return(f&&Math.abs(d)<1||!f&&Math.abs(m)<1)&&(u=!0),u},uc=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},iy=function(e){return[e.deltaX,e.deltaY]},ay=function(e){return e&&"current"in e?e.current:e},pM=function(e,t){return e[0]===t[0]&&e[1]===t[1]},gM=function(e){return`
78
- .block-interactivity-`.concat(e,` {pointer-events: none;}
79
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
80
- `)},xM=0,Wi=[];function vM(e){var t=h.useRef([]),s=h.useRef([0,0]),r=h.useRef(),i=h.useState(xM++)[0],a=h.useState(_S)[0],l=h.useRef(e);h.useEffect(function(){l.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var w=FP([e.lockRef.current],(e.shards||[]).map(ay),!0).filter(Boolean);return w.forEach(function(k){return k.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(k){return k.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var o=h.useCallback(function(w,k){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var g=uc(w),x=s.current,y="deltaX"in w?w.deltaX:x[0]-g[0],j="deltaY"in w?w.deltaY:x[1]-g[1],N,b=w.target,S=Math.abs(y)>Math.abs(j)?"h":"v";if("touches"in w&&S==="h"&&b.type==="range")return!1;var C=window.getSelection(),R=C&&C.anchorNode,E=R?R===b||R.contains(b):!1;if(E)return!1;var P=ry(S,b);if(!P)return!0;if(P?N=S:(N=S==="v"?"h":"v",P=ry(S,b)),!P)return!1;if(!r.current&&"changedTouches"in w&&(y||j)&&(r.current=N),!N)return!0;var F=r.current||N;return mM(F,k,w,F==="h"?y:j)},[]),c=h.useCallback(function(w){var k=w;if(!(!Wi.length||Wi[Wi.length-1]!==a)){var g="deltaY"in k?iy(k):uc(k),x=t.current.filter(function(N){return N.name===k.type&&(N.target===k.target||k.target===N.shadowParent)&&pM(N.delta,g)})[0];if(x&&x.should){k.cancelable&&k.preventDefault();return}if(!x){var y=(l.current.shards||[]).map(ay).filter(Boolean).filter(function(N){return N.contains(k.target)}),j=y.length>0?o(k,y[0]):!l.current.noIsolation;j&&k.cancelable&&k.preventDefault()}}},[]),u=h.useCallback(function(w,k,g,x){var y={name:w,delta:k,target:g,should:x,shadowParent:jM(g)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(j){return j!==y})},1)},[]),f=h.useCallback(function(w){s.current=uc(w),r.current=void 0},[]),d=h.useCallback(function(w){u(w.type,iy(w),w.target,o(w,e.lockRef.current))},[]),m=h.useCallback(function(w){u(w.type,uc(w),w.target,o(w,e.lockRef.current))},[]);h.useEffect(function(){return Wi.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:m}),document.addEventListener("wheel",c,zi),document.addEventListener("touchmove",c,zi),document.addEventListener("touchstart",f,zi),function(){Wi=Wi.filter(function(w){return w!==a}),document.removeEventListener("wheel",c,zi),document.removeEventListener("touchmove",c,zi),document.removeEventListener("touchstart",f,zi)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(a,{styles:gM(i)}):null,p?h.createElement(lM,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function jM(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const yM=YP(OS,vM);var Ug=h.forwardRef(function(e,t){return h.createElement(wd,Ns({},e,{ref:t,sideCar:yM}))});Ug.classNames=wd.classNames;var wM=Object.defineProperty,He=(e,t)=>wM(e,"name",{value:t,configurable:!0}),Nm=["Enter"," "],bM=["ArrowDown","PageUp","Home"],BS=["ArrowUp","PageDown","End"],kM=[...bM,...BS],SM={ltr:[...Nm,"ArrowRight"],rtl:[...Nm,"ArrowLeft"]},NM={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bd="Menu",[io,CM,EM]=od(bd),[Ii,zS]=fs(bd,[EM,pd,yd]),kd=pd(),WS=yd(),[HS,Kr]=Ii(bd),[AM,ko]=Ii(bd),TM=He(e=>{const{__scopeMenu:t,open:s=!1,children:r,dir:i,onOpenChange:a,modal:l=!0}=e,o=kd(t),[c,u]=h.useState(null),f=h.useRef(!1),d=es(a),m=xd(i);return h.useEffect(()=>{const p=He(()=>{f.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},"handleKeyDown"),v=He(()=>f.current=!1,"handlePointer");return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),h.useEffect(()=>{if(!s)return;const p=He(()=>d(!1),"handleBlur");return window.addEventListener("blur",p),()=>window.removeEventListener("blur",p)},[s,d]),n.jsx(Ig,{...o,children:n.jsx(HS,{scope:t,open:s,onOpenChange:d,content:c,onContentChange:u,children:n.jsx(AM,{scope:t,onClose:h.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:f,dir:m,modal:l,children:r})})})},"Menu"),VS=h.forwardRef(He(function(t,s){const{__scopeMenu:r,...i}=t,a=kd(r);return n.jsx(tS,{...a,...i,ref:s})},"MenuAnchor")),KS="MenuPortal",[RM,GS]=Ii(KS,{forceMount:void 0}),IM=He(e=>{const{__scopeMenu:t,forceMount:s,children:r,container:i}=e,a=Kr(KS,t);return n.jsx(RM,{scope:t,forceMount:s,children:n.jsx(ar,{present:s||a.open,children:n.jsx(Sg,{asChild:!0,container:i,children:r})})})},"MenuPortal"),cs="MenuContent",[PM,Bg]=Ii(cs),MM=h.forwardRef(He(function(t,s){const r=GS(cs,t.__scopeMenu),{forceMount:i=r.forceMount,...a}=t,l=Kr(cs,t.__scopeMenu),o=ko(cs,t.__scopeMenu);return n.jsx(io.Provider,{scope:t.__scopeMenu,children:n.jsx(ar,{present:i||l.open,children:n.jsx(io.Slot,{scope:t.__scopeMenu,children:o.modal?n.jsx($M,{...a,ref:s}):n.jsx(DM,{...a,ref:s})})})})},"MenuContent")),$M=h.forwardRef(He(function(t,s){const r=Kr(cs,t.__scopeMenu),i=h.useRef(null),a=it(s,i);return h.useEffect(()=>{const l=i.current;if(l)return MS(l)},[]),n.jsx(zg,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Re(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),DM=h.forwardRef(He(function(t,s){const r=Kr(cs,t.__scopeMenu);return n.jsx(zg,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),OM=$r("MenuContent.ScrollLock"),zg=h.forwardRef(He(function(t,s){const{__scopeMenu:r,loop:i=!1,trapFocus:a,onOpenAutoFocus:l,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:p,onDismiss:v,disableOutsideScroll:w,...k}=t,g=Kr(cs,r),x=ko(cs,r),y=kd(r),j=WS(r),N=CM(r),[b,S]=h.useState(null),C=h.useRef(null),R=it(s,C,g.onContentChange),E=h.useRef(0),P=h.useRef(""),F=h.useRef(0),M=h.useRef(null),T=h.useRef("right"),$=h.useRef(0),_=w?Ug:h.Fragment,K=w?{as:OM,allowPinchZoom:!0}:void 0,D=He(B=>{var fe,je;const V=P.current+B,de=N().filter(X=>!X.disabled),ae=document.activeElement,le=(fe=de.find(X=>X.ref.current===ae))==null?void 0:fe.textValue,Ce=de.map(X=>X.textValue),ee=sN(Ce,V,le),ce=(je=de.find(X=>X.textValue===ee))==null?void 0:je.ref.current;He(function X(be){P.current=be,window.clearTimeout(E.current),be!==""&&(E.current=window.setTimeout(()=>X(""),1e3))},"updateSearch")(V),ce&&setTimeout(()=>ce.focus())},"handleTypeaheadSearch");h.useEffect(()=>()=>window.clearTimeout(E.current),[]),vd();const Y=h.useCallback(B=>{var de,ae;return T.current===((de=M.current)==null?void 0:de.side)&&iN(B,(ae=M.current)==null?void 0:ae.area)},[]);return n.jsx(PM,{scope:r,searchRef:P,onItemEnter:h.useCallback(B=>{Y(B)&&B.preventDefault()},[Y]),onItemLeave:h.useCallback(B=>{var V;Y(B)||((V=C.current)==null||V.focus(),S(null))},[Y]),onTriggerLeave:h.useCallback(B=>{Y(B)&&B.preventDefault()},[Y]),pointerGraceTimerRef:F,onPointerGraceIntentChange:h.useCallback(B=>{M.current=B},[]),children:n.jsx(_,{...K,children:n.jsx(pS,{asChild:!0,trapped:a,onMountAutoFocus:Re(l,B=>{var V;B.preventDefault(),(V=C.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:n.jsx(bg,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:p,onDismiss:v,children:n.jsx(RS,{asChild:!0,...j,dir:x.dir,orientation:"vertical",loop:i,currentTabStopId:b,onCurrentTabStopIdChange:S,onEntryFocus:Re(u,B=>{x.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(nS,{role:"menu","aria-orientation":"vertical","data-state":Wg(g.open),"data-radix-menu-content":"",dir:x.dir,...y,...k,ref:R,style:{outline:"none",...k.style},onKeyDown:Re(k.onKeyDown,B=>{const de=B.target.closest("[data-radix-menu-content]")===B.currentTarget,ae=B.ctrlKey||B.altKey||B.metaKey,le=B.key.length===1;de&&(B.key==="Tab"&&B.preventDefault(),!ae&&le&&D(B.key));const Ce=C.current;if(B.target!==Ce||!kM.includes(B.key))return;B.preventDefault();const ce=N().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);BS.includes(B.key)&&ce.reverse(),tN(ce)}),onBlur:Re(t.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(E.current),P.current="")}),onPointerMove:Re(t.onPointerMove,Ea(B=>{const V=B.target,de=$.current!==B.clientX;if(B.currentTarget.contains(V)&&de){const ae=B.clientX>$.current?"right":"left";T.current=ae,$.current=B.clientX}}))})})})})})})},"MenuContentImpl")),YS=h.forwardRef(He(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(mt.div,{role:"group",...i,ref:s})},"MenuGroup")),_M=h.forwardRef(He(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(mt.div,{...i,ref:s})},"MenuLabel")),Cm="MenuItem",ly="menu.itemSelect",qS=h.forwardRef(He(function(t,s){const{disabled:r=!1,onSelect:i,...a}=t,l=h.useRef(null),o=ko(Cm,t.__scopeMenu),c=Bg(Cm,t.__scopeMenu),u=it(s,l),f=h.useRef(!1),d=He(()=>{const m=l.current;if(!r&&m){const p=new CustomEvent(ly,{bubbles:!0,cancelable:!0});m.addEventListener(ly,v=>i==null?void 0:i(v),{once:!0}),cd(m,p),p.defaultPrevented?f.current=!1:o.onClose()}},"handleSelect");return n.jsx(QS,{...a,ref:u,disabled:r,onClick:Re(t.onClick,d),onPointerDown:m=>{var p;(p=t.onPointerDown)==null||p.call(t,m),f.current=!0},onPointerUp:Re(t.onPointerUp,m=>{var p;f.current||(p=m.currentTarget)==null||p.click()}),onKeyDown:Re(t.onKeyDown,m=>{r||m.target!==m.currentTarget||c.searchRef.current!==""&&m.key===" "||Nm.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})},"MenuItem")),QS=h.forwardRef(He(function(t,s){const{__scopeMenu:r,disabled:i=!1,textValue:a,...l}=t,o=Bg(Cm,r),c=WS(r),u=h.useRef(null),f=it(s,u),[d,m]=h.useState(!1),[p,v]=h.useState("");return h.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[l.children]),n.jsx(io.ItemSlot,{scope:r,disabled:i,textValue:a??p,children:n.jsx(IS,{asChild:!0,...c,focusable:!i,children:n.jsx(mt.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...l,ref:f,onPointerMove:Re(t.onPointerMove,Ea(w=>{i?o.onItemLeave(w):(o.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Re(t.onPointerLeave,Ea(w=>o.onItemLeave(w))),onFocus:Re(t.onFocus,()=>m(!0)),onBlur:Re(t.onBlur,()=>m(!1))})})})},"MenuItemImpl")),LM="MenuRadioGroup",[FM,UM]=Ii(LM,{value:void 0,onValueChange:He(()=>{},"onValueChange")}),BM=h.forwardRef(He(function(t,s){const{value:r,onValueChange:i,...a}=t,l=es(i);return n.jsx(FM,{scope:t.__scopeMenu,value:r,onValueChange:l,children:n.jsx(YS,{...a,ref:s})})},"MenuRadioGroup")),zM="MenuRadioItem",WM=h.forwardRef(He(function(t,s){const{value:r,...i}=t,a=UM(zM,t.__scopeMenu),l=r===a.value;return n.jsx(VM,{scope:t.__scopeMenu,checked:l,children:n.jsx(qS,{role:"menuitemradio","aria-checked":l,...i,ref:s,"data-state":eN(l),onSelect:Re(i.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),HM="MenuItemIndicator",[VM,CH]=Ii(HM,{checked:!1}),KM=h.forwardRef(He(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(mt.div,{role:"separator","aria-orientation":"horizontal",...i,ref:s})},"MenuSeparator")),JS="MenuSub",[GM,XS]=Ii(JS),YM=He(e=>{const{__scopeMenu:t,children:s,open:r=!1,onOpenChange:i}=e,a=Kr(JS,t),l=kd(t),[o,c]=h.useState(null),[u,f]=h.useState(null),d=es(i);return h.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),n.jsx(Ig,{...l,children:n.jsx(HS,{scope:t,open:r,onOpenChange:d,content:u,onContentChange:f,children:n.jsx(GM,{scope:t,contentId:os(),triggerId:os(),trigger:o,onTriggerChange:c,children:s})})})},"MenuSub"),dc="MenuSubTrigger",qM=h.forwardRef(He(function(t,s){const r=Kr(dc,t.__scopeMenu),i=ko(dc,t.__scopeMenu),a=XS(dc,t.__scopeMenu),l=Bg(dc,t.__scopeMenu),o=h.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=l,f={__scopeMenu:t.__scopeMenu},d=h.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),u(null)}},[c,u]);const m=it(s,a.onTriggerChange);return n.jsx(VS,{asChild:!0,...f,children:n.jsx(QS,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?a.contentId:void 0,"data-state":Wg(r.open),...t,ref:m,onClick:p=>{var v;(v=t.onClick)==null||v.call(t,p),!(t.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Re(t.onPointerMove,Ea(p=>{l.onItemEnter(p),!p.defaultPrevented&&!t.disabled&&!r.open&&!o.current&&(l.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),d()},100))})),onPointerLeave:Re(t.onPointerLeave,Ea(p=>{var w,k;d();const v=(w=r.content)==null?void 0:w.getBoundingClientRect();if(v){const g=(k=r.content)==null?void 0:k.dataset.side,x=g==="right",y=x?-5:5,j=v[x?"left":"right"],N=v[x?"right":"left"];l.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:j,y:v.top},{x:N,y:v.top},{x:N,y:v.bottom},{x:j,y:v.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(p),p.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:Re(t.onKeyDown,p=>{var w;t.disabled||p.target!==p.currentTarget||l.searchRef.current!==""&&p.key===" "||SM[i.dir].includes(p.key)&&(r.onOpenChange(!0),(w=r.content)==null||w.focus(),p.preventDefault())})})})},"MenuSubTrigger")),QM="MenuSubContent",JM=h.forwardRef(He(function(t,s){const r=GS(cs,t.__scopeMenu),{forceMount:i=r.forceMount,align:a="start",...l}=t,o=Kr(cs,t.__scopeMenu),c=ko(cs,t.__scopeMenu),u=XS(QM,t.__scopeMenu),f=h.useRef(null),d=it(s,f);return n.jsx(io.Provider,{scope:t.__scopeMenu,children:n.jsx(ar,{present:i||o.open,children:n.jsx(io.Slot,{scope:t.__scopeMenu,children:n.jsx(zg,{id:u.contentId,"aria-labelledby":u.triggerId,...l,ref:d,align:a,side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var p;c.isUsingKeyboardRef.current&&((p=f.current)==null||p.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Re(t.onFocusOutside,m=>{m.target!==u.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Re(t.onEscapeKeyDown,m=>{c.onClose(),m.preventDefault()}),onKeyDown:Re(t.onKeyDown,m=>{var w;const p=m.currentTarget.contains(m.target),v=NM[c.dir].includes(m.key);p&&v&&(o.onOpenChange(!1),(w=u.trigger)==null||w.focus(),m.preventDefault())})})})})})},"MenuSubContent"));function Wg(e){return e?"open":"closed"}He(Wg,"getOpenState");function ZS(e){return e==="indeterminate"}He(ZS,"isIndeterminate");function eN(e){return ZS(e)?"indeterminate":e?"checked":"unchecked"}He(eN,"getCheckedState");function tN(e){const t=document.activeElement;for(const s of e)if(s===t||(s.focus(),document.activeElement!==t))return}He(tN,"focusFirst");function nN(e,t){return e.map((s,r)=>e[(t+r)%e.length])}He(nN,"wrapArray");function sN(e,t,s){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=s?e.indexOf(s):-1;let l=nN(e,Math.max(a,0));i.length===1&&(l=l.filter(u=>u!==s));const c=l.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==s?c:void 0}He(sN,"getNextMatch");function rN(e,t){const{x:s,y:r}=e;let i=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const o=t[a],c=t[l],u=o.x,f=o.y,d=c.x,m=c.y;f>r!=m>r&&s<(d-u)*(r-f)/(m-f)+u&&(i=!i)}return i}He(rN,"isPointInPolygon");function iN(e,t){if(!t)return!1;const s={x:e.clientX,y:e.clientY};return rN(s,t)}He(iN,"isPointerInGraceArea");function Ea(e){return t=>t.pointerType==="mouse"?e(t):void 0}He(Ea,"whenMouse");var XM=TM,ZM=VS,e$=IM,t$=MM,n$=YS,s$=_M,r$=qS,i$=BM,a$=WM,l$=KM,o$=YM,c$=qM,u$=JM,d$=Object.defineProperty,Fn=(e,t)=>d$(e,"name",{value:t,configurable:!0}),Hg="DropdownMenu",[h$,EH]=fs(Hg,[zS]),Un=zS(),[f$,aN]=h$(Hg),m$=Fn(e=>{const{__scopeDropdownMenu:t,children:s,dir:r,open:i,defaultOpen:a,onOpenChange:l,modal:o=!0}=e,c=Un(t),u=h.useRef(null),[f,d]=Ei({prop:i,defaultProp:a??!1,onChange:l,caller:Hg});return n.jsx(f$,{scope:t,triggerId:os(),triggerRef:u,contentId:os(),open:f,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(m=>!m),[d]),modal:o,children:n.jsx(XM,{...c,open:f,onOpenChange:d,dir:r,modal:o,children:s})})},"DropdownMenu"),p$="DropdownMenuTrigger",g$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,disabled:i=!1,...a}=t,l=aN(p$,r),o=Un(r),c=it(s,l.triggerRef);return n.jsx(ZM,{asChild:!0,...o,children:n.jsx(mt.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...a,ref:c,onPointerDown:Re(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(l.onOpenToggle(),l.open||u.preventDefault())}),onKeyDown:Re(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&l.onOpenToggle(),u.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),x$=Fn(e=>{const{__scopeDropdownMenu:t,...s}=e,r=Un(t);return n.jsx(e$,{...r,...s})},"DropdownMenuPortal"),v$="DropdownMenuContent",j$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=aN(v$,r),l=Un(r),o=h.useRef(!1);return n.jsx(t$,{id:a.contentId,"aria-labelledby":a.triggerId,...l,...i,ref:s,onCloseAutoFocus:Re(t.onCloseAutoFocus,c=>{var u;o.current||(u=a.triggerRef.current)==null||u.focus(),o.current=!1,c.preventDefault()}),onInteractOutside:Re(t.onInteractOutside,c=>{const u=c.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,d=u.button===2||f;(!a.modal||d)&&(o.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")),y$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(n$,{...a,...i,ref:s})},"DropdownMenuGroup")),w$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(s$,{...a,...i,ref:s})},"DropdownMenuLabel")),b$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(r$,{...a,...i,ref:s})},"DropdownMenuItem")),k$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(i$,{...a,...i,ref:s})},"DropdownMenuRadioGroup")),S$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(a$,{...a,...i,ref:s})},"DropdownMenuRadioItem")),N$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(l$,{...a,...i,ref:s})},"DropdownMenuSeparator")),C$=Fn(e=>{const{__scopeDropdownMenu:t,children:s,open:r,onOpenChange:i,defaultOpen:a}=e,l=Un(t),[o,c]=Ei({prop:r,defaultProp:a??!1,onChange:i,caller:"DropdownMenuSub"});return n.jsx(o$,{...l,open:o,onOpenChange:c,children:s})},"DropdownMenuSub"),E$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(c$,{...a,...i,ref:s})},"DropdownMenuSubTrigger")),A$=h.forwardRef(Fn(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Un(r);return n.jsx(u$,{...a,...i,ref:s,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)"}})},"DropdownMenuSubContent")),Sd=m$,Nd=g$,So=x$,Cd=j$,lN=y$,Ed=w$,hi=b$,T$=k$,R$=S$,xr=N$,I$=C$,P$=E$,M$=A$,$$=Object.defineProperty,Va=(e,t)=>$$(e,"name",{value:t,configurable:!0}),Vg="Tabs",[D$,AH]=fs(Vg,[yd]),oN=yd(),[O$,Kg]=D$(Vg),_$=h.forwardRef(Va(function(t,s){const{__scopeTabs:r,value:i,onValueChange:a,defaultValue:l,orientation:o="horizontal",dir:c,activationMode:u="automatic",...f}=t,d=xd(c),[m,p]=Ei({prop:i,onChange:a,defaultProp:l??"",caller:Vg});return n.jsx(O$,{scope:r,baseId:os(),value:m,onValueChange:p,orientation:o,dir:d,activationMode:u,children:n.jsx(mt.div,{dir:d,"data-orientation":o,...f,ref:s})})},"Tabs")),L$="TabsList",F$=h.forwardRef(Va(function(t,s){const{__scopeTabs:r,loop:i=!0,...a}=t,l=Kg(L$,r),o=oN(r);return n.jsx(RS,{asChild:!0,...o,orientation:l.orientation,dir:l.dir,loop:i,children:n.jsx(mt.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:s})})},"TabsList")),U$="TabsTrigger",B$=h.forwardRef(Va(function(t,s){const{__scopeTabs:r,value:i,disabled:a=!1,...l}=t,o=Kg(U$,r),c=oN(r),u=Gg(o.baseId,i),f=Yg(o.baseId,i),d=i===o.value;return n.jsx(IS,{asChild:!0,...c,focusable:!a,active:d,children:n.jsx(mt.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":f,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...l,ref:s,onMouseDown:Re(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(i):m.preventDefault()}),onKeyDown:Re(t.onKeyDown,m=>{a||m.target!==m.currentTarget||[" ","Enter"].includes(m.key)&&o.onValueChange(i)}),onFocus:Re(t.onFocus,()=>{const m=o.activationMode!=="manual";!d&&!a&&m&&o.onValueChange(i)})})})},"TabsTrigger")),z$="TabsContent",W$=h.forwardRef(Va(function(t,s){const{__scopeTabs:r,value:i,forceMount:a,children:l,...o}=t,c=Kg(z$,r),u=Gg(c.baseId,i),f=Yg(c.baseId,i),d=i===c.value,m=h.useRef(d);return h.useEffect(()=>{const p=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(p)},[]),n.jsx(ar,{present:a||d,children:({present:p})=>n.jsx(mt.div,{"data-state":d?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!p,id:f,tabIndex:0,...o,ref:s,style:{...t.style,animationDuration:m.current?"0s":void 0},children:p&&l})})},"TabsContent"));function Gg(e,t){return`${e}-trigger-${t}`}Va(Gg,"makeTriggerId");function Yg(e,t){return`${e}-content-${t}`}Va(Yg,"makeContentId");var H$=_$,V$=F$,K$=B$,G$=W$;function Ve(e,t){if(!e)return"—";const s=new Date(e);return Number.isNaN(s.getTime())?String(e):new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(s)}function Oe(e,t=Date.now()){if(!e)return"";const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.round((s-t)/1e3),i=Math.abs(r),[a,l]=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(a,l)}function Y$(e,t=Date.now()){if(!e)return"";const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.abs(Math.round((t-s)/1e3));return r<60?"now":r<3600?`${Math.floor(r/60)} min`:r<86400?`${Math.floor(r/3600)} h`:`${Math.floor(r/86400)} d`}function q$(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 Pt(e){return new Intl.NumberFormat("en-US").format(e)}function Em(e){return[...e.cacheRead?[`cached ${Pt(e.cacheRead)}`]:[],...e.cacheWrite?[`cache write ${Pt(e.cacheWrite)}`]:[]].join(", ")}function Q$(e){const t=Em(e);return`${Pt(e.input)} in${t?` (${t})`:""} / ${Pt(e.output)} out`}function Sn(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function ao(e,t=8){return e.length<=t?e:e.slice(0,t)}function Ms(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Aa(e){return e.replace(/<<<[^<>]*>>>/g,"")}function $t(e,t,s){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?J$(r,s):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${oy(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Pt(r):oy(r):String(e)}case"date":return X$(String(e));default:return typeof e=="string"?e:typeof e=="number"?Pt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function J$(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return q$(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function X$(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const s=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short",year:"numeric"}).format(s)}function Am(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const s=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short"}).format(s)}function oy(e){return String(Math.round(e*100)/100)}function Ru(e,t,s=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,s),i=10**Math.floor(Math.log10(r)),a=[1,2,2.5,5,10].map(o=>o*i).find(o=>o>=r)??i*10,l=[];for(let o=Math.ceil(e/a)*a;o<=t+a/1e3;o+=a)l.push(Math.round(o*1e6)/1e6);return l.filter(o=>o>=e&&o<=t)}function Z$({props:e}){if(e.bars.length===0)return n.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(a=>a.value),s=Math.max(0,...t),r=Math.min(0,...t),i=s-r||1;return n.jsx("div",{className:"wb-bars",children:e.bars.map(a=>{const l=Math.abs(a.value)/i;return n.jsxs("div",{className:"wb-bar-row",children:[n.jsx("div",{className:"wb-bar-cat",title:a.category,children:a.category}),n.jsx("div",{className:"wb-bar-track",children:n.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,l*100)}%`,background:a.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),n.jsx("div",{className:"wb-bar-val",children:$t(a.value,e.unit,e.currency)})]},a.category)})})}const eD=/^(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 )/,tD=/^(… |\.\.\. |\(no change\)$|\)/;function nD(e){return e.replace(/\n$/,"").split(`
81
- `).map(s=>({kind:sD(s),text:s}))}function sD(e){return e.startsWith("@@")?"hunk":eD.test(e)||tD.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function rD({text:e,marks:t}){const s=e.toLowerCase(),r=[];for(const l of t){const o=l.trim().toLowerCase();if(o!=="")for(let c=s.indexOf(o);c!==-1;c=s.indexOf(o,c+o.length))r.push([c,c+o.length])}if(r.length===0)return n.jsx(n.Fragment,{children:e===""?" ":e});r.sort((l,o)=>l[0]-o[0]);const i=[];let a=0;for(const[l,o]of r)l<a||(l>a&&i.push(n.jsx("span",{children:e.slice(a,l)},`t${a}`)),i.push(n.jsx("mark",{className:"wb-diff-mark",children:e.slice(l,o)},`m${l}`)),a=o);return a<e.length&&i.push(n.jsx("span",{children:e.slice(a)},`t${a}`)),n.jsx(n.Fragment,{children:i})}function Iu({text:e,limit:t,more:s,label:r="Diff",marks:i}){const a=nD(e),l=t===void 0?a:a.slice(0,t),o=a.length-l.length;return n.jsxs("div",{className:"wb-diff-wrap",children:[n.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:l.map((c,u)=>n.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?n.jsx(rD,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),o>0?n.jsxs("p",{className:"wb-diff-more",children:[o," more line",o===1?"":"s",s?n.jsxs(n.Fragment,{children:[" · ",n.jsx("button",{type:"button",className:"wb-diff-open",onClick:s.onClick,children:s.label})]}):null]}):null]})}function iD({props:e}){return n.jsxs("div",{children:[e.title?n.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:$t(t.value,t.unit,null)})]},t.label))}):null,e.diff?n.jsx(Iu,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):n.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const Vt="#/",Ar="#/chat",ut="#/agents",jt="#/activity",tn="#/settings",bi="#/files",aD="#/welcome";function Yc(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function hc(e,t={}){const s=new URLSearchParams;t.q&&s.set("q",t.q),t.origin&&s.set("origin",t.origin),t.family&&s.set("family",t.family);const r=s.toString();return`${bi}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function lD(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const s=new URLSearchParams(t[2]??""),r={};return s.get("q")&&(r.q=s.get("q")),s.get("origin")&&(r.origin=s.get("origin")),s.get("family")&&(r.family=s.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function Ke(e,t,s){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function oD(e){if(cN(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const s=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...s?{tab:s}:{}}}catch{return null}}function Tl(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function cN(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 dt(e,t,s){return`${ut}/${encodeURIComponent(e)}${t?`/${t}${s?`/${s}`:""}`:""}`}function cD(e){const t=/^#\/agents\/([^/]+)(?:\/([a-z-]+)(?:\/([a-z-]+))?)?$/.exec(e);if(!t)return null;try{return{agentId:decodeURIComponent(t[1]),...t[2]?{tab:t[2]}:{},...t[3]?{section:t[3]}:{}}}catch{return null}}function Ta(e){return`${jt}/conversations/${encodeURIComponent(e)}`}const uD="#/p";function _r(e,t,s){const r=`${uD}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return s?`${r}/${encodeURIComponent(s)}`:r}function qg(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 dD="p.";function No(e,t){return`${tn}/${encodeURIComponent(uN(e,t))}`}function hD(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const s=decodeURIComponent(t[1]);return{plugin:s,page:t[2]?decodeURIComponent(t[2]):s}}function uN(e,t){return`${dD}${e}${t===e?"":`.${t}`}`}function tt(e){return e?`${tn}/${e}`:tn}function fD(e){return`${tt("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function mD(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}function dN(e){const t=/^#\/settings\/plugins\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1])}catch{return null}}function pD(e){var s,r;const t=(r=(s=dN(e))==null?void 0:s.get("install"))==null?void 0:r.trim();return t||null}function cy(e){const t=dN(e);return t!=null&&t.get("install")?"installed":(t==null?void 0:t.get("tab"))==="browse"?"browse":"installed"}const gD=[{route:Vt,label:"Home"},{route:Ar,label:"Chat"},{route:ut,label:"Agents"},{route:jt,label:"Activity"},{route:bi,label:"Files"},{route:tn,label:"Settings"}],xD=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],vD=[{id:"you",label:"Profile",group:"you"},{id:"appearance",label:"Appearance",group:"you"},{id:"notifications",label:"Notifications",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:"connections",label:"Connections",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 jD(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const uy=tt("backup");function yD(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return Ta(decodeURIComponent(t[1]));const s=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(s)try{return _r("email","mail",s[1]?decodeURIComponent(s[1]):null)}catch{return _r("email","mail")}return e==="#/settings/email"?No("email","settings"):{"#/overview":Vt,"#/approvals":Vt,"#/events":`${jt}/events`,"#/jobs":`${jt}/jobs`,"#/conversations":jt,"#/missions":`${ut}?tab=missions`,"#/offers":`${ut}?tab=offers`,"#/reminders":`${ut}?tab=reminders`,"#/providers":tt("accounts"),"#/browser":tt("computer"),"#/sentinels":tt("watchers"),"#/settings/sentinels":tt("watchers")}[e]??null}function hN(e){if(e===""||e==="#"||e===Vt)return Vt;if(e.startsWith(Ar))return Ar;if(e.startsWith(ut))return ut;if(e.startsWith(jt))return jt;if(e.startsWith(bi))return bi;if(e.startsWith(tn))return tn;const t=qg(e);return t?_r(t.plugin,t.page):Vt}const wD="#/chat?group=new";function bD(e){const t=e.replace(/^#\/?/,"").split("?")[0].toLowerCase();if(t==="")return"home";const[s,r]=t.split("/");return!s||!/^[a-z0-9-]+$/.test(s)?null:(s==="settings"||s==="p")&&r&&/^[a-z0-9.-]+$/.test(r)?`${s}/${r}`:s}const Qg="front-desk",Jg=[{id:Qg,label:"Front desk",meaning:"Where things go when you do not say who."},{id:"overview",label:"Overview",meaning:"Answers /status and speaks for the watchers."},{id:"recap",label:"Recap",meaning:"Runs /recap."},{id:"maker",label:"Maker",meaning:"/new opens its interview."}],fN=new Set(Jg.map(e=>e.id)),dy=e=>fN.has(e);function hy(e,t){const s=t.filter(r=>!fN.has(r));return[...Jg.filter(r=>e.has(r.id)).map(r=>r.id),...s.filter((r,i)=>s.indexOf(r)===i)]}function kD(e,t){return e.find(s=>(s.roles??[]).includes(t))}const fy=["coding","finance","mail","research","calendar","files","memory"],SD={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[Qg]:"buddi"},ND=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function CD(e){const t=new Set(e.map(s=>s.split(".")[0]??s));for(const[s,r]of ND)if(r.some(i=>t.has(i)))return s;return t.size>0&&[...t].every(s=>s==="memory")?"memory":null}let Tm=null;function ED(e){Tm=e}function Co(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const s of e.roles??[]){const r=SD[s];if(r)return{key:r}}const t=CD(e.tools??[]);return t?{key:t}:Tm!==null&&e.id===Tm?{key:"buddi"}:{key:fy[AD(e.id)%fy.length]??"coding"}}function Eo(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function AD(e){let t=0;for(const s of e)t=(t*31+s.charCodeAt(0))%997;return t}const TD=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function RD(e){const s=e.replace(/\r\n/g,`
82
- `).split(`
83
-
84
- `),r=s.pop()??"",i=[];for(const a of s){let l=null,o="message";const c=[];for(const u of a.split(`
85
- `)){if(u===""||u.startsWith(":"))continue;const f=u.indexOf(":"),d=f===-1?u:u.slice(0,f),m=f===-1?"":u.slice(f+1).replace(/^ /,"");d==="id"?l=m:d==="event"?o=m:d==="data"&&c.push(m)}c.length===0&&o==="message"||i.push({id:l,name:TD.includes(o)?o:"ping",data:ID(c.join(`
86
- `))})}return{events:i,rest:r}}function ID(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function Ad(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),s=e.wait??(u=>new Promise(f=>setTimeout(f,u))),r=e.retryMs??1500;let i=e.lastEventId??null,a=!1,l=!1,o=null;return(async()=>{var u,f,d,m,p;for(;!a;){(u=e.onStatus)==null||u.call(e,"connecting"),o=new AbortController;try{const v=await t(e.url,{credentials:"same-origin",signal:o.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!v.ok||!v.body)throw new Error(`stream ${v.status}`);(f=e.onStatus)==null||f.call(e,"open"),l&&((d=e.onReconnect)==null||d.call(e));const w=v.body.getReader(),k=new TextDecoder;let g="";for(;;){const{done:x,value:y}=await w.read();if(x)break;g+=k.decode(y,{stream:!0});const{events:j,rest:N}=RD(g);g=N;for(const b of j)e.onEvent(b),b.id!==null&&(i=b.id);if(a)break}}catch{}if(a)break;l=!0,(m=e.onStatus)==null||m.call(e,"closed"),await s(r)}(p=e.onStatus)==null||p.call(e,"closed")})(),{close:()=>{a=!0,o==null||o.abort()},lastEventId:()=>i}}const Xg="0.1.0+4f74f56";function Zg(e,t=Xg){return typeof e=="string"&&e!==""&&typeof t=="string"&&t!==""&&e!==t}function PD(){var e;try{if((e=window.matchMedia)!=null&&e.call(window,"(display-mode: standalone)").matches)return!0}catch{}return window.navigator.standalone===!0}const MD=5*6e4,$D=6e4,DD=5e3,Rm="buddi:stream-reconnected",mN="buddi.autoReloadedFor";function OD(){window.dispatchEvent(new Event(Rm))}const my=["keydown","pointerdown","pointermove","wheel","touchstart","input"];let ex=Date.now(),fc=0;const py=()=>{ex=Date.now()};function _D(){if(fc===0){ex=Date.now();for(const e of my)window.addEventListener(e,py,{capture:!0,passive:!0})}return fc+=1,()=>{if(fc-=1,fc===0)for(const e of my)window.removeEventListener(e,py,{capture:!0})}}function LD(e=Date.now()){return e-ex}function FD(e=document){return e.querySelector('.wb-composer[data-busy="true"]')!==null||e.querySelector('.wb-listening, [data-recording="true"]')!==null||e.querySelector('[role="dialog"], [role="alertdialog"], dialog[open]')!==null}function UD(e){return e.hidden?!0:e.idleMs>=$D&&!e.busy}function BD(e){try{return window.sessionStorage.getItem(mN)===e}catch{return!1}}function zD(e){try{window.sessionStorage.setItem(mN,e)}catch{}}function WD(e){const t=h.useRef(e);t.current=e,h.useEffect(()=>{const s=()=>t.current();return window.addEventListener(Rm,s),()=>window.removeEventListener(Rm,s)},[])}function HD(e,t=()=>window.location.reload(),s=Xg){const r=Zg(e,s),i=h.useRef(t);i.current=t,h.useEffect(()=>_D(),[]),h.useEffect(()=>{if(!r||e===void 0||BD(e))return;let a=!1;const l=()=>{if(a)return;const c=document.visibilityState==="hidden";UD({hidden:c,idleMs:LD(),busy:FD()})&&(a=!0,zD(e),i.current())};l();const o=window.setInterval(l,DD);return document.addEventListener("visibilitychange",l),()=>{window.clearInterval(o),document.removeEventListener("visibilitychange",l)}},[r,e])}const VD="/api/chat/attention/stream";function pN(e,t){const s=(a,l)=>a.name.localeCompare(l.name),r=a=>e.filter(l=>l.anchor===a).sort(s),i=e.filter(a=>a.anchor!=="top"&&a.anchor!=="bottom").sort((a,l)=>a.id===t?l.id===t?0:-1:l.id===t?1:s(a,l));return{top:r("top"),middle:i,bottom:r("bottom")}}function gN(e,t){const s=pN(e,t);return[...s.top,...s.middle,...s.bottom]}function Td(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 KD(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function GD(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function YD(){const[e,t]=h.useState(null);return h.useEffect(()=>{let s=!1;const r=()=>{ue("/chat/attention").then(a=>{s||t(a)}).catch(()=>{})};r();const i=Ad({url:VD,onEvent:()=>r(),onReconnect:OD});return()=>{s=!0,i.close()}},[]),GD(e)}const Rd="maker";function xN(e){return e.filter(t=>t.available&&!t.roles.includes(Rd))}function vN(e){return xN(e).length>=2}function qD(e){var t;return((t=e.find(s=>s.roles.includes(Rd)))==null?void 0:t.name)??"the agent maker"}const QD="{{default}}";function JD(e,t){return e.split(QD).join(t??"your assistant")}function XD(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(s=>JD(s,t))}function ZD(e){var s,r;const t=(s=e==null?void 0:e.intro)==null?void 0:s.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function eO(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 jN(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 s=(i=e.unavailableReason)==null?void 0:i.trim();return s&&s!==""?`${e.name??"This agent"} cannot run: ${s}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const tO="Settings → Model accounts",nO="Install it in Settings → Plugins";function Im(e){return e!=null&&e.heldBack?{section:"plugins",label:nO}:{section:"accounts",label:tO}}const sO={home:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),n.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,n.jsxs(n.Fragment,{children:[n.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"}),n.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),n.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),n.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),n.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,n.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[24,1.9,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),20],files:[20,1.6,n.jsxs(n.Fragment,{children:[n.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"}),n.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),n.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),n.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),n.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),n.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,n.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,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),n.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),n.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),n.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),n.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),n.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,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),n.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],sun:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),n.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,n.jsxs(n.Fragment,{children:[n.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"}),n.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),n.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),n.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],eye:[20,1.6,n.jsxs(n.Fragment,{children:[n.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"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),n.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,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),n.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"})]})],"partly-cloudy":[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7.4",cy:"7.4",r:"2.4"}),n.jsx("path",{d:"M7.4 2.8v1M2.8 7.4h1M4.2 4.2l.7.7M10.6 4.2l-.7.7"}),n.jsx("path",{d:"M7.8 16.8h6.4a2.9 2.9 0 0 0 .3-5.8 4 4 0 0 0-7.6 1.1 2.4 2.4 0 0 0 .9 4.7Z"})]})],cloud:[20,1.6,n.jsx("path",{d:"M6 15.6h8.2a3.3 3.3 0 0 0 .4-6.6 4.6 4.6 0 0 0-8.9 1A2.8 2.8 0 0 0 6 15.6Z"})],rain:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M7.2 14.6l-.8 2M10.4 14.6l-.8 2M13.6 14.6l-.8 2"})]})],drizzle:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M7 15.2v.3M10 16.4v.3M13 15.2v.3"})]})],snow:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M7.4 14.4v2.4M6.2 15.6h2.4M12.6 14.4v2.4M11.4 15.6h2.4"})]})],storm:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M10.8 13.2 9 15.6h2.4l-1.8 2.6"})]})],fog:[20,1.6,n.jsx("path",{d:"M3.6 7.2h12.8M5.2 10.2h9.6M3.6 13.2h12.8M6.4 16.2h7.2"})],wind:[20,1.6,n.jsx("path",{d:"M3 8h9.4a2.2 2.2 0 1 0-2.2-2.2M3 12h11.6a2.2 2.2 0 1 1-2.2 2.2M3 10h5.4"})],"moon-clear":[20,1.6,n.jsx("path",{d:"M15.8 12.2A6.2 6.2 0 0 1 7.8 4.2a6.2 6.2 0 1 0 8 8Z"})],dot:[20,1.6,n.jsx("circle",{cx:"10",cy:"10",r:"2.2"})],camera:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.6 6.2a1.4 1.4 0 0 1 1.4-1.4h2l1.1-1.6h2.8l1.1 1.6h2a1.4 1.4 0 0 1 1.4 1.4v6.4a1.4 1.4 0 0 1-1.4 1.4H4a1.4 1.4 0 0 1-1.4-1.4z"}),n.jsx("circle",{cx:"8.5",cy:"9.2",r:"2.4"})]})],clip:[17,1.5,n.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"})],mic:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"6.3",y:"2.4",width:"4.4",height:"7.6",rx:"2.2"}),n.jsx("path",{d:"M3.9 8.4a4.6 4.6 0 0 0 9.2 0M8.5 13v2"})]})],speaker:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.8 6.6h2.4l3.4-2.8v9.4l-3.4-2.8H2.8z"}),n.jsx("path",{d:"M11.2 6.2a3.2 3.2 0 0 1 0 4.6M13.2 4.4a5.8 5.8 0 0 1 0 8.2"})]})],send:[16,1.8,n.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],check:[16,1.8,n.jsx("path",{d:"M3.5 8.4 6.6 11.4 12.5 4.8"})],close:[16,1.8,n.jsx("path",{d:"M4.5 4.5l7 7M11.5 4.5l-7 7"})],thought:[13,1.4,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),n.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,n.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,n.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],copy:[16,1.5,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"5.6",y:"5.6",width:"7.6",height:"7.6",rx:"1.4"}),n.jsx("path",{d:"M10.4 5.6V4a1.2 1.2 0 0 0-1.2-1.2H4A1.2 1.2 0 0 0 2.8 4v5.2A1.2 1.2 0 0 0 4 10.4h1.6"})]})],play:[16,1.5,n.jsx("path",{d:"M5.2 3.4v9.2L12.6 8z"})],pause:[16,1.5,n.jsx("path",{d:"M5.6 3.6v8.8M10.4 3.6v8.8"})],stop:[16,1.5,n.jsx("rect",{x:"4.2",y:"4.2",width:"7.6",height:"7.6",rx:"1.2"})],download:[16,1.5,n.jsx("path",{d:"M8 2.8v7.2M4.9 7 8 10.1 11.1 7M3 12.8h10"})],out:[12,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),n.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,n.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,n.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,n.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],more:[16,0,n.jsxs("g",{fill:"currentColor",stroke:"none",children:[n.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})],drop:[28,1.8,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),n.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"})]})],folder:[20,1.6,n.jsx("path",{d:"M2.8 5.6a1.4 1.4 0 0 1 1.4-1.4h3.4l1.7 1.9h6.5a1.4 1.4 0 0 1 1.4 1.4v7.3a1.4 1.4 0 0 1-1.4 1.4H4.2a1.4 1.4 0 0 1-1.4-1.4Z"})],"chevron-down":[14,1.4,n.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),n.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),n.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,n.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,n.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,n.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,n.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-tiles":[16,1.4,n.jsx("path",{d:"M2.4 3.4h4.8v4.2H2.4zM8.8 3.4h4.8v4.2H8.8zM2.4 9.2h4.8v4.2H2.4zM8.8 9.2h4.8v4.2H8.8z"})],"shape-document":[16,1.4,n.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,n.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,n.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,n.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,n.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,n.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],moon:[16,1.5,n.jsx("path",{d:"M12.9 9.7A5.3 5.3 0 0 1 6.3 3.1a5.3 5.3 0 1 0 6.6 6.6z"})],"shape-structured":[16,1.4,n.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function Se({name:e,size:t,className:s,...r}){const[i,a,l,o]=sO[e],c=t??o??i;return n.jsx("svg",{className:s,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:l})}const yN="buddi.rosterCollapsed";function rO(){try{return window.localStorage.getItem(yN)==="1"}catch{return!1}}function iO(e){try{window.localStorage.setItem(yN,e?"1":"0")}catch{}}function wN({agents:e,currentId:t,attention:s,onSelect:r,orientation:i="vertical",lastActivity:a,groups:l=[],currentGroupId:o=null,onSelectGroup:c,onNewGroup:u}){const f=[...e.top,...e.middle,...e.bottom],d=i==="vertical"?"right":"bottom",[m,p]=h.useState(rO),v=w=>n.jsx(aO,{agent:w,active:w.id===t,attention:s.get(w.id),side:d,onSelect:r,lastAt:(a==null?void 0:a.get(w.id))??null},w.id);return n.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&m?"true":void 0,children:[e.top.map(v),e.top.length>0&&e.middle.length>0?n.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!m&&e.middle.length>0?n.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,n.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(v),c&&vN(f)?n.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[n.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),n.jsxs("div",{className:"wb-groups-head",children:[n.jsx("span",{className:"wb-groups-label",children:"Groups"}),u?n.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:n.jsx(Se,{name:"plus"})}):null]}),l.map(w=>n.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":w.id===o?"true":void 0,"aria-current":w.id===o?"true":void 0,"aria-label":`${w.name}, ${w.members.length} agents`,onClick:()=>c(w.id),children:[n.jsxs("span",{className:"wb-face-mark wb-group-stack","aria-hidden":"true",children:[w.members.slice(0,3).map(k=>{const g=f.find(x=>x.id===k);return n.jsx(tx,{className:"wb-group-chip",id:k,name:(g==null?void 0:g.name)??"?",face:g,initials:1},k)}),w.members.length>3?n.jsxs("span",{className:"wb-group-chip wb-group-more",children:["+",w.members.length-3]}):null]}),n.jsxs("span",{className:"wb-face-text",children:[n.jsx("span",{className:"wb-face-name",children:w.name}),n.jsx("span",{className:"wb-face-status",children:w.members.map(k=>{var g;return((g=f.find(x=>x.id===k))==null?void 0:g.name)??k}).join(", ")})]})]},w.id))]}):c?n.jsxs("div",{className:"wb-groups","data-testid":"group-rail-hint",children:[n.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),n.jsx("div",{className:"wb-groups-head",children:n.jsx("span",{className:"wb-groups-label",children:"Groups"})}),n.jsxs("p",{className:"wb-groups-hint",children:["A group needs two agents; ",n.jsx("a",{href:ut,children:"add a teammate"}),"."]})]}):null]}),e.bottom.map(v),i==="vertical"?n.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":m?"Show agent names":"Hide agent names","aria-pressed":m,onClick:()=>p(w=>(iO(!w),!w)),children:n.jsx(Se,{name:m?"chevron-right":"chevron-left"})}):null]})}function aO({agent:e,active:t,attention:s,side:r,onSelect:i,lastAt:a=null}){const l=Td(s),o=l?gy(l):e.available?a?`Last spoke ${Oe(a)}`:e.description:e.unavailableReason??"Cannot run right now",c=KD(s),u=e.unavailableReason??"This agent cannot run on this machine right now.",f=[e.name,e.available?null:"unavailable",l,t?"current":null].filter(d=>d!==null&&d!=="").join(" — ");return n.jsxs(eo,{children:[n.jsx(to,{asChild:!0,children:n.jsxs("button",{className:"wb-face",...Eo(Co(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":f,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[n.jsx(tx,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),n.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[n.jsxs("span",{className:"wb-face-name",children:[e.name,n.jsxs("span",{className:"wb-face-handle",children:["@",e.handle]})]}),n.jsx("span",{className:"wb-face-status","data-tone":l?"critical":void 0,children:o})]}),c?n.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:n.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:n.jsx(Se,{name:"out"})})]})}),n.jsx(no,{children:n.jsxs(so,{className:"ui-tip",side:r,sideOffset:8,children:[n.jsx("span",{className:"ui-tip-title",children:e.name}),n.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:u}),l?n.jsx("span",{className:"ui-tip-alert",children:gy(l)}):null]})})]})}function gy(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function lO(e){let t=0;for(const s of e)t=(t*31+s.charCodeAt(0))%997;return t%6+1}const oO="modulepreload",cO=function(e,t){return new URL(e,t).href},xy={},uO=function(t,s,r){let i=Promise.resolve();if(s&&s.length>0){const l=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),c=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(s.map(u=>{if(u=cO(u,r),u in xy)return;xy[u]=!0;const f=u.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(!!r)for(let v=l.length-1;v>=0;v--){const w=l[v];if(w.href===u&&(!f||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":oO,f||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),f)return new Promise((v,w)=>{p.addEventListener("load",v),p.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${u}`)))})}))}function a(l){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=l,window.dispatchEvent(o),!o.defaultPrevented)throw l}return i.then(l=>{for(const o of l||[])o.status==="rejected"&&a(o.reason);return t().catch(a)})},dO="buddi",hO=["core","coding","finance","garage","mail","maker","playground","research"],Gr=e=>`./mascot/${e}.png`,fO=["core"],Pm=(e,t)=>fO.includes(e)?`./mascot/anim/${e}-${t}.json`:null,mO=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],pO="Introduce yourself by name and say one thing you can do today.",U={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",startOver:{link:"Start over",said:e=>`Starting again. What you already connected stays in Settings: ${e}.`,telegram:"Telegram",browser:"the browser"},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",know:"Uses your Claude plan's monthly Agent SDK credits; after them, an API key."},chatgpt:{title:"ChatGPT",line:"I pay for ChatGPT",know:"Uses your ChatGPT plan through OpenAI's Codex backend. Sign in with a code."},gemini:{title:"Gemini",line:"I have a Google AI key"},key:{title:"A key from Anthropic or OpenAI",line:"I have an API key"},ollama:{title:"Ollama",line:"Free, on this computer"},cloud:{title:"Ollama Cloud, one tap",line:"Free to start, no key"},service:{title:"Another service, or Ollama Cloud with a key",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."},chatgpt:{label:"ChatGPT",codeBefore:"Here is your code: ",codeAfter:". Open the link, enter it, and approve buddi on openai.com.",code:"Your code",open:"Open openai.com",again:"Try again",failed:"The sign-in did not finish. Try again."},cloud:{label:"Ollama Cloud",waiting:"Press Connect on the ollama.com page. Sign in there first if it asks. I will notice.",open:"Open the ollama.com page",again:"Try again"},gemini:{label:"Gemini",field:"Your Google AI key",placeholder:"Paste it here",submit:"Use this key",get:"Get a key at aistudio.google.com"},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",retry:"Try again",change:"Think with another"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking Ollama…",cloud:"Asking Ollama Cloud…",claude:"Checking with Claude…",chatgpt:"Asking ChatGPT…",gemini:"Asking Gemini…"},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}.`,worksOnFlash:e=>`That works. Google's free tier has no Pro allowance, so your assistant will think with ${e}; turn on billing at Google to use Pro.`,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(`
87
- `),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:{said:e=>`That was ${e}. You can answer it on the next page. One more thing before that: you can also talk to it from your phone, through Telegram; a code pairs the two.`,paired:e=>`That was ${e}. You can answer it on the next page. Your phone is already paired.`,phone:"Set up Telegram",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"};let mc=null;const vy=new Map;function gO(){return mc??(mc=uO(()=>import("./lottie_light-D7STH9tF.js").then(e=>e.l),[],import.meta.url).then(e=>e.default)),mc.catch(()=>{mc=null}),mc}function xO(e){let t=vy.get(e);return t||(t=fetch(e).then(s=>s.ok?s.text():null).catch(()=>null),vy.set(e,t)),t}const jy="(prefers-reduced-motion: reduce)";function bN(){const[e,t]=h.useState(()=>typeof window.matchMedia=="function"&&!window.matchMedia(jy).matches);return h.useEffect(()=>{var i;if(typeof window.matchMedia!="function")return;const s=window.matchMedia(jy),r=()=>t(!s.matches);return(i=s.addEventListener)==null||i.call(s,"change",r),()=>{var a;return(a=s.removeEventListener)==null?void 0:a.call(s,"change",r)}},[]),e}function Id({role:e="core",state:t,size:s,still:r,className:i,onStillError:a}){const l=h.useRef(null),o=bN(),[c,u]=h.useState(!1),f=s==="xs"?null:Pm(e,t);return h.useEffect(()=>{if(u(!1),!o||!f)return;let d=!1,m=null;return Promise.all([gO(),xO(f)]).then(([p,v])=>{if(d||!v||!l.current)return;const w=p.loadAnimation({container:l.current,renderer:"svg",loop:!0,autoplay:!document.hidden,animationData:JSON.parse(v),rendererSettings:{preserveAspectRatio:"xMidYMid meet"}}),k=()=>{document.hidden?w.pause():w.play()};document.addEventListener("visibilitychange",k),m=()=>{document.removeEventListener("visibilitychange",k),w.destroy()},u(!0)}).catch(()=>{}),()=>{d=!0,m==null||m()}},[o,f]),n.jsx("span",{ref:l,className:i?`ui-blob ${i}`:"ui-blob","data-size":s,"data-playing":c?"true":void 0,"data-testid":"blob","data-state":t,"aria-hidden":"true",children:c?null:n.jsx("img",{src:r??Gr(e),alt:"",onError:a})})}async function yy(e){const t=new Image;t.src=e,await t.decode();const s=document.createElement("canvas");s.width=8,s.height=8;const r=s.getContext("2d");return r?(r.fillStyle="#fff",r.fillRect(0,0,8,8),r.drawImage(t,0,0,8,8),Array.from(r.getImageData(0,0,8,8).data)):null}function kN(e,t="core"){const s=bN(),r=e!==null&&vO(e,t),[i,a]=h.useState(!1);return h.useEffect(()=>{if(a(!1),!e||r||!s||!Pm(t,"idle"))return;let l=!1;return Promise.all([yy(e),yy(Gr(t))]).then(([o,c])=>{if(l||!o||!c||o.length!==c.length)return;const u=o.reduce((f,d,m)=>f+Math.abs(d-c[m]),0)/o.length;a(u<12)}).catch(()=>{}),()=>{l=!0}},[e,r,s,t]),s&&Pm(t,"idle")!==null&&(r||i)}function vO(e,t){const s=Gr(t);if(e===s)return!0;try{const r=typeof window>"u"?"http://localhost/":window.location.href;return new URL(e,r).href===new URL(s,r).href}catch{return!1}}function tx({className:e,id:t,name:s,face:r,tint:i,size:a,unavailable:l,initials:o=2}){const[c,u]=h.useState(null),f=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,d=r==null?void 0:r.avatar,m=f?"image":d==null?void 0:d.kind,p=t?Eo(Co({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 n.jsx("span",{className:e,"data-tint":p?void 0:i,"data-size":a,"data-kind":m,"data-unavailable":l?"true":void 0,...p,"aria-hidden":"true",children:f?n.jsx("img",{src:f,alt:"",onError:()=>u(f)}):(d==null?void 0:d.kind)==="image"?n.jsx("img",{src:d.url,alt:""}):(d==null?void 0:d.kind)==="emoji"?d.value:eO(s).slice(0,o)})}function ps({id:e,name:t,size:s,unavailable:r,face:i}){return n.jsx(tx,{className:"ui-avatar",id:e,tint:lO(e),name:t,size:s,unavailable:r,face:i})}function vn({agents:e,id:t,size:s}){const r=e.find(i=>i.id===t);return n.jsx(ps,{id:t,name:(r==null?void 0:r.name)??t,size:s,unavailable:r?!r.available:!1,face:r})}const SN=h.createContext(null);function jO({picture:e,children:t}){return n.jsx(SN.Provider,{value:e??null,children:t})}function NN({size:e,anim:t}){const s=h.useContext(SN),[r,i]=h.useState(null),a=kN(t?s:null);return!s||s===r?null:n.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:t&&a?n.jsx(Id,{state:t,still:s,className:"ui-mascot-blob",onStillError:()=>i(s)}):n.jsx("img",{src:s,alt:"",onError:()=>i(s)})})}const CN=h.createContext([]);function nr({text:e,className:t}){const s=Mm(e.replace(/\r\n/g,`
88
- `).split(`
89
- `));return n.jsx("div",{className:t??"wb-md",children:s.map((r,i)=>n.jsx($m,{block:r},i))})}const wy=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,by=/^(#{1,6})\s+(.*?)\s*#*\s*$/,ky=/^\s*([-*_])(\s*\1){2,}\s*$/,pc=/^(\s*)([-*+])\s+(.*)$/,cl=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,gc=/^\s*>\s?(.*)$/,Mh=/^\s*\|.*\|\s*$/,Sy=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function Mm(e){const t=[];let s=0;for(;s<e.length;){const r=e[s];if(r.trim()===""){s+=1;continue}const i=wy.exec(r);if(i){const o=i[2],c=[];for(s+=1;s<e.length&&!new RegExp(`^\\s*${o}\\s*$`).test(e[s]);)c.push(e[s]),s+=1;s+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
90
- `)});continue}const a=by.exec(r);if(a){t.push({type:"h",level:a[1].length,text:a[2]}),s+=1;continue}if(ky.test(r)){t.push({type:"hr"}),s+=1;continue}if(gc.test(r)){const o=[];for(;s<e.length&&gc.test(e[s]);)o.push(gc.exec(e[s])[1]),s+=1;t.push({type:"quote",blocks:Mm(o),raw:o.join(`
91
- `)});continue}if(Mh.test(r)&&s+1<e.length&&Sy.test(e[s+1])){const o=Dh(r),c=Dh(e[s+1]).map(f=>{const d=f.startsWith(":"),m=f.endsWith(":");return d&&m?"center":m?"right":d?"left":null});s+=2;const u=[];for(;s<e.length&&Mh.test(e[s]);)u.push(Dh(e[s])),s+=1;t.push({type:"table",head:o,rows:u,align:c});continue}if(pc.test(r)||cl.test(r)){const o=cl.exec(r)??pc.exec(r),c=cl.test(r),u=o[1].length,f=c?Number(o[2]):1,d=[];for(;s<e.length;){const m=c?cl.exec(e[s]):pc.exec(e[s]);if(!m||m[1].length!==u)break;const p=[m[3]];for(s+=1;s<e.length;){const v=e[s],w=v.trim()!==""&&$h(v)>u,k=v.trim()===""&&s+1<e.length&&e[s+1].trim()!==""&&$h(e[s+1])>u;if(!w&&!k)break;p.push(v.trim()===""?"":v.slice(Math.min($h(v),u+2))),s+=1}d.push(Mm(p))}t.push({type:"list",ordered:c,start:f,items:d});continue}const l=[];for(;s<e.length;){const o=e[s];if(o.trim()===""||wy.test(o)||by.test(o)||ky.test(o)||gc.test(o)||pc.test(o)||cl.test(o)||Mh.test(o)&&s+1<e.length&&Sy.test(e[s+1]))break;l.push(o.trim()),s+=1}l.length>0&&t.push({type:"p",text:l.join(`
92
- `)})}return t}function $h(e){return e.length-e.trimStart().length}function Dh(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let r="";for(let i=0;i<t.length;i+=1){const a=t[i];if(a==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(a==="|"){s.push(r.trim()),r="";continue}r+=a}return s.push(r.trim()),s}function $m({block:e}){switch(e.type){case"p":return n.jsx("p",{children:is(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),s=`h${Math.min(t+2,6)}`;return n.jsx(s,{className:"wb-md-h","data-level":t,children:is(e.text)})}case"code":return n.jsxs("div",{className:"wb-md-code-frame",children:[n.jsxs("div",{className:"wb-md-code-head",children:[n.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),n.jsx(Ny,{text:e.text,what:"code",always:!0})]}),n.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:n.jsx("code",{children:e.text})})]});case"quote":return n.jsxs("div",{className:"wb-md-copyable",children:[n.jsx("blockquote",{children:e.blocks.map((t,s)=>n.jsx($m,{block:t},s))}),n.jsx(Ny,{text:e.raw,what:"quote"})]});case"hr":return n.jsx("hr",{});case"list":{const t=e.items.map((s,r)=>n.jsx("li",{children:s.map((i,a)=>i.type==="p"?n.jsx(h.Fragment,{children:is(i.text)},a):n.jsx($m,{block:i},a))},r));return e.ordered?n.jsx("ol",{start:e.start,children:t}):n.jsx("ul",{children:t})}case"table":return n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table wb-md-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.head.map((t,s)=>n.jsx("th",{style:e.align[s]?{textAlign:e.align[s]}:void 0,children:is(t)},s))})}),n.jsx("tbody",{children:e.rows.map((t,s)=>n.jsx("tr",{children:t.map((r,i)=>n.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:is(r)},i))},s))})]})})}}function Ny({text:e,what:t,always:s=!1}){const[r,i]=h.useState("idle"),a=()=>{var l;if(!((l=navigator.clipboard)!=null&&l.writeText)){i("failed");return}navigator.clipboard.writeText(e).then(()=>i("done"),()=>i("failed")),window.setTimeout(()=>i("idle"),1500)};return n.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":s||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:a,children:r==="done"?"Copied":r==="failed"?"Select to copy":n.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:[n.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),n.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 yO({handle:e}){const s=h.useContext(CN).find(r=>r.handle.toLowerCase()===e.toLowerCase());return s?n.jsxs(eo,{children:[n.jsx(to,{asChild:!0,children:n.jsxs("a",{className:"wb-mention-link",href:Ke(s.id),children:["@",s.handle]})}),n.jsx(no,{children:n.jsxs(so,{className:"wb-agent-card",sideOffset:6,children:[n.jsx(ps,{id:s.id,name:s.name,face:s,unavailable:!s.available}),n.jsxs("span",{className:"wb-agent-card-text",children:[n.jsx("span",{className:"wb-agent-card-name",children:s.name}),n.jsx("span",{className:"wb-agent-card-desc",children:s.description}),n.jsxs("span",{className:"wb-agent-card-meta",children:[s.model,s.available?"":" · unavailable"]})]})]})})]}):n.jsxs(n.Fragment,{children:["@",e]})}const wO=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 is(e){const t=[];let s=e,r=0;for(;s!=="";){const i=wO.exec(s);if(!i){t.push(...Cy(s,r));break}i.index>0&&t.push(...Cy(s.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(n.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(n.jsx("strong",{children:is(i[3])},r)):i[4]!==void 0?t.push(n.jsx("strong",{children:is(i[4])},r)):i[5]!==void 0?t.push(n.jsx("s",{children:is(i[5])},r)):i[6]!==void 0?t.push(n.jsx("em",{children:is(i[6])},r)):i[7]!==void 0?t.push(n.jsx("em",{children:is(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(n.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:is(i[8])},r)):i[10]!==void 0?t.push(n.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(n.jsx(yO,{handle:i[11]},r)),s=s.slice(i.index+i[0].length)}return t}function Cy(e,t){return e.split(`
93
- `).flatMap((r,i)=>i===0?[r]:[n.jsx("br",{},`${t}-br-${i}`),r])}function bO({props:e}){return n.jsxs("div",{children:[e.title?n.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:$t(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?n.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?n.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:n.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?n.jsx("div",{className:"wb-doc",children:n.jsx(nr,{text:e.text})}):n.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}const kO=["mail","money","calendar","people","file","chart","bell","plug","key","globe","sun","partly-cloudy","cloud","rain","drizzle","snow","storm","fog","wind","moon-clear"];function me(e,t){if(t===""||t==="$")return e;let s=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,a="",l=""]=i;if(a!==""){if(s===null||typeof s!="object")return;s=s[a]}for(const o of l.match(/\d+/g)??[]){if(!Array.isArray(s))return;s=s[Number(o)]}if(s===void 0)return}return s}function Pe(e,t){if(t)return"const"in t?t.const:me(e,t.path)}function $n(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 Ye(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Tr(e){return Array.isArray(e)?e:[]}function SO(e,t){const s=Tr(me(e,t.points)).map(i=>{const a=$n(me(i,t.y)),l=Ye(me(i,t.x));return a===null||l===null?null:{x:l,y:a}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const a=$n(Pe(e,i.value));return a===null?null:{value:a,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:s,unit:t.unit??"number",currency:Ye(Pe(e,t.currency)),label:Ye(Pe(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:$n(Pe(e,t.shadeBelow)),events:NO(e,t)}}function NO(e,t){const s=t.events;if(!s)return[];const r=[],i=(a,l)=>{const o=Ye(me(a,s.label));if(o===null)return;const c=Ye(me(a,s.at))??l;c!==null&&r.push({at:c,label:o,amount:s.amount?$n(me(a,s.amount)):null})};if(s.parent){for(const a of Tr(me(e,t.points))){const l=Ye(me(a,t.x));for(const o of Tr(me(a,s.parent)))i(o,l)}return r}for(const a of Tr(me(e,s.path??t.points)))i(a,null);return r}function CO(e,t){const s=(t.columns??[]).map(o=>({key:o.key,label:o.label,type:o.type??"text"})),r=o=>(t.columns??[]).map(c=>{const u=me(o,c.key);let f=null;if(c.bar){const d=$n(Pe(o,c.bar.max))??$n(Pe(e,c.bar.max)),m=$n(u);if(d!==null&&d>0&&m!==null){const p=Math.max(0,Math.min(1,m/d));f={fraction:p,tone:AO(p*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:Ye(Pe(o,c.currency))??Ye(Pe(e,c.currency)),bar:f}}),i=Tr(me(e,t.rows)),a=t.groupBy?EO(i,t.groupBy,r):[{label:null,rows:i.map(r)}],l=(t.summary??[]).map(o=>({label:o.label,value:Pe(e,o.value),unit:o.unit??"text",currency:Ye(Pe(e,o.currency)),tone:o.tone??"neutral"}));return{columns:s,groups:a,summary:l,empty:t.empty??"Nothing to show."}}function EO(e,t,s){const r=new Map;for(const i of e){const a=String(me(i,t.key)??""),l=r.get(a);l?l.push(i):r.set(a,[i])}return[...r.entries()].map(([i,a])=>{var l;return{label:((l=t.labels)==null?void 0:l[i])??i,rows:a.map(s)}})}function AO(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,a)=>a.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function TO(e,t){return{bars:Tr(me(e,t.bars)).map(r=>{const i=$n(me(r,t.value)),a=Ye(me(r,t.category));return i===null||a===null?null:{category:a,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:Ye(Pe(e,t.currency))}}function RO(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:Pe(e,r.value),unit:r.unit??"text",currency:Ye(Pe(e,r.currency)),tone:r.tone??"neutral"}))};const s=me(e,t.from??"$");return s===null||typeof s!="object"||Array.isArray(s)?{pairs:[]}:{pairs:Object.entries(s).map(([r,i])=>({label:un(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}const IO=new Set(["good","warning","critical","neutral","accent"]),PO=new Set(kO);function Dm(e){return typeof e=="string"&&PO.has(e)?e:null}function nx(e,t,s=""){const r=t.empty??"Nothing to show.",i=s.split(".")[0]??"";if(t.notice){const l=Ye(me(e,t.notice.text));if(l!==null&&l.trim()!==""){const o=t.notice.link&&i!==""?{plugin:i,page:t.notice.link.page}:null;return{tiles:[{icon:Dm(t.notice.icon??"bell"),value:"",label:l.trim(),lines:[],tone:"neutral",link:o}],notice:!0,empty:r}}}return{tiles:Tr(me(e,t.items)).map(l=>{const o=Ye(me(l,t.value))??"",c=Ye(me(l,t.label))??"";if(o===""&&c==="")return null;const u=t.tone?Ye(me(l,t.tone)):null;return{icon:Dm(Pe(l,t.icon)),value:o,label:c,lines:(t.lines??[]).slice(0,2).map(f=>Ye(me(l,f))).filter(f=>f!==null&&f.trim()!==""),tone:u!==null&&IO.has(u)?u:"neutral",link:null}}).filter(l=>l!==null),notice:!1,empty:r}}function MO(e,t){const s=Ye(Pe(e,t.kind)),r=s==="image"||s==="pdf"?s:"text",i=t.src?Ye(me(e,t.src)):null;return{kind:r,text:t.text?Ye(me(e,t.text)):null,src:i&&AN(i)?i:null,title:Ye(Pe(e,t.title)),metadata:(t.metadata??[]).map(a=>({label:a.label,value:Pe(e,a.value),unit:a.unit??"text"}))}}function $O(e,t){const s=t.diff?me(e,t.diff):void 0;return{diff:typeof s=="string"&&s.trim()!==""?s:null,title:Ye(Pe(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:Pe(e,r.value),unit:r.unit??"text"}))}}function DO(e,t){const s=t.output?me(e,t.output):void 0,r=l=>{const o=l?me(e,l):void 0;return typeof o=="number"&&Number.isInteger(o)?o:null},i=r(t.omittedBytes),a=t.elapsedMs?me(e,t.elapsedMs):void 0;return{command:Ye(Pe(e,t.command)),output:typeof s=="string"?s:null,exitCode:r(t.exitCode),elapsedMs:typeof a=="number"&&Number.isFinite(a)&&a>=0?a:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(l=>({label:l.label,value:Pe(e,l.value),unit:l.unit??"text"}))}}const OO=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function EN(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&OO.test(t)?t.toLowerCase():null}function _O(e,t){return{artifactId:t.src?EN(me(e,t.src)):null,title:Ye(Pe(e,t.title)),caption:Ye(Pe(e,t.caption)),...t.captionLabel?{captionLabel:Ye(Pe(e,t.captionLabel))}:{}}}function Ey(e){if(!AN(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const s=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return s?{plugin:s[1],name:s[2]}:null}function LO(e,t){const s=t.src?Ye(me(e,t.src)):null,r=t.port?me(e,t.port):null,i=t.awaiting?Ye(me(e,t.awaiting)):null;return{target:s?Ey(s):null,title:Ye(Pe(e,t.title)),output:t.output?Ye(me(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?Ey(i):null,reloadsItself:t.reloadsItself?me(e,t.reloadsItself)===!0:!1,ports:t.ports?FO(me(e,t.ports)):[]}}function FO(e){const t=Tr(e).filter(s=>typeof s=="number"&&Number.isInteger(s)&&s>0&&s<=65535);return[...new Set(t)].sort((s,r)=>s-r)}function AN(e){return e.startsWith("/")&&!e.startsWith("//")}function un(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 TN(e,t){const s=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:SO(t,s)};case"table":return{renderer:"table",props:CO(t,s)};case"bars":return{renderer:"bars",props:TO(t,s)};case"keyvalue":return{renderer:"keyvalue",props:RO(t,s)};case"tiles":return{renderer:"tiles",props:nx(t,s,e.tool)};case"document":return{renderer:"document",props:MO(t,s)};case"diff":return{renderer:"diff",props:$O(t,s)};case"terminal":return{renderer:"terminal",props:DO(t,s)};case"image":return{renderer:"image",props:_O(t,s)};case"preview":return{renderer:"preview",props:LO(t,s)};default:return{renderer:"structured",props:{value:t}}}}var UO=Object.defineProperty,gs=(e,t)=>UO(e,"name",{value:t,configurable:!0}),sx="Dialog",[RN,TH]=fs(sx),[BO,or]=RN(sx),rx=gs(e=>{const{__scopeDialog:t,children:s,open:r,defaultOpen:i,onOpenChange:a,modal:l=!0}=e,o=h.useRef(null),c=h.useRef(null),[u,f]=Ei({prop:r,defaultProp:i??!1,onChange:a,caller:sx}),[d,m]=h.useState(0),[p,v]=h.useState(0);return n.jsx(BO,{scope:t,triggerRef:o,contentRef:c,contentId:os(),titleId:os(),descriptionId:os(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:m,setDescriptionCount:v,open:u,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(w=>!w),[f]),modal:l,children:s})},"Dialog"),IN="DialogPortal",[zO,PN]=RN(IN,{forceMount:void 0}),ix=gs(e=>{const{__scopeDialog:t,forceMount:s,children:r,container:i}=e,a=or(IN,t);return n.jsx(zO,{scope:t,forceMount:s,children:h.Children.map(r,l=>n.jsx(ar,{present:s||a.open,children:n.jsx(Sg,{asChild:!0,container:i,children:l})}))})},"DialogPortal"),Om="DialogOverlay",MN=h.forwardRef(gs(function(t,s){const r=PN(Om,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,l=or(Om,t.__scopeDialog);return l.modal?n.jsx(ar,{present:i||l.open,children:n.jsx(HO,{...a,ref:s})}):null},"DialogOverlay")),WO=$r("DialogOverlay.RemoveScroll"),HO=h.forwardRef(gs(function(t,s){const{__scopeDialog:r,...i}=t,a=or(Om,r),l=yk(),o=it(s,l);return n.jsx(Ug,{as:WO,allowPinchZoom:!0,shards:[a.contentRef],children:n.jsx(mt.div,{"data-state":ox(a.open),...i,ref:o,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),lo="DialogContent",ax=h.forwardRef(gs(function(t,s){const r=PN(lo,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,l=or(lo,t.__scopeDialog);return n.jsx(ar,{present:i||l.open,children:l.modal?n.jsx(VO,{...a,ref:s}):n.jsx(KO,{...a,ref:s})})},"DialogContent")),VO=h.forwardRef(gs(function(t,s){const r=or(lo,t.__scopeDialog),i=h.useRef(null),a=it(s,r.contentRef,i);return h.useEffect(()=>{const l=i.current;if(l)return MS(l)},[]),n.jsx($N,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:Re(t.onCloseAutoFocus,l=>{var o;l.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Re(t.onPointerDownOutside,l=>{const o=l.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&l.preventDefault()}),onFocusOutside:Re(t.onFocusOutside,l=>l.preventDefault())})},"DialogContentModal")),KO=h.forwardRef(gs(function(t,s){const r=or(lo,t.__scopeDialog),i=h.useRef(!1),a=h.useRef(!1);return n.jsx($N,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,l),l.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),l.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:l=>{var u,f;(u=t.onInteractOutside)==null||u.call(t,l),l.defaultPrevented||(i.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=l.target;((f=r.triggerRef.current)==null?void 0:f.contains(o))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})},"DialogContentNonModal")),$N=h.forwardRef(gs(function(t,s){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:l,...o}=t,c=or(lo,r);return vd(),n.jsx(n.Fragment,{children:n.jsx(pS,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:l,children:n.jsx(bg,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":ox(c.open),...o,ref:s,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),GO="DialogTitle",lx=h.forwardRef(gs(function(t,s){const{__scopeDialog:r,...i}=t,a=or(GO,r),{setTitleCount:l}=a;return bn(()=>(l(o=>o+1),()=>l(o=>o-1)),[l]),n.jsx(mt.h2,{id:a.titleId,...i,ref:s})},"DialogTitle")),YO="DialogClose",DN=h.forwardRef(gs(function(t,s){const{__scopeDialog:r,...i}=t,a=or(YO,r);return n.jsx(mt.button,{type:"button",...i,ref:s,onClick:Re(t.onClick,()=>a.onOpenChange(!1))})},"DialogClose"));function ox(e){return e?"open":"closed"}gs(ox,"getState");const qO=5;function ie(e,t,s){const[r,i]=h.useState(void 0),[a,l]=h.useState(null),[o,c]=h.useState(!0),[u,f]=h.useState(0),[d,m]=h.useState(0),p=h.useRef(e);return p.current=e,h.useEffect(()=>{let v=!1;return c(!0),p.current().then(w=>{v||(i(w),l(null),m(0))}).catch(w=>{v||(l(w instanceof he?w.message:String(w)),m(k=>k+1))}).finally(()=>{v||c(!1)}),()=>{v=!0}},[...t,u]),h.useEffect(()=>{if(!s||d>=qO)return;const v=window.setTimeout(()=>f(w=>w+1),s*2**d);return()=>window.clearTimeout(v)},[s,d,u]),{data:r,error:a,loading:o,reload:()=>{m(0),f(v=>v+1)}}}const ON={width:480,height:160,top:10,right:10,bottom:22,left:40},_N={width:1200,height:180,top:10,right:40,bottom:22,left:40};function QO({xs:e,series:t}){const s=_N,r=s.width-s.left-s.right,i=s.height-s.top-s.bottom,a=M=>M.filter(T=>T!==null&&Number.isFinite(T)),l=t.filter(M=>M.type!=="bar"),o=t.filter(M=>M.type==="bar"),c=l.flatMap(M=>a(M.values)),u=c.length>0?Math.min(...c):0,f=c.length>0?Math.max(...c):1;let d=u,m=f;if(d===m)d-=1,m+=1;else{const M=(m-d)*.08;d-=M,m+=M}const p=M=>Yn(s.top+i-(M-d)/(m-d)*i),v=o.length>0&&o.every(M=>M.unit==="percent"),w=v?100:Math.max(1,...o.flatMap(M=>a(M.values))),k=M=>Yn(s.top+i-Math.max(0,M)/w*i),g=e.length,x=g>0?r/g:r,y=M=>Yn(s.left+x*(M+.5)),j=t.map(M=>{if(M.type==="bar")return"";let T="M";const $=[];return M.values.forEach((_,K)=>{if(_===null||!Number.isFinite(_)){T="M";return}$.push(`${T}${y(K)},${p(_)}`),T="L"}),$.join(" ")}),N=[],b=x*.6/Math.max(1,o.length),S=s.height-s.bottom;let C=0;t.forEach((M,T)=>{if(M.type!=="bar")return;const $=C++;M.values.forEach((_,K)=>{if(_===null||!Number.isFinite(_)||_<=0)return;const D=k(_);N.push({series:T,index:K,x:Yn(y(K)-x*.3+b*$),y:D,width:Yn(b),height:Yn(S-D)})})});const R=c.length>0?Ru(u,f,2).map(M=>({value:M,y:p(M)})):[],E=o.length===0?[]:(v?[0,50,100]:Ru(0,w,2)).map(M=>({value:M,y:k(M),percent:v})),P=Math.max(1,Math.ceil(g/8)),F=e.flatMap((M,T)=>T%P===0?[{index:T,x:y(T)}]:[]);return{lines:j,bars:N,targetY:null,ticks:R,xLabels:F,rightTicks:E}}function JO({xs:e,series:t,type:s="line",target:r=null}){const i=ON,a=i.width-i.left-i.right,l=i.height-i.top-i.bottom,o=t.flatMap(y=>y.values.filter(j=>j!==null&&Number.isFinite(j)));r!==null&&Number.isFinite(r)&&o.push(r),s==="bar"&&o.push(0);let c=o.length>0?Math.min(...o):0,u=o.length>0?Math.max(...o):1;if(c===u)c-=1,u+=1;else if(s==="line"){const y=(u-c)*.08;c-=y,u+=y}const f=y=>Yn(i.top+l-(y-c)/(u-c)*l),d=e.length,m=d>0?a/d:a,p=y=>Yn(s==="bar"?i.left+m*(y+.5):i.left+(d<=1?a/2:y/(d-1)*a)),v=s==="line"?t.map(y=>{let j="M";const N=[];return y.values.forEach((b,S)=>{if(b===null||!Number.isFinite(b)){j="M";return}N.push(`${j}${p(S)},${f(b)}`),j="L"}),N.join(" ")}):[],w=[];if(s==="bar"&&d>0){const y=m*.7,j=y/Math.max(1,t.length),N=f(0);t.forEach((b,S)=>{b.values.forEach((C,R)=>{if(C===null||!Number.isFinite(C))return;const E=f(C);w.push({series:S,index:R,x:Yn(i.left+m*R+(m-y)/2+j*S),y:Math.min(E,N),width:Yn(j),height:Yn(Math.abs(N-E))})})})}const g=(o.length>0?Ru(Math.min(...o),Math.max(...o),2):[]).map(y=>({value:y,y:f(y)})),x=d===0?[]:d===1?[0]:d<5?[0,d-1]:[0,Math.floor((d-1)/2),d-1];return{lines:v,bars:w,targetY:r!==null&&Number.isFinite(r)?f(r):null,ticks:g,xLabels:x.map(y=>({index:y,x:p(y)}))}}function XO(e){const t=e.formatX??(o=>o),s=e.formatY??(o=>String(o)),r=e.xs.length;if(r===0)return`${e.label??"Chart"}: nothing recorded yet.`;const i=r===1?`on ${t(e.xs[0])}`:`from ${t(e.xs[0])} to ${t(e.xs[r-1])}`,a=e.series.map(o=>{const c=o.values.filter(f=>f!==null&&Number.isFinite(f));if(c.length===0)return`${o.label}: no values`;const u=c[c.length-1];return`${o.label}: latest ${s(u)}, lowest ${s(Math.min(...c))}, highest ${s(Math.max(...c))}`}),l=e.target!==null&&e.target!==void 0&&Number.isFinite(e.target)?` Target ${s(e.target)}.`:"";return`${e.label??"Chart"}, ${r} ${r===1?"point":"points"} ${i}. ${a.join("; ")}.${l}`}function ZO({xs:e,series:t,type:s="line",target:r=null,label:i,formatX:a=o=>o,formatY:l=o=>String(o)}){const o=s==="mixed",c=o?_N:ON,u=o?QO({xs:e,series:t}):JO({xs:e,series:t,type:s,target:r}),f=XO({xs:e,series:t,target:r,...i?{label:i}:{},formatX:a,formatY:l});return n.jsxs("figure",{className:"ui-chart","data-type":s,children:[n.jsxs("svg",{viewBox:`0 0 ${c.width} ${c.height}`,"aria-hidden":"true",focusable:"false","data-testid":"chart-svg",children:[u.ticks.map(d=>n.jsxs("g",{children:[n.jsx("line",{className:"ui-chart-grid",x1:c.left,x2:c.width-c.right,y1:d.y,y2:d.y}),n.jsx("text",{x:c.left-6,y:d.y,textAnchor:"end",dominantBaseline:"middle",children:l(d.value)})]},d.value)),(u.rightTicks??[]).map(d=>n.jsx("text",{x:c.width-c.right+6,y:d.y,textAnchor:"start",dominantBaseline:"middle",children:d.percent?`${d.value}%`:l(d.value)},`r-${d.value}`)),n.jsx("line",{className:"ui-chart-axis",x1:c.left,x2:c.width-c.right,y1:c.height-c.bottom,y2:c.height-c.bottom}),u.bars.map(d=>n.jsx("rect",{className:"ui-chart-bar","data-series":d.series,x:d.x,y:d.y,width:d.width,height:d.height},`${d.series}-${d.index}`)),u.lines.map((d,m)=>d?n.jsx("path",{className:"ui-chart-line","data-series":m,d},m):null),u.targetY!==null?n.jsx("line",{className:"ui-chart-target","data-testid":"chart-target",x1:c.left,x2:c.width-c.right,y1:u.targetY,y2:u.targetY}):null,u.xLabels.map(d=>n.jsx("text",{x:d.x,y:c.height-6,textAnchor:o?"middle":u.xLabels.length>1&&d.index===0?"start":d.index===e.length-1&&e.length>1?"end":"middle",children:a(e[d.index])},d.index))]}),n.jsx("figcaption",{className:"sr-only",children:f}),t.length>1?n.jsx("ul",{className:"ui-chart-legend","aria-hidden":"true",children:t.map((d,m)=>n.jsx("li",{"data-series":m,"data-type":o?d.type??"line":void 0,children:d.label},d.label))}):null]})}function Yn(e){return Math.round(e*10)/10}function Pi(...e){return e.filter(Boolean).join(" ")}function I({variant:e,size:t,className:s,type:r="button",...i}){return n.jsx("button",{type:r,className:Pi("ui-btn",s),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function Yt({variant:e,size:t,className:s,...r}){return n.jsx("a",{className:Pi("ui-btn",s),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function Q({children:e,align:t,valign:s,className:r}){return n.jsx("div",{className:Pi("ui-toolbar",r),"data-align":t,"data-valign":s,children:e})}function sn(){return n.jsx("span",{className:"ui-toolbar-spacer"})}function te({label:e,hint:t,inline:s,grow:r,wide:i,group:a,action:l,after:o,children:c}){const u=h.useId();return n.jsxs("div",{className:"ui-field","data-inline":s?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[l?n.jsxs("div",{className:"ui-field-row",children:[n.jsxs("label",{className:"ui-field-control",children:[n.jsx("span",{className:"ui-field-label",children:e}),c]}),l]}):a?n.jsxs("div",{className:"ui-field-control",role:"group","aria-labelledby":u,children:[n.jsx("span",{className:"ui-field-label",id:u,children:e}),c]}):n.jsxs("label",{className:"ui-field-control",children:[n.jsx("span",{className:"ui-field-label",children:e}),c]}),t?n.jsx("span",{className:"ui-field-hint",children:t}):null,o]})}function sr({children:e,dense:t,columns:s}){return n.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,"data-columns":s===3?"3":void 0,children:e})}function xe({tone:e,mono:t,dot:s,children:r,className:i,title:a}){return n.jsxs("span",{className:Pi("ui-pill",t&&"mono",i),"data-tone":e,title:a,children:[s?n.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function fi({children:e}){return n.jsx("span",{className:"ui-tag",children:e})}function Pd({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 n.jsx(xe,{tone:t,children:e})}function H({tone:e,title:t,children:s,role:r,action:i}){return i?n.jsx("div",{className:"ui-notice","data-tone":e,role:r,children:n.jsxs("div",{className:"ui-notice-row",children:[n.jsxs("div",{className:"ui-notice-body",children:[t?n.jsx("div",{className:"ui-notice-title",children:t}):null,s]}),i]})}):n.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?n.jsx("div",{className:"ui-notice-title",children:t}):null,s]})}function ne({message:e}){return e?n.jsx(H,{tone:"critical",role:"alert",children:e}):null}function oe({mascot:e,warm:t,title:s,action:r,children:i}){return t||s?n.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[s?n.jsx("div",{className:"ui-empty-title",children:s}):null,n.jsx("div",{children:i}),r]}):e?n.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[n.jsx(NN,{size:"sm"}),n.jsx("p",{children:i})]}):n.jsx("p",{className:"ui-empty",children:i})}function Ut({icon:e,title:t,action:s,children:r}){return n.jsxs("div",{className:"ui-empty-state",children:[e?n.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?n.jsx(Se,{name:e}):e}):null,n.jsx("div",{className:"ui-empty-state-title",children:t}),r?n.jsx("p",{className:"ui-empty-state-line",children:r}):null,s?n.jsx("div",{className:"ui-empty-state-action",children:s}):null]})}function e_({children:e}){return n.jsx("div",{className:"ui-page",children:e})}function Md({title:e,lede:t,actions:s,before:r}){return n.jsxs("header",{className:"ui-page-head",children:[n.jsxs("div",{className:"ui-page-head-row",children:[n.jsxs("h2",{className:"ui-page-title",children:[r,n.jsx("span",{children:e})]}),s?n.jsx("div",{className:"ui-page-actions",children:s}):null]}),t?n.jsx("p",{className:"ui-page-lede",children:t}):null]})}function mn({embedded:e,title:t,lede:s,actions:r,children:i}){return e?n.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?n.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):n.jsxs(e_,{children:[n.jsx(Md,{title:t,lede:s,actions:r}),i]})}function J({title:e,aside:t,actions:s,panel:r,flush:i,foot:a,children:l}){const o=e||t||s?n.jsxs("div",{className:"ui-section-head",children:[e?n.jsx("h3",{className:"ui-section-title",children:e}):n.jsx("span",{}),t||s?n.jsxs("div",{className:"ui-section-side",children:[t?n.jsx("span",{className:"ui-section-aside",children:t}):null,s?n.jsx("div",{className:"ui-section-actions",children:s}):null]}):null]}):null;return n.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[o,r?n.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[l,a?n.jsx("div",{className:"ui-panel-foot",children:a}):null]}):n.jsxs(n.Fragment,{children:[l,a?n.jsx("div",{className:"ui-toolbar","data-align":"end",children:a}):null]})]})}function Ze({title:e,tool:t,actions:s,flush:r,children:i}){return n.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||s?n.jsxs("header",{className:"ui-panel-head",children:[e?n.jsx("h3",{className:"ui-panel-title",children:e}):n.jsx("span",{}),t?n.jsx("span",{className:"ui-panel-tool",children:t}):null,s?n.jsx("div",{className:"ui-panel-actions",children:s}):null]}):null,i]})}function On({tone:e,title:t,meta:s,actions:r,children:i,foot:a,onClick:l,label:o,as:c="div"}){const u=l?{"data-interactive":"true",tabIndex:0,"aria-label":o,onClick:l,onKeyDown:f=>{f.target!==f.currentTarget||f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),l())}}:{};return n.jsxs(c,{className:"ui-card","data-tone":e,...u,children:[t||s||r?n.jsxs("div",{className:"ui-card-head",children:[t?n.jsx("h3",{className:"ui-card-title",children:t}):null,s,r?n.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,a?n.jsx("div",{className:"ui-card-foot",children:a}):null]})}function q({gap:e,divided:t,children:s}){return n.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:s})}function t_({children:e}){return n.jsx("div",{className:"ui-row",children:e})}function $d({inline:e,children:t}){return n.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function Es({label:e,value:t,note:s,tone:r,size:i}){return n.jsxs("div",{className:"ui-stat",children:[n.jsx("div",{className:"ui-stat-k",children:e}),n.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),s?n.jsx("div",{className:"ui-stat-n",children:s}):null]})}function Kt({items:e}){return n.jsx("dl",{className:"ui-kv",children:e.map((t,s)=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:t.value})]},t.key??s))})}function Nn({children:e}){return n.jsx("div",{className:"ui-table-wrap",children:n.jsx("table",{className:"ui-table",children:e})})}function LN({value:e,label:t}){const s=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return n.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s,"aria-valuetext":`${s}%`,children:n.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${s}%`}})})}function Nt({children:e,label:t}){return n.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function Tt({summary:e,boxed:t,open:s,className:r,onToggle:i,children:a}){return n.jsxs("details",{className:Pi("ui-details",r),"data-boxed":t?"true":void 0,open:s,onToggle:i?l=>i(l.currentTarget.open):void 0,children:[n.jsx("summary",{children:e}),a]})}function Dt({title:e,onClose:t,size:s,foot:r,children:i}){return n.jsx(rx,{open:!0,onOpenChange:a=>{a||t()},children:n.jsxs(ix,{children:[n.jsx(MN,{className:"ui-sheet-overlay"}),n.jsxs(ax,{className:"ui-sheet","data-size":s,"aria-describedby":void 0,children:[n.jsxs("div",{className:"ui-sheet-head",children:[n.jsx(lx,{className:"ui-sheet-title",children:e}),n.jsx(DN,{asChild:!0,children:n.jsx(I,{size:"sm",children:"Close"})})]}),i,r?n.jsx("div",{className:"ui-sheet-foot",children:r}):null]})]})})}function Ay({title:e,onClose:t,foot:s,children:r}){return n.jsx(rx,{open:!0,onOpenChange:i=>{i||t()},children:n.jsxs(ix,{children:[n.jsx(MN,{className:"ui-sheet-overlay","data-layer":"modal"}),n.jsxs(ax,{className:"ui-modal",role:"alertdialog","aria-describedby":void 0,children:[n.jsx(lx,{className:"ui-modal-title",children:e}),r,s?n.jsx("div",{className:"ui-modal-foot",children:s}):null]})]})})}function n_({label:e,items:t}){const s=i=>i.stopPropagation(),r=h.useRef(!1);return n.jsxs(Sd,{modal:!1,onOpenChange:i=>{i&&(r.current=!1)},children:[n.jsx(Nd,{asChild:!0,children:n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":e,title:e,onClick:s,children:n.jsx(Se,{name:"more"})})}),n.jsx(So,{children:n.jsx(Cd,{className:"ui-menu",align:"end",sideOffset:4,onClick:s,onKeyDown:s,onCloseAutoFocus:i=>{r.current&&i.preventDefault()},children:t.map((i,a)=>i?i==="separator"?n.jsx(xr,{className:"ui-menu-sep"},`sep-${a}`):n.jsxs(hi,{className:"ui-menu-item","data-tone":i.tone,onSelect:()=>{r.current=!0,i.onSelect()},children:[n.jsx("span",{children:i.label}),i.hint?n.jsx("span",{className:"ui-menu-item-hint",children:i.hint}):null]},a):null)})})]})}function s_({title:e,actions:t,onClose:s,onCloseAutoFocus:r,onOpenAutoFocus:i,label:a,children:l}){return n.jsx(rx,{open:!0,modal:!1,onOpenChange:o=>{o||s()},children:n.jsx(ix,{children:n.jsxs(ax,{className:"ui-dock","aria-describedby":void 0,...a?{"aria-label":a}:{},onInteractOutside:o=>o.preventDefault(),...r?{onCloseAutoFocus:r}:{},...i?{onOpenAutoFocus:i}:{},children:[n.jsxs("div",{className:"ui-dock-head",children:[n.jsx(lx,{className:"ui-dock-title",children:e}),n.jsxs("div",{className:"ui-dock-actions",children:[t,n.jsx(DN,{asChild:!0,children:n.jsx(I,{size:"sm",variant:"ghost",children:"Close"})})]})]}),n.jsx("div",{className:"ui-dock-body",children:l})]})})})}function Ao({level:e,label:t,children:s}){return n.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:s})}function Ra({href:e,active:t,count:s,onClick:r,children:i}){return n.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,s?n.jsx("span",{className:"ui-count",children:s}):null]})}function Ys({label:e,options:t,value:s,onChange:r}){return n.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>n.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===s,onClick:()=>r(i.value),children:i.label},i.value))})}function Ct({children:e}){return n.jsx("div",{className:"ui-list",children:e})}function Et({href:e,onClick:t,lead:s,title:r,sub:i,side:a,dimmed:l,label:o}){const c=n.jsxs(n.Fragment,{children:[s,n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:r}),i?n.jsx("span",{className:"ui-list-sub",children:i}):null]}),a?n.jsx("span",{className:"ui-list-side",children:a}):null]}),u=l?"true":void 0;return e?n.jsx("a",{className:"ui-list-row","data-dimmed":u,href:e,onClick:t?f=>{f.preventDefault(),t()}:void 0,children:c}):t?n.jsx("div",{className:"ui-list-row","data-interactive":"true","data-dimmed":u,tabIndex:0,"aria-label":o,onClick:t,onKeyDown:f=>{f.target!==f.currentTarget||f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),t())},children:c}):n.jsx("div",{className:"ui-list-row","data-dimmed":u,children:c})}function FN({href:e,onClick:t,current:s,lead:r,title:i,meta:a,sub:l,snippet:o,side:c}){return n.jsxs("a",{className:"ui-pick",href:e,"aria-current":s?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?n.jsx("span",{className:"ui-pick-lead",children:r}):null,n.jsxs("span",{className:"ui-pick-main",children:[n.jsxs("span",{className:"ui-pick-top",children:[n.jsx("span",{className:"ui-pick-title",children:i}),a?n.jsx("span",{className:"ui-pick-meta",children:a}):null]}),l||c?n.jsxs("span",{className:"ui-pick-line",children:[l?n.jsx("span",{className:"ui-pick-sub",children:l}):null,c?n.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,o?n.jsx("span",{className:"ui-pick-snippet",children:o}):null]})]})}function UN({list:e,detail:t,empty:s,label:r,className:i}){return n.jsxs("div",{className:Pi("ui-split",i),"data-open":t?"true":void 0,children:[n.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),n.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??n.jsx("p",{className:"ui-empty ui-split-empty",children:s})})]})}function Pu({children:e,onRemove:t,label:s,disabled:r}){return n.jsxs("span",{className:"ui-chip",children:[e,n.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${s}`,onClick:t,disabled:r,children:"×"})]})}const r_=8;function i_({label:e,options:t,value:s,onChange:r,max:i,disabled:a,id:l}){const[o,c]=h.useState(!1),[u,f]=h.useState(""),[d,m]=h.useState(0),p=h.useRef(null),v=h.useRef(null),w=h.useRef(null),k=h.useRef(null),g=h.useId(),x=T=>{var $;return(($=t.find(_=>_.value===T))==null?void 0:$.label)??T},y=i!==void 0&&s.length>=i,j=t.filter(T=>!s.includes(T.value)),N=t.length>r_,b=u.trim().toLowerCase(),S=b===""?j:j.filter(T=>T.label.toLowerCase().includes(b)),C=Math.min(d,Math.max(0,S.length-1)),R=T=>{var $;c(!1),f(""),m(0),T&&(($=v.current)==null||$.focus())};h.useEffect(()=>{var $;if(!o)return;($=N?w.current:k.current)==null||$.focus();const T=_=>{p.current&&!p.current.contains(_.target)&&R(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[o,N]);const E=T=>{const $=[...s,T];r($),f(""),m(0);const _=i!==void 0&&$.length>=i;(_||$.length>=t.length)&&R(!_)},P=T=>{if(T.key==="Escape")T.preventDefault(),R(!0);else if(T.key==="ArrowDown")T.preventDefault(),m(S.length===0?0:(C+1)%S.length);else if(T.key==="ArrowUp")T.preventDefault(),m(S.length===0?0:(C-1+S.length)%S.length);else if(T.key==="Enter"){T.preventDefault();const $=S[C];$&&E($.value)}else T.key==="Backspace"&&u===""&&s.length>0&&(T.preventDefault(),r(s.slice(0,-1)))},F=T=>`${g}-${T}`,M=o&&S.length>0?F(C):void 0;return n.jsxs("div",{className:"ui-chippicker",ref:p,id:l,children:[s.map(T=>n.jsx(Pu,{label:x(T),disabled:a,onRemove:()=>r(s.filter($=>$!==T)),children:x(T)},T)),n.jsxs("div",{className:"ui-chippicker-add",children:[n.jsx("button",{ref:v,type:"button",className:"ui-btn","data-size":"sm","data-variant":"ghost","aria-haspopup":"listbox","aria-expanded":o,"aria-controls":o?g:void 0,disabled:a||y||j.length===0,onClick:()=>o?R(!1):c(!0),children:"Add…"}),o?n.jsxs("div",{className:"ui-menu ui-chippicker-menu",onKeyDown:P,children:[N?n.jsx("input",{ref:w,type:"search",className:"ui-chippicker-filter","aria-label":`Filter ${e}`,"aria-controls":g,"aria-activedescendant":M,value:u,onChange:T=>{f(T.target.value),m(0)}}):null,n.jsxs("div",{ref:k,id:g,role:"listbox","aria-multiselectable":"true","aria-label":e,"aria-activedescendant":N?void 0:M,tabIndex:N?-1:0,className:"ui-chippicker-list",children:[S.map((T,$)=>n.jsx("div",{id:F($),role:"option","aria-selected":"false",className:"ui-menu-item","data-highlighted":$===C?"":void 0,onMouseEnter:()=>m($),onMouseDown:_=>_.preventDefault(),onClick:()=>E(T.value),children:T.label},T.value)),S.length===0?n.jsx("p",{className:"ui-menu-empty",children:"Nothing matches"}):null]})]}):null]})]})}function a_({label:e,options:t,value:s,onChange:r}){return n.jsx("div",{className:"ui-filter-chips",role:"group","aria-label":e,children:t.map(i=>n.jsx("button",{type:"button",className:"ui-btn ui-filter-chip","data-size":"sm","aria-pressed":i.value===s,onClick:()=>r(i.value),children:i.label},i.value))})}function BN({label:e,value:t,onChange:s,placeholder:r,grow:i}){return n.jsx("span",{className:"ui-search","data-grow":i?"true":void 0,children:n.jsx("input",{type:"search","aria-label":e,value:t,placeholder:r,onChange:a=>s(a.target.value)})})}function Dd({svg:e,icon:t="plug",size:s}){return n.jsx("span",{className:"ui-app-icon","data-size":s,"data-tone":e?"accent":void 0,"aria-hidden":"true",children:e?n.jsx("span",{className:"ui-app-icon-svg",dangerouslySetInnerHTML:{__html:e}}):n.jsx(Se,{name:t})})}function zN({items:e,label:t="Where this is",inline:s}){const r=e.map((i,a)=>{const l=i.key??String(a);if(i.current)return n.jsx("span",{className:"ui-crumb","aria-current":"page",children:i.label},l);const o=i.href?n.jsx("a",{className:"ui-crumb",href:i.href,onClick:i.onClick?c=>{var u;c.preventDefault(),(u=i.onClick)==null||u.call(i)}:void 0,children:i.label}):n.jsx("button",{type:"button",className:"ui-crumb",onClick:i.onClick,children:i.label});return n.jsxs("span",{className:"ui-crumb-step",children:[o,n.jsx(Se,{name:"chevron-right",size:12})]},l)});return s?n.jsx("span",{className:"ui-crumbs","aria-label":t,children:r}):n.jsx("nav",{className:"ui-crumbs","aria-label":t,children:r})}function WN({main:e,filters:t,filtersOpen:s,onToggleFilters:r,active:i,chips:a,actions:l,onSubmit:o,label:c}){return n.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),o()},children:[n.jsxs("div",{className:"ui-searchbar-row",children:[e?n.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?n.jsxs(I,{"aria-expanded":s===!0,"aria-pressed":s===!0,onClick:r,children:["Filters",i?n.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?n.jsx("div",{className:"ui-searchbar-inline",children:t}):null,l?n.jsx("div",{className:"ui-searchbar-actions",children:l}):null]}),t&&r&&s?n.jsx("div",{className:"ui-searchbar-filters",children:t}):null,a?n.jsx("div",{className:"ui-searchbar-chips",children:a}):null]})}function HN({size:e}){return n.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function l_({quiet:e,still:t,className:s,children:r}){return n.jsx("div",{className:Pi("ui-fieldbg",s),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function o_(e){const t={};for(const s of e??[])t[s.key]=s.default;return t}function cx(e){const[t,s]=h.useState({}),r=e??[],i={...o_(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:n.jsx("div",{className:"ui-choices",children:r.map(a=>n.jsx(te,{label:a.label,inline:!0,children:n.jsx("select",{value:i[a.key],onChange:l=>s(o=>({...o,[a.key]:l.target.value})),children:a.options.map(l=>n.jsx("option",{value:l,children:l},l))})},a.key))})}}function c_({props:e,timezone:t="UTC",onDecided:s}){var x;const[r,i]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(!1),[u,f]=h.useState(null);h.useEffect(()=>{let y=!1;return i(null),l(null),A.approval(e.approvalId).then(j=>{y||i(j)}).catch(j=>{y||l(j instanceof he?j.message:String(j))}),()=>{y=!0}},[e.approvalId]);const{values:d,controls:m}=cx(r==null?void 0:r.choices),p=(y,j)=>{f(y),l(null),(d&&y==="approve"?A.decide(e.approvalId,y,j,d):A.decide(e.approvalId,y,j)).then(N=>{i(N.action),s==null||s(N.action)}).catch(N=>l(N instanceof he?N.message:String(N))).finally(()=>f(null))};if(a&&!r)return n.jsx("p",{className:"wb-empty",children:a});if(!r)return n.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const v=r.state==="pending",w=(x=r.permissionScopes)==null?void 0:x.includes("always"),k=u_(r),g=(r.preview??"").split(`
94
- `).length>12||(r.preview??"").length>900;return n.jsxs("div",{children:[n.jsxs("div",{className:"ui-stats","data-inline":"true",children:[n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:"Tool"}),n.jsx("div",{className:"ui-stat-v mono",children:r.tool})]}),n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:"State"}),n.jsx("div",{className:"ui-stat-v","data-tone":d_(r.state),children:r.state})]}),n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:v?"Expires":"Decided"}),n.jsx("div",{className:"ui-stat-v","data-size":"sm",children:Ve(v?r.expiresAt:r.decidedAt,t)})]})]}),n.jsx(ne,{message:a}),v?m:null,v?n.jsxs("div",{className:"wb-row-wrap wb-block",children:[n.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>p("approve"),children:u==="approve"?"Approving…":w?"Allow once":"Approve"}),w?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>p("approve","conversation"),children:"Auto: this conversation"}),n.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>p("approve","always"),children:"Always: this agent"})]}):null,n.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>p("reject"),children:u==="reject"?"Rejecting…":"Reject"}),n.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."})]}):n.jsxs("p",{className:"muted",children:[r.state," ",r.decidedBy?`by ${r.decidedBy}`:""," ",r.decidedVia?`via ${r.decidedVia}`:""]}),n.jsx("h4",{className:"ui-stat-k wb-label",children:"Preview"}),n.jsxs("div",{className:"wb-doc wb-block","data-clamp":g&&!o?"true":void 0,children:[r.preview||"(this tool wrote no preview)",g&&!o?n.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]}),n.jsxs("details",{className:"ui-details wb-block",children:[n.jsx("summary",{children:"The envelope, field by field"}),n.jsx("dl",{className:"ui-kv",children:k.map(y=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:y.label}),n.jsx("dd",{className:y.mono?"mono":void 0,children:y.value})]},y.label))})]})]})}function u_(e){const t=[],s=e.envelope;if(s!==null&&typeof s=="object"&&!Array.isArray(s))for(const[i,a]of Object.entries(s))t.push({label:un(i),value:qc(a)});else s!=null&&t.push({label:"Envelope",value:qc(s)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,a]of Object.entries(r)){const l=`Argument · ${un(i)}`;t.some(o=>o.label===l)||t.push({label:l,value:qc(a)})}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 qc(e){return e==null?"—":Array.isArray(e)?e.map(t=>qc(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):$t(e,"text",null)}function d_(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const h_=new Set(["image/png","image/jpeg","image/gif","image/webp"]),f_=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Mu(e){const t=e!==null&&typeof e=="object"?e.artifacts:null;return Array.isArray(t)?t.flatMap(s=>{if(s===null||typeof s!="object")return[];const r=s;return typeof r.id!="string"||!f_.test(r.id)?[]:[{type:"attachment",artifactId:r.id,filename:typeof r.filename=="string"?r.filename:null,mime:typeof r.mime=="string"?r.mime:"application/octet-stream",kind:typeof r.kind=="string"?r.kind:"other",sizeBytes:null}]}):[]}function ux(e){return h_.has(e.toLowerCase())}function rr(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function Lr(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function Cn(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 dx(e,t){const s=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return s.startsWith("image/")?"image":s==="application/pdf"?"pdf":s.startsWith("audio/")?"audio":s.startsWith("video/")?"video":s==="text/csv"||s==="text/tab-separated-values"||s.includes("spreadsheet")||s.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":s.includes("zip")||s.includes("tar")||s.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":s==="application/json"||s.includes("javascript")||s.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":s.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const mi={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function Qc(e){return`artifact:${e}`}function m_(e){const t=dx(e.mime,e.filename);return{id:Qc(e.artifactId),tool:mi[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function p_({props:e}){const t=EN(e.artifactId),[s,r]=h.useState(null),[i,a]=h.useState(null),[l,o]=h.useState(!1);if(h.useEffect(()=>{if(t===null)return;let f=!0;return r(null),a(null),o(!1),A.libraryEntry(t).then(d=>{f&&r({filename:d.entry.filename,sizeBytes:d.entry.sizeBytes})}).catch(()=>{}),()=>{f=!1}},[t]),t===null)return n.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(s==null?void 0:s.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,s!=null&&s.sizeBytes?Cn(s.sizeBytes):null].filter(f=>f!==null);return n.jsxs("figure",{className:"wb-image",children:[n.jsx("div",{className:"wb-image-frame",children:l?n.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):n.jsx("a",{href:rr(t),className:"wb-image-link",title:"Open at full size",children:n.jsx("img",{src:rr(t),alt:e.caption??c,onLoad:f=>{const d=f.currentTarget;d.naturalWidth>0&&a({width:d.naturalWidth,height:d.naturalHeight})},onError:()=>o(!0)})})}),n.jsxs("figcaption",{className:"wb-image-caption",children:[n.jsxs(Q,{children:[n.jsx("span",{className:"wb-image-name",children:c}),u.length>0?n.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(Yt,{size:"sm",href:Lr(t),download:(s==null?void 0:s.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?n.jsx(Tt,{summary:e.captionLabel,className:"wb-image-note",children:n.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?n.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function g_({props:e}){return e.pairs.length===0?n.jsx("p",{className:"wb-empty",children:"Nothing to show."}):n.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:$t(t.value,t.unit,t.currency)})]},t.label))})}const x_=8;function VN({text:e,label:t="Output",className:s}){const r=h.useRef(null),i=h.useRef(!0);return h.useLayoutEffect(()=>{const a=r.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[e]),n.jsx("pre",{ref:r,className:s?`wb-terminal-body ${s}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:a=>{const l=a.currentTarget;i.current=l.scrollHeight-l.scrollTop-l.clientHeight<=x_},children:e})}function v_(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 s=Math.floor(t/60);return`${s} min ${Math.round(t-s*60)} s`}function j_({text:e}){const[t,s]=h.useState("");return n.jsxs(n.Fragment,{children:[t?n.jsx("span",{role:"status",className:"wb-hint",children:t}):null,n.jsx(I,{size:"sm",onClick:()=>{var r;if(s(""),!((r=navigator.clipboard)!=null&&r.writeText)){s("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>s("Copied"),()=>s("Copy failed; select the text to copy."))},children:"Copy"})]})}function y_({props:e}){const t=e.output??"";return n.jsxs("div",{className:"wb-terminal",children:[n.jsxs(Q,{className:"wb-terminal-head",children:[e.command!==null?n.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?n.jsxs(xe,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?n.jsx("span",{className:"wb-terminal-fact",children:v_(e.elapsedMs)}):null,n.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?n.jsx(j_,{text:t}):null]}),e.omittedBytes!==null?n.jsxs("p",{className:"wb-terminal-note",children:["First ",Cn(e.omittedBytes)," not shown."]}):null,t!==""?n.jsx(VN,{text:t}):n.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(s=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:s.label}),n.jsx("dd",{children:$t(s.value,s.unit,null)})]},s.label))}):null]})}function w_(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function Ty(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function b_(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((s,r)=>s-r)}function k_({props:e}){var N;const[t,s]=h.useState(null),[r,i]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(!1),u=((N=e.target)==null?void 0:N.plugin)??null,f=b_(e),[d,m]=h.useState(null),p=d!==null&&f.includes(d)?d:e.port,v=e.target?p!==null&&p!==e.port?`${e.target.name}.${p}`:e.target.name:null,w=e.changes??0,k=h.useRef(w),[g,x]=h.useState(0);h.useEffect(()=>{w<=k.current||(k.current=w,e.reloadsItself||x(b=>b+1))},[w,e.reloadsItself]),h.useEffect(()=>{if(u===null||v===null)return;let b=!0;return s(null),i(null),l(null),x(0),A.previewLink(u,v).then(S=>{b&&(s(S.url),i(Ty(S.url)))}).catch(S=>{b&&l(S instanceof Error?S.message:"That preview could not be opened.")}),()=>{b=!1}},[u,v]);const y=()=>{u===null||v===null||A.previewLink(u,v).then(b=>i(b.url)).catch(()=>{})};if(e.target===null)return n.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",n.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const j=!(e.output===null||e.output==="");return n.jsxs("div",{className:"wb-preview","data-output":o||void 0,children:[n.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?n.jsx("h4",{className:"wb-doc-title",children:e.title}):null,f.length>1?n.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:p??"",onChange:b=>m(Number(b.target.value)),children:f.map(b=>n.jsxs("option",{value:b,children:[":",b]},b))}):null,j?n.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":o,onClick:()=>c(b=>!b),children:o?"Hide output":"Output"}):null,r?n.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,p!==null&&w_()?n.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${p}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",p]}):null]}),n.jsxs("div",{className:"wb-preview-body",children:[t?n.jsx("iframe",{className:"wb-preview-frame",src:g===0?t:Ty(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},g):n.jsx("p",{className:"wb-empty wb-preview-frame",children:a??"Opening the preview…"}),j&&o?n.jsx(VN,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const S_=50,N_=9,C_=24,E_=.6,A_=48,T_=/(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,R_=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,I_=/^id$|(^|[a-z0-9])Id$|_id$/;function oa(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Pn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function KN(...e){for(const t of e)if(Pn(t))for(const s of["currency","currencyCode"]){const r=t[s];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function GN(e,t,s){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))?s!==null&&T_.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&R_.test(i))?"date":"text"}function P_(e,t){if(!I_.test(e))return!1;const s=t.filter(r=>!Ka(r));return s.length<2?!1:new Set(s.map(r=>String(r))).size===s.length}function Ka(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:Pn(e)?Object.keys(e).length===0:!1}function Ry(e,t){const s=e.filter(Pn);if(s.length===0||s.length/e.length<.8)return null;const r=s.slice(0,S_),i=new Map,a=[];for(const f of r)for(const d of Object.keys(f))i.has(d)||a.push(d),i.set(d,(i.get(d)??0)+1);if(i.size===0||i.size>C_||[...i.values()].reduce((f,d)=>f+d,0)/(i.size*r.length)<E_)return null;const o=[...i.keys()].sort((f,d)=>{const m=(i.get(d)??0)-(i.get(f)??0);return m!==0?m:a.indexOf(f)-a.indexOf(d)}),c=[],u=[];for(const f of o){const d=r.map(w=>w[f]),m=d.filter(w=>!Ka(w));if(m.length===0||P_(f,d))continue;const p=KN(r[0],t),v=GN(f,d,p);if(r.length>=4&&m.length===d.length&&d.every(w=>oa(w)&&w===d[0])){u.push({label:un(f),value:d[0],type:v,currency:p});continue}if(c.push({key:f,label:un(f),type:v,currency:v==="currency"?p:null}),c.length===N_)break}return c.length===0?null:{columns:c,rows:s,constants:u}}function M_(e,t,s){const r=KN(s);return{label:un(e),value:t,type:GN(e,[t],r),currency:r}}function YN(e){return typeof e=="string"&&e.length>A_}function $_(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.":Pn(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function _m(e){if(typeof e=="string"&&e.trim()!=="")return e;if(Pn(e))for(const t of["message","error","reason","detail","description"]){const s=e[t];if(typeof s=="string"&&s.trim()!=="")return s;if(Pn(s)){const r=_m(s);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function hx(e,t={}){if(t.failed){let d=e;if(typeof e=="string")try{const m=JSON.parse(e.replace(/^tool-error:\s*/,""));Pn(m)&&(d=m)}catch{}return{kind:"error",summary:_m(d),detail:Iy(d)}}if(Pn(e)){const d=e.error,m=e.ok;if(typeof d=="string"&&d.trim()!==""||m===!1)return{kind:"error",summary:_m(e),detail:Iy(e)}}const s=$_(e);if(s)return{kind:"empty",note:s,stats:[]};if(Array.isArray(e)){const d=Ry(e,e);return d?{kind:"table",label:null,columns:d.columns,rows:d.rows,total:d.rows.length,stats:d.constants,notes:[],asides:[]}:e.every(oa)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!Pn(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,a=null;for(const[d,m]of r){if(!Array.isArray(m))continue;const p=Ry(m,e);if(p){(!i||p.rows.length>i.candidate.rows.length)&&(i={key:d,candidate:p});continue}m.length>0&&m.every(oa)&&(!a||m.length>a.items.length)&&(a={key:d,items:m})}const l=(i==null?void 0:i.key)??(a==null?void 0:a.key)??null,o=[],c=[],u=[];for(const[d,m]of r)if(d!==l){if(YN(m)){c.push(m);continue}if(oa(m)){if(m==="")continue;o.push(M_(d,m,e));continue}m!==void 0&&u.push({label:un(d),value:m})}if(i)return{kind:"table",label:un(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...o,...i.candidate.constants],notes:c,asides:u};if(a)return{kind:"list",label:un(a.key),items:a.items,total:a.items.length,stats:o,notes:c,asides:u};const f=r.filter(([,d])=>Array.isArray(d)&&d.length===0);return f.length>0&&f.length===r.filter(([,d])=>Array.isArray(d)).length?{kind:"empty",note:`No ${f.map(([m])=>un(m).toLowerCase()).join(", ")} to show.`,stats:o}:r.every(([,d])=>oa(d)||Pn(d)||Array.isArray(d))?{kind:"record",pairs:o,notes:c,asides:u}:{kind:"tree",value:e}}function Iy(e){if(!Pn(e))return null;const t=Object.entries(e).filter(([s])=>s!=="message"&&s!=="error");return t.length===0?null:Object.fromEntries(t)}const $u=25,D_=3,Lm=8,qN=6;function Fm(e,t=0){if(t>qN||Ka(e)||YN(e))return 0;if(oa(e))return 1;if(Array.isArray(e)){let s=0;for(const r of e)if(s+=Fm(r,t+1),s>=Lm)return s;return s}if(Pn(e)){let s=0;for(const r of Object.values(e))if(s+=Fm(r,t+1),s>=Lm)return s;return s}return 0}function Um(e,t=0){if(t>qN)return!1;if(Array.isArray(e))return e.some(a=>Um(a,t+1));if(!Pn(e))return!1;const s=e.artifactId??e.artifact_id;if(typeof s=="string"&&s.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(a=>Um(a,t+1))}function O_(e){if(Um(e))return!0;const t=hx(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=D_;case"record":case"tree":return Fm(e)>=Lm;default:return!1}}function Oh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function fx(e){const t=Oh(e);if(!t)return null;const s=Oh(t.output)??t;if(typeof s.state!="string"||typeof s.stdout!="string"||typeof s.stderr!="string"||!(s.exitCode===null||typeof s.exitCode=="number"&&Number.isFinite(s.exitCode)))return null;const r=s===t?null:Oh(t.input),i=(r==null?void 0:r.command)??s.command;return{command:typeof i=="string"?i:null,input:r,result:s}}function __({text:e,label:t}){const[s,r]=h.useState("");return n.jsxs("span",{className:"wb-command-copy",children:[n.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}),s&&n.jsx("span",{role:"status",className:"wb-hint",children:s})]})}function _h({title:e,text:t,error:s=!1}){return n.jsxs("section",{className:"wb-command-stream","data-error":s||void 0,children:[n.jsxs("div",{className:"wb-command-bar",children:[n.jsx("h4",{children:e}),n.jsx(__,{text:t,label:`Copy ${e.toLowerCase()}`})]}),n.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function L_({value:e,children:t}){const{result:s,command:r,input:i}=e,a=s.state==="completed"&&s.exitCode!==null&&s.exitCode!==0,l=typeof s.signal=="string"&&s.signal?s.signal:null,o=s.state==="completed"&&s.exitCode===0,c=Object.fromEntries(Object.entries(s).filter(([f,d])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(f)&&d!==null&&d!==void 0&&d!=="")),u=Array.isArray(s.outputErrors)?s.outputErrors.filter(f=>typeof f=="string"):[];return n.jsxs("div",{className:"wb-command-result",children:[n.jsxs("div",{className:"wb-command-bar",children:[n.jsx("span",{className:"ui-pill","data-tone":o?"good":"critical",children:a?"Failed":s.state==="completed"&&l?"Terminated":s.state}),s.exitCode!==null&&n.jsxs("span",{className:"mono",children:["Exit code ",s.exitCode]}),l&&n.jsxs("span",{className:"mono",children:["Signal ",l]}),n.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&n.jsx(_h,{title:"Command",text:r}),s.state==="output-limit"&&n.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),s.state==="timed-out"&&n.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),s.state==="cancelled"&&n.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),s.stdout?n.jsx(_h,{title:"Output",text:s.stdout}):n.jsx("p",{className:"wb-note",children:"No standard output."}),s.stderr?n.jsx(_h,{title:"Standard error",text:s.stderr,error:!0}):null,u.length>0&&n.jsxs("section",{children:[n.jsx("h4",{children:"File export errors"}),u.map((f,d)=>n.jsx("p",{className:"wb-fail",children:f},d))]}),t,(Object.keys(c).length>0||i!==null)&&n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"Execution details"}),n.jsx("pre",{children:Sn({...c,...i?{input:i}:{}})})]})]})}const xc=2,Py=64;function F_({props:e}){const[t,s]=h.useState(!1),r=fx(e.value),i=U_((r==null?void 0:r.result)??e.value),a=h.useMemo(()=>hx(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return n.jsxs("div",{children:[!r&&n.jsx(My,{files:i}),t?n.jsx("pre",{className:"ui-code",children:Sn(e.value)}):r?n.jsx(L_,{value:r,children:i.length>0&&n.jsxs("section",{children:[n.jsx("h4",{children:"Generated files"}),n.jsx(My,{files:i})]})}):i.length?n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"Tool details"}),n.jsx($y,{shape:a})]}):n.jsx($y,{shape:a}),n.jsx("div",{className:"wb-row-end wb-section",children:n.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>s(l=>!l),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function U_(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(s=>s&&typeof s.id=="string"&&/^[0-9a-f-]{36}$/i.test(s.id)&&typeof s.filename=="string"):[]}function My({files:e}){return e.length?n.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var s;return n.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?n.jsx(B_,{file:t}):null,n.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(s=t.mime)!=null&&s.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function B_({file:e}){const[t,s]=h.useState(!1);return t?n.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):n.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>s(!0)})}function $y({shape:e}){switch(e.kind){case"error":return n.jsxs("div",{children:[n.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"What came back with it"}),n.jsx("div",{className:"wb-tree",children:oo(e.detail,1)})]})]});case"empty":return n.jsxs("div",{children:[n.jsx(Lh,{stats:e.stats}),n.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=G_(e.columns,e.rows);return n.jsxs("div",{children:[n.jsx(Lh,{stats:e.stats}),n.jsx(Fh,{notes:e.notes}),t?n.jsx(Y_,{label:e.label,plan:t,rows:e.rows,total:e.total}):n.jsx(W_,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),n.jsx(Uh,{asides:e.asides})]})}case"list":return n.jsxs("div",{children:[n.jsx(Lh,{stats:e.stats}),n.jsx(Fh,{notes:e.notes}),e.label?n.jsx("h4",{className:"wb-sub",children:e.label}):null,n.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,s)=>n.jsx("li",{children:$t(t,"text",null)},s))}),e.total>100?n.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,n.jsx(Uh,{asides:e.asides})]});case"record":return n.jsxs("div",{children:[n.jsx(Fh,{notes:e.notes}),n.jsx(z_,{pairs:e.pairs}),n.jsx(Uh,{asides:e.asides})]});default:return n.jsx("div",{className:"wb-tree",children:oo(e.value,0)})}}function Lh({stats:e}){return e.length===0?null:n.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:t.label}),n.jsx("div",{className:"ui-stat-v",children:mx(t.value,t.type,t.currency)})]},t.label))})}const Dy=200;function Fh({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=Dy),s=e.filter(r=>r.length>Dy);return n.jsxs(n.Fragment,{children:[t.map(r=>n.jsx("p",{className:"wb-note",children:r},r)),s.length>0?n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:s.length===1?"A note that came with this result":`${s.length} notes that came with this result`}),s.map(r=>n.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function z_({pairs:e}){return e.length===0?n.jsx("p",{className:"wb-note",children:"Nothing to show."}):n.jsx("dl",{className:"ui-kv",children:e.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:mx(t.value,t.type,t.currency)})]},t.label))})}function Uh({asides:e}){return e.length===0?null:n.jsx("div",{className:"wb-section",children:e.map(t=>n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:t.label}),n.jsx("div",{className:"wb-tree",children:oo(t.value,1)})]},t.label))})}function W_({label:e,columns:t,rows:s,total:r}){const[i,a]=h.useState(!1),l=r<=$u+5?r:$u,o=i?s:s.slice(0,l);return n.jsxs("div",{children:[e?n.jsx("h4",{className:"wb-sub",children:e}):null,n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(c=>n.jsx("th",{className:JN(c.type)?"num":void 0,children:c.label},c.key))})}),n.jsx("tbody",{children:o.map((c,u)=>n.jsx("tr",{children:t.map(f=>n.jsx(q_,{value:c[f.key],column:f},f.key))},u))})]})}),r>o.length?n.jsxs("p",{className:"wb-note wb-note-row",children:[n.jsxs("span",{children:["Showing ",o.length," of ",r]}),n.jsxs("button",{className:"ui-btn",onClick:()=>a(!0),children:["Show all ",r]})]}):null]})}const H_=/^(title|name|headline|subject|label|heading)$/i,V_=/^(url|link|href|uri|permalink)$/i;function Du(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function K_(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function QN(e,t=48){try{const s=new URL(e),r=s.pathname==="/"?"":s.pathname,i=`${s.hostname.replace(/^www\./,"")}${r}${s.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function vc(e,t){const s=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return s.length===0?0:s.reduce((r,i)=>r+i.length,0)/s.length}function G_(e,t){if(t.length===0)return null;const s=e.filter(f=>f.type==="text"),r=s.find(f=>V_.test(f.key)&&t.some(d=>Du(d[f.key])))??s.find(f=>{const d=t.map(m=>m[f.key]).filter(m=>!Ka(m));return d.length>0&&d.filter(Du).length/d.length>=.6});if(!r)return null;const i=s.filter(f=>f.key!==r.key),a=i.find(f=>H_.test(f.key))??i.find(f=>vc(t,f.key)>0);if(!a)return null;const o=[...i.filter(f=>f.key!==a.key)].sort((f,d)=>vc(t,d.key)-vc(t,f.key)),c=o[0]&&vc(t,o[0].key)>40?o[0]:null,u=e.filter(f=>f.key!==r.key&&f.key!==a.key&&f.key!==(c==null?void 0:c.key)).map(f=>f.key);return{url:r.key,title:a.key,description:(c==null?void 0:c.key)??null,meta:u}}function Y_({label:e,plan:t,rows:s,total:r}){const[i,a]=h.useState(!1),l=r<=$u+5?r:$u,o=i?s:s.slice(0,l);return n.jsxs("div",{children:[e?n.jsx("h4",{className:"wb-sub",children:e}):null,n.jsx("ol",{className:"wb-records",children:o.map((c,u)=>{const f=c[t.url],d=Du(f)?f.trim():null,m=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:d?QN(d):"Untitled",p=t.description&&typeof c[t.description]=="string"?c[t.description]:null,v=d?K_(d):null,w=t.meta.map(k=>c[k]).filter(k=>!Ka(k)&&typeof k!="object").map(k=>String(k)).filter(k=>v===null||k.replace(/^www\./,"")!==v);return n.jsxs("li",{className:"wb-record",children:[d?n.jsx("a",{className:"wb-record-title",href:d,target:"_blank",rel:"noopener noreferrer",children:m}):n.jsx("span",{className:"wb-record-title",children:m}),n.jsxs("div",{className:"wb-record-meta",children:[v?n.jsx("span",{className:"wb-record-host",title:d??void 0,children:v}):null,w.map((k,g)=>n.jsx("span",{children:k.length>60?`${k.slice(0,59)}…`:k},g))]}),p?n.jsx("p",{className:"wb-record-desc",children:p.length>280?`${p.slice(0,279)}…`:p}):null]},u)})}),r>o.length?n.jsxs("p",{className:"wb-note wb-note-row",children:[n.jsxs("span",{children:["Showing ",o.length," of ",r]}),n.jsxs("button",{className:"ui-btn",onClick:()=>a(!0),children:["Show all ",r]})]}):null]})}function q_({value:e,column:t}){if(Ka(e))return n.jsx("td",{className:"wb-cell-soft",children:"—"});if(Du(e)){const i=e.trim();return n.jsx("td",{className:"wb-cell-link",children:n.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:QN(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 n.jsx("td",{className:"wb-cell-soft",title:Sn(e),children:i})}const s=mx(e,t.type,t.currency),r=s.length>Py?`${s.slice(0,Py-1)}…`:s;return n.jsx("td",{className:JN(t.type)?"num":"wb-cell-text",...r===s?{}:{title:s},children:r})}function JN(e){return e==="number"||e==="currency"}function mx(e,t,s){return e==null?"—":t==="boolean"?e?"yes":"no":$t(e,t==="text"?"text":t,s)}function oo(e,t){if(e===null)return n.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return n.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return n.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return n.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return n.jsx("span",{children:e===""?n.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return n.jsx("span",{className:"wb-tree-null",children:"none"});const i=n.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((a,l)=>n.jsxs("div",{children:[n.jsxs("span",{className:"wb-tree-key",children:[l,". "]}),oo(a,t+1)]},l)),e.length>50?n.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=xc?n.jsx(Oy,{summary:`${e.length} items`,open:t===xc,children:i}):i}const s=Object.entries(e);if(s.length===0)return n.jsx("span",{className:"wb-tree-null",children:"empty"});const r=n.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:s.map(([i,a])=>n.jsxs("div",{children:[n.jsxs("span",{className:"wb-tree-key",children:[un(i),": "]}),oo(a,t+1)]},i))});return t>=xc?n.jsx(Oy,{summary:`${s.length} fields`,open:t===xc,children:r}):r}function Oy({summary:e,open:t,children:s}){return n.jsxs("details",{open:t,children:[n.jsx("summary",{className:"wb-tree-key",children:e}),s]})}function Q_({props:e}){const t=e.groups.every(s=>s.rows.length===0);return n.jsxs("div",{children:[e.summary.length>0?n.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(s=>n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:s.label}),n.jsx("div",{className:"ui-stat-v","data-tone":s.tone,children:$t(s.value,s.unit,s.currency)})]},s.label))}):null,t?n.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((s,r)=>n.jsxs("div",{className:r>0?"wb-section":void 0,children:[s.label?n.jsx("h4",{className:"ui-stat-k wb-label",children:s.label}):null,n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(i=>n.jsx("th",{className:XN(i.type)?"num":void 0,"data-type":i.type,children:i.label},i.key))})}),n.jsx("tbody",{children:s.rows.map((i,a)=>n.jsx("tr",{children:i.map((l,o)=>{var c;return n.jsx(J_,{cell:l},((c=e.columns[o])==null?void 0:c.key)??o)})},a))})]})})]},s.label??r))]})}function J_({cell:e}){const t=$t(e.value,e.type,e.currency);return e.bar?n.jsx("td",{className:"num",children:n.jsxs("div",{className:"wb-row wb-row-end",children:[n.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:n.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),n.jsx("span",{className:"tnum",children:t})]})}):n.jsx("td",{className:XN(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function XN(e){return e==="number"||e==="currency"||e==="percent"}const _y={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe",sun:"sun","partly-cloudy":"partly-cloudy",cloud:"cloud",rain:"rain",drizzle:"drizzle",snow:"snow",storm:"storm",fog:"fog",wind:"wind","moon-clear":"moon-clear"};function Od(e){return(e&&Object.prototype.hasOwnProperty.call(_y,e)?_y[e]:void 0)??"dot"}function Ly(e,t){return(e??[]).filter(s=>s.place===t).map((s,r)=>({page:s,index:r})).sort((s,r)=>(s.page.order??0)-(r.page.order??0)||s.index-r.index).map(s=>s.page)}const Ou="buddi:plugin-pages-changed";function X_(){window.dispatchEvent(new Event(Ou))}function ZN(e=!1){const[t,s]=h.useState([]);return h.useEffect(()=>{if(e)return;let r=!1;const i=()=>{Promise.resolve().then(()=>A.pages()).then(l=>{r||s(Array.isArray(l==null?void 0:l.pages)?l.pages:[])}).catch(()=>{})};i();const a=()=>{document.visibilityState==="visible"&&i()};return window.addEventListener(Ou,i),document.addEventListener("visibilitychange",a),()=>{r=!0,window.removeEventListener(Ou,i),document.removeEventListener("visibilitychange",a)}},[e]),{all:t,rail:Ly(t,"rail"),settings:Ly(t,"settings"),find:(r,i)=>t.find(a=>a.plugin===r&&a.id===i)}}let Jc=null;typeof window<"u"&&window.addEventListener(Ou,()=>{Jc=null});function Z_(){return Jc??(Jc=Promise.resolve().then(()=>A.pages()).then(e=>Array.isArray(e==null?void 0:e.pages)?e.pages:[]).catch(()=>(Jc=null,[]))),Jc}function e1(e,t,s){return s==="settings"?No(e,t):_r(e,t)}function eL(e){const[t,s]=h.useState(null),r=e==null?void 0:e.plugin,i=e==null?void 0:e.page;return h.useEffect(()=>{if(!r||!i)return;let a=!1;return Z_().then(l=>{const o=l.find(c=>c.plugin===r&&c.id===i);a||s(o?{href:e1(r,i,o.place),label:o.place==="settings"?`Settings → ${o.title}`:o.title}:null)}),()=>{a=!0}},[r,i]),t}function t1({props:e,layout:t,selected:s,onPick:r}){return e.tiles.length===0?n.jsx("p",{className:"wb-empty",children:e.empty}):n.jsx("ul",{className:"wb-tiles","data-notice":e.notice?"true":void 0,"data-layout":t&&t!=="grid"?t:void 0,style:t==="row"?{"--tiles-n":e.tiles.length}:void 0,children:e.tiles.map((i,a)=>n.jsx(tL,{tile:i,...r?{picked:a===s,onPick:()=>r(a)}:{}},`${a}-${i.label}`))})}function tL({tile:e,picked:t,onPick:s}){const r=eL(e.link),i=[e.label,e.value,...e.lines].filter(l=>l!=="").join(", "),a=n.jsxs("div",{className:"wb-tile-body","aria-hidden":"true",children:[n.jsx("span",{className:"wb-tile-icon","data-icon":e.icon??"dot",children:n.jsx(Se,{name:Od(e.icon),size:22})}),e.value!==""?n.jsx("span",{className:"wb-tile-value tnum",children:e.value}):null,n.jsx("span",{className:"wb-tile-label",children:e.label}),e.lines.map((l,o)=>n.jsx("span",{className:"wb-tile-line",children:l},o))]});return s?n.jsx("li",{className:"wb-tile",children:n.jsx("button",{type:"button",className:"ui-card","data-tone":t?"accent":e.tone==="neutral"?void 0:e.tone,"data-selected":t?"true":void 0,"aria-pressed":t===!0,"aria-label":i,onClick:s,children:a})}):n.jsxs("li",{className:"wb-tile",children:[n.jsx("span",{className:"sr-only",children:i}),n.jsxs(On,{tone:e.tone==="neutral"?void 0:e.tone,children:[a,r?n.jsx("a",{className:"wb-tile-link",href:r.href,children:r.label}):null]})]})}const Hi=760,Bh=400,wt={top:18,right:18,bottom:36,left:66},nL=5;function sL({props:e}){const{points:t,referenceLines:s,unit:r,currency:i}=e;if(t.length===0)return n.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const a=[...t.map(j=>j.y),...s.map(j=>j.value)],l=Math.min(...a),o=Math.max(...a),c=o-l||Math.abs(o)||1,u=l-c*.08,f=o+c*.08,d=Hi-wt.left-wt.right,m=Bh-wt.top-wt.bottom,p=j=>wt.left+(t.length===1?d/2:j/(t.length-1)*d),v=j=>wt.top+m-(j-u)/(f-u)*m,w=Ru(l,o,4),k=iL(t.map(j=>j.y),e.mark),g=e.shadeBelow===null?[]:aL(t.map(j=>j.y),e.shadeBelow),x=t.map((j,N)=>`${N===0?"M":"L"}${p(N)},${v(j.y)}`).join(" "),y=j=>$t(j,r,i);return n.jsxs("div",{children:[e.label?n.jsx("p",{className:"ui-panel-sub",children:e.label}):null,n.jsxs("div",{className:"wb-chart-layout",children:[n.jsx("div",{className:"wb-chart-plot",children:n.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${Hi} ${Bh}`,role:"img","aria-label":rL(e,y),preserveAspectRatio:"xMidYMid meet",children:[g.map(j=>n.jsx("rect",{className:"wb-chart-breach",x:p(j.from),width:Math.max(2,p(j.to)-p(j.from)),y:wt.top,height:m},`band-${j.from}`)),w.map(j=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-grid",x1:wt.left,x2:Hi-wt.right,y1:v(j),y2:v(j)}),n.jsx("text",{x:wt.left-8,y:v(j)+4,textAnchor:"end",children:y(j)})]},`tick-${j}`)),s.map(j=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-floor",x1:wt.left,x2:Hi-wt.right,y1:v(j.value),y2:v(j.value)}),n.jsxs("text",{x:Hi-wt.right,y:v(j.value)-6,textAnchor:"end",children:[j.label," ",y(j.value)]})]},`rule-${j.label}`)),n.jsx("line",{className:"wb-chart-axis",x1:wt.left,x2:wt.left,y1:wt.top,y2:wt.top+m}),n.jsx("line",{className:"wb-chart-axis",x1:wt.left,x2:Hi-wt.right,y1:wt.top+m,y2:wt.top+m}),n.jsx("path",{className:"wb-chart-series",d:x}),k!==null?n.jsxs("g",{children:[n.jsx("circle",{className:"wb-chart-min",cx:p(k),cy:v(t[k].y),r:4.5}),n.jsx("text",{x:p(k),y:v(t[k].y)+20,textAnchor:"middle",children:y(t[k].y)})]}):null,lL(t.length).map(j=>n.jsx("text",{x:p(j),y:Bh-10,textAnchor:"middle",children:Am(t[j].x)},`x-${j}`))]})}),e.events.length>0?n.jsxs("aside",{className:"wb-chart-events",children:[n.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),n.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((j,N)=>n.jsxs("li",{className:"wb-chart-event",children:[n.jsxs("span",{children:[n.jsx("span",{className:"wb-chart-event-day",children:Am(j.at)}),j.label]}),j.amount===null?null:n.jsx("span",{className:j.amount<0?"tnum critical":"tnum good",children:$t(j.amount,r,i)})]},`${j.at}-${j.label}-${N}`))})]}):null]})]})}function rL(e,t){const s=e.points.map(l=>l.y),r=e.points[0],i=e.points[e.points.length-1],a=e.referenceLines.map(l=>`${l.label} at ${t(l.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(...s))}, high ${t(Math.max(...s))}`,a].filter(Boolean).join("; ")}function iL(e,t){if(!t||e.length===0)return null;let s=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[s]:e[r]>e[s])&&(s=r);return s}function aL(e,t){const s=[];let r=null;return e.forEach((i,a)=>{i<t?r===null&&(r=a):r!==null&&(s.push({from:r,to:a}),r=null)}),r!==null&&s.push({from:r,to:e.length-1}),s}function lL(e,t=nL){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const s=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*s));return[...r].sort((i,a)=>i-a)}const Hn=e=>e,Bm={timeseries:Hn(sL),table:Hn(Q_),bars:Hn(Z$),keyvalue:Hn(g_),tiles:Hn(t1),document:Hn(bO),diff:Hn(iD),terminal:Hn(y_),image:Hn(p_),preview:Hn(k_),envelope:Hn(c_),structured:Hn(F_)},oL="structured";function cL(e){return(_u(e)?Bm[e]:void 0)??Bm[oL]}function _u(e){return Object.prototype.hasOwnProperty.call(Bm,e)}function uL({renderer:e,props:t,timezone:s,onDecided:r}){const i=cL(e),l=_u(e)?t:{value:t};return n.jsx(i,{props:l,timezone:s,onDecided:r})}function dL({profile:e,onChange:t}){return n.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[n.jsx("p",{className:"wb-prof-lead",children:e.description}),n.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?n.jsx(zh,{children:"Opens by default"}):null,n.jsx(zh,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(s=>n.jsx(zh,{title:`A surface command that asks for "${s}" lands on this agent.`,children:un(s)},s))]}),e.available?null:n.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[n.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),(e.disabled??[]).map(s=>n.jsx("p",{className:"wb-prof-blocked","data-testid":"agent-profile-disabled",children:s},s)),n.jsx(ul,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:n.jsxs("ul",{className:"wb-prof-list",children:[n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),n.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."})]}),n.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),n.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),n.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."})]}),n.jsxs("span",{className:"wb-prof-gate",children:[n.jsx(n1,{}),"Exact action"]})]})]})}),n.jsx(ul,{title:"What it can do",note:hL(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?n.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((s,r)=>+(r.gated>0)-+(s.gated>0)).map(s=>n.jsx(fL,{family:s},s.family))}),n.jsx(ul,{title:"What it runs on",children:n.jsxs("dl",{className:"wb-prof-kv",children:[n.jsx(dl,{label:"Provider",children:e.engine.provider}),n.jsx(dl,{label:"Model",children:n.jsx("span",{className:"mono",children:e.engine.model})}),n.jsxs(dl,{label:"Credential",children:[e.engine.credentialKind," from"," ",n.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),n.jsxs(dl,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),n.jsx(dl,{label:"Language",children:vL(e.engine.language)})]})}),e.skills.length>0?n.jsx(ul,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:n.jsx("ul",{className:"wb-prof-list",children:e.skills.map(s=>n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name mono",children:s.name}),s.description?n.jsx("span",{className:"wb-prof-row-desc",children:s.description}):null]}),n.jsxs("span",{className:"wb-prof-row-side",title:s.file,children:[s.scope==="private"?"its own":"shared"," · ",s.provenance]})]},s.file))})}):null,e.delegates.length>0?n.jsx(ul,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:n.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(s=>n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsxs("span",{className:"wb-prof-row-name mono",children:["@",s.handle]}),n.jsx("span",{className:"wb-prof-row-desc",children:s.description})]}),n.jsx("span",{className:"wb-prof-row-side",children:s.available?s.name:`${s.name} · cannot run`})]},s.id))})}):null,n.jsxs("footer",{className:"wb-prof-foot",children:[n.jsx("p",{className:"wb-prof-note",children:e.note}),n.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?n.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 hL(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 s=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${s}.`}function fL({family:e}){const t=[...e.tools].sort((s,r)=>Number(r.gated)-Number(s.gated));return n.jsxs("section",{className:"wb-prof-family",children:[n.jsxs("h4",{className:"wb-prof-family-head",children:[n.jsx("span",{className:"wb-prof-family-name",children:un(e.family)}),n.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),n.jsx("ul",{className:"wb-prof-list",children:t.map(s=>n.jsx(mL,{tool:s},s.name))})]})}function mL({tool:e}){return n.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name mono",children:xL(e.name)}),n.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?n.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[n.jsx(n1,{}),"Needs your approval"]}):n.jsx("span",{className:"wb-prof-auto",title:gL(e.tier),children:pL(e.tier)})]})}function pL(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function gL(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 xL(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function vL(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function ul({title:e,note:t,tone:s,children:r}){return n.jsxs("section",{className:"wb-prof-section",children:[n.jsx("h3",{className:"wb-prof-title",children:e}),t?n.jsx("p",{className:"wb-prof-note-lead","data-tone":s,children:t}):null,r]})}function dl({label:e,children:t}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"wb-prof-k",children:e}),n.jsx("dd",{className:"wb-prof-v",children:t})]})}function zh({children:e,title:t}){return n.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function n1(){return n.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:[n.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),n.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const Fy=16e3,jL=10*6e4,yL="The microphone is blocked for this page: allow it in the browser’s site settings to talk.",s1="This browser cannot record here: talking needs a microphone and a secure page (https or localhost).";function wL(){const e=window;return e.AudioContext??e.webkitAudioContext}function bL(e){const t=e&&typeof e=="object"&&"name"in e?String(e.name):"";return t==="NotAllowedError"||t==="SecurityError"||t==="PermissionDeniedError"?yL:t==="NotFoundError"||t==="DevicesNotFoundError"?"No microphone was found on this computer.":t==="NotReadableError"?"The microphone is in use by another app.":s1}async function kL(e){var c;const t=wL();if(!((c=navigator.mediaDevices)!=null&&c.getUserMedia)||!t)throw Object.assign(new Error(s1),{name:"Unsupported"});const s=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),r=new t,i=r.createMediaStreamSource(s),a=r.createScriptProcessor(4096,1,1),l=[];a.onaudioprocess=u=>{const f=u.inputBuffer.getChannelData(0);l.push(new Float32Array(f));let d=0;for(let m=0;m<f.length;m++)d+=f[m]*f[m];e(Math.min(1,Math.sqrt(d/f.length)*6))},i.connect(a),a.connect(r.destination),r.state==="suspended"&&await r.resume().catch(()=>{});const o=()=>{a.onaudioprocess=null;try{i.disconnect(),a.disconnect()}catch{}s.getTracks().forEach(u=>u.stop()),r.close().catch(()=>{})};return{async stop(){const u=r.sampleRate;return o(),CL(NL(SL(l),u,Fy),Fy)},cancel:o}}function SL(e){const t=new Float32Array(e.reduce((r,i)=>r+i.length,0));let s=0;for(const r of e)t.set(r,s),s+=r.length;return t}function NL(e,t,s){if(t<=s)return e;const r=t/s,i=new Float32Array(Math.floor(e.length/r));for(let a=0;a<i.length;a++){const l=Math.floor(a*r),o=Math.min(e.length,Math.floor((a+1)*r));let c=0;for(let u=l;u<o;u++)c+=e[u];i[a]=o>l?c/(o-l):0}return i}function CL(e,t){const s=new ArrayBuffer(44+e.length*2),r=new DataView(s),i=(a,l)=>{for(let o=0;o<l.length;o++)r.setUint8(a+o,l.charCodeAt(o))};i(0,"RIFF"),r.setUint32(4,36+e.length*2,!0),i(8,"WAVEfmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,"data"),r.setUint32(40,e.length*2,!0);for(let a=0;a<e.length;a++){const l=Math.max(-1,Math.min(1,e[a]));r.setInt16(44+a*2,Math.round(l<0?l*32768:l*32767),!0)}return new Blob([s],{type:"audio/wav"})}const zm="buddi.readAloud";function r1(){try{return window.localStorage.getItem(zm)==="on"}catch{return!1}}function i1(e){try{e?window.localStorage.setItem(zm,"on"):window.localStorage.removeItem(zm)}catch{}}let ks=null,Rl=null,co=0,Wm=null;const Hm=new Set;function Lu(e){Wm!==e&&(Wm=e,Hm.forEach(t=>t()))}function EL(){return Wm}function AL(e){return Hm.add(e),()=>Hm.delete(e)}function a1(e){return Ga(),Lu(e),co}function Uy(e){return e===co}function Ga(){co++,ks&&(ks.pause(),ks.removeAttribute("src")),Rl&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(Rl),Rl=null,Lu(null)}async function TL(e,t,s=null){var i;const r=a1(s);try{const a=await fetch(e,{credentials:"same-origin"});if(!a.ok)throw new Error(`The spoken reply could not be fetched (${a.status}).`);const l=new Blob([await a.arrayBuffer()],{type:t});if(r!==co)return;ks||(ks=new Audio,(i=ks.addEventListener)==null||i.call(ks,"ended",()=>Lu(null))),Rl=URL.createObjectURL(l),ks.src=Rl,await ks.play()}catch(a){throw r===co&&Lu(null),a}}const RL=new Set(["audio/ogg","audio/mpeg","audio/mp4","audio/wav","audio/x-wav","audio/webm"]);function l1(e){return RL.has(e.toLowerCase().split(";")[0].trim())}function By(e){if(e===null||!Number.isFinite(e)||e<0)return"–:––";const t=Math.floor(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function o1({artifactId:e,name:t,mime:s,sizeBytes:r}){const i=h.useRef(null),a=h.useRef(null),[l,o]=h.useState(!1),[c,u]=h.useState(!1),[f,d]=h.useState(!1),[m,p]=h.useState(0),[v,w]=h.useState(null);h.useEffect(()=>()=>{var x;(x=i.current)==null||x.pause(),a.current&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(a.current)},[]);const k=async()=>{const x=i.current;if(x){if(l){x.pause();return}Ga(),d(!1);try{if(!a.current){u(!0);const y=await fetch(Lr(e),{credentials:"same-origin"});if(!y.ok)throw new Error(String(y.status));a.current=URL.createObjectURL(new Blob([await y.arrayBuffer()],{type:s})),x.src=a.current}await x.play()}catch{d(!0)}finally{u(!1)}}},g=f?"Could not play. Download it instead.":`${By(m)} / ${By(v)}`;return n.jsxs("span",{className:"wb-audio","data-testid":"audio-card","data-playing":l?"true":void 0,children:[n.jsx("button",{type:"button",className:"ui-icon-btn wb-audio-play","data-size":"sm","aria-label":l?`Pause ${t}`:`Play ${t}`,disabled:c,onClick:()=>void k(),children:n.jsx(Se,{name:l?"pause":"play",size:14})}),n.jsxs("span",{className:"wb-file-text",children:[n.jsx("span",{className:"wb-file-name",title:t,children:t}),n.jsxs("span",{className:"wb-file-meta","data-testid":"audio-time",children:[c?"Loading…":g,!f&&Cn(r)?` · ${Cn(r)}`:""]})]}),n.jsx("a",{className:"ui-icon-btn wb-audio-download","data-size":"sm",href:Lr(e),download:t,"aria-label":`Download ${t}`,title:"Download",children:n.jsx(Se,{name:"download",size:14})}),n.jsx("audio",{ref:i,preload:"none",onPlay:()=>o(!0),onPause:()=>o(!1),onEnded:()=>{o(!1),p(0)},onTimeUpdate:x=>p(x.currentTarget.currentTime),onLoadedMetadata:x=>w(Number.isFinite(x.currentTarget.duration)?x.currentTarget.duration:null),onDurationChange:x=>w(Number.isFinite(x.currentTarget.duration)?x.currentTarget.duration:null)})]})}const Wh=1e5,Hh=200,Vh=30;function c1({artifactId:e,filename:t,mime:s,family:r,available:i=!0}){const[a,l]=h.useState(!1);return i?r==="image"&&!a?n.jsx("figure",{className:"file-preview file-preview-image",children:n.jsx("img",{src:rr(e),alt:t??"Image",onError:()=>l(!0)})}):r==="audio"&&l1(s)?n.jsx("div",{className:"file-preview file-preview-audio",children:n.jsx(o1,{artifactId:e,name:t??"Audio",mime:s})}):r==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:rr(e),type:"application/pdf","aria-label":t??"PDF",children:n.jsx(H,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?n.jsx(IL,{artifactId:e,filename:t,mime:s,family:r}):n.jsx(H,{children:"Preview not supported for this kind of file. Download it to open it."}):n.jsx(H,{children:"The file is no longer available; its record is kept."})}function IL({artifactId:e,filename:t,mime:s,family:r}){const[i,a]=h.useState("loading");if(h.useEffect(()=>{let o=!1;return a("loading"),fetch(rr(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();o||a({text:u.slice(0,Wh),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>Wh})}).catch(()=>{o||a("failed")}),()=>{o=!0}},[e]),i==="loading")return n.jsx("div",{className:"file-preview",children:n.jsx(oe,{children:"Loading preview…"})});if(i==="failed")return n.jsx(H,{children:"The preview could not be loaded. Download the file to open it."});const l=r==="table"&&(/csv|tab-separated/.test(s)||/\.(csv|tsv)$/i.test(t??""));return n.jsxs("div",{className:"file-preview",children:[l?n.jsx(ML,{text:i.text,delimiter:/tab|\.tsv$/i.test(s+(t??""))?" ":","}):n.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?n.jsxs("p",{className:"muted",children:["Showing the first ",Wh.toLocaleString()," characters. The download has the whole file."]}):null]})}function PL(e,t,s,r){const i=[];let a=[],l="",o=!1,c=!1,u=!1;const f=()=>{a.length<r?a.push(l):c=!0,l=""},d=()=>{f(),i.push(a),a=[]};let m=0;for(;m<e.length;m+=1){if(i.length>=s){u=e.slice(m).trim()!=="";break}const p=e[m];if(o){p==='"'?e[m+1]==='"'?(l+='"',m+=1):o=!1:l+=p;continue}if(p==='"'){o=!0;continue}if(p===t){f();continue}if(p!=="\r"){if(p===`
95
- `){d();continue}l+=p}}return i.length<s&&(l!==""||a.length>0)&&d(),{rows:i,truncatedRows:u,truncatedCols:c}}function ML({text:e,delimiter:t}){const s=h.useMemo(()=>PL(e,t,Hh+1,Vh),[e,t]),[r,...i]=s.rows;if(!r)return n.jsx("p",{className:"muted",children:"The file is empty."});const a=Math.min(Vh,s.rows.reduce((o,c)=>Math.max(o,c.length),0)),l=Array.from({length:a},(o,c)=>c);return n.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:l.map(o=>n.jsx("th",{children:r[o]??""},o))})}),n.jsx("tbody",{children:i.slice(0,Hh).map((o,c)=>n.jsx("tr",{children:l.map(u=>n.jsx("td",{children:o[u]??""},u))},c))})]}),s.truncatedRows||s.truncatedCols?n.jsxs("p",{className:"muted",children:["Showing the first ",Hh," rows",s.truncatedCols?` and ${Vh} columns`:"",". The download has the whole file."]}):null]})}function $L({attachment:e}){const t=dx(e.mime,e.filename),s=e.filename??"Untitled file";return n.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[n.jsx(c1,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),n.jsxs("dl",{className:"ui-kv",children:[n.jsx("dt",{children:"Type"}),n.jsxs("dd",{children:[mi[t],n.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Size"}),n.jsx("dd",{children:Cn(e.sizeBytes)})]}):null,n.jsx("dt",{children:"Id"}),n.jsx("dd",{className:"mono",children:e.artifactId})]}),n.jsx("div",{className:"ui-toolbar","data-align":"end",children:n.jsx("a",{className:"ui-btn",href:Lr(e.artifactId),download:s,children:"Download"})})]})}const zy=80,DL=["query","path","url","dir"],OL=["message","task"];function px(e,t){const s=_L(t);if(!s)return null;const r=Vi(s.command);if(r!==null){const l=Vi(s.name);return jc(l===null?r:`${l}: ${r}`)}for(const l of DL){const o=Vi(s[l]);if(o!==null)return jc(o)}const i=Vi(s.action);if(i!==null){const l=OL.map(o=>Vi(s[o])).find(o=>o!==null)??null;return jc(l===null?i:`${i} · ${l}`)}const a=Object.values(s).filter(l=>typeof l=="string");return a.length===1?jc(Vi(a[0])):null}function Vi(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function jc(e){return e===null?null:e.length>zy?`${e.slice(0,zy-1)}…`:e}function _L(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Fr="agent.delegate";function LL(e){if(e===null||typeof e!="object")return null;const t=e,s=t.conversationId;if(typeof s!="string"||s==="")return null;const r=t.agentId??t.agent;return{conversationId:s,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function FL(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 Vm="canvas.show",Wy="canvas.clear",Hy=12;function xa(e){return`${e.plugin}/${e.name}`}function UL(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function BL({messages:e,descriptors:t}){const s=new Map(t.filter(a=>a.renderer==="preview").map(a=>[a.tool,a]));if(s.size===0)return[];const r=new Map,i=[];for(const a of e)for(const l of a.blocks??[]){if(l.type==="tool_use"&&r.set(l.id,l.name),l.type!=="tool_result"||l.ok===!1)continue;const o=s.get(l.name||r.get(l.toolUseId)||"");if(!o)continue;const c=TN(o,u1(l.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:a.at??null})}return i}function zL({messages:e,descriptors:t,awaiting:s,folded:r,served:i}){var u;const a=new Map(t.map(f=>[f.tool,f])),l=new Map;let o=[],c=0;for(const f of e)for(const d of f.blocks??[]){if(d.type==="tool_use"){if(l.set(d.id,{name:d.name,input:d.input,at:f.at??null}),d.name===Vm){const j=HL(d.id,d.input,f.at??null);j&&o.push(j)}if(d.name===Wy&&(o=[]),d.name===Fr){const j=LL(d.input);j&&o.push({id:d.id,tool:Fr,title:"Delegation",renderer:"delegate",props:{...j,result:null},at:f.at??null,source:"delegate",substantial:!0})}continue}if(d.type!=="tool_result"||d.name===Vm||d.name===Wy)continue;const m=l.get(d.toolUseId),p=f.at??(m==null?void 0:m.at)??null,v=d.name||(m==null?void 0:m.name)||"tool",w=o.find(j=>j.source==="delegate"&&j.id===d.toolUseId);if(w&&((u=d.delegation)==null?void 0:u.state)==="waiting"){w.props={...w.props,result:null,waiting:{approvalId:d.delegation.approvalId}},d.delegation.approvalId&&(w.tone="warning");continue}if(w){w.props={...w.props,result:{ok:d.ok,text:FL(d.ok?d.output:d.error??d.output),...d.ok&&Mu(d.output).length>0?{files:Mu(d.output)}:{}}},d.ok||(w.tone="critical");continue}const k=d.approval?Gm(d):(s==null?void 0:s.get(d.toolUseId))??Gm(d);if(k){o.push({id:d.toolUseId,tool:v,title:"Approval",renderer:"envelope",props:{approvalId:k},at:p,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(v))continue;const g=u1(d.output);if(d.ok===!1){o.push({id:d.toolUseId,tool:v,title:Rs(v),renderer:"structured",props:{value:d.error??g??null,failed:!0},at:p,tone:"critical",source:"fallback",substantial:!1});continue}UL(g)&&(c+=1);const x=a.get(v);if(x){const j=TN(x,g),{renderer:N}=j;let{props:b}=j;if(N==="preview"){const S=b,C=S.target??(S.awaiting&&(i!=null&&i.has(xa(S.awaiting)))?S.awaiting:null);if(C===null)continue;b={...S,target:C,awaiting:null};const R=xa(C);o=o.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&xa(E.props.target)===R))}o.push({id:d.toolUseId,tool:v,title:x.title??Rs(v),renderer:N,props:b,at:p,source:"descriptor",substantial:Km(N,b)});continue}const y={value:fx(g)?{input:m==null?void 0:m.input,output:g}:g};VL("structured",y)&&o.push({id:d.toolUseId,tool:v,title:Rs(v),renderer:"structured",props:y,at:p,source:"fallback",substantial:Km("structured",y)})}for(const f of o)f.source==="descriptor"&&f.renderer==="preview"&&(f.props={...f.props,changes:c});return WL(o)}const Vy="forAgent";function u1(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(Vy in e))return e;const{[Vy]:t,...s}=e;return s}function WL(e){if(e.length<=Hy)return e;const t=e.length-Hy;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function HL(e,t,s){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:a}=t,l=typeof r=="string"&&_u(r)?r:"structured";return{id:e,tool:Vm,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:l,props:l==="structured"&&!_u(String(r))?{value:a}:a,at:s,substantial:!0,source:"canvas"}}function VL(e,t){const s=t??{};return!!(s.failed===!0||Km(e,t)||hx(s.value).kind==="error")}function Km(e,t){const s=t??{};switch(e){case"timeseries":return hl(s.points)>0;case"bars":return hl(s.bars)>0;case"keyvalue":return hl(s.pairs)>0;case"tiles":return s.notice!==!0&&hl(s.tiles)>0;case"document":return!!s.text||!!s.src;case"diff":return!!s.diff;case"terminal":return!!s.output||!!s.command;case"image":return!!s.artifactId;case"preview":return!!s.target;case"envelope":return!0;case"table":return(Array.isArray(s.groups)?s.groups:[]).some(i=>hl(i.rows)>0);default:return fx(s.value)?!0:s.failed===!0?!1:O_(s.value)}}function hl(e){return Array.isArray(e)?e.length:0}function Gm(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const s=h1(t,0);if(s)return s}return null}function KL(e,t,s={}){var o,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 a=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),l=(o=s.redactInputOf)!=null&&o.has(i.name)?d1(i.input):i.input;return{id:t,tool:i.name,title:Rs(i.name),renderer:"structured",props:{value:{input:l,...(a==null?void 0:a.type)==="tool_result"?{status:((c=a.approval)==null?void 0:c.state)??(a.ok?"completed":"failed"),output:a.output,...a.error?{error:a.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const GL=new Set(["value","text","password","secret","code"]);function d1(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[s,r]of Object.entries(e))t[s]=GL.has(s)&&typeof r=="string"?"— withheld —":d1(r);return t}function h1(e,t){if(t>3||e===null||typeof e!="object")return null;const s=e,r=s.reason,i=s.actionId??s.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const a of Object.values(s)){const l=h1(a,t+1);if(l)return l}return null}function Rs(e){const t=e.split(".");return t.length===1?un(e):t.map(s=>un(s)).join(" · ")}function _d({name:e,mime:t,sizeBytes:s,thumbnail:r,state:i,error:a,onOpen:l,onRemove:o,size:c="md"}){const u=dx(t,e),f=[mi[u],Cn(s)].filter(Boolean).join(" · "),d=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"wb-file-visual","data-family":u,children:r?n.jsx("img",{src:r,alt:""}):n.jsx(gx,{family:u})}),n.jsxs("span",{className:"wb-file-text",children:[n.jsx("span",{className:"wb-file-name",title:e,children:e}),n.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":f})]})]});return n.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?a:void 0,children:[l?n.jsx("button",{type:"button",className:"wb-file-open",onClick:l,"aria-label":`Open ${e}`,children:d}):n.jsx("span",{className:"wb-file-open",children:d}),o?n.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:o,children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:n.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function gx({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 n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),n.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),n.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return n.jsxs("svg",{...t,children:[n.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"}),n.jsx("path",{d:"M11.5 2.5V7H16"}),n.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return n.jsxs("svg",{...t,children:[n.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"}),n.jsx("path",{d:"M11.5 2.5V7H16"}),n.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return n.jsx("svg",{...t,children:n.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return n.jsx("svg",{...t,children:n.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),n.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),n.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return n.jsxs("svg",{...t,children:[n.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"}),n.jsx("path",{d:"M11.5 2.5V7H16"})]})}}function YL(e,t,s){const r=Gy(e),i=Gy(t==null?void 0:t.input),a=ti(r==null?void 0:r.name)??ZL(ti(r==null?void 0:r.handle))??ti(r==null?void 0:r.agent)??ti(i==null?void 0:i.agent),l=typeof e=="string"?e.trim()||null:ti(r==null?void 0:r.text)??ti(r==null?void 0:r.note),o=Ky(r==null?void 0:r.durationMs)??Ky(r==null?void 0:r.elapsedMs),c=t!=null&&t.at?Date.parse(t.at):NaN,u=s?Date.parse(s):NaN,f=Number.isFinite(c)&&Number.isFinite(u)&&u>=c?u-c:null;return{who:a,question:ti(i==null?void 0:i.task),answer:l,files:Mu(e),durationMs:o??f}}function qL(e,t){var r;let s=null;for(const i of e)for(const a of i.blocks??[])a.type==="tool_result"&&a.name===Fr&&((r=a.delegation)==null?void 0:r.approvalId)===t&&(s=a.toolUseId);if(s===null)return null;for(const i of e)for(const a of i.blocks??[])if(a.type==="tool_use"&&a.id===s)return{input:a.input,at:i.at||null};return null}function QL({block:e,messages:t,answeredAt:s}){const r=YL(e.output,qL(t,e.actionId),s),i=[r.who?`Asked ${r.who}`:null,r.durationMs===null?null:`took ${JL(r.durationMs)}`].filter(a=>a!==null);return n.jsxs("div",{className:"wb-delegation-result","data-testid":"delegation-result",children:[i.length>0?n.jsx("p",{className:"wb-delegation-facts",children:i.join(" · ")}):null,r.question?n.jsx("blockquote",{className:"wb-delegation-question",children:r.question}):null,r.answer?n.jsx("div",{className:"wb-delegation-answer","data-testid":"delegation-answer",children:n.jsx(nr,{text:r.answer})}):n.jsx("p",{className:"wb-delegation-facts",children:"No answer came back."}),r.files.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${r.who??"the colleague"} made`,children:r.files.map(a=>n.jsx("a",{role:"listitem",href:Lr(a.artifactId),download:!0,children:n.jsx(_d,{name:a.filename??"Untitled file",mime:a.mime,sizeBytes:a.sizeBytes,thumbnail:ux(a.mime)?rr(a.artifactId):null,size:"sm"})},a.artifactId))}):null,n.jsx(Tt,{summary:"Raw JSON",children:n.jsx("pre",{className:"wb-approval-output mono",children:XL(e.output)})})]})}function JL(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60);return s<60?`${s}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m`}function XL(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function ZL(e){return e===null?null:`@${e.replace(/^@/,"")}`}function ti(e){return typeof e=="string"&&e.trim()!==""?e:null}function Ky(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Gy(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const eF=1e3;function tF({messageId:e,text:t,onReadAloud:s}){const[r,i]=h.useState(!1),a=h.useRef(null),l=h.useSyncExternalStore(AL,EL)===e;h.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const o=()=>{var c;(c=navigator.clipboard)==null||c.writeText(t).then(()=>{i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),eF)},()=>{})};return n.jsxs("div",{className:"wb-reply-actions","data-testid":"reply-actions",children:[n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":r?"Copied":"Copy",title:r?"Copied":"Copy",onClick:o,children:n.jsx(Se,{name:r?"check":"copy",size:14})}),r?n.jsx("span",{className:"wb-reply-copied",role:"status",children:"Copied"}):null,s?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":l?"Stop reading aloud":"Read aloud",title:l?"Stop reading aloud":"Read aloud","aria-pressed":l,onClick:()=>l?Ga():s(e,t),children:n.jsx(Se,{name:l?"stop":"play",size:14})}):null]})}function nF(e){const t=sF(e);if(!t)return null;const s=Kh(t.diff);if(s!==null)return{kind:"diff",diff:s};const r=Kh(t.command),i=Kh(t.plain),a=Gh(t.exitCode);return r!==null&&(i!==null||a!==null||Gh(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:a,elapsedMs:Gh(t.elapsedMs)}:null}function Kh(e){return typeof e=="string"&&e.trim()!==""?e:null}function Gh(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function sF(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Yy="offer:",f1="owner:interjection";function rF(e){return e===f1}function iF(e){if(typeof e!="string"||!e.startsWith(Yy))return null;const t=e.slice(Yy.length).trim();return t===""?null:t}function xx({messages:e,live:t,now:s,onOpen:r,working:i=!1,partial:a=null,agents:l,agentId:o,speakers:c,coordinatorId:u,workingAs:f,onOpenFile:d,onReadAloud:m,children:p,agentName:v,emptyHint:w,empty:k,plain:g=!1,workingLine:x,runs:y}){var B;const j=h.useRef(null);h.useEffect(()=>{var V;(V=j.current)==null||V.scrollIntoView({block:"end"})},[e.length,t.length,i,a==null?void 0:a.text.length,a==null?void 0:a.thinking.length,!!p]);const N=a&&!a.settled&&(a.text!==""||a.thinking!==""),b=e.filter(V=>(V.blocks??[]).some(gF)),S=mF(b,y??[]),C=c??l??[],R=V=>(o&&!c?C.find(de=>de.id===o):void 0)??C.find(de=>de.name===V)??null,E=o?C.find(V=>V.id===o)??null:null,P=i||t.length>0,F=P||!!N,M=!!N&&a.text!=="",T=P&&!M,$=b.at(-1),_=($==null?void 0:$.role)!=="assistant"||!!f,K=f??v??"Assistant",D=b.filter((V,de)=>{var ae;return de===0||(c?(((ae=b[de-1])==null?void 0:ae.speaker)??null)!==(V.speaker??null):b[de-1].role!==V.role)}),Y=F&&!_?((B=D.at(-1))==null?void 0:B.id)??null:null;return n.jsx(CN.Provider,{value:l??c??[],children:n.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[b.length===0&&t.length===0?k??n.jsx("p",{className:"wb-chat-empty",children:w}):null,b.map((V,de)=>{const ae=V.speaker??null,le=c?ae==="owner"||ae===null&&V.role==="user":V.role==="user",Ce=c&&ae==="room",ee=c&&ae&&ae!=="owner"&&ae!=="room"?c.find(z=>z.id===ae)??null:null,ce=b[de-1],fe=de===0||(c?((ce==null?void 0:ce.speaker)??null)!==ae:ce.role!==V.role);if(Ce)return n.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(V.blocks??[]).filter(z=>z.type==="text").map((z,se)=>n.jsx("span",{children:z.text},se))},V.id);const je=(V.blocks??[]).filter(z=>z.type==="approval_result");if(je.length>0)return n.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:je.map((z,se)=>n.jsx(xF,{block:z,messages:e,at:V.at||null},se))},V.id);const X=V.role==="user"&&rF(ae),be=V.role==="user"?iF(ae):null;if(be){const z=(V.blocks??[]).filter(se=>se.type==="text").map(se=>se.text).join(`
96
- `);return n.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:n.jsx("div",{className:"wb-bubble wb-bubble-offer",title:z,children:be})},V.id)}const Ee=c&&ee&&V.role==="user"?dF(V):null;if(Ee){const z=b.slice(de+1).find(Ae=>Ae.role==="assistant"&&Ae.speaker&&Ae.speaker!==ee.id),se=z!=null&&z.speaker?c.find(Ae=>Ae.id===z.speaker):void 0;return n.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[n.jsxs("summary",{children:[ee.name," asked ",(se==null?void 0:se.name)??"a member",Ee.request?`: ${Ee.request.length>120?`${Ee.request.slice(0,119)}…`:Ee.request}`:""]}),Ee.request?n.jsx("p",{children:Ee.request}):null]},V.id)}const qe=S.get(V.id)??null,Ie=fF(V,e),et=!le&&!X&&!g?hF(V):"";return n.jsxs("div",{className:"wb-msg","data-role":le||X?"user":"assistant",children:[X?n.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,fe&&!le&&!X?n.jsx(qy,{name:ee?ee.name:v??"Assistant",face:ee??E??R(v),moving:T&&Y===V.id,children:ee&&u===ee.id?n.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null}):null,Ie.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:Ie.map(z=>n.jsx("span",{role:"listitem",children:l1(z.mime)?n.jsx(o1,{artifactId:z.artifactId,name:z.filename??"Untitled file",mime:z.mime,sizeBytes:z.sizeBytes}):n.jsx(_d,{name:z.filename??"Untitled file",mime:z.mime,sizeBytes:z.sizeBytes,thumbnail:ux(z.mime)?rr(z.artifactId):null,...d?{onOpen:()=>d(z)}:{}})},z.artifactId))}):null,(V.blocks??[]).map((z,se)=>{const Ae=oF(V.blocks??[],se,e);if(Ae==="inside")return null;if(Ae)return n.jsx(cF,{refusals:Ae.refusals},se);if(z.type==="thinking")return g||z.text.trim()===""?null:n.jsx(Ym,{text:z.text},se);if(z.type==="text")return z.text.trim()===""?null:le?n.jsx("div",{className:"wb-bubble",children:z.text},se):n.jsx("div",{className:"wb-bubble","data-rich":"true",children:n.jsx(nr,{text:z.text})},se);if(z.type==="attachment")return null;if(z.type==="tool_use"){if(g)return null;const Me=vx(e,z.id),ot=Me?yF(Me):null;return n.jsx(qm,{label:ot&&!(Me!=null&&Me.delegation)?`Approval · ${z.name}`:Rs(z.name),tool:z.name,ok:(Me==null?void 0:Me.ok)??null,running:Me===null,...ot?{status:ot.status,waiting:ot.waiting,approval:!0}:{},gist:px(z.name,z.input),body:Me?nF(Me.output):null,opens:!0,onOpen:()=>r(z.id)},se)}return null}),qe?n.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:pF(qe)}):null,et!==""?n.jsx(tF,{messageId:V.id,text:et,onReadAloud:m}):null]},V.id)}),F?n.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[_?n.jsx(qy,{name:K,face:R(K)??E,moving:T}):null,N&&a.thinking!==""&&!g?n.jsx(Ym,{text:a.thinking,live:a.text==="",seconds:uF(a.thinkingStartedAt,a.textStartedAt??s)}):null,M?n.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[n.jsx(nr,{text:a.text}),n.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null,i&&t.length===0&&!N?n.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite","data-testid":"working",children:[x??`${f??v??"The agent"} is working`,n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]}):null,t.map(V=>n.jsx(qm,{label:Rs(V.name),tool:V.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((s-V.startedAt)/1e3)),opens:!1,onOpen:()=>r(V.toolUseId)},V.toolUseId))]}):null,p,n.jsx("div",{ref:j})]})})}function qy({name:e,face:t,moving:s=!1,children:r}){const i=(t==null?void 0:t.picture)??null,a=kN(s?i:null);return n.jsxs("div",{className:"wb-msg-who","data-testid":"turn-head",children:[n.jsx("span",{className:"wb-msg-mark","data-moving":s?a&&i?"blob":"ring":void 0,children:s&&a&&i?n.jsx(Id,{state:"working",size:"sm",still:i,className:"wb-msg-blob"}):n.jsx(ps,{id:(t==null?void 0:t.id)??e,name:(t==null?void 0:t.name)??e,unavailable:t?!t.available:!1,...t?{face:t}:{}})}),n.jsx("span",{children:e}),r]})}function aF(e){var t,s;return((s=(t=/ may delegate to ([^;]*);/.exec(e)??/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:s.trim())||null}const lF="delegation refused:";function oF(e,t,s){const r=a=>{const l=e[a];if(!l||l.type!=="tool_use"||l.name!==Fr)return null;const o=vx(s,l.id);if(!o||o.ok!==!1)return null;const c=typeof o.error=="string"?o.error:String(o.error??"");if(!c.trimStart().startsWith(lF))return null;const u=l.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 a=t;;a+=1){const l=r(a);if(!l)break;i.push(l)}return i.length<2?null:{refusals:i}}function cF({refusals:e}){const[t,s]=h.useState(!1),r=e.map(o=>aF(o.message)).find(o=>o!==null)??null,i=e.map(o=>o.target),a=i.slice(0,3),l=`Delegation refused ${e.length} times: ${a.join(", ")}${i.length>a.length?", …":""}`+(r?` (allowed: ${r})`:"");return n.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[n.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>s(o=>!o),children:[n.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:l}),n.jsx(Se,{name:"arrow",className:"wb-tool-arrow"})]}),t?n.jsx("div",{className:"wb-refusals-list",children:e.map((o,c)=>n.jsxs("div",{className:"wb-refusal",children:[n.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[n.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),n.jsxs("span",{className:"wb-tool-label",children:[Rs(Fr)," · ",o.target]}),n.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),n.jsx("p",{className:"wb-refusal-why",children:o.message})]},c))}):null]})}function uF(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function Ym({text:e,live:t=!1,seconds:s=null}){const[r,i]=h.useState(!1),a=t?`Thinking${s!==null&&s>0?` · ${s}s`:""}`:s!==null&&s>0?`Thought for ${s}s`:"Thoughts";return n.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[n.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(l=>!l),children:[t?n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}):n.jsx(Se,{name:"thought"}),n.jsx("span",{children:a}),n.jsx(Se,{name:"arrow",className:"wb-tool-arrow"})]}),r?n.jsx("div",{className:"wb-thought-text",children:n.jsx(nr,{text:e})}):null]})}function dF(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",s=/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 s?{handle:s[1],request:s[2].trim()}:null}function hF(e){return(e.blocks??[]).filter(t=>t.type==="text").map(t=>t.text.trim()).filter(t=>t!=="").join(`
97
-
98
- `)}function fF(e,t){const s=[],r=new Set,i=a=>{r.has(a.artifactId)||(r.add(a.artifactId),s.push(a))};for(const a of e.blocks??[])if(a.type==="attachment"&&i(a),a.type==="tool_use"&&a.name===Fr){const l=vx(t,a.id);l!=null&&l.ok&&Mu(l.output).forEach(i)}return s}function mF(e,t){const s=t.filter(l=>l.startedAt!==null&&l.finishedAt!==null),r=(l,o)=>o.at!==""&&o.at>=l.startedAt&&o.at<=l.finishedAt,i=(l,o)=>l!==o&&l.startedAt>=o.startedAt&&l.finishedAt<=o.finishedAt&&(l.startedAt>o.startedAt||l.finishedAt<o.finishedAt),a=new Map;for(const l of s){if(l.stopped!=="max_turns"&&l.stopped!=="max_tokens"||l.noticed!==!0||l.runId===null)continue;let o=null;for(const c of e)c.role!=="assistant"||!r(l,c)||(o=c);o===null||s.some(c=>i(c,l)&&r(c,o))||a.has(o.id)||a.set(o.id,l)}return a}function pF(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 gF(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function xF({block:e,messages:t,at:s}){const[r,i]=h.useState(!1),a=e.state==="succeeded";return n.jsxs("div",{className:"wb-approval","data-open":r||void 0,children:[n.jsxs("button",{type:"button",className:"wb-tool","data-ok":a,"aria-expanded":r,onClick:()=>i(l=>!l),children:[n.jsx("span",{className:"wb-tool-mark","data-ok":a?"true":"false","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":Rs(e.name)}),n.jsx("span",{className:"wb-tool-elapsed",children:e.state}),n.jsx(Se,{name:"arrow",className:"wb-tool-arrow"})]}),r&&e.name===Fr?n.jsx(QL,{block:e,messages:t,answeredAt:s}):null,r&&e.name!==Fr?n.jsx("pre",{className:"wb-approval-output mono",children:vF(e.output)}):null]})}function vF(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const jF=40;function yF(e){var s,r;if(((s=e.delegation)==null?void 0:s.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(Gm(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 qm({label:e,tool:t,ok:s,running:r,elapsed:i,opens:a,onOpen:l,status:o,waiting:c=!1,approval:u=!1,gist:f=null,body:d=null}){const[m,p]=h.useState(!1),v=n.jsxs(n.Fragment,{children:[r?n.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):n.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":s===!1?"false":"true","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:e}),f?n.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:f}):null,i===void 0?null:n.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),o||s===!1?n.jsx("span",{className:"wb-tool-elapsed",children:o??"failed"}):null]}),w={"data-ok":s===null?void 0:s,"data-running":r,"data-gist":f?!0:void 0,"data-approval":u||void 0};return d?n.jsxs("div",{className:"wb-toolcall","data-open":m||void 0,children:[n.jsxs("div",{className:"wb-tool","data-split":"true",...w,children:[n.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":m,onClick:()=>p(k=>!k),children:[n.jsx(Se,{name:"chevron",className:"wb-tool-chevron"}),v]}),a?n.jsxs(eo,{children:[n.jsx(to,{asChild:!0,children:n.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:l,children:n.jsx(Se,{name:"arrow",className:"wb-tool-arrow"})})}),n.jsx(no,{children:n.jsxs(so,{className:"ui-tip",sideOffset:6,children:[n.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),n.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),m?n.jsx(wF,{body:d,onOpen:a?l:null}):null]}):a?n.jsxs(eo,{children:[n.jsx(to,{asChild:!0,children:n.jsxs("button",{className:"wb-tool",...w,onClick:l,children:[v,n.jsx(Se,{name:"arrow",className:"wb-tool-arrow"})]})}),n.jsx(no,{children:n.jsxs(so,{className:"ui-tip",sideOffset:6,children:[n.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),n.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):n.jsx("span",{className:"wb-tool","data-static":"true",...w,children:v})}function wF({body:e,onOpen:t}){const s=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return n.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:n.jsx(Iu,{text:e.diff,limit:jF,...s?{more:s}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:bF(e.elapsedMs)].filter(i=>i!==null);return n.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[n.jsxs("div",{className:"wb-tool-command",children:[n.jsx("code",{className:"mono",children:e.command}),r.length>0?n.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?n.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function bF(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function vx(e,t){for(const s of e)for(const r of s.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}const m1="approval-dock";function kF(){var t;const e=document.getElementById(m1);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const SF=["workspace","cwd","workdir","root"];function NF({approvals:e,timezone:t,now:s,version:r,onDecided:i,onSay:a,onOpenFull:l}){const[o,c]=h.useState([]),u=e.filter(m=>!o.includes(m.approvalId)),f=u[0];if(!f)return null;const d=m=>c(p=>p.includes(m)?p:[...p,m]);return n.jsx(CF,{item:f,count:u.length,timezone:t,now:s,version:r,onSettled:m=>{d(f.approvalId),m&&i(m)},onSay:a,onOpenFull:()=>l(f.toolUseId)},f.approvalId)}function CF({item:e,count:t,timezone:s,now:r,version:i,onSettled:a,onSay:l,onOpenFull:o}){var C;const[c,u]=h.useState(null),[f,d]=h.useState(null),[m,p]=h.useState(null),[v,w]=h.useState("");h.useEffect(()=>{let R=!1;return A.approval(e.approvalId).then(E=>{R||(u(E),E.state!=="pending"&&a(E))}).catch(E=>{R||d(E instanceof he?E.message:String(E))}),()=>{R=!0}},[e.approvalId,i]);const k=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;h.useEffect(()=>{k&&c&&a({...c,state:"expired"})},[k]);const{values:g,controls:x}=cx(c==null?void 0:c.choices),y=(R,E)=>{const P=v.trim();p(R),d(null),(g&&R==="approve"?A.decide(e.approvalId,R,E,g):A.decide(e.approvalId,R,E)).then(F=>{a(F.action),P&&l(P)}).catch(F=>{d(F instanceof he?F.message:String(F)),p(null)})},j=m!==null||c===null||c.state!=="pending",N=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,b=c?px(c.tool,c.canonicalArgs)??AF(c.preview):null,S=c?EF(c):null;return n.jsxs("section",{id:m1,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[n.jsxs("div",{className:"wb-question-head",children:[n.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?n.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,n.jsx("strong",{children:c?Rs(c.tool):"Loading the request…"}),e.askedBy?n.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),b||S?n.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[b?n.jsx("code",{className:"wb-dock-gist",children:b}):null,S?n.jsxs("span",{className:"wb-dock-where",children:["in ",n.jsx("span",{className:"mono",children:S})]}):null]}):null,x?n.jsx("div",{className:"wb-dock-section",children:x}):null,n.jsx(ne,{message:f}),n.jsx("div",{className:"wb-dock-section",children:n.jsx("input",{className:"wb-dock-instead",value:v,onChange:R=>w(R.target.value),onKeyDown:R=>{R.key==="Enter"&&R.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:m!==null})}),n.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[n.jsxs("span",{className:"wb-dock-meta",children:[c?n.jsxs(n.Fragment,{children:["Expires ",Ve(c.expiresAt,s)," · "]}):null,n.jsx("button",{type:"button",className:"wb-link",onClick:o,children:"See the full request on the Canvas"})]}),n.jsx(I,{variant:"ghost",size:"sm",disabled:j,onClick:()=>y("reject"),children:m==="reject"?"Rejecting…":"Reject"}),N?n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",size:"sm",disabled:j,onClick:()=>y("approve","conversation"),children:"Auto: this conversation"}),n.jsx(I,{size:"sm",disabled:j,onClick:()=>y("approve","always"),children:"Always: this agent"})]}):null,n.jsx(I,{variant:"good",size:"sm",disabled:j,onClick:()=>y("approve"),children:m==="approve"?"Approving…":N?"Allow once":"Approve"})]})]})}function EF(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const s of SF){const r=t[s];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function AF(e){const t=(e??"").split(`
99
- `).map(s=>s.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const TF=2e3;function RF({conversationId:e,agentId:t,runId:s=null,result:r=null,waiting:i=null,agents:a=[]}){const l=r!==null,[o,c]=h.useState(l),u=!o||i!==null,{data:f,error:d}=ie(()=>Le.conversation(e),[e,o,(i==null?void 0:i.approvalId)??null],u?TF:void 0),m=(f==null?void 0:f.runs)??[],p=s===null?null:m.find(j=>j.runId===s)??null,v=l||i===null&&(s!==null?p!==null&&p.finishedAt!==null:m.length>0&&m.every(j=>j.finishedAt!==null));h.useEffect(()=>{v&&c(!0)},[v]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":v?"done":"working",k=a.find(j=>j.id===t)??null,g=(k==null?void 0:k.name)??(f==null?void 0:f.agentId)??t,x=(f==null?void 0:f.messages)??[],y=(r==null?void 0:r.text)??IF(x);return n.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":w,children:[n.jsxs("header",{className:"wb-delegate-head",children:[n.jsx(vn,{agents:a,id:t}),n.jsxs("div",{className:"wb-delegate-who",children:[n.jsx("strong",{children:g}),n.jsx("span",{className:"wb-delegate-status","data-status":w,role:"status",children:w==="working"?n.jsxs(n.Fragment,{children:["Working",n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]}):w==="waiting"?"Waiting for your approval":w==="failed"?"Failed":"Done"})]})]}),d?n.jsx("p",{className:"muted",children:d}):null,n.jsx("div",{className:"wb-delegate-work",children:x.map((j,N)=>n.jsx("div",{className:"wb-delegate-turn",children:(j.blocks??[]).map((b,S)=>{if(b.type==="thinking")return b.text.trim()===""?null:n.jsx(Ym,{text:b.text},S);if(b.type==="tool_use"){const C=MF(PF(x,b.id));return n.jsx(qm,{label:Rs(b.name),tool:b.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:px(b.name,b.input),opens:!1,onOpen:()=>{}},S)}return null})},j.id??N))}),y?n.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:n.jsx(nr,{text:y})}):w==="working"||w==="waiting"?n.jsxs("p",{className:"muted",children:[g," has not answered yet."]}):null,r!=null&&r.files&&r.files.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${g} made`,"data-testid":"delegate-files",children:r.files.map(j=>n.jsx("a",{role:"listitem",href:Lr(j.artifactId),download:!0,children:n.jsx(_d,{name:j.filename??"Untitled file",mime:j.mime,sizeBytes:j.sizeBytes,thumbnail:ux(j.mime)?rr(j.artifactId):null})},j.artifactId))}):null,n.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?n.jsx(I,{variant:"accent",onClick:()=>kF(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,n.jsx("a",{className:"ui-btn",href:Ke(t||(f==null?void 0:f.agentId)||"",e),children:"Open this conversation"})]})]})}function IF(e){for(let t=e.length-1;t>=0;t-=1){const s=e[t];if(s.role!=="assistant")continue;const r=(s.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
100
-
101
- `);if(r!=="")return r}return null}function PF(e,t){for(const s of e)for(const r of s.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function MF(e){var s;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(s=e.approval)==null?void 0:s.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 Qy=1024*1024;function $F({files:e,agentId:t,root:s,revision:r}){const[i,a]=h.useState({kind:"dir",path:""});return h.useEffect(()=>a({kind:"dir",path:""}),[e.plugin,t]),n.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?n.jsx(DF,{files:e,agentId:t,root:s,path:i.path,revision:r,go:a}):n.jsx(OF,{files:e,agentId:t,root:s,path:i.path,revision:r,go:a})})}function p1({root:e,path:t,go:s}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((a,l)=>({label:a,path:r.slice(0,l+1).join("/")}))];return n.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((a,l)=>{const o=l===i.length-1;return n.jsxs("span",{className:"wb-files-crumb",children:[l>0?n.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,o?n.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:a.label}):n.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>s({kind:"dir",path:a.path}),children:a.label})]},a.path)})})}function DF({files:e,agentId:t,root:s,path:r,revision:i,go:a}){const[l,o]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(!1),[m,p]=h.useState(null);h.useEffect(()=>{let k=!1;return u(null),A.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(g=>{k||o(g.data)}).catch(g=>{k||u(g instanceof Error?g.message:String(g))}),()=>{k=!0}},[e.plugin,e.list,t,r,i]),h.useEffect(()=>p(null),[r]);const v=async()=>{d(!0),p(null);try{const k=await fetch(A.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!k.ok){const j=await k.json().catch(()=>null);p((j==null?void 0:j.error)??"The archive could not be made.");return}const g=await k.blob(),x=URL.createObjectURL(g),y=document.createElement("a");y.href=x,y.download=`${r===""?s:r.split("/").at(-1)}.zip`,y.click(),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)}catch{p("The archive could not be made.")}finally{d(!1)}},w=l&&l.path===r?l.entries:null;return n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[n.jsx(p1,{root:s,path:r,go:a}),n.jsx(sn,{}),n.jsx(I,{size:"sm",onClick:()=>void v(),disabled:f||w===null||w.length===0,children:f?"Packing…":"Download as archive"})]}),m?n.jsx(H,{tone:"warning",role:"alert",children:m}):null,c?n.jsx(H,{tone:"critical",role:"alert",children:c}):null,w===null?c?null:n.jsx(oe,{children:"Reading the folder…"}):w.length===0?n.jsx(oe,{children:r===""?n.jsxs(n.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",n.jsx("a",{href:bi,children:"Files library"})," and mention it here."]}):"This folder is empty."}):n.jsx(Ct,{children:w.map(k=>n.jsx(Et,{href:"#",onClick:()=>a({kind:k.kind,path:k.path}),lead:n.jsx(LF,{kind:k.kind}),title:n.jsxs("span",{className:"mono",children:[k.name,k.kind==="dir"?"/":""]}),side:k.kind==="file"?Cn(k.bytes):void 0},k.path))}),l&&l.path===r&&(l.skipped>0||l.truncated)?n.jsxs("p",{className:"wb-files-note",children:[l.truncated?`Only the first ${l.entries.length} entries are shown. `:"",l.skipped>0?`${l.skipped} ${l.skipped===1?"entry is":"entries are"} not shown: symbolic links and protected paths are never read.`:""]}):null]})}function OF({files:e,agentId:t,root:s,path:r,revision:i,go:a}){const[l,o]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(!1);h.useEffect(()=>{let g=!1;return u(null),A.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(x=>{g||o(x.data)}).catch(x=>{g||u(x instanceof Error?x.message:String(x))}),()=>{g=!0}},[e.plugin,e.stat,t,r,i]);const m=l&&l.path===r?l:null,p=m?`${m.bytes}-${Math.round(m.mtimeMs)}`:"",v=m?A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v:p}):"",w=A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),k=(m==null?void 0:m.type)==="text"&&m.bytes<=Qy;return n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[n.jsx(p1,{root:s,path:r,go:a}),n.jsx(sn,{}),k?n.jsx(I,{size:"sm","aria-pressed":f,onClick:()=>d(g=>!g),children:"Wrap"}):null,n.jsx(Yt,{size:"sm",href:w,download:(m==null?void 0:m.name)??r.split("/").at(-1),children:"Download"})]}),c?n.jsx(H,{tone:"critical",role:"alert",children:c}):null,m===null?c?null:n.jsx(oe,{children:"Reading the file…"}):m.type==="image"?n.jsx("figure",{className:"wb-files-picture",children:n.jsx("img",{src:v,alt:m.name})}):m.type==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:v,type:"application/pdf","aria-label":m.name,children:n.jsx(H,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):k?n.jsx(_F,{src:v,wrap:f}):n.jsxs(n.Fragment,{children:[n.jsx(H,{children:m.type==="text"?`This file is over ${Cn(Qy)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),n.jsx(Kt,{items:[{label:"Size",value:Cn(m.bytes)},{label:"Type",value:n.jsx("span",{className:"mono",children:m.mime})}]})]})]})}function _F({src:e,wrap:t}){const[s,r]=h.useState(null),[i,a]=h.useState(!1);return h.useEffect(()=>{let l=!1;return a(!1),fetch(e,{credentials:"same-origin"}).then(async o=>{if(!o.ok)throw new Error(String(o.status));const c=await o.text();l||r(c)}).catch(()=>{l||a(!0)}),()=>{l=!0}},[e]),i?n.jsx(H,{tone:"critical",children:"The file could not be read."}):s===null?n.jsx(oe,{children:"Reading the file…"}):s===""?n.jsx(oe,{children:"This file is empty."}):n.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:s})}function LF({kind:e}){return n.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:n.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"?n.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):n.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}const FF=3,UF=152,BF=104,zF=100,WF=2,Jy=5;function HF({renderables:e,activeId:t,onActivate:s,timezone:r,onDecided:i,onChangeAgent:a,face:l,descriptors:o,grantedTools:c,agentName:u,maxTabs:f,browserPanel:d,agents:m,onClose:p,loading:v=!1}){const[w,k]=VF(f);if(e.length===0)return n.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[n.jsx("div",{className:"wb-canvas-tabs",ref:w,"aria-hidden":"true",children:n.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),n.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:v?null:n.jsxs("div",{className:"wb-empty",children:[l?n.jsx("span",{className:"wb-empty-face",children:l}):null,n.jsx("p",{className:"ui-empty wb-empty-line",children:QF(u,JF(o??[],c??[]))})]})})]});const g=e.some(j=>j.id===t)?t:e[e.length-1].id,{shown:x,hidden:y}=KF(e,g,k);return n.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:n.jsxs(H$,{value:g,onValueChange:s,className:"contents",children:[n.jsxs("div",{className:"wb-canvas-tabs",ref:w,children:[n.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),n.jsx(V$,{className:"wb-tabstrip","aria-label":"Canvas",children:x.map(j=>n.jsxs("div",{className:"wb-tab-item",children:[n.jsxs(K$,{value:j.id,className:"wb-tab","data-tone":j.tone,onKeyDown:N=>{N.key==="Delete"&&p&&Xy(j)&&(N.preventDefault(),p(j.id))},children:[j.tone==="warning"||j.tone==="critical"?n.jsx("span",{className:"wb-tab-dot","data-tone":j.tone,"aria-hidden":"true"}):null,n.jsx("span",{className:"wb-tab-text",children:j.title})]}),p&&Xy(j)?n.jsx("button",{className:"wb-tab-close","aria-label":`Close ${j.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>p(j.id),children:"×"}):null]},j.id))}),n.jsx(GF,{items:y,onActivate:s,timezone:r})]}),e.map(j=>n.jsx(G$,{value:j.id,className:"wb-canvas-body","data-renderer":j.source==="descriptor"&&j.renderer==="preview"?"preview":void 0,"data-dense":ZF.has(j.renderer)?"true":void 0,children:n.jsxs("section",{className:"ui-panel","data-flush":j.source==="descriptor"&&j.renderer==="preview"?"true":void 0,children:[j.source!=="browser"&&j.source!=="files"&&!(j.source==="descriptor"&&j.renderer==="preview")?n.jsxs("header",{className:"ui-panel-head",children:[n.jsx("h2",{className:"ui-panel-title",children:j.title}),n.jsx("span",{className:"ui-panel-tool mono",children:j.tool})]}):null,j.tone==="critical"?n.jsxs("p",{className:"muted",children:["Recorded tool failure",j.at?` · ${new Date(j.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,j.source==="browser"?d:j.source==="profile"?n.jsx(dL,{...j.props,...a?{onChange:a}:{}}):j.source==="artifact"?n.jsx($L,{...j.props}):j.source==="files"?n.jsx($F,{...j.props}):j.source==="delegate"?n.jsx(RF,{...j.props,agents:m??[]}):n.jsx(uL,{renderer:j.renderer,props:j.props,timezone:r,onDecided:i})]})},j.id))]})})}function Xy(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function VF(e){const[t,s]=h.useState(Jy),r=h.useRef(null);return[h.useCallback(a=>{var o;if((o=r.current)==null||o.disconnect(),r.current=null,!a||e!==void 0||typeof ResizeObserver>"u")return;const l=()=>{const c=a.clientWidth;if(c===0)return;const u=Math.floor((c-zF-BF)/UF);s(Math.max(WF,Math.min(Jy,u)))};l(),r.current=new ResizeObserver(l),r.current.observe(a)},[e]),e??t]}function KF(e,t,s){const r=new Set(e.filter(a=>a.id===t||a.source==="approval"||a.pinned===!0).map(a=>a.id)),i=new Set(r);for(let a=e.length-1;a>=0&&i.size<s;a-=1)i.add(e[a].id);return{shown:e.filter(a=>i.has(a.id)),hidden:e.filter(a=>!i.has(a.id))}}function GF({items:e,onActivate:t,timezone:s}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return n.jsxs(Sd,{modal:!1,children:[n.jsx(Nd,{asChild:!0,children:n.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?n.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,n.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),n.jsx(Se,{name:"chevron-down"})]})}),n.jsx(So,{children:n.jsxs(Cd,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[n.jsx(Ed,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>n.jsxs(hi,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[n.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?n.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),n.jsx("span",{className:"ui-menu-note mono",children:YF(i.at,s)??i.tool})]},i.id))]})})]})}function YF(e,t){if(!e)return null;const s=new Date(e);return Number.isNaN(s.getTime())?null:new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit"}).format(s)}const qF={timeseries:"charts",table:"tables",bars:"comparisons",keyvalue:"figures",tiles:"cards",document:"pages it read",diff:"diffs",terminal:"command output",image:"pictures",preview:"running apps",envelope:"drafts",structured:"results"};function QF(e,t){const s=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>qF[i.renderer]??"results"))].slice(0,3);return r.length>0?`${s} lands here: ${r.join(", ")}.`:`${s} lands here.`}function JF(e,t){const s=new Set(t),r=new Set,i=e.filter(c=>{if(!s.has(c.tool))return!1;const u=XF(c);return r.has(u)?!1:(r.add(u),!0)}),a=new Set,l=i.filter(c=>a.has(c.renderer)?!1:(a.add(c.renderer),!0)),o=i.filter(c=>!l.includes(c));return[...l,...o].slice(0,FF)}function XF(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 ZF=new Set(["table","diff","files"]),e4=3.5*6e4,t4=2e3;function n4(e,t,s={}){const[r,i]=h.useState({served:new Set,live:new Set,scope:t}),a=h.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};a.current=u.served,i(u)}const l=s.check??A.previewCheck,o=s.everyMs??t4,c=e.map(u=>`${xa(u)}@${u.at??""}`).join("|");return h.useEffect(()=>{const u=new Map;for(const p of e){const v=xa(p);if(a.current.has(v))continue;const w=p.at===null?Number.NaN:Date.parse(p.at),k=Number.isNaN(w)?0:w+e4,g=u.get(v);(!g||k>g.until)&&u.set(v,{plugin:p.plugin,name:p.name,until:k})}if(u.size===0)return;let f=!1,d;const m=async()=>{const p=Date.now();for(const[v,w]of[...u]){const k=await l(w.plugin,w.name).catch(()=>null);if(f)return;const g=p<=w.until;k!=null&&k.ok?(u.delete(v),i(x=>{const y={served:new Set(x.served).add(v),live:g?new Set(x.live).add(v):x.live,scope:x.scope};return a.current=y.served,y})):g||u.delete(v)}!f&&u.size>0&&(d=setTimeout(()=>void m(),o))};return m(),()=>{f=!0,d!==void 0&&clearTimeout(d)}},[c,t,l,o]),r}const Qm="workspace-files";function s4(e){let t=0;for(const s of e)for(const r of s.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:a,path:l}=i;typeof a=="string"&&a.trim()!==""&&typeof l=="string"&&l!==""&&(t+=1)}return t}function r4(e){const[t,s]=h.useState(null);return h.useEffect(()=>{if(s(null),!e)return;let r=!1;return(async()=>{var a;const i=await A.pages();for(const l of Array.isArray(i==null?void 0:i.files)?i.files:[]){const o=await A.pageQuery(l.plugin,l.workspace,{agent:e}).catch(()=>null),c=(a=o==null?void 0:o.data)==null?void 0:a.workspace;if(c&&typeof c.name=="string")return{files:l,agentId:e,root:c.name}}return null})().then(i=>{r||s(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function i4(e,t){return{id:Qm,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 Jm(e){return`agent-properties:${e}`}function a4(e){return{id:Jm(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function l4(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 g1({progress:e}){return n.jsxs(q,{gap:"sm",children:[n.jsx("span",{role:"status",children:l4(e)}),n.jsx(LN,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function o4(e,t,s,r){const i=e.width||1,a=e.height||1,l=t.pageScaleFactor||1,o=(s-e.left)*(t.deviceWidth/i)/l,c=((r-e.top)*(t.deviceHeight/a)-t.offsetTop)/l,u=(f,d)=>Math.max(0,Math.min(Math.round(f),Math.round(d)));return{x:u(o,t.deviceWidth),y:u(c,t.deviceHeight)}}function Yh(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function Zy(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const c4=4e3;function u4(e){return e.replace(/\r\n?/g,`
102
- `).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,c4)}const d4=["left","middle","right"],h4=33;function f4(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function m4(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const s=t.getUint16(1);if(e.byteLength<3+s)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,s))),jpeg:new Blob([new Uint8Array(e,3+s)],{type:"image/jpeg"})}}catch{return null}}function p4(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function g4({sessionId:e,csrf:t,onGiveBack:s,connect:r}){const[i,a]=h.useState("connecting"),[l,o]=h.useState(null),[c,u]=h.useState(!1),[f,d]=h.useState(null),[m,p]=h.useState(!1),[v,w]=h.useState(0),k=h.useRef(null),g=h.useRef(null),x=h.useRef(null),y=h.useRef({at:0});h.useEffect(()=>{const T=r??(K=>new WebSocket(K));let $=!0,_;try{_=T(p4())}catch{a("lost");return}return _.binaryType="arraybuffer",k.current=_,_.onopen=()=>_.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),_.onmessage=K=>{if(!$)return;if(typeof K.data!="string"){const Y=m4(K.data);if(!Y||(d(B=>B&&f4(B,Y.metadata)?B:Y.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(Y.jpeg).then(B=>{var de,ae,le;const V=g.current;if(!$||!V){(de=B.close)==null||de.call(B);return}(V.width!==B.width||V.height!==B.height)&&(V.width=B.width,V.height=B.height),(ae=V.getContext("2d"))==null||ae.drawImage(B,0,0),(le=B.close)==null||le.call(B)}).catch(()=>{});return}const D=JSON.parse(K.data);if(D.type==="driving"){a("driving"),o(null);return}(D.type==="refused"||D.type==="ended")&&(o(D.error??"The screen cannot be driven from here."),a("refused"))},_.onclose=()=>{$&&a(K=>K==="refused"?K:"lost")},_.onerror=()=>{$&&a(K=>K==="refused"?K:"lost")},()=>{$=!1,k.current=null;try{_.close()}catch{}}},[e,t,v,r]),h.useEffect(()=>()=>{clearTimeout(y.current.timer)},[]);const j=h.useCallback(T=>{const $=k.current;if($)try{$.send(JSON.stringify({type:"input",input:T}))}catch{}},[]),N=T=>{var K;const $=g.current;if(!$||!f)return null;const _=(K=$.getBoundingClientRect)==null?void 0:K.call($);return _?o4(_,f,T.clientX,T.clientY):null},b=T=>{const $=y.current,_=Date.now();clearTimeout($.timer),$.timer=void 0;const K=$.at+h4-_;if(K<=0){$.at=_,$.pending=void 0,j(T);return}$.pending=T,$.timer=setTimeout(()=>{const D=y.current.pending;y.current.timer=void 0,y.current.pending=void 0,y.current.at=Date.now(),D&&j(D)},K)},S=()=>{const T=y.current;clearTimeout(T.timer),T.timer=void 0;const $=T.pending;T.pending=void 0,$&&(T.at=Date.now(),j($))},C=T=>$=>{var D,Y;const _=N($);if(!_)return;T==="mousePressed"&&($.preventDefault(),(Y=(D=g.current)==null?void 0:D.focus)==null||Y.call(D));const K={kind:"mouse",type:T,x:_.x,y:_.y,button:d4[$.button]??"left",clickCount:T==="mouseMoved"?0:Math.min(3,Math.max(1,$.detail||1)),modifiers:Yh($)};if(T==="mouseMoved"){b(K);return}S(),j(K)},R=T=>{const $=N(T);$&&(S(),j({kind:"wheel",x:$.x,y:$.y,deltaX:Math.round(T.deltaX),deltaY:Math.round(T.deltaY)}))},E=T=>T.ctrlKey||T.metaKey||T.altKey,P=T=>{var _,K;if(T.key==="Escape"&&E(T)){p(!1),(K=(_=T.target).blur)==null||K.call(_);return}if(T.preventDefault(),(T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))return;const $=Yh(T);if(Zy(T.key)&&!E(T)){j({kind:"key",type:"char",key:T.key,code:T.code,text:T.key,modifiers:$});return}j({kind:"key",type:"keyDown",key:T.key,code:T.code,modifiers:$})},F=T=>{T.key==="Escape"&&E(T)||(T.preventDefault(),!((T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))&&(Zy(T.key)&&!E(T)||j({kind:"key",type:"keyUp",key:T.key,code:T.code,modifiers:Yh(T)})))},M=T=>{var _;T.preventDefault();const $=u4(((_=T.clipboardData)==null?void 0:_.getData("text/plain"))??"");$!==""&&j({kind:"text",text:$})};return n.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[n.jsxs("div",{className:"hand-bar",children:[n.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",variant:m?"accent":"ghost","aria-pressed":m,onClick:()=>{var $,_,K,D;const T=!m;p(T),T?(_=($=x.current)==null?void 0:$.focus)==null||_.call($):(D=(K=x.current)==null?void 0:K.blur)==null||D.call(K)},children:"Keyboard"}),n.jsx(I,{size:"sm",variant:"accent",onClick:s,children:"Give it back"})]})]}),i==="lost"?n.jsxs(H,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",variant:"accent",onClick:()=>{a("connecting"),w(T=>T+1)},children:"Reconnect"})})]}):null,i==="refused"&&l?n.jsx(H,{tone:"warning",role:"status",children:l}):null,n.jsx("div",{className:"hand-screen",children:c?n.jsx("canvas",{ref:g,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:R,onKeyDown:P,onKeyUp:F,onPaste:M,onContextMenu:T=>T.preventDefault()}):n.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),n.jsx("input",{ref:x,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:P,onKeyUp:F,onPaste:M,onBlur:()=>p(!1)})]})}function x4(e){return e==="darwin"?"this Mac":"this computer"}let qh=null;function jx(){const[e,t]=h.useState(void 0);return h.useEffect(()=>{let s=!0;return qh??(qh=A.session().then(r=>r.platform,()=>{qh=null})),qh.then(r=>{s&&t(r)}),()=>{s=!1}},[]),x4(e)}function v4({embedded:e,timezone:t}={}){var c;const{data:s,error:r,reload:i}=ie(()=>A.browser(),[],3e3),a=ie(()=>A.session(),[]),l=(c=a.data)!=null&&c.platform?a.data.platform==="darwin":!0,o=!!a.data||!!a.error;return n.jsxs(mn,{embedded:e,title:"Computer & browser",children:[n.jsx(ne,{message:r}),!s||!o?n.jsx(oe,{children:"Checking the host…"}):n.jsx(j4,{data:s,macOS:l,reload:i,timezone:t},JSON.stringify(s.settings??null))]})}function j4({data:e,macOS:t,reload:s,timezone:r}){var S,C,R;const[i,a]=h.useState(!1),[l,o]=h.useState(null),[c,u]=h.useState(!1),f=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,d=(f==null?void 0:f.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),m=d==="computer",p=(S=e.sessions)!=null&&S.length?e.sessions:e.session?[e]:[],v=p.length>0||e.busy,w=async E=>{a(!0),o(null);try{await E()}catch(P){o(P instanceof Error?P.message:String(P))}finally{a(!1),s()}},k=E=>void w(()=>A.browserSettings(E)),g=e.permissions,x=d==="playwright"?e.browser:void 0,y=((C=x==null?void 0:x.install)==null?void 0:C.state)==="running",j=(x==null?void 0:x.engine)==="none",N=!!e.enabled&&!j&&!(x!=null&&x.problem)&&(!m||!(g!=null&&g.supported)||g.accessibility&&g.screenRecording),b=m?"Ready. Agents can use your computer within the apps you allow below.":d==="extension"?"Ready. Agents work in your Chrome, in background tabs, through the buddi extension.":(x==null?void 0:x.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 n.jsxs(q,{gap:"lg",children:[n.jsx(ne,{message:l}),n.jsx(J,{title:"Status",panel:!0,actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",disabled:i,onClick:()=>void w(()=>A.computerPermissions(!1)),children:"Check again"}),m&&!N&&(g!=null&&g.supported)?n.jsx(I,{size:"sm",variant:"accent",disabled:i||v,onClick:()=>void w(()=>A.computerPermissions(!0)),children:"Request macOS permissions"}):null,j||y?n.jsx(I,{size:"sm",variant:"accent",disabled:i||y,onClick:()=>void w(()=>A.browserInstall()),children:y?"Installing…":"Install Chromium"}):null]}),children:n.jsxs(q,{children:[e.enabled?j?n.jsxs(H,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",n.jsx("code",{children:"buddi browser install"})," on this machine."]}):x!=null&&x.problem?n.jsx(H,{tone:"warning",children:x.message}):N?n.jsx(H,{tone:"good",children:b}):n.jsx(H,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):n.jsx(H,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),m?g!=null&&g.supported?n.jsxs("ul",{className:"perm-list",children:[n.jsxs("li",{className:"perm-row",children:[n.jsx(xe,{tone:g.accessibility?"good":"warning",children:g.accessibility?"Granted":"Needed"}),n.jsx("span",{className:"perm-name",children:"Accessibility"}),n.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),n.jsxs("li",{className:"perm-row",children:[n.jsx(xe,{tone:g.screenRecording?"good":"warning",children:g.screenRecording?"Granted":"Needed"}),n.jsx("span",{className:"perm-name",children:"Screen Recording"}),n.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):g?n.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,((R=x==null?void 0:x.install)==null?void 0:R.state)==="running"?n.jsx(g1,{progress:x.install.progress}):x!=null&&x.install?n.jsx("p",{className:"muted",role:"status",children:x.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${x.install.line??"no reason given"}`}):null,x!=null&&x.headless&&!j?n.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,m&&(g!=null&&g.message)?n.jsx("p",{className:"muted",children:g.message}):null,m&&(g!=null&&g.supported)&&!N?n.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),n.jsx(J,{title:"Who is driving",panel:!0,actions:p.length>0?n.jsx(I,{variant:"danger",size:"sm",disabled:i,onClick:()=>void w(()=>A.browserControl("stop")),children:m?"Stop computer control":"Stop all browsers"}):void 0,children:p.length===0?n.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."}):n.jsx("div",{className:"ui-list",children:p.map(E=>n.jsxs("a",{className:"ui-list-row",href:Ke(E.session.agentId,E.session.conversationId),children:[n.jsx(ps,{id:E.session.agentId,name:E.session.agentId,size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:E.session.task}),n.jsxs("span",{className:"ui-list-sub",children:[E.session.agentId,", ",E.busy?"working":E.state,", ",E.session.steps," of ",E.session.maxSteps," steps"]})]}),n.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},E.session.id))})}),f?n.jsxs(n.Fragment,{children:[n.jsx(J,{title:"How agents get a screen",panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?n.jsx(Qh,{current:f.mode,value:"computer",disabled:i||v||!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:()=>k({...f,mode:"computer"})}):null,n.jsx(Qh,{current:f.mode,value:"playwright",disabled:i||v||!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:()=>k({...f,mode:"playwright"})}),n.jsx(Qh,{current:f.mode,value:"extension",disabled:i||v||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>k({...f,mode:"extension"})})]}),t?null:n.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),v?n.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,f.mode==="extension"?n.jsx(k4,{busy:i,timezone:r}):null]})}),t?n.jsx(J,{title:"Apps agents may use",panel:!0,children:n.jsxs(q,{children:[f.mode!=="computer"?n.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,n.jsx(S4,{settings:f,disabled:i||v||!e.enabled,onChange:k,onAdd:()=>u(!0)}),n.jsx(Tt,{summary:"Details",children:n.jsxs("div",{className:"ui-prose muted",children:[n.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."}),n.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."}),n.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?n.jsx(T4,{chosen:f.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),f.allowedApps.includes(E)||k({...f,allowedApps:[...f.allowedApps,E]})}}):null]}):null]})}const y4="kmbckpnnjfggeffkkbmkggojnolkdokb";async function w4(){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(y4,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function b4(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function k4({busy:e,timezone:t}){const{data:s,error:r,reload:i}=ie(()=>A.extension(),[],3e3),a=jx(),l=ie(()=>w4(),[],3e3).data??null,[o,c]=h.useState(""),[u,f]=h.useState(!1),[d,m]=h.useState(null),p=(l==null?void 0:l.state)==="pairing"?l.code??"":"";h.useEffect(()=>{p&&c(p)},[p]);const v=async x=>{f(!0),m(null);try{await x()}catch(y){m(y instanceof Error?y.message:String(y))}finally{f(!1),i()}},w=e||u,k=t??Intl.DateTimeFormat().resolvedOptions().timeZone,g=n.jsxs("div",{className:"ui-prose muted",children:[n.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),n.jsx(Nt,{label:"The unpacked extension",children:(s==null?void 0:s.path)??"…"})]});return n.jsxs(q,{divided:!0,children:[n.jsx(ne,{message:r??d}),n.jsxs(Q,{children:[n.jsx(xe,{tone:s!=null&&s.connected?"good":"warning",children:s!=null&&s.connected?"Connected":"Not connected"}),n.jsxs("span",{className:"muted",children:[s!=null&&s.connected&&s.pairedAt?`Paired with Chrome on ${a} since ${Ve(s.pairedAt,k)}`:s!=null&&s.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",s!=null&&s.extension?` · extension ${s.extension}`:""]})]}),n.jsxs(q,{children:[n.jsxs("p",{className:"muted",children:[l?`The browser you are reading this in has the extension, version ${l.version}.`:s!=null&&s.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.",(l==null?void 0:l.state)==="paired"?" It is already paired with a buddi.":"",(l==null?void 0:l.state)==="disconnected"?" It is not connected yet: press Connect in its popup.":""]}),l&&!b4(l.gateway)?n.jsx(H,{tone:"warning",children:`The extension is pointed at ${l.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),s!=null&&s.pending?n.jsxs(Q,{valign:"end",children:[n.jsx(te,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:n.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:o,onChange:x=>c(x.target.value)})}),n.jsx(sn,{}),n.jsx(I,{variant:"accent",disabled:w||o.replace(/[^0-9]/g,"").length!==6,onClick:()=>void v(async()=>{await A.pairExtension(o),c("")}),children:"Pair"})]}):null,s!=null&&s.connected?n.jsx(Tt,{summary:"Pair a different browser",children:g}):g,n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"danger",disabled:w||!(s!=null&&s.pairedAt),onClick:()=>void v(()=>A.forgetExtension()),children:"Forget this browser"})})]})}function Qh({current:e,value:t,title:s,body:r,disabled:i,onPick:a}){const l=e===t;return n.jsxs("button",{type:"button",role:"radio","aria-checked":l,className:"mode-option",disabled:i,onClick:()=>{l||a()},children:[n.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),n.jsxs("span",{className:"mode-option-text",children:[n.jsx("span",{className:"mode-option-title",children:s}),n.jsx("span",{className:"mode-option-body",children:r})]})]})}function S4({settings:e,disabled:t,onChange:s,onAdd:r}){const i=ie(()=>A.installedApps(),[]),a=l=>{var o,c;return((c=(o=i.data)==null?void 0:o.apps.find(u=>u.id===l))==null?void 0:c.name)??l};return n.jsxs(n.Fragment,{children:[e.allowedApps.length===0?n.jsx(oe,{children:"No apps yet. Agents cannot touch anything until you add one."}):n.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(l=>n.jsxs("li",{className:"ui-list-row",children:[n.jsx(ps,{id:l,name:a(l),size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[a(l),l===e.browserApp?n.jsx(xe,{tone:"accent",className:"app-role",children:"browser"}):null]}),n.jsx("span",{className:"ui-list-sub mono",children:l})]}),n.jsxs(Q,{children:[l!==e.browserApp&&A4(l)?n.jsx(I,{size:"sm",variant:"ghost",disabled:t,onClick:()=>s({...e,browserApp:l}),children:"Use as browser"}):null,l===e.browserApp?n.jsx("span",{className:"muted",children:"In use as the browser"}):n.jsx(I,{size:"sm",variant:"ghost",disabled:t,onClick:()=>s({...e,allowedApps:e.allowedApps.filter(o=>o!==l)}),children:"Remove"})]})]},l))}),n.jsxs(Q,{children:[n.jsx(I,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),n.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&N4.includes(e.browserApp)?n.jsx(C4,{settings:e,disabled:t,onChange:s}):null]})}const N4=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function C4({settings:e,disabled:t,onChange:s}){var l;const i=((l=ie(()=>A.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:l.profiles)??[],a=e.browserProfile?i.some(o=>o.directory===e.browserProfile):!0;return n.jsx(te,{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:n.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:o=>{const{browserProfile:c,...u}=e;s(o.target.value?{...u,browserProfile:o.target.value}:u)},children:[n.jsx("option",{value:"",children:"Whichever is in front"}),!a&&e.browserProfile?n.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(o=>n.jsxs("option",{value:o.directory,children:[o.name,o.directory==="Default"?"":` (${o.directory})`]},o.directory))]})})}const E4=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function A4(e){return E4.includes(e)}function T4({chosen:e,onClose:t,onPick:s}){const r=ie(()=>A.installedApps(),[]),[i,a]=h.useState(""),[l,o]=h.useState(""),c=h.useMemo(()=>{var d;const u=((d=r.data)==null?void 0:d.apps)??[],f=i.trim().toLowerCase();return u.filter(m=>!f||m.name.toLowerCase().includes(f)||m.id.toLowerCase().includes(f)).slice(0,60)},[r.data,i]);return n.jsxs(Dt,{title:"Add an app",onClose:t,children:[n.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>a(u.target.value)}),n.jsx(ne,{message:r.error}),r.data?c.length===0?n.jsx(oe,{children:"No app matches."}):n.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const f=e.includes(u.id);return n.jsxs("li",{className:"ui-list-row",children:[n.jsx(ps,{id:u.id,name:u.name,size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:u.name}),n.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),n.jsx(I,{size:"sm",disabled:f,onClick:()=>s(u.id),children:f?"Allowed":"Allow"})]},u.id)})}):n.jsx(oe,{children:"Reading your Applications folder…"}),n.jsx(Tt,{summary:"Add by bundle identifier instead",children:n.jsxs(Q,{children:[n.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:l,onChange:u=>o(u.target.value)}),n.jsx(I,{disabled:!l.trim(),onClick:()=>s(l.trim()),children:"Allow this identifier"})]})})]})}function R4({data:e,error:t,reload:s,compact:r=!1,refresh:i,screenshotSrc:a,onScreenshotError:l,onScreenshotLoad:o,controls:c=!0}){var R,E,P;const[u,f]=h.useState(!1),[d,m]=h.useState(null),[p,v]=h.useState(null),[w,k]=h.useState(null),g=async F=>{f(!0),m(null),k(null);try{const M=F!=="stop"&&(e!=null&&e.session)?await A.browserControl(F,e.session.id):await A.browserControl(F);F==="takeover"?M.hand&&M.session?v(M.session.id):k(M.handMessage??null):v(null)}catch(M){m(M instanceof Error?M.message:String(M))}finally{f(!1),s()}},x=p&&((R=e==null?void 0:e.session)==null?void 0:R.id)===p&&e.state==="paused"?p:null,y=!!(e!=null&&e.enabled)&&!u,j=(e==null?void 0:e.mode)==="computer",N=(e==null?void 0:e.mode)==="extension",b=j?"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.",S=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 n.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[n.jsxs("div",{className:"browser-heading",children:[n.jsxs("div",{children:[r?null:n.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),n.jsx("h2",{className:"browser-title",children:j?"Computer":N?"Your browser":"Browser"})]}),n.jsx(xe,{tone:C,children:n.jsx("span",{role:"status",children:S})})]}),r?n.jsx("a",{className:"browser-full-view",href:"#/browser",children:j?"Open computer view & settings ↗":"Open full browser view ↗"}):n.jsx("p",{className:"ui-page-lede",children:j?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":N?"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."}),n.jsx(ne,{message:t??d}),c?n.jsxs(Q,{children:[n.jsx(I,{variant:"danger",disabled:!y||(e==null?void 0:e.state)==="stopped",onClick:()=>void g("stop"),children:j?"Stop computer control":"Stop all browsers"}),n.jsx(I,{disabled:!y||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void g("takeover"),children:"Take over"}),n.jsx(I,{disabled:!y||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void g("resume"),children:"Resume access"}),n.jsx(I,{disabled:!y||!(e!=null&&e.session),onClick:()=>void g("release"),children:j?"Release control":"Close & release"})]}):null,c?r?n.jsx(Tt,{summary:"About these controls",children:n.jsx("p",{className:"muted",children:b})}):n.jsx("p",{className:"muted",children:b}):null,w?n.jsx(H,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!x?n.jsx(H,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?n.jsxs("div",{className:"browser-task",children:[n.jsxs("div",{className:"ui-row",children:[n.jsx("strong",{children:e.session.agentId}),n.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:n.jsx("p",{children:e.session.task}),n.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",new Date(e.session.expiresAt).toLocaleTimeString()]})]}):n.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?j?"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."}),x?n.jsx(g4,{sessionId:x,csrf:Ai(),onGiveBack:()=>void g("resume")}):null,n.jsxs("div",{className:"browser-window",hidden:!!x,children:[n.jsxs("div",{className:"browser-address",children:[n.jsx("span",{"aria-hidden":"true",children:"◉"}),n.jsx("span",{children:((E=e==null?void 0:e.page)==null?void 0:E.url)??(j?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?n.jsxs("figure",{children:[n.jsx("img",{src:a??`/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}`,...l?{onError:l}:{},...o?{onLoad:o}:{}},a??e.page.id),n.jsxs("figcaption",{children:["Last observation · ",new Date(e.page.capturedAt).toLocaleTimeString()," · ",e.page.title||"Untitled page"]})]}):n.jsxs("div",{className:"browser-empty",children:[n.jsx("strong",{children:j?"Your selected app will appear here":"Your browser activity will appear here"}),n.jsx("p",{children:j?"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."})]})]}),(((P=e==null?void 0:e.page)==null?void 0:P.tabs.length)??0)>1?n.jsx(Tt,{summary:`${e.page.tabs.length} open tabs`,children:n.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(F=>n.jsxs("li",{children:[F.title||F.id," — ",F.url]},F.id))})}):null,n.jsxs("p",{className:"muted",children:[j?"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."," ",x?"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 I4=2e3,P4=5;function M4(e,t){if(!e.hasScreenshot||!e.page)return null;const s=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${s}`}function $4({status:e,error:t,reload:s,steps:r,live:i,focusedStepId:a=null}){var y;const[l,o]=h.useState(0),[c,u]=h.useState(0),f=c>=P4;h.useEffect(()=>{if(!i||f)return;const j=window.setInterval(()=>{typeof document<"u"&&document.hidden||o(N=>N+1)},I4);return()=>window.clearInterval(j)},[i,f]);const d=h.useRef(null);i&&(e!=null&&e.session)&&(d.current=e);const[m,p]=h.useState(null),v=h.useRef(null),w=((y=e==null?void 0:e.page)==null?void 0:y.id)??null;h.useEffect(()=>{const j=i&&e?M4(e):null;if(!j||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let N=!1;return(async()=>{try{const b=await fetch(j);if(!b.ok||N)return;const S=await b.blob();if(N)return;const C=URL.createObjectURL(S);v.current&&URL.revokeObjectURL(v.current),v.current=C,p(C)}catch{}})(),()=>{N=!0}},[i,w]),h.useEffect(()=>()=>{v.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(v.current)},[]);const k=d.current,g=i?e:k?m?k:{...k,hasScreenshot:!1}:e,x=r.at(-1)??null;return n.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[n.jsx(R4,{data:g,error:t,reload:s,compact:!0,controls:i,...i?{refresh:l}:{},...!i&&m?{screenshotSrc:m}:{},onScreenshotError:()=>u(j=>j+1),onScreenshotLoad:()=>u(0)}),i?f?n.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:n.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."}),n.jsx(D4,{steps:r,newestId:(x==null?void 0:x.id)??null,focusedId:a??null,live:i})]})}function D4({steps:e,newestId:t,focusedId:s,live:r}){const i=h.useRef(null);return h.useEffect(()=>{var l;if(!s||!i.current)return;const a=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(s):s}"]`);(l=a==null?void 0:a.scrollIntoView)==null||l.call(a,{block:"nearest"})},[s]),e.length===0?n.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):n.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:n.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((a,l)=>{const o=a.awaiting?"awaiting":a.ok===null?"running":a.ok?"ok":"failed";return n.jsxs("li",{"data-step":a.id,className:"wb-browser-step","data-state":o,"data-newest":a.id===t?"true":void 0,"data-focused":a.id===s?"true":void 0,children:[n.jsx("span",{className:"wb-browser-index mono",children:l+1}),n.jsxs("span",{className:"wb-browser-what",children:[n.jsx("strong",{children:a.action}),a.target?n.jsx("span",{className:"muted wb-browser-target",children:a.target}):null,a.error?n.jsx("span",{className:"wb-browser-error",children:a.error}):null]}),n.jsx("span",{className:"wb-browser-outcome","data-state":o,children:o==="awaiting"?"Awaiting approval":o==="running"?"Working":o==="ok"?"Done":"Failed"})]},a.id)})})})}function O4({agentId:e,conversationId:t}){const{data:s,error:r,reload:i}=ie(()=>A.host(e,t),[e,t],2e3),[a,l]=h.useState(null),[o,c]=h.useState(!1),u=async p=>{c(!0),l(null);try{await p(),i()}catch(v){l(v instanceof Error?v.message:String(v))}finally{c(!1)}},f=(s==null?void 0:s.permissions)??[],d=(s==null?void 0:s.runs)??[],m=f.some(p=>!p.conversationId)?"Always allowed":f.length?"Conversation auto-mode":"Ask each time";return n.jsx(Tt,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":m}${d.length?` · ${d.length} running`:""}`,children:n.jsxs(q,{gap:"sm",children:[n.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."}),n.jsx(ne,{message:a??r}),f.map(p=>n.jsxs(Q,{children:[n.jsxs("span",{children:[p.agentId,": ",p.conversationId?"conversation auto-mode":"always allowed"]}),n.jsx(I,{size:"sm",disabled:o,onClick:()=>void u(()=>A.revokeHost(p.id)),children:"Revoke permission"})]},p.id)),f.length?null:n.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),d.map(p=>n.jsxs(q,{gap:"sm",children:[n.jsxs("p",{children:[p.agentId," · ",n.jsx("span",{className:"mono",children:p.cwd})]}),n.jsx(Nt,{children:p.command}),n.jsx(Nt,{label:"Command output",children:p.stdout||p.stderr?`${p.stdout}
103
- ${p.stderr}`:"Waiting for output…"}),n.jsx(Q,{children:n.jsx(I,{size:"sm",variant:"danger",disabled:o,onClick:()=>void u(()=>A.stopHost(p.agentId,p.conversationId)),children:"Stop command"})})]},p.actionId))]})})}const x1="browser.act",_4="browser.status",Xc=new Set([x1,_4]);function L4(e,t,s){const r=e==null?void 0:e.session;return!r||!t||!s||r.agentId!==t||r.conversationId!==s?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 F4(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function U4(e){var r;const t=[],s=new Map;for(const i of e)for(const a of i.blocks??[]){if(a.type==="tool_use"&&a.name===x1){const o={id:a.id,action:B4(a.input)??"act",target:z4(a.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(o),s.set(a.id,o);continue}if(a.type!=="tool_result")continue;const l=s.get(a.toolUseId);if(l){if(((r=a.approval)==null?void 0:r.state)==="pending"){l.awaiting=!0,l.ok=null,l.error=null;continue}l.awaiting=!1,l.ok=a.ok,l.error=a.ok?null:W4(a)}}return t}function ew(e,t){var r;let s=!1;for(const i of e)for(const a of i.blocks??[])if(a.type==="tool_use"&&a.id===t&&(s=Xc.has(a.name)),a.type==="tool_result"&&a.toolUseId===t&&((r=a.approval)==null?void 0:r.state)==="pending")return null;return s?t:null}function B4(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function z4(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 s=t.target;if(s!==null&&typeof s=="object"){const r=s,i=r.name;if(typeof i=="string"&&i!=="")return i;const a=r.ref;if(typeof a=="string"&&a!=="")return a;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function W4(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 s of["message","error","reason"]){const r=t[s];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function H4({agentId:e,groupId:t,currentId:s,timezone:r,onSelect:i,onNew:a}){const[l,o]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(0);return h.useEffect(()=>{let m=!1;return o(null),u(null),(t?Le.groupConversations(t):Le.conversations(e,100)).then(p=>{m||o(p.conversations)}).catch(p=>{m||u(p instanceof Error?p.message:String(p))}),()=>{m=!0}},[e,t,f]),n.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[n.jsxs("div",{className:"ui-toolbar",children:[n.jsx("strong",{children:"Past conversations"}),n.jsx("button",{className:"ui-btn",onClick:a,children:"New conversation"})]}),c?n.jsxs("p",{role:"alert",children:[c," ",n.jsx("button",{className:"ui-btn",onClick:()=>d(m=>m+1),children:"Retry"})]}):l===null?n.jsx("p",{className:"muted",children:"Loading conversations…"}):l.length===0?n.jsx("p",{className:"muted",children:"No conversations yet."}):n.jsx("ul",{children:l.map(m=>n.jsx("li",{children:n.jsxs("a",{href:t?Tl(t,m.id):Ke(e,m.id),"aria-current":m.id===s?"page":void 0,onClick:p=>{p.button===0&&!p.metaKey&&!p.ctrlKey&&!p.shiftKey&&!p.altKey&&(p.preventDefault(),i(m.id))},children:[n.jsx("span",{children:m.preview||m.opening||"Untitled conversation"}),n.jsxs("small",{children:[Ve(m.lastMessageAt??m.startedAt??m.createdAt??null,r)," · ",m.messageCount," messages",m.id===s?" · Current":""]})]})},m.id))}),n.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(l==null?void 0:l.length)===100?n.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const v1="buddi.dismissedTabs";function V4(){try{const e=JSON.parse(sessionStorage.getItem(v1)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(s=>typeof s=="string")))}catch{return{}}}function tw(e){try{sessionStorage.setItem(v1,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const K4=350,G4=60;function Y4({conversationId:e,onText:t,onNotice:s}){const[r,i]=h.useState("idle"),a=h.useRef("idle"),l=x=>{a.current=x,i(x)},o=h.useRef(null),c=h.useRef(null),u=h.useRef(null),f=h.useRef(null),d=h.useRef(null),m=h.useRef({onText:t,onNotice:s,conversationId:e});m.current={onText:t,onNotice:s,conversationId:e};const p=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},v=async()=>{if(a.current!=="idle")return;m.current.onNotice(null),l("starting"),c.current=null;let x;try{x=await kL(N=>{var b;return(b=d.current)==null?void 0:b.call(d,N)})}catch(N){f.current=null,l("idle"),m.current.onNotice(bL(N));return}const y=c.current;c.current=null;const j=a.current;if(y==="discard"||j!=="starting"){x.cancel(),j==="starting"&&l("idle");return}o.current=x,l("recording"),u.current=window.setTimeout(()=>void w(!1),jL),y&&w(y.sendNow)},w=async x=>{f.current=null;const y=o.current;if(!y){a.current==="starting"&&(c.current={sendNow:x});return}o.current=null,p(),l("transcribing");try{const j=await y.stop();if(j.size<=44){m.current.onNotice("Nothing was recorded.");return}const N=new File([j],`recording-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.wav`,{type:"audio/wav"}),b=await Le.attach(N),S=m.current.conversationId,C=await Le.transcribe({artifactId:b.artifactId,...S?{conversationId:S}:{}});m.current.onText(C.text,x)}catch(j){m.current.onNotice(j instanceof he||j instanceof Error?j.message:String(j))}finally{l("idle")}},k=()=>{f.current=null;const x=o.current;if(!x){a.current==="starting"&&(c.current="discard");return}o.current=null,p(),x.cancel(),l("idle")};h.useEffect(()=>{const x=y=>{if(f.current===null)return;const j=Date.now()-f.current;f.current=null,j>=K4&&w(y.shiftKey)};return window.addEventListener("pointerup",x),()=>window.removeEventListener("pointerup",x)},[]);const g=r==="starting"||r==="recording";return h.useEffect(()=>{if(!g)return;const x=y=>{y.isComposing||y.repeat||(y.key==="Escape"?(y.preventDefault(),y.stopPropagation(),k()):y.key==="Enter"&&(y.preventDefault(),y.stopPropagation(),w(y.shiftKey)))};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[g]),h.useEffect(()=>()=>{var x;(x=o.current)==null||x.cancel(),p()},[]),{state:r,hold:()=>{f.current=Date.now(),v()},start:()=>{f.current=null,v()},finish:x=>void w(x),discard:k,levels:d}}function q4({disabled:e,voice:t}){const s=i=>{e||i.button>0||t.state!=="idle"||(i.preventDefault(),t.hold())},r=i=>{i.detail!==0||e||t.state!=="idle"||t.start()};return n.jsx("button",{type:"button",className:"ui-icon-btn wb-mic","data-size":"sm","aria-label":"Talk",title:"Talk: click to start, or hold to speak and let go to stop",disabled:e,onPointerDown:s,onClick:r,onContextMenu:i=>i.preventDefault(),children:n.jsx(Se,{name:"mic"})})}function Q4({voice:e}){const t=h.useRef(null),s=e.state==="transcribing";return h.useEffect(()=>{var r;(r=t.current)==null||r.focus()},[]),n.jsxs("div",{className:"wb-listening",role:"group","aria-label":"Recording","data-phase":s?"transcribing":"listening",children:[n.jsx("p",{className:"wb-listening-label","aria-live":"polite",children:s?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"wb-listening-spinner","aria-hidden":"true"}),"Transcribing…"]}):"Listening…"}),n.jsxs("div",{className:"wb-listening-row",children:[n.jsx(J4,{sink:e.levels,frozen:s}),n.jsx("button",{type:"button",className:"wb-send","data-variant":"quiet","aria-label":"Discard recording",title:"Discard (Escape)",disabled:s,onClick:()=>e.discard(),children:n.jsx(Se,{name:"close"})}),n.jsx("button",{ref:t,type:"button",className:"wb-send","aria-label":"Stop and transcribe",title:"Stop and transcribe (Enter); Shift sends at once",disabled:s,onClick:r=>e.finish(r.shiftKey),children:n.jsx(Se,{name:"check"})})]})]})}function J4({sink:e,frozen:t}){const[s,r]=h.useState(()=>Array(G4).fill(0));return h.useEffect(()=>{if(!t)return e.current=i=>r(a=>[...a.slice(1),i]),()=>{e.current=null}},[t]),n.jsx("div",{className:"wb-wave","aria-hidden":"true","data-testid":"waveform",children:s.map((i,a)=>n.jsx("span",{className:"wb-wave-bar",style:{"--level":i.toFixed(3)}},a))})}const X4="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",yc="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",Z4=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function e3(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(X4);let s;try{s=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(Z4(i))return null;throw new Error(yc)}try{const i=e.document??document,a=i.createElement("video");a.muted=!0,a.playsInline=!0,a.srcObject=s,await new Promise((f,d)=>{a.onloadedmetadata=()=>f(),a.onerror=()=>d(new Error(yc))}),await a.play(),await new Promise(f=>{const d=a.requestVideoFrameCallback;typeof d=="function"?d.call(a,()=>f()):setTimeout(f,120)});const l=i.createElement("canvas");l.width=a.videoWidth,l.height=a.videoHeight;const o=l.getContext("2d");if(!o||l.width===0)throw new Error(yc);o.drawImage(a,0,0);const c=await new Promise(f=>l.toBlob(f,"image/png"));if(!c)throw new Error(yc);const u=(((r=e.now)==null?void 0:r.call(e))??new Date).toISOString().slice(0,19).replace("T"," ").replace(/:/g,".");return new File([c],`Tab ${u}.png`,{type:"image/png"})}finally{s.getTracks().forEach(i=>i.stop())}}const nw="Send files once the agent has answered.",Xm="wb-composer-input",yx=h.forwardRef(function({disabled:t,running:s,onSend:r,onStop:i,agentName:a,draft:l,model:o,setupHref:c,thinking:u,onThinking:f,onOpenFile:d,mentions:m,history:p,threadKey:v,conversationId:w,readAloud:k,onReadAloud:g,placeholder:x},y){var qr;const j=v?`buddi.draft.${v}`:null,N=W=>{if(!W)return"";try{return window.localStorage.getItem(W)??""}catch{return""}},[b,S]=h.useState(()=>N(j)),[C,R]=h.useState([]),[E,P]=h.useState(!1),[F,M]=h.useState(null),[T,$]=h.useState(!1),_=h.useRef(null),K=h.useRef(null),[D,Y]=h.useState(null),[B,V]=h.useState(0),de=D&&m?m.filter(W=>W.handle.toLowerCase().startsWith(D.query.toLowerCase())||W.name.toLowerCase().startsWith(D.query.toLowerCase())).slice(0,6):[],ae=(W,ye)=>{if(!m||m.length===0){Y(null);return}const Qe=W.slice(0,ye),xt=/(^|\s)@([\w-]*)$/.exec(Qe);if(!xt){Y(null);return}Y({start:ye-xt[2].length-1,query:xt[2]}),V(0)},le=W=>{if(!D)return;const ye=K.current,Qe=ye?ye.selectionStart:b.length,xt=`${b.slice(0,D.start)}@${W} ${b.slice(Qe)}`;S(xt),ee<0&&X(xt),Y(null),window.requestAnimationFrame(()=>{if(!ye)return;const rn=D.start+W.length+2;ye.focus(),ye.setSelectionRange(rn,rn),pt()})},Ce=p??[],[ee,ce]=h.useState(-1),fe=h.useRef(b),je=h.useRef(j);if(je.current!==j){je.current=j;const W=N(j);fe.current=W,W!==b&&(S(W),ce(-1),Y(null))}const X=W=>{if(fe.current=W,!!j)try{W===""?window.localStorage.removeItem(j):window.localStorage.setItem(j,W)}catch{}},be=W=>{S(W),Y(null);const ye=K.current;ye&&(ye.value=W,ye.setSelectionRange(W.length,W.length)),window.requestAnimationFrame(pt)},Ee=W=>!W.value.slice(0,W.selectionStart??W.value.length).includes(`
104
- `),qe=()=>b===""||ee>=0&&b===Ce[ee],Ie=()=>{ee<0||(ce(-1),be(fe.current))},et=C.some(W=>W.state==="uploading"),z=C.length>0,se=s&&z,Ae=!t&&!et&&!se&&b.trim()!=="",Me=W=>{for(const ye of Array.from(W??[])){const Qe=`${ye.name}:${ye.size}:${Math.random().toString(36).slice(2,8)}`,xt=ye.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(ye):null;R(rn=>[...rn,{key:Qe,filename:ye.name||"Pasted image",mime:ye.type||"application/octet-stream",sizeBytes:ye.size,thumbnail:xt,state:"uploading"}]),Le.attach(ye).then(rn=>R(_s=>_s.map(Bt=>Bt.key===Qe?{...Bt,state:"ready",uploaded:rn}:Bt))).catch(rn=>R(_s=>_s.map(Bt=>Bt.key===Qe?{...Bt,state:"failed",error:rn instanceof he?rn.message:String(rn)}:Bt)))}},ot=W=>{W.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(W.thumbnail)},Ne=W=>{const ye=C.find(Qe=>Qe.key===W);ye&&(ot(ye),ye.state==="ready"&&ye.uploaded&&Le.discardAttachment(ye.uploaded.artifactId).catch(()=>{})),R(Qe=>Qe.filter(xt=>xt.key!==W))};h.useImperativeHandle(y,()=>({addFiles:W=>{var ye;Me(W),(ye=K.current)==null||ye.focus()},focus:()=>{var W;return(W=K.current)==null?void 0:W.focus()}}));const _e=h.useRef(C);_e.current=C,h.useEffect(()=>()=>_e.current.forEach(ot),[]);const Te=h.useRef(0);h.useEffect(()=>{if(!l||l.at===Te.current)return;Te.current=l.at,S(ye=>ye.trim()===""?l.text:ye),ee<0&&b.trim()===""&&X(l.text);const W=K.current;W&&(W.focus(),window.requestAnimationFrame(()=>{W.style.height="auto",W.style.height=`${Math.min(W.scrollHeight,200)}px`,W.setSelectionRange(W.value.length,W.value.length)}))},[l]);const pt=()=>{const W=K.current;W&&(W.style.height="auto",W.style.height=`${Math.min(W.scrollHeight,200)}px`)},O=W=>{const ye=(W??b).trim();if(W===void 0?!Ae:t||et||se||ye==="")return;const Qe=C.filter(xt=>xt.state==="ready"&&xt.uploaded).map(xt=>xt.uploaded);r(ye,Qe),C.forEach(ot),ce(-1),X(""),S(""),R([]),window.requestAnimationFrame(pt)},ve=W=>{if(D&&de.length>0){if(W.key==="ArrowDown"){W.preventDefault(),V(ye=>(ye+1)%de.length);return}if(W.key==="ArrowUp"){W.preventDefault(),V(ye=>(ye-1+de.length)%de.length);return}if(W.key==="Enter"||W.key==="Tab"){W.preventDefault(),le(de[B].handle);return}if(W.key==="Escape"){W.preventDefault(),Y(null);return}}if(W.key==="ArrowUp"&&!W.shiftKey&&!W.altKey&&!W.metaKey&&!W.ctrlKey){const ye=W.currentTarget;if(Ce.length>0&&ee+1<Ce.length&&Ee(ye)&&qe()){W.preventDefault(),ee<0&&(fe.current=b),ce(ee+1),be(Ce[ee+1]);return}}if(W.key==="ArrowDown"&&!W.shiftKey&&!W.altKey&&!W.metaKey&&!W.ctrlKey&&ee>=0&&b===Ce[ee]){if(W.preventDefault(),ee===0){Ie();return}ce(ee-1),be(Ce[ee-1]);return}if(W.key==="Escape"&&ee>=0){W.preventDefault(),Ie();return}W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),O())},Xe=W=>{var Qe;const ye=Array.from(((Qe=W.clipboardData)==null?void 0:Qe.files)??[]);ye.length!==0&&(W.preventDefault(),Me(ye))},Ge=C.filter(W=>W.state==="failed"),gt=Ge.length,Be=Y4({conversationId:w??null,onNotice:M,onText:(W,ye)=>{const Qe=b.trim()===""?W:`${b.replace(/\s+$/,"")} ${W}`;if(ye){O(Qe);return}be(Qe),ee<0&&X(Qe)}}),at=Be.state!=="idle",xs=h.useRef(!1);return h.useEffect(()=>{var W;xs.current&&!at&&((W=K.current)==null||W.focus(),window.requestAnimationFrame(pt)),xs.current=at},[at]),n.jsx("div",{className:"wb-composer","data-testid":"composer","data-busy":b.trim()!==""||z||at?"true":void 0,children:n.jsxs("div",{className:"wb-composer-box","data-focused":T||at,"data-disabled":t,"data-listening":at||void 0,children:[C.length>0?n.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:C.map(W=>n.jsx("span",{role:"listitem",children:n.jsx(_d,{name:W.filename,mime:W.mime,sizeBytes:W.sizeBytes,thumbnail:W.thumbnail,state:W.state,error:W.error,onRemove:()=>Ne(W.key),...d&&W.state==="ready"&&W.uploaded?{onOpen:()=>d(t3(W.uploaded))}:{},size:"sm"})},W.key))}):null,n.jsxs("label",{className:"sr-only",htmlFor:Xm,children:["Message ",a]}),n.jsx("textarea",{id:Xm,ref:K,value:b,rows:2,placeholder:s?`${a} is working…`:x??`Message ${a}`,onChange:W=>{S(W.target.value),ee<0&&X(W.target.value),ae(W.target.value,W.target.selectionStart??W.target.value.length),pt()},onFocus:()=>$(!0),onBlur:()=>$(!1),onKeyDown:ve,onPaste:Xe,disabled:t,hidden:at}),at?n.jsx(Q4,{voice:Be}):null,!at&&D&&de.length>0?n.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:de.map((W,ye)=>n.jsxs("button",{type:"button",role:"option","aria-selected":ye===B,className:"wb-mention","data-active":ye===B||void 0,onMouseDown:Qe=>{Qe.preventDefault(),le(W.handle)},children:[n.jsxs("span",{className:"wb-mention-handle",children:["@",W.handle]}),n.jsx("span",{className:"wb-mention-name",children:W.name})]},W.handle))}):null,n.jsxs("div",{className:"wb-composer-row",hidden:at,children:[n.jsx("input",{ref:_,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:W=>{Me(W.target.files),W.target.value=""}}),n.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 W;return(W=_.current)==null?void 0:W.click()},disabled:t,children:n.jsx(Se,{name:"clip"})}),n.jsx(q4,{disabled:t,voice:Be}),n.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Snap a tab",title:"Snap a tab — one picture of another tab in this browser, attached here",onClick:()=>{M(null),P(!0),e3().then(W=>{var ye;W&&(Me([W]),(ye=K.current)==null||ye.focus())}).catch(W=>M(W instanceof Error?W.message:String(W))).finally(()=>P(!1))},disabled:t||E,children:n.jsx(Se,{name:"camera"})}),o?c?n.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[n.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),o]}):n.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[n.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),o]}):null,f?n.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":wc(u),disabled:t||s,title:s?`Wait for ${a} to finish — this run started with thinking ${wc(u)?"on":"off"}`:wc(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:()=>f(wc(u)?"off":"on"),children:[n.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,g?n.jsx("button",{type:"button",className:"ui-icon-btn wb-read-aloud","data-size":"sm","aria-label":"Read replies aloud","aria-pressed":!!k,title:k?"Replies are read aloud. Click to stop.":"Read replies aloud, through the voice chosen in Settings → Speech",onClick:()=>g(!k),children:n.jsx(Se,{name:"speaker"})}):null,n.jsx("span",{className:"wb-hint","data-shown":b!==""&&!s||gt>0||se||F!==null,"data-tone":gt>0||F!==null?"critical":void 0,children:gt>0?gt===1&&((qr=Ge[0])!=null&&qr.error)?Ge[0].error:`${gt} files failed to upload and will not be sent`:F!==null?F:se?nw:"Enter sends, Shift+Enter for a new line"}),s?n.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,n.jsx("button",{className:"wb-send","aria-label":"Send",title:se?nw:et?"Waiting for the upload to finish":s?`Send — ${a} picks it up between steps`:"Send",onClick:()=>O(),disabled:!Ae,children:n.jsx(Se,{name:"send"})})]})]})})});function wc(e){return(e??"on")==="on"}function t3(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function n3({question:e,disabled:t,onAnswer:s,onSkip:r}){const[i,a]=h.useState("");return h.useEffect(()=>{if(t)return;const l=o=>{o.key!=="Escape"||o.defaultPrevented||(o.preventDefault(),r())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t,r]),n.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[n.jsxs("div",{className:"wb-question-head",children:[n.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),n.jsx(I,{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"}),n.jsx("strong",{children:e.question})]}),e.options.length>0?n.jsx("div",{className:"wb-question-options",children:e.options.map((l,o)=>n.jsxs("button",{className:"wb-question-option","data-recommended":l.recommended||void 0,disabled:t,onClick:()=>s(l.label,l.id),children:[n.jsx("span",{className:"wb-question-number",children:o+1}),n.jsxs("span",{children:[n.jsxs("span",{className:"wb-question-label",children:[l.label,l.recommended?n.jsx("em",{children:"Recommended"}):null]}),l.hint?n.jsx("small",{children:l.hint}):null]})]},l.id))}):null,e.allowOther?n.jsxs("form",{className:"wb-question-other",onSubmit:l=>{l.preventDefault(),i.trim()&&s(i.trim())},children:[n.jsx("input",{value:i,onChange:l=>a(l.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),n.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,n.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function s3(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function r3(e){const t=e/36e5;if(t>=1&&Number.isInteger(t))return`${t} hour${t===1?"":"s"}`;const s=Math.round(e/6e4);return`${s} minute${s===1?"":"s"}`}function i3(e){const{lifetime:t,startedAt:s,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 a=`A conversation ends after ${r3(t.idleTimeoutMs)} idle, or once its transcript grows past ${Math.round(t.maxChars/1e3)}k characters. What the agent remembers about you carries over.`,l=`${t.messages} message${t.messages===1?"":"s"}`;if(s3(t,r))return{text:`${l} · your next message starts a fresh one`,title:a,tone:"note"};const o=s?Oe(s,r):"";return{text:o===""?l:`${l} · started ${o}`,title:s?`Started ${Ve(s,i)}. ${a}`:a,tone:"quiet"}}const Zc=320,j1="buddi.chatWidth";function a3({timezone:e,agents:t,agentId:s,defaultAgentId:r=null,group:i=null,onEditGroup:a,onSelectAgent:l,attention:o,agentsInHeader:c,narrow:u,canvasOpen:f,onOpenCanvas:d,onCloseCanvas:m,newConversationSignal:p,requestedConversationId:v,requestedTab:w,onConversationOpened:k}){var mv,pv,gv,xv,vv,jv;const g=jx(),[x,y]=h.useState([]),[j,N]=h.useState(null),[b,S]=h.useState(null),[C,R]=h.useState(null),[E,P]=h.useState([]),[F,M]=h.useState([]),[T,$]=h.useState(null),[_,K]=h.useState(!1),[D,Y]=h.useState(new Map),[B,V]=h.useState(null),[de,ae]=h.useState(V4),[le,Ce]=h.useState([]),[ee,ce]=h.useState(!1),fe=h.useRef(0),je=h.useRef(null),[X,be]=h.useState(!1),Ee=h.useRef(p??0),qe=h.useRef(s),Ie=h.useRef({agentId:s,conversationId:j});Ie.current={agentId:s,conversationId:j};const et=de[j??""]??[],[z,se]=h.useState(null),[Ae,Me]=h.useState(null),[ot,Ne]=h.useState(null),[_e,Te]=h.useState([]),[pt,O]=h.useState(!1),[ve,Xe]=h.useState(()=>Date.now()),[Ge,gt]=h.useState(l3),Be=h.useRef(null),[at,xs]=h.useState(null),[qr,W]=h.useState(!1),[ye,Qe]=h.useState(null),[xt,rn]=h.useState(r1),_s=h.useRef(xt);_s.current=xt;const Bt=h.useRef(null),[an,$i]=h.useState(null),UE=h.useCallback(L=>{rn(L),i1(L),L||Ga()},[]),[BE,zE]=h.useState(null),[WE,qx]=h.useState(null);h.useEffect(()=>{if(!s)return;const L=d3(s);L&&Qe({text:L,at:Date.now()})},[s]);const Qr=i?`group:${i.id}`:s??null,Wn=[...t.top,...t.middle,...t.bottom],we=Wn.find(L=>L.id===s)??null,HE=ie(()=>A.providerAccounts(),[]),Di=i?i.members.map(L=>Wn.find(G=>G.id===L)).filter(L=>!!L):[],[Wd,Qx]=h.useState(null);h.useEffect(()=>{let L=!1;return Le.views().then(G=>{L||y(G.views??[])}).catch(()=>{}),()=>{L=!0}},[]),h.useEffect(()=>{if(!s)return;const L=qe.current===s;if(qe.current=s,L&&v&&v===Ie.current.conversationId)return;let G=!1;return N(null),S(null),R(null),P([]),se(null),K(!1),V(null),Ce([]),Mo(null),be(!1),xs(null),v?(v!=="new"?N(v):R(Qr),()=>{G=!0}):((i?Le.groupConversations(i.id):Le.conversations(s)).then(pe=>{if(G)return;const ke=[...pe.conversations??[]].sort(o3)[0];ke?(N(ke.id),k==null||k(s,ke.id)):R(Qr)}).catch(()=>{G||R(Qr)}),()=>{G=!0})},[s,i==null?void 0:i.id,Qr,v,k]);const vs=h.useCallback(L=>Le.conversation(L).then(G=>{if(Ie.current.conversationId===L){if(G.agentId!==Ie.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");S(G),P(pe=>pe.filter(ke=>!Jh(G,ke)))}}).catch(G=>{Ie.current.conversationId===L&&se(ur(G))}),[]);h.useEffect(()=>{if(!j)return;let L=!1;return Y(new Map),M([]),Le.conversation(j).then(G=>{if(!L){if(G.agentId!==s)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");S(G),P(pe=>pe.filter(ke=>!Jh(G,ke)))}}).catch(G=>{L||se(ur(G))}),()=>{L=!0}},[j,s]),h.useEffect(()=>{if(!j)return;let L=!1;const G=window.setInterval(()=>{Le.conversation(j).then(pe=>{L||pe.agentId!==Ie.current.agentId||(S(pe),P(ke=>ke.filter(ze=>!Jh(pe,ze))))}).catch(()=>{})},3e3);return()=>{L=!0,window.clearInterval(G)}},[j,s]),h.useEffect(()=>{if(!j)return;const L=Ad({url:Le.streamUrl(j),onEvent:G=>{var pe;switch(G.name){case"run.started":Bt.current=null,K(!0),$(null),Qx(zt(G.data.agentId));break;case"live":{const ke=zt(G.data.runId)??"",ze=Number(G.data.turn??0),$e=G.data.kind==="thinking"?"thinking":"text",ln=zt(G.data.text)??"",Ls=Date.now();if($e==="text"){const js=Bt.current;Bt.current=js&&js.runId===ke&&js.turn===ze?{...js,text:js.text+ln}:{runId:ke,turn:ze,text:ln}}$(js=>{const Fi=js&&js.runId===ke&&js.turn===ze?js:{runId:ke,turn:ze,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return $e==="thinking"?{...Fi,thinking:Fi.thinking+ln,thinkingStartedAt:Fi.thinkingStartedAt??Ls}:{...Fi,text:Fi.text+ln,textStartedAt:Fi.textStartedAt??Ls}});break}case"live.snapshot":{const ke=zt(G.data.runId)??"",ze=Number(G.data.turn??0),$e=zt(G.data.text)??"",ln=zt(G.data.thinking)??"",Ls=Number(G.data.startedAt??Date.now());Bt.current={runId:ke,turn:ze,text:$e},$({runId:ke,turn:ze,text:$e,thinking:ln,thinkingStartedAt:ln?Ls:null,textStartedAt:$e?Ls:null,settled:!1});break}case"live.settle":{const ke=zt(G.data.runId)??"",ze=Number(G.data.turn??0);$($e=>$e&&$e.runId===ke&&$e.turn===ze?{...$e,settled:!0}:$e);break}case"tool.called":{const ke=zt(G.data.toolUseId)??zt(G.data.id),ze=zt(G.data.name)??zt(G.data.tool)??"tool";ke&&M($e=>[...$e.filter(ln=>ln.toolUseId!==ke),{toolUseId:ke,name:ze,startedAt:Date.now()}]);break}case"tool.result":{const ke=zt(G.data.toolUseId)??zt(G.data.id);ke&&M(ze=>ze.filter($e=>$e.toolUseId!==ke)),vs(j);break}case"message.appended":vs(j).then(()=>{$(ke=>ke!=null&&ke.settled?null:ke)});break;case"awaiting-approval":{const ke=zt(G.data.approvalId)??zt(G.data.actionId),ze=zt(G.data.toolUseId);ke&&ze&&Y($e=>new Map($e).set(ze,ke)),M($e=>$e.filter(ln=>ln.toolUseId!==ze)),vs(j);break}case"run.finished":{K(!1),M([]),$(null),Qx(null);const ke=zt(G.data.message);se(ke??null);const ze=((pe=Bt.current)==null?void 0:pe.text.trim())??"";Bt.current=null,!ke&&ze!==""&&_s.current&&Fu(ze,j).then($e=>{$e&&$i($e)}),vs(j);break}}}});return()=>L.close()},[j,vs]),h.useEffect(()=>{const L=window.setInterval(()=>Xe(Date.now()),F.length===0?6e4:1e3);return()=>window.clearInterval(L)},[F.length]);const Po=ie(()=>s&&j?A.browser({agentId:s,conversationId:j}):Promise.resolve(void 0),[s,j],1500),Oi=Po.error?void 0:Po.data,Ja=Oi!=null&&Oi.session&&Oi.session.agentId===s&&Oi.session.conversationId===j?Oi:void 0,Jr=L4(Ja,s,j),Xr=(Jr==null?void 0:Jr.id)??null,[Xa,VE]=h.useState(null),Jx=Ja==null?void 0:Ja.mode;h.useEffect(()=>{Jr&&s&&j&&VE({agentId:s,conversationId:j,tab:F4(Jr,Jx)})},[Xr,Jx,s,j]);const KE=Xa&&Xa.agentId===s&&Xa.conversationId===j&&!et.includes(Xa.tab.id)?Xa.tab:null,qt=Jr??KE,GE=h.useMemo(()=>U4((b==null?void 0:b.messages)??[]),[b]),[YE,Mo]=h.useState(null),qE=h.useMemo(()=>BL({messages:(b==null?void 0:b.messages)??[],descriptors:x}),[b,x]),_i=n4(qE,j??null),Hd=r4(i?null:s),Xx=h.useMemo(()=>s4((b==null?void 0:b.messages)??[]),[b]),En=h.useMemo(()=>{const G=zL({messages:(b==null?void 0:b.messages)??[],descriptors:x,awaiting:D,served:_i.served,...qt?{folded:Xc}:{}}).filter(pe=>pe.source==="approval"||!et.includes(pe.id));if(B&&!et.includes(B)&&!G.some(pe=>pe.id===B)){const pe=KL((b==null?void 0:b.messages)??[],B,{redactInputOf:Xc});pe&&!Xc.has(pe.tool)&&G.push(pe)}qt&&G.push(qt);for(const pe of le)G.push(m_(pe));return Hd&&G.unshift(i4(Hd,Xx)),at?[...G,a4(at)]:G},[b,x,D,at,Xr,qt==null?void 0:qt.title,B,de,j,le,_i.served,Hd,Xx]),QE=h.useMemo(()=>{var G;const L=[];for(const pe of(b==null?void 0:b.messages)??[]){if(pe.role!=="user"||pe.speaker&&pe.speaker!=="owner")continue;const ke=(G=pe.blocks.find(ze=>ze.type==="text"))==null?void 0:G.text.trim();ke&&L.unshift(ke)}return L},[b]),Vd=h.useMemo(()=>En.filter(L=>L.source==="approval"),[En]),$o=Vd.at(-1)??null,Do=h.useMemo(()=>[...Vd.map(L=>({approvalId:L.props.approvalId,toolUseId:L.id})),...((b==null?void 0:b.delegatedApprovals)??[]).map(L=>({approvalId:L.approvalId,toolUseId:L.toolUseId??"",askedBy:p3(L.chain,Wn)}))],[Vd,b==null?void 0:b.delegatedApprovals]),Za=h.useMemo(()=>{for(let L=En.length-1;L>=0;L-=1){const G=En[L];if(G!=null&&G.substantial)return G.id}return null},[En]),Oo=h.useRef(null),Kd=((mv=En.filter(L=>(L.source!=="browser"||L.pinned===!0)&&L.id!==Qm).at(-1))==null?void 0:mv.id)??((pv=En.filter(L=>L.id!==Qm).at(-1))==null?void 0:pv.id)??null;h.useEffect(()=>{if(Za&&Za!==Oo.current){Oo.current=Za,V(Za);return}B===null&&Kd&&V(Kd)},[Za,B,Kd]);const Zx=h.useRef(_i.live);h.useEffect(()=>{const L=Zx.current;Zx.current=_i.live;const G=[..._i.live].filter(ze=>!L.has(ze));if(G.length===0||$o||B!==null&&B!==Oo.current)return;const ke=[...En].reverse().find(ze=>ze.source==="descriptor"&&ze.renderer==="preview"&&ze.props.target!==null&&G.includes(xa(ze.props.target)));ke&&V(ke.id)},[_i.live,En,$o,B]);const ev=h.useRef(null);h.useEffect(()=>{Xr!==ev.current&&(ev.current=Xr,Xr&&!$o&&V(Xr))},[Xr,$o]);const tv=h.useRef(null),el=w==="browser"?(qt==null?void 0:qt.id)??null:null;h.useEffect(()=>{!el||tv.current===el||(tv.current=el,V(el))},[el]);const Gd=(qt==null?void 0:qt.id)??null;h.useEffect(()=>{!Gd||!B||ew((b==null?void 0:b.messages)??[],B)!==null&&(Mo(B),V(Gd))},[Gd,B,b]);const nv=L=>{Ce(G=>G.some(pe=>pe.artifactId===L.artifactId)?G:[...G,L]),V(Qc(L.artifactId)),u&&(d==null||d())},_o=!i&&we&&!we.available?jN(we):null,sv=Im(i?null:we),rv=((b==null?void 0:b.offers)??[]).filter(L=>!_e.includes(L.id)&&Date.parse(L.expiresAt)>ve),JE=we&&WE===we.id?BE:(we==null?void 0:we.thinking)??null,XE=L=>{if(!we)return;const G=we.id;qx(G),zE(L),A.setAgentEngine(G,{thinking:L}).catch(pe=>{qx(null),se(pe instanceof he?pe.message:String(pe))})},iv=(L,G)=>{if(!s)return;const pe=G.map($e=>$e.artifactId),ke=_,ze={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:L},...G.map($e=>({type:"attachment",artifactId:$e.artifactId,filename:$e.filename,mime:$e.mime,kind:$e.kind,sizeBytes:$e.sizeBytes}))],...ke?{speaker:f1}:{}};P($e=>ke?[...$e,ze]:[ze]),se(null),Me(null),K(!0),(i?Le.sendToGroup(i.id,{...j?{conversationId:j}:{},text:L,attachmentIds:pe}):Le.send(s,{...j?{conversationId:j}:{},text:L,attachmentIds:pe})).then(async $e=>{Ie.current.agentId!==s||Ie.current.conversationId!==j||(Me($e.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),$e.conversationId!==j?(S(null),N($e.conversationId)):await vs($e.conversationId),$e.queued===!0&&P(ln=>ln.filter(Ls=>Ls.id!==ze.id)),k==null||k(s,$e.conversationId))}).catch($e=>{P(ln=>ln.filter(Ls=>Ls.id!==ze.id)),se(ur($e)),K(!1)})},ZE=L=>{se(null),Ne(L),Te(G=>[...G,L]),A.takeOffer(L,j??void 0).then(G=>{G.runId&&(Me(null),K(!0)),j&&vs(j)}).catch(G=>{Te(pe=>pe.filter(ke=>ke!==L)),se(ur(G)),j&&vs(j)}).finally(()=>Ne(null))},eA=(L,G)=>av({answer:L,...G?{optionId:G}:{}}),tA=()=>av({answer:"",skipped:!0}),av=L=>{const G=b==null?void 0:b.question;G&&(se(null),O(!0),K(!0),Le.answerQuestion(G.id,L).then(()=>{if(j)return vs(j)}).catch(pe=>{se(ur(pe)),K(!1)}).finally(()=>O(!1)))},nA=()=>{if(s){if(at){xs(null);return}W(!0),A.agentProfile(s).then(L=>{xs(L),V(Jm(L.id)),u&&(d==null||d())}).catch(L=>se(ur(L))).finally(()=>W(!1))}},sA=L=>{Qe({text:L.prompt,at:Date.now()}),l(L.agentId),u&&(m==null||m())},rA=()=>{j&&Le.cancel(j).catch(L=>se(ur(L))).finally(()=>{K(!1),M([])})},Lo=h.useCallback(()=>{if(N(null),S(null),P([]),K(!1),se(null),Me(null),M([]),Y(new Map),V(null),Ce([]),Mo(null),Oo.current=null,i){Le.startGroupConversation(i.id).then(({conversationId:L})=>{N(L),s&&(k==null||k(s,L))}).catch(L=>se(ur(L)));return}R(Qr),s&&(k==null||k(s,"new"))},[s,i,Qr,k]);h.useEffect(()=>{p&&p!==Ee.current&&(Ee.current=p,Lo())},[p,Lo]);const lv=L=>{j&&vs(j),A.overview().catch(()=>{}),L.state!=="pending"&&Y(G=>new Map([...G].filter(([,pe])=>pe!==L.id)))},Fo=h.useRef(!1);h.useEffect(()=>{const L=pe=>{if(!Fo.current)return;const ke=Math.max(Zc,Math.min(720,pe.clientX-52));gt(ke)},G=()=>{if(Fo.current){Fo.current=!1;try{Ge!==null&&window.localStorage.setItem(j1,String(Ge))}catch{}}};return window.addEventListener("pointermove",L),window.addEventListener("pointerup",G),()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",G)}},[Ge]);const iA=((gv=Wn.find(L=>L.id===r))==null?void 0:gv.name)??null,ov=i?[]:XD(we,iA),cv=!(b&&b.conversationId===j)&&!(!j&&C!==null&&C===Qr),uv=cv?n.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&we?n.jsx(l_,{quiet:!0,still:!0,className:"wb-chat-field",children:n.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[n.jsx(vn,{agents:Wn,id:we.id,size:"xl"}),n.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${we.name}.`}),n.jsx("p",{className:"wb-chat-intro",children:ZD(we)}),ov.length>0?n.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${we.name}`,children:ov.map(L=>n.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var G;Qe({text:L,at:Date.now()}),(G=je.current)==null||G.focus()},children:L},L))}):null]})}):null,dv=n.jsx(HF,{renderables:En,activeId:B,onActivate:V,onClose:L=>{at&&L===Jm(at.id)?xs(null):le.some(G=>Qc(G.artifactId)===L)?Ce(G=>G.filter(pe=>Qc(pe.artifactId)!==L)):j&&ae(G=>{const pe={...G,[j]:[...new Set([...G[j]??[],L])]};return tw(pe),pe}),B===L&&V(null)},timezone:e,onDecided:lv,onChangeAgent:sA,agents:Wn,browserPanel:qt?n.jsx($4,{status:Ja,error:Po.error,reload:Po.reload,steps:GE,live:Jr!==null,focusedStepId:YE},qt.id):null,descriptors:x,grantedTools:i?Di.flatMap(L=>L.tools??[]):(we==null?void 0:we.tools)??[],...we?{agentName:we.name}:{},loading:cv,...!i&&we?{face:n.jsx(vn,{agents:Wn,id:we.id,size:"xl"})}:{}}),hv=(vv=(xv=[...(b==null?void 0:b.messages)??[],...E].find(L=>L.role==="user"))==null?void 0:xv.blocks.find(L=>L.type==="text"))==null?void 0:vv.text.trim(),fv=hv?hv.split(`
105
- `)[0]:"New conversation",Li=i3({lifetime:(b==null?void 0:b.lifetime)??null,startedAt:(b==null?void 0:b.startedAt)??null,now:ve,timezone:e});return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"wb-chat",ref:Be,style:u||Ge===null?void 0:{width:Ge},"data-sized":!u&&Ge!==null?"true":void 0,"data-testid":"chat-column","data-dropping":ee||void 0,onDragEnter:L=>{bc(L)&&(L.preventDefault(),fe.current+=1,ce(!0))},onDragOver:L=>{bc(L)&&(L.preventDefault(),L.dataTransfer.dropEffect="copy")},onDragLeave:L=>{bc(L)&&(fe.current=Math.max(0,fe.current-1),fe.current===0&&ce(!1))},onDrop:L=>{var G;bc(L)&&(L.preventDefault(),fe.current=0,ce(!1),s&&((G=je.current)==null||G.addFiles(L.dataTransfer.files)))},children:[ee?n.jsx("div",{className:"wb-drop","aria-hidden":"true",children:n.jsxs("div",{className:"wb-drop-card",children:[n.jsx(c3,{}),n.jsx("strong",{children:"Drop to attach"}),n.jsx("span",{children:we?`It goes with your next message to ${we.name}`:"Pick an agent first"})]})}):null,n.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&we?Eo(Co(we)):{},children:[n.jsxs("div",{className:"wb-head-row",children:[i?n.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:Di.slice(0,3).map(L=>n.jsx(vn,{agents:Wn,id:L.id,size:"sm"},L.id))}):we?n.jsx("a",{className:"wb-head-face",href:dt(we.id),"aria-label":`${we.name}'s page`,children:n.jsx(vn,{agents:Wn,id:we.id})}):null,n.jsxs("div",{className:"wb-head-text",children:[i?n.jsx("span",{className:"wb-head-title",children:i.name}):n.jsx("span",{className:"wb-head-title",title:fv,children:fv}),n.jsx("span",{className:"wb-head-meta","data-tone":Li.tone,title:i?`${Di.map(L=>L.name).join(", ")}. Coordinator: ${(we==null?void 0:we.name)??i.coordinator}.`:Li.title,children:i?`${Di.map(L=>L.name).join(", ")} · ${Li.text}`:we?n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"wb-head-name",href:dt(we.id),title:`${we.name}'s page`,children:we.name})," ",n.jsxs("span",{className:"wb-head-handle",children:["@",we.handle]}),` · ${Li.tone==="quiet"&&Li.text==="New conversation"?`on ${g}`:Li.text}`]}):"No agent"})]}),n.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!s,onClick:()=>{be(!1),Lo()},children:n.jsx(Se,{name:"plus",size:16})}),n.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":X,"data-open":X?"true":void 0,disabled:!s,onClick:()=>be(L=>!L),children:n.jsx(h3,{})}),u?n.jsxs("button",{className:"ui-btn",onClick:d,disabled:En.length===0,children:["Canvas",En.length>0?` (${En.length})`:""]}):null,n.jsx(m3,{disabled:!s,items:i?[...Di.map(L=>({label:L.name,hint:L.id===i.coordinator?"Coordinator · open page":"Member · open page",href:dt(L.id)})),...a?[{label:"Members…",hint:"Name, coordinator, who is in the room",testId:"group-members",onSelect:a}]:[]]:[{label:at?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:qr,onSelect:nA},...we?[{label:"Set up",hint:"Identity, model and access",href:dt(we.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:dt(we.id)}]:[]]})]}),c?n.jsx(wN,{agents:t,currentId:s,attention:o,onSelect:l,orientation:"horizontal"}):null]}),X&&s?n.jsx(H4,{agentId:s,...i?{groupId:i.id}:{},currentId:j,timezone:e,onNew:()=>{be(!1),Lo()},onSelect:L=>{if(L===j){be(!1);return}be(!1),S(null),P([]),K(!1),V(null),se(null),Me(null),Ce([]),N(L),k==null||k(s,L,!1)}}):null,s&&j?n.jsx(O4,{agentId:s,conversationId:j},`${s}:${j}`):null,z?n.jsx("div",{className:"wb-chat-notice",children:n.jsx(ne,{message:z})}):null,Ae?n.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:Ae}):null,b!=null&&b.carriedOver?n.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:b.carriedOver}):null,n.jsx(xx,{messages:[...(b==null?void 0:b.messages)??[],...E],live:F,now:ve,working:_,partial:T,agents:Wn,...b!=null&&b.runs?{runs:b.runs}:{},...i?{speakers:Wn,coordinatorId:i.coordinator}:{},...Wd?{workingAs:((jv=Wn.find(L=>L.id===Wd))==null?void 0:jv.name)??Wd}:{},onOpenFile:nv,onReadAloud:(L,G)=>{$i(null),Fu(G,j??void 0,L).then(pe=>{pe&&$i(pe)})},onOpen:L=>{if(qt){const G=ew([...(b==null?void 0:b.messages)??[],...E],L);if(G){Mo(G),V(qt.id),u&&(d==null||d());return}}j&&ae(G=>{const pe={...G,[j]:(G[j]??[]).filter(ke=>ke!==L)};return tw(pe),pe}),V(L),u&&(d==null||d())},...we?{agentName:we.name,agentId:we.id}:{},...uv?{empty:uv}:{},emptyHint:we?`Nothing here yet. Ask ${we.name} for something.`:"Loading agents…"}),rv.length>0?n.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:rv.map(L=>n.jsx("button",{className:"ui-btn",disabled:ot!==null,title:L.prompt,onClick:()=>ZE(L.id),children:L.label},L.id))}):null,_o?n.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:n.jsxs(H,{tone:"warning",role:"status",children:[_o," ",n.jsx("a",{href:tt(sv.section),children:sv.label})]})}):Do.length>0?n.jsx(NF,{approvals:Do,timezone:e,now:ve,version:b,onDecided:lv,onSay:L=>iv(L,[]),onOpenFull:L=>{V(L),u&&(d==null||d())}}):null,_o||Do.length>0?null:b!=null&&b.question?n.jsx(n3,{question:b.question,disabled:pt||_,onAnswer:eA,onSkip:tA},b.question.id):null,_o?null:n.jsxs("div",{hidden:Do.length>0||!!(b!=null&&b.question),"data-testid":"composer-slot",children:[n.jsx(yx,{ref:je,disabled:!s,running:_,onSend:iv,onStop:rA,agentName:i?i.name:(we==null?void 0:we.name)??"the agent",draft:ye,history:QE,threadKey:j??(i?`group:${i.id}`:s),model:i?null:(we==null?void 0:we.model)??null,setupHref:i?null:we?dt(we.id,"setup","brain"):null,thinking:JE,...!i&&we&&fS(mS(we,HE.data))?{onThinking:XE}:{},...i?{mentions:Di.map(L=>({handle:L.handle,name:L.name}))}:{},onOpenFile:nv,conversationId:j??null,readAloud:xt,onReadAloud:UE}),an?n.jsx("p",{className:"wb-voice-note",role:"status",children:an}):null]})]}),u?f?n.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[n.jsxs("div",{className:"wb-sheet-head",children:[n.jsx("strong",{children:"Canvas"}),n.jsx("button",{className:"ui-btn",onClick:m,children:"Close"})]}),dv]}):null:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:L=>{var G,pe;Fo.current=!0,(pe=(G=L.currentTarget).setPointerCapture)==null||pe.call(G,L.pointerId)},onKeyDown:L=>{const G=pe=>{var ke;return pe??((ke=Be.current)==null?void 0:ke.offsetWidth)??Zc};L.key==="ArrowLeft"&&gt(pe=>Math.max(Zc,G(pe)-16)),L.key==="ArrowRight"&&gt(pe=>Math.min(720,G(pe)+16))}}),dv]})]})}function l3(){try{const e=window.localStorage.getItem(j1),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Zc?t:null}catch{return null}}function o3(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function zt(e){return typeof e=="string"&&e!==""?e:null}function ur(e){return e instanceof he||e instanceof Error?e.message:String(e)}function Jh(e,t){var r;const s=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!s)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const a=e.messages[i];if(a.role!=="user")continue;const l=a.blocks.find(o=>o.type==="text");if(l)return l.text.trim()===s}return!1}function bc(e){var s;const t=(s=e.dataTransfer)==null?void 0:s.types;return!!(t&&Array.from(t).includes("Files"))}function c3(){return n.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:[n.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),n.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 Zm="buddi.chatDraft";function u3(e,t){try{window.sessionStorage.setItem(Zm,JSON.stringify({agentId:e,text:t}))}catch{}}function d3(e){try{const t=window.sessionStorage.getItem(Zm);if(!t)return null;const s=JSON.parse(t);return s.agentId!==e||typeof s.text!="string"?null:(window.sessionStorage.removeItem(Zm),s.text)}catch{return null}}function h3(){return n.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:[n.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),n.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function f3(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[n.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function m3({items:e,disabled:t}){const[s,r]=h.useState(!1),i=h.useRef(null);return h.useEffect(()=>{if(!s)return;const a=o=>{i.current&&!i.current.contains(o.target)&&r(!1)},l=o=>{o.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",l)}},[s]),n.jsxs("div",{className:"wb-head-menu",ref:i,children:[n.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":"More about this agent","aria-haspopup":"menu","aria-expanded":s,"data-open":s?"true":void 0,disabled:t,onClick:()=>r(a=>!a),children:n.jsx(f3,{})}),s?n.jsx("div",{className:"ui-menu wb-head-menu-list",role:"menu",children:e.map(a=>a.href?n.jsxs("a",{className:"ui-menu-item",role:"menuitem",href:a.href,onClick:()=>r(!1),children:[n.jsx("span",{className:"ui-menu-item-text",children:a.label}),a.hint?n.jsx("span",{className:"ui-menu-item-hint",children:a.hint}):null]},a.label):n.jsxs("button",{className:"ui-menu-item",role:"menuitem","data-testid":a.testId,disabled:a.disabled,onClick:()=>{var l;r(!1),(l=a.onSelect)==null||l.call(a)},children:[n.jsx("span",{className:"ui-menu-item-text",children:a.label}),a.hint?n.jsx("span",{className:"ui-menu-item-hint",children:a.hint}):null]},a.label))}):null]})}function p3(e,t){const s=a=>{var l;return`@${((l=t.find(o=>o.id===a))==null?void 0:l.handle)??a}`},[r,...i]=e;return r===void 0?"":[s(r),...i.map(a=>`asked by ${s(a)}`)].join(", ")}let sw=!1;const g3=new Set(["missing","unconfigured","not-english"]);async function Fu(e,t,s=null){const r=a1(s);try{const i=await Le.say({text:e,...t?{conversationId:t}:{}});return Uy(r)&&await TL(i.audioUrl,i.mime,s),null}catch(i){Uy(r)&&Ga();const a=i instanceof he&&i.detail&&typeof i.detail=="object"?i.detail.reason:void 0;return typeof a=="string"&&g3.has(a)&&(s!==null||!sw)?(sw=!0,i.message):null}}let Vn=null;function x3(e){if(Yc(e)!==null)return!1;const t=hN(e);return t!==Vt&&t!==Ar}function v3({agent:e,agents:t,open:s,onOpenChange:r,navigate:i}){const a=h.useRef(null),l=h.useRef(s),o=`Ask ${e.name}`,[c,u]=h.useState(!1);return h.useEffect(()=>{if(s||!c||!Vn)return;const f=Ad({url:Le.streamUrl(Vn.conversationId),lastEventId:Vn.lastEventId??null,onEvent:d=>{d.name==="run.finished"&&u(!1)}});return()=>f.close()},[s,c]),h.useEffect(()=>{const f=d=>{!d.altKey||d.ctrlKey||d.metaKey||d.code!=="Slash"||(d.preventDefault(),r(!s))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,r]),h.useEffect(()=>{var f;l.current&&!s&&((f=a.current)==null||f.focus()),l.current=s},[s]),s?n.jsx(y3,{agent:e,agents:t,navigate:i,onClose:()=>r(!1),onBusy:u}):n.jsxs(eo,{children:[n.jsx(to,{asChild:!0,children:n.jsx("button",{ref:a,type:"button",className:"wb-ask-fab","data-busy":c?"true":void 0,"aria-label":o,onClick:()=>r(!0),children:n.jsx(j3,{busy:c})})}),n.jsx(no,{children:n.jsx(so,{className:"ui-tip",side:"left",sideOffset:8,children:o})})]})}function j3({busy:e}){const[t,s]=h.useState(!1);return t?n.jsx(HN,{size:"lg"}):n.jsx(Id,{state:e?"working":"idle",className:"wb-ask-fab-face",onStillError:()=>s(!0)})}function y3({agent:e,agents:t,navigate:s,onClose:r,onBusy:i}){const a=h.useRef(null),[l,o]=h.useState(Vn&&Vn.agentId===e.id?Vn.conversationId:null),[c,u]=h.useState(null),[f,d]=h.useState([]),[m,p]=h.useState([]),[v,w]=h.useState(null),[k,g]=h.useState(!1),[x,y]=h.useState(!1),[j,N]=h.useState(null),[b,S]=h.useState(null),[C,R]=h.useState(Date.now()),[E,P]=h.useState(r1),F=h.useRef(E);F.current=E;const[M,T]=h.useState(null),$=h.useRef(null),_=h.useCallback(async ae=>{try{const le=await Le.conversation(ae);u(le),d(Ce=>Ce.filter(ee=>!w3(le,ee)))}catch{}},[]);h.useEffect(()=>{l&&_(l)},[l,_]),h.useEffect(()=>{if(!l)return;const ae=Ad({url:Le.streamUrl(l),onEvent:le=>{var Ce;switch(le.name){case"run.started":$.current=null,g(!0),w(null);break;case"live":{const ee=An(le.data.runId)??"",ce=Number(le.data.turn??0),fe=le.data.kind==="thinking"?"thinking":"text",je=An(le.data.text)??"",X=Date.now();if(fe==="text"){const be=$.current;$.current=be&&be.runId===ee&&be.turn===ce?{...be,text:be.text+je}:{runId:ee,turn:ce,text:je}}w(be=>{const Ee=be&&be.runId===ee&&be.turn===ce?be:{runId:ee,turn:ce,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return fe==="thinking"?{...Ee,thinking:Ee.thinking+je,thinkingStartedAt:Ee.thinkingStartedAt??X}:{...Ee,text:Ee.text+je,textStartedAt:Ee.textStartedAt??X}});break}case"live.snapshot":{const ee=An(le.data.runId)??"",ce=Number(le.data.turn??0),fe=An(le.data.text)??"",je=An(le.data.thinking)??"",X=Number(le.data.startedAt??Date.now());$.current={runId:ee,turn:ce,text:fe},g(!0),w({runId:ee,turn:ce,text:fe,thinking:je,thinkingStartedAt:je?X:null,textStartedAt:fe?X:null,settled:!1});break}case"live.settle":{const ee=An(le.data.runId)??"",ce=Number(le.data.turn??0);w(fe=>fe&&fe.runId===ee&&fe.turn===ce?{...fe,settled:!0}:fe);break}case"tool.called":{const ee=An(le.data.toolUseId)??An(le.data.id),ce=An(le.data.name)??An(le.data.tool)??"tool";ee&&p(fe=>[...fe.filter(je=>je.toolUseId!==ee),{toolUseId:ee,name:ce,startedAt:Date.now()}]);break}case"tool.result":{const ee=An(le.data.toolUseId)??An(le.data.id);ee&&p(ce=>ce.filter(fe=>fe.toolUseId!==ee)),_(l);break}case"message.appended":case"awaiting-approval":_(l).then(()=>w(ee=>ee!=null&&ee.settled?null:ee));break;case"run.finished":{g(!1),p([]),w(null);const ee=An(le.data.message);N(ee??null);const ce=((Ce=$.current)==null?void 0:Ce.text.trim())??"";$.current=null,!ee&&ce!==""&&F.current&&Fu(ce,l).then(fe=>{fe&&T(fe)}),_(l);break}}}});return()=>{Vn&&Vn.conversationId===l&&(Vn.lastEventId=ae.lastEventId()),ae.close()}},[l,_]),h.useEffect(()=>{i(k||x)},[k,x,i]),h.useEffect(()=>{if(m.length===0)return;const ae=window.setInterval(()=>R(Date.now()),1e3);return()=>window.clearInterval(ae)},[m.length]);const K=(ae,le)=>{y(!0),N(null);const Ce={id:`local-${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:ae}]};d(ee=>[...ee,Ce]),(async()=>{try{const ee=l??(await Le.startConversation(e.id)).conversationId;ee!==l&&(Vn={agentId:e.id,conversationId:ee},o(ee));const ce=await Le.send(e.id,{conversationId:ee,text:ae,...le.length>0?{attachmentIds:le.map(fe=>fe.artifactId)}:{}});ce.conversationId!==ee&&(Vn={agentId:e.id,conversationId:ce.conversationId},o(ce.conversationId)),g(!0),_(ce.conversationId)}catch(ee){d(ce=>ce.filter(fe=>fe.id!==Ce.id)),N(ee instanceof he?ee.message:String(ee)),S({text:ae,at:Date.now()})}finally{y(!1)}})()},D=()=>{l&&Le.cancel(l).catch(ae=>N(String(ae))).finally(()=>g(!1))},Y=()=>{var ae;Vn=null,o(null),u(null),d([]),p([]),w(null),g(!1),N(null),(ae=a.current)==null||ae.focus()},B=ae=>{P(ae),i1(ae),ae||Ga()},V=l?Ke(e.id,l):Ke(e.id),de=[...(c==null?void 0:c.messages)??[],...f];return n.jsxs(s_,{title:e.name,label:`${e.name}, a quick chat`,onClose:r,onOpenAutoFocus:ae=>{var le;ae.preventDefault(),(le=a.current)==null||le.focus()},onCloseAutoFocus:ae=>ae.preventDefault(),actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",variant:"ghost",onClick:Y,disabled:l===null&&f.length===0,children:"New"}),n.jsx(Yt,{size:"sm",variant:"ghost",href:V,onClick:ae=>{ae.preventDefault(),s(V)},children:"Open in Chat"})]}),children:[n.jsx("div",{className:"wb-ask-thread",children:n.jsx(xx,{messages:de,live:m,now:C,working:k||x,partial:v,agents:t,agentName:e.name,agentId:e.id,onOpen:()=>s(V),onReadAloud:(ae,le)=>{T(null),Fu(le,l??void 0,ae).then(Ce=>{Ce&&T(Ce)})},emptyHint:`Ask ${e.name} anything, without leaving this page.`})}),n.jsxs("div",{className:"wb-ask-compose",children:[j?n.jsx(ne,{message:j}):null,n.jsx(yx,{ref:a,disabled:x||!e.available,running:k,onSend:K,onStop:D,agentName:e.name,placeholder:`Message ${e.name}…`,draft:b,threadKey:`dock.${l??e.id}`,conversationId:l,readAloud:E,onReadAloud:B}),M?n.jsx("p",{className:"wb-voice-note",role:"status",children:M}):null]})]})}function An(e){return typeof e=="string"?e:null}function w3(e,t){var r;const s=(r=t.blocks)==null?void 0:r.find(i=>i.type==="text");return!s||s.type!=="text"?!1:e.messages.some(i=>i.role==="user"&&(i.blocks??[]).some(a=>a.type==="text"&&a.text.includes(s.text)))}const y1=3;function b3(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function k3(e,t){return e?t?"above-dock":"above-button":"corner"}function S3({placement:e,children:t}){return n.jsx("div",{className:"wb-toast-stack","data-placement":e,children:t})}function N3(e){return e.state==="shown"&&e.seenAt===null}function C3(e){const[t,s]=h.useState([]),r=h.useRef(new Set),i=h.useRef(new Set),a=h.useCallback(()=>{e&&A.notifications(20).then(({notifications:o})=>{const c=o.filter(u=>N3(u)&&!r.current.has(u.id));s(u=>{const f=new Set(u.map(m=>m.id)),d=c.filter(m=>!f.has(m.id));return d.length===0?u:[...u,...d].sort((m,p)=>p.createdAt.localeCompare(m.createdAt))})}).catch(()=>{})},[e]);h.useEffect(()=>{for(const o of t.slice(0,y1))i.current.has(o.id)||(i.current.add(o.id),A.notificationSeen(o.id).catch(()=>{}))},[t]);const l=h.useCallback(o=>{r.current.add(o),s(c=>c.filter(u=>u.id!==o))},[]);return{queue:t,refresh:a,dismiss:l}}function E3({queue:e,agents:t,navigate:s,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,y1),a=e.length-i.length;return n.jsxs("section",{className:"nt-toasts","aria-label":"Notifications",children:[i.map(l=>n.jsxs("div",{className:"ui-toast nt-toast","data-tone":b3(l.kind),role:"status",children:[l.agentId?n.jsx(vn,{agents:t,id:l.agentId,size:"sm"}):null,n.jsxs("div",{className:"nt-toast-main",children:[n.jsx("div",{className:"ui-toast-title",children:l.title}),l.text?n.jsx("div",{className:"ui-toast-body nt-toast-line",children:A3(l.text)}):null,l.link?n.jsx("a",{className:"nt-toast-link",href:l.link,onClick:o=>{o.preventDefault(),r(l.id),s(l.link)},children:"See"}):null]}),n.jsx("button",{type:"button",className:"nt-toast-x","aria-label":`Dismiss ${l.title}`,onClick:()=>r(l.id),children:"×"})]},l.id)),a>0?n.jsxs("p",{className:"nt-toasts-more",children:["and ",a," more"]}):null]})}function A3(e){var t;return((t=e.split(`
106
- `).find(s=>s.trim()!==""))==null?void 0:t.trim())??""}const T3=3e4,R3=1e3;function I3(e,t,s){const r=h.useRef(t);r.current=t;const i=h.useRef(s);i.current=s,h.useEffect(()=>{if(!e)return;let a=!1,l=-1/0,o=null,c=null,u=!0;const f=()=>document.visibilityState!=="hidden",d=g=>{var x;l=Date.now(),A.presence(g).catch(y=>{var j;y instanceof he&&y.status===401&&(a=!0,(j=i.current)==null||j.call(i))}),g==="active"&&((x=r.current)==null||x.call(r))},m=g=>{if(a||(o=g,c!==null))return;const x=l+R3-Date.now();if(x<=0){o=null,d(g);return}c=window.setTimeout(()=>{if(c=null,a||o===null)return;const y=o;o=null,d(y)},x)},p=()=>{u=!0,f()&&m("active")},v=()=>{u=!1,m("away")},w=()=>m(f()?"active":"away");f()&&m("active");const k=window.setInterval(()=>{f()&&u&&m("active")},T3);return window.addEventListener("focus",p),window.addEventListener("blur",v),document.addEventListener("visibilitychange",w),()=>{a=!0,window.clearInterval(k),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",p),window.removeEventListener("blur",v),document.removeEventListener("visibilitychange",w)}},[e])}function rw({agents:e,group:t,onClose:s,onCreated:r,onSaved:i,onArchived:a}){return!t&&!vN(e)?n.jsx(Dt,{title:"A new group",onClose:s,children:n.jsxs(H,{children:["A group needs two agents. Make another one with ",qD(e)," first."]})}):n.jsx(M3,{agents:P3(e,t),group:t??null,onClose:s,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...a?{onArchived:a}:{}})}function P3(e,t){const s=xN(e),r=((t==null?void 0:t.members)??[]).filter(i=>!s.some(a=>a.id===i)).map(i=>e.find(a=>a.id===i)).filter(i=>i!==void 0);return[...s,...r]}function M3({agents:e,group:t,onClose:s,onCreated:r,onSaved:i,onArchived:a}){var C,R;const l=t!==null,[o,c]=h.useState((t==null?void 0:t.name)??""),[u,f]=h.useState((t==null?void 0:t.members)??[]),[d,m]=h.useState((t==null?void 0:t.coordinator)??((C=e.find(E=>E.roles.includes(Qg)))==null?void 0:C.id)??((R=e[0])==null?void 0:R.id)??""),[p,v]=h.useState(!1),[w,k]=h.useState(!1),[g,x]=h.useState(null),y=[...new Set([d,...u])].filter(Boolean),j=o.trim()!==""&&d!==""&&y.length>=2,N=E=>f(P=>P.includes(E)?P.filter(F=>F!==E):[...P,E]),b=async()=>{v(!0),x(null);try{t?i==null||i(await Le.updateGroup(t.id,{name:o.trim(),coordinator:d,members:y})):r==null||r(await Le.createGroup({name:o.trim(),coordinator:d,members:y.filter(E=>E!==d)}))}catch(E){x(E instanceof he?E.message:String(E))}finally{v(!1)}},S=async()=>{if(t){v(!0),x(null);try{await Le.archiveGroup(t.id),a==null||a(t.id)}catch(E){x(E instanceof he?E.message:String(E)),v(!1)}}};return n.jsx(Dt,{title:l?`${t.name}: members`:"A new group",onClose:s,children:n.jsxs(q,{children:[n.jsx(te,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:n.jsx("input",{value:o,autoFocus:!0,maxLength:80,onChange:E=>c(E.target.value),placeholder:"Household finances"})}),n.jsx(te,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:n.jsx("select",{value:d,onChange:E=>m(E.target.value),children:e.map(E=>n.jsx("option",{value:E.id,children:E.name},E.id))})}),n.jsx(te,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:n.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(E=>E.id!==d).map(E=>n.jsxs("label",{className:"group-pick-row","data-on":u.includes(E.id)||void 0,children:[n.jsx("input",{type:"checkbox",checked:u.includes(E.id),onChange:()=>N(E.id)}),n.jsx(vn,{agents:e,id:E.id,size:"sm"}),n.jsxs("span",{className:"group-pick-text",children:[n.jsx("span",{className:"group-pick-name",children:E.name}),n.jsx("span",{className:"group-pick-desc",children:E.description})]})]},E.id))})}),n.jsx(H,{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."}),l?n.jsx(H,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,g?n.jsx(H,{tone:"critical",children:g}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!j||p,onClick:()=>void b(),children:p?l?"Saving…":"Creating…":l?"Save":"Create group"})]}),l?n.jsx("div",{className:"group-archive",children:w?n.jsxs(q,{children:[n.jsxs(H,{tone:"warning",children:["Archive ",t.name,"? It leaves the rail and takes no new requests. Everything said in it stays readable."]}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:()=>k(!1),children:"Keep it"}),n.jsx(I,{variant:"danger",disabled:p,"data-testid":"group-archive-confirm",onClick:()=>void S(),children:"Archive group"})]})]}):n.jsx(I,{variant:"ghost",disabled:p,"data-testid":"group-archive",onClick:()=>k(!0),children:"Archive group"})}):null]})})}function wx(e){const[t,s]=h.useState(null),[r,i]=h.useState(null),[a,l]=h.useState(null);return{busy:t,note:r,failure:a,decide:async(c,u,f,d)=>{var p,v,w,k;s(c),l(null),i(null);let m;try{const g=d?await A.decide(c,u,f,d):await A.decide(c,u,f);m={decision:u,...(p=g.execution)!=null&&p.state?{state:g.execution.state}:{},...g.execution&&"result"in g.execution?{result:g.execution.result}:{}},i(u==="reject"?`Rejected ${g.action.tool}.`:((v=g.execution)==null?void 0:v.state)==="succeeded"?`Approved and done: ${g.action.tool}.`:`Approved ${g.action.tool}: ${((w=g.execution)==null?void 0:w.state)??"no execution"}${(k=g.execution)!=null&&k.message?` (${g.execution.message})`:""}`)}catch(g){l(g instanceof Error?g.message:String(g))}finally{s(null),e(m)}}}}function bx({action:e,timezone:t,busy:s,onDecide:r,agentName:i}){var f,d;const[a,l]=h.useState(!1),{values:o,controls:c}=cx(e.choices),u=m=>o?r(e.id,"approve",m,o):r(e.id,"approve",m);return n.jsxs(On,{tone:"accent",title:e.tool,meta:n.jsxs(n.Fragment,{children:[n.jsxs(xe,{children:["v",e.toolVersion]}),n.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[n.jsx(Nt,{children:e.preview}),n.jsxs("p",{className:"ui-card-meta",children:["Expires ",Ve(e.expiresAt,t)," (",Oe(e.expiresAt),"). Policy v",e.policyVersion,", args ",ao(e.argsHash,12),e.jobId?`, job ${ao(e.jobId)}`:"","."]}),c,n.jsxs(Q,{children:[n.jsx(I,{variant:"good",disabled:s,onClick:()=>u(),children:(f=e.permissionScopes)!=null&&f.length?"Allow once":"Approve"}),(d=e.permissionScopes)!=null&&d.length?n.jsxs(n.Fragment,{children:[n.jsx(I,{disabled:s,onClick:()=>u("conversation"),children:"Auto: this conversation"}),n.jsx(I,{disabled:s,onClick:()=>u("always"),children:"Always: this agent"})]}):null,n.jsx(I,{variant:"danger",disabled:s,onClick:()=>r(e.id,"reject"),children:"Reject"}),n.jsx(I,{variant:"ghost",onClick:()=>l(m=>!m),"aria-expanded":a,children:a?"Hide envelope":"Show envelope"})]}),a?n.jsxs("div",{className:"ui-card-foot",children:[n.jsx(J,{title:"Envelope: everything that decides what the world will see",children:n.jsx(Nt,{children:Sn(e.envelope)})}),n.jsx(J,{title:"Canonical arguments",children:n.jsx(Nt,{children:Sn(e.canonicalArgs)})})]}):null]})}function kx(e,t,s){const[r,i]=h.useState(!1),[a,l]=h.useState(null),[o,c]=h.useState(null);return{accept:()=>{e&&(i(!0),c(null),A.acceptPluginAgent(e,t).then(f=>{l(f.agent)}).catch(f=>c(f instanceof he?f.message:String(f))).finally(()=>i(!1)))},busy:r,created:a,failure:o}}function w1({agent:e}){return n.jsxs(H,{tone:"good",role:"status",children:["@",e.handle," is ready. ",n.jsxs("a",{href:Ke(e.id),children:["Talk to @",e.handle]})]})}function b1(e,t,s){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()===s.toLowerCase()}function $3(e,t){var i;const s=ie(()=>A.approvals(),[e,t],15e3);return{action:((i=s.data)==null?void 0:i.pending.find(a=>b1(a,e,t)))??null,reload:s.reload}}function D3({action:e,onDecided:t}){const{busy:s,failure:r,decide:i}=wx(a=>t(a));return n.jsxs(q,{gap:"sm",children:[n.jsx(bx,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:s===e.id,onDecide:(a,l,o,c)=>{i(a,l,o,c)}}),n.jsx(ne,{message:r})]})}function Sx({plugin:e,agent:t,text:s,label:r,handle:i,onDismiss:a}){var d;const l=kx(e,t),o=$3(e,t),[c,u]=h.useState(null),f=l.created??c;if(f)return n.jsx(w1,{agent:f});if(o.action){const m=i??((d=/@(\S+)/.exec(r))==null?void 0:d[1])??t;return n.jsxs(q,{gap:"sm",children:[n.jsx("span",{children:s}),n.jsx(D3,{action:o.action,onDecided:p=>{(p==null?void 0:p.decision)==="approve"&&p.state==="succeeded"?u({id:t,handle:m,name:m}):o.reload()}})]})}return n.jsxs(q,{gap:"sm",children:[n.jsxs(Q,{children:[n.jsx("span",{children:s}),n.jsx(sn,{}),a?n.jsx(I,{variant:"ghost",disabled:l.busy,onClick:a,children:"Not now"}):null,n.jsx(I,{variant:"accent",disabled:l.busy,onClick:l.accept,children:r})]}),n.jsx(ne,{message:l.failure})]})}function k1(){var t;const e=ie(()=>A.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function S1({offers:e,reload:t}){return e.length===0?null:n.jsx(J,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:n.jsx(q,{gap:"sm",divided:!0,children:e.map(s=>n.jsx(Sx,{plugin:s.plugin,agent:s.agent,text:s.text,label:`Create @${s.handle}`,handle:s.handle,onDismiss:()=>{A.dismissAgentOffer(s.plugin,s.agent).then(t,t)}},`${s.plugin}/${s.agent}`))})})}const O3=512*1024,_3=/^[A-Za-z0-9+/]*={0,2}$/;function N1(e){const t=e==null?void 0:e.play;if(typeof t!="object"||t===null)return null;const{mime:s,data:r}=t;return typeof s!="string"||!/^audio\/[a-z0-9.+-]+$/i.test(s.split(";")[0].trim())||typeof r!="string"||r===""||!_3.test(r)||Math.floor(r.length*3/4)>O3+2?null:{mime:s,data:r}}function C1(e){const t=e==null?void 0:e.message;return typeof t=="string"&&t.trim()!==""?t:null}let zs=null,Il=null,uo=null;const ep=new Set;function E1(){for(const e of ep)e()}function vl(){zs&&(zs.onended=null,zs.onerror=null,zs.pause()),Il&&URL.revokeObjectURL(Il),Il=null,uo!==null&&(uo=null,E1())}async function A1(e,t){vl();const s=atob(e.data),r=new Uint8Array(s.length);for(let i=0;i<s.length;i+=1)r[i]=s.charCodeAt(i);zs??(zs=new Audio),Il=URL.createObjectURL(new Blob([r],{type:e.mime})),uo=t,zs.onended=vl,zs.onerror=vl,zs.src=Il,E1();try{await zs.play()}catch{throw vl(),new Error("The browser would not play the sound.")}}function iw(e){e!==void 0&&uo!==e||vl()}function L3(){return h.useSyncExternalStore(e=>(ep.add(e),()=>ep.delete(e)),()=>uo,()=>null)}const F3=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Yi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],U3=["January","February","March","April","May","June","July","August","September","October","November","December"],aw=/^\d{4}-\d{2}-\d{2}$/;function Rr(e){return e.split("-").map(Number)}function Mi(e,t){const[s,r,i]=Rr(e);return new Date(Date.UTC(s,r-1,i+t)).toISOString().slice(0,10)}function T1(e){const[t,s,r]=Rr(e);return new Date(Date.UTC(t,s-1,r)).getUTCDay()}function Nx(e){return F3[T1(e)]}function R1(e){return Rr(e)[2]}function lw(e){return Mi(e,-((T1(e)+6)%7))}function qs(e){const[,t,s]=Rr(e);return`${Nx(e)} ${s} ${Yi[t-1]}`}function B3(e,t){return e===t?`Today · ${qs(e)}`:e===Mi(t,1)?`Tomorrow · ${qs(e)}`:qs(e)}function ii(e){return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}const ow=new Map;function tp(e,t){let s=ow.get(t);s||(s=new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),ow.set(t,s));const r=Object.fromEntries(s.formatToParts(e).map(i=>[i.type,i.value]));return{date:`${r.year}-${r.month}-${r.day}`,minutes:Number(r.hour)*60+Number(r.minute)}}function z3(e,t=new Date){return tp(t,e).date}function W3(e,t){return e==="week"?{from:lw(t),days:7}:e==="month"?{from:lw(`${t.slice(0,8)}01`),days:42}:{from:t,days:7}}function H3(e,t,s){if(e!=="month")return Mi(t,s*7);const[r,i]=Rr(t);return new Date(Date.UTC(r,i-1+s,1)).toISOString().slice(0,10)}function V3(e,t,s,r){const[i,a]=Rr(t);if(e==="month")return`${U3[a-1]} ${i}`;const l=Mi(s,r-1),[o,c,u]=Rr(s),[f,d,m]=Rr(l);return c===d&&o===f?`${u} – ${m} ${Yi[d-1]} ${f}`:o===f?`${u} ${Yi[c-1]} – ${m} ${Yi[d-1]} ${f}`:`${u} ${Yi[c-1]} ${o} – ${m} ${Yi[d-1]} ${f}`}function Ki(e){return e==null?"":String(e)}function K3(e,t,s,r){const i=[],a=new Set;return e.forEach((l,o)=>{const c=Ki(me(l,t.id)),u=Ki(me(l,t.title)),f=Ki(me(l,t.start)),d=Ki(me(l,t.end));if(c===""||a.has(c)||f===""){console.warn(`buddi: ${r}: event ${o} has no id, a repeated one, or no start — not drawn`);return}a.add(c);const m=t.allDay===void 0?void 0:me(l,t.allDay),p=m===void 0?aw.test(f):m===!0||m==="true",v=t.tone===void 0?0:Number(me(l,t.tone)),w=Number.isFinite(v)?(Math.trunc(v)%4+4)%4:0,k={id:c,title:u,calendar:t.calendar===void 0?"":Ki(me(l,t.calendar)),tone:w,location:t.location===void 0?"":Ki(me(l,t.location))};if(p){const N=f.slice(0,10),b=aw.test(d.slice(0,10))&&d.slice(0,10)>N?d.slice(0,10):Mi(N,1);i.push({...k,allDay:!0,startDate:N,startMin:0,endDate:b,endMin:0});return}const g=new Date(f);if(Number.isNaN(g.getTime())){console.warn(`buddi: ${r}: event ${o} starts at "${f}", which is not a time — not drawn`);return}const x=new Date(d),y=tp(g,s),j=Number.isNaN(x.getTime())||x<g?y:tp(x,s);i.push({...k,allDay:!1,startDate:y.date,startMin:y.minutes,endDate:j.date,endMin:j.minutes})}),i}function G3(e,t){if(e.allDay)return t>=e.startDate&&t<e.endDate?{from:0,to:1440,allDay:!0}:null;if(t<e.startDate||t>e.endDate)return null;const s=t===e.startDate?e.startMin:0,r=t===e.endDate?e.endMin:1440,i=e.startDate===e.endDate&&e.startMin===e.endMin;return r<=s&&!(i&&t===e.startDate)?null:{from:s,to:r,allDay:s===0&&r===1440}}function Cx(e,t){return e.map(s=>({event:s,part:G3(s,t)})).filter(s=>s.part!==null).sort((s,r)=>Number(r.part.allDay)-Number(s.part.allDay)||s.part.from-r.part.from||r.part.to-s.part.to)}function Ex(e,t){if(t.allDay)return"All day";const s=e.startDate!==e.endDate;return s&&t.from===0?`until ${ii(t.to)}`:s&&t.to===1440?`from ${ii(t.from)}`:t.from===t.to?ii(t.from):`${ii(t.from)}–${ii(t.to)}`}function np(e,t,s){return[Ex(e,t),e.title,e.location,e.calendar,qs(s)].filter(Boolean).join(", ")}const I1=30;function Y3(e){const t=[];let s=[],r=-1;const i=[],a=()=>{const l=Math.max(1,...s.map(o=>o.lane+1));for(const o of s)t.push({...o,lanes:l});s=[],i.length=0};for(const l of e){const o=Math.max(l.part.to,l.part.from+I1);s.length>0&&l.part.from>=r&&a();let c=i.findIndex(u=>u<=l.part.from);c===-1?(c=i.length,i.push(o)):i[c]=o,s.push({...l,lane:c,lanes:1}),r=Math.max(r,o)}return s.length>0&&a(),t}const Ax="(max-width: 900px)";function Ia(e){const[t,s]=h.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return h.useEffect(()=>{var a;let r;try{r=window.matchMedia(e)}catch{return}const i=l=>s(l.matches);return(a=r.addEventListener)==null||a.call(r,"change",i),()=>{var l;return(l=r.removeEventListener)==null?void 0:l.call(r,"change",i)}},[e]),t}const q3={week:"Week",month:"Month",list:"List"},Q3=["week","month","list"],J3="(max-width: 720px)";function X3(e){try{return window.localStorage.getItem(e)}catch{return null}}function Z3(e,t){try{window.localStorage.setItem(e,t)}catch{}}function e6(e){const t=e.views&&e.views.length>0?e.views:Q3,s=Ia(J3),[r,i]=h.useState(()=>{const p=X3(e.storageKey);return p!==null&&t.includes(p)?p:null}),a=s&&t.includes("list")?"list":e.default&&t.includes(e.default)?e.default:t[0],l=r??a,[o,c]=h.useState(e.today),[u,f]=h.useState(null),{from:d,days:m}=W3(l,o);return{views:t,view:l,setView:p=>{i(p),Z3(e.storageKey,p),f(null)},anchor:o,today:e.today,go:p=>{c(p===0?e.today:H3(l,o,p)),f(null)},from:d,days:m,to:Mi(d,m),selected:u,select:f}}function t6({state:e,events:t,hours:s,empty:r,label:i}){const{view:a,anchor:l,today:o,from:c,days:u}=e,f=h.useMemo(()=>Array.from({length:u},(w,k)=>Mi(c,k)),[c,u]),d=a==="month"?"month":"week",m=e.selected??(l.slice(0,7)===o.slice(0,7)?o:`${l.slice(0,8)}01`),p=a==="month"?m:a==="week"?e.selected:null,v=w=>{if(!w.target.closest('input, textarea, select, [contenteditable="true"]')&&!(w.altKey||w.ctrlKey||w.metaKey)){if(w.key==="ArrowLeft")e.go(-1);else if(w.key==="ArrowRight")e.go(1);else if(w.key==="t"||w.key==="T")e.go(0);else return;w.preventDefault()}};return n.jsxs("div",{className:"cal",role:"region","aria-label":i,tabIndex:0,onKeyDown:v,children:[n.jsxs("div",{className:"cal-bar",children:[n.jsx(I,{size:"sm","aria-label":`Previous ${d}`,onClick:()=>e.go(-1),children:n.jsx(Se,{name:"chevron-left",size:14})}),n.jsx(I,{size:"sm",onClick:()=>e.go(0),children:"Today"}),n.jsx(I,{size:"sm","aria-label":`Next ${d}`,onClick:()=>e.go(1),children:n.jsx(Se,{name:"chevron-right",size:14})}),n.jsx("h3",{className:"cal-title","aria-live":"polite",children:V3(a,l,c,u)}),e.views.length>1?n.jsx(Ys,{label:"View",options:e.views.map(w=>({value:w,label:q3[w]})),value:a,onChange:e.setView}):null]}),a==="week"?n.jsx(n6,{dates:f,today:o,events:t,hours:s??[7,21],onPick:e.select}):null,a==="month"?n.jsx(r6,{dates:f,month:l.slice(0,7),today:o,events:t,selected:m,onPick:e.select}):null,a==="list"?n.jsx("div",{className:"cal-list",children:f.map(w=>n.jsx(cw,{date:w,today:o,events:t,empty:r},w))}):null,p?n.jsx(cw,{date:p,today:o,events:t,empty:r}):null]})}function cw({date:e,today:t,events:s,empty:r}){const i=Cx(s,e);return n.jsx(Ze,{flush:!0,title:B3(e,t),children:n.jsx(Ct,{children:i.length===0?n.jsx(Et,{title:n.jsx("span",{className:"muted",children:r})}):i.map(({event:a,part:l})=>n.jsx(Et,{lead:n.jsx("span",{className:"cal-dot","data-tone":a.tone,"aria-hidden":"true"}),title:a.title,sub:a.location||void 0,side:Ex(a,l)},a.id))})})}function n6({dates:e,today:t,events:s,hours:r,onPick:i}){const a=h.useRef(null);h.useLayoutEffect(()=>{const c=a.current;c&&(c.scrollTop=c.scrollHeight/24*r[0])},[r[0]]);const l=e.map(c=>({date:c,items:Cx(s,c)})),o=c=>c===t?"true":void 0;return n.jsx(Ze,{flush:!0,children:n.jsxs("div",{className:"cal-week",role:"grid","aria-label":`Week of ${qs(e[0])}`,style:{"--cal-span":r[1]-r[0]},children:[n.jsxs("div",{className:"cal-row",role:"row",children:[n.jsx("span",{className:"cal-gutter","aria-hidden":"true"}),e.map(c=>n.jsxs("div",{className:"cal-day-head",role:"columnheader","data-today":o(c),"aria-label":qs(c),children:[n.jsx("span",{className:"cal-wd",children:Nx(c)}),n.jsx("span",{className:"cal-num",children:R1(c)})]},c))]}),n.jsxs("div",{className:"cal-row cal-allday",role:"row",children:[n.jsx("span",{className:"cal-gutter cal-gutter-label",children:"All day"}),l.map(({date:c,items:u})=>n.jsx("div",{className:"cal-allday-cell",role:"gridcell","data-today":o(c),children:u.filter(f=>f.part.allDay).map(({event:f,part:d})=>n.jsx("button",{type:"button",className:"cal-chip","data-tone":f.tone,"aria-label":np(f,d,c),onClick:()=>i(c),children:f.title},f.id))},c))]}),n.jsx("div",{className:"cal-scroll",ref:a,children:n.jsxs("div",{className:"cal-row cal-times",role:"row",children:[n.jsx("div",{className:"cal-gutter cal-hours","aria-hidden":"true",children:Array.from({length:23},(c,u)=>u+1).map(c=>n.jsx("span",{className:"cal-hour-label",style:{top:`calc(var(--cal-hour) * ${c})`},children:ii(c*60)},c))}),l.map(({date:c,items:u})=>n.jsx("div",{className:"cal-col",role:"gridcell","aria-label":qs(c),"data-today":o(c),children:Y3(u.filter(f=>!f.part.allDay)).map(({event:f,part:d,lane:m,lanes:p})=>n.jsxs("button",{type:"button",className:"cal-event","data-tone":f.tone,"data-short":d.to-d.from<60?"true":void 0,"data-lane":m,"aria-label":np(f,d,c),onClick:()=>i(c),style:{top:`calc(var(--cal-hour) * ${d.from/60})`,height:`calc(var(--cal-hour) * ${Math.max(d.to-d.from,I1)/60})`,left:`calc((100% - var(--space-1)) * ${m/p} + var(--space-0))`,width:`calc((100% - var(--space-1)) / ${p} - var(--space-0))`},children:[n.jsx("span",{className:"cal-event-time",children:Ex(f,d)}),n.jsx("span",{className:"cal-event-title",children:f.title})]},f.id))},c))]})})]})})}const s6=3;function r6({dates:e,month:t,today:s,events:r,selected:i,onPick:a}){const l=Array.from({length:6},(f,d)=>e.slice(d*7,d*7+7)),[o,c]=t.split("-").map(Number),u=new Intl.DateTimeFormat("en-GB",{month:"long",year:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(o,c-1,1)));return n.jsx(Ze,{flush:!0,children:n.jsxs("div",{className:"cal-month",role:"grid","aria-label":u,children:[n.jsx("div",{className:"cal-row",role:"row",children:e.slice(0,7).map(f=>n.jsx("div",{className:"cal-wd-head",role:"columnheader",children:Nx(f)},f))}),l.map(f=>n.jsx("div",{className:"cal-row",role:"row",children:f.map(d=>{const m=Cx(r,d),p=m.slice(0,s6),v=m.length-p.length,w=m.length===0?"nothing":m.length===1?"1 event":`${m.length} events`;return n.jsxs("div",{className:"cal-cell",role:"gridcell","aria-selected":d===i,"data-date":d,"data-today":d===s?"true":void 0,"data-outside":d.slice(0,7)!==t?"true":void 0,"data-selected":d===i?"true":void 0,onClick:()=>a(d),children:[n.jsx("button",{type:"button",className:"cal-num","aria-label":`${qs(d)}, ${w}`,"aria-pressed":d===i,children:R1(d)}),p.map(({event:k,part:g})=>n.jsx("button",{type:"button",className:"cal-chip","data-tone":k.tone,"data-timed":g.allDay?void 0:"true","aria-label":np(k,g,d),children:g.allDay?k.title:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"cal-dot","data-tone":k.tone,"aria-hidden":"true"}),n.jsx("span",{className:"cal-chip-time",children:ii(g.from)})," ",k.title]})},k.id)),v>0?n.jsxs("button",{type:"button",className:"cal-more","aria-label":`${v} more on ${qs(d)}`,children:["+",v]}):null]},d)})},f[0]))]})})}const P1={width:1200,height:200,top:28,right:12,bottom:24,left:36};function i6(e,t){if(t==="percent")return[0,50,100];let s=e.length>0?Math.min(...e):0,r=e.length>0?Math.max(...e):1;t!=="temp"&&(s=Math.min(0,s)),s===r&&(s-=1,r+=1);const i=10**Math.floor(Math.log10(Math.max(1,(r-s)/3))),a=c=>Math.ceil(r/c)-Math.floor(s/c);let l=[1,2,5,10].map(c=>c*i).find(c=>a(c)<=3)??i*10;a(l)<2&&(l>1?l/=2:r+=l);const o=[];for(let c=Math.floor(s/l)*l;c<=Math.ceil(r/l)*l+l/1e3;c+=l)o.push(Math.round(c*1e6)/1e6);return o}function kc(e,t){return t==="temp"?`${e}°`:t==="percent"?`${e}%`:String(e)}function a6(e){const t=P1,s=e.values.length,r=t.width-t.left-t.right,i=t.height-t.top-t.bottom,a=t.height-t.bottom,l=s>0?r/s:r,o=g=>ai(t.left+l*(g+.5)),c=e.values.filter(g=>g!==null&&Number.isFinite(g)),u=i6(c,e.unit),f=u[0],d=u[u.length-1],m=g=>ai(t.top+i-(g-f)/(d-f)*i),p=e.values.map((g,x)=>{const y=g!==null&&Number.isFinite(g);return{index:x,x:o(x),y:y?m(g):null,value:y?g:null}}),v=[],w=[];if(e.kind==="area"){let g=[];const x=()=>{if(g.length===0)return;const y=g.map((j,N)=>`${N===0?"M":"L"}${j.x},${j.y}`).join(" ");v.push(y),w.push(`${y} L${g[g.length-1].x},${a} L${g[0].x},${a} Z`),g=[]};for(const y of p)y.y===null?x():g.push(y);x()}const k=e.kind==="bars"?p.flatMap(g=>g.y===null?[]:[{index:g.index,x:ai(g.x-l*.28),y:g.y,width:ai(l*.56),height:ai(a-g.y)}]):[];return{ticks:u.map(g=>({value:g,y:m(g)})),lines:v,areas:w,bars:k,points:p,slot:l,floor:a}}function l6({title:e,note:t,xs:s,series:r,tiles:i,labelEvery:a=3}){var N;const[l,o]=h.useState(((N=r[0])==null?void 0:N.id)??""),[c,u]=h.useState(null),[f,d]=h.useState(null),m=h.useRef(null),p=s.length,v=c??f,w=r.find(b=>b.id===l)??r[0],k=a6(w),g=P1,x=b=>b%a===0||b===v,y=w.values.filter(b=>b!==null&&Number.isFinite(b));h.useEffect(()=>{const b=m.current,S=v===null?null:b==null?void 0:b.children[v];!b||!S||typeof b.scrollTo!="function"||(S.offsetLeft<b.scrollLeft?b.scrollTo({left:S.offsetLeft,behavior:"smooth"}):S.offsetLeft+S.offsetWidth>b.scrollLeft+b.clientWidth&&b.scrollTo({left:S.offsetLeft+S.offsetWidth-b.clientWidth,behavior:"smooth"}))},[v]);const j=b=>{var R,E,P;const S=b.key==="ArrowRight"?1:b.key==="ArrowLeft"?-1:0,C=b.key==="Home"?0:b.key==="End"?p-1:S===0?null:Math.max(0,Math.min(p-1,(f??-S)+S));C!==null&&(b.preventDefault(),d(C),(P=(E=(R=m.current)==null?void 0:R.children[C])==null?void 0:E.querySelector("button"))==null||P.focus())};return n.jsxs(Ze,{...e?{title:e}:{},children:[t?n.jsx("p",{className:"ui-panel-sub",children:t}):null,n.jsxs("div",{className:"pg-series",onMouseLeave:()=>u(null),children:[r.length>1?n.jsx("div",{className:"pg-series-tabs",role:"tablist","aria-label":"Series",children:r.map(b=>n.jsx("button",{type:"button",role:"tab",className:"ui-tab","aria-selected":b.id===w.id,onClick:()=>o(b.id),children:b.label},b.id))}):null,n.jsxs("figure",{className:"pg-series-chart","data-kind":w.kind,children:[n.jsxs("svg",{viewBox:`0 0 ${g.width} ${g.height}`,"aria-hidden":"true",focusable:"false","data-testid":"series-svg",children:[k.ticks.map(b=>n.jsxs("g",{children:[n.jsx("line",{className:"pg-series-grid",x1:g.left,x2:g.width-g.right,y1:b.y,y2:b.y}),n.jsx("text",{className:"pg-series-tick",x:g.left-8,y:b.y,textAnchor:"end",dominantBaseline:"middle",children:kc(b.value,w.unit)})]},b.value)),k.areas.map((b,S)=>n.jsx("path",{className:"pg-series-area",d:b},`a${S}`)),k.lines.map((b,S)=>n.jsx("path",{className:"pg-series-line",d:b},`l${S}`)),k.bars.map(b=>n.jsx("rect",{className:"pg-series-bar","data-index":b.index,"data-hover":b.index===v?"true":void 0,x:b.x,y:b.y,width:b.width,height:b.height},b.index)),v!==null&&k.points[v]?n.jsx("line",{className:"pg-series-guide","data-index":v,x1:k.points[v].x,x2:k.points[v].x,y1:g.top-4,y2:k.floor}):null,w.kind==="area"?k.points.map(b=>b.y!==null&&x(b.index)?n.jsx("circle",{className:"pg-series-dot","data-index":b.index,"data-hover":b.index===v?"true":void 0,cx:b.x,cy:b.y,r:b.index===v?5:3},b.index):null):null,k.points.map(b=>b.y!==null&&b.value!==null&&x(b.index)?n.jsx("text",{className:"pg-series-value","data-index":b.index,"data-hover":b.index===v?"true":void 0,x:b.x,y:b.y-(w.kind==="area"?10:6),textAnchor:"middle",children:kc(b.value,w.unit)},b.index):null),k.points.map(b=>b.index%a===0?n.jsx("text",{className:"pg-series-x",x:b.x,y:g.height-6,textAnchor:"middle",children:s[b.index]},b.index):null),k.points.map(b=>n.jsx("rect",{className:"pg-series-hit","data-index":b.index,x:ai(g.left+k.slot*b.index),y:0,width:ai(k.slot),height:g.height,onMouseEnter:()=>u(b.index),onClick:()=>d(b.index)},b.index))]}),n.jsx("figcaption",{className:"sr-only",children:y.length===0?`${w.label}: no values.`:`${w.label}, ${p} ${p===1?"point":"points"} from ${s[0]} to ${s[p-1]}: lowest ${kc(Math.min(...y),w.unit)}, highest ${kc(Math.max(...y),w.unit)}.`})]}),n.jsx("ul",{className:"wb-tiles","data-layout":"strip",ref:m,onKeyDown:j,children:i.map((b,S)=>n.jsx("li",{className:"wb-tile",children:n.jsx("button",{type:"button",className:"ui-card","data-index":S,"data-hover":S===v?"true":void 0,"aria-pressed":S===f,"aria-label":[b.label,b.value,...b.lines].filter(C=>C!=="").join(", "),onMouseEnter:()=>u(S),onClick:()=>d(S),children:n.jsxs("div",{className:"wb-tile-body","aria-hidden":"true",children:[n.jsx("span",{className:"wb-tile-icon","data-icon":b.icon??"dot",children:n.jsx(Se,{name:Od(b.icon),size:22})}),b.value!==""?n.jsx("span",{className:"wb-tile-value tnum",children:b.value}):null,n.jsx("span",{className:"wb-tile-label",children:b.label}),b.lines.map((C,R)=>n.jsx("span",{className:"wb-tile-line",children:C},R))]})})},S))})]})]})}function ai(e){return Math.round(e*10)/10}const Tx=h.createContext(null),Uu=h.createContext(!1);function yt(){const e=h.useContext(Tx);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function sp(e,t=new Set){if(Array.isArray(e))for(const s of e)sp(s,t);else if(e&&typeof e=="object"){const s=e.query;typeof s=="string"&&t.add(s);for(const r of Object.values(e))sp(r,t)}return t}function M1(e,t){if(t.size===0)return!1;for(const s of sp(e))if(t.has(s))return!0;return!1}function $1(){const[e,t]=h.useState(!1);return h.useEffect(()=>{if(!e)return;const s=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",s),window.addEventListener("blur",s),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("blur",s)}},[e]),[e,()=>t(s=>!s)]}function D1({revealed:e,onToggle:t}){return n.jsx(I,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function O1(){return n.jsx("p",{className:"muted",children:"Hidden until you show it."})}function _1({children:e}){const[t,s]=$1();return n.jsxs(q,{gap:"sm",children:[n.jsx(Q,{align:"end",children:n.jsx(D1,{revealed:t,onToggle:s})}),t?n.jsx(Uu.Provider,{value:!0,children:e}):n.jsx(O1,{})]})}function Rx(e){return e===void 0||e==="neutral"?void 0:e}function rp(e){return Rx(e)}function o6(e){const t=Rx(e);return t==="accent"?void 0:t}function us(e,t){if(!t)return!0;const s=me(e,t.path),r=t.in!==void 0?t.in.includes(s):s===t.equals;return t.not===!0?!r:r}function Ix(e,t,s){if("chat"in t){const a=Pe(s,t.chat);return a==null?"":Ke(String(a))}if("proposals"in t)return fD(e.plugin);const r=e.pages.find(a=>a.id===t.page);if((r==null?void 0:r.place)==="settings")return No(e.plugin,t.page);const i=t.item===void 0?null:Pe(s,t.item);return _r(e.plugin,t.page,i==null?null:String(i))}function c6(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(s,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(s,r)=>{const i=me(t.row,r);return i==null?"":String(i)})}function ip(e,t){if(e===void 0)return;if(typeof e=="string")return e;const s=Pe(t,e);return s==="good"||s==="warning"||s==="critical"||s==="neutral"?s:void 0}function L1(e,t,s){const r={};for(const[i,a]of Object.entries(e??{})){let l;"param"in a?l=s.params[a.param]:"route"in a?l=a.route==="plugin"?s.plugin:a.route==="page"?s.page:s.item:l=Pe(t,a),!(l==null||l==="")&&(r[i]=String(l))}return r}function ki(e,t){var r,i,a;const s={};for(const[l,o]of Object.entries(e??{}))if("row"in o)s[l]=me(t.row,o.row);else if("field"in o){if((r=t.omit)!=null&&r.has(o.field))continue;const c=(i=t.fields)==null?void 0:i[o.field],u=(a=t.shape)==null?void 0:a.find(f=>f.name===o.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;s[l]=c}else"selected"in o?s[l]=t.selected??[]:"param"in o?s[l]=t.scope.params[o.param]:s[l]=Pe(t.data,o);return s}function pn(e,t,s,r){const i=yt(),a=e?{...L1(e.params,t,i),...r}:{},l=JSON.stringify([(e==null?void 0:e.query)??null,a,i.version]),o=ie(()=>e?A.pageQuery(i.plugin,e.query,a).then(c=>c.data):Promise.resolve(void 0),[l],s);return{data:o.data,error:o.error,loading:o.loading}}function To(){const e=yt(),t=h.useId(),[s,r]=h.useState(null),[i,a]=h.useState(null),[l,o]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(null),m=(k,g)=>{if(k.done===void 0)return null;if(typeof k.done=="string")return k.done;const x=Pe(g,k.done);return x==null?null:String(x)},p=(k,g,x)=>{const y=k??"refresh";if(typeof y=="object"){const j=Ix(e,y.route,g);j===""?e.refresh():e.navigate(j);return}y==="close"&&(x==null||x()),e.refresh()},v=async(k,g,x)=>{r(k.tool),a(null),o(null);try{const y=await A.pageAct(e.plugin,{tool:k.tool,args:g});if(y.approvalId){u(y.approvalId),d({then:k.then,ref:k,...x?{onDone:x}:{}});return}u(null),d(null);const j=N1(y.result);o(m(k,y.result)??(j?C1(y.result):null)),j&&await A1(j,t),p(k.then,y.result,x)}catch(y){a(y instanceof Error?y.message:String(y)),e.refresh()}finally{r(null)}},w=k=>{if(!k){e.refresh();return}const g=f;if(u(null),d(null),g&&k.decision==="approve"&&k.state==="succeeded"){o(m(g.ref,k.result)),p(g.then,void 0,g.onDone);return}e.refresh()};return{running:s,busy:s!==null,error:i,done:l,approvalId:c,waiting:(f==null?void 0:f.ref.pending)??null,settle:w,run:v}}function Pa({action:e,args:t,disabled:s,running:r,count:i,row:a,onRun:l}){const[o,c]=h.useState(!1),u=d=>c6(d,{...i===void 0?{}:{count:i},row:a}),f=u(e.label);return o&&e.confirm?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),n.jsx(I,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),n.jsxs(I,{variant:e.tone==="danger"?"danger":"accent",disabled:s,onClick:()=>{c(!1),l(e,t)},children:["Yes, ",f.toLowerCase()]})]}):n.jsx(I,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:s,onClick:()=>e.confirm?c(!0):l(e,t),children:r&&e.busy?e.busy:f})}function Bu({id:e,onDecided:t}){const s=yt(),r=ie(()=>A.approval(e),[e,s.version]),{busy:i,note:a,failure:l,decide:o}=wx(c=>{t?t(c):s.refresh()});return r.error?n.jsx(ne,{message:r.error}):r.data?n.jsxs(q,{children:[n.jsx(bx,{action:r.data,timezone:s.timezone,busy:i===e,onDecide:(c,u,f,d)=>{o(c,u,f,d)}}),a?n.jsx(H,{tone:"good",role:"status",children:a}):null,n.jsx(ne,{message:l})]}):n.jsx(oe,{children:"Loading the approval…"})}function Ya({act:e}){return e.error?n.jsx(ne,{message:e.error}):e.approvalId?e.waiting?n.jsxs(q,{children:[n.jsx(H,{role:"status",children:e.waiting}),n.jsx(Bu,{id:e.approvalId,onDecided:e.settle})]}):n.jsx(Bu,{id:e.approvalId,onDecided:e.settle}):e.done?n.jsx(H,{tone:"good",role:"status",children:e.done}):null}function zu(e,t){const s={};for(const r of e){const i=r.from===void 0?void 0:me(t,r.from);s[r.name]=r.multiple?Array.isArray(i)?i.map(String):[]:i!==void 0?i:r.type==="checkbox"?!1:""}return s}function F1(e,t,s){const r=yt(),i=e.optionsFrom,a=i?{...L1(i.query.params,s,r),...Object.fromEntries((i.dependsOn??[]).map(c=>[c,String(t[c]??"")]).filter(([,c])=>c!==""))}:{},l=JSON.stringify([(i==null?void 0:i.query.query)??null,a,r.version]),o=ie(()=>i?A.pageQuery(r.plugin,i.query.query,a).then(c=>c.data):Promise.resolve(void 0),[l]);return i?{options:Ds(o.data,i.rows).map(c=>({value:String(me(c,i.value)??""),label:String(me(c,i.label)??"")})),loading:o.loading}:{options:e.options??[],loading:!1}}function u6({field:e,fields:t,value:s,values:r,data:i,disabled:a,compact:l,onChange:o}){const c=F1(e,r,i),u={id:`f-${e.name}`,required:e.required,name:e.name,disabled:a,...l&&e.hint?{title:e.hint}:{}},f=l?void 0:e.hint;if(e.type==="select"&&e.multiple){const m=Array.isArray(s)?s.map(String):[],v=e.max!==void 0&&m.length>=e.max?`Up to ${e.max}; remove one to add another.`:void 0;return n.jsx(te,{label:e.label,hint:l?void 0:[f,v].filter(Boolean).join(" ")||void 0,group:!0,children:n.jsx(i_,{id:u.id,label:e.label,options:c.options,value:m,max:e.max,disabled:a,onChange:o})})}if(e.type==="select"){const m=n.jsxs("select",{...u,value:String(s??""),onChange:p=>o(p.target.value),children:[n.jsx("option",{value:"",children:c.loading?"Loading…":"—"}),c.options.map(p=>n.jsx("option",{value:p.value,children:p.label},p.value))]});return e.action&&!l?n.jsx(d6,{field:e,action:e.action,fields:t??[e],values:r,data:i,disabled:a,hint:f,children:m}):n.jsx(te,{label:e.label,hint:f,children:m})}if(e.type==="textarea")return n.jsx(te,{label:e.label,hint:f,wide:!0,children:n.jsx("textarea",{...u,value:String(s??""),onChange:m=>o(m.target.value),rows:6})});if(e.type==="checkbox")return n.jsx(te,{label:e.label,hint:f,inline:!0,wide:!l,children:n.jsx("input",{...u,type:"checkbox",checked:s===!0,onChange:m=>o(m.target.checked)})});const d=e.type==="secret"?"password":e.type==="number"?"number":e.type;return n.jsx(te,{label:e.label,hint:f,children:n.jsx("input",{...u,type:d,value:s==null?"":String(s),min:e.min,max:e.max,step:e.step,...l&&e.hint?{placeholder:e.hint}:{},onChange:m=>o(e.type==="number"?h6(m.target.value):m.target.value)})})}function d6({field:e,action:t,fields:s,values:r,data:i,disabled:a,hint:l,children:o}){const c=yt(),u=h.useId(),f=L3()===u,[d,m]=h.useState(!1),[p,v]=h.useState(null),[w,k]=h.useState(null),[g,x]=h.useState(null);h.useEffect(()=>()=>iw(u),[u]);const y=Px(s,r,i),j=t.args!==void 0?ki(t.args,{data:i,fields:r,shape:s,omit:y,scope:c}):Object.fromEntries(Object.entries(r).filter(([S,C])=>!y.has(S)&&C!=="")),N=async()=>{if(f){iw(u);return}m(!0),v(null),k(null),x(null);try{const S=await A.pageAct(c.plugin,{tool:t.tool,args:j});if(S.approvalId){x(S.approvalId);return}v(C1(S.result));const C=N1(S.result);C&&await A1(C,u)}catch(S){k(S instanceof Error?S.message:String(S))}finally{m(!1)}},b=f?"Stop":t.label;return n.jsx(te,{label:e.label,hint:l,action:n.jsx(I,{"data-shape":"icon","aria-label":d?`${t.label}: working`:b,title:b,"aria-busy":d||void 0,"aria-pressed":t.icon==="play"?f:void 0,disabled:a===!0||d,onClick:()=>void N(),children:d?n.jsx("span",{className:"ui-spinner","aria-hidden":"true"}):n.jsx(Se,{name:f?"stop":t.icon??"arrow"})}),after:w?n.jsx(ne,{message:w}):g?n.jsx(Bu,{id:g,onDecided:()=>x(null)}):p?n.jsx("span",{className:"ui-field-hint",role:"status",children:p}):null,children:o})}function h6(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function U1(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function Px(e,t,s){const r=U1(t,s);return new Set(e.filter(i=>i.when!==void 0&&!us(r,i.when)||i.disabledWhen!==void 0&&us(r,i.disabledWhen)).map(i=>i.name))}function Mx({fields:e,values:t,data:s,disabled:r,compact:i,columns:a,onChange:l}){const o=U1(t,s);return n.jsx(sr,{dense:i,columns:a,children:e.filter(c=>c.when===void 0||us(o,c.when)).map(c=>n.jsx(u6,{field:c,fields:e,compact:i,value:t[c.name],values:t,data:s,disabled:r===!0||c.disabledWhen!==void 0&&us(o,c.disabledWhen),onChange:u=>l(c.name,u)},c.name))})}const ho=h.createContext(!1),B1=h.createContext(!1),z1=h.createContext(!1);function Bn({title:e,note:t,actions:s,children:r}){const i=h.useContext(ho);return n.jsx(J,{title:e,aside:t,actions:s,panel:i,children:n.jsx(ho.Provider,{value:!1,children:n.jsx(B1.Provider,{value:i,children:r})})})}function $s({component:e,data:t,choose:s,chosen:r}){const i=yt(),a=h.useContext(Uu);if(!us(t,e.when))return null;if(e.kind!=="section"&&!a&&M1(e,i.sensitive))return n.jsx(_1,{children:n.jsx($s,{component:e,data:t,...s?{choose:s}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return n.jsx(f6,{component:e,data:t});case"notice":return n.jsx(H,{tone:Rx(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(Pe(t,e.text)??"")});case"link":return n.jsx(m6,{component:e,data:t});case"progress":return n.jsx(g6,{component:e,data:t});case"chart":return n.jsx(x6,{component:e,data:t});case"stats":return n.jsx(v6,{component:e,data:t});case"list":return n.jsx(y6,{component:e,data:t,...s?{onChoose:s}:{},...r===void 0?{}:{chosen:r}});case"table":return n.jsx(w6,{component:e,data:t});case"detail":return n.jsx(S6,{component:e,data:t});case"form":return n.jsx(N6,{component:e,data:t});case"search":return n.jsx(A6,{component:e,data:t});case"list-detail":return n.jsx(T6,{component:e,data:t});case"repeat":return n.jsx(R6,{component:e,data:t});case"calendar":return n.jsx(I6,{component:e,data:t});case"tiles":return n.jsx(P6,{component:e,data:t});case"series-panel":return n.jsx(M6,{component:e,data:t});case"hero":return n.jsx($6,{component:e,data:t});case"tabs":return n.jsx(D6,{component:e,data:t});case"expand":return n.jsx(O6,{component:e,data:t});case"button":return n.jsx(_6,{component:e,data:t});case"approval":return n.jsx(F6,{component:e,data:t});case"artifact":return n.jsx(U6,{component:e,data:t});case"editor":return n.jsx(B6,{component:e,data:t});case"agent-offer":return n.jsx(L6,{component:e});default:return n.jsx(H,{children:"This page uses a part this dashboard does not know yet. Reload buddi to see it."})}}function f6({component:e,data:t}){const s=yt(),r=h.useContext(Uu),[i,a]=$1(),l=!r&&M1(e.body,s.sensitive),o=l&&!i,c=h.useContext(ho);let u=e.body.length;const f=p=>p.kind==="button"||p.kind==="link"||p.kind==="form"&&p.drawer!==void 0&&!p.title;for(;c&&u>0&&f(e.body[u-1]);)u-=1;const d=e.body.slice(0,u),m=[...e.actions??[],...e.body.slice(u)];return n.jsx(Bn,{title:e.title,note:e.note,actions:m.length>0||l?n.jsxs(n.Fragment,{children:[m.map((p,v)=>n.jsx($s,{component:p,data:t},v)),l?n.jsx(D1,{revealed:i,onToggle:a}):null]}):void 0,children:n.jsx(q,{gap:"lg",divided:c,children:o?n.jsx(O1,{}):n.jsx(Uu.Provider,{value:r||l,children:d.map((p,v)=>n.jsx($s,{component:p,data:t},v))})})})}function m6({component:e,data:t}){const s=yt(),r=Ix(s,e.to,t);return r===""?null:n.jsx(Q,{children:n.jsx(Yt,{href:r,onClick:i=>{i.preventDefault(),s.navigate(r)},children:e.label})})}function uw(e){return Math.round(e/1e6)}function p6(e,t){const s=$n(Pe(t,e.value))??0,r=e.total?$n(Pe(t,e.total)):null,i=e.total?r&&r>0?s/r:0:s,a=Math.max(0,Math.min(1,i)),l=Math.floor(a*100),o=i>=1,c=e.total&&r&&r>0?`${uw(s)} of ${Math.max(1,uw(r))} MB · ${l}%`:`${l}%`;return{percent:l,full:o,line:c}}function g6({component:e,data:t}){const s=c=>c===void 0?"":typeof c=="string"?c:String(Pe(t,c)??""),r=s(e.label),i=s(e.done),{percent:a,full:l,line:o}=p6(e,t);return n.jsxs(q,{gap:"sm",children:[r?n.jsx("span",{children:r}):null,l&&i?n.jsx("span",{role:"status",children:i}):n.jsxs(n.Fragment,{children:[n.jsx(LN,{value:a,label:r||"Progress"}),n.jsx("span",{role:"status",children:o})]})]})}function x6({component:e,data:t}){const s=pn(e.query,t),r=e.rows===void 0?Array.isArray(s.data)?s.data:[]:Ds(s.data,e.rows),i=r.map(f=>String(me(f,e.x)??"")),a=f=>r.map(d=>$n(me(d,f))??null),l=e.series!==void 0,o=e.y===void 0?[]:Array.isArray(e.y)?e.y:[e.y],c=l?e.series.map(f=>({label:f.label,values:a(f.y),type:f.type,...f.unit?{unit:f.unit}:{}})):o.map(f=>({label:o.length===1?e.label??f:f,values:a(f)})),u=e.target?$n(Pe(s.data,e.target))??null:null;return n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:s.error}),r.length===0?s.loading||s.data===void 0?n.jsx(oe,{children:"Loading…"}):n.jsx(qa,{text:e.empty??"Nothing recorded yet."}):n.jsx(ZO,{xs:i,series:c,type:l?"mixed":e.type??"line",target:u,...e.label?{label:e.label}:{},formatX:f=>/^\d{4}-\d{2}-\d{2}/.test(f)?Am(f):f,formatY:f=>$t(f,"number",null)})]})}function v6({component:e,data:t}){const s=pn(e.query,t);return n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:s.error}),s.data===void 0?n.jsx(oe,{children:e.empty??"Loading…"}):n.jsx($d,{children:e.items.map((r,i)=>n.jsx(Es,{label:r.label,value:$t(Pe(s.data,r.value),r.unit??"text",null),tone:o6(r.tone)},i))})]})}function W1(e,t,s,r){const i=(t.meta??[]).map(u=>String(Pe(s,u)??"")).filter(u=>u!==""),a=String(Pe(s,t.title)??""),l=t.to&&!r?Ix(e,t.to,s):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,f)=>{const d=Pe(s,u.value);if(d==null||d==="")return null;const m=j6(u,d,s);return n.jsx(xe,{tone:rp(m.tone),children:m.text},f)});return{text:a,href:l,pills:n.jsx(n.Fragment,{children:c}),meta:i.join(" · "),title:l?n.jsx("a",{href:l,onClick:u=>{u.preventDefault(),e.navigate(l)},children:a}):a,sub:t.sub?String(Pe(s,t.sub)??""):null,side:n.jsxs(n.Fragment,{children:[c,i.length>0?n.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function j6(e,t,s){const r=String(t),i=e.labels??{},a=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(a,r)?a[r]:ip(e.tone,s)}}function Ds(e,t){const s=me(e,t);return Array.isArray(s)?s:[]}function H1(e,t,s){const r=[],i=new Set;return e.forEach((a,l)=>{const o=t===void 0?void 0:me(a,t),c=o==null||o===""?null:String(o);if(c===null){console.warn(`buddi: plugin ${s.plugin}, page ${s.page}, ${s.component}: row ${l} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${s.plugin}, page ${s.page}, ${s.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:a})}),r}function y6({component:e,data:t,onChoose:s,chosen:r}){var N;const i=yt(),a=h.useContext(z1),l=pn(e.query,t),o=To(),[c,u]=h.useState([]),f=a&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,d=Ds(l.data,e.rows),m=e.collapsed?Ds(l.data,e.collapsed.rows):[],p={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},v=H1([...d,...m],e.key??((N=e.select)==null?void 0:N.key),p),w=new Map(v.map(b=>[b.row,b.key])),k=new Set(v.map(b=>b.row)),g=new Set(v.filter(({row:b})=>{var S;return((S=e.select)==null?void 0:S.disabledWhen)===void 0||!us(b,e.select.disabledWhen)}).map(({key:b})=>b)),x=c.filter(b=>g.has(b)),y=h.useMemo(()=>{const b=d.filter(C=>k.has(C));if(!e.groupBy)return[{label:null,rows:b}];const S=new Map;for(const C of b){const R=String(me(C,e.groupBy.key)??"");S.set(R,[...S.get(R)??[],C])}return[...S].map(([C,R])=>{var E,P;return{label:((P=(E=e.groupBy)==null?void 0:E.labels)==null?void 0:P[C])??C,rows:R}})},[d,e.groupBy,v.length]),j=b=>b.map(S=>{var F;const C=W1(i,e.item,S,s),R=w.get(S);if(f&&(s||C.href))return n.jsx(FN,{href:C.href??"#",current:r===R,onClick:()=>s?s(R):i.navigate(C.href),title:C.text,meta:C.meta,sub:C.sub,side:C.pills},R);const E=((F=e.select)==null?void 0:F.disabledWhen)!==void 0&&us(S,e.select.disabledWhen),P=(e.actions??[]).filter(M=>us(S,M.when));return n.jsx(Et,{lead:e.select?n.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(R),onClick:M=>M.stopPropagation(),onChange:M=>u(T=>M.target.checked?[...T,R]:T.filter($=>$!==R))}):void 0,title:s?n.jsx("a",{href:"#","aria-current":r===R?"true":void 0,onClick:M=>{M.preventDefault(),s(R)},children:C.text}):C.title,sub:C.sub,side:n.jsxs(n.Fragment,{children:[C.side,P.map((M,T)=>n.jsx(Pa,{action:M,args:ki(M.args,{data:l.data,row:S,scope:i}),disabled:o.busy,running:o.running===M.tool,row:S,onRun:($,_)=>void o.run($,_)},T))]})},R)});return n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:l.error}),n.jsx(Ya,{act:o}),y.every(b=>b.rows.length===0)?l.loading?n.jsx(oe,{children:"Loading…"}):n.jsx(qa,{text:e.empty??"Nothing here yet."}):n.jsxs(Ct,{children:[e.select?n.jsx(Et,{lead:n.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:g.size>0&&x.length===g.size,disabled:g.size===0,onChange:b=>u(b.target.checked?[...g]:[])}),title:n.jsxs("span",{className:"muted",children:[g.size," to choose from"]})}):null,y.map((b,S)=>n.jsxs("div",{children:[b.label?n.jsx("div",{className:"ui-list-group",children:b.label}):null,j(b.rows)]},S))]}),e.collapsed&&m.some(b=>k.has(b))?n.jsx(Tt,{summary:`${e.collapsed.label} (${m.filter(b=>k.has(b)).length})`,children:n.jsx(Ct,{children:j(m.filter(b=>k.has(b)))})}):null,e.bulk&&e.bulk.length>0?n.jsxs(Q,{align:"end",children:[n.jsxs("span",{className:"ui-toolbar-note",children:[x.length," selected"]}),e.bulk.map((b,S)=>{const C=x.length>0||b.all!==!0?x:[...g];return n.jsx(Pa,{action:b,args:ki(b.args,{data:l.data,selected:C,scope:i}),count:C.length,disabled:o.busy||C.length===0,running:o.running===b.tool,onRun:(R,E)=>{u([]),o.run(R,E)}},S)})]}):null]})}function w6({component:e,data:t}){const s=yt(),r=pn(e.query,t),i=To(),a=Ds(r.data,e.rows);return n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:r.error}),n.jsx(Ya,{act:i}),a.length===0?r.loading?n.jsx(oe,{children:"Loading…"}):n.jsx(qa,{text:e.empty??"Nothing here yet."}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[e.columns.map(l=>n.jsx("th",{children:l.label},l.key)),e.actions&&e.actions.length>0?n.jsx("th",{"aria-label":"Actions"}):null]})}),n.jsx("tbody",{children:a.map((l,o)=>n.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:$t(me(l,c.key),c.type??"text",null);return n.jsx("td",{"data-fit":c.fit,title:b6(c,l,u),children:c.pill?n.jsx(k6,{column:c,row:l}):c.fit==="truncate"?n.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?n.jsx("td",{children:n.jsx(Q,{align:"end",children:e.actions.filter(c=>us(l,c.when)).map((c,u)=>n.jsx(Pa,{action:c,args:ki(c.args,{data:r.data,row:l,scope:s}),disabled:i.busy,running:i.running===c.tool,row:l,onRun:(f,d)=>void i.run(f,d)},u))})}):null]},o))})]})]})}function b6(e,t,s){if(e.hint){const r=me(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&s?s:void 0}function k6({column:e,row:t}){var l,o;const s=me(t,e.key);if(Array.isArray(s))return n.jsx(n.Fragment,{children:s.map((c,u)=>{var w;const f=c,d=typeof f=="object"&&f!==null?f.value:c;if(d==null||d==="")return null;const m=typeof f=="object"&&f!==null?f.tone:void 0,p=(w=e.pill)==null?void 0:w.labels,v=p&&Object.prototype.hasOwnProperty.call(p,String(d))?p[String(d)]:$t(d,e.type??"text",null);return n.jsx(xe,{tone:rp(ip(typeof m=="string"?m:void 0,t)),children:v},u)})});const r=(l=e.pill)==null?void 0:l.labels,i=String(s),a=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:$t(s,e.type??"text",null);return n.jsx(xe,{tone:rp(ip((o=e.pill)==null?void 0:o.tone,t)),children:a})}function S6({component:e,data:t}){const s=pn(e.query,t);return s.error?n.jsx(ne,{message:s.error}):s.data===void 0?n.jsx(oe,{children:e.empty??"Loading…"}):n.jsx(Bn,{title:e.title,note:e.note,children:n.jsxs(q,{gap:"lg",children:[e.fields.length>0?n.jsx(Kt,{items:e.fields.map(r=>({key:r.label,label:r.label,value:$t(Pe(s.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>n.jsx($s,{component:r,data:s.data},i))]})})}function N6({component:e,data:t}){const s=yt(),r=pn(e.initial,t),i=To(),[a,l]=h.useState(!1),o=JSON.stringify([r.data??null,s.version]),c=n.jsx(C6,{component:e,data:t,initialData:r.data,act:i,onDone:()=>l(!1)},o);return e.drawer?n.jsxs(J,{title:e.title,aside:e.note,actions:n.jsx(I,{variant:"accent",onClick:()=>l(!0),children:e.drawer.button}),children:[n.jsx(Ya,{act:i}),a?n.jsx(Dt,{title:e.drawer.title,onClose:()=>l(!1),children:c}):null]}):n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:r.error}),c]})}function C6({component:e,data:t,initialData:s,act:r,onDone:i}){const a=h.useContext(B1),l=yt(),[o,c]=h.useState(()=>zu(e.fields,s)),u=Px(e.fields,o,s),f=e.fields.some(d=>d.required&&!u.has(d.name)&&(o[d.name]===""||o[d.name]===void 0||Array.isArray(o[d.name])&&o[d.name].length===0));return n.jsxs(q,{children:[n.jsx(Mx,{fields:e.fields,columns:e.columns,values:o,data:s,onChange:(d,m)=>c(p=>({...p,[d]:m}))}),e.drawer?null:n.jsx(Ya,{act:r}),n.jsx(Q,{align:"end",className:a?"ui-panel-foot":void 0,children:n.jsx(Pa,{action:e.submit,args:ki(e.submit.args,{data:t,fields:o,shape:e.fields,omit:u,scope:l}),disabled:r.busy||f,running:r.running===e.submit.tool,onRun:(d,m)=>void r.run(d,m,i)})})]})}function E6(e,t){var r;if(e.type==="checkbox")return e.label;const s=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${s?s.label:t}`}function dw(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function A6({component:e,data:t}){const s=yt(),[r,i]=h.useState(()=>zu(e.fields,t)),[a,l]=h.useState(e.auto===!0),[o,c]=h.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),f=pn(a&&u?e.query:void 0,t),d=Ds(f.data,e.rows),m=e.count===void 0?void 0:me(f.data,e.count),p=e.note===void 0?void 0:me(f.data,e.note),v=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==v),k=C=>{s.setParams(Object.fromEntries(e.fields.map(R=>[R.name,String(C[R.name]??"")||null]))),l(!0)},g=(C,R)=>{const E={...r,[C]:R};i(E),e.auto&&k(E)},x=()=>{const C=zu(e.fields,null);i(C),e.auto?k(C):(s.setParams(Object.fromEntries(e.fields.map(R=>[R.name,null]))),l(!1))},y=a?w.filter(C=>dw(s.params[C.name])):[],j=v?y.map(C=>n.jsx(Pu,{label:C.label,onRemove:()=>{const R={...r,[C.name]:C.type==="checkbox"?!1:""};i(R),k(R)},children:E6(C,String(s.params[C.name]))},C.name)):[],N=w.filter(C=>dw(r[C.name])).length,b=e.auto&&!e.reset?null:n.jsxs(n.Fragment,{children:[e.reset?n.jsx(I,{variant:"ghost",onClick:x,children:"Clear"}):null,e.auto?null:n.jsx(I,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),S=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return n.jsx(Bn,{title:e.title,children:n.jsxs(q,{children:[n.jsx(WN,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&k(r)},main:v?n.jsx("input",{id:`f-${v.name}`,name:v.name,type:v.type==="email"?"email":"search","aria-label":v.label,placeholder:v.hint??v.label,title:v.hint,required:v.required,value:String(r[v.name]??""),onChange:C=>g(v.name,C.target.value)}):void 0,filters:w.length>0?n.jsx(Mx,{fields:w,values:r,data:t,compact:!0,onChange:g}):void 0,...v&&w.length>0?{filtersOpen:o,onToggleFilters:()=>c(C=>!C),active:N}:{},chips:j.length>0?j:void 0,actions:b}),n.jsx(ne,{message:f.error}),a&&(m!==void 0||p!==void 0)?n.jsxs("p",{className:"ui-card-meta",children:[m===void 0?"":`${$t(m,"number",null)} in all. `,p===void 0?"":String(p)]}):null,a?d.length===0?n.jsx(oe,{children:f.loading?"Searching…":e.empty??"Nothing matches."}):n.jsx("div",{className:"ui-panel","data-flush":"true",children:n.jsx(Ct,{children:d.map((C,R)=>{const E=W1(s,S,C);return n.jsx(Et,{title:E.title,sub:E.sub,side:E.side},R)})})}):null]})})}function T6({component:e,data:t}){const s=yt(),r=e.selection==="local",[i,a]=h.useState(null),l=r?i:s.params[e.param]??s.item,o=r&&i!==null?{...s,params:{...s.params,[e.param]:i}}:null,c=n.jsx(q,{gap:"lg",divided:!0,children:e.detail.map((u,f)=>n.jsx($s,{component:u,data:t},f))});return n.jsx(ho.Provider,{value:!1,children:n.jsx(UN,{list:n.jsx(z1.Provider,{value:!0,children:n.jsx($s,{component:e.list,data:t,chosen:l??null,...r?{choose:a}:{}})}),detail:l?o?n.jsx(Tx.Provider,{value:o,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function R6({component:e,data:t}){const s=yt(),[r,i]=h.useState(!1),a=pn(e.query,t,r&&e.poll?e.poll.seconds*1e3:void 0),l=e.poll!==void 0&&a.data!==void 0&&us(a.data,e.poll.while);h.useEffect(()=>i(l),[l]);const o=Ds(a.data,e.rows);return n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:a.error}),o.length===0?a.loading?n.jsx(oe,{children:"Loading…"}):n.jsx(qa,{text:e.empty??"Nothing here yet."}):n.jsx(q,{gap:"lg",divided:!0,children:H1(o,e.key,{plugin:s.plugin,page:s.page,component:`repeat "${e.title??e.rows}"`}).map(({key:c,row:u})=>n.jsx(J,{children:n.jsx(q,{children:e.body.map((f,d)=>n.jsx($s,{component:f,data:u},d))})},c))})]})}function I6({component:e,data:t}){const s=yt(),r=e6({...e.views?{views:e.views}:{},...e.default?{default:e.default}:{},today:z3(s.timezone),storageKey:`buddi.calendar-view:${s.plugin}/${s.page}`}),i=pn(e.query,t,void 0,{from:r.from,to:r.to}),a=h.useMemo(()=>K3(Ds(i.data,e.events),e.map,s.timezone,`plugin ${s.plugin}, page ${s.page}, calendar`),[i.data,e.events,e.map,s.timezone,s.plugin,s.page]);return n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:i.error}),n.jsx(t6,{state:r,events:a,hours:e.hours,empty:e.empty??"Nothing.",label:e.title??"Calendar"})]})}function P6({component:e,data:t}){var d;const s=yt(),r=pn(e.query,t),i={items:"$",icon:e.icon,value:e.value,label:e.label,...e.lines?{lines:e.lines}:{},...e.tone?{tone:e.tone}:{}},a=Ds(r.data,e.items).flatMap(m=>{const p=nx([m],i).tiles[0];return p?[{tile:p,key:e.select?String(me(m,e.select.key)??""):""}]:[]}),l=e.select,o=l?Math.max(0,a.findIndex(m=>m.key===s.params[l.param])):null,c=((d=a[0])==null?void 0:d.key)??"",u=l?s.params[l.param]:void 0,f=a.some(m=>m.key===u);return h.useEffect(()=>{l&&c!==""&&!f&&s.setParams({[l.param]:c})},[l==null?void 0:l.param,c,f]),n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:r.error}),r.data===void 0?n.jsx(oe,{children:"Loading…"}):a.length===0?n.jsx(qa,{text:e.empty??"Nothing to show."}):n.jsx(t1,{props:{tiles:a.map(m=>m.tile),notice:!1,empty:""},...e.layout?{layout:e.layout}:{},...l?{selected:o,onPick:m=>{var p;return s.setParams({[l.param]:((p=a[m])==null?void 0:p.key)||null})}}:{}})]})}function M6({component:e,data:t}){const s=pn(e.query,t),r=Ds(s.data,e.points);if(s.data===void 0||r.length===0)return n.jsxs(Bn,{title:e.title,note:e.note,children:[n.jsx(ne,{message:s.error}),s.data===void 0?n.jsx(oe,{children:"Loading…"}):n.jsx(qa,{text:e.empty??"Nothing to show."})]});const i=r.map(c=>String(me(c,e.x)??"")),a={items:"$",icon:e.tiles.icon,value:e.tiles.value,label:e.tiles.label,...e.tiles.lines?{lines:e.tiles.lines}:{}},l=r.map((c,u)=>nx([c],a).tiles[0]??{icon:null,value:"",label:i[u]??"",lines:[],tone:"neutral",link:null}),o=e.series.map(c=>({id:c.id,label:c.label,kind:c.kind,...c.unit?{unit:c.unit}:{},values:r.map(u=>$n(me(u,c.y))??null)}));return n.jsxs(n.Fragment,{children:[n.jsx(ne,{message:s.error}),n.jsx(l6,{...e.title?{title:e.title}:{},...e.note?{note:e.note}:{},...e.labelEvery?{labelEvery:e.labelEvery}:{},xs:i,series:o,tiles:l})]})}function $6({component:e,data:t}){const s=pn(e.query,t),r=o=>{const c=me(s.data,o);return c==null?"":String(c)};if(s.data===void 0||s.data===null)return n.jsxs(n.Fragment,{children:[n.jsx(ne,{message:s.error}),n.jsx(oe,{children:s.loading?"Loading…":e.empty??"Nothing to show."})]});const i=r(e.value),a=r(e.title),l=e.facts.map(o=>({label:o.label,value:r(o.path)})).filter(o=>o.value!=="");return n.jsxs("section",{className:"pg-hero","aria-label":[i,a,...l.map(o=>`${o.label} ${o.value}`)].filter(Boolean).join(", "),children:[n.jsxs("div",{className:"pg-hero-main","aria-hidden":"true",children:[n.jsx("span",{className:"pg-hero-icon",children:n.jsx(Se,{name:Od(Dm(Pe(s.data,e.icon))),size:44})}),n.jsx("span",{className:"pg-hero-value",children:i}),a?n.jsx("span",{className:"pg-hero-title",children:a}):null]}),l.length>0?n.jsx("dl",{className:"pg-hero-facts","aria-hidden":"true",children:l.map(o=>n.jsxs("div",{className:"pg-hero-fact",children:[n.jsx("dt",{children:o.label}),n.jsx("dd",{children:o.value})]},o.label))}):null]})}function D6({component:e,data:t}){var u;const s=yt(),[r,i]=h.useState(e.default??e.tabs[0].id),a=e.pick,{options:l}=F1({name:(a==null?void 0:a.param)??"",label:(a==null?void 0:a.label)??"",...a!=null&&a.options?{options:a.options}:{},...a!=null&&a.optionsFrom?{optionsFrom:a.optionsFrom}:{}},{},t),o=a?l.some(f=>f.value===s.params[a.param])?s.params[a.param]:((u=l[0])==null?void 0:u.value)??"":"",c=e.tabs.find(f=>f.id===r)??e.tabs[0];return n.jsxs("div",{className:"pg-tabs",children:[n.jsxs("div",{className:"pg-tabs-bar",children:[a&&l.length>1?n.jsx(Ys,{label:a.label,options:l,value:o,onChange:f=>s.setParams({[a.param]:f})}):null,n.jsx(Ys,{label:e.title??"View",options:e.tabs.map(f=>({value:f.id,label:f.label})),value:c.id,onChange:i})]}),c.body.map((f,d)=>n.jsx($s,{component:f,data:t},`${c.id}-${d}`))]})}function O6({component:e,data:t}){const[s,r]=h.useState(!1),i=pn(s?e.query:void 0,t),a=typeof e.label=="string"?e.label:String(Pe(t,e.label)??"");return n.jsxs(Tt,{summary:a,boxed:!0,onToggle:l=>r(l),children:[n.jsx(ne,{message:i.error}),i.data===void 0?n.jsx(oe,{children:"Loading…"}):n.jsx(q,{children:e.body.map((l,o)=>n.jsx($s,{component:l,data:i.data},o))})]})}function _6({component:e,data:t}){const s=yt(),r=To();return n.jsxs(n.Fragment,{children:[n.jsx(Q,{align:"end",children:n.jsx(Pa,{action:e.action,args:ki(e.action.args,{data:t,row:t,scope:s}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,a)=>void r.run(i,a)})}),n.jsx(Ya,{act:r})]})}function L6({component:e}){const t=yt();return n.jsx(Sx,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function F6({component:e,data:t}){const s=me(t,e.path);return typeof s!="string"||s===""?null:n.jsx(Bu,{id:s})}function U6({component:e,data:t}){const s=me(t,e.path);return typeof s!="string"||s===""?null:n.jsx(Q,{children:n.jsx("a",{href:Lr(s),children:e.label})})}function B6({component:e,data:t}){const s=pn(e.query,t),r=To();return s.error?n.jsx(ne,{message:s.error}):s.data===void 0?n.jsx(oe,{children:e.empty??"Loading…"}):n.jsxs(n.Fragment,{children:[n.jsx(Ya,{act:r}),n.jsx(z6,{component:e,data:t,loaded:s.data,act:r},JSON.stringify(s.data))]})}function z6({component:e,data:t,loaded:s,act:r}){const i=yt(),[a,l]=h.useState(()=>zu(e.fields,s)),o={...a,version:me(s,e.version)},c=Px(e.fields,a,s),u=e.readOnlyWhen!==void 0&&us(s,e.readOnlyWhen),f=(e.actions??[]).filter(p=>p.placement==="leading"),d=(e.actions??[]).filter(p=>p.placement!=="leading"),m=(p,v)=>n.jsx(Pa,{action:p,args:ki(p.args,{data:t,fields:o,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===p.tool,onRun:(w,k)=>void r.run(w,k)},`${p.tool}-${v}`);return n.jsx(Bn,{title:e.title,note:e.note,children:n.jsxs(q,{children:[n.jsx(Mx,{fields:e.fields,values:a,data:s,disabled:u,onChange:(p,v)=>l(w=>({...w,[p]:v}))}),u?null:n.jsxs(Q,{align:"end",children:[f.map(m),f.length>0?n.jsx(sn,{}):null,m(e.save,-1),d.map(m)]}),e.footnote?n.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function V1({page:e,item:t,navigate:s,timezone:r,embedded:i,siblings:a}){const[l,o]=h.useState({}),[c,u]=h.useState(0),f={plugin:e.plugin,page:e.id,pages:a??[e],item:t??null,params:{...l,...t?{item:t}:{},...H6(e,t)},setParams:v=>o(w=>{const k={...w};for(const[g,x]of Object.entries(v))x===null?delete k[g]:k[g]=x;return k}),navigate:s,timezone:r,version:c,refresh:()=>u(v=>v+1),sensitive:new Set(e.sensitive??[])},d=e.body[0],m=!i&&(d==null?void 0:d.kind)==="notice"&&typeof d.text=="string"&&d.when===void 0&&d.title===void 0&&(d.tone===void 0||d.tone==="neutral")?d.text:void 0,p=m===void 0?e:{...e,body:e.body.slice(1)};return n.jsx(Tx.Provider,{value:f,children:n.jsx(mn,{embedded:i,title:e.title,lede:m,children:n.jsx(W6,{page:p,boxed:i===!0})})})}function W6({page:e,boxed:t}){const s=yt();return e.data&&s.sensitive.has(e.data.query)?n.jsx(_1,{children:n.jsx(hw,{page:e,boxed:t})}):n.jsx(hw,{page:e,boxed:t})}function hw({page:e,boxed:t}){const s=pn(e.data,null);return n.jsxs(q,{gap:"lg",divided:!t,children:[n.jsx(ne,{message:s.error}),n.jsx(ho.Provider,{value:t,children:e.body.map((r,i)=>n.jsx($s,{component:r,data:s.data??null},i))})]})}function H6(e,t){if(!t)return{};const s=[],r=i=>{for(const a of i)a.kind==="list-detail"?(s.push(a.param),r(a.detail)):(a.kind==="section"||a.kind==="detail"||a.kind==="expand")&&r(a.body)};return r(e.body),Object.fromEntries(s.map(i=>[i,t]))}function V6(e){return n.jsx(V1,{...e,embedded:!0})}function qa({text:e}){const t=e.search(/[.!?]\s/),s=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return n.jsx(Ut,{title:s,children:r||null})}const fw=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],K6=["","image","pdf","table","text","code","audio","video","archive","file"];function G6({hash:e,timezone:t,navigate:s,agents:r}){var M;const i=lD(e),a=(i==null?void 0:i.artifactId)??null,l=(i==null?void 0:i.filters.origin)??"",o=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,f]=h.useState(c);h.useEffect(()=>{f(c)},[c]);const d=(T,$=!1)=>s(hc(a,{q:c,origin:l,family:o,...T}),$);h.useEffect(()=>{if(u===c)return;const T=window.setTimeout(()=>d({q:u},!0),250);return()=>window.clearTimeout(T)},[u]);const[m,p]=h.useState(null),[v,w]=h.useState(null),[k,g]=h.useState(null),[x,y]=h.useState(!1),[j,N]=h.useState(!1),b=T=>{var $;return T?(($=r.find(_=>_.id===T))==null?void 0:$.name)??T:""},S=h.useRef(0);h.useEffect(()=>{const T=++S.current;p(null),w(null),y(!1),g(null),A.library({...c?{q:c}:{},...l?{origin:l}:{},...o?{family:o}:{}}).then($=>{S.current===T&&(p($.entries),w($.next))}).catch($=>{S.current===T&&g($ instanceof he?$.message:String($))})},[c,l,o]);const C=()=>{if(!v||x)return;y(!0);const T=S.current;A.library({...c?{q:c}:{},...l?{origin:l}:{},...o?{family:o}:{},cursor:v}).then($=>{S.current===T&&(p(_=>{const K=new Set((_??[]).map(D=>D.id));return[..._??[],...$.entries.filter(D=>!K.has(D.id))]}),w($.next))}).catch($=>{S.current===T&&g($ instanceof he?$.message:String($))}).finally(()=>{S.current===T&&y(!1)})},R=(l?1:0)+(o?1:0),E=((M=fw.find(T=>T.id===l))==null?void 0:M.label)??l,P=n.jsxs(n.Fragment,{children:[m===null?n.jsx(oe,{children:"Loading…"}):m.length===0?n.jsx(oe,{children:"No file matches that."}):n.jsx(Ct,{children:m.map(T=>n.jsx(FN,{href:hc(T.id,{q:c,origin:l,family:o}),current:T.id===a,onClick:()=>s(hc(T.id,{q:c,origin:l,family:o})),lead:n.jsx("span",{className:"files-row-visual","data-family":T.family,children:T.family==="image"&&!T.deleted?n.jsx("img",{src:rr(T.id),alt:"",loading:"lazy"}):n.jsx(gx,{family:T.family})}),title:T.filename??"Untitled file",meta:n.jsx("span",{title:Ve(T.createdAt,t),children:Oe(T.createdAt)}),sub:`${mi[T.family]} · ${Cn(T.sizeBytes)} · ${K1(T,b)}${Y6(T,b)}`},T.id))}),v?n.jsx("div",{className:"files-more",children:n.jsx(I,{size:"sm",onClick:C,disabled:x,children:x?"Loading…":"Show more"})}):null]}),F=m!==null&&m.length===0&&!c&&!l&&!o&&!u;return n.jsxs("div",{className:"ui-page files","data-selected":a?"true":void 0,children:[n.jsxs("header",{className:"ui-page-head",children:[n.jsx("h2",{className:"ui-page-title",children:"Files"}),n.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),F?n.jsx(Ut,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):n.jsxs(n.Fragment,{children:[n.jsx(WN,{label:"Files",onSubmit:()=>d({q:u},!0),main:n.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:T=>f(T.target.value)}),filters:n.jsxs(sr,{dense:!0,children:[n.jsx(te,{label:"Origin",children:n.jsx("select",{value:l,"aria-label":"Origin",onChange:T=>d({origin:T.target.value}),children:fw.map(T=>n.jsx("option",{value:T.id,children:T.label},T.id))})}),n.jsx(te,{label:"Kind",children:n.jsx("select",{value:o,"aria-label":"Kind",onChange:T=>d({family:T.target.value}),children:K6.map(T=>n.jsx("option",{value:T,children:T===""?"Any kind":mi[T]},T))})})]}),filtersOpen:j,onToggleFilters:()=>N(T=>!T),active:R,chips:R>0?n.jsxs(n.Fragment,{children:[l?n.jsx(Pu,{label:"Origin",onRemove:()=>d({origin:""}),children:E}):null,o?n.jsx(Pu,{label:"Kind",onRemove:()=>d({family:""}),children:mi[o]}):null]}):void 0}),n.jsx(ne,{message:k}),n.jsx(UN,{className:"files-split",label:"Files",list:P,detail:a?n.jsx(q6,{id:a,timezone:t,agents:r,navigate:s,onBack:()=>s(hc(null,{q:c,origin:l,family:o}))},a):void 0,empty:"Choose a file to see it here."})]})]})}function Y6(e,t){var i,a;const s=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(a=e.context)!=null&&a.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[s,r].filter(Boolean).map(l=>` · ${l}`).join("")}function K1(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 q6({id:e,timezone:t,agents:s,navigate:r,onBack:i}){const[a,l]=h.useState(null),[o,c]=h.useState(!1),[u,f]=h.useState(null);h.useEffect(()=>{let x=!1;return l(null),f(null),A.libraryEntry(e).then(y=>{x||l(y)}).catch(y=>{x||f(y instanceof he&&y.status===404?"This file is no longer in the library.":y instanceof he?y.message:String(y))}),()=>{x=!0}},[e]);const d=x=>{var y;return x?((y=s.find(j=>j.id===x))==null?void 0:y.name)??x:""};if(u)return n.jsxs("div",{className:"files-detail-body",children:[n.jsx(I,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),n.jsx(H,{tone:"critical",children:u})]});if(!a)return n.jsx("div",{className:"files-detail-body",children:n.jsx(oe,{children:"Loading…"})});const{entry:m,contexts:p,contextsTotal:v,available:w}=a,k=m.filename??"Untitled file",g=()=>{c(!0),A.libraryEntry(e,p.length).then(x=>l(y=>y&&{...y,contexts:[...y.contexts,...x.contexts],contextsTotal:x.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return n.jsxs("div",{className:"files-detail-body",children:[n.jsx(I,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),n.jsxs("header",{className:"files-detail-head",children:[n.jsx("span",{className:"files-detail-mark","data-family":m.family,"aria-hidden":"true",children:n.jsx(gx,{family:m.family})}),n.jsxs("div",{className:"files-detail-text",children:[n.jsx("h3",{className:"files-detail-name",children:k}),n.jsxs("p",{className:"files-detail-meta",children:[mi[m.family]," · ",Cn(m.sizeBytes)," · ",Ve(m.createdAt,t)]})]}),w?n.jsx("a",{className:"ui-btn","data-variant":"accent",href:Lr(m.id),download:k,children:"Download"}):null]}),w?null:n.jsx(H,{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."}),n.jsx(c1,{artifactId:m.id,filename:m.filename,mime:m.mime,family:m.family,available:w}),n.jsx(Kt,{items:[{label:"Origin",value:K1(m,d)},...m.agentId&&m.origin==="produced"?[{label:"Made by",value:n.jsxs("span",{className:"files-agent",children:[n.jsx(vn,{agents:s,id:m.agentId,size:"sm"}),d(m.agentId)]})}]:[],{label:"Type",value:n.jsx("span",{className:"mono",children:m.mime})},{label:"Id",value:n.jsx("span",{className:"mono",children:m.id})}]}),n.jsxs("section",{className:"files-conversations",children:[n.jsx("h4",{className:"ui-section-title",children:"Conversations"}),p.length===0?n.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):n.jsx("ul",{className:"files-ctx",role:"list",children:p.map(x=>{const y=x.groupId?Tl(x.groupId,x.conversationId):Ke(x.conversationAgentId,x.conversationId),j=x.groupId?x.groupName??"a group":d(x.conversationAgentId);return n.jsxs("li",{className:"files-ctx-row",children:[n.jsxs("span",{className:"files-ctx-text",children:[n.jsx("span",{children:x.groupId?`Group: ${j}`:j}),n.jsxs("span",{className:"muted",children:[" · ",x.kind==="produced"?`made by ${d(x.agentId)||"an agent"}`:x.kind==="reused"?"sent again":"sent by you"," · ",Oe(x.at)]})]}),n.jsx("a",{className:"ui-btn","data-size":"sm",href:y,onClick:N=>{N.preventDefault(),r(y)},children:"Open conversation"})]},`${x.conversationId}:${x.kind}`)})}),p.length<v?n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",onClick:g,disabled:o,children:o?"Loading…":`Show ${v-p.length} more`})}):null]})]})}const Q6={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe",sun:"sun",cloud:"cloud"};function G1(e){return e&&Q6[e]||"plug"}const Y1="a connection needs you";function J6({attention:e,place:t,onNavigate:s,theme:r,onTheme:i,plugins:a=[],updateAvailable:l=!1,settingsDot:o,version:c,stale:u=!1,reload:f,timezone:d}){return n.jsxs("nav",{className:"rail","aria-label":"Places",children:[n.jsx("a",{className:"rail-mark",href:Vt,onClick:m=>{m.preventDefault(),s(Vt)},"aria-label":"buddi home",children:n.jsx(HN,{})}),gD.filter(m=>m.route!==tn).map(m=>n.jsx(Xh,{label:m.label,href:m.route,active:t===m.route,badge:m.route===Vt?e:0,onClick:()=>s(m.route),children:mw[m.route]},m.route)),a.map(m=>{const p=_r(m.plugin,m.id);return n.jsx(Xh,{label:m.title,href:p,active:t===p,badge:0,onClick:()=>s(p),children:n.jsx(Se,{name:G1(m.icon)})},p)}),n.jsx("div",{className:"rail-spacer"}),n.jsx(Xh,{label:"Settings",href:tn,active:t===tn,badge:0,dot:l?"a newer buddi is ready":o,onClick:()=>s(tn),children:mw[tn]}),n.jsx(Z6,{theme:r,onTheme:i,onNavigate:s,version:c,stale:u,reload:f,timezone:d})]})}const X6=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function Z6({theme:e,onTheme:t,onNavigate:s,version:r,stale:i,reload:a=()=>window.location.reload(),timezone:l}){var x,y,j;const o=ie(()=>A.owner(),[]),c=ie(()=>A.focus(),[],6e4),u=((x=c.data)==null?void 0:x.focus)??null,f=(N,b)=>{A.setFocus(N,b).finally(()=>c.reload())},d=((j=(y=o.data)==null?void 0:y.preferredName)==null?void 0:j.trim())||null,m=(d??"You").slice(0,1).toUpperCase(),[p]=h.useState(PD),[v]=h.useState(nU),w=d?`You: ${d}`:"You",k=u?`${jl[u.mode]} ${q1(u,l)}`:null,g=[w,k,i?"reload to update":null].filter(Boolean).join(", ");return n.jsx("div",{className:"rail-owner",children:n.jsxs(Sd,{modal:!1,children:[n.jsx(Nd,{asChild:!0,children:n.jsxs("button",{type:"button",className:"rail-owner-btn","aria-label":g,children:[n.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:m}),i?n.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"owner-dot","aria-hidden":"true"}):null,u?n.jsx("span",{className:"rail-focus","data-testid":"owner-focus","aria-hidden":"true",children:n.jsx(Se,{name:"moon",size:10})}):null]})}),n.jsx(So,{children:n.jsxs(Cd,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[n.jsxs("div",{className:"rail-owner-head",children:[n.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:m}),n.jsxs("span",{className:"rail-owner-who",children:[n.jsx("span",{className:"rail-owner-name",children:d??"You"}),n.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),n.jsx(xr,{className:"ui-menu-sep"}),n.jsx(tU,{focus:u,timezone:l,onSwitch:f}),n.jsx(xr,{className:"ui-menu-sep"}),n.jsx(Ed,{className:"ui-menu-label",children:"Theme"}),n.jsx("div",{className:"rail-owner-theme",children:n.jsx(Ys,{label:"Theme",options:X6,value:e,onChange:t})}),n.jsx(xr,{className:"ui-menu-sep"}),n.jsx(hi,{className:"ui-menu-item",onSelect:()=>s(tt("appearance")),children:"Change appearance"}),p||i?n.jsxs(hi,{className:"ui-menu-item rail-owner-reload","data-update":i?"true":void 0,onSelect:()=>a(),children:[n.jsx("span",{children:i?"Reload to update":"Reload"}),v?n.jsx("kbd",{className:"rail-owner-kbd",children:v}):null]}):null,r?n.jsxs(n.Fragment,{children:[n.jsx(xr,{className:"ui-menu-sep"}),n.jsxs(hi,{className:"ui-menu-item rail-owner-version","data-update":r.updateAvailable?"true":void 0,onSelect:()=>s(tt("system")),children:[n.jsxs("span",{className:"mono",children:["buddi ",r.current]}),r.updateAvailable&&r.latest?n.jsxs("span",{className:"rail-owner-update",children:["A newer buddi is ready: ",r.latest]}):null]})]}):null]})})]})})}const jl={normal:"Off","urgent-only":"Urgent only","do-not-disturb":"Do not disturb"},eU=[{value:"1h",label:"For 1 hour"},{value:"3h",label:"For 3 hours"},{value:"tomorrow",label:"Until tomorrow morning"},{value:"indefinite",label:"Until I turn it off"}];function q1(e,t,s=new Date){if(!e.until)return"until you turn it off";const r=new Date(e.until),i=t?{timeZone:t}:{},a=c=>new Intl.DateTimeFormat("en-CA",{...i,dateStyle:"short"}).format(c),l=new Intl.DateTimeFormat("en-GB",{...i,hour:"2-digit",minute:"2-digit"}).format(r);return a(r)===a(s)?`until ${l}`:`until ${new Intl.DateTimeFormat("en-GB",{...i,weekday:"short"}).format(r)} ${l}`}function tU({focus:e,timezone:t,onSwitch:s}){return n.jsxs(I$,{children:[n.jsxs(P$,{className:"ui-menu-item rail-owner-focus",children:[n.jsx("span",{children:"Focus"}),n.jsx("span",{className:"rail-owner-kbd",children:e?jl[e.mode]:"Off"})]}),n.jsx(So,{children:n.jsxs(M$,{className:"ui-menu rail-owner-menu",sideOffset:6,children:[n.jsx("p",{className:"ui-menu-empty",role:"status",children:e?`${jl[e.mode]} ${q1(e,t)}${e.by==="schedule"?", from a schedule":""}.`:"No focus is on."}),["do-not-disturb","urgent-only"].map(r=>n.jsxs(lN,{children:[n.jsx(xr,{className:"ui-menu-sep"}),n.jsx(Ed,{className:"ui-menu-label",children:jl[r]}),eU.map(i=>n.jsx(hi,{className:"ui-menu-item","aria-label":`${jl[r]} ${i.label.toLowerCase()}`,onSelect:()=>s(r,i.value),children:i.label},i.value))]},r)),e?n.jsxs(n.Fragment,{children:[n.jsx(xr,{className:"ui-menu-sep"}),n.jsx(hi,{className:"ui-menu-item",onSelect:()=>s("normal"),children:"Turn off"})]}):null]})})]})}function nU(){const e=window.navigator.userAgent;return/iPhone|iPad|Android|Mobile/.test(e)?null:/Mac/.test(e)?"⌘R":"Ctrl+R"}function Xh({label:e,href:t,active:s,badge:r,dot:i,onClick:a,children:l}){return n.jsxs("a",{className:"rail-link",href:t,"data-active":s?"true":void 0,"aria-current":s?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:i?`${e}, ${i}`:e,onClick:o=>{o.preventDefault(),a()},children:[n.jsxs("span",{className:"rail-icon",children:[l,r>0?n.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null,r===0&&i?n.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"rail-dot","aria-hidden":"true"}):null]}),n.jsx("span",{className:"rail-label",children:e})]})}const mw={[bi]:n.jsx(Se,{name:"files"}),[Vt]:n.jsx(Se,{name:"home"}),[Ar]:n.jsx(Se,{name:"chat"}),[ut]:n.jsx(Se,{name:"agents"}),[jt]:n.jsx(Se,{name:"activity"}),[tn]:n.jsx(Se,{name:"settings"})},fo=e=>`${e.plugin}:${e.id}`,sU=new Set;let $x=sU,pw=!1;const ap=new Set;function lp(e){$x=e;for(const t of ap)t()}function rU(e){return ap.add(e),()=>ap.delete(e)}const gw=()=>$x;function iU(){pw||(pw=!0,Promise.resolve().then(()=>A.rail()).then(e=>lp(new Set(Array.isArray(e==null?void 0:e.hidden)?e.hidden.filter(t=>typeof t=="string"):[]))).catch(()=>{}))}async function aU(e,t){const s=$x,r=new Set(s);t?r.add(fo(e)):r.delete(fo(e)),lp(r);try{await A.setRailHidden(e.plugin,e.id,t)}catch(i){throw lp(s),i}}function Q1(){return h.useEffect(iU,[]),h.useSyncExternalStore(rU,gw,gw)}function lU(e,t){return e.filter(s=>!t.has(fo(s)))}function oU(e){return e instanceof HTMLElement?e.isContentEditable?!0:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function cU(e,t=!0,s){h.useEffect(()=>{if(!t)return;const r=i=>{if(i.key!=="/"||i.defaultPrevented||i.ctrlKey||i.metaKey||i.altKey||oU(i.target))return;i.preventDefault();const a=document.getElementById(Xm);if(a instanceof HTMLTextAreaElement){!a.disabled&&!a.hidden&&a.focus();return}s?s():e(Vt)};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t,s])}const J1="buddi.theme";function uU(e=X1()){try{const t=e==null?void 0:e.getItem(J1);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function dU(e,t=X1()){try{t==null||t.setItem(J1,e)}catch{}}function hU(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function X1(){try{return window.localStorage}catch{return}}const Z1="buddi.ground",eC="buddi.pageWidth";function fU(e=sC()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},s=t(Z1),r=t(eC);return{theme:uU(e),ground:s==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function tC(e,t=document.documentElement){t&&(hU(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 mU(e,t=sC()){dU(e.theme,t);try{t==null||t.setItem(Z1,e.ground),t==null||t.setItem(eC,e.width)}catch{}}let va=null;const op=new Set;function cp(){return va||(va=fU()),va}function pU(e){return op.add(e),()=>op.delete(e)}function gU(e){va={...cp(),...e},tC(va),mU(va);for(const t of op)t()}function nC(){return[h.useSyncExternalStore(pU,cp,cp),gU]}function sC(){try{return window.localStorage}catch{return}}function xU({timezone:e,embedded:t}){var m,p;const{data:s,error:r,reload:i}=ie(()=>A.sentinels(),[],3e4),a=ie(()=>A.missions(),[]),[l,o]=h.useState(null),c=((p=(m=a.data)==null?void 0:m.missions.find(v=>v.id==="sentinel-wake"))==null?void 0:p.agentId)??null,u=async(v,w)=>{o(null);try{await A.snoozeAlert(v,w),i()}catch(k){o(k instanceof Error?k.message:String(k))}},f=((s==null?void 0:s.open)??[]).filter(v=>!v.snoozedAt),d=((s==null?void 0:s.open)??[]).filter(v=>v.snoozedAt);return n.jsxs(mn,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[n.jsx(ne,{message:r??l}),n.jsx(H,{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."}),n.jsx(Zh,{title:"Open",findings:f,timezone:e,askAgentId:c,onSnooze:v=>u(v,!0),empty:"Nothing open. Your watchers are quiet."}),d.length>0?n.jsx(Zh,{title:"Snoozed",findings:d,timezone:e,askAgentId:c,onSnooze:v=>u(v,!1),empty:""}):null,n.jsx(Zh,{title:"Resolved",findings:(s==null?void 0:s.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),n.jsx(Ze,{title:"Waiting for the weekly recap",flush:!0,children:!s||s.digest.length===0?n.jsx(Ut,{icon:"bell",title:"Nothing waiting for the recap"}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Title"}),n.jsx("th",{children:"Severity"}),n.jsx("th",{children:"Noted"})]})}),n.jsx("tbody",{children:s.digest.map(v=>n.jsxs("tr",{children:[n.jsxs("td",{children:[Aa(v.title),n.jsx(iC,{text:Aa(v.detail)})]}),n.jsx("td",{children:n.jsx(rC,{severity:v.severity})}),n.jsx("td",{className:"nowrap",children:Ve(v.createdAt,e)})]},v.id))})]})})]})}function rC({severity:e}){return n.jsx(xe,{tone:e==="urgent"?"critical":void 0,children:e})}function iC({text:e}){const[t,s]=h.useState(!1),r=e.length>240||e.split(`
107
- `).length>3;return n.jsxs("div",{className:"sub alert-detail","data-clamp":r&&!t?"true":void 0,children:[e,r?n.jsx("button",{type:"button",className:"wb-link alert-more",onClick:()=>s(i=>!i),children:t?"Less":"More"}):null]})}function vU(e){return`About this alert: "${Aa(e.title)}". ${Aa(e.detail)}
108
-
109
- What should I do about it, and what do you need from me to clear it?`}function Zh({title:e,findings:t,timezone:s,askAgentId:r,onSnooze:i,empty:a}){const l=e==="Snoozed";return n.jsx(Ze,{title:e,flush:!0,children:t.length===0?n.jsx(oe,{children:a}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Finding"}),n.jsx("th",{children:"Severity"}),n.jsx("th",{children:"Since"}),i?n.jsx("th",{}):null]})}),n.jsx("tbody",{children:t.map(o=>n.jsxs("tr",{children:[n.jsxs("td",{children:[n.jsx("strong",{children:Aa(o.title)}),n.jsx(iC,{text:Aa(o.detail)}),o.data?n.jsx(Tt,{summary:"evidence",children:n.jsx(Nt,{children:Sn(o.data)})}):null]}),n.jsx("td",{children:n.jsx(rC,{severity:o.severity})}),n.jsxs("td",{className:"nowrap",children:[Ve(o.firstSeenAt,s),n.jsxs("div",{className:"sub",title:Ve(o.lastSeenAt,s),children:["last seen ",Oe(o.lastSeenAt)]})]}),i?n.jsx("td",{children:n.jsxs(Q,{align:"end",children:[r?n.jsx(Yt,{size:"sm",href:Ke(r,"new"),onClick:()=>u3(r,vU(o)),children:"Ask about it"}):null,n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>i(o.key),children:l?"Wake":"Snooze"})]})}):null]},o.key))})]})})}const xw=5e3,vw=50;function jU({timezone:e,embedded:t}){var g;const[s,r]=h.useState(""),[i,a]=h.useState(""),[l,o]=h.useState(null),c=ie(()=>A.eventKinds(),[]),{data:u,error:f}=ie(()=>A.events({kind:s||void 0,q:i||void 0,limit:vw}),[s,i],xw),[d,m]=h.useState({events:[],cursor:null,busy:!1,error:null});h.useEffect(()=>{m({events:[],cursor:null,busy:!1,error:null})},[s,i]);const p=d.events.length>0?d.cursor:(u==null?void 0:u.nextCursor)??null,v=async()=>{if(p){m(x=>({...x,busy:!0,error:null}));try{const x=await A.events({kind:s||void 0,q:i||void 0,before:p,limit:vw});m(y=>({events:[...y.events,...x.events],cursor:x.nextCursor,busy:!1,error:null}))}catch(x){m(y=>({...y,busy:!1,error:x instanceof Error?x.message:String(x)}))}}},w=new Set(((u==null?void 0:u.events)??[]).map(x=>x.id)),k=[...(u==null?void 0:u.events)??[],...d.events.filter(x=>!w.has(x.id))];return n.jsxs(mn,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[n.jsxs(Q,{children:[n.jsxs("select",{"aria-label":"Event kind",value:s,onChange:x=>r(x.target.value),children:[n.jsx("option",{value:"",children:"every kind"}),(((g=c.data)==null?void 0:g.kinds)??[]).map(x=>n.jsxs("option",{value:x.kind,children:[x.kind," (",x.count,")"]},x.kind))]}),n.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:x=>a(x.target.value),size:28}),s||i?n.jsx(I,{onClick:()=>{r(""),a("")},children:"Clear"}):null,n.jsxs("span",{className:"muted",children:["refreshes every ",xw/1e3,"s"]})]}),n.jsx(ne,{message:f}),n.jsx(Ze,{flush:!0,children:!u||k.length===0?n.jsx(oe,{children:"No events match."}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"#"}),n.jsx("th",{children:"When"}),n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"Payload"})]})}),n.jsx("tbody",{children:k.map(x=>n.jsxs("tr",{"data-clickable":"true",onClick:()=>o(x),children:[n.jsx("td",{className:"mono muted",children:x.id}),n.jsxs("td",{className:"nowrap",children:[Ve(x.createdAt,e),n.jsx("div",{className:"sub",children:Oe(x.createdAt)})]}),n.jsx("td",{className:"mono nowrap",children:x.kind}),n.jsx("td",{className:"mono muted",children:Ms(Sn(x.payload).replace(/\s+/g," "),120)})]},x.id))})]})}),p||d.error?n.jsxs(Q,{children:[n.jsxs("span",{className:"muted",children:[k.length," shown",p?", older ones are kept":"","."]}),n.jsx("span",{className:"ui-toolbar-spacer"}),d.error?n.jsx("span",{className:"critical",children:d.error}):null,p?n.jsx(I,{disabled:d.busy,onClick:()=>void v(),children:d.busy?"Loading…":"Load older"}):null]}):null,l?n.jsxs(Dt,{title:l.kind,onClose:()=>o(null),children:[n.jsxs("p",{className:"muted",children:["Event ",l.id," · ",Ve(l.createdAt,e),l.conversationId?n.jsxs(n.Fragment,{children:[" · ",n.jsx("a",{href:`#/conversations/${l.conversationId}`,children:"conversation"})]}):null]}),n.jsx(Nt,{children:Sn(l.payload)})]}):null]})}const yU=["pending","leased","suspended","failed","succeeded","cancelled"],fl=50;function wU({timezone:e,embedded:t,initialState:s}){const[r,i]=h.useState(s??""),[a,l]=h.useState(null),[o,c]=h.useState(null),{data:u,error:f,reload:d}=ie(()=>A.jobs({...r?{state:r}:{},limit:String(fl)}),[r],1e4),[m,p]=h.useState({jobs:[],done:!1,busy:!1});h.useEffect(()=>{p({jobs:[],done:!1,busy:!1})},[r]);const v=async()=>{p(S=>({...S,busy:!0}));try{const S=await A.jobs({...r?{state:r}:{},limit:String(fl),offset:String(fl+m.jobs.length)});p(C=>({jobs:[...C.jobs,...S.jobs],done:S.jobs.length<fl,busy:!1}))}catch(S){c(S instanceof Error?S.message:String(S)),p(C=>({...C,busy:!1}))}},w=new Set(((u==null?void 0:u.jobs)??[]).map(S=>S.id)),k=[...(u==null?void 0:u.jobs)??[],...m.jobs.filter(S=>!w.has(S.id))],g=r?(u==null?void 0:u.counts[r])??0:Object.values((u==null?void 0:u.counts)??{}).reduce((S,C)=>S+C,0),x=!m.done&&k.length<g&&((u==null?void 0:u.jobs.length)??0)>=fl,[y,j]=h.useState(null),N=async S=>{c(null),j(S);try{const C=(await A.jobs({state:"failed",limit:"500"})).jobs;for(const R of C)await(S==="retry"?A.retryJob(R.id):A.cancelJob(R.id));d()}catch(C){c(C instanceof Error?C.message:String(C))}finally{j(null)}},b=async S=>{c(null);try{await S,l(null),d()}catch(C){c(C instanceof Error?C.message:String(C))}};return n.jsxs(mn,{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:n.jsx(I,{size:"sm",variant:u!=null&&u.paused?"accent":void 0,onClick:()=>b(A.setPaused(!((u==null?void 0:u.paused)??!1))),children:u!=null&&u.paused?"Resume the queue":"Pause the queue"}),children:[n.jsxs(Q,{children:[n.jsxs("select",{"aria-label":"Job state",value:r,onChange:S=>i(S.target.value),children:[n.jsx("option",{value:"",children:"every state"}),yU.map(S=>n.jsxs("option",{value:S,children:[S," (",(u==null?void 0:u.counts[S])??0,")"]},S))]}),((u==null?void 0:u.counts.failed)??0)>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsxs("span",{className:"muted",children:[u.counts.failed," failed."]}),n.jsx(I,{size:"sm",disabled:y!==null,onClick:()=>void N("retry"),children:y==="retry"?"Retrying…":"Retry all failed"}),n.jsx(I,{size:"sm",variant:"danger",disabled:y!==null,onClick:()=>void N("cancel"),children:y==="cancel"?"Cancelling…":"Cancel all failed"})]}):null]}),n.jsx(ne,{message:f??o}),n.jsx(Ze,{flush:!0,children:!u||k.length===0?n.jsx(oe,{children:"No jobs match."}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"State"}),n.jsx("th",{className:"num",children:"Attempts"}),n.jsx("th",{children:"Last error"}),n.jsx("th",{children:"Updated"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:k.map(S=>n.jsxs("tr",{children:[n.jsxs("td",{className:"clickable",onClick:()=>l(S),children:[S.kind,n.jsx("div",{className:"sub mono",children:ao(S.id)})]}),n.jsxs("td",{children:[n.jsx(Pd,{state:S.state}),S.suspendedReason?n.jsx("div",{className:"sub",children:Ms(S.suspendedReason,40)}):null]}),n.jsxs("td",{className:"num",children:[S.attempts,"/",S.maxAttempts]}),n.jsx("td",{className:S.lastError?"critical":"muted",children:S.lastError?Ms(S.lastError,80):"—"}),n.jsxs("td",{className:"nowrap",children:[Ve(S.updatedAt,e),n.jsx("div",{className:"sub",children:Oe(S.updatedAt)})]}),n.jsx("td",{children:n.jsxs(Q,{align:"end",children:[["failed","cancelled","suspended"].includes(S.state)?n.jsx(I,{size:"sm",onClick:()=>b(A.retryJob(S.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(S.state)?n.jsx(I,{size:"sm",variant:"danger",onClick:()=>b(A.cancelJob(S.id)),children:"Cancel"}):null]})})]},S.id))})]})}),x?n.jsxs(Q,{children:[n.jsxs("span",{className:"muted",children:[k.length," of ",g," shown."]}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{disabled:m.busy,onClick:()=>void v(),children:m.busy?"Loading…":"Load older"})]}):null,a?n.jsxs(Dt,{title:a.kind,onClose:()=>l(null),children:[n.jsx("p",{className:"muted mono",children:a.id}),n.jsx(J,{title:"Payload",children:n.jsx(Nt,{children:Sn(a.payload)})}),n.jsx(J,{title:"Result",children:n.jsx(Nt,{children:Sn(a.result)})}),a.conversationId?n.jsx("p",{children:n.jsx("a",{href:`#/conversations/${a.conversationId}`,children:"open the transcript"})}):null]}):null]})}const bU=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function kU({hash:e,timezone:t,navigate:s,agents:r}){var u,f;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),a=d=>{var m;return((m=r.find(p=>p.id===d))==null?void 0:m.name)??d};if(i){let d=i[1];try{d=decodeURIComponent(d)}catch{}return n.jsx(CU,{id:d,timezone:t,navigate:s,nameOf:a})}const l=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",o=(f=/[?&]state=([a-z]+)/.exec(e))==null?void 0:f[1],c=d=>m=>{m.preventDefault(),s(d)};return n.jsxs("div",{className:"ui-page",children:[n.jsx(Md,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:n.jsx(TU,{})}),n.jsx(RU,{}),n.jsx(Ao,{children:bU.map(d=>{const m=d.id==="conversations"?jt:`${jt}/${d.id}`;return n.jsx(Ra,{href:m,active:l===d.id,onClick:c(m),children:d.label},d.id)})}),l==="conversations"?n.jsx(SU,{timezone:t,navigate:s,nameOf:a,agents:r}):null,l==="jobs"?n.jsx(wU,{timezone:t,embedded:!0,initialState:o},o??""):null,l==="approvals"?n.jsx(NU,{timezone:t,nameOf:a}):null,l==="alerts"?n.jsx(xU,{timezone:t,embedded:!0}):null,l==="events"?n.jsx(jU,{timezone:t,embedded:!0}):null]})}function SU({timezone:e,navigate:t,nameOf:s,agents:r}){const{data:i,error:a}=ie(()=>A.conversations(),[],3e4);return n.jsxs(n.Fragment,{children:[n.jsx(ne,{message:a}),n.jsx(Ze,{flush:!0,children:i?i.conversations.length===0?n.jsx(Ut,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):n.jsx(Ct,{children:i.conversations.map(l=>n.jsx(Et,{href:Ta(l.id),onClick:()=>t(Ta(l.id)),lead:n.jsx(vn,{agents:r,id:l.agentId,size:"sm"}),title:l.opening?Ms(l.opening,100):"Untitled conversation",sub:`${s(l.agentId)}, ${l.messageCount} message${l.messageCount===1?"":"s"}, ${l.runs} run${l.runs===1?"":"s"}, ${Q$(l.usage)}`,side:n.jsx("span",{title:Ve(l.lastMessageAt??l.createdAt,e),children:Oe(l.lastMessageAt??l.createdAt)})},l.id))}):n.jsx(oe,{children:"Loading…"})})]})}function NU({timezone:e,nameOf:t}){const{data:s,error:r}=ie(()=>A.approvals(),[],1e4),i=[...(s==null?void 0:s.pending)??[],...(s==null?void 0:s.recent)??[]];return n.jsxs(n.Fragment,{children:[n.jsx(ne,{message:r}),n.jsx(Ze,{flush:!0,children:s?i.length===0?n.jsx(Ut,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Tool"}),n.jsx("th",{children:"State"}),n.jsx("th",{children:"Asked by"}),n.jsx("th",{children:"Decided"}),n.jsx("th",{children:"Created"})]})}),n.jsx("tbody",{children:i.map(a=>n.jsxs("tr",{children:[n.jsxs("td",{children:[a.tool,n.jsx("div",{className:"sub mono",children:ao(a.id)})]}),n.jsx("td",{children:n.jsx(Pd,{state:a.state})}),n.jsx("td",{children:t(a.agentId)}),n.jsx("td",{className:"nowrap",children:a.decidedAt?n.jsxs(n.Fragment,{children:[Ve(a.decidedAt,e),n.jsxs("div",{className:"sub",children:["via ",a.decidedVia??"—"]})]}):n.jsx("span",{className:"muted",children:"—"})}),n.jsxs("td",{className:"nowrap",children:[Ve(a.createdAt,e),n.jsx("div",{className:"sub",children:Oe(a.createdAt)})]})]},a.id))})]}):n.jsx(oe,{children:"Loading…"})})]})}function CU({id:e,timezone:t,navigate:s,nameOf:r}){const[i,a]=h.useState(null),[l,o]=h.useState(null);h.useEffect(()=>{let u=!1;return A.conversation(e).then(f=>{u||a(f)}).catch(f=>{u||o(f instanceof Error?f.message:String(f))}),()=>{u=!0}},[e]);const c=u=>f=>{f.preventDefault(),s(u)};return n.jsxs("div",{className:"ui-page",children:[n.jsx("p",{className:"page-crumbs",children:n.jsx("a",{href:jt,onClick:c(jt),children:"Activity"})}),n.jsxs("header",{className:"ui-page-head",children:[n.jsxs("div",{className:"ui-page-head-row",children:[n.jsxs("h2",{className:"ui-page-title",children:[n.jsx(I,{size:"sm",onClick:()=>s(jt),children:"← Back"}),n.jsx("span",{children:"Transcript"})]}),i?n.jsx("div",{className:"ui-page-actions",children:n.jsx(Yt,{size:"sm",href:Ke(i.agentId,e),onClick:c(Ke(i.agentId,e)),children:"Open in chat"})}):null]}),n.jsx("p",{className:"ui-page-lede mono",children:e})]}),n.jsx(ne,{message:l}),i?n.jsxs(n.Fragment,{children:[n.jsxs($d,{children:[n.jsx(Es,{label:"Agent",value:r(i.agentId),size:"sm"}),n.jsx(Es,{label:"Runs",value:i.runs.length}),n.jsx(Es,{label:"Tokens",value:`${Pt(i.usage.input)} / ${Pt(i.usage.output)}`,note:Em(i.usage)?`input / output, ${Em(i.usage)}`:"input / output"}),n.jsx(Es,{label:"Started",value:Ve(i.createdAt,t),size:"sm"})]}),i.runs.length>0?n.jsx(Ze,{title:"Runs",flush:!0,children:n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Started"}),n.jsx("th",{children:"Finished"}),n.jsx("th",{className:"num",children:"Turns"}),n.jsx("th",{children:"Stopped"}),n.jsx("th",{className:"num",children:"Tokens"}),n.jsx("th",{className:"num",children:"Cached"})]})}),n.jsx("tbody",{children:i.runs.map((u,f)=>n.jsxs("tr",{children:[n.jsxs("td",{className:"nowrap",children:[Ve(u.startedAt,t)," ",u.resumed?n.jsx(xe,{children:"resumed"}):null]}),n.jsx("td",{className:"nowrap",children:Ve(u.finishedAt,t)}),n.jsx("td",{className:"num",children:u.turns??"—"}),n.jsxs("td",{children:[u.stopped??"—",u.actionId?n.jsxs("div",{className:"sub mono",children:["action ",ao(u.actionId)]}):null]}),n.jsxs("td",{className:"num muted nowrap",children:[Pt(u.usage.input)," / ",Pt(u.usage.output)]}),n.jsx("td",{className:"num muted nowrap",children:u.usage.cacheRead||u.usage.cacheWrite?Pt((u.usage.cacheRead??0)+(u.usage.cacheWrite??0)):"—"})]},f))})]})}):null,n.jsx(J,{title:"Messages",children:n.jsx(q,{children:i.messages.map(u=>n.jsxs("article",{className:"transcript-msg",children:[n.jsxs("header",{className:"transcript-who",children:[u.speaker===jw?"approved action, result":u.role,", ",Ve(u.createdAt,t)]}),n.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?n.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===jw?u.blocks.map((f,d)=>n.jsx(EU,{block:f},d)):u.blocks.map((f,d)=>n.jsx(AU,{block:f},d))]})]},u.id))})})]}):n.jsx(oe,{children:"Loading…"})]})}const jw="approval:resume";function EU({block:e}){return n.jsxs("div",{className:"transcript-tool",children:[n.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),n.jsx(Nt,{children:e.type==="text"?e.text??"":Sn(e)})]})}function AU({block:e}){return e.type==="text"?n.jsx("div",{className:"transcript-text",children:n.jsx(nr,{text:e.text??""})}):e.type==="thinking"?n.jsxs("details",{className:"transcript-thinking",children:[n.jsx("summary",{children:"Thoughts"}),n.jsx("div",{className:"transcript-thinking-text",children:n.jsx(nr,{text:e.text??""})})]}):e.type==="tool_use"?n.jsxs("div",{className:"transcript-tool",children:[n.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),n.jsx(Nt,{children:Sn(e.input)})]}):e.type==="tool_result"?n.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[n.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),n.jsx(Nt,{children:e.content??""})]}):n.jsxs("div",{className:"transcript-tool",children:[n.jsx("div",{className:"transcript-tool-name mono",children:e.type}),n.jsx(Nt,{children:Sn(e.ref)})]})}function TU(){const{data:e,reload:t}=ie(()=>A.overview(),[],1e4),[s,r]=h.useState(!1);if(!e)return null;const i=()=>{r(!0),A.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return n.jsx(I,{size:"sm",variant:e.paused?"accent":void 0,disabled:s,onClick:i,children:e.paused?"Resume all":"Pause all"})}function RU(){const{data:e}=ie(()=>A.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,s=t("leased");return n.jsxs($d,{children:[n.jsx(Es,{label:"Jobs done",value:Pt(t("succeeded"))}),n.jsx(Es,{label:"Failed",value:Pt(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),n.jsx(Es,{label:"Queued",value:Pt(t("pending")),note:`${s} running`}),n.jsx(Es,{label:"Approvals",value:Pt(e.approvals.pending),note:"waiting for you"})]})}const IU=["replay-all","coalesce","latest-only","skip-after-deadline"];function aC({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=ie(()=>A.missions(),[],3e4),l=((r==null?void 0:r.missions)??[]).filter(f=>!s||f.agentId===s),[o,c]=h.useState(null),u=async f=>{c(null);try{await f,a()}catch(d){c(d instanceof Error?d.message:String(d))}};return n.jsxs(mn,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[n.jsx(ne,{message:i??o}),!r||l.length===0?n.jsxs(Ut,{icon:"calendar",title:"No missions yet",children:["Run ",n.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):n.jsx(q,{children:l.map(f=>n.jsx(PU,{mission:f,timezone:e,onRun:u},f.id))})]})}function PU({mission:e,timezone:t,onRun:s}){const[r,i]=h.useState(!1);return n.jsxs(On,{tone:e.enabled&&!e.pausedReason?"good":"muted",title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"mono muted",children:e.id})]}),meta:n.jsxs(n.Fragment,{children:[n.jsx(xe,{mono:!0,children:e.agentId}),e.alwaysDeliver?n.jsx(xe,{children:"always delivers"}):null,e.enabled?null:n.jsx(xe,{tone:"warning",children:"disabled"}),e.pausedReason?n.jsx(xe,{tone:"warning",children:e.pausedReason}):null]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",onClick:()=>s(A.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>i(a=>!a),"aria-expanded":r,children:r?"Less":"More"})]}),children:[n.jsxs("p",{className:"ui-card-meta",children:[e.schedule?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${Ve(e.nextRun,t)} (${Oe(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",n.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${Oe(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?n.jsxs("div",{className:"ui-card-foot",children:[e.schedule?n.jsxs(Q,{children:[n.jsx(te,{inline:!0,label:"Misfire policy",children:n.jsx("select",{value:e.schedule.misfirePolicy,onChange:a=>s(A.setMisfirePolicy(e.id,a.target.value)),children:IU.map(a=>n.jsx("option",{value:a,children:a},a))})}),n.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,n.jsx(J,{title:"Prompt",children:n.jsx(Nt,{children:e.prompt})}),n.jsx(J,{title:"Recent occurrences",children:n.jsx(Ze,{flush:!0,children:e.occurrences.length===0?n.jsx(oe,{children:"Never run."}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Scheduled"}),n.jsx("th",{children:"State"}),n.jsx("th",{children:"Finished"}),n.jsx("th",{children:"Detail"})]})}),n.jsx("tbody",{children:e.occurrences.map(a=>n.jsxs("tr",{children:[n.jsx("td",{className:"nowrap",children:Ve(a.scheduledAt,t)}),n.jsx("td",{children:n.jsx(Pd,{state:a.state})}),n.jsx("td",{className:"nowrap",children:Ve(a.finishedAt,t)}),n.jsxs("td",{className:a.error?"critical":"muted",children:[a.error?Ms(a.error,120):null,a.runConversationId?n.jsx("a",{href:`#/conversations/${a.runConversationId}`,children:"transcript"}):null]})]},a.id))})]})})})]}):null]})}function MU(e,t){const s=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${s}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function lC({ids:e,agentName:t,onDone:s}){const r=e.length,[i,a]=h.useState(!1),[l,o]=h.useState(!1);return r<=0?null:i?n.jsxs("span",{className:"ui-row",children:[n.jsx("span",{className:"muted",children:MU(r,t)}),n.jsx(I,{size:"sm",variant:"danger",disabled:l,onClick:()=>{o(!0),A.dismissOffers(e).then(()=>{a(!1),s()}).finally(()=>o(!1))},children:`Dismiss ${r}`}),n.jsx(I,{size:"sm",variant:"ghost",disabled:l,onClick:()=>a(!1),children:"Keep them"})]}):n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>a(!0),children:"Dismiss all"})}function oC({embedded:e,agentId:t,agentName:s}){const{data:r,error:i,reload:a}=ie(()=>A.offers(),[],2e4),l=g=>!t||g.agentId===t,o=((r==null?void 0:r.offers)??[]).filter(l),c=((r==null?void 0:r.closed)??[]).filter(l),[u,f]=h.useState(null),[d,m]=h.useState(null),[p,v]=h.useState(null),w=async(g,x)=>{f(null),m(g);try{const y=await A.takeOffer(g);v(y.jobId?`On it — ${x}. Started as job ${y.jobId}.`:`Taken — ${x}. No worker is running here, so nothing has started yet.`),a()}catch(y){f(y instanceof Error?y.message:String(y))}finally{m(null)}},k=async(g,x)=>{f(null),m(g);try{await A.dismissOffer(g),v(`Dismissed — ${x}. It will not come back.`),a()}catch(y){f(y instanceof Error?y.message:String(y))}finally{m(null)}};return n.jsxs(mn,{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:[n.jsx(ne,{message:i??u}),p?n.jsx(H,{tone:"good",role:"status",children:p}):null,o.length>0?n.jsxs(Q,{children:[n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(lC,{ids:o.map(g=>g.id),agentName:s,onDone:()=>{v(null),a()}})]}):null,!r||o.length===0?n.jsx(Ut,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):n.jsx(q,{children:o.map(g=>n.jsx(On,{tone:"accent",title:g.label,meta:n.jsxs(n.Fragment,{children:[n.jsx(xe,{mono:!0,children:g.agentId}),n.jsxs("span",{className:"muted",children:["expires ",Oe(g.expiresAt)]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",variant:"ghost",disabled:d===g.id,onClick:()=>void k(g.id,g.label),children:"Not now"}),n.jsx(I,{variant:"accent",size:"sm",disabled:d===g.id,onClick:()=>void w(g.id,g.label),children:"Take"})]}),children:n.jsx("p",{className:"ui-card-meta",children:g.prompt})},g.id))}),c.length>0?n.jsxs(Tt,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[n.jsx(Ze,{flush:!0,children:n.jsx(Ct,{children:c.map(g=>n.jsx(Et,{title:g.label,sub:`${g.agentId} — ${mP(g)}`,side:Oe(g.dismissedAt??g.lapsedAt??g.createdAt)},g.id))})}),n.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const $U="Add a teammate",DU="Each one keeps its own memory and tools, and can work on a schedule. Add the ones you want; Agent Father can make others.",OU="front-desk";function cC(e,t){return e.length>0&&e.every(s=>s.id===t||s.roles.includes(OU)||s.roles.includes(Rd))}const _U={plugins:{label:"Plugins",route:tt("plugins")},mailbox:{label:"Add a mailbox",route:No("email","settings")},accounts:{label:"Accounts",route:tt("accounts")}},LU="Your starter team is complete. Agent Father can make others.";function up({navigate:e,standing:t=!1}){var f;const s=ie(()=>A.teammates(),[]),[r,i]=h.useState(new Set),a=(((f=s.data)==null?void 0:f.teammates)??[]).filter(d=>!r.has(`${d.plugin}/${d.agent}`));if(a.length===0)return null;const l=d=>{i(m=>new Set(m).add(`${d.plugin}/${d.agent}`)),A.dismissAgentOffer(d.plugin,d.agent).then(s.reload,s.reload)},o=d=>m=>{m.preventDefault(),e(d)},c=t?a.filter(d=>d.state!=="added"):a,u=t?a.filter(d=>d.state==="added"):[];return n.jsx(J,{title:$U,children:c.length===0?n.jsx("p",{className:"teammates-lede","data-testid":"teammates-complete",children:LU}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"teammates-lede",children:DU}),n.jsx("div",{className:"teammates-grid","data-testid":"teammates",children:c.map(d=>n.jsx(FU,{row:d,navigate:e,onDismiss:()=>l(d)},`${d.plugin}/${d.agent}`))}),u.length>0?n.jsx("ul",{className:"teammates-added","data-testid":"teammates-added",children:u.map(d=>n.jsx("li",{children:n.jsxs("a",{className:"teammates-added-chip",href:dt(d.agent),onClick:o(dt(d.agent)),children:["Added · open @",d.handle]})},`${d.plugin}/${d.agent}`))}):null]})})}function FU({row:e,navigate:t,onDismiss:s}){const r=kx(e.plugin,e.agent),i=c=>u=>{u.preventDefault(),t(c)},a=r.created??(e.state==="added"?{id:e.agent,handle:e.handle,name:e.name}:null),l=a?"added":e.state,o=e.fix?_U[e.fix]:null;return n.jsx("div",{className:"teammate","data-state":l,"data-testid":`teammate-${e.agent}`,children:n.jsxs(On,{title:e.name,actions:n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Dismiss ${e.name}`,title:"Not now",onClick:s,children:n.jsx(Se,{name:"close"})}),foot:n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[l==="unavailable"?n.jsx("span",{className:"teammate-reason",children:e.reason}):null,n.jsx(sn,{}),a?n.jsxs("a",{href:dt(a.id),onClick:i(dt(a.id)),children:["Added, open @",a.handle]}):l==="unavailable"?o?n.jsx("a",{href:o.route,onClick:i(o.route),children:o.label}):null:n.jsx(I,{variant:"accent",size:"sm",disabled:r.busy,onClick:r.accept,"aria-label":`Add ${e.name}`,children:"Add"})]}),n.jsx(ne,{message:r.failure})]}),children:[n.jsx("p",{className:"ui-card-meta",children:e.text}),n.jsx("p",{className:"teammate-needs",children:e.needs})]})})}const UU=["fact","observation","todo"];function uC({embedded:e,agents:t,timezone:s,agentId:r}){const{data:i,error:a,reload:l}=ie(()=>A.memory(r),[r],3e4),[o,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState(null),p=j=>{var N;return j==="shared"?"Everyone":((N=t.find(b=>b.id===j))==null?void 0:N.name)??j},v=async j=>{m(null);try{await j,l()}catch(N){m(N instanceof he?N.message:String(N))}},w={nameOf:p,timezone:s,onChangePreference:j=>c({key:j.key,scope:j.scope}),onForgetPreference:j=>void v(A.forgetPreference({key:j.key,scope:j.scope})),onEditNote:j=>f(j),onForgetNote:j=>void v(A.forgetNote(j.id))},k=r?p(r):"",g=r&&i?{preferences:i.preferences.filter(j=>j.scope===r),notes:i.notes.filter(j=>j.scope===r)}:null,x=r&&i?{preferences:i.preferences.filter(j=>j.scope==="shared"),notes:i.notes.filter(j=>j.scope==="shared")}:null,y=n.jsx(I,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return n.jsxs(mn,{embedded:e,title:"Memory",lede:"What your agents have kept about you. Correct anything here; they see the change on their next turn.",children:[n.jsx(ne,{message:a??d}),g&&x?n.jsxs(q,{gap:"lg",children:[n.jsx(J,{title:"Preferences",aside:`what you told ${k} alone`,actions:y,panel:!0,flush:!0,children:n.jsx(ef,{preferences:g.preferences,empty:`Nothing stated to ${k} alone yet.`,...w})}),n.jsx(J,{title:"Notes",aside:`what ${k} wrote down for itself`,panel:!0,flush:!0,children:n.jsx(tf,{notes:g.notes,empty:`${k} has kept no private notes yet.`,...w})}),n.jsx(Tt,{summary:`Shared with every agent, which ${k} also reads · ${x.preferences.length} preferences, ${x.notes.length} notes`,children:n.jsxs(q,{gap:"lg",children:[n.jsx(J,{title:"Shared preferences",panel:!0,flush:!0,children:n.jsx(ef,{preferences:x.preferences,empty:"No shared preferences.",...w})}),n.jsx(J,{title:"Shared notes",panel:!0,flush:!0,children:n.jsx(tf,{notes:x.notes,empty:"No shared notes.",...w})})]})})]}):n.jsxs(q,{gap:"lg",children:[n.jsx(J,{title:"Preferences",aside:"what you said you want, one current value each",actions:y,panel:!0,flush:!0,children:i?n.jsx(ef,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...w}):n.jsx(oe,{children:"Loading…"})}),n.jsx(J,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?n.jsx(tf,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...w}):n.jsx(oe,{children:"Loading…"})})]}),o?n.jsx(BU,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:o,onClose:()=>c(null),onSave:async j=>{await v((async()=>{await A.setPreference(j),o.key===j.key&&o.scope!==j.scope&&await A.forgetPreference({key:o.key,scope:o.scope})})()),c(null)}}):null,u?n.jsx(zU,{note:u,agents:t,onClose:()=>f(null),onSave:j=>v(A.updateNote(u.id,j)).then(()=>f(null))}):null]})}function ef({preferences:e,empty:t,nameOf:s,onChangePreference:r,onForgetPreference:i}){return e.length===0?n.jsx(oe,{children:t}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Preference"}),n.jsx("th",{children:"Value"}),n.jsx("th",{children:"Who sees it"}),n.jsx("th",{className:"num",children:"Since"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:e.map(a=>n.jsxs("tr",{children:[n.jsx("td",{className:"mono",children:a.key}),n.jsx("td",{children:a.value}),n.jsx("td",{children:n.jsx(dC,{scope:a.scope,name:s(a.scope)})}),n.jsxs("td",{className:"num muted",title:a.updatedAt??"",children:[a.updatedAt?Oe(a.updatedAt,Date.now()):"",a.revision>1?` · rev ${a.revision}`:""]}),n.jsx("td",{className:"num",children:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",onClick:()=>r(a),title:"Store a new value for this key",children:"Change"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>i(a),children:"Forget"})]})})]},`${a.scope}:${a.key}`))})]})}function tf({notes:e,empty:t,nameOf:s,timezone:r,onEditNote:i,onForgetNote:a}){return e.length===0?n.jsx(oe,{children:t}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Note"}),n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"Who sees it"}),n.jsx("th",{children:"Written by"}),n.jsx("th",{className:"num",children:"When"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:e.map(l=>n.jsxs("tr",{children:[n.jsx("td",{className:"memory-note",children:l.content}),n.jsx("td",{children:n.jsx(xe,{tone:l.kind==="todo"?"warning":l.kind==="fact"?"good":void 0,children:l.kind})}),n.jsx("td",{children:n.jsx(dC,{scope:l.scope,name:s(l.scope)})}),n.jsx("td",{className:"muted",children:l.createdByAgent?s(l.createdByAgent):""}),n.jsxs("td",{className:"num muted",title:l.createdAt??"",children:[l.createdAt?Oe(l.createdAt,Date.now()):"",l.expiresAt?n.jsxs("span",{className:"memory-expires",children:[" · until ",new Date(l.expiresAt).toLocaleDateString(void 0,{timeZone:r})]}):null]}),n.jsx("td",{className:"num",children:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",onClick:()=>i(l),children:"Edit"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>a(l),children:"Forget"})]})})]},l.id))})]})}function dC({scope:e,name:t}){return n.jsx(xe,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function hC({value:e,agents:t,onChange:s}){return n.jsxs("select",{value:e,onChange:r=>s(r.target.value),children:[n.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>n.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function BU({agents:e,existing:t,initial:s,onClose:r,onSave:i}){const a=t.find(x=>x.key===s.key&&x.scope===s.scope),[l,o]=h.useState(s.key),[c,u]=h.useState((a==null?void 0:a.value)??""),[f,d]=h.useState(s.scope),[m,p]=h.useState(!1),v=l.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(x=>x.key===v&&x.scope===f),k=!a||v!==a.key||c.trim()!==a.value||f!==a.scope,g=v!==""&&c.trim()!==""&&k;return n.jsx(Dt,{title:"A preference",onClose:r,children:n.jsxs(q,{children:[n.jsx(H,{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.'}),n.jsx(te,{label:"Key",hint:v&&v!==l?`Stored as ${v}`:"Short and stable, like reporting_currency or tone.",children:n.jsx("input",{value:l,autoFocus:s.key==="",onChange:x=>o(x.target.value),placeholder:"reporting_currency"})}),n.jsx(te,{label:"Value",children:n.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:s.key!=="",onChange:x=>u(x.target.value),placeholder:"EUR"})}),n.jsx(te,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:n.jsx(hC,{value:f,agents:e,onChange:d})}),w&&w!==a?n.jsxs(H,{tone:"warning",children:['This replaces the value already stored for this key here, "',w.value,'" (revision ',w.revision,")."]}):null,a&&f!==a.scope?n.jsxs(H,{children:["It moves: the copy for ",a.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:r,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!g||m,onClick:()=>{p(!0),i({key:v,value:c.trim(),scope:f}).finally(()=>p(!1))},children:a?"Save change":"Save"})]})]})})}function zU({note:e,agents:t,onClose:s,onSave:r}){var p;const[i,a]=h.useState(e.content),[l,o]=h.useState(e.scope),[c,u]=h.useState(e.kind),[f,d]=h.useState(!1),m=i.trim()!==e.content||l!==e.scope||c!==e.kind;return n.jsx(Dt,{title:"A note",onClose:s,children:n.jsxs(q,{children:[n.jsx(te,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:n.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:v=>a(v.target.value)})}),n.jsxs(sr,{children:[n.jsx(te,{label:"Kind",children:n.jsx("select",{value:c,onChange:v=>u(v.target.value),children:UU.map(v=>n.jsx("option",{value:v,children:v},v))})}),n.jsx(te,{label:"Who sees it",children:n.jsx(hC,{value:l,agents:t,onChange:o})})]}),e.createdByAgent?n.jsxs("p",{className:"muted",children:["Written by ",((p=t.find(v=>v.id===e.createdByAgent))==null?void 0:p.name)??e.createdByAgent,e.createdAt?`, ${Oe(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!m||i.trim()===""||f,onClick:()=>{d(!0);const v={};i.trim()!==e.content&&(v.content=i.trim()),l!==e.scope&&(v.scope=l),c!==e.kind&&(v.kind=c),r(v).finally(()=>d(!1))},children:"Save"})]})]})})}function WU({agentId:e,agentName:t}){const{data:s,error:r,reload:i}=ie(()=>A.agentSkills(e),[e],3e4),[a,l]=h.useState(null),[o,c]=h.useState(null),[u,f]=h.useState(null),d=async v=>{l(null),c(null),f(v.name);try{const w=await A.removeSkill(e,v.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){l(w instanceof he?w.message:String(w))}finally{f(null)}};if(!s)return r?n.jsx(ne,{message:r}):n.jsx(oe,{children:"Loading…"});const m=s.skills.filter(v=>v.learned!==null),p=s.skills.filter(v=>v.learned===null);return n.jsxs(q,{divided:!0,children:[n.jsx(ne,{message:r??a}),o?n.jsx(H,{tone:"good",role:"status",children:o}):null,n.jsx(J,{title:"Learned",aside:n.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:m.length===0?n.jsx(Ut,{icon:"bulb",title:"Nothing learned yet",children:s.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.`}):n.jsx(Ze,{flush:!0,children:n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Skill"}),n.jsx("th",{children:"Version"}),n.jsx("th",{children:"Came from"}),n.jsx("th",{className:"num",children:"Kept"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:m.map(v=>n.jsx(VU,{skill:v,busy:u===v.name,onRemove:()=>void d(v)},v.name))})]})})}),n.jsx(J,{title:"From files and plugins",aside:n.jsx("span",{className:"muted",children:"read-only here"}),children:p.length===0?n.jsx(oe,{children:"No other skills."}):n.jsx(Ze,{flush:!0,children:n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Skill"}),n.jsx("th",{children:"What it is for"}),n.jsx("th",{children:"Whose"})]})}),n.jsx("tbody",{children:p.map(v=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(Tt,{summary:n.jsx("span",{className:"mono",children:v.name}),children:[n.jsx(Nt,{children:v.body}),n.jsx("p",{className:"muted mono skill-file",children:v.file})]})}),n.jsx("td",{children:v.description}),n.jsx("td",{children:n.jsxs(q,{gap:"sm",children:[n.jsx(xe,{children:v.scope==="shared"?"shared":`${t} only`}),n.jsx("span",{className:"muted",children:HU(v)})]})})]},`${v.scope}:${v.name}`))})]})})})]})}function HU(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function VU({skill:e,busy:t,onRemove:s}){const r=e.learned;return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(Tt,{summary:n.jsxs("span",{children:[r.title," ",n.jsx("span",{className:"muted mono",children:e.name})]}),children:[n.jsxs("p",{className:"muted",children:["When: ",e.description]}),n.jsx(Nt,{children:e.body}),n.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),n.jsx("td",{children:n.jsxs(q,{gap:"sm",children:[n.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?n.jsx(xe,{tone:"warning",children:"untrusted text in view"}):null]})}),n.jsx("td",{children:n.jsxs(q,{gap:"sm",children:[r.conversation?n.jsx("a",{href:Ta(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):n.jsx("span",{className:"muted",children:"no conversation"}),n.jsx("a",{href:tt("proposals"),children:"the proposal"}),r.sources.length>0?n.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>n.jsx("li",{className:"mono",children:i},i))}):null]})}),n.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?Oe(r.keptAt,Date.now()):""}),n.jsx("td",{className:"num",children:n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",variant:"ghost",disabled:t,onClick:s,children:"Remove"})})})]})}function fC({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=ie(()=>A.reminders(),[],3e4),l=((r==null?void 0:r.reminders)??[]).filter(f=>!s||f.agentId===s),[o,c]=h.useState(null),u=async f=>{c(null);try{await A.cancelReminder(f),a()}catch(d){c(d instanceof Error?d.message:String(d))}};return n.jsxs(mn,{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:[n.jsx(ne,{message:i??o}),n.jsx(Ze,{flush:!0,children:r?l.length===0?n.jsx(Ut,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Due"}),n.jsx("th",{children:"Agent"}),n.jsx("th",{children:"Note"}),n.jsx("th",{children:"State"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:l.map(f=>n.jsxs("tr",{children:[n.jsxs("td",{className:"nowrap",children:[Ve(f.dueAt,e),n.jsx("div",{className:"sub",children:Oe(f.dueAt)})]}),n.jsx("td",{className:"mono",children:f.agentId}),n.jsxs("td",{children:[f.text,f.context?n.jsx(Tt,{summary:"context",children:n.jsx(Nt,{children:Sn(f.context)})}):null]}),n.jsxs("td",{children:[n.jsx(Pd,{state:f.state}),f.cancelReason?n.jsx("div",{className:"sub",children:f.cancelReason}):null]}),n.jsx("td",{children:f.state==="pending"?n.jsx(I,{size:"sm",variant:"danger",onClick:()=>u(f.id),children:"Cancel"}):null})]},f.id))})]}):n.jsx(oe,{children:"Loading…"})})]})}function Dx({accountId:e,label:t,value:s,onChange:r,disabled:i=!1}){const[a,l]=h.useState(null),[o,c]=h.useState(!1),[u,f]=h.useState(""),[d,m]=h.useState(!1),p=h.useRef(0),v=async x=>{if(!e)return;const y=++p.current;c(!0),f("");try{const j=await A.accountModels(e,x);y===p.current&&l(j)}catch(j){y===p.current&&f(j instanceof Error?j.message:"Could not load models. Custom entry is still available.")}finally{y===p.current&&c(!1)}};if(h.useEffect(()=>(l(null),m(!1),f(""),v(!1),()=>{p.current++}),[e]),!e)return n.jsxs(n.Fragment,{children:[n.jsx(te,{label:t,children:n.jsx("input",{required:!0,maxLength:150,value:s,disabled:i,onChange:x=>r(x.target.value)})}),n.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=(a==null?void 0:a.models)??[],k=!!s&&!w.some(x=>x.id===s),g=[a&&!w.length?"This account returned no models. You can enter a custom model.":null,a!=null&&a.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,a?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return n.jsxs(n.Fragment,{children:[n.jsx(te,{label:t,children:n.jsxs("select",{value:d?"__buddi_custom__":s,disabled:i,onChange:x=>{x.target.value==="__buddi_custom__"?m(!0):(m(!1),r(x.target.value))},children:[n.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),k&&n.jsxs("option",{value:s,children:[s," (current",a?", not listed":"",")"]}),w.map(x=>n.jsxs("option",{value:x.id,children:[x.name===x.id?x.id:`${x.name} — ${x.id}`,x.isDefault?" (provider default)":""]},x.id)),n.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),n.jsx(I,{disabled:i||o,onClick:()=>void v(!0),children:o?"Loading models…":"Refresh models"}),d&&n.jsx(te,{label:`Custom ${t.toLowerCase()}`,children:n.jsx("input",{required:!0,maxLength:150,value:s,disabled:i,onChange:x=>r(x.target.value)})}),u&&n.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),g.length>0&&n.jsx("p",{className:"ui-toolbar-note",children:g.join(" ")})]})}function KU(e,t){const s=new Set(t),r=[],i=new Set;for(const a of e){for(const o of a.tools)i.add(o.name);const l=a.tools.filter(o=>s.has(o.name));l.length!==0&&(a.glob&&l.length===a.tools.length?r.push(a.glob):r.push(...l.map(o=>o.name)))}return r.push(...t.filter(a=>!i.has(a))),r}function GU(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const YU="This agent will not remember anything between conversations.";function qU({view:e,chosen:t,onChange:s,disabled:r}){var N;const[i,a]=h.useState(""),[l,o]=h.useState(null),[c,u]=h.useState(()=>new Set),f=b=>u(S=>{const C=new Set(S);return C.has(b)?C.delete(b):C.add(b),C}),d=b=>{a(b),u(new Set)},m=h.useId(),p=new Set(t),v=new Set(e.groups.flatMap(b=>b.tools.filter(S=>S.core).map(S=>S.name))),w=(b,S)=>{const C=S.filter(R=>p.has(R));if(C.length!==0){if(C.some(R=>v.has(R))){o({plugin:b,names:C});return}s(t.filter(R=>!C.includes(R)))}},k=b=>{s([...t,...b.filter(S=>!p.has(S))])},g=i.trim().toLowerCase(),x=(b,S)=>g===""||b.toLowerCase().includes(g)||S.toLowerCase().includes(g),y=e.groups.map(b=>({group:b,tools:b.tools.filter(S=>x(S.name,S.description))})).filter(b=>b.tools.length>0),j=(((N=e.suggested)==null?void 0:N.tools)??[]).filter(b=>!p.has(b.name));return n.jsxs("div",{className:"tool-picker",children:[e.suggested&&j.length>0?n.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${m}-suggested`,children:[n.jsx("div",{className:"tool-picker-head",children:n.jsx("span",{id:`${m}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),n.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:j.map(b=>n.jsxs("li",{className:"ui-list-row",children:[n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title mono",children:b.name}),n.jsx("span",{className:"ui-list-sub",children:b.description})]}),n.jsx(I,{size:"sm",disabled:r,"aria-label":`Add ${b.name}`,onClick:()=>k([b.name]),children:"Add"})]},b.name))})]}):null,n.jsxs("label",{className:"tool-picker-search",children:[n.jsx("span",{className:"ui-field-label",children:"Find a tool"}),n.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:b=>d(b.target.value)})]}),y.length===0?n.jsxs(oe,{children:["No installed tool matches “",i.trim(),"”."]}):null,y.map(({group:b,tools:S})=>{const C=b.tools.filter(T=>T.grantable).map(T=>T.name),R=b.tools.filter(T=>p.has(T.name)).length,E=!!b.glob&&R===b.tools.length,P=`${m}-${b.plugin}`,F=`${m}-${b.plugin}-list`,M=g!==""?!c.has(b.plugin):c.has(b.plugin);return n.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":P,"data-open":M?"true":void 0,children:[n.jsxs("div",{className:"tool-picker-head",children:[n.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":M,"aria-controls":F,onClick:()=>f(b.plugin),children:[n.jsx(QU,{}),n.jsx("span",{id:P,className:"tool-picker-plugin",children:b.plugin}),n.jsx("span",{className:"muted",children:E?`all ${b.tools.length}`:`${R} of ${b.tools.length} granted`})]}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":`All ${b.plugin} tools`,disabled:r||C.every(T=>p.has(T)),onClick:()=>k(C),children:"all"}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":`No ${b.plugin} tools`,disabled:r||!C.some(T=>p.has(T)),onClick:()=>w(b.plugin,C),children:"none"})]}),(l==null?void 0:l.plugin)===b.plugin?n.jsx(H,{tone:"warning",role:"alert",children:n.jsxs("div",{className:"tool-picker-confirm",children:[n.jsx("span",{children:YU}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{size:"sm",onClick:()=>o(null),children:"Keep"}),n.jsx(I,{size:"sm",variant:"danger",onClick:()=>{s(t.filter(T=>!l.names.includes(T))),o(null)},children:"Remove"})]})}):null,n.jsx("ul",{id:F,className:"ui-list tool-picker-list",hidden:!M,children:S.map(T=>{const $=`${m}-${T.name}`;return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",id:$,checked:p.has(T.name),disabled:r||!T.grantable,onChange:_=>_.target.checked?k([T.name]):w(b.plugin,[T.name])}),n.jsxs("label",{htmlFor:$,className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[n.jsx("span",{className:"mono",children:T.name}),T.core?n.jsx(xe,{tone:"accent",children:"core"}):null,T.gated?n.jsx(xe,{tone:"warning",children:"asks you"}):null]}),n.jsx("span",{className:"ui-list-sub",children:T.grantable?T.description:`${T.description} Granted only by editing the file by hand.`})]})]},T.name)})})]},b.plugin)})]})}function QU(){return n.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:n.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const JU=(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 mC(e){const t=await fetch(Gr(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const s=await t.blob();return new File([s],`buddi-blob-${e}.png`,{type:"image/png"})}function pC({face:e,onPick:t,label:s=U.assistant.face,kept:r,disabled:i,disableEmoji:a,children:l}){return n.jsxs("div",{className:"meet-faces",role:"group","aria-label":s,children:[n.jsxs("div",{className:"meet-face-row",children:[r?n.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:n.jsx("img",{src:r,alt:""})}):null,hO.map(o=>{const c={kind:"mascot",role:o},u=JU(e,c);return n.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":U.assistant.mascot(o),disabled:i,onClick:()=>t(c),children:n.jsx("img",{src:Gr(o),alt:""})},o)})]}),n.jsx("div",{className:"meet-face-row",children:mO.map(o=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===o;return n.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||a,onClick:()=>t({kind:"emoji",value:o}),children:o},o)})}),l]})}const XU=["mirror","en","fr"],gC=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"access",label:"Access"}],yw=e=>{var t;return((t=gC.find(s=>s.id===e))==null?void 0:t.id)??"identity"};function ZU({agentId:e,section:t,navigate:s}){var w,k,g;const{data:r,error:i,reload:a}=ie(()=>A.agents(),[]),[l,o]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(yw(t));h.useEffect(()=>d(yw(t)),[t]);const m=x=>{d(x),s==null||s(dt(e,"setup",x))},p=async x=>{o(null),u(null);try{const y=await x;u(y.changed.length===0?`No file change needed. ${y.note}.`:`Changed ${y.changed.join(", ")}. ${y.note}.`),a()}catch(y){o(y instanceof Error?y.message:String(y))}},v=r==null?void 0:r.agents.find(x=>x.id===e);return n.jsxs(q,{gap:"lg",children:[n.jsx(Ao,{level:"secondary",label:"Setup",children:gC.map(x=>n.jsx(Ra,{href:dt(e,"setup",x.id),active:f===x.id,onClick:y=>{y.preventDefault(),m(x.id)},children:x.label},x.id))}),n.jsx(ne,{message:i??l}),c?n.jsx(H,{tone:"good",role:"status",children:c}):null,r?v?n.jsx(eB,{agent:v,all:r.agents,engine:r.engines.find(x=>x.id===v.id),providers:r.providers,accounts:r.providerAccounts,shown:f,onShow:m,onRun:p,onSaved:a},`${v.id}:${(w=r.engines.find(x=>x.id===v.id))==null?void 0:w.model}:${(g=(k=r.providerAccounts)==null?void 0:k.bindings.find(x=>x.agentId===v.id))==null?void 0:g.accountId}`):n.jsx(oe,{children:"This agent is not installed as a file."}):n.jsx(oe,{children:"Loading…"})]})}function eB({agent:e,all:t,engine:s,providers:r,accounts:i,shown:a,onShow:l,onRun:o,onSaved:c}){const u=(s==null?void 0:s.provider)??e.provider.kind,f=r.find(j=>j.kind===u),d=(s==null?void 0:s.model)??e.model,[m,p]=h.useState(String((s==null?void 0:s.maxTurns)??e.maxTurns)),v=j=>{o(A.setAgentEngine(e.id,j))},w=j=>{const N=r.find(b=>b.kind===j);v({provider:j,model:(N==null?void 0:N.defaultModel)??d})},k=(f==null?void 0:f.models.map(j=>j.id))??[],g=k.includes(d)?k:[d,...k],x=s?s.available:!0,y=(s==null?void 0:s.unavailableReason)??"no credential";return n.jsxs(n.Fragment,{children:[n.jsx("div",{hidden:a!=="identity",children:n.jsxs(q,{gap:"lg",children:[x?null:n.jsxs(H,{tone:"warning",children:["This agent cannot run right now."," ",n.jsx("a",{href:dt(e.id,"setup","brain"),onClick:j=>{j.preventDefault(),l("brain")},children:"See Brain."})]}),n.jsx(tB,{agent:e,onSaved:c})]})}),n.jsx("div",{hidden:a!=="brain",children:n.jsxs(q,{gap:"lg",children:[x?null:n.jsxs(H,{tone:"warning",children:["This agent cannot run right now: ",y,"."]}),n.jsx(J,{panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsxs(J,{title:"Runs on",children:[i?n.jsx(aB,{agentId:e.id,accounts:i,onRun:o}):n.jsxs(sr,{children:[n.jsx(te,{label:"Provider",children:n.jsx("select",{value:u,onChange:j=>w(j.target.value),children:r.map(j=>n.jsxs("option",{value:j.kind,children:[j.kind,j.usable?"":" (no credential)"]},j.kind))})}),n.jsxs(te,{label:"Model",children:[n.jsx("input",{list:`models-${e.id}`,defaultValue:d,onBlur:j=>{j.target.value.trim()!==""&&j.target.value.trim()!==d&&v({model:j.target.value.trim()})}}),n.jsx("datalist",{id:`models-${e.id}`,children:g.map(j=>n.jsx("option",{value:j},j))})]})]}),i?null:n.jsxs("p",{className:"ui-card-meta",children:[(s==null?void 0:s.credentialKind)??e.provider.credentialKind," from"," ",n.jsx("span",{className:"mono",children:(s==null?void 0:s.credentialEnv)??e.provider.credentialEnv}),f&&!f.usable?` · default model ${f.defaultModel} (${f.defaultFrom})`:""]}),s!=null&&s.restartRequired?n.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),n.jsx(J,{title:"Behaviour",aside:"saved as you change them",children:n.jsxs(sr,{children:[n.jsx(te,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:n.jsx("input",{type:"number",min:1,value:m,onChange:j=>p(j.target.value),onBlur:()=>{const j=Number(m);Number.isInteger(j)&&j>=1&&j!==((s==null?void 0:s.maxTurns)??e.maxTurns)&&v({maxTurns:j})}})}),n.jsx(te,{label:"Language",hint:"Mirror answers in whatever language you write.",children:n.jsx("select",{value:(s==null?void 0:s.language)??e.language,onChange:j=>v({language:j.target.value}),children:XU.map(j=>n.jsx("option",{value:j,children:j},j))})}),fS(mS(s??{id:e.id,provider:u},i))?n.jsx(te,{label:"Thinking",hint:"Reasoning before the answer. Off is faster and cheaper.",children:n.jsxs("select",{"aria-label":"Thinking",value:(s==null?void 0:s.thinking)??"default",onChange:j=>v({thinking:j.target.value==="default"?null:j.target.value}),children:[n.jsx("option",{value:"default",children:"Model default"}),n.jsx("option",{value:"on",children:"On"}),n.jsx("option",{value:"off",children:"Off"})]})}):n.jsx(te,{label:"Thinking",hint:gP,children:n.jsx("span",{className:"ui-card-meta",children:"Up to the model"})})]})})]})})]})}),n.jsx("div",{hidden:a!=="access",children:n.jsxs(q,{gap:"lg",children:[n.jsx(nB,{agent:e,all:t,onSaved:c}),n.jsx(uB,{agent:e,all:t,onSaved:c}),n.jsx(Tt,{summary:"Built-in context",boxed:!0,children:n.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."})})]})})]})}function xC({dirty:e,busy:t,failure:s,label:r,onSave:i}){return n.jsxs(n.Fragment,{children:[s?n.jsx("span",{className:"critical save-error",role:"alert",children:s}):n.jsx("span",{className:e?"warning":"muted",children:e?"Not saved yet.":"Saved. Applies to new runs."}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{variant:"accent",disabled:!e||t,onClick:i,children:r})]})}const vC=n.jsx(H,{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."});function tB({agent:e,onSaved:t}){var M;const[s,r]=h.useState(e.name),[i,a]=h.useState(e.handle),[l,o]=h.useState(e.description),[c,u]=h.useState(e.avatar??""),[f,d]=h.useState(!1),m=ie(()=>A.agentFile(e.id),[e.id]),[p,v]=h.useState(null),w=((M=m.data)==null?void 0:M.persona.trim())??"",k=p??w,g=m.data!==void 0&&p!==null&&p.trim()!==w,[x,y]=h.useState(!1),[j,N]=h.useState(null),[b,S]=h.useState(null),C=s.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||l.trim()!==e.description||c.trim()!==(e.avatar??"")||g,R=c.trim()!==""&&(c.trim()!==(e.avatar??"")||!e.picture),E=dp(R?{...e,avatar:c.trim()}:e),P={...E?{avatar:E}:{},...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...!R&&e.picture?{picture:e.picture}:{}},F=async()=>{y(!0),N(null),S(null);try{const T=await A.updateAgentFile(e.id,{name:s.trim(),handle:i.trim().replace(/^@/,""),description:l.trim(),...c.trim()===""?{}:{avatar:c.trim()},...g&&k.trim()!==""?{persona:k.trim()}:{}});e.picture&&c.trim()!==""&&c.trim()!==(e.avatar??"")&&(await A.removeAgentPicture(e.id),window.dispatchEvent(new Event(ro))),v(null),m.reload(),S(T.message),t()}catch(T){N(T instanceof Error?T.message:String(T))}finally{y(!1)}};return n.jsx(J,{title:"Who it is",aside:n.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:n.jsx(xC,{dirty:C,busy:x,failure:j,label:"Save who it is",onSave:()=>void F()}),children:n.jsxs(q,{children:[e.isExample?vC:null,b?n.jsx(H,{tone:"good",role:"status",children:b}):null,n.jsxs(sr,{children:[n.jsx(te,{label:"Name",hint:"What it is called, everywhere.",children:n.jsx("input",{value:s,disabled:x||e.isExample,onChange:T=>r(T.target.value)})}),n.jsx(te,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:n.jsx("input",{value:i,disabled:x||e.isExample,onChange:T=>a(T.target.value)})})]}),n.jsxs(Q,{children:[n.jsx(ps,{id:e.id,name:s.trim()||e.name,size:"xl",face:P}),n.jsx(I,{"aria-expanded":f,onClick:()=>d(T=>!T),children:f?"Hide faces":"Change face"})]}),f?n.jsx(rB,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:x}):null,n.jsx(te,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:n.jsx("textarea",{rows:2,value:l,disabled:x||e.isExample,onChange:T=>o(T.target.value)})}),n.jsx(te,{label:"Persona",hint:n.jsxs(n.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",n.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:m.error?n.jsx(ne,{message:m.error}):m.data?n.jsx("textarea",{className:"setup-persona",value:k,rows:Math.max(6,k.split(`
110
- `).length+1),disabled:x||e.isExample,onChange:T=>v(T.target.value)}):n.jsx(oe,{children:"Reading its file…"})})]})})}function nB({agent:e,all:t,onSaved:s}){var R;const r=ie(()=>A.agentTools(e.id),[e.id]),[i,a]=h.useState(null),[l,o]=h.useState(()=>new Set((e.roles??[]).filter(dy))),[c,u]=h.useState((e.roles??[]).filter(E=>!dy(E)).join(", ")),[f,d]=h.useState(!1),[m,p]=h.useState(null),[v,w]=h.useState(null),k=(E,P)=>E.split(P).map(F=>F.trim()).filter(F=>F!==""),g=((R=r.data)==null?void 0:R.granted)??e.tools,x=i??g,y=r.data!==void 0&&!GU(x,g),j=hy(l,k(c,/[\n,]/)),N=E=>o(P=>{const F=new Set(P);return F.has(E)?F.delete(E):F.add(E),F}),S=y||!((E,P)=>E.join(",")===P.join(","))(j,hy(new Set(e.roles??[]),e.roles??[])),C=async()=>{d(!0),p(null),w(null);try{const E=await A.updateAgentFile(e.id,{...y&&r.data?{tools:KU(r.data.groups,x)}:{},roles:j});w(E.message),a(null),r.reload(),s()}catch(E){p(E instanceof Error?E.message:String(E))}finally{d(!1)}};return n.jsx(J,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:n.jsx(xC,{dirty:S,busy:f,failure:m,label:"Save roles and tools",onSave:()=>void C()}),children:n.jsxs(q,{children:[e.isExample?vC:null,v?n.jsx(H,{tone:"good",role:"status",children:v}):null,n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",id:`roles-${e.id}`,children:"Roles"}),n.jsx("div",{className:"role-chips",role:"group","aria-labelledby":`roles-${e.id}`,children:Jg.map(E=>{const P=kD(t,E.id),F=P&&P.id!==e.id?P:void 0;return n.jsxs("button",{type:"button",className:"role-chip","aria-pressed":l.has(E.id),"data-on":l.has(E.id)?"true":void 0,disabled:f||e.isExample,onClick:()=>N(E.id),children:[n.jsx("span",{className:"role-chip-label",children:E.label}),n.jsx("span",{className:"role-chip-meaning",children:E.meaning}),F?n.jsxs("span",{className:"role-chip-holder",children:["Held by ",F.name,". If both claim it, the one listed first keeps it."]}):null]},E.id)})}),n.jsx("span",{className:"ui-field-hint",children:"Where buddi sends things when you do not say who. Tools are granted below."})]}),n.jsx(te,{label:"Other roles",hint:"Only a plugin that asks for a role by name reads these. Comma separated.",children:n.jsx("input",{value:c,disabled:f||e.isExample,onChange:E=>u(E.target.value)})}),n.jsxs("div",{className:"ui-field",children:[n.jsxs("span",{className:"ui-field-label",children:["Tools · ",g.length," granted"]}),r.error?n.jsx(ne,{message:r.error}):r.data?n.jsx(qU,{view:r.data,chosen:x,onChange:a,disabled:f||e.isExample}):n.jsx(oe,{children:"Loading the installed tools…"})]}),n.jsx(sB,{agentId:e.id,version:g.join(","),disabled:f||e.isExample})]})})}function sB({agentId:e,version:t,disabled:s}){var f;const r=ie(()=>Promise.resolve().then(()=>A.rememberedApprovals(e)),[e,t]),[i,a]=h.useState(null),[l,o]=h.useState(null),c=((f=r.data)==null?void 0:f.tools)??[];if(c.length===0)return null;const u=async(d,m)=>{a(d),o(null);try{await A.setRememberedApproval(e,d,m),r.reload()}catch(p){o(p instanceof Error?p.message:String(p))}finally{a(null)}};return n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Connection tools that ask first"}),n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Remembered approvals",children:c.map(d=>n.jsxs(q,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:d.remembered,disabled:s||!d.rememberable||i!==null,onChange:m=>void u(d.tool,m.target.checked)}),n.jsxs("span",{children:[n.jsx("span",{className:"mono",children:d.tool})," · remember my approval"]})]}),d.why?n.jsx("p",{className:"ui-card-meta",children:d.why}):null]},d.tool))}),n.jsx(ne,{message:l}),n.jsx("span",{className:"ui-field-hint",children:"Remembered, it asks once and then runs for this agent. Never for a tool that deletes or destroys."})]})}function dp(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 rB({agent:e,avatar:t,onEmoji:s,onChanged:r,disabled:i}){const[a,l]=h.useState(null),[o,c]=h.useState(!1),[u,f]=h.useState(null),d=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),m=a??(d?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),p=async v=>{if(f(null),v.kind==="emoji"){s(v.value);return}if(v.kind==="kept"){s(e.avatar??"");return}l(v),c(!0);try{await A.uploadAgentPicture(e.id,await mC(v.role)),s(e.avatar??""),r(),window.dispatchEvent(new Event(ro))}catch(w){f(w instanceof Error?w.message:String(w))}finally{l(null),c(!1)}};return n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Face"}),n.jsx(pC,{face:m,label:"Face",kept:e.picture,disabled:i||o,disableEmoji:e.isExample,onPick:v=>void p(v),children:n.jsx(iB,{agent:e,onChanged:r})}),u?n.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function iB({agent:e,onChanged:t}){const[s,r]=h.useState(null),[i,a]=h.useState(null),[l,o]=h.useState(!1),[c,u]=h.useState(null),[f,d]=h.useState(null),[m,p]=h.useState(0);h.useEffect(()=>{if(!s)return a(null);const S=URL.createObjectURL(s);return a(S),()=>URL.revokeObjectURL(S)},[s]);const v=S=>{r(null),p(C=>C+1),d(S),t(),window.dispatchEvent(new Event(ro))},w=async S=>{o(!0),u(null),d(null);try{v(await S())}catch(C){u(C instanceof Error?C.message:String(C))}finally{o(!1)}},k=()=>w(async()=>(await A.uploadAgentPicture(e.id,s)).note??null),g=()=>w(async()=>(await A.removeAgentPicture(e.id),null)),x={avatar:dp(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[y,j]=h.useState(!1),N=h.useRef(null),b=S=>{u(null),d(null),r(S??null)};return n.jsxs("div",{className:"setup-upload","data-dragging":y?"true":void 0,onDragOver:S=>{S.preventDefault(),l||j(!0)},onDragLeave:()=>j(!1),onDrop:S=>{var C;S.preventDefault(),j(!1),l||b((C=S.dataTransfer.files)==null?void 0:C[0])},children:[n.jsxs(Q,{children:[n.jsx(ps,{id:e.id,name:e.name,size:"xl",face:x}),n.jsx("input",{ref:N,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:l,onChange:S=>{var C;return b((C=S.target.files)==null?void 0:C[0])}},m),n.jsx(I,{disabled:l,onClick:()=>{var S;return(S=N.current)==null?void 0:S.click()},children:"Upload a picture"}),n.jsx("span",{className:"setup-upload-name",children:s?s.name:"or drop one here"}),n.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!s?n.jsx(I,{variant:"ghost",disabled:l,onClick:()=>void g(),children:"Remove picture"}):null,n.jsx(I,{variant:"accent",disabled:!s||l,onClick:()=>void k(),children:"Save picture"})]}),c?n.jsx("span",{className:"critical save-error",role:"alert",children:c}):n.jsx("span",{className:"ui-field-hint",children:f??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function aB({agentId:e,accounts:t,onRun:s}){const r=t.bindings.find(p=>p.agentId===e),[i,a]=h.useState((r==null?void 0:r.accountId)??""),[l,o]=h.useState((r==null?void 0:r.model)??""),[c,u]=h.useState(!1),f=t.accounts.find(p=>p.id===i),d=i!==((r==null?void 0:r.accountId)??"")||l!==((r==null?void 0:r.model)??""),m=t.accounts.find(p=>p.id===(r==null?void 0:r.accountId));return n.jsxs("div",{className:"ui-stack",children:[n.jsxs(Q,{valign:"end",children:[n.jsx(te,{label:"Account",children:n.jsxs("select",{value:i,disabled:c,onChange:p=>{var v;a(p.target.value),o(((v=t.accounts.find(w=>w.id===p.target.value))==null?void 0:v.defaultModel)??"")},children:[n.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(p=>n.jsxs("option",{value:p.id,disabled:!p.enabled,children:[p.label,p.enabled?p.configured?"":" (needs credential)":" (disabled)"]},p.id))]})}),n.jsx(Dx,{accountId:f!=null&&f.configured?i:void 0,label:"Model",value:l,onChange:o,disabled:c},`${i}:${f==null?void 0:f.revision}`)]}),n.jsxs(Q,{children:[d&&i&&l.trim()?n.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",m?`${m.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):n.jsx("span",{className:"muted",children:m?`Running on ${m.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{variant:"accent",disabled:c||!i||!l.trim()||!d,onClick:()=>{u(!0),s(A.assignProviderAccount(e,i,l).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const lB=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],nf=e=>e.tools.some(t=>lB.includes(t)),oB=["front-desk","maker"],cB={"front-desk":"Can ask: everyone, as the front desk",maker:"Can ask: everyone, as the maker",list:"Can ask: everyone"};function uB({agent:e,all:t,onSaved:s}){const[r,i]=h.useState(e.delegates),[a,l]=h.useState(!1),[o,c]=h.useState(null),[u,f]=h.useState(!1),[d,m]=h.useState(e.delegates),[p,v]=h.useState(e.asksEveryone),[w,k]=h.useState(!1),g=t.filter(E=>E.id!==e.id),x=oB.find(E=>{var P;return(P=e.roles)==null?void 0:P.includes(E)}),y=p===void 0||w,j=w||[...r].sort().join(",")!==[...d].sort().join(","),N=t.filter(E=>E.id!==e.id&&(E.delegates.includes(e.id)||E.asksEveryone!==void 0&&!nf(e))),b=E=>i(P=>P.includes(E)?P.filter(F=>F!==E):[...P,E]),S=async E=>{l(!0),c(null),f(!1);try{const P=await A.setDelegates(e.id,E);m(P.delegates),i(P.delegates),v(P.asksEveryone),k(!1),f(!0),s()}catch(P){c(P instanceof Error?P.message:String(P))}finally{l(!1)}},C=()=>{i(g.filter(E=>!nf(E)).map(E=>E.id)),k(!0),f(!1)},R=j?"Not saved yet.":u?"Saved. Applies to the next run.":y?r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`:"Asks everyone.";return n.jsx(J,{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:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:j?"warning":"muted",children:R}),n.jsx("span",{className:"ui-toolbar-spacer"}),y&&x!==void 0?n.jsx(I,{disabled:a,onClick:()=>void S(["*"]),children:"Let it ask everyone"}):null,y?n.jsx(I,{variant:"accent",disabled:!j||a,onClick:()=>void S(r),children:"Save who it can ask"}):n.jsx(I,{variant:"accent",disabled:a,onClick:C,children:"Limit to…"})]}),children:n.jsxs(q,{divided:!0,children:[n.jsxs(J,{title:"Can ask",children:[e.isExample?n.jsx(H,{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,n.jsx(ne,{message:o}),y?g.length===0?n.jsx(oe,{children:"Nobody else is installed."}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Only the agents ticked here. New teammates must be added here before it can ask them."}),n.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:g.map(E=>{const P=nf(E);return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${E.id}`,checked:r.includes(E.id),disabled:P||e.isExample||a,onChange:()=>b(E.id)}),n.jsxs("label",{htmlFor:`can-ask-${e.id}-${E.id}`,className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[E.name," ",n.jsxs("span",{className:"mono muted",children:["@",E.handle]})]}),n.jsx("span",{className:"ui-list-sub",children:P?"Makes and changes agents. Never reachable by delegation.":E.description})]})]},E.id)})})]}):n.jsxs("p",{className:"ui-card-meta",children:[cB[p??"list"],". New agents are included without being added here; agents that make and change agents are never reachable by delegation."]})]}),n.jsx(J,{title:"Asked by",children:N.length===0?n.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):n.jsx(t_,{children:N.map(E=>n.jsx(xe,{children:E.name},E.id))})})]})})}const dB=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],hB=[{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 fB({hash:e,timezone:t,navigate:s,agents:r,attention:i,defaultAgentId:a}){var g,x,y,j,N;const l=cD(e),o=((g=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:g[1])??"team",c=b=>S=>{S.preventDefault(),s(b)},u=ie(()=>A.agents(),[]),f=jx(),d=ie(()=>A.offers(),[],2e4),m=k1(),p=(((x=d.data)==null?void 0:x.offers.length)??0)+m.offers.length,v=((j=(y=u.data)==null?void 0:y.default)==null?void 0:j.defaultAgentId)??a??null,w=r.find(b=>b.roles.includes(Rd)),k=cC(r,v);return n.jsxs("div",{className:"ui-page",children:[n.jsx(Md,{title:"Agents",lede:`Your team. Each one is a file on ${f} — what it can reach is listed on its page.`,actions:w?n.jsx(Yt,{variant:"accent",href:Ke(w.id),onClick:c(Ke(w.id)),children:"Add an agent"}):null}),n.jsx(Ao,{children:dB.map(b=>n.jsx(Ra,{href:b.id==="team"?ut:`${ut}?tab=${b.id}`,active:o===b.id,count:b.id==="offers"?p:void 0,onClick:c(b.id==="team"?ut:`${ut}?tab=${b.id}`),children:b.label},b.id))}),o==="missions"?n.jsx(aC,{timezone:t,embedded:!0}):null,o==="offers"?n.jsx(S1,{offers:m.offers,reload:m.reload}):null,o==="offers"?n.jsx(oC,{embedded:!0}):null,o==="reminders"?n.jsx(fC,{timezone:t,embedded:!0}):null,o==="team"&&k?n.jsx(up,{navigate:s,standing:!0}):null,o==="team"?n.jsx(mB,{data:u.data,error:u.error,reload:u.reload}):null,o==="team"?r.length===0?n.jsx(Ut,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):n.jsx("div",{className:"agents-grid",children:gN(r,v).map(b=>{const S=Td(i.get(b.id));return n.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...Eo(Co(b)),"data-unavailable":b.available?void 0:"true",children:[n.jsx("div",{className:"agent-card-top"}),n.jsx("div",{className:"agent-card-face",children:n.jsx(ps,{id:b.id,name:b.name,size:"xl",unavailable:!b.available,face:b})}),n.jsxs("div",{children:[n.jsxs("div",{className:"ui-card-title",children:[n.jsx("a",{className:"agent-card-link",href:dt(b.id,"conversations"),onClick:c(dt(b.id,"conversations")),children:b.name}),n.jsxs("span",{className:"agent-card-handle mono faint",children:["@",b.handle]})]}),n.jsx("p",{className:"ui-card-meta agent-card-desc",children:b.description})]}),n.jsxs("div",{className:"ui-row",children:[b.id===v?n.jsx(fi,{children:"front desk"}):null,S?n.jsx(xe,{tone:"critical",dot:!0,children:"waiting for you"}):b.available?n.jsx(xe,{tone:"good",dot:!0,children:"ready"}):n.jsx(xe,{tone:"warning",children:Ms(b.unavailableReason??"cannot run",60)}),n.jsx(xe,{mono:!0,children:b.model}),n.jsx(Yt,{className:"agent-card-talk",size:"sm",href:Ke(b.id),onClick:c(Ke(b.id)),"aria-label":`Talk to ${b.name}`,children:"Talk"})]})]},b.id)})}):null,o==="team"&&!k?n.jsx(up,{navigate:s,standing:!0}):null,l?n.jsx(Dt,{title:((N=r.find(b=>b.id===l.agentId))==null?void 0:N.name)??l.agentId,size:"wide",onClose:()=>s(ut),children:n.jsx(pB,{agentId:l.agentId,agent:r.find(b=>b.id===l.agentId),agents:r,tab:l.tab??"conversations",...l.section?{section:l.section}:{},timezone:t,navigate:s,attention:i})}):null]})}function mB({data:e,error:t,reload:s}){const r=e==null?void 0:e.default,[i,a]=h.useState(null),[l,o]=h.useState(!1),[c,u]=h.useState(null),[f,d]=h.useState(null);if(t)return n.jsx(ne,{message:t});if(!r||r.choices.length===0)return null;const m=r.defaultAgentId,p=i??m??"",v=p!==""&&p!==m,w=r.problem,k=x=>x.map(y=>{var j;return((j=r.choices.find(N=>N.id===y))==null?void 0:j.name)??y}).join(" and "),g=async()=>{o(!0),u(null),d(null);try{const x=await A.setDefaultAgent(p);d(x.note),a(null),s()}catch(x){u(x instanceof Error?x.message:String(x))}finally{o(!1)}};return n.jsx(Ze,{children:n.jsxs("div",{className:"ui-stack",children:[n.jsx(ne,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?n.jsx(H,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${k(w.agents)}. The one chosen here wins.`}):(w==null?void 0:w.code)==="no-default-agent"?n.jsx(H,{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,f?n.jsx(H,{tone:"good",role:"status",children:f}):null,n.jsxs(Q,{children:[n.jsxs("div",{className:"default-agent-text",children:[n.jsx("h3",{className:"default-agent-title",children:"Default agent"}),n.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsxs("select",{"aria-label":"Default agent",value:p,disabled:l,onChange:x=>a(x.target.value),children:[p===""?n.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(x=>n.jsxs("option",{value:x.id,disabled:!x.available,children:[x.name," @",x.handle,x.available?"":" (cannot run)"]},x.id))]}),n.jsx(I,{variant:"accent",disabled:l||!v,onClick:()=>void g(),children:"Save"})]})]})})}function pB({agentId:e,agent:t,agents:s,tab:r,section:i,timezone:a,navigate:l,attention:o}){const c=d=>m=>{m.preventDefault(),l(d)},u=Td(o.get(e)),f=(t==null?void 0:t.name)??e;return n.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[n.jsxs("header",{className:"agent-head",children:[n.jsx(ps,{id:e,name:f,size:"xl",unavailable:t?!t.available:!1,face:t}),n.jsxs("div",{className:"agent-head-text",children:[n.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),n.jsxs("div",{className:"ui-row",children:[t?n.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?n.jsx("span",{className:"muted",children:t.model}):null,u?n.jsx(xe,{tone:"critical",children:u}):t&&!t.available?n.jsx(xe,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),n.jsx("div",{className:"ui-page-actions",children:n.jsxs(Yt,{variant:"accent",href:Ke(e),onClick:c(Ke(e)),children:["Talk to ",f]})})]}),t&&!t.available?n.jsxs(H,{tone:"warning",role:"status",children:[jN(t)," ",n.jsx("a",{href:tt(Im(t).section),children:Im(t).label})]}):null,n.jsx(Ao,{children:hB.map(d=>n.jsx(Ra,{href:dt(e,d.id),active:r===d.id,onClick:c(dt(e,d.id)),children:d.label},d.id))}),r==="conversations"?n.jsx(gB,{agentId:e,navigate:l}):null,r==="missions"?n.jsx(aC,{timezone:a,embedded:!0,agentId:e}):null,r==="offers"?n.jsx(oC,{embedded:!0,agentId:e,agentName:f}):null,r==="reminders"?n.jsx(fC,{timezone:a,embedded:!0,agentId:e}):null,r==="memory"?n.jsx(uC,{embedded:!0,agents:s,timezone:a,agentId:e}):null,r==="skills"?n.jsx(WU,{agentId:e,agentName:f}):null,r==="setup"?n.jsx(ZU,{agentId:e,section:i,navigate:l}):null]})}function gB({agentId:e,navigate:t}){const{data:s,error:r}=ie(()=>Le.conversations(e,50),[e]);if(r)return n.jsx(oe,{children:r});const i=(s==null?void 0:s.conversations)??[];return n.jsx(Ze,{flush:!0,children:s?i.length===0?n.jsx(Ut,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):n.jsx(Ct,{children:i.map(a=>n.jsx(Et,{href:Ke(e,a.id),onClick:()=>t(Ke(e,a.id)),title:Ms(a.preview||a.opening||"Untitled conversation",90),sub:`${a.messageCount} message${a.messageCount===1?"":"s"}`,side:Oe(a.lastMessageAt??a.startedAt??a.createdAt??null)},a.id))}):n.jsx(oe,{children:"Loading…"})})}const ww=3,xB=40;function vB({agent:e,navigate:t}){var v;const s=h.useRef(null),[r,i]=h.useState(!1),[a,l]=h.useState(null),[o,c]=h.useState(null),u=ie(()=>Le.conversations(e.id,ww),[e.id],3e4),f=Ia(Ax),d=Ia("(pointer: coarse)");h.useEffect(()=>{var w;!f&&!d&&((w=s.current)==null||w.focus())},[]);const m=(w,k)=>{i(!0),l(null),(async()=>{try{const{conversationId:g}=await Le.startConversation(e.id),x=await Le.send(e.id,{conversationId:g,text:w,...k.length>0?{attachmentIds:k.map(y=>y.artifactId)}:{}});t(Ke(e.id,x.conversationId))}catch(g){l(g instanceof he?g.message:String(g)),c({text:w,at:Date.now()}),i(!1)}})()},p=(((v=u.data)==null?void 0:v.conversations)??[]).slice(0,ww);return n.jsxs("div",{className:"home-ask",children:[a?n.jsx(ne,{message:a}):null,n.jsx(yx,{ref:s,disabled:r||!e.available,running:!1,onSend:m,onStop:()=>{},agentName:e.name,placeholder:`Message ${e.name}…`,draft:o,threadKey:`home.${e.id}`}),p.length>0?n.jsxs("div",{className:"home-continue",children:[n.jsx("span",{className:"home-continue-label",id:`home-continue-${e.id}`,children:"Continue"}),n.jsx("ul",{className:"home-continue-chips","aria-labelledby":`home-continue-${e.id}`,children:p.map(w=>{const k=Ke(e.id,w.id),g=w.opening??w.preview??"Untitled conversation",x=Y$(w.lastMessageAt??w.createdAt??w.startedAt??null);return n.jsx("li",{children:n.jsxs("a",{className:"home-continue-chip",href:k,title:g,onClick:y=>{y.preventDefault(),t(k)},children:[n.jsx("span",{className:"home-continue-title",children:Ms(g,xB)}),x?n.jsx("span",{className:"home-continue-when",children:x}):null]})},w.id)})})]}):null]})}const jC="buddi.keepClose";let Pl=null;const hp=new Set;function bw(){for(const e of hp)e()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),Pl=e,bw()}),window.addEventListener("appinstalled",()=>{Pl=null,yC(),bw()}));function kw(){try{return window.localStorage.getItem(jC)!==null}catch{return!1}}function yC(){try{window.localStorage.setItem(jC,"dismissed")}catch{}}function jB(){var e;try{return((e=window.matchMedia)==null?void 0:e.call(window,"(display-mode: standalone)").matches)??!1}catch{return!1}}function yB(e=window.location.hostname){const t=e.replace(/^\[|\]$/g,"").toLowerCase();return t==="127.0.0.1"||t==="::1"||t==="localhost"}function wB(e){return/Edg\//.test(e)?"In Edge, choose Apps → Install buddi from the … menu.":/(Chrome|CriOS)\//.test(e)?"In Chrome, click the install icon in the address bar.":/Safari\//.test(e)&&/Mac/.test(e)?"In Safari, choose File → Add to Dock.":null}function bB(e){return/Mac|iPhone|iPad/.test(e)}function kB(){const[e,t]=h.useState(()=>kw()||jB()),[s,r]=h.useState(Pl),[i,a]=h.useState(void 0);if(h.useEffect(()=>{const d=()=>{r(Pl),kw()&&t(!0)};return hp.add(d),()=>{hp.delete(d)}},[]),h.useEffect(()=>{if(e)return;let d=!0;return A.session().then(m=>{d&&a(m.platform)},()=>{}),()=>{d=!1}},[e]),e)return null;const l=typeof navigator>"u"?"":navigator.userAgent,o=yB(),c=s?null:wB(l),u=()=>{yC(),t(!0)},f=()=>{const d=s;d&&d.prompt().then(async()=>{const m=await d.userChoice;Pl=null,r(null),(m==null?void 0:m.outcome)==="accepted"&&u()},()=>{})};return n.jsxs(H,{tone:"accent",title:"Keep buddi one click away.",children:[n.jsxs("p",{children:[c?`${c} `:null,"Or bookmark it with ",bB(l)?"⌘D":"Ctrl+D",".",o?null:" This tailnet address installs as its own app, separate from the one on the machine buddi runs on."]}),o&&i==="darwin"?n.jsxs("p",{children:["On this Mac, ",n.jsx("span",{className:"mono",children:"buddi dashboard --install-app"})," puts a double-clickable app in ~/Applications (docs/cli.md, under Everyday)."]}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",onClick:u,children:"Not now"}),s?n.jsx(I,{variant:"accent",onClick:f,children:"Install app"}):null]})]})}function SB(e){const t=e.indexOf("?");if(t===-1)return;const s=new URLSearchParams(e.slice(t+1)).get("tip");return s&&/^[a-z0-9-]{1,40}$/.test(s)?s:void 0}function NB({navigate:e,preview:t,hidden:s}){var c;const r=ie(()=>A.currentTip(t),[t]),[i,a]=h.useState(null),l=((c=r.data)==null?void 0:c.tip)??null;if(!l||i===l.id||s)return null;const o=u=>{a(l.id),!t&&(u==="dismiss"?A.dismissTip(l.id):A.laterTip(l.id)).catch(()=>{})};return n.jsx("div",{className:"home-tip","data-tip":l.id,children:n.jsxs(H,{children:[n.jsxs("div",{className:"ui-notice-row",children:[n.jsx("p",{className:"ui-notice-body",children:l.text}),n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"Not now",title:"Not now",onClick:()=>o("later"),children:n.jsx(Se,{name:"close"})})]}),n.jsxs(Q,{children:[n.jsx(sn,{}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>o("dismiss"),children:"Not this again"}),n.jsx(I,{variant:"accent",size:"sm",onClick:()=>e(l.action.route),children:l.action.label})]})]})})}const fp="buddi.tipsOpen";function CB(e){const t=new Date(`${e}T12:00:00Z`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}).format(t)}function EB(e){switch(e.status){case"today":return"Due today";case"holding":return"Waiting";case"quiet":return"Not needed now";case"dismissed":return"Dismissed";case"shown":return e.shownAt?`Shown on ${CB(e.shownAt)}`:"Shown"}}function AB(){try{return window.localStorage.getItem(fp)==="1"}catch{return!1}}function TB(){const e=ie(()=>A.tips(),[]),[t,s]=h.useState(AB),r=h.useCallback(i=>{s(i);try{i?window.localStorage.setItem(fp,"1"):window.localStorage.removeItem(fp)}catch{}},[]);return{open:t,setOpen:r,list:e}}function RB({tips:e}){const{open:t,setOpen:s,list:r}=e,i=!!r.data&&!r.data.enabled&&r.data.tips.some(a=>a.status==="today");return n.jsxs("button",{type:"button",className:"ui-icon-btn home-tips-btn","aria-label":i?"Tips, one due today":"Tips","aria-pressed":t,title:"Tips","data-open":t,onClick:()=>{t||r.reload(),s(!t)},children:[n.jsx(Se,{name:"bulb"}),i?n.jsx("span",{className:"home-tips-dot","data-testid":"tips-dot"}):null]})}function IB({tips:e,navigate:t}){var k,g;const{open:s,setOpen:r,list:i}=e,[a,l]=h.useState(null),[o,c]=h.useState(null),[u,f]=h.useState(null);if(!s)return null;const d=((k=i.data)==null?void 0:k.tips)??null,m=u??((g=i.data)==null?void 0:g.enabled)??!0,p=x=>l(x instanceof he?x.message:String(x)),v=x=>{c(x),l(null),A.restoreTip(x).then(()=>i.reload(),p).finally(()=>c(null))},w=x=>{c("switch"),l(null),f(x),A.saveTipsSettings(x).then(y=>{f(y.enabled),i.reload()}).catch(y=>{f(!x),p(y)}).finally(()=>c(null))};return n.jsx("div",{className:"home-tips","data-testid":"tips-section",children:n.jsxs(J,{title:"Tips",children:[n.jsx(ne,{message:i.error??a}),n.jsx("div",{className:"tips-grid",children:(d??[]).map(x=>n.jsx("div",{className:"tips-card","data-tip":x.id,"data-status":x.status,children:n.jsxs(On,{tone:x.status==="today"?"accent":void 0,children:[n.jsx("div",{children:n.jsx(xe,{tone:x.status==="today"?"accent":"muted",children:EB(x)})}),n.jsx("p",{className:"tips-card-text",children:x.text}),n.jsxs(Q,{children:[n.jsx(sn,{}),x.status==="dismissed"?n.jsx(I,{size:"sm",disabled:o===x.id,onClick:()=>v(x.id),children:"Bring back"}):n.jsx(I,{size:"sm",variant:x.status==="today"?"accent":void 0,onClick:()=>t(x.action.route),children:x.action.label})]})]})},x.id))}),n.jsxs(Q,{children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:m,disabled:o==="switch"||d===null,onChange:x=>w(x.target.checked)}),n.jsx("span",{children:"Tips on Home"})]}),n.jsx(sn,{}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Close"})]})]})})}const PB=3;function MB(e,t=new Set){return(e??[]).filter(s=>!s.hidden&&!t.has(s.id)).slice(0,PB)}function $B({glances:e,navigate:t,onChanged:s}){const[r,i]=h.useState(new Set),a=MB(e,r);if(a.length===0)return null;const l=o=>{i(c=>new Set(c).add(o.id)),A.setGlanceHidden(o.id,!0).then(()=>s==null?void 0:s(),()=>{i(c=>{const u=new Set(c);return u.delete(o.id),u})})};return n.jsx("span",{className:"home-glances",children:a.map(o=>{const c=o.link?e1(o.link.plugin,o.link.page,o.link.place):null,u=n.jsxs(n.Fragment,{children:[n.jsx(Se,{name:Od(o.icon),size:14}),n.jsx("span",{children:o.text})]});return n.jsxs("span",{className:"home-glance",children:[n.jsx("span",{className:"home-glance-sep","aria-hidden":"true",children:"·"}),c?n.jsx("a",{className:"home-glance-text",href:c,onClick:f=>{f.preventDefault(),t(c)},children:u}):n.jsx("span",{className:"home-glance-text",children:u}),n.jsx("button",{type:"button",className:"home-glance-hide","aria-label":`Hide ${o.title} from Home`,title:"Hide from Home",onClick:()=>l(o),children:n.jsx(Se,{name:"close",size:10})})]},o.id)})})}const wC="buddi.needsYouView";function DB(){try{return window.localStorage.getItem(wC)==="list"?"list":"deck"}catch{return"deck"}}function OB(e){try{window.localStorage.setItem(wC,e)}catch{}}function _B(e,t,s){const r=(t.alsoFrom??[]).filter(i=>i!==t.agentId).map(s);return r.length===0?e:`${e} · also ${r.join(", ")}`}function LB({rows:e,agents:t,label:s,onOpen:r,onDone:i}){const[a,l]=h.useState(0);if(e.length===0)return n.jsx(oe,{mascot:!0,children:"Nothing needs you. Your agents are on it."});const o=Math.min(a,e.length-1),c=e[o],u=e.length>1,f=w=>l((o+w+e.length)%e.length),d=()=>r(c),m=()=>i(c),p=w=>{const k=w.target;k.closest('input, textarea, select, [contenteditable="true"]')||(w.key==="ArrowRight"&&u?(w.preventDefault(),f(1)):w.key==="ArrowLeft"&&u?(w.preventDefault(),f(-1)):w.key==="Enter"&&!k.closest("button, a")?(w.preventDefault(),c.link&&d()):(w.key==="d"||w.key==="Delete")&&!w.metaKey&&!w.ctrlKey&&!w.altKey&&(w.preventDefault(),m()))},v=n.jsxs("span",{className:"home-deck-from",children:[c.agentId?n.jsx(vn,{agents:t,id:c.agentId,size:"sm"}):null,n.jsx("span",{children:s(c)})]});return n.jsx("div",{className:"home-deck","data-depth":Math.min(e.length-1,2),role:"region","aria-label":"Needs you, one at a time","aria-roledescription":"deck",tabIndex:0,onKeyDown:p,children:n.jsx(On,{as:"article",title:v,meta:n.jsx("span",{className:"ui-card-meta",children:c.state==="held"?"today":Oe(c.createdAt)}),actions:n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"home-deck-count","aria-live":"polite",children:[o+1," of ",e.length]}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":"Previous",disabled:!u,onClick:()=>f(-1),children:n.jsx(Se,{name:"chevron-left"})}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":"Next",disabled:!u,onClick:()=>f(1),children:n.jsx(Se,{name:"chevron-right"})})]}),foot:n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:m,children:"Done"}),c.link?n.jsx(I,{variant:"accent",onClick:d,children:"Open"}):null]}),children:n.jsxs("div",{className:"home-deck-body",children:[n.jsx("p",{className:"home-deck-title",children:c.title}),c.text?n.jsx("p",{className:"home-deck-text",children:c.text}):null]})})})}function FB({timezone:e,navigate:t,agents:s,defaultAgentId:r,attention:i,update:a,connectionSignals:l=[],hash:o=""}){var Ee,qe,Ie,et,z,se,Ae,Me,ot,Ne,_e,Te,pt;const c=ie(()=>A.overview(),[],15e3),u=ie(()=>A.approvals(),[],1e4),f=ie(()=>A.missions(),[],6e4),d=ie(()=>A.reminders(),[],6e4),m=ie(()=>A.conversations(),[],3e4),p=ie(()=>A.offers(),[],3e4),v=ie(()=>A.proposals(),[],6e4),w=ie(()=>A.agentOffers(),[],6e4),k=ie(()=>A.owner(),[]),g=ie(()=>A.notifications(20),[],3e4),x=h.useMemo(()=>gN(s,r??null),[s,r]),{busy:y,note:j,failure:N,decide:b}=wx(()=>{u.reload(),c.reload()}),S=c.data,C=s.find(O=>O.id===r)??null,R=O=>{var ve;return((ve=s.find(Xe=>Xe.id===O))==null?void 0:ve.name)??O},E=O=>ve=>{ve.preventDefault(),t(O)},P=((Ee=u.data)==null?void 0:Ee.pending)??[],F=((qe=S==null?void 0:S.jobs)==null?void 0:qe.failed)??0,M=((Ie=S==null?void 0:S.sentinels)==null?void 0:Ie.openUrgent)??0,T=((et=v.data)==null?void 0:et.open.length)??0,$=(((z=w.data)==null?void 0:z.offers)??[]).filter(O=>!P.some(ve=>b1(ve,O.plugin,O.agent))),_=zB(((se=g.data)==null?void 0:se.notifications)??[],P),[K,D]=h.useState(new Set),[Y,B]=h.useState(DB),V=_.filter(O=>!K.has(O.id)),de=O=>{D(ve=>new Set(ve).add(O.id)),A.notificationSeen(O.id).catch(()=>{})},ae=O=>{de(O),O.link&&t(O.link)},le=O=>_B(O.agentId?R(O.agentId):O.pluginId??BB[O.kind],O,R),Ce=P.length+(F>0?1:0)+(M>0?1:0)+(S!=null&&S.paused?1:0)+(T>0?1:0)+$.length+_.length,ee=h.useMemo(()=>{var O,ve;return KB(((O=f.data)==null?void 0:O.missions)??[],((ve=d.data)==null?void 0:ve.reminders)??[])},[f.data,d.data]),ce=(((Ae=m.data)==null?void 0:Ae.conversations)??[]).slice(0,5),fe=((Me=p.data)==null?void 0:Me.offers)??[],je=fe.slice(0,WB),X=TB(),be=fe.length-je.length;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"home-band",children:n.jsxs("header",{className:"home-hero",children:[n.jsxs("div",{className:"home-hero-text",children:[n.jsxs("p",{className:"home-date",children:[n.jsx("span",{children:qB(S==null?void 0:S.now,e)}),n.jsx($B,{glances:S==null?void 0:S.glances,navigate:t,onChanged:()=>c.reload()})]}),n.jsx("h1",{className:"home-greeting",children:YB(S==null?void 0:S.now,e,((ot=k.data)==null?void 0:ot.preferredName)||((Ne=k.data)==null?void 0:Ne.displayName))}),n.jsx("p",{className:"home-lede",children:JB(Ce,P.length,F,M,(S==null?void 0:S.paused)??!1,T,$.length,_.length)})]}),n.jsxs("div",{className:"home-hero-side",children:[n.jsx(RB,{tips:X}),n.jsx(NN,{size:"lg",anim:"idle"})]})]})}),n.jsxs("div",{className:"home",children:[n.jsx(IB,{tips:X,navigate:t}),C?n.jsx(vB,{agent:C,navigate:t},C.id):null,n.jsx(kB,{}),n.jsx(NB,{navigate:t,preview:SB(o),hidden:X.open}),a&&a.updateAvailable&&!a.checkout&&a.latest?n.jsx(H,{tone:"accent",children:n.jsxs("p",{children:["A newer buddi is ready: ",n.jsx("span",{className:"mono",children:a.latest}),"."," ",n.jsx("a",{href:tt("system"),onClick:E(tt("system")),children:"Upgrade from Settings → Version."})]})}):null,l.map(O=>n.jsx(H,{tone:"accent",children:n.jsxs("p",{children:[O.sentence," ",n.jsx("a",{href:tt("connections"),onClick:E(tt("connections")),children:"Settings → Connections."})]})},O.id)),n.jsx(ne,{message:c.error??u.error??N}),j?n.jsx(H,{tone:"good",role:"status",children:j}):null,Ce>0?n.jsx(J,{title:"Needs you",actions:_.length>0?n.jsx(Ys,{label:"Show what needs you as",options:[{value:"list",label:"List"},{value:"deck",label:"Deck"}],value:Y,onChange:O=>{B(O),OB(O)}}):void 0,children:n.jsxs(q,{children:[S!=null&&S.paused?n.jsxs(H,{tone:"warning",title:"The installation is paused.",children:["Nothing is being claimed until you resume it."," ",n.jsx(I,{size:"sm",onClick:()=>{A.setPaused(!1).then(()=>c.reload())},children:"Resume"})]}):null,P.map(O=>n.jsx(bx,{action:O,timezone:e,busy:y===O.id,onDecide:b,agentName:R(O.agentId)},O.id)),_.length>0&&Y==="deck"?n.jsx(LB,{rows:V,agents:s,label:le,onOpen:ae,onDone:de}):null,_.length>0&&Y==="list"?n.jsx(Ze,{flush:!0,children:n.jsx(Ct,{children:V.map(O=>n.jsx(Et,{href:O.link??void 0,onClick:()=>ae(O),lead:O.agentId?n.jsx(vn,{agents:s,id:O.agentId,size:"sm"}):void 0,title:O.title,sub:le(O),side:O.state==="held"?"today":Oe(O.createdAt)},O.id))})}):null,F>0?n.jsx(H,{tone:"critical",children:n.jsxs("a",{href:`${jt}/jobs?state=failed`,onClick:E(`${jt}/jobs?state=failed`),children:[F," failed job",F===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,M>0?n.jsx(H,{tone:"critical",children:n.jsxs("a",{href:`${jt}/alerts`,onClick:E(`${jt}/alerts`),children:[M," urgent alert",M===1?"":"s"," from your watchers."]})}):null,$.map(O=>n.jsx(Ze,{children:n.jsx(Sx,{plugin:O.plugin,agent:O.agent,text:O.text,label:`Create @${O.handle}`,handle:O.handle,onDismiss:()=>{A.dismissAgentOffer(O.plugin,O.agent).then(()=>w.reload())}})},`${O.plugin}/${O.agent}`)),T>0?n.jsx(H,{tone:"accent",children:n.jsxs("a",{href:tt("proposals"),onClick:E(tt("proposals")),children:[T," proposal",T===1?"":"s"," from your agents to keep or discard."]})}):null,(((_e=S==null?void 0:S.sentinels)==null?void 0:_e.errors)??[]).map(O=>n.jsxs(H,{tone:"warning",children:["Watcher ",O.sentinelId," failed: ",O.error]},O.sentinelId)),((S==null?void 0:S.mail)??[]).filter(O=>O.lastError).map(O=>n.jsxs(H,{tone:"warning",children:["Source ",O.sourceId,": ",O.lastError]},O.sourceId))]})}):null,n.jsx(J,{title:"Your team",aside:n.jsx("a",{href:ut,onClick:E(ut),children:"All agents"}),children:s.length===0?n.jsx(oe,{mascot:!0,children:"No agents yet. Add one under Agents."}):n.jsx("div",{className:"home-team",children:x.map(O=>{const ve=Td(i.get(O.id));return n.jsxs("a",{className:"home-face",...Eo(Co(O)),href:Ke(O.id),onClick:E(Ke(O.id)),"data-waiting":ve?"true":void 0,"data-unavailable":O.available?void 0:"true",children:[n.jsx(ps,{id:O.id,name:O.name,size:"lg",unavailable:!O.available,face:O}),n.jsxs("span",{className:"home-face-text",children:[n.jsx("span",{className:"home-face-name",children:O.name}),n.jsx("span",{className:"home-face-status",children:ve?bC(ve):O.available?Ms(O.description,60):O.unavailableReason??"Cannot run right now."})]})]},O.id)})})}),cC(s,r)?n.jsx(up,{navigate:t}):null,je.length>0?n.jsx(J,{title:"On offer",aside:n.jsxs("span",{className:"ui-row",children:[be>0?n.jsxs("a",{href:`${ut}?tab=offers`,onClick:E(`${ut}?tab=offers`),children:[be," more"]}):null,n.jsx(lC,{ids:fe.map(O=>O.id),onDone:()=>p.reload()})]}),children:n.jsx("div",{className:"home-offers",children:je.map(O=>n.jsx(VB,{offer:O,agents:s,open:E(dt(O.agentId,"offers")),onDismissed:()=>p.reload()},O.id))})}):null,(pt=(Te=v.data)==null?void 0:Te.digest)!=null&&pt.latest?n.jsx(QB,{digest:v.data.digest.latest,go:E}):null,n.jsxs("div",{className:"home-columns",children:[n.jsx(J,{title:"Coming up",aside:n.jsx("a",{href:`${ut}?tab=missions`,onClick:E(`${ut}?tab=missions`),children:"All missions"}),children:n.jsx(Ze,{flush:!0,children:ee.length===0?n.jsx(oe,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):n.jsx(Ct,{children:ee.map(O=>n.jsx(Et,{href:O.route,onClick:()=>t(O.route),lead:n.jsx(vn,{agents:s,id:O.agentId,size:"sm"}),title:O.title,sub:`${O.kind} for ${R(O.agentId)}`,side:Oe(O.at)},O.key))})})}),n.jsx(J,{title:"Lately",aside:n.jsx("a",{href:jt,onClick:E(jt),children:"All activity"}),children:n.jsx(Ze,{flush:!0,children:ce.length===0?n.jsx(oe,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):n.jsx(Ct,{children:ce.map(O=>n.jsx(Et,{href:Ke(O.agentId,O.id),onClick:()=>t(Ke(O.agentId,O.id)),lead:n.jsx(vn,{agents:s,id:O.agentId,size:"sm"}),title:O.opening?Ms(O.opening,80):"Untitled conversation",sub:`${R(O.agentId)}, ${O.messageCount} message${O.messageCount===1?"":"s"}`,side:Oe(O.lastMessageAt??O.createdAt)},O.id))})})})]}),((S==null?void 0:S.home)??[]).map(O=>n.jsx(XB,{block:O},O.id)),S!=null&&S.jobs&&S.missions?n.jsxs("p",{className:"home-foot muted",children:[Pt(S.jobs.pending??0)," queued, ",Pt(S.jobs.leased??0)," running, ",Pt(S.missions.enabled)," of ",Pt(S.missions.total)," missions on."," ",S.paused?n.jsx(xe,{tone:"warning",children:"paused"}):n.jsx(xe,{tone:"good",children:"running"})," ",n.jsx("a",{href:Ta("").replace(/\/conversations\/$/,""),onClick:E(jt),children:"Activity"})," · ",n.jsx("a",{href:tt("system"),onClick:E(tt("system")),children:"System"})]}):null]})]})}const UB=new Set(["watcher","reminder","failure","recap","plugin"]),BB={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin"};function zB(e,t){const s=new Set(t.map(r=>r.id));return e.filter(r=>UB.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&s.has(r.actionId)))}const WB=6,HB=500;function VB({offer:e,agents:t,open:s,onDismissed:r}){const[i,a]=h.useState(!1),l=h.useRef(null),o=h.useRef(!1),c=()=>{i||(a(!0),A.dismissOffer(e.id).then(r).finally(()=>a(!1)))},u=()=>{l.current!==null&&clearTimeout(l.current),l.current=null};return n.jsxs("span",{className:"home-offer-chip",children:[n.jsxs("a",{className:"home-offer",href:dt(e.agentId,"offers"),onClick:f=>{if(o.current){o.current=!1,f.preventDefault();return}s(f)},title:e.prompt,onTouchStart:()=>{o.current=!1,u(),l.current=setTimeout(()=>{o.current=!0,c()},HB)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[n.jsx(vn,{agents:t,id:e.agentId,size:"sm"}),n.jsx("span",{children:e.label})]}),n.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function KB(e,t){const s=[];for(const r of e)r.enabled&&r.nextRun&&s.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:dt(r.agentId,"missions")});for(const r of t)r.state==="pending"&&s.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:dt(r.agentId,"reminders")});return s.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function GB(e,t){try{const s=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(s)}catch{return new Date().getHours()}}function YB(e,t,s){const r=GB(e,t),i=s!=null&&s.trim()?`, ${s.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function qB(e,t){try{const s=e?new Date(e):new Date,r=new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:t}).format(s),i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",timeZone:t}).format(s);return`${r}, ${i}`}catch{return Ve(e??null,t)}}function Sc(e,t,s){return e.count===0?null:`${e.count} ${e.count===1?t:s}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function QB({digest:e,go:t}){const s=[Sc(e.memory,"memory note","memory notes"),Sc(e.skills,"skill kept","skills kept"),Sc(e.rules,"rule kept","rules kept"),Sc(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,a])=>`${i} ${a}`).join(", ")}).`:"No rule you kept acted this week.";return n.jsx(J,{title:"What buddi learned this week",aside:n.jsx("span",{className:"muted",children:Oe(e.at)}),children:n.jsx(Ze,{children:n.jsxs(q,{divided:!0,children:[n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Learned"}),s.length===0?n.jsx("p",{children:"Nothing new."}):n.jsx("ul",{className:"home-digest-list",children:s.map(i=>n.jsx("li",{children:i},i))})]}),n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Proposes"}),n.jsx("p",{children:e.open>0?n.jsxs("a",{href:tt("proposals"),onClick:t(tt("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),n.jsx("p",{children:r})]})]})})})}function JB(e,t,s,r,i,a=0,l=0,o=0){if(e===0)return"Nothing needs you. Your agents are on it.";const c=[];t>0&&c.push(`${t} approval${t===1?"":"s"} waiting`),s>0&&c.push(`${s} failed job${s===1?"":"s"}`),r>0&&c.push(`${r} urgent alert${r===1?"":"s"}`),i&&c.push("the installation is paused"),a>0&&c.push(`${a} proposal${a===1?"":"s"} to review`),l>0&&c.push(`${l===1?"an agent":`${l} agents`} to set up`),o>0&&c.push(`${o} message${o===1?"":"s"} for you`);const u=c.length<=1?c.join(""):`${c.slice(0,-1).join(", ")} and ${c[c.length-1]}`;return`${bC(u)}.`}function bC(e){return e.charAt(0).toUpperCase()+e.slice(1)}function XB({block:e}){const[t,s]=h.useState(!1),r=e.sensitive===!0&&!t;h.useEffect(()=>{if(!e.sensitive||!t)return;const a=()=>{document.visibilityState==="hidden"&&s(!1)};return document.addEventListener("visibilitychange",a),window.addEventListener("blur",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("blur",a)}},[e.sensitive,t]);const i=n.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?n.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?n.jsx(I,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>s(a=>!a),children:r?"Show":"Hide"}):null]});return n.jsxs(J,{title:e.title,aside:i,children:[e.note?n.jsx(H,{tone:"warning",children:e.note}):null,e.stats.length>0?n.jsx($d,{children:e.stats.map(a=>n.jsx(Es,{label:a.label,value:r?"••••":a.value,note:r?void 0:a.note,tone:r?void 0:a.tone},a.label))}):null,e.rows.length>0?r?n.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):n.jsx(Ze,{flush:!0,children:n.jsx(Ct,{children:e.rows.map((a,l)=>n.jsx(Et,{title:a.title,sub:a.sub,side:a.side?n.jsx("span",{className:a.tone==="critical"?"critical":a.tone==="good"?"good":void 0,children:a.side}):void 0},`${a.title}-${l}`))})}):null]})}const ZB=3e4;function kC(){const{data:e,reload:t}=ie(()=>A.recovery(),[],ZB);return{data:e,reload:t}}const ez="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function tz({active:e,onNavigate:t}){return e?n.jsxs("div",{className:"recovery-banner",role:"status",children:[n.jsx("span",{children:ez}),n.jsx("a",{href:uy,onClick:s=>{s.preventDefault(),t(uy)},children:"Finish the checklist"})]}):null}function nz({view:e,onLeft:t}){const{secrets:s,plugins:r,pending:i,grants:a}=e.checklist,[l,o]=h.useState(!0),[c,u]=h.useState([]),[f,d]=h.useState(!1),[m,p]=h.useState(null),[v,w]=h.useState(!1),k=r.filter(j=>!j.installed),g=i.jobs+i.missions+i.approvals+i.telegramChats,x=j=>{u(N=>N.includes(j)?N.filter(b=>b!==j):[...N,j])},y=()=>{d(!0),p(null),A.leaveRecovery({dropPending:l,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(j=>p(j instanceof he?j.message:String(j))).finally(()=>d(!1))};return n.jsx(Ze,{title:"Back from a backup",children:n.jsxs(q,{divided:!0,children:[n.jsxs(J,{children:[n.jsx(Kt,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:n.jsx("span",{className:"mono",children:e.archive??"—"})}]}),n.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."})]}),n.jsx(J,{title:"Keys to paste again",children:s.length===0?n.jsx(oe,{children:"Nothing is missing."}):n.jsx("ul",{className:"recovery-list",children:s.map(j=>n.jsxs("li",{children:[j.settingsRoute?n.jsx("a",{href:j.settingsRoute,children:j.name}):j.name," ",n.jsx("span",{className:"ui-card-meta",children:j.kind})]},`${j.kind}:${j.name}`))})}),n.jsx(J,{title:"Add-ons to install again",children:k.length===0?n.jsx(oe,{children:"Everything the backup named is installed."}):n.jsx("ul",{className:"recovery-list",children:k.map(j=>n.jsxs("li",{children:[n.jsx("span",{className:"mono",children:j.name})," ",j.version," ",n.jsx("span",{className:"ui-card-meta",children:j.source})]},j.name))})}),n.jsx(J,{title:"Work that was waiting",children:g===0?n.jsx(oe,{children:"Nothing was in flight when the backup was taken."}):n.jsxs(q,{gap:"sm",children:[n.jsx(Kt,{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)}]}),n.jsxs("label",{className:"recovery-check",children:[n.jsx("input",{type:"checkbox",checked:l,onChange:j=>o(j.target.checked)}),n.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),n.jsx(J,{title:"Standing permissions",children:a.length===0?n.jsx(oe,{children:"No agent had a standing permission."}):n.jsxs(q,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),n.jsx("ul",{className:"recovery-list",children:a.map(j=>n.jsx("li",{children:n.jsxs("label",{className:"recovery-check",children:[n.jsx("input",{type:"checkbox",checked:c.includes(j.id),onChange:()=>x(j.id),"aria-label":`Keep ${j.tool} for ${j.agent}`}),n.jsxs("span",{children:[n.jsx("span",{className:"mono",children:j.tool})," for ",j.agent," ",n.jsx("span",{className:"ui-card-meta",children:j.scope}),j.description?n.jsxs("span",{className:"ui-card-meta",children:[" — ",j.description]}):null]})]})},j.id))})]})}),n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:m}),v?n.jsx(H,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):n.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:f||v,onClick:y,children:"Leave recovery mode"})})]})})]})})}const sz=2e3,rz={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 Sw(e){return rz[e.phase]??e.detail??e.phase}const iz=new Set(["done","failed","rolled-back"]);function SC(e){return e!==void 0&&(iz.has(e.phase)||!!e.finishedAt)}function az(e){const[t,s]=h.useState(void 0),[r,i]=h.useState(!1),[a,l]=h.useState(null),o=h.useRef(!1);return h.useEffect(()=>{if(!e){s(void 0),i(!1),o.current=!1;return}let c=!1;const u=()=>{A.backupJob(e).then(d=>{if(!c){if(o.current){window.location.reload();return}s(d),l(null),SC(d)&&(c=!0)}}).catch(d=>{if(!c){if(d instanceof he&&d.status!==0&&d.status<500){l(d.message);return}o.current=!0,i(!0)}})};u();const f=window.setInterval(u,sz);return()=>{c=!0,window.clearInterval(f)}},[e]),{job:t,away:r,error:a}}function lz({job:e,away:t,error:s}){return s?n.jsx(ne,{message:s}):t?n.jsx(H,{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"?n.jsxs(H,{tone:"critical",role:"alert",children:[Sw(e)," ",e.error??""]}):n.jsxs(H,{tone:e.phase==="done"?"good":void 0,role:"status",children:[Sw(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function oz(){var k,g,x,y,j,N,b;const e=ie(()=>A.backups(),[],3e4),t=kC(),s=ie(()=>A.service(),[]),[r,i]=h.useState(null),a=az(r),[l,o]=h.useState(null),[c,u]=h.useState(!1),[f,d]=h.useState(null),m=((k=e.data)==null?void 0:k.supervised)??((g=s.data)==null?void 0:g.supervised),p=f!==null||m===!1,v=((x=e.data)==null?void 0:x.archives)??[],w=S=>{u(!0),o(null),S.then(C=>{var R;return i(((R=C.job)==null?void 0:R.id)??null)}).catch(C=>{C instanceof he&&C.status===409?d(C.message):o(C instanceof he?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return h.useEffect(()=>{SC(a.job)&&e.reload()},[(y=a.job)==null?void 0:y.phase]),n.jsxs(q,{gap:"lg",children:[(j=t.data)!=null&&j.active?n.jsx(nz,{view:t.data,onLeft:t.reload}):null,n.jsx(ne,{message:e.error??l}),n.jsx(lz,{...a}),n.jsx(uz,{onSaved:()=>e.reload()}),n.jsx(J,{title:"Backups",panel:!0,actions:n.jsx(I,{variant:"accent",size:"sm",disabled:c,onClick:()=>w(A.startBackup(!0)),children:"Back up now"}),children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{children:n.jsxs("p",{className:"ui-card-meta",children:["Kept in ",n.jsx("span",{className:"mono",children:((N=e.data)==null?void 0:N.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),n.jsx(J,{children:e.data&&v.length===0?n.jsx(Ut,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?n.jsxs(Nn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Name"}),n.jsx("th",{children:"Taken"}),n.jsx("th",{children:"Size"}),n.jsx("th",{children:"State"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:v.map(S=>{var C;return n.jsx(dz,{archive:S,busy:c,database:(C=e.data)==null?void 0:C.database,checkout:p,onVerify:()=>w(A.verifyArchive(S.name)),onRestore:(R,E)=>w(A.restoreArchive({name:S.name,...R?{passphrase:R}:{},...E?{confirm:E}:{}}))},S.name)})})]}):n.jsx(oe,{children:"Loading…"})})]})}),n.jsx(hz,{}),n.jsx(fz,{busy:c,checkout:p,checkoutSaid:f,database:(b=e.data)==null?void 0:b.database,onRestore:(S,C,R)=>w(A.restoreUpload(S,{passphrase:C,confirm:R}))})]})}const cz={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function uz({onSaved:e}){var p;const t=ie(()=>A.backupSchedule(),[]),[s,r]=h.useState(null),[i,a]=h.useState(!1),[l,o]=h.useState(null),[c,u]=h.useState(!1);h.useEffect(()=>{t.data&&r(t.data)},[t.data]);const f={...cz,...s??t.data??{}};if(((p=t.data)==null?void 0:p.supervised)===!1)return n.jsx(J,{title:"Every night",panel:!0,children:n.jsx(J,{children:n.jsx(H,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const d=v=>{u(!1),r({...f,...v})},m=()=>{a(!0),o(null),A.setBackupSchedule(f).then(v=>{r(v),u(!0),e()}).catch(v=>o(v instanceof he?v.message:String(v))).finally(()=>a(!1))};return n.jsx(J,{title:"Every night",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:i,onClick:m,children:"Save"}),children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:l}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:f.enabled,onChange:v=>d({enabled:v.target.checked})}),n.jsx("span",{children:"Back this buddi up on its own"})]}),n.jsxs(sr,{children:[n.jsx(te,{label:"At",children:n.jsx("input",{type:"time",value:f.time,onChange:v=>d({time:v.target.value})})}),n.jsx(te,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:n.jsx("input",{type:"number",min:1,max:365,value:f.keep,onChange:v=>d({keep:Number(v.target.value)||1})})})]}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:f.encryptLocal,onChange:v=>d({encryptLocal:v.target.checked})}),n.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(te,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:n.jsx("input",{type:"text",value:f.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:v=>d({copyTo:v.target.value===""?null:v.target.value})})}),c?n.jsxs(H,{tone:"good",role:"status",children:["Saved.",f.lastRunAt?` Last run ${Oe(f.lastRunAt)}.`:""]}):null]})})]})})}function dz({archive:e,busy:t,database:s,checkout:r,onVerify:i,onRestore:a}){const[l,o]=h.useState(!1),[c,u]=h.useState(""),[f,d]=h.useState("");return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{children:[n.jsx("td",{className:"mono",children:e.name}),n.jsx("td",{children:Oe(e.createdAt)}),n.jsx("td",{children:Cn(e.bytes)}),n.jsxs("td",{children:[e.encrypted?n.jsx(xe,{tone:"good",children:"locked"}):n.jsx(xe,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?n.jsx(xe,{tone:"critical",children:"damaged"}):null]}),n.jsx("td",{children:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",disabled:t,onClick:i,children:"Verify"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>o(!l),children:"Restore…"})]})})]}),l?n.jsx("tr",{children:n.jsx("td",{colSpan:5,children:r?n.jsx(H,{tone:"warning",children:NC}):n.jsx(CC,{what:`${e.name}, taken ${Oe(e.createdAt)}, ${Cn(e.bytes)}`,database:s,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:f,onConfirm:d,busy:t,onCancel:()=>o(!1),onGo:()=>a(c,f)})})}):null]})}const NC="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function CC({what:e,database:t,needsPassphrase:s,passphrase:r,onPassphrase:i,confirm:a,onConfirm:l,busy:o,onCancel:c,onGo:u}){const f=t??"",d=f===""?a.trim()!=="":a.trim()===f;return n.jsxs(q,{gap:"sm",children:[n.jsxs(H,{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."]}),s?n.jsx(te,{label:"The passphrase this one was locked with",children:n.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:m=>i(m.target.value)})}):null,n.jsx(te,{label:f?`Type ${f} to confirm`:"Type the name of this database to confirm",hint:f?void 0:"The same name buddi shows on the System tab.",children:n.jsx("input",{value:a,onChange:m=>l(m.target.value)})}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",onClick:c,children:"Cancel"}),n.jsx(I,{variant:"danger",disabled:o||!d||s&&r==="",onClick:u,children:"Restore"})]})]})}function hz(){const[e,t]=h.useState(null),[s,r]=h.useState(""),[i,a]=h.useState(!1),[l,o]=h.useState(null),[c,u]=h.useState(!1),f=()=>{a(!0),o(null),A.backupPassphrase().then(m=>t(m.passphrase)).catch(m=>o(m instanceof he?m.message:String(m))).finally(()=>a(!1))},d=()=>{a(!0),o(null),A.setBackupPassphrase(s.trim()).then(m=>{t(m.passphrase),r(""),u(!0)}).catch(m=>o(m instanceof he?m.message:String(m))).finally(()=>a(!1))};return n.jsx(J,{title:"The passphrase",panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:l}),n.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?n.jsx("p",{className:"backup-phrase mono",children:e}):n.jsx(Q,{align:"end",children:n.jsx(I,{disabled:i,onClick:f,children:"Show it"})}),c?n.jsx(H,{tone:"good",role:"status",children:"Saved. Backups made from now on use it; older ones keep the one they were made with."}):null]})}),n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(te,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:n.jsx("input",{type:"text",autoComplete:"off",value:s,onChange:m=>{u(!1),r(m.target.value)}})}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:i||s.trim()==="",onClick:d,children:"Use this one"})})]})})]})})}function fz({busy:e,checkout:t,checkoutSaid:s,database:r,onRestore:i}){const[a,l]=h.useState(null),[o,c]=h.useState(""),[u,f]=h.useState(""),[d,m]=h.useState(!1);return t?n.jsx(J,{title:"Restore from a file",panel:!0,children:n.jsx(J,{children:n.jsx(H,{tone:"warning",children:s??NC})})}):n.jsx(J,{title:"Restore from a file",panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),n.jsxs(sr,{children:[n.jsx(te,{label:"The backup file",children:n.jsx("input",{type:"file",onChange:p=>{var v;m(!1),l(((v=p.target.files)==null?void 0:v[0])??null)}})}),n.jsx(te,{label:"Its passphrase",hint:"Only if it was locked with one.",children:n.jsx("input",{type:"password",autoComplete:"off",value:o,onChange:p=>c(p.target.value)})})]}),d?null:n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:e||!a,onClick:()=>m(!0),children:"Restore"})})]})}),d&&a?n.jsx(J,{children:n.jsx(CC,{what:`${a.name}, ${Cn(a.size)}`,database:r,needsPassphrase:!1,passphrase:o,onPassphrase:c,confirm:u,onConfirm:f,busy:e,onCancel:()=>m(!1),onGo:()=>i(a,o,u)})}):null]})})}const EC="gemini-2.5-pro";function Ld(e){return e.replace(/^models\//,"")}const Ox=/(image|tts|audio|live|embedding|vision|robotics|transcribe)/;function AC(e){const t=e.map(Ld);let s;for(const r of t){const i=/^gemini-(\d+(?:\.\d+)*)-pro(?:-(.+))?$/.exec(r);if(!i||Ox.test(i[2]??""))continue;const a=i[1].split(".").map(Number),l=(i[2]??"")!=="";(!s||Wu(a,s.version)>0||Wu(a,s.version)===0&&s.preview&&!l)&&(s={id:r,version:a,preview:l})}return(s==null?void 0:s.id)??t.find(r=>r.startsWith("gemini-"))}function TC(e){let t;for(const s of e.map(Ld)){const r=/^gemini-(\d+(?:\.\d+)*)-flash(?:-(.+))?$/.exec(s);if(!r||/lite/.test(r[2]??"")||Ox.test(r[2]??""))continue;const i=r[1].split(".").map(Number),a=(r[2]??"")!=="";(!t||Wu(i,t.version)>0||Wu(i,t.version)===0&&t.preview&&!a)&&(t={id:s,version:i,preview:a})}return t==null?void 0:t.id}function RC(e){return/^gemini-[\d.]+-pro(?:-|$)/.test(Ld(e))}function mz(e){return[...new Set(e.map(Ld).filter(t=>t.startsWith("gemini-")&&!Ox.test(t)))]}function IC(e){return e.httpStatus===429||e.state==="rate-limited"||e.state==="quota-exhausted"}function Wu(e,t){for(let s=0;s<Math.max(e.length,t.length);s+=1){const r=(e[s]??0)-(t[s]??0);if(r!==0)return r}return 0}function pz(e,t){if(!t||e.kind!=="openai-compatible")return!1;const s=r=>r.replace(/\/+$/,"");return s(e.baseUrl)===s(t)}function PC({code:e,label:t="Your code"}){const[s,r]=h.useState(!1),i=async()=>{var a;try{await((a=navigator.clipboard)==null?void 0:a.writeText(e)),r(!0)}catch{}};return n.jsxs(Q,{valign:"end",children:[n.jsx(te,{label:t,grow:!0,children:n.jsx("input",{readOnly:!0,value:e,spellCheck:!1,onFocus:a=>a.currentTarget.select()})}),n.jsx(I,{onClick:()=>void i(),children:s?"Copied":"Copy"})]})}function gz({embedded:e}={}){const{data:t,error:s,reload:r,loading:i}=ie(()=>A.providerAccounts(),[]),[a,l]=h.useState(!1),[o,c]=h.useState(null),[u,f]=h.useState(""),[d,m]=h.useState(!1),[p,v]=h.useState(!1),[w,k]=h.useState(null),g=t==null?void 0:t.accounts.some(N=>{var b;return((b=N.login)==null?void 0:b.state)==="pending"&&N.login.expiresAt&&Date.parse(N.login.expiresAt)>Date.now()});h.useEffect(()=>{if(!g)return;const N=setInterval(r,2e3);return()=>clearInterval(N)},[g,r]);const x=async(N,b)=>{l(!0),c(null),f(""),v(!1);try{const S=await N();return f((S==null?void 0:S.warning)??b),r(),!0}catch(S){return c(S instanceof Error?S.message:"Could not apply change."),r(),!1}finally{l(!1)}},y=(t==null?void 0:t.accounts)??[],j=y.find(N=>N.id===w)??y[0];return n.jsxs(mn,{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:[n.jsx(ne,{message:s??o}),u&&n.jsx(H,{tone:"good",role:"status",children:u}),p&&n.jsx(H,{role:"status",children:i?"Refreshing account status…":s?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!t&&!s&&n.jsx(oe,{children:"Loading accounts…"}),s&&n.jsx(Q,{children:n.jsx(I,{onClick:r,children:"Retry"})}),t&&n.jsxs(n.Fragment,{children:[(t.vault.locked||t.vault.kind==="none")&&n.jsx(H,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),d&&n.jsx(Dt,{title:"Add an account",onClose:()=>m(!1),children:n.jsx("div",{id:"new-provider-account",children:n.jsx(kz,{accounts:y,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,gemini:t.gemini,busy:a,run:x,onDone:N=>{m(!1),N&&k(N)}})})}),n.jsx(J,{title:"Accounts",aside:`Secrets live in the ${xz(t.vault.kind)}; Postgres holds names and assignments only.`,actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",size:"sm",disabled:a||i,onClick:()=>{c(null),f(""),v(!0),r()},children:i?"Refreshing…":"Refresh status"}),n.jsx(I,{variant:"accent",size:"sm",disabled:a,"aria-expanded":d,"aria-controls":"new-provider-account",onClick:()=>m(!d),children:"Add account"})]}),panel:!0,flush:!0,children:y.length===0?n.jsx(Ut,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):n.jsxs("div",{className:"accounts",children:[n.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:y.map(N=>n.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(j==null?void 0:j.id)===N.id,onClick:()=>k(N.id),children:[n.jsx(vz,{kind:N.kind,auth:N.auth}),n.jsxs("span",{className:"accounts-row-text",children:[n.jsx("span",{className:"accounts-row-name",children:N.label}),n.jsxs("span",{className:"accounts-row-sub",children:[_x(N)," · ",N.assignedAgents.length===0?"no agents":`${N.assignedAgents.length} agent${N.assignedAgents.length===1?"":"s"}`]})]}),n.jsx($C,{account:N})]},N.id))}),j?n.jsx(yz,{account:j,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:a,run:x},`${j.id}:${j.revision}`):null]})})]})]})}function xz(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function _x(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":e.auth==="device-key"?"Ollama Cloud":"OpenAI-compatible"}function MC(e){return e.detectedContextWindowSource!=="provider"?"assumed":e.kind==="codex"?"from ChatGPT":"from the provider"}function vz({kind:e,auth:t}){const s=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return n.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:s})}function jz(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function $C({account:e}){const t=e.enabled?e.configured?"good":"warning":void 0,s=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return n.jsx(xe,{tone:t,children:s})}function Lx(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 yz({account:e,busy:t,run:s,anthropicOAuthEnabled:r}){const[i,a]=h.useState(!1),[l,o]=h.useState(!1);return n.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("h3",{className:"ui-card-title",children:e.label}),n.jsx($C,{account:e})]}),n.jsx(Kt,{items:[{label:"Provider",value:_x(e)},{label:"Default model",value:n.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:n.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":` (${MC(e)})`}`})},...e.baseUrl?[{label:"Endpoint",value:n.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?n.jsx("span",{className:"ui-row",children:e.assignedAgents.map(c=>n.jsx("a",{href:dt(c,"setup","brain"),children:c},c))}):n.jsxs("span",{className:"ui-row",children:[n.jsx("span",{className:"muted",children:"No agents"}),n.jsx("a",{href:ut,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${new Date(e.tokenExpiresAt).toLocaleString()} (not your subscription renewal date)`}]:[]]}),e.removalPending&&n.jsx(H,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&n.jsxs(H,{tone:"warning",children:["Token refresh did not finish. Reconnect this ",e.kind==="codex"?"ChatGPT":"Claude"," account."]}),e.auth==="anthropic-oauth"&&n.jsx(_C,{account:e,enabled:!!r,busy:t,run:s}),e.kind==="codex"&&n.jsx(DC,{account:e,busy:t,run:s}),e.auth==="device-key"&&n.jsx(OC,{account:e,busy:t,run:s}),n.jsxs(Q,{children:[n.jsx(I,{disabled:t||e.removalPending,onClick:()=>a(!0),children:"Edit account"}),n.jsx(I,{disabled:t||e.removalPending,onClick:()=>void s(()=>A.saveProviderAccount({...Lx(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"&&n.jsx(I,{disabled:t||!e.enabled||!e.configured,onClick:()=>void s(()=>A.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),n.jsx(I,{variant:"danger",disabled:t||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>o(!0),children:"Remove account"})]}),e.test&&n.jsxs(n.Fragment,{children:[n.jsxs(H,{role:"status",tone:jz(e.test.state),children:[n.jsx("p",{children:e.test.message}),e.test.retryAt?n.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)&&n.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),n.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&&n.jsx(Dt,{title:`Edit ${e.label}`,onClose:()=>a(!1),children:n.jsx(wz,{account:e,busy:t,run:s,onDone:()=>a(!1)})}),l&&n.jsxs(H,{tone:"critical",children:[n.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."]}),n.jsxs(Q,{children:[n.jsx(I,{variant:"danger",disabled:t,onClick:()=>void s(()=>A.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),n.jsx(I,{disabled:t,onClick:()=>o(!1),children:"Cancel"})]})]}),n.jsx(Tt,{summary:"Details",children:n.jsxs("div",{className:"ui-prose muted",children:[e.auth==="legacy-subscription-token"&&n.jsx("p",{children:"Legacy subscription token: not refreshable, token expiry and subscription renewal date unknown."}),e.kind==="codex"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Talks to OpenAI’s Codex backend directly with your ChatGPT sign-in. The credential stays in buddi’s vault; buddi refreshes it and never reads your own Codex login."}),n.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."}),n.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):n.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==="device-key"&&n.jsx("p",{children:"Ollama Cloud with a device key: buddi made a key pair and keeps it in the vault; ollama.com only ever saw the public half and this computer’s name. Each request to ollama.com is signed with the key, and nothing else is sent with it. Disconnect asks ollama.com to forget the device and removes the key from buddi either way."}),e.auth==="anthropic-oauth"&&n.jsx("p",{children:"Claude subscription sign-in. Tokens remain in Buddi’s vault and refresh before use. Uses your plan’s monthly Agent SDK credits; after them, an API key. Remaining credits are unknown here."}),n.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 DC({account:e,busy:t,run:s}){var r,i,a;return n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[n.jsx(I,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void s(()=>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"&&n.jsx(I,{disabled:t,onClick:()=>void s(()=>A.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),n.jsx(I,{disabled:t||!e.configured,onClick:()=>void s(()=>A.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((a=e.login)==null?void 0:a.state)==="pending"&&n.jsxs(H,{tone:"accent",role:"status",children:[n.jsxs("p",{children:["Here is your code: ",n.jsx("strong",{children:e.login.userCode}),". Open the link, enter it, and approve buddi on openai.com."]}),e.login.userCode&&n.jsx(PC,{code:e.login.userCode}),e.login.verificationUrl&&n.jsx(Q,{children:n.jsx(Yt,{variant:"accent",href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open openai.com"})}),e.login.expiresAt&&n.jsxs("p",{className:"muted",children:["The code works until ",new Date(e.login.expiresAt).toLocaleTimeString(),". Start again after that; this is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&n.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function wz({account:e,busy:t,run:s,onDone:r,codexEnabled:i,anthropicOAuthEnabled:a}){const[l,o]=h.useState((e==null?void 0:e.label)??""),[c,u]=h.useState((e==null?void 0:e.kind)??"anthropic"),[f,d]=h.useState((e==null?void 0:e.auth)??"api-key"),[m,p]=h.useState((e==null?void 0:e.baseUrl)??""),[v,w]=h.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[k,g]=h.useState(""),[x,y]=h.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),j=b=>{u(b),d(b==="codex"?"chatgpt":"api-key"),g(""),p(b==="openai-compatible"?"http://localhost:11434/v1":""),w(b==="anthropic"?"claude-sonnet-5":b==="openai"?"gpt-5":"")},N=!l.trim()||!v.trim();return n.jsxs("form",{className:"ui-stack",onSubmit:b=>{b.preventDefault();const S=k;g(""),s(()=>A.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:l,kind:c,auth:f,baseUrl:m,defaultModel:v,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:x.trim()?Number(x):null,...S.trim()?{secret:S}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[n.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[n.jsx(te,{label:"Account name",children:n.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:l,onChange:b=>o(b.target.value),placeholder:"Anthropic — Personal"})}),n.jsx(te,{label:"Provider",children:n.jsxs("select",{disabled:!!e,value:f==="anthropic-oauth"?"anthropic-oauth":f==="device-key"?"ollama-cloud":c,onChange:b=>{b.target.value==="anthropic-oauth"?(j("anthropic"),d("anthropic-oauth")):j(b.target.value)},children:[n.jsx("option",{value:"anthropic",children:"Anthropic API"}),n.jsx("option",{value:"openai",children:"OpenAI API"}),n.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(e==null?void 0:e.auth)==="device-key"&&n.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),(a||(e==null?void 0:e.auth)==="anthropic-oauth")&&n.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),(i||(e==null?void 0:e.kind)==="codex")&&n.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),c==="openai-compatible"&&f!=="device-key"&&n.jsxs(n.Fragment,{children:[n.jsx(te,{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:n.jsx("input",{required:!0,type:"url",value:m,onChange:b=>p(b.target.value)})}),n.jsx(te,{label:"Authentication",children:n.jsxs("select",{disabled:!!e,value:f,onChange:b=>{d(b.target.value),g("")},children:[n.jsx("option",{value:"api-key",children:"API key"}),n.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),n.jsx(Q,{valign:"end",children:n.jsx(Dx,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:v,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),n.jsx(te,{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:n.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:x,placeholder:e!=null&&e.detectedContextWindowTokens?`${e.detectedContextWindowTokens} (${MC(e)})`:"assumed from the model",onChange:b=>y(b.target.value)})}),c==="codex"&&n.jsx("p",{className:"muted",children:"Pick a model from the list once the account is connected."}),f==="anthropic-oauth"&&n.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."}),f==="api-key"&&n.jsx(te,{label:e?"Replacement API key (leave blank to keep)":"API key",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:k,onChange:b=>g(b.target.value)})}),e&&n.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."}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:r,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",disabled:N,children:"Save account"})]})]}),N&&n.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function OC({account:e,busy:t,run:s}){var o;const r=((o=e.login)==null?void 0:o.state)==="pending"&&e.login.attemptId?e.login:null,i=h.useRef(s);i.current=s,h.useEffect(()=>{if(!(r!=null&&r.attemptId))return;let c=!1,u=!1;const f=setInterval(()=>{c||u||(u=!0,A.ollamaPoll(e.id,r.attemptId).then(d=>{c||d.state==="waiting"||(c=!0,d.state==="connected"?i.current(async()=>{},`Connected as ${d.username}, device ${d.deviceName}.`):i.current(async()=>{throw new Error(d.message)},""))}).catch(()=>{}).finally(()=>{u=!1}))},2e3);return()=>{c=!0,clearInterval(f)}},[e.id,r==null?void 0:r.attemptId]);const a=()=>{const c=typeof window.open=="function"?window.open("","_blank"):null;s(async()=>{try{const u=await A.ollamaConnect(e.id,e.revision);return c&&(c.location.href=u.verificationUrl),u}catch(u){throw c==null||c.close(),u}},"Press Connect on the ollama.com page. This card notices on its own.")},l=e.device;return n.jsxs(n.Fragment,{children:[l&&n.jsx("p",{className:"muted",role:"status",children:l.connectedAt?`Connected as ${l.username||"an ollama.com account"}, device ${l.deviceName}.`:`Not connected yet. Device ${l.deviceName}.`}),n.jsxs(Q,{children:[n.jsx(I,{disabled:t||!e.enabled||e.removalPending||!!r,onClick:a,children:e.configured?"Reconnect Ollama":"Connect Ollama"}),n.jsx(I,{disabled:t||!l||e.removalPending,onClick:()=>void s(async()=>({warning:(await A.ollamaDisconnect(e.id,e.revision)).note}),"Disconnected."),children:"Disconnect"})]}),r&&n.jsxs(H,{tone:"accent",role:"status",children:[n.jsxs("p",{children:[n.jsx("a",{href:r.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open the ollama.com page"})," and press Connect. Sign in there first if it asks."]}),n.jsxs("p",{className:"muted",children:["buddi stops waiting at ",r.expiresAt&&new Date(r.expiresAt).toLocaleTimeString(),"."]})]})]})}function _C({account:e,enabled:t,busy:s,run:r}){var l,o,c,u,f;const[i,a]=h.useState("");return h.useEffect(()=>{a("")},[(l=e.login)==null?void 0:l.attemptId,(o=e.login)==null?void 0:o.state]),n.jsxs(n.Fragment,{children:[!t&&n.jsx(H,{tone:"warning",children:"Claude subscription sign-in is turned off on this host."}),n.jsxs(Q,{children:[n.jsx(I,{disabled:s||!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"&&n.jsx(I,{disabled:s,onClick:()=>{a(""),r(()=>A.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),n.jsx(I,{disabled:s||!e.configured||e.removalPending,onClick:()=>{a(""),r(()=>A.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((f=e.login)==null?void 0:f.state)==="pending"&&n.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:d=>{d.preventDefault();const m=i;a(""),r(()=>A.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:m}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[n.jsx("p",{children:n.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),n.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."]}),n.jsx(te,{label:"Claude authorization code",children:n.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:d=>a(d.target.value),disabled:s})}),n.jsx(Q,{align:"end",children:n.jsx(I,{type:"submit",variant:"accent",disabled:s||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const sf={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5.5"};function rf(e,t,s){return LC(e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":t==="device-key"?"Ollama Cloud":"Local endpoint",s)}function LC(e,t){const s=new Set(t.map(r=>r.trim().toLowerCase()));if(!s.has(e.toLowerCase()))return e;for(let r=2;r<100;r+=1)if(!s.has(`${e} ${r}`.toLowerCase()))return`${e} ${r}`;return e}const bz="That key was refused. Check it and paste it again.";function kz({accounts:e,busy:t,run:s,onDone:r,codexEnabled:i,anthropicOAuthEnabled:a,gemini:l}){const o=e.map(X=>X.label),[c,u]=h.useState(null),[f,d]=h.useState("anthropic"),[m,p]=h.useState("api-key"),[v,w]=h.useState(()=>rf("anthropic","api-key",o)),[k,g]=h.useState(!1),[x,y]=h.useState(""),[j,N]=h.useState(""),[b,S]=h.useState(null),[C,R]=h.useState(!1),[E,P]=h.useState(""),[F,M]=h.useState(""),[T,$]=h.useState(!1),[_,K]=h.useState(!1),[D,Y]=h.useState(!1),B=(X,be,Ee=!1)=>{d(X),p(be),N(""),S(null),P(""),M(""),$(!1),K(Ee),Y(!1),y(Ee?"":X==="openai-compatible"?"http://localhost:11434/v1":""),k||w(Ee?rf(X,"device-key",o):rf(X,be,o))},V=X=>{B("openai-compatible",X?"api-key":"device-key",!0),X&&A.ollama().then(be=>y(be.cloudBaseUrl)).catch(()=>{})},de=()=>{l&&(B("openai-compatible","api-key"),Y(!0),y(l.baseUrl),k||w(LC("Gemini",o)))},ae=c?e.find(X=>X.id===c):void 0;if(c)return ae?n.jsx(Sz,{account:ae,busy:t,run:s,anthropicOAuthEnabled:a,onDone:()=>r(ae.id)}):n.jsx(oe,{children:"Saving…"});const le=f==="openai-compatible"&&m!=="device-key",Ce=f==="codex"||m==="anthropic-oauth"||m==="device-key",ee=!Ce&&(m==="none"||j.trim()!=="")&&(!le||x.trim()!==""),ce=async()=>{var X,be;R(!0),P("");try{const Ee=await A.probeModels({kind:f,auth:m,...le?{baseUrl:x}:{},...j.trim()?{secret:j}:{}});S(Ee),F||M(((X=Ee.models.find(qe=>qe.isDefault))==null?void 0:X.id)??((be=Ee.models[0])==null?void 0:be.id)??"")}catch(Ee){P(Ee instanceof Error?Ee.message:"Could not load models. You can still enter a custom model.")}finally{R(!1)}},fe=F.trim(),je=!v.trim()||le&&!x.trim()||le&&!D&&!fe||D&&!j.trim();return n.jsxs("form",{className:"ui-stack",onSubmit:X=>{X.preventDefault();const be=j;N("");let Ee=fe||(m==="device-key"?Vc:sf[f])||"claude-sonnet-5",qe;(async()=>{if(D){Ee=EC;try{const Ae=(await A.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:x,secret:be})).models.map(Me=>Me.id);Ee=AC(Ae)??Ee,qe=RC(Ee)?TC(Ae):void 0}catch{}}let Ie,et=!1;!await s(async()=>{if(Ie=await A.saveProviderAccount({label:v,kind:f,auth:m,baseUrl:x,defaultModel:Ee,enabled:!0,...be.trim()?{secret:be}:{}}),m!=="api-key")return Ie;const se=await A.testProviderAccount(Ie.id);if(se.state==="connected")return Ie;if(Dg(se)){const Ae=Ie.id;Ie=void 0;try{const Me=(await A.providerAccounts()).accounts.find(ot=>ot.id===Ae);Me&&await A.removeProviderAccount(Ae,Me.revision)}catch{}throw new Error(bz)}if(D&&qe&&IC(se)){const Ae=(await A.providerAccounts()).accounts.find(Me=>Me.id===Ie.id);if(Ae&&(await A.saveProviderAccount({...Lx(Ae),defaultModel:qe}),(await A.testProviderAccount(Ie.id)).state==="connected"))return{...Ie,warning:`Account saved. Google's free tier has no Pro allowance, so it starts on ${qe}; turn on billing at Google to use Pro.`}}return et=!0,{...Ie,warning:`Account saved. ${se.message}`}},"Account saved.")||!Ie||(D||et?u(Ie.id):fe||!Ce?r(Ie.id):u(Ie.id))})()},children:[n.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[n.jsx(te,{label:"Provider",children:n.jsxs("select",{value:m==="anthropic-oauth"?"anthropic-oauth":_?"ollama-cloud":D?"gemini":f,onChange:X=>{if(X.target.value==="anthropic-oauth")B("anthropic","anthropic-oauth");else if(X.target.value==="gemini")de();else if(X.target.value==="ollama-cloud")B("openai-compatible","device-key",!0);else{const be=X.target.value;B(be,be==="codex"?"chatgpt":"api-key")}},children:[n.jsx("option",{value:"anthropic",children:"Anthropic API"}),n.jsx("option",{value:"openai",children:"OpenAI API"}),l&&n.jsx("option",{value:"gemini",children:"Gemini (Google AI key)"}),n.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),n.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),a&&n.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),i&&n.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),n.jsx(te,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:n.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:v,onChange:X=>{w(X.target.value),g(!0)},placeholder:"Anthropic — Personal"})}),_&&n.jsxs("label",{className:"ui-row",children:[n.jsx("input",{type:"checkbox",checked:m==="api-key",onChange:X=>V(X.target.checked)}),n.jsx("span",{children:"Use a key instead"})]}),le&&n.jsxs(n.Fragment,{children:[n.jsx(te,{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:n.jsx("input",{required:!0,type:"url",value:x,onChange:X=>{y(X.target.value),S(null)}})}),!D&&n.jsx(te,{label:"Authentication",children:n.jsxs("select",{value:m,onChange:X=>{p(X.target.value),N(""),S(null)},children:[n.jsx("option",{value:"api-key",children:"API key"}),n.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),m==="api-key"&&n.jsx(te,{label:"API key",hint:"Stored in the vault, never shown again.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:j,onChange:X=>{N(X.target.value),S(null)}})}),D&&l?n.jsxs("p",{className:"muted",children:[n.jsx("a",{href:l.keyUrl,target:"_blank",rel:"noreferrer",children:"Get a key at aistudio.google.com"}),". buddi picks the newest Gemini Pro your key can reach; the next step lists the rest."]}):Ce?n.jsx("p",{className:"muted",children:f==="codex"?"You will connect your ChatGPT subscription on the next step, with a code you enter on openai.com, and pick a model then.":m==="device-key"?"You will connect on the next step: ollama.com opens, you press Connect, and no key is typed. Free to start.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Model"}),b?n.jsxs("div",{className:"ui-row",children:[n.jsxs("select",{"aria-label":"Model",value:T?"__custom__":F,onChange:X=>{X.target.value==="__custom__"?($(!0),M("")):($(!1),M(X.target.value))},children:[b.models.map(X=>n.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)),n.jsx("option",{value:"__custom__",children:"Custom model…"})]}),n.jsx(I,{size:"sm",disabled:C||!ee,onClick:()=>void ce(),children:C?"Loading…":"Reload"})]}):n.jsxs("div",{className:"ui-row",children:[n.jsx(I,{disabled:C||!ee,onClick:()=>void ce(),children:C?"Loading models…":"Load models"}),le?n.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):n.jsxs("span",{className:"muted",children:["Optional now: ",sf[f]," is used until you pick one."]})]}),T||le&&!b?n.jsx("input",{"aria-label":"Custom model",required:le,maxLength:150,value:F,onChange:X=>M(X.target.value),placeholder:le?"qwen3:8b":sf[f]}):null,E?n.jsx("span",{className:"ui-field-hint critical",role:"alert",children:E}):null,b!=null&&b.truncated?n.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:()=>r(),children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",disabled:je,children:"Save account"})]})]}),je&&n.jsxs("p",{className:"muted",children:["Enter an account name",D?" and a key":le?", an endpoint and a model":""," to enable Save account."]})]})}function Sz({account:e,busy:t,run:s,anthropicOAuthEnabled:r,onDone:i}){const[a,l]=h.useState(e.defaultModel),o=e.configured;return n.jsxs(q,{gap:"lg",children:[n.jsxs(H,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!o?n.jsx(_C,{account:e,enabled:!!r,busy:t,run:s}):null,e.kind==="codex"&&!o?n.jsx(DC,{account:e,busy:t,run:s}):null,e.auth==="device-key"&&!o?n.jsx(OC,{account:e,busy:t,run:s}):null,o?n.jsxs(n.Fragment,{children:[n.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."}),n.jsx(Q,{valign:"end",children:n.jsx(Dx,{accountId:e.enabled?e.id:void 0,label:"Default model",value:a,onChange:l,disabled:t},`${e.id}:${e.revision}`)}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:i,children:"Skip for now"}),n.jsx(I,{variant:"accent",disabled:t||!a.trim(),onClick:()=>{if(a===e.defaultModel){i();return}s(()=>A.saveProviderAccount({...Lx(e),defaultModel:a}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):n.jsx(Q,{children:n.jsx(I,{onClick:i,children:"Finish later"})})]})}const Nw=new Set(["co.uk","org.uk","me.uk","ltd.uk","plc.uk","net.uk","sch.uk","ac.uk","gov.uk","nhs.uk","police.uk","mod.uk","gov.ie","co.at","or.at","ac.at","gv.at","com.pl","net.pl","org.pl","info.pl","biz.pl","edu.pl","gov.pl","waw.pl","com.es","org.es","nom.es","gob.es","edu.es","com.pt","org.pt","gov.pt","edu.pt","com.gr","org.gr","net.gr","edu.gr","gov.gr","com.cy","org.cy","net.cy","gov.cy","ac.cy","com.mt","org.mt","net.mt","edu.mt","gov.mt","co.hu","org.hu","info.hu","com.ro","org.ro","info.ro","nom.ro","co.rs","org.rs","edu.rs","gov.rs","in.rs","com.ua","org.ua","net.ua","gov.ua","edu.ua","in.ua","kiev.ua","com.ru","org.ru","net.ru","msk.ru","spb.ru","co.no","priv.no","com.hr","from.hr","iz.hr","name.hr","co.it","gov.it","edu.it","asso.fr","com.fr","gouv.fr","nom.fr","prd.fr","tm.fr","co.je","net.je","org.je","co.gg","net.gg","org.gg","co.im","net.im","org.im","gc.ca","on.ca","qc.ca","bc.ca","ab.ca","com.mx","org.mx","net.mx","edu.mx","gob.mx","ny.us","ca.us","tx.us","fl.us","wa.us","k12.ca.us","lib.ca.us","com.br","net.br","org.br","gov.br","edu.br","art.br","blog.br","eco.br","emp.br","ind.br","inf.br","tv.br","app.br","dev.br","com.ar","org.ar","net.ar","gob.ar","edu.ar","int.ar","tur.ar","com.co","org.co","net.co","edu.co","gov.co","nom.co","com.pe","org.pe","net.pe","gob.pe","edu.pe","nom.pe","com.ve","org.ve","net.ve","gob.ve","co.ve","com.uy","org.uy","net.uy","gub.uy","edu.uy","com.ec","org.ec","net.ec","gob.ec","edu.ec","fin.ec","com.bo","org.bo","net.bo","gob.bo","edu.bo","com.py","org.py","net.py","gov.py","edu.py","gob.cl","gov.cl","co.cl","com.do","org.do","net.do","gob.do","edu.do","com.gt","org.gt","net.gt","gob.gt","edu.gt","co.cr","or.cr","fi.cr","go.cr","ac.cr","com.pa","org.pa","net.pa","gob.pa","com.sv","org.sv","gob.sv","edu.sv","com.ni","org.ni","gob.ni","com.hn","org.hn","net.hn","gob.hn","com.cu","org.cu","net.cu","gob.cu","com.jm","org.jm","net.jm","gov.jm","com.tt","org.tt","net.tt","gov.tt","co.tt","com.pr","org.pr","net.pr","gov.pr","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","co.nz","net.nz","org.nz","ac.nz","govt.nz","school.nz","geek.nz","gen.nz","kiwi.nz","maori.nz","co.jp","ne.jp","or.jp","ac.jp","ad.jp","ed.jp","go.jp","gr.jp","lg.jp","com.cn","net.cn","org.cn","gov.cn","edu.cn","ac.cn","com.hk","net.hk","org.hk","edu.hk","gov.hk","idv.hk","com.tw","net.tw","org.tw","edu.tw","gov.tw","idv.tw","co.kr","or.kr","ne.kr","go.kr","ac.kr","re.kr","pe.kr","co.in","net.in","org.in","firm.in","gen.in","ind.in","ac.in","edu.in","gov.in","res.in","nic.in","com.sg","net.sg","org.sg","edu.sg","gov.sg","per.sg","com.my","net.my","org.my","edu.my","gov.my","name.my","co.id","or.id","ac.id","go.id","web.id","my.id","biz.id","net.id","sch.id","co.th","in.th","ac.th","go.th","or.th","net.th","com.vn","net.vn","org.vn","edu.vn","gov.vn","com.ph","net.ph","org.ph","edu.ph","gov.ph","com.pk","net.pk","org.pk","edu.pk","gov.pk","com.bd","org.bd","net.bd","gov.bd","edu.bd","com.lk","org.lk","gov.lk","edu.lk","com.np","org.np","gov.np","edu.np","com.kh","org.kh","gov.kh","com.mm","org.mm","gov.mm","com.fj","org.fj","gov.fj","ac.fj","com.pg","org.pg","gov.pg","ac.pg","com.kz","org.kz","gov.kz","edu.kz","com.tr","net.tr","org.tr","gov.tr","edu.tr","gen.tr","biz.tr","info.tr","av.tr","bel.tr","k12.tr","co.il","org.il","net.il","ac.il","gov.il","muni.il","com.sa","net.sa","org.sa","gov.sa","edu.sa","med.sa","co.ae","net.ae","org.ae","gov.ae","ac.ae","com.qa","org.qa","net.qa","gov.qa","edu.qa","com.kw","org.kw","net.kw","gov.kw","edu.kw","com.bh","org.bh","net.bh","gov.bh","edu.bh","com.om","org.om","net.om","gov.om","co.om","com.jo","org.jo","net.jo","gov.jo","edu.jo","com.lb","org.lb","net.lb","gov.lb","edu.lb","com.eg","org.eg","net.eg","gov.eg","edu.eg","eun.eg","co.ir","ac.ir","gov.ir","org.ir","net.ir","co.za","org.za","net.za","gov.za","ac.za","web.za","edu.za","nom.za","com.ng","org.ng","net.ng","gov.ng","edu.ng","name.ng","co.ke","or.ke","ne.ke","go.ke","ac.ke","sc.ke","co.tz","or.tz","ne.tz","go.tz","ac.tz","co.ug","or.ug","ne.ug","go.ug","ac.ug","com.gh","org.gh","gov.gh","edu.gh","co.ma","net.ma","org.ma","gov.ma","ac.ma","press.ma","com.tn","org.tn","gov.tn","ens.tn","fin.tn","com.dz","org.dz","net.dz","gov.dz","edu.dz","com.et","org.et","gov.et","edu.et","co.zw","org.zw","gov.zw","ac.zw","co.zm","org.zm","gov.zm","ac.zm","co.bw","org.bw","ac.bw","com.na","org.na","co.na","co.mz","org.mz","gov.mz","com.cm","co.cm","net.cm","gov.cm","com.sn","org.sn","edu.sn","gouv.sn","com.ci","co.ci","or.ci","go.ci","ac.ci","com.tg","gouv.tg","co.rw","gov.rw","ac.rw","*.ck","*.er","*.fk","*.jm","*.kh","*.mm","*.np","*.pg","*.bd","github.io","githubusercontent.com","gitlab.io","bitbucket.io","pages.dev","workers.dev","trycloudflare.com","vercel.app","vercel.dev","now.sh","netlify.app","netlify.com","herokuapp.com","herokussl.com","cloudfront.net","amazonaws.com","s3.amazonaws.com","elasticbeanstalk.com","awsapprunner.com","amplifyapp.com","azurewebsites.net","azurestaticapps.net","cloudapp.net","azureedge.net","azurefd.net","blob.core.windows.net","trafficmanager.net","appspot.com","firebaseapp.com","web.app","run.app","cloudfunctions.net","blogspot.com","fly.dev","onrender.com","up.railway.app","deno.dev","deno.net","glitch.me","repl.co","replit.dev","replit.app","ngrok.io","ngrok.app","ngrok-free.app","ngrok.dev","ngrok-free.dev","surge.sh","readthedocs.io","myshopify.com","wixsite.com","webflow.io","framer.app","framer.website","ondigitalocean.app","digitaloceanspaces.com","supabase.co","fastly.net","global.ssl.fastly.net","edgecompute.app","duckdns.org","dyndns.org","ddns.net","no-ip.org","hopto.org","zapto.org","eu.org","us.org","neocities.org","codeberg.page","sourceforge.io","pythonanywhere.com","streamlit.app","hf.space"]);function Nz(e){const t=e.toLowerCase().replace(/\.$/,"");if(!t.includes(".")||Nw.has(t))return!0;const s=t.slice(t.indexOf(".")+1);return Nw.has(`*.${s}`)}function Cz(e){return typeof e=="string"&&e.includes("*")}function Ez(e){const t=/^(https?):\/\/([^/?#@\s]+)(?:[/?#]\S*)?$/i.exec(e.trim());if(t===null)return{ok:!1,reason:"invalid"};const[,s,r]=t;if(!r.startsWith("*.")||r.slice(2).includes("*"))return{ok:!1,reason:"placement"};let i;try{i=new URL(`${s.toLowerCase()}://${r.slice(2)}`)}catch{return{ok:!1,reason:"invalid"}}const a=i.hostname;return a===""||a.startsWith("[")||/^[\d.]+$/.test(a)||a.startsWith(".")||a.includes("..")?{ok:!1,reason:"invalid"}:Nz(a)?{ok:!1,reason:"public-suffix"}:{ok:!0,value:{pattern:`${i.protocol}//*.${i.host}`,protocol:i.protocol,suffix:a,port:i.port}}}const Cw=["every-time","first-time","pre-approved"],FC={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function Az(e){const t=Cw.indexOf(e);return Cw.slice(0,t<0?1:t+1)}function UC(e){return e.endsWith(".account")}const Tz="This account’s process holds the value for as long as its connection lives.",Fx="Stored, not usable until it has a binding.";function Rz(e){return e==="browser.field"?"the origin of the site that holds the field, e.g. https://en.wikipedia.org or *.wikimedia.org":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==="http.url"?"the plugin, then the host — e.g. calendar calendar.google.com":e==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":UC(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const BC={"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})},"http.url":{hint:"a plugin, then the host",build:(e,t)=>({plugin:e,host:t})},"developer.env":{hint:"a workspace, then the variable name",build:(e,t)=>({workspace:e,variable:t})}},Iz="A wildcard may only stand for the leftmost part of a site, like *.wikimedia.org.",Pz=e=>`That is a public suffix; ${e} would match every site.`,Ew="Give the site as an origin, like https://en.wikipedia.org.";function Aw(e){const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:["https:","//",e].join("");if(Cz(e)){const s=Ez(t);if(s.ok)return{ok:!0,target:s.value.pattern};if(s.reason==="placement")return{ok:!1,error:Iz};if(s.reason==="public-suffix"){const r=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/[/?#:].*$/,"").toLowerCase();return{ok:!1,error:Pz(r)}}return{ok:!1,error:Ew}}try{const s=new URL(t);if(s.origin==="null"||s.protocol!=="https:"&&s.protocol!=="http:")throw new Error("not an origin");return{ok:!0,target:s.origin}}catch{return{ok:!1,error:Ew}}}function Mz(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const s=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&s?[r,s]:null}function zC(e,t){const s=t.trim();if(s==="")return{ok:!1,error:"Give the exact place this value may go."};if(s.startsWith("{"))try{const a=JSON.parse(s);return a!==null&&typeof a=="object"&&!Array.isArray(a)?{ok:!0,target:a}:{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")return Aw(s);if(e==="browser.native.type"||UC(e))return{ok:!0,target:s};const r=BC[e];if(r===void 0)return{ok:!0,target:s};const i=Mz(s);if(i===null)return{ok:!1,error:`${e} needs both: ${r.hint}.`};if(e==="browser.form.data"){const a=Aw(i[0]);return a.ok?{ok:!0,target:r.build(a.target,i[1])}:a}return{ok:!0,target:r.build(i[0],i[1])}}function $z(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function Dz(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const s=t,r=BC[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),a=i.map(l=>s[l]);if(i.every(l=>typeof s[l]=="string"))return a.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const WC="accounts.provider";function Oz(e,t){for(const s of e)if(s.kind===WC&&typeof s.target=="string"){const r=t.get(s.target);if(r)return r}}function mp(e,t,s){if(e===WC&&typeof t=="string"){const r=s.get(t);if(r)return r.label}return Dz(e,t)}function HC(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function VC(e,t){if(typeof e!="object"||e===null)return[];const s=e[t];return Array.isArray(s)?s.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,a=r.count;return typeof i!="string"||typeof a!="number"||!(a>0)?[]:[{place:i,count:a}]}):[]}function KC(e){const t=e.map(({place:s,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?s.replace(/s$/,""):s}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function _z(e){const t=VC(e,"found");return t.length?`The value already sits in ${KC(t)}.`:""}function Lz(e){const t=VC(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${KC(t)}.`:""}async function Si(e,t,s,r){s(!0),r(null);try{return(await A.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{s(!1)}}function Fz({embedded:e,timezone:t}={}){const s=ie(()=>A.secrets(),[]),r=ie(()=>A.providerAccounts(),[]),i=h.useMemo(()=>{var c;return new Map((((c=r.data)==null?void 0:c.accounts)??[]).map(u=>[u.id,{label:u.label,provider:_x(u)}]))},[r.data]),[a,l]=h.useState(!1),o=s.data;return n.jsxs(mn,{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:[n.jsxs(q,{gap:"lg",children:[!o&&!s.error?n.jsx(oe,{children:"Opening the vault…"}):null,s.error?n.jsx(Q,{children:n.jsx(I,{onClick:s.reload,children:"Retry"})}):null,o?n.jsx(J,{title:"Secrets",aside:"A value the agents use and never see: bound to where it may go, never shown again.",actions:n.jsx(I,{variant:"accent",size:"sm",onClick:()=>l(!0),children:"Add a secret"}),panel:!0,children:n.jsx(q,{divided:!0,children:o.secrets.length===0?n.jsx(Ut,{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."}):o.secrets.map(c=>n.jsx(Uz,{secret:c,accounts:i,destinations:o.destinations,timezone:t,onChanged:s.reload},c.name))})}):null,o?n.jsx(J,{title:"buddi’s own keys",aside:"Read-only.",children:n.jsxs(q,{gap:"sm",children:[o.ownKeys.length===0?n.jsx(oe,{children:"No keys of buddi’s own right now."}):n.jsx("div",{className:"ui-list",children:o.ownKeys.map(c=>n.jsx("div",{className:"ui-list-row",children:n.jsx("span",{className:"ui-list-main",children:n.jsx("span",{className:"mono",children:c})})},c))}),n.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]}),a&&o?n.jsx(zz,{destinations:o.destinations,onClose:()=>l(!1),onChanged:s.reload}):null]})}function Uz({secret:e,accounts:t,destinations:s,timezone:r,onChanged:i}){const[a,l]=h.useState(!1),[o,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState(!1),[p,v]=h.useState(!1),w=async()=>{await Si("secrets.delete",{name:e.name},l,c)!==null&&(m(!1),i())},k=e.lastUse,g=Oz(e.bindings,t);return n.jsxs(q,{gap:"sm",children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("h3",{className:"ui-card-title",children:g?g.label:e.name}),g?n.jsx(fi,{children:g.provider}):null,e.totp?n.jsx(fi,{children:"TOTP"}):null,k?n.jsx(xe,{tone:HC(k.outcome),children:k.outcome}):null]}),g?n.jsx("p",{className:"ui-card-meta mono",children:e.name}):null,e.bindings.length===0?n.jsx("p",{className:"ui-card-meta",children:Fx}):n.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((x,y)=>n.jsxs("div",{className:"ui-row",children:[n.jsx(fi,{children:x.kind}),n.jsx("span",{className:"mono",children:mp(x.kind,x.target,t)}),n.jsx(xe,{tone:"muted",children:FC[x.rule]??x.rule})]},y))}),e.bindings.some(x=>x.heldByPlugin)?n.jsx("p",{className:"ui-card-meta",children:Tz}):null,n.jsx("p",{className:"ui-card-meta",children:k?`Last used ${Oe(k.at)}${k.agentId?` by ${k.agentId}`:""} — ${k.kind}, ${mp(k.kind,k.target,t)}.`:"Never used."}),n.jsx(ne,{message:o}),d?n.jsxs(H,{tone:"critical",role:"alert",children:[n.jsxs("p",{children:["Delete “",e.name,"”? The value and its bindings go; the use log stays, under the name."]}),n.jsxs(Q,{children:[n.jsx(I,{variant:"danger",disabled:a,onClick:()=>void w(),children:"Delete it"}),n.jsx(I,{disabled:a,onClick:()=>m(!1),children:"Cancel"})]})]}):null,n.jsxs(Q,{children:[n.jsx(I,{size:"sm",disabled:a,onClick:()=>f("replace"),children:"Replace value"}),n.jsx(I,{size:"sm",disabled:a,onClick:()=>f("rename"),children:"Rename"}),n.jsx(I,{size:"sm",disabled:a,onClick:()=>f("rebind"),children:e.bindings.length===0?"Add a binding":"Rebind"}),n.jsx(I,{size:"sm",variant:"danger",disabled:a,onClick:()=>m(!0),children:"Delete"}),n.jsx(I,{size:"sm",variant:"ghost","aria-expanded":p,onClick:()=>v(!p),children:"Use log"})]}),p?n.jsx(Bz,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?n.jsx(Wz,{secret:e,onClose:()=>f(null),onChanged:i}):null,u==="rename"?n.jsx(Hz,{secret:e,onClose:()=>f(null),onChanged:i}):null,u==="rebind"?n.jsx(Vz,{secret:e,destinations:s,onClose:()=>f(null),onChanged:i}):null]})}function Bz({name:e,accounts:t,timezone:s}){const r=ie(()=>A.secretUses(e,50),[e]);if(r.error)return n.jsx(ne,{message:r.error});if(!r.data)return n.jsx(oe,{children:"Reading the log…"});const i=r.data.uses;return i.length===0?n.jsx(oe,{children:"No uses yet."}):n.jsx("div",{className:"ui-list",children:i.map((a,l)=>n.jsxs("div",{className:"ui-list-row",children:[n.jsxs("span",{className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[Ve(a.at,s??"UTC")," — ",a.kind,", ",mp(a.kind,a.target,t)]}),n.jsxs("span",{className:"ui-list-sub",children:[a.agent?a.agent:"the owner",a.plugin?` · ${a.plugin}`:"",a.detail?` · ${a.detail}`:""]})]}),n.jsx("span",{className:"ui-list-side",children:n.jsx(xe,{tone:HC(a.outcome),children:a.outcome})})]},l))})}function GC({name:e,result:t,scrubbed:s,busy:r,failure:i,onScrub:a,onDone:l}){const o=_z(t);return n.jsxs(q,{gap:"sm",children:[n.jsxs(H,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),n.jsx("p",{className:"ui-card-meta",children:o||"Nothing of the value sits where buddi already holds text."}),n.jsx(ne,{message:i}),o?n.jsx(Q,{children:n.jsx(I,{variant:"accent",disabled:r||s!==null,onClick:a,children:s===null?"Scrub the history":Lz(s)||"Nothing of it was left to replace."})}):null,n.jsx(Q,{align:"end",children:n.jsx(I,{onClick:l,children:"Done"})})]})}function YC({destinations:e,bindings:t,disabled:s,onChange:r}){const i=(a,l)=>{r(t.map((o,c)=>c===a?{...o,...l}:o))};return n.jsx(q,{gap:"sm",children:t.map((a,l)=>{const o=e.find(u=>u.kind===a.kind),c=(o==null?void 0:o.maxRule)??a.rule;return n.jsxs(Q,{valign:"end",children:[n.jsx(te,{label:"Kind",inline:!0,children:n.jsx("select",{value:a.kind,disabled:s,onChange:u=>{var d;const f=u.target.value;i(l,{kind:f,rule:((d=e.find(m=>m.kind===f))==null?void 0:d.maxRule)??a.rule})},children:(o?e:[...e,{kind:a.kind,plugin:"",maxRule:a.rule}]).map(u=>n.jsx("option",{value:u.kind,children:u.kind},u.kind))})}),n.jsx(te,{label:"Target",inline:!0,grow:!0,children:n.jsx("input",{type:"text",spellCheck:!1,disabled:s,value:a.target,placeholder:Rz(a.kind),onChange:u=>i(l,{target:u.target.value})})}),n.jsx(te,{label:"Rule",inline:!0,children:n.jsx("select",{value:a.rule,disabled:s,onChange:u=>i(l,{rule:u.target.value}),children:Az(c).map(u=>n.jsx("option",{value:u,children:FC[u]},u))})}),n.jsx(I,{size:"sm",variant:"ghost",disabled:s,onClick:()=>r(t.filter((u,f)=>f!==l)),children:"Remove"})]},l)})})}function zz({destinations:e,onClose:t,onChanged:s}){const[r,i]=h.useState(""),[a,l]=h.useState(""),[o,c]=h.useState(!1),[u,f]=h.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:e[0].maxRule}]:[]),[d,m]=h.useState(!1),[p,v]=h.useState(null),[w,k]=h.useState(null),[g,x]=h.useState(null),y=async()=>{const N=u.map(R=>zC(R.kind,R.target)),b=N.findIndex(R=>!R.ok);if(b!==-1){v(`Binding ${b+1}: ${N[b].error}`);return}const S=a;l("");const C=await Si("secrets.put",{name:r.trim(),value:S,totp:o,bindings:u.map((R,E)=>({kind:R.kind,target:N[E].target,rule:R.rule}))},m,v);C!==null&&(k({name:r.trim(),result:C}),s())},j=async()=>{const N=await Si("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},m,v);N!==null&&(x(N),s())};return n.jsx(Dt,{title:"Add a secret",onClose:t,children:w?n.jsx(GC,{name:w.name,result:w.result,scrubbed:g,busy:d,failure:p,onScrub:()=>void j(),onDone:t}):n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:N=>{N.preventDefault(),y()},children:n.jsxs("fieldset",{disabled:d,className:"ui-stack","data-gap":"sm",children:[n.jsx(te,{label:"Name",hint:"What an agent calls it. Saving a name that exists replaces that secret’s value.",children:n.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:N=>i(N.target.value),placeholder:"PNC password"})}),n.jsx(te,{label:"Value",hint:"Kept in the vault, never shown again — not even here.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:a,onChange:N=>l(N.target.value)})}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:o,onChange:N=>c(N.target.checked)}),n.jsx("span",{children:"The code comes from this secret"})]}),n.jsx("p",{className:"ui-field-hint",children:"The seed and the code are one thing buddi holds — the owner’s explicit choice per secret."}),n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[n.jsx("span",{className:"ui-field-label",children:"Bindings — the places this value may go"}),n.jsx(YC,{destinations:e,bindings:u,disabled:d,onChange:f}),u.length===0?n.jsx("p",{className:"ui-field-hint",children:Fx}):null,e.length?n.jsx(Q,{children:n.jsx(I,{size:"sm",onClick:()=>f([...u,{kind:e[0].kind,target:"",rule:e[0].maxRule}]),children:"Add a binding"})}):n.jsx("p",{className:"ui-field-hint",children:"No destination is registered on this installation yet, so there is nothing to bind to."})]}),p?n.jsx(H,{tone:"critical",role:"alert",children:p}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:t,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",children:"Save secret"})]})]})})})}function Wz({secret:e,onClose:t,onChanged:s}){const[r,i]=h.useState(""),[a,l]=h.useState(!1),[o,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState(null),p=async()=>{const w=r;i("");const k=await Si("secrets.put",{name:e.name,value:w,totp:e.totp,bindings:e.bindings.map(({kind:g,target:x,rule:y})=>({kind:g,target:x,rule:y}))},l,c);k!==null&&(f(k),s())},v=async()=>{const w=await Si("secrets.scrub_history",{name:e.name},l,c);w!==null&&(m(w),s())};return n.jsx(Dt,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?n.jsx(GC,{name:e.name,result:u,scrubbed:d,busy:a,failure:o,onScrub:()=>void v(),onDone:t}):n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:w=>{w.preventDefault(),p()},children:n.jsxs("fieldset",{disabled:a,className:"ui-stack","data-gap":"sm",children:[n.jsx(te,{label:"New value",hint:"Replaces what is stored. The bindings stay as they are.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,value:r,onChange:w=>i(w.target.value)})}),o?n.jsx(H,{tone:"critical",role:"alert",children:o}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:t,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",children:"Save value"})]})]})})})}function Hz({secret:e,onClose:t,onChanged:s}){const[r,i]=h.useState(e.name),[a,l]=h.useState(!1),[o,c]=h.useState(null),u=async()=>{await Si("secrets.rename",{name:e.name,to:r.trim()},l,c)!==null&&(s(),t())};return n.jsx(Dt,{title:`Rename “${e.name}”`,onClose:t,children:n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:f=>{f.preventDefault(),u()},children:n.jsxs("fieldset",{disabled:a,className:"ui-stack","data-gap":"sm",children:[n.jsx(te,{label:"New name",hint:"The vault entry never moves; only the name the agents ask for does.",children:n.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:f=>i(f.target.value)})}),o?n.jsx(H,{tone:"critical",role:"alert",children:o}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:t,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",disabled:!r.trim()||r.trim()===e.name,children:"Save name"})]})]})})})}function Vz({secret:e,destinations:t,onClose:s,onChanged:r}){const[i,a]=h.useState(()=>e.bindings.map(d=>({kind:d.kind,target:$z(d.target),rule:d.rule}))),[l,o]=h.useState(!1),[c,u]=h.useState(null),f=async()=>{const d=i.map(v=>zC(v.kind,v.target)),m=d.findIndex(v=>!v.ok);if(m!==-1){u(`Binding ${m+1}: ${d[m].error}`);return}await Si("secrets.rebind",{name:e.name,bindings:i.map((v,w)=>({kind:v.kind,target:d[w].target,rule:v.rule}))},o,u)!==null&&(r(),s())};return n.jsx(Dt,{title:`Rebind “${e.name}”`,onClose:s,children:n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:d=>{d.preventDefault(),f()},children:n.jsxs("fieldset",{disabled:l,className:"ui-stack","data-gap":"sm",children:[n.jsx(YC,{destinations:t,bindings:i,disabled:l,onChange:a}),i.length===0?n.jsx("p",{className:"ui-field-hint",children:Fx}):null,t.length?n.jsx(Q,{children:n.jsx(I,{size:"sm",onClick:()=>a([...i,{kind:t[0].kind,target:"",rule:t[0].maxRule}]),children:"Add a binding"})}):null,c?n.jsx(H,{tone:"critical",role:"alert",children:c}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",children:"Save bindings"})]})]})})})}const Kz={connected:{label:"Connected",tone:"good"},"needs-reconnect":{label:"Needs reconnect",tone:"warning"},unreachable:{label:"Unreachable",tone:"critical"},"pending-review":{label:"Not finished",tone:"muted"},"needs-review":{label:"Changed its tools",tone:"warning"}},Gz="It can delete or destroy something, so it asks you every time and is never remembered.";function Yz(e){return e.tier==="auto"?{label:"Runs on its own",tone:"good"}:e.destructive?{label:"Asks you every time",tone:"critical"}:{label:"Asks you first",tone:"warning"}}const qC="buddi-connections",qz="/connections/callback",Qz="This service does not let buddi register itself, so it needs a client id you create in the service’s developer settings, with the address below as its redirect.";function Jz({embedded:e,timezone:t}={}){const s=ie(()=>A.connections(),[],3e4),[r,i]=h.useState(null),a=s.data,l=o=>{var c;return((c=a==null?void 0:a.agents.find(u=>u.id===o))==null?void 0:c.name)??o};return n.jsxs(mn,{embedded:e,title:"Connections",lede:"Services that speak MCP, connected once. Their tools become buddi tools: read at review, given to the agents you choose, approved like everything else.",children:[n.jsxs(q,{gap:"lg",children:[!a&&!s.error?n.jsx(oe,{children:"Reading your connections…"}):null,n.jsx(ne,{message:s.error}),a&&!a.vault?n.jsx(H,{tone:"warning",children:"This installation has no vault, so a service that asks for a sign-in cannot be connected. Turn the vault on first."}):null,a?n.jsx(J,{title:"Your connections",aside:"Each one's tools are named mcp.<connection>.<tool>.",panel:!0,children:n.jsx(q,{divided:!0,children:a.connections.length===0?n.jsx(Ut,{icon:"globe",title:"Nothing connected yet",children:"Pick a service below, or give the address of any remote MCP server."}):a.connections.map(o=>n.jsx(Xz,{connection:o,agentName:l,timezone:t??Intl.DateTimeFormat().resolvedOptions().timeZone,onFlow:i,onChanged:s.reload},o.id))})}):null,a?n.jsx(J,{title:"Connect a service",aside:"Each has an official remote server. You sign in on the service's own page.",children:n.jsxs("div",{className:"connections-cards",children:[a.catalog.map(o=>n.jsx(On,{title:o.name,foot:n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",onClick:()=>i({step:"address",card:o}),children:"Connect"})}),children:n.jsx("p",{className:"ui-card-meta",children:o.blurb})},o.id)),n.jsx(On,{title:"Another server",foot:n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",onClick:()=>i({step:"address"}),children:"Connect"})}),children:n.jsx("p",{className:"ui-card-meta",children:"Any remote MCP server, by its https address."})})]})}):null]}),r&&a?n.jsx(Zz,{start:r,agents:a.agents,onClose:()=>{i(null),s.reload()}}):null]})}function Xz({connection:e,agentName:t,timezone:s,onFlow:r,onChanged:i}){const[a,l]=h.useState(!1),[o,c]=h.useState(!1),[u,f]=h.useState(null),d=Kz[e.state],m=async()=>{c(!0),f(null);try{await A.disconnect(e.id),l(!1),i()}catch(v){f(v instanceof Error?v.message:String(v))}finally{c(!1)}},p=e.state==="pending-review";return n.jsxs(q,{gap:"sm",children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("h3",{className:"ui-card-title",children:e.name}),n.jsx(xe,{tone:d.tone,dot:!0,children:d.label}),e.grant?n.jsx(fi,{children:e.grant}):null]}),n.jsxs("p",{className:"ui-card-meta",children:[n.jsx("span",{className:"mono",children:e.host}),p?" · its tools are not reviewed yet":` · ${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,e.reviewedAt?` · reviewed ${Oe(e.reviewedAt)}`:""]}),p?null:n.jsx("p",{className:"ui-card-meta",children:e.agents.length===0?"No agent holds these tools yet.":`Held by ${e.agents.map(t).join(", ")}.`}),e.state==="needs-reconnect"?n.jsx("p",{className:"ui-card-meta",children:"Its sign-in ran out or was refused. Until you reconnect, each of its tools answers with one sentence instead of running."}):null,e.state==="needs-review"?n.jsxs("p",{className:"ui-card-meta",children:["It changed its tools since you reviewed them. The new and changed ones wait until you review it again",e.heldTools?` (${e.heldTools} of the ones you kept ${e.heldTools===1?"waits":"wait"})`:"","; the others keep working."]}):null,e.state==="unreachable"&&e.unreachableSince?n.jsxs("p",{className:"ui-card-meta",children:["Unreachable since ",Ve(e.unreachableSince,s),", retrying."]}):null,n.jsx(ne,{message:u}),a?n.jsx(H,{tone:"critical",role:"alert",title:`Disconnect ${e.name}?`,children:n.jsxs(q,{gap:"sm",children:[n.jsxs("p",{children:["buddi forgets its sign-in and its tools.",e.agents.length>0?` ${e.grant} comes out of ${e.agents.map(t).join(", ")}.`:" No agent holds its tools."]}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",onClick:()=>l(!1),disabled:o,children:"Keep it"}),n.jsx(I,{size:"sm",variant:"danger",onClick:()=>void m(),disabled:o,children:"Disconnect"})]})]})}):n.jsxs(Q,{align:"end",children:[p?n.jsx(I,{size:"sm",variant:"accent",onClick:()=>r({step:e.signedIn?"review":"consent",connection:e}),children:"Finish"}):null,p?null:n.jsx(I,{size:"sm",variant:e.state==="needs-review"?"accent":void 0,onClick:()=>r({step:"review",connection:e,keepGrants:!0}),children:"Review again"}),e.authKind==="oauth"&&!p?n.jsx(I,{size:"sm",variant:e.state==="needs-reconnect"?"accent":void 0,onClick:()=>r({step:"consent",connection:e,keepGrants:!0}),children:"Reconnect"}):null,n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>l(!0),children:"Disconnect"})]})]})}function Zz({start:e,agents:t,onClose:s,pollMs:r=2e3}){var m;const[i,a]=h.useState(e.step),[l,o]=h.useState(e.connection),[c,u]=h.useState("dynamic"),f=(l==null?void 0:l.name)??((m=e.card)==null?void 0:m.name)??"the service",d=i==="address"?"Connect a service":i==="consent"?`Sign in to ${f}`:i==="review"?`What ${f} brings`:"Who gets these tools";return n.jsxs(Dt,{title:d,onClose:s,size:"wide",children:[i==="address"?n.jsx(e5,{card:e.card,onDone:(p,v)=>{o(p),v==="none"?a("review"):(u(v),a("consent"))}}):null,i==="consent"&&l?n.jsx(t5,{connection:l,manual:c==="manual",pollMs:r,onSignedIn:p=>{o(p),e.keepGrants?s():a("review")}}):null,i==="review"&&l?n.jsx(n5,{connection:l,onKept:p=>{o(p),e.keepGrants?s():a("grant")}}):null,i==="grant"&&l?n.jsx(s5,{connection:l,agents:t,onDone:s}):null]})}function mo(e){return e instanceof Error?e.message:String(e)}function e5({card:e,onDone:t}){const[s,r]=h.useState((e==null?void 0:e.url)??""),[i,a]=h.useState(!1),[l,o]=h.useState(null),c=async()=>{a(!0),o(null);try{const u=await A.addConnection(s.trim(),e==null?void 0:e.name);t(u.connection,u.signIn)}catch(u){o(mo(u))}finally{a(!1)}};return n.jsxs("form",{className:"ui-stack",onSubmit:u=>{u.preventDefault(),c()},children:[e?n.jsxs("p",{children:["buddi opens ",e.name,"’s server, reads its name and what it offers, and asks whether it wants you to sign in. Nothing else is sent."]}):n.jsx("p",{children:"Where is the server? buddi opens it, reads its name and what it offers, and nothing else until you have read its tools."}),n.jsx(te,{label:"Address",hint:"An https:// address. Servers that run as a program on this computer are not supported yet.",children:n.jsx("input",{required:!0,autoFocus:!e,spellCheck:!1,value:s,placeholder:"https://",onChange:u=>r(u.target.value)})}),e&&!e.verified?n.jsxs("p",{className:"ui-card-meta",children:["This address is the one ",e.name," published; buddi has not checked it since."]}):null,e!=null&&e.clientIdRequired?n.jsxs("p",{className:"ui-card-meta",children:[e.name," does not let buddi register itself: you will need a client id from its developer settings."]}):null,n.jsx(ne,{message:l}),n.jsx(Q,{align:"end",children:n.jsx(I,{type:"submit",variant:"accent",disabled:i||s.trim()==="",children:i?"Opening…":"Continue"})})]})}function t5({connection:e,manual:t,pollMs:s,onSignedIn:r}){const[i,a]=h.useState(t?Qz:null),[l,o]=h.useState(""),[c,u]=h.useState(!1),[f,d]=h.useState(null),[m,p]=h.useState(!1),[v,w]=h.useState(null),k=`${location.origin}${qz}`,g=h.useRef(r);g.current=r,h.useEffect(()=>{if(!m)return;let y=!1;const j=async()=>{if(!y){y=!0;try{g.current(await A.connection(e.id))}catch(R){d(mo(R))}}},N=typeof BroadcastChannel=="function"?new BroadcastChannel(qC):null;N&&(N.onmessage=R=>{var E;((E=R.data)==null?void 0:E.id)===e.id&&j()});let b;const S=Date.now(),C=async()=>{if(!y){try{const R=await A.connection(e.id);if(!e.signedIn&&R.signedIn){j();return}}catch{}if(Date.now()-S>10*6e4){p(!1),d("The sign-in did not come back within ten minutes. Start it again.");return}b=window.setTimeout(()=>void C(),s)}};return b=window.setTimeout(()=>void C(),s),()=>{y=!0,N==null||N.close(),window.clearTimeout(b)}},[m,e,s]);const x=async()=>{var j;const y=window.open("","_blank");u(!0),d(null);try{const{authorizeUrl:N}=await A.connectionConsent(e.id,i!==null?l.trim():void 0);y?(y.opener=null,y.location.href=N):w(N),p(!0)}catch(N){y==null||y.close(),N instanceof he&&((j=N.detail)==null?void 0:j.code)==="client-id"?a(N.message):d(mo(N))}finally{u(!1)}};return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:[e.name," asks you to sign in. buddi opens its own consent page in a new tab; you say yes there, to ",e.name,", and the tab comes back here. buddi keeps the sign-in in its vault, and no agent ever sees it."]}),i!==null?n.jsxs(n.Fragment,{children:[n.jsx(H,{tone:"warning",children:i}),n.jsx(te,{label:"Client id",children:n.jsx("input",{required:!0,spellCheck:!1,value:l,onChange:y=>o(y.target.value)})}),n.jsxs("p",{className:"ui-card-meta",children:["Its redirect address: ",n.jsx("span",{className:"mono",children:k})]})]}):null,m?n.jsxs(H,{tone:"accent",role:"status",children:["Waiting for you to say yes on ",e.name,"’s page…"]}):null,v?n.jsx("p",{children:n.jsxs("a",{href:v,target:"_blank",rel:"noopener noreferrer",children:["Open ",e.name,"’s sign-in page"]})}):null,n.jsx(ne,{message:f}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",onClick:()=>void x(),disabled:c||i!==null&&l.trim()==="",children:m?"Open it again":`Sign in to ${e.name}`})})]})}function n5({connection:e,onKept:t}){const s=ie(()=>A.connectionReview(e.id),[e.id]),[r,i]=h.useState(null),[a,l]=h.useState(!1),[o,c]=h.useState(null),u=s.data,f=r??(u==null?void 0:u.slug)??"",d=async()=>{var p;if(u){l(!0),c(null);try{t(await A.saveConnectionReview(e.id,{hash:u.hash,...u.slugEditable?{slug:f}:{}}))}catch(v){v instanceof he&&((p=v.detail)==null?void 0:p.code)==="changed"&&s.reload(),c(mo(v))}finally{l(!1)}}};if(!u)return s.error?n.jsx(ne,{message:s.error}):n.jsxs(oe,{children:["Reading what ",e.name," offers…"]});const m=u.tools.filter(p=>p.problem===null).length;return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:["Read what ",e.name," brings before it brings it. Each tool gets a buddi name and a tier from what the server says it does; anything that changes something asks you first, on the same approval card as every other tool."]}),n.jsxs("p",{className:"ui-card-meta",children:["buddi talks to ",n.jsx("span",{className:"mono",children:u.host})," for these tools, and nowhere else."]}),u.annotatedNothing?n.jsxs(H,{tone:"warning",children:[e.name," says nothing about what its tools do, so every one of them asks you first."]}):null,u.changes&&u.changes.added.length+u.changes.changed.length+u.changes.removed.length>0?n.jsxs(H,{tone:"warning",title:`${e.name} changed its tools since your last review.`,children:[n.jsxs("ul",{className:"connections-changes","aria-label":"What changed",children:[u.changes.added.length>0?n.jsxs("li",{children:["New: ",n.jsx("span",{className:"mono",children:u.changes.added.join(", ")})]}):null,u.changes.changed.length>0?n.jsxs("li",{children:["Changed: ",n.jsx("span",{className:"mono",children:u.changes.changed.join(", ")})]}):null,u.changes.removed.length>0?n.jsxs("li",{children:["Gone: ",n.jsx("span",{className:"mono",children:u.changes.removed.join(", ")})]}):null]}),n.jsx("p",{children:"Until you keep this list, the new and changed tools wait; the others keep working."})]}):null,u.slugEditable?n.jsx(te,{label:"Its name in buddi",hint:`Tools are called mcp.${f||"…"}.<tool>. Lower case, letters, digits, _ and -.`,children:n.jsx("input",{required:!0,spellCheck:!1,maxLength:24,value:f,onChange:p=>i(p.target.value.toLowerCase())})}):null,u.tools.length===0?n.jsxs(oe,{children:[e.name," lists no tools."]}):n.jsx("div",{className:"ui-list","aria-label":"Tools",children:u.tools.map(p=>{const v=Yz(p),w=u.slugEditable?p.fullName.replace(/^mcp\.[^.]+\./,`mcp.${f||u.slug}.`):p.fullName;return n.jsx("div",{className:"ui-list-row connections-tool",children:n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("span",{className:"mono",children:w}),p.problem?n.jsx(xe,{tone:"muted",children:"Cannot be used"}):n.jsx(xe,{tone:v.tone,children:v.label}),p.change==="added"?n.jsx(fi,{children:"New"}):p.change==="changed"?n.jsx(fi,{children:"Changed"}):null]}),p.description?n.jsx("p",{className:"ui-card-meta",children:p.description}):null,!p.problem&&p.tier==="gated"?n.jsx("p",{className:"ui-card-meta",children:p.destructive?Gz:"You can remember its approval for an agent when you give it the tools, or later on the agent’s Access page."}):null,p.problem?n.jsxs("p",{className:"ui-card-meta",children:["Left out: ",p.problem,"."]}):null]})},p.name)})}),n.jsx(ne,{message:o}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",onClick:()=>void d(),disabled:a||u.slugEditable&&f.trim()==="",children:m===1?"Keep this tool":`Keep these ${m} tools`})})]})}function s5({connection:e,agents:t,onDone:s}){var k;const r=t.find(g=>g.frontDesk)??t[0],[i,a]=h.useState(()=>new Set(r?[r.id]:[])),o=(((k=ie(()=>A.connectionTools(e.id),[e.id]).data)==null?void 0:k.tools)??[]).filter(g=>g.tier==="gated"),[c,u]=h.useState(()=>new Set),[f,d]=h.useState(!1),[m,p]=h.useState(null),v=(g,x)=>{a(y=>{const j=new Set(y);return x?j.add(g):j.delete(g),j})},w=async()=>{d(!0),p(null);try{const g=await A.grantConnection(e.id,[...i]);if(g.failed.length>0){p(g.failed.map(x=>`${x.agent}: ${x.message}`).join(" "));return}for(const x of g.granted)for(const y of c)await A.setRememberedApproval(x,y,!0);s()}catch(g){p(mo(g))}finally{d(!1)}};return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:[r?`Give these tools to ${r.name}?`:"Which agents get these tools?"," Each one you tick gets ",n.jsx("span",{className:"mono",children:e.grant})," on its tools line."]}),n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Agents",children:t.map(g=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:i.has(g.id),onChange:x=>v(g.id,x.target.checked)}),n.jsxs("span",{children:[g.name,g.frontDesk?" (front desk)":""]})]},g.id))}),n.jsx("p",{className:"ui-card-meta",children:"No one is fine too: the connection waits here until you give it to someone."}),o.length>0?n.jsxs("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Remembered approval",children:[n.jsx("p",{children:"These ask you first. Tick one to remember your approval for the agents above, so it asks only once."}),o.map(g=>n.jsxs(q,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",disabled:!g.rememberable,checked:c.has(g.tool),onChange:x=>u(y=>{const j=new Set(y);return x.target.checked?j.add(g.tool):j.delete(g.tool),j})}),n.jsx("span",{className:"mono",children:g.tool})]}),g.why?n.jsx("p",{className:"ui-card-meta",children:g.why}):null]},g.tool))]}):null,n.jsx(ne,{message:m}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,disabled:f,children:"Not now"}),n.jsx(I,{variant:"accent",onClick:()=>void w(),disabled:f||i.size===0,children:"Give them"})]})]})}function r5({timezone:e,embedded:t}){const{data:s,error:r,reload:i}=ie(()=>A.sentinels(),[],3e4),[a,l]=h.useState(null),[o,c]=h.useState(null),u=(s==null?void 0:s.installed)??[],f=((s==null?void 0:s.runs)??[]).filter(p=>p.lastError),d=u.filter(p=>!p.enabled),m=(p,v)=>{l(p),c(null),A.setSentinelEnabled(p,v).catch(w=>c(w instanceof he?w.message:String(w))).finally(()=>{l(null),i()})};return n.jsxs(mn,{embedded:t,title:"Watchers",children:[n.jsx(ne,{message:r??o}),n.jsx(H,{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."}),f.length>0?n.jsx(H,{tone:"warning",children:f.length===1?"One watcher failed on its last run.":`${f.length} watchers failed on their last run.`}):null,d.length>0?n.jsxs(H,{tone:"warning",children:[d.length===1?"One watcher is off.":`${d.length} watchers are off.`," A watcher that is off does not run, and what it already found stays as it was."]}):null,n.jsx(J,{title:"Installed",aside:n.jsx("a",{href:`${jt}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:s?u.length===0?n.jsx(Ut,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):n.jsx(Ct,{children:u.map(p=>{const v=s.runs.find(w=>w.sentinelId===p.id);return n.jsx(Et,{lead:n.jsx(xe,{tone:p.enabled?v!=null&&v.lastError?"critical":v?"good":void 0:"muted",children:p.enabled?v!=null&&v.lastError?"failed":v?"ok":"never ran":"off"}),title:p.description,sub:`${p.id}, every ${i5(p.every)}${v!=null&&v.lastError?`. ${v.lastError}`:""}`,side:n.jsxs(n.Fragment,{children:[n.jsx("span",{title:v?Ve(v.lastRunAt,e):void 0,children:v?Oe(v.lastRunAt):"never ran"}),n.jsx(I,{size:"sm",disabled:a===p.id,onClick:()=>m(p.id,!p.enabled),children:p.enabled?"Turn off":"Turn on"})]})},p.id)})}):n.jsx(oe,{children:"Loading…"})})]})}function i5(e){if(e%86400===0){const s=e/86400;return s===1?"day":`${s} days`}if(e%3600===0){const s=e/3600;return s===1?"hour":`${s} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}function a5({embedded:e}){const{data:t,error:s,reload:r}=ie(()=>A.owner(),[]);return n.jsxs(mn,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[n.jsx(ne,{message:s}),t?n.jsx(l5,{initial:t,onSaved:r}):null]})}function l5({initial:e,onSaved:t}){const[s,r]=h.useState(e.preferredName??""),[i,a]=h.useState(e.timezone??""),[l,o]=h.useState(e.language??""),[c,u]=h.useState(e.about??""),[f,d]=h.useState(!1),[m,p]=h.useState(!1),[v,w]=h.useState(null);h.useEffect(()=>{r(e.preferredName??""),a(e.timezone??""),o(e.language??""),u(e.about??"")},[e]);const k=s.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||l.trim()!==(e.language??"")||c.trim()!==(e.about??""),g=async()=>{d(!0),w(null);try{await A.setOwner({preferredName:s.trim()===""?null:s.trim(),timezone:i===""?null:i,language:l.trim()===""?null:l.trim(),about:c.trim()===""?null:c.trim()}),p(!0),t()}catch(y){w(y instanceof he?y.message:String(y))}finally{d(!1)}},x=e.zones.length>0?e.zones:[e.detectedTimezone];return n.jsx(J,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:n.jsxs(n.Fragment,{children:[m&&!k?n.jsx("span",{className:"muted",children:"Saved"}):null,n.jsx(I,{variant:"accent",disabled:!k||f,onClick:()=>void g(),children:f?"Saving…":"Save"})]}),children:n.jsxs(q,{divided:!0,gap:"lg",children:[n.jsx(J,{title:"Name and place",children:n.jsxs(sr,{children:[n.jsx(te,{label:"What the agents call you",children:n.jsx("input",{value:s,maxLength:80,placeholder:e.displayName??"Your name",onChange:y=>{p(!1),r(y.target.value)}})}),n.jsx(te,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:n.jsxs("select",{value:i,onChange:y=>{p(!1),a(y.target.value)},children:[n.jsx("option",{value:"",children:"Not set (use the host's)"}),x.map(y=>n.jsx("option",{value:y,children:y},y))]})}),n.jsx(te,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:n.jsx("input",{value:l,maxLength:40,placeholder:"English, français…",onChange:y=>{p(!1),o(y.target.value)}})})]})}),n.jsxs(J,{title:"About you",children:[n.jsx(te,{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:n.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=>{p(!1),u(y.target.value)}})}),v?n.jsx(H,{tone:"critical",children:v}):null]})]})})}const o5=2e6;function Tw(e,t){const s=e.replace(/\r\n/g,`
111
- `).replace(/\n+$/,"").split(`
112
- `),r=t.replace(/\r\n/g,`
113
- `).replace(/\n+$/,"").split(`
114
- `);if(e.trim()===t.trim())return"(no change)";if(s.length*r.length>o5)return[...s.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
115
- `);const i=Array.from({length:s.length+1},()=>new Uint32Array(r.length+1));for(let c=s.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=s[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const a=[];let l=0,o=0;for(;l<s.length&&o<r.length;)s[l]===r[o]?(a.push(` ${s[l]}`),l++,o++):i[l+1][o]>=i[l][o+1]?a.push(`-${s[l++]}`):a.push(`+${r[o++]}`);for(;l<s.length;)a.push(`-${s[l++]}`);for(;o<r.length;)a.push(`+${r[o++]}`);return a.join(`
116
- `)}const c5={skill:"skill",policy:"rule",change:"change to itself"};function u5(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,s])=>!/Id$/.test(t)&&s!==null&&s!==void 0&&s!=="").map(([t,s])=>`${t} ${typeof s=="object"?JSON.stringify(s):String(s)}`).join(" · ")}function pp(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function d5(e,t){const s=e.change;if(!s||s.part!=="tools")return[];if(t===e.editable)return s.added;const r=new Set(pp(s.current??""));return pp(t).filter(i=>!r.has(i))}function Rw(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function h5({embedded:e,plugin:t}){const{data:s,error:r,reload:i}=ie(()=>A.proposals(),[],3e4),[a,l]=h.useState(null),[o,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState({}),p=async(g,x,y=!1)=>{l(null),c(null),f(g),m(({[g]:j,...N})=>N);try{c(await x()),i()}catch(j){const N=j instanceof Error?j.message:String(j);y?m(b=>({...b,[g]:N})):l(N)}finally{f(null)}},v=k1(),w=((s==null?void 0:s.open)??[]).filter(g=>Rw(g,t)),k=((s==null?void 0:s.closed)??[]).filter(g=>Rw(g,t));return n.jsxs(mn,{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:[n.jsx(ne,{message:r??a}),t?n.jsxs(H,{role:"status",children:["Showing the rules ",t," proposes. ",n.jsx("a",{href:tt("proposals"),children:"Show every proposal"})]}):null,o?n.jsx(H,{tone:"good",role:"status",children:o}):null,t?null:n.jsx(S1,{offers:v.offers,reload:v.reload}),!s||w.length===0?n.jsx(J,{title:"Waiting",panel:!0,children:s?t?n.jsx(Ut,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):n.jsx(Ut,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):n.jsx(oe,{children:"Loading…"})}):n.jsx(J,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(g=>n.jsx(g5,{proposal:g,busy:u===g.id,refusal:d[g.id]??null,onKeep:x=>void p(g.id,async()=>{const y=await A.keepProposal(g.id,x);return`${g.title}: ${y.note}`},!0),onDiscard:x=>void p(g.id,async()=>(await A.discardProposal(g.id,x),`Discarded: ${g.title}. ${g.agent} will be told once and will not propose it again for 90 days.`))},g.id))}),k.length>0?n.jsx(J,{title:`Kept, discarded and expired (${k.length})`,aside:"These stop being shown a week after they were decided.",panel:!0,flush:!0,children:n.jsx(Ct,{children:k.map(g=>{var x;return n.jsx(Et,{title:g.title,sub:`${g.agent}: ${f5(g)}`,side:g.kind==="skill"&&g.state==="kept"&&((x=g.skill)!=null&&x.live)?n.jsxs(Q,{align:"end",children:[n.jsx("span",{className:"muted",children:Oe(g.decidedAt??g.createdAt)}),n.jsx(I,{size:"sm",variant:"ghost",disabled:u===g.id,onClick:()=>void p(g.id,async()=>{const y=g.skill;return await A.removeSkill(g.agent,y.name),`Removed ${y.name} from ${g.agent}. Its versions are kept, and ${g.agent} will not propose it again for 90 days.`}),children:"Remove this skill"})]}):Oe(g.decidedAt??g.createdAt)},g.id)})})}):null,!t&&(s!=null&&s.digest)?n.jsx(p5,{schedule:s.digest.schedule,onSaved:i}):null]})}function f5(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 m5=Array.from({length:24},(e,t)=>t),Iw=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function p5({schedule:e,onSaved:t}){const[s,r]=h.useState(e.day),[i,a]=h.useState(e.hour),[l,o]=h.useState(!1),[c,u]=h.useState(null),f=s!==e.day||i!==e.hour,d=async()=>{o(!0),u(null);try{await A.setDigestSchedule(s,i),u({tone:"good",text:`The digest now runs on ${Iw[s]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(m){u({tone:"critical",text:m instanceof Error?m.message:String(m)})}finally{o(!1)}};return n.jsx(J,{title:"Weekly digest",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:l||!f,onClick:()=>void d(),children:"Save"}),children:n.jsxs(q,{children:[n.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: ${Oe(e.next)}.`:""]}),n.jsxs(Q,{children:[n.jsx(te,{label:"Day",children:n.jsx("select",{value:s,disabled:l,onChange:m=>r(Number(m.target.value)),children:Iw.map((m,p)=>n.jsx("option",{value:p,children:m},m))})}),n.jsx(te,{label:`Hour (${e.timezone})`,children:n.jsx("select",{value:i,disabled:l,onChange:m=>a(Number(m.target.value)),children:m5.map(m=>n.jsxs("option",{value:m,children:[String(m).padStart(2,"0"),":00"]},m))})})]}),c?n.jsx(H,{tone:c.tone,role:"status",children:c.text}):null]})})}function Pw(e,t){return e==="tools"?pp(t).join(`
117
- `):t}function g5({proposal:e,busy:t,refusal:s,onKeep:r,onDiscard:i}){const[a,l]=h.useState(e.editable??""),[o,c]=h.useState(""),u=e.editable!==null&&a!==e.editable,f=e.payload,d=e.echoes??[],m=e.kind==="change"?e.change??null:null,p=d5(e,a);return n.jsx(On,{tone:e.untrusted?"warning":"accent",title:e.title,meta:n.jsxs(n.Fragment,{children:[n.jsx(xe,{children:c5[e.kind]}),n.jsx(xe,{mono:!0,children:e.agent}),e.untrusted?n.jsx(xe,{tone:"warning",children:"untrusted text in view"}):null,p.length>0?n.jsx(xe,{tone:"warning",children:"widens its tools"}):null]}),foot:n.jsxs(Q,{align:"end",children:[s?n.jsx("span",{className:"proposal-refusal",role:"alert",children:s}):null,n.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:o,maxLength:300,disabled:t,onChange:v=>c(v.target.value)}),n.jsx(I,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(o.trim()||void 0),children:"Discard"}),n.jsx(I,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&a.trim()==="",onClick:()=>r(u?a:void 0),children:u?"Keep my version":"Keep"})]}),children:n.jsxs(q,{gap:"sm",children:[e.why?n.jsx("p",{children:e.why}):null,n.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",Oe(e.createdAt),e.conversationId?n.jsxs(n.Fragment,{children:[" in ",n.jsx("a",{href:Ta(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?n.jsxs(H,{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.",n.jsx("ul",{className:"proposal-sources",children:e.sources.map(v=>n.jsx("li",{className:"mono",children:v},v))}),d.length>0?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),n.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:d.map(v=>n.jsx("li",{children:n.jsx("mark",{className:"wb-diff-mark",children:v})},v))})]}):null]}):null,e.kind==="skill"?n.jsxs(n.Fragment,{children:[typeof f.when=="string"?n.jsxs("p",{className:"ui-card-meta",children:["When: ",f.when]}):null,e.skill?n.jsxs(q,{gap:"sm",children:[n.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",n.jsxs("a",{href:dt(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),n.jsx(Iu,{text:Tw(e.skill.steps,a),marks:d,label:`Version ${e.skill.version} against this proposal`})]}):null,n.jsx(te,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:n.jsx("textarea",{rows:8,value:a,disabled:t,onChange:v=>l(v.target.value)})})]}):null,e.kind==="change"?n.jsxs(n.Fragment,{children:[p.length>0?n.jsxs(H,{tone:"warning",title:`Adds: ${p.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,m!=null&&m.refusal&&!u?n.jsx(H,{tone:"warning",title:"Keeping this as proposed will be refused.",children:m.refusal}):null,m&&m.current!==null?n.jsx(Iu,{text:Tw(Pw(m.part,m.current),Pw(m.part,a)),marks:d,label:`${e.agent}'s ${m.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof f.before=="string"?n.jsx(Tt,{summary:`What its ${f.part==="tools"?"tool list":"instructions"} said when proposed`,children:n.jsx(Nt,{children:f.before})}):null,n.jsx(te,{label:f.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:n.jsx("textarea",{rows:8,value:a,disabled:t,onChange:v=>l(v.target.value)})})]}):null,e.kind==="policy"?n.jsx(Kt,{items:[{label:"Plugin",value:n.jsx("span",{className:"mono",children:String(f.plugin??"")})},{label:"Matches",value:n.jsx("span",{className:"mono",children:u5(f.matcher??{})})},{label:"Does",value:String(f.action??"")},{label:"Learned from",value:(()=>{const v=Array.isArray(f.verdicts)?f.verdicts.length:0;return`${v} ${v===1?"decision":"decisions"}`})()}]}):null]})})}function x5(e){const t=[{label:"Home",path:e.home}];if(e.path===e.home||!e.path.startsWith(`${e.home}/`))return t;let s=e.home;for(const r of e.path.slice(e.home.length+1).split("/"))s=`${s}/${r}`,t.push({label:r,path:s});return t}function v5({start:e,onPick:t,onClose:s}){const[r,i]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(""),u=(p,v=!1)=>{l(null),A.pluginFolders(p).then(w=>{i(w),c("")}).catch(w=>{v&&p!==void 0?u(void 0):l(w instanceof he?w.message:String(w))})};h.useEffect(()=>{u(e,!0)},[]);const f=o.trim().toLowerCase(),d=((r==null?void 0:r.folders)??[]).filter(p=>f===""||p.name.toLowerCase().includes(f)),m=r?x5(r):[];return n.jsxs(Dt,{title:"Choose the folder",onClose:s,foot:n.jsxs(Q,{children:[n.jsx("span",{className:"plugins-foot-note mono",children:(r==null?void 0:r.path)??""}),n.jsx(sn,{}),n.jsx(I,{variant:"ghost",onClick:s,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!r,onClick:()=>r&&t(r.path),children:"Use this folder"})]}),children:[n.jsx("p",{className:"plugins-note",children:"Folders on the computer buddi runs on, inside your home directory. The one you want holds the plugin's package.json and is already built."}),r?n.jsx(zN,{label:"Folder",items:m.map((p,v)=>v===m.length-1?{key:p.path,label:p.label,current:!0}:{key:p.path,label:p.label,onClick:()=>u(p.path)})}):null,n.jsx(BN,{label:"Find a folder here",value:o,placeholder:"Find a folder here…",onChange:c}),n.jsx(ne,{message:a}),r?d.length===0?n.jsx(oe,{children:f===""?"No folders in here.":`No folder here is called anything like “${o.trim()}”.`}):n.jsx(Ze,{flush:!0,children:n.jsx(Ct,{children:d.map(p=>n.jsx(Et,{onClick:()=>u(p.path),label:`Open ${p.name}`,lead:n.jsx(Dd,{icon:"folder"}),title:p.name,side:p.plugin?n.jsx(xe,{tone:"accent",children:"package.json"}):void 0},p.path))})}):a?null:n.jsx(oe,{children:"Reading the folders…"}),r!=null&&r.truncated?n.jsx("p",{className:"plugins-note",children:"Only the first 500 folders are listed; find one by name above."}):null]})}const j5=1500,y5={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."},w5="Restart buddi to apply it. In a checkout, stop it and run: buddi serve",QC=[{value:"npm",label:"From npm"},{value:"file",label:"A file"},{value:"directory",label:"A directory I built"}],JC="buddi.plugins.install-mode";function b5(){try{const e=window.localStorage.getItem(JC);if(QC.some(t=>t.value===e))return e}catch{}return"npm"}function k5(e){try{window.localStorage.setItem(JC,e)}catch{}}const Nc=".tgz",Ir=(e,t,s)=>`${e} ${e===1?t:s}`;function XC(e){const t=[];return e.tools>0&&t.push(Ir(e.tools,"tool","tools")),e.sentinels>0&&t.push(`${e.sentinels} on a timer`),e.views>0&&t.push(Ir(e.views,"view","views")),e.agents>0&&t.push(`${Ir(e.agents,"agent","agents")} proposed`),t.length===0?"nothing on its own":t.join(", ")}function ZC(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 S5(e){return e.kind==="registry"?"npm":e.kind==="tarball"?"a file":"a directory"}function eE(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function tE(e){return e.author?e.author.name:e.source.kind==="registry"?e.publisher??"nobody npm will name":"you"}function Ux({author:e}){return e.url?n.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:e.name}):n.jsx(n.Fragment,{children:e.name})}function gp({value:e}){return e===void 0||e===""?n.jsx("span",{className:"muted",children:"none — this came off a disk"}):n.jsx("span",{className:"plugins-hash",children:e})}function nE(e){return e.length===0?"none; nothing leaves this computer":n.jsx("span",{className:"mono",children:e.join(", ")})}function Bx(e){return e.length===0?"Nothing beyond its own tables, its own folder and its own tools' approvals.":e.map(t=>`It ${t.words}.`).join(" ")}const Ur=e=>e instanceof he?e.message:String(e);function N5(e){const[t,s]=h.useState(void 0),[r,i]=h.useState(null);return h.useEffect(()=>{if(!e){s(void 0),i(null);return}let a=!1;const l=()=>{A.pluginJob(e).then(c=>{a||(s(c),(c.phase==="done"||c.phase==="failed")&&(a=!0))}).catch(c=>{a||(i(Ur(c)),a=!0)})};l();const o=window.setInterval(l,j5);return()=>{a=!0,window.clearInterval(o)}},[e]),{job:t,error:r}}function C5({plugin:e,pages:t,navigate:s,variant:r}){const i=t.filter(a=>a.plugin===e);return i.length===0?null:n.jsx(n.Fragment,{children:i.map(a=>{const l=_r(a.plugin,a.id);return n.jsx(Yt,{size:"sm",variant:r,href:l,"aria-label":`Open ${a.title}`,onClick:o=>{o.stopPropagation(),s&&(o.preventDefault(),s(l))},children:i.length===1?"Open":`Open ${a.title}`},a.id)})})}function sE({plugin:e}){return e.enabled===!1?n.jsx(xe,{children:"disabled"}):e.loaded?n.jsx(xe,{tone:"good",dot:!0,children:"loaded"}):n.jsx(xe,{tone:"critical",children:"did not load"})}function zx({entry:e}){var t;return e.trust==="by-buddi"?n.jsx(xe,{tone:"accent",children:"by buddi"}):n.jsxs(xe,{tone:"good",children:["reviewed ",((t=e.reviewed)==null?void 0:t.version)??e.version]})}const xp=tt("plugins"),af={installed:xp,browse:`${xp}?tab=browse`};function E5({railPages:e=[],navigate:t,hash:s=""}={}){const r=ie(()=>A.plugins(),[],2e4),[i,a]=h.useState(null),{job:l,error:o}=N5(i),[c,u]=h.useState(null),[f,d]=h.useState(null),[m,p]=h.useState(()=>cy(s));h.useEffect(()=>p(cy(s)),[s]);const[v,w]=h.useState(null),[k,g]=h.useState(null),[x,y]=h.useState(null),[j,N]=h.useState(null),[b,S]=h.useState(!1),C=z=>{S(!0),A.market(z).then(N).catch(se=>N({plugins:[],unavailable:Ur(se)})).finally(()=>S(!1))};h.useEffect(()=>{m==="browse"&&j===null&&!b&&C(!1)},[m]);const R=z=>{u(null),d(null),a(z)},E=z=>u(Ur(z)),[P,F]=h.useState(!1),M=z=>{F(!0),w(null),z.then(se=>{R(se.job.id),p("installed")}).catch(E).finally(()=>F(!1))},T=h.useRef(null);h.useEffect(()=>{const z=pD(s);if(!(z===null||T.current===z)){T.current=z,p("installed"),M(A.stagePlugin(z));try{window.history.replaceState(window.history.state,"",xp)}catch{}}},[s]);const $=z=>se=>{se.preventDefault(),p(z),w(null),t==null||t(af[z])};h.useEffect(()=>{((l==null?void 0:l.phase)==="done"||(l==null?void 0:l.phase)==="failed")&&r.reload()},[l==null?void 0:l.phase]);const _=r.data,K=(_==null?void 0:_.checkout)??!0,D=(_==null?void 0:_.installed)??[],Y=z=>j==null?void 0:j.plugins.find(se=>se.installed!==void 0&&(se.installed.name??se.name)===z.name),B=z=>e.some(se=>se.plugin===z),V=(z,se)=>B(z)?n.jsx(C5,{plugin:z,pages:e,navigate:t,variant:se}):void 0,de=z=>{const se=e.find(Ae=>Ae.plugin===z);se&&t&&t(_r(se.plugin,se.id))},ae=((j==null?void 0:j.plugins)??[]).filter(z=>z.update).length,le=(z,se)=>A.setPluginEnabled(z,se).then(Ae=>{X_(),y({name:z,notes:Ae.notes??[]}),r.reload()}),Ce=(z,se,Ae)=>A.uninstallPlugin(z,se?{purge:!0,confirm:Ae}:{}).then(Me=>{w(null),y({name:z,notes:Me.notes??[]}),r.reload()}),ee=z=>{u(null),le(z,!0).catch(E)},ce=(z,se)=>M(A.updatePlugin(z,se)),fe=n.jsxs(Ao,{label:"Plugins",children:[n.jsx(Ra,{href:af.installed,active:m==="installed",count:ae,onClick:$("installed"),children:"Installed"}),n.jsx(Ra,{href:af.browse,active:m==="browse",onClick:$("browse"),children:"Browse"})]}),je=(v==null?void 0:v.kind)==="installed"?D.find(z=>z.name===v.name):void 0,X=(v==null?void 0:v.kind)==="market"?j==null?void 0:j.plugins.find(z=>z.name===v.name):void 0,be=x&&!(je&&je.name===x.name)&&x.notes.length>0?x.notes:null,Ee=je?n.jsx(O5,{plugin:je,listing:Y(je),notes:(x==null?void 0:x.name)===je.name?x.notes:null,canOpen:B(je.name)&&je.enabled!==!1,onOpen:()=>de(je.name),onClose:()=>w(null),onDisable:()=>g({kind:"disable",name:je.name}),onEnable:()=>ee(je.name),onRemove:()=>g({kind:"remove",name:je.name}),onUpdate:z=>ce(je.name,z),busy:P}):X?n.jsx(H5,{entry:X,canOpen:X.installed!==void 0&&B(X.installed.name??X.name),onOpen:()=>{var z;return de(((z=X.installed)==null?void 0:z.name)??X.name)},onClose:()=>w(null),onInstall:()=>M(A.stagePlugin(`${X.npm}@${X.version}`)),onUpdate:z=>{var se;return ce(((se=X.installed)==null?void 0:se.name)??X.name,z)},busy:P}):null,qe=k?D.find(z=>z.name===k.name):void 0,Ie=k?n.jsx(_5,{kind:k.kind,name:k.name,canDisable:(qe==null?void 0:qe.enabled)!==!1,onCancel:()=>g(null),onDisableInstead:()=>g({kind:"disable",name:k.name}),onDisable:()=>le(k.name,!1).then(()=>g(null)),onRemove:(z,se)=>Ce(k.name,z,se).then(()=>g(null))},`${k.kind}:${k.name}`):null;if(m==="browse")return n.jsxs(q,{gap:"lg",children:[fe,n.jsx(ne,{message:c}),n.jsx(V5,{market:j,loading:b,busy:P,onRetry:()=>C(!0),onOpen:z=>w({kind:"market",name:z.name}),onInstall:z=>M(A.stagePlugin(`${z.npm}@${z.version}`)),onUpdate:(z,se)=>{var Ae;return ce(((Ae=z.installed)==null?void 0:Ae.name)??z.name,se)}}),Ee]});const et=(_==null?void 0:_.builtIn)??[];return n.jsxs(q,{gap:"lg",children:[fe,n.jsx(ne,{message:r.error??c??o}),_!=null&&_.unavailable?n.jsx(H,{tone:"warning",children:_.unavailable}):null,be?n.jsx(H,{role:"status",children:be.join(" ")}):null,n.jsx(A5,{trust:(_==null?void 0:_.trust)??"",job:l,busy:l!==void 0&&l.phase!=="done"&&l.phase!=="failed",onStaged:R,onFailed:u}),((_==null?void 0:_.staged)??[]).map(z=>n.jsx(R5,{staged:z,onInstalled:se=>{d(se),a(null),r.reload()},onGone:()=>r.reload()},z.id)),f||_!=null&&_.restartNeeded?n.jsx(I5,{checkout:K,name:f}):null,n.jsx(Ze,{flush:!0,title:"Installed",tool:_?Ir(D.length,"plugin","plugins"):void 0,children:_?D.length===0?n.jsx(oe,{children:"Nothing installed yet. Only what buddi ships with is here."}):n.jsx("div",{className:"plugins-rows",children:n.jsx(Ct,{children:D.map(z=>n.jsx(M5,{plugin:z,listing:Y(z),open:z.enabled===!1?void 0:V(z.name,"ghost"),canOpen:B(z.name)&&z.enabled!==!1,busy:P,onDetails:()=>w({kind:"installed",name:z.name}),onOpen:()=>de(z.name),onDisable:()=>g({kind:"disable",name:z.name}),onEnable:()=>ee(z.name),onRemove:()=>g({kind:"remove",name:z.name}),onUpdate:se=>ce(z.name,se)},z.name))})}):n.jsx(oe,{children:"Loading…"})}),et.length>0?n.jsx(L5,{plugins:et,openFor:V}):null,Ee,Ie]})}function A5({trust:e,job:t,busy:s,onStaged:r,onFailed:i}){const[a,l]=h.useState(b5),[o,c]=h.useState(""),[u,f]=h.useState(!1),[d,m]=h.useState(null),[p,v]=h.useState(null),[w,k]=h.useState(!1),[g,x]=h.useState(!1),y=h.useRef(null),j=C=>i(Ur(C)),N=C=>{l(C),k5(C),v(null)},b=()=>{f(!0),A.stagePlugin(o.trim()).then(C=>{r(C.job.id),c("")}).catch(j).finally(()=>f(!1))},S=C=>{if(C){if(!C.name.toLowerCase().endsWith(Nc)){m(null),v(`${C.name} is not a ${Nc}. A packed plugin is the file npm pack writes.`);return}v(null),m(C.name),f(!0),A.uploadPlugin(C).then(R=>r(R.job.id)).catch(j).finally(()=>f(!1))}};return n.jsxs(Ze,{title:"Add a plugin",actions:n.jsx(Ys,{label:"Where it comes from",options:QC,value:a,onChange:N}),children:[n.jsxs("div",{className:"plugins-add",children:[a==="file"?n.jsxs("div",{className:"plugins-drop",role:"group","aria-label":"A plugin file","data-state":w?"over":p?"refused":d?"chosen":void 0,onDragOver:C=>{C.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:C=>{var R,E;C.preventDefault(),k(!1),S((E=(R=C.dataTransfer)==null?void 0:R.files)==null?void 0:E[0])},children:[n.jsx(Se,{name:"drop",size:20}),n.jsx("span",{className:"plugins-drop-text",children:p??(d?`${d} — reading it.`:n.jsxs(n.Fragment,{children:["Drop a ",n.jsx("span",{className:"mono",children:Nc})," here: the file ",n.jsx("span",{className:"mono",children:"npm pack"})," ","writes. It is read the moment it lands."]}))}),n.jsx(I,{variant:"accent",disabled:s||u,onClick:()=>{var C;return(C=y.current)==null?void 0:C.click()},children:"Choose a file"}),n.jsx("input",{ref:y,type:"file",accept:Nc,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:C=>{var R;S((R=C.target.files)==null?void 0:R[0]),C.target.value=""}})]}):n.jsxs("div",{className:"plugins-add-row",children:[n.jsxs(Q,{valign:"end",children:[n.jsx(te,{grow:!0,label:a==="npm"?"Package":"The directory it is in",children:n.jsx("input",{type:"text",value:o,placeholder:a==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:C=>c(C.target.value)})}),a==="directory"?n.jsx(I,{onClick:()=>x(!0),children:"Browse…"}):null,n.jsx(I,{variant:"accent",disabled:s||u||o.trim()==="",onClick:b,children:"Read it first"})]}),n.jsx("span",{className:"ui-field-hint",children:a==="npm"?"A package name, or a name@version. Reading fetches it and hashes it; nothing of it runs.":"The folder with its package.json, already built. Nothing of it runs until you say yes."})]}),t?n.jsxs("p",{className:"plugins-status",role:"status","data-tone":t.phase==="failed"?"critical":void 0,children:[y5[t.phase]," ",t.error??""]}):null,n.jsx("div",{className:"plugins-trust",children:n.jsx(H,{tone:"warning",children:e})})]}),g?n.jsx(v5,{start:o.trim().startsWith("/")?o.trim():void 0,onClose:()=>x(!1),onPick:C=>{c(C),x(!1)}}):null]})}function T5({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],s=((i=e.uses)==null?void 0:i.dropped)??[];return n.jsxs("span",{className:"plugins-uses",children:[t.length===0?Bx([]):t.map(a=>n.jsxs("span",{children:["It ",a.words,". ",a.added?n.jsxs(xe,{tone:"warning",children:["new in ",e.version]}):null]},a.use)),s.length>0?n.jsxs("span",{className:"muted",children:["No longer: ",s.map(a=>a.words).join("; "),"."]}):null]})}function R5({staged:e,onInstalled:t,onGone:s}){const[r,i]=h.useState(e.plan??null),[a,l]=h.useState(!1),[o,c]=h.useState(null),u=p=>{l(!0),c(null),A.approveStaged(e.id,{integrity:e.integrity??"",...p?{acknowledgeDrift:!0}:{}}).then(v=>{v.installed?t(e.name):v.plan&&i(v.plan)}).catch(v=>c(Ur(v))).finally(()=>l(!1))},f=()=>{l(!0),c(null),A.rejectStaged(e.id).then(()=>s()).catch(p=>c(Ur(p))).finally(()=>l(!1))},d=(r==null?void 0:r.drift)??[],m=e.dependencies;return n.jsxs(q,{gap:"sm",children:[n.jsxs(On,{tone:"accent",title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"plugins-ver",children:e.version})]}),meta:n.jsx(xe,{children:"read, not installed"}),foot:n.jsxs(Q,{children:[n.jsx("span",{className:"plugins-foot-note",children:"Nothing of it has run."}),n.jsx(sn,{}),n.jsx(I,{variant:"ghost",disabled:a,onClick:f,children:"Not this one"}),n.jsx(I,{variant:"accent",disabled:a||d.length>0,onClick:()=>u(!1),children:"Install"})]}),children:[n.jsx(ne,{message:o}),n.jsxs("div",{className:"plugins-staged",children:[n.jsx("div",{className:"plugins-facts",children:n.jsx(Kt,{items:[...e.author?[{label:"By",value:n.jsx(Ux,{author:e.author})}]:[],{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:ZC(e.source)},{label:"Published by",value:eE(e.source,e.publisher)},...e.source.kind==="directory"?[]:[{label:"Installs as",value:e.installsAs?n.jsx("span",{className:"mono",children:e.installsAs}):"the name its manifest gives, read when you approve — it declares no buddi.name"}],...e.coreAsDependency?[{label:"Core",value:"It asks npm for buddi's core; buddi provides its own."}]:[],{label:"Dependencies",value:m.count===0?"none":`${m.count}${m.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${m.withScripts.join(", ")}`}`},{label:"What it reaches",value:n.jsx(T5,{staged:e})},{label:"Integrity",value:n.jsx(gp,{value:e.integrity})},...e.stagedHash?[{label:"Files on disk",value:n.jsx(gp,{value:e.stagedHash})}]:[]]})}),n.jsxs("div",{className:"plugins-claim",children:[n.jsx("div",{className:"plugins-claim-head",children:"What it says about itself"}),n.jsx("div",{className:"plugins-claim-note",children:"From its own buddi.md. Nothing has checked it yet."}),e.claims.missing?n.jsx("p",{className:"plugins-claim-text",children:"It ships no buddi.md, so it says nothing about itself at all."}):n.jsxs("p",{className:"plugins-claim-text",children:["“",e.claims.text,"”"]}),n.jsx("div",{className:"plugins-facts",children:n.jsx(Kt,{items:[{label:"Schema it owns",value:e.claims.schema?n.jsx("span",{className:"mono",children:e.claims.schema}):"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":n.jsx("span",{className:"mono",children:e.claims.hosts.join(", ")})}]})})]})]})]}),d.length>0?n.jsxs(On,{tone:"warning",title:"What it said, and what it does",meta:n.jsx(xe,{tone:"warning",children:"read this first"}),foot:n.jsxs(Q,{children:[n.jsx("span",{className:"plugins-foot-note",children:"Install anyway says you read these."}),n.jsx(sn,{}),n.jsx(I,{variant:"ghost",disabled:a,onClick:f,children:"Not this one"}),n.jsx(I,{variant:"danger",disabled:a,onClick:()=>u(!0),children:"Install anyway"})]}),children:[n.jsx("p",{className:"plugins-note",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),n.jsx("ul",{className:"plugins-drift",children:d.map(p=>n.jsx("li",{children:p},p))}),n.jsx(rE,{unlocks:(r==null?void 0:r.agents)??[]})]}):null]})}function I5({checkout:e,name:t}){const[s,r]=h.useState(!1),[i,a]=h.useState(null),l=t?`${t} is installed.`:"A plugin was installed, disabled or enabled since buddi started, and this buddi has not caught up.";return n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:i}),n.jsxs(H,{tone:e?"warning":"accent",role:"status",action:e?void 0:n.jsx(I,{size:"sm",variant:"accent",disabled:s,onClick:()=>{r(!0),a(null),A.serviceAction("restart").catch(o=>a(Ur(o))).finally(()=>r(!1))},children:"Restart to load it"}),children:[l," ",e?w5:`${t?"Its tools appear":"It takes effect"} once buddi restarts. That closes this dashboard for a few seconds.`]})]})}const vp=e=>t=>{t.stopPropagation(),e()},P5=e=>e.unlocks.filter(t=>t.drift.state==="not-accepted").length;function M5({plugin:e,listing:t,open:s,canOpen:r,busy:i,onDetails:a,onOpen:l,onDisable:o,onEnable:c,onRemove:u,onUpdate:f}){const d=e.enabled===!1,m=P5(e);return n.jsx(Et,{onClick:a,label:`${e.name}: details`,dimmed:d,lead:n.jsx(Dd,{svg:t==null?void 0:t.iconSvg}),title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"plugins-ver",children:e.version}),m>0?n.jsxs("span",{className:"plugins-ask",children:[Ir(m,"agent","agents")," to accept"]}):null]}),sub:`by ${tE(e)} · from ${S5(e.source)} · ${XC(e.contribution)}`,side:n.jsxs("span",{className:"plugins-side",children:[t!=null&&t.update?n.jsxs(I,{size:"sm",disabled:i,onClick:vp(()=>f(t.update)),children:["Update to ",t.update]}):null,s,n.jsx(sE,{plugin:e}),n.jsx(n_,{label:`More for ${e.name}`,items:[{label:"Details",onSelect:a},r?{label:"Open its page",onSelect:l}:null,d?{label:"Enable",hint:"all of it comes back",onSelect:c}:{label:"Disable…",hint:"keeps its data",onSelect:o},"separator",{label:"Remove…",tone:"critical",onSelect:u}]})]})})}const $5={"not-accepted":["warning","not accepted"],"up-to-date":["good","up to date"],"owner-edited":["accent","yours, edited"],"proposal-changed":["warning","proposal changed"],"owner-edited-and-proposal-changed":["warning","edited, and changed"],gone:[void 0,"gone"]};function rE({plugin:e,unlocks:t}){return t.length===0?null:n.jsxs(J,{title:"Agents it would unlock",children:[n.jsx("div",{className:"plugins-unlocks",children:n.jsx(Ct,{children:t.map(s=>n.jsx(D5,{plugin:e,unlock:s},s.id))})}),n.jsxs("p",{className:"plugins-note",children:["Nothing here is created by installing. Accept creates the agent with the tools listed; change or remove it"," ",n.jsx("a",{href:ut,children:"on the Agents page"}),"."]})]})}function D5({plugin:e,unlock:t}){const s=kx(e,t.id),r=s.created?"up-to-date":t.drift.state,[i,a]=$5[r];return n.jsxs("div",{className:"plugins-unlock",children:[n.jsx(Et,{title:n.jsxs("span",{className:"plugins-handle",children:["@",t.handle]}),sub:s.created?"Accepted just now. It is on the Agents page.":t.drift.message,side:n.jsxs("span",{className:"plugins-side",children:[n.jsx(xe,{tone:i,children:a}),e&&r==="not-accepted"?n.jsx(I,{size:"sm",variant:"accent",disabled:s.busy,onClick:s.accept,children:"Accept"}):null]})}),n.jsx(ne,{message:s.failure}),s.created?n.jsx(w1,{agent:s.created}):null]})}function iE({svg:e,name:t,version:s,by:r,pills:i}){return n.jsxs("span",{className:"plugins-sheet-title",children:[n.jsx(Dd,{svg:e,size:"lg"}),n.jsxs("span",{className:"plugins-sheet-name",children:[n.jsxs("span",{children:[t," ",n.jsx("span",{className:"plugins-ver",children:s})]}),n.jsxs("span",{className:"plugins-sheet-by",children:["by ",r,i]})]})]})}function O5({plugin:e,listing:t,notes:s,canOpen:r,busy:i,onOpen:a,onClose:l,onDisable:o,onEnable:c,onRemove:u,onUpdate:f}){var k,g;const d=e.enabled===!1,m=e.author!==void 0&&e.source.kind==="directory",p=(t==null?void 0:t.summary)??e.description,v=(e.network??((g=(k=t==null?void 0:t.claims)==null?void 0:k.manifest)==null?void 0:g.network)??[]).map(x=>x.host),w=e.uses??(t==null?void 0:t.usesWords);return n.jsxs(Dt,{title:n.jsx(iE,{svg:t==null?void 0:t.iconSvg,name:e.name,version:e.version,by:e.author?n.jsx(Ux,{author:e.author}):tE(e),pills:n.jsxs(n.Fragment,{children:[t?n.jsxs(n.Fragment,{children:[" · ",n.jsx(zx,{entry:t})]}):null," · ",n.jsx(sE,{plugin:e})]})}),onClose:l,foot:n.jsxs(Q,{children:[n.jsx(I,{variant:"danger-ghost",onClick:u,children:"Remove…"}),n.jsx(sn,{}),r?n.jsx(I,{onClick:a,children:"Open"}):null,d?n.jsx(I,{onClick:c,children:"Enable"}):n.jsx(I,{variant:"ghost",onClick:o,children:"Disable…"}),t!=null&&t.update?n.jsxs(I,{variant:"accent",disabled:i,onClick:()=>f(t.update),children:["Update to ",t.update]}):n.jsx(I,{disabled:i,onClick:()=>f(),children:"Check for an update"})]}),children:[e.error?n.jsx(H,{tone:"critical",children:e.error}):null,s&&s.length>0?n.jsx(H,{role:"status",children:s.join(" ")}):null,d?n.jsx(H,{children:"Disabled: its tools, pages and watchers are off and its missions are paused. Its data is kept."}):null,p?n.jsx("p",{className:"plugins-summary-full",children:p}):null,n.jsx("div",{className:"plugins-facts",children:n.jsx(Kt,{items:[{label:"From",value:ZC(e.source)},...m?[]:[{label:"Published by",value:eE(e.source,e.publisher)}],{label:"Integrity",value:n.jsx(gp,{value:e.integrity})},{label:"Installed",value:Oe(e.installedAt)},{label:"Contributes",value:XC(e.contribution)},...e.network||t?[{label:"Talks to hosts",value:nE(v)}]:[],...w?[{label:"Reaches in buddi",value:Bx(w)}]:[]]})}),n.jsx(rE,{plugin:e.name,unlocks:e.unlocks})]})}function _5({kind:e,name:t,canDisable:s,onCancel:r,onDisableInstead:i,onDisable:a,onRemove:l}){const[o,c]=h.useState(!1),[u,f]=h.useState(""),[d,m]=h.useState(!1),[p,v]=h.useState(null),w=g=>{m(!0),v(null),g().catch(x=>v(Ur(x))).finally(()=>m(!1))};if(e==="disable")return n.jsxs(Ay,{title:`Disable ${t}?`,onClose:r,foot:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",disabled:d,onClick:r,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:d,onClick:()=>w(a),children:"Disable"})]}),children:[n.jsx("p",{className:"plugins-dialog-text",children:"Its tools, pages and watchers stop now and its missions pause. Its data and the agents you accepted from it are kept; enable it to have it all back."}),n.jsx(ne,{message:p})]});const k=!o||u.trim()===t;return n.jsxs(Ay,{title:`Remove ${t}?`,onClose:r,foot:n.jsxs(n.Fragment,{children:[s?n.jsx(I,{variant:"ghost",size:"sm",disabled:d,onClick:i,children:"Disable instead"}):null,n.jsx(sn,{}),n.jsx(I,{variant:"ghost",disabled:d,onClick:r,children:"Cancel"}),n.jsx(I,{variant:"danger",disabled:d||!k,onClick:()=>w(()=>l(o,u.trim())),children:o?"Remove and drop its data":"Remove"})]}),children:[n.jsxs("p",{className:"plugins-dialog-text",children:["This takes ",t," off this machine and stops its code loading. Its tables and the agents you accepted from it stay."]}),n.jsxs("div",{className:"plugins-purge","data-on":o?"true":void 0,children:[n.jsxs("label",{className:"plugins-check",children:[n.jsx("input",{type:"checkbox",checked:o,onChange:g=>{c(g.target.checked),f("")}}),n.jsxs("span",{children:[n.jsx("span",{className:"plugins-check-title",children:"Also drop its data"}),n.jsx("span",{className:"plugins-check-hint",children:"Its tables are gone for good; there is no undo."})]})]}),o?n.jsx(te,{label:n.jsxs(n.Fragment,{children:["Type ",n.jsx("span",{className:"mono",children:t})," to confirm"]}),children:n.jsx("input",{autoFocus:!0,value:u,onChange:g=>f(g.target.value)})}):null]}),n.jsx(ne,{message:p})]})}function L5({plugins:e,openFor:t}){return n.jsxs(Tt,{boxed:!0,summary:`Ships with buddi · ${Ir(e.length,"plugin","plugins")}`,children:[n.jsx("p",{className:"plugins-note",children:"Compiled into this buddi: nothing to approve, nothing to remove. An agent still reaches one only if its own tools line names it."}),n.jsx("div",{className:"plugins-builtins",children:e.map(s=>{const r=(s.network??[]).map(a=>a.host),i=[s.description,s.author?`By ${s.author.name}.`:null,r.length>0?`Talks to ${r.join(", ")}.`:null].filter(Boolean).join(" ");return n.jsxs("div",{className:"plugins-builtin",title:i||void 0,children:[n.jsx("span",{className:"mono",children:s.name}),n.jsxs("span",{className:"plugins-builtin-n",children:[t(s.name,"ghost"),Ir(s.contribution.tools,"tool","tools")]})]},s.name)})})]})}const F5=[{value:"days",label:"Your days"},{value:"money",label:"Money"},{value:"voice",label:"Voice"},{value:"work",label:"Work"},{value:"home",label:"Home"},{value:"other",label:"Other"}];function U5(e,t){const s=t.trim().toLowerCase();return s===""?!0:[e.title,e.summary,e.npm].some(r=>r.toLowerCase().includes(s))}function B5({pricing:e}){return e.kind==="free"?n.jsx(n.Fragment,{children:"free"}):n.jsxs(n.Fragment,{children:[e.kind==="paid"?"paid":"a subscription",e.trialDays?` · ${e.trialDays} days to try`:"",e.note?` · ${e.note}`:"",e.vendor?n.jsxs(n.Fragment,{children:[" · ",n.jsx("a",{href:e.vendor,target:"_blank",rel:"noopener noreferrer",children:"its maker's page"})]}):null]})}function z5({entry:e,busy:t,onOpen:s,onInstall:r,onUpdate:i}){var a;return n.jsxs(On,{onClick:s,label:`${e.title}: details`,children:[n.jsxs("div",{className:"plugins-card-head",children:[n.jsx(Dd,{svg:e.iconSvg,size:"lg"}),n.jsxs("div",{className:"plugins-card-name",children:[n.jsx("h3",{className:"ui-card-title",children:e.title}),n.jsxs("div",{className:"plugins-card-by",children:["by ",((a=e.author)==null?void 0:a.name)??"someone who gave no name"]})]})]}),n.jsx("p",{className:"plugins-summary",children:e.summary}),n.jsxs("div",{className:"plugins-card-foot",children:[n.jsx(zx,{entry:e}),e.installed?n.jsxs(xe,{children:["installed ",e.installed.version]}):null,n.jsx(sn,{}),e.update?n.jsxs(I,{size:"sm",disabled:t,onClick:vp(()=>i(e.update)),children:["Update to ",e.update]}):e.installed?null:n.jsx(I,{size:"sm",variant:"accent",disabled:t,onClick:vp(r),children:"Install"})]})]})}function W5(e){var o,c;const t=(o=e.claims)==null?void 0:o.manifest,s=t==null?void 0:t.tools;if(!s)return;const r=s.filter(u=>u.tier==="auto").length,i=s.length-r,a=((c=t==null?void 0:t.sentinels)==null?void 0:c.length)??0,l=[r>0?`${r} run without asking`:null,i>0?`${i} ask${i===1?"s":""} you first`:null,a>0?`${a} on a timer`:null].filter(Boolean);return l.length===0?"none":l.join(", ")}function H5({entry:e,canOpen:t,busy:s,onOpen:r,onClose:i,onInstall:a,onUpdate:l}){var m,p,v,w,k,g,x,y;const o=(m=e.screenshots)==null?void 0:m[0],c=(((v=(p=e.claims)==null?void 0:p.manifest)==null?void 0:v.network)??[]).map(j=>j.host),u=W5(e),f=((g=(k=(w=e.claims)==null?void 0:w.manifest)==null?void 0:k.agents)==null?void 0:g.length)??0,d=(y=(x=e.claims)==null?void 0:x.package)==null?void 0:y.dependencies;return n.jsxs(Dt,{title:n.jsx(iE,{svg:e.iconSvg,name:e.title,version:e.version,by:e.author?n.jsx(Ux,{author:e.author}):"someone who gave no name",pills:n.jsxs(n.Fragment,{children:[" · ",n.jsx(zx,{entry:e}),e.installed?n.jsxs(n.Fragment,{children:[" · ",n.jsxs(xe,{children:["installed ",e.installed.version]})]}):null]})}),onClose:i,foot:n.jsxs(Q,{children:[n.jsx("span",{className:"plugins-foot-note",children:e.installed&&!e.update?"This is the version you have.":"Install reads it first. Nothing of it runs until you say yes."}),n.jsx(sn,{}),t?n.jsx(I,{onClick:r,children:"Open"}):null,e.update?n.jsxs(I,{variant:"accent",disabled:s,onClick:()=>l(e.update),children:["Update to ",e.update]}):e.installed?null:n.jsx(I,{variant:"accent",disabled:s,onClick:a,children:"Install"})]}),children:[o?n.jsx("img",{className:"plugins-shot",src:A.marketAssetUrl(o),alt:`${e.title}, as it looks in buddi`}):null,n.jsx("p",{className:"plugins-summary-full",children:e.summary}),n.jsx("div",{className:"plugins-facts",children:n.jsx(Kt,{items:[{label:"Package",value:n.jsx("span",{className:"mono",children:`${e.npm}@${e.version}`})},...u?[{label:"Tools",value:u}]:[],...f>0?[{label:"Proposes",value:`${Ir(f,"agent","agents")}, created only if you accept`}]:[],{label:"Talks to hosts",value:nE(c)},{label:"Reaches in buddi",value:Bx(e.usesWords??[])},...d?[{label:"Dependencies",value:d.count===0?"none":`${d.count}${d.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${d.withScripts.join(", ")}`}`}]:[],{label:"Licence",value:n.jsxs(n.Fragment,{children:[e.license??"not stated"," · ",n.jsx(B5,{pricing:e.pricing})]})}]})})]})}function V5({market:e,loading:t,busy:s,onRetry:r,onOpen:i,onInstall:a,onUpdate:l}){const[o,c]=h.useState(""),[u,f]=h.useState("all"),d=(e==null?void 0:e.plugins)??[],m=[{value:"all",label:"All"},{value:"recommended",label:"Recommended"},...F5.filter(w=>d.some(k=>k.category===w.value))],p=d.filter(w=>u==="recommended"&&(w.trust!=="by-buddi"||w.installed)||u!=="all"&&u!=="recommended"&&w.category!==u?!1:U5(w,o)),v=o.trim();return n.jsxs(q,{gap:"lg",children:[n.jsxs(Q,{children:[n.jsx(BN,{grow:!0,label:"Search plugins",value:o,placeholder:"Search plugins: weather, money, calendar…",onChange:c}),n.jsx(a_,{label:"Show",options:m,value:u,onChange:f})]}),n.jsxs("p",{className:"plugins-quiet",children:[n.jsx(Se,{name:"globe",size:14}),"Opening this tab fetched the list from withbuddi.com. Nothing else leaves."," ",n.jsx("button",{type:"button",className:"plugins-link",disabled:t,onClick:r,children:"Refresh"})]}),e===null||t&&e.unavailable?n.jsx(oe,{children:"Asking withbuddi.com…"}):e.unavailable?n.jsx(H,{tone:"warning",action:n.jsx(I,{size:"sm",disabled:t,onClick:r,children:"Try again"}),children:e.unavailable}):n.jsxs(n.Fragment,{children:[e.stale?n.jsxs(H,{tone:"warning",action:n.jsx(I,{size:"sm",disabled:t,onClick:r,children:"Try again"}),children:["withbuddi.com did not answer, so this is the list as it was",e.fetchedAt?` ${Oe(e.fetchedAt)}`:" last time","."]}):null,p.length>0?n.jsx("div",{className:"plugins-grid",children:p.map(w=>n.jsx(z5,{entry:w,busy:s,onOpen:()=>i(w),onInstall:()=>a(w),onUpdate:k=>l(w,k)},w.npm))}):n.jsx(oe,{warm:!0,title:"Nothing listed matches",children:v!==""?`No plugin on withbuddi.com mentions “${v}”.`:d.length===0?"withbuddi.com lists no plugins yet.":"Nothing on this shelf yet."})]})]})}var Ro={},K5=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},aE={},zn={};let Wx;const G5=[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];zn.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};zn.getSymbolTotalCodewords=function(t){return G5[t]};zn.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};zn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Wx=t};zn.isKanjiModeEnabled=function(){return typeof Wx<"u"};zn.toSJIS=function(t){return Wx(t)};var Fd={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.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: "+s)}}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}}})(Fd);function lE(){this.buffer=[],this.length=0}lE.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 s=0;s<t;s++)this.putBit((e>>>t-s-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 Y5=lE;function Io(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)}Io.prototype.set=function(e,t,s,r){const i=e*this.size+t;this.data[i]=s,r&&(this.reservedBit[i]=!0)};Io.prototype.get=function(e,t){return this.data[e*this.size+t]};Io.prototype.xor=function(e,t,s){this.data[e*this.size+t]^=s};Io.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var q5=Io,oE={};(function(e){const t=zn.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,a=t(r),l=a===145?26:Math.ceil((a-13)/(2*i-2))*2,o=[a-7];for(let c=1;c<i-1;c++)o[c]=o[c-1]-l;return o.push(6),o.reverse()},e.getPositions=function(r){const i=[],a=e.getRowColCoords(r),l=a.length;for(let o=0;o<l;o++)for(let c=0;c<l;c++)o===0&&c===0||o===0&&c===l-1||o===l-1&&c===0||i.push([a[o],a[c]]);return i}})(oE);var cE={};const Q5=zn.getSymbolSize,Mw=7;cE.getPositions=function(t){const s=Q5(t);return[[0,0],[s-Mw,0],[0,s-Mw]]};var uE={};(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 a=i.size;let l=0,o=0,c=0,u=null,f=null;for(let d=0;d<a;d++){o=c=0,u=f=null;for(let m=0;m<a;m++){let p=i.get(d,m);p===u?o++:(o>=5&&(l+=t.N1+(o-5)),u=p,o=1),p=i.get(m,d),p===f?c++:(c>=5&&(l+=t.N1+(c-5)),f=p,c=1)}o>=5&&(l+=t.N1+(o-5)),c>=5&&(l+=t.N1+(c-5))}return l},e.getPenaltyN2=function(i){const a=i.size;let l=0;for(let o=0;o<a-1;o++)for(let c=0;c<a-1;c++){const u=i.get(o,c)+i.get(o,c+1)+i.get(o+1,c)+i.get(o+1,c+1);(u===4||u===0)&&l++}return l*t.N2},e.getPenaltyN3=function(i){const a=i.size;let l=0,o=0,c=0;for(let u=0;u<a;u++){o=c=0;for(let f=0;f<a;f++)o=o<<1&2047|i.get(u,f),f>=10&&(o===1488||o===93)&&l++,c=c<<1&2047|i.get(f,u),f>=10&&(c===1488||c===93)&&l++}return l*t.N3},e.getPenaltyN4=function(i){let a=0;const l=i.data.length;for(let c=0;c<l;c++)a+=i.data[c];return Math.abs(Math.ceil(a*100/l/5)-10)*t.N4};function s(r,i,a){switch(r){case e.Patterns.PATTERN000:return(i+a)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(i+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return i*a%2+i*a%3===0;case e.Patterns.PATTERN110:return(i*a%2+i*a%3)%2===0;case e.Patterns.PATTERN111:return(i*a%3+(i+a)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,a){const l=a.size;for(let o=0;o<l;o++)for(let c=0;c<l;c++)a.isReserved(c,o)||a.xor(c,o,s(i,c,o))},e.getBestMask=function(i,a){const l=Object.keys(e.Patterns).length;let o=0,c=1/0;for(let u=0;u<l;u++){a(u),e.applyMask(u,i);const f=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),f<c&&(c=f,o=u)}return o}})(uE);var Ud={};const vr=Fd,Cc=[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],Ec=[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];Ud.getBlocksCount=function(t,s){switch(s){case vr.L:return Cc[(t-1)*4+0];case vr.M:return Cc[(t-1)*4+1];case vr.Q:return Cc[(t-1)*4+2];case vr.H:return Cc[(t-1)*4+3];default:return}};Ud.getTotalCodewordsCount=function(t,s){switch(s){case vr.L:return Ec[(t-1)*4+0];case vr.M:return Ec[(t-1)*4+1];case vr.Q:return Ec[(t-1)*4+2];case vr.H:return Ec[(t-1)*4+3];default:return}};var dE={},Bd={};const Ml=new Uint8Array(512),Hu=new Uint8Array(256);(function(){let t=1;for(let s=0;s<255;s++)Ml[s]=t,Hu[t]=s,t<<=1,t&256&&(t^=285);for(let s=255;s<512;s++)Ml[s]=Ml[s-255]})();Bd.log=function(t){if(t<1)throw new Error("log("+t+")");return Hu[t]};Bd.exp=function(t){return Ml[t]};Bd.mul=function(t,s){return t===0||s===0?0:Ml[Hu[t]+Hu[s]]};(function(e){const t=Bd;e.mul=function(r,i){const a=new Uint8Array(r.length+i.length-1);for(let l=0;l<r.length;l++)for(let o=0;o<i.length;o++)a[l+o]^=t.mul(r[l],i[o]);return a},e.mod=function(r,i){let a=new Uint8Array(r);for(;a.length-i.length>=0;){const l=a[0];for(let c=0;c<i.length;c++)a[c]^=t.mul(i[c],l);let o=0;for(;o<a.length&&a[o]===0;)o++;a=a.slice(o)}return a},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let a=0;a<r;a++)i=e.mul(i,new Uint8Array([1,t.exp(a)]));return i}})(dE);const hE=dE;function Hx(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Hx.prototype.initialize=function(t){this.degree=t,this.genPoly=hE.generateECPolynomial(this.degree)};Hx.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const s=new Uint8Array(t.length+this.degree);s.set(t);const r=hE.mod(s,this.genPoly),i=this.degree-r.length;if(i>0){const a=new Uint8Array(this.degree);return a.set(r,i),a}return r};var J5=Hx,fE={},Yr={},Vx={};Vx.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var Os={};const mE="[0-9]+",X5="[A-Z $%*+\\-./:]+";let po="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";po=po.replace(/u/g,"\\u");const Z5="(?:(?![A-Z0-9 $%*+\\-./:]|"+po+`)(?:.|[\r
118
- ]))+`;Os.KANJI=new RegExp(po,"g");Os.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Os.BYTE=new RegExp(Z5,"g");Os.NUMERIC=new RegExp(mE,"g");Os.ALPHANUMERIC=new RegExp(X5,"g");const e8=new RegExp("^"+po+"$"),t8=new RegExp("^"+mE+"$"),n8=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Os.testKanji=function(t){return e8.test(t)};Os.testNumeric=function(t){return t8.test(t)};Os.testAlphanumeric=function(t){return n8.test(t)};(function(e){const t=Vx,s=Os;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(a,l){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?a.ccBits[0]:l<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return s.testNumeric(a)?e.NUMERIC:s.testAlphanumeric(a)?e.ALPHANUMERIC:s.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.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(a,l){if(e.isValid(a))return a;try{return r(a)}catch{return l}}})(Yr);(function(e){const t=zn,s=Ud,r=Fd,i=Yr,a=Vx,l=7973,o=t.getBCHDigit(l);function c(m,p,v){for(let w=1;w<=40;w++)if(p<=e.getCapacity(w,v,m))return w}function u(m,p){return i.getCharCountIndicator(m,p)+4}function f(m,p){let v=0;return m.forEach(function(w){const k=u(w.mode,p);v+=k+w.getBitsLength()}),v}function d(m,p){for(let v=1;v<=40;v++)if(f(m,v)<=e.getCapacity(v,p,i.MIXED))return v}e.from=function(p,v){return a.isValid(p)?parseInt(p,10):v},e.getCapacity=function(p,v,w){if(!a.isValid(p))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=i.BYTE);const k=t.getSymbolTotalCodewords(p),g=s.getTotalCodewordsCount(p,v),x=(k-g)*8;if(w===i.MIXED)return x;const y=x-u(w,p);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(p,v){let w;const k=r.from(v,r.M);if(Array.isArray(p)){if(p.length>1)return d(p,k);if(p.length===0)return 1;w=p[0]}else w=p;return c(w.mode,w.getLength(),k)},e.getEncodedBits=function(p){if(!a.isValid(p)||p<7)throw new Error("Invalid QR Code version");let v=p<<12;for(;t.getBCHDigit(v)-o>=0;)v^=l<<t.getBCHDigit(v)-o;return p<<12|v}})(fE);var pE={};const jp=zn,gE=1335,s8=21522,$w=jp.getBCHDigit(gE);pE.getEncodedBits=function(t,s){const r=t.bit<<3|s;let i=r<<10;for(;jp.getBCHDigit(i)-$w>=0;)i^=gE<<jp.getBCHDigit(i)-$w;return(r<<10|i)^s8};var xE={};const r8=Yr;function Ma(e){this.mode=r8.NUMERIC,this.data=e.toString()}Ma.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Ma.prototype.getLength=function(){return this.data.length};Ma.prototype.getBitsLength=function(){return Ma.getBitsLength(this.data.length)};Ma.prototype.write=function(t){let s,r,i;for(s=0;s+3<=this.data.length;s+=3)r=this.data.substr(s,3),i=parseInt(r,10),t.put(i,10);const a=this.data.length-s;a>0&&(r=this.data.substr(s),i=parseInt(r,10),t.put(i,a*3+1))};var i8=Ma;const a8=Yr,lf=["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 $a(e){this.mode=a8.ALPHANUMERIC,this.data=e}$a.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};$a.prototype.getLength=function(){return this.data.length};$a.prototype.getBitsLength=function(){return $a.getBitsLength(this.data.length)};$a.prototype.write=function(t){let s;for(s=0;s+2<=this.data.length;s+=2){let r=lf.indexOf(this.data[s])*45;r+=lf.indexOf(this.data[s+1]),t.put(r,11)}this.data.length%2&&t.put(lf.indexOf(this.data[s]),6)};var l8=$a;const o8=Yr;function Da(e){this.mode=o8.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Da.getBitsLength=function(t){return t*8};Da.prototype.getLength=function(){return this.data.length};Da.prototype.getBitsLength=function(){return Da.getBitsLength(this.data.length)};Da.prototype.write=function(e){for(let t=0,s=this.data.length;t<s;t++)e.put(this.data[t],8)};var c8=Da;const u8=Yr,d8=zn;function Oa(e){this.mode=u8.KANJI,this.data=e}Oa.getBitsLength=function(t){return t*13};Oa.prototype.getLength=function(){return this.data.length};Oa.prototype.getBitsLength=function(){return Oa.getBitsLength(this.data.length)};Oa.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let s=d8.toSJIS(this.data[t]);if(s>=33088&&s<=40956)s-=33088;else if(s>=57408&&s<=60351)s-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
119
- Make sure your charset is UTF-8`);s=(s>>>8&255)*192+(s&255),e.put(s,13)}};var h8=Oa,vE={exports:{}};(function(e){var t={single_source_shortest_paths:function(s,r,i){var a={},l={};l[r]=0;var o=t.PriorityQueue.make();o.push(r,0);for(var c,u,f,d,m,p,v,w,k;!o.empty();){c=o.pop(),u=c.value,d=c.cost,m=s[u]||{};for(f in m)m.hasOwnProperty(f)&&(p=m[f],v=d+p,w=l[f],k=typeof l[f]>"u",(k||w>v)&&(l[f]=v,o.push(f,v),a[f]=u))}if(typeof i<"u"&&typeof l[i]>"u"){var g=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(g)}return a},extract_shortest_path_from_predecessor_list:function(s,r){for(var i=[],a=r;a;)i.push(a),s[a],a=s[a];return i.reverse(),i},find_path:function(s,r,i){var a=t.single_source_shortest_paths(s,r,i);return t.extract_shortest_path_from_predecessor_list(a,i)},PriorityQueue:{make:function(s){var r=t.PriorityQueue,i={},a;s=s||{};for(a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);return i.queue=[],i.sorter=s.sorter||r.default_sorter,i},default_sorter:function(s,r){return s.cost-r.cost},push:function(s,r){var i={value:s,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})(vE);var f8=vE.exports;(function(e){const t=Yr,s=i8,r=l8,i=c8,a=h8,l=Os,o=zn,c=f8;function u(g){return unescape(encodeURIComponent(g)).length}function f(g,x,y){const j=[];let N;for(;(N=g.exec(y))!==null;)j.push({data:N[0],index:N.index,mode:x,length:N[0].length});return j}function d(g){const x=f(l.NUMERIC,t.NUMERIC,g),y=f(l.ALPHANUMERIC,t.ALPHANUMERIC,g);let j,N;return o.isKanjiModeEnabled()?(j=f(l.BYTE,t.BYTE,g),N=f(l.KANJI,t.KANJI,g)):(j=f(l.BYTE_KANJI,t.BYTE,g),N=[]),x.concat(y,j,N).sort(function(S,C){return S.index-C.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function m(g,x){switch(x){case t.NUMERIC:return s.getBitsLength(g);case t.ALPHANUMERIC:return r.getBitsLength(g);case t.KANJI:return a.getBitsLength(g);case t.BYTE:return i.getBitsLength(g)}}function p(g){return g.reduce(function(x,y){const j=x.length-1>=0?x[x.length-1]:null;return j&&j.mode===y.mode?(x[x.length-1].data+=y.data,x):(x.push(y),x)},[])}function v(g){const x=[];for(let y=0;y<g.length;y++){const j=g[y];switch(j.mode){case t.NUMERIC:x.push([j,{data:j.data,mode:t.ALPHANUMERIC,length:j.length},{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.ALPHANUMERIC:x.push([j,{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.KANJI:x.push([j,{data:j.data,mode:t.BYTE,length:u(j.data)}]);break;case t.BYTE:x.push([{data:j.data,mode:t.BYTE,length:u(j.data)}])}}return x}function w(g,x){const y={},j={start:{}};let N=["start"];for(let b=0;b<g.length;b++){const S=g[b],C=[];for(let R=0;R<S.length;R++){const E=S[R],P=""+b+R;C.push(P),y[P]={node:E,lastCount:0},j[P]={};for(let F=0;F<N.length;F++){const M=N[F];y[M]&&y[M].node.mode===E.mode?(j[M][P]=m(y[M].lastCount+E.length,E.mode)-m(y[M].lastCount,E.mode),y[M].lastCount+=E.length):(y[M]&&(y[M].lastCount=E.length),j[M][P]=m(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,x))}}N=C}for(let b=0;b<N.length;b++)j[N[b]].end=0;return{map:j,table:y}}function k(g,x){let y;const j=t.getBestModeForData(g);if(y=t.from(x,j),y!==t.BYTE&&y.bit<j.bit)throw new Error('"'+g+'" cannot be encoded with mode '+t.toString(y)+`.
120
- Suggested mode is: `+t.toString(j));switch(y===t.KANJI&&!o.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new s(g);case t.ALPHANUMERIC:return new r(g);case t.KANJI:return new a(g);case t.BYTE:return new i(g)}}e.fromArray=function(x){return x.reduce(function(y,j){return typeof j=="string"?y.push(k(j,null)):j.data&&y.push(k(j.data,j.mode)),y},[])},e.fromString=function(x,y){const j=d(x,o.isKanjiModeEnabled()),N=v(j),b=w(N,y),S=c.find_path(b.map,"start","end"),C=[];for(let R=1;R<S.length-1;R++)C.push(b.table[S[R]].node);return e.fromArray(p(C))},e.rawSplit=function(x){return e.fromArray(d(x,o.isKanjiModeEnabled()))}})(xE);const zd=zn,of=Fd,m8=Y5,p8=q5,g8=oE,x8=cE,yp=uE,wp=Ud,v8=J5,Vu=fE,j8=pE,y8=Yr,cf=xE;function w8(e,t){const s=e.size,r=x8.getPositions(t);for(let i=0;i<r.length;i++){const a=r[i][0],l=r[i][1];for(let o=-1;o<=7;o++)if(!(a+o<=-1||s<=a+o))for(let c=-1;c<=7;c++)l+c<=-1||s<=l+c||(o>=0&&o<=6&&(c===0||c===6)||c>=0&&c<=6&&(o===0||o===6)||o>=2&&o<=4&&c>=2&&c<=4?e.set(a+o,l+c,!0,!0):e.set(a+o,l+c,!1,!0))}}function b8(e){const t=e.size;for(let s=8;s<t-8;s++){const r=s%2===0;e.set(s,6,r,!0),e.set(6,s,r,!0)}}function k8(e,t){const s=g8.getPositions(t);for(let r=0;r<s.length;r++){const i=s[r][0],a=s[r][1];for(let l=-2;l<=2;l++)for(let o=-2;o<=2;o++)l===-2||l===2||o===-2||o===2||l===0&&o===0?e.set(i+l,a+o,!0,!0):e.set(i+l,a+o,!1,!0)}}function S8(e,t){const s=e.size,r=Vu.getEncodedBits(t);let i,a,l;for(let o=0;o<18;o++)i=Math.floor(o/3),a=o%3+s-8-3,l=(r>>o&1)===1,e.set(i,a,l,!0),e.set(a,i,l,!0)}function uf(e,t,s){const r=e.size,i=j8.getEncodedBits(t,s);let a,l;for(a=0;a<15;a++)l=(i>>a&1)===1,a<6?e.set(a,8,l,!0):a<8?e.set(a+1,8,l,!0):e.set(r-15+a,8,l,!0),a<8?e.set(8,r-a-1,l,!0):a<9?e.set(8,15-a-1+1,l,!0):e.set(8,15-a-1,l,!0);e.set(r-8,8,1,!0)}function N8(e,t){const s=e.size;let r=-1,i=s-1,a=7,l=0;for(let o=s-1;o>0;o-=2)for(o===6&&o--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,o-c)){let u=!1;l<t.length&&(u=(t[l]>>>a&1)===1),e.set(i,o-c,u),a--,a===-1&&(l++,a=7)}if(i+=r,i<0||s<=i){i-=r,r=-r;break}}}function C8(e,t,s){const r=new m8;s.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),y8.getCharCountIndicator(c.mode,e)),c.write(r)});const i=zd.getSymbolTotalCodewords(e),a=wp.getTotalCodewordsCount(e,t),l=(i-a)*8;for(r.getLengthInBits()+4<=l&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const o=(l-r.getLengthInBits())/8;for(let c=0;c<o;c++)r.put(c%2?17:236,8);return E8(r,e,t)}function E8(e,t,s){const r=zd.getSymbolTotalCodewords(t),i=wp.getTotalCodewordsCount(t,s),a=r-i,l=wp.getBlocksCount(t,s),o=r%l,c=l-o,u=Math.floor(r/l),f=Math.floor(a/l),d=f+1,m=u-f,p=new v8(m);let v=0;const w=new Array(l),k=new Array(l);let g=0;const x=new Uint8Array(e.buffer);for(let S=0;S<l;S++){const C=S<c?f:d;w[S]=x.slice(v,v+C),k[S]=p.encode(w[S]),v+=C,g=Math.max(g,C)}const y=new Uint8Array(r);let j=0,N,b;for(N=0;N<g;N++)for(b=0;b<l;b++)N<w[b].length&&(y[j++]=w[b][N]);for(N=0;N<m;N++)for(b=0;b<l;b++)y[j++]=k[b][N];return y}function A8(e,t,s,r){let i;if(Array.isArray(e))i=cf.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const f=cf.rawSplit(e);u=Vu.getBestVersionForData(f,s)}i=cf.fromString(e,u||40)}else throw new Error("Invalid data");const a=Vu.getBestVersionForData(i,s);if(!a)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=a;else if(t<a)throw new Error(`
121
- The chosen QR Code version cannot contain this amount of data.
122
- Minimum version required to store current data is: `+a+`.
123
- `);const l=C8(t,s,i),o=zd.getSymbolSize(t),c=new p8(o);return w8(c,t),b8(c),k8(c,t),uf(c,s,0),t>=7&&S8(c,t),N8(c,l),isNaN(r)&&(r=yp.getBestMask(c,uf.bind(null,c,s))),yp.applyMask(r,c),uf(c,s,r),{modules:c,version:t,errorCorrectionLevel:s,maskPattern:r,segments:i}}aE.create=function(t,s){if(typeof t>"u"||t==="")throw new Error("No input text");let r=of.M,i,a;return typeof s<"u"&&(r=of.from(s.errorCorrectionLevel,of.M),i=Vu.from(s.version),a=yp.from(s.maskPattern),s.toSJISFunc&&zd.setToSJISFunction(s.toSJISFunc)),A8(t,i,r,a)};var jE={},Kx={};(function(e){function t(s){if(typeof s=="number"&&(s=s.toString()),typeof s!="string")throw new Error("Color should be defined as hex string");let r=s.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+s);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(a){return[a,a]}))),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,a=r.width&&r.width>=21?r.width:void 0,l=r.scale||4;return{width:a,scale:a?4:l,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 a=e.getScale(r,i);return Math.floor((r+i.margin*2)*a)},e.qrToImageData=function(r,i,a){const l=i.modules.size,o=i.modules.data,c=e.getScale(l,a),u=Math.floor((l+a.margin*2)*c),f=a.margin*c,d=[a.color.light,a.color.dark];for(let m=0;m<u;m++)for(let p=0;p<u;p++){let v=(m*u+p)*4,w=a.color.light;if(m>=f&&p>=f&&m<u-f&&p<u-f){const k=Math.floor((m-f)/c),g=Math.floor((p-f)/c);w=d[o[k*l+g]?1:0]}r[v++]=w.r,r[v++]=w.g,r[v++]=w.b,r[v]=w.a}}})(Kx);(function(e){const t=Kx;function s(i,a,l){i.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=l,a.width=l,a.style.height=l+"px",a.style.width=l+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,l,o){let c=o,u=l;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),l||(u=r()),c=t.getOptions(c);const f=t.getImageWidth(a.modules.size,c),d=u.getContext("2d"),m=d.createImageData(f,f);return t.qrToImageData(m.data,a,c),s(d,u,f),d.putImageData(m,0,0),u},e.renderToDataURL=function(a,l,o){let c=o;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),c||(c={});const u=e.render(a,l,c),f=c.type||"image/png",d=c.rendererOpts||{};return u.toDataURL(f,d.quality)}})(jE);var yE={};const T8=Kx;function Dw(e,t){const s=e.a/255,r=t+'="'+e.hex+'"';return s<1?r+" "+t+'-opacity="'+s.toFixed(2).slice(1)+'"':r}function df(e,t,s){let r=e+t;return typeof s<"u"&&(r+=" "+s),r}function R8(e,t,s){let r="",i=0,a=!1,l=0;for(let o=0;o<e.length;o++){const c=Math.floor(o%t),u=Math.floor(o/t);!c&&!a&&(a=!0),e[o]?(l++,o>0&&c>0&&e[o-1]||(r+=a?df("M",c+s,.5+u+s):df("m",i,0),i=0,a=!1),c+1<t&&e[o+1]||(r+=df("h",l),l=0)):i++}return r}yE.render=function(t,s,r){const i=T8.getOptions(s),a=t.modules.size,l=t.modules.data,o=a+i.margin*2,c=i.color.light.a?"<path "+Dw(i.color.light,"fill")+' d="M0 0h'+o+"v"+o+'H0z"/>':"",u="<path "+Dw(i.color.dark,"stroke")+' d="'+R8(l,a,i.margin)+'"/>',f='viewBox="0 0 '+o+" "+o+'"',m='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+f+' shape-rendering="crispEdges">'+c+u+`</svg>
124
- `;return typeof r=="function"&&r(null,m),m};const I8=K5,bp=aE,wE=jE,P8=yE;function Gx(e,t,s,r,i){const a=[].slice.call(arguments,1),l=a.length,o=typeof a[l-1]=="function";if(!o&&!I8())throw new Error("Callback required as last argument");if(o){if(l<2)throw new Error("Too few arguments provided");l===2?(i=s,s=t,t=r=void 0):l===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=s,s=t,t=void 0))}else{if(l<1)throw new Error("Too few arguments provided");return l===1?(s=t,t=r=void 0):l===2&&!t.getContext&&(r=s,s=t,t=void 0),new Promise(function(c,u){try{const f=bp.create(s,r);c(e(f,t,r))}catch(f){u(f)}})}try{const c=bp.create(s,r);i(null,e(c,t,r))}catch(c){i(c)}}Ro.create=bp.create;Ro.toCanvas=Gx.bind(null,wE.render);Ro.toDataURL=Gx.bind(null,wE.renderToDataURL);Ro.toString=Gx.bind(null,function(e,t,s){return P8.render(e,s)});async function M8(e){const t=await Ro.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const Ow=10*6e4,$8=2e3;function bE(e,t){const[s,r]=h.useState(null),[i,a]=h.useState(null),[l,o]=h.useState(!1),[c,u]=h.useState(!1),f=h.useRef(e);f.current=e;const d=h.useRef(t);d.current=t;const m=h.useCallback(async()=>{const p=await A.telegramPairing();r(p),u(!1),o(!1),a(await M8(p.link).catch(()=>""))},[]);return h.useEffect(()=>{if(!s||l||c)return;let p=!1;const v=Math.min(Date.parse(s.expiresAt)||Date.now()+Ow,Date.now()+Ow),w=window.setInterval(()=>{if(Date.now()>=v){u(!0);return}f.current().then(k=>{var g;p||!k||(o(!0),(g=d.current)==null||g.call(d))}).catch(()=>{})},$8);return()=>{p=!0,window.clearInterval(w)}},[s,l,c]),{offer:s,square:i,paired:l,stale:c,ask:m}}function kE({offer:e,square:t,children:s}){return n.jsxs("div",{className:"meet-pair",children:[t?n.jsx("img",{className:"meet-qr",src:t,alt:e.link}):null,n.jsx("a",{className:"meet-link",href:e.link,target:"_blank",rel:"noreferrer",children:e.link}),s]})}const SE=new Set(["approval","question"]),Ac={approval:{label:"Approvals",hint:"A run nobody is watching wants to do something gated."},question:{label:"Questions",hint:"A run asked you something and waits."},watcher:{label:"Watchers",hint:"A watcher or a source found something."},reminder:{label:"Reminders",hint:"A reminder an agent promised you came due."},failure:{label:"Failures",hint:"Background jobs died and will not be retried."},recap:{label:"Reports",hint:"Mission reports, the weekly recap, answers to actions you tapped."},plugin:{label:"Plugins",hint:"A plugin that may send you messages has something to say."}};function D8({timezone:e}){var w,k;const t=ie(()=>A.notificationSettings(),[]),s=ie(()=>A.notifications(20),[],3e4),[r,i]=h.useState(null),[a,l]=h.useState(!1),[o,c]=h.useState(!1),[u,f]=h.useState(null),d=((w=t.data)==null?void 0:w.channels)??[],m=r??((k=t.data)==null?void 0:k.settings),p=g=>{m&&(c(!1),i({...m,...g}))},v=()=>{m&&(l(!0),c(!1),f(null),A.saveNotificationSettings(m).then(()=>{c(!0),i(null),t.reload()}).catch(g=>f(g instanceof he?g.message:String(g))).finally(()=>l(!1)))};return n.jsxs(q,{gap:"lg",children:[n.jsx(_8,{timezone:e,onChange:t.reload}),n.jsx(J,{title:"Notifications",aside:"What buddi tells you when you are not looking at this page.",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:a||!m,onClick:v,children:"Save"}),children:n.jsxs(q,{divided:!0,children:[n.jsx(ne,{message:t.error??u}),n.jsx(J,{title:"Where buddi reaches you",children:m?d.length===0?n.jsx("p",{className:"ui-card-meta",children:"No channel yet, so everything waits for you here. Pair Telegram and buddi can reach you on your phone."}):n.jsx(q,{gap:"sm",children:d.map(g=>{var x;return n.jsx(U8,{channel:g,checked:(m.defaultChannel??((x=d[0])==null?void 0:x.kind))===g.kind,onPick:()=>p({defaultChannel:g.kind})},g.kind)})}):n.jsx(oe,{children:"Loading…"})}),n.jsx(J,{title:"By kind",children:m?n.jsxs(q,{gap:"sm",children:[pP.map(g=>n.jsxs("div",{className:"pref-row nt-kind",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:Ac[g].label}),n.jsx("span",{className:"ui-field-hint",children:Ac[g].hint})]}),n.jsxs("select",{"aria-label":Ac[g].label,value:B8(m,g,d),onChange:x=>{const y={...m.perKind};x.target.value==="default"?delete y[g]:y[g]=x.target.value,p({perKind:y})},children:[n.jsx("option",{value:"default",children:"Default"}),d.map(x=>n.jsx("option",{value:x.kind,children:x.label},x.kind)),SE.has(g)?null:n.jsx("option",{value:"off",children:"Off"})]})]},g)),n.jsx("p",{className:"ui-field-hint",children:"Off keeps it in the list below and never sends it."})]}):null}),n.jsx(J,{title:"Focus schedules",children:m?n.jsxs(q,{gap:"sm",children:[n.jsx(H8,{schedules:m.schedules,onChange:g=>p({schedules:g})}),n.jsxs("p",{className:"ui-field-hint",children:["Do not disturb holds everything but approvals and questions; Urgent only also lets watchers and failures through. What waited comes in one message when the focus ends. Switch a focus by hand from your initial at the foot of the rail, or /focus on Telegram. Times are on your clock (",e,")."]}),n.jsx("div",{className:"nt-times",children:n.jsx(te,{label:"End of the day",children:n.jsx("input",{type:"time",value:m.endOfDay,onChange:g=>p({endOfDay:g.target.value})})})}),n.jsx("p",{className:"ui-field-hint",children:"At the end of the day, what could wait goes out as one message."})]}):null}),o?n.jsx(H,{tone:"good",role:"status",children:"Saved."}):null]})}),n.jsx(O8,{}),n.jsxs(J,{title:"The last twenty",panel:!0,flush:!0,children:[n.jsx(ne,{message:s.error}),s.data?s.data.notifications.length===0?n.jsx(oe,{children:"Nothing yet. What buddi tells you will be listed here."}):n.jsx(Ct,{children:s.data.notifications.map(g=>n.jsx(Et,{title:g.title,sub:`${Ve(g.createdAt,e)} · ${Ac[g.kind].label.toLowerCase()} · ${z8(g,d)}`,side:n.jsx(W8,{row:g})},g.id))}):n.jsx(oe,{children:"Loading…"})]})]})}function O8(){var u;const e=ie(()=>A.tipsSettings(),[]),[t,s]=h.useState(!1),[r,i]=h.useState(null),[a,l]=h.useState(null),o=a??((u=e.data)==null?void 0:u.enabled)??!0,c=f=>{s(!0),i(null),l(f),A.saveTipsSettings(f).then(d=>l(d.enabled)).catch(d=>{l(!f),i(d instanceof he?d.message:String(d))}).finally(()=>s(!1))};return n.jsx(J,{title:"Tips",panel:!0,children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:e.error??r}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:o,disabled:t||!e.data,onChange:f=>c(f.target.checked)}),n.jsx("span",{children:"Tips on Home"})]}),n.jsx("p",{className:"ui-field-hint",children:"When something in buddi has gone unused, Home may say so in one sentence, at most once a day."})]})})}function _8({timezone:e,onChange:t}){var C,R;const s=ie(()=>A.telegramBot(),[]),r=ie(()=>A.telegramDevices(),[]),[i,a]=h.useState(!1),[l,o]=h.useState(""),[c,u]=h.useState(!1),[f,d]=h.useState(null),[m,p]=h.useState(null),v=h.useRef(new Set),w=bE(()=>A.telegramDevices().then(E=>E.devices.some(P=>!v.current.has(P.id))),()=>{r.reload(),t()}),k=((C=s.data)==null?void 0:C.configured)??!1,g=!k||i,x=()=>{var P;if(l.trim()===""||c)return;u(!0),d(null);const E=i&&(((P=s.data)==null?void 0:P.running)??!1);A.saveTelegramToken(l.trim()).then(F=>{o(""),a(!1),d(F.restartNeeded?{ok:!1,text:F.note??"Saved. It will be ready the next time buddi starts."}:E?{ok:!0,text:"Saved. The new bot takes over the next time buddi starts."}:{ok:!0,text:"Saved."}),s.reload(),t()}).catch(F=>d({ok:!1,text:F instanceof he?F.message:String(F)})).finally(()=>u(!1))},y=()=>{var E;p(null),v.current=new Set((((E=r.data)==null?void 0:E.devices)??[]).map(P=>P.id)),w.ask().catch(P=>p(P instanceof he?P.message:String(P)))},{offer:j,square:N,paired:b,stale:S}=w;return n.jsx(J,{title:"Telegram",aside:"Talk to buddi from your phone.",panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{title:"The bot",foot:g?n.jsxs(n.Fragment,{children:[i?n.jsx(I,{variant:"ghost",onClick:()=>{a(!1),o("")},children:"Cancel"}):null,n.jsx(I,{variant:"accent",disabled:c||l.trim()==="",onClick:x,children:"Save token"})]}):void 0,children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:s.error}),!s.data&&!s.error?n.jsx(oe,{children:"Loading…"}):k&&!i?n.jsxs("div",{className:"nt-channel",children:[n.jsx("span",{className:"pref-label",children:(R=s.data)!=null&&R.username?`Bot: @${s.data.username}`:"A bot token is saved."}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{a(!0),d(null)},children:"Replace token"})]}):null,g?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Ask @BotFather for a bot and paste its token here."}),n.jsx(te,{label:"Bot token",grow:!0,children:n.jsx("input",{type:"password",value:l,autoComplete:"off",spellCheck:!1,onChange:E=>o(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),x())}})})]}):null,f?n.jsx(H,{tone:f.ok?"good":"warning",role:"status",children:f.text}):null]})}),n.jsxs(J,{title:"Your devices",children:[n.jsx(ne,{message:r.error}),r.data?r.data.devices.length===0?n.jsx("p",{className:"ui-card-meta",children:"No phone is paired yet."}):n.jsx(Ct,{children:r.data.devices.map(E=>n.jsx(Et,{title:E.name??`Telegram user ${E.userId}`,sub:`Paired ${Ve(E.pairedAt,e)} · ${E.lastSeenAt?`last spoke ${Oe(E.lastSeenAt)}`:"has not spoken yet"}`,side:n.jsx(L8,{id:E.id,onGone:()=>{r.reload(),t()}})},E.id))}):r.error?null:n.jsx(oe,{children:"Loading…"})]}),n.jsx(J,{title:"Pair a device",foot:k&&(!j||b)?n.jsx(I,{variant:j?void 0:"accent",onClick:y,children:"Pair a phone"}):k&&S?n.jsx(I,{variant:"accent",onClick:y,children:"New code"}):void 0,children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:m}),k?b?n.jsx(H,{tone:"good",role:"status",children:"Paired."}):j&&S?n.jsx("p",{className:"ui-card-meta",children:"That code has run out."}):j?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Open this on your phone, then send /start to the bot."}),n.jsx(kE,{offer:j,square:N,children:n.jsx(F8,{text:j.link})}),n.jsxs("p",{className:"ui-field-hint",children:["The code works until ",Ve(j.expiresAt,e),"."]})]}):n.jsx("p",{className:"ui-card-meta",children:"Pair another phone, or the first one if you skipped it."}):n.jsx("p",{className:"ui-card-meta",children:"Save a bot token first."})]})})]})})}function L8({id:e,onGone:t}){const[s,r]=h.useState(!1),[i,a]=h.useState(!1),[l,o]=h.useState(null);if(!s)return n.jsx(I,{size:"sm",onClick:()=>r(!0),children:"Unpair"});const c=()=>{a(!0),o(null),A.unpairTelegramDevice(e).then(t).catch(u=>o(u instanceof he?u.message:String(u))).finally(()=>a(!1))};return n.jsxs("span",{className:"nt-channel",children:[n.jsx("span",{className:"ui-field-hint",role:l?"alert":void 0,children:l??"It will no longer reach your agents."}),n.jsx(I,{size:"sm",variant:"ghost",disabled:i,onClick:()=>r(!1),children:"Keep"}),n.jsx(I,{size:"sm",variant:"danger",disabled:i,onClick:c,children:"Unpair"})]})}function F8({text:e}){const[t,s]=h.useState(null),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){s("Select the link to copy it.");return}navigator.clipboard.writeText(e).then(()=>s("Copied."),()=>s("Select the link to copy it."))};return n.jsxs("span",{className:"nt-channel",children:[n.jsx(I,{size:"sm",onClick:r,children:"Copy"}),t?n.jsx("span",{className:"ui-field-hint",role:"status",children:t}):null]})}function U8({channel:e,checked:t,onPick:s}){const[r,i]=h.useState(!1),[a,l]=h.useState(null),o=()=>{i(!0),l(null),A.testChannel(e.kind).then(()=>l({ok:!0,text:"Sent. Check that it arrived."})).catch(c=>l({ok:!1,text:c instanceof he?c.message:String(c)})).finally(()=>i(!1))};return n.jsxs("div",{className:"nt-channel",children:[n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:"nt-default-channel",checked:t,onChange:s}),n.jsxs("span",{className:"nt-channel-text",children:[n.jsxs("span",{className:"pref-label",children:[e.label,e.where?`, ${e.where}`:""]}),n.jsxs("span",{className:"ui-field-hint",children:["The title and a few lines of each message go to ",e.label,"."]}),a?n.jsx("span",{className:"nt-channel-sent","data-tone":a.ok?void 0:"critical",role:"status",children:a.text}):null]})]}),n.jsx(I,{size:"sm",disabled:r,onClick:o,children:"Send a test"})]})}function B8(e,t,s){const r=e.perKind[t];return r==="off"?SE.has(t)?"default":"off":r&&s.some(i=>i.kind===r)?r:"default"}function z8(e,t){var s;return e.channel&&e.channel!=="dashboard"?((s=t.find(r=>r.kind===e.channel))==null?void 0:s.label)??e.channel:"dashboard"}function W8({row:e}){return e.state==="failed"?n.jsxs("span",{className:"nt-state","data-tone":"critical",children:["Failed: ",e.error??"no reason given"]}):e.actedAt?n.jsx("span",{className:"nt-state",children:"Acted on"}):e.seenAt?n.jsx("span",{className:"nt-state",children:"Seen"}):e.state==="held"?n.jsx("span",{className:"nt-state",children:"Waiting"}):e.state==="stored"?n.jsx("span",{className:"nt-state",children:"Kept"}):e.state==="sent"?n.jsx("span",{className:"nt-state",children:"Sent"}):n.jsx("span",{className:"nt-state",children:"Not seen"})}const _w={mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat",sun:"Sun"},Lw={mode:"do-not-disturb",days:[...jm],from:"22:00",to:"07:00"};function H8({schedules:e,onChange:t}){const s=(r,i)=>t(e.map((a,l)=>l===r?{...a,...i}:a));return n.jsxs(q,{gap:"sm",children:[e.length===0?n.jsx("p",{className:"ui-card-meta",children:"No schedule: a focus is on only when you switch one on."}):null,e.map((r,i)=>{const a=i+1;return n.jsxs("div",{className:"nt-schedule",role:"group","aria-label":`Schedule ${a}`,children:[n.jsxs("select",{"aria-label":`Schedule ${a} mode`,value:r.mode,onChange:l=>s(i,{mode:l.target.value}),children:[n.jsx("option",{value:"do-not-disturb",children:"Do not disturb"}),n.jsx("option",{value:"urgent-only",children:"Urgent only"})]}),n.jsx("span",{className:"nt-days",children:jm.map(l=>{const o=r.days.includes(l);return n.jsx("button",{type:"button",className:"nt-day","aria-pressed":o,"aria-label":`Schedule ${a} ${_w[l]}`,onClick:()=>s(i,{days:o?r.days.filter(c=>c!==l):jm.filter(c=>c===l||r.days.includes(c))}),children:_w[l]},l)})}),n.jsx(te,{label:"From",children:n.jsx("input",{type:"time","aria-label":`Schedule ${a} from`,value:r.from,onChange:l=>s(i,{from:l.target.value})})}),n.jsx(te,{label:"To",children:n.jsx("input",{type:"time","aria-label":`Schedule ${a} to`,value:r.to,onChange:l=>s(i,{to:l.target.value})})}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":`Remove schedule ${a}`,onClick:()=>t(e.filter((l,o)=>o!==i)),children:"Remove"})]},i)}),n.jsx("div",{className:"nt-schedule-add",children:n.jsx(I,{size:"sm",onClick:()=>t([...e,{...Lw,days:[...Lw.days]}]),children:"Add a schedule"})})]})}const V8={you:"person",appearance:"sun",notifications:"bell",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",connections:"globe",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function K8(e){const t=vD.map(r=>({id:r.id,route:tt(r.id),label:r.label,icon:V8[r.id],group:r.group})),s=[...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:uN(r.plugin,r.id),route:No(r.plugin,r.id),label:r.title,icon:G1(r.icon),group:"plugins"}));return[...t,...s]}function NE(e){return xD.map(t=>({id:t.id,label:t.label,entries:e.filter(s=>s.group===t.id)})).filter(t=>t.entries.length>0)}function CE(e,t,s){return t?`${e}, ${t} open`:s?`${e}, ${s}`:void 0}function G8({entries:e,active:t,counts:s={},dots:r={},navigate:i}){var u;const a=h.useRef(null),l=NE(e),o=e.some(f=>f.id===t)?t:(u=e[0])==null?void 0:u.id,c=f=>{var v;const d=[...((v=a.current)==null?void 0:v.querySelectorAll("a.settings-nav-link"))??[]],m=d.indexOf(document.activeElement);if(m===-1)return;const p=w=>{var k;f.preventDefault(),(k=d[Math.max(0,Math.min(d.length-1,w))])==null||k.focus()};if(f.key==="ArrowDown")p(m+1);else if(f.key==="ArrowUp")p(m-1);else if(f.key==="Home")p(0);else if(f.key==="End")p(d.length-1);else if(f.key==="Enter"||f.key===" "){f.preventDefault();const w=d[m].getAttribute("href");w&&i(w)}};return n.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:a,onKeyDown:c,children:l.map(f=>n.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${f.id}`,children:[n.jsx("div",{className:"settings-nav-label",id:`settings-nav-${f.id}`,children:f.label}),f.entries.map(d=>{const m=d.id===t,p=s[d.id],v=r[d.id];return n.jsxs("a",{className:"settings-nav-link",href:d.route,"data-active":m?"true":void 0,"aria-current":m?"page":void 0,"aria-label":CE(d.label,p,v),tabIndex:d.id===o?0:-1,onClick:w=>{w.preventDefault(),i(d.route)},children:[n.jsx(Se,{name:d.icon,className:"settings-nav-icon"}),n.jsx("span",{className:"settings-nav-text",children:d.label}),p?n.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:p>99?"99+":p}):v?n.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","data-testid":"settings-nav-dot","aria-hidden":"true"}):null]},d.id)})]},f.id))})}function Y8({entries:e,active:t,counts:s={},dots:r={},navigate:i}){const a=NE(e),l=e.find(o=>o.id===t)??e[0];return n.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:n.jsxs(Sd,{modal:!1,children:[n.jsx(Nd,{asChild:!0,children:n.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(l==null?void 0:l.label)??""}`,children:[l?n.jsx(Se,{name:l.icon,className:"settings-nav-icon"}):null,n.jsx("span",{className:"settings-nav-text",children:l==null?void 0:l.label}),n.jsx(Se,{name:"chevron-down",className:"settings-menu-chevron"})]})}),n.jsx(So,{children:n.jsx(Cd,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:n.jsx(T$,{value:t,onValueChange:o=>{const c=e.find(u=>u.id===o);c&&i(c.route)},children:a.map((o,c)=>n.jsxs(lN,{children:[c>0?n.jsx(xr,{className:"ui-menu-sep"}):null,n.jsx(Ed,{className:"ui-menu-label",children:o.label}),o.entries.map(u=>{const f=s[u.id],d=r[u.id];return n.jsxs(R$,{value:u.id,className:"ui-menu-item settings-menu-item","data-active":u.id===t?"true":void 0,"aria-label":CE(u.label,f,d),children:[n.jsxs("span",{className:"settings-menu-entry",children:[n.jsx(Se,{name:u.icon,className:"settings-nav-icon"}),n.jsx("span",{className:"settings-nav-text",children:u.label})]}),f?n.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:f>99?"99+":f}):d?n.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","aria-hidden":"true"}):null]},u.id)})]},o.id))})})})]})})}function q8({hash:e,timezone:t,navigate:s,agents:r,pluginPages:i}){var x,y,j;const a=jD(e),l=ZN(i!==void 0),o=i??l,c=hD(e),u=c?o.find(c.plugin,c.page):void 0,f=Ia(Ax),d=K8(o.settings),p={proposals:((y=(x=ie(()=>Promise.resolve().then(()=>A.proposals()),[],3e4).data)==null?void 0:x.open)==null?void 0:y.length)??0},v=ie(()=>A.version(),[]),w=ie(()=>Promise.resolve().then(()=>A.connectionSignals()),[],6e4),k={};v.data&&!v.data.checkout&&v.data.updateAvailable&&(k.system="a newer buddi is ready"),(((j=w.data)==null?void 0:j.signals)??[]).length>0&&(k.connections=Y1);const g={entries:d,active:a,counts:p,dots:k,navigate:N=>s(N)};return n.jsxs("div",{className:"settings",children:[f?null:n.jsx(G8,{...g}),n.jsx("div",{className:"settings-body",children:n.jsxs("div",{className:"ui-page",children:[a==="plugins"?n.jsx(Md,{before:n.jsx(zN,{inline:!0,items:[{label:"Settings",href:tn,onClick:()=>s(tn)}]}),title:"Plugins",lede:"New tools and pages for your team, written by someone else. Each one is read with you, fact by fact, before any of it runs."}):n.jsxs("header",{className:"ui-page-head",children:[n.jsx("h2",{className:"ui-page-title",children:"Settings"}),n.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),f?n.jsx(Y8,{...g}):null,u?n.jsx(V6,{page:u,navigate:s,timezone:t,siblings:o.all.filter(N=>N.plugin===u.plugin)}):null,a==="you"?n.jsx(a5,{embedded:!0}):null,a==="appearance"?n.jsx(Q8,{railPages:o.rail}):null,a==="notifications"?n.jsx(D8,{timezone:t}):null,a==="memory"?n.jsx(uC,{embedded:!0,agents:r,timezone:t}):null,a==="proposals"?n.jsx(h5,{embedded:!0,plugin:mD(e)}):null,a==="accounts"?n.jsx(gz,{embedded:!0}):null,a==="computer"?n.jsx(v4,{embedded:!0,timezone:t}):null,a==="secrets"?n.jsx(Fz,{embedded:!0,timezone:t}):null,a==="connections"?n.jsx(Jz,{embedded:!0,timezone:t}):null,a==="watchers"?n.jsx(r5,{timezone:t,embedded:!0}):null,a==="backup"?n.jsx(oz,{}):null,a==="plugins"?n.jsx(E5,{railPages:o.rail,navigate:s,hash:e}):null,a==="system"?n.jsx(Z8,{timezone:t}):null]})})]})}function Q8({railPages:e}){const[t,s]=nC();return n.jsx(J,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:n.jsxs(q,{divided:!0,gap:"lg",children:[n.jsx(hf,{label:"Theme",hint:"System follows your Mac.",children:n.jsx(Ys,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:t.theme,onChange:r=>s({theme:r})})}),n.jsx(hf,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:n.jsx(Ys,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:t.ground,onChange:r=>s({ground:r})})}),n.jsx(hf,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:n.jsx(Ys,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:t.width,onChange:r=>s({width:r})})}),n.jsx(X8,{pages:e}),n.jsx(J8,{})]})})}function J8(){var a;const e=ie(()=>A.overview(),[]),[t,s]=h.useState(null),r=((a=e.data)==null?void 0:a.glances)??[];if(r.length===0)return null;const i=(l,o)=>{s(l),A.setGlanceHidden(l,!o).then(()=>e.reload()).finally(()=>s(null))};return n.jsxs("div",{className:"pref-row ui-section",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:"Home glances"}),n.jsx("span",{className:"ui-field-hint",children:"The lines beside the date on Home, at most three. Kept for every browser."})]}),n.jsx(q,{gap:"sm",children:r.map(l=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:!l.hidden,disabled:t===l.id,onChange:o=>i(l.id,o.target.checked)}),n.jsx("span",{children:l.title})]},l.id))})]})}function X8({pages:e}){const t=Q1(),[s,r]=h.useState(null);if(e.length===0)return null;const i=(a,l)=>{r(null),aU(a,!l).catch(o=>r(o instanceof Error?o.message:String(o)))};return n.jsxs("div",{className:"pref-row ui-section",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:"In the rail"}),n.jsx("span",{className:"ui-field-hint",children:"The plugin pages beside Home and Chat. One you turn off still opens from Settings → Plugins. Kept for every browser."})]}),n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:s}),e.map(a=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:!t.has(fo(a)),onChange:l=>i(a,l.target.checked)}),n.jsx("span",{children:a.title})]},fo(a)))]})]})}function hf({label:e,hint:t,children:s}){return n.jsxs("div",{className:"pref-row ui-section",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:e}),n.jsx("span",{className:"ui-field-hint",children:t})]}),s]})}function Z8({timezone:e}){const t=ie(()=>A.overview(),[],15e3),s=ie(()=>A.session(),[]),r=ie(()=>A.providerAccounts(),[]),i=t.data;return n.jsxs(q,{gap:"lg",children:[n.jsx(ne,{message:t.error}),n.jsx(fW,{}),i?n.jsx(J,{title:"The queue",panel:!0,actions:n.jsx(I,{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:n.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?n.jsx(xe,{tone:"warning",children:"paused"}):n.jsx(xe,{tone:"good",children:"running"})]})}):null,n.jsxs(J,{title:"This host",panel:!0,children:[n.jsx(Kt,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?Ve(i.now,e):"…"},{label:"Bound to",value:s.data?`${s.data.host}:${s.data.port}`:"…"},{label:"Credential vault",value:r.data?sW(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?n.jsx(H,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),n.jsx(nW,{}),n.jsx(eW,{}),n.jsx(J,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?n.jsx(oe,{children:"No sources are installed."}):n.jsx(Kt,{items:i.mail.map(a=>({key:a.sourceId,label:n.jsx("span",{className:"mono",children:a.sourceId}),value:a.lastError?n.jsx("span",{className:"critical",children:a.lastError}):n.jsxs("span",{children:["polled ",Oe(a.lastRunAt)]})}))}):n.jsx(oe,{children:"Loading…"})})]})}function eW(){var p;const e=ie(()=>A.tailscale(),[]),[t,s]=h.useState(null),[r,i]=h.useState(!1),[a,l]=h.useState(null),[o,c]=h.useState(!1),u=e.data,f=t??((u==null?void 0:u.login)||((p=u==null?void 0:u.self)==null?void 0:p.login)||""),d=(u==null?void 0:u.proxied)===!0,m=v=>{i(!0),l(null),c(!1),A.setTailscale({enabled:v,login:f.trim()}).then(()=>{c(!0)}).catch(w=>l(w instanceof he?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return n.jsx(J,{title:"Sign in through Tailscale",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:r||!u||d,onClick:()=>m((u==null?void 0:u.enabled)??!1),children:"Save"}),children:n.jsx(q,{divided:!0,children:n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:e.error??a}),n.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.":"…"}),d?n.jsxs(n.Fragment,{children:[n.jsx(H,{tone:"warning",children:"Change this from the computer buddi runs on."}),n.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${f}`:"Off"})]}):null,n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||d,onChange:v=>m(v.target.checked)}),n.jsx("span",{children:"Let this Tailscale login sign in"})]}),n.jsx(te,{label:"Tailscale login",children:n.jsx("input",{type:"text",value:f,placeholder:"you@example.com",disabled:r||!u||d,onChange:v=>s(v.target.value)})}),n.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:"}),n.jsxs("div",{className:"tailscale-command",children:[n.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),n.jsx(I,{size:"sm",disabled:r||!u,onClick:()=>{tW((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),n.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."}),o?n.jsx(H,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function tW(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function nW(){var u;const e=ie(()=>A.service(),[],1e4),[t,s]=h.useState(null),[r,i]=h.useState(!1),[a,l]=h.useState(null),o=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!o)return null;const c=f=>{i(!0),l(null),A.serviceAction(f).then(()=>{s(null)}).catch(d=>{l(d.message)}).finally(()=>{i(!1),e.reload()})};return n.jsx(J,{title:"Service",panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{children:n.jsx(Kt,{items:[{label:"Database",value:n.jsx(Fw,{state:o.database,pid:o.databasePid})},{label:"Gateway",value:n.jsx(Fw,{state:o.gateway,pid:o.gatewayPid})},{label:"Supervisor",value:n.jsxs("span",{className:"mono",children:["pid ",o.supervisorPid]})}]})}),n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:a}),t?n.jsx(H,{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."}):n.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),n.jsx(Q,{align:"end",children:t?n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",disabled:r,onClick:()=>{s(null),l(null)},children:"Cancel"}),n.jsx(I,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>{s("stop")},children:"Stop gateway"}),n.jsx(I,{variant:"accent",onClick:()=>{s("restart")},children:"Restart gateway"})]})})]})})]})})}function Fw({state:e,pid:t}){return n.jsxs("span",{children:[n.jsx(xe,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?n.jsx("span",{className:"ui-card-meta",children:"no process"}):n.jsxs("span",{className:"mono",children:["pid ",t]})]})}function sW(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const rW=2e3,Uw={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."},iW=new Set(["done","failed","rolled-back"]),aW="The check asks the npm registry for the newest version and sends nothing else.",lW="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",oW="A checkout upgrades with git pull, then buddi upgrade in a terminal.",cW=10*6e4,uW="buddi did not come back. Run buddi doctor in a terminal.";function dW(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 hW(e,t,s,r){const[i,a]=h.useState(void 0),[l,o]=h.useState(!1),[c,u]=h.useState(null),f=h.useRef(!1),d=h.useRef(s),m=h.useRef(r);return d.current=s,m.current=r,h.useEffect(()=>{if(!e){a(void 0),o(!1),f.current=!1;return}let p=!1,v=0;const w=()=>{f.current=!0,v=Date.now()+cW,o(!0)},k=()=>{if(Date.now()<v){A.session().then(y=>{p||y.version!==void 0&&y.version===t||(p=!0,d.current())}).catch(()=>{}),A.version().then(y=>{const j=y.history[y.history.length-1];p||(j==null?void 0:j.outcome)!=="failed"||(p=!0,o(!1),u(dW(j)))}).catch(()=>{});return}p=!0,o(!1),u(uW)},g=()=>{if(!p){if(f.current)return k();A.upgradeJob(e).then(y=>{var j;p||(a(y),u(null),(iW.has(y.phase)||y.finishedAt)&&(p=!0,y.phase==="failed"&&((j=m.current)==null||j.call(m,y))))}).catch(y=>{p||(y instanceof he&&y.status!==0&&y.status<500?u(y.message):w())})}};g();const x=window.setInterval(g,rW);return()=>{p=!0,window.clearInterval(x)}},[e,t]),{job:i,away:l,error:c}}function fW({reload:e}){var j;const t=ie(()=>A.version(),[]),[s,r]=h.useState(null),[i,a]=h.useState(!1),[l,o]=h.useState(!1),[c,u]=h.useState(null),[f,d]=h.useState(null),m=(j=t.data)==null?void 0:j.current,p=e??(()=>window.location.reload()),v=h.useCallback(N=>{r(null),d(N)},[]),w=hW(s,m,p,v),k=t.data,g=()=>{o(!0),u(null),A.checkVersion().catch(N=>u(N instanceof he?N.message:String(N))).finally(()=>{o(!1),t.reload()})},x=N=>{o(!0),u(null),A.setVersionCheck(N).catch(b=>u(b instanceof he?b.message:String(b))).finally(()=>{o(!1),t.reload()})},y=()=>{o(!0),u(null),d(null),A.startUpgrade(k==null?void 0:k.latest).then(N=>{var b;a(!1),r(((b=N.job)==null?void 0:b.id)??null)}).catch(N=>u(N instanceof he?N.message:String(N))).finally(()=>o(!1))};return k!=null&&k.checkout?n.jsx(J,{title:"Version",panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{children:n.jsx(Kt,{items:[{label:"Running",value:n.jsx("span",{className:"mono",children:k.current})}]})}),n.jsx(J,{children:n.jsx("p",{className:"ui-card-meta",children:oW})})]})}):n.jsx(J,{title:"Version",panel:!0,children:n.jsxs(q,{divided:!0,children:[n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(ne,{message:t.error??c}),n.jsx(Kt,{items:[{label:"Running",value:k?n.jsx("span",{className:"mono",children:k.current}):"…"},{label:"Newest",value:k?k.updateAvailable&&k.latest?n.jsxs("span",{children:["A newer buddi is available: ",n.jsx("span",{className:"mono",children:k.latest})]}):k.checkedAt?n.jsxs("span",{children:["This is the latest, as of ",Oe(k.checkedAt),"."]}):n.jsx("span",{children:"Not checked yet."}):"…"}]}),k!=null&&k.error?n.jsxs(H,{tone:"warning",children:["The last check did not get an answer: ",k.error]}):null,n.jsx(Q,{align:"end",children:n.jsx(I,{disabled:l,onClick:g,children:"Check now"})})]})}),n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:(k==null?void 0:k.checkEnabled)??!1,disabled:l||!k,onChange:N=>x(N.target.checked)}),n.jsx("span",{children:"Check once a day"})]}),n.jsx("p",{className:"ui-card-meta",children:aW})]})}),k!=null&&k.updateAvailable&&k.latest&&k.latestNotes?n.jsx(J,{title:`What changes in ${k.latest}`,children:n.jsx(nr,{text:k.latestNotes})}):null,n.jsx(J,{children:n.jsxs(q,{gap:"sm",children:[n.jsx(mW,{...w,job:w.job??f??void 0}),i?n.jsx(H,{tone:"warning",role:"alert",children:lW}):null,n.jsx(Q,{align:"end",children:i?n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",disabled:l,onClick:()=>a(!1),children:"Cancel"}),n.jsxs(I,{variant:"accent",disabled:l,onClick:y,children:["Upgrade to ",k==null?void 0:k.latest]})]}):n.jsx(I,{variant:"accent",disabled:l||s!==null||!(k!=null&&k.updateAvailable),onClick:()=>a(!0),children:k!=null&&k.updateAvailable&&k.latest?`Upgrade to ${k.latest}`:"Upgrade"})})]})}),k&&k.history.length>0?n.jsx(J,{title:"Upgrades so far",children:n.jsx(Kt,{items:k.history.slice().reverse().map(N=>({key:N.startedAt,label:n.jsxs("span",{className:"mono",children:[N.from," → ",N.to]}),value:n.jsx(pW,{attempt:N})}))})}):null]})})}function mW({job:e,away:t,error:s}){return s?n.jsx(ne,{message:s}):t?n.jsx(H,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="failed"?n.jsxs(H,{tone:"critical",role:"alert",children:[Uw.failed," ",e.error??""," buddi is still running on the version it had."]}):n.jsx(H,{tone:e.phase==="done"?"good":void 0,role:"status",children:Uw[e.phase]??e.detail??e.phase}):null}function pW({attempt:e}){return n.jsxs("span",{children:[n.jsx(xe,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",Oe(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?n.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",n.jsx("span",{className:"mono",children:e.backup})]}):null]})}const kp=["name","clock","brain","browser","assistant","handover"],EE={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function AE(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function gW(e){var a,l,o;const t=AE(e.accounts),s=e.assistant?(((a=e.accounts)==null?void 0:a.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(s==null?void 0:s.accountId)??((o=(l=e.onboarding)==null?void 0:l.details)==null?void 0:o.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(s==null?void 0:s.model)??i.defaultModel}}function TE(e){var r,i,a;const t=gW(e),s=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}:{},...(a=e.onboarding)!=null&&a.stepsDone.includes("browser")||s?{browser:e.browser??"other"}:{},...s?{assistant:s}:{}}}function xW(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 eu(e){return kp.find(t=>!xW(e,t))??"handover"}function vW(e,t){const s=kp.indexOf(t);return kp.filter((r,i)=>i<s||r===t)}function jW(e,t){const s={...e};return delete s[t],s}const Sp="buddi.firstRun.restore";function ff(e){try{e===null?window.sessionStorage.removeItem(Sp):window.sessionStorage.setItem(Sp,e)}catch{}}function RE(){try{return window.sessionStorage.getItem(Sp)}catch{return null}}function yW(e){const t=TE(e),s=eu(t);return{answers:t,open:s,stay:s!=="handover"}}function wW(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function bW(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}const kW=550,SW=6e4,NW=5*6e4,IE=1500,CW=3e3;function Qa(){const e=h.useRef(null);return h.useEffect(()=>{let t=0,s=0;const r=l=>{const o=l.ownerDocument.activeElement;return o===null||o===l.ownerDocument.body||o===l.ownerDocument.documentElement},i=()=>{const l=e.current;l&&r(l)&&l.focus()},a=()=>{i(),s=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(a):a(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(s),window.removeEventListener("focus",i)}},[]),e}function PE(){const[e,t]=h.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}});return h.useEffect(()=>{var i;let s;try{s=window.matchMedia("(prefers-reduced-motion: reduce)")}catch{return}const r=a=>t(a.matches);return(i=s.addEventListener)==null||i.call(s,"change",r),()=>{var a;return(a=s.removeEventListener)==null?void 0:a.call(s,"change",r)}},[]),e}function Fe({children:e,at:t=0}){const s=PE(),[r,i]=h.useState(s||t===0);return h.useEffect(()=>{if(s){i(!0);return}const a=window.setTimeout(()=>i(!0),kW*t);return()=>window.clearTimeout(a)},[s,t]),r?n.jsx("div",{className:"wb-msg","data-role":"assistant",children:n.jsx("div",{className:"wb-bubble",children:e})}):n.jsx(hs,{})}function hs({line:e}){const{report:t}=h.useContext(Yx);return h.useEffect(()=>(t(!0),()=>t(!1)),[t]),n.jsx("div",{className:"wb-msg","data-role":"assistant",children:n.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[e,n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]})})}const Yx=h.createContext({busy:0,report:()=>{}});function EW({children:e}){const[t,s]=h.useState(0),r=h.useCallback(a=>s(l=>Math.max(0,l+(a?1:-1))),[]),i=h.useMemo(()=>({busy:t,report:r}),[t,r]);return n.jsx(Yx.Provider,{value:i,children:e})}function De({children:e}){const{busy:t}=h.useContext(Yx),s=h.useRef(null),[r,i]=h.useState(!1);return h.useEffect(()=>{const a=s.current,l=a==null?void 0:a.closest(".meet-thread");if(t===0||!a||!l){i(!1);return}const o=[...l.querySelectorAll(".meet-turn > .wb-msg-who")].filter(c=>getComputedStyle(c).display!=="none");i(o.at(-1)===a)},[t]),n.jsxs("div",{className:"meet-turn",children:[n.jsxs("div",{className:"wb-msg-who",ref:s,children:[n.jsx(Id,{state:r?"working":"idle",size:"sm",className:"meet-turn-mark"}),n.jsx("span",{children:"buddi"})]}),e]})}const ME=h.createContext({body:null,actions:null});function $E({children:e,actions:t}){const s=h.useContext(ME),r=e==null?null:s.body?Ca.createPortal(e,s.body):e,i=t==null?null:s.actions?Ca.createPortal(t,s.actions):t;return n.jsxs(n.Fragment,{children:[r,i]})}function Tc({text:e,onChange:t}){return n.jsxs("div",{className:"wb-msg","data-role":"user",children:[n.jsx("div",{className:"wb-bubble",children:e}),n.jsx("button",{type:"button",className:"meet-change",onClick:t,children:U.change})]})}function At({children:e,actions:t}){return n.jsx($E,{actions:t?n.jsx("span",{className:"meet-actions",children:t}):null,children:e?n.jsx("div",{className:"meet-ask",children:e}):null})}function Br({onClick:e,disabled:t}){return n.jsxs(I,{variant:"ghost",onClick:e,disabled:t,children:[n.jsx(Se,{name:"chevron-left"}),U.brain.back]})}function AW({navigate:e,timezone:t}){var ot;const[s,r]=h.useState(void 0);h.useEffect(()=>{A.session().then(Ne=>r(Ne.platform)).catch(()=>{})},[]);const[i,a]=h.useState({}),[l,o]=h.useState(null),[c,u]=h.useState(void 0),[f,d]=h.useState(void 0),[m,p]=h.useState([]),[v,w]=h.useState(null),[k,g]=h.useState(null),[x,y]=h.useState(!1),[j,N]=h.useState(null),[b,S]=h.useState(null),[C,R]=h.useState(null),[E,P]=h.useState(null),F=h.useMemo(()=>({body:C,actions:E}),[C,E]),[M,T]=h.useState(null),[$,_]=h.useState(!1),K=h.useCallback(()=>_(!0),[]),[D,Y]=h.useState(()=>RE()?"running":"idle"),[B,V]=h.useState({}),[de,ae]=h.useState([]),[le,Ce]=h.useState(0),ee=h.useRef(void 0),ce=h.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),fe=h.useRef(e);fe.current=e;const je=h.useCallback(async(Ne=!0,_e=!1)=>{var qr,W,ye,Qe,xt,rn,_s,Bt;const[Te,pt,O,ve,Xe,Ge]=await Promise.all([A.onboarding().catch(()=>{}),A.owner().catch(()=>{}),A.providerAccounts().catch(()=>{}),Le.agents().catch(()=>{}),A.browser().catch(()=>{}),A.providers().catch(()=>{})]);u(O);const gt=(W=(qr=Ge==null?void 0:Ge.providers.find(an=>an.kind==="anthropic"))==null?void 0:qr.defaultModel)==null?void 0:W.trim();d(gt||void 0),p((pt==null?void 0:pt.zones)??[]),N(((ye=Te==null?void 0:Te.details)==null?void 0:ye.conversationId)??null);const Be=(ve==null?void 0:ve.agents.find(an=>an.id===ve.defaultAgentId))??(ve==null?void 0:ve.agents[0]);Be&&w(Be),S(Te&&!Te.needs.agent&&Be?{id:Be.id,name:Be.name,avatar:((Qe=Be.avatar)==null?void 0:Qe.kind)==="emoji"?Be.avatar.value:"",description:Be.description,...Be.picture?{picture:Be.picture}:{}}:null);const at={onboarding:Te,owner:pt,accounts:O,browser:(xt=Xe==null?void 0:Xe.browser)==null?void 0:xt.engine,...Be?{assistant:{id:Be.id,name:Be.name,avatar:((rn=Be.avatar)==null?void 0:rn.kind)==="emoji"?Be.avatar.value:""}}:{}},xs=TE(at);if(_e){const an=yW(at);if(a(an.answers),o(an.open),!an.stay){const $i=(_s=Te==null?void 0:Te.details)==null?void 0:_s.conversationId;fe.current($i&&Be?Ke(Be.id,$i):Vt,!0)}return}if(Ne&&(Te==null?void 0:Te.state)==="done"){const an=(Bt=Te.details)==null?void 0:Bt.conversationId;fe.current(an&&Be?Ke(Be.id,an):Vt,!0);return}Ne&&(a(xs),o(an=>an??eu(xs)))},[]);h.useEffect(()=>{je()},[je]);const X=(Ne,_e={})=>{A.onboardingStep(EE[Ne],_e).catch(()=>{})},be=Ne=>{let _e=Ne;for(;;){const Te=eu(_e);if(Te==="brain"&&B.brain)_e={..._e,brain:B.brain};else if(Te==="browser"&&B.browser)_e={..._e,browser:B.browser};else return _e}},Ee=(Ne,_e)=>{const Te=be(_e);Te.brain&&(ee.current=Te.brain),g(null),a(Te),X(Ne,Ne==="brain"&&Te.brain?{accountId:Te.brain.accountId}:{}),o(eu(Te))},qe=Ne=>{g(null),a(_e=>jW(_e,Ne)),o(Ne)},Ie=()=>{const Ne=i.brain??ee.current,_e=i.browser;g(null),V({}),ae([]),a({}),o("name"),Ce(Te=>Te+1),(async()=>{var gt;const[Te,pt,O]=await Promise.all([Promise.resolve().then(()=>A.providerAccounts()).catch(()=>{}),Promise.resolve().then(()=>A.telegram()).catch(()=>{}),Promise.resolve().then(()=>A.browser()).catch(()=>{})]),ve=AE(Te),Xe=Ne&&ve.some(Be=>Be.id===Ne.accountId)?Ne:void 0,Ge=_e==="installed"||((gt=O==null?void 0:O.browser)==null?void 0:gt.engine)==="chromium"?"chromium":void 0;Te&&u(Te),V({...Xe?{brain:Xe}:{},...Ge?{browser:Ge}:{}}),ae([...new Set(ve.map(Be=>Be.label)),...pt!=null&&pt.paired?[U.startOver.telegram]:[],...Ge?[U.startOver.browser]:[]])})()},et=D==="idle"&&!M&&!$&&l!==null&&(l!=="name"||Object.keys(i).length>0),z=()=>{y(!0),A.skipOnboarding().then(()=>e(Vt)).catch(Ne=>g(Ne instanceof he?Ne.message:String(Ne))).finally(()=>y(!1))},se=D==="form"||D==="running"?[]:l?vW(i,l):[],Ae=ie(()=>A.version().catch(()=>({current:""})),[]),Me=h.useRef(null);return h.useEffect(()=>{const Ne=Me.current;if(!Ne)return;const _e=()=>{Ne.scrollTop=Ne.scrollHeight};_e();let Te;try{Te=new ResizeObserver(_e),Ne.firstElementChild&&Te.observe(Ne.firstElementChild)}catch{}return()=>Te==null?void 0:Te.disconnect()},[se.length,l,i,k]),n.jsx(ME.Provider,{value:F,children:n.jsx("div",{className:"meet",children:n.jsxs("div",{className:"meet-stack",children:[n.jsxs("header",{className:"meet-head",children:[n.jsx("img",{className:"meet-head-mascot",src:Gr("core"),alt:"","aria-hidden":"true"}),n.jsxs("span",{className:"meet-head-who",children:[n.jsx("span",{className:"meet-head-name",children:"buddi"}),n.jsx("span",{className:"meet-head-line",children:s===void 0||s==="darwin"?U.tagline:U.taglineElsewhere}),(ot=Ae.data)!=null&&ot.current?n.jsxs("span",{className:"meet-head-version mono",children:["buddi ",Ae.data.current]}):null]})]}),n.jsxs("div",{className:"meet-board",children:[n.jsx("div",{className:"meet-scroll thin-scroll",ref:Me,children:n.jsx("div",{className:"meet-thread","data-testid":"meet-thread",children:n.jsxs(EW,{children:[n.jsx(De,{children:U.opening.map((Ne,_e)=>n.jsx(Fe,{at:_e,children:Ne},Ne))}),n.jsx(TW,{state:D,offered:l==="name"&&i.name===void 0,name:i.name,onState:Y,onDone:()=>{Y("idle"),je(!0,!0)},onTrouble:g}),de.length>0?n.jsx(De,{children:n.jsx(Fe,{children:U.startOver.said(de.join(", "))})}):null,se.map(Ne=>n.jsx(RW,{id:Ne,openNow:l===Ne,answers:i,accounts:c,claudeModel:f,zones:m,browserZone:ce,assistantAgent:v,met:j,onMet:N,existing:b,navigate:e,onCarriesOn:T,onClosed:K,onSettled:_e=>Ee(Ne,_e),onChange:()=>qe(Ne),onTrouble:g,onReload:()=>void je(!1),onPickAnotherBrain:()=>qe("brain")},`${le}-${Ne}`)),k?n.jsx(De,{children:n.jsx(Fe,{children:k})}):null]})})}),n.jsxs("footer",{className:"meet-dock",children:[n.jsx("div",{className:"meet-dock-ask",ref:R}),n.jsxs("div",{className:"meet-dock-row",children:[$?n.jsx("span",{}):M?n.jsx("a",{className:"meet-later",href:M,onClick:Ne=>{Ne.preventDefault(),e(M,!0)},children:U.done.open}):n.jsxs("span",{className:"meet-quiet",children:[n.jsx("button",{className:"meet-later",type:"button",disabled:x,onClick:z,children:U.later}),et?n.jsx("button",{className:"meet-later",type:"button",disabled:x,onClick:Ie,children:U.startOver.link}):null]}),n.jsx("div",{className:"meet-dock-actions",ref:P})]})]})]})]})})})}function TW({state:e,offered:t,name:s,onState:r,onDone:i,onTrouble:a}){const[l,o]=h.useState(()=>RE()),[c,u]=h.useState([]),[f,d]=h.useState(!1),[m,p]=h.useState(null),[v,w]=h.useState(""),[k,g]=h.useState(!1);h.useEffect(()=>{if(!l)return;let j=!1;const N=()=>{A.backupJob(l).then(S=>{j||(u(C=>C.includes(S.phase)?C:[...C,S.phase]),S.phase==="done"?(j=!0,ff(null),d(!0),i()):(S.phase==="rolled-back"||S.phase==="failed")&&(j=!0,ff(null),o(null),a(S.error??U.restore.phases[S.phase]),r("idle")))}).catch(()=>{})};N();const b=window.setInterval(N,IE);return()=>{j=!0,window.clearInterval(b)}},[l]);const x=()=>{!m||k||(g(!0),a(null),A.firstRunRestore(m,v.trim()).then(j=>{ff(j.job.id),o(j.job.id),r("running")}).catch(j=>a(j instanceof he?j.message:String(j))).finally(()=>g(!1)))},y=c.filter(j=>j in U.restore.phases);return n.jsxs(n.Fragment,{children:[t&&e==="idle"&&!f?n.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:U.restore.offer}):null,e==="form"?n.jsxs(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>r("idle"),children:U.restore.cancel}),n.jsx(I,{variant:"accent",disabled:k||!m,onClick:x,children:U.restore.submit})]}),children:[n.jsx(te,{label:U.restore.file,grow:!0,children:n.jsx("input",{type:"file",onChange:j=>{var N;return p(((N=j.target.files)==null?void 0:N[0])??null)}})}),n.jsx(te,{label:U.restore.passphrase,hint:U.restore.passphraseHint,children:n.jsx("input",{type:"password",autoComplete:"off",value:v,onChange:j=>w(j.target.value)})})]}):null,e==="running"||f?n.jsxs(De,{children:[n.jsx(Fe,{children:U.restore.started}),y.map(j=>n.jsx(Fe,{children:U.restore.phases[j]},j))]}):null,f?n.jsxs(De,{children:[s?n.jsx(Fe,{children:U.restore.welcome(s)}):null,n.jsx(Fe,{children:U.restore.keys})]}):null]})}function RW(e){var a,l,o,c,u;const{id:t,openNow:s,answers:r,onChange:i}=e;if(t==="name")return n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{at:1,children:U.name.ask})}),s?n.jsx(IW,{...e}):n.jsx(Tc,{text:r.name??"",onChange:i})]});if(t==="clock")return n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{at:1,children:U.clock.ask(r.name??"",r.clock??e.browserZone)})}),s?n.jsx(PW,{...e}):n.jsx(Tc,{text:U.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{at:1,children:U.brain.ask})}),s?n.jsx(MW,{...e}):n.jsxs(n.Fragment,{children:[n.jsx(Tc,{text:U.brain.answer(((a=r.brain)==null?void 0:a.label)??""),onChange:i}),n.jsxs(De,{children:[n.jsx(Fe,{children:(l=r.brain)!=null&&l.freeTier?U.brain.worksOnFlash(r.brain.model):U.brain.works(((o=r.brain)==null?void 0:o.model)??"")}),n.jsx(KW,{...e})]})]})]});if(t==="browser"){if(s)return n.jsx(ZW,{...e});const f=XW(r.browser);return f?n.jsx(De,{children:n.jsx(Fe,{children:f})}):null}return t==="assistant"?n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{at:1,children:U.assistant.ask})}),s?n.jsx(tH,{...e}):n.jsx(Tc,{text:`${((c=r.assistant)==null?void 0:c.avatar)??""} ${((u=r.assistant)==null?void 0:u.name)??""}`.trim(),onChange:i})]}):n.jsx(nH,{...e})}function IW({answers:e,onSettled:t,onTrouble:s}){const r=Qa(),[i,a]=h.useState(e.name??""),[l,o]=h.useState(!1),c=()=>{const u=i.trim();u===""||l||(o(!0),A.setOwner({preferredName:u}).then(()=>t({...e,name:u})).catch(f=>s(f instanceof he?f.message:String(f))).finally(()=>o(!1)))};return n.jsx(At,{actions:n.jsx(I,{variant:"accent",disabled:l||i.trim()==="",onClick:c,children:U.name.submit}),children:n.jsx("input",{ref:r,className:"meet-input","aria-label":U.name.placeholder,placeholder:U.name.placeholder,maxLength:80,value:i,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function PW({answers:e,zones:t,browserZone:s,onSettled:r,onTrouble:i}){const[a,l]=h.useState(!1),[o,c]=h.useState(s),[u,f]=h.useState(!1),d=m=>{f(!0),A.setOwner({timezone:m}).then(()=>r({...e,clock:m})).catch(p=>i(p instanceof he?p.message:String(p))).finally(()=>f(!1))};return a?n.jsx(At,{actions:n.jsx(I,{variant:"accent",disabled:u,onClick:()=>d(o),children:U.clock.yes}),children:n.jsx("select",{className:"meet-input","aria-label":U.clock.label,value:o,onChange:m=>c(m.target.value),children:(t.includes(o)?t:[o,...t]).map(m=>n.jsx("option",{value:m,children:m},m))})}):n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>l(!0),children:U.clock.another}),n.jsx(I,{variant:"accent",disabled:u,onClick:()=>d(s),children:U.clock.yes})]})})}function MW(e){const{accounts:t,answers:s,onSettled:r,onReload:i}=e,[a,l]=h.useState(null),[o,c]=h.useState(null),[u,f]=h.useState(!1),[d,m]=h.useState(null),[p,v]=h.useState(null),w=(t==null?void 0:t.anthropicOAuthEnabled)===!0,k=(t==null?void 0:t.codexEnabled)===!0,g=t==null?void 0:t.gemini,[x,y]=h.useState(null);h.useEffect(()=>{let C=!1;const R=()=>{A.ollama().then(P=>{C||m(P)}).catch(()=>{})};R();const E=window.setInterval(R,4e3);return()=>{C=!0,window.clearInterval(E)}},[]);const j=async C=>{if(s.assistant??e.existing)try{await A.bindBrain({accountId:C.accountId,model:C.model})}catch(R){return R instanceof he?R.message:String(R)}return i(),r({...s,brain:C}),null},N=async(C,R,E)=>{f(!0),c(null);try{const P=await A.saveProviderAccount(C);let F=await A.testProviderAccount(P.id),M=C.defaultModel,T=!1;if(F.state!=="connected"&&E&&E!==M&&IC(F)){const _=(await A.providerAccounts()).accounts.find(K=>K.id===P.id);_&&(await A.saveProviderAccount({id:_.id,revision:_.revision,label:_.label,kind:_.kind,auth:_.auth,baseUrl:_.baseUrl,defaultModel:E,enabled:_.enabled}),F=await A.testProviderAccount(P.id),F.state==="connected"&&(M=E,T=!0))}if(F.state!=="connected"){try{const _=(await A.providerAccounts()).accounts.find(K=>K.id===P.id);_&&await A.removeProviderAccount(P.id,_.revision)}catch{}return c(F.message),F}const $=await j({accountId:P.id,label:R,model:M,...T?{freeTier:T}:{}});return $&&c($),F}catch(P){return c(P instanceof he?P.message:String(P)),null}finally{f(!1)}},b=async C=>{f(!0),c(null);try{const R=await A.saveProviderAccount(C);let E;try{E=await A.testProviderAccount(R.id)}finally{try{const P=(await A.providerAccounts()).accounts.find(F=>F.id===R.id);P&&await A.removeProviderAccount(R.id,P.revision)}catch{}}return E.state!=="connected"&&c(E.message),E}catch(R){return c(R instanceof he?R.message:String(R)),null}finally{f(!1)}},S=(C,R,E)=>{if(C.length<=1){N(R(C[0]??""),E);return}v({models:C,make:R,label:E})};return p?n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{children:U.brain.model.ask})}),u?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.service})}):o?n.jsx(De,{children:n.jsx(Fe,{children:o})}):null,n.jsx(FW,{busy:u,models:p.models,onUse:C=>void N(p.make(C),p.label)})]}):a==="gemini"&&g?n.jsx(BW,{busy:u,problem:o,preset:g,onBack:()=>l(null),onUse:N}):a==="key"?n.jsx(UW,{busy:u,problem:o,onBack:()=>l(null),onUse:N}):a==="service"?n.jsx(WW,{busy:u,problem:o,address:(d==null?void 0:d.cloudBaseUrl)??"",onBack:()=>l(null),onOffer:S,onTrial:b,onUse:N}):a==="ollama"?n.jsx(zW,{busy:u,problem:o,probe:d,onBack:()=>l(null),onOffer:S}):a==="cloud"?n.jsx(VW,{busy:u,consent:x,onBack:()=>{x==null||x.close(),y(null),l(null)},onConnected:j,...e}):a==="chatgpt"?n.jsx(YW,{busy:u,consent:x,onBack:()=>{x==null||x.close(),y(null),l(null)},onConnected:j,...e}):a==="claude"?n.jsx(QW,{busy:u,problem:o,onBack:()=>l(null),onConnected:j,...e}):n.jsx($E,{children:n.jsxs("div",{className:"meet-cards",role:"group","aria-label":U.brain.ask,children:[w?n.jsx(ni,{mark:n.jsx($W,{}),card:U.brain.cards.claude,onPick:()=>l("claude")}):null,k?n.jsx(ni,{mark:n.jsx(DW,{}),card:U.brain.cards.chatgpt,onPick:()=>{y(typeof window.open=="function"?window.open("","_blank"):null),l("chatgpt")}}):null,g?n.jsx(ni,{mark:n.jsx(LW,{}),card:U.brain.cards.gemini,onPick:()=>l("gemini")}):null,n.jsx(ni,{mark:n.jsx(OW,{}),card:U.brain.cards.key,onPick:()=>l("key")}),n.jsx(ni,{mark:n.jsx(_W,{}),card:U.brain.cards.ollama,note:d===null?U.brain.ollama.looking:d.running?U.brain.ollama.found:U.brain.ollama.missing,onPick:()=>l("ollama")}),n.jsx(ni,{mark:n.jsx(Bw,{}),card:U.brain.cards.cloud,onPick:()=>{y(typeof window.open=="function"?window.open("","_blank"):null),l("cloud")}}),n.jsx(ni,{mark:n.jsx(Bw,{}),card:U.brain.cards.service,onPick:()=>l("service")})]})})}function ni({mark:e,card:t,note:s,onPick:r}){return n.jsxs("button",{type:"button",className:"meet-card",onClick:r,children:[n.jsx("span",{className:"meet-card-mark","aria-hidden":"true",children:e}),n.jsxs("span",{className:"meet-card-words",children:[n.jsx("span",{className:"meet-card-title",children:t.title}),n.jsx("span",{className:"meet-card-line",children:s??t.line}),t.know?n.jsx("span",{className:"meet-card-know",children:t.know}):null]})]})}function $W(){const e=[0,45,90,135,180,225,270,315];return n.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",children:e.map(t=>n.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 DW(){return n.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:[n.jsx("path",{d:"M5.4 4.6h13.2a2 2 0 0 1 2 2v8.2a2 2 0 0 1-2 2h-7.4l-4.4 3.4v-3.4H5.4a2 2 0 0 1-2-2V6.6a2 2 0 0 1 2-2Z"}),n.jsx("path",{d:"M8 9.4h8"}),n.jsx("path",{d:"M8 12.6h5"})]})}function OW(){return n.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:[n.jsx("circle",{cx:"8",cy:"8",r:"3.6"}),n.jsx("path",{d:"M10.6 10.6 19.4 19.4"}),n.jsx("path",{d:"M13.8 13.8 11.9 15.7"}),n.jsx("path",{d:"M16.6 16.6 14.7 18.5"})]})}function _W(){return n.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:[n.jsx("rect",{x:"3.2",y:"4.6",width:"17.6",height:"11.2",rx:"2"}),n.jsx("path",{d:"M9.4 19.4h5.2"}),n.jsx("path",{d:"M12 15.8v3.6"})]})}function LW(){return n.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round",children:n.jsx("path",{d:"M12 3c.6 4.6 3.9 8.4 9 9-5.1.6-8.4 4.4-9 9-.6-4.6-3.9-8.4-9-9 5.1-.6 8.4-4.4 9-9Z"})})}function Bw(){return n.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:n.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 FW({busy:e,models:t,onUse:s}){const[r,i]=h.useState(t[0]??"");return n.jsx(At,{actions:n.jsx(I,{variant:"accent",disabled:e||r==="",onClick:()=>s(r),children:U.brain.model.submit}),children:n.jsx(te,{label:U.brain.model.label,grow:!0,children:n.jsx("select",{value:r,onChange:a=>i(a.target.value),children:t.map(a=>n.jsx("option",{value:a,children:a},a))})})})}function DE({models:e,picked:t,disabled:s,onPick:r}){return n.jsx(te,{label:U.brain.model.label,grow:!0,children:n.jsx("select",{value:t,disabled:s,onChange:i=>r(i.target.value),children:e.map(i=>n.jsx("option",{value:i,children:i},i))})})}function UW({busy:e,problem:t,onBack:s,onUse:r}){const i=Qa(),[a,l]=h.useState(""),[o,c]=h.useState(null),[u,f]=h.useState(!1),[d,m]=h.useState([]),[p,v]=h.useState(""),[w,k]=h.useState(!1),g=e||u,x=!w&&t!==null&&d.length>0,y=o??wW(a),j=()=>{const N=a.trim();N===""||g||(f(!0),k(!1),(async()=>{var R;let b=y==="anthropic"?"claude-sonnet-5":"gpt-5",S=d;if(x&&p!=="")b=p;else try{const E=await A.probeModels({kind:y,auth:"api-key",secret:N});b=((R=E.models.find(P=>P.isDefault))==null?void 0:R.id)??b,S=E.models.map(P=>P.id)}catch{S=[]}f(!1);const C=await r({label:y==="anthropic"?U.brain.key.anthropic:U.brain.key.openai,kind:y,auth:"api-key",baseUrl:"",defaultModel:b,enabled:!0,secret:N},y==="anthropic"?U.brain.key.anthropic:U.brain.key.openai);if(!(!C||C.state==="connected")){if(Dg(C)){k(!0),m([]);return}m(S.includes(b)||S.length===0?S:[b,...S]),v(b)}})())};return n.jsxs(n.Fragment,{children:[g?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.key})}):w?n.jsx(De,{children:n.jsx(Fe,{children:U.brain.key.refused})}):t?n.jsx(De,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:s,disabled:g}),n.jsx(I,{variant:"accent",disabled:g||a.trim()==="",onClick:j,children:x?U.brain.model.retry:U.brain.key.submit})]}),children:[n.jsx(te,{label:U.brain.key.field,grow:!0,children:n.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:U.brain.key.placeholder,value:a,onChange:N=>{l(N.target.value),m([])},onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),j())}})}),x?n.jsx(DE,{models:d,picked:p,disabled:g,onPick:v}):null,n.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(y==="anthropic"?"openai":"anthropic"),children:[y==="anthropic"?U.brain.key.anthropic:U.brain.key.openai," · ",U.brain.key.which]})]})]})}function BW({busy:e,problem:t,preset:s,onBack:r,onUse:i}){const a=Qa(),[l,o]=h.useState(""),[c,u]=h.useState(!1),[f,d]=h.useState([]),[m,p]=h.useState(""),v=e||c,w=t!==null&&f.length>0,k=()=>{const g=l.trim();g===""||v||(u(!0),(async()=>{let x=EC,y;if(w&&m!=="")x=m;else try{const N=(await A.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:s.baseUrl,secret:g})).models.map(b=>b.id);x=AC(N)??x,y=RC(x)?TC(N):void 0,d(mz(N)),p(y??x)}catch{}u(!1),await i({label:U.brain.gemini.label,kind:"openai-compatible",auth:"api-key",baseUrl:s.baseUrl,defaultModel:x,enabled:!0,secret:g},U.brain.gemini.label,y)})())};return n.jsxs(n.Fragment,{children:[v?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.gemini})}):t?n.jsx(De,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:r,disabled:v}),n.jsx(I,{variant:"accent",disabled:v||l.trim()==="",onClick:k,children:U.brain.gemini.submit})]}),children:[n.jsx(te,{label:U.brain.gemini.field,grow:!0,children:n.jsx("input",{ref:a,type:"password",autoComplete:"off",spellCheck:!1,placeholder:U.brain.gemini.placeholder,value:l,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),k())}})}),w?n.jsx(te,{label:U.brain.model.label,grow:!0,children:n.jsx("select",{value:m,disabled:v,onChange:g=>p(g.target.value),children:f.map(g=>n.jsx("option",{value:g,children:g},g))})}):null,n.jsx("a",{className:"meet-quiet",href:s.keyUrl,target:"_blank",rel:"noreferrer",children:U.brain.gemini.get})]})]})}function zW({busy:e,problem:t,probe:s,onBack:r,onOffer:i}){const a=(s==null?void 0:s.models)??[],l=()=>{s&&i(a,o=>({label:U.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:s.baseUrl,defaultModel:o,enabled:!0}),U.brain.cards.ollama.title)};return n.jsxs(n.Fragment,{children:[e?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.ollama})}):t?n.jsx(De,{children:n.jsx(Fe,{children:t})}):null,n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:r,disabled:e}),s!=null&&s.running?n.jsx(I,{variant:"accent",disabled:e||a.length===0,onClick:l,children:U.brain.ollama.connect}):s?n.jsx(Yt,{variant:"accent",href:s.downloadUrl,target:"_blank",rel:"noreferrer",children:U.brain.ollama.download}):null]}),children:n.jsx("span",{className:"meet-line",children:s===null?U.brain.ollama.looking:s.running?U.brain.ollama.found:U.brain.ollama.missing})})]})}function WW({busy:e,problem:t,address:s,onBack:r,onOffer:i,onTrial:a,onUse:l}){const o=Qa(),[c,u]=h.useState(s),[f,d]=h.useState(""),[m,p]=h.useState(!1),[v,w]=h.useState([]),[k,g]=h.useState(""),[x,y]=h.useState(!1),j=e||m,N=!x&&t!==null&&v.length>0,b=()=>{c.trim()===""||j||(p(!0),y(!1),(async()=>{var $;const S=f.trim()?"api-key":"none",C=_=>({label:U.brain.cards.service.title,kind:"openai-compatible",auth:S,baseUrl:c.trim(),defaultModel:_,enabled:!0,...f.trim()?{secret:f.trim()}:{}}),R=(_,K,D)=>{if(!(!_||_.state==="connected")){if(Dg(_)){y(!0),w([]);return}w(K),g(D)}};if(S==="api-key"&&N&&k!==""){p(!1),R(await l(C(k),U.brain.cards.service.title),v,k);return}let E=[],P;try{const _=await A.probeModels({kind:"openai-compatible",auth:S,baseUrl:c.trim(),...f.trim()?{secret:f.trim()}:{}});E=_.models.map(K=>K.id),P=($=_.models.find(K=>K.isDefault))==null?void 0:$.id}catch{}p(!1);const F=P?[P]:E;if(S==="none"){i(F,C,U.brain.cards.service.title);return}const M=F[0]??"";if(F.length<=1){R(await l(C(M),U.brain.cards.service.title),E,M);return}const T=await a(C(M));(T==null?void 0:T.state)==="connected"?i(F,C,U.brain.cards.service.title):R(T,E,M)})())};return n.jsxs(n.Fragment,{children:[j?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.service})}):x?n.jsx(De,{children:n.jsx(Fe,{children:U.brain.key.refused})}):t?n.jsx(De,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:r,disabled:j}),n.jsx(I,{variant:"accent",disabled:j||c.trim()==="",onClick:b,children:N?U.brain.model.retry:U.brain.service.submit})]}),children:[n.jsx(te,{label:U.brain.service.address,grow:!0,children:n.jsx("input",{ref:o,value:c,placeholder:U.brain.service.addressPlaceholder,onChange:S=>{u(S.target.value),w([])}})}),n.jsx(te,{label:U.brain.service.key,children:n.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:f,onChange:S=>{d(S.target.value),w([])}})}),N?n.jsx(DE,{models:v,picked:k,disabled:j,onPick:g}):null]})]})}const HW=2e3;function VW({busy:e,consent:t,onBack:s,onConnected:r,accounts:i}){const[a,l]=h.useState(!0),[o,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState(0),p=h.useRef(-1),v=h.useRef(null),w=U.brain.cloud.label;h.useEffect(()=>{if(p.current===d)return;p.current=d,l(!0),c(null);const g=d===0?t:v.current;(async()=>{try{const x=((i==null?void 0:i.accounts)??[]).find(b=>b.auth==="device-key"),y=x?{id:x.id}:await A.saveProviderAccount({label:w,kind:"openai-compatible",auth:"device-key",baseUrl:"",defaultModel:Vc,enabled:!0}),j=(await A.providerAccounts()).accounts.find(b=>b.id===y.id),N=await A.ollamaConnect(j.id,j.revision);f({id:j.id,attemptId:N.attemptId,url:N.verificationUrl}),g&&(g.location.href=N.verificationUrl)}catch(x){g==null||g.close(),c(x instanceof he?x.message:String(x))}finally{l(!1)}})()},[d]),h.useEffect(()=>{if(!u)return;let g=!1,x=!1;const y=async()=>{if(!(g||x)){x=!0;try{const N=await A.ollamaPoll(u.id,u.attemptId);if(g||N.state==="waiting")return;if(g=!0,f(null),N.state==="failed"){c(N.message);return}l(!0),c(await k(u.id)),l(!1)}catch{}finally{x=!1}}},j=window.setInterval(()=>void y(),HW);return()=>{g=!0,window.clearInterval(j)}},[u]);const k=async g=>{try{const x=(await A.accountModels(g).catch(()=>({models:[]}))).models.map(b=>b.id),y=x.length===0||x.includes(Vc)?Vc:x[0],j=(await A.providerAccounts()).accounts.find(b=>b.id===g);j&&j.defaultModel!==y&&await A.saveProviderAccount({id:j.id,revision:j.revision,label:j.label,kind:j.kind,auth:j.auth,baseUrl:j.baseUrl,defaultModel:y,enabled:j.enabled});const N=await A.testProviderAccount(g);return N.state!=="connected"?N.message:await r({accountId:g,label:w,model:y})}catch(x){return x instanceof he?x.message:String(x)}};return n.jsxs(n.Fragment,{children:[a||e?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.cloud})}):o?n.jsx(De,{children:n.jsx(Fe,{children:o})}):u?n.jsx(De,{children:n.jsx(Fe,{children:U.brain.cloud.waiting})}):null,n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:s,disabled:a||e}),u?n.jsx(Yt,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:U.brain.cloud.open}):o?n.jsx(I,{variant:"accent",disabled:a||e,onClick:()=>{v.current=typeof window.open=="function"?window.open("","_blank"):null,m(g=>g+1)},children:U.brain.cloud.again}):null]})})]})}function KW({answers:e,accounts:t,onSettled:s,onTrouble:r}){var m;const i=e.brain,a=i?((t==null?void 0:t.accounts)??[]).find(p=>p.id===i.accountId):void 0,[l,o]=h.useState([]),[c,u]=h.useState(!1),f=(a==null?void 0:a.auth)==="device-key"||(a==null?void 0:a.kind)==="codex"||!!a&&pz(a,(m=t==null?void 0:t.gemini)==null?void 0:m.baseUrl);if(h.useEffect(()=>{if(!f||!a)return;let p=!1;return A.accountModels(a.id).then(v=>{p||o(v.models.map(w=>w.id))}).catch(()=>{}),()=>{p=!0}},[f,a==null?void 0:a.id]),!f||!a||!i||l.length<2)return null;const d=p=>{p===i.model||c||(u(!0),r(null),(async()=>{try{await A.saveProviderAccount({id:a.id,revision:a.revision,label:a.label,kind:a.kind,auth:a.auth,baseUrl:a.baseUrl,defaultModel:p,enabled:a.enabled}),e.assistant&&await A.bindBrain({accountId:a.id,model:p}),s({...e,brain:{accountId:i.accountId,label:i.label,model:p}})}catch(v){r(v instanceof he?v.message:String(v))}finally{u(!1)}})())};return n.jsx(Fe,{children:n.jsx(te,{label:U.brain.model.change,children:n.jsx("select",{value:i.model,disabled:c,onChange:p=>d(p.target.value),children:(l.includes(i.model)?l:[i.model,...l]).map(p=>n.jsx("option",{value:p,children:p},p))})})})}const zw="gpt-5.5",GW=2e3;function YW({busy:e,consent:t,onBack:s,onConnected:r,accounts:i}){const[a,l]=h.useState(!0),[o,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState(0),p=h.useRef(-1),v=h.useRef(null),w=h.useRef(null),k=U.brain.chatgpt.label;h.useEffect(()=>()=>{const y=w.current;w.current=null,y&&A.codexAccountAction(y.id,"cancel-login",y.revision).catch(()=>{})},[]),h.useEffect(()=>{if(p.current===d)return;p.current=d,l(!0),c(null);const y=d===0?t:v.current;(async()=>{try{const j=((i==null?void 0:i.accounts)??[]).find(C=>C.kind==="codex"),N=j?{id:j.id}:await A.saveProviderAccount({label:k,kind:"codex",auth:"chatgpt",baseUrl:"",defaultModel:zw,enabled:!0}),b=(await A.providerAccounts()).accounts.find(C=>C.id===N.id),S=await A.codexAccountAction(b.id,"login",b.revision);if(!(S!=null&&S.verificationUrl)||!S.userCode)throw new Error((S==null?void 0:S.message)??U.brain.chatgpt.failed);w.current={id:b.id,revision:b.revision},f({id:b.id,revision:b.revision,url:S.verificationUrl,code:S.userCode}),y&&(y.location.href=S.verificationUrl)}catch(j){y==null||y.close(),c(j instanceof he||j instanceof Error?j.message:String(j))}finally{l(!1)}})()},[d]),h.useEffect(()=>{if(!u)return;let y=!1,j=!1;const N=async()=>{if(!(y||j)){j=!0;try{const S=(await A.providerAccounts()).accounts.find(R=>R.id===u.id);if(y)return;const C=S==null?void 0:S.login;if(!C||C.state==="pending")return;if(y=!0,w.current=null,f(null),C.state!=="connected"){c(C.message??U.brain.chatgpt.failed);return}l(!0),c(await g(u.id)),l(!1)}catch{}finally{j=!1}}},b=window.setInterval(()=>void N(),GW);return()=>{y=!0,window.clearInterval(b)}},[u]);const g=async y=>{var j,N;try{const b=(await A.accountModels(y).catch(()=>({models:[]}))).models,S=((j=b.find(R=>R.isDefault))==null?void 0:j.id)??((N=b[0])==null?void 0:N.id)??zw,C=(await A.providerAccounts()).accounts.find(R=>R.id===y);return C&&C.defaultModel!==S&&await A.saveProviderAccount({id:C.id,revision:C.revision,label:C.label,kind:C.kind,auth:C.auth,baseUrl:C.baseUrl,defaultModel:S,enabled:C.enabled}),await r({accountId:y,label:k,model:S})}catch(b){return b instanceof he?b.message:String(b)}},x=()=>{const y=w.current;w.current=null,y&&A.codexAccountAction(y.id,"cancel-login",y.revision).catch(()=>{}),s()};return n.jsxs(n.Fragment,{children:[a||e?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.chatgpt})}):o?n.jsx(De,{children:n.jsx(Fe,{children:o})}):u?n.jsx(De,{children:n.jsxs(Fe,{children:[U.brain.chatgpt.codeBefore,n.jsx("strong",{children:u.code}),U.brain.chatgpt.codeAfter]})}):null,n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:x,disabled:a||e}),u?n.jsx(Yt,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:U.brain.chatgpt.open}):o?n.jsx(I,{variant:"accent",disabled:a||e,onClick:()=>{v.current=typeof window.open=="function"?window.open("","_blank"):null,m(y=>y+1)},children:U.brain.chatgpt.again}):null]}),children:u?n.jsx(PC,{code:u.code,label:U.brain.chatgpt.code}):null})]})}const qW="claude-sonnet-5";function QW({busy:e,problem:t,onBack:s,onConnected:r,accounts:i,claudeModel:a}){const[l,o]=h.useState(!1),[c,u]=h.useState(null),[f,d]=h.useState(null),[m,p]=h.useState(""),v=h.useRef(null);h.useEffect(()=>()=>{const y=v.current;v.current=null,y&&A.anthropicAccountAction(y.id,"cancel-login",y.revision).catch(()=>{})},[]);const w=()=>{const y=v.current;v.current=null,y&&A.anthropicAccountAction(y.id,"cancel-login",y.revision).catch(()=>{}),s()},k=a??qW,g=()=>{o(!0),u(null);const y=typeof window.open=="function"?window.open("","_blank"):null;(async()=>{try{const j=((i==null?void 0:i.accounts)??[]).find(R=>R.auth==="anthropic-oauth"),N=j?{id:j.id}:await A.saveProviderAccount({label:U.brain.cards.claude.title,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:k,enabled:!0}),S=(await A.providerAccounts()).accounts.find(R=>R.id===N.id),C=await A.anthropicAccountAction(S.id,"login",S.revision);v.current={id:S.id,revision:S.revision+1},d({id:S.id,revision:S.revision+1,url:C.verificationUrl??"",attemptId:C.attemptId??""}),y&&C.verificationUrl?y.location.href=C.verificationUrl:y==null||y.close()}catch(j){y==null||y.close(),u(j instanceof he?j.message:String(j))}finally{o(!1)}})()},x=()=>{!f||m.trim()===""||(v.current=null,o(!0),(async()=>{try{await A.anthropicAccountAction(f.id,"complete-login",f.revision,{attemptId:f.attemptId,code:m.trim()});const y=await A.testProviderAccount(f.id);if(y.state!=="connected"){u(y.message);return}u(await r({accountId:f.id,label:U.brain.cards.claude.title,model:k}))}catch(y){u(y instanceof he?y.message:String(y))}finally{o(!1)}})())};return n.jsxs(n.Fragment,{children:[l||e?n.jsx(De,{children:n.jsx(hs,{line:U.brain.checking.claude})}):t??c?n.jsx(De,{children:n.jsx(Fe,{children:t??c})}):null,f?n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{children:U.brain.claude.waiting})}),n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:w,disabled:l}),n.jsx(Yt,{href:f.url,target:"_blank",rel:"noreferrer",children:U.brain.claude.open}),n.jsx(I,{variant:"accent",disabled:l||m.trim()==="",onClick:x,children:U.brain.claude.finish})]}),children:n.jsx(te,{label:U.brain.claude.paste,grow:!0,children:n.jsx(JW,{value:m,onChange:p})})})]}):n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Br,{onClick:w,disabled:e||l}),n.jsx(I,{variant:"accent",disabled:e||l,onClick:g,children:U.brain.claude.start})]})})]})}function JW({value:e,onChange:t}){const s=Qa();return n.jsx("input",{ref:s,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function XW(e){switch(e){case"chrome":return U.browser.chrome;case"chromium":return U.browser.chromium;case"installed":return U.browser.installed;case"skipped":return U.browser.skipped;case"none":return U.browser.missing;default:return null}}function ZW({answers:e,onSettled:t}){const[s,r]=h.useState("checking"),[i,a]=h.useState(null),[l,o]=h.useState(null),[c,u]=h.useState(void 0),[f,d]=h.useState(0),m=h.useRef(!1),p=h.useRef(!1),v=h.useRef(()=>{});if(v.current=k=>{p.current||(p.current=!0,t({...e,browser:k}))},h.useEffect(()=>{let k=!1,g;const x=b=>{k||v.current(b)},y=(b,S)=>{k||(m.current=!1,r("failed"),a(b),o(S??null))},j=async b=>{r("launching");let S;try{S=await A.browserCheck()}catch(C){return y(C instanceof he?C.message:String(C))}if(!k)return S.ok?x(m.current?"installed":b):y(S.message,S.command)},N=async()=>{var C,R;let b;try{b=await A.browser()}catch{return x("other")}if(k)return;const S=b.browser;if(!S)return x("other");if(((C=S.install)==null?void 0:C.state)==="running"){r("installing"),u(S.install.progress),g=window.setTimeout(()=>void N(),1e3);return}if(S.engine!=="none")return j(S.engine);if(m.current)return y(((R=S.install)==null?void 0:R.line)??"");m.current=!0,r("installing"),u(void 0);try{await A.browserInstall()}catch(E){return y(E instanceof he?E.message:String(E))}k||(g=window.setTimeout(()=>void N(),1e3))};return N(),()=>{k=!0,window.clearTimeout(g)}},[f]),s==="checking")return n.jsx(hs,{});const w=s==="installing"||s==="launching";return n.jsxs(n.Fragment,{children:[n.jsxs(De,{children:[m.current||s==="installing"?n.jsx(Fe,{children:U.browser.needs}):null,s==="installing"?n.jsx("div",{className:"wb-msg","data-role":"assistant",children:n.jsx("div",{className:"wb-bubble",children:n.jsx(g1,{progress:c})})}):s==="launching"?n.jsx(hs,{line:U.browser.launching}):n.jsx(Fe,{children:U.browser.failed(i??"")})]}),n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>v.current("skipped"),children:U.browser.skip}),n.jsx(I,{variant:"accent",disabled:w,onClick:()=>{r("launching"),o(null),d(k=>k+1)},children:w?U.browser.installing:U.browser.retry})]}),children:s==="failed"&&l?n.jsx(eH,{command:l}):null})]})}function eH({command:e}){const[t,s]=h.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){s("failed");return}navigator.clipboard.writeText(e).then(()=>s("done"),()=>s("failed"))};return n.jsxs(q,{gap:"sm",children:[n.jsx(Nt,{label:"The command to run",children:e}),n.jsxs(Q,{align:"end",children:[t==="failed"?n.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,n.jsx(I,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function tH({answers:e,existing:t,onSettled:s,onTrouble:r,onReload:i}){const[a,l]=h.useState(()=>(t==null?void 0:t.name)??dO),[o,c]=h.useState(()=>t!=null&&t.picture?{kind:"kept",url:t.picture}:t!=null&&t.avatar?{kind:"emoji",value:t.avatar}:{kind:"mascot",role:"core"}),[u,f]=h.useState(t?null:U.assistant.purposeValue),[d,m]=h.useState(t?"":U.assistant.purposeValue);h.useEffect(()=>{if(!t)return;let k=!1;return A.firstAgentPersona().then(g=>{k||(f(g.persona),m(g.persona))},g=>{k||r(g instanceof he?g.message:String(g))}),()=>{k=!0}},[t==null?void 0:t.id]);const[p,v]=h.useState(!1),w=()=>{if(a.trim()===""||p)return;v(!0);const k=o.kind==="emoji"?{avatar:o.value}:{},g=!t||u!==null&&d.trim()!==""&&d.trim()!==u.trim()?{instructions:d.trim()}:{},x=t?A.updateFirstAgent({name:a.trim(),...g,...k}):A.createFirstAgent({name:a.trim(),handle:bW(a),description:"",...g,...k,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let y;try{y=await x}catch(N){r(N instanceof he?N.message:String(N)),v(!1);return}let j=null;try{o.kind==="mascot"?await A.uploadAgentPicture(y.id,await mC(o.role)):o.kind==="emoji"&&(t!=null&&t.picture)&&await A.removeAgentPicture(y.id)}catch(N){j=N instanceof he?N.message:String(N)}v(!1),i(),s({...e,assistant:{id:y.id,name:a.trim(),avatar:o.kind==="emoji"?o.value:""}}),j&&r(j)})()};return n.jsxs(At,{actions:n.jsx(I,{variant:"accent",disabled:p||a.trim()===""||u===null,onClick:w,children:U.assistant.submit}),children:[n.jsx("span",{className:"meet-chosen-face","data-kind":o.kind==="emoji"?"emoji":"image","aria-hidden":"true",children:o.kind==="emoji"?o.value:n.jsx("img",{src:o.kind==="mascot"?Gr(o.role):o.url,alt:""})}),n.jsx(te,{label:U.assistant.name,children:n.jsx("input",{value:a,maxLength:60,onChange:k=>l(k.target.value)})}),n.jsx(pC,{face:o,onPick:c}),n.jsx(te,{label:U.assistant.purpose,wide:!0,children:n.jsx("textarea",{className:"meet-purpose",value:d,maxLength:8e3,rows:Math.max(4,d.split(`
125
- `).length+1),onChange:k=>m(k.target.value)})})]})}function nH({answers:e,assistantAgent:t,met:s,onMet:r,onCarriesOn:i,onClosed:a,navigate:l,onPickAnotherBrain:o}){const c=e.assistant,[u,f]=h.useState(s),[d,m]=h.useState([]),[p,v]=h.useState(!1),[w,k]=h.useState(!1),[g,x]=h.useState(!0),[y,j]=h.useState("open"),[N,b]=h.useState(null);h.useEffect(()=>{let $=!1;return Promise.resolve().then(()=>A.telegram()).then(_=>{$||b((_==null?void 0:_.paired)===!0)}).catch(()=>{$||b(!1)}),()=>{$=!0}},[]);const[S,C]=h.useState(!1),R=PE(),E=h.useRef(!1),P=h.useMemo(()=>t?[t]:[],[t]);h.useEffect(()=>{if(!c||E.current)return;if(E.current=!0,s){f(s);return}let $=!1;return(async()=>{try{const _=await Le.startConversation(c.id);if($)return;f(_.conversationId),r(_.conversationId),await A.onboardingStep(EE.handover,{conversationId:_.conversationId}).catch(()=>{}),await Le.send(c.id,{conversationId:_.conversationId,text:pO,opening:!0})}catch{$||(x(!1),v(!0))}})(),()=>{$=!0}},[c==null?void 0:c.id,s]),h.useEffect(()=>{if(!u)return;let $=!1;const _=Date.now(),K=()=>{Le.conversation(u).then(Y=>{if($)return;m(Y.messages);const B=Date.now()-_;if(Y.messages.some(Ww)){x(!1),v(!1),k(!1);return}const V=Y.runs??[],de=V.some(le=>le.finishedAt===null),ae=V.length>0&&!de;k(de&&B>=SW),(ae||B>=NW)&&(x(!1),v(!0))}).catch(()=>{})};K();const D=window.setInterval(K,IE);return()=>{$=!0,window.clearInterval(D)}},[u]);const F=c&&u?Ke(c.id,u):null,M=d.some(Ww);h.useEffect(()=>{M&&F&&i(F)},[M,F,i]),h.useEffect(()=>{if(!S||!F||R)return;const $=window.setTimeout(()=>l(F,!0),CW);return()=>window.clearTimeout($)},[S,F,R,l]);const T=S&&F!==null;return h.useEffect(()=>{T&&a()},[T,a]),n.jsxs(n.Fragment,{children:[n.jsx(xx,{messages:d,live:[],now:Date.now(),onOpen:()=>{},working:g,agents:P,agentName:(c==null?void 0:c.name)??"",...c?{agentId:c.id}:{},emptyHint:U.handover.waiting,plain:!0,workingLine:U.handover.looking((c==null?void 0:c.name)??"")}),w&&!p?n.jsx(De,{children:n.jsx(Fe,{children:U.handover.slow})}):null,p?n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{children:U.handover.silent})}),n.jsx(At,{actions:n.jsx(I,{variant:"accent",onClick:o,children:U.handover.again})})]}):null,S?n.jsx(De,{children:n.jsx(Fe,{children:U.done.said})}):null,M&&N!==null&&!p?n.jsx(De,{children:n.jsx(Fe,{children:N?U.offers.paired((c==null?void 0:c.name)??""):U.offers.said((c==null?void 0:c.name)??"")})}):null,M&&N!==null&&y==="open"?n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:N?"accent":"default",onClick:()=>{j("gone"),C(!0)},children:U.offers.notNow}),N?null:n.jsx(I,{variant:"accent",onClick:()=>j("phone"),children:U.offers.phone})]})}):null,M&&y==="phone"?n.jsx(sH,{onPaired:()=>C(!0),onDismiss:()=>{j("gone"),C(!0)}}):null,T&&F?n.jsx(At,{actions:n.jsx(Yt,{variant:"accent",href:F,onClick:$=>{$.preventDefault(),l(F,!0)},children:U.done.open}),children:n.jsx("span",{className:"meet-line",children:R?U.done.ready:U.done.leaving})}):null]})}function Ww(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function sH({onPaired:e,onDismiss:t}){const s=Qa(),[r,i]=h.useState(""),[a,l]=h.useState(!1),[o,c]=h.useState(null),{offer:u,square:f,paired:d,stale:m,ask:p}=bE(()=>A.telegram().then(k=>k.paired),e),v=()=>{r.trim()===""||a||(l(!0),c(null),(async()=>{try{const k=await A.saveTelegramToken(r.trim());if(i(""),k.restartNeeded){c(k.note??U.telegram.restart);return}await p()}catch(k){c(k instanceof he?k.message:String(k))}finally{l(!1)}})())},w=()=>{c(null),p().catch(k=>c(k instanceof he?k.message:String(k)))};return d?n.jsx(De,{children:n.jsx(Fe,{children:U.telegram.paired})}):u?n.jsxs(n.Fragment,{children:[n.jsx(De,{children:n.jsx(Fe,{children:m?U.telegram.expired:U.telegram.scan})}),n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:t,children:U.offers.notNow}),m?n.jsx(I,{variant:"accent",onClick:w,children:U.telegram.newCode}):null]}),children:m?null:n.jsx(kE,{offer:u,square:f})})]}):n.jsxs(n.Fragment,{children:[n.jsxs(De,{children:[n.jsx(Fe,{children:U.telegram.how}),o?n.jsx(Fe,{children:o}):null]}),n.jsx(At,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:t,children:U.offers.notNow}),n.jsx(I,{variant:"accent",disabled:a||r.trim()==="",onClick:v,children:U.telegram.submit})]}),children:n.jsx(te,{label:U.telegram.field,grow:!0,children:n.jsx("input",{ref:s,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:k=>i(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),v())}})})})]})}const rH="(max-width: 1080px)";function iH(){const[e,t]=h.useState(()=>window.location.hash||Vt);h.useEffect(()=>{const r=()=>t(window.location.hash||Vt);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const s=h.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,s]}function aH(){const[e,t]=nC();h.useEffect(()=>{tC(e)},[e]);const s=h.useCallback(r=>t({theme:r}),[t]);return[e.theme,s]}const Hw=new Map;function lH(){var _e,Te,pt;const[e,t]=iH(),[s,r]=h.useState("UTC"),[i,a]=h.useState({approvals:0,failed:0}),[l,o]=aH(),c=Ia(Ax),[u,f]=h.useState(!1),[d,m]=h.useState([]),[p,v]=h.useState(null),[w,k]=h.useState(null),[g,x]=h.useState([]),[y,j]=h.useState(!1),[N,b]=h.useState(null),S=YD(),C=d.find(O=>O.id===p)??null,R=C!==null&&x3(e),[E,P]=h.useState(!1),F=h.useCallback(()=>P(!0),[]);h.useEffect(()=>{R||P(!1)},[R]),cU(t,Yc(e)===null,R?F:void 0);const M=Ia(rH),T=kC(),$=ZN(),_=Q1(),K=ie(()=>Promise.resolve().then(()=>A.version()),[],MD),D=K.data;WD(K.reload);const Y=D&&!D.checkout&&D.updateAvailable?D:null,B=Zg(D==null?void 0:D.web);HD(D==null?void 0:D.web);const V=((_e=ie(()=>Promise.resolve().then(()=>A.connectionSignals()),[],6e4).data)==null?void 0:_e.signals)??[],[de,ae]=h.useState(new Map);h.useEffect(()=>{const O=()=>{A.conversations().then(Xe=>{const Ge=new Map;for(const gt of Xe.conversations){const Be=gt.lastMessageAt??gt.createdAt,at=Ge.get(gt.agentId);(!at||Be>at)&&Ge.set(gt.agentId,Be)}ae(Ge)}).catch(()=>{})};O();const ve=window.setInterval(O,3e4);return()=>window.clearInterval(ve)},[e]);const[le,Ce]=h.useState(!1);h.useEffect(()=>{if(le)return;let O=!1;return A.onboarding().then(ve=>{O||(Ce(!0),ve.state==="pending"&&ve.needs.model&&!Yc(window.location.hash)&&t(aD,!0))}).catch(()=>{O||Ce(!0)}),()=>{O=!0}},[le,t]),h.useEffect(()=>{const O=yD(e);O&&t(O,!0)},[e,t]),h.useEffect(()=>{let O=!1;const ve=()=>{Le.agents().then(Ge=>{O||(m(Ge.agents),ED(Ge.defaultAgentId??null),v(Ge.defaultAgentId??null),k(gt=>{var Be;return gt??Ge.defaultAgentId??((Be=Ge.agents[0])==null?void 0:Be.id)??null}))}).catch(()=>{})};ve();const Xe=window.setInterval(ve,15e3);return window.addEventListener("focus",ve),window.addEventListener(ro,ve),()=>{O=!0,window.clearInterval(Xe),window.removeEventListener("focus",ve),window.removeEventListener(ro,ve)}},[e]),h.useEffect(()=>{let O=!1;const ve=()=>{Le.groups().then(Ge=>{O||x(Ge.groups)}).catch(()=>{})};ve();const Xe=window.setInterval(ve,3e4);return()=>{O=!0,window.clearInterval(Xe)}},[e]);const ee=pN(d,p),ce=oD(e),fe=cN(e),je=fe?g.find(O=>O.id===fe.groupId)??null:null,X=fe?null:(ce==null?void 0:ce.agentId)??w;h.useEffect(()=>{ce&&k(ce.agentId)},[ce==null?void 0:ce.agentId]);const be=O=>{k(O),t(Ke(O))},Ee=O=>t(Tl(O)),qe=h.useCallback((O,ve,Xe=!0)=>t(fe?Tl(fe.groupId,ve):Ke(O,ve),Xe),[t,fe==null?void 0:fe.groupId]),[Ie,et]=h.useState(!1);h.useEffect(()=>{A.session().then(O=>{r(O.timezone),et(!0)}).catch(()=>{})},[]);const z=C3(Ie);I3(Ie,z.refresh,()=>et(!1)),h.useEffect(()=>{const O=()=>{A.overview().then(Xe=>a({approvals:Xe.approvals.pending,failed:Xe.jobs.failed??0})).catch(()=>{})};O();const ve=window.setInterval(O,2e4);return()=>window.clearInterval(ve)},[]),h.useEffect(()=>{if(!Ie)return;if(e===wD){j(!0),t(Ar,!0);return}const O=bD(e),ve=new Date().toDateString();!O||Hw.get(O)===ve||(Hw.set(O,ve),A.tipsSeenPage(O).catch(()=>{}))},[e,Ie,t]);const se=Yc(e),Ae=hN(e),Me=Ae===Ar,ot=N?g.find(O=>O.id===N)??null:null,Ne=y?n.jsx(rw,{agents:d,onClose:()=>j(!1),onCreated:O=>{x(ve=>[...ve,O]),j(!1),t(Tl(O.id))}}):ot?n.jsx(rw,{agents:d,group:ot,onClose:()=>b(null),onSaved:O=>{x(ve=>ve.map(Xe=>Xe.id===O.id?O:Xe)),b(null)},onArchived:O=>{x(ve=>ve.filter(Xe=>Xe.id!==O)),b(null),t(Ar)}}):null;return se?n.jsx(Jj,{delayDuration:400,children:n.jsxs(Lj,{swipeDirection:"right",children:[n.jsx(AW,{navigate:t,timezone:s}),n.jsx(Fj,{className:"ui-toasts"})]})}):n.jsx(jO,{picture:(Te=d.find(O=>O.id===p))==null?void 0:Te.picture,children:n.jsx(Jj,{delayDuration:400,children:n.jsxs(Lj,{swipeDirection:"right",children:[Ne,n.jsxs("div",{className:"wb-shell",children:[n.jsx(tz,{active:((pt=T.data)==null?void 0:pt.active)===!0,onNavigate:t}),n.jsxs("div",{className:"wb",children:[n.jsx(J6,{attention:i.approvals+i.failed,place:Ae,onNavigate:t,theme:l,onTheme:o,plugins:lU($.rail,_),updateAvailable:Y!==null,settingsDot:V.length>0?Y1:void 0,stale:B,timezone:s,version:D&&!D.checkout?{current:D.current,latest:D.latest,updateAvailable:D.updateAvailable}:D?{current:D.current,updateAvailable:!1}:void 0}),Me&&!M?n.jsx(wN,{agents:ee,currentId:X,attention:S,onSelect:be,lastActivity:de,groups:g,currentGroupId:(je==null?void 0:je.id)??null,onSelectGroup:Ee,onNewGroup:()=>j(!0)}):null,Me?n.jsx(a3,{timezone:s,agents:ee,agentId:je?je.coordinator:X,defaultAgentId:p,group:je,onEditGroup:je?()=>b(je.id):void 0,requestedConversationId:(fe==null?void 0:fe.conversationId)??(ce==null?void 0:ce.conversationId),requestedTab:ce==null?void 0:ce.tab,onConversationOpened:qe,onSelectAgent:be,attention:S,agentsInHeader:M,narrow:c,canvasOpen:u,onOpenCanvas:()=>f(!0),onCloseCanvas:()=>f(!1)}):n.jsx("main",{"data-ground":oH(Ae,e)?"plain":void 0,"data-layout":Ae===tn?"split":void 0,children:n.jsx(cH,{hash:e,place:Ae,timezone:s,navigate:t,agents:d,defaultAgentId:p,attention:S,pluginPages:$,update:Y,connectionSignals:V})})]})]}),R&&C?n.jsx(v3,{agent:C,agents:d,open:E,onOpenChange:P,navigate:t}):null,n.jsxs(S3,{placement:k3(R,E),children:[n.jsx(E3,{queue:z.queue,agents:d,navigate:t,onDismiss:z.dismiss}),n.jsx(Fj,{className:"ui-toasts"})]})]})})})}function oH(e,t){return qg(t)!==null}function cH({place:e,pluginPages:t,...s}){const r={...s,pluginPages:t},i=qg(s.hash);if(i){const a=t.find(i.plugin,i.page);if(a)return n.jsx(V1,{page:a,item:i.item??null,navigate:s.navigate,timezone:s.timezone,siblings:t.all.filter(l=>l.plugin===i.plugin)});if(t.all.length===0)return n.jsx(n.Fragment,{})}switch(e){case ut:return n.jsx(fB,{...s});case jt:return n.jsx(kU,{...s});case tn:return n.jsx(q8,{...r});case bi:return n.jsx(G6,{...s});default:return n.jsx(FB,{...s})}}function uH(){"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=`./sw.js?v=${encodeURIComponent(Xg)}`;navigator.serviceWorker.register(e,{scope:"./"}).catch(()=>{})})}const OE=1e4,dH=3e4,_E=6e3,hH=/^(localhost|127(?:\.\d{1,3}){3}|\[?::1\]?)$|\.localhost$/i;function fH(e){return hH.test(e)?n.jsxs(n.Fragment,{children:["Is buddi running on this Mac? ",n.jsx("code",{children:"buddi status"})," says."]}):n.jsx(n.Fragment,{children:"Is Tailscale on, and the Mac it runs on awake?"})}async function LE(e){let t;const s=new Promise((r,i)=>{t=setTimeout(()=>i(new he(0,Tu)),e)});try{return{up:!0,version:await Promise.race([A.version(),s])}}catch(r){return dP(r)?{up:!1}:{up:!0}}finally{clearTimeout(t)}}function FE(e){var t;return e.up&&Zg((t=e.version)==null?void 0:t.web)?(window.location.reload(),!1):e.up}function mH({host:e,onRetry:t,retrying:s}){return n.jsxs("main",{className:"unreachable",role:"alert",children:[n.jsx("span",{className:"ui-blob","data-size":"lg","aria-hidden":"true",children:n.jsx("img",{src:Gr("core"),alt:""})}),n.jsxs("h1",{children:["buddi isn't answering at ",e,"."]}),n.jsx("p",{children:fH(e.replace(/:\d+$/,""))}),n.jsx("div",{className:"unreachable-actions",children:n.jsx(I,{variant:"accent",onClick:t,disabled:s,children:s?"Retrying…":"Retry"})})]})}function pH({children:e}){const[t,s]=h.useState("checking"),[r,i]=h.useState(!1),a=h.useRef(!1),l=h.useCallback(async()=>{if(a.current)return;a.current=!0,i(!0);const o=await LE(_E);a.current=!1,i(!1),s(c=>c==="checking"?o.up?"up":"down":FE(o)?"up":"down")},[]);return h.useEffect(()=>{l()},[l]),h.useEffect(()=>{if(t!=="down")return;const o=window.setInterval(()=>void l(),OE);return()=>window.clearInterval(o)},[t,l]),t==="checking"?null:t==="down"?n.jsx(mH,{host:window.location.host,onRetry:()=>void l(),retrying:r}):n.jsxs(n.Fragment,{children:[n.jsx(xH,{}),e]})}function gH(e=dH){const[t,s]=h.useState(!1);return h.useEffect(()=>{let r;const i=()=>{clearTimeout(r);const l=cP();if(l===null)return s(!1);const o=l+e-Date.now();o<=0?s(!0):r=setTimeout(i,o)};i();const a=uP(i);return()=>{a(),clearTimeout(r)}},[e]),t}function xH(){const e=gH();return h.useEffect(()=>{if(!e)return;const t=window.setInterval(()=>{LE(_E).then(FE)},OE);return()=>window.clearInterval(t)},[e]),e?n.jsx("div",{className:"lost-bar",role:"status",children:"Lost buddi. Retrying…"}):null}function vH({search:e=location.search}){const[t,s]=h.useState(null),r=h.useRef(!1);return h.useEffect(()=>{if(r.current)return;r.current=!0;const i=new URLSearchParams(e);try{history.replaceState(null,"",location.pathname)}catch{}const a=i.get("state")??"",l=i.get("code")??void 0,o=i.get("error")??void 0;A.connectionCallback({state:a,...l?{code:l}:{},...o?{error:o}:{}}).then(c=>{s({ok:!0,name:c.name});try{const u=new BroadcastChannel(qC);u.postMessage({id:c.id}),u.close()}catch{}window.setTimeout(()=>{try{window.close()}catch{}},1500)}).catch(c=>s({ok:!1,message:c instanceof Error?c.message:String(c)}))},[e]),n.jsx("main",{className:"ui-page connections-callback",children:n.jsxs(q,{gap:"lg",children:[n.jsx("h2",{className:"ui-page-title",children:"Connections"}),t===null?n.jsx(H,{tone:"accent",role:"status",children:"Finishing the sign-in…"}):null,t!=null&&t.ok?n.jsx(H,{tone:"good",role:"status",title:`Signed in to ${t.name}`,children:"buddi keeps the sign-in in its vault. You can close this tab; the other one carries on."}):null,t&&!t.ok?n.jsx(H,{tone:"critical",role:"alert",title:"Nothing was connected",children:t.message}):null,t?n.jsx(Yt,{href:"/#/settings/connections",children:"Back to Connections"}):null]})})}const Vw=document.getElementById("root");Vw&&rk(Vw).render(n.jsx(h.StrictMode,{children:location.pathname==="/connections/callback"?n.jsx(vH,{}):n.jsx(pH,{children:n.jsx(lH,{})})}));uH();export{yH as c,lA as g};