@withbuddi/buddi 0.1.0-pre.21 → 0.1.0-pre.23

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 (1456) hide show
  1. package/README.md +6 -4
  2. package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
  3. package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
  4. package/node_modules/@buddi/cli/dist/commands.js +24 -2
  5. package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
  6. package/node_modules/@buddi/cli/dist/doctor-probes.d.ts.map +1 -1
  7. package/node_modules/@buddi/cli/dist/doctor-probes.js +1 -0
  8. package/node_modules/@buddi/cli/dist/doctor-probes.js.map +1 -1
  9. package/node_modules/@buddi/cli/dist/doctor.d.ts +2 -0
  10. package/node_modules/@buddi/cli/dist/doctor.d.ts.map +1 -1
  11. package/node_modules/@buddi/cli/dist/doctor.js +7 -0
  12. package/node_modules/@buddi/cli/dist/doctor.js.map +1 -1
  13. package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
  14. package/node_modules/@buddi/core/dist/actions/permissions.d.ts +14 -0
  15. package/node_modules/@buddi/core/dist/actions/permissions.d.ts.map +1 -1
  16. package/node_modules/@buddi/core/dist/actions/permissions.js +15 -0
  17. package/node_modules/@buddi/core/dist/actions/permissions.js.map +1 -1
  18. package/node_modules/@buddi/core/dist/agents/catalog.d.ts +49 -3
  19. package/node_modules/@buddi/core/dist/agents/catalog.d.ts.map +1 -1
  20. package/node_modules/@buddi/core/dist/agents/catalog.js +104 -15
  21. package/node_modules/@buddi/core/dist/agents/catalog.js.map +1 -1
  22. package/node_modules/@buddi/core/dist/agents/delegates.d.ts +54 -0
  23. package/node_modules/@buddi/core/dist/agents/delegates.d.ts.map +1 -0
  24. package/node_modules/@buddi/core/dist/agents/delegates.js +51 -0
  25. package/node_modules/@buddi/core/dist/agents/delegates.js.map +1 -0
  26. package/node_modules/@buddi/core/dist/agents/index.d.ts +1 -0
  27. package/node_modules/@buddi/core/dist/agents/index.d.ts.map +1 -1
  28. package/node_modules/@buddi/core/dist/agents/index.js +1 -0
  29. package/node_modules/@buddi/core/dist/agents/index.js.map +1 -1
  30. package/node_modules/@buddi/core/dist/home.d.ts +30 -1
  31. package/node_modules/@buddi/core/dist/home.d.ts.map +1 -1
  32. package/node_modules/@buddi/core/dist/home.js +1 -1
  33. package/node_modules/@buddi/core/dist/home.js.map +1 -1
  34. package/node_modules/@buddi/core/dist/host/build.d.ts +26 -5
  35. package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
  36. package/node_modules/@buddi/core/dist/host/build.js +109 -3
  37. package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
  38. package/node_modules/@buddi/core/dist/host/http.d.ts +32 -0
  39. package/node_modules/@buddi/core/dist/host/http.d.ts.map +1 -1
  40. package/node_modules/@buddi/core/dist/host/http.js +102 -2
  41. package/node_modules/@buddi/core/dist/host/http.js.map +1 -1
  42. package/node_modules/@buddi/core/dist/host/types.d.ts +75 -5
  43. package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
  44. package/node_modules/@buddi/core/dist/index.d.ts +2 -0
  45. package/node_modules/@buddi/core/dist/index.d.ts.map +1 -1
  46. package/node_modules/@buddi/core/dist/index.js +2 -0
  47. package/node_modules/@buddi/core/dist/index.js.map +1 -1
  48. package/node_modules/@buddi/core/dist/json-schema.d.ts +32 -0
  49. package/node_modules/@buddi/core/dist/json-schema.d.ts.map +1 -0
  50. package/node_modules/@buddi/core/dist/json-schema.js +147 -0
  51. package/node_modules/@buddi/core/dist/json-schema.js.map +1 -0
  52. package/node_modules/@buddi/core/dist/learning/announce.d.ts +1 -1
  53. package/node_modules/@buddi/core/dist/learning/sources.d.ts.map +1 -1
  54. package/node_modules/@buddi/core/dist/learning/sources.js +3 -0
  55. package/node_modules/@buddi/core/dist/learning/sources.js.map +1 -1
  56. package/node_modules/@buddi/core/dist/learning/types.d.ts +4 -3
  57. package/node_modules/@buddi/core/dist/learning/types.d.ts.map +1 -1
  58. package/node_modules/@buddi/core/dist/learning/types.js +1 -1
  59. package/node_modules/@buddi/core/dist/learning/types.js.map +1 -1
  60. package/node_modules/@buddi/core/dist/notifications/focus.d.ts +42 -0
  61. package/node_modules/@buddi/core/dist/notifications/focus.d.ts.map +1 -0
  62. package/node_modules/@buddi/core/dist/notifications/focus.js +150 -0
  63. package/node_modules/@buddi/core/dist/notifications/focus.js.map +1 -0
  64. package/node_modules/@buddi/core/dist/notifications/index.d.ts +2 -0
  65. package/node_modules/@buddi/core/dist/notifications/index.d.ts.map +1 -1
  66. package/node_modules/@buddi/core/dist/notifications/index.js +2 -0
  67. package/node_modules/@buddi/core/dist/notifications/index.js.map +1 -1
  68. package/node_modules/@buddi/core/dist/notifications/notify.d.ts +66 -7
  69. package/node_modules/@buddi/core/dist/notifications/notify.d.ts.map +1 -1
  70. package/node_modules/@buddi/core/dist/notifications/notify.js +166 -39
  71. package/node_modules/@buddi/core/dist/notifications/notify.js.map +1 -1
  72. package/node_modules/@buddi/core/dist/notifications/store.d.ts +6 -4
  73. package/node_modules/@buddi/core/dist/notifications/store.d.ts.map +1 -1
  74. package/node_modules/@buddi/core/dist/notifications/store.js +26 -23
  75. package/node_modules/@buddi/core/dist/notifications/store.js.map +1 -1
  76. package/node_modules/@buddi/core/dist/notifications/topic.d.ts +25 -0
  77. package/node_modules/@buddi/core/dist/notifications/topic.d.ts.map +1 -0
  78. package/node_modules/@buddi/core/dist/notifications/topic.js +116 -0
  79. package/node_modules/@buddi/core/dist/notifications/topic.js.map +1 -0
  80. package/node_modules/@buddi/core/dist/notifications/types.d.ts +50 -3
  81. package/node_modules/@buddi/core/dist/notifications/types.d.ts.map +1 -1
  82. package/node_modules/@buddi/core/dist/notifications/types.js +12 -0
  83. package/node_modules/@buddi/core/dist/notifications/types.js.map +1 -1
  84. package/node_modules/@buddi/core/dist/onboarding/language-tag.d.ts +12 -0
  85. package/node_modules/@buddi/core/dist/onboarding/language-tag.d.ts.map +1 -0
  86. package/node_modules/@buddi/core/dist/onboarding/language-tag.js +64 -0
  87. package/node_modules/@buddi/core/dist/onboarding/language-tag.js.map +1 -0
  88. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts +11 -0
  89. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  90. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js +23 -1
  91. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js.map +1 -1
  92. package/node_modules/@buddi/core/dist/pages.d.ts +204 -5
  93. package/node_modules/@buddi/core/dist/pages.d.ts.map +1 -1
  94. package/node_modules/@buddi/core/dist/pages.js +244 -12
  95. package/node_modules/@buddi/core/dist/pages.js.map +1 -1
  96. package/node_modules/@buddi/core/dist/plugin/author.d.ts +42 -0
  97. package/node_modules/@buddi/core/dist/plugin/author.d.ts.map +1 -0
  98. package/node_modules/@buddi/core/dist/plugin/author.js +77 -0
  99. package/node_modules/@buddi/core/dist/plugin/author.js.map +1 -0
  100. package/node_modules/@buddi/core/dist/plugin/index.d.ts +11 -6
  101. package/node_modules/@buddi/core/dist/plugin/index.d.ts.map +1 -1
  102. package/node_modules/@buddi/core/dist/plugin/index.js +3 -0
  103. package/node_modules/@buddi/core/dist/plugin/index.js.map +1 -1
  104. package/node_modules/@buddi/core/dist/plugin/version.d.ts +1 -1
  105. package/node_modules/@buddi/core/dist/plugin/version.d.ts.map +1 -1
  106. package/node_modules/@buddi/core/dist/plugin/version.js +1 -1
  107. package/node_modules/@buddi/core/dist/plugin/version.js.map +1 -1
  108. package/node_modules/@buddi/core/dist/plugins/record.d.ts +8 -0
  109. package/node_modules/@buddi/core/dist/plugins/record.d.ts.map +1 -1
  110. package/node_modules/@buddi/core/dist/plugins/record.js +17 -0
  111. package/node_modules/@buddi/core/dist/plugins/record.js.map +1 -1
  112. package/node_modules/@buddi/core/dist/plugins/types.d.ts +7 -0
  113. package/node_modules/@buddi/core/dist/plugins/types.d.ts.map +1 -1
  114. package/node_modules/@buddi/core/dist/plugins/types.js.map +1 -1
  115. package/node_modules/@buddi/core/dist/provider-accounts.d.ts +31 -0
  116. package/node_modules/@buddi/core/dist/provider-accounts.d.ts.map +1 -1
  117. package/node_modules/@buddi/core/dist/registry.d.ts +39 -1
  118. package/node_modules/@buddi/core/dist/registry.d.ts.map +1 -1
  119. package/node_modules/@buddi/core/dist/registry.js +202 -36
  120. package/node_modules/@buddi/core/dist/registry.js.map +1 -1
  121. package/node_modules/@buddi/core/dist/scheduler/materialize.js +1 -1
  122. package/node_modules/@buddi/core/dist/scheduler/missions.d.ts +10 -0
  123. package/node_modules/@buddi/core/dist/scheduler/missions.d.ts.map +1 -1
  124. package/node_modules/@buddi/core/dist/scheduler/missions.js +29 -1
  125. package/node_modules/@buddi/core/dist/scheduler/missions.js.map +1 -1
  126. package/node_modules/@buddi/core/dist/scheduler/types.d.ts +7 -0
  127. package/node_modules/@buddi/core/dist/scheduler/types.d.ts.map +1 -1
  128. package/node_modules/@buddi/core/dist/scheduler/types.js +1 -0
  129. package/node_modules/@buddi/core/dist/scheduler/types.js.map +1 -1
  130. package/node_modules/@buddi/core/dist/secrets/scrub.d.ts +2 -0
  131. package/node_modules/@buddi/core/dist/secrets/scrub.d.ts.map +1 -1
  132. package/node_modules/@buddi/core/dist/secrets/scrub.js +29 -0
  133. package/node_modules/@buddi/core/dist/secrets/scrub.js.map +1 -1
  134. package/node_modules/@buddi/core/dist/tools.d.ts +44 -1
  135. package/node_modules/@buddi/core/dist/tools.d.ts.map +1 -1
  136. package/node_modules/@buddi/core/dist/tools.js.map +1 -1
  137. package/node_modules/@buddi/core/dist/views.d.ts +190 -15
  138. package/node_modules/@buddi/core/dist/views.d.ts.map +1 -1
  139. package/node_modules/@buddi/core/dist/views.js +56 -1
  140. package/node_modules/@buddi/core/dist/views.js.map +1 -1
  141. package/node_modules/@buddi/core/migrations/050_notification_topic.sql +8 -0
  142. package/node_modules/@buddi/core/migrations/051_notification_focus.sql +20 -0
  143. package/node_modules/@buddi/core/migrations/052_mission_paused_reason.sql +6 -0
  144. package/node_modules/@buddi/core/package.json +2 -0
  145. package/node_modules/@buddi/gateway/assets/mascot/core-idle.tgs +0 -0
  146. package/node_modules/@buddi/gateway/assets/mascot/core-working.tgs +0 -0
  147. package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
  148. package/node_modules/@buddi/gateway/dist/agents/canvas.d.ts +2 -2
  149. package/node_modules/@buddi/gateway/dist/agents/canvas.d.ts.map +1 -1
  150. package/node_modules/@buddi/gateway/dist/agents/canvas.js.map +1 -1
  151. package/node_modules/@buddi/gateway/dist/agents/catalog.d.ts +6 -0
  152. package/node_modules/@buddi/gateway/dist/agents/catalog.d.ts.map +1 -1
  153. package/node_modules/@buddi/gateway/dist/agents/catalog.js +31 -6
  154. package/node_modules/@buddi/gateway/dist/agents/catalog.js.map +1 -1
  155. package/node_modules/@buddi/gateway/dist/agents/delegation.d.ts +20 -3
  156. package/node_modules/@buddi/gateway/dist/agents/delegation.d.ts.map +1 -1
  157. package/node_modules/@buddi/gateway/dist/agents/delegation.js +38 -12
  158. package/node_modules/@buddi/gateway/dist/agents/delegation.js.map +1 -1
  159. package/node_modules/@buddi/gateway/dist/agents/platform.d.ts +43 -13
  160. package/node_modules/@buddi/gateway/dist/agents/platform.d.ts.map +1 -1
  161. package/node_modules/@buddi/gateway/dist/agents/platform.js +97 -3
  162. package/node_modules/@buddi/gateway/dist/agents/platform.js.map +1 -1
  163. package/node_modules/@buddi/gateway/dist/agents/starter-team.d.ts +59 -0
  164. package/node_modules/@buddi/gateway/dist/agents/starter-team.d.ts.map +1 -0
  165. package/node_modules/@buddi/gateway/dist/agents/starter-team.js +156 -0
  166. package/node_modules/@buddi/gateway/dist/agents/starter-team.js.map +1 -0
  167. package/node_modules/@buddi/gateway/dist/anthropic-accounts.d.ts.map +1 -1
  168. package/node_modules/@buddi/gateway/dist/anthropic-accounts.js +9 -20
  169. package/node_modules/@buddi/gateway/dist/anthropic-accounts.js.map +1 -1
  170. package/node_modules/@buddi/gateway/dist/bootstrap.d.ts +3 -0
  171. package/node_modules/@buddi/gateway/dist/bootstrap.d.ts.map +1 -1
  172. package/node_modules/@buddi/gateway/dist/bootstrap.js +58 -2
  173. package/node_modules/@buddi/gateway/dist/bootstrap.js.map +1 -1
  174. package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts +7 -1
  175. package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts.map +1 -1
  176. package/node_modules/@buddi/gateway/dist/codex-accounts.js +25 -26
  177. package/node_modules/@buddi/gateway/dist/codex-accounts.js.map +1 -1
  178. package/node_modules/@buddi/gateway/dist/mcp/requests.d.ts +8 -1
  179. package/node_modules/@buddi/gateway/dist/mcp/requests.d.ts.map +1 -1
  180. package/node_modules/@buddi/gateway/dist/mcp/requests.js +8 -1
  181. package/node_modules/@buddi/gateway/dist/mcp/requests.js.map +1 -1
  182. package/node_modules/@buddi/gateway/dist/missions/goals-page.d.ts.map +1 -1
  183. package/node_modules/@buddi/gateway/dist/missions/goals-page.js +57 -0
  184. package/node_modules/@buddi/gateway/dist/missions/goals-page.js.map +1 -1
  185. package/node_modules/@buddi/gateway/dist/missions-cli.d.ts.map +1 -1
  186. package/node_modules/@buddi/gateway/dist/missions-cli.js +6 -3
  187. package/node_modules/@buddi/gateway/dist/missions-cli.js.map +1 -1
  188. package/node_modules/@buddi/gateway/dist/plugins/approve.d.ts.map +1 -1
  189. package/node_modules/@buddi/gateway/dist/plugins/approve.js +54 -11
  190. package/node_modules/@buddi/gateway/dist/plugins/approve.js.map +1 -1
  191. package/node_modules/@buddi/gateway/dist/plugins/index.d.ts +1 -0
  192. package/node_modules/@buddi/gateway/dist/plugins/index.d.ts.map +1 -1
  193. package/node_modules/@buddi/gateway/dist/plugins/index.js +1 -0
  194. package/node_modules/@buddi/gateway/dist/plugins/index.js.map +1 -1
  195. package/node_modules/@buddi/gateway/dist/plugins/load.d.ts +5 -0
  196. package/node_modules/@buddi/gateway/dist/plugins/load.d.ts.map +1 -1
  197. package/node_modules/@buddi/gateway/dist/plugins/load.js +14 -1
  198. package/node_modules/@buddi/gateway/dist/plugins/load.js.map +1 -1
  199. package/node_modules/@buddi/gateway/dist/plugins/npm.d.ts +5 -1
  200. package/node_modules/@buddi/gateway/dist/plugins/npm.d.ts.map +1 -1
  201. package/node_modules/@buddi/gateway/dist/plugins/npm.js +6 -0
  202. package/node_modules/@buddi/gateway/dist/plugins/npm.js.map +1 -1
  203. package/node_modules/@buddi/gateway/dist/plugins/provenance.d.ts.map +1 -1
  204. package/node_modules/@buddi/gateway/dist/plugins/provenance.js +10 -3
  205. package/node_modules/@buddi/gateway/dist/plugins/provenance.js.map +1 -1
  206. package/node_modules/@buddi/gateway/dist/plugins/scaffold.d.ts +23 -4
  207. package/node_modules/@buddi/gateway/dist/plugins/scaffold.d.ts.map +1 -1
  208. package/node_modules/@buddi/gateway/dist/plugins/scaffold.js +130 -21
  209. package/node_modules/@buddi/gateway/dist/plugins/scaffold.js.map +1 -1
  210. package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts +41 -2
  211. package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts.map +1 -1
  212. package/node_modules/@buddi/gateway/dist/plugins/stage.js +137 -9
  213. package/node_modules/@buddi/gateway/dist/plugins/stage.js.map +1 -1
  214. package/node_modules/@buddi/gateway/dist/plugins/toggle.d.ts +21 -0
  215. package/node_modules/@buddi/gateway/dist/plugins/toggle.d.ts.map +1 -0
  216. package/node_modules/@buddi/gateway/dist/plugins/toggle.js +86 -0
  217. package/node_modules/@buddi/gateway/dist/plugins/toggle.js.map +1 -0
  218. package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts +23 -3
  219. package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts.map +1 -1
  220. package/node_modules/@buddi/gateway/dist/plugins-cli.js +102 -10
  221. package/node_modules/@buddi/gateway/dist/plugins-cli.js.map +1 -1
  222. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
  223. package/node_modules/@buddi/gateway/dist/provider-accounts.js +31 -3
  224. package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
  225. package/node_modules/@buddi/gateway/dist/provider-diagnostics.d.ts +14 -2
  226. package/node_modules/@buddi/gateway/dist/provider-diagnostics.d.ts.map +1 -1
  227. package/node_modules/@buddi/gateway/dist/provider-diagnostics.js +25 -9
  228. package/node_modules/@buddi/gateway/dist/provider-diagnostics.js.map +1 -1
  229. package/node_modules/@buddi/gateway/dist/serve.js +3 -3
  230. package/node_modules/@buddi/gateway/dist/serve.js.map +1 -1
  231. package/node_modules/@buddi/gateway/dist/speech-cli.d.ts +13 -0
  232. package/node_modules/@buddi/gateway/dist/speech-cli.d.ts.map +1 -1
  233. package/node_modules/@buddi/gateway/dist/speech-cli.js +40 -1
  234. package/node_modules/@buddi/gateway/dist/speech-cli.js.map +1 -1
  235. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts +49 -0
  236. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts.map +1 -1
  237. package/node_modules/@buddi/gateway/dist/telegram/api.js +99 -0
  238. package/node_modules/@buddi/gateway/dist/telegram/api.js.map +1 -1
  239. package/node_modules/@buddi/gateway/dist/telegram/focus.d.ts +27 -0
  240. package/node_modules/@buddi/gateway/dist/telegram/focus.d.ts.map +1 -0
  241. package/node_modules/@buddi/gateway/dist/telegram/focus.js +72 -0
  242. package/node_modules/@buddi/gateway/dist/telegram/focus.js.map +1 -0
  243. package/node_modules/@buddi/gateway/dist/telegram/main.d.ts.map +1 -1
  244. package/node_modules/@buddi/gateway/dist/telegram/main.js +18 -0
  245. package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
  246. package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts +5 -0
  247. package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts.map +1 -1
  248. package/node_modules/@buddi/gateway/dist/telegram/outbound.js +10 -0
  249. package/node_modules/@buddi/gateway/dist/telegram/outbound.js.map +1 -1
  250. package/node_modules/@buddi/gateway/dist/telegram/stickers.d.ts +30 -0
  251. package/node_modules/@buddi/gateway/dist/telegram/stickers.d.ts.map +1 -0
  252. package/node_modules/@buddi/gateway/dist/telegram/stickers.js +146 -0
  253. package/node_modules/@buddi/gateway/dist/telegram/stickers.js.map +1 -0
  254. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +8 -0
  255. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
  256. package/node_modules/@buddi/gateway/dist/telegram/surface.js +60 -4
  257. package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
  258. package/node_modules/@buddi/gateway/dist/tips/engine.d.ts +75 -0
  259. package/node_modules/@buddi/gateway/dist/tips/engine.d.ts.map +1 -0
  260. package/node_modules/@buddi/gateway/dist/tips/engine.js +135 -0
  261. package/node_modules/@buddi/gateway/dist/tips/engine.js.map +1 -0
  262. package/node_modules/@buddi/gateway/dist/tips/facts.d.ts +69 -0
  263. package/node_modules/@buddi/gateway/dist/tips/facts.d.ts.map +1 -0
  264. package/node_modules/@buddi/gateway/dist/tips/facts.js +104 -0
  265. package/node_modules/@buddi/gateway/dist/tips/facts.js.map +1 -0
  266. package/node_modules/@buddi/gateway/dist/tips/route.d.ts +25 -0
  267. package/node_modules/@buddi/gateway/dist/tips/route.d.ts.map +1 -0
  268. package/node_modules/@buddi/gateway/dist/tips/route.js +96 -0
  269. package/node_modules/@buddi/gateway/dist/tips/route.js.map +1 -0
  270. package/node_modules/@buddi/gateway/dist/tips/rules.d.ts +33 -0
  271. package/node_modules/@buddi/gateway/dist/tips/rules.d.ts.map +1 -0
  272. package/node_modules/@buddi/gateway/dist/tips/rules.js +54 -0
  273. package/node_modules/@buddi/gateway/dist/tips/rules.js.map +1 -0
  274. package/node_modules/@buddi/gateway/dist/web/agent-offers.d.ts +30 -0
  275. package/node_modules/@buddi/gateway/dist/web/agent-offers.d.ts.map +1 -1
  276. package/node_modules/@buddi/gateway/dist/web/agent-offers.js +64 -1
  277. package/node_modules/@buddi/gateway/dist/web/agent-offers.js.map +1 -1
  278. package/node_modules/@buddi/gateway/dist/web/connections.d.ts +83 -0
  279. package/node_modules/@buddi/gateway/dist/web/connections.d.ts.map +1 -0
  280. package/node_modules/@buddi/gateway/dist/web/connections.js +270 -0
  281. package/node_modules/@buddi/gateway/dist/web/connections.js.map +1 -0
  282. package/node_modules/@buddi/gateway/dist/web/notifications.d.ts +8 -1
  283. package/node_modules/@buddi/gateway/dist/web/notifications.d.ts.map +1 -1
  284. package/node_modules/@buddi/gateway/dist/web/notifications.js +23 -1
  285. package/node_modules/@buddi/gateway/dist/web/notifications.js.map +1 -1
  286. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +1 -1
  287. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
  288. package/node_modules/@buddi/gateway/dist/web/onboarding.js +5 -4
  289. package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
  290. package/node_modules/@buddi/gateway/dist/web/plugins.d.ts +18 -1
  291. package/node_modules/@buddi/gateway/dist/web/plugins.d.ts.map +1 -1
  292. package/node_modules/@buddi/gateway/dist/web/plugins.js +54 -6
  293. package/node_modules/@buddi/gateway/dist/web/plugins.js.map +1 -1
  294. package/node_modules/@buddi/gateway/dist/web/profile.d.ts +2 -0
  295. package/node_modules/@buddi/gateway/dist/web/profile.d.ts.map +1 -1
  296. package/node_modules/@buddi/gateway/dist/web/profile.js +5 -3
  297. package/node_modules/@buddi/gateway/dist/web/profile.js.map +1 -1
  298. package/node_modules/@buddi/gateway/dist/web/rail.d.ts +33 -0
  299. package/node_modules/@buddi/gateway/dist/web/rail.d.ts.map +1 -0
  300. package/node_modules/@buddi/gateway/dist/web/rail.js +45 -0
  301. package/node_modules/@buddi/gateway/dist/web/rail.js.map +1 -0
  302. package/node_modules/@buddi/gateway/dist/web/read.d.ts +52 -0
  303. package/node_modules/@buddi/gateway/dist/web/read.d.ts.map +1 -1
  304. package/node_modules/@buddi/gateway/dist/web/read.js +88 -5
  305. package/node_modules/@buddi/gateway/dist/web/read.js.map +1 -1
  306. package/node_modules/@buddi/gateway/dist/web/server.d.ts +6 -0
  307. package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
  308. package/node_modules/@buddi/gateway/dist/web/server.js +107 -8
  309. package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
  310. package/node_modules/@buddi/gateway/dist/web/static.d.ts.map +1 -1
  311. package/node_modules/@buddi/gateway/dist/web/static.js +1 -0
  312. package/node_modules/@buddi/gateway/dist/web/static.js.map +1 -1
  313. package/node_modules/@buddi/gateway/dist/web/version.d.ts +2 -0
  314. package/node_modules/@buddi/gateway/dist/web/version.d.ts.map +1 -1
  315. package/node_modules/@buddi/gateway/dist/web/version.js +27 -0
  316. package/node_modules/@buddi/gateway/dist/web/version.js.map +1 -1
  317. package/node_modules/@buddi/gateway/dist/web/write.d.ts +5 -0
  318. package/node_modules/@buddi/gateway/dist/web/write.d.ts.map +1 -1
  319. package/node_modules/@buddi/gateway/dist/web/write.js +20 -1
  320. package/node_modules/@buddi/gateway/dist/web/write.js.map +1 -1
  321. package/node_modules/@buddi/gateway/package.json +4 -1
  322. package/node_modules/@buddi/gateway/src/agents/starter/keeper/agent.md +31 -0
  323. package/node_modules/@buddi/gateway/src/agents/starter/keeper/skills/keeping-a-history.md +22 -0
  324. package/node_modules/@buddi/gateway/src/agents/starter/planner/agent.md +30 -0
  325. package/node_modules/@buddi/gateway/src/agents/starter/planner/skills/holding-a-follow-up.md +17 -0
  326. package/node_modules/@buddi/gateway/src/agents/starter/planner/skills/writing-the-morning-brief.md +32 -0
  327. package/node_modules/@buddi/gateway/src/agents/starter/scout/agent.md +33 -0
  328. package/node_modules/@buddi/gateway/src/agents/starter/scout/skills/answering-with-sources.md +23 -0
  329. package/node_modules/@buddi/gateway/src/agents/starter/scout/skills/the-web-is-evidence.md +25 -0
  330. package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
  331. package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
  332. package/node_modules/@buddi/runtime/dist/anthropic-oauth.d.ts.map +1 -1
  333. package/node_modules/@buddi/runtime/dist/anthropic-oauth.js +38 -73
  334. package/node_modules/@buddi/runtime/dist/anthropic-oauth.js.map +1 -1
  335. package/node_modules/@buddi/runtime/dist/codex-direct.d.ts +39 -0
  336. package/node_modules/@buddi/runtime/dist/codex-direct.d.ts.map +1 -1
  337. package/node_modules/@buddi/runtime/dist/codex-direct.js +122 -0
  338. package/node_modules/@buddi/runtime/dist/codex-direct.js.map +1 -1
  339. package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts +0 -12
  340. package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts.map +1 -1
  341. package/node_modules/@buddi/runtime/dist/codex-oauth.js +32 -45
  342. package/node_modules/@buddi/runtime/dist/codex-oauth.js.map +1 -1
  343. package/node_modules/@buddi/runtime/dist/delegate.d.ts.map +1 -1
  344. package/node_modules/@buddi/runtime/dist/delegate.js +4 -2
  345. package/node_modules/@buddi/runtime/dist/delegate.js.map +1 -1
  346. package/node_modules/@buddi/runtime/dist/index.d.ts +2 -0
  347. package/node_modules/@buddi/runtime/dist/index.d.ts.map +1 -1
  348. package/node_modules/@buddi/runtime/dist/index.js +2 -0
  349. package/node_modules/@buddi/runtime/dist/index.js.map +1 -1
  350. package/node_modules/@buddi/runtime/dist/oauth-port.d.ts +68 -0
  351. package/node_modules/@buddi/runtime/dist/oauth-port.d.ts.map +1 -0
  352. package/node_modules/@buddi/runtime/dist/oauth-port.js +51 -0
  353. package/node_modules/@buddi/runtime/dist/oauth-port.js.map +1 -0
  354. package/node_modules/@buddi/runtime/dist/oauth.d.ts +255 -0
  355. package/node_modules/@buddi/runtime/dist/oauth.d.ts.map +1 -0
  356. package/node_modules/@buddi/runtime/dist/oauth.js +535 -0
  357. package/node_modules/@buddi/runtime/dist/oauth.js.map +1 -0
  358. package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
  359. package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
  360. package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
  361. package/node_modules/@buddi/tool-email/dist/types.d.ts +2 -2
  362. package/node_modules/@buddi/tool-email/dist/types.d.ts.map +1 -1
  363. package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
  364. package/node_modules/@buddi/tool-mcp/dist/.tsbuildinfo +1 -0
  365. package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts +26 -0
  366. package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts.map +1 -0
  367. package/node_modules/@buddi/tool-mcp/dist/catalog.js +17 -0
  368. package/node_modules/@buddi/tool-mcp/dist/catalog.js.map +1 -0
  369. package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts +44 -0
  370. package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts.map +1 -0
  371. package/node_modules/@buddi/tool-mcp/dist/fetch.js +88 -0
  372. package/node_modules/@buddi/tool-mcp/dist/fetch.js.map +1 -0
  373. package/node_modules/@buddi/tool-mcp/dist/index.d.ts +27 -0
  374. package/node_modules/@buddi/tool-mcp/dist/index.d.ts.map +1 -0
  375. package/node_modules/@buddi/tool-mcp/dist/index.js +74 -0
  376. package/node_modules/@buddi/tool-mcp/dist/index.js.map +1 -0
  377. package/node_modules/@buddi/tool-mcp/dist/output.d.ts +38 -0
  378. package/node_modules/@buddi/tool-mcp/dist/output.d.ts.map +1 -0
  379. package/node_modules/@buddi/tool-mcp/dist/output.js +90 -0
  380. package/node_modules/@buddi/tool-mcp/dist/output.js.map +1 -0
  381. package/node_modules/@buddi/tool-mcp/dist/ports.d.ts +105 -0
  382. package/node_modules/@buddi/tool-mcp/dist/ports.d.ts.map +1 -0
  383. package/node_modules/@buddi/tool-mcp/dist/ports.js +9 -0
  384. package/node_modules/@buddi/tool-mcp/dist/ports.js.map +1 -0
  385. package/node_modules/@buddi/tool-mcp/dist/service.d.ts +220 -0
  386. package/node_modules/@buddi/tool-mcp/dist/service.d.ts.map +1 -0
  387. package/node_modules/@buddi/tool-mcp/dist/service.js +742 -0
  388. package/node_modules/@buddi/tool-mcp/dist/service.js.map +1 -0
  389. package/node_modules/@buddi/tool-mcp/dist/session.d.ts +50 -0
  390. package/node_modules/@buddi/tool-mcp/dist/session.d.ts.map +1 -0
  391. package/node_modules/@buddi/tool-mcp/dist/session.js +108 -0
  392. package/node_modules/@buddi/tool-mcp/dist/session.js.map +1 -0
  393. package/node_modules/@buddi/tool-mcp/dist/store.d.ts +70 -0
  394. package/node_modules/@buddi/tool-mcp/dist/store.d.ts.map +1 -0
  395. package/node_modules/@buddi/tool-mcp/dist/store.js +78 -0
  396. package/node_modules/@buddi/tool-mcp/dist/store.js.map +1 -0
  397. package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts +51 -0
  398. package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts.map +1 -0
  399. package/node_modules/@buddi/tool-mcp/dist/testing/fake.js +147 -0
  400. package/node_modules/@buddi/tool-mcp/dist/testing/fake.js.map +1 -0
  401. package/node_modules/@buddi/tool-mcp/dist/tiers.d.ts +51 -0
  402. package/node_modules/@buddi/tool-mcp/dist/tiers.d.ts.map +1 -0
  403. package/node_modules/@buddi/tool-mcp/dist/tiers.js +106 -0
  404. package/node_modules/@buddi/tool-mcp/dist/tiers.js.map +1 -0
  405. package/node_modules/@buddi/tool-mcp/dist/tokens.d.ts +35 -0
  406. package/node_modules/@buddi/tool-mcp/dist/tokens.d.ts.map +1 -0
  407. package/node_modules/@buddi/tool-mcp/dist/tokens.js +75 -0
  408. package/node_modules/@buddi/tool-mcp/dist/tokens.js.map +1 -0
  409. package/node_modules/@buddi/tool-mcp/migrations/001_connections.sql +49 -0
  410. package/node_modules/@buddi/tool-mcp/migrations/002_review_again.sql +15 -0
  411. package/node_modules/@buddi/tool-mcp/package.json +34 -0
  412. package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
  413. package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
  414. package/node_modules/@zone-eu/mailsplit/lib/flowed-decoder.js +1 -5
  415. package/node_modules/@zone-eu/mailsplit/lib/headers.js +35 -25
  416. package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +126 -79
  417. package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +27 -5
  418. package/node_modules/@zone-eu/mailsplit/lib/node-rewriter.js +3 -2
  419. package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +0 -3
  420. package/node_modules/@zone-eu/mailsplit/package.json +5 -5
  421. package/node_modules/hono/dist/_virtual/_rolldown/runtime.js +13 -0
  422. package/node_modules/hono/dist/adapter/aws-lambda/conninfo.js +42 -23
  423. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +318 -344
  424. package/node_modules/hono/dist/adapter/aws-lambda/index.js +2 -8
  425. package/node_modules/hono/dist/adapter/aws-lambda/types.js +1 -0
  426. package/node_modules/hono/dist/adapter/bun/conninfo.js +20 -25
  427. package/node_modules/hono/dist/adapter/bun/index.js +3 -13
  428. package/node_modules/hono/dist/adapter/bun/serve-static.js +27 -27
  429. package/node_modules/hono/dist/adapter/bun/server.js +11 -5
  430. package/node_modules/hono/dist/adapter/bun/ssg.js +25 -15
  431. package/node_modules/hono/dist/adapter/bun/websocket.js +61 -68
  432. package/node_modules/hono/dist/adapter/cloudflare-pages/conninfo.js +24 -9
  433. package/node_modules/hono/dist/adapter/cloudflare-pages/handler.js +59 -62
  434. package/node_modules/hono/dist/adapter/cloudflare-pages/index.js +2 -8
  435. package/node_modules/hono/dist/adapter/cloudflare-workers/conninfo.js +7 -9
  436. package/node_modules/hono/dist/adapter/cloudflare-workers/index.js +3 -8
  437. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static-module.js +5 -6
  438. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static.js +26 -20
  439. package/node_modules/hono/dist/adapter/cloudflare-workers/utils.js +21 -34
  440. package/node_modules/hono/dist/adapter/cloudflare-workers/websocket.js +31 -39
  441. package/node_modules/hono/dist/adapter/deno/conninfo.js +16 -13
  442. package/node_modules/hono/dist/adapter/deno/deno.d.js +1 -0
  443. package/node_modules/hono/dist/adapter/deno/index.js +3 -10
  444. package/node_modules/hono/dist/adapter/deno/serve-static.js +33 -38
  445. package/node_modules/hono/dist/adapter/deno/ssg.js +27 -16
  446. package/node_modules/hono/dist/adapter/deno/websocket.js +30 -30
  447. package/node_modules/hono/dist/adapter/lambda-edge/conninfo.js +7 -9
  448. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +102 -101
  449. package/node_modules/hono/dist/adapter/lambda-edge/index.js +2 -6
  450. package/node_modules/hono/dist/adapter/netlify/conninfo.js +24 -9
  451. package/node_modules/hono/dist/adapter/netlify/handler.js +10 -8
  452. package/node_modules/hono/dist/adapter/netlify/index.js +3 -2
  453. package/node_modules/hono/dist/adapter/netlify/mod.js +2 -6
  454. package/node_modules/hono/dist/adapter/service-worker/handler.js +15 -19
  455. package/node_modules/hono/dist/adapter/service-worker/index.js +23 -7
  456. package/node_modules/hono/dist/adapter/service-worker/types.js +1 -0
  457. package/node_modules/hono/dist/adapter/vercel/conninfo.js +7 -10
  458. package/node_modules/hono/dist/adapter/vercel/handler.js +8 -6
  459. package/node_modules/hono/dist/adapter/vercel/index.js +2 -6
  460. package/node_modules/hono/dist/cjs/_virtual/_rolldown/runtime.js +33 -0
  461. package/node_modules/hono/dist/cjs/adapter/aws-lambda/conninfo.js +42 -44
  462. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +326 -373
  463. package/node_modules/hono/dist/cjs/adapter/aws-lambda/index.js +7 -34
  464. package/node_modules/hono/dist/cjs/adapter/aws-lambda/types.js +0 -15
  465. package/node_modules/hono/dist/cjs/adapter/bun/conninfo.js +21 -47
  466. package/node_modules/hono/dist/cjs/adapter/bun/index.js +14 -45
  467. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +29 -50
  468. package/node_modules/hono/dist/cjs/adapter/bun/server.js +11 -26
  469. package/node_modules/hono/dist/cjs/adapter/bun/ssg.js +24 -35
  470. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +63 -91
  471. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/conninfo.js +25 -31
  472. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/handler.js +61 -85
  473. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/index.js +7 -34
  474. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/conninfo.js +8 -31
  475. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/index.js +7 -33
  476. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +7 -29
  477. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static.js +27 -42
  478. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/utils.js +21 -55
  479. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/websocket.js +33 -62
  480. package/node_modules/hono/dist/cjs/adapter/deno/conninfo.js +16 -34
  481. package/node_modules/hono/dist/cjs/adapter/deno/index.js +10 -38
  482. package/node_modules/hono/dist/cjs/adapter/deno/serve-static.js +33 -59
  483. package/node_modules/hono/dist/cjs/adapter/deno/ssg.js +27 -37
  484. package/node_modules/hono/dist/cjs/adapter/deno/websocket.js +32 -53
  485. package/node_modules/hono/dist/cjs/adapter/lambda-edge/conninfo.js +8 -31
  486. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +102 -130
  487. package/node_modules/hono/dist/cjs/adapter/lambda-edge/index.js +5 -30
  488. package/node_modules/hono/dist/cjs/adapter/netlify/conninfo.js +25 -31
  489. package/node_modules/hono/dist/cjs/adapter/netlify/handler.js +10 -29
  490. package/node_modules/hono/dist/cjs/adapter/netlify/index.js +5 -21
  491. package/node_modules/hono/dist/cjs/adapter/netlify/mod.js +5 -30
  492. package/node_modules/hono/dist/cjs/adapter/service-worker/handler.js +16 -41
  493. package/node_modules/hono/dist/cjs/adapter/service-worker/index.js +25 -30
  494. package/node_modules/hono/dist/cjs/adapter/service-worker/types.js +0 -15
  495. package/node_modules/hono/dist/cjs/adapter/vercel/conninfo.js +8 -32
  496. package/node_modules/hono/dist/cjs/adapter/vercel/handler.js +8 -27
  497. package/node_modules/hono/dist/cjs/adapter/vercel/index.js +5 -30
  498. package/node_modules/hono/dist/cjs/client/client.js +139 -212
  499. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +62 -80
  500. package/node_modules/hono/dist/cjs/client/index.js +7 -32
  501. package/node_modules/hono/dist/cjs/client/types.js +0 -15
  502. package/node_modules/hono/dist/cjs/client/utils.js +54 -92
  503. package/node_modules/hono/dist/cjs/compose.js +49 -66
  504. package/node_modules/hono/dist/cjs/context.js +379 -450
  505. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +47 -72
  506. package/node_modules/hono/dist/cjs/helper/accepts/index.js +3 -27
  507. package/node_modules/hono/dist/cjs/helper/adapter/index.js +33 -73
  508. package/node_modules/hono/dist/cjs/helper/conninfo/index.js +0 -15
  509. package/node_modules/hono/dist/cjs/helper/conninfo/types.js +0 -15
  510. package/node_modules/hono/dist/cjs/helper/cookie/index.js +75 -116
  511. package/node_modules/hono/dist/cjs/helper/css/common.js +165 -244
  512. package/node_modules/hono/dist/cjs/helper/css/index.js +136 -151
  513. package/node_modules/hono/dist/cjs/helper/dev/index.js +45 -71
  514. package/node_modules/hono/dist/cjs/helper/factory/index.js +30 -51
  515. package/node_modules/hono/dist/cjs/helper/html/index.js +32 -62
  516. package/node_modules/hono/dist/cjs/helper/proxy/index.js +113 -106
  517. package/node_modules/hono/dist/cjs/helper/route/index.js +123 -66
  518. package/node_modules/hono/dist/cjs/helper/ssg/index.js +19 -43
  519. package/node_modules/hono/dist/cjs/helper/ssg/middleware.js +56 -64
  520. package/node_modules/hono/dist/cjs/helper/ssg/plugins.js +55 -57
  521. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +196 -296
  522. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +47 -90
  523. package/node_modules/hono/dist/cjs/helper/streaming/index.js +8 -35
  524. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +53 -85
  525. package/node_modules/hono/dist/cjs/helper/streaming/stream.js +23 -53
  526. package/node_modules/hono/dist/cjs/helper/streaming/text.js +10 -32
  527. package/node_modules/hono/dist/cjs/helper/streaming/utils.js +13 -32
  528. package/node_modules/hono/dist/cjs/helper/testing/index.js +16 -31
  529. package/node_modules/hono/dist/cjs/helper/websocket/index.js +51 -76
  530. package/node_modules/hono/dist/cjs/hono-base.js +345 -403
  531. package/node_modules/hono/dist/cjs/hono.js +28 -42
  532. package/node_modules/hono/dist/cjs/http-exception.js +55 -56
  533. package/node_modules/hono/dist/cjs/index.js +22 -30
  534. package/node_modules/hono/dist/cjs/jsx/base.js +237 -366
  535. package/node_modules/hono/dist/cjs/jsx/children.js +16 -41
  536. package/node_modules/hono/dist/cjs/jsx/components.js +119 -192
  537. package/node_modules/hono/dist/cjs/jsx/constants.js +15 -42
  538. package/node_modules/hono/dist/cjs/jsx/context.js +144 -162
  539. package/node_modules/hono/dist/cjs/jsx/dom/client.js +49 -69
  540. package/node_modules/hono/dist/cjs/jsx/dom/components.js +23 -52
  541. package/node_modules/hono/dist/cjs/jsx/dom/context.js +39 -67
  542. package/node_modules/hono/dist/cjs/jsx/dom/css.js +143 -158
  543. package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +55 -64
  544. package/node_modules/hono/dist/cjs/jsx/dom/index.js +114 -173
  545. package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +282 -375
  546. package/node_modules/hono/dist/cjs/jsx/dom/jsx-dev-runtime.js +14 -49
  547. package/node_modules/hono/dist/cjs/jsx/dom/jsx-runtime.js +5 -32
  548. package/node_modules/hono/dist/cjs/jsx/dom/render.js +469 -623
  549. package/node_modules/hono/dist/cjs/jsx/dom/server.js +37 -64
  550. package/node_modules/hono/dist/cjs/jsx/dom/utils.js +7 -30
  551. package/node_modules/hono/dist/cjs/jsx/hooks/index.js +225 -318
  552. package/node_modules/hono/dist/cjs/jsx/index.js +86 -135
  553. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/common.js +20 -43
  554. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +117 -168
  555. package/node_modules/hono/dist/cjs/jsx/intrinsic-elements.js +0 -15
  556. package/node_modules/hono/dist/cjs/jsx/jsx-dev-runtime.js +14 -39
  557. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +34 -68
  558. package/node_modules/hono/dist/cjs/jsx/streaming.js +123 -166
  559. package/node_modules/hono/dist/cjs/jsx/types.js +0 -15
  560. package/node_modules/hono/dist/cjs/jsx/utils.js +91 -175
  561. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +98 -86
  562. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +92 -109
  563. package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +66 -72
  564. package/node_modules/hono/dist/cjs/middleware/cache/index.js +153 -199
  565. package/node_modules/hono/dist/cjs/middleware/combine/index.js +133 -95
  566. package/node_modules/hono/dist/cjs/middleware/compress/index.js +73 -88
  567. package/node_modules/hono/dist/cjs/middleware/context-storage/index.js +49 -41
  568. package/node_modules/hono/dist/cjs/middleware/cors/index.js +107 -107
  569. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +101 -72
  570. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +58 -97
  571. package/node_modules/hono/dist/cjs/middleware/etag/index.js +71 -91
  572. package/node_modules/hono/dist/cjs/middleware/ip-restriction/index.js +161 -169
  573. package/node_modules/hono/dist/cjs/middleware/jsx-renderer/index.js +99 -77
  574. package/node_modules/hono/dist/cjs/middleware/jwk/index.js +3 -27
  575. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +118 -135
  576. package/node_modules/hono/dist/cjs/middleware/jwt/index.js +9 -38
  577. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +120 -141
  578. package/node_modules/hono/dist/cjs/middleware/language/index.js +7 -35
  579. package/node_modules/hono/dist/cjs/middleware/language/language.js +184 -182
  580. package/node_modules/hono/dist/cjs/middleware/logger/index.js +41 -62
  581. package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +82 -88
  582. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +101 -102
  583. package/node_modules/hono/dist/cjs/middleware/powered-by/index.js +23 -30
  584. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +38 -42
  585. package/node_modules/hono/dist/cjs/middleware/request-id/index.js +3 -27
  586. package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +34 -42
  587. package/node_modules/hono/dist/cjs/middleware/secure-headers/index.js +4 -29
  588. package/node_modules/hono/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -15
  589. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +142 -174
  590. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +55 -93
  591. package/node_modules/hono/dist/cjs/middleware/serve-static/path.js +15 -38
  592. package/node_modules/hono/dist/cjs/middleware/timeout/index.js +40 -45
  593. package/node_modules/hono/dist/cjs/middleware/timing/index.js +7 -35
  594. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +177 -118
  595. package/node_modules/hono/dist/cjs/middleware/trailing-slash/index.js +85 -58
  596. package/node_modules/hono/dist/cjs/preset/quick.js +18 -37
  597. package/node_modules/hono/dist/cjs/preset/tiny.js +15 -33
  598. package/node_modules/hono/dist/cjs/request/constants.js +5 -27
  599. package/node_modules/hono/dist/cjs/request.js +334 -346
  600. package/node_modules/hono/dist/cjs/router/linear-router/index.js +3 -27
  601. package/node_modules/hono/dist/cjs/router/linear-router/router.js +95 -143
  602. package/node_modules/hono/dist/cjs/router/pattern-router/index.js +3 -27
  603. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +41 -63
  604. package/node_modules/hono/dist/cjs/router/reg-exp-router/index.js +7 -34
  605. package/node_modules/hono/dist/cjs/router/reg-exp-router/matcher.js +18 -45
  606. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +91 -135
  607. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +92 -161
  608. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +98 -147
  609. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +73 -89
  610. package/node_modules/hono/dist/cjs/router/smart-router/index.js +3 -27
  611. package/node_modules/hono/dist/cjs/router/smart-router/router.js +49 -79
  612. package/node_modules/hono/dist/cjs/router/trie-router/index.js +3 -27
  613. package/node_modules/hono/dist/cjs/router/trie-router/node.js +134 -186
  614. package/node_modules/hono/dist/cjs/router/trie-router/router.js +15 -39
  615. package/node_modules/hono/dist/cjs/router/utils.js +5 -27
  616. package/node_modules/hono/dist/cjs/router.js +37 -37
  617. package/node_modules/hono/dist/cjs/types.js +5 -28
  618. package/node_modules/hono/dist/cjs/utils/accept.js +177 -225
  619. package/node_modules/hono/dist/cjs/utils/basic-auth.js +16 -40
  620. package/node_modules/hono/dist/cjs/utils/body.js +84 -110
  621. package/node_modules/hono/dist/cjs/utils/buffer.js +43 -91
  622. package/node_modules/hono/dist/cjs/utils/color.js +35 -44
  623. package/node_modules/hono/dist/cjs/utils/compress.js +11 -26
  624. package/node_modules/hono/dist/cjs/utils/concurrent.js +29 -59
  625. package/node_modules/hono/dist/cjs/utils/constants.js +7 -26
  626. package/node_modules/hono/dist/cjs/utils/cookie.js +107 -177
  627. package/node_modules/hono/dist/cjs/utils/crypto.js +30 -61
  628. package/node_modules/hono/dist/cjs/utils/encode.js +31 -48
  629. package/node_modules/hono/dist/cjs/utils/filepath.js +23 -54
  630. package/node_modules/hono/dist/cjs/utils/handler.js +11 -33
  631. package/node_modules/hono/dist/cjs/utils/headers.js +0 -15
  632. package/node_modules/hono/dist/cjs/utils/html.js +96 -137
  633. package/node_modules/hono/dist/cjs/utils/http-status.js +0 -15
  634. package/node_modules/hono/dist/cjs/utils/ipaddr.js +213 -286
  635. package/node_modules/hono/dist/cjs/utils/jwt/index.js +14 -27
  636. package/node_modules/hono/dist/cjs/utils/jwt/jwa.js +25 -42
  637. package/node_modules/hono/dist/cjs/utils/jwt/jws.js +119 -199
  638. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +122 -206
  639. package/node_modules/hono/dist/cjs/utils/jwt/types.js +122 -159
  640. package/node_modules/hono/dist/cjs/utils/jwt/utf8.js +9 -28
  641. package/node_modules/hono/dist/cjs/utils/mime.js +75 -101
  642. package/node_modules/hono/dist/cjs/utils/stream.js +88 -111
  643. package/node_modules/hono/dist/cjs/utils/types.js +0 -15
  644. package/node_modules/hono/dist/cjs/utils/url.js +185 -234
  645. package/node_modules/hono/dist/cjs/validator/index.js +3 -27
  646. package/node_modules/hono/dist/cjs/validator/utils.js +0 -15
  647. package/node_modules/hono/dist/cjs/validator/validator.js +60 -103
  648. package/node_modules/hono/dist/client/client.js +138 -197
  649. package/node_modules/hono/dist/client/fetch-result-please.js +59 -56
  650. package/node_modules/hono/dist/client/index.js +3 -7
  651. package/node_modules/hono/dist/client/types.js +1 -0
  652. package/node_modules/hono/dist/client/utils.js +51 -68
  653. package/node_modules/hono/dist/compose.js +49 -45
  654. package/node_modules/hono/dist/context.js +376 -426
  655. package/node_modules/hono/dist/helper/accepts/accepts.js +47 -51
  656. package/node_modules/hono/dist/helper/accepts/index.js +1 -4
  657. package/node_modules/hono/dist/helper/adapter/index.js +33 -52
  658. package/node_modules/hono/dist/helper/conninfo/index.js +1 -0
  659. package/node_modules/hono/dist/helper/conninfo/types.js +1 -0
  660. package/node_modules/hono/dist/helper/cookie/index.js +74 -94
  661. package/node_modules/hono/dist/helper/css/common.js +167 -225
  662. package/node_modules/hono/dist/helper/css/index.js +132 -137
  663. package/node_modules/hono/dist/helper/dev/index.js +44 -49
  664. package/node_modules/hono/dist/helper/factory/index.js +27 -27
  665. package/node_modules/hono/dist/helper/html/index.js +30 -39
  666. package/node_modules/hono/dist/helper/proxy/index.js +116 -88
  667. package/node_modules/hono/dist/helper/route/index.js +121 -43
  668. package/node_modules/hono/dist/helper/ssg/index.js +3 -18
  669. package/node_modules/hono/dist/helper/ssg/middleware.js +53 -40
  670. package/node_modules/hono/dist/helper/ssg/plugins.js +55 -36
  671. package/node_modules/hono/dist/helper/ssg/ssg.js +198 -283
  672. package/node_modules/hono/dist/helper/ssg/utils.js +53 -75
  673. package/node_modules/hono/dist/helper/streaming/index.js +2 -8
  674. package/node_modules/hono/dist/helper/streaming/sse.js +50 -61
  675. package/node_modules/hono/dist/helper/streaming/stream.js +22 -31
  676. package/node_modules/hono/dist/helper/streaming/text.js +9 -10
  677. package/node_modules/hono/dist/helper/streaming/utils.js +9 -12
  678. package/node_modules/hono/dist/helper/testing/index.js +16 -10
  679. package/node_modules/hono/dist/helper/websocket/index.js +49 -53
  680. package/node_modules/hono/dist/hono-base.js +342 -379
  681. package/node_modules/hono/dist/hono.js +27 -20
  682. package/node_modules/hono/dist/http-exception.js +53 -33
  683. package/node_modules/hono/dist/index.js +19 -6
  684. package/node_modules/hono/dist/jsx/base.js +231 -340
  685. package/node_modules/hono/dist/jsx/children.js +16 -20
  686. package/node_modules/hono/dist/jsx/components.js +118 -170
  687. package/node_modules/hono/dist/jsx/constants.js +9 -15
  688. package/node_modules/hono/dist/jsx/context.js +153 -150
  689. package/node_modules/hono/dist/jsx/dom/client.js +45 -48
  690. package/node_modules/hono/dist/jsx/dom/components.js +21 -29
  691. package/node_modules/hono/dist/jsx/dom/context.js +37 -44
  692. package/node_modules/hono/dist/jsx/dom/css.js +142 -147
  693. package/node_modules/hono/dist/jsx/dom/hooks/index.js +52 -40
  694. package/node_modules/hono/dist/jsx/dom/index.js +71 -134
  695. package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +275 -359
  696. package/node_modules/hono/dist/jsx/dom/jsx-dev-runtime.js +14 -18
  697. package/node_modules/hono/dist/jsx/dom/jsx-runtime.js +2 -8
  698. package/node_modules/hono/dist/jsx/dom/render.js +492 -631
  699. package/node_modules/hono/dist/jsx/dom/server.js +32 -32
  700. package/node_modules/hono/dist/jsx/dom/utils.js +6 -8
  701. package/node_modules/hono/dist/jsx/hooks/index.js +236 -308
  702. package/node_modules/hono/dist/jsx/index.js +45 -98
  703. package/node_modules/hono/dist/jsx/intrinsic-element/common.js +20 -22
  704. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +113 -154
  705. package/node_modules/hono/dist/jsx/intrinsic-elements.js +1 -0
  706. package/node_modules/hono/dist/jsx/jsx-dev-runtime.js +12 -16
  707. package/node_modules/hono/dist/jsx/jsx-runtime.js +29 -42
  708. package/node_modules/hono/dist/jsx/streaming.js +120 -142
  709. package/node_modules/hono/dist/jsx/types.js +1 -0
  710. package/node_modules/hono/dist/jsx/utils.js +105 -168
  711. package/node_modules/hono/dist/middleware/basic-auth/index.js +96 -63
  712. package/node_modules/hono/dist/middleware/bearer-auth/index.js +93 -89
  713. package/node_modules/hono/dist/middleware/body-limit/index.js +66 -51
  714. package/node_modules/hono/dist/middleware/cache/index.js +165 -190
  715. package/node_modules/hono/dist/middleware/combine/index.js +132 -73
  716. package/node_modules/hono/dist/middleware/compress/index.js +75 -69
  717. package/node_modules/hono/dist/middleware/context-storage/index.js +49 -19
  718. package/node_modules/hono/dist/middleware/cors/index.js +107 -86
  719. package/node_modules/hono/dist/middleware/csrf/index.js +103 -53
  720. package/node_modules/hono/dist/middleware/etag/digest.js +59 -77
  721. package/node_modules/hono/dist/middleware/etag/index.js +71 -70
  722. package/node_modules/hono/dist/middleware/ip-restriction/index.js +163 -158
  723. package/node_modules/hono/dist/middleware/jsx-renderer/index.js +97 -54
  724. package/node_modules/hono/dist/middleware/jwk/index.js +1 -4
  725. package/node_modules/hono/dist/middleware/jwk/jwk.js +116 -112
  726. package/node_modules/hono/dist/middleware/jwt/index.js +2 -10
  727. package/node_modules/hono/dist/middleware/jwt/jwt.js +114 -114
  728. package/node_modules/hono/dist/middleware/language/index.js +2 -15
  729. package/node_modules/hono/dist/middleware/language/language.js +180 -157
  730. package/node_modules/hono/dist/middleware/logger/index.js +43 -37
  731. package/node_modules/hono/dist/middleware/method-not-allowed/index.js +81 -66
  732. package/node_modules/hono/dist/middleware/method-override/index.js +101 -81
  733. package/node_modules/hono/dist/middleware/powered-by/index.js +23 -9
  734. package/node_modules/hono/dist/middleware/pretty-json/index.js +39 -22
  735. package/node_modules/hono/dist/middleware/request-id/index.js +1 -4
  736. package/node_modules/hono/dist/middleware/request-id/request-id.js +33 -20
  737. package/node_modules/hono/dist/middleware/secure-headers/index.js +1 -5
  738. package/node_modules/hono/dist/middleware/secure-headers/permissions-policy.js +1 -0
  739. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +144 -155
  740. package/node_modules/hono/dist/middleware/serve-static/index.js +55 -72
  741. package/node_modules/hono/dist/middleware/serve-static/path.js +15 -17
  742. package/node_modules/hono/dist/middleware/timeout/index.js +40 -23
  743. package/node_modules/hono/dist/middleware/timing/index.js +2 -9
  744. package/node_modules/hono/dist/middleware/timing/timing.js +177 -97
  745. package/node_modules/hono/dist/middleware/trailing-slash/index.js +85 -37
  746. package/node_modules/hono/dist/preset/quick.js +17 -15
  747. package/node_modules/hono/dist/preset/tiny.js +14 -11
  748. package/node_modules/hono/dist/request/constants.js +4 -5
  749. package/node_modules/hono/dist/request.js +328 -319
  750. package/node_modules/hono/dist/router/linear-router/index.js +1 -4
  751. package/node_modules/hono/dist/router/linear-router/router.js +93 -120
  752. package/node_modules/hono/dist/router/pattern-router/index.js +1 -4
  753. package/node_modules/hono/dist/router/pattern-router/router.js +39 -40
  754. package/node_modules/hono/dist/router/reg-exp-router/index.js +1 -7
  755. package/node_modules/hono/dist/router/reg-exp-router/matcher.js +17 -23
  756. package/node_modules/hono/dist/router/reg-exp-router/node.js +87 -110
  757. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +89 -137
  758. package/node_modules/hono/dist/router/reg-exp-router/router.js +92 -129
  759. package/node_modules/hono/dist/router/reg-exp-router/trie.js +69 -64
  760. package/node_modules/hono/dist/router/smart-router/index.js +1 -4
  761. package/node_modules/hono/dist/router/smart-router/router.js +46 -55
  762. package/node_modules/hono/dist/router/trie-router/index.js +1 -4
  763. package/node_modules/hono/dist/router/trie-router/node.js +131 -162
  764. package/node_modules/hono/dist/router/trie-router/router.js +11 -14
  765. package/node_modules/hono/dist/router/utils.js +4 -5
  766. package/node_modules/hono/dist/router.js +35 -14
  767. package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +4 -1
  768. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +150 -105
  769. package/node_modules/hono/dist/types/adapter/aws-lambda/index.d.ts +4 -8
  770. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +152 -123
  771. package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +4 -1
  772. package/node_modules/hono/dist/types/adapter/bun/index.d.ts +6 -10
  773. package/node_modules/hono/dist/types/adapter/bun/serve-static.d.ts +7 -2
  774. package/node_modules/hono/dist/types/adapter/bun/server.d.ts +4 -5
  775. package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +5 -1
  776. package/node_modules/hono/dist/types/adapter/bun/websocket.d.ts +31 -17
  777. package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +4 -1
  778. package/node_modules/hono/dist/types/adapter/cloudflare-pages/handler.d.ts +29 -18
  779. package/node_modules/hono/dist/types/adapter/cloudflare-pages/index.d.ts +3 -7
  780. package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +6 -1
  781. package/node_modules/hono/dist/types/adapter/cloudflare-workers/index.d.ts +4 -7
  782. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +5 -3
  783. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static.d.ts +10 -5
  784. package/node_modules/hono/dist/types/adapter/cloudflare-workers/utils.d.ts +10 -2
  785. package/node_modules/hono/dist/types/adapter/cloudflare-workers/websocket.d.ts +6 -1
  786. package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +4 -1
  787. package/node_modules/hono/dist/types/adapter/deno/deno.d.ts +1 -0
  788. package/node_modules/hono/dist/types/adapter/deno/index.d.ts +5 -8
  789. package/node_modules/hono/dist/types/adapter/deno/serve-static.d.ts +7 -2
  790. package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +5 -1
  791. package/node_modules/hono/dist/types/adapter/deno/websocket.d.ts +6 -1
  792. package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +6 -1
  793. package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +83 -58
  794. package/node_modules/hono/dist/types/adapter/lambda-edge/index.d.ts +3 -7
  795. package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +4 -1
  796. package/node_modules/hono/dist/types/adapter/netlify/handler.d.ts +6 -1
  797. package/node_modules/hono/dist/types/adapter/netlify/index.d.ts +3 -5
  798. package/node_modules/hono/dist/types/adapter/netlify/mod.d.ts +3 -2
  799. package/node_modules/hono/dist/types/adapter/service-worker/handler.d.ts +9 -8
  800. package/node_modules/hono/dist/types/adapter/service-worker/index.d.ts +6 -9
  801. package/node_modules/hono/dist/types/adapter/service-worker/types.d.ts +12 -8
  802. package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +6 -1
  803. package/node_modules/hono/dist/types/adapter/vercel/handler.d.ts +6 -1
  804. package/node_modules/hono/dist/types/adapter/vercel/index.d.ts +3 -6
  805. package/node_modules/hono/dist/types/client/client.d.ts +5 -3
  806. package/node_modules/hono/dist/types/client/fetch-result-please.d.ts +21 -19
  807. package/node_modules/hono/dist/types/client/index.d.ts +5 -7
  808. package/node_modules/hono/dist/types/client/types.d.ts +134 -160
  809. package/node_modules/hono/dist/types/client/utils.d.ts +6 -4
  810. package/node_modules/hono/dist/types/compose.d.ts +4 -2
  811. package/node_modules/hono/dist/types/context.d.ts +335 -336
  812. package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +11 -9
  813. package/node_modules/hono/dist/types/helper/accepts/index.d.ts +2 -5
  814. package/node_modules/hono/dist/types/helper/adapter/index.d.ts +4 -6
  815. package/node_modules/hono/dist/types/helper/conninfo/index.d.ts +2 -5
  816. package/node_modules/hono/dist/types/helper/conninfo/types.d.ts +25 -23
  817. package/node_modules/hono/dist/types/helper/cookie/index.d.ts +10 -13
  818. package/node_modules/hono/dist/types/helper/css/common.d.ts +11 -10
  819. package/node_modules/hono/dist/types/helper/css/index.d.ts +25 -28
  820. package/node_modules/hono/dist/types/helper/dev/index.d.ts +10 -13
  821. package/node_modules/hono/dist/types/helper/factory/index.d.ts +26 -74
  822. package/node_modules/hono/dist/types/helper/html/index.d.ts +4 -7
  823. package/node_modules/hono/dist/types/helper/proxy/index.d.ts +19 -22
  824. package/node_modules/hono/dist/types/helper/route/index.d.ts +4 -2
  825. package/node_modules/hono/dist/types/helper/ssg/index.d.ts +4 -7
  826. package/node_modules/hono/dist/types/helper/ssg/middleware.d.ts +8 -7
  827. package/node_modules/hono/dist/types/helper/ssg/plugins.d.ts +3 -1
  828. package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +38 -36
  829. package/node_modules/hono/dist/types/helper/ssg/utils.d.ts +5 -4
  830. package/node_modules/hono/dist/types/helper/streaming/index.d.ts +4 -8
  831. package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +10 -8
  832. package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +4 -2
  833. package/node_modules/hono/dist/types/helper/streaming/text.d.ts +4 -2
  834. package/node_modules/hono/dist/types/helper/streaming/utils.d.ts +2 -0
  835. package/node_modules/hono/dist/types/helper/testing/index.d.ts +7 -10
  836. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +30 -33
  837. package/node_modules/hono/dist/types/hono-base.d.ts +208 -211
  838. package/node_modules/hono/dist/types/hono.d.ts +11 -10
  839. package/node_modules/hono/dist/types/http-exception.d.ts +20 -23
  840. package/node_modules/hono/dist/types/index.d.ts +6 -37
  841. package/node_modules/hono/dist/types/jsx/base.d.ts +36 -35
  842. package/node_modules/hono/dist/types/jsx/children.d.ts +8 -6
  843. package/node_modules/hono/dist/types/jsx/components.d.ts +8 -5
  844. package/node_modules/hono/dist/types/jsx/constants.d.ts +2 -0
  845. package/node_modules/hono/dist/types/jsx/context.d.ts +9 -7
  846. package/node_modules/hono/dist/types/jsx/dom/client.d.ts +8 -10
  847. package/node_modules/hono/dist/types/jsx/dom/components.d.ts +9 -6
  848. package/node_modules/hono/dist/types/jsx/dom/context.d.ts +3 -1
  849. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +26 -30
  850. package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +11 -13
  851. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +78 -83
  852. package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +9 -5
  853. package/node_modules/hono/dist/types/jsx/dom/jsx-dev-runtime.d.ts +4 -6
  854. package/node_modules/hono/dist/types/jsx/dom/jsx-runtime.d.ts +3 -7
  855. package/node_modules/hono/dist/types/jsx/dom/render.d.ts +32 -51
  856. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +86 -85
  857. package/node_modules/hono/dist/types/jsx/dom/utils.d.ts +2 -0
  858. package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +16 -17
  859. package/node_modules/hono/dist/types/jsx/index.d.ts +70 -73
  860. package/node_modules/hono/dist/types/jsx/intrinsic-element/common.d.ts +3 -1
  861. package/node_modules/hono/dist/types/jsx/intrinsic-element/components.d.ts +7 -4
  862. package/node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts +708 -708
  863. package/node_modules/hono/dist/types/jsx/jsx-dev-runtime.d.ts +4 -7
  864. package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +7 -10
  865. package/node_modules/hono/dist/types/jsx/streaming.d.ts +9 -10
  866. package/node_modules/hono/dist/types/jsx/types.d.ts +11 -13
  867. package/node_modules/hono/dist/types/jsx/utils.d.ts +2 -0
  868. package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +17 -20
  869. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +46 -49
  870. package/node_modules/hono/dist/types/middleware/body-limit/index.d.ts +6 -9
  871. package/node_modules/hono/dist/types/middleware/cache/index.d.ts +13 -15
  872. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +4 -7
  873. package/node_modules/hono/dist/types/middleware/compress/index.d.ts +8 -10
  874. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +4 -6
  875. package/node_modules/hono/dist/types/middleware/cors/index.d.ts +10 -13
  876. package/node_modules/hono/dist/types/middleware/csrf/index.d.ts +6 -9
  877. package/node_modules/hono/dist/types/middleware/etag/digest.d.ts +2 -0
  878. package/node_modules/hono/dist/types/middleware/etag/index.d.ts +6 -9
  879. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +11 -13
  880. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +11 -12
  881. package/node_modules/hono/dist/types/middleware/jwk/index.d.ts +2 -1
  882. package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +20 -23
  883. package/node_modules/hono/dist/types/middleware/jwt/index.d.ts +6 -6
  884. package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +28 -30
  885. package/node_modules/hono/dist/types/middleware/language/index.d.ts +5 -5
  886. package/node_modules/hono/dist/types/middleware/language/language.d.ts +42 -44
  887. package/node_modules/hono/dist/types/middleware/logger/index.d.ts +3 -6
  888. package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +7 -10
  889. package/node_modules/hono/dist/types/middleware/method-override/index.d.ts +14 -17
  890. package/node_modules/hono/dist/types/middleware/powered-by/index.d.ts +8 -11
  891. package/node_modules/hono/dist/types/middleware/pretty-json/index.d.ts +18 -21
  892. package/node_modules/hono/dist/types/middleware/request-id/index.d.ts +5 -5
  893. package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +9 -11
  894. package/node_modules/hono/dist/types/middleware/secure-headers/index.d.ts +5 -6
  895. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +2 -1
  896. package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +55 -58
  897. package/node_modules/hono/dist/types/middleware/serve-static/index.d.ts +22 -24
  898. package/node_modules/hono/dist/types/middleware/serve-static/path.d.ts +2 -0
  899. package/node_modules/hono/dist/types/middleware/timeout/index.d.ts +5 -7
  900. package/node_modules/hono/dist/types/middleware/timing/index.d.ts +5 -5
  901. package/node_modules/hono/dist/types/middleware/timing/timing.d.ts +17 -21
  902. package/node_modules/hono/dist/types/middleware/trailing-slash/index.d.ts +35 -38
  903. package/node_modules/hono/dist/types/preset/quick.d.ts +6 -9
  904. package/node_modules/hono/dist/types/preset/tiny.d.ts +6 -9
  905. package/node_modules/hono/dist/types/request/constants.d.ts +2 -0
  906. package/node_modules/hono/dist/types/request.d.ts +288 -287
  907. package/node_modules/hono/dist/types/router/linear-router/index.d.ts +2 -5
  908. package/node_modules/hono/dist/types/router/linear-router/router.d.ts +7 -5
  909. package/node_modules/hono/dist/types/router/pattern-router/index.d.ts +2 -5
  910. package/node_modules/hono/dist/types/router/pattern-router/router.d.ts +7 -5
  911. package/node_modules/hono/dist/types/router/reg-exp-router/index.d.ts +3 -6
  912. package/node_modules/hono/dist/types/router/reg-exp-router/matcher.d.ts +3 -1
  913. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +6 -4
  914. package/node_modules/hono/dist/types/router/reg-exp-router/prepared-router.d.ts +11 -11
  915. package/node_modules/hono/dist/types/router/reg-exp-router/router.d.ts +10 -9
  916. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +7 -5
  917. package/node_modules/hono/dist/types/router/smart-router/index.d.ts +2 -5
  918. package/node_modules/hono/dist/types/router/smart-router/router.d.ts +11 -9
  919. package/node_modules/hono/dist/types/router/trie-router/index.d.ts +2 -5
  920. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +6 -4
  921. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +7 -5
  922. package/node_modules/hono/dist/types/router/utils.d.ts +2 -0
  923. package/node_modules/hono/dist/types/router.d.ts +23 -22
  924. package/node_modules/hono/dist/types/types.d.ts +146 -506
  925. package/node_modules/hono/dist/types/utils/accept.d.ts +5 -3
  926. package/node_modules/hono/dist/types/utils/basic-auth.d.ts +4 -2
  927. package/node_modules/hono/dist/types/utils/body.d.ts +46 -51
  928. package/node_modules/hono/dist/types/utils/buffer.d.ts +7 -6
  929. package/node_modules/hono/dist/types/utils/color.d.ts +2 -0
  930. package/node_modules/hono/dist/types/utils/compress.d.ts +2 -0
  931. package/node_modules/hono/dist/types/utils/concurrent.d.ts +6 -4
  932. package/node_modules/hono/dist/types/utils/constants.d.ts +2 -0
  933. package/node_modules/hono/dist/types/utils/cookie.d.ts +20 -19
  934. package/node_modules/hono/dist/types/utils/crypto.d.ts +5 -8
  935. package/node_modules/hono/dist/types/utils/encode.d.ts +2 -0
  936. package/node_modules/hono/dist/types/utils/filepath.d.ts +5 -4
  937. package/node_modules/hono/dist/types/utils/handler.d.ts +2 -0
  938. package/node_modules/hono/dist/types/utils/headers.d.ts +2 -0
  939. package/node_modules/hono/dist/types/utils/html.d.ts +11 -10
  940. package/node_modules/hono/dist/types/utils/http-status.d.ts +2 -0
  941. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +4 -6
  942. package/node_modules/hono/dist/types/utils/jwt/index.d.ts +18 -12
  943. package/node_modules/hono/dist/types/utils/jwt/jwa.d.ts +15 -13
  944. package/node_modules/hono/dist/types/utils/jwt/jws.d.ts +4 -7
  945. package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +26 -29
  946. package/node_modules/hono/dist/types/utils/jwt/types.d.ts +48 -45
  947. package/node_modules/hono/dist/types/utils/jwt/utf8.d.ts +2 -0
  948. package/node_modules/hono/dist/types/utils/mime.d.ts +59 -57
  949. package/node_modules/hono/dist/types/utils/stream.d.ts +27 -25
  950. package/node_modules/hono/dist/types/utils/types.d.ts +14 -27
  951. package/node_modules/hono/dist/types/utils/url.d.ts +2 -1
  952. package/node_modules/hono/dist/types/validator/index.d.ts +3 -7
  953. package/node_modules/hono/dist/types/validator/utils.d.ts +6 -9
  954. package/node_modules/hono/dist/types/validator/validator.d.ts +11 -10
  955. package/node_modules/hono/dist/types.js +4 -6
  956. package/node_modules/hono/dist/utils/accept.js +185 -212
  957. package/node_modules/hono/dist/utils/basic-auth.js +18 -21
  958. package/node_modules/hono/dist/utils/body.js +87 -92
  959. package/node_modules/hono/dist/utils/buffer.js +44 -71
  960. package/node_modules/hono/dist/utils/color.js +33 -21
  961. package/node_modules/hono/dist/utils/compress.js +11 -5
  962. package/node_modules/hono/dist/utils/concurrent.js +29 -38
  963. package/node_modules/hono/dist/utils/constants.js +7 -5
  964. package/node_modules/hono/dist/utils/cookie.js +114 -163
  965. package/node_modules/hono/dist/utils/crypto.js +30 -40
  966. package/node_modules/hono/dist/utils/encode.js +30 -26
  967. package/node_modules/hono/dist/utils/filepath.js +23 -33
  968. package/node_modules/hono/dist/utils/handler.js +10 -11
  969. package/node_modules/hono/dist/utils/headers.js +1 -0
  970. package/node_modules/hono/dist/utils/html.js +97 -117
  971. package/node_modules/hono/dist/utils/http-status.js +1 -0
  972. package/node_modules/hono/dist/utils/ipaddr.js +227 -279
  973. package/node_modules/hono/dist/utils/jwt/index.js +12 -4
  974. package/node_modules/hono/dist/utils/jwt/jwa.js +24 -20
  975. package/node_modules/hono/dist/utils/jwt/jws.js +115 -174
  976. package/node_modules/hono/dist/utils/jwt/jwt.js +120 -198
  977. package/node_modules/hono/dist/utils/jwt/types.js +79 -95
  978. package/node_modules/hono/dist/utils/jwt/utf8.js +9 -7
  979. package/node_modules/hono/dist/utils/mime.js +74 -79
  980. package/node_modules/hono/dist/utils/stream.js +86 -88
  981. package/node_modules/hono/dist/utils/types.js +1 -0
  982. package/node_modules/hono/dist/utils/url.js +187 -215
  983. package/node_modules/hono/dist/validator/index.js +1 -4
  984. package/node_modules/hono/dist/validator/utils.js +1 -0
  985. package/node_modules/hono/dist/validator/validator.js +61 -83
  986. package/node_modules/hono/package.json +27 -27
  987. package/node_modules/imapflow/CHANGELOG.md +14 -0
  988. package/node_modules/imapflow/README.md +2 -0
  989. package/node_modules/imapflow/dist/cjs/commands/list.js +20 -8
  990. package/node_modules/imapflow/dist/cjs/errors.d.ts +2 -0
  991. package/node_modules/imapflow/dist/cjs/errors.js +4 -1
  992. package/node_modules/imapflow/dist/cjs/handler/imap-stream.js +7 -11
  993. package/node_modules/imapflow/dist/cjs/imap-flow.js +54 -27
  994. package/node_modules/imapflow/dist/cjs/logger.d.ts +21 -3
  995. package/node_modules/imapflow/dist/cjs/logger.js +35 -5
  996. package/node_modules/imapflow/dist/cjs/package-info.d.ts +1 -1
  997. package/node_modules/imapflow/dist/cjs/package-info.js +1 -1
  998. package/node_modules/imapflow/dist/cjs/search-compiler.d.ts +1 -1
  999. package/node_modules/imapflow/dist/cjs/search-compiler.js +48 -35
  1000. package/node_modules/imapflow/dist/cjs/tools.js +9 -2
  1001. package/node_modules/imapflow/dist/esm/commands/list.js +20 -8
  1002. package/node_modules/imapflow/dist/esm/errors.d.ts +2 -0
  1003. package/node_modules/imapflow/dist/esm/errors.js +4 -1
  1004. package/node_modules/imapflow/dist/esm/handler/imap-stream.js +7 -8
  1005. package/node_modules/imapflow/dist/esm/imap-flow.js +54 -27
  1006. package/node_modules/imapflow/dist/esm/logger.d.ts +21 -3
  1007. package/node_modules/imapflow/dist/esm/logger.js +33 -3
  1008. package/node_modules/imapflow/dist/esm/package-info.d.ts +1 -1
  1009. package/node_modules/imapflow/dist/esm/package-info.js +1 -1
  1010. package/node_modules/imapflow/dist/esm/search-compiler.d.ts +1 -1
  1011. package/node_modules/imapflow/dist/esm/search-compiler.js +49 -36
  1012. package/node_modules/imapflow/dist/esm/tools.js +9 -2
  1013. package/node_modules/imapflow/package.json +5 -5
  1014. package/node_modules/libbase64/.github/workflows/release.yaml +12 -10
  1015. package/node_modules/libbase64/.ncurc.js +7 -1
  1016. package/node_modules/libbase64/CHANGELOG.md +7 -0
  1017. package/node_modules/libbase64/lib/libbase64.js +27 -0
  1018. package/node_modules/libbase64/package.json +4 -4
  1019. package/node_modules/libmime/CHANGELOG.md +14 -0
  1020. package/node_modules/libmime/lib/libmime.js +41 -21
  1021. package/node_modules/libmime/package.json +3 -3
  1022. package/node_modules/libqp/.github/workflows/release.yaml +12 -10
  1023. package/node_modules/libqp/CHANGELOG.md +7 -0
  1024. package/node_modules/libqp/lib/libqp.js +6 -4
  1025. package/node_modules/libqp/package.json +2 -2
  1026. package/node_modules/libqp/test/libqp-test.js +71 -14
  1027. package/package.json +4 -2
  1028. package/packages/cli/dist/.tsbuildinfo +1 -1
  1029. package/packages/cli/dist/commands.d.ts.map +1 -1
  1030. package/packages/cli/dist/commands.js +24 -2
  1031. package/packages/cli/dist/commands.js.map +1 -1
  1032. package/packages/cli/dist/doctor-probes.d.ts.map +1 -1
  1033. package/packages/cli/dist/doctor-probes.js +1 -0
  1034. package/packages/cli/dist/doctor-probes.js.map +1 -1
  1035. package/packages/cli/dist/doctor.d.ts +2 -0
  1036. package/packages/cli/dist/doctor.d.ts.map +1 -1
  1037. package/packages/cli/dist/doctor.js +7 -0
  1038. package/packages/cli/dist/doctor.js.map +1 -1
  1039. package/packages/core/dist/.tsbuildinfo +1 -1
  1040. package/packages/core/dist/actions/permissions.d.ts +14 -0
  1041. package/packages/core/dist/actions/permissions.d.ts.map +1 -1
  1042. package/packages/core/dist/actions/permissions.js +15 -0
  1043. package/packages/core/dist/actions/permissions.js.map +1 -1
  1044. package/packages/core/dist/agents/catalog.d.ts +49 -3
  1045. package/packages/core/dist/agents/catalog.d.ts.map +1 -1
  1046. package/packages/core/dist/agents/catalog.js +104 -15
  1047. package/packages/core/dist/agents/catalog.js.map +1 -1
  1048. package/packages/core/dist/agents/delegates.d.ts +54 -0
  1049. package/packages/core/dist/agents/delegates.d.ts.map +1 -0
  1050. package/packages/core/dist/agents/delegates.js +51 -0
  1051. package/packages/core/dist/agents/delegates.js.map +1 -0
  1052. package/packages/core/dist/agents/index.d.ts +1 -0
  1053. package/packages/core/dist/agents/index.d.ts.map +1 -1
  1054. package/packages/core/dist/agents/index.js +1 -0
  1055. package/packages/core/dist/agents/index.js.map +1 -1
  1056. package/packages/core/dist/home.d.ts +30 -1
  1057. package/packages/core/dist/home.d.ts.map +1 -1
  1058. package/packages/core/dist/home.js +1 -1
  1059. package/packages/core/dist/home.js.map +1 -1
  1060. package/packages/core/dist/host/build.d.ts +26 -5
  1061. package/packages/core/dist/host/build.d.ts.map +1 -1
  1062. package/packages/core/dist/host/build.js +109 -3
  1063. package/packages/core/dist/host/build.js.map +1 -1
  1064. package/packages/core/dist/host/http.d.ts +32 -0
  1065. package/packages/core/dist/host/http.d.ts.map +1 -1
  1066. package/packages/core/dist/host/http.js +102 -2
  1067. package/packages/core/dist/host/http.js.map +1 -1
  1068. package/packages/core/dist/host/types.d.ts +75 -5
  1069. package/packages/core/dist/host/types.d.ts.map +1 -1
  1070. package/packages/core/dist/index.d.ts +2 -0
  1071. package/packages/core/dist/index.d.ts.map +1 -1
  1072. package/packages/core/dist/index.js +2 -0
  1073. package/packages/core/dist/index.js.map +1 -1
  1074. package/packages/core/dist/json-schema.d.ts +32 -0
  1075. package/packages/core/dist/json-schema.d.ts.map +1 -0
  1076. package/packages/core/dist/json-schema.js +147 -0
  1077. package/packages/core/dist/json-schema.js.map +1 -0
  1078. package/packages/core/dist/learning/announce.d.ts +1 -1
  1079. package/packages/core/dist/learning/sources.d.ts.map +1 -1
  1080. package/packages/core/dist/learning/sources.js +3 -0
  1081. package/packages/core/dist/learning/sources.js.map +1 -1
  1082. package/packages/core/dist/learning/types.d.ts +4 -3
  1083. package/packages/core/dist/learning/types.d.ts.map +1 -1
  1084. package/packages/core/dist/learning/types.js +1 -1
  1085. package/packages/core/dist/learning/types.js.map +1 -1
  1086. package/packages/core/dist/notifications/focus.d.ts +42 -0
  1087. package/packages/core/dist/notifications/focus.d.ts.map +1 -0
  1088. package/packages/core/dist/notifications/focus.js +150 -0
  1089. package/packages/core/dist/notifications/focus.js.map +1 -0
  1090. package/packages/core/dist/notifications/index.d.ts +2 -0
  1091. package/packages/core/dist/notifications/index.d.ts.map +1 -1
  1092. package/packages/core/dist/notifications/index.js +2 -0
  1093. package/packages/core/dist/notifications/index.js.map +1 -1
  1094. package/packages/core/dist/notifications/notify.d.ts +66 -7
  1095. package/packages/core/dist/notifications/notify.d.ts.map +1 -1
  1096. package/packages/core/dist/notifications/notify.js +166 -39
  1097. package/packages/core/dist/notifications/notify.js.map +1 -1
  1098. package/packages/core/dist/notifications/store.d.ts +6 -4
  1099. package/packages/core/dist/notifications/store.d.ts.map +1 -1
  1100. package/packages/core/dist/notifications/store.js +26 -23
  1101. package/packages/core/dist/notifications/store.js.map +1 -1
  1102. package/packages/core/dist/notifications/topic.d.ts +25 -0
  1103. package/packages/core/dist/notifications/topic.d.ts.map +1 -0
  1104. package/packages/core/dist/notifications/topic.js +116 -0
  1105. package/packages/core/dist/notifications/topic.js.map +1 -0
  1106. package/packages/core/dist/notifications/types.d.ts +50 -3
  1107. package/packages/core/dist/notifications/types.d.ts.map +1 -1
  1108. package/packages/core/dist/notifications/types.js +12 -0
  1109. package/packages/core/dist/notifications/types.js.map +1 -1
  1110. package/packages/core/dist/onboarding/language-tag.d.ts +12 -0
  1111. package/packages/core/dist/onboarding/language-tag.d.ts.map +1 -0
  1112. package/packages/core/dist/onboarding/language-tag.js +64 -0
  1113. package/packages/core/dist/onboarding/language-tag.js.map +1 -0
  1114. package/packages/core/dist/pages/__fixtures__/demo.d.ts +11 -0
  1115. package/packages/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  1116. package/packages/core/dist/pages/__fixtures__/demo.js +23 -1
  1117. package/packages/core/dist/pages/__fixtures__/demo.js.map +1 -1
  1118. package/packages/core/dist/pages.d.ts +204 -5
  1119. package/packages/core/dist/pages.d.ts.map +1 -1
  1120. package/packages/core/dist/pages.js +244 -12
  1121. package/packages/core/dist/pages.js.map +1 -1
  1122. package/packages/core/dist/plugin/author.d.ts +42 -0
  1123. package/packages/core/dist/plugin/author.d.ts.map +1 -0
  1124. package/packages/core/dist/plugin/author.js +77 -0
  1125. package/packages/core/dist/plugin/author.js.map +1 -0
  1126. package/packages/core/dist/plugin/index.d.ts +11 -6
  1127. package/packages/core/dist/plugin/index.d.ts.map +1 -1
  1128. package/packages/core/dist/plugin/index.js +3 -0
  1129. package/packages/core/dist/plugin/index.js.map +1 -1
  1130. package/packages/core/dist/plugin/version.d.ts +1 -1
  1131. package/packages/core/dist/plugin/version.d.ts.map +1 -1
  1132. package/packages/core/dist/plugin/version.js +1 -1
  1133. package/packages/core/dist/plugin/version.js.map +1 -1
  1134. package/packages/core/dist/plugins/record.d.ts +8 -0
  1135. package/packages/core/dist/plugins/record.d.ts.map +1 -1
  1136. package/packages/core/dist/plugins/record.js +17 -0
  1137. package/packages/core/dist/plugins/record.js.map +1 -1
  1138. package/packages/core/dist/plugins/types.d.ts +7 -0
  1139. package/packages/core/dist/plugins/types.d.ts.map +1 -1
  1140. package/packages/core/dist/plugins/types.js.map +1 -1
  1141. package/packages/core/dist/provider-accounts.d.ts +31 -0
  1142. package/packages/core/dist/provider-accounts.d.ts.map +1 -1
  1143. package/packages/core/dist/registry.d.ts +39 -1
  1144. package/packages/core/dist/registry.d.ts.map +1 -1
  1145. package/packages/core/dist/registry.js +202 -36
  1146. package/packages/core/dist/registry.js.map +1 -1
  1147. package/packages/core/dist/scheduler/materialize.js +1 -1
  1148. package/packages/core/dist/scheduler/missions.d.ts +10 -0
  1149. package/packages/core/dist/scheduler/missions.d.ts.map +1 -1
  1150. package/packages/core/dist/scheduler/missions.js +29 -1
  1151. package/packages/core/dist/scheduler/missions.js.map +1 -1
  1152. package/packages/core/dist/scheduler/types.d.ts +7 -0
  1153. package/packages/core/dist/scheduler/types.d.ts.map +1 -1
  1154. package/packages/core/dist/scheduler/types.js +1 -0
  1155. package/packages/core/dist/scheduler/types.js.map +1 -1
  1156. package/packages/core/dist/secrets/scrub.d.ts +2 -0
  1157. package/packages/core/dist/secrets/scrub.d.ts.map +1 -1
  1158. package/packages/core/dist/secrets/scrub.js +29 -0
  1159. package/packages/core/dist/secrets/scrub.js.map +1 -1
  1160. package/packages/core/dist/tools.d.ts +44 -1
  1161. package/packages/core/dist/tools.d.ts.map +1 -1
  1162. package/packages/core/dist/tools.js.map +1 -1
  1163. package/packages/core/dist/views.d.ts +190 -15
  1164. package/packages/core/dist/views.d.ts.map +1 -1
  1165. package/packages/core/dist/views.js +56 -1
  1166. package/packages/core/dist/views.js.map +1 -1
  1167. package/packages/core/migrations/050_notification_topic.sql +8 -0
  1168. package/packages/core/migrations/051_notification_focus.sql +20 -0
  1169. package/packages/core/migrations/052_mission_paused_reason.sql +6 -0
  1170. package/packages/core/package.json +2 -0
  1171. package/packages/gateway/assets/mascot/core-idle.tgs +0 -0
  1172. package/packages/gateway/assets/mascot/core-working.tgs +0 -0
  1173. package/packages/gateway/dist/.tsbuildinfo +1 -1
  1174. package/packages/gateway/dist/agents/canvas.d.ts +2 -2
  1175. package/packages/gateway/dist/agents/canvas.d.ts.map +1 -1
  1176. package/packages/gateway/dist/agents/canvas.js.map +1 -1
  1177. package/packages/gateway/dist/agents/catalog.d.ts +6 -0
  1178. package/packages/gateway/dist/agents/catalog.d.ts.map +1 -1
  1179. package/packages/gateway/dist/agents/catalog.js +31 -6
  1180. package/packages/gateway/dist/agents/catalog.js.map +1 -1
  1181. package/packages/gateway/dist/agents/delegation.d.ts +20 -3
  1182. package/packages/gateway/dist/agents/delegation.d.ts.map +1 -1
  1183. package/packages/gateway/dist/agents/delegation.js +38 -12
  1184. package/packages/gateway/dist/agents/delegation.js.map +1 -1
  1185. package/packages/gateway/dist/agents/platform.d.ts +43 -13
  1186. package/packages/gateway/dist/agents/platform.d.ts.map +1 -1
  1187. package/packages/gateway/dist/agents/platform.js +97 -3
  1188. package/packages/gateway/dist/agents/platform.js.map +1 -1
  1189. package/packages/gateway/dist/agents/starter-team.d.ts +59 -0
  1190. package/packages/gateway/dist/agents/starter-team.d.ts.map +1 -0
  1191. package/packages/gateway/dist/agents/starter-team.js +156 -0
  1192. package/packages/gateway/dist/agents/starter-team.js.map +1 -0
  1193. package/packages/gateway/dist/anthropic-accounts.d.ts.map +1 -1
  1194. package/packages/gateway/dist/anthropic-accounts.js +9 -20
  1195. package/packages/gateway/dist/anthropic-accounts.js.map +1 -1
  1196. package/packages/gateway/dist/bootstrap.d.ts +3 -0
  1197. package/packages/gateway/dist/bootstrap.d.ts.map +1 -1
  1198. package/packages/gateway/dist/bootstrap.js +58 -2
  1199. package/packages/gateway/dist/bootstrap.js.map +1 -1
  1200. package/packages/gateway/dist/codex-accounts.d.ts +7 -1
  1201. package/packages/gateway/dist/codex-accounts.d.ts.map +1 -1
  1202. package/packages/gateway/dist/codex-accounts.js +25 -26
  1203. package/packages/gateway/dist/codex-accounts.js.map +1 -1
  1204. package/packages/gateway/dist/mcp/requests.d.ts +8 -1
  1205. package/packages/gateway/dist/mcp/requests.d.ts.map +1 -1
  1206. package/packages/gateway/dist/mcp/requests.js +8 -1
  1207. package/packages/gateway/dist/mcp/requests.js.map +1 -1
  1208. package/packages/gateway/dist/missions/goals-page.d.ts.map +1 -1
  1209. package/packages/gateway/dist/missions/goals-page.js +57 -0
  1210. package/packages/gateway/dist/missions/goals-page.js.map +1 -1
  1211. package/packages/gateway/dist/missions-cli.d.ts.map +1 -1
  1212. package/packages/gateway/dist/missions-cli.js +6 -3
  1213. package/packages/gateway/dist/missions-cli.js.map +1 -1
  1214. package/packages/gateway/dist/plugins/approve.d.ts.map +1 -1
  1215. package/packages/gateway/dist/plugins/approve.js +54 -11
  1216. package/packages/gateway/dist/plugins/approve.js.map +1 -1
  1217. package/packages/gateway/dist/plugins/index.d.ts +1 -0
  1218. package/packages/gateway/dist/plugins/index.d.ts.map +1 -1
  1219. package/packages/gateway/dist/plugins/index.js +1 -0
  1220. package/packages/gateway/dist/plugins/index.js.map +1 -1
  1221. package/packages/gateway/dist/plugins/load.d.ts +5 -0
  1222. package/packages/gateway/dist/plugins/load.d.ts.map +1 -1
  1223. package/packages/gateway/dist/plugins/load.js +14 -1
  1224. package/packages/gateway/dist/plugins/load.js.map +1 -1
  1225. package/packages/gateway/dist/plugins/npm.d.ts +5 -1
  1226. package/packages/gateway/dist/plugins/npm.d.ts.map +1 -1
  1227. package/packages/gateway/dist/plugins/npm.js +6 -0
  1228. package/packages/gateway/dist/plugins/npm.js.map +1 -1
  1229. package/packages/gateway/dist/plugins/provenance.d.ts.map +1 -1
  1230. package/packages/gateway/dist/plugins/provenance.js +10 -3
  1231. package/packages/gateway/dist/plugins/provenance.js.map +1 -1
  1232. package/packages/gateway/dist/plugins/scaffold.d.ts +23 -4
  1233. package/packages/gateway/dist/plugins/scaffold.d.ts.map +1 -1
  1234. package/packages/gateway/dist/plugins/scaffold.js +130 -21
  1235. package/packages/gateway/dist/plugins/scaffold.js.map +1 -1
  1236. package/packages/gateway/dist/plugins/stage.d.ts +41 -2
  1237. package/packages/gateway/dist/plugins/stage.d.ts.map +1 -1
  1238. package/packages/gateway/dist/plugins/stage.js +137 -9
  1239. package/packages/gateway/dist/plugins/stage.js.map +1 -1
  1240. package/packages/gateway/dist/plugins/toggle.d.ts +21 -0
  1241. package/packages/gateway/dist/plugins/toggle.d.ts.map +1 -0
  1242. package/packages/gateway/dist/plugins/toggle.js +86 -0
  1243. package/packages/gateway/dist/plugins/toggle.js.map +1 -0
  1244. package/packages/gateway/dist/plugins-cli.d.ts +23 -3
  1245. package/packages/gateway/dist/plugins-cli.d.ts.map +1 -1
  1246. package/packages/gateway/dist/plugins-cli.js +102 -10
  1247. package/packages/gateway/dist/plugins-cli.js.map +1 -1
  1248. package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
  1249. package/packages/gateway/dist/provider-accounts.js +31 -3
  1250. package/packages/gateway/dist/provider-accounts.js.map +1 -1
  1251. package/packages/gateway/dist/provider-diagnostics.d.ts +14 -2
  1252. package/packages/gateway/dist/provider-diagnostics.d.ts.map +1 -1
  1253. package/packages/gateway/dist/provider-diagnostics.js +25 -9
  1254. package/packages/gateway/dist/provider-diagnostics.js.map +1 -1
  1255. package/packages/gateway/dist/serve.js +3 -3
  1256. package/packages/gateway/dist/serve.js.map +1 -1
  1257. package/packages/gateway/dist/speech-cli.d.ts +13 -0
  1258. package/packages/gateway/dist/speech-cli.d.ts.map +1 -1
  1259. package/packages/gateway/dist/speech-cli.js +40 -1
  1260. package/packages/gateway/dist/speech-cli.js.map +1 -1
  1261. package/packages/gateway/dist/telegram/api.d.ts +49 -0
  1262. package/packages/gateway/dist/telegram/api.d.ts.map +1 -1
  1263. package/packages/gateway/dist/telegram/api.js +99 -0
  1264. package/packages/gateway/dist/telegram/api.js.map +1 -1
  1265. package/packages/gateway/dist/telegram/focus.d.ts +27 -0
  1266. package/packages/gateway/dist/telegram/focus.d.ts.map +1 -0
  1267. package/packages/gateway/dist/telegram/focus.js +72 -0
  1268. package/packages/gateway/dist/telegram/focus.js.map +1 -0
  1269. package/packages/gateway/dist/telegram/main.d.ts.map +1 -1
  1270. package/packages/gateway/dist/telegram/main.js +18 -0
  1271. package/packages/gateway/dist/telegram/main.js.map +1 -1
  1272. package/packages/gateway/dist/telegram/outbound.d.ts +5 -0
  1273. package/packages/gateway/dist/telegram/outbound.d.ts.map +1 -1
  1274. package/packages/gateway/dist/telegram/outbound.js +10 -0
  1275. package/packages/gateway/dist/telegram/outbound.js.map +1 -1
  1276. package/packages/gateway/dist/telegram/stickers.d.ts +30 -0
  1277. package/packages/gateway/dist/telegram/stickers.d.ts.map +1 -0
  1278. package/packages/gateway/dist/telegram/stickers.js +146 -0
  1279. package/packages/gateway/dist/telegram/stickers.js.map +1 -0
  1280. package/packages/gateway/dist/telegram/surface.d.ts +8 -0
  1281. package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
  1282. package/packages/gateway/dist/telegram/surface.js +60 -4
  1283. package/packages/gateway/dist/telegram/surface.js.map +1 -1
  1284. package/packages/gateway/dist/tips/engine.d.ts +75 -0
  1285. package/packages/gateway/dist/tips/engine.d.ts.map +1 -0
  1286. package/packages/gateway/dist/tips/engine.js +135 -0
  1287. package/packages/gateway/dist/tips/engine.js.map +1 -0
  1288. package/packages/gateway/dist/tips/facts.d.ts +69 -0
  1289. package/packages/gateway/dist/tips/facts.d.ts.map +1 -0
  1290. package/packages/gateway/dist/tips/facts.js +104 -0
  1291. package/packages/gateway/dist/tips/facts.js.map +1 -0
  1292. package/packages/gateway/dist/tips/route.d.ts +25 -0
  1293. package/packages/gateway/dist/tips/route.d.ts.map +1 -0
  1294. package/packages/gateway/dist/tips/route.js +96 -0
  1295. package/packages/gateway/dist/tips/route.js.map +1 -0
  1296. package/packages/gateway/dist/tips/rules.d.ts +33 -0
  1297. package/packages/gateway/dist/tips/rules.d.ts.map +1 -0
  1298. package/packages/gateway/dist/tips/rules.js +54 -0
  1299. package/packages/gateway/dist/tips/rules.js.map +1 -0
  1300. package/packages/gateway/dist/web/agent-offers.d.ts +30 -0
  1301. package/packages/gateway/dist/web/agent-offers.d.ts.map +1 -1
  1302. package/packages/gateway/dist/web/agent-offers.js +64 -1
  1303. package/packages/gateway/dist/web/agent-offers.js.map +1 -1
  1304. package/packages/gateway/dist/web/connections.d.ts +83 -0
  1305. package/packages/gateway/dist/web/connections.d.ts.map +1 -0
  1306. package/packages/gateway/dist/web/connections.js +270 -0
  1307. package/packages/gateway/dist/web/connections.js.map +1 -0
  1308. package/packages/gateway/dist/web/notifications.d.ts +8 -1
  1309. package/packages/gateway/dist/web/notifications.d.ts.map +1 -1
  1310. package/packages/gateway/dist/web/notifications.js +23 -1
  1311. package/packages/gateway/dist/web/notifications.js.map +1 -1
  1312. package/packages/gateway/dist/web/onboarding.d.ts +1 -1
  1313. package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
  1314. package/packages/gateway/dist/web/onboarding.js +5 -4
  1315. package/packages/gateway/dist/web/onboarding.js.map +1 -1
  1316. package/packages/gateway/dist/web/plugins.d.ts +18 -1
  1317. package/packages/gateway/dist/web/plugins.d.ts.map +1 -1
  1318. package/packages/gateway/dist/web/plugins.js +54 -6
  1319. package/packages/gateway/dist/web/plugins.js.map +1 -1
  1320. package/packages/gateway/dist/web/profile.d.ts +2 -0
  1321. package/packages/gateway/dist/web/profile.d.ts.map +1 -1
  1322. package/packages/gateway/dist/web/profile.js +5 -3
  1323. package/packages/gateway/dist/web/profile.js.map +1 -1
  1324. package/packages/gateway/dist/web/rail.d.ts +33 -0
  1325. package/packages/gateway/dist/web/rail.d.ts.map +1 -0
  1326. package/packages/gateway/dist/web/rail.js +45 -0
  1327. package/packages/gateway/dist/web/rail.js.map +1 -0
  1328. package/packages/gateway/dist/web/read.d.ts +52 -0
  1329. package/packages/gateway/dist/web/read.d.ts.map +1 -1
  1330. package/packages/gateway/dist/web/read.js +88 -5
  1331. package/packages/gateway/dist/web/read.js.map +1 -1
  1332. package/packages/gateway/dist/web/server.d.ts +6 -0
  1333. package/packages/gateway/dist/web/server.d.ts.map +1 -1
  1334. package/packages/gateway/dist/web/server.js +107 -8
  1335. package/packages/gateway/dist/web/server.js.map +1 -1
  1336. package/packages/gateway/dist/web/static.d.ts.map +1 -1
  1337. package/packages/gateway/dist/web/static.js +1 -0
  1338. package/packages/gateway/dist/web/static.js.map +1 -1
  1339. package/packages/gateway/dist/web/version.d.ts +2 -0
  1340. package/packages/gateway/dist/web/version.d.ts.map +1 -1
  1341. package/packages/gateway/dist/web/version.js +27 -0
  1342. package/packages/gateway/dist/web/version.js.map +1 -1
  1343. package/packages/gateway/dist/web/write.d.ts +5 -0
  1344. package/packages/gateway/dist/web/write.d.ts.map +1 -1
  1345. package/packages/gateway/dist/web/write.js +20 -1
  1346. package/packages/gateway/dist/web/write.js.map +1 -1
  1347. package/packages/gateway/package.json +4 -1
  1348. package/packages/gateway/src/agents/starter/keeper/agent.md +31 -0
  1349. package/packages/gateway/src/agents/starter/keeper/skills/keeping-a-history.md +22 -0
  1350. package/packages/gateway/src/agents/starter/planner/agent.md +30 -0
  1351. package/packages/gateway/src/agents/starter/planner/skills/holding-a-follow-up.md +17 -0
  1352. package/packages/gateway/src/agents/starter/planner/skills/writing-the-morning-brief.md +32 -0
  1353. package/packages/gateway/src/agents/starter/scout/agent.md +33 -0
  1354. package/packages/gateway/src/agents/starter/scout/skills/answering-with-sources.md +23 -0
  1355. package/packages/gateway/src/agents/starter/scout/skills/the-web-is-evidence.md +25 -0
  1356. package/packages/install/dist/.tsbuildinfo +1 -1
  1357. package/packages/runtime/dist/.tsbuildinfo +1 -1
  1358. package/packages/runtime/dist/anthropic-oauth.d.ts.map +1 -1
  1359. package/packages/runtime/dist/anthropic-oauth.js +38 -73
  1360. package/packages/runtime/dist/anthropic-oauth.js.map +1 -1
  1361. package/packages/runtime/dist/codex-direct.d.ts +39 -0
  1362. package/packages/runtime/dist/codex-direct.d.ts.map +1 -1
  1363. package/packages/runtime/dist/codex-direct.js +122 -0
  1364. package/packages/runtime/dist/codex-direct.js.map +1 -1
  1365. package/packages/runtime/dist/codex-oauth.d.ts +0 -12
  1366. package/packages/runtime/dist/codex-oauth.d.ts.map +1 -1
  1367. package/packages/runtime/dist/codex-oauth.js +32 -45
  1368. package/packages/runtime/dist/codex-oauth.js.map +1 -1
  1369. package/packages/runtime/dist/delegate.d.ts.map +1 -1
  1370. package/packages/runtime/dist/delegate.js +4 -2
  1371. package/packages/runtime/dist/delegate.js.map +1 -1
  1372. package/packages/runtime/dist/index.d.ts +2 -0
  1373. package/packages/runtime/dist/index.d.ts.map +1 -1
  1374. package/packages/runtime/dist/index.js +2 -0
  1375. package/packages/runtime/dist/index.js.map +1 -1
  1376. package/packages/runtime/dist/oauth-port.d.ts +68 -0
  1377. package/packages/runtime/dist/oauth-port.d.ts.map +1 -0
  1378. package/packages/runtime/dist/oauth-port.js +51 -0
  1379. package/packages/runtime/dist/oauth-port.js.map +1 -0
  1380. package/packages/runtime/dist/oauth.d.ts +255 -0
  1381. package/packages/runtime/dist/oauth.d.ts.map +1 -0
  1382. package/packages/runtime/dist/oauth.js +535 -0
  1383. package/packages/runtime/dist/oauth.js.map +1 -0
  1384. package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
  1385. package/packages/tools/browser/dist/.tsbuildinfo +1 -1
  1386. package/packages/tools/email/dist/.tsbuildinfo +1 -1
  1387. package/packages/tools/email/dist/types.d.ts +2 -2
  1388. package/packages/tools/email/dist/types.d.ts.map +1 -1
  1389. package/packages/tools/host/dist/.tsbuildinfo +1 -1
  1390. package/packages/tools/mcp/dist/.tsbuildinfo +1 -0
  1391. package/packages/tools/mcp/dist/catalog.d.ts +26 -0
  1392. package/packages/tools/mcp/dist/catalog.d.ts.map +1 -0
  1393. package/packages/tools/mcp/dist/catalog.js +17 -0
  1394. package/packages/tools/mcp/dist/catalog.js.map +1 -0
  1395. package/packages/tools/mcp/dist/fetch.d.ts +44 -0
  1396. package/packages/tools/mcp/dist/fetch.d.ts.map +1 -0
  1397. package/packages/tools/mcp/dist/fetch.js +88 -0
  1398. package/packages/tools/mcp/dist/fetch.js.map +1 -0
  1399. package/packages/tools/mcp/dist/index.d.ts +27 -0
  1400. package/packages/tools/mcp/dist/index.d.ts.map +1 -0
  1401. package/packages/tools/mcp/dist/index.js +74 -0
  1402. package/packages/tools/mcp/dist/index.js.map +1 -0
  1403. package/packages/tools/mcp/dist/output.d.ts +38 -0
  1404. package/packages/tools/mcp/dist/output.d.ts.map +1 -0
  1405. package/packages/tools/mcp/dist/output.js +90 -0
  1406. package/packages/tools/mcp/dist/output.js.map +1 -0
  1407. package/packages/tools/mcp/dist/ports.d.ts +105 -0
  1408. package/packages/tools/mcp/dist/ports.d.ts.map +1 -0
  1409. package/packages/tools/mcp/dist/ports.js +9 -0
  1410. package/packages/tools/mcp/dist/ports.js.map +1 -0
  1411. package/packages/tools/mcp/dist/service.d.ts +220 -0
  1412. package/packages/tools/mcp/dist/service.d.ts.map +1 -0
  1413. package/packages/tools/mcp/dist/service.js +742 -0
  1414. package/packages/tools/mcp/dist/service.js.map +1 -0
  1415. package/packages/tools/mcp/dist/session.d.ts +50 -0
  1416. package/packages/tools/mcp/dist/session.d.ts.map +1 -0
  1417. package/packages/tools/mcp/dist/session.js +108 -0
  1418. package/packages/tools/mcp/dist/session.js.map +1 -0
  1419. package/packages/tools/mcp/dist/store.d.ts +70 -0
  1420. package/packages/tools/mcp/dist/store.d.ts.map +1 -0
  1421. package/packages/tools/mcp/dist/store.js +78 -0
  1422. package/packages/tools/mcp/dist/store.js.map +1 -0
  1423. package/packages/tools/mcp/dist/testing/fake.d.ts +51 -0
  1424. package/packages/tools/mcp/dist/testing/fake.d.ts.map +1 -0
  1425. package/packages/tools/mcp/dist/testing/fake.js +147 -0
  1426. package/packages/tools/mcp/dist/testing/fake.js.map +1 -0
  1427. package/packages/tools/mcp/dist/tiers.d.ts +51 -0
  1428. package/packages/tools/mcp/dist/tiers.d.ts.map +1 -0
  1429. package/packages/tools/mcp/dist/tiers.js +106 -0
  1430. package/packages/tools/mcp/dist/tiers.js.map +1 -0
  1431. package/packages/tools/mcp/dist/tokens.d.ts +35 -0
  1432. package/packages/tools/mcp/dist/tokens.d.ts.map +1 -0
  1433. package/packages/tools/mcp/dist/tokens.js +75 -0
  1434. package/packages/tools/mcp/dist/tokens.js.map +1 -0
  1435. package/packages/tools/mcp/migrations/001_connections.sql +49 -0
  1436. package/packages/tools/mcp/migrations/002_review_again.sql +15 -0
  1437. package/packages/tools/mcp/package.json +34 -0
  1438. package/packages/tools/memory/dist/.tsbuildinfo +1 -1
  1439. package/packages/tools/web/dist/.tsbuildinfo +1 -1
  1440. package/packages/web/dist/apple-touch-icon.png +0 -0
  1441. package/packages/web/dist/assets/index-4hpqlMjL.css +1 -0
  1442. package/packages/web/dist/assets/index-B8crjABB.js +125 -0
  1443. package/packages/web/dist/assets/lottie_light-e1djomjW.js +9 -0
  1444. package/packages/web/dist/build.json +1 -0
  1445. package/packages/web/dist/icon-192.png +0 -0
  1446. package/packages/web/dist/icon-512.png +0 -0
  1447. package/packages/web/dist/icon-maskable-512.png +0 -0
  1448. package/packages/web/dist/index.html +6 -3
  1449. package/packages/web/dist/manifest.webmanifest +16 -0
  1450. package/packages/web/dist/mascot/README.md +5 -0
  1451. package/packages/web/dist/mascot/anim/core-idle.json +1 -0
  1452. package/packages/web/dist/mascot/anim/core-working.json +1 -0
  1453. package/packages/web/dist/precache.json +28 -0
  1454. package/packages/web/dist/sw.js +106 -0
  1455. package/packages/web/dist/assets/index-D5cRFcgm.css +0 -1
  1456. package/packages/web/dist/assets/index-GCFB1vBV.js +0 -125
@@ -0,0 +1,125 @@
1
+ var av=e=>{throw TypeError(e)};var lv=(e,t,s)=>t.has(e)||av("Cannot "+s);var qt=(e,t,s)=>(lv(e,t,"read from private field"),s?s.call(e):t.get(e)),ov=(e,t,s)=>t.has(e)?av("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Fd=(e,t,s,r)=>(lv(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s);function FE(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 LW=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function UE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rw={exports:{}},Fu={},Iw={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 fo=Symbol.for("react.element"),BE=Symbol.for("react.portal"),zE=Symbol.for("react.fragment"),WE=Symbol.for("react.strict_mode"),HE=Symbol.for("react.profiler"),VE=Symbol.for("react.provider"),KE=Symbol.for("react.context"),GE=Symbol.for("react.forward_ref"),YE=Symbol.for("react.suspense"),qE=Symbol.for("react.memo"),QE=Symbol.for("react.lazy"),cv=Symbol.iterator;function JE(e){return e===null||typeof e!="object"?null:(e=cv&&e[cv]||e["@@iterator"],typeof e=="function"?e:null)}var Pw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Mw=Object.assign,$w={};function $a(e,t,s){this.props=e,this.context=t,this.refs=$w,this.updater=s||Pw}$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 Dw(){}Dw.prototype=$a.prototype;function fp(e,t,s){this.props=e,this.context=t,this.refs=$w,this.updater=s||Pw}var mp=fp.prototype=new Dw;mp.constructor=fp;Mw(mp,$a.prototype);mp.isPureReactComponent=!0;var uv=Array.isArray,_w=Object.prototype.hasOwnProperty,pp={current:null},Ow={key:!0,ref:!0,__self:!0,__source:!0};function Lw(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)_w.call(t,r)&&!Ow.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:fo,type:e,key:a,ref:l,props:i,_owner:pp.current}}function XE(e,t){return{$$typeof:fo,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function gp(e){return typeof e=="object"&&e!==null&&e.$$typeof===fo}function ZE(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var dv=/\/+/g;function Ud(e,t){return typeof e=="object"&&e!==null&&e.key!=null?ZE(""+e.key):t.toString(36)}function Nc(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 fo:case BE:l=!0}}if(l)return l=e,i=i(l),e=r===""?"."+Ud(l,0):r,uv(i)?(s="",e!=null&&(s=e.replace(dv,"$&/")+"/"),Nc(i,t,s,"",function(u){return u})):i!=null&&(gp(i)&&(i=XE(i,s+(!i.key||l&&l.key===i.key?"":(""+i.key).replace(dv,"$&/")+"/")+e)),t.push(i)),1;if(l=0,r=r===""?".":r+":",uv(e))for(var o=0;o<e.length;o++){a=e[o];var c=r+Ud(a,o);l+=Nc(a,t,s,c,i)}else if(c=JE(e),typeof c=="function")for(e=c.call(e),o=0;!(a=e.next()).done;)a=a.value,c=r+Ud(a,o++),l+=Nc(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 Do(e,t,s){if(e==null)return e;var r=[],i=0;return Nc(e,r,"","",function(a){return t.call(s,a,i++)}),r}function eA(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 un={current:null},Cc={transition:null},tA={ReactCurrentDispatcher:un,ReactCurrentBatchConfig:Cc,ReactCurrentOwner:pp};function Fw(){throw Error("act(...) is not supported in production builds of React.")}Ue.Children={map:Do,forEach:function(e,t,s){Do(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return Do(e,function(){t++}),t},toArray:function(e){return Do(e,function(t){return t})||[]},only:function(e){if(!gp(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ue.Component=$a;Ue.Fragment=zE;Ue.Profiler=HE;Ue.PureComponent=fp;Ue.StrictMode=WE;Ue.Suspense=YE;Ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tA;Ue.act=Fw;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=Mw({},e.props),i=e.key,a=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(a=t.ref,l=pp.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(c in t)_w.call(t,c)&&!Ow.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:fo,type:e.type,key:i,ref:a,props:r,_owner:l}};Ue.createContext=function(e){return e={$$typeof:KE,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:VE,_context:e},e.Consumer=e};Ue.createElement=Lw;Ue.createFactory=function(e){var t=Lw.bind(null,e);return t.type=e,t};Ue.createRef=function(){return{current:null}};Ue.forwardRef=function(e){return{$$typeof:GE,render:e}};Ue.isValidElement=gp;Ue.lazy=function(e){return{$$typeof:QE,_payload:{_status:-1,_result:e},_init:eA}};Ue.memo=function(e,t){return{$$typeof:qE,type:e,compare:t===void 0?null:t}};Ue.startTransition=function(e){var t=Cc.transition;Cc.transition={};try{e()}finally{Cc.transition=t}};Ue.unstable_act=Fw;Ue.useCallback=function(e,t){return un.current.useCallback(e,t)};Ue.useContext=function(e){return un.current.useContext(e)};Ue.useDebugValue=function(){};Ue.useDeferredValue=function(e){return un.current.useDeferredValue(e)};Ue.useEffect=function(e,t){return un.current.useEffect(e,t)};Ue.useId=function(){return un.current.useId()};Ue.useImperativeHandle=function(e,t,s){return un.current.useImperativeHandle(e,t,s)};Ue.useInsertionEffect=function(e,t){return un.current.useInsertionEffect(e,t)};Ue.useLayoutEffect=function(e,t){return un.current.useLayoutEffect(e,t)};Ue.useMemo=function(e,t){return un.current.useMemo(e,t)};Ue.useReducer=function(e,t,s){return un.current.useReducer(e,t,s)};Ue.useRef=function(e){return un.current.useRef(e)};Ue.useState=function(e){return un.current.useState(e)};Ue.useSyncExternalStore=function(e,t,s){return un.current.useSyncExternalStore(e,t,s)};Ue.useTransition=function(){return un.current.useTransition()};Ue.version="18.3.1";Iw.exports=Ue;var h=Iw.exports;const nA=UE(h),Da=FE({__proto__:null,default:nA},[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,rA=Symbol.for("react.element"),iA=Symbol.for("react.fragment"),aA=Object.prototype.hasOwnProperty,lA=sA.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,oA={key:!0,ref:!0,__self:!0,__source:!0};function Uw(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)aA.call(t,r)&&!oA.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:rA,type:e,key:a,ref:l,props:i,_owner:lA.current}}Fu.Fragment=iA;Fu.jsx=Uw;Fu.jsxs=Uw;Rw.exports=Fu;var n=Rw.exports,Bw={exports:{}},_n={},zw={exports:{}},Ww={};/**
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(_,q){var B=_.length;_.push(q);e:for(;0<B;){var H=B-1>>>1,ue=_[H];if(0<i(ue,q))_[H]=q,_[B]=ue,B=H;else break e}}function s(_){return _.length===0?null:_[0]}function r(_){if(_.length===0)return null;var q=_[0],B=_.pop();if(B!==q){_[0]=B;e:for(var H=0,ue=_.length,re=ue>>>1;H<re;){var ie=2*(H+1)-1,Ne=_[ie],Z=ie+1,ce=_[Z];if(0>i(Ne,B))Z<ue&&0>i(ce,Ne)?(_[H]=ce,_[Z]=B,H=Z):(_[H]=Ne,_[ie]=B,H=ie);else if(Z<ue&&0>i(ce,B))_[H]=ce,_[Z]=B,H=Z;else break e}}return q}function i(_,q){var B=_.sortIndex-q.sortIndex;return B!==0?B:_.id-q.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,j=!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(_){for(var q=s(u);q!==null;){if(q.callback===null)r(u);else if(q.startTime<=_)r(u),q.sortIndex=q.expirationTime,t(c,q);else break;q=s(u)}}function v(_){if(w=!1,y(_),!j)if(s(c)!==null)j=!0,U(N);else{var q=s(u);q!==null&&K(v,q.startTime-_)}}function N(_,q){j=!1,w&&(w=!1,g(C),C=-1),p=!0;var B=m;try{for(y(q),d=s(c);d!==null&&(!(d.expirationTime>q)||_&&!P());){var H=d.callback;if(typeof H=="function"){d.callback=null,m=d.priorityLevel;var ue=H(d.expirationTime<=q);q=e.unstable_now(),typeof ue=="function"?d.callback=ue:d===s(c)&&r(c),y(q)}else r(c);d=s(c)}if(d!==null)var re=!0;else{var ie=s(u);ie!==null&&K(v,ie.startTime-q),re=!1}return re}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 L(){if(S!==null){var _=e.unstable_now();E=_;var q=!0;try{q=S(!0,_)}finally{q?$():(b=!1,S=null)}}else b=!1}var $;if(typeof x=="function")$=function(){x(L)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,M=T.port2;T.port1.onmessage=L,$=function(){M.postMessage(null)}}else $=function(){k(L,0)};function U(_){S=_,b||(b=!0,$())}function K(_,q){C=k(function(){_(e.unstable_now())},q)}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(_){_.callback=null},e.unstable_continueExecution=function(){j||p||(j=!0,U(N))},e.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return s(c)},e.unstable_next=function(_){switch(m){case 1:case 2:case 3:var q=3;break;default:q=m}var B=m;m=q;try{return _()}finally{m=B}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,q){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var B=m;m=_;try{return q()}finally{m=B}},e.unstable_scheduleCallback=function(_,q,B){var H=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?H+B:H):B=H,_){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=B+ue,_={id:f++,callback:q,priorityLevel:_,startTime:B,expirationTime:ue,sortIndex:-1},B>H?(_.sortIndex=B,t(u,_),s(c)===null&&_===s(u)&&(w?(g(C),C=-1):w=!0,K(v,B-H))):(_.sortIndex=ue,t(c,_),j||p||(j=!0,U(N))),_},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(_){var q=m;return function(){var B=m;m=q;try{return _.apply(this,arguments)}finally{m=B}}}})(Ww);zw.exports=Ww;var cA=zw.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 uA=h,$n=cA;function ee(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 Hw=new Set,Il={};function bi(e,t){xa(e,t),xa(e+"Capture",t)}function xa(e,t){for(Il[e]=t,e=0;e<t.length;e++)Hw.add(t[e])}var qs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rf=Object.prototype.hasOwnProperty,dA=/^[: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]*$/,hv={},fv={};function hA(e){return rf.call(fv,e)?!0:rf.call(hv,e)?!1:dA.test(e)?fv[e]=!0:(hv[e]=!0,!1)}function fA(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 mA(e,t,s,r){if(t===null||typeof t>"u"||fA(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 dn(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 Kt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Kt[e]=new dn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Kt[t]=new dn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Kt[e]=new dn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Kt[e]=new dn(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){Kt[e]=new dn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Kt[e]=new dn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Kt[e]=new dn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Kt[e]=new dn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Kt[e]=new dn(e,5,!1,e.toLowerCase(),null,!1,!1)});var xp=/[\-:]([a-z])/g;function vp(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(xp,vp);Kt[t]=new dn(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(xp,vp);Kt[t]=new dn(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(xp,vp);Kt[t]=new dn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Kt[e]=new dn(e,1,!1,e.toLowerCase(),null,!1,!1)});Kt.xlinkHref=new dn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Kt[e]=new dn(e,1,!1,e.toLowerCase(),null,!0,!0)});function jp(e,t,s,r){var i=Kt.hasOwnProperty(t)?Kt[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(mA(t,s,i,r)&&(s=null),r||i===null?hA(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 rr=uA.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_o=Symbol.for("react.element"),Ki=Symbol.for("react.portal"),Gi=Symbol.for("react.fragment"),yp=Symbol.for("react.strict_mode"),af=Symbol.for("react.profiler"),Vw=Symbol.for("react.provider"),Kw=Symbol.for("react.context"),wp=Symbol.for("react.forward_ref"),lf=Symbol.for("react.suspense"),of=Symbol.for("react.suspense_list"),bp=Symbol.for("react.memo"),ur=Symbol.for("react.lazy"),Gw=Symbol.for("react.offscreen"),mv=Symbol.iterator;function Xa(e){return e===null||typeof e!="object"?null:(e=mv&&e[mv]||e["@@iterator"],typeof e=="function"?e:null)}var ft=Object.assign,Bd;function dl(e){if(Bd===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);Bd=t&&t[1]||""}return`
34
+ `+Bd+e}var zd=!1;function Wd(e,t){if(!e||zd)return"";zd=!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{zd=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?dl(e):""}function pA(e){switch(e.tag){case 5:return dl(e.type);case 16:return dl("Lazy");case 13:return dl("Suspense");case 19:return dl("SuspenseList");case 0:case 2:case 15:return e=Wd(e.type,!1),e;case 11:return e=Wd(e.type.render,!1),e;case 1:return e=Wd(e.type,!0),e;default:return""}}function cf(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 Gi:return"Fragment";case Ki:return"Portal";case af:return"Profiler";case yp:return"StrictMode";case lf:return"Suspense";case of:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Kw:return(e.displayName||"Context")+".Consumer";case Vw:return(e._context.displayName||"Context")+".Provider";case wp:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case bp:return t=e.displayName||null,t!==null?t:cf(e.type)||"Memo";case ur:t=e._payload,e=e._init;try{return cf(e(t))}catch{}}return null}function gA(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 cf(t);case 8:return t===yp?"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 Rr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Yw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function xA(e){var t=Yw(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 Oo(e){e._valueTracker||(e._valueTracker=xA(e))}function qw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),r="";return e&&(r=Yw(e)?e.checked?"true":"false":e.value),e=r,e!==s?(t.setValue(e),!0):!1}function qc(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 uf(e,t){var s=t.checked;return ft({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function pv(e,t){var s=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;s=Rr(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 Qw(e,t){t=t.checked,t!=null&&jp(e,"checked",t,!1)}function df(e,t){Qw(e,t);var s=Rr(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")?hf(e,t.type,s):t.hasOwnProperty("defaultValue")&&hf(e,t.type,Rr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function gv(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 hf(e,t,s){(t!=="number"||qc(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var hl=Array.isArray;function aa(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=""+Rr(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 ff(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(ee(91));return ft({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function xv(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(ee(92));if(hl(s)){if(1<s.length)throw Error(ee(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:Rr(s)}}function Jw(e,t){var s=Rr(t.value),r=Rr(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 vv(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Xw(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 mf(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Xw(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Lo,Zw=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(Lo=Lo||document.createElement("div"),Lo.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Lo.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Pl(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var xl={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},vA=["Webkit","ms","Moz","O"];Object.keys(xl).forEach(function(e){vA.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),xl[t]=xl[e]})});function eb(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||xl.hasOwnProperty(e)&&xl[e]?(""+t).trim():t+"px"}function tb(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var r=s.indexOf("--")===0,i=eb(s,t[s],r);s==="float"&&(s="cssFloat"),r?e.setProperty(s,i):e[s]=i}}var jA=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 pf(e,t){if(t){if(jA[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ee(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ee(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ee(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ee(62))}}function gf(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 xf=null;function kp(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var vf=null,la=null,oa=null;function jv(e){if(e=go(e)){if(typeof vf!="function")throw Error(ee(280));var t=e.stateNode;t&&(t=Hu(t),vf(e.stateNode,e.type,t))}}function nb(e){la?oa?oa.push(e):oa=[e]:la=e}function sb(){if(la){var e=la,t=oa;if(oa=la=null,jv(e),t)for(e=0;e<t.length;e++)jv(t[e])}}function rb(e,t){return e(t)}function ib(){}var Hd=!1;function ab(e,t,s){if(Hd)return e(t,s);Hd=!0;try{return rb(e,t,s)}finally{Hd=!1,(la!==null||oa!==null)&&(ib(),sb())}}function Ml(e,t){var s=e.stateNode;if(s===null)return null;var r=Hu(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(ee(231,t,typeof s));return s}var jf=!1;if(qs)try{var Za={};Object.defineProperty(Za,"passive",{get:function(){jf=!0}}),window.addEventListener("test",Za,Za),window.removeEventListener("test",Za,Za)}catch{jf=!1}function yA(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 vl=!1,Qc=null,Jc=!1,yf=null,wA={onError:function(e){vl=!0,Qc=e}};function bA(e,t,s,r,i,a,l,o,c){vl=!1,Qc=null,yA.apply(wA,arguments)}function kA(e,t,s,r,i,a,l,o,c){if(bA.apply(this,arguments),vl){if(vl){var u=Qc;vl=!1,Qc=null}else throw Error(ee(198));Jc||(Jc=!0,yf=u)}}function ki(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 lb(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 yv(e){if(ki(e)!==e)throw Error(ee(188))}function SA(e){var t=e.alternate;if(!t){if(t=ki(e),t===null)throw Error(ee(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 yv(i),e;if(a===r)return yv(i),t;a=a.sibling}throw Error(ee(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(ee(189))}}if(s.alternate!==r)throw Error(ee(190))}if(s.tag!==3)throw Error(ee(188));return s.stateNode.current===s?e:t}function ob(e){return e=SA(e),e!==null?cb(e):null}function cb(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=cb(e);if(t!==null)return t;e=e.sibling}return null}var ub=$n.unstable_scheduleCallback,wv=$n.unstable_cancelCallback,NA=$n.unstable_shouldYield,CA=$n.unstable_requestPaint,bt=$n.unstable_now,EA=$n.unstable_getCurrentPriorityLevel,Sp=$n.unstable_ImmediatePriority,db=$n.unstable_UserBlockingPriority,Xc=$n.unstable_NormalPriority,AA=$n.unstable_LowPriority,hb=$n.unstable_IdlePriority,Uu=null,Es=null;function TA(e){if(Es&&typeof Es.onCommitFiberRoot=="function")try{Es.onCommitFiberRoot(Uu,e,void 0,(e.current.flags&128)===128)}catch{}}var is=Math.clz32?Math.clz32:PA,RA=Math.log,IA=Math.LN2;function PA(e){return e>>>=0,e===0?32:31-(RA(e)/IA|0)|0}var Fo=64,Uo=4194304;function fl(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 Zc(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=fl(o):(a&=l,a!==0&&(r=fl(a)))}else l=s&~i,l!==0?r=fl(l):a!==0&&(r=fl(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-is(t),i=1<<s,r|=e[s],t&=~i;return r}function MA(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 $A(e,t){for(var s=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes;0<a;){var l=31-is(a),o=1<<l,c=i[l];c===-1?(!(o&s)||o&r)&&(i[l]=MA(o,t)):c<=t&&(e.expiredLanes|=o),a&=~o}}function wf(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function fb(){var e=Fo;return Fo<<=1,!(Fo&4194240)&&(Fo=64),e}function Vd(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function mo(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-is(t),e[t]=s}function DA(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-is(s),a=1<<i;t[i]=0,r[i]=-1,e[i]=-1,s&=~a}}function Np(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var r=31-is(s),i=1<<r;i&t|e[r]&t&&(e[r]|=t),s&=~i}}var Qe=0;function mb(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var pb,Cp,gb,xb,vb,bf=!1,Bo=[],xr=null,vr=null,jr=null,$l=new Map,Dl=new Map,hr=[],_A="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 bv(e,t){switch(e){case"focusin":case"focusout":xr=null;break;case"dragenter":case"dragleave":vr=null;break;case"mouseover":case"mouseout":jr=null;break;case"pointerover":case"pointerout":$l.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Dl.delete(t.pointerId)}}function el(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=go(t),t!==null&&Cp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function OA(e,t,s,r,i){switch(t){case"focusin":return xr=el(xr,e,t,s,r,i),!0;case"dragenter":return vr=el(vr,e,t,s,r,i),!0;case"mouseover":return jr=el(jr,e,t,s,r,i),!0;case"pointerover":var a=i.pointerId;return $l.set(a,el($l.get(a)||null,e,t,s,r,i)),!0;case"gotpointercapture":return a=i.pointerId,Dl.set(a,el(Dl.get(a)||null,e,t,s,r,i)),!0}return!1}function jb(e){var t=si(e.target);if(t!==null){var s=ki(t);if(s!==null){if(t=s.tag,t===13){if(t=lb(s),t!==null){e.blockedOn=t,vb(e.priority,function(){gb(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 Ec(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=kf(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var r=new s.constructor(s.type,s);xf=r,s.target.dispatchEvent(r),xf=null}else return t=go(s),t!==null&&Cp(t),e.blockedOn=s,!1;t.shift()}return!0}function kv(e,t,s){Ec(e)&&s.delete(t)}function LA(){bf=!1,xr!==null&&Ec(xr)&&(xr=null),vr!==null&&Ec(vr)&&(vr=null),jr!==null&&Ec(jr)&&(jr=null),$l.forEach(kv),Dl.forEach(kv)}function tl(e,t){e.blockedOn===t&&(e.blockedOn=null,bf||(bf=!0,$n.unstable_scheduleCallback($n.unstable_NormalPriority,LA)))}function _l(e){function t(i){return tl(i,e)}if(0<Bo.length){tl(Bo[0],e);for(var s=1;s<Bo.length;s++){var r=Bo[s];r.blockedOn===e&&(r.blockedOn=null)}}for(xr!==null&&tl(xr,e),vr!==null&&tl(vr,e),jr!==null&&tl(jr,e),$l.forEach(t),Dl.forEach(t),s=0;s<hr.length;s++)r=hr[s],r.blockedOn===e&&(r.blockedOn=null);for(;0<hr.length&&(s=hr[0],s.blockedOn===null);)jb(s),s.blockedOn===null&&hr.shift()}var ca=rr.ReactCurrentBatchConfig,eu=!0;function FA(e,t,s,r){var i=Qe,a=ca.transition;ca.transition=null;try{Qe=1,Ep(e,t,s,r)}finally{Qe=i,ca.transition=a}}function UA(e,t,s,r){var i=Qe,a=ca.transition;ca.transition=null;try{Qe=4,Ep(e,t,s,r)}finally{Qe=i,ca.transition=a}}function Ep(e,t,s,r){if(eu){var i=kf(e,t,s,r);if(i===null)th(e,t,r,tu,s),bv(e,r);else if(OA(i,e,t,s,r))r.stopPropagation();else if(bv(e,r),t&4&&-1<_A.indexOf(e)){for(;i!==null;){var a=go(i);if(a!==null&&pb(a),a=kf(e,t,s,r),a===null&&th(e,t,r,tu,s),a===i)break;i=a}i!==null&&r.stopPropagation()}else th(e,t,r,null,s)}}var tu=null;function kf(e,t,s,r){if(tu=null,e=kp(r),e=si(e),e!==null)if(t=ki(e),t===null)e=null;else if(s=t.tag,s===13){if(e=lb(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 tu=e,null}function yb(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(EA()){case Sp:return 1;case db:return 4;case Xc:case AA:return 16;case hb:return 536870912;default:return 16}default:return 16}}var mr=null,Ap=null,Ac=null;function wb(){if(Ac)return Ac;var e,t=Ap,s=t.length,r,i="value"in mr?mr.value:mr.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 Ac=i.slice(e,1<r?1-r:void 0)}function Tc(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 zo(){return!0}function Sv(){return!1}function On(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)?zo:Sv,this.isPropagationStopped=Sv,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=zo)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=zo)},persist:function(){},isPersistent:zo}),t}var _a={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Tp=On(_a),po=ft({},_a,{view:0,detail:0}),BA=On(po),Kd,Gd,nl,Bu=ft({},po,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rp,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!==nl&&(nl&&e.type==="mousemove"?(Kd=e.screenX-nl.screenX,Gd=e.screenY-nl.screenY):Gd=Kd=0,nl=e),Kd)},movementY:function(e){return"movementY"in e?e.movementY:Gd}}),Nv=On(Bu),zA=ft({},Bu,{dataTransfer:0}),WA=On(zA),HA=ft({},po,{relatedTarget:0}),Yd=On(HA),VA=ft({},_a,{animationName:0,elapsedTime:0,pseudoElement:0}),KA=On(VA),GA=ft({},_a,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),YA=On(GA),qA=ft({},_a,{data:0}),Cv=On(qA),QA={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},JA={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"},XA={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ZA(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=XA[e])?!!t[e]:!1}function Rp(){return ZA}var eT=ft({},po,{key:function(e){if(e.key){var t=QA[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Tc(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?JA[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rp,charCode:function(e){return e.type==="keypress"?Tc(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Tc(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),tT=On(eT),nT=ft({},Bu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ev=On(nT),sT=ft({},po,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rp}),rT=On(sT),iT=ft({},_a,{propertyName:0,elapsedTime:0,pseudoElement:0}),aT=On(iT),lT=ft({},Bu,{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}),oT=On(lT),cT=[9,13,27,32],Ip=qs&&"CompositionEvent"in window,jl=null;qs&&"documentMode"in document&&(jl=document.documentMode);var uT=qs&&"TextEvent"in window&&!jl,bb=qs&&(!Ip||jl&&8<jl&&11>=jl),Av=" ",Tv=!1;function kb(e,t){switch(e){case"keyup":return cT.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sb(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Yi=!1;function dT(e,t){switch(e){case"compositionend":return Sb(t);case"keypress":return t.which!==32?null:(Tv=!0,Av);case"textInput":return e=t.data,e===Av&&Tv?null:e;default:return null}}function hT(e,t){if(Yi)return e==="compositionend"||!Ip&&kb(e,t)?(e=wb(),Ac=Ap=mr=null,Yi=!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 bb&&t.locale!=="ko"?null:t.data;default:return null}}var fT={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 Rv(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!fT[e.type]:t==="textarea"}function Nb(e,t,s,r){nb(r),t=nu(t,"onChange"),0<t.length&&(s=new Tp("onChange","change",null,s,r),e.push({event:s,listeners:t}))}var yl=null,Ol=null;function mT(e){_b(e,0)}function zu(e){var t=Ji(e);if(qw(t))return e}function pT(e,t){if(e==="change")return t}var Cb=!1;if(qs){var qd;if(qs){var Qd="oninput"in document;if(!Qd){var Iv=document.createElement("div");Iv.setAttribute("oninput","return;"),Qd=typeof Iv.oninput=="function"}qd=Qd}else qd=!1;Cb=qd&&(!document.documentMode||9<document.documentMode)}function Pv(){yl&&(yl.detachEvent("onpropertychange",Eb),Ol=yl=null)}function Eb(e){if(e.propertyName==="value"&&zu(Ol)){var t=[];Nb(t,Ol,e,kp(e)),ab(mT,t)}}function gT(e,t,s){e==="focusin"?(Pv(),yl=t,Ol=s,yl.attachEvent("onpropertychange",Eb)):e==="focusout"&&Pv()}function xT(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return zu(Ol)}function vT(e,t){if(e==="click")return zu(t)}function jT(e,t){if(e==="input"||e==="change")return zu(t)}function yT(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var us=typeof Object.is=="function"?Object.is:yT;function Ll(e,t){if(us(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(!rf.call(t,i)||!us(e[i],t[i]))return!1}return!0}function Mv(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function $v(e,t){var s=Mv(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=Mv(s)}}function Ab(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ab(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Tb(){for(var e=window,t=qc();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=qc(e.document)}return t}function Pp(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 wT(e){var t=Tb(),s=e.focusedElem,r=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Ab(s.ownerDocument.documentElement,s)){if(r!==null&&Pp(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=$v(s,a);var l=$v(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 bT=qs&&"documentMode"in document&&11>=document.documentMode,qi=null,Sf=null,wl=null,Nf=!1;function Dv(e,t,s){var r=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Nf||qi==null||qi!==qc(r)||(r=qi,"selectionStart"in r&&Pp(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}),wl&&Ll(wl,r)||(wl=r,r=nu(Sf,"onSelect"),0<r.length&&(t=new Tp("onSelect","select",null,t,s),e.push({event:t,listeners:r}),t.target=qi)))}function Wo(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Qi={animationend:Wo("Animation","AnimationEnd"),animationiteration:Wo("Animation","AnimationIteration"),animationstart:Wo("Animation","AnimationStart"),transitionend:Wo("Transition","TransitionEnd")},Jd={},Rb={};qs&&(Rb=document.createElement("div").style,"AnimationEvent"in window||(delete Qi.animationend.animation,delete Qi.animationiteration.animation,delete Qi.animationstart.animation),"TransitionEvent"in window||delete Qi.transitionend.transition);function Wu(e){if(Jd[e])return Jd[e];if(!Qi[e])return e;var t=Qi[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Rb)return Jd[e]=t[s];return e}var Ib=Wu("animationend"),Pb=Wu("animationiteration"),Mb=Wu("animationstart"),$b=Wu("transitionend"),Db=new Map,_v="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 Lr(e,t){Db.set(e,t),bi(t,[e])}for(var Xd=0;Xd<_v.length;Xd++){var Zd=_v[Xd],kT=Zd.toLowerCase(),ST=Zd[0].toUpperCase()+Zd.slice(1);Lr(kT,"on"+ST)}Lr(Ib,"onAnimationEnd");Lr(Pb,"onAnimationIteration");Lr(Mb,"onAnimationStart");Lr("dblclick","onDoubleClick");Lr("focusin","onFocus");Lr("focusout","onBlur");Lr($b,"onTransitionEnd");xa("onMouseEnter",["mouseout","mouseover"]);xa("onMouseLeave",["mouseout","mouseover"]);xa("onPointerEnter",["pointerout","pointerover"]);xa("onPointerLeave",["pointerout","pointerover"]);bi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));bi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));bi("onBeforeInput",["compositionend","keypress","textInput","paste"]);bi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));bi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));bi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ml="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(" "),NT=new Set("cancel close invalid load scroll toggle".split(" ").concat(ml));function Ov(e,t,s){var r=e.type||"unknown-event";e.currentTarget=s,kA(r,t,void 0,e),e.currentTarget=null}function _b(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;Ov(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;Ov(i,o,u),a=c}}}if(Jc)throw e=yf,Jc=!1,yf=null,e}function et(e,t){var s=t[Rf];s===void 0&&(s=t[Rf]=new Set);var r=e+"__bubble";s.has(r)||(Ob(t,e,2,!1),s.add(r))}function eh(e,t,s){var r=0;t&&(r|=4),Ob(s,e,r,t)}var Ho="_reactListening"+Math.random().toString(36).slice(2);function Fl(e){if(!e[Ho]){e[Ho]=!0,Hw.forEach(function(s){s!=="selectionchange"&&(NT.has(s)||eh(s,!1,e),eh(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ho]||(t[Ho]=!0,eh("selectionchange",!1,t))}}function Ob(e,t,s,r){switch(yb(t)){case 1:var i=FA;break;case 4:i=UA;break;default:i=Ep}s=i.bind(null,t,s,e),i=void 0,!jf||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 th(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=si(o),l===null)return;if(c=l.tag,c===5||c===6){r=a=l;continue e}o=o.parentNode}}r=r.return}ab(function(){var u=a,f=kp(s),d=[];e:{var m=Db.get(e);if(m!==void 0){var p=Tp,j=e;switch(e){case"keypress":if(Tc(s)===0)break e;case"keydown":case"keyup":p=tT;break;case"focusin":j="focus",p=Yd;break;case"focusout":j="blur",p=Yd;break;case"beforeblur":case"afterblur":p=Yd;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=Nv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=WA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=rT;break;case Ib:case Pb:case Mb:p=KA;break;case $b:p=aT;break;case"scroll":p=BA;break;case"wheel":p=oT;break;case"copy":case"cut":case"paste":p=YA;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Ev}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 v=y.stateNode;if(y.tag===5&&v!==null&&(y=v,g!==null&&(v=Ml(x,g),v!=null&&w.push(Ul(x,v,y)))),k)break;x=x.return}0<w.length&&(m=new p(m,j,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!==xf&&(j=s.relatedTarget||s.fromElement)&&(si(j)||j[Qs]))break e;if((p||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,p?(j=s.relatedTarget||s.toElement,p=u,j=j?si(j):null,j!==null&&(k=ki(j),j!==k||j.tag!==5&&j.tag!==6)&&(j=null)):(p=null,j=u),p!==j)){if(w=Nv,v="onMouseLeave",g="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(w=Ev,v="onPointerLeave",g="onPointerEnter",x="pointer"),k=p==null?m:Ji(p),y=j==null?m:Ji(j),m=new w(v,x+"leave",p,s,f),m.target=k,m.relatedTarget=y,v=null,si(f)===u&&(w=new w(g,x+"enter",j,s,f),w.target=y,w.relatedTarget=k,v=w),k=v,p&&j)t:{for(w=p,g=j,x=0,y=w;y;y=Oi(y))x++;for(y=0,v=g;v;v=Oi(v))y++;for(;0<x-y;)w=Oi(w),x--;for(;0<y-x;)g=Oi(g),y--;for(;x--;){if(w===g||g!==null&&w===g.alternate)break t;w=Oi(w),g=Oi(g)}w=null}else w=null;p!==null&&Lv(d,m,p,w,!1),j!==null&&k!==null&&Lv(d,k,j,w,!0)}}e:{if(m=u?Ji(u):window,p=m.nodeName&&m.nodeName.toLowerCase(),p==="select"||p==="input"&&m.type==="file")var N=pT;else if(Rv(m))if(Cb)N=jT;else{N=xT;var b=gT}else(p=m.nodeName)&&p.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(N=vT);if(N&&(N=N(e,u))){Nb(d,N,s,f);break e}b&&b(e,m,u),e==="focusout"&&(b=m._wrapperState)&&b.controlled&&m.type==="number"&&hf(m,"number",m.value)}switch(b=u?Ji(u):window,e){case"focusin":(Rv(b)||b.contentEditable==="true")&&(qi=b,Sf=u,wl=null);break;case"focusout":wl=Sf=qi=null;break;case"mousedown":Nf=!0;break;case"contextmenu":case"mouseup":case"dragend":Nf=!1,Dv(d,s,f);break;case"selectionchange":if(bT)break;case"keydown":case"keyup":Dv(d,s,f)}var S;if(Ip)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 Yi?kb(e,s)&&(C="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(C="onCompositionStart");C&&(bb&&s.locale!=="ko"&&(Yi||C!=="onCompositionStart"?C==="onCompositionEnd"&&Yi&&(S=wb()):(mr=f,Ap="value"in mr?mr.value:mr.textContent,Yi=!0)),b=nu(u,C),0<b.length&&(C=new Cv(C,e,null,s,f),d.push({event:C,listeners:b}),S?C.data=S:(S=Sb(s),S!==null&&(C.data=S)))),(S=uT?dT(e,s):hT(e,s))&&(u=nu(u,"onBeforeInput"),0<u.length&&(f=new Cv("onBeforeInput","beforeinput",null,s,f),d.push({event:f,listeners:u}),f.data=S))}_b(d,t)})}function Ul(e,t,s){return{instance:e,listener:t,currentTarget:s}}function nu(e,t){for(var s=t+"Capture",r=[];e!==null;){var i=e,a=i.stateNode;i.tag===5&&a!==null&&(i=a,a=Ml(e,s),a!=null&&r.unshift(Ul(e,a,i)),a=Ml(e,t),a!=null&&r.push(Ul(e,a,i))),e=e.return}return r}function Oi(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Lv(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=Ml(s,a),c!=null&&l.unshift(Ul(s,c,o))):i||(c=Ml(s,a),c!=null&&l.push(Ul(s,c,o)))),s=s.return}l.length!==0&&e.push({event:t,listeners:l})}var CT=/\r\n?/g,ET=/\u0000|\uFFFD/g;function Fv(e){return(typeof e=="string"?e:""+e).replace(CT,`
38
+ `).replace(ET,"")}function Vo(e,t,s){if(t=Fv(t),Fv(e)!==t&&s)throw Error(ee(425))}function su(){}var Cf=null,Ef=null;function Af(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 Tf=typeof setTimeout=="function"?setTimeout:void 0,AT=typeof clearTimeout=="function"?clearTimeout:void 0,Uv=typeof Promise=="function"?Promise:void 0,TT=typeof queueMicrotask=="function"?queueMicrotask:typeof Uv<"u"?function(e){return Uv.resolve(null).then(e).catch(RT)}:Tf;function RT(e){setTimeout(function(){throw e})}function nh(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),_l(t);return}r--}else s!=="$"&&s!=="$?"&&s!=="$!"||r++;s=i}while(s);_l(t)}function yr(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 Bv(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 Oa=Math.random().toString(36).slice(2),ks="__reactFiber$"+Oa,Bl="__reactProps$"+Oa,Qs="__reactContainer$"+Oa,Rf="__reactEvents$"+Oa,IT="__reactListeners$"+Oa,PT="__reactHandles$"+Oa;function si(e){var t=e[ks];if(t)return t;for(var s=e.parentNode;s;){if(t=s[Qs]||s[ks]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=Bv(e);e!==null;){if(s=e[ks])return s;e=Bv(e)}return t}e=s,s=e.parentNode}return null}function go(e){return e=e[ks]||e[Qs],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ji(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(ee(33))}function Hu(e){return e[Bl]||null}var If=[],Xi=-1;function Fr(e){return{current:e}}function nt(e){0>Xi||(e.current=If[Xi],If[Xi]=null,Xi--)}function Xe(e,t){Xi++,If[Xi]=e.current,e.current=t}var Ir={},en=Fr(Ir),vn=Fr(!1),di=Ir;function va(e,t){var s=e.type.contextTypes;if(!s)return Ir;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 jn(e){return e=e.childContextTypes,e!=null}function ru(){nt(vn),nt(en)}function zv(e,t,s){if(en.current!==Ir)throw Error(ee(168));Xe(en,t),Xe(vn,s)}function Lb(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(ee(108,gA(e)||"Unknown",i));return ft({},s,r)}function iu(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ir,di=en.current,Xe(en,e),Xe(vn,vn.current),!0}function Wv(e,t,s){var r=e.stateNode;if(!r)throw Error(ee(169));s?(e=Lb(e,t,di),r.__reactInternalMemoizedMergedChildContext=e,nt(vn),nt(en),Xe(en,e)):nt(vn),Xe(vn,s)}var Bs=null,Vu=!1,sh=!1;function Fb(e){Bs===null?Bs=[e]:Bs.push(e)}function MT(e){Vu=!0,Fb(e)}function Ur(){if(!sh&&Bs!==null){sh=!0;var e=0,t=Qe;try{var s=Bs;for(Qe=1;e<s.length;e++){var r=s[e];do r=r(!0);while(r!==null)}Bs=null,Vu=!1}catch(i){throw Bs!==null&&(Bs=Bs.slice(e+1)),ub(Sp,Ur),i}finally{Qe=t,sh=!1}}return null}var Zi=[],ea=0,au=null,lu=0,Vn=[],Kn=0,hi=null,Ws=1,Hs="";function Zr(e,t){Zi[ea++]=lu,Zi[ea++]=au,au=e,lu=t}function Ub(e,t,s){Vn[Kn++]=Ws,Vn[Kn++]=Hs,Vn[Kn++]=hi,hi=e;var r=Ws;e=Hs;var i=32-is(r)-1;r&=~(1<<i),s+=1;var a=32-is(t)+i;if(30<a){var l=i-i%5;a=(r&(1<<l)-1).toString(32),r>>=l,i-=l,Ws=1<<32-is(t)+i|s<<i|r,Hs=a+e}else Ws=1<<a|s<<i|r,Hs=e}function Mp(e){e.return!==null&&(Zr(e,1),Ub(e,1,0))}function $p(e){for(;e===au;)au=Zi[--ea],Zi[ea]=null,lu=Zi[--ea],Zi[ea]=null;for(;e===hi;)hi=Vn[--Kn],Vn[Kn]=null,Hs=Vn[--Kn],Vn[Kn]=null,Ws=Vn[--Kn],Vn[Kn]=null}var Pn=null,Rn=null,lt=!1,ss=null;function Bb(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 Hv(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,Pn=e,Rn=yr(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Pn=e,Rn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=hi!==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,Pn=e,Rn=null,!0):!1;default:return!1}}function Pf(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Mf(e){if(lt){var t=Rn;if(t){var s=t;if(!Hv(e,t)){if(Pf(e))throw Error(ee(418));t=yr(s.nextSibling);var r=Pn;t&&Hv(e,t)?Bb(r,s):(e.flags=e.flags&-4097|2,lt=!1,Pn=e)}}else{if(Pf(e))throw Error(ee(418));e.flags=e.flags&-4097|2,lt=!1,Pn=e}}}function Vv(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Pn=e}function Ko(e){if(e!==Pn)return!1;if(!lt)return Vv(e),lt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Af(e.type,e.memoizedProps)),t&&(t=Rn)){if(Pf(e))throw zb(),Error(ee(418));for(;t;)Bb(e,t),t=yr(t.nextSibling)}if(Vv(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(ee(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){Rn=yr(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}Rn=null}}else Rn=Pn?yr(e.stateNode.nextSibling):null;return!0}function zb(){for(var e=Rn;e;)e=yr(e.nextSibling)}function ja(){Rn=Pn=null,lt=!1}function Dp(e){ss===null?ss=[e]:ss.push(e)}var $T=rr.ReactCurrentBatchConfig;function sl(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(ee(309));var r=s.stateNode}if(!r)throw Error(ee(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(ee(284));if(!s._owner)throw Error(ee(290,e))}return e}function Go(e,t){throw e=Object.prototype.toString.call(t),Error(ee(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Kv(e){var t=e._init;return t(e._payload)}function Wb(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=Sr(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,v){return x===null||x.tag!==6?(x=uh(y,g.mode,v),x.return=g,x):(x=i(x,y),x.return=g,x)}function c(g,x,y,v){var N=y.type;return N===Gi?f(g,x,y.props.children,v,y.key):x!==null&&(x.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===ur&&Kv(N)===x.type)?(v=i(x,y.props),v.ref=sl(g,x,y),v.return=g,v):(v=_c(y.type,y.key,y.props,null,g.mode,v),v.ref=sl(g,x,y),v.return=g,v)}function u(g,x,y,v){return x===null||x.tag!==4||x.stateNode.containerInfo!==y.containerInfo||x.stateNode.implementation!==y.implementation?(x=dh(y,g.mode,v),x.return=g,x):(x=i(x,y.children||[]),x.return=g,x)}function f(g,x,y,v,N){return x===null||x.tag!==7?(x=oi(y,g.mode,v,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=uh(""+x,g.mode,y),x.return=g,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case _o:return y=_c(x.type,x.key,x.props,null,g.mode,y),y.ref=sl(g,null,x),y.return=g,y;case Ki:return x=dh(x,g.mode,y),x.return=g,x;case ur:var v=x._init;return d(g,v(x._payload),y)}if(hl(x)||Xa(x))return x=oi(x,g.mode,y,null),x.return=g,x;Go(g,x)}return null}function m(g,x,y,v){var N=x!==null?x.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return N!==null?null:o(g,x,""+y,v);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case _o:return y.key===N?c(g,x,y,v):null;case Ki:return y.key===N?u(g,x,y,v):null;case ur:return N=y._init,m(g,x,N(y._payload),v)}if(hl(y)||Xa(y))return N!==null?null:f(g,x,y,v,null);Go(g,y)}return null}function p(g,x,y,v,N){if(typeof v=="string"&&v!==""||typeof v=="number")return g=g.get(y)||null,o(x,g,""+v,N);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case _o:return g=g.get(v.key===null?y:v.key)||null,c(x,g,v,N);case Ki:return g=g.get(v.key===null?y:v.key)||null,u(x,g,v,N);case ur:var b=v._init;return p(g,x,y,b(v._payload),N)}if(hl(v)||Xa(v))return g=g.get(y)||null,f(x,g,v,N,null);Go(x,v)}return null}function j(g,x,y,v){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],v);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&&Zr(g,C),N;if(S===null){for(;C<y.length;C++)S=d(g,y[C],v),S!==null&&(x=a(S,x,C),b===null?N=S:b.sibling=S,b=S);return lt&&Zr(g,C),N}for(S=r(g,S);C<y.length;C++)R=p(S,g,C,y[C],v),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&&Zr(g,C),N}function w(g,x,y,v){var N=Xa(y);if(typeof N!="function")throw Error(ee(150));if(y=N.call(y),y==null)throw Error(ee(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,v);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&&Zr(g,C),N;if(S===null){for(;!E.done;C++,E=y.next())E=d(g,E.value,v),E!==null&&(x=a(E,x,C),b===null?N=E:b.sibling=E,b=E);return lt&&Zr(g,C),N}for(S=r(g,S);!E.done;C++,E=y.next())E=p(S,g,C,E.value,v),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(L){return t(g,L)}),lt&&Zr(g,C),N}function k(g,x,y,v){if(typeof y=="object"&&y!==null&&y.type===Gi&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case _o:e:{for(var N=y.key,b=x;b!==null;){if(b.key===N){if(N=y.type,N===Gi){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===ur&&Kv(N)===b.type){s(g,b.sibling),x=i(b,y.props),x.ref=sl(g,b,y),x.return=g,g=x;break e}s(g,b);break}else t(g,b);b=b.sibling}y.type===Gi?(x=oi(y.props.children,g.mode,v,y.key),x.return=g,g=x):(v=_c(y.type,y.key,y.props,null,g.mode,v),v.ref=sl(g,x,y),v.return=g,g=v)}return l(g);case Ki: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=dh(y,g.mode,v),x.return=g,g=x}return l(g);case ur:return b=y._init,k(g,x,b(y._payload),v)}if(hl(y))return j(g,x,y,v);if(Xa(y))return w(g,x,y,v);Go(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=uh(y,g.mode,v),x.return=g,g=x),l(g)):s(g,x)}return k}var ya=Wb(!0),Hb=Wb(!1),ou=Fr(null),cu=null,ta=null,_p=null;function Op(){_p=ta=cu=null}function Lp(e){var t=ou.current;nt(ou),e._currentValue=t}function $f(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 ua(e,t){cu=e,_p=ta=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(gn=!0),e.firstContext=null)}function Jn(e){var t=e._currentValue;if(_p!==e)if(e={context:e,memoizedValue:t,next:null},ta===null){if(cu===null)throw Error(ee(308));ta=e,cu.dependencies={lanes:0,firstContext:e}}else ta=ta.next=e;return t}var ri=null;function Fp(e){ri===null?ri=[e]:ri.push(e)}function Vb(e,t,s,r){var i=t.interleaved;return i===null?(s.next=s,Fp(t)):(s.next=i.next,i.next=s),t.interleaved=s,Js(e,r)}function Js(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 dr=!1;function Up(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kb(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 wr(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,Js(e,s)}return i=r.interleaved,i===null?(t.next=t,Fp(r)):(t.next=i.next,i.next=t),r.interleaved=t,Js(e,s)}function Rc(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,Np(e,s)}}function Gv(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 uu(e,t,s,r){var i=e.updateQueue;dr=!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 j=e,w=o;switch(m=t,p=s,w.tag){case 1:if(j=w.payload,typeof j=="function"){d=j.call(p,d,m);break e}d=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=w.payload,m=typeof j=="function"?j.call(p,d,m):j,m==null)break e;d=ft({},d,m);break e;case 2:dr=!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);mi|=l,e.lanes=l,e.memoizedState=d}}function Yv(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(ee(191,i));i.call(r)}}}var xo={},As=Fr(xo),zl=Fr(xo),Wl=Fr(xo);function ii(e){if(e===xo)throw Error(ee(174));return e}function Bp(e,t){switch(Xe(Wl,t),Xe(zl,e),Xe(As,xo),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:mf(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=mf(t,e)}nt(As),Xe(As,t)}function wa(){nt(As),nt(zl),nt(Wl)}function Gb(e){ii(Wl.current);var t=ii(As.current),s=mf(t,e.type);t!==s&&(Xe(zl,e),Xe(As,s))}function zp(e){zl.current===e&&(nt(As),nt(zl))}var ct=Fr(0);function du(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 rh=[];function Wp(){for(var e=0;e<rh.length;e++)rh[e]._workInProgressVersionPrimary=null;rh.length=0}var Ic=rr.ReactCurrentDispatcher,ih=rr.ReactCurrentBatchConfig,fi=0,ht=null,Et=null,$t=null,hu=!1,bl=!1,Hl=0,DT=0;function Qt(){throw Error(ee(321))}function Hp(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!us(e[s],t[s]))return!1;return!0}function Vp(e,t,s,r,i,a){if(fi=a,ht=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ic.current=e===null||e.memoizedState===null?FT:UT,e=s(r,i),bl){a=0;do{if(bl=!1,Hl=0,25<=a)throw Error(ee(301));a+=1,$t=Et=null,t.updateQueue=null,Ic.current=BT,e=s(r,i)}while(bl)}if(Ic.current=fu,t=Et!==null&&Et.next!==null,fi=0,$t=Et=ht=null,hu=!1,t)throw Error(ee(300));return e}function Kp(){var e=Hl!==0;return Hl=0,e}function ws(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $t===null?ht.memoizedState=$t=e:$t=$t.next=e,$t}function Xn(){if(Et===null){var e=ht.alternate;e=e!==null?e.memoizedState:null}else e=Et.next;var t=$t===null?ht.memoizedState:$t.next;if(t!==null)$t=t,Et=e;else{if(e===null)throw Error(ee(310));Et=e,e={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},$t===null?ht.memoizedState=$t=e:$t=$t.next=e}return $t}function Vl(e,t){return typeof t=="function"?t(e):t}function ah(e){var t=Xn(),s=t.queue;if(s===null)throw Error(ee(311));s.lastRenderedReducer=e;var r=Et,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((fi&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,mi|=f}u=u.next}while(u!==null&&u!==a);c===null?l=r:c.next=o,us(r,t.memoizedState)||(gn=!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,mi|=a,i=i.next;while(i!==e)}else i===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function lh(e){var t=Xn(),s=t.queue;if(s===null)throw Error(ee(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);us(a,t.memoizedState)||(gn=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),s.lastRenderedState=a}return[a,r]}function Yb(){}function qb(e,t){var s=ht,r=Xn(),i=t(),a=!us(r.memoizedState,i);if(a&&(r.memoizedState=i,gn=!0),r=r.queue,Gp(Xb.bind(null,s,r,e),[e]),r.getSnapshot!==t||a||$t!==null&&$t.memoizedState.tag&1){if(s.flags|=2048,Kl(9,Jb.bind(null,s,r,i,t),void 0,null),Ot===null)throw Error(ee(349));fi&30||Qb(s,t,i)}return i}function Qb(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 Jb(e,t,s,r){t.value=s,t.getSnapshot=r,Zb(t)&&e0(e)}function Xb(e,t,s){return s(function(){Zb(t)&&e0(e)})}function Zb(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!us(e,s)}catch{return!0}}function e0(e){var t=Js(e,1);t!==null&&as(t,e,1,-1)}function qv(e){var t=ws();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vl,lastRenderedState:e},t.queue=e,e=e.dispatch=LT.bind(null,ht,e),[t.memoizedState,e]}function Kl(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 t0(){return Xn().memoizedState}function Pc(e,t,s,r){var i=ws();ht.flags|=e,i.memoizedState=Kl(1|t,s,void 0,r===void 0?null:r)}function Ku(e,t,s,r){var i=Xn();r=r===void 0?null:r;var a=void 0;if(Et!==null){var l=Et.memoizedState;if(a=l.destroy,r!==null&&Hp(r,l.deps)){i.memoizedState=Kl(t,s,a,r);return}}ht.flags|=e,i.memoizedState=Kl(1|t,s,a,r)}function Qv(e,t){return Pc(8390656,8,e,t)}function Gp(e,t){return Ku(2048,8,e,t)}function n0(e,t){return Ku(4,2,e,t)}function s0(e,t){return Ku(4,4,e,t)}function r0(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 i0(e,t,s){return s=s!=null?s.concat([e]):null,Ku(4,4,r0.bind(null,t,e),s)}function Yp(){}function a0(e,t){var s=Xn();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&Hp(t,r[1])?r[0]:(s.memoizedState=[e,t],e)}function l0(e,t){var s=Xn();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&Hp(t,r[1])?r[0]:(e=e(),s.memoizedState=[e,t],e)}function o0(e,t,s){return fi&21?(us(s,t)||(s=fb(),ht.lanes|=s,mi|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,gn=!0),e.memoizedState=s)}function _T(e,t){var s=Qe;Qe=s!==0&&4>s?s:4,e(!0);var r=ih.transition;ih.transition={};try{e(!1),t()}finally{Qe=s,ih.transition=r}}function c0(){return Xn().memoizedState}function OT(e,t,s){var r=kr(e);if(s={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null},u0(e))d0(t,s);else if(s=Vb(e,t,s,r),s!==null){var i=cn();as(s,e,r,i),h0(s,t,r)}}function LT(e,t,s){var r=kr(e),i={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null};if(u0(e))d0(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,us(o,l)){var c=t.interleaved;c===null?(i.next=i,Fp(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}s=Vb(e,t,i,r),s!==null&&(i=cn(),as(s,e,r,i),h0(s,t,r))}}function u0(e){var t=e.alternate;return e===ht||t!==null&&t===ht}function d0(e,t){bl=hu=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function h0(e,t,s){if(s&4194240){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,Np(e,s)}}var fu={readContext:Jn,useCallback:Qt,useContext:Qt,useEffect:Qt,useImperativeHandle:Qt,useInsertionEffect:Qt,useLayoutEffect:Qt,useMemo:Qt,useReducer:Qt,useRef:Qt,useState:Qt,useDebugValue:Qt,useDeferredValue:Qt,useTransition:Qt,useMutableSource:Qt,useSyncExternalStore:Qt,useId:Qt,unstable_isNewReconciler:!1},FT={readContext:Jn,useCallback:function(e,t){return ws().memoizedState=[e,t===void 0?null:t],e},useContext:Jn,useEffect:Qv,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,Pc(4194308,4,r0.bind(null,t,e),s)},useLayoutEffect:function(e,t){return Pc(4194308,4,e,t)},useInsertionEffect:function(e,t){return Pc(4,2,e,t)},useMemo:function(e,t){var s=ws();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var r=ws();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=OT.bind(null,ht,e),[r.memoizedState,e]},useRef:function(e){var t=ws();return e={current:e},t.memoizedState=e},useState:qv,useDebugValue:Yp,useDeferredValue:function(e){return ws().memoizedState=e},useTransition:function(){var e=qv(!1),t=e[0];return e=_T.bind(null,e[1]),ws().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var r=ht,i=ws();if(lt){if(s===void 0)throw Error(ee(407));s=s()}else{if(s=t(),Ot===null)throw Error(ee(349));fi&30||Qb(r,t,s)}i.memoizedState=s;var a={value:s,getSnapshot:t};return i.queue=a,Qv(Xb.bind(null,r,a,e),[e]),r.flags|=2048,Kl(9,Jb.bind(null,r,a,s,t),void 0,null),s},useId:function(){var e=ws(),t=Ot.identifierPrefix;if(lt){var s=Hs,r=Ws;s=(r&~(1<<32-is(r)-1)).toString(32)+s,t=":"+t+"R"+s,s=Hl++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=DT++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},UT={readContext:Jn,useCallback:a0,useContext:Jn,useEffect:Gp,useImperativeHandle:i0,useInsertionEffect:n0,useLayoutEffect:s0,useMemo:l0,useReducer:ah,useRef:t0,useState:function(){return ah(Vl)},useDebugValue:Yp,useDeferredValue:function(e){var t=Xn();return o0(t,Et.memoizedState,e)},useTransition:function(){var e=ah(Vl)[0],t=Xn().memoizedState;return[e,t]},useMutableSource:Yb,useSyncExternalStore:qb,useId:c0,unstable_isNewReconciler:!1},BT={readContext:Jn,useCallback:a0,useContext:Jn,useEffect:Gp,useImperativeHandle:i0,useInsertionEffect:n0,useLayoutEffect:s0,useMemo:l0,useReducer:lh,useRef:t0,useState:function(){return lh(Vl)},useDebugValue:Yp,useDeferredValue:function(e){var t=Xn();return Et===null?t.memoizedState=e:o0(t,Et.memoizedState,e)},useTransition:function(){var e=lh(Vl)[0],t=Xn().memoizedState;return[e,t]},useMutableSource:Yb,useSyncExternalStore:qb,useId:c0,unstable_isNewReconciler:!1};function ts(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 Df(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 Gu={isMounted:function(e){return(e=e._reactInternals)?ki(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var r=cn(),i=kr(e),a=Vs(r,i);a.payload=t,s!=null&&(a.callback=s),t=wr(e,a,i),t!==null&&(as(t,e,i,r),Rc(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var r=cn(),i=kr(e),a=Vs(r,i);a.tag=1,a.payload=t,s!=null&&(a.callback=s),t=wr(e,a,i),t!==null&&(as(t,e,i,r),Rc(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=cn(),r=kr(e),i=Vs(s,r);i.tag=2,t!=null&&(i.callback=t),t=wr(e,i,r),t!==null&&(as(t,e,r,s),Rc(t,e,r))}};function Jv(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?!Ll(s,r)||!Ll(i,a):!0}function f0(e,t,s){var r=!1,i=Ir,a=t.contextType;return typeof a=="object"&&a!==null?a=Jn(a):(i=jn(t)?di:en.current,r=t.contextTypes,a=(r=r!=null)?va(e,i):Ir),t=new t(s,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Gu,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Xv(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&&Gu.enqueueReplaceState(t,t.state,null)}function _f(e,t,s,r){var i=e.stateNode;i.props=s,i.state=e.memoizedState,i.refs={},Up(e);var a=t.contextType;typeof a=="object"&&a!==null?i.context=Jn(a):(a=jn(t)?di:en.current,i.context=va(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a=="function"&&(Df(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&&Gu.enqueueReplaceState(i,i.state,null),uu(e,s,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function ba(e,t){try{var s="",r=t;do s+=pA(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 oh(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function Of(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var zT=typeof WeakMap=="function"?WeakMap:Map;function m0(e,t,s){s=Vs(-1,s),s.tag=3,s.payload={element:null};var r=t.value;return s.callback=function(){pu||(pu=!0,Gf=r),Of(e,t)},s}function p0(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(){Of(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(s.callback=function(){Of(e,t),typeof r!="function"&&(br===null?br=new Set([this]):br.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),s}function Zv(e,t,s){var r=e.pingCache;if(r===null){r=e.pingCache=new zT;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=nR.bind(null,e,t,s),t.then(e,e))}function ej(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 tj(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,wr(s,t,1))),s.lanes|=1),e)}var WT=rr.ReactCurrentOwner,gn=!1;function an(e,t,s,r){t.child=e===null?Hb(t,null,s,r):ya(t,e.child,s,r)}function nj(e,t,s,r,i){s=s.render;var a=t.ref;return ua(t,i),r=Vp(e,t,s,r,a,i),s=Kp(),e!==null&&!gn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Xs(e,t,i)):(lt&&s&&Mp(t),t.flags|=1,an(e,t,r,i),t.child)}function sj(e,t,s,r,i){if(e===null){var a=s.type;return typeof a=="function"&&!ng(a)&&a.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=a,g0(e,t,a,r,i)):(e=_c(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:Ll,s(l,r)&&e.ref===t.ref)return Xs(e,t,i)}return t.flags|=1,e=Sr(a,r),e.ref=t.ref,e.return=t,t.child=e}function g0(e,t,s,r,i){if(e!==null){var a=e.memoizedProps;if(Ll(a,r)&&e.ref===t.ref)if(gn=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(gn=!0);else return t.lanes=e.lanes,Xs(e,t,i)}return Lf(e,t,s,r,i)}function x0(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},Xe(sa,An),An|=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,Xe(sa,An),An|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a!==null?a.baseLanes:s,Xe(sa,An),An|=r}else a!==null?(r=a.baseLanes|s,t.memoizedState=null):r=s,Xe(sa,An),An|=r;return an(e,t,i,s),t.child}function v0(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function Lf(e,t,s,r,i){var a=jn(s)?di:en.current;return a=va(t,a),ua(t,i),s=Vp(e,t,s,r,a,i),r=Kp(),e!==null&&!gn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Xs(e,t,i)):(lt&&r&&Mp(t),t.flags|=1,an(e,t,s,i),t.child)}function rj(e,t,s,r,i){if(jn(s)){var a=!0;iu(t)}else a=!1;if(ua(t,i),t.stateNode===null)Mc(e,t),f0(t,s,r),_f(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=Jn(u):(u=jn(s)?di:en.current,u=va(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)&&Xv(t,l,r,u),dr=!1;var m=t.memoizedState;l.state=m,uu(t,r,l,i),c=t.memoizedState,o!==r||m!==c||vn.current||dr?(typeof f=="function"&&(Df(t,s,f,r),c=t.memoizedState),(o=dr||Jv(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,Kb(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:ts(t.type,o),l.props=u,d=t.pendingProps,m=l.context,c=s.contextType,typeof c=="object"&&c!==null?c=Jn(c):(c=jn(s)?di:en.current,c=va(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)&&Xv(t,l,r,c),dr=!1,m=t.memoizedState,l.state=m,uu(t,r,l,i);var j=t.memoizedState;o!==d||m!==j||vn.current||dr?(typeof p=="function"&&(Df(t,s,p,r),j=t.memoizedState),(u=dr||Jv(t,s,u,r,m,j,c)||!1)?(f||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,j,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,j,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=j),l.props=r,l.state=j,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 Ff(e,t,s,r,a,i)}function Ff(e,t,s,r,i,a){v0(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return i&&Wv(t,s,!1),Xs(e,t,a);r=t.stateNode,WT.current=t;var o=l&&typeof s.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=ya(t,e.child,null,a),t.child=ya(t,null,o,a)):an(e,t,o,a),t.memoizedState=r.state,i&&Wv(t,s,!0),t.child}function j0(e){var t=e.stateNode;t.pendingContext?zv(e,t.pendingContext,t.pendingContext!==t.context):t.context&&zv(e,t.context,!1),Bp(e,t.containerInfo)}function ij(e,t,s,r,i){return ja(),Dp(i),t.flags|=256,an(e,t,s,r),t.child}var Uf={dehydrated:null,treeContext:null,retryLane:0};function Bf(e){return{baseLanes:e,cachePool:null,transitions:null}}function y0(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),Xe(ct,i&1),e===null)return Mf(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=Qu(l,r,0,null),e=oi(e,r,s,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Bf(s),t.memoizedState=Uf,e):qp(t,l));if(i=e.memoizedState,i!==null&&(o=i.dehydrated,o!==null))return HT(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=Sr(i,c),r.subtreeFlags=i.subtreeFlags&14680064),o!==null?a=Sr(o,a):(a=oi(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?Bf(s):{baseLanes:l.baseLanes|s,cachePool:null,transitions:l.transitions},a.memoizedState=l,a.childLanes=e.childLanes&~s,t.memoizedState=Uf,r}return a=e.child,e=a.sibling,r=Sr(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 qp(e,t){return t=Qu({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Yo(e,t,s,r){return r!==null&&Dp(r),ya(t,e.child,null,s),e=qp(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function HT(e,t,s,r,i,a,l){if(s)return t.flags&256?(t.flags&=-257,r=oh(Error(ee(422))),Yo(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(a=r.fallback,i=t.mode,r=Qu({mode:"visible",children:r.children},i,0,null),a=oi(a,i,l,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,t.mode&1&&ya(t,e.child,null,l),t.child.memoizedState=Bf(l),t.memoizedState=Uf,a);if(!(t.mode&1))return Yo(e,t,l,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var o=r.dgst;return r=o,a=Error(ee(419)),r=oh(a,r,void 0),Yo(e,t,l,r)}if(o=(l&e.childLanes)!==0,gn||o){if(r=Ot,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,Js(e,i),as(r,e,i,-1))}return tg(),r=oh(Error(ee(421))),Yo(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,Rn=yr(i.nextSibling),Pn=t,lt=!0,ss=null,e!==null&&(Vn[Kn++]=Ws,Vn[Kn++]=Hs,Vn[Kn++]=hi,Ws=e.id,Hs=e.overflow,hi=t),t=qp(t,r.children),t.flags|=4096,t)}function aj(e,t,s){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),$f(e.return,t,s)}function ch(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 w0(e,t,s){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(an(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&&aj(e,s,t);else if(e.tag===19)aj(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(Xe(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&&du(e)===null&&(i=s),s=s.sibling;s=i,s===null?(i=t.child,t.child=null):(i=s.sibling,s.sibling=null),ch(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&&du(e)===null){t.child=i;break}e=i.sibling,i.sibling=s,s=i,i=e}ch(t,!0,s,null,a);break;case"together":ch(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Mc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Xs(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),mi|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(ee(153));if(t.child!==null){for(e=t.child,s=Sr(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Sr(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function VT(e,t,s){switch(t.tag){case 3:j0(t),ja();break;case 5:Gb(t);break;case 1:jn(t.type)&&iu(t);break;case 4:Bp(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Xe(ou,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Xe(ct,ct.current&1),t.flags|=128,null):s&t.child.childLanes?y0(e,t,s):(Xe(ct,ct.current&1),e=Xs(e,t,s),e!==null?e.sibling:null);Xe(ct,ct.current&1);break;case 19:if(r=(s&t.childLanes)!==0,e.flags&128){if(r)return w0(e,t,s);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Xe(ct,ct.current),r)break;return null;case 22:case 23:return t.lanes=0,x0(e,t,s)}return Xs(e,t,s)}var b0,zf,k0,S0;b0=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}};zf=function(){};k0=function(e,t,s,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,ii(As.current);var a=null;switch(s){case"input":i=uf(e,i),r=uf(e,r),a=[];break;case"select":i=ft({},i,{value:void 0}),r=ft({},r,{value:void 0}),a=[];break;case"textarea":i=ff(e,i),r=ff(e,r),a=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=su)}pf(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"&&(Il.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"&&(Il.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&et("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)}};S0=function(e,t,s,r){s!==r&&(t.flags|=4)};function rl(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 Jt(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 KT(e,t,s){var r=t.pendingProps;switch($p(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jt(t),null;case 1:return jn(t.type)&&ru(),Jt(t),null;case 3:return r=t.stateNode,wa(),nt(vn),nt(en),Wp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ko(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ss!==null&&(Qf(ss),ss=null))),zf(e,t),Jt(t),null;case 5:zp(t);var i=ii(Wl.current);if(s=t.type,e!==null&&t.stateNode!=null)k0(e,t,s,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(ee(166));return Jt(t),null}if(e=ii(As.current),Ko(t)){r=t.stateNode,s=t.type;var a=t.memoizedProps;switch(r[ks]=t,r[Bl]=a,e=(t.mode&1)!==0,s){case"dialog":et("cancel",r),et("close",r);break;case"iframe":case"object":case"embed":et("load",r);break;case"video":case"audio":for(i=0;i<ml.length;i++)et(ml[i],r);break;case"source":et("error",r);break;case"img":case"image":case"link":et("error",r),et("load",r);break;case"details":et("toggle",r);break;case"input":pv(r,a),et("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},et("invalid",r);break;case"textarea":xv(r,a),et("invalid",r)}pf(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&&Vo(r.textContent,o,e),i=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(a.suppressHydrationWarning!==!0&&Vo(r.textContent,o,e),i=["children",""+o]):Il.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&et("scroll",r)}switch(s){case"input":Oo(r),gv(r,a,!0);break;case"textarea":Oo(r),vv(r);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(r.onclick=su)}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=Xw(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[ks]=t,e[Bl]=r,b0(e,t,!1,!1),t.stateNode=e;e:{switch(l=gf(s,r),s){case"dialog":et("cancel",e),et("close",e),i=r;break;case"iframe":case"object":case"embed":et("load",e),i=r;break;case"video":case"audio":for(i=0;i<ml.length;i++)et(ml[i],e);i=r;break;case"source":et("error",e),i=r;break;case"img":case"image":case"link":et("error",e),et("load",e),i=r;break;case"details":et("toggle",e),i=r;break;case"input":pv(e,r),i=uf(e,r),et("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=ft({},r,{value:void 0}),et("invalid",e);break;case"textarea":xv(e,r),i=ff(e,r),et("invalid",e);break;default:i=r}pf(s,i),o=i;for(a in o)if(o.hasOwnProperty(a)){var c=o[a];a==="style"?tb(e,c):a==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Zw(e,c)):a==="children"?typeof c=="string"?(s!=="textarea"||c!=="")&&Pl(e,c):typeof c=="number"&&Pl(e,""+c):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(Il.hasOwnProperty(a)?c!=null&&a==="onScroll"&&et("scroll",e):c!=null&&jp(e,a,c,l))}switch(s){case"input":Oo(e),gv(e,r,!1);break;case"textarea":Oo(e),vv(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Rr(r.value));break;case"select":e.multiple=!!r.multiple,a=r.value,a!=null?aa(e,!!r.multiple,a,!1):r.defaultValue!=null&&aa(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=su)}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 Jt(t),null;case 6:if(e&&t.stateNode!=null)S0(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(ee(166));if(s=ii(Wl.current),ii(As.current),Ko(t)){if(r=t.stateNode,s=t.memoizedProps,r[ks]=t,(a=r.nodeValue!==s)&&(e=Pn,e!==null))switch(e.tag){case 3:Vo(r.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Vo(r.nodeValue,s,(e.mode&1)!==0)}a&&(t.flags|=4)}else r=(s.nodeType===9?s:s.ownerDocument).createTextNode(r),r[ks]=t,t.stateNode=r}return Jt(t),null;case 13:if(nt(ct),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(lt&&Rn!==null&&t.mode&1&&!(t.flags&128))zb(),ja(),t.flags|=98560,a=!1;else if(a=Ko(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(ee(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(ee(317));a[ks]=t}else ja(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Jt(t),a=!1}else ss!==null&&(Qf(ss),ss=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?Rt===0&&(Rt=3):tg())),t.updateQueue!==null&&(t.flags|=4),Jt(t),null);case 4:return wa(),zf(e,t),e===null&&Fl(t.stateNode.containerInfo),Jt(t),null;case 10:return Lp(t.type._context),Jt(t),null;case 17:return jn(t.type)&&ru(),Jt(t),null;case 19:if(nt(ct),a=t.memoizedState,a===null)return Jt(t),null;if(r=(t.flags&128)!==0,l=a.rendering,l===null)if(r)rl(a,!1);else{if(Rt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=du(e),l!==null){for(t.flags|=128,rl(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 Xe(ct,ct.current&1|2),t.child}e=e.sibling}a.tail!==null&&bt()>ka&&(t.flags|=128,r=!0,rl(a,!1),t.lanes=4194304)}else{if(!r)if(e=du(l),e!==null){if(t.flags|=128,r=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),rl(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!lt)return Jt(t),null}else 2*bt()-a.renderingStartTime>ka&&s!==1073741824&&(t.flags|=128,r=!0,rl(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,Xe(ct,r?s&1|2:s&1),t):(Jt(t),null);case 22:case 23:return eg(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?An&1073741824&&(Jt(t),t.subtreeFlags&6&&(t.flags|=8192)):Jt(t),null;case 24:return null;case 25:return null}throw Error(ee(156,t.tag))}function GT(e,t){switch($p(t),t.tag){case 1:return jn(t.type)&&ru(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return wa(),nt(vn),nt(en),Wp(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return zp(t),null;case 13:if(nt(ct),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ee(340));ja()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return nt(ct),null;case 4:return wa(),null;case 10:return Lp(t.type._context),null;case 22:case 23:return eg(),null;case 24:return null;default:return null}}var qo=!1,Zt=!1,YT=typeof WeakSet=="function"?WeakSet:Set,pe=null;function na(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 Wf(e,t,s){try{s()}catch(r){vt(e,t,r)}}var lj=!1;function qT(e,t){if(Cf=eu,e=Tb(),Pp(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(Ef={focusedElem:e,selectionRange:s},eu=!1,pe=t;pe!==null;)if(t=pe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,pe=e;else for(;pe!==null;){t=pe;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var w=j.memoizedProps,k=j.memoizedState,g=t.stateNode,x=g.getSnapshotBeforeUpdate(t.elementType===t.type?w:ts(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(ee(163))}}catch(v){vt(t,t.return,v)}if(e=t.sibling,e!==null){e.return=t.return,pe=e;break}pe=t.return}return j=lj,lj=!1,j}function kl(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&&Wf(t,s,a)}i=i.next}while(i!==r)}}function Yu(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 Hf(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 N0(e){var t=e.alternate;t!==null&&(e.alternate=null,N0(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ks],delete t[Bl],delete t[Rf],delete t[IT],delete t[PT])),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 C0(e){return e.tag===5||e.tag===3||e.tag===4}function oj(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||C0(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 Vf(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=su));else if(r!==4&&(e=e.child,e!==null))for(Vf(e,t,s),e=e.sibling;e!==null;)Vf(e,t,s),e=e.sibling}function Kf(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(Kf(e,t,s),e=e.sibling;e!==null;)Kf(e,t,s),e=e.sibling}var Ut=null,ns=!1;function or(e,t,s){for(s=s.child;s!==null;)E0(e,t,s),s=s.sibling}function E0(e,t,s){if(Es&&typeof Es.onCommitFiberUnmount=="function")try{Es.onCommitFiberUnmount(Uu,s)}catch{}switch(s.tag){case 5:Zt||na(s,t);case 6:var r=Ut,i=ns;Ut=null,or(e,t,s),Ut=r,ns=i,Ut!==null&&(ns?(e=Ut,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):Ut.removeChild(s.stateNode));break;case 18:Ut!==null&&(ns?(e=Ut,s=s.stateNode,e.nodeType===8?nh(e.parentNode,s):e.nodeType===1&&nh(e,s),_l(e)):nh(Ut,s.stateNode));break;case 4:r=Ut,i=ns,Ut=s.stateNode.containerInfo,ns=!0,or(e,t,s),Ut=r,ns=i;break;case 0:case 11:case 14:case 15:if(!Zt&&(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)&&Wf(s,t,l),i=i.next}while(i!==r)}or(e,t,s);break;case 1:if(!Zt&&(na(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)}or(e,t,s);break;case 21:or(e,t,s);break;case 22:s.mode&1?(Zt=(r=Zt)||s.memoizedState!==null,or(e,t,s),Zt=r):or(e,t,s);break;default:or(e,t,s)}}function cj(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new YT),t.forEach(function(r){var i=rR.bind(null,e,r);s.has(r)||(s.add(r),r.then(i,i))})}}function es(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:Ut=o.stateNode,ns=!1;break e;case 3:Ut=o.stateNode.containerInfo,ns=!0;break e;case 4:Ut=o.stateNode.containerInfo,ns=!0;break e}o=o.return}if(Ut===null)throw Error(ee(160));E0(a,l,i),Ut=null,ns=!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;)A0(t,e),t=t.sibling}function A0(e,t){var s=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(es(t,e),js(e),r&4){try{kl(3,e,e.return),Yu(3,e)}catch(w){vt(e,e.return,w)}try{kl(5,e,e.return)}catch(w){vt(e,e.return,w)}}break;case 1:es(t,e),js(e),r&512&&s!==null&&na(s,s.return);break;case 5:if(es(t,e),js(e),r&512&&s!==null&&na(s,s.return),e.flags&32){var i=e.stateNode;try{Pl(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&&Qw(i,a),gf(o,l);var u=gf(o,a);for(l=0;l<c.length;l+=2){var f=c[l],d=c[l+1];f==="style"?tb(i,d):f==="dangerouslySetInnerHTML"?Zw(i,d):f==="children"?Pl(i,d):jp(i,f,d,u)}switch(o){case"input":df(i,a);break;case"textarea":Jw(i,a);break;case"select":var m=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!a.multiple;var p=a.value;p!=null?aa(i,!!a.multiple,p,!1):m!==!!a.multiple&&(a.defaultValue!=null?aa(i,!!a.multiple,a.defaultValue,!0):aa(i,!!a.multiple,a.multiple?[]:"",!1))}i[Bl]=a}catch(w){vt(e,e.return,w)}}break;case 6:if(es(t,e),js(e),r&4){if(e.stateNode===null)throw Error(ee(162));i=e.stateNode,a=e.memoizedProps;try{i.nodeValue=a}catch(w){vt(e,e.return,w)}}break;case 3:if(es(t,e),js(e),r&4&&s!==null&&s.memoizedState.isDehydrated)try{_l(t.containerInfo)}catch(w){vt(e,e.return,w)}break;case 4:es(t,e),js(e);break;case 13:es(t,e),js(e),i=e.child,i.flags&8192&&(a=i.memoizedState!==null,i.stateNode.isHidden=a,!a||i.alternate!==null&&i.alternate.memoizedState!==null||(Xp=bt())),r&4&&cj(e);break;case 22:if(f=s!==null&&s.memoizedState!==null,e.mode&1?(Zt=(u=Zt)||f,es(t,e),Zt=u):es(t,e),js(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(pe=e,f=e.child;f!==null;){for(d=pe=f;pe!==null;){switch(m=pe,p=m.child,m.tag){case 0:case 11:case 14:case 15:kl(4,m,m.return);break;case 1:na(m,m.return);var j=m.stateNode;if(typeof j.componentWillUnmount=="function"){r=m,s=m.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(w){vt(r,s,w)}}break;case 5:na(m,m.return);break;case 22:if(m.memoizedState!==null){dj(d);continue}}p!==null?(p.return=m,pe=p):dj(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=eb("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:es(t,e),js(e),r&4&&cj(e);break;case 21:break;default:es(t,e),js(e)}}function js(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(C0(s)){var r=s;break e}s=s.return}throw Error(ee(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Pl(i,""),r.flags&=-33);var a=oj(e);Kf(e,a,i);break;case 3:case 4:var l=r.stateNode.containerInfo,o=oj(e);Vf(e,o,l);break;default:throw Error(ee(161))}}catch(c){vt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function QT(e,t,s){pe=e,T0(e)}function T0(e,t,s){for(var r=(e.mode&1)!==0;pe!==null;){var i=pe,a=i.child;if(i.tag===22&&r){var l=i.memoizedState!==null||qo;if(!l){var o=i.alternate,c=o!==null&&o.memoizedState!==null||Zt;o=qo;var u=Zt;if(qo=l,(Zt=c)&&!u)for(pe=i;pe!==null;)l=pe,c=l.child,l.tag===22&&l.memoizedState!==null?hj(i):c!==null?(c.return=l,pe=c):hj(i);for(;a!==null;)pe=a,T0(a),a=a.sibling;pe=i,qo=o,Zt=u}uj(e)}else i.subtreeFlags&8772&&a!==null?(a.return=i,pe=a):uj(e)}}function uj(e){for(;pe!==null;){var t=pe;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Zt||Yu(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Zt)if(s===null)r.componentDidMount();else{var i=t.elementType===t.type?s.memoizedProps:ts(t.type,s.memoizedProps);r.componentDidUpdate(i,s.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;a!==null&&Yv(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}Yv(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&&_l(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ee(163))}Zt||t.flags&512&&Hf(t)}catch(m){vt(t,t.return,m)}}if(t===e){pe=null;break}if(s=t.sibling,s!==null){s.return=t.return,pe=s;break}pe=t.return}}function dj(e){for(;pe!==null;){var t=pe;if(t===e){pe=null;break}var s=t.sibling;if(s!==null){s.return=t.return,pe=s;break}pe=t.return}}function hj(e){for(;pe!==null;){var t=pe;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{Yu(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{Hf(t)}catch(c){vt(t,a,c)}break;case 5:var l=t.return;try{Hf(t)}catch(c){vt(t,l,c)}}}catch(c){vt(t,t.return,c)}if(t===e){pe=null;break}var o=t.sibling;if(o!==null){o.return=t.return,pe=o;break}pe=t.return}}var JT=Math.ceil,mu=rr.ReactCurrentDispatcher,Qp=rr.ReactCurrentOwner,Qn=rr.ReactCurrentBatchConfig,We=0,Ot=null,St=null,Bt=0,An=0,sa=Fr(0),Rt=0,Gl=null,mi=0,qu=0,Jp=0,Sl=null,mn=null,Xp=0,ka=1/0,Fs=null,pu=!1,Gf=null,br=null,Qo=!1,pr=null,gu=0,Nl=0,Yf=null,$c=-1,Dc=0;function cn(){return We&6?bt():$c!==-1?$c:$c=bt()}function kr(e){return e.mode&1?We&2&&Bt!==0?Bt&-Bt:$T.transition!==null?(Dc===0&&(Dc=fb()),Dc):(e=Qe,e!==0||(e=window.event,e=e===void 0?16:yb(e.type)),e):1}function as(e,t,s,r){if(50<Nl)throw Nl=0,Yf=null,Error(ee(185));mo(e,s,r),(!(We&2)||e!==Ot)&&(e===Ot&&(!(We&2)&&(qu|=s),Rt===4&&fr(e,Bt)),yn(e,r),s===1&&We===0&&!(t.mode&1)&&(ka=bt()+500,Vu&&Ur()))}function yn(e,t){var s=e.callbackNode;$A(e,t);var r=Zc(e,e===Ot?Bt:0);if(r===0)s!==null&&wv(s),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(s!=null&&wv(s),t===1)e.tag===0?MT(fj.bind(null,e)):Fb(fj.bind(null,e)),TT(function(){!(We&6)&&Ur()}),s=null;else{switch(mb(r)){case 1:s=Sp;break;case 4:s=db;break;case 16:s=Xc;break;case 536870912:s=hb;break;default:s=Xc}s=O0(s,R0.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function R0(e,t){if($c=-1,Dc=0,We&6)throw Error(ee(327));var s=e.callbackNode;if(da()&&e.callbackNode!==s)return null;var r=Zc(e,e===Ot?Bt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=xu(e,r);else{t=r;var i=We;We|=2;var a=P0();(Ot!==e||Bt!==t)&&(Fs=null,ka=bt()+500,li(e,t));do try{eR();break}catch(o){I0(e,o)}while(!0);Op(),mu.current=a,We=i,St!==null?t=0:(Ot=null,Bt=0,t=Rt)}if(t!==0){if(t===2&&(i=wf(e),i!==0&&(r=i,t=qf(e,i))),t===1)throw s=Gl,li(e,0),fr(e,r),yn(e,bt()),s;if(t===6)fr(e,r);else{if(i=e.current.alternate,!(r&30)&&!XT(i)&&(t=xu(e,r),t===2&&(a=wf(e),a!==0&&(r=a,t=qf(e,a))),t===1))throw s=Gl,li(e,0),fr(e,r),yn(e,bt()),s;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(ee(345));case 2:ei(e,mn,Fs);break;case 3:if(fr(e,r),(r&130023424)===r&&(t=Xp+500-bt(),10<t)){if(Zc(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){cn(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=Tf(ei.bind(null,e,mn,Fs),t);break}ei(e,mn,Fs);break;case 4:if(fr(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var l=31-is(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*JT(r/1960))-r,10<r){e.timeoutHandle=Tf(ei.bind(null,e,mn,Fs),r);break}ei(e,mn,Fs);break;case 5:ei(e,mn,Fs);break;default:throw Error(ee(329))}}}return yn(e,bt()),e.callbackNode===s?R0.bind(null,e):null}function qf(e,t){var s=Sl;return e.current.memoizedState.isDehydrated&&(li(e,t).flags|=256),e=xu(e,t),e!==2&&(t=mn,mn=s,t!==null&&Qf(t)),e}function Qf(e){mn===null?mn=e:mn.push.apply(mn,e)}function XT(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(!us(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 fr(e,t){for(t&=~Jp,t&=~qu,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-is(t),r=1<<s;e[s]=-1,t&=~r}}function fj(e){if(We&6)throw Error(ee(327));da();var t=Zc(e,0);if(!(t&1))return yn(e,bt()),null;var s=xu(e,t);if(e.tag!==0&&s===2){var r=wf(e);r!==0&&(t=r,s=qf(e,r))}if(s===1)throw s=Gl,li(e,0),fr(e,t),yn(e,bt()),s;if(s===6)throw Error(ee(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ei(e,mn,Fs),yn(e,bt()),null}function Zp(e,t){var s=We;We|=1;try{return e(t)}finally{We=s,We===0&&(ka=bt()+500,Vu&&Ur())}}function pi(e){pr!==null&&pr.tag===0&&!(We&6)&&da();var t=We;We|=1;var s=Qn.transition,r=Qe;try{if(Qn.transition=null,Qe=1,e)return e()}finally{Qe=r,Qn.transition=s,We=t,!(We&6)&&Ur()}}function eg(){An=sa.current,nt(sa)}function li(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,AT(s)),St!==null)for(s=St.return;s!==null;){var r=s;switch($p(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ru();break;case 3:wa(),nt(vn),nt(en),Wp();break;case 5:zp(r);break;case 4:wa();break;case 13:nt(ct);break;case 19:nt(ct);break;case 10:Lp(r.type._context);break;case 22:case 23:eg()}s=s.return}if(Ot=e,St=e=Sr(e.current,null),Bt=An=t,Rt=0,Gl=null,Jp=qu=mi=0,mn=Sl=null,ri!==null){for(t=0;t<ri.length;t++)if(s=ri[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}ri=null}return e}function I0(e,t){do{var s=St;try{if(Op(),Ic.current=fu,hu){for(var r=ht.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}hu=!1}if(fi=0,$t=Et=ht=null,bl=!1,Hl=0,Qp.current=null,s===null||s.return===null){Rt=1,Gl=t,St=null;break}e:{var a=e,l=s.return,o=s,c=t;if(t=Bt,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=ej(l);if(p!==null){p.flags&=-257,tj(p,l,o,a,t),p.mode&1&&Zv(a,u,t),t=p,c=u;var j=t.updateQueue;if(j===null){var w=new Set;w.add(c),t.updateQueue=w}else j.add(c);break e}else{if(!(t&1)){Zv(a,u,t),tg();break e}c=Error(ee(426))}}else if(lt&&o.mode&1){var k=ej(l);if(k!==null){!(k.flags&65536)&&(k.flags|=256),tj(k,l,o,a,t),Dp(ba(c,o));break e}}a=c=ba(c,o),Rt!==4&&(Rt=2),Sl===null?Sl=[a]:Sl.push(a),a=l;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t;var g=m0(a,c,t);Gv(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"&&(br===null||!br.has(y)))){a.flags|=65536,t&=-t,a.lanes|=t;var v=p0(a,o,t);Gv(a,v);break e}}a=a.return}while(a!==null)}$0(s)}catch(N){t=N,St===s&&s!==null&&(St=s=s.return);continue}break}while(!0)}function P0(){var e=mu.current;return mu.current=fu,e===null?fu:e}function tg(){(Rt===0||Rt===3||Rt===2)&&(Rt=4),Ot===null||!(mi&268435455)&&!(qu&268435455)||fr(Ot,Bt)}function xu(e,t){var s=We;We|=2;var r=P0();(Ot!==e||Bt!==t)&&(Fs=null,li(e,t));do try{ZT();break}catch(i){I0(e,i)}while(!0);if(Op(),We=s,mu.current=r,St!==null)throw Error(ee(261));return Ot=null,Bt=0,Rt}function ZT(){for(;St!==null;)M0(St)}function eR(){for(;St!==null&&!NA();)M0(St)}function M0(e){var t=_0(e.alternate,e,An);e.memoizedProps=e.pendingProps,t===null?$0(e):St=t,Qp.current=null}function $0(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=GT(s,t),s!==null){s.flags&=32767,St=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Rt=6,St=null;return}}else if(s=KT(s,t,An),s!==null){St=s;return}if(t=t.sibling,t!==null){St=t;return}St=t=e}while(t!==null);Rt===0&&(Rt=5)}function ei(e,t,s){var r=Qe,i=Qn.transition;try{Qn.transition=null,Qe=1,tR(e,t,s,r)}finally{Qn.transition=i,Qe=r}return null}function tR(e,t,s,r){do da();while(pr!==null);if(We&6)throw Error(ee(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(ee(177));e.callbackNode=null,e.callbackPriority=0;var a=s.lanes|s.childLanes;if(DA(e,a),e===Ot&&(St=Ot=null,Bt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||Qo||(Qo=!0,O0(Xc,function(){return da(),null})),a=(s.flags&15990)!==0,s.subtreeFlags&15990||a){a=Qn.transition,Qn.transition=null;var l=Qe;Qe=1;var o=We;We|=4,Qp.current=null,qT(e,s),A0(s,e),wT(Ef),eu=!!Cf,Ef=Cf=null,e.current=s,QT(s),CA(),We=o,Qe=l,Qn.transition=a}else e.current=s;if(Qo&&(Qo=!1,pr=e,gu=i),a=e.pendingLanes,a===0&&(br=null),TA(s.stateNode),yn(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(pu)throw pu=!1,e=Gf,Gf=null,e;return gu&1&&e.tag!==0&&da(),a=e.pendingLanes,a&1?e===Yf?Nl++:(Nl=0,Yf=e):Nl=0,Ur(),null}function da(){if(pr!==null){var e=mb(gu),t=Qn.transition,s=Qe;try{if(Qn.transition=null,Qe=16>e?16:e,pr===null)var r=!1;else{if(e=pr,pr=null,gu=0,We&6)throw Error(ee(331));var i=We;for(We|=4,pe=e.current;pe!==null;){var a=pe,l=a.child;if(pe.flags&16){var o=a.deletions;if(o!==null){for(var c=0;c<o.length;c++){var u=o[c];for(pe=u;pe!==null;){var f=pe;switch(f.tag){case 0:case 11:case 15:kl(8,f,a)}var d=f.child;if(d!==null)d.return=f,pe=d;else for(;pe!==null;){f=pe;var m=f.sibling,p=f.return;if(N0(f),f===u){pe=null;break}if(m!==null){m.return=p,pe=m;break}pe=p}}}var j=a.alternate;if(j!==null){var w=j.child;if(w!==null){j.child=null;do{var k=w.sibling;w.sibling=null,w=k}while(w!==null)}}pe=a}}if(a.subtreeFlags&2064&&l!==null)l.return=a,pe=l;else e:for(;pe!==null;){if(a=pe,a.flags&2048)switch(a.tag){case 0:case 11:case 15:kl(9,a,a.return)}var g=a.sibling;if(g!==null){g.return=a.return,pe=g;break e}pe=a.return}}var x=e.current;for(pe=x;pe!==null;){l=pe;var y=l.child;if(l.subtreeFlags&2064&&y!==null)y.return=l,pe=y;else e:for(l=x;pe!==null;){if(o=pe,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:Yu(9,o)}}catch(N){vt(o,o.return,N)}if(o===l){pe=null;break e}var v=o.sibling;if(v!==null){v.return=o.return,pe=v;break e}pe=o.return}}if(We=i,Ur(),Es&&typeof Es.onPostCommitFiberRoot=="function")try{Es.onPostCommitFiberRoot(Uu,e)}catch{}r=!0}return r}finally{Qe=s,Qn.transition=t}}return!1}function mj(e,t,s){t=ba(s,t),t=m0(e,t,1),e=wr(e,t,1),t=cn(),e!==null&&(mo(e,1,t),yn(e,t))}function vt(e,t,s){if(e.tag===3)mj(e,e,s);else for(;t!==null;){if(t.tag===3){mj(t,e,s);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(br===null||!br.has(r))){e=ba(s,e),e=p0(t,e,1),t=wr(t,e,1),e=cn(),t!==null&&(mo(t,1,e),yn(t,e));break}}t=t.return}}function nR(e,t,s){var r=e.pingCache;r!==null&&r.delete(t),t=cn(),e.pingedLanes|=e.suspendedLanes&s,Ot===e&&(Bt&s)===s&&(Rt===4||Rt===3&&(Bt&130023424)===Bt&&500>bt()-Xp?li(e,0):Jp|=s),yn(e,t)}function D0(e,t){t===0&&(e.mode&1?(t=Uo,Uo<<=1,!(Uo&130023424)&&(Uo=4194304)):t=1);var s=cn();e=Js(e,t),e!==null&&(mo(e,t,s),yn(e,s))}function sR(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),D0(e,s)}function rR(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(ee(314))}r!==null&&r.delete(t),D0(e,s)}var _0;_0=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||vn.current)gn=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return gn=!1,VT(e,t,s);gn=!!(e.flags&131072)}else gn=!1,lt&&t.flags&1048576&&Ub(t,lu,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Mc(e,t),e=t.pendingProps;var i=va(t,en.current);ua(t,s),i=Vp(null,t,r,e,i,s);var a=Kp();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,jn(r)?(a=!0,iu(t)):a=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Up(t),i.updater=Gu,t.stateNode=i,i._reactInternals=t,_f(t,r,e,s),t=Ff(null,t,r,!0,a,s)):(t.tag=0,lt&&a&&Mp(t),an(null,t,i,s),t=t.child),t;case 16:r=t.elementType;e:{switch(Mc(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=aR(r),e=ts(r,e),i){case 0:t=Lf(null,t,r,e,s);break e;case 1:t=rj(null,t,r,e,s);break e;case 11:t=nj(null,t,r,e,s);break e;case 14:t=sj(null,t,r,ts(r.type,e),s);break e}throw Error(ee(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ts(r,i),Lf(e,t,r,i,s);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ts(r,i),rj(e,t,r,i,s);case 3:e:{if(j0(t),e===null)throw Error(ee(387));r=t.pendingProps,a=t.memoizedState,i=a.element,Kb(e,t),uu(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=ba(Error(ee(423)),t),t=ij(e,t,r,s,i);break e}else if(r!==i){i=ba(Error(ee(424)),t),t=ij(e,t,r,s,i);break e}else for(Rn=yr(t.stateNode.containerInfo.firstChild),Pn=t,lt=!0,ss=null,s=Hb(t,null,r,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(ja(),r===i){t=Xs(e,t,s);break e}an(e,t,r,s)}t=t.child}return t;case 5:return Gb(t),e===null&&Mf(t),r=t.type,i=t.pendingProps,a=e!==null?e.memoizedProps:null,l=i.children,Af(r,i)?l=null:a!==null&&Af(r,a)&&(t.flags|=32),v0(e,t),an(e,t,l,s),t.child;case 6:return e===null&&Mf(t),null;case 13:return y0(e,t,s);case 4:return Bp(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ya(t,null,r,s):an(e,t,r,s),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ts(r,i),nj(e,t,r,i,s);case 7:return an(e,t,t.pendingProps,s),t.child;case 8:return an(e,t,t.pendingProps.children,s),t.child;case 12:return an(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,Xe(ou,r._currentValue),r._currentValue=l,a!==null)if(us(a.value,l)){if(a.children===i.children&&!vn.current){t=Xs(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),$f(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(ee(341));l.lanes|=s,o=l.alternate,o!==null&&(o.lanes|=s),$f(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}an(e,t,i.children,s),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,ua(t,s),i=Jn(i),r=r(i),t.flags|=1,an(e,t,r,s),t.child;case 14:return r=t.type,i=ts(r,t.pendingProps),i=ts(r.type,i),sj(e,t,r,i,s);case 15:return g0(e,t,t.type,t.pendingProps,s);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ts(r,i),Mc(e,t),t.tag=1,jn(r)?(e=!0,iu(t)):e=!1,ua(t,s),f0(t,r,i),_f(t,r,i,s),Ff(null,t,r,!0,e,s);case 19:return w0(e,t,s);case 22:return x0(e,t,s)}throw Error(ee(156,t.tag))};function O0(e,t){return ub(e,t)}function iR(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 iR(e,t,s,r)}function ng(e){return e=e.prototype,!(!e||!e.isReactComponent)}function aR(e){if(typeof e=="function")return ng(e)?1:0;if(e!=null){if(e=e.$$typeof,e===wp)return 11;if(e===bp)return 14}return 2}function Sr(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 _c(e,t,s,r,i,a){var l=2;if(r=e,typeof e=="function")ng(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Gi:return oi(s.children,i,a,t);case yp:l=8,i|=8;break;case af:return e=qn(12,s,t,i|2),e.elementType=af,e.lanes=a,e;case lf:return e=qn(13,s,t,i),e.elementType=lf,e.lanes=a,e;case of:return e=qn(19,s,t,i),e.elementType=of,e.lanes=a,e;case Gw:return Qu(s,i,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Vw:l=10;break e;case Kw:l=9;break e;case wp:l=11;break e;case bp:l=14;break e;case ur:l=16,r=null;break e}throw Error(ee(130,e==null?e:typeof e,""))}return t=qn(l,s,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function oi(e,t,s,r){return e=qn(7,e,r,t),e.lanes=s,e}function Qu(e,t,s,r){return e=qn(22,e,r,t),e.elementType=Gw,e.lanes=s,e.stateNode={isHidden:!1},e}function uh(e,t,s){return e=qn(6,e,null,t),e.lanes=s,e}function dh(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 lR(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=Vd(0),this.expirationTimes=Vd(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vd(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function sg(e,t,s,r,i,a,l,o,c){return e=new lR(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},Up(a),e}function oR(e,t,s){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ki,key:r==null?null:""+r,children:e,containerInfo:t,implementation:s}}function L0(e){if(!e)return Ir;e=e._reactInternals;e:{if(ki(e)!==e||e.tag!==1)throw Error(ee(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(jn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(ee(171))}if(e.tag===1){var s=e.type;if(jn(s))return Lb(e,s,t)}return t}function F0(e,t,s,r,i,a,l,o,c){return e=sg(s,r,!0,e,i,a,l,o,c),e.context=L0(null),s=e.current,r=cn(),i=kr(s),a=Vs(r,i),a.callback=t??null,wr(s,a,i),e.current.lanes=i,mo(e,i,r),yn(e,r),e}function Ju(e,t,s,r){var i=t.current,a=cn(),l=kr(i);return s=L0(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=wr(i,t,l),e!==null&&(as(e,i,l,a),Rc(e,i,l)),l}function vu(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 pj(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function rg(e,t){pj(e,t),(e=e.alternate)&&pj(e,t)}function cR(){return null}var U0=typeof reportError=="function"?reportError:function(e){console.error(e)};function ig(e){this._internalRoot=e}Xu.prototype.render=ig.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(ee(409));Ju(e,t,null,null)};Xu.prototype.unmount=ig.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;pi(function(){Ju(null,e,null,null)}),t[Qs]=null}};function Xu(e){this._internalRoot=e}Xu.prototype.unstable_scheduleHydration=function(e){if(e){var t=xb();e={blockedOn:null,target:e,priority:t};for(var s=0;s<hr.length&&t!==0&&t<hr[s].priority;s++);hr.splice(s,0,e),s===0&&jb(e)}};function ag(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Zu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function gj(){}function uR(e,t,s,r,i){if(i){if(typeof r=="function"){var a=r;r=function(){var u=vu(l);a.call(u)}}var l=F0(t,r,e,0,null,!1,!1,"",gj);return e._reactRootContainer=l,e[Qs]=l.current,Fl(e.nodeType===8?e.parentNode:e),pi(),l}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var o=r;r=function(){var u=vu(c);o.call(u)}}var c=sg(e,0,!1,null,null,!1,!1,"",gj);return e._reactRootContainer=c,e[Qs]=c.current,Fl(e.nodeType===8?e.parentNode:e),pi(function(){Ju(t,c,s,r)}),c}function ed(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=vu(l);o.call(c)}}Ju(t,l,e,i)}else l=uR(s,t,e,i,r);return vu(l)}pb=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=fl(t.pendingLanes);s!==0&&(Np(t,s|1),yn(t,bt()),!(We&6)&&(ka=bt()+500,Ur()))}break;case 13:pi(function(){var r=Js(e,1);if(r!==null){var i=cn();as(r,e,1,i)}}),rg(e,1)}};Cp=function(e){if(e.tag===13){var t=Js(e,134217728);if(t!==null){var s=cn();as(t,e,134217728,s)}rg(e,134217728)}};gb=function(e){if(e.tag===13){var t=kr(e),s=Js(e,t);if(s!==null){var r=cn();as(s,e,t,r)}rg(e,t)}};xb=function(){return Qe};vb=function(e,t){var s=Qe;try{return Qe=e,t()}finally{Qe=s}};vf=function(e,t,s){switch(t){case"input":if(df(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=Hu(r);if(!i)throw Error(ee(90));qw(r),df(r,i)}}}break;case"textarea":Jw(e,s);break;case"select":t=s.value,t!=null&&aa(e,!!s.multiple,t,!1)}};rb=Zp;ib=pi;var dR={usingClientEntryPoint:!1,Events:[go,Ji,Hu,nb,sb,Zp]},il={findFiberByHostInstance:si,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},hR={bundleType:il.bundleType,version:il.version,rendererPackageName:il.rendererPackageName,rendererConfig:il.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:rr.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ob(e),e===null?null:e.stateNode},findFiberByHostInstance:il.findFiberByHostInstance||cR,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 Jo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jo.isDisabled&&Jo.supportsFiber)try{Uu=Jo.inject(hR),Es=Jo}catch{}}_n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dR;_n.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ag(t))throw Error(ee(200));return oR(e,t,null,s)};_n.createRoot=function(e,t){if(!ag(e))throw Error(ee(299));var s=!1,r="",i=U0;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=sg(e,1,!1,null,null,s,!1,r,i),e[Qs]=t.current,Fl(e.nodeType===8?e.parentNode:e),new ig(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(ee(188)):(e=Object.keys(e).join(","),Error(ee(268,e)));return e=ob(t),e=e===null?null:e.stateNode,e};_n.flushSync=function(e){return pi(e)};_n.hydrate=function(e,t,s){if(!Zu(t))throw Error(ee(200));return ed(null,e,t,!0,s)};_n.hydrateRoot=function(e,t,s){if(!ag(e))throw Error(ee(405));var r=s!=null&&s.hydratedSources||null,i=!1,a="",l=U0;if(s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(l=s.onRecoverableError)),t=F0(t,null,e,1,s??null,i,!1,a,l),e[Qs]=t.current,Fl(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 Xu(t)};_n.render=function(e,t,s){if(!Zu(t))throw Error(ee(200));return ed(null,e,t,!1,s)};_n.unmountComponentAtNode=function(e){if(!Zu(e))throw Error(ee(40));return e._reactRootContainer?(pi(function(){ed(null,null,e,!1,function(){e._reactRootContainer=null,e[Qs]=null})}),!0):!1};_n.unstable_batchedUpdates=Zp;_n.unstable_renderSubtreeIntoContainer=function(e,t,s,r){if(!Zu(s))throw Error(ee(200));if(e==null||e._reactInternals===void 0)throw Error(ee(38));return ed(e,t,s,!1,r)};_n.version="18.3.1-next-f1338f8080-20240426";function B0(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(B0)}catch(e){console.error(e)}}B0(),Bw.exports=_n;var Sa=Bw.exports,z0,xj=Sa;z0=xj.createRoot,xj.hydrateRoot;var fR=Object.defineProperty,La=(e,t)=>fR(e,"name",{value:t,configurable:!0}),W0=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ee(e,t,{checkForDefaultPrevented:s=!0}={}){return La(function(i){if(e==null||e(i),s===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}La(Ee,"composeEventHandlers");function mR(e){var t;if(!W0)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}La(mR,"getOwnerWindow");function Jf(e){if(!W0)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}La(Jf,"getOwnerDocument");function H0(e,t=!1){const{activeElement:s}=Jf(e);if(!(s!=null&&s.nodeName))return null;if(V0(s)&&s.contentDocument)return H0(s.contentDocument.body,t);if(t){const r=s.getAttribute("aria-activedescendant");if(r){const i=Jf(s).getElementById(r);if(i)return i}}return s}La(H0,"getActiveElement");function V0(e){return e.tagName==="IFRAME"}La(V0,"isFrame");var pR=Object.defineProperty,lg=(e,t)=>pR(e,"name",{value:t,configurable:!0});function Xf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}lg(Xf,"setRef");function K0(...e){return t=>{let s=!1;const r=e.map(i=>{const a=Xf(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():Xf(e[i],null)}}}}lg(K0,"composeRefs");function rt(...e){return h.useCallback(K0(...e),e)}lg(rt,"useComposedRefs");var gR=Object.defineProperty,Yn=(e,t)=>gR(e,"name",{value:t,configurable:!0});function xR(e,t){const s=h.createContext(t);s.displayName=e+"Context";const r=Yn(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 Yn(i,"useContext"),[r,i]}Yn(xR,"createContext");function hs(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=Yn(d=>{var g;const{scope:m,children:p,...j}=d,w=((g=m==null?void 0:m[e])==null?void 0:g[c])||o,k=h.useMemo(()=>j,Object.values(j));return n.jsx(w.Provider,{value:k,children:p})},"Provider");u.displayName=a+"Provider";function f(d,m,p={}){var g;const{optional:j=!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(!j)throw new Error(`\`${d}\` must be used within \`${a}\``)}return Yn(f,"useContext"),[u,f]}Yn(r,"createContext");const i=Yn(()=>{const a=s.map(l=>h.createContext(l));return Yn(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,G0(i,...t)]}Yn(hs,"createContextScope");function G0(...e){const t=e[0];if(e.length===1)return t;const s=Yn(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Yn(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}Yn(G0,"composeContextScopes");var vR=Object.defineProperty,fs=(e,t)=>vR(e,"name",{value:t,configurable:!0});function Pr(e){const t=h.forwardRef((s,r)=>{let{children:i,...a}=s,l=null,o=!1;const c=[];Zf(i)&&typeof Xo=="function"&&(i=Xo(i._payload)),h.Children.forEach(i,m=>{var p;if(X0(m)){o=!0;const j=m;let w="child"in j.props?j.props.child:j.props.children;Zf(w)&&typeof Xo=="function"&&(w=Xo(w._payload)),l=jR(j,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?J0(l):void 0,f=rt(r,u);if(!l){if(i||i===0)throw new Error(o?bR(e):wR(e));return i}const d=Q0(a,l.props??{});return l.type!==h.Fragment&&(d.ref=r?f:u),h.cloneElement(l,d)});return t.displayName=`${e}.Slot`,t}fs(Pr,"createSlot");var Y0=Symbol.for("radix.slottable");function q0(e){const t=fs(s=>"child"in s?s.children(s.child):s.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Y0,t}fs(q0,"createSlottable");var jR=fs((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 Q0(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}}fs(Q0,"mergeProps");function J0(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)}fs(J0,"getElementRef");function X0(e){return h.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Y0}fs(X0,"isSlottable");var yR=Symbol.for("react.lazy");function Zf(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===yR&&"_payload"in e&&Z0(e._payload)}fs(Zf,"isLazyComponent");function Z0(e){return typeof e=="object"&&e!==null&&"then"in e}fs(Z0,"isPromiseLike");var wR=fs(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),bR=fs(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Xo=Da[" use ".trim().toString()],kR=Object.defineProperty,Dt=(e,t)=>kR(e,"name",{value:t,configurable:!0});function td(e){const t=e+"CollectionProvider",[s,r]=hs(t),[i,a]=s(t,{collectionRef:{current:null},itemMap:new Map}),l=Dt(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=Pr(o),u=h.forwardRef((w,k)=>{const{scope:g,children:x}=w,y=a(o,g),v=rt(k,y.collectionRef);return n.jsx(c,{ref:v,children:x})});u.displayName=o;const f=e+"CollectionItemSlot",d="data-radix-collection-item",m=Pr(f),p=h.forwardRef((w,k)=>{const{scope:g,children:x,...y}=w,v=h.useRef(null),N=rt(k,v),b=a(f,g);return h.useEffect(()=>(b.itemMap.set(v,{ref:v,...y}),()=>void b.itemMap.delete(v))),n.jsx(m,{[d]:"",ref:N,children:x})});p.displayName=f;function j(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 Dt(j,"useCollection"),[{Provider:l,Slot:u,ItemSlot:p},j,r]}Dt(td,"createCollection");var vj=new WeakMap,kt,Tn,hh=(Tn=class extends Map{constructor(s){super(s);ov(this,kt);Fd(this,kt,[...super.keys()]),vj.set(this,!0)}set(s,r){return vj.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=og(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 j=c;j<f;j++)if(c===j){let w=d[j];d[j]===r&&(w=d[j+1]),a&&this.delete(r),m=this.get(w),this.set(r,i)}else{!p&&d[j-1]===r&&(p=!0);const w=d[p?j:j-1],k=m;m=this.get(w),this.delete(w),this.set(w,k)}return this}with(s,r,i){const a=new Tn(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 Fd(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=Oc(qt(this,kt),s);if(r!==void 0)return this.get(r)}entryAt(s){const r=Oc(qt(this,kt),s);if(r!==void 0)return[r,this.get(r)]}indexOf(s){return qt(this,kt).indexOf(s)}keyAt(s){return Oc(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 Tn(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 Tn(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 Tn(r)}toReversed(){const s=new Tn;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 Tn(r)}slice(s,r){const i=new Tn;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,Dt(Tn,"OrderedDict"),Tn);function Oc(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const s=ek(e,t);return s===-1?void 0:e[s]}Dt(Oc,"at");function ek(e,t){const s=e.length,r=og(t),i=r>=0?r:s+r;return i<0||i>=s?-1:i}Dt(ek,"toSafeIndex");function og(e){return e!==e||e===0?0:Math.trunc(e)}Dt(og,"toSafeInteger");function SR(e){const t=e+"CollectionProvider",[s,r]=hs(t),[i,a]=s(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new hh,setItemMap:Dt(()=>{},"setItemMap")}),l=Dt(({state:y,...v})=>y?n.jsx(c,{...v,state:y}):n.jsx(o,{...v}),"CollectionProvider");l.displayName=t;const o=Dt(y=>{const v=k();return n.jsx(c,{...y,state:v})},"CollectionInit");o.displayName=t+"Init";const c=Dt(y=>{const{scope:v,children:N,state:b}=y,S=h.useRef(null),[C,R]=h.useState(null),E=rt(S,R),[P,L]=b;return h.useEffect(()=>{if(!C)return;const $=sk(()=>{});return $.observe(C,{childList:!0,subtree:!0}),()=>{$.disconnect()}},[C]),n.jsx(i,{scope:v,itemMap:P,setItemMap:L,collectionRef:E,collectionRefObject:S,collectionElement:C,children:N})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",f=Pr(u),d=h.forwardRef((y,v)=>{const{scope:N,children:b}=y,S=a(u,N),C=rt(v,S.collectionRef);return n.jsx(f,{ref:C,children:b})});d.displayName=u;const m=e+"CollectionItemSlot",p="data-radix-collection-item",j=Pr(m),w=h.forwardRef((y,v)=>{const{scope:N,children:b,...S}=y,C=h.useRef(null),[R,E]=h.useState(null),P=rt(v,C,E),L=a(m,N),{setItemMap:$}=L,T=h.useRef(S);tk(T.current,S)||(T.current=S);const M=T.current;return h.useEffect(()=>{const U=M;return $(K=>R?K.has(R)?K.set(R,{...U,element:R}).toSorted(em):(K.set(R,{...U,element:R}),K.toSorted(em)):K),()=>{$(K=>!R||!K.has(R)?K:(K.delete(R),new hh(K)))}},[R,M,$]),n.jsx(j,{[p]:"",ref:P,children:b})});w.displayName=m;function k(){return h.useState(new hh)}Dt(k,"useInitCollection");function g(y){const{itemMap:v}=a(e+"CollectionConsumer",y);return v}return Dt(g,"useCollection"),[{Provider:l,Slot:d,ItemSlot:w},{createCollectionScope:r,useCollection:g,useInitCollection:k}]}Dt(SR,"createCollection");function tk(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}Dt(tk,"shallowEqual");function nk(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Dt(nk,"isElementPreceding");function em(e,t){return!e[1].element||!t[1].element?0:nk(e[1].element,t[1].element)?-1:1}Dt(em,"sortByDocumentPosition");function sk(e){return new MutationObserver(s=>{for(const r of s)if(r.type==="childList"){e();return}})}Dt(sk,"getChildListObserver");var NR=Object.defineProperty,CR=(e,t)=>NR(e,"name",{value:t,configurable:!0}),ER=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mt=ER.reduce((e,t)=>{const s=Pr(`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 nd(e,t){e&&Sa.flushSync(()=>e.dispatchEvent(t))}CR(nd,"dispatchDiscreteCustomEvent");var AR=Object.defineProperty,TR=(e,t)=>AR(e,"name",{value:t,configurable:!0});function Zn(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)},[])}TR(Zn,"useCallbackRef");var RR=Object.defineProperty,At=(e,t)=>RR(e,"name",{value:t,configurable:!0}),tm="dismissableLayer.update",IR="dismissableLayer.pointerDownOutside",PR="dismissableLayer.focusOutside",jj,cg=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),ug=h.forwardRef(At(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(cg),[m,p]=h.useState(null),j=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=h.useState({}),k=rt(s,p),g=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=x?g.indexOf(x):-1,v=m?g.indexOf(m):-1,N=d.layersWithOutsidePointerEventsDisabled.size>0,b=v>=y,S=h.useRef(!1),C=ik(L=>{l==null||l(L),c==null||c(L),L.defaultPrevented||u==null||u()},{ownerDocument:j,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(L=>{if(!(L instanceof Node))return!1;const $=[...d.branches].some(T=>T.contains(L));return b&&!$},[d.branches,b])}),R=ak(L=>{if(i&&S.current)return;const $=L.target;[...d.branches].some(M=>M.contains($))||(o==null||o(L),c==null||c(L),L.defaultPrevented||u==null||u())},j),E=m?v===g.length-1:!1,P=Zn(L=>{L.key==="Escape"&&(a==null||a(L),!L.defaultPrevented&&u&&(L.preventDefault(),u()))});return h.useEffect(()=>{if(E)return j.addEventListener("keydown",P,{capture:!0}),()=>j.removeEventListener("keydown",P,{capture:!0})},[j,E,P]),h.useEffect(()=>{if(m)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(jj=j.body.style.pointerEvents,j.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),nm(),()=>{r&&(d.layersWithOutsidePointerEventsDisabled.delete(m),d.layersWithOutsidePointerEventsDisabled.size===0&&(j.body.style.pointerEvents=jj))}},[m,j,r,d]),h.useEffect(()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),nm())},[m,d]),h.useEffect(()=>{const L=At(()=>w({}),"handleUpdate");return document.addEventListener(tm,L),()=>document.removeEventListener(tm,L)},[]),n.jsx(mt.div,{...f,ref:k,style:{pointerEvents:N?b?"auto":"none":void 0,...t.style},onFocusCapture:Ee(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Ee(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Ee(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),MR=h.forwardRef(At(function(t,s){const r=h.useContext(cg),i=h.useRef(null),a=rt(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 rk(){const e=h.useContext(cg),[t,s]=h.useState(null);return h.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}At(rk,"useDismissableLayerSurface");var $R=At(()=>!0,"IS_TRUE");function ik(e,t){const{ownerDocument:s=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:l=$R}=t,o=Zn(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()}At(m,"resetOutsideInteraction");function p(){return Array.from(f.current.values()).some(Boolean)}At(p,"isOutsideInteractionIntercepted");function j(y){if(!u.current)return;const v=y.target;v instanceof Node&&[...a].some(b=>b.contains(v))||f.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{u.current&&d.current()},0)}At(j,"handleInteractionCapture");function w(y){u.current&&f.current.set(y.type,!1)}At(w,"handleInteractionBubble");const k=At(y=>{if(y.target&&!c.current){let v=function(){s.removeEventListener("click",d.current);const b=p();m(),b||dg(IR,o,N,{discrete:!0})};if(At(v,"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?v():(s.removeEventListener("click",d.current),d.current=v,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,j,!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,j,!0),s.removeEventListener(y,w)}},[s,o,r,i,a,l]),{onPointerDownCapture:At(()=>c.current=!0,"onPointerDownCapture")}}At(ik,"usePointerDownOutside");function ak(e,t=globalThis==null?void 0:globalThis.document){const s=Zn(e),r=h.useRef(!1);return h.useEffect(()=>{const i=At(a=>{a.target&&!r.current&&dg(PR,s,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,s]),{onFocusCapture:At(()=>r.current=!0,"onFocusCapture"),onBlurCapture:At(()=>r.current=!1,"onBlurCapture")}}At(ak,"useFocusOutside");function nm(){const e=new CustomEvent(tm);document.dispatchEvent(e)}At(nm,"dispatchUpdate");function dg(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?nd(i,a):i.dispatchEvent(a)}At(dg,"handleAndDispatchCustomEvent");var DR=MR,wn=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},_R=Object.defineProperty,OR=(e,t)=>_R(e,"name",{value:t,configurable:!0}),hg=h.forwardRef(OR(function(t,s){var c;const{container:r,...i}=t,[a,l]=h.useState(!1);wn(()=>l(!0),[]);const o=r||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Sa.createPortal(n.jsx(mt.div,{...i,ref:s}),o):null},"Portal")),LR=Object.defineProperty,Zs=(e,t)=>LR(e,"name",{value:t,configurable:!0});function lk(e,t){return h.useReducer((s,r)=>t[s][r]??s,e)}Zs(lk,"useStateMachine");var ir=Zs(e=>{const{present:t,children:s}=e,r=ok(t),i=typeof s=="function"?s({present:r.isPresent}):h.Children.only(s),a=ck(r.ref,uk(i));return typeof s=="function"||r.isPresent?h.cloneElement(i,{ref:a}):null},"Presence");function ok(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]=lk(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??Hi(r.current),l.current=void 0):a.current="none"},[c]),wn(()=>{const f=r.current,d=i.current;if(d!==e){const p=a.current,j=Hi(f);e?(l.current=j,u("MOUNT")):j==="none"||(f==null?void 0:f.display)==="none"?u("UNMOUNT"):u(d&&p!==j?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),wn(()=>{if(t){let f;const d=t.ownerDocument.defaultView??window,m=Zs(j=>{const k=Hi(r.current).includes(CSS.escape(j.animationName));if(j.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=Zs(j=>{j.target===t&&(a.current=Hi(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=Hi(d)}else r.current=null;s(f)},[])}}Zs(ok,"usePresence");function sm(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Zs(sm,"setRef");function ck(...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=sm(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():sm(r[l],null)}}},[])}Zs(ck,"useStableComposedRefs");function Hi(e){return(e==null?void 0:e.animationName)||"none"}Zs(Hi,"getAnimationName");function uk(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)}Zs(uk,"getElementRef");var FR=Object.defineProperty,UR=(e,t)=>FR(e,"name",{value:t,configurable:!0}),yj=Da[" useEffectEvent ".trim().toString()],wj=Da[" useInsertionEffect ".trim().toString()];function dk(e){if(typeof yj=="function")return yj(e);const t=h.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof wj=="function"?wj(()=>{t.current=e}):wn(()=>{t.current=e}),h.useMemo(()=>(...s)=>{var r;return(r=t.current)==null?void 0:r.call(t,...s)},[])}UR(dk,"useEffectEvent");var BR=Object.defineProperty,vo=(e,t)=>BR(e,"name",{value:t,configurable:!0}),zR=Da[" useInsertionEffect ".trim().toString()]||wn;function Si({prop:e,defaultProp:t,onChange:s=vo(()=>{},"onChange"),caller:r}){const[i,a,l]=hk({defaultProp:t,onChange:s}),o=e!==void 0,c=o?e:i,u=h.useCallback(f=>{var d;if(o){const m=fk(f)?f(e):f;m!==e&&((d=l.current)==null||d.call(l,m))}else a(f)},[o,e,a,l]);return[c,u]}vo(Si,"useControllableState");function hk({defaultProp:e,onChange:t}){const[s,r]=h.useState(e),i=h.useRef(s),a=h.useRef(t);return zR(()=>{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]}vo(hk,"useUncontrolledState");function fk(e){return typeof e=="function"}vo(fk,"isFunction");var bj=Symbol("RADIX:SYNC_STATE");function WR(e,t,s,r){const{prop:i,defaultProp:a,onChange:l,caller:o}=t,c=i!==void 0,u=dk(l),f=[{...s,state:a}];r&&f.push(r);const[d,m]=h.useReducer((k,g)=>{if(g.type===bj)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,j=h.useRef(p);h.useEffect(()=>{j.current!==p&&(j.current=p,c||u(p))},[p,j,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:bj,state:i})},[i,d.state,c]),[w,m]}vo(WR,"useControllableStateReducer");var HR=Object.defineProperty,VR=(e,t)=>HR(e,"name",{value:t,configurable:!0}),KR=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"}),mk=h.forwardRef(VR(function(t,s){return n.jsx(mt.span,{...t,ref:s,style:{...KR,...t.style}})},"VisuallyHidden")),GR=mk,YR=Object.defineProperty,Xt=(e,t)=>YR(e,"name",{value:t,configurable:!0}),pk="ToastProvider",[gk,qR,QR]=td("Toast"),[xk,FW]=hs("Toast",[QR]),[JR,vk]=xk(pk),XR=Xt(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 \`${pk}\`. Expected non-empty \`string\`.`),n.jsx(gk.Provider,{scope:t,children:n.jsx(JR,{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"),ZR="ToastViewport",e2=["F8"],t2="toast.viewportPause",n2="toast.viewportResume",s2=h.forwardRef(Xt(function(t,s){const{__scopeToast:r,hotkey:i=e2,label:a="Notifications ({hotkey})",...l}=t,o=vk(ZR,r),c=qR(r),u=h.useRef(null),f=h.useRef(null),d=h.useRef(null),m=h.useRef(null),p=rt(s,m,o.onViewportChange),j=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=o.toastCount>0;h.useEffect(()=>{const g=Xt(x=>{var v;i.length!==0&&i.every(N=>x[N]||x.code===N)&&((v=m.current)==null||v.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=Xt(()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(t2);x.dispatchEvent(S),o.isClosePausedRef.current=!0}},"handlePause"),v=Xt(()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(n2);x.dispatchEvent(S),o.isClosePausedRef.current=!1}},"handleResume"),N=Xt(S=>{!g.contains(S.relatedTarget)&&v()},"handleFocusOutResume"),b=Xt(()=>{g.contains(document.activeElement)||v()},"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",v),()=>{g.removeEventListener("focusin",y),g.removeEventListener("focusout",N),g.removeEventListener("pointermove",y),g.removeEventListener("pointerleave",b),window.removeEventListener("blur",y),window.removeEventListener("focus",v)}}},[w,o.isClosePausedRef]);const k=h.useCallback(({tabbingDirection:g})=>{const y=c().map(v=>{const N=v.ref.current,b=[N,...wk(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=Xt(y=>{var b,S,C;const v=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!v){const R=document.activeElement,E=y.shiftKey;if(y.target===g&&E){(b=f.current)==null||b.focus();return}const $=k({tabbingDirection:E?"backwards":"forwards"}),T=$.findIndex(M=>M===R);Lc($.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(DR,{ref:u,role:"region","aria-label":a.replace("{hotkey}",j),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&n.jsx(kj,{ref:f,onFocusFromOutsideViewport:()=>{const g=k({tabbingDirection:"forwards"});Lc(g)}}),n.jsx(gk.Slot,{scope:r,children:n.jsx(mt.ol,{tabIndex:-1,...l,ref:p})}),w&&n.jsx(kj,{ref:d,onFocusFromOutsideViewport:()=>{const g=k({tabbingDirection:"backwards"});Lc(g)}})]})},"ToastViewport")),r2="ToastFocusProxy",kj=h.forwardRef(Xt(function(t,s){const{__scopeToast:r,onFocusFromOutsideViewport:i,...a}=t,l=vk(r2,r);return n.jsx(mk,{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")),i2="Toast",[UW,BW]=xk(i2,{onClose(){}});function jk(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),yk(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(...jk(r))}}),t}Xt(jk,"getAnnounceTextContent");function a2(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?nd(i,a):i.dispatchEvent(a)}Xt(a2,"handleAndDispatchCustomEvent");function l2(e=()=>{}){const t=Zn(e);wn(()=>{let s=0,r=0;return s=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(r)}},[t])}Xt(l2,"useNextFrame");function yk(e){return e.nodeType===e.ELEMENT_NODE}Xt(yk,"isHTMLElement");function wk(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Xt(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}Xt(wk,"getTabbableCandidates");function Lc(e){const t=document.activeElement;return e.some(s=>s===t?!0:(s.focus(),document.activeElement!==t))}Xt(Lc,"focusFirst");var Sj=XR,Nj=s2,o2=Object.defineProperty,c2=(e,t)=>o2(e,"name",{value:t,configurable:!0}),u2=Da[" useId ".trim().toString()]||(()=>{}),d2=0;function ls(e){const[t,s]=h.useState(u2());return wn(()=>{e||s(r=>r??String(d2++))},[e]),e||(t?`radix-${t}`:"")}c2(ls,"useId");const h2=["top","right","bottom","left"],Mr=Math.min,Ks=Math.max,ju=Math.round,Zo=Math.floor,Gs=e=>({x:e,y:e}),f2={left:"right",right:"left",bottom:"top",top:"bottom"};function bk(e,t,s){return Ks(e,Mr(t,s))}function er(e,t){return typeof e=="function"?e(t):e}function $r(e){return e.split("-")[0]}function Fa(e){return e.split("-")[1]}function fg(e){return e==="x"?"y":"x"}function mg(e){return e==="y"?"height":"width"}function Ns(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function pg(e){return fg(Ns(e))}function m2(e,t,s){s===void 0&&(s=!1);const r=Fa(e),i=pg(e),a=mg(i);let l=i==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=yu(l)),[l,yu(l)]}function p2(e){const t=yu(e);return[rm(e),t,rm(t)]}function rm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Cj=["left","right"],Ej=["right","left"],g2=["top","bottom"],x2=["bottom","top"];function v2(e,t,s){switch(e){case"top":case"bottom":return s?t?Ej:Cj:t?Cj:Ej;case"left":case"right":return t?g2:x2;default:return[]}}function j2(e,t,s,r){const i=Fa(e);let a=v2($r(e),s==="start",r);return i&&(a=a.map(l=>l+"-"+i),t&&(a=a.concat(a.map(rm)))),a}function yu(e){const t=$r(e);return f2[t]+e.slice(t.length)}function y2(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 kk(e){return typeof e!="number"?y2(e):{top:e,right:e,bottom:e,left:e}}function wu(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 Aj(e,t,s){let{reference:r,floating:i}=e;const a=Ns(t),l=pg(t),o=mg(l),c=$r(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 j=Fa(t);return j&&(p[l]+=m*(j==="end"?1:-1)*(s&&u?-1:1)),p}async function w2(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}=er(t,e),j=kk(p),k=o[m?d==="floating"?"reference":"floating":d],g=wu(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)),v=await(a.isElement==null?void 0:a.isElement(y))&&await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1},N=wu(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:x,offsetParent:y,strategy:c}):x);return{top:(g.top-N.top+j.top)/v.y,bottom:(N.bottom-g.bottom+j.bottom)/v.y,left:(g.left-N.left+j.left)/v.x,right:(N.right-g.right+j.right)/v.x}}const b2=50,k2=async(e,t,s)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:l}=s,o=l.detectOverflow?l:{...l,detectOverflow:w2},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}=Aj(u,r,c),m=r,p=0;const j={};for(let w=0;w<a.length;w++){const k=a[w];if(!k)continue;const{name:g,fn:x}=k,{x:y,y:v,data:N,reset:b}=await x({x:f,y:d,initialPlacement:r,placement:m,strategy:i,middlewareData:j,rects:u,platform:o,elements:{reference:e,floating:t}});f=y??f,d=v??d,j[g]={...j[g],...N},b&&p<b2&&(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}=Aj(u,m,c)),w=-1)}return{x:f,y:d,placement:m,strategy:i,middlewareData:j}},S2=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}=er(e,t)||{};if(u==null)return{};const d=kk(f),m={x:s,y:r},p=pg(i),j=mg(p),w=await l.getDimensions(u),k=p==="y",g=k?"top":"left",x=k?"bottom":"right",y=k?"clientHeight":"clientWidth",v=a.reference[j]+a.reference[p]-m[p]-a.floating[j],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[j]);const C=v/2-N/2,R=S/2-w[j]/2-1,E=Mr(d[g],R),P=Mr(d[x],R),L=S-w[j]-P,$=S/2-w[j]/2+C,T=bk(E,$,L),M=!c.arrow&&Fa(i)!=null&&$!==T&&a.reference[j]/2-($<E?E:P)-w[j]/2<0,U=M?$<E?$-E:$-L:0;return{[p]:m[p]+U,data:{[p]:T,centerOffset:$-T-U,...M&&{alignmentOffset:U}},reset:M}}}),N2=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:j="none",flipAlignment:w=!0,...k}=er(e,t);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const g=$r(i),x=Ns(o),y=$r(o)===o,v=await(c.isRTL==null?void 0:c.isRTL(u.floating)),N=m||(y||!w?[yu(o)]:p2(o)),b=j!=="none";!m&&b&&N.push(...j2(o,w,j,v));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=m2(i,l,v);R.push(C[T[0]],C[T[1]])}if(E=[...E,{placement:i,overflows:R}],!R.every(T=>T<=0)){var P,L;const T=(((P=a.flip)==null?void 0:P.index)||0)+1,M=S[T];if(M&&(!(d==="alignment"?x!==Ns(M):!1)||E.every(_=>Ns(_.placement)===x?_.overflows[0]>0:!0)))return{data:{index:T,overflows:E},reset:{placement:M}};let U=(L=E.filter(K=>K.overflows[0]<=0).sort((K,_)=>K.overflows[1]-_.overflows[1])[0])==null?void 0:L.placement;if(!U)switch(p){case"bestFit":{var $;const K=($=E.filter(_=>{if(b){const q=Ns(_.placement);return q===x||q==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(q=>q>0).reduce((q,B)=>q+B,0)]).sort((_,q)=>_[1]-q[1])[0])==null?void 0:$[0];K&&(U=K);break}case"initialPlacement":U=o;break}if(i!==U)return{reset:{placement:U}}}return{}}}};function Tj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Rj(e){return h2.some(t=>e[t]>=0)}const C2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:s,platform:r}=t,{strategy:i="referenceHidden",...a}=er(e,t);switch(i){case"referenceHidden":{const l=await r.detectOverflow(t,{...a,elementContext:"reference"}),o=Tj(l,s.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Rj(o)}}}case"escaped":{const l=await r.detectOverflow(t,{...a,altBoundary:!0}),o=Tj(l,s.floating);return{data:{escapedOffsets:o,escaped:Rj(o)}}}default:return{}}}}},Sk=new Set(["left","top"]);async function E2(e,t){const{placement:s,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),l=$r(s),o=Fa(s),c=Ns(s)==="y",u=Sk.has(l)?-1:1,f=a&&c?-1:1,d=er(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:j}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return o&&typeof j=="number"&&(p=o==="end"?j*-1:j),c?{x:p*f,y:m*u}:{x:m*u,y:p*f}}const A2=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 E2(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}}}}},T2=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:v}=x;return{x:y,y:v}}},...u}=er(e,t),f={x:s,y:r},d=await a.detectOverflow(t,u),m=Ns(i),p=fg(m);let j=f[p],w=f[m];const k=(x,y)=>bk(y+d[x==="y"?"top":"left"],y,y-d[x==="y"?"bottom":"right"]);l&&(j=k(p,j)),o&&(w=k(m,w));const g=c.fn({...t,[p]:j,[m]:w});return{...g,data:{x:g.x-s,y:g.y-r,enabled:{[p]:l,[m]:o}}}}}},R2=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}=er(e,t),m={x:i,y:a},p=Ns(l),j=fg(p);let w=m[j],k=m[p];const g=er(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=j==="y"?"height":"width",b=o.reference[j]-o.floating[N]+x.mainAxis,S=o.reference[j]+o.reference[N]-x.mainAxis;w<b?w=b:w>S&&(w=S)}if(d){var y,v;const N=j==="y"?"width":"height",b=Sk.has($r(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:((v=c.offset)==null?void 0:v[p])||0)-(b?x.crossAxis:0);k<S?k=S:k>C&&(k=C)}return{[j]:w,[p]:k}}}},I2=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}=er(e,t),c=await i.detectOverflow(t,o),u=$r(s),f=Fa(s),d=Ns(s)==="y",{width:m,height:p}=r.floating;let j,w;u==="top"||u==="bottom"?(j=u,w=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=u,j=f==="end"?"top":"bottom");const k=p-c.top-c.bottom,g=m-c.left-c.right,x=Mr(p-c[j],k),y=Mr(m-c[w],g),v=t.middlewareData.shift,N=!v;let b=x,S=y;v!=null&&v.enabled.x&&(S=g),v!=null&&v.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 sd(){return typeof window<"u"}function Ua(e){return Nk(e)?(e.nodeName||"").toLowerCase():"#document"}function bn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ar(e){var t;return(t=(Nk(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Nk(e){return sd()?e instanceof Node||e instanceof bn(e).Node:!1}function Rs(e){return sd()?e instanceof Element||e instanceof bn(e).Element:!1}function Br(e){return sd()?e instanceof HTMLElement||e instanceof bn(e).HTMLElement:!1}function Ij(e){return!sd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof bn(e).ShadowRoot}function rd(e){const{overflow:t,overflowX:s,overflowY:r,display:i}=Is(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+s)&&i!=="inline"&&i!=="contents"}function P2(e){return/^(table|td|th)$/.test(Ua(e))}function id(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const M2=/transform|translate|scale|rotate|perspective|filter/,$2=/paint|layout|strict|content/,qr=e=>!!e&&e!=="none";let fh;function gg(e){const t=Rs(e)?Is(e):e;return qr(t.transform)||qr(t.translate)||qr(t.scale)||qr(t.rotate)||qr(t.perspective)||!xg()&&(qr(t.backdropFilter)||qr(t.filter))||M2.test(t.willChange||"")||$2.test(t.contain||"")}function D2(e){let t=gi(e);for(;Br(t)&&!Yl(t);){if(gg(t))return t;if(id(t))return null;t=gi(t)}return null}function xg(){return fh==null&&(fh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),fh}function Yl(e){return/^(html|body|#document)$/.test(Ua(e))}function Is(e){return bn(e).getComputedStyle(e)}function ad(e){return Rs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function gi(e){if(Ua(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ij(e)&&e.host||ar(e);return Ij(t)?t.host:t}function Ck(e){const t=gi(e);return Yl(t)?(e.ownerDocument||e).body:Br(t)&&rd(t)?t:Ck(t)}function ql(e,t,s){var r;t===void 0&&(t=[]),s===void 0&&(s=!0);const i=Ck(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),l=bn(i);if(a){const o=im(l);return t.concat(l,l.visualViewport||[],rd(i)?i:[],o&&s?ql(o):[])}else return t.concat(i,ql(i,[],s))}function im(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ek(e){const t=Is(e);let s=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Br(e),a=i?e.offsetWidth:s,l=i?e.offsetHeight:r,o=ju(s)!==a||ju(r)!==l;return o&&(s=a,r=l),{width:s,height:r,$:o}}function vg(e){return Rs(e)?e:e.contextElement}function ha(e){const t=vg(e);if(!Br(t))return Gs(1);const s=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ek(t);let l=(a?ju(s.width):s.width)/r,o=(a?ju(s.height):s.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!o||!Number.isFinite(o))&&(o=1),{x:l,y:o}}const _2=Gs(0);function Ak(e){const t=bn(e);return!xg()||!t.visualViewport?_2:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function O2(e,t,s){return t===void 0&&(t=!1),!!s&&t&&s===bn(e)}function xi(e,t,s,r){t===void 0&&(t=!1),s===void 0&&(s=!1);const i=e.getBoundingClientRect(),a=vg(e);let l=Gs(1);t&&(r?Rs(r)&&(l=ha(r)):l=ha(e));const o=O2(a,s,r)?Ak(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=bn(a),p=Rs(r)?bn(r):r;let j=m,w=im(j);for(;w&&p!==j;){const k=ha(w),g=w.getBoundingClientRect(),x=Is(w),y=g.left+(w.clientLeft+parseFloat(x.paddingLeft))*k.x,v=g.top+(w.clientTop+parseFloat(x.paddingTop))*k.y;c*=k.x,u*=k.y,f*=k.x,d*=k.y,c+=y,u+=v,j=bn(w),w=im(j)}}return wu({width:f,height:d,x:c,y:u})}function ld(e,t){const s=ad(e).scrollLeft;return t?t.left+s:xi(ar(e)).left+s}function Tk(e,t){const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-ld(e,s),i=s.top+t.scrollTop;return{x:r,y:i}}function L2(e){let{elements:t,rect:s,offsetParent:r,strategy:i}=e;const a=i==="fixed",l=ar(r),o=t?id(t.floating):!1;if(r===l||o&&a)return s;let c={scrollLeft:0,scrollTop:0},u=Gs(1);const f=Gs(0),d=Br(r);if((d||!a)&&((Ua(r)!=="body"||rd(l))&&(c=ad(r)),d)){const p=xi(r);u=ha(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const m=l&&!d&&!a?Tk(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 F2(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function U2(e){const t=ad(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+ld(e);const l=-t.scrollTop;return Is(s).direction==="rtl"&&(a+=Ks(e.clientWidth,s.clientWidth)-r),{width:r,height:i,x:a,y:l}}const B2=25;function z2(e,t,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",i=bn(e),a=ar(e),l=i.visualViewport;let o=a.clientWidth,c=a.clientHeight,u=0,f=0;if(l){const m=!xg()||t==="fixed";r?m||(u=-l.offsetLeft,f=-l.offsetTop):(o=l.width,c=l.height,m&&(u=l.offsetLeft,f=l.offsetTop))}if(ld(a)<=0){const m=a.ownerDocument,p=m.body,j=getComputedStyle(p),w=m.compatMode==="CSS1Compat"&&parseFloat(j.marginLeft)+parseFloat(j.marginRight)||0,k=Math.abs(a.clientWidth-p.clientWidth-w),g=getComputedStyle(a).scrollbarGutter==="stable both-edges"?k/2:k;g<=B2&&(o-=g)}return{width:o,height:c,x:u,y:f}}function W2(e,t){const s=xi(e,!0,t==="fixed"),r=s.top+e.clientTop,i=s.left+e.clientLeft,a=ha(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 Pj(e,t,s){let r;if(t==="viewport"||t==="layoutViewport")r=z2(e,s,t);else if(t==="document")r=U2(ar(e));else if(Rs(t))r=W2(t,s);else{const i=Ak(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return wu(r)}function H2(e,t){const s=t.get(e);if(s)return s;let r=ql(e,[],!1).filter(o=>Rs(o)&&Ua(o)!=="body"),i=null;const a=Is(e).position==="fixed";let l=a?gi(e):e;for(;Rs(l)&&!Yl(l);){const o=Is(l),c=gg(l),u=i?i.position:a?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&o.position==="static")?r=r.filter(d=>d!==l):i=o,l=gi(l)}return t.set(e,r),r}function V2(e){let{element:t,boundary:s,rootBoundary:r,strategy:i}=e;const l=[...s==="clippingAncestors"?id(t)?[]:H2(t,this._c):[].concat(s),r],o=Pj(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=Pj(t,l[m],i);c=Ks(p.top,c),u=Mr(p.right,u),f=Mr(p.bottom,f),d=Ks(p.left,d)}return{width:u-d,height:f-c,x:d,y:c}}function K2(e){const{width:t,height:s}=Ek(e);return{width:t,height:s}}function G2(e,t,s){const r=Br(t),i=ar(t),a=s==="fixed",l=xi(e,!0,a,t);let o={scrollLeft:0,scrollTop:0};const c=Gs(0);if((r||!a)&&((Ua(t)!=="body"||rd(i))&&(o=ad(t)),r)){const m=xi(t,!0,a,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}!r&&i&&(c.x=ld(i));const u=i&&!r&&!a?Tk(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 mh(e){return Is(e).position==="static"}function Mj(e,t){if(!Br(e)||Is(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return ar(e)===s&&(s=s.ownerDocument.body),s}function Rk(e,t){const s=bn(e);if(id(e))return s;if(!Br(e)){let i=gi(e);for(;i&&!Yl(i);){if(Rs(i)&&!mh(i))return i;i=gi(i)}return s}let r=Mj(e,t);for(;r&&P2(r)&&mh(r);)r=Mj(r,t);return r&&Yl(r)&&mh(r)&&!gg(r)?s:r||D2(e)||s}const Y2=async function(e){const t=this.getOffsetParent||Rk,s=this.getDimensions,r=await s(e.floating);return{reference:G2(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function q2(e){return Is(e).direction==="rtl"}const Q2={convertOffsetParentRelativeRectToViewportRelativeRect:L2,getDocumentElement:ar,getClippingRect:V2,getOffsetParent:Rk,getElementRects:Y2,getClientRects:F2,getDimensions:K2,getScale:ha,isElement:Rs,isRTL:q2};function Ik(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function J2(e,t,s){let r=null,i;const a=ar(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:j,width:w,height:k}=m;if(f||t(),!w||!k)return;const g=Zo(j),x=Zo(a.clientWidth-(p+w)),y=Zo(a.clientHeight-(j+k)),v=Zo(p),b={rootMargin:-g+"px "+-x+"px "+-y+"px "+-v+"px",threshold:Ks(0,Mr(1,d))||1};let S=!0;function C(R){const E=R[0].intersectionRatio;if(!Ik(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=bn(e),u=()=>o(s);return c.addEventListener("resize",u),o(!0),()=>{c.removeEventListener("resize",u),l()}}function X2(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=vg(e),f=i||a?[...u?ql(u):[],...t?ql(t):[]]:[];f.forEach(g=>{i&&g.addEventListener("scroll",s),a&&g.addEventListener("resize",s)});const d=u&&o?J2(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 j,w=c?xi(e):null;c&&k();function k(){const g=xi(e);w&&!Ik(w,g)&&s(),w=g,j=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(j)}}const Z2=A2,eI=T2,tI=N2,nI=I2,sI=C2,$j=S2,rI=R2,iI=(e,t,s)=>{const r=new Map,i=s??{},a={...Q2,...i.platform,_c:r};return k2(e,t,{...i,platform:a})};var aI=typeof document<"u",lI=function(){},Fc=aI?h.useLayoutEffect:lI;function bu(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(!bu(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)&&!bu(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Pk(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Dj(e,t){const s=Pk(e);return Math.round(t*s)/s}function ph(e){const t=h.useRef(e);return Fc(()=>{t.current=e}),t}function oI(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);bu(m,r)||p(r);const[j,w]=h.useState(null),[k,g]=h.useState(null),x=h.useCallback(_=>{_!==b.current&&(b.current=_,w(_))},[]),y=h.useCallback(_=>{_!==S.current&&(S.current=_,g(_))},[]),v=a||j,N=l||k,b=h.useRef(null),S=h.useRef(null),C=h.useRef(f),R=c!=null,E=ph(c),P=ph(i),L=ph(u),$=h.useCallback(()=>{if(!b.current||!S.current)return;const _={placement:t,strategy:s,middleware:m};P.current&&(_.platform=P.current),iI(b.current,S.current,_).then(q=>{const B={...q,isPositioned:L.current!==!1};T.current&&!bu(C.current,B)&&(C.current=B,Sa.flushSync(()=>{d(B)}))})},[m,t,s,P,L]);Fc(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,d(_=>({..._,isPositioned:!1})))},[u]);const T=h.useRef(!1);Fc(()=>(T.current=!0,()=>{T.current=!1}),[]),Fc(()=>{if(v&&(b.current=v),N&&(S.current=N),v&&N){if(E.current)return E.current(v,N,$);$()}},[v,N,$,E,R]);const M=h.useMemo(()=>({reference:b,floating:S,setReference:x,setFloating:y}),[x,y]),U=h.useMemo(()=>({reference:v,floating:N}),[v,N]),K=h.useMemo(()=>{const _={position:s,left:0,top:0};if(!U.floating)return _;const q=Dj(U.floating,f.x),B=Dj(U.floating,f.y);return o?{..._,transform:"translate("+q+"px, "+B+"px)",...Pk(U.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:q,top:B}},[s,o,U.floating,f.x,f.y]);return h.useMemo(()=>({...f,update:$,refs:M,elements:U,floatingStyles:K}),[f,$,M,U,K])}const cI=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?$j({element:r.current,padding:i}).fn(s):{}:r?$j({element:r,padding:i}).fn(s):{}}}},uI=(e,t)=>{const s=Z2(e);return{name:s.name,fn:s.fn,options:[e,t]}},dI=(e,t)=>{const s=eI(e);return{name:s.name,fn:s.fn,options:[e,t]}},hI=(e,t)=>({fn:rI(e).fn,options:[e,t]}),fI=(e,t)=>{const s=tI(e);return{name:s.name,fn:s.fn,options:[e,t]}},mI=(e,t)=>{const s=nI(e);return{name:s.name,fn:s.fn,options:[e,t]}},pI=(e,t)=>{const s=sI(e);return{name:s.name,fn:s.fn,options:[e,t]}},gI=(e,t)=>{const s=cI(e);return{name:s.name,fn:s.fn,options:[e,t]}};var xI=Object.defineProperty,vI=(e,t)=>xI(e,"name",{value:t,configurable:!0});function Mk(e){const[t,s]=h.useState(void 0);return wn(()=>{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}vI(Mk,"useSize");var jI=Object.defineProperty,Nr=(e,t)=>jI(e,"name",{value:t,configurable:!0}),$k="Popper",[Dk,od]=hs($k),[yI,_k]=Dk($k),wI=Nr(e=>{const{__scopePopper:t,children:s}=e,[r,i]=h.useState(null),[a,l]=h.useState(void 0);return n.jsx(yI,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:l,children:s})},"Popper"),bI="PopperAnchor",kI=h.forwardRef(Nr(function(t,s){const{__scopePopper:r,virtualRef:i,...a}=t,l=_k(bI,r),o=h.useRef(null),c=l.onAnchorChange,u=h.useCallback(w=>{o.current=w,w&&c(w)},[c]),f=rt(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&&cd(l.placementState),p=m==null?void 0:m[0],j=m==null?void 0:m[1];return i?null:n.jsx(mt.div,{"data-radix-popper-side":p,"data-radix-popper-align":j,...a,ref:f})},"PopperAnchor")),Ok="PopperContent",[SI,zW]=Dk(Ok),NI=h.forwardRef(Nr(function(t,s){var Ae,ne,be,Te,Ze,Ie,it;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:j="optimized",onPlaced:w,...k}=t,g=_k(Ok,r),[x,y]=h.useState(null),v=rt(s,y),[N,b]=h.useState(null),S=Mk(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},L=Array.isArray(f)?f:[f],$=L.length>0,T={padding:P,boundary:L.filter(Lk),altBoundary:$},{refs:M,floatingStyles:U,placement:K,isPositioned:_,middlewareData:q}=oI({strategy:"fixed",placement:E,whileElementsMounted:Nr((...fe)=>X2(...fe,{animationFrame:j==="always"}),"whileElementsMounted"),elements:{reference:g.anchor},middleware:[uI({mainAxis:a+R,alignmentAxis:o}),u&&dI({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?hI():void 0,...T}),u&&fI({...T}),mI({...T,apply:Nr(({elements:fe,rects:ve,availableWidth:Le,availableHeight:Me})=>{const{width:ot,height:ke}=ve.reference,_e=fe.floating.style;_e.setProperty("--radix-popper-available-width",`${Le}px`),_e.setProperty("--radix-popper-available-height",`${Me}px`),_e.setProperty("--radix-popper-anchor-width",`${ot}px`),_e.setProperty("--radix-popper-anchor-height",`${ke}px`)},"apply")}),N&&gI({element:N,padding:c}),CI({arrowWidth:C,arrowHeight:R}),p&&pI({strategy:"referenceHidden",...T,boundary:$?T.boundary:void 0})]}),B=g.setPlacementState;wn(()=>(B(K),()=>{B(void 0)}),[K,B]);const[H,ue]=cd(K),re=Zn(w);wn(()=>{_&&(re==null||re())},[_,re]);const ie=(Ae=q.arrow)==null?void 0:Ae.x,Ne=(ne=q.arrow)==null?void 0:ne.y,Z=((be=q.arrow)==null?void 0:be.centerOffset)!==0,[ce,de]=h.useState();return wn(()=>{x&&de(window.getComputedStyle(x).zIndex)},[x]),n.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:_?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[(Te=q.transformOrigin)==null?void 0:Te.x,(Ze=q.transformOrigin)==null?void 0:Ze.y].join(" "),...((Ie=q.hide)==null?void 0:Ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:n.jsx(SI,{scope:r,placedSide:H,placedAlign:ue,onArrowChange:b,arrowX:ie,arrowY:Ne,shouldHideArrow:Z,children:n.jsx(mt.div,{"data-side":H,"data-align":ue,...k,ref:v,style:{...k.style,animation:_?(it=k.style)==null?void 0:it.animation:"none"}})})})},"PopperContent"));function Lk(e){return e!==null}Nr(Lk,"isNotNull");var CI=Nr(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]=cd(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 j="",w="";return u==="bottom"?(j=l?d:`${m}px`,w=`${-c}px`):u==="top"?(j=l?d:`${m}px`,w=`${r.floating.height+c}px`):u==="right"?(j=`${-c}px`,w=l?d:`${p}px`):u==="left"&&(j=`${r.floating.width+c}px`,w=l?d:`${p}px`),{data:{x:j,y:w}}}}),"transformOrigin");function cd(e){const[t,s="center"]=e.split("-");return[t,s]}Nr(cd,"getSideAndAlignFromPlacement");var jg=wI,Fk=kI,Uk=NI,EI=Object.defineProperty,_t=(e,t)=>EI(e,"name",{value:t,configurable:!0}),[yg,WW]=hs("Tooltip",[od]),wg=od(),AI="TooltipProvider",TI=700,am="tooltip.open",[RI,bg]=yg(AI),II=_t(e=>{const{__scopeTooltip:t,delayDuration:s=TI,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(RI,{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"),lm="Tooltip",[PI,jo]=yg(lm),MI=_t(e=>{const{__scopeTooltip:t,children:s,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:l,delayDuration:o}=e,c=bg(lm,e.__scopeTooltip),u=wg(t),[f,d]=h.useState(null),[m,p]=h.useState(void 0),j=ls(),w=h.useRef(0),k=l??c.disableHoverableContent,g=o??c.delayDuration,x=h.useRef(!1),[y,v]=Si({prop:r,defaultProp:i??!1,onChange:_t(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(am))):c.onClose(),a==null||a(E)},"onChange"),caller:lm}),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,v(!0)},[v]),S=h.useCallback(()=>{window.clearTimeout(w.current),w.current=0,v(!1)},[v]),C=h.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{x.current=!0,v(!0),w.current=0},g)},[g,v]);h.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const R=m??j;return n.jsx(jg,{...u,children:n.jsx(PI,{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"),_j="TooltipTrigger",$I=h.forwardRef(_t(function(t,s){const{__scopeTooltip:r,...i}=t,a=jo(_j,r),l=bg(_j,r),o=wg(r),c=h.useRef(null),u=rt(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(Fk,{asChild:!0,...o,children:n.jsx(mt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:u,onPointerMove:Ee(t.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),d.current=!0)}),onPointerLeave:Ee(t.onPointerLeave,()=>{a.onTriggerLeave(),d.current=!1}),onPointerDown:Ee(t.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:Ee(t.onFocus,()=>{f.current||a.onOpen()}),onBlur:Ee(t.onBlur,a.onClose),onClick:Ee(t.onClick,a.onClose)})})},"TooltipTrigger")),Bk="TooltipPortal",[DI,_I]=yg(Bk,{forceMount:void 0}),OI=_t(e=>{const{__scopeTooltip:t,forceMount:s,children:r,container:i}=e,a=jo(Bk,t);return n.jsx(DI,{scope:t,forceMount:s,children:n.jsx(ir,{present:s||a.open,children:n.jsx(hg,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Ql="TooltipContent",LI=h.forwardRef(_t(function(t,s){const r=_I(Ql,t.__scopeTooltip),{forceMount:i=r.forceMount,side:a="top",...l}=t,o=jo(Ql,t.__scopeTooltip);return n.jsx(ir,{present:i||o.open,children:o.disableHoverableContent?n.jsx(zk,{side:a,...l,ref:s}):n.jsx(FI,{side:a,...l,ref:s})})},"TooltipContent")),FI=h.forwardRef(_t(function(t,s){const r=jo(Ql,t.__scopeTooltip),i=bg(Ql,t.__scopeTooltip),a=h.useRef(null),l=rt(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]),j=h.useCallback((w,k)=>{const g=w.currentTarget,x={x:w.clientX,y:w.clientY},y=Wk(x,g.getBoundingClientRect()),v=Hk(x,y),N=Vk(k.getBoundingClientRect()),b=Gk([...v,...N]);c(b),m(!0)},[m]);return h.useEffect(()=>()=>p(),[p]),h.useEffect(()=>{if(u&&d){const w=_t(g=>j(g,d),"handleTriggerLeave"),k=_t(g=>j(g,u),"handleContentLeave");return u.addEventListener("pointerleave",w),d.addEventListener("pointerleave",k),()=>{u.removeEventListener("pointerleave",w),d.removeEventListener("pointerleave",k)}}},[u,d,j,p]),h.useEffect(()=>{if(o){const w=_t(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)),v=!Kk(x,o);y?p():v&&(p(),f())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,d,o,f,p]),n.jsx(zk,{...t,ref:l})},"TooltipContentHoverable")),UI=q0("TooltipContent"),zk=h.forwardRef(_t(function(t,s){const{__scopeTooltip:r,children:i,"aria-label":a,id:l,onEscapeKeyDown:o,onPointerDownOutside:c,...u}=t,f=jo(Ql,r),d=wg(r),{onClose:m}=f;h.useEffect(()=>(document.addEventListener(am,m),()=>document.removeEventListener(am,m)),[m]),h.useEffect(()=>{if(f.trigger){const j=_t(w=>{w.target instanceof Node&&w.target.contains(f.trigger)&&m()},"handleScroll");return window.addEventListener("scroll",j,{capture:!0}),()=>window.removeEventListener("scroll",j,{capture:!0})}},[f.trigger,m]);const{setContentId:p}=f;return wn(()=>(p(l),()=>{p(void 0)}),[l,p]),n.jsx(ug,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:j=>j.preventDefault(),onDismiss:m,children:n.jsxs(Uk,{"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(UI,{children:i}),a?n.jsx(GR,{id:f.contentId,role:"tooltip",children:a}):null]})})},"TooltipContentImpl"));function Wk(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")}}_t(Wk,"getExitSideFromRect");function Hk(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}_t(Hk,"getPaddedExitPoints");function Vk(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}]}_t(Vk,"getPointsFromRect");function Kk(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}_t(Kk,"isPointInPolygon");function Gk(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),Yk(t)}_t(Gk,"getHull");function Yk(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)}_t(Yk,"getHullPresorted");var Oj=II,Jl=MI,Xl=$I,Zl=OI,eo=LI;const Lj="buddi_csrf",Ba="x-buddi-csrf",to="buddi:agents-changed",BI="This page's sign-in no longer matches its cookies. Reload the page and try again.";class ae extends Error{constructor(t,s,r){super(s),this.status=t,this.detail=r,this.name="ApiError"}}function Ni(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${Lj}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const s=[...document.cookie.matchAll(new RegExp(`(?:^|; )${Lj}(?:_\\d+)?=([^;]*)`,"g"))];return s.length===1&&((r=s[0])!=null&&r[1])?decodeURIComponent(s[0][1]):""}const ku="buddi isn't answering.";let om=null;const cm=new Set;function ec(e){if(e!==(om===null)){om=e?null:Date.now();for(const t of cm)t()}}function zI(){return om}function WI(e){return cm.add(e),()=>cm.delete(e)}function HI(e){return e instanceof ae&&(e.status===0||e.status===502||e.status===503)&&e.message===ku}async function Ci(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:(ec(!1),new ae(0,ku,o))}if(s.status===401)throw ec(!0),new ae(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await s.text(),i=r===""?null:VI(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 ec(!1),new ae(s.status,ku,i);if(ec(!0),!s.ok){const o=(t.method??"GET").toUpperCase(),c=a??(s.status===403&&o!=="GET"&&o!=="HEAD"?BI:`request failed (${s.status})`);throw new ae(s.status,c,i)}return i}function VI(e){try{return JSON.parse(e)}catch{return null}}function le(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 Ci(`/api${e}${r?`?${r}`:""}`)}function qk(e,t){return Ci(`/api${e}`,{method:"POST",headers:{[Ba]:Ni()},body:t})}function ra(e){return Ci(`/api${e}`,{method:"DELETE",headers:{[Ba]:Ni()}})}function J(e,t={}){return Ci(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[Ba]:Ni()},body:JSON.stringify(t??{})})}function Qk(e,t,s,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||s;return Ci(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[Ba]:Ni(),"X-Filename":i,...r},body:t})}function Fj(e,t,s){return Qk(e,t,"backup.tar.gz",{...s.passphrase?{"X-Backup-Passphrase":s.passphrase}:{},...s.confirm?{"X-Backup-Confirm":s.confirm}:{}})}function KI(e,t={}){return Ci(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[Ba]:Ni()},body:JSON.stringify(t??{})})}function Qr(e,t={}){return Ci(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[Ba]:Ni()},body:JSON.stringify(t??{})})}function GI(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 Uc="gpt-oss:120b",YI=["approval","question","watcher","reminder","failure","recap","plugin"],um=["mon","tue","wed","thu","fri","sat","sun"],Oe={agents:()=>le("/chat/agents"),views:()=>le("/chat/views"),conversations:(e,t)=>le(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>J(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>le(`/chat/conversations/${encodeURIComponent(e)}`),send:(e,t)=>J(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>J(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>J(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),qk("/chat/attachments",t)},transcribe:e=>J("/speech/transcribe",e),say:e=>J("/speech/say",e),discardAttachment:e=>ra(`/artifacts/${encodeURIComponent(e)}`),groups:()=>le("/groups"),group:e=>le(`/groups/${encodeURIComponent(e)}`),createGroup:e=>J("/groups",e),updateGroup:(e,t)=>KI(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>ra(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>le(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>J(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>J(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`};function kg(e){return e.httpStatus===401||e.httpStatus===403||e.state==="authentication-error"||e.state==="access-denied"}const A={providers:()=>le("/providers"),providerAccounts:()=>le("/provider-accounts"),probeModels:e=>J("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>J(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>J("/provider-accounts/save",e),testProviderAccount:e=>J(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>J(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,s)=>J(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:s}),ollamaConnect:(e,t)=>J(`/provider-accounts/${encodeURIComponent(e)}/ollama/connect`,{revision:t}),ollamaPoll:(e,t)=>J(`/provider-accounts/${encodeURIComponent(e)}/ollama/poll`,{attemptId:t}),ollamaDisconnect:(e,t)=>J(`/provider-accounts/${encodeURIComponent(e)}/ollama/disconnect`,{revision:t}),anthropicAccountAction:(e,t,s,r)=>J(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:s,...r}),assignProviderAccount:(e,t,s)=>J(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:s}),configureProvider:(e,t)=>J(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>J(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>J(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>J(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>le("/host/browser-profiles",{app:e}),installedApps:()=>le("/host/apps"),browser:e=>le(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>J(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>J("/browser/settings",e),computerPermissions:(e=!1)=>J("/browser/permissions",{prompt:e}),browserInstall:()=>J("/browser/install",{}),browserCheck:()=>J("/browser/check",{}),previewLink:(e,t)=>le(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>le(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>le("/extension"),pairExtension:e=>J("/extension/pair",{code:e}),forgetExtension:()=>ra("/extension/pair"),session:()=>le("/session"),overview:()=>le("/overview"),events:e=>le("/events",e),eventKinds:()=>le("/events/kinds"),conversations:()=>le("/conversations"),conversation:e=>le(`/conversations/${encodeURIComponent(e)}`),missions:()=>le("/missions"),jobs:(e={})=>le("/jobs",e),approvals:()=>le("/approvals"),approval:e=>le(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>le("/offers"),dismissOffer:e=>J(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>J("/offers/dismiss-all",{ids:e}),agentOffers:()=>le("/agent-offers"),teammates:()=>le("/teammates"),dismissAgentOffer:(e,t)=>J(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>le("/proposals"),setDigestSchedule:(e,t)=>J("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>J(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),discardProposal:(e,t)=>J(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>le("/reminders"),sentinels:()=>le("/sentinels"),setSentinelEnabled:(e,t)=>J(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),setGlanceHidden:(e,t)=>J(`/home/glances/${encodeURIComponent(e)}/hidden`,{hidden:t}),rail:()=>le("/rail"),setRailHidden:(e,t,s)=>J(`/rail/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}/hidden`,{hidden:s}),snoozeAlert:(e,t)=>J(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>le("/agents"),library:e=>le("/artifacts",e),libraryEntry:(e,t=0)=>le(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>le("/onboarding"),onboardingStep:(e,t={})=>J("/onboarding/step",{step:e,...t}),completeOnboarding:()=>J("/onboarding/complete"),skipOnboarding:()=>J("/onboarding/skip"),createFirstAgent:e=>J("/onboarding/agent",e),ollama:()=>le("/onboarding/ollama"),firstAgentPersona:()=>le("/onboarding/agent"),updateFirstAgent:e=>J("/onboarding/agent/update",e),bindBrain:e=>J("/onboarding/brain",e),pages:()=>le("/pages"),pageQuery:(e,t,s={})=>le(`/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)=>J(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>le("/telegram"),saveTelegramToken:e=>J("/telegram/token",{token:e}),telegramPairing:()=>J("/telegram/pairing"),telegramBot:()=>le("/telegram/bot"),telegramDevices:()=>le("/telegram/devices"),unpairTelegramDevice:e=>ra(`/telegram/devices/${encodeURIComponent(e)}`),notifications:(e=20)=>le("/notifications",{limit:e}),notificationSeen:e=>J(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>le("/notifications/settings"),saveNotificationSettings:e=>Qr("/notifications/settings",e),focus:()=>le("/notifications/focus"),setFocus:(e,t)=>Qr("/notifications/focus",t?{mode:e,duration:t}:{mode:e}),testChannel:e=>J("/notifications/test",{channel:e}),currentTip:e=>le(e?`/tips/current?preview=${encodeURIComponent(e)}`:"/tips/current"),tips:()=>le("/tips"),restoreTip:e=>J(`/tips/${encodeURIComponent(e)}/restore`),dismissTip:e=>J(`/tips/${encodeURIComponent(e)}/dismiss`),laterTip:e=>J(`/tips/${encodeURIComponent(e)}/later`),tipsSeenPage:e=>J("/tips/seen-page",{page:e}),tipsSettings:()=>le("/tips/settings"),saveTipsSettings:e=>Qr("/tips/settings",{enabled:e}),presence:e=>J("/presence",{state:e}),owner:()=>le("/owner"),setOwner:e=>J("/owner",e),memory:e=>le(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>J("/memory/preferences",e),forgetPreference:e=>J("/memory/preferences/forget",e),updateNote:(e,t)=>J(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>J(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>J(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>le(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>le(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>J(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>le("/host",{agentId:e,conversationId:t}),connections:()=>le("/connections"),connection:e=>le(`/connections/${e}`),addConnection:(e,t)=>J("/connections",{url:e,...t?{name:t}:{}}),connectionConsent:(e,t)=>J(`/connections/${e}/consent`,t?{clientId:t}:{}),connectionCallback:e=>J("/connections/callback",e),connectionReview:e=>le(`/connections/${e}/review`),saveConnectionReview:(e,t)=>J(`/connections/${e}/review`,t),grantConnection:(e,t)=>J(`/connections/${e}/grant`,{agents:t}),disconnect:e=>ra(`/connections/${e}`),connectionSignals:()=>le("/connections/signals"),connectionTools:e=>le(`/connections/${e}/tools`),rememberedApprovals:e=>le(`/connections/remembered/${encodeURIComponent(e)}`),setRememberedApproval:(e,t,s)=>J("/connections/remembered",{agent:e,tool:t,remember:s}),secrets:()=>le("/secrets"),secretUses:(e,t)=>le("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>J("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>J("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>J("/host/revoke",{id:e}),decide:(e,t,s,r)=>J(`/approvals/${encodeURIComponent(e)}/${t}`,s||r?{...s?{permissionScope:s}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>J("/pause",{paused:e}),service:()=>le("/service"),serviceAction:e=>J(`/service/${e}`),version:()=>le("/version"),checkVersion:()=>J("/version/check"),setVersionCheck:e=>Qr("/version/check",{enabled:e}),tailscale:()=>le("/tailscale"),setTailscale:e=>Qr("/tailscale",e),startUpgrade:e=>J("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>le(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>le("/backups"),startBackup:e=>J("/backups",{encrypt:e}),verifyArchive:e=>J("/backups/verify",{name:e}),restoreArchive:e=>J("/backups/restore",e),restoreUpload:(e,t)=>Fj("/backups/restore",e,t),backupJob:e=>le(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>le("/backups/schedule"),setBackupSchedule:e=>Qr("/backups/schedule",e),backupPassphrase:()=>le("/backups/passphrase"),setBackupPassphrase:e=>Qr("/backups/passphrase",{passphrase:e}),plugins:()=>le("/plugins"),stagePlugin:e=>J("/plugins/stage",{spec:e}),uploadPlugin:e=>Qk("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>le(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>J(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>J(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>J(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),setPluginEnabled:(e,t)=>J(`/plugins/${encodeURIComponent(e)}/${t?"enable":"disable"}`,{}),uninstallPlugin:(e,t)=>J(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>J(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>le("/recovery"),leaveRecovery:e=>J("/recovery/leave",e),firstRunRestore:(e,t)=>Fj("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>J(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,s)=>J(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...s===void 0?{}:{deadlineMinutes:s}}),retryJob:e=>J(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>J(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>J("/agents/default",{agentId:e}),agentTools:e=>le(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>le(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const s=new FormData;return s.append("file",t,t.name),qk(`/agents/${encodeURIComponent(e)}/avatar`,s)},removeAgentPicture:e=>ra(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>J(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>J(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>J(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>J(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};function Jk(e){return e==="anthropic"||e==="openai"}function Xk(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 qI="Thinking is up to this model. What it writes while thinking is shown apart and kept out of the answer.";var QI=Object.defineProperty,JI=(e,t)=>QI(e,"name",{value:t,configurable:!0}),XI=h.createContext(void 0);function ud(e){const t=h.useContext(XI);return e||t||"ltr"}JI(ud,"useDirection");var ZI=Object.defineProperty,Sg=(e,t)=>ZI(e,"name",{value:t,configurable:!0}),tc=0,ys=null;function eP(e){return dd(),e.children}Sg(eP,"FocusGuards");function dd(){h.useEffect(()=>{ys||(ys={start:dm(),end:dm()});const{start:e,end:t}=ys;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),tc++,()=>{tc===1&&(ys==null||ys.start.remove(),ys==null||ys.end.remove(),ys=null),tc=Math.max(0,tc-1)}},[])}Sg(dd,"useFocusGuards");function dm(){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}Sg(dm,"createFocusGuard");var tP=Object.defineProperty,ln=(e,t)=>tP(e,"name",{value:t,configurable:!0}),gh="focusScope.autoFocusOnMount",xh="focusScope.autoFocusOnUnmount",Uj={bubbles:!1,cancelable:!0},Zk=h.forwardRef(ln(function(t,s){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...o}=t,[c,u]=h.useState(null),f=Zn(a),d=Zn(l),m=h.useRef(null),p=rt(s,u),j=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(i){let k=function(v){if(j.paused||!c)return;const N=v.target;c.contains(N)?m.current=N:Us(m.current,{select:!0})},g=function(v){if(j.paused||!c)return;const N=v.relatedTarget;N!==null&&(c.contains(N)||Us(m.current,{select:!0}))},x=function(v){if(document.activeElement===document.body)for(const b of v)b.removedNodes.length>0&&Us(c)};ln(k,"handleFocusIn"),ln(g,"handleFocusOut"),ln(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,j.paused]),h.useEffect(()=>{if(c){Bj.add(j);const k=document.activeElement;if(!c.contains(k)){const x=new CustomEvent(gh,Uj);c.addEventListener(gh,f),c.dispatchEvent(x),x.defaultPrevented||(eS(iS(Ng(c)),{select:!0}),document.activeElement===k&&Us(c))}return()=>{c.removeEventListener(gh,f),setTimeout(()=>{const x=new CustomEvent(xh,Uj);c.addEventListener(xh,d),c.dispatchEvent(x),x.defaultPrevented||Us(k??document.body,{select:!0}),c.removeEventListener(xh,d),Bj.remove(j)},0)}}},[c,f,d,j]);const w=h.useCallback(k=>{if(!r&&!i||j.paused)return;const g=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,x=document.activeElement;if(g&&x){const y=k.currentTarget,[v,N]=tS(y);v&&N?!k.shiftKey&&x===N?(k.preventDefault(),r&&Us(v,{select:!0})):k.shiftKey&&x===v&&(k.preventDefault(),r&&Us(N,{select:!0})):x===y&&k.preventDefault()}},[r,i,j.paused]);return n.jsx(mt.div,{tabIndex:-1,...o,ref:p,onKeyDown:w})},"FocusScope"));function eS(e,{select:t=!1}={}){const s=document.activeElement;for(const r of e)if(Us(r,{select:t}),document.activeElement!==s)return}ln(eS,"focusFirst");function tS(e){const t=Ng(e),s=hm(t,e),r=hm(t.reverse(),e);return[s,r]}ln(tS,"getTabbableEdges");function Ng(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ln(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}ln(Ng,"getTabbableCandidates");function hm(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(s?!r.checkVisibility({checkVisibilityCSS:!0}):nS(r,{upTo:t})))return r}ln(hm,"findVisible");function nS(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}ln(nS,"isHidden");function sS(e){return e instanceof HTMLInputElement&&"select"in e}ln(sS,"isSelectableInput");function Us(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&sS(e)&&t&&e.select()}}ln(Us,"focus");var Bj=rS();function rS(){let e=[];return{add(t){const s=e[0];t!==s&&(s==null||s.pause()),e=fm(e,t),e.unshift(t)},remove(t){var s;e=fm(e,t),(s=e[0])==null||s.resume()}}}ln(rS,"createFocusScopesStack");function fm(e,t){const s=[...e],r=s.indexOf(t);return r!==-1&&s.splice(r,1),s}ln(fm,"arrayRemove");function iS(e){return e.filter(t=>t.tagName!=="A")}ln(iS,"removeLinks");var nP=Object.defineProperty,Cg=(e,t)=>nP(e,"name",{value:t,configurable:!0}),vh=!1;function aS(){const[e,t]=h.useState(vh);return h.useEffect(()=>{vh||(vh=!0,t(!0))},[]),e}Cg(aS,"useIsHydrated");var lS=Da[" useSyncExternalStore ".trim().toString()];function oS(){return()=>{}}Cg(oS,"subscribe");function cS(){return lS(oS,()=>!0,()=>!1)}Cg(cS,"useIsHydratedModern");var sP=typeof lS=="function"?cS:aS,rP=Object.defineProperty,Ei=(e,t)=>rP(e,"name",{value:t,configurable:!0}),jh="rovingFocusGroup.onEntryFocus",iP={bubbles:!1,cancelable:!0},hd="RovingFocusGroup",[mm,uS,aP]=td(hd),[lP,fd]=hs(hd,[aP]),[oP,cP]=lP(hd),uP=h.forwardRef(Ei(function(t,s){return n.jsx(mm.Provider,{scope:t.__scopeRovingFocusGroup,children:n.jsx(mm.Slot,{scope:t.__scopeRovingFocusGroup,children:n.jsx(dP,{...t,ref:s})})})},"RovingFocusGroup")),dP=h.forwardRef(Ei(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),j=rt(s,p),w=ud(l),[k,g]=Si({prop:o,defaultProp:c??null,onChange:u,caller:hd}),[x,y]=h.useState(!1),v=Zn(f),N=uS(r),b=h.useRef(!1),[S,C]=h.useState(0);return h.useEffect(()=>{const R=p.current;if(R)return R.addEventListener(jh,v),()=>R.removeEventListener(jh,v)},[v]),n.jsx(oP,{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:j,style:{outline:"none",...t.style},onMouseDown:Ee(t.onMouseDown,()=>{b.current=!0}),onFocus:Ee(t.onFocus,R=>{const E=!b.current;if(R.target===R.currentTarget&&E&&!x){const P=new CustomEvent(jh,iP);if(R.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=N().filter(K=>K.focusable),$=L.find(K=>K.active),T=L.find(K=>K.id===k),U=[$,T,...L].filter(Boolean).map(K=>K.ref.current);Eg(U,d)}}b.current=!1}),onBlur:Ee(t.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),hP="RovingFocusGroupItem",fP=h.forwardRef(Ei(function(t,s){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:a=!1,tabStopId:l,children:o,...c}=t,u=ls(),f=l||u,d=cP(hP,r),m=d.currentTabStopId===f,p=uS(r),{onFocusableItemAdd:j,onFocusableItemRemove:w,currentTabStopId:k}=d,g=sP();return wn(()=>{if(!(!g||!i))return j(),()=>w()},[g,i,j,w]),h.useEffect(()=>{if(!(g||!i))return j(),()=>w()},[g,i,j,w]),n.jsx(mm.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:Ee(t.onMouseDown,x=>{i?d.onItemFocus(f):x.preventDefault()}),onFocus:Ee(t.onFocus,()=>d.onItemFocus(f)),onKeyDown:Ee(t.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=hS(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?fS(N,b+1):N.slice(b+1)}setTimeout(()=>Eg(N))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:k!=null}):o})})},"RovingFocusGroupItem")),mP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function dS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Ei(dS,"getDirectionAwareKey");function hS(e,t,s){const r=dS(e.key,s);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return mP[r]}Ei(hS,"getFocusIntent");function Eg(e,t=!1){const s=document.activeElement;for(const r of e)if(r===s||(r.focus({preventScroll:t}),document.activeElement!==s))return}Ei(Eg,"focusFirst");function fS(e,t){return e.map((s,r)=>e[(t+r)%e.length])}Ei(fS,"wrapArray");var mS=uP,pS=fP,pP=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Li=new WeakMap,nc=new WeakMap,sc={},yh=0,gS=function(e){return e&&(e.host||gS(e.parentNode))},gP=function(e,t){return t.map(function(s){if(e.contains(s))return s;var r=gS(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})},xP=function(e,t,s,r){var i=gP(t,Array.isArray(e)?e:[e]);sc[s]||(sc[s]=new WeakMap);var a=sc[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),j=p!==null&&p!=="false",w=(Li.get(m)||0)+1,k=(a.get(m)||0)+1;Li.set(m,w),a.set(m,k),l.push(m),w===1&&j&&nc.set(m,!0),k===1&&m.setAttribute(s,"true"),j||m.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",m,g)}})};return f(t),o.clear(),yh++,function(){l.forEach(function(d){var m=Li.get(d)-1,p=a.get(d)-1;Li.set(d,m),a.set(d,p),m||(nc.has(d)||d.removeAttribute(r),nc.delete(d)),p||d.removeAttribute(s)}),yh--,yh||(Li=new WeakMap,Li=new WeakMap,nc=new WeakMap,sc={})}},xS=function(e,t,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=pP(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),xP(r,i,s,"aria-hidden")):function(){return null}},Ss=function(){return Ss=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},Ss.apply(this,arguments)};function vS(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 vP(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 Bc="right-scroll-bar-position",zc="width-before-scroll-bar",jP="with-scroll-bars-hidden",yP="--removed-body-scroll-bar-size";function wh(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function wP(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 bP=typeof window<"u"?h.useLayoutEffect:h.useEffect,zj=new WeakMap;function kP(e,t){var s=wP(null,function(r){return e.forEach(function(i){return wh(i,r)})});return bP(function(){var r=zj.get(s);if(r){var i=new Set(r),a=new Set(e),l=s.current;i.forEach(function(o){a.has(o)||wh(o,null)}),a.forEach(function(o){i.has(o)||wh(o,l)})}zj.set(s,e)},[e]),s}function SP(e){return e}function NP(e,t){t===void 0&&(t=SP);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 CP(e){e===void 0&&(e={});var t=NP(null);return t.options=Ss({async:!0,ssr:!1},e),t}var jS=function(e){var t=e.sideCar,s=vS(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,Ss({},s))};jS.isSideCarExport=!0;function EP(e,t){return e.useMedium(t),jS}var yS=CP(),bh=function(){},md=h.forwardRef(function(e,t){var s=h.useRef(null),r=h.useState({onScrollCapture:bh,onWheelCapture:bh,onTouchMoveCapture:bh}),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,j=e.noIsolation,w=e.inert,k=e.allowPinchZoom,g=e.as,x=g===void 0?"div":g,y=e.gapMode,v=vS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=m,b=kP([s,t]),S=Ss(Ss({},v),i);return h.createElement(h.Fragment,null,f&&h.createElement(N,{sideCar:yS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:j,inert:w,setCallbacks:a,allowPinchZoom:!!k,lockRef:s,gapMode:y}),l?h.cloneElement(h.Children.only(o),Ss(Ss({},S),{ref:b})):h.createElement(x,Ss({},S,{className:c,ref:b}),o))});md.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};md.classNames={fullWidth:zc,zeroRight:Bc};var AP=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function TP(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=AP();return t&&e.setAttribute("nonce",t),e}function RP(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function IP(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var PP=function(){var e=0,t=null;return{add:function(s){e==0&&(t=TP())&&(RP(t,s),IP(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},MP=function(){var e=PP();return function(t,s){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},wS=function(){var e=MP(),t=function(s){var r=s.styles,i=s.dynamic;return e(r,i),null};return t},$P={left:0,top:0,right:0,gap:0},kh=function(e){return parseInt(e||"",10)||0},DP=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[kh(s),kh(r),kh(i)]},_P=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return $P;var t=DP(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])}},OP=wS(),fa="data-scroll-locked",LP=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(jP,` {
42
+ overflow: hidden `).concat(r,`;
43
+ padding-right: `).concat(o,"px ").concat(r,`;
44
+ }
45
+ body[`).concat(fa,`] {
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(Bc,` {
59
+ right: `).concat(o,"px ").concat(r,`;
60
+ }
61
+
62
+ .`).concat(zc,` {
63
+ margin-right: `).concat(o,"px ").concat(r,`;
64
+ }
65
+
66
+ .`).concat(Bc," .").concat(Bc,` {
67
+ right: 0 `).concat(r,`;
68
+ }
69
+
70
+ .`).concat(zc," .").concat(zc,` {
71
+ margin-right: 0 `).concat(r,`;
72
+ }
73
+
74
+ body[`).concat(fa,`] {
75
+ `).concat(yP,": ").concat(o,`px;
76
+ }
77
+ `)},Wj=function(){var e=parseInt(document.body.getAttribute(fa)||"0",10);return isFinite(e)?e:0},FP=function(){h.useEffect(function(){return document.body.setAttribute(fa,(Wj()+1).toString()),function(){var e=Wj()-1;e<=0?document.body.removeAttribute(fa):document.body.setAttribute(fa,e.toString())}},[])},UP=function(e){var t=e.noRelative,s=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;FP();var a=h.useMemo(function(){return _P(i)},[i]);return h.createElement(OP,{styles:LP(a,!t,i,s?"":"!important")})},pm=!1;if(typeof window<"u")try{var rc=Object.defineProperty({},"passive",{get:function(){return pm=!0,!0}});window.addEventListener("test",rc,rc),window.removeEventListener("test",rc,rc)}catch{pm=!1}var Fi=pm?{passive:!1}:!1,BP=function(e){return e.tagName==="TEXTAREA"},bS=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!BP(e)&&s[t]==="visible")},zP=function(e){return bS(e,"overflowY")},WP=function(e){return bS(e,"overflowX")},Hj=function(e,t){var s=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=kS(e,r);if(i){var a=SS(e,r),l=a[1],o=a[2];if(l>o)return!0}r=r.parentNode}while(r&&r!==s.body);return!1},HP=function(e){var t=e.scrollTop,s=e.scrollHeight,r=e.clientHeight;return[t,s,r]},VP=function(e){var t=e.scrollLeft,s=e.scrollWidth,r=e.clientWidth;return[t,s,r]},kS=function(e,t){return e==="v"?zP(t):WP(t)},SS=function(e,t){return e==="v"?HP(t):VP(t)},KP=function(e,t){return e==="h"&&t==="rtl"?-1:1},GP=function(e,t,s,r,i){var a=KP(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=SS(e,o),j=p[0],w=p[1],k=p[2],g=w-k-a*j;(j||g)&&kS(e,o)&&(d+=g,m+=j);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},ic=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Vj=function(e){return[e.deltaX,e.deltaY]},Kj=function(e){return e&&"current"in e?e.current:e},YP=function(e,t){return e[0]===t[0]&&e[1]===t[1]},qP=function(e){return`
78
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
79
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
80
+ `)},QP=0,Ui=[];function JP(e){var t=h.useRef([]),s=h.useRef([0,0]),r=h.useRef(),i=h.useState(QP++)[0],a=h.useState(wS)[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=vP([e.lockRef.current],(e.shards||[]).map(Kj),!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=ic(w),x=s.current,y="deltaX"in w?w.deltaX:x[0]-g[0],v="deltaY"in w?w.deltaY:x[1]-g[1],N,b=w.target,S=Math.abs(y)>Math.abs(v)?"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=Hj(S,b);if(!P)return!0;if(P?N=S:(N=S==="v"?"h":"v",P=Hj(S,b)),!P)return!1;if(!r.current&&"changedTouches"in w&&(y||v)&&(r.current=N),!N)return!0;var L=r.current||N;return GP(L,k,w,L==="h"?y:v)},[]),c=h.useCallback(function(w){var k=w;if(!(!Ui.length||Ui[Ui.length-1]!==a)){var g="deltaY"in k?Vj(k):ic(k),x=t.current.filter(function(N){return N.name===k.type&&(N.target===k.target||k.target===N.shadowParent)&&YP(N.delta,g)})[0];if(x&&x.should){k.cancelable&&k.preventDefault();return}if(!x){var y=(l.current.shards||[]).map(Kj).filter(Boolean).filter(function(N){return N.contains(k.target)}),v=y.length>0?o(k,y[0]):!l.current.noIsolation;v&&k.cancelable&&k.preventDefault()}}},[]),u=h.useCallback(function(w,k,g,x){var y={name:w,delta:k,target:g,should:x,shadowParent:XP(g)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(v){return v!==y})},1)},[]),f=h.useCallback(function(w){s.current=ic(w),r.current=void 0},[]),d=h.useCallback(function(w){u(w.type,Vj(w),w.target,o(w,e.lockRef.current))},[]),m=h.useCallback(function(w){u(w.type,ic(w),w.target,o(w,e.lockRef.current))},[]);h.useEffect(function(){return Ui.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Fi),document.addEventListener("touchmove",c,Fi),document.addEventListener("touchstart",f,Fi),function(){Ui=Ui.filter(function(w){return w!==a}),document.removeEventListener("wheel",c,Fi),document.removeEventListener("touchmove",c,Fi),document.removeEventListener("touchstart",f,Fi)}},[]);var p=e.removeScrollBar,j=e.inert;return h.createElement(h.Fragment,null,j?h.createElement(a,{styles:qP(i)}):null,p?h.createElement(UP,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function XP(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ZP=EP(yS,JP);var Ag=h.forwardRef(function(e,t){return h.createElement(md,Ss({},e,{ref:t,sideCar:ZP}))});Ag.classNames=md.classNames;var eM=Object.defineProperty,He=(e,t)=>eM(e,"name",{value:t,configurable:!0}),gm=["Enter"," "],tM=["ArrowDown","PageUp","Home"],NS=["ArrowUp","PageDown","End"],nM=[...tM,...NS],sM={ltr:[...gm,"ArrowRight"],rtl:[...gm,"ArrowLeft"]},rM={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pd="Menu",[no,iM,aM]=td(pd),[Ai,CS]=hs(pd,[aM,od,fd]),gd=od(),ES=fd(),[AS,zr]=Ai(pd),[lM,yo]=Ai(pd),oM=He(e=>{const{__scopeMenu:t,open:s=!1,children:r,dir:i,onOpenChange:a,modal:l=!0}=e,o=gd(t),[c,u]=h.useState(null),f=h.useRef(!1),d=Zn(a),m=ud(i);return h.useEffect(()=>{const p=He(()=>{f.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},"handleKeyDown"),j=He(()=>f.current=!1,"handlePointer");return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{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(jg,{...o,children:n.jsx(AS,{scope:t,open:s,onOpenChange:d,content:c,onContentChange:u,children:n.jsx(lM,{scope:t,onClose:h.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:f,dir:m,modal:l,children:r})})})},"Menu"),TS=h.forwardRef(He(function(t,s){const{__scopeMenu:r,...i}=t,a=gd(r);return n.jsx(Fk,{...a,...i,ref:s})},"MenuAnchor")),RS="MenuPortal",[cM,IS]=Ai(RS,{forceMount:void 0}),uM=He(e=>{const{__scopeMenu:t,forceMount:s,children:r,container:i}=e,a=zr(RS,t);return n.jsx(cM,{scope:t,forceMount:s,children:n.jsx(ir,{present:s||a.open,children:n.jsx(hg,{asChild:!0,container:i,children:r})})})},"MenuPortal"),os="MenuContent",[dM,Tg]=Ai(os),hM=h.forwardRef(He(function(t,s){const r=IS(os,t.__scopeMenu),{forceMount:i=r.forceMount,...a}=t,l=zr(os,t.__scopeMenu),o=yo(os,t.__scopeMenu);return n.jsx(no.Provider,{scope:t.__scopeMenu,children:n.jsx(ir,{present:i||l.open,children:n.jsx(no.Slot,{scope:t.__scopeMenu,children:o.modal?n.jsx(fM,{...a,ref:s}):n.jsx(mM,{...a,ref:s})})})})},"MenuContent")),fM=h.forwardRef(He(function(t,s){const r=zr(os,t.__scopeMenu),i=h.useRef(null),a=rt(s,i);return h.useEffect(()=>{const l=i.current;if(l)return xS(l)},[]),n.jsx(Rg,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Ee(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),mM=h.forwardRef(He(function(t,s){const r=zr(os,t.__scopeMenu);return n.jsx(Rg,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),pM=Pr("MenuContent.ScrollLock"),Rg=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:j,disableOutsideScroll:w,...k}=t,g=zr(os,r),x=yo(os,r),y=gd(r),v=ES(r),N=iM(r),[b,S]=h.useState(null),C=h.useRef(null),R=rt(s,C,g.onContentChange),E=h.useRef(0),P=h.useRef(""),L=h.useRef(0),$=h.useRef(null),T=h.useRef("right"),M=h.useRef(0),U=w?Ag:h.Fragment,K=w?{as:pM,allowPinchZoom:!0}:void 0,_=He(B=>{var de,Ae;const H=P.current+B,ue=N().filter(ne=>!ne.disabled),re=document.activeElement,ie=(de=ue.find(ne=>ne.ref.current===re))==null?void 0:de.textValue,Ne=ue.map(ne=>ne.textValue),Z=BS(Ne,H,ie),ce=(Ae=ue.find(ne=>ne.textValue===Z))==null?void 0:Ae.ref.current;He(function ne(be){P.current=be,window.clearTimeout(E.current),be!==""&&(E.current=window.setTimeout(()=>ne(""),1e3))},"updateSearch")(H),ce&&setTimeout(()=>ce.focus())},"handleTypeaheadSearch");h.useEffect(()=>()=>window.clearTimeout(E.current),[]),dd();const q=h.useCallback(B=>{var ue,re;return T.current===((ue=$.current)==null?void 0:ue.side)&&WS(B,(re=$.current)==null?void 0:re.area)},[]);return n.jsx(dM,{scope:r,searchRef:P,onItemEnter:h.useCallback(B=>{q(B)&&B.preventDefault()},[q]),onItemLeave:h.useCallback(B=>{var H;q(B)||((H=C.current)==null||H.focus(),S(null))},[q]),onTriggerLeave:h.useCallback(B=>{q(B)&&B.preventDefault()},[q]),pointerGraceTimerRef:L,onPointerGraceIntentChange:h.useCallback(B=>{$.current=B},[]),children:n.jsx(U,{...K,children:n.jsx(Zk,{asChild:!0,trapped:a,onMountAutoFocus:Ee(l,B=>{var H;B.preventDefault(),(H=C.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:n.jsx(ug,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:p,onDismiss:j,children:n.jsx(mS,{asChild:!0,...v,dir:x.dir,orientation:"vertical",loop:i,currentTabStopId:b,onCurrentTabStopIdChange:S,onEntryFocus:Ee(u,B=>{x.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(Uk,{role:"menu","aria-orientation":"vertical","data-state":Ig(g.open),"data-radix-menu-content":"",dir:x.dir,...y,...k,ref:R,style:{outline:"none",...k.style},onKeyDown:Ee(k.onKeyDown,B=>{const ue=B.target.closest("[data-radix-menu-content]")===B.currentTarget,re=B.ctrlKey||B.altKey||B.metaKey,ie=B.key.length===1;ue&&(B.key==="Tab"&&B.preventDefault(),!re&&ie&&_(B.key));const Ne=C.current;if(B.target!==Ne||!nM.includes(B.key))return;B.preventDefault();const ce=N().filter(de=>!de.disabled).map(de=>de.ref.current);NS.includes(B.key)&&ce.reverse(),FS(ce)}),onBlur:Ee(t.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(E.current),P.current="")}),onPointerMove:Ee(t.onPointerMove,Na(B=>{const H=B.target,ue=M.current!==B.clientX;if(B.currentTarget.contains(H)&&ue){const re=B.clientX>M.current?"right":"left";T.current=re,M.current=B.clientX}}))})})})})})})},"MenuContentImpl")),PS=h.forwardRef(He(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(mt.div,{role:"group",...i,ref:s})},"MenuGroup")),gM=h.forwardRef(He(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(mt.div,{...i,ref:s})},"MenuLabel")),xm="MenuItem",Gj="menu.itemSelect",MS=h.forwardRef(He(function(t,s){const{disabled:r=!1,onSelect:i,...a}=t,l=h.useRef(null),o=yo(xm,t.__scopeMenu),c=Tg(xm,t.__scopeMenu),u=rt(s,l),f=h.useRef(!1),d=He(()=>{const m=l.current;if(!r&&m){const p=new CustomEvent(Gj,{bubbles:!0,cancelable:!0});m.addEventListener(Gj,j=>i==null?void 0:i(j),{once:!0}),nd(m,p),p.defaultPrevented?f.current=!1:o.onClose()}},"handleSelect");return n.jsx($S,{...a,ref:u,disabled:r,onClick:Ee(t.onClick,d),onPointerDown:m=>{var p;(p=t.onPointerDown)==null||p.call(t,m),f.current=!0},onPointerUp:Ee(t.onPointerUp,m=>{var p;f.current||(p=m.currentTarget)==null||p.click()}),onKeyDown:Ee(t.onKeyDown,m=>{r||m.target!==m.currentTarget||c.searchRef.current!==""&&m.key===" "||gm.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})},"MenuItem")),$S=h.forwardRef(He(function(t,s){const{__scopeMenu:r,disabled:i=!1,textValue:a,...l}=t,o=Tg(xm,r),c=ES(r),u=h.useRef(null),f=rt(s,u),[d,m]=h.useState(!1),[p,j]=h.useState("");return h.useEffect(()=>{const w=u.current;w&&j((w.textContent??"").trim())},[l.children]),n.jsx(no.ItemSlot,{scope:r,disabled:i,textValue:a??p,children:n.jsx(pS,{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:Ee(t.onPointerMove,Na(w=>{i?o.onItemLeave(w):(o.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ee(t.onPointerLeave,Na(w=>o.onItemLeave(w))),onFocus:Ee(t.onFocus,()=>m(!0)),onBlur:Ee(t.onBlur,()=>m(!1))})})})},"MenuItemImpl")),xM="MenuRadioGroup",[vM,jM]=Ai(xM,{value:void 0,onValueChange:He(()=>{},"onValueChange")}),yM=h.forwardRef(He(function(t,s){const{value:r,onValueChange:i,...a}=t,l=Zn(i);return n.jsx(vM,{scope:t.__scopeMenu,value:r,onValueChange:l,children:n.jsx(PS,{...a,ref:s})})},"MenuRadioGroup")),wM="MenuRadioItem",bM=h.forwardRef(He(function(t,s){const{value:r,...i}=t,a=jM(wM,t.__scopeMenu),l=r===a.value;return n.jsx(SM,{scope:t.__scopeMenu,checked:l,children:n.jsx(MS,{role:"menuitemradio","aria-checked":l,...i,ref:s,"data-state":LS(l),onSelect:Ee(i.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),kM="MenuItemIndicator",[SM,HW]=Ai(kM,{checked:!1}),NM=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")),DS="MenuSub",[CM,_S]=Ai(DS),EM=He(e=>{const{__scopeMenu:t,children:s,open:r=!1,onOpenChange:i}=e,a=zr(DS,t),l=gd(t),[o,c]=h.useState(null),[u,f]=h.useState(null),d=Zn(i);return h.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),n.jsx(jg,{...l,children:n.jsx(AS,{scope:t,open:r,onOpenChange:d,content:u,onContentChange:f,children:n.jsx(CM,{scope:t,contentId:ls(),triggerId:ls(),trigger:o,onTriggerChange:c,children:s})})})},"MenuSub"),ac="MenuSubTrigger",AM=h.forwardRef(He(function(t,s){const r=zr(ac,t.__scopeMenu),i=yo(ac,t.__scopeMenu),a=_S(ac,t.__scopeMenu),l=Tg(ac,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=rt(s,a.onTriggerChange);return n.jsx(TS,{asChild:!0,...f,children:n.jsx($S,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?a.contentId:void 0,"data-state":Ig(r.open),...t,ref:m,onClick:p=>{var j;(j=t.onClick)==null||j.call(t,p),!(t.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Ee(t.onPointerMove,Na(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:Ee(t.onPointerLeave,Na(p=>{var w,k;d();const j=(w=r.content)==null?void 0:w.getBoundingClientRect();if(j){const g=(k=r.content)==null?void 0:k.dataset.side,x=g==="right",y=x?-5:5,v=j[x?"left":"right"],N=j[x?"right":"left"];l.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:v,y:j.top},{x:N,y:j.top},{x:N,y:j.bottom},{x:v,y:j.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:Ee(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")),TM="MenuSubContent",RM=h.forwardRef(He(function(t,s){const r=IS(os,t.__scopeMenu),{forceMount:i=r.forceMount,align:a="start",...l}=t,o=zr(os,t.__scopeMenu),c=yo(os,t.__scopeMenu),u=_S(TM,t.__scopeMenu),f=h.useRef(null),d=rt(s,f);return n.jsx(no.Provider,{scope:t.__scopeMenu,children:n.jsx(ir,{present:i||o.open,children:n.jsx(no.Slot,{scope:t.__scopeMenu,children:n.jsx(Rg,{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:Ee(t.onFocusOutside,m=>{m.target!==u.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ee(t.onEscapeKeyDown,m=>{c.onClose(),m.preventDefault()}),onKeyDown:Ee(t.onKeyDown,m=>{var w;const p=m.currentTarget.contains(m.target),j=rM[c.dir].includes(m.key);p&&j&&(o.onOpenChange(!1),(w=u.trigger)==null||w.focus(),m.preventDefault())})})})})})},"MenuSubContent"));function Ig(e){return e?"open":"closed"}He(Ig,"getOpenState");function OS(e){return e==="indeterminate"}He(OS,"isIndeterminate");function LS(e){return OS(e)?"indeterminate":e?"checked":"unchecked"}He(LS,"getCheckedState");function FS(e){const t=document.activeElement;for(const s of e)if(s===t||(s.focus(),document.activeElement!==t))return}He(FS,"focusFirst");function US(e,t){return e.map((s,r)=>e[(t+r)%e.length])}He(US,"wrapArray");function BS(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=US(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(BS,"getNextMatch");function zS(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(zS,"isPointInPolygon");function WS(e,t){if(!t)return!1;const s={x:e.clientX,y:e.clientY};return zS(s,t)}He(WS,"isPointerInGraceArea");function Na(e){return t=>t.pointerType==="mouse"?e(t):void 0}He(Na,"whenMouse");var IM=oM,PM=TS,MM=uM,$M=hM,DM=PS,_M=gM,OM=MS,LM=yM,FM=bM,UM=NM,BM=EM,zM=AM,WM=RM,HM=Object.defineProperty,Ln=(e,t)=>HM(e,"name",{value:t,configurable:!0}),Pg="DropdownMenu",[VM,VW]=hs(Pg,[CS]),Fn=CS(),[KM,HS]=VM(Pg),GM=Ln(e=>{const{__scopeDropdownMenu:t,children:s,dir:r,open:i,defaultOpen:a,onOpenChange:l,modal:o=!0}=e,c=Fn(t),u=h.useRef(null),[f,d]=Si({prop:i,defaultProp:a??!1,onChange:l,caller:Pg});return n.jsx(KM,{scope:t,triggerId:ls(),triggerRef:u,contentId:ls(),open:f,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(m=>!m),[d]),modal:o,children:n.jsx(IM,{...c,open:f,onOpenChange:d,dir:r,modal:o,children:s})})},"DropdownMenu"),YM="DropdownMenuTrigger",qM=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,disabled:i=!1,...a}=t,l=HS(YM,r),o=Fn(r),c=rt(s,l.triggerRef);return n.jsx(PM,{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:Ee(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(l.onOpenToggle(),l.open||u.preventDefault())}),onKeyDown:Ee(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&l.onOpenToggle(),u.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),QM=Ln(e=>{const{__scopeDropdownMenu:t,...s}=e,r=Fn(t);return n.jsx(MM,{...r,...s})},"DropdownMenuPortal"),JM="DropdownMenuContent",XM=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=HS(JM,r),l=Fn(r),o=h.useRef(!1);return n.jsx($M,{id:a.contentId,"aria-labelledby":a.triggerId,...l,...i,ref:s,onCloseAutoFocus:Ee(t.onCloseAutoFocus,c=>{var u;o.current||(u=a.triggerRef.current)==null||u.focus(),o.current=!1,c.preventDefault()}),onInteractOutside:Ee(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")),ZM=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(DM,{...a,...i,ref:s})},"DropdownMenuGroup")),e$=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(_M,{...a,...i,ref:s})},"DropdownMenuLabel")),t$=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(OM,{...a,...i,ref:s})},"DropdownMenuItem")),n$=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(LM,{...a,...i,ref:s})},"DropdownMenuRadioGroup")),s$=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(FM,{...a,...i,ref:s})},"DropdownMenuRadioItem")),r$=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(UM,{...a,...i,ref:s})},"DropdownMenuSeparator")),i$=Ln(e=>{const{__scopeDropdownMenu:t,children:s,open:r,onOpenChange:i,defaultOpen:a}=e,l=Fn(t),[o,c]=Si({prop:r,defaultProp:a??!1,onChange:i,caller:"DropdownMenuSub"});return n.jsx(BM,{...l,open:o,onOpenChange:c,children:s})},"DropdownMenuSub"),a$=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(zM,{...a,...i,ref:s})},"DropdownMenuSubTrigger")),l$=h.forwardRef(Ln(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Fn(r);return n.jsx(WM,{...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")),Mg=GM,$g=qM,xd=QM,Dg=XM,VS=ZM,vd=e$,ma=t$,o$=n$,c$=s$,ai=r$,u$=i$,d$=a$,h$=l$,f$=Object.defineProperty,za=(e,t)=>f$(e,"name",{value:t,configurable:!0}),_g="Tabs",[m$,KW]=hs(_g,[fd]),KS=fd(),[p$,Og]=m$(_g),g$=h.forwardRef(za(function(t,s){const{__scopeTabs:r,value:i,onValueChange:a,defaultValue:l,orientation:o="horizontal",dir:c,activationMode:u="automatic",...f}=t,d=ud(c),[m,p]=Si({prop:i,onChange:a,defaultProp:l??"",caller:_g});return n.jsx(p$,{scope:r,baseId:ls(),value:m,onValueChange:p,orientation:o,dir:d,activationMode:u,children:n.jsx(mt.div,{dir:d,"data-orientation":o,...f,ref:s})})},"Tabs")),x$="TabsList",v$=h.forwardRef(za(function(t,s){const{__scopeTabs:r,loop:i=!0,...a}=t,l=Og(x$,r),o=KS(r);return n.jsx(mS,{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")),j$="TabsTrigger",y$=h.forwardRef(za(function(t,s){const{__scopeTabs:r,value:i,disabled:a=!1,...l}=t,o=Og(j$,r),c=KS(r),u=Lg(o.baseId,i),f=Fg(o.baseId,i),d=i===o.value;return n.jsx(pS,{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:Ee(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(i):m.preventDefault()}),onKeyDown:Ee(t.onKeyDown,m=>{a||m.target!==m.currentTarget||[" ","Enter"].includes(m.key)&&o.onValueChange(i)}),onFocus:Ee(t.onFocus,()=>{const m=o.activationMode!=="manual";!d&&!a&&m&&o.onValueChange(i)})})})},"TabsTrigger")),w$="TabsContent",b$=h.forwardRef(za(function(t,s){const{__scopeTabs:r,value:i,forceMount:a,children:l,...o}=t,c=Og(w$,r),u=Lg(c.baseId,i),f=Fg(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(ir,{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 Lg(e,t){return`${e}-trigger-${t}`}za(Lg,"makeTriggerId");function Fg(e,t){return`${e}-content-${t}`}za(Fg,"makeContentId");var k$=g$,S$=v$,N$=y$,C$=b$;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 De(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 E$(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 A$(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 Tt(e){return new Intl.NumberFormat("en-US").format(e)}function vm(e){return[...e.cacheRead?[`cached ${Tt(e.cacheRead)}`]:[],...e.cacheWrite?[`cache write ${Tt(e.cacheWrite)}`]:[]].join(", ")}function T$(e){const t=vm(e);return`${Tt(e.input)} in${t?` (${t})`:""} / ${Tt(e.output)} out`}function kn(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function so(e,t=8){return e.length<=t?e:e.slice(0,t)}function Ps(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Ca(e){return e.replace(/<<<[^<>]*>>>/g,"")}function It(e,t,s){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?R$(r,s):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${Yj(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Tt(r):Yj(r):String(e)}case"date":return I$(String(e));default:return typeof e=="string"?e:typeof e=="number"?Tt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function R$(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return A$(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function I$(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 jm(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 Yj(e){return String(Math.round(e*100)/100)}function Su(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 P$({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:It(a.value,e.unit,e.currency)})]},a.category)})})}const M$=/^(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 )/,$$=/^(… |\.\.\. |\(no change\)$|\)/;function D$(e){return e.replace(/\n$/,"").split(`
81
+ `).map(s=>({kind:_$(s),text:s}))}function _$(e){return e.startsWith("@@")?"hunk":M$.test(e)||$$.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function O$({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 Nu({text:e,limit:t,more:s,label:r="Diff",marks:i}){const a=D$(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(O$,{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 L$({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:It(t.value,t.unit,null)})]},t.label))}):null,e.diff?n.jsx(Nu,{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 zt="#/",Cr="#/chat",ut="#/agents",jt="#/activity",pn="#/settings",vi="#/files",F$="#/welcome";function Wc(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function lc(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`${vi}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function U$(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 B$(e){if(GS(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 Cl(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function GS(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 z$(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 Ea(e){return`${jt}/conversations/${encodeURIComponent(e)}`}const W$="#/p";function ji(e,t,s){const r=`${W$}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return s?`${r}/${encodeURIComponent(s)}`:r}function Ug(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 H$="p.";function wo(e,t){return`${pn}/${encodeURIComponent(YS(e,t))}`}function V$(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 YS(e,t){return`${H$}${e}${t===e?"":`.${t}`}`}function tt(e){return e?`${pn}/${e}`:pn}function K$(e){return`${tt("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function G$(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}const Y$=[{route:zt,label:"Home"},{route:Cr,label:"Chat"},{route:ut,label:"Agents"},{route:jt,label:"Activity"},{route:vi,label:"Files"},{route:pn,label:"Settings"}],q$=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],Q$=[{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 J$(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const qj=tt("backup");function X$(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return Ea(decodeURIComponent(t[1]));const s=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(s)try{return ji("email","mail",s[1]?decodeURIComponent(s[1]):null)}catch{return ji("email","mail")}return e==="#/settings/email"?wo("email","settings"):{"#/overview":zt,"#/approvals":zt,"#/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 qS(e){if(e===""||e==="#"||e===zt)return zt;if(e.startsWith(Cr))return Cr;if(e.startsWith(ut))return ut;if(e.startsWith(jt))return jt;if(e.startsWith(vi))return vi;if(e.startsWith(pn))return pn;const t=Ug(e);return t?ji(t.plugin,t.page):zt}const Z$="#/chat?group=new";function eD(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 Bg="front-desk",zg=[{id:Bg,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."}],QS=new Set(zg.map(e=>e.id)),Qj=e=>QS.has(e);function Jj(e,t){const s=t.filter(r=>!QS.has(r));return[...zg.filter(r=>e.has(r.id)).map(r=>r.id),...s.filter((r,i)=>s.indexOf(r)===i)]}function tD(e,t){return e.find(s=>(s.roles??[]).includes(t))}const Xj=["coding","finance","mail","research","calendar","files","memory"],nD={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[Bg]:"buddi"},sD=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function rD(e){const t=new Set(e.map(s=>s.split(".")[0]??s));for(const[s,r]of sD)if(r.some(i=>t.has(i)))return s;return t.size>0&&[...t].every(s=>s==="memory")?"memory":null}let ym=null;function iD(e){ym=e}function bo(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=nD[s];if(r)return{key:r}}const t=rD(e.tools??[]);return t?{key:t}:ym!==null&&e.id===ym?{key:"buddi"}:{key:Xj[aD(e.id)%Xj.length]??"coding"}}function ko(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 lD=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function oD(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:lD.includes(o)?o:"ping",data:cD(c.join(`
86
+ `))})}return{events:i,rest:r}}function cD(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function jd(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 j=await t(e.url,{credentials:"same-origin",signal:o.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!j.ok||!j.body)throw new Error(`stream ${j.status}`);(f=e.onStatus)==null||f.call(e,"open"),l&&((d=e.onReconnect)==null||d.call(e));const w=j.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:v,rest:N}=oD(g);g=N;for(const b of v)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 Wg="0.1.0+e2b040b";function Hg(e,t=Wg){return typeof e=="string"&&e!==""&&typeof t=="string"&&t!==""&&e!==t}function uD(){var e;try{if((e=window.matchMedia)!=null&&e.call(window,"(display-mode: standalone)").matches)return!0}catch{}return window.navigator.standalone===!0}const dD=5*6e4,hD=6e4,fD=5e3,wm="buddi:stream-reconnected",JS="buddi.autoReloadedFor";function mD(){window.dispatchEvent(new Event(wm))}const Zj=["keydown","pointerdown","pointermove","wheel","touchstart","input"];let Vg=Date.now(),oc=0;const ey=()=>{Vg=Date.now()};function pD(){if(oc===0){Vg=Date.now();for(const e of Zj)window.addEventListener(e,ey,{capture:!0,passive:!0})}return oc+=1,()=>{if(oc-=1,oc===0)for(const e of Zj)window.removeEventListener(e,ey,{capture:!0})}}function gD(e=Date.now()){return e-Vg}function xD(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 vD(e){return e.hidden?!0:e.idleMs>=hD&&!e.busy}function jD(e){try{return window.sessionStorage.getItem(JS)===e}catch{return!1}}function yD(e){try{window.sessionStorage.setItem(JS,e)}catch{}}function wD(e){const t=h.useRef(e);t.current=e,h.useEffect(()=>{const s=()=>t.current();return window.addEventListener(wm,s),()=>window.removeEventListener(wm,s)},[])}function bD(e,t=()=>window.location.reload(),s=Wg){const r=Hg(e,s),i=h.useRef(t);i.current=t,h.useEffect(()=>pD(),[]),h.useEffect(()=>{if(!r||e===void 0||jD(e))return;let a=!1;const l=()=>{if(a)return;const c=document.visibilityState==="hidden";vD({hidden:c,idleMs:gD(),busy:xD()})&&(a=!0,yD(e),i.current())};l();const o=window.setInterval(l,fD);return document.addEventListener("visibilitychange",l),()=>{window.clearInterval(o),document.removeEventListener("visibilitychange",l)}},[r,e])}const kD="/api/chat/attention/stream";function XS(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 ZS(e,t){const s=XS(e,t);return[...s.top,...s.middle,...s.bottom]}function yd(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 SD(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function ND(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function CD(){const[e,t]=h.useState(null);return h.useEffect(()=>{let s=!1;const r=()=>{le("/chat/attention").then(a=>{s||t(a)}).catch(()=>{})};r();const i=jd({url:kD,onEvent:()=>r(),onReconnect:mD});return()=>{s=!0,i.close()}},[]),ND(e)}const wd="maker";function eN(e){return e.filter(t=>t.available&&!t.roles.includes(wd))}function tN(e){return eN(e).length>=2}function ED(e){var t;return((t=e.find(s=>s.roles.includes(wd)))==null?void 0:t.name)??"the agent maker"}const AD="{{default}}";function TD(e,t){return e.split(AD).join(t??"your assistant")}function RD(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(s=>TD(s,t))}function ID(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 PD(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 nN(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 MD="Settings → Model accounts",$D="Install it in Settings → Plugins";function bm(e){return e!=null&&e.heldBack?{section:"plugins",label:$D}:{section:"accounts",label:MD}}const DD={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"})],"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]=DD[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 sN="buddi.rosterCollapsed";function _D(){try{return window.localStorage.getItem(sN)==="1"}catch{return!1}}function OD(e){try{window.localStorage.setItem(sN,e?"1":"0")}catch{}}function rN({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(_D),j=w=>n.jsx(LD,{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(j),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(j),c&&tN(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(Kg,{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(j),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=>(OD(!w),!w)),children:n.jsx(Se,{name:m?"chevron-right":"chevron-left"})}):null]})}function LD({agent:e,active:t,attention:s,side:r,onSelect:i,lastAt:a=null}){const l=yd(s),o=l?ty(l):e.available?a?`Last spoke ${De(a)}`:e.description:e.unavailableReason??"Cannot run right now",c=SD(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(Jl,{children:[n.jsx(Xl,{asChild:!0,children:n.jsxs("button",{className:"wb-face",...ko(bo(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(Kg,{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(Zl,{children:n.jsxs(eo,{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:ty(l)}):null]})})]})}function ty(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function FD(e){let t=0;for(const s of e)t=(t*31+s.charCodeAt(0))%997;return t%6+1}const UD="modulepreload",BD=function(e,t){return new URL(e,t).href},ny={},zD=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=BD(u,r),u in ny)return;ny[u]=!0;const f=u.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(!!r)for(let j=l.length-1;j>=0;j--){const w=l[j];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":UD,f||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),f)return new Promise((j,w)=>{p.addEventListener("load",j),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)})},WD="buddi",HD=["core","coding","finance","garage","mail","maker","playground","research"],Wr=e=>`./mascot/${e}.png`,VD=["core"],km=(e,t)=>VD.includes(e)?`./mascot/anim/${e}-${t}.json`:null,KD=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],GD="Introduce yourself by name and say one thing you can do today.",F={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 cc=null;const sy=new Map;function YD(){return cc??(cc=zD(()=>import("./lottie_light-e1djomjW.js").then(e=>e.l),[],import.meta.url).then(e=>e.default)),cc.catch(()=>{cc=null}),cc}function qD(e){let t=sy.get(e);return t||(t=fetch(e).then(s=>s.ok?s.text():null).catch(()=>null),sy.set(e,t)),t}const ry="(prefers-reduced-motion: reduce)";function iN(){const[e,t]=h.useState(()=>typeof window.matchMedia=="function"&&!window.matchMedia(ry).matches);return h.useEffect(()=>{var i;if(typeof window.matchMedia!="function")return;const s=window.matchMedia(ry),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 bd({role:e="core",state:t,size:s,still:r,className:i,onStillError:a}){const l=h.useRef(null),o=iN(),[c,u]=h.useState(!1),f=s==="xs"?null:km(e,t);return h.useEffect(()=>{if(u(!1),!o||!f)return;let d=!1,m=null;return Promise.all([YD(),qD(f)]).then(([p,j])=>{if(d||!j||!l.current)return;const w=p.loadAnimation({container:l.current,renderer:"svg",loop:!0,autoplay:!document.hidden,animationData:JSON.parse(j),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??Wr(e),alt:"",onError:a})})}async function iy(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 aN(e,t="core"){const s=iN(),r=e!==null&&QD(e,t),[i,a]=h.useState(!1);return h.useEffect(()=>{if(a(!1),!e||r||!s||!km(t,"idle"))return;let l=!1;return Promise.all([iy(e),iy(Wr(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&&km(t,"idle")!==null&&(r||i)}function QD(e,t){const s=Wr(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 Kg({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?ko(bo({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:PD(s).slice(0,o)})}function ms({id:e,name:t,size:s,unavailable:r,face:i}){return n.jsx(Kg,{className:"ui-avatar",id:e,tint:FD(e),name:t,size:s,unavailable:r,face:i})}function xn({agents:e,id:t,size:s}){const r=e.find(i=>i.id===t);return n.jsx(ms,{id:t,name:(r==null?void 0:r.name)??t,size:s,unavailable:r?!r.available:!1,face:r})}const lN=h.createContext(null);function JD({picture:e,children:t}){return n.jsx(lN.Provider,{value:e??null,children:t})}function oN({size:e,anim:t}){const s=h.useContext(lN),[r,i]=h.useState(null),a=aN(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(bd,{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 tr({text:e,className:t}){const s=Sm(e.replace(/\r\n/g,`
88
+ `).split(`
89
+ `));return n.jsx("div",{className:t??"wb-md",children:s.map((r,i)=>n.jsx(Nm,{block:r},i))})}const ay=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,ly=/^(#{1,6})\s+(.*?)\s*#*\s*$/,oy=/^\s*([-*_])(\s*\1){2,}\s*$/,uc=/^(\s*)([-*+])\s+(.*)$/,al=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,dc=/^\s*>\s?(.*)$/,Sh=/^\s*\|.*\|\s*$/,cy=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function Sm(e){const t=[];let s=0;for(;s<e.length;){const r=e[s];if(r.trim()===""){s+=1;continue}const i=ay.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=ly.exec(r);if(a){t.push({type:"h",level:a[1].length,text:a[2]}),s+=1;continue}if(oy.test(r)){t.push({type:"hr"}),s+=1;continue}if(dc.test(r)){const o=[];for(;s<e.length&&dc.test(e[s]);)o.push(dc.exec(e[s])[1]),s+=1;t.push({type:"quote",blocks:Sm(o),raw:o.join(`
91
+ `)});continue}if(Sh.test(r)&&s+1<e.length&&cy.test(e[s+1])){const o=Ch(r),c=Ch(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&&Sh.test(e[s]);)u.push(Ch(e[s])),s+=1;t.push({type:"table",head:o,rows:u,align:c});continue}if(uc.test(r)||al.test(r)){const o=al.exec(r)??uc.exec(r),c=al.test(r),u=o[1].length,f=c?Number(o[2]):1,d=[];for(;s<e.length;){const m=c?al.exec(e[s]):uc.exec(e[s]);if(!m||m[1].length!==u)break;const p=[m[3]];for(s+=1;s<e.length;){const j=e[s],w=j.trim()!==""&&Nh(j)>u,k=j.trim()===""&&s+1<e.length&&e[s+1].trim()!==""&&Nh(e[s+1])>u;if(!w&&!k)break;p.push(j.trim()===""?"":j.slice(Math.min(Nh(j),u+2))),s+=1}d.push(Sm(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()===""||ay.test(o)||ly.test(o)||oy.test(o)||dc.test(o)||uc.test(o)||al.test(o)||Sh.test(o)&&s+1<e.length&&cy.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 Nh(e){return e.length-e.trimStart().length}function Ch(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 Nm({block:e}){switch(e.type){case"p":return n.jsx("p",{children:rs(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:rs(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(uy,{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(Nm,{block:t},s))}),n.jsx(uy,{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:rs(i.text)},a):n.jsx(Nm,{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:rs(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:rs(r)},i))},s))})]})})}}function uy({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 XD({handle:e}){const s=h.useContext(cN).find(r=>r.handle.toLowerCase()===e.toLowerCase());return s?n.jsxs(Jl,{children:[n.jsx(Xl,{asChild:!0,children:n.jsxs("a",{className:"wb-mention-link",href:Ke(s.id),children:["@",s.handle]})}),n.jsx(Zl,{children:n.jsxs(eo,{className:"wb-agent-card",sideOffset:6,children:[n.jsx(ms,{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 ZD=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 rs(e){const t=[];let s=e,r=0;for(;s!=="";){const i=ZD.exec(s);if(!i){t.push(...dy(s,r));break}i.index>0&&t.push(...dy(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:rs(i[3])},r)):i[4]!==void 0?t.push(n.jsx("strong",{children:rs(i[4])},r)):i[5]!==void 0?t.push(n.jsx("s",{children:rs(i[5])},r)):i[6]!==void 0?t.push(n.jsx("em",{children:rs(i[6])},r)):i[7]!==void 0?t.push(n.jsx("em",{children:rs(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:rs(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(XD,{handle:i[11]},r)),s=s.slice(i.index+i[0].length)}return t}function dy(e,t){return e.split(`
93
+ `).flatMap((r,i)=>i===0?[r]:[n.jsx("br",{},`${t}-br-${i}`),r])}function e_({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:It(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(tr,{text:e.text})}):n.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}const t_=["mail","money","calendar","people","file","chart","bell","plug","key","globe","sun","partly-cloudy","cloud","rain","drizzle","snow","storm","fog","wind","moon-clear"];function he(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 Re(e,t){if(t)return"const"in t?t.const:he(e,t.path)}function Mn(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 Er(e){return Array.isArray(e)?e:[]}function n_(e,t){const s=Er(he(e,t.points)).map(i=>{const a=Mn(he(i,t.y)),l=Ye(he(i,t.x));return a===null||l===null?null:{x:l,y:a}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const a=Mn(Re(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(Re(e,t.currency)),label:Ye(Re(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:Mn(Re(e,t.shadeBelow)),events:s_(e,t)}}function s_(e,t){const s=t.events;if(!s)return[];const r=[],i=(a,l)=>{const o=Ye(he(a,s.label));if(o===null)return;const c=Ye(he(a,s.at))??l;c!==null&&r.push({at:c,label:o,amount:s.amount?Mn(he(a,s.amount)):null})};if(s.parent){for(const a of Er(he(e,t.points))){const l=Ye(he(a,t.x));for(const o of Er(he(a,s.parent)))i(o,l)}return r}for(const a of Er(he(e,s.path??t.points)))i(a,null);return r}function r_(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=he(o,c.key);let f=null;if(c.bar){const d=Mn(Re(o,c.bar.max))??Mn(Re(e,c.bar.max)),m=Mn(u);if(d!==null&&d>0&&m!==null){const p=Math.max(0,Math.min(1,m/d));f={fraction:p,tone:a_(p*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:Ye(Re(o,c.currency))??Ye(Re(e,c.currency)),bar:f}}),i=Er(he(e,t.rows)),a=t.groupBy?i_(i,t.groupBy,r):[{label:null,rows:i.map(r)}],l=(t.summary??[]).map(o=>({label:o.label,value:Re(e,o.value),unit:o.unit??"text",currency:Ye(Re(e,o.currency)),tone:o.tone??"neutral"}));return{columns:s,groups:a,summary:l,empty:t.empty??"Nothing to show."}}function i_(e,t,s){const r=new Map;for(const i of e){const a=String(he(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 a_(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 l_(e,t){return{bars:Er(he(e,t.bars)).map(r=>{const i=Mn(he(r,t.value)),a=Ye(he(r,t.category));return i===null||a===null?null:{category:a,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:Ye(Re(e,t.currency))}}function o_(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:Re(e,r.value),unit:r.unit??"text",currency:Ye(Re(e,r.currency)),tone:r.tone??"neutral"}))};const s=he(e,t.from??"$");return s===null||typeof s!="object"||Array.isArray(s)?{pairs:[]}:{pairs:Object.entries(s).map(([r,i])=>({label:on(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}const c_=new Set(["good","warning","critical","neutral","accent"]),u_=new Set(t_);function Cm(e){return typeof e=="string"&&u_.has(e)?e:null}function Gg(e,t,s=""){const r=t.empty??"Nothing to show.",i=s.split(".")[0]??"";if(t.notice){const l=Ye(he(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:Cm(t.notice.icon??"bell"),value:"",label:l.trim(),lines:[],tone:"neutral",link:o}],notice:!0,empty:r}}}return{tiles:Er(he(e,t.items)).map(l=>{const o=Ye(he(l,t.value))??"",c=Ye(he(l,t.label))??"";if(o===""&&c==="")return null;const u=t.tone?Ye(he(l,t.tone)):null;return{icon:Cm(Re(l,t.icon)),value:o,label:c,lines:(t.lines??[]).slice(0,2).map(f=>Ye(he(l,f))).filter(f=>f!==null&&f.trim()!==""),tone:u!==null&&c_.has(u)?u:"neutral",link:null}}).filter(l=>l!==null),notice:!1,empty:r}}function d_(e,t){const s=Ye(Re(e,t.kind)),r=s==="image"||s==="pdf"?s:"text",i=t.src?Ye(he(e,t.src)):null;return{kind:r,text:t.text?Ye(he(e,t.text)):null,src:i&&dN(i)?i:null,title:Ye(Re(e,t.title)),metadata:(t.metadata??[]).map(a=>({label:a.label,value:Re(e,a.value),unit:a.unit??"text"}))}}function h_(e,t){const s=t.diff?he(e,t.diff):void 0;return{diff:typeof s=="string"&&s.trim()!==""?s:null,title:Ye(Re(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:Re(e,r.value),unit:r.unit??"text"}))}}function f_(e,t){const s=t.output?he(e,t.output):void 0,r=l=>{const o=l?he(e,l):void 0;return typeof o=="number"&&Number.isInteger(o)?o:null},i=r(t.omittedBytes),a=t.elapsedMs?he(e,t.elapsedMs):void 0;return{command:Ye(Re(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:Re(e,l.value),unit:l.unit??"text"}))}}const m_=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function uN(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&m_.test(t)?t.toLowerCase():null}function p_(e,t){return{artifactId:t.src?uN(he(e,t.src)):null,title:Ye(Re(e,t.title)),caption:Ye(Re(e,t.caption)),...t.captionLabel?{captionLabel:Ye(Re(e,t.captionLabel))}:{}}}function hy(e){if(!dN(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 g_(e,t){const s=t.src?Ye(he(e,t.src)):null,r=t.port?he(e,t.port):null,i=t.awaiting?Ye(he(e,t.awaiting)):null;return{target:s?hy(s):null,title:Ye(Re(e,t.title)),output:t.output?Ye(he(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?hy(i):null,reloadsItself:t.reloadsItself?he(e,t.reloadsItself)===!0:!1,ports:t.ports?x_(he(e,t.ports)):[]}}function x_(e){const t=Er(e).filter(s=>typeof s=="number"&&Number.isInteger(s)&&s>0&&s<=65535);return[...new Set(t)].sort((s,r)=>s-r)}function dN(e){return e.startsWith("/")&&!e.startsWith("//")}function on(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 hN(e,t){const s=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:n_(t,s)};case"table":return{renderer:"table",props:r_(t,s)};case"bars":return{renderer:"bars",props:l_(t,s)};case"keyvalue":return{renderer:"keyvalue",props:o_(t,s)};case"tiles":return{renderer:"tiles",props:Gg(t,s,e.tool)};case"document":return{renderer:"document",props:d_(t,s)};case"diff":return{renderer:"diff",props:h_(t,s)};case"terminal":return{renderer:"terminal",props:f_(t,s)};case"image":return{renderer:"image",props:p_(t,s)};case"preview":return{renderer:"preview",props:g_(t,s)};default:return{renderer:"structured",props:{value:t}}}}var v_=Object.defineProperty,ps=(e,t)=>v_(e,"name",{value:t,configurable:!0}),Yg="Dialog",[fN,GW]=hs(Yg),[j_,lr]=fN(Yg),mN=ps(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]=Si({prop:r,defaultProp:i??!1,onChange:a,caller:Yg}),[d,m]=h.useState(0),[p,j]=h.useState(0);return n.jsx(j_,{scope:t,triggerRef:o,contentRef:c,contentId:ls(),titleId:ls(),descriptionId:ls(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:m,setDescriptionCount:j,open:u,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(w=>!w),[f]),modal:l,children:s})},"Dialog"),pN="DialogPortal",[y_,gN]=fN(pN,{forceMount:void 0}),xN=ps(e=>{const{__scopeDialog:t,forceMount:s,children:r,container:i}=e,a=lr(pN,t);return n.jsx(y_,{scope:t,forceMount:s,children:h.Children.map(r,l=>n.jsx(ir,{present:s||a.open,children:n.jsx(hg,{asChild:!0,container:i,children:l})}))})},"DialogPortal"),Em="DialogOverlay",w_=h.forwardRef(ps(function(t,s){const r=gN(Em,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,l=lr(Em,t.__scopeDialog);return l.modal?n.jsx(ir,{present:i||l.open,children:n.jsx(k_,{...a,ref:s})}):null},"DialogOverlay")),b_=Pr("DialogOverlay.RemoveScroll"),k_=h.forwardRef(ps(function(t,s){const{__scopeDialog:r,...i}=t,a=lr(Em,r),l=rk(),o=rt(s,l);return n.jsx(Ag,{as:b_,allowPinchZoom:!0,shards:[a.contentRef],children:n.jsx(mt.div,{"data-state":qg(a.open),...i,ref:o,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),ro="DialogContent",vN=h.forwardRef(ps(function(t,s){const r=gN(ro,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,l=lr(ro,t.__scopeDialog);return n.jsx(ir,{present:i||l.open,children:l.modal?n.jsx(S_,{...a,ref:s}):n.jsx(N_,{...a,ref:s})})},"DialogContent")),S_=h.forwardRef(ps(function(t,s){const r=lr(ro,t.__scopeDialog),i=h.useRef(null),a=rt(s,r.contentRef,i);return h.useEffect(()=>{const l=i.current;if(l)return xS(l)},[]),n.jsx(jN,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:Ee(t.onCloseAutoFocus,l=>{var o;l.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Ee(t.onPointerDownOutside,l=>{const o=l.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&l.preventDefault()}),onFocusOutside:Ee(t.onFocusOutside,l=>l.preventDefault())})},"DialogContentModal")),N_=h.forwardRef(ps(function(t,s){const r=lr(ro,t.__scopeDialog),i=h.useRef(!1),a=h.useRef(!1);return n.jsx(jN,{...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")),jN=h.forwardRef(ps(function(t,s){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:l,...o}=t,c=lr(ro,r);return dd(),n.jsx(n.Fragment,{children:n.jsx(Zk,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:l,children:n.jsx(ug,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":qg(c.open),...o,ref:s,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),C_="DialogTitle",yN=h.forwardRef(ps(function(t,s){const{__scopeDialog:r,...i}=t,a=lr(C_,r),{setTitleCount:l}=a;return wn(()=>(l(o=>o+1),()=>l(o=>o-1)),[l]),n.jsx(mt.h2,{id:a.titleId,...i,ref:s})},"DialogTitle")),E_="DialogClose",wN=h.forwardRef(ps(function(t,s){const{__scopeDialog:r,...i}=t,a=lr(E_,r);return n.jsx(mt.button,{type:"button",...i,ref:s,onClick:Ee(t.onClick,()=>a.onOpenChange(!1))})},"DialogClose"));function qg(e){return e?"open":"closed"}ps(qg,"getState");const A_=5;function se(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 j=!1;return c(!0),p.current().then(w=>{j||(i(w),l(null),m(0))}).catch(w=>{j||(l(w instanceof ae?w.message:String(w)),m(k=>k+1))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[...t,u]),h.useEffect(()=>{if(!s||d>=A_)return;const j=window.setTimeout(()=>f(w=>w+1),s*2**d);return()=>window.clearTimeout(j)},[s,d,u]),{data:r,error:a,loading:o,reload:()=>{m(0),f(j=>j+1)}}}const bN={width:480,height:160,top:10,right:10,bottom:22,left:40},kN={width:1200,height:180,top:10,right:40,bottom:22,left:40};function T_({xs:e,series:t}){const s=kN,r=s.width-s.left-s.right,i=s.height-s.top-s.bottom,a=$=>$.filter(T=>T!==null&&Number.isFinite(T)),l=t.filter($=>$.type!=="bar"),o=t.filter($=>$.type==="bar"),c=l.flatMap($=>a($.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-d)*.08;d-=$,m+=$}const p=$=>Gn(s.top+i-($-d)/(m-d)*i),j=o.length>0&&o.every($=>$.unit==="percent"),w=j?100:Math.max(1,...o.flatMap($=>a($.values))),k=$=>Gn(s.top+i-Math.max(0,$)/w*i),g=e.length,x=g>0?r/g:r,y=$=>Gn(s.left+x*($+.5)),v=t.map($=>{if($.type==="bar")return"";let T="M";const M=[];return $.values.forEach((U,K)=>{if(U===null||!Number.isFinite(U)){T="M";return}M.push(`${T}${y(K)},${p(U)}`),T="L"}),M.join(" ")}),N=[],b=x*.6/Math.max(1,o.length),S=s.height-s.bottom;let C=0;t.forEach(($,T)=>{if($.type!=="bar")return;const M=C++;$.values.forEach((U,K)=>{if(U===null||!Number.isFinite(U)||U<=0)return;const _=k(U);N.push({series:T,index:K,x:Gn(y(K)-x*.3+b*M),y:_,width:Gn(b),height:Gn(S-_)})})});const R=c.length>0?Su(u,f,2).map($=>({value:$,y:p($)})):[],E=o.length===0?[]:(j?[0,50,100]:Su(0,w,2)).map($=>({value:$,y:k($),percent:j})),P=Math.max(1,Math.ceil(g/8)),L=e.flatMap(($,T)=>T%P===0?[{index:T,x:y(T)}]:[]);return{lines:v,bars:N,targetY:null,ticks:R,xLabels:L,rightTicks:E}}function R_({xs:e,series:t,type:s="line",target:r=null}){const i=bN,a=i.width-i.left-i.right,l=i.height-i.top-i.bottom,o=t.flatMap(y=>y.values.filter(v=>v!==null&&Number.isFinite(v)));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=>Gn(i.top+l-(y-c)/(u-c)*l),d=e.length,m=d>0?a/d:a,p=y=>Gn(s==="bar"?i.left+m*(y+.5):i.left+(d<=1?a/2:y/(d-1)*a)),j=s==="line"?t.map(y=>{let v="M";const N=[];return y.values.forEach((b,S)=>{if(b===null||!Number.isFinite(b)){v="M";return}N.push(`${v}${p(S)},${f(b)}`),v="L"}),N.join(" ")}):[],w=[];if(s==="bar"&&d>0){const y=m*.7,v=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:Gn(i.left+m*R+(m-y)/2+v*S),y:Math.min(E,N),width:Gn(v),height:Gn(Math.abs(N-E))})})})}const g=(o.length>0?Su(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:j,bars:w,targetY:r!==null&&Number.isFinite(r)?f(r):null,ticks:g,xLabels:x.map(y=>({index:y,x:p(y)}))}}function I_(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 P_({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?kN:bN,u=o?T_({xs:e,series:t}):R_({xs:e,series:t,type:s,target:r}),f=I_({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 Gn(e){return Math.round(e*10)/10}function Ti(...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:Ti("ui-btn",s),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function Gt({variant:e,size:t,className:s,...r}){return n.jsx("a",{className:Ti("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:Ti("ui-toolbar",r),"data-align":t,"data-valign":s,children:e})}function Ms(){return n.jsx("span",{className:"ui-toolbar-spacer"})}function X({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 nr({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:Ti("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 ci({children:e}){return n.jsx("span",{className:"ui-tag",children:e})}function kd({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 W({tone:e,title:t,children:s,role:r}){return 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 te({message:e}){return e?n.jsx(W,{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(oN,{size:"sm"}),n.jsx("p",{children:i})]}):n.jsx("p",{className:"ui-empty",children:i})}function Pt({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 M_({children:e}){return n.jsx("div",{className:"ui-page",children:e})}function Qg({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 hn({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(M_,{children:[n.jsx(Qg,{title:t,lede:s,actions:r}),i]})}function Y({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 st({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 Dn({tone:e,title:t,meta:s,actions:r,children:i,foot:a,as:l="div"}){return n.jsxs(l,{className:"ui-card","data-tone":e,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 V({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 $_({children:e}){return n.jsx("div",{className:"ui-row",children:e})}function Sd({inline:e,children:t}){return n.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function Cs({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 Wt({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 Sn({children:e}){return n.jsx("div",{className:"ui-table-wrap",children:n.jsx("table",{className:"ui-table",children:e})})}function SN({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 Mt({summary:e,boxed:t,open:s,className:r,onToggle:i,children:a}){return n.jsxs("details",{className:Ti("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 tn({title:e,onClose:t,size:s,children:r}){return n.jsx(mN,{open:!0,onOpenChange:i=>{i||t()},children:n.jsxs(xN,{children:[n.jsx(w_,{className:"ui-sheet-overlay"}),n.jsxs(vN,{className:"ui-sheet","data-size":s,"aria-describedby":void 0,children:[n.jsxs("div",{className:"ui-sheet-head",children:[n.jsx(yN,{className:"ui-sheet-title",children:e}),n.jsx(wN,{asChild:!0,children:n.jsx(I,{size:"sm",children:"Close"})})]}),r]})]})})}function D_({title:e,actions:t,onClose:s,onCloseAutoFocus:r,onOpenAutoFocus:i,label:a,children:l}){return n.jsx(mN,{open:!0,modal:!1,onOpenChange:o=>{o||s()},children:n.jsx(xN,{children:n.jsxs(vN,{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(yN,{className:"ui-dock-title",children:e}),n.jsxs("div",{className:"ui-dock-actions",children:[t,n.jsx(wN,{asChild:!0,children:n.jsx(I,{size:"sm",variant:"ghost",children:"Close"})})]})]}),n.jsx("div",{className:"ui-dock-body",children:l})]})})})}function Nd({level:e,label:t,children:s}){return n.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:s})}function Cd({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 Ar({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 Ht({children:e}){return n.jsx("div",{className:"ui-list",children:e})}function Vt({href:e,onClick:t,lead:s,title:r,sub:i,side:a}){const l=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]});return e?n.jsx("a",{className:"ui-list-row",href:e,onClick:t?o=>{o.preventDefault(),t()}:void 0,children:l}):n.jsx("div",{className:"ui-list-row",children:l})}function NN({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 CN({list:e,detail:t,empty:s,label:r,className:i}){return n.jsxs("div",{className:Ti("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 Cu({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 __=8;function O_({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),j=h.useRef(null),w=h.useRef(null),k=h.useRef(null),g=h.useId(),x=T=>{var M;return((M=t.find(U=>U.value===T))==null?void 0:M.label)??T},y=i!==void 0&&s.length>=i,v=t.filter(T=>!s.includes(T.value)),N=t.length>__,b=u.trim().toLowerCase(),S=b===""?v:v.filter(T=>T.label.toLowerCase().includes(b)),C=Math.min(d,Math.max(0,S.length-1)),R=T=>{var M;c(!1),f(""),m(0),T&&((M=j.current)==null||M.focus())};h.useEffect(()=>{var M;if(!o)return;(M=N?w.current:k.current)==null||M.focus();const T=U=>{p.current&&!p.current.contains(U.target)&&R(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[o,N]);const E=T=>{const M=[...s,T];r(M),f(""),m(0);const U=i!==void 0&&M.length>=i;(U||M.length>=t.length)&&R(!U)},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 M=S[C];M&&E(M.value)}else T.key==="Backspace"&&u===""&&s.length>0&&(T.preventDefault(),r(s.slice(0,-1)))},L=T=>`${g}-${T}`,$=o&&S.length>0?L(C):void 0;return n.jsxs("div",{className:"ui-chippicker",ref:p,id:l,children:[s.map(T=>n.jsx(Cu,{label:x(T),disabled:a,onRemove:()=>r(s.filter(M=>M!==T)),children:x(T)},T)),n.jsxs("div",{className:"ui-chippicker-add",children:[n.jsx("button",{ref:j,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||v.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":$,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:$,tabIndex:N?-1:0,className:"ui-chippicker-list",children:[S.map((T,M)=>n.jsx("div",{id:L(M),role:"option","aria-selected":"false",className:"ui-menu-item","data-highlighted":M===C?"":void 0,onMouseEnter:()=>m(M),onMouseDown:U=>U.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 EN({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 AN({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:Ti("ui-fieldbg",s),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function F_(e){const t={};for(const s of e??[])t[s.key]=s.default;return t}function Jg(e){const[t,s]=h.useState({}),r=e??[],i={...F_(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(X,{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 U_({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(v=>{y||i(v)}).catch(v=>{y||l(v instanceof ae?v.message:String(v))}),()=>{y=!0}},[e.approvalId]);const{values:d,controls:m}=Jg(r==null?void 0:r.choices),p=(y,v)=>{f(y),l(null),(d&&y==="approve"?A.decide(e.approvalId,y,v,d):A.decide(e.approvalId,y,v)).then(N=>{i(N.action),s==null||s(N.action)}).catch(N=>l(N instanceof ae?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 j=r.state==="pending",w=(x=r.permissionScopes)==null?void 0:x.includes("always"),k=B_(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":z_(r.state),children:r.state})]}),n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:j?"Expires":"Decided"}),n.jsx("div",{className:"ui-stat-v","data-size":"sm",children:Ve(j?r.expiresAt:r.decidedAt,t)})]})]}),n.jsx(te,{message:a}),j?m:null,j?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 B_(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:on(i),value:Hc(a)});else s!=null&&t.push({label:"Envelope",value:Hc(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 · ${on(i)}`;t.some(o=>o.label===l)||t.push({label:l,value:Hc(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 Hc(e){return e==null?"—":Array.isArray(e)?e.map(t=>Hc(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):It(e,"text",null)}function z_(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const W_=new Set(["image/png","image/jpeg","image/gif","image/webp"]),H_=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Eu(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"||!H_.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 Xg(e){return W_.has(e.toLowerCase())}function sr(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function Dr(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function Nn(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 Zg(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 ui={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function Vc(e){return`artifact:${e}`}function V_(e){const t=Zg(e.mime,e.filename);return{id:Vc(e.artifactId),tool:ui[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function K_({props:e}){const t=uN(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?Nn(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:sr(t),className:"wb-image-link",title:"Open at full size",children:n.jsx("img",{src:sr(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(Gt,{size:"sm",href:Dr(t),download:(s==null?void 0:s.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?n.jsx(Mt,{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:It(t.value,t.unit,t.currency)})]},t.label))})}const Y_=8;function TN({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<=Y_},children:e})}function q_(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 Q_({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 J_({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:q_(e.elapsedMs)}):null,n.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?n.jsx(Q_,{text:t}):null]}),e.omittedBytes!==null?n.jsxs("p",{className:"wb-terminal-note",children:["First ",Nn(e.omittedBytes)," not shown."]}):null,t!==""?n.jsx(TN,{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:It(s.value,s.unit,null)})]},s.label))}):null]})}function X_(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function fy(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function Z_(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((s,r)=>s-r)}function eO({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=Z_(e),[d,m]=h.useState(null),p=d!==null&&f.includes(d)?d:e.port,j=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||j===null)return;let b=!0;return s(null),i(null),l(null),x(0),A.previewLink(u,j).then(S=>{b&&(s(S.url),i(fy(S.url)))}).catch(S=>{b&&l(S instanceof Error?S.message:"That preview could not be opened.")}),()=>{b=!1}},[u,j]);const y=()=>{u===null||j===null||A.previewLink(u,j).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 v=!(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,v?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&&X_()?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:fy(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…"}),v&&o?n.jsx(TN,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const tO=50,nO=9,sO=24,rO=.6,iO=48,aO=/(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,lO=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,oO=/^id$|(^|[a-z0-9])Id$|_id$/;function ia(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function In(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function RN(...e){for(const t of e)if(In(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 IN(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&&aO.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&lO.test(i))?"date":"text"}function cO(e,t){if(!oO.test(e))return!1;const s=t.filter(r=>!Wa(r));return s.length<2?!1:new Set(s.map(r=>String(r))).size===s.length}function Wa(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:In(e)?Object.keys(e).length===0:!1}function my(e,t){const s=e.filter(In);if(s.length===0||s.length/e.length<.8)return null;const r=s.slice(0,tO),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>sO||[...i.values()].reduce((f,d)=>f+d,0)/(i.size*r.length)<rO)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=>!Wa(w));if(m.length===0||cO(f,d))continue;const p=RN(r[0],t),j=IN(f,d,p);if(r.length>=4&&m.length===d.length&&d.every(w=>ia(w)&&w===d[0])){u.push({label:on(f),value:d[0],type:j,currency:p});continue}if(c.push({key:f,label:on(f),type:j,currency:j==="currency"?p:null}),c.length===nO)break}return c.length===0?null:{columns:c,rows:s,constants:u}}function uO(e,t,s){const r=RN(s);return{label:on(e),value:t,type:IN(e,[t],r),currency:r}}function PN(e){return typeof e=="string"&&e.length>iO}function dO(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.":In(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function Am(e){if(typeof e=="string"&&e.trim()!=="")return e;if(In(e))for(const t of["message","error","reason","detail","description"]){const s=e[t];if(typeof s=="string"&&s.trim()!=="")return s;if(In(s)){const r=Am(s);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function ex(e,t={}){if(t.failed){let d=e;if(typeof e=="string")try{const m=JSON.parse(e.replace(/^tool-error:\s*/,""));In(m)&&(d=m)}catch{}return{kind:"error",summary:Am(d),detail:py(d)}}if(In(e)){const d=e.error,m=e.ok;if(typeof d=="string"&&d.trim()!==""||m===!1)return{kind:"error",summary:Am(e),detail:py(e)}}const s=dO(e);if(s)return{kind:"empty",note:s,stats:[]};if(Array.isArray(e)){const d=my(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(ia)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!In(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=my(m,e);if(p){(!i||p.rows.length>i.candidate.rows.length)&&(i={key:d,candidate:p});continue}m.length>0&&m.every(ia)&&(!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(PN(m)){c.push(m);continue}if(ia(m)){if(m==="")continue;o.push(uO(d,m,e));continue}m!==void 0&&u.push({label:on(d),value:m})}if(i)return{kind:"table",label:on(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:on(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])=>on(m).toLowerCase()).join(", ")} to show.`,stats:o}:r.every(([,d])=>ia(d)||In(d)||Array.isArray(d))?{kind:"record",pairs:o,notes:c,asides:u}:{kind:"tree",value:e}}function py(e){if(!In(e))return null;const t=Object.entries(e).filter(([s])=>s!=="message"&&s!=="error");return t.length===0?null:Object.fromEntries(t)}const Au=25,hO=3,Tm=8,MN=6;function Rm(e,t=0){if(t>MN||Wa(e)||PN(e))return 0;if(ia(e))return 1;if(Array.isArray(e)){let s=0;for(const r of e)if(s+=Rm(r,t+1),s>=Tm)return s;return s}if(In(e)){let s=0;for(const r of Object.values(e))if(s+=Rm(r,t+1),s>=Tm)return s;return s}return 0}function Im(e,t=0){if(t>MN)return!1;if(Array.isArray(e))return e.some(a=>Im(a,t+1));if(!In(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=>Im(a,t+1))}function fO(e){if(Im(e))return!0;const t=ex(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=hO;case"record":case"tree":return Rm(e)>=Tm;default:return!1}}function Eh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function tx(e){const t=Eh(e);if(!t)return null;const s=Eh(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:Eh(t.input),i=(r==null?void 0:r.command)??s.command;return{command:typeof i=="string"?i:null,input:r,result:s}}function mO({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 Ah({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(mO,{text:t,label:`Copy ${e.toLowerCase()}`})]}),n.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function pO({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(Ah,{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(Ah,{title:"Output",text:s.stdout}):n.jsx("p",{className:"wb-note",children:"No standard output."}),s.stderr?n.jsx(Ah,{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:kn({...c,...i?{input:i}:{}})})]})]})}const hc=2,gy=64;function gO({props:e}){const[t,s]=h.useState(!1),r=tx(e.value),i=xO((r==null?void 0:r.result)??e.value),a=h.useMemo(()=>ex(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return n.jsxs("div",{children:[!r&&n.jsx(xy,{files:i}),t?n.jsx("pre",{className:"ui-code",children:kn(e.value)}):r?n.jsx(pO,{value:r,children:i.length>0&&n.jsxs("section",{children:[n.jsx("h4",{children:"Generated files"}),n.jsx(xy,{files:i})]})}):i.length?n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"Tool details"}),n.jsx(vy,{shape:a})]}):n.jsx(vy,{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 xO(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 xy({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(vO,{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 vO({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 vy({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:io(e.detail,1)})]})]});case"empty":return n.jsxs("div",{children:[n.jsx(Th,{stats:e.stats}),n.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=SO(e.columns,e.rows);return n.jsxs("div",{children:[n.jsx(Th,{stats:e.stats}),n.jsx(Rh,{notes:e.notes}),t?n.jsx(NO,{label:e.label,plan:t,rows:e.rows,total:e.total}):n.jsx(yO,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),n.jsx(Ih,{asides:e.asides})]})}case"list":return n.jsxs("div",{children:[n.jsx(Th,{stats:e.stats}),n.jsx(Rh,{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:It(t,"text",null)},s))}),e.total>100?n.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,n.jsx(Ih,{asides:e.asides})]});case"record":return n.jsxs("div",{children:[n.jsx(Rh,{notes:e.notes}),n.jsx(jO,{pairs:e.pairs}),n.jsx(Ih,{asides:e.asides})]});default:return n.jsx("div",{className:"wb-tree",children:io(e.value,0)})}}function Th({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:nx(t.value,t.type,t.currency)})]},t.label))})}const jy=200;function Rh({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=jy),s=e.filter(r=>r.length>jy);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 jO({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:nx(t.value,t.type,t.currency)})]},t.label))})}function Ih({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:io(t.value,1)})]},t.label))})}function yO({label:e,columns:t,rows:s,total:r}){const[i,a]=h.useState(!1),l=r<=Au+5?r:Au,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:DN(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(CO,{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 wO=/^(title|name|headline|subject|label|heading)$/i,bO=/^(url|link|href|uri|permalink)$/i;function Tu(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function kO(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function $N(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 fc(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 SO(e,t){if(t.length===0)return null;const s=e.filter(f=>f.type==="text"),r=s.find(f=>bO.test(f.key)&&t.some(d=>Tu(d[f.key])))??s.find(f=>{const d=t.map(m=>m[f.key]).filter(m=>!Wa(m));return d.length>0&&d.filter(Tu).length/d.length>=.6});if(!r)return null;const i=s.filter(f=>f.key!==r.key),a=i.find(f=>wO.test(f.key))??i.find(f=>fc(t,f.key)>0);if(!a)return null;const o=[...i.filter(f=>f.key!==a.key)].sort((f,d)=>fc(t,d.key)-fc(t,f.key)),c=o[0]&&fc(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 NO({label:e,plan:t,rows:s,total:r}){const[i,a]=h.useState(!1),l=r<=Au+5?r:Au,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=Tu(f)?f.trim():null,m=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:d?$N(d):"Untitled",p=t.description&&typeof c[t.description]=="string"?c[t.description]:null,j=d?kO(d):null,w=t.meta.map(k=>c[k]).filter(k=>!Wa(k)&&typeof k!="object").map(k=>String(k)).filter(k=>j===null||k.replace(/^www\./,"")!==j);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:[j?n.jsx("span",{className:"wb-record-host",title:d??void 0,children:j}):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 CO({value:e,column:t}){if(Wa(e))return n.jsx("td",{className:"wb-cell-soft",children:"—"});if(Tu(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:$N(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:kn(e),children:i})}const s=nx(e,t.type,t.currency),r=s.length>gy?`${s.slice(0,gy-1)}…`:s;return n.jsx("td",{className:DN(t.type)?"num":"wb-cell-text",...r===s?{}:{title:s},children:r})}function DN(e){return e==="number"||e==="currency"}function nx(e,t,s){return e==null?"—":t==="boolean"?e?"yes":"no":It(e,t==="text"?"text":t,s)}function io(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,". "]}),io(a,t+1)]},l)),e.length>50?n.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=hc?n.jsx(yy,{summary:`${e.length} items`,open:t===hc,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:[on(i),": "]}),io(a,t+1)]},i))});return t>=hc?n.jsx(yy,{summary:`${s.length} fields`,open:t===hc,children:r}):r}function yy({summary:e,open:t,children:s}){return n.jsxs("details",{open:t,children:[n.jsx("summary",{className:"wb-tree-key",children:e}),s]})}function EO({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:It(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:_N(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(AO,{cell:l},((c=e.columns[o])==null?void 0:c.key)??o)})},a))})]})})]},s.label??r))]})}function AO({cell:e}){const t=It(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:_N(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function _N(e){return e==="number"||e==="currency"||e==="percent"}const wy={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 Ed(e){return(e&&Object.prototype.hasOwnProperty.call(wy,e)?wy[e]:void 0)??"dot"}let Ph=null;function TO(){return Ph??(Ph=Promise.resolve().then(()=>A.pages()).then(e=>Array.isArray(e==null?void 0:e.pages)?e.pages:[]).catch(()=>(Ph=null,[]))),Ph}function ON(e,t,s){return s==="settings"?wo(e,t):ji(e,t)}function RO(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 TO().then(l=>{const o=l.find(c=>c.plugin===r&&c.id===i);a||s(o?{href:ON(r,i,o.place),label:o.place==="settings"?`Settings → ${o.title}`:o.title}:null)}),()=>{a=!0}},[r,i]),t}function LN({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(IO,{tile:i,...r?{picked:a===s,onPick:()=>r(a)}:{}},`${a}-${i.label}`))})}function IO({tile:e,picked:t,onPick:s}){const r=RO(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:Ed(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(Dn,{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 Bi=760,Mh=400,wt={top:18,right:18,bottom:36,left:66},PO=5;function MO({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(v=>v.y),...s.map(v=>v.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=Bi-wt.left-wt.right,m=Mh-wt.top-wt.bottom,p=v=>wt.left+(t.length===1?d/2:v/(t.length-1)*d),j=v=>wt.top+m-(v-u)/(f-u)*m,w=Su(l,o,4),k=DO(t.map(v=>v.y),e.mark),g=e.shadeBelow===null?[]:_O(t.map(v=>v.y),e.shadeBelow),x=t.map((v,N)=>`${N===0?"M":"L"}${p(N)},${j(v.y)}`).join(" "),y=v=>It(v,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 ${Bi} ${Mh}`,role:"img","aria-label":$O(e,y),preserveAspectRatio:"xMidYMid meet",children:[g.map(v=>n.jsx("rect",{className:"wb-chart-breach",x:p(v.from),width:Math.max(2,p(v.to)-p(v.from)),y:wt.top,height:m},`band-${v.from}`)),w.map(v=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-grid",x1:wt.left,x2:Bi-wt.right,y1:j(v),y2:j(v)}),n.jsx("text",{x:wt.left-8,y:j(v)+4,textAnchor:"end",children:y(v)})]},`tick-${v}`)),s.map(v=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-floor",x1:wt.left,x2:Bi-wt.right,y1:j(v.value),y2:j(v.value)}),n.jsxs("text",{x:Bi-wt.right,y:j(v.value)-6,textAnchor:"end",children:[v.label," ",y(v.value)]})]},`rule-${v.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:Bi-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:j(t[k].y),r:4.5}),n.jsx("text",{x:p(k),y:j(t[k].y)+20,textAnchor:"middle",children:y(t[k].y)})]}):null,OO(t.length).map(v=>n.jsx("text",{x:p(v),y:Mh-10,textAnchor:"middle",children:jm(t[v].x)},`x-${v}`))]})}),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((v,N)=>n.jsxs("li",{className:"wb-chart-event",children:[n.jsxs("span",{children:[n.jsx("span",{className:"wb-chart-event-day",children:jm(v.at)}),v.label]}),v.amount===null?null:n.jsx("span",{className:v.amount<0?"tnum critical":"tnum good",children:It(v.amount,r,i)})]},`${v.at}-${v.label}-${N}`))})]}):null]})]})}function $O(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 DO(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 _O(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 OO(e,t=PO){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 Wn=e=>e,Pm={timeseries:Wn(MO),table:Wn(EO),bars:Wn(P$),keyvalue:Wn(G_),tiles:Wn(LN),document:Wn(e_),diff:Wn(L$),terminal:Wn(J_),image:Wn(K_),preview:Wn(eO),envelope:Wn(U_),structured:Wn(gO)},LO="structured";function FO(e){return(Ru(e)?Pm[e]:void 0)??Pm[LO]}function Ru(e){return Object.prototype.hasOwnProperty.call(Pm,e)}function UO({renderer:e,props:t,timezone:s,onDecided:r}){const i=FO(e),l=Ru(e)?t:{value:t};return n.jsx(i,{props:l,timezone:s,onDecided:r})}function BO({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($h,{children:"Opens by default"}):null,n.jsx($h,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(s=>n.jsx($h,{title:`A surface command that asks for "${s}" lands on this agent.`,children:on(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(ll,{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(FN,{}),"Exact action"]})]})]})}),n.jsx(ll,{title:"What it can do",note:zO(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(WO,{family:s},s.family))}),n.jsx(ll,{title:"What it runs on",children:n.jsxs("dl",{className:"wb-prof-kv",children:[n.jsx(ol,{label:"Provider",children:e.engine.provider}),n.jsx(ol,{label:"Model",children:n.jsx("span",{className:"mono",children:e.engine.model})}),n.jsxs(ol,{label:"Credential",children:[e.engine.credentialKind," from"," ",n.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),n.jsxs(ol,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),n.jsx(ol,{label:"Language",children:YO(e.engine.language)})]})}),e.skills.length>0?n.jsx(ll,{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(ll,{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 zO(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 WO({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:on(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(HO,{tool:s},s.name))})]})}function HO({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:GO(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(FN,{}),"Needs your approval"]}):n.jsx("span",{className:"wb-prof-auto",title:KO(e.tier),children:VO(e.tier)})]})}function VO(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function KO(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 GO(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function YO(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function ll({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 ol({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 $h({children:e,title:t}){return n.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function FN(){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 by=16e3,qO=10*6e4,QO="The microphone is blocked for this page: allow it in the browser’s site settings to talk.",UN="This browser cannot record here: talking needs a microphone and a secure page (https or localhost).";function JO(){const e=window;return e.AudioContext??e.webkitAudioContext}function XO(e){const t=e&&typeof e=="object"&&"name"in e?String(e.name):"";return t==="NotAllowedError"||t==="SecurityError"||t==="PermissionDeniedError"?QO:t==="NotFoundError"||t==="DevicesNotFoundError"?"No microphone was found on this computer.":t==="NotReadableError"?"The microphone is in use by another app.":UN}async function ZO(e){var c;const t=JO();if(!((c=navigator.mediaDevices)!=null&&c.getUserMedia)||!t)throw Object.assign(new Error(UN),{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(),nL(tL(eL(l),u,by),by)},cancel:o}}function eL(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 tL(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 nL(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 Mm="buddi.readAloud";function BN(){try{return window.localStorage.getItem(Mm)==="on"}catch{return!1}}function zN(e){try{e?window.localStorage.setItem(Mm,"on"):window.localStorage.removeItem(Mm)}catch{}}let bs=null,El=null,ao=0,$m=null;const Dm=new Set;function Iu(e){$m!==e&&($m=e,Dm.forEach(t=>t()))}function sL(){return $m}function rL(e){return Dm.add(e),()=>Dm.delete(e)}function WN(e){return Ha(),Iu(e),ao}function ky(e){return e===ao}function Ha(){ao++,bs&&(bs.pause(),bs.removeAttribute("src")),El&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(El),El=null,Iu(null)}async function iL(e,t,s=null){var i;const r=WN(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!==ao)return;bs||(bs=new Audio,(i=bs.addEventListener)==null||i.call(bs,"ended",()=>Iu(null))),El=URL.createObjectURL(l),bs.src=El,await bs.play()}catch(a){throw r===ao&&Iu(null),a}}const aL=new Set(["audio/ogg","audio/mpeg","audio/mp4","audio/wav","audio/x-wav","audio/webm"]);function HN(e){return aL.has(e.toLowerCase().split(";")[0].trim())}function Sy(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 VN({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),[j,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}Ha(),d(!1);try{if(!a.current){u(!0);const y=await fetch(Dr(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.":`${Sy(m)} / ${Sy(j)}`;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&&Nn(r)?` · ${Nn(r)}`:""]})]}),n.jsx("a",{className:"ui-icon-btn wb-audio-download","data-size":"sm",href:Dr(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 Dh=1e5,_h=200,Oh=30;function KN({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:sr(e),alt:t??"Image",onError:()=>l(!0)})}):r==="audio"&&HN(s)?n.jsx("div",{className:"file-preview file-preview-audio",children:n.jsx(VN,{artifactId:e,name:t??"Audio",mime:s})}):r==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:sr(e),type:"application/pdf","aria-label":t??"PDF",children:n.jsx(W,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?n.jsx(lL,{artifactId:e,filename:t,mime:s,family:r}):n.jsx(W,{children:"Preview not supported for this kind of file. Download it to open it."}):n.jsx(W,{children:"The file is no longer available; its record is kept."})}function lL({artifactId:e,filename:t,mime:s,family:r}){const[i,a]=h.useState("loading");if(h.useEffect(()=>{let o=!1;return a("loading"),fetch(sr(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,Dh),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>Dh})}).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(W,{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(cL,{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 ",Dh.toLocaleString()," characters. The download has the whole file."]}):null]})}function oL(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 cL({text:e,delimiter:t}){const s=h.useMemo(()=>oL(e,t,_h+1,Oh),[e,t]),[r,...i]=s.rows;if(!r)return n.jsx("p",{className:"muted",children:"The file is empty."});const a=Math.min(Oh,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,_h).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 ",_h," rows",s.truncatedCols?` and ${Oh} columns`:"",". The download has the whole file."]}):null]})}function uL({attachment:e}){const t=Zg(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(KN,{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:[ui[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:Nn(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:Dr(e.artifactId),download:s,children:"Download"})})]})}const Ny=80,dL=["query","path","url","dir"],hL=["message","task"];function sx(e,t){const s=fL(t);if(!s)return null;const r=zi(s.command);if(r!==null){const l=zi(s.name);return mc(l===null?r:`${l}: ${r}`)}for(const l of dL){const o=zi(s[l]);if(o!==null)return mc(o)}const i=zi(s.action);if(i!==null){const l=hL.map(o=>zi(s[o])).find(o=>o!==null)??null;return mc(l===null?i:`${i} · ${l}`)}const a=Object.values(s).filter(l=>typeof l=="string");return a.length===1?mc(zi(a[0])):null}function zi(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function mc(e){return e===null?null:e.length>Ny?`${e.slice(0,Ny-1)}…`:e}function fL(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const _r="agent.delegate";function mL(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 pL(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 _m="canvas.show",Cy="canvas.clear",Ey=12;function pa(e){return`${e.plugin}/${e.name}`}function gL(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function xL({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=hN(o,GN(l.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:a.at??null})}return i}function vL({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===_m){const v=yL(d.id,d.input,f.at??null);v&&o.push(v)}if(d.name===Cy&&(o=[]),d.name===_r){const v=mL(d.input);v&&o.push({id:d.id,tool:_r,title:"Delegation",renderer:"delegate",props:{...v,result:null},at:f.at??null,source:"delegate",substantial:!0})}continue}if(d.type!=="tool_result"||d.name===_m||d.name===Cy)continue;const m=l.get(d.toolUseId),p=f.at??(m==null?void 0:m.at)??null,j=d.name||(m==null?void 0:m.name)||"tool",w=o.find(v=>v.source==="delegate"&&v.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:pL(d.ok?d.output:d.error??d.output),...d.ok&&Eu(d.output).length>0?{files:Eu(d.output)}:{}}},d.ok||(w.tone="critical");continue}const k=d.approval?Lm(d):(s==null?void 0:s.get(d.toolUseId))??Lm(d);if(k){o.push({id:d.toolUseId,tool:j,title:"Approval",renderer:"envelope",props:{approvalId:k},at:p,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(j))continue;const g=GN(d.output);if(d.ok===!1){o.push({id:d.toolUseId,tool:j,title:Ts(j),renderer:"structured",props:{value:d.error??g??null,failed:!0},at:p,tone:"critical",source:"fallback",substantial:!1});continue}gL(g)&&(c+=1);const x=a.get(j);if(x){const v=hN(x,g),{renderer:N}=v;let{props:b}=v;if(N==="preview"){const S=b,C=S.target??(S.awaiting&&(i!=null&&i.has(pa(S.awaiting)))?S.awaiting:null);if(C===null)continue;b={...S,target:C,awaiting:null};const R=pa(C);o=o.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&pa(E.props.target)===R))}o.push({id:d.toolUseId,tool:j,title:x.title??Ts(j),renderer:N,props:b,at:p,source:"descriptor",substantial:Om(N,b)});continue}const y={value:tx(g)?{input:m==null?void 0:m.input,output:g}:g};wL("structured",y)&&o.push({id:d.toolUseId,tool:j,title:Ts(j),renderer:"structured",props:y,at:p,source:"fallback",substantial:Om("structured",y)})}for(const f of o)f.source==="descriptor"&&f.renderer==="preview"&&(f.props={...f.props,changes:c});return jL(o)}const Ay="forAgent";function GN(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(Ay in e))return e;const{[Ay]:t,...s}=e;return s}function jL(e){if(e.length<=Ey)return e;const t=e.length-Ey;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function yL(e,t,s){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:a}=t,l=typeof r=="string"&&Ru(r)?r:"structured";return{id:e,tool:_m,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:l,props:l==="structured"&&!Ru(String(r))?{value:a}:a,at:s,substantial:!0,source:"canvas"}}function wL(e,t){const s=t??{};return!!(s.failed===!0||Om(e,t)||ex(s.value).kind==="error")}function Om(e,t){const s=t??{};switch(e){case"timeseries":return cl(s.points)>0;case"bars":return cl(s.bars)>0;case"keyvalue":return cl(s.pairs)>0;case"tiles":return s.notice!==!0&&cl(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=>cl(i.rows)>0);default:return tx(s.value)?!0:s.failed===!0?!1:fO(s.value)}}function cl(e){return Array.isArray(e)?e.length:0}function Lm(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const s=qN(t,0);if(s)return s}return null}function bL(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)?YN(i.input):i.input;return{id:t,tool:i.name,title:Ts(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 kL=new Set(["value","text","password","secret","code"]);function YN(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[s,r]of Object.entries(e))t[s]=kL.has(s)&&typeof r=="string"?"— withheld —":YN(r);return t}function qN(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=qN(a,t+1);if(l)return l}return null}function Ts(e){const t=e.split(".");return t.length===1?on(e):t.map(s=>on(s)).join(" · ")}function Ad({name:e,mime:t,sizeBytes:s,thumbnail:r,state:i,error:a,onOpen:l,onRemove:o,size:c="md"}){const u=Zg(t,e),f=[ui[u],Nn(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(rx,{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 rx({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 SL(e,t,s){const r=Ry(e),i=Ry(t==null?void 0:t.input),a=Jr(r==null?void 0:r.name)??TL(Jr(r==null?void 0:r.handle))??Jr(r==null?void 0:r.agent)??Jr(i==null?void 0:i.agent),l=typeof e=="string"?e.trim()||null:Jr(r==null?void 0:r.text)??Jr(r==null?void 0:r.note),o=Ty(r==null?void 0:r.durationMs)??Ty(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:Jr(i==null?void 0:i.task),answer:l,files:Eu(e),durationMs:o??f}}function NL(e,t){var r;let s=null;for(const i of e)for(const a of i.blocks??[])a.type==="tool_result"&&a.name===_r&&((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 CL({block:e,messages:t,answeredAt:s}){const r=SL(e.output,NL(t,e.actionId),s),i=[r.who?`Asked ${r.who}`:null,r.durationMs===null?null:`took ${EL(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(tr,{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:Dr(a.artifactId),download:!0,children:n.jsx(Ad,{name:a.filename??"Untitled file",mime:a.mime,sizeBytes:a.sizeBytes,thumbnail:Xg(a.mime)?sr(a.artifactId):null,size:"sm"})},a.artifactId))}):null,n.jsx(Mt,{summary:"Raw JSON",children:n.jsx("pre",{className:"wb-approval-output mono",children:AL(e.output)})})]})}function EL(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 AL(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function TL(e){return e===null?null:`@${e.replace(/^@/,"")}`}function Jr(e){return typeof e=="string"&&e.trim()!==""?e:null}function Ty(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Ry(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const RL=1e3;function IL({messageId:e,text:t,onReadAloud:s}){const[r,i]=h.useState(!1),a=h.useRef(null),l=h.useSyncExternalStore(rL,sL)===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),RL)},()=>{})};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?Ha():s(e,t),children:n.jsx(Se,{name:l?"stop":"play",size:14})}):null]})}function PL(e){const t=ML(e);if(!t)return null;const s=Lh(t.diff);if(s!==null)return{kind:"diff",diff:s};const r=Lh(t.command),i=Lh(t.plain),a=Fh(t.exitCode);return r!==null&&(i!==null||a!==null||Fh(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:a,elapsedMs:Fh(t.elapsedMs)}:null}function Lh(e){return typeof e=="string"&&e.trim()!==""?e:null}function Fh(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ML(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Iy="offer:",QN="owner:interjection";function $L(e){return e===QN}function DL(e){if(typeof e!="string"||!e.startsWith(Iy))return null;const t=e.slice(Iy.length).trim();return t===""?null:t}function ix({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:j,emptyHint:w,empty:k,plain:g=!1,workingLine:x,runs:y}){var B;const v=h.useRef(null);h.useEffect(()=>{var H;(H=v.current)==null||H.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(H=>(H.blocks??[]).some(KL)),S=HL(b,y??[]),C=c??l??[],R=H=>(o&&!c?C.find(ue=>ue.id===o):void 0)??C.find(ue=>ue.name===H)??null,E=o?C.find(H=>H.id===o)??null:null,P=i||t.length>0,L=P||!!N,$=!!N&&a.text!=="",T=P&&!$,M=b.at(-1),U=(M==null?void 0:M.role)!=="assistant"||!!f,K=f??j??"Assistant",_=b.filter((H,ue)=>{var re;return ue===0||(c?(((re=b[ue-1])==null?void 0:re.speaker)??null)!==(H.speaker??null):b[ue-1].role!==H.role)}),q=L&&!U?((B=_.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((H,ue)=>{const re=H.speaker??null,ie=c?re==="owner"||re===null&&H.role==="user":H.role==="user",Ne=c&&re==="room",Z=c&&re&&re!=="owner"&&re!=="room"?c.find(fe=>fe.id===re)??null:null,ce=b[ue-1],de=ue===0||(c?((ce==null?void 0:ce.speaker)??null)!==re:ce.role!==H.role);if(Ne)return n.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(H.blocks??[]).filter(fe=>fe.type==="text").map((fe,ve)=>n.jsx("span",{children:fe.text},ve))},H.id);const Ae=(H.blocks??[]).filter(fe=>fe.type==="approval_result");if(Ae.length>0)return n.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:Ae.map((fe,ve)=>n.jsx(GL,{block:fe,messages:e,at:H.at||null},ve))},H.id);const ne=H.role==="user"&&$L(re),be=H.role==="user"?DL(re):null;if(be){const fe=(H.blocks??[]).filter(ve=>ve.type==="text").map(ve=>ve.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:fe,children:be})},H.id)}const Te=c&&Z&&H.role==="user"?BL(H):null;if(Te){const fe=b.slice(ue+1).find(Le=>Le.role==="assistant"&&Le.speaker&&Le.speaker!==Z.id),ve=fe!=null&&fe.speaker?c.find(Le=>Le.id===fe.speaker):void 0;return n.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[n.jsxs("summary",{children:[Z.name," asked ",(ve==null?void 0:ve.name)??"a member",Te.request?`: ${Te.request.length>120?`${Te.request.slice(0,119)}…`:Te.request}`:""]}),Te.request?n.jsx("p",{children:Te.request}):null]},H.id)}const Ze=S.get(H.id)??null,Ie=WL(H,e),it=!ie&&!ne&&!g?zL(H):"";return n.jsxs("div",{className:"wb-msg","data-role":ie||ne?"user":"assistant",children:[ne?n.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,de&&!ie&&!ne?n.jsx(Py,{name:Z?Z.name:j??"Assistant",face:Z??E??R(j),moving:T&&q===H.id,children:Z&&u===Z.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(fe=>n.jsx("span",{role:"listitem",children:HN(fe.mime)?n.jsx(VN,{artifactId:fe.artifactId,name:fe.filename??"Untitled file",mime:fe.mime,sizeBytes:fe.sizeBytes}):n.jsx(Ad,{name:fe.filename??"Untitled file",mime:fe.mime,sizeBytes:fe.sizeBytes,thumbnail:Xg(fe.mime)?sr(fe.artifactId):null,...d?{onOpen:()=>d(fe)}:{}})},fe.artifactId))}):null,(H.blocks??[]).map((fe,ve)=>{const Le=LL(H.blocks??[],ve,e);if(Le==="inside")return null;if(Le)return n.jsx(FL,{refusals:Le.refusals},ve);if(fe.type==="thinking")return g||fe.text.trim()===""?null:n.jsx(Fm,{text:fe.text},ve);if(fe.type==="text")return fe.text.trim()===""?null:ie?n.jsx("div",{className:"wb-bubble",children:fe.text},ve):n.jsx("div",{className:"wb-bubble","data-rich":"true",children:n.jsx(tr,{text:fe.text})},ve);if(fe.type==="attachment")return null;if(fe.type==="tool_use"){if(g)return null;const Me=ax(e,fe.id),ot=Me?QL(Me):null;return n.jsx(Um,{label:ot&&!(Me!=null&&Me.delegation)?`Approval · ${fe.name}`:Ts(fe.name),tool:fe.name,ok:(Me==null?void 0:Me.ok)??null,running:Me===null,...ot?{status:ot.status,waiting:ot.waiting,approval:!0}:{},gist:sx(fe.name,fe.input),body:Me?PL(Me.output):null,opens:!0,onOpen:()=>r(fe.id)},ve)}return null}),Ze?n.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:VL(Ze)}):null,it!==""?n.jsx(IL,{messageId:H.id,text:it,onReadAloud:m}):null]},H.id)}),L?n.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[U?n.jsx(Py,{name:K,face:R(K)??E,moving:T}):null,N&&a.thinking!==""&&!g?n.jsx(Fm,{text:a.thinking,live:a.text==="",seconds:UL(a.thinkingStartedAt,a.textStartedAt??s)}):null,$?n.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[n.jsx(tr,{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??j??"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(H=>n.jsx(Um,{label:Ts(H.name),tool:H.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((s-H.startedAt)/1e3)),opens:!1,onOpen:()=>r(H.toolUseId)},H.toolUseId))]}):null,p,n.jsx("div",{ref:v})]})})}function Py({name:e,face:t,moving:s=!1,children:r}){const i=(t==null?void 0:t.picture)??null,a=aN(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(bd,{state:"working",size:"sm",still:i,className:"wb-msg-blob"}):n.jsx(ms,{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 _L(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 OL="delegation refused:";function LL(e,t,s){const r=a=>{const l=e[a];if(!l||l.type!=="tool_use"||l.name!==_r)return null;const o=ax(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(OL))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 FL({refusals:e}){const[t,s]=h.useState(!1),r=e.map(o=>_L(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:[Ts(_r)," · ",o.target]}),n.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),n.jsx("p",{className:"wb-refusal-why",children:o.message})]},c))}):null]})}function UL(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function Fm({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(tr,{text:e})}):null]})}function BL(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 zL(e){return(e.blocks??[]).filter(t=>t.type==="text").map(t=>t.text.trim()).filter(t=>t!=="").join(`
97
+
98
+ `)}function WL(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===_r){const l=ax(t,a.id);l!=null&&l.ok&&Eu(l.output).forEach(i)}return s}function HL(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 VL(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 KL(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function GL({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":Ts(e.name)}),n.jsx("span",{className:"wb-tool-elapsed",children:e.state}),n.jsx(Se,{name:"arrow",className:"wb-tool-arrow"})]}),r&&e.name===_r?n.jsx(CL,{block:e,messages:t,answeredAt:s}):null,r&&e.name!==_r?n.jsx("pre",{className:"wb-approval-output mono",children:YL(e.output)}):null]})}function YL(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const qL=40;function QL(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(Lm(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 Um({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),j=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"}),j]}),a?n.jsxs(Jl,{children:[n.jsx(Xl,{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(Zl,{children:n.jsxs(eo,{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(JL,{body:d,onOpen:a?l:null}):null]}):a?n.jsxs(Jl,{children:[n.jsx(Xl,{asChild:!0,children:n.jsxs("button",{className:"wb-tool",...w,onClick:l,children:[j,n.jsx(Se,{name:"arrow",className:"wb-tool-arrow"})]})}),n.jsx(Zl,{children:n.jsxs(eo,{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:j})}function JL({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(Nu,{text:e.diff,limit:qL,...s?{more:s}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:XL(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 XL(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function ax(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 JN="approval-dock";function ZL(){var t;const e=document.getElementById(JN);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const eF=["workspace","cwd","workdir","root"];function tF({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(nF,{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 nF({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),[j,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 ae?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}=Jg(c==null?void 0:c.choices),y=(R,E)=>{const P=j.trim();p(R),d(null),(g&&R==="approve"?A.decide(e.approvalId,R,E,g):A.decide(e.approvalId,R,E)).then(L=>{a(L.action),P&&l(P)}).catch(L=>{d(L instanceof ae?L.message:String(L)),p(null)})},v=m!==null||c===null||c.state!=="pending",N=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,b=c?sx(c.tool,c.canonicalArgs)??rF(c.preview):null,S=c?sF(c):null;return n.jsxs("section",{id:JN,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?Ts(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(te,{message:f}),n.jsx("div",{className:"wb-dock-section",children:n.jsx("input",{className:"wb-dock-instead",value:j,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:v,onClick:()=>y("reject"),children:m==="reject"?"Rejecting…":"Reject"}),N?n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",size:"sm",disabled:v,onClick:()=>y("approve","conversation"),children:"Auto: this conversation"}),n.jsx(I,{size:"sm",disabled:v,onClick:()=>y("approve","always"),children:"Always: this agent"})]}):null,n.jsx(I,{variant:"good",size:"sm",disabled:v,onClick:()=>y("approve"),children:m==="approve"?"Approving…":N?"Allow once":"Approve"})]})]})}function sF(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const s of eF){const r=t[s];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function rF(e){const t=(e??"").split(`
99
+ `).map(s=>s.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const iF=2e3;function aF({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}=se(()=>Oe.conversation(e),[e,o,(i==null?void 0:i.approvalId)??null],u?iF:void 0),m=(f==null?void 0:f.runs)??[],p=s===null?null:m.find(v=>v.runId===s)??null,j=l||i===null&&(s!==null?p!==null&&p.finishedAt!==null:m.length>0&&m.every(v=>v.finishedAt!==null));h.useEffect(()=>{j&&c(!0)},[j]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":j?"done":"working",k=a.find(v=>v.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)??lF(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(xn,{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((v,N)=>n.jsx("div",{className:"wb-delegate-turn",children:(v.blocks??[]).map((b,S)=>{if(b.type==="thinking")return b.text.trim()===""?null:n.jsx(Fm,{text:b.text},S);if(b.type==="tool_use"){const C=cF(oF(x,b.id));return n.jsx(Um,{label:Ts(b.name),tool:b.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:sx(b.name,b.input),opens:!1,onOpen:()=>{}},S)}return null})},v.id??N))}),y?n.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:n.jsx(tr,{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(v=>n.jsx("a",{role:"listitem",href:Dr(v.artifactId),download:!0,children:n.jsx(Ad,{name:v.filename??"Untitled file",mime:v.mime,sizeBytes:v.sizeBytes,thumbnail:Xg(v.mime)?sr(v.artifactId):null})},v.artifactId))}):null,n.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?n.jsx(I,{variant:"accent",onClick:()=>ZL(),"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 lF(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 oF(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 cF(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 My=1024*1024;function uF({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(hF,{files:e,agentId:t,root:s,path:i.path,revision:r,go:a})})}function XN({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 j=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 v=await k.json().catch(()=>null);p((v==null?void 0:v.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(XN,{root:s,path:r,go:a}),n.jsx(Ms,{}),n.jsx(I,{size:"sm",onClick:()=>void j(),disabled:f||w===null||w.length===0,children:f?"Packing…":"Download as archive"})]}),m?n.jsx(W,{tone:"warning",role:"alert",children:m}):null,c?n.jsx(W,{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:vi,children:"Files library"})," and mention it here."]}):"This folder is empty."}):n.jsx(Ht,{children:w.map(k=>n.jsx(Vt,{href:"#",onClick:()=>a({kind:k.kind,path:k.path}),lead:n.jsx(mF,{kind:k.kind}),title:n.jsxs("span",{className:"mono",children:[k.name,k.kind==="dir"?"/":""]}),side:k.kind==="file"?Nn(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 hF({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)}`:"",j=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<=My;return n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[n.jsx(XN,{root:s,path:r,go:a}),n.jsx(Ms,{}),k?n.jsx(I,{size:"sm","aria-pressed":f,onClick:()=>d(g=>!g),children:"Wrap"}):null,n.jsx(Gt,{size:"sm",href:w,download:(m==null?void 0:m.name)??r.split("/").at(-1),children:"Download"})]}),c?n.jsx(W,{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:j,alt:m.name})}):m.type==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:j,type:"application/pdf","aria-label":m.name,children:n.jsx(W,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):k?n.jsx(fF,{src:j,wrap:f}):n.jsxs(n.Fragment,{children:[n.jsx(W,{children:m.type==="text"?`This file is over ${Nn(My)}, 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(Wt,{items:[{label:"Size",value:Nn(m.bytes)},{label:"Type",value:n.jsx("span",{className:"mono",children:m.mime})}]})]})]})}function fF({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(W,{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 mF({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 pF=3,gF=152,xF=104,vF=100,jF=2,$y=5;function yF({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:j=!1}){const[w,k]=wF(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:j?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:CF(u,EF(o??[],c??[]))})]})})]});const g=e.some(v=>v.id===t)?t:e[e.length-1].id,{shown:x,hidden:y}=bF(e,g,k);return n.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:n.jsxs(k$,{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(S$,{className:"wb-tabstrip","aria-label":"Canvas",children:x.map(v=>n.jsxs("div",{className:"wb-tab-item",children:[n.jsxs(N$,{value:v.id,className:"wb-tab","data-tone":v.tone,onKeyDown:N=>{N.key==="Delete"&&p&&Dy(v)&&(N.preventDefault(),p(v.id))},children:[v.tone==="warning"||v.tone==="critical"?n.jsx("span",{className:"wb-tab-dot","data-tone":v.tone,"aria-hidden":"true"}):null,n.jsx("span",{className:"wb-tab-text",children:v.title})]}),p&&Dy(v)?n.jsx("button",{className:"wb-tab-close","aria-label":`Close ${v.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>p(v.id),children:"×"}):null]},v.id))}),n.jsx(kF,{items:y,onActivate:s,timezone:r})]}),e.map(v=>n.jsx(C$,{value:v.id,className:"wb-canvas-body","data-renderer":v.source==="descriptor"&&v.renderer==="preview"?"preview":void 0,"data-dense":TF.has(v.renderer)?"true":void 0,children:n.jsxs("section",{className:"ui-panel","data-flush":v.source==="descriptor"&&v.renderer==="preview"?"true":void 0,children:[v.source!=="browser"&&v.source!=="files"&&!(v.source==="descriptor"&&v.renderer==="preview")?n.jsxs("header",{className:"ui-panel-head",children:[n.jsx("h2",{className:"ui-panel-title",children:v.title}),n.jsx("span",{className:"ui-panel-tool mono",children:v.tool})]}):null,v.tone==="critical"?n.jsxs("p",{className:"muted",children:["Recorded tool failure",v.at?` · ${new Date(v.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,v.source==="browser"?d:v.source==="profile"?n.jsx(BO,{...v.props,...a?{onChange:a}:{}}):v.source==="artifact"?n.jsx(uL,{...v.props}):v.source==="files"?n.jsx(uF,{...v.props}):v.source==="delegate"?n.jsx(aF,{...v.props,agents:m??[]}):n.jsx(UO,{renderer:v.renderer,props:v.props,timezone:r,onDecided:i})]})},v.id))]})})}function Dy(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function wF(e){const[t,s]=h.useState($y),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-vF-xF)/gF);s(Math.max(jF,Math.min($y,u)))};l(),r.current=new ResizeObserver(l),r.current.observe(a)},[e]),e??t]}function bF(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 kF({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(Mg,{modal:!1,children:[n.jsx($g,{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(xd,{children:n.jsxs(Dg,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[n.jsx(vd,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>n.jsxs(ma,{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:SF(i.at,s)??i.tool})]},i.id))]})})]})}function SF(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 NF={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 CF(e,t){const s=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>NF[i.renderer]??"results"))].slice(0,3);return r.length>0?`${s} lands here: ${r.join(", ")}.`:`${s} lands here.`}function EF(e,t){const s=new Set(t),r=new Set,i=e.filter(c=>{if(!s.has(c.tool))return!1;const u=AF(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,pF)}function AF(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 TF=new Set(["table","diff","files"]),RF=3.5*6e4,IF=2e3;function PF(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??IF,c=e.map(u=>`${pa(u)}@${u.at??""}`).join("|");return h.useEffect(()=>{const u=new Map;for(const p of e){const j=pa(p);if(a.current.has(j))continue;const w=p.at===null?Number.NaN:Date.parse(p.at),k=Number.isNaN(w)?0:w+RF,g=u.get(j);(!g||k>g.until)&&u.set(j,{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[j,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(j),i(x=>{const y={served:new Set(x.served).add(j),live:g?new Set(x.live).add(j):x.live,scope:x.scope};return a.current=y.served,y})):g||u.delete(j)}!f&&u.size>0&&(d=setTimeout(()=>void m(),o))};return m(),()=>{f=!0,d!==void 0&&clearTimeout(d)}},[c,t,l,o]),r}const Bm="workspace-files";function MF(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 $F(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 DF(e,t){return{id:Bm,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 zm(e){return`agent-properties:${e}`}function _F(e){return{id:zm(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function OF(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 ZN({progress:e}){return n.jsxs(V,{gap:"sm",children:[n.jsx("span",{role:"status",children:OF(e)}),n.jsx(SN,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function LF(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 Uh(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function _y(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const FF=4e3;function UF(e){return e.replace(/\r\n?/g,`
102
+ `).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,FF)}const BF=["left","middle","right"],zF=33;function WF(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function HF(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 VF(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function KF({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),[j,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 M=!0,U;try{U=T(VF())}catch{a("lost");return}return U.binaryType="arraybuffer",k.current=U,U.onopen=()=>U.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),U.onmessage=K=>{if(!M)return;if(typeof K.data!="string"){const q=HF(K.data);if(!q||(d(B=>B&&WF(B,q.metadata)?B:q.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(q.jpeg).then(B=>{var ue,re,ie;const H=g.current;if(!M||!H){(ue=B.close)==null||ue.call(B);return}(H.width!==B.width||H.height!==B.height)&&(H.width=B.width,H.height=B.height),(re=H.getContext("2d"))==null||re.drawImage(B,0,0),(ie=B.close)==null||ie.call(B)}).catch(()=>{});return}const _=JSON.parse(K.data);if(_.type==="driving"){a("driving"),o(null);return}(_.type==="refused"||_.type==="ended")&&(o(_.error??"The screen cannot be driven from here."),a("refused"))},U.onclose=()=>{M&&a(K=>K==="refused"?K:"lost")},U.onerror=()=>{M&&a(K=>K==="refused"?K:"lost")},()=>{M=!1,k.current=null;try{U.close()}catch{}}},[e,t,j,r]),h.useEffect(()=>()=>{clearTimeout(y.current.timer)},[]);const v=h.useCallback(T=>{const M=k.current;if(M)try{M.send(JSON.stringify({type:"input",input:T}))}catch{}},[]),N=T=>{var K;const M=g.current;if(!M||!f)return null;const U=(K=M.getBoundingClientRect)==null?void 0:K.call(M);return U?LF(U,f,T.clientX,T.clientY):null},b=T=>{const M=y.current,U=Date.now();clearTimeout(M.timer),M.timer=void 0;const K=M.at+zF-U;if(K<=0){M.at=U,M.pending=void 0,v(T);return}M.pending=T,M.timer=setTimeout(()=>{const _=y.current.pending;y.current.timer=void 0,y.current.pending=void 0,y.current.at=Date.now(),_&&v(_)},K)},S=()=>{const T=y.current;clearTimeout(T.timer),T.timer=void 0;const M=T.pending;T.pending=void 0,M&&(T.at=Date.now(),v(M))},C=T=>M=>{var _,q;const U=N(M);if(!U)return;T==="mousePressed"&&(M.preventDefault(),(q=(_=g.current)==null?void 0:_.focus)==null||q.call(_));const K={kind:"mouse",type:T,x:U.x,y:U.y,button:BF[M.button]??"left",clickCount:T==="mouseMoved"?0:Math.min(3,Math.max(1,M.detail||1)),modifiers:Uh(M)};if(T==="mouseMoved"){b(K);return}S(),v(K)},R=T=>{const M=N(T);M&&(S(),v({kind:"wheel",x:M.x,y:M.y,deltaX:Math.round(T.deltaX),deltaY:Math.round(T.deltaY)}))},E=T=>T.ctrlKey||T.metaKey||T.altKey,P=T=>{var U,K;if(T.key==="Escape"&&E(T)){p(!1),(K=(U=T.target).blur)==null||K.call(U);return}if(T.preventDefault(),(T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))return;const M=Uh(T);if(_y(T.key)&&!E(T)){v({kind:"key",type:"char",key:T.key,code:T.code,text:T.key,modifiers:M});return}v({kind:"key",type:"keyDown",key:T.key,code:T.code,modifiers:M})},L=T=>{T.key==="Escape"&&E(T)||(T.preventDefault(),!((T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))&&(_y(T.key)&&!E(T)||v({kind:"key",type:"keyUp",key:T.key,code:T.code,modifiers:Uh(T)})))},$=T=>{var U;T.preventDefault();const M=UF(((U=T.clipboardData)==null?void 0:U.getData("text/plain"))??"");M!==""&&v({kind:"text",text:M})};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 M,U,K,_;const T=!m;p(T),T?(U=(M=x.current)==null?void 0:M.focus)==null||U.call(M):(_=(K=x.current)==null?void 0:K.blur)==null||_.call(K)},children:"Keyboard"}),n.jsx(I,{size:"sm",variant:"accent",onClick:s,children:"Give it back"})]})]}),i==="lost"?n.jsxs(W,{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(W,{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:L,onPaste:$,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:L,onPaste:$,onBlur:()=>p(!1)})]})}function GF(e){return e==="darwin"?"this Mac":"this computer"}let Bh=null;function lx(){const[e,t]=h.useState(void 0);return h.useEffect(()=>{let s=!0;return Bh??(Bh=A.session().then(r=>r.platform,()=>{Bh=null})),Bh.then(r=>{s&&t(r)}),()=>{s=!1}},[]),GF(e)}function YF({embedded:e,timezone:t}={}){var c;const{data:s,error:r,reload:i}=se(()=>A.browser(),[],3e3),a=se(()=>A.session(),[]),l=(c=a.data)!=null&&c.platform?a.data.platform==="darwin":!0,o=!!a.data||!!a.error;return n.jsxs(hn,{embedded:e,title:"Computer & browser",children:[n.jsx(te,{message:r}),!s||!o?n.jsx(oe,{children:"Checking the host…"}):n.jsx(qF,{data:s,macOS:l,reload:i,timezone:t},JSON.stringify(s.settings??null))]})}function qF({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]:[],j=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",v=(x==null?void 0:x.engine)==="none",N=!!e.enabled&&!v&&!(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(V,{gap:"lg",children:[n.jsx(te,{message:l}),n.jsx(Y,{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||j,onClick:()=>void w(()=>A.computerPermissions(!0)),children:"Request macOS permissions"}):null,v||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(V,{children:[e.enabled?v?n.jsxs(W,{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(W,{tone:"warning",children:x.message}):N?n.jsx(W,{tone:"good",children:b}):n.jsx(W,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):n.jsx(W,{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(ZN,{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&&!v?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(Y,{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(ms,{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(Y,{title:"How agents get a screen",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?n.jsx(zh,{current:f.mode,value:"computer",disabled:i||j||!e.enabled,title:"Use my apps",body:"Agents work in your own windows, signed in as you, in the browser profile you choose below. One agent at a time. Releasing control leaves everything open.",onPick:()=>k({...f,mode:"computer"})}):null,n.jsx(zh,{current:f.mode,value:"playwright",disabled:i||j||!e.enabled,title:"Give agents their own browser",body:"A separate browser profile with its own tabs, one per conversation. Your apps are never touched.",onPick:()=>k({...f,mode:"playwright"})}),n.jsx(zh,{current:f.mode,value:"extension",disabled:i||j||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>k({...f,mode:"extension"})})]}),t?null:n.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),j?n.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,f.mode==="extension"?n.jsx(ZF,{busy:i,timezone:r}):null]})}),t?n.jsx(Y,{title:"Apps agents may use",panel:!0,children:n.jsxs(V,{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(e4,{settings:f,disabled:i||j||!e.enabled,onChange:k,onAdd:()=>u(!0)}),n.jsx(Mt,{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(i4,{chosen:f.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),f.allowedApps.includes(E)||k({...f,allowedApps:[...f.allowedApps,E]})}}):null]}):null]})}const QF="kmbckpnnjfggeffkkbmkggojnolkdokb";async function JF(){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(QF,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function XF(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function ZF({busy:e,timezone:t}){const{data:s,error:r,reload:i}=se(()=>A.extension(),[],3e3),a=lx(),l=se(()=>JF(),[],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 j=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(V,{divided:!0,children:[n.jsx(te,{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(V,{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&&!XF(l.gateway)?n.jsx(W,{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(X,{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(Ms,{}),n.jsx(I,{variant:"accent",disabled:w||o.replace(/[^0-9]/g,"").length!==6,onClick:()=>void j(async()=>{await A.pairExtension(o),c("")}),children:"Pair"})]}):null,s!=null&&s.connected?n.jsx(Mt,{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 j(()=>A.forgetExtension()),children:"Forget this browser"})})]})}function zh({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 e4({settings:e,disabled:t,onChange:s,onAdd:r}){const i=se(()=>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(ms,{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&&r4(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"&&t4.includes(e.browserApp)?n.jsx(n4,{settings:e,disabled:t,onChange:s}):null]})}const t4=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function n4({settings:e,disabled:t,onChange:s}){var l;const i=((l=se(()=>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(X,{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 s4=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function r4(e){return s4.includes(e)}function i4({chosen:e,onClose:t,onPick:s}){const r=se(()=>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(tn,{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(te,{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(ms,{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(Mt,{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 a4({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,j]=h.useState(null),[w,k]=h.useState(null),g=async L=>{f(!0),m(null),k(null);try{const $=L!=="stop"&&(e!=null&&e.session)?await A.browserControl(L,e.session.id):await A.browserControl(L);L==="takeover"?$.hand&&$.session?j($.session.id):k($.handMessage??null):j(null)}catch($){m($ instanceof Error?$.message:String($))}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,v=(e==null?void 0:e.mode)==="computer",N=(e==null?void 0:e.mode)==="extension",b=v?"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:v?"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:v?"Open computer view & settings ↗":"Open full browser view ↗"}):n.jsx("p",{className:"ui-page-lede",children:v?"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(te,{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:v?"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:v?"Release control":"Close & release"})]}):null,c?r?n.jsx(Mt,{summary:"About these controls",children:n.jsx("p",{className:"muted",children:b})}):n.jsx("p",{className:"muted",children:b}):null,w?n.jsx(W,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!x?n.jsx(W,{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?v?"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(KF,{sessionId:x,csrf:Ni(),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)??(v?"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:v?"Your selected app will appear here":"Your browser activity will appear here"}),n.jsx("p",{children:v?"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(Mt,{summary:`${e.page.tabs.length} open tabs`,children:n.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(L=>n.jsxs("li",{children:[L.title||L.id," — ",L.url]},L.id))})}):null,n.jsxs("p",{className:"muted",children:[v?"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 l4=2e3,o4=5;function c4(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 u4({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>=o4;h.useEffect(()=>{if(!i||f)return;const v=window.setInterval(()=>{typeof document<"u"&&document.hidden||o(N=>N+1)},l4);return()=>window.clearInterval(v)},[i,f]);const d=h.useRef(null);i&&(e!=null&&e.session)&&(d.current=e);const[m,p]=h.useState(null),j=h.useRef(null),w=((y=e==null?void 0:e.page)==null?void 0:y.id)??null;h.useEffect(()=>{const v=i&&e?c4(e):null;if(!v||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let N=!1;return(async()=>{try{const b=await fetch(v);if(!b.ok||N)return;const S=await b.blob();if(N)return;const C=URL.createObjectURL(S);j.current&&URL.revokeObjectURL(j.current),j.current=C,p(C)}catch{}})(),()=>{N=!0}},[i,w]),h.useEffect(()=>()=>{j.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(j.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(a4,{data:g,error:t,reload:s,compact:!0,controls:i,...i?{refresh:l}:{},...!i&&m?{screenshotSrc:m}:{},onScreenshotError:()=>u(v=>v+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 h4({agentId:e,conversationId:t}){const{data:s,error:r,reload:i}=se(()=>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(j){l(j instanceof Error?j.message:String(j))}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(Mt,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":m}${d.length?` · ${d.length} running`:""}`,children:n.jsxs(V,{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(te,{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(V,{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 e1="browser.act",f4="browser.status",Kc=new Set([e1,f4]);function m4(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 p4(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function g4(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===e1){const o={id:a.id,action:x4(a.input)??"act",target:v4(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:j4(a)}}return t}function Oy(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=Kc.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 x4(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function v4(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 j4(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 y4({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?Oe.groupConversations(t):Oe.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?Cl(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 t1="buddi.dismissedTabs";function w4(){try{const e=JSON.parse(sessionStorage.getItem(t1)??"{}");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 Ly(e){try{sessionStorage.setItem(t1,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const b4=350,k4=60;function S4({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)},j=async()=>{if(a.current!=="idle")return;m.current.onNotice(null),l("starting"),c.current=null;let x;try{x=await ZO(N=>{var b;return(b=d.current)==null?void 0:b.call(d,N)})}catch(N){f.current=null,l("idle"),m.current.onNotice(XO(N));return}const y=c.current;c.current=null;const v=a.current;if(y==="discard"||v!=="starting"){x.cancel(),v==="starting"&&l("idle");return}o.current=x,l("recording"),u.current=window.setTimeout(()=>void w(!1),qO),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 v=await y.stop();if(v.size<=44){m.current.onNotice("Nothing was recorded.");return}const N=new File([v],`recording-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.wav`,{type:"audio/wav"}),b=await Oe.attach(N),S=m.current.conversationId,C=await Oe.transcribe({artifactId:b.artifactId,...S?{conversationId:S}:{}});m.current.onText(C.text,x)}catch(v){m.current.onNotice(v instanceof ae||v instanceof Error?v.message:String(v))}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 v=Date.now()-f.current;f.current=null,v>=b4&&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(),j()},start:()=>{f.current=null,j()},finish:x=>void w(x),discard:k,levels:d}}function N4({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 C4({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(E4,{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 E4({sink:e,frozen:t}){const[s,r]=h.useState(()=>Array(k4).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 A4="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",pc="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",T4=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function R4(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(A4);let s;try{s=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(T4(i))return null;throw new Error(pc)}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(pc))}),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(pc);o.drawImage(a,0,0);const c=await new Promise(f=>l.toBlob(f,"image/png"));if(!c)throw new Error(pc);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 Fy="Send files once the agent has answered.",Wm="wb-composer-input",ox=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:j,conversationId:w,readAloud:k,onReadAloud:g,placeholder:x},y){var Vr;const v=j?`buddi.draft.${j}`:null,N=z=>{if(!z)return"";try{return window.localStorage.getItem(z)??""}catch{return""}},[b,S]=h.useState(()=>N(v)),[C,R]=h.useState([]),[E,P]=h.useState(!1),[L,$]=h.useState(null),[T,M]=h.useState(!1),U=h.useRef(null),K=h.useRef(null),[_,q]=h.useState(null),[B,H]=h.useState(0),ue=_&&m?m.filter(z=>z.handle.toLowerCase().startsWith(_.query.toLowerCase())||z.name.toLowerCase().startsWith(_.query.toLowerCase())).slice(0,6):[],re=(z,je)=>{if(!m||m.length===0){q(null);return}const qe=z.slice(0,je),xt=/(^|\s)@([\w-]*)$/.exec(qe);if(!xt){q(null);return}q({start:je-xt[2].length-1,query:xt[2]}),H(0)},ie=z=>{if(!_)return;const je=K.current,qe=je?je.selectionStart:b.length,xt=`${b.slice(0,_.start)}@${z} ${b.slice(qe)}`;S(xt),Z<0&&ne(xt),q(null),window.requestAnimationFrame(()=>{if(!je)return;const nn=_.start+z.length+2;je.focus(),je.setSelectionRange(nn,nn),pt()})},Ne=p??[],[Z,ce]=h.useState(-1),de=h.useRef(b),Ae=h.useRef(v);if(Ae.current!==v){Ae.current=v;const z=N(v);de.current=z,z!==b&&(S(z),ce(-1),q(null))}const ne=z=>{if(de.current=z,!!v)try{z===""?window.localStorage.removeItem(v):window.localStorage.setItem(v,z)}catch{}},be=z=>{S(z),q(null);const je=K.current;je&&(je.value=z,je.setSelectionRange(z.length,z.length)),window.requestAnimationFrame(pt)},Te=z=>!z.value.slice(0,z.selectionStart??z.value.length).includes(`
104
+ `),Ze=()=>b===""||Z>=0&&b===Ne[Z],Ie=()=>{Z<0||(ce(-1),be(de.current))},it=C.some(z=>z.state==="uploading"),fe=C.length>0,ve=s&&fe,Le=!t&&!it&&!ve&&b.trim()!=="",Me=z=>{for(const je of Array.from(z??[])){const qe=`${je.name}:${je.size}:${Math.random().toString(36).slice(2,8)}`,xt=je.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(je):null;R(nn=>[...nn,{key:qe,filename:je.name||"Pasted image",mime:je.type||"application/octet-stream",sizeBytes:je.size,thumbnail:xt,state:"uploading"}]),Oe.attach(je).then(nn=>R(Os=>Os.map(Lt=>Lt.key===qe?{...Lt,state:"ready",uploaded:nn}:Lt))).catch(nn=>R(Os=>Os.map(Lt=>Lt.key===qe?{...Lt,state:"failed",error:nn instanceof ae?nn.message:String(nn)}:Lt)))}},ot=z=>{z.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(z.thumbnail)},ke=z=>{const je=C.find(qe=>qe.key===z);je&&(ot(je),je.state==="ready"&&je.uploaded&&Oe.discardAttachment(je.uploaded.artifactId).catch(()=>{})),R(qe=>qe.filter(xt=>xt.key!==z))};h.useImperativeHandle(y,()=>({addFiles:z=>{var je;Me(z),(je=K.current)==null||je.focus()},focus:()=>{var z;return(z=K.current)==null?void 0:z.focus()}}));const _e=h.useRef(C);_e.current=C,h.useEffect(()=>()=>_e.current.forEach(ot),[]);const Ce=h.useRef(0);h.useEffect(()=>{if(!l||l.at===Ce.current)return;Ce.current=l.at,S(je=>je.trim()===""?l.text:je),Z<0&&b.trim()===""&&ne(l.text);const z=K.current;z&&(z.focus(),window.requestAnimationFrame(()=>{z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,200)}px`,z.setSelectionRange(z.value.length,z.value.length)}))},[l]);const pt=()=>{const z=K.current;z&&(z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,200)}px`)},D=z=>{const je=(z??b).trim();if(z===void 0?!Le:t||it||ve||je==="")return;const qe=C.filter(xt=>xt.state==="ready"&&xt.uploaded).map(xt=>xt.uploaded);r(je,qe),C.forEach(ot),ce(-1),ne(""),S(""),R([]),window.requestAnimationFrame(pt)},ge=z=>{if(_&&ue.length>0){if(z.key==="ArrowDown"){z.preventDefault(),H(je=>(je+1)%ue.length);return}if(z.key==="ArrowUp"){z.preventDefault(),H(je=>(je-1+ue.length)%ue.length);return}if(z.key==="Enter"||z.key==="Tab"){z.preventDefault(),ie(ue[B].handle);return}if(z.key==="Escape"){z.preventDefault(),q(null);return}}if(z.key==="ArrowUp"&&!z.shiftKey&&!z.altKey&&!z.metaKey&&!z.ctrlKey){const je=z.currentTarget;if(Ne.length>0&&Z+1<Ne.length&&Te(je)&&Ze()){z.preventDefault(),Z<0&&(de.current=b),ce(Z+1),be(Ne[Z+1]);return}}if(z.key==="ArrowDown"&&!z.shiftKey&&!z.altKey&&!z.metaKey&&!z.ctrlKey&&Z>=0&&b===Ne[Z]){if(z.preventDefault(),Z===0){Ie();return}ce(Z-1),be(Ne[Z-1]);return}if(z.key==="Escape"&&Z>=0){z.preventDefault(),Ie();return}z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),D())},Je=z=>{var qe;const je=Array.from(((qe=z.clipboardData)==null?void 0:qe.files)??[]);je.length!==0&&(z.preventDefault(),Me(je))},Ge=C.filter(z=>z.state==="failed"),gt=Ge.length,Be=S4({conversationId:w??null,onNotice:$,onText:(z,je)=>{const qe=b.trim()===""?z:`${b.replace(/\s+$/,"")} ${z}`;if(je){D(qe);return}be(qe),Z<0&&ne(qe)}}),at=Be.state!=="idle",gs=h.useRef(!1);return h.useEffect(()=>{var z;gs.current&&!at&&((z=K.current)==null||z.focus(),window.requestAnimationFrame(pt)),gs.current=at},[at]),n.jsx("div",{className:"wb-composer","data-testid":"composer","data-busy":b.trim()!==""||fe||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(z=>n.jsx("span",{role:"listitem",children:n.jsx(Ad,{name:z.filename,mime:z.mime,sizeBytes:z.sizeBytes,thumbnail:z.thumbnail,state:z.state,error:z.error,onRemove:()=>ke(z.key),...d&&z.state==="ready"&&z.uploaded?{onOpen:()=>d(I4(z.uploaded))}:{},size:"sm"})},z.key))}):null,n.jsxs("label",{className:"sr-only",htmlFor:Wm,children:["Message ",a]}),n.jsx("textarea",{id:Wm,ref:K,value:b,rows:2,placeholder:s?`${a} is working…`:x??`Message ${a}`,onChange:z=>{S(z.target.value),Z<0&&ne(z.target.value),re(z.target.value,z.target.selectionStart??z.target.value.length),pt()},onFocus:()=>M(!0),onBlur:()=>M(!1),onKeyDown:ge,onPaste:Je,disabled:t,hidden:at}),at?n.jsx(C4,{voice:Be}):null,!at&&_&&ue.length>0?n.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:ue.map((z,je)=>n.jsxs("button",{type:"button",role:"option","aria-selected":je===B,className:"wb-mention","data-active":je===B||void 0,onMouseDown:qe=>{qe.preventDefault(),ie(z.handle)},children:[n.jsxs("span",{className:"wb-mention-handle",children:["@",z.handle]}),n.jsx("span",{className:"wb-mention-name",children:z.name})]},z.handle))}):null,n.jsxs("div",{className:"wb-composer-row",hidden:at,children:[n.jsx("input",{ref:U,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:z=>{Me(z.target.files),z.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 z;return(z=U.current)==null?void 0:z.click()},disabled:t,children:n.jsx(Se,{name:"clip"})}),n.jsx(N4,{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:()=>{$(null),P(!0),R4().then(z=>{var je;z&&(Me([z]),(je=K.current)==null||je.focus())}).catch(z=>$(z instanceof Error?z.message:String(z))).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":gc(u),disabled:t||s,title:s?`Wait for ${a} to finish — this run started with thinking ${gc(u)?"on":"off"}`:gc(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(gc(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||ve||L!==null,"data-tone":gt>0||L!==null?"critical":void 0,children:gt>0?gt===1&&((Vr=Ge[0])!=null&&Vr.error)?Ge[0].error:`${gt} files failed to upload and will not be sent`:L!==null?L:ve?Fy:"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:ve?Fy:it?"Waiting for the upload to finish":s?`Send — ${a} picks it up between steps`:"Send",onClick:()=>D(),disabled:!Le,children:n.jsx(Se,{name:"send"})})]})]})})});function gc(e){return(e??"on")==="on"}function I4(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function P4({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 M4(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function $4(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 D4(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 ${$4(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(M4(t,r))return{text:`${l} · your next message starts a fresh one`,title:a,tone:"note"};const o=s?De(s,r):"";return{text:o===""?l:`${l} · started ${o}`,title:s?`Started ${Ve(s,i)}. ${a}`:a,tone:"quiet"}}const Gc=320,n1="buddi.chatWidth";function _4({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:j,requestedTab:w,onConversationOpened:k}){var ev,tv,nv,sv,rv,iv;const g=lx(),[x,y]=h.useState([]),[v,N]=h.useState(null),[b,S]=h.useState(null),[C,R]=h.useState(null),[E,P]=h.useState([]),[L,$]=h.useState([]),[T,M]=h.useState(null),[U,K]=h.useState(!1),[_,q]=h.useState(new Map),[B,H]=h.useState(null),[ue,re]=h.useState(w4),[ie,Ne]=h.useState([]),[Z,ce]=h.useState(!1),de=h.useRef(0),Ae=h.useRef(null),[ne,be]=h.useState(!1),Te=h.useRef(p??0),Ze=h.useRef(s),Ie=h.useRef({agentId:s,conversationId:v});Ie.current={agentId:s,conversationId:v};const it=ue[v??""]??[],[fe,ve]=h.useState(null),[Le,Me]=h.useState(null),[ot,ke]=h.useState(null),[_e,Ce]=h.useState([]),[pt,D]=h.useState(!1),[ge,Je]=h.useState(()=>Date.now()),[Ge,gt]=h.useState(O4),Be=h.useRef(null),[at,gs]=h.useState(null),[Vr,z]=h.useState(!1),[je,qe]=h.useState(null),[xt,nn]=h.useState(BN),Os=h.useRef(xt);Os.current=xt;const Lt=h.useRef(null),[sn,Ii]=h.useState(null),jE=h.useCallback(O=>{nn(O),zN(O),O||Ha()},[]),[yE,wE]=h.useState(null),[bE,Dx]=h.useState(null);h.useEffect(()=>{if(!s)return;const O=B4(s);O&&qe({text:O,at:Date.now()})},[s]);const Kr=i?`group:${i.id}`:s??null,zn=[...t.top,...t.middle,...t.bottom],ye=zn.find(O=>O.id===s)??null,kE=se(()=>A.providerAccounts(),[]),Pi=i?i.members.map(O=>zn.find(G=>G.id===O)).filter(O=>!!O):[],[$d,_x]=h.useState(null);h.useEffect(()=>{let O=!1;return Oe.views().then(G=>{O||y(G.views??[])}).catch(()=>{}),()=>{O=!0}},[]),h.useEffect(()=>{if(!s)return;const O=Ze.current===s;if(Ze.current=s,O&&j&&j===Ie.current.conversationId)return;let G=!1;return N(null),S(null),R(null),P([]),ve(null),K(!1),H(null),Ne([]),Ao(null),be(!1),gs(null),j?(j!=="new"?N(j):R(Kr),()=>{G=!0}):((i?Oe.groupConversations(i.id):Oe.conversations(s)).then(me=>{if(G)return;const we=[...me.conversations??[]].sort(L4)[0];we?(N(we.id),k==null||k(s,we.id)):R(Kr)}).catch(()=>{G||R(Kr)}),()=>{G=!0})},[s,i==null?void 0:i.id,Kr,j,k]);const xs=h.useCallback(O=>Oe.conversation(O).then(G=>{if(Ie.current.conversationId===O){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(me=>me.filter(we=>!Wh(G,we)))}}).catch(G=>{Ie.current.conversationId===O&&ve(cr(G))}),[]);h.useEffect(()=>{if(!v)return;let O=!1;return q(new Map),$([]),Oe.conversation(v).then(G=>{if(!O){if(G.agentId!==s)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");S(G),P(me=>me.filter(we=>!Wh(G,we)))}}).catch(G=>{O||ve(cr(G))}),()=>{O=!0}},[v,s]),h.useEffect(()=>{if(!v)return;let O=!1;const G=window.setInterval(()=>{Oe.conversation(v).then(me=>{O||me.agentId!==Ie.current.agentId||(S(me),P(we=>we.filter(ze=>!Wh(me,ze))))}).catch(()=>{})},3e3);return()=>{O=!0,window.clearInterval(G)}},[v,s]),h.useEffect(()=>{if(!v)return;const O=jd({url:Oe.streamUrl(v),onEvent:G=>{var me;switch(G.name){case"run.started":Lt.current=null,K(!0),M(null),_x(Ft(G.data.agentId));break;case"live":{const we=Ft(G.data.runId)??"",ze=Number(G.data.turn??0),Pe=G.data.kind==="thinking"?"thinking":"text",rn=Ft(G.data.text)??"",Ls=Date.now();if(Pe==="text"){const vs=Lt.current;Lt.current=vs&&vs.runId===we&&vs.turn===ze?{...vs,text:vs.text+rn}:{runId:we,turn:ze,text:rn}}M(vs=>{const _i=vs&&vs.runId===we&&vs.turn===ze?vs:{runId:we,turn:ze,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return Pe==="thinking"?{..._i,thinking:_i.thinking+rn,thinkingStartedAt:_i.thinkingStartedAt??Ls}:{..._i,text:_i.text+rn,textStartedAt:_i.textStartedAt??Ls}});break}case"live.snapshot":{const we=Ft(G.data.runId)??"",ze=Number(G.data.turn??0),Pe=Ft(G.data.text)??"",rn=Ft(G.data.thinking)??"",Ls=Number(G.data.startedAt??Date.now());Lt.current={runId:we,turn:ze,text:Pe},M({runId:we,turn:ze,text:Pe,thinking:rn,thinkingStartedAt:rn?Ls:null,textStartedAt:Pe?Ls:null,settled:!1});break}case"live.settle":{const we=Ft(G.data.runId)??"",ze=Number(G.data.turn??0);M(Pe=>Pe&&Pe.runId===we&&Pe.turn===ze?{...Pe,settled:!0}:Pe);break}case"tool.called":{const we=Ft(G.data.toolUseId)??Ft(G.data.id),ze=Ft(G.data.name)??Ft(G.data.tool)??"tool";we&&$(Pe=>[...Pe.filter(rn=>rn.toolUseId!==we),{toolUseId:we,name:ze,startedAt:Date.now()}]);break}case"tool.result":{const we=Ft(G.data.toolUseId)??Ft(G.data.id);we&&$(ze=>ze.filter(Pe=>Pe.toolUseId!==we)),xs(v);break}case"message.appended":xs(v).then(()=>{M(we=>we!=null&&we.settled?null:we)});break;case"awaiting-approval":{const we=Ft(G.data.approvalId)??Ft(G.data.actionId),ze=Ft(G.data.toolUseId);we&&ze&&q(Pe=>new Map(Pe).set(ze,we)),$(Pe=>Pe.filter(rn=>rn.toolUseId!==ze)),xs(v);break}case"run.finished":{K(!1),$([]),M(null),_x(null);const we=Ft(G.data.message);ve(we??null);const ze=((me=Lt.current)==null?void 0:me.text.trim())??"";Lt.current=null,!we&&ze!==""&&Os.current&&Pu(ze,v).then(Pe=>{Pe&&Ii(Pe)}),xs(v);break}}}});return()=>O.close()},[v,xs]),h.useEffect(()=>{const O=window.setInterval(()=>Je(Date.now()),L.length===0?6e4:1e3);return()=>window.clearInterval(O)},[L.length]);const Eo=se(()=>s&&v?A.browser({agentId:s,conversationId:v}):Promise.resolve(void 0),[s,v],1500),Mi=Eo.error?void 0:Eo.data,Ya=Mi!=null&&Mi.session&&Mi.session.agentId===s&&Mi.session.conversationId===v?Mi:void 0,Gr=m4(Ya,s,v),Yr=(Gr==null?void 0:Gr.id)??null,[qa,SE]=h.useState(null),Ox=Ya==null?void 0:Ya.mode;h.useEffect(()=>{Gr&&s&&v&&SE({agentId:s,conversationId:v,tab:p4(Gr,Ox)})},[Yr,Ox,s,v]);const NE=qa&&qa.agentId===s&&qa.conversationId===v&&!it.includes(qa.tab.id)?qa.tab:null,Yt=Gr??NE,CE=h.useMemo(()=>g4((b==null?void 0:b.messages)??[]),[b]),[EE,Ao]=h.useState(null),AE=h.useMemo(()=>xL({messages:(b==null?void 0:b.messages)??[],descriptors:x}),[b,x]),$i=PF(AE,v??null),Dd=$F(i?null:s),Lx=h.useMemo(()=>MF((b==null?void 0:b.messages)??[]),[b]),Cn=h.useMemo(()=>{const G=vL({messages:(b==null?void 0:b.messages)??[],descriptors:x,awaiting:_,served:$i.served,...Yt?{folded:Kc}:{}}).filter(me=>me.source==="approval"||!it.includes(me.id));if(B&&!it.includes(B)&&!G.some(me=>me.id===B)){const me=bL((b==null?void 0:b.messages)??[],B,{redactInputOf:Kc});me&&!Kc.has(me.tool)&&G.push(me)}Yt&&G.push(Yt);for(const me of ie)G.push(V_(me));return Dd&&G.unshift(DF(Dd,Lx)),at?[...G,_F(at)]:G},[b,x,_,at,Yr,Yt==null?void 0:Yt.title,B,ue,v,ie,$i.served,Dd,Lx]),TE=h.useMemo(()=>{var G;const O=[];for(const me of(b==null?void 0:b.messages)??[]){if(me.role!=="user"||me.speaker&&me.speaker!=="owner")continue;const we=(G=me.blocks.find(ze=>ze.type==="text"))==null?void 0:G.text.trim();we&&O.unshift(we)}return O},[b]),_d=h.useMemo(()=>Cn.filter(O=>O.source==="approval"),[Cn]),To=_d.at(-1)??null,Ro=h.useMemo(()=>[..._d.map(O=>({approvalId:O.props.approvalId,toolUseId:O.id})),...((b==null?void 0:b.delegatedApprovals)??[]).map(O=>({approvalId:O.approvalId,toolUseId:O.toolUseId??"",askedBy:V4(O.chain,zn)}))],[_d,b==null?void 0:b.delegatedApprovals]),Qa=h.useMemo(()=>{for(let O=Cn.length-1;O>=0;O-=1){const G=Cn[O];if(G!=null&&G.substantial)return G.id}return null},[Cn]),Io=h.useRef(null),Od=((ev=Cn.filter(O=>(O.source!=="browser"||O.pinned===!0)&&O.id!==Bm).at(-1))==null?void 0:ev.id)??((tv=Cn.filter(O=>O.id!==Bm).at(-1))==null?void 0:tv.id)??null;h.useEffect(()=>{if(Qa&&Qa!==Io.current){Io.current=Qa,H(Qa);return}B===null&&Od&&H(Od)},[Qa,B,Od]);const Fx=h.useRef($i.live);h.useEffect(()=>{const O=Fx.current;Fx.current=$i.live;const G=[...$i.live].filter(ze=>!O.has(ze));if(G.length===0||To||B!==null&&B!==Io.current)return;const we=[...Cn].reverse().find(ze=>ze.source==="descriptor"&&ze.renderer==="preview"&&ze.props.target!==null&&G.includes(pa(ze.props.target)));we&&H(we.id)},[$i.live,Cn,To,B]);const Ux=h.useRef(null);h.useEffect(()=>{Yr!==Ux.current&&(Ux.current=Yr,Yr&&!To&&H(Yr))},[Yr,To]);const Bx=h.useRef(null),Ja=w==="browser"?(Yt==null?void 0:Yt.id)??null:null;h.useEffect(()=>{!Ja||Bx.current===Ja||(Bx.current=Ja,H(Ja))},[Ja]);const Ld=(Yt==null?void 0:Yt.id)??null;h.useEffect(()=>{!Ld||!B||Oy((b==null?void 0:b.messages)??[],B)!==null&&(Ao(B),H(Ld))},[Ld,B,b]);const zx=O=>{Ne(G=>G.some(me=>me.artifactId===O.artifactId)?G:[...G,O]),H(Vc(O.artifactId)),u&&(d==null||d())},Po=!i&&ye&&!ye.available?nN(ye):null,Wx=bm(i?null:ye),Hx=((b==null?void 0:b.offers)??[]).filter(O=>!_e.includes(O.id)&&Date.parse(O.expiresAt)>ge),RE=ye&&bE===ye.id?yE:(ye==null?void 0:ye.thinking)??null,IE=O=>{if(!ye)return;const G=ye.id;Dx(G),wE(O),A.setAgentEngine(G,{thinking:O}).catch(me=>{Dx(null),ve(me instanceof ae?me.message:String(me))})},Vx=(O,G)=>{if(!s)return;const me=G.map(Pe=>Pe.artifactId),we=U,ze={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:O},...G.map(Pe=>({type:"attachment",artifactId:Pe.artifactId,filename:Pe.filename,mime:Pe.mime,kind:Pe.kind,sizeBytes:Pe.sizeBytes}))],...we?{speaker:QN}:{}};P(Pe=>we?[...Pe,ze]:[ze]),ve(null),Me(null),K(!0),(i?Oe.sendToGroup(i.id,{...v?{conversationId:v}:{},text:O,attachmentIds:me}):Oe.send(s,{...v?{conversationId:v}:{},text:O,attachmentIds:me})).then(async Pe=>{Ie.current.agentId!==s||Ie.current.conversationId!==v||(Me(Pe.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),Pe.conversationId!==v?(S(null),N(Pe.conversationId)):await xs(Pe.conversationId),Pe.queued===!0&&P(rn=>rn.filter(Ls=>Ls.id!==ze.id)),k==null||k(s,Pe.conversationId))}).catch(Pe=>{P(rn=>rn.filter(Ls=>Ls.id!==ze.id)),ve(cr(Pe)),K(!1)})},PE=O=>{ve(null),ke(O),Ce(G=>[...G,O]),A.takeOffer(O,v??void 0).then(G=>{G.runId&&(Me(null),K(!0)),v&&xs(v)}).catch(G=>{Ce(me=>me.filter(we=>we!==O)),ve(cr(G)),v&&xs(v)}).finally(()=>ke(null))},ME=(O,G)=>Kx({answer:O,...G?{optionId:G}:{}}),$E=()=>Kx({answer:"",skipped:!0}),Kx=O=>{const G=b==null?void 0:b.question;G&&(ve(null),D(!0),K(!0),Oe.answerQuestion(G.id,O).then(()=>{if(v)return xs(v)}).catch(me=>{ve(cr(me)),K(!1)}).finally(()=>D(!1)))},DE=()=>{if(s){if(at){gs(null);return}z(!0),A.agentProfile(s).then(O=>{gs(O),H(zm(O.id)),u&&(d==null||d())}).catch(O=>ve(cr(O))).finally(()=>z(!1))}},_E=O=>{qe({text:O.prompt,at:Date.now()}),l(O.agentId),u&&(m==null||m())},OE=()=>{v&&Oe.cancel(v).catch(O=>ve(cr(O))).finally(()=>{K(!1),$([])})},Mo=h.useCallback(()=>{if(N(null),S(null),P([]),K(!1),ve(null),Me(null),$([]),q(new Map),H(null),Ne([]),Ao(null),Io.current=null,i){Oe.startGroupConversation(i.id).then(({conversationId:O})=>{N(O),s&&(k==null||k(s,O))}).catch(O=>ve(cr(O)));return}R(Kr),s&&(k==null||k(s,"new"))},[s,i,Kr,k]);h.useEffect(()=>{p&&p!==Te.current&&(Te.current=p,Mo())},[p,Mo]);const Gx=O=>{v&&xs(v),A.overview().catch(()=>{}),O.state!=="pending"&&q(G=>new Map([...G].filter(([,me])=>me!==O.id)))},$o=h.useRef(!1);h.useEffect(()=>{const O=me=>{if(!$o.current)return;const we=Math.max(Gc,Math.min(720,me.clientX-52));gt(we)},G=()=>{if($o.current){$o.current=!1;try{Ge!==null&&window.localStorage.setItem(n1,String(Ge))}catch{}}};return window.addEventListener("pointermove",O),window.addEventListener("pointerup",G),()=>{window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",G)}},[Ge]);const LE=((nv=zn.find(O=>O.id===r))==null?void 0:nv.name)??null,Yx=i?[]:RD(ye,LE),qx=!(b&&b.conversationId===v)&&!(!v&&C!==null&&C===Kr),Qx=qx?n.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&ye?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(xn,{agents:zn,id:ye.id,size:"xl"}),n.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${ye.name}.`}),n.jsx("p",{className:"wb-chat-intro",children:ID(ye)}),Yx.length>0?n.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${ye.name}`,children:Yx.map(O=>n.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var G;qe({text:O,at:Date.now()}),(G=Ae.current)==null||G.focus()},children:O},O))}):null]})}):null,Jx=n.jsx(yF,{renderables:Cn,activeId:B,onActivate:H,onClose:O=>{at&&O===zm(at.id)?gs(null):ie.some(G=>Vc(G.artifactId)===O)?Ne(G=>G.filter(me=>Vc(me.artifactId)!==O)):v&&re(G=>{const me={...G,[v]:[...new Set([...G[v]??[],O])]};return Ly(me),me}),B===O&&H(null)},timezone:e,onDecided:Gx,onChangeAgent:_E,agents:zn,browserPanel:Yt?n.jsx(u4,{status:Ya,error:Eo.error,reload:Eo.reload,steps:CE,live:Gr!==null,focusedStepId:EE},Yt.id):null,descriptors:x,grantedTools:i?Pi.flatMap(O=>O.tools??[]):(ye==null?void 0:ye.tools)??[],...ye?{agentName:ye.name}:{},loading:qx,...!i&&ye?{face:n.jsx(xn,{agents:zn,id:ye.id,size:"xl"})}:{}}),Xx=(rv=(sv=[...(b==null?void 0:b.messages)??[],...E].find(O=>O.role==="user"))==null?void 0:sv.blocks.find(O=>O.type==="text"))==null?void 0:rv.text.trim(),Zx=Xx?Xx.split(`
105
+ `)[0]:"New conversation",Di=D4({lifetime:(b==null?void 0:b.lifetime)??null,startedAt:(b==null?void 0:b.startedAt)??null,now:ge,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":Z||void 0,onDragEnter:O=>{xc(O)&&(O.preventDefault(),de.current+=1,ce(!0))},onDragOver:O=>{xc(O)&&(O.preventDefault(),O.dataTransfer.dropEffect="copy")},onDragLeave:O=>{xc(O)&&(de.current=Math.max(0,de.current-1),de.current===0&&ce(!1))},onDrop:O=>{var G;xc(O)&&(O.preventDefault(),de.current=0,ce(!1),s&&((G=Ae.current)==null||G.addFiles(O.dataTransfer.files)))},children:[Z?n.jsx("div",{className:"wb-drop","aria-hidden":"true",children:n.jsxs("div",{className:"wb-drop-card",children:[n.jsx(F4,{}),n.jsx("strong",{children:"Drop to attach"}),n.jsx("span",{children:ye?`It goes with your next message to ${ye.name}`:"Pick an agent first"})]})}):null,n.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&ye?ko(bo(ye)):{},children:[n.jsxs("div",{className:"wb-head-row",children:[i?n.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:Pi.slice(0,3).map(O=>n.jsx(xn,{agents:zn,id:O.id,size:"sm"},O.id))}):ye?n.jsx("a",{className:"wb-head-face",href:dt(ye.id),"aria-label":`${ye.name}'s page`,children:n.jsx(xn,{agents:zn,id:ye.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:Zx,children:Zx}),n.jsx("span",{className:"wb-head-meta","data-tone":Di.tone,title:i?`${Pi.map(O=>O.name).join(", ")}. Coordinator: ${(ye==null?void 0:ye.name)??i.coordinator}.`:Di.title,children:i?`${Pi.map(O=>O.name).join(", ")} · ${Di.text}`:ye?n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"wb-head-name",href:dt(ye.id),title:`${ye.name}'s page`,children:ye.name})," ",n.jsxs("span",{className:"wb-head-handle",children:["@",ye.handle]}),` · ${Di.tone==="quiet"&&Di.text==="New conversation"?`on ${g}`:Di.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),Mo()},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":ne,"data-open":ne?"true":void 0,disabled:!s,onClick:()=>be(O=>!O),children:n.jsx(z4,{})}),u?n.jsxs("button",{className:"ui-btn",onClick:d,disabled:Cn.length===0,children:["Canvas",Cn.length>0?` (${Cn.length})`:""]}):null,n.jsx(H4,{disabled:!s,items:i?[...Pi.map(O=>({label:O.name,hint:O.id===i.coordinator?"Coordinator · open page":"Member · open page",href:dt(O.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:Vr,onSelect:DE},...ye?[{label:"Set up",hint:"Identity, model and access",href:dt(ye.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:dt(ye.id)}]:[]]})]}),c?n.jsx(rN,{agents:t,currentId:s,attention:o,onSelect:l,orientation:"horizontal"}):null]}),ne&&s?n.jsx(y4,{agentId:s,...i?{groupId:i.id}:{},currentId:v,timezone:e,onNew:()=>{be(!1),Mo()},onSelect:O=>{if(O===v){be(!1);return}be(!1),S(null),P([]),K(!1),H(null),ve(null),Me(null),Ne([]),N(O),k==null||k(s,O,!1)}}):null,s&&v?n.jsx(h4,{agentId:s,conversationId:v},`${s}:${v}`):null,fe?n.jsx("div",{className:"wb-chat-notice",children:n.jsx(te,{message:fe})}):null,Le?n.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:Le}):null,b!=null&&b.carriedOver?n.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:b.carriedOver}):null,n.jsx(ix,{messages:[...(b==null?void 0:b.messages)??[],...E],live:L,now:ge,working:U,partial:T,agents:zn,...b!=null&&b.runs?{runs:b.runs}:{},...i?{speakers:zn,coordinatorId:i.coordinator}:{},...$d?{workingAs:((iv=zn.find(O=>O.id===$d))==null?void 0:iv.name)??$d}:{},onOpenFile:zx,onReadAloud:(O,G)=>{Ii(null),Pu(G,v??void 0,O).then(me=>{me&&Ii(me)})},onOpen:O=>{if(Yt){const G=Oy([...(b==null?void 0:b.messages)??[],...E],O);if(G){Ao(G),H(Yt.id),u&&(d==null||d());return}}v&&re(G=>{const me={...G,[v]:(G[v]??[]).filter(we=>we!==O)};return Ly(me),me}),H(O),u&&(d==null||d())},...ye?{agentName:ye.name,agentId:ye.id}:{},...Qx?{empty:Qx}:{},emptyHint:ye?`Nothing here yet. Ask ${ye.name} for something.`:"Loading agents…"}),Hx.length>0?n.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:Hx.map(O=>n.jsx("button",{className:"ui-btn",disabled:ot!==null,title:O.prompt,onClick:()=>PE(O.id),children:O.label},O.id))}):null,Po?n.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:n.jsxs(W,{tone:"warning",role:"status",children:[Po," ",n.jsx("a",{href:tt(Wx.section),children:Wx.label})]})}):Ro.length>0?n.jsx(tF,{approvals:Ro,timezone:e,now:ge,version:b,onDecided:Gx,onSay:O=>Vx(O,[]),onOpenFull:O=>{H(O),u&&(d==null||d())}}):null,Po||Ro.length>0?null:b!=null&&b.question?n.jsx(P4,{question:b.question,disabled:pt||U,onAnswer:ME,onSkip:$E},b.question.id):null,Po?null:n.jsxs("div",{hidden:Ro.length>0||!!(b!=null&&b.question),"data-testid":"composer-slot",children:[n.jsx(ox,{ref:Ae,disabled:!s,running:U,onSend:Vx,onStop:OE,agentName:i?i.name:(ye==null?void 0:ye.name)??"the agent",draft:je,history:TE,threadKey:v??(i?`group:${i.id}`:s),model:i?null:(ye==null?void 0:ye.model)??null,setupHref:i?null:ye?dt(ye.id,"setup","brain"):null,thinking:RE,...!i&&ye&&Jk(Xk(ye,kE.data))?{onThinking:IE}:{},...i?{mentions:Pi.map(O=>({handle:O.handle,name:O.name}))}:{},onOpenFile:zx,conversationId:v??null,readAloud:xt,onReadAloud:jE}),sn?n.jsx("p",{className:"wb-voice-note",role:"status",children:sn}):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"})]}),Jx]}):null:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:O=>{var G,me;$o.current=!0,(me=(G=O.currentTarget).setPointerCapture)==null||me.call(G,O.pointerId)},onKeyDown:O=>{const G=me=>{var we;return me??((we=Be.current)==null?void 0:we.offsetWidth)??Gc};O.key==="ArrowLeft"&&gt(me=>Math.max(Gc,G(me)-16)),O.key==="ArrowRight"&&gt(me=>Math.min(720,G(me)+16))}}),Jx]})]})}function O4(){try{const e=window.localStorage.getItem(n1),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Gc?t:null}catch{return null}}function L4(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function Ft(e){return typeof e=="string"&&e!==""?e:null}function cr(e){return e instanceof ae||e instanceof Error?e.message:String(e)}function Wh(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 xc(e){var s;const t=(s=e.dataTransfer)==null?void 0:s.types;return!!(t&&Array.from(t).includes("Files"))}function F4(){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 Hm="buddi.chatDraft";function U4(e,t){try{window.sessionStorage.setItem(Hm,JSON.stringify({agentId:e,text:t}))}catch{}}function B4(e){try{const t=window.sessionStorage.getItem(Hm);if(!t)return null;const s=JSON.parse(t);return s.agentId!==e||typeof s.text!="string"?null:(window.sessionStorage.removeItem(Hm),s.text)}catch{return null}}function z4(){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 W4(){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 H4({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(W4,{})}),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 V4(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 Uy=!1;const K4=new Set(["missing","unconfigured","not-english"]);async function Pu(e,t,s=null){const r=WN(s);try{const i=await Oe.say({text:e,...t?{conversationId:t}:{}});return ky(r)&&await iL(i.audioUrl,i.mime,s),null}catch(i){ky(r)&&Ha();const a=i instanceof ae&&i.detail&&typeof i.detail=="object"?i.detail.reason:void 0;return typeof a=="string"&&K4.has(a)&&(s!==null||!Uy)?(Uy=!0,i.message):null}}let Hn=null;function G4(e){if(Wc(e)!==null)return!1;const t=qS(e);return t!==zt&&t!==Cr}function Y4({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||!Hn)return;const f=jd({url:Oe.streamUrl(Hn.conversationId),lastEventId:Hn.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(Q4,{agent:e,agents:t,navigate:i,onClose:()=>r(!1),onBusy:u}):n.jsxs(Jl,{children:[n.jsx(Xl,{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(q4,{busy:c})})}),n.jsx(Zl,{children:n.jsx(eo,{className:"ui-tip",side:"left",sideOffset:8,children:o})})]})}function q4({busy:e}){const[t,s]=h.useState(!1);return t?n.jsx(AN,{size:"lg"}):n.jsx(bd,{state:e?"working":"idle",className:"wb-ask-fab-face",onStillError:()=>s(!0)})}function Q4({agent:e,agents:t,navigate:s,onClose:r,onBusy:i}){const a=h.useRef(null),[l,o]=h.useState(Hn&&Hn.agentId===e.id?Hn.conversationId:null),[c,u]=h.useState(null),[f,d]=h.useState([]),[m,p]=h.useState([]),[j,w]=h.useState(null),[k,g]=h.useState(!1),[x,y]=h.useState(!1),[v,N]=h.useState(null),[b,S]=h.useState(null),[C,R]=h.useState(Date.now()),[E,P]=h.useState(BN),L=h.useRef(E);L.current=E;const[$,T]=h.useState(null),M=h.useRef(null),U=h.useCallback(async re=>{try{const ie=await Oe.conversation(re);u(ie),d(Ne=>Ne.filter(Z=>!J4(ie,Z)))}catch{}},[]);h.useEffect(()=>{l&&U(l)},[l,U]),h.useEffect(()=>{if(!l)return;const re=jd({url:Oe.streamUrl(l),onEvent:ie=>{var Ne;switch(ie.name){case"run.started":M.current=null,g(!0),w(null);break;case"live":{const Z=En(ie.data.runId)??"",ce=Number(ie.data.turn??0),de=ie.data.kind==="thinking"?"thinking":"text",Ae=En(ie.data.text)??"",ne=Date.now();if(de==="text"){const be=M.current;M.current=be&&be.runId===Z&&be.turn===ce?{...be,text:be.text+Ae}:{runId:Z,turn:ce,text:Ae}}w(be=>{const Te=be&&be.runId===Z&&be.turn===ce?be:{runId:Z,turn:ce,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return de==="thinking"?{...Te,thinking:Te.thinking+Ae,thinkingStartedAt:Te.thinkingStartedAt??ne}:{...Te,text:Te.text+Ae,textStartedAt:Te.textStartedAt??ne}});break}case"live.snapshot":{const Z=En(ie.data.runId)??"",ce=Number(ie.data.turn??0),de=En(ie.data.text)??"",Ae=En(ie.data.thinking)??"",ne=Number(ie.data.startedAt??Date.now());M.current={runId:Z,turn:ce,text:de},g(!0),w({runId:Z,turn:ce,text:de,thinking:Ae,thinkingStartedAt:Ae?ne:null,textStartedAt:de?ne:null,settled:!1});break}case"live.settle":{const Z=En(ie.data.runId)??"",ce=Number(ie.data.turn??0);w(de=>de&&de.runId===Z&&de.turn===ce?{...de,settled:!0}:de);break}case"tool.called":{const Z=En(ie.data.toolUseId)??En(ie.data.id),ce=En(ie.data.name)??En(ie.data.tool)??"tool";Z&&p(de=>[...de.filter(Ae=>Ae.toolUseId!==Z),{toolUseId:Z,name:ce,startedAt:Date.now()}]);break}case"tool.result":{const Z=En(ie.data.toolUseId)??En(ie.data.id);Z&&p(ce=>ce.filter(de=>de.toolUseId!==Z)),U(l);break}case"message.appended":case"awaiting-approval":U(l).then(()=>w(Z=>Z!=null&&Z.settled?null:Z));break;case"run.finished":{g(!1),p([]),w(null);const Z=En(ie.data.message);N(Z??null);const ce=((Ne=M.current)==null?void 0:Ne.text.trim())??"";M.current=null,!Z&&ce!==""&&L.current&&Pu(ce,l).then(de=>{de&&T(de)}),U(l);break}}}});return()=>{Hn&&Hn.conversationId===l&&(Hn.lastEventId=re.lastEventId()),re.close()}},[l,U]),h.useEffect(()=>{i(k||x)},[k,x,i]),h.useEffect(()=>{if(m.length===0)return;const re=window.setInterval(()=>R(Date.now()),1e3);return()=>window.clearInterval(re)},[m.length]);const K=(re,ie)=>{y(!0),N(null);const Ne={id:`local-${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:re}]};d(Z=>[...Z,Ne]),(async()=>{try{const Z=l??(await Oe.startConversation(e.id)).conversationId;Z!==l&&(Hn={agentId:e.id,conversationId:Z},o(Z));const ce=await Oe.send(e.id,{conversationId:Z,text:re,...ie.length>0?{attachmentIds:ie.map(de=>de.artifactId)}:{}});ce.conversationId!==Z&&(Hn={agentId:e.id,conversationId:ce.conversationId},o(ce.conversationId)),g(!0),U(ce.conversationId)}catch(Z){d(ce=>ce.filter(de=>de.id!==Ne.id)),N(Z instanceof ae?Z.message:String(Z)),S({text:re,at:Date.now()})}finally{y(!1)}})()},_=()=>{l&&Oe.cancel(l).catch(re=>N(String(re))).finally(()=>g(!1))},q=()=>{var re;Hn=null,o(null),u(null),d([]),p([]),w(null),g(!1),N(null),(re=a.current)==null||re.focus()},B=re=>{P(re),zN(re),re||Ha()},H=l?Ke(e.id,l):Ke(e.id),ue=[...(c==null?void 0:c.messages)??[],...f];return n.jsxs(D_,{title:e.name,label:`${e.name}, a quick chat`,onClose:r,onOpenAutoFocus:re=>{var ie;re.preventDefault(),(ie=a.current)==null||ie.focus()},onCloseAutoFocus:re=>re.preventDefault(),actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",variant:"ghost",onClick:q,disabled:l===null&&f.length===0,children:"New"}),n.jsx(Gt,{size:"sm",variant:"ghost",href:H,onClick:re=>{re.preventDefault(),s(H)},children:"Open in Chat"})]}),children:[n.jsx("div",{className:"wb-ask-thread",children:n.jsx(ix,{messages:ue,live:m,now:C,working:k||x,partial:j,agents:t,agentName:e.name,agentId:e.id,onOpen:()=>s(H),onReadAloud:(re,ie)=>{T(null),Pu(ie,l??void 0,re).then(Ne=>{Ne&&T(Ne)})},emptyHint:`Ask ${e.name} anything, without leaving this page.`})}),n.jsxs("div",{className:"wb-ask-compose",children:[v?n.jsx(te,{message:v}):null,n.jsx(ox,{ref:a,disabled:x||!e.available,running:k,onSend:K,onStop:_,agentName:e.name,placeholder:`Message ${e.name}…`,draft:b,threadKey:`dock.${l??e.id}`,conversationId:l,readAloud:E,onReadAloud:B}),$?n.jsx("p",{className:"wb-voice-note",role:"status",children:$}):null]})]})}function En(e){return typeof e=="string"?e:null}function J4(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 s1=3;function X4(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function Z4(e,t){return e?t?"above-dock":"above-button":"corner"}function e3({placement:e,children:t}){return n.jsx("div",{className:"wb-toast-stack","data-placement":e,children:t})}function t3(e){return e.state==="shown"&&e.seenAt===null}function n3(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=>t3(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,s1))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 s3({queue:e,agents:t,navigate:s,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,s1),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":X4(l.kind),role:"status",children:[l.agentId?n.jsx(xn,{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:r3(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 r3(e){var t;return((t=e.split(`
106
+ `).find(s=>s.trim()!==""))==null?void 0:t.trim())??""}const i3=3e4,a3=1e3;function l3(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 v;y instanceof ae&&y.status===401&&(a=!0,(v=i.current)==null||v.call(i))}),g==="active"&&((x=r.current)==null||x.call(r))},m=g=>{if(a||(o=g,c!==null))return;const x=l+a3-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")},j=()=>{u=!1,m("away")},w=()=>m(f()?"active":"away");f()&&m("active");const k=window.setInterval(()=>{f()&&u&&m("active")},i3);return window.addEventListener("focus",p),window.addEventListener("blur",j),document.addEventListener("visibilitychange",w),()=>{a=!0,window.clearInterval(k),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",p),window.removeEventListener("blur",j),document.removeEventListener("visibilitychange",w)}},[e])}function By({agents:e,group:t,onClose:s,onCreated:r,onSaved:i,onArchived:a}){return!t&&!tN(e)?n.jsx(tn,{title:"A new group",onClose:s,children:n.jsxs(W,{children:["A group needs two agents. Make another one with ",ED(e)," first."]})}):n.jsx(c3,{agents:o3(e,t),group:t??null,onClose:s,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...a?{onArchived:a}:{}})}function o3(e,t){const s=eN(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 c3({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(Bg)))==null?void 0:C.id)??((R=e[0])==null?void 0:R.id)??""),[p,j]=h.useState(!1),[w,k]=h.useState(!1),[g,x]=h.useState(null),y=[...new Set([d,...u])].filter(Boolean),v=o.trim()!==""&&d!==""&&y.length>=2,N=E=>f(P=>P.includes(E)?P.filter(L=>L!==E):[...P,E]),b=async()=>{j(!0),x(null);try{t?i==null||i(await Oe.updateGroup(t.id,{name:o.trim(),coordinator:d,members:y})):r==null||r(await Oe.createGroup({name:o.trim(),coordinator:d,members:y.filter(E=>E!==d)}))}catch(E){x(E instanceof ae?E.message:String(E))}finally{j(!1)}},S=async()=>{if(t){j(!0),x(null);try{await Oe.archiveGroup(t.id),a==null||a(t.id)}catch(E){x(E instanceof ae?E.message:String(E)),j(!1)}}};return n.jsx(tn,{title:l?`${t.name}: members`:"A new group",onClose:s,children:n.jsxs(V,{children:[n.jsx(X,{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(X,{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(X,{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(xn,{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(W,{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(W,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,g?n.jsx(W,{tone:"critical",children:g}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!v||p,onClick:()=>void b(),children:p?l?"Saving…":"Creating…":l?"Save":"Create group"})]}),l?n.jsx("div",{className:"group-archive",children:w?n.jsxs(V,{children:[n.jsxs(W,{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 cx(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,j,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}.`:((j=g.execution)==null?void 0:j.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 ux({action:e,timezone:t,busy:s,onDecide:r,agentName:i}){var f,d;const[a,l]=h.useState(!1),{values:o,controls:c}=Jg(e.choices),u=m=>o?r(e.id,"approve",m,o):r(e.id,"approve",m);return n.jsxs(Dn,{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)," (",De(e.expiresAt),"). Policy v",e.policyVersion,", args ",so(e.argsHash,12),e.jobId?`, job ${so(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(Y,{title:"Envelope: everything that decides what the world will see",children:n.jsx(Nt,{children:kn(e.envelope)})}),n.jsx(Y,{title:"Canonical arguments",children:n.jsx(Nt,{children:kn(e.canonicalArgs)})})]}):null]})}function dx(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 ae?f.message:String(f))).finally(()=>i(!1)))},busy:r,created:a,failure:o}}function r1({agent:e}){return n.jsxs(W,{tone:"good",role:"status",children:["@",e.handle," is ready. ",n.jsxs("a",{href:Ke(e.id),children:["Talk to @",e.handle]})]})}function i1(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 u3(e,t){var i;const s=se(()=>A.approvals(),[e,t],15e3);return{action:((i=s.data)==null?void 0:i.pending.find(a=>i1(a,e,t)))??null,reload:s.reload}}function d3({action:e,onDecided:t}){const{busy:s,failure:r,decide:i}=cx(a=>t(a));return n.jsxs(V,{gap:"sm",children:[n.jsx(ux,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:s===e.id,onDecide:(a,l,o,c)=>{i(a,l,o,c)}}),n.jsx(te,{message:r})]})}function hx({plugin:e,agent:t,text:s,label:r,handle:i,onDismiss:a}){var d;const l=dx(e,t),o=u3(e,t),[c,u]=h.useState(null),f=l.created??c;if(f)return n.jsx(r1,{agent:f});if(o.action){const m=i??((d=/@(\S+)/.exec(r))==null?void 0:d[1])??t;return n.jsxs(V,{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(V,{gap:"sm",children:[n.jsxs(Q,{children:[n.jsx("span",{children:s}),n.jsx(Ms,{}),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(te,{message:l.failure})]})}function a1(){var t;const e=se(()=>A.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function l1({offers:e,reload:t}){return e.length===0?null:n.jsx(Y,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:n.jsx(V,{gap:"sm",divided:!0,children:e.map(s=>n.jsx(hx,{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 h3=512*1024,f3=/^[A-Za-z0-9+/]*={0,2}$/;function o1(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===""||!f3.test(r)||Math.floor(r.length*3/4)>h3+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,Al=null,lo=null;const Vm=new Set;function u1(){for(const e of Vm)e()}function pl(){zs&&(zs.onended=null,zs.onerror=null,zs.pause()),Al&&URL.revokeObjectURL(Al),Al=null,lo!==null&&(lo=null,u1())}async function d1(e,t){pl();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),Al=URL.createObjectURL(new Blob([r],{type:e.mime})),lo=t,zs.onended=pl,zs.onerror=pl,zs.src=Al,u1();try{await zs.play()}catch{throw pl(),new Error("The browser would not play the sound.")}}function zy(e){e!==void 0&&lo!==e||pl()}function m3(){return h.useSyncExternalStore(e=>(Vm.add(e),()=>Vm.delete(e)),()=>lo,()=>null)}const p3=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Vi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],g3=["January","February","March","April","May","June","July","August","September","October","November","December"],Wy=/^\d{4}-\d{2}-\d{2}$/;function Tr(e){return e.split("-").map(Number)}function Ri(e,t){const[s,r,i]=Tr(e);return new Date(Date.UTC(s,r-1,i+t)).toISOString().slice(0,10)}function h1(e){const[t,s,r]=Tr(e);return new Date(Date.UTC(t,s-1,r)).getUTCDay()}function fx(e){return p3[h1(e)]}function f1(e){return Tr(e)[2]}function Hy(e){return Ri(e,-((h1(e)+6)%7))}function Ys(e){const[,t,s]=Tr(e);return`${fx(e)} ${s} ${Vi[t-1]}`}function x3(e,t){return e===t?`Today · ${Ys(e)}`:e===Ri(t,1)?`Tomorrow · ${Ys(e)}`:Ys(e)}function ti(e){return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}const Vy=new Map;function Km(e,t){let s=Vy.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"}),Vy.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 v3(e,t=new Date){return Km(t,e).date}function j3(e,t){return e==="week"?{from:Hy(t),days:7}:e==="month"?{from:Hy(`${t.slice(0,8)}01`),days:42}:{from:t,days:7}}function y3(e,t,s){if(e!=="month")return Ri(t,s*7);const[r,i]=Tr(t);return new Date(Date.UTC(r,i-1+s,1)).toISOString().slice(0,10)}function w3(e,t,s,r){const[i,a]=Tr(t);if(e==="month")return`${g3[a-1]} ${i}`;const l=Ri(s,r-1),[o,c,u]=Tr(s),[f,d,m]=Tr(l);return c===d&&o===f?`${u} – ${m} ${Vi[d-1]} ${f}`:o===f?`${u} ${Vi[c-1]} – ${m} ${Vi[d-1]} ${f}`:`${u} ${Vi[c-1]} ${o} – ${m} ${Vi[d-1]} ${f}`}function Wi(e){return e==null?"":String(e)}function b3(e,t,s,r){const i=[],a=new Set;return e.forEach((l,o)=>{const c=Wi(he(l,t.id)),u=Wi(he(l,t.title)),f=Wi(he(l,t.start)),d=Wi(he(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:he(l,t.allDay),p=m===void 0?Wy.test(f):m===!0||m==="true",j=t.tone===void 0?0:Number(he(l,t.tone)),w=Number.isFinite(j)?(Math.trunc(j)%4+4)%4:0,k={id:c,title:u,calendar:t.calendar===void 0?"":Wi(he(l,t.calendar)),tone:w,location:t.location===void 0?"":Wi(he(l,t.location))};if(p){const N=f.slice(0,10),b=Wy.test(d.slice(0,10))&&d.slice(0,10)>N?d.slice(0,10):Ri(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=Km(g,s),v=Number.isNaN(x.getTime())||x<g?y:Km(x,s);i.push({...k,allDay:!1,startDate:y.date,startMin:y.minutes,endDate:v.date,endMin:v.minutes})}),i}function k3(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 mx(e,t){return e.map(s=>({event:s,part:k3(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 px(e,t){if(t.allDay)return"All day";const s=e.startDate!==e.endDate;return s&&t.from===0?`until ${ti(t.to)}`:s&&t.to===1440?`from ${ti(t.from)}`:t.from===t.to?ti(t.from):`${ti(t.from)}–${ti(t.to)}`}function Gm(e,t,s){return[px(e,t),e.title,e.location,e.calendar,Ys(s)].filter(Boolean).join(", ")}const m1=30;function S3(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+m1);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 gx="(max-width: 900px)";function Aa(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 N3={week:"Week",month:"Month",list:"List"},C3=["week","month","list"],E3="(max-width: 720px)";function A3(e){try{return window.localStorage.getItem(e)}catch{return null}}function T3(e,t){try{window.localStorage.setItem(e,t)}catch{}}function R3(e){const t=e.views&&e.views.length>0?e.views:C3,s=Aa(E3),[r,i]=h.useState(()=>{const p=A3(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}=j3(l,o);return{views:t,view:l,setView:p=>{i(p),T3(e.storageKey,p),f(null)},anchor:o,today:e.today,go:p=>{c(p===0?e.today:y3(l,o,p)),f(null)},from:d,days:m,to:Ri(d,m),selected:u,select:f}}function I3({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)=>Ri(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,j=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:j,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:w3(a,l,c,u)}),e.views.length>1?n.jsx(Ar,{label:"View",options:e.views.map(w=>({value:w,label:N3[w]})),value:a,onChange:e.setView}):null]}),a==="week"?n.jsx(P3,{dates:f,today:o,events:t,hours:s??[7,21],onPick:e.select}):null,a==="month"?n.jsx($3,{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(Ky,{date:w,today:o,events:t,empty:r},w))}):null,p?n.jsx(Ky,{date:p,today:o,events:t,empty:r}):null]})}function Ky({date:e,today:t,events:s,empty:r}){const i=mx(s,e);return n.jsx(st,{flush:!0,title:x3(e,t),children:n.jsx(Ht,{children:i.length===0?n.jsx(Vt,{title:n.jsx("span",{className:"muted",children:r})}):i.map(({event:a,part:l})=>n.jsx(Vt,{lead:n.jsx("span",{className:"cal-dot","data-tone":a.tone,"aria-hidden":"true"}),title:a.title,sub:a.location||void 0,side:px(a,l)},a.id))})})}function P3({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:mx(s,c)})),o=c=>c===t?"true":void 0;return n.jsx(st,{flush:!0,children:n.jsxs("div",{className:"cal-week",role:"grid","aria-label":`Week of ${Ys(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":Ys(c),children:[n.jsx("span",{className:"cal-wd",children:fx(c)}),n.jsx("span",{className:"cal-num",children:f1(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":Gm(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:ti(c*60)},c))}),l.map(({date:c,items:u})=>n.jsx("div",{className:"cal-col",role:"gridcell","aria-label":Ys(c),"data-today":o(c),children:S3(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":Gm(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,m1)/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:px(f,d)}),n.jsx("span",{className:"cal-event-title",children:f.title})]},f.id))},c))]})})]})})}const M3=3;function $3({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(st,{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:fx(f)},f))}),l.map(f=>n.jsx("div",{className:"cal-row",role:"row",children:f.map(d=>{const m=mx(r,d),p=m.slice(0,M3),j=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":`${Ys(d)}, ${w}`,"aria-pressed":d===i,children:f1(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":Gm(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:ti(g.from)})," ",k.title]})},k.id)),j>0?n.jsxs("button",{type:"button",className:"cal-more","aria-label":`${j} more on ${Ys(d)}`,children:["+",j]}):null]},d)})},f[0]))]})})}const p1={width:1200,height:200,top:28,right:12,bottom:24,left:36};function D3(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 vc(e,t){return t==="temp"?`${e}°`:t==="percent"?`${e}%`:String(e)}function _3(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=>ni(t.left+l*(g+.5)),c=e.values.filter(g=>g!==null&&Number.isFinite(g)),u=D3(c,e.unit),f=u[0],d=u[u.length-1],m=g=>ni(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}}),j=[],w=[];if(e.kind==="area"){let g=[];const x=()=>{if(g.length===0)return;const y=g.map((v,N)=>`${N===0?"M":"L"}${v.x},${v.y}`).join(" ");j.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:ni(g.x-l*.28),y:g.y,width:ni(l*.56),height:ni(a-g.y)}]):[];return{ticks:u.map(g=>({value:g,y:m(g)})),lines:j,areas:w,bars:k,points:p,slot:l,floor:a}}function O3({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,j=c??f,w=r.find(b=>b.id===l)??r[0],k=_3(w),g=p1,x=b=>b%a===0||b===j,y=w.values.filter(b=>b!==null&&Number.isFinite(b));h.useEffect(()=>{const b=m.current,S=j===null?null:b==null?void 0:b.children[j];!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"}))},[j]);const v=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(st,{...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:vc(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===j?"true":void 0,x:b.x,y:b.y,width:b.width,height:b.height},b.index)),j!==null&&k.points[j]?n.jsx("line",{className:"pg-series-guide","data-index":j,x1:k.points[j].x,x2:k.points[j].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===j?"true":void 0,cx:b.x,cy:b.y,r:b.index===j?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===j?"true":void 0,x:b.x,y:b.y-(w.kind==="area"?10:6),textAnchor:"middle",children:vc(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:ni(g.left+k.slot*b.index),y:0,width:ni(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 ${vc(Math.min(...y),w.unit)}, highest ${vc(Math.max(...y),w.unit)}.`})]}),n.jsx("ul",{className:"wb-tiles","data-layout":"strip",ref:m,onKeyDown:v,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===j?"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:Ed(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 ni(e){return Math.round(e*10)/10}const xx=h.createContext(null),Mu=h.createContext(!1);function yt(){const e=h.useContext(xx);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function Ym(e,t=new Set){if(Array.isArray(e))for(const s of e)Ym(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))Ym(r,t)}return t}function g1(e,t){if(t.size===0)return!1;for(const s of Ym(e))if(t.has(s))return!0;return!1}function x1(){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 v1({revealed:e,onToggle:t}){return n.jsx(I,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function j1(){return n.jsx("p",{className:"muted",children:"Hidden until you show it."})}function y1({children:e}){const[t,s]=x1();return n.jsxs(V,{gap:"sm",children:[n.jsx(Q,{align:"end",children:n.jsx(v1,{revealed:t,onToggle:s})}),t?n.jsx(Mu.Provider,{value:!0,children:e}):n.jsx(j1,{})]})}function vx(e){return e===void 0||e==="neutral"?void 0:e}function qm(e){return vx(e)}function L3(e){const t=vx(e);return t==="accent"?void 0:t}function cs(e,t){if(!t)return!0;const s=he(e,t.path),r=t.in!==void 0?t.in.includes(s):s===t.equals;return t.not===!0?!r:r}function jx(e,t,s){if("chat"in t){const a=Re(s,t.chat);return a==null?"":Ke(String(a))}if("proposals"in t)return K$(e.plugin);const r=e.pages.find(a=>a.id===t.page);if((r==null?void 0:r.place)==="settings")return wo(e.plugin,t.page);const i=t.item===void 0?null:Re(s,t.item);return ji(e.plugin,t.page,i==null?null:String(i))}function F3(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=he(t.row,r);return i==null?"":String(i)})}function Qm(e,t){if(e===void 0)return;if(typeof e=="string")return e;const s=Re(t,e);return s==="good"||s==="warning"||s==="critical"||s==="neutral"?s:void 0}function w1(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=Re(t,a),!(l==null||l==="")&&(r[i]=String(l))}return r}function yi(e,t){var r,i,a;const s={};for(const[l,o]of Object.entries(e??{}))if("row"in o)s[l]=he(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]=Re(t.data,o);return s}function fn(e,t,s,r){const i=yt(),a=e?{...w1(e.params,t,i),...r}:{},l=JSON.stringify([(e==null?void 0:e.query)??null,a,i.version]),o=se(()=>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 So(){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=Re(g,k.done);return x==null?null:String(x)},p=(k,g,x)=>{const y=k??"refresh";if(typeof y=="object"){const v=jx(e,y.route,g);v===""?e.refresh():e.navigate(v);return}y==="close"&&(x==null||x()),e.refresh()},j=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 v=o1(y.result);o(m(k,y.result)??(v?c1(y.result):null)),v&&await d1(v,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:j}}function Ta({action:e,args:t,disabled:s,running:r,count:i,row:a,onRun:l}){const[o,c]=h.useState(!1),u=d=>F3(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 $u({id:e,onDecided:t}){const s=yt(),r=se(()=>A.approval(e),[e,s.version]),{busy:i,note:a,failure:l,decide:o}=cx(c=>{t?t(c):s.refresh()});return r.error?n.jsx(te,{message:r.error}):r.data?n.jsxs(V,{children:[n.jsx(ux,{action:r.data,timezone:s.timezone,busy:i===e,onDecide:(c,u,f,d)=>{o(c,u,f,d)}}),a?n.jsx(W,{tone:"good",role:"status",children:a}):null,n.jsx(te,{message:l})]}):n.jsx(oe,{children:"Loading the approval…"})}function Va({act:e}){return e.error?n.jsx(te,{message:e.error}):e.approvalId?e.waiting?n.jsxs(V,{children:[n.jsx(W,{role:"status",children:e.waiting}),n.jsx($u,{id:e.approvalId,onDecided:e.settle})]}):n.jsx($u,{id:e.approvalId,onDecided:e.settle}):e.done?n.jsx(W,{tone:"good",role:"status",children:e.done}):null}function Du(e,t){const s={};for(const r of e){const i=r.from===void 0?void 0:he(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 b1(e,t,s){const r=yt(),i=e.optionsFrom,a=i?{...w1(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=se(()=>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(he(c,i.value)??""),label:String(he(c,i.label)??"")})),loading:o.loading}:{options:e.options??[],loading:!1}}function U3({field:e,fields:t,value:s,values:r,data:i,disabled:a,compact:l,onChange:o}){const c=b1(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):[],j=e.max!==void 0&&m.length>=e.max?`Up to ${e.max}; remove one to add another.`:void 0;return n.jsx(X,{label:e.label,hint:l?void 0:[f,j].filter(Boolean).join(" ")||void 0,group:!0,children:n.jsx(O_,{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(B3,{field:e,action:e.action,fields:t??[e],values:r,data:i,disabled:a,hint:f,children:m}):n.jsx(X,{label:e.label,hint:f,children:m})}if(e.type==="textarea")return n.jsx(X,{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(X,{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(X,{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"?z3(m.target.value):m.target.value)})})}function B3({field:e,action:t,fields:s,values:r,data:i,disabled:a,hint:l,children:o}){const c=yt(),u=h.useId(),f=m3()===u,[d,m]=h.useState(!1),[p,j]=h.useState(null),[w,k]=h.useState(null),[g,x]=h.useState(null);h.useEffect(()=>()=>zy(u),[u]);const y=yx(s,r,i),v=t.args!==void 0?yi(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){zy(u);return}m(!0),j(null),k(null),x(null);try{const S=await A.pageAct(c.plugin,{tool:t.tool,args:v});if(S.approvalId){x(S.approvalId);return}j(c1(S.result));const C=o1(S.result);C&&await d1(C,u)}catch(S){k(S instanceof Error?S.message:String(S))}finally{m(!1)}},b=f?"Stop":t.label;return n.jsx(X,{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(te,{message:w}):g?n.jsx($u,{id:g,onDecided:()=>x(null)}):p?n.jsx("span",{className:"ui-field-hint",role:"status",children:p}):null,children:o})}function z3(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function k1(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function yx(e,t,s){const r=k1(t,s);return new Set(e.filter(i=>i.when!==void 0&&!cs(r,i.when)||i.disabledWhen!==void 0&&cs(r,i.disabledWhen)).map(i=>i.name))}function wx({fields:e,values:t,data:s,disabled:r,compact:i,columns:a,onChange:l}){const o=k1(t,s);return n.jsx(nr,{dense:i,columns:a,children:e.filter(c=>c.when===void 0||cs(o,c.when)).map(c=>n.jsx(U3,{field:c,fields:e,compact:i,value:t[c.name],values:t,data:s,disabled:r===!0||c.disabledWhen!==void 0&&cs(o,c.disabledWhen),onChange:u=>l(c.name,u)},c.name))})}const oo=h.createContext(!1),S1=h.createContext(!1),N1=h.createContext(!1);function Un({title:e,note:t,actions:s,children:r}){const i=h.useContext(oo);return n.jsx(Y,{title:e,aside:t,actions:s,panel:i,children:n.jsx(oo.Provider,{value:!1,children:n.jsx(S1.Provider,{value:i,children:r})})})}function $s({component:e,data:t,choose:s,chosen:r}){const i=yt(),a=h.useContext(Mu);if(!cs(t,e.when))return null;if(e.kind!=="section"&&!a&&g1(e,i.sensitive))return n.jsx(y1,{children:n.jsx($s,{component:e,data:t,...s?{choose:s}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return n.jsx(W3,{component:e,data:t});case"notice":return n.jsx(W,{tone:vx(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(Re(t,e.text)??"")});case"link":return n.jsx(H3,{component:e,data:t});case"progress":return n.jsx(K3,{component:e,data:t});case"chart":return n.jsx(G3,{component:e,data:t});case"stats":return n.jsx(Y3,{component:e,data:t});case"list":return n.jsx(Q3,{component:e,data:t,...s?{onChoose:s}:{},...r===void 0?{}:{chosen:r}});case"table":return n.jsx(J3,{component:e,data:t});case"detail":return n.jsx(e6,{component:e,data:t});case"form":return n.jsx(t6,{component:e,data:t});case"search":return n.jsx(r6,{component:e,data:t});case"list-detail":return n.jsx(i6,{component:e,data:t});case"repeat":return n.jsx(a6,{component:e,data:t});case"calendar":return n.jsx(l6,{component:e,data:t});case"tiles":return n.jsx(o6,{component:e,data:t});case"series-panel":return n.jsx(c6,{component:e,data:t});case"hero":return n.jsx(u6,{component:e,data:t});case"tabs":return n.jsx(d6,{component:e,data:t});case"expand":return n.jsx(h6,{component:e,data:t});case"button":return n.jsx(f6,{component:e,data:t});case"approval":return n.jsx(p6,{component:e,data:t});case"artifact":return n.jsx(g6,{component:e,data:t});case"editor":return n.jsx(x6,{component:e,data:t});case"agent-offer":return n.jsx(m6,{component:e});default:return n.jsx(W,{children:"This page uses a part this dashboard does not know yet. Reload buddi to see it."})}}function W3({component:e,data:t}){const s=yt(),r=h.useContext(Mu),[i,a]=x1(),l=!r&&g1(e.body,s.sensitive),o=l&&!i,c=h.useContext(oo);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(Un,{title:e.title,note:e.note,actions:m.length>0||l?n.jsxs(n.Fragment,{children:[m.map((p,j)=>n.jsx($s,{component:p,data:t},j)),l?n.jsx(v1,{revealed:i,onToggle:a}):null]}):void 0,children:n.jsx(V,{gap:"lg",divided:c,children:o?n.jsx(j1,{}):n.jsx(Mu.Provider,{value:r||l,children:d.map((p,j)=>n.jsx($s,{component:p,data:t},j))})})})}function H3({component:e,data:t}){const s=yt(),r=jx(s,e.to,t);return r===""?null:n.jsx(Q,{children:n.jsx(Gt,{href:r,onClick:i=>{i.preventDefault(),s.navigate(r)},children:e.label})})}function Gy(e){return Math.round(e/1e6)}function V3(e,t){const s=Mn(Re(t,e.value))??0,r=e.total?Mn(Re(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?`${Gy(s)} of ${Math.max(1,Gy(r))} MB · ${l}%`:`${l}%`;return{percent:l,full:o,line:c}}function K3({component:e,data:t}){const s=c=>c===void 0?"":typeof c=="string"?c:String(Re(t,c)??""),r=s(e.label),i=s(e.done),{percent:a,full:l,line:o}=V3(e,t);return n.jsxs(V,{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(SN,{value:a,label:r||"Progress"}),n.jsx("span",{role:"status",children:o})]})]})}function G3({component:e,data:t}){const s=fn(e.query,t),r=e.rows===void 0?Array.isArray(s.data)?s.data:[]:Ds(s.data,e.rows),i=r.map(f=>String(he(f,e.x)??"")),a=f=>r.map(d=>Mn(he(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?Mn(Re(s.data,e.target))??null:null;return n.jsxs(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:s.error}),r.length===0?s.loading||s.data===void 0?n.jsx(oe,{children:"Loading…"}):n.jsx(Ka,{text:e.empty??"Nothing recorded yet."}):n.jsx(P_,{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)?jm(f):f,formatY:f=>It(f,"number",null)})]})}function Y3({component:e,data:t}){const s=fn(e.query,t);return n.jsxs(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:s.error}),s.data===void 0?n.jsx(oe,{children:e.empty??"Loading…"}):n.jsx(Sd,{children:e.items.map((r,i)=>n.jsx(Cs,{label:r.label,value:It(Re(s.data,r.value),r.unit??"text",null),tone:L3(r.tone)},i))})]})}function C1(e,t,s,r){const i=(t.meta??[]).map(u=>String(Re(s,u)??"")).filter(u=>u!==""),a=String(Re(s,t.title)??""),l=t.to&&!r?jx(e,t.to,s):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,f)=>{const d=Re(s,u.value);if(d==null||d==="")return null;const m=q3(u,d,s);return n.jsx(xe,{tone:qm(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(Re(s,t.sub)??""):null,side:n.jsxs(n.Fragment,{children:[c,i.length>0?n.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function q3(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]:Qm(e.tone,s)}}function Ds(e,t){const s=he(e,t);return Array.isArray(s)?s:[]}function E1(e,t,s){const r=[],i=new Set;return e.forEach((a,l)=>{const o=t===void 0?void 0:he(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 Q3({component:e,data:t,onChoose:s,chosen:r}){var N;const i=yt(),a=h.useContext(N1),l=fn(e.query,t),o=So(),[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}"`},j=E1([...d,...m],e.key??((N=e.select)==null?void 0:N.key),p),w=new Map(j.map(b=>[b.row,b.key])),k=new Set(j.map(b=>b.row)),g=new Set(j.filter(({row:b})=>{var S;return((S=e.select)==null?void 0:S.disabledWhen)===void 0||!cs(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(he(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,j.length]),v=b=>b.map(S=>{var L;const C=C1(i,e.item,S,s),R=w.get(S);if(f&&(s||C.href))return n.jsx(NN,{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=((L=e.select)==null?void 0:L.disabledWhen)!==void 0&&cs(S,e.select.disabledWhen),P=(e.actions??[]).filter($=>cs(S,$.when));return n.jsx(Vt,{lead:e.select?n.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(R),onClick:$=>$.stopPropagation(),onChange:$=>u(T=>$.target.checked?[...T,R]:T.filter(M=>M!==R))}):void 0,title:s?n.jsx("a",{href:"#","aria-current":r===R?"true":void 0,onClick:$=>{$.preventDefault(),s(R)},children:C.text}):C.title,sub:C.sub,side:n.jsxs(n.Fragment,{children:[C.side,P.map(($,T)=>n.jsx(Ta,{action:$,args:yi($.args,{data:l.data,row:S,scope:i}),disabled:o.busy,running:o.running===$.tool,row:S,onRun:(M,U)=>void o.run(M,U)},T))]})},R)});return n.jsxs(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:l.error}),n.jsx(Va,{act:o}),y.every(b=>b.rows.length===0)?l.loading?n.jsx(oe,{children:"Loading…"}):n.jsx(Ka,{text:e.empty??"Nothing here yet."}):n.jsxs(Ht,{children:[e.select?n.jsx(Vt,{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,v(b.rows)]},S))]}),e.collapsed&&m.some(b=>k.has(b))?n.jsx(Mt,{summary:`${e.collapsed.label} (${m.filter(b=>k.has(b)).length})`,children:n.jsx(Ht,{children:v(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(Ta,{action:b,args:yi(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 J3({component:e,data:t}){const s=yt(),r=fn(e.query,t),i=So(),a=Ds(r.data,e.rows);return n.jsxs(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:r.error}),n.jsx(Va,{act:i}),a.length===0?r.loading?n.jsx(oe,{children:"Loading…"}):n.jsx(Ka,{text:e.empty??"Nothing here yet."}):n.jsxs(Sn,{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:It(he(l,c.key),c.type??"text",null);return n.jsx("td",{"data-fit":c.fit,title:X3(c,l,u),children:c.pill?n.jsx(Z3,{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=>cs(l,c.when)).map((c,u)=>n.jsx(Ta,{action:c,args:yi(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 X3(e,t,s){if(e.hint){const r=he(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&s?s:void 0}function Z3({column:e,row:t}){var l,o;const s=he(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,j=p&&Object.prototype.hasOwnProperty.call(p,String(d))?p[String(d)]:It(d,e.type??"text",null);return n.jsx(xe,{tone:qm(Qm(typeof m=="string"?m:void 0,t)),children:j},u)})});const r=(l=e.pill)==null?void 0:l.labels,i=String(s),a=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:It(s,e.type??"text",null);return n.jsx(xe,{tone:qm(Qm((o=e.pill)==null?void 0:o.tone,t)),children:a})}function e6({component:e,data:t}){const s=fn(e.query,t);return s.error?n.jsx(te,{message:s.error}):s.data===void 0?n.jsx(oe,{children:e.empty??"Loading…"}):n.jsx(Un,{title:e.title,note:e.note,children:n.jsxs(V,{gap:"lg",children:[e.fields.length>0?n.jsx(Wt,{items:e.fields.map(r=>({key:r.label,label:r.label,value:It(Re(s.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>n.jsx($s,{component:r,data:s.data},i))]})})}function t6({component:e,data:t}){const s=yt(),r=fn(e.initial,t),i=So(),[a,l]=h.useState(!1),o=JSON.stringify([r.data??null,s.version]),c=n.jsx(n6,{component:e,data:t,initialData:r.data,act:i,onDone:()=>l(!1)},o);return e.drawer?n.jsxs(Y,{title:e.title,aside:e.note,actions:n.jsx(I,{variant:"accent",onClick:()=>l(!0),children:e.drawer.button}),children:[n.jsx(Va,{act:i}),a?n.jsx(tn,{title:e.drawer.title,onClose:()=>l(!1),children:c}):null]}):n.jsxs(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:r.error}),c]})}function n6({component:e,data:t,initialData:s,act:r,onDone:i}){const a=h.useContext(S1),l=yt(),[o,c]=h.useState(()=>Du(e.fields,s)),u=yx(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(V,{children:[n.jsx(wx,{fields:e.fields,columns:e.columns,values:o,data:s,onChange:(d,m)=>c(p=>({...p,[d]:m}))}),e.drawer?null:n.jsx(Va,{act:r}),n.jsx(Q,{align:"end",className:a?"ui-panel-foot":void 0,children:n.jsx(Ta,{action:e.submit,args:yi(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 s6(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 Yy(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function r6({component:e,data:t}){const s=yt(),[r,i]=h.useState(()=>Du(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=fn(a&&u?e.query:void 0,t),d=Ds(f.data,e.rows),m=e.count===void 0?void 0:he(f.data,e.count),p=e.note===void 0?void 0:he(f.data,e.note),j=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==j),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=Du(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=>Yy(s.params[C.name])):[],v=j?y.map(C=>n.jsx(Cu,{label:C.label,onRemove:()=>{const R={...r,[C.name]:C.type==="checkbox"?!1:""};i(R),k(R)},children:s6(C,String(s.params[C.name]))},C.name)):[],N=w.filter(C=>Yy(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(Un,{title:e.title,children:n.jsxs(V,{children:[n.jsx(EN,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&k(r)},main:j?n.jsx("input",{id:`f-${j.name}`,name:j.name,type:j.type==="email"?"email":"search","aria-label":j.label,placeholder:j.hint??j.label,title:j.hint,required:j.required,value:String(r[j.name]??""),onChange:C=>g(j.name,C.target.value)}):void 0,filters:w.length>0?n.jsx(wx,{fields:w,values:r,data:t,compact:!0,onChange:g}):void 0,...j&&w.length>0?{filtersOpen:o,onToggleFilters:()=>c(C=>!C),active:N}:{},chips:v.length>0?v:void 0,actions:b}),n.jsx(te,{message:f.error}),a&&(m!==void 0||p!==void 0)?n.jsxs("p",{className:"ui-card-meta",children:[m===void 0?"":`${It(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(Ht,{children:d.map((C,R)=>{const E=C1(s,S,C);return n.jsx(Vt,{title:E.title,sub:E.sub,side:E.side},R)})})}):null]})})}function i6({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(V,{gap:"lg",divided:!0,children:e.detail.map((u,f)=>n.jsx($s,{component:u,data:t},f))});return n.jsx(oo.Provider,{value:!1,children:n.jsx(CN,{list:n.jsx(N1.Provider,{value:!0,children:n.jsx($s,{component:e.list,data:t,chosen:l??null,...r?{choose:a}:{}})}),detail:l?o?n.jsx(xx.Provider,{value:o,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function a6({component:e,data:t}){const s=yt(),[r,i]=h.useState(!1),a=fn(e.query,t,r&&e.poll?e.poll.seconds*1e3:void 0),l=e.poll!==void 0&&a.data!==void 0&&cs(a.data,e.poll.while);h.useEffect(()=>i(l),[l]);const o=Ds(a.data,e.rows);return n.jsxs(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:a.error}),o.length===0?a.loading?n.jsx(oe,{children:"Loading…"}):n.jsx(Ka,{text:e.empty??"Nothing here yet."}):n.jsx(V,{gap:"lg",divided:!0,children:E1(o,e.key,{plugin:s.plugin,page:s.page,component:`repeat "${e.title??e.rows}"`}).map(({key:c,row:u})=>n.jsx(Y,{children:n.jsx(V,{children:e.body.map((f,d)=>n.jsx($s,{component:f,data:u},d))})},c))})]})}function l6({component:e,data:t}){const s=yt(),r=R3({...e.views?{views:e.views}:{},...e.default?{default:e.default}:{},today:v3(s.timezone),storageKey:`buddi.calendar-view:${s.plugin}/${s.page}`}),i=fn(e.query,t,void 0,{from:r.from,to:r.to}),a=h.useMemo(()=>b3(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(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:i.error}),n.jsx(I3,{state:r,events:a,hours:e.hours,empty:e.empty??"Nothing.",label:e.title??"Calendar"})]})}function o6({component:e,data:t}){var d;const s=yt(),r=fn(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=Gg([m],i).tiles[0];return p?[{tile:p,key:e.select?String(he(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(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:r.error}),r.data===void 0?n.jsx(oe,{children:"Loading…"}):a.length===0?n.jsx(Ka,{text:e.empty??"Nothing to show."}):n.jsx(LN,{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 c6({component:e,data:t}){const s=fn(e.query,t),r=Ds(s.data,e.points);if(s.data===void 0||r.length===0)return n.jsxs(Un,{title:e.title,note:e.note,children:[n.jsx(te,{message:s.error}),s.data===void 0?n.jsx(oe,{children:"Loading…"}):n.jsx(Ka,{text:e.empty??"Nothing to show."})]});const i=r.map(c=>String(he(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)=>Gg([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=>Mn(he(u,c.y))??null)}));return n.jsxs(n.Fragment,{children:[n.jsx(te,{message:s.error}),n.jsx(O3,{...e.title?{title:e.title}:{},...e.note?{note:e.note}:{},...e.labelEvery?{labelEvery:e.labelEvery}:{},xs:i,series:o,tiles:l})]})}function u6({component:e,data:t}){const s=fn(e.query,t),r=o=>{const c=he(s.data,o);return c==null?"":String(c)};if(s.data===void 0||s.data===null)return n.jsxs(n.Fragment,{children:[n.jsx(te,{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:Ed(Cm(Re(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}=b1({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(Ar,{label:a.label,options:l,value:o,onChange:f=>s.setParams({[a.param]:f})}):null,n.jsx(Ar,{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 h6({component:e,data:t}){const[s,r]=h.useState(!1),i=fn(s?e.query:void 0,t),a=typeof e.label=="string"?e.label:String(Re(t,e.label)??"");return n.jsxs(Mt,{summary:a,boxed:!0,onToggle:l=>r(l),children:[n.jsx(te,{message:i.error}),i.data===void 0?n.jsx(oe,{children:"Loading…"}):n.jsx(V,{children:e.body.map((l,o)=>n.jsx($s,{component:l,data:i.data},o))})]})}function f6({component:e,data:t}){const s=yt(),r=So();return n.jsxs(n.Fragment,{children:[n.jsx(Q,{align:"end",children:n.jsx(Ta,{action:e.action,args:yi(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(Va,{act:r})]})}function m6({component:e}){const t=yt();return n.jsx(hx,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function p6({component:e,data:t}){const s=he(t,e.path);return typeof s!="string"||s===""?null:n.jsx($u,{id:s})}function g6({component:e,data:t}){const s=he(t,e.path);return typeof s!="string"||s===""?null:n.jsx(Q,{children:n.jsx("a",{href:Dr(s),children:e.label})})}function x6({component:e,data:t}){const s=fn(e.query,t),r=So();return s.error?n.jsx(te,{message:s.error}):s.data===void 0?n.jsx(oe,{children:e.empty??"Loading…"}):n.jsxs(n.Fragment,{children:[n.jsx(Va,{act:r}),n.jsx(v6,{component:e,data:t,loaded:s.data,act:r},JSON.stringify(s.data))]})}function v6({component:e,data:t,loaded:s,act:r}){const i=yt(),[a,l]=h.useState(()=>Du(e.fields,s)),o={...a,version:he(s,e.version)},c=yx(e.fields,a,s),u=e.readOnlyWhen!==void 0&&cs(s,e.readOnlyWhen),f=(e.actions??[]).filter(p=>p.placement==="leading"),d=(e.actions??[]).filter(p=>p.placement!=="leading"),m=(p,j)=>n.jsx(Ta,{action:p,args:yi(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}-${j}`);return n.jsx(Un,{title:e.title,note:e.note,children:n.jsxs(V,{children:[n.jsx(wx,{fields:e.fields,values:a,data:s,disabled:u,onChange:(p,j)=>l(w=>({...w,[p]:j}))}),u?null:n.jsxs(Q,{align:"end",children:[f.map(m),f.length>0?n.jsx(Ms,{}):null,m(e.save,-1),d.map(m)]}),e.footnote?n.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function A1({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}:{},...y6(e,t)},setParams:j=>o(w=>{const k={...w};for(const[g,x]of Object.entries(j))x===null?delete k[g]:k[g]=x;return k}),navigate:s,timezone:r,version:c,refresh:()=>u(j=>j+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(xx.Provider,{value:f,children:n.jsx(hn,{embedded:i,title:e.title,lede:m,children:n.jsx(j6,{page:p,boxed:i===!0})})})}function j6({page:e,boxed:t}){const s=yt();return e.data&&s.sensitive.has(e.data.query)?n.jsx(y1,{children:n.jsx(qy,{page:e,boxed:t})}):n.jsx(qy,{page:e,boxed:t})}function qy({page:e,boxed:t}){const s=fn(e.data,null);return n.jsxs(V,{gap:"lg",divided:!t,children:[n.jsx(te,{message:s.error}),n.jsx(oo.Provider,{value:t,children:e.body.map((r,i)=>n.jsx($s,{component:r,data:s.data??null},i))})]})}function y6(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 w6(e){return n.jsx(A1,{...e,embedded:!0})}function Ka({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(Pt,{title:s,children:r||null})}function Qy(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)}function T1(e=!1){const[t,s]=h.useState([]);return h.useEffect(()=>{if(e)return;let r=!1;return Promise.resolve().then(()=>A.pages()).then(i=>{r||s(Array.isArray(i==null?void 0:i.pages)?i.pages:[])}).catch(()=>{}),()=>{r=!0}},[e]),{all:t,rail:Qy(t,"rail"),settings:Qy(t,"settings"),find:(r,i)=>t.find(a=>a.plugin===r&&a.id===i)}}const Jy=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],b6=["","image","pdf","table","text","code","audio","video","archive","file"];function k6({hash:e,timezone:t,navigate:s,agents:r}){var $;const i=U$(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,M=!1)=>s(lc(a,{q:c,origin:l,family:o,...T}),M);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),[j,w]=h.useState(null),[k,g]=h.useState(null),[x,y]=h.useState(!1),[v,N]=h.useState(!1),b=T=>{var M;return T?((M=r.find(U=>U.id===T))==null?void 0:M.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(M=>{S.current===T&&(p(M.entries),w(M.next))}).catch(M=>{S.current===T&&g(M instanceof ae?M.message:String(M))})},[c,l,o]);const C=()=>{if(!j||x)return;y(!0);const T=S.current;A.library({...c?{q:c}:{},...l?{origin:l}:{},...o?{family:o}:{},cursor:j}).then(M=>{S.current===T&&(p(U=>{const K=new Set((U??[]).map(_=>_.id));return[...U??[],...M.entries.filter(_=>!K.has(_.id))]}),w(M.next))}).catch(M=>{S.current===T&&g(M instanceof ae?M.message:String(M))}).finally(()=>{S.current===T&&y(!1)})},R=(l?1:0)+(o?1:0),E=(($=Jy.find(T=>T.id===l))==null?void 0:$.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(Ht,{children:m.map(T=>n.jsx(NN,{href:lc(T.id,{q:c,origin:l,family:o}),current:T.id===a,onClick:()=>s(lc(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:sr(T.id),alt:"",loading:"lazy"}):n.jsx(rx,{family:T.family})}),title:T.filename??"Untitled file",meta:n.jsx("span",{title:Ve(T.createdAt,t),children:De(T.createdAt)}),sub:`${ui[T.family]} · ${Nn(T.sizeBytes)} · ${R1(T,b)}${S6(T,b)}`},T.id))}),j?n.jsx("div",{className:"files-more",children:n.jsx(I,{size:"sm",onClick:C,disabled:x,children:x?"Loading…":"Show more"})}):null]}),L=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."})]}),L?n.jsx(Pt,{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(EN,{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(nr,{dense:!0,children:[n.jsx(X,{label:"Origin",children:n.jsx("select",{value:l,"aria-label":"Origin",onChange:T=>d({origin:T.target.value}),children:Jy.map(T=>n.jsx("option",{value:T.id,children:T.label},T.id))})}),n.jsx(X,{label:"Kind",children:n.jsx("select",{value:o,"aria-label":"Kind",onChange:T=>d({family:T.target.value}),children:b6.map(T=>n.jsx("option",{value:T,children:T===""?"Any kind":ui[T]},T))})})]}),filtersOpen:v,onToggleFilters:()=>N(T=>!T),active:R,chips:R>0?n.jsxs(n.Fragment,{children:[l?n.jsx(Cu,{label:"Origin",onRemove:()=>d({origin:""}),children:E}):null,o?n.jsx(Cu,{label:"Kind",onRemove:()=>d({family:""}),children:ui[o]}):null]}):void 0}),n.jsx(te,{message:k}),n.jsx(CN,{className:"files-split",label:"Files",list:P,detail:a?n.jsx(N6,{id:a,timezone:t,agents:r,navigate:s,onBack:()=>s(lc(null,{q:c,origin:l,family:o}))},a):void 0,empty:"Choose a file to see it here."})]})]})}function S6(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 R1(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 N6({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 ae&&y.status===404?"This file is no longer in the library.":y instanceof ae?y.message:String(y))}),()=>{x=!0}},[e]);const d=x=>{var y;return x?((y=s.find(v=>v.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(W,{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:j,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(rx,{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:[ui[m.family]," · ",Nn(m.sizeBytes)," · ",Ve(m.createdAt,t)]})]}),w?n.jsx("a",{className:"ui-btn","data-variant":"accent",href:Dr(m.id),download:k,children:"Download"}):null]}),w?null:n.jsx(W,{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(KN,{artifactId:m.id,filename:m.filename,mime:m.mime,family:m.family,available:w}),n.jsx(Wt,{items:[{label:"Origin",value:R1(m,d)},...m.agentId&&m.origin==="produced"?[{label:"Made by",value:n.jsxs("span",{className:"files-agent",children:[n.jsx(xn,{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?Cl(x.groupId,x.conversationId):Ke(x.conversationAgentId,x.conversationId),v=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: ${v}`:v}),n.jsxs("span",{className:"muted",children:[" · ",x.kind==="produced"?`made by ${d(x.agentId)||"an agent"}`:x.kind==="reused"?"sent again":"sent by you"," · ",De(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<j?n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",onClick:g,disabled:o,children:o?"Loading…":`Show ${j-p.length} more`})}):null]})]})}const C6={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 I1(e){return e&&C6[e]||"plug"}const P1="a connection needs you";function E6({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:zt,onClick:m=>{m.preventDefault(),s(zt)},"aria-label":"buddi home",children:n.jsx(AN,{})}),Y$.filter(m=>m.route!==pn).map(m=>n.jsx(Hh,{label:m.label,href:m.route,active:t===m.route,badge:m.route===zt?e:0,onClick:()=>s(m.route),children:Xy[m.route]},m.route)),a.map(m=>{const p=ji(m.plugin,m.id);return n.jsx(Hh,{label:m.title,href:p,active:t===p,badge:0,onClick:()=>s(p),children:n.jsx(Se,{name:I1(m.icon)})},p)}),n.jsx("div",{className:"rail-spacer"}),n.jsx(Hh,{label:"Settings",href:pn,active:t===pn,badge:0,dot:l?"a newer buddi is ready":o,onClick:()=>s(pn),children:Xy[pn]}),n.jsx(T6,{theme:r,onTheme:i,onNavigate:s,version:c,stale:u,reload:f,timezone:d})]})}const A6=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function T6({theme:e,onTheme:t,onNavigate:s,version:r,stale:i,reload:a=()=>window.location.reload(),timezone:l}){var x,y,v;const o=se(()=>A.owner(),[]),c=se(()=>A.focus(),[],6e4),u=((x=c.data)==null?void 0:x.focus)??null,f=(N,b)=>{A.setFocus(N,b).finally(()=>c.reload())},d=((v=(y=o.data)==null?void 0:y.preferredName)==null?void 0:v.trim())||null,m=(d??"You").slice(0,1).toUpperCase(),[p]=h.useState(uD),[j]=h.useState(P6),w=d?`You: ${d}`:"You",k=u?`${gl[u.mode]} ${M1(u,l)}`:null,g=[w,k,i?"reload to update":null].filter(Boolean).join(", ");return n.jsx("div",{className:"rail-owner",children:n.jsxs(Mg,{modal:!1,children:[n.jsx($g,{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(xd,{children:n.jsxs(Dg,{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(ai,{className:"ui-menu-sep"}),n.jsx(I6,{focus:u,timezone:l,onSwitch:f}),n.jsx(ai,{className:"ui-menu-sep"}),n.jsx(vd,{className:"ui-menu-label",children:"Theme"}),n.jsx("div",{className:"rail-owner-theme",children:n.jsx(Ar,{label:"Theme",options:A6,value:e,onChange:t})}),n.jsx(ai,{className:"ui-menu-sep"}),n.jsx(ma,{className:"ui-menu-item",onSelect:()=>s(tt("appearance")),children:"Change appearance"}),p||i?n.jsxs(ma,{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"}),j?n.jsx("kbd",{className:"rail-owner-kbd",children:j}):null]}):null,r?n.jsxs(n.Fragment,{children:[n.jsx(ai,{className:"ui-menu-sep"}),n.jsxs(ma,{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 gl={normal:"Off","urgent-only":"Urgent only","do-not-disturb":"Do not disturb"},R6=[{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 M1(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 I6({focus:e,timezone:t,onSwitch:s}){return n.jsxs(u$,{children:[n.jsxs(d$,{className:"ui-menu-item rail-owner-focus",children:[n.jsx("span",{children:"Focus"}),n.jsx("span",{className:"rail-owner-kbd",children:e?gl[e.mode]:"Off"})]}),n.jsx(xd,{children:n.jsxs(h$,{className:"ui-menu rail-owner-menu",sideOffset:6,children:[n.jsx("p",{className:"ui-menu-empty",role:"status",children:e?`${gl[e.mode]} ${M1(e,t)}${e.by==="schedule"?", from a schedule":""}.`:"No focus is on."}),["do-not-disturb","urgent-only"].map(r=>n.jsxs(VS,{children:[n.jsx(ai,{className:"ui-menu-sep"}),n.jsx(vd,{className:"ui-menu-label",children:gl[r]}),R6.map(i=>n.jsx(ma,{className:"ui-menu-item","aria-label":`${gl[r]} ${i.label.toLowerCase()}`,onSelect:()=>s(r,i.value),children:i.label},i.value))]},r)),e?n.jsxs(n.Fragment,{children:[n.jsx(ai,{className:"ui-menu-sep"}),n.jsx(ma,{className:"ui-menu-item",onSelect:()=>s("normal"),children:"Turn off"})]}):null]})})]})}function P6(){const e=window.navigator.userAgent;return/iPhone|iPad|Android|Mobile/.test(e)?null:/Mac/.test(e)?"⌘R":"Ctrl+R"}function Hh({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 Xy={[vi]:n.jsx(Se,{name:"files"}),[zt]:n.jsx(Se,{name:"home"}),[Cr]:n.jsx(Se,{name:"chat"}),[ut]:n.jsx(Se,{name:"agents"}),[jt]:n.jsx(Se,{name:"activity"}),[pn]:n.jsx(Se,{name:"settings"})},co=e=>`${e.plugin}:${e.id}`,M6=new Set;let bx=M6,Zy=!1;const Jm=new Set;function Xm(e){bx=e;for(const t of Jm)t()}function $6(e){return Jm.add(e),()=>Jm.delete(e)}const ew=()=>bx;function D6(){Zy||(Zy=!0,Promise.resolve().then(()=>A.rail()).then(e=>Xm(new Set(Array.isArray(e==null?void 0:e.hidden)?e.hidden.filter(t=>typeof t=="string"):[]))).catch(()=>{}))}async function _6(e,t){const s=bx,r=new Set(s);t?r.add(co(e)):r.delete(co(e)),Xm(r);try{await A.setRailHidden(e.plugin,e.id,t)}catch(i){throw Xm(s),i}}function $1(){return h.useEffect(D6,[]),h.useSyncExternalStore($6,ew,ew)}function O6(e,t){return e.filter(s=>!t.has(co(s)))}function L6(e){return e instanceof HTMLElement?e.isContentEditable?!0:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function F6(e,t=!0,s){h.useEffect(()=>{if(!t)return;const r=i=>{if(i.key!=="/"||i.defaultPrevented||i.ctrlKey||i.metaKey||i.altKey||L6(i.target))return;i.preventDefault();const a=document.getElementById(Wm);if(a instanceof HTMLTextAreaElement){!a.disabled&&!a.hidden&&a.focus();return}s?s():e(zt)};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t,s])}const D1="buddi.theme";function U6(e=_1()){try{const t=e==null?void 0:e.getItem(D1);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function B6(e,t=_1()){try{t==null||t.setItem(D1,e)}catch{}}function z6(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function _1(){try{return window.localStorage}catch{return}}const O1="buddi.ground",L1="buddi.pageWidth";function W6(e=B1()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},s=t(O1),r=t(L1);return{theme:U6(e),ground:s==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function F1(e,t=document.documentElement){t&&(z6(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 H6(e,t=B1()){B6(e.theme,t);try{t==null||t.setItem(O1,e.ground),t==null||t.setItem(L1,e.width)}catch{}}let ga=null;const Zm=new Set;function ep(){return ga||(ga=W6()),ga}function V6(e){return Zm.add(e),()=>Zm.delete(e)}function K6(e){ga={...ep(),...e},F1(ga),H6(ga);for(const t of Zm)t()}function U1(){return[h.useSyncExternalStore(V6,ep,ep),K6]}function B1(){try{return window.localStorage}catch{return}}function G6({timezone:e,embedded:t}){var m,p;const{data:s,error:r,reload:i}=se(()=>A.sentinels(),[],3e4),a=se(()=>A.missions(),[]),[l,o]=h.useState(null),c=((p=(m=a.data)==null?void 0:m.missions.find(j=>j.id==="sentinel-wake"))==null?void 0:p.agentId)??null,u=async(j,w)=>{o(null);try{await A.snoozeAlert(j,w),i()}catch(k){o(k instanceof Error?k.message:String(k))}},f=((s==null?void 0:s.open)??[]).filter(j=>!j.snoozedAt),d=((s==null?void 0:s.open)??[]).filter(j=>j.snoozedAt);return n.jsxs(hn,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[n.jsx(te,{message:r??l}),n.jsx(W,{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(Vh,{title:"Open",findings:f,timezone:e,askAgentId:c,onSnooze:j=>u(j,!0),empty:"Nothing open. Your watchers are quiet."}),d.length>0?n.jsx(Vh,{title:"Snoozed",findings:d,timezone:e,askAgentId:c,onSnooze:j=>u(j,!1),empty:""}):null,n.jsx(Vh,{title:"Resolved",findings:(s==null?void 0:s.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),n.jsx(st,{title:"Waiting for the weekly recap",flush:!0,children:!s||s.digest.length===0?n.jsx(Pt,{icon:"bell",title:"Nothing waiting for the recap"}):n.jsxs(Sn,{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(j=>n.jsxs("tr",{children:[n.jsxs("td",{children:[Ca(j.title),n.jsx(W1,{text:Ca(j.detail)})]}),n.jsx("td",{children:n.jsx(z1,{severity:j.severity})}),n.jsx("td",{className:"nowrap",children:Ve(j.createdAt,e)})]},j.id))})]})})]})}function z1({severity:e}){return n.jsx(xe,{tone:e==="urgent"?"critical":void 0,children:e})}function W1({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 Y6(e){return`About this alert: "${Ca(e.title)}". ${Ca(e.detail)}
108
+
109
+ What should I do about it, and what do you need from me to clear it?`}function Vh({title:e,findings:t,timezone:s,askAgentId:r,onSnooze:i,empty:a}){const l=e==="Snoozed";return n.jsx(st,{title:e,flush:!0,children:t.length===0?n.jsx(oe,{children:a}):n.jsxs(Sn,{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:Ca(o.title)}),n.jsx(W1,{text:Ca(o.detail)}),o.data?n.jsx(Mt,{summary:"evidence",children:n.jsx(Nt,{children:kn(o.data)})}):null]}),n.jsx("td",{children:n.jsx(z1,{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 ",De(o.lastSeenAt)]})]}),i?n.jsx("td",{children:n.jsxs(Q,{align:"end",children:[r?n.jsx(Gt,{size:"sm",href:Ke(r,"new"),onClick:()=>U4(r,Y6(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 tw=5e3,nw=50;function q6({timezone:e,embedded:t}){var g;const[s,r]=h.useState(""),[i,a]=h.useState(""),[l,o]=h.useState(null),c=se(()=>A.eventKinds(),[]),{data:u,error:f}=se(()=>A.events({kind:s||void 0,q:i||void 0,limit:nw}),[s,i],tw),[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,j=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:nw});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(hn,{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 ",tw/1e3,"s"]})]}),n.jsx(te,{message:f}),n.jsx(st,{flush:!0,children:!u||k.length===0?n.jsx(oe,{children:"No events match."}):n.jsxs(Sn,{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:De(x.createdAt)})]}),n.jsx("td",{className:"mono nowrap",children:x.kind}),n.jsx("td",{className:"mono muted",children:Ps(kn(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 j(),children:d.busy?"Loading…":"Load older"}):null]}):null,l?n.jsxs(tn,{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:kn(l.payload)})]}):null]})}const Q6=["pending","leased","suspended","failed","succeeded","cancelled"],ul=50;function J6({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}=se(()=>A.jobs({...r?{state:r}:{},limit:String(ul)}),[r],1e4),[m,p]=h.useState({jobs:[],done:!1,busy:!1});h.useEffect(()=>{p({jobs:[],done:!1,busy:!1})},[r]);const j=async()=>{p(S=>({...S,busy:!0}));try{const S=await A.jobs({...r?{state:r}:{},limit:String(ul),offset:String(ul+m.jobs.length)});p(C=>({jobs:[...C.jobs,...S.jobs],done:S.jobs.length<ul,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)>=ul,[y,v]=h.useState(null),N=async S=>{c(null),v(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{v(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(hn,{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"}),Q6.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(te,{message:f??o}),n.jsx(st,{flush:!0,children:!u||k.length===0?n.jsx(oe,{children:"No jobs match."}):n.jsxs(Sn,{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:so(S.id)})]}),n.jsxs("td",{children:[n.jsx(kd,{state:S.state}),S.suspendedReason?n.jsx("div",{className:"sub",children:Ps(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?Ps(S.lastError,80):"—"}),n.jsxs("td",{className:"nowrap",children:[Ve(S.updatedAt,e),n.jsx("div",{className:"sub",children:De(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 j(),children:m.busy?"Loading…":"Load older"})]}):null,a?n.jsxs(tn,{title:a.kind,onClose:()=>l(null),children:[n.jsx("p",{className:"muted mono",children:a.id}),n.jsx(Y,{title:"Payload",children:n.jsx(Nt,{children:kn(a.payload)})}),n.jsx(Y,{title:"Result",children:n.jsx(Nt,{children:kn(a.result)})}),a.conversationId?n.jsx("p",{children:n.jsx("a",{href:`#/conversations/${a.conversationId}`,children:"open the transcript"})}):null]}):null]})}const X6=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function Z6({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(nU,{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(Qg,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:n.jsx(iU,{})}),n.jsx(aU,{}),n.jsx(Nd,{children:X6.map(d=>{const m=d.id==="conversations"?jt:`${jt}/${d.id}`;return n.jsx(Cd,{href:m,active:l===d.id,onClick:c(m),children:d.label},d.id)})}),l==="conversations"?n.jsx(eU,{timezone:t,navigate:s,nameOf:a,agents:r}):null,l==="jobs"?n.jsx(J6,{timezone:t,embedded:!0,initialState:o},o??""):null,l==="approvals"?n.jsx(tU,{timezone:t,nameOf:a}):null,l==="alerts"?n.jsx(G6,{timezone:t,embedded:!0}):null,l==="events"?n.jsx(q6,{timezone:t,embedded:!0}):null]})}function eU({timezone:e,navigate:t,nameOf:s,agents:r}){const{data:i,error:a}=se(()=>A.conversations(),[],3e4);return n.jsxs(n.Fragment,{children:[n.jsx(te,{message:a}),n.jsx(st,{flush:!0,children:i?i.conversations.length===0?n.jsx(Pt,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):n.jsx(Ht,{children:i.conversations.map(l=>n.jsx(Vt,{href:Ea(l.id),onClick:()=>t(Ea(l.id)),lead:n.jsx(xn,{agents:r,id:l.agentId,size:"sm"}),title:l.opening?Ps(l.opening,100):"Untitled conversation",sub:`${s(l.agentId)}, ${l.messageCount} message${l.messageCount===1?"":"s"}, ${l.runs} run${l.runs===1?"":"s"}, ${T$(l.usage)}`,side:n.jsx("span",{title:Ve(l.lastMessageAt??l.createdAt,e),children:De(l.lastMessageAt??l.createdAt)})},l.id))}):n.jsx(oe,{children:"Loading…"})})]})}function tU({timezone:e,nameOf:t}){const{data:s,error:r}=se(()=>A.approvals(),[],1e4),i=[...(s==null?void 0:s.pending)??[],...(s==null?void 0:s.recent)??[]];return n.jsxs(n.Fragment,{children:[n.jsx(te,{message:r}),n.jsx(st,{flush:!0,children:s?i.length===0?n.jsx(Pt,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):n.jsxs(Sn,{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:so(a.id)})]}),n.jsx("td",{children:n.jsx(kd,{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:De(a.createdAt)})]})]},a.id))})]}):n.jsx(oe,{children:"Loading…"})})]})}function nU({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(Gt,{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(te,{message:l}),i?n.jsxs(n.Fragment,{children:[n.jsxs(Sd,{children:[n.jsx(Cs,{label:"Agent",value:r(i.agentId),size:"sm"}),n.jsx(Cs,{label:"Runs",value:i.runs.length}),n.jsx(Cs,{label:"Tokens",value:`${Tt(i.usage.input)} / ${Tt(i.usage.output)}`,note:vm(i.usage)?`input / output, ${vm(i.usage)}`:"input / output"}),n.jsx(Cs,{label:"Started",value:Ve(i.createdAt,t),size:"sm"})]}),i.runs.length>0?n.jsx(st,{title:"Runs",flush:!0,children:n.jsxs(Sn,{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 ",so(u.actionId)]}):null]}),n.jsxs("td",{className:"num muted nowrap",children:[Tt(u.usage.input)," / ",Tt(u.usage.output)]}),n.jsx("td",{className:"num muted nowrap",children:u.usage.cacheRead||u.usage.cacheWrite?Tt((u.usage.cacheRead??0)+(u.usage.cacheWrite??0)):"—"})]},f))})]})}):null,n.jsx(Y,{title:"Messages",children:n.jsx(V,{children:i.messages.map(u=>n.jsxs("article",{className:"transcript-msg",children:[n.jsxs("header",{className:"transcript-who",children:[u.speaker===sw?"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===sw?u.blocks.map((f,d)=>n.jsx(sU,{block:f},d)):u.blocks.map((f,d)=>n.jsx(rU,{block:f},d))]})]},u.id))})})]}):n.jsx(oe,{children:"Loading…"})]})}const sw="approval:resume";function sU({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??"":kn(e)})]})}function rU({block:e}){return e.type==="text"?n.jsx("div",{className:"transcript-text",children:n.jsx(tr,{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(tr,{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:kn(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:kn(e.ref)})]})}function iU(){const{data:e,reload:t}=se(()=>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 aU(){const{data:e}=se(()=>A.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,s=t("leased");return n.jsxs(Sd,{children:[n.jsx(Cs,{label:"Jobs done",value:Tt(t("succeeded"))}),n.jsx(Cs,{label:"Failed",value:Tt(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),n.jsx(Cs,{label:"Queued",value:Tt(t("pending")),note:`${s} running`}),n.jsx(Cs,{label:"Approvals",value:Tt(e.approvals.pending),note:"waiting for you"})]})}const lU=["replay-all","coalesce","latest-only","skip-after-deadline"];function H1({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=se(()=>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(hn,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[n.jsx(te,{message:i??o}),!r||l.length===0?n.jsxs(Pt,{icon:"calendar",title:"No missions yet",children:["Run ",n.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):n.jsx(V,{children:l.map(f=>n.jsx(oU,{mission:f,timezone:e,onRun:u},f.id))})]})}function oU({mission:e,timezone:t,onRun:s}){const[r,i]=h.useState(!1);return n.jsxs(Dn,{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)} (${De(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"} ${De(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(X,{inline:!0,label:"Misfire policy",children:n.jsx("select",{value:e.schedule.misfirePolicy,onChange:a=>s(A.setMisfirePolicy(e.id,a.target.value)),children:lU.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(Y,{title:"Prompt",children:n.jsx(Nt,{children:e.prompt})}),n.jsx(Y,{title:"Recent occurrences",children:n.jsx(st,{flush:!0,children:e.occurrences.length===0?n.jsx(oe,{children:"Never run."}):n.jsxs(Sn,{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(kd,{state:a.state})}),n.jsx("td",{className:"nowrap",children:Ve(a.finishedAt,t)}),n.jsxs("td",{className:a.error?"critical":"muted",children:[a.error?Ps(a.error,120):null,a.runConversationId?n.jsx("a",{href:`#/conversations/${a.runConversationId}`,children:"transcript"}):null]})]},a.id))})]})})})]}):null]})}function cU(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 V1({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:cU(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 K1({embedded:e,agentId:t,agentName:s}){const{data:r,error:i,reload:a}=se(()=>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,j]=h.useState(null),w=async(g,x)=>{f(null),m(g);try{const y=await A.takeOffer(g);j(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),j(`Dismissed — ${x}. It will not come back.`),a()}catch(y){f(y instanceof Error?y.message:String(y))}finally{m(null)}};return n.jsxs(hn,{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(te,{message:i??u}),p?n.jsx(W,{tone:"good",role:"status",children:p}):null,o.length>0?n.jsxs(Q,{children:[n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(V1,{ids:o.map(g=>g.id),agentName:s,onDone:()=>{j(null),a()}})]}):null,!r||o.length===0?n.jsx(Pt,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):n.jsx(V,{children:o.map(g=>n.jsx(Dn,{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 ",De(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(Mt,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[n.jsx(st,{flush:!0,children:n.jsx(Ht,{children:c.map(g=>n.jsx(Vt,{title:g.label,sub:`${g.agentId} — ${GI(g)}`,side:De(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 uU="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.",hU="front-desk";function G1(e,t){return e.length>0&&e.every(s=>s.id===t||s.roles.includes(hU)||s.roles.includes(wd))}const fU={plugins:{label:"Plugins",route:tt("plugins")},mailbox:{label:"Add a mailbox",route:wo("email","settings")},accounts:{label:"Accounts",route:tt("accounts")}},mU="Your starter team is complete. Agent Father can make others.";function tp({navigate:e,standing:t=!1}){var f;const s=se(()=>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(Y,{title:uU,children:c.length===0?n.jsx("p",{className:"teammates-lede","data-testid":"teammates-complete",children:mU}):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(pU,{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 pU({row:e,navigate:t,onDismiss:s}){const r=dx(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?fU[e.fix]:null;return n.jsx("div",{className:"teammate","data-state":l,"data-testid":`teammate-${e.agent}`,children:n.jsxs(Dn,{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(Ms,{}),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(te,{message:r.failure})]}),children:[n.jsx("p",{className:"ui-card-meta",children:e.text}),n.jsx("p",{className:"teammate-needs",children:e.needs})]})})}const gU=["fact","observation","todo"];function Y1({embedded:e,agents:t,timezone:s,agentId:r}){const{data:i,error:a,reload:l}=se(()=>A.memory(r),[r],3e4),[o,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState(null),p=v=>{var N;return v==="shared"?"Everyone":((N=t.find(b=>b.id===v))==null?void 0:N.name)??v},j=async v=>{m(null);try{await v,l()}catch(N){m(N instanceof ae?N.message:String(N))}},w={nameOf:p,timezone:s,onChangePreference:v=>c({key:v.key,scope:v.scope}),onForgetPreference:v=>void j(A.forgetPreference({key:v.key,scope:v.scope})),onEditNote:v=>f(v),onForgetNote:v=>void j(A.forgetNote(v.id))},k=r?p(r):"",g=r&&i?{preferences:i.preferences.filter(v=>v.scope===r),notes:i.notes.filter(v=>v.scope===r)}:null,x=r&&i?{preferences:i.preferences.filter(v=>v.scope==="shared"),notes:i.notes.filter(v=>v.scope==="shared")}:null,y=n.jsx(I,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return n.jsxs(hn,{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(te,{message:a??d}),g&&x?n.jsxs(V,{gap:"lg",children:[n.jsx(Y,{title:"Preferences",aside:`what you told ${k} alone`,actions:y,panel:!0,flush:!0,children:n.jsx(Kh,{preferences:g.preferences,empty:`Nothing stated to ${k} alone yet.`,...w})}),n.jsx(Y,{title:"Notes",aside:`what ${k} wrote down for itself`,panel:!0,flush:!0,children:n.jsx(Gh,{notes:g.notes,empty:`${k} has kept no private notes yet.`,...w})}),n.jsx(Mt,{summary:`Shared with every agent, which ${k} also reads · ${x.preferences.length} preferences, ${x.notes.length} notes`,children:n.jsxs(V,{gap:"lg",children:[n.jsx(Y,{title:"Shared preferences",panel:!0,flush:!0,children:n.jsx(Kh,{preferences:x.preferences,empty:"No shared preferences.",...w})}),n.jsx(Y,{title:"Shared notes",panel:!0,flush:!0,children:n.jsx(Gh,{notes:x.notes,empty:"No shared notes.",...w})})]})})]}):n.jsxs(V,{gap:"lg",children:[n.jsx(Y,{title:"Preferences",aside:"what you said you want, one current value each",actions:y,panel:!0,flush:!0,children:i?n.jsx(Kh,{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(Y,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?n.jsx(Gh,{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(xU,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:o,onClose:()=>c(null),onSave:async v=>{await j((async()=>{await A.setPreference(v),o.key===v.key&&o.scope!==v.scope&&await A.forgetPreference({key:o.key,scope:o.scope})})()),c(null)}}):null,u?n.jsx(vU,{note:u,agents:t,onClose:()=>f(null),onSave:v=>j(A.updateNote(u.id,v)).then(()=>f(null))}):null]})}function Kh({preferences:e,empty:t,nameOf:s,onChangePreference:r,onForgetPreference:i}){return e.length===0?n.jsx(oe,{children:t}):n.jsxs(Sn,{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(q1,{scope:a.scope,name:s(a.scope)})}),n.jsxs("td",{className:"num muted",title:a.updatedAt??"",children:[a.updatedAt?De(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 Gh({notes:e,empty:t,nameOf:s,timezone:r,onEditNote:i,onForgetNote:a}){return e.length===0?n.jsx(oe,{children:t}):n.jsxs(Sn,{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(q1,{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?De(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 q1({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 Q1({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 xU({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),j=l.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(x=>x.key===j&&x.scope===f),k=!a||j!==a.key||c.trim()!==a.value||f!==a.scope,g=j!==""&&c.trim()!==""&&k;return n.jsx(tn,{title:"A preference",onClose:r,children:n.jsxs(V,{children:[n.jsx(W,{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(X,{label:"Key",hint:j&&j!==l?`Stored as ${j}`:"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(X,{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(X,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:n.jsx(Q1,{value:f,agents:e,onChange:d})}),w&&w!==a?n.jsxs(W,{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(W,{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:j,value:c.trim(),scope:f}).finally(()=>p(!1))},children:a?"Save change":"Save"})]})]})})}function vU({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(tn,{title:"A note",onClose:s,children:n.jsxs(V,{children:[n.jsx(X,{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:j=>a(j.target.value)})}),n.jsxs(nr,{children:[n.jsx(X,{label:"Kind",children:n.jsx("select",{value:c,onChange:j=>u(j.target.value),children:gU.map(j=>n.jsx("option",{value:j,children:j},j))})}),n.jsx(X,{label:"Who sees it",children:n.jsx(Q1,{value:l,agents:t,onChange:o})})]}),e.createdByAgent?n.jsxs("p",{className:"muted",children:["Written by ",((p=t.find(j=>j.id===e.createdByAgent))==null?void 0:p.name)??e.createdByAgent,e.createdAt?`, ${De(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 j={};i.trim()!==e.content&&(j.content=i.trim()),l!==e.scope&&(j.scope=l),c!==e.kind&&(j.kind=c),r(j).finally(()=>d(!1))},children:"Save"})]})]})})}function jU({agentId:e,agentName:t}){const{data:s,error:r,reload:i}=se(()=>A.agentSkills(e),[e],3e4),[a,l]=h.useState(null),[o,c]=h.useState(null),[u,f]=h.useState(null),d=async j=>{l(null),c(null),f(j.name);try{const w=await A.removeSkill(e,j.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){l(w instanceof ae?w.message:String(w))}finally{f(null)}};if(!s)return r?n.jsx(te,{message:r}):n.jsx(oe,{children:"Loading…"});const m=s.skills.filter(j=>j.learned!==null),p=s.skills.filter(j=>j.learned===null);return n.jsxs(V,{divided:!0,children:[n.jsx(te,{message:r??a}),o?n.jsx(W,{tone:"good",role:"status",children:o}):null,n.jsx(Y,{title:"Learned",aside:n.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:m.length===0?n.jsx(Pt,{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(st,{flush:!0,children:n.jsxs(Sn,{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(j=>n.jsx(wU,{skill:j,busy:u===j.name,onRemove:()=>void d(j)},j.name))})]})})}),n.jsx(Y,{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(st,{flush:!0,children:n.jsxs(Sn,{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(j=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(Mt,{summary:n.jsx("span",{className:"mono",children:j.name}),children:[n.jsx(Nt,{children:j.body}),n.jsx("p",{className:"muted mono skill-file",children:j.file})]})}),n.jsx("td",{children:j.description}),n.jsx("td",{children:n.jsxs(V,{gap:"sm",children:[n.jsx(xe,{children:j.scope==="shared"?"shared":`${t} only`}),n.jsx("span",{className:"muted",children:yU(j)})]})})]},`${j.scope}:${j.name}`))})]})})})]})}function yU(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function wU({skill:e,busy:t,onRemove:s}){const r=e.learned;return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(Mt,{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(V,{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(V,{gap:"sm",children:[r.conversation?n.jsx("a",{href:Ea(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?De(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 J1({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=se(()=>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(hn,{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(te,{message:i??o}),n.jsx(st,{flush:!0,children:r?l.length===0?n.jsx(Pt,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):n.jsxs(Sn,{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:De(f.dueAt)})]}),n.jsx("td",{className:"mono",children:f.agentId}),n.jsxs("td",{children:[f.text,f.context?n.jsx(Mt,{summary:"context",children:n.jsx(Nt,{children:kn(f.context)})}):null]}),n.jsxs("td",{children:[n.jsx(kd,{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 kx({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),j=async x=>{if(!e)return;const y=++p.current;c(!0),f("");try{const v=await A.accountModels(e,x);y===p.current&&l(v)}catch(v){y===p.current&&f(v instanceof Error?v.message:"Could not load models. Custom entry is still available.")}finally{y===p.current&&c(!1)}};if(h.useEffect(()=>(l(null),m(!1),f(""),j(!1),()=>{p.current++}),[e]),!e)return n.jsxs(n.Fragment,{children:[n.jsx(X,{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(X,{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 j(!0),children:o?"Loading models…":"Refresh models"}),d&&n.jsx(X,{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 bU(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 kU(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const SU="This agent will not remember anything between conversations.";function NU({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),j=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=>j.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),v=(((N=e.suggested)==null?void 0:N.tools)??[]).filter(b=>!p.has(b.name));return n.jsxs("div",{className:"tool-picker",children:[e.suggested&&v.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:v.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}`,L=`${m}-${b.plugin}-list`,$=g!==""?!c.has(b.plugin):c.has(b.plugin);return n.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":P,"data-open":$?"true":void 0,children:[n.jsxs("div",{className:"tool-picker-head",children:[n.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":$,"aria-controls":L,onClick:()=>f(b.plugin),children:[n.jsx(CU,{}),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(W,{tone:"warning",role:"alert",children:n.jsxs("div",{className:"tool-picker-confirm",children:[n.jsx("span",{children:SU}),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:L,className:"ui-list tool-picker-list",hidden:!$,children:S.map(T=>{const M=`${m}-${T.name}`;return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",id:M,checked:p.has(T.name),disabled:r||!T.grantable,onChange:U=>U.target.checked?k([T.name]):w(b.plugin,[T.name])}),n.jsxs("label",{htmlFor:M,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 CU(){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 EU=(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 X1(e){const t=await fetch(Wr(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 Z1({face:e,onPick:t,label:s=F.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,HD.map(o=>{const c={kind:"mascot",role:o},u=EU(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":F.assistant.mascot(o),disabled:i,onClick:()=>t(c),children:n.jsx("img",{src:Wr(o),alt:""})},o)})]}),n.jsx("div",{className:"meet-face-row",children:KD.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 AU=["mirror","en","fr"],eC=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"access",label:"Access"}],rw=e=>{var t;return((t=eC.find(s=>s.id===e))==null?void 0:t.id)??"identity"};function TU({agentId:e,section:t,navigate:s}){var w,k,g;const{data:r,error:i,reload:a}=se(()=>A.agents(),[]),[l,o]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(rw(t));h.useEffect(()=>d(rw(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))}},j=r==null?void 0:r.agents.find(x=>x.id===e);return n.jsxs(V,{gap:"lg",children:[n.jsx(Nd,{level:"secondary",label:"Setup",children:eC.map(x=>n.jsx(Cd,{href:dt(e,"setup",x.id),active:f===x.id,onClick:y=>{y.preventDefault(),m(x.id)},children:x.label},x.id))}),n.jsx(te,{message:i??l}),c?n.jsx(W,{tone:"good",role:"status",children:c}):null,r?j?n.jsx(RU,{agent:j,all:r.agents,engine:r.engines.find(x=>x.id===j.id),providers:r.providers,accounts:r.providerAccounts,shown:f,onShow:m,onRun:p,onSaved:a},`${j.id}:${(w=r.engines.find(x=>x.id===j.id))==null?void 0:w.model}:${(g=(k=r.providerAccounts)==null?void 0:k.bindings.find(x=>x.agentId===j.id))==null?void 0:g.accountId}`):n.jsx(oe,{children:"This agent is not installed as a file."}):n.jsx(oe,{children:"Loading…"})]})}function RU({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(v=>v.kind===u),d=(s==null?void 0:s.model)??e.model,[m,p]=h.useState(String((s==null?void 0:s.maxTurns)??e.maxTurns)),j=v=>{o(A.setAgentEngine(e.id,v))},w=v=>{const N=r.find(b=>b.kind===v);j({provider:v,model:(N==null?void 0:N.defaultModel)??d})},k=(f==null?void 0:f.models.map(v=>v.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(V,{gap:"lg",children:[x?null:n.jsxs(W,{tone:"warning",children:["This agent cannot run right now."," ",n.jsx("a",{href:dt(e.id,"setup","brain"),onClick:v=>{v.preventDefault(),l("brain")},children:"See Brain."})]}),n.jsx(IU,{agent:e,onSaved:c})]})}),n.jsx("div",{hidden:a!=="brain",children:n.jsxs(V,{gap:"lg",children:[x?null:n.jsxs(W,{tone:"warning",children:["This agent cannot run right now: ",y,"."]}),n.jsx(Y,{panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsxs(Y,{title:"Runs on",children:[i?n.jsx(_U,{agentId:e.id,accounts:i,onRun:o}):n.jsxs(nr,{children:[n.jsx(X,{label:"Provider",children:n.jsx("select",{value:u,onChange:v=>w(v.target.value),children:r.map(v=>n.jsxs("option",{value:v.kind,children:[v.kind,v.usable?"":" (no credential)"]},v.kind))})}),n.jsxs(X,{label:"Model",children:[n.jsx("input",{list:`models-${e.id}`,defaultValue:d,onBlur:v=>{v.target.value.trim()!==""&&v.target.value.trim()!==d&&j({model:v.target.value.trim()})}}),n.jsx("datalist",{id:`models-${e.id}`,children:g.map(v=>n.jsx("option",{value:v},v))})]})]}),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(Y,{title:"Behaviour",aside:"saved as you change them",children:n.jsxs(nr,{children:[n.jsx(X,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:n.jsx("input",{type:"number",min:1,value:m,onChange:v=>p(v.target.value),onBlur:()=>{const v=Number(m);Number.isInteger(v)&&v>=1&&v!==((s==null?void 0:s.maxTurns)??e.maxTurns)&&j({maxTurns:v})}})}),n.jsx(X,{label:"Language",hint:"Mirror answers in whatever language you write.",children:n.jsx("select",{value:(s==null?void 0:s.language)??e.language,onChange:v=>j({language:v.target.value}),children:AU.map(v=>n.jsx("option",{value:v,children:v},v))})}),Jk(Xk(s??{id:e.id,provider:u},i))?n.jsx(X,{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:v=>j({thinking:v.target.value==="default"?null:v.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(X,{label:"Thinking",hint:qI,children:n.jsx("span",{className:"ui-card-meta",children:"Up to the model"})})]})})]})})]})}),n.jsx("div",{hidden:a!=="access",children:n.jsxs(V,{gap:"lg",children:[n.jsx(PU,{agent:e,all:t,onSaved:c}),n.jsx(UU,{agent:e,all:t,onSaved:c}),n.jsx(Mt,{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 tC({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 nC=n.jsx(W,{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 IU({agent:e,onSaved:t}){var $;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=se(()=>A.agentFile(e.id),[e.id]),[p,j]=h.useState(null),w=(($=m.data)==null?void 0:$.persona.trim())??"",k=p??w,g=m.data!==void 0&&p!==null&&p.trim()!==w,[x,y]=h.useState(!1),[v,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=np(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}:{}},L=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(to))),j(null),m.reload(),S(T.message),t()}catch(T){N(T instanceof Error?T.message:String(T))}finally{y(!1)}};return n.jsx(Y,{title:"Who it is",aside:n.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:n.jsx(tC,{dirty:C,busy:x,failure:v,label:"Save who it is",onSave:()=>void L()}),children:n.jsxs(V,{children:[e.isExample?nC:null,b?n.jsx(W,{tone:"good",role:"status",children:b}):null,n.jsxs(nr,{children:[n.jsx(X,{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(X,{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(ms,{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($U,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:x}):null,n.jsx(X,{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(X,{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(te,{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=>j(T.target.value)}):n.jsx(oe,{children:"Reading its file…"})})]})})}function PU({agent:e,all:t,onSaved:s}){var R;const r=se(()=>A.agentTools(e.id),[e.id]),[i,a]=h.useState(null),[l,o]=h.useState(()=>new Set((e.roles??[]).filter(Qj))),[c,u]=h.useState((e.roles??[]).filter(E=>!Qj(E)).join(", ")),[f,d]=h.useState(!1),[m,p]=h.useState(null),[j,w]=h.useState(null),k=(E,P)=>E.split(P).map(L=>L.trim()).filter(L=>L!==""),g=((R=r.data)==null?void 0:R.granted)??e.tools,x=i??g,y=r.data!==void 0&&!kU(x,g),v=Jj(l,k(c,/[\n,]/)),N=E=>o(P=>{const L=new Set(P);return L.has(E)?L.delete(E):L.add(E),L}),S=y||!((E,P)=>E.join(",")===P.join(","))(v,Jj(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:bU(r.data.groups,x)}:{},roles:v});w(E.message),a(null),r.reload(),s()}catch(E){p(E instanceof Error?E.message:String(E))}finally{d(!1)}};return n.jsx(Y,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:n.jsx(tC,{dirty:S,busy:f,failure:m,label:"Save roles and tools",onSave:()=>void C()}),children:n.jsxs(V,{children:[e.isExample?nC:null,j?n.jsx(W,{tone:"good",role:"status",children:j}):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:zg.map(E=>{const P=tD(t,E.id),L=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}),L?n.jsxs("span",{className:"role-chip-holder",children:["Held by ",L.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(X,{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(te,{message:r.error}):r.data?n.jsx(NU,{view:r.data,chosen:x,onChange:a,disabled:f||e.isExample}):n.jsx(oe,{children:"Loading the installed tools…"})]}),n.jsx(MU,{agentId:e.id,version:g.join(","),disabled:f||e.isExample})]})})}function MU({agentId:e,version:t,disabled:s}){var f;const r=se(()=>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(V,{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(te,{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 np(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 $U({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 j=>{if(f(null),j.kind==="emoji"){s(j.value);return}if(j.kind==="kept"){s(e.avatar??"");return}l(j),c(!0);try{await A.uploadAgentPicture(e.id,await X1(j.role)),s(e.avatar??""),r(),window.dispatchEvent(new Event(to))}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(Z1,{face:m,label:"Face",kept:e.picture,disabled:i||o,disableEmoji:e.isExample,onPick:j=>void p(j),children:n.jsx(DU,{agent:e,onChanged:r})}),u?n.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function DU({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 j=S=>{r(null),p(C=>C+1),d(S),t(),window.dispatchEvent(new Event(to))},w=async S=>{o(!0),u(null),d(null);try{j(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:np(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[y,v]=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||v(!0)},onDragLeave:()=>v(!1),onDrop:S=>{var C;S.preventDefault(),v(!1),l||b((C=S.dataTransfer.files)==null?void 0:C[0])},children:[n.jsxs(Q,{children:[n.jsx(ms,{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 _U({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(X,{label:"Account",children:n.jsxs("select",{value:i,disabled:c,onChange:p=>{var j;a(p.target.value),o(((j=t.accounts.find(w=>w.id===p.target.value))==null?void 0:j.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(kx,{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 OU=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],Yh=e=>e.tools.some(t=>OU.includes(t)),LU=["front-desk","maker"],FU={"front-desk":"Can ask: everyone, as the front desk",maker:"Can ask: everyone, as the maker",list:"Can ask: everyone"};function UU({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,j]=h.useState(e.asksEveryone),[w,k]=h.useState(!1),g=t.filter(E=>E.id!==e.id),x=LU.find(E=>{var P;return(P=e.roles)==null?void 0:P.includes(E)}),y=p===void 0||w,v=w||[...r].sort().join(",")!==[...d].sort().join(","),N=t.filter(E=>E.id!==e.id&&(E.delegates.includes(e.id)||E.asksEveryone!==void 0&&!Yh(e))),b=E=>i(P=>P.includes(E)?P.filter(L=>L!==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),j(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=>!Yh(E)).map(E=>E.id)),k(!0),f(!1)},R=v?"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(Y,{title:"Delegation",aside:e.tools.includes("agent.delegate")?"holds agent.delegate":"no agent.delegate tool: it cannot ask anyone until granted",panel:!0,foot:e.isExample?void 0:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:v?"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:!v||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(V,{divided:!0,children:[n.jsxs(Y,{title:"Can ask",children:[e.isExample?n.jsx(W,{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(te,{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=Yh(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:[FU[p??"list"],". New agents are included without being added here; agents that make and change agents are never reachable by delegation."]})]}),n.jsx(Y,{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($_,{children:N.map(E=>n.jsx(xe,{children:E.name},E.id))})})]})})}const BU=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],zU=[{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 WU({hash:e,timezone:t,navigate:s,agents:r,attention:i,defaultAgentId:a}){var g,x,y,v,N;const l=z$(e),o=((g=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:g[1])??"team",c=b=>S=>{S.preventDefault(),s(b)},u=se(()=>A.agents(),[]),f=lx(),d=se(()=>A.offers(),[],2e4),m=a1(),p=(((x=d.data)==null?void 0:x.offers.length)??0)+m.offers.length,j=((v=(y=u.data)==null?void 0:y.default)==null?void 0:v.defaultAgentId)??a??null,w=r.find(b=>b.roles.includes(wd)),k=G1(r,j);return n.jsxs("div",{className:"ui-page",children:[n.jsx(Qg,{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(Gt,{variant:"accent",href:Ke(w.id),onClick:c(Ke(w.id)),children:"Add an agent"}):null}),n.jsx(Nd,{children:BU.map(b=>n.jsx(Cd,{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(H1,{timezone:t,embedded:!0}):null,o==="offers"?n.jsx(l1,{offers:m.offers,reload:m.reload}):null,o==="offers"?n.jsx(K1,{embedded:!0}):null,o==="reminders"?n.jsx(J1,{timezone:t,embedded:!0}):null,o==="team"&&k?n.jsx(tp,{navigate:s,standing:!0}):null,o==="team"?n.jsx(HU,{data:u.data,error:u.error,reload:u.reload}):null,o==="team"?r.length===0?n.jsx(Pt,{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:ZS(r,j).map(b=>{const S=yd(i.get(b.id));return n.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...ko(bo(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(ms,{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===j?n.jsx(ci,{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:Ps(b.unavailableReason??"cannot run",60)}),n.jsx(xe,{mono:!0,children:b.model}),n.jsx(Gt,{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(tp,{navigate:s,standing:!0}):null,l?n.jsx(tn,{title:((N=r.find(b=>b.id===l.agentId))==null?void 0:N.name)??l.agentId,size:"wide",onClose:()=>s(ut),children:n.jsx(VU,{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 HU({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(te,{message:t});if(!r||r.choices.length===0)return null;const m=r.defaultAgentId,p=i??m??"",j=p!==""&&p!==m,w=r.problem,k=x=>x.map(y=>{var v;return((v=r.choices.find(N=>N.id===y))==null?void 0:v.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(st,{children:n.jsxs("div",{className:"ui-stack",children:[n.jsx(te,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?n.jsx(W,{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(W,{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(W,{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||!j,onClick:()=>void g(),children:"Save"})]})]})})}function VU({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=yd(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(ms,{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(Gt,{variant:"accent",href:Ke(e),onClick:c(Ke(e)),children:["Talk to ",f]})})]}),t&&!t.available?n.jsxs(W,{tone:"warning",role:"status",children:[nN(t)," ",n.jsx("a",{href:tt(bm(t).section),children:bm(t).label})]}):null,n.jsx(Nd,{children:zU.map(d=>n.jsx(Cd,{href:dt(e,d.id),active:r===d.id,onClick:c(dt(e,d.id)),children:d.label},d.id))}),r==="conversations"?n.jsx(KU,{agentId:e,navigate:l}):null,r==="missions"?n.jsx(H1,{timezone:a,embedded:!0,agentId:e}):null,r==="offers"?n.jsx(K1,{embedded:!0,agentId:e,agentName:f}):null,r==="reminders"?n.jsx(J1,{timezone:a,embedded:!0,agentId:e}):null,r==="memory"?n.jsx(Y1,{embedded:!0,agents:s,timezone:a,agentId:e}):null,r==="skills"?n.jsx(jU,{agentId:e,agentName:f}):null,r==="setup"?n.jsx(TU,{agentId:e,section:i,navigate:l}):null]})}function KU({agentId:e,navigate:t}){const{data:s,error:r}=se(()=>Oe.conversations(e,50),[e]);if(r)return n.jsx(oe,{children:r});const i=(s==null?void 0:s.conversations)??[];return n.jsx(st,{flush:!0,children:s?i.length===0?n.jsx(Pt,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):n.jsx(Ht,{children:i.map(a=>n.jsx(Vt,{href:Ke(e,a.id),onClick:()=>t(Ke(e,a.id)),title:Ps(a.preview||a.opening||"Untitled conversation",90),sub:`${a.messageCount} message${a.messageCount===1?"":"s"}`,side:De(a.lastMessageAt??a.startedAt??a.createdAt??null)},a.id))}):n.jsx(oe,{children:"Loading…"})})}const iw=3,GU=40;function YU({agent:e,navigate:t}){var j;const s=h.useRef(null),[r,i]=h.useState(!1),[a,l]=h.useState(null),[o,c]=h.useState(null),u=se(()=>Oe.conversations(e.id,iw),[e.id],3e4),f=Aa(gx),d=Aa("(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 Oe.startConversation(e.id),x=await Oe.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 ae?g.message:String(g)),c({text:w,at:Date.now()}),i(!1)}})()},p=(((j=u.data)==null?void 0:j.conversations)??[]).slice(0,iw);return n.jsxs("div",{className:"home-ask",children:[a?n.jsx(te,{message:a}):null,n.jsx(ox,{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=E$(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:Ps(g,GU)}),x?n.jsx("span",{className:"home-continue-when",children:x}):null]})},w.id)})})]}):null]})}const sC="buddi.keepClose";let Tl=null;const sp=new Set;function aw(){for(const e of sp)e()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),Tl=e,aw()}),window.addEventListener("appinstalled",()=>{Tl=null,rC(),aw()}));function lw(){try{return window.localStorage.getItem(sC)!==null}catch{return!1}}function rC(){try{window.localStorage.setItem(sC,"dismissed")}catch{}}function qU(){var e;try{return((e=window.matchMedia)==null?void 0:e.call(window,"(display-mode: standalone)").matches)??!1}catch{return!1}}function QU(e=window.location.hostname){const t=e.replace(/^\[|\]$/g,"").toLowerCase();return t==="127.0.0.1"||t==="::1"||t==="localhost"}function JU(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 XU(e){return/Mac|iPhone|iPad/.test(e)}function ZU(){const[e,t]=h.useState(()=>lw()||qU()),[s,r]=h.useState(Tl),[i,a]=h.useState(void 0);if(h.useEffect(()=>{const d=()=>{r(Tl),lw()&&t(!0)};return sp.add(d),()=>{sp.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=QU(),c=s?null:JU(l),u=()=>{rC(),t(!0)},f=()=>{const d=s;d&&d.prompt().then(async()=>{const m=await d.userChoice;Tl=null,r(null),(m==null?void 0:m.outcome)==="accepted"&&u()},()=>{})};return n.jsxs(W,{tone:"accent",title:"Keep buddi one click away.",children:[n.jsxs("p",{children:[c?`${c} `:null,"Or bookmark it with ",XU(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 eB(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 tB({navigate:e,preview:t,hidden:s}){var c;const r=se(()=>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(W,{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(Ms,{}),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 rp="buddi.tipsOpen";function nB(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 sB(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 ${nB(e.shownAt)}`:"Shown"}}function rB(){try{return window.localStorage.getItem(rp)==="1"}catch{return!1}}function iB(){const e=se(()=>A.tips(),[]),[t,s]=h.useState(rB),r=h.useCallback(i=>{s(i);try{i?window.localStorage.setItem(rp,"1"):window.localStorage.removeItem(rp)}catch{}},[]);return{open:t,setOpen:r,list:e}}function aB({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 lB({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 ae?x.message:String(x)),j=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(Y,{title:"Tips",children:[n.jsx(te,{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(Dn,{tone:x.status==="today"?"accent":void 0,children:[n.jsx("div",{children:n.jsx(xe,{tone:x.status==="today"?"accent":"muted",children:sB(x)})}),n.jsx("p",{className:"tips-card-text",children:x.text}),n.jsxs(Q,{children:[n.jsx(Ms,{}),x.status==="dismissed"?n.jsx(I,{size:"sm",disabled:o===x.id,onClick:()=>j(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(Ms,{}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Close"})]})]})})}const oB=3;function cB(e,t=new Set){return(e??[]).filter(s=>!s.hidden&&!t.has(s.id)).slice(0,oB)}function uB({glances:e,navigate:t,onChanged:s}){const[r,i]=h.useState(new Set),a=cB(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?ON(o.link.plugin,o.link.page,o.link.place):null,u=n.jsxs(n.Fragment,{children:[n.jsx(Se,{name:Ed(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 iC="buddi.needsYouView";function dB(){try{return window.localStorage.getItem(iC)==="list"?"list":"deck"}catch{return"deck"}}function hB(e){try{window.localStorage.setItem(iC,e)}catch{}}function fB(e,t,s){const r=(t.alsoFrom??[]).filter(i=>i!==t.agentId).map(s);return r.length===0?e:`${e} · also ${r.join(", ")}`}function mB({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()))},j=n.jsxs("span",{className:"home-deck-from",children:[c.agentId?n.jsx(xn,{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(Dn,{as:"article",title:j,meta:n.jsx("span",{className:"ui-card-meta",children:c.state==="held"?"today":De(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 pB({timezone:e,navigate:t,agents:s,defaultAgentId:r,attention:i,update:a,connectionSignals:l=[],hash:o=""}){var Te,Ze,Ie,it,fe,ve,Le,Me,ot,ke,_e,Ce,pt;const c=se(()=>A.overview(),[],15e3),u=se(()=>A.approvals(),[],1e4),f=se(()=>A.missions(),[],6e4),d=se(()=>A.reminders(),[],6e4),m=se(()=>A.conversations(),[],3e4),p=se(()=>A.offers(),[],3e4),j=se(()=>A.proposals(),[],6e4),w=se(()=>A.agentOffers(),[],6e4),k=se(()=>A.owner(),[]),g=se(()=>A.notifications(20),[],3e4),x=h.useMemo(()=>ZS(s,r??null),[s,r]),{busy:y,note:v,failure:N,decide:b}=cx(()=>{u.reload(),c.reload()}),S=c.data,C=s.find(D=>D.id===r)??null,R=D=>{var ge;return((ge=s.find(Je=>Je.id===D))==null?void 0:ge.name)??D},E=D=>ge=>{ge.preventDefault(),t(D)},P=((Te=u.data)==null?void 0:Te.pending)??[],L=((Ze=S==null?void 0:S.jobs)==null?void 0:Ze.failed)??0,$=((Ie=S==null?void 0:S.sentinels)==null?void 0:Ie.openUrgent)??0,T=((it=j.data)==null?void 0:it.open.length)??0,M=(((fe=w.data)==null?void 0:fe.offers)??[]).filter(D=>!P.some(ge=>i1(ge,D.plugin,D.agent))),U=vB(((ve=g.data)==null?void 0:ve.notifications)??[],P),[K,_]=h.useState(new Set),[q,B]=h.useState(dB),H=U.filter(D=>!K.has(D.id)),ue=D=>{_(ge=>new Set(ge).add(D.id)),A.notificationSeen(D.id).catch(()=>{})},re=D=>{ue(D),D.link&&t(D.link)},ie=D=>fB(D.agentId?R(D.agentId):D.pluginId??xB[D.kind],D,R),Ne=P.length+(L>0?1:0)+($>0?1:0)+(S!=null&&S.paused?1:0)+(T>0?1:0)+M.length+U.length,Z=h.useMemo(()=>{var D,ge;return bB(((D=f.data)==null?void 0:D.missions)??[],((ge=d.data)==null?void 0:ge.reminders)??[])},[f.data,d.data]),ce=(((Le=m.data)==null?void 0:Le.conversations)??[]).slice(0,5),de=((Me=p.data)==null?void 0:Me.offers)??[],Ae=de.slice(0,jB),ne=iB(),be=de.length-Ae.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:NB(S==null?void 0:S.now,e)}),n.jsx(uB,{glances:S==null?void 0:S.glances,navigate:t,onChanged:()=>c.reload()})]}),n.jsx("h1",{className:"home-greeting",children:SB(S==null?void 0:S.now,e,((ot=k.data)==null?void 0:ot.preferredName)||((ke=k.data)==null?void 0:ke.displayName))}),n.jsx("p",{className:"home-lede",children:EB(Ne,P.length,L,$,(S==null?void 0:S.paused)??!1,T,M.length,U.length)})]}),n.jsxs("div",{className:"home-hero-side",children:[n.jsx(aB,{tips:ne}),n.jsx(oN,{size:"lg",anim:"idle"})]})]})}),n.jsxs("div",{className:"home",children:[n.jsx(lB,{tips:ne,navigate:t}),C?n.jsx(YU,{agent:C,navigate:t},C.id):null,n.jsx(ZU,{}),n.jsx(tB,{navigate:t,preview:eB(o),hidden:ne.open}),a&&a.updateAvailable&&!a.checkout&&a.latest?n.jsx(W,{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(D=>n.jsx(W,{tone:"accent",children:n.jsxs("p",{children:[D.sentence," ",n.jsx("a",{href:tt("connections"),onClick:E(tt("connections")),children:"Settings → Connections."})]})},D.id)),n.jsx(te,{message:c.error??u.error??N}),v?n.jsx(W,{tone:"good",role:"status",children:v}):null,Ne>0?n.jsx(Y,{title:"Needs you",actions:U.length>0?n.jsx(Ar,{label:"Show what needs you as",options:[{value:"list",label:"List"},{value:"deck",label:"Deck"}],value:q,onChange:D=>{B(D),hB(D)}}):void 0,children:n.jsxs(V,{children:[S!=null&&S.paused?n.jsxs(W,{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(D=>n.jsx(ux,{action:D,timezone:e,busy:y===D.id,onDecide:b,agentName:R(D.agentId)},D.id)),U.length>0&&q==="deck"?n.jsx(mB,{rows:H,agents:s,label:ie,onOpen:re,onDone:ue}):null,U.length>0&&q==="list"?n.jsx(st,{flush:!0,children:n.jsx(Ht,{children:H.map(D=>n.jsx(Vt,{href:D.link??void 0,onClick:()=>re(D),lead:D.agentId?n.jsx(xn,{agents:s,id:D.agentId,size:"sm"}):void 0,title:D.title,sub:ie(D),side:D.state==="held"?"today":De(D.createdAt)},D.id))})}):null,L>0?n.jsx(W,{tone:"critical",children:n.jsxs("a",{href:`${jt}/jobs?state=failed`,onClick:E(`${jt}/jobs?state=failed`),children:[L," failed job",L===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,$>0?n.jsx(W,{tone:"critical",children:n.jsxs("a",{href:`${jt}/alerts`,onClick:E(`${jt}/alerts`),children:[$," urgent alert",$===1?"":"s"," from your watchers."]})}):null,M.map(D=>n.jsx(st,{children:n.jsx(hx,{plugin:D.plugin,agent:D.agent,text:D.text,label:`Create @${D.handle}`,handle:D.handle,onDismiss:()=>{A.dismissAgentOffer(D.plugin,D.agent).then(()=>w.reload())}})},`${D.plugin}/${D.agent}`)),T>0?n.jsx(W,{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(D=>n.jsxs(W,{tone:"warning",children:["Watcher ",D.sentinelId," failed: ",D.error]},D.sentinelId)),((S==null?void 0:S.mail)??[]).filter(D=>D.lastError).map(D=>n.jsxs(W,{tone:"warning",children:["Source ",D.sourceId,": ",D.lastError]},D.sourceId))]})}):null,n.jsx(Y,{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(D=>{const ge=yd(i.get(D.id));return n.jsxs("a",{className:"home-face",...ko(bo(D)),href:Ke(D.id),onClick:E(Ke(D.id)),"data-waiting":ge?"true":void 0,"data-unavailable":D.available?void 0:"true",children:[n.jsx(ms,{id:D.id,name:D.name,size:"lg",unavailable:!D.available,face:D}),n.jsxs("span",{className:"home-face-text",children:[n.jsx("span",{className:"home-face-name",children:D.name}),n.jsx("span",{className:"home-face-status",children:ge?aC(ge):D.available?Ps(D.description,60):D.unavailableReason??"Cannot run right now."})]})]},D.id)})})}),G1(s,r)?n.jsx(tp,{navigate:t}):null,Ae.length>0?n.jsx(Y,{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(V1,{ids:de.map(D=>D.id),onDone:()=>p.reload()})]}),children:n.jsx("div",{className:"home-offers",children:Ae.map(D=>n.jsx(wB,{offer:D,agents:s,open:E(dt(D.agentId,"offers")),onDismissed:()=>p.reload()},D.id))})}):null,(pt=(Ce=j.data)==null?void 0:Ce.digest)!=null&&pt.latest?n.jsx(CB,{digest:j.data.digest.latest,go:E}):null,n.jsxs("div",{className:"home-columns",children:[n.jsx(Y,{title:"Coming up",aside:n.jsx("a",{href:`${ut}?tab=missions`,onClick:E(`${ut}?tab=missions`),children:"All missions"}),children:n.jsx(st,{flush:!0,children:Z.length===0?n.jsx(oe,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):n.jsx(Ht,{children:Z.map(D=>n.jsx(Vt,{href:D.route,onClick:()=>t(D.route),lead:n.jsx(xn,{agents:s,id:D.agentId,size:"sm"}),title:D.title,sub:`${D.kind} for ${R(D.agentId)}`,side:De(D.at)},D.key))})})}),n.jsx(Y,{title:"Lately",aside:n.jsx("a",{href:jt,onClick:E(jt),children:"All activity"}),children:n.jsx(st,{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(Ht,{children:ce.map(D=>n.jsx(Vt,{href:Ke(D.agentId,D.id),onClick:()=>t(Ke(D.agentId,D.id)),lead:n.jsx(xn,{agents:s,id:D.agentId,size:"sm"}),title:D.opening?Ps(D.opening,80):"Untitled conversation",sub:`${R(D.agentId)}, ${D.messageCount} message${D.messageCount===1?"":"s"}`,side:De(D.lastMessageAt??D.createdAt)},D.id))})})})]}),((S==null?void 0:S.home)??[]).map(D=>n.jsx(AB,{block:D},D.id)),S!=null&&S.jobs&&S.missions?n.jsxs("p",{className:"home-foot muted",children:[Tt(S.jobs.pending??0)," queued, ",Tt(S.jobs.leased??0)," running, ",Tt(S.missions.enabled)," of ",Tt(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:Ea("").replace(/\/conversations\/$/,""),onClick:E(jt),children:"Activity"})," · ",n.jsx("a",{href:tt("system"),onClick:E(tt("system")),children:"System"})]}):null]})]})}const gB=new Set(["watcher","reminder","failure","recap","plugin"]),xB={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin"};function vB(e,t){const s=new Set(t.map(r=>r.id));return e.filter(r=>gB.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&s.has(r.actionId)))}const jB=6,yB=500;function wB({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()},yB)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[n.jsx(xn,{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 bB(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 kB(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 SB(e,t,s){const r=kB(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 NB(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 jc(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 CB({digest:e,go:t}){const s=[jc(e.memory,"memory note","memory notes"),jc(e.skills,"skill kept","skills kept"),jc(e.rules,"rule kept","rules kept"),jc(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(Y,{title:"What buddi learned this week",aside:n.jsx("span",{className:"muted",children:De(e.at)}),children:n.jsx(st,{children:n.jsxs(V,{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 EB(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`${aC(u)}.`}function aC(e){return e.charAt(0).toUpperCase()+e.slice(1)}function AB({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(Y,{title:e.title,aside:i,children:[e.note?n.jsx(W,{tone:"warning",children:e.note}):null,e.stats.length>0?n.jsx(Sd,{children:e.stats.map(a=>n.jsx(Cs,{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(st,{flush:!0,children:n.jsx(Ht,{children:e.rows.map((a,l)=>n.jsx(Vt,{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 TB=3e4;function lC(){const{data:e,reload:t}=se(()=>A.recovery(),[],TB);return{data:e,reload:t}}const RB="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function IB({active:e,onNavigate:t}){return e?n.jsxs("div",{className:"recovery-banner",role:"status",children:[n.jsx("span",{children:RB}),n.jsx("a",{href:qj,onClick:s=>{s.preventDefault(),t(qj)},children:"Finish the checklist"})]}):null}function PB({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),[j,w]=h.useState(!1),k=r.filter(v=>!v.installed),g=i.jobs+i.missions+i.approvals+i.telegramChats,x=v=>{u(N=>N.includes(v)?N.filter(b=>b!==v):[...N,v])},y=()=>{d(!0),p(null),A.leaveRecovery({dropPending:l,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(v=>p(v instanceof ae?v.message:String(v))).finally(()=>d(!1))};return n.jsx(st,{title:"Back from a backup",children:n.jsxs(V,{divided:!0,children:[n.jsxs(Y,{children:[n.jsx(Wt,{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(Y,{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(v=>n.jsxs("li",{children:[v.settingsRoute?n.jsx("a",{href:v.settingsRoute,children:v.name}):v.name," ",n.jsx("span",{className:"ui-card-meta",children:v.kind})]},`${v.kind}:${v.name}`))})}),n.jsx(Y,{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(v=>n.jsxs("li",{children:[n.jsx("span",{className:"mono",children:v.name})," ",v.version," ",n.jsx("span",{className:"ui-card-meta",children:v.source})]},v.name))})}),n.jsx(Y,{title:"Work that was waiting",children:g===0?n.jsx(oe,{children:"Nothing was in flight when the backup was taken."}):n.jsxs(V,{gap:"sm",children:[n.jsx(Wt,{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:v=>o(v.target.checked)}),n.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),n.jsx(Y,{title:"Standing permissions",children:a.length===0?n.jsx(oe,{children:"No agent had a standing permission."}):n.jsxs(V,{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(v=>n.jsx("li",{children:n.jsxs("label",{className:"recovery-check",children:[n.jsx("input",{type:"checkbox",checked:c.includes(v.id),onChange:()=>x(v.id),"aria-label":`Keep ${v.tool} for ${v.agent}`}),n.jsxs("span",{children:[n.jsx("span",{className:"mono",children:v.tool})," for ",v.agent," ",n.jsx("span",{className:"ui-card-meta",children:v.scope}),v.description?n.jsxs("span",{className:"ui-card-meta",children:[" — ",v.description]}):null]})]})},v.id))})]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{message:m}),j?n.jsx(W,{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||j,onClick:y,children:"Leave recovery mode"})})]})})]})})}const MB=2e3,$B={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 ow(e){return $B[e.phase]??e.detail??e.phase}const DB=new Set(["done","failed","rolled-back"]);function oC(e){return e!==void 0&&(DB.has(e.phase)||!!e.finishedAt)}function _B(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),oC(d)&&(c=!0)}}).catch(d=>{if(!c){if(d instanceof ae&&d.status!==0&&d.status<500){l(d.message);return}o.current=!0,i(!0)}})};u();const f=window.setInterval(u,MB);return()=>{c=!0,window.clearInterval(f)}},[e]),{job:t,away:r,error:a}}function OB({job:e,away:t,error:s}){return s?n.jsx(te,{message:s}):t?n.jsx(W,{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(W,{tone:"critical",role:"alert",children:[ow(e)," ",e.error??""]}):n.jsxs(W,{tone:e.phase==="done"?"good":void 0,role:"status",children:[ow(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function LB(){var k,g,x,y,v,N,b;const e=se(()=>A.backups(),[],3e4),t=lC(),s=se(()=>A.service(),[]),[r,i]=h.useState(null),a=_B(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,j=((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 ae&&C.status===409?d(C.message):o(C instanceof ae?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return h.useEffect(()=>{oC(a.job)&&e.reload()},[(y=a.job)==null?void 0:y.phase]),n.jsxs(V,{gap:"lg",children:[(v=t.data)!=null&&v.active?n.jsx(PB,{view:t.data,onLeft:t.reload}):null,n.jsx(te,{message:e.error??l}),n.jsx(OB,{...a}),n.jsx(UB,{onSaved:()=>e.reload()}),n.jsx(Y,{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(V,{divided:!0,children:[n.jsx(Y,{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(Y,{children:e.data&&j.length===0?n.jsx(Pt,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?n.jsxs(Sn,{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:j.map(S=>{var C;return n.jsx(BB,{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(zB,{}),n.jsx(WB,{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 FB={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function UB({onSaved:e}){var p;const t=se(()=>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={...FB,...s??t.data??{}};if(((p=t.data)==null?void 0:p.supervised)===!1)return n.jsx(Y,{title:"Every night",panel:!0,children:n.jsx(Y,{children:n.jsx(W,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const d=j=>{u(!1),r({...f,...j})},m=()=>{a(!0),o(null),A.setBackupSchedule(f).then(j=>{r(j),u(!0),e()}).catch(j=>o(j instanceof ae?j.message:String(j))).finally(()=>a(!1))};return n.jsx(Y,{title:"Every night",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:i,onClick:m,children:"Save"}),children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{message:l}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:f.enabled,onChange:j=>d({enabled:j.target.checked})}),n.jsx("span",{children:"Back this buddi up on its own"})]}),n.jsxs(nr,{children:[n.jsx(X,{label:"At",children:n.jsx("input",{type:"time",value:f.time,onChange:j=>d({time:j.target.value})})}),n.jsx(X,{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:j=>d({keep:Number(j.target.value)||1})})})]}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:f.encryptLocal,onChange:j=>d({encryptLocal:j.target.checked})}),n.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(X,{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:j=>d({copyTo:j.target.value===""?null:j.target.value})})}),c?n.jsxs(W,{tone:"good",role:"status",children:["Saved.",f.lastRunAt?` Last run ${De(f.lastRunAt)}.`:""]}):null]})})]})})}function BB({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:De(e.createdAt)}),n.jsx("td",{children:Nn(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(W,{tone:"warning",children:cC}):n.jsx(uC,{what:`${e.name}, taken ${De(e.createdAt)}, ${Nn(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 cC="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function uC({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(V,{gap:"sm",children:[n.jsxs(W,{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(X,{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(X,{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 zB(){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 ae?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 ae?m.message:String(m))).finally(()=>a(!1))};return n.jsx(Y,{title:"The passphrase",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{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(W,{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(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(X,{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 WB({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(Y,{title:"Restore from a file",panel:!0,children:n.jsx(Y,{children:n.jsx(W,{tone:"warning",children:s??cC})})}):n.jsx(Y,{title:"Restore from a file",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),n.jsxs(nr,{children:[n.jsx(X,{label:"The backup file",children:n.jsx("input",{type:"file",onChange:p=>{var j;m(!1),l(((j=p.target.files)==null?void 0:j[0])??null)}})}),n.jsx(X,{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(Y,{children:n.jsx(uC,{what:`${a.name}, ${Nn(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 dC="gemini-2.5-pro";function Td(e){return e.replace(/^models\//,"")}const Sx=/(image|tts|audio|live|embedding|vision|robotics|transcribe)/;function hC(e){const t=e.map(Td);let s;for(const r of t){const i=/^gemini-(\d+(?:\.\d+)*)-pro(?:-(.+))?$/.exec(r);if(!i||Sx.test(i[2]??""))continue;const a=i[1].split(".").map(Number),l=(i[2]??"")!=="";(!s||_u(a,s.version)>0||_u(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 fC(e){let t;for(const s of e.map(Td)){const r=/^gemini-(\d+(?:\.\d+)*)-flash(?:-(.+))?$/.exec(s);if(!r||/lite/.test(r[2]??"")||Sx.test(r[2]??""))continue;const i=r[1].split(".").map(Number),a=(r[2]??"")!=="";(!t||_u(i,t.version)>0||_u(i,t.version)===0&&t.preview&&!a)&&(t={id:s,version:i,preview:a})}return t==null?void 0:t.id}function mC(e){return/^gemini-[\d.]+-pro(?:-|$)/.test(Td(e))}function HB(e){return[...new Set(e.map(Td).filter(t=>t.startsWith("gemini-")&&!Sx.test(t)))]}function pC(e){return e.httpStatus===429||e.state==="rate-limited"||e.state==="quota-exhausted"}function _u(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 VB(e,t){if(!t||e.kind!=="openai-compatible")return!1;const s=r=>r.replace(/\/+$/,"");return s(e.baseUrl)===s(t)}function gC({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(X,{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 KB({embedded:e}={}){const{data:t,error:s,reload:r,loading:i}=se(()=>A.providerAccounts(),[]),[a,l]=h.useState(!1),[o,c]=h.useState(null),[u,f]=h.useState(""),[d,m]=h.useState(!1),[p,j]=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(""),j(!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)??[],v=y.find(N=>N.id===w)??y[0];return n.jsxs(hn,{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(te,{message:s??o}),u&&n.jsx(W,{tone:"good",role:"status",children:u}),p&&n.jsx(W,{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(W,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),d&&n.jsx(tn,{title:"Add an account",onClose:()=>m(!1),children:n.jsx("div",{id:"new-provider-account",children:n.jsx(ZB,{accounts:y,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,gemini:t.gemini,busy:a,run:x,onDone:N=>{m(!1),N&&k(N)}})})}),n.jsx(Y,{title:"Accounts",aside:`Secrets live in the ${GB(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(""),j(!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(Pt,{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":(v==null?void 0:v.id)===N.id,onClick:()=>k(N.id),children:[n.jsx(YB,{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:[Nx(N)," · ",N.assignedAgents.length===0?"no agents":`${N.assignedAgents.length} agent${N.assignedAgents.length===1?"":"s"}`]})]}),n.jsx(vC,{account:N})]},N.id))}),v?n.jsx(QB,{account:v,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:a,run:x},`${v.id}:${v.revision}`):null]})})]})]})}function GB(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function Nx(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 xC(e){return e.detectedContextWindowSource!=="provider"?"assumed":e.kind==="codex"?"from ChatGPT":"from the provider"}function YB({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 qB(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function vC({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 Cx(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 QB({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(vC,{account:e})]}),n.jsx(Wt,{items:[{label:"Provider",value:Nx(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?"":` (${xC(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(W,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&n.jsxs(W,{tone:"warning",children:["Token refresh did not finish. Reconnect this ",e.kind==="codex"?"ChatGPT":"Claude"," account."]}),e.auth==="anthropic-oauth"&&n.jsx(wC,{account:e,enabled:!!r,busy:t,run:s}),e.kind==="codex"&&n.jsx(jC,{account:e,busy:t,run:s}),e.auth==="device-key"&&n.jsx(yC,{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({...Cx(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(W,{role:"status",tone:qB(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(tn,{title:`Edit ${e.label}`,onClose:()=>a(!1),children:n.jsx(JB,{account:e,busy:t,run:s,onDone:()=>a(!1)})}),l&&n.jsxs(W,{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(Mt,{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 jC({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(W,{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(gC,{code:e.login.userCode}),e.login.verificationUrl&&n.jsx(Q,{children:n.jsx(Gt,{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 JB({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)??""),[j,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):""),v=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()||!j.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:j,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(X,{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(X,{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"?(v("anthropic"),d("anthropic-oauth")):v(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(X,{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(X,{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(kx,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:j,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),n.jsx(X,{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} (${xC(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(X,{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 yC({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(W,{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 wC({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(W,{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(X,{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 qh={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5.5"};function Qh(e,t,s){return bC(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 bC(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 XB="That key was refused. Check it and paste it again.";function ZB({accounts:e,busy:t,run:s,onDone:r,codexEnabled:i,anthropicOAuthEnabled:a,gemini:l}){const o=e.map(ne=>ne.label),[c,u]=h.useState(null),[f,d]=h.useState("anthropic"),[m,p]=h.useState("api-key"),[j,w]=h.useState(()=>Qh("anthropic","api-key",o)),[k,g]=h.useState(!1),[x,y]=h.useState(""),[v,N]=h.useState(""),[b,S]=h.useState(null),[C,R]=h.useState(!1),[E,P]=h.useState(""),[L,$]=h.useState(""),[T,M]=h.useState(!1),[U,K]=h.useState(!1),[_,q]=h.useState(!1),B=(ne,be,Te=!1)=>{d(ne),p(be),N(""),S(null),P(""),$(""),M(!1),K(Te),q(!1),y(Te?"":ne==="openai-compatible"?"http://localhost:11434/v1":""),k||w(Te?Qh(ne,"device-key",o):Qh(ne,be,o))},H=ne=>{B("openai-compatible",ne?"api-key":"device-key",!0),ne&&A.ollama().then(be=>y(be.cloudBaseUrl)).catch(()=>{})},ue=()=>{l&&(B("openai-compatible","api-key"),q(!0),y(l.baseUrl),k||w(bC("Gemini",o)))},re=c?e.find(ne=>ne.id===c):void 0;if(c)return re?n.jsx(ez,{account:re,busy:t,run:s,anthropicOAuthEnabled:a,onDone:()=>r(re.id)}):n.jsx(oe,{children:"Saving…"});const ie=f==="openai-compatible"&&m!=="device-key",Ne=f==="codex"||m==="anthropic-oauth"||m==="device-key",Z=!Ne&&(m==="none"||v.trim()!=="")&&(!ie||x.trim()!==""),ce=async()=>{var ne,be;R(!0),P("");try{const Te=await A.probeModels({kind:f,auth:m,...ie?{baseUrl:x}:{},...v.trim()?{secret:v}:{}});S(Te),L||$(((ne=Te.models.find(Ze=>Ze.isDefault))==null?void 0:ne.id)??((be=Te.models[0])==null?void 0:be.id)??"")}catch(Te){P(Te instanceof Error?Te.message:"Could not load models. You can still enter a custom model.")}finally{R(!1)}},de=L.trim(),Ae=!j.trim()||ie&&!x.trim()||ie&&!_&&!de||_&&!v.trim();return n.jsxs("form",{className:"ui-stack",onSubmit:ne=>{ne.preventDefault();const be=v;N("");let Te=de||(m==="device-key"?Uc:qh[f])||"claude-sonnet-5",Ze;(async()=>{if(_){Te=dC;try{const Le=(await A.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:x,secret:be})).models.map(Me=>Me.id);Te=hC(Le)??Te,Ze=mC(Te)?fC(Le):void 0}catch{}}let Ie,it=!1;!await s(async()=>{if(Ie=await A.saveProviderAccount({label:j,kind:f,auth:m,baseUrl:x,defaultModel:Te,enabled:!0,...be.trim()?{secret:be}:{}}),m!=="api-key")return Ie;const ve=await A.testProviderAccount(Ie.id);if(ve.state==="connected")return Ie;if(kg(ve)){const Le=Ie.id;Ie=void 0;try{const Me=(await A.providerAccounts()).accounts.find(ot=>ot.id===Le);Me&&await A.removeProviderAccount(Le,Me.revision)}catch{}throw new Error(XB)}if(_&&Ze&&pC(ve)){const Le=(await A.providerAccounts()).accounts.find(Me=>Me.id===Ie.id);if(Le&&(await A.saveProviderAccount({...Cx(Le),defaultModel:Ze}),(await A.testProviderAccount(Ie.id)).state==="connected"))return{...Ie,warning:`Account saved. Google's free tier has no Pro allowance, so it starts on ${Ze}; turn on billing at Google to use Pro.`}}return it=!0,{...Ie,warning:`Account saved. ${ve.message}`}},"Account saved.")||!Ie||(_||it?u(Ie.id):de||!Ne?r(Ie.id):u(Ie.id))})()},children:[n.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[n.jsx(X,{label:"Provider",children:n.jsxs("select",{value:m==="anthropic-oauth"?"anthropic-oauth":U?"ollama-cloud":_?"gemini":f,onChange:ne=>{if(ne.target.value==="anthropic-oauth")B("anthropic","anthropic-oauth");else if(ne.target.value==="gemini")ue();else if(ne.target.value==="ollama-cloud")B("openai-compatible","device-key",!0);else{const be=ne.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(X,{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:j,onChange:ne=>{w(ne.target.value),g(!0)},placeholder:"Anthropic — Personal"})}),U&&n.jsxs("label",{className:"ui-row",children:[n.jsx("input",{type:"checkbox",checked:m==="api-key",onChange:ne=>H(ne.target.checked)}),n.jsx("span",{children:"Use a key instead"})]}),ie&&n.jsxs(n.Fragment,{children:[n.jsx(X,{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:ne=>{y(ne.target.value),S(null)}})}),!_&&n.jsx(X,{label:"Authentication",children:n.jsxs("select",{value:m,onChange:ne=>{p(ne.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(X,{label:"API key",hint:"Stored in the vault, never shown again.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:v,onChange:ne=>{N(ne.target.value),S(null)}})}),_&&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."]}):Ne?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__":L,onChange:ne=>{ne.target.value==="__custom__"?(M(!0),$("")):(M(!1),$(ne.target.value))},children:[b.models.map(ne=>n.jsxs("option",{value:ne.id,children:[ne.name===ne.id?ne.id:`${ne.name} — ${ne.id}`,ne.isDefault?" (provider default)":"",ne.thinks?" · thinks":""]},ne.id)),n.jsx("option",{value:"__custom__",children:"Custom model…"})]}),n.jsx(I,{size:"sm",disabled:C||!Z,onClick:()=>void ce(),children:C?"Loading…":"Reload"})]}):n.jsxs("div",{className:"ui-row",children:[n.jsx(I,{disabled:C||!Z,onClick:()=>void ce(),children:C?"Loading models…":"Load models"}),ie?n.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):n.jsxs("span",{className:"muted",children:["Optional now: ",qh[f]," is used until you pick one."]})]}),T||ie&&!b?n.jsx("input",{"aria-label":"Custom model",required:ie,maxLength:150,value:L,onChange:ne=>$(ne.target.value),placeholder:ie?"qwen3:8b":qh[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:Ae,children:"Save account"})]})]}),Ae&&n.jsxs("p",{className:"muted",children:["Enter an account name",_?" and a key":ie?", an endpoint and a model":""," to enable Save account."]})]})}function ez({account:e,busy:t,run:s,anthropicOAuthEnabled:r,onDone:i}){const[a,l]=h.useState(e.defaultModel),o=e.configured;return n.jsxs(V,{gap:"lg",children:[n.jsxs(W,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!o?n.jsx(wC,{account:e,enabled:!!r,busy:t,run:s}):null,e.kind==="codex"&&!o?n.jsx(jC,{account:e,busy:t,run:s}):null,e.auth==="device-key"&&!o?n.jsx(yC,{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(kx,{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({...Cx(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 cw=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 tz(e){const t=e.toLowerCase().replace(/\.$/,"");if(!t.includes(".")||cw.has(t))return!0;const s=t.slice(t.indexOf(".")+1);return cw.has(`*.${s}`)}function nz(e){return typeof e=="string"&&e.includes("*")}function sz(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"}:tz(a)?{ok:!1,reason:"public-suffix"}:{ok:!0,value:{pattern:`${i.protocol}//*.${i.host}`,protocol:i.protocol,suffix:a,port:i.port}}}const uw=["every-time","first-time","pre-approved"],kC={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function rz(e){const t=uw.indexOf(e);return uw.slice(0,t<0?1:t+1)}function SC(e){return e.endsWith(".account")}const iz="This account’s process holds the value for as long as its connection lives.",Ex="Stored, not usable until it has a binding.";function az(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":SC(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const NC={"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})}},lz="A wildcard may only stand for the leftmost part of a site, like *.wikimedia.org.",oz=e=>`That is a public suffix; ${e} would match every site.`,dw="Give the site as an origin, like https://en.wikipedia.org.";function hw(e){const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:["https:","//",e].join("");if(nz(e)){const s=sz(t);if(s.ok)return{ok:!0,target:s.value.pattern};if(s.reason==="placement")return{ok:!1,error:lz};if(s.reason==="public-suffix"){const r=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/[/?#:].*$/,"").toLowerCase();return{ok:!1,error:oz(r)}}return{ok:!1,error:dw}}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:dw}}}function cz(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 CC(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 hw(s);if(e==="browser.native.type"||SC(e))return{ok:!0,target:s};const r=NC[e];if(r===void 0)return{ok:!0,target:s};const i=cz(s);if(i===null)return{ok:!1,error:`${e} needs both: ${r.hint}.`};if(e==="browser.form.data"){const a=hw(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 uz(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=NC[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 EC="accounts.provider";function hz(e,t){for(const s of e)if(s.kind===EC&&typeof s.target=="string"){const r=t.get(s.target);if(r)return r}}function ip(e,t,s){if(e===EC&&typeof t=="string"){const r=s.get(t);if(r)return r.label}return dz(e,t)}function AC(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function TC(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 RC(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 fz(e){const t=TC(e,"found");return t.length?`The value already sits in ${RC(t)}.`:""}function mz(e){const t=TC(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${RC(t)}.`:""}async function wi(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 pz({embedded:e,timezone:t}={}){const s=se(()=>A.secrets(),[]),r=se(()=>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:Nx(u)}]))},[r.data]),[a,l]=h.useState(!1),o=s.data;return n.jsxs(hn,{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(V,{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(Y,{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(V,{divided:!0,children:o.secrets.length===0?n.jsx(Pt,{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(gz,{secret:c,accounts:i,destinations:o.destinations,timezone:t,onChanged:s.reload},c.name))})}):null,o?n.jsx(Y,{title:"buddi’s own keys",aside:"Read-only.",children:n.jsxs(V,{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(vz,{destinations:o.destinations,onClose:()=>l(!1),onChanged:s.reload}):null]})}function gz({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,j]=h.useState(!1),w=async()=>{await wi("secrets.delete",{name:e.name},l,c)!==null&&(m(!1),i())},k=e.lastUse,g=hz(e.bindings,t);return n.jsxs(V,{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(ci,{children:g.provider}):null,e.totp?n.jsx(ci,{children:"TOTP"}):null,k?n.jsx(xe,{tone:AC(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:Ex}):n.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((x,y)=>n.jsxs("div",{className:"ui-row",children:[n.jsx(ci,{children:x.kind}),n.jsx("span",{className:"mono",children:ip(x.kind,x.target,t)}),n.jsx(xe,{tone:"muted",children:kC[x.rule]??x.rule})]},y))}),e.bindings.some(x=>x.heldByPlugin)?n.jsx("p",{className:"ui-card-meta",children:iz}):null,n.jsx("p",{className:"ui-card-meta",children:k?`Last used ${De(k.at)}${k.agentId?` by ${k.agentId}`:""} — ${k.kind}, ${ip(k.kind,k.target,t)}.`:"Never used."}),n.jsx(te,{message:o}),d?n.jsxs(W,{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:()=>j(!p),children:"Use log"})]}),p?n.jsx(xz,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?n.jsx(jz,{secret:e,onClose:()=>f(null),onChanged:i}):null,u==="rename"?n.jsx(yz,{secret:e,onClose:()=>f(null),onChanged:i}):null,u==="rebind"?n.jsx(wz,{secret:e,destinations:s,onClose:()=>f(null),onChanged:i}):null]})}function xz({name:e,accounts:t,timezone:s}){const r=se(()=>A.secretUses(e,50),[e]);if(r.error)return n.jsx(te,{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,", ",ip(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:AC(a.outcome),children:a.outcome})})]},l))})}function IC({name:e,result:t,scrubbed:s,busy:r,failure:i,onScrub:a,onDone:l}){const o=fz(t);return n.jsxs(V,{gap:"sm",children:[n.jsxs(W,{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(te,{message:i}),o?n.jsx(Q,{children:n.jsx(I,{variant:"accent",disabled:r||s!==null,onClick:a,children:s===null?"Scrub the history":mz(s)||"Nothing of it was left to replace."})}):null,n.jsx(Q,{align:"end",children:n.jsx(I,{onClick:l,children:"Done"})})]})}function PC({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(V,{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(X,{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(X,{label:"Target",inline:!0,grow:!0,children:n.jsx("input",{type:"text",spellCheck:!1,disabled:s,value:a.target,placeholder:az(a.kind),onChange:u=>i(l,{target:u.target.value})})}),n.jsx(X,{label:"Rule",inline:!0,children:n.jsx("select",{value:a.rule,disabled:s,onChange:u=>i(l,{rule:u.target.value}),children:rz(c).map(u=>n.jsx("option",{value:u,children:kC[u]},u))})}),n.jsx(I,{size:"sm",variant:"ghost",disabled:s,onClick:()=>r(t.filter((u,f)=>f!==l)),children:"Remove"})]},l)})})}function vz({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,j]=h.useState(null),[w,k]=h.useState(null),[g,x]=h.useState(null),y=async()=>{const N=u.map(R=>CC(R.kind,R.target)),b=N.findIndex(R=>!R.ok);if(b!==-1){j(`Binding ${b+1}: ${N[b].error}`);return}const S=a;l("");const C=await wi("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,j);C!==null&&(k({name:r.trim(),result:C}),s())},v=async()=>{const N=await wi("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},m,j);N!==null&&(x(N),s())};return n.jsx(tn,{title:"Add a secret",onClose:t,children:w?n.jsx(IC,{name:w.name,result:w.result,scrubbed:g,busy:d,failure:p,onScrub:()=>void v(),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(X,{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(X,{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(PC,{destinations:e,bindings:u,disabled:d,onChange:f}),u.length===0?n.jsx("p",{className:"ui-field-hint",children:Ex}):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(W,{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 jz({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 wi("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())},j=async()=>{const w=await wi("secrets.scrub_history",{name:e.name},l,c);w!==null&&(m(w),s())};return n.jsx(tn,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?n.jsx(IC,{name:e.name,result:u,scrubbed:d,busy:a,failure:o,onScrub:()=>void j(),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(X,{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(W,{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 yz({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 wi("secrets.rename",{name:e.name,to:r.trim()},l,c)!==null&&(s(),t())};return n.jsx(tn,{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(X,{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(W,{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 wz({secret:e,destinations:t,onClose:s,onChanged:r}){const[i,a]=h.useState(()=>e.bindings.map(d=>({kind:d.kind,target:uz(d.target),rule:d.rule}))),[l,o]=h.useState(!1),[c,u]=h.useState(null),f=async()=>{const d=i.map(j=>CC(j.kind,j.target)),m=d.findIndex(j=>!j.ok);if(m!==-1){u(`Binding ${m+1}: ${d[m].error}`);return}await wi("secrets.rebind",{name:e.name,bindings:i.map((j,w)=>({kind:j.kind,target:d[w].target,rule:j.rule}))},o,u)!==null&&(r(),s())};return n.jsx(tn,{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(PC,{destinations:t,bindings:i,disabled:l,onChange:a}),i.length===0?n.jsx("p",{className:"ui-field-hint",children:Ex}):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(W,{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 bz={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"}},kz="It can delete or destroy something, so it asks you every time and is never remembered.";function Sz(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 MC="buddi-connections",Nz="/connections/callback",Cz="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 Ez({embedded:e,timezone:t}={}){const s=se(()=>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(hn,{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(V,{gap:"lg",children:[!a&&!s.error?n.jsx(oe,{children:"Reading your connections…"}):null,n.jsx(te,{message:s.error}),a&&!a.vault?n.jsx(W,{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(Y,{title:"Your connections",aside:"Each one's tools are named mcp.<connection>.<tool>.",panel:!0,children:n.jsx(V,{divided:!0,children:a.connections.length===0?n.jsx(Pt,{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(Az,{connection:o,agentName:l,timezone:t??Intl.DateTimeFormat().resolvedOptions().timeZone,onFlow:i,onChanged:s.reload},o.id))})}):null,a?n.jsx(Y,{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(Dn,{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(Dn,{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(Tz,{start:r,agents:a.agents,onClose:()=>{i(null),s.reload()}}):null]})}function Az({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=bz[e.state],m=async()=>{c(!0),f(null);try{await A.disconnect(e.id),l(!1),i()}catch(j){f(j instanceof Error?j.message:String(j))}finally{c(!1)}},p=e.state==="pending-review";return n.jsxs(V,{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(ci,{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 ${De(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(te,{message:u}),a?n.jsx(W,{tone:"critical",role:"alert",title:`Disconnect ${e.name}?`,children:n.jsxs(V,{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 Tz({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(tn,{title:d,onClose:s,size:"wide",children:[i==="address"?n.jsx(Rz,{card:e.card,onDone:(p,j)=>{o(p),j==="none"?a("review"):(u(j),a("consent"))}}):null,i==="consent"&&l?n.jsx(Iz,{connection:l,manual:c==="manual",pollMs:r,onSignedIn:p=>{o(p),e.keepGrants?s():a("review")}}):null,i==="review"&&l?n.jsx(Pz,{connection:l,onKept:p=>{o(p),e.keepGrants?s():a("grant")}}):null,i==="grant"&&l?n.jsx(Mz,{connection:l,agents:t,onDone:s}):null]})}function uo(e){return e instanceof Error?e.message:String(e)}function Rz({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(uo(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(X,{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(te,{message:l}),n.jsx(Q,{align:"end",children:n.jsx(I,{type:"submit",variant:"accent",disabled:i||s.trim()==="",children:i?"Opening…":"Continue"})})]})}function Iz({connection:e,manual:t,pollMs:s,onSignedIn:r}){const[i,a]=h.useState(t?Cz:null),[l,o]=h.useState(""),[c,u]=h.useState(!1),[f,d]=h.useState(null),[m,p]=h.useState(!1),[j,w]=h.useState(null),k=`${location.origin}${Nz}`,g=h.useRef(r);g.current=r,h.useEffect(()=>{if(!m)return;let y=!1;const v=async()=>{if(!y){y=!0;try{g.current(await A.connection(e.id))}catch(R){d(uo(R))}}},N=typeof BroadcastChannel=="function"?new BroadcastChannel(MC):null;N&&(N.onmessage=R=>{var E;((E=R.data)==null?void 0:E.id)===e.id&&v()});let b;const S=Date.now(),C=async()=>{if(!y){try{const R=await A.connection(e.id);if(!e.signedIn&&R.signedIn){v();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 v;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 ae&&((v=N.detail)==null?void 0:v.code)==="client-id"?a(N.message):d(uo(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(W,{tone:"warning",children:i}),n.jsx(X,{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(W,{tone:"accent",role:"status",children:["Waiting for you to say yes on ",e.name,"’s page…"]}):null,j?n.jsx("p",{children:n.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",children:["Open ",e.name,"’s sign-in page"]})}):null,n.jsx(te,{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 Pz({connection:e,onKept:t}){const s=se(()=>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(j){j instanceof ae&&((p=j.detail)==null?void 0:p.code)==="changed"&&s.reload(),c(uo(j))}finally{l(!1)}}};if(!u)return s.error?n.jsx(te,{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(W,{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(W,{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(X,{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 j=Sz(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:j.tone,children:j.label}),p.change==="added"?n.jsx(ci,{children:"New"}):p.change==="changed"?n.jsx(ci,{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?kz:"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(te,{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 Mz({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=se(()=>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),j=(g,x)=>{a(y=>{const v=new Set(y);return x?v.add(g):v.delete(g),v})},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(uo(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=>j(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(V,{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 v=new Set(y);return x.target.checked?v.add(g.tool):v.delete(g.tool),v})}),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(te,{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 $z({timezone:e,embedded:t}){const{data:s,error:r,reload:i}=se(()=>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,j)=>{l(p),c(null),A.setSentinelEnabled(p,j).catch(w=>c(w instanceof ae?w.message:String(w))).finally(()=>{l(null),i()})};return n.jsxs(hn,{embedded:t,title:"Watchers",children:[n.jsx(te,{message:r??o}),n.jsx(W,{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(W,{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(W,{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(Y,{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(Pt,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):n.jsx(Ht,{children:u.map(p=>{const j=s.runs.find(w=>w.sentinelId===p.id);return n.jsx(Vt,{lead:n.jsx(xe,{tone:p.enabled?j!=null&&j.lastError?"critical":j?"good":void 0:"muted",children:p.enabled?j!=null&&j.lastError?"failed":j?"ok":"never ran":"off"}),title:p.description,sub:`${p.id}, every ${Dz(p.every)}${j!=null&&j.lastError?`. ${j.lastError}`:""}`,side:n.jsxs(n.Fragment,{children:[n.jsx("span",{title:j?Ve(j.lastRunAt,e):void 0,children:j?De(j.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 Dz(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 _z({embedded:e}){const{data:t,error:s,reload:r}=se(()=>A.owner(),[]);return n.jsxs(hn,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[n.jsx(te,{message:s}),t?n.jsx(Oz,{initial:t,onSaved:r}):null]})}function Oz({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),[j,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 ae?y.message:String(y))}finally{d(!1)}},x=e.zones.length>0?e.zones:[e.detectedTimezone];return n.jsx(Y,{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(V,{divided:!0,gap:"lg",children:[n.jsx(Y,{title:"Name and place",children:n.jsxs(nr,{children:[n.jsx(X,{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(X,{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(X,{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(Y,{title:"About you",children:[n.jsx(X,{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)}})}),j?n.jsx(W,{tone:"critical",children:j}):null]})]})})}const Lz=2e6;function fw(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>Lz)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 Fz={skill:"skill",policy:"rule",change:"change to itself"};function Uz(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 ap(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function Bz(e,t){const s=e.change;if(!s||s.part!=="tools")return[];if(t===e.editable)return s.added;const r=new Set(ap(s.current??""));return ap(t).filter(i=>!r.has(i))}function mw(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function zz({embedded:e,plugin:t}){const{data:s,error:r,reload:i}=se(()=>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]:v,...N})=>N);try{c(await x()),i()}catch(v){const N=v instanceof Error?v.message:String(v);y?m(b=>({...b,[g]:N})):l(N)}finally{f(null)}},j=a1(),w=((s==null?void 0:s.open)??[]).filter(g=>mw(g,t)),k=((s==null?void 0:s.closed)??[]).filter(g=>mw(g,t));return n.jsxs(hn,{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(te,{message:r??a}),t?n.jsxs(W,{role:"status",children:["Showing the rules ",t," proposes. ",n.jsx("a",{href:tt("proposals"),children:"Show every proposal"})]}):null,o?n.jsx(W,{tone:"good",role:"status",children:o}):null,t?null:n.jsx(l1,{offers:j.offers,reload:j.reload}),!s||w.length===0?n.jsx(Y,{title:"Waiting",panel:!0,children:s?t?n.jsx(Pt,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):n.jsx(Pt,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):n.jsx(oe,{children:"Loading…"})}):n.jsx(Y,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(g=>n.jsx(Kz,{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(Y,{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(Ht,{children:k.map(g=>{var x;return n.jsx(Vt,{title:g.title,sub:`${g.agent}: ${Wz(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:De(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"})]}):De(g.decidedAt??g.createdAt)},g.id)})})}):null,!t&&(s!=null&&s.digest)?n.jsx(Vz,{schedule:s.digest.schedule,onSaved:i}):null]})}function Wz(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 Hz=Array.from({length:24},(e,t)=>t),pw=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Vz({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 ${pw[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(Y,{title:"Weekly digest",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:l||!f,onClick:()=>void d(),children:"Save"}),children:n.jsxs(V,{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: ${De(e.next)}.`:""]}),n.jsxs(Q,{children:[n.jsx(X,{label:"Day",children:n.jsx("select",{value:s,disabled:l,onChange:m=>r(Number(m.target.value)),children:pw.map((m,p)=>n.jsx("option",{value:p,children:m},m))})}),n.jsx(X,{label:`Hour (${e.timezone})`,children:n.jsx("select",{value:i,disabled:l,onChange:m=>a(Number(m.target.value)),children:Hz.map(m=>n.jsxs("option",{value:m,children:[String(m).padStart(2,"0"),":00"]},m))})})]}),c?n.jsx(W,{tone:c.tone,role:"status",children:c.text}):null]})})}function gw(e,t){return e==="tools"?ap(t).join(`
117
+ `):t}function Kz({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=Bz(e,a);return n.jsx(Dn,{tone:e.untrusted?"warning":"accent",title:e.title,meta:n.jsxs(n.Fragment,{children:[n.jsx(xe,{children:Fz[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:j=>c(j.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(V,{gap:"sm",children:[e.why?n.jsx("p",{children:e.why}):null,n.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",De(e.createdAt),e.conversationId?n.jsxs(n.Fragment,{children:[" in ",n.jsx("a",{href:Ea(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?n.jsxs(W,{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(j=>n.jsx("li",{className:"mono",children:j},j))}),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(j=>n.jsx("li",{children:n.jsx("mark",{className:"wb-diff-mark",children:j})},j))})]}):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(V,{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(Nu,{text:fw(e.skill.steps,a),marks:d,label:`Version ${e.skill.version} against this proposal`})]}):null,n.jsx(X,{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:j=>l(j.target.value)})})]}):null,e.kind==="change"?n.jsxs(n.Fragment,{children:[p.length>0?n.jsxs(W,{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(W,{tone:"warning",title:"Keeping this as proposed will be refused.",children:m.refusal}):null,m&&m.current!==null?n.jsx(Nu,{text:fw(gw(m.part,m.current),gw(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(Mt,{summary:`What its ${f.part==="tools"?"tool list":"instructions"} said when proposed`,children:n.jsx(Nt,{children:f.before})}):null,n.jsx(X,{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:j=>l(j.target.value)})})]}):null,e.kind==="policy"?n.jsx(Wt,{items:[{label:"Plugin",value:n.jsx("span",{className:"mono",children:String(f.plugin??"")})},{label:"Matches",value:n.jsx("span",{className:"mono",children:Uz(f.matcher??{})})},{label:"Does",value:String(f.action??"")},{label:"Learned from",value:(()=>{const j=Array.isArray(f.verdicts)?f.verdicts.length:0;return`${j} ${j===1?"decision":"decisions"}`})()}]}):null]})})}const Gz=1500,Yz={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."},qz="Restart buddi to apply it. In a checkout, stop it and run: buddi serve",$C=[{id:"npm",label:"From npm"},{id:"file",label:"A file"},{id:"directory",label:"A directory I built"}],DC="buddi.plugins.install-mode";function Qz(){try{const e=window.localStorage.getItem(DC);if($C.some(t=>t.id===e))return e}catch{}return"npm"}function Jz(e){try{window.localStorage.setItem(DC,e)}catch{}}const yc=".tgz";function Xz(e){const t=[],s=(r,i,a)=>{r>0&&t.push(`${r} ${r===1?i:a}`)};return s(e.tools,"tool","tools"),s(e.sentinels,"watcher","watchers"),s(e.views,"view","views"),s(e.agents,"agent","agents"),t.length===0?"nothing on its own":t.join(", ")}function _C(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 Zz(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function OC({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 Ax({author:e}){return e?n.jsxs("p",{className:"ui-card-meta",children:["by ",n.jsx(OC,{author:e})]}):null}function e5(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(c instanceof ae?c.message:String(c)),a=!0)})};l();const o=window.setInterval(l,Gz);return()=>{a=!0,window.clearInterval(o)}},[e]),{job:t,error:r}}function t5({plugin:e,pages:t,navigate:s}){const r=t.filter(i=>i.plugin===e);return r.length===0?null:n.jsx(n.Fragment,{children:r.map(i=>{const a=ji(i.plugin,i.id);return n.jsx(Gt,{size:"sm",href:a,"aria-label":`Open ${i.title}`,onClick:l=>{s&&(l.preventDefault(),s(a))},children:r.length===1?"Open":`Open ${i.title}`},i.id)})})}function n5({railPages:e=[],navigate:t}={}){const s=se(()=>A.plugins(),[],2e4),[r,i]=h.useState(null),{job:a,error:l}=e5(r),[o,c]=h.useState(null),[u,f]=h.useState(null);h.useEffect(()=>{((a==null?void 0:a.phase)==="done"||(a==null?void 0:a.phase)==="failed")&&s.reload()},[a==null?void 0:a.phase]);const d=s.data,m=(d==null?void 0:d.checkout)??!0,p=j=>e.some(w=>w.plugin===j)?n.jsx(t5,{plugin:j,pages:e,navigate:t}):void 0;return n.jsxs(V,{gap:"lg",children:[n.jsx(te,{message:s.error??o??l}),d!=null&&d.unavailable?n.jsx(W,{tone:"warning",children:d.unavailable}):null,n.jsx(Y,{title:"Plugins",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsx(W,{tone:"warning",children:(d==null?void 0:d.trust)??""})}),n.jsx(Y,{children:n.jsx(r5,{busy:a!==void 0&&a.phase!=="done"&&a.phase!=="failed",onStaged:j=>{c(null),f(null),i(j)},onFailed:c})}),a?n.jsx(Y,{children:n.jsxs(W,{tone:a.phase==="failed"?"critical":a.phase==="done"?"good":void 0,role:"status",children:[Yz[a.phase]," ",a.error??""]})}):null]})}),((d==null?void 0:d.staged)??[]).map(j=>n.jsx(a5,{staged:j,onInstalled:w=>{f(w),i(null),s.reload()},onGone:()=>s.reload()},j.id)),u||d!=null&&d.restartNeeded?n.jsx(l5,{checkout:m,name:u}):null,n.jsx(Y,{title:"Installed",panel:!0,children:d?d.installed.length===0?n.jsx(Pt,{icon:"plug",title:"Nothing installed yet",children:"Only what buddi ships with is here."}):n.jsx(V,{divided:!0,children:d.installed.map(j=>n.jsx(Y,{children:n.jsx(c5,{plugin:j,onChanged:()=>s.reload(),onFailed:c,open:p(j.name)})},j.name))}):n.jsx(oe,{children:"Loading…"})}),((d==null?void 0:d.builtIn)??[]).length>0?n.jsx(Y,{title:"Ships with buddi",panel:!0,children:n.jsx(V,{divided:!0,children:((d==null?void 0:d.builtIn)??[]).map(j=>n.jsx(Y,{children:n.jsx(s5,{plugin:j,open:p(j.name)})},j.name))})}):null]})}function s5({plugin:e,open:t}){return n.jsxs(V,{gap:"sm",children:[t?n.jsx(Q,{align:"end",children:t}):null,n.jsx(Wt,{items:[{label:n.jsx("span",{children:e.name}),value:n.jsxs("span",{children:[e.version," · ",Xz(e.contribution)]})}]}),n.jsx(Ax,{author:e.author}),e.description?n.jsx("p",{className:"ui-card-meta",children:e.description}):null,e.network&&e.network.length>0?n.jsxs("p",{className:"ui-card-meta",children:["Talks to ",e.network.map((s,r)=>n.jsxs("span",{children:[r>0?", ":"",n.jsx("span",{className:"mono",title:s.why,children:s.host})]},s.host)),"."]}):null]})}function r5({busy:e,onStaged:t,onFailed:s}){const[r,i]=h.useState(Qz),[a,l]=h.useState(""),[o,c]=h.useState(!1),[u,f]=h.useState(null),[d,m]=h.useState(null),[p,j]=h.useState(!1),w=h.useRef(null),k=v=>s(v instanceof ae?v.message:String(v)),g=v=>{i(v),Jz(v),m(null)},x=()=>{c(!0),A.stagePlugin(a.trim()).then(v=>{t(v.job.id),l("")}).catch(k).finally(()=>c(!1))},y=v=>{if(v){if(!v.name.toLowerCase().endsWith(yc)){f(null),m(`${v.name} is not a ${yc}. A packed plugin is the file npm pack writes.`);return}m(null),f(v.name),c(!0),A.uploadPlugin(v).then(N=>t(N.job.id)).catch(k).finally(()=>c(!1))}};return n.jsxs(V,{gap:"sm",children:[n.jsx("div",{className:"plugin-modes",role:"radiogroup","aria-label":"Where it comes from",children:$C.map(v=>n.jsx("button",{type:"button",role:"radio","aria-checked":r===v.id,className:"plugin-mode","data-chosen":r===v.id?"true":void 0,onClick:()=>g(v.id),children:v.label},v.id))}),r==="file"?n.jsxs("div",{className:"plugin-drop",role:"group","aria-label":"A plugin file","data-state":p?"over":d?"refused":u?"chosen":void 0,onDragOver:v=>{v.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:v=>{var N,b;v.preventDefault(),j(!1),y((b=(N=v.dataTransfer)==null?void 0:N.files)==null?void 0:b[0])},children:[n.jsx("p",{className:"ui-card-meta",children:d??(u?`${u} — reading it.`:`Drop a ${yc} here, or choose one.`)}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:e||o,onClick:()=>{var v;return(v=w.current)==null?void 0:v.click()},children:"Choose a file"})}),n.jsx("input",{ref:w,type:"file",accept:yc,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:v=>{var N;y((N=v.target.files)==null?void 0:N[0]),v.target.value=""}})]}):n.jsxs(n.Fragment,{children:[n.jsx(X,{label:r==="npm"?"Install a plugin":"The directory it is in",hint:r==="npm"?"A package name, or a name@version.":"The folder with its package.json, already built.",children:n.jsx("input",{type:"text",value:a,placeholder:r==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:v=>l(v.target.value)})}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:e||o||a.trim()==="",onClick:x,children:"Read it first"})})]})]})}function i5({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.jsx(Y,{title:"What it reaches in buddi",children:n.jsxs(V,{gap:"sm",children:[t.length===0?n.jsx("p",{className:"ui-card-meta",children:"Nothing beyond its own tables, its own folder and its own tools' approvals."}):n.jsx("ul",{className:"plugin-uses",children:t.map(a=>n.jsxs("li",{children:["It ",a.words,"."," ",a.added?n.jsxs(xe,{tone:"warning",children:["new in ",e.version]}):null]},a.use))}),s.length>0?n.jsxs("p",{className:"ui-card-meta",children:["No longer: ",s.map(a=>a.words).join("; "),"."]}):null]})})}function a5({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=m=>{l(!0),c(null),A.approveStaged(e.id,{integrity:e.integrity??"",...m?{acknowledgeDrift:!0}:{}}).then(p=>{p.installed?t(e.name):p.plan&&i(p.plan)}).catch(p=>c(p instanceof ae?p.message:String(p))).finally(()=>l(!1))},f=()=>{l(!0),c(null),A.rejectStaged(e.id).then(()=>s()).catch(m=>c(m instanceof ae?m.message:String(m))).finally(()=>l(!1))},d=(r==null?void 0:r.drift)??[];return n.jsxs(V,{gap:"lg",children:[n.jsx(Dn,{tone:"accent",title:`${e.name} ${e.version}`,meta:n.jsx(xe,{tone:"muted",children:"read, not installed"}),children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{message:o}),n.jsx(Ax,{author:e.author}),n.jsx(Wt,{items:[{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:_C(e.source)},{label:"Published by",value:e.publisher??"nobody npm will name"},{label:"Integrity",value:n.jsx("span",{className:"mono",children:e.integrity===void 0||e.integrity===""?"none — this came off a disk":e.integrity})},...e.source.kind==="directory"?[]:[{label:"Installs as",value: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."}]:[],...e.stagedHash?[{label:"Files on disk",value:n.jsx("span",{className:"mono",children:e.stagedHash})}]:[],{label:"Dependencies",value:e.dependencies.count===0?"none":`${e.dependencies.count}${e.dependencies.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${e.dependencies.withScripts.join(", ")}`}`}]}),n.jsx(i5,{staged:e}),n.jsx(Y,{title:"What the package says about itself",children:n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"This is its claim, taken from its own buddi.md. Nothing has checked it yet."}),n.jsx(Wt,{items:[{label:"Schema it owns",value:e.claims.schema??"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":e.claims.hosts.join(", ")}]}),e.claims.missing?n.jsx("p",{className:"ui-card-meta",children:"It ships no buddi.md, so it says nothing about itself at all."}):n.jsx("p",{className:"ui-card-meta",children:e.claims.text})]})}),n.jsxs(Q,{align:"end",children:[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"})]})]})}),d.length>0?n.jsx(Dn,{tone:"warning",title:"What it said, and what it does",meta:n.jsx(xe,{tone:"warning",children:"read this first"}),children:n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),n.jsx("ul",{className:"plugin-drift",children:d.map(m=>n.jsx("li",{children:m},m))}),n.jsx(LC,{unlocks:(r==null?void 0:r.agents)??[]}),n.jsxs(Q,{align:"end",children:[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"})]})]})}):null]})}function l5({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.jsx(Y,{title:"Restart to load it",panel:!0,children:n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{message:i}),n.jsxs(W,{tone:e?"warning":void 0,role:"status",children:[l," ",e?qz:`${t?"Its tools appear":"It takes effect"} once buddi restarts. That closes this dashboard for a few seconds.`]}),e?null:n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:s,onClick:()=>{r(!0),a(null),A.serviceAction("restart").catch(o=>a(o instanceof ae?o.message:String(o))).finally(()=>r(!1))},children:"Restart to load it"})})]})})})}function LC({plugin:e,unlocks:t}){return t.length===0?null:n.jsx(Y,{title:"Agents it would unlock",children:n.jsxs(V,{gap:"sm",divided:!0,children:[t.map(s=>n.jsx(o5,{plugin:e,unlock:s},s.id)),n.jsxs("p",{className:"ui-card-meta",children:["Nothing here is created by installing. Accept creates the agent with the tools listed. You can change or remove it ",n.jsx("a",{href:ut,children:"on the Agents page"}),"."]})]})})}function o5({plugin:e,unlock:t}){const s=dx(e,t.id),r=t.drift.state!=="not-accepted";return n.jsxs(V,{gap:"sm",children:[n.jsxs(Q,{children:[n.jsxs("span",{className:"mono",children:["@",t.handle]}),n.jsx(xe,{tone:t.drift.state==="up-to-date"?"good":"warning",children:t.drift.state}),n.jsx("span",{className:"ui-card-meta",children:t.drift.message}),n.jsx(Ms,{}),e&&!r&&!s.created?n.jsx(I,{size:"sm",disabled:s.busy,onClick:s.accept,children:"Accept"}):null]}),n.jsx(te,{message:s.failure}),s.created?n.jsx(r1,{agent:s.created}):null]})}function c5({plugin:e,onChanged:t,onFailed:s,open:r}){const[i,a]=h.useState(!1),[l,o]=h.useState(!1),[c,u]=h.useState(!1),[f,d]=h.useState(""),[m,p]=h.useState(!1),j=x=>{p(!0),x.then(()=>{a(!1),o(!1),u(!1),d(""),t()}).catch(y=>s(y instanceof ae?y.message:String(y))).finally(()=>p(!1))},w=e.contribution,k=e.enabled===!1,g=e.author!==void 0&&e.source.kind==="directory";return n.jsxs(V,{gap:"sm",children:[n.jsx(Dn,{tone:e.loaded||k?void 0:"critical",title:`${e.name} ${e.version}`,meta:k?n.jsx(xe,{tone:"muted",children:"disabled"}):e.loaded?n.jsx(xe,{tone:"good",children:"loaded"}):n.jsx(xe,{tone:"critical",children:"did not load"}),actions:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",variant:"ghost",disabled:m,onClick:()=>{a(!i),o(!1)},children:"Remove…"}),k?n.jsx(I,{size:"sm",disabled:m,onClick:()=>j(A.setPluginEnabled(e.name,!0)),children:"Enable"}):n.jsx(I,{size:"sm",variant:"ghost",disabled:m,onClick:()=>{o(!l),a(!1)},children:"Disable…"}),n.jsx(I,{size:"sm",disabled:m,onClick:()=>j(A.updatePlugin(e.name)),children:"Update"}),r]}),children:n.jsxs(V,{gap:"sm",children:[e.error?n.jsx(W,{tone:"critical",children:e.error}):null,k?n.jsx("p",{className:"ui-card-meta",children:"Disabled: its tools, pages and watchers are off and its missions are paused. Its data is kept."}):null,g?null:n.jsx(Ax,{author:e.author}),n.jsx(Wt,{items:[{label:"From",value:_C(e.source)},g?{label:"By",value:n.jsx(OC,{author:e.author})}:{label:"Published by",value:Zz(e.source,e.publisher)},{label:"Installed",value:De(e.installedAt)},{label:"Contributes",value:`${w.tools} tool${w.tools===1?"":"s"}, ${w.sentinels} on a timer, ${w.views} view${w.views===1?"":"s"}, ${w.agents} agent${w.agents===1?"":"s"} proposed`}]}),n.jsx(LC,{plugin:e.name,unlocks:e.unlocks})]})}),l?n.jsxs(V,{gap:"sm",children:[n.jsx(W,{tone:"accent",children:"Disabling keeps everything: its tables and data, the agents you accepted from it and their grants. When buddi restarts its tools, pages and watchers stop, its missions pause, and agents that use it carry on without those tools. Enable it to have it all back."}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",disabled:m,onClick:()=>o(!1),children:"Cancel"}),n.jsx(I,{disabled:m,onClick:()=>j(A.setPluginEnabled(e.name,!1)),children:"Disable"})]})]}):null,i?n.jsxs(V,{gap:"sm",children:[n.jsx(W,{tone:"warning",children:"Removing takes the plugin off this machine and stops its code loading. Its tables stay unless you also drop its data below, and then they are gone for good. To stop it and keep everything, disable it instead."}),n.jsxs("label",{className:"plugin-check",children:[n.jsx("input",{type:"checkbox",checked:c,onChange:x=>{u(x.target.checked),d("")}}),n.jsx("span",{children:"Also drop its data. Its tables are not recoverable afterwards."})]}),c?n.jsx(X,{label:`Type ${e.name} to confirm`,children:n.jsx("input",{value:f,onChange:x=>d(x.target.value)})}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",disabled:m,onClick:()=>{a(!1),u(!1),d("")},children:"Cancel"}),n.jsx(I,{variant:"danger",disabled:m||c&&f.trim()!==e.name,onClick:()=>j(A.uninstallPlugin(e.name,c?{purge:!0,confirm:f.trim()}:{})),children:c?"Remove and drop its data":"Remove"})]})]}):null]})}var No={},u5=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},FC={},Bn={};let Tx;const d5=[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];Bn.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};Bn.getSymbolTotalCodewords=function(t){return d5[t]};Bn.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};Bn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Tx=t};Bn.isKanjiModeEnabled=function(){return typeof Tx<"u"};Bn.toSJIS=function(t){return Tx(t)};var Rd={};(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}}})(Rd);function UC(){this.buffer=[],this.length=0}UC.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 h5=UC;function Co(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)}Co.prototype.set=function(e,t,s,r){const i=e*this.size+t;this.data[i]=s,r&&(this.reservedBit[i]=!0)};Co.prototype.get=function(e,t){return this.data[e*this.size+t]};Co.prototype.xor=function(e,t,s){this.data[e*this.size+t]^=s};Co.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var f5=Co,BC={};(function(e){const t=Bn.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}})(BC);var zC={};const m5=Bn.getSymbolSize,xw=7;zC.getPositions=function(t){const s=m5(t);return[[0,0],[s-xw,0],[0,s-xw]]};var WC={};(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}})(WC);var Id={};const gr=Rd,wc=[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],bc=[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];Id.getBlocksCount=function(t,s){switch(s){case gr.L:return wc[(t-1)*4+0];case gr.M:return wc[(t-1)*4+1];case gr.Q:return wc[(t-1)*4+2];case gr.H:return wc[(t-1)*4+3];default:return}};Id.getTotalCodewordsCount=function(t,s){switch(s){case gr.L:return bc[(t-1)*4+0];case gr.M:return bc[(t-1)*4+1];case gr.Q:return bc[(t-1)*4+2];case gr.H:return bc[(t-1)*4+3];default:return}};var HC={},Pd={};const Rl=new Uint8Array(512),Ou=new Uint8Array(256);(function(){let t=1;for(let s=0;s<255;s++)Rl[s]=t,Ou[t]=s,t<<=1,t&256&&(t^=285);for(let s=255;s<512;s++)Rl[s]=Rl[s-255]})();Pd.log=function(t){if(t<1)throw new Error("log("+t+")");return Ou[t]};Pd.exp=function(t){return Rl[t]};Pd.mul=function(t,s){return t===0||s===0?0:Rl[Ou[t]+Ou[s]]};(function(e){const t=Pd;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}})(HC);const VC=HC;function Rx(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Rx.prototype.initialize=function(t){this.degree=t,this.genPoly=VC.generateECPolynomial(this.degree)};Rx.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=VC.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 p5=Rx,KC={},Hr={},Ix={};Ix.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var _s={};const GC="[0-9]+",g5="[A-Z $%*+\\-./:]+";let ho="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";ho=ho.replace(/u/g,"\\u");const x5="(?:(?![A-Z0-9 $%*+\\-./:]|"+ho+`)(?:.|[\r
118
+ ]))+`;_s.KANJI=new RegExp(ho,"g");_s.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");_s.BYTE=new RegExp(x5,"g");_s.NUMERIC=new RegExp(GC,"g");_s.ALPHANUMERIC=new RegExp(g5,"g");const v5=new RegExp("^"+ho+"$"),j5=new RegExp("^"+GC+"$"),y5=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");_s.testKanji=function(t){return v5.test(t)};_s.testNumeric=function(t){return j5.test(t)};_s.testAlphanumeric=function(t){return y5.test(t)};(function(e){const t=Ix,s=_s;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}}})(Hr);(function(e){const t=Bn,s=Id,r=Rd,i=Hr,a=Ix,l=7973,o=t.getBCHDigit(l);function c(m,p,j){for(let w=1;w<=40;w++)if(p<=e.getCapacity(w,j,m))return w}function u(m,p){return i.getCharCountIndicator(m,p)+4}function f(m,p){let j=0;return m.forEach(function(w){const k=u(w.mode,p);j+=k+w.getBitsLength()}),j}function d(m,p){for(let j=1;j<=40;j++)if(f(m,j)<=e.getCapacity(j,p,i.MIXED))return j}e.from=function(p,j){return a.isValid(p)?parseInt(p,10):j},e.getCapacity=function(p,j,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,j),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,j){let w;const k=r.from(j,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 j=p<<12;for(;t.getBCHDigit(j)-o>=0;)j^=l<<t.getBCHDigit(j)-o;return p<<12|j}})(KC);var YC={};const lp=Bn,qC=1335,w5=21522,vw=lp.getBCHDigit(qC);YC.getEncodedBits=function(t,s){const r=t.bit<<3|s;let i=r<<10;for(;lp.getBCHDigit(i)-vw>=0;)i^=qC<<lp.getBCHDigit(i)-vw;return(r<<10|i)^w5};var QC={};const b5=Hr;function Ra(e){this.mode=b5.NUMERIC,this.data=e.toString()}Ra.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Ra.prototype.getLength=function(){return this.data.length};Ra.prototype.getBitsLength=function(){return Ra.getBitsLength(this.data.length)};Ra.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 k5=Ra;const S5=Hr,Jh=["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 Ia(e){this.mode=S5.ALPHANUMERIC,this.data=e}Ia.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Ia.prototype.getLength=function(){return this.data.length};Ia.prototype.getBitsLength=function(){return Ia.getBitsLength(this.data.length)};Ia.prototype.write=function(t){let s;for(s=0;s+2<=this.data.length;s+=2){let r=Jh.indexOf(this.data[s])*45;r+=Jh.indexOf(this.data[s+1]),t.put(r,11)}this.data.length%2&&t.put(Jh.indexOf(this.data[s]),6)};var N5=Ia;const C5=Hr;function Pa(e){this.mode=C5.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Pa.getBitsLength=function(t){return t*8};Pa.prototype.getLength=function(){return this.data.length};Pa.prototype.getBitsLength=function(){return Pa.getBitsLength(this.data.length)};Pa.prototype.write=function(e){for(let t=0,s=this.data.length;t<s;t++)e.put(this.data[t],8)};var E5=Pa;const A5=Hr,T5=Bn;function Ma(e){this.mode=A5.KANJI,this.data=e}Ma.getBitsLength=function(t){return t*13};Ma.prototype.getLength=function(){return this.data.length};Ma.prototype.getBitsLength=function(){return Ma.getBitsLength(this.data.length)};Ma.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let s=T5.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 R5=Ma,JC={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,j,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],j=d+p,w=l[f],k=typeof l[f]>"u",(k||w>j)&&(l[f]=j,o.push(f,j),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})(JC);var I5=JC.exports;(function(e){const t=Hr,s=k5,r=N5,i=E5,a=R5,l=_s,o=Bn,c=I5;function u(g){return unescape(encodeURIComponent(g)).length}function f(g,x,y){const v=[];let N;for(;(N=g.exec(y))!==null;)v.push({data:N[0],index:N.index,mode:x,length:N[0].length});return v}function d(g){const x=f(l.NUMERIC,t.NUMERIC,g),y=f(l.ALPHANUMERIC,t.ALPHANUMERIC,g);let v,N;return o.isKanjiModeEnabled()?(v=f(l.BYTE,t.BYTE,g),N=f(l.KANJI,t.KANJI,g)):(v=f(l.BYTE_KANJI,t.BYTE,g),N=[]),x.concat(y,v,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 v=x.length-1>=0?x[x.length-1]:null;return v&&v.mode===y.mode?(x[x.length-1].data+=y.data,x):(x.push(y),x)},[])}function j(g){const x=[];for(let y=0;y<g.length;y++){const v=g[y];switch(v.mode){case t.NUMERIC:x.push([v,{data:v.data,mode:t.ALPHANUMERIC,length:v.length},{data:v.data,mode:t.BYTE,length:v.length}]);break;case t.ALPHANUMERIC:x.push([v,{data:v.data,mode:t.BYTE,length:v.length}]);break;case t.KANJI:x.push([v,{data:v.data,mode:t.BYTE,length:u(v.data)}]);break;case t.BYTE:x.push([{data:v.data,mode:t.BYTE,length:u(v.data)}])}}return x}function w(g,x){const y={},v={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},v[P]={};for(let L=0;L<N.length;L++){const $=N[L];y[$]&&y[$].node.mode===E.mode?(v[$][P]=m(y[$].lastCount+E.length,E.mode)-m(y[$].lastCount,E.mode),y[$].lastCount+=E.length):(y[$]&&(y[$].lastCount=E.length),v[$][P]=m(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,x))}}N=C}for(let b=0;b<N.length;b++)v[N[b]].end=0;return{map:v,table:y}}function k(g,x){let y;const v=t.getBestModeForData(g);if(y=t.from(x,v),y!==t.BYTE&&y.bit<v.bit)throw new Error('"'+g+'" cannot be encoded with mode '+t.toString(y)+`.
120
+ Suggested mode is: `+t.toString(v));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,v){return typeof v=="string"?y.push(k(v,null)):v.data&&y.push(k(v.data,v.mode)),y},[])},e.fromString=function(x,y){const v=d(x,o.isKanjiModeEnabled()),N=j(v),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()))}})(QC);const Md=Bn,Xh=Rd,P5=h5,M5=f5,$5=BC,D5=zC,op=WC,cp=Id,_5=p5,Lu=KC,O5=YC,L5=Hr,Zh=QC;function F5(e,t){const s=e.size,r=D5.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 U5(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 B5(e,t){const s=$5.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 z5(e,t){const s=e.size,r=Lu.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 ef(e,t,s){const r=e.size,i=O5.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 W5(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 H5(e,t,s){const r=new P5;s.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),L5.getCharCountIndicator(c.mode,e)),c.write(r)});const i=Md.getSymbolTotalCodewords(e),a=cp.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 V5(r,e,t)}function V5(e,t,s){const r=Md.getSymbolTotalCodewords(t),i=cp.getTotalCodewordsCount(t,s),a=r-i,l=cp.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 _5(m);let j=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(j,j+C),k[S]=p.encode(w[S]),j+=C,g=Math.max(g,C)}const y=new Uint8Array(r);let v=0,N,b;for(N=0;N<g;N++)for(b=0;b<l;b++)N<w[b].length&&(y[v++]=w[b][N]);for(N=0;N<m;N++)for(b=0;b<l;b++)y[v++]=k[b][N];return y}function K5(e,t,s,r){let i;if(Array.isArray(e))i=Zh.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const f=Zh.rawSplit(e);u=Lu.getBestVersionForData(f,s)}i=Zh.fromString(e,u||40)}else throw new Error("Invalid data");const a=Lu.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=H5(t,s,i),o=Md.getSymbolSize(t),c=new M5(o);return F5(c,t),U5(c),B5(c,t),ef(c,s,0),t>=7&&z5(c,t),W5(c,l),isNaN(r)&&(r=op.getBestMask(c,ef.bind(null,c,s))),op.applyMask(r,c),ef(c,s,r),{modules:c,version:t,errorCorrectionLevel:s,maskPattern:r,segments:i}}FC.create=function(t,s){if(typeof t>"u"||t==="")throw new Error("No input text");let r=Xh.M,i,a;return typeof s<"u"&&(r=Xh.from(s.errorCorrectionLevel,Xh.M),i=Lu.from(s.version),a=op.from(s.maskPattern),s.toSJISFunc&&Md.setToSJISFunction(s.toSJISFunc)),K5(t,i,r,a)};var XC={},Px={};(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 j=(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[j++]=w.r,r[j++]=w.g,r[j++]=w.b,r[j]=w.a}}})(Px);(function(e){const t=Px;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)}})(XC);var ZC={};const G5=Px;function jw(e,t){const s=e.a/255,r=t+'="'+e.hex+'"';return s<1?r+" "+t+'-opacity="'+s.toFixed(2).slice(1)+'"':r}function tf(e,t,s){let r=e+t;return typeof s<"u"&&(r+=" "+s),r}function Y5(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?tf("M",c+s,.5+u+s):tf("m",i,0),i=0,a=!1),c+1<t&&e[o+1]||(r+=tf("h",l),l=0)):i++}return r}ZC.render=function(t,s,r){const i=G5.getOptions(s),a=t.modules.size,l=t.modules.data,o=a+i.margin*2,c=i.color.light.a?"<path "+jw(i.color.light,"fill")+' d="M0 0h'+o+"v"+o+'H0z"/>':"",u="<path "+jw(i.color.dark,"stroke")+' d="'+Y5(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 q5=u5,up=FC,eE=XC,Q5=ZC;function Mx(e,t,s,r,i){const a=[].slice.call(arguments,1),l=a.length,o=typeof a[l-1]=="function";if(!o&&!q5())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=up.create(s,r);c(e(f,t,r))}catch(f){u(f)}})}try{const c=up.create(s,r);i(null,e(c,t,r))}catch(c){i(c)}}No.create=up.create;No.toCanvas=Mx.bind(null,eE.render);No.toDataURL=Mx.bind(null,eE.renderToDataURL);No.toString=Mx.bind(null,function(e,t,s){return Q5.render(e,s)});async function J5(e){const t=await No.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const yw=10*6e4,X5=2e3;function tE(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 J5(p.link).catch(()=>""))},[]);return h.useEffect(()=>{if(!s||l||c)return;let p=!1;const j=Math.min(Date.parse(s.expiresAt)||Date.now()+yw,Date.now()+yw),w=window.setInterval(()=>{if(Date.now()>=j){u(!0);return}f.current().then(k=>{var g;p||!k||(o(!0),(g=d.current)==null||g.call(d))}).catch(()=>{})},X5);return()=>{p=!0,window.clearInterval(w)}},[s,l,c]),{offer:s,square:i,paired:l,stale:c,ask:m}}function nE({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"]),kc={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 Z5({timezone:e}){var w,k;const t=se(()=>A.notificationSettings(),[]),s=se(()=>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}))},j=()=>{m&&(l(!0),c(!1),f(null),A.saveNotificationSettings(m).then(()=>{c(!0),i(null),t.reload()}).catch(g=>f(g instanceof ae?g.message:String(g))).finally(()=>l(!1)))};return n.jsxs(V,{gap:"lg",children:[n.jsx(t8,{timezone:e,onChange:t.reload}),n.jsx(Y,{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:j,children:"Save"}),children:n.jsxs(V,{divided:!0,children:[n.jsx(te,{message:t.error??u}),n.jsx(Y,{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(V,{gap:"sm",children:d.map(g=>{var x;return n.jsx(r8,{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(Y,{title:"By kind",children:m?n.jsxs(V,{gap:"sm",children:[YI.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:kc[g].label}),n.jsx("span",{className:"ui-field-hint",children:kc[g].hint})]}),n.jsxs("select",{"aria-label":kc[g].label,value:i8(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(Y,{title:"Focus schedules",children:m?n.jsxs(V,{gap:"sm",children:[n.jsx(o8,{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(X,{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(W,{tone:"good",role:"status",children:"Saved."}):null]})}),n.jsx(e8,{}),n.jsxs(Y,{title:"The last twenty",panel:!0,flush:!0,children:[n.jsx(te,{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(Ht,{children:s.data.notifications.map(g=>n.jsx(Vt,{title:g.title,sub:`${Ve(g.createdAt,e)} · ${kc[g.kind].label.toLowerCase()} · ${a8(g,d)}`,side:n.jsx(l8,{row:g})},g.id))}):n.jsx(oe,{children:"Loading…"})]})]})}function e8(){var u;const e=se(()=>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 ae?d.message:String(d))}).finally(()=>s(!1))};return n.jsx(Y,{title:"Tips",panel:!0,children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{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 t8({timezone:e,onChange:t}){var C,R;const s=se(()=>A.telegramBot(),[]),r=se(()=>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),j=h.useRef(new Set),w=tE(()=>A.telegramDevices().then(E=>E.devices.some(P=>!j.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(L=>{o(""),a(!1),d(L.restartNeeded?{ok:!1,text:L.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(L=>d({ok:!1,text:L instanceof ae?L.message:String(L)})).finally(()=>u(!1))},y=()=>{var E;p(null),j.current=new Set((((E=r.data)==null?void 0:E.devices)??[]).map(P=>P.id)),w.ask().catch(P=>p(P instanceof ae?P.message:String(P)))},{offer:v,square:N,paired:b,stale:S}=w;return n.jsx(Y,{title:"Telegram",aside:"Talk to buddi from your phone.",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{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(V,{gap:"sm",children:[n.jsx(te,{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(X,{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(W,{tone:f.ok?"good":"warning",role:"status",children:f.text}):null]})}),n.jsxs(Y,{title:"Your devices",children:[n.jsx(te,{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(Ht,{children:r.data.devices.map(E=>n.jsx(Vt,{title:E.name??`Telegram user ${E.userId}`,sub:`Paired ${Ve(E.pairedAt,e)} · ${E.lastSeenAt?`last spoke ${De(E.lastSeenAt)}`:"has not spoken yet"}`,side:n.jsx(n8,{id:E.id,onGone:()=>{r.reload(),t()}})},E.id))}):r.error?null:n.jsx(oe,{children:"Loading…"})]}),n.jsx(Y,{title:"Pair a device",foot:k&&(!v||b)?n.jsx(I,{variant:v?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(V,{gap:"sm",children:[n.jsx(te,{message:m}),k?b?n.jsx(W,{tone:"good",role:"status",children:"Paired."}):v&&S?n.jsx("p",{className:"ui-card-meta",children:"That code has run out."}):v?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(nE,{offer:v,square:N,children:n.jsx(s8,{text:v.link})}),n.jsxs("p",{className:"ui-field-hint",children:["The code works until ",Ve(v.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 n8({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 ae?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 s8({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 r8({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 ae?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 i8(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 a8(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 l8({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 ww={mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat",sun:"Sun"},bw={mode:"do-not-disturb",days:[...um],from:"22:00",to:"07:00"};function o8({schedules:e,onChange:t}){const s=(r,i)=>t(e.map((a,l)=>l===r?{...a,...i}:a));return n.jsxs(V,{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:um.map(l=>{const o=r.days.includes(l);return n.jsx("button",{type:"button",className:"nt-day","aria-pressed":o,"aria-label":`Schedule ${a} ${ww[l]}`,onClick:()=>s(i,{days:o?r.days.filter(c=>c!==l):um.filter(c=>c===l||r.days.includes(c))}),children:ww[l]},l)})}),n.jsx(X,{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(X,{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,{...bw,days:[...bw.days]}]),children:"Add a schedule"})})]})}const c8={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 u8(e){const t=Q$.map(r=>({id:r.id,route:tt(r.id),label:r.label,icon:c8[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:YS(r.plugin,r.id),route:wo(r.plugin,r.id),label:r.title,icon:I1(r.icon),group:"plugins"}));return[...t,...s]}function rE(e){return q$.map(t=>({id:t.id,label:t.label,entries:e.filter(s=>s.group===t.id)})).filter(t=>t.entries.length>0)}function iE(e,t,s){return t?`${e}, ${t} open`:s?`${e}, ${s}`:void 0}function d8({entries:e,active:t,counts:s={},dots:r={},navigate:i}){var u;const a=h.useRef(null),l=rE(e),o=e.some(f=>f.id===t)?t:(u=e[0])==null?void 0:u.id,c=f=>{var j;const d=[...((j=a.current)==null?void 0:j.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],j=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":iE(d.label,p,j),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}):j?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 h8({entries:e,active:t,counts:s={},dots:r={},navigate:i}){const a=rE(e),l=e.find(o=>o.id===t)??e[0];return n.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:n.jsxs(Mg,{modal:!1,children:[n.jsx($g,{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(xd,{children:n.jsx(Dg,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:n.jsx(o$,{value:t,onValueChange:o=>{const c=e.find(u=>u.id===o);c&&i(c.route)},children:a.map((o,c)=>n.jsxs(VS,{children:[c>0?n.jsx(ai,{className:"ui-menu-sep"}):null,n.jsx(vd,{className:"ui-menu-label",children:o.label}),o.entries.map(u=>{const f=s[u.id],d=r[u.id];return n.jsxs(c$,{value:u.id,className:"ui-menu-item settings-menu-item","data-active":u.id===t?"true":void 0,"aria-label":iE(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 f8({hash:e,timezone:t,navigate:s,agents:r,pluginPages:i}){var x,y,v;const a=J$(e),l=T1(i!==void 0),o=i??l,c=V$(e),u=c?o.find(c.plugin,c.page):void 0,f=Aa(gx),d=u8(o.settings),p={proposals:((y=(x=se(()=>Promise.resolve().then(()=>A.proposals()),[],3e4).data)==null?void 0:x.open)==null?void 0:y.length)??0},j=se(()=>A.version(),[]),w=se(()=>Promise.resolve().then(()=>A.connectionSignals()),[],6e4),k={};j.data&&!j.data.checkout&&j.data.updateAvailable&&(k.system="a newer buddi is ready"),(((v=w.data)==null?void 0:v.signals)??[]).length>0&&(k.connections=P1);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(d8,{...g}),n.jsx("div",{className:"settings-body",children:n.jsxs("div",{className:"ui-page",children:[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(h8,{...g}):null,u?n.jsx(w6,{page:u,navigate:s,timezone:t,siblings:o.all.filter(N=>N.plugin===u.plugin)}):null,a==="you"?n.jsx(_z,{embedded:!0}):null,a==="appearance"?n.jsx(m8,{railPages:o.rail}):null,a==="notifications"?n.jsx(Z5,{timezone:t}):null,a==="memory"?n.jsx(Y1,{embedded:!0,agents:r,timezone:t}):null,a==="proposals"?n.jsx(zz,{embedded:!0,plugin:G$(e)}):null,a==="accounts"?n.jsx(KB,{embedded:!0}):null,a==="computer"?n.jsx(YF,{embedded:!0,timezone:t}):null,a==="secrets"?n.jsx(pz,{embedded:!0,timezone:t}):null,a==="connections"?n.jsx(Ez,{embedded:!0,timezone:t}):null,a==="watchers"?n.jsx($z,{timezone:t,embedded:!0}):null,a==="backup"?n.jsx(LB,{}):null,a==="plugins"?n.jsx(n5,{railPages:o.rail,navigate:s}):null,a==="system"?n.jsx(x8,{timezone:t}):null]})})]})}function m8({railPages:e}){const[t,s]=U1();return n.jsx(Y,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:n.jsxs(V,{divided:!0,gap:"lg",children:[n.jsx(nf,{label:"Theme",hint:"System follows your Mac.",children:n.jsx(Ar,{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(nf,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:n.jsx(Ar,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:t.ground,onChange:r=>s({ground:r})})}),n.jsx(nf,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:n.jsx(Ar,{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(g8,{pages:e}),n.jsx(p8,{})]})})}function p8(){var a;const e=se(()=>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(V,{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 g8({pages:e}){const t=$1(),[s,r]=h.useState(null);if(e.length===0)return null;const i=(a,l)=>{r(null),_6(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(V,{gap:"sm",children:[n.jsx(te,{message:s}),e.map(a=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:!t.has(co(a)),onChange:l=>i(a,l.target.checked)}),n.jsx("span",{children:a.title})]},co(a)))]})]})}function nf({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 x8({timezone:e}){const t=se(()=>A.overview(),[],15e3),s=se(()=>A.session(),[]),r=se(()=>A.providerAccounts(),[]),i=t.data;return n.jsxs(V,{gap:"lg",children:[n.jsx(te,{message:t.error}),n.jsx(I8,{}),i?n.jsx(Y,{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(Y,{title:"This host",panel:!0,children:[n.jsx(Wt,{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?w8(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?n.jsx(W,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),n.jsx(y8,{}),n.jsx(v8,{}),n.jsx(Y,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?n.jsx(oe,{children:"No sources are installed."}):n.jsx(Wt,{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 ",De(a.lastRunAt)]})}))}):n.jsx(oe,{children:"Loading…"})})]})}function v8(){var p;const e=se(()=>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=j=>{i(!0),l(null),c(!1),A.setTailscale({enabled:j,login:f.trim()}).then(()=>{c(!0)}).catch(w=>l(w instanceof ae?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return n.jsx(Y,{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(V,{divided:!0,children:n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{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(W,{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:j=>m(j.target.checked)}),n.jsx("span",{children:"Let this Tailscale login sign in"})]}),n.jsx(X,{label:"Tailscale login",children:n.jsx("input",{type:"text",value:f,placeholder:"you@example.com",disabled:r||!u||d,onChange:j=>s(j.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:()=>{j8((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(W,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function j8(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function y8(){var u;const e=se(()=>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(Y,{title:"Service",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsx(Wt,{items:[{label:"Database",value:n.jsx(kw,{state:o.database,pid:o.databasePid})},{label:"Gateway",value:n.jsx(kw,{state:o.gateway,pid:o.gatewayPid})},{label:"Supervisor",value:n.jsxs("span",{className:"mono",children:["pid ",o.supervisorPid]})}]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{message:a}),t?n.jsx(W,{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 kw({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 w8(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const b8=2e3,Sw={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."},k8=new Set(["done","failed","rolled-back"]),S8="The check asks the npm registry for the newest version and sends nothing else.",N8="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",C8="A checkout upgrades with git pull, then buddi upgrade in a terminal.",E8=10*6e4,A8="buddi did not come back. Run buddi doctor in a terminal.";function T8(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 R8(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,j=0;const w=()=>{f.current=!0,j=Date.now()+E8,o(!0)},k=()=>{if(Date.now()<j){A.session().then(y=>{p||y.version!==void 0&&y.version===t||(p=!0,d.current())}).catch(()=>{}),A.version().then(y=>{const v=y.history[y.history.length-1];p||(v==null?void 0:v.outcome)!=="failed"||(p=!0,o(!1),u(T8(v)))}).catch(()=>{});return}p=!0,o(!1),u(A8)},g=()=>{if(!p){if(f.current)return k();A.upgradeJob(e).then(y=>{var v;p||(a(y),u(null),(k8.has(y.phase)||y.finishedAt)&&(p=!0,y.phase==="failed"&&((v=m.current)==null||v.call(m,y))))}).catch(y=>{p||(y instanceof ae&&y.status!==0&&y.status<500?u(y.message):w())})}};g();const x=window.setInterval(g,b8);return()=>{p=!0,window.clearInterval(x)}},[e,t]),{job:i,away:l,error:c}}function I8({reload:e}){var v;const t=se(()=>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=(v=t.data)==null?void 0:v.current,p=e??(()=>window.location.reload()),j=h.useCallback(N=>{r(null),d(N)},[]),w=R8(s,m,p,j),k=t.data,g=()=>{o(!0),u(null),A.checkVersion().catch(N=>u(N instanceof ae?N.message:String(N))).finally(()=>{o(!1),t.reload()})},x=N=>{o(!0),u(null),A.setVersionCheck(N).catch(b=>u(b instanceof ae?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 ae?N.message:String(N))).finally(()=>o(!1))};return k!=null&&k.checkout?n.jsx(Y,{title:"Version",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsx(Wt,{items:[{label:"Running",value:n.jsx("span",{className:"mono",children:k.current})}]})}),n.jsx(Y,{children:n.jsx("p",{className:"ui-card-meta",children:C8})})]})}):n.jsx(Y,{title:"Version",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(te,{message:t.error??c}),n.jsx(Wt,{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 ",De(k.checkedAt),"."]}):n.jsx("span",{children:"Not checked yet."}):"…"}]}),k!=null&&k.error?n.jsxs(W,{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(Y,{children:n.jsxs(V,{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:S8})]})}),k!=null&&k.updateAvailable&&k.latest&&k.latestNotes?n.jsx(Y,{title:`What changes in ${k.latest}`,children:n.jsx(tr,{text:k.latestNotes})}):null,n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(P8,{...w,job:w.job??f??void 0}),i?n.jsx(W,{tone:"warning",role:"alert",children:N8}):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(Y,{title:"Upgrades so far",children:n.jsx(Wt,{items:k.history.slice().reverse().map(N=>({key:N.startedAt,label:n.jsxs("span",{className:"mono",children:[N.from," → ",N.to]}),value:n.jsx(M8,{attempt:N})}))})}):null]})})}function P8({job:e,away:t,error:s}){return s?n.jsx(te,{message:s}):t?n.jsx(W,{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(W,{tone:"critical",role:"alert",children:[Sw.failed," ",e.error??""," buddi is still running on the version it had."]}):n.jsx(W,{tone:e.phase==="done"?"good":void 0,role:"status",children:Sw[e.phase]??e.detail??e.phase}):null}function M8({attempt:e}){return n.jsxs("span",{children:[n.jsx(xe,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",De(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 dp=["name","clock","brain","browser","assistant","handover"],aE={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function lE(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function $8(e){var a,l,o;const t=lE(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 oE(e){var r,i,a;const t=$8(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 D8(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 Yc(e){return dp.find(t=>!D8(e,t))??"handover"}function _8(e,t){const s=dp.indexOf(t);return dp.filter((r,i)=>i<s||r===t)}function O8(e,t){const s={...e};return delete s[t],s}const hp="buddi.firstRun.restore";function sf(e){try{e===null?window.sessionStorage.removeItem(hp):window.sessionStorage.setItem(hp,e)}catch{}}function cE(){try{return window.sessionStorage.getItem(hp)}catch{return null}}function L8(e){const t=oE(e),s=Yc(t);return{answers:t,open:s,stay:s!=="handover"}}function F8(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function U8(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 B8=550,z8=6e4,W8=5*6e4,uE=1500,H8=3e3;function Ga(){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 dE(){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=dE(),[r,i]=h.useState(s||t===0);return h.useEffect(()=>{if(s){i(!0);return}const a=window.setTimeout(()=>i(!0),B8*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(ds,{})}function ds({line:e}){const{report:t}=h.useContext($x);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 $x=h.createContext({busy:0,report:()=>{}});function V8({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($x.Provider,{value:i,children:e})}function $e({children:e}){const{busy:t}=h.useContext($x),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(bd,{state:r?"working":"idle",size:"sm",className:"meet-turn-mark"}),n.jsx("span",{children:"buddi"})]}),e]})}const hE=h.createContext({body:null,actions:null});function fE({children:e,actions:t}){const s=h.useContext(hE),r=e==null?null:s.body?Sa.createPortal(e,s.body):e,i=t==null?null:s.actions?Sa.createPortal(t,s.actions):t;return n.jsxs(n.Fragment,{children:[r,i]})}function Sc({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:F.change})]})}function Ct({children:e,actions:t}){return n.jsx(fE,{actions:t?n.jsx("span",{className:"meet-actions",children:t}):null,children:e?n.jsx("div",{className:"meet-ask",children:e}):null})}function Or({onClick:e,disabled:t}){return n.jsxs(I,{variant:"ghost",onClick:e,disabled:t,children:[n.jsx(Se,{name:"chevron-left"}),F.brain.back]})}function K8({navigate:e,timezone:t}){var ot;const[s,r]=h.useState(void 0);h.useEffect(()=>{A.session().then(ke=>r(ke.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([]),[j,w]=h.useState(null),[k,g]=h.useState(null),[x,y]=h.useState(!1),[v,N]=h.useState(null),[b,S]=h.useState(null),[C,R]=h.useState(null),[E,P]=h.useState(null),L=h.useMemo(()=>({body:C,actions:E}),[C,E]),[$,T]=h.useState(null),[M,U]=h.useState(!1),K=h.useCallback(()=>U(!0),[]),[_,q]=h.useState(()=>cE()?"running":"idle"),[B,H]=h.useState({}),[ue,re]=h.useState([]),[ie,Ne]=h.useState(0),Z=h.useRef(void 0),ce=h.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),de=h.useRef(e);de.current=e;const Ae=h.useCallback(async(ke=!0,_e=!1)=>{var Vr,z,je,qe,xt,nn,Os,Lt;const[Ce,pt,D,ge,Je,Ge]=await Promise.all([A.onboarding().catch(()=>{}),A.owner().catch(()=>{}),A.providerAccounts().catch(()=>{}),Oe.agents().catch(()=>{}),A.browser().catch(()=>{}),A.providers().catch(()=>{})]);u(D);const gt=(z=(Vr=Ge==null?void 0:Ge.providers.find(sn=>sn.kind==="anthropic"))==null?void 0:Vr.defaultModel)==null?void 0:z.trim();d(gt||void 0),p((pt==null?void 0:pt.zones)??[]),N(((je=Ce==null?void 0:Ce.details)==null?void 0:je.conversationId)??null);const Be=(ge==null?void 0:ge.agents.find(sn=>sn.id===ge.defaultAgentId))??(ge==null?void 0:ge.agents[0]);Be&&w(Be),S(Ce&&!Ce.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:Ce,owner:pt,accounts:D,browser:(xt=Je==null?void 0:Je.browser)==null?void 0:xt.engine,...Be?{assistant:{id:Be.id,name:Be.name,avatar:((nn=Be.avatar)==null?void 0:nn.kind)==="emoji"?Be.avatar.value:""}}:{}},gs=oE(at);if(_e){const sn=L8(at);if(a(sn.answers),o(sn.open),!sn.stay){const Ii=(Os=Ce==null?void 0:Ce.details)==null?void 0:Os.conversationId;de.current(Ii&&Be?Ke(Be.id,Ii):zt,!0)}return}if(ke&&(Ce==null?void 0:Ce.state)==="done"){const sn=(Lt=Ce.details)==null?void 0:Lt.conversationId;de.current(sn&&Be?Ke(Be.id,sn):zt,!0);return}ke&&(a(gs),o(sn=>sn??Yc(gs)))},[]);h.useEffect(()=>{Ae()},[Ae]);const ne=(ke,_e={})=>{A.onboardingStep(aE[ke],_e).catch(()=>{})},be=ke=>{let _e=ke;for(;;){const Ce=Yc(_e);if(Ce==="brain"&&B.brain)_e={..._e,brain:B.brain};else if(Ce==="browser"&&B.browser)_e={..._e,browser:B.browser};else return _e}},Te=(ke,_e)=>{const Ce=be(_e);Ce.brain&&(Z.current=Ce.brain),g(null),a(Ce),ne(ke,ke==="brain"&&Ce.brain?{accountId:Ce.brain.accountId}:{}),o(Yc(Ce))},Ze=ke=>{g(null),a(_e=>O8(_e,ke)),o(ke)},Ie=()=>{const ke=i.brain??Z.current,_e=i.browser;g(null),H({}),re([]),a({}),o("name"),Ne(Ce=>Ce+1),(async()=>{var gt;const[Ce,pt,D]=await Promise.all([Promise.resolve().then(()=>A.providerAccounts()).catch(()=>{}),Promise.resolve().then(()=>A.telegram()).catch(()=>{}),Promise.resolve().then(()=>A.browser()).catch(()=>{})]),ge=lE(Ce),Je=ke&&ge.some(Be=>Be.id===ke.accountId)?ke:void 0,Ge=_e==="installed"||((gt=D==null?void 0:D.browser)==null?void 0:gt.engine)==="chromium"?"chromium":void 0;Ce&&u(Ce),H({...Je?{brain:Je}:{},...Ge?{browser:Ge}:{}}),re([...new Set(ge.map(Be=>Be.label)),...pt!=null&&pt.paired?[F.startOver.telegram]:[],...Ge?[F.startOver.browser]:[]])})()},it=_==="idle"&&!$&&!M&&l!==null&&(l!=="name"||Object.keys(i).length>0),fe=()=>{y(!0),A.skipOnboarding().then(()=>e(zt)).catch(ke=>g(ke instanceof ae?ke.message:String(ke))).finally(()=>y(!1))},ve=_==="form"||_==="running"?[]:l?_8(i,l):[],Le=se(()=>A.version().catch(()=>({current:""})),[]),Me=h.useRef(null);return h.useEffect(()=>{const ke=Me.current;if(!ke)return;const _e=()=>{ke.scrollTop=ke.scrollHeight};_e();let Ce;try{Ce=new ResizeObserver(_e),ke.firstElementChild&&Ce.observe(ke.firstElementChild)}catch{}return()=>Ce==null?void 0:Ce.disconnect()},[ve.length,l,i,k]),n.jsx(hE.Provider,{value:L,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:Wr("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"?F.tagline:F.taglineElsewhere}),(ot=Le.data)!=null&&ot.current?n.jsxs("span",{className:"meet-head-version mono",children:["buddi ",Le.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(V8,{children:[n.jsx($e,{children:F.opening.map((ke,_e)=>n.jsx(Fe,{at:_e,children:ke},ke))}),n.jsx(G8,{state:_,offered:l==="name"&&i.name===void 0,name:i.name,onState:q,onDone:()=>{q("idle"),Ae(!0,!0)},onTrouble:g}),ue.length>0?n.jsx($e,{children:n.jsx(Fe,{children:F.startOver.said(ue.join(", "))})}):null,ve.map(ke=>n.jsx(Y8,{id:ke,openNow:l===ke,answers:i,accounts:c,claudeModel:f,zones:m,browserZone:ce,assistantAgent:j,met:v,onMet:N,existing:b,navigate:e,onCarriesOn:T,onClosed:K,onSettled:_e=>Te(ke,_e),onChange:()=>Ze(ke),onTrouble:g,onReload:()=>void Ae(!1),onPickAnotherBrain:()=>Ze("brain")},`${ie}-${ke}`)),k?n.jsx($e,{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:[M?n.jsx("span",{}):$?n.jsx("a",{className:"meet-later",href:$,onClick:ke=>{ke.preventDefault(),e($,!0)},children:F.done.open}):n.jsxs("span",{className:"meet-quiet",children:[n.jsx("button",{className:"meet-later",type:"button",disabled:x,onClick:fe,children:F.later}),it?n.jsx("button",{className:"meet-later",type:"button",disabled:x,onClick:Ie,children:F.startOver.link}):null]}),n.jsx("div",{className:"meet-dock-actions",ref:P})]})]})]})]})})})}function G8({state:e,offered:t,name:s,onState:r,onDone:i,onTrouble:a}){const[l,o]=h.useState(()=>cE()),[c,u]=h.useState([]),[f,d]=h.useState(!1),[m,p]=h.useState(null),[j,w]=h.useState(""),[k,g]=h.useState(!1);h.useEffect(()=>{if(!l)return;let v=!1;const N=()=>{A.backupJob(l).then(S=>{v||(u(C=>C.includes(S.phase)?C:[...C,S.phase]),S.phase==="done"?(v=!0,sf(null),d(!0),i()):(S.phase==="rolled-back"||S.phase==="failed")&&(v=!0,sf(null),o(null),a(S.error??F.restore.phases[S.phase]),r("idle")))}).catch(()=>{})};N();const b=window.setInterval(N,uE);return()=>{v=!0,window.clearInterval(b)}},[l]);const x=()=>{!m||k||(g(!0),a(null),A.firstRunRestore(m,j.trim()).then(v=>{sf(v.job.id),o(v.job.id),r("running")}).catch(v=>a(v instanceof ae?v.message:String(v))).finally(()=>g(!1)))},y=c.filter(v=>v in F.restore.phases);return n.jsxs(n.Fragment,{children:[t&&e==="idle"&&!f?n.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:F.restore.offer}):null,e==="form"?n.jsxs(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>r("idle"),children:F.restore.cancel}),n.jsx(I,{variant:"accent",disabled:k||!m,onClick:x,children:F.restore.submit})]}),children:[n.jsx(X,{label:F.restore.file,grow:!0,children:n.jsx("input",{type:"file",onChange:v=>{var N;return p(((N=v.target.files)==null?void 0:N[0])??null)}})}),n.jsx(X,{label:F.restore.passphrase,hint:F.restore.passphraseHint,children:n.jsx("input",{type:"password",autoComplete:"off",value:j,onChange:v=>w(v.target.value)})})]}):null,e==="running"||f?n.jsxs($e,{children:[n.jsx(Fe,{children:F.restore.started}),y.map(v=>n.jsx(Fe,{children:F.restore.phases[v]},v))]}):null,f?n.jsxs($e,{children:[s?n.jsx(Fe,{children:F.restore.welcome(s)}):null,n.jsx(Fe,{children:F.restore.keys})]}):null]})}function Y8(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($e,{children:n.jsx(Fe,{at:1,children:F.name.ask})}),s?n.jsx(q8,{...e}):n.jsx(Sc,{text:r.name??"",onChange:i})]});if(t==="clock")return n.jsxs(n.Fragment,{children:[n.jsx($e,{children:n.jsx(Fe,{at:1,children:F.clock.ask(r.name??"",r.clock??e.browserZone)})}),s?n.jsx(Q8,{...e}):n.jsx(Sc,{text:F.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return n.jsxs(n.Fragment,{children:[n.jsx($e,{children:n.jsx(Fe,{at:1,children:F.brain.ask})}),s?n.jsx(J8,{...e}):n.jsxs(n.Fragment,{children:[n.jsx(Sc,{text:F.brain.answer(((a=r.brain)==null?void 0:a.label)??""),onChange:i}),n.jsxs($e,{children:[n.jsx(Fe,{children:(l=r.brain)!=null&&l.freeTier?F.brain.worksOnFlash(r.brain.model):F.brain.works(((o=r.brain)==null?void 0:o.model)??"")}),n.jsx(uW,{...e})]})]})]});if(t==="browser"){if(s)return n.jsx(xW,{...e});const f=gW(r.browser);return f?n.jsx($e,{children:n.jsx(Fe,{children:f})}):null}return t==="assistant"?n.jsxs(n.Fragment,{children:[n.jsx($e,{children:n.jsx(Fe,{at:1,children:F.assistant.ask})}),s?n.jsx(jW,{...e}):n.jsx(Sc,{text:`${((c=r.assistant)==null?void 0:c.avatar)??""} ${((u=r.assistant)==null?void 0:u.name)??""}`.trim(),onChange:i})]}):n.jsx(yW,{...e})}function q8({answers:e,onSettled:t,onTrouble:s}){const r=Ga(),[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 ae?f.message:String(f))).finally(()=>o(!1)))};return n.jsx(Ct,{actions:n.jsx(I,{variant:"accent",disabled:l||i.trim()==="",onClick:c,children:F.name.submit}),children:n.jsx("input",{ref:r,className:"meet-input","aria-label":F.name.placeholder,placeholder:F.name.placeholder,maxLength:80,value:i,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function Q8({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 ae?p.message:String(p))).finally(()=>f(!1))};return a?n.jsx(Ct,{actions:n.jsx(I,{variant:"accent",disabled:u,onClick:()=>d(o),children:F.clock.yes}),children:n.jsx("select",{className:"meet-input","aria-label":F.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(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>l(!0),children:F.clock.another}),n.jsx(I,{variant:"accent",disabled:u,onClick:()=>d(s),children:F.clock.yes})]})})}function J8(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,j]=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 v=async C=>{if(s.assistant??e.existing)try{await A.bindBrain({accountId:C.accountId,model:C.model})}catch(R){return R instanceof ae?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 L=await A.testProviderAccount(P.id),$=C.defaultModel,T=!1;if(L.state!=="connected"&&E&&E!==$&&pC(L)){const U=(await A.providerAccounts()).accounts.find(K=>K.id===P.id);U&&(await A.saveProviderAccount({id:U.id,revision:U.revision,label:U.label,kind:U.kind,auth:U.auth,baseUrl:U.baseUrl,defaultModel:E,enabled:U.enabled}),L=await A.testProviderAccount(P.id),L.state==="connected"&&($=E,T=!0))}if(L.state!=="connected"){try{const U=(await A.providerAccounts()).accounts.find(K=>K.id===P.id);U&&await A.removeProviderAccount(P.id,U.revision)}catch{}return c(L.message),L}const M=await v({accountId:P.id,label:R,model:$,...T?{freeTier:T}:{}});return M&&c(M),L}catch(P){return c(P instanceof ae?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(L=>L.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 ae?R.message:String(R)),null}finally{f(!1)}},S=(C,R,E)=>{if(C.length<=1){N(R(C[0]??""),E);return}j({models:C,make:R,label:E})};return p?n.jsxs(n.Fragment,{children:[n.jsx($e,{children:n.jsx(Fe,{children:F.brain.model.ask})}),u?n.jsx($e,{children:n.jsx(ds,{line:F.brain.checking.service})}):o?n.jsx($e,{children:n.jsx(Fe,{children:o})}):null,n.jsx(sW,{busy:u,models:p.models,onUse:C=>void N(p.make(C),p.label)})]}):a==="gemini"&&g?n.jsx(iW,{busy:u,problem:o,preset:g,onBack:()=>l(null),onUse:N}):a==="key"?n.jsx(rW,{busy:u,problem:o,onBack:()=>l(null),onUse:N}):a==="service"?n.jsx(lW,{busy:u,problem:o,address:(d==null?void 0:d.cloudBaseUrl)??"",onBack:()=>l(null),onOffer:S,onTrial:b,onUse:N}):a==="ollama"?n.jsx(aW,{busy:u,problem:o,probe:d,onBack:()=>l(null),onOffer:S}):a==="cloud"?n.jsx(cW,{busy:u,consent:x,onBack:()=>{x==null||x.close(),y(null),l(null)},onConnected:v,...e}):a==="chatgpt"?n.jsx(hW,{busy:u,consent:x,onBack:()=>{x==null||x.close(),y(null),l(null)},onConnected:v,...e}):a==="claude"?n.jsx(mW,{busy:u,problem:o,onBack:()=>l(null),onConnected:v,...e}):n.jsx(fE,{children:n.jsxs("div",{className:"meet-cards",role:"group","aria-label":F.brain.ask,children:[w?n.jsx(Xr,{mark:n.jsx(X8,{}),card:F.brain.cards.claude,onPick:()=>l("claude")}):null,k?n.jsx(Xr,{mark:n.jsx(Z8,{}),card:F.brain.cards.chatgpt,onPick:()=>{y(typeof window.open=="function"?window.open("","_blank"):null),l("chatgpt")}}):null,g?n.jsx(Xr,{mark:n.jsx(nW,{}),card:F.brain.cards.gemini,onPick:()=>l("gemini")}):null,n.jsx(Xr,{mark:n.jsx(eW,{}),card:F.brain.cards.key,onPick:()=>l("key")}),n.jsx(Xr,{mark:n.jsx(tW,{}),card:F.brain.cards.ollama,note:d===null?F.brain.ollama.looking:d.running?F.brain.ollama.found:F.brain.ollama.missing,onPick:()=>l("ollama")}),n.jsx(Xr,{mark:n.jsx(Nw,{}),card:F.brain.cards.cloud,onPick:()=>{y(typeof window.open=="function"?window.open("","_blank"):null),l("cloud")}}),n.jsx(Xr,{mark:n.jsx(Nw,{}),card:F.brain.cards.service,onPick:()=>l("service")})]})})}function Xr({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 X8(){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 Z8(){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 eW(){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 tW(){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 nW(){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 Nw(){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 sW({busy:e,models:t,onUse:s}){const[r,i]=h.useState(t[0]??"");return n.jsx(Ct,{actions:n.jsx(I,{variant:"accent",disabled:e||r==="",onClick:()=>s(r),children:F.brain.model.submit}),children:n.jsx(X,{label:F.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 mE({models:e,picked:t,disabled:s,onPick:r}){return n.jsx(X,{label:F.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 rW({busy:e,problem:t,onBack:s,onUse:r}){const i=Ga(),[a,l]=h.useState(""),[o,c]=h.useState(null),[u,f]=h.useState(!1),[d,m]=h.useState([]),[p,j]=h.useState(""),[w,k]=h.useState(!1),g=e||u,x=!w&&t!==null&&d.length>0,y=o??F8(a),v=()=>{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"?F.brain.key.anthropic:F.brain.key.openai,kind:y,auth:"api-key",baseUrl:"",defaultModel:b,enabled:!0,secret:N},y==="anthropic"?F.brain.key.anthropic:F.brain.key.openai);if(!(!C||C.state==="connected")){if(kg(C)){k(!0),m([]);return}m(S.includes(b)||S.length===0?S:[b,...S]),j(b)}})())};return n.jsxs(n.Fragment,{children:[g?n.jsx($e,{children:n.jsx(ds,{line:F.brain.checking.key})}):w?n.jsx($e,{children:n.jsx(Fe,{children:F.brain.key.refused})}):t?n.jsx($e,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:s,disabled:g}),n.jsx(I,{variant:"accent",disabled:g||a.trim()==="",onClick:v,children:x?F.brain.model.retry:F.brain.key.submit})]}),children:[n.jsx(X,{label:F.brain.key.field,grow:!0,children:n.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:F.brain.key.placeholder,value:a,onChange:N=>{l(N.target.value),m([])},onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),v())}})}),x?n.jsx(mE,{models:d,picked:p,disabled:g,onPick:j}):null,n.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(y==="anthropic"?"openai":"anthropic"),children:[y==="anthropic"?F.brain.key.anthropic:F.brain.key.openai," · ",F.brain.key.which]})]})]})}function iW({busy:e,problem:t,preset:s,onBack:r,onUse:i}){const a=Ga(),[l,o]=h.useState(""),[c,u]=h.useState(!1),[f,d]=h.useState([]),[m,p]=h.useState(""),j=e||c,w=t!==null&&f.length>0,k=()=>{const g=l.trim();g===""||j||(u(!0),(async()=>{let x=dC,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=hC(N)??x,y=mC(x)?fC(N):void 0,d(HB(N)),p(y??x)}catch{}u(!1),await i({label:F.brain.gemini.label,kind:"openai-compatible",auth:"api-key",baseUrl:s.baseUrl,defaultModel:x,enabled:!0,secret:g},F.brain.gemini.label,y)})())};return n.jsxs(n.Fragment,{children:[j?n.jsx($e,{children:n.jsx(ds,{line:F.brain.checking.gemini})}):t?n.jsx($e,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:r,disabled:j}),n.jsx(I,{variant:"accent",disabled:j||l.trim()==="",onClick:k,children:F.brain.gemini.submit})]}),children:[n.jsx(X,{label:F.brain.gemini.field,grow:!0,children:n.jsx("input",{ref:a,type:"password",autoComplete:"off",spellCheck:!1,placeholder:F.brain.gemini.placeholder,value:l,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),k())}})}),w?n.jsx(X,{label:F.brain.model.label,grow:!0,children:n.jsx("select",{value:m,disabled:j,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:F.brain.gemini.get})]})]})}function aW({busy:e,problem:t,probe:s,onBack:r,onOffer:i}){const a=(s==null?void 0:s.models)??[],l=()=>{s&&i(a,o=>({label:F.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:s.baseUrl,defaultModel:o,enabled:!0}),F.brain.cards.ollama.title)};return n.jsxs(n.Fragment,{children:[e?n.jsx($e,{children:n.jsx(ds,{line:F.brain.checking.ollama})}):t?n.jsx($e,{children:n.jsx(Fe,{children:t})}):null,n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:r,disabled:e}),s!=null&&s.running?n.jsx(I,{variant:"accent",disabled:e||a.length===0,onClick:l,children:F.brain.ollama.connect}):s?n.jsx(Gt,{variant:"accent",href:s.downloadUrl,target:"_blank",rel:"noreferrer",children:F.brain.ollama.download}):null]}),children:n.jsx("span",{className:"meet-line",children:s===null?F.brain.ollama.looking:s.running?F.brain.ollama.found:F.brain.ollama.missing})})]})}function lW({busy:e,problem:t,address:s,onBack:r,onOffer:i,onTrial:a,onUse:l}){const o=Ga(),[c,u]=h.useState(s),[f,d]=h.useState(""),[m,p]=h.useState(!1),[j,w]=h.useState([]),[k,g]=h.useState(""),[x,y]=h.useState(!1),v=e||m,N=!x&&t!==null&&j.length>0,b=()=>{c.trim()===""||v||(p(!0),y(!1),(async()=>{var M;const S=f.trim()?"api-key":"none",C=U=>({label:F.brain.cards.service.title,kind:"openai-compatible",auth:S,baseUrl:c.trim(),defaultModel:U,enabled:!0,...f.trim()?{secret:f.trim()}:{}}),R=(U,K,_)=>{if(!(!U||U.state==="connected")){if(kg(U)){y(!0),w([]);return}w(K),g(_)}};if(S==="api-key"&&N&&k!==""){p(!1),R(await l(C(k),F.brain.cards.service.title),j,k);return}let E=[],P;try{const U=await A.probeModels({kind:"openai-compatible",auth:S,baseUrl:c.trim(),...f.trim()?{secret:f.trim()}:{}});E=U.models.map(K=>K.id),P=(M=U.models.find(K=>K.isDefault))==null?void 0:M.id}catch{}p(!1);const L=P?[P]:E;if(S==="none"){i(L,C,F.brain.cards.service.title);return}const $=L[0]??"";if(L.length<=1){R(await l(C($),F.brain.cards.service.title),E,$);return}const T=await a(C($));(T==null?void 0:T.state)==="connected"?i(L,C,F.brain.cards.service.title):R(T,E,$)})())};return n.jsxs(n.Fragment,{children:[v?n.jsx($e,{children:n.jsx(ds,{line:F.brain.checking.service})}):x?n.jsx($e,{children:n.jsx(Fe,{children:F.brain.key.refused})}):t?n.jsx($e,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:r,disabled:v}),n.jsx(I,{variant:"accent",disabled:v||c.trim()==="",onClick:b,children:N?F.brain.model.retry:F.brain.service.submit})]}),children:[n.jsx(X,{label:F.brain.service.address,grow:!0,children:n.jsx("input",{ref:o,value:c,placeholder:F.brain.service.addressPlaceholder,onChange:S=>{u(S.target.value),w([])}})}),n.jsx(X,{label:F.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(mE,{models:j,picked:k,disabled:v,onPick:g}):null]})]})}const oW=2e3;function cW({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),j=h.useRef(null),w=F.brain.cloud.label;h.useEffect(()=>{if(p.current===d)return;p.current=d,l(!0),c(null);const g=d===0?t:j.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:Uc,enabled:!0}),v=(await A.providerAccounts()).accounts.find(b=>b.id===y.id),N=await A.ollamaConnect(v.id,v.revision);f({id:v.id,attemptId:N.attemptId,url:N.verificationUrl}),g&&(g.location.href=N.verificationUrl)}catch(x){g==null||g.close(),c(x instanceof ae?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}}},v=window.setInterval(()=>void y(),oW);return()=>{g=!0,window.clearInterval(v)}},[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(Uc)?Uc:x[0],v=(await A.providerAccounts()).accounts.find(b=>b.id===g);v&&v.defaultModel!==y&&await A.saveProviderAccount({id:v.id,revision:v.revision,label:v.label,kind:v.kind,auth:v.auth,baseUrl:v.baseUrl,defaultModel:y,enabled:v.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 ae?x.message:String(x)}};return n.jsxs(n.Fragment,{children:[a||e?n.jsx($e,{children:n.jsx(ds,{line:F.brain.checking.cloud})}):o?n.jsx($e,{children:n.jsx(Fe,{children:o})}):u?n.jsx($e,{children:n.jsx(Fe,{children:F.brain.cloud.waiting})}):null,n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:s,disabled:a||e}),u?n.jsx(Gt,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:F.brain.cloud.open}):o?n.jsx(I,{variant:"accent",disabled:a||e,onClick:()=>{j.current=typeof window.open=="function"?window.open("","_blank"):null,m(g=>g+1)},children:F.brain.cloud.again}):null]})})]})}function uW({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&&VB(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(j=>{p||o(j.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(j){r(j instanceof ae?j.message:String(j))}finally{u(!1)}})())};return n.jsx(Fe,{children:n.jsx(X,{label:F.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 Cw="gpt-5.5",dW=2e3;function hW({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),j=h.useRef(null),w=h.useRef(null),k=F.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:j.current;(async()=>{try{const v=((i==null?void 0:i.accounts)??[]).find(C=>C.kind==="codex"),N=v?{id:v.id}:await A.saveProviderAccount({label:k,kind:"codex",auth:"chatgpt",baseUrl:"",defaultModel:Cw,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)??F.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(v){y==null||y.close(),c(v instanceof ae||v instanceof Error?v.message:String(v))}finally{l(!1)}})()},[d]),h.useEffect(()=>{if(!u)return;let y=!1,v=!1;const N=async()=>{if(!(y||v)){v=!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??F.brain.chatgpt.failed);return}l(!0),c(await g(u.id)),l(!1)}catch{}finally{v=!1}}},b=window.setInterval(()=>void N(),dW);return()=>{y=!0,window.clearInterval(b)}},[u]);const g=async y=>{var v,N;try{const b=(await A.accountModels(y).catch(()=>({models:[]}))).models,S=((v=b.find(R=>R.isDefault))==null?void 0:v.id)??((N=b[0])==null?void 0:N.id)??Cw,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 ae?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($e,{children:n.jsx(ds,{line:F.brain.checking.chatgpt})}):o?n.jsx($e,{children:n.jsx(Fe,{children:o})}):u?n.jsx($e,{children:n.jsxs(Fe,{children:[F.brain.chatgpt.codeBefore,n.jsx("strong",{children:u.code}),F.brain.chatgpt.codeAfter]})}):null,n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:x,disabled:a||e}),u?n.jsx(Gt,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:F.brain.chatgpt.open}):o?n.jsx(I,{variant:"accent",disabled:a||e,onClick:()=>{j.current=typeof window.open=="function"?window.open("","_blank"):null,m(y=>y+1)},children:F.brain.chatgpt.again}):null]}),children:u?n.jsx(gC,{code:u.code,label:F.brain.chatgpt.code}):null})]})}const fW="claude-sonnet-5";function mW({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(""),j=h.useRef(null);h.useEffect(()=>()=>{const y=j.current;j.current=null,y&&A.anthropicAccountAction(y.id,"cancel-login",y.revision).catch(()=>{})},[]);const w=()=>{const y=j.current;j.current=null,y&&A.anthropicAccountAction(y.id,"cancel-login",y.revision).catch(()=>{}),s()},k=a??fW,g=()=>{o(!0),u(null);const y=typeof window.open=="function"?window.open("","_blank"):null;(async()=>{try{const v=((i==null?void 0:i.accounts)??[]).find(R=>R.auth==="anthropic-oauth"),N=v?{id:v.id}:await A.saveProviderAccount({label:F.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);j.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(v){y==null||y.close(),u(v instanceof ae?v.message:String(v))}finally{o(!1)}})()},x=()=>{!f||m.trim()===""||(j.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:F.brain.cards.claude.title,model:k}))}catch(y){u(y instanceof ae?y.message:String(y))}finally{o(!1)}})())};return n.jsxs(n.Fragment,{children:[l||e?n.jsx($e,{children:n.jsx(ds,{line:F.brain.checking.claude})}):t??c?n.jsx($e,{children:n.jsx(Fe,{children:t??c})}):null,f?n.jsxs(n.Fragment,{children:[n.jsx($e,{children:n.jsx(Fe,{children:F.brain.claude.waiting})}),n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:w,disabled:l}),n.jsx(Gt,{href:f.url,target:"_blank",rel:"noreferrer",children:F.brain.claude.open}),n.jsx(I,{variant:"accent",disabled:l||m.trim()==="",onClick:x,children:F.brain.claude.finish})]}),children:n.jsx(X,{label:F.brain.claude.paste,grow:!0,children:n.jsx(pW,{value:m,onChange:p})})})]}):n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Or,{onClick:w,disabled:e||l}),n.jsx(I,{variant:"accent",disabled:e||l,onClick:g,children:F.brain.claude.start})]})})]})}function pW({value:e,onChange:t}){const s=Ga();return n.jsx("input",{ref:s,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function gW(e){switch(e){case"chrome":return F.browser.chrome;case"chromium":return F.browser.chromium;case"installed":return F.browser.installed;case"skipped":return F.browser.skipped;case"none":return F.browser.missing;default:return null}}function xW({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),j=h.useRef(()=>{});if(j.current=k=>{p.current||(p.current=!0,t({...e,browser:k}))},h.useEffect(()=>{let k=!1,g;const x=b=>{k||j.current(b)},y=(b,S)=>{k||(m.current=!1,r("failed"),a(b),o(S??null))},v=async b=>{r("launching");let S;try{S=await A.browserCheck()}catch(C){return y(C instanceof ae?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 v(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 ae?E.message:String(E))}k||(g=window.setTimeout(()=>void N(),1e3))};return N(),()=>{k=!0,window.clearTimeout(g)}},[f]),s==="checking")return n.jsx(ds,{});const w=s==="installing"||s==="launching";return n.jsxs(n.Fragment,{children:[n.jsxs($e,{children:[m.current||s==="installing"?n.jsx(Fe,{children:F.browser.needs}):null,s==="installing"?n.jsx("div",{className:"wb-msg","data-role":"assistant",children:n.jsx("div",{className:"wb-bubble",children:n.jsx(ZN,{progress:c})})}):s==="launching"?n.jsx(ds,{line:F.browser.launching}):n.jsx(Fe,{children:F.browser.failed(i??"")})]}),n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>j.current("skipped"),children:F.browser.skip}),n.jsx(I,{variant:"accent",disabled:w,onClick:()=>{r("launching"),o(null),d(k=>k+1)},children:w?F.browser.installing:F.browser.retry})]}),children:s==="failed"&&l?n.jsx(vW,{command:l}):null})]})}function vW({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(V,{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 jW({answers:e,existing:t,onSettled:s,onTrouble:r,onReload:i}){const[a,l]=h.useState(()=>(t==null?void 0:t.name)??WD),[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:F.assistant.purposeValue),[d,m]=h.useState(t?"":F.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 ae?g.message:String(g))}),()=>{k=!0}},[t==null?void 0:t.id]);const[p,j]=h.useState(!1),w=()=>{if(a.trim()===""||p)return;j(!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:U8(a),description:"",...g,...k,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let y;try{y=await x}catch(N){r(N instanceof ae?N.message:String(N)),j(!1);return}let v=null;try{o.kind==="mascot"?await A.uploadAgentPicture(y.id,await X1(o.role)):o.kind==="emoji"&&(t!=null&&t.picture)&&await A.removeAgentPicture(y.id)}catch(N){v=N instanceof ae?N.message:String(N)}j(!1),i(),s({...e,assistant:{id:y.id,name:a.trim(),avatar:o.kind==="emoji"?o.value:""}}),v&&r(v)})()};return n.jsxs(Ct,{actions:n.jsx(I,{variant:"accent",disabled:p||a.trim()===""||u===null,onClick:w,children:F.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"?Wr(o.role):o.url,alt:""})}),n.jsx(X,{label:F.assistant.name,children:n.jsx("input",{value:a,maxLength:60,onChange:k=>l(k.target.value)})}),n.jsx(Z1,{face:o,onPick:c}),n.jsx(X,{label:F.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 yW({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,j]=h.useState(!1),[w,k]=h.useState(!1),[g,x]=h.useState(!0),[y,v]=h.useState("open"),[N,b]=h.useState(null);h.useEffect(()=>{let M=!1;return Promise.resolve().then(()=>A.telegram()).then(U=>{M||b((U==null?void 0:U.paired)===!0)}).catch(()=>{M||b(!1)}),()=>{M=!0}},[]);const[S,C]=h.useState(!1),R=dE(),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 M=!1;return(async()=>{try{const U=await Oe.startConversation(c.id);if(M)return;f(U.conversationId),r(U.conversationId),await A.onboardingStep(aE.handover,{conversationId:U.conversationId}).catch(()=>{}),await Oe.send(c.id,{conversationId:U.conversationId,text:GD,opening:!0})}catch{M||(x(!1),j(!0))}})(),()=>{M=!0}},[c==null?void 0:c.id,s]),h.useEffect(()=>{if(!u)return;let M=!1;const U=Date.now(),K=()=>{Oe.conversation(u).then(q=>{if(M)return;m(q.messages);const B=Date.now()-U;if(q.messages.some(Ew)){x(!1),j(!1),k(!1);return}const H=q.runs??[],ue=H.some(ie=>ie.finishedAt===null),re=H.length>0&&!ue;k(ue&&B>=z8),(re||B>=W8)&&(x(!1),j(!0))}).catch(()=>{})};K();const _=window.setInterval(K,uE);return()=>{M=!0,window.clearInterval(_)}},[u]);const L=c&&u?Ke(c.id,u):null,$=d.some(Ew);h.useEffect(()=>{$&&L&&i(L)},[$,L,i]),h.useEffect(()=>{if(!S||!L||R)return;const M=window.setTimeout(()=>l(L,!0),H8);return()=>window.clearTimeout(M)},[S,L,R,l]);const T=S&&L!==null;return h.useEffect(()=>{T&&a()},[T,a]),n.jsxs(n.Fragment,{children:[n.jsx(ix,{messages:d,live:[],now:Date.now(),onOpen:()=>{},working:g,agents:P,agentName:(c==null?void 0:c.name)??"",...c?{agentId:c.id}:{},emptyHint:F.handover.waiting,plain:!0,workingLine:F.handover.looking((c==null?void 0:c.name)??"")}),w&&!p?n.jsx($e,{children:n.jsx(Fe,{children:F.handover.slow})}):null,p?n.jsxs(n.Fragment,{children:[n.jsx($e,{children:n.jsx(Fe,{children:F.handover.silent})}),n.jsx(Ct,{actions:n.jsx(I,{variant:"accent",onClick:o,children:F.handover.again})})]}):null,S?n.jsx($e,{children:n.jsx(Fe,{children:F.done.said})}):null,$&&N!==null&&!p?n.jsx($e,{children:n.jsx(Fe,{children:N?F.offers.paired((c==null?void 0:c.name)??""):F.offers.said((c==null?void 0:c.name)??"")})}):null,$&&N!==null&&y==="open"?n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:N?"accent":"default",onClick:()=>{v("gone"),C(!0)},children:F.offers.notNow}),N?null:n.jsx(I,{variant:"accent",onClick:()=>v("phone"),children:F.offers.phone})]})}):null,$&&y==="phone"?n.jsx(wW,{onPaired:()=>C(!0),onDismiss:()=>{v("gone"),C(!0)}}):null,T&&L?n.jsx(Ct,{actions:n.jsx(Gt,{variant:"accent",href:L,onClick:M=>{M.preventDefault(),l(L,!0)},children:F.done.open}),children:n.jsx("span",{className:"meet-line",children:R?F.done.ready:F.done.leaving})}):null]})}function Ew(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function wW({onPaired:e,onDismiss:t}){const s=Ga(),[r,i]=h.useState(""),[a,l]=h.useState(!1),[o,c]=h.useState(null),{offer:u,square:f,paired:d,stale:m,ask:p}=tE(()=>A.telegram().then(k=>k.paired),e),j=()=>{r.trim()===""||a||(l(!0),c(null),(async()=>{try{const k=await A.saveTelegramToken(r.trim());if(i(""),k.restartNeeded){c(k.note??F.telegram.restart);return}await p()}catch(k){c(k instanceof ae?k.message:String(k))}finally{l(!1)}})())},w=()=>{c(null),p().catch(k=>c(k instanceof ae?k.message:String(k)))};return d?n.jsx($e,{children:n.jsx(Fe,{children:F.telegram.paired})}):u?n.jsxs(n.Fragment,{children:[n.jsx($e,{children:n.jsx(Fe,{children:m?F.telegram.expired:F.telegram.scan})}),n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:t,children:F.offers.notNow}),m?n.jsx(I,{variant:"accent",onClick:w,children:F.telegram.newCode}):null]}),children:m?null:n.jsx(nE,{offer:u,square:f})})]}):n.jsxs(n.Fragment,{children:[n.jsxs($e,{children:[n.jsx(Fe,{children:F.telegram.how}),o?n.jsx(Fe,{children:o}):null]}),n.jsx(Ct,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:t,children:F.offers.notNow}),n.jsx(I,{variant:"accent",disabled:a||r.trim()==="",onClick:j,children:F.telegram.submit})]}),children:n.jsx(X,{label:F.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(),j())}})})})]})}const bW="(max-width: 1080px)";function kW(){const[e,t]=h.useState(()=>window.location.hash||zt);h.useEffect(()=>{const r=()=>t(window.location.hash||zt);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 SW(){const[e,t]=U1();h.useEffect(()=>{F1(e)},[e]);const s=h.useCallback(r=>t({theme:r}),[t]);return[e.theme,s]}const Aw=new Map;function NW(){var _e,Ce,pt;const[e,t]=kW(),[s,r]=h.useState("UTC"),[i,a]=h.useState({approvals:0,failed:0}),[l,o]=SW(),c=Aa(gx),[u,f]=h.useState(!1),[d,m]=h.useState([]),[p,j]=h.useState(null),[w,k]=h.useState(null),[g,x]=h.useState([]),[y,v]=h.useState(!1),[N,b]=h.useState(null),S=CD(),C=d.find(D=>D.id===p)??null,R=C!==null&&G4(e),[E,P]=h.useState(!1),L=h.useCallback(()=>P(!0),[]);h.useEffect(()=>{R||P(!1)},[R]),F6(t,Wc(e)===null,R?L:void 0);const $=Aa(bW),T=lC(),M=T1(),U=$1(),K=se(()=>Promise.resolve().then(()=>A.version()),[],dD),_=K.data;wD(K.reload);const q=_&&!_.checkout&&_.updateAvailable?_:null,B=Hg(_==null?void 0:_.web);bD(_==null?void 0:_.web);const H=((_e=se(()=>Promise.resolve().then(()=>A.connectionSignals()),[],6e4).data)==null?void 0:_e.signals)??[],[ue,re]=h.useState(new Map);h.useEffect(()=>{const D=()=>{A.conversations().then(Je=>{const Ge=new Map;for(const gt of Je.conversations){const Be=gt.lastMessageAt??gt.createdAt,at=Ge.get(gt.agentId);(!at||Be>at)&&Ge.set(gt.agentId,Be)}re(Ge)}).catch(()=>{})};D();const ge=window.setInterval(D,3e4);return()=>window.clearInterval(ge)},[e]);const[ie,Ne]=h.useState(!1);h.useEffect(()=>{if(ie)return;let D=!1;return A.onboarding().then(ge=>{D||(Ne(!0),ge.state==="pending"&&ge.needs.model&&!Wc(window.location.hash)&&t(F$,!0))}).catch(()=>{D||Ne(!0)}),()=>{D=!0}},[ie,t]),h.useEffect(()=>{const D=X$(e);D&&t(D,!0)},[e,t]),h.useEffect(()=>{let D=!1;const ge=()=>{Oe.agents().then(Ge=>{D||(m(Ge.agents),iD(Ge.defaultAgentId??null),j(Ge.defaultAgentId??null),k(gt=>{var Be;return gt??Ge.defaultAgentId??((Be=Ge.agents[0])==null?void 0:Be.id)??null}))}).catch(()=>{})};ge();const Je=window.setInterval(ge,15e3);return window.addEventListener("focus",ge),window.addEventListener(to,ge),()=>{D=!0,window.clearInterval(Je),window.removeEventListener("focus",ge),window.removeEventListener(to,ge)}},[e]),h.useEffect(()=>{let D=!1;const ge=()=>{Oe.groups().then(Ge=>{D||x(Ge.groups)}).catch(()=>{})};ge();const Je=window.setInterval(ge,3e4);return()=>{D=!0,window.clearInterval(Je)}},[e]);const Z=XS(d,p),ce=B$(e),de=GS(e),Ae=de?g.find(D=>D.id===de.groupId)??null:null,ne=de?null:(ce==null?void 0:ce.agentId)??w;h.useEffect(()=>{ce&&k(ce.agentId)},[ce==null?void 0:ce.agentId]);const be=D=>{k(D),t(Ke(D))},Te=D=>t(Cl(D)),Ze=h.useCallback((D,ge,Je=!0)=>t(de?Cl(de.groupId,ge):Ke(D,ge),Je),[t,de==null?void 0:de.groupId]),[Ie,it]=h.useState(!1);h.useEffect(()=>{A.session().then(D=>{r(D.timezone),it(!0)}).catch(()=>{})},[]);const fe=n3(Ie);l3(Ie,fe.refresh,()=>it(!1)),h.useEffect(()=>{const D=()=>{A.overview().then(Je=>a({approvals:Je.approvals.pending,failed:Je.jobs.failed??0})).catch(()=>{})};D();const ge=window.setInterval(D,2e4);return()=>window.clearInterval(ge)},[]),h.useEffect(()=>{if(!Ie)return;if(e===Z$){v(!0),t(Cr,!0);return}const D=eD(e),ge=new Date().toDateString();!D||Aw.get(D)===ge||(Aw.set(D,ge),A.tipsSeenPage(D).catch(()=>{}))},[e,Ie,t]);const ve=Wc(e),Le=qS(e),Me=Le===Cr,ot=N?g.find(D=>D.id===N)??null:null,ke=y?n.jsx(By,{agents:d,onClose:()=>v(!1),onCreated:D=>{x(ge=>[...ge,D]),v(!1),t(Cl(D.id))}}):ot?n.jsx(By,{agents:d,group:ot,onClose:()=>b(null),onSaved:D=>{x(ge=>ge.map(Je=>Je.id===D.id?D:Je)),b(null)},onArchived:D=>{x(ge=>ge.filter(Je=>Je.id!==D)),b(null),t(Cr)}}):null;return ve?n.jsx(Oj,{delayDuration:400,children:n.jsxs(Sj,{swipeDirection:"right",children:[n.jsx(K8,{navigate:t,timezone:s}),n.jsx(Nj,{className:"ui-toasts"})]})}):n.jsx(JD,{picture:(Ce=d.find(D=>D.id===p))==null?void 0:Ce.picture,children:n.jsx(Oj,{delayDuration:400,children:n.jsxs(Sj,{swipeDirection:"right",children:[ke,n.jsxs("div",{className:"wb-shell",children:[n.jsx(IB,{active:((pt=T.data)==null?void 0:pt.active)===!0,onNavigate:t}),n.jsxs("div",{className:"wb",children:[n.jsx(E6,{attention:i.approvals+i.failed,place:Le,onNavigate:t,theme:l,onTheme:o,plugins:O6(M.rail,U),updateAvailable:q!==null,settingsDot:H.length>0?P1:void 0,stale:B,timezone:s,version:_&&!_.checkout?{current:_.current,latest:_.latest,updateAvailable:_.updateAvailable}:_?{current:_.current,updateAvailable:!1}:void 0}),Me&&!$?n.jsx(rN,{agents:Z,currentId:ne,attention:S,onSelect:be,lastActivity:ue,groups:g,currentGroupId:(Ae==null?void 0:Ae.id)??null,onSelectGroup:Te,onNewGroup:()=>v(!0)}):null,Me?n.jsx(_4,{timezone:s,agents:Z,agentId:Ae?Ae.coordinator:ne,defaultAgentId:p,group:Ae,onEditGroup:Ae?()=>b(Ae.id):void 0,requestedConversationId:(de==null?void 0:de.conversationId)??(ce==null?void 0:ce.conversationId),requestedTab:ce==null?void 0:ce.tab,onConversationOpened:Ze,onSelectAgent:be,attention:S,agentsInHeader:$,narrow:c,canvasOpen:u,onOpenCanvas:()=>f(!0),onCloseCanvas:()=>f(!1)}):n.jsx("main",{"data-ground":CW(Le,e)?"plain":void 0,"data-layout":Le===pn?"split":void 0,children:n.jsx(EW,{hash:e,place:Le,timezone:s,navigate:t,agents:d,defaultAgentId:p,attention:S,pluginPages:M,update:q,connectionSignals:H})})]})]}),R&&C?n.jsx(Y4,{agent:C,agents:d,open:E,onOpenChange:P,navigate:t}):null,n.jsxs(e3,{placement:Z4(R,E),children:[n.jsx(s3,{queue:fe.queue,agents:d,navigate:t,onDismiss:fe.dismiss}),n.jsx(Nj,{className:"ui-toasts"})]})]})})})}function CW(e,t){return Ug(t)!==null}function EW({place:e,pluginPages:t,...s}){const r={...s,pluginPages:t},i=Ug(s.hash);if(i){const a=t.find(i.plugin,i.page);if(a)return n.jsx(A1,{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(WU,{...s});case jt:return n.jsx(Z6,{...s});case pn:return n.jsx(f8,{...r});case vi:return n.jsx(k6,{...s});default:return n.jsx(pB,{...s})}}function AW(){"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=`./sw.js?v=${encodeURIComponent(Wg)}`;navigator.serviceWorker.register(e,{scope:"./"}).catch(()=>{})})}const pE=1e4,TW=3e4,gE=6e3,RW=/^(localhost|127(?:\.\d{1,3}){3}|\[?::1\]?)$|\.localhost$/i;function IW(e){return RW.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 xE(e){let t;const s=new Promise((r,i)=>{t=setTimeout(()=>i(new ae(0,ku)),e)});try{return{up:!0,version:await Promise.race([A.version(),s])}}catch(r){return HI(r)?{up:!1}:{up:!0}}finally{clearTimeout(t)}}function vE(e){var t;return e.up&&Hg((t=e.version)==null?void 0:t.web)?(window.location.reload(),!1):e.up}function PW({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:Wr("core"),alt:""})}),n.jsxs("h1",{children:["buddi isn't answering at ",e,"."]}),n.jsx("p",{children:IW(e.replace(/:\d+$/,""))}),n.jsx("div",{className:"unreachable-actions",children:n.jsx(I,{variant:"accent",onClick:t,disabled:s,children:s?"Retrying…":"Retry"})})]})}function MW({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 xE(gE);a.current=!1,i(!1),s(c=>c==="checking"?o.up?"up":"down":vE(o)?"up":"down")},[]);return h.useEffect(()=>{l()},[l]),h.useEffect(()=>{if(t!=="down")return;const o=window.setInterval(()=>void l(),pE);return()=>window.clearInterval(o)},[t,l]),t==="checking"?null:t==="down"?n.jsx(PW,{host:window.location.host,onRetry:()=>void l(),retrying:r}):n.jsxs(n.Fragment,{children:[n.jsx(DW,{}),e]})}function $W(e=TW){const[t,s]=h.useState(!1);return h.useEffect(()=>{let r;const i=()=>{clearTimeout(r);const l=zI();if(l===null)return s(!1);const o=l+e-Date.now();o<=0?s(!0):r=setTimeout(i,o)};i();const a=WI(i);return()=>{a(),clearTimeout(r)}},[e]),t}function DW(){const e=$W();return h.useEffect(()=>{if(!e)return;const t=window.setInterval(()=>{xE(gE).then(vE)},pE);return()=>window.clearInterval(t)},[e]),e?n.jsx("div",{className:"lost-bar",role:"status",children:"Lost buddi. Retrying…"}):null}function _W({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(MC);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(V,{gap:"lg",children:[n.jsx("h2",{className:"ui-page-title",children:"Connections"}),t===null?n.jsx(W,{tone:"accent",role:"status",children:"Finishing the sign-in…"}):null,t!=null&&t.ok?n.jsx(W,{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(W,{tone:"critical",role:"alert",title:"Nothing was connected",children:t.message}):null,t?n.jsx(Gt,{href:"/#/settings/connections",children:"Back to Connections"}):null]})})}const Tw=document.getElementById("root");Tw&&z0(Tw).render(n.jsx(h.StrictMode,{children:location.pathname==="/connections/callback"?n.jsx(_W,{}):n.jsx(MW,{children:n.jsx(NW,{})})}));AW();export{LW as c,UE as g};