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

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 (483) hide show
  1. package/README.md +10 -4
  2. package/extension/background.js +38 -7
  3. package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
  4. package/node_modules/@buddi/cli/dist/args.d.ts +7 -0
  5. package/node_modules/@buddi/cli/dist/args.d.ts.map +1 -1
  6. package/node_modules/@buddi/cli/dist/args.js +14 -0
  7. package/node_modules/@buddi/cli/dist/args.js.map +1 -1
  8. package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
  9. package/node_modules/@buddi/cli/dist/commands.js +36 -1
  10. package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
  11. package/node_modules/@buddi/cli/dist/dashboard-app.d.ts +6 -0
  12. package/node_modules/@buddi/cli/dist/dashboard-app.d.ts.map +1 -1
  13. package/node_modules/@buddi/cli/dist/dashboard-app.js +16 -1
  14. package/node_modules/@buddi/cli/dist/dashboard-app.js.map +1 -1
  15. package/node_modules/@buddi/cli/dist/doctor-probes.d.ts.map +1 -1
  16. package/node_modules/@buddi/cli/dist/doctor-probes.js +5 -2
  17. package/node_modules/@buddi/cli/dist/doctor-probes.js.map +1 -1
  18. package/node_modules/@buddi/cli/dist/doctor.d.ts +16 -0
  19. package/node_modules/@buddi/cli/dist/doctor.d.ts.map +1 -1
  20. package/node_modules/@buddi/cli/dist/doctor.js +18 -0
  21. package/node_modules/@buddi/cli/dist/doctor.js.map +1 -1
  22. package/node_modules/@buddi/cli/dist/index.d.ts +1 -0
  23. package/node_modules/@buddi/cli/dist/index.d.ts.map +1 -1
  24. package/node_modules/@buddi/cli/dist/index.js +1 -0
  25. package/node_modules/@buddi/cli/dist/index.js.map +1 -1
  26. package/node_modules/@buddi/cli/dist/main.d.ts.map +1 -1
  27. package/node_modules/@buddi/cli/dist/main.js +10 -0
  28. package/node_modules/@buddi/cli/dist/main.js.map +1 -1
  29. package/node_modules/@buddi/cli/dist/uninstall-cmd.d.ts +42 -0
  30. package/node_modules/@buddi/cli/dist/uninstall-cmd.d.ts.map +1 -0
  31. package/node_modules/@buddi/cli/dist/uninstall-cmd.js +208 -0
  32. package/node_modules/@buddi/cli/dist/uninstall-cmd.js.map +1 -0
  33. package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
  34. package/node_modules/@buddi/core/dist/agents/models.d.ts.map +1 -1
  35. package/node_modules/@buddi/core/dist/agents/models.js +4 -3
  36. package/node_modules/@buddi/core/dist/agents/models.js.map +1 -1
  37. package/node_modules/@buddi/core/dist/agents/skills.d.ts +2 -2
  38. package/node_modules/@buddi/core/dist/goals/frequency.d.ts +51 -0
  39. package/node_modules/@buddi/core/dist/goals/frequency.d.ts.map +1 -0
  40. package/node_modules/@buddi/core/dist/goals/frequency.js +113 -0
  41. package/node_modules/@buddi/core/dist/goals/frequency.js.map +1 -0
  42. package/node_modules/@buddi/core/dist/goals/index.d.ts +2 -0
  43. package/node_modules/@buddi/core/dist/goals/index.d.ts.map +1 -1
  44. package/node_modules/@buddi/core/dist/goals/index.js +2 -0
  45. package/node_modules/@buddi/core/dist/goals/index.js.map +1 -1
  46. package/node_modules/@buddi/core/dist/goals/math.d.ts +8 -2
  47. package/node_modules/@buddi/core/dist/goals/math.d.ts.map +1 -1
  48. package/node_modules/@buddi/core/dist/goals/math.js +17 -4
  49. package/node_modules/@buddi/core/dist/goals/math.js.map +1 -1
  50. package/node_modules/@buddi/core/dist/goals/owner.d.ts +129 -0
  51. package/node_modules/@buddi/core/dist/goals/owner.d.ts.map +1 -0
  52. package/node_modules/@buddi/core/dist/goals/owner.js +239 -0
  53. package/node_modules/@buddi/core/dist/goals/owner.js.map +1 -0
  54. package/node_modules/@buddi/core/dist/goals/store.d.ts.map +1 -1
  55. package/node_modules/@buddi/core/dist/goals/store.js +11 -4
  56. package/node_modules/@buddi/core/dist/goals/store.js.map +1 -1
  57. package/node_modules/@buddi/core/dist/goals/types.d.ts +17 -3
  58. package/node_modules/@buddi/core/dist/goals/types.d.ts.map +1 -1
  59. package/node_modules/@buddi/core/dist/goals/types.js +8 -2
  60. package/node_modules/@buddi/core/dist/goals/types.js.map +1 -1
  61. package/node_modules/@buddi/core/dist/learning/announce.d.ts +29 -0
  62. package/node_modules/@buddi/core/dist/learning/announce.d.ts.map +1 -0
  63. package/node_modules/@buddi/core/dist/learning/announce.js +49 -0
  64. package/node_modules/@buddi/core/dist/learning/announce.js.map +1 -0
  65. package/node_modules/@buddi/core/dist/learning/index.d.ts +1 -0
  66. package/node_modules/@buddi/core/dist/learning/index.d.ts.map +1 -1
  67. package/node_modules/@buddi/core/dist/learning/index.js +1 -0
  68. package/node_modules/@buddi/core/dist/learning/index.js.map +1 -1
  69. package/node_modules/@buddi/core/dist/learning/store.d.ts.map +1 -1
  70. package/node_modules/@buddi/core/dist/learning/store.js +15 -4
  71. package/node_modules/@buddi/core/dist/learning/store.js.map +1 -1
  72. package/node_modules/@buddi/core/dist/notifications/notify.d.ts.map +1 -1
  73. package/node_modules/@buddi/core/dist/notifications/notify.js +1 -0
  74. package/node_modules/@buddi/core/dist/notifications/notify.js.map +1 -1
  75. package/node_modules/@buddi/core/dist/notifications/store.d.ts +2 -0
  76. package/node_modules/@buddi/core/dist/notifications/store.d.ts.map +1 -1
  77. package/node_modules/@buddi/core/dist/notifications/store.js +9 -0
  78. package/node_modules/@buddi/core/dist/notifications/store.js.map +1 -1
  79. package/node_modules/@buddi/core/dist/notifications/types.d.ts +6 -0
  80. package/node_modules/@buddi/core/dist/notifications/types.d.ts.map +1 -1
  81. package/node_modules/@buddi/core/dist/pages.d.ts +2 -2
  82. package/node_modules/@buddi/core/dist/sentinels/run.d.ts.map +1 -1
  83. package/node_modules/@buddi/core/dist/sentinels/run.js +4 -1
  84. package/node_modules/@buddi/core/dist/sentinels/run.js.map +1 -1
  85. package/node_modules/@buddi/core/dist/sentinels/types.d.ts +20 -0
  86. package/node_modules/@buddi/core/dist/sentinels/types.d.ts.map +1 -1
  87. package/node_modules/@buddi/core/dist/sentinels/types.js.map +1 -1
  88. package/node_modules/@buddi/core/dist/surfaces.d.ts +2 -0
  89. package/node_modules/@buddi/core/dist/surfaces.d.ts.map +1 -1
  90. package/node_modules/@buddi/core/dist/surfaces.js +7 -0
  91. package/node_modules/@buddi/core/dist/surfaces.js.map +1 -1
  92. package/node_modules/@buddi/core/dist/uninstall.d.ts +79 -0
  93. package/node_modules/@buddi/core/dist/uninstall.d.ts.map +1 -0
  94. package/node_modules/@buddi/core/dist/uninstall.js +109 -0
  95. package/node_modules/@buddi/core/dist/uninstall.js.map +1 -0
  96. package/node_modules/@buddi/core/dist/views.d.ts +66 -66
  97. package/node_modules/@buddi/core/migrations/044_owner_metrics.sql +45 -0
  98. package/node_modules/@buddi/core/migrations/045_frequency_goals.sql +19 -0
  99. package/node_modules/@buddi/core/package.json +4 -0
  100. package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
  101. package/node_modules/@buddi/gateway/dist/chat/usage.d.ts.map +1 -1
  102. package/node_modules/@buddi/gateway/dist/chat/usage.js +1 -0
  103. package/node_modules/@buddi/gateway/dist/chat/usage.js.map +1 -1
  104. package/node_modules/@buddi/gateway/dist/index.d.ts +1 -0
  105. package/node_modules/@buddi/gateway/dist/index.d.ts.map +1 -1
  106. package/node_modules/@buddi/gateway/dist/index.js +1 -0
  107. package/node_modules/@buddi/gateway/dist/index.js.map +1 -1
  108. package/node_modules/@buddi/gateway/dist/missions/agent-run.d.ts.map +1 -1
  109. package/node_modules/@buddi/gateway/dist/missions/agent-run.js +1 -0
  110. package/node_modules/@buddi/gateway/dist/missions/agent-run.js.map +1 -1
  111. package/node_modules/@buddi/gateway/dist/missions/execute.d.ts +7 -0
  112. package/node_modules/@buddi/gateway/dist/missions/execute.d.ts.map +1 -1
  113. package/node_modules/@buddi/gateway/dist/missions/execute.js +3 -1
  114. package/node_modules/@buddi/gateway/dist/missions/execute.js.map +1 -1
  115. package/node_modules/@buddi/gateway/dist/missions/goals-format.d.ts +32 -5
  116. package/node_modules/@buddi/gateway/dist/missions/goals-format.d.ts.map +1 -1
  117. package/node_modules/@buddi/gateway/dist/missions/goals-format.js +59 -2
  118. package/node_modules/@buddi/gateway/dist/missions/goals-format.js.map +1 -1
  119. package/node_modules/@buddi/gateway/dist/missions/goals-page.d.ts +60 -5
  120. package/node_modules/@buddi/gateway/dist/missions/goals-page.d.ts.map +1 -1
  121. package/node_modules/@buddi/gateway/dist/missions/goals-page.js +355 -8
  122. package/node_modules/@buddi/gateway/dist/missions/goals-page.js.map +1 -1
  123. package/node_modules/@buddi/gateway/dist/missions/goals.d.ts +64 -5
  124. package/node_modules/@buddi/gateway/dist/missions/goals.d.ts.map +1 -1
  125. package/node_modules/@buddi/gateway/dist/missions/goals.js +834 -116
  126. package/node_modules/@buddi/gateway/dist/missions/goals.js.map +1 -1
  127. package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.d.ts +5 -0
  128. package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.d.ts.map +1 -1
  129. package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.js +12 -0
  130. package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.js.map +1 -1
  131. package/node_modules/@buddi/gateway/dist/owner-notify.d.ts +2 -1
  132. package/node_modules/@buddi/gateway/dist/owner-notify.d.ts.map +1 -1
  133. package/node_modules/@buddi/gateway/dist/owner-notify.js +6 -2
  134. package/node_modules/@buddi/gateway/dist/owner-notify.js.map +1 -1
  135. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
  136. package/node_modules/@buddi/gateway/dist/provider-accounts.js +22 -13
  137. package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
  138. package/node_modules/@buddi/gateway/dist/serve.d.ts.map +1 -1
  139. package/node_modules/@buddi/gateway/dist/serve.js +1 -0
  140. package/node_modules/@buddi/gateway/dist/serve.js.map +1 -1
  141. package/node_modules/@buddi/gateway/dist/subscription-signins.d.ts +28 -0
  142. package/node_modules/@buddi/gateway/dist/subscription-signins.d.ts.map +1 -0
  143. package/node_modules/@buddi/gateway/dist/subscription-signins.js +30 -0
  144. package/node_modules/@buddi/gateway/dist/subscription-signins.js.map +1 -0
  145. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts +43 -9
  146. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts.map +1 -1
  147. package/node_modules/@buddi/gateway/dist/telegram/api.js +80 -21
  148. package/node_modules/@buddi/gateway/dist/telegram/api.js.map +1 -1
  149. package/node_modules/@buddi/gateway/dist/telegram/attachments.d.ts +6 -0
  150. package/node_modules/@buddi/gateway/dist/telegram/attachments.d.ts.map +1 -1
  151. package/node_modules/@buddi/gateway/dist/telegram/attachments.js +1 -0
  152. package/node_modules/@buddi/gateway/dist/telegram/attachments.js.map +1 -1
  153. package/node_modules/@buddi/gateway/dist/telegram/browser-view.d.ts.map +1 -1
  154. package/node_modules/@buddi/gateway/dist/telegram/browser-view.js +2 -1
  155. package/node_modules/@buddi/gateway/dist/telegram/browser-view.js.map +1 -1
  156. package/node_modules/@buddi/gateway/dist/telegram/channel.d.ts +7 -1
  157. package/node_modules/@buddi/gateway/dist/telegram/channel.d.ts.map +1 -1
  158. package/node_modules/@buddi/gateway/dist/telegram/channel.js +24 -2
  159. package/node_modules/@buddi/gateway/dist/telegram/channel.js.map +1 -1
  160. package/node_modules/@buddi/gateway/dist/telegram/commands.d.ts +28 -0
  161. package/node_modules/@buddi/gateway/dist/telegram/commands.d.ts.map +1 -0
  162. package/node_modules/@buddi/gateway/dist/telegram/commands.js +74 -0
  163. package/node_modules/@buddi/gateway/dist/telegram/commands.js.map +1 -0
  164. package/node_modules/@buddi/gateway/dist/telegram/main.d.ts +3 -0
  165. package/node_modules/@buddi/gateway/dist/telegram/main.d.ts.map +1 -1
  166. package/node_modules/@buddi/gateway/dist/telegram/main.js +71 -2
  167. package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
  168. package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts +191 -0
  169. package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts.map +1 -0
  170. package/node_modules/@buddi/gateway/dist/telegram/outbound.js +671 -0
  171. package/node_modules/@buddi/gateway/dist/telegram/outbound.js.map +1 -0
  172. package/node_modules/@buddi/gateway/dist/telegram/proposals.d.ts +65 -0
  173. package/node_modules/@buddi/gateway/dist/telegram/proposals.d.ts.map +1 -0
  174. package/node_modules/@buddi/gateway/dist/telegram/proposals.js +183 -0
  175. package/node_modules/@buddi/gateway/dist/telegram/proposals.js.map +1 -0
  176. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +47 -47
  177. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
  178. package/node_modules/@buddi/gateway/dist/telegram/surface.js +99 -290
  179. package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
  180. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
  181. package/node_modules/@buddi/gateway/dist/web/onboarding.js +4 -0
  182. package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
  183. package/node_modules/@buddi/gateway/dist/web/secrets.d.ts.map +1 -1
  184. package/node_modules/@buddi/gateway/dist/web/secrets.js +3 -2
  185. package/node_modules/@buddi/gateway/dist/web/secrets.js.map +1 -1
  186. package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
  187. package/node_modules/@buddi/gateway/dist/web/server.js +20 -1
  188. package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
  189. package/node_modules/@buddi/gateway/dist/web/telegram.d.ts +39 -0
  190. package/node_modules/@buddi/gateway/dist/web/telegram.d.ts.map +1 -1
  191. package/node_modules/@buddi/gateway/dist/web/telegram.js +53 -1
  192. package/node_modules/@buddi/gateway/dist/web/telegram.js.map +1 -1
  193. package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
  194. package/node_modules/@buddi/install/dist/launcher.d.ts.map +1 -1
  195. package/node_modules/@buddi/install/dist/launcher.js +135 -10
  196. package/node_modules/@buddi/install/dist/launcher.js.map +1 -1
  197. package/node_modules/@buddi/install/dist/uninstall.d.ts +59 -0
  198. package/node_modules/@buddi/install/dist/uninstall.d.ts.map +1 -0
  199. package/node_modules/@buddi/install/dist/uninstall.js +260 -0
  200. package/node_modules/@buddi/install/dist/uninstall.js.map +1 -0
  201. package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
  202. package/node_modules/@buddi/runtime/dist/context-window.d.ts.map +1 -1
  203. package/node_modules/@buddi/runtime/dist/context-window.js +5 -2
  204. package/node_modules/@buddi/runtime/dist/context-window.js.map +1 -1
  205. package/node_modules/@buddi/runtime/dist/openai.d.ts.map +1 -1
  206. package/node_modules/@buddi/runtime/dist/openai.js +17 -2
  207. package/node_modules/@buddi/runtime/dist/openai.js.map +1 -1
  208. package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
  209. package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
  210. package/node_modules/@buddi/tool-browser/dist/index.d.ts +1 -1
  211. package/node_modules/@buddi/tool-browser/dist/index.d.ts.map +1 -1
  212. package/node_modules/@buddi/tool-browser/dist/index.js +12 -4
  213. package/node_modules/@buddi/tool-browser/dist/index.js.map +1 -1
  214. package/node_modules/@buddi/tool-browser/dist/origin-pattern.d.ts +31 -0
  215. package/node_modules/@buddi/tool-browser/dist/origin-pattern.d.ts.map +1 -0
  216. package/node_modules/@buddi/tool-browser/dist/origin-pattern.js +61 -0
  217. package/node_modules/@buddi/tool-browser/dist/origin-pattern.js.map +1 -0
  218. package/node_modules/@buddi/tool-browser/dist/public-suffixes.d.ts +24 -0
  219. package/node_modules/@buddi/tool-browser/dist/public-suffixes.d.ts.map +1 -0
  220. package/node_modules/@buddi/tool-browser/dist/public-suffixes.js +153 -0
  221. package/node_modules/@buddi/tool-browser/dist/public-suffixes.js.map +1 -0
  222. package/node_modules/@buddi/tool-browser/dist/secrets.d.ts +45 -9
  223. package/node_modules/@buddi/tool-browser/dist/secrets.d.ts.map +1 -1
  224. package/node_modules/@buddi/tool-browser/dist/secrets.js +77 -20
  225. package/node_modules/@buddi/tool-browser/dist/secrets.js.map +1 -1
  226. package/node_modules/@buddi/tool-browser/dist/service.d.ts +10 -0
  227. package/node_modules/@buddi/tool-browser/dist/service.d.ts.map +1 -1
  228. package/node_modules/@buddi/tool-browser/dist/service.js +84 -20
  229. package/node_modules/@buddi/tool-browser/dist/service.js.map +1 -1
  230. package/node_modules/@buddi/tool-browser/dist/types.d.ts +7 -1
  231. package/node_modules/@buddi/tool-browser/dist/types.d.ts.map +1 -1
  232. package/node_modules/@buddi/tool-browser/dist/types.js +7 -1
  233. package/node_modules/@buddi/tool-browser/dist/types.js.map +1 -1
  234. package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
  235. package/node_modules/@buddi/tool-email/dist/tools/read.js +1 -1
  236. package/node_modules/@buddi/tool-email/dist/tools/read.js.map +1 -1
  237. package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
  238. package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
  239. package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
  240. package/node_modules/ws/lib/websocket.js +17 -3
  241. package/node_modules/ws/package.json +1 -1
  242. package/package.json +2 -2
  243. package/packages/cli/dist/.tsbuildinfo +1 -1
  244. package/packages/cli/dist/args.d.ts +7 -0
  245. package/packages/cli/dist/args.d.ts.map +1 -1
  246. package/packages/cli/dist/args.js +14 -0
  247. package/packages/cli/dist/args.js.map +1 -1
  248. package/packages/cli/dist/commands.d.ts.map +1 -1
  249. package/packages/cli/dist/commands.js +36 -1
  250. package/packages/cli/dist/commands.js.map +1 -1
  251. package/packages/cli/dist/dashboard-app.d.ts +6 -0
  252. package/packages/cli/dist/dashboard-app.d.ts.map +1 -1
  253. package/packages/cli/dist/dashboard-app.js +16 -1
  254. package/packages/cli/dist/dashboard-app.js.map +1 -1
  255. package/packages/cli/dist/doctor-probes.d.ts.map +1 -1
  256. package/packages/cli/dist/doctor-probes.js +5 -2
  257. package/packages/cli/dist/doctor-probes.js.map +1 -1
  258. package/packages/cli/dist/doctor.d.ts +16 -0
  259. package/packages/cli/dist/doctor.d.ts.map +1 -1
  260. package/packages/cli/dist/doctor.js +18 -0
  261. package/packages/cli/dist/doctor.js.map +1 -1
  262. package/packages/cli/dist/index.d.ts +1 -0
  263. package/packages/cli/dist/index.d.ts.map +1 -1
  264. package/packages/cli/dist/index.js +1 -0
  265. package/packages/cli/dist/index.js.map +1 -1
  266. package/packages/cli/dist/main.d.ts.map +1 -1
  267. package/packages/cli/dist/main.js +10 -0
  268. package/packages/cli/dist/main.js.map +1 -1
  269. package/packages/cli/dist/uninstall-cmd.d.ts +42 -0
  270. package/packages/cli/dist/uninstall-cmd.d.ts.map +1 -0
  271. package/packages/cli/dist/uninstall-cmd.js +208 -0
  272. package/packages/cli/dist/uninstall-cmd.js.map +1 -0
  273. package/packages/core/dist/.tsbuildinfo +1 -1
  274. package/packages/core/dist/agents/models.d.ts.map +1 -1
  275. package/packages/core/dist/agents/models.js +4 -3
  276. package/packages/core/dist/agents/models.js.map +1 -1
  277. package/packages/core/dist/agents/skills.d.ts +2 -2
  278. package/packages/core/dist/goals/frequency.d.ts +51 -0
  279. package/packages/core/dist/goals/frequency.d.ts.map +1 -0
  280. package/packages/core/dist/goals/frequency.js +113 -0
  281. package/packages/core/dist/goals/frequency.js.map +1 -0
  282. package/packages/core/dist/goals/index.d.ts +2 -0
  283. package/packages/core/dist/goals/index.d.ts.map +1 -1
  284. package/packages/core/dist/goals/index.js +2 -0
  285. package/packages/core/dist/goals/index.js.map +1 -1
  286. package/packages/core/dist/goals/math.d.ts +8 -2
  287. package/packages/core/dist/goals/math.d.ts.map +1 -1
  288. package/packages/core/dist/goals/math.js +17 -4
  289. package/packages/core/dist/goals/math.js.map +1 -1
  290. package/packages/core/dist/goals/owner.d.ts +129 -0
  291. package/packages/core/dist/goals/owner.d.ts.map +1 -0
  292. package/packages/core/dist/goals/owner.js +239 -0
  293. package/packages/core/dist/goals/owner.js.map +1 -0
  294. package/packages/core/dist/goals/store.d.ts.map +1 -1
  295. package/packages/core/dist/goals/store.js +11 -4
  296. package/packages/core/dist/goals/store.js.map +1 -1
  297. package/packages/core/dist/goals/types.d.ts +17 -3
  298. package/packages/core/dist/goals/types.d.ts.map +1 -1
  299. package/packages/core/dist/goals/types.js +8 -2
  300. package/packages/core/dist/goals/types.js.map +1 -1
  301. package/packages/core/dist/learning/announce.d.ts +29 -0
  302. package/packages/core/dist/learning/announce.d.ts.map +1 -0
  303. package/packages/core/dist/learning/announce.js +49 -0
  304. package/packages/core/dist/learning/announce.js.map +1 -0
  305. package/packages/core/dist/learning/index.d.ts +1 -0
  306. package/packages/core/dist/learning/index.d.ts.map +1 -1
  307. package/packages/core/dist/learning/index.js +1 -0
  308. package/packages/core/dist/learning/index.js.map +1 -1
  309. package/packages/core/dist/learning/store.d.ts.map +1 -1
  310. package/packages/core/dist/learning/store.js +15 -4
  311. package/packages/core/dist/learning/store.js.map +1 -1
  312. package/packages/core/dist/notifications/notify.d.ts.map +1 -1
  313. package/packages/core/dist/notifications/notify.js +1 -0
  314. package/packages/core/dist/notifications/notify.js.map +1 -1
  315. package/packages/core/dist/notifications/store.d.ts +2 -0
  316. package/packages/core/dist/notifications/store.d.ts.map +1 -1
  317. package/packages/core/dist/notifications/store.js +9 -0
  318. package/packages/core/dist/notifications/store.js.map +1 -1
  319. package/packages/core/dist/notifications/types.d.ts +6 -0
  320. package/packages/core/dist/notifications/types.d.ts.map +1 -1
  321. package/packages/core/dist/pages.d.ts +2 -2
  322. package/packages/core/dist/sentinels/run.d.ts.map +1 -1
  323. package/packages/core/dist/sentinels/run.js +4 -1
  324. package/packages/core/dist/sentinels/run.js.map +1 -1
  325. package/packages/core/dist/sentinels/types.d.ts +20 -0
  326. package/packages/core/dist/sentinels/types.d.ts.map +1 -1
  327. package/packages/core/dist/sentinels/types.js.map +1 -1
  328. package/packages/core/dist/surfaces.d.ts +2 -0
  329. package/packages/core/dist/surfaces.d.ts.map +1 -1
  330. package/packages/core/dist/surfaces.js +7 -0
  331. package/packages/core/dist/surfaces.js.map +1 -1
  332. package/packages/core/dist/uninstall.d.ts +79 -0
  333. package/packages/core/dist/uninstall.d.ts.map +1 -0
  334. package/packages/core/dist/uninstall.js +109 -0
  335. package/packages/core/dist/uninstall.js.map +1 -0
  336. package/packages/core/dist/views.d.ts +66 -66
  337. package/packages/core/migrations/044_owner_metrics.sql +45 -0
  338. package/packages/core/migrations/045_frequency_goals.sql +19 -0
  339. package/packages/core/package.json +4 -0
  340. package/packages/gateway/dist/.tsbuildinfo +1 -1
  341. package/packages/gateway/dist/chat/usage.d.ts.map +1 -1
  342. package/packages/gateway/dist/chat/usage.js +1 -0
  343. package/packages/gateway/dist/chat/usage.js.map +1 -1
  344. package/packages/gateway/dist/index.d.ts +1 -0
  345. package/packages/gateway/dist/index.d.ts.map +1 -1
  346. package/packages/gateway/dist/index.js +1 -0
  347. package/packages/gateway/dist/index.js.map +1 -1
  348. package/packages/gateway/dist/missions/agent-run.d.ts.map +1 -1
  349. package/packages/gateway/dist/missions/agent-run.js +1 -0
  350. package/packages/gateway/dist/missions/agent-run.js.map +1 -1
  351. package/packages/gateway/dist/missions/execute.d.ts +7 -0
  352. package/packages/gateway/dist/missions/execute.d.ts.map +1 -1
  353. package/packages/gateway/dist/missions/execute.js +3 -1
  354. package/packages/gateway/dist/missions/execute.js.map +1 -1
  355. package/packages/gateway/dist/missions/goals-format.d.ts +32 -5
  356. package/packages/gateway/dist/missions/goals-format.d.ts.map +1 -1
  357. package/packages/gateway/dist/missions/goals-format.js +59 -2
  358. package/packages/gateway/dist/missions/goals-format.js.map +1 -1
  359. package/packages/gateway/dist/missions/goals-page.d.ts +60 -5
  360. package/packages/gateway/dist/missions/goals-page.d.ts.map +1 -1
  361. package/packages/gateway/dist/missions/goals-page.js +355 -8
  362. package/packages/gateway/dist/missions/goals-page.js.map +1 -1
  363. package/packages/gateway/dist/missions/goals.d.ts +64 -5
  364. package/packages/gateway/dist/missions/goals.d.ts.map +1 -1
  365. package/packages/gateway/dist/missions/goals.js +834 -116
  366. package/packages/gateway/dist/missions/goals.js.map +1 -1
  367. package/packages/gateway/dist/missions/sentinel-wake.d.ts +5 -0
  368. package/packages/gateway/dist/missions/sentinel-wake.d.ts.map +1 -1
  369. package/packages/gateway/dist/missions/sentinel-wake.js +12 -0
  370. package/packages/gateway/dist/missions/sentinel-wake.js.map +1 -1
  371. package/packages/gateway/dist/owner-notify.d.ts +2 -1
  372. package/packages/gateway/dist/owner-notify.d.ts.map +1 -1
  373. package/packages/gateway/dist/owner-notify.js +6 -2
  374. package/packages/gateway/dist/owner-notify.js.map +1 -1
  375. package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
  376. package/packages/gateway/dist/provider-accounts.js +22 -13
  377. package/packages/gateway/dist/provider-accounts.js.map +1 -1
  378. package/packages/gateway/dist/serve.d.ts.map +1 -1
  379. package/packages/gateway/dist/serve.js +1 -0
  380. package/packages/gateway/dist/serve.js.map +1 -1
  381. package/packages/gateway/dist/subscription-signins.d.ts +28 -0
  382. package/packages/gateway/dist/subscription-signins.d.ts.map +1 -0
  383. package/packages/gateway/dist/subscription-signins.js +30 -0
  384. package/packages/gateway/dist/subscription-signins.js.map +1 -0
  385. package/packages/gateway/dist/telegram/api.d.ts +43 -9
  386. package/packages/gateway/dist/telegram/api.d.ts.map +1 -1
  387. package/packages/gateway/dist/telegram/api.js +80 -21
  388. package/packages/gateway/dist/telegram/api.js.map +1 -1
  389. package/packages/gateway/dist/telegram/attachments.d.ts +6 -0
  390. package/packages/gateway/dist/telegram/attachments.d.ts.map +1 -1
  391. package/packages/gateway/dist/telegram/attachments.js +1 -0
  392. package/packages/gateway/dist/telegram/attachments.js.map +1 -1
  393. package/packages/gateway/dist/telegram/browser-view.d.ts.map +1 -1
  394. package/packages/gateway/dist/telegram/browser-view.js +2 -1
  395. package/packages/gateway/dist/telegram/browser-view.js.map +1 -1
  396. package/packages/gateway/dist/telegram/channel.d.ts +7 -1
  397. package/packages/gateway/dist/telegram/channel.d.ts.map +1 -1
  398. package/packages/gateway/dist/telegram/channel.js +24 -2
  399. package/packages/gateway/dist/telegram/channel.js.map +1 -1
  400. package/packages/gateway/dist/telegram/commands.d.ts +28 -0
  401. package/packages/gateway/dist/telegram/commands.d.ts.map +1 -0
  402. package/packages/gateway/dist/telegram/commands.js +74 -0
  403. package/packages/gateway/dist/telegram/commands.js.map +1 -0
  404. package/packages/gateway/dist/telegram/main.d.ts +3 -0
  405. package/packages/gateway/dist/telegram/main.d.ts.map +1 -1
  406. package/packages/gateway/dist/telegram/main.js +71 -2
  407. package/packages/gateway/dist/telegram/main.js.map +1 -1
  408. package/packages/gateway/dist/telegram/outbound.d.ts +191 -0
  409. package/packages/gateway/dist/telegram/outbound.d.ts.map +1 -0
  410. package/packages/gateway/dist/telegram/outbound.js +671 -0
  411. package/packages/gateway/dist/telegram/outbound.js.map +1 -0
  412. package/packages/gateway/dist/telegram/proposals.d.ts +65 -0
  413. package/packages/gateway/dist/telegram/proposals.d.ts.map +1 -0
  414. package/packages/gateway/dist/telegram/proposals.js +183 -0
  415. package/packages/gateway/dist/telegram/proposals.js.map +1 -0
  416. package/packages/gateway/dist/telegram/surface.d.ts +47 -47
  417. package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
  418. package/packages/gateway/dist/telegram/surface.js +99 -290
  419. package/packages/gateway/dist/telegram/surface.js.map +1 -1
  420. package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
  421. package/packages/gateway/dist/web/onboarding.js +4 -0
  422. package/packages/gateway/dist/web/onboarding.js.map +1 -1
  423. package/packages/gateway/dist/web/secrets.d.ts.map +1 -1
  424. package/packages/gateway/dist/web/secrets.js +3 -2
  425. package/packages/gateway/dist/web/secrets.js.map +1 -1
  426. package/packages/gateway/dist/web/server.d.ts.map +1 -1
  427. package/packages/gateway/dist/web/server.js +20 -1
  428. package/packages/gateway/dist/web/server.js.map +1 -1
  429. package/packages/gateway/dist/web/telegram.d.ts +39 -0
  430. package/packages/gateway/dist/web/telegram.d.ts.map +1 -1
  431. package/packages/gateway/dist/web/telegram.js +53 -1
  432. package/packages/gateway/dist/web/telegram.js.map +1 -1
  433. package/packages/install/dist/.tsbuildinfo +1 -1
  434. package/packages/install/dist/launcher.d.ts.map +1 -1
  435. package/packages/install/dist/launcher.js +135 -10
  436. package/packages/install/dist/launcher.js.map +1 -1
  437. package/packages/install/dist/uninstall.d.ts +59 -0
  438. package/packages/install/dist/uninstall.d.ts.map +1 -0
  439. package/packages/install/dist/uninstall.js +260 -0
  440. package/packages/install/dist/uninstall.js.map +1 -0
  441. package/packages/runtime/dist/.tsbuildinfo +1 -1
  442. package/packages/runtime/dist/context-window.d.ts.map +1 -1
  443. package/packages/runtime/dist/context-window.js +5 -2
  444. package/packages/runtime/dist/context-window.js.map +1 -1
  445. package/packages/runtime/dist/openai.d.ts.map +1 -1
  446. package/packages/runtime/dist/openai.js +17 -2
  447. package/packages/runtime/dist/openai.js.map +1 -1
  448. package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
  449. package/packages/tools/browser/dist/.tsbuildinfo +1 -1
  450. package/packages/tools/browser/dist/index.d.ts +1 -1
  451. package/packages/tools/browser/dist/index.d.ts.map +1 -1
  452. package/packages/tools/browser/dist/index.js +12 -4
  453. package/packages/tools/browser/dist/index.js.map +1 -1
  454. package/packages/tools/browser/dist/origin-pattern.d.ts +31 -0
  455. package/packages/tools/browser/dist/origin-pattern.d.ts.map +1 -0
  456. package/packages/tools/browser/dist/origin-pattern.js +61 -0
  457. package/packages/tools/browser/dist/origin-pattern.js.map +1 -0
  458. package/packages/tools/browser/dist/public-suffixes.d.ts +24 -0
  459. package/packages/tools/browser/dist/public-suffixes.d.ts.map +1 -0
  460. package/packages/tools/browser/dist/public-suffixes.js +153 -0
  461. package/packages/tools/browser/dist/public-suffixes.js.map +1 -0
  462. package/packages/tools/browser/dist/secrets.d.ts +45 -9
  463. package/packages/tools/browser/dist/secrets.d.ts.map +1 -1
  464. package/packages/tools/browser/dist/secrets.js +77 -20
  465. package/packages/tools/browser/dist/secrets.js.map +1 -1
  466. package/packages/tools/browser/dist/service.d.ts +10 -0
  467. package/packages/tools/browser/dist/service.d.ts.map +1 -1
  468. package/packages/tools/browser/dist/service.js +84 -20
  469. package/packages/tools/browser/dist/service.js.map +1 -1
  470. package/packages/tools/browser/dist/types.d.ts +7 -1
  471. package/packages/tools/browser/dist/types.d.ts.map +1 -1
  472. package/packages/tools/browser/dist/types.js +7 -1
  473. package/packages/tools/browser/dist/types.js.map +1 -1
  474. package/packages/tools/email/dist/.tsbuildinfo +1 -1
  475. package/packages/tools/email/dist/tools/read.js +1 -1
  476. package/packages/tools/email/dist/tools/read.js.map +1 -1
  477. package/packages/tools/host/dist/.tsbuildinfo +1 -1
  478. package/packages/tools/memory/dist/.tsbuildinfo +1 -1
  479. package/packages/tools/web/dist/.tsbuildinfo +1 -1
  480. package/packages/web/dist/assets/{index-DCn0vN58.css → index-B727JQsO.css} +1 -1
  481. package/packages/web/dist/assets/index-OA0xgibo.js +123 -0
  482. package/packages/web/dist/index.html +2 -2
  483. package/packages/web/dist/assets/index-BRkIoT-q.js +0 -123
@@ -1,123 +0,0 @@
1
- var xg=e=>{throw TypeError(e)};var vg=(e,t,n)=>t.has(e)||xg("Cannot "+n);var It=(e,t,n)=>(vg(e,t,"read from private field"),n?n.call(e):t.get(e)),jg=(e,t,n)=>t.has(e)?xg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Tu=(e,t,n,r)=>(vg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function b1(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(r,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const o of l.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function k1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fj={exports:{}},_c={},hj={exports:{}},Ee={};/**
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 ho=Symbol.for("react.element"),S1=Symbol.for("react.portal"),N1=Symbol.for("react.fragment"),C1=Symbol.for("react.strict_mode"),E1=Symbol.for("react.profiler"),A1=Symbol.for("react.provider"),R1=Symbol.for("react.context"),T1=Symbol.for("react.forward_ref"),P1=Symbol.for("react.suspense"),I1=Symbol.for("react.memo"),M1=Symbol.for("react.lazy"),yg=Symbol.iterator;function $1(e){return e===null||typeof e!="object"?null:(e=yg&&e[yg]||e["@@iterator"],typeof e=="function"?e:null)}var pj={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},mj=Object.assign,gj={};function Yi(e,t,n){this.props=e,this.context=t,this.refs=gj,this.updater=n||pj}Yi.prototype.isReactComponent={};Yi.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")};Yi.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function xj(){}xj.prototype=Yi.prototype;function Uh(e,t,n){this.props=e,this.context=t,this.refs=gj,this.updater=n||pj}var Bh=Uh.prototype=new xj;Bh.constructor=Uh;mj(Bh,Yi.prototype);Bh.isPureReactComponent=!0;var wg=Array.isArray,vj=Object.prototype.hasOwnProperty,zh={current:null},jj={key:!0,ref:!0,__self:!0,__source:!0};function yj(e,t,n){var r,i={},l=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(l=""+t.key),t)vj.call(t,r)&&!jj.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){for(var c=Array(a),u=0;u<a;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)i[r]===void 0&&(i[r]=a[r]);return{$$typeof:ho,type:e,key:l,ref:o,props:i,_owner:zh.current}}function _1(e,t){return{$$typeof:ho,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Wh(e){return typeof e=="object"&&e!==null&&e.$$typeof===ho}function O1(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var bg=/\/+/g;function Pu(e,t){return typeof e=="object"&&e!==null&&e.key!=null?O1(""+e.key):t.toString(36)}function ba(e,t,n,r,i){var l=typeof e;(l==="undefined"||l==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(l){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case ho:case S1:o=!0}}if(o)return o=e,i=i(o),e=r===""?"."+Pu(o,0):r,wg(i)?(n="",e!=null&&(n=e.replace(bg,"$&/")+"/"),ba(i,t,n,"",function(u){return u})):i!=null&&(Wh(i)&&(i=_1(i,n+(!i.key||o&&o.key===i.key?"":(""+i.key).replace(bg,"$&/")+"/")+e)),t.push(i)),1;if(o=0,r=r===""?".":r+":",wg(e))for(var a=0;a<e.length;a++){l=e[a];var c=r+Pu(l,a);o+=ba(l,t,n,c,i)}else if(c=$1(e),typeof c=="function")for(e=c.call(e),a=0;!(l=e.next()).done;)l=l.value,c=r+Pu(l,a++),o+=ba(l,t,n,c,i);else if(l==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function _o(e,t,n){if(e==null)return e;var r=[],i=0;return ba(e,r,"","",function(l){return t.call(n,l,i++)}),r}function D1(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Kt={current:null},ka={transition:null},L1={ReactCurrentDispatcher:Kt,ReactCurrentBatchConfig:ka,ReactCurrentOwner:zh};function wj(){throw Error("act(...) is not supported in production builds of React.")}Ee.Children={map:_o,forEach:function(e,t,n){_o(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return _o(e,function(){t++}),t},toArray:function(e){return _o(e,function(t){return t})||[]},only:function(e){if(!Wh(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ee.Component=Yi;Ee.Fragment=N1;Ee.Profiler=E1;Ee.PureComponent=Uh;Ee.StrictMode=C1;Ee.Suspense=P1;Ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=L1;Ee.act=wj;Ee.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=mj({},e.props),i=e.key,l=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(l=t.ref,o=zh.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(c in t)vj.call(t,c)&&!jj.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&a!==void 0?a[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){a=Array(c);for(var u=0;u<c;u++)a[u]=arguments[u+2];r.children=a}return{$$typeof:ho,type:e.type,key:i,ref:l,props:r,_owner:o}};Ee.createContext=function(e){return e={$$typeof:R1,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:A1,_context:e},e.Consumer=e};Ee.createElement=yj;Ee.createFactory=function(e){var t=yj.bind(null,e);return t.type=e,t};Ee.createRef=function(){return{current:null}};Ee.forwardRef=function(e){return{$$typeof:T1,render:e}};Ee.isValidElement=Wh;Ee.lazy=function(e){return{$$typeof:M1,_payload:{_status:-1,_result:e},_init:D1}};Ee.memo=function(e,t){return{$$typeof:I1,type:e,compare:t===void 0?null:t}};Ee.startTransition=function(e){var t=ka.transition;ka.transition={};try{e()}finally{ka.transition=t}};Ee.unstable_act=wj;Ee.useCallback=function(e,t){return Kt.current.useCallback(e,t)};Ee.useContext=function(e){return Kt.current.useContext(e)};Ee.useDebugValue=function(){};Ee.useDeferredValue=function(e){return Kt.current.useDeferredValue(e)};Ee.useEffect=function(e,t){return Kt.current.useEffect(e,t)};Ee.useId=function(){return Kt.current.useId()};Ee.useImperativeHandle=function(e,t,n){return Kt.current.useImperativeHandle(e,t,n)};Ee.useInsertionEffect=function(e,t){return Kt.current.useInsertionEffect(e,t)};Ee.useLayoutEffect=function(e,t){return Kt.current.useLayoutEffect(e,t)};Ee.useMemo=function(e,t){return Kt.current.useMemo(e,t)};Ee.useReducer=function(e,t,n){return Kt.current.useReducer(e,t,n)};Ee.useRef=function(e){return Kt.current.useRef(e)};Ee.useState=function(e){return Kt.current.useState(e)};Ee.useSyncExternalStore=function(e,t,n){return Kt.current.useSyncExternalStore(e,t,n)};Ee.useTransition=function(){return Kt.current.useTransition()};Ee.version="18.3.1";hj.exports=Ee;var f=hj.exports;const F1=k1(f),qi=b1({__proto__:null,default:F1},[f]);/**
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 U1=f,B1=Symbol.for("react.element"),z1=Symbol.for("react.fragment"),W1=Object.prototype.hasOwnProperty,V1=U1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,H1={key:!0,ref:!0,__self:!0,__source:!0};function bj(e,t,n){var r,i={},l=null,o=null;n!==void 0&&(l=""+n),t.key!==void 0&&(l=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)W1.call(t,r)&&!H1.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:B1,type:e,key:l,ref:o,props:i,_owner:V1.current}}_c.Fragment=z1;_c.jsx=bj;_c.jsxs=bj;fj.exports=_c;var s=fj.exports,kj={exports:{}},vn={},Sj={exports:{}},Nj={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t(M,z){var $=M.length;M.push(z);e:for(;0<$;){var U=$-1>>>1,X=M[U];if(0<i(X,z))M[U]=z,M[$]=X,$=U;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var z=M[0],$=M.pop();if($!==z){M[0]=$;e:for(var U=0,X=M.length,Z=X>>>1;U<Z;){var fe=2*(U+1)-1,ve=M[fe],Ne=fe+1,oe=M[Ne];if(0>i(ve,$))Ne<X&&0>i(oe,ve)?(M[U]=oe,M[Ne]=$,U=Ne):(M[U]=ve,M[fe]=$,U=fe);else if(Ne<X&&0>i(oe,$))M[U]=oe,M[Ne]=$,U=Ne;else break e}}return z}function i(M,z){var $=M.sortIndex-z.sortIndex;return $!==0?$:M.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var c=[],u=[],p=1,d=null,h=3,x=!1,v=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(M){for(var z=n(u);z!==null;){if(z.callback===null)r(u);else if(z.startTime<=M)r(u),z.sortIndex=z.expirationTime,t(c,z);else break;z=n(u)}}function m(M){if(w=!1,y(M),!v)if(n(c)!==null)v=!0,q(k);else{var z=n(u);z!==null&&V(m,z.startTime-M)}}function k(M,z){v=!1,w&&(w=!1,j(C),C=-1),x=!0;var $=h;try{for(y(z),d=n(c);d!==null&&(!(d.expirationTime>z)||M&&!_());){var U=d.callback;if(typeof U=="function"){d.callback=null,h=d.priorityLevel;var X=U(d.expirationTime<=z);z=e.unstable_now(),typeof X=="function"?d.callback=X:d===n(c)&&r(c),y(z)}else r(c);d=n(c)}if(d!==null)var Z=!0;else{var fe=n(u);fe!==null&&V(m,fe.startTime-z),Z=!1}return Z}finally{d=null,h=$,x=!1}}var S=!1,N=null,C=-1,T=5,E=-1;function _(){return!(e.unstable_now()-E<T)}function F(){if(N!==null){var M=e.unstable_now();E=M;var z=!0;try{z=N(!0,M)}finally{z?O():(S=!1,N=null)}}else S=!1}var O;if(typeof g=="function")O=function(){g(F)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,D=A.port2;A.port1.onmessage=F,O=function(){D.postMessage(null)}}else O=function(){b(F,0)};function q(M){N=M,S||(S=!0,O())}function V(M,z){C=b(function(){M(e.unstable_now())},z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){v||x||(v=!0,q(k))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(M){switch(h){case 1:case 2:case 3:var z=3;break;default:z=h}var $=h;h=z;try{return M()}finally{h=$}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,z){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var $=h;h=M;try{return z()}finally{h=$}},e.unstable_scheduleCallback=function(M,z,$){var U=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?U+$:U):$=U,M){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=$+X,M={id:p++,callback:z,priorityLevel:M,startTime:$,expirationTime:X,sortIndex:-1},$>U?(M.sortIndex=$,t(u,M),n(c)===null&&M===n(u)&&(w?(j(C),C=-1):w=!0,V(m,$-U))):(M.sortIndex=X,t(c,M),v||x||(v=!0,q(k))),M},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(M){var z=h;return function(){var $=h;h=z;try{return M.apply(this,arguments)}finally{h=$}}}})(Nj);Sj.exports=Nj;var K1=Sj.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 G1=f,xn=K1;function Q(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Cj=new Set,Fl={};function zr(e,t){Ti(e,t),Ti(e+"Capture",t)}function Ti(e,t){for(Fl[e]=t,e=0;e<t.length;e++)Cj.add(t[e])}var ws=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kd=Object.prototype.hasOwnProperty,Y1=/^[: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]*$/,kg={},Sg={};function q1(e){return Kd.call(Sg,e)?!0:Kd.call(kg,e)?!1:Y1.test(e)?Sg[e]=!0:(kg[e]=!0,!1)}function Q1(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function J1(e,t,n,r){if(t===null||typeof t>"u"||Q1(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Gt(e,t,n,r,i,l,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=l,this.removeEmptyString=o}var Tt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Tt[e]=new Gt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Tt[t]=new Gt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Tt[e]=new Gt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Tt[e]=new Gt(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){Tt[e]=new Gt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Tt[e]=new Gt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Tt[e]=new Gt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Tt[e]=new Gt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Tt[e]=new Gt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Vh=/[\-:]([a-z])/g;function Hh(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(Vh,Hh);Tt[t]=new Gt(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(Vh,Hh);Tt[t]=new Gt(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(Vh,Hh);Tt[t]=new Gt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Tt[e]=new Gt(e,1,!1,e.toLowerCase(),null,!1,!1)});Tt.xlinkHref=new Gt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Tt[e]=new Gt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Kh(e,t,n,r){var i=Tt.hasOwnProperty(t)?Tt[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(J1(t,n,i,r)&&(n=null),r||i===null?q1(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Ts=G1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Oo=Symbol.for("react.element"),oi=Symbol.for("react.portal"),ai=Symbol.for("react.fragment"),Gh=Symbol.for("react.strict_mode"),Gd=Symbol.for("react.profiler"),Ej=Symbol.for("react.provider"),Aj=Symbol.for("react.context"),Yh=Symbol.for("react.forward_ref"),Yd=Symbol.for("react.suspense"),qd=Symbol.for("react.suspense_list"),qh=Symbol.for("react.memo"),Us=Symbol.for("react.lazy"),Rj=Symbol.for("react.offscreen"),Ng=Symbol.iterator;function dl(e){return e===null||typeof e!="object"?null:(e=Ng&&e[Ng]||e["@@iterator"],typeof e=="function"?e:null)}var qe=Object.assign,Iu;function Sl(e){if(Iu===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Iu=t&&t[1]||""}return`
34
- `+Iu+e}var Mu=!1;function $u(e,t){if(!e||Mu)return"";Mu=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(`
35
- `),l=r.stack.split(`
36
- `),o=i.length-1,a=l.length-1;1<=o&&0<=a&&i[o]!==l[a];)a--;for(;1<=o&&0<=a;o--,a--)if(i[o]!==l[a]){if(o!==1||a!==1)do if(o--,a--,0>a||i[o]!==l[a]){var c=`
37
- `+i[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=a);break}}}finally{Mu=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Sl(e):""}function X1(e){switch(e.tag){case 5:return Sl(e.type);case 16:return Sl("Lazy");case 13:return Sl("Suspense");case 19:return Sl("SuspenseList");case 0:case 2:case 15:return e=$u(e.type,!1),e;case 11:return e=$u(e.type.render,!1),e;case 1:return e=$u(e.type,!0),e;default:return""}}function Qd(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 ai:return"Fragment";case oi:return"Portal";case Gd:return"Profiler";case Gh:return"StrictMode";case Yd:return"Suspense";case qd:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Aj:return(e.displayName||"Context")+".Consumer";case Ej:return(e._context.displayName||"Context")+".Provider";case Yh:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case qh:return t=e.displayName||null,t!==null?t:Qd(e.type)||"Memo";case Us:t=e._payload,e=e._init;try{return Qd(e(t))}catch{}}return null}function Z1(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 Qd(t);case 8:return t===Gh?"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 Tj(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function eN(e){var t=Tj(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,l=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,l.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Do(e){e._valueTracker||(e._valueTracker=eN(e))}function Pj(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Tj(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ka(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 Jd(e,t){var n=t.checked;return qe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Cg(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=rr(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ij(e,t){t=t.checked,t!=null&&Kh(e,"checked",t,!1)}function Xd(e,t){Ij(e,t);var n=rr(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Zd(e,t.type,n):t.hasOwnProperty("defaultValue")&&Zd(e,t.type,rr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Eg(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Zd(e,t,n){(t!=="number"||Ka(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Nl=Array.isArray;function yi(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+rr(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function ef(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Q(91));return qe({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ag(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Q(92));if(Nl(n)){if(1<n.length)throw Error(Q(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:rr(n)}}function Mj(e,t){var n=rr(t.value),r=rr(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Rg(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function $j(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 tf(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?$j(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Lo,_j=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(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 Ul(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Al={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},tN=["Webkit","ms","Moz","O"];Object.keys(Al).forEach(function(e){tN.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Al[t]=Al[e]})});function Oj(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Al.hasOwnProperty(e)&&Al[e]?(""+t).trim():t+"px"}function Dj(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Oj(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var nN=qe({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 nf(e,t){if(t){if(nN[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Q(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Q(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Q(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Q(62))}}function sf(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 rf=null;function Qh(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lf=null,wi=null,bi=null;function Tg(e){if(e=go(e)){if(typeof lf!="function")throw Error(Q(280));var t=e.stateNode;t&&(t=Uc(t),lf(e.stateNode,e.type,t))}}function Lj(e){wi?bi?bi.push(e):bi=[e]:wi=e}function Fj(){if(wi){var e=wi,t=bi;if(bi=wi=null,Tg(e),t)for(e=0;e<t.length;e++)Tg(t[e])}}function Uj(e,t){return e(t)}function Bj(){}var _u=!1;function zj(e,t,n){if(_u)return e(t,n);_u=!0;try{return Uj(e,t,n)}finally{_u=!1,(wi!==null||bi!==null)&&(Bj(),Fj())}}function Bl(e,t){var n=e.stateNode;if(n===null)return null;var r=Uc(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Q(231,t,typeof n));return n}var of=!1;if(ws)try{var fl={};Object.defineProperty(fl,"passive",{get:function(){of=!0}}),window.addEventListener("test",fl,fl),window.removeEventListener("test",fl,fl)}catch{of=!1}function sN(e,t,n,r,i,l,o,a,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var Rl=!1,Ga=null,Ya=!1,af=null,rN={onError:function(e){Rl=!0,Ga=e}};function iN(e,t,n,r,i,l,o,a,c){Rl=!1,Ga=null,sN.apply(rN,arguments)}function lN(e,t,n,r,i,l,o,a,c){if(iN.apply(this,arguments),Rl){if(Rl){var u=Ga;Rl=!1,Ga=null}else throw Error(Q(198));Ya||(Ya=!0,af=u)}}function Wr(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Wj(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 Pg(e){if(Wr(e)!==e)throw Error(Q(188))}function oN(e){var t=e.alternate;if(!t){if(t=Wr(e),t===null)throw Error(Q(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var l=i.alternate;if(l===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===l.child){for(l=i.child;l;){if(l===n)return Pg(i),e;if(l===r)return Pg(i),t;l=l.sibling}throw Error(Q(188))}if(n.return!==r.return)n=i,r=l;else{for(var o=!1,a=i.child;a;){if(a===n){o=!0,n=i,r=l;break}if(a===r){o=!0,r=i,n=l;break}a=a.sibling}if(!o){for(a=l.child;a;){if(a===n){o=!0,n=l,r=i;break}if(a===r){o=!0,r=l,n=i;break}a=a.sibling}if(!o)throw Error(Q(189))}}if(n.alternate!==r)throw Error(Q(190))}if(n.tag!==3)throw Error(Q(188));return n.stateNode.current===n?e:t}function Vj(e){return e=oN(e),e!==null?Hj(e):null}function Hj(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Hj(e);if(t!==null)return t;e=e.sibling}return null}var Kj=xn.unstable_scheduleCallback,Ig=xn.unstable_cancelCallback,aN=xn.unstable_shouldYield,cN=xn.unstable_requestPaint,nt=xn.unstable_now,uN=xn.unstable_getCurrentPriorityLevel,Jh=xn.unstable_ImmediatePriority,Gj=xn.unstable_UserBlockingPriority,qa=xn.unstable_NormalPriority,dN=xn.unstable_LowPriority,Yj=xn.unstable_IdlePriority,Oc=null,Zn=null;function fN(e){if(Zn&&typeof Zn.onCommitFiberRoot=="function")try{Zn.onCommitFiberRoot(Oc,e,void 0,(e.current.flags&128)===128)}catch{}}var Dn=Math.clz32?Math.clz32:mN,hN=Math.log,pN=Math.LN2;function mN(e){return e>>>=0,e===0?32:31-(hN(e)/pN|0)|0}var Fo=64,Uo=4194304;function Cl(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 Qa(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,l=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=Cl(a):(l&=o,l!==0&&(r=Cl(l)))}else o=n&~i,o!==0?r=Cl(o):l!==0&&(r=Cl(l));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,l=t&-t,i>=l||i===16&&(l&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Dn(t),i=1<<n,r|=e[n],t&=~i;return r}function gN(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 xN(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,l=e.pendingLanes;0<l;){var o=31-Dn(l),a=1<<o,c=i[o];c===-1?(!(a&n)||a&r)&&(i[o]=gN(a,t)):c<=t&&(e.expiredLanes|=a),l&=~a}}function cf(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function qj(){var e=Fo;return Fo<<=1,!(Fo&4194240)&&(Fo=64),e}function Ou(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function po(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Dn(t),e[t]=n}function vN(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-Dn(n),l=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~l}}function Xh(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Dn(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var $e=0;function Qj(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Jj,Zh,Xj,Zj,ey,uf=!1,Bo=[],Gs=null,Ys=null,qs=null,zl=new Map,Wl=new Map,zs=[],jN="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 Mg(e,t){switch(e){case"focusin":case"focusout":Gs=null;break;case"dragenter":case"dragleave":Ys=null;break;case"mouseover":case"mouseout":qs=null;break;case"pointerover":case"pointerout":zl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wl.delete(t.pointerId)}}function hl(e,t,n,r,i,l){return e===null||e.nativeEvent!==l?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:l,targetContainers:[i]},t!==null&&(t=go(t),t!==null&&Zh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function yN(e,t,n,r,i){switch(t){case"focusin":return Gs=hl(Gs,e,t,n,r,i),!0;case"dragenter":return Ys=hl(Ys,e,t,n,r,i),!0;case"mouseover":return qs=hl(qs,e,t,n,r,i),!0;case"pointerover":var l=i.pointerId;return zl.set(l,hl(zl.get(l)||null,e,t,n,r,i)),!0;case"gotpointercapture":return l=i.pointerId,Wl.set(l,hl(Wl.get(l)||null,e,t,n,r,i)),!0}return!1}function ty(e){var t=Sr(e.target);if(t!==null){var n=Wr(t);if(n!==null){if(t=n.tag,t===13){if(t=Wj(n),t!==null){e.blockedOn=t,ey(e.priority,function(){Xj(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Sa(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=df(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);rf=r,n.target.dispatchEvent(r),rf=null}else return t=go(n),t!==null&&Zh(t),e.blockedOn=n,!1;t.shift()}return!0}function $g(e,t,n){Sa(e)&&n.delete(t)}function wN(){uf=!1,Gs!==null&&Sa(Gs)&&(Gs=null),Ys!==null&&Sa(Ys)&&(Ys=null),qs!==null&&Sa(qs)&&(qs=null),zl.forEach($g),Wl.forEach($g)}function pl(e,t){e.blockedOn===t&&(e.blockedOn=null,uf||(uf=!0,xn.unstable_scheduleCallback(xn.unstable_NormalPriority,wN)))}function Vl(e){function t(i){return pl(i,e)}if(0<Bo.length){pl(Bo[0],e);for(var n=1;n<Bo.length;n++){var r=Bo[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Gs!==null&&pl(Gs,e),Ys!==null&&pl(Ys,e),qs!==null&&pl(qs,e),zl.forEach(t),Wl.forEach(t),n=0;n<zs.length;n++)r=zs[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<zs.length&&(n=zs[0],n.blockedOn===null);)ty(n),n.blockedOn===null&&zs.shift()}var ki=Ts.ReactCurrentBatchConfig,Ja=!0;function bN(e,t,n,r){var i=$e,l=ki.transition;ki.transition=null;try{$e=1,ep(e,t,n,r)}finally{$e=i,ki.transition=l}}function kN(e,t,n,r){var i=$e,l=ki.transition;ki.transition=null;try{$e=4,ep(e,t,n,r)}finally{$e=i,ki.transition=l}}function ep(e,t,n,r){if(Ja){var i=df(e,t,n,r);if(i===null)Ku(e,t,r,Xa,n),Mg(e,r);else if(yN(i,e,t,n,r))r.stopPropagation();else if(Mg(e,r),t&4&&-1<jN.indexOf(e)){for(;i!==null;){var l=go(i);if(l!==null&&Jj(l),l=df(e,t,n,r),l===null&&Ku(e,t,r,Xa,n),l===i)break;i=l}i!==null&&r.stopPropagation()}else Ku(e,t,r,null,n)}}var Xa=null;function df(e,t,n,r){if(Xa=null,e=Qh(r),e=Sr(e),e!==null)if(t=Wr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Wj(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Xa=e,null}function ny(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(uN()){case Jh:return 1;case Gj:return 4;case qa:case dN:return 16;case Yj:return 536870912;default:return 16}default:return 16}}var Vs=null,tp=null,Na=null;function sy(){if(Na)return Na;var e,t=tp,n=t.length,r,i="value"in Vs?Vs.value:Vs.textContent,l=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[l-r];r++);return Na=i.slice(e,1<r?1-r:void 0)}function Ca(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 _g(){return!1}function jn(e){function t(n,r,i,l,o){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=l,this.target=o,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(l):l[a]);return this.isDefaultPrevented=(l.defaultPrevented!=null?l.defaultPrevented:l.returnValue===!1)?zo:_g,this.isPropagationStopped=_g,this}return qe(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=zo)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=zo)},persist:function(){},isPersistent:zo}),t}var Qi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},np=jn(Qi),mo=qe({},Qi,{view:0,detail:0}),SN=jn(mo),Du,Lu,ml,Dc=qe({},mo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sp,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!==ml&&(ml&&e.type==="mousemove"?(Du=e.screenX-ml.screenX,Lu=e.screenY-ml.screenY):Lu=Du=0,ml=e),Du)},movementY:function(e){return"movementY"in e?e.movementY:Lu}}),Og=jn(Dc),NN=qe({},Dc,{dataTransfer:0}),CN=jn(NN),EN=qe({},mo,{relatedTarget:0}),Fu=jn(EN),AN=qe({},Qi,{animationName:0,elapsedTime:0,pseudoElement:0}),RN=jn(AN),TN=qe({},Qi,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),PN=jn(TN),IN=qe({},Qi,{data:0}),Dg=jn(IN),MN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$N={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"},_N={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ON(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=_N[e])?!!t[e]:!1}function sp(){return ON}var DN=qe({},mo,{key:function(e){if(e.key){var t=MN[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ca(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?$N[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sp,charCode:function(e){return e.type==="keypress"?Ca(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ca(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),LN=jn(DN),FN=qe({},Dc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Lg=jn(FN),UN=qe({},mo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sp}),BN=jn(UN),zN=qe({},Qi,{propertyName:0,elapsedTime:0,pseudoElement:0}),WN=jn(zN),VN=qe({},Dc,{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}),HN=jn(VN),KN=[9,13,27,32],rp=ws&&"CompositionEvent"in window,Tl=null;ws&&"documentMode"in document&&(Tl=document.documentMode);var GN=ws&&"TextEvent"in window&&!Tl,ry=ws&&(!rp||Tl&&8<Tl&&11>=Tl),Fg=" ",Ug=!1;function iy(e,t){switch(e){case"keyup":return KN.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ly(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ci=!1;function YN(e,t){switch(e){case"compositionend":return ly(t);case"keypress":return t.which!==32?null:(Ug=!0,Fg);case"textInput":return e=t.data,e===Fg&&Ug?null:e;default:return null}}function qN(e,t){if(ci)return e==="compositionend"||!rp&&iy(e,t)?(e=sy(),Na=tp=Vs=null,ci=!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 ry&&t.locale!=="ko"?null:t.data;default:return null}}var QN={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 Bg(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!QN[e.type]:t==="textarea"}function oy(e,t,n,r){Lj(r),t=Za(t,"onChange"),0<t.length&&(n=new np("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Pl=null,Hl=null;function JN(e){vy(e,0)}function Lc(e){var t=fi(e);if(Pj(t))return e}function XN(e,t){if(e==="change")return t}var ay=!1;if(ws){var Uu;if(ws){var Bu="oninput"in document;if(!Bu){var zg=document.createElement("div");zg.setAttribute("oninput","return;"),Bu=typeof zg.oninput=="function"}Uu=Bu}else Uu=!1;ay=Uu&&(!document.documentMode||9<document.documentMode)}function Wg(){Pl&&(Pl.detachEvent("onpropertychange",cy),Hl=Pl=null)}function cy(e){if(e.propertyName==="value"&&Lc(Hl)){var t=[];oy(t,Hl,e,Qh(e)),zj(JN,t)}}function ZN(e,t,n){e==="focusin"?(Wg(),Pl=t,Hl=n,Pl.attachEvent("onpropertychange",cy)):e==="focusout"&&Wg()}function eC(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Lc(Hl)}function tC(e,t){if(e==="click")return Lc(t)}function nC(e,t){if(e==="input"||e==="change")return Lc(t)}function sC(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Fn=typeof Object.is=="function"?Object.is:sC;function Kl(e,t){if(Fn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Kd.call(t,i)||!Fn(e[i],t[i]))return!1}return!0}function Vg(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Hg(e,t){var n=Vg(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Vg(n)}}function uy(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?uy(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function dy(){for(var e=window,t=Ka();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ka(e.document)}return t}function ip(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 rC(e){var t=dy(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&uy(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,l=Math.min(r.start,i);r=r.end===void 0?l:Math.min(r.end,i),!e.extend&&l>r&&(i=r,r=l,l=i),i=Hg(n,l);var o=Hg(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),l>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var iC=ws&&"documentMode"in document&&11>=document.documentMode,ui=null,ff=null,Il=null,hf=!1;function Kg(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hf||ui==null||ui!==Ka(r)||(r=ui,"selectionStart"in r&&ip(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}),Il&&Kl(Il,r)||(Il=r,r=Za(ff,"onSelect"),0<r.length&&(t=new np("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ui)))}function Wo(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var di={animationend:Wo("Animation","AnimationEnd"),animationiteration:Wo("Animation","AnimationIteration"),animationstart:Wo("Animation","AnimationStart"),transitionend:Wo("Transition","TransitionEnd")},zu={},fy={};ws&&(fy=document.createElement("div").style,"AnimationEvent"in window||(delete di.animationend.animation,delete di.animationiteration.animation,delete di.animationstart.animation),"TransitionEvent"in window||delete di.transitionend.transition);function Fc(e){if(zu[e])return zu[e];if(!di[e])return e;var t=di[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in fy)return zu[e]=t[n];return e}var hy=Fc("animationend"),py=Fc("animationiteration"),my=Fc("animationstart"),gy=Fc("transitionend"),xy=new Map,Gg="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 dr(e,t){xy.set(e,t),zr(t,[e])}for(var Wu=0;Wu<Gg.length;Wu++){var Vu=Gg[Wu],lC=Vu.toLowerCase(),oC=Vu[0].toUpperCase()+Vu.slice(1);dr(lC,"on"+oC)}dr(hy,"onAnimationEnd");dr(py,"onAnimationIteration");dr(my,"onAnimationStart");dr("dblclick","onDoubleClick");dr("focusin","onFocus");dr("focusout","onBlur");dr(gy,"onTransitionEnd");Ti("onMouseEnter",["mouseout","mouseover"]);Ti("onMouseLeave",["mouseout","mouseover"]);Ti("onPointerEnter",["pointerout","pointerover"]);Ti("onPointerLeave",["pointerout","pointerover"]);zr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));zr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));zr("onBeforeInput",["compositionend","keypress","textInput","paste"]);zr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));zr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));zr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var El="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(" "),aC=new Set("cancel close invalid load scroll toggle".split(" ").concat(El));function Yg(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,lN(r,t,void 0,e),e.currentTarget=null}function vy(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var l=void 0;if(t)for(var o=r.length-1;0<=o;o--){var a=r[o],c=a.instance,u=a.currentTarget;if(a=a.listener,c!==l&&i.isPropagationStopped())break e;Yg(i,a,u),l=c}else for(o=0;o<r.length;o++){if(a=r[o],c=a.instance,u=a.currentTarget,a=a.listener,c!==l&&i.isPropagationStopped())break e;Yg(i,a,u),l=c}}}if(Ya)throw e=af,Ya=!1,af=null,e}function Be(e,t){var n=t[vf];n===void 0&&(n=t[vf]=new Set);var r=e+"__bubble";n.has(r)||(jy(t,e,2,!1),n.add(r))}function Hu(e,t,n){var r=0;t&&(r|=4),jy(n,e,r,t)}var Vo="_reactListening"+Math.random().toString(36).slice(2);function Gl(e){if(!e[Vo]){e[Vo]=!0,Cj.forEach(function(n){n!=="selectionchange"&&(aC.has(n)||Hu(n,!1,e),Hu(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Vo]||(t[Vo]=!0,Hu("selectionchange",!1,t))}}function jy(e,t,n,r){switch(ny(t)){case 1:var i=bN;break;case 4:i=kN;break;default:i=ep}n=i.bind(null,t,n,e),i=void 0,!of||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Ku(e,t,n,r,i){var l=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;o=o.return}for(;a!==null;){if(o=Sr(a),o===null)return;if(c=o.tag,c===5||c===6){r=l=o;continue e}a=a.parentNode}}r=r.return}zj(function(){var u=l,p=Qh(n),d=[];e:{var h=xy.get(e);if(h!==void 0){var x=np,v=e;switch(e){case"keypress":if(Ca(n)===0)break e;case"keydown":case"keyup":x=LN;break;case"focusin":v="focus",x=Fu;break;case"focusout":v="blur",x=Fu;break;case"beforeblur":case"afterblur":x=Fu;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":x=Og;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=CN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=BN;break;case hy:case py:case my:x=RN;break;case gy:x=WN;break;case"scroll":x=SN;break;case"wheel":x=HN;break;case"copy":case"cut":case"paste":x=PN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Lg}var w=(t&4)!==0,b=!w&&e==="scroll",j=w?h!==null?h+"Capture":null:h;w=[];for(var g=u,y;g!==null;){y=g;var m=y.stateNode;if(y.tag===5&&m!==null&&(y=m,j!==null&&(m=Bl(g,j),m!=null&&w.push(Yl(g,m,y)))),b)break;g=g.return}0<w.length&&(h=new x(h,v,null,n,p),d.push({event:h,listeners:w}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",h&&n!==rf&&(v=n.relatedTarget||n.fromElement)&&(Sr(v)||v[bs]))break e;if((x||h)&&(h=p.window===p?p:(h=p.ownerDocument)?h.defaultView||h.parentWindow:window,x?(v=n.relatedTarget||n.toElement,x=u,v=v?Sr(v):null,v!==null&&(b=Wr(v),v!==b||v.tag!==5&&v.tag!==6)&&(v=null)):(x=null,v=u),x!==v)){if(w=Og,m="onMouseLeave",j="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(w=Lg,m="onPointerLeave",j="onPointerEnter",g="pointer"),b=x==null?h:fi(x),y=v==null?h:fi(v),h=new w(m,g+"leave",x,n,p),h.target=b,h.relatedTarget=y,m=null,Sr(p)===u&&(w=new w(j,g+"enter",v,n,p),w.target=y,w.relatedTarget=b,m=w),b=m,x&&v)t:{for(w=x,j=v,g=0,y=w;y;y=ei(y))g++;for(y=0,m=j;m;m=ei(m))y++;for(;0<g-y;)w=ei(w),g--;for(;0<y-g;)j=ei(j),y--;for(;g--;){if(w===j||j!==null&&w===j.alternate)break t;w=ei(w),j=ei(j)}w=null}else w=null;x!==null&&qg(d,h,x,w,!1),v!==null&&b!==null&&qg(d,b,v,w,!0)}}e:{if(h=u?fi(u):window,x=h.nodeName&&h.nodeName.toLowerCase(),x==="select"||x==="input"&&h.type==="file")var k=XN;else if(Bg(h))if(ay)k=nC;else{k=eC;var S=ZN}else(x=h.nodeName)&&x.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(k=tC);if(k&&(k=k(e,u))){oy(d,k,n,p);break e}S&&S(e,h,u),e==="focusout"&&(S=h._wrapperState)&&S.controlled&&h.type==="number"&&Zd(h,"number",h.value)}switch(S=u?fi(u):window,e){case"focusin":(Bg(S)||S.contentEditable==="true")&&(ui=S,ff=u,Il=null);break;case"focusout":Il=ff=ui=null;break;case"mousedown":hf=!0;break;case"contextmenu":case"mouseup":case"dragend":hf=!1,Kg(d,n,p);break;case"selectionchange":if(iC)break;case"keydown":case"keyup":Kg(d,n,p)}var N;if(rp)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 ci?iy(e,n)&&(C="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(ry&&n.locale!=="ko"&&(ci||C!=="onCompositionStart"?C==="onCompositionEnd"&&ci&&(N=sy()):(Vs=p,tp="value"in Vs?Vs.value:Vs.textContent,ci=!0)),S=Za(u,C),0<S.length&&(C=new Dg(C,e,null,n,p),d.push({event:C,listeners:S}),N?C.data=N:(N=ly(n),N!==null&&(C.data=N)))),(N=GN?YN(e,n):qN(e,n))&&(u=Za(u,"onBeforeInput"),0<u.length&&(p=new Dg("onBeforeInput","beforeinput",null,n,p),d.push({event:p,listeners:u}),p.data=N))}vy(d,t)})}function Yl(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Za(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,l=i.stateNode;i.tag===5&&l!==null&&(i=l,l=Bl(e,n),l!=null&&r.unshift(Yl(e,l,i)),l=Bl(e,t),l!=null&&r.push(Yl(e,l,i))),e=e.return}return r}function ei(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function qg(e,t,n,r,i){for(var l=t._reactName,o=[];n!==null&&n!==r;){var a=n,c=a.alternate,u=a.stateNode;if(c!==null&&c===r)break;a.tag===5&&u!==null&&(a=u,i?(c=Bl(n,l),c!=null&&o.unshift(Yl(n,c,a))):i||(c=Bl(n,l),c!=null&&o.push(Yl(n,c,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var cC=/\r\n?/g,uC=/\u0000|\uFFFD/g;function Qg(e){return(typeof e=="string"?e:""+e).replace(cC,`
38
- `).replace(uC,"")}function Ho(e,t,n){if(t=Qg(t),Qg(e)!==t&&n)throw Error(Q(425))}function ec(){}var pf=null,mf=null;function gf(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 xf=typeof setTimeout=="function"?setTimeout:void 0,dC=typeof clearTimeout=="function"?clearTimeout:void 0,Jg=typeof Promise=="function"?Promise:void 0,fC=typeof queueMicrotask=="function"?queueMicrotask:typeof Jg<"u"?function(e){return Jg.resolve(null).then(e).catch(hC)}:xf;function hC(e){setTimeout(function(){throw e})}function Gu(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),Vl(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);Vl(t)}function Qs(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 Xg(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Ji=Math.random().toString(36).slice(2),qn="__reactFiber$"+Ji,ql="__reactProps$"+Ji,bs="__reactContainer$"+Ji,vf="__reactEvents$"+Ji,pC="__reactListeners$"+Ji,mC="__reactHandles$"+Ji;function Sr(e){var t=e[qn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[bs]||n[qn]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Xg(e);e!==null;){if(n=e[qn])return n;e=Xg(e)}return t}e=n,n=e.parentNode}return null}function go(e){return e=e[qn]||e[bs],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function fi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Q(33))}function Uc(e){return e[ql]||null}var jf=[],hi=-1;function fr(e){return{current:e}}function ze(e){0>hi||(e.current=jf[hi],jf[hi]=null,hi--)}function Ue(e,t){hi++,jf[hi]=e.current,e.current=t}var ir={},Lt=fr(ir),Zt=fr(!1),Pr=ir;function Pi(e,t){var n=e.type.contextTypes;if(!n)return ir;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},l;for(l in n)i[l]=t[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function en(e){return e=e.childContextTypes,e!=null}function tc(){ze(Zt),ze(Lt)}function Zg(e,t,n){if(Lt.current!==ir)throw Error(Q(168));Ue(Lt,t),Ue(Zt,n)}function yy(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(Q(108,Z1(e)||"Unknown",i));return qe({},n,r)}function nc(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ir,Pr=Lt.current,Ue(Lt,e),Ue(Zt,Zt.current),!0}function ex(e,t,n){var r=e.stateNode;if(!r)throw Error(Q(169));n?(e=yy(e,t,Pr),r.__reactInternalMemoizedMergedChildContext=e,ze(Zt),ze(Lt),Ue(Lt,e)):ze(Zt),Ue(Zt,n)}var ps=null,Bc=!1,Yu=!1;function wy(e){ps===null?ps=[e]:ps.push(e)}function gC(e){Bc=!0,wy(e)}function hr(){if(!Yu&&ps!==null){Yu=!0;var e=0,t=$e;try{var n=ps;for($e=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}ps=null,Bc=!1}catch(i){throw ps!==null&&(ps=ps.slice(e+1)),Kj(Jh,hr),i}finally{$e=t,Yu=!1}}return null}var pi=[],mi=0,sc=null,rc=0,bn=[],kn=0,Ir=null,ms=1,gs="";function br(e,t){pi[mi++]=rc,pi[mi++]=sc,sc=e,rc=t}function by(e,t,n){bn[kn++]=ms,bn[kn++]=gs,bn[kn++]=Ir,Ir=e;var r=ms;e=gs;var i=32-Dn(r)-1;r&=~(1<<i),n+=1;var l=32-Dn(t)+i;if(30<l){var o=i-i%5;l=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ms=1<<32-Dn(t)+i|n<<i|r,gs=l+e}else ms=1<<l|n<<i|r,gs=e}function lp(e){e.return!==null&&(br(e,1),by(e,1,0))}function op(e){for(;e===sc;)sc=pi[--mi],pi[mi]=null,rc=pi[--mi],pi[mi]=null;for(;e===Ir;)Ir=bn[--kn],bn[kn]=null,gs=bn[--kn],bn[kn]=null,ms=bn[--kn],bn[kn]=null}var gn=null,pn=null,He=!1,_n=null;function ky(e,t){var n=Nn(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function tx(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,gn=e,pn=Qs(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,gn=e,pn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ir!==null?{id:ms,overflow:gs}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Nn(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,gn=e,pn=null,!0):!1;default:return!1}}function yf(e){return(e.mode&1)!==0&&(e.flags&128)===0}function wf(e){if(He){var t=pn;if(t){var n=t;if(!tx(e,t)){if(yf(e))throw Error(Q(418));t=Qs(n.nextSibling);var r=gn;t&&tx(e,t)?ky(r,n):(e.flags=e.flags&-4097|2,He=!1,gn=e)}}else{if(yf(e))throw Error(Q(418));e.flags=e.flags&-4097|2,He=!1,gn=e}}}function nx(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;gn=e}function Ko(e){if(e!==gn)return!1;if(!He)return nx(e),He=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!gf(e.type,e.memoizedProps)),t&&(t=pn)){if(yf(e))throw Sy(),Error(Q(418));for(;t;)ky(e,t),t=Qs(t.nextSibling)}if(nx(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Q(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){pn=Qs(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}pn=null}}else pn=gn?Qs(e.stateNode.nextSibling):null;return!0}function Sy(){for(var e=pn;e;)e=Qs(e.nextSibling)}function Ii(){pn=gn=null,He=!1}function ap(e){_n===null?_n=[e]:_n.push(e)}var xC=Ts.ReactCurrentBatchConfig;function gl(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Q(309));var r=n.stateNode}if(!r)throw Error(Q(147,e));var i=r,l=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===l?t.ref:(t=function(o){var a=i.refs;o===null?delete a[l]:a[l]=o},t._stringRef=l,t)}if(typeof e!="string")throw Error(Q(284));if(!n._owner)throw Error(Q(290,e))}return e}function Go(e,t){throw e=Object.prototype.toString.call(t),Error(Q(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function sx(e){var t=e._init;return t(e._payload)}function Ny(e){function t(j,g){if(e){var y=j.deletions;y===null?(j.deletions=[g],j.flags|=16):y.push(g)}}function n(j,g){if(!e)return null;for(;g!==null;)t(j,g),g=g.sibling;return null}function r(j,g){for(j=new Map;g!==null;)g.key!==null?j.set(g.key,g):j.set(g.index,g),g=g.sibling;return j}function i(j,g){return j=er(j,g),j.index=0,j.sibling=null,j}function l(j,g,y){return j.index=y,e?(y=j.alternate,y!==null?(y=y.index,y<g?(j.flags|=2,g):y):(j.flags|=2,g)):(j.flags|=1048576,g)}function o(j){return e&&j.alternate===null&&(j.flags|=2),j}function a(j,g,y,m){return g===null||g.tag!==6?(g=td(y,j.mode,m),g.return=j,g):(g=i(g,y),g.return=j,g)}function c(j,g,y,m){var k=y.type;return k===ai?p(j,g,y.props.children,m,y.key):g!==null&&(g.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Us&&sx(k)===g.type)?(m=i(g,y.props),m.ref=gl(j,g,y),m.return=j,m):(m=Ma(y.type,y.key,y.props,null,j.mode,m),m.ref=gl(j,g,y),m.return=j,m)}function u(j,g,y,m){return g===null||g.tag!==4||g.stateNode.containerInfo!==y.containerInfo||g.stateNode.implementation!==y.implementation?(g=nd(y,j.mode,m),g.return=j,g):(g=i(g,y.children||[]),g.return=j,g)}function p(j,g,y,m,k){return g===null||g.tag!==7?(g=Ar(y,j.mode,m,k),g.return=j,g):(g=i(g,y),g.return=j,g)}function d(j,g,y){if(typeof g=="string"&&g!==""||typeof g=="number")return g=td(""+g,j.mode,y),g.return=j,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Oo:return y=Ma(g.type,g.key,g.props,null,j.mode,y),y.ref=gl(j,null,g),y.return=j,y;case oi:return g=nd(g,j.mode,y),g.return=j,g;case Us:var m=g._init;return d(j,m(g._payload),y)}if(Nl(g)||dl(g))return g=Ar(g,j.mode,y,null),g.return=j,g;Go(j,g)}return null}function h(j,g,y,m){var k=g!==null?g.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return k!==null?null:a(j,g,""+y,m);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Oo:return y.key===k?c(j,g,y,m):null;case oi:return y.key===k?u(j,g,y,m):null;case Us:return k=y._init,h(j,g,k(y._payload),m)}if(Nl(y)||dl(y))return k!==null?null:p(j,g,y,m,null);Go(j,y)}return null}function x(j,g,y,m,k){if(typeof m=="string"&&m!==""||typeof m=="number")return j=j.get(y)||null,a(g,j,""+m,k);if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Oo:return j=j.get(m.key===null?y:m.key)||null,c(g,j,m,k);case oi:return j=j.get(m.key===null?y:m.key)||null,u(g,j,m,k);case Us:var S=m._init;return x(j,g,y,S(m._payload),k)}if(Nl(m)||dl(m))return j=j.get(y)||null,p(g,j,m,k,null);Go(g,m)}return null}function v(j,g,y,m){for(var k=null,S=null,N=g,C=g=0,T=null;N!==null&&C<y.length;C++){N.index>C?(T=N,N=null):T=N.sibling;var E=h(j,N,y[C],m);if(E===null){N===null&&(N=T);break}e&&N&&E.alternate===null&&t(j,N),g=l(E,g,C),S===null?k=E:S.sibling=E,S=E,N=T}if(C===y.length)return n(j,N),He&&br(j,C),k;if(N===null){for(;C<y.length;C++)N=d(j,y[C],m),N!==null&&(g=l(N,g,C),S===null?k=N:S.sibling=N,S=N);return He&&br(j,C),k}for(N=r(j,N);C<y.length;C++)T=x(N,j,C,y[C],m),T!==null&&(e&&T.alternate!==null&&N.delete(T.key===null?C:T.key),g=l(T,g,C),S===null?k=T:S.sibling=T,S=T);return e&&N.forEach(function(_){return t(j,_)}),He&&br(j,C),k}function w(j,g,y,m){var k=dl(y);if(typeof k!="function")throw Error(Q(150));if(y=k.call(y),y==null)throw Error(Q(151));for(var S=k=null,N=g,C=g=0,T=null,E=y.next();N!==null&&!E.done;C++,E=y.next()){N.index>C?(T=N,N=null):T=N.sibling;var _=h(j,N,E.value,m);if(_===null){N===null&&(N=T);break}e&&N&&_.alternate===null&&t(j,N),g=l(_,g,C),S===null?k=_:S.sibling=_,S=_,N=T}if(E.done)return n(j,N),He&&br(j,C),k;if(N===null){for(;!E.done;C++,E=y.next())E=d(j,E.value,m),E!==null&&(g=l(E,g,C),S===null?k=E:S.sibling=E,S=E);return He&&br(j,C),k}for(N=r(j,N);!E.done;C++,E=y.next())E=x(N,j,C,E.value,m),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?C:E.key),g=l(E,g,C),S===null?k=E:S.sibling=E,S=E);return e&&N.forEach(function(F){return t(j,F)}),He&&br(j,C),k}function b(j,g,y,m){if(typeof y=="object"&&y!==null&&y.type===ai&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Oo:e:{for(var k=y.key,S=g;S!==null;){if(S.key===k){if(k=y.type,k===ai){if(S.tag===7){n(j,S.sibling),g=i(S,y.props.children),g.return=j,j=g;break e}}else if(S.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Us&&sx(k)===S.type){n(j,S.sibling),g=i(S,y.props),g.ref=gl(j,S,y),g.return=j,j=g;break e}n(j,S);break}else t(j,S);S=S.sibling}y.type===ai?(g=Ar(y.props.children,j.mode,m,y.key),g.return=j,j=g):(m=Ma(y.type,y.key,y.props,null,j.mode,m),m.ref=gl(j,g,y),m.return=j,j=m)}return o(j);case oi:e:{for(S=y.key;g!==null;){if(g.key===S)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(j,g.sibling),g=i(g,y.children||[]),g.return=j,j=g;break e}else{n(j,g);break}else t(j,g);g=g.sibling}g=nd(y,j.mode,m),g.return=j,j=g}return o(j);case Us:return S=y._init,b(j,g,S(y._payload),m)}if(Nl(y))return v(j,g,y,m);if(dl(y))return w(j,g,y,m);Go(j,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(j,g.sibling),g=i(g,y),g.return=j,j=g):(n(j,g),g=td(y,j.mode,m),g.return=j,j=g),o(j)):n(j,g)}return b}var Mi=Ny(!0),Cy=Ny(!1),ic=fr(null),lc=null,gi=null,cp=null;function up(){cp=gi=lc=null}function dp(e){var t=ic.current;ze(ic),e._currentValue=t}function bf(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Si(e,t){lc=e,cp=gi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Jt=!0),e.firstContext=null)}function En(e){var t=e._currentValue;if(cp!==e)if(e={context:e,memoizedValue:t,next:null},gi===null){if(lc===null)throw Error(Q(308));gi=e,lc.dependencies={lanes:0,firstContext:e}}else gi=gi.next=e;return t}var Nr=null;function fp(e){Nr===null?Nr=[e]:Nr.push(e)}function Ey(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,fp(t)):(n.next=i.next,i.next=n),t.interleaved=n,ks(e,r)}function ks(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Bs=!1;function hp(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ay(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 xs(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Js(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Re&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,ks(e,n)}return i=r.interleaved,i===null?(t.next=t,fp(r)):(t.next=i.next,i.next=t),r.interleaved=t,ks(e,n)}function Ea(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xh(e,n)}}function rx(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?i=l=o:l=l.next=o,n=n.next}while(n!==null);l===null?i=l=t:l=l.next=t}else i=l=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:l,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function oc(e,t,n,r){var i=e.updateQueue;Bs=!1;var l=i.firstBaseUpdate,o=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var c=a,u=c.next;c.next=null,o===null?l=u:o.next=u,o=c;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==o&&(a===null?p.firstBaseUpdate=u:a.next=u,p.lastBaseUpdate=c))}if(l!==null){var d=i.baseState;o=0,p=u=c=null,a=l;do{var h=a.lane,x=a.eventTime;if((r&h)===h){p!==null&&(p=p.next={eventTime:x,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var v=e,w=a;switch(h=t,x=n,w.tag){case 1:if(v=w.payload,typeof v=="function"){d=v.call(x,d,h);break e}d=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=w.payload,h=typeof v=="function"?v.call(x,d,h):v,h==null)break e;d=qe({},d,h);break e;case 2:Bs=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=i.effects,h===null?i.effects=[a]:h.push(a))}else x={eventTime:x,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(u=p=x,c=d):p=p.next=x,o|=h;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;h=a,a=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(p===null&&(c=d),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=p,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else l===null&&(i.shared.lanes=0);$r|=o,e.lanes=o,e.memoizedState=d}}function ix(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(Q(191,i));i.call(r)}}}var xo={},es=fr(xo),Ql=fr(xo),Jl=fr(xo);function Cr(e){if(e===xo)throw Error(Q(174));return e}function pp(e,t){switch(Ue(Jl,t),Ue(Ql,e),Ue(es,xo),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:tf(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=tf(t,e)}ze(es),Ue(es,t)}function $i(){ze(es),ze(Ql),ze(Jl)}function Ry(e){Cr(Jl.current);var t=Cr(es.current),n=tf(t,e.type);t!==n&&(Ue(Ql,e),Ue(es,n))}function mp(e){Ql.current===e&&(ze(es),ze(Ql))}var Ke=fr(0);function ac(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var qu=[];function gp(){for(var e=0;e<qu.length;e++)qu[e]._workInProgressVersionPrimary=null;qu.length=0}var Aa=Ts.ReactCurrentDispatcher,Qu=Ts.ReactCurrentBatchConfig,Mr=0,Ge=null,dt=null,gt=null,cc=!1,Ml=!1,Xl=0,vC=0;function Mt(){throw Error(Q(321))}function xp(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Fn(e[n],t[n]))return!1;return!0}function vp(e,t,n,r,i,l){if(Mr=l,Ge=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Aa.current=e===null||e.memoizedState===null?bC:kC,e=n(r,i),Ml){l=0;do{if(Ml=!1,Xl=0,25<=l)throw Error(Q(301));l+=1,gt=dt=null,t.updateQueue=null,Aa.current=SC,e=n(r,i)}while(Ml)}if(Aa.current=uc,t=dt!==null&&dt.next!==null,Mr=0,gt=dt=Ge=null,cc=!1,t)throw Error(Q(300));return e}function jp(){var e=Xl!==0;return Xl=0,e}function Yn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gt===null?Ge.memoizedState=gt=e:gt=gt.next=e,gt}function An(){if(dt===null){var e=Ge.alternate;e=e!==null?e.memoizedState:null}else e=dt.next;var t=gt===null?Ge.memoizedState:gt.next;if(t!==null)gt=t,dt=e;else{if(e===null)throw Error(Q(310));dt=e,e={memoizedState:dt.memoizedState,baseState:dt.baseState,baseQueue:dt.baseQueue,queue:dt.queue,next:null},gt===null?Ge.memoizedState=gt=e:gt=gt.next=e}return gt}function Zl(e,t){return typeof t=="function"?t(e):t}function Ju(e){var t=An(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=dt,i=r.baseQueue,l=n.pending;if(l!==null){if(i!==null){var o=i.next;i.next=l.next,l.next=o}r.baseQueue=i=l,n.pending=null}if(i!==null){l=i.next,r=r.baseState;var a=o=null,c=null,u=l;do{var p=u.lane;if((Mr&p)===p)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:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(a=c=d,o=r):c=c.next=d,Ge.lanes|=p,$r|=p}u=u.next}while(u!==null&&u!==l);c===null?o=r:c.next=a,Fn(r,t.memoizedState)||(Jt=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do l=i.lane,Ge.lanes|=l,$r|=l,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Xu(e){var t=An(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,l=t.memoizedState;if(i!==null){n.pending=null;var o=i=i.next;do l=e(l,o.action),o=o.next;while(o!==i);Fn(l,t.memoizedState)||(Jt=!0),t.memoizedState=l,t.baseQueue===null&&(t.baseState=l),n.lastRenderedState=l}return[l,r]}function Ty(){}function Py(e,t){var n=Ge,r=An(),i=t(),l=!Fn(r.memoizedState,i);if(l&&(r.memoizedState=i,Jt=!0),r=r.queue,yp($y.bind(null,n,r,e),[e]),r.getSnapshot!==t||l||gt!==null&&gt.memoizedState.tag&1){if(n.flags|=2048,eo(9,My.bind(null,n,r,i,t),void 0,null),jt===null)throw Error(Q(349));Mr&30||Iy(n,t,i)}return i}function Iy(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ge.updateQueue,t===null?(t={lastEffect:null,stores:null},Ge.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function My(e,t,n,r){t.value=n,t.getSnapshot=r,_y(t)&&Oy(e)}function $y(e,t,n){return n(function(){_y(t)&&Oy(e)})}function _y(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Fn(e,n)}catch{return!0}}function Oy(e){var t=ks(e,1);t!==null&&Ln(t,e,1,-1)}function lx(e){var t=Yn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Zl,lastRenderedState:e},t.queue=e,e=e.dispatch=wC.bind(null,Ge,e),[t.memoizedState,e]}function eo(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ge.updateQueue,t===null?(t={lastEffect:null,stores:null},Ge.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Dy(){return An().memoizedState}function Ra(e,t,n,r){var i=Yn();Ge.flags|=e,i.memoizedState=eo(1|t,n,void 0,r===void 0?null:r)}function zc(e,t,n,r){var i=An();r=r===void 0?null:r;var l=void 0;if(dt!==null){var o=dt.memoizedState;if(l=o.destroy,r!==null&&xp(r,o.deps)){i.memoizedState=eo(t,n,l,r);return}}Ge.flags|=e,i.memoizedState=eo(1|t,n,l,r)}function ox(e,t){return Ra(8390656,8,e,t)}function yp(e,t){return zc(2048,8,e,t)}function Ly(e,t){return zc(4,2,e,t)}function Fy(e,t){return zc(4,4,e,t)}function Uy(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 By(e,t,n){return n=n!=null?n.concat([e]):null,zc(4,4,Uy.bind(null,t,e),n)}function wp(){}function zy(e,t){var n=An();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xp(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Wy(e,t){var n=An();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xp(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Vy(e,t,n){return Mr&21?(Fn(n,t)||(n=qj(),Ge.lanes|=n,$r|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Jt=!0),e.memoizedState=n)}function jC(e,t){var n=$e;$e=n!==0&&4>n?n:4,e(!0);var r=Qu.transition;Qu.transition={};try{e(!1),t()}finally{$e=n,Qu.transition=r}}function Hy(){return An().memoizedState}function yC(e,t,n){var r=Zs(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ky(e))Gy(t,n);else if(n=Ey(e,t,n,r),n!==null){var i=Wt();Ln(n,e,r,i),Yy(n,t,r)}}function wC(e,t,n){var r=Zs(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ky(e))Gy(t,i);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=t.lastRenderedReducer,l!==null))try{var o=t.lastRenderedState,a=l(o,n);if(i.hasEagerState=!0,i.eagerState=a,Fn(a,o)){var c=t.interleaved;c===null?(i.next=i,fp(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=Ey(e,t,i,r),n!==null&&(i=Wt(),Ln(n,e,r,i),Yy(n,t,r))}}function Ky(e){var t=e.alternate;return e===Ge||t!==null&&t===Ge}function Gy(e,t){Ml=cc=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Yy(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xh(e,n)}}var uc={readContext:En,useCallback:Mt,useContext:Mt,useEffect:Mt,useImperativeHandle:Mt,useInsertionEffect:Mt,useLayoutEffect:Mt,useMemo:Mt,useReducer:Mt,useRef:Mt,useState:Mt,useDebugValue:Mt,useDeferredValue:Mt,useTransition:Mt,useMutableSource:Mt,useSyncExternalStore:Mt,useId:Mt,unstable_isNewReconciler:!1},bC={readContext:En,useCallback:function(e,t){return Yn().memoizedState=[e,t===void 0?null:t],e},useContext:En,useEffect:ox,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ra(4194308,4,Uy.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ra(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ra(4,2,e,t)},useMemo:function(e,t){var n=Yn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Yn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=yC.bind(null,Ge,e),[r.memoizedState,e]},useRef:function(e){var t=Yn();return e={current:e},t.memoizedState=e},useState:lx,useDebugValue:wp,useDeferredValue:function(e){return Yn().memoizedState=e},useTransition:function(){var e=lx(!1),t=e[0];return e=jC.bind(null,e[1]),Yn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ge,i=Yn();if(He){if(n===void 0)throw Error(Q(407));n=n()}else{if(n=t(),jt===null)throw Error(Q(349));Mr&30||Iy(r,t,n)}i.memoizedState=n;var l={value:n,getSnapshot:t};return i.queue=l,ox($y.bind(null,r,l,e),[e]),r.flags|=2048,eo(9,My.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=Yn(),t=jt.identifierPrefix;if(He){var n=gs,r=ms;n=(r&~(1<<32-Dn(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Xl++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=vC++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},kC={readContext:En,useCallback:zy,useContext:En,useEffect:yp,useImperativeHandle:By,useInsertionEffect:Ly,useLayoutEffect:Fy,useMemo:Wy,useReducer:Ju,useRef:Dy,useState:function(){return Ju(Zl)},useDebugValue:wp,useDeferredValue:function(e){var t=An();return Vy(t,dt.memoizedState,e)},useTransition:function(){var e=Ju(Zl)[0],t=An().memoizedState;return[e,t]},useMutableSource:Ty,useSyncExternalStore:Py,useId:Hy,unstable_isNewReconciler:!1},SC={readContext:En,useCallback:zy,useContext:En,useEffect:yp,useImperativeHandle:By,useInsertionEffect:Ly,useLayoutEffect:Fy,useMemo:Wy,useReducer:Xu,useRef:Dy,useState:function(){return Xu(Zl)},useDebugValue:wp,useDeferredValue:function(e){var t=An();return dt===null?t.memoizedState=e:Vy(t,dt.memoizedState,e)},useTransition:function(){var e=Xu(Zl)[0],t=An().memoizedState;return[e,t]},useMutableSource:Ty,useSyncExternalStore:Py,useId:Hy,unstable_isNewReconciler:!1};function Mn(e,t){if(e&&e.defaultProps){t=qe({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function kf(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:qe({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Wc={isMounted:function(e){return(e=e._reactInternals)?Wr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Wt(),i=Zs(e),l=xs(r,i);l.payload=t,n!=null&&(l.callback=n),t=Js(e,l,i),t!==null&&(Ln(t,e,i,r),Ea(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Wt(),i=Zs(e),l=xs(r,i);l.tag=1,l.payload=t,n!=null&&(l.callback=n),t=Js(e,l,i),t!==null&&(Ln(t,e,i,r),Ea(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Wt(),r=Zs(e),i=xs(n,r);i.tag=2,t!=null&&(i.callback=t),t=Js(e,i,r),t!==null&&(Ln(t,e,r,n),Ea(t,e,r))}};function ax(e,t,n,r,i,l,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,l,o):t.prototype&&t.prototype.isPureReactComponent?!Kl(n,r)||!Kl(i,l):!0}function qy(e,t,n){var r=!1,i=ir,l=t.contextType;return typeof l=="object"&&l!==null?l=En(l):(i=en(t)?Pr:Lt.current,r=t.contextTypes,l=(r=r!=null)?Pi(e,i):ir),t=new t(n,l),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Wc,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=l),t}function cx(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Wc.enqueueReplaceState(t,t.state,null)}function Sf(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},hp(e);var l=t.contextType;typeof l=="object"&&l!==null?i.context=En(l):(l=en(t)?Pr:Lt.current,i.context=Pi(e,l)),i.state=e.memoizedState,l=t.getDerivedStateFromProps,typeof l=="function"&&(kf(e,t,l,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&Wc.enqueueReplaceState(i,i.state,null),oc(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function _i(e,t){try{var n="",r=t;do n+=X1(r),r=r.return;while(r);var i=n}catch(l){i=`
39
- Error generating stack: `+l.message+`
40
- `+l.stack}return{value:e,source:t,stack:i,digest:null}}function Zu(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Nf(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var NC=typeof WeakMap=="function"?WeakMap:Map;function Qy(e,t,n){n=xs(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){fc||(fc=!0,_f=r),Nf(e,t)},n}function Jy(e,t,n){n=xs(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Nf(e,t)}}var l=e.stateNode;return l!==null&&typeof l.componentDidCatch=="function"&&(n.callback=function(){Nf(e,t),typeof r!="function"&&(Xs===null?Xs=new Set([this]):Xs.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function ux(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new NC;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=FC.bind(null,e,t,n),t.then(e,e))}function dx(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 fx(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=xs(-1,1),t.tag=2,Js(n,t,1))),n.lanes|=1),e)}var CC=Ts.ReactCurrentOwner,Jt=!1;function Ut(e,t,n,r){t.child=e===null?Cy(t,null,n,r):Mi(t,e.child,n,r)}function hx(e,t,n,r,i){n=n.render;var l=t.ref;return Si(t,i),r=vp(e,t,n,r,l,i),n=jp(),e!==null&&!Jt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ss(e,t,i)):(He&&n&&lp(t),t.flags|=1,Ut(e,t,r,i),t.child)}function px(e,t,n,r,i){if(e===null){var l=n.type;return typeof l=="function"&&!Rp(l)&&l.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=l,Xy(e,t,l,r,i)):(e=Ma(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(l=e.child,!(e.lanes&i)){var o=l.memoizedProps;if(n=n.compare,n=n!==null?n:Kl,n(o,r)&&e.ref===t.ref)return Ss(e,t,i)}return t.flags|=1,e=er(l,r),e.ref=t.ref,e.return=t,t.child=e}function Xy(e,t,n,r,i){if(e!==null){var l=e.memoizedProps;if(Kl(l,r)&&e.ref===t.ref)if(Jt=!1,t.pendingProps=r=l,(e.lanes&i)!==0)e.flags&131072&&(Jt=!0);else return t.lanes=e.lanes,Ss(e,t,i)}return Cf(e,t,n,r,i)}function Zy(e,t,n){var r=t.pendingProps,i=r.children,l=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ue(vi,fn),fn|=n;else{if(!(n&1073741824))return e=l!==null?l.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ue(vi,fn),fn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=l!==null?l.baseLanes:n,Ue(vi,fn),fn|=r}else l!==null?(r=l.baseLanes|n,t.memoizedState=null):r=n,Ue(vi,fn),fn|=r;return Ut(e,t,i,n),t.child}function ew(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Cf(e,t,n,r,i){var l=en(n)?Pr:Lt.current;return l=Pi(t,l),Si(t,i),n=vp(e,t,n,r,l,i),r=jp(),e!==null&&!Jt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ss(e,t,i)):(He&&r&&lp(t),t.flags|=1,Ut(e,t,n,i),t.child)}function mx(e,t,n,r,i){if(en(n)){var l=!0;nc(t)}else l=!1;if(Si(t,i),t.stateNode===null)Ta(e,t),qy(t,n,r),Sf(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var c=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=En(u):(u=en(n)?Pr:Lt.current,u=Pi(t,u));var p=n.getDerivedStateFromProps,d=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||c!==u)&&cx(t,o,r,u),Bs=!1;var h=t.memoizedState;o.state=h,oc(t,r,o,i),c=t.memoizedState,a!==r||h!==c||Zt.current||Bs?(typeof p=="function"&&(kf(t,n,p,r),c=t.memoizedState),(a=Bs||ax(t,n,a,r,h,c,u))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Ay(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Mn(t.type,a),o.props=u,d=t.pendingProps,h=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=En(c):(c=en(n)?Pr:Lt.current,c=Pi(t,c));var x=n.getDerivedStateFromProps;(p=typeof x=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||h!==c)&&cx(t,o,r,c),Bs=!1,h=t.memoizedState,o.state=h,oc(t,r,o,i);var v=t.memoizedState;a!==d||h!==v||Zt.current||Bs?(typeof x=="function"&&(kf(t,n,x,r),v=t.memoizedState),(u=Bs||ax(t,n,u,r,h,v,c)||!1)?(p||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,v,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,v,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=v),o.props=r,o.state=v,o.context=c,r=u):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Ef(e,t,n,r,l,i)}function Ef(e,t,n,r,i,l){ew(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return i&&ex(t,n,!1),Ss(e,t,l);r=t.stateNode,CC.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Mi(t,e.child,null,l),t.child=Mi(t,null,a,l)):Ut(e,t,a,l),t.memoizedState=r.state,i&&ex(t,n,!0),t.child}function tw(e){var t=e.stateNode;t.pendingContext?Zg(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Zg(e,t.context,!1),pp(e,t.containerInfo)}function gx(e,t,n,r,i){return Ii(),ap(i),t.flags|=256,Ut(e,t,n,r),t.child}var Af={dehydrated:null,treeContext:null,retryLane:0};function Rf(e){return{baseLanes:e,cachePool:null,transitions:null}}function nw(e,t,n){var r=t.pendingProps,i=Ke.current,l=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(l=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Ue(Ke,i&1),e===null)return wf(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,l?(r=t.mode,l=t.child,o={mode:"hidden",children:o},!(r&1)&&l!==null?(l.childLanes=0,l.pendingProps=o):l=Kc(o,r,0,null),e=Ar(e,r,n,null),l.return=t,e.return=t,l.sibling=e,t.child=l,t.child.memoizedState=Rf(n),t.memoizedState=Af,e):bp(t,o));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return EC(e,t,o,r,a,i,n);if(l){l=r.fallback,o=t.mode,i=e.child,a=i.sibling;var c={mode:"hidden",children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=er(i,c),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?l=er(a,l):(l=Ar(l,o,n,null),l.flags|=2),l.return=t,r.return=t,r.sibling=l,t.child=r,r=l,l=t.child,o=e.child.memoizedState,o=o===null?Rf(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},l.memoizedState=o,l.childLanes=e.childLanes&~n,t.memoizedState=Af,r}return l=e.child,e=l.sibling,r=er(l,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function bp(e,t){return t=Kc({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Yo(e,t,n,r){return r!==null&&ap(r),Mi(t,e.child,null,n),e=bp(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function EC(e,t,n,r,i,l,o){if(n)return t.flags&256?(t.flags&=-257,r=Zu(Error(Q(422))),Yo(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(l=r.fallback,i=t.mode,r=Kc({mode:"visible",children:r.children},i,0,null),l=Ar(l,i,o,null),l.flags|=2,r.return=t,l.return=t,r.sibling=l,t.child=r,t.mode&1&&Mi(t,e.child,null,o),t.child.memoizedState=Rf(o),t.memoizedState=Af,l);if(!(t.mode&1))return Yo(e,t,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,l=Error(Q(419)),r=Zu(l,r,void 0),Yo(e,t,o,r)}if(a=(o&e.childLanes)!==0,Jt||a){if(r=jt,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==l.retryLane&&(l.retryLane=i,ks(e,i),Ln(r,e,i,-1))}return Ap(),r=Zu(Error(Q(421))),Yo(e,t,o,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=UC.bind(null,e),i._reactRetry=t,null):(e=l.treeContext,pn=Qs(i.nextSibling),gn=t,He=!0,_n=null,e!==null&&(bn[kn++]=ms,bn[kn++]=gs,bn[kn++]=Ir,ms=e.id,gs=e.overflow,Ir=t),t=bp(t,r.children),t.flags|=4096,t)}function xx(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),bf(e.return,t,n)}function ed(e,t,n,r,i){var l=e.memoizedState;l===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(l.isBackwards=t,l.rendering=null,l.renderingStartTime=0,l.last=r,l.tail=n,l.tailMode=i)}function sw(e,t,n){var r=t.pendingProps,i=r.revealOrder,l=r.tail;if(Ut(e,t,r.children,n),r=Ke.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&&xx(e,n,t);else if(e.tag===19)xx(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ue(Ke,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&ac(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ed(t,!1,i,n,l);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ac(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ed(t,!0,n,null,l);break;case"together":ed(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ta(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ss(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$r|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Q(153));if(t.child!==null){for(e=t.child,n=er(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=er(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function AC(e,t,n){switch(t.tag){case 3:tw(t),Ii();break;case 5:Ry(t);break;case 1:en(t.type)&&nc(t);break;case 4:pp(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Ue(ic,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Ue(Ke,Ke.current&1),t.flags|=128,null):n&t.child.childLanes?nw(e,t,n):(Ue(Ke,Ke.current&1),e=Ss(e,t,n),e!==null?e.sibling:null);Ue(Ke,Ke.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return sw(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ue(Ke,Ke.current),r)break;return null;case 22:case 23:return t.lanes=0,Zy(e,t,n)}return Ss(e,t,n)}var rw,Tf,iw,lw;rw=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Tf=function(){};iw=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Cr(es.current);var l=null;switch(n){case"input":i=Jd(e,i),r=Jd(e,r),l=[];break;case"select":i=qe({},i,{value:void 0}),r=qe({},r,{value:void 0}),l=[];break;case"textarea":i=ef(e,i),r=ef(e,r),l=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ec)}nf(n,r);var o;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var a=i[u];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Fl.hasOwnProperty(u)?l||(l=[]):(l=l||[]).push(u,null));for(u in r){var c=r[u];if(a=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==a&&(c!=null||a!=null))if(u==="style")if(a){for(o in a)!a.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&a[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(l||(l=[]),l.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,a=a?a.__html:void 0,c!=null&&a!==c&&(l=l||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(l=l||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Fl.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Be("scroll",e),l||a===c||(l=[])):(l=l||[]).push(u,c))}n&&(l=l||[]).push("style",n);var u=l;(t.updateQueue=u)&&(t.flags|=4)}};lw=function(e,t,n,r){n!==r&&(t.flags|=4)};function xl(e,t){if(!He)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function $t(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function RC(e,t,n){var r=t.pendingProps;switch(op(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $t(t),null;case 1:return en(t.type)&&tc(),$t(t),null;case 3:return r=t.stateNode,$i(),ze(Zt),ze(Lt),gp(),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,_n!==null&&(Lf(_n),_n=null))),Tf(e,t),$t(t),null;case 5:mp(t);var i=Cr(Jl.current);if(n=t.type,e!==null&&t.stateNode!=null)iw(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Q(166));return $t(t),null}if(e=Cr(es.current),Ko(t)){r=t.stateNode,n=t.type;var l=t.memoizedProps;switch(r[qn]=t,r[ql]=l,e=(t.mode&1)!==0,n){case"dialog":Be("cancel",r),Be("close",r);break;case"iframe":case"object":case"embed":Be("load",r);break;case"video":case"audio":for(i=0;i<El.length;i++)Be(El[i],r);break;case"source":Be("error",r);break;case"img":case"image":case"link":Be("error",r),Be("load",r);break;case"details":Be("toggle",r);break;case"input":Cg(r,l),Be("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!l.multiple},Be("invalid",r);break;case"textarea":Ag(r,l),Be("invalid",r)}nf(n,l),i=null;for(var o in l)if(l.hasOwnProperty(o)){var a=l[o];o==="children"?typeof a=="string"?r.textContent!==a&&(l.suppressHydrationWarning!==!0&&Ho(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(l.suppressHydrationWarning!==!0&&Ho(r.textContent,a,e),i=["children",""+a]):Fl.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&Be("scroll",r)}switch(n){case"input":Do(r),Eg(r,l,!0);break;case"textarea":Do(r),Rg(r);break;case"select":case"option":break;default:typeof l.onClick=="function"&&(r.onclick=ec)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=$j(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[qn]=t,e[ql]=r,rw(e,t,!1,!1),t.stateNode=e;e:{switch(o=sf(n,r),n){case"dialog":Be("cancel",e),Be("close",e),i=r;break;case"iframe":case"object":case"embed":Be("load",e),i=r;break;case"video":case"audio":for(i=0;i<El.length;i++)Be(El[i],e);i=r;break;case"source":Be("error",e),i=r;break;case"img":case"image":case"link":Be("error",e),Be("load",e),i=r;break;case"details":Be("toggle",e),i=r;break;case"input":Cg(e,r),i=Jd(e,r),Be("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=qe({},r,{value:void 0}),Be("invalid",e);break;case"textarea":Ag(e,r),i=ef(e,r),Be("invalid",e);break;default:i=r}nf(n,i),a=i;for(l in a)if(a.hasOwnProperty(l)){var c=a[l];l==="style"?Dj(e,c):l==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&_j(e,c)):l==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Ul(e,c):typeof c=="number"&&Ul(e,""+c):l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&l!=="autoFocus"&&(Fl.hasOwnProperty(l)?c!=null&&l==="onScroll"&&Be("scroll",e):c!=null&&Kh(e,l,c,o))}switch(n){case"input":Do(e),Eg(e,r,!1);break;case"textarea":Do(e),Rg(e);break;case"option":r.value!=null&&e.setAttribute("value",""+rr(r.value));break;case"select":e.multiple=!!r.multiple,l=r.value,l!=null?yi(e,!!r.multiple,l,!1):r.defaultValue!=null&&yi(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=ec)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return $t(t),null;case 6:if(e&&t.stateNode!=null)lw(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Q(166));if(n=Cr(Jl.current),Cr(es.current),Ko(t)){if(r=t.stateNode,n=t.memoizedProps,r[qn]=t,(l=r.nodeValue!==n)&&(e=gn,e!==null))switch(e.tag){case 3:Ho(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ho(r.nodeValue,n,(e.mode&1)!==0)}l&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[qn]=t,t.stateNode=r}return $t(t),null;case 13:if(ze(Ke),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(He&&pn!==null&&t.mode&1&&!(t.flags&128))Sy(),Ii(),t.flags|=98560,l=!1;else if(l=Ko(t),r!==null&&r.dehydrated!==null){if(e===null){if(!l)throw Error(Q(318));if(l=t.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(Q(317));l[qn]=t}else Ii(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;$t(t),l=!1}else _n!==null&&(Lf(_n),_n=null),l=!0;if(!l)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Ke.current&1?pt===0&&(pt=3):Ap())),t.updateQueue!==null&&(t.flags|=4),$t(t),null);case 4:return $i(),Tf(e,t),e===null&&Gl(t.stateNode.containerInfo),$t(t),null;case 10:return dp(t.type._context),$t(t),null;case 17:return en(t.type)&&tc(),$t(t),null;case 19:if(ze(Ke),l=t.memoizedState,l===null)return $t(t),null;if(r=(t.flags&128)!==0,o=l.rendering,o===null)if(r)xl(l,!1);else{if(pt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=ac(e),o!==null){for(t.flags|=128,xl(l,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)l=n,e=r,l.flags&=14680066,o=l.alternate,o===null?(l.childLanes=0,l.lanes=e,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=o.childLanes,l.lanes=o.lanes,l.child=o.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=o.memoizedProps,l.memoizedState=o.memoizedState,l.updateQueue=o.updateQueue,l.type=o.type,e=o.dependencies,l.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ue(Ke,Ke.current&1|2),t.child}e=e.sibling}l.tail!==null&&nt()>Oi&&(t.flags|=128,r=!0,xl(l,!1),t.lanes=4194304)}else{if(!r)if(e=ac(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),xl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!o.alternate&&!He)return $t(t),null}else 2*nt()-l.renderingStartTime>Oi&&n!==1073741824&&(t.flags|=128,r=!0,xl(l,!1),t.lanes=4194304);l.isBackwards?(o.sibling=t.child,t.child=o):(n=l.last,n!==null?n.sibling=o:t.child=o,l.last=o)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=nt(),t.sibling=null,n=Ke.current,Ue(Ke,r?n&1|2:n&1),t):($t(t),null);case 22:case 23:return Ep(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?fn&1073741824&&($t(t),t.subtreeFlags&6&&(t.flags|=8192)):$t(t),null;case 24:return null;case 25:return null}throw Error(Q(156,t.tag))}function TC(e,t){switch(op(t),t.tag){case 1:return en(t.type)&&tc(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $i(),ze(Zt),ze(Lt),gp(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return mp(t),null;case 13:if(ze(Ke),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Q(340));Ii()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ze(Ke),null;case 4:return $i(),null;case 10:return dp(t.type._context),null;case 22:case 23:return Ep(),null;case 24:return null;default:return null}}var qo=!1,Ot=!1,PC=typeof WeakSet=="function"?WeakSet:Set,ie=null;function xi(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Xe(e,t,r)}else n.current=null}function Pf(e,t,n){try{n()}catch(r){Xe(e,t,r)}}var vx=!1;function IC(e,t){if(pf=Ja,e=dy(),ip(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var o=0,a=-1,c=-1,u=0,p=0,d=e,h=null;t:for(;;){for(var x;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==l||r!==0&&d.nodeType!==3||(c=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(x=d.firstChild)!==null;)h=d,d=x;for(;;){if(d===e)break t;if(h===n&&++u===i&&(a=o),h===l&&++p===r&&(c=o),(x=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=x}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(mf={focusedElem:e,selectionRange:n},Ja=!1,ie=t;ie!==null;)if(t=ie,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ie=e;else for(;ie!==null;){t=ie;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var w=v.memoizedProps,b=v.memoizedState,j=t.stateNode,g=j.getSnapshotBeforeUpdate(t.elementType===t.type?w:Mn(t.type,w),b);j.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Q(163))}}catch(m){Xe(t,t.return,m)}if(e=t.sibling,e!==null){e.return=t.return,ie=e;break}ie=t.return}return v=vx,vx=!1,v}function $l(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var l=i.destroy;i.destroy=void 0,l!==void 0&&Pf(t,n,l)}i=i.next}while(i!==r)}}function Vc(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function If(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function ow(e){var t=e.alternate;t!==null&&(e.alternate=null,ow(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[qn],delete t[ql],delete t[vf],delete t[pC],delete t[mC])),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 aw(e){return e.tag===5||e.tag===3||e.tag===4}function jx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||aw(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 Mf(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ec));else if(r!==4&&(e=e.child,e!==null))for(Mf(e,t,n),e=e.sibling;e!==null;)Mf(e,t,n),e=e.sibling}function $f(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for($f(e,t,n),e=e.sibling;e!==null;)$f(e,t,n),e=e.sibling}var Ct=null,$n=!1;function Ls(e,t,n){for(n=n.child;n!==null;)cw(e,t,n),n=n.sibling}function cw(e,t,n){if(Zn&&typeof Zn.onCommitFiberUnmount=="function")try{Zn.onCommitFiberUnmount(Oc,n)}catch{}switch(n.tag){case 5:Ot||xi(n,t);case 6:var r=Ct,i=$n;Ct=null,Ls(e,t,n),Ct=r,$n=i,Ct!==null&&($n?(e=Ct,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ct.removeChild(n.stateNode));break;case 18:Ct!==null&&($n?(e=Ct,n=n.stateNode,e.nodeType===8?Gu(e.parentNode,n):e.nodeType===1&&Gu(e,n),Vl(e)):Gu(Ct,n.stateNode));break;case 4:r=Ct,i=$n,Ct=n.stateNode.containerInfo,$n=!0,Ls(e,t,n),Ct=r,$n=i;break;case 0:case 11:case 14:case 15:if(!Ot&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var l=i,o=l.destroy;l=l.tag,o!==void 0&&(l&2||l&4)&&Pf(n,t,o),i=i.next}while(i!==r)}Ls(e,t,n);break;case 1:if(!Ot&&(xi(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Xe(n,t,a)}Ls(e,t,n);break;case 21:Ls(e,t,n);break;case 22:n.mode&1?(Ot=(r=Ot)||n.memoizedState!==null,Ls(e,t,n),Ot=r):Ls(e,t,n);break;default:Ls(e,t,n)}}function yx(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new PC),t.forEach(function(r){var i=BC.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Pn(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var l=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:Ct=a.stateNode,$n=!1;break e;case 3:Ct=a.stateNode.containerInfo,$n=!0;break e;case 4:Ct=a.stateNode.containerInfo,$n=!0;break e}a=a.return}if(Ct===null)throw Error(Q(160));cw(l,o,i),Ct=null,$n=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){Xe(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)uw(t,e),t=t.sibling}function uw(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Pn(t,e),Kn(e),r&4){try{$l(3,e,e.return),Vc(3,e)}catch(w){Xe(e,e.return,w)}try{$l(5,e,e.return)}catch(w){Xe(e,e.return,w)}}break;case 1:Pn(t,e),Kn(e),r&512&&n!==null&&xi(n,n.return);break;case 5:if(Pn(t,e),Kn(e),r&512&&n!==null&&xi(n,n.return),e.flags&32){var i=e.stateNode;try{Ul(i,"")}catch(w){Xe(e,e.return,w)}}if(r&4&&(i=e.stateNode,i!=null)){var l=e.memoizedProps,o=n!==null?n.memoizedProps:l,a=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{a==="input"&&l.type==="radio"&&l.name!=null&&Ij(i,l),sf(a,o);var u=sf(a,l);for(o=0;o<c.length;o+=2){var p=c[o],d=c[o+1];p==="style"?Dj(i,d):p==="dangerouslySetInnerHTML"?_j(i,d):p==="children"?Ul(i,d):Kh(i,p,d,u)}switch(a){case"input":Xd(i,l);break;case"textarea":Mj(i,l);break;case"select":var h=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!l.multiple;var x=l.value;x!=null?yi(i,!!l.multiple,x,!1):h!==!!l.multiple&&(l.defaultValue!=null?yi(i,!!l.multiple,l.defaultValue,!0):yi(i,!!l.multiple,l.multiple?[]:"",!1))}i[ql]=l}catch(w){Xe(e,e.return,w)}}break;case 6:if(Pn(t,e),Kn(e),r&4){if(e.stateNode===null)throw Error(Q(162));i=e.stateNode,l=e.memoizedProps;try{i.nodeValue=l}catch(w){Xe(e,e.return,w)}}break;case 3:if(Pn(t,e),Kn(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vl(t.containerInfo)}catch(w){Xe(e,e.return,w)}break;case 4:Pn(t,e),Kn(e);break;case 13:Pn(t,e),Kn(e),i=e.child,i.flags&8192&&(l=i.memoizedState!==null,i.stateNode.isHidden=l,!l||i.alternate!==null&&i.alternate.memoizedState!==null||(Np=nt())),r&4&&yx(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Ot=(u=Ot)||p,Pn(t,e),Ot=u):Pn(t,e),Kn(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(ie=e,p=e.child;p!==null;){for(d=ie=p;ie!==null;){switch(h=ie,x=h.child,h.tag){case 0:case 11:case 14:case 15:$l(4,h,h.return);break;case 1:xi(h,h.return);var v=h.stateNode;if(typeof v.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,v.props=t.memoizedProps,v.state=t.memoizedState,v.componentWillUnmount()}catch(w){Xe(r,n,w)}}break;case 5:xi(h,h.return);break;case 22:if(h.memoizedState!==null){bx(d);continue}}x!==null?(x.return=h,ie=x):bx(d)}p=p.sibling}e:for(p=null,d=e;;){if(d.tag===5){if(p===null){p=d;try{i=d.stateNode,u?(l=i.style,typeof l.setProperty=="function"?l.setProperty("display","none","important"):l.display="none"):(a=d.stateNode,c=d.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,a.style.display=Oj("display",o))}catch(w){Xe(e,e.return,w)}}}else if(d.tag===6){if(p===null)try{d.stateNode.nodeValue=u?"":d.memoizedProps}catch(w){Xe(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;p===d&&(p=null),d=d.return}p===d&&(p=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Pn(t,e),Kn(e),r&4&&yx(e);break;case 21:break;default:Pn(t,e),Kn(e)}}function Kn(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(aw(n)){var r=n;break e}n=n.return}throw Error(Q(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Ul(i,""),r.flags&=-33);var l=jx(e);$f(e,l,i);break;case 3:case 4:var o=r.stateNode.containerInfo,a=jx(e);Mf(e,a,o);break;default:throw Error(Q(161))}}catch(c){Xe(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function MC(e,t,n){ie=e,dw(e)}function dw(e,t,n){for(var r=(e.mode&1)!==0;ie!==null;){var i=ie,l=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||qo;if(!o){var a=i.alternate,c=a!==null&&a.memoizedState!==null||Ot;a=qo;var u=Ot;if(qo=o,(Ot=c)&&!u)for(ie=i;ie!==null;)o=ie,c=o.child,o.tag===22&&o.memoizedState!==null?kx(i):c!==null?(c.return=o,ie=c):kx(i);for(;l!==null;)ie=l,dw(l),l=l.sibling;ie=i,qo=a,Ot=u}wx(e)}else i.subtreeFlags&8772&&l!==null?(l.return=i,ie=l):wx(e)}}function wx(e){for(;ie!==null;){var t=ie;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ot||Vc(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ot)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Mn(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var l=t.updateQueue;l!==null&&ix(t,l,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}ix(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var d=p.dehydrated;d!==null&&Vl(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Q(163))}Ot||t.flags&512&&If(t)}catch(h){Xe(t,t.return,h)}}if(t===e){ie=null;break}if(n=t.sibling,n!==null){n.return=t.return,ie=n;break}ie=t.return}}function bx(e){for(;ie!==null;){var t=ie;if(t===e){ie=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ie=n;break}ie=t.return}}function kx(e){for(;ie!==null;){var t=ie;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Vc(4,t)}catch(c){Xe(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){Xe(t,i,c)}}var l=t.return;try{If(t)}catch(c){Xe(t,l,c)}break;case 5:var o=t.return;try{If(t)}catch(c){Xe(t,o,c)}}}catch(c){Xe(t,t.return,c)}if(t===e){ie=null;break}var a=t.sibling;if(a!==null){a.return=t.return,ie=a;break}ie=t.return}}var $C=Math.ceil,dc=Ts.ReactCurrentDispatcher,kp=Ts.ReactCurrentOwner,Cn=Ts.ReactCurrentBatchConfig,Re=0,jt=null,ct=null,Et=0,fn=0,vi=fr(0),pt=0,to=null,$r=0,Hc=0,Sp=0,_l=null,qt=null,Np=0,Oi=1/0,fs=null,fc=!1,_f=null,Xs=null,Qo=!1,Hs=null,hc=0,Ol=0,Of=null,Pa=-1,Ia=0;function Wt(){return Re&6?nt():Pa!==-1?Pa:Pa=nt()}function Zs(e){return e.mode&1?Re&2&&Et!==0?Et&-Et:xC.transition!==null?(Ia===0&&(Ia=qj()),Ia):(e=$e,e!==0||(e=window.event,e=e===void 0?16:ny(e.type)),e):1}function Ln(e,t,n,r){if(50<Ol)throw Ol=0,Of=null,Error(Q(185));po(e,n,r),(!(Re&2)||e!==jt)&&(e===jt&&(!(Re&2)&&(Hc|=n),pt===4&&Ws(e,Et)),tn(e,r),n===1&&Re===0&&!(t.mode&1)&&(Oi=nt()+500,Bc&&hr()))}function tn(e,t){var n=e.callbackNode;xN(e,t);var r=Qa(e,e===jt?Et:0);if(r===0)n!==null&&Ig(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Ig(n),t===1)e.tag===0?gC(Sx.bind(null,e)):wy(Sx.bind(null,e)),fC(function(){!(Re&6)&&hr()}),n=null;else{switch(Qj(r)){case 1:n=Jh;break;case 4:n=Gj;break;case 16:n=qa;break;case 536870912:n=Yj;break;default:n=qa}n=jw(n,fw.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function fw(e,t){if(Pa=-1,Ia=0,Re&6)throw Error(Q(327));var n=e.callbackNode;if(Ni()&&e.callbackNode!==n)return null;var r=Qa(e,e===jt?Et:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=pc(e,r);else{t=r;var i=Re;Re|=2;var l=pw();(jt!==e||Et!==t)&&(fs=null,Oi=nt()+500,Er(e,t));do try{DC();break}catch(a){hw(e,a)}while(!0);up(),dc.current=l,Re=i,ct!==null?t=0:(jt=null,Et=0,t=pt)}if(t!==0){if(t===2&&(i=cf(e),i!==0&&(r=i,t=Df(e,i))),t===1)throw n=to,Er(e,0),Ws(e,r),tn(e,nt()),n;if(t===6)Ws(e,r);else{if(i=e.current.alternate,!(r&30)&&!_C(i)&&(t=pc(e,r),t===2&&(l=cf(e),l!==0&&(r=l,t=Df(e,l))),t===1))throw n=to,Er(e,0),Ws(e,r),tn(e,nt()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(Q(345));case 2:kr(e,qt,fs);break;case 3:if(Ws(e,r),(r&130023424)===r&&(t=Np+500-nt(),10<t)){if(Qa(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Wt(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=xf(kr.bind(null,e,qt,fs),t);break}kr(e,qt,fs);break;case 4:if(Ws(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var o=31-Dn(r);l=1<<o,o=t[o],o>i&&(i=o),r&=~l}if(r=i,r=nt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*$C(r/1960))-r,10<r){e.timeoutHandle=xf(kr.bind(null,e,qt,fs),r);break}kr(e,qt,fs);break;case 5:kr(e,qt,fs);break;default:throw Error(Q(329))}}}return tn(e,nt()),e.callbackNode===n?fw.bind(null,e):null}function Df(e,t){var n=_l;return e.current.memoizedState.isDehydrated&&(Er(e,t).flags|=256),e=pc(e,t),e!==2&&(t=qt,qt=n,t!==null&&Lf(t)),e}function Lf(e){qt===null?qt=e:qt.push.apply(qt,e)}function _C(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],l=i.getSnapshot;i=i.value;try{if(!Fn(l(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ws(e,t){for(t&=~Sp,t&=~Hc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Dn(t),r=1<<n;e[n]=-1,t&=~r}}function Sx(e){if(Re&6)throw Error(Q(327));Ni();var t=Qa(e,0);if(!(t&1))return tn(e,nt()),null;var n=pc(e,t);if(e.tag!==0&&n===2){var r=cf(e);r!==0&&(t=r,n=Df(e,r))}if(n===1)throw n=to,Er(e,0),Ws(e,t),tn(e,nt()),n;if(n===6)throw Error(Q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,kr(e,qt,fs),tn(e,nt()),null}function Cp(e,t){var n=Re;Re|=1;try{return e(t)}finally{Re=n,Re===0&&(Oi=nt()+500,Bc&&hr())}}function _r(e){Hs!==null&&Hs.tag===0&&!(Re&6)&&Ni();var t=Re;Re|=1;var n=Cn.transition,r=$e;try{if(Cn.transition=null,$e=1,e)return e()}finally{$e=r,Cn.transition=n,Re=t,!(Re&6)&&hr()}}function Ep(){fn=vi.current,ze(vi)}function Er(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,dC(n)),ct!==null)for(n=ct.return;n!==null;){var r=n;switch(op(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&tc();break;case 3:$i(),ze(Zt),ze(Lt),gp();break;case 5:mp(r);break;case 4:$i();break;case 13:ze(Ke);break;case 19:ze(Ke);break;case 10:dp(r.type._context);break;case 22:case 23:Ep()}n=n.return}if(jt=e,ct=e=er(e.current,null),Et=fn=t,pt=0,to=null,Sp=Hc=$r=0,qt=_l=null,Nr!==null){for(t=0;t<Nr.length;t++)if(n=Nr[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,l=n.pending;if(l!==null){var o=l.next;l.next=i,r.next=o}n.pending=r}Nr=null}return e}function hw(e,t){do{var n=ct;try{if(up(),Aa.current=uc,cc){for(var r=Ge.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}cc=!1}if(Mr=0,gt=dt=Ge=null,Ml=!1,Xl=0,kp.current=null,n===null||n.return===null){pt=1,to=t,ct=null;break}e:{var l=e,o=n.return,a=n,c=t;if(t=Et,a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=a,d=p.tag;if(!(p.mode&1)&&(d===0||d===11||d===15)){var h=p.alternate;h?(p.updateQueue=h.updateQueue,p.memoizedState=h.memoizedState,p.lanes=h.lanes):(p.updateQueue=null,p.memoizedState=null)}var x=dx(o);if(x!==null){x.flags&=-257,fx(x,o,a,l,t),x.mode&1&&ux(l,u,t),t=x,c=u;var v=t.updateQueue;if(v===null){var w=new Set;w.add(c),t.updateQueue=w}else v.add(c);break e}else{if(!(t&1)){ux(l,u,t),Ap();break e}c=Error(Q(426))}}else if(He&&a.mode&1){var b=dx(o);if(b!==null){!(b.flags&65536)&&(b.flags|=256),fx(b,o,a,l,t),ap(_i(c,a));break e}}l=c=_i(c,a),pt!==4&&(pt=2),_l===null?_l=[l]:_l.push(l),l=o;do{switch(l.tag){case 3:l.flags|=65536,t&=-t,l.lanes|=t;var j=Qy(l,c,t);rx(l,j);break e;case 1:a=c;var g=l.type,y=l.stateNode;if(!(l.flags&128)&&(typeof g.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Xs===null||!Xs.has(y)))){l.flags|=65536,t&=-t,l.lanes|=t;var m=Jy(l,a,t);rx(l,m);break e}}l=l.return}while(l!==null)}gw(n)}catch(k){t=k,ct===n&&n!==null&&(ct=n=n.return);continue}break}while(!0)}function pw(){var e=dc.current;return dc.current=uc,e===null?uc:e}function Ap(){(pt===0||pt===3||pt===2)&&(pt=4),jt===null||!($r&268435455)&&!(Hc&268435455)||Ws(jt,Et)}function pc(e,t){var n=Re;Re|=2;var r=pw();(jt!==e||Et!==t)&&(fs=null,Er(e,t));do try{OC();break}catch(i){hw(e,i)}while(!0);if(up(),Re=n,dc.current=r,ct!==null)throw Error(Q(261));return jt=null,Et=0,pt}function OC(){for(;ct!==null;)mw(ct)}function DC(){for(;ct!==null&&!aN();)mw(ct)}function mw(e){var t=vw(e.alternate,e,fn);e.memoizedProps=e.pendingProps,t===null?gw(e):ct=t,kp.current=null}function gw(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=TC(n,t),n!==null){n.flags&=32767,ct=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{pt=6,ct=null;return}}else if(n=RC(n,t,fn),n!==null){ct=n;return}if(t=t.sibling,t!==null){ct=t;return}ct=t=e}while(t!==null);pt===0&&(pt=5)}function kr(e,t,n){var r=$e,i=Cn.transition;try{Cn.transition=null,$e=1,LC(e,t,n,r)}finally{Cn.transition=i,$e=r}return null}function LC(e,t,n,r){do Ni();while(Hs!==null);if(Re&6)throw Error(Q(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Q(177));e.callbackNode=null,e.callbackPriority=0;var l=n.lanes|n.childLanes;if(vN(e,l),e===jt&&(ct=jt=null,Et=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Qo||(Qo=!0,jw(qa,function(){return Ni(),null})),l=(n.flags&15990)!==0,n.subtreeFlags&15990||l){l=Cn.transition,Cn.transition=null;var o=$e;$e=1;var a=Re;Re|=4,kp.current=null,IC(e,n),uw(n,e),rC(mf),Ja=!!pf,mf=pf=null,e.current=n,MC(n),cN(),Re=a,$e=o,Cn.transition=l}else e.current=n;if(Qo&&(Qo=!1,Hs=e,hc=i),l=e.pendingLanes,l===0&&(Xs=null),fN(n.stateNode),tn(e,nt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(fc)throw fc=!1,e=_f,_f=null,e;return hc&1&&e.tag!==0&&Ni(),l=e.pendingLanes,l&1?e===Of?Ol++:(Ol=0,Of=e):Ol=0,hr(),null}function Ni(){if(Hs!==null){var e=Qj(hc),t=Cn.transition,n=$e;try{if(Cn.transition=null,$e=16>e?16:e,Hs===null)var r=!1;else{if(e=Hs,Hs=null,hc=0,Re&6)throw Error(Q(331));var i=Re;for(Re|=4,ie=e.current;ie!==null;){var l=ie,o=l.child;if(ie.flags&16){var a=l.deletions;if(a!==null){for(var c=0;c<a.length;c++){var u=a[c];for(ie=u;ie!==null;){var p=ie;switch(p.tag){case 0:case 11:case 15:$l(8,p,l)}var d=p.child;if(d!==null)d.return=p,ie=d;else for(;ie!==null;){p=ie;var h=p.sibling,x=p.return;if(ow(p),p===u){ie=null;break}if(h!==null){h.return=x,ie=h;break}ie=x}}}var v=l.alternate;if(v!==null){var w=v.child;if(w!==null){v.child=null;do{var b=w.sibling;w.sibling=null,w=b}while(w!==null)}}ie=l}}if(l.subtreeFlags&2064&&o!==null)o.return=l,ie=o;else e:for(;ie!==null;){if(l=ie,l.flags&2048)switch(l.tag){case 0:case 11:case 15:$l(9,l,l.return)}var j=l.sibling;if(j!==null){j.return=l.return,ie=j;break e}ie=l.return}}var g=e.current;for(ie=g;ie!==null;){o=ie;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,ie=y;else e:for(o=g;ie!==null;){if(a=ie,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Vc(9,a)}}catch(k){Xe(a,a.return,k)}if(a===o){ie=null;break e}var m=a.sibling;if(m!==null){m.return=a.return,ie=m;break e}ie=a.return}}if(Re=i,hr(),Zn&&typeof Zn.onPostCommitFiberRoot=="function")try{Zn.onPostCommitFiberRoot(Oc,e)}catch{}r=!0}return r}finally{$e=n,Cn.transition=t}}return!1}function Nx(e,t,n){t=_i(n,t),t=Qy(e,t,1),e=Js(e,t,1),t=Wt(),e!==null&&(po(e,1,t),tn(e,t))}function Xe(e,t,n){if(e.tag===3)Nx(e,e,n);else for(;t!==null;){if(t.tag===3){Nx(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Xs===null||!Xs.has(r))){e=_i(n,e),e=Jy(t,e,1),t=Js(t,e,1),e=Wt(),t!==null&&(po(t,1,e),tn(t,e));break}}t=t.return}}function FC(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Wt(),e.pingedLanes|=e.suspendedLanes&n,jt===e&&(Et&n)===n&&(pt===4||pt===3&&(Et&130023424)===Et&&500>nt()-Np?Er(e,0):Sp|=n),tn(e,t)}function xw(e,t){t===0&&(e.mode&1?(t=Uo,Uo<<=1,!(Uo&130023424)&&(Uo=4194304)):t=1);var n=Wt();e=ks(e,t),e!==null&&(po(e,t,n),tn(e,n))}function UC(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),xw(e,n)}function BC(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Q(314))}r!==null&&r.delete(t),xw(e,n)}var vw;vw=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Zt.current)Jt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Jt=!1,AC(e,t,n);Jt=!!(e.flags&131072)}else Jt=!1,He&&t.flags&1048576&&by(t,rc,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ta(e,t),e=t.pendingProps;var i=Pi(t,Lt.current);Si(t,n),i=vp(null,t,r,e,i,n);var l=jp();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,en(r)?(l=!0,nc(t)):l=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,hp(t),i.updater=Wc,t.stateNode=i,i._reactInternals=t,Sf(t,r,e,n),t=Ef(null,t,r,!0,l,n)):(t.tag=0,He&&l&&lp(t),Ut(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ta(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=WC(r),e=Mn(r,e),i){case 0:t=Cf(null,t,r,e,n);break e;case 1:t=mx(null,t,r,e,n);break e;case 11:t=hx(null,t,r,e,n);break e;case 14:t=px(null,t,r,Mn(r.type,e),n);break e}throw Error(Q(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),Cf(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),mx(e,t,r,i,n);case 3:e:{if(tw(t),e===null)throw Error(Q(387));r=t.pendingProps,l=t.memoizedState,i=l.element,Ay(e,t),oc(t,r,null,n);var o=t.memoizedState;if(r=o.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=l,t.memoizedState=l,t.flags&256){i=_i(Error(Q(423)),t),t=gx(e,t,r,n,i);break e}else if(r!==i){i=_i(Error(Q(424)),t),t=gx(e,t,r,n,i);break e}else for(pn=Qs(t.stateNode.containerInfo.firstChild),gn=t,He=!0,_n=null,n=Cy(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ii(),r===i){t=Ss(e,t,n);break e}Ut(e,t,r,n)}t=t.child}return t;case 5:return Ry(t),e===null&&wf(t),r=t.type,i=t.pendingProps,l=e!==null?e.memoizedProps:null,o=i.children,gf(r,i)?o=null:l!==null&&gf(r,l)&&(t.flags|=32),ew(e,t),Ut(e,t,o,n),t.child;case 6:return e===null&&wf(t),null;case 13:return nw(e,t,n);case 4:return pp(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Mi(t,null,r,n):Ut(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),hx(e,t,r,i,n);case 7:return Ut(e,t,t.pendingProps,n),t.child;case 8:return Ut(e,t,t.pendingProps.children,n),t.child;case 12:return Ut(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,l=t.memoizedProps,o=i.value,Ue(ic,r._currentValue),r._currentValue=o,l!==null)if(Fn(l.value,o)){if(l.children===i.children&&!Zt.current){t=Ss(e,t,n);break e}}else for(l=t.child,l!==null&&(l.return=t);l!==null;){var a=l.dependencies;if(a!==null){o=l.child;for(var c=a.firstContext;c!==null;){if(c.context===r){if(l.tag===1){c=xs(-1,n&-n),c.tag=2;var u=l.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}l.lanes|=n,c=l.alternate,c!==null&&(c.lanes|=n),bf(l.return,n,t),a.lanes|=n;break}c=c.next}}else if(l.tag===10)o=l.type===t.type?null:l.child;else if(l.tag===18){if(o=l.return,o===null)throw Error(Q(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),bf(o,n,t),o=l.sibling}else o=l.child;if(o!==null)o.return=l;else for(o=l;o!==null;){if(o===t){o=null;break}if(l=o.sibling,l!==null){l.return=o.return,o=l;break}o=o.return}l=o}Ut(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Si(t,n),i=En(i),r=r(i),t.flags|=1,Ut(e,t,r,n),t.child;case 14:return r=t.type,i=Mn(r,t.pendingProps),i=Mn(r.type,i),px(e,t,r,i,n);case 15:return Xy(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),Ta(e,t),t.tag=1,en(r)?(e=!0,nc(t)):e=!1,Si(t,n),qy(t,r,i),Sf(t,r,i,n),Ef(null,t,r,!0,e,n);case 19:return sw(e,t,n);case 22:return Zy(e,t,n)}throw Error(Q(156,t.tag))};function jw(e,t){return Kj(e,t)}function zC(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nn(e,t,n,r){return new zC(e,t,n,r)}function Rp(e){return e=e.prototype,!(!e||!e.isReactComponent)}function WC(e){if(typeof e=="function")return Rp(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Yh)return 11;if(e===qh)return 14}return 2}function er(e,t){var n=e.alternate;return n===null?(n=Nn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ma(e,t,n,r,i,l){var o=2;if(r=e,typeof e=="function")Rp(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ai:return Ar(n.children,i,l,t);case Gh:o=8,i|=8;break;case Gd:return e=Nn(12,n,t,i|2),e.elementType=Gd,e.lanes=l,e;case Yd:return e=Nn(13,n,t,i),e.elementType=Yd,e.lanes=l,e;case qd:return e=Nn(19,n,t,i),e.elementType=qd,e.lanes=l,e;case Rj:return Kc(n,i,l,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ej:o=10;break e;case Aj:o=9;break e;case Yh:o=11;break e;case qh:o=14;break e;case Us:o=16,r=null;break e}throw Error(Q(130,e==null?e:typeof e,""))}return t=Nn(o,n,t,i),t.elementType=e,t.type=r,t.lanes=l,t}function Ar(e,t,n,r){return e=Nn(7,e,r,t),e.lanes=n,e}function Kc(e,t,n,r){return e=Nn(22,e,r,t),e.elementType=Rj,e.lanes=n,e.stateNode={isHidden:!1},e}function td(e,t,n){return e=Nn(6,e,null,t),e.lanes=n,e}function nd(e,t,n){return t=Nn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function VC(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ou(0),this.expirationTimes=Ou(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ou(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Tp(e,t,n,r,i,l,o,a,c){return e=new VC(e,t,n,a,c),t===1?(t=1,l===!0&&(t|=8)):t=0,l=Nn(3,null,null,t),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},hp(l),e}function HC(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:oi,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function yw(e){if(!e)return ir;e=e._reactInternals;e:{if(Wr(e)!==e||e.tag!==1)throw Error(Q(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(en(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Q(171))}if(e.tag===1){var n=e.type;if(en(n))return yy(e,n,t)}return t}function ww(e,t,n,r,i,l,o,a,c){return e=Tp(n,r,!0,e,i,l,o,a,c),e.context=yw(null),n=e.current,r=Wt(),i=Zs(n),l=xs(r,i),l.callback=t??null,Js(n,l,i),e.current.lanes=i,po(e,i,r),tn(e,r),e}function Gc(e,t,n,r){var i=t.current,l=Wt(),o=Zs(i);return n=yw(n),t.context===null?t.context=n:t.pendingContext=n,t=xs(l,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Js(i,t,o),e!==null&&(Ln(e,i,o,l),Ea(e,i,o)),o}function mc(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 Cx(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Pp(e,t){Cx(e,t),(e=e.alternate)&&Cx(e,t)}function KC(){return null}var bw=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ip(e){this._internalRoot=e}Yc.prototype.render=Ip.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Q(409));Gc(e,t,null,null)};Yc.prototype.unmount=Ip.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;_r(function(){Gc(null,e,null,null)}),t[bs]=null}};function Yc(e){this._internalRoot=e}Yc.prototype.unstable_scheduleHydration=function(e){if(e){var t=Zj();e={blockedOn:null,target:e,priority:t};for(var n=0;n<zs.length&&t!==0&&t<zs[n].priority;n++);zs.splice(n,0,e),n===0&&ty(e)}};function Mp(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function qc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Ex(){}function GC(e,t,n,r,i){if(i){if(typeof r=="function"){var l=r;r=function(){var u=mc(o);l.call(u)}}var o=ww(t,r,e,0,null,!1,!1,"",Ex);return e._reactRootContainer=o,e[bs]=o.current,Gl(e.nodeType===8?e.parentNode:e),_r(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var u=mc(c);a.call(u)}}var c=Tp(e,0,!1,null,null,!1,!1,"",Ex);return e._reactRootContainer=c,e[bs]=c.current,Gl(e.nodeType===8?e.parentNode:e),_r(function(){Gc(t,c,n,r)}),c}function Qc(e,t,n,r,i){var l=n._reactRootContainer;if(l){var o=l;if(typeof i=="function"){var a=i;i=function(){var c=mc(o);a.call(c)}}Gc(t,o,e,i)}else o=GC(n,t,e,i,r);return mc(o)}Jj=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Cl(t.pendingLanes);n!==0&&(Xh(t,n|1),tn(t,nt()),!(Re&6)&&(Oi=nt()+500,hr()))}break;case 13:_r(function(){var r=ks(e,1);if(r!==null){var i=Wt();Ln(r,e,1,i)}}),Pp(e,1)}};Zh=function(e){if(e.tag===13){var t=ks(e,134217728);if(t!==null){var n=Wt();Ln(t,e,134217728,n)}Pp(e,134217728)}};Xj=function(e){if(e.tag===13){var t=Zs(e),n=ks(e,t);if(n!==null){var r=Wt();Ln(n,e,t,r)}Pp(e,t)}};Zj=function(){return $e};ey=function(e,t){var n=$e;try{return $e=e,t()}finally{$e=n}};lf=function(e,t,n){switch(t){case"input":if(Xd(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=Uc(r);if(!i)throw Error(Q(90));Pj(r),Xd(r,i)}}}break;case"textarea":Mj(e,n);break;case"select":t=n.value,t!=null&&yi(e,!!n.multiple,t,!1)}};Uj=Cp;Bj=_r;var YC={usingClientEntryPoint:!1,Events:[go,fi,Uc,Lj,Fj,Cp]},vl={findFiberByHostInstance:Sr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},qC={bundleType:vl.bundleType,version:vl.version,rendererPackageName:vl.rendererPackageName,rendererConfig:vl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ts.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Vj(e),e===null?null:e.stateNode},findFiberByHostInstance:vl.findFiberByHostInstance||KC,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{Oc=Jo.inject(qC),Zn=Jo}catch{}}vn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=YC;vn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Mp(t))throw Error(Q(200));return HC(e,t,null,n)};vn.createRoot=function(e,t){if(!Mp(e))throw Error(Q(299));var n=!1,r="",i=bw;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Tp(e,1,!1,null,null,n,!1,r,i),e[bs]=t.current,Gl(e.nodeType===8?e.parentNode:e),new Ip(t)};vn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Q(188)):(e=Object.keys(e).join(","),Error(Q(268,e)));return e=Vj(t),e=e===null?null:e.stateNode,e};vn.flushSync=function(e){return _r(e)};vn.hydrate=function(e,t,n){if(!qc(t))throw Error(Q(200));return Qc(null,e,t,!0,n)};vn.hydrateRoot=function(e,t,n){if(!Mp(e))throw Error(Q(405));var r=n!=null&&n.hydratedSources||null,i=!1,l="",o=bw;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=ww(t,null,e,1,n??null,i,!1,l,o),e[bs]=t.current,Gl(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Yc(t)};vn.render=function(e,t,n){if(!qc(t))throw Error(Q(200));return Qc(null,e,t,!1,n)};vn.unmountComponentAtNode=function(e){if(!qc(e))throw Error(Q(40));return e._reactRootContainer?(_r(function(){Qc(null,null,e,!1,function(){e._reactRootContainer=null,e[bs]=null})}),!0):!1};vn.unstable_batchedUpdates=Cp;vn.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!qc(n))throw Error(Q(200));if(e==null||e._reactInternals===void 0)throw Error(Q(38));return Qc(e,t,n,!1,r)};vn.version="18.3.1-next-f1338f8080-20240426";function kw(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kw)}catch(e){console.error(e)}}kw(),kj.exports=vn;var Di=kj.exports,Sw,Ax=Di;Sw=Ax.createRoot,Ax.hydrateRoot;var QC=Object.defineProperty,Xi=(e,t)=>QC(e,"name",{value:t,configurable:!0}),Nw=!!(typeof window<"u"&&window.document&&window.document.createElement);function je(e,t,{checkForDefaultPrevented:n=!0}={}){return Xi(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}Xi(je,"composeEventHandlers");function JC(e){var t;if(!Nw)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Xi(JC,"getOwnerWindow");function Ff(e){if(!Nw)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Xi(Ff,"getOwnerDocument");function Cw(e,t=!1){const{activeElement:n}=Ff(e);if(!(n!=null&&n.nodeName))return null;if(Ew(n)&&n.contentDocument)return Cw(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=Ff(n).getElementById(r);if(i)return i}}return n}Xi(Cw,"getActiveElement");function Ew(e){return e.tagName==="IFRAME"}Xi(Ew,"isFrame");var XC=Object.defineProperty,$p=(e,t)=>XC(e,"name",{value:t,configurable:!0});function Uf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}$p(Uf,"setRef");function Aw(...e){return t=>{let n=!1;const r=e.map(i=>{const l=Uf(i,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let i=0;i<r.length;i++){const l=r[i];typeof l=="function"?l():Uf(e[i],null)}}}}$p(Aw,"composeRefs");function Ye(...e){return f.useCallback(Aw(...e),e)}$p(Ye,"useComposedRefs");var ZC=Object.defineProperty,Sn=(e,t)=>ZC(e,"name",{value:t,configurable:!0});function eE(e,t){const n=f.createContext(t);n.displayName=e+"Context";const r=Sn(l=>{const{children:o,...a}=l,c=f.useMemo(()=>a,Object.values(a));return s.jsx(n.Provider,{value:c,children:o})},"Provider");r.displayName=e+"Provider";function i(l,o={}){const{optional:a=!1}=o,c=f.useContext(n);if(c)return c;if(t!==void 0)return t;if(!a)throw new Error(`\`${l}\` must be used within \`${e}\``)}return Sn(i,"useContext"),[r,i]}Sn(eE,"createContext");function zn(e,t=[]){let n=[];function r(l,o){const a=f.createContext(o);a.displayName=l+"Context";const c=n.length;n=[...n,o];const u=Sn(d=>{var j;const{scope:h,children:x,...v}=d,w=((j=h==null?void 0:h[e])==null?void 0:j[c])||a,b=f.useMemo(()=>v,Object.values(v));return s.jsx(w.Provider,{value:b,children:x})},"Provider");u.displayName=l+"Provider";function p(d,h,x={}){var j;const{optional:v=!1}=x,w=((j=h==null?void 0:h[e])==null?void 0:j[c])||a,b=f.useContext(w);if(b)return b;if(o!==void 0)return o;if(!v)throw new Error(`\`${d}\` must be used within \`${l}\``)}return Sn(p,"useContext"),[u,p]}Sn(r,"createContext");const i=Sn(()=>{const l=n.map(o=>f.createContext(o));return Sn(function(a){const c=(a==null?void 0:a[e])||l;return f.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])},"useScope")},"createScope");return i.scopeName=e,[r,Rw(i,...t)]}Sn(zn,"createContextScope");function Rw(...e){const t=e[0];if(e.length===1)return t;const n=Sn(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Sn(function(l){const o=r.reduce((a,{useScope:c,scopeName:u})=>{const d=c(l)[`__scope${u}`];return{...a,...d}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Sn(Rw,"composeContextScopes");var tE=Object.defineProperty,Wn=(e,t)=>tE(e,"name",{value:t,configurable:!0});function lr(e){const t=f.forwardRef((n,r)=>{let{children:i,...l}=n,o=null,a=!1;const c=[];Bf(i)&&typeof Xo=="function"&&(i=Xo(i._payload)),f.Children.forEach(i,h=>{var x;if($w(h)){a=!0;const v=h;let w="child"in v.props?v.props.child:v.props.children;Bf(w)&&typeof Xo=="function"&&(w=Xo(w._payload)),o=nE(v,w),c.push((x=o==null?void 0:o.props)==null?void 0:x.children)}else c.push(h)}),o?o=f.cloneElement(o,void 0,c):!a&&f.Children.count(i)===1&&f.isValidElement(i)&&(o=i);const u=o?Mw(o):void 0,p=Ye(r,u);if(!o){if(i||i===0)throw new Error(a?iE(e):rE(e));return i}const d=Iw(l,o.props??{});return o.type!==f.Fragment&&(d.ref=r?p:u),f.cloneElement(o,d)});return t.displayName=`${e}.Slot`,t}Wn(lr,"createSlot");var Tw=Symbol.for("radix.slottable");function Pw(e){const t=Wn(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Tw,t}Wn(Pw,"createSlottable");var nE=Wn((e,t)=>{if("child"in e.props){const n=e.props.child;return f.isValidElement(n)?f.cloneElement(n,void 0,e.props.children(n.props.children)):null}return f.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Iw(e,t){const n={...t};for(const r in t){const i=e[r],l=t[r];/^on[A-Z]/.test(r)?i&&l?n[r]=(...a)=>{const c=l(...a);return i(...a),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...l}:r==="className"&&(n[r]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}Wn(Iw,"mergeProps");function Mw(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Wn(Mw,"getElementRef");function $w(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Tw}Wn($w,"isSlottable");var sE=Symbol.for("react.lazy");function Bf(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===sE&&"_payload"in e&&_w(e._payload)}Wn(Bf,"isLazyComponent");function _w(e){return typeof e=="object"&&e!==null&&"then"in e}Wn(_w,"isPromiseLike");var rE=Wn(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),iE=Wn(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Xo=qi[" use ".trim().toString()],lE=Object.defineProperty,xt=(e,t)=>lE(e,"name",{value:t,configurable:!0});function Jc(e){const t=e+"CollectionProvider",[n,r]=zn(t),[i,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=xt(w=>{const{scope:b,children:j}=w,g=f.useRef(null),y=f.useRef(new Map).current;return s.jsx(i,{scope:b,itemMap:y,collectionRef:g,children:j})},"CollectionProvider");o.displayName=t;const a=e+"CollectionSlot",c=lr(a),u=f.forwardRef((w,b)=>{const{scope:j,children:g}=w,y=l(a,j),m=Ye(b,y.collectionRef);return s.jsx(c,{ref:m,children:g})});u.displayName=a;const p=e+"CollectionItemSlot",d="data-radix-collection-item",h=lr(p),x=f.forwardRef((w,b)=>{const{scope:j,children:g,...y}=w,m=f.useRef(null),k=Ye(b,m),S=l(p,j);return f.useEffect(()=>(S.itemMap.set(m,{ref:m,...y}),()=>void S.itemMap.delete(m))),s.jsx(h,{[d]:"",ref:k,children:g})});x.displayName=p;function v(w){const b=l(e+"CollectionConsumer",w);return f.useCallback(()=>{const g=b.collectionRef.current;if(!g)return[];const y=Array.from(g.querySelectorAll(`[${d}]`));return Array.from(b.itemMap.values()).sort((S,N)=>y.indexOf(S.ref.current)-y.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return xt(v,"useCollection"),[{Provider:o,Slot:u,ItemSlot:x},v,r]}xt(Jc,"createCollection");var Rx=new WeakMap,at,hn,sd=(hn=class extends Map{constructor(n){super(n);jg(this,at);Tu(this,at,[...super.keys()]),Rx.set(this,!0)}set(n,r){return Rx.get(this)&&(this.has(n)?It(this,at)[It(this,at).indexOf(n)]=n:It(this,at).push(n)),super.set(n,r),this}insert(n,r,i){const l=this.has(r),o=It(this,at).length,a=_p(n);let c=a>=0?a:o+a;const u=c<0||c>=o?-1:c;if(u===this.size||l&&u===this.size-1||u===-1)return this.set(r,i),this;const p=this.size+(l?0:1);a<0&&c++;const d=[...It(this,at)];let h,x=!1;for(let v=c;v<p;v++)if(c===v){let w=d[v];d[v]===r&&(w=d[v+1]),l&&this.delete(r),h=this.get(w),this.set(r,i)}else{!x&&d[v-1]===r&&(x=!0);const w=d[x?v:v-1],b=h;h=this.get(w),this.delete(w),this.set(w,b)}return this}with(n,r,i){const l=new hn(this);return l.insert(n,r,i),l}before(n){const r=It(this,at).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,i){const l=It(this,at).indexOf(n);return l===-1?this:this.insert(l,r,i)}after(n){let r=It(this,at).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,i){const l=It(this,at).indexOf(n);return l===-1?this:this.insert(l+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Tu(this,at,[]),super.clear()}delete(n){const r=super.delete(n);return r&&It(this,at).splice(It(this,at).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=$a(It(this,at),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=$a(It(this,at),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return It(this,at).indexOf(n)}keyAt(n){return $a(It(this,at),n)}from(n,r){const i=this.indexOf(n);if(i===-1)return;let l=i+r;return l<0&&(l=0),l>=this.size&&(l=this.size-1),this.at(l)}keyFrom(n,r){const i=this.indexOf(n);if(i===-1)return;let l=i+r;return l<0&&(l=0),l>=this.size&&(l=this.size-1),this.keyAt(l)}find(n,r){let i=0;for(const l of this){if(Reflect.apply(n,r,[l,i,this]))return l;i++}}findIndex(n,r){let i=0;for(const l of this){if(Reflect.apply(n,r,[l,i,this]))return i;i++}return-1}filter(n,r){const i=[];let l=0;for(const o of this)Reflect.apply(n,r,[o,l,this])&&i.push(o),l++;return new hn(i)}map(n,r){const i=[];let l=0;for(const o of this)i.push([o[0],Reflect.apply(n,r,[o,l,this])]),l++;return new hn(i)}reduce(...n){const[r,i]=n;let l=0,o=i??this.at(0);for(const a of this)l===0&&n.length===1?o=a:o=Reflect.apply(r,this,[o,a,l,this]),l++;return o}reduceRight(...n){const[r,i]=n;let l=i??this.at(-1);for(let o=this.size-1;o>=0;o--){const a=this.at(o);o===this.size-1&&n.length===1?l=a:l=Reflect.apply(r,this,[l,a,o,this])}return l}toSorted(n){const r=[...this.entries()].sort(n);return new hn(r)}toReversed(){const n=new hn;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),l=this.get(i);n.set(i,l)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new hn(r)}slice(n,r){const i=new hn;let l=this.size-1;if(n===void 0)return i;n<0&&(n=n+this.size),r!==void 0&&r>0&&(l=r-1);for(let o=n;o<=l;o++){const a=this.keyAt(o),c=this.get(a);i.set(a,c)}return i}every(n,r){let i=0;for(const l of this){if(!Reflect.apply(n,r,[l,i,this]))return!1;i++}return!0}some(n,r){let i=0;for(const l of this){if(Reflect.apply(n,r,[l,i,this]))return!0;i++}return!1}},at=new WeakMap,xt(hn,"OrderedDict"),hn);function $a(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Ow(e,t);return n===-1?void 0:e[n]}xt($a,"at");function Ow(e,t){const n=e.length,r=_p(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}xt(Ow,"toSafeIndex");function _p(e){return e!==e||e===0?0:Math.trunc(e)}xt(_p,"toSafeInteger");function oE(e){const t=e+"CollectionProvider",[n,r]=zn(t),[i,l]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new sd,setItemMap:xt(()=>{},"setItemMap")}),o=xt(({state:y,...m})=>y?s.jsx(c,{...m,state:y}):s.jsx(a,{...m}),"CollectionProvider");o.displayName=t;const a=xt(y=>{const m=b();return s.jsx(c,{...y,state:m})},"CollectionInit");a.displayName=t+"Init";const c=xt(y=>{const{scope:m,children:k,state:S}=y,N=f.useRef(null),[C,T]=f.useState(null),E=Ye(N,T),[_,F]=S;return f.useEffect(()=>{if(!C)return;const O=Fw(()=>{});return O.observe(C,{childList:!0,subtree:!0}),()=>{O.disconnect()}},[C]),s.jsx(i,{scope:m,itemMap:_,setItemMap:F,collectionRef:E,collectionRefObject:N,collectionElement:C,children:k})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",p=lr(u),d=f.forwardRef((y,m)=>{const{scope:k,children:S}=y,N=l(u,k),C=Ye(m,N.collectionRef);return s.jsx(p,{ref:C,children:S})});d.displayName=u;const h=e+"CollectionItemSlot",x="data-radix-collection-item",v=lr(h),w=f.forwardRef((y,m)=>{const{scope:k,children:S,...N}=y,C=f.useRef(null),[T,E]=f.useState(null),_=Ye(m,C,E),F=l(h,k),{setItemMap:O}=F,A=f.useRef(N);Dw(A.current,N)||(A.current=N);const D=A.current;return f.useEffect(()=>{const q=D;return O(V=>T?V.has(T)?V.set(T,{...q,element:T}).toSorted(zf):(V.set(T,{...q,element:T}),V.toSorted(zf)):V),()=>{O(V=>!T||!V.has(T)?V:(V.delete(T),new sd(V)))}},[T,D,O]),s.jsx(v,{[x]:"",ref:_,children:S})});w.displayName=h;function b(){return f.useState(new sd)}xt(b,"useInitCollection");function j(y){const{itemMap:m}=l(e+"CollectionConsumer",y);return m}return xt(j,"useCollection"),[{Provider:o,Slot:d,ItemSlot:w},{createCollectionScope:r,useCollection:j,useInitCollection:b}]}xt(oE,"createCollection");function Dw(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}xt(Dw,"shallowEqual");function Lw(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}xt(Lw,"isElementPreceding");function zf(e,t){return!e[1].element||!t[1].element?0:Lw(e[1].element,t[1].element)?-1:1}xt(zf,"sortByDocumentPosition");function Fw(e){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){e();return}})}xt(Fw,"getChildListObserver");var aE=Object.defineProperty,cE=(e,t)=>aE(e,"name",{value:t,configurable:!0}),uE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Qe=uE.reduce((e,t)=>{const n=lr(`Primitive.${t}`),r=f.forwardRef((i,l)=>{const{asChild:o,...a}=i,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...a,ref:l})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Xc(e,t){e&&Di.flushSync(()=>e.dispatchEvent(t))}cE(Xc,"dispatchDiscreteCustomEvent");var dE=Object.defineProperty,fE=(e,t)=>dE(e,"name",{value:t,configurable:!0});function Un(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}fE(Un,"useCallbackRef");var hE=Object.defineProperty,ft=(e,t)=>hE(e,"name",{value:t,configurable:!0}),Wf="dismissableLayer.update",pE="dismissableLayer.pointerDownOutside",mE="dismissableLayer.focusOutside",Tx,Op=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Dp=f.forwardRef(ft(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:c,onDismiss:u,...p}=t,d=f.useContext(Op),[h,x]=f.useState(null),v=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=f.useState({}),b=Ye(n,x),j=Array.from(d.layers),[g]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=g?j.indexOf(g):-1,m=h?j.indexOf(h):-1,k=d.layersWithOutsidePointerEventsDisabled.size>0,S=m>=y,N=f.useRef(!1),C=Bw(F=>{o==null||o(F),c==null||c(F),F.defaultPrevented||u==null||u()},{ownerDocument:v,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:N,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:f.useCallback(F=>{if(!(F instanceof Node))return!1;const O=[...d.branches].some(A=>A.contains(F));return S&&!O},[d.branches,S])}),T=zw(F=>{if(i&&N.current)return;const O=F.target;[...d.branches].some(D=>D.contains(O))||(a==null||a(F),c==null||c(F),F.defaultPrevented||u==null||u())},v),E=h?m===j.length-1:!1,_=Un(F=>{F.key==="Escape"&&(l==null||l(F),!F.defaultPrevented&&u&&(F.preventDefault(),u()))});return f.useEffect(()=>{if(E)return v.addEventListener("keydown",_,{capture:!0}),()=>v.removeEventListener("keydown",_,{capture:!0})},[v,E,_]),f.useEffect(()=>{if(h)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Tx=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),Vf(),()=>{r&&(d.layersWithOutsidePointerEventsDisabled.delete(h),d.layersWithOutsidePointerEventsDisabled.size===0&&(v.body.style.pointerEvents=Tx))}},[h,v,r,d]),f.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),Vf())},[h,d]),f.useEffect(()=>{const F=ft(()=>w({}),"handleUpdate");return document.addEventListener(Wf,F),()=>document.removeEventListener(Wf,F)},[]),s.jsx(Qe.div,{...p,ref:b,style:{pointerEvents:k?S?"auto":"none":void 0,...t.style},onFocusCapture:je(t.onFocusCapture,T.onFocusCapture),onBlurCapture:je(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:je(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),gE=f.forwardRef(ft(function(t,n){const r=f.useContext(Op),i=f.useRef(null),l=Ye(n,i);return f.useEffect(()=>{const o=i.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),s.jsx(Qe.div,{...t,ref:l})},"DismissableLayerBranch"));function Uw(){const e=f.useContext(Op),[t,n]=f.useState(null);return f.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}ft(Uw,"useDismissableLayerSurface");var xE=ft(()=>!0,"IS_TRUE");function Bw(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:l,shouldHandlePointerDownOutside:o=xE}=t,a=Un(e),c=f.useRef(!1),u=f.useRef(!1),p=f.useRef(new Map),d=f.useRef(()=>{});return f.useEffect(()=>{function h(){u.current=!1,i.current=!1,p.current.clear()}ft(h,"resetOutsideInteraction");function x(){return Array.from(p.current.values()).some(Boolean)}ft(x,"isOutsideInteractionIntercepted");function v(y){if(!u.current)return;const m=y.target;m instanceof Node&&[...l].some(S=>S.contains(m))||p.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{u.current&&d.current()},0)}ft(v,"handleInteractionCapture");function w(y){u.current&&p.current.set(y.type,!1)}ft(w,"handleInteractionBubble");const b=ft(y=>{if(y.target&&!c.current){let m=function(){n.removeEventListener("click",d.current);const S=x();h(),S||Lp(pE,a,k,{discrete:!0})};if(ft(m,"handleAndDispatchPointerDownOutsideEvent"),!o(y.target)){n.removeEventListener("click",d.current),h(),c.current=!1;return}const k={originalEvent:y};u.current=!0,i.current=r&&y.button===0,p.current.clear(),!r||y.button!==0?m():(n.removeEventListener("click",d.current),d.current=m,n.addEventListener("click",d.current,{once:!0}))}else n.removeEventListener("click",d.current),h();c.current=!1},"handlePointerDown"),j=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of j)n.addEventListener(y,v,!0),n.addEventListener(y,w);const g=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(g),n.removeEventListener("pointerdown",b),n.removeEventListener("click",d.current);for(const y of j)n.removeEventListener(y,v,!0),n.removeEventListener(y,w)}},[n,a,r,i,l,o]),{onPointerDownCapture:ft(()=>c.current=!0,"onPointerDownCapture")}}ft(Bw,"usePointerDownOutside");function zw(e,t=globalThis==null?void 0:globalThis.document){const n=Un(e),r=f.useRef(!1);return f.useEffect(()=>{const i=ft(l=>{l.target&&!r.current&&Lp(mE,n,{originalEvent:l},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:ft(()=>r.current=!0,"onFocusCapture"),onBlurCapture:ft(()=>r.current=!1,"onBlurCapture")}}ft(zw,"useFocusOutside");function Vf(){const e=new CustomEvent(Wf);document.dispatchEvent(e)}ft(Vf,"dispatchUpdate");function Lp(e,t,n,{discrete:r}){const i=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Xc(i,l):i.dispatchEvent(l)}ft(Lp,"handleAndDispatchCustomEvent");var vE=gE,nn=globalThis!=null&&globalThis.document?f.useLayoutEffect:()=>{},jE=Object.defineProperty,yE=(e,t)=>jE(e,"name",{value:t,configurable:!0}),Fp=f.forwardRef(yE(function(t,n){var c;const{container:r,...i}=t,[l,o]=f.useState(!1);nn(()=>o(!0),[]);const a=r||l&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?Di.createPortal(s.jsx(Qe.div,{...i,ref:n}),a):null},"Portal")),wE=Object.defineProperty,Ns=(e,t)=>wE(e,"name",{value:t,configurable:!0});function Ww(e,t){return f.useReducer((n,r)=>t[n][r]??n,e)}Ns(Ww,"useStateMachine");var pr=Ns(e=>{const{present:t,children:n}=e,r=Vw(t),i=typeof n=="function"?n({present:r.isPresent}):f.Children.only(n),l=Hw(r.ref,Kw(i));return typeof n=="function"||r.isPresent?f.cloneElement(i,{ref:l}):null},"Presence");function Vw(e){const[t,n]=f.useState(),r=f.useRef(null),i=f.useRef(e),l=f.useRef("none"),o=f.useRef(void 0),a=e?"mounted":"unmounted",[c,u]=Ww(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return f.useEffect(()=>{c==="mounted"?(l.current=o.current??li(r.current),o.current=void 0):l.current="none"},[c]),nn(()=>{const p=r.current,d=i.current;if(d!==e){const x=l.current,v=li(p);e?(o.current=v,u("MOUNT")):v==="none"||(p==null?void 0:p.display)==="none"?u("UNMOUNT"):u(d&&x!==v?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),nn(()=>{if(t){let p;const d=t.ownerDocument.defaultView??window,h=Ns(v=>{const b=li(r.current).includes(CSS.escape(v.animationName));if(v.target===t&&b&&(u("ANIMATION_END"),!i.current)){const j=t.style.animationFillMode;t.style.animationFillMode="forwards",p=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=j)})}},"handleAnimationEnd"),x=Ns(v=>{v.target===t&&(l.current=li(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(p),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:f.useCallback(p=>{if(p){const d=getComputedStyle(p);r.current=d,o.current=li(d)}else r.current=null;n(p)},[])}}Ns(Vw,"usePresence");function Hf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Ns(Hf,"setRef");function Hw(...e){const t=f.useRef(e);return t.current=e,f.useCallback(n=>{const r=t.current;let i=!1;const l=r.map(o=>{const a=Hf(o,n);return!i&&typeof a=="function"&&(i=!0),a});if(i)return()=>{for(let o=0;o<l.length;o++){const a=l[o];typeof a=="function"?a():Hf(r[o],null)}}},[])}Ns(Hw,"useStableComposedRefs");function li(e){return(e==null?void 0:e.animationName)||"none"}Ns(li,"getAnimationName");function Kw(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Ns(Kw,"getElementRef");var bE=Object.defineProperty,kE=(e,t)=>bE(e,"name",{value:t,configurable:!0}),Px=qi[" useEffectEvent ".trim().toString()],Ix=qi[" useInsertionEffect ".trim().toString()];function Gw(e){if(typeof Px=="function")return Px(e);const t=f.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Ix=="function"?Ix(()=>{t.current=e}):nn(()=>{t.current=e}),f.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}kE(Gw,"useEffectEvent");var SE=Object.defineProperty,vo=(e,t)=>SE(e,"name",{value:t,configurable:!0}),NE=qi[" useInsertionEffect ".trim().toString()]||nn;function Zi({prop:e,defaultProp:t,onChange:n=vo(()=>{},"onChange"),caller:r}){const[i,l,o]=Yw({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:i,u=f.useCallback(p=>{var d;if(a){const h=qw(p)?p(e):p;h!==e&&((d=o.current)==null||d.call(o,h))}else l(p)},[a,e,l,o]);return[c,u]}vo(Zi,"useControllableState");function Yw({defaultProp:e,onChange:t}){const[n,r]=f.useState(e),i=f.useRef(n),l=f.useRef(t);return NE(()=>{l.current=t},[t]),f.useEffect(()=>{var o;i.current!==n&&((o=l.current)==null||o.call(l,n),i.current=n)},[n,i]),[n,r,l]}vo(Yw,"useUncontrolledState");function qw(e){return typeof e=="function"}vo(qw,"isFunction");var Mx=Symbol("RADIX:SYNC_STATE");function CE(e,t,n,r){const{prop:i,defaultProp:l,onChange:o,caller:a}=t,c=i!==void 0,u=Gw(o),p=[{...n,state:l}];r&&p.push(r);const[d,h]=f.useReducer((b,j)=>{if(j.type===Mx)return{...b,state:j.state};const g=e(b,j);return c&&!Object.is(g.state,b.state)&&u(g.state),g},...p),x=d.state,v=f.useRef(x);f.useEffect(()=>{v.current!==x&&(v.current=x,c||u(x))},[x,v,c]);const w=f.useMemo(()=>i!==void 0?{...d,state:i}:d,[d,i]);return f.useEffect(()=>{c&&!Object.is(i,d.state)&&h({type:Mx,state:i})},[i,d.state,c]),[w,h]}vo(CE,"useControllableStateReducer");var EE=Object.defineProperty,AE=(e,t)=>EE(e,"name",{value:t,configurable:!0}),RE=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"}),Qw=f.forwardRef(AE(function(t,n){return s.jsx(Qe.span,{...t,ref:n,style:{...RE,...t.style}})},"VisuallyHidden")),TE=Qw,PE=Object.defineProperty,_t=(e,t)=>PE(e,"name",{value:t,configurable:!0}),Jw="ToastProvider",[Xw,IE,ME]=Jc("Toast"),[Zw,U3]=zn("Toast",[ME]),[$E,eb]=Zw(Jw),_E=_t(e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:l=50,announcerContainer:o,children:a}=e,[c,u]=f.useState(null),[p,d]=f.useState(0),h=f.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Jw}\`. Expected non-empty \`string\`.`),s.jsx(Xw.Provider,{scope:t,children:s.jsx($E,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:l,toastCount:p,viewport:c,onViewportChange:u,onToastAdd:f.useCallback(()=>d(x=>x+1),[]),onToastRemove:f.useCallback(()=>d(x=>x-1),[]),isClosePausedRef:h,announcerContainer:o,children:a})})},"ToastProvider"),OE="ToastViewport",DE=["F8"],LE="toast.viewportPause",FE="toast.viewportResume",UE=f.forwardRef(_t(function(t,n){const{__scopeToast:r,hotkey:i=DE,label:l="Notifications ({hotkey})",...o}=t,a=eb(OE,r),c=IE(r),u=f.useRef(null),p=f.useRef(null),d=f.useRef(null),h=f.useRef(null),x=Ye(n,h,a.onViewportChange),v=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=a.toastCount>0;f.useEffect(()=>{const j=_t(g=>{var m;i.length!==0&&i.every(k=>g[k]||g.code===k)&&((m=h.current)==null||m.focus())},"handleKeyDown");return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[i]),f.useEffect(()=>{const j=u.current,g=h.current;if(w&&j&&g){const y=_t(()=>{if(!a.isClosePausedRef.current){const N=new CustomEvent(LE);g.dispatchEvent(N),a.isClosePausedRef.current=!0}},"handlePause"),m=_t(()=>{if(a.isClosePausedRef.current){const N=new CustomEvent(FE);g.dispatchEvent(N),a.isClosePausedRef.current=!1}},"handleResume"),k=_t(N=>{!j.contains(N.relatedTarget)&&m()},"handleFocusOutResume"),S=_t(()=>{j.contains(document.activeElement)||m()},"handlePointerLeaveResume");return j.addEventListener("focusin",y),j.addEventListener("focusout",k),j.addEventListener("pointermove",y),j.addEventListener("pointerleave",S),window.addEventListener("blur",y),window.addEventListener("focus",m),()=>{j.removeEventListener("focusin",y),j.removeEventListener("focusout",k),j.removeEventListener("pointermove",y),j.removeEventListener("pointerleave",S),window.removeEventListener("blur",y),window.removeEventListener("focus",m)}}},[w,a.isClosePausedRef]);const b=f.useCallback(({tabbingDirection:j})=>{const y=c().map(m=>{const k=m.ref.current,S=[k,...sb(k)];return j==="forwards"?S:S.reverse()});return(j==="forwards"?y.reverse():y).flat()},[c]);return f.useEffect(()=>{const j=h.current;if(j){const g=_t(y=>{var S,N,C;const m=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!m){const T=document.activeElement,E=y.shiftKey;if(y.target===j&&E){(S=p.current)==null||S.focus();return}const O=b({tabbingDirection:E?"backwards":"forwards"}),A=O.findIndex(D=>D===T);_a(O.slice(A+1))?y.preventDefault():E?(N=p.current)==null||N.focus():(C=d.current)==null||C.focus()}},"handleKeyDown");return j.addEventListener("keydown",g),()=>j.removeEventListener("keydown",g)}},[c,b]),s.jsxs(vE,{ref:u,role:"region","aria-label":l.replace("{hotkey}",v),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&s.jsx($x,{ref:p,onFocusFromOutsideViewport:()=>{const j=b({tabbingDirection:"forwards"});_a(j)}}),s.jsx(Xw.Slot,{scope:r,children:s.jsx(Qe.ol,{tabIndex:-1,...o,ref:x})}),w&&s.jsx($x,{ref:d,onFocusFromOutsideViewport:()=>{const j=b({tabbingDirection:"backwards"});_a(j)}})]})},"ToastViewport")),BE="ToastFocusProxy",$x=f.forwardRef(_t(function(t,n){const{__scopeToast:r,onFocusFromOutsideViewport:i,...l}=t,o=eb(BE,r);return s.jsx(Qw,{tabIndex:0,...l,ref:n,style:{position:"fixed"},onFocus:a=>{var p;const c=a.relatedTarget;!((p=o.viewport)!=null&&p.contains(c))&&i()}})},"ToastFocusProxy")),zE="Toast",[B3,z3]=Zw(zE,{onClose(){}});function tb(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),nb(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",l=r.dataset.radixToastAnnounceExclude==="";if(!i)if(l){const o=r.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...tb(r))}}),t}_t(tb,"getAnnounceTextContent");function WE(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,l=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Xc(i,l):i.dispatchEvent(l)}_t(WE,"handleAndDispatchCustomEvent");function VE(e=()=>{}){const t=Un(e);nn(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}_t(VE,"useNextFrame");function nb(e){return e.nodeType===e.ELEMENT_NODE}_t(nb,"isHTMLElement");function sb(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:_t(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}_t(sb,"getTabbableCandidates");function _a(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}_t(_a,"focusFirst");var _x=_E,Ox=UE,HE=Object.defineProperty,KE=(e,t)=>HE(e,"name",{value:t,configurable:!0}),GE=qi[" useId ".trim().toString()]||(()=>{}),YE=0;function vs(e){const[t,n]=f.useState(GE());return nn(()=>{e||n(r=>r??String(YE++))},[e]),e||(t?`radix-${t}`:"")}KE(vs,"useId");const qE=["top","right","bottom","left"],or=Math.min,js=Math.max,gc=Math.round,Zo=Math.floor,ys=e=>({x:e,y:e}),QE={left:"right",right:"left",bottom:"top",top:"bottom"};function rb(e,t,n){return js(e,or(t,n))}function Cs(e,t){return typeof e=="function"?e(t):e}function ar(e){return e.split("-")[0]}function el(e){return e.split("-")[1]}function Up(e){return e==="x"?"y":"x"}function Bp(e){return e==="y"?"height":"width"}function Jn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function zp(e){return Up(Jn(e))}function JE(e,t,n){n===void 0&&(n=!1);const r=el(e),i=zp(e),l=Bp(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(o=xc(o)),[o,xc(o)]}function XE(e){const t=xc(e);return[Kf(e),t,Kf(t)]}function Kf(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Dx=["left","right"],Lx=["right","left"],ZE=["top","bottom"],eA=["bottom","top"];function tA(e,t,n){switch(e){case"top":case"bottom":return n?t?Lx:Dx:t?Dx:Lx;case"left":case"right":return t?ZE:eA;default:return[]}}function nA(e,t,n,r){const i=el(e);let l=tA(ar(e),n==="start",r);return i&&(l=l.map(o=>o+"-"+i),t&&(l=l.concat(l.map(Kf)))),l}function xc(e){const t=ar(e);return QE[t]+e.slice(t.length)}function sA(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function ib(e){return typeof e!="number"?sA(e):{top:e,right:e,bottom:e,left:e}}function vc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Fx(e,t,n){let{reference:r,floating:i}=e;const l=Jn(t),o=zp(t),a=Bp(o),c=ar(t),u=l==="y",p=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2;let x;switch(c){case"top":x={x:p,y:r.y-i.height};break;case"bottom":x={x:p,y:r.y+r.height};break;case"right":x={x:r.x+r.width,y:d};break;case"left":x={x:r.x-i.width,y:d};break;default:x={x:r.x,y:r.y}}const v=el(t);return v&&(x[o]+=h*(v==="end"?1:-1)*(n&&u?-1:1)),x}async function rA(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:l,rects:o,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:d="floating",altBoundary:h=!1,padding:x=0}=Cs(t,e),v=ib(x),b=a[h?d==="floating"?"reference":"floating":d],j=vc(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(b)))==null||n?b:b.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(a.floating)),boundary:u,rootBoundary:p,strategy:c})),g=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(l.getOffsetParent==null?void 0:l.getOffsetParent(a.floating)),m=await(l.isElement==null?void 0:l.isElement(y))&&await(l.getScale==null?void 0:l.getScale(y))||{x:1,y:1},k=vc(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:g,offsetParent:y,strategy:c}):g);return{top:(j.top-k.top+v.top)/m.y,bottom:(k.bottom-j.bottom+v.bottom)/m.y,left:(j.left-k.left+v.left)/m.x,right:(k.right-j.right+v.right)/m.x}}const iA=50,lA=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:l=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:rA},c=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:d}=Fx(u,r,c),h=r,x=0;const v={};for(let w=0;w<l.length;w++){const b=l[w];if(!b)continue;const{name:j,fn:g}=b,{x:y,y:m,data:k,reset:S}=await g({x:p,y:d,initialPlacement:r,placement:h,strategy:i,middlewareData:v,rects:u,platform:a,elements:{reference:e,floating:t}});p=y??p,d=m??d,v[j]={...v[j],...k},S&&x<iA&&(x++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):S.rects),{x:p,y:d}=Fx(u,h,c)),w=-1)}return{x:p,y:d,placement:h,strategy:i,middlewareData:v}},oA=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:l,platform:o,elements:a,middlewareData:c}=t,{element:u,padding:p=0}=Cs(e,t)||{};if(u==null)return{};const d=ib(p),h={x:n,y:r},x=zp(i),v=Bp(x),w=await o.getDimensions(u),b=x==="y",j=b?"top":"left",g=b?"bottom":"right",y=b?"clientHeight":"clientWidth",m=l.reference[v]+l.reference[x]-h[x]-l.floating[v],k=h[x]-l.reference[x],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let N=S?S[y]:0;(!N||!await(o.isElement==null?void 0:o.isElement(S)))&&(N=a.floating[y]||l.floating[v]);const C=m/2-k/2,T=N/2-w[v]/2-1,E=or(d[j],T),_=or(d[g],T),F=N-w[v]-_,O=N/2-w[v]/2+C,A=rb(E,O,F),D=!c.arrow&&el(i)!=null&&O!==A&&l.reference[v]/2-(O<E?E:_)-w[v]/2<0,q=D?O<E?O-E:O-F:0;return{[x]:h[x]+q,data:{[x]:A,centerOffset:O-A-q,...D&&{alignmentOffset:q}},reset:D}}}),aA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:l,rects:o,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:p=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...b}=Cs(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const j=ar(i),g=Jn(a),y=ar(a)===a,m=await(c.isRTL==null?void 0:c.isRTL(u.floating)),k=h||(y||!w?[xc(a)]:XE(a)),S=v!=="none";!h&&S&&k.push(...nA(a,w,v,m));const N=[a,...k],C=await c.detectOverflow(t,b),T=[];let E=((r=l.flip)==null?void 0:r.overflows)||[];if(p&&T.push(C[j]),d){const A=JE(i,o,m);T.push(C[A[0]],C[A[1]])}if(E=[...E,{placement:i,overflows:T}],!T.every(A=>A<=0)){var _,F;const A=(((_=l.flip)==null?void 0:_.index)||0)+1,D=N[A];if(D&&(!(d==="alignment"?g!==Jn(D):!1)||E.every(M=>Jn(M.placement)===g?M.overflows[0]>0:!0)))return{data:{index:A,overflows:E},reset:{placement:D}};let q=(F=E.filter(V=>V.overflows[0]<=0).sort((V,M)=>V.overflows[1]-M.overflows[1])[0])==null?void 0:F.placement;if(!q)switch(x){case"bestFit":{var O;const V=(O=E.filter(M=>{if(S){const z=Jn(M.placement);return z===g||z==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(z=>z>0).reduce((z,$)=>z+$,0)]).sort((M,z)=>M[1]-z[1])[0])==null?void 0:O[0];V&&(q=V);break}case"initialPlacement":q=a;break}if(i!==q)return{reset:{placement:q}}}return{}}}};function Ux(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Bx(e){return qE.some(t=>e[t]>=0)}const cA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...l}=Cs(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...l,elementContext:"reference"}),a=Ux(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Bx(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...l,altBoundary:!0}),a=Ux(o,n.floating);return{data:{escapedOffsets:a,escaped:Bx(a)}}}default:return{}}}}},lb=new Set(["left","top"]);async function uA(e,t){const{placement:n,platform:r,elements:i}=e,l=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ar(n),a=el(n),c=Jn(n)==="y",u=lb.has(o)?-1:1,p=l&&c?-1:1,d=Cs(t,e);let{mainAxis:h,crossAxis:x,alignmentAxis:v}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof v=="number"&&(x=a==="end"?v*-1:v),c?{x:x*p,y:h*u}:{x:h*u,y:x*p}}const dA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:l,placement:o,middlewareData:a}=t,c=await uA(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:l+c.y,data:{...c,placement:o}}}}},fA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:l}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:c={fn:g=>{let{x:y,y:m}=g;return{x:y,y:m}}},...u}=Cs(e,t),p={x:n,y:r},d=await l.detectOverflow(t,u),h=Jn(i),x=Up(h);let v=p[x],w=p[h];const b=(g,y)=>rb(y+d[g==="y"?"top":"left"],y,y-d[g==="y"?"bottom":"right"]);o&&(v=b(x,v)),a&&(w=b(h,w));const j=c.fn({...t,[x]:v,[h]:w});return{...j,data:{x:j.x-n,y:j.y-r,enabled:{[x]:o,[h]:a}}}}}},hA=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:l,placement:o,rects:a,middlewareData:c}=t,{offset:u=0,mainAxis:p=!0,crossAxis:d=!0}=Cs(e,t),h={x:i,y:l},x=Jn(o),v=Up(x);let w=h[v],b=h[x];const j=Cs(u,t),g=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:(n=j.mainAxis)!=null?n:0,crossAxis:(r=j.crossAxis)!=null?r:0};if(p){const k=v==="y"?"height":"width",S=a.reference[v]-a.floating[k]+g.mainAxis,N=a.reference[v]+a.reference[k]-g.mainAxis;w<S?w=S:w>N&&(w=N)}if(d){var y,m;const k=v==="y"?"width":"height",S=lb.has(ar(o)),N=a.reference[x]-a.floating[k]+(S&&((y=c.offset)==null?void 0:y[x])||0)+(S?0:g.crossAxis),C=a.reference[x]+a.reference[k]+(S?0:((m=c.offset)==null?void 0:m[x])||0)-(S?g.crossAxis:0);b<N?b=N:b>C&&(b=C)}return{[v]:w,[x]:b}}}},pA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:l}=t,{apply:o=()=>{},...a}=Cs(e,t),c=await i.detectOverflow(t,a),u=ar(n),p=el(n),d=Jn(n)==="y",{width:h,height:x}=r.floating;let v,w;u==="top"||u==="bottom"?(v=u,w=p===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(w=u,v=p==="end"?"top":"bottom");const b=x-c.top-c.bottom,j=h-c.left-c.right,g=or(x-c[v],b),y=or(h-c[w],j),m=t.middlewareData.shift,k=!m;let S=g,N=y;m!=null&&m.enabled.x&&(N=j),m!=null&&m.enabled.y&&(S=b),k&&!p&&(d?N=h-2*js(c.left,c.right):S=x-2*js(c.top,c.bottom)),await o({...t,availableWidth:N,availableHeight:S});const C=await i.getDimensions(l.floating);return h!==C.width||x!==C.height?{reset:{rects:!0}}:{}}}};function Zc(){return typeof window<"u"}function tl(e){return ob(e)?(e.nodeName||"").toLowerCase():"#document"}function sn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ps(e){var t;return(t=(ob(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ob(e){return Zc()?e instanceof Node||e instanceof sn(e).Node:!1}function ss(e){return Zc()?e instanceof Element||e instanceof sn(e).Element:!1}function mr(e){return Zc()?e instanceof HTMLElement||e instanceof sn(e).HTMLElement:!1}function zx(e){return!Zc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof sn(e).ShadowRoot}function eu(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=rs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function mA(e){return/^(table|td|th)$/.test(tl(e))}function tu(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const gA=/transform|translate|scale|rotate|perspective|filter/,xA=/paint|layout|strict|content/,wr=e=>!!e&&e!=="none";let rd;function Wp(e){const t=ss(e)?rs(e):e;return wr(t.transform)||wr(t.translate)||wr(t.scale)||wr(t.rotate)||wr(t.perspective)||!Vp()&&(wr(t.backdropFilter)||wr(t.filter))||gA.test(t.willChange||"")||xA.test(t.contain||"")}function vA(e){let t=Or(e);for(;mr(t)&&!no(t);){if(Wp(t))return t;if(tu(t))return null;t=Or(t)}return null}function Vp(){return rd==null&&(rd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),rd}function no(e){return/^(html|body|#document)$/.test(tl(e))}function rs(e){return sn(e).getComputedStyle(e)}function nu(e){return ss(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Or(e){if(tl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||zx(e)&&e.host||Ps(e);return zx(t)?t.host:t}function ab(e){const t=Or(e);return no(t)?(e.ownerDocument||e).body:mr(t)&&eu(t)?t:ab(t)}function so(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=ab(e),l=i===((r=e.ownerDocument)==null?void 0:r.body),o=sn(i);if(l){const a=Gf(o);return t.concat(o,o.visualViewport||[],eu(i)?i:[],a&&n?so(a):[])}else return t.concat(i,so(i,[],n))}function Gf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function cb(e){const t=rs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=mr(e),l=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=gc(n)!==l||gc(r)!==o;return a&&(n=l,r=o),{width:n,height:r,$:a}}function Hp(e){return ss(e)?e:e.contextElement}function Ci(e){const t=Hp(e);if(!mr(t))return ys(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:l}=cb(t);let o=(l?gc(n.width):n.width)/r,a=(l?gc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const jA=ys(0);function ub(e){const t=sn(e);return!Vp()||!t.visualViewport?jA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function yA(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===sn(e)}function Dr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),l=Hp(e);let o=ys(1);t&&(r?ss(r)&&(o=Ci(r)):o=Ci(e));const a=yA(l,n,r)?ub(l):ys(0);let c=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,p=i.width/o.x,d=i.height/o.y;if(l&&r){const h=sn(l),x=ss(r)?sn(r):r;let v=h,w=Gf(v);for(;w&&x!==v;){const b=Ci(w),j=w.getBoundingClientRect(),g=rs(w),y=j.left+(w.clientLeft+parseFloat(g.paddingLeft))*b.x,m=j.top+(w.clientTop+parseFloat(g.paddingTop))*b.y;c*=b.x,u*=b.y,p*=b.x,d*=b.y,c+=y,u+=m,v=sn(w),w=Gf(v)}}return vc({width:p,height:d,x:c,y:u})}function su(e,t){const n=nu(e).scrollLeft;return t?t.left+n:Dr(Ps(e)).left+n}function db(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-su(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function wA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const l=i==="fixed",o=Ps(r),a=t?tu(t.floating):!1;if(r===o||a&&l)return n;let c={scrollLeft:0,scrollTop:0},u=ys(1);const p=ys(0),d=mr(r);if((d||!l)&&((tl(r)!=="body"||eu(o))&&(c=nu(r)),d)){const x=Dr(r);u=Ci(r),p.x=x.x+r.clientLeft,p.y=x.y+r.clientTop}const h=o&&!d&&!l?db(o,c):ys(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+h.x,y:n.y*u.y-c.scrollTop*u.y+p.y+h.y}}function bA(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function kA(e){const t=nu(e),n=e.ownerDocument.body,r=js(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=js(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let l=-t.scrollLeft+su(e);const o=-t.scrollTop;return rs(n).direction==="rtl"&&(l+=js(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:l,y:o}}const SA=25;function NA(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=sn(e),l=Ps(e),o=i.visualViewport;let a=l.clientWidth,c=l.clientHeight,u=0,p=0;if(o){const h=!Vp()||t==="fixed";r?h||(u=-o.offsetLeft,p=-o.offsetTop):(a=o.width,c=o.height,h&&(u=o.offsetLeft,p=o.offsetTop))}if(su(l)<=0){const h=l.ownerDocument,x=h.body,v=getComputedStyle(x),w=h.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,b=Math.abs(l.clientWidth-x.clientWidth-w),j=getComputedStyle(l).scrollbarGutter==="stable both-edges"?b/2:b;j<=SA&&(a-=j)}return{width:a,height:c,x:u,y:p}}function CA(e,t){const n=Dr(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,l=Ci(e),o=e.clientWidth*l.x,a=e.clientHeight*l.y,c=i*l.x,u=r*l.y;return{width:o,height:a,x:c,y:u}}function Wx(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=NA(e,n,t);else if(t==="document")r=kA(Ps(e));else if(ss(t))r=CA(t,n);else{const i=ub(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return vc(r)}function EA(e,t){const n=t.get(e);if(n)return n;let r=so(e,[],!1).filter(a=>ss(a)&&tl(a)!=="body"),i=null;const l=rs(e).position==="fixed";let o=l?Or(e):e;for(;ss(o)&&!no(o);){const a=rs(o),c=Wp(o),u=i?i.position:l?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&a.position==="static")?r=r.filter(d=>d!==o):i=a,o=Or(o)}return t.set(e,r),r}function AA(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?tu(t)?[]:EA(t,this._c):[].concat(n),r],a=Wx(t,o[0],i);let c=a.top,u=a.right,p=a.bottom,d=a.left;for(let h=1;h<o.length;h++){const x=Wx(t,o[h],i);c=js(x.top,c),u=or(x.right,u),p=or(x.bottom,p),d=js(x.left,d)}return{width:u-d,height:p-c,x:d,y:c}}function RA(e){const{width:t,height:n}=cb(e);return{width:t,height:n}}function TA(e,t,n){const r=mr(t),i=Ps(t),l=n==="fixed",o=Dr(e,!0,l,t);let a={scrollLeft:0,scrollTop:0};const c=ys(0);if((r||!l)&&((tl(t)!=="body"||eu(i))&&(a=nu(t)),r)){const h=Dr(t,!0,l,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}!r&&i&&(c.x=su(i));const u=i&&!r&&!l?db(i,a):ys(0),p=o.left+a.scrollLeft-c.x-u.x,d=o.top+a.scrollTop-c.y-u.y;return{x:p,y:d,width:o.width,height:o.height}}function id(e){return rs(e).position==="static"}function Vx(e,t){if(!mr(e)||rs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ps(e)===n&&(n=n.ownerDocument.body),n}function fb(e,t){const n=sn(e);if(tu(e))return n;if(!mr(e)){let i=Or(e);for(;i&&!no(i);){if(ss(i)&&!id(i))return i;i=Or(i)}return n}let r=Vx(e,t);for(;r&&mA(r)&&id(r);)r=Vx(r,t);return r&&no(r)&&id(r)&&!Wp(r)?n:r||vA(e)||n}const PA=async function(e){const t=this.getOffsetParent||fb,n=this.getDimensions,r=await n(e.floating);return{reference:TA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function IA(e){return rs(e).direction==="rtl"}const MA={convertOffsetParentRelativeRectToViewportRelativeRect:wA,getDocumentElement:Ps,getClippingRect:AA,getOffsetParent:fb,getElementRects:PA,getClientRects:bA,getDimensions:RA,getScale:Ci,isElement:ss,isRTL:IA};function hb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $A(e,t,n){let r=null,i;const l=Ps(e);function o(){var p;clearTimeout(i),(p=r)==null||p.disconnect(),r=null}function a(p,d){p===void 0&&(p=!1),d===void 0&&(d=1),o();const h=e.getBoundingClientRect(),{left:x,top:v,width:w,height:b}=h;if(p||t(),!w||!b)return;const j=Zo(v),g=Zo(l.clientWidth-(x+w)),y=Zo(l.clientHeight-(v+b)),m=Zo(x),S={rootMargin:-j+"px "+-g+"px "+-y+"px "+-m+"px",threshold:js(0,or(1,d))||1};let N=!0;function C(T){const E=T[0].intersectionRatio;if(!hb(h,e.getBoundingClientRect()))return a();if(E!==d){if(!N)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}N=!1}try{r=new IntersectionObserver(C,{...S,root:l.ownerDocument})}catch{r=new IntersectionObserver(C,S)}r.observe(e)}const c=sn(e),u=()=>a(n);return c.addEventListener("resize",u),a(!0),()=>{c.removeEventListener("resize",u),o()}}function _A(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:l=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Hp(e),p=i||l?[...u?so(u):[],...t?so(t):[]]:[];p.forEach(j=>{i&&j.addEventListener("scroll",n),l&&j.addEventListener("resize",n)});const d=u&&a?$A(u,n,l):null;let h=-1,x=null;o&&(x=new ResizeObserver(j=>{let[g]=j;g&&g.target===u&&x&&t&&(x.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=x)==null||y.observe(t)})),n()}),u&&!c&&x.observe(u),t&&x.observe(t));let v,w=c?Dr(e):null;c&&b();function b(){const j=Dr(e);w&&!hb(w,j)&&n(),w=j,v=requestAnimationFrame(b)}return n(),()=>{var j;p.forEach(g=>{i&&g.removeEventListener("scroll",n),l&&g.removeEventListener("resize",n)}),d==null||d(),(j=x)==null||j.disconnect(),x=null,c&&cancelAnimationFrame(v)}}const OA=dA,DA=fA,LA=aA,FA=pA,UA=cA,Hx=oA,BA=hA,zA=(e,t,n)=>{const r=new Map,i=n??{},l={...MA,...i.platform,_c:r};return lA(e,t,{...i,platform:l})};var WA=typeof document<"u",VA=function(){},Oa=WA?f.useLayoutEffect:VA;function jc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!jc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const l=i[r];if(!(l==="_owner"&&e.$$typeof)&&!jc(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function pb(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Kx(e,t){const n=pb(e);return Math.round(t*n)/n}function ld(e){const t=f.useRef(e);return Oa(()=>{t.current=e}),t}function HA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:l,floating:o}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[p,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,x]=f.useState(r);jc(h,r)||x(r);const[v,w]=f.useState(null),[b,j]=f.useState(null),g=f.useCallback(M=>{M!==S.current&&(S.current=M,w(M))},[]),y=f.useCallback(M=>{M!==N.current&&(N.current=M,j(M))},[]),m=l||v,k=o||b,S=f.useRef(null),N=f.useRef(null),C=f.useRef(p),T=c!=null,E=ld(c),_=ld(i),F=ld(u),O=f.useCallback(()=>{if(!S.current||!N.current)return;const M={placement:t,strategy:n,middleware:h};_.current&&(M.platform=_.current),zA(S.current,N.current,M).then(z=>{const $={...z,isPositioned:F.current!==!1};A.current&&!jc(C.current,$)&&(C.current=$,Di.flushSync(()=>{d($)}))})},[h,t,n,_,F]);Oa(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,d(M=>({...M,isPositioned:!1})))},[u]);const A=f.useRef(!1);Oa(()=>(A.current=!0,()=>{A.current=!1}),[]),Oa(()=>{if(m&&(S.current=m),k&&(N.current=k),m&&k){if(E.current)return E.current(m,k,O);O()}},[m,k,O,E,T]);const D=f.useMemo(()=>({reference:S,floating:N,setReference:g,setFloating:y}),[g,y]),q=f.useMemo(()=>({reference:m,floating:k}),[m,k]),V=f.useMemo(()=>{const M={position:n,left:0,top:0};if(!q.floating)return M;const z=Kx(q.floating,p.x),$=Kx(q.floating,p.y);return a?{...M,transform:"translate("+z+"px, "+$+"px)",...pb(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:$}},[n,a,q.floating,p.x,p.y]);return f.useMemo(()=>({...p,update:O,refs:D,elements:q,floatingStyles:V}),[p,O,D,q,V])}const KA=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Hx({element:r.current,padding:i}).fn(n):{}:r?Hx({element:r,padding:i}).fn(n):{}}}},GA=(e,t)=>{const n=OA(e);return{name:n.name,fn:n.fn,options:[e,t]}},YA=(e,t)=>{const n=DA(e);return{name:n.name,fn:n.fn,options:[e,t]}},qA=(e,t)=>({fn:BA(e).fn,options:[e,t]}),QA=(e,t)=>{const n=LA(e);return{name:n.name,fn:n.fn,options:[e,t]}},JA=(e,t)=>{const n=FA(e);return{name:n.name,fn:n.fn,options:[e,t]}},XA=(e,t)=>{const n=UA(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZA=(e,t)=>{const n=KA(e);return{name:n.name,fn:n.fn,options:[e,t]}};var eR=Object.defineProperty,tR=(e,t)=>eR(e,"name",{value:t,configurable:!0});function mb(e){const[t,n]=f.useState(void 0);return nn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const l=i[0];let o,a;if("borderBoxSize"in l){const c=l.borderBoxSize,u=Array.isArray(c)?c[0]:c;o=u.inlineSize,a=u.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}tR(mb,"useSize");var nR=Object.defineProperty,tr=(e,t)=>nR(e,"name",{value:t,configurable:!0}),gb="Popper",[xb,ru]=zn(gb),[sR,vb]=xb(gb),rR=tr(e=>{const{__scopePopper:t,children:n}=e,[r,i]=f.useState(null),[l,o]=f.useState(void 0);return s.jsx(sR,{scope:t,anchor:r,onAnchorChange:i,placementState:l,setPlacementState:o,children:n})},"Popper"),iR="PopperAnchor",lR=f.forwardRef(tr(function(t,n){const{__scopePopper:r,virtualRef:i,...l}=t,o=vb(iR,r),a=f.useRef(null),c=o.onAnchorChange,u=f.useCallback(w=>{a.current=w,w&&c(w)},[c]),p=Ye(n,u),d=f.useRef(null);f.useEffect(()=>{if(!i)return;const w=d.current;d.current=i.current,w!==d.current&&c(d.current)});const h=o.placementState&&iu(o.placementState),x=h==null?void 0:h[0],v=h==null?void 0:h[1];return i?null:s.jsx(Qe.div,{"data-radix-popper-side":x,"data-radix-popper-align":v,...l,ref:p})},"PopperAnchor")),jb="PopperContent",[oR,W3]=xb(jb),aR=f.forwardRef(tr(function(t,n){var ye,Te,Ve,it,H,me,ue;const{__scopePopper:r,side:i="bottom",sideOffset:l=0,align:o="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:p=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:x=!1,updatePositionStrategy:v="optimized",onPlaced:w,...b}=t,j=vb(jb,r),[g,y]=f.useState(null),m=Ye(n,y),[k,S]=f.useState(null),N=mb(k),C=(N==null?void 0:N.width)??0,T=(N==null?void 0:N.height)??0,E=i+(o!=="center"?"-"+o:""),_=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(p)?p:[p],O=F.length>0,A={padding:_,boundary:F.filter(yb),altBoundary:O},{refs:D,floatingStyles:q,placement:V,isPositioned:M,middlewareData:z}=HA({strategy:"fixed",placement:E,whileElementsMounted:tr((...ke)=>_A(...ke,{animationFrame:v==="always"}),"whileElementsMounted"),elements:{reference:j.anchor},middleware:[GA({mainAxis:l+T,alignmentAxis:a}),u&&YA({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?qA():void 0,...A}),u&&QA({...A}),JA({...A,apply:tr(({elements:ke,rects:we,availableWidth:Je,availableHeight:lt})=>{const{width:St,height:cn}=we.reference,Tn=ke.floating.style;Tn.setProperty("--radix-popper-available-width",`${Je}px`),Tn.setProperty("--radix-popper-available-height",`${lt}px`),Tn.setProperty("--radix-popper-anchor-width",`${St}px`),Tn.setProperty("--radix-popper-anchor-height",`${cn}px`)},"apply")}),k&&ZA({element:k,padding:c}),cR({arrowWidth:C,arrowHeight:T}),x&&XA({strategy:"referenceHidden",...A,boundary:O?A.boundary:void 0})]}),$=j.setPlacementState;nn(()=>($(V),()=>{$(void 0)}),[V,$]);const[U,X]=iu(V),Z=Un(w);nn(()=>{M&&(Z==null||Z())},[M,Z]);const fe=(ye=z.arrow)==null?void 0:ye.x,ve=(Te=z.arrow)==null?void 0:Te.y,Ne=((Ve=z.arrow)==null?void 0:Ve.centerOffset)!==0,[oe,be]=f.useState();return nn(()=>{g&&be(window.getComputedStyle(g).zIndex)},[g]),s.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:M?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(it=z.transformOrigin)==null?void 0:it.x,(H=z.transformOrigin)==null?void 0:H.y].join(" "),...((me=z.hide)==null?void 0:me.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(oR,{scope:r,placedSide:U,placedAlign:X,onArrowChange:S,arrowX:fe,arrowY:ve,shouldHideArrow:Ne,children:s.jsx(Qe.div,{"data-side":U,"data-align":X,...b,ref:m,style:{...b.style,animation:M?(ue=b.style)==null?void 0:ue.animation:"none"}})})})},"PopperContent"));function yb(e){return e!==null}tr(yb,"isNotNull");var cR=tr(e=>({name:"transformOrigin",options:e,fn(t){var b,j,g;const{placement:n,rects:r,middlewareData:i}=t,o=((b=i.arrow)==null?void 0:b.centerOffset)!==0,a=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[u,p]=iu(n),d={start:"0%",center:"50%",end:"100%"}[p],h=(((j=i.arrow)==null?void 0:j.x)??0)+a/2,x=(((g=i.arrow)==null?void 0:g.y)??0)+c/2;let v="",w="";return u==="bottom"?(v=o?d:`${h}px`,w=`${-c}px`):u==="top"?(v=o?d:`${h}px`,w=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,w=o?d:`${x}px`):u==="left"&&(v=`${r.floating.width+c}px`,w=o?d:`${x}px`),{data:{x:v,y:w}}}}),"transformOrigin");function iu(e){const[t,n="center"]=e.split("-");return[t,n]}tr(iu,"getSideAndAlignFromPlacement");var wb=rR,bb=lR,kb=aR,uR=Object.defineProperty,vt=(e,t)=>uR(e,"name",{value:t,configurable:!0}),[Kp,V3]=zn("Tooltip",[ru]),Gp=ru(),dR="TooltipProvider",fR=700,Yf="tooltip.open",[hR,Yp]=Kp(dR),pR=vt(e=>{const{__scopeTooltip:t,delayDuration:n=fR,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:l}=e,o=f.useRef(!0),a=f.useRef(!1),c=f.useRef(0);return f.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(hR,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:f.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:l})},"TooltipProvider"),qf="Tooltip",[mR,jo]=Kp(qf),gR=vt(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:l,disableHoverableContent:o,delayDuration:a}=e,c=Yp(qf,e.__scopeTooltip),u=Gp(t),[p,d]=f.useState(null),[h,x]=f.useState(void 0),v=vs(),w=f.useRef(0),b=o??c.disableHoverableContent,j=a??c.delayDuration,g=f.useRef(!1),[y,m]=Zi({prop:r,defaultProp:i??!1,onChange:vt(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(Yf))):c.onClose(),l==null||l(E)},"onChange"),caller:qf}),k=f.useMemo(()=>y?g.current?"delayed-open":"instant-open":"closed",[y]),S=f.useCallback(()=>{window.clearTimeout(w.current),w.current=0,g.current=!1,m(!0)},[m]),N=f.useCallback(()=>{window.clearTimeout(w.current),w.current=0,m(!1)},[m]),C=f.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{g.current=!0,m(!0),w.current=0},j)},[j,m]);f.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const T=h??v;return s.jsx(wb,{...u,children:s.jsx(mR,{scope:t,contentId:T,setContentId:x,open:y,stateAttribute:k,trigger:p,onTriggerChange:d,onTriggerEnter:f.useCallback(()=>{c.isOpenDelayedRef.current?C():S()},[c.isOpenDelayedRef,C,S]),onTriggerLeave:f.useCallback(()=>{b?N():(window.clearTimeout(w.current),w.current=0)},[N,b]),onOpen:S,onClose:N,disableHoverableContent:b,children:n})})},"Tooltip"),Gx="TooltipTrigger",xR=f.forwardRef(vt(function(t,n){const{__scopeTooltip:r,...i}=t,l=jo(Gx,r),o=Yp(Gx,r),a=Gp(r),c=f.useRef(null),u=Ye(n,c,l.onTriggerChange),p=f.useRef(!1),d=f.useRef(!1),h=f.useCallback(()=>p.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(bb,{asChild:!0,...a,children:s.jsx(Qe.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...i,ref:u,onPointerMove:je(t.onPointerMove,x=>{x.pointerType!=="touch"&&!d.current&&!o.isPointerInTransitRef.current&&(l.onTriggerEnter(),d.current=!0)}),onPointerLeave:je(t.onPointerLeave,()=>{l.onTriggerLeave(),d.current=!1}),onPointerDown:je(t.onPointerDown,()=>{l.open&&l.onClose(),p.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:je(t.onFocus,()=>{p.current||l.onOpen()}),onBlur:je(t.onBlur,l.onClose),onClick:je(t.onClick,l.onClose)})})},"TooltipTrigger")),Sb="TooltipPortal",[vR,jR]=Kp(Sb,{forceMount:void 0}),yR=vt(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,l=jo(Sb,t);return s.jsx(vR,{scope:t,forceMount:n,children:s.jsx(pr,{present:n||l.open,children:s.jsx(Fp,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),ro="TooltipContent",wR=f.forwardRef(vt(function(t,n){const r=jR(ro,t.__scopeTooltip),{forceMount:i=r.forceMount,side:l="top",...o}=t,a=jo(ro,t.__scopeTooltip);return s.jsx(pr,{present:i||a.open,children:a.disableHoverableContent?s.jsx(Nb,{side:l,...o,ref:n}):s.jsx(bR,{side:l,...o,ref:n})})},"TooltipContent")),bR=f.forwardRef(vt(function(t,n){const r=jo(ro,t.__scopeTooltip),i=Yp(ro,t.__scopeTooltip),l=f.useRef(null),o=Ye(n,l),[a,c]=f.useState(null),{trigger:u,onClose:p}=r,d=l.current,{onPointerInTransitChange:h}=i,x=f.useCallback(()=>{c(null),h(!1)},[h]),v=f.useCallback((w,b)=>{const j=w.currentTarget,g={x:w.clientX,y:w.clientY},y=Cb(g,j.getBoundingClientRect()),m=Eb(g,y),k=Ab(b.getBoundingClientRect()),S=Tb([...m,...k]);c(S),h(!0)},[h]);return f.useEffect(()=>()=>x(),[x]),f.useEffect(()=>{if(u&&d){const w=vt(j=>v(j,d),"handleTriggerLeave"),b=vt(j=>v(j,u),"handleContentLeave");return u.addEventListener("pointerleave",w),d.addEventListener("pointerleave",b),()=>{u.removeEventListener("pointerleave",w),d.removeEventListener("pointerleave",b)}}},[u,d,v,x]),f.useEffect(()=>{if(a){const w=vt(b=>{const j=b.target,g={x:b.clientX,y:b.clientY},y=(u==null?void 0:u.contains(j))||(d==null?void 0:d.contains(j)),m=!Rb(g,a);y?x():m&&(x(),p())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,d,a,p,x]),s.jsx(Nb,{...t,ref:o})},"TooltipContentHoverable")),kR=Pw("TooltipContent"),Nb=f.forwardRef(vt(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":l,id:o,onEscapeKeyDown:a,onPointerDownOutside:c,...u}=t,p=jo(ro,r),d=Gp(r),{onClose:h}=p;f.useEffect(()=>(document.addEventListener(Yf,h),()=>document.removeEventListener(Yf,h)),[h]),f.useEffect(()=>{if(p.trigger){const v=vt(w=>{w.target instanceof Node&&w.target.contains(p.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",v,{capture:!0}),()=>window.removeEventListener("scroll",v,{capture:!0})}},[p.trigger,h]);const{setContentId:x}=p;return nn(()=>(x(o),()=>{x(void 0)}),[o,x]),s.jsx(Dp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:v=>v.preventDefault(),onDismiss:h,children:s.jsxs(kb,{"data-state":p.stateAttribute,role:l?void 0:"tooltip",id:l?void 0:p.contentId,...d,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(kR,{children:i}),l?s.jsx(TE,{id:p.contentId,role:"tooltip",children:l}):null]})})},"TooltipContentImpl"));function Cb(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,r,i,l)){case l:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}vt(Cb,"getExitSideFromRect");function Eb(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}vt(Eb,"getPaddedExitPoints");function Ab(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}vt(Ab,"getPointsFromRect");function Rb(e,t){const{x:n,y:r}=e;let i=!1;for(let l=0,o=t.length-1;l<t.length;o=l++){const a=t[l],c=t[o],u=a.x,p=a.y,d=c.x,h=c.y;p>r!=h>r&&n<(d-u)*(r-p)/(h-p)+u&&(i=!i)}return i}vt(Rb,"isPointInPolygon");function Tb(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Pb(t)}vt(Tb,"getHull");function Pb(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const l=t[t.length-1],o=t[t.length-2];if((l.x-o.x)*(i.y-o.y)>=(l.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const l=n[n.length-1],o=n[n.length-2];if((l.x-o.x)*(i.y-o.y)>=(l.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}vt(Pb,"getHullPresorted");var Yx=pR,yc=gR,wc=xR,bc=yR,kc=wR;const qx="buddi_csrf",nl="x-buddi-csrf",io="buddi:agents-changed",SR="This page's sign-in no longer matches its cookies. Reload the page and try again.";class de extends Error{constructor(t,n,r){super(n),this.status=t,this.detail=r,this.name="ApiError"}}function Vr(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${qx}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const n=[...document.cookie.matchAll(new RegExp(`(?:^|; )${qx}(?:_\\d+)?=([^;]*)`,"g"))];return n.length===1&&((r=n[0])!=null&&r[1])?decodeURIComponent(n[0][1]):""}async function Hr(e,t={}){const n=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}});if(n.status===401)throw new de(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await n.text(),i=r===""?null:NR(r);if(!n.ok){const l=i&&typeof i=="object"&&"error"in i?String(i.error):void 0,o=(t.method??"GET").toUpperCase(),a=l??(n.status===403&&o!=="GET"&&o!=="HEAD"?SR:`request failed (${n.status})`);throw new de(n.status,a,i)}return i}function NR(e){try{return JSON.parse(e)}catch{return null}}function ae(e,t={}){const n=new URLSearchParams;for(const[i,l]of Object.entries(t))l!==void 0&&l!==""&&n.set(i,String(l));const r=n.toString();return Hr(`/api${e}${r?`?${r}`:""}`)}function Ib(e,t){return Hr(`/api${e}`,{method:"POST",headers:{[nl]:Vr()},body:t})}function Sc(e){return Hr(`/api${e}`,{method:"DELETE",headers:{[nl]:Vr()}})}function ne(e,t={}){return Hr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[nl]:Vr()},body:JSON.stringify(t??{})})}function Mb(e,t,n,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||n;return Hr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[nl]:Vr(),"X-Filename":i,...r},body:t})}function Qx(e,t,n){return Mb(e,t,"backup.tar.gz",{...n.passphrase?{"X-Backup-Passphrase":n.passphrase}:{},...n.confirm?{"X-Backup-Confirm":n.confirm}:{}})}function CR(e,t={}){return Hr(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[nl]:Vr()},body:JSON.stringify(t??{})})}function jl(e,t={}){return Hr(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[nl]:Vr()},body:JSON.stringify(t??{})})}function ER(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 AR=["approval","question","watcher","reminder","failure","recap","plugin"],Le={agents:()=>ae("/chat/agents"),views:()=>ae("/chat/views"),conversations:(e,t)=>ae(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>ne(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>ae(`/chat/conversations/${encodeURIComponent(e)}`),send:(e,t)=>ne(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>ne(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>ne(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),Ib("/chat/attachments",t)},discardAttachment:e=>Sc(`/artifacts/${encodeURIComponent(e)}`),groups:()=>ae("/groups"),group:e=>ae(`/groups/${encodeURIComponent(e)}`),createGroup:e=>ne("/groups",e),updateGroup:(e,t)=>CR(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>Sc(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>ae(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>ne(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>ne(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`},R={providers:()=>ae("/providers"),providerAccounts:()=>ae("/provider-accounts"),probeModels:e=>ne("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>ne(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>ne("/provider-accounts/save",e),testProviderAccount:e=>ne(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>ne(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,n)=>ne(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:n}),anthropicAccountAction:(e,t,n,r)=>ne(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:n,...r}),assignProviderAccount:(e,t,n)=>ne(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:n}),configureProvider:(e,t)=>ne(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>ne(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>ne(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>ne(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>ae("/host/browser-profiles",{app:e}),installedApps:()=>ae("/host/apps"),browser:e=>ae(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>ne(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>ne("/browser/settings",e),computerPermissions:(e=!1)=>ne("/browser/permissions",{prompt:e}),browserInstall:()=>ne("/browser/install",{}),browserCheck:()=>ne("/browser/check",{}),previewLink:(e,t)=>ae(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>ae(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>ae("/extension"),pairExtension:e=>ne("/extension/pair",{code:e}),forgetExtension:()=>Sc("/extension/pair"),session:()=>ae("/session"),overview:()=>ae("/overview"),events:e=>ae("/events",e),eventKinds:()=>ae("/events/kinds"),conversations:()=>ae("/conversations"),conversation:e=>ae(`/conversations/${encodeURIComponent(e)}`),missions:()=>ae("/missions"),jobs:(e={})=>ae("/jobs",e),approvals:()=>ae("/approvals"),approval:e=>ae(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>ae("/offers"),dismissOffer:e=>ne(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>ne("/offers/dismiss-all",{ids:e}),agentOffers:()=>ae("/agent-offers"),dismissAgentOffer:(e,t)=>ne(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>ae("/proposals"),setDigestSchedule:(e,t)=>ne("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>ne(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),discardProposal:(e,t)=>ne(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>ae("/reminders"),sentinels:()=>ae("/sentinels"),setSentinelEnabled:(e,t)=>ne(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),snoozeAlert:(e,t)=>ne(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>ae("/agents"),library:e=>ae("/artifacts",e),libraryEntry:(e,t=0)=>ae(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>ae("/onboarding"),onboardingStep:(e,t={})=>ne("/onboarding/step",{step:e,...t}),completeOnboarding:()=>ne("/onboarding/complete"),skipOnboarding:()=>ne("/onboarding/skip"),createFirstAgent:e=>ne("/onboarding/agent",e),ollama:()=>ae("/onboarding/ollama"),firstAgentPersona:()=>ae("/onboarding/agent"),updateFirstAgent:e=>ne("/onboarding/agent/update",e),bindBrain:e=>ne("/onboarding/brain",e),pages:()=>ae("/pages"),pageQuery:(e,t,n={})=>ae(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n),pageFileUrl:(e,t,n={})=>{const r=new URLSearchParams(Object.entries(n).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>ne(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>ae("/telegram"),saveTelegramToken:e=>ne("/telegram/token",{token:e}),telegramPairing:()=>ne("/telegram/pairing"),notifications:(e=20)=>ae("/notifications",{limit:e}),notificationSeen:e=>ne(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>ae("/notifications/settings"),saveNotificationSettings:e=>jl("/notifications/settings",e),testChannel:e=>ne("/notifications/test",{channel:e}),presence:e=>ne("/presence",{state:e}),owner:()=>ae("/owner"),setOwner:e=>ne("/owner",e),memory:e=>ae(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>ne("/memory/preferences",e),forgetPreference:e=>ne("/memory/preferences/forget",e),updateNote:(e,t)=>ne(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>ne(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>ae(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>ae(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>ae("/host",{agentId:e,conversationId:t}),secrets:()=>ae("/secrets"),secretUses:(e,t)=>ae("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>ne("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>ne("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>ne("/host/revoke",{id:e}),decide:(e,t,n,r)=>ne(`/approvals/${encodeURIComponent(e)}/${t}`,n||r?{...n?{permissionScope:n}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>ne("/pause",{paused:e}),service:()=>ae("/service"),serviceAction:e=>ne(`/service/${e}`),version:()=>ae("/version"),checkVersion:()=>ne("/version/check"),setVersionCheck:e=>jl("/version/check",{enabled:e}),tailscale:()=>ae("/tailscale"),setTailscale:e=>jl("/tailscale",e),startUpgrade:e=>ne("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>ae(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>ae("/backups"),startBackup:e=>ne("/backups",{encrypt:e}),verifyArchive:e=>ne("/backups/verify",{name:e}),restoreArchive:e=>ne("/backups/restore",e),restoreUpload:(e,t)=>Qx("/backups/restore",e,t),backupJob:e=>ae(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>ae("/backups/schedule"),setBackupSchedule:e=>jl("/backups/schedule",e),backupPassphrase:()=>ae("/backups/passphrase"),setBackupPassphrase:e=>jl("/backups/passphrase",{passphrase:e}),plugins:()=>ae("/plugins"),stagePlugin:e=>ne("/plugins/stage",{spec:e}),uploadPlugin:e=>Mb("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>ae(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>ne(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>ne(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),uninstallPlugin:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>ae("/recovery"),leaveRecovery:e=>ne("/recovery/leave",e),firstRunRestore:(e,t)=>Qx("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>ne(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,n)=>ne(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...n===void 0?{}:{deadlineMinutes:n}}),retryJob:e=>ne(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>ne(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>ne("/agents/default",{agentId:e}),agentTools:e=>ae(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>ae(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const n=new FormData;return n.append("file",t,t.name),Ib(`/agents/${encodeURIComponent(e)}/avatar`,n)},removeAgentPicture:e=>Sc(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>ne(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>ne(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};var RR=Object.defineProperty,TR=(e,t)=>RR(e,"name",{value:t,configurable:!0}),PR=f.createContext(void 0);function lu(e){const t=f.useContext(PR);return e||t||"ltr"}TR(lu,"useDirection");var IR=Object.defineProperty,qp=(e,t)=>IR(e,"name",{value:t,configurable:!0}),ea=0,Gn=null;function MR(e){return ou(),e.children}qp(MR,"FocusGuards");function ou(){f.useEffect(()=>{Gn||(Gn={start:Qf(),end:Qf()});const{start:e,end:t}=Gn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ea++,()=>{ea===1&&(Gn==null||Gn.start.remove(),Gn==null||Gn.end.remove(),Gn=null),ea=Math.max(0,ea-1)}},[])}qp(ou,"useFocusGuards");function Qf(){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}qp(Qf,"createFocusGuard");var $R=Object.defineProperty,Bt=(e,t)=>$R(e,"name",{value:t,configurable:!0}),od="focusScope.autoFocusOnMount",ad="focusScope.autoFocusOnUnmount",Jx={bubbles:!1,cancelable:!0},$b=f.forwardRef(Bt(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:l,onUnmountAutoFocus:o,...a}=t,[c,u]=f.useState(null),p=Un(l),d=Un(o),h=f.useRef(null),x=Ye(n,u),v=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(i){let b=function(m){if(v.paused||!c)return;const k=m.target;c.contains(k)?h.current=k:hs(h.current,{select:!0})},j=function(m){if(v.paused||!c)return;const k=m.relatedTarget;k!==null&&(c.contains(k)||hs(h.current,{select:!0}))},g=function(m){if(document.activeElement===document.body)for(const S of m)S.removedNodes.length>0&&hs(c)};Bt(b,"handleFocusIn"),Bt(j,"handleFocusOut"),Bt(g,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",j);const y=new MutationObserver(g);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",j),y.disconnect()}}},[i,c,v.paused]),f.useEffect(()=>{if(c){Xx.add(v);const b=document.activeElement;if(!c.contains(b)){const g=new CustomEvent(od,Jx);c.addEventListener(od,p),c.dispatchEvent(g),g.defaultPrevented||(_b(Ub(Qp(c)),{select:!0}),document.activeElement===b&&hs(c))}return()=>{c.removeEventListener(od,p),setTimeout(()=>{const g=new CustomEvent(ad,Jx);c.addEventListener(ad,d),c.dispatchEvent(g),g.defaultPrevented||hs(b??document.body,{select:!0}),c.removeEventListener(ad,d),Xx.remove(v)},0)}}},[c,p,d,v]);const w=f.useCallback(b=>{if(!r&&!i||v.paused)return;const j=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,g=document.activeElement;if(j&&g){const y=b.currentTarget,[m,k]=Ob(y);m&&k?!b.shiftKey&&g===k?(b.preventDefault(),r&&hs(m,{select:!0})):b.shiftKey&&g===m&&(b.preventDefault(),r&&hs(k,{select:!0})):g===y&&b.preventDefault()}},[r,i,v.paused]);return s.jsx(Qe.div,{tabIndex:-1,...a,ref:x,onKeyDown:w})},"FocusScope"));function _b(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(hs(r,{select:t}),document.activeElement!==n)return}Bt(_b,"focusFirst");function Ob(e){const t=Qp(e),n=Jf(t,e),r=Jf(t.reverse(),e);return[n,r]}Bt(Ob,"getTabbableEdges");function Qp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Bt(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Bt(Qp,"getTabbableCandidates");function Jf(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Db(r,{upTo:t})))return r}Bt(Jf,"findVisible");function Db(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}Bt(Db,"isHidden");function Lb(e){return e instanceof HTMLInputElement&&"select"in e}Bt(Lb,"isSelectableInput");function hs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Lb(e)&&t&&e.select()}}Bt(hs,"focus");var Xx=Fb();function Fb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Xf(e,t),e.unshift(t)},remove(t){var n;e=Xf(e,t),(n=e[0])==null||n.resume()}}}Bt(Fb,"createFocusScopesStack");function Xf(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Bt(Xf,"arrayRemove");function Ub(e){return e.filter(t=>t.tagName!=="A")}Bt(Ub,"removeLinks");var _R=Object.defineProperty,Jp=(e,t)=>_R(e,"name",{value:t,configurable:!0}),cd=!1;function Bb(){const[e,t]=f.useState(cd);return f.useEffect(()=>{cd||(cd=!0,t(!0))},[]),e}Jp(Bb,"useIsHydrated");var zb=qi[" useSyncExternalStore ".trim().toString()];function Wb(){return()=>{}}Jp(Wb,"subscribe");function Vb(){return zb(Wb,()=>!0,()=>!1)}Jp(Vb,"useIsHydratedModern");var OR=typeof zb=="function"?Vb:Bb,DR=Object.defineProperty,Kr=(e,t)=>DR(e,"name",{value:t,configurable:!0}),ud="rovingFocusGroup.onEntryFocus",LR={bubbles:!1,cancelable:!0},au="RovingFocusGroup",[Zf,Hb,FR]=Jc(au),[UR,cu]=zn(au,[FR]),[BR,zR]=UR(au),WR=f.forwardRef(Kr(function(t,n){return s.jsx(Zf.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Zf.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(VR,{...t,ref:n})})})},"RovingFocusGroup")),VR=f.forwardRef(Kr(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:l=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:p,preventScrollOnEntryFocus:d=!1,...h}=t,x=f.useRef(null),v=Ye(n,x),w=lu(o),[b,j]=Zi({prop:a,defaultProp:c??null,onChange:u,caller:au}),[g,y]=f.useState(!1),m=Un(p),k=Hb(r),S=f.useRef(!1),[N,C]=f.useState(0);return f.useEffect(()=>{const T=x.current;if(T)return T.addEventListener(ud,m),()=>T.removeEventListener(ud,m)},[m]),s.jsx(BR,{scope:r,orientation:i,dir:w,loop:l,currentTabStopId:b,onItemFocus:f.useCallback(T=>j(T),[j]),onItemShiftTab:f.useCallback(()=>y(!0),[]),onFocusableItemAdd:f.useCallback(()=>C(T=>T+1),[]),onFocusableItemRemove:f.useCallback(()=>C(T=>T-1),[]),children:s.jsx(Qe.div,{tabIndex:g||N===0?-1:0,"data-orientation":i,...h,ref:v,style:{outline:"none",...t.style},onMouseDown:je(t.onMouseDown,()=>{S.current=!0}),onFocus:je(t.onFocus,T=>{const E=!S.current;if(T.target===T.currentTarget&&E&&!g){const _=new CustomEvent(ud,LR);if(T.currentTarget.dispatchEvent(_),!_.defaultPrevented){const F=k().filter(V=>V.focusable),O=F.find(V=>V.active),A=F.find(V=>V.id===b),q=[O,A,...F].filter(Boolean).map(V=>V.ref.current);Xp(q,d)}}S.current=!1}),onBlur:je(t.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),HR="RovingFocusGroupItem",KR=f.forwardRef(Kr(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:l=!1,tabStopId:o,children:a,...c}=t,u=vs(),p=o||u,d=zR(HR,r),h=d.currentTabStopId===p,x=Hb(r),{onFocusableItemAdd:v,onFocusableItemRemove:w,currentTabStopId:b}=d,j=OR();return nn(()=>{if(!(!j||!i))return v(),()=>w()},[j,i,v,w]),f.useEffect(()=>{if(!(j||!i))return v(),()=>w()},[j,i,v,w]),s.jsx(Zf.ItemSlot,{scope:r,id:p,focusable:i,active:l,children:s.jsx(Qe.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...c,ref:n,onMouseDown:je(t.onMouseDown,g=>{i?d.onItemFocus(p):g.preventDefault()}),onFocus:je(t.onFocus,()=>d.onItemFocus(p)),onKeyDown:je(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=Gb(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let k=x().filter(S=>S.focusable).map(S=>S.ref.current);if(y==="last")k.reverse();else if(y==="prev"||y==="next"){y==="prev"&&k.reverse();const S=k.indexOf(g.currentTarget);k=d.loop?Yb(k,S+1):k.slice(S+1)}setTimeout(()=>Xp(k))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:b!=null}):a})})},"RovingFocusGroupItem")),GR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Kb(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Kr(Kb,"getDirectionAwareKey");function Gb(e,t,n){const r=Kb(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return GR[r]}Kr(Gb,"getFocusIntent");function Xp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Kr(Xp,"focusFirst");function Yb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Kr(Yb,"wrapArray");var qb=WR,Qb=KR,YR=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ti=new WeakMap,ta=new WeakMap,na={},dd=0,Jb=function(e){return e&&(e.host||Jb(e.parentNode))},qR=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Jb(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},QR=function(e,t,n,r){var i=qR(t,Array.isArray(e)?e:[e]);na[n]||(na[n]=new WeakMap);var l=na[n],o=[],a=new Set,c=new Set(i),u=function(d){!d||a.has(d)||(a.add(d),u(d.parentNode))};i.forEach(u);var p=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))p(h);else try{var x=h.getAttribute(r),v=x!==null&&x!=="false",w=(ti.get(h)||0)+1,b=(l.get(h)||0)+1;ti.set(h,w),l.set(h,b),o.push(h),w===1&&v&&ta.set(h,!0),b===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",h,j)}})};return p(t),a.clear(),dd++,function(){o.forEach(function(d){var h=ti.get(d)-1,x=l.get(d)-1;ti.set(d,h),l.set(d,x),h||(ta.has(d)||d.removeAttribute(r),ta.delete(d)),x||d.removeAttribute(n)}),dd--,dd||(ti=new WeakMap,ti=new WeakMap,ta=new WeakMap,na={})}},Xb=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=YR(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),QR(r,i,n,"aria-hidden")):function(){return null}},Qn=function(){return Qn=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])}return t},Qn.apply(this,arguments)};function Zb(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function JR(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,l;r<i;r++)(l||!(r in t))&&(l||(l=Array.prototype.slice.call(t,0,r)),l[r]=t[r]);return e.concat(l||Array.prototype.slice.call(t))}var Da="right-scroll-bar-position",La="width-before-scroll-bar",XR="with-scroll-bars-hidden",ZR="--removed-body-scroll-bar-size";function fd(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function eT(e,t){var n=f.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var tT=typeof window<"u"?f.useLayoutEffect:f.useEffect,Zx=new WeakMap;function nT(e,t){var n=eT(null,function(r){return e.forEach(function(i){return fd(i,r)})});return tT(function(){var r=Zx.get(n);if(r){var i=new Set(r),l=new Set(e),o=n.current;i.forEach(function(a){l.has(a)||fd(a,null)}),l.forEach(function(a){i.has(a)||fd(a,o)})}Zx.set(n,e)},[e]),n}function sT(e){return e}function rT(e,t){t===void 0&&(t=sT);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(l){var o=t(l,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(l){for(r=!0;n.length;){var o=n;n=[],o.forEach(l)}n={push:function(a){return l(a)},filter:function(){return n}}},assignMedium:function(l){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(l),o=n}var c=function(){var p=o;o=[],p.forEach(l)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(p){o.push(p),u()},filter:function(p){return o=o.filter(p),n}}}};return i}function iT(e){e===void 0&&(e={});var t=rT(null);return t.options=Qn({async:!0,ssr:!1},e),t}var e0=function(e){var t=e.sideCar,n=Zb(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 f.createElement(r,Qn({},n))};e0.isSideCarExport=!0;function lT(e,t){return e.useMedium(t),e0}var t0=iT(),hd=function(){},uu=f.forwardRef(function(e,t){var n=f.useRef(null),r=f.useState({onScrollCapture:hd,onWheelCapture:hd,onTouchMoveCapture:hd}),i=r[0],l=r[1],o=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,p=e.enabled,d=e.shards,h=e.sideCar,x=e.noRelative,v=e.noIsolation,w=e.inert,b=e.allowPinchZoom,j=e.as,g=j===void 0?"div":j,y=e.gapMode,m=Zb(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,S=nT([n,t]),N=Qn(Qn({},m),i);return f.createElement(f.Fragment,null,p&&f.createElement(k,{sideCar:t0,removeScrollBar:u,shards:d,noRelative:x,noIsolation:v,inert:w,setCallbacks:l,allowPinchZoom:!!b,lockRef:n,gapMode:y}),o?f.cloneElement(f.Children.only(a),Qn(Qn({},N),{ref:S})):f.createElement(g,Qn({},N,{className:c,ref:S}),a))});uu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};uu.classNames={fullWidth:La,zeroRight:Da};var oT=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function aT(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=oT();return t&&e.setAttribute("nonce",t),e}function cT(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function uT(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var dT=function(){var e=0,t=null;return{add:function(n){e==0&&(t=aT())&&(cT(t,n),uT(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},fT=function(){var e=dT();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},n0=function(){var e=fT(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},hT={left:0,top:0,right:0,gap:0},pd=function(e){return parseInt(e||"",10)||0},pT=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[pd(n),pd(r),pd(i)]},mT=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return hT;var t=pT(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},gT=n0(),Ei="data-scroll-locked",xT=function(e,t,n,r){var i=e.left,l=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
41
- .`.concat(XR,` {
42
- overflow: hidden `).concat(r,`;
43
- padding-right: `).concat(a,"px ").concat(r,`;
44
- }
45
- body[`).concat(Ei,`] {
46
- overflow: hidden `).concat(r,`;
47
- overscroll-behavior: contain;
48
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
49
- padding-left: `.concat(i,`px;
50
- padding-top: `).concat(l,`px;
51
- padding-right: `).concat(o,`px;
52
- margin-left:0;
53
- margin-top:0;
54
- margin-right: `).concat(a,"px ").concat(r,`;
55
- `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
56
- }
57
-
58
- .`).concat(Da,` {
59
- right: `).concat(a,"px ").concat(r,`;
60
- }
61
-
62
- .`).concat(La,` {
63
- margin-right: `).concat(a,"px ").concat(r,`;
64
- }
65
-
66
- .`).concat(Da," .").concat(Da,` {
67
- right: 0 `).concat(r,`;
68
- }
69
-
70
- .`).concat(La," .").concat(La,` {
71
- margin-right: 0 `).concat(r,`;
72
- }
73
-
74
- body[`).concat(Ei,`] {
75
- `).concat(ZR,": ").concat(a,`px;
76
- }
77
- `)},ev=function(){var e=parseInt(document.body.getAttribute(Ei)||"0",10);return isFinite(e)?e:0},vT=function(){f.useEffect(function(){return document.body.setAttribute(Ei,(ev()+1).toString()),function(){var e=ev()-1;e<=0?document.body.removeAttribute(Ei):document.body.setAttribute(Ei,e.toString())}},[])},jT=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;vT();var l=f.useMemo(function(){return mT(i)},[i]);return f.createElement(gT,{styles:xT(l,!t,i,n?"":"!important")})},eh=!1;if(typeof window<"u")try{var sa=Object.defineProperty({},"passive",{get:function(){return eh=!0,!0}});window.addEventListener("test",sa,sa),window.removeEventListener("test",sa,sa)}catch{eh=!1}var ni=eh?{passive:!1}:!1,yT=function(e){return e.tagName==="TEXTAREA"},s0=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!yT(e)&&n[t]==="visible")},wT=function(e){return s0(e,"overflowY")},bT=function(e){return s0(e,"overflowX")},tv=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=r0(e,r);if(i){var l=i0(e,r),o=l[1],a=l[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},kT=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},ST=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},r0=function(e,t){return e==="v"?wT(t):bT(t)},i0=function(e,t){return e==="v"?kT(t):ST(t)},NT=function(e,t){return e==="h"&&t==="rtl"?-1:1},CT=function(e,t,n,r,i){var l=NT(e,window.getComputedStyle(t).direction),o=l*r,a=n.target,c=t.contains(a),u=!1,p=o>0,d=0,h=0;do{if(!a)break;var x=i0(e,a),v=x[0],w=x[1],b=x[2],j=w-b-l*v;(v||j)&&r0(e,a)&&(d+=j,h+=v);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(p&&Math.abs(d)<1||!p&&Math.abs(h)<1)&&(u=!0),u},ra=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},nv=function(e){return[e.deltaX,e.deltaY]},sv=function(e){return e&&"current"in e?e.current:e},ET=function(e,t){return e[0]===t[0]&&e[1]===t[1]},AT=function(e){return`
78
- .block-interactivity-`.concat(e,` {pointer-events: none;}
79
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
80
- `)},RT=0,si=[];function TT(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),i=f.useState(RT++)[0],l=f.useState(n0)[0],o=f.useRef(e);f.useEffect(function(){o.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var w=JR([e.lockRef.current],(e.shards||[]).map(sv),!0).filter(Boolean);return w.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=f.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var j=ra(w),g=n.current,y="deltaX"in w?w.deltaX:g[0]-j[0],m="deltaY"in w?w.deltaY:g[1]-j[1],k,S=w.target,N=Math.abs(y)>Math.abs(m)?"h":"v";if("touches"in w&&N==="h"&&S.type==="range")return!1;var C=window.getSelection(),T=C&&C.anchorNode,E=T?T===S||T.contains(S):!1;if(E)return!1;var _=tv(N,S);if(!_)return!0;if(_?k=N:(k=N==="v"?"h":"v",_=tv(N,S)),!_)return!1;if(!r.current&&"changedTouches"in w&&(y||m)&&(r.current=k),!k)return!0;var F=r.current||k;return CT(F,b,w,F==="h"?y:m)},[]),c=f.useCallback(function(w){var b=w;if(!(!si.length||si[si.length-1]!==l)){var j="deltaY"in b?nv(b):ra(b),g=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&ET(k.delta,j)})[0];if(g&&g.should){b.cancelable&&b.preventDefault();return}if(!g){var y=(o.current.shards||[]).map(sv).filter(Boolean).filter(function(k){return k.contains(b.target)}),m=y.length>0?a(b,y[0]):!o.current.noIsolation;m&&b.cancelable&&b.preventDefault()}}},[]),u=f.useCallback(function(w,b,j,g){var y={name:w,delta:b,target:j,should:g,shadowParent:PT(j)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(m){return m!==y})},1)},[]),p=f.useCallback(function(w){n.current=ra(w),r.current=void 0},[]),d=f.useCallback(function(w){u(w.type,nv(w),w.target,a(w,e.lockRef.current))},[]),h=f.useCallback(function(w){u(w.type,ra(w),w.target,a(w,e.lockRef.current))},[]);f.useEffect(function(){return si.push(l),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",c,ni),document.addEventListener("touchmove",c,ni),document.addEventListener("touchstart",p,ni),function(){si=si.filter(function(w){return w!==l}),document.removeEventListener("wheel",c,ni),document.removeEventListener("touchmove",c,ni),document.removeEventListener("touchstart",p,ni)}},[]);var x=e.removeScrollBar,v=e.inert;return f.createElement(f.Fragment,null,v?f.createElement(l,{styles:AT(i)}):null,x?f.createElement(jT,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function PT(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const IT=lT(t0,TT);var Zp=f.forwardRef(function(e,t){return f.createElement(uu,Qn({},e,{ref:t,sideCar:IT}))});Zp.classNames=uu.classNames;var MT=Object.defineProperty,Pe=(e,t)=>MT(e,"name",{value:t,configurable:!0}),$T=["Enter"," "],_T=["ArrowDown","PageUp","Home"],l0=["ArrowUp","PageDown","End"],OT=[..._T,...l0],du="Menu",[th,DT,LT]=Jc(du),[Gr,o0]=zn(du,[LT,ru,cu]),em=ru(),a0=cu(),[FT,yo]=Gr(du),[UT,tm]=Gr(du),BT=Pe(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:l,modal:o=!0}=e,a=em(t),[c,u]=f.useState(null),p=f.useRef(!1),d=Un(l),h=lu(i);return f.useEffect(()=>{const x=Pe(()=>{p.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},"handleKeyDown"),v=Pe(()=>p.current=!1,"handlePointer");return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),f.useEffect(()=>{if(!n)return;const x=Pe(()=>d(!1),"handleBlur");return window.addEventListener("blur",x),()=>window.removeEventListener("blur",x)},[n,d]),s.jsx(wb,{...a,children:s.jsx(FT,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:u,children:s.jsx(UT,{scope:t,onClose:f.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:p,dir:h,modal:o,children:r})})})},"Menu"),zT=f.forwardRef(Pe(function(t,n){const{__scopeMenu:r,...i}=t,l=em(r);return s.jsx(bb,{...l,...i,ref:n})},"MenuAnchor")),c0="MenuPortal",[WT,VT]=Gr(c0,{forceMount:void 0}),HT=Pe(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,l=yo(c0,t);return s.jsx(WT,{scope:t,forceMount:n,children:s.jsx(pr,{present:n||l.open,children:s.jsx(Fp,{asChild:!0,container:i,children:r})})})},"MenuPortal"),nr="MenuContent",[KT,u0]=Gr(nr),GT=f.forwardRef(Pe(function(t,n){const r=VT(nr,t.__scopeMenu),{forceMount:i=r.forceMount,...l}=t,o=yo(nr,t.__scopeMenu),a=tm(nr,t.__scopeMenu);return s.jsx(th.Provider,{scope:t.__scopeMenu,children:s.jsx(pr,{present:i||o.open,children:s.jsx(th.Slot,{scope:t.__scopeMenu,children:a.modal?s.jsx(YT,{...l,ref:n}):s.jsx(qT,{...l,ref:n})})})})},"MenuContent")),YT=f.forwardRef(Pe(function(t,n){const r=yo(nr,t.__scopeMenu),i=f.useRef(null),l=Ye(n,i);return f.useEffect(()=>{const o=i.current;if(o)return Xb(o)},[]),s.jsx(d0,{...t,ref:l,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:je(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),qT=f.forwardRef(Pe(function(t,n){const r=yo(nr,t.__scopeMenu);return s.jsx(d0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),QT=lr("MenuContent.ScrollLock"),d0=f.forwardRef(Pe(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:l,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:p,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:x,onDismiss:v,disableOutsideScroll:w,...b}=t,j=yo(nr,r),g=tm(nr,r),y=em(r),m=a0(r),k=DT(r),[S,N]=f.useState(null),C=f.useRef(null),T=Ye(n,C,j.onContentChange),E=f.useRef(0),_=f.useRef(""),F=f.useRef(0),O=f.useRef(null),A=f.useRef("right"),D=f.useRef(0),q=w?Zp:f.Fragment,V=w?{as:QT,allowPinchZoom:!0}:void 0,M=Pe($=>{var be,ye;const U=_.current+$,X=k().filter(Te=>!Te.disabled),Z=document.activeElement,fe=(be=X.find(Te=>Te.ref.current===Z))==null?void 0:be.textValue,ve=X.map(Te=>Te.textValue),Ne=j0(ve,U,fe),oe=(ye=X.find(Te=>Te.textValue===Ne))==null?void 0:ye.ref.current;Pe(function Te(Ve){_.current=Ve,window.clearTimeout(E.current),Ve!==""&&(E.current=window.setTimeout(()=>Te(""),1e3))},"updateSearch")(U),oe&&setTimeout(()=>oe.focus())},"handleTypeaheadSearch");f.useEffect(()=>()=>window.clearTimeout(E.current),[]),ou();const z=f.useCallback($=>{var X,Z;return A.current===((X=O.current)==null?void 0:X.side)&&w0($,(Z=O.current)==null?void 0:Z.area)},[]);return s.jsx(KT,{scope:r,searchRef:_,onItemEnter:f.useCallback($=>{z($)&&$.preventDefault()},[z]),onItemLeave:f.useCallback($=>{var U;z($)||((U=C.current)==null||U.focus(),N(null))},[z]),onTriggerLeave:f.useCallback($=>{z($)&&$.preventDefault()},[z]),pointerGraceTimerRef:F,onPointerGraceIntentChange:f.useCallback($=>{O.current=$},[]),children:s.jsx(q,{...V,children:s.jsx($b,{asChild:!0,trapped:l,onMountAutoFocus:je(o,$=>{var U;$.preventDefault(),(U=C.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:s.jsx(Dp,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:p,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:x,onDismiss:v,children:s.jsx(qb,{asChild:!0,...m,dir:g.dir,orientation:"vertical",loop:i,currentTabStopId:S,onCurrentTabStopIdChange:N,onEntryFocus:je(u,$=>{g.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(kb,{role:"menu","aria-orientation":"vertical","data-state":p0(j.open),"data-radix-menu-content":"",dir:g.dir,...y,...b,ref:T,style:{outline:"none",...b.style},onKeyDown:je(b.onKeyDown,$=>{const X=$.target.closest("[data-radix-menu-content]")===$.currentTarget,Z=$.ctrlKey||$.altKey||$.metaKey,fe=$.key.length===1;X&&($.key==="Tab"&&$.preventDefault(),!Z&&fe&&M($.key));const ve=C.current;if($.target!==ve||!OT.includes($.key))return;$.preventDefault();const oe=k().filter(be=>!be.disabled).map(be=>be.ref.current);l0.includes($.key)&&oe.reverse(),x0(oe)}),onBlur:je(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(E.current),_.current="")}),onPointerMove:je(t.onPointerMove,Nc($=>{const U=$.target,X=D.current!==$.clientX;if($.currentTarget.contains(U)&&X){const Z=$.clientX>D.current?"right":"left";A.current=Z,D.current=$.clientX}}))})})})})})})},"MenuContentImpl")),f0=f.forwardRef(Pe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(Qe.div,{role:"group",...i,ref:n})},"MenuGroup")),JT=f.forwardRef(Pe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(Qe.div,{...i,ref:n})},"MenuLabel")),nh="MenuItem",rv="menu.itemSelect",h0=f.forwardRef(Pe(function(t,n){const{disabled:r=!1,onSelect:i,...l}=t,o=f.useRef(null),a=tm(nh,t.__scopeMenu),c=u0(nh,t.__scopeMenu),u=Ye(n,o),p=f.useRef(!1),d=Pe(()=>{const h=o.current;if(!r&&h){const x=new CustomEvent(rv,{bubbles:!0,cancelable:!0});h.addEventListener(rv,v=>i==null?void 0:i(v),{once:!0}),Xc(h,x),x.defaultPrevented?p.current=!1:a.onClose()}},"handleSelect");return s.jsx(XT,{...l,ref:u,disabled:r,onClick:je(t.onClick,d),onPointerDown:h=>{var x;(x=t.onPointerDown)==null||x.call(t,h),p.current=!0},onPointerUp:je(t.onPointerUp,h=>{var x;p.current||(x=h.currentTarget)==null||x.click()}),onKeyDown:je(t.onKeyDown,h=>{r||h.target!==h.currentTarget||c.searchRef.current!==""&&h.key===" "||$T.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})},"MenuItem")),XT=f.forwardRef(Pe(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:l,...o}=t,a=u0(nh,r),c=a0(r),u=f.useRef(null),p=Ye(n,u),[d,h]=f.useState(!1),[x,v]=f.useState("");return f.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[o.children]),s.jsx(th.ItemSlot,{scope:r,disabled:i,textValue:l??x,children:s.jsx(Qb,{asChild:!0,...c,focusable:!i,children:s.jsx(Qe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:p,onPointerMove:je(t.onPointerMove,Nc(w=>{i?a.onItemLeave(w):(a.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:je(t.onPointerLeave,Nc(w=>a.onItemLeave(w))),onFocus:je(t.onFocus,()=>h(!0)),onBlur:je(t.onBlur,()=>h(!1))})})})},"MenuItemImpl")),ZT="MenuRadioGroup",[eP,tP]=Gr(ZT,{value:void 0,onValueChange:Pe(()=>{},"onValueChange")}),nP=f.forwardRef(Pe(function(t,n){const{value:r,onValueChange:i,...l}=t,o=Un(i);return s.jsx(eP,{scope:t.__scopeMenu,value:r,onValueChange:o,children:s.jsx(f0,{...l,ref:n})})},"MenuRadioGroup")),sP="MenuRadioItem",rP=f.forwardRef(Pe(function(t,n){const{value:r,...i}=t,l=tP(sP,t.__scopeMenu),o=r===l.value;return s.jsx(lP,{scope:t.__scopeMenu,checked:o,children:s.jsx(h0,{role:"menuitemradio","aria-checked":o,...i,ref:n,"data-state":g0(o),onSelect:je(i.onSelect,()=>{var a;return(a=l.onValueChange)==null?void 0:a.call(l,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),iP="MenuItemIndicator",[lP,H3]=Gr(iP,{checked:!1}),oP=f.forwardRef(Pe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(Qe.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),aP="MenuSub",[K3,G3]=Gr(aP);function p0(e){return e?"open":"closed"}Pe(p0,"getOpenState");function m0(e){return e==="indeterminate"}Pe(m0,"isIndeterminate");function g0(e){return m0(e)?"indeterminate":e?"checked":"unchecked"}Pe(g0,"getCheckedState");function x0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Pe(x0,"focusFirst");function v0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Pe(v0,"wrapArray");function j0(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let o=v0(e,Math.max(l,0));i.length===1&&(o=o.filter(u=>u!==n));const c=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}Pe(j0,"getNextMatch");function y0(e,t){const{x:n,y:r}=e;let i=!1;for(let l=0,o=t.length-1;l<t.length;o=l++){const a=t[l],c=t[o],u=a.x,p=a.y,d=c.x,h=c.y;p>r!=h>r&&n<(d-u)*(r-p)/(h-p)+u&&(i=!i)}return i}Pe(y0,"isPointInPolygon");function w0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return y0(n,t)}Pe(w0,"isPointerInGraceArea");function Nc(e){return t=>t.pointerType==="mouse"?e(t):void 0}Pe(Nc,"whenMouse");var cP=BT,uP=zT,dP=HT,fP=GT,hP=f0,pP=JT,mP=h0,gP=nP,xP=rP,vP=oP,jP=Object.defineProperty,is=(e,t)=>jP(e,"name",{value:t,configurable:!0}),nm="DropdownMenu",[yP,Y3]=zn(nm,[o0]),ls=o0(),[wP,b0]=yP(nm),bP=is(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:l,onOpenChange:o,modal:a=!0}=e,c=ls(t),u=f.useRef(null),[p,d]=Zi({prop:i,defaultProp:l??!1,onChange:o,caller:nm});return s.jsx(wP,{scope:t,triggerId:vs(),triggerRef:u,contentId:vs(),open:p,onOpenChange:d,onOpenToggle:f.useCallback(()=>d(h=>!h),[d]),modal:a,children:s.jsx(cP,{...c,open:p,onOpenChange:d,dir:r,modal:a,children:n})})},"DropdownMenu"),kP="DropdownMenuTrigger",SP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...l}=t,o=b0(kP,r),a=ls(r),c=Ye(n,o.triggerRef);return s.jsx(uP,{asChild:!0,...a,children:s.jsx(Qe.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...l,ref:c,onPointerDown:je(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(o.onOpenToggle(),o.open||u.preventDefault())}),onKeyDown:je(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&o.onOpenToggle(),u.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),NP=is(e=>{const{__scopeDropdownMenu:t,...n}=e,r=ls(t);return s.jsx(dP,{...r,...n})},"DropdownMenuPortal"),CP="DropdownMenuContent",EP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=b0(CP,r),o=ls(r),a=f.useRef(!1);return s.jsx(fP,{id:l.contentId,"aria-labelledby":l.triggerId,...o,...i,ref:n,onCloseAutoFocus:je(t.onCloseAutoFocus,c=>{var u;a.current||(u=l.triggerRef.current)==null||u.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:je(t.onInteractOutside,c=>{const u=c.detail.originalEvent,p=u.button===0&&u.ctrlKey===!0,d=u.button===2||p;(!l.modal||d)&&(a.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),AP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(hP,{...l,...i,ref:n})},"DropdownMenuGroup")),RP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(pP,{...l,...i,ref:n})},"DropdownMenuLabel")),TP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(mP,{...l,...i,ref:n})},"DropdownMenuItem")),PP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(gP,{...l,...i,ref:n})},"DropdownMenuRadioGroup")),IP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(xP,{...l,...i,ref:n})},"DropdownMenuRadioItem")),MP=f.forwardRef(is(function(t,n){const{__scopeDropdownMenu:r,...i}=t,l=ls(r);return s.jsx(vP,{...l,...i,ref:n})},"DropdownMenuSeparator")),sm=bP,rm=SP,im=NP,lm=EP,$P=AP,om=RP,sh=TP,_P=PP,OP=IP,Fa=MP,DP=Object.defineProperty,sl=(e,t)=>DP(e,"name",{value:t,configurable:!0}),am="Tabs",[LP,q3]=zn(am,[cu]),k0=cu(),[FP,cm]=LP(am),UP=f.forwardRef(sl(function(t,n){const{__scopeTabs:r,value:i,onValueChange:l,defaultValue:o,orientation:a="horizontal",dir:c,activationMode:u="automatic",...p}=t,d=lu(c),[h,x]=Zi({prop:i,onChange:l,defaultProp:o??"",caller:am});return s.jsx(FP,{scope:r,baseId:vs(),value:h,onValueChange:x,orientation:a,dir:d,activationMode:u,children:s.jsx(Qe.div,{dir:d,"data-orientation":a,...p,ref:n})})},"Tabs")),BP="TabsList",zP=f.forwardRef(sl(function(t,n){const{__scopeTabs:r,loop:i=!0,...l}=t,o=cm(BP,r),a=k0(r);return s.jsx(qb,{asChild:!0,...a,orientation:o.orientation,dir:o.dir,loop:i,children:s.jsx(Qe.div,{role:"tablist","aria-orientation":o.orientation,...l,ref:n})})},"TabsList")),WP="TabsTrigger",VP=f.forwardRef(sl(function(t,n){const{__scopeTabs:r,value:i,disabled:l=!1,...o}=t,a=cm(WP,r),c=k0(r),u=um(a.baseId,i),p=dm(a.baseId,i),d=i===a.value;return s.jsx(Qb,{asChild:!0,...c,focusable:!l,active:d,children:s.jsx(Qe.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":p,"data-state":d?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:u,...o,ref:n,onMouseDown:je(t.onMouseDown,h=>{!l&&h.button===0&&h.ctrlKey===!1?a.onValueChange(i):h.preventDefault()}),onKeyDown:je(t.onKeyDown,h=>{l||h.target!==h.currentTarget||[" ","Enter"].includes(h.key)&&a.onValueChange(i)}),onFocus:je(t.onFocus,()=>{const h=a.activationMode!=="manual";!d&&!l&&h&&a.onValueChange(i)})})})},"TabsTrigger")),HP="TabsContent",KP=f.forwardRef(sl(function(t,n){const{__scopeTabs:r,value:i,forceMount:l,children:o,...a}=t,c=cm(HP,r),u=um(c.baseId,i),p=dm(c.baseId,i),d=i===c.value,h=f.useRef(d);return f.useEffect(()=>{const x=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(pr,{present:l||d,children:({present:x})=>s.jsx(Qe.div,{"data-state":d?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:p,tabIndex:0,...a,ref:n,style:{...t.style,animationDuration:h.current?"0s":void 0},children:x&&o})})},"TabsContent"));function um(e,t){return`${e}-trigger-${t}`}sl(um,"makeTriggerId");function dm(e,t){return`${e}-content-${t}`}sl(dm,"makeContentId");var GP=UP,YP=zP,qP=VP,QP=KP;function Ie(e,t){if(!e)return"—";const n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function Ce(e,t=Date.now()){if(!e)return"";const n=new Date(e).getTime();if(Number.isNaN(n))return"";const r=Math.round((n-t)/1e3),i=Math.abs(r),[l,o]=i<60?[r,"second"]:i<3600?[Math.round(r/60),"minute"]:i<86400?[Math.round(r/3600),"hour"]:[Math.round(r/86400),"day"];return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(l,o)}function JP(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 Dt(e){return new Intl.NumberFormat("en-US").format(e)}function ln(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function lo(e,t=8){return e.length<=t?e:e.slice(0,t)}function Es(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Li(e){return e.replace(/<<<[^<>]*>>>/g,"")}function yt(e,t,n){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?XP(r,n):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${lv(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Dt(r):lv(r):String(e)}case"date":return ZP(String(e));default:return typeof e=="string"?e:typeof e=="number"?Dt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function XP(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return JP(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function ZP(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short",year:"numeric"}).format(n)}function iv(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short"}).format(n)}function lv(e){return String(Math.round(e*100)/100)}function e2(e,t,n=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,n),i=10**Math.floor(Math.log10(r)),l=[1,2,2.5,5,10].map(a=>a*i).find(a=>a>=r)??i*10,o=[];for(let a=Math.ceil(e/l)*l;a<=t+l/1e3;a+=l)o.push(Math.round(a*1e6)/1e6);return o.filter(a=>a>=e&&a<=t)}function t2({props:e}){if(e.bars.length===0)return s.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(l=>l.value),n=Math.max(0,...t),r=Math.min(0,...t),i=n-r||1;return s.jsx("div",{className:"wb-bars",children:e.bars.map(l=>{const o=Math.abs(l.value)/i;return s.jsxs("div",{className:"wb-bar-row",children:[s.jsx("div",{className:"wb-bar-cat",title:l.category,children:l.category}),s.jsx("div",{className:"wb-bar-track",children:s.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,o*100)}%`,background:l.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),s.jsx("div",{className:"wb-bar-val",children:yt(l.value,e.unit,e.currency)})]},l.category)})})}const n2=/^(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 )/,s2=/^(… |\.\.\. |\(no change\)$|\)/;function r2(e){return e.replace(/\n$/,"").split(`
81
- `).map(n=>({kind:i2(n),text:n}))}function i2(e){return e.startsWith("@@")?"hunk":n2.test(e)||s2.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function l2({text:e,marks:t}){const n=e.toLowerCase(),r=[];for(const o of t){const a=o.trim().toLowerCase();if(a!=="")for(let c=n.indexOf(a);c!==-1;c=n.indexOf(a,c+a.length))r.push([c,c+a.length])}if(r.length===0)return s.jsx(s.Fragment,{children:e===""?" ":e});r.sort((o,a)=>o[0]-a[0]);const i=[];let l=0;for(const[o,a]of r)o<l||(o>l&&i.push(s.jsx("span",{children:e.slice(l,o)},`t${l}`)),i.push(s.jsx("mark",{className:"wb-diff-mark",children:e.slice(o,a)},`m${o}`)),l=a);return l<e.length&&i.push(s.jsx("span",{children:e.slice(l)},`t${l}`)),s.jsx(s.Fragment,{children:i})}function Cc({text:e,limit:t,more:n,label:r="Diff",marks:i}){const l=r2(e),o=t===void 0?l:l.slice(0,t),a=l.length-o.length;return s.jsxs("div",{className:"wb-diff-wrap",children:[s.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:o.map((c,u)=>s.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?s.jsx(l2,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),a>0?s.jsxs("p",{className:"wb-diff-more",children:[a," more line",a===1?"":"s",n?s.jsxs(s.Fragment,{children:[" · ",s.jsx("button",{type:"button",className:"wb-diff-open",onClick:n.onClick,children:n.label})]}):null]}):null]})}function o2({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:yt(t.value,t.unit,null)})]},t.label))}):null,e.diff?s.jsx(Cc,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):s.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const Vt="#/",Fi="#/chat",et="#/agents",Ze="#/activity",Qt="#/settings",Lr="#/files",a2="#/welcome";function ov(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function ia(e,t={}){const n=new URLSearchParams;t.q&&n.set("q",t.q),t.origin&&n.set("origin",t.origin),t.family&&n.set("family",t.family);const r=n.toString();return`${Lr}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function c2(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[2]??""),r={};return n.get("q")&&(r.q=n.get("q")),n.get("origin")&&(r.origin=n.get("origin")),n.get("family")&&(r.family=n.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function Fe(e,t,n){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function u2(e){if(S0(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...n?{tab:n}:{}}}catch{return null}}function Dl(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function S0(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 ht(e,t,n){return`${et}/${encodeURIComponent(e)}${t?`/${t}${n?`/${n}`:""}`:""}`}function d2(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 Ui(e){return`${Ze}/conversations/${encodeURIComponent(e)}`}const f2="#/p";function oo(e,t,n){const r=`${f2}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return n?`${r}/${encodeURIComponent(n)}`:r}function fm(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 h2="p.";function hm(e,t){return`${Qt}/${encodeURIComponent(N0(e,t))}`}function p2(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const n=decodeURIComponent(t[1]);return{plugin:n,page:t[2]?decodeURIComponent(t[2]):n}}function N0(e,t){return`${h2}${e}${t===e?"":`.${t}`}`}function st(e){return e?`${Qt}/${e}`:Qt}function m2(e){return`${st("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function g2(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}const x2=[{route:Vt,label:"Home"},{route:Fi,label:"Chat"},{route:et,label:"Agents"},{route:Ze,label:"Activity"},{route:Lr,label:"Files"},{route:Qt,label:"Settings"}],v2=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],j2=[{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:"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 y2(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const av=st("backup");function w2(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return Ui(decodeURIComponent(t[1]));const n=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(n)try{return oo("email","mail",n[1]?decodeURIComponent(n[1]):null)}catch{return oo("email","mail")}return e==="#/settings/email"?hm("email","settings"):{"#/overview":Vt,"#/approvals":Vt,"#/events":`${Ze}/events`,"#/jobs":`${Ze}/jobs`,"#/conversations":Ze,"#/missions":`${et}?tab=missions`,"#/offers":`${et}?tab=offers`,"#/reminders":`${et}?tab=reminders`,"#/providers":st("accounts"),"#/browser":st("computer"),"#/sentinels":st("watchers"),"#/settings/sentinels":st("watchers")}[e]??null}function b2(e){if(e===""||e==="#"||e===Vt)return Vt;if(e.startsWith(Fi))return Fi;if(e.startsWith(et))return et;if(e.startsWith(Ze))return Ze;if(e.startsWith(Lr))return Lr;if(e.startsWith(Qt))return Qt;const t=fm(e);return t?oo(t.plugin,t.page):Vt}const pm="front-desk",mm=[{id:pm,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."}],C0=new Set(mm.map(e=>e.id)),cv=e=>C0.has(e);function uv(e,t){const n=t.filter(r=>!C0.has(r));return[...mm.filter(r=>e.has(r.id)).map(r=>r.id),...n.filter((r,i)=>n.indexOf(r)===i)]}function k2(e,t){return e.find(n=>(n.roles??[]).includes(t))}const dv=["coding","finance","mail","research","calendar","files","memory"],S2={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[pm]:"buddi"},N2=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function C2(e){const t=new Set(e.map(n=>n.split(".")[0]??n));for(const[n,r]of N2)if(r.some(i=>t.has(i)))return n;return t.size>0&&[...t].every(n=>n==="memory")?"memory":null}let rh=null;function E2(e){rh=e}function wo(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const n of e.roles??[]){const r=S2[n];if(r)return{key:r}}const t=C2(e.tools??[]);return t?{key:t}:rh!==null&&e.id===rh?{key:"buddi"}:{key:dv[A2(e.id)%dv.length]??"coding"}}function bo(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function A2(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t}const R2=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function T2(e){const n=e.replace(/\r\n/g,`
82
- `).split(`
83
-
84
- `),r=n.pop()??"",i=[];for(const l of n){let o=null,a="message";const c=[];for(const u of l.split(`
85
- `)){if(u===""||u.startsWith(":"))continue;const p=u.indexOf(":"),d=p===-1?u:u.slice(0,p),h=p===-1?"":u.slice(p+1).replace(/^ /,"");d==="id"?o=h:d==="event"?a=h:d==="data"&&c.push(h)}c.length===0&&a==="message"||i.push({id:o,name:R2.includes(a)?a:"ping",data:P2(c.join(`
86
- `))})}return{events:i,rest:r}}function P2(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function E0(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),n=e.wait??(c=>new Promise(u=>setTimeout(u,c))),r=e.retryMs??1500;let i=e.lastEventId??null,l=!1,o=null;return(async()=>{var c,u,p,d;for(;!l;){(c=e.onStatus)==null||c.call(e,"connecting"),o=new AbortController;try{const h=await t(e.url,{credentials:"same-origin",signal:o.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!h.ok||!h.body)throw new Error(`stream ${h.status}`);(u=e.onStatus)==null||u.call(e,"open");const x=h.body.getReader(),v=new TextDecoder;let w="";for(;;){const{done:b,value:j}=await x.read();if(b)break;w+=v.decode(j,{stream:!0});const{events:g,rest:y}=T2(w);w=y;for(const m of g)e.onEvent(m),m.id!==null&&(i=m.id);if(l)break}}catch{}if(l)break;(p=e.onStatus)==null||p.call(e,"closed"),await n(r)}(d=e.onStatus)==null||d.call(e,"closed")})(),{close:()=>{l=!0,o==null||o.abort()},lastEventId:()=>i}}const I2="/api/chat/attention/stream";function A0(e,t){const n=(l,o)=>l.name.localeCompare(o.name),r=l=>e.filter(o=>o.anchor===l).sort(n),i=e.filter(l=>l.anchor!=="top"&&l.anchor!=="bottom").sort((l,o)=>l.id===t?o.id===t?0:-1:o.id===t?1:n(l,o));return{top:r("top"),middle:i,bottom:r("bottom")}}function R0(e,t){const n=A0(e,t);return[...n.top,...n.middle,...n.bottom]}function fu(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 M2(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function $2(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function _2(){const[e,t]=f.useState(null);return f.useEffect(()=>{let n=!1;const r=()=>{ae("/chat/attention").then(l=>{n||t(l)}).catch(()=>{})};r();const i=E0({url:I2,onEvent:()=>r()});return()=>{n=!0,i.close()}},[]),$2(e)}const gm="maker";function T0(e){return e.filter(t=>t.available&&!t.roles.includes(gm))}function P0(e){return T0(e).length>=2}function O2(e){var t;return((t=e.find(n=>n.roles.includes(gm)))==null?void 0:t.name)??"the agent maker"}const D2="{{default}}";function L2(e,t){return e.split(D2).join(t??"your assistant")}function F2(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(n=>L2(n,t))}function U2(e){var n,r;const t=(n=e==null?void 0:e.intro)==null?void 0:n.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function B2(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 I0(e){var r,i;const t=(r=e.heldBack)==null?void 0:r.message.trim();if(t!==void 0&&t!=="")return`${e.name??"This agent"} is held back. ${t}`;const n=(i=e.unavailableReason)==null?void 0:i.trim();return n&&n!==""?`${e.name??"This agent"} cannot run: ${n}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const z2="Settings → Model accounts",W2="Install it in Settings → Plugins";function ih(e){return e!=null&&e.heldBack?{section:"plugins",label:W2}:{section:"accounts",label:z2}}const V2={home:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),s.jsx("path",{d:"M5.2 8.4v7.4a1 1 0 0 0 1 1h2.6v-4.6h2.4v4.6h2.6a1 1 0 0 0 1-1V8.4"})]})],chat:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 10.6a4.9 4.9 0 0 1-4.9 4.9H7.8L3.6 18l.9-3A4.9 4.9 0 0 1 3 11V8.2A4.9 4.9 0 0 1 7.9 3.3h4.2A4.9 4.9 0 0 1 17 8.2Z"}),s.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),s.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),s.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),s.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,s.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[24,1.9,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),20],files:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 2.8h5.2L16.5 6.6v8.6a1.2 1.2 0 0 1-1.2 1.2H7.5a1.2 1.2 0 0 1-1.2-1.2V4a1.2 1.2 0 0 1 1.2-1.2z"}),s.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),s.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),s.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),s.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),s.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,s.jsx("path",{d:"M3.2 16.4V8.6M8.4 16.4V3.9M13.6 16.4v-5.8M3.2 16.4h13.6"})],bell:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),s.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),s.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),s.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),s.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),s.jsx("path",{d:"M2.9 10h14.2M10 2.9c3.4 3.7 3.4 10.5 0 14.2-3.4-3.7-3.4-10.5 0-14.2Z"})]})],person:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),s.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],sun:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),s.jsx("path",{d:"M10 2.6v1.6M10 15.8v1.6M2.6 10h1.6M15.8 10h1.6M4.8 4.8l1.1 1.1M14.1 14.1l1.1 1.1M4.8 15.2l1.1-1.1M14.1 5.9l1.1-1.1"})]})],notebook:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.5 3.2h8.3a1 1 0 0 1 1 1v11.6a1 1 0 0 1-1 1H5.5a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1Z"}),s.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),s.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),s.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],eye:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.4 10S5.2 4.8 10 4.8 17.6 10 17.6 10 14.8 15.2 10 15.2 2.4 10 2.4 10Z"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),s.jsx("path",{d:"M4 7.2v8a1.2 1.2 0 0 0 1.2 1.2h9.6a1.2 1.2 0 0 0 1.2-1.2v-8M8.2 10.4h3.6"})]})],chip:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),s.jsx("path",{d:"M8 2.8v2.6M12 2.8v2.6M8 14.6v2.6M12 14.6v2.6M2.8 8h2.6M2.8 12h2.6M14.6 8h2.6M14.6 12h2.6"})]})],camera:[17,1.5,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("circle",{cx:"8.5",cy:"9.2",r:"2.4"})]})],clip:[17,1.5,s.jsx("path",{d:"M13.2 8 8.4 12.8a3 3 0 0 1-4.2-4.2l5.1-5.1a2 2 0 1 1 2.8 2.8l-5 5"})],send:[16,1.8,s.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],thought:[13,1.4,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),s.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,s.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],out:[12,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),s.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,s.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,s.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,s.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],"chevron-down":[14,1.4,s.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),s.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),s.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,s.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,s.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,s.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,s.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-document":[16,1.4,s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,s.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 11l3.6-3.4 2.6 2.4 2-1.8 3.4 3M10.6 6.2h.01"})],"shape-preview":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 6h11.6M4.1 4.7h.01M6 4.7h.01"})],"shape-envelope":[16,1.4,s.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],"shape-structured":[16,1.4,s.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function Oe({name:e,size:t,className:n,...r}){const[i,l,o,a]=V2[e],c=t??a??i;return s.jsx("svg",{className:n,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:l,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:o})}const M0="buddi.rosterCollapsed";function H2(){try{return window.localStorage.getItem(M0)==="1"}catch{return!1}}function K2(e){try{window.localStorage.setItem(M0,e?"1":"0")}catch{}}function $0({agents:e,currentId:t,attention:n,onSelect:r,orientation:i="vertical",lastActivity:l,groups:o=[],currentGroupId:a=null,onSelectGroup:c,onNewGroup:u}){const p=[...e.top,...e.middle,...e.bottom],d=i==="vertical"?"right":"bottom",[h,x]=f.useState(H2),v=w=>s.jsx(G2,{agent:w,active:w.id===t,attention:n.get(w.id),side:d,onSelect:r,lastAt:(l==null?void 0:l.get(w.id))??null},w.id);return s.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&h?"true":void 0,children:[e.top.map(v),e.top.length>0&&e.middle.length>0?s.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!h&&e.middle.length>0?s.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,s.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(v),c&&P0(p)?s.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[s.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),s.jsxs("div",{className:"wb-groups-head",children:[s.jsx("span",{className:"wb-groups-label",children:"Groups"}),u?s.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"New group",title:"A team of agents in one conversation",onClick:u,children:s.jsx(Oe,{name:"plus"})}):null]}),o.map(w=>s.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":w.id===a?"true":void 0,"aria-current":w.id===a?"true":void 0,"aria-label":`${w.name}, ${w.members.length} agents`,onClick:()=>c(w.id),children:[s.jsxs("span",{className:"wb-face-mark wb-group-stack","aria-hidden":"true",children:[w.members.slice(0,3).map(b=>{const j=p.find(g=>g.id===b);return s.jsx(xm,{className:"wb-group-chip",id:b,name:(j==null?void 0:j.name)??"?",face:j,initials:1},b)}),w.members.length>3?s.jsxs("span",{className:"wb-group-chip wb-group-more",children:["+",w.members.length-3]}):null]}),s.jsxs("span",{className:"wb-face-text",children:[s.jsx("span",{className:"wb-face-name",children:w.name}),s.jsx("span",{className:"wb-face-status",children:w.members.map(b=>{var j;return((j=p.find(g=>g.id===b))==null?void 0:j.name)??b}).join(", ")})]})]},w.id))]}):null]}),e.bottom.map(v),i==="vertical"?s.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":h?"Show agent names":"Hide agent names","aria-pressed":h,onClick:()=>x(w=>(K2(!w),!w)),children:s.jsx(Oe,{name:h?"chevron-right":"chevron-left"})}):null]})}function G2({agent:e,active:t,attention:n,side:r,onSelect:i,lastAt:l=null}){const o=fu(n),a=o?fv(o):e.available?l?`Last spoke ${Ce(l)}`:e.description:e.unavailableReason??"Cannot run right now",c=M2(n),u=e.unavailableReason??"This agent cannot run on this machine right now.",p=[e.name,e.available?null:"unavailable",o,t?"current":null].filter(d=>d!==null&&d!=="").join(" — ");return s.jsxs(yc,{children:[s.jsx(wc,{asChild:!0,children:s.jsxs("button",{className:"wb-face",...bo(wo(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":p,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[s.jsx(xm,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),s.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[s.jsxs("span",{className:"wb-face-name",children:[e.name,s.jsxs("span",{className:"wb-face-handle",children:["@",e.handle]})]}),s.jsx("span",{className:"wb-face-status","data-tone":o?"critical":void 0,children:a})]}),c?s.jsx("span",{className:"wb-face-badge","data-kind":c.count===null?"dot":"count","data-testid":`agent-badge-${e.id}`,"aria-hidden":"true",children:c.count===null?"":c.count}):null,e.available?null:s.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:s.jsx(Oe,{name:"out"})})]})}),s.jsx(bc,{children:s.jsxs(kc,{className:"ui-tip",side:r,sideOffset:8,children:[s.jsx("span",{className:"ui-tip-title",children:e.name}),s.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:u}),o?s.jsx("span",{className:"ui-tip-alert",children:fv(o)}):null]})})]})}function fv(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function Y2(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t%6+1}function xm({className:e,id:t,name:n,face:r,tint:i,size:l,unavailable:o,initials:a=2}){const[c,u]=f.useState(null),p=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,d=r==null?void 0:r.avatar,h=p?"image":d==null?void 0:d.kind,x=t?bo(wo({id:t,accent:r==null?void 0:r.accent,roles:r==null?void 0:r.roles,tools:r==null?void 0:r.tools})):void 0;return s.jsx("span",{className:e,"data-tint":x?void 0:i,"data-size":l,"data-kind":h,"data-unavailable":o?"true":void 0,...x,"aria-hidden":"true",children:p?s.jsx("img",{src:p,alt:"",onError:()=>u(p)}):(d==null?void 0:d.kind)==="image"?s.jsx("img",{src:d.url,alt:""}):(d==null?void 0:d.kind)==="emoji"?d.value:B2(n).slice(0,a)})}function os({id:e,name:t,size:n,unavailable:r,face:i}){return s.jsx(xm,{className:"ui-avatar",id:e,tint:Y2(e),name:t,size:n,unavailable:r,face:i})}function Xt({agents:e,id:t,size:n}){const r=e.find(i=>i.id===t);return s.jsx(os,{id:t,name:(r==null?void 0:r.name)??t,size:n,unavailable:r?!r.available:!1,face:r})}const _0=f.createContext(null);function q2({picture:e,children:t}){return s.jsx(_0.Provider,{value:e??null,children:t})}function O0({size:e}){const t=f.useContext(_0),[n,r]=f.useState(null);return!t||t===n?null:s.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:s.jsx("img",{src:t,alt:"",onError:()=>r(t)})})}const D0=f.createContext([]);function cr({text:e,className:t}){const n=lh(e.replace(/\r\n/g,`
87
- `).split(`
88
- `));return s.jsx("div",{className:t??"wb-md",children:n.map((r,i)=>s.jsx(oh,{block:r},i))})}const hv=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,pv=/^(#{1,6})\s+(.*?)\s*#*\s*$/,mv=/^\s*([-*_])(\s*\1){2,}\s*$/,la=/^(\s*)([-*+])\s+(.*)$/,yl=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,oa=/^\s*>\s?(.*)$/,md=/^\s*\|.*\|\s*$/,gv=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function lh(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r.trim()===""){n+=1;continue}const i=hv.exec(r);if(i){const a=i[2],c=[];for(n+=1;n<e.length&&!new RegExp(`^\\s*${a}\\s*$`).test(e[n]);)c.push(e[n]),n+=1;n+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
89
- `)});continue}const l=pv.exec(r);if(l){t.push({type:"h",level:l[1].length,text:l[2]}),n+=1;continue}if(mv.test(r)){t.push({type:"hr"}),n+=1;continue}if(oa.test(r)){const a=[];for(;n<e.length&&oa.test(e[n]);)a.push(oa.exec(e[n])[1]),n+=1;t.push({type:"quote",blocks:lh(a),raw:a.join(`
90
- `)});continue}if(md.test(r)&&n+1<e.length&&gv.test(e[n+1])){const a=xd(r),c=xd(e[n+1]).map(p=>{const d=p.startsWith(":"),h=p.endsWith(":");return d&&h?"center":h?"right":d?"left":null});n+=2;const u=[];for(;n<e.length&&md.test(e[n]);)u.push(xd(e[n])),n+=1;t.push({type:"table",head:a,rows:u,align:c});continue}if(la.test(r)||yl.test(r)){const a=yl.exec(r)??la.exec(r),c=yl.test(r),u=a[1].length,p=c?Number(a[2]):1,d=[];for(;n<e.length;){const h=c?yl.exec(e[n]):la.exec(e[n]);if(!h||h[1].length!==u)break;const x=[h[3]];for(n+=1;n<e.length;){const v=e[n],w=v.trim()!==""&&gd(v)>u,b=v.trim()===""&&n+1<e.length&&e[n+1].trim()!==""&&gd(e[n+1])>u;if(!w&&!b)break;x.push(v.trim()===""?"":v.slice(Math.min(gd(v),u+2))),n+=1}d.push(lh(x))}t.push({type:"list",ordered:c,start:p,items:d});continue}const o=[];for(;n<e.length;){const a=e[n];if(a.trim()===""||hv.test(a)||pv.test(a)||mv.test(a)||oa.test(a)||la.test(a)||yl.test(a)||md.test(a)&&n+1<e.length&&gv.test(e[n+1]))break;o.push(a.trim()),n+=1}o.length>0&&t.push({type:"p",text:o.join(`
91
- `)})}return t}function gd(e){return e.length-e.trimStart().length}function xd(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="";for(let i=0;i<t.length;i+=1){const l=t[i];if(l==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(l==="|"){n.push(r.trim()),r="";continue}r+=l}return n.push(r.trim()),n}function oh({block:e}){switch(e.type){case"p":return s.jsx("p",{children:On(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),n=`h${Math.min(t+2,6)}`;return s.jsx(n,{className:"wb-md-h","data-level":t,children:On(e.text)})}case"code":return s.jsxs("div",{className:"wb-md-code-frame",children:[s.jsxs("div",{className:"wb-md-code-head",children:[s.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),s.jsx(xv,{text:e.text,what:"code",always:!0})]}),s.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:s.jsx("code",{children:e.text})})]});case"quote":return s.jsxs("div",{className:"wb-md-copyable",children:[s.jsx("blockquote",{children:e.blocks.map((t,n)=>s.jsx(oh,{block:t},n))}),s.jsx(xv,{text:e.raw,what:"quote"})]});case"hr":return s.jsx("hr",{});case"list":{const t=e.items.map((n,r)=>s.jsx("li",{children:n.map((i,l)=>i.type==="p"?s.jsx(f.Fragment,{children:On(i.text)},l):s.jsx(oh,{block:i},l))},r));return e.ordered?s.jsx("ol",{start:e.start,children:t}):s.jsx("ul",{children:t})}case"table":return s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table wb-md-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.head.map((t,n)=>s.jsx("th",{style:e.align[n]?{textAlign:e.align[n]}:void 0,children:On(t)},n))})}),s.jsx("tbody",{children:e.rows.map((t,n)=>s.jsx("tr",{children:t.map((r,i)=>s.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:On(r)},i))},n))})]})})}}function xv({text:e,what:t,always:n=!1}){const[r,i]=f.useState("idle"),l=()=>{var o;if(!((o=navigator.clipboard)!=null&&o.writeText)){i("failed");return}navigator.clipboard.writeText(e).then(()=>i("done"),()=>i("failed")),window.setTimeout(()=>i("idle"),1500)};return s.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":n||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:l,children:r==="done"?"Copied":r==="failed"?"Select to copy":s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),s.jsx("path",{d:"M8.5 4.5V3a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4.5a1 1 0 0 0 1 1h1.5"})]})})}function Q2({handle:e}){const n=f.useContext(D0).find(r=>r.handle.toLowerCase()===e.toLowerCase());return n?s.jsxs(yc,{children:[s.jsx(wc,{asChild:!0,children:s.jsxs("a",{className:"wb-mention-link",href:Fe(n.id),children:["@",n.handle]})}),s.jsx(bc,{children:s.jsxs(kc,{className:"wb-agent-card",sideOffset:6,children:[s.jsx(os,{id:n.id,name:n.name,face:n,unavailable:!n.available}),s.jsxs("span",{className:"wb-agent-card-text",children:[s.jsx("span",{className:"wb-agent-card-name",children:n.name}),s.jsx("span",{className:"wb-agent-card-desc",children:n.description}),s.jsxs("span",{className:"wb-agent-card-meta",children:[n.model,n.available?"":" · unavailable"]})]})]})})]}):s.jsxs(s.Fragment,{children:["@",e]})}const J2=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 On(e){const t=[];let n=e,r=0;for(;n!=="";){const i=J2.exec(n);if(!i){t.push(...vv(n,r));break}i.index>0&&t.push(...vv(n.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(s.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(s.jsx("strong",{children:On(i[3])},r)):i[4]!==void 0?t.push(s.jsx("strong",{children:On(i[4])},r)):i[5]!==void 0?t.push(s.jsx("s",{children:On(i[5])},r)):i[6]!==void 0?t.push(s.jsx("em",{children:On(i[6])},r)):i[7]!==void 0?t.push(s.jsx("em",{children:On(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(s.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:On(i[8])},r)):i[10]!==void 0?t.push(s.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(s.jsx(Q2,{handle:i[11]},r)),n=n.slice(i.index+i[0].length)}return t}function vv(e,t){return e.split(`
92
- `).flatMap((r,i)=>i===0?[r]:[s.jsx("br",{},`${t}-br-${i}`),r])}function X2({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:yt(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?s.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?s.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:s.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?s.jsx("div",{className:"wb-doc",children:s.jsx(cr,{text:e.text})}):s.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}function ge(e,t){if(t===""||t==="$")return e;let n=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,l="",o=""]=i;if(l!==""){if(n===null||typeof n!="object")return;n=n[l]}for(const a of o.match(/\d+/g)??[]){if(!Array.isArray(n))return;n=n[Number(a)]}if(n===void 0)return}return n}function Se(e,t){if(t)return"const"in t?t.const:ge(e,t.path)}function sr(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 We(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Rr(e){return Array.isArray(e)?e:[]}function Z2(e,t){const n=Rr(ge(e,t.points)).map(i=>{const l=sr(ge(i,t.y)),o=We(ge(i,t.x));return l===null||o===null?null:{x:o,y:l}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const l=sr(Se(e,i.value));return l===null?null:{value:l,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:n,unit:t.unit??"number",currency:We(Se(e,t.currency)),label:We(Se(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:sr(Se(e,t.shadeBelow)),events:eI(e,t)}}function eI(e,t){const n=t.events;if(!n)return[];const r=[],i=(l,o)=>{const a=We(ge(l,n.label));if(a===null)return;const c=We(ge(l,n.at))??o;c!==null&&r.push({at:c,label:a,amount:n.amount?sr(ge(l,n.amount)):null})};if(n.parent){for(const l of Rr(ge(e,t.points))){const o=We(ge(l,t.x));for(const a of Rr(ge(l,n.parent)))i(a,o)}return r}for(const l of Rr(ge(e,n.path??t.points)))i(l,null);return r}function tI(e,t){const n=(t.columns??[]).map(a=>({key:a.key,label:a.label,type:a.type??"text"})),r=a=>(t.columns??[]).map(c=>{const u=ge(a,c.key);let p=null;if(c.bar){const d=sr(Se(a,c.bar.max))??sr(Se(e,c.bar.max)),h=sr(u);if(d!==null&&d>0&&h!==null){const x=Math.max(0,Math.min(1,h/d));p={fraction:x,tone:sI(x*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:We(Se(a,c.currency))??We(Se(e,c.currency)),bar:p}}),i=Rr(ge(e,t.rows)),l=t.groupBy?nI(i,t.groupBy,r):[{label:null,rows:i.map(r)}],o=(t.summary??[]).map(a=>({label:a.label,value:Se(e,a.value),unit:a.unit??"text",currency:We(Se(e,a.currency)),tone:a.tone??"neutral"}));return{columns:n,groups:l,summary:o,empty:t.empty??"Nothing to show."}}function nI(e,t,n){const r=new Map;for(const i of e){const l=String(ge(i,t.key)??""),o=r.get(l);o?o.push(i):r.set(l,[i])}return[...r.entries()].map(([i,l])=>{var o;return{label:((o=t.labels)==null?void 0:o[i])??i,rows:l.map(n)}})}function sI(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,l)=>l.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function rI(e,t){return{bars:Rr(ge(e,t.bars)).map(r=>{const i=sr(ge(r,t.value)),l=We(ge(r,t.category));return i===null||l===null?null:{category:l,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:We(Se(e,t.currency))}}function iI(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:Se(e,r.value),unit:r.unit??"text",currency:We(Se(e,r.currency)),tone:r.tone??"neutral"}))};const n=ge(e,t.from??"$");return n===null||typeof n!="object"||Array.isArray(n)?{pairs:[]}:{pairs:Object.entries(n).map(([r,i])=>({label:zt(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}function lI(e,t){const n=We(Se(e,t.kind)),r=n==="image"||n==="pdf"?n:"text",i=t.src?We(ge(e,t.src)):null;return{kind:r,text:t.text?We(ge(e,t.text)):null,src:i&&F0(i)?i:null,title:We(Se(e,t.title)),metadata:(t.metadata??[]).map(l=>({label:l.label,value:Se(e,l.value),unit:l.unit??"text"}))}}function oI(e,t){const n=t.diff?ge(e,t.diff):void 0;return{diff:typeof n=="string"&&n.trim()!==""?n:null,title:We(Se(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:Se(e,r.value),unit:r.unit??"text"}))}}function aI(e,t){const n=t.output?ge(e,t.output):void 0,r=o=>{const a=o?ge(e,o):void 0;return typeof a=="number"&&Number.isInteger(a)?a:null},i=r(t.omittedBytes),l=t.elapsedMs?ge(e,t.elapsedMs):void 0;return{command:We(Se(e,t.command)),output:typeof n=="string"?n:null,exitCode:r(t.exitCode),elapsedMs:typeof l=="number"&&Number.isFinite(l)&&l>=0?l:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(o=>({label:o.label,value:Se(e,o.value),unit:o.unit??"text"}))}}const cI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function L0(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&cI.test(t)?t.toLowerCase():null}function uI(e,t){return{artifactId:t.src?L0(ge(e,t.src)):null,title:We(Se(e,t.title)),caption:We(Se(e,t.caption)),...t.captionLabel?{captionLabel:We(Se(e,t.captionLabel))}:{}}}function jv(e){if(!F0(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const n=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return n?{plugin:n[1],name:n[2]}:null}function dI(e,t){const n=t.src?We(ge(e,t.src)):null,r=t.port?ge(e,t.port):null,i=t.awaiting?We(ge(e,t.awaiting)):null;return{target:n?jv(n):null,title:We(Se(e,t.title)),output:t.output?We(ge(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?jv(i):null,reloadsItself:t.reloadsItself?ge(e,t.reloadsItself)===!0:!1,ports:t.ports?fI(ge(e,t.ports)):[]}}function fI(e){const t=Rr(e).filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>0&&n<=65535);return[...new Set(t)].sort((n,r)=>n-r)}function F0(e){return e.startsWith("/")&&!e.startsWith("//")}function zt(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 U0(e,t){const n=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:Z2(t,n)};case"table":return{renderer:"table",props:tI(t,n)};case"bars":return{renderer:"bars",props:rI(t,n)};case"keyvalue":return{renderer:"keyvalue",props:iI(t,n)};case"document":return{renderer:"document",props:lI(t,n)};case"diff":return{renderer:"diff",props:oI(t,n)};case"terminal":return{renderer:"terminal",props:aI(t,n)};case"image":return{renderer:"image",props:uI(t,n)};case"preview":return{renderer:"preview",props:dI(t,n)};default:return{renderer:"structured",props:{value:t}}}}var hI=Object.defineProperty,Vn=(e,t)=>hI(e,"name",{value:t,configurable:!0}),vm="Dialog",[B0,Q3]=zn(vm),[pI,Is]=B0(vm),mI=Vn(e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:l,modal:o=!0}=e,a=f.useRef(null),c=f.useRef(null),[u,p]=Zi({prop:r,defaultProp:i??!1,onChange:l,caller:vm}),[d,h]=f.useState(0),[x,v]=f.useState(0);return s.jsx(pI,{scope:t,triggerRef:a,contentRef:c,contentId:vs(),titleId:vs(),descriptionId:vs(),titlePresent:d>0,descriptionPresent:x>0,setTitleCount:h,setDescriptionCount:v,open:u,onOpenChange:p,onOpenToggle:f.useCallback(()=>p(w=>!w),[p]),modal:o,children:n})},"Dialog"),z0="DialogPortal",[gI,W0]=B0(z0,{forceMount:void 0}),xI=Vn(e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,l=Is(z0,t);return s.jsx(gI,{scope:t,forceMount:n,children:f.Children.map(r,o=>s.jsx(pr,{present:n||l.open,children:s.jsx(Fp,{asChild:!0,container:i,children:o})}))})},"DialogPortal"),ah="DialogOverlay",vI=f.forwardRef(Vn(function(t,n){const r=W0(ah,t.__scopeDialog),{forceMount:i=r.forceMount,...l}=t,o=Is(ah,t.__scopeDialog);return o.modal?s.jsx(pr,{present:i||o.open,children:s.jsx(yI,{...l,ref:n})}):null},"DialogOverlay")),jI=lr("DialogOverlay.RemoveScroll"),yI=f.forwardRef(Vn(function(t,n){const{__scopeDialog:r,...i}=t,l=Is(ah,r),o=Uw(),a=Ye(n,o);return s.jsx(Zp,{as:jI,allowPinchZoom:!0,shards:[l.contentRef],children:s.jsx(Qe.div,{"data-state":jm(l.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),ao="DialogContent",wI=f.forwardRef(Vn(function(t,n){const r=W0(ao,t.__scopeDialog),{forceMount:i=r.forceMount,...l}=t,o=Is(ao,t.__scopeDialog);return s.jsx(pr,{present:i||o.open,children:o.modal?s.jsx(bI,{...l,ref:n}):s.jsx(kI,{...l,ref:n})})},"DialogContent")),bI=f.forwardRef(Vn(function(t,n){const r=Is(ao,t.__scopeDialog),i=f.useRef(null),l=Ye(n,r.contentRef,i);return f.useEffect(()=>{const o=i.current;if(o)return Xb(o)},[]),s.jsx(V0,{...t,ref:l,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:je(t.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:je(t.onPointerDownOutside,o=>{const a=o.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&o.preventDefault()}),onFocusOutside:je(t.onFocusOutside,o=>o.preventDefault())})},"DialogContentModal")),kI=f.forwardRef(Vn(function(t,n){const r=Is(ao,t.__scopeDialog),i=f.useRef(!1),l=f.useRef(!1);return s.jsx(V0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,c;(a=t.onCloseAutoFocus)==null||a.call(t,o),o.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),o.preventDefault()),i.current=!1,l.current=!1},onInteractOutside:o=>{var u,p;(u=t.onInteractOutside)==null||u.call(t,o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const a=o.target;((p=r.triggerRef.current)==null?void 0:p.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&l.current&&o.preventDefault()}})},"DialogContentNonModal")),V0=f.forwardRef(Vn(function(t,n){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:l,onCloseAutoFocus:o,...a}=t,c=Is(ao,r);return ou(),s.jsx(s.Fragment,{children:s.jsx($b,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:l,onUnmountAutoFocus:o,children:s.jsx(Dp,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":jm(c.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),SI="DialogTitle",NI=f.forwardRef(Vn(function(t,n){const{__scopeDialog:r,...i}=t,l=Is(SI,r),{setTitleCount:o}=l;return nn(()=>(o(a=>a+1),()=>o(a=>a-1)),[o]),s.jsx(Qe.h2,{id:l.titleId,...i,ref:n})},"DialogTitle")),CI="DialogClose",EI=f.forwardRef(Vn(function(t,n){const{__scopeDialog:r,...i}=t,l=Is(CI,r);return s.jsx(Qe.button,{type:"button",...i,ref:n,onClick:je(t.onClick,()=>l.onOpenChange(!1))})},"DialogClose"));function jm(e){return e?"open":"closed"}Vn(jm,"getState");const AI=5;function se(e,t,n){const[r,i]=f.useState(void 0),[l,o]=f.useState(null),[a,c]=f.useState(!0),[u,p]=f.useState(0),[d,h]=f.useState(0),x=f.useRef(e);return x.current=e,f.useEffect(()=>{let v=!1;return c(!0),x.current().then(w=>{v||(i(w),o(null),h(0))}).catch(w=>{v||(o(w instanceof de?w.message:String(w)),h(b=>b+1))}).finally(()=>{v||c(!1)}),()=>{v=!0}},[...t,u]),f.useEffect(()=>{if(!n||d>=AI)return;const v=window.setTimeout(()=>p(w=>w+1),n*2**d);return()=>window.clearTimeout(v)},[n,d,u]),{data:r,error:l,loading:a,reload:()=>{h(0),p(v=>v+1)}}}function Yr(...e){return e.filter(Boolean).join(" ")}function P({variant:e,size:t,className:n,type:r="button",...i}){return s.jsx("button",{type:r,className:Yr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function Bn({variant:e,size:t,className:n,...r}){return s.jsx("a",{className:Yr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function J({children:e,align:t,valign:n,className:r}){return s.jsx("div",{className:Yr("ui-toolbar",r),"data-align":t,"data-valign":n,children:e})}function rl(){return s.jsx("span",{className:"ui-toolbar-spacer"})}function te({label:e,hint:t,inline:n,grow:r,wide:i,children:l}){return s.jsxs("div",{className:"ui-field","data-inline":n?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[s.jsxs("label",{className:"ui-field-control",children:[s.jsx("span",{className:"ui-field-label",children:e}),l]}),t?s.jsx("span",{className:"ui-field-hint",children:t}):null]})}function As({children:e,dense:t}){return s.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,children:e})}function pe({tone:e,mono:t,dot:n,children:r,className:i,title:l}){return s.jsxs("span",{className:Yr("ui-pill",t&&"mono",i),"data-tone":e,title:l,children:[n?s.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function Ua({children:e}){return s.jsx("span",{className:"ui-tag",children:e})}function hu({state:e}){const t=e==="succeeded"||e==="approved"||e==="fired"||e==="running"||e==="leased"?"good":e==="failed"||e==="rejected"||e==="unknown"||e==="error"||e==="refused"?"critical":e==="pending"||e==="suspended"||e==="expired"||e==="paused"?"warning":void 0;return s.jsx(pe,{tone:t,children:e})}function K({tone:e,title:t,children:n,role:r}){return s.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?s.jsx("div",{className:"ui-notice-title",children:t}):null,n]})}function re({message:e}){return e?s.jsx(K,{tone:"critical",role:"alert",children:e}):null}function le({mascot:e,warm:t,title:n,action:r,children:i}){return t||n?s.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[n?s.jsx("div",{className:"ui-empty-title",children:n}):null,s.jsx("div",{children:i}),r]}):e?s.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[s.jsx(O0,{size:"sm"}),s.jsx("p",{children:i})]}):s.jsx("p",{className:"ui-empty",children:i})}function wt({icon:e,title:t,action:n,children:r}){return s.jsxs("div",{className:"ui-empty-state",children:[e?s.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?s.jsx(Oe,{name:e}):e}):null,s.jsx("div",{className:"ui-empty-state-title",children:t}),r?s.jsx("p",{className:"ui-empty-state-line",children:r}):null,n?s.jsx("div",{className:"ui-empty-state-action",children:n}):null]})}function RI({children:e}){return s.jsx("div",{className:"ui-page",children:e})}function ym({title:e,lede:t,actions:n,before:r}){return s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[r,s.jsx("span",{children:e})]}),n?s.jsx("div",{className:"ui-page-actions",children:n}):null]}),t?s.jsx("p",{className:"ui-page-lede",children:t}):null]})}function an({embedded:e,title:t,lede:n,actions:r,children:i}){return e?s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):s.jsxs(RI,{children:[s.jsx(ym,{title:t,lede:n,actions:r}),i]})}function Y({title:e,aside:t,actions:n,panel:r,flush:i,foot:l,children:o}){const a=e||t||n?s.jsxs("div",{className:"ui-section-head",children:[e?s.jsx("h3",{className:"ui-section-title",children:e}):s.jsx("span",{}),t||n?s.jsxs("div",{className:"ui-section-side",children:[t?s.jsx("span",{className:"ui-section-aside",children:t}):null,n?s.jsx("div",{className:"ui-section-actions",children:n}):null]}):null]}):null;return s.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[a,r?s.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[o,l?s.jsx("div",{className:"ui-panel-foot",children:l}):null]}):s.jsxs(s.Fragment,{children:[o,l?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:l}):null]})]})}function rt({title:e,tool:t,actions:n,flush:r,children:i}){return s.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||n?s.jsxs("header",{className:"ui-panel-head",children:[e?s.jsx("h3",{className:"ui-panel-title",children:e}):s.jsx("span",{}),t?s.jsx("span",{className:"ui-panel-tool",children:t}):null,n?s.jsx("div",{className:"ui-panel-actions",children:n}):null]}):null,i]})}function Fr({tone:e,title:t,meta:n,actions:r,children:i,foot:l,as:o="div"}){return s.jsxs(o,{className:"ui-card","data-tone":e,children:[t||n||r?s.jsxs("div",{className:"ui-card-head",children:[t?s.jsx("h3",{className:"ui-card-title",children:t}):null,n,r?s.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,l?s.jsx("div",{className:"ui-card-foot",children:l}):null]})}function G({gap:e,divided:t,children:n}){return s.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:n})}function TI({children:e}){return s.jsx("div",{className:"ui-row",children:e})}function pu({inline:e,children:t}){return s.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function Xn({label:e,value:t,note:n,tone:r,size:i}){return s.jsxs("div",{className:"ui-stat",children:[s.jsx("div",{className:"ui-stat-k",children:e}),s.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),n?s.jsx("div",{className:"ui-stat-n",children:n}):null]})}function At({items:e}){return s.jsx("dl",{className:"ui-kv",children:e.map((t,n)=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:t.value})]},t.key??n))})}function on({children:e}){return s.jsx("div",{className:"ui-table-wrap",children:s.jsx("table",{className:"ui-table",children:e})})}function PI({value:e,label:t}){const n=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return s.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-valuetext":`${n}%`,children:s.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${n}%`}})})}function ut({children:e,label:t}){return s.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function bt({summary:e,boxed:t,open:n,className:r,onToggle:i,children:l}){return s.jsxs("details",{className:Yr("ui-details",r),"data-boxed":t?"true":void 0,open:n,onToggle:i?o=>i(o.currentTarget.open):void 0,children:[s.jsx("summary",{children:e}),l]})}function Yt({title:e,onClose:t,size:n,children:r}){return s.jsx(mI,{open:!0,onOpenChange:i=>{i||t()},children:s.jsxs(xI,{children:[s.jsx(vI,{className:"ui-sheet-overlay"}),s.jsxs(wI,{className:"ui-sheet","data-size":n,"aria-describedby":void 0,children:[s.jsxs("div",{className:"ui-sheet-head",children:[s.jsx(NI,{className:"ui-sheet-title",children:e}),s.jsx(EI,{asChild:!0,children:s.jsx(P,{size:"sm",children:"Close"})})]}),r]})]})})}function mu({level:e,label:t,children:n}){return s.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:n})}function gu({href:e,active:t,count:n,onClick:r,children:i}){return s.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,n?s.jsx("span",{className:"ui-count",children:n}):null]})}function Ba({label:e,options:t,value:n,onChange:r}){return s.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>s.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===n,onClick:()=>r(i.value),children:i.label},i.value))})}function Ht({children:e}){return s.jsx("div",{className:"ui-list",children:e})}function rn({href:e,onClick:t,lead:n,title:r,sub:i,side:l}){const o=s.jsxs(s.Fragment,{children:[n,s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:r}),i?s.jsx("span",{className:"ui-list-sub",children:i}):null]}),l?s.jsx("span",{className:"ui-list-side",children:l}):null]});return e?s.jsx("a",{className:"ui-list-row",href:e,onClick:t?a=>{a.preventDefault(),t()}:void 0,children:o}):s.jsx("div",{className:"ui-list-row",children:o})}function H0({href:e,onClick:t,current:n,lead:r,title:i,meta:l,sub:o,snippet:a,side:c}){return s.jsxs("a",{className:"ui-pick",href:e,"aria-current":n?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?s.jsx("span",{className:"ui-pick-lead",children:r}):null,s.jsxs("span",{className:"ui-pick-main",children:[s.jsxs("span",{className:"ui-pick-top",children:[s.jsx("span",{className:"ui-pick-title",children:i}),l?s.jsx("span",{className:"ui-pick-meta",children:l}):null]}),o||c?s.jsxs("span",{className:"ui-pick-line",children:[o?s.jsx("span",{className:"ui-pick-sub",children:o}):null,c?s.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,a?s.jsx("span",{className:"ui-pick-snippet",children:a}):null]})]})}function K0({list:e,detail:t,empty:n,label:r,className:i}){return s.jsxs("div",{className:Yr("ui-split",i),"data-open":t?"true":void 0,children:[s.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),s.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??s.jsx("p",{className:"ui-empty ui-split-empty",children:n})})]})}function ch({children:e,onRemove:t,label:n}){return s.jsxs("span",{className:"ui-chip",children:[e,s.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${n}`,onClick:t,children:"×"})]})}function G0({main:e,filters:t,filtersOpen:n,onToggleFilters:r,active:i,chips:l,actions:o,onSubmit:a,label:c}){return s.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),a()},children:[s.jsxs("div",{className:"ui-searchbar-row",children:[e?s.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?s.jsxs(P,{"aria-expanded":n===!0,"aria-pressed":n===!0,onClick:r,children:["Filters",i?s.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?s.jsx("div",{className:"ui-searchbar-inline",children:t}):null,o?s.jsx("div",{className:"ui-searchbar-actions",children:o}):null]}),t&&r&&n?s.jsx("div",{className:"ui-searchbar-filters",children:t}):null,l?s.jsx("div",{className:"ui-searchbar-chips",children:l}):null]})}function Y0({size:e}){return s.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function II({quiet:e,still:t,className:n,children:r}){return s.jsx("div",{className:Yr("ui-fieldbg",n),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function MI(e){const t={};for(const n of e??[])t[n.key]=n.default;return t}function wm(e){const[t,n]=f.useState({}),r=e??[],i={...MI(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:s.jsx("div",{className:"ui-choices",children:r.map(l=>s.jsx(te,{label:l.label,inline:!0,children:s.jsx("select",{value:i[l.key],onChange:o=>n(a=>({...a,[l.key]:o.target.value})),children:l.options.map(o=>s.jsx("option",{value:o,children:o},o))})},l.key))})}}function $I({props:e,timezone:t="UTC",onDecided:n}){var g;const[r,i]=f.useState(null),[l,o]=f.useState(null),[a,c]=f.useState(!1),[u,p]=f.useState(null);f.useEffect(()=>{let y=!1;return i(null),o(null),R.approval(e.approvalId).then(m=>{y||i(m)}).catch(m=>{y||o(m instanceof de?m.message:String(m))}),()=>{y=!0}},[e.approvalId]);const{values:d,controls:h}=wm(r==null?void 0:r.choices),x=(y,m)=>{p(y),o(null),(d&&y==="approve"?R.decide(e.approvalId,y,m,d):R.decide(e.approvalId,y,m)).then(k=>{i(k.action),n==null||n(k.action)}).catch(k=>o(k instanceof de?k.message:String(k))).finally(()=>p(null))};if(l&&!r)return s.jsx("p",{className:"wb-empty",children:l});if(!r)return s.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const v=r.state==="pending",w=(g=r.permissionScopes)==null?void 0:g.includes("always"),b=_I(r),j=(r.preview??"").split(`
93
- `).length>12||(r.preview??"").length>900;return s.jsxs("div",{children:[s.jsxs("div",{className:"ui-stats","data-inline":"true",children:[s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"Tool"}),s.jsx("div",{className:"ui-stat-v mono",children:r.tool})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"State"}),s.jsx("div",{className:"ui-stat-v","data-tone":OI(r.state),children:r.state})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:v?"Expires":"Decided"}),s.jsx("div",{className:"ui-stat-v","data-size":"sm",children:Ie(v?r.expiresAt:r.decidedAt,t)})]})]}),s.jsx(re,{message:l}),v?h:null,v?s.jsxs("div",{className:"wb-row-wrap wb-block",children:[s.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>x("approve"),children:u==="approve"?"Approving…":w?"Allow once":"Approve"}),w?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>x("approve","conversation"),children:"Auto: this conversation"}),s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>x("approve","always"),children:"Always: this agent"})]}):null,s.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>x("reject"),children:u==="reject"?"Rejecting…":"Reject"}),s.jsx("span",{className:"wb-hint",children:w?"Auto-mode and Always also approve future calls to this tool within that scope. Host permissions can be revoked under Host execution.":"This runs the action exactly as printed above."})]}):s.jsxs("p",{className:"muted",children:[r.state," ",r.decidedBy?`by ${r.decidedBy}`:""," ",r.decidedVia?`via ${r.decidedVia}`:""]}),s.jsx("h4",{className:"ui-stat-k wb-label",children:"Preview"}),s.jsxs("div",{className:"wb-doc wb-block","data-clamp":j&&!a?"true":void 0,children:[r.preview||"(this tool wrote no preview)",j&&!a?s.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]}),s.jsxs("details",{className:"ui-details wb-block",children:[s.jsx("summary",{children:"The envelope, field by field"}),s.jsx("dl",{className:"ui-kv",children:b.map(y=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:y.label}),s.jsx("dd",{className:y.mono?"mono":void 0,children:y.value})]},y.label))})]})]})}function _I(e){const t=[],n=e.envelope;if(n!==null&&typeof n=="object"&&!Array.isArray(n))for(const[i,l]of Object.entries(n))t.push({label:zt(i),value:za(l)});else n!=null&&t.push({label:"Envelope",value:za(n)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,l]of Object.entries(r)){const o=`Argument · ${zt(i)}`;t.some(a=>a.label===o)||t.push({label:o,value:za(l)})}return t.push({label:"Action id",value:e.id,mono:!0},{label:"Tool version",value:e.toolVersion,mono:!0},{label:"Agent",value:e.agentId,mono:!0},{label:"Args hash",value:e.argsHash,mono:!0},{label:"Policy version",value:String(e.policyVersion)}),e.conversationId&&t.push({label:"Conversation",value:e.conversationId,mono:!0}),e.jobId&&t.push({label:"Job",value:e.jobId,mono:!0}),t}function za(e){return e==null?"—":Array.isArray(e)?e.map(t=>za(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):yt(e,"text",null)}function OI(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const DI=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function LI(e){return DI.has(e.toLowerCase())}function Ur(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function xu(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function Rn(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 bm(e,t){const n=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return n.startsWith("image/")?"image":n==="application/pdf"?"pdf":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":n==="text/csv"||n==="text/tab-separated-values"||n.includes("spreadsheet")||n.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":n.includes("zip")||n.includes("tar")||n.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":n==="application/json"||n.includes("javascript")||n.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":n.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const Tr={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function Wa(e){return`artifact:${e}`}function FI(e){const t=bm(e.mime,e.filename);return{id:Wa(e.artifactId),tool:Tr[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function UI({props:e}){const t=L0(e.artifactId),[n,r]=f.useState(null),[i,l]=f.useState(null),[o,a]=f.useState(!1);if(f.useEffect(()=>{if(t===null)return;let p=!0;return r(null),l(null),a(!1),R.libraryEntry(t).then(d=>{p&&r({filename:d.entry.filename,sizeBytes:d.entry.sizeBytes})}).catch(()=>{}),()=>{p=!1}},[t]),t===null)return s.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(n==null?void 0:n.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,n!=null&&n.sizeBytes?Rn(n.sizeBytes):null].filter(p=>p!==null);return s.jsxs("figure",{className:"wb-image",children:[s.jsx("div",{className:"wb-image-frame",children:o?s.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):s.jsx("a",{href:Ur(t),className:"wb-image-link",title:"Open at full size",children:s.jsx("img",{src:Ur(t),alt:e.caption??c,onLoad:p=>{const d=p.currentTarget;d.naturalWidth>0&&l({width:d.naturalWidth,height:d.naturalHeight})},onError:()=>a(!0)})})}),s.jsxs("figcaption",{className:"wb-image-caption",children:[s.jsxs(J,{children:[s.jsx("span",{className:"wb-image-name",children:c}),u.length>0?s.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(Bn,{size:"sm",href:xu(t),download:(n==null?void 0:n.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?s.jsx(bt,{summary:e.captionLabel,className:"wb-image-note",children:s.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?s.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function BI({props:e}){return e.pairs.length===0?s.jsx("p",{className:"wb-empty",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:yt(t.value,t.unit,t.currency)})]},t.label))})}const zI=8;function q0({text:e,label:t="Output",className:n}){const r=f.useRef(null),i=f.useRef(!0);return f.useLayoutEffect(()=>{const l=r.current;l&&i.current&&(l.scrollTop=l.scrollHeight)},[e]),s.jsx("pre",{ref:r,className:n?`wb-terminal-body ${n}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:l=>{const o=l.currentTarget;i.current=o.scrollHeight-o.scrollTop-o.clientHeight<=zI},children:e})}function WI(e){if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?1:0)} s`;const n=Math.floor(t/60);return`${n} min ${Math.round(t-n*60)} s`}function VI({text:e}){const[t,n]=f.useState("");return s.jsxs(s.Fragment,{children:[t?s.jsx("span",{role:"status",className:"wb-hint",children:t}):null,s.jsx(P,{size:"sm",onClick:()=>{var r;if(n(""),!((r=navigator.clipboard)!=null&&r.writeText)){n("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>n("Copied"),()=>n("Copy failed; select the text to copy."))},children:"Copy"})]})}function HI({props:e}){const t=e.output??"";return s.jsxs("div",{className:"wb-terminal",children:[s.jsxs(J,{className:"wb-terminal-head",children:[e.command!==null?s.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?s.jsxs(pe,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?s.jsx("span",{className:"wb-terminal-fact",children:WI(e.elapsedMs)}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?s.jsx(VI,{text:t}):null]}),e.omittedBytes!==null?s.jsxs("p",{className:"wb-terminal-note",children:["First ",Rn(e.omittedBytes)," not shown."]}):null,t!==""?s.jsx(q0,{text:t}):s.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(n=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:n.label}),s.jsx("dd",{children:yt(n.value,n.unit,null)})]},n.label))}):null]})}function KI(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function yv(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function GI(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((n,r)=>n-r)}function YI({props:e}){var k;const[t,n]=f.useState(null),[r,i]=f.useState(null),[l,o]=f.useState(null),[a,c]=f.useState(!1),u=((k=e.target)==null?void 0:k.plugin)??null,p=GI(e),[d,h]=f.useState(null),x=d!==null&&p.includes(d)?d:e.port,v=e.target?x!==null&&x!==e.port?`${e.target.name}.${x}`:e.target.name:null,w=e.changes??0,b=f.useRef(w),[j,g]=f.useState(0);f.useEffect(()=>{w<=b.current||(b.current=w,e.reloadsItself||g(S=>S+1))},[w,e.reloadsItself]),f.useEffect(()=>{if(u===null||v===null)return;let S=!0;return n(null),i(null),o(null),g(0),R.previewLink(u,v).then(N=>{S&&(n(N.url),i(yv(N.url)))}).catch(N=>{S&&o(N instanceof Error?N.message:"That preview could not be opened.")}),()=>{S=!1}},[u,v]);const y=()=>{u===null||v===null||R.previewLink(u,v).then(S=>i(S.url)).catch(()=>{})};if(e.target===null)return s.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",s.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const m=!(e.output===null||e.output==="");return s.jsxs("div",{className:"wb-preview","data-output":a||void 0,children:[s.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,p.length>1?s.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:x??"",onChange:S=>h(Number(S.target.value)),children:p.map(S=>s.jsxs("option",{value:S,children:[":",S]},S))}):null,m?s.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":a,onClick:()=>c(S=>!S),children:a?"Hide output":"Output"}):null,r?s.jsx("a",{className:"wb-preview-open",href:r,target:"_blank",rel:"noreferrer noopener",onPointerEnter:y,onFocus:y,title:"Through buddi: works from anywhere the dashboard does, including the tailnet.",children:"Open in a tab"}):null,x!==null&&KI()?s.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${x}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",x]}):null]}),s.jsxs("div",{className:"wb-preview-body",children:[t?s.jsx("iframe",{className:"wb-preview-frame",src:j===0?t:yv(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},j):s.jsx("p",{className:"wb-empty wb-preview-frame",children:l??"Opening the preview…"}),m&&a?s.jsx(q0,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const qI=50,QI=9,JI=24,XI=.6,ZI=48,eM=/(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,tM=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,nM=/^id$|(^|[a-z0-9])Id$|_id$/;function ji(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function mn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Q0(...e){for(const t of e)if(mn(t))for(const n of["currency","currencyCode"]){const r=t[n];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function J0(e,t,n){const r=t.filter(i=>i!=null&&i!=="");return r.length===0?"text":r.every(i=>typeof i=="boolean")?"boolean":r.every(i=>typeof i=="number"&&Number.isFinite(i))?n!==null&&eM.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&tM.test(i))?"date":"text"}function sM(e,t){if(!nM.test(e))return!1;const n=t.filter(r=>!il(r));return n.length<2?!1:new Set(n.map(r=>String(r))).size===n.length}function il(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:mn(e)?Object.keys(e).length===0:!1}function wv(e,t){const n=e.filter(mn);if(n.length===0||n.length/e.length<.8)return null;const r=n.slice(0,qI),i=new Map,l=[];for(const p of r)for(const d of Object.keys(p))i.has(d)||l.push(d),i.set(d,(i.get(d)??0)+1);if(i.size===0||i.size>JI||[...i.values()].reduce((p,d)=>p+d,0)/(i.size*r.length)<XI)return null;const a=[...i.keys()].sort((p,d)=>{const h=(i.get(d)??0)-(i.get(p)??0);return h!==0?h:l.indexOf(p)-l.indexOf(d)}),c=[],u=[];for(const p of a){const d=r.map(w=>w[p]),h=d.filter(w=>!il(w));if(h.length===0||sM(p,d))continue;const x=Q0(r[0],t),v=J0(p,d,x);if(r.length>=4&&h.length===d.length&&d.every(w=>ji(w)&&w===d[0])){u.push({label:zt(p),value:d[0],type:v,currency:x});continue}if(c.push({key:p,label:zt(p),type:v,currency:v==="currency"?x:null}),c.length===QI)break}return c.length===0?null:{columns:c,rows:n,constants:u}}function rM(e,t,n){const r=Q0(n);return{label:zt(e),value:t,type:J0(e,[t],r),currency:r}}function X0(e){return typeof e=="string"&&e.length>ZI}function iM(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.":mn(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function uh(e){if(typeof e=="string"&&e.trim()!=="")return e;if(mn(e))for(const t of["message","error","reason","detail","description"]){const n=e[t];if(typeof n=="string"&&n.trim()!=="")return n;if(mn(n)){const r=uh(n);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function km(e,t={}){if(t.failed){let d=e;if(typeof e=="string")try{const h=JSON.parse(e.replace(/^tool-error:\s*/,""));mn(h)&&(d=h)}catch{}return{kind:"error",summary:uh(d),detail:bv(d)}}if(mn(e)){const d=e.error,h=e.ok;if(typeof d=="string"&&d.trim()!==""||h===!1)return{kind:"error",summary:uh(e),detail:bv(e)}}const n=iM(e);if(n)return{kind:"empty",note:n,stats:[]};if(Array.isArray(e)){const d=wv(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(ji)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!mn(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,l=null;for(const[d,h]of r){if(!Array.isArray(h))continue;const x=wv(h,e);if(x){(!i||x.rows.length>i.candidate.rows.length)&&(i={key:d,candidate:x});continue}h.length>0&&h.every(ji)&&(!l||h.length>l.items.length)&&(l={key:d,items:h})}const o=(i==null?void 0:i.key)??(l==null?void 0:l.key)??null,a=[],c=[],u=[];for(const[d,h]of r)if(d!==o){if(X0(h)){c.push(h);continue}if(ji(h)){if(h==="")continue;a.push(rM(d,h,e));continue}h!==void 0&&u.push({label:zt(d),value:h})}if(i)return{kind:"table",label:zt(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...a,...i.candidate.constants],notes:c,asides:u};if(l)return{kind:"list",label:zt(l.key),items:l.items,total:l.items.length,stats:a,notes:c,asides:u};const p=r.filter(([,d])=>Array.isArray(d)&&d.length===0);return p.length>0&&p.length===r.filter(([,d])=>Array.isArray(d)).length?{kind:"empty",note:`No ${p.map(([h])=>zt(h).toLowerCase()).join(", ")} to show.`,stats:a}:r.every(([,d])=>ji(d)||mn(d)||Array.isArray(d))?{kind:"record",pairs:a,notes:c,asides:u}:{kind:"tree",value:e}}function bv(e){if(!mn(e))return null;const t=Object.entries(e).filter(([n])=>n!=="message"&&n!=="error");return t.length===0?null:Object.fromEntries(t)}const Ec=25,lM=3,dh=8,Z0=6;function fh(e,t=0){if(t>Z0||il(e)||X0(e))return 0;if(ji(e))return 1;if(Array.isArray(e)){let n=0;for(const r of e)if(n+=fh(r,t+1),n>=dh)return n;return n}if(mn(e)){let n=0;for(const r of Object.values(e))if(n+=fh(r,t+1),n>=dh)return n;return n}return 0}function hh(e,t=0){if(t>Z0)return!1;if(Array.isArray(e))return e.some(l=>hh(l,t+1));if(!mn(e))return!1;const n=e.artifactId??e.artifact_id;if(typeof n=="string"&&n.trim()!=="")return!0;const r=e.mime??e.mimeType??e.contentType,i=e.url??e.src??e.downloadUrl??e.path;return typeof r=="string"&&r.includes("/")&&typeof i=="string"&&i.trim()!==""?!0:Object.values(e).some(l=>hh(l,t+1))}function oM(e){if(hh(e))return!0;const t=km(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=lM;case"record":case"tree":return fh(e)>=dh;default:return!1}}function vd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Sm(e){const t=vd(e);if(!t)return null;const n=vd(t.output)??t;if(typeof n.state!="string"||typeof n.stdout!="string"||typeof n.stderr!="string"||!(n.exitCode===null||typeof n.exitCode=="number"&&Number.isFinite(n.exitCode)))return null;const r=n===t?null:vd(t.input),i=(r==null?void 0:r.command)??n.command;return{command:typeof i=="string"?i:null,input:r,result:n}}function aM({text:e,label:t}){const[n,r]=f.useState("");return s.jsxs("span",{className:"wb-command-copy",children:[s.jsx("button",{className:"ui-btn",onClick:()=>{var i;if(r(""),!((i=navigator.clipboard)!=null&&i.writeText)){r("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>r("Copied"),()=>r("Copy failed; select the text to copy."))},children:t}),n&&s.jsx("span",{role:"status",className:"wb-hint",children:n})]})}function jd({title:e,text:t,error:n=!1}){return s.jsxs("section",{className:"wb-command-stream","data-error":n||void 0,children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("h4",{children:e}),s.jsx(aM,{text:t,label:`Copy ${e.toLowerCase()}`})]}),s.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function cM({value:e,children:t}){const{result:n,command:r,input:i}=e,l=n.state==="completed"&&n.exitCode!==null&&n.exitCode!==0,o=typeof n.signal=="string"&&n.signal?n.signal:null,a=n.state==="completed"&&n.exitCode===0,c=Object.fromEntries(Object.entries(n).filter(([p,d])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(p)&&d!==null&&d!==void 0&&d!=="")),u=Array.isArray(n.outputErrors)?n.outputErrors.filter(p=>typeof p=="string"):[];return s.jsxs("div",{className:"wb-command-result",children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("span",{className:"ui-pill","data-tone":a?"good":"critical",children:l?"Failed":n.state==="completed"&&o?"Terminated":n.state}),n.exitCode!==null&&s.jsxs("span",{className:"mono",children:["Exit code ",n.exitCode]}),o&&s.jsxs("span",{className:"mono",children:["Signal ",o]}),s.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&s.jsx(jd,{title:"Command",text:r}),n.state==="output-limit"&&s.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),n.state==="timed-out"&&s.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),n.state==="cancelled"&&s.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),n.stdout?s.jsx(jd,{title:"Output",text:n.stdout}):s.jsx("p",{className:"wb-note",children:"No standard output."}),n.stderr?s.jsx(jd,{title:"Standard error",text:n.stderr,error:!0}):null,u.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"File export errors"}),u.map((p,d)=>s.jsx("p",{className:"wb-fail",children:p},d))]}),t,(Object.keys(c).length>0||i!==null)&&s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Execution details"}),s.jsx("pre",{children:ln({...c,...i?{input:i}:{}})})]})]})}const aa=2,kv=64;function uM({props:e}){const[t,n]=f.useState(!1),r=Sm(e.value),i=dM((r==null?void 0:r.result)??e.value),l=f.useMemo(()=>km(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return s.jsxs("div",{children:[!r&&s.jsx(Sv,{files:i}),t?s.jsx("pre",{className:"ui-code",children:ln(e.value)}):r?s.jsx(cM,{value:r,children:i.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"Generated files"}),s.jsx(Sv,{files:i})]})}):i.length?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Tool details"}),s.jsx(Nv,{shape:l})]}):s.jsx(Nv,{shape:l}),s.jsx("div",{className:"wb-row-end wb-section",children:s.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>n(o=>!o),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function dM(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(n=>n&&typeof n.id=="string"&&/^[0-9a-f-]{36}$/i.test(n.id)&&typeof n.filename=="string"):[]}function Sv({files:e}){return e.length?s.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var n;return s.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?s.jsx(fM,{file:t}):null,s.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(n=t.mime)!=null&&n.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function fM({file:e}){const[t,n]=f.useState(!1);return t?s.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):s.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>n(!0)})}function Nv({shape:e}){switch(e.kind){case"error":return s.jsxs("div",{children:[s.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"What came back with it"}),s.jsx("div",{className:"wb-tree",children:co(e.detail,1)})]})]});case"empty":return s.jsxs("div",{children:[s.jsx(yd,{stats:e.stats}),s.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=vM(e.columns,e.rows);return s.jsxs("div",{children:[s.jsx(yd,{stats:e.stats}),s.jsx(wd,{notes:e.notes}),t?s.jsx(jM,{label:e.label,plan:t,rows:e.rows,total:e.total}):s.jsx(pM,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),s.jsx(bd,{asides:e.asides})]})}case"list":return s.jsxs("div",{children:[s.jsx(yd,{stats:e.stats}),s.jsx(wd,{notes:e.notes}),e.label?s.jsx("h4",{className:"wb-sub",children:e.label}):null,s.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,n)=>s.jsx("li",{children:yt(t,"text",null)},n))}),e.total>100?s.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,s.jsx(bd,{asides:e.asides})]});case"record":return s.jsxs("div",{children:[s.jsx(wd,{notes:e.notes}),s.jsx(hM,{pairs:e.pairs}),s.jsx(bd,{asides:e.asides})]});default:return s.jsx("div",{className:"wb-tree",children:co(e.value,0)})}}function yd({stats:e}){return e.length===0?null:s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:t.label}),s.jsx("div",{className:"ui-stat-v",children:Nm(t.value,t.type,t.currency)})]},t.label))})}const Cv=200;function wd({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=Cv),n=e.filter(r=>r.length>Cv);return s.jsxs(s.Fragment,{children:[t.map(r=>s.jsx("p",{className:"wb-note",children:r},r)),n.length>0?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:n.length===1?"A note that came with this result":`${n.length} notes that came with this result`}),n.map(r=>s.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function hM({pairs:e}){return e.length===0?s.jsx("p",{className:"wb-note",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:Nm(t.value,t.type,t.currency)})]},t.label))})}function bd({asides:e}){return e.length===0?null:s.jsx("div",{className:"wb-section",children:e.map(t=>s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:t.label}),s.jsx("div",{className:"wb-tree",children:co(t.value,1)})]},t.label))})}function pM({label:e,columns:t,rows:n,total:r}){const[i,l]=f.useState(!1),o=r<=Ec+5?r:Ec,a=i?n:n.slice(0,o);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:t.map(c=>s.jsx("th",{className:tk(c.type)?"num":void 0,children:c.label},c.key))})}),s.jsx("tbody",{children:a.map((c,u)=>s.jsx("tr",{children:t.map(p=>s.jsx(yM,{value:c[p.key],column:p},p.key))},u))})]})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>l(!0),children:["Show all ",r]})]}):null]})}const mM=/^(title|name|headline|subject|label|heading)$/i,gM=/^(url|link|href|uri|permalink)$/i;function Ac(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function xM(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function ek(e,t=48){try{const n=new URL(e),r=n.pathname==="/"?"":n.pathname,i=`${n.hostname.replace(/^www\./,"")}${r}${n.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function ca(e,t){const n=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return n.length===0?0:n.reduce((r,i)=>r+i.length,0)/n.length}function vM(e,t){if(t.length===0)return null;const n=e.filter(p=>p.type==="text"),r=n.find(p=>gM.test(p.key)&&t.some(d=>Ac(d[p.key])))??n.find(p=>{const d=t.map(h=>h[p.key]).filter(h=>!il(h));return d.length>0&&d.filter(Ac).length/d.length>=.6});if(!r)return null;const i=n.filter(p=>p.key!==r.key),l=i.find(p=>mM.test(p.key))??i.find(p=>ca(t,p.key)>0);if(!l)return null;const a=[...i.filter(p=>p.key!==l.key)].sort((p,d)=>ca(t,d.key)-ca(t,p.key)),c=a[0]&&ca(t,a[0].key)>40?a[0]:null,u=e.filter(p=>p.key!==r.key&&p.key!==l.key&&p.key!==(c==null?void 0:c.key)).map(p=>p.key);return{url:r.key,title:l.key,description:(c==null?void 0:c.key)??null,meta:u}}function jM({label:e,plan:t,rows:n,total:r}){const[i,l]=f.useState(!1),o=r<=Ec+5?r:Ec,a=i?n:n.slice(0,o);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("ol",{className:"wb-records",children:a.map((c,u)=>{const p=c[t.url],d=Ac(p)?p.trim():null,h=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:d?ek(d):"Untitled",x=t.description&&typeof c[t.description]=="string"?c[t.description]:null,v=d?xM(d):null,w=t.meta.map(b=>c[b]).filter(b=>!il(b)&&typeof b!="object").map(b=>String(b)).filter(b=>v===null||b.replace(/^www\./,"")!==v);return s.jsxs("li",{className:"wb-record",children:[d?s.jsx("a",{className:"wb-record-title",href:d,target:"_blank",rel:"noopener noreferrer",children:h}):s.jsx("span",{className:"wb-record-title",children:h}),s.jsxs("div",{className:"wb-record-meta",children:[v?s.jsx("span",{className:"wb-record-host",title:d??void 0,children:v}):null,w.map((b,j)=>s.jsx("span",{children:b.length>60?`${b.slice(0,59)}…`:b},j))]}),x?s.jsx("p",{className:"wb-record-desc",children:x.length>280?`${x.slice(0,279)}…`:x}):null]},u)})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>l(!0),children:["Show all ",r]})]}):null]})}function yM({value:e,column:t}){if(il(e))return s.jsx("td",{className:"wb-cell-soft",children:"—"});if(Ac(e)){const i=e.trim();return s.jsx("td",{className:"wb-cell-link",children:s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:ek(i)})})}if(e!==null&&typeof e=="object"){const i=Array.isArray(e)?`${e.length} item${e.length===1?"":"s"}`:`${Object.keys(e).length} fields`;return s.jsx("td",{className:"wb-cell-soft",title:ln(e),children:i})}const n=Nm(e,t.type,t.currency),r=n.length>kv?`${n.slice(0,kv-1)}…`:n;return s.jsx("td",{className:tk(t.type)?"num":"wb-cell-text",...r===n?{}:{title:n},children:r})}function tk(e){return e==="number"||e==="currency"}function Nm(e,t,n){return e==null?"—":t==="boolean"?e?"yes":"no":yt(e,t==="text"?"text":t,n)}function co(e,t){if(e===null)return s.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return s.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return s.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return s.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return s.jsx("span",{children:e===""?s.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return s.jsx("span",{className:"wb-tree-null",children:"none"});const i=s.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((l,o)=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[o,". "]}),co(l,t+1)]},o)),e.length>50?s.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=aa?s.jsx(Ev,{summary:`${e.length} items`,open:t===aa,children:i}):i}const n=Object.entries(e);if(n.length===0)return s.jsx("span",{className:"wb-tree-null",children:"empty"});const r=s.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:n.map(([i,l])=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[zt(i),": "]}),co(l,t+1)]},i))});return t>=aa?s.jsx(Ev,{summary:`${n.length} fields`,open:t===aa,children:r}):r}function Ev({summary:e,open:t,children:n}){return s.jsxs("details",{open:t,children:[s.jsx("summary",{className:"wb-tree-key",children:e}),n]})}function wM({props:e}){const t=e.groups.every(n=>n.rows.length===0);return s.jsxs("div",{children:[e.summary.length>0?s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(n=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:n.label}),s.jsx("div",{className:"ui-stat-v","data-tone":n.tone,children:yt(n.value,n.unit,n.currency)})]},n.label))}):null,t?s.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((n,r)=>s.jsxs("div",{className:r>0?"wb-section":void 0,children:[n.label?s.jsx("h4",{className:"ui-stat-k wb-label",children:n.label}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.columns.map(i=>s.jsx("th",{className:nk(i.type)?"num":void 0,"data-type":i.type,children:i.label},i.key))})}),s.jsx("tbody",{children:n.rows.map((i,l)=>s.jsx("tr",{children:i.map((o,a)=>{var c;return s.jsx(bM,{cell:o},((c=e.columns[a])==null?void 0:c.key)??a)})},l))})]})})]},n.label??r))]})}function bM({cell:e}){const t=yt(e.value,e.type,e.currency);return e.bar?s.jsx("td",{className:"num",children:s.jsxs("div",{className:"wb-row wb-row-end",children:[s.jsx("div",{className:"ui-meter",role:"meter","aria-valuenow":Math.round(e.bar.fraction*100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":t,children:s.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),s.jsx("span",{className:"tnum",children:t})]})}):s.jsx("td",{className:nk(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function nk(e){return e==="number"||e==="currency"||e==="percent"}const ri=760,kd=400,tt={top:18,right:18,bottom:36,left:66},kM=5;function SM({props:e}){const{points:t,referenceLines:n,unit:r,currency:i}=e;if(t.length===0)return s.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const l=[...t.map(m=>m.y),...n.map(m=>m.value)],o=Math.min(...l),a=Math.max(...l),c=a-o||Math.abs(a)||1,u=o-c*.08,p=a+c*.08,d=ri-tt.left-tt.right,h=kd-tt.top-tt.bottom,x=m=>tt.left+(t.length===1?d/2:m/(t.length-1)*d),v=m=>tt.top+h-(m-u)/(p-u)*h,w=e2(o,a,4),b=CM(t.map(m=>m.y),e.mark),j=e.shadeBelow===null?[]:EM(t.map(m=>m.y),e.shadeBelow),g=t.map((m,k)=>`${k===0?"M":"L"}${x(k)},${v(m.y)}`).join(" "),y=m=>yt(m,r,i);return s.jsxs("div",{children:[e.label?s.jsx("p",{className:"ui-panel-sub",children:e.label}):null,s.jsxs("div",{className:"wb-chart-layout",children:[s.jsx("div",{className:"wb-chart-plot",children:s.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${ri} ${kd}`,role:"img","aria-label":NM(e,y),preserveAspectRatio:"xMidYMid meet",children:[j.map(m=>s.jsx("rect",{className:"wb-chart-breach",x:x(m.from),width:Math.max(2,x(m.to)-x(m.from)),y:tt.top,height:h},`band-${m.from}`)),w.map(m=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-grid",x1:tt.left,x2:ri-tt.right,y1:v(m),y2:v(m)}),s.jsx("text",{x:tt.left-8,y:v(m)+4,textAnchor:"end",children:y(m)})]},`tick-${m}`)),n.map(m=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-floor",x1:tt.left,x2:ri-tt.right,y1:v(m.value),y2:v(m.value)}),s.jsxs("text",{x:ri-tt.right,y:v(m.value)-6,textAnchor:"end",children:[m.label," ",y(m.value)]})]},`rule-${m.label}`)),s.jsx("line",{className:"wb-chart-axis",x1:tt.left,x2:tt.left,y1:tt.top,y2:tt.top+h}),s.jsx("line",{className:"wb-chart-axis",x1:tt.left,x2:ri-tt.right,y1:tt.top+h,y2:tt.top+h}),s.jsx("path",{className:"wb-chart-series",d:g}),b!==null?s.jsxs("g",{children:[s.jsx("circle",{className:"wb-chart-min",cx:x(b),cy:v(t[b].y),r:4.5}),s.jsx("text",{x:x(b),y:v(t[b].y)+20,textAnchor:"middle",children:y(t[b].y)})]}):null,AM(t.length).map(m=>s.jsx("text",{x:x(m),y:kd-10,textAnchor:"middle",children:iv(t[m].x)},`x-${m}`))]})}),e.events.length>0?s.jsxs("aside",{className:"wb-chart-events",children:[s.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),s.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((m,k)=>s.jsxs("li",{className:"wb-chart-event",children:[s.jsxs("span",{children:[s.jsx("span",{className:"wb-chart-event-day",children:iv(m.at)}),m.label]}),m.amount===null?null:s.jsx("span",{className:m.amount<0?"tnum critical":"tnum good",children:yt(m.amount,r,i)})]},`${m.at}-${m.label}-${k}`))})]}):null]})]})}function NM(e,t){const n=e.points.map(o=>o.y),r=e.points[0],i=e.points[e.points.length-1],l=e.referenceLines.map(o=>`${o.label} at ${t(o.value)}`).join(", ");return[`${e.points.length} points from ${r==null?void 0:r.x} to ${i==null?void 0:i.x}`,`low ${t(Math.min(...n))}, high ${t(Math.max(...n))}`,l].filter(Boolean).join("; ")}function CM(e,t){if(!t||e.length===0)return null;let n=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[n]:e[r]>e[n])&&(n=r);return n}function EM(e,t){const n=[];let r=null;return e.forEach((i,l)=>{i<t?r===null&&(r=l):r!==null&&(n.push({from:r,to:l}),r=null)}),r!==null&&n.push({from:r,to:e.length-1}),n}function AM(e,t=kM){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const n=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*n));return[...r].sort((i,l)=>i-l)}const In=e=>e,ph={timeseries:In(SM),table:In(wM),bars:In(t2),keyvalue:In(BI),document:In(X2),diff:In(o2),terminal:In(HI),image:In(UI),preview:In(YI),envelope:In($I),structured:In(uM)},RM="structured";function TM(e){return(Rc(e)?ph[e]:void 0)??ph[RM]}function Rc(e){return Object.prototype.hasOwnProperty.call(ph,e)}function PM({renderer:e,props:t,timezone:n,onDecided:r}){const i=TM(e),o=Rc(e)?t:{value:t};return s.jsx(i,{props:o,timezone:n,onDecided:r})}function IM({profile:e,onChange:t}){return s.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[s.jsx("p",{className:"wb-prof-lead",children:e.description}),s.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?s.jsx(Sd,{children:"Opens by default"}):null,s.jsx(Sd,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(n=>s.jsx(Sd,{title:`A surface command that asks for "${n}" lands on this agent.`,children:zt(n)},n))]}),e.available?null:s.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[s.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),s.jsx(wl,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:s.jsxs("ul",{className:"wb-prof-list",children:[s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),s.jsx("span",{className:"wb-prof-row-desc",children:"When it knows the likely answers, it can show one-tap choices in the dashboard and Telegram. You can still write a different answer when the question allows it."})]}),s.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),s.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),s.jsx("span",{className:"wb-prof-row-desc",children:"A request to send, spend, publish or otherwise affect the world appears in the conversation with the exact action. Answering a question never approves it."})]}),s.jsxs("span",{className:"wb-prof-gate",children:[s.jsx(sk,{}),"Exact action"]})]})]})}),s.jsx(wl,{title:"What it can do",note:MM(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?s.jsx("p",{className:"wb-prof-empty",children:"No tools at all. It answers from the conversation and from what it remembers, and it can change nothing."}):[...e.tools].sort((n,r)=>+(r.gated>0)-+(n.gated>0)).map(n=>s.jsx($M,{family:n},n.family))}),s.jsx(wl,{title:"What it runs on",children:s.jsxs("dl",{className:"wb-prof-kv",children:[s.jsx(bl,{label:"Provider",children:e.engine.provider}),s.jsx(bl,{label:"Model",children:s.jsx("span",{className:"mono",children:e.engine.model})}),s.jsxs(bl,{label:"Credential",children:[e.engine.credentialKind," from"," ",s.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),s.jsxs(bl,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),s.jsx(bl,{label:"Language",children:FM(e.engine.language)})]})}),e.skills.length>0?s.jsx(wl,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:s.jsx("ul",{className:"wb-prof-list",children:e.skills.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:n.name}),n.description?s.jsx("span",{className:"wb-prof-row-desc",children:n.description}):null]}),s.jsxs("span",{className:"wb-prof-row-side",title:n.file,children:[n.scope==="private"?"its own":"shared"," · ",n.provenance]})]},n.file))})}):null,e.delegates.length>0?s.jsx(wl,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:s.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsxs("span",{className:"wb-prof-row-name mono",children:["@",n.handle]}),s.jsx("span",{className:"wb-prof-row-desc",children:n.description})]}),s.jsx("span",{className:"wb-prof-row-side",children:n.available?n.name:`${n.name} · cannot run`})]},n.id))})}):null,s.jsxs("footer",{className:"wb-prof-foot",children:[s.jsx("p",{className:"wb-prof-note",children:e.note}),s.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?s.jsxs("button",{className:"ui-btn","data-testid":"agent-profile-change",title:e.changeVia.prompt,onClick:()=>t({agentId:e.changeVia.agentId,prompt:e.changeVia.prompt}),children:["Ask @",e.changeVia.handle," to change this"]}):null]})]})}function MM(e){if(e.toolCount===0)return"Nothing. This agent holds no tools.";const t=`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`;if(e.gatedCount===0)return`${t}, every one of them running without asking you. None of them can send, spend or write to the world.`;const n=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${n}.`}function $M({family:e}){const t=[...e.tools].sort((n,r)=>Number(r.gated)-Number(n.gated));return s.jsxs("section",{className:"wb-prof-family",children:[s.jsxs("h4",{className:"wb-prof-family-head",children:[s.jsx("span",{className:"wb-prof-family-name",children:zt(e.family)}),s.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),s.jsx("ul",{className:"wb-prof-list",children:t.map(n=>s.jsx(_M,{tool:n},n.name))})]})}function _M({tool:e}){return s.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:LM(e.name)}),s.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?s.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[s.jsx(sk,{}),"Needs your approval"]}):s.jsx("span",{className:"wb-prof-auto",title:DM(e.tier),children:OM(e.tier)})]})}function OM(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function DM(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 LM(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function FM(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function wl({title:e,note:t,tone:n,children:r}){return s.jsxs("section",{className:"wb-prof-section",children:[s.jsx("h3",{className:"wb-prof-title",children:e}),t?s.jsx("p",{className:"wb-prof-note-lead","data-tone":n,children:t}):null,r]})}function bl({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"wb-prof-k",children:e}),s.jsx("dd",{className:"wb-prof-v",children:t})]})}function Sd({children:e,title:t}){return s.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function sk(){return s.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),s.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const Nd=1e5,Cd=200,Ed=30;function rk({artifactId:e,filename:t,mime:n,family:r,available:i=!0}){const[l,o]=f.useState(!1);return i?r==="image"&&!l?s.jsx("figure",{className:"file-preview file-preview-image",children:s.jsx("img",{src:Ur(e),alt:t??"Image",onError:()=>o(!0)})}):r==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:Ur(e),type:"application/pdf","aria-label":t??"PDF",children:s.jsx(K,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?s.jsx(UM,{artifactId:e,filename:t,mime:n,family:r}):s.jsx(K,{children:"Preview not supported for this kind of file. Download it to open it."}):s.jsx(K,{children:"The file is no longer available; its record is kept."})}function UM({artifactId:e,filename:t,mime:n,family:r}){const[i,l]=f.useState("loading");if(f.useEffect(()=>{let a=!1;return l("loading"),fetch(Ur(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();a||l({text:u.slice(0,Nd),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>Nd})}).catch(()=>{a||l("failed")}),()=>{a=!0}},[e]),i==="loading")return s.jsx("div",{className:"file-preview",children:s.jsx(le,{children:"Loading preview…"})});if(i==="failed")return s.jsx(K,{children:"The preview could not be loaded. Download the file to open it."});const o=r==="table"&&(/csv|tab-separated/.test(n)||/\.(csv|tsv)$/i.test(t??""));return s.jsxs("div",{className:"file-preview",children:[o?s.jsx(zM,{text:i.text,delimiter:/tab|\.tsv$/i.test(n+(t??""))?" ":","}):s.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?s.jsxs("p",{className:"muted",children:["Showing the first ",Nd.toLocaleString()," characters. The download has the whole file."]}):null]})}function BM(e,t,n,r){const i=[];let l=[],o="",a=!1,c=!1,u=!1;const p=()=>{l.length<r?l.push(o):c=!0,o=""},d=()=>{p(),i.push(l),l=[]};let h=0;for(;h<e.length;h+=1){if(i.length>=n){u=e.slice(h).trim()!=="";break}const x=e[h];if(a){x==='"'?e[h+1]==='"'?(o+='"',h+=1):a=!1:o+=x;continue}if(x==='"'){a=!0;continue}if(x===t){p();continue}if(x!=="\r"){if(x===`
94
- `){d();continue}o+=x}}return i.length<n&&(o!==""||l.length>0)&&d(),{rows:i,truncatedRows:u,truncatedCols:c}}function zM({text:e,delimiter:t}){const n=f.useMemo(()=>BM(e,t,Cd+1,Ed),[e,t]),[r,...i]=n.rows;if(!r)return s.jsx("p",{className:"muted",children:"The file is empty."});const l=Math.min(Ed,n.rows.reduce((a,c)=>Math.max(a,c.length),0)),o=Array.from({length:l},(a,c)=>c);return s.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:o.map(a=>s.jsx("th",{children:r[a]??""},a))})}),s.jsx("tbody",{children:i.slice(0,Cd).map((a,c)=>s.jsx("tr",{children:o.map(u=>s.jsx("td",{children:a[u]??""},u))},c))})]}),n.truncatedRows||n.truncatedCols?s.jsxs("p",{className:"muted",children:["Showing the first ",Cd," rows",n.truncatedCols?` and ${Ed} columns`:"",". The download has the whole file."]}):null]})}function WM({attachment:e}){const t=bm(e.mime,e.filename),n=e.filename??"Untitled file";return s.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[s.jsx(rk,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),s.jsxs("dl",{className:"ui-kv",children:[s.jsx("dt",{children:"Type"}),s.jsxs("dd",{children:[Tr[t],s.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Size"}),s.jsx("dd",{children:Rn(e.sizeBytes)})]}):null,s.jsx("dt",{children:"Id"}),s.jsx("dd",{className:"mono",children:e.artifactId})]}),s.jsx("div",{className:"ui-toolbar","data-align":"end",children:s.jsx("a",{className:"ui-btn",href:xu(e.artifactId),download:n,children:"Download"})})]})}const Av=80,VM=["query","path","url","dir"],HM=["message","task"];function Cm(e,t){const n=KM(t);if(!n)return null;const r=ii(n.command);if(r!==null){const o=ii(n.name);return ua(o===null?r:`${o}: ${r}`)}for(const o of VM){const a=ii(n[o]);if(a!==null)return ua(a)}const i=ii(n.action);if(i!==null){const o=HM.map(a=>ii(n[a])).find(a=>a!==null)??null;return ua(o===null?i:`${i} · ${o}`)}const l=Object.values(n).filter(o=>typeof o=="string");return l.length===1?ua(ii(l[0])):null}function ii(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function ua(e){return e===null?null:e.length>Av?`${e.slice(0,Av-1)}…`:e}function KM(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Tc="agent.delegate";function GM(e){if(e===null||typeof e!="object")return null;const t=e,n=t.conversationId;if(typeof n!="string"||n==="")return null;const r=t.agentId??t.agent;return{conversationId:n,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function YM(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 mh="canvas.show",Rv="canvas.clear",Tv=12;function Ai(e){return`${e.plugin}/${e.name}`}function qM(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function QM({messages:e,descriptors:t}){const n=new Map(t.filter(l=>l.renderer==="preview").map(l=>[l.tool,l]));if(n.size===0)return[];const r=new Map,i=[];for(const l of e)for(const o of l.blocks??[]){if(o.type==="tool_use"&&r.set(o.id,o.name),o.type!=="tool_result"||o.ok===!1)continue;const a=n.get(o.name||r.get(o.toolUseId)||"");if(!a)continue;const c=U0(a,ik(o.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:l.at??null})}return i}function JM({messages:e,descriptors:t,awaiting:n,folded:r,served:i}){var u;const l=new Map(t.map(p=>[p.tool,p])),o=new Map;let a=[],c=0;for(const p of e)for(const d of p.blocks??[]){if(d.type==="tool_use"){if(o.set(d.id,{name:d.name,input:d.input,at:p.at??null}),d.name===mh){const m=ZM(d.id,d.input,p.at??null);m&&a.push(m)}if(d.name===Rv&&(a=[]),d.name===Tc){const m=GM(d.input);m&&a.push({id:d.id,tool:Tc,title:"Delegation",renderer:"delegate",props:{...m,result:null},at:p.at??null,source:"delegate",substantial:!0})}continue}if(d.type!=="tool_result"||d.name===mh||d.name===Rv)continue;const h=o.get(d.toolUseId),x=p.at??(h==null?void 0:h.at)??null,v=d.name||(h==null?void 0:h.name)||"tool",w=a.find(m=>m.source==="delegate"&&m.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:YM(d.ok?d.output:d.error??d.output)}},d.ok||(w.tone="critical");continue}const b=d.approval?xh(d):(n==null?void 0:n.get(d.toolUseId))??xh(d);if(b){a.push({id:d.toolUseId,tool:v,title:"Approval",renderer:"envelope",props:{approvalId:b},at:x,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(v))continue;const j=ik(d.output);if(d.ok===!1){a.push({id:d.toolUseId,tool:v,title:ts(v),renderer:"structured",props:{value:d.error??j??null,failed:!0},at:x,tone:"critical",source:"fallback",substantial:!1});continue}qM(j)&&(c+=1);const g=l.get(v);if(g){const m=U0(g,j),{renderer:k}=m;let{props:S}=m;if(k==="preview"){const N=S,C=N.target??(N.awaiting&&(i!=null&&i.has(Ai(N.awaiting)))?N.awaiting:null);if(C===null)continue;S={...N,target:C,awaiting:null};const T=Ai(C);a=a.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&Ai(E.props.target)===T))}a.push({id:d.toolUseId,tool:v,title:g.title??ts(v),renderer:k,props:S,at:x,source:"descriptor",substantial:gh(k,S)});continue}const y={value:Sm(j)?{input:h==null?void 0:h.input,output:j}:j};e$("structured",y)&&a.push({id:d.toolUseId,tool:v,title:ts(v),renderer:"structured",props:y,at:x,source:"fallback",substantial:gh("structured",y)})}for(const p of a)p.source==="descriptor"&&p.renderer==="preview"&&(p.props={...p.props,changes:c});return XM(a)}const Pv="forAgent";function ik(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(Pv in e))return e;const{[Pv]:t,...n}=e;return n}function XM(e){if(e.length<=Tv)return e;const t=e.length-Tv;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function ZM(e,t,n){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:l}=t,o=typeof r=="string"&&Rc(r)?r:"structured";return{id:e,tool:mh,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:o,props:o==="structured"&&!Rc(String(r))?{value:l}:l,at:n,substantial:!0,source:"canvas"}}function e$(e,t){const n=t??{};return!!(n.failed===!0||gh(e,t)||km(n.value).kind==="error")}function gh(e,t){const n=t??{};switch(e){case"timeseries":return da(n.points)>0;case"bars":return da(n.bars)>0;case"keyvalue":return da(n.pairs)>0;case"document":return!!n.text||!!n.src;case"diff":return!!n.diff;case"terminal":return!!n.output||!!n.command;case"image":return!!n.artifactId;case"preview":return!!n.target;case"envelope":return!0;case"table":return(Array.isArray(n.groups)?n.groups:[]).some(i=>da(i.rows)>0);default:return Sm(n.value)?!0:n.failed===!0?!1:oM(n.value)}}function da(e){return Array.isArray(e)?e.length:0}function xh(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const n=ok(t,0);if(n)return n}return null}function t$(e,t,n={}){var a,c;const r=e.flatMap(u=>u.blocks),i=r.find(u=>u.type==="tool_use"&&u.id===t);if((i==null?void 0:i.type)!=="tool_use")return null;const l=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),o=(a=n.redactInputOf)!=null&&a.has(i.name)?lk(i.input):i.input;return{id:t,tool:i.name,title:ts(i.name),renderer:"structured",props:{value:{input:o,...(l==null?void 0:l.type)==="tool_result"?{status:((c=l.approval)==null?void 0:c.state)??(l.ok?"completed":"failed"),output:l.output,...l.error?{error:l.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const n$=new Set(["value","text","password","secret","code"]);function lk(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=n$.has(n)&&typeof r=="string"?"— withheld —":lk(r);return t}function ok(e,t){if(t>3||e===null||typeof e!="object")return null;const n=e,r=n.reason,i=n.actionId??n.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const l of Object.values(n)){const o=ok(l,t+1);if(o)return o}return null}function ts(e){const t=e.split(".");return t.length===1?zt(e):t.map(n=>zt(n)).join(" · ")}function ak({name:e,mime:t,sizeBytes:n,thumbnail:r,state:i,error:l,onOpen:o,onRemove:a,size:c="md"}){const u=bm(t,e),p=[Tr[u],Rn(n)].filter(Boolean).join(" · "),d=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wb-file-visual","data-family":u,children:r?s.jsx("img",{src:r,alt:""}):s.jsx(Em,{family:u})}),s.jsxs("span",{className:"wb-file-text",children:[s.jsx("span",{className:"wb-file-name",title:e,children:e}),s.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":p})]})]});return s.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?l:void 0,children:[o?s.jsx("button",{type:"button",className:"wb-file-open",onClick:o,"aria-label":`Open ${e}`,children:d}):s.jsx("span",{className:"wb-file-open",children:d}),a?s.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:a,children:s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:s.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function Em({family:e}){const t={width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"image":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),s.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),s.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),s.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),s.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),s.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"})]})}}function s$(e){const t=r$(e);if(!t)return null;const n=Ad(t.diff);if(n!==null)return{kind:"diff",diff:n};const r=Ad(t.command),i=Ad(t.plain),l=Rd(t.exitCode);return r!==null&&(i!==null||l!==null||Rd(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:l,elapsedMs:Rd(t.elapsedMs)}:null}function Ad(e){return typeof e=="string"&&e.trim()!==""?e:null}function Rd(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function r$(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Iv="offer:",ck="owner:interjection";function i$(e){return e===ck}function l$(e){if(typeof e!="string"||!e.startsWith(Iv))return null;const t=e.slice(Iv.length).trim();return t===""?null:t}function uk({messages:e,live:t,now:n,onOpen:r,working:i=!1,partial:l=null,agents:o,speakers:a,coordinatorId:c,workingAs:u,onOpenFile:p,children:d,agentName:h,emptyHint:x,empty:v,plain:w=!1,workingLine:b,runs:j}){var S,N;const g=f.useRef(null);f.useEffect(()=>{var C;(C=g.current)==null||C.scrollIntoView({block:"end"})},[e.length,t.length,i,l==null?void 0:l.text.length,l==null?void 0:l.thinking.length,!!d]);const y=l&&!l.settled&&(l.text!==""||l.thinking!==""),m=e.filter(C=>(C.blocks??[]).some(m$)),k=h$(m,j??[]);return s.jsx(D0.Provider,{value:o??a??[],children:s.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[m.length===0&&t.length===0?v??s.jsx("p",{className:"wb-chat-empty",children:x}):null,m.map((C,T)=>{const E=C.speaker??null,_=a?E==="owner"||E===null&&C.role==="user":C.role==="user",F=a&&E==="room",O=a&&E&&E!=="owner"&&E!=="room"?a.find(U=>U.id===E)??null:null,A=m[T-1],D=T===0||(a?((A==null?void 0:A.speaker)??null)!==E:A.role!==C.role);if(F)return s.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(C.blocks??[]).filter(U=>U.type==="text").map((U,X)=>s.jsx("span",{children:U.text},X))},C.id);const q=(C.blocks??[]).filter(U=>U.type==="approval_result");if(q.length>0)return s.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:q.map((U,X)=>s.jsx(g$,{block:U},X))},C.id);const V=C.role==="user"&&i$(E),M=C.role==="user"?l$(E):null;if(M){const U=(C.blocks??[]).filter(X=>X.type==="text").map(X=>X.text).join(`
95
- `);return s.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:s.jsx("div",{className:"wb-bubble wb-bubble-offer",title:U,children:M})},C.id)}const z=a&&O&&C.role==="user"?f$(C):null;if(z){const U=m.slice(T+1).find(Z=>Z.role==="assistant"&&Z.speaker&&Z.speaker!==O.id),X=U!=null&&U.speaker?a.find(Z=>Z.id===U.speaker):void 0;return s.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[s.jsxs("summary",{children:[O.name," asked ",(X==null?void 0:X.name)??"a member",z.request?`: ${z.request.length>120?`${z.request.slice(0,119)}…`:z.request}`:""]}),z.request?s.jsx("p",{children:z.request}):null]},C.id)}const $=k.get(C.id)??null;return s.jsxs("div",{className:"wb-msg","data-role":_||V?"user":"assistant",children:[V?s.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,D&&!_&&!V?s.jsxs("div",{className:"wb-msg-who",children:[O&&a?s.jsx(Xt,{agents:a,id:O.id,size:"sm"}):null,s.jsx("span",{children:O?O.name:h??"Assistant"}),O&&c===O.id?s.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null]}):null,Mv(C).length>0?s.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:Mv(C).map(U=>s.jsx("span",{role:"listitem",children:s.jsx(ak,{name:U.filename??"Untitled file",mime:U.mime,sizeBytes:U.sizeBytes,thumbnail:LI(U.mime)?Ur(U.artifactId):null,...p?{onOpen:()=>p(U)}:{}})},U.artifactId))}):null,(C.blocks??[]).map((U,X)=>{const Z=c$(C.blocks??[],X,e);if(Z==="inside")return null;if(Z)return s.jsx(u$,{refusals:Z.refusals},X);if(U.type==="thinking")return w||U.text.trim()===""?null:s.jsx(vh,{text:U.text},X);if(U.type==="text")return U.text.trim()===""?null:_?s.jsx("div",{className:"wb-bubble",children:U.text},X):s.jsx("div",{className:"wb-bubble","data-rich":"true",children:s.jsx(cr,{text:U.text})},X);if(U.type==="attachment")return null;if(U.type==="tool_use"){if(w)return null;const fe=dk(e,U.id),ve=fe?j$(fe):null;return s.jsx(jh,{label:ve&&!(fe!=null&&fe.delegation)?`Approval · ${U.name}`:ts(U.name),tool:U.name,ok:(fe==null?void 0:fe.ok)??null,running:fe===null,...ve?{status:ve.status,waiting:ve.waiting,approval:!0}:{},gist:Cm(U.name,U.input),body:fe?s$(fe.output):null,opens:!0,onOpen:()=>r(U.id)},X)}return null}),$?s.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:p$($)}):null]},C.id)}),y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[((S=m.at(-1))==null?void 0:S.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??h??"Assistant"}):null,l.thinking!==""&&!w?s.jsx(vh,{text:l.thinking,live:l.text==="",seconds:d$(l.thinkingStartedAt,l.textStartedAt??n)}):null,l.text!==""?s.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[s.jsx(cr,{text:l.text}),s.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null]}):null,i&&t.length===0&&!y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"working",children:[((N=m.at(-1))==null?void 0:N.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??h??"Assistant"}):null,s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[b??`${u??h??"The agent"} is working`,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})]}):null,t.map(C=>s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx(jh,{label:ts(C.name),tool:C.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((n-C.startedAt)/1e3)),opens:!1,onOpen:()=>r(C.toolUseId)})},C.toolUseId)),d,s.jsx("div",{ref:g})]})})}function o$(e){var t,n;return((n=(t=/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:n.trim())||null}const a$="delegation refused:";function c$(e,t,n){const r=l=>{const o=e[l];if(!o||o.type!=="tool_use"||o.name!==Tc)return null;const a=dk(n,o.id);if(!a||a.ok!==!1)return null;const c=typeof a.error=="string"?a.error:String(a.error??"");if(!c.trimStart().startsWith(a$))return null;const u=o.input??{};return{target:typeof u.agent=="string"&&u.agent!==""?u.agent:"a colleague",message:c}};if(!r(t))return null;if(r(t-1))return"inside";const i=[];for(let l=t;;l+=1){const o=r(l);if(!o)break;i.push(o)}return i.length<2?null:{refusals:i}}function u$({refusals:e}){const[t,n]=f.useState(!1),r=e.map(a=>o$(a.message)).find(a=>a!==null)??null,i=e.map(a=>a.target),l=i.slice(0,3),o=`Delegation refused ${e.length} times: ${l.join(", ")}${i.length>l.length?", …":""}`+(r?` (allowed: ${r})`:"");return s.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>n(a=>!a),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:o}),s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("div",{className:"wb-refusals-list",children:e.map((a,c)=>s.jsxs("div",{className:"wb-refusal",children:[s.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsxs("span",{className:"wb-tool-label",children:[ts(Tc)," · ",a.target]}),s.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),s.jsx("p",{className:"wb-refusal-why",children:a.message})]},c))}):null]})}function d$(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function vh({text:e,live:t=!1,seconds:n=null}){const[r,i]=f.useState(!1),l=t?`Thinking${n!==null&&n>0?` · ${n}s`:""}`:n!==null&&n>0?`Thought for ${n}s`:"Thoughts";return s.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[s.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(o=>!o),children:[t?s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}):s.jsx(Oe,{name:"thought"}),s.jsx("span",{children:l}),s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]}),r?s.jsx("div",{className:"wb-thought-text",children:s.jsx(cr,{text:e})}):null]})}function f$(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",n=/You are a member of the group "[^"]*"\. @([\w-]+), the coordinator, asks you now:\n\n([\s\S]*?)(?:\n\nAnswer for the room|$)/.exec(t);return n?{handle:n[1],request:n[2].trim()}:null}function Mv(e){return(e.blocks??[]).filter(t=>t.type==="attachment")}function h$(e,t){const n=t.filter(o=>o.startedAt!==null&&o.finishedAt!==null),r=(o,a)=>a.at!==""&&a.at>=o.startedAt&&a.at<=o.finishedAt,i=(o,a)=>o!==a&&o.startedAt>=a.startedAt&&o.finishedAt<=a.finishedAt&&(o.startedAt>a.startedAt||o.finishedAt<a.finishedAt),l=new Map;for(const o of n){if(o.stopped!=="max_turns"&&o.stopped!=="max_tokens"||o.noticed!==!0||o.runId===null)continue;let a=null;for(const c of e)c.role!=="assistant"||!r(o,c)||(a=c);a===null||n.some(c=>i(c,o)&&r(c,a))||l.has(a.id)||l.set(a.id,o)}return l}function p$(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 m$(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function g$({block:e}){const[t,n]=f.useState(!1),r=e.state==="succeeded";return s.jsxs("div",{className:"wb-approval","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":r,"aria-expanded":t,onClick:()=>n(i=>!i),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":r?"true":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":ts(e.name)}),s.jsx("span",{className:"wb-tool-elapsed",children:e.state}),s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("pre",{className:"wb-approval-output mono",children:x$(e.output)}):null]})}function x$(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const v$=40;function j$(e){var n,r;if(((n=e.delegation)==null?void 0:n.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(xh(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 jh({label:e,tool:t,ok:n,running:r,elapsed:i,opens:l,onOpen:o,status:a,waiting:c=!1,approval:u=!1,gist:p=null,body:d=null}){const[h,x]=f.useState(!1),v=s.jsxs(s.Fragment,{children:[r?s.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):s.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":n===!1?"false":"true","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e}),p?s.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:p}):null,i===void 0?null:s.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),a||n===!1?s.jsx("span",{className:"wb-tool-elapsed",children:a??"failed"}):null]}),w={"data-ok":n===null?void 0:n,"data-running":r,"data-gist":p?!0:void 0,"data-approval":u||void 0};return d?s.jsxs("div",{className:"wb-toolcall","data-open":h||void 0,children:[s.jsxs("div",{className:"wb-tool","data-split":"true",...w,children:[s.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":h,onClick:()=>x(b=>!b),children:[s.jsx(Oe,{name:"chevron",className:"wb-tool-chevron"}),v]}),l?s.jsxs(yc,{children:[s.jsx(wc,{asChild:!0,children:s.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:o,children:s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})})}),s.jsx(bc,{children:s.jsxs(kc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),h?s.jsx(y$,{body:d,onOpen:l?o:null}):null]}):l?s.jsxs(yc,{children:[s.jsx(wc,{asChild:!0,children:s.jsxs("button",{className:"wb-tool",...w,onClick:o,children:[v,s.jsx(Oe,{name:"arrow",className:"wb-tool-arrow"})]})}),s.jsx(bc,{children:s.jsxs(kc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):s.jsx("span",{className:"wb-tool","data-static":"true",...w,children:v})}function y$({body:e,onOpen:t}){const n=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return s.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:s.jsx(Cc,{text:e.diff,limit:v$,...n?{more:n}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:w$(e.elapsedMs)].filter(i=>i!==null);return s.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[s.jsxs("div",{className:"wb-tool-command",children:[s.jsx("code",{className:"mono",children:e.command}),r.length>0?s.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?s.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function w$(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function dk(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}const fk="approval-dock";function b$(){var t;const e=document.getElementById(fk);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const k$=["workspace","cwd","workdir","root"];function S$({approvals:e,timezone:t,now:n,version:r,onDecided:i,onSay:l,onOpenFull:o}){const[a,c]=f.useState([]),u=e.filter(h=>!a.includes(h.approvalId)),p=u[0];if(!p)return null;const d=h=>c(x=>x.includes(h)?x:[...x,h]);return s.jsx(N$,{item:p,count:u.length,timezone:t,now:n,version:r,onSettled:h=>{d(p.approvalId),h&&i(h)},onSay:l,onOpenFull:()=>o(p.toolUseId)},p.approvalId)}function N$({item:e,count:t,timezone:n,now:r,version:i,onSettled:l,onSay:o,onOpenFull:a}){var C;const[c,u]=f.useState(null),[p,d]=f.useState(null),[h,x]=f.useState(null),[v,w]=f.useState("");f.useEffect(()=>{let T=!1;return R.approval(e.approvalId).then(E=>{T||(u(E),E.state!=="pending"&&l(E))}).catch(E=>{T||d(E instanceof de?E.message:String(E))}),()=>{T=!0}},[e.approvalId,i]);const b=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;f.useEffect(()=>{b&&c&&l({...c,state:"expired"})},[b]);const{values:j,controls:g}=wm(c==null?void 0:c.choices),y=(T,E)=>{const _=v.trim();x(T),d(null),(j&&T==="approve"?R.decide(e.approvalId,T,E,j):R.decide(e.approvalId,T,E)).then(F=>{l(F.action),_&&o(_)}).catch(F=>{d(F instanceof de?F.message:String(F)),x(null)})},m=h!==null||c===null||c.state!=="pending",k=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,S=c?Cm(c.tool,c.canonicalArgs)??E$(c.preview):null,N=c?C$(c):null;return s.jsxs("section",{id:fk,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?s.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,s.jsx("strong",{children:c?ts(c.tool):"Loading the request…"}),e.askedBy?s.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),S||N?s.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[S?s.jsx("code",{className:"wb-dock-gist",children:S}):null,N?s.jsxs("span",{className:"wb-dock-where",children:["in ",s.jsx("span",{className:"mono",children:N})]}):null]}):null,g?s.jsx("div",{className:"wb-dock-section",children:g}):null,s.jsx(re,{message:p}),s.jsx("div",{className:"wb-dock-section",children:s.jsx("input",{className:"wb-dock-instead",value:v,onChange:T=>w(T.target.value),onKeyDown:T=>{T.key==="Enter"&&T.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:h!==null})}),s.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[s.jsxs("span",{className:"wb-dock-meta",children:[c?s.jsxs(s.Fragment,{children:["Expires ",Ie(c.expiresAt,n)," · "]}):null,s.jsx("button",{type:"button",className:"wb-link",onClick:a,children:"See the full request on the Canvas"})]}),s.jsx(P,{variant:"ghost",size:"sm",disabled:m,onClick:()=>y("reject"),children:h==="reject"?"Rejecting…":"Reject"}),k?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",size:"sm",disabled:m,onClick:()=>y("approve","conversation"),children:"Auto: this conversation"}),s.jsx(P,{size:"sm",disabled:m,onClick:()=>y("approve","always"),children:"Always: this agent"})]}):null,s.jsx(P,{variant:"good",size:"sm",disabled:m,onClick:()=>y("approve"),children:h==="approve"?"Approving…":k?"Allow once":"Approve"})]})]})}function C$(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const n of k$){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function E$(e){const t=(e??"").split(`
96
- `).map(n=>n.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const A$=2e3;function R$({conversationId:e,agentId:t,runId:n=null,result:r=null,waiting:i=null,agents:l=[]}){const o=r!==null,[a,c]=f.useState(o),u=!a||i!==null,{data:p,error:d}=se(()=>Le.conversation(e),[e,a,(i==null?void 0:i.approvalId)??null],u?A$:void 0),h=(p==null?void 0:p.runs)??[],x=n===null?null:h.find(m=>m.runId===n)??null,v=o||i===null&&(n!==null?x!==null&&x.finishedAt!==null:h.length>0&&h.every(m=>m.finishedAt!==null));f.useEffect(()=>{v&&c(!0)},[v]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":v?"done":"working",b=l.find(m=>m.id===t)??null,j=(b==null?void 0:b.name)??(p==null?void 0:p.agentId)??t,g=(p==null?void 0:p.messages)??[],y=(r==null?void 0:r.text)??T$(g);return s.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":w,children:[s.jsxs("header",{className:"wb-delegate-head",children:[s.jsx(Xt,{agents:l,id:t}),s.jsxs("div",{className:"wb-delegate-who",children:[s.jsx("strong",{children:j}),s.jsx("span",{className:"wb-delegate-status","data-status":w,role:"status",children:w==="working"?s.jsxs(s.Fragment,{children:["Working",s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]}):w==="waiting"?"Waiting for your approval":w==="failed"?"Failed":"Done"})]})]}),d?s.jsx("p",{className:"muted",children:d}):null,s.jsx("div",{className:"wb-delegate-work",children:g.map((m,k)=>s.jsx("div",{className:"wb-delegate-turn",children:(m.blocks??[]).map((S,N)=>{if(S.type==="thinking")return S.text.trim()===""?null:s.jsx(vh,{text:S.text},N);if(S.type==="tool_use"){const C=I$(P$(g,S.id));return s.jsx(jh,{label:ts(S.name),tool:S.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:Cm(S.name,S.input),opens:!1,onOpen:()=>{}},N)}return null})},m.id??k))}),y?s.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:s.jsx(cr,{text:y})}):w==="working"||w==="waiting"?s.jsxs("p",{className:"muted",children:[j," has not answered yet."]}):null,s.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?s.jsx(P,{variant:"accent",onClick:()=>b$(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,s.jsx("a",{className:"ui-btn",href:Fe(t||(p==null?void 0:p.agentId)||"",e),children:"Open this conversation"})]})]})}function T$(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.role!=="assistant")continue;const r=(n.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
97
-
98
- `);if(r!=="")return r}return null}function P$(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function I$(e){var n;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(n=e.approval)==null?void 0:n.state;return t==="pending"?{running:!1,ok:null,waiting:!0,status:"waiting approval"}:t==="approved"||t==="executing"?{running:!0,ok:null,waiting:!1,status:"running"}:t==="succeeded"?{running:!1,ok:!0,waiting:!1,status:void 0}:t?{running:!1,ok:!1,waiting:!1,status:t}:{running:!1,ok:e.ok,waiting:!1,status:void 0}}const $v=1024*1024;function M$({files:e,agentId:t,root:n,revision:r}){const[i,l]=f.useState({kind:"dir",path:""});return f.useEffect(()=>l({kind:"dir",path:""}),[e.plugin,t]),s.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?s.jsx($$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:l}):s.jsx(_$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:l})})}function hk({root:e,path:t,go:n}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((l,o)=>({label:l,path:r.slice(0,o+1).join("/")}))];return s.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((l,o)=>{const a=o===i.length-1;return s.jsxs("span",{className:"wb-files-crumb",children:[o>0?s.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,a?s.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:l.label}):s.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>n({kind:"dir",path:l.path}),children:l.label})]},l.path)})})}function $$({files:e,agentId:t,root:n,path:r,revision:i,go:l}){const[o,a]=f.useState(null),[c,u]=f.useState(null),[p,d]=f.useState(!1),[h,x]=f.useState(null);f.useEffect(()=>{let b=!1;return u(null),R.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(j=>{b||a(j.data)}).catch(j=>{b||u(j instanceof Error?j.message:String(j))}),()=>{b=!0}},[e.plugin,e.list,t,r,i]),f.useEffect(()=>x(null),[r]);const v=async()=>{d(!0),x(null);try{const b=await fetch(R.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!b.ok){const m=await b.json().catch(()=>null);x((m==null?void 0:m.error)??"The archive could not be made.");return}const j=await b.blob(),g=URL.createObjectURL(j),y=document.createElement("a");y.href=g,y.download=`${r===""?n:r.split("/").at(-1)}.zip`,y.click(),window.setTimeout(()=>URL.revokeObjectURL(g),1e4)}catch{x("The archive could not be made.")}finally{d(!1)}},w=o&&o.path===r?o.entries:null;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(hk,{root:n,path:r,go:l}),s.jsx(rl,{}),s.jsx(P,{size:"sm",onClick:()=>void v(),disabled:p||w===null||w.length===0,children:p?"Packing…":"Download as archive"})]}),h?s.jsx(K,{tone:"warning",role:"alert",children:h}):null,c?s.jsx(K,{tone:"critical",role:"alert",children:c}):null,w===null?c?null:s.jsx(le,{children:"Reading the folder…"}):w.length===0?s.jsx(le,{children:r===""?s.jsxs(s.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",s.jsx("a",{href:Lr,children:"Files library"})," and mention it here."]}):"This folder is empty."}):s.jsx(Ht,{children:w.map(b=>s.jsx(rn,{href:"#",onClick:()=>l({kind:b.kind,path:b.path}),lead:s.jsx(D$,{kind:b.kind}),title:s.jsxs("span",{className:"mono",children:[b.name,b.kind==="dir"?"/":""]}),side:b.kind==="file"?Rn(b.bytes):void 0},b.path))}),o&&o.path===r&&(o.skipped>0||o.truncated)?s.jsxs("p",{className:"wb-files-note",children:[o.truncated?`Only the first ${o.entries.length} entries are shown. `:"",o.skipped>0?`${o.skipped} ${o.skipped===1?"entry is":"entries are"} not shown: symbolic links and protected paths are never read.`:""]}):null]})}function _$({files:e,agentId:t,root:n,path:r,revision:i,go:l}){const[o,a]=f.useState(null),[c,u]=f.useState(null),[p,d]=f.useState(!1);f.useEffect(()=>{let j=!1;return u(null),R.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(g=>{j||a(g.data)}).catch(g=>{j||u(g instanceof Error?g.message:String(g))}),()=>{j=!0}},[e.plugin,e.stat,t,r,i]);const h=o&&o.path===r?o:null,x=h?`${h.bytes}-${Math.round(h.mtimeMs)}`:"",v=h?R.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v:x}):"",w=R.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),b=(h==null?void 0:h.type)==="text"&&h.bytes<=$v;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(hk,{root:n,path:r,go:l}),s.jsx(rl,{}),b?s.jsx(P,{size:"sm","aria-pressed":p,onClick:()=>d(j=>!j),children:"Wrap"}):null,s.jsx(Bn,{size:"sm",href:w,download:(h==null?void 0:h.name)??r.split("/").at(-1),children:"Download"})]}),c?s.jsx(K,{tone:"critical",role:"alert",children:c}):null,h===null?c?null:s.jsx(le,{children:"Reading the file…"}):h.type==="image"?s.jsx("figure",{className:"wb-files-picture",children:s.jsx("img",{src:v,alt:h.name})}):h.type==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:v,type:"application/pdf","aria-label":h.name,children:s.jsx(K,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):b?s.jsx(O$,{src:v,wrap:p}):s.jsxs(s.Fragment,{children:[s.jsx(K,{children:h.type==="text"?`This file is over ${Rn($v)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),s.jsx(At,{items:[{label:"Size",value:Rn(h.bytes)},{label:"Type",value:s.jsx("span",{className:"mono",children:h.mime})}]})]})]})}function O$({src:e,wrap:t}){const[n,r]=f.useState(null),[i,l]=f.useState(!1);return f.useEffect(()=>{let o=!1;return l(!1),fetch(e,{credentials:"same-origin"}).then(async a=>{if(!a.ok)throw new Error(String(a.status));const c=await a.text();o||r(c)}).catch(()=>{o||l(!0)}),()=>{o=!0}},[e]),i?s.jsx(K,{tone:"critical",children:"The file could not be read."}):n===null?s.jsx(le,{children:"Reading the file…"}):n===""?s.jsx(le,{children:"This file is empty."}):s.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:n})}function D$({kind:e}){return s.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:e==="dir"?s.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}const L$=3,F$=152,U$=104,B$=100,z$=2,_v=5;function W$({renderables:e,activeId:t,onActivate:n,timezone:r,onDecided:i,onChangeAgent:l,face:o,descriptors:a,grantedTools:c,agentName:u,maxTabs:p,browserPanel:d,agents:h,onClose:x,loading:v=!1}){const[w,b]=V$(p);if(e.length===0)return s.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[s.jsx("div",{className:"wb-canvas-tabs",ref:w,"aria-hidden":"true",children:s.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),s.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:v?null:s.jsxs("div",{className:"wb-empty",children:[o?s.jsx("span",{className:"wb-empty-face",children:o}):null,s.jsx("p",{className:"ui-empty wb-empty-line",children:q$(u,Q$(a??[],c??[]))})]})})]});const j=e.some(m=>m.id===t)?t:e[e.length-1].id,{shown:g,hidden:y}=H$(e,j,b);return s.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:s.jsxs(GP,{value:j,onValueChange:n,className:"contents",children:[s.jsxs("div",{className:"wb-canvas-tabs",ref:w,children:[s.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),s.jsx(YP,{className:"wb-tabstrip","aria-label":"Canvas",children:g.map(m=>s.jsxs("div",{className:"wb-tab-item",children:[s.jsxs(qP,{value:m.id,className:"wb-tab","data-tone":m.tone,onKeyDown:k=>{k.key==="Delete"&&x&&Ov(m)&&(k.preventDefault(),x(m.id))},children:[m.tone==="warning"||m.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":m.tone,"aria-hidden":"true"}):null,s.jsx("span",{className:"wb-tab-text",children:m.title})]}),x&&Ov(m)?s.jsx("button",{className:"wb-tab-close","aria-label":`Close ${m.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>x(m.id),children:"×"}):null]},m.id))}),s.jsx(K$,{items:y,onActivate:n,timezone:r})]}),e.map(m=>s.jsx(QP,{value:m.id,className:"wb-canvas-body","data-renderer":m.source==="descriptor"&&m.renderer==="preview"?"preview":void 0,"data-dense":X$.has(m.renderer)?"true":void 0,children:s.jsxs("section",{className:"ui-panel","data-flush":m.source==="descriptor"&&m.renderer==="preview"?"true":void 0,children:[m.source!=="browser"&&m.source!=="files"&&!(m.source==="descriptor"&&m.renderer==="preview")?s.jsxs("header",{className:"ui-panel-head",children:[s.jsx("h2",{className:"ui-panel-title",children:m.title}),s.jsx("span",{className:"ui-panel-tool mono",children:m.tool})]}):null,m.tone==="critical"?s.jsxs("p",{className:"muted",children:["Recorded tool failure",m.at?` · ${new Date(m.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,m.source==="browser"?d:m.source==="profile"?s.jsx(IM,{...m.props,...l?{onChange:l}:{}}):m.source==="artifact"?s.jsx(WM,{...m.props}):m.source==="files"?s.jsx(M$,{...m.props}):m.source==="delegate"?s.jsx(R$,{...m.props,agents:h??[]}):s.jsx(PM,{renderer:m.renderer,props:m.props,timezone:r,onDecided:i})]})},m.id))]})})}function Ov(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function V$(e){const[t,n]=f.useState(_v),r=f.useRef(null);return[f.useCallback(l=>{var a;if((a=r.current)==null||a.disconnect(),r.current=null,!l||e!==void 0||typeof ResizeObserver>"u")return;const o=()=>{const c=l.clientWidth;if(c===0)return;const u=Math.floor((c-B$-U$)/F$);n(Math.max(z$,Math.min(_v,u)))};o(),r.current=new ResizeObserver(o),r.current.observe(l)},[e]),e??t]}function H$(e,t,n){const r=new Set(e.filter(l=>l.id===t||l.source==="approval"||l.pinned===!0).map(l=>l.id)),i=new Set(r);for(let l=e.length-1;l>=0&&i.size<n;l-=1)i.add(e[l].id);return{shown:e.filter(l=>i.has(l.id)),hidden:e.filter(l=>!i.has(l.id))}}function K$({items:e,onActivate:t,timezone:n}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return s.jsxs(sm,{modal:!1,children:[s.jsx(rm,{asChild:!0,children:s.jsxs("button",{className:"wb-tab wb-tab-more","data-tone":r??void 0,"aria-label":`${e.length} more ${e.length===1?"view":"views"} in this conversation`,children:[r?s.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,s.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),s.jsx(Oe,{name:"chevron-down"})]})}),s.jsx(im,{children:s.jsxs(lm,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[s.jsx(om,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>s.jsxs(sh,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[s.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),s.jsx("span",{className:"ui-menu-note mono",children:G$(i.at,n)??i.tool})]},i.id))]})})]})}function G$(e,t){if(!e)return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit"}).format(n)}const Y$={timeseries:"charts",table:"tables",bars:"comparisons",keyvalue:"figures",document:"pages it read",diff:"diffs",terminal:"command output",image:"pictures",preview:"running apps",envelope:"drafts",structured:"results"};function q$(e,t){const n=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>Y$[i.renderer]??"results"))].slice(0,3);return r.length>0?`${n} lands here: ${r.join(", ")}.`:`${n} lands here.`}function Q$(e,t){const n=new Set(t),r=new Set,i=e.filter(c=>{if(!n.has(c.tool))return!1;const u=J$(c);return r.has(u)?!1:(r.add(u),!0)}),l=new Set,o=i.filter(c=>l.has(c.renderer)?!1:(l.add(c.renderer),!0)),a=i.filter(c=>!o.includes(c));return[...o,...a].slice(0,L$)}function J$(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 X$=new Set(["table","diff","files"]),Z$=3.5*6e4,e_=2e3;function t_(e,t,n={}){const[r,i]=f.useState({served:new Set,live:new Set,scope:t}),l=f.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};l.current=u.served,i(u)}const o=n.check??R.previewCheck,a=n.everyMs??e_,c=e.map(u=>`${Ai(u)}@${u.at??""}`).join("|");return f.useEffect(()=>{const u=new Map;for(const x of e){const v=Ai(x);if(l.current.has(v))continue;const w=x.at===null?Number.NaN:Date.parse(x.at),b=Number.isNaN(w)?0:w+Z$,j=u.get(v);(!j||b>j.until)&&u.set(v,{plugin:x.plugin,name:x.name,until:b})}if(u.size===0)return;let p=!1,d;const h=async()=>{const x=Date.now();for(const[v,w]of[...u]){const b=await o(w.plugin,w.name).catch(()=>null);if(p)return;const j=x<=w.until;b!=null&&b.ok?(u.delete(v),i(g=>{const y={served:new Set(g.served).add(v),live:j?new Set(g.live).add(v):g.live,scope:g.scope};return l.current=y.served,y})):j||u.delete(v)}!p&&u.size>0&&(d=setTimeout(()=>void h(),a))};return h(),()=>{p=!0,d!==void 0&&clearTimeout(d)}},[c,t,o,a]),r}const yh="workspace-files";function n_(e){let t=0;for(const n of e)for(const r of n.blocks??[]){if(r.type!=="tool_result"||r.ok===!1)continue;const i=r.output;if(i===null||typeof i!="object"||Array.isArray(i))continue;const{diff:l,path:o}=i;typeof l=="string"&&l.trim()!==""&&typeof o=="string"&&o!==""&&(t+=1)}return t}function s_(e){const[t,n]=f.useState(null);return f.useEffect(()=>{if(n(null),!e)return;let r=!1;return(async()=>{var l;const i=await R.pages();for(const o of Array.isArray(i==null?void 0:i.files)?i.files:[]){const a=await R.pageQuery(o.plugin,o.workspace,{agent:e}).catch(()=>null),c=(l=a==null?void 0:a.data)==null?void 0:l.workspace;if(c&&typeof c.name=="string")return{files:o,agentId:e,root:c.name}}return null})().then(i=>{r||n(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function r_(e,t){return{id:yh,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 wh(e){return`agent-properties:${e}`}function i_(e){return{id:wh(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function l_(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 pk({progress:e}){return s.jsxs(G,{gap:"sm",children:[s.jsx("span",{role:"status",children:l_(e)}),s.jsx(PI,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function o_(e,t,n,r){const i=e.width||1,l=e.height||1,o=t.pageScaleFactor||1,a=(n-e.left)*(t.deviceWidth/i)/o,c=((r-e.top)*(t.deviceHeight/l)-t.offsetTop)/o,u=(p,d)=>Math.max(0,Math.min(Math.round(p),Math.round(d)));return{x:u(a,t.deviceWidth),y:u(c,t.deviceHeight)}}function Td(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function Dv(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const a_=4e3;function c_(e){return e.replace(/\r\n?/g,`
99
- `).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,a_)}const u_=["left","middle","right"],d_=33;function f_(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function h_(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const n=t.getUint16(1);if(e.byteLength<3+n)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,n))),jpeg:new Blob([new Uint8Array(e,3+n)],{type:"image/jpeg"})}}catch{return null}}function p_(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function m_({sessionId:e,csrf:t,onGiveBack:n,connect:r}){const[i,l]=f.useState("connecting"),[o,a]=f.useState(null),[c,u]=f.useState(!1),[p,d]=f.useState(null),[h,x]=f.useState(!1),[v,w]=f.useState(0),b=f.useRef(null),j=f.useRef(null),g=f.useRef(null),y=f.useRef({at:0});f.useEffect(()=>{const A=r??(V=>new WebSocket(V));let D=!0,q;try{q=A(p_())}catch{l("lost");return}return q.binaryType="arraybuffer",b.current=q,q.onopen=()=>q.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),q.onmessage=V=>{if(!D)return;if(typeof V.data!="string"){const z=h_(V.data);if(!z||(d($=>$&&f_($,z.metadata)?$:z.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(z.jpeg).then($=>{var X,Z,fe;const U=j.current;if(!D||!U){(X=$.close)==null||X.call($);return}(U.width!==$.width||U.height!==$.height)&&(U.width=$.width,U.height=$.height),(Z=U.getContext("2d"))==null||Z.drawImage($,0,0),(fe=$.close)==null||fe.call($)}).catch(()=>{});return}const M=JSON.parse(V.data);if(M.type==="driving"){l("driving"),a(null);return}(M.type==="refused"||M.type==="ended")&&(a(M.error??"The screen cannot be driven from here."),l("refused"))},q.onclose=()=>{D&&l(V=>V==="refused"?V:"lost")},q.onerror=()=>{D&&l(V=>V==="refused"?V:"lost")},()=>{D=!1,b.current=null;try{q.close()}catch{}}},[e,t,v,r]),f.useEffect(()=>()=>{clearTimeout(y.current.timer)},[]);const m=f.useCallback(A=>{const D=b.current;if(D)try{D.send(JSON.stringify({type:"input",input:A}))}catch{}},[]),k=A=>{var V;const D=j.current;if(!D||!p)return null;const q=(V=D.getBoundingClientRect)==null?void 0:V.call(D);return q?o_(q,p,A.clientX,A.clientY):null},S=A=>{const D=y.current,q=Date.now();clearTimeout(D.timer),D.timer=void 0;const V=D.at+d_-q;if(V<=0){D.at=q,D.pending=void 0,m(A);return}D.pending=A,D.timer=setTimeout(()=>{const M=y.current.pending;y.current.timer=void 0,y.current.pending=void 0,y.current.at=Date.now(),M&&m(M)},V)},N=()=>{const A=y.current;clearTimeout(A.timer),A.timer=void 0;const D=A.pending;A.pending=void 0,D&&(A.at=Date.now(),m(D))},C=A=>D=>{var M,z;const q=k(D);if(!q)return;A==="mousePressed"&&(D.preventDefault(),(z=(M=j.current)==null?void 0:M.focus)==null||z.call(M));const V={kind:"mouse",type:A,x:q.x,y:q.y,button:u_[D.button]??"left",clickCount:A==="mouseMoved"?0:Math.min(3,Math.max(1,D.detail||1)),modifiers:Td(D)};if(A==="mouseMoved"){S(V);return}N(),m(V)},T=A=>{const D=k(A);D&&(N(),m({kind:"wheel",x:D.x,y:D.y,deltaX:Math.round(A.deltaX),deltaY:Math.round(A.deltaY)}))},E=A=>A.ctrlKey||A.metaKey||A.altKey,_=A=>{var q,V;if(A.key==="Escape"&&E(A)){x(!1),(V=(q=A.target).blur)==null||V.call(q);return}if(A.preventDefault(),(A.metaKey||A.ctrlKey)&&(A.key==="v"||A.key==="V"))return;const D=Td(A);if(Dv(A.key)&&!E(A)){m({kind:"key",type:"char",key:A.key,code:A.code,text:A.key,modifiers:D});return}m({kind:"key",type:"keyDown",key:A.key,code:A.code,modifiers:D})},F=A=>{A.key==="Escape"&&E(A)||(A.preventDefault(),!((A.metaKey||A.ctrlKey)&&(A.key==="v"||A.key==="V"))&&(Dv(A.key)&&!E(A)||m({kind:"key",type:"keyUp",key:A.key,code:A.code,modifiers:Td(A)})))},O=A=>{var q;A.preventDefault();const D=c_(((q=A.clipboardData)==null?void 0:q.getData("text/plain"))??"");D!==""&&m({kind:"text",text:D})};return s.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[s.jsxs("div",{className:"hand-bar",children:[s.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",variant:h?"accent":"ghost","aria-pressed":h,onClick:()=>{var D,q,V,M;const A=!h;x(A),A?(q=(D=g.current)==null?void 0:D.focus)==null||q.call(D):(M=(V=g.current)==null?void 0:V.blur)==null||M.call(V)},children:"Keyboard"}),s.jsx(P,{size:"sm",variant:"accent",onClick:n,children:"Give it back"})]})]}),i==="lost"?s.jsxs(K,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",s.jsx(J,{align:"end",children:s.jsx(P,{size:"sm",variant:"accent",onClick:()=>{l("connecting"),w(A=>A+1)},children:"Reconnect"})})]}):null,i==="refused"&&o?s.jsx(K,{tone:"warning",role:"status",children:o}):null,s.jsx("div",{className:"hand-screen",children:c?s.jsx("canvas",{ref:j,className:"hand-picture",role:"img","aria-label":"The host browser, live","data-testid":"hand-picture",tabIndex:0,onMouseDown:C("mousePressed"),onMouseUp:C("mouseReleased"),onMouseMove:C("mouseMoved"),onWheel:T,onKeyDown:_,onKeyUp:F,onPaste:O,onContextMenu:A=>A.preventDefault()}):s.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),s.jsx("input",{ref:g,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:_,onKeyUp:F,onPaste:O,onBlur:()=>x(!1)})]})}function g_(e){return e==="darwin"?"this Mac":"this computer"}let Pd=null;function Am(){const[e,t]=f.useState(void 0);return f.useEffect(()=>{let n=!0;return Pd??(Pd=R.session().then(r=>r.platform,()=>{Pd=null})),Pd.then(r=>{n&&t(r)}),()=>{n=!1}},[]),g_(e)}function x_({embedded:e,timezone:t}={}){var c;const{data:n,error:r,reload:i}=se(()=>R.browser(),[],3e3),l=se(()=>R.session(),[]),o=(c=l.data)!=null&&c.platform?l.data.platform==="darwin":!0,a=!!l.data||!!l.error;return s.jsxs(an,{embedded:e,title:"Computer & browser",children:[s.jsx(re,{message:r}),!n||!a?s.jsx(le,{children:"Checking the host…"}):s.jsx(v_,{data:n,macOS:o,reload:i,timezone:t},JSON.stringify(n.settings??null))]})}function v_({data:e,macOS:t,reload:n,timezone:r}){var N,C,T;const[i,l]=f.useState(!1),[o,a]=f.useState(null),[c,u]=f.useState(!1),p=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,d=(p==null?void 0:p.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),h=d==="computer",x=(N=e.sessions)!=null&&N.length?e.sessions:e.session?[e]:[],v=x.length>0||e.busy,w=async E=>{l(!0),a(null);try{await E()}catch(_){a(_ instanceof Error?_.message:String(_))}finally{l(!1),n()}},b=E=>void w(()=>R.browserSettings(E)),j=e.permissions,g=d==="playwright"?e.browser:void 0,y=((C=g==null?void 0:g.install)==null?void 0:C.state)==="running",m=(g==null?void 0:g.engine)==="none",k=!!e.enabled&&!m&&!(g!=null&&g.problem)&&(!h||!(j!=null&&j.supported)||j.accessibility&&j.screenRecording),S=h?"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.":(g==null?void 0:g.engine)==="chrome"?"Ready. Agents work in their own browser, a separate Google Chrome profile. Your apps are never touched.":"Ready. Agents work in their own browser. Your apps are never touched.";return s.jsxs(G,{gap:"lg",children:[s.jsx(re,{message:o}),s.jsx(Y,{title:"Status",panel:!0,actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",disabled:i,onClick:()=>void w(()=>R.computerPermissions(!1)),children:"Check again"}),h&&!k&&(j!=null&&j.supported)?s.jsx(P,{size:"sm",variant:"accent",disabled:i||v,onClick:()=>void w(()=>R.computerPermissions(!0)),children:"Request macOS permissions"}):null,m||y?s.jsx(P,{size:"sm",variant:"accent",disabled:i||y,onClick:()=>void w(()=>R.browserInstall()),children:y?"Installing…":"Install Chromium"}):null]}),children:s.jsxs(G,{children:[e.enabled?m?s.jsxs(K,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",s.jsx("code",{children:"buddi browser install"})," on this machine."]}):g!=null&&g.problem?s.jsx(K,{tone:"warning",children:g.message}):k?s.jsx(K,{tone:"good",children:S}):s.jsx(K,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):s.jsx(K,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),h?j!=null&&j.supported?s.jsxs("ul",{className:"perm-list",children:[s.jsxs("li",{className:"perm-row",children:[s.jsx(pe,{tone:j.accessibility?"good":"warning",children:j.accessibility?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Accessibility"}),s.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),s.jsxs("li",{className:"perm-row",children:[s.jsx(pe,{tone:j.screenRecording?"good":"warning",children:j.screenRecording?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Screen Recording"}),s.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):j?s.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,((T=g==null?void 0:g.install)==null?void 0:T.state)==="running"?s.jsx(pk,{progress:g.install.progress}):g!=null&&g.install?s.jsx("p",{className:"muted",role:"status",children:g.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${g.install.line??"no reason given"}`}):null,g!=null&&g.headless&&!m?s.jsx("p",{className:"muted",children:"The agents’ browser runs headless on this machine, since it has no display. Watch it and take over from the conversation’s Canvas."}):null,h&&(j!=null&&j.message)?s.jsx("p",{className:"muted",children:j.message}):null,h&&(j!=null&&j.supported)&&!k?s.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),s.jsx(Y,{title:"Who is driving",panel:!0,actions:x.length>0?s.jsx(P,{variant:"danger",size:"sm",disabled:i,onClick:()=>void w(()=>R.browserControl("stop")),children:h?"Stop computer control":"Stop all browsers"}):void 0,children:x.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nobody right now. Ask an agent to open a website or one of the allowed apps, and you will see it working on that conversation’s Canvas."}):s.jsx("div",{className:"ui-list",children:x.map(E=>s.jsxs("a",{className:"ui-list-row",href:Fe(E.session.agentId,E.session.conversationId),children:[s.jsx(os,{id:E.session.agentId,name:E.session.agentId,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:E.session.task}),s.jsxs("span",{className:"ui-list-sub",children:[E.session.agentId,", ",E.busy?"working":E.state,", ",E.session.steps," of ",E.session.maxSteps," steps"]})]}),s.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},E.session.id))})}),p?s.jsxs(s.Fragment,{children:[s.jsx(Y,{title:"How agents get a screen",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?s.jsx(Id,{current:p.mode,value:"computer",disabled:i||v||!e.enabled,title:"Use my apps",body:"Agents work in your own windows, signed in as you, in the browser profile you choose below. One agent at a time. Releasing control leaves everything open.",onPick:()=>b({...p,mode:"computer"})}):null,s.jsx(Id,{current:p.mode,value:"playwright",disabled:i||v||!e.enabled,title:"Give agents their own browser",body:"A separate browser profile with its own tabs, one per conversation. Your apps are never touched.",onPick:()=>b({...p,mode:"playwright"})}),s.jsx(Id,{current:p.mode,value:"extension",disabled:i||v||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>b({...p,mode:"extension"})})]}),t?null:s.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),v?s.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,p.mode==="extension"?s.jsx(b_,{busy:i,timezone:r}):null]})}),t?s.jsx(Y,{title:"Apps agents may use",panel:!0,children:s.jsxs(G,{children:[p.mode!=="computer"?s.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,s.jsx(k_,{settings:p,disabled:i||v||!e.enabled,onChange:b,onAdd:()=>u(!0)}),s.jsx(bt,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Agents see what is on screen in these apps, and what they see goes to the agent’s model provider. Allow only apps you want operated."}),s.jsx("p",{children:"Never type a password or a sign-in code in chat. Sign in yourself, in the app, while you have taken over."}),s.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?s.jsx(A_,{chosen:p.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),p.allowedApps.includes(E)||b({...p,allowedApps:[...p.allowedApps,E]})}}):null]}):null]})}const j_="kmbckpnnjfggeffkkbmkggojnolkdokb";async function y_(){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(j_,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function w_(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function b_({busy:e,timezone:t}){const{data:n,error:r,reload:i}=se(()=>R.extension(),[],3e3),l=Am(),o=se(()=>y_(),[],3e3).data??null,[a,c]=f.useState(""),[u,p]=f.useState(!1),[d,h]=f.useState(null),x=(o==null?void 0:o.state)==="pairing"?o.code??"":"";f.useEffect(()=>{x&&c(x)},[x]);const v=async g=>{p(!0),h(null);try{await g()}catch(y){h(y instanceof Error?y.message:String(y))}finally{p(!1),i()}},w=e||u,b=t??Intl.DateTimeFormat().resolvedOptions().timeZone,j=s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),s.jsx(ut,{label:"The unpacked extension",children:(n==null?void 0:n.path)??"…"})]});return s.jsxs(G,{divided:!0,children:[s.jsx(re,{message:r??d}),s.jsxs(J,{children:[s.jsx(pe,{tone:n!=null&&n.connected?"good":"warning",children:n!=null&&n.connected?"Connected":"Not connected"}),s.jsxs("span",{className:"muted",children:[n!=null&&n.connected&&n.pairedAt?`Paired with Chrome on ${l} since ${Ie(n.pairedAt,b)}`:n!=null&&n.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",n!=null&&n.extension?` · extension ${n.extension}`:""]})]}),s.jsxs(G,{children:[s.jsxs("p",{className:"muted",children:[o?`The browser you are reading this in has the extension, version ${o.version}.`:n!=null&&n.connected?"The browser you are reading this in has no buddi extension. You only need it here to pair this browser instead.":"The browser you are reading this in has no buddi extension yet.",(o==null?void 0:o.state)==="paired"?" It is already paired with a buddi.":"",(o==null?void 0:o.state)==="disconnected"?" It is not connected yet: press Connect in its popup.":""]}),o&&!w_(o.gateway)?s.jsx(K,{tone:"warning",children:`The extension is pointed at ${o.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),n!=null&&n.pending?s.jsxs(J,{valign:"end",children:[s.jsx(te,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:s.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:a,onChange:g=>c(g.target.value)})}),s.jsx(rl,{}),s.jsx(P,{variant:"accent",disabled:w||a.replace(/[^0-9]/g,"").length!==6,onClick:()=>void v(async()=>{await R.pairExtension(a),c("")}),children:"Pair"})]}):null,n!=null&&n.connected?s.jsx(bt,{summary:"Pair a different browser",children:j}):j,s.jsx(J,{align:"end",children:s.jsx(P,{variant:"danger",disabled:w||!(n!=null&&n.pairedAt),onClick:()=>void v(()=>R.forgetExtension()),children:"Forget this browser"})})]})}function Id({current:e,value:t,title:n,body:r,disabled:i,onPick:l}){const o=e===t;return s.jsxs("button",{type:"button",role:"radio","aria-checked":o,className:"mode-option",disabled:i,onClick:()=>{o||l()},children:[s.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),s.jsxs("span",{className:"mode-option-text",children:[s.jsx("span",{className:"mode-option-title",children:n}),s.jsx("span",{className:"mode-option-body",children:r})]})]})}function k_({settings:e,disabled:t,onChange:n,onAdd:r}){const i=se(()=>R.installedApps(),[]),l=o=>{var a,c;return((c=(a=i.data)==null?void 0:a.apps.find(u=>u.id===o))==null?void 0:c.name)??o};return s.jsxs(s.Fragment,{children:[e.allowedApps.length===0?s.jsx(le,{children:"No apps yet. Agents cannot touch anything until you add one."}):s.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(o=>s.jsxs("li",{className:"ui-list-row",children:[s.jsx(os,{id:o,name:l(o),size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[l(o),o===e.browserApp?s.jsx(pe,{tone:"accent",className:"app-role",children:"browser"}):null]}),s.jsx("span",{className:"ui-list-sub mono",children:o})]}),s.jsxs(J,{children:[o!==e.browserApp&&E_(o)?s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,browserApp:o}),children:"Use as browser"}):null,o===e.browserApp?s.jsx("span",{className:"muted",children:"In use as the browser"}):s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,allowedApps:e.allowedApps.filter(a=>a!==o)}),children:"Remove"})]})]},o))}),s.jsxs(J,{children:[s.jsx(P,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),s.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&S_.includes(e.browserApp)?s.jsx(N_,{settings:e,disabled:t,onChange:n}):null]})}const S_=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function N_({settings:e,disabled:t,onChange:n}){var o;const i=((o=se(()=>R.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:o.profiles)??[],l=e.browserProfile?i.some(a=>a.directory===e.browserProfile):!0;return s.jsx(te,{label:"Browser profile",hint:e.browserProfile?"Websites open in this profile, signed in as it is.":"Not chosen: websites open in whichever profile’s window is in front, or the last one you used.",children:s.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:a=>{const{browserProfile:c,...u}=e;n(a.target.value?{...u,browserProfile:a.target.value}:u)},children:[s.jsx("option",{value:"",children:"Whichever is in front"}),!l&&e.browserProfile?s.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(a=>s.jsxs("option",{value:a.directory,children:[a.name,a.directory==="Default"?"":` (${a.directory})`]},a.directory))]})})}const C_=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function E_(e){return C_.includes(e)}function A_({chosen:e,onClose:t,onPick:n}){const r=se(()=>R.installedApps(),[]),[i,l]=f.useState(""),[o,a]=f.useState(""),c=f.useMemo(()=>{var d;const u=((d=r.data)==null?void 0:d.apps)??[],p=i.trim().toLowerCase();return u.filter(h=>!p||h.name.toLowerCase().includes(p)||h.id.toLowerCase().includes(p)).slice(0,60)},[r.data,i]);return s.jsxs(Yt,{title:"Add an app",onClose:t,children:[s.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>l(u.target.value)}),s.jsx(re,{message:r.error}),r.data?c.length===0?s.jsx(le,{children:"No app matches."}):s.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const p=e.includes(u.id);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx(os,{id:u.id,name:u.name,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:u.name}),s.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),s.jsx(P,{size:"sm",disabled:p,onClick:()=>n(u.id),children:p?"Allowed":"Allow"})]},u.id)})}):s.jsx(le,{children:"Reading your Applications folder…"}),s.jsx(bt,{summary:"Add by bundle identifier instead",children:s.jsxs(J,{children:[s.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:o,onChange:u=>a(u.target.value)}),s.jsx(P,{disabled:!o.trim(),onClick:()=>n(o.trim()),children:"Allow this identifier"})]})})]})}function R_({data:e,error:t,reload:n,compact:r=!1,refresh:i,screenshotSrc:l,onScreenshotError:o,onScreenshotLoad:a,controls:c=!0}){var T,E,_;const[u,p]=f.useState(!1),[d,h]=f.useState(null),[x,v]=f.useState(null),[w,b]=f.useState(null),j=async F=>{p(!0),h(null),b(null);try{const O=F!=="stop"&&(e!=null&&e.session)?await R.browserControl(F,e.session.id):await R.browserControl(F);F==="takeover"?O.hand&&O.session?v(O.session.id):b(O.handMessage??null):v(null)}catch(O){h(O instanceof Error?O.message:String(O))}finally{p(!1),n()}},g=x&&((T=e==null?void 0:e.session)==null?void 0:T.id)===x&&e.state==="paused"?x:null,y=!!(e!=null&&e.enabled)&&!u,m=(e==null?void 0:e.mode)==="computer",k=(e==null?void 0:e.mode)==="extension",S=m?"Stop computer control interrupts native input and revokes access. Take over pauses agent input. Release ends this conversation’s control without closing your apps. Already dispatched actions cannot be undone. Avoid using the same mouse and keyboard while the agent is working.":"Stop all browsers closes every session and revokes access until you resume. Take over, Resume and Close & release affect only the selected conversation. An in-flight action is interrupted by closing its tabs. Actions already submitted cannot be undone.",N=e!=null&&e.busy?"Working":(e==null?void 0:e.state)==="running"?"Ready":(e==null?void 0:e.state)??"Connecting",C=e!=null&&e.busy||(e==null?void 0:e.state)==="running"?"good":(e==null?void 0:e.state)==="stopped"||(e==null?void 0:e.state)==="error"?"critical":void 0;return s.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[s.jsxs("div",{className:"browser-heading",children:[s.jsxs("div",{children:[r?null:s.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),s.jsx("h2",{className:"browser-title",children:m?"Computer":k?"Your browser":"Browser"})]}),s.jsx(pe,{tone:C,children:s.jsx("span",{role:"status",children:N})})]}),r?s.jsx("a",{className:"browser-full-view",href:"#/browser",children:m?"Open computer view & settings ↗":"Open full browser view ↗"}):s.jsx("p",{className:"ui-page-lede",children:m?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":k?"Your own Chrome, signed in as you, working in background tabs grouped as “buddi”. You keep browsing.":"A real browser window, driven by your assistant. You stay in control."}),s.jsx(re,{message:t??d}),c?s.jsxs(J,{children:[s.jsx(P,{variant:"danger",disabled:!y||(e==null?void 0:e.state)==="stopped",onClick:()=>void j("stop"),children:m?"Stop computer control":"Stop all browsers"}),s.jsx(P,{disabled:!y||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void j("takeover"),children:"Take over"}),s.jsx(P,{disabled:!y||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void j("resume"),children:"Resume access"}),s.jsx(P,{disabled:!y||!(e!=null&&e.session),onClick:()=>void j("release"),children:m?"Release control":"Close & release"})]}):null,c?r?s.jsx(bt,{summary:"About these controls",children:s.jsx("p",{className:"muted",children:S})}):s.jsx("p",{className:"muted",children:S}):null,w?s.jsx(K,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!g?s.jsx(K,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?s.jsxs("div",{className:"browser-task",children:[s.jsxs("div",{className:"ui-row",children:[s.jsx("strong",{children:e.session.agentId}),s.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:s.jsx("p",{children:e.session.task}),s.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",new Date(e.session.expiresAt).toLocaleTimeString()]})]}):s.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?m?"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."}),g?s.jsx(m_,{sessionId:g,csrf:Vr(),onGiveBack:()=>void j("resume")}):null,s.jsxs("div",{className:"browser-window",hidden:!!g,children:[s.jsxs("div",{className:"browser-address",children:[s.jsx("span",{"aria-hidden":"true",children:"◉"}),s.jsx("span",{children:((E=e==null?void 0:e.page)==null?void 0:E.url)??(m?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?s.jsxs("figure",{children:[s.jsx("img",{src:l??`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:""}${i?`&tick=${i}`:""}`,alt:`Last browser observation: ${e.page.title||e.page.url}`,...o?{onError:o}:{},...a?{onLoad:a}:{}},l??e.page.id),s.jsxs("figcaption",{children:["Last observation · ",new Date(e.page.capturedAt).toLocaleTimeString()," · ",e.page.title||"Untitled page"]})]}):s.jsxs("div",{className:"browser-empty",children:[s.jsx("strong",{children:m?"Your selected app will appear here":"Your browser activity will appear here"}),s.jsx("p",{children:m?"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."})]})]}),(((_=e==null?void 0:e.page)==null?void 0:_.tabs.length)??0)>1?s.jsx(bt,{summary:`${e.page.tabs.length} open tabs`,children:s.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(F=>s.jsxs("li",{children:[F.title||F.id," — ",F.url]},F.id))})}):null,s.jsxs("p",{className:"muted",children:[m?"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."," ",g?"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 T_=2e3,P_=5;function I_(e,t){if(!e.hasScreenshot||!e.page)return null;const n=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${n}`}function M_({status:e,error:t,reload:n,steps:r,live:i,focusedStepId:l=null}){var y;const[o,a]=f.useState(0),[c,u]=f.useState(0),p=c>=P_;f.useEffect(()=>{if(!i||p)return;const m=window.setInterval(()=>{typeof document<"u"&&document.hidden||a(k=>k+1)},T_);return()=>window.clearInterval(m)},[i,p]);const d=f.useRef(null);i&&(e!=null&&e.session)&&(d.current=e);const[h,x]=f.useState(null),v=f.useRef(null),w=((y=e==null?void 0:e.page)==null?void 0:y.id)??null;f.useEffect(()=>{const m=i&&e?I_(e):null;if(!m||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let k=!1;return(async()=>{try{const S=await fetch(m);if(!S.ok||k)return;const N=await S.blob();if(k)return;const C=URL.createObjectURL(N);v.current&&URL.revokeObjectURL(v.current),v.current=C,x(C)}catch{}})(),()=>{k=!0}},[i,w]),f.useEffect(()=>()=>{v.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(v.current)},[]);const b=d.current,j=i?e:b?h?b:{...b,hasScreenshot:!1}:e,g=r.at(-1)??null;return s.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[s.jsx(R_,{data:j,error:t,reload:n,compact:!0,controls:i,...i?{refresh:o}:{},...!i&&h?{screenshotSrc:h}:{},onScreenshotError:()=>u(m=>m+1),onScreenshotLoad:()=>u(0)}),i?p?s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"This session has ended. What is on this panel is the last thing it showed."}),s.jsx($_,{steps:r,newestId:(g==null?void 0:g.id)??null,focusedId:l??null,live:i})]})}function $_({steps:e,newestId:t,focusedId:n,live:r}){const i=f.useRef(null);return f.useEffect(()=>{var o;if(!n||!i.current)return;const l=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(n):n}"]`);(o=l==null?void 0:l.scrollIntoView)==null||o.call(l,{block:"nearest"})},[n]),e.length===0?s.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):s.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:s.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((l,o)=>{const a=l.awaiting?"awaiting":l.ok===null?"running":l.ok?"ok":"failed";return s.jsxs("li",{"data-step":l.id,className:"wb-browser-step","data-state":a,"data-newest":l.id===t?"true":void 0,"data-focused":l.id===n?"true":void 0,children:[s.jsx("span",{className:"wb-browser-index mono",children:o+1}),s.jsxs("span",{className:"wb-browser-what",children:[s.jsx("strong",{children:l.action}),l.target?s.jsx("span",{className:"muted wb-browser-target",children:l.target}):null,l.error?s.jsx("span",{className:"wb-browser-error",children:l.error}):null]}),s.jsx("span",{className:"wb-browser-outcome","data-state":a,children:a==="awaiting"?"Awaiting approval":a==="running"?"Working":a==="ok"?"Done":"Failed"})]},l.id)})})})}function __({agentId:e,conversationId:t}){const{data:n,error:r,reload:i}=se(()=>R.host(e,t),[e,t],2e3),[l,o]=f.useState(null),[a,c]=f.useState(!1),u=async x=>{c(!0),o(null);try{await x(),i()}catch(v){o(v instanceof Error?v.message:String(v))}finally{c(!1)}},p=(n==null?void 0:n.permissions)??[],d=(n==null?void 0:n.runs)??[],h=p.some(x=>!x.conversationId)?"Always allowed":p.length?"Conversation auto-mode":"Ask each time";return s.jsx(bt,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":h}${d.length?` · ${d.length} running`:""}`,children:s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"muted",children:"Commands run as your user, not in a sandbox. Auto-mode covers all commands within its scope. Stop interrupts a command; revoke also ends the permission. Neither undoes completed changes."}),s.jsx(re,{message:l??r}),p.map(x=>s.jsxs(J,{children:[s.jsxs("span",{children:[x.agentId,": ",x.conversationId?"conversation auto-mode":"always allowed"]}),s.jsx(P,{size:"sm",disabled:a,onClick:()=>void u(()=>R.revokeHost(x.id)),children:"Revoke permission"})]},x.id)),p.length?null:s.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),d.map(x=>s.jsxs(G,{gap:"sm",children:[s.jsxs("p",{children:[x.agentId," · ",s.jsx("span",{className:"mono",children:x.cwd})]}),s.jsx(ut,{children:x.command}),s.jsx(ut,{label:"Command output",children:x.stdout||x.stderr?`${x.stdout}
100
- ${x.stderr}`:"Waiting for output…"}),s.jsx(J,{children:s.jsx(P,{size:"sm",variant:"danger",disabled:a,onClick:()=>void u(()=>R.stopHost(x.agentId,x.conversationId)),children:"Stop command"})})]},x.actionId))]})})}const mk="browser.act",O_="browser.status",Va=new Set([mk,O_]);function D_(e,t,n){const r=e==null?void 0:e.session;return!r||!t||!n||r.agentId!==t||r.conversationId!==n?null:{id:`host-browser:${r.id}`,title:e.mode==="computer"?"Computer":"Browser",tool:"Host browser",renderer:"browser",source:"browser",pinned:!0,props:{},at:null,substantial:!1}}function L_(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function F_(e){var r;const t=[],n=new Map;for(const i of e)for(const l of i.blocks??[]){if(l.type==="tool_use"&&l.name===mk){const a={id:l.id,action:U_(l.input)??"act",target:B_(l.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(a),n.set(l.id,a);continue}if(l.type!=="tool_result")continue;const o=n.get(l.toolUseId);if(o){if(((r=l.approval)==null?void 0:r.state)==="pending"){o.awaiting=!0,o.ok=null,o.error=null;continue}o.awaiting=!1,o.ok=l.ok,o.error=l.ok?null:z_(l)}}return t}function Lv(e,t){var r;let n=!1;for(const i of e)for(const l of i.blocks??[])if(l.type==="tool_use"&&l.id===t&&(n=Va.has(l.name)),l.type==="tool_result"&&l.toolUseId===t&&((r=l.approval)==null?void 0:r.state)==="pending")return null;return n?t:null}function U_(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function B_(e){if(e===null||typeof e!="object")return null;const t=e;for(const r of["url","appId","direction","key","tabId"]){const i=t[r];if(typeof i=="string"&&i!=="")return i}const n=t.target;if(n!==null&&typeof n=="object"){const r=n,i=r.name;if(typeof i=="string"&&i!=="")return i;const l=r.ref;if(typeof l=="string"&&l!=="")return l;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function z_(e){for(const t of[e.error,e.output]){if(typeof t=="string"&&t.trim()!=="")return t.trim();if(t!==null&&typeof t=="object")for(const n of["message","error","reason"]){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function W_({agentId:e,groupId:t,currentId:n,timezone:r,onSelect:i,onNew:l}){const[o,a]=f.useState(null),[c,u]=f.useState(null),[p,d]=f.useState(0);return f.useEffect(()=>{let h=!1;return a(null),u(null),(t?Le.groupConversations(t):Le.conversations(e,100)).then(x=>{h||a(x.conversations)}).catch(x=>{h||u(x instanceof Error?x.message:String(x))}),()=>{h=!0}},[e,t,p]),s.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[s.jsxs("div",{className:"ui-toolbar",children:[s.jsx("strong",{children:"Past conversations"}),s.jsx("button",{className:"ui-btn",onClick:l,children:"New conversation"})]}),c?s.jsxs("p",{role:"alert",children:[c," ",s.jsx("button",{className:"ui-btn",onClick:()=>d(h=>h+1),children:"Retry"})]}):o===null?s.jsx("p",{className:"muted",children:"Loading conversations…"}):o.length===0?s.jsx("p",{className:"muted",children:"No conversations yet."}):s.jsx("ul",{children:o.map(h=>s.jsx("li",{children:s.jsxs("a",{href:t?Dl(t,h.id):Fe(e,h.id),"aria-current":h.id===n?"page":void 0,onClick:x=>{x.button===0&&!x.metaKey&&!x.ctrlKey&&!x.shiftKey&&!x.altKey&&(x.preventDefault(),i(h.id))},children:[s.jsx("span",{children:h.preview||h.opening||"Untitled conversation"}),s.jsxs("small",{children:[Ie(h.lastMessageAt??h.startedAt??h.createdAt??null,r)," · ",h.messageCount," messages",h.id===n?" · Current":""]})]})},h.id))}),s.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(o==null?void 0:o.length)===100?s.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const gk="buddi.dismissedTabs";function V_(){try{const e=JSON.parse(sessionStorage.getItem(gk)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(n=>typeof n=="string")))}catch{return{}}}function Fv(e){try{sessionStorage.setItem(gk,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const H_="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",fa="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",K_=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function G_(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(H_);let n;try{n=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(K_(i))return null;throw new Error(fa)}try{const i=e.document??document,l=i.createElement("video");l.muted=!0,l.playsInline=!0,l.srcObject=n,await new Promise((p,d)=>{l.onloadedmetadata=()=>p(),l.onerror=()=>d(new Error(fa))}),await l.play(),await new Promise(p=>{const d=l.requestVideoFrameCallback;typeof d=="function"?d.call(l,()=>p()):setTimeout(p,120)});const o=i.createElement("canvas");o.width=l.videoWidth,o.height=l.videoHeight;const a=o.getContext("2d");if(!a||o.width===0)throw new Error(fa);a.drawImage(l,0,0);const c=await new Promise(p=>o.toBlob(p,"image/png"));if(!c)throw new Error(fa);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{n.getTracks().forEach(i=>i.stop())}}const Uv="Send files once the agent has answered.",Y_=f.forwardRef(function({disabled:t,running:n,onSend:r,onStop:i,agentName:l,draft:o,model:a,setupHref:c,thinking:u,onThinking:p,onOpenFile:d,mentions:h,history:x,threadKey:v},w){var xr;const b=v?`buddi.draft.${v}`:null,j=L=>{if(!L)return"";try{return window.localStorage.getItem(L)??""}catch{return""}},[g,y]=f.useState(()=>j(b)),[m,k]=f.useState([]),[S,N]=f.useState(!1),[C,T]=f.useState(null),[E,_]=f.useState(!1),F=f.useRef(null),O=f.useRef(null),[A,D]=f.useState(null),[q,V]=f.useState(0),M=A&&h?h.filter(L=>L.handle.toLowerCase().startsWith(A.query.toLowerCase())||L.name.toLowerCase().startsWith(A.query.toLowerCase())).slice(0,6):[],z=(L,ce)=>{if(!h||h.length===0){D(null);return}const ot=L.slice(0,ce),un=/(^|\s)@([\w-]*)$/.exec(ot);if(!un){D(null);return}D({start:ce-un[2].length-1,query:un[2]}),V(0)},$=L=>{if(!A)return;const ce=O.current,ot=ce?ce.selectionStart:g.length,un=`${g.slice(0,A.start)}@${L} ${g.slice(ot)}`;y(un),X<0&&Ne(un),D(null),window.requestAnimationFrame(()=>{if(!ce)return;const mt=A.start+L.length+2;ce.focus(),ce.setSelectionRange(mt,mt),St()})},U=x??[],[X,Z]=f.useState(-1),fe=f.useRef(g),ve=f.useRef(b);if(ve.current!==b){ve.current=b;const L=j(b);fe.current=L,L!==g&&(y(L),Z(-1),D(null))}const Ne=L=>{if(fe.current=L,!!b)try{L===""?window.localStorage.removeItem(b):window.localStorage.setItem(b,L)}catch{}},oe=L=>{y(L),D(null);const ce=O.current;ce&&(ce.value=L,ce.setSelectionRange(L.length,L.length)),window.requestAnimationFrame(St)},be=L=>!L.value.slice(0,L.selectionStart??L.value.length).includes(`
101
- `),ye=()=>g===""||X>=0&&g===U[X],Te=()=>{X<0||(Z(-1),oe(fe.current))},Ve=m.some(L=>L.state==="uploading"),it=m.length>0,H=n&&it,me=!t&&!Ve&&!H&&g.trim()!=="",ue=L=>{for(const ce of Array.from(L??[])){const ot=`${ce.name}:${ce.size}:${Math.random().toString(36).slice(2,8)}`,un=ce.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(ce):null;k(mt=>[...mt,{key:ot,filename:ce.name||"Pasted image",mime:ce.type||"application/octet-stream",sizeBytes:ce.size,thumbnail:un,state:"uploading"}]),Le.attach(ce).then(mt=>k(Os=>Os.map(us=>us.key===ot?{...us,state:"ready",uploaded:mt}:us))).catch(mt=>k(Os=>Os.map(us=>us.key===ot?{...us,state:"failed",error:mt instanceof de?mt.message:String(mt)}:us)))}},ke=L=>{L.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(L.thumbnail)},we=L=>{const ce=m.find(ot=>ot.key===L);ce&&(ke(ce),ce.state==="ready"&&ce.uploaded&&Le.discardAttachment(ce.uploaded.artifactId).catch(()=>{})),k(ot=>ot.filter(un=>un.key!==L))};f.useImperativeHandle(w,()=>({addFiles:L=>{var ce;ue(L),(ce=O.current)==null||ce.focus()},focus:()=>{var L;return(L=O.current)==null?void 0:L.focus()}}));const Je=f.useRef(m);Je.current=m,f.useEffect(()=>()=>Je.current.forEach(ke),[]);const lt=f.useRef(0);f.useEffect(()=>{if(!o||o.at===lt.current)return;lt.current=o.at,y(ce=>ce.trim()===""?o.text:ce),X<0&&g.trim()===""&&Ne(o.text);const L=O.current;L&&(L.focus(),window.requestAnimationFrame(()=>{L.style.height="auto",L.style.height=`${Math.min(L.scrollHeight,200)}px`,L.setSelectionRange(L.value.length,L.value.length)}))},[o]);const St=()=>{const L=O.current;L&&(L.style.height="auto",L.style.height=`${Math.min(L.scrollHeight,200)}px`)},cn=()=>{if(!me)return;const L=m.filter(ce=>ce.state==="ready"&&ce.uploaded).map(ce=>ce.uploaded);r(g.trim(),L),m.forEach(ke),Z(-1),Ne(""),y(""),k([]),window.requestAnimationFrame(St)},Tn=L=>{if(A&&M.length>0){if(L.key==="ArrowDown"){L.preventDefault(),V(ce=>(ce+1)%M.length);return}if(L.key==="ArrowUp"){L.preventDefault(),V(ce=>(ce-1+M.length)%M.length);return}if(L.key==="Enter"||L.key==="Tab"){L.preventDefault(),$(M[q].handle);return}if(L.key==="Escape"){L.preventDefault(),D(null);return}}if(L.key==="ArrowUp"&&!L.shiftKey&&!L.altKey&&!L.metaKey&&!L.ctrlKey){const ce=L.currentTarget;if(U.length>0&&X+1<U.length&&be(ce)&&ye()){L.preventDefault(),X<0&&(fe.current=g),Z(X+1),oe(U[X+1]);return}}if(L.key==="ArrowDown"&&!L.shiftKey&&!L.altKey&&!L.metaKey&&!L.ctrlKey&&X>=0&&g===U[X]){if(L.preventDefault(),X===0){Te();return}Z(X-1),oe(U[X-1]);return}if(L.key==="Escape"&&X>=0){L.preventDefault(),Te();return}L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),cn())},Ft=L=>{var ot;const ce=Array.from(((ot=L.clipboardData)==null?void 0:ot.files)??[]);ce.length!==0&&(L.preventDefault(),ue(ce))},$s=m.filter(L=>L.state==="failed"),_s=$s.length;return s.jsx("div",{className:"wb-composer","data-testid":"composer",children:s.jsxs("div",{className:"wb-composer-box","data-focused":E,"data-disabled":t,children:[m.length>0?s.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:m.map(L=>s.jsx("span",{role:"listitem",children:s.jsx(ak,{name:L.filename,mime:L.mime,sizeBytes:L.sizeBytes,thumbnail:L.thumbnail,state:L.state,error:L.error,onRemove:()=>we(L.key),...d&&L.state==="ready"&&L.uploaded?{onOpen:()=>d(q_(L.uploaded))}:{},size:"sm"})},L.key))}):null,s.jsxs("label",{className:"sr-only",htmlFor:"wb-composer-input",children:["Message ",l]}),s.jsx("textarea",{id:"wb-composer-input",ref:O,value:g,rows:2,placeholder:n?`${l} is working…`:`Message ${l}`,onChange:L=>{y(L.target.value),X<0&&Ne(L.target.value),z(L.target.value,L.target.selectionStart??L.target.value.length),St()},onFocus:()=>_(!0),onBlur:()=>_(!1),onKeyDown:Tn,onPaste:Ft,disabled:t}),A&&M.length>0?s.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:M.map((L,ce)=>s.jsxs("button",{type:"button",role:"option","aria-selected":ce===q,className:"wb-mention","data-active":ce===q||void 0,onMouseDown:ot=>{ot.preventDefault(),$(L.handle)},children:[s.jsxs("span",{className:"wb-mention-handle",children:["@",L.handle]}),s.jsx("span",{className:"wb-mention-name",children:L.name})]},L.handle))}):null,s.jsxs("div",{className:"wb-composer-row",children:[s.jsx("input",{ref:F,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:L=>{ue(L.target.files),L.target.value=""}}),s.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Attach a file",title:"Attach a file — or paste one, or drop it anywhere on the chat",onClick:()=>{var L;return(L=F.current)==null?void 0:L.click()},disabled:t,children:s.jsx(Oe,{name:"clip"})}),s.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:()=>{T(null),N(!0),G_().then(L=>{var ce;L&&(ue([L]),(ce=O.current)==null||ce.focus())}).catch(L=>T(L instanceof Error?L.message:String(L))).finally(()=>N(!1))},disabled:t||S,children:s.jsx(Oe,{name:"camera"})}),a?c?s.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):s.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):null,p?s.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":ha(u),disabled:t||n,title:n?`Wait for ${l} to finish — this run started with thinking ${ha(u)?"on":"off"}`:ha(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:()=>p(ha(u)?"off":"on"),children:[s.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,s.jsx("span",{className:"wb-hint","data-shown":g!==""&&!n||_s>0||H||C!==null,"data-tone":_s>0||C!==null?"critical":void 0,children:_s>0?_s===1&&((xr=$s[0])!=null&&xr.error)?$s[0].error:`${_s} files failed to upload and will not be sent`:C!==null?C:H?Uv:"Enter sends, Shift+Enter for a new line"}),n?s.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,s.jsx("button",{className:"wb-send","aria-label":"Send",title:H?Uv:Ve?"Waiting for the upload to finish":n?`Send — ${l} picks it up between steps`:"Send",onClick:cn,disabled:!me,children:s.jsx(Oe,{name:"send"})})]})]})})});function ha(e){return(e??"on")==="on"}function q_(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function Q_({question:e,disabled:t,onAnswer:n,onSkip:r}){const[i,l]=f.useState("");return f.useEffect(()=>{if(t)return;const o=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),r())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,r]),s.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),s.jsx(P,{className:"wb-question-skip",variant:"ghost",size:"sm",disabled:t,onClick:r,title:"Skip this question (Esc). The agent carries on without an answer.",children:"Skip"}),s.jsx("strong",{children:e.question})]}),e.options.length>0?s.jsx("div",{className:"wb-question-options",children:e.options.map((o,a)=>s.jsxs("button",{className:"wb-question-option","data-recommended":o.recommended||void 0,disabled:t,onClick:()=>n(o.label,o.id),children:[s.jsx("span",{className:"wb-question-number",children:a+1}),s.jsxs("span",{children:[s.jsxs("span",{className:"wb-question-label",children:[o.label,o.recommended?s.jsx("em",{children:"Recommended"}):null]}),o.hint?s.jsx("small",{children:o.hint}):null]})]},o.id))}):null,e.allowOther?s.jsxs("form",{className:"wb-question-other",onSubmit:o=>{o.preventDefault(),i.trim()&&n(i.trim())},children:[s.jsx("input",{value:i,onChange:o=>l(o.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),s.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,s.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function J_(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function X_(e){const t=e/36e5;if(t>=1&&Number.isInteger(t))return`${t} hour${t===1?"":"s"}`;const n=Math.round(e/6e4);return`${n} minute${n===1?"":"s"}`}function Z_(e){const{lifetime:t,startedAt:n,now:r,timezone:i}=e;if(!t||t.messages<=0)return{text:"New conversation",title:"Nothing has been said in this one yet.",tone:"quiet"};const l=`A conversation ends after ${X_(t.idleTimeoutMs)} idle, or once its transcript grows past ${Math.round(t.maxChars/1e3)}k characters. What the agent remembers about you carries over.`,o=`${t.messages} message${t.messages===1?"":"s"}`;if(J_(t,r))return{text:`${o} · your next message starts a fresh one`,title:l,tone:"note"};const a=n?Ce(n,r):"";return{text:a===""?o:`${o} · started ${a}`,title:n?`Started ${Ie(n,i)}. ${l}`:l,tone:"quiet"}}const Ha=320,xk="buddi.chatWidth";function eO({timezone:e,agents:t,agentId:n,defaultAgentId:r=null,group:i=null,onEditGroup:l,onSelectAgent:o,attention:a,agentsInHeader:c,narrow:u,canvasOpen:p,onOpenCanvas:d,onCloseCanvas:h,newConversationSignal:x,requestedConversationId:v,requestedTab:w,onConversationOpened:b}){var dg,fg,hg,pg,mg,gg;const j=Am(),[g,y]=f.useState([]),[m,k]=f.useState(null),[S,N]=f.useState(null),[C,T]=f.useState(null),[E,_]=f.useState([]),[F,O]=f.useState([]),[A,D]=f.useState(null),[q,V]=f.useState(!1),[M,z]=f.useState(new Map),[$,U]=f.useState(null),[X,Z]=f.useState(V_),[fe,ve]=f.useState([]),[Ne,oe]=f.useState(!1),be=f.useRef(0),ye=f.useRef(null),[Te,Ve]=f.useState(!1),it=f.useRef(x??0),H=f.useRef(n),me=f.useRef({agentId:n,conversationId:m});me.current={agentId:n,conversationId:m};const ue=X[m??""]??[],[ke,we]=f.useState(null),[Je,lt]=f.useState(null),[St,cn]=f.useState(null),[Tn,Ft]=f.useState([]),[$s,_s]=f.useState(!1),[xr,L]=f.useState(()=>Date.now()),[ce,ot]=f.useState(tO),un=f.useRef(null),[mt,Os]=f.useState(null),[us,Hm]=f.useState(!1),[s1,Su]=f.useState(null),[r1,i1]=f.useState(null),[l1,Km]=f.useState(null);f.useEffect(()=>{if(!n)return;const I=iO(n);I&&Su({text:I,at:Date.now()})},[n]);const vr=i?`group:${i.id}`:n??null,wn=[...t.top,...t.middle,...t.bottom],he=wn.find(I=>I.id===n)??null,qr=i?i.members.map(I=>wn.find(W=>W.id===I)).filter(I=>!!I):[],[Nu,Gm]=f.useState(null);f.useEffect(()=>{let I=!1;return Le.views().then(W=>{I||y(W.views??[])}).catch(()=>{}),()=>{I=!0}},[]),f.useEffect(()=>{if(!n)return;const I=H.current===n;if(H.current=n,I&&v&&v===me.current.conversationId)return;let W=!1;return k(null),N(null),T(null),_([]),we(null),V(!1),U(null),ve([]),Ao(null),Ve(!1),Os(null),v?(v!=="new"?k(v):T(vr),()=>{W=!0}):((i?Le.groupConversations(i.id):Le.conversations(n)).then(ee=>{if(W)return;const xe=[...ee.conversations??[]].sort(nO)[0];xe?(k(xe.id),b==null||b(n,xe.id)):T(vr)}).catch(()=>{W||T(vr)}),()=>{W=!0})},[n,i==null?void 0:i.id,vr,v,b]);const Hn=f.useCallback(I=>Le.conversation(I).then(W=>{if(me.current.conversationId===I){if(W.agentId!==me.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(W),_(ee=>ee.filter(xe=>!Md(W,xe)))}}).catch(W=>{me.current.conversationId===I&&we(Fs(W))}),[]);f.useEffect(()=>{if(!m)return;let I=!1;return z(new Map),O([]),Le.conversation(m).then(W=>{if(!I){if(W.agentId!==n)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(W),_(ee=>ee.filter(xe=>!Md(W,xe)))}}).catch(W=>{I||we(Fs(W))}),()=>{I=!0}},[m,n]),f.useEffect(()=>{if(!m)return;let I=!1;const W=window.setInterval(()=>{Le.conversation(m).then(ee=>{I||ee.agentId!==me.current.agentId||(N(ee),_(xe=>xe.filter(Ae=>!Md(ee,Ae))))}).catch(()=>{})},3e3);return()=>{I=!0,window.clearInterval(W)}},[m,n]),f.useEffect(()=>{if(!m)return;const I=E0({url:Le.streamUrl(m),onEvent:W=>{switch(W.name){case"run.started":V(!0),D(null),Gm(Nt(W.data.agentId));break;case"live":{const ee=Nt(W.data.runId)??"",xe=Number(W.data.turn??0),Ae=W.data.kind==="thinking"?"thinking":"text",_e=Nt(W.data.text)??"",ds=Date.now();D(Ds=>{const Zr=Ds&&Ds.runId===ee&&Ds.turn===xe?Ds:{runId:ee,turn:xe,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return Ae==="thinking"?{...Zr,thinking:Zr.thinking+_e,thinkingStartedAt:Zr.thinkingStartedAt??ds}:{...Zr,text:Zr.text+_e,textStartedAt:Zr.textStartedAt??ds}});break}case"live.snapshot":{const ee=Nt(W.data.runId)??"",xe=Number(W.data.turn??0),Ae=Nt(W.data.text)??"",_e=Nt(W.data.thinking)??"",ds=Number(W.data.startedAt??Date.now());D({runId:ee,turn:xe,text:Ae,thinking:_e,thinkingStartedAt:_e?ds:null,textStartedAt:Ae?ds:null,settled:!1});break}case"live.settle":{const ee=Nt(W.data.runId)??"",xe=Number(W.data.turn??0);D(Ae=>Ae&&Ae.runId===ee&&Ae.turn===xe?{...Ae,settled:!0}:Ae);break}case"tool.called":{const ee=Nt(W.data.toolUseId)??Nt(W.data.id),xe=Nt(W.data.name)??Nt(W.data.tool)??"tool";ee&&O(Ae=>[...Ae.filter(_e=>_e.toolUseId!==ee),{toolUseId:ee,name:xe,startedAt:Date.now()}]);break}case"tool.result":{const ee=Nt(W.data.toolUseId)??Nt(W.data.id);ee&&O(xe=>xe.filter(Ae=>Ae.toolUseId!==ee)),Hn(m);break}case"message.appended":Hn(m).then(()=>{D(ee=>ee!=null&&ee.settled?null:ee)});break;case"awaiting-approval":{const ee=Nt(W.data.approvalId)??Nt(W.data.actionId),xe=Nt(W.data.toolUseId);ee&&xe&&z(Ae=>new Map(Ae).set(xe,ee)),O(Ae=>Ae.filter(_e=>_e.toolUseId!==xe)),Hn(m);break}case"run.finished":{V(!1),O([]),D(null),Gm(null);const ee=Nt(W.data.message);we(ee??null),Hn(m);break}}}});return()=>I.close()},[m,Hn]),f.useEffect(()=>{const I=window.setInterval(()=>L(Date.now()),F.length===0?6e4:1e3);return()=>window.clearInterval(I)},[F.length]);const Eo=se(()=>n&&m?R.browser({agentId:n,conversationId:m}):Promise.resolve(void 0),[n,m],1500),Qr=Eo.error?void 0:Eo.data,ol=Qr!=null&&Qr.session&&Qr.session.agentId===n&&Qr.session.conversationId===m?Qr:void 0,jr=D_(ol,n,m),yr=(jr==null?void 0:jr.id)??null,[al,o1]=f.useState(null),Ym=ol==null?void 0:ol.mode;f.useEffect(()=>{jr&&n&&m&&o1({agentId:n,conversationId:m,tab:L_(jr,Ym)})},[yr,Ym,n,m]);const a1=al&&al.agentId===n&&al.conversationId===m&&!ue.includes(al.tab.id)?al.tab:null,Pt=jr??a1,c1=f.useMemo(()=>F_((S==null?void 0:S.messages)??[]),[S]),[u1,Ao]=f.useState(null),d1=f.useMemo(()=>QM({messages:(S==null?void 0:S.messages)??[],descriptors:g}),[S,g]),Jr=t_(d1,m??null),Cu=s_(i?null:n),qm=f.useMemo(()=>n_((S==null?void 0:S.messages)??[]),[S]),dn=f.useMemo(()=>{const W=JM({messages:(S==null?void 0:S.messages)??[],descriptors:g,awaiting:M,served:Jr.served,...Pt?{folded:Va}:{}}).filter(ee=>ee.source==="approval"||!ue.includes(ee.id));if($&&!ue.includes($)&&!W.some(ee=>ee.id===$)){const ee=t$((S==null?void 0:S.messages)??[],$,{redactInputOf:Va});ee&&!Va.has(ee.tool)&&W.push(ee)}Pt&&W.push(Pt);for(const ee of fe)W.push(FI(ee));return Cu&&W.unshift(r_(Cu,qm)),mt?[...W,i_(mt)]:W},[S,g,M,mt,yr,Pt==null?void 0:Pt.title,$,X,m,fe,Jr.served,Cu,qm]),f1=f.useMemo(()=>{var W;const I=[];for(const ee of(S==null?void 0:S.messages)??[]){if(ee.role!=="user"||ee.speaker&&ee.speaker!=="owner")continue;const xe=(W=ee.blocks.find(Ae=>Ae.type==="text"))==null?void 0:W.text.trim();xe&&I.unshift(xe)}return I},[S]),Eu=f.useMemo(()=>dn.filter(I=>I.source==="approval"),[dn]),Ro=Eu.at(-1)??null,To=f.useMemo(()=>[...Eu.map(I=>({approvalId:I.props.approvalId,toolUseId:I.id})),...((S==null?void 0:S.delegatedApprovals)??[]).map(I=>({approvalId:I.approvalId,toolUseId:I.toolUseId??"",askedBy:cO(I.chain,wn)}))],[Eu,S==null?void 0:S.delegatedApprovals]),cl=f.useMemo(()=>{for(let I=dn.length-1;I>=0;I-=1){const W=dn[I];if(W!=null&&W.substantial)return W.id}return null},[dn]),Po=f.useRef(null),Au=((dg=dn.filter(I=>(I.source!=="browser"||I.pinned===!0)&&I.id!==yh).at(-1))==null?void 0:dg.id)??((fg=dn.filter(I=>I.id!==yh).at(-1))==null?void 0:fg.id)??null;f.useEffect(()=>{if(cl&&cl!==Po.current){Po.current=cl,U(cl);return}$===null&&Au&&U(Au)},[cl,$,Au]);const Qm=f.useRef(Jr.live);f.useEffect(()=>{const I=Qm.current;Qm.current=Jr.live;const W=[...Jr.live].filter(Ae=>!I.has(Ae));if(W.length===0||Ro||$!==null&&$!==Po.current)return;const xe=[...dn].reverse().find(Ae=>Ae.source==="descriptor"&&Ae.renderer==="preview"&&Ae.props.target!==null&&W.includes(Ai(Ae.props.target)));xe&&U(xe.id)},[Jr.live,dn,Ro,$]);const Jm=f.useRef(null);f.useEffect(()=>{yr!==Jm.current&&(Jm.current=yr,yr&&!Ro&&U(yr))},[yr,Ro]);const Xm=f.useRef(null),ul=w==="browser"?(Pt==null?void 0:Pt.id)??null:null;f.useEffect(()=>{!ul||Xm.current===ul||(Xm.current=ul,U(ul))},[ul]);const Ru=(Pt==null?void 0:Pt.id)??null;f.useEffect(()=>{!Ru||!$||Lv((S==null?void 0:S.messages)??[],$)!==null&&(Ao($),U(Ru))},[Ru,$,S]);const Zm=I=>{ve(W=>W.some(ee=>ee.artifactId===I.artifactId)?W:[...W,I]),U(Wa(I.artifactId)),u&&(d==null||d())},Io=!i&&he&&!he.available?I0(he):null,eg=ih(i?null:he),tg=((S==null?void 0:S.offers)??[]).filter(I=>!Tn.includes(I.id)&&Date.parse(I.expiresAt)>xr),h1=he&&l1===he.id?r1:(he==null?void 0:he.thinking)??null,p1=I=>{if(!he)return;const W=he.id;Km(W),i1(I),R.setAgentEngine(W,{thinking:I}).catch(ee=>{Km(null),we(ee instanceof de?ee.message:String(ee))})},ng=(I,W)=>{if(!n)return;const ee=W.map(_e=>_e.artifactId),xe=q,Ae={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:I},...W.map(_e=>({type:"attachment",artifactId:_e.artifactId,filename:_e.filename,mime:_e.mime,kind:_e.kind,sizeBytes:_e.sizeBytes}))],...xe?{speaker:ck}:{}};_(_e=>xe?[..._e,Ae]:[Ae]),we(null),lt(null),V(!0),(i?Le.sendToGroup(i.id,{...m?{conversationId:m}:{},text:I,attachmentIds:ee}):Le.send(n,{...m?{conversationId:m}:{},text:I,attachmentIds:ee})).then(async _e=>{me.current.agentId!==n||me.current.conversationId!==m||(lt(_e.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),_e.conversationId!==m?(N(null),k(_e.conversationId)):await Hn(_e.conversationId),_e.queued===!0&&_(ds=>ds.filter(Ds=>Ds.id!==Ae.id)),b==null||b(n,_e.conversationId))}).catch(_e=>{_(ds=>ds.filter(Ds=>Ds.id!==Ae.id)),we(Fs(_e)),V(!1)})},m1=I=>{we(null),cn(I),Ft(W=>[...W,I]),R.takeOffer(I,m??void 0).then(W=>{W.runId&&(lt(null),V(!0)),m&&Hn(m)}).catch(W=>{Ft(ee=>ee.filter(xe=>xe!==I)),we(Fs(W)),m&&Hn(m)}).finally(()=>cn(null))},g1=(I,W)=>sg({answer:I,...W?{optionId:W}:{}}),x1=()=>sg({answer:"",skipped:!0}),sg=I=>{const W=S==null?void 0:S.question;W&&(we(null),_s(!0),V(!0),Le.answerQuestion(W.id,I).then(()=>{if(m)return Hn(m)}).catch(ee=>{we(Fs(ee)),V(!1)}).finally(()=>_s(!1)))},v1=()=>{if(n){if(mt){Os(null);return}Hm(!0),R.agentProfile(n).then(I=>{Os(I),U(wh(I.id)),u&&(d==null||d())}).catch(I=>we(Fs(I))).finally(()=>Hm(!1))}},j1=I=>{Su({text:I.prompt,at:Date.now()}),o(I.agentId),u&&(h==null||h())},y1=()=>{m&&Le.cancel(m).catch(I=>we(Fs(I))).finally(()=>{V(!1),O([])})},Mo=f.useCallback(()=>{if(k(null),N(null),_([]),V(!1),we(null),lt(null),O([]),z(new Map),U(null),ve([]),Ao(null),Po.current=null,i){Le.startGroupConversation(i.id).then(({conversationId:I})=>{k(I),n&&(b==null||b(n,I))}).catch(I=>we(Fs(I)));return}T(vr),n&&(b==null||b(n,"new"))},[n,i,vr,b]);f.useEffect(()=>{x&&x!==it.current&&(it.current=x,Mo())},[x,Mo]);const rg=I=>{m&&Hn(m),R.overview().catch(()=>{}),I.state!=="pending"&&z(W=>new Map([...W].filter(([,ee])=>ee!==I.id)))},$o=f.useRef(!1);f.useEffect(()=>{const I=ee=>{if(!$o.current)return;const xe=Math.max(Ha,Math.min(720,ee.clientX-52));ot(xe)},W=()=>{if($o.current){$o.current=!1;try{ce!==null&&window.localStorage.setItem(xk,String(ce))}catch{}}};return window.addEventListener("pointermove",I),window.addEventListener("pointerup",W),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",W)}},[ce]);const w1=((hg=wn.find(I=>I.id===r))==null?void 0:hg.name)??null,ig=i?[]:F2(he,w1),lg=!(S&&S.conversationId===m)&&!(!m&&C!==null&&C===vr),og=lg?s.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&he?s.jsx(II,{quiet:!0,still:!0,className:"wb-chat-field",children:s.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[s.jsx(Xt,{agents:wn,id:he.id,size:"xl"}),s.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${he.name}.`}),s.jsx("p",{className:"wb-chat-intro",children:U2(he)}),ig.length>0?s.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${he.name}`,children:ig.map(I=>s.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var W;Su({text:I,at:Date.now()}),(W=ye.current)==null||W.focus()},children:I},I))}):null]})}):null,ag=s.jsx(W$,{renderables:dn,activeId:$,onActivate:U,onClose:I=>{mt&&I===wh(mt.id)?Os(null):fe.some(W=>Wa(W.artifactId)===I)?ve(W=>W.filter(ee=>Wa(ee.artifactId)!==I)):m&&Z(W=>{const ee={...W,[m]:[...new Set([...W[m]??[],I])]};return Fv(ee),ee}),$===I&&U(null)},timezone:e,onDecided:rg,onChangeAgent:j1,agents:wn,browserPanel:Pt?s.jsx(M_,{status:ol,error:Eo.error,reload:Eo.reload,steps:c1,live:jr!==null,focusedStepId:u1},Pt.id):null,descriptors:g,grantedTools:i?qr.flatMap(I=>I.tools??[]):(he==null?void 0:he.tools)??[],...he?{agentName:he.name}:{},loading:lg,...!i&&he?{face:s.jsx(Xt,{agents:wn,id:he.id,size:"xl"})}:{}}),cg=(mg=(pg=[...(S==null?void 0:S.messages)??[],...E].find(I=>I.role==="user"))==null?void 0:pg.blocks.find(I=>I.type==="text"))==null?void 0:mg.text.trim(),ug=cg?cg.split(`
102
- `)[0]:"New conversation",Xr=Z_({lifetime:(S==null?void 0:S.lifetime)??null,startedAt:(S==null?void 0:S.startedAt)??null,now:xr,timezone:e});return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"wb-chat",ref:un,style:u||ce===null?void 0:{width:ce},"data-sized":!u&&ce!==null?"true":void 0,"data-testid":"chat-column","data-dropping":Ne||void 0,onDragEnter:I=>{pa(I)&&(I.preventDefault(),be.current+=1,oe(!0))},onDragOver:I=>{pa(I)&&(I.preventDefault(),I.dataTransfer.dropEffect="copy")},onDragLeave:I=>{pa(I)&&(be.current=Math.max(0,be.current-1),be.current===0&&oe(!1))},onDrop:I=>{var W;pa(I)&&(I.preventDefault(),be.current=0,oe(!1),n&&((W=ye.current)==null||W.addFiles(I.dataTransfer.files)))},children:[Ne?s.jsx("div",{className:"wb-drop","aria-hidden":"true",children:s.jsxs("div",{className:"wb-drop-card",children:[s.jsx(sO,{}),s.jsx("strong",{children:"Drop to attach"}),s.jsx("span",{children:he?`It goes with your next message to ${he.name}`:"Pick an agent first"})]})}):null,s.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&he?bo(wo(he)):{},children:[s.jsxs("div",{className:"wb-head-row",children:[i?s.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:qr.slice(0,3).map(I=>s.jsx(Xt,{agents:wn,id:I.id,size:"sm"},I.id))}):he?s.jsx("a",{className:"wb-head-face",href:ht(he.id),"aria-label":`${he.name}'s page`,children:s.jsx(Xt,{agents:wn,id:he.id})}):null,s.jsxs("div",{className:"wb-head-text",children:[i?s.jsx("span",{className:"wb-head-title",children:i.name}):s.jsx("span",{className:"wb-head-title",title:ug,children:ug}),s.jsx("span",{className:"wb-head-meta","data-tone":Xr.tone,title:i?`${qr.map(I=>I.name).join(", ")}. Coordinator: ${(he==null?void 0:he.name)??i.coordinator}.`:Xr.title,children:i?`${qr.map(I=>I.name).join(", ")} · ${Xr.text}`:he?s.jsxs(s.Fragment,{children:[s.jsx("a",{className:"wb-head-name",href:ht(he.id),title:`${he.name}'s page`,children:he.name})," ",s.jsxs("span",{className:"wb-head-handle",children:["@",he.handle]}),` · ${Xr.tone==="quiet"&&Xr.text==="New conversation"?`on ${j}`:Xr.text}`]}):"No agent"})]}),s.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!n,onClick:()=>{Ve(!1),Mo()},children:s.jsx(Oe,{name:"plus",size:16})}),s.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":Te,"data-open":Te?"true":void 0,disabled:!n,onClick:()=>Ve(I=>!I),children:s.jsx(lO,{})}),u?s.jsxs("button",{className:"ui-btn",onClick:d,disabled:dn.length===0,children:["Canvas",dn.length>0?` (${dn.length})`:""]}):null,s.jsx(aO,{disabled:!n,items:i?[...qr.map(I=>({label:I.name,hint:I.id===i.coordinator?"Coordinator · open page":"Member · open page",href:ht(I.id)})),...l?[{label:"Members…",hint:"Name, coordinator, who is in the room",testId:"group-members",onSelect:l}]:[]]:[{label:mt?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:us,onSelect:v1},...he?[{label:"Set up",hint:"Identity, model and access",href:ht(he.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:ht(he.id)}]:[]]})]}),c?s.jsx($0,{agents:t,currentId:n,attention:a,onSelect:o,orientation:"horizontal"}):null]}),Te&&n?s.jsx(W_,{agentId:n,...i?{groupId:i.id}:{},currentId:m,timezone:e,onNew:()=>{Ve(!1),Mo()},onSelect:I=>{if(I===m){Ve(!1);return}Ve(!1),N(null),_([]),V(!1),U(null),we(null),lt(null),ve([]),k(I),b==null||b(n,I,!1)}}):null,n&&m?s.jsx(__,{agentId:n,conversationId:m},`${n}:${m}`):null,ke?s.jsx("div",{className:"wb-chat-notice",children:s.jsx(re,{message:ke})}):null,Je?s.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:Je}):null,S!=null&&S.carriedOver?s.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:S.carriedOver}):null,s.jsx(uk,{messages:[...(S==null?void 0:S.messages)??[],...E],live:F,now:xr,working:q,partial:A,agents:wn,...S!=null&&S.runs?{runs:S.runs}:{},...i?{speakers:wn,coordinatorId:i.coordinator}:{},...Nu?{workingAs:((gg=wn.find(I=>I.id===Nu))==null?void 0:gg.name)??Nu}:{},onOpenFile:Zm,onOpen:I=>{if(Pt){const W=Lv([...(S==null?void 0:S.messages)??[],...E],I);if(W){Ao(W),U(Pt.id),u&&(d==null||d());return}}m&&Z(W=>{const ee={...W,[m]:(W[m]??[]).filter(xe=>xe!==I)};return Fv(ee),ee}),U(I),u&&(d==null||d())},...he?{agentName:he.name}:{},...og?{empty:og}:{},emptyHint:he?`Nothing here yet. Ask ${he.name} for something.`:"Loading agents…"}),tg.length>0?s.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:tg.map(I=>s.jsx("button",{className:"ui-btn",disabled:St!==null,title:I.prompt,onClick:()=>m1(I.id),children:I.label},I.id))}):null,Io?s.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:s.jsxs(K,{tone:"warning",role:"status",children:[Io," ",s.jsx("a",{href:st(eg.section),children:eg.label})]})}):To.length>0?s.jsx(S$,{approvals:To,timezone:e,now:xr,version:S,onDecided:rg,onSay:I=>ng(I,[]),onOpenFull:I=>{U(I),u&&(d==null||d())}}):null,Io||To.length>0?null:S!=null&&S.question?s.jsx(Q_,{question:S.question,disabled:$s||q,onAnswer:g1,onSkip:x1},S.question.id):null,Io?null:s.jsx("div",{hidden:To.length>0||!!(S!=null&&S.question),"data-testid":"composer-slot",children:s.jsx(Y_,{ref:ye,disabled:!n,running:q,onSend:ng,onStop:y1,agentName:i?i.name:(he==null?void 0:he.name)??"the agent",draft:s1,history:f1,threadKey:m??(i?`group:${i.id}`:n),model:i?null:(he==null?void 0:he.model)??null,setupHref:i?null:he?ht(he.id,"setup","brain"):null,thinking:h1,...!i&&he?{onThinking:p1}:{},...i?{mentions:qr.map(I=>({handle:I.handle,name:I.name}))}:{},onOpenFile:Zm})})]}),u?p?s.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[s.jsxs("div",{className:"wb-sheet-head",children:[s.jsx("strong",{children:"Canvas"}),s.jsx("button",{className:"ui-btn",onClick:h,children:"Close"})]}),ag]}):null:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:I=>{var W,ee;$o.current=!0,(ee=(W=I.currentTarget).setPointerCapture)==null||ee.call(W,I.pointerId)},onKeyDown:I=>{const W=ee=>{var xe;return ee??((xe=un.current)==null?void 0:xe.offsetWidth)??Ha};I.key==="ArrowLeft"&&ot(ee=>Math.max(Ha,W(ee)-16)),I.key==="ArrowRight"&&ot(ee=>Math.min(720,W(ee)+16))}}),ag]})]})}function tO(){try{const e=window.localStorage.getItem(xk),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Ha?t:null}catch{return null}}function nO(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function Nt(e){return typeof e=="string"&&e!==""?e:null}function Fs(e){return e instanceof de||e instanceof Error?e.message:String(e)}function Md(e,t){var r;const n=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!n)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const l=e.messages[i];if(l.role!=="user")continue;const o=l.blocks.find(a=>a.type==="text");if(o)return o.text.trim()===n}return!1}function pa(e){var n;const t=(n=e.dataTransfer)==null?void 0:n.types;return!!(t&&Array.from(t).includes("Files"))}function sO(){return s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),s.jsx("path",{d:"M5 19.5v2a2.5 2.5 0 0 0 2.5 2.5h13a2.5 2.5 0 0 0 2.5-2.5v-2"})]})}const bh="buddi.chatDraft";function rO(e,t){try{window.sessionStorage.setItem(bh,JSON.stringify({agentId:e,text:t}))}catch{}}function iO(e){try{const t=window.sessionStorage.getItem(bh);if(!t)return null;const n=JSON.parse(t);return n.agentId!==e||typeof n.text!="string"?null:(window.sessionStorage.removeItem(bh),n.text)}catch{return null}}function lO(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),s.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function oO(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[s.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function aO({items:e,disabled:t}){const[n,r]=f.useState(!1),i=f.useRef(null);return f.useEffect(()=>{if(!n)return;const l=a=>{i.current&&!i.current.contains(a.target)&&r(!1)},o=a=>{a.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",o),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",o)}},[n]),s.jsxs("div",{className:"wb-head-menu",ref:i,children:[s.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":"More about this agent","aria-haspopup":"menu","aria-expanded":n,"data-open":n?"true":void 0,disabled:t,onClick:()=>r(l=>!l),children:s.jsx(oO,{})}),n?s.jsx("div",{className:"ui-menu wb-head-menu-list",role:"menu",children:e.map(l=>l.href?s.jsxs("a",{className:"ui-menu-item",role:"menuitem",href:l.href,onClick:()=>r(!1),children:[s.jsx("span",{className:"ui-menu-item-text",children:l.label}),l.hint?s.jsx("span",{className:"ui-menu-item-hint",children:l.hint}):null]},l.label):s.jsxs("button",{className:"ui-menu-item",role:"menuitem","data-testid":l.testId,disabled:l.disabled,onClick:()=>{var o;r(!1),(o=l.onSelect)==null||o.call(l)},children:[s.jsx("span",{className:"ui-menu-item-text",children:l.label}),l.hint?s.jsx("span",{className:"ui-menu-item-hint",children:l.hint}):null]},l.label))}):null]})}function cO(e,t){const n=l=>{var o;return`@${((o=t.find(a=>a.id===l))==null?void 0:o.handle)??l}`},[r,...i]=e;return r===void 0?"":[n(r),...i.map(l=>`asked by ${n(l)}`)].join(", ")}const vk=3;function uO(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function dO(e){return e.state==="shown"&&e.seenAt===null}function fO(e){const[t,n]=f.useState([]),r=f.useRef(new Set),i=f.useRef(new Set),l=f.useCallback(()=>{e&&R.notifications(20).then(({notifications:a})=>{const c=a.filter(u=>dO(u)&&!r.current.has(u.id));n(u=>{const p=new Set(u.map(h=>h.id)),d=c.filter(h=>!p.has(h.id));return d.length===0?u:[...u,...d].sort((h,x)=>x.createdAt.localeCompare(h.createdAt))})}).catch(()=>{})},[e]);f.useEffect(()=>{for(const a of t.slice(0,vk))i.current.has(a.id)||(i.current.add(a.id),R.notificationSeen(a.id).catch(()=>{}))},[t]);const o=f.useCallback(a=>{r.current.add(a),n(c=>c.filter(u=>u.id!==a))},[]);return{queue:t,refresh:l,dismiss:o}}function hO({queue:e,agents:t,navigate:n,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,vk),l=e.length-i.length;return s.jsxs("section",{className:"nt-toasts","aria-label":"Notifications",children:[i.map(o=>s.jsxs("div",{className:"ui-toast nt-toast","data-tone":uO(o.kind),role:"status",children:[o.agentId?s.jsx(Xt,{agents:t,id:o.agentId,size:"sm"}):null,s.jsxs("div",{className:"nt-toast-main",children:[s.jsx("div",{className:"ui-toast-title",children:o.title}),o.text?s.jsx("div",{className:"ui-toast-body nt-toast-line",children:pO(o.text)}):null,o.link?s.jsx("a",{className:"nt-toast-link",href:o.link,onClick:a=>{a.preventDefault(),r(o.id),n(o.link)},children:"See"}):null]}),s.jsx("button",{type:"button",className:"nt-toast-x","aria-label":`Dismiss ${o.title}`,onClick:()=>r(o.id),children:"×"})]},o.id)),l>0?s.jsxs("p",{className:"nt-toasts-more",children:["and ",l," more"]}):null]})}function pO(e){var t;return((t=e.split(`
103
- `).find(n=>n.trim()!==""))==null?void 0:t.trim())??""}const mO=3e4,gO=1e3;function xO(e,t,n){const r=f.useRef(t);r.current=t;const i=f.useRef(n);i.current=n,f.useEffect(()=>{if(!e)return;let l=!1,o=-1/0,a=null,c=null,u=!0;const p=()=>document.visibilityState!=="hidden",d=j=>{var g;o=Date.now(),R.presence(j).catch(y=>{var m;y instanceof de&&y.status===401&&(l=!0,(m=i.current)==null||m.call(i))}),j==="active"&&((g=r.current)==null||g.call(r))},h=j=>{if(l||(a=j,c!==null))return;const g=o+gO-Date.now();if(g<=0){a=null,d(j);return}c=window.setTimeout(()=>{if(c=null,l||a===null)return;const y=a;a=null,d(y)},g)},x=()=>{u=!0,p()&&h("active")},v=()=>{u=!1,h("away")},w=()=>h(p()?"active":"away");p()&&h("active");const b=window.setInterval(()=>{p()&&u&&h("active")},mO);return window.addEventListener("focus",x),window.addEventListener("blur",v),document.addEventListener("visibilitychange",w),()=>{l=!0,window.clearInterval(b),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",x),window.removeEventListener("blur",v),document.removeEventListener("visibilitychange",w)}},[e])}function Bv({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:l}){return!t&&!P0(e)?s.jsx(Yt,{title:"A new group",onClose:n,children:s.jsxs(K,{children:["A group needs two agents. Make another one with ",O2(e)," first."]})}):s.jsx(jO,{agents:vO(e,t),group:t??null,onClose:n,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...l?{onArchived:l}:{}})}function vO(e,t){const n=T0(e),r=((t==null?void 0:t.members)??[]).filter(i=>!n.some(l=>l.id===i)).map(i=>e.find(l=>l.id===i)).filter(i=>i!==void 0);return[...n,...r]}function jO({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:l}){var C,T;const o=t!==null,[a,c]=f.useState((t==null?void 0:t.name)??""),[u,p]=f.useState((t==null?void 0:t.members)??[]),[d,h]=f.useState((t==null?void 0:t.coordinator)??((C=e.find(E=>E.roles.includes(pm)))==null?void 0:C.id)??((T=e[0])==null?void 0:T.id)??""),[x,v]=f.useState(!1),[w,b]=f.useState(!1),[j,g]=f.useState(null),y=[...new Set([d,...u])].filter(Boolean),m=a.trim()!==""&&d!==""&&y.length>=2,k=E=>p(_=>_.includes(E)?_.filter(F=>F!==E):[..._,E]),S=async()=>{v(!0),g(null);try{t?i==null||i(await Le.updateGroup(t.id,{name:a.trim(),coordinator:d,members:y})):r==null||r(await Le.createGroup({name:a.trim(),coordinator:d,members:y.filter(E=>E!==d)}))}catch(E){g(E instanceof de?E.message:String(E))}finally{v(!1)}},N=async()=>{if(t){v(!0),g(null);try{await Le.archiveGroup(t.id),l==null||l(t.id)}catch(E){g(E instanceof de?E.message:String(E)),v(!1)}}};return s.jsx(Yt,{title:o?`${t.name}: members`:"A new group",onClose:n,children:s.jsxs(G,{children:[s.jsx(te,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:s.jsx("input",{value:a,autoFocus:!0,maxLength:80,onChange:E=>c(E.target.value),placeholder:"Household finances"})}),s.jsx(te,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:s.jsx("select",{value:d,onChange:E=>h(E.target.value),children:e.map(E=>s.jsx("option",{value:E.id,children:E.name},E.id))})}),s.jsx(te,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:s.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(E=>E.id!==d).map(E=>s.jsxs("label",{className:"group-pick-row","data-on":u.includes(E.id)||void 0,children:[s.jsx("input",{type:"checkbox",checked:u.includes(E.id),onChange:()=>k(E.id)}),s.jsx(Xt,{agents:e,id:E.id,size:"sm"}),s.jsxs("span",{className:"group-pick-text",children:[s.jsx("span",{className:"group-pick-name",children:E.name}),s.jsx("span",{className:"group-pick-desc",children:E.description})]})]},E.id))})}),s.jsx(K,{children:"Members read what is said in this group and what they recall from shared and group memory. Nothing an agent knows privately is brought in on its own: what enters the room is seen by the room."}),o?s.jsx(K,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,j?s.jsx(K,{tone:"critical",children:j}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!m||x,onClick:()=>void S(),children:x?o?"Saving…":"Creating…":o?"Save":"Create group"})]}),o?s.jsx("div",{className:"group-archive",children:w?s.jsxs(G,{children:[s.jsxs(K,{tone:"warning",children:["Archive ",t.name,"? It leaves the rail and takes no new requests. Everything said in it stays readable."]}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:()=>b(!1),children:"Keep it"}),s.jsx(P,{variant:"danger",disabled:x,"data-testid":"group-archive-confirm",onClick:()=>void N(),children:"Archive group"})]})]}):s.jsx(P,{variant:"ghost",disabled:x,"data-testid":"group-archive",onClick:()=>b(!0),children:"Archive group"})}):null]})})}function Rm(e){const[t,n]=f.useState(null),[r,i]=f.useState(null),[l,o]=f.useState(null);return{busy:t,note:r,failure:l,decide:async(c,u,p,d)=>{var x,v,w,b;n(c),o(null),i(null);let h;try{const j=d?await R.decide(c,u,p,d):await R.decide(c,u,p);h={decision:u,...(x=j.execution)!=null&&x.state?{state:j.execution.state}:{},...j.execution&&"result"in j.execution?{result:j.execution.result}:{}},i(u==="reject"?`Rejected ${j.action.tool}.`:((v=j.execution)==null?void 0:v.state)==="succeeded"?`Approved and done: ${j.action.tool}.`:`Approved ${j.action.tool}: ${((w=j.execution)==null?void 0:w.state)??"no execution"}${(b=j.execution)!=null&&b.message?` (${j.execution.message})`:""}`)}catch(j){o(j instanceof Error?j.message:String(j))}finally{n(null),e(h)}}}}function Tm({action:e,timezone:t,busy:n,onDecide:r,agentName:i}){var p,d;const[l,o]=f.useState(!1),{values:a,controls:c}=wm(e.choices),u=h=>a?r(e.id,"approve",h,a):r(e.id,"approve",h);return s.jsxs(Fr,{tone:"accent",title:e.tool,meta:s.jsxs(s.Fragment,{children:[s.jsxs(pe,{children:["v",e.toolVersion]}),s.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[s.jsx(ut,{children:e.preview}),s.jsxs("p",{className:"ui-card-meta",children:["Expires ",Ie(e.expiresAt,t)," (",Ce(e.expiresAt),"). Policy v",e.policyVersion,", args ",lo(e.argsHash,12),e.jobId?`, job ${lo(e.jobId)}`:"","."]}),c,s.jsxs(J,{children:[s.jsx(P,{variant:"good",disabled:n,onClick:()=>u(),children:(p=e.permissionScopes)!=null&&p.length?"Allow once":"Approve"}),(d=e.permissionScopes)!=null&&d.length?s.jsxs(s.Fragment,{children:[s.jsx(P,{disabled:n,onClick:()=>u("conversation"),children:"Auto: this conversation"}),s.jsx(P,{disabled:n,onClick:()=>u("always"),children:"Always: this agent"})]}):null,s.jsx(P,{variant:"danger",disabled:n,onClick:()=>r(e.id,"reject"),children:"Reject"}),s.jsx(P,{variant:"ghost",onClick:()=>o(h=>!h),"aria-expanded":l,children:l?"Hide envelope":"Show envelope"})]}),l?s.jsxs("div",{className:"ui-card-foot",children:[s.jsx(Y,{title:"Envelope: everything that decides what the world will see",children:s.jsx(ut,{children:ln(e.envelope)})}),s.jsx(Y,{title:"Canonical arguments",children:s.jsx(ut,{children:ln(e.canonicalArgs)})})]}):null]})}function jk(e,t,n){const[r,i]=f.useState(!1),[l,o]=f.useState(null),[a,c]=f.useState(null);return{accept:()=>{e&&(i(!0),c(null),R.acceptPluginAgent(e,t).then(p=>{o(p.agent)}).catch(p=>c(p instanceof de?p.message:String(p))).finally(()=>i(!1)))},busy:r,created:l,failure:a}}function yk({agent:e}){return s.jsxs(K,{tone:"good",role:"status",children:["@",e.handle," is ready. ",s.jsxs("a",{href:Fe(e.id),children:["Talk to @",e.handle]})]})}function wk(e,t,n){const r=e.canonicalArgs;return e.tool==="platform.accept_plugin_agent"&&(r==null?void 0:r.plugin)===t&&typeof r.agent=="string"&&r.agent.toLowerCase()===n.toLowerCase()}function yO(e,t){var i;const n=se(()=>R.approvals(),[e,t],15e3);return{action:((i=n.data)==null?void 0:i.pending.find(l=>wk(l,e,t)))??null,reload:n.reload}}function wO({action:e,onDecided:t}){const{busy:n,failure:r,decide:i}=Rm(l=>t(l));return s.jsxs(G,{gap:"sm",children:[s.jsx(Tm,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:n===e.id,onDecide:(l,o,a,c)=>{i(l,o,a,c)}}),s.jsx(re,{message:r})]})}function Pm({plugin:e,agent:t,text:n,label:r,handle:i,onDismiss:l}){var d;const o=jk(e,t),a=yO(e,t),[c,u]=f.useState(null),p=o.created??c;if(p)return s.jsx(yk,{agent:p});if(a.action){const h=i??((d=/@(\S+)/.exec(r))==null?void 0:d[1])??t;return s.jsxs(G,{gap:"sm",children:[s.jsx("span",{children:n}),s.jsx(wO,{action:a.action,onDecided:x=>{(x==null?void 0:x.decision)==="approve"&&x.state==="succeeded"?u({id:t,handle:h,name:h}):a.reload()}})]})}return s.jsxs(G,{gap:"sm",children:[s.jsxs(J,{children:[s.jsx("span",{children:n}),s.jsx(rl,{}),l?s.jsx(P,{variant:"ghost",disabled:o.busy,onClick:l,children:"Not now"}):null,s.jsx(P,{variant:"accent",disabled:o.busy,onClick:o.accept,children:r})]}),s.jsx(re,{message:o.failure})]})}function bk(){var t;const e=se(()=>R.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function kk({offers:e,reload:t}){return e.length===0?null:s.jsx(Y,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:s.jsx(G,{gap:"sm",divided:!0,children:e.map(n=>s.jsx(Pm,{plugin:n.plugin,agent:n.agent,text:n.text,label:`Create @${n.handle}`,handle:n.handle,onDismiss:()=>{R.dismissAgentOffer(n.plugin,n.agent).then(t,t)}},`${n.plugin}/${n.agent}`))})})}const Im=f.createContext(null),Pc=f.createContext(!1);function kt(){const e=f.useContext(Im);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function kh(e,t=new Set){if(Array.isArray(e))for(const n of e)kh(n,t);else if(e&&typeof e=="object"){const n=e.query;typeof n=="string"&&t.add(n);for(const r of Object.values(e))kh(r,t)}return t}function Sk(e,t){if(t.size===0)return!1;for(const n of kh(e))if(t.has(n))return!0;return!1}function Nk(){const[e,t]=f.useState(!1);return f.useEffect(()=>{if(!e)return;const n=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",n),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",n),window.removeEventListener("blur",n)}},[e]),[e,()=>t(n=>!n)]}function Ck({revealed:e,onToggle:t}){return s.jsx(P,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function Ek(){return s.jsx("p",{className:"muted",children:"Hidden until you show it."})}function Ak({children:e}){const[t,n]=Nk();return s.jsxs(G,{gap:"sm",children:[s.jsx(J,{align:"end",children:s.jsx(Ck,{revealed:t,onToggle:n})}),t?s.jsx(Pc.Provider,{value:!0,children:e}):s.jsx(Ek,{})]})}function Mm(e){return e===void 0||e==="neutral"?void 0:e}function Sh(e){return Mm(e)}function bO(e){const t=Mm(e);return t==="accent"?void 0:t}function ns(e,t){if(!t)return!0;const n=ge(e,t.path),r=t.in!==void 0?t.in.includes(n):n===t.equals;return t.not===!0?!r:r}function $m(e,t,n){if("chat"in t){const l=Se(n,t.chat);return l==null?"":Fe(String(l))}if("proposals"in t)return m2(e.plugin);const r=e.pages.find(l=>l.id===t.page);if((r==null?void 0:r.place)==="settings")return hm(e.plugin,t.page);const i=t.item===void 0?null:Se(n,t.item);return oo(e.plugin,t.page,i==null?null:String(i))}function kO(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(n,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(n,r)=>{const i=ge(t.row,r);return i==null?"":String(i)})}function Nh(e,t){if(e===void 0)return;if(typeof e=="string")return e;const n=Se(t,e);return n==="good"||n==="warning"||n==="critical"||n==="neutral"?n:void 0}function Rk(e,t,n){const r={};for(const[i,l]of Object.entries(e??{})){let o;"param"in l?o=n.params[l.param]:"route"in l?o=l.route==="plugin"?n.plugin:l.route==="page"?n.page:n.item:o=Se(t,l),!(o==null||o==="")&&(r[i]=String(o))}return r}function Bi(e,t){var r,i,l;const n={};for(const[o,a]of Object.entries(e??{}))if("row"in a)n[o]=ge(t.row,a.row);else if("field"in a){if((r=t.omit)!=null&&r.has(a.field))continue;const c=(i=t.fields)==null?void 0:i[a.field],u=(l=t.shape)==null?void 0:l.find(p=>p.name===a.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;n[o]=c}else"selected"in a?n[o]=t.selected??[]:"param"in a?n[o]=t.scope.params[a.param]:n[o]=Se(t.data,a);return n}function as(e,t){const n=kt(),r=e?Rk(e.params,t,n):{},i=JSON.stringify([(e==null?void 0:e.query)??null,r,n.version]),l=se(()=>e?R.pageQuery(n.plugin,e.query,r).then(o=>o.data):Promise.resolve(void 0),[i]);return{data:l.data,error:l.error,loading:l.loading}}function ko(){const e=kt(),[t,n]=f.useState(null),[r,i]=f.useState(null),[l,o]=f.useState(null),[a,c]=f.useState(null),[u,p]=f.useState(null),d=(w,b)=>{if(w.done===void 0)return null;if(typeof w.done=="string")return w.done;const j=Se(b,w.done);return j==null?null:String(j)},h=(w,b,j)=>{const g=w??"refresh";if(typeof g=="object"){const y=$m(e,g.route,b);y===""?e.refresh():e.navigate(y);return}g==="close"&&(j==null||j()),e.refresh()},x=async(w,b,j)=>{n(w.tool),i(null),o(null);try{const g=await R.pageAct(e.plugin,{tool:w.tool,args:b});if(g.approvalId){c(g.approvalId),p({then:w.then,ref:w,...j?{onDone:j}:{}});return}c(null),p(null),o(d(w,g.result)),h(w.then,g.result,j)}catch(g){i(g instanceof Error?g.message:String(g)),e.refresh()}finally{n(null)}},v=w=>{if(!w){e.refresh();return}const b=u;if(c(null),p(null),b&&w.decision==="approve"&&w.state==="succeeded"){o(d(b.ref,w.result)),h(b.then,void 0,b.onDone);return}e.refresh()};return{running:t,busy:t!==null,error:r,done:l,approvalId:a,waiting:(u==null?void 0:u.ref.pending)??null,settle:v,run:x}}function zi({action:e,args:t,disabled:n,running:r,count:i,row:l,onRun:o}){const[a,c]=f.useState(!1),u=d=>kO(d,{...i===void 0?{}:{count:i},row:l}),p=u(e.label);return a&&e.confirm?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),s.jsx(P,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsxs(P,{variant:e.tone==="danger"?"danger":"accent",disabled:n,onClick:()=>{c(!1),o(e,t)},children:["Yes, ",p.toLowerCase()]})]}):s.jsx(P,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:n,onClick:()=>e.confirm?c(!0):o(e,t),children:r&&e.busy?e.busy:p})}function Ch({id:e,onDecided:t}){const n=kt(),r=se(()=>R.approval(e),[e,n.version]),{busy:i,note:l,failure:o,decide:a}=Rm(c=>{t?t(c):n.refresh()});return r.error?s.jsx(re,{message:r.error}):r.data?s.jsxs(G,{children:[s.jsx(Tm,{action:r.data,timezone:n.timezone,busy:i===e,onDecide:(c,u,p,d)=>{a(c,u,p,d)}}),l?s.jsx(K,{tone:"good",role:"status",children:l}):null,s.jsx(re,{message:o})]}):s.jsx(le,{children:"Loading the approval…"})}function ll({act:e}){return e.error?s.jsx(re,{message:e.error}):e.approvalId?e.waiting?s.jsxs(G,{children:[s.jsx(K,{role:"status",children:e.waiting}),s.jsx(Ch,{id:e.approvalId,onDecided:e.settle})]}):s.jsx(Ch,{id:e.approvalId,onDecided:e.settle}):e.done?s.jsx(K,{tone:"good",role:"status",children:e.done}):null}function Ic(e,t){const n={};for(const r of e){const i=r.from===void 0?void 0:ge(t,r.from);n[r.name]=i!==void 0?i:r.type==="checkbox"?!1:(r.type==="number","")}return n}function SO(e,t,n){const r=kt(),i=e.optionsFrom,l=i?{...Rk(i.query.params,n,r),...Object.fromEntries((i.dependsOn??[]).map(c=>[c,String(t[c]??"")]).filter(([,c])=>c!==""))}:{},o=JSON.stringify([(i==null?void 0:i.query.query)??null,l,r.version]),a=se(()=>i?R.pageQuery(r.plugin,i.query.query,l).then(c=>c.data):Promise.resolve(void 0),[o]);return i?{options:Wi(a.data,i.rows).map(c=>({value:String(ge(c,i.value)??""),label:String(ge(c,i.label)??"")})),loading:a.loading}:{options:e.options??[],loading:!1}}function NO({field:e,value:t,values:n,data:r,disabled:i,compact:l,onChange:o}){const a=SO(e,n,r),c={id:`f-${e.name}`,required:e.required,name:e.name,disabled:i,...l&&e.hint?{title:e.hint}:{}},u=l?void 0:e.hint;if(e.type==="select")return s.jsx(te,{label:e.label,hint:u,children:s.jsxs("select",{...c,value:String(t??""),onChange:d=>o(d.target.value),children:[s.jsx("option",{value:"",children:a.loading?"Loading…":"—"}),a.options.map(d=>s.jsx("option",{value:d.value,children:d.label},d.value))]})});if(e.type==="textarea")return s.jsx(te,{label:e.label,hint:u,wide:!0,children:s.jsx("textarea",{...c,value:String(t??""),onChange:d=>o(d.target.value),rows:6})});if(e.type==="checkbox")return s.jsx(te,{label:e.label,hint:u,inline:!0,wide:!l,children:s.jsx("input",{...c,type:"checkbox",checked:t===!0,onChange:d=>o(d.target.checked)})});const p=e.type==="secret"?"password":e.type==="number"?"number":e.type;return s.jsx(te,{label:e.label,hint:u,children:s.jsx("input",{...c,type:p,value:t==null?"":String(t),min:e.min,max:e.max,step:e.step,...l&&e.hint?{placeholder:e.hint}:{},onChange:d=>o(e.type==="number"?CO(d.target.value):d.target.value)})})}function CO(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function Tk(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function Pk(e,t,n){const r=Tk(t,n);return new Set(e.filter(i=>i.when!==void 0&&!ns(r,i.when)||i.disabledWhen!==void 0&&ns(r,i.disabledWhen)).map(i=>i.name))}function _m({fields:e,values:t,data:n,disabled:r,compact:i,onChange:l}){const o=Tk(t,n);return s.jsx(As,{dense:i,children:e.filter(a=>a.when===void 0||ns(o,a.when)).map(a=>s.jsx(NO,{field:a,compact:i,value:t[a.name],values:t,data:n,disabled:r===!0||a.disabledWhen!==void 0&&ns(o,a.disabledWhen),onChange:c=>l(a.name,c)},a.name))})}const uo=f.createContext(!1),Ik=f.createContext(!1),Mk=f.createContext(!1);function Ms({title:e,note:t,actions:n,children:r}){const i=f.useContext(uo);return s.jsx(Y,{title:e,aside:t,actions:n,panel:i,children:s.jsx(uo.Provider,{value:!1,children:s.jsx(Ik.Provider,{value:i,children:r})})})}function Rs({component:e,data:t,choose:n,chosen:r}){const i=kt(),l=f.useContext(Pc);if(!ns(t,e.when))return null;if(e.kind!=="section"&&!l&&Sk(e,i.sensitive))return s.jsx(Ak,{children:s.jsx(Rs,{component:e,data:t,...n?{choose:n}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return s.jsx(EO,{component:e,data:t});case"notice":return s.jsx(K,{tone:Mm(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(Se(t,e.text)??"")});case"link":return s.jsx(AO,{component:e,data:t});case"stats":return s.jsx(RO,{component:e,data:t});case"list":return s.jsx(PO,{component:e,data:t,...n?{onChoose:n}:{},...r===void 0?{}:{chosen:r}});case"table":return s.jsx(IO,{component:e,data:t});case"detail":return s.jsx(_O,{component:e,data:t});case"form":return s.jsx(OO,{component:e,data:t});case"search":return s.jsx(FO,{component:e,data:t});case"list-detail":return s.jsx(UO,{component:e,data:t});case"repeat":return s.jsx(BO,{component:e,data:t});case"expand":return s.jsx(zO,{component:e,data:t});case"button":return s.jsx(WO,{component:e,data:t});case"approval":return s.jsx(HO,{component:e,data:t});case"artifact":return s.jsx(KO,{component:e,data:t});case"editor":return s.jsx(GO,{component:e,data:t});case"agent-offer":return s.jsx(VO,{component:e});default:return null}}function EO({component:e,data:t}){const n=kt(),r=f.useContext(Pc),[i,l]=Nk(),o=!r&&Sk(e.body,n.sensitive),a=o&&!i,c=f.useContext(uo);let u=e.body.length;const p=x=>x.kind==="button"||x.kind==="link"||x.kind==="form"&&x.drawer!==void 0&&!x.title;for(;c&&u>0&&p(e.body[u-1]);)u-=1;const d=e.body.slice(0,u),h=[...e.actions??[],...e.body.slice(u)];return s.jsx(Ms,{title:e.title,note:e.note,actions:h.length>0||o?s.jsxs(s.Fragment,{children:[h.map((x,v)=>s.jsx(Rs,{component:x,data:t},v)),o?s.jsx(Ck,{revealed:i,onToggle:l}):null]}):void 0,children:s.jsx(G,{gap:"lg",divided:c,children:a?s.jsx(Ek,{}):s.jsx(Pc.Provider,{value:r||o,children:d.map((x,v)=>s.jsx(Rs,{component:x,data:t},v))})})})}function AO({component:e,data:t}){const n=kt(),r=$m(n,e.to,t);return r===""?null:s.jsx(J,{children:s.jsx(Bn,{href:r,onClick:i=>{i.preventDefault(),n.navigate(r)},children:e.label})})}function RO({component:e,data:t}){const n=as(e.query,t);return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(re,{message:n.error}),n.data===void 0?s.jsx(le,{children:e.empty??"Loading…"}):s.jsx(pu,{children:e.items.map((r,i)=>s.jsx(Xn,{label:r.label,value:yt(Se(n.data,r.value),r.unit??"text",null),tone:bO(r.tone)},i))})]})}function $k(e,t,n,r){const i=(t.meta??[]).map(u=>String(Se(n,u)??"")).filter(u=>u!==""),l=String(Se(n,t.title)??""),o=t.to&&!r?$m(e,t.to,n):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,p)=>{const d=Se(n,u.value);if(d==null||d==="")return null;const h=TO(u,d,n);return s.jsx(pe,{tone:Sh(h.tone),children:h.text},p)});return{text:l,href:o,pills:s.jsx(s.Fragment,{children:c}),meta:i.join(" · "),title:o?s.jsx("a",{href:o,onClick:u=>{u.preventDefault(),e.navigate(o)},children:l}):l,sub:t.sub?String(Se(n,t.sub)??""):null,side:s.jsxs(s.Fragment,{children:[c,i.length>0?s.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function TO(e,t,n){const r=String(t),i=e.labels??{},l=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(l,r)?l[r]:Nh(e.tone,n)}}function Wi(e,t){const n=ge(e,t);return Array.isArray(n)?n:[]}function _k(e,t,n){const r=[],i=new Set;return e.forEach((l,o)=>{const a=t===void 0?void 0:ge(l,t),c=a==null||a===""?null:String(a);if(c===null){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: row ${o} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:l})}),r}function PO({component:e,data:t,onChoose:n,chosen:r}){var k;const i=kt(),l=f.useContext(Mk),o=as(e.query,t),a=ko(),[c,u]=f.useState([]),p=l&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,d=Wi(o.data,e.rows),h=e.collapsed?Wi(o.data,e.collapsed.rows):[],x={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},v=_k([...d,...h],e.key??((k=e.select)==null?void 0:k.key),x),w=new Map(v.map(S=>[S.row,S.key])),b=new Set(v.map(S=>S.row)),j=new Set(v.filter(({row:S})=>{var N;return((N=e.select)==null?void 0:N.disabledWhen)===void 0||!ns(S,e.select.disabledWhen)}).map(({key:S})=>S)),g=c.filter(S=>j.has(S)),y=f.useMemo(()=>{const S=d.filter(C=>b.has(C));if(!e.groupBy)return[{label:null,rows:S}];const N=new Map;for(const C of S){const T=String(ge(C,e.groupBy.key)??"");N.set(T,[...N.get(T)??[],C])}return[...N].map(([C,T])=>{var E,_;return{label:((_=(E=e.groupBy)==null?void 0:E.labels)==null?void 0:_[C])??C,rows:T}})},[d,e.groupBy,v.length]),m=S=>S.map(N=>{var F;const C=$k(i,e.item,N,n),T=w.get(N);if(p&&(n||C.href))return s.jsx(H0,{href:C.href??"#",current:r===T,onClick:()=>n?n(T):i.navigate(C.href),title:C.text,meta:C.meta,sub:C.sub,side:C.pills},T);const E=((F=e.select)==null?void 0:F.disabledWhen)!==void 0&&ns(N,e.select.disabledWhen),_=(e.actions??[]).filter(O=>ns(N,O.when));return s.jsx(rn,{lead:e.select?s.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(T),onClick:O=>O.stopPropagation(),onChange:O=>u(A=>O.target.checked?[...A,T]:A.filter(D=>D!==T))}):void 0,title:n?s.jsx("a",{href:"#","aria-current":r===T?"true":void 0,onClick:O=>{O.preventDefault(),n(T)},children:C.text}):C.title,sub:C.sub,side:s.jsxs(s.Fragment,{children:[C.side,_.map((O,A)=>s.jsx(zi,{action:O,args:Bi(O.args,{data:o.data,row:N,scope:i}),disabled:a.busy,running:a.running===O.tool,row:N,onRun:(D,q)=>void a.run(D,q)},A))]})},T)});return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(re,{message:o.error}),s.jsx(ll,{act:a}),y.every(S=>S.rows.length===0)?o.loading?s.jsx(le,{children:"Loading…"}):s.jsx(Om,{text:e.empty??"Nothing here yet."}):s.jsxs(Ht,{children:[e.select?s.jsx(rn,{lead:s.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:j.size>0&&g.length===j.size,disabled:j.size===0,onChange:S=>u(S.target.checked?[...j]:[])}),title:s.jsxs("span",{className:"muted",children:[j.size," to choose from"]})}):null,y.map((S,N)=>s.jsxs("div",{children:[S.label?s.jsx("div",{className:"ui-list-group",children:S.label}):null,m(S.rows)]},N))]}),e.collapsed&&h.some(S=>b.has(S))?s.jsx(bt,{summary:`${e.collapsed.label} (${h.filter(S=>b.has(S)).length})`,children:s.jsx(Ht,{children:m(h.filter(S=>b.has(S)))})}):null,e.bulk&&e.bulk.length>0?s.jsxs(J,{align:"end",children:[s.jsxs("span",{className:"ui-toolbar-note",children:[g.length," selected"]}),e.bulk.map((S,N)=>{const C=g.length>0||S.all!==!0?g:[...j];return s.jsx(zi,{action:S,args:Bi(S.args,{data:o.data,selected:C,scope:i}),count:C.length,disabled:a.busy||C.length===0,running:a.running===S.tool,onRun:(T,E)=>{u([]),a.run(T,E)}},N)})]}):null]})}function IO({component:e,data:t}){const n=kt(),r=as(e.query,t),i=ko(),l=Wi(r.data,e.rows);return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),s.jsx(ll,{act:i}),l.length===0?r.loading?s.jsx(le,{children:"Loading…"}):s.jsx(Om,{text:e.empty??"Nothing here yet."}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[e.columns.map(o=>s.jsx("th",{children:o.label},o.key)),e.actions&&e.actions.length>0?s.jsx("th",{"aria-label":"Actions"}):null]})}),s.jsx("tbody",{children:l.map((o,a)=>s.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:yt(ge(o,c.key),c.type??"text",null);return s.jsx("td",{"data-fit":c.fit,title:MO(c,o,u),children:c.pill?s.jsx($O,{column:c,row:o}):c.fit==="truncate"?s.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?s.jsx("td",{children:s.jsx(J,{align:"end",children:e.actions.filter(c=>ns(o,c.when)).map((c,u)=>s.jsx(zi,{action:c,args:Bi(c.args,{data:r.data,row:o,scope:n}),disabled:i.busy,running:i.running===c.tool,row:o,onRun:(p,d)=>void i.run(p,d)},u))})}):null]},a))})]})]})}function MO(e,t,n){if(e.hint){const r=ge(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&n?n:void 0}function $O({column:e,row:t}){var o,a;const n=ge(t,e.key);if(Array.isArray(n))return s.jsx(s.Fragment,{children:n.map((c,u)=>{var w;const p=c,d=typeof p=="object"&&p!==null?p.value:c;if(d==null||d==="")return null;const h=typeof p=="object"&&p!==null?p.tone:void 0,x=(w=e.pill)==null?void 0:w.labels,v=x&&Object.prototype.hasOwnProperty.call(x,String(d))?x[String(d)]:yt(d,e.type??"text",null);return s.jsx(pe,{tone:Sh(Nh(typeof h=="string"?h:void 0,t)),children:v},u)})});const r=(o=e.pill)==null?void 0:o.labels,i=String(n),l=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:yt(n,e.type??"text",null);return s.jsx(pe,{tone:Sh(Nh((a=e.pill)==null?void 0:a.tone,t)),children:l})}function _O({component:e,data:t}){const n=as(e.query,t);return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(le,{children:e.empty??"Loading…"}):s.jsx(Ms,{title:e.title,note:e.note,children:s.jsxs(G,{gap:"lg",children:[e.fields.length>0?s.jsx(At,{items:e.fields.map(r=>({key:r.label,label:r.label,value:yt(Se(n.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>s.jsx(Rs,{component:r,data:n.data},i))]})})}function OO({component:e,data:t}){const n=kt(),r=as(e.initial,t),i=ko(),[l,o]=f.useState(!1),a=JSON.stringify([r.data??null,n.version]),c=s.jsx(DO,{component:e,data:t,initialData:r.data,act:i,onDone:()=>o(!1)},a);return e.drawer?s.jsxs(Y,{title:e.title,aside:e.note,actions:s.jsx(P,{variant:"accent",onClick:()=>o(!0),children:e.drawer.button}),children:[s.jsx(ll,{act:i}),l?s.jsx(Yt,{title:e.drawer.title,onClose:()=>o(!1),children:c}):null]}):s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),c]})}function DO({component:e,data:t,initialData:n,act:r,onDone:i}){const l=f.useContext(Ik),o=kt(),[a,c]=f.useState(()=>Ic(e.fields,n)),u=Pk(e.fields,a,n),p=e.fields.some(d=>d.required&&!u.has(d.name)&&(a[d.name]===""||a[d.name]===void 0));return s.jsxs(G,{children:[s.jsx(_m,{fields:e.fields,values:a,data:n,onChange:(d,h)=>c(x=>({...x,[d]:h}))}),e.drawer?null:s.jsx(ll,{act:r}),s.jsx(J,{align:"end",className:l?"ui-panel-foot":void 0,children:s.jsx(zi,{action:e.submit,args:Bi(e.submit.args,{data:t,fields:a,shape:e.fields,omit:u,scope:o}),disabled:r.busy||p,running:r.running===e.submit.tool,onRun:(d,h)=>void r.run(d,h,i)})})]})}function LO(e,t){var r;if(e.type==="checkbox")return e.label;const n=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${n?n.label:t}`}function zv(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function FO({component:e,data:t}){const n=kt(),[r,i]=f.useState(()=>Ic(e.fields,t)),[l,o]=f.useState(e.auto===!0),[a,c]=f.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),p=as(l&&u?e.query:void 0,t),d=Wi(p.data,e.rows),h=e.count===void 0?void 0:ge(p.data,e.count),x=e.note===void 0?void 0:ge(p.data,e.note),v=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==v),b=C=>{n.setParams(Object.fromEntries(e.fields.map(T=>[T.name,String(C[T.name]??"")||null]))),o(!0)},j=(C,T)=>{const E={...r,[C]:T};i(E),e.auto&&b(E)},g=()=>{const C=Ic(e.fields,null);i(C),e.auto?b(C):(n.setParams(Object.fromEntries(e.fields.map(T=>[T.name,null]))),o(!1))},y=l?w.filter(C=>zv(n.params[C.name])):[],m=v?y.map(C=>s.jsx(ch,{label:C.label,onRemove:()=>{const T={...r,[C.name]:C.type==="checkbox"?!1:""};i(T),b(T)},children:LO(C,String(n.params[C.name]))},C.name)):[],k=w.filter(C=>zv(r[C.name])).length,S=e.auto&&!e.reset?null:s.jsxs(s.Fragment,{children:[e.reset?s.jsx(P,{variant:"ghost",onClick:g,children:"Clear"}):null,e.auto?null:s.jsx(P,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),N=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return s.jsx(Ms,{title:e.title,children:s.jsxs(G,{children:[s.jsx(G0,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&b(r)},main:v?s.jsx("input",{id:`f-${v.name}`,name:v.name,type:v.type==="email"?"email":"search","aria-label":v.label,placeholder:v.hint??v.label,title:v.hint,required:v.required,value:String(r[v.name]??""),onChange:C=>j(v.name,C.target.value)}):void 0,filters:w.length>0?s.jsx(_m,{fields:w,values:r,data:t,compact:!0,onChange:j}):void 0,...v&&w.length>0?{filtersOpen:a,onToggleFilters:()=>c(C=>!C),active:k}:{},chips:m.length>0?m:void 0,actions:S}),s.jsx(re,{message:p.error}),l&&(h!==void 0||x!==void 0)?s.jsxs("p",{className:"ui-card-meta",children:[h===void 0?"":`${yt(h,"number",null)} in all. `,x===void 0?"":String(x)]}):null,l?d.length===0?s.jsx(le,{children:p.loading?"Searching…":e.empty??"Nothing matches."}):s.jsx("div",{className:"ui-panel","data-flush":"true",children:s.jsx(Ht,{children:d.map((C,T)=>{const E=$k(n,N,C);return s.jsx(rn,{title:E.title,sub:E.sub,side:E.side},T)})})}):null]})})}function UO({component:e,data:t}){const n=kt(),r=e.selection==="local",[i,l]=f.useState(null),o=r?i:n.params[e.param]??n.item,a=r&&i!==null?{...n,params:{...n.params,[e.param]:i}}:null,c=s.jsx(G,{gap:"lg",divided:!0,children:e.detail.map((u,p)=>s.jsx(Rs,{component:u,data:t},p))});return s.jsx(uo.Provider,{value:!1,children:s.jsx(K0,{list:s.jsx(Mk.Provider,{value:!0,children:s.jsx(Rs,{component:e.list,data:t,chosen:o??null,...r?{choose:l}:{}})}),detail:o?a?s.jsx(Im.Provider,{value:a,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function BO({component:e,data:t}){const n=kt(),r=as(e.query,t),i=Wi(r.data,e.rows);return s.jsxs(Ms,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),i.length===0?r.loading?s.jsx(le,{children:"Loading…"}):s.jsx(Om,{text:e.empty??"Nothing here yet."}):s.jsx(G,{gap:"lg",divided:!0,children:_k(i,e.key,{plugin:n.plugin,page:n.page,component:`repeat "${e.title??e.rows}"`}).map(({key:l,row:o})=>s.jsx(Y,{children:s.jsx(G,{children:e.body.map((a,c)=>s.jsx(Rs,{component:a,data:o},c))})},l))})]})}function zO({component:e,data:t}){const[n,r]=f.useState(!1),i=as(n?e.query:void 0,t),l=typeof e.label=="string"?e.label:String(Se(t,e.label)??"");return s.jsxs(bt,{summary:l,boxed:!0,onToggle:o=>r(o),children:[s.jsx(re,{message:i.error}),i.data===void 0?s.jsx(le,{children:"Loading…"}):s.jsx(G,{children:e.body.map((o,a)=>s.jsx(Rs,{component:o,data:i.data},a))})]})}function WO({component:e,data:t}){const n=kt(),r=ko();return s.jsxs(s.Fragment,{children:[s.jsx(J,{align:"end",children:s.jsx(zi,{action:e.action,args:Bi(e.action.args,{data:t,row:t,scope:n}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,l)=>void r.run(i,l)})}),s.jsx(ll,{act:r})]})}function VO({component:e}){const t=kt();return s.jsx(Pm,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function HO({component:e,data:t}){const n=ge(t,e.path);return typeof n!="string"||n===""?null:s.jsx(Ch,{id:n})}function KO({component:e,data:t}){const n=ge(t,e.path);return typeof n!="string"||n===""?null:s.jsx(J,{children:s.jsx("a",{href:xu(n),children:e.label})})}function GO({component:e,data:t}){const n=as(e.query,t),r=ko();return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(le,{children:e.empty??"Loading…"}):s.jsxs(s.Fragment,{children:[s.jsx(ll,{act:r}),s.jsx(YO,{component:e,data:t,loaded:n.data,act:r},JSON.stringify(n.data))]})}function YO({component:e,data:t,loaded:n,act:r}){const i=kt(),[l,o]=f.useState(()=>Ic(e.fields,n)),a={...l,version:ge(n,e.version)},c=Pk(e.fields,l,n),u=e.readOnlyWhen!==void 0&&ns(n,e.readOnlyWhen),p=(e.actions??[]).filter(x=>x.placement==="leading"),d=(e.actions??[]).filter(x=>x.placement!=="leading"),h=(x,v)=>s.jsx(zi,{action:x,args:Bi(x.args,{data:t,fields:a,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===x.tool,onRun:(w,b)=>void r.run(w,b)},`${x.tool}-${v}`);return s.jsx(Ms,{title:e.title,note:e.note,children:s.jsxs(G,{children:[s.jsx(_m,{fields:e.fields,values:l,data:n,disabled:u,onChange:(x,v)=>o(w=>({...w,[x]:v}))}),u?null:s.jsxs(J,{align:"end",children:[p.map(h),p.length>0?s.jsx(rl,{}):null,h(e.save,-1),d.map(h)]}),e.footnote?s.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function Ok({page:e,item:t,navigate:n,timezone:r,embedded:i,siblings:l}){const[o,a]=f.useState({}),[c,u]=f.useState(0),p={plugin:e.plugin,page:e.id,pages:l??[e],item:t??null,params:{...o,...t?{item:t}:{},...QO(e,t)},setParams:v=>a(w=>{const b={...w};for(const[j,g]of Object.entries(v))g===null?delete b[j]:b[j]=g;return b}),navigate:n,timezone:r,version:c,refresh:()=>u(v=>v+1),sensitive:new Set(e.sensitive??[])},d=e.body[0],h=!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,x=h===void 0?e:{...e,body:e.body.slice(1)};return s.jsx(Im.Provider,{value:p,children:s.jsx(an,{embedded:i,title:e.title,lede:h,children:s.jsx(qO,{page:x,boxed:i===!0})})})}function qO({page:e,boxed:t}){const n=kt();return e.data&&n.sensitive.has(e.data.query)?s.jsx(Ak,{children:s.jsx(Wv,{page:e,boxed:t})}):s.jsx(Wv,{page:e,boxed:t})}function Wv({page:e,boxed:t}){const n=as(e.data,null);return s.jsxs(G,{gap:"lg",divided:!t,children:[s.jsx(re,{message:n.error}),s.jsx(uo.Provider,{value:t,children:e.body.map((r,i)=>s.jsx(Rs,{component:r,data:n.data??null},i))})]})}function QO(e,t){if(!t)return{};const n=[],r=i=>{for(const l of i)l.kind==="list-detail"?(n.push(l.param),r(l.detail)):(l.kind==="section"||l.kind==="detail"||l.kind==="expand")&&r(l.body)};return r(e.body),Object.fromEntries(n.map(i=>[i,t]))}function JO(e){return s.jsx(Ok,{...e,embedded:!0})}function Om({text:e}){const t=e.search(/[.!?]\s/),n=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return s.jsx(wt,{title:n,children:r||null})}function Vv(e,t){return(e??[]).filter(n=>n.place===t).map((n,r)=>({page:n,index:r})).sort((n,r)=>(n.page.order??0)-(r.page.order??0)||n.index-r.index).map(n=>n.page)}function Dk(e=!1){const[t,n]=f.useState([]);return f.useEffect(()=>{if(e)return;let r=!1;return Promise.resolve().then(()=>R.pages()).then(i=>{r||n(Array.isArray(i==null?void 0:i.pages)?i.pages:[])}).catch(()=>{}),()=>{r=!0}},[e]),{all:t,rail:Vv(t,"rail"),settings:Vv(t,"settings"),find:(r,i)=>t.find(l=>l.plugin===r&&l.id===i)}}const Hv=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],XO=["","image","pdf","table","text","code","audio","video","archive","file"];function ZO({hash:e,timezone:t,navigate:n,agents:r}){var O;const i=c2(e),l=(i==null?void 0:i.artifactId)??null,o=(i==null?void 0:i.filters.origin)??"",a=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,p]=f.useState(c);f.useEffect(()=>{p(c)},[c]);const d=(A,D=!1)=>n(ia(l,{q:c,origin:o,family:a,...A}),D);f.useEffect(()=>{if(u===c)return;const A=window.setTimeout(()=>d({q:u},!0),250);return()=>window.clearTimeout(A)},[u]);const[h,x]=f.useState(null),[v,w]=f.useState(null),[b,j]=f.useState(null),[g,y]=f.useState(!1),[m,k]=f.useState(!1),S=A=>{var D;return A?((D=r.find(q=>q.id===A))==null?void 0:D.name)??A:""},N=f.useRef(0);f.useEffect(()=>{const A=++N.current;x(null),w(null),y(!1),j(null),R.library({...c?{q:c}:{},...o?{origin:o}:{},...a?{family:a}:{}}).then(D=>{N.current===A&&(x(D.entries),w(D.next))}).catch(D=>{N.current===A&&j(D instanceof de?D.message:String(D))})},[c,o,a]);const C=()=>{if(!v||g)return;y(!0);const A=N.current;R.library({...c?{q:c}:{},...o?{origin:o}:{},...a?{family:a}:{},cursor:v}).then(D=>{N.current===A&&(x(q=>{const V=new Set((q??[]).map(M=>M.id));return[...q??[],...D.entries.filter(M=>!V.has(M.id))]}),w(D.next))}).catch(D=>{N.current===A&&j(D instanceof de?D.message:String(D))}).finally(()=>{N.current===A&&y(!1)})},T=(o?1:0)+(a?1:0),E=((O=Hv.find(A=>A.id===o))==null?void 0:O.label)??o,_=s.jsxs(s.Fragment,{children:[h===null?s.jsx(le,{children:"Loading…"}):h.length===0?s.jsx(le,{children:"No file matches that."}):s.jsx(Ht,{children:h.map(A=>s.jsx(H0,{href:ia(A.id,{q:c,origin:o,family:a}),current:A.id===l,onClick:()=>n(ia(A.id,{q:c,origin:o,family:a})),lead:s.jsx("span",{className:"files-row-visual","data-family":A.family,children:A.family==="image"&&!A.deleted?s.jsx("img",{src:Ur(A.id),alt:"",loading:"lazy"}):s.jsx(Em,{family:A.family})}),title:A.filename??"Untitled file",meta:s.jsx("span",{title:Ie(A.createdAt,t),children:Ce(A.createdAt)}),sub:`${Tr[A.family]} · ${Rn(A.sizeBytes)} · ${Lk(A,S)}${eD(A,S)}`},A.id))}),v?s.jsx("div",{className:"files-more",children:s.jsx(P,{size:"sm",onClick:C,disabled:g,children:g?"Loading…":"Show more"})}):null]}),F=h!==null&&h.length===0&&!c&&!o&&!a&&!u;return s.jsxs("div",{className:"ui-page files","data-selected":l?"true":void 0,children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Files"}),s.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),F?s.jsx(wt,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):s.jsxs(s.Fragment,{children:[s.jsx(G0,{label:"Files",onSubmit:()=>d({q:u},!0),main:s.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:A=>p(A.target.value)}),filters:s.jsxs(As,{dense:!0,children:[s.jsx(te,{label:"Origin",children:s.jsx("select",{value:o,"aria-label":"Origin",onChange:A=>d({origin:A.target.value}),children:Hv.map(A=>s.jsx("option",{value:A.id,children:A.label},A.id))})}),s.jsx(te,{label:"Kind",children:s.jsx("select",{value:a,"aria-label":"Kind",onChange:A=>d({family:A.target.value}),children:XO.map(A=>s.jsx("option",{value:A,children:A===""?"Any kind":Tr[A]},A))})})]}),filtersOpen:m,onToggleFilters:()=>k(A=>!A),active:T,chips:T>0?s.jsxs(s.Fragment,{children:[o?s.jsx(ch,{label:"Origin",onRemove:()=>d({origin:""}),children:E}):null,a?s.jsx(ch,{label:"Kind",onRemove:()=>d({family:""}),children:Tr[a]}):null]}):void 0}),s.jsx(re,{message:b}),s.jsx(K0,{className:"files-split",label:"Files",list:_,detail:l?s.jsx(tD,{id:l,timezone:t,agents:r,navigate:n,onBack:()=>n(ia(null,{q:c,origin:o,family:a}))},l):void 0,empty:"Choose a file to see it here."})]})]})}function eD(e,t){var i,l;const n=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(l=e.context)!=null&&l.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[n,r].filter(Boolean).map(o=>` · ${o}`).join("")}function Lk(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 tD({id:e,timezone:t,agents:n,navigate:r,onBack:i}){const[l,o]=f.useState(null),[a,c]=f.useState(!1),[u,p]=f.useState(null);f.useEffect(()=>{let g=!1;return o(null),p(null),R.libraryEntry(e).then(y=>{g||o(y)}).catch(y=>{g||p(y instanceof de&&y.status===404?"This file is no longer in the library.":y instanceof de?y.message:String(y))}),()=>{g=!0}},[e]);const d=g=>{var y;return g?((y=n.find(m=>m.id===g))==null?void 0:y.name)??g:""};if(u)return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(P,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsx(K,{tone:"critical",children:u})]});if(!l)return s.jsx("div",{className:"files-detail-body",children:s.jsx(le,{children:"Loading…"})});const{entry:h,contexts:x,contextsTotal:v,available:w}=l,b=h.filename??"Untitled file",j=()=>{c(!0),R.libraryEntry(e,x.length).then(g=>o(y=>y&&{...y,contexts:[...y.contexts,...g.contexts],contextsTotal:g.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(P,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsxs("header",{className:"files-detail-head",children:[s.jsx("span",{className:"files-detail-mark","data-family":h.family,"aria-hidden":"true",children:s.jsx(Em,{family:h.family})}),s.jsxs("div",{className:"files-detail-text",children:[s.jsx("h3",{className:"files-detail-name",children:b}),s.jsxs("p",{className:"files-detail-meta",children:[Tr[h.family]," · ",Rn(h.sizeBytes)," · ",Ie(h.createdAt,t)]})]}),w?s.jsx("a",{className:"ui-btn","data-variant":"accent",href:xu(h.id),download:b,children:"Download"}):null]}),w?null:s.jsx(K,{tone:"warning",children:"The file's bytes are no longer on this machine. What is known about it stays here; the download will not work."}),s.jsx(rk,{artifactId:h.id,filename:h.filename,mime:h.mime,family:h.family,available:w}),s.jsx(At,{items:[{label:"Origin",value:Lk(h,d)},...h.agentId&&h.origin==="produced"?[{label:"Made by",value:s.jsxs("span",{className:"files-agent",children:[s.jsx(Xt,{agents:n,id:h.agentId,size:"sm"}),d(h.agentId)]})}]:[],{label:"Type",value:s.jsx("span",{className:"mono",children:h.mime})},{label:"Id",value:s.jsx("span",{className:"mono",children:h.id})}]}),s.jsxs("section",{className:"files-conversations",children:[s.jsx("h4",{className:"ui-section-title",children:"Conversations"}),x.length===0?s.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):s.jsx("ul",{className:"files-ctx",role:"list",children:x.map(g=>{const y=g.groupId?Dl(g.groupId,g.conversationId):Fe(g.conversationAgentId,g.conversationId),m=g.groupId?g.groupName??"a group":d(g.conversationAgentId);return s.jsxs("li",{className:"files-ctx-row",children:[s.jsxs("span",{className:"files-ctx-text",children:[s.jsx("span",{children:g.groupId?`Group: ${m}`:m}),s.jsxs("span",{className:"muted",children:[" · ",g.kind==="produced"?`made by ${d(g.agentId)||"an agent"}`:g.kind==="reused"?"sent again":"sent by you"," · ",Ce(g.at)]})]}),s.jsx("a",{className:"ui-btn","data-size":"sm",href:y,onClick:k=>{k.preventDefault(),r(y)},children:"Open conversation"})]},`${g.conversationId}:${g.kind}`)})}),x.length<v?s.jsx(J,{align:"end",children:s.jsx(P,{size:"sm",onClick:j,disabled:a,children:a?"Loading…":`Show ${v-x.length} more`})}):null]})]})}const nD={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe"};function Fk(e){return e&&nD[e]||"plug"}function sD({attention:e,place:t,onNavigate:n,theme:r,onTheme:i,plugins:l=[],updateAvailable:o=!1,version:a}){return s.jsxs("nav",{className:"rail","aria-label":"Places",children:[s.jsx("a",{className:"rail-mark",href:Vt,onClick:c=>{c.preventDefault(),n(Vt)},"aria-label":"buddi home",children:s.jsx(Y0,{})}),x2.filter(c=>c.route!==Qt).map(c=>s.jsx($d,{label:c.label,href:c.route,active:t===c.route,badge:c.route===Vt?e:0,onClick:()=>n(c.route),children:Kv[c.route]},c.route)),l.map(c=>{const u=oo(c.plugin,c.id);return s.jsx($d,{label:c.title,href:u,active:t===u,badge:0,onClick:()=>n(u),children:s.jsx(Oe,{name:Fk(c.icon)})},u)}),s.jsx("div",{className:"rail-spacer"}),s.jsx($d,{label:"Settings",href:Qt,active:t===Qt,badge:0,dot:o?"a newer buddi is ready":void 0,onClick:()=>n(Qt),children:Kv[Qt]}),s.jsx(iD,{theme:r,onTheme:i,onNavigate:n,version:a})]})}const rD=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function iD({theme:e,onTheme:t,onNavigate:n,version:r}){var a,c;const l=((c=(a=se(()=>R.owner(),[]).data)==null?void 0:a.preferredName)==null?void 0:c.trim())||null,o=(l??"You").slice(0,1).toUpperCase();return s.jsx("div",{className:"rail-owner",children:s.jsxs(sm,{modal:!1,children:[s.jsx(rm,{asChild:!0,children:s.jsx("button",{type:"button",className:"rail-owner-btn","aria-label":l?`You: ${l}`:"You",children:s.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:o})})}),s.jsx(im,{children:s.jsxs(lm,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[s.jsxs("div",{className:"rail-owner-head",children:[s.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:o}),s.jsxs("span",{className:"rail-owner-who",children:[s.jsx("span",{className:"rail-owner-name",children:l??"You"}),s.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),s.jsx(Fa,{className:"ui-menu-sep"}),s.jsx(om,{className:"ui-menu-label",children:"Theme"}),s.jsx("div",{className:"rail-owner-theme",children:s.jsx(Ba,{label:"Theme",options:rD,value:e,onChange:t})}),s.jsx(Fa,{className:"ui-menu-sep"}),s.jsx(sh,{className:"ui-menu-item",onSelect:()=>n(st("appearance")),children:"Change appearance"}),r?s.jsxs(s.Fragment,{children:[s.jsx(Fa,{className:"ui-menu-sep"}),s.jsxs(sh,{className:"ui-menu-item rail-owner-version","data-update":r.updateAvailable?"true":void 0,onSelect:()=>n(st("system")),children:[s.jsxs("span",{className:"mono",children:["buddi ",r.current]}),r.updateAvailable&&r.latest?s.jsxs("span",{className:"rail-owner-update",children:["A newer buddi is ready: ",r.latest]}):null]})]}):null]})})]})})}function $d({label:e,href:t,active:n,badge:r,dot:i,onClick:l,children:o}){return s.jsxs("a",{className:"rail-link",href:t,"data-active":n?"true":void 0,"aria-current":n?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:i?`${e}, ${i}`:e,onClick:a=>{a.preventDefault(),l()},children:[s.jsxs("span",{className:"rail-icon",children:[o,r>0?s.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null,r===0&&i?s.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"rail-dot","aria-hidden":"true"}):null]}),s.jsx("span",{className:"rail-label",children:e})]})}const Kv={[Lr]:s.jsx(Oe,{name:"files"}),[Vt]:s.jsx(Oe,{name:"home"}),[Fi]:s.jsx(Oe,{name:"chat"}),[et]:s.jsx(Oe,{name:"agents"}),[Ze]:s.jsx(Oe,{name:"activity"}),[Qt]:s.jsx(Oe,{name:"settings"})},Uk="buddi.theme";function lD(e=Bk()){try{const t=e==null?void 0:e.getItem(Uk);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function oD(e,t=Bk()){try{t==null||t.setItem(Uk,e)}catch{}}function aD(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function Bk(){try{return window.localStorage}catch{return}}const zk="buddi.ground",Wk="buddi.pageWidth";function cD(e=Kk()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},n=t(zk),r=t(Wk);return{theme:lD(e),ground:n==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function Vk(e,t=document.documentElement){t&&(aD(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 uD(e,t=Kk()){oD(e.theme,t);try{t==null||t.setItem(zk,e.ground),t==null||t.setItem(Wk,e.width)}catch{}}let Ri=null;const Eh=new Set;function Ah(){return Ri||(Ri=cD()),Ri}function dD(e){return Eh.add(e),()=>Eh.delete(e)}function fD(e){Ri={...Ah(),...e},Vk(Ri),uD(Ri);for(const t of Eh)t()}function Hk(){return[f.useSyncExternalStore(dD,Ah,Ah),fD]}function Kk(){try{return window.localStorage}catch{return}}function hD({timezone:e,embedded:t}){var h,x;const{data:n,error:r,reload:i}=se(()=>R.sentinels(),[],3e4),l=se(()=>R.missions(),[]),[o,a]=f.useState(null),c=((x=(h=l.data)==null?void 0:h.missions.find(v=>v.id==="sentinel-wake"))==null?void 0:x.agentId)??null,u=async(v,w)=>{a(null);try{await R.snoozeAlert(v,w),i()}catch(b){a(b instanceof Error?b.message:String(b))}},p=((n==null?void 0:n.open)??[]).filter(v=>!v.snoozedAt),d=((n==null?void 0:n.open)??[]).filter(v=>v.snoozedAt);return s.jsxs(an,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[s.jsx(re,{message:r??o}),s.jsx(K,{children:"An alert closes on its own once the fact behind it changes: record the payment, update the balance, and the watcher clears it on its next run. Snooze one you have decided to live with; it stays quiet until it resolves."}),s.jsx(_d,{title:"Open",findings:p,timezone:e,askAgentId:c,onSnooze:v=>u(v,!0),empty:"Nothing open. Your watchers are quiet."}),d.length>0?s.jsx(_d,{title:"Snoozed",findings:d,timezone:e,askAgentId:c,onSnooze:v=>u(v,!1),empty:""}):null,s.jsx(_d,{title:"Resolved",findings:(n==null?void 0:n.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),s.jsx(rt,{title:"Waiting for the weekly recap",flush:!0,children:!n||n.digest.length===0?s.jsx(wt,{icon:"bell",title:"Nothing waiting for the recap"}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Title"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Noted"})]})}),s.jsx("tbody",{children:n.digest.map(v=>s.jsxs("tr",{children:[s.jsxs("td",{children:[Li(v.title),s.jsx(Yk,{text:Li(v.detail)})]}),s.jsx("td",{children:s.jsx(Gk,{severity:v.severity})}),s.jsx("td",{className:"nowrap",children:Ie(v.createdAt,e)})]},v.id))})]})})]})}function Gk({severity:e}){return s.jsx(pe,{tone:e==="urgent"?"critical":void 0,children:e})}function Yk({text:e}){const[t,n]=f.useState(!1),r=e.length>240||e.split(`
104
- `).length>3;return s.jsxs("div",{className:"sub alert-detail","data-clamp":r&&!t?"true":void 0,children:[e,r?s.jsx("button",{type:"button",className:"wb-link alert-more",onClick:()=>n(i=>!i),children:t?"Less":"More"}):null]})}function pD(e){return`About this alert: "${Li(e.title)}". ${Li(e.detail)}
105
-
106
- What should I do about it, and what do you need from me to clear it?`}function _d({title:e,findings:t,timezone:n,askAgentId:r,onSnooze:i,empty:l}){const o=e==="Snoozed";return s.jsx(rt,{title:e,flush:!0,children:t.length===0?s.jsx(le,{children:l}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Finding"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Since"}),i?s.jsx("th",{}):null]})}),s.jsx("tbody",{children:t.map(a=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:Li(a.title)}),s.jsx(Yk,{text:Li(a.detail)}),a.data?s.jsx(bt,{summary:"evidence",children:s.jsx(ut,{children:ln(a.data)})}):null]}),s.jsx("td",{children:s.jsx(Gk,{severity:a.severity})}),s.jsxs("td",{className:"nowrap",children:[Ie(a.firstSeenAt,n),s.jsxs("div",{className:"sub",title:Ie(a.lastSeenAt,n),children:["last seen ",Ce(a.lastSeenAt)]})]}),i?s.jsx("td",{children:s.jsxs(J,{align:"end",children:[r?s.jsx(Bn,{size:"sm",href:Fe(r,"new"),onClick:()=>rO(r,pD(a)),children:"Ask about it"}):null,s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(a.key),children:o?"Wake":"Snooze"})]})}):null]},a.key))})]})})}const Gv=5e3,Yv=50;function mD({timezone:e,embedded:t}){var j;const[n,r]=f.useState(""),[i,l]=f.useState(""),[o,a]=f.useState(null),c=se(()=>R.eventKinds(),[]),{data:u,error:p}=se(()=>R.events({kind:n||void 0,q:i||void 0,limit:Yv}),[n,i],Gv),[d,h]=f.useState({events:[],cursor:null,busy:!1,error:null});f.useEffect(()=>{h({events:[],cursor:null,busy:!1,error:null})},[n,i]);const x=d.events.length>0?d.cursor:(u==null?void 0:u.nextCursor)??null,v=async()=>{if(x){h(g=>({...g,busy:!0,error:null}));try{const g=await R.events({kind:n||void 0,q:i||void 0,before:x,limit:Yv});h(y=>({events:[...y.events,...g.events],cursor:g.nextCursor,busy:!1,error:null}))}catch(g){h(y=>({...y,busy:!1,error:g instanceof Error?g.message:String(g)}))}}},w=new Set(((u==null?void 0:u.events)??[]).map(g=>g.id)),b=[...(u==null?void 0:u.events)??[],...d.events.filter(g=>!w.has(g.id))];return s.jsxs(an,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[s.jsxs(J,{children:[s.jsxs("select",{"aria-label":"Event kind",value:n,onChange:g=>r(g.target.value),children:[s.jsx("option",{value:"",children:"every kind"}),(((j=c.data)==null?void 0:j.kinds)??[]).map(g=>s.jsxs("option",{value:g.kind,children:[g.kind," (",g.count,")"]},g.kind))]}),s.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:g=>l(g.target.value),size:28}),n||i?s.jsx(P,{onClick:()=>{r(""),l("")},children:"Clear"}):null,s.jsxs("span",{className:"muted",children:["refreshes every ",Gv/1e3,"s"]})]}),s.jsx(re,{message:p}),s.jsx(rt,{flush:!0,children:!u||b.length===0?s.jsx(le,{children:"No events match."}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"#"}),s.jsx("th",{children:"When"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Payload"})]})}),s.jsx("tbody",{children:b.map(g=>s.jsxs("tr",{"data-clickable":"true",onClick:()=>a(g),children:[s.jsx("td",{className:"mono muted",children:g.id}),s.jsxs("td",{className:"nowrap",children:[Ie(g.createdAt,e),s.jsx("div",{className:"sub",children:Ce(g.createdAt)})]}),s.jsx("td",{className:"mono nowrap",children:g.kind}),s.jsx("td",{className:"mono muted",children:Es(ln(g.payload).replace(/\s+/g," "),120)})]},g.id))})]})}),x||d.error?s.jsxs(J,{children:[s.jsxs("span",{className:"muted",children:[b.length," shown",x?", older ones are kept":"","."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),d.error?s.jsx("span",{className:"critical",children:d.error}):null,x?s.jsx(P,{disabled:d.busy,onClick:()=>void v(),children:d.busy?"Loading…":"Load older"}):null]}):null,o?s.jsxs(Yt,{title:o.kind,onClose:()=>a(null),children:[s.jsxs("p",{className:"muted",children:["Event ",o.id," · ",Ie(o.createdAt,e),o.conversationId?s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:`#/conversations/${o.conversationId}`,children:"conversation"})]}):null]}),s.jsx(ut,{children:ln(o.payload)})]}):null]})}const gD=["pending","leased","suspended","failed","succeeded","cancelled"],kl=50;function xD({timezone:e,embedded:t,initialState:n}){const[r,i]=f.useState(n??""),[l,o]=f.useState(null),[a,c]=f.useState(null),{data:u,error:p,reload:d}=se(()=>R.jobs({...r?{state:r}:{},limit:String(kl)}),[r],1e4),[h,x]=f.useState({jobs:[],done:!1,busy:!1});f.useEffect(()=>{x({jobs:[],done:!1,busy:!1})},[r]);const v=async()=>{x(N=>({...N,busy:!0}));try{const N=await R.jobs({...r?{state:r}:{},limit:String(kl),offset:String(kl+h.jobs.length)});x(C=>({jobs:[...C.jobs,...N.jobs],done:N.jobs.length<kl,busy:!1}))}catch(N){c(N instanceof Error?N.message:String(N)),x(C=>({...C,busy:!1}))}},w=new Set(((u==null?void 0:u.jobs)??[]).map(N=>N.id)),b=[...(u==null?void 0:u.jobs)??[],...h.jobs.filter(N=>!w.has(N.id))],j=r?(u==null?void 0:u.counts[r])??0:Object.values((u==null?void 0:u.counts)??{}).reduce((N,C)=>N+C,0),g=!h.done&&b.length<j&&((u==null?void 0:u.jobs.length)??0)>=kl,[y,m]=f.useState(null),k=async N=>{c(null),m(N);try{const C=(await R.jobs({state:"failed",limit:"500"})).jobs;for(const T of C)await(N==="retry"?R.retryJob(T.id):R.cancelJob(T.id));d()}catch(C){c(C instanceof Error?C.message:String(C))}finally{m(null)}},S=async N=>{c(null);try{await N,o(null),d()}catch(C){c(C instanceof Error?C.message:String(C))}};return s.jsxs(an,{embedded:t,title:"Jobs",lede:`${u!=null&&u.paused?"Paused: nothing is being claimed. ":""}Bounded retries with backoff; past the budget a job waits for you.`,actions:t?void 0:s.jsx(P,{size:"sm",variant:u!=null&&u.paused?"accent":void 0,onClick:()=>S(R.setPaused(!((u==null?void 0:u.paused)??!1))),children:u!=null&&u.paused?"Resume the queue":"Pause the queue"}),children:[s.jsxs(J,{children:[s.jsxs("select",{"aria-label":"Job state",value:r,onChange:N=>i(N.target.value),children:[s.jsx("option",{value:"",children:"every state"}),gD.map(N=>s.jsxs("option",{value:N,children:[N," (",(u==null?void 0:u.counts[N])??0,")"]},N))]}),((u==null?void 0:u.counts.failed)??0)>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("span",{className:"muted",children:[u.counts.failed," failed."]}),s.jsx(P,{size:"sm",disabled:y!==null,onClick:()=>void k("retry"),children:y==="retry"?"Retrying…":"Retry all failed"}),s.jsx(P,{size:"sm",variant:"danger",disabled:y!==null,onClick:()=>void k("cancel"),children:y==="cancel"?"Cancelling…":"Cancel all failed"})]}):null]}),s.jsx(re,{message:p??a}),s.jsx(rt,{flush:!0,children:!u||b.length===0?s.jsx(le,{children:"No jobs match."}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"State"}),s.jsx("th",{className:"num",children:"Attempts"}),s.jsx("th",{children:"Last error"}),s.jsx("th",{children:"Updated"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:b.map(N=>s.jsxs("tr",{children:[s.jsxs("td",{className:"clickable",onClick:()=>o(N),children:[N.kind,s.jsx("div",{className:"sub mono",children:lo(N.id)})]}),s.jsxs("td",{children:[s.jsx(hu,{state:N.state}),N.suspendedReason?s.jsx("div",{className:"sub",children:Es(N.suspendedReason,40)}):null]}),s.jsxs("td",{className:"num",children:[N.attempts,"/",N.maxAttempts]}),s.jsx("td",{className:N.lastError?"critical":"muted",children:N.lastError?Es(N.lastError,80):"—"}),s.jsxs("td",{className:"nowrap",children:[Ie(N.updatedAt,e),s.jsx("div",{className:"sub",children:Ce(N.updatedAt)})]}),s.jsx("td",{children:s.jsxs(J,{align:"end",children:[["failed","cancelled","suspended"].includes(N.state)?s.jsx(P,{size:"sm",onClick:()=>S(R.retryJob(N.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(N.state)?s.jsx(P,{size:"sm",variant:"danger",onClick:()=>S(R.cancelJob(N.id)),children:"Cancel"}):null]})})]},N.id))})]})}),g?s.jsxs(J,{children:[s.jsxs("span",{className:"muted",children:[b.length," of ",j," shown."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{disabled:h.busy,onClick:()=>void v(),children:h.busy?"Loading…":"Load older"})]}):null,l?s.jsxs(Yt,{title:l.kind,onClose:()=>o(null),children:[s.jsx("p",{className:"muted mono",children:l.id}),s.jsx(Y,{title:"Payload",children:s.jsx(ut,{children:ln(l.payload)})}),s.jsx(Y,{title:"Result",children:s.jsx(ut,{children:ln(l.result)})}),l.conversationId?s.jsx("p",{children:s.jsx("a",{href:`#/conversations/${l.conversationId}`,children:"open the transcript"})}):null]}):null]})}const vD=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function jD({hash:e,timezone:t,navigate:n,agents:r}){var u,p;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),l=d=>{var h;return((h=r.find(x=>x.id===d))==null?void 0:h.name)??d};if(i){let d=i[1];try{d=decodeURIComponent(d)}catch{}return s.jsx(bD,{id:d,timezone:t,navigate:n,nameOf:l})}const o=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",a=(p=/[?&]state=([a-z]+)/.exec(e))==null?void 0:p[1],c=d=>h=>{h.preventDefault(),n(d)};return s.jsxs("div",{className:"ui-page",children:[s.jsx(ym,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:s.jsx(ND,{})}),s.jsx(CD,{}),s.jsx(mu,{children:vD.map(d=>{const h=d.id==="conversations"?Ze:`${Ze}/${d.id}`;return s.jsx(gu,{href:h,active:o===d.id,onClick:c(h),children:d.label},d.id)})}),o==="conversations"?s.jsx(yD,{timezone:t,navigate:n,nameOf:l,agents:r}):null,o==="jobs"?s.jsx(xD,{timezone:t,embedded:!0,initialState:a},a??""):null,o==="approvals"?s.jsx(wD,{timezone:t,nameOf:l}):null,o==="alerts"?s.jsx(hD,{timezone:t,embedded:!0}):null,o==="events"?s.jsx(mD,{timezone:t,embedded:!0}):null]})}function yD({timezone:e,navigate:t,nameOf:n,agents:r}){const{data:i,error:l}=se(()=>R.conversations(),[],3e4);return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:l}),s.jsx(rt,{flush:!0,children:i?i.conversations.length===0?s.jsx(wt,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):s.jsx(Ht,{children:i.conversations.map(o=>s.jsx(rn,{href:Ui(o.id),onClick:()=>t(Ui(o.id)),lead:s.jsx(Xt,{agents:r,id:o.agentId,size:"sm"}),title:o.opening?Es(o.opening,100):"Untitled conversation",sub:`${n(o.agentId)}, ${o.messageCount} message${o.messageCount===1?"":"s"}, ${o.runs} run${o.runs===1?"":"s"}, ${Dt(o.usage.input)} in / ${Dt(o.usage.output)} out`,side:s.jsx("span",{title:Ie(o.lastMessageAt??o.createdAt,e),children:Ce(o.lastMessageAt??o.createdAt)})},o.id))}):s.jsx(le,{children:"Loading…"})})]})}function wD({timezone:e,nameOf:t}){const{data:n,error:r}=se(()=>R.approvals(),[],1e4),i=[...(n==null?void 0:n.pending)??[],...(n==null?void 0:n.recent)??[]];return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:r}),s.jsx(rt,{flush:!0,children:n?i.length===0?s.jsx(wt,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Tool"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Asked by"}),s.jsx("th",{children:"Decided"}),s.jsx("th",{children:"Created"})]})}),s.jsx("tbody",{children:i.map(l=>s.jsxs("tr",{children:[s.jsxs("td",{children:[l.tool,s.jsx("div",{className:"sub mono",children:lo(l.id)})]}),s.jsx("td",{children:s.jsx(hu,{state:l.state})}),s.jsx("td",{children:t(l.agentId)}),s.jsx("td",{className:"nowrap",children:l.decidedAt?s.jsxs(s.Fragment,{children:[Ie(l.decidedAt,e),s.jsxs("div",{className:"sub",children:["via ",l.decidedVia??"—"]})]}):s.jsx("span",{className:"muted",children:"—"})}),s.jsxs("td",{className:"nowrap",children:[Ie(l.createdAt,e),s.jsx("div",{className:"sub",children:Ce(l.createdAt)})]})]},l.id))})]}):s.jsx(le,{children:"Loading…"})})]})}function bD({id:e,timezone:t,navigate:n,nameOf:r}){const[i,l]=f.useState(null),[o,a]=f.useState(null);f.useEffect(()=>{let u=!1;return R.conversation(e).then(p=>{u||l(p)}).catch(p=>{u||a(p instanceof Error?p.message:String(p))}),()=>{u=!0}},[e]);const c=u=>p=>{p.preventDefault(),n(u)};return s.jsxs("div",{className:"ui-page",children:[s.jsx("p",{className:"page-crumbs",children:s.jsx("a",{href:Ze,onClick:c(Ze),children:"Activity"})}),s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[s.jsx(P,{size:"sm",onClick:()=>n(Ze),children:"← Back"}),s.jsx("span",{children:"Transcript"})]}),i?s.jsx("div",{className:"ui-page-actions",children:s.jsx(Bn,{size:"sm",href:Fe(i.agentId,e),onClick:c(Fe(i.agentId,e)),children:"Open in chat"})}):null]}),s.jsx("p",{className:"ui-page-lede mono",children:e})]}),s.jsx(re,{message:o}),i?s.jsxs(s.Fragment,{children:[s.jsxs(pu,{children:[s.jsx(Xn,{label:"Agent",value:r(i.agentId),size:"sm"}),s.jsx(Xn,{label:"Runs",value:i.runs.length}),s.jsx(Xn,{label:"Tokens",value:`${Dt(i.usage.input)} / ${Dt(i.usage.output)}`,note:"input / output"}),s.jsx(Xn,{label:"Started",value:Ie(i.createdAt,t),size:"sm"})]}),i.runs.length>0?s.jsx(rt,{title:"Runs",flush:!0,children:s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{className:"num",children:"Turns"}),s.jsx("th",{children:"Stopped"}),s.jsx("th",{className:"num",children:"Tokens"})]})}),s.jsx("tbody",{children:i.runs.map((u,p)=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Ie(u.startedAt,t)," ",u.resumed?s.jsx(pe,{children:"resumed"}):null]}),s.jsx("td",{className:"nowrap",children:Ie(u.finishedAt,t)}),s.jsx("td",{className:"num",children:u.turns??"—"}),s.jsxs("td",{children:[u.stopped??"—",u.actionId?s.jsxs("div",{className:"sub mono",children:["action ",lo(u.actionId)]}):null]}),s.jsxs("td",{className:"num muted nowrap",children:[Dt(u.usage.input)," / ",Dt(u.usage.output)]})]},p))})]})}):null,s.jsx(Y,{title:"Messages",children:s.jsx(G,{children:i.messages.map(u=>s.jsxs("article",{className:"transcript-msg",children:[s.jsxs("header",{className:"transcript-who",children:[u.speaker===qv?"approved action, result":u.role,", ",Ie(u.createdAt,t)]}),s.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?s.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===qv?u.blocks.map((p,d)=>s.jsx(kD,{block:p},d)):u.blocks.map((p,d)=>s.jsx(SD,{block:p},d))]})]},u.id))})})]}):s.jsx(le,{children:"Loading…"})]})}const qv="approval:resume";function kD({block:e}){return s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),s.jsx(ut,{children:e.type==="text"?e.text??"":ln(e)})]})}function SD({block:e}){return e.type==="text"?s.jsx("div",{className:"transcript-text",children:s.jsx(cr,{text:e.text??""})}):e.type==="thinking"?s.jsxs("details",{className:"transcript-thinking",children:[s.jsx("summary",{children:"Thoughts"}),s.jsx("div",{className:"transcript-thinking-text",children:s.jsx(cr,{text:e.text??""})})]}):e.type==="tool_use"?s.jsxs("div",{className:"transcript-tool",children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),s.jsx(ut,{children:ln(e.input)})]}):e.type==="tool_result"?s.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),s.jsx(ut,{children:e.content??""})]}):s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:e.type}),s.jsx(ut,{children:ln(e.ref)})]})}function ND(){const{data:e,reload:t}=se(()=>R.overview(),[],1e4),[n,r]=f.useState(!1);if(!e)return null;const i=()=>{r(!0),R.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return s.jsx(P,{size:"sm",variant:e.paused?"accent":void 0,disabled:n,onClick:i,children:e.paused?"Resume all":"Pause all"})}function CD(){const{data:e}=se(()=>R.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,n=t("leased");return s.jsxs(pu,{children:[s.jsx(Xn,{label:"Jobs done",value:Dt(t("succeeded"))}),s.jsx(Xn,{label:"Failed",value:Dt(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),s.jsx(Xn,{label:"Queued",value:Dt(t("pending")),note:`${n} running`}),s.jsx(Xn,{label:"Approvals",value:Dt(e.approvals.pending),note:"waiting for you"})]})}const ED=["replay-all","coalesce","latest-only","skip-after-deadline"];function qk({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:l}=se(()=>R.missions(),[],3e4),o=((r==null?void 0:r.missions)??[]).filter(p=>!n||p.agentId===n),[a,c]=f.useState(null),u=async p=>{c(null);try{await p,l()}catch(d){c(d instanceof Error?d.message:String(d))}};return s.jsxs(an,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[s.jsx(re,{message:i??a}),!r||o.length===0?s.jsxs(wt,{icon:"calendar",title:"No missions yet",children:["Run ",s.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):s.jsx(G,{children:o.map(p=>s.jsx(AD,{mission:p,timezone:e,onRun:u},p.id))})]})}function AD({mission:e,timezone:t,onRun:n}){const[r,i]=f.useState(!1);return s.jsxs(Fr,{tone:e.enabled?"good":"muted",title:s.jsxs(s.Fragment,{children:[e.name," ",s.jsx("span",{className:"mono muted",children:e.id})]}),meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{mono:!0,children:e.agentId}),e.alwaysDeliver?s.jsx(pe,{children:"always delivers"}):null,e.enabled?null:s.jsx(pe,{tone:"warning",children:"disabled"})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",onClick:()=>n(R.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(l=>!l),"aria-expanded":r,children:r?"Less":"More"})]}),children:[s.jsxs("p",{className:"ui-card-meta",children:[e.schedule?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${Ie(e.nextRun,t)} (${Ce(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",s.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${Ce(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?s.jsxs("div",{className:"ui-card-foot",children:[e.schedule?s.jsxs(J,{children:[s.jsx(te,{inline:!0,label:"Misfire policy",children:s.jsx("select",{value:e.schedule.misfirePolicy,onChange:l=>n(R.setMisfirePolicy(e.id,l.target.value)),children:ED.map(l=>s.jsx("option",{value:l,children:l},l))})}),s.jsx("span",{className:"muted",children:"What a week asleep does: replay every instant, coalesce into one, keep only the latest, or skip past a deadline."})]}):null,s.jsx(Y,{title:"Prompt",children:s.jsx(ut,{children:e.prompt})}),s.jsx(Y,{title:"Recent occurrences",children:s.jsx(rt,{flush:!0,children:e.occurrences.length===0?s.jsx(le,{children:"Never run."}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Scheduled"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{children:"Detail"})]})}),s.jsx("tbody",{children:e.occurrences.map(l=>s.jsxs("tr",{children:[s.jsx("td",{className:"nowrap",children:Ie(l.scheduledAt,t)}),s.jsx("td",{children:s.jsx(hu,{state:l.state})}),s.jsx("td",{className:"nowrap",children:Ie(l.finishedAt,t)}),s.jsxs("td",{className:l.error?"critical":"muted",children:[l.error?Es(l.error,120):null,l.runConversationId?s.jsx("a",{href:`#/conversations/${l.runConversationId}`,children:"transcript"}):null]})]},l.id))})]})})})]}):null]})}function RD(e,t){const n=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${n}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function Qk({ids:e,agentName:t,onDone:n}){const r=e.length,[i,l]=f.useState(!1),[o,a]=f.useState(!1);return r<=0?null:i?s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:RD(r,t)}),s.jsx(P,{size:"sm",variant:"danger",disabled:o,onClick:()=>{a(!0),R.dismissOffers(e).then(()=>{l(!1),n()}).finally(()=>a(!1))},children:`Dismiss ${r}`}),s.jsx(P,{size:"sm",variant:"ghost",disabled:o,onClick:()=>l(!1),children:"Keep them"})]}):s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>l(!0),children:"Dismiss all"})}function Jk({embedded:e,agentId:t,agentName:n}){const{data:r,error:i,reload:l}=se(()=>R.offers(),[],2e4),o=j=>!t||j.agentId===t,a=((r==null?void 0:r.offers)??[]).filter(o),c=((r==null?void 0:r.closed)??[]).filter(o),[u,p]=f.useState(null),[d,h]=f.useState(null),[x,v]=f.useState(null),w=async(j,g)=>{p(null),h(j);try{const y=await R.takeOffer(j);v(y.jobId?`On it — ${g}. Started as job ${y.jobId}.`:`Taken — ${g}. No worker is running here, so nothing has started yet.`),l()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(null)}},b=async(j,g)=>{p(null),h(j);try{await R.dismissOffer(j),v(`Dismissed — ${g}. It will not come back.`),l()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(null)}};return s.jsxs(an,{embedded:e,title:"Offers",lede:"Things an agent already worked out that you might want done. Taking one asks that agent the sentence it wrote. It authorizes nothing, and anything that would leave this machine still comes back to you as an approval.",children:[s.jsx(re,{message:i??u}),x?s.jsx(K,{tone:"good",role:"status",children:x}):null,a.length>0?s.jsxs(J,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(Qk,{ids:a.map(j=>j.id),agentName:n,onDone:()=>{v(null),l()}})]}):null,!r||a.length===0?s.jsx(wt,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):s.jsx(G,{children:a.map(j=>s.jsx(Fr,{tone:"accent",title:j.label,meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{mono:!0,children:j.agentId}),s.jsxs("span",{className:"muted",children:["expires ",Ce(j.expiresAt)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",variant:"ghost",disabled:d===j.id,onClick:()=>void b(j.id,j.label),children:"Not now"}),s.jsx(P,{variant:"accent",size:"sm",disabled:d===j.id,onClick:()=>void w(j.id,j.label),children:"Take"})]}),children:s.jsx("p",{className:"ui-card-meta",children:j.prompt})},j.id))}),c.length>0?s.jsxs(bt,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[s.jsx(rt,{flush:!0,children:s.jsx(Ht,{children:c.map(j=>s.jsx(rn,{title:j.label,sub:`${j.agentId} — ${ER(j)}`,side:Ce(j.dismissedAt??j.lapsedAt??j.createdAt)},j.id))})}),s.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const TD=["fact","observation","todo"];function Xk({embedded:e,agents:t,timezone:n,agentId:r}){const{data:i,error:l,reload:o}=se(()=>R.memory(r),[r],3e4),[a,c]=f.useState(null),[u,p]=f.useState(null),[d,h]=f.useState(null),x=m=>{var k;return m==="shared"?"Everyone":((k=t.find(S=>S.id===m))==null?void 0:k.name)??m},v=async m=>{h(null);try{await m,o()}catch(k){h(k instanceof de?k.message:String(k))}},w={nameOf:x,timezone:n,onChangePreference:m=>c({key:m.key,scope:m.scope}),onForgetPreference:m=>void v(R.forgetPreference({key:m.key,scope:m.scope})),onEditNote:m=>p(m),onForgetNote:m=>void v(R.forgetNote(m.id))},b=r?x(r):"",j=r&&i?{preferences:i.preferences.filter(m=>m.scope===r),notes:i.notes.filter(m=>m.scope===r)}:null,g=r&&i?{preferences:i.preferences.filter(m=>m.scope==="shared"),notes:i.notes.filter(m=>m.scope==="shared")}:null,y=s.jsx(P,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return s.jsxs(an,{embedded:e,title:"Memory",lede:"What your agents have kept about you. Correct anything here; they see the change on their next turn.",children:[s.jsx(re,{message:l??d}),j&&g?s.jsxs(G,{gap:"lg",children:[s.jsx(Y,{title:"Preferences",aside:`what you told ${b} alone`,actions:y,panel:!0,flush:!0,children:s.jsx(Od,{preferences:j.preferences,empty:`Nothing stated to ${b} alone yet.`,...w})}),s.jsx(Y,{title:"Notes",aside:`what ${b} wrote down for itself`,panel:!0,flush:!0,children:s.jsx(Dd,{notes:j.notes,empty:`${b} has kept no private notes yet.`,...w})}),s.jsx(bt,{summary:`Shared with every agent, which ${b} also reads · ${g.preferences.length} preferences, ${g.notes.length} notes`,children:s.jsxs(G,{gap:"lg",children:[s.jsx(Y,{title:"Shared preferences",panel:!0,flush:!0,children:s.jsx(Od,{preferences:g.preferences,empty:"No shared preferences.",...w})}),s.jsx(Y,{title:"Shared notes",panel:!0,flush:!0,children:s.jsx(Dd,{notes:g.notes,empty:"No shared notes.",...w})})]})})]}):s.jsxs(G,{gap:"lg",children:[s.jsx(Y,{title:"Preferences",aside:"what you said you want, one current value each",actions:y,panel:!0,flush:!0,children:i?s.jsx(Od,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...w}):s.jsx(le,{children:"Loading…"})}),s.jsx(Y,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?s.jsx(Dd,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...w}):s.jsx(le,{children:"Loading…"})})]}),a?s.jsx(PD,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:a,onClose:()=>c(null),onSave:async m=>{await v((async()=>{await R.setPreference(m),a.key===m.key&&a.scope!==m.scope&&await R.forgetPreference({key:a.key,scope:a.scope})})()),c(null)}}):null,u?s.jsx(ID,{note:u,agents:t,onClose:()=>p(null),onSave:m=>v(R.updateNote(u.id,m)).then(()=>p(null))}):null]})}function Od({preferences:e,empty:t,nameOf:n,onChangePreference:r,onForgetPreference:i}){return e.length===0?s.jsx(le,{children:t}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Preference"}),s.jsx("th",{children:"Value"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{className:"num",children:"Since"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:l.key}),s.jsx("td",{children:l.value}),s.jsx("td",{children:s.jsx(Zk,{scope:l.scope,name:n(l.scope)})}),s.jsxs("td",{className:"num muted",title:l.updatedAt??"",children:[l.updatedAt?Ce(l.updatedAt,Date.now()):"",l.revision>1?` · rev ${l.revision}`:""]}),s.jsx("td",{className:"num",children:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",onClick:()=>r(l),title:"Store a new value for this key",children:"Change"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(l),children:"Forget"})]})})]},`${l.scope}:${l.key}`))})]})}function Dd({notes:e,empty:t,nameOf:n,timezone:r,onEditNote:i,onForgetNote:l}){return e.length===0?s.jsx(le,{children:t}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Note"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{children:"Written by"}),s.jsx("th",{className:"num",children:"When"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"memory-note",children:o.content}),s.jsx("td",{children:s.jsx(pe,{tone:o.kind==="todo"?"warning":o.kind==="fact"?"good":void 0,children:o.kind})}),s.jsx("td",{children:s.jsx(Zk,{scope:o.scope,name:n(o.scope)})}),s.jsx("td",{className:"muted",children:o.createdByAgent?n(o.createdByAgent):""}),s.jsxs("td",{className:"num muted",title:o.createdAt??"",children:[o.createdAt?Ce(o.createdAt,Date.now()):"",o.expiresAt?s.jsxs("span",{className:"memory-expires",children:[" · until ",new Date(o.expiresAt).toLocaleDateString(void 0,{timeZone:r})]}):null]}),s.jsx("td",{className:"num",children:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",onClick:()=>i(o),children:"Edit"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>l(o),children:"Forget"})]})})]},o.id))})]})}function Zk({scope:e,name:t}){return s.jsx(pe,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function eS({value:e,agents:t,onChange:n}){return s.jsxs("select",{value:e,onChange:r=>n(r.target.value),children:[s.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>s.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function PD({agents:e,existing:t,initial:n,onClose:r,onSave:i}){const l=t.find(g=>g.key===n.key&&g.scope===n.scope),[o,a]=f.useState(n.key),[c,u]=f.useState((l==null?void 0:l.value)??""),[p,d]=f.useState(n.scope),[h,x]=f.useState(!1),v=o.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(g=>g.key===v&&g.scope===p),b=!l||v!==l.key||c.trim()!==l.value||p!==l.scope,j=v!==""&&c.trim()!==""&&b;return s.jsx(Yt,{title:"A preference",onClose:r,children:s.jsxs(G,{children:[s.jsx(K,{children:'A preference is a standing choice, in your words: "paid biweekly on Thursdays", "answers short, numbers first". Storing the same key again records a correction and keeps the old value in the history.'}),s.jsx(te,{label:"Key",hint:v&&v!==o?`Stored as ${v}`:"Short and stable, like reporting_currency or tone.",children:s.jsx("input",{value:o,autoFocus:n.key==="",onChange:g=>a(g.target.value),placeholder:"reporting_currency"})}),s.jsx(te,{label:"Value",children:s.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:n.key!=="",onChange:g=>u(g.target.value),placeholder:"EUR"})}),s.jsx(te,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:s.jsx(eS,{value:p,agents:e,onChange:d})}),w&&w!==l?s.jsxs(K,{tone:"warning",children:['This replaces the value already stored for this key here, "',w.value,'" (revision ',w.revision,")."]}):null,l&&p!==l.scope?s.jsxs(K,{children:["It moves: the copy for ",l.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:r,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!j||h,onClick:()=>{x(!0),i({key:v,value:c.trim(),scope:p}).finally(()=>x(!1))},children:l?"Save change":"Save"})]})]})})}function ID({note:e,agents:t,onClose:n,onSave:r}){var x;const[i,l]=f.useState(e.content),[o,a]=f.useState(e.scope),[c,u]=f.useState(e.kind),[p,d]=f.useState(!1),h=i.trim()!==e.content||o!==e.scope||c!==e.kind;return s.jsx(Yt,{title:"A note",onClose:n,children:s.jsxs(G,{children:[s.jsx(te,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:s.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:v=>l(v.target.value)})}),s.jsxs(As,{children:[s.jsx(te,{label:"Kind",children:s.jsx("select",{value:c,onChange:v=>u(v.target.value),children:TD.map(v=>s.jsx("option",{value:v,children:v},v))})}),s.jsx(te,{label:"Who sees it",children:s.jsx(eS,{value:o,agents:t,onChange:a})})]}),e.createdByAgent?s.jsxs("p",{className:"muted",children:["Written by ",((x=t.find(v=>v.id===e.createdByAgent))==null?void 0:x.name)??e.createdByAgent,e.createdAt?`, ${Ce(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!h||i.trim()===""||p,onClick:()=>{d(!0);const v={};i.trim()!==e.content&&(v.content=i.trim()),o!==e.scope&&(v.scope=o),c!==e.kind&&(v.kind=c),r(v).finally(()=>d(!1))},children:"Save"})]})]})})}function MD({agentId:e,agentName:t}){const{data:n,error:r,reload:i}=se(()=>R.agentSkills(e),[e],3e4),[l,o]=f.useState(null),[a,c]=f.useState(null),[u,p]=f.useState(null),d=async v=>{o(null),c(null),p(v.name);try{const w=await R.removeSkill(e,v.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){o(w instanceof de?w.message:String(w))}finally{p(null)}};if(!n)return r?s.jsx(re,{message:r}):s.jsx(le,{children:"Loading…"});const h=n.skills.filter(v=>v.learned!==null),x=n.skills.filter(v=>v.learned===null);return s.jsxs(G,{divided:!0,children:[s.jsx(re,{message:r??l}),a?s.jsx(K,{tone:"good",role:"status",children:a}):null,s.jsx(Y,{title:"Learned",aside:s.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:h.length===0?s.jsx(wt,{icon:"bulb",title:"Nothing learned yet",children:n.writable?`When ${t} proposes a procedure and you keep it on Settings → Proposals, it appears here.`:`${t} ships with buddi, so it keeps no learned skills of its own until it is yours.`}):s.jsx(rt,{flush:!0,children:s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"Version"}),s.jsx("th",{children:"Came from"}),s.jsx("th",{className:"num",children:"Kept"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:h.map(v=>s.jsx(_D,{skill:v,busy:u===v.name,onRemove:()=>void d(v)},v.name))})]})})}),s.jsx(Y,{title:"From files and plugins",aside:s.jsx("span",{className:"muted",children:"read-only here"}),children:x.length===0?s.jsx(le,{children:"No other skills."}):s.jsx(rt,{flush:!0,children:s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"What it is for"}),s.jsx("th",{children:"Whose"})]})}),s.jsx("tbody",{children:x.map(v=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(bt,{summary:s.jsx("span",{className:"mono",children:v.name}),children:[s.jsx(ut,{children:v.body}),s.jsx("p",{className:"muted mono skill-file",children:v.file})]})}),s.jsx("td",{children:v.description}),s.jsx("td",{children:s.jsxs(G,{gap:"sm",children:[s.jsx(pe,{children:v.scope==="shared"?"shared":`${t} only`}),s.jsx("span",{className:"muted",children:$D(v)})]})})]},`${v.scope}:${v.name}`))})]})})})]})}function $D(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function _D({skill:e,busy:t,onRemove:n}){const r=e.learned;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(bt,{summary:s.jsxs("span",{children:[r.title," ",s.jsx("span",{className:"muted mono",children:e.name})]}),children:[s.jsxs("p",{className:"muted",children:["When: ",e.description]}),s.jsx(ut,{children:e.body}),s.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),s.jsx("td",{children:s.jsxs(G,{gap:"sm",children:[s.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?s.jsx(pe,{tone:"warning",children:"untrusted text in view"}):null]})}),s.jsx("td",{children:s.jsxs(G,{gap:"sm",children:[r.conversation?s.jsx("a",{href:Ui(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):s.jsx("span",{className:"muted",children:"no conversation"}),s.jsx("a",{href:st("proposals"),children:"the proposal"}),r.sources.length>0?s.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>s.jsx("li",{className:"mono",children:i},i))}):null]})}),s.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?Ce(r.keptAt,Date.now()):""}),s.jsx("td",{className:"num",children:s.jsx(J,{align:"end",children:s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:n,children:"Remove"})})})]})}function tS({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:l}=se(()=>R.reminders(),[],3e4),o=((r==null?void 0:r.reminders)??[]).filter(p=>!n||p.agentId===n),[a,c]=f.useState(null),u=async p=>{c(null);try{await R.cancelReminder(p),l()}catch(d){c(d instanceof Error?d.message:String(d))}};return s.jsxs(an,{embedded:t,title:"Reminders",lede:"A reminder wakes an agent with a note and the instruction to check before it speaks, never a message queued for delivery.",children:[s.jsx(re,{message:i??a}),s.jsx(rt,{flush:!0,children:r?o.length===0?s.jsx(wt,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Due"}),s.jsx("th",{children:"Agent"}),s.jsx("th",{children:"Note"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:o.map(p=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Ie(p.dueAt,e),s.jsx("div",{className:"sub",children:Ce(p.dueAt)})]}),s.jsx("td",{className:"mono",children:p.agentId}),s.jsxs("td",{children:[p.text,p.context?s.jsx(bt,{summary:"context",children:s.jsx(ut,{children:ln(p.context)})}):null]}),s.jsxs("td",{children:[s.jsx(hu,{state:p.state}),p.cancelReason?s.jsx("div",{className:"sub",children:p.cancelReason}):null]}),s.jsx("td",{children:p.state==="pending"?s.jsx(P,{size:"sm",variant:"danger",onClick:()=>u(p.id),children:"Cancel"}):null})]},p.id))})]}):s.jsx(le,{children:"Loading…"})})]})}function Dm({accountId:e,label:t,value:n,onChange:r,disabled:i=!1}){const[l,o]=f.useState(null),[a,c]=f.useState(!1),[u,p]=f.useState(""),[d,h]=f.useState(!1),x=f.useRef(0),v=async g=>{if(!e)return;const y=++x.current;c(!0),p("");try{const m=await R.accountModels(e,g);y===x.current&&o(m)}catch(m){y===x.current&&p(m instanceof Error?m.message:"Could not load models. Custom entry is still available.")}finally{y===x.current&&c(!1)}};if(f.useEffect(()=>(o(null),h(!1),p(""),v(!1),()=>{x.current++}),[e]),!e)return s.jsxs(s.Fragment,{children:[s.jsx(te,{label:t,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:g=>r(g.target.value)})}),s.jsx("p",{className:"ui-toolbar-note",children:"Save and connect the account to load its model list. You can enter a model manually now."})]});const w=(l==null?void 0:l.models)??[],b=!!n&&!w.some(g=>g.id===n),j=[l&&!w.length?"This account returned no models. You can enter a custom model.":null,l!=null&&l.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,l?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(te,{label:t,children:s.jsxs("select",{value:d?"__buddi_custom__":n,disabled:i,onChange:g=>{g.target.value==="__buddi_custom__"?h(!0):(h(!1),r(g.target.value))},children:[s.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),b&&s.jsxs("option",{value:n,children:[n," (current",l?", not listed":"",")"]}),w.map(g=>s.jsxs("option",{value:g.id,children:[g.name===g.id?g.id:`${g.name} — ${g.id}`,g.isDefault?" (provider default)":""]},g.id)),s.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),s.jsx(P,{disabled:i||a,onClick:()=>void v(!0),children:a?"Loading models…":"Refresh models"}),d&&s.jsx(te,{label:`Custom ${t.toLowerCase()}`,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:g=>r(g.target.value)})}),u&&s.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),j.length>0&&s.jsx("p",{className:"ui-toolbar-note",children:j.join(" ")})]})}function OD(e,t){const n=new Set(t),r=[],i=new Set;for(const l of e){for(const a of l.tools)i.add(a.name);const o=l.tools.filter(a=>n.has(a.name));o.length!==0&&(l.glob&&o.length===l.tools.length?r.push(l.glob):r.push(...o.map(a=>a.name)))}return r.push(...t.filter(l=>!i.has(l))),r}function DD(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const LD="This agent will not remember anything between conversations.";function FD({view:e,chosen:t,onChange:n,disabled:r}){var k;const[i,l]=f.useState(""),[o,a]=f.useState(null),[c,u]=f.useState(()=>new Set),p=S=>u(N=>{const C=new Set(N);return C.has(S)?C.delete(S):C.add(S),C}),d=S=>{l(S),u(new Set)},h=f.useId(),x=new Set(t),v=new Set(e.groups.flatMap(S=>S.tools.filter(N=>N.core).map(N=>N.name))),w=(S,N)=>{const C=N.filter(T=>x.has(T));if(C.length!==0){if(C.some(T=>v.has(T))){a({plugin:S,names:C});return}n(t.filter(T=>!C.includes(T)))}},b=S=>{n([...t,...S.filter(N=>!x.has(N))])},j=i.trim().toLowerCase(),g=(S,N)=>j===""||S.toLowerCase().includes(j)||N.toLowerCase().includes(j),y=e.groups.map(S=>({group:S,tools:S.tools.filter(N=>g(N.name,N.description))})).filter(S=>S.tools.length>0),m=(((k=e.suggested)==null?void 0:k.tools)??[]).filter(S=>!x.has(S.name));return s.jsxs("div",{className:"tool-picker",children:[e.suggested&&m.length>0?s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${h}-suggested`,children:[s.jsx("div",{className:"tool-picker-head",children:s.jsx("span",{id:`${h}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),s.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:m.map(S=>s.jsxs("li",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title mono",children:S.name}),s.jsx("span",{className:"ui-list-sub",children:S.description})]}),s.jsx(P,{size:"sm",disabled:r,"aria-label":`Add ${S.name}`,onClick:()=>b([S.name]),children:"Add"})]},S.name))})]}):null,s.jsxs("label",{className:"tool-picker-search",children:[s.jsx("span",{className:"ui-field-label",children:"Find a tool"}),s.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:S=>d(S.target.value)})]}),y.length===0?s.jsxs(le,{children:["No installed tool matches “",i.trim(),"”."]}):null,y.map(({group:S,tools:N})=>{const C=S.tools.filter(A=>A.grantable).map(A=>A.name),T=S.tools.filter(A=>x.has(A.name)).length,E=!!S.glob&&T===S.tools.length,_=`${h}-${S.plugin}`,F=`${h}-${S.plugin}-list`,O=j!==""?!c.has(S.plugin):c.has(S.plugin);return s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":_,"data-open":O?"true":void 0,children:[s.jsxs("div",{className:"tool-picker-head",children:[s.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":O,"aria-controls":F,onClick:()=>p(S.plugin),children:[s.jsx(UD,{}),s.jsx("span",{id:_,className:"tool-picker-plugin",children:S.plugin}),s.jsx("span",{className:"muted",children:E?`all ${S.tools.length}`:`${T} of ${S.tools.length} granted`})]}),s.jsx(P,{size:"sm",variant:"ghost","aria-label":`All ${S.plugin} tools`,disabled:r||C.every(A=>x.has(A)),onClick:()=>b(C),children:"all"}),s.jsx(P,{size:"sm",variant:"ghost","aria-label":`No ${S.plugin} tools`,disabled:r||!C.some(A=>x.has(A)),onClick:()=>w(S.plugin,C),children:"none"})]}),(o==null?void 0:o.plugin)===S.plugin?s.jsx(K,{tone:"warning",role:"alert",children:s.jsxs("div",{className:"tool-picker-confirm",children:[s.jsx("span",{children:LD}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{size:"sm",onClick:()=>a(null),children:"Keep"}),s.jsx(P,{size:"sm",variant:"danger",onClick:()=>{n(t.filter(A=>!o.names.includes(A))),a(null)},children:"Remove"})]})}):null,s.jsx("ul",{id:F,className:"ui-list tool-picker-list",hidden:!O,children:N.map(A=>{const D=`${h}-${A.name}`;return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:D,checked:x.has(A.name),disabled:r||!A.grantable,onChange:q=>q.target.checked?b([A.name]):w(S.plugin,[A.name])}),s.jsxs("label",{htmlFor:D,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[s.jsx("span",{className:"mono",children:A.name}),A.core?s.jsx(pe,{tone:"accent",children:"core"}):null,A.gated?s.jsx(pe,{tone:"warning",children:"asks you"}):null]}),s.jsx("span",{className:"ui-list-sub",children:A.grantable?A.description:`${A.description} Granted only by editing the file by hand.`})]})]},A.name)})})]},S.plugin)})]})}function UD(){return s.jsx("svg",{className:"tool-picker-chevron",viewBox:"0 0 11 11","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const BD="buddi",zD=["core","coding","finance","garage","mail","maker","playground","research"],vu=e=>`./mascot/${e}.png`,WD=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],VD="Introduce yourself by name, say one thing you can do today, and ask one question.",B={opening:["Hi. I'm buddi. I live on this computer, and I'm about to introduce you to your first assistant.","Nothing you tell me leaves this machine, except what your assistant sends to the AI you pick in a minute."],later:"Set up later",name:{ask:"First, what should we call you?",placeholder:"Your first name",submit:"That's me"},clock:{ask:(e,t)=>`Nice to meet you, ${e}. I'll set your clock to ${t}, which is what this browser says. Right?`,yes:"Yes",another:"Pick another",label:"Your clock",answer:e=>e},brain:{ask:"Your assistant needs a brain: an AI it thinks with. Which of these do you already have?",cards:{claude:{title:"Claude",line:"I pay for Claude"},key:{title:"A key from Anthropic or OpenAI",line:"I have an API key"},ollama:{title:"Ollama",line:"Free, on this computer"},service:{title:"Ollama Cloud, or another service",line:"I have an address and a key"}},claude:{start:"Sign in with Claude",open:"Open the Claude sign-in page",paste:"Paste what Claude gave you",finish:"Done",waiting:"Sign in, then paste the code Claude shows you."},key:{field:"Your key",placeholder:"Paste it here",submit:"Use this key",which:"Not right?",anthropic:"Anthropic",openai:"OpenAI",refused:"That key was refused. Check it and paste it again."},ollama:{found:"Found it, running now",missing:"Install Ollama, then come back",connect:"Use Ollama",download:"Get Ollama",looking:"Looking for it on this computer…"},model:{ask:"Which one should it think with?",label:"The model",submit:"Use this one"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking Ollama…",claude:"Checking with Claude…"},back:"Back",service:{address:"Address",addressPlaceholder:"The address they gave you",key:"Key",submit:"Connect it"},works:e=>`That works. Your assistant will think with ${e}.`,refused:e=>e,answer:e=>e},browser:{chrome:"Your assistant will browse with Google Chrome.",chromium:"Your assistant will browse with its own Chromium.",needs:"Your assistant needs a browser of its own to look at websites. I am fetching one now, about 150 MB.",installing:"Fetching the browser…",launching:"Making sure it opens…",installed:"Installed.",skip:"Skip for now",skipped:"Skipped. Settings → Computer & browser can install it whenever you like.",missing:"No browser for your assistant yet. Settings → Computer & browser can install one.",failed:e=>`That did not work: ${e}`,retry:"Try again"},assistant:{ask:"Last thing: your assistant. I've picked a name and a face; change either, or keep them.",name:"Name",face:"A face",mascot:e=>e==="core"?"Buddi Blob":`Buddi Blob, ${e}`,purpose:"What should it help you with?",purposeValue:["You're not a chatbot. You're becoming someone this person can count on.","","Some starting truths:","",`- Help for real. No "Great question", no "I'd be happy to". Do the thing, then say what you did.`,"- Have a view. Prefer things, disagree when you should, say when something is a bad idea. A search engine with manners is not a colleague.","- Look before you ask. Read the file, check what you remember, try it. Come back with an answer and one question at most.","- You are a guest here. You can see messages, files and a calendar. Treat that with care, keep what you learn to yourself, and never lecture.","- Remember what matters. Names, preferences, the things they said once and expect you to keep.","- When you change how you work, say so. This file is yours to grow, and the owner should always know what it says."].join(`
107
- `),submit:"Introduce us"},restore:{offer:"I have a backup from another buddi",file:"The backup file",passphrase:"Its passphrase",passphraseHint:"Only if it was locked with one.",submit:"Restore",cancel:"Never mind",started:"Right. Give me a couple of minutes.",phases:{stopping:"Putting everything down for a moment.",snapshot:"Keeping a copy of what is here now, just in case.",database:"Bringing back your conversations and everything you told it to remember.",recovery:"Almost there. Nothing will run on its own until you say so.",files:"Bringing back your files.",starting:"Starting back up.",done:"That is everything.","rolled-back":"That did not work, so I put everything back the way it was.",failed:"That did not work."},welcome:e=>`Welcome back, ${e}.`,keys:"A backup never carries keys, so the AI you think with needs its key one more time."},tagline:"Setting up, on this Mac.",taglineElsewhere:"Setting up, on this computer.",handover:{waiting:"One moment.",looking:e=>`${e} is looking around…`,slow:"Still waking up. A brain on this computer takes a minute the first time.",silent:"Your assistant isn't answering. The AI you picked may be down; try again, or pick another brain above.",again:"Pick another brain"},offers:{phone:"Talk to me from your phone",notNow:"Not now"},done:{said:"You're all set. This conversation carries on in your dashboard.",leaving:"Opening buddi…",ready:"Ready when you are.",open:"Open buddi"},telegram:{how:"Two minutes: open Telegram, message @BotFather, send /newbot, paste the token it gives you here.",field:"The token",submit:"Save it",restart:"Saved. It will be ready the next time buddi starts.",scan:"Scan this with your phone and press Start.",expired:"That code has run out. I can make you another one.",newCode:"Show a new code",paired:"That is your phone, talking to me. You can close this and carry on there."},change:"change"},HD=(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 nS(e){const t=await fetch(vu(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const n=await t.blob();return new File([n],`buddi-blob-${e}.png`,{type:"image/png"})}function sS({face:e,onPick:t,label:n=B.assistant.face,kept:r,disabled:i,disableEmoji:l,children:o}){return s.jsxs("div",{className:"meet-faces",role:"group","aria-label":n,children:[s.jsxs("div",{className:"meet-face-row",children:[r?s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":(e==null?void 0:e.kind)==="kept"?"true":void 0,"aria-pressed":(e==null?void 0:e.kind)==="kept","aria-label":"The current picture",disabled:i,onClick:()=>t({kind:"kept",url:r}),children:s.jsx("img",{src:r,alt:""})}):null,zD.map(a=>{const c={kind:"mascot",role:a},u=HD(e,c);return s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":B.assistant.mascot(a),disabled:i,onClick:()=>t(c),children:s.jsx("img",{src:vu(a),alt:""})},a)})]}),s.jsx("div",{className:"meet-face-row",children:WD.map(a=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===a;return s.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||l,onClick:()=>t({kind:"emoji",value:a}),children:a},a)})}),o]})}const KD=["mirror","en","fr"],rS=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"access",label:"Access"}],Qv=e=>{var t;return((t=rS.find(n=>n.id===e))==null?void 0:t.id)??"identity"};function GD({agentId:e,section:t,navigate:n}){var w,b,j;const{data:r,error:i,reload:l}=se(()=>R.agents(),[]),[o,a]=f.useState(null),[c,u]=f.useState(null),[p,d]=f.useState(Qv(t));f.useEffect(()=>d(Qv(t)),[t]);const h=g=>{d(g),n==null||n(ht(e,"setup",g))},x=async g=>{a(null),u(null);try{const y=await g;u(y.changed.length===0?`No file change needed. ${y.note}.`:`Changed ${y.changed.join(", ")}. ${y.note}.`),l()}catch(y){a(y instanceof Error?y.message:String(y))}},v=r==null?void 0:r.agents.find(g=>g.id===e);return s.jsxs(G,{gap:"lg",children:[s.jsx(mu,{level:"secondary",label:"Setup",children:rS.map(g=>s.jsx(gu,{href:ht(e,"setup",g.id),active:p===g.id,onClick:y=>{y.preventDefault(),h(g.id)},children:g.label},g.id))}),s.jsx(re,{message:i??o}),c?s.jsx(K,{tone:"good",role:"status",children:c}):null,r?v?s.jsx(YD,{agent:v,all:r.agents,engine:r.engines.find(g=>g.id===v.id),providers:r.providers,accounts:r.providerAccounts,shown:p,onShow:h,onRun:x,onSaved:l},`${v.id}:${(w=r.engines.find(g=>g.id===v.id))==null?void 0:w.model}:${(j=(b=r.providerAccounts)==null?void 0:b.bindings.find(g=>g.agentId===v.id))==null?void 0:j.accountId}`):s.jsx(le,{children:"This agent is not installed as a file."}):s.jsx(le,{children:"Loading…"})]})}function YD({agent:e,all:t,engine:n,providers:r,accounts:i,shown:l,onShow:o,onRun:a,onSaved:c}){const u=(n==null?void 0:n.provider)??e.provider.kind,p=r.find(m=>m.kind===u),d=(n==null?void 0:n.model)??e.model,[h,x]=f.useState(String((n==null?void 0:n.maxTurns)??e.maxTurns)),v=m=>{a(R.setAgentEngine(e.id,m))},w=m=>{const k=r.find(S=>S.kind===m);v({provider:m,model:(k==null?void 0:k.defaultModel)??d})},b=(p==null?void 0:p.models.map(m=>m.id))??[],j=b.includes(d)?b:[d,...b],g=n?n.available:!0,y=(n==null?void 0:n.unavailableReason)??"no credential";return s.jsxs(s.Fragment,{children:[s.jsx("div",{hidden:l!=="identity",children:s.jsxs(G,{gap:"lg",children:[g?null:s.jsxs(K,{tone:"warning",children:["This agent cannot run right now."," ",s.jsx("a",{href:ht(e.id,"setup","brain"),onClick:m=>{m.preventDefault(),o("brain")},children:"See Brain."})]}),s.jsx(qD,{agent:e,onSaved:c})]})}),s.jsx("div",{hidden:l!=="brain",children:s.jsxs(G,{gap:"lg",children:[g?null:s.jsxs(K,{tone:"warning",children:["This agent cannot run right now: ",y,"."]}),s.jsx(Y,{panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsxs(Y,{title:"Runs on",children:[i?s.jsx(ZD,{agentId:e.id,accounts:i,onRun:a}):s.jsxs(As,{children:[s.jsx(te,{label:"Provider",children:s.jsx("select",{value:u,onChange:m=>w(m.target.value),children:r.map(m=>s.jsxs("option",{value:m.kind,children:[m.kind,m.usable?"":" (no credential)"]},m.kind))})}),s.jsxs(te,{label:"Model",children:[s.jsx("input",{list:`models-${e.id}`,defaultValue:d,onBlur:m=>{m.target.value.trim()!==""&&m.target.value.trim()!==d&&v({model:m.target.value.trim()})}}),s.jsx("datalist",{id:`models-${e.id}`,children:j.map(m=>s.jsx("option",{value:m},m))})]})]}),i?null:s.jsxs("p",{className:"ui-card-meta",children:[(n==null?void 0:n.credentialKind)??e.provider.credentialKind," from"," ",s.jsx("span",{className:"mono",children:(n==null?void 0:n.credentialEnv)??e.provider.credentialEnv}),p&&!p.usable?` · default model ${p.defaultModel} (${p.defaultFrom})`:""]}),n!=null&&n.restartRequired?s.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),s.jsx(Y,{title:"Behaviour",aside:"saved as you change them",children:s.jsxs(As,{children:[s.jsx(te,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:s.jsx("input",{type:"number",min:1,value:h,onChange:m=>x(m.target.value),onBlur:()=>{const m=Number(h);Number.isInteger(m)&&m>=1&&m!==((n==null?void 0:n.maxTurns)??e.maxTurns)&&v({maxTurns:m})}})}),s.jsx(te,{label:"Language",hint:"Mirror answers in whatever language you write.",children:s.jsx("select",{value:(n==null?void 0:n.language)??e.language,onChange:m=>v({language:m.target.value}),children:KD.map(m=>s.jsx("option",{value:m,children:m},m))})}),s.jsx(te,{label:"Thinking",hint:"Reasoning before the answer. Off is faster; the model's default is usually on for local models.",children:s.jsxs("select",{"aria-label":"Thinking",value:(n==null?void 0:n.thinking)??"default",onChange:m=>v({thinking:m.target.value==="default"?null:m.target.value}),children:[s.jsx("option",{value:"default",children:"Model default"}),s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})})]})})]})})]})}),s.jsx("div",{hidden:l!=="access",children:s.jsxs(G,{gap:"lg",children:[s.jsx(QD,{agent:e,all:t,onSaved:c}),s.jsx(nL,{agent:e,all:t,onSaved:c}),s.jsx(bt,{summary:"Built-in context",boxed:!0,children:s.jsx("p",{className:"ui-card-meta",children:"Every agent receives current time, owner timezone and server-host information. system.time and system.info are always available, without grants or approval. Host and browser access still require their own permissions."})})]})})]})}function iS({dirty:e,busy:t,failure:n,label:r,onSave:i}){return s.jsxs(s.Fragment,{children:[n?s.jsx("span",{className:"critical save-error",role:"alert",children:n}):s.jsx("span",{className:e?"warning":"muted",children:e?"Not saved yet.":"Saved. Applies to new runs."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:!e||t,onClick:i,children:r})]})}const lS=s.jsx(K,{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 qD({agent:e,onSaved:t}){var O;const[n,r]=f.useState(e.name),[i,l]=f.useState(e.handle),[o,a]=f.useState(e.description),[c,u]=f.useState(e.avatar??""),[p,d]=f.useState(!1),h=se(()=>R.agentFile(e.id),[e.id]),[x,v]=f.useState(null),w=((O=h.data)==null?void 0:O.persona.trim())??"",b=x??w,j=h.data!==void 0&&x!==null&&x.trim()!==w,[g,y]=f.useState(!1),[m,k]=f.useState(null),[S,N]=f.useState(null),C=n.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||o.trim()!==e.description||c.trim()!==(e.avatar??"")||j,T=c.trim()!==""&&(c.trim()!==(e.avatar??"")||!e.picture),E=Rh(T?{...e,avatar:c.trim()}:e),_={...E?{avatar:E}:{},...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...!T&&e.picture?{picture:e.picture}:{}},F=async()=>{y(!0),k(null),N(null);try{const A=await R.updateAgentFile(e.id,{name:n.trim(),handle:i.trim().replace(/^@/,""),description:o.trim(),...c.trim()===""?{}:{avatar:c.trim()},...j&&b.trim()!==""?{persona:b.trim()}:{}});e.picture&&c.trim()!==""&&c.trim()!==(e.avatar??"")&&(await R.removeAgentPicture(e.id),window.dispatchEvent(new Event(io))),v(null),h.reload(),N(A.message),t()}catch(A){k(A instanceof Error?A.message:String(A))}finally{y(!1)}};return s.jsx(Y,{title:"Who it is",aside:s.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:s.jsx(iS,{dirty:C,busy:g,failure:m,label:"Save who it is",onSave:()=>void F()}),children:s.jsxs(G,{children:[e.isExample?lS:null,S?s.jsx(K,{tone:"good",role:"status",children:S}):null,s.jsxs(As,{children:[s.jsx(te,{label:"Name",hint:"What it is called, everywhere.",children:s.jsx("input",{value:n,disabled:g||e.isExample,onChange:A=>r(A.target.value)})}),s.jsx(te,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:s.jsx("input",{value:i,disabled:g||e.isExample,onChange:A=>l(A.target.value)})})]}),s.jsxs(J,{children:[s.jsx(os,{id:e.id,name:n.trim()||e.name,size:"xl",face:_}),s.jsx(P,{"aria-expanded":p,onClick:()=>d(A=>!A),children:p?"Hide faces":"Change face"})]}),p?s.jsx(JD,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:g}):null,s.jsx(te,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:s.jsx("textarea",{rows:2,value:o,disabled:g||e.isExample,onChange:A=>a(A.target.value)})}),s.jsx(te,{label:"Persona",hint:s.jsxs(s.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",s.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:h.error?s.jsx(re,{message:h.error}):h.data?s.jsx("textarea",{className:"setup-persona",value:b,rows:Math.max(6,b.split(`
108
- `).length+1),disabled:g||e.isExample,onChange:A=>v(A.target.value)}):s.jsx(le,{children:"Reading its file…"})})]})})}function QD({agent:e,all:t,onSaved:n}){var T;const r=se(()=>R.agentTools(e.id),[e.id]),[i,l]=f.useState(null),[o,a]=f.useState(()=>new Set((e.roles??[]).filter(cv))),[c,u]=f.useState((e.roles??[]).filter(E=>!cv(E)).join(", ")),[p,d]=f.useState(!1),[h,x]=f.useState(null),[v,w]=f.useState(null),b=(E,_)=>E.split(_).map(F=>F.trim()).filter(F=>F!==""),j=((T=r.data)==null?void 0:T.granted)??e.tools,g=i??j,y=r.data!==void 0&&!DD(g,j),m=uv(o,b(c,/[\n,]/)),k=E=>a(_=>{const F=new Set(_);return F.has(E)?F.delete(E):F.add(E),F}),N=y||!((E,_)=>E.join(",")===_.join(","))(m,uv(new Set(e.roles??[]),e.roles??[])),C=async()=>{d(!0),x(null),w(null);try{const E=await R.updateAgentFile(e.id,{...y&&r.data?{tools:OD(r.data.groups,g)}:{},roles:m});w(E.message),l(null),r.reload(),n()}catch(E){x(E instanceof Error?E.message:String(E))}finally{d(!1)}};return s.jsx(Y,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:s.jsx(iS,{dirty:N,busy:p,failure:h,label:"Save roles and tools",onSave:()=>void C()}),children:s.jsxs(G,{children:[e.isExample?lS:null,v?s.jsx(K,{tone:"good",role:"status",children:v}):null,s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",id:`roles-${e.id}`,children:"Roles"}),s.jsx("div",{className:"role-chips",role:"group","aria-labelledby":`roles-${e.id}`,children:mm.map(E=>{const _=k2(t,E.id),F=_&&_.id!==e.id?_:void 0;return s.jsxs("button",{type:"button",className:"role-chip","aria-pressed":o.has(E.id),"data-on":o.has(E.id)?"true":void 0,disabled:p||e.isExample,onClick:()=>k(E.id),children:[s.jsx("span",{className:"role-chip-label",children:E.label}),s.jsx("span",{className:"role-chip-meaning",children:E.meaning}),F?s.jsxs("span",{className:"role-chip-holder",children:["Held by ",F.name,". If both claim it, the one listed first keeps it."]}):null]},E.id)})}),s.jsx("span",{className:"ui-field-hint",children:"Where buddi sends things when you do not say who. Tools are granted below."})]}),s.jsx(te,{label:"Other roles",hint:"Only a plugin that asks for a role by name reads these. Comma separated.",children:s.jsx("input",{value:c,disabled:p||e.isExample,onChange:E=>u(E.target.value)})}),s.jsxs("div",{className:"ui-field",children:[s.jsxs("span",{className:"ui-field-label",children:["Tools · ",j.length," granted"]}),r.error?s.jsx(re,{message:r.error}):r.data?s.jsx(FD,{view:r.data,chosen:g,onChange:l,disabled:p||e.isExample}):s.jsx(le,{children:"Loading the installed tools…"})]})]})})}function Rh(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 JD({agent:e,avatar:t,onEmoji:n,onChanged:r,disabled:i}){const[l,o]=f.useState(null),[a,c]=f.useState(!1),[u,p]=f.useState(null),d=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),h=l??(d?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),x=async v=>{if(p(null),v.kind==="emoji"){n(v.value);return}if(v.kind==="kept"){n(e.avatar??"");return}o(v),c(!0);try{await R.uploadAgentPicture(e.id,await nS(v.role)),n(e.avatar??""),r(),window.dispatchEvent(new Event(io))}catch(w){p(w instanceof Error?w.message:String(w))}finally{o(null),c(!1)}};return s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Face"}),s.jsx(sS,{face:h,label:"Face",kept:e.picture,disabled:i||a,disableEmoji:e.isExample,onPick:v=>void x(v),children:s.jsx(XD,{agent:e,onChanged:r})}),u?s.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function XD({agent:e,onChanged:t}){const[n,r]=f.useState(null),[i,l]=f.useState(null),[o,a]=f.useState(!1),[c,u]=f.useState(null),[p,d]=f.useState(null),[h,x]=f.useState(0);f.useEffect(()=>{if(!n)return l(null);const N=URL.createObjectURL(n);return l(N),()=>URL.revokeObjectURL(N)},[n]);const v=N=>{r(null),x(C=>C+1),d(N),t(),window.dispatchEvent(new Event(io))},w=async N=>{a(!0),u(null),d(null);try{v(await N())}catch(C){u(C instanceof Error?C.message:String(C))}finally{a(!1)}},b=()=>w(async()=>(await R.uploadAgentPicture(e.id,n)).note??null),j=()=>w(async()=>(await R.removeAgentPicture(e.id),null)),g={avatar:Rh(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[y,m]=f.useState(!1),k=f.useRef(null),S=N=>{u(null),d(null),r(N??null)};return s.jsxs("div",{className:"setup-upload","data-dragging":y?"true":void 0,onDragOver:N=>{N.preventDefault(),o||m(!0)},onDragLeave:()=>m(!1),onDrop:N=>{var C;N.preventDefault(),m(!1),o||S((C=N.dataTransfer.files)==null?void 0:C[0])},children:[s.jsxs(J,{children:[s.jsx(os,{id:e.id,name:e.name,size:"xl",face:g}),s.jsx("input",{ref:k,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:o,onChange:N=>{var C;return S((C=N.target.files)==null?void 0:C[0])}},h),s.jsx(P,{disabled:o,onClick:()=>{var N;return(N=k.current)==null?void 0:N.click()},children:"Upload a picture"}),s.jsx("span",{className:"setup-upload-name",children:n?n.name:"or drop one here"}),s.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!n?s.jsx(P,{variant:"ghost",disabled:o,onClick:()=>void j(),children:"Remove picture"}):null,s.jsx(P,{variant:"accent",disabled:!n||o,onClick:()=>void b(),children:"Save picture"})]}),c?s.jsx("span",{className:"critical save-error",role:"alert",children:c}):s.jsx("span",{className:"ui-field-hint",children:p??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function ZD({agentId:e,accounts:t,onRun:n}){const r=t.bindings.find(x=>x.agentId===e),[i,l]=f.useState((r==null?void 0:r.accountId)??""),[o,a]=f.useState((r==null?void 0:r.model)??""),[c,u]=f.useState(!1),p=t.accounts.find(x=>x.id===i),d=i!==((r==null?void 0:r.accountId)??"")||o!==((r==null?void 0:r.model)??""),h=t.accounts.find(x=>x.id===(r==null?void 0:r.accountId));return s.jsxs("div",{className:"ui-stack",children:[s.jsxs(J,{valign:"end",children:[s.jsx(te,{label:"Account",children:s.jsxs("select",{value:i,disabled:c,onChange:x=>{var v;l(x.target.value),a(((v=t.accounts.find(w=>w.id===x.target.value))==null?void 0:v.defaultModel)??"")},children:[s.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(x=>s.jsxs("option",{value:x.id,disabled:!x.enabled,children:[x.label,x.enabled?x.configured?"":" (needs credential)":" (disabled)"]},x.id))]})}),s.jsx(Dm,{accountId:p!=null&&p.configured?i:void 0,label:"Model",value:o,onChange:a,disabled:c},`${i}:${p==null?void 0:p.revision}`)]}),s.jsxs(J,{children:[d&&i&&o.trim()?s.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",h?`${h.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):s.jsx("span",{className:"muted",children:h?`Running on ${h.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:c||!i||!o.trim()||!d,onClick:()=>{u(!0),n(R.assignProviderAccount(e,i,o).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const eL=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],tL=e=>e.tools.some(t=>eL.includes(t));function nL({agent:e,all:t,onSaved:n}){const[r,i]=f.useState(e.delegates),[l,o]=f.useState(!1),[a,c]=f.useState(null),[u,p]=f.useState(!1),[d,h]=f.useState(e.delegates),x=t.filter(g=>g.id!==e.id),v=[...r].sort().join(",")!==[...d].sort().join(","),w=t.filter(g=>g.id!==e.id&&g.delegates.includes(e.id)),b=g=>i(y=>y.includes(g)?y.filter(m=>m!==g):[...y,g]),j=async()=>{o(!0),c(null),p(!1);try{const g=await R.setDelegates(e.id,r);h(g.delegates),i(g.delegates),p(!0),n()}catch(g){c(g instanceof Error?g.message:String(g))}finally{o(!1)}};return s.jsx(Y,{title:"Delegation",aside:e.tools.includes("agent.delegate")?"holds agent.delegate":"no agent.delegate tool: it cannot ask anyone until granted",panel:!0,foot:e.isExample?void 0:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:v?"warning":"muted",children:v?"Not saved yet.":u?"Saved. Applies to the next run.":r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:!v||l,onClick:()=>void j(),children:"Save who it can ask"})]}),children:s.jsxs(G,{divided:!0,children:[s.jsxs(Y,{title:"Can ask",children:[e.isExample?s.jsx(K,{tone:"warning",children:"This agent ships with buddi, so its allowlist is read-only here. Ask Agent Father to make it yours, then it can change."}):null,s.jsx(re,{message:a}),x.length===0?s.jsx(le,{children:"Nobody else is installed."}):s.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:x.map(g=>{const y=tL(g);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${g.id}`,checked:r.includes(g.id),disabled:y||e.isExample||l,onChange:()=>b(g.id)}),s.jsxs("label",{htmlFor:`can-ask-${e.id}-${g.id}`,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[g.name," ",s.jsxs("span",{className:"mono muted",children:["@",g.handle]})]}),s.jsx("span",{className:"ui-list-sub",children:y?"Makes and changes agents. Never reachable by delegation.":g.description})]})]},g.id)})})]}),s.jsx(Y,{title:"Asked by",children:w.length===0?s.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):s.jsx(TI,{children:w.map(g=>s.jsx(pe,{children:g.name},g.id))})})]})})}const sL=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],rL=[{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 iL({hash:e,timezone:t,navigate:n,agents:r,attention:i,defaultAgentId:l}){var b,j,g,y,m;const o=d2(e),a=((b=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:b[1])??"team",c=k=>S=>{S.preventDefault(),n(k)},u=se(()=>R.agents(),[]),p=Am(),d=se(()=>R.offers(),[],2e4),h=bk(),x=(((j=d.data)==null?void 0:j.offers.length)??0)+h.offers.length,v=((y=(g=u.data)==null?void 0:g.default)==null?void 0:y.defaultAgentId)??l??null,w=r.find(k=>k.roles.includes(gm));return s.jsxs("div",{className:"ui-page",children:[s.jsx(ym,{title:"Agents",lede:`Your team. Each one is a file on ${p} — what it can reach is listed on its page.`,actions:w?s.jsx(Bn,{variant:"accent",href:Fe(w.id),onClick:c(Fe(w.id)),children:"Add an agent"}):null}),s.jsx(mu,{children:sL.map(k=>s.jsx(gu,{href:k.id==="team"?et:`${et}?tab=${k.id}`,active:a===k.id,count:k.id==="offers"?x:void 0,onClick:c(k.id==="team"?et:`${et}?tab=${k.id}`),children:k.label},k.id))}),a==="missions"?s.jsx(qk,{timezone:t,embedded:!0}):null,a==="offers"?s.jsx(kk,{offers:h.offers,reload:h.reload}):null,a==="offers"?s.jsx(Jk,{embedded:!0}):null,a==="reminders"?s.jsx(tS,{timezone:t,embedded:!0}):null,a==="team"?s.jsx(lL,{data:u.data,error:u.error,reload:u.reload}):null,a==="team"?r.length===0?s.jsx(wt,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):s.jsx("div",{className:"agents-grid",children:R0(r,v).map(k=>{const S=fu(i.get(k.id));return s.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...bo(wo(k)),"data-unavailable":k.available?void 0:"true",children:[s.jsx("div",{className:"agent-card-top"}),s.jsx("div",{className:"agent-card-face",children:s.jsx(os,{id:k.id,name:k.name,size:"xl",unavailable:!k.available,face:k})}),s.jsxs("div",{children:[s.jsxs("div",{className:"ui-card-title",children:[s.jsx("a",{className:"agent-card-link",href:ht(k.id,"conversations"),onClick:c(ht(k.id,"conversations")),children:k.name}),s.jsxs("span",{className:"agent-card-handle mono faint",children:["@",k.handle]})]}),s.jsx("p",{className:"ui-card-meta agent-card-desc",children:k.description})]}),s.jsxs("div",{className:"ui-row",children:[k.id===v?s.jsx(Ua,{children:"front desk"}):null,S?s.jsx(pe,{tone:"critical",dot:!0,children:"waiting for you"}):k.available?s.jsx(pe,{tone:"good",dot:!0,children:"ready"}):s.jsx(pe,{tone:"warning",children:Es(k.unavailableReason??"cannot run",60)}),s.jsx(pe,{mono:!0,children:k.model}),s.jsx(Bn,{className:"agent-card-talk",size:"sm",href:Fe(k.id),onClick:c(Fe(k.id)),"aria-label":`Talk to ${k.name}`,children:"Talk"})]})]},k.id)})}):null,o?s.jsx(Yt,{title:((m=r.find(k=>k.id===o.agentId))==null?void 0:m.name)??o.agentId,size:"wide",onClose:()=>n(et),children:s.jsx(oL,{agentId:o.agentId,agent:r.find(k=>k.id===o.agentId),agents:r,tab:o.tab??"conversations",...o.section?{section:o.section}:{},timezone:t,navigate:n,attention:i})}):null]})}function lL({data:e,error:t,reload:n}){const r=e==null?void 0:e.default,[i,l]=f.useState(null),[o,a]=f.useState(!1),[c,u]=f.useState(null),[p,d]=f.useState(null);if(t)return s.jsx(re,{message:t});if(!r||r.choices.length===0)return null;const h=r.defaultAgentId,x=i??h??"",v=x!==""&&x!==h,w=r.problem,b=g=>g.map(y=>{var m;return((m=r.choices.find(k=>k.id===y))==null?void 0:m.name)??y}).join(" and "),j=async()=>{a(!0),u(null),d(null);try{const g=await R.setDefaultAgent(x);d(g.note),l(null),n()}catch(g){u(g instanceof Error?g.message:String(g))}finally{a(!1)}};return s.jsx(rt,{children:s.jsxs("div",{className:"ui-stack",children:[s.jsx(re,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?s.jsx(K,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${b(w.agents)}. The one chosen here wins.`}):(w==null?void 0:w.code)==="no-default-agent"?s.jsx(K,{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,p?s.jsx(K,{tone:"good",role:"status",children:p}):null,s.jsxs(J,{children:[s.jsxs("div",{className:"default-agent-text",children:[s.jsx("h3",{className:"default-agent-title",children:"Default agent"}),s.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("select",{"aria-label":"Default agent",value:x,disabled:o,onChange:g=>l(g.target.value),children:[x===""?s.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(g=>s.jsxs("option",{value:g.id,disabled:!g.available,children:[g.name," @",g.handle,g.available?"":" (cannot run)"]},g.id))]}),s.jsx(P,{variant:"accent",disabled:o||!v,onClick:()=>void j(),children:"Save"})]})]})})}function oL({agentId:e,agent:t,agents:n,tab:r,section:i,timezone:l,navigate:o,attention:a}){const c=d=>h=>{h.preventDefault(),o(d)},u=fu(a.get(e)),p=(t==null?void 0:t.name)??e;return s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[s.jsxs("header",{className:"agent-head",children:[s.jsx(os,{id:e,name:p,size:"xl",unavailable:t?!t.available:!1,face:t}),s.jsxs("div",{className:"agent-head-text",children:[s.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),s.jsxs("div",{className:"ui-row",children:[t?s.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?s.jsx("span",{className:"muted",children:t.model}):null,u?s.jsx(pe,{tone:"critical",children:u}):t&&!t.available?s.jsx(pe,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),s.jsx("div",{className:"ui-page-actions",children:s.jsxs(Bn,{variant:"accent",href:Fe(e),onClick:c(Fe(e)),children:["Talk to ",p]})})]}),t&&!t.available?s.jsxs(K,{tone:"warning",role:"status",children:[I0(t)," ",s.jsx("a",{href:st(ih(t).section),children:ih(t).label})]}):null,s.jsx(mu,{children:rL.map(d=>s.jsx(gu,{href:ht(e,d.id),active:r===d.id,onClick:c(ht(e,d.id)),children:d.label},d.id))}),r==="conversations"?s.jsx(aL,{agentId:e,navigate:o}):null,r==="missions"?s.jsx(qk,{timezone:l,embedded:!0,agentId:e}):null,r==="offers"?s.jsx(Jk,{embedded:!0,agentId:e,agentName:p}):null,r==="reminders"?s.jsx(tS,{timezone:l,embedded:!0,agentId:e}):null,r==="memory"?s.jsx(Xk,{embedded:!0,agents:n,timezone:l,agentId:e}):null,r==="skills"?s.jsx(MD,{agentId:e,agentName:p}):null,r==="setup"?s.jsx(GD,{agentId:e,section:i,navigate:o}):null]})}function aL({agentId:e,navigate:t}){const{data:n,error:r}=se(()=>Le.conversations(e,50),[e]);if(r)return s.jsx(le,{children:r});const i=(n==null?void 0:n.conversations)??[];return s.jsx(rt,{flush:!0,children:n?i.length===0?s.jsx(wt,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):s.jsx(Ht,{children:i.map(l=>s.jsx(rn,{href:Fe(e,l.id),onClick:()=>t(Fe(e,l.id)),title:Es(l.preview||l.opening||"Untitled conversation",90),sub:`${l.messageCount} message${l.messageCount===1?"":"s"}`,side:Ce(l.lastMessageAt??l.startedAt??l.createdAt??null)},l.id))}):s.jsx(le,{children:"Loading…"})})}function cL({timezone:e,navigate:t,agents:n,defaultAgentId:r,attention:i,update:l}){var $,U,X,Z,fe,ve,Ne,oe,be,ye,Te,Ve,it;const o=se(()=>R.overview(),[],15e3),a=se(()=>R.approvals(),[],1e4),c=se(()=>R.missions(),[],6e4),u=se(()=>R.reminders(),[],6e4),p=se(()=>R.conversations(),[],3e4),d=se(()=>R.offers(),[],3e4),h=se(()=>R.proposals(),[],6e4),x=se(()=>R.agentOffers(),[],6e4),v=se(()=>R.owner(),[]),w=se(()=>R.notifications(20),[],3e4),b=f.useMemo(()=>R0(n,r??null),[n,r]),{busy:j,note:g,failure:y,decide:m}=Rm(()=>{a.reload(),o.reload()}),k=o.data,S=H=>{var me;return((me=n.find(ue=>ue.id===H))==null?void 0:me.name)??H},N=H=>me=>{me.preventDefault(),t(H)},C=(($=a.data)==null?void 0:$.pending)??[],T=((U=k==null?void 0:k.jobs)==null?void 0:U.failed)??0,E=((X=k==null?void 0:k.sentinels)==null?void 0:X.openUrgent)??0,_=((Z=h.data)==null?void 0:Z.open.length)??0,F=(((fe=x.data)==null?void 0:fe.offers)??[]).filter(H=>!C.some(me=>wk(me,H.plugin,H.agent))),O=fL(((ve=w.data)==null?void 0:ve.notifications)??[],C),A=C.length+(T>0?1:0)+(E>0?1:0)+(k!=null&&k.paused?1:0)+(_>0?1:0)+F.length+O.length,D=f.useMemo(()=>{var H,me;return gL(((H=c.data)==null?void 0:H.missions)??[],((me=u.data)==null?void 0:me.reminders)??[])},[c.data,u.data]),q=(((Ne=p.data)==null?void 0:Ne.conversations)??[]).slice(0,5),V=((oe=d.data)==null?void 0:oe.offers)??[],M=V.slice(0,hL),z=V.length-M.length;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"home-band",children:s.jsxs("header",{className:"home-hero",children:[s.jsxs("div",{className:"home-hero-text",children:[s.jsx("p",{className:"home-date",children:jL(k==null?void 0:k.now,e)}),s.jsx("h1",{className:"home-greeting",children:vL(k==null?void 0:k.now,e,((be=v.data)==null?void 0:be.preferredName)||((ye=v.data)==null?void 0:ye.displayName))}),s.jsx("p",{className:"home-lede",children:wL(A,C.length,T,E,(k==null?void 0:k.paused)??!1,_,F.length,O.length)})]}),s.jsx(O0,{size:"lg"})]})}),s.jsxs("div",{className:"home",children:[l&&l.updateAvailable&&!l.checkout&&l.latest?s.jsxs(K,{tone:"accent",children:["A newer buddi is ready: ",s.jsx("span",{className:"mono",children:l.latest}),"."," ",s.jsx("a",{href:st("system"),onClick:N(st("system")),children:"Upgrade from Settings → Version."})]}):null,s.jsx(re,{message:o.error??a.error??y}),g?s.jsx(K,{tone:"good",role:"status",children:g}):null,A>0?s.jsx(Y,{title:"Needs you",children:s.jsxs(G,{children:[k!=null&&k.paused?s.jsxs(K,{tone:"warning",title:"The installation is paused.",children:["Nothing is being claimed until you resume it."," ",s.jsx(P,{size:"sm",onClick:()=>{R.setPaused(!1).then(()=>o.reload())},children:"Resume"})]}):null,C.map(H=>s.jsx(Tm,{action:H,timezone:e,busy:j===H.id,onDecide:m,agentName:S(H.agentId)},H.id)),O.length>0?s.jsx(rt,{flush:!0,children:s.jsx(Ht,{children:O.map(H=>s.jsx(rn,{href:H.link??void 0,onClick:H.link?()=>{R.notificationSeen(H.id).catch(()=>{}),t(H.link)}:void 0,lead:H.agentId?s.jsx(Xt,{agents:n,id:H.agentId,size:"sm"}):void 0,title:H.title,sub:H.agentId?S(H.agentId):H.pluginId??dL[H.kind],side:H.state==="held"?"today":Ce(H.createdAt)},H.id))})}):null,T>0?s.jsx(K,{tone:"critical",children:s.jsxs("a",{href:`${Ze}/jobs?state=failed`,onClick:N(`${Ze}/jobs?state=failed`),children:[T," failed job",T===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,E>0?s.jsx(K,{tone:"critical",children:s.jsxs("a",{href:`${Ze}/alerts`,onClick:N(`${Ze}/alerts`),children:[E," urgent alert",E===1?"":"s"," from your watchers."]})}):null,F.map(H=>s.jsx(rt,{children:s.jsx(Pm,{plugin:H.plugin,agent:H.agent,text:H.text,label:`Create @${H.handle}`,handle:H.handle,onDismiss:()=>{R.dismissAgentOffer(H.plugin,H.agent).then(()=>x.reload())}})},`${H.plugin}/${H.agent}`)),_>0?s.jsx(K,{tone:"accent",children:s.jsxs("a",{href:st("proposals"),onClick:N(st("proposals")),children:[_," proposal",_===1?"":"s"," from your agents to keep or discard."]})}):null,(((Te=k==null?void 0:k.sentinels)==null?void 0:Te.errors)??[]).map(H=>s.jsxs(K,{tone:"warning",children:["Watcher ",H.sentinelId," failed: ",H.error]},H.sentinelId)),((k==null?void 0:k.mail)??[]).filter(H=>H.lastError).map(H=>s.jsxs(K,{tone:"warning",children:["Source ",H.sourceId,": ",H.lastError]},H.sourceId))]})}):null,s.jsx(Y,{title:"Your team",aside:s.jsx("a",{href:et,onClick:N(et),children:"All agents"}),children:n.length===0?s.jsx(le,{mascot:!0,children:"No agents yet. Add one under Agents."}):s.jsx("div",{className:"home-team",children:b.map(H=>{const me=fu(i.get(H.id));return s.jsxs("a",{className:"home-face",...bo(wo(H)),href:Fe(H.id),onClick:N(Fe(H.id)),"data-waiting":me?"true":void 0,"data-unavailable":H.available?void 0:"true",children:[s.jsx(os,{id:H.id,name:H.name,size:"lg",unavailable:!H.available,face:H}),s.jsxs("span",{className:"home-face-text",children:[s.jsx("span",{className:"home-face-name",children:H.name}),s.jsx("span",{className:"home-face-status",children:me?oS(me):H.available?Es(H.description,60):H.unavailableReason??"Cannot run right now."})]})]},H.id)})})}),M.length>0?s.jsx(Y,{title:"On offer",aside:s.jsxs("span",{className:"ui-row",children:[z>0?s.jsxs("a",{href:`${et}?tab=offers`,onClick:N(`${et}?tab=offers`),children:[z," more"]}):null,s.jsx(Qk,{ids:V.map(H=>H.id),onDone:()=>d.reload()})]}),children:s.jsx("div",{className:"home-offers",children:M.map(H=>s.jsx(mL,{offer:H,agents:n,open:N(ht(H.agentId,"offers")),onDismissed:()=>d.reload()},H.id))})}):null,(it=(Ve=h.data)==null?void 0:Ve.digest)!=null&&it.latest?s.jsx(yL,{digest:h.data.digest.latest,go:N}):null,s.jsxs("div",{className:"home-columns",children:[s.jsx(Y,{title:"Coming up",aside:s.jsx("a",{href:`${et}?tab=missions`,onClick:N(`${et}?tab=missions`),children:"All missions"}),children:s.jsx(rt,{flush:!0,children:D.length===0?s.jsx(le,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):s.jsx(Ht,{children:D.map(H=>s.jsx(rn,{href:H.route,onClick:()=>t(H.route),lead:s.jsx(Xt,{agents:n,id:H.agentId,size:"sm"}),title:H.title,sub:`${H.kind} for ${S(H.agentId)}`,side:Ce(H.at)},H.key))})})}),s.jsx(Y,{title:"Lately",aside:s.jsx("a",{href:Ze,onClick:N(Ze),children:"All activity"}),children:s.jsx(rt,{flush:!0,children:q.length===0?s.jsx(le,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):s.jsx(Ht,{children:q.map(H=>s.jsx(rn,{href:Fe(H.agentId,H.id),onClick:()=>t(Fe(H.agentId,H.id)),lead:s.jsx(Xt,{agents:n,id:H.agentId,size:"sm"}),title:H.opening?Es(H.opening,80):"Untitled conversation",sub:`${S(H.agentId)}, ${H.messageCount} message${H.messageCount===1?"":"s"}`,side:Ce(H.lastMessageAt??H.createdAt)},H.id))})})})]}),((k==null?void 0:k.home)??[]).map(H=>s.jsx(bL,{block:H},H.id)),k!=null&&k.jobs&&k.missions?s.jsxs("p",{className:"home-foot muted",children:[Dt(k.jobs.pending??0)," queued, ",Dt(k.jobs.leased??0)," running, ",Dt(k.missions.enabled)," of ",Dt(k.missions.total)," missions on."," ",k.paused?s.jsx(pe,{tone:"warning",children:"paused"}):s.jsx(pe,{tone:"good",children:"running"})," ",s.jsx("a",{href:Ui("").replace(/\/conversations\/$/,""),onClick:N(Ze),children:"Activity"})," · ",s.jsx("a",{href:st("system"),onClick:N(st("system")),children:"System"})]}):null]})]})}const uL=new Set(["watcher","reminder","failure","recap","plugin"]),dL={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin"};function fL(e,t){const n=new Set(t.map(r=>r.id));return e.filter(r=>uL.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&n.has(r.actionId)))}const hL=6,pL=500;function mL({offer:e,agents:t,open:n,onDismissed:r}){const[i,l]=f.useState(!1),o=f.useRef(null),a=f.useRef(!1),c=()=>{i||(l(!0),R.dismissOffer(e.id).then(r).finally(()=>l(!1)))},u=()=>{o.current!==null&&clearTimeout(o.current),o.current=null};return s.jsxs("span",{className:"home-offer-chip",children:[s.jsxs("a",{className:"home-offer",href:ht(e.agentId,"offers"),onClick:p=>{if(a.current){a.current=!1,p.preventDefault();return}n(p)},title:e.prompt,onTouchStart:()=>{a.current=!1,u(),o.current=setTimeout(()=>{a.current=!0,c()},pL)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[s.jsx(Xt,{agents:t,id:e.agentId,size:"sm"}),s.jsx("span",{children:e.label})]}),s.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function gL(e,t){const n=[];for(const r of e)r.enabled&&r.nextRun&&n.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:ht(r.agentId,"missions")});for(const r of t)r.state==="pending"&&n.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:ht(r.agentId,"reminders")});return n.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function xL(e,t){try{const n=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(n)}catch{return new Date().getHours()}}function vL(e,t,n){const r=xL(e,t),i=n!=null&&n.trim()?`, ${n.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function jL(e,t){try{const n=e?new Date(e):new Date,r=new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:t}).format(n),i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",timeZone:t}).format(n);return`${r}, ${i}`}catch{return Ie(e??null,t)}}function ma(e,t,n){return e.count===0?null:`${e.count} ${e.count===1?t:n}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function yL({digest:e,go:t}){const n=[ma(e.memory,"memory note","memory notes"),ma(e.skills,"skill kept","skills kept"),ma(e.rules,"rule kept","rules kept"),ma(e.changes,"change to an agent kept","changes to agents kept")].filter(i=>i!==null),r=e.stopped===null?"Not measured yet.":e.stopped.total>0?`Rules you kept acted ${e.stopped.total} time${e.stopped.total===1?"":"s"} (${Object.entries(e.stopped.byPlugin).filter(([,i])=>i>0).map(([i,l])=>`${i} ${l}`).join(", ")}).`:"No rule you kept acted this week.";return s.jsx(Y,{title:"What buddi learned this week",aside:s.jsx("span",{className:"muted",children:Ce(e.at)}),children:s.jsx(rt,{children:s.jsxs(G,{divided:!0,children:[s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Learned"}),n.length===0?s.jsx("p",{children:"Nothing new."}):s.jsx("ul",{className:"home-digest-list",children:n.map(i=>s.jsx("li",{children:i},i))})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Proposes"}),s.jsx("p",{children:e.open>0?s.jsxs("a",{href:st("proposals"),onClick:t(st("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),s.jsx("p",{children:r})]})]})})})}function wL(e,t,n,r,i,l=0,o=0,a=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`),n>0&&c.push(`${n} failed job${n===1?"":"s"}`),r>0&&c.push(`${r} urgent alert${r===1?"":"s"}`),i&&c.push("the installation is paused"),l>0&&c.push(`${l} proposal${l===1?"":"s"} to review`),o>0&&c.push(`${o===1?"an agent":`${o} agents`} to set up`),a>0&&c.push(`${a} message${a===1?"":"s"} for you`);const u=c.length<=1?c.join(""):`${c.slice(0,-1).join(", ")} and ${c[c.length-1]}`;return`${oS(u)}.`}function oS(e){return e.charAt(0).toUpperCase()+e.slice(1)}function bL({block:e}){const[t,n]=f.useState(!1),r=e.sensitive===!0&&!t;f.useEffect(()=>{if(!e.sensitive||!t)return;const l=()=>{document.visibilityState==="hidden"&&n(!1)};return document.addEventListener("visibilitychange",l),window.addEventListener("blur",l),()=>{document.removeEventListener("visibilitychange",l),window.removeEventListener("blur",l)}},[e.sensitive,t]);const i=s.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?s.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?s.jsx(P,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>n(l=>!l),children:r?"Show":"Hide"}):null]});return s.jsxs(Y,{title:e.title,aside:i,children:[e.note?s.jsx(K,{tone:"warning",children:e.note}):null,e.stats.length>0?s.jsx(pu,{children:e.stats.map(l=>s.jsx(Xn,{label:l.label,value:r?"••••":l.value,note:r?void 0:l.note,tone:r?void 0:l.tone},l.label))}):null,e.rows.length>0?r?s.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):s.jsx(rt,{flush:!0,children:s.jsx(Ht,{children:e.rows.map((l,o)=>s.jsx(rn,{title:l.title,sub:l.sub,side:l.side?s.jsx("span",{className:l.tone==="critical"?"critical":l.tone==="good"?"good":void 0,children:l.side}):void 0},`${l.title}-${o}`))})}):null]})}const aS="(max-width: 900px)";function Th(e){const[t,n]=f.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return f.useEffect(()=>{var l;let r;try{r=window.matchMedia(e)}catch{return}const i=o=>n(o.matches);return(l=r.addEventListener)==null||l.call(r,"change",i),()=>{var o;return(o=r.removeEventListener)==null?void 0:o.call(r,"change",i)}},[e]),t}const kL=3e4;function cS(){const{data:e,reload:t}=se(()=>R.recovery(),[],kL);return{data:e,reload:t}}const SL="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function NL({active:e,onNavigate:t}){return e?s.jsxs("div",{className:"recovery-banner",role:"status",children:[s.jsx("span",{children:SL}),s.jsx("a",{href:av,onClick:n=>{n.preventDefault(),t(av)},children:"Finish the checklist"})]}):null}function CL({view:e,onLeft:t}){const{secrets:n,plugins:r,pending:i,grants:l}=e.checklist,[o,a]=f.useState(!0),[c,u]=f.useState([]),[p,d]=f.useState(!1),[h,x]=f.useState(null),[v,w]=f.useState(!1),b=r.filter(m=>!m.installed),j=i.jobs+i.missions+i.approvals+i.telegramChats,g=m=>{u(k=>k.includes(m)?k.filter(S=>S!==m):[...k,m])},y=()=>{d(!0),x(null),R.leaveRecovery({dropPending:o,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(m=>x(m instanceof de?m.message:String(m))).finally(()=>d(!1))};return s.jsx(rt,{title:"Back from a backup",children:s.jsxs(G,{divided:!0,children:[s.jsxs(Y,{children:[s.jsx(At,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:s.jsx("span",{className:"mono",children:e.archive??"—"})}]}),s.jsx("p",{className:"ui-card-meta",children:"Nothing runs on its own yet: no schedules, no watchers, no phone. Chat works. Go through what is below, then turn this buddi back on."})]}),s.jsx(Y,{title:"Keys to paste again",children:n.length===0?s.jsx(le,{children:"Nothing is missing."}):s.jsx("ul",{className:"recovery-list",children:n.map(m=>s.jsxs("li",{children:[m.settingsRoute?s.jsx("a",{href:m.settingsRoute,children:m.name}):m.name," ",s.jsx("span",{className:"ui-card-meta",children:m.kind})]},`${m.kind}:${m.name}`))})}),s.jsx(Y,{title:"Add-ons to install again",children:b.length===0?s.jsx(le,{children:"Everything the backup named is installed."}):s.jsx("ul",{className:"recovery-list",children:b.map(m=>s.jsxs("li",{children:[s.jsx("span",{className:"mono",children:m.name})," ",m.version," ",s.jsx("span",{className:"ui-card-meta",children:m.source})]},m.name))})}),s.jsx(Y,{title:"Work that was waiting",children:j===0?s.jsx(le,{children:"Nothing was in flight when the backup was taken."}):s.jsxs(G,{gap:"sm",children:[s.jsx(At,{items:[{label:"Jobs",value:String(i.jobs)},{label:"Missions",value:String(i.missions)},{label:"Waiting for an answer",value:String(i.approvals)},{label:"Phones",value:String(i.telegramChats)}]}),s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:o,onChange:m=>a(m.target.checked)}),s.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),s.jsx(Y,{title:"Standing permissions",children:l.length===0?s.jsx(le,{children:"No agent had a standing permission."}):s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),s.jsx("ul",{className:"recovery-list",children:l.map(m=>s.jsx("li",{children:s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:c.includes(m.id),onChange:()=>g(m.id),"aria-label":`Keep ${m.tool} for ${m.agent}`}),s.jsxs("span",{children:[s.jsx("span",{className:"mono",children:m.tool})," for ",m.agent," ",s.jsx("span",{className:"ui-card-meta",children:m.scope}),m.description?s.jsxs("span",{className:"ui-card-meta",children:[" — ",m.description]}):null]})]})},m.id))})]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:h}),v?s.jsx(K,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):s.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:p||v,onClick:y,children:"Leave recovery mode"})})]})})]})})}const EL=2e3,AL={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 Jv(e){return AL[e.phase]??e.detail??e.phase}const RL=new Set(["done","failed","rolled-back"]);function uS(e){return e!==void 0&&(RL.has(e.phase)||!!e.finishedAt)}function TL(e){const[t,n]=f.useState(void 0),[r,i]=f.useState(!1),[l,o]=f.useState(null),a=f.useRef(!1);return f.useEffect(()=>{if(!e){n(void 0),i(!1),a.current=!1;return}let c=!1;const u=()=>{R.backupJob(e).then(d=>{if(!c){if(a.current){window.location.reload();return}n(d),o(null),uS(d)&&(c=!0)}}).catch(d=>{if(!c){if(d instanceof de&&d.status!==0&&d.status<500){o(d.message);return}a.current=!0,i(!0)}})};u();const p=window.setInterval(u,EL);return()=>{c=!0,window.clearInterval(p)}},[e]),{job:t,away:r,error:l}}function PL({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.jsx(K,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="rolled-back"||e.phase==="failed"?s.jsxs(K,{tone:"critical",role:"alert",children:[Jv(e)," ",e.error??""]}):s.jsxs(K,{tone:e.phase==="done"?"good":void 0,role:"status",children:[Jv(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function IL(){var b,j,g,y,m,k,S;const e=se(()=>R.backups(),[],3e4),t=cS(),n=se(()=>R.service(),[]),[r,i]=f.useState(null),l=TL(r),[o,a]=f.useState(null),[c,u]=f.useState(!1),[p,d]=f.useState(null),h=((b=e.data)==null?void 0:b.supervised)??((j=n.data)==null?void 0:j.supervised),x=p!==null||h===!1,v=((g=e.data)==null?void 0:g.archives)??[],w=N=>{u(!0),a(null),N.then(C=>{var T;return i(((T=C.job)==null?void 0:T.id)??null)}).catch(C=>{C instanceof de&&C.status===409?d(C.message):a(C instanceof de?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return f.useEffect(()=>{uS(l.job)&&e.reload()},[(y=l.job)==null?void 0:y.phase]),s.jsxs(G,{gap:"lg",children:[(m=t.data)!=null&&m.active?s.jsx(CL,{view:t.data,onLeft:t.reload}):null,s.jsx(re,{message:e.error??o}),s.jsx(PL,{...l}),s.jsx($L,{onSaved:()=>e.reload()}),s.jsx(Y,{title:"Backups",panel:!0,actions:s.jsx(P,{variant:"accent",size:"sm",disabled:c,onClick:()=>w(R.startBackup(!0)),children:"Back up now"}),children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs("p",{className:"ui-card-meta",children:["Kept in ",s.jsx("span",{className:"mono",children:((k=e.data)==null?void 0:k.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),s.jsx(Y,{children:e.data&&v.length===0?s.jsx(wt,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?s.jsxs(on,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Taken"}),s.jsx("th",{children:"Size"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:v.map(N=>{var C;return s.jsx(_L,{archive:N,busy:c,database:(C=e.data)==null?void 0:C.database,checkout:x,onVerify:()=>w(R.verifyArchive(N.name)),onRestore:(T,E)=>w(R.restoreArchive({name:N.name,...T?{passphrase:T}:{},...E?{confirm:E}:{}}))},N.name)})})]}):s.jsx(le,{children:"Loading…"})})]})}),s.jsx(OL,{}),s.jsx(DL,{busy:c,checkout:x,checkoutSaid:p,database:(S=e.data)==null?void 0:S.database,onRestore:(N,C,T)=>w(R.restoreUpload(N,{passphrase:C,confirm:T}))})]})}const ML={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function $L({onSaved:e}){var x;const t=se(()=>R.backupSchedule(),[]),[n,r]=f.useState(null),[i,l]=f.useState(!1),[o,a]=f.useState(null),[c,u]=f.useState(!1);f.useEffect(()=>{t.data&&r(t.data)},[t.data]);const p={...ML,...n??t.data??{}};if(((x=t.data)==null?void 0:x.supervised)===!1)return s.jsx(Y,{title:"Every night",panel:!0,children:s.jsx(Y,{children:s.jsx(K,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const d=v=>{u(!1),r({...p,...v})},h=()=>{l(!0),a(null),R.setBackupSchedule(p).then(v=>{r(v),u(!0),e()}).catch(v=>a(v instanceof de?v.message:String(v))).finally(()=>l(!1))};return s.jsx(Y,{title:"Every night",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:i,onClick:h,children:"Save"}),children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:o}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:p.enabled,onChange:v=>d({enabled:v.target.checked})}),s.jsx("span",{children:"Back this buddi up on its own"})]}),s.jsxs(As,{children:[s.jsx(te,{label:"At",children:s.jsx("input",{type:"time",value:p.time,onChange:v=>d({time:v.target.value})})}),s.jsx(te,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:s.jsx("input",{type:"number",min:1,max:365,value:p.keep,onChange:v=>d({keep:Number(v.target.value)||1})})})]}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:p.encryptLocal,onChange:v=>d({encryptLocal:v.target.checked})}),s.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(te,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:s.jsx("input",{type:"text",value:p.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:v=>d({copyTo:v.target.value===""?null:v.target.value})})}),c?s.jsxs(K,{tone:"good",role:"status",children:["Saved.",p.lastRunAt?` Last run ${Ce(p.lastRunAt)}.`:""]}):null]})})]})})}function _L({archive:e,busy:t,database:n,checkout:r,onVerify:i,onRestore:l}){const[o,a]=f.useState(!1),[c,u]=f.useState(""),[p,d]=f.useState("");return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:e.name}),s.jsx("td",{children:Ce(e.createdAt)}),s.jsx("td",{children:Rn(e.bytes)}),s.jsxs("td",{children:[e.encrypted?s.jsx(pe,{tone:"good",children:"locked"}):s.jsx(pe,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?s.jsx(pe,{tone:"critical",children:"damaged"}):null]}),s.jsx("td",{children:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",disabled:t,onClick:i,children:"Verify"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>a(!o),children:"Restore…"})]})})]}),o?s.jsx("tr",{children:s.jsx("td",{colSpan:5,children:r?s.jsx(K,{tone:"warning",children:dS}):s.jsx(fS,{what:`${e.name}, taken ${Ce(e.createdAt)}, ${Rn(e.bytes)}`,database:n,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:p,onConfirm:d,busy:t,onCancel:()=>a(!1),onGo:()=>l(c,p)})})}):null]})}const dS="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function fS({what:e,database:t,needsPassphrase:n,passphrase:r,onPassphrase:i,confirm:l,onConfirm:o,busy:a,onCancel:c,onGo:u}){const p=t??"",d=p===""?l.trim()!=="":l.trim()===p;return s.jsxs(G,{gap:"sm",children:[s.jsxs(K,{tone:"warning",children:["This replaces everything in this buddi with ",e,". What is here now is copied first, so a restore that fails puts it back."]}),n?s.jsx(te,{label:"The passphrase this one was locked with",children:s.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:h=>i(h.target.value)})}):null,s.jsx(te,{label:p?`Type ${p} to confirm`:"Type the name of this database to confirm",hint:p?void 0:"The same name buddi shows on the System tab.",children:s.jsx("input",{value:l,onChange:h=>o(h.target.value)})}),s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(P,{variant:"danger",disabled:a||!d||n&&r==="",onClick:u,children:"Restore"})]})]})}function OL(){const[e,t]=f.useState(null),[n,r]=f.useState(""),[i,l]=f.useState(!1),[o,a]=f.useState(null),[c,u]=f.useState(!1),p=()=>{l(!0),a(null),R.backupPassphrase().then(h=>t(h.passphrase)).catch(h=>a(h instanceof de?h.message:String(h))).finally(()=>l(!1))},d=()=>{l(!0),a(null),R.setBackupPassphrase(n.trim()).then(h=>{t(h.passphrase),r(""),u(!0)}).catch(h=>a(h instanceof de?h.message:String(h))).finally(()=>l(!1))};return s.jsx(Y,{title:"The passphrase",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:o}),s.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?s.jsx("p",{className:"backup-phrase mono",children:e}):s.jsx(J,{align:"end",children:s.jsx(P,{disabled:i,onClick:p,children:"Show it"})}),c?s.jsx(K,{tone:"good",role:"status",children:"Saved. Backups made from now on use it; older ones keep the one they were made with."}):null]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(te,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:s.jsx("input",{type:"text",autoComplete:"off",value:n,onChange:h=>{u(!1),r(h.target.value)}})}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:i||n.trim()==="",onClick:d,children:"Use this one"})})]})})]})})}function DL({busy:e,checkout:t,checkoutSaid:n,database:r,onRestore:i}){const[l,o]=f.useState(null),[a,c]=f.useState(""),[u,p]=f.useState(""),[d,h]=f.useState(!1);return t?s.jsx(Y,{title:"Restore from a file",panel:!0,children:s.jsx(Y,{children:s.jsx(K,{tone:"warning",children:n??dS})})}):s.jsx(Y,{title:"Restore from a file",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),s.jsxs(As,{children:[s.jsx(te,{label:"The backup file",children:s.jsx("input",{type:"file",onChange:x=>{var v;h(!1),o(((v=x.target.files)==null?void 0:v[0])??null)}})}),s.jsx(te,{label:"Its passphrase",hint:"Only if it was locked with one.",children:s.jsx("input",{type:"password",autoComplete:"off",value:a,onChange:x=>c(x.target.value)})})]}),d?null:s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||!l,onClick:()=>h(!0),children:"Restore"})})]})}),d&&l?s.jsx(Y,{children:s.jsx(fS,{what:`${l.name}, ${Rn(l.size)}`,database:r,needsPassphrase:!1,passphrase:a,onPassphrase:c,confirm:u,onConfirm:p,busy:e,onCancel:()=>h(!1),onGo:()=>i(l,a,u)})}):null]})})}function LL({embedded:e}={}){const{data:t,error:n,reload:r,loading:i}=se(()=>R.providerAccounts(),[]),[l,o]=f.useState(!1),[a,c]=f.useState(null),[u,p]=f.useState(""),[d,h]=f.useState(!1),[x,v]=f.useState(!1),[w,b]=f.useState(null),j=t==null?void 0:t.accounts.some(k=>{var S;return((S=k.login)==null?void 0:S.state)==="pending"&&k.login.expiresAt&&Date.parse(k.login.expiresAt)>Date.now()});f.useEffect(()=>{if(!j)return;const k=setInterval(r,2e3);return()=>clearInterval(k)},[j,r]);const g=async(k,S)=>{o(!0),c(null),p(""),v(!1);try{const N=await k();return p((N==null?void 0:N.warning)??S),r(),!0}catch(N){return c(N instanceof Error?N.message:"Could not apply change."),r(),!1}finally{o(!1)}},y=(t==null?void 0:t.accounts)??[],m=y.find(k=>k.id===w)??y[0];return s.jsxs(an,{embedded:e,title:"Model accounts",lede:"Give each API key or subscription a name, then pick one per agent. An account never falls back to another credential on its own.",children:[s.jsx(re,{message:n??a}),u&&s.jsx(K,{tone:"good",role:"status",children:u}),x&&s.jsx(K,{role:"status",children:i?"Refreshing account status…":n?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!t&&!n&&s.jsx(le,{children:"Loading accounts…"}),n&&s.jsx(J,{children:s.jsx(P,{onClick:r,children:"Retry"})}),t&&s.jsxs(s.Fragment,{children:[(t.vault.locked||t.vault.kind==="none")&&s.jsx(K,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),d&&s.jsx(Yt,{title:"Add an account",onClose:()=>h(!1),children:s.jsx("div",{id:"new-provider-account",children:s.jsx(VL,{accounts:y,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:l,run:g,onDone:k=>{h(!1),k&&b(k)}})})}),s.jsx(Y,{title:"Accounts",aside:`Secrets live in the ${FL(t.vault.kind)}; Postgres holds names and assignments only.`,actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",size:"sm",disabled:l||i,onClick:()=>{c(null),p(""),v(!0),r()},children:i?"Refreshing…":"Refresh status"}),s.jsx(P,{variant:"accent",size:"sm",disabled:l,"aria-expanded":d,"aria-controls":"new-provider-account",onClick:()=>h(!d),children:"Add account"})]}),panel:!0,flush:!0,children:y.length===0?s.jsx(wt,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):s.jsxs("div",{className:"accounts",children:[s.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:y.map(k=>s.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(m==null?void 0:m.id)===k.id,onClick:()=>b(k.id),children:[s.jsx(UL,{kind:k.kind,auth:k.auth}),s.jsxs("span",{className:"accounts-row-text",children:[s.jsx("span",{className:"accounts-row-name",children:k.label}),s.jsxs("span",{className:"accounts-row-sub",children:[Lm(k)," · ",k.assignedAgents.length===0?"no agents":`${k.assignedAgents.length} agent${k.assignedAgents.length===1?"":"s"}`]})]}),s.jsx(hS,{account:k})]},k.id))}),m?s.jsx(zL,{account:m,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:l,run:g},`${m.id}:${m.revision}`):null]})})]})]})}function FL(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function Lm(e){return e.kind==="codex"?"ChatGPT subscription":e.kind==="anthropic"?e.auth==="anthropic-oauth"?"Claude subscription":e.auth==="legacy-subscription-token"?"Claude setup token":"Anthropic API":e.kind==="openai"?"OpenAI API":"OpenAI-compatible"}function UL({kind:e,auth:t}){const n=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return s.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:n})}function BL(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function hS({account:e}){const t=e.enabled?e.configured?"good":"warning":void 0,n=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return s.jsx(pe,{tone:t,children:n})}function pS(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 zL({account:e,busy:t,run:n,anthropicOAuthEnabled:r}){const[i,l]=f.useState(!1),[o,a]=f.useState(!1);return s.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:e.label}),s.jsx(hS,{account:e})]}),s.jsx(At,{items:[{label:"Provider",value:Lm(e)},{label:"Default model",value:s.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:s.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":" (detected)"}`})},...e.baseUrl?[{label:"Endpoint",value:s.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?s.jsx("span",{className:"ui-row",children:e.assignedAgents.map(c=>s.jsx("a",{href:ht(c,"setup","brain"),children:c},c))}):s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:"No agents"}),s.jsx("a",{href:et,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${new Date(e.tokenExpiresAt).toLocaleString()} (not your subscription renewal date)`}]:[]]}),e.removalPending&&s.jsx(K,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&s.jsx(K,{tone:"warning",children:"Token refresh did not finish. Reconnect this Claude account."}),e.auth==="anthropic-oauth"&&s.jsx(gS,{account:e,enabled:!!r,busy:t,run:n}),e.kind==="codex"&&s.jsx(mS,{account:e,busy:t,run:n}),s.jsxs(J,{children:[s.jsx(P,{disabled:t||e.removalPending,onClick:()=>l(!0),children:"Edit account"}),s.jsx(P,{disabled:t||e.removalPending,onClick:()=>void n(()=>R.saveProviderAccount({...pS(e),enabled:!e.enabled}),e.enabled?"Account disabled. Subsequent model calls will stop; already-sent requests cannot be recalled.":"Account enabled."),children:e.enabled?"Disable":"Enable"}),e.kind!=="codex"&&s.jsx(P,{disabled:t||!e.enabled||!e.configured,onClick:()=>void n(()=>R.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),s.jsx(P,{variant:"danger",disabled:t||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>a(!0),children:"Remove account"})]}),e.test&&s.jsxs(s.Fragment,{children:[s.jsxs(K,{role:"status",tone:BL(e.test.state),children:[s.jsx("p",{children:e.test.message}),e.test.retryAt?s.jsxs("p",{children:["Provider suggested retry time: ",new Date(e.test.retryAt).toLocaleString(),". This is retry advice, not a guaranteed quota reset."]}):["rate-limited","quota-exhausted"].includes(e.test.state)&&s.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),s.jsxs("p",{className:"muted",children:["Tested at ",new Date(e.test.checkedAt).toLocaleString(),e.test.httpStatus?` · HTTP ${e.test.httpStatus}`:"",". This is not a quota reset or subscription renewal date."]})]}),i&&s.jsx(Yt,{title:`Edit ${e.label}`,onClose:()=>l(!1),children:s.jsx(WL,{account:e,busy:t,run:n,onDone:()=>l(!1)})}),o&&s.jsxs(K,{tone:"critical",children:[s.jsxs("p",{children:["Remove “",e.label,"” and its stored credential from Buddi? This does not revoke it at the provider or remove it from backups."]}),s.jsxs(J,{children:[s.jsx(P,{variant:"danger",disabled:t,onClick:()=>void n(()=>R.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),s.jsx(P,{disabled:t,onClick:()=>a(!1),children:"Cancel"})]})]}),s.jsx(bt,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[e.auth==="legacy-subscription-token"&&s.jsx("p",{children:"Legacy subscription token: not refreshable, token expiry and subscription renewal date unknown."}),e.kind==="codex"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Experimental Codex App Server. Credentials stay in Buddi’s vault and are staged in a private temporary file during native sessions. Codex manages refresh. Subscription renewal date is unknown."}),s.jsx("p",{children:"Native tool-step usage reporting is incomplete. Do not use Buddi’s token or API-cost estimates as subscription billing or remaining quota."}),s.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):s.jsx("p",{children:"Testing sends a small fixed prompt and may incur a charge. No conversation or files are sent. Configured does not mean verified."}),e.auth==="anthropic-oauth"&&s.jsx("p",{children:"Experimental Claude subscription sign-in. Tokens remain in Buddi’s vault and refresh before use. Subscription renewal and remaining quota are unknown."}),s.jsx("p",{children:"Subscription login is separate from API-key access. Existing Claude setup tokens remain legacy accounts, without automatic refresh or a known expiry."})]})})]})}function mS({account:e,busy:t,run:n}){var r,i,l;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(P,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void n(()=>R.codexAccountAction(e.id,"login",e.revision),"Complete device sign-in below."),children:e.configured?"Reconnect ChatGPT":"Connect ChatGPT"}),((i=e.login)==null?void 0:i.state)==="pending"&&s.jsx(P,{disabled:t,onClick:()=>void n(()=>R.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),s.jsx(P,{disabled:t||!e.configured,onClick:()=>void n(()=>R.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((l=e.login)==null?void 0:l.state)==="pending"&&s.jsxs(K,{tone:"accent",role:"status",children:[s.jsxs("p",{children:["Open ",s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:e.login.verificationUrl})," and enter ",s.jsx("code",{children:e.login.userCode}),"."]}),s.jsxs("p",{className:"muted",children:["Buddi stops waiting at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),". This is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&s.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function WL({account:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:l}){const[o,a]=f.useState((e==null?void 0:e.label)??""),[c,u]=f.useState((e==null?void 0:e.kind)??"anthropic"),[p,d]=f.useState((e==null?void 0:e.auth)??"api-key"),[h,x]=f.useState((e==null?void 0:e.baseUrl)??""),[v,w]=f.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[b,j]=f.useState(""),[g,y]=f.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),m=S=>{u(S),d(S==="codex"?"chatgpt":"api-key"),j(""),x(S==="openai-compatible"?"http://localhost:11434/v1":""),w(S==="anthropic"?"claude-sonnet-5":S==="openai"?"gpt-5":"")},k=!o.trim()||!v.trim();return s.jsxs("form",{className:"ui-stack",onSubmit:S=>{S.preventDefault();const N=b;j(""),n(()=>R.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:o,kind:c,auth:p,baseUrl:h,defaultModel:v,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:g.trim()?Number(g):null,...N.trim()?{secret:N}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(te,{label:"Account name",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:o,onChange:S=>a(S.target.value),placeholder:"Anthropic — Personal"})}),s.jsx(te,{label:"Provider",children:s.jsxs("select",{disabled:!!e,value:p==="anthropic-oauth"?"anthropic-oauth":c,onChange:S=>{S.target.value==="anthropic-oauth"?(m("anthropic"),d("anthropic-oauth")):m(S.target.value)},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(l||(e==null?void 0:e.auth)==="anthropic-oauth")&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription (experimental)"}),(i||(e==null?void 0:e.kind)==="codex")&&s.jsx("option",{value:"codex",children:"ChatGPT subscription via Codex (experimental)"})]})}),c==="openai-compatible"&&s.jsxs(s.Fragment,{children:[s.jsx(te,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:h,onChange:S=>x(S.target.value)})}),s.jsx(te,{label:"Authentication",children:s.jsxs("select",{disabled:!!e,value:p,onChange:S=>{d(S.target.value),j("")},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),s.jsx(J,{valign:"end",children:s.jsx(Dm,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:v,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),s.jsx(te,{label:"Context window",hint:"Tokens this endpoint actually serves. Leave blank unless you run the model yourself and set a window of your own — a conversation is ended once its history would fill half of this.",children:s.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:g,placeholder:e!=null&&e.detectedContextWindowTokens?String(e.detectedContextWindowTokens):"detected from the model",onChange:S=>y(S.target.value)})}),c==="codex"&&s.jsx("p",{className:"muted",children:"Enter a model available to your Codex subscription. API model availability is different; there is no automatic model fallback."}),p==="anthropic-oauth"&&s.jsx("p",{className:"muted",children:"Save this account, then choose Connect Claude. You will approve in your browser and paste the authorization code here, not in chat. No existing agent assignment changes."}),p==="api-key"&&s.jsx(te,{label:e?"Replacement API key (leave blank to keep)":"API key",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:b,onChange:S=>j(S.target.value)})}),e&&s.jsx("p",{className:"muted",children:"Saving changes stops an active run at its next model call. Start a new turn afterward. Changing the default model does not change existing agent assignments."}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:r,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:k,children:"Save account"})]})]}),k&&s.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function gS({account:e,enabled:t,busy:n,run:r}){var o,a,c,u,p;const[i,l]=f.useState("");return f.useEffect(()=>{l("")},[(o=e.login)==null?void 0:o.attemptId,(a=e.login)==null?void 0:a.state]),s.jsxs(s.Fragment,{children:[!t&&s.jsx(K,{tone:"warning",children:"Claude OAuth is disabled on this host."}),s.jsxs(J,{children:[s.jsx(P,{disabled:n||!t||!e.enabled||e.removalPending||((c=e.login)==null?void 0:c.state)==="pending",onClick:()=>void r(()=>R.anthropicAccountAction(e.id,"login",e.revision),"Open the Claude consent link below. Existing credentials remain until sign-in succeeds."),children:e.configured?"Reconnect Claude":"Connect Claude"}),((u=e.login)==null?void 0:u.state)==="pending"&&s.jsx(P,{disabled:n,onClick:()=>{l(""),r(()=>R.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),s.jsx(P,{disabled:n||!e.configured||e.removalPending,onClick:()=>{l(""),r(()=>R.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((p=e.login)==null?void 0:p.state)==="pending"&&s.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:d=>{d.preventDefault();const h=i;l(""),r(()=>R.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:h}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[s.jsx("p",{children:s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),s.jsxs("p",{className:"muted",children:["Use the Claude account you want to connect. Paste the entire code including #state. This attempt expires at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),"; restarting Buddi also ends it."]}),s.jsx(te,{label:"Claude authorization code",children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:d=>l(d.target.value),disabled:n})}),s.jsx(J,{align:"end",children:s.jsx(P,{type:"submit",variant:"accent",disabled:n||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const Ld={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5"};function Xv(e,t,n){const r=e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":"Local endpoint",i=new Set(n.map(l=>l.trim().toLowerCase()));if(!i.has(r.toLowerCase()))return r;for(let l=2;l<100;l+=1)if(!i.has(`${r} ${l}`.toLowerCase()))return`${r} ${l}`;return r}function VL({accounts:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:l}){const o=e.map(Z=>Z.label),[a,c]=f.useState(null),[u,p]=f.useState("anthropic"),[d,h]=f.useState("api-key"),[x,v]=f.useState(()=>Xv("anthropic","api-key",o)),[w,b]=f.useState(!1),[j,g]=f.useState(""),[y,m]=f.useState(""),[k,S]=f.useState(null),[N,C]=f.useState(!1),[T,E]=f.useState(""),[_,F]=f.useState(""),[O,A]=f.useState(!1),D=(Z,fe)=>{p(Z),h(fe),m(""),S(null),E(""),F(""),A(!1),g(Z==="openai-compatible"?"http://localhost:11434/v1":""),w||v(Xv(Z,fe,o))},q=a?e.find(Z=>Z.id===a):void 0;if(a)return q?s.jsx(HL,{account:q,busy:t,run:n,anthropicOAuthEnabled:l,onDone:()=>r(q.id)}):s.jsx(le,{children:"Saving…"});const V=u==="openai-compatible",M=u==="codex"||d==="anthropic-oauth",z=!M&&(d==="none"||y.trim()!=="")&&(!V||j.trim()!==""),$=async()=>{var Z,fe;C(!0),E("");try{const ve=await R.probeModels({kind:u,auth:d,...V?{baseUrl:j}:{},...y.trim()?{secret:y}:{}});S(ve),_||F(((Z=ve.models.find(Ne=>Ne.isDefault))==null?void 0:Z.id)??((fe=ve.models[0])==null?void 0:fe.id)??"")}catch(ve){E(ve instanceof Error?ve.message:"Could not load models. You can still enter a custom model.")}finally{C(!1)}},U=_.trim(),X=!x.trim()||V&&!j.trim()||V&&!U;return s.jsxs("form",{className:"ui-stack",onSubmit:Z=>{Z.preventDefault();const fe=y;m("");const ve=U||Ld[u]||"claude-sonnet-5";(async()=>{let Ne;!await n(async()=>(Ne=await R.saveProviderAccount({label:x,kind:u,auth:d,baseUrl:j,defaultModel:ve,enabled:!0,...fe.trim()?{secret:fe}:{}}),Ne),"Account saved.")||!Ne||(U||!M?r(Ne.id):c(Ne.id))})()},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(te,{label:"Provider",children:s.jsxs("select",{value:d==="anthropic-oauth"?"anthropic-oauth":u,onChange:Z=>{if(Z.target.value==="anthropic-oauth")D("anthropic","anthropic-oauth");else{const fe=Z.target.value;D(fe,fe==="codex"?"chatgpt":"api-key")}},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),l&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription (experimental)"}),i&&s.jsx("option",{value:"codex",children:"ChatGPT subscription via Codex (experimental)"})]})}),s.jsx(te,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:x,onChange:Z=>{v(Z.target.value),b(!0)},placeholder:"Anthropic — Personal"})}),V&&s.jsxs(s.Fragment,{children:[s.jsx(te,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:j,onChange:Z=>{g(Z.target.value),S(null)}})}),s.jsx(te,{label:"Authentication",children:s.jsxs("select",{value:d,onChange:Z=>{h(Z.target.value),m(""),S(null)},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),d==="api-key"&&s.jsx(te,{label:"API key",hint:"Stored in the vault, never shown again.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:y,onChange:Z=>{m(Z.target.value),S(null)}})}),M?s.jsx("p",{className:"muted",children:u==="codex"?"You will connect your ChatGPT subscription on the next step, with a device code, and pick a model then.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Model"}),k?s.jsxs("div",{className:"ui-row",children:[s.jsxs("select",{"aria-label":"Model",value:O?"__custom__":_,onChange:Z=>{Z.target.value==="__custom__"?(A(!0),F("")):(A(!1),F(Z.target.value))},children:[k.models.map(Z=>s.jsxs("option",{value:Z.id,children:[Z.name===Z.id?Z.id:`${Z.name} — ${Z.id}`,Z.isDefault?" (provider default)":"",Z.thinks?" · thinks":""]},Z.id)),s.jsx("option",{value:"__custom__",children:"Custom model…"})]}),s.jsx(P,{size:"sm",disabled:N||!z,onClick:()=>void $(),children:N?"Loading…":"Reload"})]}):s.jsxs("div",{className:"ui-row",children:[s.jsx(P,{disabled:N||!z,onClick:()=>void $(),children:N?"Loading models…":"Load models"}),V?s.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):s.jsxs("span",{className:"muted",children:["Optional now: ",Ld[u]," is used until you pick one."]})]}),O||V&&!k?s.jsx("input",{"aria-label":"Custom model",required:V,maxLength:150,value:_,onChange:Z=>F(Z.target.value),placeholder:V?"qwen3:8b":Ld[u]}):null,T?s.jsx("span",{className:"ui-field-hint critical",role:"alert",children:T}):null,k!=null&&k.truncated?s.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:()=>r(),children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:X,children:"Save account"})]})]}),X&&s.jsxs("p",{className:"muted",children:["Enter an account name",V?", an endpoint and a model":""," to enable Save account."]})]})}function HL({account:e,busy:t,run:n,anthropicOAuthEnabled:r,onDone:i}){const[l,o]=f.useState(e.defaultModel),a=e.configured;return s.jsxs(G,{gap:"lg",children:[s.jsxs(K,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!a?s.jsx(gS,{account:e,enabled:!!r,busy:t,run:n}):null,e.kind==="codex"&&!a?s.jsx(mS,{account:e,busy:t,run:n}):null,a?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-page-lede",children:"Pick the model this account offers by default. An agent can still choose another when you assign it."}),s.jsx(J,{valign:"end",children:s.jsx(Dm,{accountId:e.enabled?e.id:void 0,label:"Default model",value:l,onChange:o,disabled:t},`${e.id}:${e.revision}`)}),s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:i,children:"Skip for now"}),s.jsx(P,{variant:"accent",disabled:t||!l.trim(),onClick:()=>{if(l===e.defaultModel){i();return}n(()=>R.saveProviderAccount({...pS(e),defaultModel:l}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):s.jsx(J,{children:s.jsx(P,{onClick:i,children:"Finish later"})})]})}const Zv=["every-time","first-time","pre-approved"],xS={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function KL(e){const t=Zv.indexOf(e);return Zv.slice(0,t<0?1:t+1)}function vS(e){return e.endsWith(".account")}const GL="This account’s process holds the value for as long as its connection lives.",Fm="Stored, not usable until it has a binding.";function YL(e){return e==="browser.field"?"the exact origin — scheme, host and port — e.g. https://localhost:8443":e==="browser.form.data"?"the origin, then the field name — e.g. https://localhost:8443 card-number":e==="browser.native.type"?"the app’s bundle id, e.g. com.bank.app":e==="http.header"?"the host, then the header name — e.g. localhost:9200 Authorization":e==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":vS(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const jS={"browser.form.data":{hint:"an origin, then the field name",build:(e,t)=>({origin:e,field:t})},"http.header":{hint:"a host, then the header name",build:(e,t)=>({host:e,header:t})},"developer.env":{hint:"a workspace, then the variable name",build:(e,t)=>({workspace:e,variable:t})}};function qL(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const n=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&n?[r,n]:null}function yS(e,t){const n=t.trim();if(n==="")return{ok:!1,error:"Give the exact place this value may go."};if(n.startsWith("{"))try{const l=JSON.parse(n);return l!==null&&typeof l=="object"&&!Array.isArray(l)?{ok:!0,target:l}:{ok:!1,error:'A target in JSON is an object, like {"host":"localhost","header":"Authorization"}.'}}catch{return{ok:!1,error:"That opens like JSON but does not parse."}}if(e==="browser.field"||e==="browser.native.type"||vS(e))return{ok:!0,target:n};const r=jS[e];if(r===void 0)return{ok:!0,target:n};const i=qL(n);return i===null?{ok:!1,error:`${e} needs both: ${r.hint}.`}:{ok:!0,target:r.build(i[0],i[1])}}function QL(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function JL(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const n=t,r=jS[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),l=i.map(o=>n[o]);if(i.every(o=>typeof n[o]=="string"))return l.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const wS="accounts.provider";function XL(e,t){for(const n of e)if(n.kind===wS&&typeof n.target=="string"){const r=t.get(n.target);if(r)return r}}function Ph(e,t,n){if(e===wS&&typeof t=="string"){const r=n.get(t);if(r)return r.label}return JL(e,t)}function bS(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function kS(e,t){if(typeof e!="object"||e===null)return[];const n=e[t];return Array.isArray(n)?n.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,l=r.count;return typeof i!="string"||typeof l!="number"||!(l>0)?[]:[{place:i,count:l}]}):[]}function SS(e){const t=e.map(({place:n,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?n.replace(/s$/,""):n}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function ZL(e){const t=kS(e,"found");return t.length?`The value already sits in ${SS(t)}.`:""}function eF(e){const t=kS(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${SS(t)}.`:""}async function Br(e,t,n,r){n(!0),r(null);try{return(await R.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{n(!1)}}function tF({embedded:e,timezone:t}={}){const n=se(()=>R.secrets(),[]),r=se(()=>R.providerAccounts(),[]),i=f.useMemo(()=>{var c;return new Map((((c=r.data)==null?void 0:c.accounts)??[]).map(u=>[u.id,{label:u.label,provider:Lm(u)}]))},[r.data]),[l,o]=f.useState(!1),a=n.data;return s.jsxs(an,{embedded:e,title:"Keys and secrets",lede:"What the agents may use and never see: a name, a value buddi keeps, and the exact places the value may go.",children:[s.jsxs(G,{gap:"lg",children:[!a&&!n.error?s.jsx(le,{children:"Opening the vault…"}):null,n.error?s.jsx(J,{children:s.jsx(P,{onClick:n.reload,children:"Retry"})}):null,a?s.jsx(Y,{title:"Secrets",aside:"A value the agents use and never see: bound to where it may go, never shown again.",actions:s.jsx(P,{variant:"accent",size:"sm",onClick:()=>o(!0),children:"Add a secret"}),panel:!0,children:s.jsx(G,{divided:!0,children:a.secrets.length===0?s.jsx(wt,{icon:"key",title:"Nothing stored yet",children:"Add one — a site password, an API token — and bind it to the places an agent may use it."}):a.secrets.map(c=>s.jsx(nF,{secret:c,accounts:i,destinations:a.destinations,timezone:t,onChanged:n.reload},c.name))})}):null,a?s.jsx(Y,{title:"buddi’s own keys",aside:"Read-only.",children:s.jsxs(G,{gap:"sm",children:[a.ownKeys.length===0?s.jsx(le,{children:"No keys of buddi’s own right now."}):s.jsx("div",{className:"ui-list",children:a.ownKeys.map(c=>s.jsx("div",{className:"ui-list-row",children:s.jsx("span",{className:"ui-list-main",children:s.jsx("span",{className:"mono",children:c})})},c))}),s.jsx("p",{className:"ui-card-meta",children:"These are the keys buddi itself runs on. They cannot be bound or replaced here, and the scrubber replaces them in what buddi sends out, exactly like your own secrets."})]})}):null]}),l&&a?s.jsx(rF,{destinations:a.destinations,onClose:()=>o(!1),onChanged:n.reload}):null]})}function nF({secret:e,accounts:t,destinations:n,timezone:r,onChanged:i}){const[l,o]=f.useState(!1),[a,c]=f.useState(null),[u,p]=f.useState(null),[d,h]=f.useState(!1),[x,v]=f.useState(!1),w=async()=>{await Br("secrets.delete",{name:e.name},o,c)!==null&&(h(!1),i())},b=e.lastUse,j=XL(e.bindings,t);return s.jsxs(G,{gap:"sm",children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:j?j.label:e.name}),j?s.jsx(Ua,{children:j.provider}):null,e.totp?s.jsx(Ua,{children:"TOTP"}):null,b?s.jsx(pe,{tone:bS(b.outcome),children:b.outcome}):null]}),j?s.jsx("p",{className:"ui-card-meta mono",children:e.name}):null,e.bindings.length===0?s.jsx("p",{className:"ui-card-meta",children:Fm}):s.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((g,y)=>s.jsxs("div",{className:"ui-row",children:[s.jsx(Ua,{children:g.kind}),s.jsx("span",{className:"mono",children:Ph(g.kind,g.target,t)}),s.jsx(pe,{tone:"muted",children:xS[g.rule]??g.rule})]},y))}),e.bindings.some(g=>g.heldByPlugin)?s.jsx("p",{className:"ui-card-meta",children:GL}):null,s.jsx("p",{className:"ui-card-meta",children:b?`Last used ${Ce(b.at)}${b.agentId?` by ${b.agentId}`:""} — ${b.kind}, ${Ph(b.kind,b.target,t)}.`:"Never used."}),s.jsx(re,{message:a}),d?s.jsxs(K,{tone:"critical",role:"alert",children:[s.jsxs("p",{children:["Delete “",e.name,"”? The value and its bindings go; the use log stays, under the name."]}),s.jsxs(J,{children:[s.jsx(P,{variant:"danger",disabled:l,onClick:()=>void w(),children:"Delete it"}),s.jsx(P,{disabled:l,onClick:()=>h(!1),children:"Cancel"})]})]}):null,s.jsxs(J,{children:[s.jsx(P,{size:"sm",disabled:l,onClick:()=>p("replace"),children:"Replace value"}),s.jsx(P,{size:"sm",disabled:l,onClick:()=>p("rename"),children:"Rename"}),s.jsx(P,{size:"sm",disabled:l,onClick:()=>p("rebind"),children:e.bindings.length===0?"Add a binding":"Rebind"}),s.jsx(P,{size:"sm",variant:"danger",disabled:l,onClick:()=>h(!0),children:"Delete"}),s.jsx(P,{size:"sm",variant:"ghost","aria-expanded":x,onClick:()=>v(!x),children:"Use log"})]}),x?s.jsx(sF,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?s.jsx(iF,{secret:e,onClose:()=>p(null),onChanged:i}):null,u==="rename"?s.jsx(lF,{secret:e,onClose:()=>p(null),onChanged:i}):null,u==="rebind"?s.jsx(oF,{secret:e,destinations:n,onClose:()=>p(null),onChanged:i}):null]})}function sF({name:e,accounts:t,timezone:n}){const r=se(()=>R.secretUses(e,50),[e]);if(r.error)return s.jsx(re,{message:r.error});if(!r.data)return s.jsx(le,{children:"Reading the log…"});const i=r.data.uses;return i.length===0?s.jsx(le,{children:"No uses yet."}):s.jsx("div",{className:"ui-list",children:i.map((l,o)=>s.jsxs("div",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[Ie(l.at,n??"UTC")," — ",l.kind,", ",Ph(l.kind,l.target,t)]}),s.jsxs("span",{className:"ui-list-sub",children:[l.agent?l.agent:"the owner",l.plugin?` · ${l.plugin}`:"",l.detail?` · ${l.detail}`:""]})]}),s.jsx("span",{className:"ui-list-side",children:s.jsx(pe,{tone:bS(l.outcome),children:l.outcome})})]},o))})}function NS({name:e,result:t,scrubbed:n,busy:r,failure:i,onScrub:l,onDone:o}){const a=ZL(t);return s.jsxs(G,{gap:"sm",children:[s.jsxs(K,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),s.jsx("p",{className:"ui-card-meta",children:a||"Nothing of the value sits where buddi already holds text."}),s.jsx(re,{message:i}),a?s.jsx(J,{children:s.jsx(P,{variant:"accent",disabled:r||n!==null,onClick:l,children:n===null?"Scrub the history":eF(n)||"Nothing of it was left to replace."})}):null,s.jsx(J,{align:"end",children:s.jsx(P,{onClick:o,children:"Done"})})]})}function CS({destinations:e,bindings:t,disabled:n,onChange:r}){const i=(l,o)=>{r(t.map((a,c)=>c===l?{...a,...o}:a))};return s.jsx(G,{gap:"sm",children:t.map((l,o)=>{const a=e.find(u=>u.kind===l.kind),c=(a==null?void 0:a.maxRule)??l.rule;return s.jsxs(J,{valign:"end",children:[s.jsx(te,{label:"Kind",inline:!0,children:s.jsx("select",{value:l.kind,disabled:n,onChange:u=>{var d;const p=u.target.value;i(o,{kind:p,rule:((d=e.find(h=>h.kind===p))==null?void 0:d.maxRule)??l.rule})},children:(a?e:[...e,{kind:l.kind,plugin:"",maxRule:l.rule}]).map(u=>s.jsx("option",{value:u.kind,children:u.kind},u.kind))})}),s.jsx(te,{label:"Target",inline:!0,grow:!0,children:s.jsx("input",{type:"text",spellCheck:!1,disabled:n,value:l.target,placeholder:YL(l.kind),onChange:u=>i(o,{target:u.target.value})})}),s.jsx(te,{label:"Rule",inline:!0,children:s.jsx("select",{value:l.rule,disabled:n,onChange:u=>i(o,{rule:u.target.value}),children:KL(c).map(u=>s.jsx("option",{value:u,children:xS[u]},u))})}),s.jsx(P,{size:"sm",variant:"ghost",disabled:n,onClick:()=>r(t.filter((u,p)=>p!==o)),children:"Remove"})]},o)})})}function rF({destinations:e,onClose:t,onChanged:n}){const[r,i]=f.useState(""),[l,o]=f.useState(""),[a,c]=f.useState(!1),[u,p]=f.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:e[0].maxRule}]:[]),[d,h]=f.useState(!1),[x,v]=f.useState(null),[w,b]=f.useState(null),[j,g]=f.useState(null),y=async()=>{const k=u.map(T=>yS(T.kind,T.target)),S=k.findIndex(T=>!T.ok);if(S!==-1){v(`Binding ${S+1}: ${k[S].error}`);return}const N=l;o("");const C=await Br("secrets.put",{name:r.trim(),value:N,totp:a,bindings:u.map((T,E)=>({kind:T.kind,target:k[E].target,rule:T.rule}))},h,v);C!==null&&(b({name:r.trim(),result:C}),n())},m=async()=>{const k=await Br("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},h,v);k!==null&&(g(k),n())};return s.jsx(Yt,{title:"Add a secret",onClose:t,children:w?s.jsx(NS,{name:w.name,result:w.result,scrubbed:j,busy:d,failure:x,onScrub:()=>void m(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:k=>{k.preventDefault(),y()},children:s.jsxs("fieldset",{disabled:d,className:"ui-stack","data-gap":"sm",children:[s.jsx(te,{label:"Name",hint:"What an agent calls it. Saving a name that exists replaces that secret’s value.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:k=>i(k.target.value),placeholder:"PNC password"})}),s.jsx(te,{label:"Value",hint:"Kept in the vault, never shown again — not even here.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:l,onChange:k=>o(k.target.value)})}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:k=>c(k.target.checked)}),s.jsx("span",{children:"The code comes from this secret"})]}),s.jsx("p",{className:"ui-field-hint",children:"The seed and the code are one thing buddi holds — the owner’s explicit choice per secret."}),s.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[s.jsx("span",{className:"ui-field-label",children:"Bindings — the places this value may go"}),s.jsx(CS,{destinations:e,bindings:u,disabled:d,onChange:p}),u.length===0?s.jsx("p",{className:"ui-field-hint",children:Fm}):null,e.length?s.jsx(J,{children:s.jsx(P,{size:"sm",onClick:()=>p([...u,{kind:e[0].kind,target:"",rule:e[0].maxRule}]),children:"Add a binding"})}):s.jsx("p",{className:"ui-field-hint",children:"No destination is registered on this installation yet, so there is nothing to bind to."})]}),x?s.jsx(K,{tone:"critical",role:"alert",children:x}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save secret"})]})]})})})}function iF({secret:e,onClose:t,onChanged:n}){const[r,i]=f.useState(""),[l,o]=f.useState(!1),[a,c]=f.useState(null),[u,p]=f.useState(null),[d,h]=f.useState(null),x=async()=>{const w=r;i("");const b=await Br("secrets.put",{name:e.name,value:w,totp:e.totp,bindings:e.bindings.map(({kind:j,target:g,rule:y})=>({kind:j,target:g,rule:y}))},o,c);b!==null&&(p(b),n())},v=async()=>{const w=await Br("secrets.scrub_history",{name:e.name},o,c);w!==null&&(h(w),n())};return s.jsx(Yt,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?s.jsx(NS,{name:e.name,result:u,scrubbed:d,busy:l,failure:a,onScrub:()=>void v(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:w=>{w.preventDefault(),x()},children:s.jsxs("fieldset",{disabled:l,className:"ui-stack","data-gap":"sm",children:[s.jsx(te,{label:"New value",hint:"Replaces what is stored. The bindings stay as they are.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,value:r,onChange:w=>i(w.target.value)})}),a?s.jsx(K,{tone:"critical",role:"alert",children:a}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save value"})]})]})})})}function lF({secret:e,onClose:t,onChanged:n}){const[r,i]=f.useState(e.name),[l,o]=f.useState(!1),[a,c]=f.useState(null),u=async()=>{await Br("secrets.rename",{name:e.name,to:r.trim()},o,c)!==null&&(n(),t())};return s.jsx(Yt,{title:`Rename “${e.name}”`,onClose:t,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:p=>{p.preventDefault(),u()},children:s.jsxs("fieldset",{disabled:l,className:"ui-stack","data-gap":"sm",children:[s.jsx(te,{label:"New name",hint:"The vault entry never moves; only the name the agents ask for does.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:p=>i(p.target.value)})}),a?s.jsx(K,{tone:"critical",role:"alert",children:a}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:!r.trim()||r.trim()===e.name,children:"Save name"})]})]})})})}function oF({secret:e,destinations:t,onClose:n,onChanged:r}){const[i,l]=f.useState(()=>e.bindings.map(d=>({kind:d.kind,target:QL(d.target),rule:d.rule}))),[o,a]=f.useState(!1),[c,u]=f.useState(null),p=async()=>{const d=i.map(v=>yS(v.kind,v.target)),h=d.findIndex(v=>!v.ok);if(h!==-1){u(`Binding ${h+1}: ${d[h].error}`);return}await Br("secrets.rebind",{name:e.name,bindings:i.map((v,w)=>({kind:v.kind,target:d[w].target,rule:v.rule}))},a,u)!==null&&(r(),n())};return s.jsx(Yt,{title:`Rebind “${e.name}”`,onClose:n,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:d=>{d.preventDefault(),p()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(CS,{destinations:t,bindings:i,disabled:o,onChange:l}),i.length===0?s.jsx("p",{className:"ui-field-hint",children:Fm}):null,t.length?s.jsx(J,{children:s.jsx(P,{size:"sm",onClick:()=>l([...i,{kind:t[0].kind,target:"",rule:t[0].maxRule}]),children:"Add a binding"})}):null,c?s.jsx(K,{tone:"critical",role:"alert",children:c}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save bindings"})]})]})})})}function aF({timezone:e,embedded:t}){const{data:n,error:r,reload:i}=se(()=>R.sentinels(),[],3e4),[l,o]=f.useState(null),[a,c]=f.useState(null),u=(n==null?void 0:n.installed)??[],p=((n==null?void 0:n.runs)??[]).filter(x=>x.lastError),d=u.filter(x=>!x.enabled),h=(x,v)=>{o(x),c(null),R.setSentinelEnabled(x,v).catch(w=>c(w instanceof de?w.message:String(w))).finally(()=>{o(null),i()})};return s.jsxs(an,{embedded:t,title:"Watchers",children:[s.jsx(re,{message:r??a}),s.jsx(K,{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."}),p.length>0?s.jsx(K,{tone:"warning",children:p.length===1?"One watcher failed on its last run.":`${p.length} watchers failed on their last run.`}):null,d.length>0?s.jsxs(K,{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,s.jsx(Y,{title:"Installed",aside:s.jsx("a",{href:`${Ze}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:n?u.length===0?s.jsx(wt,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):s.jsx(Ht,{children:u.map(x=>{const v=n.runs.find(w=>w.sentinelId===x.id);return s.jsx(rn,{lead:s.jsx(pe,{tone:x.enabled?v!=null&&v.lastError?"critical":v?"good":void 0:"muted",children:x.enabled?v!=null&&v.lastError?"failed":v?"ok":"never ran":"off"}),title:x.description,sub:`${x.id}, every ${cF(x.every)}${v!=null&&v.lastError?`. ${v.lastError}`:""}`,side:s.jsxs(s.Fragment,{children:[s.jsx("span",{title:v?Ie(v.lastRunAt,e):void 0,children:v?Ce(v.lastRunAt):"never ran"}),s.jsx(P,{size:"sm",disabled:l===x.id,onClick:()=>h(x.id,!x.enabled),children:x.enabled?"Turn off":"Turn on"})]})},x.id)})}):s.jsx(le,{children:"Loading…"})})]})}function cF(e){if(e%86400===0){const n=e/86400;return n===1?"day":`${n} days`}if(e%3600===0){const n=e/3600;return n===1?"hour":`${n} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}function uF({embedded:e}){const{data:t,error:n,reload:r}=se(()=>R.owner(),[]);return s.jsxs(an,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[s.jsx(re,{message:n}),t?s.jsx(dF,{initial:t,onSaved:r}):null]})}function dF({initial:e,onSaved:t}){const[n,r]=f.useState(e.preferredName??""),[i,l]=f.useState(e.timezone??""),[o,a]=f.useState(e.language??""),[c,u]=f.useState(e.about??""),[p,d]=f.useState(!1),[h,x]=f.useState(!1),[v,w]=f.useState(null);f.useEffect(()=>{r(e.preferredName??""),l(e.timezone??""),a(e.language??""),u(e.about??"")},[e]);const b=n.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||o.trim()!==(e.language??"")||c.trim()!==(e.about??""),j=async()=>{d(!0),w(null);try{await R.setOwner({preferredName:n.trim()===""?null:n.trim(),timezone:i===""?null:i,language:o.trim()===""?null:o.trim(),about:c.trim()===""?null:c.trim()}),x(!0),t()}catch(y){w(y instanceof de?y.message:String(y))}finally{d(!1)}},g=e.zones.length>0?e.zones:[e.detectedTimezone];return s.jsx(Y,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:s.jsxs(s.Fragment,{children:[h&&!b?s.jsx("span",{className:"muted",children:"Saved"}):null,s.jsx(P,{variant:"accent",disabled:!b||p,onClick:()=>void j(),children:p?"Saving…":"Save"})]}),children:s.jsxs(G,{divided:!0,gap:"lg",children:[s.jsx(Y,{title:"Name and place",children:s.jsxs(As,{children:[s.jsx(te,{label:"What the agents call you",children:s.jsx("input",{value:n,maxLength:80,placeholder:e.displayName??"Your name",onChange:y=>{x(!1),r(y.target.value)}})}),s.jsx(te,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:s.jsxs("select",{value:i,onChange:y=>{x(!1),l(y.target.value)},children:[s.jsx("option",{value:"",children:"Not set (use the host's)"}),g.map(y=>s.jsx("option",{value:y,children:y},y))]})}),s.jsx(te,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:s.jsx("input",{value:o,maxLength:40,placeholder:"English, français…",onChange:y=>{x(!1),a(y.target.value)}})})]})}),s.jsxs(Y,{title:"About you",children:[s.jsx(te,{label:"In your own words",hint:"Who you are, how you like answers, anything every agent should keep in mind. A few lines is plenty.",children:s.jsx("textarea",{rows:4,maxLength:1e3,value:c,placeholder:"I run a small studio and prefer short answers with the numbers first. Call me by my first name.",onChange:y=>{x(!1),u(y.target.value)}})}),v?s.jsx(K,{tone:"critical",children:v}):null]})]})})}const fF=2e6;function ej(e,t){const n=e.replace(/\r\n/g,`
109
- `).replace(/\n+$/,"").split(`
110
- `),r=t.replace(/\r\n/g,`
111
- `).replace(/\n+$/,"").split(`
112
- `);if(e.trim()===t.trim())return"(no change)";if(n.length*r.length>fF)return[...n.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
113
- `);const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let c=n.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=n[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const l=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(l.push(` ${n[o]}`),o++,a++):i[o+1][a]>=i[o][a+1]?l.push(`-${n[o++]}`):l.push(`+${r[a++]}`);for(;o<n.length;)l.push(`-${n[o++]}`);for(;a<r.length;)l.push(`+${r[a++]}`);return l.join(`
114
- `)}const hF={skill:"skill",policy:"rule",change:"change to itself"};function pF(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,n])=>!/Id$/.test(t)&&n!==null&&n!==void 0&&n!=="").map(([t,n])=>`${t} ${typeof n=="object"?JSON.stringify(n):String(n)}`).join(" · ")}function Ih(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function mF(e,t){const n=e.change;if(!n||n.part!=="tools")return[];if(t===e.editable)return n.added;const r=new Set(Ih(n.current??""));return Ih(t).filter(i=>!r.has(i))}function tj(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function gF({embedded:e,plugin:t}){const{data:n,error:r,reload:i}=se(()=>R.proposals(),[],3e4),[l,o]=f.useState(null),[a,c]=f.useState(null),[u,p]=f.useState(null),[d,h]=f.useState({}),x=async(j,g,y=!1)=>{o(null),c(null),p(j),h(({[j]:m,...k})=>k);try{c(await g()),i()}catch(m){const k=m instanceof Error?m.message:String(m);y?h(S=>({...S,[j]:k})):o(k)}finally{p(null)}},v=bk(),w=((n==null?void 0:n.open)??[]).filter(j=>tj(j,t)),b=((n==null?void 0:n.closed)??[]).filter(j=>tj(j,t));return s.jsxs(an,{embedded:e,title:"Proposals",lede:"What your agents learned and would like to keep: a procedure, a rule, a change to their own instructions. Nothing here applies itself. Keep what is right, correct what is nearly right, discard the rest.",children:[s.jsx(re,{message:r??l}),t?s.jsxs(K,{role:"status",children:["Showing the rules ",t," proposes. ",s.jsx("a",{href:st("proposals"),children:"Show every proposal"})]}):null,a?s.jsx(K,{tone:"good",role:"status",children:a}):null,t?null:s.jsx(kk,{offers:v.offers,reload:v.reload}),!n||w.length===0?s.jsx(Y,{title:"Waiting",panel:!0,children:n?t?s.jsx(wt,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):s.jsx(wt,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):s.jsx(le,{children:"Loading…"})}):s.jsx(Y,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(j=>s.jsx(yF,{proposal:j,busy:u===j.id,refusal:d[j.id]??null,onKeep:g=>void x(j.id,async()=>{const y=await R.keepProposal(j.id,g);return`${j.title}: ${y.note}`},!0),onDiscard:g=>void x(j.id,async()=>(await R.discardProposal(j.id,g),`Discarded: ${j.title}. ${j.agent} will be told once and will not propose it again for 90 days.`))},j.id))}),b.length>0?s.jsx(Y,{title:`Kept, discarded and expired (${b.length})`,aside:"These stop being shown a week after they were decided.",panel:!0,flush:!0,children:s.jsx(Ht,{children:b.map(j=>{var g;return s.jsx(rn,{title:j.title,sub:`${j.agent}: ${xF(j)}`,side:j.kind==="skill"&&j.state==="kept"&&((g=j.skill)!=null&&g.live)?s.jsxs(J,{align:"end",children:[s.jsx("span",{className:"muted",children:Ce(j.decidedAt??j.createdAt)}),s.jsx(P,{size:"sm",variant:"ghost",disabled:u===j.id,onClick:()=>void x(j.id,async()=>{const y=j.skill;return await R.removeSkill(j.agent,y.name),`Removed ${y.name} from ${j.agent}. Its versions are kept, and ${j.agent} will not propose it again for 90 days.`}),children:"Remove this skill"})]}):Ce(j.decidedAt??j.createdAt)},j.id)})})}):null,!t&&(n!=null&&n.digest)?s.jsx(jF,{schedule:n.digest.schedule,onSaved:i}):null]})}function xF(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 vF=Array.from({length:24},(e,t)=>t),nj=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function jF({schedule:e,onSaved:t}){const[n,r]=f.useState(e.day),[i,l]=f.useState(e.hour),[o,a]=f.useState(!1),[c,u]=f.useState(null),p=n!==e.day||i!==e.hour,d=async()=>{a(!0),u(null);try{await R.setDigestSchedule(n,i),u({tone:"good",text:`The digest now runs on ${nj[n]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(h){u({tone:"critical",text:h instanceof Error?h.message:String(h)})}finally{a(!1)}};return s.jsx(Y,{title:"Weekly digest",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:o||!p,onClick:()=>void d(),children:"Save"}),children:s.jsxs(G,{children:[s.jsxs("p",{className:"muted",children:["Once a week, one message on Telegram and a card on Home: what your agents learned, what waits here, and what the rules you kept stopped them doing. No message when nothing was learned and nothing waits.",e.next?` Next: ${Ce(e.next)}.`:""]}),s.jsxs(J,{children:[s.jsx(te,{label:"Day",children:s.jsx("select",{value:n,disabled:o,onChange:h=>r(Number(h.target.value)),children:nj.map((h,x)=>s.jsx("option",{value:x,children:h},h))})}),s.jsx(te,{label:`Hour (${e.timezone})`,children:s.jsx("select",{value:i,disabled:o,onChange:h=>l(Number(h.target.value)),children:vF.map(h=>s.jsxs("option",{value:h,children:[String(h).padStart(2,"0"),":00"]},h))})})]}),c?s.jsx(K,{tone:c.tone,role:"status",children:c.text}):null]})})}function sj(e,t){return e==="tools"?Ih(t).join(`
115
- `):t}function yF({proposal:e,busy:t,refusal:n,onKeep:r,onDiscard:i}){const[l,o]=f.useState(e.editable??""),[a,c]=f.useState(""),u=e.editable!==null&&l!==e.editable,p=e.payload,d=e.echoes??[],h=e.kind==="change"?e.change??null:null,x=mF(e,l);return s.jsx(Fr,{tone:e.untrusted?"warning":"accent",title:e.title,meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{children:hF[e.kind]}),s.jsx(pe,{mono:!0,children:e.agent}),e.untrusted?s.jsx(pe,{tone:"warning",children:"untrusted text in view"}):null,x.length>0?s.jsx(pe,{tone:"warning",children:"widens its tools"}):null]}),foot:s.jsxs(J,{align:"end",children:[n?s.jsx("span",{className:"proposal-refusal",role:"alert",children:n}):null,s.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:a,maxLength:300,disabled:t,onChange:v=>c(v.target.value)}),s.jsx(P,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(a.trim()||void 0),children:"Discard"}),s.jsx(P,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&l.trim()==="",onClick:()=>r(u?l:void 0),children:u?"Keep my version":"Keep"})]}),children:s.jsxs(G,{gap:"sm",children:[e.why?s.jsx("p",{children:e.why}):null,s.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",Ce(e.createdAt),e.conversationId?s.jsxs(s.Fragment,{children:[" in ",s.jsx("a",{href:Ui(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?s.jsxs(K,{tone:"warning",title:e.kind==="policy"?"Learned from mail you received.":"Made with untrusted text in view.",children:[e.kind==="policy"?"The plugin counted this rule from your own triage decisions; no instruction in that mail can change what it does.":"Something written by someone other than you was in the agent's context when it proposed this. Read it for instructions that came from there rather than from you.",s.jsx("ul",{className:"proposal-sources",children:e.sources.map(v=>s.jsx("li",{className:"mono",children:v},v))}),d.length>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),s.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:d.map(v=>s.jsx("li",{children:s.jsx("mark",{className:"wb-diff-mark",children:v})},v))})]}):null]}):null,e.kind==="skill"?s.jsxs(s.Fragment,{children:[typeof p.when=="string"?s.jsxs("p",{className:"ui-card-meta",children:["When: ",p.when]}):null,e.skill?s.jsxs(G,{gap:"sm",children:[s.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",s.jsxs("a",{href:ht(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),s.jsx(Cc,{text:ej(e.skill.steps,l),marks:d,label:`Version ${e.skill.version} against this proposal`})]}):null,s.jsx(te,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:s.jsx("textarea",{rows:8,value:l,disabled:t,onChange:v=>o(v.target.value)})})]}):null,e.kind==="change"?s.jsxs(s.Fragment,{children:[x.length>0?s.jsxs(K,{tone:"warning",title:`Adds: ${x.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,h!=null&&h.refusal&&!u?s.jsx(K,{tone:"warning",title:"Keeping this as proposed will be refused.",children:h.refusal}):null,h&&h.current!==null?s.jsx(Cc,{text:ej(sj(h.part,h.current),sj(h.part,l)),marks:d,label:`${e.agent}'s ${h.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof p.before=="string"?s.jsx(bt,{summary:`What its ${p.part==="tools"?"tool list":"instructions"} said when proposed`,children:s.jsx(ut,{children:p.before})}):null,s.jsx(te,{label:p.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:s.jsx("textarea",{rows:8,value:l,disabled:t,onChange:v=>o(v.target.value)})})]}):null,e.kind==="policy"?s.jsx(At,{items:[{label:"Plugin",value:s.jsx("span",{className:"mono",children:String(p.plugin??"")})},{label:"Matches",value:s.jsx("span",{className:"mono",children:pF(p.matcher??{})})},{label:"Does",value:String(p.action??"")},{label:"Learned from",value:(()=>{const v=Array.isArray(p.verdicts)?p.verdicts.length:0;return`${v} ${v===1?"decision":"decisions"}`})()}]}):null]})})}const wF=1500,bF={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."},kF="Restart buddi to load it. In a checkout, stop it and run: buddi serve",ES=[{id:"npm",label:"From npm"},{id:"file",label:"A file"},{id:"directory",label:"A directory I built"}],AS="buddi.plugins.install-mode";function SF(){try{const e=window.localStorage.getItem(AS);if(ES.some(t=>t.id===e))return e}catch{}return"npm"}function NF(e){try{window.localStorage.setItem(AS,e)}catch{}}const ga=".tgz";function CF(e){const t=[],n=(r,i,l)=>{r>0&&t.push(`${r} ${r===1?i:l}`)};return n(e.tools,"tool","tools"),n(e.sentinels,"watcher","watchers"),n(e.views,"view","views"),n(e.agents,"agent","agents"),t.length===0?"nothing on its own":t.join(", ")}function RS(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 EF(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function AF(e){const[t,n]=f.useState(void 0),[r,i]=f.useState(null);return f.useEffect(()=>{if(!e){n(void 0),i(null);return}let l=!1;const o=()=>{R.pluginJob(e).then(c=>{l||(n(c),(c.phase==="done"||c.phase==="failed")&&(l=!0))}).catch(c=>{l||(i(c instanceof de?c.message:String(c)),l=!0)})};o();const a=window.setInterval(o,wF);return()=>{l=!0,window.clearInterval(a)}},[e]),{job:t,error:r}}function RF(){const e=se(()=>R.plugins(),[],2e4),[t,n]=f.useState(null),{job:r,error:i}=AF(t),[l,o]=f.useState(null),[a,c]=f.useState(null);f.useEffect(()=>{((r==null?void 0:r.phase)==="done"||(r==null?void 0:r.phase)==="failed")&&e.reload()},[r==null?void 0:r.phase]);const u=e.data,p=(u==null?void 0:u.checkout)??!0;return s.jsxs(G,{gap:"lg",children:[s.jsx(re,{message:e.error??l??i}),u!=null&&u.unavailable?s.jsx(K,{tone:"warning",children:u.unavailable}):null,s.jsx(Y,{title:"Plugins",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsx(K,{tone:"warning",children:(u==null?void 0:u.trust)??""})}),s.jsx(Y,{children:s.jsx(PF,{busy:r!==void 0&&r.phase!=="done"&&r.phase!=="failed",onStaged:d=>{o(null),c(null),n(d)},onFailed:o})}),r?s.jsx(Y,{children:s.jsxs(K,{tone:r.phase==="failed"?"critical":r.phase==="done"?"good":void 0,role:"status",children:[bF[r.phase]," ",r.error??""]})}):null]})}),((u==null?void 0:u.staged)??[]).map(d=>s.jsx(MF,{staged:d,onInstalled:h=>{c(h),n(null),e.reload()},onGone:()=>e.reload()},d.id)),a||u!=null&&u.restartNeeded?s.jsx($F,{checkout:p,name:a}):null,s.jsx(Y,{title:"Installed",panel:!0,children:u?u.installed.length===0?s.jsx(wt,{icon:"plug",title:"Nothing installed yet",children:"Only what buddi ships with is here."}):s.jsx(G,{divided:!0,children:u.installed.map(d=>s.jsx(Y,{children:s.jsx(OF,{plugin:d,onChanged:()=>e.reload(),onFailed:o})},d.name))}):s.jsx(le,{children:"Loading…"})}),((u==null?void 0:u.builtIn)??[]).length>0?s.jsx(Y,{title:"Ships with buddi",panel:!0,children:s.jsx(G,{divided:!0,children:((u==null?void 0:u.builtIn)??[]).map(d=>s.jsx(Y,{children:s.jsx(TF,{plugin:d})},d.name))})}):null]})}function TF({plugin:e}){return s.jsxs(G,{gap:"sm",children:[s.jsx(At,{items:[{label:s.jsx("span",{children:e.name}),value:s.jsxs("span",{children:[e.version," · ",CF(e.contribution)]})}]}),e.description?s.jsx("p",{className:"ui-card-meta",children:e.description}):null]})}function PF({busy:e,onStaged:t,onFailed:n}){const[r,i]=f.useState(SF),[l,o]=f.useState(""),[a,c]=f.useState(!1),[u,p]=f.useState(null),[d,h]=f.useState(null),[x,v]=f.useState(!1),w=f.useRef(null),b=m=>n(m instanceof de?m.message:String(m)),j=m=>{i(m),NF(m),h(null)},g=()=>{c(!0),R.stagePlugin(l.trim()).then(m=>{t(m.job.id),o("")}).catch(b).finally(()=>c(!1))},y=m=>{if(m){if(!m.name.toLowerCase().endsWith(ga)){p(null),h(`${m.name} is not a ${ga}. A packed plugin is the file npm pack writes.`);return}h(null),p(m.name),c(!0),R.uploadPlugin(m).then(k=>t(k.job.id)).catch(b).finally(()=>c(!1))}};return s.jsxs(G,{gap:"sm",children:[s.jsx("div",{className:"plugin-modes",role:"radiogroup","aria-label":"Where it comes from",children:ES.map(m=>s.jsx("button",{type:"button",role:"radio","aria-checked":r===m.id,className:"plugin-mode","data-chosen":r===m.id?"true":void 0,onClick:()=>j(m.id),children:m.label},m.id))}),r==="file"?s.jsxs("div",{className:"plugin-drop",role:"group","aria-label":"A plugin file","data-state":x?"over":d?"refused":u?"chosen":void 0,onDragOver:m=>{m.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:m=>{var k,S;m.preventDefault(),v(!1),y((S=(k=m.dataTransfer)==null?void 0:k.files)==null?void 0:S[0])},children:[s.jsx("p",{className:"ui-card-meta",children:d??(u?`${u} — reading it.`:`Drop a ${ga} here, or choose one.`)}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||a,onClick:()=>{var m;return(m=w.current)==null?void 0:m.click()},children:"Choose a file"})}),s.jsx("input",{ref:w,type:"file",accept:ga,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:m=>{var k;y((k=m.target.files)==null?void 0:k[0]),m.target.value=""}})]}):s.jsxs(s.Fragment,{children:[s.jsx(te,{label:r==="npm"?"Install a plugin":"The directory it is in",hint:r==="npm"?"A package name, or a name@version.":"The folder with its package.json, already built.",children:s.jsx("input",{type:"text",value:l,placeholder:r==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:m=>o(m.target.value)})}),s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||a||l.trim()==="",onClick:g,children:"Read it first"})})]})]})}function IF({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],n=((i=e.uses)==null?void 0:i.dropped)??[];return s.jsx(Y,{title:"What it reaches in buddi",children:s.jsxs(G,{gap:"sm",children:[t.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nothing beyond its own tables, its own folder and its own tools' approvals."}):s.jsx("ul",{className:"plugin-uses",children:t.map(l=>s.jsxs("li",{children:["It ",l.words,"."," ",l.added?s.jsxs(pe,{tone:"warning",children:["new in ",e.version]}):null]},l.use))}),n.length>0?s.jsxs("p",{className:"ui-card-meta",children:["No longer: ",n.map(l=>l.words).join("; "),"."]}):null]})})}function MF({staged:e,onInstalled:t,onGone:n}){const[r,i]=f.useState(e.plan??null),[l,o]=f.useState(!1),[a,c]=f.useState(null),u=h=>{o(!0),c(null),R.approveStaged(e.id,{integrity:e.integrity??"",...h?{acknowledgeDrift:!0}:{}}).then(x=>{x.installed?t(e.name):x.plan&&i(x.plan)}).catch(x=>c(x instanceof de?x.message:String(x))).finally(()=>o(!1))},p=()=>{o(!0),c(null),R.rejectStaged(e.id).then(()=>n()).catch(h=>c(h instanceof de?h.message:String(h))).finally(()=>o(!1))},d=(r==null?void 0:r.drift)??[];return s.jsxs(G,{gap:"lg",children:[s.jsx(Fr,{tone:"accent",title:`${e.name} ${e.version}`,meta:s.jsx(pe,{tone:"muted",children:"read, not installed"}),children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:a}),s.jsx(At,{items:[{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:RS(e.source)},{label:"Published by",value:e.publisher??"nobody npm will name"},{label:"Integrity",value:s.jsx("span",{className:"mono",children:e.integrity===void 0||e.integrity===""?"none — this came off a disk":e.integrity})},...e.stagedHash?[{label:"Files on disk",value:s.jsx("span",{className:"mono",children:e.stagedHash})}]:[],{label:"Dependencies",value:e.dependencies.count===0?"none":`${e.dependencies.count}${e.dependencies.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${e.dependencies.withScripts.join(", ")}`}`}]}),s.jsx(IF,{staged:e}),s.jsx(Y,{title:"What the package says about itself",children:s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"This is its claim, taken from its own buddi.md. Nothing has checked it yet."}),s.jsx(At,{items:[{label:"Schema it owns",value:e.claims.schema??"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":e.claims.hosts.join(", ")}]}),e.claims.missing?s.jsx("p",{className:"ui-card-meta",children:"It ships no buddi.md, so it says nothing about itself at all."}):s.jsx("p",{className:"ui-card-meta",children:e.claims.text})]})}),s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:l,onClick:p,children:"Not this one"}),s.jsx(P,{variant:"accent",disabled:l||d.length>0,onClick:()=>u(!1),children:"Install"})]})]})}),d.length>0?s.jsx(Fr,{tone:"warning",title:"What it said, and what it does",meta:s.jsx(pe,{tone:"warning",children:"read this first"}),children:s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),s.jsx("ul",{className:"plugin-drift",children:d.map(h=>s.jsx("li",{children:h},h))}),s.jsx(TS,{unlocks:(r==null?void 0:r.agents)??[]}),s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:l,onClick:p,children:"Not this one"}),s.jsx(P,{variant:"danger",disabled:l,onClick:()=>u(!0),children:"Install anyway"})]})]})}):null]})}function $F({checkout:e,name:t}){const[n,r]=f.useState(!1),[i,l]=f.useState(null),o=t?`${t} is installed.`:"Something is installed that this buddi has not loaded.";return s.jsx(Y,{title:"Restart to load it",panel:!0,children:s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:i}),s.jsxs(K,{tone:e?"warning":void 0,role:"status",children:[o," ",e?kF:"Its tools appear once buddi restarts. That closes this dashboard for a few seconds."]}),e?null:s.jsx(J,{align:"end",children:s.jsx(P,{variant:"accent",disabled:n,onClick:()=>{r(!0),l(null),R.serviceAction("restart").catch(a=>l(a instanceof de?a.message:String(a))).finally(()=>r(!1))},children:"Restart to load it"})})]})})})}function TS({plugin:e,unlocks:t}){return t.length===0?null:s.jsx(Y,{title:"Agents it would unlock",children:s.jsxs(G,{gap:"sm",divided:!0,children:[t.map(n=>s.jsx(_F,{plugin:e,unlock:n},n.id)),s.jsxs("p",{className:"ui-card-meta",children:["Nothing here is created by installing. Accept creates the agent with the tools listed. You can change or remove it ",s.jsx("a",{href:et,children:"on the Agents page"}),"."]})]})})}function _F({plugin:e,unlock:t}){const n=jk(e,t.id),r=t.drift.state!=="not-accepted";return s.jsxs(G,{gap:"sm",children:[s.jsxs(J,{children:[s.jsxs("span",{className:"mono",children:["@",t.handle]}),s.jsx(pe,{tone:t.drift.state==="up-to-date"?"good":"warning",children:t.drift.state}),s.jsx("span",{className:"ui-card-meta",children:t.drift.message}),s.jsx(rl,{}),e&&!r&&!n.created?s.jsx(P,{size:"sm",disabled:n.busy,onClick:n.accept,children:"Accept"}):null]}),s.jsx(re,{message:n.failure}),n.created?s.jsx(yk,{agent:n.created}):null]})}function OF({plugin:e,onChanged:t,onFailed:n}){const[r,i]=f.useState(!1),[l,o]=f.useState(!1),[a,c]=f.useState(""),[u,p]=f.useState(!1),d=x=>{p(!0),x.then(()=>{i(!1),o(!1),c(""),t()}).catch(v=>n(v instanceof de?v.message:String(v))).finally(()=>p(!1))},h=e.contribution;return s.jsxs(G,{gap:"sm",children:[s.jsx(Fr,{tone:e.loaded?void 0:"critical",title:`${e.name} ${e.version}`,meta:e.loaded?s.jsx(pe,{tone:"good",children:"loaded"}):s.jsx(pe,{tone:"critical",children:"did not load"}),actions:s.jsxs(J,{align:"end",children:[s.jsx(P,{size:"sm",variant:"ghost",disabled:u,onClick:()=>i(!r),children:"Remove…"}),s.jsx(P,{size:"sm",disabled:u,onClick:()=>d(R.updatePlugin(e.name)),children:"Update"})]}),children:s.jsxs(G,{gap:"sm",children:[e.error?s.jsx(K,{tone:"critical",children:e.error}):null,s.jsx(At,{items:[{label:"From",value:RS(e.source)},{label:"Published by",value:EF(e.source,e.publisher)},{label:"Installed",value:Ce(e.installedAt)},{label:"Contributes",value:`${h.tools} tool${h.tools===1?"":"s"}, ${h.sentinels} on a timer, ${h.views} view${h.views===1?"":"s"}, ${h.agents} agent${h.agents===1?"":"s"} proposed`}]}),s.jsx(TS,{plugin:e.name,unlocks:e.unlocks})]})}),r?s.jsxs(G,{gap:"sm",children:[s.jsx(K,{tone:"warning",children:"Removing it stops its code loading and leaves its tables exactly where they are, so installing it again picks up where it left off."}),s.jsxs("label",{className:"plugin-check",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:x=>{o(x.target.checked),c("")}}),s.jsx("span",{children:"Also drop its data. Its tables are not recoverable afterwards."})]}),l?s.jsx(te,{label:`Type ${e.name} to confirm`,children:s.jsx("input",{value:a,onChange:x=>c(x.target.value)})}):null,s.jsxs(J,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:u,onClick:()=>{i(!1),o(!1),c("")},children:"Cancel"}),s.jsx(P,{variant:"danger",disabled:u||l&&a.trim()!==e.name,onClick:()=>d(R.uninstallPlugin(e.name,l?{purge:!0,confirm:a.trim()}:{})),children:l?"Remove and drop its data":"Remove"})]})]}):null]})}const PS=new Set(["approval","question"]),xa={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 DF({timezone:e}){var w,b;const t=se(()=>R.notificationSettings(),[]),n=se(()=>R.notifications(20),[],3e4),[r,i]=f.useState(null),[l,o]=f.useState(!1),[a,c]=f.useState(!1),[u,p]=f.useState(null),d=((w=t.data)==null?void 0:w.channels)??[],h=r??((b=t.data)==null?void 0:b.settings),x=j=>{h&&(c(!1),i({...h,...j}))},v=()=>{h&&(o(!0),c(!1),p(null),R.saveNotificationSettings(h).then(()=>{c(!0),i(null),t.reload()}).catch(j=>p(j instanceof de?j.message:String(j))).finally(()=>o(!1)))};return s.jsxs(G,{gap:"lg",children:[s.jsx(Y,{title:"Notifications",aside:"What buddi tells you when you are not looking at this page.",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:l||!h,onClick:v,children:"Save"}),children:s.jsxs(G,{divided:!0,children:[s.jsx(re,{message:t.error??u}),s.jsx(Y,{title:"Where buddi reaches you",children:h?d.length===0?s.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."}):s.jsx(G,{gap:"sm",children:d.map(j=>{var g;return s.jsx(LF,{channel:j,checked:(h.defaultChannel??((g=d[0])==null?void 0:g.kind))===j.kind,onPick:()=>x({defaultChannel:j.kind})},j.kind)})}):s.jsx(le,{children:"Loading…"})}),s.jsx(Y,{title:"By kind",children:h?s.jsxs(G,{gap:"sm",children:[AR.map(j=>s.jsxs("div",{className:"pref-row nt-kind",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:xa[j].label}),s.jsx("span",{className:"ui-field-hint",children:xa[j].hint})]}),s.jsxs("select",{"aria-label":xa[j].label,value:FF(h,j,d),onChange:g=>{const y={...h.perKind};g.target.value==="default"?delete y[j]:y[j]=g.target.value,x({perKind:y})},children:[s.jsx("option",{value:"default",children:"Default"}),d.map(g=>s.jsx("option",{value:g.kind,children:g.label},g.kind)),PS.has(j)?null:s.jsx("option",{value:"off",children:"Off"})]})]},j)),s.jsx("p",{className:"ui-field-hint",children:"Off keeps it in the list below and never sends it."})]}):null}),s.jsx(Y,{title:"Quiet hours",children:h?s.jsxs(G,{gap:"sm",children:[s.jsxs("div",{className:"nt-times",children:[s.jsx(te,{label:"From",children:s.jsx("input",{type:"time",value:h.quietStart??"",onChange:j=>x({quietStart:j.target.value||null})})}),s.jsx(te,{label:"Until",children:s.jsx("input",{type:"time",value:h.quietEnd??"",onChange:j=>x({quietEnd:j.target.value||null})})}),s.jsx(te,{label:"End of the day",children:s.jsx("input",{type:"time",value:h.endOfDay,onChange:j=>x({endOfDay:j.target.value})})})]}),s.jsxs("p",{className:"ui-field-hint",children:["Messages wait until quiet hours end. Approvals and questions still come through. At the end of the day, what could wait goes out as one message. Times are on your clock (",e,")."]})]}):null}),a?s.jsx(K,{tone:"good",role:"status",children:"Saved."}):null]})}),s.jsxs(Y,{title:"The last twenty",panel:!0,flush:!0,children:[s.jsx(re,{message:n.error}),n.data?n.data.notifications.length===0?s.jsx(le,{children:"Nothing yet. What buddi tells you will be listed here."}):s.jsx(Ht,{children:n.data.notifications.map(j=>s.jsx(rn,{title:j.title,sub:`${Ie(j.createdAt,e)} · ${xa[j.kind].label.toLowerCase()} · ${UF(j,d)}`,side:s.jsx(BF,{row:j})},j.id))}):s.jsx(le,{children:"Loading…"})]})]})}function LF({channel:e,checked:t,onPick:n}){const[r,i]=f.useState(!1),[l,o]=f.useState(null),a=()=>{i(!0),o(null),R.testChannel(e.kind).then(()=>o({ok:!0,text:"Sent. Check that it arrived."})).catch(c=>o({ok:!1,text:c instanceof de?c.message:String(c)})).finally(()=>i(!1))};return s.jsxs("div",{className:"nt-channel",children:[s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"nt-default-channel",checked:t,onChange:n}),s.jsxs("span",{className:"nt-channel-text",children:[s.jsxs("span",{className:"pref-label",children:[e.label,e.where?`, ${e.where}`:""]}),s.jsxs("span",{className:"ui-field-hint",children:["The title and a few lines of each message go to ",e.label,"."]}),l?s.jsx("span",{className:"nt-channel-sent","data-tone":l.ok?void 0:"critical",role:"status",children:l.text}):null]})]}),s.jsx(P,{size:"sm",disabled:r,onClick:a,children:"Send a test"})]})}function FF(e,t,n){const r=e.perKind[t];return r==="off"?PS.has(t)?"default":"off":r&&n.some(i=>i.kind===r)?r:"default"}function UF(e,t){var n;return e.channel&&e.channel!=="dashboard"?((n=t.find(r=>r.kind===e.channel))==null?void 0:n.label)??e.channel:"dashboard"}function BF({row:e}){return e.state==="failed"?s.jsxs("span",{className:"nt-state","data-tone":"critical",children:["Failed: ",e.error??"no reason given"]}):e.actedAt?s.jsx("span",{className:"nt-state",children:"Acted on"}):e.seenAt?s.jsx("span",{className:"nt-state",children:"Seen"}):e.state==="held"?s.jsx("span",{className:"nt-state",children:"Waiting"}):e.state==="stored"?s.jsx("span",{className:"nt-state",children:"Kept"}):e.state==="sent"?s.jsx("span",{className:"nt-state",children:"Sent"}):s.jsx("span",{className:"nt-state",children:"Not seen"})}const zF={you:"person",appearance:"sun",notifications:"bell",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function WF(e){const t=j2.map(r=>({id:r.id,route:st(r.id),label:r.label,icon:zF[r.id],group:r.group})),n=[...e].sort((r,i)=>r.title.localeCompare(i.title,void 0,{sensitivity:"base"})||r.plugin.localeCompare(i.plugin)||r.id.localeCompare(i.id)).map(r=>({id:N0(r.plugin,r.id),route:hm(r.plugin,r.id),label:r.title,icon:Fk(r.icon),group:"plugins"}));return[...t,...n]}function IS(e){return v2.map(t=>({id:t.id,label:t.label,entries:e.filter(n=>n.group===t.id)})).filter(t=>t.entries.length>0)}function MS(e,t){return t?`${e}, ${t} open`:e}function VF({entries:e,active:t,counts:n={},navigate:r}){var c;const i=f.useRef(null),l=IS(e),o=e.some(u=>u.id===t)?t:(c=e[0])==null?void 0:c.id,a=u=>{var x;const p=[...((x=i.current)==null?void 0:x.querySelectorAll("a.settings-nav-link"))??[]],d=p.indexOf(document.activeElement);if(d===-1)return;const h=v=>{var w;u.preventDefault(),(w=p[Math.max(0,Math.min(p.length-1,v))])==null||w.focus()};if(u.key==="ArrowDown")h(d+1);else if(u.key==="ArrowUp")h(d-1);else if(u.key==="Home")h(0);else if(u.key==="End")h(p.length-1);else if(u.key==="Enter"||u.key===" "){u.preventDefault();const v=p[d].getAttribute("href");v&&r(v)}};return s.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:i,onKeyDown:a,children:l.map(u=>s.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${u.id}`,children:[s.jsx("div",{className:"settings-nav-label",id:`settings-nav-${u.id}`,children:u.label}),u.entries.map(p=>{const d=p.id===t,h=n[p.id];return s.jsxs("a",{className:"settings-nav-link",href:p.route,"data-active":d?"true":void 0,"aria-current":d?"page":void 0,"aria-label":h?MS(p.label,h):void 0,tabIndex:p.id===o?0:-1,onClick:x=>{x.preventDefault(),r(p.route)},children:[s.jsx(Oe,{name:p.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:p.label}),h?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:h>99?"99+":h}):null]},p.id)})]},u.id))})}function HF({entries:e,active:t,counts:n={},navigate:r}){const i=IS(e),l=e.find(o=>o.id===t)??e[0];return s.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:s.jsxs(sm,{modal:!1,children:[s.jsx(rm,{asChild:!0,children:s.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(l==null?void 0:l.label)??""}`,children:[l?s.jsx(Oe,{name:l.icon,className:"settings-nav-icon"}):null,s.jsx("span",{className:"settings-nav-text",children:l==null?void 0:l.label}),s.jsx(Oe,{name:"chevron-down",className:"settings-menu-chevron"})]})}),s.jsx(im,{children:s.jsx(lm,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:s.jsx(_P,{value:t,onValueChange:o=>{const a=e.find(c=>c.id===o);a&&r(a.route)},children:i.map((o,a)=>s.jsxs($P,{children:[a>0?s.jsx(Fa,{className:"ui-menu-sep"}):null,s.jsx(om,{className:"ui-menu-label",children:o.label}),o.entries.map(c=>{const u=n[c.id];return s.jsxs(OP,{value:c.id,className:"ui-menu-item settings-menu-item","data-active":c.id===t?"true":void 0,"aria-label":u?MS(c.label,u):void 0,children:[s.jsxs("span",{className:"settings-menu-entry",children:[s.jsx(Oe,{name:c.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:c.label})]}),u?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:u>99?"99+":u}):null]},c.id)})]},o.id))})})})]})})}function KF({hash:e,timezone:t,navigate:n,agents:r,pluginPages:i}){var w,b;const l=y2(e),o=Dk(i!==void 0),a=i??o,c=p2(e),u=c?a.find(c.plugin,c.page):void 0,p=Th(aS),d=WF(a.settings),x={proposals:((b=(w=se(()=>Promise.resolve().then(()=>R.proposals()),[],3e4).data)==null?void 0:w.open)==null?void 0:b.length)??0},v={entries:d,active:l,counts:x,navigate:j=>n(j)};return s.jsxs("div",{className:"settings",children:[p?null:s.jsx(VF,{...v}),s.jsx("div",{className:"settings-body",children:s.jsxs("div",{className:"ui-page",children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Settings"}),s.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),p?s.jsx(HF,{...v}):null,u?s.jsx(JO,{page:u,navigate:n,timezone:t,siblings:a.all.filter(j=>j.plugin===u.plugin)}):null,l==="you"?s.jsx(uF,{embedded:!0}):null,l==="appearance"?s.jsx(GF,{}):null,l==="notifications"?s.jsx(DF,{timezone:t}):null,l==="memory"?s.jsx(Xk,{embedded:!0,agents:r,timezone:t}):null,l==="proposals"?s.jsx(gF,{embedded:!0,plugin:g2(e)}):null,l==="accounts"?s.jsx(LL,{embedded:!0}):null,l==="computer"?s.jsx(x_,{embedded:!0,timezone:t}):null,l==="secrets"?s.jsx(tF,{embedded:!0,timezone:t}):null,l==="watchers"?s.jsx(aF,{timezone:t,embedded:!0}):null,l==="backup"?s.jsx(IL,{}):null,l==="plugins"?s.jsx(RF,{}):null,l==="system"?s.jsx(YF,{timezone:t}):null]})})]})}function GF(){const[e,t]=Hk();return s.jsx(Y,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:s.jsxs(G,{divided:!0,gap:"lg",children:[s.jsx(Fd,{label:"Theme",hint:"System follows your Mac.",children:s.jsx(Ba,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:e.theme,onChange:n=>t({theme:n})})}),s.jsx(Fd,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:s.jsx(Ba,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:e.ground,onChange:n=>t({ground:n})})}),s.jsx(Fd,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:s.jsx(Ba,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:e.width,onChange:n=>t({width:n})})})]})})}function Fd({label:e,hint:t,children:n}){return s.jsxs("div",{className:"pref-row ui-section",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:e}),s.jsx("span",{className:"ui-field-hint",children:t})]}),n]})}function YF({timezone:e}){const t=se(()=>R.overview(),[],15e3),n=se(()=>R.session(),[]),r=se(()=>R.providerAccounts(),[]),i=t.data;return s.jsxs(G,{gap:"lg",children:[s.jsx(re,{message:t.error}),s.jsx(a4,{}),i?s.jsx(Y,{title:"The queue",panel:!0,actions:s.jsx(P,{size:"sm",variant:i.paused?"accent":void 0,onClick:()=>{R.setPaused(!i.paused).then(()=>t.reload())},children:i.paused?"Resume the queue":"Pause the queue"}),children:s.jsxs("p",{className:"ui-card-meta",children:[i.paused?"Paused. Nothing is being claimed until you resume.":"Running. Jobs are claimed as they come due."," ",i.paused?s.jsx(pe,{tone:"warning",children:"paused"}):s.jsx(pe,{tone:"good",children:"running"})]})}):null,s.jsxs(Y,{title:"This host",panel:!0,children:[s.jsx(At,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?Ie(i.now,e):"…"},{label:"Bound to",value:n.data?`${n.data.host}:${n.data.port}`:"…"},{label:"Credential vault",value:r.data?XF(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?s.jsx(K,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),s.jsx(JF,{}),s.jsx(qF,{}),s.jsx(Y,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?s.jsx(le,{children:"No sources are installed."}):s.jsx(At,{items:i.mail.map(l=>({key:l.sourceId,label:s.jsx("span",{className:"mono",children:l.sourceId}),value:l.lastError?s.jsx("span",{className:"critical",children:l.lastError}):s.jsxs("span",{children:["polled ",Ce(l.lastRunAt)]})}))}):s.jsx(le,{children:"Loading…"})})]})}function qF(){var x;const e=se(()=>R.tailscale(),[]),[t,n]=f.useState(null),[r,i]=f.useState(!1),[l,o]=f.useState(null),[a,c]=f.useState(!1),u=e.data,p=t??((u==null?void 0:u.login)||((x=u==null?void 0:u.self)==null?void 0:x.login)||""),d=(u==null?void 0:u.proxied)===!0,h=v=>{i(!0),o(null),c(!1),R.setTailscale({enabled:v,login:p.trim()}).then(()=>{c(!0)}).catch(w=>o(w instanceof de?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return s.jsx(Y,{title:"Sign in through Tailscale",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:r||!u||d,onClick:()=>h((u==null?void 0:u.enabled)??!1),children:"Save"}),children:s.jsx(G,{divided:!0,children:s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:e.error??l}),s.jsx("p",{className:"ui-card-meta",children:u?u.available&&u.self?`Tailscale is running on this machine as ${u.self.login}.`:u.available?"Tailscale is running on this machine.":"Tailscale is not running here.":"…"}),d?s.jsxs(s.Fragment,{children:[s.jsx(K,{tone:"warning",children:"Change this from the computer buddi runs on."}),s.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${p}`:"Off"})]}):null,s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||d,onChange:v=>h(v.target.checked)}),s.jsx("span",{children:"Let this Tailscale login sign in"})]}),s.jsx(te,{label:"Tailscale login",children:s.jsx("input",{type:"text",value:p,placeholder:"you@example.com",disabled:r||!u||d,onChange:v=>n(v.target.value)})}),s.jsx("p",{className:"ui-card-meta",children:"Anyone signed in to Tailscale as this login, on any device in your tailnet, is signed in to buddi. The proxy must run on this machine:"}),s.jsxs("div",{className:"tailscale-command",children:[s.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),s.jsx(P,{size:"sm",disabled:r||!u,onClick:()=>{QF((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),s.jsx("p",{className:"ui-card-meta",children:"This gives your tailnet the trust this machine already has: buddi cannot tell the Tailscale proxy from another program running here, and any program that can reach the dashboard on this machine can already read buddi’s files."}),a?s.jsx(K,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function QF(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function JF(){var u;const e=se(()=>R.service(),[],1e4),[t,n]=f.useState(null),[r,i]=f.useState(!1),[l,o]=f.useState(null),a=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!a)return null;const c=p=>{i(!0),o(null),R.serviceAction(p).then(()=>{n(null)}).catch(d=>{o(d.message)}).finally(()=>{i(!1),e.reload()})};return s.jsx(Y,{title:"Service",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsx(At,{items:[{label:"Database",value:s.jsx(rj,{state:a.database,pid:a.databasePid})},{label:"Gateway",value:s.jsx(rj,{state:a.gateway,pid:a.gatewayPid})},{label:"Supervisor",value:s.jsxs("span",{className:"mono",children:["pid ",a.supervisorPid]})}]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:l}),t?s.jsx(K,{tone:"warning",role:"alert",children:t==="stop"?"Stopping the gateway closes this dashboard. The database keeps running; run buddi in a terminal to bring the dashboard back.":"Restarting the gateway closes this dashboard for a few seconds. If it does not come back on its own, run buddi in a terminal."}):s.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),s.jsx(J,{align:"end",children:t?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",disabled:r,onClick:()=>{n(null),o(null)},children:"Cancel"}),s.jsx(P,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>{n("stop")},children:"Stop gateway"}),s.jsx(P,{variant:"accent",onClick:()=>{n("restart")},children:"Restart gateway"})]})})]})})]})})}function rj({state:e,pid:t}){return s.jsxs("span",{children:[s.jsx(pe,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?s.jsx("span",{className:"ui-card-meta",children:"no process"}):s.jsxs("span",{className:"mono",children:["pid ",t]})]})}function XF(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const ZF=2e3,ij={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."},e4=new Set(["done","failed","rolled-back"]),t4="The check asks the npm registry for the newest version and sends nothing else.",n4="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",s4="A checkout upgrades with git pull, then buddi upgrade in a terminal.",r4=10*6e4,i4="buddi did not come back. Run buddi doctor in a terminal.";function l4(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 o4(e,t,n,r){const[i,l]=f.useState(void 0),[o,a]=f.useState(!1),[c,u]=f.useState(null),p=f.useRef(!1),d=f.useRef(n),h=f.useRef(r);return d.current=n,h.current=r,f.useEffect(()=>{if(!e){l(void 0),a(!1),p.current=!1;return}let x=!1,v=0;const w=()=>{p.current=!0,v=Date.now()+r4,a(!0)},b=()=>{if(Date.now()<v){R.session().then(y=>{x||y.version!==void 0&&y.version===t||(x=!0,d.current())}).catch(()=>{}),R.version().then(y=>{const m=y.history[y.history.length-1];x||(m==null?void 0:m.outcome)!=="failed"||(x=!0,a(!1),u(l4(m)))}).catch(()=>{});return}x=!0,a(!1),u(i4)},j=()=>{if(!x){if(p.current)return b();R.upgradeJob(e).then(y=>{var m;x||(l(y),u(null),(e4.has(y.phase)||y.finishedAt)&&(x=!0,y.phase==="failed"&&((m=h.current)==null||m.call(h,y))))}).catch(y=>{x||(y instanceof de&&y.status!==0&&y.status<500?u(y.message):w())})}};j();const g=window.setInterval(j,ZF);return()=>{x=!0,window.clearInterval(g)}},[e,t]),{job:i,away:o,error:c}}function a4({reload:e}){var m;const t=se(()=>R.version(),[]),[n,r]=f.useState(null),[i,l]=f.useState(!1),[o,a]=f.useState(!1),[c,u]=f.useState(null),[p,d]=f.useState(null),h=(m=t.data)==null?void 0:m.current,x=e??(()=>window.location.reload()),v=f.useCallback(k=>{r(null),d(k)},[]),w=o4(n,h,x,v),b=t.data,j=()=>{a(!0),u(null),R.checkVersion().catch(k=>u(k instanceof de?k.message:String(k))).finally(()=>{a(!1),t.reload()})},g=k=>{a(!0),u(null),R.setVersionCheck(k).catch(S=>u(S instanceof de?S.message:String(S))).finally(()=>{a(!1),t.reload()})},y=()=>{a(!0),u(null),d(null),R.startUpgrade(b==null?void 0:b.latest).then(k=>{var S;l(!1),r(((S=k.job)==null?void 0:S.id)??null)}).catch(k=>u(k instanceof de?k.message:String(k))).finally(()=>a(!1))};return b!=null&&b.checkout?s.jsx(Y,{title:"Version",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsx(At,{items:[{label:"Running",value:s.jsx("span",{className:"mono",children:b.current})}]})}),s.jsx(Y,{children:s.jsx("p",{className:"ui-card-meta",children:s4})})]})}):s.jsx(Y,{title:"Version",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:t.error??c}),s.jsx(At,{items:[{label:"Running",value:b?s.jsx("span",{className:"mono",children:b.current}):"…"},{label:"Newest",value:b?b.updateAvailable&&b.latest?s.jsxs("span",{children:["A newer buddi is available: ",s.jsx("span",{className:"mono",children:b.latest})]}):b.checkedAt?s.jsxs("span",{children:["This is the latest, as of ",Ce(b.checkedAt),"."]}):s.jsx("span",{children:"Not checked yet."}):"…"}]}),b!=null&&b.error?s.jsxs(K,{tone:"warning",children:["The last check did not get an answer: ",b.error]}):null,s.jsx(J,{align:"end",children:s.jsx(P,{disabled:o,onClick:j,children:"Check now"})})]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(b==null?void 0:b.checkEnabled)??!1,disabled:o||!b,onChange:k=>g(k.target.checked)}),s.jsx("span",{children:"Check once a day"})]}),s.jsx("p",{className:"ui-card-meta",children:t4})]})}),b!=null&&b.updateAvailable&&b.latest&&b.latestNotes?s.jsx(Y,{title:`What changes in ${b.latest}`,children:s.jsx(cr,{text:b.latestNotes})}):null,s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(c4,{...w,job:w.job??p??void 0}),i?s.jsx(K,{tone:"warning",role:"alert",children:n4}):null,s.jsx(J,{align:"end",children:i?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",disabled:o,onClick:()=>l(!1),children:"Cancel"}),s.jsxs(P,{variant:"accent",disabled:o,onClick:y,children:["Upgrade to ",b==null?void 0:b.latest]})]}):s.jsx(P,{variant:"accent",disabled:o||n!==null||!(b!=null&&b.updateAvailable),onClick:()=>l(!0),children:b!=null&&b.updateAvailable&&b.latest?`Upgrade to ${b.latest}`:"Upgrade"})})]})}),b&&b.history.length>0?s.jsx(Y,{title:"Upgrades so far",children:s.jsx(At,{items:b.history.slice().reverse().map(k=>({key:k.startedAt,label:s.jsxs("span",{className:"mono",children:[k.from," → ",k.to]}),value:s.jsx(u4,{attempt:k})}))})}):null]})})}function c4({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.jsx(K,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="failed"?s.jsxs(K,{tone:"critical",role:"alert",children:[ij.failed," ",e.error??""," buddi is still running on the version it had."]}):s.jsx(K,{tone:e.phase==="done"?"good":void 0,role:"status",children:ij[e.phase]??e.detail??e.phase}):null}function u4({attempt:e}){return s.jsxs("span",{children:[s.jsx(pe,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",Ce(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?s.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",s.jsx("span",{className:"mono",children:e.backup})]}):null]})}const Mh=["name","clock","brain","browser","assistant","handover"],$S={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function d4(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function f4(e){var l,o,a;const t=d4(e.accounts),n=e.assistant?(((l=e.accounts)==null?void 0:l.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(n==null?void 0:n.accountId)??((a=(o=e.onboarding)==null?void 0:o.details)==null?void 0:a.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(n==null?void 0:n.model)??i.defaultModel}}function _S(e){var r,i,l;const t=f4(e),n=e.onboarding&&!e.onboarding.needs.agent?e.assistant:void 0;return{...(r=e.owner)!=null&&r.preferredName?{name:e.owner.preferredName}:{},...(i=e.owner)!=null&&i.timezone?{clock:e.owner.timezone}:{},...t?{brain:t}:{},...(l=e.onboarding)!=null&&l.stepsDone.includes("browser")||n?{browser:e.browser??"other"}:{},...n?{assistant:n}:{}}}function h4(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 $h(e){return Mh.find(t=>!h4(e,t))??"handover"}function p4(e,t){const n=Mh.indexOf(t);return Mh.filter((r,i)=>i<n||r===t)}function m4(e,t){const n={...e};return delete n[t],n}const _h="buddi.firstRun.restore";function Ud(e){try{e===null?window.sessionStorage.removeItem(_h):window.sessionStorage.setItem(_h,e)}catch{}}function OS(){try{return window.sessionStorage.getItem(_h)}catch{return null}}function g4(e){const t=_S(e),n=$h(t);return{answers:t,open:n,stay:n!=="handover"}}function x4(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function v4(e){const t=e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,20).replace(/-+$/,"");return t===""?"assistant":t}var So={},j4=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},DS={},yn={};let Um;const y4=[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];yn.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};yn.getSymbolTotalCodewords=function(t){return y4[t]};yn.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};yn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Um=t};yn.isKanjiModeEnabled=function(){return typeof Um<"u"};yn.toSJIS=function(t){return Um(t)};var ju={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(ju);function LS(){this.buffer=[],this.length=0}LS.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var w4=LS;function No(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)}No.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};No.prototype.get=function(e,t){return this.data[e*this.size+t]};No.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};No.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var b4=No,FS={};(function(e){const t=yn.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,l=t(r),o=l===145?26:Math.ceil((l-13)/(2*i-2))*2,a=[l-7];for(let c=1;c<i-1;c++)a[c]=a[c-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],l=e.getRowColCoords(r),o=l.length;for(let a=0;a<o;a++)for(let c=0;c<o;c++)a===0&&c===0||a===0&&c===o-1||a===o-1&&c===0||i.push([l[a],l[c]]);return i}})(FS);var US={};const k4=yn.getSymbolSize,lj=7;US.getPositions=function(t){const n=k4(t);return[[0,0],[n-lj,0],[0,n-lj]]};var BS={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const l=i.size;let o=0,a=0,c=0,u=null,p=null;for(let d=0;d<l;d++){a=c=0,u=p=null;for(let h=0;h<l;h++){let x=i.get(d,h);x===u?a++:(a>=5&&(o+=t.N1+(a-5)),u=x,a=1),x=i.get(h,d),x===p?c++:(c>=5&&(o+=t.N1+(c-5)),p=x,c=1)}a>=5&&(o+=t.N1+(a-5)),c>=5&&(o+=t.N1+(c-5))}return o},e.getPenaltyN2=function(i){const l=i.size;let o=0;for(let a=0;a<l-1;a++)for(let c=0;c<l-1;c++){const u=i.get(a,c)+i.get(a,c+1)+i.get(a+1,c)+i.get(a+1,c+1);(u===4||u===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const l=i.size;let o=0,a=0,c=0;for(let u=0;u<l;u++){a=c=0;for(let p=0;p<l;p++)a=a<<1&2047|i.get(u,p),p>=10&&(a===1488||a===93)&&o++,c=c<<1&2047|i.get(p,u),p>=10&&(c===1488||c===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let l=0;const o=i.data.length;for(let c=0;c<o;c++)l+=i.data[c];return Math.abs(Math.ceil(l*100/o/5)-10)*t.N4};function n(r,i,l){switch(r){case e.Patterns.PATTERN000:return(i+l)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(i+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return i*l%2+i*l%3===0;case e.Patterns.PATTERN110:return(i*l%2+i*l%3)%2===0;case e.Patterns.PATTERN111:return(i*l%3+(i+l)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,l){const o=l.size;for(let a=0;a<o;a++)for(let c=0;c<o;c++)l.isReserved(c,a)||l.xor(c,a,n(i,c,a))},e.getBestMask=function(i,l){const o=Object.keys(e.Patterns).length;let a=0,c=1/0;for(let u=0;u<o;u++){l(u),e.applyMask(u,i);const p=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),p<c&&(c=p,a=u)}return a}})(BS);var yu={};const Ks=ju,va=[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],ja=[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];yu.getBlocksCount=function(t,n){switch(n){case Ks.L:return va[(t-1)*4+0];case Ks.M:return va[(t-1)*4+1];case Ks.Q:return va[(t-1)*4+2];case Ks.H:return va[(t-1)*4+3];default:return}};yu.getTotalCodewordsCount=function(t,n){switch(n){case Ks.L:return ja[(t-1)*4+0];case Ks.M:return ja[(t-1)*4+1];case Ks.Q:return ja[(t-1)*4+2];case Ks.H:return ja[(t-1)*4+3];default:return}};var zS={},wu={};const Ll=new Uint8Array(512),Mc=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Ll[n]=t,Mc[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Ll[n]=Ll[n-255]})();wu.log=function(t){if(t<1)throw new Error("log("+t+")");return Mc[t]};wu.exp=function(t){return Ll[t]};wu.mul=function(t,n){return t===0||n===0?0:Ll[Mc[t]+Mc[n]]};(function(e){const t=wu;e.mul=function(r,i){const l=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)l[o+a]^=t.mul(r[o],i[a]);return l},e.mod=function(r,i){let l=new Uint8Array(r);for(;l.length-i.length>=0;){const o=l[0];for(let c=0;c<i.length;c++)l[c]^=t.mul(i[c],o);let a=0;for(;a<l.length&&l[a]===0;)a++;l=l.slice(a)}return l},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let l=0;l<r;l++)i=e.mul(i,new Uint8Array([1,t.exp(l)]));return i}})(zS);const WS=zS;function Bm(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Bm.prototype.initialize=function(t){this.degree=t,this.genPoly=WS.generateECPolynomial(this.degree)};Bm.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=WS.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const l=new Uint8Array(this.degree);return l.set(r,i),l}return r};var S4=Bm,VS={},gr={},zm={};zm.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var cs={};const HS="[0-9]+",N4="[A-Z $%*+\\-./:]+";let fo="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";fo=fo.replace(/u/g,"\\u");const C4="(?:(?![A-Z0-9 $%*+\\-./:]|"+fo+`)(?:.|[\r
116
- ]))+`;cs.KANJI=new RegExp(fo,"g");cs.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");cs.BYTE=new RegExp(C4,"g");cs.NUMERIC=new RegExp(HS,"g");cs.ALPHANUMERIC=new RegExp(N4,"g");const E4=new RegExp("^"+fo+"$"),A4=new RegExp("^"+HS+"$"),R4=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");cs.testKanji=function(t){return E4.test(t)};cs.testNumeric=function(t){return A4.test(t)};cs.testAlphanumeric=function(t){return R4.test(t)};(function(e){const t=zm,n=cs;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(l,o){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?l.ccBits[0]:o<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return n.testNumeric(l)?e.NUMERIC:n.testAlphanumeric(l)?e.ALPHANUMERIC:n.testKanji(l)?e.KANJI:e.BYTE},e.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},e.isValid=function(l){return l&&l.bit&&l.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(l,o){if(e.isValid(l))return l;try{return r(l)}catch{return o}}})(gr);(function(e){const t=yn,n=yu,r=ju,i=gr,l=zm,o=7973,a=t.getBCHDigit(o);function c(h,x,v){for(let w=1;w<=40;w++)if(x<=e.getCapacity(w,v,h))return w}function u(h,x){return i.getCharCountIndicator(h,x)+4}function p(h,x){let v=0;return h.forEach(function(w){const b=u(w.mode,x);v+=b+w.getBitsLength()}),v}function d(h,x){for(let v=1;v<=40;v++)if(p(h,v)<=e.getCapacity(v,x,i.MIXED))return v}e.from=function(x,v){return l.isValid(x)?parseInt(x,10):v},e.getCapacity=function(x,v,w){if(!l.isValid(x))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=i.BYTE);const b=t.getSymbolTotalCodewords(x),j=n.getTotalCodewordsCount(x,v),g=(b-j)*8;if(w===i.MIXED)return g;const y=g-u(w,x);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(x,v){let w;const b=r.from(v,r.M);if(Array.isArray(x)){if(x.length>1)return d(x,b);if(x.length===0)return 1;w=x[0]}else w=x;return c(w.mode,w.getLength(),b)},e.getEncodedBits=function(x){if(!l.isValid(x)||x<7)throw new Error("Invalid QR Code version");let v=x<<12;for(;t.getBCHDigit(v)-a>=0;)v^=o<<t.getBCHDigit(v)-a;return x<<12|v}})(VS);var KS={};const Oh=yn,GS=1335,T4=21522,oj=Oh.getBCHDigit(GS);KS.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;Oh.getBCHDigit(i)-oj>=0;)i^=GS<<Oh.getBCHDigit(i)-oj;return(r<<10|i)^T4};var YS={};const P4=gr;function Vi(e){this.mode=P4.NUMERIC,this.data=e.toString()}Vi.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Vi.prototype.getLength=function(){return this.data.length};Vi.prototype.getBitsLength=function(){return Vi.getBitsLength(this.data.length)};Vi.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const l=this.data.length-n;l>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,l*3+1))};var I4=Vi;const M4=gr,Bd=["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 Hi(e){this.mode=M4.ALPHANUMERIC,this.data=e}Hi.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Hi.prototype.getLength=function(){return this.data.length};Hi.prototype.getBitsLength=function(){return Hi.getBitsLength(this.data.length)};Hi.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=Bd.indexOf(this.data[n])*45;r+=Bd.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(Bd.indexOf(this.data[n]),6)};var $4=Hi;const _4=gr;function Ki(e){this.mode=_4.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Ki.getBitsLength=function(t){return t*8};Ki.prototype.getLength=function(){return this.data.length};Ki.prototype.getBitsLength=function(){return Ki.getBitsLength(this.data.length)};Ki.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var O4=Ki;const D4=gr,L4=yn;function Gi(e){this.mode=D4.KANJI,this.data=e}Gi.getBitsLength=function(t){return t*13};Gi.prototype.getLength=function(){return this.data.length};Gi.prototype.getBitsLength=function(){return Gi.getBitsLength(this.data.length)};Gi.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=L4.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
117
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var F4=Gi,qS={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var l={},o={};o[r]=0;var a=t.PriorityQueue.make();a.push(r,0);for(var c,u,p,d,h,x,v,w,b;!a.empty();){c=a.pop(),u=c.value,d=c.cost,h=n[u]||{};for(p in h)h.hasOwnProperty(p)&&(x=h[p],v=d+x,w=o[p],b=typeof o[p]>"u",(b||w>v)&&(o[p]=v,a.push(p,v),l[p]=u))}if(typeof i<"u"&&typeof o[i]>"u"){var j=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(j)}return l},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],l=r;l;)i.push(l),n[l],l=n[l];return i.reverse(),i},find_path:function(n,r,i){var l=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(l,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},l;n=n||{};for(l in r)r.hasOwnProperty(l)&&(i[l]=r[l]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(qS);var U4=qS.exports;(function(e){const t=gr,n=I4,r=$4,i=O4,l=F4,o=cs,a=yn,c=U4;function u(j){return unescape(encodeURIComponent(j)).length}function p(j,g,y){const m=[];let k;for(;(k=j.exec(y))!==null;)m.push({data:k[0],index:k.index,mode:g,length:k[0].length});return m}function d(j){const g=p(o.NUMERIC,t.NUMERIC,j),y=p(o.ALPHANUMERIC,t.ALPHANUMERIC,j);let m,k;return a.isKanjiModeEnabled()?(m=p(o.BYTE,t.BYTE,j),k=p(o.KANJI,t.KANJI,j)):(m=p(o.BYTE_KANJI,t.BYTE,j),k=[]),g.concat(y,m,k).sort(function(N,C){return N.index-C.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function h(j,g){switch(g){case t.NUMERIC:return n.getBitsLength(j);case t.ALPHANUMERIC:return r.getBitsLength(j);case t.KANJI:return l.getBitsLength(j);case t.BYTE:return i.getBitsLength(j)}}function x(j){return j.reduce(function(g,y){const m=g.length-1>=0?g[g.length-1]:null;return m&&m.mode===y.mode?(g[g.length-1].data+=y.data,g):(g.push(y),g)},[])}function v(j){const g=[];for(let y=0;y<j.length;y++){const m=j[y];switch(m.mode){case t.NUMERIC:g.push([m,{data:m.data,mode:t.ALPHANUMERIC,length:m.length},{data:m.data,mode:t.BYTE,length:m.length}]);break;case t.ALPHANUMERIC:g.push([m,{data:m.data,mode:t.BYTE,length:m.length}]);break;case t.KANJI:g.push([m,{data:m.data,mode:t.BYTE,length:u(m.data)}]);break;case t.BYTE:g.push([{data:m.data,mode:t.BYTE,length:u(m.data)}])}}return g}function w(j,g){const y={},m={start:{}};let k=["start"];for(let S=0;S<j.length;S++){const N=j[S],C=[];for(let T=0;T<N.length;T++){const E=N[T],_=""+S+T;C.push(_),y[_]={node:E,lastCount:0},m[_]={};for(let F=0;F<k.length;F++){const O=k[F];y[O]&&y[O].node.mode===E.mode?(m[O][_]=h(y[O].lastCount+E.length,E.mode)-h(y[O].lastCount,E.mode),y[O].lastCount+=E.length):(y[O]&&(y[O].lastCount=E.length),m[O][_]=h(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,g))}}k=C}for(let S=0;S<k.length;S++)m[k[S]].end=0;return{map:m,table:y}}function b(j,g){let y;const m=t.getBestModeForData(j);if(y=t.from(g,m),y!==t.BYTE&&y.bit<m.bit)throw new Error('"'+j+'" cannot be encoded with mode '+t.toString(y)+`.
118
- Suggested mode is: `+t.toString(m));switch(y===t.KANJI&&!a.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new n(j);case t.ALPHANUMERIC:return new r(j);case t.KANJI:return new l(j);case t.BYTE:return new i(j)}}e.fromArray=function(g){return g.reduce(function(y,m){return typeof m=="string"?y.push(b(m,null)):m.data&&y.push(b(m.data,m.mode)),y},[])},e.fromString=function(g,y){const m=d(g,a.isKanjiModeEnabled()),k=v(m),S=w(k,y),N=c.find_path(S.map,"start","end"),C=[];for(let T=1;T<N.length-1;T++)C.push(S.table[N[T]].node);return e.fromArray(x(C))},e.rawSplit=function(g){return e.fromArray(d(g,a.isKanjiModeEnabled()))}})(YS);const bu=yn,zd=ju,B4=w4,z4=b4,W4=FS,V4=US,Dh=BS,Lh=yu,H4=S4,$c=VS,K4=KS,G4=gr,Wd=YS;function Y4(e,t){const n=e.size,r=V4.getPositions(t);for(let i=0;i<r.length;i++){const l=r[i][0],o=r[i][1];for(let a=-1;a<=7;a++)if(!(l+a<=-1||n<=l+a))for(let c=-1;c<=7;c++)o+c<=-1||n<=o+c||(a>=0&&a<=6&&(c===0||c===6)||c>=0&&c<=6&&(a===0||a===6)||a>=2&&a<=4&&c>=2&&c<=4?e.set(l+a,o+c,!0,!0):e.set(l+a,o+c,!1,!0))}}function q4(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function Q4(e,t){const n=W4.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],l=n[r][1];for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?e.set(i+o,l+a,!0,!0):e.set(i+o,l+a,!1,!0)}}function J4(e,t){const n=e.size,r=$c.getEncodedBits(t);let i,l,o;for(let a=0;a<18;a++)i=Math.floor(a/3),l=a%3+n-8-3,o=(r>>a&1)===1,e.set(i,l,o,!0),e.set(l,i,o,!0)}function Vd(e,t,n){const r=e.size,i=K4.getEncodedBits(t,n);let l,o;for(l=0;l<15;l++)o=(i>>l&1)===1,l<6?e.set(l,8,o,!0):l<8?e.set(l+1,8,o,!0):e.set(r-15+l,8,o,!0),l<8?e.set(8,r-l-1,o,!0):l<9?e.set(8,15-l-1+1,o,!0):e.set(8,15-l-1,o,!0);e.set(r-8,8,1,!0)}function X4(e,t){const n=e.size;let r=-1,i=n-1,l=7,o=0;for(let a=n-1;a>0;a-=2)for(a===6&&a--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,a-c)){let u=!1;o<t.length&&(u=(t[o]>>>l&1)===1),e.set(i,a-c,u),l--,l===-1&&(o++,l=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function Z4(e,t,n){const r=new B4;n.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),G4.getCharCountIndicator(c.mode,e)),c.write(r)});const i=bu.getSymbolTotalCodewords(e),l=Lh.getTotalCodewordsCount(e,t),o=(i-l)*8;for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const a=(o-r.getLengthInBits())/8;for(let c=0;c<a;c++)r.put(c%2?17:236,8);return e3(r,e,t)}function e3(e,t,n){const r=bu.getSymbolTotalCodewords(t),i=Lh.getTotalCodewordsCount(t,n),l=r-i,o=Lh.getBlocksCount(t,n),a=r%o,c=o-a,u=Math.floor(r/o),p=Math.floor(l/o),d=p+1,h=u-p,x=new H4(h);let v=0;const w=new Array(o),b=new Array(o);let j=0;const g=new Uint8Array(e.buffer);for(let N=0;N<o;N++){const C=N<c?p:d;w[N]=g.slice(v,v+C),b[N]=x.encode(w[N]),v+=C,j=Math.max(j,C)}const y=new Uint8Array(r);let m=0,k,S;for(k=0;k<j;k++)for(S=0;S<o;S++)k<w[S].length&&(y[m++]=w[S][k]);for(k=0;k<h;k++)for(S=0;S<o;S++)y[m++]=b[S][k];return y}function t3(e,t,n,r){let i;if(Array.isArray(e))i=Wd.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const p=Wd.rawSplit(e);u=$c.getBestVersionForData(p,n)}i=Wd.fromString(e,u||40)}else throw new Error("Invalid data");const l=$c.getBestVersionForData(i,n);if(!l)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=l;else if(t<l)throw new Error(`
119
- The chosen QR Code version cannot contain this amount of data.
120
- Minimum version required to store current data is: `+l+`.
121
- `);const o=Z4(t,n,i),a=bu.getSymbolSize(t),c=new z4(a);return Y4(c,t),q4(c),Q4(c,t),Vd(c,n,0),t>=7&&J4(c,t),X4(c,o),isNaN(r)&&(r=Dh.getBestMask(c,Vd.bind(null,c,n))),Dh.applyMask(r,c),Vd(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}DS.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=zd.M,i,l;return typeof n<"u"&&(r=zd.from(n.errorCorrectionLevel,zd.M),i=$c.from(n.version),l=Dh.from(n.maskPattern),n.toSJISFunc&&bu.setToSJISFunction(n.toSJISFunc)),t3(t,i,r,l)};var QS={},Wm={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(l){return[l,l]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,l=r.width&&r.width>=21?r.width:void 0,o=r.scale||4;return{width:l,scale:l?4:o,margin:i,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},e.getImageWidth=function(r,i){const l=e.getScale(r,i);return Math.floor((r+i.margin*2)*l)},e.qrToImageData=function(r,i,l){const o=i.modules.size,a=i.modules.data,c=e.getScale(o,l),u=Math.floor((o+l.margin*2)*c),p=l.margin*c,d=[l.color.light,l.color.dark];for(let h=0;h<u;h++)for(let x=0;x<u;x++){let v=(h*u+x)*4,w=l.color.light;if(h>=p&&x>=p&&h<u-p&&x<u-p){const b=Math.floor((h-p)/c),j=Math.floor((x-p)/c);w=d[a[b*o+j]?1:0]}r[v++]=w.r,r[v++]=w.g,r[v++]=w.b,r[v]=w.a}}})(Wm);(function(e){const t=Wm;function n(i,l,o){i.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=o,l.width=o,l.style.height=o+"px",l.style.width=o+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(l,o,a){let c=a,u=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(u=r()),c=t.getOptions(c);const p=t.getImageWidth(l.modules.size,c),d=u.getContext("2d"),h=d.createImageData(p,p);return t.qrToImageData(h.data,l,c),n(d,u,p),d.putImageData(h,0,0),u},e.renderToDataURL=function(l,o,a){let c=a;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const u=e.render(l,o,c),p=c.type||"image/png",d=c.rendererOpts||{};return u.toDataURL(p,d.quality)}})(QS);var JS={};const n3=Wm;function aj(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function Hd(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function s3(e,t,n){let r="",i=0,l=!1,o=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),u=Math.floor(a/t);!c&&!l&&(l=!0),e[a]?(o++,a>0&&c>0&&e[a-1]||(r+=l?Hd("M",c+n,.5+u+n):Hd("m",i,0),i=0,l=!1),c+1<t&&e[a+1]||(r+=Hd("h",o),o=0)):i++}return r}JS.render=function(t,n,r){const i=n3.getOptions(n),l=t.modules.size,o=t.modules.data,a=l+i.margin*2,c=i.color.light.a?"<path "+aj(i.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",u="<path "+aj(i.color.dark,"stroke")+' d="'+s3(o,l,i.margin)+'"/>',p='viewBox="0 0 '+a+" "+a+'"',h='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+p+' shape-rendering="crispEdges">'+c+u+`</svg>
122
- `;return typeof r=="function"&&r(null,h),h};const r3=j4,Fh=DS,XS=QS,i3=JS;function Vm(e,t,n,r,i){const l=[].slice.call(arguments,1),o=l.length,a=typeof l[o-1]=="function";if(!a&&!r3())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(i=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(c,u){try{const p=Fh.create(n,r);c(e(p,t,r))}catch(p){u(p)}})}try{const c=Fh.create(n,r);i(null,e(c,t,r))}catch(c){i(c)}}So.create=Fh.create;So.toCanvas=Vm.bind(null,XS.render);So.toDataURL=Vm.bind(null,XS.renderToDataURL);So.toString=Vm.bind(null,function(e,t,n){return i3.render(e,n)});async function l3(e){const t=await So.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const o3=550,a3=6e4,c3=5*6e4,ZS=1500,u3=3e3,cj=10*6e4;function Co(){const e=f.useRef(null);return f.useEffect(()=>{let t=0,n=0;const r=o=>{const a=o.ownerDocument.activeElement;return a===null||a===o.ownerDocument.body||a===o.ownerDocument.documentElement},i=()=>{const o=e.current;o&&r(o)&&o.focus()},l=()=>{i(),n=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(l):l(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(n),window.removeEventListener("focus",i)}},[]),e}function e1(){const[e,t]=f.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}});return f.useEffect(()=>{var i;let n;try{n=window.matchMedia("(prefers-reduced-motion: reduce)")}catch{return}const r=l=>t(l.matches);return(i=n.addEventListener)==null||i.call(n,"change",r),()=>{var l;return(l=n.removeEventListener)==null?void 0:l.call(n,"change",r)}},[]),e}function De({children:e,at:t=0}){const n=e1(),[r,i]=f.useState(n||t===0);return f.useEffect(()=>{if(n){i(!0);return}const l=window.setTimeout(()=>i(!0),o3*t);return()=>window.clearTimeout(l)},[n,t]),r?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:e})}):s.jsx(ur,{})}function ur({line:e}){return s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[e,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})})}function Me({children:e}){return s.jsxs("div",{className:"meet-turn",children:[s.jsxs("div",{className:"wb-msg-who",children:[s.jsx(Y0,{size:"sm"}),s.jsx("span",{children:"buddi"})]}),e]})}const t1=f.createContext({body:null,actions:null});function n1({children:e,actions:t}){const n=f.useContext(t1),r=e==null?null:n.body?Di.createPortal(e,n.body):e,i=t==null?null:n.actions?Di.createPortal(t,n.actions):t;return s.jsxs(s.Fragment,{children:[r,i]})}function ya({text:e,onChange:t}){return s.jsxs("div",{className:"wb-msg","data-role":"user",children:[s.jsx("div",{className:"wb-bubble",children:e}),s.jsx("button",{type:"button",className:"meet-change",onClick:t,children:B.change})]})}function Rt({children:e,actions:t}){return s.jsx(n1,{actions:t?s.jsx("span",{className:"meet-actions",children:t}):null,children:e?s.jsx("div",{className:"meet-ask",children:e}):null})}function ku({onClick:e,disabled:t}){return s.jsxs(P,{variant:"ghost",onClick:e,disabled:t,children:[s.jsx(Oe,{name:"chevron-left"}),B.brain.back]})}function d3({navigate:e,timezone:t}){const[n,r]=f.useState(void 0);f.useEffect(()=>{R.session().then(oe=>r(oe.platform)).catch(()=>{})},[]);const[i,l]=f.useState({}),[o,a]=f.useState(null),[c,u]=f.useState(void 0),[p,d]=f.useState([]),[h,x]=f.useState(null),[v,w]=f.useState(null),[b,j]=f.useState(!1),[g,y]=f.useState(null),[m,k]=f.useState(null),[S,N]=f.useState(null),[C,T]=f.useState(null),E=f.useMemo(()=>({body:S,actions:C}),[S,C]),[_,F]=f.useState(null),[O,A]=f.useState(!1),D=f.useCallback(()=>A(!0),[]),[q,V]=f.useState(()=>OS()?"running":"idle"),M=f.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),z=f.useRef(e);z.current=e;const $=f.useCallback(async(oe=!0,be=!1)=>{var we,Je,lt,St,cn,Tn;const[ye,Te,Ve,it,H]=await Promise.all([R.onboarding().catch(()=>{}),R.owner().catch(()=>{}),R.providerAccounts().catch(()=>{}),Le.agents().catch(()=>{}),R.browser().catch(()=>{})]);u(Ve),d((Te==null?void 0:Te.zones)??[]),y(((we=ye==null?void 0:ye.details)==null?void 0:we.conversationId)??null);const me=(it==null?void 0:it.agents.find(Ft=>Ft.id===it.defaultAgentId))??(it==null?void 0:it.agents[0]);me&&x(me),k(ye&&!ye.needs.agent&&me?{id:me.id,name:me.name,avatar:((Je=me.avatar)==null?void 0:Je.kind)==="emoji"?me.avatar.value:"",description:me.description,...me.picture?{picture:me.picture}:{}}:null);const ue={onboarding:ye,owner:Te,accounts:Ve,browser:(lt=H==null?void 0:H.browser)==null?void 0:lt.engine,...me?{assistant:{id:me.id,name:me.name,avatar:((St=me.avatar)==null?void 0:St.kind)==="emoji"?me.avatar.value:""}}:{}},ke=_S(ue);if(be){const Ft=g4(ue);if(l(Ft.answers),a(Ft.open),!Ft.stay){const $s=(cn=ye==null?void 0:ye.details)==null?void 0:cn.conversationId;z.current($s&&me?Fe(me.id,$s):Vt,!0)}return}if(oe&&(ye==null?void 0:ye.state)==="done"){const Ft=(Tn=ye.details)==null?void 0:Tn.conversationId;z.current(Ft&&me?Fe(me.id,Ft):Vt,!0);return}oe&&(l(ke),a(Ft=>Ft??$h(ke)))},[]);f.useEffect(()=>{$()},[$]);const U=(oe,be={})=>{R.onboardingStep($S[oe],be).catch(()=>{})},X=(oe,be)=>{w(null),l(be),U(oe,oe==="brain"&&be.brain?{accountId:be.brain.accountId}:{}),a($h(be))},Z=oe=>{w(null),l(be=>m4(be,oe)),a(oe)},fe=()=>{j(!0),R.skipOnboarding().then(()=>e(Vt)).catch(oe=>w(oe instanceof de?oe.message:String(oe))).finally(()=>j(!1))},ve=q==="form"||q==="running"?[]:o?p4(i,o):[],Ne=f.useRef(null);return f.useEffect(()=>{const oe=Ne.current;if(!oe)return;const be=()=>{oe.scrollTop=oe.scrollHeight};be();let ye;try{ye=new ResizeObserver(be),oe.firstElementChild&&ye.observe(oe.firstElementChild)}catch{}return()=>ye==null?void 0:ye.disconnect()},[ve.length,o,i,v]),s.jsx(t1.Provider,{value:E,children:s.jsx("div",{className:"meet",children:s.jsxs("div",{className:"meet-stack",children:[s.jsxs("header",{className:"meet-head",children:[s.jsx("img",{className:"meet-head-mascot",src:vu("core"),alt:"","aria-hidden":"true"}),s.jsxs("span",{className:"meet-head-who",children:[s.jsx("span",{className:"meet-head-name",children:"buddi"}),s.jsx("span",{className:"meet-head-line",children:n===void 0||n==="darwin"?B.tagline:B.taglineElsewhere})]})]}),s.jsxs("div",{className:"meet-board",children:[s.jsx("div",{className:"meet-scroll thin-scroll",ref:Ne,children:s.jsxs("div",{className:"meet-thread","data-testid":"meet-thread",children:[s.jsx(Me,{children:B.opening.map((oe,be)=>s.jsx(De,{at:be,children:oe},oe))}),s.jsx(f3,{state:q,offered:o==="name"&&i.name===void 0,name:i.name,onState:V,onDone:()=>{V("idle"),$(!0,!0)},onTrouble:w}),ve.map(oe=>s.jsx(h3,{id:oe,openNow:o===oe,answers:i,accounts:c,zones:p,browserZone:M,assistantAgent:h,met:g,onMet:y,existing:m,navigate:e,onCarriesOn:F,onClosed:D,onSettled:be=>X(oe,be),onChange:()=>Z(oe),onTrouble:w,onReload:()=>void $(!1),onPickAnotherBrain:()=>Z("brain")},oe)),v?s.jsx(Me,{children:s.jsx(De,{children:v})}):null]})}),s.jsxs("footer",{className:"meet-dock",children:[s.jsx("div",{className:"meet-dock-ask",ref:N}),s.jsxs("div",{className:"meet-dock-row",children:[O?s.jsx("span",{}):_?s.jsx("a",{className:"meet-later",href:_,onClick:oe=>{oe.preventDefault(),e(_,!0)},children:B.done.open}):s.jsx("button",{className:"meet-later",type:"button",disabled:b,onClick:fe,children:B.later}),s.jsx("div",{className:"meet-dock-actions",ref:T})]})]})]})]})})})}function f3({state:e,offered:t,name:n,onState:r,onDone:i,onTrouble:l}){const[o,a]=f.useState(()=>OS()),[c,u]=f.useState([]),[p,d]=f.useState(!1),[h,x]=f.useState(null),[v,w]=f.useState(""),[b,j]=f.useState(!1);f.useEffect(()=>{if(!o)return;let m=!1;const k=()=>{R.backupJob(o).then(N=>{m||(u(C=>C.includes(N.phase)?C:[...C,N.phase]),N.phase==="done"?(m=!0,Ud(null),d(!0),i()):(N.phase==="rolled-back"||N.phase==="failed")&&(m=!0,Ud(null),a(null),l(N.error??B.restore.phases[N.phase]),r("idle")))}).catch(()=>{})};k();const S=window.setInterval(k,ZS);return()=>{m=!0,window.clearInterval(S)}},[o]);const g=()=>{!h||b||(j(!0),l(null),R.firstRunRestore(h,v.trim()).then(m=>{Ud(m.job.id),a(m.job.id),r("running")}).catch(m=>l(m instanceof de?m.message:String(m))).finally(()=>j(!1)))},y=c.filter(m=>m in B.restore.phases);return s.jsxs(s.Fragment,{children:[t&&e==="idle"&&!p?s.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:B.restore.offer}):null,e==="form"?s.jsxs(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>r("idle"),children:B.restore.cancel}),s.jsx(P,{variant:"accent",disabled:b||!h,onClick:g,children:B.restore.submit})]}),children:[s.jsx(te,{label:B.restore.file,grow:!0,children:s.jsx("input",{type:"file",onChange:m=>{var k;return x(((k=m.target.files)==null?void 0:k[0])??null)}})}),s.jsx(te,{label:B.restore.passphrase,hint:B.restore.passphraseHint,children:s.jsx("input",{type:"password",autoComplete:"off",value:v,onChange:m=>w(m.target.value)})})]}):null,e==="running"||p?s.jsxs(Me,{children:[s.jsx(De,{children:B.restore.started}),y.map(m=>s.jsx(De,{children:B.restore.phases[m]},m))]}):null,p?s.jsxs(Me,{children:[n?s.jsx(De,{children:B.restore.welcome(n)}):null,s.jsx(De,{children:B.restore.keys})]}):null]})}function h3(e){var l,o,a,c;const{id:t,openNow:n,answers:r,onChange:i}=e;if(t==="name")return s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{at:1,children:B.name.ask})}),n?s.jsx(p3,{...e}):s.jsx(ya,{text:r.name??"",onChange:i})]});if(t==="clock")return s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{at:1,children:B.clock.ask(r.name??"",r.clock??e.browserZone)})}),n?s.jsx(m3,{...e}):s.jsx(ya,{text:B.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{at:1,children:B.brain.ask})}),n?s.jsx(g3,{...e}):s.jsxs(s.Fragment,{children:[s.jsx(ya,{text:B.brain.answer(((l=r.brain)==null?void 0:l.label)??""),onChange:i}),s.jsx(Me,{children:s.jsx(De,{children:B.brain.works(((o=r.brain)==null?void 0:o.model)??"")})})]})]});if(t==="browser"){if(n)return s.jsx(A3,{...e});const u=E3(r.browser);return u?s.jsx(Me,{children:s.jsx(De,{children:u})}):null}return t==="assistant"?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{at:1,children:B.assistant.ask})}),n?s.jsx(T3,{...e}):s.jsx(ya,{text:`${((a=r.assistant)==null?void 0:a.avatar)??""} ${((c=r.assistant)==null?void 0:c.name)??""}`.trim(),onChange:i})]}):s.jsx(P3,{...e})}function p3({answers:e,onSettled:t,onTrouble:n}){const r=Co(),[i,l]=f.useState(e.name??""),[o,a]=f.useState(!1),c=()=>{const u=i.trim();u===""||o||(a(!0),R.setOwner({preferredName:u}).then(()=>t({...e,name:u})).catch(p=>n(p instanceof de?p.message:String(p))).finally(()=>a(!1)))};return s.jsx(Rt,{actions:s.jsx(P,{variant:"accent",disabled:o||i.trim()==="",onClick:c,children:B.name.submit}),children:s.jsx("input",{ref:r,className:"meet-input","aria-label":B.name.placeholder,placeholder:B.name.placeholder,maxLength:80,value:i,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function m3({answers:e,zones:t,browserZone:n,onSettled:r,onTrouble:i}){const[l,o]=f.useState(!1),[a,c]=f.useState(n),[u,p]=f.useState(!1),d=h=>{p(!0),R.setOwner({timezone:h}).then(()=>r({...e,clock:h})).catch(x=>i(x instanceof de?x.message:String(x))).finally(()=>p(!1))};return l?s.jsx(Rt,{actions:s.jsx(P,{variant:"accent",disabled:u,onClick:()=>d(a),children:B.clock.yes}),children:s.jsx("select",{className:"meet-input","aria-label":B.clock.label,value:a,onChange:h=>c(h.target.value),children:(t.includes(a)?t:[a,...t]).map(h=>s.jsx("option",{value:h,children:h},h))})}):s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>o(!0),children:B.clock.another}),s.jsx(P,{variant:"accent",disabled:u,onClick:()=>d(n),children:B.clock.yes})]})})}function g3(e){const{accounts:t,answers:n,onSettled:r,onReload:i}=e,[l,o]=f.useState(null),[a,c]=f.useState(null),[u,p]=f.useState(!1),[d,h]=f.useState(null),[x,v]=f.useState(null),w=(t==null?void 0:t.anthropicOAuthEnabled)===!0;f.useEffect(()=>{let y=!1;const m=()=>{R.ollama().then(S=>{y||h(S)}).catch(()=>{})};m();const k=window.setInterval(m,4e3);return()=>{y=!0,window.clearInterval(k)}},[]);const b=async y=>{if(n.assistant)try{await R.bindBrain({accountId:y.accountId,model:y.model})}catch(k){return k instanceof de?k.message:String(k)}return i(),r({...n,brain:y}),null},j=async(y,m)=>{p(!0),c(null);try{const k=await R.saveProviderAccount(y),S=await R.testProviderAccount(k.id);if(S.state!=="connected"){try{const C=(await R.providerAccounts()).accounts.find(T=>T.id===k.id);C&&await R.removeProviderAccount(k.id,C.revision)}catch{}c(S.message);return}const N=await b({accountId:k.id,label:m,model:y.defaultModel});N&&c(N)}catch(k){c(k instanceof de?k.message:String(k))}finally{p(!1)}},g=(y,m,k)=>{if(y.length<=1){j(m(y[0]??""),k);return}v({models:y,make:m,label:k})};return x?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{children:B.brain.model.ask})}),u?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.service})}):a?s.jsx(Me,{children:s.jsx(De,{children:a})}):null,s.jsx(w3,{busy:u,models:x.models,onUse:y=>void j(x.make(y),x.label)})]}):l==="key"?s.jsx(b3,{busy:u,problem:a,onBack:()=>o(null),onUse:j}):l==="service"?s.jsx(S3,{busy:u,problem:a,address:(d==null?void 0:d.cloudBaseUrl)??"",onBack:()=>o(null),onOffer:g}):l==="ollama"?s.jsx(k3,{busy:u,problem:a,probe:d,onBack:()=>o(null),onOffer:g}):l==="claude"?s.jsx(N3,{busy:u,problem:a,onBack:()=>o(null),onConnected:b,...e}):s.jsx(n1,{children:s.jsxs("div",{className:"meet-cards",role:"group","aria-label":B.brain.ask,children:[w?s.jsx(wa,{mark:s.jsx(x3,{}),card:B.brain.cards.claude,onPick:()=>o("claude")}):null,s.jsx(wa,{mark:s.jsx(v3,{}),card:B.brain.cards.key,onPick:()=>o("key")}),s.jsx(wa,{mark:s.jsx(j3,{}),card:B.brain.cards.ollama,note:d===null?B.brain.ollama.looking:d.running?B.brain.ollama.found:B.brain.ollama.missing,onPick:()=>o("ollama")}),s.jsx(wa,{mark:s.jsx(y3,{}),card:B.brain.cards.service,onPick:()=>o("service")})]})})}function wa({mark:e,card:t,note:n,onPick:r}){return s.jsxs("button",{type:"button",className:"meet-card",onClick:r,children:[s.jsx("span",{className:"meet-card-mark","aria-hidden":"true",children:e}),s.jsxs("span",{className:"meet-card-words",children:[s.jsx("span",{className:"meet-card-title",children:t.title}),s.jsx("span",{className:"meet-card-line",children:n??t.line})]})]})}function x3(){const e=[0,45,90,135,180,225,270,315];return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",children:e.map(t=>s.jsx("rect",{x:"11.1",y:"2.6",width:"1.8",height:"8.6",rx:"0.9",fill:"currentColor",transform:`rotate(${t} 12 12)`},t))})}function v3(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"8",cy:"8",r:"3.6"}),s.jsx("path",{d:"M10.6 10.6 19.4 19.4"}),s.jsx("path",{d:"M13.8 13.8 11.9 15.7"}),s.jsx("path",{d:"M16.6 16.6 14.7 18.5"})]})}function j3(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3.2",y:"4.6",width:"17.6",height:"11.2",rx:"2"}),s.jsx("path",{d:"M9.4 19.4h5.2"}),s.jsx("path",{d:"M12 15.8v3.6"})]})}function y3(){return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7.2 18.3h9.6a3.8 3.8 0 0 0 .5-7.6 5.4 5.4 0 0 0-10.3-1.2 3.9 3.9 0 0 0 .2 8.8Z"})})}function w3({busy:e,models:t,onUse:n}){const[r,i]=f.useState(t[0]??"");return s.jsx(Rt,{actions:s.jsx(P,{variant:"accent",disabled:e||r==="",onClick:()=>n(r),children:B.brain.model.submit}),children:s.jsx(te,{label:B.brain.model.label,grow:!0,children:s.jsx("select",{value:r,onChange:l=>i(l.target.value),children:t.map(l=>s.jsx("option",{value:l,children:l},l))})})})}function b3({busy:e,problem:t,onBack:n,onUse:r}){const i=Co(),[l,o]=f.useState(""),[a,c]=f.useState(null),[u,p]=f.useState(!1),d=e||u,h=a??x4(l),x=()=>{const v=l.trim();v===""||d||(p(!0),(async()=>{var b;let w=h==="anthropic"?"claude-sonnet-5":"gpt-5";try{w=((b=(await R.probeModels({kind:h,auth:"api-key",secret:v})).models.find(g=>g.isDefault))==null?void 0:b.id)??w}catch{}p(!1),await r({label:h==="anthropic"?B.brain.key.anthropic:B.brain.key.openai,kind:h,auth:"api-key",baseUrl:"",defaultModel:w,enabled:!0,secret:v},h==="anthropic"?B.brain.key.anthropic:B.brain.key.openai)})())};return s.jsxs(s.Fragment,{children:[d?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.key})}):t?s.jsx(Me,{children:s.jsx(De,{children:B.brain.key.refused})}):null,s.jsxs(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:n,disabled:d}),s.jsx(P,{variant:"accent",disabled:d||l.trim()==="",onClick:x,children:B.brain.key.submit})]}),children:[s.jsx(te,{label:B.brain.key.field,grow:!0,children:s.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:B.brain.key.placeholder,value:l,onChange:v=>o(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),x())}})}),s.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(h==="anthropic"?"openai":"anthropic"),children:[h==="anthropic"?B.brain.key.anthropic:B.brain.key.openai," · ",B.brain.key.which]})]})]})}function k3({busy:e,problem:t,probe:n,onBack:r,onOffer:i}){const l=(n==null?void 0:n.models)??[],o=()=>{n&&i(l,a=>({label:B.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:n.baseUrl,defaultModel:a,enabled:!0}),B.brain.cards.ollama.title)};return s.jsxs(s.Fragment,{children:[e?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.ollama})}):t?s.jsx(Me,{children:s.jsx(De,{children:t})}):null,s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:r,disabled:e}),n!=null&&n.running?s.jsx(P,{variant:"accent",disabled:e||l.length===0,onClick:o,children:B.brain.ollama.connect}):n?s.jsx(Bn,{variant:"accent",href:n.downloadUrl,target:"_blank",rel:"noreferrer",children:B.brain.ollama.download}):null]}),children:s.jsx("span",{className:"meet-line",children:n===null?B.brain.ollama.looking:n.running?B.brain.ollama.found:B.brain.ollama.missing})})]})}function S3({busy:e,problem:t,address:n,onBack:r,onOffer:i}){const l=Co(),[o,a]=f.useState(n),[c,u]=f.useState(""),[p,d]=f.useState(!1),h=e||p,x=()=>{o.trim()===""||h||(d(!0),(async()=>{var g;const v=c.trim()?"api-key":"none",w=y=>({label:B.brain.cards.service.title,kind:"openai-compatible",auth:v,baseUrl:o.trim(),defaultModel:y,enabled:!0,...c.trim()?{secret:c.trim()}:{}});let b=[],j;try{const y=await R.probeModels({kind:"openai-compatible",auth:v,baseUrl:o.trim(),...c.trim()?{secret:c.trim()}:{}});b=y.models.map(m=>m.id),j=(g=y.models.find(m=>m.isDefault))==null?void 0:g.id}catch{}d(!1),i(j?[j]:b,w,B.brain.cards.service.title)})())};return s.jsxs(s.Fragment,{children:[h?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.service})}):t?s.jsx(Me,{children:s.jsx(De,{children:t})}):null,s.jsxs(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:r,disabled:h}),s.jsx(P,{variant:"accent",disabled:h||o.trim()==="",onClick:x,children:B.brain.service.submit})]}),children:[s.jsx(te,{label:B.brain.service.address,grow:!0,children:s.jsx("input",{ref:l,value:o,placeholder:B.brain.service.addressPlaceholder,onChange:v=>a(v.target.value)})}),s.jsx(te,{label:B.brain.service.key,children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:c,onChange:v=>u(v.target.value)})})]})]})}function N3({busy:e,problem:t,onBack:n,onConnected:r,accounts:i}){const[l,o]=f.useState(!1),[a,c]=f.useState(null),[u,p]=f.useState(null),[d,h]=f.useState(""),x="claude-sonnet-5",v=()=>{o(!0),c(null),(async()=>{try{const b=((i==null?void 0:i.accounts)??[]).find(k=>k.auth==="anthropic-oauth"),j=b?{id:b.id}:await R.saveProviderAccount({label:B.brain.cards.claude.title,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:x,enabled:!0}),y=(await R.providerAccounts()).accounts.find(k=>k.id===j.id),m=await R.anthropicAccountAction(y.id,"login",y.revision);p({id:y.id,revision:y.revision+1,url:m.verificationUrl??"",attemptId:m.attemptId??""})}catch(b){c(b instanceof de?b.message:String(b))}finally{o(!1)}})()},w=()=>{!u||d.trim()===""||(o(!0),(async()=>{try{await R.anthropicAccountAction(u.id,"complete-login",u.revision,{attemptId:u.attemptId,code:d.trim()});const b=await R.testProviderAccount(u.id);if(b.state!=="connected"){c(b.message);return}c(await r({accountId:u.id,label:B.brain.cards.claude.title,model:x}))}catch(b){c(b instanceof de?b.message:String(b))}finally{o(!1)}})())};return s.jsxs(s.Fragment,{children:[l||e?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.claude})}):t??a?s.jsx(Me,{children:s.jsx(De,{children:t??a})}):null,u?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{children:B.brain.claude.waiting})}),s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(Bn,{href:u.url,target:"_blank",rel:"noreferrer",children:B.brain.claude.open}),s.jsx(P,{variant:"accent",disabled:l||d.trim()==="",onClick:w,children:B.brain.claude.finish})]}),children:s.jsx(te,{label:B.brain.claude.paste,grow:!0,children:s.jsx(C3,{value:d,onChange:h})})})]}):s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:n,disabled:e||l}),s.jsx(P,{variant:"accent",disabled:e||l,onClick:v,children:B.brain.claude.start})]})})]})}function C3({value:e,onChange:t}){const n=Co();return s.jsx("input",{ref:n,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function E3(e){switch(e){case"chrome":return B.browser.chrome;case"chromium":return B.browser.chromium;case"installed":return B.browser.installed;case"skipped":return B.browser.skipped;case"none":return B.browser.missing;default:return null}}function A3({answers:e,onSettled:t}){const[n,r]=f.useState("checking"),[i,l]=f.useState(null),[o,a]=f.useState(null),[c,u]=f.useState(void 0),[p,d]=f.useState(0),h=f.useRef(!1),x=f.useRef(!1),v=f.useRef(()=>{});if(v.current=b=>{x.current||(x.current=!0,t({...e,browser:b}))},f.useEffect(()=>{let b=!1,j;const g=S=>{b||v.current(S)},y=(S,N)=>{b||(h.current=!1,r("failed"),l(S),a(N??null))},m=async S=>{r("launching");let N;try{N=await R.browserCheck()}catch(C){return y(C instanceof de?C.message:String(C))}if(!b)return N.ok?g(h.current?"installed":S):y(N.message,N.command)},k=async()=>{var C,T;let S;try{S=await R.browser()}catch{return g("other")}if(b)return;const N=S.browser;if(!N)return g("other");if(((C=N.install)==null?void 0:C.state)==="running"){r("installing"),u(N.install.progress),j=window.setTimeout(()=>void k(),1e3);return}if(N.engine!=="none")return m(N.engine);if(h.current)return y(((T=N.install)==null?void 0:T.line)??"");h.current=!0,r("installing"),u(void 0);try{await R.browserInstall()}catch(E){return y(E instanceof de?E.message:String(E))}b||(j=window.setTimeout(()=>void k(),1e3))};return k(),()=>{b=!0,window.clearTimeout(j)}},[p]),n==="checking")return s.jsx(ur,{});const w=n==="installing"||n==="launching";return s.jsxs(s.Fragment,{children:[s.jsxs(Me,{children:[h.current||n==="installing"?s.jsx(De,{children:B.browser.needs}):null,n==="installing"?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:s.jsx(pk,{progress:c})})}):n==="launching"?s.jsx(ur,{line:B.browser.launching}):s.jsx(De,{children:B.browser.failed(i??"")})]}),s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>v.current("skipped"),children:B.browser.skip}),s.jsx(P,{variant:"accent",disabled:w,onClick:()=>{r("launching"),a(null),d(b=>b+1)},children:w?B.browser.installing:B.browser.retry})]}),children:n==="failed"&&o?s.jsx(R3,{command:o}):null})]})}function R3({command:e}){const[t,n]=f.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("failed");return}navigator.clipboard.writeText(e).then(()=>n("done"),()=>n("failed"))};return s.jsxs(G,{gap:"sm",children:[s.jsx(ut,{label:"The command to run",children:e}),s.jsxs(J,{align:"end",children:[t==="failed"?s.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,s.jsx(P,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function T3({answers:e,existing:t,onSettled:n,onTrouble:r,onReload:i}){const[l,o]=f.useState(()=>(t==null?void 0:t.name)??BD),[a,c]=f.useState(()=>t!=null&&t.picture?{kind:"kept",url:t.picture}:t!=null&&t.avatar?{kind:"emoji",value:t.avatar}:{kind:"mascot",role:"core"}),[u,p]=f.useState(t?null:B.assistant.purposeValue),[d,h]=f.useState(t?"":B.assistant.purposeValue);f.useEffect(()=>{if(!t)return;let b=!1;return R.firstAgentPersona().then(j=>{b||(p(j.persona),h(j.persona))},j=>{b||r(j instanceof de?j.message:String(j))}),()=>{b=!0}},[t==null?void 0:t.id]);const[x,v]=f.useState(!1),w=()=>{if(l.trim()===""||x)return;v(!0);const b=a.kind==="emoji"?{avatar:a.value}:{},j=!t||u!==null&&d.trim()!==""&&d.trim()!==u.trim()?{instructions:d.trim()}:{},g=t?R.updateFirstAgent({name:l.trim(),...j,...b}):R.createFirstAgent({name:l.trim(),handle:v4(l),description:"",...j,...b,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let y;try{y=await g}catch(k){r(k instanceof de?k.message:String(k)),v(!1);return}let m=null;try{a.kind==="mascot"?await R.uploadAgentPicture(y.id,await nS(a.role)):a.kind==="emoji"&&(t!=null&&t.picture)&&await R.removeAgentPicture(y.id)}catch(k){m=k instanceof de?k.message:String(k)}v(!1),i(),n({...e,assistant:{id:y.id,name:l.trim(),avatar:a.kind==="emoji"?a.value:""}}),m&&r(m)})()};return s.jsxs(Rt,{actions:s.jsx(P,{variant:"accent",disabled:x||l.trim()===""||u===null,onClick:w,children:B.assistant.submit}),children:[s.jsx("span",{className:"meet-chosen-face","data-kind":a.kind==="emoji"?"emoji":"image","aria-hidden":"true",children:a.kind==="emoji"?a.value:s.jsx("img",{src:a.kind==="mascot"?vu(a.role):a.url,alt:""})}),s.jsx(te,{label:B.assistant.name,children:s.jsx("input",{value:l,maxLength:60,onChange:b=>o(b.target.value)})}),s.jsx(sS,{face:a,onPick:c}),s.jsx(te,{label:B.assistant.purpose,wide:!0,children:s.jsx("textarea",{className:"meet-purpose",value:d,maxLength:8e3,rows:Math.max(4,d.split(`
123
- `).length+1),onChange:b=>h(b.target.value)})})]})}function P3({answers:e,assistantAgent:t,met:n,onMet:r,onCarriesOn:i,onClosed:l,navigate:o,onPickAnotherBrain:a}){const c=e.assistant,[u,p]=f.useState(n),[d,h]=f.useState([]),[x,v]=f.useState(!1),[w,b]=f.useState(!1),[j,g]=f.useState(!0),[y,m]=f.useState("open"),[k,S]=f.useState(!1),N=e1(),C=f.useRef(!1),T=f.useMemo(()=>t?[t]:[],[t]);f.useEffect(()=>{if(!c||C.current)return;if(C.current=!0,n){p(n);return}let O=!1;return(async()=>{try{const A=await Le.startConversation(c.id);if(O)return;p(A.conversationId),r(A.conversationId),await R.onboardingStep($S.handover,{conversationId:A.conversationId}).catch(()=>{}),await Le.send(c.id,{conversationId:A.conversationId,text:VD,opening:!0})}catch{O||(g(!1),v(!0))}})(),()=>{O=!0}},[c==null?void 0:c.id,n]),f.useEffect(()=>{if(!u)return;let O=!1;const A=Date.now(),D=()=>{Le.conversation(u).then(V=>{if(O)return;h(V.messages);const M=Date.now()-A;if(V.messages.some(uj)){g(!1),v(!1),b(!1);return}const z=V.runs??[],$=z.some(X=>X.finishedAt===null),U=z.length>0&&!$;b($&&M>=a3),(U||M>=c3)&&(g(!1),v(!0))}).catch(()=>{})};D();const q=window.setInterval(D,ZS);return()=>{O=!0,window.clearInterval(q)}},[u]);const E=c&&u?Fe(c.id,u):null,_=d.some(uj);f.useEffect(()=>{_&&E&&i(E)},[_,E,i]),f.useEffect(()=>{if(!k||!E||N)return;const O=window.setTimeout(()=>o(E,!0),u3);return()=>window.clearTimeout(O)},[k,E,N,o]);const F=k&&E!==null;return f.useEffect(()=>{F&&l()},[F,l]),s.jsxs(s.Fragment,{children:[s.jsx(uk,{messages:d,live:[],now:Date.now(),onOpen:()=>{},working:j,agents:T,agentName:(c==null?void 0:c.name)??"",emptyHint:B.handover.waiting,plain:!0,workingLine:B.handover.looking((c==null?void 0:c.name)??"")}),w&&!x?s.jsx(Me,{children:s.jsx(De,{children:B.handover.slow})}):null,x?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{children:B.handover.silent})}),s.jsx(Rt,{actions:s.jsx(P,{variant:"accent",onClick:a,children:B.handover.again})})]}):null,k?s.jsx(Me,{children:s.jsx(De,{children:B.done.said})}):null,_&&y==="open"?s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{onClick:()=>m("phone"),children:B.offers.phone}),s.jsx(P,{variant:"accent",onClick:()=>{m("gone"),S(!0)},children:B.offers.notNow})]})}):null,_&&y==="phone"?s.jsx(I3,{onPaired:()=>S(!0),onDismiss:()=>{m("gone"),S(!0)}}):null,F&&E?s.jsx(Rt,{actions:s.jsx(Bn,{variant:"accent",href:E,onClick:O=>{O.preventDefault(),o(E,!0)},children:B.done.open}),children:s.jsx("span",{className:"meet-line",children:N?B.done.ready:B.done.leaving})}):null]})}function uj(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function I3({onPaired:e,onDismiss:t}){const n=Co(),[r,i]=f.useState(""),[l,o]=f.useState(!1),[a,c]=f.useState(null),[u,p]=f.useState(null),[d,h]=f.useState(null),[x,v]=f.useState(!1),[w,b]=f.useState(!1),j=async()=>{const m=await R.telegramPairing();p(m),b(!1),h(await l3(m.link).catch(()=>""))},g=()=>{r.trim()===""||l||(o(!0),c(null),(async()=>{try{const m=await R.saveTelegramToken(r.trim());if(i(""),m.restartNeeded){c(m.note??B.telegram.restart);return}await j()}catch(m){c(m instanceof de?m.message:String(m))}finally{o(!1)}})())},y=()=>{c(null),j().catch(m=>c(m instanceof de?m.message:String(m)))};return f.useEffect(()=>{if(!u||x||w)return;let m=!1;const k=Math.min(Date.parse(u.expiresAt)||Date.now()+cj,Date.now()+cj),S=window.setInterval(()=>{if(Date.now()>=k){b(!0);return}R.telegram().then(N=>{m||!N.paired||(v(!0),e())}).catch(()=>{})},2e3);return()=>{m=!0,window.clearInterval(S)}},[u,x,w]),x?s.jsx(Me,{children:s.jsx(De,{children:B.telegram.paired})}):u?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(De,{children:w?B.telegram.expired:B.telegram.scan})}),s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:t,children:B.offers.notNow}),w?s.jsx(P,{variant:"accent",onClick:y,children:B.telegram.newCode}):null]}),children:w?null:s.jsxs("div",{className:"meet-pair",children:[d?s.jsx("img",{className:"meet-qr",src:d,alt:u.link}):null,s.jsx("a",{className:"meet-link",href:u.link,target:"_blank",rel:"noreferrer",children:u.link})]})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Me,{children:[s.jsx(De,{children:B.telegram.how}),a?s.jsx(De,{children:a}):null]}),s.jsx(Rt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:t,children:B.offers.notNow}),s.jsx(P,{variant:"accent",disabled:l||r.trim()==="",onClick:g,children:B.telegram.submit})]}),children:s.jsx(te,{label:B.telegram.field,grow:!0,children:s.jsx("input",{ref:n,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),g())}})})})]})}const M3="(max-width: 1080px)";function $3(){const[e,t]=f.useState(()=>window.location.hash||Vt);f.useEffect(()=>{const r=()=>t(window.location.hash||Vt);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const n=f.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,n]}function _3(){const[e,t]=Hk();f.useEffect(()=>{Vk(e)},[e]);const n=f.useCallback(r=>t({theme:r}),[t]);return[e.theme,n]}function O3(){var H,me;const[e,t]=$3(),[n,r]=f.useState("UTC"),[i,l]=f.useState({approvals:0,failed:0}),[o,a]=_3(),c=Th(aS),[u,p]=f.useState(!1),[d,h]=f.useState([]),[x,v]=f.useState(null),[w,b]=f.useState(null),[j,g]=f.useState([]),[y,m]=f.useState(!1),[k,S]=f.useState(null),N=_2(),C=Th(M3),T=cS(),E=Dk(),_=se(()=>Promise.resolve().then(()=>R.version()),[],60*6e4).data,F=_&&!_.checkout&&_.updateAvailable?_:null,[O,A]=f.useState(new Map);f.useEffect(()=>{const ue=()=>{R.conversations().then(we=>{const Je=new Map;for(const lt of we.conversations){const St=lt.lastMessageAt??lt.createdAt,cn=Je.get(lt.agentId);(!cn||St>cn)&&Je.set(lt.agentId,St)}A(Je)}).catch(()=>{})};ue();const ke=window.setInterval(ue,3e4);return()=>window.clearInterval(ke)},[e]);const[D,q]=f.useState(!1);f.useEffect(()=>{if(D)return;let ue=!1;return R.onboarding().then(ke=>{ue||(q(!0),ke.state==="pending"&&ke.needs.model&&!ov(window.location.hash)&&t(a2,!0))}).catch(()=>{ue||q(!0)}),()=>{ue=!0}},[D,t]),f.useEffect(()=>{const ue=w2(e);ue&&t(ue,!0)},[e,t]),f.useEffect(()=>{let ue=!1;const ke=()=>{Le.agents().then(Je=>{ue||(h(Je.agents),E2(Je.defaultAgentId??null),v(Je.defaultAgentId??null),b(lt=>{var St;return lt??Je.defaultAgentId??((St=Je.agents[0])==null?void 0:St.id)??null}))}).catch(()=>{})};ke();const we=window.setInterval(ke,15e3);return window.addEventListener("focus",ke),window.addEventListener(io,ke),()=>{ue=!0,window.clearInterval(we),window.removeEventListener("focus",ke),window.removeEventListener(io,ke)}},[e]),f.useEffect(()=>{let ue=!1;const ke=()=>{Le.groups().then(Je=>{ue||g(Je.groups)}).catch(()=>{})};ke();const we=window.setInterval(ke,3e4);return()=>{ue=!0,window.clearInterval(we)}},[e]);const V=A0(d,x),M=u2(e),z=S0(e),$=z?j.find(ue=>ue.id===z.groupId)??null:null,U=z?null:(M==null?void 0:M.agentId)??w;f.useEffect(()=>{M&&b(M.agentId)},[M==null?void 0:M.agentId]);const X=ue=>{b(ue),t(Fe(ue))},Z=ue=>t(Dl(ue)),fe=f.useCallback((ue,ke,we=!0)=>t(z?Dl(z.groupId,ke):Fe(ue,ke),we),[t,z==null?void 0:z.groupId]),[ve,Ne]=f.useState(!1);f.useEffect(()=>{R.session().then(ue=>{r(ue.timezone),Ne(!0)}).catch(()=>{})},[]);const oe=fO(ve);xO(ve,oe.refresh,()=>Ne(!1)),f.useEffect(()=>{const ue=()=>{R.overview().then(we=>l({approvals:we.approvals.pending,failed:we.jobs.failed??0})).catch(()=>{})};ue();const ke=window.setInterval(ue,2e4);return()=>window.clearInterval(ke)},[]);const be=ov(e),ye=b2(e),Te=ye===Fi,Ve=k?j.find(ue=>ue.id===k)??null:null,it=y?s.jsx(Bv,{agents:d,onClose:()=>m(!1),onCreated:ue=>{g(ke=>[...ke,ue]),m(!1),t(Dl(ue.id))}}):Ve?s.jsx(Bv,{agents:d,group:Ve,onClose:()=>S(null),onSaved:ue=>{g(ke=>ke.map(we=>we.id===ue.id?ue:we)),S(null)},onArchived:ue=>{g(ke=>ke.filter(we=>we.id!==ue)),S(null),t(Fi)}}):null;return be?s.jsx(Yx,{delayDuration:400,children:s.jsxs(_x,{swipeDirection:"right",children:[s.jsx(d3,{navigate:t,timezone:n}),s.jsx(Ox,{className:"ui-toasts"})]})}):s.jsx(q2,{picture:(H=d.find(ue=>ue.id===x))==null?void 0:H.picture,children:s.jsx(Yx,{delayDuration:400,children:s.jsxs(_x,{swipeDirection:"right",children:[it,s.jsxs("div",{className:"wb-shell",children:[s.jsx(NL,{active:((me=T.data)==null?void 0:me.active)===!0,onNavigate:t}),s.jsxs("div",{className:"wb",children:[s.jsx(sD,{attention:i.approvals+i.failed,place:ye,onNavigate:t,theme:o,onTheme:a,plugins:E.rail,updateAvailable:F!==null,version:_&&!_.checkout?{current:_.current,latest:_.latest,updateAvailable:_.updateAvailable}:_?{current:_.current,updateAvailable:!1}:void 0}),Te&&!C?s.jsx($0,{agents:V,currentId:U,attention:N,onSelect:X,lastActivity:O,groups:j,currentGroupId:($==null?void 0:$.id)??null,onSelectGroup:Z,onNewGroup:()=>m(!0)}):null,Te?s.jsx(eO,{timezone:n,agents:V,agentId:$?$.coordinator:U,defaultAgentId:x,group:$,onEditGroup:$?()=>S($.id):void 0,requestedConversationId:(z==null?void 0:z.conversationId)??(M==null?void 0:M.conversationId),requestedTab:M==null?void 0:M.tab,onConversationOpened:fe,onSelectAgent:X,attention:N,agentsInHeader:C,narrow:c,canvasOpen:u,onOpenCanvas:()=>p(!0),onCloseCanvas:()=>p(!1)}):s.jsx("main",{"data-ground":D3(ye,e)?"plain":void 0,"data-layout":ye===Qt?"split":void 0,children:s.jsx(L3,{hash:e,place:ye,timezone:n,navigate:t,agents:d,defaultAgentId:x,attention:N,pluginPages:E,update:F})})]})]}),s.jsx(hO,{queue:oe.queue,agents:d,navigate:t,onDismiss:oe.dismiss}),s.jsx(Ox,{className:"ui-toasts"})]})})})}function D3(e,t){return fm(t)!==null}function L3({place:e,pluginPages:t,...n}){const r={...n,pluginPages:t},i=fm(n.hash);if(i){const l=t.find(i.plugin,i.page);if(l)return s.jsx(Ok,{page:l,item:i.item??null,navigate:n.navigate,timezone:n.timezone,siblings:t.all.filter(o=>o.plugin===i.plugin)});if(t.all.length===0)return s.jsx(s.Fragment,{})}switch(e){case et:return s.jsx(iL,{...n});case Ze:return s.jsx(jD,{...n});case Qt:return s.jsx(KF,{...r});case Lr:return s.jsx(ZO,{...n});default:return s.jsx(cL,{...n})}}const dj=document.getElementById("root");dj&&Sw(dj).render(s.jsx(f.StrictMode,{children:s.jsx(O3,{})}));