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

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 (1275) hide show
  1. package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
  2. package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
  3. package/node_modules/@buddi/cli/dist/commands.js +5 -2
  4. package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
  5. package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
  6. package/node_modules/@buddi/core/dist/actions/permissions.d.ts +14 -0
  7. package/node_modules/@buddi/core/dist/actions/permissions.d.ts.map +1 -1
  8. package/node_modules/@buddi/core/dist/actions/permissions.js +15 -0
  9. package/node_modules/@buddi/core/dist/actions/permissions.js.map +1 -1
  10. package/node_modules/@buddi/core/dist/agents/catalog.d.ts +12 -1
  11. package/node_modules/@buddi/core/dist/agents/catalog.d.ts.map +1 -1
  12. package/node_modules/@buddi/core/dist/agents/catalog.js +57 -6
  13. package/node_modules/@buddi/core/dist/agents/catalog.js.map +1 -1
  14. package/node_modules/@buddi/core/dist/agents/delegates.d.ts +54 -0
  15. package/node_modules/@buddi/core/dist/agents/delegates.d.ts.map +1 -0
  16. package/node_modules/@buddi/core/dist/agents/delegates.js +51 -0
  17. package/node_modules/@buddi/core/dist/agents/delegates.js.map +1 -0
  18. package/node_modules/@buddi/core/dist/agents/index.d.ts +1 -0
  19. package/node_modules/@buddi/core/dist/agents/index.d.ts.map +1 -1
  20. package/node_modules/@buddi/core/dist/agents/index.js +1 -0
  21. package/node_modules/@buddi/core/dist/agents/index.js.map +1 -1
  22. package/node_modules/@buddi/core/dist/host/build.d.ts +26 -5
  23. package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
  24. package/node_modules/@buddi/core/dist/host/build.js +72 -0
  25. package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
  26. package/node_modules/@buddi/core/dist/host/types.d.ts +67 -5
  27. package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
  28. package/node_modules/@buddi/core/dist/index.d.ts +1 -0
  29. package/node_modules/@buddi/core/dist/index.d.ts.map +1 -1
  30. package/node_modules/@buddi/core/dist/index.js +1 -0
  31. package/node_modules/@buddi/core/dist/index.js.map +1 -1
  32. package/node_modules/@buddi/core/dist/json-schema.d.ts +32 -0
  33. package/node_modules/@buddi/core/dist/json-schema.d.ts.map +1 -0
  34. package/node_modules/@buddi/core/dist/json-schema.js +147 -0
  35. package/node_modules/@buddi/core/dist/json-schema.js.map +1 -0
  36. package/node_modules/@buddi/core/dist/learning/sources.d.ts.map +1 -1
  37. package/node_modules/@buddi/core/dist/learning/sources.js +3 -0
  38. package/node_modules/@buddi/core/dist/learning/sources.js.map +1 -1
  39. package/node_modules/@buddi/core/dist/learning/types.d.ts +4 -3
  40. package/node_modules/@buddi/core/dist/learning/types.d.ts.map +1 -1
  41. package/node_modules/@buddi/core/dist/learning/types.js +1 -1
  42. package/node_modules/@buddi/core/dist/learning/types.js.map +1 -1
  43. package/node_modules/@buddi/core/dist/notifications/index.d.ts +1 -0
  44. package/node_modules/@buddi/core/dist/notifications/index.d.ts.map +1 -1
  45. package/node_modules/@buddi/core/dist/notifications/index.js +1 -0
  46. package/node_modules/@buddi/core/dist/notifications/index.js.map +1 -1
  47. package/node_modules/@buddi/core/dist/notifications/notify.d.ts.map +1 -1
  48. package/node_modules/@buddi/core/dist/notifications/notify.js +47 -5
  49. package/node_modules/@buddi/core/dist/notifications/notify.js.map +1 -1
  50. package/node_modules/@buddi/core/dist/notifications/store.d.ts.map +1 -1
  51. package/node_modules/@buddi/core/dist/notifications/store.js +3 -1
  52. package/node_modules/@buddi/core/dist/notifications/store.js.map +1 -1
  53. package/node_modules/@buddi/core/dist/notifications/topic.d.ts +25 -0
  54. package/node_modules/@buddi/core/dist/notifications/topic.d.ts.map +1 -0
  55. package/node_modules/@buddi/core/dist/notifications/topic.js +116 -0
  56. package/node_modules/@buddi/core/dist/notifications/topic.js.map +1 -0
  57. package/node_modules/@buddi/core/dist/notifications/types.d.ts +4 -0
  58. package/node_modules/@buddi/core/dist/notifications/types.d.ts.map +1 -1
  59. package/node_modules/@buddi/core/dist/onboarding/language-tag.d.ts +12 -0
  60. package/node_modules/@buddi/core/dist/onboarding/language-tag.d.ts.map +1 -0
  61. package/node_modules/@buddi/core/dist/onboarding/language-tag.js +64 -0
  62. package/node_modules/@buddi/core/dist/onboarding/language-tag.js.map +1 -0
  63. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts +11 -0
  64. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  65. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js +23 -1
  66. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js.map +1 -1
  67. package/node_modules/@buddi/core/dist/pages.d.ts +19 -0
  68. package/node_modules/@buddi/core/dist/pages.d.ts.map +1 -1
  69. package/node_modules/@buddi/core/dist/pages.js +13 -0
  70. package/node_modules/@buddi/core/dist/pages.js.map +1 -1
  71. package/node_modules/@buddi/core/dist/plugin/index.d.ts +4 -3
  72. package/node_modules/@buddi/core/dist/plugin/index.d.ts.map +1 -1
  73. package/node_modules/@buddi/core/dist/plugin/version.d.ts +1 -1
  74. package/node_modules/@buddi/core/dist/plugin/version.js +1 -1
  75. package/node_modules/@buddi/core/dist/provider-accounts.d.ts +31 -0
  76. package/node_modules/@buddi/core/dist/provider-accounts.d.ts.map +1 -1
  77. package/node_modules/@buddi/core/dist/registry.d.ts +37 -1
  78. package/node_modules/@buddi/core/dist/registry.d.ts.map +1 -1
  79. package/node_modules/@buddi/core/dist/registry.js +187 -32
  80. package/node_modules/@buddi/core/dist/registry.js.map +1 -1
  81. package/node_modules/@buddi/core/dist/secrets/scrub.d.ts +2 -0
  82. package/node_modules/@buddi/core/dist/secrets/scrub.d.ts.map +1 -1
  83. package/node_modules/@buddi/core/dist/secrets/scrub.js +29 -0
  84. package/node_modules/@buddi/core/dist/secrets/scrub.js.map +1 -1
  85. package/node_modules/@buddi/core/dist/tools.d.ts +36 -1
  86. package/node_modules/@buddi/core/dist/tools.d.ts.map +1 -1
  87. package/node_modules/@buddi/core/dist/tools.js.map +1 -1
  88. package/node_modules/@buddi/core/dist/views.d.ts +12 -12
  89. package/node_modules/@buddi/core/migrations/050_notification_topic.sql +8 -0
  90. package/node_modules/@buddi/core/package.json +2 -0
  91. package/node_modules/@buddi/gateway/assets/mascot/core-idle.tgs +0 -0
  92. package/node_modules/@buddi/gateway/assets/mascot/core-working.tgs +0 -0
  93. package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
  94. package/node_modules/@buddi/gateway/dist/agents/canvas.d.ts +2 -2
  95. package/node_modules/@buddi/gateway/dist/agents/canvas.d.ts.map +1 -1
  96. package/node_modules/@buddi/gateway/dist/agents/canvas.js.map +1 -1
  97. package/node_modules/@buddi/gateway/dist/agents/catalog.d.ts.map +1 -1
  98. package/node_modules/@buddi/gateway/dist/agents/catalog.js +15 -6
  99. package/node_modules/@buddi/gateway/dist/agents/catalog.js.map +1 -1
  100. package/node_modules/@buddi/gateway/dist/agents/delegation.d.ts +20 -3
  101. package/node_modules/@buddi/gateway/dist/agents/delegation.d.ts.map +1 -1
  102. package/node_modules/@buddi/gateway/dist/agents/delegation.js +38 -12
  103. package/node_modules/@buddi/gateway/dist/agents/delegation.js.map +1 -1
  104. package/node_modules/@buddi/gateway/dist/agents/platform.d.ts +43 -13
  105. package/node_modules/@buddi/gateway/dist/agents/platform.d.ts.map +1 -1
  106. package/node_modules/@buddi/gateway/dist/agents/platform.js +97 -3
  107. package/node_modules/@buddi/gateway/dist/agents/platform.js.map +1 -1
  108. package/node_modules/@buddi/gateway/dist/agents/starter-team.d.ts +57 -0
  109. package/node_modules/@buddi/gateway/dist/agents/starter-team.d.ts.map +1 -0
  110. package/node_modules/@buddi/gateway/dist/agents/starter-team.js +151 -0
  111. package/node_modules/@buddi/gateway/dist/agents/starter-team.js.map +1 -0
  112. package/node_modules/@buddi/gateway/dist/anthropic-accounts.d.ts.map +1 -1
  113. package/node_modules/@buddi/gateway/dist/anthropic-accounts.js +9 -20
  114. package/node_modules/@buddi/gateway/dist/anthropic-accounts.js.map +1 -1
  115. package/node_modules/@buddi/gateway/dist/bootstrap.d.ts +3 -0
  116. package/node_modules/@buddi/gateway/dist/bootstrap.d.ts.map +1 -1
  117. package/node_modules/@buddi/gateway/dist/bootstrap.js +58 -2
  118. package/node_modules/@buddi/gateway/dist/bootstrap.js.map +1 -1
  119. package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts +7 -1
  120. package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts.map +1 -1
  121. package/node_modules/@buddi/gateway/dist/codex-accounts.js +25 -26
  122. package/node_modules/@buddi/gateway/dist/codex-accounts.js.map +1 -1
  123. package/node_modules/@buddi/gateway/dist/mcp/requests.d.ts +8 -1
  124. package/node_modules/@buddi/gateway/dist/mcp/requests.d.ts.map +1 -1
  125. package/node_modules/@buddi/gateway/dist/mcp/requests.js +8 -1
  126. package/node_modules/@buddi/gateway/dist/mcp/requests.js.map +1 -1
  127. package/node_modules/@buddi/gateway/dist/missions/goals-page.d.ts.map +1 -1
  128. package/node_modules/@buddi/gateway/dist/missions/goals-page.js +57 -0
  129. package/node_modules/@buddi/gateway/dist/missions/goals-page.js.map +1 -1
  130. package/node_modules/@buddi/gateway/dist/plugins/approve.js +45 -9
  131. package/node_modules/@buddi/gateway/dist/plugins/approve.js.map +1 -1
  132. package/node_modules/@buddi/gateway/dist/plugins/load.d.ts.map +1 -1
  133. package/node_modules/@buddi/gateway/dist/plugins/load.js +4 -0
  134. package/node_modules/@buddi/gateway/dist/plugins/load.js.map +1 -1
  135. package/node_modules/@buddi/gateway/dist/plugins/npm.d.ts +5 -1
  136. package/node_modules/@buddi/gateway/dist/plugins/npm.d.ts.map +1 -1
  137. package/node_modules/@buddi/gateway/dist/plugins/npm.js +6 -0
  138. package/node_modules/@buddi/gateway/dist/plugins/npm.js.map +1 -1
  139. package/node_modules/@buddi/gateway/dist/plugins/scaffold.d.ts +15 -4
  140. package/node_modules/@buddi/gateway/dist/plugins/scaffold.d.ts.map +1 -1
  141. package/node_modules/@buddi/gateway/dist/plugins/scaffold.js +86 -16
  142. package/node_modules/@buddi/gateway/dist/plugins/scaffold.js.map +1 -1
  143. package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts +35 -1
  144. package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts.map +1 -1
  145. package/node_modules/@buddi/gateway/dist/plugins/stage.js +134 -8
  146. package/node_modules/@buddi/gateway/dist/plugins/stage.js.map +1 -1
  147. package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts +5 -1
  148. package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts.map +1 -1
  149. package/node_modules/@buddi/gateway/dist/plugins-cli.js +26 -4
  150. package/node_modules/@buddi/gateway/dist/plugins-cli.js.map +1 -1
  151. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
  152. package/node_modules/@buddi/gateway/dist/provider-accounts.js +31 -3
  153. package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
  154. package/node_modules/@buddi/gateway/dist/provider-diagnostics.d.ts +14 -2
  155. package/node_modules/@buddi/gateway/dist/provider-diagnostics.d.ts.map +1 -1
  156. package/node_modules/@buddi/gateway/dist/provider-diagnostics.js +25 -9
  157. package/node_modules/@buddi/gateway/dist/provider-diagnostics.js.map +1 -1
  158. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts +49 -0
  159. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts.map +1 -1
  160. package/node_modules/@buddi/gateway/dist/telegram/api.js +99 -0
  161. package/node_modules/@buddi/gateway/dist/telegram/api.js.map +1 -1
  162. package/node_modules/@buddi/gateway/dist/telegram/main.d.ts.map +1 -1
  163. package/node_modules/@buddi/gateway/dist/telegram/main.js +17 -0
  164. package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
  165. package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts +5 -0
  166. package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts.map +1 -1
  167. package/node_modules/@buddi/gateway/dist/telegram/outbound.js +10 -0
  168. package/node_modules/@buddi/gateway/dist/telegram/outbound.js.map +1 -1
  169. package/node_modules/@buddi/gateway/dist/telegram/stickers.d.ts +30 -0
  170. package/node_modules/@buddi/gateway/dist/telegram/stickers.d.ts.map +1 -0
  171. package/node_modules/@buddi/gateway/dist/telegram/stickers.js +146 -0
  172. package/node_modules/@buddi/gateway/dist/telegram/stickers.js.map +1 -0
  173. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +6 -0
  174. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
  175. package/node_modules/@buddi/gateway/dist/telegram/surface.js +36 -3
  176. package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
  177. package/node_modules/@buddi/gateway/dist/tips/engine.d.ts +75 -0
  178. package/node_modules/@buddi/gateway/dist/tips/engine.d.ts.map +1 -0
  179. package/node_modules/@buddi/gateway/dist/tips/engine.js +135 -0
  180. package/node_modules/@buddi/gateway/dist/tips/engine.js.map +1 -0
  181. package/node_modules/@buddi/gateway/dist/tips/facts.d.ts +69 -0
  182. package/node_modules/@buddi/gateway/dist/tips/facts.d.ts.map +1 -0
  183. package/node_modules/@buddi/gateway/dist/tips/facts.js +104 -0
  184. package/node_modules/@buddi/gateway/dist/tips/facts.js.map +1 -0
  185. package/node_modules/@buddi/gateway/dist/tips/route.d.ts +25 -0
  186. package/node_modules/@buddi/gateway/dist/tips/route.d.ts.map +1 -0
  187. package/node_modules/@buddi/gateway/dist/tips/route.js +96 -0
  188. package/node_modules/@buddi/gateway/dist/tips/route.js.map +1 -0
  189. package/node_modules/@buddi/gateway/dist/tips/rules.d.ts +33 -0
  190. package/node_modules/@buddi/gateway/dist/tips/rules.d.ts.map +1 -0
  191. package/node_modules/@buddi/gateway/dist/tips/rules.js +54 -0
  192. package/node_modules/@buddi/gateway/dist/tips/rules.js.map +1 -0
  193. package/node_modules/@buddi/gateway/dist/web/agent-offers.d.ts +30 -0
  194. package/node_modules/@buddi/gateway/dist/web/agent-offers.d.ts.map +1 -1
  195. package/node_modules/@buddi/gateway/dist/web/agent-offers.js +64 -1
  196. package/node_modules/@buddi/gateway/dist/web/agent-offers.js.map +1 -1
  197. package/node_modules/@buddi/gateway/dist/web/connections.d.ts +83 -0
  198. package/node_modules/@buddi/gateway/dist/web/connections.d.ts.map +1 -0
  199. package/node_modules/@buddi/gateway/dist/web/connections.js +270 -0
  200. package/node_modules/@buddi/gateway/dist/web/connections.js.map +1 -0
  201. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +1 -1
  202. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
  203. package/node_modules/@buddi/gateway/dist/web/onboarding.js +5 -4
  204. package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
  205. package/node_modules/@buddi/gateway/dist/web/plugins.d.ts +12 -0
  206. package/node_modules/@buddi/gateway/dist/web/plugins.d.ts.map +1 -1
  207. package/node_modules/@buddi/gateway/dist/web/plugins.js +12 -2
  208. package/node_modules/@buddi/gateway/dist/web/plugins.js.map +1 -1
  209. package/node_modules/@buddi/gateway/dist/web/profile.js +3 -2
  210. package/node_modules/@buddi/gateway/dist/web/profile.js.map +1 -1
  211. package/node_modules/@buddi/gateway/dist/web/read.d.ts +6 -0
  212. package/node_modules/@buddi/gateway/dist/web/read.d.ts.map +1 -1
  213. package/node_modules/@buddi/gateway/dist/web/read.js +11 -4
  214. package/node_modules/@buddi/gateway/dist/web/read.js.map +1 -1
  215. package/node_modules/@buddi/gateway/dist/web/server.d.ts +6 -0
  216. package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
  217. package/node_modules/@buddi/gateway/dist/web/server.js +71 -2
  218. package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
  219. package/node_modules/@buddi/gateway/dist/web/static.d.ts.map +1 -1
  220. package/node_modules/@buddi/gateway/dist/web/static.js +1 -0
  221. package/node_modules/@buddi/gateway/dist/web/static.js.map +1 -1
  222. package/node_modules/@buddi/gateway/dist/web/version.d.ts +2 -0
  223. package/node_modules/@buddi/gateway/dist/web/version.d.ts.map +1 -1
  224. package/node_modules/@buddi/gateway/dist/web/version.js +27 -0
  225. package/node_modules/@buddi/gateway/dist/web/version.js.map +1 -1
  226. package/node_modules/@buddi/gateway/dist/web/write.d.ts +5 -0
  227. package/node_modules/@buddi/gateway/dist/web/write.d.ts.map +1 -1
  228. package/node_modules/@buddi/gateway/dist/web/write.js +20 -1
  229. package/node_modules/@buddi/gateway/dist/web/write.js.map +1 -1
  230. package/node_modules/@buddi/gateway/package.json +4 -1
  231. package/node_modules/@buddi/gateway/src/agents/starter/keeper/agent.md +31 -0
  232. package/node_modules/@buddi/gateway/src/agents/starter/keeper/skills/keeping-a-history.md +22 -0
  233. package/node_modules/@buddi/gateway/src/agents/starter/planner/agent.md +30 -0
  234. package/node_modules/@buddi/gateway/src/agents/starter/planner/skills/holding-a-follow-up.md +17 -0
  235. package/node_modules/@buddi/gateway/src/agents/starter/planner/skills/writing-the-morning-brief.md +25 -0
  236. package/node_modules/@buddi/gateway/src/agents/starter/scout/agent.md +33 -0
  237. package/node_modules/@buddi/gateway/src/agents/starter/scout/skills/answering-with-sources.md +23 -0
  238. package/node_modules/@buddi/gateway/src/agents/starter/scout/skills/the-web-is-evidence.md +25 -0
  239. package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
  240. package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
  241. package/node_modules/@buddi/runtime/dist/anthropic-oauth.d.ts.map +1 -1
  242. package/node_modules/@buddi/runtime/dist/anthropic-oauth.js +38 -73
  243. package/node_modules/@buddi/runtime/dist/anthropic-oauth.js.map +1 -1
  244. package/node_modules/@buddi/runtime/dist/codex-direct.d.ts +39 -0
  245. package/node_modules/@buddi/runtime/dist/codex-direct.d.ts.map +1 -1
  246. package/node_modules/@buddi/runtime/dist/codex-direct.js +122 -0
  247. package/node_modules/@buddi/runtime/dist/codex-direct.js.map +1 -1
  248. package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts +0 -12
  249. package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts.map +1 -1
  250. package/node_modules/@buddi/runtime/dist/codex-oauth.js +32 -45
  251. package/node_modules/@buddi/runtime/dist/codex-oauth.js.map +1 -1
  252. package/node_modules/@buddi/runtime/dist/delegate.d.ts.map +1 -1
  253. package/node_modules/@buddi/runtime/dist/delegate.js +4 -2
  254. package/node_modules/@buddi/runtime/dist/delegate.js.map +1 -1
  255. package/node_modules/@buddi/runtime/dist/index.d.ts +2 -0
  256. package/node_modules/@buddi/runtime/dist/index.d.ts.map +1 -1
  257. package/node_modules/@buddi/runtime/dist/index.js +2 -0
  258. package/node_modules/@buddi/runtime/dist/index.js.map +1 -1
  259. package/node_modules/@buddi/runtime/dist/oauth-port.d.ts +68 -0
  260. package/node_modules/@buddi/runtime/dist/oauth-port.d.ts.map +1 -0
  261. package/node_modules/@buddi/runtime/dist/oauth-port.js +51 -0
  262. package/node_modules/@buddi/runtime/dist/oauth-port.js.map +1 -0
  263. package/node_modules/@buddi/runtime/dist/oauth.d.ts +255 -0
  264. package/node_modules/@buddi/runtime/dist/oauth.d.ts.map +1 -0
  265. package/node_modules/@buddi/runtime/dist/oauth.js +535 -0
  266. package/node_modules/@buddi/runtime/dist/oauth.js.map +1 -0
  267. package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
  268. package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
  269. package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
  270. package/node_modules/@buddi/tool-email/dist/types.d.ts +2 -2
  271. package/node_modules/@buddi/tool-email/dist/types.d.ts.map +1 -1
  272. package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
  273. package/node_modules/@buddi/tool-mcp/dist/.tsbuildinfo +1 -0
  274. package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts +26 -0
  275. package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts.map +1 -0
  276. package/node_modules/@buddi/tool-mcp/dist/catalog.js +17 -0
  277. package/node_modules/@buddi/tool-mcp/dist/catalog.js.map +1 -0
  278. package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts +44 -0
  279. package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts.map +1 -0
  280. package/node_modules/@buddi/tool-mcp/dist/fetch.js +88 -0
  281. package/node_modules/@buddi/tool-mcp/dist/fetch.js.map +1 -0
  282. package/node_modules/@buddi/tool-mcp/dist/index.d.ts +27 -0
  283. package/node_modules/@buddi/tool-mcp/dist/index.d.ts.map +1 -0
  284. package/node_modules/@buddi/tool-mcp/dist/index.js +74 -0
  285. package/node_modules/@buddi/tool-mcp/dist/index.js.map +1 -0
  286. package/node_modules/@buddi/tool-mcp/dist/output.d.ts +38 -0
  287. package/node_modules/@buddi/tool-mcp/dist/output.d.ts.map +1 -0
  288. package/node_modules/@buddi/tool-mcp/dist/output.js +90 -0
  289. package/node_modules/@buddi/tool-mcp/dist/output.js.map +1 -0
  290. package/node_modules/@buddi/tool-mcp/dist/ports.d.ts +105 -0
  291. package/node_modules/@buddi/tool-mcp/dist/ports.d.ts.map +1 -0
  292. package/node_modules/@buddi/tool-mcp/dist/ports.js +9 -0
  293. package/node_modules/@buddi/tool-mcp/dist/ports.js.map +1 -0
  294. package/node_modules/@buddi/tool-mcp/dist/service.d.ts +220 -0
  295. package/node_modules/@buddi/tool-mcp/dist/service.d.ts.map +1 -0
  296. package/node_modules/@buddi/tool-mcp/dist/service.js +742 -0
  297. package/node_modules/@buddi/tool-mcp/dist/service.js.map +1 -0
  298. package/node_modules/@buddi/tool-mcp/dist/session.d.ts +50 -0
  299. package/node_modules/@buddi/tool-mcp/dist/session.d.ts.map +1 -0
  300. package/node_modules/@buddi/tool-mcp/dist/session.js +108 -0
  301. package/node_modules/@buddi/tool-mcp/dist/session.js.map +1 -0
  302. package/node_modules/@buddi/tool-mcp/dist/store.d.ts +70 -0
  303. package/node_modules/@buddi/tool-mcp/dist/store.d.ts.map +1 -0
  304. package/node_modules/@buddi/tool-mcp/dist/store.js +78 -0
  305. package/node_modules/@buddi/tool-mcp/dist/store.js.map +1 -0
  306. package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts +51 -0
  307. package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts.map +1 -0
  308. package/node_modules/@buddi/tool-mcp/dist/testing/fake.js +147 -0
  309. package/node_modules/@buddi/tool-mcp/dist/testing/fake.js.map +1 -0
  310. package/node_modules/@buddi/tool-mcp/dist/tiers.d.ts +51 -0
  311. package/node_modules/@buddi/tool-mcp/dist/tiers.d.ts.map +1 -0
  312. package/node_modules/@buddi/tool-mcp/dist/tiers.js +106 -0
  313. package/node_modules/@buddi/tool-mcp/dist/tiers.js.map +1 -0
  314. package/node_modules/@buddi/tool-mcp/dist/tokens.d.ts +35 -0
  315. package/node_modules/@buddi/tool-mcp/dist/tokens.d.ts.map +1 -0
  316. package/node_modules/@buddi/tool-mcp/dist/tokens.js +75 -0
  317. package/node_modules/@buddi/tool-mcp/dist/tokens.js.map +1 -0
  318. package/node_modules/@buddi/tool-mcp/migrations/001_connections.sql +49 -0
  319. package/node_modules/@buddi/tool-mcp/migrations/002_review_again.sql +15 -0
  320. package/node_modules/@buddi/tool-mcp/package.json +34 -0
  321. package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
  322. package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
  323. package/node_modules/@zone-eu/mailsplit/lib/flowed-decoder.js +1 -5
  324. package/node_modules/@zone-eu/mailsplit/lib/headers.js +35 -25
  325. package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +126 -79
  326. package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +27 -5
  327. package/node_modules/@zone-eu/mailsplit/lib/node-rewriter.js +3 -2
  328. package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +0 -3
  329. package/node_modules/@zone-eu/mailsplit/package.json +5 -5
  330. package/node_modules/hono/dist/_virtual/_rolldown/runtime.js +13 -0
  331. package/node_modules/hono/dist/adapter/aws-lambda/conninfo.js +42 -23
  332. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +318 -344
  333. package/node_modules/hono/dist/adapter/aws-lambda/index.js +2 -8
  334. package/node_modules/hono/dist/adapter/aws-lambda/types.js +1 -0
  335. package/node_modules/hono/dist/adapter/bun/conninfo.js +20 -25
  336. package/node_modules/hono/dist/adapter/bun/index.js +3 -13
  337. package/node_modules/hono/dist/adapter/bun/serve-static.js +27 -27
  338. package/node_modules/hono/dist/adapter/bun/server.js +11 -5
  339. package/node_modules/hono/dist/adapter/bun/ssg.js +25 -15
  340. package/node_modules/hono/dist/adapter/bun/websocket.js +61 -68
  341. package/node_modules/hono/dist/adapter/cloudflare-pages/conninfo.js +24 -9
  342. package/node_modules/hono/dist/adapter/cloudflare-pages/handler.js +59 -62
  343. package/node_modules/hono/dist/adapter/cloudflare-pages/index.js +2 -8
  344. package/node_modules/hono/dist/adapter/cloudflare-workers/conninfo.js +7 -9
  345. package/node_modules/hono/dist/adapter/cloudflare-workers/index.js +3 -8
  346. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static-module.js +5 -6
  347. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static.js +26 -20
  348. package/node_modules/hono/dist/adapter/cloudflare-workers/utils.js +21 -34
  349. package/node_modules/hono/dist/adapter/cloudflare-workers/websocket.js +31 -39
  350. package/node_modules/hono/dist/adapter/deno/conninfo.js +16 -13
  351. package/node_modules/hono/dist/adapter/deno/deno.d.js +1 -0
  352. package/node_modules/hono/dist/adapter/deno/index.js +3 -10
  353. package/node_modules/hono/dist/adapter/deno/serve-static.js +33 -38
  354. package/node_modules/hono/dist/adapter/deno/ssg.js +27 -16
  355. package/node_modules/hono/dist/adapter/deno/websocket.js +30 -30
  356. package/node_modules/hono/dist/adapter/lambda-edge/conninfo.js +7 -9
  357. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +102 -101
  358. package/node_modules/hono/dist/adapter/lambda-edge/index.js +2 -6
  359. package/node_modules/hono/dist/adapter/netlify/conninfo.js +24 -9
  360. package/node_modules/hono/dist/adapter/netlify/handler.js +10 -8
  361. package/node_modules/hono/dist/adapter/netlify/index.js +3 -2
  362. package/node_modules/hono/dist/adapter/netlify/mod.js +2 -6
  363. package/node_modules/hono/dist/adapter/service-worker/handler.js +15 -19
  364. package/node_modules/hono/dist/adapter/service-worker/index.js +23 -7
  365. package/node_modules/hono/dist/adapter/service-worker/types.js +1 -0
  366. package/node_modules/hono/dist/adapter/vercel/conninfo.js +7 -10
  367. package/node_modules/hono/dist/adapter/vercel/handler.js +8 -6
  368. package/node_modules/hono/dist/adapter/vercel/index.js +2 -6
  369. package/node_modules/hono/dist/cjs/_virtual/_rolldown/runtime.js +33 -0
  370. package/node_modules/hono/dist/cjs/adapter/aws-lambda/conninfo.js +42 -44
  371. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +326 -373
  372. package/node_modules/hono/dist/cjs/adapter/aws-lambda/index.js +7 -34
  373. package/node_modules/hono/dist/cjs/adapter/aws-lambda/types.js +0 -15
  374. package/node_modules/hono/dist/cjs/adapter/bun/conninfo.js +21 -47
  375. package/node_modules/hono/dist/cjs/adapter/bun/index.js +14 -45
  376. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +29 -50
  377. package/node_modules/hono/dist/cjs/adapter/bun/server.js +11 -26
  378. package/node_modules/hono/dist/cjs/adapter/bun/ssg.js +24 -35
  379. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +63 -91
  380. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/conninfo.js +25 -31
  381. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/handler.js +61 -85
  382. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/index.js +7 -34
  383. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/conninfo.js +8 -31
  384. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/index.js +7 -33
  385. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +7 -29
  386. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static.js +27 -42
  387. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/utils.js +21 -55
  388. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/websocket.js +33 -62
  389. package/node_modules/hono/dist/cjs/adapter/deno/conninfo.js +16 -34
  390. package/node_modules/hono/dist/cjs/adapter/deno/index.js +10 -38
  391. package/node_modules/hono/dist/cjs/adapter/deno/serve-static.js +33 -59
  392. package/node_modules/hono/dist/cjs/adapter/deno/ssg.js +27 -37
  393. package/node_modules/hono/dist/cjs/adapter/deno/websocket.js +32 -53
  394. package/node_modules/hono/dist/cjs/adapter/lambda-edge/conninfo.js +8 -31
  395. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +102 -130
  396. package/node_modules/hono/dist/cjs/adapter/lambda-edge/index.js +5 -30
  397. package/node_modules/hono/dist/cjs/adapter/netlify/conninfo.js +25 -31
  398. package/node_modules/hono/dist/cjs/adapter/netlify/handler.js +10 -29
  399. package/node_modules/hono/dist/cjs/adapter/netlify/index.js +5 -21
  400. package/node_modules/hono/dist/cjs/adapter/netlify/mod.js +5 -30
  401. package/node_modules/hono/dist/cjs/adapter/service-worker/handler.js +16 -41
  402. package/node_modules/hono/dist/cjs/adapter/service-worker/index.js +25 -30
  403. package/node_modules/hono/dist/cjs/adapter/service-worker/types.js +0 -15
  404. package/node_modules/hono/dist/cjs/adapter/vercel/conninfo.js +8 -32
  405. package/node_modules/hono/dist/cjs/adapter/vercel/handler.js +8 -27
  406. package/node_modules/hono/dist/cjs/adapter/vercel/index.js +5 -30
  407. package/node_modules/hono/dist/cjs/client/client.js +139 -212
  408. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +62 -80
  409. package/node_modules/hono/dist/cjs/client/index.js +7 -32
  410. package/node_modules/hono/dist/cjs/client/types.js +0 -15
  411. package/node_modules/hono/dist/cjs/client/utils.js +54 -92
  412. package/node_modules/hono/dist/cjs/compose.js +49 -66
  413. package/node_modules/hono/dist/cjs/context.js +379 -450
  414. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +47 -72
  415. package/node_modules/hono/dist/cjs/helper/accepts/index.js +3 -27
  416. package/node_modules/hono/dist/cjs/helper/adapter/index.js +33 -73
  417. package/node_modules/hono/dist/cjs/helper/conninfo/index.js +0 -15
  418. package/node_modules/hono/dist/cjs/helper/conninfo/types.js +0 -15
  419. package/node_modules/hono/dist/cjs/helper/cookie/index.js +75 -116
  420. package/node_modules/hono/dist/cjs/helper/css/common.js +165 -244
  421. package/node_modules/hono/dist/cjs/helper/css/index.js +136 -151
  422. package/node_modules/hono/dist/cjs/helper/dev/index.js +45 -71
  423. package/node_modules/hono/dist/cjs/helper/factory/index.js +30 -51
  424. package/node_modules/hono/dist/cjs/helper/html/index.js +32 -62
  425. package/node_modules/hono/dist/cjs/helper/proxy/index.js +113 -106
  426. package/node_modules/hono/dist/cjs/helper/route/index.js +123 -66
  427. package/node_modules/hono/dist/cjs/helper/ssg/index.js +19 -43
  428. package/node_modules/hono/dist/cjs/helper/ssg/middleware.js +56 -64
  429. package/node_modules/hono/dist/cjs/helper/ssg/plugins.js +55 -57
  430. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +196 -296
  431. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +47 -90
  432. package/node_modules/hono/dist/cjs/helper/streaming/index.js +8 -35
  433. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +53 -85
  434. package/node_modules/hono/dist/cjs/helper/streaming/stream.js +23 -53
  435. package/node_modules/hono/dist/cjs/helper/streaming/text.js +10 -32
  436. package/node_modules/hono/dist/cjs/helper/streaming/utils.js +13 -32
  437. package/node_modules/hono/dist/cjs/helper/testing/index.js +16 -31
  438. package/node_modules/hono/dist/cjs/helper/websocket/index.js +51 -76
  439. package/node_modules/hono/dist/cjs/hono-base.js +345 -403
  440. package/node_modules/hono/dist/cjs/hono.js +28 -42
  441. package/node_modules/hono/dist/cjs/http-exception.js +55 -56
  442. package/node_modules/hono/dist/cjs/index.js +22 -30
  443. package/node_modules/hono/dist/cjs/jsx/base.js +237 -366
  444. package/node_modules/hono/dist/cjs/jsx/children.js +16 -41
  445. package/node_modules/hono/dist/cjs/jsx/components.js +119 -192
  446. package/node_modules/hono/dist/cjs/jsx/constants.js +15 -42
  447. package/node_modules/hono/dist/cjs/jsx/context.js +144 -162
  448. package/node_modules/hono/dist/cjs/jsx/dom/client.js +49 -69
  449. package/node_modules/hono/dist/cjs/jsx/dom/components.js +23 -52
  450. package/node_modules/hono/dist/cjs/jsx/dom/context.js +39 -67
  451. package/node_modules/hono/dist/cjs/jsx/dom/css.js +143 -158
  452. package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +55 -64
  453. package/node_modules/hono/dist/cjs/jsx/dom/index.js +114 -173
  454. package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +282 -375
  455. package/node_modules/hono/dist/cjs/jsx/dom/jsx-dev-runtime.js +14 -49
  456. package/node_modules/hono/dist/cjs/jsx/dom/jsx-runtime.js +5 -32
  457. package/node_modules/hono/dist/cjs/jsx/dom/render.js +469 -623
  458. package/node_modules/hono/dist/cjs/jsx/dom/server.js +37 -64
  459. package/node_modules/hono/dist/cjs/jsx/dom/utils.js +7 -30
  460. package/node_modules/hono/dist/cjs/jsx/hooks/index.js +225 -318
  461. package/node_modules/hono/dist/cjs/jsx/index.js +86 -135
  462. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/common.js +20 -43
  463. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +117 -168
  464. package/node_modules/hono/dist/cjs/jsx/intrinsic-elements.js +0 -15
  465. package/node_modules/hono/dist/cjs/jsx/jsx-dev-runtime.js +14 -39
  466. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +34 -68
  467. package/node_modules/hono/dist/cjs/jsx/streaming.js +123 -166
  468. package/node_modules/hono/dist/cjs/jsx/types.js +0 -15
  469. package/node_modules/hono/dist/cjs/jsx/utils.js +91 -175
  470. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +98 -86
  471. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +92 -109
  472. package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +66 -72
  473. package/node_modules/hono/dist/cjs/middleware/cache/index.js +153 -199
  474. package/node_modules/hono/dist/cjs/middleware/combine/index.js +133 -95
  475. package/node_modules/hono/dist/cjs/middleware/compress/index.js +73 -88
  476. package/node_modules/hono/dist/cjs/middleware/context-storage/index.js +49 -41
  477. package/node_modules/hono/dist/cjs/middleware/cors/index.js +107 -107
  478. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +101 -72
  479. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +58 -97
  480. package/node_modules/hono/dist/cjs/middleware/etag/index.js +71 -91
  481. package/node_modules/hono/dist/cjs/middleware/ip-restriction/index.js +161 -169
  482. package/node_modules/hono/dist/cjs/middleware/jsx-renderer/index.js +99 -77
  483. package/node_modules/hono/dist/cjs/middleware/jwk/index.js +3 -27
  484. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +118 -135
  485. package/node_modules/hono/dist/cjs/middleware/jwt/index.js +9 -38
  486. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +120 -141
  487. package/node_modules/hono/dist/cjs/middleware/language/index.js +7 -35
  488. package/node_modules/hono/dist/cjs/middleware/language/language.js +184 -182
  489. package/node_modules/hono/dist/cjs/middleware/logger/index.js +41 -62
  490. package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +82 -88
  491. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +101 -102
  492. package/node_modules/hono/dist/cjs/middleware/powered-by/index.js +23 -30
  493. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +38 -42
  494. package/node_modules/hono/dist/cjs/middleware/request-id/index.js +3 -27
  495. package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +34 -42
  496. package/node_modules/hono/dist/cjs/middleware/secure-headers/index.js +4 -29
  497. package/node_modules/hono/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -15
  498. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +142 -174
  499. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +55 -93
  500. package/node_modules/hono/dist/cjs/middleware/serve-static/path.js +15 -38
  501. package/node_modules/hono/dist/cjs/middleware/timeout/index.js +40 -45
  502. package/node_modules/hono/dist/cjs/middleware/timing/index.js +7 -35
  503. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +177 -118
  504. package/node_modules/hono/dist/cjs/middleware/trailing-slash/index.js +85 -58
  505. package/node_modules/hono/dist/cjs/preset/quick.js +18 -37
  506. package/node_modules/hono/dist/cjs/preset/tiny.js +15 -33
  507. package/node_modules/hono/dist/cjs/request/constants.js +5 -27
  508. package/node_modules/hono/dist/cjs/request.js +334 -346
  509. package/node_modules/hono/dist/cjs/router/linear-router/index.js +3 -27
  510. package/node_modules/hono/dist/cjs/router/linear-router/router.js +95 -143
  511. package/node_modules/hono/dist/cjs/router/pattern-router/index.js +3 -27
  512. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +41 -63
  513. package/node_modules/hono/dist/cjs/router/reg-exp-router/index.js +7 -34
  514. package/node_modules/hono/dist/cjs/router/reg-exp-router/matcher.js +18 -45
  515. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +91 -135
  516. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +92 -161
  517. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +98 -147
  518. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +73 -89
  519. package/node_modules/hono/dist/cjs/router/smart-router/index.js +3 -27
  520. package/node_modules/hono/dist/cjs/router/smart-router/router.js +49 -79
  521. package/node_modules/hono/dist/cjs/router/trie-router/index.js +3 -27
  522. package/node_modules/hono/dist/cjs/router/trie-router/node.js +134 -186
  523. package/node_modules/hono/dist/cjs/router/trie-router/router.js +15 -39
  524. package/node_modules/hono/dist/cjs/router/utils.js +5 -27
  525. package/node_modules/hono/dist/cjs/router.js +37 -37
  526. package/node_modules/hono/dist/cjs/types.js +5 -28
  527. package/node_modules/hono/dist/cjs/utils/accept.js +177 -225
  528. package/node_modules/hono/dist/cjs/utils/basic-auth.js +16 -40
  529. package/node_modules/hono/dist/cjs/utils/body.js +84 -110
  530. package/node_modules/hono/dist/cjs/utils/buffer.js +43 -91
  531. package/node_modules/hono/dist/cjs/utils/color.js +35 -44
  532. package/node_modules/hono/dist/cjs/utils/compress.js +11 -26
  533. package/node_modules/hono/dist/cjs/utils/concurrent.js +29 -59
  534. package/node_modules/hono/dist/cjs/utils/constants.js +7 -26
  535. package/node_modules/hono/dist/cjs/utils/cookie.js +107 -177
  536. package/node_modules/hono/dist/cjs/utils/crypto.js +30 -61
  537. package/node_modules/hono/dist/cjs/utils/encode.js +31 -48
  538. package/node_modules/hono/dist/cjs/utils/filepath.js +23 -54
  539. package/node_modules/hono/dist/cjs/utils/handler.js +11 -33
  540. package/node_modules/hono/dist/cjs/utils/headers.js +0 -15
  541. package/node_modules/hono/dist/cjs/utils/html.js +96 -137
  542. package/node_modules/hono/dist/cjs/utils/http-status.js +0 -15
  543. package/node_modules/hono/dist/cjs/utils/ipaddr.js +213 -286
  544. package/node_modules/hono/dist/cjs/utils/jwt/index.js +14 -27
  545. package/node_modules/hono/dist/cjs/utils/jwt/jwa.js +25 -42
  546. package/node_modules/hono/dist/cjs/utils/jwt/jws.js +119 -199
  547. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +122 -206
  548. package/node_modules/hono/dist/cjs/utils/jwt/types.js +122 -159
  549. package/node_modules/hono/dist/cjs/utils/jwt/utf8.js +9 -28
  550. package/node_modules/hono/dist/cjs/utils/mime.js +75 -101
  551. package/node_modules/hono/dist/cjs/utils/stream.js +88 -111
  552. package/node_modules/hono/dist/cjs/utils/types.js +0 -15
  553. package/node_modules/hono/dist/cjs/utils/url.js +185 -234
  554. package/node_modules/hono/dist/cjs/validator/index.js +3 -27
  555. package/node_modules/hono/dist/cjs/validator/utils.js +0 -15
  556. package/node_modules/hono/dist/cjs/validator/validator.js +60 -103
  557. package/node_modules/hono/dist/client/client.js +138 -197
  558. package/node_modules/hono/dist/client/fetch-result-please.js +59 -56
  559. package/node_modules/hono/dist/client/index.js +3 -7
  560. package/node_modules/hono/dist/client/types.js +1 -0
  561. package/node_modules/hono/dist/client/utils.js +51 -68
  562. package/node_modules/hono/dist/compose.js +49 -45
  563. package/node_modules/hono/dist/context.js +376 -426
  564. package/node_modules/hono/dist/helper/accepts/accepts.js +47 -51
  565. package/node_modules/hono/dist/helper/accepts/index.js +1 -4
  566. package/node_modules/hono/dist/helper/adapter/index.js +33 -52
  567. package/node_modules/hono/dist/helper/conninfo/index.js +1 -0
  568. package/node_modules/hono/dist/helper/conninfo/types.js +1 -0
  569. package/node_modules/hono/dist/helper/cookie/index.js +74 -94
  570. package/node_modules/hono/dist/helper/css/common.js +167 -225
  571. package/node_modules/hono/dist/helper/css/index.js +132 -137
  572. package/node_modules/hono/dist/helper/dev/index.js +44 -49
  573. package/node_modules/hono/dist/helper/factory/index.js +27 -27
  574. package/node_modules/hono/dist/helper/html/index.js +30 -39
  575. package/node_modules/hono/dist/helper/proxy/index.js +116 -88
  576. package/node_modules/hono/dist/helper/route/index.js +121 -43
  577. package/node_modules/hono/dist/helper/ssg/index.js +3 -18
  578. package/node_modules/hono/dist/helper/ssg/middleware.js +53 -40
  579. package/node_modules/hono/dist/helper/ssg/plugins.js +55 -36
  580. package/node_modules/hono/dist/helper/ssg/ssg.js +198 -283
  581. package/node_modules/hono/dist/helper/ssg/utils.js +53 -75
  582. package/node_modules/hono/dist/helper/streaming/index.js +2 -8
  583. package/node_modules/hono/dist/helper/streaming/sse.js +50 -61
  584. package/node_modules/hono/dist/helper/streaming/stream.js +22 -31
  585. package/node_modules/hono/dist/helper/streaming/text.js +9 -10
  586. package/node_modules/hono/dist/helper/streaming/utils.js +9 -12
  587. package/node_modules/hono/dist/helper/testing/index.js +16 -10
  588. package/node_modules/hono/dist/helper/websocket/index.js +49 -53
  589. package/node_modules/hono/dist/hono-base.js +342 -379
  590. package/node_modules/hono/dist/hono.js +27 -20
  591. package/node_modules/hono/dist/http-exception.js +53 -33
  592. package/node_modules/hono/dist/index.js +19 -6
  593. package/node_modules/hono/dist/jsx/base.js +231 -340
  594. package/node_modules/hono/dist/jsx/children.js +16 -20
  595. package/node_modules/hono/dist/jsx/components.js +118 -170
  596. package/node_modules/hono/dist/jsx/constants.js +9 -15
  597. package/node_modules/hono/dist/jsx/context.js +153 -150
  598. package/node_modules/hono/dist/jsx/dom/client.js +45 -48
  599. package/node_modules/hono/dist/jsx/dom/components.js +21 -29
  600. package/node_modules/hono/dist/jsx/dom/context.js +37 -44
  601. package/node_modules/hono/dist/jsx/dom/css.js +142 -147
  602. package/node_modules/hono/dist/jsx/dom/hooks/index.js +52 -40
  603. package/node_modules/hono/dist/jsx/dom/index.js +71 -134
  604. package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +275 -359
  605. package/node_modules/hono/dist/jsx/dom/jsx-dev-runtime.js +14 -18
  606. package/node_modules/hono/dist/jsx/dom/jsx-runtime.js +2 -8
  607. package/node_modules/hono/dist/jsx/dom/render.js +492 -631
  608. package/node_modules/hono/dist/jsx/dom/server.js +32 -32
  609. package/node_modules/hono/dist/jsx/dom/utils.js +6 -8
  610. package/node_modules/hono/dist/jsx/hooks/index.js +236 -308
  611. package/node_modules/hono/dist/jsx/index.js +45 -98
  612. package/node_modules/hono/dist/jsx/intrinsic-element/common.js +20 -22
  613. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +113 -154
  614. package/node_modules/hono/dist/jsx/intrinsic-elements.js +1 -0
  615. package/node_modules/hono/dist/jsx/jsx-dev-runtime.js +12 -16
  616. package/node_modules/hono/dist/jsx/jsx-runtime.js +29 -42
  617. package/node_modules/hono/dist/jsx/streaming.js +120 -142
  618. package/node_modules/hono/dist/jsx/types.js +1 -0
  619. package/node_modules/hono/dist/jsx/utils.js +105 -168
  620. package/node_modules/hono/dist/middleware/basic-auth/index.js +96 -63
  621. package/node_modules/hono/dist/middleware/bearer-auth/index.js +93 -89
  622. package/node_modules/hono/dist/middleware/body-limit/index.js +66 -51
  623. package/node_modules/hono/dist/middleware/cache/index.js +165 -190
  624. package/node_modules/hono/dist/middleware/combine/index.js +132 -73
  625. package/node_modules/hono/dist/middleware/compress/index.js +75 -69
  626. package/node_modules/hono/dist/middleware/context-storage/index.js +49 -19
  627. package/node_modules/hono/dist/middleware/cors/index.js +107 -86
  628. package/node_modules/hono/dist/middleware/csrf/index.js +103 -53
  629. package/node_modules/hono/dist/middleware/etag/digest.js +59 -77
  630. package/node_modules/hono/dist/middleware/etag/index.js +71 -70
  631. package/node_modules/hono/dist/middleware/ip-restriction/index.js +163 -158
  632. package/node_modules/hono/dist/middleware/jsx-renderer/index.js +97 -54
  633. package/node_modules/hono/dist/middleware/jwk/index.js +1 -4
  634. package/node_modules/hono/dist/middleware/jwk/jwk.js +116 -112
  635. package/node_modules/hono/dist/middleware/jwt/index.js +2 -10
  636. package/node_modules/hono/dist/middleware/jwt/jwt.js +114 -114
  637. package/node_modules/hono/dist/middleware/language/index.js +2 -15
  638. package/node_modules/hono/dist/middleware/language/language.js +180 -157
  639. package/node_modules/hono/dist/middleware/logger/index.js +43 -37
  640. package/node_modules/hono/dist/middleware/method-not-allowed/index.js +81 -66
  641. package/node_modules/hono/dist/middleware/method-override/index.js +101 -81
  642. package/node_modules/hono/dist/middleware/powered-by/index.js +23 -9
  643. package/node_modules/hono/dist/middleware/pretty-json/index.js +39 -22
  644. package/node_modules/hono/dist/middleware/request-id/index.js +1 -4
  645. package/node_modules/hono/dist/middleware/request-id/request-id.js +33 -20
  646. package/node_modules/hono/dist/middleware/secure-headers/index.js +1 -5
  647. package/node_modules/hono/dist/middleware/secure-headers/permissions-policy.js +1 -0
  648. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +144 -155
  649. package/node_modules/hono/dist/middleware/serve-static/index.js +55 -72
  650. package/node_modules/hono/dist/middleware/serve-static/path.js +15 -17
  651. package/node_modules/hono/dist/middleware/timeout/index.js +40 -23
  652. package/node_modules/hono/dist/middleware/timing/index.js +2 -9
  653. package/node_modules/hono/dist/middleware/timing/timing.js +177 -97
  654. package/node_modules/hono/dist/middleware/trailing-slash/index.js +85 -37
  655. package/node_modules/hono/dist/preset/quick.js +17 -15
  656. package/node_modules/hono/dist/preset/tiny.js +14 -11
  657. package/node_modules/hono/dist/request/constants.js +4 -5
  658. package/node_modules/hono/dist/request.js +328 -319
  659. package/node_modules/hono/dist/router/linear-router/index.js +1 -4
  660. package/node_modules/hono/dist/router/linear-router/router.js +93 -120
  661. package/node_modules/hono/dist/router/pattern-router/index.js +1 -4
  662. package/node_modules/hono/dist/router/pattern-router/router.js +39 -40
  663. package/node_modules/hono/dist/router/reg-exp-router/index.js +1 -7
  664. package/node_modules/hono/dist/router/reg-exp-router/matcher.js +17 -23
  665. package/node_modules/hono/dist/router/reg-exp-router/node.js +87 -110
  666. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +89 -137
  667. package/node_modules/hono/dist/router/reg-exp-router/router.js +92 -129
  668. package/node_modules/hono/dist/router/reg-exp-router/trie.js +69 -64
  669. package/node_modules/hono/dist/router/smart-router/index.js +1 -4
  670. package/node_modules/hono/dist/router/smart-router/router.js +46 -55
  671. package/node_modules/hono/dist/router/trie-router/index.js +1 -4
  672. package/node_modules/hono/dist/router/trie-router/node.js +131 -162
  673. package/node_modules/hono/dist/router/trie-router/router.js +11 -14
  674. package/node_modules/hono/dist/router/utils.js +4 -5
  675. package/node_modules/hono/dist/router.js +35 -14
  676. package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +4 -1
  677. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +150 -105
  678. package/node_modules/hono/dist/types/adapter/aws-lambda/index.d.ts +4 -8
  679. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +152 -123
  680. package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +4 -1
  681. package/node_modules/hono/dist/types/adapter/bun/index.d.ts +6 -10
  682. package/node_modules/hono/dist/types/adapter/bun/serve-static.d.ts +7 -2
  683. package/node_modules/hono/dist/types/adapter/bun/server.d.ts +4 -5
  684. package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +5 -1
  685. package/node_modules/hono/dist/types/adapter/bun/websocket.d.ts +31 -17
  686. package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +4 -1
  687. package/node_modules/hono/dist/types/adapter/cloudflare-pages/handler.d.ts +29 -18
  688. package/node_modules/hono/dist/types/adapter/cloudflare-pages/index.d.ts +3 -7
  689. package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +6 -1
  690. package/node_modules/hono/dist/types/adapter/cloudflare-workers/index.d.ts +4 -7
  691. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +5 -3
  692. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static.d.ts +10 -5
  693. package/node_modules/hono/dist/types/adapter/cloudflare-workers/utils.d.ts +10 -2
  694. package/node_modules/hono/dist/types/adapter/cloudflare-workers/websocket.d.ts +6 -1
  695. package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +4 -1
  696. package/node_modules/hono/dist/types/adapter/deno/deno.d.ts +1 -0
  697. package/node_modules/hono/dist/types/adapter/deno/index.d.ts +5 -8
  698. package/node_modules/hono/dist/types/adapter/deno/serve-static.d.ts +7 -2
  699. package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +5 -1
  700. package/node_modules/hono/dist/types/adapter/deno/websocket.d.ts +6 -1
  701. package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +6 -1
  702. package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +83 -58
  703. package/node_modules/hono/dist/types/adapter/lambda-edge/index.d.ts +3 -7
  704. package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +4 -1
  705. package/node_modules/hono/dist/types/adapter/netlify/handler.d.ts +6 -1
  706. package/node_modules/hono/dist/types/adapter/netlify/index.d.ts +3 -5
  707. package/node_modules/hono/dist/types/adapter/netlify/mod.d.ts +3 -2
  708. package/node_modules/hono/dist/types/adapter/service-worker/handler.d.ts +9 -8
  709. package/node_modules/hono/dist/types/adapter/service-worker/index.d.ts +6 -9
  710. package/node_modules/hono/dist/types/adapter/service-worker/types.d.ts +12 -8
  711. package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +6 -1
  712. package/node_modules/hono/dist/types/adapter/vercel/handler.d.ts +6 -1
  713. package/node_modules/hono/dist/types/adapter/vercel/index.d.ts +3 -6
  714. package/node_modules/hono/dist/types/client/client.d.ts +5 -3
  715. package/node_modules/hono/dist/types/client/fetch-result-please.d.ts +21 -19
  716. package/node_modules/hono/dist/types/client/index.d.ts +5 -7
  717. package/node_modules/hono/dist/types/client/types.d.ts +134 -160
  718. package/node_modules/hono/dist/types/client/utils.d.ts +6 -4
  719. package/node_modules/hono/dist/types/compose.d.ts +4 -2
  720. package/node_modules/hono/dist/types/context.d.ts +335 -336
  721. package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +11 -9
  722. package/node_modules/hono/dist/types/helper/accepts/index.d.ts +2 -5
  723. package/node_modules/hono/dist/types/helper/adapter/index.d.ts +4 -6
  724. package/node_modules/hono/dist/types/helper/conninfo/index.d.ts +2 -5
  725. package/node_modules/hono/dist/types/helper/conninfo/types.d.ts +25 -23
  726. package/node_modules/hono/dist/types/helper/cookie/index.d.ts +10 -13
  727. package/node_modules/hono/dist/types/helper/css/common.d.ts +11 -10
  728. package/node_modules/hono/dist/types/helper/css/index.d.ts +25 -28
  729. package/node_modules/hono/dist/types/helper/dev/index.d.ts +10 -13
  730. package/node_modules/hono/dist/types/helper/factory/index.d.ts +26 -74
  731. package/node_modules/hono/dist/types/helper/html/index.d.ts +4 -7
  732. package/node_modules/hono/dist/types/helper/proxy/index.d.ts +19 -22
  733. package/node_modules/hono/dist/types/helper/route/index.d.ts +4 -2
  734. package/node_modules/hono/dist/types/helper/ssg/index.d.ts +4 -7
  735. package/node_modules/hono/dist/types/helper/ssg/middleware.d.ts +8 -7
  736. package/node_modules/hono/dist/types/helper/ssg/plugins.d.ts +3 -1
  737. package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +38 -36
  738. package/node_modules/hono/dist/types/helper/ssg/utils.d.ts +5 -4
  739. package/node_modules/hono/dist/types/helper/streaming/index.d.ts +4 -8
  740. package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +10 -8
  741. package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +4 -2
  742. package/node_modules/hono/dist/types/helper/streaming/text.d.ts +4 -2
  743. package/node_modules/hono/dist/types/helper/streaming/utils.d.ts +2 -0
  744. package/node_modules/hono/dist/types/helper/testing/index.d.ts +7 -10
  745. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +30 -33
  746. package/node_modules/hono/dist/types/hono-base.d.ts +208 -211
  747. package/node_modules/hono/dist/types/hono.d.ts +11 -10
  748. package/node_modules/hono/dist/types/http-exception.d.ts +20 -23
  749. package/node_modules/hono/dist/types/index.d.ts +6 -37
  750. package/node_modules/hono/dist/types/jsx/base.d.ts +36 -35
  751. package/node_modules/hono/dist/types/jsx/children.d.ts +8 -6
  752. package/node_modules/hono/dist/types/jsx/components.d.ts +8 -5
  753. package/node_modules/hono/dist/types/jsx/constants.d.ts +2 -0
  754. package/node_modules/hono/dist/types/jsx/context.d.ts +9 -7
  755. package/node_modules/hono/dist/types/jsx/dom/client.d.ts +8 -10
  756. package/node_modules/hono/dist/types/jsx/dom/components.d.ts +9 -6
  757. package/node_modules/hono/dist/types/jsx/dom/context.d.ts +3 -1
  758. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +26 -30
  759. package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +11 -13
  760. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +78 -83
  761. package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +9 -5
  762. package/node_modules/hono/dist/types/jsx/dom/jsx-dev-runtime.d.ts +4 -6
  763. package/node_modules/hono/dist/types/jsx/dom/jsx-runtime.d.ts +3 -7
  764. package/node_modules/hono/dist/types/jsx/dom/render.d.ts +32 -51
  765. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +86 -85
  766. package/node_modules/hono/dist/types/jsx/dom/utils.d.ts +2 -0
  767. package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +16 -17
  768. package/node_modules/hono/dist/types/jsx/index.d.ts +70 -73
  769. package/node_modules/hono/dist/types/jsx/intrinsic-element/common.d.ts +3 -1
  770. package/node_modules/hono/dist/types/jsx/intrinsic-element/components.d.ts +7 -4
  771. package/node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts +708 -708
  772. package/node_modules/hono/dist/types/jsx/jsx-dev-runtime.d.ts +4 -7
  773. package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +7 -10
  774. package/node_modules/hono/dist/types/jsx/streaming.d.ts +9 -10
  775. package/node_modules/hono/dist/types/jsx/types.d.ts +11 -13
  776. package/node_modules/hono/dist/types/jsx/utils.d.ts +2 -0
  777. package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +17 -20
  778. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +46 -49
  779. package/node_modules/hono/dist/types/middleware/body-limit/index.d.ts +6 -9
  780. package/node_modules/hono/dist/types/middleware/cache/index.d.ts +13 -15
  781. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +4 -7
  782. package/node_modules/hono/dist/types/middleware/compress/index.d.ts +8 -10
  783. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +4 -6
  784. package/node_modules/hono/dist/types/middleware/cors/index.d.ts +10 -13
  785. package/node_modules/hono/dist/types/middleware/csrf/index.d.ts +6 -9
  786. package/node_modules/hono/dist/types/middleware/etag/digest.d.ts +2 -0
  787. package/node_modules/hono/dist/types/middleware/etag/index.d.ts +6 -9
  788. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +11 -13
  789. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +11 -12
  790. package/node_modules/hono/dist/types/middleware/jwk/index.d.ts +2 -1
  791. package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +20 -23
  792. package/node_modules/hono/dist/types/middleware/jwt/index.d.ts +6 -6
  793. package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +28 -30
  794. package/node_modules/hono/dist/types/middleware/language/index.d.ts +5 -5
  795. package/node_modules/hono/dist/types/middleware/language/language.d.ts +42 -44
  796. package/node_modules/hono/dist/types/middleware/logger/index.d.ts +3 -6
  797. package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +7 -10
  798. package/node_modules/hono/dist/types/middleware/method-override/index.d.ts +14 -17
  799. package/node_modules/hono/dist/types/middleware/powered-by/index.d.ts +8 -11
  800. package/node_modules/hono/dist/types/middleware/pretty-json/index.d.ts +18 -21
  801. package/node_modules/hono/dist/types/middleware/request-id/index.d.ts +5 -5
  802. package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +9 -11
  803. package/node_modules/hono/dist/types/middleware/secure-headers/index.d.ts +5 -6
  804. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +2 -1
  805. package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +55 -58
  806. package/node_modules/hono/dist/types/middleware/serve-static/index.d.ts +22 -24
  807. package/node_modules/hono/dist/types/middleware/serve-static/path.d.ts +2 -0
  808. package/node_modules/hono/dist/types/middleware/timeout/index.d.ts +5 -7
  809. package/node_modules/hono/dist/types/middleware/timing/index.d.ts +5 -5
  810. package/node_modules/hono/dist/types/middleware/timing/timing.d.ts +17 -21
  811. package/node_modules/hono/dist/types/middleware/trailing-slash/index.d.ts +35 -38
  812. package/node_modules/hono/dist/types/preset/quick.d.ts +6 -9
  813. package/node_modules/hono/dist/types/preset/tiny.d.ts +6 -9
  814. package/node_modules/hono/dist/types/request/constants.d.ts +2 -0
  815. package/node_modules/hono/dist/types/request.d.ts +288 -287
  816. package/node_modules/hono/dist/types/router/linear-router/index.d.ts +2 -5
  817. package/node_modules/hono/dist/types/router/linear-router/router.d.ts +7 -5
  818. package/node_modules/hono/dist/types/router/pattern-router/index.d.ts +2 -5
  819. package/node_modules/hono/dist/types/router/pattern-router/router.d.ts +7 -5
  820. package/node_modules/hono/dist/types/router/reg-exp-router/index.d.ts +3 -6
  821. package/node_modules/hono/dist/types/router/reg-exp-router/matcher.d.ts +3 -1
  822. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +6 -4
  823. package/node_modules/hono/dist/types/router/reg-exp-router/prepared-router.d.ts +11 -11
  824. package/node_modules/hono/dist/types/router/reg-exp-router/router.d.ts +10 -9
  825. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +7 -5
  826. package/node_modules/hono/dist/types/router/smart-router/index.d.ts +2 -5
  827. package/node_modules/hono/dist/types/router/smart-router/router.d.ts +11 -9
  828. package/node_modules/hono/dist/types/router/trie-router/index.d.ts +2 -5
  829. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +6 -4
  830. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +7 -5
  831. package/node_modules/hono/dist/types/router/utils.d.ts +2 -0
  832. package/node_modules/hono/dist/types/router.d.ts +23 -22
  833. package/node_modules/hono/dist/types/types.d.ts +146 -506
  834. package/node_modules/hono/dist/types/utils/accept.d.ts +5 -3
  835. package/node_modules/hono/dist/types/utils/basic-auth.d.ts +4 -2
  836. package/node_modules/hono/dist/types/utils/body.d.ts +46 -51
  837. package/node_modules/hono/dist/types/utils/buffer.d.ts +7 -6
  838. package/node_modules/hono/dist/types/utils/color.d.ts +2 -0
  839. package/node_modules/hono/dist/types/utils/compress.d.ts +2 -0
  840. package/node_modules/hono/dist/types/utils/concurrent.d.ts +6 -4
  841. package/node_modules/hono/dist/types/utils/constants.d.ts +2 -0
  842. package/node_modules/hono/dist/types/utils/cookie.d.ts +20 -19
  843. package/node_modules/hono/dist/types/utils/crypto.d.ts +5 -8
  844. package/node_modules/hono/dist/types/utils/encode.d.ts +2 -0
  845. package/node_modules/hono/dist/types/utils/filepath.d.ts +5 -4
  846. package/node_modules/hono/dist/types/utils/handler.d.ts +2 -0
  847. package/node_modules/hono/dist/types/utils/headers.d.ts +2 -0
  848. package/node_modules/hono/dist/types/utils/html.d.ts +11 -10
  849. package/node_modules/hono/dist/types/utils/http-status.d.ts +2 -0
  850. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +4 -6
  851. package/node_modules/hono/dist/types/utils/jwt/index.d.ts +18 -12
  852. package/node_modules/hono/dist/types/utils/jwt/jwa.d.ts +15 -13
  853. package/node_modules/hono/dist/types/utils/jwt/jws.d.ts +4 -7
  854. package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +26 -29
  855. package/node_modules/hono/dist/types/utils/jwt/types.d.ts +48 -45
  856. package/node_modules/hono/dist/types/utils/jwt/utf8.d.ts +2 -0
  857. package/node_modules/hono/dist/types/utils/mime.d.ts +59 -57
  858. package/node_modules/hono/dist/types/utils/stream.d.ts +27 -25
  859. package/node_modules/hono/dist/types/utils/types.d.ts +14 -27
  860. package/node_modules/hono/dist/types/utils/url.d.ts +2 -1
  861. package/node_modules/hono/dist/types/validator/index.d.ts +3 -7
  862. package/node_modules/hono/dist/types/validator/utils.d.ts +6 -9
  863. package/node_modules/hono/dist/types/validator/validator.d.ts +11 -10
  864. package/node_modules/hono/dist/types.js +4 -6
  865. package/node_modules/hono/dist/utils/accept.js +185 -212
  866. package/node_modules/hono/dist/utils/basic-auth.js +18 -21
  867. package/node_modules/hono/dist/utils/body.js +87 -92
  868. package/node_modules/hono/dist/utils/buffer.js +44 -71
  869. package/node_modules/hono/dist/utils/color.js +33 -21
  870. package/node_modules/hono/dist/utils/compress.js +11 -5
  871. package/node_modules/hono/dist/utils/concurrent.js +29 -38
  872. package/node_modules/hono/dist/utils/constants.js +7 -5
  873. package/node_modules/hono/dist/utils/cookie.js +114 -163
  874. package/node_modules/hono/dist/utils/crypto.js +30 -40
  875. package/node_modules/hono/dist/utils/encode.js +30 -26
  876. package/node_modules/hono/dist/utils/filepath.js +23 -33
  877. package/node_modules/hono/dist/utils/handler.js +10 -11
  878. package/node_modules/hono/dist/utils/headers.js +1 -0
  879. package/node_modules/hono/dist/utils/html.js +97 -117
  880. package/node_modules/hono/dist/utils/http-status.js +1 -0
  881. package/node_modules/hono/dist/utils/ipaddr.js +227 -279
  882. package/node_modules/hono/dist/utils/jwt/index.js +12 -4
  883. package/node_modules/hono/dist/utils/jwt/jwa.js +24 -20
  884. package/node_modules/hono/dist/utils/jwt/jws.js +115 -174
  885. package/node_modules/hono/dist/utils/jwt/jwt.js +120 -198
  886. package/node_modules/hono/dist/utils/jwt/types.js +79 -95
  887. package/node_modules/hono/dist/utils/jwt/utf8.js +9 -7
  888. package/node_modules/hono/dist/utils/mime.js +74 -79
  889. package/node_modules/hono/dist/utils/stream.js +86 -88
  890. package/node_modules/hono/dist/utils/types.js +1 -0
  891. package/node_modules/hono/dist/utils/url.js +187 -215
  892. package/node_modules/hono/dist/validator/index.js +1 -4
  893. package/node_modules/hono/dist/validator/utils.js +1 -0
  894. package/node_modules/hono/dist/validator/validator.js +61 -83
  895. package/node_modules/hono/package.json +27 -27
  896. package/node_modules/imapflow/CHANGELOG.md +14 -0
  897. package/node_modules/imapflow/README.md +2 -0
  898. package/node_modules/imapflow/dist/cjs/commands/list.js +20 -8
  899. package/node_modules/imapflow/dist/cjs/errors.d.ts +2 -0
  900. package/node_modules/imapflow/dist/cjs/errors.js +4 -1
  901. package/node_modules/imapflow/dist/cjs/handler/imap-stream.js +7 -11
  902. package/node_modules/imapflow/dist/cjs/imap-flow.js +54 -27
  903. package/node_modules/imapflow/dist/cjs/logger.d.ts +21 -3
  904. package/node_modules/imapflow/dist/cjs/logger.js +35 -5
  905. package/node_modules/imapflow/dist/cjs/package-info.d.ts +1 -1
  906. package/node_modules/imapflow/dist/cjs/package-info.js +1 -1
  907. package/node_modules/imapflow/dist/cjs/search-compiler.d.ts +1 -1
  908. package/node_modules/imapflow/dist/cjs/search-compiler.js +48 -35
  909. package/node_modules/imapflow/dist/cjs/tools.js +9 -2
  910. package/node_modules/imapflow/dist/esm/commands/list.js +20 -8
  911. package/node_modules/imapflow/dist/esm/errors.d.ts +2 -0
  912. package/node_modules/imapflow/dist/esm/errors.js +4 -1
  913. package/node_modules/imapflow/dist/esm/handler/imap-stream.js +7 -8
  914. package/node_modules/imapflow/dist/esm/imap-flow.js +54 -27
  915. package/node_modules/imapflow/dist/esm/logger.d.ts +21 -3
  916. package/node_modules/imapflow/dist/esm/logger.js +33 -3
  917. package/node_modules/imapflow/dist/esm/package-info.d.ts +1 -1
  918. package/node_modules/imapflow/dist/esm/package-info.js +1 -1
  919. package/node_modules/imapflow/dist/esm/search-compiler.d.ts +1 -1
  920. package/node_modules/imapflow/dist/esm/search-compiler.js +49 -36
  921. package/node_modules/imapflow/dist/esm/tools.js +9 -2
  922. package/node_modules/imapflow/package.json +5 -5
  923. package/node_modules/libbase64/.github/workflows/release.yaml +12 -10
  924. package/node_modules/libbase64/.ncurc.js +7 -1
  925. package/node_modules/libbase64/CHANGELOG.md +7 -0
  926. package/node_modules/libbase64/lib/libbase64.js +27 -0
  927. package/node_modules/libbase64/package.json +4 -4
  928. package/node_modules/libmime/CHANGELOG.md +14 -0
  929. package/node_modules/libmime/lib/libmime.js +41 -21
  930. package/node_modules/libmime/package.json +3 -3
  931. package/node_modules/libqp/.github/workflows/release.yaml +12 -10
  932. package/node_modules/libqp/CHANGELOG.md +7 -0
  933. package/node_modules/libqp/lib/libqp.js +6 -4
  934. package/node_modules/libqp/package.json +2 -2
  935. package/node_modules/libqp/test/libqp-test.js +71 -14
  936. package/package.json +4 -2
  937. package/packages/cli/dist/.tsbuildinfo +1 -1
  938. package/packages/cli/dist/commands.d.ts.map +1 -1
  939. package/packages/cli/dist/commands.js +5 -2
  940. package/packages/cli/dist/commands.js.map +1 -1
  941. package/packages/core/dist/.tsbuildinfo +1 -1
  942. package/packages/core/dist/actions/permissions.d.ts +14 -0
  943. package/packages/core/dist/actions/permissions.d.ts.map +1 -1
  944. package/packages/core/dist/actions/permissions.js +15 -0
  945. package/packages/core/dist/actions/permissions.js.map +1 -1
  946. package/packages/core/dist/agents/catalog.d.ts +12 -1
  947. package/packages/core/dist/agents/catalog.d.ts.map +1 -1
  948. package/packages/core/dist/agents/catalog.js +57 -6
  949. package/packages/core/dist/agents/catalog.js.map +1 -1
  950. package/packages/core/dist/agents/delegates.d.ts +54 -0
  951. package/packages/core/dist/agents/delegates.d.ts.map +1 -0
  952. package/packages/core/dist/agents/delegates.js +51 -0
  953. package/packages/core/dist/agents/delegates.js.map +1 -0
  954. package/packages/core/dist/agents/index.d.ts +1 -0
  955. package/packages/core/dist/agents/index.d.ts.map +1 -1
  956. package/packages/core/dist/agents/index.js +1 -0
  957. package/packages/core/dist/agents/index.js.map +1 -1
  958. package/packages/core/dist/host/build.d.ts +26 -5
  959. package/packages/core/dist/host/build.d.ts.map +1 -1
  960. package/packages/core/dist/host/build.js +72 -0
  961. package/packages/core/dist/host/build.js.map +1 -1
  962. package/packages/core/dist/host/types.d.ts +67 -5
  963. package/packages/core/dist/host/types.d.ts.map +1 -1
  964. package/packages/core/dist/index.d.ts +1 -0
  965. package/packages/core/dist/index.d.ts.map +1 -1
  966. package/packages/core/dist/index.js +1 -0
  967. package/packages/core/dist/index.js.map +1 -1
  968. package/packages/core/dist/json-schema.d.ts +32 -0
  969. package/packages/core/dist/json-schema.d.ts.map +1 -0
  970. package/packages/core/dist/json-schema.js +147 -0
  971. package/packages/core/dist/json-schema.js.map +1 -0
  972. package/packages/core/dist/learning/sources.d.ts.map +1 -1
  973. package/packages/core/dist/learning/sources.js +3 -0
  974. package/packages/core/dist/learning/sources.js.map +1 -1
  975. package/packages/core/dist/learning/types.d.ts +4 -3
  976. package/packages/core/dist/learning/types.d.ts.map +1 -1
  977. package/packages/core/dist/learning/types.js +1 -1
  978. package/packages/core/dist/learning/types.js.map +1 -1
  979. package/packages/core/dist/notifications/index.d.ts +1 -0
  980. package/packages/core/dist/notifications/index.d.ts.map +1 -1
  981. package/packages/core/dist/notifications/index.js +1 -0
  982. package/packages/core/dist/notifications/index.js.map +1 -1
  983. package/packages/core/dist/notifications/notify.d.ts.map +1 -1
  984. package/packages/core/dist/notifications/notify.js +47 -5
  985. package/packages/core/dist/notifications/notify.js.map +1 -1
  986. package/packages/core/dist/notifications/store.d.ts.map +1 -1
  987. package/packages/core/dist/notifications/store.js +3 -1
  988. package/packages/core/dist/notifications/store.js.map +1 -1
  989. package/packages/core/dist/notifications/topic.d.ts +25 -0
  990. package/packages/core/dist/notifications/topic.d.ts.map +1 -0
  991. package/packages/core/dist/notifications/topic.js +116 -0
  992. package/packages/core/dist/notifications/topic.js.map +1 -0
  993. package/packages/core/dist/notifications/types.d.ts +4 -0
  994. package/packages/core/dist/notifications/types.d.ts.map +1 -1
  995. package/packages/core/dist/onboarding/language-tag.d.ts +12 -0
  996. package/packages/core/dist/onboarding/language-tag.d.ts.map +1 -0
  997. package/packages/core/dist/onboarding/language-tag.js +64 -0
  998. package/packages/core/dist/onboarding/language-tag.js.map +1 -0
  999. package/packages/core/dist/pages/__fixtures__/demo.d.ts +11 -0
  1000. package/packages/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  1001. package/packages/core/dist/pages/__fixtures__/demo.js +23 -1
  1002. package/packages/core/dist/pages/__fixtures__/demo.js.map +1 -1
  1003. package/packages/core/dist/pages.d.ts +19 -0
  1004. package/packages/core/dist/pages.d.ts.map +1 -1
  1005. package/packages/core/dist/pages.js +13 -0
  1006. package/packages/core/dist/pages.js.map +1 -1
  1007. package/packages/core/dist/plugin/index.d.ts +4 -3
  1008. package/packages/core/dist/plugin/index.d.ts.map +1 -1
  1009. package/packages/core/dist/plugin/version.d.ts +1 -1
  1010. package/packages/core/dist/plugin/version.js +1 -1
  1011. package/packages/core/dist/provider-accounts.d.ts +31 -0
  1012. package/packages/core/dist/provider-accounts.d.ts.map +1 -1
  1013. package/packages/core/dist/registry.d.ts +37 -1
  1014. package/packages/core/dist/registry.d.ts.map +1 -1
  1015. package/packages/core/dist/registry.js +187 -32
  1016. package/packages/core/dist/registry.js.map +1 -1
  1017. package/packages/core/dist/secrets/scrub.d.ts +2 -0
  1018. package/packages/core/dist/secrets/scrub.d.ts.map +1 -1
  1019. package/packages/core/dist/secrets/scrub.js +29 -0
  1020. package/packages/core/dist/secrets/scrub.js.map +1 -1
  1021. package/packages/core/dist/tools.d.ts +36 -1
  1022. package/packages/core/dist/tools.d.ts.map +1 -1
  1023. package/packages/core/dist/tools.js.map +1 -1
  1024. package/packages/core/dist/views.d.ts +12 -12
  1025. package/packages/core/migrations/050_notification_topic.sql +8 -0
  1026. package/packages/core/package.json +2 -0
  1027. package/packages/gateway/assets/mascot/core-idle.tgs +0 -0
  1028. package/packages/gateway/assets/mascot/core-working.tgs +0 -0
  1029. package/packages/gateway/dist/.tsbuildinfo +1 -1
  1030. package/packages/gateway/dist/agents/canvas.d.ts +2 -2
  1031. package/packages/gateway/dist/agents/canvas.d.ts.map +1 -1
  1032. package/packages/gateway/dist/agents/canvas.js.map +1 -1
  1033. package/packages/gateway/dist/agents/catalog.d.ts.map +1 -1
  1034. package/packages/gateway/dist/agents/catalog.js +15 -6
  1035. package/packages/gateway/dist/agents/catalog.js.map +1 -1
  1036. package/packages/gateway/dist/agents/delegation.d.ts +20 -3
  1037. package/packages/gateway/dist/agents/delegation.d.ts.map +1 -1
  1038. package/packages/gateway/dist/agents/delegation.js +38 -12
  1039. package/packages/gateway/dist/agents/delegation.js.map +1 -1
  1040. package/packages/gateway/dist/agents/platform.d.ts +43 -13
  1041. package/packages/gateway/dist/agents/platform.d.ts.map +1 -1
  1042. package/packages/gateway/dist/agents/platform.js +97 -3
  1043. package/packages/gateway/dist/agents/platform.js.map +1 -1
  1044. package/packages/gateway/dist/agents/starter-team.d.ts +57 -0
  1045. package/packages/gateway/dist/agents/starter-team.d.ts.map +1 -0
  1046. package/packages/gateway/dist/agents/starter-team.js +151 -0
  1047. package/packages/gateway/dist/agents/starter-team.js.map +1 -0
  1048. package/packages/gateway/dist/anthropic-accounts.d.ts.map +1 -1
  1049. package/packages/gateway/dist/anthropic-accounts.js +9 -20
  1050. package/packages/gateway/dist/anthropic-accounts.js.map +1 -1
  1051. package/packages/gateway/dist/bootstrap.d.ts +3 -0
  1052. package/packages/gateway/dist/bootstrap.d.ts.map +1 -1
  1053. package/packages/gateway/dist/bootstrap.js +58 -2
  1054. package/packages/gateway/dist/bootstrap.js.map +1 -1
  1055. package/packages/gateway/dist/codex-accounts.d.ts +7 -1
  1056. package/packages/gateway/dist/codex-accounts.d.ts.map +1 -1
  1057. package/packages/gateway/dist/codex-accounts.js +25 -26
  1058. package/packages/gateway/dist/codex-accounts.js.map +1 -1
  1059. package/packages/gateway/dist/mcp/requests.d.ts +8 -1
  1060. package/packages/gateway/dist/mcp/requests.d.ts.map +1 -1
  1061. package/packages/gateway/dist/mcp/requests.js +8 -1
  1062. package/packages/gateway/dist/mcp/requests.js.map +1 -1
  1063. package/packages/gateway/dist/missions/goals-page.d.ts.map +1 -1
  1064. package/packages/gateway/dist/missions/goals-page.js +57 -0
  1065. package/packages/gateway/dist/missions/goals-page.js.map +1 -1
  1066. package/packages/gateway/dist/plugins/approve.js +45 -9
  1067. package/packages/gateway/dist/plugins/approve.js.map +1 -1
  1068. package/packages/gateway/dist/plugins/load.d.ts.map +1 -1
  1069. package/packages/gateway/dist/plugins/load.js +4 -0
  1070. package/packages/gateway/dist/plugins/load.js.map +1 -1
  1071. package/packages/gateway/dist/plugins/npm.d.ts +5 -1
  1072. package/packages/gateway/dist/plugins/npm.d.ts.map +1 -1
  1073. package/packages/gateway/dist/plugins/npm.js +6 -0
  1074. package/packages/gateway/dist/plugins/npm.js.map +1 -1
  1075. package/packages/gateway/dist/plugins/scaffold.d.ts +15 -4
  1076. package/packages/gateway/dist/plugins/scaffold.d.ts.map +1 -1
  1077. package/packages/gateway/dist/plugins/scaffold.js +86 -16
  1078. package/packages/gateway/dist/plugins/scaffold.js.map +1 -1
  1079. package/packages/gateway/dist/plugins/stage.d.ts +35 -1
  1080. package/packages/gateway/dist/plugins/stage.d.ts.map +1 -1
  1081. package/packages/gateway/dist/plugins/stage.js +134 -8
  1082. package/packages/gateway/dist/plugins/stage.js.map +1 -1
  1083. package/packages/gateway/dist/plugins-cli.d.ts +5 -1
  1084. package/packages/gateway/dist/plugins-cli.d.ts.map +1 -1
  1085. package/packages/gateway/dist/plugins-cli.js +26 -4
  1086. package/packages/gateway/dist/plugins-cli.js.map +1 -1
  1087. package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
  1088. package/packages/gateway/dist/provider-accounts.js +31 -3
  1089. package/packages/gateway/dist/provider-accounts.js.map +1 -1
  1090. package/packages/gateway/dist/provider-diagnostics.d.ts +14 -2
  1091. package/packages/gateway/dist/provider-diagnostics.d.ts.map +1 -1
  1092. package/packages/gateway/dist/provider-diagnostics.js +25 -9
  1093. package/packages/gateway/dist/provider-diagnostics.js.map +1 -1
  1094. package/packages/gateway/dist/telegram/api.d.ts +49 -0
  1095. package/packages/gateway/dist/telegram/api.d.ts.map +1 -1
  1096. package/packages/gateway/dist/telegram/api.js +99 -0
  1097. package/packages/gateway/dist/telegram/api.js.map +1 -1
  1098. package/packages/gateway/dist/telegram/main.d.ts.map +1 -1
  1099. package/packages/gateway/dist/telegram/main.js +17 -0
  1100. package/packages/gateway/dist/telegram/main.js.map +1 -1
  1101. package/packages/gateway/dist/telegram/outbound.d.ts +5 -0
  1102. package/packages/gateway/dist/telegram/outbound.d.ts.map +1 -1
  1103. package/packages/gateway/dist/telegram/outbound.js +10 -0
  1104. package/packages/gateway/dist/telegram/outbound.js.map +1 -1
  1105. package/packages/gateway/dist/telegram/stickers.d.ts +30 -0
  1106. package/packages/gateway/dist/telegram/stickers.d.ts.map +1 -0
  1107. package/packages/gateway/dist/telegram/stickers.js +146 -0
  1108. package/packages/gateway/dist/telegram/stickers.js.map +1 -0
  1109. package/packages/gateway/dist/telegram/surface.d.ts +6 -0
  1110. package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
  1111. package/packages/gateway/dist/telegram/surface.js +36 -3
  1112. package/packages/gateway/dist/telegram/surface.js.map +1 -1
  1113. package/packages/gateway/dist/tips/engine.d.ts +75 -0
  1114. package/packages/gateway/dist/tips/engine.d.ts.map +1 -0
  1115. package/packages/gateway/dist/tips/engine.js +135 -0
  1116. package/packages/gateway/dist/tips/engine.js.map +1 -0
  1117. package/packages/gateway/dist/tips/facts.d.ts +69 -0
  1118. package/packages/gateway/dist/tips/facts.d.ts.map +1 -0
  1119. package/packages/gateway/dist/tips/facts.js +104 -0
  1120. package/packages/gateway/dist/tips/facts.js.map +1 -0
  1121. package/packages/gateway/dist/tips/route.d.ts +25 -0
  1122. package/packages/gateway/dist/tips/route.d.ts.map +1 -0
  1123. package/packages/gateway/dist/tips/route.js +96 -0
  1124. package/packages/gateway/dist/tips/route.js.map +1 -0
  1125. package/packages/gateway/dist/tips/rules.d.ts +33 -0
  1126. package/packages/gateway/dist/tips/rules.d.ts.map +1 -0
  1127. package/packages/gateway/dist/tips/rules.js +54 -0
  1128. package/packages/gateway/dist/tips/rules.js.map +1 -0
  1129. package/packages/gateway/dist/web/agent-offers.d.ts +30 -0
  1130. package/packages/gateway/dist/web/agent-offers.d.ts.map +1 -1
  1131. package/packages/gateway/dist/web/agent-offers.js +64 -1
  1132. package/packages/gateway/dist/web/agent-offers.js.map +1 -1
  1133. package/packages/gateway/dist/web/connections.d.ts +83 -0
  1134. package/packages/gateway/dist/web/connections.d.ts.map +1 -0
  1135. package/packages/gateway/dist/web/connections.js +270 -0
  1136. package/packages/gateway/dist/web/connections.js.map +1 -0
  1137. package/packages/gateway/dist/web/onboarding.d.ts +1 -1
  1138. package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
  1139. package/packages/gateway/dist/web/onboarding.js +5 -4
  1140. package/packages/gateway/dist/web/onboarding.js.map +1 -1
  1141. package/packages/gateway/dist/web/plugins.d.ts +12 -0
  1142. package/packages/gateway/dist/web/plugins.d.ts.map +1 -1
  1143. package/packages/gateway/dist/web/plugins.js +12 -2
  1144. package/packages/gateway/dist/web/plugins.js.map +1 -1
  1145. package/packages/gateway/dist/web/profile.js +3 -2
  1146. package/packages/gateway/dist/web/profile.js.map +1 -1
  1147. package/packages/gateway/dist/web/read.d.ts +6 -0
  1148. package/packages/gateway/dist/web/read.d.ts.map +1 -1
  1149. package/packages/gateway/dist/web/read.js +11 -4
  1150. package/packages/gateway/dist/web/read.js.map +1 -1
  1151. package/packages/gateway/dist/web/server.d.ts +6 -0
  1152. package/packages/gateway/dist/web/server.d.ts.map +1 -1
  1153. package/packages/gateway/dist/web/server.js +71 -2
  1154. package/packages/gateway/dist/web/server.js.map +1 -1
  1155. package/packages/gateway/dist/web/static.d.ts.map +1 -1
  1156. package/packages/gateway/dist/web/static.js +1 -0
  1157. package/packages/gateway/dist/web/static.js.map +1 -1
  1158. package/packages/gateway/dist/web/version.d.ts +2 -0
  1159. package/packages/gateway/dist/web/version.d.ts.map +1 -1
  1160. package/packages/gateway/dist/web/version.js +27 -0
  1161. package/packages/gateway/dist/web/version.js.map +1 -1
  1162. package/packages/gateway/dist/web/write.d.ts +5 -0
  1163. package/packages/gateway/dist/web/write.d.ts.map +1 -1
  1164. package/packages/gateway/dist/web/write.js +20 -1
  1165. package/packages/gateway/dist/web/write.js.map +1 -1
  1166. package/packages/gateway/package.json +4 -1
  1167. package/packages/gateway/src/agents/starter/keeper/agent.md +31 -0
  1168. package/packages/gateway/src/agents/starter/keeper/skills/keeping-a-history.md +22 -0
  1169. package/packages/gateway/src/agents/starter/planner/agent.md +30 -0
  1170. package/packages/gateway/src/agents/starter/planner/skills/holding-a-follow-up.md +17 -0
  1171. package/packages/gateway/src/agents/starter/planner/skills/writing-the-morning-brief.md +25 -0
  1172. package/packages/gateway/src/agents/starter/scout/agent.md +33 -0
  1173. package/packages/gateway/src/agents/starter/scout/skills/answering-with-sources.md +23 -0
  1174. package/packages/gateway/src/agents/starter/scout/skills/the-web-is-evidence.md +25 -0
  1175. package/packages/install/dist/.tsbuildinfo +1 -1
  1176. package/packages/runtime/dist/.tsbuildinfo +1 -1
  1177. package/packages/runtime/dist/anthropic-oauth.d.ts.map +1 -1
  1178. package/packages/runtime/dist/anthropic-oauth.js +38 -73
  1179. package/packages/runtime/dist/anthropic-oauth.js.map +1 -1
  1180. package/packages/runtime/dist/codex-direct.d.ts +39 -0
  1181. package/packages/runtime/dist/codex-direct.d.ts.map +1 -1
  1182. package/packages/runtime/dist/codex-direct.js +122 -0
  1183. package/packages/runtime/dist/codex-direct.js.map +1 -1
  1184. package/packages/runtime/dist/codex-oauth.d.ts +0 -12
  1185. package/packages/runtime/dist/codex-oauth.d.ts.map +1 -1
  1186. package/packages/runtime/dist/codex-oauth.js +32 -45
  1187. package/packages/runtime/dist/codex-oauth.js.map +1 -1
  1188. package/packages/runtime/dist/delegate.d.ts.map +1 -1
  1189. package/packages/runtime/dist/delegate.js +4 -2
  1190. package/packages/runtime/dist/delegate.js.map +1 -1
  1191. package/packages/runtime/dist/index.d.ts +2 -0
  1192. package/packages/runtime/dist/index.d.ts.map +1 -1
  1193. package/packages/runtime/dist/index.js +2 -0
  1194. package/packages/runtime/dist/index.js.map +1 -1
  1195. package/packages/runtime/dist/oauth-port.d.ts +68 -0
  1196. package/packages/runtime/dist/oauth-port.d.ts.map +1 -0
  1197. package/packages/runtime/dist/oauth-port.js +51 -0
  1198. package/packages/runtime/dist/oauth-port.js.map +1 -0
  1199. package/packages/runtime/dist/oauth.d.ts +255 -0
  1200. package/packages/runtime/dist/oauth.d.ts.map +1 -0
  1201. package/packages/runtime/dist/oauth.js +535 -0
  1202. package/packages/runtime/dist/oauth.js.map +1 -0
  1203. package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
  1204. package/packages/tools/browser/dist/.tsbuildinfo +1 -1
  1205. package/packages/tools/email/dist/.tsbuildinfo +1 -1
  1206. package/packages/tools/email/dist/types.d.ts +2 -2
  1207. package/packages/tools/email/dist/types.d.ts.map +1 -1
  1208. package/packages/tools/host/dist/.tsbuildinfo +1 -1
  1209. package/packages/tools/mcp/dist/.tsbuildinfo +1 -0
  1210. package/packages/tools/mcp/dist/catalog.d.ts +26 -0
  1211. package/packages/tools/mcp/dist/catalog.d.ts.map +1 -0
  1212. package/packages/tools/mcp/dist/catalog.js +17 -0
  1213. package/packages/tools/mcp/dist/catalog.js.map +1 -0
  1214. package/packages/tools/mcp/dist/fetch.d.ts +44 -0
  1215. package/packages/tools/mcp/dist/fetch.d.ts.map +1 -0
  1216. package/packages/tools/mcp/dist/fetch.js +88 -0
  1217. package/packages/tools/mcp/dist/fetch.js.map +1 -0
  1218. package/packages/tools/mcp/dist/index.d.ts +27 -0
  1219. package/packages/tools/mcp/dist/index.d.ts.map +1 -0
  1220. package/packages/tools/mcp/dist/index.js +74 -0
  1221. package/packages/tools/mcp/dist/index.js.map +1 -0
  1222. package/packages/tools/mcp/dist/output.d.ts +38 -0
  1223. package/packages/tools/mcp/dist/output.d.ts.map +1 -0
  1224. package/packages/tools/mcp/dist/output.js +90 -0
  1225. package/packages/tools/mcp/dist/output.js.map +1 -0
  1226. package/packages/tools/mcp/dist/ports.d.ts +105 -0
  1227. package/packages/tools/mcp/dist/ports.d.ts.map +1 -0
  1228. package/packages/tools/mcp/dist/ports.js +9 -0
  1229. package/packages/tools/mcp/dist/ports.js.map +1 -0
  1230. package/packages/tools/mcp/dist/service.d.ts +220 -0
  1231. package/packages/tools/mcp/dist/service.d.ts.map +1 -0
  1232. package/packages/tools/mcp/dist/service.js +742 -0
  1233. package/packages/tools/mcp/dist/service.js.map +1 -0
  1234. package/packages/tools/mcp/dist/session.d.ts +50 -0
  1235. package/packages/tools/mcp/dist/session.d.ts.map +1 -0
  1236. package/packages/tools/mcp/dist/session.js +108 -0
  1237. package/packages/tools/mcp/dist/session.js.map +1 -0
  1238. package/packages/tools/mcp/dist/store.d.ts +70 -0
  1239. package/packages/tools/mcp/dist/store.d.ts.map +1 -0
  1240. package/packages/tools/mcp/dist/store.js +78 -0
  1241. package/packages/tools/mcp/dist/store.js.map +1 -0
  1242. package/packages/tools/mcp/dist/testing/fake.d.ts +51 -0
  1243. package/packages/tools/mcp/dist/testing/fake.d.ts.map +1 -0
  1244. package/packages/tools/mcp/dist/testing/fake.js +147 -0
  1245. package/packages/tools/mcp/dist/testing/fake.js.map +1 -0
  1246. package/packages/tools/mcp/dist/tiers.d.ts +51 -0
  1247. package/packages/tools/mcp/dist/tiers.d.ts.map +1 -0
  1248. package/packages/tools/mcp/dist/tiers.js +106 -0
  1249. package/packages/tools/mcp/dist/tiers.js.map +1 -0
  1250. package/packages/tools/mcp/dist/tokens.d.ts +35 -0
  1251. package/packages/tools/mcp/dist/tokens.d.ts.map +1 -0
  1252. package/packages/tools/mcp/dist/tokens.js +75 -0
  1253. package/packages/tools/mcp/dist/tokens.js.map +1 -0
  1254. package/packages/tools/mcp/migrations/001_connections.sql +49 -0
  1255. package/packages/tools/mcp/migrations/002_review_again.sql +15 -0
  1256. package/packages/tools/mcp/package.json +34 -0
  1257. package/packages/tools/memory/dist/.tsbuildinfo +1 -1
  1258. package/packages/tools/web/dist/.tsbuildinfo +1 -1
  1259. package/packages/web/dist/apple-touch-icon.png +0 -0
  1260. package/packages/web/dist/assets/index-CBEdA2dN.js +125 -0
  1261. package/packages/web/dist/assets/index-Ddp9egOQ.css +1 -0
  1262. package/packages/web/dist/assets/lottie_light-BCNsQpt8.js +9 -0
  1263. package/packages/web/dist/build.json +1 -0
  1264. package/packages/web/dist/icon-192.png +0 -0
  1265. package/packages/web/dist/icon-512.png +0 -0
  1266. package/packages/web/dist/icon-maskable-512.png +0 -0
  1267. package/packages/web/dist/index.html +6 -3
  1268. package/packages/web/dist/manifest.webmanifest +16 -0
  1269. package/packages/web/dist/mascot/README.md +5 -0
  1270. package/packages/web/dist/mascot/anim/core-idle.json +1 -0
  1271. package/packages/web/dist/mascot/anim/core-working.json +1 -0
  1272. package/packages/web/dist/precache.json +28 -0
  1273. package/packages/web/dist/sw.js +99 -0
  1274. package/packages/web/dist/assets/index-D5cRFcgm.css +0 -1
  1275. package/packages/web/dist/assets/index-GCFB1vBV.js +0 -125
@@ -0,0 +1,125 @@
1
+ var Sx=e=>{throw TypeError(e)};var Nx=(e,t,s)=>t.has(e)||Sx("Cannot "+s);var Kt=(e,t,s)=>(Nx(e,t,"read from private field"),s?s.call(e):t.get(e)),Cx=(e,t,s)=>t.has(e)?Sx("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),yd=(e,t,s,r)=>(Nx(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s);function $C(e,t){for(var s=0;s<t.length;s++){const r=t[s];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function s(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=s(i);fetch(i.href,a)}})();var v5=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function OC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Dy={exports:{}},bu={},Ly={exports:{}},Ue={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Xo=Symbol.for("react.element"),_C=Symbol.for("react.portal"),DC=Symbol.for("react.fragment"),LC=Symbol.for("react.strict_mode"),FC=Symbol.for("react.profiler"),UC=Symbol.for("react.provider"),BC=Symbol.for("react.context"),zC=Symbol.for("react.forward_ref"),WC=Symbol.for("react.suspense"),HC=Symbol.for("react.memo"),VC=Symbol.for("react.lazy"),Ex=Symbol.iterator;function KC(e){return e===null||typeof e!="object"?null:(e=Ex&&e[Ex]||e["@@iterator"],typeof e=="function"?e:null)}var Fy={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Uy=Object.assign,By={};function ja(e,t,s){this.props=e,this.context=t,this.refs=By,this.updater=s||Fy}ja.prototype.isReactComponent={};ja.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")};ja.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function zy(){}zy.prototype=ja.prototype;function Up(e,t,s){this.props=e,this.context=t,this.refs=By,this.updater=s||Fy}var Bp=Up.prototype=new zy;Bp.constructor=Up;Uy(Bp,ja.prototype);Bp.isPureReactComponent=!0;var Ax=Array.isArray,Wy=Object.prototype.hasOwnProperty,zp={current:null},Hy={key:!0,ref:!0,__self:!0,__source:!0};function Vy(e,t,s){var r,i={},a=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(a=""+t.key),t)Wy.call(t,r)&&!Hy.hasOwnProperty(r)&&(i[r]=t[r]);var l=arguments.length-2;if(l===1)i.children=s;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)i[r]===void 0&&(i[r]=l[r]);return{$$typeof:Xo,type:e,key:a,ref:o,props:i,_owner:zp.current}}function GC(e,t){return{$$typeof:Xo,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Wp(e){return typeof e=="object"&&e!==null&&e.$$typeof===Xo}function YC(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var Tx=/\/+/g;function wd(e,t){return typeof e=="object"&&e!==null&&e.key!=null?YC(""+e.key):t.toString(36)}function ac(e,t,s,r,i){var a=typeof e;(a==="undefined"||a==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(a){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case Xo:case _C:o=!0}}if(o)return o=e,i=i(o),e=r===""?"."+wd(o,0):r,Ax(i)?(s="",e!=null&&(s=e.replace(Tx,"$&/")+"/"),ac(i,t,s,"",function(u){return u})):i!=null&&(Wp(i)&&(i=GC(i,s+(!i.key||o&&o.key===i.key?"":(""+i.key).replace(Tx,"$&/")+"/")+e)),t.push(i)),1;if(o=0,r=r===""?".":r+":",Ax(e))for(var l=0;l<e.length;l++){a=e[l];var c=r+wd(a,l);o+=ac(a,t,s,c,i)}else if(c=KC(e),typeof c=="function")for(e=c.call(e),l=0;!(a=e.next()).done;)a=a.value,c=r+wd(a,l++),o+=ac(a,t,s,c,i);else if(a==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function vl(e,t,s){if(e==null)return e;var r=[],i=0;return ac(e,r,"","",function(a){return t.call(s,a,i++)}),r}function qC(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var un={current:null},oc={transition:null},QC={ReactCurrentDispatcher:un,ReactCurrentBatchConfig:oc,ReactCurrentOwner:zp};function Ky(){throw Error("act(...) is not supported in production builds of React.")}Ue.Children={map:vl,forEach:function(e,t,s){vl(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return vl(e,function(){t++}),t},toArray:function(e){return vl(e,function(t){return t})||[]},only:function(e){if(!Wp(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ue.Component=ja;Ue.Fragment=DC;Ue.Profiler=FC;Ue.PureComponent=Up;Ue.StrictMode=LC;Ue.Suspense=WC;Ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=QC;Ue.act=Ky;Ue.cloneElement=function(e,t,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Uy({},e.props),i=e.key,a=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(a=t.ref,o=zp.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)Wy.call(t,c)&&!Hy.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=s;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:Xo,type:e.type,key:i,ref:a,props:r,_owner:o}};Ue.createContext=function(e){return e={$$typeof:BC,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:UC,_context:e},e.Consumer=e};Ue.createElement=Vy;Ue.createFactory=function(e){var t=Vy.bind(null,e);return t.type=e,t};Ue.createRef=function(){return{current:null}};Ue.forwardRef=function(e){return{$$typeof:zC,render:e}};Ue.isValidElement=Wp;Ue.lazy=function(e){return{$$typeof:VC,_payload:{_status:-1,_result:e},_init:qC}};Ue.memo=function(e,t){return{$$typeof:HC,type:e,compare:t===void 0?null:t}};Ue.startTransition=function(e){var t=oc.transition;oc.transition={};try{e()}finally{oc.transition=t}};Ue.unstable_act=Ky;Ue.useCallback=function(e,t){return un.current.useCallback(e,t)};Ue.useContext=function(e){return un.current.useContext(e)};Ue.useDebugValue=function(){};Ue.useDeferredValue=function(e){return un.current.useDeferredValue(e)};Ue.useEffect=function(e,t){return un.current.useEffect(e,t)};Ue.useId=function(){return un.current.useId()};Ue.useImperativeHandle=function(e,t,s){return un.current.useImperativeHandle(e,t,s)};Ue.useInsertionEffect=function(e,t){return un.current.useInsertionEffect(e,t)};Ue.useLayoutEffect=function(e,t){return un.current.useLayoutEffect(e,t)};Ue.useMemo=function(e,t){return un.current.useMemo(e,t)};Ue.useReducer=function(e,t,s){return un.current.useReducer(e,t,s)};Ue.useRef=function(e){return un.current.useRef(e)};Ue.useState=function(e){return un.current.useState(e)};Ue.useSyncExternalStore=function(e,t,s){return un.current.useSyncExternalStore(e,t,s)};Ue.useTransition=function(){return un.current.useTransition()};Ue.version="18.3.1";Ly.exports=Ue;var d=Ly.exports;const XC=OC(d),ya=$C({__proto__:null,default:XC},[d]);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var JC=d,ZC=Symbol.for("react.element"),eE=Symbol.for("react.fragment"),tE=Object.prototype.hasOwnProperty,nE=JC.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sE={key:!0,ref:!0,__self:!0,__source:!0};function Gy(e,t,s){var r,i={},a=null,o=null;s!==void 0&&(a=""+s),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)tE.call(t,r)&&!sE.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:ZC,type:e,key:a,ref:o,props:i,_owner:nE.current}}bu.Fragment=eE;bu.jsx=Gy;bu.jsxs=Gy;Dy.exports=bu;var n=Dy.exports,Yy={exports:{}},Mn={},qy={exports:{}},Qy={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(e){function t(D,q){var F=D.length;D.push(q);e:for(;0<F;){var H=F-1>>>1,le=D[H];if(0<i(le,q))D[H]=q,D[F]=le,F=H;else break e}}function s(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var q=D[0],F=D.pop();if(F!==q){D[0]=F;e:for(var H=0,le=D.length,ie=le>>>1;H<ie;){var ae=2*(H+1)-1,ge=D[ae],X=ae+1,de=D[X];if(0>i(ge,F))X<le&&0>i(de,ge)?(D[H]=de,D[X]=F,H=X):(D[H]=ge,D[ae]=F,H=ae);else if(X<le&&0>i(de,F))D[H]=de,D[X]=F,H=X;else break e}}return q}function i(D,q){var F=D.sortIndex-q.sortIndex;return F!==0?F:D.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],u=[],h=1,f=null,p=3,m=!1,j=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(D){for(var q=s(u);q!==null;){if(q.callback===null)r(u);else if(q.startTime<=D)r(u),q.sortIndex=q.expirationTime,t(c,q);else break;q=s(u)}}function g(D){if(w=!1,y(D),!j)if(s(c)!==null)j=!0,L(N);else{var q=s(u);q!==null&&K(g,q.startTime-D)}}function N(D,q){j=!1,w&&(w=!1,v(C),C=-1),m=!0;var F=p;try{for(y(q),f=s(c);f!==null&&(!(f.expirationTime>q)||D&&!P());){var H=f.callback;if(typeof H=="function"){f.callback=null,p=f.priorityLevel;var le=H(f.expirationTime<=q);q=e.unstable_now(),typeof le=="function"?f.callback=le:f===s(c)&&r(c),y(q)}else r(c);f=s(c)}if(f!==null)var ie=!0;else{var ae=s(u);ae!==null&&K(g,ae.startTime-q),ie=!1}return ie}finally{f=null,p=F,m=!1}}var k=!1,S=null,C=-1,R=5,E=-1;function P(){return!(e.unstable_now()-E<R)}function O(){if(S!==null){var D=e.unstable_now();E=D;var q=!0;try{q=S(!0,D)}finally{q?U():(k=!1,S=null)}}else k=!1}var U;if(typeof x=="function")U=function(){x(O)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,M=T.port2;T.port1.onmessage=O,U=function(){M.postMessage(null)}}else U=function(){b(O,0)};function L(D){S=D,k||(k=!0,U())}function K(D,q){C=b(function(){D(e.unstable_now())},q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(D){D.callback=null},e.unstable_continueExecution=function(){j||m||(j=!0,L(N))},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return s(c)},e.unstable_next=function(D){switch(p){case 1:case 2:case 3:var q=3;break;default:q=p}var F=p;p=q;try{return D()}finally{p=F}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(D,q){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var F=p;p=D;try{return q()}finally{p=F}},e.unstable_scheduleCallback=function(D,q,F){var H=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?H+F:H):F=H,D){case 1:var le=-1;break;case 2:le=250;break;case 5:le=1073741823;break;case 4:le=1e4;break;default:le=5e3}return le=F+le,D={id:h++,callback:q,priorityLevel:D,startTime:F,expirationTime:le,sortIndex:-1},F>H?(D.sortIndex=F,t(u,D),s(c)===null&&D===s(u)&&(w?(v(C),C=-1):w=!0,K(g,F-H))):(D.sortIndex=le,t(c,D),j||m||(j=!0,L(N))),D},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(D){var q=p;return function(){var F=p;p=q;try{return D.apply(this,arguments)}finally{p=F}}}})(Qy);qy.exports=Qy;var rE=qy.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 iE=d,Pn=rE;function te(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Xy=new Set,go={};function fi(e,t){ra(e,t),ra(e+"Capture",t)}function ra(e,t){for(go[e]=t,e=0;e<t.length;e++)Xy.add(t[e])}var Hs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ff=Object.prototype.hasOwnProperty,aE=/^[: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]*$/,Rx={},Ix={};function oE(e){return Ff.call(Ix,e)?!0:Ff.call(Rx,e)?!1:aE.test(e)?Ix[e]=!0:(Rx[e]=!0,!1)}function lE(e,t,s,r){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function cE(e,t,s,r){if(t===null||typeof t>"u"||lE(e,t,s,r))return!0;if(r)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function dn(e,t,s,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var Ht={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ht[e]=new dn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ht[t]=new dn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ht[e]=new dn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ht[e]=new dn(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ht[e]=new dn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ht[e]=new dn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ht[e]=new dn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ht[e]=new dn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ht[e]=new dn(e,5,!1,e.toLowerCase(),null,!1,!1)});var Hp=/[\-:]([a-z])/g;function Vp(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Hp,Vp);Ht[t]=new dn(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Hp,Vp);Ht[t]=new dn(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Hp,Vp);Ht[t]=new dn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ht[e]=new dn(e,1,!1,e.toLowerCase(),null,!1,!1)});Ht.xlinkHref=new dn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ht[e]=new dn(e,1,!1,e.toLowerCase(),null,!0,!0)});function Kp(e,t,s,r){var i=Ht.hasOwnProperty(t)?Ht[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(cE(t,s,i,r)&&(s=null),r||i===null?oE(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):i.mustUseProperty?e[i.propertyName]=s===null?i.type===3?!1:"":s:(t=i.attributeName,r=i.attributeNamespace,s===null?e.removeAttribute(t):(i=i.type,s=i===3||i===4&&s===!0?"":""+s,r?e.setAttributeNS(r,t,s):e.setAttribute(t,s))))}var er=iE.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,jl=Symbol.for("react.element"),$i=Symbol.for("react.portal"),Oi=Symbol.for("react.fragment"),Gp=Symbol.for("react.strict_mode"),Uf=Symbol.for("react.profiler"),Jy=Symbol.for("react.provider"),Zy=Symbol.for("react.context"),Yp=Symbol.for("react.forward_ref"),Bf=Symbol.for("react.suspense"),zf=Symbol.for("react.suspense_list"),qp=Symbol.for("react.memo"),ir=Symbol.for("react.lazy"),ew=Symbol.for("react.offscreen"),Px=Symbol.iterator;function Da(e){return e===null||typeof e!="object"?null:(e=Px&&e[Px]||e["@@iterator"],typeof e=="function"?e:null)}var dt=Object.assign,bd;function qa(e){if(bd===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);bd=t&&t[1]||""}return`
34
+ `+bd+e}var kd=!1;function Sd(e,t){if(!e||kd)return"";kd=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(`
35
+ `),a=r.stack.split(`
36
+ `),o=i.length-1,l=a.length-1;1<=o&&0<=l&&i[o]!==a[l];)l--;for(;1<=o&&0<=l;o--,l--)if(i[o]!==a[l]){if(o!==1||l!==1)do if(o--,l--,0>l||i[o]!==a[l]){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<=l);break}}}finally{kd=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?qa(e):""}function uE(e){switch(e.tag){case 5:return qa(e.type);case 16:return qa("Lazy");case 13:return qa("Suspense");case 19:return qa("SuspenseList");case 0:case 2:case 15:return e=Sd(e.type,!1),e;case 11:return e=Sd(e.type.render,!1),e;case 1:return e=Sd(e.type,!0),e;default:return""}}function Wf(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 Oi:return"Fragment";case $i:return"Portal";case Uf:return"Profiler";case Gp:return"StrictMode";case Bf:return"Suspense";case zf:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Zy:return(e.displayName||"Context")+".Consumer";case Jy:return(e._context.displayName||"Context")+".Provider";case Yp:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case qp:return t=e.displayName||null,t!==null?t:Wf(e.type)||"Memo";case ir:t=e._payload,e=e._init;try{return Wf(e(t))}catch{}}return null}function dE(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 Wf(t);case 8:return t===Gp?"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 kr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function tw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function fE(e){var t=tw(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var i=s.get,a=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,a.call(this,o)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yl(e){e._valueTracker||(e._valueTracker=fE(e))}function nw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),r="";return e&&(r=tw(e)?e.checked?"true":"false":e.value),e=r,e!==s?(t.setValue(e),!0):!1}function Pc(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 Hf(e,t){var s=t.checked;return dt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function Mx(e,t){var s=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;s=kr(t.value!=null?t.value:s),e._wrapperState={initialChecked:r,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function sw(e,t){t=t.checked,t!=null&&Kp(e,"checked",t,!1)}function Vf(e,t){sw(e,t);var s=kr(t.value),r=t.type;if(s!=null)r==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Kf(e,t.type,s):t.hasOwnProperty("defaultValue")&&Kf(e,t.type,kr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function $x(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function Kf(e,t,s){(t!=="number"||Pc(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var Qa=Array.isArray;function Yi(e,t,s,r){if(e=e.options,t){t={};for(var i=0;i<s.length;i++)t["$"+s[i]]=!0;for(s=0;s<e.length;s++)i=t.hasOwnProperty("$"+e[s].value),e[s].selected!==i&&(e[s].selected=i),i&&r&&(e[s].defaultSelected=!0)}else{for(s=""+kr(s),t=null,i=0;i<e.length;i++){if(e[i].value===s){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Gf(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(te(91));return dt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ox(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(te(92));if(Qa(s)){if(1<s.length)throw Error(te(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:kr(s)}}function rw(e,t){var s=kr(t.value),r=kr(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),r!=null&&(e.defaultValue=""+r)}function _x(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function iw(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 Yf(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?iw(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var wl,aw=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,s,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(wl=wl||document.createElement("div"),wl.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=wl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function xo(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var eo={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},hE=["Webkit","ms","Moz","O"];Object.keys(eo).forEach(function(e){hE.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),eo[t]=eo[e]})});function ow(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||eo.hasOwnProperty(e)&&eo[e]?(""+t).trim():t+"px"}function lw(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var r=s.indexOf("--")===0,i=ow(s,t[s],r);s==="float"&&(s="cssFloat"),r?e.setProperty(s,i):e[s]=i}}var pE=dt({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 qf(e,t){if(t){if(pE[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(te(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(te(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(te(61))}if(t.style!=null&&typeof t.style!="object")throw Error(te(62))}}function Qf(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Xf=null;function Qp(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Jf=null,qi=null,Qi=null;function Dx(e){if(e=el(e)){if(typeof Jf!="function")throw Error(te(280));var t=e.stateNode;t&&(t=Eu(t),Jf(e.stateNode,e.type,t))}}function cw(e){qi?Qi?Qi.push(e):Qi=[e]:qi=e}function uw(){if(qi){var e=qi,t=Qi;if(Qi=qi=null,Dx(e),t)for(e=0;e<t.length;e++)Dx(t[e])}}function dw(e,t){return e(t)}function fw(){}var Nd=!1;function hw(e,t,s){if(Nd)return e(t,s);Nd=!0;try{return dw(e,t,s)}finally{Nd=!1,(qi!==null||Qi!==null)&&(fw(),uw())}}function vo(e,t){var s=e.stateNode;if(s===null)return null;var r=Eu(s);if(r===null)return null;s=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(te(231,t,typeof s));return s}var Zf=!1;if(Hs)try{var La={};Object.defineProperty(La,"passive",{get:function(){Zf=!0}}),window.addEventListener("test",La,La),window.removeEventListener("test",La,La)}catch{Zf=!1}function mE(e,t,s,r,i,a,o,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(s,u)}catch(h){this.onError(h)}}var to=!1,Mc=null,$c=!1,eh=null,gE={onError:function(e){to=!0,Mc=e}};function xE(e,t,s,r,i,a,o,l,c){to=!1,Mc=null,mE.apply(gE,arguments)}function vE(e,t,s,r,i,a,o,l,c){if(xE.apply(this,arguments),to){if(to){var u=Mc;to=!1,Mc=null}else throw Error(te(198));$c||($c=!0,eh=u)}}function hi(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function pw(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 Lx(e){if(hi(e)!==e)throw Error(te(188))}function jE(e){var t=e.alternate;if(!t){if(t=hi(e),t===null)throw Error(te(188));return t!==e?null:e}for(var s=e,r=t;;){var i=s.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){s=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===s)return Lx(i),e;if(a===r)return Lx(i),t;a=a.sibling}throw Error(te(188))}if(s.return!==r.return)s=i,r=a;else{for(var o=!1,l=i.child;l;){if(l===s){o=!0,s=i,r=a;break}if(l===r){o=!0,r=i,s=a;break}l=l.sibling}if(!o){for(l=a.child;l;){if(l===s){o=!0,s=a,r=i;break}if(l===r){o=!0,r=a,s=i;break}l=l.sibling}if(!o)throw Error(te(189))}}if(s.alternate!==r)throw Error(te(190))}if(s.tag!==3)throw Error(te(188));return s.stateNode.current===s?e:t}function mw(e){return e=jE(e),e!==null?gw(e):null}function gw(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=gw(e);if(t!==null)return t;e=e.sibling}return null}var xw=Pn.unstable_scheduleCallback,Fx=Pn.unstable_cancelCallback,yE=Pn.unstable_shouldYield,wE=Pn.unstable_requestPaint,xt=Pn.unstable_now,bE=Pn.unstable_getCurrentPriorityLevel,Xp=Pn.unstable_ImmediatePriority,vw=Pn.unstable_UserBlockingPriority,Oc=Pn.unstable_NormalPriority,kE=Pn.unstable_LowPriority,jw=Pn.unstable_IdlePriority,ku=null,ws=null;function SE(e){if(ws&&typeof ws.onCommitFiberRoot=="function")try{ws.onCommitFiberRoot(ku,e,void 0,(e.current.flags&128)===128)}catch{}}var Zn=Math.clz32?Math.clz32:EE,NE=Math.log,CE=Math.LN2;function EE(e){return e>>>=0,e===0?32:31-(NE(e)/CE|0)|0}var bl=64,kl=4194304;function Xa(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 _c(e,t){var s=e.pendingLanes;if(s===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=s&268435455;if(o!==0){var l=o&~i;l!==0?r=Xa(l):(a&=o,a!==0&&(r=Xa(a)))}else o=s&~i,o!==0?r=Xa(o):a!==0&&(r=Xa(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,a=t&-t,i>=a||i===16&&(a&4194240)!==0))return t;if(r&4&&(r|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)s=31-Zn(t),i=1<<s,r|=e[s],t&=~i;return r}function AE(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 TE(e,t){for(var s=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes;0<a;){var o=31-Zn(a),l=1<<o,c=i[o];c===-1?(!(l&s)||l&r)&&(i[o]=AE(l,t)):c<=t&&(e.expiredLanes|=l),a&=~l}}function th(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function yw(){var e=bl;return bl<<=1,!(bl&4194240)&&(bl=64),e}function Cd(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function Jo(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Zn(t),e[t]=s}function RE(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<s;){var i=31-Zn(s),a=1<<i;t[i]=0,r[i]=-1,e[i]=-1,s&=~a}}function Jp(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var r=31-Zn(s),i=1<<r;i&t|e[r]&t&&(e[r]|=t),s&=~i}}var qe=0;function ww(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var bw,Zp,kw,Sw,Nw,nh=!1,Sl=[],fr=null,hr=null,pr=null,jo=new Map,yo=new Map,or=[],IE="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 Ux(e,t){switch(e){case"focusin":case"focusout":fr=null;break;case"dragenter":case"dragleave":hr=null;break;case"mouseover":case"mouseout":pr=null;break;case"pointerover":case"pointerout":jo.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":yo.delete(t.pointerId)}}function Fa(e,t,s,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:s,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=el(t),t!==null&&Zp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function PE(e,t,s,r,i){switch(t){case"focusin":return fr=Fa(fr,e,t,s,r,i),!0;case"dragenter":return hr=Fa(hr,e,t,s,r,i),!0;case"mouseover":return pr=Fa(pr,e,t,s,r,i),!0;case"pointerover":var a=i.pointerId;return jo.set(a,Fa(jo.get(a)||null,e,t,s,r,i)),!0;case"gotpointercapture":return a=i.pointerId,yo.set(a,Fa(yo.get(a)||null,e,t,s,r,i)),!0}return!1}function Cw(e){var t=Gr(e.target);if(t!==null){var s=hi(t);if(s!==null){if(t=s.tag,t===13){if(t=pw(s),t!==null){e.blockedOn=t,Nw(e.priority,function(){kw(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function lc(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=sh(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var r=new s.constructor(s.type,s);Xf=r,s.target.dispatchEvent(r),Xf=null}else return t=el(s),t!==null&&Zp(t),e.blockedOn=s,!1;t.shift()}return!0}function Bx(e,t,s){lc(e)&&s.delete(t)}function ME(){nh=!1,fr!==null&&lc(fr)&&(fr=null),hr!==null&&lc(hr)&&(hr=null),pr!==null&&lc(pr)&&(pr=null),jo.forEach(Bx),yo.forEach(Bx)}function Ua(e,t){e.blockedOn===t&&(e.blockedOn=null,nh||(nh=!0,Pn.unstable_scheduleCallback(Pn.unstable_NormalPriority,ME)))}function wo(e){function t(i){return Ua(i,e)}if(0<Sl.length){Ua(Sl[0],e);for(var s=1;s<Sl.length;s++){var r=Sl[s];r.blockedOn===e&&(r.blockedOn=null)}}for(fr!==null&&Ua(fr,e),hr!==null&&Ua(hr,e),pr!==null&&Ua(pr,e),jo.forEach(t),yo.forEach(t),s=0;s<or.length;s++)r=or[s],r.blockedOn===e&&(r.blockedOn=null);for(;0<or.length&&(s=or[0],s.blockedOn===null);)Cw(s),s.blockedOn===null&&or.shift()}var Xi=er.ReactCurrentBatchConfig,Dc=!0;function $E(e,t,s,r){var i=qe,a=Xi.transition;Xi.transition=null;try{qe=1,em(e,t,s,r)}finally{qe=i,Xi.transition=a}}function OE(e,t,s,r){var i=qe,a=Xi.transition;Xi.transition=null;try{qe=4,em(e,t,s,r)}finally{qe=i,Xi.transition=a}}function em(e,t,s,r){if(Dc){var i=sh(e,t,s,r);if(i===null)_d(e,t,r,Lc,s),Ux(e,r);else if(PE(i,e,t,s,r))r.stopPropagation();else if(Ux(e,r),t&4&&-1<IE.indexOf(e)){for(;i!==null;){var a=el(i);if(a!==null&&bw(a),a=sh(e,t,s,r),a===null&&_d(e,t,r,Lc,s),a===i)break;i=a}i!==null&&r.stopPropagation()}else _d(e,t,r,null,s)}}var Lc=null;function sh(e,t,s,r){if(Lc=null,e=Qp(r),e=Gr(e),e!==null)if(t=hi(e),t===null)e=null;else if(s=t.tag,s===13){if(e=pw(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Lc=e,null}function Ew(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(bE()){case Xp:return 1;case vw:return 4;case Oc:case kE:return 16;case jw:return 536870912;default:return 16}default:return 16}}var cr=null,tm=null,cc=null;function Aw(){if(cc)return cc;var e,t=tm,s=t.length,r,i="value"in cr?cr.value:cr.textContent,a=i.length;for(e=0;e<s&&t[e]===i[e];e++);var o=s-e;for(r=1;r<=o&&t[s-r]===i[a-r];r++);return cc=i.slice(e,1<r?1-r:void 0)}function uc(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 Nl(){return!0}function zx(){return!1}function $n(e){function t(s,r,i,a,o){this._reactName=s,this._targetInst=i,this.type=r,this.nativeEvent=a,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(s=e[l],this[l]=s?s(a):a[l]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?Nl:zx,this.isPropagationStopped=zx,this}return dt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Nl)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Nl)},persist:function(){},isPersistent:Nl}),t}var wa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nm=$n(wa),Zo=dt({},wa,{view:0,detail:0}),_E=$n(Zo),Ed,Ad,Ba,Su=dt({},Zo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sm,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!==Ba&&(Ba&&e.type==="mousemove"?(Ed=e.screenX-Ba.screenX,Ad=e.screenY-Ba.screenY):Ad=Ed=0,Ba=e),Ed)},movementY:function(e){return"movementY"in e?e.movementY:Ad}}),Wx=$n(Su),DE=dt({},Su,{dataTransfer:0}),LE=$n(DE),FE=dt({},Zo,{relatedTarget:0}),Td=$n(FE),UE=dt({},wa,{animationName:0,elapsedTime:0,pseudoElement:0}),BE=$n(UE),zE=dt({},wa,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),WE=$n(zE),HE=dt({},wa,{data:0}),Hx=$n(HE),VE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},KE={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"},GE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function YE(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=GE[e])?!!t[e]:!1}function sm(){return YE}var qE=dt({},Zo,{key:function(e){if(e.key){var t=VE[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=uc(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?KE[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sm,charCode:function(e){return e.type==="keypress"?uc(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?uc(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),QE=$n(qE),XE=dt({},Su,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Vx=$n(XE),JE=dt({},Zo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sm}),ZE=$n(JE),eA=dt({},wa,{propertyName:0,elapsedTime:0,pseudoElement:0}),tA=$n(eA),nA=dt({},Su,{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}),sA=$n(nA),rA=[9,13,27,32],rm=Hs&&"CompositionEvent"in window,no=null;Hs&&"documentMode"in document&&(no=document.documentMode);var iA=Hs&&"TextEvent"in window&&!no,Tw=Hs&&(!rm||no&&8<no&&11>=no),Kx=" ",Gx=!1;function Rw(e,t){switch(e){case"keyup":return rA.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Iw(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var _i=!1;function aA(e,t){switch(e){case"compositionend":return Iw(t);case"keypress":return t.which!==32?null:(Gx=!0,Kx);case"textInput":return e=t.data,e===Kx&&Gx?null:e;default:return null}}function oA(e,t){if(_i)return e==="compositionend"||!rm&&Rw(e,t)?(e=Aw(),cc=tm=cr=null,_i=!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 Tw&&t.locale!=="ko"?null:t.data;default:return null}}var lA={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 Yx(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!lA[e.type]:t==="textarea"}function Pw(e,t,s,r){cw(r),t=Fc(t,"onChange"),0<t.length&&(s=new nm("onChange","change",null,s,r),e.push({event:s,listeners:t}))}var so=null,bo=null;function cA(e){Ww(e,0)}function Nu(e){var t=Fi(e);if(nw(t))return e}function uA(e,t){if(e==="change")return t}var Mw=!1;if(Hs){var Rd;if(Hs){var Id="oninput"in document;if(!Id){var qx=document.createElement("div");qx.setAttribute("oninput","return;"),Id=typeof qx.oninput=="function"}Rd=Id}else Rd=!1;Mw=Rd&&(!document.documentMode||9<document.documentMode)}function Qx(){so&&(so.detachEvent("onpropertychange",$w),bo=so=null)}function $w(e){if(e.propertyName==="value"&&Nu(bo)){var t=[];Pw(t,bo,e,Qp(e)),hw(cA,t)}}function dA(e,t,s){e==="focusin"?(Qx(),so=t,bo=s,so.attachEvent("onpropertychange",$w)):e==="focusout"&&Qx()}function fA(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Nu(bo)}function hA(e,t){if(e==="click")return Nu(t)}function pA(e,t){if(e==="input"||e==="change")return Nu(t)}function mA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ns=typeof Object.is=="function"?Object.is:mA;function ko(e,t){if(ns(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(r=0;r<s.length;r++){var i=s[r];if(!Ff.call(t,i)||!ns(e[i],t[i]))return!1}return!0}function Xx(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jx(e,t){var s=Xx(e);e=0;for(var r;s;){if(s.nodeType===3){if(r=e+s.textContent.length,e<=t&&r>=t)return{node:s,offset:t-e};e=r}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Xx(s)}}function Ow(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ow(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function _w(){for(var e=window,t=Pc();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Pc(e.document)}return t}function im(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 gA(e){var t=_w(),s=e.focusedElem,r=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Ow(s.ownerDocument.documentElement,s)){if(r!==null&&im(s)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=s.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Jx(s,a);var o=Jx(s,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(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var xA=Hs&&"documentMode"in document&&11>=document.documentMode,Di=null,rh=null,ro=null,ih=!1;function Zx(e,t,s){var r=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;ih||Di==null||Di!==Pc(r)||(r=Di,"selectionStart"in r&&im(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}),ro&&ko(ro,r)||(ro=r,r=Fc(rh,"onSelect"),0<r.length&&(t=new nm("onSelect","select",null,t,s),e.push({event:t,listeners:r}),t.target=Di)))}function Cl(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Li={animationend:Cl("Animation","AnimationEnd"),animationiteration:Cl("Animation","AnimationIteration"),animationstart:Cl("Animation","AnimationStart"),transitionend:Cl("Transition","TransitionEnd")},Pd={},Dw={};Hs&&(Dw=document.createElement("div").style,"AnimationEvent"in window||(delete Li.animationend.animation,delete Li.animationiteration.animation,delete Li.animationstart.animation),"TransitionEvent"in window||delete Li.transitionend.transition);function Cu(e){if(Pd[e])return Pd[e];if(!Li[e])return e;var t=Li[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Dw)return Pd[e]=t[s];return e}var Lw=Cu("animationend"),Fw=Cu("animationiteration"),Uw=Cu("animationstart"),Bw=Cu("transitionend"),zw=new Map,ev="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 Ir(e,t){zw.set(e,t),fi(t,[e])}for(var Md=0;Md<ev.length;Md++){var $d=ev[Md],vA=$d.toLowerCase(),jA=$d[0].toUpperCase()+$d.slice(1);Ir(vA,"on"+jA)}Ir(Lw,"onAnimationEnd");Ir(Fw,"onAnimationIteration");Ir(Uw,"onAnimationStart");Ir("dblclick","onDoubleClick");Ir("focusin","onFocus");Ir("focusout","onBlur");Ir(Bw,"onTransitionEnd");ra("onMouseEnter",["mouseout","mouseover"]);ra("onMouseLeave",["mouseout","mouseover"]);ra("onPointerEnter",["pointerout","pointerover"]);ra("onPointerLeave",["pointerout","pointerover"]);fi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));fi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));fi("onBeforeInput",["compositionend","keypress","textInput","paste"]);fi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));fi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));fi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ja="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(" "),yA=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ja));function tv(e,t,s){var r=e.type||"unknown-event";e.currentTarget=s,vE(r,t,void 0,e),e.currentTarget=null}function Ww(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var r=e[s],i=r.event;r=r.listeners;e:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var l=r[o],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==a&&i.isPropagationStopped())break e;tv(i,l,u),a=c}else for(o=0;o<r.length;o++){if(l=r[o],c=l.instance,u=l.currentTarget,l=l.listener,c!==a&&i.isPropagationStopped())break e;tv(i,l,u),a=c}}}if($c)throw e=eh,$c=!1,eh=null,e}function Je(e,t){var s=t[uh];s===void 0&&(s=t[uh]=new Set);var r=e+"__bubble";s.has(r)||(Hw(t,e,2,!1),s.add(r))}function Od(e,t,s){var r=0;t&&(r|=4),Hw(s,e,r,t)}var El="_reactListening"+Math.random().toString(36).slice(2);function So(e){if(!e[El]){e[El]=!0,Xy.forEach(function(s){s!=="selectionchange"&&(yA.has(s)||Od(s,!1,e),Od(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[El]||(t[El]=!0,Od("selectionchange",!1,t))}}function Hw(e,t,s,r){switch(Ew(t)){case 1:var i=$E;break;case 4:i=OE;break;default:i=em}s=i.bind(null,t,s,e),i=void 0,!Zf||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,s,{capture:!0,passive:i}):e.addEventListener(t,s,!0):i!==void 0?e.addEventListener(t,s,{passive:i}):e.addEventListener(t,s,!1)}function _d(e,t,s,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var l=r.stateNode.containerInfo;if(l===i||l.nodeType===8&&l.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(;l!==null;){if(o=Gr(l),o===null)return;if(c=o.tag,c===5||c===6){r=a=o;continue e}l=l.parentNode}}r=r.return}hw(function(){var u=a,h=Qp(s),f=[];e:{var p=zw.get(e);if(p!==void 0){var m=nm,j=e;switch(e){case"keypress":if(uc(s)===0)break e;case"keydown":case"keyup":m=QE;break;case"focusin":j="focus",m=Td;break;case"focusout":j="blur",m=Td;break;case"beforeblur":case"afterblur":m=Td;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=Wx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=LE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=ZE;break;case Lw:case Fw:case Uw:m=BE;break;case Bw:m=tA;break;case"scroll":m=_E;break;case"wheel":m=sA;break;case"copy":case"cut":case"paste":m=WE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=Vx}var w=(t&4)!==0,b=!w&&e==="scroll",v=w?p!==null?p+"Capture":null:p;w=[];for(var x=u,y;x!==null;){y=x;var g=y.stateNode;if(y.tag===5&&g!==null&&(y=g,v!==null&&(g=vo(x,v),g!=null&&w.push(No(x,g,y)))),b)break;x=x.return}0<w.length&&(p=new m(p,j,null,s,h),f.push({event:p,listeners:w}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&s!==Xf&&(j=s.relatedTarget||s.fromElement)&&(Gr(j)||j[Vs]))break e;if((m||p)&&(p=h.window===h?h:(p=h.ownerDocument)?p.defaultView||p.parentWindow:window,m?(j=s.relatedTarget||s.toElement,m=u,j=j?Gr(j):null,j!==null&&(b=hi(j),j!==b||j.tag!==5&&j.tag!==6)&&(j=null)):(m=null,j=u),m!==j)){if(w=Wx,g="onMouseLeave",v="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(w=Vx,g="onPointerLeave",v="onPointerEnter",x="pointer"),b=m==null?p:Fi(m),y=j==null?p:Fi(j),p=new w(g,x+"leave",m,s,h),p.target=b,p.relatedTarget=y,g=null,Gr(h)===u&&(w=new w(v,x+"enter",j,s,h),w.target=y,w.relatedTarget=b,g=w),b=g,m&&j)t:{for(w=m,v=j,x=0,y=w;y;y=Ni(y))x++;for(y=0,g=v;g;g=Ni(g))y++;for(;0<x-y;)w=Ni(w),x--;for(;0<y-x;)v=Ni(v),y--;for(;x--;){if(w===v||v!==null&&w===v.alternate)break t;w=Ni(w),v=Ni(v)}w=null}else w=null;m!==null&&nv(f,p,m,w,!1),j!==null&&b!==null&&nv(f,b,j,w,!0)}}e:{if(p=u?Fi(u):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var N=uA;else if(Yx(p))if(Mw)N=pA;else{N=fA;var k=dA}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(N=hA);if(N&&(N=N(e,u))){Pw(f,N,s,h);break e}k&&k(e,p,u),e==="focusout"&&(k=p._wrapperState)&&k.controlled&&p.type==="number"&&Kf(p,"number",p.value)}switch(k=u?Fi(u):window,e){case"focusin":(Yx(k)||k.contentEditable==="true")&&(Di=k,rh=u,ro=null);break;case"focusout":ro=rh=Di=null;break;case"mousedown":ih=!0;break;case"contextmenu":case"mouseup":case"dragend":ih=!1,Zx(f,s,h);break;case"selectionchange":if(xA)break;case"keydown":case"keyup":Zx(f,s,h)}var S;if(rm)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 _i?Rw(e,s)&&(C="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(C="onCompositionStart");C&&(Tw&&s.locale!=="ko"&&(_i||C!=="onCompositionStart"?C==="onCompositionEnd"&&_i&&(S=Aw()):(cr=h,tm="value"in cr?cr.value:cr.textContent,_i=!0)),k=Fc(u,C),0<k.length&&(C=new Hx(C,e,null,s,h),f.push({event:C,listeners:k}),S?C.data=S:(S=Iw(s),S!==null&&(C.data=S)))),(S=iA?aA(e,s):oA(e,s))&&(u=Fc(u,"onBeforeInput"),0<u.length&&(h=new Hx("onBeforeInput","beforeinput",null,s,h),f.push({event:h,listeners:u}),h.data=S))}Ww(f,t)})}function No(e,t,s){return{instance:e,listener:t,currentTarget:s}}function Fc(e,t){for(var s=t+"Capture",r=[];e!==null;){var i=e,a=i.stateNode;i.tag===5&&a!==null&&(i=a,a=vo(e,s),a!=null&&r.unshift(No(e,a,i)),a=vo(e,t),a!=null&&r.push(No(e,a,i))),e=e.return}return r}function Ni(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function nv(e,t,s,r,i){for(var a=t._reactName,o=[];s!==null&&s!==r;){var l=s,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,i?(c=vo(s,a),c!=null&&o.unshift(No(s,c,l))):i||(c=vo(s,a),c!=null&&o.push(No(s,c,l)))),s=s.return}o.length!==0&&e.push({event:t,listeners:o})}var wA=/\r\n?/g,bA=/\u0000|\uFFFD/g;function sv(e){return(typeof e=="string"?e:""+e).replace(wA,`
38
+ `).replace(bA,"")}function Al(e,t,s){if(t=sv(t),sv(e)!==t&&s)throw Error(te(425))}function Uc(){}var ah=null,oh=null;function lh(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 ch=typeof setTimeout=="function"?setTimeout:void 0,kA=typeof clearTimeout=="function"?clearTimeout:void 0,rv=typeof Promise=="function"?Promise:void 0,SA=typeof queueMicrotask=="function"?queueMicrotask:typeof rv<"u"?function(e){return rv.resolve(null).then(e).catch(NA)}:ch;function NA(e){setTimeout(function(){throw e})}function Dd(e,t){var s=t,r=0;do{var i=s.nextSibling;if(e.removeChild(s),i&&i.nodeType===8)if(s=i.data,s==="/$"){if(r===0){e.removeChild(i),wo(t);return}r--}else s!=="$"&&s!=="$?"&&s!=="$!"||r++;s=i}while(s);wo(t)}function mr(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 iv(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var ba=Math.random().toString(36).slice(2),xs="__reactFiber$"+ba,Co="__reactProps$"+ba,Vs="__reactContainer$"+ba,uh="__reactEvents$"+ba,CA="__reactListeners$"+ba,EA="__reactHandles$"+ba;function Gr(e){var t=e[xs];if(t)return t;for(var s=e.parentNode;s;){if(t=s[Vs]||s[xs]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=iv(e);e!==null;){if(s=e[xs])return s;e=iv(e)}return t}e=s,s=e.parentNode}return null}function el(e){return e=e[xs]||e[Vs],!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(te(33))}function Eu(e){return e[Co]||null}var dh=[],Ui=-1;function Pr(e){return{current:e}}function et(e){0>Ui||(e.current=dh[Ui],dh[Ui]=null,Ui--)}function Xe(e,t){Ui++,dh[Ui]=e.current,e.current=t}var Sr={},Jt=Pr(Sr),xn=Pr(!1),ti=Sr;function ia(e,t){var s=e.type.contextTypes;if(!s)return Sr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in s)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function vn(e){return e=e.childContextTypes,e!=null}function Bc(){et(xn),et(Jt)}function av(e,t,s){if(Jt.current!==Sr)throw Error(te(168));Xe(Jt,t),Xe(xn,s)}function Vw(e,t,s){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return s;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(te(108,dE(e)||"Unknown",i));return dt({},s,r)}function zc(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Sr,ti=Jt.current,Xe(Jt,e),Xe(xn,xn.current),!0}function ov(e,t,s){var r=e.stateNode;if(!r)throw Error(te(169));s?(e=Vw(e,t,ti),r.__reactInternalMemoizedMergedChildContext=e,et(xn),et(Jt),Xe(Jt,e)):et(xn),Xe(xn,s)}var _s=null,Au=!1,Ld=!1;function Kw(e){_s===null?_s=[e]:_s.push(e)}function AA(e){Au=!0,Kw(e)}function Mr(){if(!Ld&&_s!==null){Ld=!0;var e=0,t=qe;try{var s=_s;for(qe=1;e<s.length;e++){var r=s[e];do r=r(!0);while(r!==null)}_s=null,Au=!1}catch(i){throw _s!==null&&(_s=_s.slice(e+1)),xw(Xp,Mr),i}finally{qe=t,Ld=!1}}return null}var Bi=[],zi=0,Wc=null,Hc=0,Ln=[],Fn=0,ni=null,Ls=1,Fs="";function Vr(e,t){Bi[zi++]=Hc,Bi[zi++]=Wc,Wc=e,Hc=t}function Gw(e,t,s){Ln[Fn++]=Ls,Ln[Fn++]=Fs,Ln[Fn++]=ni,ni=e;var r=Ls;e=Fs;var i=32-Zn(r)-1;r&=~(1<<i),s+=1;var a=32-Zn(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ls=1<<32-Zn(t)+i|s<<i|r,Fs=a+e}else Ls=1<<a|s<<i|r,Fs=e}function am(e){e.return!==null&&(Vr(e,1),Gw(e,1,0))}function om(e){for(;e===Wc;)Wc=Bi[--zi],Bi[zi]=null,Hc=Bi[--zi],Bi[zi]=null;for(;e===ni;)ni=Ln[--Fn],Ln[Fn]=null,Fs=Ln[--Fn],Ln[Fn]=null,Ls=Ln[--Fn],Ln[Fn]=null}var In=null,Tn=null,st=!1,Xn=null;function Yw(e,t){var s=Bn(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function lv(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,In=e,Tn=mr(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,In=e,Tn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=ni!==null?{id:Ls,overflow:Fs}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=Bn(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,In=e,Tn=null,!0):!1;default:return!1}}function fh(e){return(e.mode&1)!==0&&(e.flags&128)===0}function hh(e){if(st){var t=Tn;if(t){var s=t;if(!lv(e,t)){if(fh(e))throw Error(te(418));t=mr(s.nextSibling);var r=In;t&&lv(e,t)?Yw(r,s):(e.flags=e.flags&-4097|2,st=!1,In=e)}}else{if(fh(e))throw Error(te(418));e.flags=e.flags&-4097|2,st=!1,In=e}}}function cv(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;In=e}function Tl(e){if(e!==In)return!1;if(!st)return cv(e),st=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!lh(e.type,e.memoizedProps)),t&&(t=Tn)){if(fh(e))throw qw(),Error(te(418));for(;t;)Yw(e,t),t=mr(t.nextSibling)}if(cv(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(te(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){Tn=mr(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}Tn=null}}else Tn=In?mr(e.stateNode.nextSibling):null;return!0}function qw(){for(var e=Tn;e;)e=mr(e.nextSibling)}function aa(){Tn=In=null,st=!1}function lm(e){Xn===null?Xn=[e]:Xn.push(e)}var TA=er.ReactCurrentBatchConfig;function za(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(te(309));var r=s.stateNode}if(!r)throw Error(te(147,e));var i=r,a=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===a?t.ref:(t=function(o){var l=i.refs;o===null?delete l[a]:l[a]=o},t._stringRef=a,t)}if(typeof e!="string")throw Error(te(284));if(!s._owner)throw Error(te(290,e))}return e}function Rl(e,t){throw e=Object.prototype.toString.call(t),Error(te(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function uv(e){var t=e._init;return t(e._payload)}function Qw(e){function t(v,x){if(e){var y=v.deletions;y===null?(v.deletions=[x],v.flags|=16):y.push(x)}}function s(v,x){if(!e)return null;for(;x!==null;)t(v,x),x=x.sibling;return null}function r(v,x){for(v=new Map;x!==null;)x.key!==null?v.set(x.key,x):v.set(x.index,x),x=x.sibling;return v}function i(v,x){return v=jr(v,x),v.index=0,v.sibling=null,v}function a(v,x,y){return v.index=y,e?(y=v.alternate,y!==null?(y=y.index,y<x?(v.flags|=2,x):y):(v.flags|=2,x)):(v.flags|=1048576,x)}function o(v){return e&&v.alternate===null&&(v.flags|=2),v}function l(v,x,y,g){return x===null||x.tag!==6?(x=Vd(y,v.mode,g),x.return=v,x):(x=i(x,y),x.return=v,x)}function c(v,x,y,g){var N=y.type;return N===Oi?h(v,x,y.props.children,g,y.key):x!==null&&(x.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===ir&&uv(N)===x.type)?(g=i(x,y.props),g.ref=za(v,x,y),g.return=v,g):(g=xc(y.type,y.key,y.props,null,v.mode,g),g.ref=za(v,x,y),g.return=v,g)}function u(v,x,y,g){return x===null||x.tag!==4||x.stateNode.containerInfo!==y.containerInfo||x.stateNode.implementation!==y.implementation?(x=Kd(y,v.mode,g),x.return=v,x):(x=i(x,y.children||[]),x.return=v,x)}function h(v,x,y,g,N){return x===null||x.tag!==7?(x=Xr(y,v.mode,g,N),x.return=v,x):(x=i(x,y),x.return=v,x)}function f(v,x,y){if(typeof x=="string"&&x!==""||typeof x=="number")return x=Vd(""+x,v.mode,y),x.return=v,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case jl:return y=xc(x.type,x.key,x.props,null,v.mode,y),y.ref=za(v,null,x),y.return=v,y;case $i:return x=Kd(x,v.mode,y),x.return=v,x;case ir:var g=x._init;return f(v,g(x._payload),y)}if(Qa(x)||Da(x))return x=Xr(x,v.mode,y,null),x.return=v,x;Rl(v,x)}return null}function p(v,x,y,g){var N=x!==null?x.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return N!==null?null:l(v,x,""+y,g);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case jl:return y.key===N?c(v,x,y,g):null;case $i:return y.key===N?u(v,x,y,g):null;case ir:return N=y._init,p(v,x,N(y._payload),g)}if(Qa(y)||Da(y))return N!==null?null:h(v,x,y,g,null);Rl(v,y)}return null}function m(v,x,y,g,N){if(typeof g=="string"&&g!==""||typeof g=="number")return v=v.get(y)||null,l(x,v,""+g,N);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case jl:return v=v.get(g.key===null?y:g.key)||null,c(x,v,g,N);case $i:return v=v.get(g.key===null?y:g.key)||null,u(x,v,g,N);case ir:var k=g._init;return m(v,x,y,k(g._payload),N)}if(Qa(g)||Da(g))return v=v.get(y)||null,h(x,v,g,N,null);Rl(x,g)}return null}function j(v,x,y,g){for(var N=null,k=null,S=x,C=x=0,R=null;S!==null&&C<y.length;C++){S.index>C?(R=S,S=null):R=S.sibling;var E=p(v,S,y[C],g);if(E===null){S===null&&(S=R);break}e&&S&&E.alternate===null&&t(v,S),x=a(E,x,C),k===null?N=E:k.sibling=E,k=E,S=R}if(C===y.length)return s(v,S),st&&Vr(v,C),N;if(S===null){for(;C<y.length;C++)S=f(v,y[C],g),S!==null&&(x=a(S,x,C),k===null?N=S:k.sibling=S,k=S);return st&&Vr(v,C),N}for(S=r(v,S);C<y.length;C++)R=m(S,v,C,y[C],g),R!==null&&(e&&R.alternate!==null&&S.delete(R.key===null?C:R.key),x=a(R,x,C),k===null?N=R:k.sibling=R,k=R);return e&&S.forEach(function(P){return t(v,P)}),st&&Vr(v,C),N}function w(v,x,y,g){var N=Da(y);if(typeof N!="function")throw Error(te(150));if(y=N.call(y),y==null)throw Error(te(151));for(var k=N=null,S=x,C=x=0,R=null,E=y.next();S!==null&&!E.done;C++,E=y.next()){S.index>C?(R=S,S=null):R=S.sibling;var P=p(v,S,E.value,g);if(P===null){S===null&&(S=R);break}e&&S&&P.alternate===null&&t(v,S),x=a(P,x,C),k===null?N=P:k.sibling=P,k=P,S=R}if(E.done)return s(v,S),st&&Vr(v,C),N;if(S===null){for(;!E.done;C++,E=y.next())E=f(v,E.value,g),E!==null&&(x=a(E,x,C),k===null?N=E:k.sibling=E,k=E);return st&&Vr(v,C),N}for(S=r(v,S);!E.done;C++,E=y.next())E=m(S,v,C,E.value,g),E!==null&&(e&&E.alternate!==null&&S.delete(E.key===null?C:E.key),x=a(E,x,C),k===null?N=E:k.sibling=E,k=E);return e&&S.forEach(function(O){return t(v,O)}),st&&Vr(v,C),N}function b(v,x,y,g){if(typeof y=="object"&&y!==null&&y.type===Oi&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case jl:e:{for(var N=y.key,k=x;k!==null;){if(k.key===N){if(N=y.type,N===Oi){if(k.tag===7){s(v,k.sibling),x=i(k,y.props.children),x.return=v,v=x;break e}}else if(k.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===ir&&uv(N)===k.type){s(v,k.sibling),x=i(k,y.props),x.ref=za(v,k,y),x.return=v,v=x;break e}s(v,k);break}else t(v,k);k=k.sibling}y.type===Oi?(x=Xr(y.props.children,v.mode,g,y.key),x.return=v,v=x):(g=xc(y.type,y.key,y.props,null,v.mode,g),g.ref=za(v,x,y),g.return=v,v=g)}return o(v);case $i:e:{for(k=y.key;x!==null;){if(x.key===k)if(x.tag===4&&x.stateNode.containerInfo===y.containerInfo&&x.stateNode.implementation===y.implementation){s(v,x.sibling),x=i(x,y.children||[]),x.return=v,v=x;break e}else{s(v,x);break}else t(v,x);x=x.sibling}x=Kd(y,v.mode,g),x.return=v,v=x}return o(v);case ir:return k=y._init,b(v,x,k(y._payload),g)}if(Qa(y))return j(v,x,y,g);if(Da(y))return w(v,x,y,g);Rl(v,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,x!==null&&x.tag===6?(s(v,x.sibling),x=i(x,y),x.return=v,v=x):(s(v,x),x=Vd(y,v.mode,g),x.return=v,v=x),o(v)):s(v,x)}return b}var oa=Qw(!0),Xw=Qw(!1),Vc=Pr(null),Kc=null,Wi=null,cm=null;function um(){cm=Wi=Kc=null}function dm(e){var t=Vc.current;et(Vc),e._currentValue=t}function ph(e,t,s){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===s)break;e=e.return}}function Ji(e,t){Kc=e,cm=Wi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(mn=!0),e.firstContext=null)}function Hn(e){var t=e._currentValue;if(cm!==e)if(e={context:e,memoizedValue:t,next:null},Wi===null){if(Kc===null)throw Error(te(308));Wi=e,Kc.dependencies={lanes:0,firstContext:e}}else Wi=Wi.next=e;return t}var Yr=null;function fm(e){Yr===null?Yr=[e]:Yr.push(e)}function Jw(e,t,s,r){var i=t.interleaved;return i===null?(s.next=s,fm(t)):(s.next=i.next,i.next=s),t.interleaved=s,Ks(e,r)}function Ks(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var ar=!1;function hm(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zw(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 Us(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function gr(e,t,s){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,We&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ks(e,s)}return i=r.interleaved,i===null?(t.next=t,fm(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ks(e,s)}function dc(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,Jp(e,s)}}function dv(e,t){var s=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,s===r)){var i=null,a=null;if(s=s.firstBaseUpdate,s!==null){do{var o={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};a===null?i=a=o:a=a.next=o,s=s.next}while(s!==null);a===null?i=a=t:a=a.next=t}else i=a=t;s={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function Gc(e,t,s,r){var i=e.updateQueue;ar=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,u=c.next;c.next=null,o===null?a=u:o.next=u,o=c;var h=e.alternate;h!==null&&(h=h.updateQueue,l=h.lastBaseUpdate,l!==o&&(l===null?h.firstBaseUpdate=u:l.next=u,h.lastBaseUpdate=c))}if(a!==null){var f=i.baseState;o=0,h=u=c=null,l=a;do{var p=l.lane,m=l.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var j=e,w=l;switch(p=t,m=s,w.tag){case 1:if(j=w.payload,typeof j=="function"){f=j.call(m,f,p);break e}f=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=w.payload,p=typeof j=="function"?j.call(m,f,p):j,p==null)break e;f=dt({},f,p);break e;case 2:ar=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=i.effects,p===null?i.effects=[l]:p.push(l))}else m={eventTime:m,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},h===null?(u=h=m,c=f):h=h.next=m,o|=p;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;p=l,l=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(!0);if(h===null&&(c=f),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=h,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);ri|=o,e.lanes=o,e.memoizedState=f}}function fv(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=s,typeof i!="function")throw Error(te(191,i));i.call(r)}}}var tl={},bs=Pr(tl),Eo=Pr(tl),Ao=Pr(tl);function qr(e){if(e===tl)throw Error(te(174));return e}function pm(e,t){switch(Xe(Ao,t),Xe(Eo,e),Xe(bs,tl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Yf(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Yf(t,e)}et(bs),Xe(bs,t)}function la(){et(bs),et(Eo),et(Ao)}function eb(e){qr(Ao.current);var t=qr(bs.current),s=Yf(t,e.type);t!==s&&(Xe(Eo,e),Xe(bs,s))}function mm(e){Eo.current===e&&(et(bs),et(Eo))}var at=Pr(0);function Yc(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Fd=[];function gm(){for(var e=0;e<Fd.length;e++)Fd[e]._workInProgressVersionPrimary=null;Fd.length=0}var fc=er.ReactCurrentDispatcher,Ud=er.ReactCurrentBatchConfig,si=0,ct=null,Nt=null,$t=null,qc=!1,io=!1,To=0,RA=0;function Gt(){throw Error(te(321))}function xm(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!ns(e[s],t[s]))return!1;return!0}function vm(e,t,s,r,i,a){if(si=a,ct=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,fc.current=e===null||e.memoizedState===null?$A:OA,e=s(r,i),io){a=0;do{if(io=!1,To=0,25<=a)throw Error(te(301));a+=1,$t=Nt=null,t.updateQueue=null,fc.current=_A,e=s(r,i)}while(io)}if(fc.current=Qc,t=Nt!==null&&Nt.next!==null,si=0,$t=Nt=ct=null,qc=!1,t)throw Error(te(300));return e}function jm(){var e=To!==0;return To=0,e}function ms(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $t===null?ct.memoizedState=$t=e:$t=$t.next=e,$t}function Vn(){if(Nt===null){var e=ct.alternate;e=e!==null?e.memoizedState:null}else e=Nt.next;var t=$t===null?ct.memoizedState:$t.next;if(t!==null)$t=t,Nt=e;else{if(e===null)throw Error(te(310));Nt=e,e={memoizedState:Nt.memoizedState,baseState:Nt.baseState,baseQueue:Nt.baseQueue,queue:Nt.queue,next:null},$t===null?ct.memoizedState=$t=e:$t=$t.next=e}return $t}function Ro(e,t){return typeof t=="function"?t(e):t}function Bd(e){var t=Vn(),s=t.queue;if(s===null)throw Error(te(311));s.lastRenderedReducer=e;var r=Nt,i=r.baseQueue,a=s.pending;if(a!==null){if(i!==null){var o=i.next;i.next=a.next,a.next=o}r.baseQueue=i=a,s.pending=null}if(i!==null){a=i.next,r=r.baseState;var l=o=null,c=null,u=a;do{var h=u.lane;if((si&h)===h)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:h,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,o=r):c=c.next=f,ct.lanes|=h,ri|=h}u=u.next}while(u!==null&&u!==a);c===null?o=r:c.next=l,ns(r,t.memoizedState)||(mn=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,s.lastRenderedState=r}if(e=s.interleaved,e!==null){i=e;do a=i.lane,ct.lanes|=a,ri|=a,i=i.next;while(i!==e)}else i===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function zd(e){var t=Vn(),s=t.queue;if(s===null)throw Error(te(311));s.lastRenderedReducer=e;var r=s.dispatch,i=s.pending,a=t.memoizedState;if(i!==null){s.pending=null;var o=i=i.next;do a=e(a,o.action),o=o.next;while(o!==i);ns(a,t.memoizedState)||(mn=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),s.lastRenderedState=a}return[a,r]}function tb(){}function nb(e,t){var s=ct,r=Vn(),i=t(),a=!ns(r.memoizedState,i);if(a&&(r.memoizedState=i,mn=!0),r=r.queue,ym(ib.bind(null,s,r,e),[e]),r.getSnapshot!==t||a||$t!==null&&$t.memoizedState.tag&1){if(s.flags|=2048,Io(9,rb.bind(null,s,r,i,t),void 0,null),Dt===null)throw Error(te(349));si&30||sb(s,t,i)}return i}function sb(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=ct.updateQueue,t===null?(t={lastEffect:null,stores:null},ct.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function rb(e,t,s,r){t.value=s,t.getSnapshot=r,ab(t)&&ob(e)}function ib(e,t,s){return s(function(){ab(t)&&ob(e)})}function ab(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!ns(e,s)}catch{return!0}}function ob(e){var t=Ks(e,1);t!==null&&es(t,e,1,-1)}function hv(e){var t=ms();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:e},t.queue=e,e=e.dispatch=MA.bind(null,ct,e),[t.memoizedState,e]}function Io(e,t,s,r){return e={tag:e,create:t,destroy:s,deps:r,next:null},t=ct.updateQueue,t===null?(t={lastEffect:null,stores:null},ct.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(r=s.next,s.next=e,e.next=r,t.lastEffect=e)),e}function lb(){return Vn().memoizedState}function hc(e,t,s,r){var i=ms();ct.flags|=e,i.memoizedState=Io(1|t,s,void 0,r===void 0?null:r)}function Tu(e,t,s,r){var i=Vn();r=r===void 0?null:r;var a=void 0;if(Nt!==null){var o=Nt.memoizedState;if(a=o.destroy,r!==null&&xm(r,o.deps)){i.memoizedState=Io(t,s,a,r);return}}ct.flags|=e,i.memoizedState=Io(1|t,s,a,r)}function pv(e,t){return hc(8390656,8,e,t)}function ym(e,t){return Tu(2048,8,e,t)}function cb(e,t){return Tu(4,2,e,t)}function ub(e,t){return Tu(4,4,e,t)}function db(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 fb(e,t,s){return s=s!=null?s.concat([e]):null,Tu(4,4,db.bind(null,t,e),s)}function wm(){}function hb(e,t){var s=Vn();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&xm(t,r[1])?r[0]:(s.memoizedState=[e,t],e)}function pb(e,t){var s=Vn();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&xm(t,r[1])?r[0]:(e=e(),s.memoizedState=[e,t],e)}function mb(e,t,s){return si&21?(ns(s,t)||(s=yw(),ct.lanes|=s,ri|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,mn=!0),e.memoizedState=s)}function IA(e,t){var s=qe;qe=s!==0&&4>s?s:4,e(!0);var r=Ud.transition;Ud.transition={};try{e(!1),t()}finally{qe=s,Ud.transition=r}}function gb(){return Vn().memoizedState}function PA(e,t,s){var r=vr(e);if(s={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null},xb(e))vb(t,s);else if(s=Jw(e,t,s,r),s!==null){var i=ln();es(s,e,r,i),jb(s,t,r)}}function MA(e,t,s){var r=vr(e),i={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null};if(xb(e))vb(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,l=a(o,s);if(i.hasEagerState=!0,i.eagerState=l,ns(l,o)){var c=t.interleaved;c===null?(i.next=i,fm(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}s=Jw(e,t,i,r),s!==null&&(i=ln(),es(s,e,r,i),jb(s,t,r))}}function xb(e){var t=e.alternate;return e===ct||t!==null&&t===ct}function vb(e,t){io=qc=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function jb(e,t,s){if(s&4194240){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,Jp(e,s)}}var Qc={readContext:Hn,useCallback:Gt,useContext:Gt,useEffect:Gt,useImperativeHandle:Gt,useInsertionEffect:Gt,useLayoutEffect:Gt,useMemo:Gt,useReducer:Gt,useRef:Gt,useState:Gt,useDebugValue:Gt,useDeferredValue:Gt,useTransition:Gt,useMutableSource:Gt,useSyncExternalStore:Gt,useId:Gt,unstable_isNewReconciler:!1},$A={readContext:Hn,useCallback:function(e,t){return ms().memoizedState=[e,t===void 0?null:t],e},useContext:Hn,useEffect:pv,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,hc(4194308,4,db.bind(null,t,e),s)},useLayoutEffect:function(e,t){return hc(4194308,4,e,t)},useInsertionEffect:function(e,t){return hc(4,2,e,t)},useMemo:function(e,t){var s=ms();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var r=ms();return t=s!==void 0?s(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=PA.bind(null,ct,e),[r.memoizedState,e]},useRef:function(e){var t=ms();return e={current:e},t.memoizedState=e},useState:hv,useDebugValue:wm,useDeferredValue:function(e){return ms().memoizedState=e},useTransition:function(){var e=hv(!1),t=e[0];return e=IA.bind(null,e[1]),ms().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var r=ct,i=ms();if(st){if(s===void 0)throw Error(te(407));s=s()}else{if(s=t(),Dt===null)throw Error(te(349));si&30||sb(r,t,s)}i.memoizedState=s;var a={value:s,getSnapshot:t};return i.queue=a,pv(ib.bind(null,r,a,e),[e]),r.flags|=2048,Io(9,rb.bind(null,r,a,s,t),void 0,null),s},useId:function(){var e=ms(),t=Dt.identifierPrefix;if(st){var s=Fs,r=Ls;s=(r&~(1<<32-Zn(r)-1)).toString(32)+s,t=":"+t+"R"+s,s=To++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=RA++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},OA={readContext:Hn,useCallback:hb,useContext:Hn,useEffect:ym,useImperativeHandle:fb,useInsertionEffect:cb,useLayoutEffect:ub,useMemo:pb,useReducer:Bd,useRef:lb,useState:function(){return Bd(Ro)},useDebugValue:wm,useDeferredValue:function(e){var t=Vn();return mb(t,Nt.memoizedState,e)},useTransition:function(){var e=Bd(Ro)[0],t=Vn().memoizedState;return[e,t]},useMutableSource:tb,useSyncExternalStore:nb,useId:gb,unstable_isNewReconciler:!1},_A={readContext:Hn,useCallback:hb,useContext:Hn,useEffect:ym,useImperativeHandle:fb,useInsertionEffect:cb,useLayoutEffect:ub,useMemo:pb,useReducer:zd,useRef:lb,useState:function(){return zd(Ro)},useDebugValue:wm,useDeferredValue:function(e){var t=Vn();return Nt===null?t.memoizedState=e:mb(t,Nt.memoizedState,e)},useTransition:function(){var e=zd(Ro)[0],t=Vn().memoizedState;return[e,t]},useMutableSource:tb,useSyncExternalStore:nb,useId:gb,unstable_isNewReconciler:!1};function qn(e,t){if(e&&e.defaultProps){t=dt({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function mh(e,t,s,r){t=e.memoizedState,s=s(r,t),s=s==null?t:dt({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Ru={isMounted:function(e){return(e=e._reactInternals)?hi(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var r=ln(),i=vr(e),a=Us(r,i);a.payload=t,s!=null&&(a.callback=s),t=gr(e,a,i),t!==null&&(es(t,e,i,r),dc(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var r=ln(),i=vr(e),a=Us(r,i);a.tag=1,a.payload=t,s!=null&&(a.callback=s),t=gr(e,a,i),t!==null&&(es(t,e,i,r),dc(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=ln(),r=vr(e),i=Us(s,r);i.tag=2,t!=null&&(i.callback=t),t=gr(e,i,r),t!==null&&(es(t,e,r,s),dc(t,e,r))}};function mv(e,t,s,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!ko(s,r)||!ko(i,a):!0}function yb(e,t,s){var r=!1,i=Sr,a=t.contextType;return typeof a=="object"&&a!==null?a=Hn(a):(i=vn(t)?ti:Jt.current,r=t.contextTypes,a=(r=r!=null)?ia(e,i):Sr),t=new t(s,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ru,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function gv(e,t,s,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,r),t.state!==e&&Ru.enqueueReplaceState(t,t.state,null)}function gh(e,t,s,r){var i=e.stateNode;i.props=s,i.state=e.memoizedState,i.refs={},hm(e);var a=t.contextType;typeof a=="object"&&a!==null?i.context=Hn(a):(a=vn(t)?ti:Jt.current,i.context=ia(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a=="function"&&(mh(e,t,a,s),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&Ru.enqueueReplaceState(i,i.state,null),Gc(e,s,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function ca(e,t){try{var s="",r=t;do s+=uE(r),r=r.return;while(r);var i=s}catch(a){i=`
39
+ Error generating stack: `+a.message+`
40
+ `+a.stack}return{value:e,source:t,stack:i,digest:null}}function Wd(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function xh(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var DA=typeof WeakMap=="function"?WeakMap:Map;function wb(e,t,s){s=Us(-1,s),s.tag=3,s.payload={element:null};var r=t.value;return s.callback=function(){Jc||(Jc=!0,Eh=r),xh(e,t)},s}function bb(e,t,s){s=Us(-1,s),s.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;s.payload=function(){return r(i)},s.callback=function(){xh(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(s.callback=function(){xh(e,t),typeof r!="function"&&(xr===null?xr=new Set([this]):xr.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),s}function xv(e,t,s){var r=e.pingCache;if(r===null){r=e.pingCache=new DA;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(s)||(i.add(s),e=XA.bind(null,e,t,s),t.then(e,e))}function vv(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 jv(e,t,s,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=Us(-1,1),t.tag=2,gr(s,t,1))),s.lanes|=1),e)}var LA=er.ReactCurrentOwner,mn=!1;function rn(e,t,s,r){t.child=e===null?Xw(t,null,s,r):oa(t,e.child,s,r)}function yv(e,t,s,r,i){s=s.render;var a=t.ref;return Ji(t,i),r=vm(e,t,s,r,a,i),s=jm(),e!==null&&!mn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Gs(e,t,i)):(st&&s&&am(t),t.flags|=1,rn(e,t,r,i),t.child)}function wv(e,t,s,r,i){if(e===null){var a=s.type;return typeof a=="function"&&!Tm(a)&&a.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=a,kb(e,t,a,r,i)):(e=xc(s.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!(e.lanes&i)){var o=a.memoizedProps;if(s=s.compare,s=s!==null?s:ko,s(o,r)&&e.ref===t.ref)return Gs(e,t,i)}return t.flags|=1,e=jr(a,r),e.ref=t.ref,e.return=t,t.child=e}function kb(e,t,s,r,i){if(e!==null){var a=e.memoizedProps;if(ko(a,r)&&e.ref===t.ref)if(mn=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(mn=!0);else return t.lanes=e.lanes,Gs(e,t,i)}return vh(e,t,s,r,i)}function Sb(e,t,s){var r=t.pendingProps,i=r.children,a=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Xe(Vi,En),En|=s;else{if(!(s&1073741824))return e=a!==null?a.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Xe(Vi,En),En|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a!==null?a.baseLanes:s,Xe(Vi,En),En|=r}else a!==null?(r=a.baseLanes|s,t.memoizedState=null):r=s,Xe(Vi,En),En|=r;return rn(e,t,i,s),t.child}function Nb(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function vh(e,t,s,r,i){var a=vn(s)?ti:Jt.current;return a=ia(t,a),Ji(t,i),s=vm(e,t,s,r,a,i),r=jm(),e!==null&&!mn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Gs(e,t,i)):(st&&r&&am(t),t.flags|=1,rn(e,t,s,i),t.child)}function bv(e,t,s,r,i){if(vn(s)){var a=!0;zc(t)}else a=!1;if(Ji(t,i),t.stateNode===null)pc(e,t),yb(t,s,r),gh(t,s,r,i),r=!0;else if(e===null){var o=t.stateNode,l=t.memoizedProps;o.props=l;var c=o.context,u=s.contextType;typeof u=="object"&&u!==null?u=Hn(u):(u=vn(s)?ti:Jt.current,u=ia(t,u));var h=s.getDerivedStateFromProps,f=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function";f||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||c!==u)&&gv(t,o,r,u),ar=!1;var p=t.memoizedState;o.state=p,Gc(t,r,o,i),c=t.memoizedState,l!==r||p!==c||xn.current||ar?(typeof h=="function"&&(mh(t,s,h,r),c=t.memoizedState),(l=ar||mv(t,s,l,r,p,c,u))?(f||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=u,r=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Zw(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:qn(t.type,l),o.props=u,f=t.pendingProps,p=o.context,c=s.contextType,typeof c=="object"&&c!==null?c=Hn(c):(c=vn(s)?ti:Jt.current,c=ia(t,c));var m=s.getDerivedStateFromProps;(h=typeof m=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==f||p!==c)&&gv(t,o,r,c),ar=!1,p=t.memoizedState,o.state=p,Gc(t,r,o,i);var j=t.memoizedState;l!==f||p!==j||xn.current||ar?(typeof m=="function"&&(mh(t,s,m,r),j=t.memoizedState),(u=ar||mv(t,s,u,r,p,j,c)||!1)?(h||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,j,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,j,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),o.props=r,o.state=j,o.context=c,r=u):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return jh(e,t,s,r,a,i)}function jh(e,t,s,r,i,a){Nb(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return i&&ov(t,s,!1),Gs(e,t,a);r=t.stateNode,LA.current=t;var l=o&&typeof s.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=oa(t,e.child,null,a),t.child=oa(t,null,l,a)):rn(e,t,l,a),t.memoizedState=r.state,i&&ov(t,s,!0),t.child}function Cb(e){var t=e.stateNode;t.pendingContext?av(e,t.pendingContext,t.pendingContext!==t.context):t.context&&av(e,t.context,!1),pm(e,t.containerInfo)}function kv(e,t,s,r,i){return aa(),lm(i),t.flags|=256,rn(e,t,s,r),t.child}var yh={dehydrated:null,treeContext:null,retryLane:0};function wh(e){return{baseLanes:e,cachePool:null,transitions:null}}function Eb(e,t,s){var r=t.pendingProps,i=at.current,a=!1,o=(t.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(i&2)!==0),l?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Xe(at,i&1),e===null)return hh(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,a?(r=t.mode,a=t.child,o={mode:"hidden",children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=Mu(o,r,0,null),e=Xr(e,r,s,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=wh(s),t.memoizedState=yh,e):bm(t,o));if(i=e.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return FA(e,t,o,r,l,i,s);if(a){a=r.fallback,o=t.mode,i=e.child,l=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=jr(i,c),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?a=jr(l,a):(a=Xr(a,o,s,null),a.flags|=2),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?wh(s):{baseLanes:o.baseLanes|s,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~s,t.memoizedState=yh,r}return a=e.child,e=a.sibling,r=jr(a,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=s),r.return=t,r.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=r,t.memoizedState=null,r}function bm(e,t){return t=Mu({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Il(e,t,s,r){return r!==null&&lm(r),oa(t,e.child,null,s),e=bm(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function FA(e,t,s,r,i,a,o){if(s)return t.flags&256?(t.flags&=-257,r=Wd(Error(te(422))),Il(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(a=r.fallback,i=t.mode,r=Mu({mode:"visible",children:r.children},i,0,null),a=Xr(a,i,o,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,t.mode&1&&oa(t,e.child,null,o),t.child.memoizedState=wh(o),t.memoizedState=yh,a);if(!(t.mode&1))return Il(e,t,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,a=Error(te(419)),r=Wd(a,r,void 0),Il(e,t,o,r)}if(l=(o&e.childLanes)!==0,mn||l){if(r=Dt,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!==a.retryLane&&(a.retryLane=i,Ks(e,i),es(r,e,i,-1))}return Am(),r=Wd(Error(te(421))),Il(e,t,o,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=JA.bind(null,e),i._reactRetry=t,null):(e=a.treeContext,Tn=mr(i.nextSibling),In=t,st=!0,Xn=null,e!==null&&(Ln[Fn++]=Ls,Ln[Fn++]=Fs,Ln[Fn++]=ni,Ls=e.id,Fs=e.overflow,ni=t),t=bm(t,r.children),t.flags|=4096,t)}function Sv(e,t,s){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ph(e.return,t,s)}function Hd(e,t,s,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:s,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=s,a.tailMode=i)}function Ab(e,t,s){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(rn(e,t,r.children,s),r=at.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&&Sv(e,s,t);else if(e.tag===19)Sv(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Xe(at,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(s=t.child,i=null;s!==null;)e=s.alternate,e!==null&&Yc(e)===null&&(i=s),s=s.sibling;s=i,s===null?(i=t.child,t.child=null):(i=s.sibling,s.sibling=null),Hd(t,!1,i,s,a);break;case"backwards":for(s=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Yc(e)===null){t.child=i;break}e=i.sibling,i.sibling=s,s=i,i=e}Hd(t,!0,s,null,a);break;case"together":Hd(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function pc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Gs(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),ri|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(te(153));if(t.child!==null){for(e=t.child,s=jr(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=jr(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function UA(e,t,s){switch(t.tag){case 3:Cb(t),aa();break;case 5:eb(t);break;case 1:vn(t.type)&&zc(t);break;case 4:pm(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Xe(Vc,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Xe(at,at.current&1),t.flags|=128,null):s&t.child.childLanes?Eb(e,t,s):(Xe(at,at.current&1),e=Gs(e,t,s),e!==null?e.sibling:null);Xe(at,at.current&1);break;case 19:if(r=(s&t.childLanes)!==0,e.flags&128){if(r)return Ab(e,t,s);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Xe(at,at.current),r)break;return null;case 22:case 23:return t.lanes=0,Sb(e,t,s)}return Gs(e,t,s)}var Tb,bh,Rb,Ib;Tb=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};bh=function(){};Rb=function(e,t,s,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,qr(bs.current);var a=null;switch(s){case"input":i=Hf(e,i),r=Hf(e,r),a=[];break;case"select":i=dt({},i,{value:void 0}),r=dt({},r,{value:void 0}),a=[];break;case"textarea":i=Gf(e,i),r=Gf(e,r),a=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Uc)}qf(s,r);var o;s=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(o in l)l.hasOwnProperty(o)&&(s||(s={}),s[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(go.hasOwnProperty(u)?a||(a=[]):(a=a||[]).push(u,null));for(u in r){var c=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(s||(s={}),s[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(s||(s={}),s[o]=c[o])}else s||(a||(a=[]),a.push(u,s)),s=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(a=a||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(a=a||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(go.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Je("scroll",e),a||l===c||(a=[])):(a=a||[]).push(u,c))}s&&(a=a||[]).push("style",s);var u=a;(t.updateQueue=u)&&(t.flags|=4)}};Ib=function(e,t,s,r){s!==r&&(t.flags|=4)};function Wa(e,t){if(!st)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var r=null;s!==null;)s.alternate!==null&&(r=s),s=s.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Yt(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,r=0;if(t)for(var i=e.child;i!==null;)s|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)s|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=s,t}function BA(e,t,s){var r=t.pendingProps;switch(om(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(t),null;case 1:return vn(t.type)&&Bc(),Yt(t),null;case 3:return r=t.stateNode,la(),et(xn),et(Jt),gm(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Tl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Xn!==null&&(Rh(Xn),Xn=null))),bh(e,t),Yt(t),null;case 5:mm(t);var i=qr(Ao.current);if(s=t.type,e!==null&&t.stateNode!=null)Rb(e,t,s,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(te(166));return Yt(t),null}if(e=qr(bs.current),Tl(t)){r=t.stateNode,s=t.type;var a=t.memoizedProps;switch(r[xs]=t,r[Co]=a,e=(t.mode&1)!==0,s){case"dialog":Je("cancel",r),Je("close",r);break;case"iframe":case"object":case"embed":Je("load",r);break;case"video":case"audio":for(i=0;i<Ja.length;i++)Je(Ja[i],r);break;case"source":Je("error",r);break;case"img":case"image":case"link":Je("error",r),Je("load",r);break;case"details":Je("toggle",r);break;case"input":Mx(r,a),Je("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},Je("invalid",r);break;case"textarea":Ox(r,a),Je("invalid",r)}qf(s,a),i=null;for(var o in a)if(a.hasOwnProperty(o)){var l=a[o];o==="children"?typeof l=="string"?r.textContent!==l&&(a.suppressHydrationWarning!==!0&&Al(r.textContent,l,e),i=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(a.suppressHydrationWarning!==!0&&Al(r.textContent,l,e),i=["children",""+l]):go.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&Je("scroll",r)}switch(s){case"input":yl(r),$x(r,a,!0);break;case"textarea":yl(r),_x(r);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(r.onclick=Uc)}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=iw(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(s,{is:r.is}):(e=o.createElement(s),s==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,s),e[xs]=t,e[Co]=r,Tb(e,t,!1,!1),t.stateNode=e;e:{switch(o=Qf(s,r),s){case"dialog":Je("cancel",e),Je("close",e),i=r;break;case"iframe":case"object":case"embed":Je("load",e),i=r;break;case"video":case"audio":for(i=0;i<Ja.length;i++)Je(Ja[i],e);i=r;break;case"source":Je("error",e),i=r;break;case"img":case"image":case"link":Je("error",e),Je("load",e),i=r;break;case"details":Je("toggle",e),i=r;break;case"input":Mx(e,r),i=Hf(e,r),Je("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=dt({},r,{value:void 0}),Je("invalid",e);break;case"textarea":Ox(e,r),i=Gf(e,r),Je("invalid",e);break;default:i=r}qf(s,i),l=i;for(a in l)if(l.hasOwnProperty(a)){var c=l[a];a==="style"?lw(e,c):a==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&aw(e,c)):a==="children"?typeof c=="string"?(s!=="textarea"||c!=="")&&xo(e,c):typeof c=="number"&&xo(e,""+c):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(go.hasOwnProperty(a)?c!=null&&a==="onScroll"&&Je("scroll",e):c!=null&&Kp(e,a,c,o))}switch(s){case"input":yl(e),$x(e,r,!1);break;case"textarea":yl(e),_x(e);break;case"option":r.value!=null&&e.setAttribute("value",""+kr(r.value));break;case"select":e.multiple=!!r.multiple,a=r.value,a!=null?Yi(e,!!r.multiple,a,!1):r.defaultValue!=null&&Yi(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=Uc)}switch(s){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Yt(t),null;case 6:if(e&&t.stateNode!=null)Ib(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(te(166));if(s=qr(Ao.current),qr(bs.current),Tl(t)){if(r=t.stateNode,s=t.memoizedProps,r[xs]=t,(a=r.nodeValue!==s)&&(e=In,e!==null))switch(e.tag){case 3:Al(r.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Al(r.nodeValue,s,(e.mode&1)!==0)}a&&(t.flags|=4)}else r=(s.nodeType===9?s:s.ownerDocument).createTextNode(r),r[xs]=t,t.stateNode=r}return Yt(t),null;case 13:if(et(at),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(st&&Tn!==null&&t.mode&1&&!(t.flags&128))qw(),aa(),t.flags|=98560,a=!1;else if(a=Tl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(te(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(te(317));a[xs]=t}else aa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Yt(t),a=!1}else Xn!==null&&(Rh(Xn),Xn=null),a=!0;if(!a)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||at.current&1?At===0&&(At=3):Am())),t.updateQueue!==null&&(t.flags|=4),Yt(t),null);case 4:return la(),bh(e,t),e===null&&So(t.stateNode.containerInfo),Yt(t),null;case 10:return dm(t.type._context),Yt(t),null;case 17:return vn(t.type)&&Bc(),Yt(t),null;case 19:if(et(at),a=t.memoizedState,a===null)return Yt(t),null;if(r=(t.flags&128)!==0,o=a.rendering,o===null)if(r)Wa(a,!1);else{if(At!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Yc(e),o!==null){for(t.flags|=128,Wa(a,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=s,s=t.child;s!==null;)a=s,e=r,a.flags&=14680066,o=a.alternate,o===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=o.childLanes,a.lanes=o.lanes,a.child=o.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=o.memoizedProps,a.memoizedState=o.memoizedState,a.updateQueue=o.updateQueue,a.type=o.type,e=o.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return Xe(at,at.current&1|2),t.child}e=e.sibling}a.tail!==null&&xt()>ua&&(t.flags|=128,r=!0,Wa(a,!1),t.lanes=4194304)}else{if(!r)if(e=Yc(o),e!==null){if(t.flags|=128,r=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),Wa(a,!0),a.tail===null&&a.tailMode==="hidden"&&!o.alternate&&!st)return Yt(t),null}else 2*xt()-a.renderingStartTime>ua&&s!==1073741824&&(t.flags|=128,r=!0,Wa(a,!1),t.lanes=4194304);a.isBackwards?(o.sibling=t.child,t.child=o):(s=a.last,s!==null?s.sibling=o:t.child=o,a.last=o)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=xt(),t.sibling=null,s=at.current,Xe(at,r?s&1|2:s&1),t):(Yt(t),null);case 22:case 23:return Em(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?En&1073741824&&(Yt(t),t.subtreeFlags&6&&(t.flags|=8192)):Yt(t),null;case 24:return null;case 25:return null}throw Error(te(156,t.tag))}function zA(e,t){switch(om(t),t.tag){case 1:return vn(t.type)&&Bc(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return la(),et(xn),et(Jt),gm(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return mm(t),null;case 13:if(et(at),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(te(340));aa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return et(at),null;case 4:return la(),null;case 10:return dm(t.type._context),null;case 22:case 23:return Em(),null;case 24:return null;default:return null}}var Pl=!1,Qt=!1,WA=typeof WeakSet=="function"?WeakSet:Set,pe=null;function Hi(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(r){pt(e,t,r)}else s.current=null}function kh(e,t,s){try{s()}catch(r){pt(e,t,r)}}var Nv=!1;function HA(e,t){if(ah=Dc,e=_w(),im(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var r=s.getSelection&&s.getSelection();if(r&&r.rangeCount!==0){s=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{s.nodeType,a.nodeType}catch{s=null;break e}var o=0,l=-1,c=-1,u=0,h=0,f=e,p=null;t:for(;;){for(var m;f!==s||i!==0&&f.nodeType!==3||(l=o+i),f!==a||r!==0&&f.nodeType!==3||(c=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break t;if(p===s&&++u===i&&(l=o),p===a&&++h===r&&(c=o),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}s=l===-1||c===-1?null:{start:l,end:c}}else s=null}s=s||{start:0,end:0}}else s=null;for(oh={focusedElem:e,selectionRange:s},Dc=!1,pe=t;pe!==null;)if(t=pe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,pe=e;else for(;pe!==null;){t=pe;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var w=j.memoizedProps,b=j.memoizedState,v=t.stateNode,x=v.getSnapshotBeforeUpdate(t.elementType===t.type?w:qn(t.type,w),b);v.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(te(163))}}catch(g){pt(t,t.return,g)}if(e=t.sibling,e!==null){e.return=t.return,pe=e;break}pe=t.return}return j=Nv,Nv=!1,j}function ao(e,t,s){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&kh(t,s,a)}i=i.next}while(i!==r)}}function Iu(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var r=s.create;s.destroy=r()}s=s.next}while(s!==t)}}function Sh(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function Pb(e){var t=e.alternate;t!==null&&(e.alternate=null,Pb(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[xs],delete t[Co],delete t[uh],delete t[CA],delete t[EA])),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 Mb(e){return e.tag===5||e.tag===3||e.tag===4}function Cv(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Mb(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 Nh(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Uc));else if(r!==4&&(e=e.child,e!==null))for(Nh(e,t,s),e=e.sibling;e!==null;)Nh(e,t,s),e=e.sibling}function Ch(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ch(e,t,s),e=e.sibling;e!==null;)Ch(e,t,s),e=e.sibling}var Ut=null,Qn=!1;function sr(e,t,s){for(s=s.child;s!==null;)$b(e,t,s),s=s.sibling}function $b(e,t,s){if(ws&&typeof ws.onCommitFiberUnmount=="function")try{ws.onCommitFiberUnmount(ku,s)}catch{}switch(s.tag){case 5:Qt||Hi(s,t);case 6:var r=Ut,i=Qn;Ut=null,sr(e,t,s),Ut=r,Qn=i,Ut!==null&&(Qn?(e=Ut,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):Ut.removeChild(s.stateNode));break;case 18:Ut!==null&&(Qn?(e=Ut,s=s.stateNode,e.nodeType===8?Dd(e.parentNode,s):e.nodeType===1&&Dd(e,s),wo(e)):Dd(Ut,s.stateNode));break;case 4:r=Ut,i=Qn,Ut=s.stateNode.containerInfo,Qn=!0,sr(e,t,s),Ut=r,Qn=i;break;case 0:case 11:case 14:case 15:if(!Qt&&(r=s.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&kh(s,t,o),i=i.next}while(i!==r)}sr(e,t,s);break;case 1:if(!Qt&&(Hi(s,t),r=s.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=s.memoizedProps,r.state=s.memoizedState,r.componentWillUnmount()}catch(l){pt(s,t,l)}sr(e,t,s);break;case 21:sr(e,t,s);break;case 22:s.mode&1?(Qt=(r=Qt)||s.memoizedState!==null,sr(e,t,s),Qt=r):sr(e,t,s);break;default:sr(e,t,s)}}function Ev(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new WA),t.forEach(function(r){var i=ZA.bind(null,e,r);s.has(r)||(s.add(r),r.then(i,i))})}}function Gn(e,t){var s=t.deletions;if(s!==null)for(var r=0;r<s.length;r++){var i=s[r];try{var a=e,o=t,l=o;e:for(;l!==null;){switch(l.tag){case 5:Ut=l.stateNode,Qn=!1;break e;case 3:Ut=l.stateNode.containerInfo,Qn=!0;break e;case 4:Ut=l.stateNode.containerInfo,Qn=!0;break e}l=l.return}if(Ut===null)throw Error(te(160));$b(a,o,i),Ut=null,Qn=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){pt(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Ob(t,e),t=t.sibling}function Ob(e,t){var s=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Gn(t,e),hs(e),r&4){try{ao(3,e,e.return),Iu(3,e)}catch(w){pt(e,e.return,w)}try{ao(5,e,e.return)}catch(w){pt(e,e.return,w)}}break;case 1:Gn(t,e),hs(e),r&512&&s!==null&&Hi(s,s.return);break;case 5:if(Gn(t,e),hs(e),r&512&&s!==null&&Hi(s,s.return),e.flags&32){var i=e.stateNode;try{xo(i,"")}catch(w){pt(e,e.return,w)}}if(r&4&&(i=e.stateNode,i!=null)){var a=e.memoizedProps,o=s!==null?s.memoizedProps:a,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&a.type==="radio"&&a.name!=null&&sw(i,a),Qf(l,o);var u=Qf(l,a);for(o=0;o<c.length;o+=2){var h=c[o],f=c[o+1];h==="style"?lw(i,f):h==="dangerouslySetInnerHTML"?aw(i,f):h==="children"?xo(i,f):Kp(i,h,f,u)}switch(l){case"input":Vf(i,a);break;case"textarea":rw(i,a);break;case"select":var p=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!a.multiple;var m=a.value;m!=null?Yi(i,!!a.multiple,m,!1):p!==!!a.multiple&&(a.defaultValue!=null?Yi(i,!!a.multiple,a.defaultValue,!0):Yi(i,!!a.multiple,a.multiple?[]:"",!1))}i[Co]=a}catch(w){pt(e,e.return,w)}}break;case 6:if(Gn(t,e),hs(e),r&4){if(e.stateNode===null)throw Error(te(162));i=e.stateNode,a=e.memoizedProps;try{i.nodeValue=a}catch(w){pt(e,e.return,w)}}break;case 3:if(Gn(t,e),hs(e),r&4&&s!==null&&s.memoizedState.isDehydrated)try{wo(t.containerInfo)}catch(w){pt(e,e.return,w)}break;case 4:Gn(t,e),hs(e);break;case 13:Gn(t,e),hs(e),i=e.child,i.flags&8192&&(a=i.memoizedState!==null,i.stateNode.isHidden=a,!a||i.alternate!==null&&i.alternate.memoizedState!==null||(Nm=xt())),r&4&&Ev(e);break;case 22:if(h=s!==null&&s.memoizedState!==null,e.mode&1?(Qt=(u=Qt)||h,Gn(t,e),Qt=u):Gn(t,e),hs(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!h&&e.mode&1)for(pe=e,h=e.child;h!==null;){for(f=pe=h;pe!==null;){switch(p=pe,m=p.child,p.tag){case 0:case 11:case 14:case 15:ao(4,p,p.return);break;case 1:Hi(p,p.return);var j=p.stateNode;if(typeof j.componentWillUnmount=="function"){r=p,s=p.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(w){pt(r,s,w)}}break;case 5:Hi(p,p.return);break;case 22:if(p.memoizedState!==null){Tv(f);continue}}m!==null?(m.return=p,pe=m):Tv(f)}h=h.sibling}e:for(h=null,f=e;;){if(f.tag===5){if(h===null){h=f;try{i=f.stateNode,u?(a=i.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(l=f.stateNode,c=f.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=ow("display",o))}catch(w){pt(e,e.return,w)}}}else if(f.tag===6){if(h===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(w){pt(e,e.return,w)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;h===f&&(h=null),f=f.return}h===f&&(h=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Gn(t,e),hs(e),r&4&&Ev(e);break;case 21:break;default:Gn(t,e),hs(e)}}function hs(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(Mb(s)){var r=s;break e}s=s.return}throw Error(te(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(xo(i,""),r.flags&=-33);var a=Cv(e);Ch(e,a,i);break;case 3:case 4:var o=r.stateNode.containerInfo,l=Cv(e);Nh(e,l,o);break;default:throw Error(te(161))}}catch(c){pt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function VA(e,t,s){pe=e,_b(e)}function _b(e,t,s){for(var r=(e.mode&1)!==0;pe!==null;){var i=pe,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||Pl;if(!o){var l=i.alternate,c=l!==null&&l.memoizedState!==null||Qt;l=Pl;var u=Qt;if(Pl=o,(Qt=c)&&!u)for(pe=i;pe!==null;)o=pe,c=o.child,o.tag===22&&o.memoizedState!==null?Rv(i):c!==null?(c.return=o,pe=c):Rv(i);for(;a!==null;)pe=a,_b(a),a=a.sibling;pe=i,Pl=l,Qt=u}Av(e)}else i.subtreeFlags&8772&&a!==null?(a.return=i,pe=a):Av(e)}}function Av(e){for(;pe!==null;){var t=pe;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Qt||Iu(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Qt)if(s===null)r.componentDidMount();else{var i=t.elementType===t.type?s.memoizedProps:qn(t.type,s.memoizedProps);r.componentDidUpdate(i,s.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;a!==null&&fv(t,a,r);break;case 3:var o=t.updateQueue;if(o!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}fv(t,o,s)}break;case 5:var l=t.stateNode;if(s===null&&t.flags&4){s=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&s.focus();break;case"img":c.src&&(s.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var h=u.memoizedState;if(h!==null){var f=h.dehydrated;f!==null&&wo(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(te(163))}Qt||t.flags&512&&Sh(t)}catch(p){pt(t,t.return,p)}}if(t===e){pe=null;break}if(s=t.sibling,s!==null){s.return=t.return,pe=s;break}pe=t.return}}function Tv(e){for(;pe!==null;){var t=pe;if(t===e){pe=null;break}var s=t.sibling;if(s!==null){s.return=t.return,pe=s;break}pe=t.return}}function Rv(e){for(;pe!==null;){var t=pe;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{Iu(4,t)}catch(c){pt(t,s,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){pt(t,i,c)}}var a=t.return;try{Sh(t)}catch(c){pt(t,a,c)}break;case 5:var o=t.return;try{Sh(t)}catch(c){pt(t,o,c)}}}catch(c){pt(t,t.return,c)}if(t===e){pe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,pe=l;break}pe=t.return}}var KA=Math.ceil,Xc=er.ReactCurrentDispatcher,km=er.ReactCurrentOwner,zn=er.ReactCurrentBatchConfig,We=0,Dt=null,wt=null,Bt=0,En=0,Vi=Pr(0),At=0,Po=null,ri=0,Pu=0,Sm=0,oo=null,hn=null,Nm=0,ua=1/0,$s=null,Jc=!1,Eh=null,xr=null,Ml=!1,ur=null,Zc=0,lo=0,Ah=null,mc=-1,gc=0;function ln(){return We&6?xt():mc!==-1?mc:mc=xt()}function vr(e){return e.mode&1?We&2&&Bt!==0?Bt&-Bt:TA.transition!==null?(gc===0&&(gc=yw()),gc):(e=qe,e!==0||(e=window.event,e=e===void 0?16:Ew(e.type)),e):1}function es(e,t,s,r){if(50<lo)throw lo=0,Ah=null,Error(te(185));Jo(e,s,r),(!(We&2)||e!==Dt)&&(e===Dt&&(!(We&2)&&(Pu|=s),At===4&&lr(e,Bt)),jn(e,r),s===1&&We===0&&!(t.mode&1)&&(ua=xt()+500,Au&&Mr()))}function jn(e,t){var s=e.callbackNode;TE(e,t);var r=_c(e,e===Dt?Bt:0);if(r===0)s!==null&&Fx(s),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(s!=null&&Fx(s),t===1)e.tag===0?AA(Iv.bind(null,e)):Kw(Iv.bind(null,e)),SA(function(){!(We&6)&&Mr()}),s=null;else{switch(ww(r)){case 1:s=Xp;break;case 4:s=vw;break;case 16:s=Oc;break;case 536870912:s=jw;break;default:s=Oc}s=Hb(s,Db.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function Db(e,t){if(mc=-1,gc=0,We&6)throw Error(te(327));var s=e.callbackNode;if(Zi()&&e.callbackNode!==s)return null;var r=_c(e,e===Dt?Bt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=eu(e,r);else{t=r;var i=We;We|=2;var a=Fb();(Dt!==e||Bt!==t)&&($s=null,ua=xt()+500,Qr(e,t));do try{qA();break}catch(l){Lb(e,l)}while(!0);um(),Xc.current=a,We=i,wt!==null?t=0:(Dt=null,Bt=0,t=At)}if(t!==0){if(t===2&&(i=th(e),i!==0&&(r=i,t=Th(e,i))),t===1)throw s=Po,Qr(e,0),lr(e,r),jn(e,xt()),s;if(t===6)lr(e,r);else{if(i=e.current.alternate,!(r&30)&&!GA(i)&&(t=eu(e,r),t===2&&(a=th(e),a!==0&&(r=a,t=Th(e,a))),t===1))throw s=Po,Qr(e,0),lr(e,r),jn(e,xt()),s;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(te(345));case 2:Kr(e,hn,$s);break;case 3:if(lr(e,r),(r&130023424)===r&&(t=Nm+500-xt(),10<t)){if(_c(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){ln(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=ch(Kr.bind(null,e,hn,$s),t);break}Kr(e,hn,$s);break;case 4:if(lr(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var o=31-Zn(r);a=1<<o,o=t[o],o>i&&(i=o),r&=~a}if(r=i,r=xt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*KA(r/1960))-r,10<r){e.timeoutHandle=ch(Kr.bind(null,e,hn,$s),r);break}Kr(e,hn,$s);break;case 5:Kr(e,hn,$s);break;default:throw Error(te(329))}}}return jn(e,xt()),e.callbackNode===s?Db.bind(null,e):null}function Th(e,t){var s=oo;return e.current.memoizedState.isDehydrated&&(Qr(e,t).flags|=256),e=eu(e,t),e!==2&&(t=hn,hn=s,t!==null&&Rh(t)),e}function Rh(e){hn===null?hn=e:hn.push.apply(hn,e)}function GA(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var r=0;r<s.length;r++){var i=s[r],a=i.getSnapshot;i=i.value;try{if(!ns(a(),i))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function lr(e,t){for(t&=~Sm,t&=~Pu,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-Zn(t),r=1<<s;e[s]=-1,t&=~r}}function Iv(e){if(We&6)throw Error(te(327));Zi();var t=_c(e,0);if(!(t&1))return jn(e,xt()),null;var s=eu(e,t);if(e.tag!==0&&s===2){var r=th(e);r!==0&&(t=r,s=Th(e,r))}if(s===1)throw s=Po,Qr(e,0),lr(e,t),jn(e,xt()),s;if(s===6)throw Error(te(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Kr(e,hn,$s),jn(e,xt()),null}function Cm(e,t){var s=We;We|=1;try{return e(t)}finally{We=s,We===0&&(ua=xt()+500,Au&&Mr())}}function ii(e){ur!==null&&ur.tag===0&&!(We&6)&&Zi();var t=We;We|=1;var s=zn.transition,r=qe;try{if(zn.transition=null,qe=1,e)return e()}finally{qe=r,zn.transition=s,We=t,!(We&6)&&Mr()}}function Em(){En=Vi.current,et(Vi)}function Qr(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,kA(s)),wt!==null)for(s=wt.return;s!==null;){var r=s;switch(om(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Bc();break;case 3:la(),et(xn),et(Jt),gm();break;case 5:mm(r);break;case 4:la();break;case 13:et(at);break;case 19:et(at);break;case 10:dm(r.type._context);break;case 22:case 23:Em()}s=s.return}if(Dt=e,wt=e=jr(e.current,null),Bt=En=t,At=0,Po=null,Sm=Pu=ri=0,hn=oo=null,Yr!==null){for(t=0;t<Yr.length;t++)if(s=Yr[t],r=s.interleaved,r!==null){s.interleaved=null;var i=r.next,a=s.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}s.pending=r}Yr=null}return e}function Lb(e,t){do{var s=wt;try{if(um(),fc.current=Qc,qc){for(var r=ct.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}qc=!1}if(si=0,$t=Nt=ct=null,io=!1,To=0,km.current=null,s===null||s.return===null){At=1,Po=t,wt=null;break}e:{var a=e,o=s.return,l=s,c=t;if(t=Bt,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,h=l,f=h.tag;if(!(h.mode&1)&&(f===0||f===11||f===15)){var p=h.alternate;p?(h.updateQueue=p.updateQueue,h.memoizedState=p.memoizedState,h.lanes=p.lanes):(h.updateQueue=null,h.memoizedState=null)}var m=vv(o);if(m!==null){m.flags&=-257,jv(m,o,l,a,t),m.mode&1&&xv(a,u,t),t=m,c=u;var j=t.updateQueue;if(j===null){var w=new Set;w.add(c),t.updateQueue=w}else j.add(c);break e}else{if(!(t&1)){xv(a,u,t),Am();break e}c=Error(te(426))}}else if(st&&l.mode&1){var b=vv(o);if(b!==null){!(b.flags&65536)&&(b.flags|=256),jv(b,o,l,a,t),lm(ca(c,l));break e}}a=c=ca(c,l),At!==4&&(At=2),oo===null?oo=[a]:oo.push(a),a=o;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t;var v=wb(a,c,t);dv(a,v);break e;case 1:l=c;var x=a.type,y=a.stateNode;if(!(a.flags&128)&&(typeof x.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(xr===null||!xr.has(y)))){a.flags|=65536,t&=-t,a.lanes|=t;var g=bb(a,l,t);dv(a,g);break e}}a=a.return}while(a!==null)}Bb(s)}catch(N){t=N,wt===s&&s!==null&&(wt=s=s.return);continue}break}while(!0)}function Fb(){var e=Xc.current;return Xc.current=Qc,e===null?Qc:e}function Am(){(At===0||At===3||At===2)&&(At=4),Dt===null||!(ri&268435455)&&!(Pu&268435455)||lr(Dt,Bt)}function eu(e,t){var s=We;We|=2;var r=Fb();(Dt!==e||Bt!==t)&&($s=null,Qr(e,t));do try{YA();break}catch(i){Lb(e,i)}while(!0);if(um(),We=s,Xc.current=r,wt!==null)throw Error(te(261));return Dt=null,Bt=0,At}function YA(){for(;wt!==null;)Ub(wt)}function qA(){for(;wt!==null&&!yE();)Ub(wt)}function Ub(e){var t=Wb(e.alternate,e,En);e.memoizedProps=e.pendingProps,t===null?Bb(e):wt=t,km.current=null}function Bb(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=zA(s,t),s!==null){s.flags&=32767,wt=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{At=6,wt=null;return}}else if(s=BA(s,t,En),s!==null){wt=s;return}if(t=t.sibling,t!==null){wt=t;return}wt=t=e}while(t!==null);At===0&&(At=5)}function Kr(e,t,s){var r=qe,i=zn.transition;try{zn.transition=null,qe=1,QA(e,t,s,r)}finally{zn.transition=i,qe=r}return null}function QA(e,t,s,r){do Zi();while(ur!==null);if(We&6)throw Error(te(327));s=e.finishedWork;var i=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(te(177));e.callbackNode=null,e.callbackPriority=0;var a=s.lanes|s.childLanes;if(RE(e,a),e===Dt&&(wt=Dt=null,Bt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||Ml||(Ml=!0,Hb(Oc,function(){return Zi(),null})),a=(s.flags&15990)!==0,s.subtreeFlags&15990||a){a=zn.transition,zn.transition=null;var o=qe;qe=1;var l=We;We|=4,km.current=null,HA(e,s),Ob(s,e),gA(oh),Dc=!!ah,oh=ah=null,e.current=s,VA(s),wE(),We=l,qe=o,zn.transition=a}else e.current=s;if(Ml&&(Ml=!1,ur=e,Zc=i),a=e.pendingLanes,a===0&&(xr=null),SE(s.stateNode),jn(e,xt()),t!==null)for(r=e.onRecoverableError,s=0;s<t.length;s++)i=t[s],r(i.value,{componentStack:i.stack,digest:i.digest});if(Jc)throw Jc=!1,e=Eh,Eh=null,e;return Zc&1&&e.tag!==0&&Zi(),a=e.pendingLanes,a&1?e===Ah?lo++:(lo=0,Ah=e):lo=0,Mr(),null}function Zi(){if(ur!==null){var e=ww(Zc),t=zn.transition,s=qe;try{if(zn.transition=null,qe=16>e?16:e,ur===null)var r=!1;else{if(e=ur,ur=null,Zc=0,We&6)throw Error(te(331));var i=We;for(We|=4,pe=e.current;pe!==null;){var a=pe,o=a.child;if(pe.flags&16){var l=a.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(pe=u;pe!==null;){var h=pe;switch(h.tag){case 0:case 11:case 15:ao(8,h,a)}var f=h.child;if(f!==null)f.return=h,pe=f;else for(;pe!==null;){h=pe;var p=h.sibling,m=h.return;if(Pb(h),h===u){pe=null;break}if(p!==null){p.return=m,pe=p;break}pe=m}}}var j=a.alternate;if(j!==null){var w=j.child;if(w!==null){j.child=null;do{var b=w.sibling;w.sibling=null,w=b}while(w!==null)}}pe=a}}if(a.subtreeFlags&2064&&o!==null)o.return=a,pe=o;else e:for(;pe!==null;){if(a=pe,a.flags&2048)switch(a.tag){case 0:case 11:case 15:ao(9,a,a.return)}var v=a.sibling;if(v!==null){v.return=a.return,pe=v;break e}pe=a.return}}var x=e.current;for(pe=x;pe!==null;){o=pe;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,pe=y;else e:for(o=x;pe!==null;){if(l=pe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Iu(9,l)}}catch(N){pt(l,l.return,N)}if(l===o){pe=null;break e}var g=l.sibling;if(g!==null){g.return=l.return,pe=g;break e}pe=l.return}}if(We=i,Mr(),ws&&typeof ws.onPostCommitFiberRoot=="function")try{ws.onPostCommitFiberRoot(ku,e)}catch{}r=!0}return r}finally{qe=s,zn.transition=t}}return!1}function Pv(e,t,s){t=ca(s,t),t=wb(e,t,1),e=gr(e,t,1),t=ln(),e!==null&&(Jo(e,1,t),jn(e,t))}function pt(e,t,s){if(e.tag===3)Pv(e,e,s);else for(;t!==null;){if(t.tag===3){Pv(t,e,s);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(xr===null||!xr.has(r))){e=ca(s,e),e=bb(t,e,1),t=gr(t,e,1),e=ln(),t!==null&&(Jo(t,1,e),jn(t,e));break}}t=t.return}}function XA(e,t,s){var r=e.pingCache;r!==null&&r.delete(t),t=ln(),e.pingedLanes|=e.suspendedLanes&s,Dt===e&&(Bt&s)===s&&(At===4||At===3&&(Bt&130023424)===Bt&&500>xt()-Nm?Qr(e,0):Sm|=s),jn(e,t)}function zb(e,t){t===0&&(e.mode&1?(t=kl,kl<<=1,!(kl&130023424)&&(kl=4194304)):t=1);var s=ln();e=Ks(e,t),e!==null&&(Jo(e,t,s),jn(e,s))}function JA(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),zb(e,s)}function ZA(e,t){var s=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(s=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(te(314))}r!==null&&r.delete(t),zb(e,s)}var Wb;Wb=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||xn.current)mn=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return mn=!1,UA(e,t,s);mn=!!(e.flags&131072)}else mn=!1,st&&t.flags&1048576&&Gw(t,Hc,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;pc(e,t),e=t.pendingProps;var i=ia(t,Jt.current);Ji(t,s),i=vm(null,t,r,e,i,s);var a=jm();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,vn(r)?(a=!0,zc(t)):a=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,hm(t),i.updater=Ru,t.stateNode=i,i._reactInternals=t,gh(t,r,e,s),t=jh(null,t,r,!0,a,s)):(t.tag=0,st&&a&&am(t),rn(null,t,i,s),t=t.child),t;case 16:r=t.elementType;e:{switch(pc(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=tT(r),e=qn(r,e),i){case 0:t=vh(null,t,r,e,s);break e;case 1:t=bv(null,t,r,e,s);break e;case 11:t=yv(null,t,r,e,s);break e;case 14:t=wv(null,t,r,qn(r.type,e),s);break e}throw Error(te(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:qn(r,i),vh(e,t,r,i,s);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:qn(r,i),bv(e,t,r,i,s);case 3:e:{if(Cb(t),e===null)throw Error(te(387));r=t.pendingProps,a=t.memoizedState,i=a.element,Zw(e,t),Gc(t,r,null,s);var o=t.memoizedState;if(r=o.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){i=ca(Error(te(423)),t),t=kv(e,t,r,s,i);break e}else if(r!==i){i=ca(Error(te(424)),t),t=kv(e,t,r,s,i);break e}else for(Tn=mr(t.stateNode.containerInfo.firstChild),In=t,st=!0,Xn=null,s=Xw(t,null,r,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(aa(),r===i){t=Gs(e,t,s);break e}rn(e,t,r,s)}t=t.child}return t;case 5:return eb(t),e===null&&hh(t),r=t.type,i=t.pendingProps,a=e!==null?e.memoizedProps:null,o=i.children,lh(r,i)?o=null:a!==null&&lh(r,a)&&(t.flags|=32),Nb(e,t),rn(e,t,o,s),t.child;case 6:return e===null&&hh(t),null;case 13:return Eb(e,t,s);case 4:return pm(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=oa(t,null,r,s):rn(e,t,r,s),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:qn(r,i),yv(e,t,r,i,s);case 7:return rn(e,t,t.pendingProps,s),t.child;case 8:return rn(e,t,t.pendingProps.children,s),t.child;case 12:return rn(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,a=t.memoizedProps,o=i.value,Xe(Vc,r._currentValue),r._currentValue=o,a!==null)if(ns(a.value,o)){if(a.children===i.children&&!xn.current){t=Gs(e,t,s);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var l=a.dependencies;if(l!==null){o=a.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=Us(-1,s&-s),c.tag=2;var u=a.updateQueue;if(u!==null){u=u.shared;var h=u.pending;h===null?c.next=c:(c.next=h.next,h.next=c),u.pending=c}}a.lanes|=s,c=a.alternate,c!==null&&(c.lanes|=s),ph(a.return,s,t),l.lanes|=s;break}c=c.next}}else if(a.tag===10)o=a.type===t.type?null:a.child;else if(a.tag===18){if(o=a.return,o===null)throw Error(te(341));o.lanes|=s,l=o.alternate,l!==null&&(l.lanes|=s),ph(o,s,t),o=a.sibling}else o=a.child;if(o!==null)o.return=a;else for(o=a;o!==null;){if(o===t){o=null;break}if(a=o.sibling,a!==null){a.return=o.return,o=a;break}o=o.return}a=o}rn(e,t,i.children,s),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Ji(t,s),i=Hn(i),r=r(i),t.flags|=1,rn(e,t,r,s),t.child;case 14:return r=t.type,i=qn(r,t.pendingProps),i=qn(r.type,i),wv(e,t,r,i,s);case 15:return kb(e,t,t.type,t.pendingProps,s);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:qn(r,i),pc(e,t),t.tag=1,vn(r)?(e=!0,zc(t)):e=!1,Ji(t,s),yb(t,r,i),gh(t,r,i,s),jh(null,t,r,!0,e,s);case 19:return Ab(e,t,s);case 22:return Sb(e,t,s)}throw Error(te(156,t.tag))};function Hb(e,t){return xw(e,t)}function eT(e,t,s,r){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bn(e,t,s,r){return new eT(e,t,s,r)}function Tm(e){return e=e.prototype,!(!e||!e.isReactComponent)}function tT(e){if(typeof e=="function")return Tm(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Yp)return 11;if(e===qp)return 14}return 2}function jr(e,t){var s=e.alternate;return s===null?(s=Bn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function xc(e,t,s,r,i,a){var o=2;if(r=e,typeof e=="function")Tm(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Oi:return Xr(s.children,i,a,t);case Gp:o=8,i|=8;break;case Uf:return e=Bn(12,s,t,i|2),e.elementType=Uf,e.lanes=a,e;case Bf:return e=Bn(13,s,t,i),e.elementType=Bf,e.lanes=a,e;case zf:return e=Bn(19,s,t,i),e.elementType=zf,e.lanes=a,e;case ew:return Mu(s,i,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Jy:o=10;break e;case Zy:o=9;break e;case Yp:o=11;break e;case qp:o=14;break e;case ir:o=16,r=null;break e}throw Error(te(130,e==null?e:typeof e,""))}return t=Bn(o,s,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function Xr(e,t,s,r){return e=Bn(7,e,r,t),e.lanes=s,e}function Mu(e,t,s,r){return e=Bn(22,e,r,t),e.elementType=ew,e.lanes=s,e.stateNode={isHidden:!1},e}function Vd(e,t,s){return e=Bn(6,e,null,t),e.lanes=s,e}function Kd(e,t,s){return t=Bn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function nT(e,t,s,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Cd(0),this.expirationTimes=Cd(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Cd(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Rm(e,t,s,r,i,a,o,l,c){return e=new nT(e,t,s,l,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=Bn(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},hm(a),e}function sT(e,t,s){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$i,key:r==null?null:""+r,children:e,containerInfo:t,implementation:s}}function Vb(e){if(!e)return Sr;e=e._reactInternals;e:{if(hi(e)!==e||e.tag!==1)throw Error(te(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(vn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(te(171))}if(e.tag===1){var s=e.type;if(vn(s))return Vw(e,s,t)}return t}function Kb(e,t,s,r,i,a,o,l,c){return e=Rm(s,r,!0,e,i,a,o,l,c),e.context=Vb(null),s=e.current,r=ln(),i=vr(s),a=Us(r,i),a.callback=t??null,gr(s,a,i),e.current.lanes=i,Jo(e,i,r),jn(e,r),e}function $u(e,t,s,r){var i=t.current,a=ln(),o=vr(i);return s=Vb(s),t.context===null?t.context=s:t.pendingContext=s,t=Us(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=gr(i,t,o),e!==null&&(es(e,i,o,a),dc(e,i,o)),o}function tu(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 Mv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Im(e,t){Mv(e,t),(e=e.alternate)&&Mv(e,t)}function rT(){return null}var Gb=typeof reportError=="function"?reportError:function(e){console.error(e)};function Pm(e){this._internalRoot=e}Ou.prototype.render=Pm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(te(409));$u(e,t,null,null)};Ou.prototype.unmount=Pm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ii(function(){$u(null,e,null,null)}),t[Vs]=null}};function Ou(e){this._internalRoot=e}Ou.prototype.unstable_scheduleHydration=function(e){if(e){var t=Sw();e={blockedOn:null,target:e,priority:t};for(var s=0;s<or.length&&t!==0&&t<or[s].priority;s++);or.splice(s,0,e),s===0&&Cw(e)}};function Mm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function _u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function $v(){}function iT(e,t,s,r,i){if(i){if(typeof r=="function"){var a=r;r=function(){var u=tu(o);a.call(u)}}var o=Kb(t,r,e,0,null,!1,!1,"",$v);return e._reactRootContainer=o,e[Vs]=o.current,So(e.nodeType===8?e.parentNode:e),ii(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var l=r;r=function(){var u=tu(c);l.call(u)}}var c=Rm(e,0,!1,null,null,!1,!1,"",$v);return e._reactRootContainer=c,e[Vs]=c.current,So(e.nodeType===8?e.parentNode:e),ii(function(){$u(t,c,s,r)}),c}function Du(e,t,s,r,i){var a=s._reactRootContainer;if(a){var o=a;if(typeof i=="function"){var l=i;i=function(){var c=tu(o);l.call(c)}}$u(t,o,e,i)}else o=iT(s,t,e,i,r);return tu(o)}bw=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=Xa(t.pendingLanes);s!==0&&(Jp(t,s|1),jn(t,xt()),!(We&6)&&(ua=xt()+500,Mr()))}break;case 13:ii(function(){var r=Ks(e,1);if(r!==null){var i=ln();es(r,e,1,i)}}),Im(e,1)}};Zp=function(e){if(e.tag===13){var t=Ks(e,134217728);if(t!==null){var s=ln();es(t,e,134217728,s)}Im(e,134217728)}};kw=function(e){if(e.tag===13){var t=vr(e),s=Ks(e,t);if(s!==null){var r=ln();es(s,e,t,r)}Im(e,t)}};Sw=function(){return qe};Nw=function(e,t){var s=qe;try{return qe=e,t()}finally{qe=s}};Jf=function(e,t,s){switch(t){case"input":if(Vf(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var r=s[t];if(r!==e&&r.form===e.form){var i=Eu(r);if(!i)throw Error(te(90));nw(r),Vf(r,i)}}}break;case"textarea":rw(e,s);break;case"select":t=s.value,t!=null&&Yi(e,!!s.multiple,t,!1)}};dw=Cm;fw=ii;var aT={usingClientEntryPoint:!1,Events:[el,Fi,Eu,cw,uw,Cm]},Ha={findFiberByHostInstance:Gr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},oT={bundleType:Ha.bundleType,version:Ha.version,rendererPackageName:Ha.rendererPackageName,rendererConfig:Ha.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:er.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=mw(e),e===null?null:e.stateNode},findFiberByHostInstance:Ha.findFiberByHostInstance||rT,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 $l=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$l.isDisabled&&$l.supportsFiber)try{ku=$l.inject(oT),ws=$l}catch{}}Mn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=aT;Mn.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Mm(t))throw Error(te(200));return sT(e,t,null,s)};Mn.createRoot=function(e,t){if(!Mm(e))throw Error(te(299));var s=!1,r="",i=Gb;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Rm(e,1,!1,null,null,s,!1,r,i),e[Vs]=t.current,So(e.nodeType===8?e.parentNode:e),new Pm(t)};Mn.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(te(188)):(e=Object.keys(e).join(","),Error(te(268,e)));return e=mw(t),e=e===null?null:e.stateNode,e};Mn.flushSync=function(e){return ii(e)};Mn.hydrate=function(e,t,s){if(!_u(t))throw Error(te(200));return Du(null,e,t,!0,s)};Mn.hydrateRoot=function(e,t,s){if(!Mm(e))throw Error(te(405));var r=s!=null&&s.hydratedSources||null,i=!1,a="",o=Gb;if(s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(o=s.onRecoverableError)),t=Kb(t,null,e,1,s??null,i,!1,a,o),e[Vs]=t.current,So(e),r)for(e=0;e<r.length;e++)s=r[e],i=s._getVersion,i=i(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,i]:t.mutableSourceEagerHydrationData.push(s,i);return new Ou(t)};Mn.render=function(e,t,s){if(!_u(t))throw Error(te(200));return Du(null,e,t,!1,s)};Mn.unmountComponentAtNode=function(e){if(!_u(e))throw Error(te(40));return e._reactRootContainer?(ii(function(){Du(null,null,e,!1,function(){e._reactRootContainer=null,e[Vs]=null})}),!0):!1};Mn.unstable_batchedUpdates=Cm;Mn.unstable_renderSubtreeIntoContainer=function(e,t,s,r){if(!_u(s))throw Error(te(200));if(e==null||e._reactInternals===void 0)throw Error(te(38));return Du(e,t,s,!1,r)};Mn.version="18.3.1-next-f1338f8080-20240426";function Yb(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Yb)}catch(e){console.error(e)}}Yb(),Yy.exports=Mn;var da=Yy.exports,qb,Ov=da;qb=Ov.createRoot,Ov.hydrateRoot;var lT=Object.defineProperty,ka=(e,t)=>lT(e,"name",{value:t,configurable:!0}),Qb=!!(typeof window<"u"&&window.document&&window.document.createElement);function Pe(e,t,{checkForDefaultPrevented:s=!0}={}){return ka(function(i){if(e==null||e(i),s===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}ka(Pe,"composeEventHandlers");function cT(e){var t;if(!Qb)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}ka(cT,"getOwnerWindow");function Ih(e){if(!Qb)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}ka(Ih,"getOwnerDocument");function Xb(e,t=!1){const{activeElement:s}=Ih(e);if(!(s!=null&&s.nodeName))return null;if(Jb(s)&&s.contentDocument)return Xb(s.contentDocument.body,t);if(t){const r=s.getAttribute("aria-activedescendant");if(r){const i=Ih(s).getElementById(r);if(i)return i}}return s}ka(Xb,"getActiveElement");function Jb(e){return e.tagName==="IFRAME"}ka(Jb,"isFrame");var uT=Object.defineProperty,$m=(e,t)=>uT(e,"name",{value:t,configurable:!0});function Ph(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}$m(Ph,"setRef");function Zb(...e){return t=>{let s=!1;const r=e.map(i=>{const a=Ph(i,t);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():Ph(e[i],null)}}}}$m(Zb,"composeRefs");function ut(...e){return d.useCallback(Zb(...e),e)}$m(ut,"useComposedRefs");var dT=Object.defineProperty,Un=(e,t)=>dT(e,"name",{value:t,configurable:!0});function fT(e,t){const s=d.createContext(t);s.displayName=e+"Context";const r=Un(a=>{const{children:o,...l}=a,c=d.useMemo(()=>l,Object.values(l));return n.jsx(s.Provider,{value:c,children:o})},"Provider");r.displayName=e+"Provider";function i(a,o={}){const{optional:l=!1}=o,c=d.useContext(s);if(c)return c;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Un(i,"useContext"),[r,i]}Un(fT,"createContext");function is(e,t=[]){let s=[];function r(a,o){const l=d.createContext(o);l.displayName=a+"Context";const c=s.length;s=[...s,o];const u=Un(f=>{var v;const{scope:p,children:m,...j}=f,w=((v=p==null?void 0:p[e])==null?void 0:v[c])||l,b=d.useMemo(()=>j,Object.values(j));return n.jsx(w.Provider,{value:b,children:m})},"Provider");u.displayName=a+"Provider";function h(f,p,m={}){var v;const{optional:j=!1}=m,w=((v=p==null?void 0:p[e])==null?void 0:v[c])||l,b=d.useContext(w);if(b)return b;if(o!==void 0)return o;if(!j)throw new Error(`\`${f}\` must be used within \`${a}\``)}return Un(h,"useContext"),[u,h]}Un(r,"createContext");const i=Un(()=>{const a=s.map(o=>d.createContext(o));return Un(function(l){const c=(l==null?void 0:l[e])||a;return d.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])},"useScope")},"createScope");return i.scopeName=e,[r,e0(i,...t)]}Un(is,"createContextScope");function e0(...e){const t=e[0];if(e.length===1)return t;const s=Un(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Un(function(a){const o=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(a)[`__scope${u}`];return{...l,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return s.scopeName=t.scopeName,s}Un(e0,"composeContextScopes");var hT=Object.defineProperty,as=(e,t)=>hT(e,"name",{value:t,configurable:!0});function Nr(e){const t=d.forwardRef((s,r)=>{let{children:i,...a}=s,o=null,l=!1;const c=[];Mh(i)&&typeof Ol=="function"&&(i=Ol(i._payload)),d.Children.forEach(i,p=>{var m;if(i0(p)){l=!0;const j=p;let w="child"in j.props?j.props.child:j.props.children;Mh(w)&&typeof Ol=="function"&&(w=Ol(w._payload)),o=pT(j,w),c.push((m=o==null?void 0:o.props)==null?void 0:m.children)}else c.push(p)}),o?o=d.cloneElement(o,void 0,c):!l&&d.Children.count(i)===1&&d.isValidElement(i)&&(o=i);const u=o?r0(o):void 0,h=ut(r,u);if(!o){if(i||i===0)throw new Error(l?xT(e):gT(e));return i}const f=s0(a,o.props??{});return o.type!==d.Fragment&&(f.ref=r?h:u),d.cloneElement(o,f)});return t.displayName=`${e}.Slot`,t}as(Nr,"createSlot");var t0=Symbol.for("radix.slottable");function n0(e){const t=as(s=>"child"in s?s.children(s.child):s.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=t0,t}as(n0,"createSlottable");var pT=as((e,t)=>{if("child"in e.props){const s=e.props.child;return d.isValidElement(s)?d.cloneElement(s,void 0,e.props.children(s.props.children)):null}return d.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function s0(e,t){const s={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?s[r]=(...l)=>{const c=a(...l);return i(...l),c}:i&&(s[r]=i):r==="style"?s[r]={...i,...a}:r==="className"&&(s[r]=[i,a].filter(Boolean).join(" "))}return{...e,...s}}as(s0,"mergeProps");function r0(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}as(r0,"getElementRef");function i0(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===t0}as(i0,"isSlottable");var mT=Symbol.for("react.lazy");function Mh(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===mT&&"_payload"in e&&a0(e._payload)}as(Mh,"isLazyComponent");function a0(e){return typeof e=="object"&&e!==null&&"then"in e}as(a0,"isPromiseLike");var gT=as(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),xT=as(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ol=ya[" use ".trim().toString()],vT=Object.defineProperty,Ot=(e,t)=>vT(e,"name",{value:t,configurable:!0});function Lu(e){const t=e+"CollectionProvider",[s,r]=is(t),[i,a]=s(t,{collectionRef:{current:null},itemMap:new Map}),o=Ot(w=>{const{scope:b,children:v}=w,x=d.useRef(null),y=d.useRef(new Map).current;return n.jsx(i,{scope:b,itemMap:y,collectionRef:x,children:v})},"CollectionProvider");o.displayName=t;const l=e+"CollectionSlot",c=Nr(l),u=d.forwardRef((w,b)=>{const{scope:v,children:x}=w,y=a(l,v),g=ut(b,y.collectionRef);return n.jsx(c,{ref:g,children:x})});u.displayName=l;const h=e+"CollectionItemSlot",f="data-radix-collection-item",p=Nr(h),m=d.forwardRef((w,b)=>{const{scope:v,children:x,...y}=w,g=d.useRef(null),N=ut(b,g),k=a(h,v);return d.useEffect(()=>(k.itemMap.set(g,{ref:g,...y}),()=>void k.itemMap.delete(g))),n.jsx(p,{[f]:"",ref:N,children:x})});m.displayName=h;function j(w){const b=a(e+"CollectionConsumer",w);return d.useCallback(()=>{const x=b.collectionRef.current;if(!x)return[];const y=Array.from(x.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((k,S)=>y.indexOf(k.ref.current)-y.indexOf(S.ref.current))},[b.collectionRef,b.itemMap])}return Ot(j,"useCollection"),[{Provider:o,Slot:u,ItemSlot:m},j,r]}Ot(Lu,"createCollection");var _v=new WeakMap,yt,An,Gd=(An=class extends Map{constructor(s){super(s);Cx(this,yt);yd(this,yt,[...super.keys()]),_v.set(this,!0)}set(s,r){return _v.get(this)&&(this.has(s)?Kt(this,yt)[Kt(this,yt).indexOf(s)]=s:Kt(this,yt).push(s)),super.set(s,r),this}insert(s,r,i){const a=this.has(r),o=Kt(this,yt).length,l=Om(s);let c=l>=0?l:o+l;const u=c<0||c>=o?-1:c;if(u===this.size||a&&u===this.size-1||u===-1)return this.set(r,i),this;const h=this.size+(a?0:1);l<0&&c++;const f=[...Kt(this,yt)];let p,m=!1;for(let j=c;j<h;j++)if(c===j){let w=f[j];f[j]===r&&(w=f[j+1]),a&&this.delete(r),p=this.get(w),this.set(r,i)}else{!m&&f[j-1]===r&&(m=!0);const w=f[m?j:j-1],b=p;p=this.get(w),this.delete(w),this.set(w,b)}return this}with(s,r,i){const a=new An(this);return a.insert(s,r,i),a}before(s){const r=Kt(this,yt).indexOf(s)-1;if(!(r<0))return this.entryAt(r)}setBefore(s,r,i){const a=Kt(this,yt).indexOf(s);return a===-1?this:this.insert(a,r,i)}after(s){let r=Kt(this,yt).indexOf(s);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(s,r,i){const a=Kt(this,yt).indexOf(s);return a===-1?this:this.insert(a+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return yd(this,yt,[]),super.clear()}delete(s){const r=super.delete(s);return r&&Kt(this,yt).splice(Kt(this,yt).indexOf(s),1),r}deleteAt(s){const r=this.keyAt(s);return r!==void 0?this.delete(r):!1}at(s){const r=vc(Kt(this,yt),s);if(r!==void 0)return this.get(r)}entryAt(s){const r=vc(Kt(this,yt),s);if(r!==void 0)return[r,this.get(r)]}indexOf(s){return Kt(this,yt).indexOf(s)}keyAt(s){return vc(Kt(this,yt),s)}from(s,r){const i=this.indexOf(s);if(i===-1)return;let a=i+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.at(a)}keyFrom(s,r){const i=this.indexOf(s);if(i===-1)return;let a=i+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.keyAt(a)}find(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return a;i++}}findIndex(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return i;i++}return-1}filter(s,r){const i=[];let a=0;for(const o of this)Reflect.apply(s,r,[o,a,this])&&i.push(o),a++;return new An(i)}map(s,r){const i=[];let a=0;for(const o of this)i.push([o[0],Reflect.apply(s,r,[o,a,this])]),a++;return new An(i)}reduce(...s){const[r,i]=s;let a=0,o=i??this.at(0);for(const l of this)a===0&&s.length===1?o=l:o=Reflect.apply(r,this,[o,l,a,this]),a++;return o}reduceRight(...s){const[r,i]=s;let a=i??this.at(-1);for(let o=this.size-1;o>=0;o--){const l=this.at(o);o===this.size-1&&s.length===1?a=l:a=Reflect.apply(r,this,[a,l,o,this])}return a}toSorted(s){const r=[...this.entries()].sort(s);return new An(r)}toReversed(){const s=new An;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),a=this.get(i);s.set(i,a)}return s}toSpliced(...s){const r=[...this.entries()];return r.splice(...s),new An(r)}slice(s,r){const i=new An;let a=this.size-1;if(s===void 0)return i;s<0&&(s=s+this.size),r!==void 0&&r>0&&(a=r-1);for(let o=s;o<=a;o++){const l=this.keyAt(o),c=this.get(l);i.set(l,c)}return i}every(s,r){let i=0;for(const a of this){if(!Reflect.apply(s,r,[a,i,this]))return!1;i++}return!0}some(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return!0;i++}return!1}},yt=new WeakMap,Ot(An,"OrderedDict"),An);function vc(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const s=o0(e,t);return s===-1?void 0:e[s]}Ot(vc,"at");function o0(e,t){const s=e.length,r=Om(t),i=r>=0?r:s+r;return i<0||i>=s?-1:i}Ot(o0,"toSafeIndex");function Om(e){return e!==e||e===0?0:Math.trunc(e)}Ot(Om,"toSafeInteger");function jT(e){const t=e+"CollectionProvider",[s,r]=is(t),[i,a]=s(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Gd,setItemMap:Ot(()=>{},"setItemMap")}),o=Ot(({state:y,...g})=>y?n.jsx(c,{...g,state:y}):n.jsx(l,{...g}),"CollectionProvider");o.displayName=t;const l=Ot(y=>{const g=b();return n.jsx(c,{...y,state:g})},"CollectionInit");l.displayName=t+"Init";const c=Ot(y=>{const{scope:g,children:N,state:k}=y,S=d.useRef(null),[C,R]=d.useState(null),E=ut(S,R),[P,O]=k;return d.useEffect(()=>{if(!C)return;const U=u0(()=>{});return U.observe(C,{childList:!0,subtree:!0}),()=>{U.disconnect()}},[C]),n.jsx(i,{scope:g,itemMap:P,setItemMap:O,collectionRef:E,collectionRefObject:S,collectionElement:C,children:N})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",h=Nr(u),f=d.forwardRef((y,g)=>{const{scope:N,children:k}=y,S=a(u,N),C=ut(g,S.collectionRef);return n.jsx(h,{ref:C,children:k})});f.displayName=u;const p=e+"CollectionItemSlot",m="data-radix-collection-item",j=Nr(p),w=d.forwardRef((y,g)=>{const{scope:N,children:k,...S}=y,C=d.useRef(null),[R,E]=d.useState(null),P=ut(g,C,E),O=a(p,N),{setItemMap:U}=O,T=d.useRef(S);l0(T.current,S)||(T.current=S);const M=T.current;return d.useEffect(()=>{const L=M;return U(K=>R?K.has(R)?K.set(R,{...L,element:R}).toSorted($h):(K.set(R,{...L,element:R}),K.toSorted($h)):K),()=>{U(K=>!R||!K.has(R)?K:(K.delete(R),new Gd(K)))}},[R,M,U]),n.jsx(j,{[m]:"",ref:P,children:k})});w.displayName=p;function b(){return d.useState(new Gd)}Ot(b,"useInitCollection");function v(y){const{itemMap:g}=a(e+"CollectionConsumer",y);return g}return Ot(v,"useCollection"),[{Provider:o,Slot:f,ItemSlot:w},{createCollectionScope:r,useCollection:v,useInitCollection:b}]}Ot(jT,"createCollection");function l0(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}Ot(l0,"shallowEqual");function c0(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ot(c0,"isElementPreceding");function $h(e,t){return!e[1].element||!t[1].element?0:c0(e[1].element,t[1].element)?-1:1}Ot($h,"sortByDocumentPosition");function u0(e){return new MutationObserver(s=>{for(const r of s)if(r.type==="childList"){e();return}})}Ot(u0,"getChildListObserver");var yT=Object.defineProperty,wT=(e,t)=>yT(e,"name",{value:t,configurable:!0}),bT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ft=bT.reduce((e,t)=>{const s=Nr(`Primitive.${t}`),r=d.forwardRef((i,a)=>{const{asChild:o,...l}=i,c=o?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fu(e,t){e&&da.flushSync(()=>e.dispatchEvent(t))}wT(Fu,"dispatchDiscreteCustomEvent");var kT=Object.defineProperty,ST=(e,t)=>kT(e,"name",{value:t,configurable:!0});function ss(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...s)=>{var r;return(r=t.current)==null?void 0:r.call(t,...s)},[])}ST(ss,"useCallbackRef");var NT=Object.defineProperty,Ct=(e,t)=>NT(e,"name",{value:t,configurable:!0}),Oh="dismissableLayer.update",CT="dismissableLayer.pointerDownOutside",ET="dismissableLayer.focusOutside",Dv,_m=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Dm=d.forwardRef(Ct(function(t,s){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:c,onDismiss:u,...h}=t,f=d.useContext(_m),[p,m]=d.useState(null),j=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=d.useState({}),b=ut(s,m),v=Array.from(f.layers),[x]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=x?v.indexOf(x):-1,g=p?v.indexOf(p):-1,N=f.layersWithOutsidePointerEventsDisabled.size>0,k=g>=y,S=d.useRef(!1),C=f0(O=>{o==null||o(O),c==null||c(O),O.defaultPrevented||u==null||u()},{ownerDocument:j,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(O=>{if(!(O instanceof Node))return!1;const U=[...f.branches].some(T=>T.contains(O));return k&&!U},[f.branches,k])}),R=h0(O=>{if(i&&S.current)return;const U=O.target;[...f.branches].some(M=>M.contains(U))||(l==null||l(O),c==null||c(O),O.defaultPrevented||u==null||u())},j),E=p?g===v.length-1:!1,P=ss(O=>{O.key==="Escape"&&(a==null||a(O),!O.defaultPrevented&&u&&(O.preventDefault(),u()))});return d.useEffect(()=>{if(E)return j.addEventListener("keydown",P,{capture:!0}),()=>j.removeEventListener("keydown",P,{capture:!0})},[j,E,P]),d.useEffect(()=>{if(p)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Dv=j.body.style.pointerEvents,j.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),_h(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(j.body.style.pointerEvents=Dv))}},[p,j,r,f]),d.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),_h())},[p,f]),d.useEffect(()=>{const O=Ct(()=>w({}),"handleUpdate");return document.addEventListener(Oh,O),()=>document.removeEventListener(Oh,O)},[]),n.jsx(ft.div,{...h,ref:b,style:{pointerEvents:N?k?"auto":"none":void 0,...t.style},onFocusCapture:Pe(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Pe(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Pe(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),AT=d.forwardRef(Ct(function(t,s){const r=d.useContext(_m),i=d.useRef(null),a=ut(s,i);return d.useEffect(()=>{const o=i.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),n.jsx(ft.div,{...t,ref:a})},"DismissableLayerBranch"));function d0(){const e=d.useContext(_m),[t,s]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}Ct(d0,"useDismissableLayerSurface");var TT=Ct(()=>!0,"IS_TRUE");function f0(e,t){const{ownerDocument:s=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=TT}=t,l=ss(e),c=d.useRef(!1),u=d.useRef(!1),h=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function p(){u.current=!1,i.current=!1,h.current.clear()}Ct(p,"resetOutsideInteraction");function m(){return Array.from(h.current.values()).some(Boolean)}Ct(m,"isOutsideInteractionIntercepted");function j(y){if(!u.current)return;const g=y.target;g instanceof Node&&[...a].some(k=>k.contains(g))||h.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}Ct(j,"handleInteractionCapture");function w(y){u.current&&h.current.set(y.type,!1)}Ct(w,"handleInteractionBubble");const b=Ct(y=>{if(y.target&&!c.current){let g=function(){s.removeEventListener("click",f.current);const k=m();p(),k||Lm(CT,l,N,{discrete:!0})};if(Ct(g,"handleAndDispatchPointerDownOutsideEvent"),!o(y.target)){s.removeEventListener("click",f.current),p(),c.current=!1;return}const N={originalEvent:y};u.current=!0,i.current=r&&y.button===0,h.current.clear(),!r||y.button!==0?g():(s.removeEventListener("click",f.current),f.current=g,s.addEventListener("click",f.current,{once:!0}))}else s.removeEventListener("click",f.current),p();c.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of v)s.addEventListener(y,j,!0),s.addEventListener(y,w);const x=window.setTimeout(()=>{s.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(x),s.removeEventListener("pointerdown",b),s.removeEventListener("click",f.current);for(const y of v)s.removeEventListener(y,j,!0),s.removeEventListener(y,w)}},[s,l,r,i,a,o]),{onPointerDownCapture:Ct(()=>c.current=!0,"onPointerDownCapture")}}Ct(f0,"usePointerDownOutside");function h0(e,t=globalThis==null?void 0:globalThis.document){const s=ss(e),r=d.useRef(!1);return d.useEffect(()=>{const i=Ct(a=>{a.target&&!r.current&&Lm(ET,s,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,s]),{onFocusCapture:Ct(()=>r.current=!0,"onFocusCapture"),onBlurCapture:Ct(()=>r.current=!1,"onBlurCapture")}}Ct(h0,"useFocusOutside");function _h(){const e=new CustomEvent(Oh);document.dispatchEvent(e)}Ct(_h,"dispatchUpdate");function Lm(e,t,s,{discrete:r}){const i=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&i.addEventListener(e,t,{once:!0}),r?Fu(i,a):i.dispatchEvent(a)}Ct(Lm,"handleAndDispatchCustomEvent");var RT=AT,yn=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},IT=Object.defineProperty,PT=(e,t)=>IT(e,"name",{value:t,configurable:!0}),Fm=d.forwardRef(PT(function(t,s){var c;const{container:r,...i}=t,[a,o]=d.useState(!1);yn(()=>o(!0),[]);const l=r||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?da.createPortal(n.jsx(ft.div,{...i,ref:s}),l):null},"Portal")),MT=Object.defineProperty,Ys=(e,t)=>MT(e,"name",{value:t,configurable:!0});function p0(e,t){return d.useReducer((s,r)=>t[s][r]??s,e)}Ys(p0,"useStateMachine");var $r=Ys(e=>{const{present:t,children:s}=e,r=m0(t),i=typeof s=="function"?s({present:r.isPresent}):d.Children.only(s),a=g0(r.ref,x0(i));return typeof s=="function"||r.isPresent?d.cloneElement(i,{ref:a}):null},"Presence");function m0(e){const[t,s]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef("none"),o=d.useRef(void 0),l=e?"mounted":"unmounted",[c,u]=p0(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{c==="mounted"?(a.current=o.current??Mi(r.current),o.current=void 0):a.current="none"},[c]),yn(()=>{const h=r.current,f=i.current;if(f!==e){const m=a.current,j=Mi(h);e?(o.current=j,u("MOUNT")):j==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&m!==j?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),yn(()=>{if(t){let h;const f=t.ownerDocument.defaultView??window,p=Ys(j=>{const b=Mi(r.current).includes(CSS.escape(j.animationName));if(j.target===t&&b&&(u("ANIMATION_END"),!i.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",h=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},"handleAnimationEnd"),m=Ys(j=>{j.target===t&&(a.current=Mi(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(h),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:d.useCallback(h=>{if(h){const f=getComputedStyle(h);r.current=f,o.current=Mi(f)}else r.current=null;s(h)},[])}}Ys(m0,"usePresence");function Dh(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Ys(Dh,"setRef");function g0(...e){const t=d.useRef(e);return t.current=e,d.useCallback(s=>{const r=t.current;let i=!1;const a=r.map(o=>{const l=Dh(o,s);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let o=0;o<a.length;o++){const l=a[o];typeof l=="function"?l():Dh(r[o],null)}}},[])}Ys(g0,"useStableComposedRefs");function Mi(e){return(e==null?void 0:e.animationName)||"none"}Ys(Mi,"getAnimationName");function x0(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}Ys(x0,"getElementRef");var $T=Object.defineProperty,OT=(e,t)=>$T(e,"name",{value:t,configurable:!0}),Lv=ya[" useEffectEvent ".trim().toString()],Fv=ya[" useInsertionEffect ".trim().toString()];function v0(e){if(typeof Lv=="function")return Lv(e);const t=d.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Fv=="function"?Fv(()=>{t.current=e}):yn(()=>{t.current=e}),d.useMemo(()=>(...s)=>{var r;return(r=t.current)==null?void 0:r.call(t,...s)},[])}OT(v0,"useEffectEvent");var _T=Object.defineProperty,nl=(e,t)=>_T(e,"name",{value:t,configurable:!0}),DT=ya[" useInsertionEffect ".trim().toString()]||yn;function Sa({prop:e,defaultProp:t,onChange:s=nl(()=>{},"onChange"),caller:r}){const[i,a,o]=j0({defaultProp:t,onChange:s}),l=e!==void 0,c=l?e:i,u=d.useCallback(h=>{var f;if(l){const p=y0(h)?h(e):h;p!==e&&((f=o.current)==null||f.call(o,p))}else a(h)},[l,e,a,o]);return[c,u]}nl(Sa,"useControllableState");function j0({defaultProp:e,onChange:t}){const[s,r]=d.useState(e),i=d.useRef(s),a=d.useRef(t);return DT(()=>{a.current=t},[t]),d.useEffect(()=>{var o;i.current!==s&&((o=a.current)==null||o.call(a,s),i.current=s)},[s,i]),[s,r,a]}nl(j0,"useUncontrolledState");function y0(e){return typeof e=="function"}nl(y0,"isFunction");var Uv=Symbol("RADIX:SYNC_STATE");function LT(e,t,s,r){const{prop:i,defaultProp:a,onChange:o,caller:l}=t,c=i!==void 0,u=v0(o),h=[{...s,state:a}];r&&h.push(r);const[f,p]=d.useReducer((b,v)=>{if(v.type===Uv)return{...b,state:v.state};const x=e(b,v);return c&&!Object.is(x.state,b.state)&&u(x.state),x},...h),m=f.state,j=d.useRef(m);d.useEffect(()=>{j.current!==m&&(j.current=m,c||u(m))},[m,j,c]);const w=d.useMemo(()=>i!==void 0?{...f,state:i}:f,[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&p({type:Uv,state:i})},[i,f.state,c]),[w,p]}nl(LT,"useControllableStateReducer");var FT=Object.defineProperty,UT=(e,t)=>FT(e,"name",{value:t,configurable:!0}),BT=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"}),w0=d.forwardRef(UT(function(t,s){return n.jsx(ft.span,{...t,ref:s,style:{...BT,...t.style}})},"VisuallyHidden")),zT=w0,WT=Object.defineProperty,qt=(e,t)=>WT(e,"name",{value:t,configurable:!0}),b0="ToastProvider",[k0,HT,VT]=Lu("Toast"),[S0,j5]=is("Toast",[VT]),[KT,N0]=S0(b0),GT=qt(e=>{const{__scopeToast:t,label:s="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:a=50,announcerContainer:o,children:l}=e,[c,u]=d.useState(null),[h,f]=d.useState(0),p=d.useRef(!1);return s.trim()||console.error(`Invalid prop \`label\` supplied to \`${b0}\`. Expected non-empty \`string\`.`),n.jsx(k0.Provider,{scope:t,children:n.jsx(KT,{scope:t,label:s,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:h,viewport:c,onViewportChange:u,onToastAdd:d.useCallback(()=>f(m=>m+1),[]),onToastRemove:d.useCallback(()=>f(m=>m-1),[]),isClosePausedRef:p,announcerContainer:o,children:l})})},"ToastProvider"),YT="ToastViewport",qT=["F8"],QT="toast.viewportPause",XT="toast.viewportResume",JT=d.forwardRef(qt(function(t,s){const{__scopeToast:r,hotkey:i=qT,label:a="Notifications ({hotkey})",...o}=t,l=N0(YT,r),c=HT(r),u=d.useRef(null),h=d.useRef(null),f=d.useRef(null),p=d.useRef(null),m=ut(s,p,l.onViewportChange),j=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=l.toastCount>0;d.useEffect(()=>{const v=qt(x=>{var g;i.length!==0&&i.every(N=>x[N]||x.code===N)&&((g=p.current)==null||g.focus())},"handleKeyDown");return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[i]),d.useEffect(()=>{const v=u.current,x=p.current;if(w&&v&&x){const y=qt(()=>{if(!l.isClosePausedRef.current){const S=new CustomEvent(QT);x.dispatchEvent(S),l.isClosePausedRef.current=!0}},"handlePause"),g=qt(()=>{if(l.isClosePausedRef.current){const S=new CustomEvent(XT);x.dispatchEvent(S),l.isClosePausedRef.current=!1}},"handleResume"),N=qt(S=>{!v.contains(S.relatedTarget)&&g()},"handleFocusOutResume"),k=qt(()=>{v.contains(document.activeElement)||g()},"handlePointerLeaveResume");return v.addEventListener("focusin",y),v.addEventListener("focusout",N),v.addEventListener("pointermove",y),v.addEventListener("pointerleave",k),window.addEventListener("blur",y),window.addEventListener("focus",g),()=>{v.removeEventListener("focusin",y),v.removeEventListener("focusout",N),v.removeEventListener("pointermove",y),v.removeEventListener("pointerleave",k),window.removeEventListener("blur",y),window.removeEventListener("focus",g)}}},[w,l.isClosePausedRef]);const b=d.useCallback(({tabbingDirection:v})=>{const y=c().map(g=>{const N=g.ref.current,k=[N,...A0(N)];return v==="forwards"?k:k.reverse()});return(v==="forwards"?y.reverse():y).flat()},[c]);return d.useEffect(()=>{const v=p.current;if(v){const x=qt(y=>{var k,S,C;const g=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!g){const R=document.activeElement,E=y.shiftKey;if(y.target===v&&E){(k=h.current)==null||k.focus();return}const U=b({tabbingDirection:E?"backwards":"forwards"}),T=U.findIndex(M=>M===R);jc(U.slice(T+1))?y.preventDefault():E?(S=h.current)==null||S.focus():(C=f.current)==null||C.focus()}},"handleKeyDown");return v.addEventListener("keydown",x),()=>v.removeEventListener("keydown",x)}},[c,b]),n.jsxs(RT,{ref:u,role:"region","aria-label":a.replace("{hotkey}",j),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&n.jsx(Bv,{ref:h,onFocusFromOutsideViewport:()=>{const v=b({tabbingDirection:"forwards"});jc(v)}}),n.jsx(k0.Slot,{scope:r,children:n.jsx(ft.ol,{tabIndex:-1,...o,ref:m})}),w&&n.jsx(Bv,{ref:f,onFocusFromOutsideViewport:()=>{const v=b({tabbingDirection:"backwards"});jc(v)}})]})},"ToastViewport")),ZT="ToastFocusProxy",Bv=d.forwardRef(qt(function(t,s){const{__scopeToast:r,onFocusFromOutsideViewport:i,...a}=t,o=N0(ZT,r);return n.jsx(w0,{tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:l=>{var h;const c=l.relatedTarget;!((h=o.viewport)!=null&&h.contains(c))&&i()}})},"ToastFocusProxy")),eR="Toast",[y5,w5]=S0(eR,{onClose(){}});function C0(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),E0(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!i)if(a){const o=r.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...C0(r))}}),t}qt(C0,"getAnnounceTextContent");function tR(e,t,s,{discrete:r}){const i=s.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:s});t&&i.addEventListener(e,t,{once:!0}),r?Fu(i,a):i.dispatchEvent(a)}qt(tR,"handleAndDispatchCustomEvent");function nR(e=()=>{}){const t=ss(e);yn(()=>{let s=0,r=0;return s=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(r)}},[t])}qt(nR,"useNextFrame");function E0(e){return e.nodeType===e.ELEMENT_NODE}qt(E0,"isHTMLElement");function A0(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:qt(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;s.nextNode();)t.push(s.currentNode);return t}qt(A0,"getTabbableCandidates");function jc(e){const t=document.activeElement;return e.some(s=>s===t?!0:(s.focus(),document.activeElement!==t))}qt(jc,"focusFirst");var zv=GT,Wv=JT,sR=Object.defineProperty,rR=(e,t)=>sR(e,"name",{value:t,configurable:!0}),iR=ya[" useId ".trim().toString()]||(()=>{}),aR=0;function Bs(e){const[t,s]=d.useState(iR());return yn(()=>{e||s(r=>r??String(aR++))},[e]),e||(t?`radix-${t}`:"")}rR(Bs,"useId");const oR=["top","right","bottom","left"],Cr=Math.min,zs=Math.max,nu=Math.round,_l=Math.floor,Ws=e=>({x:e,y:e}),lR={left:"right",right:"left",bottom:"top",top:"bottom"};function T0(e,t,s){return zs(e,Cr(t,s))}function qs(e,t){return typeof e=="function"?e(t):e}function Er(e){return e.split("-")[0]}function Na(e){return e.split("-")[1]}function Um(e){return e==="x"?"y":"x"}function Bm(e){return e==="y"?"height":"width"}function js(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function zm(e){return Um(js(e))}function cR(e,t,s){s===void 0&&(s=!1);const r=Na(e),i=zm(e),a=Bm(i);let o=i==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(o=su(o)),[o,su(o)]}function uR(e){const t=su(e);return[Lh(e),t,Lh(t)]}function Lh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Hv=["left","right"],Vv=["right","left"],dR=["top","bottom"],fR=["bottom","top"];function hR(e,t,s){switch(e){case"top":case"bottom":return s?t?Vv:Hv:t?Hv:Vv;case"left":case"right":return t?dR:fR;default:return[]}}function pR(e,t,s,r){const i=Na(e);let a=hR(Er(e),s==="start",r);return i&&(a=a.map(o=>o+"-"+i),t&&(a=a.concat(a.map(Lh)))),a}function su(e){const t=Er(e);return lR[t]+e.slice(t.length)}function mR(e){var t,s,r,i;return{top:(t=e.top)!=null?t:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function R0(e){return typeof e!="number"?mR(e):{top:e,right:e,bottom:e,left:e}}function ru(e){const{x:t,y:s,width:r,height:i}=e;return{width:r,height:i,top:s,left:t,right:t+r,bottom:s+i,x:t,y:s}}function Kv(e,t,s){let{reference:r,floating:i}=e;const a=js(t),o=zm(t),l=Bm(o),c=Er(t),u=a==="y",h=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,p=r[l]/2-i[l]/2;let m;switch(c){case"top":m={x:h,y:r.y-i.height};break;case"bottom":m={x:h,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-i.width,y:f};break;default:m={x:r.x,y:r.y}}const j=Na(t);return j&&(m[o]+=p*(j==="end"?1:-1)*(s&&u?-1:1)),m}async function gR(e,t){var s;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:o,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=qs(t,e),j=R0(m),b=l[p?f==="floating"?"reference":"floating":f],v=ru(await a.getClippingRect({element:(s=await(a.isElement==null?void 0:a.isElement(b)))==null||s?b:b.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:h,strategy:c})),x=f==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),g=await(a.isElement==null?void 0:a.isElement(y))&&await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1},N=ru(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:y,strategy:c}):x);return{top:(v.top-N.top+j.top)/g.y,bottom:(N.bottom-v.bottom+j.bottom)/g.y,left:(v.left-N.left+j.left)/g.x,right:(N.right-v.right+j.right)/g.x}}const xR=50,vR=async(e,t,s)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:o}=s,l=o.detectOverflow?o:{...o,detectOverflow:gR},c=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:f}=Kv(u,r,c),p=r,m=0;const j={};for(let w=0;w<a.length;w++){const b=a[w];if(!b)continue;const{name:v,fn:x}=b,{x:y,y:g,data:N,reset:k}=await x({x:h,y:f,initialPlacement:r,placement:p,strategy:i,middlewareData:j,rects:u,platform:l,elements:{reference:e,floating:t}});h=y??h,f=g??f,j[v]={...j[v],...N},k&&m<xR&&(m++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(u=k.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:h,y:f}=Kv(u,p,c)),w=-1)}return{x:h,y:f,placement:p,strategy:i,middlewareData:j}},jR=e=>({name:"arrow",options:e,async fn(t){const{x:s,y:r,placement:i,rects:a,platform:o,elements:l,middlewareData:c}=t,{element:u,padding:h=0}=qs(e,t)||{};if(u==null)return{};const f=R0(h),p={x:s,y:r},m=zm(i),j=Bm(m),w=await o.getDimensions(u),b=m==="y",v=b?"top":"left",x=b?"bottom":"right",y=b?"clientHeight":"clientWidth",g=a.reference[j]+a.reference[m]-p[m]-a.floating[j],N=p[m]-a.reference[m],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let S=k?k[y]:0;(!S||!await(o.isElement==null?void 0:o.isElement(k)))&&(S=l.floating[y]||a.floating[j]);const C=g/2-N/2,R=S/2-w[j]/2-1,E=Cr(f[v],R),P=Cr(f[x],R),O=S-w[j]-P,U=S/2-w[j]/2+C,T=T0(E,U,O),M=!c.arrow&&Na(i)!=null&&U!==T&&a.reference[j]/2-(U<E?E:P)-w[j]/2<0,L=M?U<E?U-E:U-O:0;return{[m]:p[m]+L,data:{[m]:T,centerOffset:U-T-L,...M&&{alignmentOffset:L}},reset:M}}}),yR=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,r;const{placement:i,middlewareData:a,rects:o,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:w=!0,...b}=qs(e,t);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const v=Er(i),x=js(l),y=Er(l)===l,g=await(c.isRTL==null?void 0:c.isRTL(u.floating)),N=p||(y||!w?[su(l)]:uR(l)),k=j!=="none";!p&&k&&N.push(...pR(l,w,j,g));const S=[l,...N],C=await c.detectOverflow(t,b),R=[];let E=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&R.push(C[v]),f){const T=cR(i,o,g);R.push(C[T[0]],C[T[1]])}if(E=[...E,{placement:i,overflows:R}],!R.every(T=>T<=0)){var P,O;const T=(((P=a.flip)==null?void 0:P.index)||0)+1,M=S[T];if(M&&(!(f==="alignment"?x!==js(M):!1)||E.every(D=>js(D.placement)===x?D.overflows[0]>0:!0)))return{data:{index:T,overflows:E},reset:{placement:M}};let L=(O=E.filter(K=>K.overflows[0]<=0).sort((K,D)=>K.overflows[1]-D.overflows[1])[0])==null?void 0:O.placement;if(!L)switch(m){case"bestFit":{var U;const K=(U=E.filter(D=>{if(k){const q=js(D.placement);return q===x||q==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(q=>q>0).reduce((q,F)=>q+F,0)]).sort((D,q)=>D[1]-q[1])[0])==null?void 0:U[0];K&&(L=K);break}case"initialPlacement":L=l;break}if(i!==L)return{reset:{placement:L}}}return{}}}};function Gv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Yv(e){return oR.some(t=>e[t]>=0)}const wR=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:s,platform:r}=t,{strategy:i="referenceHidden",...a}=qs(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=Gv(o,s.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Yv(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...a,altBoundary:!0}),l=Gv(o,s.floating);return{data:{escapedOffsets:l,escaped:Yv(l)}}}default:return{}}}}},I0=new Set(["left","top"]);async function bR(e,t){const{placement:s,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Er(s),l=Na(s),c=js(s)==="y",u=I0.has(o)?-1:1,h=a&&c?-1:1,f=qs(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:j}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof j=="number"&&(m=l==="end"?j*-1:j),c?{x:m*h,y:p*u}:{x:p*u,y:m*h}}const kR=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,r;const{x:i,y:a,placement:o,middlewareData:l}=t,c=await bR(t,e);return o===((s=l.offset)==null?void 0:s.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:{...c,placement:o}}}}},SR=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:x=>{let{x:y,y:g}=x;return{x:y,y:g}}},...u}=qs(e,t),h={x:s,y:r},f=await a.detectOverflow(t,u),p=js(i),m=Um(p);let j=h[m],w=h[p];const b=(x,y)=>T0(y+f[x==="y"?"top":"left"],y,y-f[x==="y"?"bottom":"right"]);o&&(j=b(m,j)),l&&(w=b(p,w));const v=c.fn({...t,[m]:j,[p]:w});return{...v,data:{x:v.x-s,y:v.y-r,enabled:{[m]:o,[p]:l}}}}}},NR=function(e){return e===void 0&&(e={}),{options:e,fn(t){var s,r;const{x:i,y:a,placement:o,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:h=!0,crossAxis:f=!0}=qs(e,t),p={x:i,y:a},m=js(o),j=Um(m);let w=p[j],b=p[m];const v=qs(u,t),x=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:(s=v.mainAxis)!=null?s:0,crossAxis:(r=v.crossAxis)!=null?r:0};if(h){const N=j==="y"?"height":"width",k=l.reference[j]-l.floating[N]+x.mainAxis,S=l.reference[j]+l.reference[N]-x.mainAxis;w<k?w=k:w>S&&(w=S)}if(f){var y,g;const N=j==="y"?"width":"height",k=I0.has(Er(o)),S=l.reference[m]-l.floating[N]+(k&&((y=c.offset)==null?void 0:y[m])||0)+(k?0:x.crossAxis),C=l.reference[m]+l.reference[N]+(k?0:((g=c.offset)==null?void 0:g[m])||0)-(k?x.crossAxis:0);b<S?b=S:b>C&&(b=C)}return{[j]:w,[m]:b}}}},CR=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:s,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...l}=qs(e,t),c=await i.detectOverflow(t,l),u=Er(s),h=Na(s),f=js(s)==="y",{width:p,height:m}=r.floating;let j,w;u==="top"||u==="bottom"?(j=u,w=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=u,j=h==="end"?"top":"bottom");const b=m-c.top-c.bottom,v=p-c.left-c.right,x=Cr(m-c[j],b),y=Cr(p-c[w],v),g=t.middlewareData.shift,N=!g;let k=x,S=y;g!=null&&g.enabled.x&&(S=v),g!=null&&g.enabled.y&&(k=b),N&&!h&&(f?S=p-2*zs(c.left,c.right):k=m-2*zs(c.top,c.bottom)),await o({...t,availableWidth:S,availableHeight:k});const C=await i.getDimensions(a.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}};function Uu(){return typeof window<"u"}function Ca(e){return P0(e)?(e.nodeName||"").toLowerCase():"#document"}function wn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function tr(e){var t;return(t=(P0(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function P0(e){return Uu()?e instanceof Node||e instanceof wn(e).Node:!1}function Ss(e){return Uu()?e instanceof Element||e instanceof wn(e).Element:!1}function Or(e){return Uu()?e instanceof HTMLElement||e instanceof wn(e).HTMLElement:!1}function qv(e){return!Uu()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof wn(e).ShadowRoot}function Bu(e){const{overflow:t,overflowX:s,overflowY:r,display:i}=Ns(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+s)&&i!=="inline"&&i!=="contents"}function ER(e){return/^(table|td|th)$/.test(Ca(e))}function zu(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const AR=/transform|translate|scale|rotate|perspective|filter/,TR=/paint|layout|strict|content/,zr=e=>!!e&&e!=="none";let Yd;function Wm(e){const t=Ss(e)?Ns(e):e;return zr(t.transform)||zr(t.translate)||zr(t.scale)||zr(t.rotate)||zr(t.perspective)||!Hm()&&(zr(t.backdropFilter)||zr(t.filter))||AR.test(t.willChange||"")||TR.test(t.contain||"")}function RR(e){let t=ai(e);for(;Or(t)&&!Mo(t);){if(Wm(t))return t;if(zu(t))return null;t=ai(t)}return null}function Hm(){return Yd==null&&(Yd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Yd}function Mo(e){return/^(html|body|#document)$/.test(Ca(e))}function Ns(e){return wn(e).getComputedStyle(e)}function Wu(e){return Ss(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ai(e){if(Ca(e)==="html")return e;const t=e.assignedSlot||e.parentNode||qv(e)&&e.host||tr(e);return qv(t)?t.host:t}function M0(e){const t=ai(e);return Mo(t)?(e.ownerDocument||e).body:Or(t)&&Bu(t)?t:M0(t)}function $o(e,t,s){var r;t===void 0&&(t=[]),s===void 0&&(s=!0);const i=M0(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),o=wn(i);if(a){const l=Fh(o);return t.concat(o,o.visualViewport||[],Bu(i)?i:[],l&&s?$o(l):[])}else return t.concat(i,$o(i,[],s))}function Fh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $0(e){const t=Ns(e);let s=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Or(e),a=i?e.offsetWidth:s,o=i?e.offsetHeight:r,l=nu(s)!==a||nu(r)!==o;return l&&(s=a,r=o),{width:s,height:r,$:l}}function Vm(e){return Ss(e)?e:e.contextElement}function ea(e){const t=Vm(e);if(!Or(t))return Ws(1);const s=t.getBoundingClientRect(),{width:r,height:i,$:a}=$0(t);let o=(a?nu(s.width):s.width)/r,l=(a?nu(s.height):s.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const IR=Ws(0);function O0(e){const t=wn(e);return!Hm()||!t.visualViewport?IR:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function PR(e,t,s){return t===void 0&&(t=!1),!!s&&t&&s===wn(e)}function oi(e,t,s,r){t===void 0&&(t=!1),s===void 0&&(s=!1);const i=e.getBoundingClientRect(),a=Vm(e);let o=Ws(1);t&&(r?Ss(r)&&(o=ea(r)):o=ea(e));const l=PR(a,s,r)?O0(a):Ws(0);let c=(i.left+l.x)/o.x,u=(i.top+l.y)/o.y,h=i.width/o.x,f=i.height/o.y;if(a&&r){const p=wn(a),m=Ss(r)?wn(r):r;let j=p,w=Fh(j);for(;w&&m!==j;){const b=ea(w),v=w.getBoundingClientRect(),x=Ns(w),y=v.left+(w.clientLeft+parseFloat(x.paddingLeft))*b.x,g=v.top+(w.clientTop+parseFloat(x.paddingTop))*b.y;c*=b.x,u*=b.y,h*=b.x,f*=b.y,c+=y,u+=g,j=wn(w),w=Fh(j)}}return ru({width:h,height:f,x:c,y:u})}function Hu(e,t){const s=Wu(e).scrollLeft;return t?t.left+s:oi(tr(e)).left+s}function _0(e,t){const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-Hu(e,s),i=s.top+t.scrollTop;return{x:r,y:i}}function MR(e){let{elements:t,rect:s,offsetParent:r,strategy:i}=e;const a=i==="fixed",o=tr(r),l=t?zu(t.floating):!1;if(r===o||l&&a)return s;let c={scrollLeft:0,scrollTop:0},u=Ws(1);const h=Ws(0),f=Or(r);if((f||!a)&&((Ca(r)!=="body"||Bu(o))&&(c=Wu(r)),f)){const m=oi(r);u=ea(r),h.x=m.x+r.clientLeft,h.y=m.y+r.clientTop}const p=o&&!f&&!a?_0(o,c):Ws(0);return{width:s.width*u.x,height:s.height*u.y,x:s.x*u.x-c.scrollLeft*u.x+h.x+p.x,y:s.y*u.y-c.scrollTop*u.y+h.y+p.y}}function $R(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function OR(e){const t=Wu(e),s=e.ownerDocument.body,r=zs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=zs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let a=-t.scrollLeft+Hu(e);const o=-t.scrollTop;return Ns(s).direction==="rtl"&&(a+=zs(e.clientWidth,s.clientWidth)-r),{width:r,height:i,x:a,y:o}}const _R=25;function DR(e,t,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",i=wn(e),a=tr(e),o=i.visualViewport;let l=a.clientWidth,c=a.clientHeight,u=0,h=0;if(o){const p=!Hm()||t==="fixed";r?p||(u=-o.offsetLeft,h=-o.offsetTop):(l=o.width,c=o.height,p&&(u=o.offsetLeft,h=o.offsetTop))}if(Hu(a)<=0){const p=a.ownerDocument,m=p.body,j=getComputedStyle(m),w=p.compatMode==="CSS1Compat"&&parseFloat(j.marginLeft)+parseFloat(j.marginRight)||0,b=Math.abs(a.clientWidth-m.clientWidth-w),v=getComputedStyle(a).scrollbarGutter==="stable both-edges"?b/2:b;v<=_R&&(l-=v)}return{width:l,height:c,x:u,y:h}}function LR(e,t){const s=oi(e,!0,t==="fixed"),r=s.top+e.clientTop,i=s.left+e.clientLeft,a=ea(e),o=e.clientWidth*a.x,l=e.clientHeight*a.y,c=i*a.x,u=r*a.y;return{width:o,height:l,x:c,y:u}}function Qv(e,t,s){let r;if(t==="viewport"||t==="layoutViewport")r=DR(e,s,t);else if(t==="document")r=OR(tr(e));else if(Ss(t))r=LR(t,s);else{const i=O0(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return ru(r)}function FR(e,t){const s=t.get(e);if(s)return s;let r=$o(e,[],!1).filter(l=>Ss(l)&&Ca(l)!=="body"),i=null;const a=Ns(e).position==="fixed";let o=a?ai(e):e;for(;Ss(o)&&!Mo(o);){const l=Ns(o),c=Wm(o),u=i?i.position:a?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&l.position==="static")?r=r.filter(f=>f!==o):i=l,o=ai(o)}return t.set(e,r),r}function UR(e){let{element:t,boundary:s,rootBoundary:r,strategy:i}=e;const o=[...s==="clippingAncestors"?zu(t)?[]:FR(t,this._c):[].concat(s),r],l=Qv(t,o[0],i);let c=l.top,u=l.right,h=l.bottom,f=l.left;for(let p=1;p<o.length;p++){const m=Qv(t,o[p],i);c=zs(m.top,c),u=Cr(m.right,u),h=Cr(m.bottom,h),f=zs(m.left,f)}return{width:u-f,height:h-c,x:f,y:c}}function BR(e){const{width:t,height:s}=$0(e);return{width:t,height:s}}function zR(e,t,s){const r=Or(t),i=tr(t),a=s==="fixed",o=oi(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=Ws(0);if((r||!a)&&((Ca(t)!=="body"||Bu(i))&&(l=Wu(t)),r)){const p=oi(t,!0,a,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}!r&&i&&(c.x=Hu(i));const u=i&&!r&&!a?_0(i,l):Ws(0),h=o.left+l.scrollLeft-c.x-u.x,f=o.top+l.scrollTop-c.y-u.y;return{x:h,y:f,width:o.width,height:o.height}}function qd(e){return Ns(e).position==="static"}function Xv(e,t){if(!Or(e)||Ns(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return tr(e)===s&&(s=s.ownerDocument.body),s}function D0(e,t){const s=wn(e);if(zu(e))return s;if(!Or(e)){let i=ai(e);for(;i&&!Mo(i);){if(Ss(i)&&!qd(i))return i;i=ai(i)}return s}let r=Xv(e,t);for(;r&&ER(r)&&qd(r);)r=Xv(r,t);return r&&Mo(r)&&qd(r)&&!Wm(r)?s:r||RR(e)||s}const WR=async function(e){const t=this.getOffsetParent||D0,s=this.getDimensions,r=await s(e.floating);return{reference:zR(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function HR(e){return Ns(e).direction==="rtl"}const VR={convertOffsetParentRelativeRectToViewportRelativeRect:MR,getDocumentElement:tr,getClippingRect:UR,getOffsetParent:D0,getElementRects:WR,getClientRects:$R,getDimensions:BR,getScale:ea,isElement:Ss,isRTL:HR};function L0(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function KR(e,t,s){let r=null,i;const a=tr(e);function o(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function l(h,f){h===void 0&&(h=!1),f===void 0&&(f=1),o();const p=e.getBoundingClientRect(),{left:m,top:j,width:w,height:b}=p;if(h||t(),!w||!b)return;const v=_l(j),x=_l(a.clientWidth-(m+w)),y=_l(a.clientHeight-(j+b)),g=_l(m),k={rootMargin:-v+"px "+-x+"px "+-y+"px "+-g+"px",threshold:zs(0,Cr(1,f))||1};let S=!0;function C(R){const E=R[0].intersectionRatio;if(!L0(p,e.getBoundingClientRect()))return l();if(E!==f){if(!S)return l();E?l(!1,E):i=setTimeout(()=>{l(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...k,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,k)}r.observe(e)}const c=wn(e),u=()=>l(s);return c.addEventListener("resize",u),l(!0),()=>{c.removeEventListener("resize",u),o()}}function GR(e,t,s,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Vm(e),h=i||a?[...u?$o(u):[],...t?$o(t):[]]:[];h.forEach(v=>{i&&v.addEventListener("scroll",s),a&&v.addEventListener("resize",s)});const f=u&&l?KR(u,s,a):null;let p=-1,m=null;o&&(m=new ResizeObserver(v=>{let[x]=v;x&&x.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),s()}),u&&!c&&m.observe(u),t&&m.observe(t));let j,w=c?oi(e):null;c&&b();function b(){const v=oi(e);w&&!L0(w,v)&&s(),w=v,j=requestAnimationFrame(b)}return s(),()=>{var v;h.forEach(x=>{i&&x.removeEventListener("scroll",s),a&&x.removeEventListener("resize",s)}),f==null||f(),(v=m)==null||v.disconnect(),m=null,c&&cancelAnimationFrame(j)}}const YR=kR,qR=SR,QR=yR,XR=CR,JR=wR,Jv=jR,ZR=NR,eI=(e,t,s)=>{const r=new Map,i=s??{},a={...VR,...i.platform,_c:r};return vR(e,t,{...i,platform:a})};var tI=typeof document<"u",nI=function(){},yc=tI?d.useLayoutEffect:nI;function iu(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let s,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(r=s;r--!==0;)if(!iu(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),s=i.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=s;r--!==0;){const a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!iu(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function F0(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Zv(e,t){const s=F0(e);return Math.round(t*s)/s}function Qd(e){const t=d.useRef(e);return yc(()=>{t.current=e}),t}function sI(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[h,f]=d.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=d.useState(r);iu(p,r)||m(r);const[j,w]=d.useState(null),[b,v]=d.useState(null),x=d.useCallback(D=>{D!==k.current&&(k.current=D,w(D))},[]),y=d.useCallback(D=>{D!==S.current&&(S.current=D,v(D))},[]),g=a||j,N=o||b,k=d.useRef(null),S=d.useRef(null),C=d.useRef(h),R=c!=null,E=Qd(c),P=Qd(i),O=Qd(u),U=d.useCallback(()=>{if(!k.current||!S.current)return;const D={placement:t,strategy:s,middleware:p};P.current&&(D.platform=P.current),eI(k.current,S.current,D).then(q=>{const F={...q,isPositioned:O.current!==!1};T.current&&!iu(C.current,F)&&(C.current=F,da.flushSync(()=>{f(F)}))})},[p,t,s,P,O]);yc(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[u]);const T=d.useRef(!1);yc(()=>(T.current=!0,()=>{T.current=!1}),[]),yc(()=>{if(g&&(k.current=g),N&&(S.current=N),g&&N){if(E.current)return E.current(g,N,U);U()}},[g,N,U,E,R]);const M=d.useMemo(()=>({reference:k,floating:S,setReference:x,setFloating:y}),[x,y]),L=d.useMemo(()=>({reference:g,floating:N}),[g,N]),K=d.useMemo(()=>{const D={position:s,left:0,top:0};if(!L.floating)return D;const q=Zv(L.floating,h.x),F=Zv(L.floating,h.y);return l?{...D,transform:"translate("+q+"px, "+F+"px)",...F0(L.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:q,top:F}},[s,l,L.floating,h.x,h.y]);return d.useMemo(()=>({...h,update:U,refs:M,elements:L,floatingStyles:K}),[h,U,M,L,K])}const rI=e=>{function t(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:r,padding:i}=typeof e=="function"?e(s):e;return r&&t(r)?r.current!=null?Jv({element:r.current,padding:i}).fn(s):{}:r?Jv({element:r,padding:i}).fn(s):{}}}},iI=(e,t)=>{const s=YR(e);return{name:s.name,fn:s.fn,options:[e,t]}},aI=(e,t)=>{const s=qR(e);return{name:s.name,fn:s.fn,options:[e,t]}},oI=(e,t)=>({fn:ZR(e).fn,options:[e,t]}),lI=(e,t)=>{const s=QR(e);return{name:s.name,fn:s.fn,options:[e,t]}},cI=(e,t)=>{const s=XR(e);return{name:s.name,fn:s.fn,options:[e,t]}},uI=(e,t)=>{const s=JR(e);return{name:s.name,fn:s.fn,options:[e,t]}},dI=(e,t)=>{const s=rI(e);return{name:s.name,fn:s.fn,options:[e,t]}};var fI=Object.defineProperty,hI=(e,t)=>fI(e,"name",{value:t,configurable:!0});function U0(e){const[t,s]=d.useState(void 0);return yn(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let o,l;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;o=u.inlineSize,l=u.blockSize}else o=e.offsetWidth,l=e.offsetHeight;s({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else s(void 0)},[e]),t}hI(U0,"useSize");var pI=Object.defineProperty,yr=(e,t)=>pI(e,"name",{value:t,configurable:!0}),B0="Popper",[z0,Vu]=is(B0),[mI,W0]=z0(B0),gI=yr(e=>{const{__scopePopper:t,children:s}=e,[r,i]=d.useState(null),[a,o]=d.useState(void 0);return n.jsx(mI,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:s})},"Popper"),xI="PopperAnchor",vI=d.forwardRef(yr(function(t,s){const{__scopePopper:r,virtualRef:i,...a}=t,o=W0(xI,r),l=d.useRef(null),c=o.onAnchorChange,u=d.useCallback(w=>{l.current=w,w&&c(w)},[c]),h=ut(s,u),f=d.useRef(null);d.useEffect(()=>{if(!i)return;const w=f.current;f.current=i.current,w!==f.current&&c(f.current)});const p=o.placementState&&Ku(o.placementState),m=p==null?void 0:p[0],j=p==null?void 0:p[1];return i?null:n.jsx(ft.div,{"data-radix-popper-side":m,"data-radix-popper-align":j,...a,ref:h})},"PopperAnchor")),H0="PopperContent",[jI,b5]=z0(H0),yI=d.forwardRef(yr(function(t,s){var $e,ne,be,Ne,Qe,Ie,rt;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:j="optimized",onPlaced:w,...b}=t,v=W0(H0,r),[x,y]=d.useState(null),g=ut(s,y),[N,k]=d.useState(null),S=U0(N),C=(S==null?void 0:S.width)??0,R=(S==null?void 0:S.height)??0,E=i+(o!=="center"?"-"+o:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},O=Array.isArray(h)?h:[h],U=O.length>0,T={padding:P,boundary:O.filter(V0),altBoundary:U},{refs:M,floatingStyles:L,placement:K,isPositioned:D,middlewareData:q}=sI({strategy:"fixed",placement:E,whileElementsMounted:yr((...fe)=>GR(...fe,{animationFrame:j==="always"}),"whileElementsMounted"),elements:{reference:v.anchor},middleware:[iI({mainAxis:a+R,alignmentAxis:l}),u&&aI({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?oI():void 0,...T}),u&&lI({...T}),cI({...T,apply:yr(({elements:fe,rects:xe,availableWidth:ze,availableHeight:Oe})=>{const{width:it,height:ke}=xe.reference,De=fe.floating.style;De.setProperty("--radix-popper-available-width",`${ze}px`),De.setProperty("--radix-popper-available-height",`${Oe}px`),De.setProperty("--radix-popper-anchor-width",`${it}px`),De.setProperty("--radix-popper-anchor-height",`${ke}px`)},"apply")}),N&&dI({element:N,padding:c}),wI({arrowWidth:C,arrowHeight:R}),m&&uI({strategy:"referenceHidden",...T,boundary:U?T.boundary:void 0})]}),F=v.setPlacementState;yn(()=>(F(K),()=>{F(void 0)}),[K,F]);const[H,le]=Ku(K),ie=ss(w);yn(()=>{D&&(ie==null||ie())},[D,ie]);const ae=($e=q.arrow)==null?void 0:$e.x,ge=(ne=q.arrow)==null?void 0:ne.y,X=((be=q.arrow)==null?void 0:be.centerOffset)!==0,[de,me]=d.useState();return yn(()=>{x&&me(window.getComputedStyle(x).zIndex)},[x]),n.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:D?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(Ne=q.transformOrigin)==null?void 0:Ne.x,(Qe=q.transformOrigin)==null?void 0:Qe.y].join(" "),...((Ie=q.hide)==null?void 0:Ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:n.jsx(jI,{scope:r,placedSide:H,placedAlign:le,onArrowChange:k,arrowX:ae,arrowY:ge,shouldHideArrow:X,children:n.jsx(ft.div,{"data-side":H,"data-align":le,...b,ref:g,style:{...b.style,animation:D?(rt=b.style)==null?void 0:rt.animation:"none"}})})})},"PopperContent"));function V0(e){return e!==null}yr(V0,"isNotNull");var wI=yr(e=>({name:"transformOrigin",options:e,fn(t){var b,v,x;const{placement:s,rects:r,middlewareData:i}=t,o=((b=i.arrow)==null?void 0:b.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[u,h]=Ku(s),f={start:"0%",center:"50%",end:"100%"}[h],p=(((v=i.arrow)==null?void 0:v.x)??0)+l/2,m=(((x=i.arrow)==null?void 0:x.y)??0)+c/2;let j="",w="";return u==="bottom"?(j=o?f:`${p}px`,w=`${-c}px`):u==="top"?(j=o?f:`${p}px`,w=`${r.floating.height+c}px`):u==="right"?(j=`${-c}px`,w=o?f:`${m}px`):u==="left"&&(j=`${r.floating.width+c}px`,w=o?f:`${m}px`),{data:{x:j,y:w}}}}),"transformOrigin");function Ku(e){const[t,s="center"]=e.split("-");return[t,s]}yr(Ku,"getSideAndAlignFromPlacement");var K0=gI,G0=vI,Y0=yI,bI=Object.defineProperty,_t=(e,t)=>bI(e,"name",{value:t,configurable:!0}),[Km,k5]=is("Tooltip",[Vu]),Gm=Vu(),kI="TooltipProvider",SI=700,Uh="tooltip.open",[NI,Ym]=Km(kI),CI=_t(e=>{const{__scopeTooltip:t,delayDuration:s=SI,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=d.useRef(!0),l=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),n.jsx(NI,{scope:t,isOpenDelayedRef:o,delayDuration:s,onOpen:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:l,onPointerInTransitChange:d.useCallback(u=>{l.current=u},[]),disableHoverableContent:i,children:a})},"TooltipProvider"),Bh="Tooltip",[EI,sl]=Km(Bh),AI=_t(e=>{const{__scopeTooltip:t,children:s,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:l}=e,c=Ym(Bh,e.__scopeTooltip),u=Gm(t),[h,f]=d.useState(null),[p,m]=d.useState(void 0),j=Bs(),w=d.useRef(0),b=o??c.disableHoverableContent,v=l??c.delayDuration,x=d.useRef(!1),[y,g]=Sa({prop:r,defaultProp:i??!1,onChange:_t(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(Uh))):c.onClose(),a==null||a(E)},"onChange"),caller:Bh}),N=d.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x.current=!1,g(!0)},[g]),S=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,g(!1)},[g]),C=d.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{x.current=!0,g(!0),w.current=0},v)},[v,g]);d.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const R=p??j;return n.jsx(K0,{...u,children:n.jsx(EI,{scope:t,contentId:R,setContentId:m,open:y,stateAttribute:N,trigger:h,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?C():k()},[c.isOpenDelayedRef,C,k]),onTriggerLeave:d.useCallback(()=>{b?S():(window.clearTimeout(w.current),w.current=0)},[S,b]),onOpen:k,onClose:S,disableHoverableContent:b,children:s})})},"Tooltip"),ej="TooltipTrigger",TI=d.forwardRef(_t(function(t,s){const{__scopeTooltip:r,...i}=t,a=sl(ej,r),o=Ym(ej,r),l=Gm(r),c=d.useRef(null),u=ut(s,c,a.onTriggerChange),h=d.useRef(!1),f=d.useRef(!1),p=d.useCallback(()=>h.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),n.jsx(G0,{asChild:!0,...l,children:n.jsx(ft.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:u,onPointerMove:Pe(t.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),f.current=!0)}),onPointerLeave:Pe(t.onPointerLeave,()=>{a.onTriggerLeave(),f.current=!1}),onPointerDown:Pe(t.onPointerDown,()=>{a.open&&a.onClose(),h.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:Pe(t.onFocus,()=>{h.current||a.onOpen()}),onBlur:Pe(t.onBlur,a.onClose),onClick:Pe(t.onClick,a.onClose)})})},"TooltipTrigger")),q0="TooltipPortal",[RI,II]=Km(q0,{forceMount:void 0}),PI=_t(e=>{const{__scopeTooltip:t,forceMount:s,children:r,container:i}=e,a=sl(q0,t);return n.jsx(RI,{scope:t,forceMount:s,children:n.jsx($r,{present:s||a.open,children:n.jsx(Fm,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Oo="TooltipContent",MI=d.forwardRef(_t(function(t,s){const r=II(Oo,t.__scopeTooltip),{forceMount:i=r.forceMount,side:a="top",...o}=t,l=sl(Oo,t.__scopeTooltip);return n.jsx($r,{present:i||l.open,children:l.disableHoverableContent?n.jsx(Q0,{side:a,...o,ref:s}):n.jsx($I,{side:a,...o,ref:s})})},"TooltipContent")),$I=d.forwardRef(_t(function(t,s){const r=sl(Oo,t.__scopeTooltip),i=Ym(Oo,t.__scopeTooltip),a=d.useRef(null),o=ut(s,a),[l,c]=d.useState(null),{trigger:u,onClose:h}=r,f=a.current,{onPointerInTransitChange:p}=i,m=d.useCallback(()=>{c(null),p(!1)},[p]),j=d.useCallback((w,b)=>{const v=w.currentTarget,x={x:w.clientX,y:w.clientY},y=X0(x,v.getBoundingClientRect()),g=J0(x,y),N=Z0(b.getBoundingClientRect()),k=tk([...g,...N]);c(k),p(!0)},[p]);return d.useEffect(()=>()=>m(),[m]),d.useEffect(()=>{if(u&&f){const w=_t(v=>j(v,f),"handleTriggerLeave"),b=_t(v=>j(v,u),"handleContentLeave");return u.addEventListener("pointerleave",w),f.addEventListener("pointerleave",b),()=>{u.removeEventListener("pointerleave",w),f.removeEventListener("pointerleave",b)}}},[u,f,j,m]),d.useEffect(()=>{if(l){const w=_t(b=>{const v=b.target,x={x:b.clientX,y:b.clientY},y=(u==null?void 0:u.contains(v))||(f==null?void 0:f.contains(v)),g=!ek(x,l);y?m():g&&(m(),h())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,f,l,h,m]),n.jsx(Q0,{...t,ref:o})},"TooltipContentHoverable")),OI=n0("TooltipContent"),Q0=d.forwardRef(_t(function(t,s){const{__scopeTooltip:r,children:i,"aria-label":a,id:o,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=t,h=sl(Oo,r),f=Gm(r),{onClose:p}=h;d.useEffect(()=>(document.addEventListener(Uh,p),()=>document.removeEventListener(Uh,p)),[p]),d.useEffect(()=>{if(h.trigger){const j=_t(w=>{w.target instanceof Node&&w.target.contains(h.trigger)&&p()},"handleScroll");return window.addEventListener("scroll",j,{capture:!0}),()=>window.removeEventListener("scroll",j,{capture:!0})}},[h.trigger,p]);const{setContentId:m}=h;return yn(()=>(m(o),()=>{m(void 0)}),[o,m]),n.jsx(Dm,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:j=>j.preventDefault(),onDismiss:p,children:n.jsxs(Y0,{"data-state":h.stateAttribute,role:a?void 0:"tooltip",id:a?void 0:h.contentId,...f,...u,ref:s,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[n.jsx(OI,{children:i}),a?n.jsx(zT,{id:h.contentId,role:"tooltip",children:a}):null]})})},"TooltipContentImpl"));function X0(e,t){const s=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(s,r,i,a)){case a:return"left";case i:return"right";case s:return"top";case r:return"bottom";default:throw new Error("unreachable")}}_t(X0,"getExitSideFromRect");function J0(e,t,s=5){const r=[];switch(t){case"top":r.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":r.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":r.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":r.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return r}_t(J0,"getPaddedExitPoints");function Z0(e){const{top:t,right:s,bottom:r,left:i}=e;return[{x:i,y:t},{x:s,y:t},{x:s,y:r},{x:i,y:r}]}_t(Z0,"getPointsFromRect");function ek(e,t){const{x:s,y:r}=e;let i=!1;for(let a=0,o=t.length-1;a<t.length;o=a++){const l=t[a],c=t[o],u=l.x,h=l.y,f=c.x,p=c.y;h>r!=p>r&&s<(f-u)*(r-h)/(p-h)+u&&(i=!i)}return i}_t(ek,"isPointInPolygon");function tk(e){const t=e.slice();return t.sort((s,r)=>s.x<r.x?-1:s.x>r.x?1:s.y<r.y?-1:s.y>r.y?1:0),nk(t)}_t(tk,"getHull");function nk(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const a=t[t.length-1],o=t[t.length-2];if((a.x-o.x)*(i.y-o.y)>=(a.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const s=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;s.length>=2;){const a=s[s.length-1],o=s[s.length-2];if((a.x-o.x)*(i.y-o.y)>=(a.y-o.y)*(i.x-o.x))s.pop();else break}s.push(i)}return s.pop(),t.length===1&&s.length===1&&t[0].x===s[0].x&&t[0].y===s[0].y?t:t.concat(s)}_t(nk,"getHullPresorted");var tj=CI,_o=AI,Do=TI,Lo=PI,Fo=MI;const nj="buddi_csrf",Ea="x-buddi-csrf",Uo="buddi:agents-changed",_I="This page's sign-in no longer matches its cookies. Reload the page and try again.";class oe extends Error{constructor(t,s,r){super(s),this.status=t,this.detail=r,this.name="ApiError"}}function pi(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${nj}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const s=[...document.cookie.matchAll(new RegExp(`(?:^|; )${nj}(?:_\\d+)?=([^;]*)`,"g"))];return s.length===1&&((r=s[0])!=null&&r[1])?decodeURIComponent(s[0][1]):""}const au="buddi isn't answering.";let zh=null;const Wh=new Set;function Dl(e){if(e!==(zh===null)){zh=e?null:Date.now();for(const t of Wh)t()}}function DI(){return zh}function LI(e){return Wh.add(e),()=>Wh.delete(e)}function FI(e){return e instanceof oe&&(e.status===0||e.status===502||e.status===503)&&e.message===au}async function mi(e,t={}){var o;let s;try{s=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}})}catch(l){throw(l==null?void 0:l.name)==="AbortError"||(o=t.signal)!=null&&o.aborted?l:(Dl(!1),new oe(0,au,l))}if(s.status===401)throw Dl(!0),new oe(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await s.text(),i=r===""?null:UI(r),a=i&&typeof i=="object"&&"error"in i?String(i.error):void 0;if((s.status===502||s.status===503)&&a===void 0)throw Dl(!1),new oe(s.status,au,i);if(Dl(!0),!s.ok){const l=(t.method??"GET").toUpperCase(),c=a??(s.status===403&&l!=="GET"&&l!=="HEAD"?_I:`request failed (${s.status})`);throw new oe(s.status,c,i)}return i}function UI(e){try{return JSON.parse(e)}catch{return null}}function ce(e,t={}){const s=new URLSearchParams;for(const[i,a]of Object.entries(t))a!==void 0&&a!==""&&s.set(i,String(a));const r=s.toString();return mi(`/api${e}${r?`?${r}`:""}`)}function sk(e,t){return mi(`/api${e}`,{method:"POST",headers:{[Ea]:pi()},body:t})}function Ki(e){return mi(`/api${e}`,{method:"DELETE",headers:{[Ea]:pi()}})}function Z(e,t={}){return mi(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[Ea]:pi()},body:JSON.stringify(t??{})})}function rk(e,t,s,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||s;return mi(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[Ea]:pi(),"X-Filename":i,...r},body:t})}function sj(e,t,s){return rk(e,t,"backup.tar.gz",{...s.passphrase?{"X-Backup-Passphrase":s.passphrase}:{},...s.confirm?{"X-Backup-Confirm":s.confirm}:{}})}function BI(e,t={}){return mi(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[Ea]:pi()},body:JSON.stringify(t??{})})}function Ci(e,t={}){return mi(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[Ea]:pi()},body:JSON.stringify(t??{})})}function zI(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 wc="gpt-oss:120b",WI=["approval","question","watcher","reminder","failure","recap","plugin"],Le={agents:()=>ce("/chat/agents"),views:()=>ce("/chat/views"),conversations:(e,t)=>ce(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>Z(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>ce(`/chat/conversations/${encodeURIComponent(e)}`),send:(e,t)=>Z(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>Z(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>Z(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),sk("/chat/attachments",t)},transcribe:e=>Z("/speech/transcribe",e),say:e=>Z("/speech/say",e),discardAttachment:e=>Ki(`/artifacts/${encodeURIComponent(e)}`),groups:()=>ce("/groups"),group:e=>ce(`/groups/${encodeURIComponent(e)}`),createGroup:e=>Z("/groups",e),updateGroup:(e,t)=>BI(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>Ki(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>ce(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>Z(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>Z(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`};function qm(e){return e.httpStatus===401||e.httpStatus===403||e.state==="authentication-error"||e.state==="access-denied"}const A={providers:()=>ce("/providers"),providerAccounts:()=>ce("/provider-accounts"),probeModels:e=>Z("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>Z(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>Z("/provider-accounts/save",e),testProviderAccount:e=>Z(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,s)=>Z(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:s}),ollamaConnect:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/connect`,{revision:t}),ollamaPoll:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/poll`,{attemptId:t}),ollamaDisconnect:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/disconnect`,{revision:t}),anthropicAccountAction:(e,t,s,r)=>Z(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:s,...r}),assignProviderAccount:(e,t,s)=>Z(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:s}),configureProvider:(e,t)=>Z(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>Z(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>Z(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>Z(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>ce("/host/browser-profiles",{app:e}),installedApps:()=>ce("/host/apps"),browser:e=>ce(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>Z(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>Z("/browser/settings",e),computerPermissions:(e=!1)=>Z("/browser/permissions",{prompt:e}),browserInstall:()=>Z("/browser/install",{}),browserCheck:()=>Z("/browser/check",{}),previewLink:(e,t)=>ce(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>ce(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>ce("/extension"),pairExtension:e=>Z("/extension/pair",{code:e}),forgetExtension:()=>Ki("/extension/pair"),session:()=>ce("/session"),overview:()=>ce("/overview"),events:e=>ce("/events",e),eventKinds:()=>ce("/events/kinds"),conversations:()=>ce("/conversations"),conversation:e=>ce(`/conversations/${encodeURIComponent(e)}`),missions:()=>ce("/missions"),jobs:(e={})=>ce("/jobs",e),approvals:()=>ce("/approvals"),approval:e=>ce(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>ce("/offers"),dismissOffer:e=>Z(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>Z("/offers/dismiss-all",{ids:e}),agentOffers:()=>ce("/agent-offers"),teammates:()=>ce("/teammates"),dismissAgentOffer:(e,t)=>Z(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>ce("/proposals"),setDigestSchedule:(e,t)=>Z("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>Z(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),discardProposal:(e,t)=>Z(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>ce("/reminders"),sentinels:()=>ce("/sentinels"),setSentinelEnabled:(e,t)=>Z(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),snoozeAlert:(e,t)=>Z(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>ce("/agents"),library:e=>ce("/artifacts",e),libraryEntry:(e,t=0)=>ce(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>ce("/onboarding"),onboardingStep:(e,t={})=>Z("/onboarding/step",{step:e,...t}),completeOnboarding:()=>Z("/onboarding/complete"),skipOnboarding:()=>Z("/onboarding/skip"),createFirstAgent:e=>Z("/onboarding/agent",e),ollama:()=>ce("/onboarding/ollama"),firstAgentPersona:()=>ce("/onboarding/agent"),updateFirstAgent:e=>Z("/onboarding/agent/update",e),bindBrain:e=>Z("/onboarding/brain",e),pages:()=>ce("/pages"),pageQuery:(e,t,s={})=>ce(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,s),pageFileUrl:(e,t,s={})=>{const r=new URLSearchParams(Object.entries(s).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>Z(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>ce("/telegram"),saveTelegramToken:e=>Z("/telegram/token",{token:e}),telegramPairing:()=>Z("/telegram/pairing"),telegramBot:()=>ce("/telegram/bot"),telegramDevices:()=>ce("/telegram/devices"),unpairTelegramDevice:e=>Ki(`/telegram/devices/${encodeURIComponent(e)}`),notifications:(e=20)=>ce("/notifications",{limit:e}),notificationSeen:e=>Z(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>ce("/notifications/settings"),saveNotificationSettings:e=>Ci("/notifications/settings",e),testChannel:e=>Z("/notifications/test",{channel:e}),currentTip:e=>ce(e?`/tips/current?preview=${encodeURIComponent(e)}`:"/tips/current"),tips:()=>ce("/tips"),restoreTip:e=>Z(`/tips/${encodeURIComponent(e)}/restore`),dismissTip:e=>Z(`/tips/${encodeURIComponent(e)}/dismiss`),laterTip:e=>Z(`/tips/${encodeURIComponent(e)}/later`),tipsSeenPage:e=>Z("/tips/seen-page",{page:e}),tipsSettings:()=>ce("/tips/settings"),saveTipsSettings:e=>Ci("/tips/settings",{enabled:e}),presence:e=>Z("/presence",{state:e}),owner:()=>ce("/owner"),setOwner:e=>Z("/owner",e),memory:e=>ce(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>Z("/memory/preferences",e),forgetPreference:e=>Z("/memory/preferences/forget",e),updateNote:(e,t)=>Z(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>Z(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>ce(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>ce(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>ce("/host",{agentId:e,conversationId:t}),connections:()=>ce("/connections"),connection:e=>ce(`/connections/${e}`),addConnection:(e,t)=>Z("/connections",{url:e,...t?{name:t}:{}}),connectionConsent:(e,t)=>Z(`/connections/${e}/consent`,t?{clientId:t}:{}),connectionCallback:e=>Z("/connections/callback",e),connectionReview:e=>ce(`/connections/${e}/review`),saveConnectionReview:(e,t)=>Z(`/connections/${e}/review`,t),grantConnection:(e,t)=>Z(`/connections/${e}/grant`,{agents:t}),disconnect:e=>Ki(`/connections/${e}`),connectionSignals:()=>ce("/connections/signals"),connectionTools:e=>ce(`/connections/${e}/tools`),rememberedApprovals:e=>ce(`/connections/remembered/${encodeURIComponent(e)}`),setRememberedApproval:(e,t,s)=>Z("/connections/remembered",{agent:e,tool:t,remember:s}),secrets:()=>ce("/secrets"),secretUses:(e,t)=>ce("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>Z("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>Z("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>Z("/host/revoke",{id:e}),decide:(e,t,s,r)=>Z(`/approvals/${encodeURIComponent(e)}/${t}`,s||r?{...s?{permissionScope:s}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>Z("/pause",{paused:e}),service:()=>ce("/service"),serviceAction:e=>Z(`/service/${e}`),version:()=>ce("/version"),checkVersion:()=>Z("/version/check"),setVersionCheck:e=>Ci("/version/check",{enabled:e}),tailscale:()=>ce("/tailscale"),setTailscale:e=>Ci("/tailscale",e),startUpgrade:e=>Z("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>ce(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>ce("/backups"),startBackup:e=>Z("/backups",{encrypt:e}),verifyArchive:e=>Z("/backups/verify",{name:e}),restoreArchive:e=>Z("/backups/restore",e),restoreUpload:(e,t)=>sj("/backups/restore",e,t),backupJob:e=>ce(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>ce("/backups/schedule"),setBackupSchedule:e=>Ci("/backups/schedule",e),backupPassphrase:()=>ce("/backups/passphrase"),setBackupPassphrase:e=>Ci("/backups/passphrase",{passphrase:e}),plugins:()=>ce("/plugins"),stagePlugin:e=>Z("/plugins/stage",{spec:e}),uploadPlugin:e=>rk("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>ce(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>Z(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>Z(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),uninstallPlugin:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>ce("/recovery"),leaveRecovery:e=>Z("/recovery/leave",e),firstRunRestore:(e,t)=>sj("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>Z(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,s)=>Z(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...s===void 0?{}:{deadlineMinutes:s}}),retryJob:e=>Z(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>Z(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>Z("/agents/default",{agentId:e}),agentTools:e=>ce(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>ce(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const s=new FormData;return s.append("file",t,t.name),sk(`/agents/${encodeURIComponent(e)}/avatar`,s)},removeAgentPicture:e=>Ki(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>Z(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>Z(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};function ik(e){return e==="anthropic"||e==="openai"}function ak(e,t){var i,a;if(!e)return null;const s=e.credentialEnv&&(t!=null&&t.accounts.some(o=>o.id===e.credentialEnv))?e.credentialEnv:(a=(i=t==null?void 0:t.bindings)==null?void 0:i.find(o=>o.agentId===e.id))==null?void 0:a.accountId,r=s?t==null?void 0:t.accounts.find(o=>o.id===s):void 0;return(r==null?void 0:r.kind)??e.provider}const HI="Thinking is up to this model. What it writes while thinking is shown apart and kept out of the answer.";var VI=Object.defineProperty,KI=(e,t)=>VI(e,"name",{value:t,configurable:!0}),GI=d.createContext(void 0);function Gu(e){const t=d.useContext(GI);return e||t||"ltr"}KI(Gu,"useDirection");var YI=Object.defineProperty,Qm=(e,t)=>YI(e,"name",{value:t,configurable:!0}),Ll=0,ps=null;function qI(e){return Yu(),e.children}Qm(qI,"FocusGuards");function Yu(){d.useEffect(()=>{ps||(ps={start:Hh(),end:Hh()});const{start:e,end:t}=ps;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Ll++,()=>{Ll===1&&(ps==null||ps.start.remove(),ps==null||ps.end.remove(),ps=null),Ll=Math.max(0,Ll-1)}},[])}Qm(Yu,"useFocusGuards");function Hh(){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}Qm(Hh,"createFocusGuard");var QI=Object.defineProperty,an=(e,t)=>QI(e,"name",{value:t,configurable:!0}),Xd="focusScope.autoFocusOnMount",Jd="focusScope.autoFocusOnUnmount",rj={bubbles:!1,cancelable:!0},ok=d.forwardRef(an(function(t,s){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[c,u]=d.useState(null),h=ss(a),f=ss(o),p=d.useRef(null),m=ut(s,u),j=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let b=function(g){if(j.paused||!c)return;const N=g.target;c.contains(N)?p.current=N:Os(p.current,{select:!0})},v=function(g){if(j.paused||!c)return;const N=g.relatedTarget;N!==null&&(c.contains(N)||Os(p.current,{select:!0}))},x=function(g){if(document.activeElement===document.body)for(const k of g)k.removedNodes.length>0&&Os(c)};an(b,"handleFocusIn"),an(v,"handleFocusOut"),an(x,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",v);const y=new MutationObserver(x);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",v),y.disconnect()}}},[i,c,j.paused]),d.useEffect(()=>{if(c){ij.add(j);const b=document.activeElement;if(!c.contains(b)){const x=new CustomEvent(Xd,rj);c.addEventListener(Xd,h),c.dispatchEvent(x),x.defaultPrevented||(lk(hk(Xm(c)),{select:!0}),document.activeElement===b&&Os(c))}return()=>{c.removeEventListener(Xd,h),setTimeout(()=>{const x=new CustomEvent(Jd,rj);c.addEventListener(Jd,f),c.dispatchEvent(x),x.defaultPrevented||Os(b??document.body,{select:!0}),c.removeEventListener(Jd,f),ij.remove(j)},0)}}},[c,h,f,j]);const w=d.useCallback(b=>{if(!r&&!i||j.paused)return;const v=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,x=document.activeElement;if(v&&x){const y=b.currentTarget,[g,N]=ck(y);g&&N?!b.shiftKey&&x===N?(b.preventDefault(),r&&Os(g,{select:!0})):b.shiftKey&&x===g&&(b.preventDefault(),r&&Os(N,{select:!0})):x===y&&b.preventDefault()}},[r,i,j.paused]);return n.jsx(ft.div,{tabIndex:-1,...l,ref:m,onKeyDown:w})},"FocusScope"));function lk(e,{select:t=!1}={}){const s=document.activeElement;for(const r of e)if(Os(r,{select:t}),document.activeElement!==s)return}an(lk,"focusFirst");function ck(e){const t=Xm(e),s=Vh(t,e),r=Vh(t.reverse(),e);return[s,r]}an(ck,"getTabbableEdges");function Xm(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:an(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;s.nextNode();)t.push(s.currentNode);return t}an(Xm,"getTabbableCandidates");function Vh(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(s?!r.checkVisibility({checkVisibilityCSS:!0}):uk(r,{upTo:t})))return r}an(Vh,"findVisible");function uk(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}an(uk,"isHidden");function dk(e){return e instanceof HTMLInputElement&&"select"in e}an(dk,"isSelectableInput");function Os(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&dk(e)&&t&&e.select()}}an(Os,"focus");var ij=fk();function fk(){let e=[];return{add(t){const s=e[0];t!==s&&(s==null||s.pause()),e=Kh(e,t),e.unshift(t)},remove(t){var s;e=Kh(e,t),(s=e[0])==null||s.resume()}}}an(fk,"createFocusScopesStack");function Kh(e,t){const s=[...e],r=s.indexOf(t);return r!==-1&&s.splice(r,1),s}an(Kh,"arrayRemove");function hk(e){return e.filter(t=>t.tagName!=="A")}an(hk,"removeLinks");var XI=Object.defineProperty,Jm=(e,t)=>XI(e,"name",{value:t,configurable:!0}),Zd=!1;function pk(){const[e,t]=d.useState(Zd);return d.useEffect(()=>{Zd||(Zd=!0,t(!0))},[]),e}Jm(pk,"useIsHydrated");var mk=ya[" useSyncExternalStore ".trim().toString()];function gk(){return()=>{}}Jm(gk,"subscribe");function xk(){return mk(gk,()=>!0,()=>!1)}Jm(xk,"useIsHydratedModern");var JI=typeof mk=="function"?xk:pk,ZI=Object.defineProperty,gi=(e,t)=>ZI(e,"name",{value:t,configurable:!0}),ef="rovingFocusGroup.onEntryFocus",eP={bubbles:!1,cancelable:!0},qu="RovingFocusGroup",[Gh,vk,tP]=Lu(qu),[nP,Qu]=is(qu,[tP]),[sP,rP]=nP(qu),iP=d.forwardRef(gi(function(t,s){return n.jsx(Gh.Provider,{scope:t.__scopeRovingFocusGroup,children:n.jsx(Gh.Slot,{scope:t.__scopeRovingFocusGroup,children:n.jsx(aP,{...t,ref:s})})})},"RovingFocusGroup")),aP=d.forwardRef(gi(function(t,s){const{__scopeRovingFocusGroup:r,orientation:i,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...p}=t,m=d.useRef(null),j=ut(s,m),w=Gu(o),[b,v]=Sa({prop:l,defaultProp:c??null,onChange:u,caller:qu}),[x,y]=d.useState(!1),g=ss(h),N=vk(r),k=d.useRef(!1),[S,C]=d.useState(0);return d.useEffect(()=>{const R=m.current;if(R)return R.addEventListener(ef,g),()=>R.removeEventListener(ef,g)},[g]),n.jsx(sP,{scope:r,orientation:i,dir:w,loop:a,currentTabStopId:b,onItemFocus:d.useCallback(R=>v(R),[v]),onItemShiftTab:d.useCallback(()=>y(!0),[]),onFocusableItemAdd:d.useCallback(()=>C(R=>R+1),[]),onFocusableItemRemove:d.useCallback(()=>C(R=>R-1),[]),children:n.jsx(ft.div,{tabIndex:x||S===0?-1:0,"data-orientation":i,...p,ref:j,style:{outline:"none",...t.style},onMouseDown:Pe(t.onMouseDown,()=>{k.current=!0}),onFocus:Pe(t.onFocus,R=>{const E=!k.current;if(R.target===R.currentTarget&&E&&!x){const P=new CustomEvent(ef,eP);if(R.currentTarget.dispatchEvent(P),!P.defaultPrevented){const O=N().filter(K=>K.focusable),U=O.find(K=>K.active),T=O.find(K=>K.id===b),L=[U,T,...O].filter(Boolean).map(K=>K.ref.current);Zm(L,f)}}k.current=!1}),onBlur:Pe(t.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),oP="RovingFocusGroupItem",lP=d.forwardRef(gi(function(t,s){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:a=!1,tabStopId:o,children:l,...c}=t,u=Bs(),h=o||u,f=rP(oP,r),p=f.currentTabStopId===h,m=vk(r),{onFocusableItemAdd:j,onFocusableItemRemove:w,currentTabStopId:b}=f,v=JI();return yn(()=>{if(!(!v||!i))return j(),()=>w()},[v,i,j,w]),d.useEffect(()=>{if(!(v||!i))return j(),()=>w()},[v,i,j,w]),n.jsx(Gh.ItemSlot,{scope:r,id:h,focusable:i,active:a,children:n.jsx(ft.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...c,ref:s,onMouseDown:Pe(t.onMouseDown,x=>{i?f.onItemFocus(h):x.preventDefault()}),onFocus:Pe(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:Pe(t.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){f.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=yk(x,f.orientation,f.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let N=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")N.reverse();else if(y==="prev"||y==="next"){y==="prev"&&N.reverse();const k=N.indexOf(x.currentTarget);N=f.loop?wk(N,k+1):N.slice(k+1)}setTimeout(()=>Zm(N))}}),children:typeof l=="function"?l({isCurrentTabStop:p,hasTabStop:b!=null}):l})})},"RovingFocusGroupItem")),cP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jk(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}gi(jk,"getDirectionAwareKey");function yk(e,t,s){const r=jk(e.key,s);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return cP[r]}gi(yk,"getFocusIntent");function Zm(e,t=!1){const s=document.activeElement;for(const r of e)if(r===s||(r.focus({preventScroll:t}),document.activeElement!==s))return}gi(Zm,"focusFirst");function wk(e,t){return e.map((s,r)=>e[(t+r)%e.length])}gi(wk,"wrapArray");var bk=iP,kk=lP,uP=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ei=new WeakMap,Fl=new WeakMap,Ul={},tf=0,Sk=function(e){return e&&(e.host||Sk(e.parentNode))},dP=function(e,t){return t.map(function(s){if(e.contains(s))return s;var r=Sk(s);return r&&e.contains(r)?r:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},fP=function(e,t,s,r){var i=dP(t,Array.isArray(e)?e:[e]);Ul[s]||(Ul[s]=new WeakMap);var a=Ul[s],o=[],l=new Set,c=new Set(i),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};i.forEach(u);var h=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(l.has(p))h(p);else try{var m=p.getAttribute(r),j=m!==null&&m!=="false",w=(Ei.get(p)||0)+1,b=(a.get(p)||0)+1;Ei.set(p,w),a.set(p,b),o.push(p),w===1&&j&&Fl.set(p,!0),b===1&&p.setAttribute(s,"true"),j||p.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",p,v)}})};return h(t),l.clear(),tf++,function(){o.forEach(function(f){var p=Ei.get(f)-1,m=a.get(f)-1;Ei.set(f,p),a.set(f,m),p||(Fl.has(f)||f.removeAttribute(r),Fl.delete(f)),m||f.removeAttribute(s)}),tf--,tf||(Ei=new WeakMap,Ei=new WeakMap,Fl=new WeakMap,Ul={})}},Nk=function(e,t,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=uP(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),fP(r,i,s,"aria-hidden")):function(){return null}},vs=function(){return vs=Object.assign||function(t){for(var s,r=1,i=arguments.length;r<i;r++){s=arguments[r];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},vs.apply(this,arguments)};function Ck(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(s[r[i]]=e[r[i]]);return s}function hP(e,t,s){if(s||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var bc="right-scroll-bar-position",kc="width-before-scroll-bar",pP="with-scroll-bars-hidden",mP="--removed-body-scroll-bar-size";function nf(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function gP(e,t){var s=d.useState(function(){return{value:e,callback:t,facade:{get current(){return s.value},set current(r){var i=s.value;i!==r&&(s.value=r,s.callback(r,i))}}}})[0];return s.callback=t,s.facade}var xP=typeof window<"u"?d.useLayoutEffect:d.useEffect,aj=new WeakMap;function vP(e,t){var s=gP(null,function(r){return e.forEach(function(i){return nf(i,r)})});return xP(function(){var r=aj.get(s);if(r){var i=new Set(r),a=new Set(e),o=s.current;i.forEach(function(l){a.has(l)||nf(l,null)}),a.forEach(function(l){i.has(l)||nf(l,o)})}aj.set(s,e)},[e]),s}function jP(e){return e}function yP(e,t){t===void 0&&(t=jP);var s=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(a){var o=t(a,r);return s.push(o),function(){s=s.filter(function(l){return l!==o})}},assignSyncMedium:function(a){for(r=!0;s.length;){var o=s;s=[],o.forEach(a)}s={push:function(l){return a(l)},filter:function(){return s}}},assignMedium:function(a){r=!0;var o=[];if(s.length){var l=s;s=[],l.forEach(a),o=s}var c=function(){var h=o;o=[],h.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),s={push:function(h){o.push(h),u()},filter:function(h){return o=o.filter(h),s}}}};return i}function wP(e){e===void 0&&(e={});var t=yP(null);return t.options=vs({async:!0,ssr:!1},e),t}var Ek=function(e){var t=e.sideCar,s=Ck(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,vs({},s))};Ek.isSideCarExport=!0;function bP(e,t){return e.useMedium(t),Ek}var Ak=wP(),sf=function(){},Xu=d.forwardRef(function(e,t){var s=d.useRef(null),r=d.useState({onScrollCapture:sf,onWheelCapture:sf,onTouchMoveCapture:sf}),i=r[0],a=r[1],o=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,h=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,j=e.noIsolation,w=e.inert,b=e.allowPinchZoom,v=e.as,x=v===void 0?"div":v,y=e.gapMode,g=Ck(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=p,k=vP([s,t]),S=vs(vs({},g),i);return d.createElement(d.Fragment,null,h&&d.createElement(N,{sideCar:Ak,removeScrollBar:u,shards:f,noRelative:m,noIsolation:j,inert:w,setCallbacks:a,allowPinchZoom:!!b,lockRef:s,gapMode:y}),o?d.cloneElement(d.Children.only(l),vs(vs({},S),{ref:k})):d.createElement(x,vs({},S,{className:c,ref:k}),l))});Xu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Xu.classNames={fullWidth:kc,zeroRight:bc};var kP=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function SP(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=kP();return t&&e.setAttribute("nonce",t),e}function NP(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function CP(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var EP=function(){var e=0,t=null;return{add:function(s){e==0&&(t=SP())&&(NP(t,s),CP(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},AP=function(){var e=EP();return function(t,s){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},Tk=function(){var e=AP(),t=function(s){var r=s.styles,i=s.dynamic;return e(r,i),null};return t},TP={left:0,top:0,right:0,gap:0},rf=function(e){return parseInt(e||"",10)||0},RP=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[rf(s),rf(r),rf(i)]},IP=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return TP;var t=RP(e),s=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-s+t[2]-t[0])}},PP=Tk(),ta="data-scroll-locked",MP=function(e,t,s,r){var i=e.left,a=e.top,o=e.right,l=e.gap;return s===void 0&&(s="margin"),`
41
+ .`.concat(pP,` {
42
+ overflow: hidden `).concat(r,`;
43
+ padding-right: `).concat(l,"px ").concat(r,`;
44
+ }
45
+ body[`).concat(ta,`] {
46
+ overflow: hidden `).concat(r,`;
47
+ overscroll-behavior: contain;
48
+ `).concat([t&&"position: relative ".concat(r,";"),s==="margin"&&`
49
+ padding-left: `.concat(i,`px;
50
+ padding-top: `).concat(a,`px;
51
+ padding-right: `).concat(o,`px;
52
+ margin-left:0;
53
+ margin-top:0;
54
+ margin-right: `).concat(l,"px ").concat(r,`;
55
+ `),s==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
56
+ }
57
+
58
+ .`).concat(bc,` {
59
+ right: `).concat(l,"px ").concat(r,`;
60
+ }
61
+
62
+ .`).concat(kc,` {
63
+ margin-right: `).concat(l,"px ").concat(r,`;
64
+ }
65
+
66
+ .`).concat(bc," .").concat(bc,` {
67
+ right: 0 `).concat(r,`;
68
+ }
69
+
70
+ .`).concat(kc," .").concat(kc,` {
71
+ margin-right: 0 `).concat(r,`;
72
+ }
73
+
74
+ body[`).concat(ta,`] {
75
+ `).concat(mP,": ").concat(l,`px;
76
+ }
77
+ `)},oj=function(){var e=parseInt(document.body.getAttribute(ta)||"0",10);return isFinite(e)?e:0},$P=function(){d.useEffect(function(){return document.body.setAttribute(ta,(oj()+1).toString()),function(){var e=oj()-1;e<=0?document.body.removeAttribute(ta):document.body.setAttribute(ta,e.toString())}},[])},OP=function(e){var t=e.noRelative,s=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;$P();var a=d.useMemo(function(){return IP(i)},[i]);return d.createElement(PP,{styles:MP(a,!t,i,s?"":"!important")})},Yh=!1;if(typeof window<"u")try{var Bl=Object.defineProperty({},"passive",{get:function(){return Yh=!0,!0}});window.addEventListener("test",Bl,Bl),window.removeEventListener("test",Bl,Bl)}catch{Yh=!1}var Ai=Yh?{passive:!1}:!1,_P=function(e){return e.tagName==="TEXTAREA"},Rk=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!_P(e)&&s[t]==="visible")},DP=function(e){return Rk(e,"overflowY")},LP=function(e){return Rk(e,"overflowX")},lj=function(e,t){var s=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=Ik(e,r);if(i){var a=Pk(e,r),o=a[1],l=a[2];if(o>l)return!0}r=r.parentNode}while(r&&r!==s.body);return!1},FP=function(e){var t=e.scrollTop,s=e.scrollHeight,r=e.clientHeight;return[t,s,r]},UP=function(e){var t=e.scrollLeft,s=e.scrollWidth,r=e.clientWidth;return[t,s,r]},Ik=function(e,t){return e==="v"?DP(t):LP(t)},Pk=function(e,t){return e==="v"?FP(t):UP(t)},BP=function(e,t){return e==="h"&&t==="rtl"?-1:1},zP=function(e,t,s,r,i){var a=BP(e,window.getComputedStyle(t).direction),o=a*r,l=s.target,c=t.contains(l),u=!1,h=o>0,f=0,p=0;do{if(!l)break;var m=Pk(e,l),j=m[0],w=m[1],b=m[2],v=w-b-a*j;(j||v)&&Ik(e,l)&&(f+=v,p+=j);var x=l.parentNode;l=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(h&&Math.abs(f)<1||!h&&Math.abs(p)<1)&&(u=!0),u},zl=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},cj=function(e){return[e.deltaX,e.deltaY]},uj=function(e){return e&&"current"in e?e.current:e},WP=function(e,t){return e[0]===t[0]&&e[1]===t[1]},HP=function(e){return`
78
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
79
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
80
+ `)},VP=0,Ti=[];function KP(e){var t=d.useRef([]),s=d.useRef([0,0]),r=d.useRef(),i=d.useState(VP++)[0],a=d.useState(Tk)[0],o=d.useRef(e);d.useEffect(function(){o.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var w=hP([e.lockRef.current],(e.shards||[]).map(uj),!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 l=d.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var v=zl(w),x=s.current,y="deltaX"in w?w.deltaX:x[0]-v[0],g="deltaY"in w?w.deltaY:x[1]-v[1],N,k=w.target,S=Math.abs(y)>Math.abs(g)?"h":"v";if("touches"in w&&S==="h"&&k.type==="range")return!1;var C=window.getSelection(),R=C&&C.anchorNode,E=R?R===k||R.contains(k):!1;if(E)return!1;var P=lj(S,k);if(!P)return!0;if(P?N=S:(N=S==="v"?"h":"v",P=lj(S,k)),!P)return!1;if(!r.current&&"changedTouches"in w&&(y||g)&&(r.current=N),!N)return!0;var O=r.current||N;return zP(O,b,w,O==="h"?y:g)},[]),c=d.useCallback(function(w){var b=w;if(!(!Ti.length||Ti[Ti.length-1]!==a)){var v="deltaY"in b?cj(b):zl(b),x=t.current.filter(function(N){return N.name===b.type&&(N.target===b.target||b.target===N.shadowParent)&&WP(N.delta,v)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(o.current.shards||[]).map(uj).filter(Boolean).filter(function(N){return N.contains(b.target)}),g=y.length>0?l(b,y[0]):!o.current.noIsolation;g&&b.cancelable&&b.preventDefault()}}},[]),u=d.useCallback(function(w,b,v,x){var y={name:w,delta:b,target:v,should:x,shadowParent:GP(v)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(g){return g!==y})},1)},[]),h=d.useCallback(function(w){s.current=zl(w),r.current=void 0},[]),f=d.useCallback(function(w){u(w.type,cj(w),w.target,l(w,e.lockRef.current))},[]),p=d.useCallback(function(w){u(w.type,zl(w),w.target,l(w,e.lockRef.current))},[]);d.useEffect(function(){return Ti.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Ai),document.addEventListener("touchmove",c,Ai),document.addEventListener("touchstart",h,Ai),function(){Ti=Ti.filter(function(w){return w!==a}),document.removeEventListener("wheel",c,Ai),document.removeEventListener("touchmove",c,Ai),document.removeEventListener("touchstart",h,Ai)}},[]);var m=e.removeScrollBar,j=e.inert;return d.createElement(d.Fragment,null,j?d.createElement(a,{styles:HP(i)}):null,m?d.createElement(OP,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function GP(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const YP=bP(Ak,KP);var eg=d.forwardRef(function(e,t){return d.createElement(Xu,vs({},e,{ref:t,sideCar:YP}))});eg.classNames=Xu.classNames;var qP=Object.defineProperty,Ge=(e,t)=>qP(e,"name",{value:t,configurable:!0}),QP=["Enter"," "],XP=["ArrowDown","PageUp","Home"],Mk=["ArrowUp","PageDown","End"],JP=[...XP,...Mk],Ju="Menu",[qh,ZP,e2]=Lu(Ju),[xi,$k]=is(Ju,[e2,Vu,Qu]),tg=Vu(),Ok=Qu(),[t2,rl]=xi(Ju),[n2,ng]=xi(Ju),s2=Ge(e=>{const{__scopeMenu:t,open:s=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,l=tg(t),[c,u]=d.useState(null),h=d.useRef(!1),f=ss(a),p=Gu(i);return d.useEffect(()=>{const m=Ge(()=>{h.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},"handleKeyDown"),j=Ge(()=>h.current=!1,"handlePointer");return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),d.useEffect(()=>{if(!s)return;const m=Ge(()=>f(!1),"handleBlur");return window.addEventListener("blur",m),()=>window.removeEventListener("blur",m)},[s,f]),n.jsx(K0,{...l,children:n.jsx(t2,{scope:t,open:s,onOpenChange:f,content:c,onContentChange:u,children:n.jsx(n2,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:p,modal:o,children:r})})})},"Menu"),r2=d.forwardRef(Ge(function(t,s){const{__scopeMenu:r,...i}=t,a=tg(r);return n.jsx(G0,{...a,...i,ref:s})},"MenuAnchor")),_k="MenuPortal",[i2,a2]=xi(_k,{forceMount:void 0}),o2=Ge(e=>{const{__scopeMenu:t,forceMount:s,children:r,container:i}=e,a=rl(_k,t);return n.jsx(i2,{scope:t,forceMount:s,children:n.jsx($r,{present:s||a.open,children:n.jsx(Fm,{asChild:!0,container:i,children:r})})})},"MenuPortal"),wr="MenuContent",[l2,Dk]=xi(wr),c2=d.forwardRef(Ge(function(t,s){const r=a2(wr,t.__scopeMenu),{forceMount:i=r.forceMount,...a}=t,o=rl(wr,t.__scopeMenu),l=ng(wr,t.__scopeMenu);return n.jsx(qh.Provider,{scope:t.__scopeMenu,children:n.jsx($r,{present:i||o.open,children:n.jsx(qh.Slot,{scope:t.__scopeMenu,children:l.modal?n.jsx(u2,{...a,ref:s}):n.jsx(d2,{...a,ref:s})})})})},"MenuContent")),u2=d.forwardRef(Ge(function(t,s){const r=rl(wr,t.__scopeMenu),i=d.useRef(null),a=ut(s,i);return d.useEffect(()=>{const o=i.current;if(o)return Nk(o)},[]),n.jsx(Lk,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Pe(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),d2=d.forwardRef(Ge(function(t,s){const r=rl(wr,t.__scopeMenu);return n.jsx(Lk,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),f2=Nr("MenuContent.ScrollLock"),Lk=d.forwardRef(Ge(function(t,s){const{__scopeMenu:r,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:j,disableOutsideScroll:w,...b}=t,v=rl(wr,r),x=ng(wr,r),y=tg(r),g=Ok(r),N=ZP(r),[k,S]=d.useState(null),C=d.useRef(null),R=ut(s,C,v.onContentChange),E=d.useRef(0),P=d.useRef(""),O=d.useRef(0),U=d.useRef(null),T=d.useRef("right"),M=d.useRef(0),L=w?eg:d.Fragment,K=w?{as:f2,allowPinchZoom:!0}:void 0,D=Ge(F=>{var me,$e;const H=P.current+F,le=N().filter(ne=>!ne.disabled),ie=document.activeElement,ae=(me=le.find(ne=>ne.ref.current===ie))==null?void 0:me.textValue,ge=le.map(ne=>ne.textValue),X=Kk(ge,H,ae),de=($e=le.find(ne=>ne.textValue===X))==null?void 0:$e.ref.current;Ge(function ne(be){P.current=be,window.clearTimeout(E.current),be!==""&&(E.current=window.setTimeout(()=>ne(""),1e3))},"updateSearch")(H),de&&setTimeout(()=>de.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(E.current),[]),Yu();const q=d.useCallback(F=>{var le,ie;return T.current===((le=U.current)==null?void 0:le.side)&&Yk(F,(ie=U.current)==null?void 0:ie.area)},[]);return n.jsx(l2,{scope:r,searchRef:P,onItemEnter:d.useCallback(F=>{q(F)&&F.preventDefault()},[q]),onItemLeave:d.useCallback(F=>{var H;q(F)||((H=C.current)==null||H.focus(),S(null))},[q]),onTriggerLeave:d.useCallback(F=>{q(F)&&F.preventDefault()},[q]),pointerGraceTimerRef:O,onPointerGraceIntentChange:d.useCallback(F=>{U.current=F},[]),children:n.jsx(L,{...K,children:n.jsx(ok,{asChild:!0,trapped:a,onMountAutoFocus:Pe(o,F=>{var H;F.preventDefault(),(H=C.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:n.jsx(Dm,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:j,children:n.jsx(bk,{asChild:!0,...g,dir:x.dir,orientation:"vertical",loop:i,currentTabStopId:k,onCurrentTabStopIdChange:S,onEntryFocus:Pe(u,F=>{x.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(Y0,{role:"menu","aria-orientation":"vertical","data-state":Bk(v.open),"data-radix-menu-content":"",dir:x.dir,...y,...b,ref:R,style:{outline:"none",...b.style},onKeyDown:Pe(b.onKeyDown,F=>{const le=F.target.closest("[data-radix-menu-content]")===F.currentTarget,ie=F.ctrlKey||F.altKey||F.metaKey,ae=F.key.length===1;le&&(F.key==="Tab"&&F.preventDefault(),!ie&&ae&&D(F.key));const ge=C.current;if(F.target!==ge||!JP.includes(F.key))return;F.preventDefault();const de=N().filter(me=>!me.disabled).map(me=>me.ref.current);Mk.includes(F.key)&&de.reverse(),Hk(de)}),onBlur:Pe(t.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(E.current),P.current="")}),onPointerMove:Pe(t.onPointerMove,ou(F=>{const H=F.target,le=M.current!==F.clientX;if(F.currentTarget.contains(H)&&le){const ie=F.clientX>M.current?"right":"left";T.current=ie,M.current=F.clientX}}))})})})})})})},"MenuContentImpl")),Fk=d.forwardRef(Ge(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(ft.div,{role:"group",...i,ref:s})},"MenuGroup")),h2=d.forwardRef(Ge(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(ft.div,{...i,ref:s})},"MenuLabel")),Qh="MenuItem",dj="menu.itemSelect",Uk=d.forwardRef(Ge(function(t,s){const{disabled:r=!1,onSelect:i,...a}=t,o=d.useRef(null),l=ng(Qh,t.__scopeMenu),c=Dk(Qh,t.__scopeMenu),u=ut(s,o),h=d.useRef(!1),f=Ge(()=>{const p=o.current;if(!r&&p){const m=new CustomEvent(dj,{bubbles:!0,cancelable:!0});p.addEventListener(dj,j=>i==null?void 0:i(j),{once:!0}),Fu(p,m),m.defaultPrevented?h.current=!1:l.onClose()}},"handleSelect");return n.jsx(p2,{...a,ref:u,disabled:r,onClick:Pe(t.onClick,f),onPointerDown:p=>{var m;(m=t.onPointerDown)==null||m.call(t,p),h.current=!0},onPointerUp:Pe(t.onPointerUp,p=>{var m;h.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:Pe(t.onKeyDown,p=>{r||p.target!==p.currentTarget||c.searchRef.current!==""&&p.key===" "||QP.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),p2=d.forwardRef(Ge(function(t,s){const{__scopeMenu:r,disabled:i=!1,textValue:a,...o}=t,l=Dk(Qh,r),c=Ok(r),u=d.useRef(null),h=ut(s,u),[f,p]=d.useState(!1),[m,j]=d.useState("");return d.useEffect(()=>{const w=u.current;w&&j((w.textContent??"").trim())},[o.children]),n.jsx(qh.ItemSlot,{scope:r,disabled:i,textValue:a??m,children:n.jsx(kk,{asChild:!0,...c,focusable:!i,children:n.jsx(ft.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:h,onPointerMove:Pe(t.onPointerMove,ou(w=>{i?l.onItemLeave(w):(l.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(t.onPointerLeave,ou(w=>l.onItemLeave(w))),onFocus:Pe(t.onFocus,()=>p(!0)),onBlur:Pe(t.onBlur,()=>p(!1))})})})},"MenuItemImpl")),m2="MenuRadioGroup",[g2,x2]=xi(m2,{value:void 0,onValueChange:Ge(()=>{},"onValueChange")}),v2=d.forwardRef(Ge(function(t,s){const{value:r,onValueChange:i,...a}=t,o=ss(i);return n.jsx(g2,{scope:t.__scopeMenu,value:r,onValueChange:o,children:n.jsx(Fk,{...a,ref:s})})},"MenuRadioGroup")),j2="MenuRadioItem",y2=d.forwardRef(Ge(function(t,s){const{value:r,...i}=t,a=x2(j2,t.__scopeMenu),o=r===a.value;return n.jsx(b2,{scope:t.__scopeMenu,checked:o,children:n.jsx(Uk,{role:"menuitemradio","aria-checked":o,...i,ref:s,"data-state":Wk(o),onSelect:Pe(i.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),w2="MenuItemIndicator",[b2,S5]=xi(w2,{checked:!1}),k2=d.forwardRef(Ge(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(ft.div,{role:"separator","aria-orientation":"horizontal",...i,ref:s})},"MenuSeparator")),S2="MenuSub",[N5,C5]=xi(S2);function Bk(e){return e?"open":"closed"}Ge(Bk,"getOpenState");function zk(e){return e==="indeterminate"}Ge(zk,"isIndeterminate");function Wk(e){return zk(e)?"indeterminate":e?"checked":"unchecked"}Ge(Wk,"getCheckedState");function Hk(e){const t=document.activeElement;for(const s of e)if(s===t||(s.focus(),document.activeElement!==t))return}Ge(Hk,"focusFirst");function Vk(e,t){return e.map((s,r)=>e[(t+r)%e.length])}Ge(Vk,"wrapArray");function Kk(e,t,s){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=s?e.indexOf(s):-1;let o=Vk(e,Math.max(a,0));i.length===1&&(o=o.filter(u=>u!==s));const c=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==s?c:void 0}Ge(Kk,"getNextMatch");function Gk(e,t){const{x:s,y:r}=e;let i=!1;for(let a=0,o=t.length-1;a<t.length;o=a++){const l=t[a],c=t[o],u=l.x,h=l.y,f=c.x,p=c.y;h>r!=p>r&&s<(f-u)*(r-h)/(p-h)+u&&(i=!i)}return i}Ge(Gk,"isPointInPolygon");function Yk(e,t){if(!t)return!1;const s={x:e.clientX,y:e.clientY};return Gk(s,t)}Ge(Yk,"isPointerInGraceArea");function ou(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ge(ou,"whenMouse");var N2=s2,C2=r2,E2=o2,A2=c2,T2=Fk,R2=h2,I2=Uk,P2=v2,M2=y2,$2=k2,O2=Object.defineProperty,As=(e,t)=>O2(e,"name",{value:t,configurable:!0}),sg="DropdownMenu",[_2,E5]=is(sg,[$k]),Ts=$k(),[D2,qk]=_2(sg),L2=As(e=>{const{__scopeDropdownMenu:t,children:s,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:l=!0}=e,c=Ts(t),u=d.useRef(null),[h,f]=Sa({prop:i,defaultProp:a??!1,onChange:o,caller:sg});return n.jsx(D2,{scope:t,triggerId:Bs(),triggerRef:u,contentId:Bs(),open:h,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(p=>!p),[f]),modal:l,children:n.jsx(N2,{...c,open:h,onOpenChange:f,dir:r,modal:l,children:s})})},"DropdownMenu"),F2="DropdownMenuTrigger",U2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,disabled:i=!1,...a}=t,o=qk(F2,r),l=Ts(r),c=ut(s,o.triggerRef);return n.jsx(C2,{asChild:!0,...l,children:n.jsx(ft.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,...a,ref:c,onPointerDown:Pe(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(o.onOpenToggle(),o.open||u.preventDefault())}),onKeyDown:Pe(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&o.onOpenToggle(),u.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),B2=As(e=>{const{__scopeDropdownMenu:t,...s}=e,r=Ts(t);return n.jsx(E2,{...r,...s})},"DropdownMenuPortal"),z2="DropdownMenuContent",W2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=qk(z2,r),o=Ts(r),l=d.useRef(!1);return n.jsx(A2,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...i,ref:s,onCloseAutoFocus:Pe(t.onCloseAutoFocus,c=>{var u;l.current||(u=a.triggerRef.current)==null||u.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:Pe(t.onInteractOutside,c=>{const u=c.detail.originalEvent,h=u.button===0&&u.ctrlKey===!0,f=u.button===2||h;(!a.modal||f)&&(l.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")),H2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Ts(r);return n.jsx(T2,{...a,...i,ref:s})},"DropdownMenuGroup")),V2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Ts(r);return n.jsx(R2,{...a,...i,ref:s})},"DropdownMenuLabel")),K2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Ts(r);return n.jsx(I2,{...a,...i,ref:s})},"DropdownMenuItem")),G2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Ts(r);return n.jsx(P2,{...a,...i,ref:s})},"DropdownMenuRadioGroup")),Y2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Ts(r);return n.jsx(M2,{...a,...i,ref:s})},"DropdownMenuRadioItem")),q2=d.forwardRef(As(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=Ts(r);return n.jsx($2,{...a,...i,ref:s})},"DropdownMenuSeparator")),rg=L2,ig=U2,ag=B2,og=W2,Q2=H2,lg=V2,Sc=K2,X2=G2,J2=Y2,Nc=q2,Z2=Object.defineProperty,Aa=(e,t)=>Z2(e,"name",{value:t,configurable:!0}),cg="Tabs",[eM,A5]=is(cg,[Qu]),Qk=Qu(),[tM,ug]=eM(cg),nM=d.forwardRef(Aa(function(t,s){const{__scopeTabs:r,value:i,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Gu(c),[p,m]=Sa({prop:i,onChange:a,defaultProp:o??"",caller:cg});return n.jsx(tM,{scope:r,baseId:Bs(),value:p,onValueChange:m,orientation:l,dir:f,activationMode:u,children:n.jsx(ft.div,{dir:f,"data-orientation":l,...h,ref:s})})},"Tabs")),sM="TabsList",rM=d.forwardRef(Aa(function(t,s){const{__scopeTabs:r,loop:i=!0,...a}=t,o=ug(sM,r),l=Qk(r);return n.jsx(bk,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:i,children:n.jsx(ft.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})},"TabsList")),iM="TabsTrigger",aM=d.forwardRef(Aa(function(t,s){const{__scopeTabs:r,value:i,disabled:a=!1,...o}=t,l=ug(iM,r),c=Qk(r),u=dg(l.baseId,i),h=fg(l.baseId,i),f=i===l.value;return n.jsx(kk,{asChild:!0,...c,focusable:!a,active:f,children:n.jsx(ft.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...o,ref:s,onMouseDown:Pe(t.onMouseDown,p=>{!a&&p.button===0&&p.ctrlKey===!1?l.onValueChange(i):p.preventDefault()}),onKeyDown:Pe(t.onKeyDown,p=>{a||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&l.onValueChange(i)}),onFocus:Pe(t.onFocus,()=>{const p=l.activationMode!=="manual";!f&&!a&&p&&l.onValueChange(i)})})})},"TabsTrigger")),oM="TabsContent",lM=d.forwardRef(Aa(function(t,s){const{__scopeTabs:r,value:i,forceMount:a,children:o,...l}=t,c=ug(oM,r),u=dg(c.baseId,i),h=fg(c.baseId,i),f=i===c.value,p=d.useRef(f);return d.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),n.jsx($r,{present:a||f,children:({present:m})=>n.jsx(ft.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:h,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:p.current?"0s":void 0},children:m&&o})})},"TabsContent"));function dg(e,t){return`${e}-trigger-${t}`}Aa(dg,"makeTriggerId");function fg(e,t){return`${e}-content-${t}`}Aa(fg,"makeContentId");var cM=nM,uM=rM,dM=aM,fM=lM;function He(e,t){if(!e)return"—";const s=new Date(e);return Number.isNaN(s.getTime())?String(e):new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(s)}function _e(e,t=Date.now()){if(!e)return"";const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.round((s-t)/1e3),i=Math.abs(r),[a,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(a,o)}function hM(e,t=Date.now()){if(!e)return"";const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.abs(Math.round((t-s)/1e3));return r<60?"now":r<3600?`${Math.floor(r/60)} min`:r<86400?`${Math.floor(r/3600)} h`:`${Math.floor(r/86400)} d`}function pM(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 Et(e){return new Intl.NumberFormat("en-US").format(e)}function Xh(e){return[...e.cacheRead?[`cached ${Et(e.cacheRead)}`]:[],...e.cacheWrite?[`cache write ${Et(e.cacheWrite)}`]:[]].join(", ")}function mM(e){const t=Xh(e);return`${Et(e.input)} in${t?` (${t})`:""} / ${Et(e.output)} out`}function bn(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function Bo(e,t=8){return e.length<=t?e:e.slice(0,t)}function Cs(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function fa(e){return e.replace(/<<<[^<>]*>>>/g,"")}function Tt(e,t,s){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?gM(r,s):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${fj(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Et(r):fj(r):String(e)}case"date":return xM(String(e));default:return typeof e=="string"?e:typeof e=="number"?Et(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function gM(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return pM(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function xM(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const s=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short",year:"numeric"}).format(s)}function Jh(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const s=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short"}).format(s)}function fj(e){return String(Math.round(e*100)/100)}function Xk(e,t,s=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,s),i=10**Math.floor(Math.log10(r)),a=[1,2,2.5,5,10].map(l=>l*i).find(l=>l>=r)??i*10,o=[];for(let l=Math.ceil(e/a)*a;l<=t+a/1e3;l+=a)o.push(Math.round(l*1e6)/1e6);return o.filter(l=>l>=e&&l<=t)}function vM({props:e}){if(e.bars.length===0)return n.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(a=>a.value),s=Math.max(0,...t),r=Math.min(0,...t),i=s-r||1;return n.jsx("div",{className:"wb-bars",children:e.bars.map(a=>{const o=Math.abs(a.value)/i;return n.jsxs("div",{className:"wb-bar-row",children:[n.jsx("div",{className:"wb-bar-cat",title:a.category,children:a.category}),n.jsx("div",{className:"wb-bar-track",children:n.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,o*100)}%`,background:a.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),n.jsx("div",{className:"wb-bar-val",children:Tt(a.value,e.unit,e.currency)})]},a.category)})})}const jM=/^(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 )/,yM=/^(… |\.\.\. |\(no change\)$|\)/;function wM(e){return e.replace(/\n$/,"").split(`
81
+ `).map(s=>({kind:bM(s),text:s}))}function bM(e){return e.startsWith("@@")?"hunk":jM.test(e)||yM.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function kM({text:e,marks:t}){const s=e.toLowerCase(),r=[];for(const o of t){const l=o.trim().toLowerCase();if(l!=="")for(let c=s.indexOf(l);c!==-1;c=s.indexOf(l,c+l.length))r.push([c,c+l.length])}if(r.length===0)return n.jsx(n.Fragment,{children:e===""?" ":e});r.sort((o,l)=>o[0]-l[0]);const i=[];let a=0;for(const[o,l]of r)o<a||(o>a&&i.push(n.jsx("span",{children:e.slice(a,o)},`t${a}`)),i.push(n.jsx("mark",{className:"wb-diff-mark",children:e.slice(o,l)},`m${o}`)),a=l);return a<e.length&&i.push(n.jsx("span",{children:e.slice(a)},`t${a}`)),n.jsx(n.Fragment,{children:i})}function lu({text:e,limit:t,more:s,label:r="Diff",marks:i}){const a=wM(e),o=t===void 0?a:a.slice(0,t),l=a.length-o.length;return n.jsxs("div",{className:"wb-diff-wrap",children:[n.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:o.map((c,u)=>n.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?n.jsx(kM,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),l>0?n.jsxs("p",{className:"wb-diff-more",children:[l," more line",l===1?"":"s",s?n.jsxs(n.Fragment,{children:[" · ",n.jsx("button",{type:"button",className:"wb-diff-open",onClick:s.onClick,children:s.label})]}):null]}):null]})}function SM({props:e}){return n.jsxs("div",{children:[e.title?n.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:Tt(t.value,t.unit,null)})]},t.label))}):null,e.diff?n.jsx(lu,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):n.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const zt="#/",br="#/chat",ot="#/agents",mt="#/activity",pn="#/settings",li="#/files",NM="#/welcome";function Cc(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function Wl(e,t={}){const s=new URLSearchParams;t.q&&s.set("q",t.q),t.origin&&s.set("origin",t.origin),t.family&&s.set("family",t.family);const r=s.toString();return`${li}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function CM(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const s=new URLSearchParams(t[2]??""),r={};return s.get("q")&&(r.q=s.get("q")),s.get("origin")&&(r.origin=s.get("origin")),s.get("family")&&(r.family=s.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function Ve(e,t,s){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function EM(e){if(Jk(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const s=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...s?{tab:s}:{}}}catch{return null}}function co(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function Jk(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 lt(e,t,s){return`${ot}/${encodeURIComponent(e)}${t?`/${t}${s?`/${s}`:""}`:""}`}function AM(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 ha(e){return`${mt}/conversations/${encodeURIComponent(e)}`}const TM="#/p";function zo(e,t,s){const r=`${TM}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return s?`${r}/${encodeURIComponent(s)}`:r}function hg(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 RM="p.";function Zu(e,t){return`${pn}/${encodeURIComponent(Zk(e,t))}`}function IM(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const s=decodeURIComponent(t[1]);return{plugin:s,page:t[2]?decodeURIComponent(t[2]):s}}function Zk(e,t){return`${RM}${e}${t===e?"":`.${t}`}`}function Ze(e){return e?`${pn}/${e}`:pn}function PM(e){return`${Ze("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function MM(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}const $M=[{route:zt,label:"Home"},{route:br,label:"Chat"},{route:ot,label:"Agents"},{route:mt,label:"Activity"},{route:li,label:"Files"},{route:pn,label:"Settings"}],OM=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],_M=[{id:"you",label:"Profile",group:"you"},{id:"appearance",label:"Appearance",group:"you"},{id:"notifications",label:"Notifications",group:"you"},{id:"memory",label:"Memory",group:"you"},{id:"proposals",label:"Proposals",group:"you"},{id:"accounts",label:"Model accounts",group:"access"},{id:"computer",label:"Computer & browser",group:"access"},{id:"secrets",label:"Keys and secrets",group:"access"},{id:"connections",label:"Connections",group:"access"},{id:"watchers",label:"Watchers",group:"running"},{id:"backup",label:"Backup",group:"running"},{id:"system",label:"System",group:"running"},{id:"plugins",label:"All plugins",group:"plugins"}];function DM(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const hj=Ze("backup");function LM(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return ha(decodeURIComponent(t[1]));const s=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(s)try{return zo("email","mail",s[1]?decodeURIComponent(s[1]):null)}catch{return zo("email","mail")}return e==="#/settings/email"?Zu("email","settings"):{"#/overview":zt,"#/approvals":zt,"#/events":`${mt}/events`,"#/jobs":`${mt}/jobs`,"#/conversations":mt,"#/missions":`${ot}?tab=missions`,"#/offers":`${ot}?tab=offers`,"#/reminders":`${ot}?tab=reminders`,"#/providers":Ze("accounts"),"#/browser":Ze("computer"),"#/sentinels":Ze("watchers"),"#/settings/sentinels":Ze("watchers")}[e]??null}function eS(e){if(e===""||e==="#"||e===zt)return zt;if(e.startsWith(br))return br;if(e.startsWith(ot))return ot;if(e.startsWith(mt))return mt;if(e.startsWith(li))return li;if(e.startsWith(pn))return pn;const t=hg(e);return t?zo(t.plugin,t.page):zt}const FM="#/chat?group=new";function UM(e){const t=e.replace(/^#\/?/,"").split("?")[0].toLowerCase();if(t==="")return"home";const[s,r]=t.split("/");return!s||!/^[a-z0-9-]+$/.test(s)?null:(s==="settings"||s==="p")&&r&&/^[a-z0-9.-]+$/.test(r)?`${s}/${r}`:s}const pg="front-desk",mg=[{id:pg,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."}],tS=new Set(mg.map(e=>e.id)),pj=e=>tS.has(e);function mj(e,t){const s=t.filter(r=>!tS.has(r));return[...mg.filter(r=>e.has(r.id)).map(r=>r.id),...s.filter((r,i)=>s.indexOf(r)===i)]}function BM(e,t){return e.find(s=>(s.roles??[]).includes(t))}const gj=["coding","finance","mail","research","calendar","files","memory"],zM={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[pg]:"buddi"},WM=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function HM(e){const t=new Set(e.map(s=>s.split(".")[0]??s));for(const[s,r]of WM)if(r.some(i=>t.has(i)))return s;return t.size>0&&[...t].every(s=>s==="memory")?"memory":null}let Zh=null;function VM(e){Zh=e}function il(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const s of e.roles??[]){const r=zM[s];if(r)return{key:r}}const t=HM(e.tools??[]);return t?{key:t}:Zh!==null&&e.id===Zh?{key:"buddi"}:{key:gj[KM(e.id)%gj.length]??"coding"}}function al(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function KM(e){let t=0;for(const s of e)t=(t*31+s.charCodeAt(0))%997;return t}const GM=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function YM(e){const s=e.replace(/\r\n/g,`
82
+ `).split(`
83
+
84
+ `),r=s.pop()??"",i=[];for(const a of s){let o=null,l="message";const c=[];for(const u of a.split(`
85
+ `)){if(u===""||u.startsWith(":"))continue;const h=u.indexOf(":"),f=h===-1?u:u.slice(0,h),p=h===-1?"":u.slice(h+1).replace(/^ /,"");f==="id"?o=p:f==="event"?l=p:f==="data"&&c.push(p)}c.length===0&&l==="message"||i.push({id:o,name:GM.includes(l)?l:"ping",data:qM(c.join(`
86
+ `))})}return{events:i,rest:r}}function qM(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function ed(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),s=e.wait??(c=>new Promise(u=>setTimeout(u,c))),r=e.retryMs??1500;let i=e.lastEventId??null,a=!1,o=null;return(async()=>{var c,u,h,f;for(;!a;){(c=e.onStatus)==null||c.call(e,"connecting"),o=new AbortController;try{const p=await t(e.url,{credentials:"same-origin",signal:o.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!p.ok||!p.body)throw new Error(`stream ${p.status}`);(u=e.onStatus)==null||u.call(e,"open");const m=p.body.getReader(),j=new TextDecoder;let w="";for(;;){const{done:b,value:v}=await m.read();if(b)break;w+=j.decode(v,{stream:!0});const{events:x,rest:y}=YM(w);w=y;for(const g of x)e.onEvent(g),g.id!==null&&(i=g.id);if(a)break}}catch{}if(a)break;(h=e.onStatus)==null||h.call(e,"closed"),await s(r)}(f=e.onStatus)==null||f.call(e,"closed")})(),{close:()=>{a=!0,o==null||o.abort()},lastEventId:()=>i}}const QM="/api/chat/attention/stream";function nS(e,t){const s=(a,o)=>a.name.localeCompare(o.name),r=a=>e.filter(o=>o.anchor===a).sort(s),i=e.filter(a=>a.anchor!=="top"&&a.anchor!=="bottom").sort((a,o)=>a.id===t?o.id===t?0:-1:o.id===t?1:s(a,o));return{top:r("top"),middle:i,bottom:r("bottom")}}function sS(e,t){const s=nS(e,t);return[...s.top,...s.middle,...s.bottom]}function td(e){if(!e)return null;const t=[];return e.approvals>0&&t.push(e.approvals===1?"one approval is waiting for you":`${e.approvals} approvals are waiting for you`),e.question&&t.push("asked you a question and is holding for the answer"),t.length===0?null:t.join(", and ")}function XM(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function JM(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function ZM(){const[e,t]=d.useState(null);return d.useEffect(()=>{let s=!1;const r=()=>{ce("/chat/attention").then(a=>{s||t(a)}).catch(()=>{})};r();const i=ed({url:QM,onEvent:()=>r()});return()=>{s=!0,i.close()}},[]),JM(e)}const nd="maker";function rS(e){return e.filter(t=>t.available&&!t.roles.includes(nd))}function iS(e){return rS(e).length>=2}function e$(e){var t;return((t=e.find(s=>s.roles.includes(nd)))==null?void 0:t.name)??"the agent maker"}const t$="{{default}}";function n$(e,t){return e.split(t$).join(t??"your assistant")}function s$(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(s=>n$(s,t))}function r$(e){var s,r;const t=(s=e==null?void 0:e.intro)==null?void 0:s.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function i$(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 aS(e){var r,i;const t=(r=e.heldBack)==null?void 0:r.message.trim();if(t!==void 0&&t!=="")return`${e.name??"This agent"} is held back. ${t}`;const s=(i=e.unavailableReason)==null?void 0:i.trim();return s&&s!==""?`${e.name??"This agent"} cannot run: ${s}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const a$="Settings → Model accounts",o$="Install it in Settings → Plugins";function ep(e){return e!=null&&e.heldBack?{section:"plugins",label:o$}:{section:"accounts",label:a$}}const l$={home:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),n.jsx("path",{d:"M5.2 8.4v7.4a1 1 0 0 0 1 1h2.6v-4.6h2.4v4.6h2.6a1 1 0 0 0 1-1V8.4"})]})],chat:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M17 10.6a4.9 4.9 0 0 1-4.9 4.9H7.8L3.6 18l.9-3A4.9 4.9 0 0 1 3 11V8.2A4.9 4.9 0 0 1 7.9 3.3h4.2A4.9 4.9 0 0 1 17 8.2Z"}),n.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),n.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),n.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),n.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,n.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[24,1.9,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),20],files:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.5 2.8h5.2L16.5 6.6v8.6a1.2 1.2 0 0 1-1.2 1.2H7.5a1.2 1.2 0 0 1-1.2-1.2V4a1.2 1.2 0 0 1 1.2-1.2z"}),n.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),n.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),n.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),n.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),n.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,n.jsx("path",{d:"M3.2 16.4V8.6M8.4 16.4V3.9M13.6 16.4v-5.8M3.2 16.4h13.6"})],bell:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),n.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),n.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),n.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),n.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),n.jsx("path",{d:"M2.9 10h14.2M10 2.9c3.4 3.7 3.4 10.5 0 14.2-3.4-3.7-3.4-10.5 0-14.2Z"})]})],person:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),n.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],sun:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),n.jsx("path",{d:"M10 2.6v1.6M10 15.8v1.6M2.6 10h1.6M15.8 10h1.6M4.8 4.8l1.1 1.1M14.1 14.1l1.1 1.1M4.8 15.2l1.1-1.1M14.1 5.9l1.1-1.1"})]})],notebook:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5.5 3.2h8.3a1 1 0 0 1 1 1v11.6a1 1 0 0 1-1 1H5.5a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1Z"}),n.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),n.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),n.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],eye:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.4 10S5.2 4.8 10 4.8 17.6 10 17.6 10 14.8 15.2 10 15.2 2.4 10 2.4 10Z"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),n.jsx("path",{d:"M4 7.2v8a1.2 1.2 0 0 0 1.2 1.2h9.6a1.2 1.2 0 0 0 1.2-1.2v-8M8.2 10.4h3.6"})]})],chip:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),n.jsx("path",{d:"M8 2.8v2.6M12 2.8v2.6M8 14.6v2.6M12 14.6v2.6M2.8 8h2.6M2.8 12h2.6M14.6 8h2.6M14.6 12h2.6"})]})],camera:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.6 6.2a1.4 1.4 0 0 1 1.4-1.4h2l1.1-1.6h2.8l1.1 1.6h2a1.4 1.4 0 0 1 1.4 1.4v6.4a1.4 1.4 0 0 1-1.4 1.4H4a1.4 1.4 0 0 1-1.4-1.4z"}),n.jsx("circle",{cx:"8.5",cy:"9.2",r:"2.4"})]})],clip:[17,1.5,n.jsx("path",{d:"M13.2 8 8.4 12.8a3 3 0 0 1-4.2-4.2l5.1-5.1a2 2 0 1 1 2.8 2.8l-5 5"})],mic:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"6.3",y:"2.4",width:"4.4",height:"7.6",rx:"2.2"}),n.jsx("path",{d:"M3.9 8.4a4.6 4.6 0 0 0 9.2 0M8.5 13v2"})]})],speaker:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.8 6.6h2.4l3.4-2.8v9.4l-3.4-2.8H2.8z"}),n.jsx("path",{d:"M11.2 6.2a3.2 3.2 0 0 1 0 4.6M13.2 4.4a5.8 5.8 0 0 1 0 8.2"})]})],send:[16,1.8,n.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],check:[16,1.8,n.jsx("path",{d:"M3.5 8.4 6.6 11.4 12.5 4.8"})],close:[16,1.8,n.jsx("path",{d:"M4.5 4.5l7 7M11.5 4.5l-7 7"})],thought:[13,1.4,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),n.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,n.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,n.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],copy:[16,1.5,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"5.6",y:"5.6",width:"7.6",height:"7.6",rx:"1.4"}),n.jsx("path",{d:"M10.4 5.6V4a1.2 1.2 0 0 0-1.2-1.2H4A1.2 1.2 0 0 0 2.8 4v5.2A1.2 1.2 0 0 0 4 10.4h1.6"})]})],play:[16,1.5,n.jsx("path",{d:"M5.2 3.4v9.2L12.6 8z"})],pause:[16,1.5,n.jsx("path",{d:"M5.6 3.6v8.8M10.4 3.6v8.8"})],stop:[16,1.5,n.jsx("rect",{x:"4.2",y:"4.2",width:"7.6",height:"7.6",rx:"1.2"})],download:[16,1.5,n.jsx("path",{d:"M8 2.8v7.2M4.9 7 8 10.1 11.1 7M3 12.8h10"})],out:[12,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),n.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,n.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,n.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,n.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],"chevron-down":[14,1.4,n.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),n.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),n.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,n.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,n.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,n.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,n.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-document":[16,1.4,n.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,n.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,n.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,n.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 11l3.6-3.4 2.6 2.4 2-1.8 3.4 3M10.6 6.2h.01"})],"shape-preview":[16,1.4,n.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 6h11.6M4.1 4.7h.01M6 4.7h.01"})],"shape-envelope":[16,1.4,n.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],"shape-structured":[16,1.4,n.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function Te({name:e,size:t,className:s,...r}){const[i,a,o,l]=l$[e],c=t??l??i;return n.jsx("svg",{className:s,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:o})}const oS="buddi.rosterCollapsed";function c$(){try{return window.localStorage.getItem(oS)==="1"}catch{return!1}}function u$(e){try{window.localStorage.setItem(oS,e?"1":"0")}catch{}}function lS({agents:e,currentId:t,attention:s,onSelect:r,orientation:i="vertical",lastActivity:a,groups:o=[],currentGroupId:l=null,onSelectGroup:c,onNewGroup:u}){const h=[...e.top,...e.middle,...e.bottom],f=i==="vertical"?"right":"bottom",[p,m]=d.useState(c$),j=w=>n.jsx(d$,{agent:w,active:w.id===t,attention:s.get(w.id),side:f,onSelect:r,lastAt:(a==null?void 0:a.get(w.id))??null},w.id);return n.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&p?"true":void 0,children:[e.top.map(j),e.top.length>0&&e.middle.length>0?n.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!p&&e.middle.length>0?n.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,n.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(j),c&&iS(h)?n.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[n.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),n.jsxs("div",{className:"wb-groups-head",children:[n.jsx("span",{className:"wb-groups-label",children:"Groups"}),u?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"New group",title:"A team of agents in one conversation",onClick:u,children:n.jsx(Te,{name:"plus"})}):null]}),o.map(w=>n.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":w.id===l?"true":void 0,"aria-current":w.id===l?"true":void 0,"aria-label":`${w.name}, ${w.members.length} agents`,onClick:()=>c(w.id),children:[n.jsxs("span",{className:"wb-face-mark wb-group-stack","aria-hidden":"true",children:[w.members.slice(0,3).map(b=>{const v=h.find(x=>x.id===b);return n.jsx(gg,{className:"wb-group-chip",id:b,name:(v==null?void 0:v.name)??"?",face:v,initials:1},b)}),w.members.length>3?n.jsxs("span",{className:"wb-group-chip wb-group-more",children:["+",w.members.length-3]}):null]}),n.jsxs("span",{className:"wb-face-text",children:[n.jsx("span",{className:"wb-face-name",children:w.name}),n.jsx("span",{className:"wb-face-status",children:w.members.map(b=>{var v;return((v=h.find(x=>x.id===b))==null?void 0:v.name)??b}).join(", ")})]})]},w.id))]}):c?n.jsxs("div",{className:"wb-groups","data-testid":"group-rail-hint",children:[n.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),n.jsx("div",{className:"wb-groups-head",children:n.jsx("span",{className:"wb-groups-label",children:"Groups"})}),n.jsxs("p",{className:"wb-groups-hint",children:["A group needs two agents; ",n.jsx("a",{href:ot,children:"add a teammate"}),"."]})]}):null]}),e.bottom.map(j),i==="vertical"?n.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":p?"Show agent names":"Hide agent names","aria-pressed":p,onClick:()=>m(w=>(u$(!w),!w)),children:n.jsx(Te,{name:p?"chevron-right":"chevron-left"})}):null]})}function d$({agent:e,active:t,attention:s,side:r,onSelect:i,lastAt:a=null}){const o=td(s),l=o?xj(o):e.available?a?`Last spoke ${_e(a)}`:e.description:e.unavailableReason??"Cannot run right now",c=XM(s),u=e.unavailableReason??"This agent cannot run on this machine right now.",h=[e.name,e.available?null:"unavailable",o,t?"current":null].filter(f=>f!==null&&f!=="").join(" — ");return n.jsxs(_o,{children:[n.jsx(Do,{asChild:!0,children:n.jsxs("button",{className:"wb-face",...al(il(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":h,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[n.jsx(gg,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),n.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[n.jsxs("span",{className:"wb-face-name",children:[e.name,n.jsxs("span",{className:"wb-face-handle",children:["@",e.handle]})]}),n.jsx("span",{className:"wb-face-status","data-tone":o?"critical":void 0,children:l})]}),c?n.jsx("span",{className:"wb-face-badge","data-kind":c.count===null?"dot":"count","data-testid":`agent-badge-${e.id}`,"aria-hidden":"true",children:c.count===null?"":c.count}):null,e.available?null:n.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:n.jsx(Te,{name:"out"})})]})}),n.jsx(Lo,{children:n.jsxs(Fo,{className:"ui-tip",side:r,sideOffset:8,children:[n.jsx("span",{className:"ui-tip-title",children:e.name}),n.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:u}),o?n.jsx("span",{className:"ui-tip-alert",children:xj(o)}):null]})})]})}function xj(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function f$(e){let t=0;for(const s of e)t=(t*31+s.charCodeAt(0))%997;return t%6+1}const h$="modulepreload",p$=function(e,t){return new URL(e,t).href},vj={},m$=function(t,s,r){let i=Promise.resolve();if(s&&s.length>0){const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=Promise.allSettled(s.map(u=>{if(u=p$(u,r),u in vj)return;vj[u]=!0;const h=u.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(!!r)for(let j=o.length-1;j>=0;j--){const w=o[j];if(w.href===u&&(!h||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${f}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":h$,h||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),h)return new Promise((j,w)=>{m.addEventListener("load",j),m.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${u}`)))})}))}function a(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&a(l.reason);return t().catch(a)})},g$="buddi",x$=["core","coding","finance","garage","mail","maker","playground","research"],_r=e=>`./mascot/${e}.png`,v$=["core"],tp=(e,t)=>v$.includes(e)?`./mascot/anim/${e}-${t}.json`:null,j$=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],y$="Introduce yourself by name and say one thing you can do today.",_={opening:["Hi. I'm buddi. I live on this computer, and I'm about to introduce you to your first assistant.","Nothing you tell me leaves this machine, except what your assistant sends to the AI you pick in a minute."],later:"Set up later",startOver:{link:"Start over",said:e=>`Starting again. What you already connected stays in Settings: ${e}.`,telegram:"Telegram",browser:"the browser"},name:{ask:"First, what should we call you?",placeholder:"Your first name",submit:"That's me"},clock:{ask:(e,t)=>`Nice to meet you, ${e}. I'll set your clock to ${t}, which is what this browser says. Right?`,yes:"Yes",another:"Pick another",label:"Your clock",answer:e=>e},brain:{ask:"Your assistant needs a brain: an AI it thinks with. Which of these do you already have?",cards:{claude:{title:"Claude",line:"I pay for Claude",know:"Uses your Claude plan's monthly Agent SDK credits; after them, an API key."},chatgpt:{title:"ChatGPT",line:"I pay for ChatGPT",know:"Uses your ChatGPT plan through OpenAI's Codex backend. Sign in with a code."},gemini:{title:"Gemini",line:"I have a Google AI key"},key:{title:"A key from Anthropic or OpenAI",line:"I have an API key"},ollama:{title:"Ollama",line:"Free, on this computer"},cloud:{title:"Ollama Cloud, one tap",line:"Free to start, no key"},service:{title:"Another service, or Ollama Cloud with a key",line:"I have an address and a key"}},claude:{start:"Sign in with Claude",open:"Open the Claude sign-in page",paste:"Paste what Claude gave you",finish:"Done",waiting:"Sign in, then paste the code Claude shows you."},chatgpt:{label:"ChatGPT",codeBefore:"Here is your code: ",codeAfter:". Open the link, enter it, and approve buddi on openai.com.",code:"Your code",open:"Open openai.com",again:"Try again",failed:"The sign-in did not finish. Try again."},cloud:{label:"Ollama Cloud",waiting:"Press Connect on the ollama.com page. Sign in there first if it asks. I will notice.",open:"Open the ollama.com page",again:"Try again"},gemini:{label:"Gemini",field:"Your Google AI key",placeholder:"Paste it here",submit:"Use this key",get:"Get a key at aistudio.google.com"},key:{field:"Your key",placeholder:"Paste it here",submit:"Use this key",which:"Not right?",anthropic:"Anthropic",openai:"OpenAI",refused:"That key was refused. Check it and paste it again."},ollama:{found:"Found it, running now",missing:"Install Ollama, then come back",connect:"Use Ollama",download:"Get Ollama",looking:"Looking for it on this computer…"},model:{ask:"Which one should it think with?",label:"The model",submit:"Use this one",retry:"Try again",change:"Think with another"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking Ollama…",cloud:"Asking Ollama Cloud…",claude:"Checking with Claude…",chatgpt:"Asking ChatGPT…",gemini:"Asking Gemini…"},back:"Back",service:{address:"Address",addressPlaceholder:"The address they gave you",key:"Key",submit:"Connect it"},works:e=>`That works. Your assistant will think with ${e}.`,worksOnFlash:e=>`That works. Google's free tier has no Pro allowance, so your assistant will think with ${e}; turn on billing at Google to use Pro.`,refused:e=>e,answer:e=>e},browser:{chrome:"Your assistant will browse with Google Chrome.",chromium:"Your assistant will browse with its own Chromium.",needs:"Your assistant needs a browser of its own to look at websites. I am fetching one now, about 150 MB.",installing:"Fetching the browser…",launching:"Making sure it opens…",installed:"Installed.",skip:"Skip for now",skipped:"Skipped. Settings → Computer & browser can install it whenever you like.",missing:"No browser for your assistant yet. Settings → Computer & browser can install one.",failed:e=>`That did not work: ${e}`,retry:"Try again"},assistant:{ask:"Last thing: your assistant. I've picked a name and a face; change either, or keep them.",name:"Name",face:"A face",mascot:e=>e==="core"?"Buddi Blob":`Buddi Blob, ${e}`,purpose:"What should it help you with?",purposeValue:["You're not a chatbot. You're becoming someone this person can count on.","","Some starting truths:","",`- Help for real. No "Great question", no "I'd be happy to". Do the thing, then say what you did.`,"- Have a view. Prefer things, disagree when you should, say when something is a bad idea. A search engine with manners is not a colleague.","- Look before you ask. Read the file, check what you remember, try it. Come back with an answer and one question at most.","- You are a guest here. You can see messages, files and a calendar. Treat that with care, keep what you learn to yourself, and never lecture.","- Remember what matters. Names, preferences, the things they said once and expect you to keep.","- When you change how you work, say so. This file is yours to grow, and the owner should always know what it says."].join(`
87
+ `),submit:"Introduce us"},restore:{offer:"I have a backup from another buddi",file:"The backup file",passphrase:"Its passphrase",passphraseHint:"Only if it was locked with one.",submit:"Restore",cancel:"Never mind",started:"Right. Give me a couple of minutes.",phases:{stopping:"Putting everything down for a moment.",snapshot:"Keeping a copy of what is here now, just in case.",database:"Bringing back your conversations and everything you told it to remember.",recovery:"Almost there. Nothing will run on its own until you say so.",files:"Bringing back your files.",starting:"Starting back up.",done:"That is everything.","rolled-back":"That did not work, so I put everything back the way it was.",failed:"That did not work."},welcome:e=>`Welcome back, ${e}.`,keys:"A backup never carries keys, so the AI you think with needs its key one more time."},tagline:"Setting up, on this Mac.",taglineElsewhere:"Setting up, on this computer.",handover:{waiting:"One moment.",looking:e=>`${e} is looking around…`,slow:"Still waking up. A brain on this computer takes a minute the first time.",silent:"Your assistant isn't answering. The AI you picked may be down; try again, or pick another brain above.",again:"Pick another brain"},offers:{said:e=>`That was ${e}. You can answer it on the next page. One more thing before that: you can also talk to it from your phone, through Telegram; a code pairs the two.`,paired:e=>`That was ${e}. You can answer it on the next page. Your phone is already paired.`,phone:"Set up Telegram",notNow:"Not now"},done:{said:"You're all set. This conversation carries on in your dashboard.",leaving:"Opening buddi…",ready:"Ready when you are.",open:"Open buddi"},telegram:{how:"Two minutes: open Telegram, message @BotFather, send /newbot, paste the token it gives you here.",field:"The token",submit:"Save it",restart:"Saved. It will be ready the next time buddi starts.",scan:"Scan this with your phone and press Start.",expired:"That code has run out. I can make you another one.",newCode:"Show a new code",paired:"That is your phone, talking to me. You can close this and carry on there."},change:"change"};let Hl=null;const jj=new Map;function w$(){return Hl??(Hl=m$(()=>import("./lottie_light-BCNsQpt8.js").then(e=>e.l),[],import.meta.url).then(e=>e.default)),Hl.catch(()=>{Hl=null}),Hl}function b$(e){let t=jj.get(e);return t||(t=fetch(e).then(s=>s.ok?s.text():null).catch(()=>null),jj.set(e,t)),t}const yj="(prefers-reduced-motion: reduce)";function cS(){const[e,t]=d.useState(()=>typeof window.matchMedia=="function"&&!window.matchMedia(yj).matches);return d.useEffect(()=>{var i;if(typeof window.matchMedia!="function")return;const s=window.matchMedia(yj),r=()=>t(!s.matches);return(i=s.addEventListener)==null||i.call(s,"change",r),()=>{var a;return(a=s.removeEventListener)==null?void 0:a.call(s,"change",r)}},[]),e}function sd({role:e="core",state:t,size:s,still:r,className:i,onStillError:a}){const o=d.useRef(null),l=cS(),[c,u]=d.useState(!1),h=s==="xs"?null:tp(e,t);return d.useEffect(()=>{if(u(!1),!l||!h)return;let f=!1,p=null;return Promise.all([w$(),b$(h)]).then(([m,j])=>{if(f||!j||!o.current)return;const w=m.loadAnimation({container:o.current,renderer:"svg",loop:!0,autoplay:!document.hidden,animationData:JSON.parse(j),rendererSettings:{preserveAspectRatio:"xMidYMid meet"}}),b=()=>{document.hidden?w.pause():w.play()};document.addEventListener("visibilitychange",b),p=()=>{document.removeEventListener("visibilitychange",b),w.destroy()},u(!0)}).catch(()=>{}),()=>{f=!0,p==null||p()}},[l,h]),n.jsx("span",{ref:o,className:i?`ui-blob ${i}`:"ui-blob","data-size":s,"data-playing":c?"true":void 0,"data-testid":"blob","data-state":t,"aria-hidden":"true",children:c?null:n.jsx("img",{src:r??_r(e),alt:"",onError:a})})}async function wj(e){const t=new Image;t.src=e,await t.decode();const s=document.createElement("canvas");s.width=8,s.height=8;const r=s.getContext("2d");return r?(r.fillStyle="#fff",r.fillRect(0,0,8,8),r.drawImage(t,0,0,8,8),Array.from(r.getImageData(0,0,8,8).data)):null}function uS(e,t="core"){const s=cS(),r=e!==null&&k$(e,t),[i,a]=d.useState(!1);return d.useEffect(()=>{if(a(!1),!e||r||!s||!tp(t,"idle"))return;let o=!1;return Promise.all([wj(e),wj(_r(t))]).then(([l,c])=>{if(o||!l||!c||l.length!==c.length)return;const u=l.reduce((h,f,p)=>h+Math.abs(f-c[p]),0)/l.length;a(u<12)}).catch(()=>{}),()=>{o=!0}},[e,r,s,t]),s&&tp(t,"idle")!==null&&(r||i)}function k$(e,t){const s=_r(t);if(e===s)return!0;try{const r=typeof window>"u"?"http://localhost/":window.location.href;return new URL(e,r).href===new URL(s,r).href}catch{return!1}}function gg({className:e,id:t,name:s,face:r,tint:i,size:a,unavailable:o,initials:l=2}){const[c,u]=d.useState(null),h=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,f=r==null?void 0:r.avatar,p=h?"image":f==null?void 0:f.kind,m=t?al(il({id:t,accent:r==null?void 0:r.accent,roles:r==null?void 0:r.roles,tools:r==null?void 0:r.tools})):void 0;return n.jsx("span",{className:e,"data-tint":m?void 0:i,"data-size":a,"data-kind":p,"data-unavailable":o?"true":void 0,...m,"aria-hidden":"true",children:h?n.jsx("img",{src:h,alt:"",onError:()=>u(h)}):(f==null?void 0:f.kind)==="image"?n.jsx("img",{src:f.url,alt:""}):(f==null?void 0:f.kind)==="emoji"?f.value:i$(s).slice(0,l)})}function os({id:e,name:t,size:s,unavailable:r,face:i}){return n.jsx(gg,{className:"ui-avatar",id:e,tint:f$(e),name:t,size:s,unavailable:r,face:i})}function gn({agents:e,id:t,size:s}){const r=e.find(i=>i.id===t);return n.jsx(os,{id:t,name:(r==null?void 0:r.name)??t,size:s,unavailable:r?!r.available:!1,face:r})}const dS=d.createContext(null);function S$({picture:e,children:t}){return n.jsx(dS.Provider,{value:e??null,children:t})}function fS({size:e,anim:t}){const s=d.useContext(dS),[r,i]=d.useState(null),a=uS(t?s:null);return!s||s===r?null:n.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:t&&a?n.jsx(sd,{state:t,still:s,className:"ui-mascot-blob",onStillError:()=>i(s)}):n.jsx("img",{src:s,alt:"",onError:()=>i(s)})})}const hS=d.createContext([]);function Qs({text:e,className:t}){const s=np(e.replace(/\r\n/g,`
88
+ `).split(`
89
+ `));return n.jsx("div",{className:t??"wb-md",children:s.map((r,i)=>n.jsx(sp,{block:r},i))})}const bj=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,kj=/^(#{1,6})\s+(.*?)\s*#*\s*$/,Sj=/^\s*([-*_])(\s*\1){2,}\s*$/,Vl=/^(\s*)([-*+])\s+(.*)$/,Va=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,Kl=/^\s*>\s?(.*)$/,af=/^\s*\|.*\|\s*$/,Nj=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function np(e){const t=[];let s=0;for(;s<e.length;){const r=e[s];if(r.trim()===""){s+=1;continue}const i=bj.exec(r);if(i){const l=i[2],c=[];for(s+=1;s<e.length&&!new RegExp(`^\\s*${l}\\s*$`).test(e[s]);)c.push(e[s]),s+=1;s+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
90
+ `)});continue}const a=kj.exec(r);if(a){t.push({type:"h",level:a[1].length,text:a[2]}),s+=1;continue}if(Sj.test(r)){t.push({type:"hr"}),s+=1;continue}if(Kl.test(r)){const l=[];for(;s<e.length&&Kl.test(e[s]);)l.push(Kl.exec(e[s])[1]),s+=1;t.push({type:"quote",blocks:np(l),raw:l.join(`
91
+ `)});continue}if(af.test(r)&&s+1<e.length&&Nj.test(e[s+1])){const l=lf(r),c=lf(e[s+1]).map(h=>{const f=h.startsWith(":"),p=h.endsWith(":");return f&&p?"center":p?"right":f?"left":null});s+=2;const u=[];for(;s<e.length&&af.test(e[s]);)u.push(lf(e[s])),s+=1;t.push({type:"table",head:l,rows:u,align:c});continue}if(Vl.test(r)||Va.test(r)){const l=Va.exec(r)??Vl.exec(r),c=Va.test(r),u=l[1].length,h=c?Number(l[2]):1,f=[];for(;s<e.length;){const p=c?Va.exec(e[s]):Vl.exec(e[s]);if(!p||p[1].length!==u)break;const m=[p[3]];for(s+=1;s<e.length;){const j=e[s],w=j.trim()!==""&&of(j)>u,b=j.trim()===""&&s+1<e.length&&e[s+1].trim()!==""&&of(e[s+1])>u;if(!w&&!b)break;m.push(j.trim()===""?"":j.slice(Math.min(of(j),u+2))),s+=1}f.push(np(m))}t.push({type:"list",ordered:c,start:h,items:f});continue}const o=[];for(;s<e.length;){const l=e[s];if(l.trim()===""||bj.test(l)||kj.test(l)||Sj.test(l)||Kl.test(l)||Vl.test(l)||Va.test(l)||af.test(l)&&s+1<e.length&&Nj.test(e[s+1]))break;o.push(l.trim()),s+=1}o.length>0&&t.push({type:"p",text:o.join(`
92
+ `)})}return t}function of(e){return e.length-e.trimStart().length}function lf(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let r="";for(let i=0;i<t.length;i+=1){const a=t[i];if(a==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(a==="|"){s.push(r.trim()),r="";continue}r+=a}return s.push(r.trim()),s}function sp({block:e}){switch(e.type){case"p":return n.jsx("p",{children:Jn(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),s=`h${Math.min(t+2,6)}`;return n.jsx(s,{className:"wb-md-h","data-level":t,children:Jn(e.text)})}case"code":return n.jsxs("div",{className:"wb-md-code-frame",children:[n.jsxs("div",{className:"wb-md-code-head",children:[n.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),n.jsx(Cj,{text:e.text,what:"code",always:!0})]}),n.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:n.jsx("code",{children:e.text})})]});case"quote":return n.jsxs("div",{className:"wb-md-copyable",children:[n.jsx("blockquote",{children:e.blocks.map((t,s)=>n.jsx(sp,{block:t},s))}),n.jsx(Cj,{text:e.raw,what:"quote"})]});case"hr":return n.jsx("hr",{});case"list":{const t=e.items.map((s,r)=>n.jsx("li",{children:s.map((i,a)=>i.type==="p"?n.jsx(d.Fragment,{children:Jn(i.text)},a):n.jsx(sp,{block:i},a))},r));return e.ordered?n.jsx("ol",{start:e.start,children:t}):n.jsx("ul",{children:t})}case"table":return n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table wb-md-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.head.map((t,s)=>n.jsx("th",{style:e.align[s]?{textAlign:e.align[s]}:void 0,children:Jn(t)},s))})}),n.jsx("tbody",{children:e.rows.map((t,s)=>n.jsx("tr",{children:t.map((r,i)=>n.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:Jn(r)},i))},s))})]})})}}function Cj({text:e,what:t,always:s=!1}){const[r,i]=d.useState("idle"),a=()=>{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 n.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":s||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:a,children:r==="done"?"Copied":r==="failed"?"Select to copy":n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),n.jsx("path",{d:"M8.5 4.5V3a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4.5a1 1 0 0 0 1 1h1.5"})]})})}function N$({handle:e}){const s=d.useContext(hS).find(r=>r.handle.toLowerCase()===e.toLowerCase());return s?n.jsxs(_o,{children:[n.jsx(Do,{asChild:!0,children:n.jsxs("a",{className:"wb-mention-link",href:Ve(s.id),children:["@",s.handle]})}),n.jsx(Lo,{children:n.jsxs(Fo,{className:"wb-agent-card",sideOffset:6,children:[n.jsx(os,{id:s.id,name:s.name,face:s,unavailable:!s.available}),n.jsxs("span",{className:"wb-agent-card-text",children:[n.jsx("span",{className:"wb-agent-card-name",children:s.name}),n.jsx("span",{className:"wb-agent-card-desc",children:s.description}),n.jsxs("span",{className:"wb-agent-card-meta",children:[s.model,s.available?"":" · unavailable"]})]})]})})]}):n.jsxs(n.Fragment,{children:["@",e]})}const C$=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 Jn(e){const t=[];let s=e,r=0;for(;s!=="";){const i=C$.exec(s);if(!i){t.push(...Ej(s,r));break}i.index>0&&t.push(...Ej(s.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(n.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(n.jsx("strong",{children:Jn(i[3])},r)):i[4]!==void 0?t.push(n.jsx("strong",{children:Jn(i[4])},r)):i[5]!==void 0?t.push(n.jsx("s",{children:Jn(i[5])},r)):i[6]!==void 0?t.push(n.jsx("em",{children:Jn(i[6])},r)):i[7]!==void 0?t.push(n.jsx("em",{children:Jn(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(n.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:Jn(i[8])},r)):i[10]!==void 0?t.push(n.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(n.jsx(N$,{handle:i[11]},r)),s=s.slice(i.index+i[0].length)}return t}function Ej(e,t){return e.split(`
93
+ `).flatMap((r,i)=>i===0?[r]:[n.jsx("br",{},`${t}-br-${i}`),r])}function E$({props:e}){return n.jsxs("div",{children:[e.title?n.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:Tt(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?n.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?n.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:n.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?n.jsx("div",{className:"wb-doc",children:n.jsx(Qs,{text:e.text})}):n.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}function Se(e,t){if(t===""||t==="$")return e;let s=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,a="",o=""]=i;if(a!==""){if(s===null||typeof s!="object")return;s=s[a]}for(const l of o.match(/\d+/g)??[]){if(!Array.isArray(s))return;s=s[Number(l)]}if(s===void 0)return}return s}function Re(e,t){if(t)return"const"in t?t.const:Se(e,t.path)}function Wn(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 tt(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Jr(e){return Array.isArray(e)?e:[]}function A$(e,t){const s=Jr(Se(e,t.points)).map(i=>{const a=Wn(Se(i,t.y)),o=tt(Se(i,t.x));return a===null||o===null?null:{x:o,y:a}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const a=Wn(Re(e,i.value));return a===null?null:{value:a,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:s,unit:t.unit??"number",currency:tt(Re(e,t.currency)),label:tt(Re(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:Wn(Re(e,t.shadeBelow)),events:T$(e,t)}}function T$(e,t){const s=t.events;if(!s)return[];const r=[],i=(a,o)=>{const l=tt(Se(a,s.label));if(l===null)return;const c=tt(Se(a,s.at))??o;c!==null&&r.push({at:c,label:l,amount:s.amount?Wn(Se(a,s.amount)):null})};if(s.parent){for(const a of Jr(Se(e,t.points))){const o=tt(Se(a,t.x));for(const l of Jr(Se(a,s.parent)))i(l,o)}return r}for(const a of Jr(Se(e,s.path??t.points)))i(a,null);return r}function R$(e,t){const s=(t.columns??[]).map(l=>({key:l.key,label:l.label,type:l.type??"text"})),r=l=>(t.columns??[]).map(c=>{const u=Se(l,c.key);let h=null;if(c.bar){const f=Wn(Re(l,c.bar.max))??Wn(Re(e,c.bar.max)),p=Wn(u);if(f!==null&&f>0&&p!==null){const m=Math.max(0,Math.min(1,p/f));h={fraction:m,tone:P$(m*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:tt(Re(l,c.currency))??tt(Re(e,c.currency)),bar:h}}),i=Jr(Se(e,t.rows)),a=t.groupBy?I$(i,t.groupBy,r):[{label:null,rows:i.map(r)}],o=(t.summary??[]).map(l=>({label:l.label,value:Re(e,l.value),unit:l.unit??"text",currency:tt(Re(e,l.currency)),tone:l.tone??"neutral"}));return{columns:s,groups:a,summary:o,empty:t.empty??"Nothing to show."}}function I$(e,t,s){const r=new Map;for(const i of e){const a=String(Se(i,t.key)??""),o=r.get(a);o?o.push(i):r.set(a,[i])}return[...r.entries()].map(([i,a])=>{var o;return{label:((o=t.labels)==null?void 0:o[i])??i,rows:a.map(s)}})}function P$(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,a)=>a.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function M$(e,t){return{bars:Jr(Se(e,t.bars)).map(r=>{const i=Wn(Se(r,t.value)),a=tt(Se(r,t.category));return i===null||a===null?null:{category:a,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:tt(Re(e,t.currency))}}function $$(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:Re(e,r.value),unit:r.unit??"text",currency:tt(Re(e,r.currency)),tone:r.tone??"neutral"}))};const s=Se(e,t.from??"$");return s===null||typeof s!="object"||Array.isArray(s)?{pairs:[]}:{pairs:Object.entries(s).map(([r,i])=>({label:on(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}function O$(e,t){const s=tt(Re(e,t.kind)),r=s==="image"||s==="pdf"?s:"text",i=t.src?tt(Se(e,t.src)):null;return{kind:r,text:t.text?tt(Se(e,t.text)):null,src:i&&mS(i)?i:null,title:tt(Re(e,t.title)),metadata:(t.metadata??[]).map(a=>({label:a.label,value:Re(e,a.value),unit:a.unit??"text"}))}}function _$(e,t){const s=t.diff?Se(e,t.diff):void 0;return{diff:typeof s=="string"&&s.trim()!==""?s:null,title:tt(Re(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:Re(e,r.value),unit:r.unit??"text"}))}}function D$(e,t){const s=t.output?Se(e,t.output):void 0,r=o=>{const l=o?Se(e,o):void 0;return typeof l=="number"&&Number.isInteger(l)?l:null},i=r(t.omittedBytes),a=t.elapsedMs?Se(e,t.elapsedMs):void 0;return{command:tt(Re(e,t.command)),output:typeof s=="string"?s:null,exitCode:r(t.exitCode),elapsedMs:typeof a=="number"&&Number.isFinite(a)&&a>=0?a:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(o=>({label:o.label,value:Re(e,o.value),unit:o.unit??"text"}))}}const L$=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function pS(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&L$.test(t)?t.toLowerCase():null}function F$(e,t){return{artifactId:t.src?pS(Se(e,t.src)):null,title:tt(Re(e,t.title)),caption:tt(Re(e,t.caption)),...t.captionLabel?{captionLabel:tt(Re(e,t.captionLabel))}:{}}}function Aj(e){if(!mS(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const s=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return s?{plugin:s[1],name:s[2]}:null}function U$(e,t){const s=t.src?tt(Se(e,t.src)):null,r=t.port?Se(e,t.port):null,i=t.awaiting?tt(Se(e,t.awaiting)):null;return{target:s?Aj(s):null,title:tt(Re(e,t.title)),output:t.output?tt(Se(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?Aj(i):null,reloadsItself:t.reloadsItself?Se(e,t.reloadsItself)===!0:!1,ports:t.ports?B$(Se(e,t.ports)):[]}}function B$(e){const t=Jr(e).filter(s=>typeof s=="number"&&Number.isInteger(s)&&s>0&&s<=65535);return[...new Set(t)].sort((s,r)=>s-r)}function mS(e){return e.startsWith("/")&&!e.startsWith("//")}function on(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function gS(e,t){const s=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:A$(t,s)};case"table":return{renderer:"table",props:R$(t,s)};case"bars":return{renderer:"bars",props:M$(t,s)};case"keyvalue":return{renderer:"keyvalue",props:$$(t,s)};case"document":return{renderer:"document",props:O$(t,s)};case"diff":return{renderer:"diff",props:_$(t,s)};case"terminal":return{renderer:"terminal",props:D$(t,s)};case"image":return{renderer:"image",props:F$(t,s)};case"preview":return{renderer:"preview",props:U$(t,s)};default:return{renderer:"structured",props:{value:t}}}}var z$=Object.defineProperty,ls=(e,t)=>z$(e,"name",{value:t,configurable:!0}),xg="Dialog",[xS,T5]=is(xg),[W$,nr]=xS(xg),vS=ls(e=>{const{__scopeDialog:t,children:s,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,l=d.useRef(null),c=d.useRef(null),[u,h]=Sa({prop:r,defaultProp:i??!1,onChange:a,caller:xg}),[f,p]=d.useState(0),[m,j]=d.useState(0);return n.jsx(W$,{scope:t,triggerRef:l,contentRef:c,contentId:Bs(),titleId:Bs(),descriptionId:Bs(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:j,open:u,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(w=>!w),[h]),modal:o,children:s})},"Dialog"),jS="DialogPortal",[H$,yS]=xS(jS,{forceMount:void 0}),wS=ls(e=>{const{__scopeDialog:t,forceMount:s,children:r,container:i}=e,a=nr(jS,t);return n.jsx(H$,{scope:t,forceMount:s,children:d.Children.map(r,o=>n.jsx($r,{present:s||a.open,children:n.jsx(Fm,{asChild:!0,container:i,children:o})}))})},"DialogPortal"),rp="DialogOverlay",V$=d.forwardRef(ls(function(t,s){const r=yS(rp,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,o=nr(rp,t.__scopeDialog);return o.modal?n.jsx($r,{present:i||o.open,children:n.jsx(G$,{...a,ref:s})}):null},"DialogOverlay")),K$=Nr("DialogOverlay.RemoveScroll"),G$=d.forwardRef(ls(function(t,s){const{__scopeDialog:r,...i}=t,a=nr(rp,r),o=d0(),l=ut(s,o);return n.jsx(eg,{as:K$,allowPinchZoom:!0,shards:[a.contentRef],children:n.jsx(ft.div,{"data-state":vg(a.open),...i,ref:l,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),Wo="DialogContent",bS=d.forwardRef(ls(function(t,s){const r=yS(Wo,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,o=nr(Wo,t.__scopeDialog);return n.jsx($r,{present:i||o.open,children:o.modal?n.jsx(Y$,{...a,ref:s}):n.jsx(q$,{...a,ref:s})})},"DialogContent")),Y$=d.forwardRef(ls(function(t,s){const r=nr(Wo,t.__scopeDialog),i=d.useRef(null),a=ut(s,r.contentRef,i);return d.useEffect(()=>{const o=i.current;if(o)return Nk(o)},[]),n.jsx(kS,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:Pe(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Pe(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&o.preventDefault()}),onFocusOutside:Pe(t.onFocusOutside,o=>o.preventDefault())})},"DialogContentModal")),q$=d.forwardRef(ls(function(t,s){const r=nr(Wo,t.__scopeDialog),i=d.useRef(!1),a=d.useRef(!1);return n.jsx(kS,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,c;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),o.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:o=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})},"DialogContentNonModal")),kS=d.forwardRef(ls(function(t,s){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,c=nr(Wo,r);return Yu(),n.jsx(n.Fragment,{children:n.jsx(ok,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:o,children:n.jsx(Dm,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":vg(c.open),...l,ref:s,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),Q$="DialogTitle",SS=d.forwardRef(ls(function(t,s){const{__scopeDialog:r,...i}=t,a=nr(Q$,r),{setTitleCount:o}=a;return yn(()=>(o(l=>l+1),()=>o(l=>l-1)),[o]),n.jsx(ft.h2,{id:a.titleId,...i,ref:s})},"DialogTitle")),X$="DialogClose",NS=d.forwardRef(ls(function(t,s){const{__scopeDialog:r,...i}=t,a=nr(X$,r);return n.jsx(ft.button,{type:"button",...i,ref:s,onClick:Pe(t.onClick,()=>a.onOpenChange(!1))})},"DialogClose"));function vg(e){return e?"open":"closed"}ls(vg,"getState");const J$=5;function re(e,t,s){const[r,i]=d.useState(void 0),[a,o]=d.useState(null),[l,c]=d.useState(!0),[u,h]=d.useState(0),[f,p]=d.useState(0),m=d.useRef(e);return m.current=e,d.useEffect(()=>{let j=!1;return c(!0),m.current().then(w=>{j||(i(w),o(null),p(0))}).catch(w=>{j||(o(w instanceof oe?w.message:String(w)),p(b=>b+1))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[...t,u]),d.useEffect(()=>{if(!s||f>=J$)return;const j=window.setTimeout(()=>h(w=>w+1),s*2**f);return()=>window.clearTimeout(j)},[s,f,u]),{data:r,error:a,loading:l,reload:()=>{p(0),h(j=>j+1)}}}const CS={width:480,height:160,top:10,right:10,bottom:22,left:40};function Z$({xs:e,series:t,type:s="line",target:r=null}){const i=CS,a=i.width-i.left-i.right,o=i.height-i.top-i.bottom,l=t.flatMap(y=>y.values.filter(g=>g!==null&&Number.isFinite(g)));r!==null&&Number.isFinite(r)&&l.push(r),s==="bar"&&l.push(0);let c=l.length>0?Math.min(...l):0,u=l.length>0?Math.max(...l):1;if(c===u)c-=1,u+=1;else if(s==="line"){const y=(u-c)*.08;c-=y,u+=y}const h=y=>Ri(i.top+o-(y-c)/(u-c)*o),f=e.length,p=f>0?a/f:a,m=y=>Ri(s==="bar"?i.left+p*(y+.5):i.left+(f<=1?a/2:y/(f-1)*a)),j=s==="line"?t.map(y=>{let g="M";const N=[];return y.values.forEach((k,S)=>{if(k===null||!Number.isFinite(k)){g="M";return}N.push(`${g}${m(S)},${h(k)}`),g="L"}),N.join(" ")}):[],w=[];if(s==="bar"&&f>0){const y=p*.7,g=y/Math.max(1,t.length),N=h(0);t.forEach((k,S)=>{k.values.forEach((C,R)=>{if(C===null||!Number.isFinite(C))return;const E=h(C);w.push({series:S,index:R,x:Ri(i.left+p*R+(p-y)/2+g*S),y:Math.min(E,N),width:Ri(g),height:Ri(Math.abs(N-E))})})})}const v=(l.length>0?Xk(Math.min(...l),Math.max(...l),2):[]).map(y=>({value:y,y:h(y)})),x=f===0?[]:f===1?[0]:f<5?[0,f-1]:[0,Math.floor((f-1)/2),f-1];return{lines:j,bars:w,targetY:r!==null&&Number.isFinite(r)?h(r):null,ticks:v,xLabels:x.map(y=>({index:y,x:m(y)}))}}function eO(e){const t=e.formatX??(l=>l),s=e.formatY??(l=>String(l)),r=e.xs.length;if(r===0)return`${e.label??"Chart"}: nothing recorded yet.`;const i=r===1?`on ${t(e.xs[0])}`:`from ${t(e.xs[0])} to ${t(e.xs[r-1])}`,a=e.series.map(l=>{const c=l.values.filter(h=>h!==null&&Number.isFinite(h));if(c.length===0)return`${l.label}: no values`;const u=c[c.length-1];return`${l.label}: latest ${s(u)}, lowest ${s(Math.min(...c))}, highest ${s(Math.max(...c))}`}),o=e.target!==null&&e.target!==void 0&&Number.isFinite(e.target)?` Target ${s(e.target)}.`:"";return`${e.label??"Chart"}, ${r} ${r===1?"point":"points"} ${i}. ${a.join("; ")}.${o}`}function tO({xs:e,series:t,type:s="line",target:r=null,label:i,formatX:a=l=>l,formatY:o=l=>String(l)}){const l=CS,c=Z$({xs:e,series:t,type:s,target:r}),u=eO({xs:e,series:t,target:r,...i?{label:i}:{},formatX:a,formatY:o});return n.jsxs("figure",{className:"ui-chart","data-type":s,children:[n.jsxs("svg",{viewBox:`0 0 ${l.width} ${l.height}`,"aria-hidden":"true",focusable:"false","data-testid":"chart-svg",children:[c.ticks.map(h=>n.jsxs("g",{children:[n.jsx("line",{className:"ui-chart-grid",x1:l.left,x2:l.width-l.right,y1:h.y,y2:h.y}),n.jsx("text",{x:l.left-6,y:h.y,textAnchor:"end",dominantBaseline:"middle",children:o(h.value)})]},h.value)),n.jsx("line",{className:"ui-chart-axis",x1:l.left,x2:l.width-l.right,y1:l.height-l.bottom,y2:l.height-l.bottom}),c.bars.map(h=>n.jsx("rect",{className:"ui-chart-bar","data-series":h.series,x:h.x,y:h.y,width:h.width,height:h.height},`${h.series}-${h.index}`)),c.lines.map((h,f)=>h?n.jsx("path",{className:"ui-chart-line","data-series":f,d:h},f):null),c.targetY!==null?n.jsx("line",{className:"ui-chart-target","data-testid":"chart-target",x1:l.left,x2:l.width-l.right,y1:c.targetY,y2:c.targetY}):null,c.xLabels.map(h=>n.jsx("text",{x:h.x,y:l.height-6,textAnchor:c.xLabels.length>1&&h.index===0?"start":h.index===e.length-1&&e.length>1?"end":"middle",children:a(e[h.index])},h.index))]}),n.jsx("figcaption",{className:"sr-only",children:u}),t.length>1?n.jsx("ul",{className:"ui-chart-legend","aria-hidden":"true",children:t.map((h,f)=>n.jsx("li",{"data-series":f,children:h.label},h.label))}):null]})}function Ri(e){return Math.round(e*10)/10}function vi(...e){return e.filter(Boolean).join(" ")}function I({variant:e,size:t,className:s,type:r="button",...i}){return n.jsx("button",{type:r,className:vi("ui-btn",s),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function Zt({variant:e,size:t,className:s,...r}){return n.jsx("a",{className:vi("ui-btn",s),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function Q({children:e,align:t,valign:s,className:r}){return n.jsx("div",{className:vi("ui-toolbar",r),"data-align":t,"data-valign":s,children:e})}function Es(){return n.jsx("span",{className:"ui-toolbar-spacer"})}function J({label:e,hint:t,inline:s,grow:r,wide:i,group:a,action:o,after:l,children:c}){const u=d.useId();return n.jsxs("div",{className:"ui-field","data-inline":s?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[o?n.jsxs("div",{className:"ui-field-row",children:[n.jsxs("label",{className:"ui-field-control",children:[n.jsx("span",{className:"ui-field-label",children:e}),c]}),o]}):a?n.jsxs("div",{className:"ui-field-control",role:"group","aria-labelledby":u,children:[n.jsx("span",{className:"ui-field-label",id:u,children:e}),c]}):n.jsxs("label",{className:"ui-field-control",children:[n.jsx("span",{className:"ui-field-label",children:e}),c]}),t?n.jsx("span",{className:"ui-field-hint",children:t}):null,l]})}function Xs({children:e,dense:t,columns:s}){return n.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,"data-columns":s===3?"3":void 0,children:e})}function ye({tone:e,mono:t,dot:s,children:r,className:i,title:a}){return n.jsxs("span",{className:vi("ui-pill",t&&"mono",i),"data-tone":e,title:a,children:[s?n.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function Zr({children:e}){return n.jsx("span",{className:"ui-tag",children:e})}function rd({state:e}){const t=e==="succeeded"||e==="approved"||e==="fired"||e==="running"||e==="leased"?"good":e==="failed"||e==="rejected"||e==="unknown"||e==="error"||e==="refused"?"critical":e==="pending"||e==="suspended"||e==="expired"||e==="paused"?"warning":void 0;return n.jsx(ye,{tone:t,children:e})}function W({tone:e,title:t,children:s,role:r}){return n.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?n.jsx("div",{className:"ui-notice-title",children:t}):null,s]})}function se({message:e}){return e?n.jsx(W,{tone:"critical",role:"alert",children:e}):null}function ue({mascot:e,warm:t,title:s,action:r,children:i}){return t||s?n.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[s?n.jsx("div",{className:"ui-empty-title",children:s}):null,n.jsx("div",{children:i}),r]}):e?n.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[n.jsx(fS,{size:"sm"}),n.jsx("p",{children:i})]}):n.jsx("p",{className:"ui-empty",children:i})}function Rt({icon:e,title:t,action:s,children:r}){return n.jsxs("div",{className:"ui-empty-state",children:[e?n.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?n.jsx(Te,{name:e}):e}):null,n.jsx("div",{className:"ui-empty-state-title",children:t}),r?n.jsx("p",{className:"ui-empty-state-line",children:r}):null,s?n.jsx("div",{className:"ui-empty-state-action",children:s}):null]})}function nO({children:e}){return n.jsx("div",{className:"ui-page",children:e})}function jg({title:e,lede:t,actions:s,before:r}){return n.jsxs("header",{className:"ui-page-head",children:[n.jsxs("div",{className:"ui-page-head-row",children:[n.jsxs("h2",{className:"ui-page-title",children:[r,n.jsx("span",{children:e})]}),s?n.jsx("div",{className:"ui-page-actions",children:s}):null]}),t?n.jsx("p",{className:"ui-page-lede",children:t}):null]})}function fn({embedded:e,title:t,lede:s,actions:r,children:i}){return e?n.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?n.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):n.jsxs(nO,{children:[n.jsx(jg,{title:t,lede:s,actions:r}),i]})}function Y({title:e,aside:t,actions:s,panel:r,flush:i,foot:a,children:o}){const l=e||t||s?n.jsxs("div",{className:"ui-section-head",children:[e?n.jsx("h3",{className:"ui-section-title",children:e}):n.jsx("span",{}),t||s?n.jsxs("div",{className:"ui-section-side",children:[t?n.jsx("span",{className:"ui-section-aside",children:t}):null,s?n.jsx("div",{className:"ui-section-actions",children:s}):null]}):null]}):null;return n.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[l,r?n.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[o,a?n.jsx("div",{className:"ui-panel-foot",children:a}):null]}):n.jsxs(n.Fragment,{children:[o,a?n.jsx("div",{className:"ui-toolbar","data-align":"end",children:a}):null]})]})}function vt({title:e,tool:t,actions:s,flush:r,children:i}){return n.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||s?n.jsxs("header",{className:"ui-panel-head",children:[e?n.jsx("h3",{className:"ui-panel-title",children:e}):n.jsx("span",{}),t?n.jsx("span",{className:"ui-panel-tool",children:t}):null,s?n.jsx("div",{className:"ui-panel-actions",children:s}):null]}):null,i]})}function Kn({tone:e,title:t,meta:s,actions:r,children:i,foot:a,as:o="div"}){return n.jsxs(o,{className:"ui-card","data-tone":e,children:[t||s||r?n.jsxs("div",{className:"ui-card-head",children:[t?n.jsx("h3",{className:"ui-card-title",children:t}):null,s,r?n.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,a?n.jsx("div",{className:"ui-card-foot",children:a}):null]})}function V({gap:e,divided:t,children:s}){return n.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:s})}function sO({children:e}){return n.jsx("div",{className:"ui-row",children:e})}function id({inline:e,children:t}){return n.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function ys({label:e,value:t,note:s,tone:r,size:i}){return n.jsxs("div",{className:"ui-stat",children:[n.jsx("div",{className:"ui-stat-k",children:e}),n.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),s?n.jsx("div",{className:"ui-stat-n",children:s}):null]})}function Wt({items:e}){return n.jsx("dl",{className:"ui-kv",children:e.map((t,s)=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:t.value})]},t.key??s))})}function kn({children:e}){return n.jsx("div",{className:"ui-table-wrap",children:n.jsx("table",{className:"ui-table",children:e})})}function ES({value:e,label:t}){const s=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return n.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s,"aria-valuetext":`${s}%`,children:n.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${s}%`}})})}function bt({children:e,label:t}){return n.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function It({summary:e,boxed:t,open:s,className:r,onToggle:i,children:a}){return n.jsxs("details",{className:vi("ui-details",r),"data-boxed":t?"true":void 0,open:s,onToggle:i?o=>i(o.currentTarget.open):void 0,children:[n.jsx("summary",{children:e}),a]})}function en({title:e,onClose:t,size:s,children:r}){return n.jsx(vS,{open:!0,onOpenChange:i=>{i||t()},children:n.jsxs(wS,{children:[n.jsx(V$,{className:"ui-sheet-overlay"}),n.jsxs(bS,{className:"ui-sheet","data-size":s,"aria-describedby":void 0,children:[n.jsxs("div",{className:"ui-sheet-head",children:[n.jsx(SS,{className:"ui-sheet-title",children:e}),n.jsx(NS,{asChild:!0,children:n.jsx(I,{size:"sm",children:"Close"})})]}),r]})]})})}function rO({title:e,actions:t,onClose:s,onCloseAutoFocus:r,onOpenAutoFocus:i,label:a,children:o}){return n.jsx(vS,{open:!0,modal:!1,onOpenChange:l=>{l||s()},children:n.jsx(wS,{children:n.jsxs(bS,{className:"ui-dock","aria-describedby":void 0,...a?{"aria-label":a}:{},onInteractOutside:l=>l.preventDefault(),...r?{onCloseAutoFocus:r}:{},...i?{onOpenAutoFocus:i}:{},children:[n.jsxs("div",{className:"ui-dock-head",children:[n.jsx(SS,{className:"ui-dock-title",children:e}),n.jsxs("div",{className:"ui-dock-actions",children:[t,n.jsx(NS,{asChild:!0,children:n.jsx(I,{size:"sm",variant:"ghost",children:"Close"})})]})]}),n.jsx("div",{className:"ui-dock-body",children:o})]})})})}function ad({level:e,label:t,children:s}){return n.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:s})}function od({href:e,active:t,count:s,onClick:r,children:i}){return n.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,s?n.jsx("span",{className:"ui-count",children:s}):null]})}function uo({label:e,options:t,value:s,onChange:r}){return n.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>n.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===s,onClick:()=>r(i.value),children:i.label},i.value))})}function Xt({children:e}){return n.jsx("div",{className:"ui-list",children:e})}function cn({href:e,onClick:t,lead:s,title:r,sub:i,side:a}){const o=n.jsxs(n.Fragment,{children:[s,n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:r}),i?n.jsx("span",{className:"ui-list-sub",children:i}):null]}),a?n.jsx("span",{className:"ui-list-side",children:a}):null]});return e?n.jsx("a",{className:"ui-list-row",href:e,onClick:t?l=>{l.preventDefault(),t()}:void 0,children:o}):n.jsx("div",{className:"ui-list-row",children:o})}function AS({href:e,onClick:t,current:s,lead:r,title:i,meta:a,sub:o,snippet:l,side:c}){return n.jsxs("a",{className:"ui-pick",href:e,"aria-current":s?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?n.jsx("span",{className:"ui-pick-lead",children:r}):null,n.jsxs("span",{className:"ui-pick-main",children:[n.jsxs("span",{className:"ui-pick-top",children:[n.jsx("span",{className:"ui-pick-title",children:i}),a?n.jsx("span",{className:"ui-pick-meta",children:a}):null]}),o||c?n.jsxs("span",{className:"ui-pick-line",children:[o?n.jsx("span",{className:"ui-pick-sub",children:o}):null,c?n.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,l?n.jsx("span",{className:"ui-pick-snippet",children:l}):null]})]})}function TS({list:e,detail:t,empty:s,label:r,className:i}){return n.jsxs("div",{className:vi("ui-split",i),"data-open":t?"true":void 0,children:[n.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),n.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??n.jsx("p",{className:"ui-empty ui-split-empty",children:s})})]})}function cu({children:e,onRemove:t,label:s,disabled:r}){return n.jsxs("span",{className:"ui-chip",children:[e,n.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${s}`,onClick:t,disabled:r,children:"×"})]})}const iO=8;function aO({label:e,options:t,value:s,onChange:r,max:i,disabled:a,id:o}){const[l,c]=d.useState(!1),[u,h]=d.useState(""),[f,p]=d.useState(0),m=d.useRef(null),j=d.useRef(null),w=d.useRef(null),b=d.useRef(null),v=d.useId(),x=T=>{var M;return((M=t.find(L=>L.value===T))==null?void 0:M.label)??T},y=i!==void 0&&s.length>=i,g=t.filter(T=>!s.includes(T.value)),N=t.length>iO,k=u.trim().toLowerCase(),S=k===""?g:g.filter(T=>T.label.toLowerCase().includes(k)),C=Math.min(f,Math.max(0,S.length-1)),R=T=>{var M;c(!1),h(""),p(0),T&&((M=j.current)==null||M.focus())};d.useEffect(()=>{var M;if(!l)return;(M=N?w.current:b.current)==null||M.focus();const T=L=>{m.current&&!m.current.contains(L.target)&&R(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[l,N]);const E=T=>{const M=[...s,T];r(M),h(""),p(0);const L=i!==void 0&&M.length>=i;(L||M.length>=t.length)&&R(!L)},P=T=>{if(T.key==="Escape")T.preventDefault(),R(!0);else if(T.key==="ArrowDown")T.preventDefault(),p(S.length===0?0:(C+1)%S.length);else if(T.key==="ArrowUp")T.preventDefault(),p(S.length===0?0:(C-1+S.length)%S.length);else if(T.key==="Enter"){T.preventDefault();const M=S[C];M&&E(M.value)}else T.key==="Backspace"&&u===""&&s.length>0&&(T.preventDefault(),r(s.slice(0,-1)))},O=T=>`${v}-${T}`,U=l&&S.length>0?O(C):void 0;return n.jsxs("div",{className:"ui-chippicker",ref:m,id:o,children:[s.map(T=>n.jsx(cu,{label:x(T),disabled:a,onRemove:()=>r(s.filter(M=>M!==T)),children:x(T)},T)),n.jsxs("div",{className:"ui-chippicker-add",children:[n.jsx("button",{ref:j,type:"button",className:"ui-btn","data-size":"sm","data-variant":"ghost","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":l?v:void 0,disabled:a||y||g.length===0,onClick:()=>l?R(!1):c(!0),children:"Add…"}),l?n.jsxs("div",{className:"ui-menu ui-chippicker-menu",onKeyDown:P,children:[N?n.jsx("input",{ref:w,type:"search",className:"ui-chippicker-filter","aria-label":`Filter ${e}`,"aria-controls":v,"aria-activedescendant":U,value:u,onChange:T=>{h(T.target.value),p(0)}}):null,n.jsxs("div",{ref:b,id:v,role:"listbox","aria-multiselectable":"true","aria-label":e,"aria-activedescendant":N?void 0:U,tabIndex:N?-1:0,className:"ui-chippicker-list",children:[S.map((T,M)=>n.jsx("div",{id:O(M),role:"option","aria-selected":"false",className:"ui-menu-item","data-highlighted":M===C?"":void 0,onMouseEnter:()=>p(M),onMouseDown:L=>L.preventDefault(),onClick:()=>E(T.value),children:T.label},T.value)),S.length===0?n.jsx("p",{className:"ui-menu-empty",children:"Nothing matches"}):null]})]}):null]})]})}function RS({main:e,filters:t,filtersOpen:s,onToggleFilters:r,active:i,chips:a,actions:o,onSubmit:l,label:c}){return n.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),l()},children:[n.jsxs("div",{className:"ui-searchbar-row",children:[e?n.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?n.jsxs(I,{"aria-expanded":s===!0,"aria-pressed":s===!0,onClick:r,children:["Filters",i?n.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?n.jsx("div",{className:"ui-searchbar-inline",children:t}):null,o?n.jsx("div",{className:"ui-searchbar-actions",children:o}):null]}),t&&r&&s?n.jsx("div",{className:"ui-searchbar-filters",children:t}):null,a?n.jsx("div",{className:"ui-searchbar-chips",children:a}):null]})}function IS({size:e}){return n.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function oO({quiet:e,still:t,className:s,children:r}){return n.jsx("div",{className:vi("ui-fieldbg",s),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function lO(e){const t={};for(const s of e??[])t[s.key]=s.default;return t}function yg(e){const[t,s]=d.useState({}),r=e??[],i={...lO(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:n.jsx("div",{className:"ui-choices",children:r.map(a=>n.jsx(J,{label:a.label,inline:!0,children:n.jsx("select",{value:i[a.key],onChange:o=>s(l=>({...l,[a.key]:o.target.value})),children:a.options.map(o=>n.jsx("option",{value:o,children:o},o))})},a.key))})}}function cO({props:e,timezone:t="UTC",onDecided:s}){var x;const[r,i]=d.useState(null),[a,o]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let y=!1;return i(null),o(null),A.approval(e.approvalId).then(g=>{y||i(g)}).catch(g=>{y||o(g instanceof oe?g.message:String(g))}),()=>{y=!0}},[e.approvalId]);const{values:f,controls:p}=yg(r==null?void 0:r.choices),m=(y,g)=>{h(y),o(null),(f&&y==="approve"?A.decide(e.approvalId,y,g,f):A.decide(e.approvalId,y,g)).then(N=>{i(N.action),s==null||s(N.action)}).catch(N=>o(N instanceof oe?N.message:String(N))).finally(()=>h(null))};if(a&&!r)return n.jsx("p",{className:"wb-empty",children:a});if(!r)return n.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const j=r.state==="pending",w=(x=r.permissionScopes)==null?void 0:x.includes("always"),b=uO(r),v=(r.preview??"").split(`
94
+ `).length>12||(r.preview??"").length>900;return n.jsxs("div",{children:[n.jsxs("div",{className:"ui-stats","data-inline":"true",children:[n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:"Tool"}),n.jsx("div",{className:"ui-stat-v mono",children:r.tool})]}),n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:"State"}),n.jsx("div",{className:"ui-stat-v","data-tone":dO(r.state),children:r.state})]}),n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:j?"Expires":"Decided"}),n.jsx("div",{className:"ui-stat-v","data-size":"sm",children:He(j?r.expiresAt:r.decidedAt,t)})]})]}),n.jsx(se,{message:a}),j?p:null,j?n.jsxs("div",{className:"wb-row-wrap wb-block",children:[n.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>m("approve"),children:u==="approve"?"Approving…":w?"Allow once":"Approve"}),w?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>m("approve","conversation"),children:"Auto: this conversation"}),n.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>m("approve","always"),children:"Always: this agent"})]}):null,n.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>m("reject"),children:u==="reject"?"Rejecting…":"Reject"}),n.jsx("span",{className:"wb-hint",children:w?"Auto-mode and Always also approve future calls to this tool within that scope. Host permissions can be revoked under Host execution.":"This runs the action exactly as printed above."})]}):n.jsxs("p",{className:"muted",children:[r.state," ",r.decidedBy?`by ${r.decidedBy}`:""," ",r.decidedVia?`via ${r.decidedVia}`:""]}),n.jsx("h4",{className:"ui-stat-k wb-label",children:"Preview"}),n.jsxs("div",{className:"wb-doc wb-block","data-clamp":v&&!l?"true":void 0,children:[r.preview||"(this tool wrote no preview)",v&&!l?n.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]}),n.jsxs("details",{className:"ui-details wb-block",children:[n.jsx("summary",{children:"The envelope, field by field"}),n.jsx("dl",{className:"ui-kv",children:b.map(y=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:y.label}),n.jsx("dd",{className:y.mono?"mono":void 0,children:y.value})]},y.label))})]})]})}function uO(e){const t=[],s=e.envelope;if(s!==null&&typeof s=="object"&&!Array.isArray(s))for(const[i,a]of Object.entries(s))t.push({label:on(i),value:Ec(a)});else s!=null&&t.push({label:"Envelope",value:Ec(s)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,a]of Object.entries(r)){const o=`Argument · ${on(i)}`;t.some(l=>l.label===o)||t.push({label:o,value:Ec(a)})}return t.push({label:"Action id",value:e.id,mono:!0},{label:"Tool version",value:e.toolVersion,mono:!0},{label:"Agent",value:e.agentId,mono:!0},{label:"Args hash",value:e.argsHash,mono:!0},{label:"Policy version",value:String(e.policyVersion)}),e.conversationId&&t.push({label:"Conversation",value:e.conversationId,mono:!0}),e.jobId&&t.push({label:"Job",value:e.jobId,mono:!0}),t}function Ec(e){return e==null?"—":Array.isArray(e)?e.map(t=>Ec(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):Tt(e,"text",null)}function dO(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const fO=new Set(["image/png","image/jpeg","image/gif","image/webp"]),hO=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function uu(e){const t=e!==null&&typeof e=="object"?e.artifacts:null;return Array.isArray(t)?t.flatMap(s=>{if(s===null||typeof s!="object")return[];const r=s;return typeof r.id!="string"||!hO.test(r.id)?[]:[{type:"attachment",artifactId:r.id,filename:typeof r.filename=="string"?r.filename:null,mime:typeof r.mime=="string"?r.mime:"application/octet-stream",kind:typeof r.kind=="string"?r.kind:"other",sizeBytes:null}]}):[]}function wg(e){return fO.has(e.toLowerCase())}function Js(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function Ar(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function Sn(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 bg(e,t){const s=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return s.startsWith("image/")?"image":s==="application/pdf"?"pdf":s.startsWith("audio/")?"audio":s.startsWith("video/")?"video":s==="text/csv"||s==="text/tab-separated-values"||s.includes("spreadsheet")||s.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":s.includes("zip")||s.includes("tar")||s.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":s==="application/json"||s.includes("javascript")||s.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":s.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const ei={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function Ac(e){return`artifact:${e}`}function pO(e){const t=bg(e.mime,e.filename);return{id:Ac(e.artifactId),tool:ei[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function mO({props:e}){const t=pS(e.artifactId),[s,r]=d.useState(null),[i,a]=d.useState(null),[o,l]=d.useState(!1);if(d.useEffect(()=>{if(t===null)return;let h=!0;return r(null),a(null),l(!1),A.libraryEntry(t).then(f=>{h&&r({filename:f.entry.filename,sizeBytes:f.entry.sizeBytes})}).catch(()=>{}),()=>{h=!1}},[t]),t===null)return n.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(s==null?void 0:s.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,s!=null&&s.sizeBytes?Sn(s.sizeBytes):null].filter(h=>h!==null);return n.jsxs("figure",{className:"wb-image",children:[n.jsx("div",{className:"wb-image-frame",children:o?n.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):n.jsx("a",{href:Js(t),className:"wb-image-link",title:"Open at full size",children:n.jsx("img",{src:Js(t),alt:e.caption??c,onLoad:h=>{const f=h.currentTarget;f.naturalWidth>0&&a({width:f.naturalWidth,height:f.naturalHeight})},onError:()=>l(!0)})})}),n.jsxs("figcaption",{className:"wb-image-caption",children:[n.jsxs(Q,{children:[n.jsx("span",{className:"wb-image-name",children:c}),u.length>0?n.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(Zt,{size:"sm",href:Ar(t),download:(s==null?void 0:s.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?n.jsx(It,{summary:e.captionLabel,className:"wb-image-note",children:n.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?n.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function gO({props:e}){return e.pairs.length===0?n.jsx("p",{className:"wb-empty",children:"Nothing to show."}):n.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:Tt(t.value,t.unit,t.currency)})]},t.label))})}const xO=8;function PS({text:e,label:t="Output",className:s}){const r=d.useRef(null),i=d.useRef(!0);return d.useLayoutEffect(()=>{const a=r.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[e]),n.jsx("pre",{ref:r,className:s?`wb-terminal-body ${s}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:a=>{const o=a.currentTarget;i.current=o.scrollHeight-o.scrollTop-o.clientHeight<=xO},children:e})}function vO(e){if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?1:0)} s`;const s=Math.floor(t/60);return`${s} min ${Math.round(t-s*60)} s`}function jO({text:e}){const[t,s]=d.useState("");return n.jsxs(n.Fragment,{children:[t?n.jsx("span",{role:"status",className:"wb-hint",children:t}):null,n.jsx(I,{size:"sm",onClick:()=>{var r;if(s(""),!((r=navigator.clipboard)!=null&&r.writeText)){s("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>s("Copied"),()=>s("Copy failed; select the text to copy."))},children:"Copy"})]})}function yO({props:e}){const t=e.output??"";return n.jsxs("div",{className:"wb-terminal",children:[n.jsxs(Q,{className:"wb-terminal-head",children:[e.command!==null?n.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?n.jsxs(ye,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?n.jsx("span",{className:"wb-terminal-fact",children:vO(e.elapsedMs)}):null,n.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?n.jsx(jO,{text:t}):null]}),e.omittedBytes!==null?n.jsxs("p",{className:"wb-terminal-note",children:["First ",Sn(e.omittedBytes)," not shown."]}):null,t!==""?n.jsx(PS,{text:t}):n.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(s=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:s.label}),n.jsx("dd",{children:Tt(s.value,s.unit,null)})]},s.label))}):null]})}function wO(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function Tj(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function bO(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((s,r)=>s-r)}function kO({props:e}){var N;const[t,s]=d.useState(null),[r,i]=d.useState(null),[a,o]=d.useState(null),[l,c]=d.useState(!1),u=((N=e.target)==null?void 0:N.plugin)??null,h=bO(e),[f,p]=d.useState(null),m=f!==null&&h.includes(f)?f:e.port,j=e.target?m!==null&&m!==e.port?`${e.target.name}.${m}`:e.target.name:null,w=e.changes??0,b=d.useRef(w),[v,x]=d.useState(0);d.useEffect(()=>{w<=b.current||(b.current=w,e.reloadsItself||x(k=>k+1))},[w,e.reloadsItself]),d.useEffect(()=>{if(u===null||j===null)return;let k=!0;return s(null),i(null),o(null),x(0),A.previewLink(u,j).then(S=>{k&&(s(S.url),i(Tj(S.url)))}).catch(S=>{k&&o(S instanceof Error?S.message:"That preview could not be opened.")}),()=>{k=!1}},[u,j]);const y=()=>{u===null||j===null||A.previewLink(u,j).then(k=>i(k.url)).catch(()=>{})};if(e.target===null)return n.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",n.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const g=!(e.output===null||e.output==="");return n.jsxs("div",{className:"wb-preview","data-output":l||void 0,children:[n.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?n.jsx("h4",{className:"wb-doc-title",children:e.title}):null,h.length>1?n.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:m??"",onChange:k=>p(Number(k.target.value)),children:h.map(k=>n.jsxs("option",{value:k,children:[":",k]},k))}):null,g?n.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":l,onClick:()=>c(k=>!k),children:l?"Hide output":"Output"}):null,r?n.jsx("a",{className:"wb-preview-open",href:r,target:"_blank",rel:"noreferrer noopener",onPointerEnter:y,onFocus:y,title:"Through buddi: works from anywhere the dashboard does, including the tailnet.",children:"Open in a tab"}):null,m!==null&&wO()?n.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${m}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",m]}):null]}),n.jsxs("div",{className:"wb-preview-body",children:[t?n.jsx("iframe",{className:"wb-preview-frame",src:v===0?t:Tj(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},v):n.jsx("p",{className:"wb-empty wb-preview-frame",children:a??"Opening the preview…"}),g&&l?n.jsx(PS,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const SO=50,NO=9,CO=24,EO=.6,AO=48,TO=/(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,RO=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,IO=/^id$|(^|[a-z0-9])Id$|_id$/;function Gi(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Rn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function MS(...e){for(const t of e)if(Rn(t))for(const s of["currency","currencyCode"]){const r=t[s];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function $S(e,t,s){const r=t.filter(i=>i!=null&&i!=="");return r.length===0?"text":r.every(i=>typeof i=="boolean")?"boolean":r.every(i=>typeof i=="number"&&Number.isFinite(i))?s!==null&&TO.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&RO.test(i))?"date":"text"}function PO(e,t){if(!IO.test(e))return!1;const s=t.filter(r=>!Ta(r));return s.length<2?!1:new Set(s.map(r=>String(r))).size===s.length}function Ta(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:Rn(e)?Object.keys(e).length===0:!1}function Rj(e,t){const s=e.filter(Rn);if(s.length===0||s.length/e.length<.8)return null;const r=s.slice(0,SO),i=new Map,a=[];for(const h of r)for(const f of Object.keys(h))i.has(f)||a.push(f),i.set(f,(i.get(f)??0)+1);if(i.size===0||i.size>CO||[...i.values()].reduce((h,f)=>h+f,0)/(i.size*r.length)<EO)return null;const l=[...i.keys()].sort((h,f)=>{const p=(i.get(f)??0)-(i.get(h)??0);return p!==0?p:a.indexOf(h)-a.indexOf(f)}),c=[],u=[];for(const h of l){const f=r.map(w=>w[h]),p=f.filter(w=>!Ta(w));if(p.length===0||PO(h,f))continue;const m=MS(r[0],t),j=$S(h,f,m);if(r.length>=4&&p.length===f.length&&f.every(w=>Gi(w)&&w===f[0])){u.push({label:on(h),value:f[0],type:j,currency:m});continue}if(c.push({key:h,label:on(h),type:j,currency:j==="currency"?m:null}),c.length===NO)break}return c.length===0?null:{columns:c,rows:s,constants:u}}function MO(e,t,s){const r=MS(s);return{label:on(e),value:t,type:$S(e,[t],r),currency:r}}function OS(e){return typeof e=="string"&&e.length>AO}function $O(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.":Rn(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function ip(e){if(typeof e=="string"&&e.trim()!=="")return e;if(Rn(e))for(const t of["message","error","reason","detail","description"]){const s=e[t];if(typeof s=="string"&&s.trim()!=="")return s;if(Rn(s)){const r=ip(s);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function kg(e,t={}){if(t.failed){let f=e;if(typeof e=="string")try{const p=JSON.parse(e.replace(/^tool-error:\s*/,""));Rn(p)&&(f=p)}catch{}return{kind:"error",summary:ip(f),detail:Ij(f)}}if(Rn(e)){const f=e.error,p=e.ok;if(typeof f=="string"&&f.trim()!==""||p===!1)return{kind:"error",summary:ip(e),detail:Ij(e)}}const s=$O(e);if(s)return{kind:"empty",note:s,stats:[]};if(Array.isArray(e)){const f=Rj(e,e);return f?{kind:"table",label:null,columns:f.columns,rows:f.rows,total:f.rows.length,stats:f.constants,notes:[],asides:[]}:e.every(Gi)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!Rn(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,a=null;for(const[f,p]of r){if(!Array.isArray(p))continue;const m=Rj(p,e);if(m){(!i||m.rows.length>i.candidate.rows.length)&&(i={key:f,candidate:m});continue}p.length>0&&p.every(Gi)&&(!a||p.length>a.items.length)&&(a={key:f,items:p})}const o=(i==null?void 0:i.key)??(a==null?void 0:a.key)??null,l=[],c=[],u=[];for(const[f,p]of r)if(f!==o){if(OS(p)){c.push(p);continue}if(Gi(p)){if(p==="")continue;l.push(MO(f,p,e));continue}p!==void 0&&u.push({label:on(f),value:p})}if(i)return{kind:"table",label:on(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...l,...i.candidate.constants],notes:c,asides:u};if(a)return{kind:"list",label:on(a.key),items:a.items,total:a.items.length,stats:l,notes:c,asides:u};const h=r.filter(([,f])=>Array.isArray(f)&&f.length===0);return h.length>0&&h.length===r.filter(([,f])=>Array.isArray(f)).length?{kind:"empty",note:`No ${h.map(([p])=>on(p).toLowerCase()).join(", ")} to show.`,stats:l}:r.every(([,f])=>Gi(f)||Rn(f)||Array.isArray(f))?{kind:"record",pairs:l,notes:c,asides:u}:{kind:"tree",value:e}}function Ij(e){if(!Rn(e))return null;const t=Object.entries(e).filter(([s])=>s!=="message"&&s!=="error");return t.length===0?null:Object.fromEntries(t)}const du=25,OO=3,ap=8,_S=6;function op(e,t=0){if(t>_S||Ta(e)||OS(e))return 0;if(Gi(e))return 1;if(Array.isArray(e)){let s=0;for(const r of e)if(s+=op(r,t+1),s>=ap)return s;return s}if(Rn(e)){let s=0;for(const r of Object.values(e))if(s+=op(r,t+1),s>=ap)return s;return s}return 0}function lp(e,t=0){if(t>_S)return!1;if(Array.isArray(e))return e.some(a=>lp(a,t+1));if(!Rn(e))return!1;const s=e.artifactId??e.artifact_id;if(typeof s=="string"&&s.trim()!=="")return!0;const r=e.mime??e.mimeType??e.contentType,i=e.url??e.src??e.downloadUrl??e.path;return typeof r=="string"&&r.includes("/")&&typeof i=="string"&&i.trim()!==""?!0:Object.values(e).some(a=>lp(a,t+1))}function _O(e){if(lp(e))return!0;const t=kg(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=OO;case"record":case"tree":return op(e)>=ap;default:return!1}}function cf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Sg(e){const t=cf(e);if(!t)return null;const s=cf(t.output)??t;if(typeof s.state!="string"||typeof s.stdout!="string"||typeof s.stderr!="string"||!(s.exitCode===null||typeof s.exitCode=="number"&&Number.isFinite(s.exitCode)))return null;const r=s===t?null:cf(t.input),i=(r==null?void 0:r.command)??s.command;return{command:typeof i=="string"?i:null,input:r,result:s}}function DO({text:e,label:t}){const[s,r]=d.useState("");return n.jsxs("span",{className:"wb-command-copy",children:[n.jsx("button",{className:"ui-btn",onClick:()=>{var i;if(r(""),!((i=navigator.clipboard)!=null&&i.writeText)){r("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>r("Copied"),()=>r("Copy failed; select the text to copy."))},children:t}),s&&n.jsx("span",{role:"status",className:"wb-hint",children:s})]})}function uf({title:e,text:t,error:s=!1}){return n.jsxs("section",{className:"wb-command-stream","data-error":s||void 0,children:[n.jsxs("div",{className:"wb-command-bar",children:[n.jsx("h4",{children:e}),n.jsx(DO,{text:t,label:`Copy ${e.toLowerCase()}`})]}),n.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function LO({value:e,children:t}){const{result:s,command:r,input:i}=e,a=s.state==="completed"&&s.exitCode!==null&&s.exitCode!==0,o=typeof s.signal=="string"&&s.signal?s.signal:null,l=s.state==="completed"&&s.exitCode===0,c=Object.fromEntries(Object.entries(s).filter(([h,f])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(h)&&f!==null&&f!==void 0&&f!=="")),u=Array.isArray(s.outputErrors)?s.outputErrors.filter(h=>typeof h=="string"):[];return n.jsxs("div",{className:"wb-command-result",children:[n.jsxs("div",{className:"wb-command-bar",children:[n.jsx("span",{className:"ui-pill","data-tone":l?"good":"critical",children:a?"Failed":s.state==="completed"&&o?"Terminated":s.state}),s.exitCode!==null&&n.jsxs("span",{className:"mono",children:["Exit code ",s.exitCode]}),o&&n.jsxs("span",{className:"mono",children:["Signal ",o]}),n.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&n.jsx(uf,{title:"Command",text:r}),s.state==="output-limit"&&n.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),s.state==="timed-out"&&n.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),s.state==="cancelled"&&n.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),s.stdout?n.jsx(uf,{title:"Output",text:s.stdout}):n.jsx("p",{className:"wb-note",children:"No standard output."}),s.stderr?n.jsx(uf,{title:"Standard error",text:s.stderr,error:!0}):null,u.length>0&&n.jsxs("section",{children:[n.jsx("h4",{children:"File export errors"}),u.map((h,f)=>n.jsx("p",{className:"wb-fail",children:h},f))]}),t,(Object.keys(c).length>0||i!==null)&&n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"Execution details"}),n.jsx("pre",{children:bn({...c,...i?{input:i}:{}})})]})]})}const Gl=2,Pj=64;function FO({props:e}){const[t,s]=d.useState(!1),r=Sg(e.value),i=UO((r==null?void 0:r.result)??e.value),a=d.useMemo(()=>kg(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return n.jsxs("div",{children:[!r&&n.jsx(Mj,{files:i}),t?n.jsx("pre",{className:"ui-code",children:bn(e.value)}):r?n.jsx(LO,{value:r,children:i.length>0&&n.jsxs("section",{children:[n.jsx("h4",{children:"Generated files"}),n.jsx(Mj,{files:i})]})}):i.length?n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"Tool details"}),n.jsx($j,{shape:a})]}):n.jsx($j,{shape:a}),n.jsx("div",{className:"wb-row-end wb-section",children:n.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>s(o=>!o),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function UO(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(s=>s&&typeof s.id=="string"&&/^[0-9a-f-]{36}$/i.test(s.id)&&typeof s.filename=="string"):[]}function Mj({files:e}){return e.length?n.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var s;return n.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?n.jsx(BO,{file:t}):null,n.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(s=t.mime)!=null&&s.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function BO({file:e}){const[t,s]=d.useState(!1);return t?n.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):n.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>s(!0)})}function $j({shape:e}){switch(e.kind){case"error":return n.jsxs("div",{children:[n.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"What came back with it"}),n.jsx("div",{className:"wb-tree",children:Ho(e.detail,1)})]})]});case"empty":return n.jsxs("div",{children:[n.jsx(df,{stats:e.stats}),n.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=GO(e.columns,e.rows);return n.jsxs("div",{children:[n.jsx(df,{stats:e.stats}),n.jsx(ff,{notes:e.notes}),t?n.jsx(YO,{label:e.label,plan:t,rows:e.rows,total:e.total}):n.jsx(WO,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),n.jsx(hf,{asides:e.asides})]})}case"list":return n.jsxs("div",{children:[n.jsx(df,{stats:e.stats}),n.jsx(ff,{notes:e.notes}),e.label?n.jsx("h4",{className:"wb-sub",children:e.label}):null,n.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,s)=>n.jsx("li",{children:Tt(t,"text",null)},s))}),e.total>100?n.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,n.jsx(hf,{asides:e.asides})]});case"record":return n.jsxs("div",{children:[n.jsx(ff,{notes:e.notes}),n.jsx(zO,{pairs:e.pairs}),n.jsx(hf,{asides:e.asides})]});default:return n.jsx("div",{className:"wb-tree",children:Ho(e.value,0)})}}function df({stats:e}){return e.length===0?null:n.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:t.label}),n.jsx("div",{className:"ui-stat-v",children:Ng(t.value,t.type,t.currency)})]},t.label))})}const Oj=200;function ff({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=Oj),s=e.filter(r=>r.length>Oj);return n.jsxs(n.Fragment,{children:[t.map(r=>n.jsx("p",{className:"wb-note",children:r},r)),s.length>0?n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:s.length===1?"A note that came with this result":`${s.length} notes that came with this result`}),s.map(r=>n.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function zO({pairs:e}){return e.length===0?n.jsx("p",{className:"wb-note",children:"Nothing to show."}):n.jsx("dl",{className:"ui-kv",children:e.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:Ng(t.value,t.type,t.currency)})]},t.label))})}function hf({asides:e}){return e.length===0?null:n.jsx("div",{className:"wb-section",children:e.map(t=>n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:t.label}),n.jsx("div",{className:"wb-tree",children:Ho(t.value,1)})]},t.label))})}function WO({label:e,columns:t,rows:s,total:r}){const[i,a]=d.useState(!1),o=r<=du+5?r:du,l=i?s:s.slice(0,o);return n.jsxs("div",{children:[e?n.jsx("h4",{className:"wb-sub",children:e}):null,n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(c=>n.jsx("th",{className:LS(c.type)?"num":void 0,children:c.label},c.key))})}),n.jsx("tbody",{children:l.map((c,u)=>n.jsx("tr",{children:t.map(h=>n.jsx(qO,{value:c[h.key],column:h},h.key))},u))})]})}),r>l.length?n.jsxs("p",{className:"wb-note wb-note-row",children:[n.jsxs("span",{children:["Showing ",l.length," of ",r]}),n.jsxs("button",{className:"ui-btn",onClick:()=>a(!0),children:["Show all ",r]})]}):null]})}const HO=/^(title|name|headline|subject|label|heading)$/i,VO=/^(url|link|href|uri|permalink)$/i;function fu(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function KO(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function DS(e,t=48){try{const s=new URL(e),r=s.pathname==="/"?"":s.pathname,i=`${s.hostname.replace(/^www\./,"")}${r}${s.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function Yl(e,t){const s=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return s.length===0?0:s.reduce((r,i)=>r+i.length,0)/s.length}function GO(e,t){if(t.length===0)return null;const s=e.filter(h=>h.type==="text"),r=s.find(h=>VO.test(h.key)&&t.some(f=>fu(f[h.key])))??s.find(h=>{const f=t.map(p=>p[h.key]).filter(p=>!Ta(p));return f.length>0&&f.filter(fu).length/f.length>=.6});if(!r)return null;const i=s.filter(h=>h.key!==r.key),a=i.find(h=>HO.test(h.key))??i.find(h=>Yl(t,h.key)>0);if(!a)return null;const l=[...i.filter(h=>h.key!==a.key)].sort((h,f)=>Yl(t,f.key)-Yl(t,h.key)),c=l[0]&&Yl(t,l[0].key)>40?l[0]:null,u=e.filter(h=>h.key!==r.key&&h.key!==a.key&&h.key!==(c==null?void 0:c.key)).map(h=>h.key);return{url:r.key,title:a.key,description:(c==null?void 0:c.key)??null,meta:u}}function YO({label:e,plan:t,rows:s,total:r}){const[i,a]=d.useState(!1),o=r<=du+5?r:du,l=i?s:s.slice(0,o);return n.jsxs("div",{children:[e?n.jsx("h4",{className:"wb-sub",children:e}):null,n.jsx("ol",{className:"wb-records",children:l.map((c,u)=>{const h=c[t.url],f=fu(h)?h.trim():null,p=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:f?DS(f):"Untitled",m=t.description&&typeof c[t.description]=="string"?c[t.description]:null,j=f?KO(f):null,w=t.meta.map(b=>c[b]).filter(b=>!Ta(b)&&typeof b!="object").map(b=>String(b)).filter(b=>j===null||b.replace(/^www\./,"")!==j);return n.jsxs("li",{className:"wb-record",children:[f?n.jsx("a",{className:"wb-record-title",href:f,target:"_blank",rel:"noopener noreferrer",children:p}):n.jsx("span",{className:"wb-record-title",children:p}),n.jsxs("div",{className:"wb-record-meta",children:[j?n.jsx("span",{className:"wb-record-host",title:f??void 0,children:j}):null,w.map((b,v)=>n.jsx("span",{children:b.length>60?`${b.slice(0,59)}…`:b},v))]}),m?n.jsx("p",{className:"wb-record-desc",children:m.length>280?`${m.slice(0,279)}…`:m}):null]},u)})}),r>l.length?n.jsxs("p",{className:"wb-note wb-note-row",children:[n.jsxs("span",{children:["Showing ",l.length," of ",r]}),n.jsxs("button",{className:"ui-btn",onClick:()=>a(!0),children:["Show all ",r]})]}):null]})}function qO({value:e,column:t}){if(Ta(e))return n.jsx("td",{className:"wb-cell-soft",children:"—"});if(fu(e)){const i=e.trim();return n.jsx("td",{className:"wb-cell-link",children:n.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:DS(i)})})}if(e!==null&&typeof e=="object"){const i=Array.isArray(e)?`${e.length} item${e.length===1?"":"s"}`:`${Object.keys(e).length} fields`;return n.jsx("td",{className:"wb-cell-soft",title:bn(e),children:i})}const s=Ng(e,t.type,t.currency),r=s.length>Pj?`${s.slice(0,Pj-1)}…`:s;return n.jsx("td",{className:LS(t.type)?"num":"wb-cell-text",...r===s?{}:{title:s},children:r})}function LS(e){return e==="number"||e==="currency"}function Ng(e,t,s){return e==null?"—":t==="boolean"?e?"yes":"no":Tt(e,t==="text"?"text":t,s)}function Ho(e,t){if(e===null)return n.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return n.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return n.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return n.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return n.jsx("span",{children:e===""?n.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return n.jsx("span",{className:"wb-tree-null",children:"none"});const i=n.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((a,o)=>n.jsxs("div",{children:[n.jsxs("span",{className:"wb-tree-key",children:[o,". "]}),Ho(a,t+1)]},o)),e.length>50?n.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=Gl?n.jsx(_j,{summary:`${e.length} items`,open:t===Gl,children:i}):i}const s=Object.entries(e);if(s.length===0)return n.jsx("span",{className:"wb-tree-null",children:"empty"});const r=n.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:s.map(([i,a])=>n.jsxs("div",{children:[n.jsxs("span",{className:"wb-tree-key",children:[on(i),": "]}),Ho(a,t+1)]},i))});return t>=Gl?n.jsx(_j,{summary:`${s.length} fields`,open:t===Gl,children:r}):r}function _j({summary:e,open:t,children:s}){return n.jsxs("details",{open:t,children:[n.jsx("summary",{className:"wb-tree-key",children:e}),s]})}function QO({props:e}){const t=e.groups.every(s=>s.rows.length===0);return n.jsxs("div",{children:[e.summary.length>0?n.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(s=>n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:s.label}),n.jsx("div",{className:"ui-stat-v","data-tone":s.tone,children:Tt(s.value,s.unit,s.currency)})]},s.label))}):null,t?n.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((s,r)=>n.jsxs("div",{className:r>0?"wb-section":void 0,children:[s.label?n.jsx("h4",{className:"ui-stat-k wb-label",children:s.label}):null,n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(i=>n.jsx("th",{className:FS(i.type)?"num":void 0,"data-type":i.type,children:i.label},i.key))})}),n.jsx("tbody",{children:s.rows.map((i,a)=>n.jsx("tr",{children:i.map((o,l)=>{var c;return n.jsx(XO,{cell:o},((c=e.columns[l])==null?void 0:c.key)??l)})},a))})]})})]},s.label??r))]})}function XO({cell:e}){const t=Tt(e.value,e.type,e.currency);return e.bar?n.jsx("td",{className:"num",children:n.jsxs("div",{className:"wb-row wb-row-end",children:[n.jsx("div",{className:"ui-meter",role:"meter","aria-valuenow":Math.round(e.bar.fraction*100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":t,children:n.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),n.jsx("span",{className:"tnum",children:t})]})}):n.jsx("td",{className:FS(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function FS(e){return e==="number"||e==="currency"||e==="percent"}const Ii=760,pf=400,gt={top:18,right:18,bottom:36,left:66},JO=5;function ZO({props:e}){const{points:t,referenceLines:s,unit:r,currency:i}=e;if(t.length===0)return n.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const a=[...t.map(g=>g.y),...s.map(g=>g.value)],o=Math.min(...a),l=Math.max(...a),c=l-o||Math.abs(l)||1,u=o-c*.08,h=l+c*.08,f=Ii-gt.left-gt.right,p=pf-gt.top-gt.bottom,m=g=>gt.left+(t.length===1?f/2:g/(t.length-1)*f),j=g=>gt.top+p-(g-u)/(h-u)*p,w=Xk(o,l,4),b=t_(t.map(g=>g.y),e.mark),v=e.shadeBelow===null?[]:n_(t.map(g=>g.y),e.shadeBelow),x=t.map((g,N)=>`${N===0?"M":"L"}${m(N)},${j(g.y)}`).join(" "),y=g=>Tt(g,r,i);return n.jsxs("div",{children:[e.label?n.jsx("p",{className:"ui-panel-sub",children:e.label}):null,n.jsxs("div",{className:"wb-chart-layout",children:[n.jsx("div",{className:"wb-chart-plot",children:n.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${Ii} ${pf}`,role:"img","aria-label":e_(e,y),preserveAspectRatio:"xMidYMid meet",children:[v.map(g=>n.jsx("rect",{className:"wb-chart-breach",x:m(g.from),width:Math.max(2,m(g.to)-m(g.from)),y:gt.top,height:p},`band-${g.from}`)),w.map(g=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-grid",x1:gt.left,x2:Ii-gt.right,y1:j(g),y2:j(g)}),n.jsx("text",{x:gt.left-8,y:j(g)+4,textAnchor:"end",children:y(g)})]},`tick-${g}`)),s.map(g=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-floor",x1:gt.left,x2:Ii-gt.right,y1:j(g.value),y2:j(g.value)}),n.jsxs("text",{x:Ii-gt.right,y:j(g.value)-6,textAnchor:"end",children:[g.label," ",y(g.value)]})]},`rule-${g.label}`)),n.jsx("line",{className:"wb-chart-axis",x1:gt.left,x2:gt.left,y1:gt.top,y2:gt.top+p}),n.jsx("line",{className:"wb-chart-axis",x1:gt.left,x2:Ii-gt.right,y1:gt.top+p,y2:gt.top+p}),n.jsx("path",{className:"wb-chart-series",d:x}),b!==null?n.jsxs("g",{children:[n.jsx("circle",{className:"wb-chart-min",cx:m(b),cy:j(t[b].y),r:4.5}),n.jsx("text",{x:m(b),y:j(t[b].y)+20,textAnchor:"middle",children:y(t[b].y)})]}):null,s_(t.length).map(g=>n.jsx("text",{x:m(g),y:pf-10,textAnchor:"middle",children:Jh(t[g].x)},`x-${g}`))]})}),e.events.length>0?n.jsxs("aside",{className:"wb-chart-events",children:[n.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),n.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((g,N)=>n.jsxs("li",{className:"wb-chart-event",children:[n.jsxs("span",{children:[n.jsx("span",{className:"wb-chart-event-day",children:Jh(g.at)}),g.label]}),g.amount===null?null:n.jsx("span",{className:g.amount<0?"tnum critical":"tnum good",children:Tt(g.amount,r,i)})]},`${g.at}-${g.label}-${N}`))})]}):null]})]})}function e_(e,t){const s=e.points.map(o=>o.y),r=e.points[0],i=e.points[e.points.length-1],a=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(...s))}, high ${t(Math.max(...s))}`,a].filter(Boolean).join("; ")}function t_(e,t){if(!t||e.length===0)return null;let s=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[s]:e[r]>e[s])&&(s=r);return s}function n_(e,t){const s=[];let r=null;return e.forEach((i,a)=>{i<t?r===null&&(r=a):r!==null&&(s.push({from:r,to:a}),r=null)}),r!==null&&s.push({from:r,to:e.length-1}),s}function s_(e,t=JO){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const s=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*s));return[...r].sort((i,a)=>i-a)}const Yn=e=>e,cp={timeseries:Yn(ZO),table:Yn(QO),bars:Yn(vM),keyvalue:Yn(gO),document:Yn(E$),diff:Yn(SM),terminal:Yn(yO),image:Yn(mO),preview:Yn(kO),envelope:Yn(cO),structured:Yn(FO)},r_="structured";function i_(e){return(hu(e)?cp[e]:void 0)??cp[r_]}function hu(e){return Object.prototype.hasOwnProperty.call(cp,e)}function a_({renderer:e,props:t,timezone:s,onDecided:r}){const i=i_(e),o=hu(e)?t:{value:t};return n.jsx(i,{props:o,timezone:s,onDecided:r})}function o_({profile:e,onChange:t}){return n.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[n.jsx("p",{className:"wb-prof-lead",children:e.description}),n.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?n.jsx(mf,{children:"Opens by default"}):null,n.jsx(mf,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(s=>n.jsx(mf,{title:`A surface command that asks for "${s}" lands on this agent.`,children:on(s)},s))]}),e.available?null:n.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[n.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),n.jsx(Ka,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:n.jsxs("ul",{className:"wb-prof-list",children:[n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),n.jsx("span",{className:"wb-prof-row-desc",children:"When it knows the likely answers, it can show one-tap choices in the dashboard and Telegram. You can still write a different answer when the question allows it."})]}),n.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),n.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),n.jsx("span",{className:"wb-prof-row-desc",children:"A request to send, spend, publish or otherwise affect the world appears in the conversation with the exact action. Answering a question never approves it."})]}),n.jsxs("span",{className:"wb-prof-gate",children:[n.jsx(US,{}),"Exact action"]})]})]})}),n.jsx(Ka,{title:"What it can do",note:l_(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?n.jsx("p",{className:"wb-prof-empty",children:"No tools at all. It answers from the conversation and from what it remembers, and it can change nothing."}):[...e.tools].sort((s,r)=>+(r.gated>0)-+(s.gated>0)).map(s=>n.jsx(c_,{family:s},s.family))}),n.jsx(Ka,{title:"What it runs on",children:n.jsxs("dl",{className:"wb-prof-kv",children:[n.jsx(Ga,{label:"Provider",children:e.engine.provider}),n.jsx(Ga,{label:"Model",children:n.jsx("span",{className:"mono",children:e.engine.model})}),n.jsxs(Ga,{label:"Credential",children:[e.engine.credentialKind," from"," ",n.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),n.jsxs(Ga,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),n.jsx(Ga,{label:"Language",children:p_(e.engine.language)})]})}),e.skills.length>0?n.jsx(Ka,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:n.jsx("ul",{className:"wb-prof-list",children:e.skills.map(s=>n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name mono",children:s.name}),s.description?n.jsx("span",{className:"wb-prof-row-desc",children:s.description}):null]}),n.jsxs("span",{className:"wb-prof-row-side",title:s.file,children:[s.scope==="private"?"its own":"shared"," · ",s.provenance]})]},s.file))})}):null,e.delegates.length>0?n.jsx(Ka,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:n.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(s=>n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsxs("span",{className:"wb-prof-row-name mono",children:["@",s.handle]}),n.jsx("span",{className:"wb-prof-row-desc",children:s.description})]}),n.jsx("span",{className:"wb-prof-row-side",children:s.available?s.name:`${s.name} · cannot run`})]},s.id))})}):null,n.jsxs("footer",{className:"wb-prof-foot",children:[n.jsx("p",{className:"wb-prof-note",children:e.note}),n.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?n.jsxs("button",{className:"ui-btn","data-testid":"agent-profile-change",title:e.changeVia.prompt,onClick:()=>t({agentId:e.changeVia.agentId,prompt:e.changeVia.prompt}),children:["Ask @",e.changeVia.handle," to change this"]}):null]})]})}function l_(e){if(e.toolCount===0)return"Nothing. This agent holds no tools.";const t=`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`;if(e.gatedCount===0)return`${t}, every one of them running without asking you. None of them can send, spend or write to the world.`;const s=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${s}.`}function c_({family:e}){const t=[...e.tools].sort((s,r)=>Number(r.gated)-Number(s.gated));return n.jsxs("section",{className:"wb-prof-family",children:[n.jsxs("h4",{className:"wb-prof-family-head",children:[n.jsx("span",{className:"wb-prof-family-name",children:on(e.family)}),n.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),n.jsx("ul",{className:"wb-prof-list",children:t.map(s=>n.jsx(u_,{tool:s},s.name))})]})}function u_({tool:e}){return n.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name mono",children:h_(e.name)}),n.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?n.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[n.jsx(US,{}),"Needs your approval"]}):n.jsx("span",{className:"wb-prof-auto",title:f_(e.tier),children:d_(e.tier)})]})}function d_(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function f_(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 h_(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function p_(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function Ka({title:e,note:t,tone:s,children:r}){return n.jsxs("section",{className:"wb-prof-section",children:[n.jsx("h3",{className:"wb-prof-title",children:e}),t?n.jsx("p",{className:"wb-prof-note-lead","data-tone":s,children:t}):null,r]})}function Ga({label:e,children:t}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"wb-prof-k",children:e}),n.jsx("dd",{className:"wb-prof-v",children:t})]})}function mf({children:e,title:t}){return n.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function US(){return n.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),n.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const Dj=16e3,m_=10*6e4,g_="The microphone is blocked for this page: allow it in the browser’s site settings to talk.",BS="This browser cannot record here: talking needs a microphone and a secure page (https or localhost).";function x_(){const e=window;return e.AudioContext??e.webkitAudioContext}function v_(e){const t=e&&typeof e=="object"&&"name"in e?String(e.name):"";return t==="NotAllowedError"||t==="SecurityError"||t==="PermissionDeniedError"?g_:t==="NotFoundError"||t==="DevicesNotFoundError"?"No microphone was found on this computer.":t==="NotReadableError"?"The microphone is in use by another app.":BS}async function j_(e){var c;const t=x_();if(!((c=navigator.mediaDevices)!=null&&c.getUserMedia)||!t)throw Object.assign(new Error(BS),{name:"Unsupported"});const s=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),r=new t,i=r.createMediaStreamSource(s),a=r.createScriptProcessor(4096,1,1),o=[];a.onaudioprocess=u=>{const h=u.inputBuffer.getChannelData(0);o.push(new Float32Array(h));let f=0;for(let p=0;p<h.length;p++)f+=h[p]*h[p];e(Math.min(1,Math.sqrt(f/h.length)*6))},i.connect(a),a.connect(r.destination),r.state==="suspended"&&await r.resume().catch(()=>{});const l=()=>{a.onaudioprocess=null;try{i.disconnect(),a.disconnect()}catch{}s.getTracks().forEach(u=>u.stop()),r.close().catch(()=>{})};return{async stop(){const u=r.sampleRate;return l(),b_(w_(y_(o),u,Dj),Dj)},cancel:l}}function y_(e){const t=new Float32Array(e.reduce((r,i)=>r+i.length,0));let s=0;for(const r of e)t.set(r,s),s+=r.length;return t}function w_(e,t,s){if(t<=s)return e;const r=t/s,i=new Float32Array(Math.floor(e.length/r));for(let a=0;a<i.length;a++){const o=Math.floor(a*r),l=Math.min(e.length,Math.floor((a+1)*r));let c=0;for(let u=o;u<l;u++)c+=e[u];i[a]=l>o?c/(l-o):0}return i}function b_(e,t){const s=new ArrayBuffer(44+e.length*2),r=new DataView(s),i=(a,o)=>{for(let l=0;l<o.length;l++)r.setUint8(a+l,o.charCodeAt(l))};i(0,"RIFF"),r.setUint32(4,36+e.length*2,!0),i(8,"WAVEfmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,"data"),r.setUint32(40,e.length*2,!0);for(let a=0;a<e.length;a++){const o=Math.max(-1,Math.min(1,e[a]));r.setInt16(44+a*2,Math.round(o<0?o*32768:o*32767),!0)}return new Blob([s],{type:"audio/wav"})}const up="buddi.readAloud";function zS(){try{return window.localStorage.getItem(up)==="on"}catch{return!1}}function WS(e){try{e?window.localStorage.setItem(up,"on"):window.localStorage.removeItem(up)}catch{}}let gs=null,fo=null,Vo=0,dp=null;const fp=new Set;function pu(e){dp!==e&&(dp=e,fp.forEach(t=>t()))}function k_(){return dp}function S_(e){return fp.add(e),()=>fp.delete(e)}function HS(e){return Ra(),pu(e),Vo}function Lj(e){return e===Vo}function Ra(){Vo++,gs&&(gs.pause(),gs.removeAttribute("src")),fo&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(fo),fo=null,pu(null)}async function N_(e,t,s=null){var i;const r=HS(s);try{const a=await fetch(e,{credentials:"same-origin"});if(!a.ok)throw new Error(`The spoken reply could not be fetched (${a.status}).`);const o=new Blob([await a.arrayBuffer()],{type:t});if(r!==Vo)return;gs||(gs=new Audio,(i=gs.addEventListener)==null||i.call(gs,"ended",()=>pu(null))),fo=URL.createObjectURL(o),gs.src=fo,await gs.play()}catch(a){throw r===Vo&&pu(null),a}}const C_=new Set(["audio/ogg","audio/mpeg","audio/mp4","audio/wav","audio/x-wav","audio/webm"]);function VS(e){return C_.has(e.toLowerCase().split(";")[0].trim())}function Fj(e){if(e===null||!Number.isFinite(e)||e<0)return"–:––";const t=Math.floor(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function KS({artifactId:e,name:t,mime:s,sizeBytes:r}){const i=d.useRef(null),a=d.useRef(null),[o,l]=d.useState(!1),[c,u]=d.useState(!1),[h,f]=d.useState(!1),[p,m]=d.useState(0),[j,w]=d.useState(null);d.useEffect(()=>()=>{var x;(x=i.current)==null||x.pause(),a.current&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(a.current)},[]);const b=async()=>{const x=i.current;if(x){if(o){x.pause();return}Ra(),f(!1);try{if(!a.current){u(!0);const y=await fetch(Ar(e),{credentials:"same-origin"});if(!y.ok)throw new Error(String(y.status));a.current=URL.createObjectURL(new Blob([await y.arrayBuffer()],{type:s})),x.src=a.current}await x.play()}catch{f(!0)}finally{u(!1)}}},v=h?"Could not play. Download it instead.":`${Fj(p)} / ${Fj(j)}`;return n.jsxs("span",{className:"wb-audio","data-testid":"audio-card","data-playing":o?"true":void 0,children:[n.jsx("button",{type:"button",className:"ui-icon-btn wb-audio-play","data-size":"sm","aria-label":o?`Pause ${t}`:`Play ${t}`,disabled:c,onClick:()=>void b(),children:n.jsx(Te,{name:o?"pause":"play",size:14})}),n.jsxs("span",{className:"wb-file-text",children:[n.jsx("span",{className:"wb-file-name",title:t,children:t}),n.jsxs("span",{className:"wb-file-meta","data-testid":"audio-time",children:[c?"Loading…":v,!h&&Sn(r)?` · ${Sn(r)}`:""]})]}),n.jsx("a",{className:"ui-icon-btn wb-audio-download","data-size":"sm",href:Ar(e),download:t,"aria-label":`Download ${t}`,title:"Download",children:n.jsx(Te,{name:"download",size:14})}),n.jsx("audio",{ref:i,preload:"none",onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>{l(!1),m(0)},onTimeUpdate:x=>m(x.currentTarget.currentTime),onLoadedMetadata:x=>w(Number.isFinite(x.currentTarget.duration)?x.currentTarget.duration:null),onDurationChange:x=>w(Number.isFinite(x.currentTarget.duration)?x.currentTarget.duration:null)})]})}const gf=1e5,xf=200,vf=30;function GS({artifactId:e,filename:t,mime:s,family:r,available:i=!0}){const[a,o]=d.useState(!1);return i?r==="image"&&!a?n.jsx("figure",{className:"file-preview file-preview-image",children:n.jsx("img",{src:Js(e),alt:t??"Image",onError:()=>o(!0)})}):r==="audio"&&VS(s)?n.jsx("div",{className:"file-preview file-preview-audio",children:n.jsx(KS,{artifactId:e,name:t??"Audio",mime:s})}):r==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:Js(e),type:"application/pdf","aria-label":t??"PDF",children:n.jsx(W,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?n.jsx(E_,{artifactId:e,filename:t,mime:s,family:r}):n.jsx(W,{children:"Preview not supported for this kind of file. Download it to open it."}):n.jsx(W,{children:"The file is no longer available; its record is kept."})}function E_({artifactId:e,filename:t,mime:s,family:r}){const[i,a]=d.useState("loading");if(d.useEffect(()=>{let l=!1;return a("loading"),fetch(Js(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();l||a({text:u.slice(0,gf),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>gf})}).catch(()=>{l||a("failed")}),()=>{l=!0}},[e]),i==="loading")return n.jsx("div",{className:"file-preview",children:n.jsx(ue,{children:"Loading preview…"})});if(i==="failed")return n.jsx(W,{children:"The preview could not be loaded. Download the file to open it."});const o=r==="table"&&(/csv|tab-separated/.test(s)||/\.(csv|tsv)$/i.test(t??""));return n.jsxs("div",{className:"file-preview",children:[o?n.jsx(T_,{text:i.text,delimiter:/tab|\.tsv$/i.test(s+(t??""))?" ":","}):n.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?n.jsxs("p",{className:"muted",children:["Showing the first ",gf.toLocaleString()," characters. The download has the whole file."]}):null]})}function A_(e,t,s,r){const i=[];let a=[],o="",l=!1,c=!1,u=!1;const h=()=>{a.length<r?a.push(o):c=!0,o=""},f=()=>{h(),i.push(a),a=[]};let p=0;for(;p<e.length;p+=1){if(i.length>=s){u=e.slice(p).trim()!=="";break}const m=e[p];if(l){m==='"'?e[p+1]==='"'?(o+='"',p+=1):l=!1:o+=m;continue}if(m==='"'){l=!0;continue}if(m===t){h();continue}if(m!=="\r"){if(m===`
95
+ `){f();continue}o+=m}}return i.length<s&&(o!==""||a.length>0)&&f(),{rows:i,truncatedRows:u,truncatedCols:c}}function T_({text:e,delimiter:t}){const s=d.useMemo(()=>A_(e,t,xf+1,vf),[e,t]),[r,...i]=s.rows;if(!r)return n.jsx("p",{className:"muted",children:"The file is empty."});const a=Math.min(vf,s.rows.reduce((l,c)=>Math.max(l,c.length),0)),o=Array.from({length:a},(l,c)=>c);return n.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:o.map(l=>n.jsx("th",{children:r[l]??""},l))})}),n.jsx("tbody",{children:i.slice(0,xf).map((l,c)=>n.jsx("tr",{children:o.map(u=>n.jsx("td",{children:l[u]??""},u))},c))})]}),s.truncatedRows||s.truncatedCols?n.jsxs("p",{className:"muted",children:["Showing the first ",xf," rows",s.truncatedCols?` and ${vf} columns`:"",". The download has the whole file."]}):null]})}function R_({attachment:e}){const t=bg(e.mime,e.filename),s=e.filename??"Untitled file";return n.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[n.jsx(GS,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),n.jsxs("dl",{className:"ui-kv",children:[n.jsx("dt",{children:"Type"}),n.jsxs("dd",{children:[ei[t],n.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Size"}),n.jsx("dd",{children:Sn(e.sizeBytes)})]}):null,n.jsx("dt",{children:"Id"}),n.jsx("dd",{className:"mono",children:e.artifactId})]}),n.jsx("div",{className:"ui-toolbar","data-align":"end",children:n.jsx("a",{className:"ui-btn",href:Ar(e.artifactId),download:s,children:"Download"})})]})}const Uj=80,I_=["query","path","url","dir"],P_=["message","task"];function Cg(e,t){const s=M_(t);if(!s)return null;const r=Pi(s.command);if(r!==null){const o=Pi(s.name);return ql(o===null?r:`${o}: ${r}`)}for(const o of I_){const l=Pi(s[o]);if(l!==null)return ql(l)}const i=Pi(s.action);if(i!==null){const o=P_.map(l=>Pi(s[l])).find(l=>l!==null)??null;return ql(o===null?i:`${i} · ${o}`)}const a=Object.values(s).filter(o=>typeof o=="string");return a.length===1?ql(Pi(a[0])):null}function Pi(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function ql(e){return e===null?null:e.length>Uj?`${e.slice(0,Uj-1)}…`:e}function M_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Tr="agent.delegate";function $_(e){if(e===null||typeof e!="object")return null;const t=e,s=t.conversationId;if(typeof s!="string"||s==="")return null;const r=t.agentId??t.agent;return{conversationId:s,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function O_(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 hp="canvas.show",Bj="canvas.clear",zj=12;function na(e){return`${e.plugin}/${e.name}`}function __(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function D_({messages:e,descriptors:t}){const s=new Map(t.filter(a=>a.renderer==="preview").map(a=>[a.tool,a]));if(s.size===0)return[];const r=new Map,i=[];for(const a of e)for(const o of a.blocks??[]){if(o.type==="tool_use"&&r.set(o.id,o.name),o.type!=="tool_result"||o.ok===!1)continue;const l=s.get(o.name||r.get(o.toolUseId)||"");if(!l)continue;const c=gS(l,YS(o.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:a.at??null})}return i}function L_({messages:e,descriptors:t,awaiting:s,folded:r,served:i}){var u;const a=new Map(t.map(h=>[h.tool,h])),o=new Map;let l=[],c=0;for(const h of e)for(const f of h.blocks??[]){if(f.type==="tool_use"){if(o.set(f.id,{name:f.name,input:f.input,at:h.at??null}),f.name===hp){const g=U_(f.id,f.input,h.at??null);g&&l.push(g)}if(f.name===Bj&&(l=[]),f.name===Tr){const g=$_(f.input);g&&l.push({id:f.id,tool:Tr,title:"Delegation",renderer:"delegate",props:{...g,result:null},at:h.at??null,source:"delegate",substantial:!0})}continue}if(f.type!=="tool_result"||f.name===hp||f.name===Bj)continue;const p=o.get(f.toolUseId),m=h.at??(p==null?void 0:p.at)??null,j=f.name||(p==null?void 0:p.name)||"tool",w=l.find(g=>g.source==="delegate"&&g.id===f.toolUseId);if(w&&((u=f.delegation)==null?void 0:u.state)==="waiting"){w.props={...w.props,result:null,waiting:{approvalId:f.delegation.approvalId}},f.delegation.approvalId&&(w.tone="warning");continue}if(w){w.props={...w.props,result:{ok:f.ok,text:O_(f.ok?f.output:f.error??f.output),...f.ok&&uu(f.output).length>0?{files:uu(f.output)}:{}}},f.ok||(w.tone="critical");continue}const b=f.approval?mp(f):(s==null?void 0:s.get(f.toolUseId))??mp(f);if(b){l.push({id:f.toolUseId,tool:j,title:"Approval",renderer:"envelope",props:{approvalId:b},at:m,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(j))continue;const v=YS(f.output);if(f.ok===!1){l.push({id:f.toolUseId,tool:j,title:ks(j),renderer:"structured",props:{value:f.error??v??null,failed:!0},at:m,tone:"critical",source:"fallback",substantial:!1});continue}__(v)&&(c+=1);const x=a.get(j);if(x){const g=gS(x,v),{renderer:N}=g;let{props:k}=g;if(N==="preview"){const S=k,C=S.target??(S.awaiting&&(i!=null&&i.has(na(S.awaiting)))?S.awaiting:null);if(C===null)continue;k={...S,target:C,awaiting:null};const R=na(C);l=l.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&na(E.props.target)===R))}l.push({id:f.toolUseId,tool:j,title:x.title??ks(j),renderer:N,props:k,at:m,source:"descriptor",substantial:pp(N,k)});continue}const y={value:Sg(v)?{input:p==null?void 0:p.input,output:v}:v};B_("structured",y)&&l.push({id:f.toolUseId,tool:j,title:ks(j),renderer:"structured",props:y,at:m,source:"fallback",substantial:pp("structured",y)})}for(const h of l)h.source==="descriptor"&&h.renderer==="preview"&&(h.props={...h.props,changes:c});return F_(l)}const Wj="forAgent";function YS(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(Wj in e))return e;const{[Wj]:t,...s}=e;return s}function F_(e){if(e.length<=zj)return e;const t=e.length-zj;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function U_(e,t,s){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:a}=t,o=typeof r=="string"&&hu(r)?r:"structured";return{id:e,tool:hp,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:o,props:o==="structured"&&!hu(String(r))?{value:a}:a,at:s,substantial:!0,source:"canvas"}}function B_(e,t){const s=t??{};return!!(s.failed===!0||pp(e,t)||kg(s.value).kind==="error")}function pp(e,t){const s=t??{};switch(e){case"timeseries":return Ql(s.points)>0;case"bars":return Ql(s.bars)>0;case"keyvalue":return Ql(s.pairs)>0;case"document":return!!s.text||!!s.src;case"diff":return!!s.diff;case"terminal":return!!s.output||!!s.command;case"image":return!!s.artifactId;case"preview":return!!s.target;case"envelope":return!0;case"table":return(Array.isArray(s.groups)?s.groups:[]).some(i=>Ql(i.rows)>0);default:return Sg(s.value)?!0:s.failed===!0?!1:_O(s.value)}}function Ql(e){return Array.isArray(e)?e.length:0}function mp(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const s=QS(t,0);if(s)return s}return null}function z_(e,t,s={}){var l,c;const r=e.flatMap(u=>u.blocks),i=r.find(u=>u.type==="tool_use"&&u.id===t);if((i==null?void 0:i.type)!=="tool_use")return null;const a=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),o=(l=s.redactInputOf)!=null&&l.has(i.name)?qS(i.input):i.input;return{id:t,tool:i.name,title:ks(i.name),renderer:"structured",props:{value:{input:o,...(a==null?void 0:a.type)==="tool_result"?{status:((c=a.approval)==null?void 0:c.state)??(a.ok?"completed":"failed"),output:a.output,...a.error?{error:a.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const W_=new Set(["value","text","password","secret","code"]);function qS(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[s,r]of Object.entries(e))t[s]=W_.has(s)&&typeof r=="string"?"— withheld —":qS(r);return t}function QS(e,t){if(t>3||e===null||typeof e!="object")return null;const s=e,r=s.reason,i=s.actionId??s.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const a of Object.values(s)){const o=QS(a,t+1);if(o)return o}return null}function ks(e){const t=e.split(".");return t.length===1?on(e):t.map(s=>on(s)).join(" · ")}function ld({name:e,mime:t,sizeBytes:s,thumbnail:r,state:i,error:a,onOpen:o,onRemove:l,size:c="md"}){const u=bg(t,e),h=[ei[u],Sn(s)].filter(Boolean).join(" · "),f=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"wb-file-visual","data-family":u,children:r?n.jsx("img",{src:r,alt:""}):n.jsx(Eg,{family:u})}),n.jsxs("span",{className:"wb-file-text",children:[n.jsx("span",{className:"wb-file-name",title:e,children:e}),n.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":h})]})]});return n.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?a:void 0,children:[o?n.jsx("button",{type:"button",className:"wb-file-open",onClick:o,"aria-label":`Open ${e}`,children:f}):n.jsx("span",{className:"wb-file-open",children:f}),l?n.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:l,children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:n.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function Eg({family:e}){const t={width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"image":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),n.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),n.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return n.jsxs("svg",{...t,children:[n.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),n.jsx("path",{d:"M11.5 2.5V7H16"}),n.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return n.jsxs("svg",{...t,children:[n.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),n.jsx("path",{d:"M11.5 2.5V7H16"}),n.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return n.jsx("svg",{...t,children:n.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return n.jsx("svg",{...t,children:n.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),n.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),n.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return n.jsxs("svg",{...t,children:[n.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),n.jsx("path",{d:"M11.5 2.5V7H16"})]})}}function H_(e,t,s){const r=Vj(e),i=Vj(t==null?void 0:t.input),a=Wr(r==null?void 0:r.name)??q_(Wr(r==null?void 0:r.handle))??Wr(r==null?void 0:r.agent)??Wr(i==null?void 0:i.agent),o=typeof e=="string"?e.trim()||null:Wr(r==null?void 0:r.text)??Wr(r==null?void 0:r.note),l=Hj(r==null?void 0:r.durationMs)??Hj(r==null?void 0:r.elapsedMs),c=t!=null&&t.at?Date.parse(t.at):NaN,u=s?Date.parse(s):NaN,h=Number.isFinite(c)&&Number.isFinite(u)&&u>=c?u-c:null;return{who:a,question:Wr(i==null?void 0:i.task),answer:o,files:uu(e),durationMs:l??h}}function V_(e,t){var r;let s=null;for(const i of e)for(const a of i.blocks??[])a.type==="tool_result"&&a.name===Tr&&((r=a.delegation)==null?void 0:r.approvalId)===t&&(s=a.toolUseId);if(s===null)return null;for(const i of e)for(const a of i.blocks??[])if(a.type==="tool_use"&&a.id===s)return{input:a.input,at:i.at||null};return null}function K_({block:e,messages:t,answeredAt:s}){const r=H_(e.output,V_(t,e.actionId),s),i=[r.who?`Asked ${r.who}`:null,r.durationMs===null?null:`took ${G_(r.durationMs)}`].filter(a=>a!==null);return n.jsxs("div",{className:"wb-delegation-result","data-testid":"delegation-result",children:[i.length>0?n.jsx("p",{className:"wb-delegation-facts",children:i.join(" · ")}):null,r.question?n.jsx("blockquote",{className:"wb-delegation-question",children:r.question}):null,r.answer?n.jsx("div",{className:"wb-delegation-answer","data-testid":"delegation-answer",children:n.jsx(Qs,{text:r.answer})}):n.jsx("p",{className:"wb-delegation-facts",children:"No answer came back."}),r.files.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${r.who??"the colleague"} made`,children:r.files.map(a=>n.jsx("a",{role:"listitem",href:Ar(a.artifactId),download:!0,children:n.jsx(ld,{name:a.filename??"Untitled file",mime:a.mime,sizeBytes:a.sizeBytes,thumbnail:wg(a.mime)?Js(a.artifactId):null,size:"sm"})},a.artifactId))}):null,n.jsx(It,{summary:"Raw JSON",children:n.jsx("pre",{className:"wb-approval-output mono",children:Y_(e.output)})})]})}function G_(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60);return s<60?`${s}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m`}function Y_(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function q_(e){return e===null?null:`@${e.replace(/^@/,"")}`}function Wr(e){return typeof e=="string"&&e.trim()!==""?e:null}function Hj(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Vj(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Q_=1e3;function X_({messageId:e,text:t,onReadAloud:s}){const[r,i]=d.useState(!1),a=d.useRef(null),o=d.useSyncExternalStore(S_,k_)===e;d.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const l=()=>{var c;(c=navigator.clipboard)==null||c.writeText(t).then(()=>{i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),Q_)},()=>{})};return n.jsxs("div",{className:"wb-reply-actions","data-testid":"reply-actions",children:[n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":r?"Copied":"Copy",title:r?"Copied":"Copy",onClick:l,children:n.jsx(Te,{name:r?"check":"copy",size:14})}),r?n.jsx("span",{className:"wb-reply-copied",role:"status",children:"Copied"}):null,s?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":o?"Stop reading aloud":"Read aloud",title:o?"Stop reading aloud":"Read aloud","aria-pressed":o,onClick:()=>o?Ra():s(e,t),children:n.jsx(Te,{name:o?"stop":"play",size:14})}):null]})}function J_(e){const t=Z_(e);if(!t)return null;const s=jf(t.diff);if(s!==null)return{kind:"diff",diff:s};const r=jf(t.command),i=jf(t.plain),a=yf(t.exitCode);return r!==null&&(i!==null||a!==null||yf(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:a,elapsedMs:yf(t.elapsedMs)}:null}function jf(e){return typeof e=="string"&&e.trim()!==""?e:null}function yf(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Z_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Kj="offer:",XS="owner:interjection";function eD(e){return e===XS}function tD(e){if(typeof e!="string"||!e.startsWith(Kj))return null;const t=e.slice(Kj.length).trim();return t===""?null:t}function Ag({messages:e,live:t,now:s,onOpen:r,working:i=!1,partial:a=null,agents:o,agentId:l,speakers:c,coordinatorId:u,workingAs:h,onOpenFile:f,onReadAloud:p,children:m,agentName:j,emptyHint:w,empty:b,plain:v=!1,workingLine:x,runs:y}){var F;const g=d.useRef(null);d.useEffect(()=>{var H;(H=g.current)==null||H.scrollIntoView({block:"end"})},[e.length,t.length,i,a==null?void 0:a.text.length,a==null?void 0:a.thinking.length,!!m]);const N=a&&!a.settled&&(a.text!==""||a.thinking!==""),k=e.filter(H=>(H.blocks??[]).some(fD)),S=uD(k,y??[]),C=c??o??[],R=H=>(l&&!c?C.find(le=>le.id===l):void 0)??C.find(le=>le.name===H)??null,E=l?C.find(H=>H.id===l)??null:null,P=i||t.length>0,O=P||!!N,U=!!N&&a.text!=="",T=P&&!U,M=k.at(-1),L=(M==null?void 0:M.role)!=="assistant"||!!h,K=h??j??"Assistant",D=k.filter((H,le)=>{var ie;return le===0||(c?(((ie=k[le-1])==null?void 0:ie.speaker)??null)!==(H.speaker??null):k[le-1].role!==H.role)}),q=O&&!L?((F=D.at(-1))==null?void 0:F.id)??null:null;return n.jsx(hS.Provider,{value:o??c??[],children:n.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[k.length===0&&t.length===0?b??n.jsx("p",{className:"wb-chat-empty",children:w}):null,k.map((H,le)=>{const ie=H.speaker??null,ae=c?ie==="owner"||ie===null&&H.role==="user":H.role==="user",ge=c&&ie==="room",X=c&&ie&&ie!=="owner"&&ie!=="room"?c.find(fe=>fe.id===ie)??null:null,de=k[le-1],me=le===0||(c?((de==null?void 0:de.speaker)??null)!==ie:de.role!==H.role);if(ge)return n.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(H.blocks??[]).filter(fe=>fe.type==="text").map((fe,xe)=>n.jsx("span",{children:fe.text},xe))},H.id);const $e=(H.blocks??[]).filter(fe=>fe.type==="approval_result");if($e.length>0)return n.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:$e.map((fe,xe)=>n.jsx(hD,{block:fe,messages:e,at:H.at||null},xe))},H.id);const ne=H.role==="user"&&eD(ie),be=H.role==="user"?tD(ie):null;if(be){const fe=(H.blocks??[]).filter(xe=>xe.type==="text").map(xe=>xe.text).join(`
96
+ `);return n.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:n.jsx("div",{className:"wb-bubble wb-bubble-offer",title:fe,children:be})},H.id)}const Ne=c&&X&&H.role==="user"?oD(H):null;if(Ne){const fe=k.slice(le+1).find(ze=>ze.role==="assistant"&&ze.speaker&&ze.speaker!==X.id),xe=fe!=null&&fe.speaker?c.find(ze=>ze.id===fe.speaker):void 0;return n.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[n.jsxs("summary",{children:[X.name," asked ",(xe==null?void 0:xe.name)??"a member",Ne.request?`: ${Ne.request.length>120?`${Ne.request.slice(0,119)}…`:Ne.request}`:""]}),Ne.request?n.jsx("p",{children:Ne.request}):null]},H.id)}const Qe=S.get(H.id)??null,Ie=cD(H,e),rt=!ae&&!ne&&!v?lD(H):"";return n.jsxs("div",{className:"wb-msg","data-role":ae||ne?"user":"assistant",children:[ne?n.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,me&&!ae&&!ne?n.jsx(Gj,{name:X?X.name:j??"Assistant",face:X??E??R(j),moving:T&&q===H.id,children:X&&u===X.id?n.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null}):null,Ie.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:Ie.map(fe=>n.jsx("span",{role:"listitem",children:VS(fe.mime)?n.jsx(KS,{artifactId:fe.artifactId,name:fe.filename??"Untitled file",mime:fe.mime,sizeBytes:fe.sizeBytes}):n.jsx(ld,{name:fe.filename??"Untitled file",mime:fe.mime,sizeBytes:fe.sizeBytes,thumbnail:wg(fe.mime)?Js(fe.artifactId):null,...f?{onOpen:()=>f(fe)}:{}})},fe.artifactId))}):null,(H.blocks??[]).map((fe,xe)=>{const ze=rD(H.blocks??[],xe,e);if(ze==="inside")return null;if(ze)return n.jsx(iD,{refusals:ze.refusals},xe);if(fe.type==="thinking")return v||fe.text.trim()===""?null:n.jsx(gp,{text:fe.text},xe);if(fe.type==="text")return fe.text.trim()===""?null:ae?n.jsx("div",{className:"wb-bubble",children:fe.text},xe):n.jsx("div",{className:"wb-bubble","data-rich":"true",children:n.jsx(Qs,{text:fe.text})},xe);if(fe.type==="attachment")return null;if(fe.type==="tool_use"){if(v)return null;const Oe=Tg(e,fe.id),it=Oe?gD(Oe):null;return n.jsx(xp,{label:it&&!(Oe!=null&&Oe.delegation)?`Approval · ${fe.name}`:ks(fe.name),tool:fe.name,ok:(Oe==null?void 0:Oe.ok)??null,running:Oe===null,...it?{status:it.status,waiting:it.waiting,approval:!0}:{},gist:Cg(fe.name,fe.input),body:Oe?J_(Oe.output):null,opens:!0,onOpen:()=>r(fe.id)},xe)}return null}),Qe?n.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:dD(Qe)}):null,rt!==""?n.jsx(X_,{messageId:H.id,text:rt,onReadAloud:p}):null]},H.id)}),O?n.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[L?n.jsx(Gj,{name:K,face:R(K)??E,moving:T}):null,N&&a.thinking!==""&&!v?n.jsx(gp,{text:a.thinking,live:a.text==="",seconds:aD(a.thinkingStartedAt,a.textStartedAt??s)}):null,U?n.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[n.jsx(Qs,{text:a.text}),n.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null,i&&t.length===0&&!N?n.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite","data-testid":"working",children:[x??`${h??j??"The agent"} is working`,n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]}):null,t.map(H=>n.jsx(xp,{label:ks(H.name),tool:H.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((s-H.startedAt)/1e3)),opens:!1,onOpen:()=>r(H.toolUseId)},H.toolUseId))]}):null,m,n.jsx("div",{ref:g})]})})}function Gj({name:e,face:t,moving:s=!1,children:r}){const i=(t==null?void 0:t.picture)??null,a=uS(s?i:null);return n.jsxs("div",{className:"wb-msg-who","data-testid":"turn-head",children:[n.jsx("span",{className:"wb-msg-mark","data-moving":s?a&&i?"blob":"ring":void 0,children:s&&a&&i?n.jsx(sd,{state:"working",size:"sm",still:i,className:"wb-msg-blob"}):n.jsx(os,{id:(t==null?void 0:t.id)??e,name:(t==null?void 0:t.name)??e,unavailable:t?!t.available:!1,...t?{face:t}:{}})}),n.jsx("span",{children:e}),r]})}function nD(e){var t,s;return((s=(t=/ may delegate to ([^;]*);/.exec(e)??/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:s.trim())||null}const sD="delegation refused:";function rD(e,t,s){const r=a=>{const o=e[a];if(!o||o.type!=="tool_use"||o.name!==Tr)return null;const l=Tg(s,o.id);if(!l||l.ok!==!1)return null;const c=typeof l.error=="string"?l.error:String(l.error??"");if(!c.trimStart().startsWith(sD))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 a=t;;a+=1){const o=r(a);if(!o)break;i.push(o)}return i.length<2?null:{refusals:i}}function iD({refusals:e}){const[t,s]=d.useState(!1),r=e.map(l=>nD(l.message)).find(l=>l!==null)??null,i=e.map(l=>l.target),a=i.slice(0,3),o=`Delegation refused ${e.length} times: ${a.join(", ")}${i.length>a.length?", …":""}`+(r?` (allowed: ${r})`:"");return n.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[n.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>s(l=>!l),children:[n.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:o}),n.jsx(Te,{name:"arrow",className:"wb-tool-arrow"})]}),t?n.jsx("div",{className:"wb-refusals-list",children:e.map((l,c)=>n.jsxs("div",{className:"wb-refusal",children:[n.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[n.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),n.jsxs("span",{className:"wb-tool-label",children:[ks(Tr)," · ",l.target]}),n.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),n.jsx("p",{className:"wb-refusal-why",children:l.message})]},c))}):null]})}function aD(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function gp({text:e,live:t=!1,seconds:s=null}){const[r,i]=d.useState(!1),a=t?`Thinking${s!==null&&s>0?` · ${s}s`:""}`:s!==null&&s>0?`Thought for ${s}s`:"Thoughts";return n.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[n.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(o=>!o),children:[t?n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}):n.jsx(Te,{name:"thought"}),n.jsx("span",{children:a}),n.jsx(Te,{name:"arrow",className:"wb-tool-arrow"})]}),r?n.jsx("div",{className:"wb-thought-text",children:n.jsx(Qs,{text:e})}):null]})}function oD(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",s=/You are a member of the group "[^"]*"\. @([\w-]+), the coordinator, asks you now:\n\n([\s\S]*?)(?:\n\nAnswer for the room|$)/.exec(t);return s?{handle:s[1],request:s[2].trim()}:null}function lD(e){return(e.blocks??[]).filter(t=>t.type==="text").map(t=>t.text.trim()).filter(t=>t!=="").join(`
97
+
98
+ `)}function cD(e,t){const s=[],r=new Set,i=a=>{r.has(a.artifactId)||(r.add(a.artifactId),s.push(a))};for(const a of e.blocks??[])if(a.type==="attachment"&&i(a),a.type==="tool_use"&&a.name===Tr){const o=Tg(t,a.id);o!=null&&o.ok&&uu(o.output).forEach(i)}return s}function uD(e,t){const s=t.filter(o=>o.startedAt!==null&&o.finishedAt!==null),r=(o,l)=>l.at!==""&&l.at>=o.startedAt&&l.at<=o.finishedAt,i=(o,l)=>o!==l&&o.startedAt>=l.startedAt&&o.finishedAt<=l.finishedAt&&(o.startedAt>l.startedAt||o.finishedAt<l.finishedAt),a=new Map;for(const o of s){if(o.stopped!=="max_turns"&&o.stopped!=="max_tokens"||o.noticed!==!0||o.runId===null)continue;let l=null;for(const c of e)c.role!=="assistant"||!r(o,c)||(l=c);l===null||s.some(c=>i(c,o)&&r(c,l))||a.has(l.id)||a.set(l.id,o)}return a}function dD(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 fD(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function hD({block:e,messages:t,at:s}){const[r,i]=d.useState(!1),a=e.state==="succeeded";return n.jsxs("div",{className:"wb-approval","data-open":r||void 0,children:[n.jsxs("button",{type:"button",className:"wb-tool","data-ok":a,"aria-expanded":r,onClick:()=>i(o=>!o),children:[n.jsx("span",{className:"wb-tool-mark","data-ok":a?"true":"false","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":ks(e.name)}),n.jsx("span",{className:"wb-tool-elapsed",children:e.state}),n.jsx(Te,{name:"arrow",className:"wb-tool-arrow"})]}),r&&e.name===Tr?n.jsx(K_,{block:e,messages:t,answeredAt:s}):null,r&&e.name!==Tr?n.jsx("pre",{className:"wb-approval-output mono",children:pD(e.output)}):null]})}function pD(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const mD=40;function gD(e){var s,r;if(((s=e.delegation)==null?void 0:s.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(mp(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 xp({label:e,tool:t,ok:s,running:r,elapsed:i,opens:a,onOpen:o,status:l,waiting:c=!1,approval:u=!1,gist:h=null,body:f=null}){const[p,m]=d.useState(!1),j=n.jsxs(n.Fragment,{children:[r?n.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):n.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":s===!1?"false":"true","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:e}),h?n.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:h}):null,i===void 0?null:n.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),l||s===!1?n.jsx("span",{className:"wb-tool-elapsed",children:l??"failed"}):null]}),w={"data-ok":s===null?void 0:s,"data-running":r,"data-gist":h?!0:void 0,"data-approval":u||void 0};return f?n.jsxs("div",{className:"wb-toolcall","data-open":p||void 0,children:[n.jsxs("div",{className:"wb-tool","data-split":"true",...w,children:[n.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":p,onClick:()=>m(b=>!b),children:[n.jsx(Te,{name:"chevron",className:"wb-tool-chevron"}),j]}),a?n.jsxs(_o,{children:[n.jsx(Do,{asChild:!0,children:n.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:o,children:n.jsx(Te,{name:"arrow",className:"wb-tool-arrow"})})}),n.jsx(Lo,{children:n.jsxs(Fo,{className:"ui-tip",sideOffset:6,children:[n.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),n.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),p?n.jsx(xD,{body:f,onOpen:a?o:null}):null]}):a?n.jsxs(_o,{children:[n.jsx(Do,{asChild:!0,children:n.jsxs("button",{className:"wb-tool",...w,onClick:o,children:[j,n.jsx(Te,{name:"arrow",className:"wb-tool-arrow"})]})}),n.jsx(Lo,{children:n.jsxs(Fo,{className:"ui-tip",sideOffset:6,children:[n.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),n.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):n.jsx("span",{className:"wb-tool","data-static":"true",...w,children:j})}function xD({body:e,onOpen:t}){const s=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return n.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:n.jsx(lu,{text:e.diff,limit:mD,...s?{more:s}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:vD(e.elapsedMs)].filter(i=>i!==null);return n.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[n.jsxs("div",{className:"wb-tool-command",children:[n.jsx("code",{className:"mono",children:e.command}),r.length>0?n.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?n.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function vD(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Tg(e,t){for(const s of e)for(const r of s.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}const JS="approval-dock";function jD(){var t;const e=document.getElementById(JS);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const yD=["workspace","cwd","workdir","root"];function wD({approvals:e,timezone:t,now:s,version:r,onDecided:i,onSay:a,onOpenFull:o}){const[l,c]=d.useState([]),u=e.filter(p=>!l.includes(p.approvalId)),h=u[0];if(!h)return null;const f=p=>c(m=>m.includes(p)?m:[...m,p]);return n.jsx(bD,{item:h,count:u.length,timezone:t,now:s,version:r,onSettled:p=>{f(h.approvalId),p&&i(p)},onSay:a,onOpenFull:()=>o(h.toolUseId)},h.approvalId)}function bD({item:e,count:t,timezone:s,now:r,version:i,onSettled:a,onSay:o,onOpenFull:l}){var C;const[c,u]=d.useState(null),[h,f]=d.useState(null),[p,m]=d.useState(null),[j,w]=d.useState("");d.useEffect(()=>{let R=!1;return A.approval(e.approvalId).then(E=>{R||(u(E),E.state!=="pending"&&a(E))}).catch(E=>{R||f(E instanceof oe?E.message:String(E))}),()=>{R=!0}},[e.approvalId,i]);const b=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;d.useEffect(()=>{b&&c&&a({...c,state:"expired"})},[b]);const{values:v,controls:x}=yg(c==null?void 0:c.choices),y=(R,E)=>{const P=j.trim();m(R),f(null),(v&&R==="approve"?A.decide(e.approvalId,R,E,v):A.decide(e.approvalId,R,E)).then(O=>{a(O.action),P&&o(P)}).catch(O=>{f(O instanceof oe?O.message:String(O)),m(null)})},g=p!==null||c===null||c.state!=="pending",N=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,k=c?Cg(c.tool,c.canonicalArgs)??SD(c.preview):null,S=c?kD(c):null;return n.jsxs("section",{id:JS,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[n.jsxs("div",{className:"wb-question-head",children:[n.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?n.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,n.jsx("strong",{children:c?ks(c.tool):"Loading the request…"}),e.askedBy?n.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),k||S?n.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[k?n.jsx("code",{className:"wb-dock-gist",children:k}):null,S?n.jsxs("span",{className:"wb-dock-where",children:["in ",n.jsx("span",{className:"mono",children:S})]}):null]}):null,x?n.jsx("div",{className:"wb-dock-section",children:x}):null,n.jsx(se,{message:h}),n.jsx("div",{className:"wb-dock-section",children:n.jsx("input",{className:"wb-dock-instead",value:j,onChange:R=>w(R.target.value),onKeyDown:R=>{R.key==="Enter"&&R.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:p!==null})}),n.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[n.jsxs("span",{className:"wb-dock-meta",children:[c?n.jsxs(n.Fragment,{children:["Expires ",He(c.expiresAt,s)," · "]}):null,n.jsx("button",{type:"button",className:"wb-link",onClick:l,children:"See the full request on the Canvas"})]}),n.jsx(I,{variant:"ghost",size:"sm",disabled:g,onClick:()=>y("reject"),children:p==="reject"?"Rejecting…":"Reject"}),N?n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",size:"sm",disabled:g,onClick:()=>y("approve","conversation"),children:"Auto: this conversation"}),n.jsx(I,{size:"sm",disabled:g,onClick:()=>y("approve","always"),children:"Always: this agent"})]}):null,n.jsx(I,{variant:"good",size:"sm",disabled:g,onClick:()=>y("approve"),children:p==="approve"?"Approving…":N?"Allow once":"Approve"})]})]})}function kD(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const s of yD){const r=t[s];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function SD(e){const t=(e??"").split(`
99
+ `).map(s=>s.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const ND=2e3;function CD({conversationId:e,agentId:t,runId:s=null,result:r=null,waiting:i=null,agents:a=[]}){const o=r!==null,[l,c]=d.useState(o),u=!l||i!==null,{data:h,error:f}=re(()=>Le.conversation(e),[e,l,(i==null?void 0:i.approvalId)??null],u?ND:void 0),p=(h==null?void 0:h.runs)??[],m=s===null?null:p.find(g=>g.runId===s)??null,j=o||i===null&&(s!==null?m!==null&&m.finishedAt!==null:p.length>0&&p.every(g=>g.finishedAt!==null));d.useEffect(()=>{j&&c(!0)},[j]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":j?"done":"working",b=a.find(g=>g.id===t)??null,v=(b==null?void 0:b.name)??(h==null?void 0:h.agentId)??t,x=(h==null?void 0:h.messages)??[],y=(r==null?void 0:r.text)??ED(x);return n.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":w,children:[n.jsxs("header",{className:"wb-delegate-head",children:[n.jsx(gn,{agents:a,id:t}),n.jsxs("div",{className:"wb-delegate-who",children:[n.jsx("strong",{children:v}),n.jsx("span",{className:"wb-delegate-status","data-status":w,role:"status",children:w==="working"?n.jsxs(n.Fragment,{children:["Working",n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]}):w==="waiting"?"Waiting for your approval":w==="failed"?"Failed":"Done"})]})]}),f?n.jsx("p",{className:"muted",children:f}):null,n.jsx("div",{className:"wb-delegate-work",children:x.map((g,N)=>n.jsx("div",{className:"wb-delegate-turn",children:(g.blocks??[]).map((k,S)=>{if(k.type==="thinking")return k.text.trim()===""?null:n.jsx(gp,{text:k.text},S);if(k.type==="tool_use"){const C=TD(AD(x,k.id));return n.jsx(xp,{label:ks(k.name),tool:k.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:Cg(k.name,k.input),opens:!1,onOpen:()=>{}},S)}return null})},g.id??N))}),y?n.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:n.jsx(Qs,{text:y})}):w==="working"||w==="waiting"?n.jsxs("p",{className:"muted",children:[v," has not answered yet."]}):null,r!=null&&r.files&&r.files.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${v} made`,"data-testid":"delegate-files",children:r.files.map(g=>n.jsx("a",{role:"listitem",href:Ar(g.artifactId),download:!0,children:n.jsx(ld,{name:g.filename??"Untitled file",mime:g.mime,sizeBytes:g.sizeBytes,thumbnail:wg(g.mime)?Js(g.artifactId):null})},g.artifactId))}):null,n.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?n.jsx(I,{variant:"accent",onClick:()=>jD(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,n.jsx("a",{className:"ui-btn",href:Ve(t||(h==null?void 0:h.agentId)||"",e),children:"Open this conversation"})]})]})}function ED(e){for(let t=e.length-1;t>=0;t-=1){const s=e[t];if(s.role!=="assistant")continue;const r=(s.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
100
+
101
+ `);if(r!=="")return r}return null}function AD(e,t){for(const s of e)for(const r of s.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function TD(e){var s;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(s=e.approval)==null?void 0:s.state;return t==="pending"?{running:!1,ok:null,waiting:!0,status:"waiting approval"}:t==="approved"||t==="executing"?{running:!0,ok:null,waiting:!1,status:"running"}:t==="succeeded"?{running:!1,ok:!0,waiting:!1,status:void 0}:t?{running:!1,ok:!1,waiting:!1,status:t}:{running:!1,ok:e.ok,waiting:!1,status:void 0}}const Yj=1024*1024;function RD({files:e,agentId:t,root:s,revision:r}){const[i,a]=d.useState({kind:"dir",path:""});return d.useEffect(()=>a({kind:"dir",path:""}),[e.plugin,t]),n.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?n.jsx(ID,{files:e,agentId:t,root:s,path:i.path,revision:r,go:a}):n.jsx(PD,{files:e,agentId:t,root:s,path:i.path,revision:r,go:a})})}function ZS({root:e,path:t,go:s}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((a,o)=>({label:a,path:r.slice(0,o+1).join("/")}))];return n.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((a,o)=>{const l=o===i.length-1;return n.jsxs("span",{className:"wb-files-crumb",children:[o>0?n.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,l?n.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:a.label}):n.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>s({kind:"dir",path:a.path}),children:a.label})]},a.path)})})}function ID({files:e,agentId:t,root:s,path:r,revision:i,go:a}){const[o,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1),[p,m]=d.useState(null);d.useEffect(()=>{let b=!1;return u(null),A.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(v=>{b||l(v.data)}).catch(v=>{b||u(v instanceof Error?v.message:String(v))}),()=>{b=!0}},[e.plugin,e.list,t,r,i]),d.useEffect(()=>m(null),[r]);const j=async()=>{f(!0),m(null);try{const b=await fetch(A.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!b.ok){const g=await b.json().catch(()=>null);m((g==null?void 0:g.error)??"The archive could not be made.");return}const v=await b.blob(),x=URL.createObjectURL(v),y=document.createElement("a");y.href=x,y.download=`${r===""?s:r.split("/").at(-1)}.zip`,y.click(),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)}catch{m("The archive could not be made.")}finally{f(!1)}},w=o&&o.path===r?o.entries:null;return n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[n.jsx(ZS,{root:s,path:r,go:a}),n.jsx(Es,{}),n.jsx(I,{size:"sm",onClick:()=>void j(),disabled:h||w===null||w.length===0,children:h?"Packing…":"Download as archive"})]}),p?n.jsx(W,{tone:"warning",role:"alert",children:p}):null,c?n.jsx(W,{tone:"critical",role:"alert",children:c}):null,w===null?c?null:n.jsx(ue,{children:"Reading the folder…"}):w.length===0?n.jsx(ue,{children:r===""?n.jsxs(n.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",n.jsx("a",{href:li,children:"Files library"})," and mention it here."]}):"This folder is empty."}):n.jsx(Xt,{children:w.map(b=>n.jsx(cn,{href:"#",onClick:()=>a({kind:b.kind,path:b.path}),lead:n.jsx($D,{kind:b.kind}),title:n.jsxs("span",{className:"mono",children:[b.name,b.kind==="dir"?"/":""]}),side:b.kind==="file"?Sn(b.bytes):void 0},b.path))}),o&&o.path===r&&(o.skipped>0||o.truncated)?n.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 PD({files:e,agentId:t,root:s,path:r,revision:i,go:a}){const[o,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1);d.useEffect(()=>{let v=!1;return u(null),A.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(x=>{v||l(x.data)}).catch(x=>{v||u(x instanceof Error?x.message:String(x))}),()=>{v=!0}},[e.plugin,e.stat,t,r,i]);const p=o&&o.path===r?o:null,m=p?`${p.bytes}-${Math.round(p.mtimeMs)}`:"",j=p?A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v:m}):"",w=A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),b=(p==null?void 0:p.type)==="text"&&p.bytes<=Yj;return n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[n.jsx(ZS,{root:s,path:r,go:a}),n.jsx(Es,{}),b?n.jsx(I,{size:"sm","aria-pressed":h,onClick:()=>f(v=>!v),children:"Wrap"}):null,n.jsx(Zt,{size:"sm",href:w,download:(p==null?void 0:p.name)??r.split("/").at(-1),children:"Download"})]}),c?n.jsx(W,{tone:"critical",role:"alert",children:c}):null,p===null?c?null:n.jsx(ue,{children:"Reading the file…"}):p.type==="image"?n.jsx("figure",{className:"wb-files-picture",children:n.jsx("img",{src:j,alt:p.name})}):p.type==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:j,type:"application/pdf","aria-label":p.name,children:n.jsx(W,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):b?n.jsx(MD,{src:j,wrap:h}):n.jsxs(n.Fragment,{children:[n.jsx(W,{children:p.type==="text"?`This file is over ${Sn(Yj)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),n.jsx(Wt,{items:[{label:"Size",value:Sn(p.bytes)},{label:"Type",value:n.jsx("span",{className:"mono",children:p.mime})}]})]})]})}function MD({src:e,wrap:t}){const[s,r]=d.useState(null),[i,a]=d.useState(!1);return d.useEffect(()=>{let o=!1;return a(!1),fetch(e,{credentials:"same-origin"}).then(async l=>{if(!l.ok)throw new Error(String(l.status));const c=await l.text();o||r(c)}).catch(()=>{o||a(!0)}),()=>{o=!0}},[e]),i?n.jsx(W,{tone:"critical",children:"The file could not be read."}):s===null?n.jsx(ue,{children:"Reading the file…"}):s===""?n.jsx(ue,{children:"This file is empty."}):n.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:s})}function $D({kind:e}){return n.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:e==="dir"?n.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):n.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}const OD=3,_D=152,DD=104,LD=100,FD=2,qj=5;function UD({renderables:e,activeId:t,onActivate:s,timezone:r,onDecided:i,onChangeAgent:a,face:o,descriptors:l,grantedTools:c,agentName:u,maxTabs:h,browserPanel:f,agents:p,onClose:m,loading:j=!1}){const[w,b]=BD(h);if(e.length===0)return n.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[n.jsx("div",{className:"wb-canvas-tabs",ref:w,"aria-hidden":"true",children:n.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),n.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:j?null:n.jsxs("div",{className:"wb-empty",children:[o?n.jsx("span",{className:"wb-empty-face",children:o}):null,n.jsx("p",{className:"ui-empty wb-empty-line",children:KD(u,GD(l??[],c??[]))})]})})]});const v=e.some(g=>g.id===t)?t:e[e.length-1].id,{shown:x,hidden:y}=zD(e,v,b);return n.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:n.jsxs(cM,{value:v,onValueChange:s,className:"contents",children:[n.jsxs("div",{className:"wb-canvas-tabs",ref:w,children:[n.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),n.jsx(uM,{className:"wb-tabstrip","aria-label":"Canvas",children:x.map(g=>n.jsxs("div",{className:"wb-tab-item",children:[n.jsxs(dM,{value:g.id,className:"wb-tab","data-tone":g.tone,onKeyDown:N=>{N.key==="Delete"&&m&&Qj(g)&&(N.preventDefault(),m(g.id))},children:[g.tone==="warning"||g.tone==="critical"?n.jsx("span",{className:"wb-tab-dot","data-tone":g.tone,"aria-hidden":"true"}):null,n.jsx("span",{className:"wb-tab-text",children:g.title})]}),m&&Qj(g)?n.jsx("button",{className:"wb-tab-close","aria-label":`Close ${g.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>m(g.id),children:"×"}):null]},g.id))}),n.jsx(WD,{items:y,onActivate:s,timezone:r})]}),e.map(g=>n.jsx(fM,{value:g.id,className:"wb-canvas-body","data-renderer":g.source==="descriptor"&&g.renderer==="preview"?"preview":void 0,"data-dense":qD.has(g.renderer)?"true":void 0,children:n.jsxs("section",{className:"ui-panel","data-flush":g.source==="descriptor"&&g.renderer==="preview"?"true":void 0,children:[g.source!=="browser"&&g.source!=="files"&&!(g.source==="descriptor"&&g.renderer==="preview")?n.jsxs("header",{className:"ui-panel-head",children:[n.jsx("h2",{className:"ui-panel-title",children:g.title}),n.jsx("span",{className:"ui-panel-tool mono",children:g.tool})]}):null,g.tone==="critical"?n.jsxs("p",{className:"muted",children:["Recorded tool failure",g.at?` · ${new Date(g.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,g.source==="browser"?f:g.source==="profile"?n.jsx(o_,{...g.props,...a?{onChange:a}:{}}):g.source==="artifact"?n.jsx(R_,{...g.props}):g.source==="files"?n.jsx(RD,{...g.props}):g.source==="delegate"?n.jsx(CD,{...g.props,agents:p??[]}):n.jsx(a_,{renderer:g.renderer,props:g.props,timezone:r,onDecided:i})]})},g.id))]})})}function Qj(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function BD(e){const[t,s]=d.useState(qj),r=d.useRef(null);return[d.useCallback(a=>{var l;if((l=r.current)==null||l.disconnect(),r.current=null,!a||e!==void 0||typeof ResizeObserver>"u")return;const o=()=>{const c=a.clientWidth;if(c===0)return;const u=Math.floor((c-LD-DD)/_D);s(Math.max(FD,Math.min(qj,u)))};o(),r.current=new ResizeObserver(o),r.current.observe(a)},[e]),e??t]}function zD(e,t,s){const r=new Set(e.filter(a=>a.id===t||a.source==="approval"||a.pinned===!0).map(a=>a.id)),i=new Set(r);for(let a=e.length-1;a>=0&&i.size<s;a-=1)i.add(e[a].id);return{shown:e.filter(a=>i.has(a.id)),hidden:e.filter(a=>!i.has(a.id))}}function WD({items:e,onActivate:t,timezone:s}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return n.jsxs(rg,{modal:!1,children:[n.jsx(ig,{asChild:!0,children:n.jsxs("button",{className:"wb-tab wb-tab-more","data-tone":r??void 0,"aria-label":`${e.length} more ${e.length===1?"view":"views"} in this conversation`,children:[r?n.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,n.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),n.jsx(Te,{name:"chevron-down"})]})}),n.jsx(ag,{children:n.jsxs(og,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[n.jsx(lg,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>n.jsxs(Sc,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[n.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?n.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),n.jsx("span",{className:"ui-menu-note mono",children:HD(i.at,s)??i.tool})]},i.id))]})})]})}function HD(e,t){if(!e)return null;const s=new Date(e);return Number.isNaN(s.getTime())?null:new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit"}).format(s)}const VD={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 KD(e,t){const s=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>VD[i.renderer]??"results"))].slice(0,3);return r.length>0?`${s} lands here: ${r.join(", ")}.`:`${s} lands here.`}function GD(e,t){const s=new Set(t),r=new Set,i=e.filter(c=>{if(!s.has(c.tool))return!1;const u=YD(c);return r.has(u)?!1:(r.add(u),!0)}),a=new Set,o=i.filter(c=>a.has(c.renderer)?!1:(a.add(c.renderer),!0)),l=i.filter(c=>!o.includes(c));return[...o,...l].slice(0,OD)}function YD(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 qD=new Set(["table","diff","files"]),QD=3.5*6e4,XD=2e3;function JD(e,t,s={}){const[r,i]=d.useState({served:new Set,live:new Set,scope:t}),a=d.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};a.current=u.served,i(u)}const o=s.check??A.previewCheck,l=s.everyMs??XD,c=e.map(u=>`${na(u)}@${u.at??""}`).join("|");return d.useEffect(()=>{const u=new Map;for(const m of e){const j=na(m);if(a.current.has(j))continue;const w=m.at===null?Number.NaN:Date.parse(m.at),b=Number.isNaN(w)?0:w+QD,v=u.get(j);(!v||b>v.until)&&u.set(j,{plugin:m.plugin,name:m.name,until:b})}if(u.size===0)return;let h=!1,f;const p=async()=>{const m=Date.now();for(const[j,w]of[...u]){const b=await o(w.plugin,w.name).catch(()=>null);if(h)return;const v=m<=w.until;b!=null&&b.ok?(u.delete(j),i(x=>{const y={served:new Set(x.served).add(j),live:v?new Set(x.live).add(j):x.live,scope:x.scope};return a.current=y.served,y})):v||u.delete(j)}!h&&u.size>0&&(f=setTimeout(()=>void p(),l))};return p(),()=>{h=!0,f!==void 0&&clearTimeout(f)}},[c,t,o,l]),r}const vp="workspace-files";function ZD(e){let t=0;for(const s of e)for(const r of s.blocks??[]){if(r.type!=="tool_result"||r.ok===!1)continue;const i=r.output;if(i===null||typeof i!="object"||Array.isArray(i))continue;const{diff:a,path:o}=i;typeof a=="string"&&a.trim()!==""&&typeof o=="string"&&o!==""&&(t+=1)}return t}function eL(e){const[t,s]=d.useState(null);return d.useEffect(()=>{if(s(null),!e)return;let r=!1;return(async()=>{var a;const i=await A.pages();for(const o of Array.isArray(i==null?void 0:i.files)?i.files:[]){const l=await A.pageQuery(o.plugin,o.workspace,{agent:e}).catch(()=>null),c=(a=l==null?void 0:l.data)==null?void 0:a.workspace;if(c&&typeof c.name=="string")return{files:o,agentId:e,root:c.name}}return null})().then(i=>{r||s(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function tL(e,t){return{id:vp,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 jp(e){return`agent-properties:${e}`}function nL(e){return{id:jp(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function sL(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 eN({progress:e}){return n.jsxs(V,{gap:"sm",children:[n.jsx("span",{role:"status",children:sL(e)}),n.jsx(ES,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function rL(e,t,s,r){const i=e.width||1,a=e.height||1,o=t.pageScaleFactor||1,l=(s-e.left)*(t.deviceWidth/i)/o,c=((r-e.top)*(t.deviceHeight/a)-t.offsetTop)/o,u=(h,f)=>Math.max(0,Math.min(Math.round(h),Math.round(f)));return{x:u(l,t.deviceWidth),y:u(c,t.deviceHeight)}}function wf(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function Xj(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const iL=4e3;function aL(e){return e.replace(/\r\n?/g,`
102
+ `).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,iL)}const oL=["left","middle","right"],lL=33;function cL(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function uL(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const s=t.getUint16(1);if(e.byteLength<3+s)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,s))),jpeg:new Blob([new Uint8Array(e,3+s)],{type:"image/jpeg"})}}catch{return null}}function dL(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function fL({sessionId:e,csrf:t,onGiveBack:s,connect:r}){const[i,a]=d.useState("connecting"),[o,l]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState(!1),[j,w]=d.useState(0),b=d.useRef(null),v=d.useRef(null),x=d.useRef(null),y=d.useRef({at:0});d.useEffect(()=>{const T=r??(K=>new WebSocket(K));let M=!0,L;try{L=T(dL())}catch{a("lost");return}return L.binaryType="arraybuffer",b.current=L,L.onopen=()=>L.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),L.onmessage=K=>{if(!M)return;if(typeof K.data!="string"){const q=uL(K.data);if(!q||(f(F=>F&&cL(F,q.metadata)?F:q.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(q.jpeg).then(F=>{var le,ie,ae;const H=v.current;if(!M||!H){(le=F.close)==null||le.call(F);return}(H.width!==F.width||H.height!==F.height)&&(H.width=F.width,H.height=F.height),(ie=H.getContext("2d"))==null||ie.drawImage(F,0,0),(ae=F.close)==null||ae.call(F)}).catch(()=>{});return}const D=JSON.parse(K.data);if(D.type==="driving"){a("driving"),l(null);return}(D.type==="refused"||D.type==="ended")&&(l(D.error??"The screen cannot be driven from here."),a("refused"))},L.onclose=()=>{M&&a(K=>K==="refused"?K:"lost")},L.onerror=()=>{M&&a(K=>K==="refused"?K:"lost")},()=>{M=!1,b.current=null;try{L.close()}catch{}}},[e,t,j,r]),d.useEffect(()=>()=>{clearTimeout(y.current.timer)},[]);const g=d.useCallback(T=>{const M=b.current;if(M)try{M.send(JSON.stringify({type:"input",input:T}))}catch{}},[]),N=T=>{var K;const M=v.current;if(!M||!h)return null;const L=(K=M.getBoundingClientRect)==null?void 0:K.call(M);return L?rL(L,h,T.clientX,T.clientY):null},k=T=>{const M=y.current,L=Date.now();clearTimeout(M.timer),M.timer=void 0;const K=M.at+lL-L;if(K<=0){M.at=L,M.pending=void 0,g(T);return}M.pending=T,M.timer=setTimeout(()=>{const D=y.current.pending;y.current.timer=void 0,y.current.pending=void 0,y.current.at=Date.now(),D&&g(D)},K)},S=()=>{const T=y.current;clearTimeout(T.timer),T.timer=void 0;const M=T.pending;T.pending=void 0,M&&(T.at=Date.now(),g(M))},C=T=>M=>{var D,q;const L=N(M);if(!L)return;T==="mousePressed"&&(M.preventDefault(),(q=(D=v.current)==null?void 0:D.focus)==null||q.call(D));const K={kind:"mouse",type:T,x:L.x,y:L.y,button:oL[M.button]??"left",clickCount:T==="mouseMoved"?0:Math.min(3,Math.max(1,M.detail||1)),modifiers:wf(M)};if(T==="mouseMoved"){k(K);return}S(),g(K)},R=T=>{const M=N(T);M&&(S(),g({kind:"wheel",x:M.x,y:M.y,deltaX:Math.round(T.deltaX),deltaY:Math.round(T.deltaY)}))},E=T=>T.ctrlKey||T.metaKey||T.altKey,P=T=>{var L,K;if(T.key==="Escape"&&E(T)){m(!1),(K=(L=T.target).blur)==null||K.call(L);return}if(T.preventDefault(),(T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))return;const M=wf(T);if(Xj(T.key)&&!E(T)){g({kind:"key",type:"char",key:T.key,code:T.code,text:T.key,modifiers:M});return}g({kind:"key",type:"keyDown",key:T.key,code:T.code,modifiers:M})},O=T=>{T.key==="Escape"&&E(T)||(T.preventDefault(),!((T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))&&(Xj(T.key)&&!E(T)||g({kind:"key",type:"keyUp",key:T.key,code:T.code,modifiers:wf(T)})))},U=T=>{var L;T.preventDefault();const M=aL(((L=T.clipboardData)==null?void 0:L.getData("text/plain"))??"");M!==""&&g({kind:"text",text:M})};return n.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[n.jsxs("div",{className:"hand-bar",children:[n.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",variant:p?"accent":"ghost","aria-pressed":p,onClick:()=>{var M,L,K,D;const T=!p;m(T),T?(L=(M=x.current)==null?void 0:M.focus)==null||L.call(M):(D=(K=x.current)==null?void 0:K.blur)==null||D.call(K)},children:"Keyboard"}),n.jsx(I,{size:"sm",variant:"accent",onClick:s,children:"Give it back"})]})]}),i==="lost"?n.jsxs(W,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",variant:"accent",onClick:()=>{a("connecting"),w(T=>T+1)},children:"Reconnect"})})]}):null,i==="refused"&&o?n.jsx(W,{tone:"warning",role:"status",children:o}):null,n.jsx("div",{className:"hand-screen",children:c?n.jsx("canvas",{ref:v,className:"hand-picture",role:"img","aria-label":"The host browser, live","data-testid":"hand-picture",tabIndex:0,onMouseDown:C("mousePressed"),onMouseUp:C("mouseReleased"),onMouseMove:C("mouseMoved"),onWheel:R,onKeyDown:P,onKeyUp:O,onPaste:U,onContextMenu:T=>T.preventDefault()}):n.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),n.jsx("input",{ref:x,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:P,onKeyUp:O,onPaste:U,onBlur:()=>m(!1)})]})}function hL(e){return e==="darwin"?"this Mac":"this computer"}let bf=null;function Rg(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{let s=!0;return bf??(bf=A.session().then(r=>r.platform,()=>{bf=null})),bf.then(r=>{s&&t(r)}),()=>{s=!1}},[]),hL(e)}function pL({embedded:e,timezone:t}={}){var c;const{data:s,error:r,reload:i}=re(()=>A.browser(),[],3e3),a=re(()=>A.session(),[]),o=(c=a.data)!=null&&c.platform?a.data.platform==="darwin":!0,l=!!a.data||!!a.error;return n.jsxs(fn,{embedded:e,title:"Computer & browser",children:[n.jsx(se,{message:r}),!s||!l?n.jsx(ue,{children:"Checking the host…"}):n.jsx(mL,{data:s,macOS:o,reload:i,timezone:t},JSON.stringify(s.settings??null))]})}function mL({data:e,macOS:t,reload:s,timezone:r}){var S,C,R;const[i,a]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState(!1),h=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,f=(h==null?void 0:h.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),p=f==="computer",m=(S=e.sessions)!=null&&S.length?e.sessions:e.session?[e]:[],j=m.length>0||e.busy,w=async E=>{a(!0),l(null);try{await E()}catch(P){l(P instanceof Error?P.message:String(P))}finally{a(!1),s()}},b=E=>void w(()=>A.browserSettings(E)),v=e.permissions,x=f==="playwright"?e.browser:void 0,y=((C=x==null?void 0:x.install)==null?void 0:C.state)==="running",g=(x==null?void 0:x.engine)==="none",N=!!e.enabled&&!g&&!(x!=null&&x.problem)&&(!p||!(v!=null&&v.supported)||v.accessibility&&v.screenRecording),k=p?"Ready. Agents can use your computer within the apps you allow below.":f==="extension"?"Ready. Agents work in your Chrome, in background tabs, through the buddi extension.":(x==null?void 0:x.engine)==="chrome"?"Ready. Agents work in their own browser, a separate Google Chrome profile. Your apps are never touched.":"Ready. Agents work in their own browser. Your apps are never touched.";return n.jsxs(V,{gap:"lg",children:[n.jsx(se,{message:o}),n.jsx(Y,{title:"Status",panel:!0,actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",disabled:i,onClick:()=>void w(()=>A.computerPermissions(!1)),children:"Check again"}),p&&!N&&(v!=null&&v.supported)?n.jsx(I,{size:"sm",variant:"accent",disabled:i||j,onClick:()=>void w(()=>A.computerPermissions(!0)),children:"Request macOS permissions"}):null,g||y?n.jsx(I,{size:"sm",variant:"accent",disabled:i||y,onClick:()=>void w(()=>A.browserInstall()),children:y?"Installing…":"Install Chromium"}):null]}),children:n.jsxs(V,{children:[e.enabled?g?n.jsxs(W,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",n.jsx("code",{children:"buddi browser install"})," on this machine."]}):x!=null&&x.problem?n.jsx(W,{tone:"warning",children:x.message}):N?n.jsx(W,{tone:"good",children:k}):n.jsx(W,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):n.jsx(W,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),p?v!=null&&v.supported?n.jsxs("ul",{className:"perm-list",children:[n.jsxs("li",{className:"perm-row",children:[n.jsx(ye,{tone:v.accessibility?"good":"warning",children:v.accessibility?"Granted":"Needed"}),n.jsx("span",{className:"perm-name",children:"Accessibility"}),n.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),n.jsxs("li",{className:"perm-row",children:[n.jsx(ye,{tone:v.screenRecording?"good":"warning",children:v.screenRecording?"Granted":"Needed"}),n.jsx("span",{className:"perm-name",children:"Screen Recording"}),n.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):v?n.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,((R=x==null?void 0:x.install)==null?void 0:R.state)==="running"?n.jsx(eN,{progress:x.install.progress}):x!=null&&x.install?n.jsx("p",{className:"muted",role:"status",children:x.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${x.install.line??"no reason given"}`}):null,x!=null&&x.headless&&!g?n.jsx("p",{className:"muted",children:"The agents’ browser runs headless on this machine, since it has no display. Watch it and take over from the conversation’s Canvas."}):null,p&&(v!=null&&v.message)?n.jsx("p",{className:"muted",children:v.message}):null,p&&(v!=null&&v.supported)&&!N?n.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),n.jsx(Y,{title:"Who is driving",panel:!0,actions:m.length>0?n.jsx(I,{variant:"danger",size:"sm",disabled:i,onClick:()=>void w(()=>A.browserControl("stop")),children:p?"Stop computer control":"Stop all browsers"}):void 0,children:m.length===0?n.jsx("p",{className:"ui-card-meta",children:"Nobody right now. Ask an agent to open a website or one of the allowed apps, and you will see it working on that conversation’s Canvas."}):n.jsx("div",{className:"ui-list",children:m.map(E=>n.jsxs("a",{className:"ui-list-row",href:Ve(E.session.agentId,E.session.conversationId),children:[n.jsx(os,{id:E.session.agentId,name:E.session.agentId,size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:E.session.task}),n.jsxs("span",{className:"ui-list-sub",children:[E.session.agentId,", ",E.busy?"working":E.state,", ",E.session.steps," of ",E.session.maxSteps," steps"]})]}),n.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},E.session.id))})}),h?n.jsxs(n.Fragment,{children:[n.jsx(Y,{title:"How agents get a screen",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?n.jsx(kf,{current:h.mode,value:"computer",disabled:i||j||!e.enabled,title:"Use my apps",body:"Agents work in your own windows, signed in as you, in the browser profile you choose below. One agent at a time. Releasing control leaves everything open.",onPick:()=>b({...h,mode:"computer"})}):null,n.jsx(kf,{current:h.mode,value:"playwright",disabled:i||j||!e.enabled,title:"Give agents their own browser",body:"A separate browser profile with its own tabs, one per conversation. Your apps are never touched.",onPick:()=>b({...h,mode:"playwright"})}),n.jsx(kf,{current:h.mode,value:"extension",disabled:i||j||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>b({...h,mode:"extension"})})]}),t?null:n.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),j?n.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,h.mode==="extension"?n.jsx(jL,{busy:i,timezone:r}):null]})}),t?n.jsx(Y,{title:"Apps agents may use",panel:!0,children:n.jsxs(V,{children:[h.mode!=="computer"?n.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,n.jsx(yL,{settings:h,disabled:i||j||!e.enabled,onChange:b,onAdd:()=>u(!0)}),n.jsx(It,{summary:"Details",children:n.jsxs("div",{className:"ui-prose muted",children:[n.jsx("p",{children:"Agents see what is on screen in these apps, and what they see goes to the agent’s model provider. Allow only apps you want operated."}),n.jsx("p",{children:"Never type a password or a sign-in code in chat. Sign in yourself, in the app, while you have taken over."}),n.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?n.jsx(NL,{chosen:h.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),h.allowedApps.includes(E)||b({...h,allowedApps:[...h.allowedApps,E]})}}):null]}):null]})}const gL="kmbckpnnjfggeffkkbmkggojnolkdokb";async function xL(){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(gL,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function vL(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function jL({busy:e,timezone:t}){const{data:s,error:r,reload:i}=re(()=>A.extension(),[],3e3),a=Rg(),o=re(()=>xL(),[],3e3).data??null,[l,c]=d.useState(""),[u,h]=d.useState(!1),[f,p]=d.useState(null),m=(o==null?void 0:o.state)==="pairing"?o.code??"":"";d.useEffect(()=>{m&&c(m)},[m]);const j=async x=>{h(!0),p(null);try{await x()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(!1),i()}},w=e||u,b=t??Intl.DateTimeFormat().resolvedOptions().timeZone,v=n.jsxs("div",{className:"ui-prose muted",children:[n.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),n.jsx(bt,{label:"The unpacked extension",children:(s==null?void 0:s.path)??"…"})]});return n.jsxs(V,{divided:!0,children:[n.jsx(se,{message:r??f}),n.jsxs(Q,{children:[n.jsx(ye,{tone:s!=null&&s.connected?"good":"warning",children:s!=null&&s.connected?"Connected":"Not connected"}),n.jsxs("span",{className:"muted",children:[s!=null&&s.connected&&s.pairedAt?`Paired with Chrome on ${a} since ${He(s.pairedAt,b)}`:s!=null&&s.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",s!=null&&s.extension?` · extension ${s.extension}`:""]})]}),n.jsxs(V,{children:[n.jsxs("p",{className:"muted",children:[o?`The browser you are reading this in has the extension, version ${o.version}.`:s!=null&&s.connected?"The browser you are reading this in has no buddi extension. You only need it here to pair this browser instead.":"The browser you are reading this in has no buddi extension yet.",(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&&!vL(o.gateway)?n.jsx(W,{tone:"warning",children:`The extension is pointed at ${o.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),s!=null&&s.pending?n.jsxs(Q,{valign:"end",children:[n.jsx(J,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:n.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:l,onChange:x=>c(x.target.value)})}),n.jsx(Es,{}),n.jsx(I,{variant:"accent",disabled:w||l.replace(/[^0-9]/g,"").length!==6,onClick:()=>void j(async()=>{await A.pairExtension(l),c("")}),children:"Pair"})]}):null,s!=null&&s.connected?n.jsx(It,{summary:"Pair a different browser",children:v}):v,n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"danger",disabled:w||!(s!=null&&s.pairedAt),onClick:()=>void j(()=>A.forgetExtension()),children:"Forget this browser"})})]})}function kf({current:e,value:t,title:s,body:r,disabled:i,onPick:a}){const o=e===t;return n.jsxs("button",{type:"button",role:"radio","aria-checked":o,className:"mode-option",disabled:i,onClick:()=>{o||a()},children:[n.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),n.jsxs("span",{className:"mode-option-text",children:[n.jsx("span",{className:"mode-option-title",children:s}),n.jsx("span",{className:"mode-option-body",children:r})]})]})}function yL({settings:e,disabled:t,onChange:s,onAdd:r}){const i=re(()=>A.installedApps(),[]),a=o=>{var l,c;return((c=(l=i.data)==null?void 0:l.apps.find(u=>u.id===o))==null?void 0:c.name)??o};return n.jsxs(n.Fragment,{children:[e.allowedApps.length===0?n.jsx(ue,{children:"No apps yet. Agents cannot touch anything until you add one."}):n.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(o=>n.jsxs("li",{className:"ui-list-row",children:[n.jsx(os,{id:o,name:a(o),size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[a(o),o===e.browserApp?n.jsx(ye,{tone:"accent",className:"app-role",children:"browser"}):null]}),n.jsx("span",{className:"ui-list-sub mono",children:o})]}),n.jsxs(Q,{children:[o!==e.browserApp&&SL(o)?n.jsx(I,{size:"sm",variant:"ghost",disabled:t,onClick:()=>s({...e,browserApp:o}),children:"Use as browser"}):null,o===e.browserApp?n.jsx("span",{className:"muted",children:"In use as the browser"}):n.jsx(I,{size:"sm",variant:"ghost",disabled:t,onClick:()=>s({...e,allowedApps:e.allowedApps.filter(l=>l!==o)}),children:"Remove"})]})]},o))}),n.jsxs(Q,{children:[n.jsx(I,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),n.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&wL.includes(e.browserApp)?n.jsx(bL,{settings:e,disabled:t,onChange:s}):null]})}const wL=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function bL({settings:e,disabled:t,onChange:s}){var o;const i=((o=re(()=>A.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:o.profiles)??[],a=e.browserProfile?i.some(l=>l.directory===e.browserProfile):!0;return n.jsx(J,{label:"Browser profile",hint:e.browserProfile?"Websites open in this profile, signed in as it is.":"Not chosen: websites open in whichever profile’s window is in front, or the last one you used.",children:n.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:l=>{const{browserProfile:c,...u}=e;s(l.target.value?{...u,browserProfile:l.target.value}:u)},children:[n.jsx("option",{value:"",children:"Whichever is in front"}),!a&&e.browserProfile?n.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(l=>n.jsxs("option",{value:l.directory,children:[l.name,l.directory==="Default"?"":` (${l.directory})`]},l.directory))]})})}const kL=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function SL(e){return kL.includes(e)}function NL({chosen:e,onClose:t,onPick:s}){const r=re(()=>A.installedApps(),[]),[i,a]=d.useState(""),[o,l]=d.useState(""),c=d.useMemo(()=>{var f;const u=((f=r.data)==null?void 0:f.apps)??[],h=i.trim().toLowerCase();return u.filter(p=>!h||p.name.toLowerCase().includes(h)||p.id.toLowerCase().includes(h)).slice(0,60)},[r.data,i]);return n.jsxs(en,{title:"Add an app",onClose:t,children:[n.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>a(u.target.value)}),n.jsx(se,{message:r.error}),r.data?c.length===0?n.jsx(ue,{children:"No app matches."}):n.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const h=e.includes(u.id);return n.jsxs("li",{className:"ui-list-row",children:[n.jsx(os,{id:u.id,name:u.name,size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:u.name}),n.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),n.jsx(I,{size:"sm",disabled:h,onClick:()=>s(u.id),children:h?"Allowed":"Allow"})]},u.id)})}):n.jsx(ue,{children:"Reading your Applications folder…"}),n.jsx(It,{summary:"Add by bundle identifier instead",children:n.jsxs(Q,{children:[n.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:o,onChange:u=>l(u.target.value)}),n.jsx(I,{disabled:!o.trim(),onClick:()=>s(o.trim()),children:"Allow this identifier"})]})})]})}function CL({data:e,error:t,reload:s,compact:r=!1,refresh:i,screenshotSrc:a,onScreenshotError:o,onScreenshotLoad:l,controls:c=!0}){var R,E,P;const[u,h]=d.useState(!1),[f,p]=d.useState(null),[m,j]=d.useState(null),[w,b]=d.useState(null),v=async O=>{h(!0),p(null),b(null);try{const U=O!=="stop"&&(e!=null&&e.session)?await A.browserControl(O,e.session.id):await A.browserControl(O);O==="takeover"?U.hand&&U.session?j(U.session.id):b(U.handMessage??null):j(null)}catch(U){p(U instanceof Error?U.message:String(U))}finally{h(!1),s()}},x=m&&((R=e==null?void 0:e.session)==null?void 0:R.id)===m&&e.state==="paused"?m:null,y=!!(e!=null&&e.enabled)&&!u,g=(e==null?void 0:e.mode)==="computer",N=(e==null?void 0:e.mode)==="extension",k=g?"Stop computer control interrupts native input and revokes access. Take over pauses agent input. Release ends this conversation’s control without closing your apps. Already dispatched actions cannot be undone. Avoid using the same mouse and keyboard while the agent is working.":"Stop all browsers closes every session and revokes access until you resume. Take over, Resume and Close & release affect only the selected conversation. An in-flight action is interrupted by closing its tabs. Actions already submitted cannot be undone.",S=e!=null&&e.busy?"Working":(e==null?void 0:e.state)==="running"?"Ready":(e==null?void 0:e.state)??"Connecting",C=e!=null&&e.busy||(e==null?void 0:e.state)==="running"?"good":(e==null?void 0:e.state)==="stopped"||(e==null?void 0:e.state)==="error"?"critical":void 0;return n.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[n.jsxs("div",{className:"browser-heading",children:[n.jsxs("div",{children:[r?null:n.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),n.jsx("h2",{className:"browser-title",children:g?"Computer":N?"Your browser":"Browser"})]}),n.jsx(ye,{tone:C,children:n.jsx("span",{role:"status",children:S})})]}),r?n.jsx("a",{className:"browser-full-view",href:"#/browser",children:g?"Open computer view & settings ↗":"Open full browser view ↗"}):n.jsx("p",{className:"ui-page-lede",children:g?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":N?"Your own Chrome, signed in as you, working in background tabs grouped as “buddi”. You keep browsing.":"A real browser window, driven by your assistant. You stay in control."}),n.jsx(se,{message:t??f}),c?n.jsxs(Q,{children:[n.jsx(I,{variant:"danger",disabled:!y||(e==null?void 0:e.state)==="stopped",onClick:()=>void v("stop"),children:g?"Stop computer control":"Stop all browsers"}),n.jsx(I,{disabled:!y||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void v("takeover"),children:"Take over"}),n.jsx(I,{disabled:!y||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void v("resume"),children:"Resume access"}),n.jsx(I,{disabled:!y||!(e!=null&&e.session),onClick:()=>void v("release"),children:g?"Release control":"Close & release"})]}):null,c?r?n.jsx(It,{summary:"About these controls",children:n.jsx("p",{className:"muted",children:k})}):n.jsx("p",{className:"muted",children:k}):null,w?n.jsx(W,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!x?n.jsx(W,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?n.jsxs("div",{className:"browser-task",children:[n.jsxs("div",{className:"ui-row",children:[n.jsx("strong",{children:e.session.agentId}),n.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:n.jsx("p",{children:e.session.task}),n.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",new Date(e.session.expiresAt).toLocaleTimeString()]})]}):n.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?g?"No agent is driving. Ask an agent granted browser.* to open a website or an allowed native app.":"No agent is driving. Ask an agent granted browser.* to open a website.":"The host browser is unavailable. Start buddi serve on a machine with a desktop session."}),x?n.jsx(fL,{sessionId:x,csrf:pi(),onGiveBack:()=>void v("resume")}):null,n.jsxs("div",{className:"browser-window",hidden:!!x,children:[n.jsxs("div",{className:"browser-address",children:[n.jsx("span",{"aria-hidden":"true",children:"◉"}),n.jsx("span",{children:((E=e==null?void 0:e.page)==null?void 0:E.url)??(g?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?n.jsxs("figure",{children:[n.jsx("img",{src:a??`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:""}${i?`&tick=${i}`:""}`,alt:`Last browser observation: ${e.page.title||e.page.url}`,...o?{onError:o}:{},...l?{onLoad:l}:{}},a??e.page.id),n.jsxs("figcaption",{children:["Last observation · ",new Date(e.page.capturedAt).toLocaleTimeString()," · ",e.page.title||"Untitled page"]})]}):n.jsxs("div",{className:"browser-empty",children:[n.jsx("strong",{children:g?"Your selected app will appear here":"Your browser activity will appear here"}),n.jsx("p",{children:g?"Only the selected app window is captured, not the whole desktop. This preview is not interactive.":"This is a view of the host browser, not a second browser or a remote desktop."})]})]}),(((P=e==null?void 0:e.page)==null?void 0:P.tabs.length)??0)>1?n.jsx(It,{summary:`${e.page.tabs.length} open tabs`,children:n.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(O=>n.jsxs("li",{children:[O.title||O.id," — ",O.url]},O.id))})}):null,n.jsxs("p",{className:"muted",children:[g?"Sign in directly in the host app during takeover. Don’t send passwords or MFA codes in chat. Native apps retain your existing logins and documents. Secure accessibility fields are masked; other sensitive window content can still appear in screenshots.":"Sign in directly in this conversation’s host tab during takeover. Don’t send passwords or MFA codes in chat. Agent tabs share saved logins and cookies."," ",x?"While you are driving this is a live view of the page; nothing you type is kept.":"Screenshots update after agent actions; this is not a live video feed."]})]})}const EL=2e3,AL=5;function TL(e,t){if(!e.hasScreenshot||!e.page)return null;const s=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${s}`}function RL({status:e,error:t,reload:s,steps:r,live:i,focusedStepId:a=null}){var y;const[o,l]=d.useState(0),[c,u]=d.useState(0),h=c>=AL;d.useEffect(()=>{if(!i||h)return;const g=window.setInterval(()=>{typeof document<"u"&&document.hidden||l(N=>N+1)},EL);return()=>window.clearInterval(g)},[i,h]);const f=d.useRef(null);i&&(e!=null&&e.session)&&(f.current=e);const[p,m]=d.useState(null),j=d.useRef(null),w=((y=e==null?void 0:e.page)==null?void 0:y.id)??null;d.useEffect(()=>{const g=i&&e?TL(e):null;if(!g||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let N=!1;return(async()=>{try{const k=await fetch(g);if(!k.ok||N)return;const S=await k.blob();if(N)return;const C=URL.createObjectURL(S);j.current&&URL.revokeObjectURL(j.current),j.current=C,m(C)}catch{}})(),()=>{N=!0}},[i,w]),d.useEffect(()=>()=>{j.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(j.current)},[]);const b=f.current,v=i?e:b?p?b:{...b,hasScreenshot:!1}:e,x=r.at(-1)??null;return n.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[n.jsx(CL,{data:v,error:t,reload:s,compact:!0,controls:i,...i?{refresh:o}:{},...!i&&p?{screenshotSrc:p}:{},onScreenshotError:()=>u(g=>g+1),onScreenshotLoad:()=>u(0)}),i?h?n.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:n.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"This session has ended. What is on this panel is the last thing it showed."}),n.jsx(IL,{steps:r,newestId:(x==null?void 0:x.id)??null,focusedId:a??null,live:i})]})}function IL({steps:e,newestId:t,focusedId:s,live:r}){const i=d.useRef(null);return d.useEffect(()=>{var o;if(!s||!i.current)return;const a=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(s):s}"]`);(o=a==null?void 0:a.scrollIntoView)==null||o.call(a,{block:"nearest"})},[s]),e.length===0?n.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):n.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:n.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((a,o)=>{const l=a.awaiting?"awaiting":a.ok===null?"running":a.ok?"ok":"failed";return n.jsxs("li",{"data-step":a.id,className:"wb-browser-step","data-state":l,"data-newest":a.id===t?"true":void 0,"data-focused":a.id===s?"true":void 0,children:[n.jsx("span",{className:"wb-browser-index mono",children:o+1}),n.jsxs("span",{className:"wb-browser-what",children:[n.jsx("strong",{children:a.action}),a.target?n.jsx("span",{className:"muted wb-browser-target",children:a.target}):null,a.error?n.jsx("span",{className:"wb-browser-error",children:a.error}):null]}),n.jsx("span",{className:"wb-browser-outcome","data-state":l,children:l==="awaiting"?"Awaiting approval":l==="running"?"Working":l==="ok"?"Done":"Failed"})]},a.id)})})})}function PL({agentId:e,conversationId:t}){const{data:s,error:r,reload:i}=re(()=>A.host(e,t),[e,t],2e3),[a,o]=d.useState(null),[l,c]=d.useState(!1),u=async m=>{c(!0),o(null);try{await m(),i()}catch(j){o(j instanceof Error?j.message:String(j))}finally{c(!1)}},h=(s==null?void 0:s.permissions)??[],f=(s==null?void 0:s.runs)??[],p=h.some(m=>!m.conversationId)?"Always allowed":h.length?"Conversation auto-mode":"Ask each time";return n.jsx(It,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":p}${f.length?` · ${f.length} running`:""}`,children:n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"muted",children:"Commands run as your user, not in a sandbox. Auto-mode covers all commands within its scope. Stop interrupts a command; revoke also ends the permission. Neither undoes completed changes."}),n.jsx(se,{message:a??r}),h.map(m=>n.jsxs(Q,{children:[n.jsxs("span",{children:[m.agentId,": ",m.conversationId?"conversation auto-mode":"always allowed"]}),n.jsx(I,{size:"sm",disabled:l,onClick:()=>void u(()=>A.revokeHost(m.id)),children:"Revoke permission"})]},m.id)),h.length?null:n.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),f.map(m=>n.jsxs(V,{gap:"sm",children:[n.jsxs("p",{children:[m.agentId," · ",n.jsx("span",{className:"mono",children:m.cwd})]}),n.jsx(bt,{children:m.command}),n.jsx(bt,{label:"Command output",children:m.stdout||m.stderr?`${m.stdout}
103
+ ${m.stderr}`:"Waiting for output…"}),n.jsx(Q,{children:n.jsx(I,{size:"sm",variant:"danger",disabled:l,onClick:()=>void u(()=>A.stopHost(m.agentId,m.conversationId)),children:"Stop command"})})]},m.actionId))]})})}const tN="browser.act",ML="browser.status",Tc=new Set([tN,ML]);function $L(e,t,s){const r=e==null?void 0:e.session;return!r||!t||!s||r.agentId!==t||r.conversationId!==s?null:{id:`host-browser:${r.id}`,title:e.mode==="computer"?"Computer":"Browser",tool:"Host browser",renderer:"browser",source:"browser",pinned:!0,props:{},at:null,substantial:!1}}function OL(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function _L(e){var r;const t=[],s=new Map;for(const i of e)for(const a of i.blocks??[]){if(a.type==="tool_use"&&a.name===tN){const l={id:a.id,action:DL(a.input)??"act",target:LL(a.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(l),s.set(a.id,l);continue}if(a.type!=="tool_result")continue;const o=s.get(a.toolUseId);if(o){if(((r=a.approval)==null?void 0:r.state)==="pending"){o.awaiting=!0,o.ok=null,o.error=null;continue}o.awaiting=!1,o.ok=a.ok,o.error=a.ok?null:FL(a)}}return t}function Jj(e,t){var r;let s=!1;for(const i of e)for(const a of i.blocks??[])if(a.type==="tool_use"&&a.id===t&&(s=Tc.has(a.name)),a.type==="tool_result"&&a.toolUseId===t&&((r=a.approval)==null?void 0:r.state)==="pending")return null;return s?t:null}function DL(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function LL(e){if(e===null||typeof e!="object")return null;const t=e;for(const r of["url","appId","direction","key","tabId"]){const i=t[r];if(typeof i=="string"&&i!=="")return i}const s=t.target;if(s!==null&&typeof s=="object"){const r=s,i=r.name;if(typeof i=="string"&&i!=="")return i;const a=r.ref;if(typeof a=="string"&&a!=="")return a;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function FL(e){for(const t of[e.error,e.output]){if(typeof t=="string"&&t.trim()!=="")return t.trim();if(t!==null&&typeof t=="object")for(const s of["message","error","reason"]){const r=t[s];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function UL({agentId:e,groupId:t,currentId:s,timezone:r,onSelect:i,onNew:a}){const[o,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(0);return d.useEffect(()=>{let p=!1;return l(null),u(null),(t?Le.groupConversations(t):Le.conversations(e,100)).then(m=>{p||l(m.conversations)}).catch(m=>{p||u(m instanceof Error?m.message:String(m))}),()=>{p=!0}},[e,t,h]),n.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[n.jsxs("div",{className:"ui-toolbar",children:[n.jsx("strong",{children:"Past conversations"}),n.jsx("button",{className:"ui-btn",onClick:a,children:"New conversation"})]}),c?n.jsxs("p",{role:"alert",children:[c," ",n.jsx("button",{className:"ui-btn",onClick:()=>f(p=>p+1),children:"Retry"})]}):o===null?n.jsx("p",{className:"muted",children:"Loading conversations…"}):o.length===0?n.jsx("p",{className:"muted",children:"No conversations yet."}):n.jsx("ul",{children:o.map(p=>n.jsx("li",{children:n.jsxs("a",{href:t?co(t,p.id):Ve(e,p.id),"aria-current":p.id===s?"page":void 0,onClick:m=>{m.button===0&&!m.metaKey&&!m.ctrlKey&&!m.shiftKey&&!m.altKey&&(m.preventDefault(),i(p.id))},children:[n.jsx("span",{children:p.preview||p.opening||"Untitled conversation"}),n.jsxs("small",{children:[He(p.lastMessageAt??p.startedAt??p.createdAt??null,r)," · ",p.messageCount," messages",p.id===s?" · Current":""]})]})},p.id))}),n.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(o==null?void 0:o.length)===100?n.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const nN="buddi.dismissedTabs";function BL(){try{const e=JSON.parse(sessionStorage.getItem(nN)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(s=>typeof s=="string")))}catch{return{}}}function Zj(e){try{sessionStorage.setItem(nN,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const zL=350,WL=60;function HL({conversationId:e,onText:t,onNotice:s}){const[r,i]=d.useState("idle"),a=d.useRef("idle"),o=x=>{a.current=x,i(x)},l=d.useRef(null),c=d.useRef(null),u=d.useRef(null),h=d.useRef(null),f=d.useRef(null),p=d.useRef({onText:t,onNotice:s,conversationId:e});p.current={onText:t,onNotice:s,conversationId:e};const m=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},j=async()=>{if(a.current!=="idle")return;p.current.onNotice(null),o("starting"),c.current=null;let x;try{x=await j_(N=>{var k;return(k=f.current)==null?void 0:k.call(f,N)})}catch(N){h.current=null,o("idle"),p.current.onNotice(v_(N));return}const y=c.current;c.current=null;const g=a.current;if(y==="discard"||g!=="starting"){x.cancel(),g==="starting"&&o("idle");return}l.current=x,o("recording"),u.current=window.setTimeout(()=>void w(!1),m_),y&&w(y.sendNow)},w=async x=>{h.current=null;const y=l.current;if(!y){a.current==="starting"&&(c.current={sendNow:x});return}l.current=null,m(),o("transcribing");try{const g=await y.stop();if(g.size<=44){p.current.onNotice("Nothing was recorded.");return}const N=new File([g],`recording-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.wav`,{type:"audio/wav"}),k=await Le.attach(N),S=p.current.conversationId,C=await Le.transcribe({artifactId:k.artifactId,...S?{conversationId:S}:{}});p.current.onText(C.text,x)}catch(g){p.current.onNotice(g instanceof oe||g instanceof Error?g.message:String(g))}finally{o("idle")}},b=()=>{h.current=null;const x=l.current;if(!x){a.current==="starting"&&(c.current="discard");return}l.current=null,m(),x.cancel(),o("idle")};d.useEffect(()=>{const x=y=>{if(h.current===null)return;const g=Date.now()-h.current;h.current=null,g>=zL&&w(y.shiftKey)};return window.addEventListener("pointerup",x),()=>window.removeEventListener("pointerup",x)},[]);const v=r==="starting"||r==="recording";return d.useEffect(()=>{if(!v)return;const x=y=>{y.isComposing||y.repeat||(y.key==="Escape"?(y.preventDefault(),y.stopPropagation(),b()):y.key==="Enter"&&(y.preventDefault(),y.stopPropagation(),w(y.shiftKey)))};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[v]),d.useEffect(()=>()=>{var x;(x=l.current)==null||x.cancel(),m()},[]),{state:r,hold:()=>{h.current=Date.now(),j()},start:()=>{h.current=null,j()},finish:x=>void w(x),discard:b,levels:f}}function VL({disabled:e,voice:t}){const s=i=>{e||i.button>0||t.state!=="idle"||(i.preventDefault(),t.hold())},r=i=>{i.detail!==0||e||t.state!=="idle"||t.start()};return n.jsx("button",{type:"button",className:"ui-icon-btn wb-mic","data-size":"sm","aria-label":"Talk",title:"Talk: click to start, or hold to speak and let go to stop",disabled:e,onPointerDown:s,onClick:r,onContextMenu:i=>i.preventDefault(),children:n.jsx(Te,{name:"mic"})})}function KL({voice:e}){const t=d.useRef(null),s=e.state==="transcribing";return d.useEffect(()=>{var r;(r=t.current)==null||r.focus()},[]),n.jsxs("div",{className:"wb-listening",role:"group","aria-label":"Recording","data-phase":s?"transcribing":"listening",children:[n.jsx("p",{className:"wb-listening-label","aria-live":"polite",children:s?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"wb-listening-spinner","aria-hidden":"true"}),"Transcribing…"]}):"Listening…"}),n.jsxs("div",{className:"wb-listening-row",children:[n.jsx(GL,{sink:e.levels,frozen:s}),n.jsx("button",{type:"button",className:"wb-send","data-variant":"quiet","aria-label":"Discard recording",title:"Discard (Escape)",disabled:s,onClick:()=>e.discard(),children:n.jsx(Te,{name:"close"})}),n.jsx("button",{ref:t,type:"button",className:"wb-send","aria-label":"Stop and transcribe",title:"Stop and transcribe (Enter); Shift sends at once",disabled:s,onClick:r=>e.finish(r.shiftKey),children:n.jsx(Te,{name:"check"})})]})]})}function GL({sink:e,frozen:t}){const[s,r]=d.useState(()=>Array(WL).fill(0));return d.useEffect(()=>{if(!t)return e.current=i=>r(a=>[...a.slice(1),i]),()=>{e.current=null}},[t]),n.jsx("div",{className:"wb-wave","aria-hidden":"true","data-testid":"waveform",children:s.map((i,a)=>n.jsx("span",{className:"wb-wave-bar",style:{"--level":i.toFixed(3)}},a))})}const YL="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",Xl="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",qL=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function QL(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(YL);let s;try{s=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(qL(i))return null;throw new Error(Xl)}try{const i=e.document??document,a=i.createElement("video");a.muted=!0,a.playsInline=!0,a.srcObject=s,await new Promise((h,f)=>{a.onloadedmetadata=()=>h(),a.onerror=()=>f(new Error(Xl))}),await a.play(),await new Promise(h=>{const f=a.requestVideoFrameCallback;typeof f=="function"?f.call(a,()=>h()):setTimeout(h,120)});const o=i.createElement("canvas");o.width=a.videoWidth,o.height=a.videoHeight;const l=o.getContext("2d");if(!l||o.width===0)throw new Error(Xl);l.drawImage(a,0,0);const c=await new Promise(h=>o.toBlob(h,"image/png"));if(!c)throw new Error(Xl);const u=(((r=e.now)==null?void 0:r.call(e))??new Date).toISOString().slice(0,19).replace("T"," ").replace(/:/g,".");return new File([c],`Tab ${u}.png`,{type:"image/png"})}finally{s.getTracks().forEach(i=>i.stop())}}const ey="Send files once the agent has answered.",yp="wb-composer-input",Ig=d.forwardRef(function({disabled:t,running:s,onSend:r,onStop:i,agentName:a,draft:o,model:l,setupHref:c,thinking:u,onThinking:h,onOpenFile:f,mentions:p,history:m,threadKey:j,conversationId:w,readAloud:b,onReadAloud:v,placeholder:x},y){var Lr;const g=j?`buddi.draft.${j}`:null,N=z=>{if(!z)return"";try{return window.localStorage.getItem(z)??""}catch{return""}},[k,S]=d.useState(()=>N(g)),[C,R]=d.useState([]),[E,P]=d.useState(!1),[O,U]=d.useState(null),[T,M]=d.useState(!1),L=d.useRef(null),K=d.useRef(null),[D,q]=d.useState(null),[F,H]=d.useState(0),le=D&&p?p.filter(z=>z.handle.toLowerCase().startsWith(D.query.toLowerCase())||z.name.toLowerCase().startsWith(D.query.toLowerCase())).slice(0,6):[],ie=(z,ve)=>{if(!p||p.length===0){q(null);return}const Ye=z.slice(0,ve),ht=/(^|\s)@([\w-]*)$/.exec(Ye);if(!ht){q(null);return}q({start:ve-ht[2].length-1,query:ht[2]}),H(0)},ae=z=>{if(!D)return;const ve=K.current,Ye=ve?ve.selectionStart:k.length,ht=`${k.slice(0,D.start)}@${z} ${k.slice(Ye)}`;S(ht),X<0&&ne(ht),q(null),window.requestAnimationFrame(()=>{if(!ve)return;const tn=D.start+z.length+2;ve.focus(),ve.setSelectionRange(tn,tn),Ce()})},ge=m??[],[X,de]=d.useState(-1),me=d.useRef(k),$e=d.useRef(g);if($e.current!==g){$e.current=g;const z=N(g);me.current=z,z!==k&&(S(z),de(-1),q(null))}const ne=z=>{if(me.current=z,!!g)try{z===""?window.localStorage.removeItem(g):window.localStorage.setItem(g,z)}catch{}},be=z=>{S(z),q(null);const ve=K.current;ve&&(ve.value=z,ve.setSelectionRange(z.length,z.length)),window.requestAnimationFrame(Ce)},Ne=z=>!z.value.slice(0,z.selectionStart??z.value.length).includes(`
104
+ `),Qe=()=>k===""||X>=0&&k===ge[X],Ie=()=>{X<0||(de(-1),be(me.current))},rt=C.some(z=>z.state==="uploading"),fe=C.length>0,xe=s&&fe,ze=!t&&!rt&&!xe&&k.trim()!=="",Oe=z=>{for(const ve of Array.from(z??[])){const Ye=`${ve.name}:${ve.size}:${Math.random().toString(36).slice(2,8)}`,ht=ve.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(ve):null;R(tn=>[...tn,{key:Ye,filename:ve.name||"Pasted image",mime:ve.type||"application/octet-stream",sizeBytes:ve.size,thumbnail:ht,state:"uploading"}]),Le.attach(ve).then(tn=>R(Ps=>Ps.map(Lt=>Lt.key===Ye?{...Lt,state:"ready",uploaded:tn}:Lt))).catch(tn=>R(Ps=>Ps.map(Lt=>Lt.key===Ye?{...Lt,state:"failed",error:tn instanceof oe?tn.message:String(tn)}:Lt)))}},it=z=>{z.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(z.thumbnail)},ke=z=>{const ve=C.find(Ye=>Ye.key===z);ve&&(it(ve),ve.state==="ready"&&ve.uploaded&&Le.discardAttachment(ve.uploaded.artifactId).catch(()=>{})),R(Ye=>Ye.filter(ht=>ht.key!==z))};d.useImperativeHandle(y,()=>({addFiles:z=>{var ve;Oe(z),(ve=K.current)==null||ve.focus()},focus:()=>{var z;return(z=K.current)==null?void 0:z.focus()}}));const De=d.useRef(C);De.current=C,d.useEffect(()=>()=>De.current.forEach(it),[]);const ee=d.useRef(0);d.useEffect(()=>{if(!o||o.at===ee.current)return;ee.current=o.at,S(ve=>ve.trim()===""?o.text:ve),X<0&&k.trim()===""&&ne(o.text);const z=K.current;z&&(z.focus(),window.requestAnimationFrame(()=>{z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,200)}px`,z.setSelectionRange(z.value.length,z.value.length)}))},[o]);const Ce=()=>{const z=K.current;z&&(z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,200)}px`)},B=z=>{const ve=(z??k).trim();if(z===void 0?!ze:t||rt||xe||ve==="")return;const Ye=C.filter(ht=>ht.state==="ready"&&ht.uploaded).map(ht=>ht.uploaded);r(ve,Ye),C.forEach(it),de(-1),ne(""),S(""),R([]),window.requestAnimationFrame(Ce)},Ee=z=>{if(D&&le.length>0){if(z.key==="ArrowDown"){z.preventDefault(),H(ve=>(ve+1)%le.length);return}if(z.key==="ArrowUp"){z.preventDefault(),H(ve=>(ve-1+le.length)%le.length);return}if(z.key==="Enter"||z.key==="Tab"){z.preventDefault(),ae(le[F].handle);return}if(z.key==="Escape"){z.preventDefault(),q(null);return}}if(z.key==="ArrowUp"&&!z.shiftKey&&!z.altKey&&!z.metaKey&&!z.ctrlKey){const ve=z.currentTarget;if(ge.length>0&&X+1<ge.length&&Ne(ve)&&Qe()){z.preventDefault(),X<0&&(me.current=k),de(X+1),be(ge[X+1]);return}}if(z.key==="ArrowDown"&&!z.shiftKey&&!z.altKey&&!z.metaKey&&!z.ctrlKey&&X>=0&&k===ge[X]){if(z.preventDefault(),X===0){Ie();return}de(X-1),be(ge[X-1]);return}if(z.key==="Escape"&&X>=0){z.preventDefault(),Ie();return}z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),B())},St=z=>{var Ye;const ve=Array.from(((Ye=z.clipboardData)==null?void 0:Ye.files)??[]);ve.length!==0&&(z.preventDefault(),Oe(ve))},nt=C.filter(z=>z.state==="failed"),Mt=nt.length,Ke=HL({conversationId:w??null,onNotice:U,onText:(z,ve)=>{const Ye=k.trim()===""?z:`${k.replace(/\s+$/,"")} ${z}`;if(ve){B(Ye);return}be(Ye),X<0&&ne(Ye)}}),jt=Ke.state!=="idle",us=d.useRef(!1);return d.useEffect(()=>{var z;us.current&&!jt&&((z=K.current)==null||z.focus(),window.requestAnimationFrame(Ce)),us.current=jt},[jt]),n.jsx("div",{className:"wb-composer","data-testid":"composer",children:n.jsxs("div",{className:"wb-composer-box","data-focused":T||jt,"data-disabled":t,"data-listening":jt||void 0,children:[C.length>0?n.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:C.map(z=>n.jsx("span",{role:"listitem",children:n.jsx(ld,{name:z.filename,mime:z.mime,sizeBytes:z.sizeBytes,thumbnail:z.thumbnail,state:z.state,error:z.error,onRemove:()=>ke(z.key),...f&&z.state==="ready"&&z.uploaded?{onOpen:()=>f(XL(z.uploaded))}:{},size:"sm"})},z.key))}):null,n.jsxs("label",{className:"sr-only",htmlFor:yp,children:["Message ",a]}),n.jsx("textarea",{id:yp,ref:K,value:k,rows:2,placeholder:s?`${a} is working…`:x??`Message ${a}`,onChange:z=>{S(z.target.value),X<0&&ne(z.target.value),ie(z.target.value,z.target.selectionStart??z.target.value.length),Ce()},onFocus:()=>M(!0),onBlur:()=>M(!1),onKeyDown:Ee,onPaste:St,disabled:t,hidden:jt}),jt?n.jsx(KL,{voice:Ke}):null,!jt&&D&&le.length>0?n.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:le.map((z,ve)=>n.jsxs("button",{type:"button",role:"option","aria-selected":ve===F,className:"wb-mention","data-active":ve===F||void 0,onMouseDown:Ye=>{Ye.preventDefault(),ae(z.handle)},children:[n.jsxs("span",{className:"wb-mention-handle",children:["@",z.handle]}),n.jsx("span",{className:"wb-mention-name",children:z.name})]},z.handle))}):null,n.jsxs("div",{className:"wb-composer-row",hidden:jt,children:[n.jsx("input",{ref:L,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:z=>{Oe(z.target.files),z.target.value=""}}),n.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Attach a file",title:"Attach a file — or paste one, or drop it anywhere on the chat",onClick:()=>{var z;return(z=L.current)==null?void 0:z.click()},disabled:t,children:n.jsx(Te,{name:"clip"})}),n.jsx(VL,{disabled:t,voice:Ke}),n.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Snap a tab",title:"Snap a tab — one picture of another tab in this browser, attached here",onClick:()=>{U(null),P(!0),QL().then(z=>{var ve;z&&(Oe([z]),(ve=K.current)==null||ve.focus())}).catch(z=>U(z instanceof Error?z.message:String(z))).finally(()=>P(!1))},disabled:t||E,children:n.jsx(Te,{name:"camera"})}),l?c?n.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[n.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),l]}):n.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[n.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),l]}):null,h?n.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":Jl(u),disabled:t||s,title:s?`Wait for ${a} to finish — this run started with thinking ${Jl(u)?"on":"off"}`:Jl(u)?"Reasoning before the answer is on. Click to turn it off — answers come back faster.":"Reasoning before the answer is off. Click to turn it on.",onClick:()=>h(Jl(u)?"off":"on"),children:[n.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,v?n.jsx("button",{type:"button",className:"ui-icon-btn wb-read-aloud","data-size":"sm","aria-label":"Read replies aloud","aria-pressed":!!b,title:b?"Replies are read aloud. Click to stop.":"Read replies aloud, through the voice chosen in Settings → Speech",onClick:()=>v(!b),children:n.jsx(Te,{name:"speaker"})}):null,n.jsx("span",{className:"wb-hint","data-shown":k!==""&&!s||Mt>0||xe||O!==null,"data-tone":Mt>0||O!==null?"critical":void 0,children:Mt>0?Mt===1&&((Lr=nt[0])!=null&&Lr.error)?nt[0].error:`${Mt} files failed to upload and will not be sent`:O!==null?O:xe?ey:"Enter sends, Shift+Enter for a new line"}),s?n.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,n.jsx("button",{className:"wb-send","aria-label":"Send",title:xe?ey:rt?"Waiting for the upload to finish":s?`Send — ${a} picks it up between steps`:"Send",onClick:()=>B(),disabled:!ze,children:n.jsx(Te,{name:"send"})})]})]})})});function Jl(e){return(e??"on")==="on"}function XL(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function JL({question:e,disabled:t,onAnswer:s,onSkip:r}){const[i,a]=d.useState("");return d.useEffect(()=>{if(t)return;const o=l=>{l.key!=="Escape"||l.defaultPrevented||(l.preventDefault(),r())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,r]),n.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[n.jsxs("div",{className:"wb-question-head",children:[n.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),n.jsx(I,{className:"wb-question-skip",variant:"ghost",size:"sm",disabled:t,onClick:r,title:"Skip this question (Esc). The agent carries on without an answer.",children:"Skip"}),n.jsx("strong",{children:e.question})]}),e.options.length>0?n.jsx("div",{className:"wb-question-options",children:e.options.map((o,l)=>n.jsxs("button",{className:"wb-question-option","data-recommended":o.recommended||void 0,disabled:t,onClick:()=>s(o.label,o.id),children:[n.jsx("span",{className:"wb-question-number",children:l+1}),n.jsxs("span",{children:[n.jsxs("span",{className:"wb-question-label",children:[o.label,o.recommended?n.jsx("em",{children:"Recommended"}):null]}),o.hint?n.jsx("small",{children:o.hint}):null]})]},o.id))}):null,e.allowOther?n.jsxs("form",{className:"wb-question-other",onSubmit:o=>{o.preventDefault(),i.trim()&&s(i.trim())},children:[n.jsx("input",{value:i,onChange:o=>a(o.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),n.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,n.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function ZL(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function eF(e){const t=e/36e5;if(t>=1&&Number.isInteger(t))return`${t} hour${t===1?"":"s"}`;const s=Math.round(e/6e4);return`${s} minute${s===1?"":"s"}`}function tF(e){const{lifetime:t,startedAt:s,now:r,timezone:i}=e;if(!t||t.messages<=0)return{text:"New conversation",title:"Nothing has been said in this one yet.",tone:"quiet"};const a=`A conversation ends after ${eF(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(ZL(t,r))return{text:`${o} · your next message starts a fresh one`,title:a,tone:"note"};const l=s?_e(s,r):"";return{text:l===""?o:`${o} · started ${l}`,title:s?`Started ${He(s,i)}. ${a}`:a,tone:"quiet"}}const Rc=320,sN="buddi.chatWidth";function nF({timezone:e,agents:t,agentId:s,defaultAgentId:r=null,group:i=null,onEditGroup:a,onSelectAgent:o,attention:l,agentsInHeader:c,narrow:u,canvasOpen:h,onOpenCanvas:f,onCloseCanvas:p,newConversationSignal:m,requestedConversationId:j,requestedTab:w,onConversationOpened:b}){var vx,jx,yx,wx,bx,kx;const v=Rg(),[x,y]=d.useState([]),[g,N]=d.useState(null),[k,S]=d.useState(null),[C,R]=d.useState(null),[E,P]=d.useState([]),[O,U]=d.useState([]),[T,M]=d.useState(null),[L,K]=d.useState(!1),[D,q]=d.useState(new Map),[F,H]=d.useState(null),[le,ie]=d.useState(BL),[ae,ge]=d.useState([]),[X,de]=d.useState(!1),me=d.useRef(0),$e=d.useRef(null),[ne,be]=d.useState(!1),Ne=d.useRef(m??0),Qe=d.useRef(s),Ie=d.useRef({agentId:s,conversationId:g});Ie.current={agentId:s,conversationId:g};const rt=le[g??""]??[],[fe,xe]=d.useState(null),[ze,Oe]=d.useState(null),[it,ke]=d.useState(null),[De,ee]=d.useState([]),[Ce,B]=d.useState(!1),[Ee,St]=d.useState(()=>Date.now()),[nt,Mt]=d.useState(sF),Ke=d.useRef(null),[jt,us]=d.useState(null),[Lr,z]=d.useState(!1),[ve,Ye]=d.useState(null),[ht,tn]=d.useState(zS),Ps=d.useRef(ht);Ps.current=ht;const Lt=d.useRef(null),[nn,ji]=d.useState(null),pC=d.useCallback($=>{tn($),WS($),$||Ra()},[]),[mC,gC]=d.useState(null),[xC,Zg]=d.useState(null);d.useEffect(()=>{if(!s)return;const $=oF(s);$&&Ye({text:$,at:Date.now()})},[s]);const Fr=i?`group:${i.id}`:s??null,_n=[...t.top,...t.middle,...t.bottom],je=_n.find($=>$.id===s)??null,vC=re(()=>A.providerAccounts(),[]),yi=i?i.members.map($=>_n.find(G=>G.id===$)).filter($=>!!$):[],[md,ex]=d.useState(null);d.useEffect(()=>{let $=!1;return Le.views().then(G=>{$||y(G.views??[])}).catch(()=>{}),()=>{$=!0}},[]),d.useEffect(()=>{if(!s)return;const $=Qe.current===s;if(Qe.current=s,$&&j&&j===Ie.current.conversationId)return;let G=!1;return N(null),S(null),R(null),P([]),xe(null),K(!1),H(null),ge([]),dl(null),be(!1),us(null),j?(j!=="new"?N(j):R(Fr),()=>{G=!0}):((i?Le.groupConversations(i.id):Le.conversations(s)).then(he=>{if(G)return;const we=[...he.conversations??[]].sort(rF)[0];we?(N(we.id),b==null||b(s,we.id)):R(Fr)}).catch(()=>{G||R(Fr)}),()=>{G=!0})},[s,i==null?void 0:i.id,Fr,j,b]);const ds=d.useCallback($=>Le.conversation($).then(G=>{if(Ie.current.conversationId===$){if(G.agentId!==Ie.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");S(G),P(he=>he.filter(we=>!Sf(G,we)))}}).catch(G=>{Ie.current.conversationId===$&&xe(rr(G))}),[]);d.useEffect(()=>{if(!g)return;let $=!1;return q(new Map),U([]),Le.conversation(g).then(G=>{if(!$){if(G.agentId!==s)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");S(G),P(he=>he.filter(we=>!Sf(G,we)))}}).catch(G=>{$||xe(rr(G))}),()=>{$=!0}},[g,s]),d.useEffect(()=>{if(!g)return;let $=!1;const G=window.setInterval(()=>{Le.conversation(g).then(he=>{$||he.agentId!==Ie.current.agentId||(S(he),P(we=>we.filter(Be=>!Sf(he,Be))))}).catch(()=>{})},3e3);return()=>{$=!0,window.clearInterval(G)}},[g,s]),d.useEffect(()=>{if(!g)return;const $=ed({url:Le.streamUrl(g),onEvent:G=>{var he;switch(G.name){case"run.started":Lt.current=null,K(!0),M(null),ex(Ft(G.data.agentId));break;case"live":{const we=Ft(G.data.runId)??"",Be=Number(G.data.turn??0),Ae=G.data.kind==="thinking"?"thinking":"text",sn=Ft(G.data.text)??"",Ms=Date.now();if(Ae==="text"){const fs=Lt.current;Lt.current=fs&&fs.runId===we&&fs.turn===Be?{...fs,text:fs.text+sn}:{runId:we,turn:Be,text:sn}}M(fs=>{const Si=fs&&fs.runId===we&&fs.turn===Be?fs:{runId:we,turn:Be,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return Ae==="thinking"?{...Si,thinking:Si.thinking+sn,thinkingStartedAt:Si.thinkingStartedAt??Ms}:{...Si,text:Si.text+sn,textStartedAt:Si.textStartedAt??Ms}});break}case"live.snapshot":{const we=Ft(G.data.runId)??"",Be=Number(G.data.turn??0),Ae=Ft(G.data.text)??"",sn=Ft(G.data.thinking)??"",Ms=Number(G.data.startedAt??Date.now());Lt.current={runId:we,turn:Be,text:Ae},M({runId:we,turn:Be,text:Ae,thinking:sn,thinkingStartedAt:sn?Ms:null,textStartedAt:Ae?Ms:null,settled:!1});break}case"live.settle":{const we=Ft(G.data.runId)??"",Be=Number(G.data.turn??0);M(Ae=>Ae&&Ae.runId===we&&Ae.turn===Be?{...Ae,settled:!0}:Ae);break}case"tool.called":{const we=Ft(G.data.toolUseId)??Ft(G.data.id),Be=Ft(G.data.name)??Ft(G.data.tool)??"tool";we&&U(Ae=>[...Ae.filter(sn=>sn.toolUseId!==we),{toolUseId:we,name:Be,startedAt:Date.now()}]);break}case"tool.result":{const we=Ft(G.data.toolUseId)??Ft(G.data.id);we&&U(Be=>Be.filter(Ae=>Ae.toolUseId!==we)),ds(g);break}case"message.appended":ds(g).then(()=>{M(we=>we!=null&&we.settled?null:we)});break;case"awaiting-approval":{const we=Ft(G.data.approvalId)??Ft(G.data.actionId),Be=Ft(G.data.toolUseId);we&&Be&&q(Ae=>new Map(Ae).set(Be,we)),U(Ae=>Ae.filter(sn=>sn.toolUseId!==Be)),ds(g);break}case"run.finished":{K(!1),U([]),M(null),ex(null);const we=Ft(G.data.message);xe(we??null);const Be=((he=Lt.current)==null?void 0:he.text.trim())??"";Lt.current=null,!we&&Be!==""&&Ps.current&&mu(Be,g).then(Ae=>{Ae&&ji(Ae)}),ds(g);break}}}});return()=>$.close()},[g,ds]),d.useEffect(()=>{const $=window.setInterval(()=>St(Date.now()),O.length===0?6e4:1e3);return()=>window.clearInterval($)},[O.length]);const ul=re(()=>s&&g?A.browser({agentId:s,conversationId:g}):Promise.resolve(void 0),[s,g],1500),wi=ul.error?void 0:ul.data,Ma=wi!=null&&wi.session&&wi.session.agentId===s&&wi.session.conversationId===g?wi:void 0,Ur=$L(Ma,s,g),Br=(Ur==null?void 0:Ur.id)??null,[$a,jC]=d.useState(null),tx=Ma==null?void 0:Ma.mode;d.useEffect(()=>{Ur&&s&&g&&jC({agentId:s,conversationId:g,tab:OL(Ur,tx)})},[Br,tx,s,g]);const yC=$a&&$a.agentId===s&&$a.conversationId===g&&!rt.includes($a.tab.id)?$a.tab:null,Vt=Ur??yC,wC=d.useMemo(()=>_L((k==null?void 0:k.messages)??[]),[k]),[bC,dl]=d.useState(null),kC=d.useMemo(()=>D_({messages:(k==null?void 0:k.messages)??[],descriptors:x}),[k,x]),bi=JD(kC,g??null),gd=eL(i?null:s),nx=d.useMemo(()=>ZD((k==null?void 0:k.messages)??[]),[k]),Nn=d.useMemo(()=>{const G=L_({messages:(k==null?void 0:k.messages)??[],descriptors:x,awaiting:D,served:bi.served,...Vt?{folded:Tc}:{}}).filter(he=>he.source==="approval"||!rt.includes(he.id));if(F&&!rt.includes(F)&&!G.some(he=>he.id===F)){const he=z_((k==null?void 0:k.messages)??[],F,{redactInputOf:Tc});he&&!Tc.has(he.tool)&&G.push(he)}Vt&&G.push(Vt);for(const he of ae)G.push(pO(he));return gd&&G.unshift(tL(gd,nx)),jt?[...G,nL(jt)]:G},[k,x,D,jt,Br,Vt==null?void 0:Vt.title,F,le,g,ae,bi.served,gd,nx]),SC=d.useMemo(()=>{var G;const $=[];for(const he of(k==null?void 0:k.messages)??[]){if(he.role!=="user"||he.speaker&&he.speaker!=="owner")continue;const we=(G=he.blocks.find(Be=>Be.type==="text"))==null?void 0:G.text.trim();we&&$.unshift(we)}return $},[k]),xd=d.useMemo(()=>Nn.filter($=>$.source==="approval"),[Nn]),fl=xd.at(-1)??null,hl=d.useMemo(()=>[...xd.map($=>({approvalId:$.props.approvalId,toolUseId:$.id})),...((k==null?void 0:k.delegatedApprovals)??[]).map($=>({approvalId:$.approvalId,toolUseId:$.toolUseId??"",askedBy:dF($.chain,_n)}))],[xd,k==null?void 0:k.delegatedApprovals]),Oa=d.useMemo(()=>{for(let $=Nn.length-1;$>=0;$-=1){const G=Nn[$];if(G!=null&&G.substantial)return G.id}return null},[Nn]),pl=d.useRef(null),vd=((vx=Nn.filter($=>($.source!=="browser"||$.pinned===!0)&&$.id!==vp).at(-1))==null?void 0:vx.id)??((jx=Nn.filter($=>$.id!==vp).at(-1))==null?void 0:jx.id)??null;d.useEffect(()=>{if(Oa&&Oa!==pl.current){pl.current=Oa,H(Oa);return}F===null&&vd&&H(vd)},[Oa,F,vd]);const sx=d.useRef(bi.live);d.useEffect(()=>{const $=sx.current;sx.current=bi.live;const G=[...bi.live].filter(Be=>!$.has(Be));if(G.length===0||fl||F!==null&&F!==pl.current)return;const we=[...Nn].reverse().find(Be=>Be.source==="descriptor"&&Be.renderer==="preview"&&Be.props.target!==null&&G.includes(na(Be.props.target)));we&&H(we.id)},[bi.live,Nn,fl,F]);const rx=d.useRef(null);d.useEffect(()=>{Br!==rx.current&&(rx.current=Br,Br&&!fl&&H(Br))},[Br,fl]);const ix=d.useRef(null),_a=w==="browser"?(Vt==null?void 0:Vt.id)??null:null;d.useEffect(()=>{!_a||ix.current===_a||(ix.current=_a,H(_a))},[_a]);const jd=(Vt==null?void 0:Vt.id)??null;d.useEffect(()=>{!jd||!F||Jj((k==null?void 0:k.messages)??[],F)!==null&&(dl(F),H(jd))},[jd,F,k]);const ax=$=>{ge(G=>G.some(he=>he.artifactId===$.artifactId)?G:[...G,$]),H(Ac($.artifactId)),u&&(f==null||f())},ml=!i&&je&&!je.available?aS(je):null,ox=ep(i?null:je),lx=((k==null?void 0:k.offers)??[]).filter($=>!De.includes($.id)&&Date.parse($.expiresAt)>Ee),NC=je&&xC===je.id?mC:(je==null?void 0:je.thinking)??null,CC=$=>{if(!je)return;const G=je.id;Zg(G),gC($),A.setAgentEngine(G,{thinking:$}).catch(he=>{Zg(null),xe(he instanceof oe?he.message:String(he))})},cx=($,G)=>{if(!s)return;const he=G.map(Ae=>Ae.artifactId),we=L,Be={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:$},...G.map(Ae=>({type:"attachment",artifactId:Ae.artifactId,filename:Ae.filename,mime:Ae.mime,kind:Ae.kind,sizeBytes:Ae.sizeBytes}))],...we?{speaker:XS}:{}};P(Ae=>we?[...Ae,Be]:[Be]),xe(null),Oe(null),K(!0),(i?Le.sendToGroup(i.id,{...g?{conversationId:g}:{},text:$,attachmentIds:he}):Le.send(s,{...g?{conversationId:g}:{},text:$,attachmentIds:he})).then(async Ae=>{Ie.current.agentId!==s||Ie.current.conversationId!==g||(Oe(Ae.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),Ae.conversationId!==g?(S(null),N(Ae.conversationId)):await ds(Ae.conversationId),Ae.queued===!0&&P(sn=>sn.filter(Ms=>Ms.id!==Be.id)),b==null||b(s,Ae.conversationId))}).catch(Ae=>{P(sn=>sn.filter(Ms=>Ms.id!==Be.id)),xe(rr(Ae)),K(!1)})},EC=$=>{xe(null),ke($),ee(G=>[...G,$]),A.takeOffer($,g??void 0).then(G=>{G.runId&&(Oe(null),K(!0)),g&&ds(g)}).catch(G=>{ee(he=>he.filter(we=>we!==$)),xe(rr(G)),g&&ds(g)}).finally(()=>ke(null))},AC=($,G)=>ux({answer:$,...G?{optionId:G}:{}}),TC=()=>ux({answer:"",skipped:!0}),ux=$=>{const G=k==null?void 0:k.question;G&&(xe(null),B(!0),K(!0),Le.answerQuestion(G.id,$).then(()=>{if(g)return ds(g)}).catch(he=>{xe(rr(he)),K(!1)}).finally(()=>B(!1)))},RC=()=>{if(s){if(jt){us(null);return}z(!0),A.agentProfile(s).then($=>{us($),H(jp($.id)),u&&(f==null||f())}).catch($=>xe(rr($))).finally(()=>z(!1))}},IC=$=>{Ye({text:$.prompt,at:Date.now()}),o($.agentId),u&&(p==null||p())},PC=()=>{g&&Le.cancel(g).catch($=>xe(rr($))).finally(()=>{K(!1),U([])})},gl=d.useCallback(()=>{if(N(null),S(null),P([]),K(!1),xe(null),Oe(null),U([]),q(new Map),H(null),ge([]),dl(null),pl.current=null,i){Le.startGroupConversation(i.id).then(({conversationId:$})=>{N($),s&&(b==null||b(s,$))}).catch($=>xe(rr($)));return}R(Fr),s&&(b==null||b(s,"new"))},[s,i,Fr,b]);d.useEffect(()=>{m&&m!==Ne.current&&(Ne.current=m,gl())},[m,gl]);const dx=$=>{g&&ds(g),A.overview().catch(()=>{}),$.state!=="pending"&&q(G=>new Map([...G].filter(([,he])=>he!==$.id)))},xl=d.useRef(!1);d.useEffect(()=>{const $=he=>{if(!xl.current)return;const we=Math.max(Rc,Math.min(720,he.clientX-52));Mt(we)},G=()=>{if(xl.current){xl.current=!1;try{nt!==null&&window.localStorage.setItem(sN,String(nt))}catch{}}};return window.addEventListener("pointermove",$),window.addEventListener("pointerup",G),()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",G)}},[nt]);const MC=((yx=_n.find($=>$.id===r))==null?void 0:yx.name)??null,fx=i?[]:s$(je,MC),hx=!(k&&k.conversationId===g)&&!(!g&&C!==null&&C===Fr),px=hx?n.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&je?n.jsx(oO,{quiet:!0,still:!0,className:"wb-chat-field",children:n.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[n.jsx(gn,{agents:_n,id:je.id,size:"xl"}),n.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${je.name}.`}),n.jsx("p",{className:"wb-chat-intro",children:r$(je)}),fx.length>0?n.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${je.name}`,children:fx.map($=>n.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var G;Ye({text:$,at:Date.now()}),(G=$e.current)==null||G.focus()},children:$},$))}):null]})}):null,mx=n.jsx(UD,{renderables:Nn,activeId:F,onActivate:H,onClose:$=>{jt&&$===jp(jt.id)?us(null):ae.some(G=>Ac(G.artifactId)===$)?ge(G=>G.filter(he=>Ac(he.artifactId)!==$)):g&&ie(G=>{const he={...G,[g]:[...new Set([...G[g]??[],$])]};return Zj(he),he}),F===$&&H(null)},timezone:e,onDecided:dx,onChangeAgent:IC,agents:_n,browserPanel:Vt?n.jsx(RL,{status:Ma,error:ul.error,reload:ul.reload,steps:wC,live:Ur!==null,focusedStepId:bC},Vt.id):null,descriptors:x,grantedTools:i?yi.flatMap($=>$.tools??[]):(je==null?void 0:je.tools)??[],...je?{agentName:je.name}:{},loading:hx,...!i&&je?{face:n.jsx(gn,{agents:_n,id:je.id,size:"xl"})}:{}}),gx=(bx=(wx=[...(k==null?void 0:k.messages)??[],...E].find($=>$.role==="user"))==null?void 0:wx.blocks.find($=>$.type==="text"))==null?void 0:bx.text.trim(),xx=gx?gx.split(`
105
+ `)[0]:"New conversation",ki=tF({lifetime:(k==null?void 0:k.lifetime)??null,startedAt:(k==null?void 0:k.startedAt)??null,now:Ee,timezone:e});return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"wb-chat",ref:Ke,style:u||nt===null?void 0:{width:nt},"data-sized":!u&&nt!==null?"true":void 0,"data-testid":"chat-column","data-dropping":X||void 0,onDragEnter:$=>{Zl($)&&($.preventDefault(),me.current+=1,de(!0))},onDragOver:$=>{Zl($)&&($.preventDefault(),$.dataTransfer.dropEffect="copy")},onDragLeave:$=>{Zl($)&&(me.current=Math.max(0,me.current-1),me.current===0&&de(!1))},onDrop:$=>{var G;Zl($)&&($.preventDefault(),me.current=0,de(!1),s&&((G=$e.current)==null||G.addFiles($.dataTransfer.files)))},children:[X?n.jsx("div",{className:"wb-drop","aria-hidden":"true",children:n.jsxs("div",{className:"wb-drop-card",children:[n.jsx(iF,{}),n.jsx("strong",{children:"Drop to attach"}),n.jsx("span",{children:je?`It goes with your next message to ${je.name}`:"Pick an agent first"})]})}):null,n.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&je?al(il(je)):{},children:[n.jsxs("div",{className:"wb-head-row",children:[i?n.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:yi.slice(0,3).map($=>n.jsx(gn,{agents:_n,id:$.id,size:"sm"},$.id))}):je?n.jsx("a",{className:"wb-head-face",href:lt(je.id),"aria-label":`${je.name}'s page`,children:n.jsx(gn,{agents:_n,id:je.id})}):null,n.jsxs("div",{className:"wb-head-text",children:[i?n.jsx("span",{className:"wb-head-title",children:i.name}):n.jsx("span",{className:"wb-head-title",title:xx,children:xx}),n.jsx("span",{className:"wb-head-meta","data-tone":ki.tone,title:i?`${yi.map($=>$.name).join(", ")}. Coordinator: ${(je==null?void 0:je.name)??i.coordinator}.`:ki.title,children:i?`${yi.map($=>$.name).join(", ")} · ${ki.text}`:je?n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"wb-head-name",href:lt(je.id),title:`${je.name}'s page`,children:je.name})," ",n.jsxs("span",{className:"wb-head-handle",children:["@",je.handle]}),` · ${ki.tone==="quiet"&&ki.text==="New conversation"?`on ${v}`:ki.text}`]}):"No agent"})]}),n.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!s,onClick:()=>{be(!1),gl()},children:n.jsx(Te,{name:"plus",size:16})}),n.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":ne,"data-open":ne?"true":void 0,disabled:!s,onClick:()=>be($=>!$),children:n.jsx(lF,{})}),u?n.jsxs("button",{className:"ui-btn",onClick:f,disabled:Nn.length===0,children:["Canvas",Nn.length>0?` (${Nn.length})`:""]}):null,n.jsx(uF,{disabled:!s,items:i?[...yi.map($=>({label:$.name,hint:$.id===i.coordinator?"Coordinator · open page":"Member · open page",href:lt($.id)})),...a?[{label:"Members…",hint:"Name, coordinator, who is in the room",testId:"group-members",onSelect:a}]:[]]:[{label:jt?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:Lr,onSelect:RC},...je?[{label:"Set up",hint:"Identity, model and access",href:lt(je.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:lt(je.id)}]:[]]})]}),c?n.jsx(lS,{agents:t,currentId:s,attention:l,onSelect:o,orientation:"horizontal"}):null]}),ne&&s?n.jsx(UL,{agentId:s,...i?{groupId:i.id}:{},currentId:g,timezone:e,onNew:()=>{be(!1),gl()},onSelect:$=>{if($===g){be(!1);return}be(!1),S(null),P([]),K(!1),H(null),xe(null),Oe(null),ge([]),N($),b==null||b(s,$,!1)}}):null,s&&g?n.jsx(PL,{agentId:s,conversationId:g},`${s}:${g}`):null,fe?n.jsx("div",{className:"wb-chat-notice",children:n.jsx(se,{message:fe})}):null,ze?n.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:ze}):null,k!=null&&k.carriedOver?n.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:k.carriedOver}):null,n.jsx(Ag,{messages:[...(k==null?void 0:k.messages)??[],...E],live:O,now:Ee,working:L,partial:T,agents:_n,...k!=null&&k.runs?{runs:k.runs}:{},...i?{speakers:_n,coordinatorId:i.coordinator}:{},...md?{workingAs:((kx=_n.find($=>$.id===md))==null?void 0:kx.name)??md}:{},onOpenFile:ax,onReadAloud:($,G)=>{ji(null),mu(G,g??void 0,$).then(he=>{he&&ji(he)})},onOpen:$=>{if(Vt){const G=Jj([...(k==null?void 0:k.messages)??[],...E],$);if(G){dl(G),H(Vt.id),u&&(f==null||f());return}}g&&ie(G=>{const he={...G,[g]:(G[g]??[]).filter(we=>we!==$)};return Zj(he),he}),H($),u&&(f==null||f())},...je?{agentName:je.name,agentId:je.id}:{},...px?{empty:px}:{},emptyHint:je?`Nothing here yet. Ask ${je.name} for something.`:"Loading agents…"}),lx.length>0?n.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:lx.map($=>n.jsx("button",{className:"ui-btn",disabled:it!==null,title:$.prompt,onClick:()=>EC($.id),children:$.label},$.id))}):null,ml?n.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:n.jsxs(W,{tone:"warning",role:"status",children:[ml," ",n.jsx("a",{href:Ze(ox.section),children:ox.label})]})}):hl.length>0?n.jsx(wD,{approvals:hl,timezone:e,now:Ee,version:k,onDecided:dx,onSay:$=>cx($,[]),onOpenFull:$=>{H($),u&&(f==null||f())}}):null,ml||hl.length>0?null:k!=null&&k.question?n.jsx(JL,{question:k.question,disabled:Ce||L,onAnswer:AC,onSkip:TC},k.question.id):null,ml?null:n.jsxs("div",{hidden:hl.length>0||!!(k!=null&&k.question),"data-testid":"composer-slot",children:[n.jsx(Ig,{ref:$e,disabled:!s,running:L,onSend:cx,onStop:PC,agentName:i?i.name:(je==null?void 0:je.name)??"the agent",draft:ve,history:SC,threadKey:g??(i?`group:${i.id}`:s),model:i?null:(je==null?void 0:je.model)??null,setupHref:i?null:je?lt(je.id,"setup","brain"):null,thinking:NC,...!i&&je&&ik(ak(je,vC.data))?{onThinking:CC}:{},...i?{mentions:yi.map($=>({handle:$.handle,name:$.name}))}:{},onOpenFile:ax,conversationId:g??null,readAloud:ht,onReadAloud:pC}),nn?n.jsx("p",{className:"wb-voice-note",role:"status",children:nn}):null]})]}),u?h?n.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[n.jsxs("div",{className:"wb-sheet-head",children:[n.jsx("strong",{children:"Canvas"}),n.jsx("button",{className:"ui-btn",onClick:p,children:"Close"})]}),mx]}):null:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:$=>{var G,he;xl.current=!0,(he=(G=$.currentTarget).setPointerCapture)==null||he.call(G,$.pointerId)},onKeyDown:$=>{const G=he=>{var we;return he??((we=Ke.current)==null?void 0:we.offsetWidth)??Rc};$.key==="ArrowLeft"&&Mt(he=>Math.max(Rc,G(he)-16)),$.key==="ArrowRight"&&Mt(he=>Math.min(720,G(he)+16))}}),mx]})]})}function sF(){try{const e=window.localStorage.getItem(sN),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Rc?t:null}catch{return null}}function rF(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function Ft(e){return typeof e=="string"&&e!==""?e:null}function rr(e){return e instanceof oe||e instanceof Error?e.message:String(e)}function Sf(e,t){var r;const s=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!s)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const a=e.messages[i];if(a.role!=="user")continue;const o=a.blocks.find(l=>l.type==="text");if(o)return o.text.trim()===s}return!1}function Zl(e){var s;const t=(s=e.dataTransfer)==null?void 0:s.types;return!!(t&&Array.from(t).includes("Files"))}function iF(){return n.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),n.jsx("path",{d:"M5 19.5v2a2.5 2.5 0 0 0 2.5 2.5h13a2.5 2.5 0 0 0 2.5-2.5v-2"})]})}const wp="buddi.chatDraft";function aF(e,t){try{window.sessionStorage.setItem(wp,JSON.stringify({agentId:e,text:t}))}catch{}}function oF(e){try{const t=window.sessionStorage.getItem(wp);if(!t)return null;const s=JSON.parse(t);return s.agentId!==e||typeof s.text!="string"?null:(window.sessionStorage.removeItem(wp),s.text)}catch{return null}}function lF(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),n.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function cF(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[n.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function uF({items:e,disabled:t}){const[s,r]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!s)return;const a=l=>{i.current&&!i.current.contains(l.target)&&r(!1)},o=l=>{l.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",o),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",o)}},[s]),n.jsxs("div",{className:"wb-head-menu",ref:i,children:[n.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":"More about this agent","aria-haspopup":"menu","aria-expanded":s,"data-open":s?"true":void 0,disabled:t,onClick:()=>r(a=>!a),children:n.jsx(cF,{})}),s?n.jsx("div",{className:"ui-menu wb-head-menu-list",role:"menu",children:e.map(a=>a.href?n.jsxs("a",{className:"ui-menu-item",role:"menuitem",href:a.href,onClick:()=>r(!1),children:[n.jsx("span",{className:"ui-menu-item-text",children:a.label}),a.hint?n.jsx("span",{className:"ui-menu-item-hint",children:a.hint}):null]},a.label):n.jsxs("button",{className:"ui-menu-item",role:"menuitem","data-testid":a.testId,disabled:a.disabled,onClick:()=>{var o;r(!1),(o=a.onSelect)==null||o.call(a)},children:[n.jsx("span",{className:"ui-menu-item-text",children:a.label}),a.hint?n.jsx("span",{className:"ui-menu-item-hint",children:a.hint}):null]},a.label))}):null]})}function dF(e,t){const s=a=>{var o;return`@${((o=t.find(l=>l.id===a))==null?void 0:o.handle)??a}`},[r,...i]=e;return r===void 0?"":[s(r),...i.map(a=>`asked by ${s(a)}`)].join(", ")}let ty=!1;const fF=new Set(["missing","unconfigured","not-english"]);async function mu(e,t,s=null){const r=HS(s);try{const i=await Le.say({text:e,...t?{conversationId:t}:{}});return Lj(r)&&await N_(i.audioUrl,i.mime,s),null}catch(i){Lj(r)&&Ra();const a=i instanceof oe&&i.detail&&typeof i.detail=="object"?i.detail.reason:void 0;return typeof a=="string"&&fF.has(a)&&(s!==null||!ty)?(ty=!0,i.message):null}}let Dn=null;function hF(e){if(Cc(e)!==null)return!1;const t=eS(e);return t!==zt&&t!==br}function pF({agent:e,agents:t,open:s,onOpenChange:r,navigate:i}){const a=d.useRef(null),o=d.useRef(s),l=`Ask ${e.name}`,[c,u]=d.useState(!1);return d.useEffect(()=>{if(s||!c||!Dn)return;const h=ed({url:Le.streamUrl(Dn.conversationId),lastEventId:Dn.lastEventId??null,onEvent:f=>{f.name==="run.finished"&&u(!1)}});return()=>h.close()},[s,c]),d.useEffect(()=>{const h=f=>{!f.altKey||f.ctrlKey||f.metaKey||f.code!=="Slash"||(f.preventDefault(),r(!s))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s,r]),d.useEffect(()=>{var h;o.current&&!s&&((h=a.current)==null||h.focus()),o.current=s},[s]),s?n.jsx(gF,{agent:e,agents:t,navigate:i,onClose:()=>r(!1),onBusy:u}):n.jsxs(_o,{children:[n.jsx(Do,{asChild:!0,children:n.jsx("button",{ref:a,type:"button",className:"wb-ask-fab","data-busy":c?"true":void 0,"aria-label":l,onClick:()=>r(!0),children:n.jsx(mF,{busy:c})})}),n.jsx(Lo,{children:n.jsx(Fo,{className:"ui-tip",side:"left",sideOffset:8,children:l})})]})}function mF({busy:e}){const[t,s]=d.useState(!1);return t?n.jsx(IS,{size:"lg"}):n.jsx(sd,{state:e?"working":"idle",className:"wb-ask-fab-face",onStillError:()=>s(!0)})}function gF({agent:e,agents:t,navigate:s,onClose:r,onBusy:i}){const a=d.useRef(null),[o,l]=d.useState(Dn&&Dn.agentId===e.id?Dn.conversationId:null),[c,u]=d.useState(null),[h,f]=d.useState([]),[p,m]=d.useState([]),[j,w]=d.useState(null),[b,v]=d.useState(!1),[x,y]=d.useState(!1),[g,N]=d.useState(null),[k,S]=d.useState(null),[C,R]=d.useState(Date.now()),[E,P]=d.useState(zS),O=d.useRef(E);O.current=E;const[U,T]=d.useState(null),M=d.useRef(null),L=d.useCallback(async ie=>{try{const ae=await Le.conversation(ie);u(ae),f(ge=>ge.filter(X=>!xF(ae,X)))}catch{}},[]);d.useEffect(()=>{o&&L(o)},[o,L]),d.useEffect(()=>{if(!o)return;const ie=ed({url:Le.streamUrl(o),onEvent:ae=>{var ge;switch(ae.name){case"run.started":M.current=null,v(!0),w(null);break;case"live":{const X=Cn(ae.data.runId)??"",de=Number(ae.data.turn??0),me=ae.data.kind==="thinking"?"thinking":"text",$e=Cn(ae.data.text)??"",ne=Date.now();if(me==="text"){const be=M.current;M.current=be&&be.runId===X&&be.turn===de?{...be,text:be.text+$e}:{runId:X,turn:de,text:$e}}w(be=>{const Ne=be&&be.runId===X&&be.turn===de?be:{runId:X,turn:de,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return me==="thinking"?{...Ne,thinking:Ne.thinking+$e,thinkingStartedAt:Ne.thinkingStartedAt??ne}:{...Ne,text:Ne.text+$e,textStartedAt:Ne.textStartedAt??ne}});break}case"live.snapshot":{const X=Cn(ae.data.runId)??"",de=Number(ae.data.turn??0),me=Cn(ae.data.text)??"",$e=Cn(ae.data.thinking)??"",ne=Number(ae.data.startedAt??Date.now());M.current={runId:X,turn:de,text:me},v(!0),w({runId:X,turn:de,text:me,thinking:$e,thinkingStartedAt:$e?ne:null,textStartedAt:me?ne:null,settled:!1});break}case"live.settle":{const X=Cn(ae.data.runId)??"",de=Number(ae.data.turn??0);w(me=>me&&me.runId===X&&me.turn===de?{...me,settled:!0}:me);break}case"tool.called":{const X=Cn(ae.data.toolUseId)??Cn(ae.data.id),de=Cn(ae.data.name)??Cn(ae.data.tool)??"tool";X&&m(me=>[...me.filter($e=>$e.toolUseId!==X),{toolUseId:X,name:de,startedAt:Date.now()}]);break}case"tool.result":{const X=Cn(ae.data.toolUseId)??Cn(ae.data.id);X&&m(de=>de.filter(me=>me.toolUseId!==X)),L(o);break}case"message.appended":case"awaiting-approval":L(o).then(()=>w(X=>X!=null&&X.settled?null:X));break;case"run.finished":{v(!1),m([]),w(null);const X=Cn(ae.data.message);N(X??null);const de=((ge=M.current)==null?void 0:ge.text.trim())??"";M.current=null,!X&&de!==""&&O.current&&mu(de,o).then(me=>{me&&T(me)}),L(o);break}}}});return()=>{Dn&&Dn.conversationId===o&&(Dn.lastEventId=ie.lastEventId()),ie.close()}},[o,L]),d.useEffect(()=>{i(b||x)},[b,x,i]),d.useEffect(()=>{if(p.length===0)return;const ie=window.setInterval(()=>R(Date.now()),1e3);return()=>window.clearInterval(ie)},[p.length]);const K=(ie,ae)=>{y(!0),N(null);const ge={id:`local-${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:ie}]};f(X=>[...X,ge]),(async()=>{try{const X=o??(await Le.startConversation(e.id)).conversationId;X!==o&&(Dn={agentId:e.id,conversationId:X},l(X));const de=await Le.send(e.id,{conversationId:X,text:ie,...ae.length>0?{attachmentIds:ae.map(me=>me.artifactId)}:{}});de.conversationId!==X&&(Dn={agentId:e.id,conversationId:de.conversationId},l(de.conversationId)),v(!0),L(de.conversationId)}catch(X){f(de=>de.filter(me=>me.id!==ge.id)),N(X instanceof oe?X.message:String(X)),S({text:ie,at:Date.now()})}finally{y(!1)}})()},D=()=>{o&&Le.cancel(o).catch(ie=>N(String(ie))).finally(()=>v(!1))},q=()=>{var ie;Dn=null,l(null),u(null),f([]),m([]),w(null),v(!1),N(null),(ie=a.current)==null||ie.focus()},F=ie=>{P(ie),WS(ie),ie||Ra()},H=o?Ve(e.id,o):Ve(e.id),le=[...(c==null?void 0:c.messages)??[],...h];return n.jsxs(rO,{title:e.name,label:`${e.name}, a quick chat`,onClose:r,onOpenAutoFocus:ie=>{var ae;ie.preventDefault(),(ae=a.current)==null||ae.focus()},onCloseAutoFocus:ie=>ie.preventDefault(),actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",variant:"ghost",onClick:q,disabled:o===null&&h.length===0,children:"New"}),n.jsx(Zt,{size:"sm",variant:"ghost",href:H,onClick:ie=>{ie.preventDefault(),s(H)},children:"Open in Chat"})]}),children:[n.jsx("div",{className:"wb-ask-thread",children:n.jsx(Ag,{messages:le,live:p,now:C,working:b||x,partial:j,agents:t,agentName:e.name,agentId:e.id,onOpen:()=>s(H),onReadAloud:(ie,ae)=>{T(null),mu(ae,o??void 0,ie).then(ge=>{ge&&T(ge)})},emptyHint:`Ask ${e.name} anything, without leaving this page.`})}),n.jsxs("div",{className:"wb-ask-compose",children:[g?n.jsx(se,{message:g}):null,n.jsx(Ig,{ref:a,disabled:x||!e.available,running:b,onSend:K,onStop:D,agentName:e.name,placeholder:`Message ${e.name}…`,draft:k,threadKey:`dock.${o??e.id}`,conversationId:o,readAloud:E,onReadAloud:F}),U?n.jsx("p",{className:"wb-voice-note",role:"status",children:U}):null]})]})}function Cn(e){return typeof e=="string"?e:null}function xF(e,t){var r;const s=(r=t.blocks)==null?void 0:r.find(i=>i.type==="text");return!s||s.type!=="text"?!1:e.messages.some(i=>i.role==="user"&&(i.blocks??[]).some(a=>a.type==="text"&&a.text.includes(s.text)))}const rN=3;function vF(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function jF(e,t){return e?t?"above-dock":"above-button":"corner"}function yF({placement:e,children:t}){return n.jsx("div",{className:"wb-toast-stack","data-placement":e,children:t})}function wF(e){return e.state==="shown"&&e.seenAt===null}function bF(e){const[t,s]=d.useState([]),r=d.useRef(new Set),i=d.useRef(new Set),a=d.useCallback(()=>{e&&A.notifications(20).then(({notifications:l})=>{const c=l.filter(u=>wF(u)&&!r.current.has(u.id));s(u=>{const h=new Set(u.map(p=>p.id)),f=c.filter(p=>!h.has(p.id));return f.length===0?u:[...u,...f].sort((p,m)=>m.createdAt.localeCompare(p.createdAt))})}).catch(()=>{})},[e]);d.useEffect(()=>{for(const l of t.slice(0,rN))i.current.has(l.id)||(i.current.add(l.id),A.notificationSeen(l.id).catch(()=>{}))},[t]);const o=d.useCallback(l=>{r.current.add(l),s(c=>c.filter(u=>u.id!==l))},[]);return{queue:t,refresh:a,dismiss:o}}function kF({queue:e,agents:t,navigate:s,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,rN),a=e.length-i.length;return n.jsxs("section",{className:"nt-toasts","aria-label":"Notifications",children:[i.map(o=>n.jsxs("div",{className:"ui-toast nt-toast","data-tone":vF(o.kind),role:"status",children:[o.agentId?n.jsx(gn,{agents:t,id:o.agentId,size:"sm"}):null,n.jsxs("div",{className:"nt-toast-main",children:[n.jsx("div",{className:"ui-toast-title",children:o.title}),o.text?n.jsx("div",{className:"ui-toast-body nt-toast-line",children:SF(o.text)}):null,o.link?n.jsx("a",{className:"nt-toast-link",href:o.link,onClick:l=>{l.preventDefault(),r(o.id),s(o.link)},children:"See"}):null]}),n.jsx("button",{type:"button",className:"nt-toast-x","aria-label":`Dismiss ${o.title}`,onClick:()=>r(o.id),children:"×"})]},o.id)),a>0?n.jsxs("p",{className:"nt-toasts-more",children:["and ",a," more"]}):null]})}function SF(e){var t;return((t=e.split(`
106
+ `).find(s=>s.trim()!==""))==null?void 0:t.trim())??""}const NF=3e4,CF=1e3;function EF(e,t,s){const r=d.useRef(t);r.current=t;const i=d.useRef(s);i.current=s,d.useEffect(()=>{if(!e)return;let a=!1,o=-1/0,l=null,c=null,u=!0;const h=()=>document.visibilityState!=="hidden",f=v=>{var x;o=Date.now(),A.presence(v).catch(y=>{var g;y instanceof oe&&y.status===401&&(a=!0,(g=i.current)==null||g.call(i))}),v==="active"&&((x=r.current)==null||x.call(r))},p=v=>{if(a||(l=v,c!==null))return;const x=o+CF-Date.now();if(x<=0){l=null,f(v);return}c=window.setTimeout(()=>{if(c=null,a||l===null)return;const y=l;l=null,f(y)},x)},m=()=>{u=!0,h()&&p("active")},j=()=>{u=!1,p("away")},w=()=>p(h()?"active":"away");h()&&p("active");const b=window.setInterval(()=>{h()&&u&&p("active")},NF);return window.addEventListener("focus",m),window.addEventListener("blur",j),document.addEventListener("visibilitychange",w),()=>{a=!0,window.clearInterval(b),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",m),window.removeEventListener("blur",j),document.removeEventListener("visibilitychange",w)}},[e])}function ny({agents:e,group:t,onClose:s,onCreated:r,onSaved:i,onArchived:a}){return!t&&!iS(e)?n.jsx(en,{title:"A new group",onClose:s,children:n.jsxs(W,{children:["A group needs two agents. Make another one with ",e$(e)," first."]})}):n.jsx(TF,{agents:AF(e,t),group:t??null,onClose:s,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...a?{onArchived:a}:{}})}function AF(e,t){const s=rS(e),r=((t==null?void 0:t.members)??[]).filter(i=>!s.some(a=>a.id===i)).map(i=>e.find(a=>a.id===i)).filter(i=>i!==void 0);return[...s,...r]}function TF({agents:e,group:t,onClose:s,onCreated:r,onSaved:i,onArchived:a}){var C,R;const o=t!==null,[l,c]=d.useState((t==null?void 0:t.name)??""),[u,h]=d.useState((t==null?void 0:t.members)??[]),[f,p]=d.useState((t==null?void 0:t.coordinator)??((C=e.find(E=>E.roles.includes(pg)))==null?void 0:C.id)??((R=e[0])==null?void 0:R.id)??""),[m,j]=d.useState(!1),[w,b]=d.useState(!1),[v,x]=d.useState(null),y=[...new Set([f,...u])].filter(Boolean),g=l.trim()!==""&&f!==""&&y.length>=2,N=E=>h(P=>P.includes(E)?P.filter(O=>O!==E):[...P,E]),k=async()=>{j(!0),x(null);try{t?i==null||i(await Le.updateGroup(t.id,{name:l.trim(),coordinator:f,members:y})):r==null||r(await Le.createGroup({name:l.trim(),coordinator:f,members:y.filter(E=>E!==f)}))}catch(E){x(E instanceof oe?E.message:String(E))}finally{j(!1)}},S=async()=>{if(t){j(!0),x(null);try{await Le.archiveGroup(t.id),a==null||a(t.id)}catch(E){x(E instanceof oe?E.message:String(E)),j(!1)}}};return n.jsx(en,{title:o?`${t.name}: members`:"A new group",onClose:s,children:n.jsxs(V,{children:[n.jsx(J,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:n.jsx("input",{value:l,autoFocus:!0,maxLength:80,onChange:E=>c(E.target.value),placeholder:"Household finances"})}),n.jsx(J,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:n.jsx("select",{value:f,onChange:E=>p(E.target.value),children:e.map(E=>n.jsx("option",{value:E.id,children:E.name},E.id))})}),n.jsx(J,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:n.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(E=>E.id!==f).map(E=>n.jsxs("label",{className:"group-pick-row","data-on":u.includes(E.id)||void 0,children:[n.jsx("input",{type:"checkbox",checked:u.includes(E.id),onChange:()=>N(E.id)}),n.jsx(gn,{agents:e,id:E.id,size:"sm"}),n.jsxs("span",{className:"group-pick-text",children:[n.jsx("span",{className:"group-pick-name",children:E.name}),n.jsx("span",{className:"group-pick-desc",children:E.description})]})]},E.id))})}),n.jsx(W,{children:"Members read what is said in this group and what they recall from shared and group memory. Nothing an agent knows privately is brought in on its own: what enters the room is seen by the room."}),o?n.jsx(W,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,v?n.jsx(W,{tone:"critical",children:v}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!g||m,onClick:()=>void k(),children:m?o?"Saving…":"Creating…":o?"Save":"Create group"})]}),o?n.jsx("div",{className:"group-archive",children:w?n.jsxs(V,{children:[n.jsxs(W,{tone:"warning",children:["Archive ",t.name,"? It leaves the rail and takes no new requests. Everything said in it stays readable."]}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:()=>b(!1),children:"Keep it"}),n.jsx(I,{variant:"danger",disabled:m,"data-testid":"group-archive-confirm",onClick:()=>void S(),children:"Archive group"})]})]}):n.jsx(I,{variant:"ghost",disabled:m,"data-testid":"group-archive",onClick:()=>b(!0),children:"Archive group"})}):null]})})}function Pg(e){const[t,s]=d.useState(null),[r,i]=d.useState(null),[a,o]=d.useState(null);return{busy:t,note:r,failure:a,decide:async(c,u,h,f)=>{var m,j,w,b;s(c),o(null),i(null);let p;try{const v=f?await A.decide(c,u,h,f):await A.decide(c,u,h);p={decision:u,...(m=v.execution)!=null&&m.state?{state:v.execution.state}:{},...v.execution&&"result"in v.execution?{result:v.execution.result}:{}},i(u==="reject"?`Rejected ${v.action.tool}.`:((j=v.execution)==null?void 0:j.state)==="succeeded"?`Approved and done: ${v.action.tool}.`:`Approved ${v.action.tool}: ${((w=v.execution)==null?void 0:w.state)??"no execution"}${(b=v.execution)!=null&&b.message?` (${v.execution.message})`:""}`)}catch(v){o(v instanceof Error?v.message:String(v))}finally{s(null),e(p)}}}}function Mg({action:e,timezone:t,busy:s,onDecide:r,agentName:i}){var h,f;const[a,o]=d.useState(!1),{values:l,controls:c}=yg(e.choices),u=p=>l?r(e.id,"approve",p,l):r(e.id,"approve",p);return n.jsxs(Kn,{tone:"accent",title:e.tool,meta:n.jsxs(n.Fragment,{children:[n.jsxs(ye,{children:["v",e.toolVersion]}),n.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[n.jsx(bt,{children:e.preview}),n.jsxs("p",{className:"ui-card-meta",children:["Expires ",He(e.expiresAt,t)," (",_e(e.expiresAt),"). Policy v",e.policyVersion,", args ",Bo(e.argsHash,12),e.jobId?`, job ${Bo(e.jobId)}`:"","."]}),c,n.jsxs(Q,{children:[n.jsx(I,{variant:"good",disabled:s,onClick:()=>u(),children:(h=e.permissionScopes)!=null&&h.length?"Allow once":"Approve"}),(f=e.permissionScopes)!=null&&f.length?n.jsxs(n.Fragment,{children:[n.jsx(I,{disabled:s,onClick:()=>u("conversation"),children:"Auto: this conversation"}),n.jsx(I,{disabled:s,onClick:()=>u("always"),children:"Always: this agent"})]}):null,n.jsx(I,{variant:"danger",disabled:s,onClick:()=>r(e.id,"reject"),children:"Reject"}),n.jsx(I,{variant:"ghost",onClick:()=>o(p=>!p),"aria-expanded":a,children:a?"Hide envelope":"Show envelope"})]}),a?n.jsxs("div",{className:"ui-card-foot",children:[n.jsx(Y,{title:"Envelope: everything that decides what the world will see",children:n.jsx(bt,{children:bn(e.envelope)})}),n.jsx(Y,{title:"Canonical arguments",children:n.jsx(bt,{children:bn(e.canonicalArgs)})})]}):null]})}function $g(e,t,s){const[r,i]=d.useState(!1),[a,o]=d.useState(null),[l,c]=d.useState(null);return{accept:()=>{e&&(i(!0),c(null),A.acceptPluginAgent(e,t).then(h=>{o(h.agent)}).catch(h=>c(h instanceof oe?h.message:String(h))).finally(()=>i(!1)))},busy:r,created:a,failure:l}}function iN({agent:e}){return n.jsxs(W,{tone:"good",role:"status",children:["@",e.handle," is ready. ",n.jsxs("a",{href:Ve(e.id),children:["Talk to @",e.handle]})]})}function aN(e,t,s){const r=e.canonicalArgs;return e.tool==="platform.accept_plugin_agent"&&(r==null?void 0:r.plugin)===t&&typeof r.agent=="string"&&r.agent.toLowerCase()===s.toLowerCase()}function RF(e,t){var i;const s=re(()=>A.approvals(),[e,t],15e3);return{action:((i=s.data)==null?void 0:i.pending.find(a=>aN(a,e,t)))??null,reload:s.reload}}function IF({action:e,onDecided:t}){const{busy:s,failure:r,decide:i}=Pg(a=>t(a));return n.jsxs(V,{gap:"sm",children:[n.jsx(Mg,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:s===e.id,onDecide:(a,o,l,c)=>{i(a,o,l,c)}}),n.jsx(se,{message:r})]})}function Og({plugin:e,agent:t,text:s,label:r,handle:i,onDismiss:a}){var f;const o=$g(e,t),l=RF(e,t),[c,u]=d.useState(null),h=o.created??c;if(h)return n.jsx(iN,{agent:h});if(l.action){const p=i??((f=/@(\S+)/.exec(r))==null?void 0:f[1])??t;return n.jsxs(V,{gap:"sm",children:[n.jsx("span",{children:s}),n.jsx(IF,{action:l.action,onDecided:m=>{(m==null?void 0:m.decision)==="approve"&&m.state==="succeeded"?u({id:t,handle:p,name:p}):l.reload()}})]})}return n.jsxs(V,{gap:"sm",children:[n.jsxs(Q,{children:[n.jsx("span",{children:s}),n.jsx(Es,{}),a?n.jsx(I,{variant:"ghost",disabled:o.busy,onClick:a,children:"Not now"}):null,n.jsx(I,{variant:"accent",disabled:o.busy,onClick:o.accept,children:r})]}),n.jsx(se,{message:o.failure})]})}function oN(){var t;const e=re(()=>A.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function lN({offers:e,reload:t}){return e.length===0?null:n.jsx(Y,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:n.jsx(V,{gap:"sm",divided:!0,children:e.map(s=>n.jsx(Og,{plugin:s.plugin,agent:s.agent,text:s.text,label:`Create @${s.handle}`,handle:s.handle,onDismiss:()=>{A.dismissAgentOffer(s.plugin,s.agent).then(t,t)}},`${s.plugin}/${s.agent}`))})})}const PF=512*1024,MF=/^[A-Za-z0-9+/]*={0,2}$/;function cN(e){const t=e==null?void 0:e.play;if(typeof t!="object"||t===null)return null;const{mime:s,data:r}=t;return typeof s!="string"||!/^audio\/[a-z0-9.+-]+$/i.test(s.split(";")[0].trim())||typeof r!="string"||r===""||!MF.test(r)||Math.floor(r.length*3/4)>PF+2?null:{mime:s,data:r}}function uN(e){const t=e==null?void 0:e.message;return typeof t=="string"&&t.trim()!==""?t:null}let Ds=null,ho=null,Ko=null;const bp=new Set;function dN(){for(const e of bp)e()}function Za(){Ds&&(Ds.onended=null,Ds.onerror=null,Ds.pause()),ho&&URL.revokeObjectURL(ho),ho=null,Ko!==null&&(Ko=null,dN())}async function fN(e,t){Za();const s=atob(e.data),r=new Uint8Array(s.length);for(let i=0;i<s.length;i+=1)r[i]=s.charCodeAt(i);Ds??(Ds=new Audio),ho=URL.createObjectURL(new Blob([r],{type:e.mime})),Ko=t,Ds.onended=Za,Ds.onerror=Za,Ds.src=ho,dN();try{await Ds.play()}catch{throw Za(),new Error("The browser would not play the sound.")}}function sy(e){e!==void 0&&Ko!==e||Za()}function $F(){return d.useSyncExternalStore(e=>(bp.add(e),()=>bp.delete(e)),()=>Ko,()=>null)}const _g=d.createContext(null),gu=d.createContext(!1);function Pt(){const e=d.useContext(_g);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function kp(e,t=new Set){if(Array.isArray(e))for(const s of e)kp(s,t);else if(e&&typeof e=="object"){const s=e.query;typeof s=="string"&&t.add(s);for(const r of Object.values(e))kp(r,t)}return t}function hN(e,t){if(t.size===0)return!1;for(const s of kp(e))if(t.has(s))return!0;return!1}function pN(){const[e,t]=d.useState(!1);return d.useEffect(()=>{if(!e)return;const s=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",s),window.addEventListener("blur",s),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("blur",s)}},[e]),[e,()=>t(s=>!s)]}function mN({revealed:e,onToggle:t}){return n.jsx(I,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function gN(){return n.jsx("p",{className:"muted",children:"Hidden until you show it."})}function xN({children:e}){const[t,s]=pN();return n.jsxs(V,{gap:"sm",children:[n.jsx(Q,{align:"end",children:n.jsx(mN,{revealed:t,onToggle:s})}),t?n.jsx(gu.Provider,{value:!0,children:e}):n.jsx(gN,{})]})}function Dg(e){return e===void 0||e==="neutral"?void 0:e}function Sp(e){return Dg(e)}function OF(e){const t=Dg(e);return t==="accent"?void 0:t}function ts(e,t){if(!t)return!0;const s=Se(e,t.path),r=t.in!==void 0?t.in.includes(s):s===t.equals;return t.not===!0?!r:r}function Lg(e,t,s){if("chat"in t){const a=Re(s,t.chat);return a==null?"":Ve(String(a))}if("proposals"in t)return PM(e.plugin);const r=e.pages.find(a=>a.id===t.page);if((r==null?void 0:r.place)==="settings")return Zu(e.plugin,t.page);const i=t.item===void 0?null:Re(s,t.item);return zo(e.plugin,t.page,i==null?null:String(i))}function _F(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(s,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(s,r)=>{const i=Se(t.row,r);return i==null?"":String(i)})}function Np(e,t){if(e===void 0)return;if(typeof e=="string")return e;const s=Re(t,e);return s==="good"||s==="warning"||s==="critical"||s==="neutral"?s:void 0}function vN(e,t,s){const r={};for(const[i,a]of Object.entries(e??{})){let o;"param"in a?o=s.params[a.param]:"route"in a?o=a.route==="plugin"?s.plugin:a.route==="page"?s.page:s.item:o=Re(t,a),!(o==null||o==="")&&(r[i]=String(o))}return r}function ci(e,t){var r,i,a;const s={};for(const[o,l]of Object.entries(e??{}))if("row"in l)s[o]=Se(t.row,l.row);else if("field"in l){if((r=t.omit)!=null&&r.has(l.field))continue;const c=(i=t.fields)==null?void 0:i[l.field],u=(a=t.shape)==null?void 0:a.find(h=>h.name===l.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;s[o]=c}else"selected"in l?s[o]=t.selected??[]:"param"in l?s[o]=t.scope.params[l.param]:s[o]=Re(t.data,l);return s}function cs(e,t,s){const r=Pt(),i=e?vN(e.params,t,r):{},a=JSON.stringify([(e==null?void 0:e.query)??null,i,r.version]),o=re(()=>e?A.pageQuery(r.plugin,e.query,i).then(l=>l.data):Promise.resolve(void 0),[a],s);return{data:o.data,error:o.error,loading:o.loading}}function ol(){const e=Pt(),t=d.useId(),[s,r]=d.useState(null),[i,a]=d.useState(null),[o,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(null),p=(b,v)=>{if(b.done===void 0)return null;if(typeof b.done=="string")return b.done;const x=Re(v,b.done);return x==null?null:String(x)},m=(b,v,x)=>{const y=b??"refresh";if(typeof y=="object"){const g=Lg(e,y.route,v);g===""?e.refresh():e.navigate(g);return}y==="close"&&(x==null||x()),e.refresh()},j=async(b,v,x)=>{r(b.tool),a(null),l(null);try{const y=await A.pageAct(e.plugin,{tool:b.tool,args:v});if(y.approvalId){u(y.approvalId),f({then:b.then,ref:b,...x?{onDone:x}:{}});return}u(null),f(null);const g=cN(y.result);l(p(b,y.result)??(g?uN(y.result):null)),g&&await fN(g,t),m(b.then,y.result,x)}catch(y){a(y instanceof Error?y.message:String(y)),e.refresh()}finally{r(null)}},w=b=>{if(!b){e.refresh();return}const v=h;if(u(null),f(null),v&&b.decision==="approve"&&b.state==="succeeded"){l(p(v.ref,b.result)),m(v.then,void 0,v.onDone);return}e.refresh()};return{running:s,busy:s!==null,error:i,done:o,approvalId:c,waiting:(h==null?void 0:h.ref.pending)??null,settle:w,run:j}}function pa({action:e,args:t,disabled:s,running:r,count:i,row:a,onRun:o}){const[l,c]=d.useState(!1),u=f=>_F(f,{...i===void 0?{}:{count:i},row:a}),h=u(e.label);return l&&e.confirm?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),n.jsx(I,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),n.jsxs(I,{variant:e.tone==="danger"?"danger":"accent",disabled:s,onClick:()=>{c(!1),o(e,t)},children:["Yes, ",h.toLowerCase()]})]}):n.jsx(I,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:s,onClick:()=>e.confirm?c(!0):o(e,t),children:r&&e.busy?e.busy:h})}function xu({id:e,onDecided:t}){const s=Pt(),r=re(()=>A.approval(e),[e,s.version]),{busy:i,note:a,failure:o,decide:l}=Pg(c=>{t?t(c):s.refresh()});return r.error?n.jsx(se,{message:r.error}):r.data?n.jsxs(V,{children:[n.jsx(Mg,{action:r.data,timezone:s.timezone,busy:i===e,onDecide:(c,u,h,f)=>{l(c,u,h,f)}}),a?n.jsx(W,{tone:"good",role:"status",children:a}):null,n.jsx(se,{message:o})]}):n.jsx(ue,{children:"Loading the approval…"})}function Ia({act:e}){return e.error?n.jsx(se,{message:e.error}):e.approvalId?e.waiting?n.jsxs(V,{children:[n.jsx(W,{role:"status",children:e.waiting}),n.jsx(xu,{id:e.approvalId,onDecided:e.settle})]}):n.jsx(xu,{id:e.approvalId,onDecided:e.settle}):e.done?n.jsx(W,{tone:"good",role:"status",children:e.done}):null}function vu(e,t){const s={};for(const r of e){const i=r.from===void 0?void 0:Se(t,r.from);s[r.name]=r.multiple?Array.isArray(i)?i.map(String):[]:i!==void 0?i:r.type==="checkbox"?!1:""}return s}function DF(e,t,s){const r=Pt(),i=e.optionsFrom,a=i?{...vN(i.query.params,s,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,a,r.version]),l=re(()=>i?A.pageQuery(r.plugin,i.query.query,a).then(c=>c.data):Promise.resolve(void 0),[o]);return i?{options:ui(l.data,i.rows).map(c=>({value:String(Se(c,i.value)??""),label:String(Se(c,i.label)??"")})),loading:l.loading}:{options:e.options??[],loading:!1}}function LF({field:e,fields:t,value:s,values:r,data:i,disabled:a,compact:o,onChange:l}){const c=DF(e,r,i),u={id:`f-${e.name}`,required:e.required,name:e.name,disabled:a,...o&&e.hint?{title:e.hint}:{}},h=o?void 0:e.hint;if(e.type==="select"&&e.multiple){const p=Array.isArray(s)?s.map(String):[],j=e.max!==void 0&&p.length>=e.max?`Up to ${e.max}; remove one to add another.`:void 0;return n.jsx(J,{label:e.label,hint:o?void 0:[h,j].filter(Boolean).join(" ")||void 0,group:!0,children:n.jsx(aO,{id:u.id,label:e.label,options:c.options,value:p,max:e.max,disabled:a,onChange:l})})}if(e.type==="select"){const p=n.jsxs("select",{...u,value:String(s??""),onChange:m=>l(m.target.value),children:[n.jsx("option",{value:"",children:c.loading?"Loading…":"—"}),c.options.map(m=>n.jsx("option",{value:m.value,children:m.label},m.value))]});return e.action&&!o?n.jsx(FF,{field:e,action:e.action,fields:t??[e],values:r,data:i,disabled:a,hint:h,children:p}):n.jsx(J,{label:e.label,hint:h,children:p})}if(e.type==="textarea")return n.jsx(J,{label:e.label,hint:h,wide:!0,children:n.jsx("textarea",{...u,value:String(s??""),onChange:p=>l(p.target.value),rows:6})});if(e.type==="checkbox")return n.jsx(J,{label:e.label,hint:h,inline:!0,wide:!o,children:n.jsx("input",{...u,type:"checkbox",checked:s===!0,onChange:p=>l(p.target.checked)})});const f=e.type==="secret"?"password":e.type==="number"?"number":e.type;return n.jsx(J,{label:e.label,hint:h,children:n.jsx("input",{...u,type:f,value:s==null?"":String(s),min:e.min,max:e.max,step:e.step,...o&&e.hint?{placeholder:e.hint}:{},onChange:p=>l(e.type==="number"?UF(p.target.value):p.target.value)})})}function FF({field:e,action:t,fields:s,values:r,data:i,disabled:a,hint:o,children:l}){const c=Pt(),u=d.useId(),h=$F()===u,[f,p]=d.useState(!1),[m,j]=d.useState(null),[w,b]=d.useState(null),[v,x]=d.useState(null);d.useEffect(()=>()=>sy(u),[u]);const y=Fg(s,r,i),g=t.args!==void 0?ci(t.args,{data:i,fields:r,shape:s,omit:y,scope:c}):Object.fromEntries(Object.entries(r).filter(([S,C])=>!y.has(S)&&C!=="")),N=async()=>{if(h){sy(u);return}p(!0),j(null),b(null),x(null);try{const S=await A.pageAct(c.plugin,{tool:t.tool,args:g});if(S.approvalId){x(S.approvalId);return}j(uN(S.result));const C=cN(S.result);C&&await fN(C,u)}catch(S){b(S instanceof Error?S.message:String(S))}finally{p(!1)}},k=h?"Stop":t.label;return n.jsx(J,{label:e.label,hint:o,action:n.jsx(I,{"data-shape":"icon","aria-label":f?`${t.label}: working`:k,title:k,"aria-busy":f||void 0,"aria-pressed":t.icon==="play"?h:void 0,disabled:a===!0||f,onClick:()=>void N(),children:f?n.jsx("span",{className:"ui-spinner","aria-hidden":"true"}):n.jsx(Te,{name:h?"stop":t.icon??"arrow"})}),after:w?n.jsx(se,{message:w}):v?n.jsx(xu,{id:v,onDecided:()=>x(null)}):m?n.jsx("span",{className:"ui-field-hint",role:"status",children:m}):null,children:l})}function UF(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function jN(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function Fg(e,t,s){const r=jN(t,s);return new Set(e.filter(i=>i.when!==void 0&&!ts(r,i.when)||i.disabledWhen!==void 0&&ts(r,i.disabledWhen)).map(i=>i.name))}function Ug({fields:e,values:t,data:s,disabled:r,compact:i,columns:a,onChange:o}){const l=jN(t,s);return n.jsx(Xs,{dense:i,columns:a,children:e.filter(c=>c.when===void 0||ts(l,c.when)).map(c=>n.jsx(LF,{field:c,fields:e,compact:i,value:t[c.name],values:t,data:s,disabled:r===!0||c.disabledWhen!==void 0&&ts(l,c.disabledWhen),onChange:u=>o(c.name,u)},c.name))})}const Go=d.createContext(!1),yN=d.createContext(!1),wN=d.createContext(!1);function Rs({title:e,note:t,actions:s,children:r}){const i=d.useContext(Go);return n.jsx(Y,{title:e,aside:t,actions:s,panel:i,children:n.jsx(Go.Provider,{value:!1,children:n.jsx(yN.Provider,{value:i,children:r})})})}function Zs({component:e,data:t,choose:s,chosen:r}){const i=Pt(),a=d.useContext(gu);if(!ts(t,e.when))return null;if(e.kind!=="section"&&!a&&hN(e,i.sensitive))return n.jsx(xN,{children:n.jsx(Zs,{component:e,data:t,...s?{choose:s}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return n.jsx(BF,{component:e,data:t});case"notice":return n.jsx(W,{tone:Dg(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(Re(t,e.text)??"")});case"link":return n.jsx(zF,{component:e,data:t});case"progress":return n.jsx(HF,{component:e,data:t});case"chart":return n.jsx(VF,{component:e,data:t});case"stats":return n.jsx(KF,{component:e,data:t});case"list":return n.jsx(YF,{component:e,data:t,...s?{onChoose:s}:{},...r===void 0?{}:{chosen:r}});case"table":return n.jsx(qF,{component:e,data:t});case"detail":return n.jsx(JF,{component:e,data:t});case"form":return n.jsx(ZF,{component:e,data:t});case"search":return n.jsx(n4,{component:e,data:t});case"list-detail":return n.jsx(s4,{component:e,data:t});case"repeat":return n.jsx(r4,{component:e,data:t});case"expand":return n.jsx(i4,{component:e,data:t});case"button":return n.jsx(a4,{component:e,data:t});case"approval":return n.jsx(l4,{component:e,data:t});case"artifact":return n.jsx(c4,{component:e,data:t});case"editor":return n.jsx(u4,{component:e,data:t});case"agent-offer":return n.jsx(o4,{component:e});default:return null}}function BF({component:e,data:t}){const s=Pt(),r=d.useContext(gu),[i,a]=pN(),o=!r&&hN(e.body,s.sensitive),l=o&&!i,c=d.useContext(Go);let u=e.body.length;const h=m=>m.kind==="button"||m.kind==="link"||m.kind==="form"&&m.drawer!==void 0&&!m.title;for(;c&&u>0&&h(e.body[u-1]);)u-=1;const f=e.body.slice(0,u),p=[...e.actions??[],...e.body.slice(u)];return n.jsx(Rs,{title:e.title,note:e.note,actions:p.length>0||o?n.jsxs(n.Fragment,{children:[p.map((m,j)=>n.jsx(Zs,{component:m,data:t},j)),o?n.jsx(mN,{revealed:i,onToggle:a}):null]}):void 0,children:n.jsx(V,{gap:"lg",divided:c,children:l?n.jsx(gN,{}):n.jsx(gu.Provider,{value:r||o,children:f.map((m,j)=>n.jsx(Zs,{component:m,data:t},j))})})})}function zF({component:e,data:t}){const s=Pt(),r=Lg(s,e.to,t);return r===""?null:n.jsx(Q,{children:n.jsx(Zt,{href:r,onClick:i=>{i.preventDefault(),s.navigate(r)},children:e.label})})}function ry(e){return Math.round(e/1e6)}function WF(e,t){const s=Wn(Re(t,e.value))??0,r=e.total?Wn(Re(t,e.total)):null,i=e.total?r&&r>0?s/r:0:s,a=Math.max(0,Math.min(1,i)),o=Math.floor(a*100),l=i>=1,c=e.total&&r&&r>0?`${ry(s)} of ${Math.max(1,ry(r))} MB · ${o}%`:`${o}%`;return{percent:o,full:l,line:c}}function HF({component:e,data:t}){const s=c=>c===void 0?"":typeof c=="string"?c:String(Re(t,c)??""),r=s(e.label),i=s(e.done),{percent:a,full:o,line:l}=WF(e,t);return n.jsxs(V,{gap:"sm",children:[r?n.jsx("span",{children:r}):null,o&&i?n.jsx("span",{role:"status",children:i}):n.jsxs(n.Fragment,{children:[n.jsx(ES,{value:a,label:r||"Progress"}),n.jsx("span",{role:"status",children:l})]})]})}function VF({component:e,data:t}){const s=cs(e.query,t),r=e.rows===void 0?Array.isArray(s.data)?s.data:[]:ui(s.data,e.rows),i=Array.isArray(e.y)?e.y:[e.y],a=r.map(c=>String(Se(c,e.x)??"")),o=i.map(c=>({label:i.length===1?e.label??c:c,values:r.map(u=>Wn(Se(u,c))??null)})),l=e.target?Wn(Re(s.data,e.target))??null:null;return n.jsxs(Rs,{title:e.title,note:e.note,children:[n.jsx(se,{message:s.error}),r.length===0?s.loading||s.data===void 0?n.jsx(ue,{children:"Loading…"}):n.jsx(cd,{text:e.empty??"Nothing recorded yet."}):n.jsx(tO,{xs:a,series:o,type:e.type??"line",target:l,...e.label?{label:e.label}:{},formatX:c=>/^\d{4}-\d{2}-\d{2}/.test(c)?Jh(c):c,formatY:c=>Tt(c,"number",null)})]})}function KF({component:e,data:t}){const s=cs(e.query,t);return n.jsxs(Rs,{title:e.title,note:e.note,children:[n.jsx(se,{message:s.error}),s.data===void 0?n.jsx(ue,{children:e.empty??"Loading…"}):n.jsx(id,{children:e.items.map((r,i)=>n.jsx(ys,{label:r.label,value:Tt(Re(s.data,r.value),r.unit??"text",null),tone:OF(r.tone)},i))})]})}function bN(e,t,s,r){const i=(t.meta??[]).map(u=>String(Re(s,u)??"")).filter(u=>u!==""),a=String(Re(s,t.title)??""),o=t.to&&!r?Lg(e,t.to,s):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,h)=>{const f=Re(s,u.value);if(f==null||f==="")return null;const p=GF(u,f,s);return n.jsx(ye,{tone:Sp(p.tone),children:p.text},h)});return{text:a,href:o,pills:n.jsx(n.Fragment,{children:c}),meta:i.join(" · "),title:o?n.jsx("a",{href:o,onClick:u=>{u.preventDefault(),e.navigate(o)},children:a}):a,sub:t.sub?String(Re(s,t.sub)??""):null,side:n.jsxs(n.Fragment,{children:[c,i.length>0?n.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function GF(e,t,s){const r=String(t),i=e.labels??{},a=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(a,r)?a[r]:Np(e.tone,s)}}function ui(e,t){const s=Se(e,t);return Array.isArray(s)?s:[]}function kN(e,t,s){const r=[],i=new Set;return e.forEach((a,o)=>{const l=t===void 0?void 0:Se(a,t),c=l==null||l===""?null:String(l);if(c===null){console.warn(`buddi: plugin ${s.plugin}, page ${s.page}, ${s.component}: row ${o} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${s.plugin}, page ${s.page}, ${s.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:a})}),r}function YF({component:e,data:t,onChoose:s,chosen:r}){var N;const i=Pt(),a=d.useContext(wN),o=cs(e.query,t),l=ol(),[c,u]=d.useState([]),h=a&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,f=ui(o.data,e.rows),p=e.collapsed?ui(o.data,e.collapsed.rows):[],m={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},j=kN([...f,...p],e.key??((N=e.select)==null?void 0:N.key),m),w=new Map(j.map(k=>[k.row,k.key])),b=new Set(j.map(k=>k.row)),v=new Set(j.filter(({row:k})=>{var S;return((S=e.select)==null?void 0:S.disabledWhen)===void 0||!ts(k,e.select.disabledWhen)}).map(({key:k})=>k)),x=c.filter(k=>v.has(k)),y=d.useMemo(()=>{const k=f.filter(C=>b.has(C));if(!e.groupBy)return[{label:null,rows:k}];const S=new Map;for(const C of k){const R=String(Se(C,e.groupBy.key)??"");S.set(R,[...S.get(R)??[],C])}return[...S].map(([C,R])=>{var E,P;return{label:((P=(E=e.groupBy)==null?void 0:E.labels)==null?void 0:P[C])??C,rows:R}})},[f,e.groupBy,j.length]),g=k=>k.map(S=>{var O;const C=bN(i,e.item,S,s),R=w.get(S);if(h&&(s||C.href))return n.jsx(AS,{href:C.href??"#",current:r===R,onClick:()=>s?s(R):i.navigate(C.href),title:C.text,meta:C.meta,sub:C.sub,side:C.pills},R);const E=((O=e.select)==null?void 0:O.disabledWhen)!==void 0&&ts(S,e.select.disabledWhen),P=(e.actions??[]).filter(U=>ts(S,U.when));return n.jsx(cn,{lead:e.select?n.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(R),onClick:U=>U.stopPropagation(),onChange:U=>u(T=>U.target.checked?[...T,R]:T.filter(M=>M!==R))}):void 0,title:s?n.jsx("a",{href:"#","aria-current":r===R?"true":void 0,onClick:U=>{U.preventDefault(),s(R)},children:C.text}):C.title,sub:C.sub,side:n.jsxs(n.Fragment,{children:[C.side,P.map((U,T)=>n.jsx(pa,{action:U,args:ci(U.args,{data:o.data,row:S,scope:i}),disabled:l.busy,running:l.running===U.tool,row:S,onRun:(M,L)=>void l.run(M,L)},T))]})},R)});return n.jsxs(Rs,{title:e.title,note:e.note,children:[n.jsx(se,{message:o.error}),n.jsx(Ia,{act:l}),y.every(k=>k.rows.length===0)?o.loading?n.jsx(ue,{children:"Loading…"}):n.jsx(cd,{text:e.empty??"Nothing here yet."}):n.jsxs(Xt,{children:[e.select?n.jsx(cn,{lead:n.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:v.size>0&&x.length===v.size,disabled:v.size===0,onChange:k=>u(k.target.checked?[...v]:[])}),title:n.jsxs("span",{className:"muted",children:[v.size," to choose from"]})}):null,y.map((k,S)=>n.jsxs("div",{children:[k.label?n.jsx("div",{className:"ui-list-group",children:k.label}):null,g(k.rows)]},S))]}),e.collapsed&&p.some(k=>b.has(k))?n.jsx(It,{summary:`${e.collapsed.label} (${p.filter(k=>b.has(k)).length})`,children:n.jsx(Xt,{children:g(p.filter(k=>b.has(k)))})}):null,e.bulk&&e.bulk.length>0?n.jsxs(Q,{align:"end",children:[n.jsxs("span",{className:"ui-toolbar-note",children:[x.length," selected"]}),e.bulk.map((k,S)=>{const C=x.length>0||k.all!==!0?x:[...v];return n.jsx(pa,{action:k,args:ci(k.args,{data:o.data,selected:C,scope:i}),count:C.length,disabled:l.busy||C.length===0,running:l.running===k.tool,onRun:(R,E)=>{u([]),l.run(R,E)}},S)})]}):null]})}function qF({component:e,data:t}){const s=Pt(),r=cs(e.query,t),i=ol(),a=ui(r.data,e.rows);return n.jsxs(Rs,{title:e.title,note:e.note,children:[n.jsx(se,{message:r.error}),n.jsx(Ia,{act:i}),a.length===0?r.loading?n.jsx(ue,{children:"Loading…"}):n.jsx(cd,{text:e.empty??"Nothing here yet."}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[e.columns.map(o=>n.jsx("th",{children:o.label},o.key)),e.actions&&e.actions.length>0?n.jsx("th",{"aria-label":"Actions"}):null]})}),n.jsx("tbody",{children:a.map((o,l)=>n.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:Tt(Se(o,c.key),c.type??"text",null);return n.jsx("td",{"data-fit":c.fit,title:QF(c,o,u),children:c.pill?n.jsx(XF,{column:c,row:o}):c.fit==="truncate"?n.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?n.jsx("td",{children:n.jsx(Q,{align:"end",children:e.actions.filter(c=>ts(o,c.when)).map((c,u)=>n.jsx(pa,{action:c,args:ci(c.args,{data:r.data,row:o,scope:s}),disabled:i.busy,running:i.running===c.tool,row:o,onRun:(h,f)=>void i.run(h,f)},u))})}):null]},l))})]})]})}function QF(e,t,s){if(e.hint){const r=Se(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&s?s:void 0}function XF({column:e,row:t}){var o,l;const s=Se(t,e.key);if(Array.isArray(s))return n.jsx(n.Fragment,{children:s.map((c,u)=>{var w;const h=c,f=typeof h=="object"&&h!==null?h.value:c;if(f==null||f==="")return null;const p=typeof h=="object"&&h!==null?h.tone:void 0,m=(w=e.pill)==null?void 0:w.labels,j=m&&Object.prototype.hasOwnProperty.call(m,String(f))?m[String(f)]:Tt(f,e.type??"text",null);return n.jsx(ye,{tone:Sp(Np(typeof p=="string"?p:void 0,t)),children:j},u)})});const r=(o=e.pill)==null?void 0:o.labels,i=String(s),a=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:Tt(s,e.type??"text",null);return n.jsx(ye,{tone:Sp(Np((l=e.pill)==null?void 0:l.tone,t)),children:a})}function JF({component:e,data:t}){const s=cs(e.query,t);return s.error?n.jsx(se,{message:s.error}):s.data===void 0?n.jsx(ue,{children:e.empty??"Loading…"}):n.jsx(Rs,{title:e.title,note:e.note,children:n.jsxs(V,{gap:"lg",children:[e.fields.length>0?n.jsx(Wt,{items:e.fields.map(r=>({key:r.label,label:r.label,value:Tt(Re(s.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>n.jsx(Zs,{component:r,data:s.data},i))]})})}function ZF({component:e,data:t}){const s=Pt(),r=cs(e.initial,t),i=ol(),[a,o]=d.useState(!1),l=JSON.stringify([r.data??null,s.version]),c=n.jsx(e4,{component:e,data:t,initialData:r.data,act:i,onDone:()=>o(!1)},l);return e.drawer?n.jsxs(Y,{title:e.title,aside:e.note,actions:n.jsx(I,{variant:"accent",onClick:()=>o(!0),children:e.drawer.button}),children:[n.jsx(Ia,{act:i}),a?n.jsx(en,{title:e.drawer.title,onClose:()=>o(!1),children:c}):null]}):n.jsxs(Rs,{title:e.title,note:e.note,children:[n.jsx(se,{message:r.error}),c]})}function e4({component:e,data:t,initialData:s,act:r,onDone:i}){const a=d.useContext(yN),o=Pt(),[l,c]=d.useState(()=>vu(e.fields,s)),u=Fg(e.fields,l,s),h=e.fields.some(f=>f.required&&!u.has(f.name)&&(l[f.name]===""||l[f.name]===void 0||Array.isArray(l[f.name])&&l[f.name].length===0));return n.jsxs(V,{children:[n.jsx(Ug,{fields:e.fields,columns:e.columns,values:l,data:s,onChange:(f,p)=>c(m=>({...m,[f]:p}))}),e.drawer?null:n.jsx(Ia,{act:r}),n.jsx(Q,{align:"end",className:a?"ui-panel-foot":void 0,children:n.jsx(pa,{action:e.submit,args:ci(e.submit.args,{data:t,fields:l,shape:e.fields,omit:u,scope:o}),disabled:r.busy||h,running:r.running===e.submit.tool,onRun:(f,p)=>void r.run(f,p,i)})})]})}function t4(e,t){var r;if(e.type==="checkbox")return e.label;const s=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${s?s.label:t}`}function iy(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function n4({component:e,data:t}){const s=Pt(),[r,i]=d.useState(()=>vu(e.fields,t)),[a,o]=d.useState(e.auto===!0),[l,c]=d.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),h=cs(a&&u?e.query:void 0,t),f=ui(h.data,e.rows),p=e.count===void 0?void 0:Se(h.data,e.count),m=e.note===void 0?void 0:Se(h.data,e.note),j=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==j),b=C=>{s.setParams(Object.fromEntries(e.fields.map(R=>[R.name,String(C[R.name]??"")||null]))),o(!0)},v=(C,R)=>{const E={...r,[C]:R};i(E),e.auto&&b(E)},x=()=>{const C=vu(e.fields,null);i(C),e.auto?b(C):(s.setParams(Object.fromEntries(e.fields.map(R=>[R.name,null]))),o(!1))},y=a?w.filter(C=>iy(s.params[C.name])):[],g=j?y.map(C=>n.jsx(cu,{label:C.label,onRemove:()=>{const R={...r,[C.name]:C.type==="checkbox"?!1:""};i(R),b(R)},children:t4(C,String(s.params[C.name]))},C.name)):[],N=w.filter(C=>iy(r[C.name])).length,k=e.auto&&!e.reset?null:n.jsxs(n.Fragment,{children:[e.reset?n.jsx(I,{variant:"ghost",onClick:x,children:"Clear"}):null,e.auto?null:n.jsx(I,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),S=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return n.jsx(Rs,{title:e.title,children:n.jsxs(V,{children:[n.jsx(RS,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&b(r)},main:j?n.jsx("input",{id:`f-${j.name}`,name:j.name,type:j.type==="email"?"email":"search","aria-label":j.label,placeholder:j.hint??j.label,title:j.hint,required:j.required,value:String(r[j.name]??""),onChange:C=>v(j.name,C.target.value)}):void 0,filters:w.length>0?n.jsx(Ug,{fields:w,values:r,data:t,compact:!0,onChange:v}):void 0,...j&&w.length>0?{filtersOpen:l,onToggleFilters:()=>c(C=>!C),active:N}:{},chips:g.length>0?g:void 0,actions:k}),n.jsx(se,{message:h.error}),a&&(p!==void 0||m!==void 0)?n.jsxs("p",{className:"ui-card-meta",children:[p===void 0?"":`${Tt(p,"number",null)} in all. `,m===void 0?"":String(m)]}):null,a?f.length===0?n.jsx(ue,{children:h.loading?"Searching…":e.empty??"Nothing matches."}):n.jsx("div",{className:"ui-panel","data-flush":"true",children:n.jsx(Xt,{children:f.map((C,R)=>{const E=bN(s,S,C);return n.jsx(cn,{title:E.title,sub:E.sub,side:E.side},R)})})}):null]})})}function s4({component:e,data:t}){const s=Pt(),r=e.selection==="local",[i,a]=d.useState(null),o=r?i:s.params[e.param]??s.item,l=r&&i!==null?{...s,params:{...s.params,[e.param]:i}}:null,c=n.jsx(V,{gap:"lg",divided:!0,children:e.detail.map((u,h)=>n.jsx(Zs,{component:u,data:t},h))});return n.jsx(Go.Provider,{value:!1,children:n.jsx(TS,{list:n.jsx(wN.Provider,{value:!0,children:n.jsx(Zs,{component:e.list,data:t,chosen:o??null,...r?{choose:a}:{}})}),detail:o?l?n.jsx(_g.Provider,{value:l,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function r4({component:e,data:t}){const s=Pt(),[r,i]=d.useState(!1),a=cs(e.query,t,r&&e.poll?e.poll.seconds*1e3:void 0),o=e.poll!==void 0&&a.data!==void 0&&ts(a.data,e.poll.while);d.useEffect(()=>i(o),[o]);const l=ui(a.data,e.rows);return n.jsxs(Rs,{title:e.title,note:e.note,children:[n.jsx(se,{message:a.error}),l.length===0?a.loading?n.jsx(ue,{children:"Loading…"}):n.jsx(cd,{text:e.empty??"Nothing here yet."}):n.jsx(V,{gap:"lg",divided:!0,children:kN(l,e.key,{plugin:s.plugin,page:s.page,component:`repeat "${e.title??e.rows}"`}).map(({key:c,row:u})=>n.jsx(Y,{children:n.jsx(V,{children:e.body.map((h,f)=>n.jsx(Zs,{component:h,data:u},f))})},c))})]})}function i4({component:e,data:t}){const[s,r]=d.useState(!1),i=cs(s?e.query:void 0,t),a=typeof e.label=="string"?e.label:String(Re(t,e.label)??"");return n.jsxs(It,{summary:a,boxed:!0,onToggle:o=>r(o),children:[n.jsx(se,{message:i.error}),i.data===void 0?n.jsx(ue,{children:"Loading…"}):n.jsx(V,{children:e.body.map((o,l)=>n.jsx(Zs,{component:o,data:i.data},l))})]})}function a4({component:e,data:t}){const s=Pt(),r=ol();return n.jsxs(n.Fragment,{children:[n.jsx(Q,{align:"end",children:n.jsx(pa,{action:e.action,args:ci(e.action.args,{data:t,row:t,scope:s}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,a)=>void r.run(i,a)})}),n.jsx(Ia,{act:r})]})}function o4({component:e}){const t=Pt();return n.jsx(Og,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function l4({component:e,data:t}){const s=Se(t,e.path);return typeof s!="string"||s===""?null:n.jsx(xu,{id:s})}function c4({component:e,data:t}){const s=Se(t,e.path);return typeof s!="string"||s===""?null:n.jsx(Q,{children:n.jsx("a",{href:Ar(s),children:e.label})})}function u4({component:e,data:t}){const s=cs(e.query,t),r=ol();return s.error?n.jsx(se,{message:s.error}):s.data===void 0?n.jsx(ue,{children:e.empty??"Loading…"}):n.jsxs(n.Fragment,{children:[n.jsx(Ia,{act:r}),n.jsx(d4,{component:e,data:t,loaded:s.data,act:r},JSON.stringify(s.data))]})}function d4({component:e,data:t,loaded:s,act:r}){const i=Pt(),[a,o]=d.useState(()=>vu(e.fields,s)),l={...a,version:Se(s,e.version)},c=Fg(e.fields,a,s),u=e.readOnlyWhen!==void 0&&ts(s,e.readOnlyWhen),h=(e.actions??[]).filter(m=>m.placement==="leading"),f=(e.actions??[]).filter(m=>m.placement!=="leading"),p=(m,j)=>n.jsx(pa,{action:m,args:ci(m.args,{data:t,fields:l,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===m.tool,onRun:(w,b)=>void r.run(w,b)},`${m.tool}-${j}`);return n.jsx(Rs,{title:e.title,note:e.note,children:n.jsxs(V,{children:[n.jsx(Ug,{fields:e.fields,values:a,data:s,disabled:u,onChange:(m,j)=>o(w=>({...w,[m]:j}))}),u?null:n.jsxs(Q,{align:"end",children:[h.map(p),h.length>0?n.jsx(Es,{}):null,p(e.save,-1),f.map(p)]}),e.footnote?n.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function SN({page:e,item:t,navigate:s,timezone:r,embedded:i,siblings:a}){const[o,l]=d.useState({}),[c,u]=d.useState(0),h={plugin:e.plugin,page:e.id,pages:a??[e],item:t??null,params:{...o,...t?{item:t}:{},...h4(e,t)},setParams:j=>l(w=>{const b={...w};for(const[v,x]of Object.entries(j))x===null?delete b[v]:b[v]=x;return b}),navigate:s,timezone:r,version:c,refresh:()=>u(j=>j+1),sensitive:new Set(e.sensitive??[])},f=e.body[0],p=!i&&(f==null?void 0:f.kind)==="notice"&&typeof f.text=="string"&&f.when===void 0&&f.title===void 0&&(f.tone===void 0||f.tone==="neutral")?f.text:void 0,m=p===void 0?e:{...e,body:e.body.slice(1)};return n.jsx(_g.Provider,{value:h,children:n.jsx(fn,{embedded:i,title:e.title,lede:p,children:n.jsx(f4,{page:m,boxed:i===!0})})})}function f4({page:e,boxed:t}){const s=Pt();return e.data&&s.sensitive.has(e.data.query)?n.jsx(xN,{children:n.jsx(ay,{page:e,boxed:t})}):n.jsx(ay,{page:e,boxed:t})}function ay({page:e,boxed:t}){const s=cs(e.data,null);return n.jsxs(V,{gap:"lg",divided:!t,children:[n.jsx(se,{message:s.error}),n.jsx(Go.Provider,{value:t,children:e.body.map((r,i)=>n.jsx(Zs,{component:r,data:s.data??null},i))})]})}function h4(e,t){if(!t)return{};const s=[],r=i=>{for(const a of i)a.kind==="list-detail"?(s.push(a.param),r(a.detail)):(a.kind==="section"||a.kind==="detail"||a.kind==="expand")&&r(a.body)};return r(e.body),Object.fromEntries(s.map(i=>[i,t]))}function p4(e){return n.jsx(SN,{...e,embedded:!0})}function cd({text:e}){const t=e.search(/[.!?]\s/),s=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return n.jsx(Rt,{title:s,children:r||null})}function oy(e,t){return(e??[]).filter(s=>s.place===t).map((s,r)=>({page:s,index:r})).sort((s,r)=>(s.page.order??0)-(r.page.order??0)||s.index-r.index).map(s=>s.page)}function NN(e=!1){const[t,s]=d.useState([]);return d.useEffect(()=>{if(e)return;let r=!1;return Promise.resolve().then(()=>A.pages()).then(i=>{r||s(Array.isArray(i==null?void 0:i.pages)?i.pages:[])}).catch(()=>{}),()=>{r=!0}},[e]),{all:t,rail:oy(t,"rail"),settings:oy(t,"settings"),find:(r,i)=>t.find(a=>a.plugin===r&&a.id===i)}}const ly=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],m4=["","image","pdf","table","text","code","audio","video","archive","file"];function g4({hash:e,timezone:t,navigate:s,agents:r}){var U;const i=CM(e),a=(i==null?void 0:i.artifactId)??null,o=(i==null?void 0:i.filters.origin)??"",l=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,h]=d.useState(c);d.useEffect(()=>{h(c)},[c]);const f=(T,M=!1)=>s(Wl(a,{q:c,origin:o,family:l,...T}),M);d.useEffect(()=>{if(u===c)return;const T=window.setTimeout(()=>f({q:u},!0),250);return()=>window.clearTimeout(T)},[u]);const[p,m]=d.useState(null),[j,w]=d.useState(null),[b,v]=d.useState(null),[x,y]=d.useState(!1),[g,N]=d.useState(!1),k=T=>{var M;return T?((M=r.find(L=>L.id===T))==null?void 0:M.name)??T:""},S=d.useRef(0);d.useEffect(()=>{const T=++S.current;m(null),w(null),y(!1),v(null),A.library({...c?{q:c}:{},...o?{origin:o}:{},...l?{family:l}:{}}).then(M=>{S.current===T&&(m(M.entries),w(M.next))}).catch(M=>{S.current===T&&v(M instanceof oe?M.message:String(M))})},[c,o,l]);const C=()=>{if(!j||x)return;y(!0);const T=S.current;A.library({...c?{q:c}:{},...o?{origin:o}:{},...l?{family:l}:{},cursor:j}).then(M=>{S.current===T&&(m(L=>{const K=new Set((L??[]).map(D=>D.id));return[...L??[],...M.entries.filter(D=>!K.has(D.id))]}),w(M.next))}).catch(M=>{S.current===T&&v(M instanceof oe?M.message:String(M))}).finally(()=>{S.current===T&&y(!1)})},R=(o?1:0)+(l?1:0),E=((U=ly.find(T=>T.id===o))==null?void 0:U.label)??o,P=n.jsxs(n.Fragment,{children:[p===null?n.jsx(ue,{children:"Loading…"}):p.length===0?n.jsx(ue,{children:"No file matches that."}):n.jsx(Xt,{children:p.map(T=>n.jsx(AS,{href:Wl(T.id,{q:c,origin:o,family:l}),current:T.id===a,onClick:()=>s(Wl(T.id,{q:c,origin:o,family:l})),lead:n.jsx("span",{className:"files-row-visual","data-family":T.family,children:T.family==="image"&&!T.deleted?n.jsx("img",{src:Js(T.id),alt:"",loading:"lazy"}):n.jsx(Eg,{family:T.family})}),title:T.filename??"Untitled file",meta:n.jsx("span",{title:He(T.createdAt,t),children:_e(T.createdAt)}),sub:`${ei[T.family]} · ${Sn(T.sizeBytes)} · ${CN(T,k)}${x4(T,k)}`},T.id))}),j?n.jsx("div",{className:"files-more",children:n.jsx(I,{size:"sm",onClick:C,disabled:x,children:x?"Loading…":"Show more"})}):null]}),O=p!==null&&p.length===0&&!c&&!o&&!l&&!u;return n.jsxs("div",{className:"ui-page files","data-selected":a?"true":void 0,children:[n.jsxs("header",{className:"ui-page-head",children:[n.jsx("h2",{className:"ui-page-title",children:"Files"}),n.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),O?n.jsx(Rt,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):n.jsxs(n.Fragment,{children:[n.jsx(RS,{label:"Files",onSubmit:()=>f({q:u},!0),main:n.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:T=>h(T.target.value)}),filters:n.jsxs(Xs,{dense:!0,children:[n.jsx(J,{label:"Origin",children:n.jsx("select",{value:o,"aria-label":"Origin",onChange:T=>f({origin:T.target.value}),children:ly.map(T=>n.jsx("option",{value:T.id,children:T.label},T.id))})}),n.jsx(J,{label:"Kind",children:n.jsx("select",{value:l,"aria-label":"Kind",onChange:T=>f({family:T.target.value}),children:m4.map(T=>n.jsx("option",{value:T,children:T===""?"Any kind":ei[T]},T))})})]}),filtersOpen:g,onToggleFilters:()=>N(T=>!T),active:R,chips:R>0?n.jsxs(n.Fragment,{children:[o?n.jsx(cu,{label:"Origin",onRemove:()=>f({origin:""}),children:E}):null,l?n.jsx(cu,{label:"Kind",onRemove:()=>f({family:""}),children:ei[l]}):null]}):void 0}),n.jsx(se,{message:b}),n.jsx(TS,{className:"files-split",label:"Files",list:P,detail:a?n.jsx(v4,{id:a,timezone:t,agents:r,navigate:s,onBack:()=>s(Wl(null,{q:c,origin:o,family:l}))},a):void 0,empty:"Choose a file to see it here."})]})]})}function x4(e,t){var i,a;const s=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(a=e.context)!=null&&a.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[s,r].filter(Boolean).map(o=>` · ${o}`).join("")}function CN(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 v4({id:e,timezone:t,agents:s,navigate:r,onBack:i}){const[a,o]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let x=!1;return o(null),h(null),A.libraryEntry(e).then(y=>{x||o(y)}).catch(y=>{x||h(y instanceof oe&&y.status===404?"This file is no longer in the library.":y instanceof oe?y.message:String(y))}),()=>{x=!0}},[e]);const f=x=>{var y;return x?((y=s.find(g=>g.id===x))==null?void 0:y.name)??x:""};if(u)return n.jsxs("div",{className:"files-detail-body",children:[n.jsx(I,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),n.jsx(W,{tone:"critical",children:u})]});if(!a)return n.jsx("div",{className:"files-detail-body",children:n.jsx(ue,{children:"Loading…"})});const{entry:p,contexts:m,contextsTotal:j,available:w}=a,b=p.filename??"Untitled file",v=()=>{c(!0),A.libraryEntry(e,m.length).then(x=>o(y=>y&&{...y,contexts:[...y.contexts,...x.contexts],contextsTotal:x.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return n.jsxs("div",{className:"files-detail-body",children:[n.jsx(I,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),n.jsxs("header",{className:"files-detail-head",children:[n.jsx("span",{className:"files-detail-mark","data-family":p.family,"aria-hidden":"true",children:n.jsx(Eg,{family:p.family})}),n.jsxs("div",{className:"files-detail-text",children:[n.jsx("h3",{className:"files-detail-name",children:b}),n.jsxs("p",{className:"files-detail-meta",children:[ei[p.family]," · ",Sn(p.sizeBytes)," · ",He(p.createdAt,t)]})]}),w?n.jsx("a",{className:"ui-btn","data-variant":"accent",href:Ar(p.id),download:b,children:"Download"}):null]}),w?null:n.jsx(W,{tone:"warning",children:"The file's bytes are no longer on this machine. What is known about it stays here; the download will not work."}),n.jsx(GS,{artifactId:p.id,filename:p.filename,mime:p.mime,family:p.family,available:w}),n.jsx(Wt,{items:[{label:"Origin",value:CN(p,f)},...p.agentId&&p.origin==="produced"?[{label:"Made by",value:n.jsxs("span",{className:"files-agent",children:[n.jsx(gn,{agents:s,id:p.agentId,size:"sm"}),f(p.agentId)]})}]:[],{label:"Type",value:n.jsx("span",{className:"mono",children:p.mime})},{label:"Id",value:n.jsx("span",{className:"mono",children:p.id})}]}),n.jsxs("section",{className:"files-conversations",children:[n.jsx("h4",{className:"ui-section-title",children:"Conversations"}),m.length===0?n.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):n.jsx("ul",{className:"files-ctx",role:"list",children:m.map(x=>{const y=x.groupId?co(x.groupId,x.conversationId):Ve(x.conversationAgentId,x.conversationId),g=x.groupId?x.groupName??"a group":f(x.conversationAgentId);return n.jsxs("li",{className:"files-ctx-row",children:[n.jsxs("span",{className:"files-ctx-text",children:[n.jsx("span",{children:x.groupId?`Group: ${g}`:g}),n.jsxs("span",{className:"muted",children:[" · ",x.kind==="produced"?`made by ${f(x.agentId)||"an agent"}`:x.kind==="reused"?"sent again":"sent by you"," · ",_e(x.at)]})]}),n.jsx("a",{className:"ui-btn","data-size":"sm",href:y,onClick:N=>{N.preventDefault(),r(y)},children:"Open conversation"})]},`${x.conversationId}:${x.kind}`)})}),m.length<j?n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",onClick:v,disabled:l,children:l?"Loading…":`Show ${j-m.length} more`})}):null]})]})}const EN="0.1.0+2265ef5";function AN(e,t=EN){return typeof e=="string"&&e!==""&&typeof t=="string"&&t!==""&&e!==t}function j4(){var e;try{if((e=window.matchMedia)!=null&&e.call(window,"(display-mode: standalone)").matches)return!0}catch{}return window.navigator.standalone===!0}const y4={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe"};function TN(e){return e&&y4[e]||"plug"}const RN="a connection needs you";function w4({attention:e,place:t,onNavigate:s,theme:r,onTheme:i,plugins:a=[],updateAvailable:o=!1,settingsDot:l,version:c,stale:u=!1,reload:h}){return n.jsxs("nav",{className:"rail","aria-label":"Places",children:[n.jsx("a",{className:"rail-mark",href:zt,onClick:f=>{f.preventDefault(),s(zt)},"aria-label":"buddi home",children:n.jsx(IS,{})}),$M.filter(f=>f.route!==pn).map(f=>n.jsx(Nf,{label:f.label,href:f.route,active:t===f.route,badge:f.route===zt?e:0,onClick:()=>s(f.route),children:cy[f.route]},f.route)),a.map(f=>{const p=zo(f.plugin,f.id);return n.jsx(Nf,{label:f.title,href:p,active:t===p,badge:0,onClick:()=>s(p),children:n.jsx(Te,{name:TN(f.icon)})},p)}),n.jsx("div",{className:"rail-spacer"}),n.jsx(Nf,{label:"Settings",href:pn,active:t===pn,badge:0,dot:o?"a newer buddi is ready":l,onClick:()=>s(pn),children:cy[pn]}),n.jsx(k4,{theme:r,onTheme:i,onNavigate:s,version:c,stale:u,reload:h})]})}const b4=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function k4({theme:e,onTheme:t,onNavigate:s,version:r,stale:i,reload:a=()=>window.location.reload()}){var p,m;const l=((m=(p=re(()=>A.owner(),[]).data)==null?void 0:p.preferredName)==null?void 0:m.trim())||null,c=(l??"You").slice(0,1).toUpperCase(),[u]=d.useState(j4),[h]=d.useState(S4),f=l?`You: ${l}`:"You";return n.jsx("div",{className:"rail-owner",children:n.jsxs(rg,{modal:!1,children:[n.jsx(ig,{asChild:!0,children:n.jsxs("button",{type:"button",className:"rail-owner-btn","aria-label":i?`${f}, reload to update`:f,children:[n.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:c}),i?n.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"owner-dot","aria-hidden":"true"}):null]})}),n.jsx(ag,{children:n.jsxs(og,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[n.jsxs("div",{className:"rail-owner-head",children:[n.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:c}),n.jsxs("span",{className:"rail-owner-who",children:[n.jsx("span",{className:"rail-owner-name",children:l??"You"}),n.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),n.jsx(Nc,{className:"ui-menu-sep"}),n.jsx(lg,{className:"ui-menu-label",children:"Theme"}),n.jsx("div",{className:"rail-owner-theme",children:n.jsx(uo,{label:"Theme",options:b4,value:e,onChange:t})}),n.jsx(Nc,{className:"ui-menu-sep"}),n.jsx(Sc,{className:"ui-menu-item",onSelect:()=>s(Ze("appearance")),children:"Change appearance"}),u||i?n.jsxs(Sc,{className:"ui-menu-item rail-owner-reload","data-update":i?"true":void 0,onSelect:()=>a(),children:[n.jsx("span",{children:i?"Reload to update":"Reload"}),h?n.jsx("kbd",{className:"rail-owner-kbd",children:h}):null]}):null,r?n.jsxs(n.Fragment,{children:[n.jsx(Nc,{className:"ui-menu-sep"}),n.jsxs(Sc,{className:"ui-menu-item rail-owner-version","data-update":r.updateAvailable?"true":void 0,onSelect:()=>s(Ze("system")),children:[n.jsxs("span",{className:"mono",children:["buddi ",r.current]}),r.updateAvailable&&r.latest?n.jsxs("span",{className:"rail-owner-update",children:["A newer buddi is ready: ",r.latest]}):null]})]}):null]})})]})})}function S4(){const e=window.navigator.userAgent;return/iPhone|iPad|Android|Mobile/.test(e)?null:/Mac/.test(e)?"⌘R":"Ctrl+R"}function Nf({label:e,href:t,active:s,badge:r,dot:i,onClick:a,children:o}){return n.jsxs("a",{className:"rail-link",href:t,"data-active":s?"true":void 0,"aria-current":s?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:i?`${e}, ${i}`:e,onClick:l=>{l.preventDefault(),a()},children:[n.jsxs("span",{className:"rail-icon",children:[o,r>0?n.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null,r===0&&i?n.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"rail-dot","aria-hidden":"true"}):null]}),n.jsx("span",{className:"rail-label",children:e})]})}const cy={[li]:n.jsx(Te,{name:"files"}),[zt]:n.jsx(Te,{name:"home"}),[br]:n.jsx(Te,{name:"chat"}),[ot]:n.jsx(Te,{name:"agents"}),[mt]:n.jsx(Te,{name:"activity"}),[pn]:n.jsx(Te,{name:"settings"})};function N4(e){return e instanceof HTMLElement?e.isContentEditable?!0:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function C4(e,t=!0,s){d.useEffect(()=>{if(!t)return;const r=i=>{if(i.key!=="/"||i.defaultPrevented||i.ctrlKey||i.metaKey||i.altKey||N4(i.target))return;i.preventDefault();const a=document.getElementById(yp);if(a instanceof HTMLTextAreaElement){!a.disabled&&!a.hidden&&a.focus();return}s?s():e(zt)};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t,s])}const IN="buddi.theme";function E4(e=PN()){try{const t=e==null?void 0:e.getItem(IN);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function A4(e,t=PN()){try{t==null||t.setItem(IN,e)}catch{}}function T4(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function PN(){try{return window.localStorage}catch{return}}const MN="buddi.ground",$N="buddi.pageWidth";function R4(e=DN()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},s=t(MN),r=t($N);return{theme:E4(e),ground:s==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function ON(e,t=document.documentElement){t&&(T4(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 I4(e,t=DN()){A4(e.theme,t);try{t==null||t.setItem(MN,e.ground),t==null||t.setItem($N,e.width)}catch{}}let sa=null;const Cp=new Set;function Ep(){return sa||(sa=R4()),sa}function P4(e){return Cp.add(e),()=>Cp.delete(e)}function M4(e){sa={...Ep(),...e},ON(sa),I4(sa);for(const t of Cp)t()}function _N(){return[d.useSyncExternalStore(P4,Ep,Ep),M4]}function DN(){try{return window.localStorage}catch{return}}function $4({timezone:e,embedded:t}){var p,m;const{data:s,error:r,reload:i}=re(()=>A.sentinels(),[],3e4),a=re(()=>A.missions(),[]),[o,l]=d.useState(null),c=((m=(p=a.data)==null?void 0:p.missions.find(j=>j.id==="sentinel-wake"))==null?void 0:m.agentId)??null,u=async(j,w)=>{l(null);try{await A.snoozeAlert(j,w),i()}catch(b){l(b instanceof Error?b.message:String(b))}},h=((s==null?void 0:s.open)??[]).filter(j=>!j.snoozedAt),f=((s==null?void 0:s.open)??[]).filter(j=>j.snoozedAt);return n.jsxs(fn,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[n.jsx(se,{message:r??o}),n.jsx(W,{children:"An alert closes on its own once the fact behind it changes: record the payment, update the balance, and the watcher clears it on its next run. Snooze one you have decided to live with; it stays quiet until it resolves."}),n.jsx(Cf,{title:"Open",findings:h,timezone:e,askAgentId:c,onSnooze:j=>u(j,!0),empty:"Nothing open. Your watchers are quiet."}),f.length>0?n.jsx(Cf,{title:"Snoozed",findings:f,timezone:e,askAgentId:c,onSnooze:j=>u(j,!1),empty:""}):null,n.jsx(Cf,{title:"Resolved",findings:(s==null?void 0:s.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),n.jsx(vt,{title:"Waiting for the weekly recap",flush:!0,children:!s||s.digest.length===0?n.jsx(Rt,{icon:"bell",title:"Nothing waiting for the recap"}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Title"}),n.jsx("th",{children:"Severity"}),n.jsx("th",{children:"Noted"})]})}),n.jsx("tbody",{children:s.digest.map(j=>n.jsxs("tr",{children:[n.jsxs("td",{children:[fa(j.title),n.jsx(FN,{text:fa(j.detail)})]}),n.jsx("td",{children:n.jsx(LN,{severity:j.severity})}),n.jsx("td",{className:"nowrap",children:He(j.createdAt,e)})]},j.id))})]})})]})}function LN({severity:e}){return n.jsx(ye,{tone:e==="urgent"?"critical":void 0,children:e})}function FN({text:e}){const[t,s]=d.useState(!1),r=e.length>240||e.split(`
107
+ `).length>3;return n.jsxs("div",{className:"sub alert-detail","data-clamp":r&&!t?"true":void 0,children:[e,r?n.jsx("button",{type:"button",className:"wb-link alert-more",onClick:()=>s(i=>!i),children:t?"Less":"More"}):null]})}function O4(e){return`About this alert: "${fa(e.title)}". ${fa(e.detail)}
108
+
109
+ What should I do about it, and what do you need from me to clear it?`}function Cf({title:e,findings:t,timezone:s,askAgentId:r,onSnooze:i,empty:a}){const o=e==="Snoozed";return n.jsx(vt,{title:e,flush:!0,children:t.length===0?n.jsx(ue,{children:a}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Finding"}),n.jsx("th",{children:"Severity"}),n.jsx("th",{children:"Since"}),i?n.jsx("th",{}):null]})}),n.jsx("tbody",{children:t.map(l=>n.jsxs("tr",{children:[n.jsxs("td",{children:[n.jsx("strong",{children:fa(l.title)}),n.jsx(FN,{text:fa(l.detail)}),l.data?n.jsx(It,{summary:"evidence",children:n.jsx(bt,{children:bn(l.data)})}):null]}),n.jsx("td",{children:n.jsx(LN,{severity:l.severity})}),n.jsxs("td",{className:"nowrap",children:[He(l.firstSeenAt,s),n.jsxs("div",{className:"sub",title:He(l.lastSeenAt,s),children:["last seen ",_e(l.lastSeenAt)]})]}),i?n.jsx("td",{children:n.jsxs(Q,{align:"end",children:[r?n.jsx(Zt,{size:"sm",href:Ve(r,"new"),onClick:()=>aF(r,O4(l)),children:"Ask about it"}):null,n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>i(l.key),children:o?"Wake":"Snooze"})]})}):null]},l.key))})]})})}const uy=5e3,dy=50;function _4({timezone:e,embedded:t}){var v;const[s,r]=d.useState(""),[i,a]=d.useState(""),[o,l]=d.useState(null),c=re(()=>A.eventKinds(),[]),{data:u,error:h}=re(()=>A.events({kind:s||void 0,q:i||void 0,limit:dy}),[s,i],uy),[f,p]=d.useState({events:[],cursor:null,busy:!1,error:null});d.useEffect(()=>{p({events:[],cursor:null,busy:!1,error:null})},[s,i]);const m=f.events.length>0?f.cursor:(u==null?void 0:u.nextCursor)??null,j=async()=>{if(m){p(x=>({...x,busy:!0,error:null}));try{const x=await A.events({kind:s||void 0,q:i||void 0,before:m,limit:dy});p(y=>({events:[...y.events,...x.events],cursor:x.nextCursor,busy:!1,error:null}))}catch(x){p(y=>({...y,busy:!1,error:x instanceof Error?x.message:String(x)}))}}},w=new Set(((u==null?void 0:u.events)??[]).map(x=>x.id)),b=[...(u==null?void 0:u.events)??[],...f.events.filter(x=>!w.has(x.id))];return n.jsxs(fn,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[n.jsxs(Q,{children:[n.jsxs("select",{"aria-label":"Event kind",value:s,onChange:x=>r(x.target.value),children:[n.jsx("option",{value:"",children:"every kind"}),(((v=c.data)==null?void 0:v.kinds)??[]).map(x=>n.jsxs("option",{value:x.kind,children:[x.kind," (",x.count,")"]},x.kind))]}),n.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:x=>a(x.target.value),size:28}),s||i?n.jsx(I,{onClick:()=>{r(""),a("")},children:"Clear"}):null,n.jsxs("span",{className:"muted",children:["refreshes every ",uy/1e3,"s"]})]}),n.jsx(se,{message:h}),n.jsx(vt,{flush:!0,children:!u||b.length===0?n.jsx(ue,{children:"No events match."}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"#"}),n.jsx("th",{children:"When"}),n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"Payload"})]})}),n.jsx("tbody",{children:b.map(x=>n.jsxs("tr",{"data-clickable":"true",onClick:()=>l(x),children:[n.jsx("td",{className:"mono muted",children:x.id}),n.jsxs("td",{className:"nowrap",children:[He(x.createdAt,e),n.jsx("div",{className:"sub",children:_e(x.createdAt)})]}),n.jsx("td",{className:"mono nowrap",children:x.kind}),n.jsx("td",{className:"mono muted",children:Cs(bn(x.payload).replace(/\s+/g," "),120)})]},x.id))})]})}),m||f.error?n.jsxs(Q,{children:[n.jsxs("span",{className:"muted",children:[b.length," shown",m?", older ones are kept":"","."]}),n.jsx("span",{className:"ui-toolbar-spacer"}),f.error?n.jsx("span",{className:"critical",children:f.error}):null,m?n.jsx(I,{disabled:f.busy,onClick:()=>void j(),children:f.busy?"Loading…":"Load older"}):null]}):null,o?n.jsxs(en,{title:o.kind,onClose:()=>l(null),children:[n.jsxs("p",{className:"muted",children:["Event ",o.id," · ",He(o.createdAt,e),o.conversationId?n.jsxs(n.Fragment,{children:[" · ",n.jsx("a",{href:`#/conversations/${o.conversationId}`,children:"conversation"})]}):null]}),n.jsx(bt,{children:bn(o.payload)})]}):null]})}const D4=["pending","leased","suspended","failed","succeeded","cancelled"],Ya=50;function L4({timezone:e,embedded:t,initialState:s}){const[r,i]=d.useState(s??""),[a,o]=d.useState(null),[l,c]=d.useState(null),{data:u,error:h,reload:f}=re(()=>A.jobs({...r?{state:r}:{},limit:String(Ya)}),[r],1e4),[p,m]=d.useState({jobs:[],done:!1,busy:!1});d.useEffect(()=>{m({jobs:[],done:!1,busy:!1})},[r]);const j=async()=>{m(S=>({...S,busy:!0}));try{const S=await A.jobs({...r?{state:r}:{},limit:String(Ya),offset:String(Ya+p.jobs.length)});m(C=>({jobs:[...C.jobs,...S.jobs],done:S.jobs.length<Ya,busy:!1}))}catch(S){c(S instanceof Error?S.message:String(S)),m(C=>({...C,busy:!1}))}},w=new Set(((u==null?void 0:u.jobs)??[]).map(S=>S.id)),b=[...(u==null?void 0:u.jobs)??[],...p.jobs.filter(S=>!w.has(S.id))],v=r?(u==null?void 0:u.counts[r])??0:Object.values((u==null?void 0:u.counts)??{}).reduce((S,C)=>S+C,0),x=!p.done&&b.length<v&&((u==null?void 0:u.jobs.length)??0)>=Ya,[y,g]=d.useState(null),N=async S=>{c(null),g(S);try{const C=(await A.jobs({state:"failed",limit:"500"})).jobs;for(const R of C)await(S==="retry"?A.retryJob(R.id):A.cancelJob(R.id));f()}catch(C){c(C instanceof Error?C.message:String(C))}finally{g(null)}},k=async S=>{c(null);try{await S,o(null),f()}catch(C){c(C instanceof Error?C.message:String(C))}};return n.jsxs(fn,{embedded:t,title:"Jobs",lede:`${u!=null&&u.paused?"Paused: nothing is being claimed. ":""}Bounded retries with backoff; past the budget a job waits for you.`,actions:t?void 0:n.jsx(I,{size:"sm",variant:u!=null&&u.paused?"accent":void 0,onClick:()=>k(A.setPaused(!((u==null?void 0:u.paused)??!1))),children:u!=null&&u.paused?"Resume the queue":"Pause the queue"}),children:[n.jsxs(Q,{children:[n.jsxs("select",{"aria-label":"Job state",value:r,onChange:S=>i(S.target.value),children:[n.jsx("option",{value:"",children:"every state"}),D4.map(S=>n.jsxs("option",{value:S,children:[S," (",(u==null?void 0:u.counts[S])??0,")"]},S))]}),((u==null?void 0:u.counts.failed)??0)>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsxs("span",{className:"muted",children:[u.counts.failed," failed."]}),n.jsx(I,{size:"sm",disabled:y!==null,onClick:()=>void N("retry"),children:y==="retry"?"Retrying…":"Retry all failed"}),n.jsx(I,{size:"sm",variant:"danger",disabled:y!==null,onClick:()=>void N("cancel"),children:y==="cancel"?"Cancelling…":"Cancel all failed"})]}):null]}),n.jsx(se,{message:h??l}),n.jsx(vt,{flush:!0,children:!u||b.length===0?n.jsx(ue,{children:"No jobs match."}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"State"}),n.jsx("th",{className:"num",children:"Attempts"}),n.jsx("th",{children:"Last error"}),n.jsx("th",{children:"Updated"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:b.map(S=>n.jsxs("tr",{children:[n.jsxs("td",{className:"clickable",onClick:()=>o(S),children:[S.kind,n.jsx("div",{className:"sub mono",children:Bo(S.id)})]}),n.jsxs("td",{children:[n.jsx(rd,{state:S.state}),S.suspendedReason?n.jsx("div",{className:"sub",children:Cs(S.suspendedReason,40)}):null]}),n.jsxs("td",{className:"num",children:[S.attempts,"/",S.maxAttempts]}),n.jsx("td",{className:S.lastError?"critical":"muted",children:S.lastError?Cs(S.lastError,80):"—"}),n.jsxs("td",{className:"nowrap",children:[He(S.updatedAt,e),n.jsx("div",{className:"sub",children:_e(S.updatedAt)})]}),n.jsx("td",{children:n.jsxs(Q,{align:"end",children:[["failed","cancelled","suspended"].includes(S.state)?n.jsx(I,{size:"sm",onClick:()=>k(A.retryJob(S.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(S.state)?n.jsx(I,{size:"sm",variant:"danger",onClick:()=>k(A.cancelJob(S.id)),children:"Cancel"}):null]})})]},S.id))})]})}),x?n.jsxs(Q,{children:[n.jsxs("span",{className:"muted",children:[b.length," of ",v," shown."]}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{disabled:p.busy,onClick:()=>void j(),children:p.busy?"Loading…":"Load older"})]}):null,a?n.jsxs(en,{title:a.kind,onClose:()=>o(null),children:[n.jsx("p",{className:"muted mono",children:a.id}),n.jsx(Y,{title:"Payload",children:n.jsx(bt,{children:bn(a.payload)})}),n.jsx(Y,{title:"Result",children:n.jsx(bt,{children:bn(a.result)})}),a.conversationId?n.jsx("p",{children:n.jsx("a",{href:`#/conversations/${a.conversationId}`,children:"open the transcript"})}):null]}):null]})}const F4=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function U4({hash:e,timezone:t,navigate:s,agents:r}){var u,h;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),a=f=>{var p;return((p=r.find(m=>m.id===f))==null?void 0:p.name)??f};if(i){let f=i[1];try{f=decodeURIComponent(f)}catch{}return n.jsx(W4,{id:f,timezone:t,navigate:s,nameOf:a})}const o=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",l=(h=/[?&]state=([a-z]+)/.exec(e))==null?void 0:h[1],c=f=>p=>{p.preventDefault(),s(f)};return n.jsxs("div",{className:"ui-page",children:[n.jsx(jg,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:n.jsx(K4,{})}),n.jsx(G4,{}),n.jsx(ad,{children:F4.map(f=>{const p=f.id==="conversations"?mt:`${mt}/${f.id}`;return n.jsx(od,{href:p,active:o===f.id,onClick:c(p),children:f.label},f.id)})}),o==="conversations"?n.jsx(B4,{timezone:t,navigate:s,nameOf:a,agents:r}):null,o==="jobs"?n.jsx(L4,{timezone:t,embedded:!0,initialState:l},l??""):null,o==="approvals"?n.jsx(z4,{timezone:t,nameOf:a}):null,o==="alerts"?n.jsx($4,{timezone:t,embedded:!0}):null,o==="events"?n.jsx(_4,{timezone:t,embedded:!0}):null]})}function B4({timezone:e,navigate:t,nameOf:s,agents:r}){const{data:i,error:a}=re(()=>A.conversations(),[],3e4);return n.jsxs(n.Fragment,{children:[n.jsx(se,{message:a}),n.jsx(vt,{flush:!0,children:i?i.conversations.length===0?n.jsx(Rt,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):n.jsx(Xt,{children:i.conversations.map(o=>n.jsx(cn,{href:ha(o.id),onClick:()=>t(ha(o.id)),lead:n.jsx(gn,{agents:r,id:o.agentId,size:"sm"}),title:o.opening?Cs(o.opening,100):"Untitled conversation",sub:`${s(o.agentId)}, ${o.messageCount} message${o.messageCount===1?"":"s"}, ${o.runs} run${o.runs===1?"":"s"}, ${mM(o.usage)}`,side:n.jsx("span",{title:He(o.lastMessageAt??o.createdAt,e),children:_e(o.lastMessageAt??o.createdAt)})},o.id))}):n.jsx(ue,{children:"Loading…"})})]})}function z4({timezone:e,nameOf:t}){const{data:s,error:r}=re(()=>A.approvals(),[],1e4),i=[...(s==null?void 0:s.pending)??[],...(s==null?void 0:s.recent)??[]];return n.jsxs(n.Fragment,{children:[n.jsx(se,{message:r}),n.jsx(vt,{flush:!0,children:s?i.length===0?n.jsx(Rt,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Tool"}),n.jsx("th",{children:"State"}),n.jsx("th",{children:"Asked by"}),n.jsx("th",{children:"Decided"}),n.jsx("th",{children:"Created"})]})}),n.jsx("tbody",{children:i.map(a=>n.jsxs("tr",{children:[n.jsxs("td",{children:[a.tool,n.jsx("div",{className:"sub mono",children:Bo(a.id)})]}),n.jsx("td",{children:n.jsx(rd,{state:a.state})}),n.jsx("td",{children:t(a.agentId)}),n.jsx("td",{className:"nowrap",children:a.decidedAt?n.jsxs(n.Fragment,{children:[He(a.decidedAt,e),n.jsxs("div",{className:"sub",children:["via ",a.decidedVia??"—"]})]}):n.jsx("span",{className:"muted",children:"—"})}),n.jsxs("td",{className:"nowrap",children:[He(a.createdAt,e),n.jsx("div",{className:"sub",children:_e(a.createdAt)})]})]},a.id))})]}):n.jsx(ue,{children:"Loading…"})})]})}function W4({id:e,timezone:t,navigate:s,nameOf:r}){const[i,a]=d.useState(null),[o,l]=d.useState(null);d.useEffect(()=>{let u=!1;return A.conversation(e).then(h=>{u||a(h)}).catch(h=>{u||l(h instanceof Error?h.message:String(h))}),()=>{u=!0}},[e]);const c=u=>h=>{h.preventDefault(),s(u)};return n.jsxs("div",{className:"ui-page",children:[n.jsx("p",{className:"page-crumbs",children:n.jsx("a",{href:mt,onClick:c(mt),children:"Activity"})}),n.jsxs("header",{className:"ui-page-head",children:[n.jsxs("div",{className:"ui-page-head-row",children:[n.jsxs("h2",{className:"ui-page-title",children:[n.jsx(I,{size:"sm",onClick:()=>s(mt),children:"← Back"}),n.jsx("span",{children:"Transcript"})]}),i?n.jsx("div",{className:"ui-page-actions",children:n.jsx(Zt,{size:"sm",href:Ve(i.agentId,e),onClick:c(Ve(i.agentId,e)),children:"Open in chat"})}):null]}),n.jsx("p",{className:"ui-page-lede mono",children:e})]}),n.jsx(se,{message:o}),i?n.jsxs(n.Fragment,{children:[n.jsxs(id,{children:[n.jsx(ys,{label:"Agent",value:r(i.agentId),size:"sm"}),n.jsx(ys,{label:"Runs",value:i.runs.length}),n.jsx(ys,{label:"Tokens",value:`${Et(i.usage.input)} / ${Et(i.usage.output)}`,note:Xh(i.usage)?`input / output, ${Xh(i.usage)}`:"input / output"}),n.jsx(ys,{label:"Started",value:He(i.createdAt,t),size:"sm"})]}),i.runs.length>0?n.jsx(vt,{title:"Runs",flush:!0,children:n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Started"}),n.jsx("th",{children:"Finished"}),n.jsx("th",{className:"num",children:"Turns"}),n.jsx("th",{children:"Stopped"}),n.jsx("th",{className:"num",children:"Tokens"}),n.jsx("th",{className:"num",children:"Cached"})]})}),n.jsx("tbody",{children:i.runs.map((u,h)=>n.jsxs("tr",{children:[n.jsxs("td",{className:"nowrap",children:[He(u.startedAt,t)," ",u.resumed?n.jsx(ye,{children:"resumed"}):null]}),n.jsx("td",{className:"nowrap",children:He(u.finishedAt,t)}),n.jsx("td",{className:"num",children:u.turns??"—"}),n.jsxs("td",{children:[u.stopped??"—",u.actionId?n.jsxs("div",{className:"sub mono",children:["action ",Bo(u.actionId)]}):null]}),n.jsxs("td",{className:"num muted nowrap",children:[Et(u.usage.input)," / ",Et(u.usage.output)]}),n.jsx("td",{className:"num muted nowrap",children:u.usage.cacheRead||u.usage.cacheWrite?Et((u.usage.cacheRead??0)+(u.usage.cacheWrite??0)):"—"})]},h))})]})}):null,n.jsx(Y,{title:"Messages",children:n.jsx(V,{children:i.messages.map(u=>n.jsxs("article",{className:"transcript-msg",children:[n.jsxs("header",{className:"transcript-who",children:[u.speaker===fy?"approved action, result":u.role,", ",He(u.createdAt,t)]}),n.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?n.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===fy?u.blocks.map((h,f)=>n.jsx(H4,{block:h},f)):u.blocks.map((h,f)=>n.jsx(V4,{block:h},f))]})]},u.id))})})]}):n.jsx(ue,{children:"Loading…"})]})}const fy="approval:resume";function H4({block:e}){return n.jsxs("div",{className:"transcript-tool",children:[n.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),n.jsx(bt,{children:e.type==="text"?e.text??"":bn(e)})]})}function V4({block:e}){return e.type==="text"?n.jsx("div",{className:"transcript-text",children:n.jsx(Qs,{text:e.text??""})}):e.type==="thinking"?n.jsxs("details",{className:"transcript-thinking",children:[n.jsx("summary",{children:"Thoughts"}),n.jsx("div",{className:"transcript-thinking-text",children:n.jsx(Qs,{text:e.text??""})})]}):e.type==="tool_use"?n.jsxs("div",{className:"transcript-tool",children:[n.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),n.jsx(bt,{children:bn(e.input)})]}):e.type==="tool_result"?n.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[n.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),n.jsx(bt,{children:e.content??""})]}):n.jsxs("div",{className:"transcript-tool",children:[n.jsx("div",{className:"transcript-tool-name mono",children:e.type}),n.jsx(bt,{children:bn(e.ref)})]})}function K4(){const{data:e,reload:t}=re(()=>A.overview(),[],1e4),[s,r]=d.useState(!1);if(!e)return null;const i=()=>{r(!0),A.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return n.jsx(I,{size:"sm",variant:e.paused?"accent":void 0,disabled:s,onClick:i,children:e.paused?"Resume all":"Pause all"})}function G4(){const{data:e}=re(()=>A.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,s=t("leased");return n.jsxs(id,{children:[n.jsx(ys,{label:"Jobs done",value:Et(t("succeeded"))}),n.jsx(ys,{label:"Failed",value:Et(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),n.jsx(ys,{label:"Queued",value:Et(t("pending")),note:`${s} running`}),n.jsx(ys,{label:"Approvals",value:Et(e.approvals.pending),note:"waiting for you"})]})}const Y4=["replay-all","coalesce","latest-only","skip-after-deadline"];function UN({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=re(()=>A.missions(),[],3e4),o=((r==null?void 0:r.missions)??[]).filter(h=>!s||h.agentId===s),[l,c]=d.useState(null),u=async h=>{c(null);try{await h,a()}catch(f){c(f instanceof Error?f.message:String(f))}};return n.jsxs(fn,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[n.jsx(se,{message:i??l}),!r||o.length===0?n.jsxs(Rt,{icon:"calendar",title:"No missions yet",children:["Run ",n.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):n.jsx(V,{children:o.map(h=>n.jsx(q4,{mission:h,timezone:e,onRun:u},h.id))})]})}function q4({mission:e,timezone:t,onRun:s}){const[r,i]=d.useState(!1);return n.jsxs(Kn,{tone:e.enabled?"good":"muted",title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"mono muted",children:e.id})]}),meta:n.jsxs(n.Fragment,{children:[n.jsx(ye,{mono:!0,children:e.agentId}),e.alwaysDeliver?n.jsx(ye,{children:"always delivers"}):null,e.enabled?null:n.jsx(ye,{tone:"warning",children:"disabled"})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",onClick:()=>s(A.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>i(a=>!a),"aria-expanded":r,children:r?"Less":"More"})]}),children:[n.jsxs("p",{className:"ui-card-meta",children:[e.schedule?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${He(e.nextRun,t)} (${_e(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",n.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${_e(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?n.jsxs("div",{className:"ui-card-foot",children:[e.schedule?n.jsxs(Q,{children:[n.jsx(J,{inline:!0,label:"Misfire policy",children:n.jsx("select",{value:e.schedule.misfirePolicy,onChange:a=>s(A.setMisfirePolicy(e.id,a.target.value)),children:Y4.map(a=>n.jsx("option",{value:a,children:a},a))})}),n.jsx("span",{className:"muted",children:"What a week asleep does: replay every instant, coalesce into one, keep only the latest, or skip past a deadline."})]}):null,n.jsx(Y,{title:"Prompt",children:n.jsx(bt,{children:e.prompt})}),n.jsx(Y,{title:"Recent occurrences",children:n.jsx(vt,{flush:!0,children:e.occurrences.length===0?n.jsx(ue,{children:"Never run."}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Scheduled"}),n.jsx("th",{children:"State"}),n.jsx("th",{children:"Finished"}),n.jsx("th",{children:"Detail"})]})}),n.jsx("tbody",{children:e.occurrences.map(a=>n.jsxs("tr",{children:[n.jsx("td",{className:"nowrap",children:He(a.scheduledAt,t)}),n.jsx("td",{children:n.jsx(rd,{state:a.state})}),n.jsx("td",{className:"nowrap",children:He(a.finishedAt,t)}),n.jsxs("td",{className:a.error?"critical":"muted",children:[a.error?Cs(a.error,120):null,a.runConversationId?n.jsx("a",{href:`#/conversations/${a.runConversationId}`,children:"transcript"}):null]})]},a.id))})]})})})]}):null]})}function Q4(e,t){const s=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${s}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function BN({ids:e,agentName:t,onDone:s}){const r=e.length,[i,a]=d.useState(!1),[o,l]=d.useState(!1);return r<=0?null:i?n.jsxs("span",{className:"ui-row",children:[n.jsx("span",{className:"muted",children:Q4(r,t)}),n.jsx(I,{size:"sm",variant:"danger",disabled:o,onClick:()=>{l(!0),A.dismissOffers(e).then(()=>{a(!1),s()}).finally(()=>l(!1))},children:`Dismiss ${r}`}),n.jsx(I,{size:"sm",variant:"ghost",disabled:o,onClick:()=>a(!1),children:"Keep them"})]}):n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>a(!0),children:"Dismiss all"})}function zN({embedded:e,agentId:t,agentName:s}){const{data:r,error:i,reload:a}=re(()=>A.offers(),[],2e4),o=v=>!t||v.agentId===t,l=((r==null?void 0:r.offers)??[]).filter(o),c=((r==null?void 0:r.closed)??[]).filter(o),[u,h]=d.useState(null),[f,p]=d.useState(null),[m,j]=d.useState(null),w=async(v,x)=>{h(null),p(v);try{const y=await A.takeOffer(v);j(y.jobId?`On it — ${x}. Started as job ${y.jobId}.`:`Taken — ${x}. No worker is running here, so nothing has started yet.`),a()}catch(y){h(y instanceof Error?y.message:String(y))}finally{p(null)}},b=async(v,x)=>{h(null),p(v);try{await A.dismissOffer(v),j(`Dismissed — ${x}. It will not come back.`),a()}catch(y){h(y instanceof Error?y.message:String(y))}finally{p(null)}};return n.jsxs(fn,{embedded:e,title:"Offers",lede:"Things an agent already worked out that you might want done. Taking one asks that agent the sentence it wrote. It authorizes nothing, and anything that would leave this machine still comes back to you as an approval.",children:[n.jsx(se,{message:i??u}),m?n.jsx(W,{tone:"good",role:"status",children:m}):null,l.length>0?n.jsxs(Q,{children:[n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(BN,{ids:l.map(v=>v.id),agentName:s,onDone:()=>{j(null),a()}})]}):null,!r||l.length===0?n.jsx(Rt,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):n.jsx(V,{children:l.map(v=>n.jsx(Kn,{tone:"accent",title:v.label,meta:n.jsxs(n.Fragment,{children:[n.jsx(ye,{mono:!0,children:v.agentId}),n.jsxs("span",{className:"muted",children:["expires ",_e(v.expiresAt)]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{size:"sm",variant:"ghost",disabled:f===v.id,onClick:()=>void b(v.id,v.label),children:"Not now"}),n.jsx(I,{variant:"accent",size:"sm",disabled:f===v.id,onClick:()=>void w(v.id,v.label),children:"Take"})]}),children:n.jsx("p",{className:"ui-card-meta",children:v.prompt})},v.id))}),c.length>0?n.jsxs(It,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[n.jsx(vt,{flush:!0,children:n.jsx(Xt,{children:c.map(v=>n.jsx(cn,{title:v.label,sub:`${v.agentId} — ${zI(v)}`,side:_e(v.dismissedAt??v.lapsedAt??v.createdAt)},v.id))})}),n.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const X4="Add a teammate",J4="Each one keeps its own memory and tools, and can work on a schedule. Add the ones you want; Agent Father can make others.",Z4="front-desk";function WN(e,t){return e.length>0&&e.every(s=>s.id===t||s.roles.includes(Z4)||s.roles.includes(nd))}const e3={plugins:{label:"Plugins",route:Ze("plugins")},mailbox:{label:"Add a mailbox",route:Zu("email","settings")},accounts:{label:"Accounts",route:Ze("accounts")}},t3="Your starter team is complete. Agent Father can make others.";function Ap({navigate:e,standing:t=!1}){var h;const s=re(()=>A.teammates(),[]),[r,i]=d.useState(new Set),a=(((h=s.data)==null?void 0:h.teammates)??[]).filter(f=>!r.has(`${f.plugin}/${f.agent}`));if(a.length===0)return null;const o=f=>{i(p=>new Set(p).add(`${f.plugin}/${f.agent}`)),A.dismissAgentOffer(f.plugin,f.agent).then(s.reload,s.reload)},l=f=>p=>{p.preventDefault(),e(f)},c=t?a.filter(f=>f.state!=="added"):a,u=t?a.filter(f=>f.state==="added"):[];return n.jsx(Y,{title:X4,children:c.length===0?n.jsx("p",{className:"teammates-lede","data-testid":"teammates-complete",children:t3}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"teammates-lede",children:J4}),n.jsx("div",{className:"teammates-grid","data-testid":"teammates",children:c.map(f=>n.jsx(n3,{row:f,navigate:e,onDismiss:()=>o(f)},`${f.plugin}/${f.agent}`))}),u.length>0?n.jsx("ul",{className:"teammates-added","data-testid":"teammates-added",children:u.map(f=>n.jsx("li",{children:n.jsxs("a",{className:"teammates-added-chip",href:lt(f.agent),onClick:l(lt(f.agent)),children:["Added · open @",f.handle]})},`${f.plugin}/${f.agent}`))}):null]})})}function n3({row:e,navigate:t,onDismiss:s}){const r=$g(e.plugin,e.agent),i=c=>u=>{u.preventDefault(),t(c)},a=r.created??(e.state==="added"?{id:e.agent,handle:e.handle,name:e.name}:null),o=a?"added":e.state,l=e.fix?e3[e.fix]:null;return n.jsx("div",{className:"teammate","data-state":o,"data-testid":`teammate-${e.agent}`,children:n.jsxs(Kn,{title:e.name,actions:n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Dismiss ${e.name}`,title:"Not now",onClick:s,children:n.jsx(Te,{name:"close"})}),foot:n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[o==="unavailable"?n.jsx("span",{className:"teammate-reason",children:e.reason}):null,n.jsx(Es,{}),a?n.jsxs("a",{href:lt(a.id),onClick:i(lt(a.id)),children:["Added, open @",a.handle]}):o==="unavailable"?l?n.jsx("a",{href:l.route,onClick:i(l.route),children:l.label}):null:n.jsx(I,{variant:"accent",size:"sm",disabled:r.busy,onClick:r.accept,"aria-label":`Add ${e.name}`,children:"Add"})]}),n.jsx(se,{message:r.failure})]}),children:[n.jsx("p",{className:"ui-card-meta",children:e.text}),n.jsx("p",{className:"teammate-needs",children:e.needs})]})})}const s3=["fact","observation","todo"];function HN({embedded:e,agents:t,timezone:s,agentId:r}){const{data:i,error:a,reload:o}=re(()=>A.memory(r),[r],3e4),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),m=g=>{var N;return g==="shared"?"Everyone":((N=t.find(k=>k.id===g))==null?void 0:N.name)??g},j=async g=>{p(null);try{await g,o()}catch(N){p(N instanceof oe?N.message:String(N))}},w={nameOf:m,timezone:s,onChangePreference:g=>c({key:g.key,scope:g.scope}),onForgetPreference:g=>void j(A.forgetPreference({key:g.key,scope:g.scope})),onEditNote:g=>h(g),onForgetNote:g=>void j(A.forgetNote(g.id))},b=r?m(r):"",v=r&&i?{preferences:i.preferences.filter(g=>g.scope===r),notes:i.notes.filter(g=>g.scope===r)}:null,x=r&&i?{preferences:i.preferences.filter(g=>g.scope==="shared"),notes:i.notes.filter(g=>g.scope==="shared")}:null,y=n.jsx(I,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return n.jsxs(fn,{embedded:e,title:"Memory",lede:"What your agents have kept about you. Correct anything here; they see the change on their next turn.",children:[n.jsx(se,{message:a??f}),v&&x?n.jsxs(V,{gap:"lg",children:[n.jsx(Y,{title:"Preferences",aside:`what you told ${b} alone`,actions:y,panel:!0,flush:!0,children:n.jsx(Ef,{preferences:v.preferences,empty:`Nothing stated to ${b} alone yet.`,...w})}),n.jsx(Y,{title:"Notes",aside:`what ${b} wrote down for itself`,panel:!0,flush:!0,children:n.jsx(Af,{notes:v.notes,empty:`${b} has kept no private notes yet.`,...w})}),n.jsx(It,{summary:`Shared with every agent, which ${b} also reads · ${x.preferences.length} preferences, ${x.notes.length} notes`,children:n.jsxs(V,{gap:"lg",children:[n.jsx(Y,{title:"Shared preferences",panel:!0,flush:!0,children:n.jsx(Ef,{preferences:x.preferences,empty:"No shared preferences.",...w})}),n.jsx(Y,{title:"Shared notes",panel:!0,flush:!0,children:n.jsx(Af,{notes:x.notes,empty:"No shared notes.",...w})})]})})]}):n.jsxs(V,{gap:"lg",children:[n.jsx(Y,{title:"Preferences",aside:"what you said you want, one current value each",actions:y,panel:!0,flush:!0,children:i?n.jsx(Ef,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...w}):n.jsx(ue,{children:"Loading…"})}),n.jsx(Y,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?n.jsx(Af,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...w}):n.jsx(ue,{children:"Loading…"})})]}),l?n.jsx(r3,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:l,onClose:()=>c(null),onSave:async g=>{await j((async()=>{await A.setPreference(g),l.key===g.key&&l.scope!==g.scope&&await A.forgetPreference({key:l.key,scope:l.scope})})()),c(null)}}):null,u?n.jsx(i3,{note:u,agents:t,onClose:()=>h(null),onSave:g=>j(A.updateNote(u.id,g)).then(()=>h(null))}):null]})}function Ef({preferences:e,empty:t,nameOf:s,onChangePreference:r,onForgetPreference:i}){return e.length===0?n.jsx(ue,{children:t}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Preference"}),n.jsx("th",{children:"Value"}),n.jsx("th",{children:"Who sees it"}),n.jsx("th",{className:"num",children:"Since"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:e.map(a=>n.jsxs("tr",{children:[n.jsx("td",{className:"mono",children:a.key}),n.jsx("td",{children:a.value}),n.jsx("td",{children:n.jsx(VN,{scope:a.scope,name:s(a.scope)})}),n.jsxs("td",{className:"num muted",title:a.updatedAt??"",children:[a.updatedAt?_e(a.updatedAt,Date.now()):"",a.revision>1?` · rev ${a.revision}`:""]}),n.jsx("td",{className:"num",children:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",onClick:()=>r(a),title:"Store a new value for this key",children:"Change"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>i(a),children:"Forget"})]})})]},`${a.scope}:${a.key}`))})]})}function Af({notes:e,empty:t,nameOf:s,timezone:r,onEditNote:i,onForgetNote:a}){return e.length===0?n.jsx(ue,{children:t}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Note"}),n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"Who sees it"}),n.jsx("th",{children:"Written by"}),n.jsx("th",{className:"num",children:"When"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:e.map(o=>n.jsxs("tr",{children:[n.jsx("td",{className:"memory-note",children:o.content}),n.jsx("td",{children:n.jsx(ye,{tone:o.kind==="todo"?"warning":o.kind==="fact"?"good":void 0,children:o.kind})}),n.jsx("td",{children:n.jsx(VN,{scope:o.scope,name:s(o.scope)})}),n.jsx("td",{className:"muted",children:o.createdByAgent?s(o.createdByAgent):""}),n.jsxs("td",{className:"num muted",title:o.createdAt??"",children:[o.createdAt?_e(o.createdAt,Date.now()):"",o.expiresAt?n.jsxs("span",{className:"memory-expires",children:[" · until ",new Date(o.expiresAt).toLocaleDateString(void 0,{timeZone:r})]}):null]}),n.jsx("td",{className:"num",children:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",onClick:()=>i(o),children:"Edit"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>a(o),children:"Forget"})]})})]},o.id))})]})}function VN({scope:e,name:t}){return n.jsx(ye,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function KN({value:e,agents:t,onChange:s}){return n.jsxs("select",{value:e,onChange:r=>s(r.target.value),children:[n.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>n.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function r3({agents:e,existing:t,initial:s,onClose:r,onSave:i}){const a=t.find(x=>x.key===s.key&&x.scope===s.scope),[o,l]=d.useState(s.key),[c,u]=d.useState((a==null?void 0:a.value)??""),[h,f]=d.useState(s.scope),[p,m]=d.useState(!1),j=o.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(x=>x.key===j&&x.scope===h),b=!a||j!==a.key||c.trim()!==a.value||h!==a.scope,v=j!==""&&c.trim()!==""&&b;return n.jsx(en,{title:"A preference",onClose:r,children:n.jsxs(V,{children:[n.jsx(W,{children:'A preference is a standing choice, in your words: "paid biweekly on Thursdays", "answers short, numbers first". Storing the same key again records a correction and keeps the old value in the history.'}),n.jsx(J,{label:"Key",hint:j&&j!==o?`Stored as ${j}`:"Short and stable, like reporting_currency or tone.",children:n.jsx("input",{value:o,autoFocus:s.key==="",onChange:x=>l(x.target.value),placeholder:"reporting_currency"})}),n.jsx(J,{label:"Value",children:n.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:s.key!=="",onChange:x=>u(x.target.value),placeholder:"EUR"})}),n.jsx(J,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:n.jsx(KN,{value:h,agents:e,onChange:f})}),w&&w!==a?n.jsxs(W,{tone:"warning",children:['This replaces the value already stored for this key here, "',w.value,'" (revision ',w.revision,")."]}):null,a&&h!==a.scope?n.jsxs(W,{children:["It moves: the copy for ",a.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:r,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!v||p,onClick:()=>{m(!0),i({key:j,value:c.trim(),scope:h}).finally(()=>m(!1))},children:a?"Save change":"Save"})]})]})})}function i3({note:e,agents:t,onClose:s,onSave:r}){var m;const[i,a]=d.useState(e.content),[o,l]=d.useState(e.scope),[c,u]=d.useState(e.kind),[h,f]=d.useState(!1),p=i.trim()!==e.content||o!==e.scope||c!==e.kind;return n.jsx(en,{title:"A note",onClose:s,children:n.jsxs(V,{children:[n.jsx(J,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:n.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:j=>a(j.target.value)})}),n.jsxs(Xs,{children:[n.jsx(J,{label:"Kind",children:n.jsx("select",{value:c,onChange:j=>u(j.target.value),children:s3.map(j=>n.jsx("option",{value:j,children:j},j))})}),n.jsx(J,{label:"Who sees it",children:n.jsx(KN,{value:o,agents:t,onChange:l})})]}),e.createdByAgent?n.jsxs("p",{className:"muted",children:["Written by ",((m=t.find(j=>j.id===e.createdByAgent))==null?void 0:m.name)??e.createdByAgent,e.createdAt?`, ${_e(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,children:"Cancel"}),n.jsx(I,{variant:"accent",disabled:!p||i.trim()===""||h,onClick:()=>{f(!0);const j={};i.trim()!==e.content&&(j.content=i.trim()),o!==e.scope&&(j.scope=o),c!==e.kind&&(j.kind=c),r(j).finally(()=>f(!1))},children:"Save"})]})]})})}function a3({agentId:e,agentName:t}){const{data:s,error:r,reload:i}=re(()=>A.agentSkills(e),[e],3e4),[a,o]=d.useState(null),[l,c]=d.useState(null),[u,h]=d.useState(null),f=async j=>{o(null),c(null),h(j.name);try{const w=await A.removeSkill(e,j.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){o(w instanceof oe?w.message:String(w))}finally{h(null)}};if(!s)return r?n.jsx(se,{message:r}):n.jsx(ue,{children:"Loading…"});const p=s.skills.filter(j=>j.learned!==null),m=s.skills.filter(j=>j.learned===null);return n.jsxs(V,{divided:!0,children:[n.jsx(se,{message:r??a}),l?n.jsx(W,{tone:"good",role:"status",children:l}):null,n.jsx(Y,{title:"Learned",aside:n.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:p.length===0?n.jsx(Rt,{icon:"bulb",title:"Nothing learned yet",children:s.writable?`When ${t} proposes a procedure and you keep it on Settings → Proposals, it appears here.`:`${t} ships with buddi, so it keeps no learned skills of its own until it is yours.`}):n.jsx(vt,{flush:!0,children:n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Skill"}),n.jsx("th",{children:"Version"}),n.jsx("th",{children:"Came from"}),n.jsx("th",{className:"num",children:"Kept"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:p.map(j=>n.jsx(l3,{skill:j,busy:u===j.name,onRemove:()=>void f(j)},j.name))})]})})}),n.jsx(Y,{title:"From files and plugins",aside:n.jsx("span",{className:"muted",children:"read-only here"}),children:m.length===0?n.jsx(ue,{children:"No other skills."}):n.jsx(vt,{flush:!0,children:n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Skill"}),n.jsx("th",{children:"What it is for"}),n.jsx("th",{children:"Whose"})]})}),n.jsx("tbody",{children:m.map(j=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(It,{summary:n.jsx("span",{className:"mono",children:j.name}),children:[n.jsx(bt,{children:j.body}),n.jsx("p",{className:"muted mono skill-file",children:j.file})]})}),n.jsx("td",{children:j.description}),n.jsx("td",{children:n.jsxs(V,{gap:"sm",children:[n.jsx(ye,{children:j.scope==="shared"?"shared":`${t} only`}),n.jsx("span",{className:"muted",children:o3(j)})]})})]},`${j.scope}:${j.name}`))})]})})})]})}function o3(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function l3({skill:e,busy:t,onRemove:s}){const r=e.learned;return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(It,{summary:n.jsxs("span",{children:[r.title," ",n.jsx("span",{className:"muted mono",children:e.name})]}),children:[n.jsxs("p",{className:"muted",children:["When: ",e.description]}),n.jsx(bt,{children:e.body}),n.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),n.jsx("td",{children:n.jsxs(V,{gap:"sm",children:[n.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?n.jsx(ye,{tone:"warning",children:"untrusted text in view"}):null]})}),n.jsx("td",{children:n.jsxs(V,{gap:"sm",children:[r.conversation?n.jsx("a",{href:ha(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):n.jsx("span",{className:"muted",children:"no conversation"}),n.jsx("a",{href:Ze("proposals"),children:"the proposal"}),r.sources.length>0?n.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>n.jsx("li",{className:"mono",children:i},i))}):null]})}),n.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?_e(r.keptAt,Date.now()):""}),n.jsx("td",{className:"num",children:n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",variant:"ghost",disabled:t,onClick:s,children:"Remove"})})})]})}function GN({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=re(()=>A.reminders(),[],3e4),o=((r==null?void 0:r.reminders)??[]).filter(h=>!s||h.agentId===s),[l,c]=d.useState(null),u=async h=>{c(null);try{await A.cancelReminder(h),a()}catch(f){c(f instanceof Error?f.message:String(f))}};return n.jsxs(fn,{embedded:t,title:"Reminders",lede:"A reminder wakes an agent with a note and the instruction to check before it speaks, never a message queued for delivery.",children:[n.jsx(se,{message:i??l}),n.jsx(vt,{flush:!0,children:r?o.length===0?n.jsx(Rt,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Due"}),n.jsx("th",{children:"Agent"}),n.jsx("th",{children:"Note"}),n.jsx("th",{children:"State"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:o.map(h=>n.jsxs("tr",{children:[n.jsxs("td",{className:"nowrap",children:[He(h.dueAt,e),n.jsx("div",{className:"sub",children:_e(h.dueAt)})]}),n.jsx("td",{className:"mono",children:h.agentId}),n.jsxs("td",{children:[h.text,h.context?n.jsx(It,{summary:"context",children:n.jsx(bt,{children:bn(h.context)})}):null]}),n.jsxs("td",{children:[n.jsx(rd,{state:h.state}),h.cancelReason?n.jsx("div",{className:"sub",children:h.cancelReason}):null]}),n.jsx("td",{children:h.state==="pending"?n.jsx(I,{size:"sm",variant:"danger",onClick:()=>u(h.id),children:"Cancel"}):null})]},h.id))})]}):n.jsx(ue,{children:"Loading…"})})]})}function Bg({accountId:e,label:t,value:s,onChange:r,disabled:i=!1}){const[a,o]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(""),[f,p]=d.useState(!1),m=d.useRef(0),j=async x=>{if(!e)return;const y=++m.current;c(!0),h("");try{const g=await A.accountModels(e,x);y===m.current&&o(g)}catch(g){y===m.current&&h(g instanceof Error?g.message:"Could not load models. Custom entry is still available.")}finally{y===m.current&&c(!1)}};if(d.useEffect(()=>(o(null),p(!1),h(""),j(!1),()=>{m.current++}),[e]),!e)return n.jsxs(n.Fragment,{children:[n.jsx(J,{label:t,children:n.jsx("input",{required:!0,maxLength:150,value:s,disabled:i,onChange:x=>r(x.target.value)})}),n.jsx("p",{className:"ui-toolbar-note",children:"Save and connect the account to load its model list. You can enter a model manually now."})]});const w=(a==null?void 0:a.models)??[],b=!!s&&!w.some(x=>x.id===s),v=[a&&!w.length?"This account returned no models. You can enter a custom model.":null,a!=null&&a.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,a?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return n.jsxs(n.Fragment,{children:[n.jsx(J,{label:t,children:n.jsxs("select",{value:f?"__buddi_custom__":s,disabled:i,onChange:x=>{x.target.value==="__buddi_custom__"?p(!0):(p(!1),r(x.target.value))},children:[n.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),b&&n.jsxs("option",{value:s,children:[s," (current",a?", not listed":"",")"]}),w.map(x=>n.jsxs("option",{value:x.id,children:[x.name===x.id?x.id:`${x.name} — ${x.id}`,x.isDefault?" (provider default)":""]},x.id)),n.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),n.jsx(I,{disabled:i||l,onClick:()=>void j(!0),children:l?"Loading models…":"Refresh models"}),f&&n.jsx(J,{label:`Custom ${t.toLowerCase()}`,children:n.jsx("input",{required:!0,maxLength:150,value:s,disabled:i,onChange:x=>r(x.target.value)})}),u&&n.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),v.length>0&&n.jsx("p",{className:"ui-toolbar-note",children:v.join(" ")})]})}function c3(e,t){const s=new Set(t),r=[],i=new Set;for(const a of e){for(const l of a.tools)i.add(l.name);const o=a.tools.filter(l=>s.has(l.name));o.length!==0&&(a.glob&&o.length===a.tools.length?r.push(a.glob):r.push(...o.map(l=>l.name)))}return r.push(...t.filter(a=>!i.has(a))),r}function u3(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const d3="This agent will not remember anything between conversations.";function f3({view:e,chosen:t,onChange:s,disabled:r}){var N;const[i,a]=d.useState(""),[o,l]=d.useState(null),[c,u]=d.useState(()=>new Set),h=k=>u(S=>{const C=new Set(S);return C.has(k)?C.delete(k):C.add(k),C}),f=k=>{a(k),u(new Set)},p=d.useId(),m=new Set(t),j=new Set(e.groups.flatMap(k=>k.tools.filter(S=>S.core).map(S=>S.name))),w=(k,S)=>{const C=S.filter(R=>m.has(R));if(C.length!==0){if(C.some(R=>j.has(R))){l({plugin:k,names:C});return}s(t.filter(R=>!C.includes(R)))}},b=k=>{s([...t,...k.filter(S=>!m.has(S))])},v=i.trim().toLowerCase(),x=(k,S)=>v===""||k.toLowerCase().includes(v)||S.toLowerCase().includes(v),y=e.groups.map(k=>({group:k,tools:k.tools.filter(S=>x(S.name,S.description))})).filter(k=>k.tools.length>0),g=(((N=e.suggested)==null?void 0:N.tools)??[]).filter(k=>!m.has(k.name));return n.jsxs("div",{className:"tool-picker",children:[e.suggested&&g.length>0?n.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${p}-suggested`,children:[n.jsx("div",{className:"tool-picker-head",children:n.jsx("span",{id:`${p}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),n.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:g.map(k=>n.jsxs("li",{className:"ui-list-row",children:[n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title mono",children:k.name}),n.jsx("span",{className:"ui-list-sub",children:k.description})]}),n.jsx(I,{size:"sm",disabled:r,"aria-label":`Add ${k.name}`,onClick:()=>b([k.name]),children:"Add"})]},k.name))})]}):null,n.jsxs("label",{className:"tool-picker-search",children:[n.jsx("span",{className:"ui-field-label",children:"Find a tool"}),n.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:k=>f(k.target.value)})]}),y.length===0?n.jsxs(ue,{children:["No installed tool matches “",i.trim(),"”."]}):null,y.map(({group:k,tools:S})=>{const C=k.tools.filter(T=>T.grantable).map(T=>T.name),R=k.tools.filter(T=>m.has(T.name)).length,E=!!k.glob&&R===k.tools.length,P=`${p}-${k.plugin}`,O=`${p}-${k.plugin}-list`,U=v!==""?!c.has(k.plugin):c.has(k.plugin);return n.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":P,"data-open":U?"true":void 0,children:[n.jsxs("div",{className:"tool-picker-head",children:[n.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":U,"aria-controls":O,onClick:()=>h(k.plugin),children:[n.jsx(h3,{}),n.jsx("span",{id:P,className:"tool-picker-plugin",children:k.plugin}),n.jsx("span",{className:"muted",children:E?`all ${k.tools.length}`:`${R} of ${k.tools.length} granted`})]}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":`All ${k.plugin} tools`,disabled:r||C.every(T=>m.has(T)),onClick:()=>b(C),children:"all"}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":`No ${k.plugin} tools`,disabled:r||!C.some(T=>m.has(T)),onClick:()=>w(k.plugin,C),children:"none"})]}),(o==null?void 0:o.plugin)===k.plugin?n.jsx(W,{tone:"warning",role:"alert",children:n.jsxs("div",{className:"tool-picker-confirm",children:[n.jsx("span",{children:d3}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{size:"sm",onClick:()=>l(null),children:"Keep"}),n.jsx(I,{size:"sm",variant:"danger",onClick:()=>{s(t.filter(T=>!o.names.includes(T))),l(null)},children:"Remove"})]})}):null,n.jsx("ul",{id:O,className:"ui-list tool-picker-list",hidden:!U,children:S.map(T=>{const M=`${p}-${T.name}`;return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",id:M,checked:m.has(T.name),disabled:r||!T.grantable,onChange:L=>L.target.checked?b([T.name]):w(k.plugin,[T.name])}),n.jsxs("label",{htmlFor:M,className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[n.jsx("span",{className:"mono",children:T.name}),T.core?n.jsx(ye,{tone:"accent",children:"core"}):null,T.gated?n.jsx(ye,{tone:"warning",children:"asks you"}):null]}),n.jsx("span",{className:"ui-list-sub",children:T.grantable?T.description:`${T.description} Granted only by editing the file by hand.`})]})]},T.name)})})]},k.plugin)})]})}function h3(){return n.jsx("svg",{className:"tool-picker-chevron",viewBox:"0 0 11 11","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const p3=(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 YN(e){const t=await fetch(_r(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const s=await t.blob();return new File([s],`buddi-blob-${e}.png`,{type:"image/png"})}function qN({face:e,onPick:t,label:s=_.assistant.face,kept:r,disabled:i,disableEmoji:a,children:o}){return n.jsxs("div",{className:"meet-faces",role:"group","aria-label":s,children:[n.jsxs("div",{className:"meet-face-row",children:[r?n.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":(e==null?void 0:e.kind)==="kept"?"true":void 0,"aria-pressed":(e==null?void 0:e.kind)==="kept","aria-label":"The current picture",disabled:i,onClick:()=>t({kind:"kept",url:r}),children:n.jsx("img",{src:r,alt:""})}):null,x$.map(l=>{const c={kind:"mascot",role:l},u=p3(e,c);return n.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":_.assistant.mascot(l),disabled:i,onClick:()=>t(c),children:n.jsx("img",{src:_r(l),alt:""})},l)})]}),n.jsx("div",{className:"meet-face-row",children:j$.map(l=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===l;return n.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||a,onClick:()=>t({kind:"emoji",value:l}),children:l},l)})}),o]})}const m3=["mirror","en","fr"],QN=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"access",label:"Access"}],hy=e=>{var t;return((t=QN.find(s=>s.id===e))==null?void 0:t.id)??"identity"};function g3({agentId:e,section:t,navigate:s}){var w,b,v;const{data:r,error:i,reload:a}=re(()=>A.agents(),[]),[o,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(hy(t));d.useEffect(()=>f(hy(t)),[t]);const p=x=>{f(x),s==null||s(lt(e,"setup",x))},m=async x=>{l(null),u(null);try{const y=await x;u(y.changed.length===0?`No file change needed. ${y.note}.`:`Changed ${y.changed.join(", ")}. ${y.note}.`),a()}catch(y){l(y instanceof Error?y.message:String(y))}},j=r==null?void 0:r.agents.find(x=>x.id===e);return n.jsxs(V,{gap:"lg",children:[n.jsx(ad,{level:"secondary",label:"Setup",children:QN.map(x=>n.jsx(od,{href:lt(e,"setup",x.id),active:h===x.id,onClick:y=>{y.preventDefault(),p(x.id)},children:x.label},x.id))}),n.jsx(se,{message:i??o}),c?n.jsx(W,{tone:"good",role:"status",children:c}):null,r?j?n.jsx(x3,{agent:j,all:r.agents,engine:r.engines.find(x=>x.id===j.id),providers:r.providers,accounts:r.providerAccounts,shown:h,onShow:p,onRun:m,onSaved:a},`${j.id}:${(w=r.engines.find(x=>x.id===j.id))==null?void 0:w.model}:${(v=(b=r.providerAccounts)==null?void 0:b.bindings.find(x=>x.agentId===j.id))==null?void 0:v.accountId}`):n.jsx(ue,{children:"This agent is not installed as a file."}):n.jsx(ue,{children:"Loading…"})]})}function x3({agent:e,all:t,engine:s,providers:r,accounts:i,shown:a,onShow:o,onRun:l,onSaved:c}){const u=(s==null?void 0:s.provider)??e.provider.kind,h=r.find(g=>g.kind===u),f=(s==null?void 0:s.model)??e.model,[p,m]=d.useState(String((s==null?void 0:s.maxTurns)??e.maxTurns)),j=g=>{l(A.setAgentEngine(e.id,g))},w=g=>{const N=r.find(k=>k.kind===g);j({provider:g,model:(N==null?void 0:N.defaultModel)??f})},b=(h==null?void 0:h.models.map(g=>g.id))??[],v=b.includes(f)?b:[f,...b],x=s?s.available:!0,y=(s==null?void 0:s.unavailableReason)??"no credential";return n.jsxs(n.Fragment,{children:[n.jsx("div",{hidden:a!=="identity",children:n.jsxs(V,{gap:"lg",children:[x?null:n.jsxs(W,{tone:"warning",children:["This agent cannot run right now."," ",n.jsx("a",{href:lt(e.id,"setup","brain"),onClick:g=>{g.preventDefault(),o("brain")},children:"See Brain."})]}),n.jsx(v3,{agent:e,onSaved:c})]})}),n.jsx("div",{hidden:a!=="brain",children:n.jsxs(V,{gap:"lg",children:[x?null:n.jsxs(W,{tone:"warning",children:["This agent cannot run right now: ",y,"."]}),n.jsx(Y,{panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsxs(Y,{title:"Runs on",children:[i?n.jsx(k3,{agentId:e.id,accounts:i,onRun:l}):n.jsxs(Xs,{children:[n.jsx(J,{label:"Provider",children:n.jsx("select",{value:u,onChange:g=>w(g.target.value),children:r.map(g=>n.jsxs("option",{value:g.kind,children:[g.kind,g.usable?"":" (no credential)"]},g.kind))})}),n.jsxs(J,{label:"Model",children:[n.jsx("input",{list:`models-${e.id}`,defaultValue:f,onBlur:g=>{g.target.value.trim()!==""&&g.target.value.trim()!==f&&j({model:g.target.value.trim()})}}),n.jsx("datalist",{id:`models-${e.id}`,children:v.map(g=>n.jsx("option",{value:g},g))})]})]}),i?null:n.jsxs("p",{className:"ui-card-meta",children:[(s==null?void 0:s.credentialKind)??e.provider.credentialKind," from"," ",n.jsx("span",{className:"mono",children:(s==null?void 0:s.credentialEnv)??e.provider.credentialEnv}),h&&!h.usable?` · default model ${h.defaultModel} (${h.defaultFrom})`:""]}),s!=null&&s.restartRequired?n.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),n.jsx(Y,{title:"Behaviour",aside:"saved as you change them",children:n.jsxs(Xs,{children:[n.jsx(J,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:n.jsx("input",{type:"number",min:1,value:p,onChange:g=>m(g.target.value),onBlur:()=>{const g=Number(p);Number.isInteger(g)&&g>=1&&g!==((s==null?void 0:s.maxTurns)??e.maxTurns)&&j({maxTurns:g})}})}),n.jsx(J,{label:"Language",hint:"Mirror answers in whatever language you write.",children:n.jsx("select",{value:(s==null?void 0:s.language)??e.language,onChange:g=>j({language:g.target.value}),children:m3.map(g=>n.jsx("option",{value:g,children:g},g))})}),ik(ak(s??{id:e.id,provider:u},i))?n.jsx(J,{label:"Thinking",hint:"Reasoning before the answer. Off is faster and cheaper.",children:n.jsxs("select",{"aria-label":"Thinking",value:(s==null?void 0:s.thinking)??"default",onChange:g=>j({thinking:g.target.value==="default"?null:g.target.value}),children:[n.jsx("option",{value:"default",children:"Model default"}),n.jsx("option",{value:"on",children:"On"}),n.jsx("option",{value:"off",children:"Off"})]})}):n.jsx(J,{label:"Thinking",hint:HI,children:n.jsx("span",{className:"ui-card-meta",children:"Up to the model"})})]})})]})})]})}),n.jsx("div",{hidden:a!=="access",children:n.jsxs(V,{gap:"lg",children:[n.jsx(j3,{agent:e,all:t,onSaved:c}),n.jsx(E3,{agent:e,all:t,onSaved:c}),n.jsx(It,{summary:"Built-in context",boxed:!0,children:n.jsx("p",{className:"ui-card-meta",children:"Every agent receives current time, owner timezone and server-host information. system.time and system.info are always available, without grants or approval. Host and browser access still require their own permissions."})})]})})]})}function XN({dirty:e,busy:t,failure:s,label:r,onSave:i}){return n.jsxs(n.Fragment,{children:[s?n.jsx("span",{className:"critical save-error",role:"alert",children:s}):n.jsx("span",{className:e?"warning":"muted",children:e?"Not saved yet.":"Saved. Applies to new runs."}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{variant:"accent",disabled:!e||t,onClick:i,children:r})]})}const JN=n.jsx(W,{tone:"warning",children:"This agent ships with buddi, so its file is read-only here. Ask Agent Father to make it yours, then these fields can change."});function v3({agent:e,onSaved:t}){var U;const[s,r]=d.useState(e.name),[i,a]=d.useState(e.handle),[o,l]=d.useState(e.description),[c,u]=d.useState(e.avatar??""),[h,f]=d.useState(!1),p=re(()=>A.agentFile(e.id),[e.id]),[m,j]=d.useState(null),w=((U=p.data)==null?void 0:U.persona.trim())??"",b=m??w,v=p.data!==void 0&&m!==null&&m.trim()!==w,[x,y]=d.useState(!1),[g,N]=d.useState(null),[k,S]=d.useState(null),C=s.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||o.trim()!==e.description||c.trim()!==(e.avatar??"")||v,R=c.trim()!==""&&(c.trim()!==(e.avatar??"")||!e.picture),E=Tp(R?{...e,avatar:c.trim()}:e),P={...E?{avatar:E}:{},...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...!R&&e.picture?{picture:e.picture}:{}},O=async()=>{y(!0),N(null),S(null);try{const T=await A.updateAgentFile(e.id,{name:s.trim(),handle:i.trim().replace(/^@/,""),description:o.trim(),...c.trim()===""?{}:{avatar:c.trim()},...v&&b.trim()!==""?{persona:b.trim()}:{}});e.picture&&c.trim()!==""&&c.trim()!==(e.avatar??"")&&(await A.removeAgentPicture(e.id),window.dispatchEvent(new Event(Uo))),j(null),p.reload(),S(T.message),t()}catch(T){N(T instanceof Error?T.message:String(T))}finally{y(!1)}};return n.jsx(Y,{title:"Who it is",aside:n.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:n.jsx(XN,{dirty:C,busy:x,failure:g,label:"Save who it is",onSave:()=>void O()}),children:n.jsxs(V,{children:[e.isExample?JN:null,k?n.jsx(W,{tone:"good",role:"status",children:k}):null,n.jsxs(Xs,{children:[n.jsx(J,{label:"Name",hint:"What it is called, everywhere.",children:n.jsx("input",{value:s,disabled:x||e.isExample,onChange:T=>r(T.target.value)})}),n.jsx(J,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:n.jsx("input",{value:i,disabled:x||e.isExample,onChange:T=>a(T.target.value)})})]}),n.jsxs(Q,{children:[n.jsx(os,{id:e.id,name:s.trim()||e.name,size:"xl",face:P}),n.jsx(I,{"aria-expanded":h,onClick:()=>f(T=>!T),children:h?"Hide faces":"Change face"})]}),h?n.jsx(w3,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:x}):null,n.jsx(J,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:n.jsx("textarea",{rows:2,value:o,disabled:x||e.isExample,onChange:T=>l(T.target.value)})}),n.jsx(J,{label:"Persona",hint:n.jsxs(n.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",n.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:p.error?n.jsx(se,{message:p.error}):p.data?n.jsx("textarea",{className:"setup-persona",value:b,rows:Math.max(6,b.split(`
110
+ `).length+1),disabled:x||e.isExample,onChange:T=>j(T.target.value)}):n.jsx(ue,{children:"Reading its file…"})})]})})}function j3({agent:e,all:t,onSaved:s}){var R;const r=re(()=>A.agentTools(e.id),[e.id]),[i,a]=d.useState(null),[o,l]=d.useState(()=>new Set((e.roles??[]).filter(pj))),[c,u]=d.useState((e.roles??[]).filter(E=>!pj(E)).join(", ")),[h,f]=d.useState(!1),[p,m]=d.useState(null),[j,w]=d.useState(null),b=(E,P)=>E.split(P).map(O=>O.trim()).filter(O=>O!==""),v=((R=r.data)==null?void 0:R.granted)??e.tools,x=i??v,y=r.data!==void 0&&!u3(x,v),g=mj(o,b(c,/[\n,]/)),N=E=>l(P=>{const O=new Set(P);return O.has(E)?O.delete(E):O.add(E),O}),S=y||!((E,P)=>E.join(",")===P.join(","))(g,mj(new Set(e.roles??[]),e.roles??[])),C=async()=>{f(!0),m(null),w(null);try{const E=await A.updateAgentFile(e.id,{...y&&r.data?{tools:c3(r.data.groups,x)}:{},roles:g});w(E.message),a(null),r.reload(),s()}catch(E){m(E instanceof Error?E.message:String(E))}finally{f(!1)}};return n.jsx(Y,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:n.jsx(XN,{dirty:S,busy:h,failure:p,label:"Save roles and tools",onSave:()=>void C()}),children:n.jsxs(V,{children:[e.isExample?JN:null,j?n.jsx(W,{tone:"good",role:"status",children:j}):null,n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",id:`roles-${e.id}`,children:"Roles"}),n.jsx("div",{className:"role-chips",role:"group","aria-labelledby":`roles-${e.id}`,children:mg.map(E=>{const P=BM(t,E.id),O=P&&P.id!==e.id?P:void 0;return n.jsxs("button",{type:"button",className:"role-chip","aria-pressed":o.has(E.id),"data-on":o.has(E.id)?"true":void 0,disabled:h||e.isExample,onClick:()=>N(E.id),children:[n.jsx("span",{className:"role-chip-label",children:E.label}),n.jsx("span",{className:"role-chip-meaning",children:E.meaning}),O?n.jsxs("span",{className:"role-chip-holder",children:["Held by ",O.name,". If both claim it, the one listed first keeps it."]}):null]},E.id)})}),n.jsx("span",{className:"ui-field-hint",children:"Where buddi sends things when you do not say who. Tools are granted below."})]}),n.jsx(J,{label:"Other roles",hint:"Only a plugin that asks for a role by name reads these. Comma separated.",children:n.jsx("input",{value:c,disabled:h||e.isExample,onChange:E=>u(E.target.value)})}),n.jsxs("div",{className:"ui-field",children:[n.jsxs("span",{className:"ui-field-label",children:["Tools · ",v.length," granted"]}),r.error?n.jsx(se,{message:r.error}):r.data?n.jsx(f3,{view:r.data,chosen:x,onChange:a,disabled:h||e.isExample}):n.jsx(ue,{children:"Loading the installed tools…"})]}),n.jsx(y3,{agentId:e.id,version:v.join(","),disabled:h||e.isExample})]})})}function y3({agentId:e,version:t,disabled:s}){var h;const r=re(()=>Promise.resolve().then(()=>A.rememberedApprovals(e)),[e,t]),[i,a]=d.useState(null),[o,l]=d.useState(null),c=((h=r.data)==null?void 0:h.tools)??[];if(c.length===0)return null;const u=async(f,p)=>{a(f),l(null);try{await A.setRememberedApproval(e,f,p),r.reload()}catch(m){l(m instanceof Error?m.message:String(m))}finally{a(null)}};return n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Connection tools that ask first"}),n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Remembered approvals",children:c.map(f=>n.jsxs(V,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:f.remembered,disabled:s||!f.rememberable||i!==null,onChange:p=>void u(f.tool,p.target.checked)}),n.jsxs("span",{children:[n.jsx("span",{className:"mono",children:f.tool})," · remember my approval"]})]}),f.why?n.jsx("p",{className:"ui-card-meta",children:f.why}):null]},f.tool))}),n.jsx(se,{message:o}),n.jsx("span",{className:"ui-field-hint",children:"Remembered, it asks once and then runs for this agent. Never for a tool that deletes or destroys."})]})}function Tp(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 w3({agent:e,avatar:t,onEmoji:s,onChanged:r,disabled:i}){const[a,o]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(null),f=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),p=a??(f?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),m=async j=>{if(h(null),j.kind==="emoji"){s(j.value);return}if(j.kind==="kept"){s(e.avatar??"");return}o(j),c(!0);try{await A.uploadAgentPicture(e.id,await YN(j.role)),s(e.avatar??""),r(),window.dispatchEvent(new Event(Uo))}catch(w){h(w instanceof Error?w.message:String(w))}finally{o(null),c(!1)}};return n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Face"}),n.jsx(qN,{face:p,label:"Face",kept:e.picture,disabled:i||l,disableEmoji:e.isExample,onPick:j=>void m(j),children:n.jsx(b3,{agent:e,onChanged:r})}),u?n.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function b3({agent:e,onChanged:t}){const[s,r]=d.useState(null),[i,a]=d.useState(null),[o,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[p,m]=d.useState(0);d.useEffect(()=>{if(!s)return a(null);const S=URL.createObjectURL(s);return a(S),()=>URL.revokeObjectURL(S)},[s]);const j=S=>{r(null),m(C=>C+1),f(S),t(),window.dispatchEvent(new Event(Uo))},w=async S=>{l(!0),u(null),f(null);try{j(await S())}catch(C){u(C instanceof Error?C.message:String(C))}finally{l(!1)}},b=()=>w(async()=>(await A.uploadAgentPicture(e.id,s)).note??null),v=()=>w(async()=>(await A.removeAgentPicture(e.id),null)),x={avatar:Tp(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[y,g]=d.useState(!1),N=d.useRef(null),k=S=>{u(null),f(null),r(S??null)};return n.jsxs("div",{className:"setup-upload","data-dragging":y?"true":void 0,onDragOver:S=>{S.preventDefault(),o||g(!0)},onDragLeave:()=>g(!1),onDrop:S=>{var C;S.preventDefault(),g(!1),o||k((C=S.dataTransfer.files)==null?void 0:C[0])},children:[n.jsxs(Q,{children:[n.jsx(os,{id:e.id,name:e.name,size:"xl",face:x}),n.jsx("input",{ref:N,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:o,onChange:S=>{var C;return k((C=S.target.files)==null?void 0:C[0])}},p),n.jsx(I,{disabled:o,onClick:()=>{var S;return(S=N.current)==null?void 0:S.click()},children:"Upload a picture"}),n.jsx("span",{className:"setup-upload-name",children:s?s.name:"or drop one here"}),n.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!s?n.jsx(I,{variant:"ghost",disabled:o,onClick:()=>void v(),children:"Remove picture"}):null,n.jsx(I,{variant:"accent",disabled:!s||o,onClick:()=>void b(),children:"Save picture"})]}),c?n.jsx("span",{className:"critical save-error",role:"alert",children:c}):n.jsx("span",{className:"ui-field-hint",children:h??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function k3({agentId:e,accounts:t,onRun:s}){const r=t.bindings.find(m=>m.agentId===e),[i,a]=d.useState((r==null?void 0:r.accountId)??""),[o,l]=d.useState((r==null?void 0:r.model)??""),[c,u]=d.useState(!1),h=t.accounts.find(m=>m.id===i),f=i!==((r==null?void 0:r.accountId)??"")||o!==((r==null?void 0:r.model)??""),p=t.accounts.find(m=>m.id===(r==null?void 0:r.accountId));return n.jsxs("div",{className:"ui-stack",children:[n.jsxs(Q,{valign:"end",children:[n.jsx(J,{label:"Account",children:n.jsxs("select",{value:i,disabled:c,onChange:m=>{var j;a(m.target.value),l(((j=t.accounts.find(w=>w.id===m.target.value))==null?void 0:j.defaultModel)??"")},children:[n.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(m=>n.jsxs("option",{value:m.id,disabled:!m.enabled,children:[m.label,m.enabled?m.configured?"":" (needs credential)":" (disabled)"]},m.id))]})}),n.jsx(Bg,{accountId:h!=null&&h.configured?i:void 0,label:"Model",value:o,onChange:l,disabled:c},`${i}:${h==null?void 0:h.revision}`)]}),n.jsxs(Q,{children:[f&&i&&o.trim()?n.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",p?`${p.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):n.jsx("span",{className:"muted",children:p?`Running on ${p.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(I,{variant:"accent",disabled:c||!i||!o.trim()||!f,onClick:()=>{u(!0),s(A.assignProviderAccount(e,i,o).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const S3=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],Tf=e=>e.tools.some(t=>S3.includes(t)),N3=["front-desk","maker"],C3={"front-desk":"Can ask: everyone, as the front desk",maker:"Can ask: everyone, as the maker",list:"Can ask: everyone"};function E3({agent:e,all:t,onSaved:s}){const[r,i]=d.useState(e.delegates),[a,o]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(!1),[f,p]=d.useState(e.delegates),[m,j]=d.useState(e.asksEveryone),[w,b]=d.useState(!1),v=t.filter(E=>E.id!==e.id),x=N3.find(E=>{var P;return(P=e.roles)==null?void 0:P.includes(E)}),y=m===void 0||w,g=w||[...r].sort().join(",")!==[...f].sort().join(","),N=t.filter(E=>E.id!==e.id&&(E.delegates.includes(e.id)||E.asksEveryone!==void 0&&!Tf(e))),k=E=>i(P=>P.includes(E)?P.filter(O=>O!==E):[...P,E]),S=async E=>{o(!0),c(null),h(!1);try{const P=await A.setDelegates(e.id,E);p(P.delegates),i(P.delegates),j(P.asksEveryone),b(!1),h(!0),s()}catch(P){c(P instanceof Error?P.message:String(P))}finally{o(!1)}},C=()=>{i(v.filter(E=>!Tf(E)).map(E=>E.id)),b(!0),h(!1)},R=g?"Not saved yet.":u?"Saved. Applies to the next run.":y?r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`:"Asks everyone.";return n.jsx(Y,{title:"Delegation",aside:e.tools.includes("agent.delegate")?"holds agent.delegate":"no agent.delegate tool: it cannot ask anyone until granted",panel:!0,foot:e.isExample?void 0:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:g?"warning":"muted",children:R}),n.jsx("span",{className:"ui-toolbar-spacer"}),y&&x!==void 0?n.jsx(I,{disabled:a,onClick:()=>void S(["*"]),children:"Let it ask everyone"}):null,y?n.jsx(I,{variant:"accent",disabled:!g||a,onClick:()=>void S(r),children:"Save who it can ask"}):n.jsx(I,{variant:"accent",disabled:a,onClick:C,children:"Limit to…"})]}),children:n.jsxs(V,{divided:!0,children:[n.jsxs(Y,{title:"Can ask",children:[e.isExample?n.jsx(W,{tone:"warning",children:"This agent ships with buddi, so its allowlist is read-only here. Ask Agent Father to make it yours, then it can change."}):null,n.jsx(se,{message:l}),y?v.length===0?n.jsx(ue,{children:"Nobody else is installed."}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Only the agents ticked here. New teammates must be added here before it can ask them."}),n.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:v.map(E=>{const P=Tf(E);return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${E.id}`,checked:r.includes(E.id),disabled:P||e.isExample||a,onChange:()=>k(E.id)}),n.jsxs("label",{htmlFor:`can-ask-${e.id}-${E.id}`,className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[E.name," ",n.jsxs("span",{className:"mono muted",children:["@",E.handle]})]}),n.jsx("span",{className:"ui-list-sub",children:P?"Makes and changes agents. Never reachable by delegation.":E.description})]})]},E.id)})})]}):n.jsxs("p",{className:"ui-card-meta",children:[C3[m??"list"],". New agents are included without being added here; agents that make and change agents are never reachable by delegation."]})]}),n.jsx(Y,{title:"Asked by",children:N.length===0?n.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):n.jsx(sO,{children:N.map(E=>n.jsx(ye,{children:E.name},E.id))})})]})})}const A3=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],T3=[{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 R3({hash:e,timezone:t,navigate:s,agents:r,attention:i,defaultAgentId:a}){var v,x,y,g,N;const o=AM(e),l=((v=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:v[1])??"team",c=k=>S=>{S.preventDefault(),s(k)},u=re(()=>A.agents(),[]),h=Rg(),f=re(()=>A.offers(),[],2e4),p=oN(),m=(((x=f.data)==null?void 0:x.offers.length)??0)+p.offers.length,j=((g=(y=u.data)==null?void 0:y.default)==null?void 0:g.defaultAgentId)??a??null,w=r.find(k=>k.roles.includes(nd)),b=WN(r,j);return n.jsxs("div",{className:"ui-page",children:[n.jsx(jg,{title:"Agents",lede:`Your team. Each one is a file on ${h} — what it can reach is listed on its page.`,actions:w?n.jsx(Zt,{variant:"accent",href:Ve(w.id),onClick:c(Ve(w.id)),children:"Add an agent"}):null}),n.jsx(ad,{children:A3.map(k=>n.jsx(od,{href:k.id==="team"?ot:`${ot}?tab=${k.id}`,active:l===k.id,count:k.id==="offers"?m:void 0,onClick:c(k.id==="team"?ot:`${ot}?tab=${k.id}`),children:k.label},k.id))}),l==="missions"?n.jsx(UN,{timezone:t,embedded:!0}):null,l==="offers"?n.jsx(lN,{offers:p.offers,reload:p.reload}):null,l==="offers"?n.jsx(zN,{embedded:!0}):null,l==="reminders"?n.jsx(GN,{timezone:t,embedded:!0}):null,l==="team"&&b?n.jsx(Ap,{navigate:s,standing:!0}):null,l==="team"?n.jsx(I3,{data:u.data,error:u.error,reload:u.reload}):null,l==="team"?r.length===0?n.jsx(Rt,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):n.jsx("div",{className:"agents-grid",children:sS(r,j).map(k=>{const S=td(i.get(k.id));return n.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...al(il(k)),"data-unavailable":k.available?void 0:"true",children:[n.jsx("div",{className:"agent-card-top"}),n.jsx("div",{className:"agent-card-face",children:n.jsx(os,{id:k.id,name:k.name,size:"xl",unavailable:!k.available,face:k})}),n.jsxs("div",{children:[n.jsxs("div",{className:"ui-card-title",children:[n.jsx("a",{className:"agent-card-link",href:lt(k.id,"conversations"),onClick:c(lt(k.id,"conversations")),children:k.name}),n.jsxs("span",{className:"agent-card-handle mono faint",children:["@",k.handle]})]}),n.jsx("p",{className:"ui-card-meta agent-card-desc",children:k.description})]}),n.jsxs("div",{className:"ui-row",children:[k.id===j?n.jsx(Zr,{children:"front desk"}):null,S?n.jsx(ye,{tone:"critical",dot:!0,children:"waiting for you"}):k.available?n.jsx(ye,{tone:"good",dot:!0,children:"ready"}):n.jsx(ye,{tone:"warning",children:Cs(k.unavailableReason??"cannot run",60)}),n.jsx(ye,{mono:!0,children:k.model}),n.jsx(Zt,{className:"agent-card-talk",size:"sm",href:Ve(k.id),onClick:c(Ve(k.id)),"aria-label":`Talk to ${k.name}`,children:"Talk"})]})]},k.id)})}):null,l==="team"&&!b?n.jsx(Ap,{navigate:s,standing:!0}):null,o?n.jsx(en,{title:((N=r.find(k=>k.id===o.agentId))==null?void 0:N.name)??o.agentId,size:"wide",onClose:()=>s(ot),children:n.jsx(P3,{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:s,attention:i})}):null]})}function I3({data:e,error:t,reload:s}){const r=e==null?void 0:e.default,[i,a]=d.useState(null),[o,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null);if(t)return n.jsx(se,{message:t});if(!r||r.choices.length===0)return null;const p=r.defaultAgentId,m=i??p??"",j=m!==""&&m!==p,w=r.problem,b=x=>x.map(y=>{var g;return((g=r.choices.find(N=>N.id===y))==null?void 0:g.name)??y}).join(" and "),v=async()=>{l(!0),u(null),f(null);try{const x=await A.setDefaultAgent(m);f(x.note),a(null),s()}catch(x){u(x instanceof Error?x.message:String(x))}finally{l(!1)}};return n.jsx(vt,{children:n.jsxs("div",{className:"ui-stack",children:[n.jsx(se,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?n.jsx(W,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${b(w.agents)}. The one chosen here wins.`}):(w==null?void 0:w.code)==="no-default-agent"?n.jsx(W,{tone:"warning",role:"status",children:"No agent file claims the default and this installation has not recorded one. Choose who answers when you name nobody."}):null,h?n.jsx(W,{tone:"good",role:"status",children:h}):null,n.jsxs(Q,{children:[n.jsxs("div",{className:"default-agent-text",children:[n.jsx("h3",{className:"default-agent-title",children:"Default agent"}),n.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsxs("select",{"aria-label":"Default agent",value:m,disabled:o,onChange:x=>a(x.target.value),children:[m===""?n.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(x=>n.jsxs("option",{value:x.id,disabled:!x.available,children:[x.name," @",x.handle,x.available?"":" (cannot run)"]},x.id))]}),n.jsx(I,{variant:"accent",disabled:o||!j,onClick:()=>void v(),children:"Save"})]})]})})}function P3({agentId:e,agent:t,agents:s,tab:r,section:i,timezone:a,navigate:o,attention:l}){const c=f=>p=>{p.preventDefault(),o(f)},u=td(l.get(e)),h=(t==null?void 0:t.name)??e;return n.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[n.jsxs("header",{className:"agent-head",children:[n.jsx(os,{id:e,name:h,size:"xl",unavailable:t?!t.available:!1,face:t}),n.jsxs("div",{className:"agent-head-text",children:[n.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),n.jsxs("div",{className:"ui-row",children:[t?n.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?n.jsx("span",{className:"muted",children:t.model}):null,u?n.jsx(ye,{tone:"critical",children:u}):t&&!t.available?n.jsx(ye,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),n.jsx("div",{className:"ui-page-actions",children:n.jsxs(Zt,{variant:"accent",href:Ve(e),onClick:c(Ve(e)),children:["Talk to ",h]})})]}),t&&!t.available?n.jsxs(W,{tone:"warning",role:"status",children:[aS(t)," ",n.jsx("a",{href:Ze(ep(t).section),children:ep(t).label})]}):null,n.jsx(ad,{children:T3.map(f=>n.jsx(od,{href:lt(e,f.id),active:r===f.id,onClick:c(lt(e,f.id)),children:f.label},f.id))}),r==="conversations"?n.jsx(M3,{agentId:e,navigate:o}):null,r==="missions"?n.jsx(UN,{timezone:a,embedded:!0,agentId:e}):null,r==="offers"?n.jsx(zN,{embedded:!0,agentId:e,agentName:h}):null,r==="reminders"?n.jsx(GN,{timezone:a,embedded:!0,agentId:e}):null,r==="memory"?n.jsx(HN,{embedded:!0,agents:s,timezone:a,agentId:e}):null,r==="skills"?n.jsx(a3,{agentId:e,agentName:h}):null,r==="setup"?n.jsx(g3,{agentId:e,section:i,navigate:o}):null]})}function M3({agentId:e,navigate:t}){const{data:s,error:r}=re(()=>Le.conversations(e,50),[e]);if(r)return n.jsx(ue,{children:r});const i=(s==null?void 0:s.conversations)??[];return n.jsx(vt,{flush:!0,children:s?i.length===0?n.jsx(Rt,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):n.jsx(Xt,{children:i.map(a=>n.jsx(cn,{href:Ve(e,a.id),onClick:()=>t(Ve(e,a.id)),title:Cs(a.preview||a.opening||"Untitled conversation",90),sub:`${a.messageCount} message${a.messageCount===1?"":"s"}`,side:_e(a.lastMessageAt??a.startedAt??a.createdAt??null)},a.id))}):n.jsx(ue,{children:"Loading…"})})}const zg="(max-width: 900px)";function Yo(e){const[t,s]=d.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return d.useEffect(()=>{var a;let r;try{r=window.matchMedia(e)}catch{return}const i=o=>s(o.matches);return(a=r.addEventListener)==null||a.call(r,"change",i),()=>{var o;return(o=r.removeEventListener)==null?void 0:o.call(r,"change",i)}},[e]),t}const py=3,$3=40;function O3({agent:e,navigate:t}){var j;const s=d.useRef(null),[r,i]=d.useState(!1),[a,o]=d.useState(null),[l,c]=d.useState(null),u=re(()=>Le.conversations(e.id,py),[e.id],3e4),h=Yo(zg),f=Yo("(pointer: coarse)");d.useEffect(()=>{var w;!h&&!f&&((w=s.current)==null||w.focus())},[]);const p=(w,b)=>{i(!0),o(null),(async()=>{try{const{conversationId:v}=await Le.startConversation(e.id),x=await Le.send(e.id,{conversationId:v,text:w,...b.length>0?{attachmentIds:b.map(y=>y.artifactId)}:{}});t(Ve(e.id,x.conversationId))}catch(v){o(v instanceof oe?v.message:String(v)),c({text:w,at:Date.now()}),i(!1)}})()},m=(((j=u.data)==null?void 0:j.conversations)??[]).slice(0,py);return n.jsxs("div",{className:"home-ask",children:[a?n.jsx(se,{message:a}):null,n.jsx(Ig,{ref:s,disabled:r||!e.available,running:!1,onSend:p,onStop:()=>{},agentName:e.name,placeholder:`Message ${e.name}…`,draft:l,threadKey:`home.${e.id}`}),m.length>0?n.jsxs("div",{className:"home-continue",children:[n.jsx("span",{className:"home-continue-label",id:`home-continue-${e.id}`,children:"Continue"}),n.jsx("ul",{className:"home-continue-chips","aria-labelledby":`home-continue-${e.id}`,children:m.map(w=>{const b=Ve(e.id,w.id),v=w.opening??w.preview??"Untitled conversation",x=hM(w.lastMessageAt??w.createdAt??w.startedAt??null);return n.jsx("li",{children:n.jsxs("a",{className:"home-continue-chip",href:b,title:v,onClick:y=>{y.preventDefault(),t(b)},children:[n.jsx("span",{className:"home-continue-title",children:Cs(v,$3)}),x?n.jsx("span",{className:"home-continue-when",children:x}):null]})},w.id)})})]}):null]})}const ZN="buddi.keepClose";let po=null;const Rp=new Set;function my(){for(const e of Rp)e()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),po=e,my()}),window.addEventListener("appinstalled",()=>{po=null,e1(),my()}));function gy(){try{return window.localStorage.getItem(ZN)!==null}catch{return!1}}function e1(){try{window.localStorage.setItem(ZN,"dismissed")}catch{}}function _3(){var e;try{return((e=window.matchMedia)==null?void 0:e.call(window,"(display-mode: standalone)").matches)??!1}catch{return!1}}function D3(e=window.location.hostname){const t=e.replace(/^\[|\]$/g,"").toLowerCase();return t==="127.0.0.1"||t==="::1"||t==="localhost"}function L3(e){return/Edg\//.test(e)?"In Edge, choose Apps → Install buddi from the … menu.":/(Chrome|CriOS)\//.test(e)?"In Chrome, click the install icon in the address bar.":/Safari\//.test(e)&&/Mac/.test(e)?"In Safari, choose File → Add to Dock.":null}function F3(e){return/Mac|iPhone|iPad/.test(e)}function U3(){const[e,t]=d.useState(()=>gy()||_3()),[s,r]=d.useState(po),[i,a]=d.useState(void 0);if(d.useEffect(()=>{const f=()=>{r(po),gy()&&t(!0)};return Rp.add(f),()=>{Rp.delete(f)}},[]),d.useEffect(()=>{if(e)return;let f=!0;return A.session().then(p=>{f&&a(p.platform)},()=>{}),()=>{f=!1}},[e]),e)return null;const o=typeof navigator>"u"?"":navigator.userAgent,l=D3(),c=s?null:L3(o),u=()=>{e1(),t(!0)},h=()=>{const f=s;f&&f.prompt().then(async()=>{const p=await f.userChoice;po=null,r(null),(p==null?void 0:p.outcome)==="accepted"&&u()},()=>{})};return n.jsxs(W,{tone:"accent",title:"Keep buddi one click away.",children:[n.jsxs("p",{children:[c?`${c} `:null,"Or bookmark it with ",F3(o)?"⌘D":"Ctrl+D",".",l?null:" This tailnet address installs as its own app, separate from the one on the machine buddi runs on."]}),l&&i==="darwin"?n.jsxs("p",{children:["On this Mac, ",n.jsx("span",{className:"mono",children:"buddi dashboard --install-app"})," puts a double-clickable app in ~/Applications (docs/cli.md, under Everyday)."]}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",onClick:u,children:"Not now"}),s?n.jsx(I,{variant:"accent",onClick:h,children:"Install app"}):null]})]})}function B3(e){const t=e.indexOf("?");if(t===-1)return;const s=new URLSearchParams(e.slice(t+1)).get("tip");return s&&/^[a-z0-9-]{1,40}$/.test(s)?s:void 0}function z3({navigate:e,preview:t,hidden:s}){var c;const r=re(()=>A.currentTip(t),[t]),[i,a]=d.useState(null),o=((c=r.data)==null?void 0:c.tip)??null;if(!o||i===o.id||s)return null;const l=u=>{a(o.id),!t&&(u==="dismiss"?A.dismissTip(o.id):A.laterTip(o.id)).catch(()=>{})};return n.jsx("div",{className:"home-tip","data-tip":o.id,children:n.jsxs(W,{children:[n.jsxs("div",{className:"ui-notice-row",children:[n.jsx("p",{className:"ui-notice-body",children:o.text}),n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"Not now",title:"Not now",onClick:()=>l("later"),children:n.jsx(Te,{name:"close"})})]}),n.jsxs(Q,{children:[n.jsx(Es,{}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l("dismiss"),children:"Not this again"}),n.jsx(I,{variant:"accent",size:"sm",onClick:()=>e(o.action.route),children:o.action.label})]})]})})}const Ip="buddi.tipsOpen";function W3(e){const t=new Date(`${e}T12:00:00Z`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}).format(t)}function H3(e){switch(e.status){case"today":return"Due today";case"holding":return"Waiting";case"quiet":return"Not needed now";case"dismissed":return"Dismissed";case"shown":return e.shownAt?`Shown on ${W3(e.shownAt)}`:"Shown"}}function V3(){try{return window.localStorage.getItem(Ip)==="1"}catch{return!1}}function K3(){const e=re(()=>A.tips(),[]),[t,s]=d.useState(V3),r=d.useCallback(i=>{s(i);try{i?window.localStorage.setItem(Ip,"1"):window.localStorage.removeItem(Ip)}catch{}},[]);return{open:t,setOpen:r,list:e}}function G3({tips:e}){const{open:t,setOpen:s,list:r}=e,i=!!r.data&&!r.data.enabled&&r.data.tips.some(a=>a.status==="today");return n.jsxs("button",{type:"button",className:"ui-icon-btn home-tips-btn","aria-label":i?"Tips, one due today":"Tips","aria-pressed":t,title:"Tips","data-open":t,onClick:()=>{t||r.reload(),s(!t)},children:[n.jsx(Te,{name:"bulb"}),i?n.jsx("span",{className:"home-tips-dot","data-testid":"tips-dot"}):null]})}function Y3({tips:e,navigate:t}){var b,v;const{open:s,setOpen:r,list:i}=e,[a,o]=d.useState(null),[l,c]=d.useState(null),[u,h]=d.useState(null);if(!s)return null;const f=((b=i.data)==null?void 0:b.tips)??null,p=u??((v=i.data)==null?void 0:v.enabled)??!0,m=x=>o(x instanceof oe?x.message:String(x)),j=x=>{c(x),o(null),A.restoreTip(x).then(()=>i.reload(),m).finally(()=>c(null))},w=x=>{c("switch"),o(null),h(x),A.saveTipsSettings(x).then(y=>{h(y.enabled),i.reload()}).catch(y=>{h(!x),m(y)}).finally(()=>c(null))};return n.jsx("div",{className:"home-tips","data-testid":"tips-section",children:n.jsxs(Y,{title:"Tips",children:[n.jsx(se,{message:i.error??a}),n.jsx("div",{className:"tips-grid",children:(f??[]).map(x=>n.jsx("div",{className:"tips-card","data-tip":x.id,"data-status":x.status,children:n.jsxs(Kn,{tone:x.status==="today"?"accent":void 0,children:[n.jsx("div",{children:n.jsx(ye,{tone:x.status==="today"?"accent":"muted",children:H3(x)})}),n.jsx("p",{className:"tips-card-text",children:x.text}),n.jsxs(Q,{children:[n.jsx(Es,{}),x.status==="dismissed"?n.jsx(I,{size:"sm",disabled:l===x.id,onClick:()=>j(x.id),children:"Bring back"}):n.jsx(I,{size:"sm",variant:x.status==="today"?"accent":void 0,onClick:()=>t(x.action.route),children:x.action.label})]})]})},x.id))}),n.jsxs(Q,{children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:p,disabled:l==="switch"||f===null,onChange:x=>w(x.target.checked)}),n.jsx("span",{children:"Tips on Home"})]}),n.jsx(Es,{}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Close"})]})]})})}const t1="buddi.needsYouView";function q3(){try{return window.localStorage.getItem(t1)==="list"?"list":"deck"}catch{return"deck"}}function Q3(e){try{window.localStorage.setItem(t1,e)}catch{}}function X3(e,t,s){const r=(t.alsoFrom??[]).filter(i=>i!==t.agentId).map(s);return r.length===0?e:`${e} · also ${r.join(", ")}`}function J3({rows:e,agents:t,label:s,onOpen:r,onDone:i}){const[a,o]=d.useState(0);if(e.length===0)return n.jsx(ue,{mascot:!0,children:"Nothing needs you. Your agents are on it."});const l=Math.min(a,e.length-1),c=e[l],u=e.length>1,h=w=>o((l+w+e.length)%e.length),f=()=>r(c),p=()=>i(c),m=w=>{const b=w.target;b.closest('input, textarea, select, [contenteditable="true"]')||(w.key==="ArrowRight"&&u?(w.preventDefault(),h(1)):w.key==="ArrowLeft"&&u?(w.preventDefault(),h(-1)):w.key==="Enter"&&!b.closest("button, a")?(w.preventDefault(),c.link&&f()):(w.key==="d"||w.key==="Delete")&&!w.metaKey&&!w.ctrlKey&&!w.altKey&&(w.preventDefault(),p()))},j=n.jsxs("span",{className:"home-deck-from",children:[c.agentId?n.jsx(gn,{agents:t,id:c.agentId,size:"sm"}):null,n.jsx("span",{children:s(c)})]});return n.jsx("div",{className:"home-deck","data-depth":Math.min(e.length-1,2),role:"region","aria-label":"Needs you, one at a time","aria-roledescription":"deck",tabIndex:0,onKeyDown:m,children:n.jsx(Kn,{as:"article",title:j,meta:n.jsx("span",{className:"ui-card-meta",children:c.state==="held"?"today":_e(c.createdAt)}),actions:n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"home-deck-count","aria-live":"polite",children:[l+1," of ",e.length]}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":"Previous",disabled:!u,onClick:()=>h(-1),children:n.jsx(Te,{name:"chevron-left"})}),n.jsx(I,{size:"sm",variant:"ghost","aria-label":"Next",disabled:!u,onClick:()=>h(1),children:n.jsx(Te,{name:"chevron-right"})})]}),foot:n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:p,children:"Done"}),c.link?n.jsx(I,{variant:"accent",onClick:f,children:"Open"}):null]}),children:n.jsxs("div",{className:"home-deck-body",children:[n.jsx("p",{className:"home-deck-title",children:c.title}),c.text?n.jsx("p",{className:"home-deck-text",children:c.text}):null]})})})}function Z3({timezone:e,navigate:t,agents:s,defaultAgentId:r,attention:i,update:a,connectionSignals:o=[],hash:l=""}){var Ne,Qe,Ie,rt,fe,xe,ze,Oe,it,ke,De,ee,Ce;const c=re(()=>A.overview(),[],15e3),u=re(()=>A.approvals(),[],1e4),h=re(()=>A.missions(),[],6e4),f=re(()=>A.reminders(),[],6e4),p=re(()=>A.conversations(),[],3e4),m=re(()=>A.offers(),[],3e4),j=re(()=>A.proposals(),[],6e4),w=re(()=>A.agentOffers(),[],6e4),b=re(()=>A.owner(),[]),v=re(()=>A.notifications(20),[],3e4),x=d.useMemo(()=>sS(s,r??null),[s,r]),{busy:y,note:g,failure:N,decide:k}=Pg(()=>{u.reload(),c.reload()}),S=c.data,C=s.find(B=>B.id===r)??null,R=B=>{var Ee;return((Ee=s.find(St=>St.id===B))==null?void 0:Ee.name)??B},E=B=>Ee=>{Ee.preventDefault(),t(B)},P=((Ne=u.data)==null?void 0:Ne.pending)??[],O=((Qe=S==null?void 0:S.jobs)==null?void 0:Qe.failed)??0,U=((Ie=S==null?void 0:S.sentinels)==null?void 0:Ie.openUrgent)??0,T=((rt=j.data)==null?void 0:rt.open.length)??0,M=(((fe=w.data)==null?void 0:fe.offers)??[]).filter(B=>!P.some(Ee=>aN(Ee,B.plugin,B.agent))),L=nU(((xe=v.data)==null?void 0:xe.notifications)??[],P),[K,D]=d.useState(new Set),[q,F]=d.useState(q3),H=L.filter(B=>!K.has(B.id)),le=B=>{D(Ee=>new Set(Ee).add(B.id)),A.notificationSeen(B.id).catch(()=>{})},ie=B=>{le(B),B.link&&t(B.link)},ae=B=>X3(B.agentId?R(B.agentId):B.pluginId??tU[B.kind],B,R),ge=P.length+(O>0?1:0)+(U>0?1:0)+(S!=null&&S.paused?1:0)+(T>0?1:0)+M.length+L.length,X=d.useMemo(()=>{var B,Ee;return aU(((B=h.data)==null?void 0:B.missions)??[],((Ee=f.data)==null?void 0:Ee.reminders)??[])},[h.data,f.data]),de=(((ze=p.data)==null?void 0:ze.conversations)??[]).slice(0,5),me=((Oe=m.data)==null?void 0:Oe.offers)??[],$e=me.slice(0,sU),ne=K3(),be=me.length-$e.length;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"home-band",children:n.jsxs("header",{className:"home-hero",children:[n.jsxs("div",{className:"home-hero-text",children:[n.jsx("p",{className:"home-date",children:cU(S==null?void 0:S.now,e)}),n.jsx("h1",{className:"home-greeting",children:lU(S==null?void 0:S.now,e,((it=b.data)==null?void 0:it.preferredName)||((ke=b.data)==null?void 0:ke.displayName))}),n.jsx("p",{className:"home-lede",children:dU(ge,P.length,O,U,(S==null?void 0:S.paused)??!1,T,M.length,L.length)})]}),n.jsxs("div",{className:"home-hero-side",children:[n.jsx(G3,{tips:ne}),n.jsx(fS,{size:"lg",anim:"idle"})]})]})}),n.jsxs("div",{className:"home",children:[n.jsx(Y3,{tips:ne,navigate:t}),C?n.jsx(O3,{agent:C,navigate:t},C.id):null,n.jsx(U3,{}),n.jsx(z3,{navigate:t,preview:B3(l),hidden:ne.open}),a&&a.updateAvailable&&!a.checkout&&a.latest?n.jsx(W,{tone:"accent",children:n.jsxs("p",{children:["A newer buddi is ready: ",n.jsx("span",{className:"mono",children:a.latest}),"."," ",n.jsx("a",{href:Ze("system"),onClick:E(Ze("system")),children:"Upgrade from Settings → Version."})]})}):null,o.map(B=>n.jsx(W,{tone:"accent",children:n.jsxs("p",{children:[B.sentence," ",n.jsx("a",{href:Ze("connections"),onClick:E(Ze("connections")),children:"Settings → Connections."})]})},B.id)),n.jsx(se,{message:c.error??u.error??N}),g?n.jsx(W,{tone:"good",role:"status",children:g}):null,ge>0?n.jsx(Y,{title:"Needs you",actions:L.length>0?n.jsx(uo,{label:"Show what needs you as",options:[{value:"list",label:"List"},{value:"deck",label:"Deck"}],value:q,onChange:B=>{F(B),Q3(B)}}):void 0,children:n.jsxs(V,{children:[S!=null&&S.paused?n.jsxs(W,{tone:"warning",title:"The installation is paused.",children:["Nothing is being claimed until you resume it."," ",n.jsx(I,{size:"sm",onClick:()=>{A.setPaused(!1).then(()=>c.reload())},children:"Resume"})]}):null,P.map(B=>n.jsx(Mg,{action:B,timezone:e,busy:y===B.id,onDecide:k,agentName:R(B.agentId)},B.id)),L.length>0&&q==="deck"?n.jsx(J3,{rows:H,agents:s,label:ae,onOpen:ie,onDone:le}):null,L.length>0&&q==="list"?n.jsx(vt,{flush:!0,children:n.jsx(Xt,{children:H.map(B=>n.jsx(cn,{href:B.link??void 0,onClick:()=>ie(B),lead:B.agentId?n.jsx(gn,{agents:s,id:B.agentId,size:"sm"}):void 0,title:B.title,sub:ae(B),side:B.state==="held"?"today":_e(B.createdAt)},B.id))})}):null,O>0?n.jsx(W,{tone:"critical",children:n.jsxs("a",{href:`${mt}/jobs?state=failed`,onClick:E(`${mt}/jobs?state=failed`),children:[O," failed job",O===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,U>0?n.jsx(W,{tone:"critical",children:n.jsxs("a",{href:`${mt}/alerts`,onClick:E(`${mt}/alerts`),children:[U," urgent alert",U===1?"":"s"," from your watchers."]})}):null,M.map(B=>n.jsx(vt,{children:n.jsx(Og,{plugin:B.plugin,agent:B.agent,text:B.text,label:`Create @${B.handle}`,handle:B.handle,onDismiss:()=>{A.dismissAgentOffer(B.plugin,B.agent).then(()=>w.reload())}})},`${B.plugin}/${B.agent}`)),T>0?n.jsx(W,{tone:"accent",children:n.jsxs("a",{href:Ze("proposals"),onClick:E(Ze("proposals")),children:[T," proposal",T===1?"":"s"," from your agents to keep or discard."]})}):null,(((De=S==null?void 0:S.sentinels)==null?void 0:De.errors)??[]).map(B=>n.jsxs(W,{tone:"warning",children:["Watcher ",B.sentinelId," failed: ",B.error]},B.sentinelId)),((S==null?void 0:S.mail)??[]).filter(B=>B.lastError).map(B=>n.jsxs(W,{tone:"warning",children:["Source ",B.sourceId,": ",B.lastError]},B.sourceId))]})}):null,n.jsx(Y,{title:"Your team",aside:n.jsx("a",{href:ot,onClick:E(ot),children:"All agents"}),children:s.length===0?n.jsx(ue,{mascot:!0,children:"No agents yet. Add one under Agents."}):n.jsx("div",{className:"home-team",children:x.map(B=>{const Ee=td(i.get(B.id));return n.jsxs("a",{className:"home-face",...al(il(B)),href:Ve(B.id),onClick:E(Ve(B.id)),"data-waiting":Ee?"true":void 0,"data-unavailable":B.available?void 0:"true",children:[n.jsx(os,{id:B.id,name:B.name,size:"lg",unavailable:!B.available,face:B}),n.jsxs("span",{className:"home-face-text",children:[n.jsx("span",{className:"home-face-name",children:B.name}),n.jsx("span",{className:"home-face-status",children:Ee?n1(Ee):B.available?Cs(B.description,60):B.unavailableReason??"Cannot run right now."})]})]},B.id)})})}),WN(s,r)?n.jsx(Ap,{navigate:t}):null,$e.length>0?n.jsx(Y,{title:"On offer",aside:n.jsxs("span",{className:"ui-row",children:[be>0?n.jsxs("a",{href:`${ot}?tab=offers`,onClick:E(`${ot}?tab=offers`),children:[be," more"]}):null,n.jsx(BN,{ids:me.map(B=>B.id),onDone:()=>m.reload()})]}),children:n.jsx("div",{className:"home-offers",children:$e.map(B=>n.jsx(iU,{offer:B,agents:s,open:E(lt(B.agentId,"offers")),onDismissed:()=>m.reload()},B.id))})}):null,(Ce=(ee=j.data)==null?void 0:ee.digest)!=null&&Ce.latest?n.jsx(uU,{digest:j.data.digest.latest,go:E}):null,n.jsxs("div",{className:"home-columns",children:[n.jsx(Y,{title:"Coming up",aside:n.jsx("a",{href:`${ot}?tab=missions`,onClick:E(`${ot}?tab=missions`),children:"All missions"}),children:n.jsx(vt,{flush:!0,children:X.length===0?n.jsx(ue,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):n.jsx(Xt,{children:X.map(B=>n.jsx(cn,{href:B.route,onClick:()=>t(B.route),lead:n.jsx(gn,{agents:s,id:B.agentId,size:"sm"}),title:B.title,sub:`${B.kind} for ${R(B.agentId)}`,side:_e(B.at)},B.key))})})}),n.jsx(Y,{title:"Lately",aside:n.jsx("a",{href:mt,onClick:E(mt),children:"All activity"}),children:n.jsx(vt,{flush:!0,children:de.length===0?n.jsx(ue,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):n.jsx(Xt,{children:de.map(B=>n.jsx(cn,{href:Ve(B.agentId,B.id),onClick:()=>t(Ve(B.agentId,B.id)),lead:n.jsx(gn,{agents:s,id:B.agentId,size:"sm"}),title:B.opening?Cs(B.opening,80):"Untitled conversation",sub:`${R(B.agentId)}, ${B.messageCount} message${B.messageCount===1?"":"s"}`,side:_e(B.lastMessageAt??B.createdAt)},B.id))})})})]}),((S==null?void 0:S.home)??[]).map(B=>n.jsx(fU,{block:B},B.id)),S!=null&&S.jobs&&S.missions?n.jsxs("p",{className:"home-foot muted",children:[Et(S.jobs.pending??0)," queued, ",Et(S.jobs.leased??0)," running, ",Et(S.missions.enabled)," of ",Et(S.missions.total)," missions on."," ",S.paused?n.jsx(ye,{tone:"warning",children:"paused"}):n.jsx(ye,{tone:"good",children:"running"})," ",n.jsx("a",{href:ha("").replace(/\/conversations\/$/,""),onClick:E(mt),children:"Activity"})," · ",n.jsx("a",{href:Ze("system"),onClick:E(Ze("system")),children:"System"})]}):null]})]})}const eU=new Set(["watcher","reminder","failure","recap","plugin"]),tU={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin"};function nU(e,t){const s=new Set(t.map(r=>r.id));return e.filter(r=>eU.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&s.has(r.actionId)))}const sU=6,rU=500;function iU({offer:e,agents:t,open:s,onDismissed:r}){const[i,a]=d.useState(!1),o=d.useRef(null),l=d.useRef(!1),c=()=>{i||(a(!0),A.dismissOffer(e.id).then(r).finally(()=>a(!1)))},u=()=>{o.current!==null&&clearTimeout(o.current),o.current=null};return n.jsxs("span",{className:"home-offer-chip",children:[n.jsxs("a",{className:"home-offer",href:lt(e.agentId,"offers"),onClick:h=>{if(l.current){l.current=!1,h.preventDefault();return}s(h)},title:e.prompt,onTouchStart:()=>{l.current=!1,u(),o.current=setTimeout(()=>{l.current=!0,c()},rU)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[n.jsx(gn,{agents:t,id:e.agentId,size:"sm"}),n.jsx("span",{children:e.label})]}),n.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function aU(e,t){const s=[];for(const r of e)r.enabled&&r.nextRun&&s.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:lt(r.agentId,"missions")});for(const r of t)r.state==="pending"&&s.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:lt(r.agentId,"reminders")});return s.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function oU(e,t){try{const s=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(s)}catch{return new Date().getHours()}}function lU(e,t,s){const r=oU(e,t),i=s!=null&&s.trim()?`, ${s.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function cU(e,t){try{const s=e?new Date(e):new Date,r=new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:t}).format(s),i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",timeZone:t}).format(s);return`${r}, ${i}`}catch{return He(e??null,t)}}function ec(e,t,s){return e.count===0?null:`${e.count} ${e.count===1?t:s}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function uU({digest:e,go:t}){const s=[ec(e.memory,"memory note","memory notes"),ec(e.skills,"skill kept","skills kept"),ec(e.rules,"rule kept","rules kept"),ec(e.changes,"change to an agent kept","changes to agents kept")].filter(i=>i!==null),r=e.stopped===null?"Not measured yet.":e.stopped.total>0?`Rules you kept acted ${e.stopped.total} time${e.stopped.total===1?"":"s"} (${Object.entries(e.stopped.byPlugin).filter(([,i])=>i>0).map(([i,a])=>`${i} ${a}`).join(", ")}).`:"No rule you kept acted this week.";return n.jsx(Y,{title:"What buddi learned this week",aside:n.jsx("span",{className:"muted",children:_e(e.at)}),children:n.jsx(vt,{children:n.jsxs(V,{divided:!0,children:[n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Learned"}),s.length===0?n.jsx("p",{children:"Nothing new."}):n.jsx("ul",{className:"home-digest-list",children:s.map(i=>n.jsx("li",{children:i},i))})]}),n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Proposes"}),n.jsx("p",{children:e.open>0?n.jsxs("a",{href:Ze("proposals"),onClick:t(Ze("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),n.jsx("p",{children:r})]})]})})})}function dU(e,t,s,r,i,a=0,o=0,l=0){if(e===0)return"Nothing needs you. Your agents are on it.";const c=[];t>0&&c.push(`${t} approval${t===1?"":"s"} waiting`),s>0&&c.push(`${s} failed job${s===1?"":"s"}`),r>0&&c.push(`${r} urgent alert${r===1?"":"s"}`),i&&c.push("the installation is paused"),a>0&&c.push(`${a} proposal${a===1?"":"s"} to review`),o>0&&c.push(`${o===1?"an agent":`${o} agents`} to set up`),l>0&&c.push(`${l} message${l===1?"":"s"} for you`);const u=c.length<=1?c.join(""):`${c.slice(0,-1).join(", ")} and ${c[c.length-1]}`;return`${n1(u)}.`}function n1(e){return e.charAt(0).toUpperCase()+e.slice(1)}function fU({block:e}){const[t,s]=d.useState(!1),r=e.sensitive===!0&&!t;d.useEffect(()=>{if(!e.sensitive||!t)return;const a=()=>{document.visibilityState==="hidden"&&s(!1)};return document.addEventListener("visibilitychange",a),window.addEventListener("blur",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("blur",a)}},[e.sensitive,t]);const i=n.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?n.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?n.jsx(I,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>s(a=>!a),children:r?"Show":"Hide"}):null]});return n.jsxs(Y,{title:e.title,aside:i,children:[e.note?n.jsx(W,{tone:"warning",children:e.note}):null,e.stats.length>0?n.jsx(id,{children:e.stats.map(a=>n.jsx(ys,{label:a.label,value:r?"••••":a.value,note:r?void 0:a.note,tone:r?void 0:a.tone},a.label))}):null,e.rows.length>0?r?n.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):n.jsx(vt,{flush:!0,children:n.jsx(Xt,{children:e.rows.map((a,o)=>n.jsx(cn,{title:a.title,sub:a.sub,side:a.side?n.jsx("span",{className:a.tone==="critical"?"critical":a.tone==="good"?"good":void 0,children:a.side}):void 0},`${a.title}-${o}`))})}):null]})}const hU=3e4;function s1(){const{data:e,reload:t}=re(()=>A.recovery(),[],hU);return{data:e,reload:t}}const pU="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function mU({active:e,onNavigate:t}){return e?n.jsxs("div",{className:"recovery-banner",role:"status",children:[n.jsx("span",{children:pU}),n.jsx("a",{href:hj,onClick:s=>{s.preventDefault(),t(hj)},children:"Finish the checklist"})]}):null}function gU({view:e,onLeft:t}){const{secrets:s,plugins:r,pending:i,grants:a}=e.checklist,[o,l]=d.useState(!0),[c,u]=d.useState([]),[h,f]=d.useState(!1),[p,m]=d.useState(null),[j,w]=d.useState(!1),b=r.filter(g=>!g.installed),v=i.jobs+i.missions+i.approvals+i.telegramChats,x=g=>{u(N=>N.includes(g)?N.filter(k=>k!==g):[...N,g])},y=()=>{f(!0),m(null),A.leaveRecovery({dropPending:o,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(g=>m(g instanceof oe?g.message:String(g))).finally(()=>f(!1))};return n.jsx(vt,{title:"Back from a backup",children:n.jsxs(V,{divided:!0,children:[n.jsxs(Y,{children:[n.jsx(Wt,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:n.jsx("span",{className:"mono",children:e.archive??"—"})}]}),n.jsx("p",{className:"ui-card-meta",children:"Nothing runs on its own yet: no schedules, no watchers, no phone. Chat works. Go through what is below, then turn this buddi back on."})]}),n.jsx(Y,{title:"Keys to paste again",children:s.length===0?n.jsx(ue,{children:"Nothing is missing."}):n.jsx("ul",{className:"recovery-list",children:s.map(g=>n.jsxs("li",{children:[g.settingsRoute?n.jsx("a",{href:g.settingsRoute,children:g.name}):g.name," ",n.jsx("span",{className:"ui-card-meta",children:g.kind})]},`${g.kind}:${g.name}`))})}),n.jsx(Y,{title:"Add-ons to install again",children:b.length===0?n.jsx(ue,{children:"Everything the backup named is installed."}):n.jsx("ul",{className:"recovery-list",children:b.map(g=>n.jsxs("li",{children:[n.jsx("span",{className:"mono",children:g.name})," ",g.version," ",n.jsx("span",{className:"ui-card-meta",children:g.source})]},g.name))})}),n.jsx(Y,{title:"Work that was waiting",children:v===0?n.jsx(ue,{children:"Nothing was in flight when the backup was taken."}):n.jsxs(V,{gap:"sm",children:[n.jsx(Wt,{items:[{label:"Jobs",value:String(i.jobs)},{label:"Missions",value:String(i.missions)},{label:"Waiting for an answer",value:String(i.approvals)},{label:"Phones",value:String(i.telegramChats)}]}),n.jsxs("label",{className:"recovery-check",children:[n.jsx("input",{type:"checkbox",checked:o,onChange:g=>l(g.target.checked)}),n.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),n.jsx(Y,{title:"Standing permissions",children:a.length===0?n.jsx(ue,{children:"No agent had a standing permission."}):n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),n.jsx("ul",{className:"recovery-list",children:a.map(g=>n.jsx("li",{children:n.jsxs("label",{className:"recovery-check",children:[n.jsx("input",{type:"checkbox",checked:c.includes(g.id),onChange:()=>x(g.id),"aria-label":`Keep ${g.tool} for ${g.agent}`}),n.jsxs("span",{children:[n.jsx("span",{className:"mono",children:g.tool})," for ",g.agent," ",n.jsx("span",{className:"ui-card-meta",children:g.scope}),g.description?n.jsxs("span",{className:"ui-card-meta",children:[" — ",g.description]}):null]})]})},g.id))})]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:p}),j?n.jsx(W,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):n.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:h||j,onClick:y,children:"Leave recovery mode"})})]})})]})})}const xU=2e3,vU={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 xy(e){return vU[e.phase]??e.detail??e.phase}const jU=new Set(["done","failed","rolled-back"]);function r1(e){return e!==void 0&&(jU.has(e.phase)||!!e.finishedAt)}function yU(e){const[t,s]=d.useState(void 0),[r,i]=d.useState(!1),[a,o]=d.useState(null),l=d.useRef(!1);return d.useEffect(()=>{if(!e){s(void 0),i(!1),l.current=!1;return}let c=!1;const u=()=>{A.backupJob(e).then(f=>{if(!c){if(l.current){window.location.reload();return}s(f),o(null),r1(f)&&(c=!0)}}).catch(f=>{if(!c){if(f instanceof oe&&f.status!==0&&f.status<500){o(f.message);return}l.current=!0,i(!0)}})};u();const h=window.setInterval(u,xU);return()=>{c=!0,window.clearInterval(h)}},[e]),{job:t,away:r,error:a}}function wU({job:e,away:t,error:s}){return s?n.jsx(se,{message:s}):t?n.jsx(W,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="rolled-back"||e.phase==="failed"?n.jsxs(W,{tone:"critical",role:"alert",children:[xy(e)," ",e.error??""]}):n.jsxs(W,{tone:e.phase==="done"?"good":void 0,role:"status",children:[xy(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function bU(){var b,v,x,y,g,N,k;const e=re(()=>A.backups(),[],3e4),t=s1(),s=re(()=>A.service(),[]),[r,i]=d.useState(null),a=yU(r),[o,l]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),p=((b=e.data)==null?void 0:b.supervised)??((v=s.data)==null?void 0:v.supervised),m=h!==null||p===!1,j=((x=e.data)==null?void 0:x.archives)??[],w=S=>{u(!0),l(null),S.then(C=>{var R;return i(((R=C.job)==null?void 0:R.id)??null)}).catch(C=>{C instanceof oe&&C.status===409?f(C.message):l(C instanceof oe?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return d.useEffect(()=>{r1(a.job)&&e.reload()},[(y=a.job)==null?void 0:y.phase]),n.jsxs(V,{gap:"lg",children:[(g=t.data)!=null&&g.active?n.jsx(gU,{view:t.data,onLeft:t.reload}):null,n.jsx(se,{message:e.error??o}),n.jsx(wU,{...a}),n.jsx(SU,{onSaved:()=>e.reload()}),n.jsx(Y,{title:"Backups",panel:!0,actions:n.jsx(I,{variant:"accent",size:"sm",disabled:c,onClick:()=>w(A.startBackup(!0)),children:"Back up now"}),children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs("p",{className:"ui-card-meta",children:["Kept in ",n.jsx("span",{className:"mono",children:((N=e.data)==null?void 0:N.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),n.jsx(Y,{children:e.data&&j.length===0?n.jsx(Rt,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?n.jsxs(kn,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Name"}),n.jsx("th",{children:"Taken"}),n.jsx("th",{children:"Size"}),n.jsx("th",{children:"State"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:j.map(S=>{var C;return n.jsx(NU,{archive:S,busy:c,database:(C=e.data)==null?void 0:C.database,checkout:m,onVerify:()=>w(A.verifyArchive(S.name)),onRestore:(R,E)=>w(A.restoreArchive({name:S.name,...R?{passphrase:R}:{},...E?{confirm:E}:{}}))},S.name)})})]}):n.jsx(ue,{children:"Loading…"})})]})}),n.jsx(CU,{}),n.jsx(EU,{busy:c,checkout:m,checkoutSaid:h,database:(k=e.data)==null?void 0:k.database,onRestore:(S,C,R)=>w(A.restoreUpload(S,{passphrase:C,confirm:R}))})]})}const kU={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function SU({onSaved:e}){var m;const t=re(()=>A.backupSchedule(),[]),[s,r]=d.useState(null),[i,a]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState(!1);d.useEffect(()=>{t.data&&r(t.data)},[t.data]);const h={...kU,...s??t.data??{}};if(((m=t.data)==null?void 0:m.supervised)===!1)return n.jsx(Y,{title:"Every night",panel:!0,children:n.jsx(Y,{children:n.jsx(W,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const f=j=>{u(!1),r({...h,...j})},p=()=>{a(!0),l(null),A.setBackupSchedule(h).then(j=>{r(j),u(!0),e()}).catch(j=>l(j instanceof oe?j.message:String(j))).finally(()=>a(!1))};return n.jsx(Y,{title:"Every night",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:i,onClick:p,children:"Save"}),children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:o}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:h.enabled,onChange:j=>f({enabled:j.target.checked})}),n.jsx("span",{children:"Back this buddi up on its own"})]}),n.jsxs(Xs,{children:[n.jsx(J,{label:"At",children:n.jsx("input",{type:"time",value:h.time,onChange:j=>f({time:j.target.value})})}),n.jsx(J,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:n.jsx("input",{type:"number",min:1,max:365,value:h.keep,onChange:j=>f({keep:Number(j.target.value)||1})})})]}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:h.encryptLocal,onChange:j=>f({encryptLocal:j.target.checked})}),n.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(J,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:n.jsx("input",{type:"text",value:h.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:j=>f({copyTo:j.target.value===""?null:j.target.value})})}),c?n.jsxs(W,{tone:"good",role:"status",children:["Saved.",h.lastRunAt?` Last run ${_e(h.lastRunAt)}.`:""]}):null]})})]})})}function NU({archive:e,busy:t,database:s,checkout:r,onVerify:i,onRestore:a}){const[o,l]=d.useState(!1),[c,u]=d.useState(""),[h,f]=d.useState("");return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{children:[n.jsx("td",{className:"mono",children:e.name}),n.jsx("td",{children:_e(e.createdAt)}),n.jsx("td",{children:Sn(e.bytes)}),n.jsxs("td",{children:[e.encrypted?n.jsx(ye,{tone:"good",children:"locked"}):n.jsx(ye,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?n.jsx(ye,{tone:"critical",children:"damaged"}):null]}),n.jsx("td",{children:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",disabled:t,onClick:i,children:"Verify"}),n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>l(!o),children:"Restore…"})]})})]}),o?n.jsx("tr",{children:n.jsx("td",{colSpan:5,children:r?n.jsx(W,{tone:"warning",children:i1}):n.jsx(a1,{what:`${e.name}, taken ${_e(e.createdAt)}, ${Sn(e.bytes)}`,database:s,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:h,onConfirm:f,busy:t,onCancel:()=>l(!1),onGo:()=>a(c,h)})})}):null]})}const i1="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function a1({what:e,database:t,needsPassphrase:s,passphrase:r,onPassphrase:i,confirm:a,onConfirm:o,busy:l,onCancel:c,onGo:u}){const h=t??"",f=h===""?a.trim()!=="":a.trim()===h;return n.jsxs(V,{gap:"sm",children:[n.jsxs(W,{tone:"warning",children:["This replaces everything in this buddi with ",e,". What is here now is copied first, so a restore that fails puts it back."]}),s?n.jsx(J,{label:"The passphrase this one was locked with",children:n.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:p=>i(p.target.value)})}):null,n.jsx(J,{label:h?`Type ${h} to confirm`:"Type the name of this database to confirm",hint:h?void 0:"The same name buddi shows on the System tab.",children:n.jsx("input",{value:a,onChange:p=>o(p.target.value)})}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",onClick:c,children:"Cancel"}),n.jsx(I,{variant:"danger",disabled:l||!f||s&&r==="",onClick:u,children:"Restore"})]})]})}function CU(){const[e,t]=d.useState(null),[s,r]=d.useState(""),[i,a]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState(!1),h=()=>{a(!0),l(null),A.backupPassphrase().then(p=>t(p.passphrase)).catch(p=>l(p instanceof oe?p.message:String(p))).finally(()=>a(!1))},f=()=>{a(!0),l(null),A.setBackupPassphrase(s.trim()).then(p=>{t(p.passphrase),r(""),u(!0)}).catch(p=>l(p instanceof oe?p.message:String(p))).finally(()=>a(!1))};return n.jsx(Y,{title:"The passphrase",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:o}),n.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?n.jsx("p",{className:"backup-phrase mono",children:e}):n.jsx(Q,{align:"end",children:n.jsx(I,{disabled:i,onClick:h,children:"Show it"})}),c?n.jsx(W,{tone:"good",role:"status",children:"Saved. Backups made from now on use it; older ones keep the one they were made with."}):null]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(J,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:n.jsx("input",{type:"text",autoComplete:"off",value:s,onChange:p=>{u(!1),r(p.target.value)}})}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:i||s.trim()==="",onClick:f,children:"Use this one"})})]})})]})})}function EU({busy:e,checkout:t,checkoutSaid:s,database:r,onRestore:i}){const[a,o]=d.useState(null),[l,c]=d.useState(""),[u,h]=d.useState(""),[f,p]=d.useState(!1);return t?n.jsx(Y,{title:"Restore from a file",panel:!0,children:n.jsx(Y,{children:n.jsx(W,{tone:"warning",children:s??i1})})}):n.jsx(Y,{title:"Restore from a file",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),n.jsxs(Xs,{children:[n.jsx(J,{label:"The backup file",children:n.jsx("input",{type:"file",onChange:m=>{var j;p(!1),o(((j=m.target.files)==null?void 0:j[0])??null)}})}),n.jsx(J,{label:"Its passphrase",hint:"Only if it was locked with one.",children:n.jsx("input",{type:"password",autoComplete:"off",value:l,onChange:m=>c(m.target.value)})})]}),f?null:n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:e||!a,onClick:()=>p(!0),children:"Restore"})})]})}),f&&a?n.jsx(Y,{children:n.jsx(a1,{what:`${a.name}, ${Sn(a.size)}`,database:r,needsPassphrase:!1,passphrase:l,onPassphrase:c,confirm:u,onConfirm:h,busy:e,onCancel:()=>p(!1),onGo:()=>i(a,l,u)})}):null]})})}const o1="gemini-2.5-pro";function ud(e){return e.replace(/^models\//,"")}const Wg=/(image|tts|audio|live|embedding|vision|robotics|transcribe)/;function l1(e){const t=e.map(ud);let s;for(const r of t){const i=/^gemini-(\d+(?:\.\d+)*)-pro(?:-(.+))?$/.exec(r);if(!i||Wg.test(i[2]??""))continue;const a=i[1].split(".").map(Number),o=(i[2]??"")!=="";(!s||ju(a,s.version)>0||ju(a,s.version)===0&&s.preview&&!o)&&(s={id:r,version:a,preview:o})}return(s==null?void 0:s.id)??t.find(r=>r.startsWith("gemini-"))}function c1(e){let t;for(const s of e.map(ud)){const r=/^gemini-(\d+(?:\.\d+)*)-flash(?:-(.+))?$/.exec(s);if(!r||/lite/.test(r[2]??"")||Wg.test(r[2]??""))continue;const i=r[1].split(".").map(Number),a=(r[2]??"")!=="";(!t||ju(i,t.version)>0||ju(i,t.version)===0&&t.preview&&!a)&&(t={id:s,version:i,preview:a})}return t==null?void 0:t.id}function u1(e){return/^gemini-[\d.]+-pro(?:-|$)/.test(ud(e))}function AU(e){return[...new Set(e.map(ud).filter(t=>t.startsWith("gemini-")&&!Wg.test(t)))]}function d1(e){return e.httpStatus===429||e.state==="rate-limited"||e.state==="quota-exhausted"}function ju(e,t){for(let s=0;s<Math.max(e.length,t.length);s+=1){const r=(e[s]??0)-(t[s]??0);if(r!==0)return r}return 0}function TU(e,t){if(!t||e.kind!=="openai-compatible")return!1;const s=r=>r.replace(/\/+$/,"");return s(e.baseUrl)===s(t)}function f1({code:e,label:t="Your code"}){const[s,r]=d.useState(!1),i=async()=>{var a;try{await((a=navigator.clipboard)==null?void 0:a.writeText(e)),r(!0)}catch{}};return n.jsxs(Q,{valign:"end",children:[n.jsx(J,{label:t,grow:!0,children:n.jsx("input",{readOnly:!0,value:e,spellCheck:!1,onFocus:a=>a.currentTarget.select()})}),n.jsx(I,{onClick:()=>void i(),children:s?"Copied":"Copy"})]})}function RU({embedded:e}={}){const{data:t,error:s,reload:r,loading:i}=re(()=>A.providerAccounts(),[]),[a,o]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(""),[f,p]=d.useState(!1),[m,j]=d.useState(!1),[w,b]=d.useState(null),v=t==null?void 0:t.accounts.some(N=>{var k;return((k=N.login)==null?void 0:k.state)==="pending"&&N.login.expiresAt&&Date.parse(N.login.expiresAt)>Date.now()});d.useEffect(()=>{if(!v)return;const N=setInterval(r,2e3);return()=>clearInterval(N)},[v,r]);const x=async(N,k)=>{o(!0),c(null),h(""),j(!1);try{const S=await N();return h((S==null?void 0:S.warning)??k),r(),!0}catch(S){return c(S instanceof Error?S.message:"Could not apply change."),r(),!1}finally{o(!1)}},y=(t==null?void 0:t.accounts)??[],g=y.find(N=>N.id===w)??y[0];return n.jsxs(fn,{embedded:e,title:"Model accounts",lede:"Give each API key or subscription a name, then pick one per agent. An account never falls back to another credential on its own.",children:[n.jsx(se,{message:s??l}),u&&n.jsx(W,{tone:"good",role:"status",children:u}),m&&n.jsx(W,{role:"status",children:i?"Refreshing account status…":s?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!t&&!s&&n.jsx(ue,{children:"Loading accounts…"}),s&&n.jsx(Q,{children:n.jsx(I,{onClick:r,children:"Retry"})}),t&&n.jsxs(n.Fragment,{children:[(t.vault.locked||t.vault.kind==="none")&&n.jsx(W,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),f&&n.jsx(en,{title:"Add an account",onClose:()=>p(!1),children:n.jsx("div",{id:"new-provider-account",children:n.jsx(DU,{accounts:y,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,gemini:t.gemini,busy:a,run:x,onDone:N=>{p(!1),N&&b(N)}})})}),n.jsx(Y,{title:"Accounts",aside:`Secrets live in the ${IU(t.vault.kind)}; Postgres holds names and assignments only.`,actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",size:"sm",disabled:a||i,onClick:()=>{c(null),h(""),j(!0),r()},children:i?"Refreshing…":"Refresh status"}),n.jsx(I,{variant:"accent",size:"sm",disabled:a,"aria-expanded":f,"aria-controls":"new-provider-account",onClick:()=>p(!f),children:"Add account"})]}),panel:!0,flush:!0,children:y.length===0?n.jsx(Rt,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):n.jsxs("div",{className:"accounts",children:[n.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:y.map(N=>n.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(g==null?void 0:g.id)===N.id,onClick:()=>b(N.id),children:[n.jsx(PU,{kind:N.kind,auth:N.auth}),n.jsxs("span",{className:"accounts-row-text",children:[n.jsx("span",{className:"accounts-row-name",children:N.label}),n.jsxs("span",{className:"accounts-row-sub",children:[Hg(N)," · ",N.assignedAgents.length===0?"no agents":`${N.assignedAgents.length} agent${N.assignedAgents.length===1?"":"s"}`]})]}),n.jsx(p1,{account:N})]},N.id))}),g?n.jsx($U,{account:g,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:a,run:x},`${g.id}:${g.revision}`):null]})})]})]})}function IU(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function Hg(e){return e.kind==="codex"?"ChatGPT subscription":e.kind==="anthropic"?e.auth==="anthropic-oauth"?"Claude subscription":e.auth==="legacy-subscription-token"?"Claude setup token":"Anthropic API":e.kind==="openai"?"OpenAI API":e.auth==="device-key"?"Ollama Cloud":"OpenAI-compatible"}function h1(e){return e.detectedContextWindowSource!=="provider"?"assumed":e.kind==="codex"?"from ChatGPT":"from the provider"}function PU({kind:e,auth:t}){const s=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return n.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:s})}function MU(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function p1({account:e}){const t=e.enabled?e.configured?"good":"warning":void 0,s=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return n.jsx(ye,{tone:t,children:s})}function Vg(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 $U({account:e,busy:t,run:s,anthropicOAuthEnabled:r}){const[i,a]=d.useState(!1),[o,l]=d.useState(!1);return n.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("h3",{className:"ui-card-title",children:e.label}),n.jsx(p1,{account:e})]}),n.jsx(Wt,{items:[{label:"Provider",value:Hg(e)},{label:"Default model",value:n.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:n.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":` (${h1(e)})`}`})},...e.baseUrl?[{label:"Endpoint",value:n.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?n.jsx("span",{className:"ui-row",children:e.assignedAgents.map(c=>n.jsx("a",{href:lt(c,"setup","brain"),children:c},c))}):n.jsxs("span",{className:"ui-row",children:[n.jsx("span",{className:"muted",children:"No agents"}),n.jsx("a",{href:ot,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${new Date(e.tokenExpiresAt).toLocaleString()} (not your subscription renewal date)`}]:[]]}),e.removalPending&&n.jsx(W,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&n.jsxs(W,{tone:"warning",children:["Token refresh did not finish. Reconnect this ",e.kind==="codex"?"ChatGPT":"Claude"," account."]}),e.auth==="anthropic-oauth"&&n.jsx(x1,{account:e,enabled:!!r,busy:t,run:s}),e.kind==="codex"&&n.jsx(m1,{account:e,busy:t,run:s}),e.auth==="device-key"&&n.jsx(g1,{account:e,busy:t,run:s}),n.jsxs(Q,{children:[n.jsx(I,{disabled:t||e.removalPending,onClick:()=>a(!0),children:"Edit account"}),n.jsx(I,{disabled:t||e.removalPending,onClick:()=>void s(()=>A.saveProviderAccount({...Vg(e),enabled:!e.enabled}),e.enabled?"Account disabled. Subsequent model calls will stop; already-sent requests cannot be recalled.":"Account enabled."),children:e.enabled?"Disable":"Enable"}),e.kind!=="codex"&&n.jsx(I,{disabled:t||!e.enabled||!e.configured,onClick:()=>void s(()=>A.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),n.jsx(I,{variant:"danger",disabled:t||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>l(!0),children:"Remove account"})]}),e.test&&n.jsxs(n.Fragment,{children:[n.jsxs(W,{role:"status",tone:MU(e.test.state),children:[n.jsx("p",{children:e.test.message}),e.test.retryAt?n.jsxs("p",{children:["Provider suggested retry time: ",new Date(e.test.retryAt).toLocaleString(),". This is retry advice, not a guaranteed quota reset."]}):["rate-limited","quota-exhausted"].includes(e.test.state)&&n.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),n.jsxs("p",{className:"muted",children:["Tested at ",new Date(e.test.checkedAt).toLocaleString(),e.test.httpStatus?` · HTTP ${e.test.httpStatus}`:"",". This is not a quota reset or subscription renewal date."]})]}),i&&n.jsx(en,{title:`Edit ${e.label}`,onClose:()=>a(!1),children:n.jsx(OU,{account:e,busy:t,run:s,onDone:()=>a(!1)})}),o&&n.jsxs(W,{tone:"critical",children:[n.jsxs("p",{children:["Remove “",e.label,"” and its stored credential from Buddi? This does not revoke it at the provider or remove it from backups."]}),n.jsxs(Q,{children:[n.jsx(I,{variant:"danger",disabled:t,onClick:()=>void s(()=>A.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),n.jsx(I,{disabled:t,onClick:()=>l(!1),children:"Cancel"})]})]}),n.jsx(It,{summary:"Details",children:n.jsxs("div",{className:"ui-prose muted",children:[e.auth==="legacy-subscription-token"&&n.jsx("p",{children:"Legacy subscription token: not refreshable, token expiry and subscription renewal date unknown."}),e.kind==="codex"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Talks to OpenAI’s Codex backend directly with your ChatGPT sign-in. The credential stays in buddi’s vault; buddi refreshes it and never reads your own Codex login."}),n.jsx("p",{children:"Native tool-step usage reporting is incomplete. Do not use Buddi’s token or API-cost estimates as subscription billing or remaining quota."}),n.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):n.jsx("p",{children:"Testing sends a small fixed prompt and may incur a charge. No conversation or files are sent. Configured does not mean verified."}),e.auth==="device-key"&&n.jsx("p",{children:"Ollama Cloud with a device key: buddi made a key pair and keeps it in the vault; ollama.com only ever saw the public half and this computer’s name. Each request to ollama.com is signed with the key, and nothing else is sent with it. Disconnect asks ollama.com to forget the device and removes the key from buddi either way."}),e.auth==="anthropic-oauth"&&n.jsx("p",{children:"Claude subscription sign-in. Tokens remain in Buddi’s vault and refresh before use. Uses your plan’s monthly Agent SDK credits; after them, an API key. Remaining credits are unknown here."}),n.jsx("p",{children:"Subscription login is separate from API-key access. Existing Claude setup tokens remain legacy accounts, without automatic refresh or a known expiry."})]})})]})}function m1({account:e,busy:t,run:s}){var r,i,a;return n.jsxs(n.Fragment,{children:[n.jsxs(Q,{children:[n.jsx(I,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void s(()=>A.codexAccountAction(e.id,"login",e.revision),"Complete device sign-in below."),children:e.configured?"Reconnect ChatGPT":"Connect ChatGPT"}),((i=e.login)==null?void 0:i.state)==="pending"&&n.jsx(I,{disabled:t,onClick:()=>void s(()=>A.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),n.jsx(I,{disabled:t||!e.configured,onClick:()=>void s(()=>A.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((a=e.login)==null?void 0:a.state)==="pending"&&n.jsxs(W,{tone:"accent",role:"status",children:[n.jsxs("p",{children:["Here is your code: ",n.jsx("strong",{children:e.login.userCode}),". Open the link, enter it, and approve buddi on openai.com."]}),e.login.userCode&&n.jsx(f1,{code:e.login.userCode}),e.login.verificationUrl&&n.jsx(Q,{children:n.jsx(Zt,{variant:"accent",href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open openai.com"})}),e.login.expiresAt&&n.jsxs("p",{className:"muted",children:["The code works until ",new Date(e.login.expiresAt).toLocaleTimeString(),". Start again after that; this is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&n.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function OU({account:e,busy:t,run:s,onDone:r,codexEnabled:i,anthropicOAuthEnabled:a}){const[o,l]=d.useState((e==null?void 0:e.label)??""),[c,u]=d.useState((e==null?void 0:e.kind)??"anthropic"),[h,f]=d.useState((e==null?void 0:e.auth)??"api-key"),[p,m]=d.useState((e==null?void 0:e.baseUrl)??""),[j,w]=d.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[b,v]=d.useState(""),[x,y]=d.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),g=k=>{u(k),f(k==="codex"?"chatgpt":"api-key"),v(""),m(k==="openai-compatible"?"http://localhost:11434/v1":""),w(k==="anthropic"?"claude-sonnet-5":k==="openai"?"gpt-5":"")},N=!o.trim()||!j.trim();return n.jsxs("form",{className:"ui-stack",onSubmit:k=>{k.preventDefault();const S=b;v(""),s(()=>A.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:o,kind:c,auth:h,baseUrl:p,defaultModel:j,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:x.trim()?Number(x):null,...S.trim()?{secret:S}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[n.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[n.jsx(J,{label:"Account name",children:n.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:o,onChange:k=>l(k.target.value),placeholder:"Anthropic — Personal"})}),n.jsx(J,{label:"Provider",children:n.jsxs("select",{disabled:!!e,value:h==="anthropic-oauth"?"anthropic-oauth":h==="device-key"?"ollama-cloud":c,onChange:k=>{k.target.value==="anthropic-oauth"?(g("anthropic"),f("anthropic-oauth")):g(k.target.value)},children:[n.jsx("option",{value:"anthropic",children:"Anthropic API"}),n.jsx("option",{value:"openai",children:"OpenAI API"}),n.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(e==null?void 0:e.auth)==="device-key"&&n.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),(a||(e==null?void 0:e.auth)==="anthropic-oauth")&&n.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),(i||(e==null?void 0:e.kind)==="codex")&&n.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),c==="openai-compatible"&&h!=="device-key"&&n.jsxs(n.Fragment,{children:[n.jsx(J,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:n.jsx("input",{required:!0,type:"url",value:p,onChange:k=>m(k.target.value)})}),n.jsx(J,{label:"Authentication",children:n.jsxs("select",{disabled:!!e,value:h,onChange:k=>{f(k.target.value),v("")},children:[n.jsx("option",{value:"api-key",children:"API key"}),n.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),n.jsx(Q,{valign:"end",children:n.jsx(Bg,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:j,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),n.jsx(J,{label:"Context window",hint:"Tokens this endpoint actually serves. Leave blank unless you run the model yourself and set a window of your own — a conversation is ended once its history would fill half of this.",children:n.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:x,placeholder:e!=null&&e.detectedContextWindowTokens?`${e.detectedContextWindowTokens} (${h1(e)})`:"assumed from the model",onChange:k=>y(k.target.value)})}),c==="codex"&&n.jsx("p",{className:"muted",children:"Pick a model from the list once the account is connected."}),h==="anthropic-oauth"&&n.jsx("p",{className:"muted",children:"Save this account, then choose Connect Claude. You will approve in your browser and paste the authorization code here, not in chat. No existing agent assignment changes."}),h==="api-key"&&n.jsx(J,{label:e?"Replacement API key (leave blank to keep)":"API key",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:b,onChange:k=>v(k.target.value)})}),e&&n.jsx("p",{className:"muted",children:"Saving changes stops an active run at its next model call. Start a new turn afterward. Changing the default model does not change existing agent assignments."}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:r,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",disabled:N,children:"Save account"})]})]}),N&&n.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function g1({account:e,busy:t,run:s}){var l;const r=((l=e.login)==null?void 0:l.state)==="pending"&&e.login.attemptId?e.login:null,i=d.useRef(s);i.current=s,d.useEffect(()=>{if(!(r!=null&&r.attemptId))return;let c=!1,u=!1;const h=setInterval(()=>{c||u||(u=!0,A.ollamaPoll(e.id,r.attemptId).then(f=>{c||f.state==="waiting"||(c=!0,f.state==="connected"?i.current(async()=>{},`Connected as ${f.username}, device ${f.deviceName}.`):i.current(async()=>{throw new Error(f.message)},""))}).catch(()=>{}).finally(()=>{u=!1}))},2e3);return()=>{c=!0,clearInterval(h)}},[e.id,r==null?void 0:r.attemptId]);const a=()=>{const c=typeof window.open=="function"?window.open("","_blank"):null;s(async()=>{try{const u=await A.ollamaConnect(e.id,e.revision);return c&&(c.location.href=u.verificationUrl),u}catch(u){throw c==null||c.close(),u}},"Press Connect on the ollama.com page. This card notices on its own.")},o=e.device;return n.jsxs(n.Fragment,{children:[o&&n.jsx("p",{className:"muted",role:"status",children:o.connectedAt?`Connected as ${o.username||"an ollama.com account"}, device ${o.deviceName}.`:`Not connected yet. Device ${o.deviceName}.`}),n.jsxs(Q,{children:[n.jsx(I,{disabled:t||!e.enabled||e.removalPending||!!r,onClick:a,children:e.configured?"Reconnect Ollama":"Connect Ollama"}),n.jsx(I,{disabled:t||!o||e.removalPending,onClick:()=>void s(async()=>({warning:(await A.ollamaDisconnect(e.id,e.revision)).note}),"Disconnected."),children:"Disconnect"})]}),r&&n.jsxs(W,{tone:"accent",role:"status",children:[n.jsxs("p",{children:[n.jsx("a",{href:r.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open the ollama.com page"})," and press Connect. Sign in there first if it asks."]}),n.jsxs("p",{className:"muted",children:["buddi stops waiting at ",r.expiresAt&&new Date(r.expiresAt).toLocaleTimeString(),"."]})]})]})}function x1({account:e,enabled:t,busy:s,run:r}){var o,l,c,u,h;const[i,a]=d.useState("");return d.useEffect(()=>{a("")},[(o=e.login)==null?void 0:o.attemptId,(l=e.login)==null?void 0:l.state]),n.jsxs(n.Fragment,{children:[!t&&n.jsx(W,{tone:"warning",children:"Claude subscription sign-in is turned off on this host."}),n.jsxs(Q,{children:[n.jsx(I,{disabled:s||!t||!e.enabled||e.removalPending||((c=e.login)==null?void 0:c.state)==="pending",onClick:()=>void r(()=>A.anthropicAccountAction(e.id,"login",e.revision),"Open the Claude consent link below. Existing credentials remain until sign-in succeeds."),children:e.configured?"Reconnect Claude":"Connect Claude"}),((u=e.login)==null?void 0:u.state)==="pending"&&n.jsx(I,{disabled:s,onClick:()=>{a(""),r(()=>A.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),n.jsx(I,{disabled:s||!e.configured||e.removalPending,onClick:()=>{a(""),r(()=>A.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((h=e.login)==null?void 0:h.state)==="pending"&&n.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:f=>{f.preventDefault();const p=i;a(""),r(()=>A.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:p}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[n.jsx("p",{children:n.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),n.jsxs("p",{className:"muted",children:["Use the Claude account you want to connect. Paste the entire code including #state. This attempt expires at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),"; restarting Buddi also ends it."]}),n.jsx(J,{label:"Claude authorization code",children:n.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:f=>a(f.target.value),disabled:s})}),n.jsx(Q,{align:"end",children:n.jsx(I,{type:"submit",variant:"accent",disabled:s||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const Rf={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5.5"};function If(e,t,s){return v1(e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":t==="device-key"?"Ollama Cloud":"Local endpoint",s)}function v1(e,t){const s=new Set(t.map(r=>r.trim().toLowerCase()));if(!s.has(e.toLowerCase()))return e;for(let r=2;r<100;r+=1)if(!s.has(`${e} ${r}`.toLowerCase()))return`${e} ${r}`;return e}const _U="That key was refused. Check it and paste it again.";function DU({accounts:e,busy:t,run:s,onDone:r,codexEnabled:i,anthropicOAuthEnabled:a,gemini:o}){const l=e.map(ne=>ne.label),[c,u]=d.useState(null),[h,f]=d.useState("anthropic"),[p,m]=d.useState("api-key"),[j,w]=d.useState(()=>If("anthropic","api-key",l)),[b,v]=d.useState(!1),[x,y]=d.useState(""),[g,N]=d.useState(""),[k,S]=d.useState(null),[C,R]=d.useState(!1),[E,P]=d.useState(""),[O,U]=d.useState(""),[T,M]=d.useState(!1),[L,K]=d.useState(!1),[D,q]=d.useState(!1),F=(ne,be,Ne=!1)=>{f(ne),m(be),N(""),S(null),P(""),U(""),M(!1),K(Ne),q(!1),y(Ne?"":ne==="openai-compatible"?"http://localhost:11434/v1":""),b||w(Ne?If(ne,"device-key",l):If(ne,be,l))},H=ne=>{F("openai-compatible",ne?"api-key":"device-key",!0),ne&&A.ollama().then(be=>y(be.cloudBaseUrl)).catch(()=>{})},le=()=>{o&&(F("openai-compatible","api-key"),q(!0),y(o.baseUrl),b||w(v1("Gemini",l)))},ie=c?e.find(ne=>ne.id===c):void 0;if(c)return ie?n.jsx(LU,{account:ie,busy:t,run:s,anthropicOAuthEnabled:a,onDone:()=>r(ie.id)}):n.jsx(ue,{children:"Saving…"});const ae=h==="openai-compatible"&&p!=="device-key",ge=h==="codex"||p==="anthropic-oauth"||p==="device-key",X=!ge&&(p==="none"||g.trim()!=="")&&(!ae||x.trim()!==""),de=async()=>{var ne,be;R(!0),P("");try{const Ne=await A.probeModels({kind:h,auth:p,...ae?{baseUrl:x}:{},...g.trim()?{secret:g}:{}});S(Ne),O||U(((ne=Ne.models.find(Qe=>Qe.isDefault))==null?void 0:ne.id)??((be=Ne.models[0])==null?void 0:be.id)??"")}catch(Ne){P(Ne instanceof Error?Ne.message:"Could not load models. You can still enter a custom model.")}finally{R(!1)}},me=O.trim(),$e=!j.trim()||ae&&!x.trim()||ae&&!D&&!me||D&&!g.trim();return n.jsxs("form",{className:"ui-stack",onSubmit:ne=>{ne.preventDefault();const be=g;N("");let Ne=me||(p==="device-key"?wc:Rf[h])||"claude-sonnet-5",Qe;(async()=>{if(D){Ne=o1;try{const ze=(await A.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:x,secret:be})).models.map(Oe=>Oe.id);Ne=l1(ze)??Ne,Qe=u1(Ne)?c1(ze):void 0}catch{}}let Ie,rt=!1;!await s(async()=>{if(Ie=await A.saveProviderAccount({label:j,kind:h,auth:p,baseUrl:x,defaultModel:Ne,enabled:!0,...be.trim()?{secret:be}:{}}),p!=="api-key")return Ie;const xe=await A.testProviderAccount(Ie.id);if(xe.state==="connected")return Ie;if(qm(xe)){const ze=Ie.id;Ie=void 0;try{const Oe=(await A.providerAccounts()).accounts.find(it=>it.id===ze);Oe&&await A.removeProviderAccount(ze,Oe.revision)}catch{}throw new Error(_U)}if(D&&Qe&&d1(xe)){const ze=(await A.providerAccounts()).accounts.find(Oe=>Oe.id===Ie.id);if(ze&&(await A.saveProviderAccount({...Vg(ze),defaultModel:Qe}),(await A.testProviderAccount(Ie.id)).state==="connected"))return{...Ie,warning:`Account saved. Google's free tier has no Pro allowance, so it starts on ${Qe}; turn on billing at Google to use Pro.`}}return rt=!0,{...Ie,warning:`Account saved. ${xe.message}`}},"Account saved.")||!Ie||(D||rt?u(Ie.id):me||!ge?r(Ie.id):u(Ie.id))})()},children:[n.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[n.jsx(J,{label:"Provider",children:n.jsxs("select",{value:p==="anthropic-oauth"?"anthropic-oauth":L?"ollama-cloud":D?"gemini":h,onChange:ne=>{if(ne.target.value==="anthropic-oauth")F("anthropic","anthropic-oauth");else if(ne.target.value==="gemini")le();else if(ne.target.value==="ollama-cloud")F("openai-compatible","device-key",!0);else{const be=ne.target.value;F(be,be==="codex"?"chatgpt":"api-key")}},children:[n.jsx("option",{value:"anthropic",children:"Anthropic API"}),n.jsx("option",{value:"openai",children:"OpenAI API"}),o&&n.jsx("option",{value:"gemini",children:"Gemini (Google AI key)"}),n.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),n.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),a&&n.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),i&&n.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),n.jsx(J,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:n.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:j,onChange:ne=>{w(ne.target.value),v(!0)},placeholder:"Anthropic — Personal"})}),L&&n.jsxs("label",{className:"ui-row",children:[n.jsx("input",{type:"checkbox",checked:p==="api-key",onChange:ne=>H(ne.target.checked)}),n.jsx("span",{children:"Use a key instead"})]}),ae&&n.jsxs(n.Fragment,{children:[n.jsx(J,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:n.jsx("input",{required:!0,type:"url",value:x,onChange:ne=>{y(ne.target.value),S(null)}})}),!D&&n.jsx(J,{label:"Authentication",children:n.jsxs("select",{value:p,onChange:ne=>{m(ne.target.value),N(""),S(null)},children:[n.jsx("option",{value:"api-key",children:"API key"}),n.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),p==="api-key"&&n.jsx(J,{label:"API key",hint:"Stored in the vault, never shown again.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:g,onChange:ne=>{N(ne.target.value),S(null)}})}),D&&o?n.jsxs("p",{className:"muted",children:[n.jsx("a",{href:o.keyUrl,target:"_blank",rel:"noreferrer",children:"Get a key at aistudio.google.com"}),". buddi picks the newest Gemini Pro your key can reach; the next step lists the rest."]}):ge?n.jsx("p",{className:"muted",children:h==="codex"?"You will connect your ChatGPT subscription on the next step, with a code you enter on openai.com, and pick a model then.":p==="device-key"?"You will connect on the next step: ollama.com opens, you press Connect, and no key is typed. Free to start.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Model"}),k?n.jsxs("div",{className:"ui-row",children:[n.jsxs("select",{"aria-label":"Model",value:T?"__custom__":O,onChange:ne=>{ne.target.value==="__custom__"?(M(!0),U("")):(M(!1),U(ne.target.value))},children:[k.models.map(ne=>n.jsxs("option",{value:ne.id,children:[ne.name===ne.id?ne.id:`${ne.name} — ${ne.id}`,ne.isDefault?" (provider default)":"",ne.thinks?" · thinks":""]},ne.id)),n.jsx("option",{value:"__custom__",children:"Custom model…"})]}),n.jsx(I,{size:"sm",disabled:C||!X,onClick:()=>void de(),children:C?"Loading…":"Reload"})]}):n.jsxs("div",{className:"ui-row",children:[n.jsx(I,{disabled:C||!X,onClick:()=>void de(),children:C?"Loading models…":"Load models"}),ae?n.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):n.jsxs("span",{className:"muted",children:["Optional now: ",Rf[h]," is used until you pick one."]})]}),T||ae&&!k?n.jsx("input",{"aria-label":"Custom model",required:ae,maxLength:150,value:O,onChange:ne=>U(ne.target.value),placeholder:ae?"qwen3:8b":Rf[h]}):null,E?n.jsx("span",{className:"ui-field-hint critical",role:"alert",children:E}):null,k!=null&&k.truncated?n.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:()=>r(),children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",disabled:$e,children:"Save account"})]})]}),$e&&n.jsxs("p",{className:"muted",children:["Enter an account name",D?" and a key":ae?", an endpoint and a model":""," to enable Save account."]})]})}function LU({account:e,busy:t,run:s,anthropicOAuthEnabled:r,onDone:i}){const[a,o]=d.useState(e.defaultModel),l=e.configured;return n.jsxs(V,{gap:"lg",children:[n.jsxs(W,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!l?n.jsx(x1,{account:e,enabled:!!r,busy:t,run:s}):null,e.kind==="codex"&&!l?n.jsx(m1,{account:e,busy:t,run:s}):null,e.auth==="device-key"&&!l?n.jsx(g1,{account:e,busy:t,run:s}):null,l?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-page-lede",children:"Pick the model this account offers by default. An agent can still choose another when you assign it."}),n.jsx(Q,{valign:"end",children:n.jsx(Bg,{accountId:e.enabled?e.id:void 0,label:"Default model",value:a,onChange:o,disabled:t},`${e.id}:${e.revision}`)}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:i,children:"Skip for now"}),n.jsx(I,{variant:"accent",disabled:t||!a.trim(),onClick:()=>{if(a===e.defaultModel){i();return}s(()=>A.saveProviderAccount({...Vg(e),defaultModel:a}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):n.jsx(Q,{children:n.jsx(I,{onClick:i,children:"Finish later"})})]})}const vy=new Set(["co.uk","org.uk","me.uk","ltd.uk","plc.uk","net.uk","sch.uk","ac.uk","gov.uk","nhs.uk","police.uk","mod.uk","gov.ie","co.at","or.at","ac.at","gv.at","com.pl","net.pl","org.pl","info.pl","biz.pl","edu.pl","gov.pl","waw.pl","com.es","org.es","nom.es","gob.es","edu.es","com.pt","org.pt","gov.pt","edu.pt","com.gr","org.gr","net.gr","edu.gr","gov.gr","com.cy","org.cy","net.cy","gov.cy","ac.cy","com.mt","org.mt","net.mt","edu.mt","gov.mt","co.hu","org.hu","info.hu","com.ro","org.ro","info.ro","nom.ro","co.rs","org.rs","edu.rs","gov.rs","in.rs","com.ua","org.ua","net.ua","gov.ua","edu.ua","in.ua","kiev.ua","com.ru","org.ru","net.ru","msk.ru","spb.ru","co.no","priv.no","com.hr","from.hr","iz.hr","name.hr","co.it","gov.it","edu.it","asso.fr","com.fr","gouv.fr","nom.fr","prd.fr","tm.fr","co.je","net.je","org.je","co.gg","net.gg","org.gg","co.im","net.im","org.im","gc.ca","on.ca","qc.ca","bc.ca","ab.ca","com.mx","org.mx","net.mx","edu.mx","gob.mx","ny.us","ca.us","tx.us","fl.us","wa.us","k12.ca.us","lib.ca.us","com.br","net.br","org.br","gov.br","edu.br","art.br","blog.br","eco.br","emp.br","ind.br","inf.br","tv.br","app.br","dev.br","com.ar","org.ar","net.ar","gob.ar","edu.ar","int.ar","tur.ar","com.co","org.co","net.co","edu.co","gov.co","nom.co","com.pe","org.pe","net.pe","gob.pe","edu.pe","nom.pe","com.ve","org.ve","net.ve","gob.ve","co.ve","com.uy","org.uy","net.uy","gub.uy","edu.uy","com.ec","org.ec","net.ec","gob.ec","edu.ec","fin.ec","com.bo","org.bo","net.bo","gob.bo","edu.bo","com.py","org.py","net.py","gov.py","edu.py","gob.cl","gov.cl","co.cl","com.do","org.do","net.do","gob.do","edu.do","com.gt","org.gt","net.gt","gob.gt","edu.gt","co.cr","or.cr","fi.cr","go.cr","ac.cr","com.pa","org.pa","net.pa","gob.pa","com.sv","org.sv","gob.sv","edu.sv","com.ni","org.ni","gob.ni","com.hn","org.hn","net.hn","gob.hn","com.cu","org.cu","net.cu","gob.cu","com.jm","org.jm","net.jm","gov.jm","com.tt","org.tt","net.tt","gov.tt","co.tt","com.pr","org.pr","net.pr","gov.pr","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","co.nz","net.nz","org.nz","ac.nz","govt.nz","school.nz","geek.nz","gen.nz","kiwi.nz","maori.nz","co.jp","ne.jp","or.jp","ac.jp","ad.jp","ed.jp","go.jp","gr.jp","lg.jp","com.cn","net.cn","org.cn","gov.cn","edu.cn","ac.cn","com.hk","net.hk","org.hk","edu.hk","gov.hk","idv.hk","com.tw","net.tw","org.tw","edu.tw","gov.tw","idv.tw","co.kr","or.kr","ne.kr","go.kr","ac.kr","re.kr","pe.kr","co.in","net.in","org.in","firm.in","gen.in","ind.in","ac.in","edu.in","gov.in","res.in","nic.in","com.sg","net.sg","org.sg","edu.sg","gov.sg","per.sg","com.my","net.my","org.my","edu.my","gov.my","name.my","co.id","or.id","ac.id","go.id","web.id","my.id","biz.id","net.id","sch.id","co.th","in.th","ac.th","go.th","or.th","net.th","com.vn","net.vn","org.vn","edu.vn","gov.vn","com.ph","net.ph","org.ph","edu.ph","gov.ph","com.pk","net.pk","org.pk","edu.pk","gov.pk","com.bd","org.bd","net.bd","gov.bd","edu.bd","com.lk","org.lk","gov.lk","edu.lk","com.np","org.np","gov.np","edu.np","com.kh","org.kh","gov.kh","com.mm","org.mm","gov.mm","com.fj","org.fj","gov.fj","ac.fj","com.pg","org.pg","gov.pg","ac.pg","com.kz","org.kz","gov.kz","edu.kz","com.tr","net.tr","org.tr","gov.tr","edu.tr","gen.tr","biz.tr","info.tr","av.tr","bel.tr","k12.tr","co.il","org.il","net.il","ac.il","gov.il","muni.il","com.sa","net.sa","org.sa","gov.sa","edu.sa","med.sa","co.ae","net.ae","org.ae","gov.ae","ac.ae","com.qa","org.qa","net.qa","gov.qa","edu.qa","com.kw","org.kw","net.kw","gov.kw","edu.kw","com.bh","org.bh","net.bh","gov.bh","edu.bh","com.om","org.om","net.om","gov.om","co.om","com.jo","org.jo","net.jo","gov.jo","edu.jo","com.lb","org.lb","net.lb","gov.lb","edu.lb","com.eg","org.eg","net.eg","gov.eg","edu.eg","eun.eg","co.ir","ac.ir","gov.ir","org.ir","net.ir","co.za","org.za","net.za","gov.za","ac.za","web.za","edu.za","nom.za","com.ng","org.ng","net.ng","gov.ng","edu.ng","name.ng","co.ke","or.ke","ne.ke","go.ke","ac.ke","sc.ke","co.tz","or.tz","ne.tz","go.tz","ac.tz","co.ug","or.ug","ne.ug","go.ug","ac.ug","com.gh","org.gh","gov.gh","edu.gh","co.ma","net.ma","org.ma","gov.ma","ac.ma","press.ma","com.tn","org.tn","gov.tn","ens.tn","fin.tn","com.dz","org.dz","net.dz","gov.dz","edu.dz","com.et","org.et","gov.et","edu.et","co.zw","org.zw","gov.zw","ac.zw","co.zm","org.zm","gov.zm","ac.zm","co.bw","org.bw","ac.bw","com.na","org.na","co.na","co.mz","org.mz","gov.mz","com.cm","co.cm","net.cm","gov.cm","com.sn","org.sn","edu.sn","gouv.sn","com.ci","co.ci","or.ci","go.ci","ac.ci","com.tg","gouv.tg","co.rw","gov.rw","ac.rw","*.ck","*.er","*.fk","*.jm","*.kh","*.mm","*.np","*.pg","*.bd","github.io","githubusercontent.com","gitlab.io","bitbucket.io","pages.dev","workers.dev","trycloudflare.com","vercel.app","vercel.dev","now.sh","netlify.app","netlify.com","herokuapp.com","herokussl.com","cloudfront.net","amazonaws.com","s3.amazonaws.com","elasticbeanstalk.com","awsapprunner.com","amplifyapp.com","azurewebsites.net","azurestaticapps.net","cloudapp.net","azureedge.net","azurefd.net","blob.core.windows.net","trafficmanager.net","appspot.com","firebaseapp.com","web.app","run.app","cloudfunctions.net","blogspot.com","fly.dev","onrender.com","up.railway.app","deno.dev","deno.net","glitch.me","repl.co","replit.dev","replit.app","ngrok.io","ngrok.app","ngrok-free.app","ngrok.dev","ngrok-free.dev","surge.sh","readthedocs.io","myshopify.com","wixsite.com","webflow.io","framer.app","framer.website","ondigitalocean.app","digitaloceanspaces.com","supabase.co","fastly.net","global.ssl.fastly.net","edgecompute.app","duckdns.org","dyndns.org","ddns.net","no-ip.org","hopto.org","zapto.org","eu.org","us.org","neocities.org","codeberg.page","sourceforge.io","pythonanywhere.com","streamlit.app","hf.space"]);function FU(e){const t=e.toLowerCase().replace(/\.$/,"");if(!t.includes(".")||vy.has(t))return!0;const s=t.slice(t.indexOf(".")+1);return vy.has(`*.${s}`)}function UU(e){return typeof e=="string"&&e.includes("*")}function BU(e){const t=/^(https?):\/\/([^/?#@\s]+)(?:[/?#]\S*)?$/i.exec(e.trim());if(t===null)return{ok:!1,reason:"invalid"};const[,s,r]=t;if(!r.startsWith("*.")||r.slice(2).includes("*"))return{ok:!1,reason:"placement"};let i;try{i=new URL(`${s.toLowerCase()}://${r.slice(2)}`)}catch{return{ok:!1,reason:"invalid"}}const a=i.hostname;return a===""||a.startsWith("[")||/^[\d.]+$/.test(a)||a.startsWith(".")||a.includes("..")?{ok:!1,reason:"invalid"}:FU(a)?{ok:!1,reason:"public-suffix"}:{ok:!0,value:{pattern:`${i.protocol}//*.${i.host}`,protocol:i.protocol,suffix:a,port:i.port}}}const jy=["every-time","first-time","pre-approved"],j1={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function zU(e){const t=jy.indexOf(e);return jy.slice(0,t<0?1:t+1)}function y1(e){return e.endsWith(".account")}const WU="This account’s process holds the value for as long as its connection lives.",Kg="Stored, not usable until it has a binding.";function HU(e){return e==="browser.field"?"the origin of the site that holds the field, e.g. https://en.wikipedia.org or *.wikimedia.org":e==="browser.form.data"?"the origin, then the field name — e.g. https://localhost:8443 card-number":e==="browser.native.type"?"the app’s bundle id, e.g. com.bank.app":e==="http.header"?"the host, then the header name — e.g. localhost:9200 Authorization":e==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":y1(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const w1={"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})}},VU="A wildcard may only stand for the leftmost part of a site, like *.wikimedia.org.",KU=e=>`That is a public suffix; ${e} would match every site.`,yy="Give the site as an origin, like https://en.wikipedia.org.";function wy(e){const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:["https:","//",e].join("");if(UU(e)){const s=BU(t);if(s.ok)return{ok:!0,target:s.value.pattern};if(s.reason==="placement")return{ok:!1,error:VU};if(s.reason==="public-suffix"){const r=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/[/?#:].*$/,"").toLowerCase();return{ok:!1,error:KU(r)}}return{ok:!1,error:yy}}try{const s=new URL(t);if(s.origin==="null"||s.protocol!=="https:"&&s.protocol!=="http:")throw new Error("not an origin");return{ok:!0,target:s.origin}}catch{return{ok:!1,error:yy}}}function GU(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const s=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&s?[r,s]:null}function b1(e,t){const s=t.trim();if(s==="")return{ok:!1,error:"Give the exact place this value may go."};if(s.startsWith("{"))try{const a=JSON.parse(s);return a!==null&&typeof a=="object"&&!Array.isArray(a)?{ok:!0,target:a}:{ok:!1,error:'A target in JSON is an object, like {"host":"localhost","header":"Authorization"}.'}}catch{return{ok:!1,error:"That opens like JSON but does not parse."}}if(e==="browser.field")return wy(s);if(e==="browser.native.type"||y1(e))return{ok:!0,target:s};const r=w1[e];if(r===void 0)return{ok:!0,target:s};const i=GU(s);if(i===null)return{ok:!1,error:`${e} needs both: ${r.hint}.`};if(e==="browser.form.data"){const a=wy(i[0]);return a.ok?{ok:!0,target:r.build(a.target,i[1])}:a}return{ok:!0,target:r.build(i[0],i[1])}}function YU(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function qU(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const s=t,r=w1[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),a=i.map(o=>s[o]);if(i.every(o=>typeof s[o]=="string"))return a.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const k1="accounts.provider";function QU(e,t){for(const s of e)if(s.kind===k1&&typeof s.target=="string"){const r=t.get(s.target);if(r)return r}}function Pp(e,t,s){if(e===k1&&typeof t=="string"){const r=s.get(t);if(r)return r.label}return qU(e,t)}function S1(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function N1(e,t){if(typeof e!="object"||e===null)return[];const s=e[t];return Array.isArray(s)?s.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,a=r.count;return typeof i!="string"||typeof a!="number"||!(a>0)?[]:[{place:i,count:a}]}):[]}function C1(e){const t=e.map(({place:s,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?s.replace(/s$/,""):s}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function XU(e){const t=N1(e,"found");return t.length?`The value already sits in ${C1(t)}.`:""}function JU(e){const t=N1(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${C1(t)}.`:""}async function di(e,t,s,r){s(!0),r(null);try{return(await A.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{s(!1)}}function ZU({embedded:e,timezone:t}={}){const s=re(()=>A.secrets(),[]),r=re(()=>A.providerAccounts(),[]),i=d.useMemo(()=>{var c;return new Map((((c=r.data)==null?void 0:c.accounts)??[]).map(u=>[u.id,{label:u.label,provider:Hg(u)}]))},[r.data]),[a,o]=d.useState(!1),l=s.data;return n.jsxs(fn,{embedded:e,title:"Keys and secrets",lede:"What the agents may use and never see: a name, a value buddi keeps, and the exact places the value may go.",children:[n.jsxs(V,{gap:"lg",children:[!l&&!s.error?n.jsx(ue,{children:"Opening the vault…"}):null,s.error?n.jsx(Q,{children:n.jsx(I,{onClick:s.reload,children:"Retry"})}):null,l?n.jsx(Y,{title:"Secrets",aside:"A value the agents use and never see: bound to where it may go, never shown again.",actions:n.jsx(I,{variant:"accent",size:"sm",onClick:()=>o(!0),children:"Add a secret"}),panel:!0,children:n.jsx(V,{divided:!0,children:l.secrets.length===0?n.jsx(Rt,{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."}):l.secrets.map(c=>n.jsx(e6,{secret:c,accounts:i,destinations:l.destinations,timezone:t,onChanged:s.reload},c.name))})}):null,l?n.jsx(Y,{title:"buddi’s own keys",aside:"Read-only.",children:n.jsxs(V,{gap:"sm",children:[l.ownKeys.length===0?n.jsx(ue,{children:"No keys of buddi’s own right now."}):n.jsx("div",{className:"ui-list",children:l.ownKeys.map(c=>n.jsx("div",{className:"ui-list-row",children:n.jsx("span",{className:"ui-list-main",children:n.jsx("span",{className:"mono",children:c})})},c))}),n.jsx("p",{className:"ui-card-meta",children:"These are the keys buddi itself runs on. They cannot be bound or replaced here, and the scrubber replaces them in what buddi sends out, exactly like your own secrets."})]})}):null]}),a&&l?n.jsx(n6,{destinations:l.destinations,onClose:()=>o(!1),onChanged:s.reload}):null]})}function e6({secret:e,accounts:t,destinations:s,timezone:r,onChanged:i}){const[a,o]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(!1),[m,j]=d.useState(!1),w=async()=>{await di("secrets.delete",{name:e.name},o,c)!==null&&(p(!1),i())},b=e.lastUse,v=QU(e.bindings,t);return n.jsxs(V,{gap:"sm",children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("h3",{className:"ui-card-title",children:v?v.label:e.name}),v?n.jsx(Zr,{children:v.provider}):null,e.totp?n.jsx(Zr,{children:"TOTP"}):null,b?n.jsx(ye,{tone:S1(b.outcome),children:b.outcome}):null]}),v?n.jsx("p",{className:"ui-card-meta mono",children:e.name}):null,e.bindings.length===0?n.jsx("p",{className:"ui-card-meta",children:Kg}):n.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((x,y)=>n.jsxs("div",{className:"ui-row",children:[n.jsx(Zr,{children:x.kind}),n.jsx("span",{className:"mono",children:Pp(x.kind,x.target,t)}),n.jsx(ye,{tone:"muted",children:j1[x.rule]??x.rule})]},y))}),e.bindings.some(x=>x.heldByPlugin)?n.jsx("p",{className:"ui-card-meta",children:WU}):null,n.jsx("p",{className:"ui-card-meta",children:b?`Last used ${_e(b.at)}${b.agentId?` by ${b.agentId}`:""} — ${b.kind}, ${Pp(b.kind,b.target,t)}.`:"Never used."}),n.jsx(se,{message:l}),f?n.jsxs(W,{tone:"critical",role:"alert",children:[n.jsxs("p",{children:["Delete “",e.name,"”? The value and its bindings go; the use log stays, under the name."]}),n.jsxs(Q,{children:[n.jsx(I,{variant:"danger",disabled:a,onClick:()=>void w(),children:"Delete it"}),n.jsx(I,{disabled:a,onClick:()=>p(!1),children:"Cancel"})]})]}):null,n.jsxs(Q,{children:[n.jsx(I,{size:"sm",disabled:a,onClick:()=>h("replace"),children:"Replace value"}),n.jsx(I,{size:"sm",disabled:a,onClick:()=>h("rename"),children:"Rename"}),n.jsx(I,{size:"sm",disabled:a,onClick:()=>h("rebind"),children:e.bindings.length===0?"Add a binding":"Rebind"}),n.jsx(I,{size:"sm",variant:"danger",disabled:a,onClick:()=>p(!0),children:"Delete"}),n.jsx(I,{size:"sm",variant:"ghost","aria-expanded":m,onClick:()=>j(!m),children:"Use log"})]}),m?n.jsx(t6,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?n.jsx(s6,{secret:e,onClose:()=>h(null),onChanged:i}):null,u==="rename"?n.jsx(r6,{secret:e,onClose:()=>h(null),onChanged:i}):null,u==="rebind"?n.jsx(i6,{secret:e,destinations:s,onClose:()=>h(null),onChanged:i}):null]})}function t6({name:e,accounts:t,timezone:s}){const r=re(()=>A.secretUses(e,50),[e]);if(r.error)return n.jsx(se,{message:r.error});if(!r.data)return n.jsx(ue,{children:"Reading the log…"});const i=r.data.uses;return i.length===0?n.jsx(ue,{children:"No uses yet."}):n.jsx("div",{className:"ui-list",children:i.map((a,o)=>n.jsxs("div",{className:"ui-list-row",children:[n.jsxs("span",{className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[He(a.at,s??"UTC")," — ",a.kind,", ",Pp(a.kind,a.target,t)]}),n.jsxs("span",{className:"ui-list-sub",children:[a.agent?a.agent:"the owner",a.plugin?` · ${a.plugin}`:"",a.detail?` · ${a.detail}`:""]})]}),n.jsx("span",{className:"ui-list-side",children:n.jsx(ye,{tone:S1(a.outcome),children:a.outcome})})]},o))})}function E1({name:e,result:t,scrubbed:s,busy:r,failure:i,onScrub:a,onDone:o}){const l=XU(t);return n.jsxs(V,{gap:"sm",children:[n.jsxs(W,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),n.jsx("p",{className:"ui-card-meta",children:l||"Nothing of the value sits where buddi already holds text."}),n.jsx(se,{message:i}),l?n.jsx(Q,{children:n.jsx(I,{variant:"accent",disabled:r||s!==null,onClick:a,children:s===null?"Scrub the history":JU(s)||"Nothing of it was left to replace."})}):null,n.jsx(Q,{align:"end",children:n.jsx(I,{onClick:o,children:"Done"})})]})}function A1({destinations:e,bindings:t,disabled:s,onChange:r}){const i=(a,o)=>{r(t.map((l,c)=>c===a?{...l,...o}:l))};return n.jsx(V,{gap:"sm",children:t.map((a,o)=>{const l=e.find(u=>u.kind===a.kind),c=(l==null?void 0:l.maxRule)??a.rule;return n.jsxs(Q,{valign:"end",children:[n.jsx(J,{label:"Kind",inline:!0,children:n.jsx("select",{value:a.kind,disabled:s,onChange:u=>{var f;const h=u.target.value;i(o,{kind:h,rule:((f=e.find(p=>p.kind===h))==null?void 0:f.maxRule)??a.rule})},children:(l?e:[...e,{kind:a.kind,plugin:"",maxRule:a.rule}]).map(u=>n.jsx("option",{value:u.kind,children:u.kind},u.kind))})}),n.jsx(J,{label:"Target",inline:!0,grow:!0,children:n.jsx("input",{type:"text",spellCheck:!1,disabled:s,value:a.target,placeholder:HU(a.kind),onChange:u=>i(o,{target:u.target.value})})}),n.jsx(J,{label:"Rule",inline:!0,children:n.jsx("select",{value:a.rule,disabled:s,onChange:u=>i(o,{rule:u.target.value}),children:zU(c).map(u=>n.jsx("option",{value:u,children:j1[u]},u))})}),n.jsx(I,{size:"sm",variant:"ghost",disabled:s,onClick:()=>r(t.filter((u,h)=>h!==o)),children:"Remove"})]},o)})})}function n6({destinations:e,onClose:t,onChanged:s}){const[r,i]=d.useState(""),[a,o]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:e[0].maxRule}]:[]),[f,p]=d.useState(!1),[m,j]=d.useState(null),[w,b]=d.useState(null),[v,x]=d.useState(null),y=async()=>{const N=u.map(R=>b1(R.kind,R.target)),k=N.findIndex(R=>!R.ok);if(k!==-1){j(`Binding ${k+1}: ${N[k].error}`);return}const S=a;o("");const C=await di("secrets.put",{name:r.trim(),value:S,totp:l,bindings:u.map((R,E)=>({kind:R.kind,target:N[E].target,rule:R.rule}))},p,j);C!==null&&(b({name:r.trim(),result:C}),s())},g=async()=>{const N=await di("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},p,j);N!==null&&(x(N),s())};return n.jsx(en,{title:"Add a secret",onClose:t,children:w?n.jsx(E1,{name:w.name,result:w.result,scrubbed:v,busy:f,failure:m,onScrub:()=>void g(),onDone:t}):n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:N=>{N.preventDefault(),y()},children:n.jsxs("fieldset",{disabled:f,className:"ui-stack","data-gap":"sm",children:[n.jsx(J,{label:"Name",hint:"What an agent calls it. Saving a name that exists replaces that secret’s value.",children:n.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:N=>i(N.target.value),placeholder:"PNC password"})}),n.jsx(J,{label:"Value",hint:"Kept in the vault, never shown again — not even here.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:a,onChange:N=>o(N.target.value)})}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:l,onChange:N=>c(N.target.checked)}),n.jsx("span",{children:"The code comes from this secret"})]}),n.jsx("p",{className:"ui-field-hint",children:"The seed and the code are one thing buddi holds — the owner’s explicit choice per secret."}),n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[n.jsx("span",{className:"ui-field-label",children:"Bindings — the places this value may go"}),n.jsx(A1,{destinations:e,bindings:u,disabled:f,onChange:h}),u.length===0?n.jsx("p",{className:"ui-field-hint",children:Kg}):null,e.length?n.jsx(Q,{children:n.jsx(I,{size:"sm",onClick:()=>h([...u,{kind:e[0].kind,target:"",rule:e[0].maxRule}]),children:"Add a binding"})}):n.jsx("p",{className:"ui-field-hint",children:"No destination is registered on this installation yet, so there is nothing to bind to."})]}),m?n.jsx(W,{tone:"critical",role:"alert",children:m}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:t,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",children:"Save secret"})]})]})})})}function s6({secret:e,onClose:t,onChanged:s}){const[r,i]=d.useState(""),[a,o]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),m=async()=>{const w=r;i("");const b=await di("secrets.put",{name:e.name,value:w,totp:e.totp,bindings:e.bindings.map(({kind:v,target:x,rule:y})=>({kind:v,target:x,rule:y}))},o,c);b!==null&&(h(b),s())},j=async()=>{const w=await di("secrets.scrub_history",{name:e.name},o,c);w!==null&&(p(w),s())};return n.jsx(en,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?n.jsx(E1,{name:e.name,result:u,scrubbed:f,busy:a,failure:l,onScrub:()=>void j(),onDone:t}):n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:w=>{w.preventDefault(),m()},children:n.jsxs("fieldset",{disabled:a,className:"ui-stack","data-gap":"sm",children:[n.jsx(J,{label:"New value",hint:"Replaces what is stored. The bindings stay as they are.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,value:r,onChange:w=>i(w.target.value)})}),l?n.jsx(W,{tone:"critical",role:"alert",children:l}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:t,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",children:"Save value"})]})]})})})}function r6({secret:e,onClose:t,onChanged:s}){const[r,i]=d.useState(e.name),[a,o]=d.useState(!1),[l,c]=d.useState(null),u=async()=>{await di("secrets.rename",{name:e.name,to:r.trim()},o,c)!==null&&(s(),t())};return n.jsx(en,{title:`Rename “${e.name}”`,onClose:t,children:n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:h=>{h.preventDefault(),u()},children:n.jsxs("fieldset",{disabled:a,className:"ui-stack","data-gap":"sm",children:[n.jsx(J,{label:"New name",hint:"The vault entry never moves; only the name the agents ask for does.",children:n.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:h=>i(h.target.value)})}),l?n.jsx(W,{tone:"critical",role:"alert",children:l}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:t,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",disabled:!r.trim()||r.trim()===e.name,children:"Save name"})]})]})})})}function i6({secret:e,destinations:t,onClose:s,onChanged:r}){const[i,a]=d.useState(()=>e.bindings.map(f=>({kind:f.kind,target:YU(f.target),rule:f.rule}))),[o,l]=d.useState(!1),[c,u]=d.useState(null),h=async()=>{const f=i.map(j=>b1(j.kind,j.target)),p=f.findIndex(j=>!j.ok);if(p!==-1){u(`Binding ${p+1}: ${f[p].error}`);return}await di("secrets.rebind",{name:e.name,bindings:i.map((j,w)=>({kind:j.kind,target:f[w].target,rule:j.rule}))},l,u)!==null&&(r(),s())};return n.jsx(en,{title:`Rebind “${e.name}”`,onClose:s,children:n.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:f=>{f.preventDefault(),h()},children:n.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[n.jsx(A1,{destinations:t,bindings:i,disabled:o,onChange:a}),i.length===0?n.jsx("p",{className:"ui-field-hint",children:Kg}):null,t.length?n.jsx(Q,{children:n.jsx(I,{size:"sm",onClick:()=>a([...i,{kind:t[0].kind,target:"",rule:t[0].maxRule}]),children:"Add a binding"})}):null,c?n.jsx(W,{tone:"critical",role:"alert",children:c}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,children:"Cancel"}),n.jsx(I,{type:"submit",variant:"accent",children:"Save bindings"})]})]})})})}const a6={connected:{label:"Connected",tone:"good"},"needs-reconnect":{label:"Needs reconnect",tone:"warning"},unreachable:{label:"Unreachable",tone:"critical"},"pending-review":{label:"Not finished",tone:"muted"},"needs-review":{label:"Changed its tools",tone:"warning"}},o6="It can delete or destroy something, so it asks you every time and is never remembered.";function l6(e){return e.tier==="auto"?{label:"Runs on its own",tone:"good"}:e.destructive?{label:"Asks you every time",tone:"critical"}:{label:"Asks you first",tone:"warning"}}const T1="buddi-connections",c6="/connections/callback",u6="This service does not let buddi register itself, so it needs a client id you create in the service’s developer settings, with the address below as its redirect.";function d6({embedded:e,timezone:t}={}){const s=re(()=>A.connections(),[],3e4),[r,i]=d.useState(null),a=s.data,o=l=>{var c;return((c=a==null?void 0:a.agents.find(u=>u.id===l))==null?void 0:c.name)??l};return n.jsxs(fn,{embedded:e,title:"Connections",lede:"Services that speak MCP, connected once. Their tools become buddi tools: read at review, given to the agents you choose, approved like everything else.",children:[n.jsxs(V,{gap:"lg",children:[!a&&!s.error?n.jsx(ue,{children:"Reading your connections…"}):null,n.jsx(se,{message:s.error}),a&&!a.vault?n.jsx(W,{tone:"warning",children:"This installation has no vault, so a service that asks for a sign-in cannot be connected. Turn the vault on first."}):null,a?n.jsx(Y,{title:"Your connections",aside:"Each one's tools are named mcp.<connection>.<tool>.",panel:!0,children:n.jsx(V,{divided:!0,children:a.connections.length===0?n.jsx(Rt,{icon:"globe",title:"Nothing connected yet",children:"Pick a service below, or give the address of any remote MCP server."}):a.connections.map(l=>n.jsx(f6,{connection:l,agentName:o,timezone:t??Intl.DateTimeFormat().resolvedOptions().timeZone,onFlow:i,onChanged:s.reload},l.id))})}):null,a?n.jsx(Y,{title:"Connect a service",aside:"Each has an official remote server. You sign in on the service's own page.",children:n.jsxs("div",{className:"connections-cards",children:[a.catalog.map(l=>n.jsx(Kn,{title:l.name,foot:n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",onClick:()=>i({step:"address",card:l}),children:"Connect"})}),children:n.jsx("p",{className:"ui-card-meta",children:l.blurb})},l.id)),n.jsx(Kn,{title:"Another server",foot:n.jsx(Q,{align:"end",children:n.jsx(I,{size:"sm",onClick:()=>i({step:"address"}),children:"Connect"})}),children:n.jsx("p",{className:"ui-card-meta",children:"Any remote MCP server, by its https address."})})]})}):null]}),r&&a?n.jsx(h6,{start:r,agents:a.agents,onClose:()=>{i(null),s.reload()}}):null]})}function f6({connection:e,agentName:t,timezone:s,onFlow:r,onChanged:i}){const[a,o]=d.useState(!1),[l,c]=d.useState(!1),[u,h]=d.useState(null),f=a6[e.state],p=async()=>{c(!0),h(null);try{await A.disconnect(e.id),o(!1),i()}catch(j){h(j instanceof Error?j.message:String(j))}finally{c(!1)}},m=e.state==="pending-review";return n.jsxs(V,{gap:"sm",children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("h3",{className:"ui-card-title",children:e.name}),n.jsx(ye,{tone:f.tone,dot:!0,children:f.label}),e.grant?n.jsx(Zr,{children:e.grant}):null]}),n.jsxs("p",{className:"ui-card-meta",children:[n.jsx("span",{className:"mono",children:e.host}),m?" · its tools are not reviewed yet":` · ${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,e.reviewedAt?` · reviewed ${_e(e.reviewedAt)}`:""]}),m?null:n.jsx("p",{className:"ui-card-meta",children:e.agents.length===0?"No agent holds these tools yet.":`Held by ${e.agents.map(t).join(", ")}.`}),e.state==="needs-reconnect"?n.jsx("p",{className:"ui-card-meta",children:"Its sign-in ran out or was refused. Until you reconnect, each of its tools answers with one sentence instead of running."}):null,e.state==="needs-review"?n.jsxs("p",{className:"ui-card-meta",children:["It changed its tools since you reviewed them. The new and changed ones wait until you review it again",e.heldTools?` (${e.heldTools} of the ones you kept ${e.heldTools===1?"waits":"wait"})`:"","; the others keep working."]}):null,e.state==="unreachable"&&e.unreachableSince?n.jsxs("p",{className:"ui-card-meta",children:["Unreachable since ",He(e.unreachableSince,s),", retrying."]}):null,n.jsx(se,{message:u}),a?n.jsx(W,{tone:"critical",role:"alert",title:`Disconnect ${e.name}?`,children:n.jsxs(V,{gap:"sm",children:[n.jsxs("p",{children:["buddi forgets its sign-in and its tools.",e.agents.length>0?` ${e.grant} comes out of ${e.agents.map(t).join(", ")}.`:" No agent holds its tools."]}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",onClick:()=>o(!1),disabled:l,children:"Keep it"}),n.jsx(I,{size:"sm",variant:"danger",onClick:()=>void p(),disabled:l,children:"Disconnect"})]})]})}):n.jsxs(Q,{align:"end",children:[m?n.jsx(I,{size:"sm",variant:"accent",onClick:()=>r({step:e.signedIn?"review":"consent",connection:e}),children:"Finish"}):null,m?null:n.jsx(I,{size:"sm",variant:e.state==="needs-review"?"accent":void 0,onClick:()=>r({step:"review",connection:e,keepGrants:!0}),children:"Review again"}),e.authKind==="oauth"&&!m?n.jsx(I,{size:"sm",variant:e.state==="needs-reconnect"?"accent":void 0,onClick:()=>r({step:"consent",connection:e,keepGrants:!0}),children:"Reconnect"}):null,n.jsx(I,{size:"sm",variant:"ghost",onClick:()=>o(!0),children:"Disconnect"})]})]})}function h6({start:e,agents:t,onClose:s,pollMs:r=2e3}){var p;const[i,a]=d.useState(e.step),[o,l]=d.useState(e.connection),[c,u]=d.useState("dynamic"),h=(o==null?void 0:o.name)??((p=e.card)==null?void 0:p.name)??"the service",f=i==="address"?"Connect a service":i==="consent"?`Sign in to ${h}`:i==="review"?`What ${h} brings`:"Who gets these tools";return n.jsxs(en,{title:f,onClose:s,size:"wide",children:[i==="address"?n.jsx(p6,{card:e.card,onDone:(m,j)=>{l(m),j==="none"?a("review"):(u(j),a("consent"))}}):null,i==="consent"&&o?n.jsx(m6,{connection:o,manual:c==="manual",pollMs:r,onSignedIn:m=>{l(m),e.keepGrants?s():a("review")}}):null,i==="review"&&o?n.jsx(g6,{connection:o,onKept:m=>{l(m),e.keepGrants?s():a("grant")}}):null,i==="grant"&&o?n.jsx(x6,{connection:o,agents:t,onDone:s}):null]})}function qo(e){return e instanceof Error?e.message:String(e)}function p6({card:e,onDone:t}){const[s,r]=d.useState((e==null?void 0:e.url)??""),[i,a]=d.useState(!1),[o,l]=d.useState(null),c=async()=>{a(!0),l(null);try{const u=await A.addConnection(s.trim(),e==null?void 0:e.name);t(u.connection,u.signIn)}catch(u){l(qo(u))}finally{a(!1)}};return n.jsxs("form",{className:"ui-stack",onSubmit:u=>{u.preventDefault(),c()},children:[e?n.jsxs("p",{children:["buddi opens ",e.name,"’s server, reads its name and what it offers, and asks whether it wants you to sign in. Nothing else is sent."]}):n.jsx("p",{children:"Where is the server? buddi opens it, reads its name and what it offers, and nothing else until you have read its tools."}),n.jsx(J,{label:"Address",hint:"An https:// address. Servers that run as a program on this computer are not supported yet.",children:n.jsx("input",{required:!0,autoFocus:!e,spellCheck:!1,value:s,placeholder:"https://",onChange:u=>r(u.target.value)})}),e&&!e.verified?n.jsxs("p",{className:"ui-card-meta",children:["This address is the one ",e.name," published; buddi has not checked it since."]}):null,e!=null&&e.clientIdRequired?n.jsxs("p",{className:"ui-card-meta",children:[e.name," does not let buddi register itself: you will need a client id from its developer settings."]}):null,n.jsx(se,{message:o}),n.jsx(Q,{align:"end",children:n.jsx(I,{type:"submit",variant:"accent",disabled:i||s.trim()==="",children:i?"Opening…":"Continue"})})]})}function m6({connection:e,manual:t,pollMs:s,onSignedIn:r}){const[i,a]=d.useState(t?u6:null),[o,l]=d.useState(""),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState(!1),[j,w]=d.useState(null),b=`${location.origin}${c6}`,v=d.useRef(r);v.current=r,d.useEffect(()=>{if(!p)return;let y=!1;const g=async()=>{if(!y){y=!0;try{v.current(await A.connection(e.id))}catch(R){f(qo(R))}}},N=typeof BroadcastChannel=="function"?new BroadcastChannel(T1):null;N&&(N.onmessage=R=>{var E;((E=R.data)==null?void 0:E.id)===e.id&&g()});let k;const S=Date.now(),C=async()=>{if(!y){try{const R=await A.connection(e.id);if(!e.signedIn&&R.signedIn){g();return}}catch{}if(Date.now()-S>10*6e4){m(!1),f("The sign-in did not come back within ten minutes. Start it again.");return}k=window.setTimeout(()=>void C(),s)}};return k=window.setTimeout(()=>void C(),s),()=>{y=!0,N==null||N.close(),window.clearTimeout(k)}},[p,e,s]);const x=async()=>{var g;const y=window.open("","_blank");u(!0),f(null);try{const{authorizeUrl:N}=await A.connectionConsent(e.id,i!==null?o.trim():void 0);y?(y.opener=null,y.location.href=N):w(N),m(!0)}catch(N){y==null||y.close(),N instanceof oe&&((g=N.detail)==null?void 0:g.code)==="client-id"?a(N.message):f(qo(N))}finally{u(!1)}};return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:[e.name," asks you to sign in. buddi opens its own consent page in a new tab; you say yes there, to ",e.name,", and the tab comes back here. buddi keeps the sign-in in its vault, and no agent ever sees it."]}),i!==null?n.jsxs(n.Fragment,{children:[n.jsx(W,{tone:"warning",children:i}),n.jsx(J,{label:"Client id",children:n.jsx("input",{required:!0,spellCheck:!1,value:o,onChange:y=>l(y.target.value)})}),n.jsxs("p",{className:"ui-card-meta",children:["Its redirect address: ",n.jsx("span",{className:"mono",children:b})]})]}):null,p?n.jsxs(W,{tone:"accent",role:"status",children:["Waiting for you to say yes on ",e.name,"’s page…"]}):null,j?n.jsx("p",{children:n.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",children:["Open ",e.name,"’s sign-in page"]})}):null,n.jsx(se,{message:h}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",onClick:()=>void x(),disabled:c||i!==null&&o.trim()==="",children:p?"Open it again":`Sign in to ${e.name}`})})]})}function g6({connection:e,onKept:t}){const s=re(()=>A.connectionReview(e.id),[e.id]),[r,i]=d.useState(null),[a,o]=d.useState(!1),[l,c]=d.useState(null),u=s.data,h=r??(u==null?void 0:u.slug)??"",f=async()=>{var m;if(u){o(!0),c(null);try{t(await A.saveConnectionReview(e.id,{hash:u.hash,...u.slugEditable?{slug:h}:{}}))}catch(j){j instanceof oe&&((m=j.detail)==null?void 0:m.code)==="changed"&&s.reload(),c(qo(j))}finally{o(!1)}}};if(!u)return s.error?n.jsx(se,{message:s.error}):n.jsxs(ue,{children:["Reading what ",e.name," offers…"]});const p=u.tools.filter(m=>m.problem===null).length;return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:["Read what ",e.name," brings before it brings it. Each tool gets a buddi name and a tier from what the server says it does; anything that changes something asks you first, on the same approval card as every other tool."]}),n.jsxs("p",{className:"ui-card-meta",children:["buddi talks to ",n.jsx("span",{className:"mono",children:u.host})," for these tools, and nowhere else."]}),u.annotatedNothing?n.jsxs(W,{tone:"warning",children:[e.name," says nothing about what its tools do, so every one of them asks you first."]}):null,u.changes&&u.changes.added.length+u.changes.changed.length+u.changes.removed.length>0?n.jsxs(W,{tone:"warning",title:`${e.name} changed its tools since your last review.`,children:[n.jsxs("ul",{className:"connections-changes","aria-label":"What changed",children:[u.changes.added.length>0?n.jsxs("li",{children:["New: ",n.jsx("span",{className:"mono",children:u.changes.added.join(", ")})]}):null,u.changes.changed.length>0?n.jsxs("li",{children:["Changed: ",n.jsx("span",{className:"mono",children:u.changes.changed.join(", ")})]}):null,u.changes.removed.length>0?n.jsxs("li",{children:["Gone: ",n.jsx("span",{className:"mono",children:u.changes.removed.join(", ")})]}):null]}),n.jsx("p",{children:"Until you keep this list, the new and changed tools wait; the others keep working."})]}):null,u.slugEditable?n.jsx(J,{label:"Its name in buddi",hint:`Tools are called mcp.${h||"…"}.<tool>. Lower case, letters, digits, _ and -.`,children:n.jsx("input",{required:!0,spellCheck:!1,maxLength:24,value:h,onChange:m=>i(m.target.value.toLowerCase())})}):null,u.tools.length===0?n.jsxs(ue,{children:[e.name," lists no tools."]}):n.jsx("div",{className:"ui-list","aria-label":"Tools",children:u.tools.map(m=>{const j=l6(m),w=u.slugEditable?m.fullName.replace(/^mcp\.[^.]+\./,`mcp.${h||u.slug}.`):m.fullName;return n.jsx("div",{className:"ui-list-row connections-tool",children:n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("span",{className:"mono",children:w}),m.problem?n.jsx(ye,{tone:"muted",children:"Cannot be used"}):n.jsx(ye,{tone:j.tone,children:j.label}),m.change==="added"?n.jsx(Zr,{children:"New"}):m.change==="changed"?n.jsx(Zr,{children:"Changed"}):null]}),m.description?n.jsx("p",{className:"ui-card-meta",children:m.description}):null,!m.problem&&m.tier==="gated"?n.jsx("p",{className:"ui-card-meta",children:m.destructive?o6:"You can remember its approval for an agent when you give it the tools, or later on the agent’s Access page."}):null,m.problem?n.jsxs("p",{className:"ui-card-meta",children:["Left out: ",m.problem,"."]}):null]})},m.name)})}),n.jsx(se,{message:l}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",onClick:()=>void f(),disabled:a||u.slugEditable&&h.trim()==="",children:p===1?"Keep this tool":`Keep these ${p} tools`})})]})}function x6({connection:e,agents:t,onDone:s}){var b;const r=t.find(v=>v.frontDesk)??t[0],[i,a]=d.useState(()=>new Set(r?[r.id]:[])),l=(((b=re(()=>A.connectionTools(e.id),[e.id]).data)==null?void 0:b.tools)??[]).filter(v=>v.tier==="gated"),[c,u]=d.useState(()=>new Set),[h,f]=d.useState(!1),[p,m]=d.useState(null),j=(v,x)=>{a(y=>{const g=new Set(y);return x?g.add(v):g.delete(v),g})},w=async()=>{f(!0),m(null);try{const v=await A.grantConnection(e.id,[...i]);if(v.failed.length>0){m(v.failed.map(x=>`${x.agent}: ${x.message}`).join(" "));return}for(const x of v.granted)for(const y of c)await A.setRememberedApproval(x,y,!0);s()}catch(v){m(qo(v))}finally{f(!1)}};return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:[r?`Give these tools to ${r.name}?`:"Which agents get these tools?"," Each one you tick gets ",n.jsx("span",{className:"mono",children:e.grant})," on its tools line."]}),n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Agents",children:t.map(v=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:i.has(v.id),onChange:x=>j(v.id,x.target.checked)}),n.jsxs("span",{children:[v.name,v.frontDesk?" (front desk)":""]})]},v.id))}),n.jsx("p",{className:"ui-card-meta",children:"No one is fine too: the connection waits here until you give it to someone."}),l.length>0?n.jsxs("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Remembered approval",children:[n.jsx("p",{children:"These ask you first. Tick one to remember your approval for the agents above, so it asks only once."}),l.map(v=>n.jsxs(V,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",disabled:!v.rememberable,checked:c.has(v.tool),onChange:x=>u(y=>{const g=new Set(y);return x.target.checked?g.add(v.tool):g.delete(v.tool),g})}),n.jsx("span",{className:"mono",children:v.tool})]}),v.why?n.jsx("p",{className:"ui-card-meta",children:v.why}):null]},v.tool))]}):null,n.jsx(se,{message:p}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{onClick:s,disabled:h,children:"Not now"}),n.jsx(I,{variant:"accent",onClick:()=>void w(),disabled:h||i.size===0,children:"Give them"})]})]})}function v6({timezone:e,embedded:t}){const{data:s,error:r,reload:i}=re(()=>A.sentinels(),[],3e4),[a,o]=d.useState(null),[l,c]=d.useState(null),u=(s==null?void 0:s.installed)??[],h=((s==null?void 0:s.runs)??[]).filter(m=>m.lastError),f=u.filter(m=>!m.enabled),p=(m,j)=>{o(m),c(null),A.setSentinelEnabled(m,j).catch(w=>c(w instanceof oe?w.message:String(w))).finally(()=>{o(null),i()})};return n.jsxs(fn,{embedded:t,title:"Watchers",children:[n.jsx(se,{message:r??l}),n.jsx(W,{children:"Watchers are small checks that run on their own, with no model involved. An urgent finding wakes an agent, which verifies it before it tells you. The rest waits for the weekly recap."}),h.length>0?n.jsx(W,{tone:"warning",children:h.length===1?"One watcher failed on its last run.":`${h.length} watchers failed on their last run.`}):null,f.length>0?n.jsxs(W,{tone:"warning",children:[f.length===1?"One watcher is off.":`${f.length} watchers are off.`," A watcher that is off does not run, and what it already found stays as it was."]}):null,n.jsx(Y,{title:"Installed",aside:n.jsx("a",{href:`${mt}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:s?u.length===0?n.jsx(Rt,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):n.jsx(Xt,{children:u.map(m=>{const j=s.runs.find(w=>w.sentinelId===m.id);return n.jsx(cn,{lead:n.jsx(ye,{tone:m.enabled?j!=null&&j.lastError?"critical":j?"good":void 0:"muted",children:m.enabled?j!=null&&j.lastError?"failed":j?"ok":"never ran":"off"}),title:m.description,sub:`${m.id}, every ${j6(m.every)}${j!=null&&j.lastError?`. ${j.lastError}`:""}`,side:n.jsxs(n.Fragment,{children:[n.jsx("span",{title:j?He(j.lastRunAt,e):void 0,children:j?_e(j.lastRunAt):"never ran"}),n.jsx(I,{size:"sm",disabled:a===m.id,onClick:()=>p(m.id,!m.enabled),children:m.enabled?"Turn off":"Turn on"})]})},m.id)})}):n.jsx(ue,{children:"Loading…"})})]})}function j6(e){if(e%86400===0){const s=e/86400;return s===1?"day":`${s} days`}if(e%3600===0){const s=e/3600;return s===1?"hour":`${s} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}function y6({embedded:e}){const{data:t,error:s,reload:r}=re(()=>A.owner(),[]);return n.jsxs(fn,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[n.jsx(se,{message:s}),t?n.jsx(w6,{initial:t,onSaved:r}):null]})}function w6({initial:e,onSaved:t}){const[s,r]=d.useState(e.preferredName??""),[i,a]=d.useState(e.timezone??""),[o,l]=d.useState(e.language??""),[c,u]=d.useState(e.about??""),[h,f]=d.useState(!1),[p,m]=d.useState(!1),[j,w]=d.useState(null);d.useEffect(()=>{r(e.preferredName??""),a(e.timezone??""),l(e.language??""),u(e.about??"")},[e]);const b=s.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||o.trim()!==(e.language??"")||c.trim()!==(e.about??""),v=async()=>{f(!0),w(null);try{await A.setOwner({preferredName:s.trim()===""?null:s.trim(),timezone:i===""?null:i,language:o.trim()===""?null:o.trim(),about:c.trim()===""?null:c.trim()}),m(!0),t()}catch(y){w(y instanceof oe?y.message:String(y))}finally{f(!1)}},x=e.zones.length>0?e.zones:[e.detectedTimezone];return n.jsx(Y,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:n.jsxs(n.Fragment,{children:[p&&!b?n.jsx("span",{className:"muted",children:"Saved"}):null,n.jsx(I,{variant:"accent",disabled:!b||h,onClick:()=>void v(),children:h?"Saving…":"Save"})]}),children:n.jsxs(V,{divided:!0,gap:"lg",children:[n.jsx(Y,{title:"Name and place",children:n.jsxs(Xs,{children:[n.jsx(J,{label:"What the agents call you",children:n.jsx("input",{value:s,maxLength:80,placeholder:e.displayName??"Your name",onChange:y=>{m(!1),r(y.target.value)}})}),n.jsx(J,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:n.jsxs("select",{value:i,onChange:y=>{m(!1),a(y.target.value)},children:[n.jsx("option",{value:"",children:"Not set (use the host's)"}),x.map(y=>n.jsx("option",{value:y,children:y},y))]})}),n.jsx(J,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:n.jsx("input",{value:o,maxLength:40,placeholder:"English, français…",onChange:y=>{m(!1),l(y.target.value)}})})]})}),n.jsxs(Y,{title:"About you",children:[n.jsx(J,{label:"In your own words",hint:"Who you are, how you like answers, anything every agent should keep in mind. A few lines is plenty.",children:n.jsx("textarea",{rows:4,maxLength:1e3,value:c,placeholder:"I run a small studio and prefer short answers with the numbers first. Call me by my first name.",onChange:y=>{m(!1),u(y.target.value)}})}),j?n.jsx(W,{tone:"critical",children:j}):null]})]})})}const b6=2e6;function by(e,t){const s=e.replace(/\r\n/g,`
111
+ `).replace(/\n+$/,"").split(`
112
+ `),r=t.replace(/\r\n/g,`
113
+ `).replace(/\n+$/,"").split(`
114
+ `);if(e.trim()===t.trim())return"(no change)";if(s.length*r.length>b6)return[...s.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
115
+ `);const i=Array.from({length:s.length+1},()=>new Uint32Array(r.length+1));for(let c=s.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=s[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const a=[];let o=0,l=0;for(;o<s.length&&l<r.length;)s[o]===r[l]?(a.push(` ${s[o]}`),o++,l++):i[o+1][l]>=i[o][l+1]?a.push(`-${s[o++]}`):a.push(`+${r[l++]}`);for(;o<s.length;)a.push(`-${s[o++]}`);for(;l<r.length;)a.push(`+${r[l++]}`);return a.join(`
116
+ `)}const k6={skill:"skill",policy:"rule",change:"change to itself"};function S6(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,s])=>!/Id$/.test(t)&&s!==null&&s!==void 0&&s!=="").map(([t,s])=>`${t} ${typeof s=="object"?JSON.stringify(s):String(s)}`).join(" · ")}function Mp(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function N6(e,t){const s=e.change;if(!s||s.part!=="tools")return[];if(t===e.editable)return s.added;const r=new Set(Mp(s.current??""));return Mp(t).filter(i=>!r.has(i))}function ky(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function C6({embedded:e,plugin:t}){const{data:s,error:r,reload:i}=re(()=>A.proposals(),[],3e4),[a,o]=d.useState(null),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState({}),m=async(v,x,y=!1)=>{o(null),c(null),h(v),p(({[v]:g,...N})=>N);try{c(await x()),i()}catch(g){const N=g instanceof Error?g.message:String(g);y?p(k=>({...k,[v]:N})):o(N)}finally{h(null)}},j=oN(),w=((s==null?void 0:s.open)??[]).filter(v=>ky(v,t)),b=((s==null?void 0:s.closed)??[]).filter(v=>ky(v,t));return n.jsxs(fn,{embedded:e,title:"Proposals",lede:"What your agents learned and would like to keep: a procedure, a rule, a change to their own instructions. Nothing here applies itself. Keep what is right, correct what is nearly right, discard the rest.",children:[n.jsx(se,{message:r??a}),t?n.jsxs(W,{role:"status",children:["Showing the rules ",t," proposes. ",n.jsx("a",{href:Ze("proposals"),children:"Show every proposal"})]}):null,l?n.jsx(W,{tone:"good",role:"status",children:l}):null,t?null:n.jsx(lN,{offers:j.offers,reload:j.reload}),!s||w.length===0?n.jsx(Y,{title:"Waiting",panel:!0,children:s?t?n.jsx(Rt,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):n.jsx(Rt,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):n.jsx(ue,{children:"Loading…"})}):n.jsx(Y,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(v=>n.jsx(R6,{proposal:v,busy:u===v.id,refusal:f[v.id]??null,onKeep:x=>void m(v.id,async()=>{const y=await A.keepProposal(v.id,x);return`${v.title}: ${y.note}`},!0),onDiscard:x=>void m(v.id,async()=>(await A.discardProposal(v.id,x),`Discarded: ${v.title}. ${v.agent} will be told once and will not propose it again for 90 days.`))},v.id))}),b.length>0?n.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:n.jsx(Xt,{children:b.map(v=>{var x;return n.jsx(cn,{title:v.title,sub:`${v.agent}: ${E6(v)}`,side:v.kind==="skill"&&v.state==="kept"&&((x=v.skill)!=null&&x.live)?n.jsxs(Q,{align:"end",children:[n.jsx("span",{className:"muted",children:_e(v.decidedAt??v.createdAt)}),n.jsx(I,{size:"sm",variant:"ghost",disabled:u===v.id,onClick:()=>void m(v.id,async()=>{const y=v.skill;return await A.removeSkill(v.agent,y.name),`Removed ${y.name} from ${v.agent}. Its versions are kept, and ${v.agent} will not propose it again for 90 days.`}),children:"Remove this skill"})]}):_e(v.decidedAt??v.createdAt)},v.id)})})}):null,!t&&(s!=null&&s.digest)?n.jsx(T6,{schedule:s.digest.schedule,onSaved:i}):null]})}function E6(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 A6=Array.from({length:24},(e,t)=>t),Sy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function T6({schedule:e,onSaved:t}){const[s,r]=d.useState(e.day),[i,a]=d.useState(e.hour),[o,l]=d.useState(!1),[c,u]=d.useState(null),h=s!==e.day||i!==e.hour,f=async()=>{l(!0),u(null);try{await A.setDigestSchedule(s,i),u({tone:"good",text:`The digest now runs on ${Sy[s]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(p){u({tone:"critical",text:p instanceof Error?p.message:String(p)})}finally{l(!1)}};return n.jsx(Y,{title:"Weekly digest",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:o||!h,onClick:()=>void f(),children:"Save"}),children:n.jsxs(V,{children:[n.jsxs("p",{className:"muted",children:["Once a week, one message on Telegram and a card on Home: what your agents learned, what waits here, and what the rules you kept stopped them doing. No message when nothing was learned and nothing waits.",e.next?` Next: ${_e(e.next)}.`:""]}),n.jsxs(Q,{children:[n.jsx(J,{label:"Day",children:n.jsx("select",{value:s,disabled:o,onChange:p=>r(Number(p.target.value)),children:Sy.map((p,m)=>n.jsx("option",{value:m,children:p},p))})}),n.jsx(J,{label:`Hour (${e.timezone})`,children:n.jsx("select",{value:i,disabled:o,onChange:p=>a(Number(p.target.value)),children:A6.map(p=>n.jsxs("option",{value:p,children:[String(p).padStart(2,"0"),":00"]},p))})})]}),c?n.jsx(W,{tone:c.tone,role:"status",children:c.text}):null]})})}function Ny(e,t){return e==="tools"?Mp(t).join(`
117
+ `):t}function R6({proposal:e,busy:t,refusal:s,onKeep:r,onDiscard:i}){const[a,o]=d.useState(e.editable??""),[l,c]=d.useState(""),u=e.editable!==null&&a!==e.editable,h=e.payload,f=e.echoes??[],p=e.kind==="change"?e.change??null:null,m=N6(e,a);return n.jsx(Kn,{tone:e.untrusted?"warning":"accent",title:e.title,meta:n.jsxs(n.Fragment,{children:[n.jsx(ye,{children:k6[e.kind]}),n.jsx(ye,{mono:!0,children:e.agent}),e.untrusted?n.jsx(ye,{tone:"warning",children:"untrusted text in view"}):null,m.length>0?n.jsx(ye,{tone:"warning",children:"widens its tools"}):null]}),foot:n.jsxs(Q,{align:"end",children:[s?n.jsx("span",{className:"proposal-refusal",role:"alert",children:s}):null,n.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:l,maxLength:300,disabled:t,onChange:j=>c(j.target.value)}),n.jsx(I,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(l.trim()||void 0),children:"Discard"}),n.jsx(I,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&a.trim()==="",onClick:()=>r(u?a:void 0),children:u?"Keep my version":"Keep"})]}),children:n.jsxs(V,{gap:"sm",children:[e.why?n.jsx("p",{children:e.why}):null,n.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",_e(e.createdAt),e.conversationId?n.jsxs(n.Fragment,{children:[" in ",n.jsx("a",{href:ha(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?n.jsxs(W,{tone:"warning",title:e.kind==="policy"?"Learned from mail you received.":"Made with untrusted text in view.",children:[e.kind==="policy"?"The plugin counted this rule from your own triage decisions; no instruction in that mail can change what it does.":"Something written by someone other than you was in the agent's context when it proposed this. Read it for instructions that came from there rather than from you.",n.jsx("ul",{className:"proposal-sources",children:e.sources.map(j=>n.jsx("li",{className:"mono",children:j},j))}),f.length>0?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),n.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:f.map(j=>n.jsx("li",{children:n.jsx("mark",{className:"wb-diff-mark",children:j})},j))})]}):null]}):null,e.kind==="skill"?n.jsxs(n.Fragment,{children:[typeof h.when=="string"?n.jsxs("p",{className:"ui-card-meta",children:["When: ",h.when]}):null,e.skill?n.jsxs(V,{gap:"sm",children:[n.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",n.jsxs("a",{href:lt(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),n.jsx(lu,{text:by(e.skill.steps,a),marks:f,label:`Version ${e.skill.version} against this proposal`})]}):null,n.jsx(J,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:n.jsx("textarea",{rows:8,value:a,disabled:t,onChange:j=>o(j.target.value)})})]}):null,e.kind==="change"?n.jsxs(n.Fragment,{children:[m.length>0?n.jsxs(W,{tone:"warning",title:`Adds: ${m.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,p!=null&&p.refusal&&!u?n.jsx(W,{tone:"warning",title:"Keeping this as proposed will be refused.",children:p.refusal}):null,p&&p.current!==null?n.jsx(lu,{text:by(Ny(p.part,p.current),Ny(p.part,a)),marks:f,label:`${e.agent}'s ${p.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof h.before=="string"?n.jsx(It,{summary:`What its ${h.part==="tools"?"tool list":"instructions"} said when proposed`,children:n.jsx(bt,{children:h.before})}):null,n.jsx(J,{label:h.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:n.jsx("textarea",{rows:8,value:a,disabled:t,onChange:j=>o(j.target.value)})})]}):null,e.kind==="policy"?n.jsx(Wt,{items:[{label:"Plugin",value:n.jsx("span",{className:"mono",children:String(h.plugin??"")})},{label:"Matches",value:n.jsx("span",{className:"mono",children:S6(h.matcher??{})})},{label:"Does",value:String(h.action??"")},{label:"Learned from",value:(()=>{const j=Array.isArray(h.verdicts)?h.verdicts.length:0;return`${j} ${j===1?"decision":"decisions"}`})()}]}):null]})})}const I6=1500,P6={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."},M6="Restart buddi to load it. In a checkout, stop it and run: buddi serve",R1=[{id:"npm",label:"From npm"},{id:"file",label:"A file"},{id:"directory",label:"A directory I built"}],I1="buddi.plugins.install-mode";function $6(){try{const e=window.localStorage.getItem(I1);if(R1.some(t=>t.id===e))return e}catch{}return"npm"}function O6(e){try{window.localStorage.setItem(I1,e)}catch{}}const tc=".tgz";function _6(e){const t=[],s=(r,i,a)=>{r>0&&t.push(`${r} ${r===1?i:a}`)};return s(e.tools,"tool","tools"),s(e.sentinels,"watcher","watchers"),s(e.views,"view","views"),s(e.agents,"agent","agents"),t.length===0?"nothing on its own":t.join(", ")}function P1(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 D6(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function L6(e){const[t,s]=d.useState(void 0),[r,i]=d.useState(null);return d.useEffect(()=>{if(!e){s(void 0),i(null);return}let a=!1;const o=()=>{A.pluginJob(e).then(c=>{a||(s(c),(c.phase==="done"||c.phase==="failed")&&(a=!0))}).catch(c=>{a||(i(c instanceof oe?c.message:String(c)),a=!0)})};o();const l=window.setInterval(o,I6);return()=>{a=!0,window.clearInterval(l)}},[e]),{job:t,error:r}}function F6(){const e=re(()=>A.plugins(),[],2e4),[t,s]=d.useState(null),{job:r,error:i}=L6(t),[a,o]=d.useState(null),[l,c]=d.useState(null);d.useEffect(()=>{((r==null?void 0:r.phase)==="done"||(r==null?void 0:r.phase)==="failed")&&e.reload()},[r==null?void 0:r.phase]);const u=e.data,h=(u==null?void 0:u.checkout)??!0;return n.jsxs(V,{gap:"lg",children:[n.jsx(se,{message:e.error??a??i}),u!=null&&u.unavailable?n.jsx(W,{tone:"warning",children:u.unavailable}):null,n.jsx(Y,{title:"Plugins",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsx(W,{tone:"warning",children:(u==null?void 0:u.trust)??""})}),n.jsx(Y,{children:n.jsx(B6,{busy:r!==void 0&&r.phase!=="done"&&r.phase!=="failed",onStaged:f=>{o(null),c(null),s(f)},onFailed:o})}),r?n.jsx(Y,{children:n.jsxs(W,{tone:r.phase==="failed"?"critical":r.phase==="done"?"good":void 0,role:"status",children:[P6[r.phase]," ",r.error??""]})}):null]})}),((u==null?void 0:u.staged)??[]).map(f=>n.jsx(W6,{staged:f,onInstalled:p=>{c(p),s(null),e.reload()},onGone:()=>e.reload()},f.id)),l||u!=null&&u.restartNeeded?n.jsx(H6,{checkout:h,name:l}):null,n.jsx(Y,{title:"Installed",panel:!0,children:u?u.installed.length===0?n.jsx(Rt,{icon:"plug",title:"Nothing installed yet",children:"Only what buddi ships with is here."}):n.jsx(V,{divided:!0,children:u.installed.map(f=>n.jsx(Y,{children:n.jsx(K6,{plugin:f,onChanged:()=>e.reload(),onFailed:o})},f.name))}):n.jsx(ue,{children:"Loading…"})}),((u==null?void 0:u.builtIn)??[]).length>0?n.jsx(Y,{title:"Ships with buddi",panel:!0,children:n.jsx(V,{divided:!0,children:((u==null?void 0:u.builtIn)??[]).map(f=>n.jsx(Y,{children:n.jsx(U6,{plugin:f})},f.name))})}):null]})}function U6({plugin:e}){return n.jsxs(V,{gap:"sm",children:[n.jsx(Wt,{items:[{label:n.jsx("span",{children:e.name}),value:n.jsxs("span",{children:[e.version," · ",_6(e.contribution)]})}]}),e.description?n.jsx("p",{className:"ui-card-meta",children:e.description}):null,e.network&&e.network.length>0?n.jsxs("p",{className:"ui-card-meta",children:["Talks to ",e.network.map((t,s)=>n.jsxs("span",{children:[s>0?", ":"",n.jsx("span",{className:"mono",title:t.why,children:t.host})]},t.host)),"."]}):null]})}function B6({busy:e,onStaged:t,onFailed:s}){const[r,i]=d.useState($6),[a,o]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState(null),[f,p]=d.useState(null),[m,j]=d.useState(!1),w=d.useRef(null),b=g=>s(g instanceof oe?g.message:String(g)),v=g=>{i(g),O6(g),p(null)},x=()=>{c(!0),A.stagePlugin(a.trim()).then(g=>{t(g.job.id),o("")}).catch(b).finally(()=>c(!1))},y=g=>{if(g){if(!g.name.toLowerCase().endsWith(tc)){h(null),p(`${g.name} is not a ${tc}. A packed plugin is the file npm pack writes.`);return}p(null),h(g.name),c(!0),A.uploadPlugin(g).then(N=>t(N.job.id)).catch(b).finally(()=>c(!1))}};return n.jsxs(V,{gap:"sm",children:[n.jsx("div",{className:"plugin-modes",role:"radiogroup","aria-label":"Where it comes from",children:R1.map(g=>n.jsx("button",{type:"button",role:"radio","aria-checked":r===g.id,className:"plugin-mode","data-chosen":r===g.id?"true":void 0,onClick:()=>v(g.id),children:g.label},g.id))}),r==="file"?n.jsxs("div",{className:"plugin-drop",role:"group","aria-label":"A plugin file","data-state":m?"over":f?"refused":u?"chosen":void 0,onDragOver:g=>{g.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:g=>{var N,k;g.preventDefault(),j(!1),y((k=(N=g.dataTransfer)==null?void 0:N.files)==null?void 0:k[0])},children:[n.jsx("p",{className:"ui-card-meta",children:f??(u?`${u} — reading it.`:`Drop a ${tc} here, or choose one.`)}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:e||l,onClick:()=>{var g;return(g=w.current)==null?void 0:g.click()},children:"Choose a file"})}),n.jsx("input",{ref:w,type:"file",accept:tc,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:g=>{var N;y((N=g.target.files)==null?void 0:N[0]),g.target.value=""}})]}):n.jsxs(n.Fragment,{children:[n.jsx(J,{label:r==="npm"?"Install a plugin":"The directory it is in",hint:r==="npm"?"A package name, or a name@version.":"The folder with its package.json, already built.",children:n.jsx("input",{type:"text",value:a,placeholder:r==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:g=>o(g.target.value)})}),n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:e||l||a.trim()==="",onClick:x,children:"Read it first"})})]})]})}function z6({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],s=((i=e.uses)==null?void 0:i.dropped)??[];return n.jsx(Y,{title:"What it reaches in buddi",children:n.jsxs(V,{gap:"sm",children:[t.length===0?n.jsx("p",{className:"ui-card-meta",children:"Nothing beyond its own tables, its own folder and its own tools' approvals."}):n.jsx("ul",{className:"plugin-uses",children:t.map(a=>n.jsxs("li",{children:["It ",a.words,"."," ",a.added?n.jsxs(ye,{tone:"warning",children:["new in ",e.version]}):null]},a.use))}),s.length>0?n.jsxs("p",{className:"ui-card-meta",children:["No longer: ",s.map(a=>a.words).join("; "),"."]}):null]})})}function W6({staged:e,onInstalled:t,onGone:s}){const[r,i]=d.useState(e.plan??null),[a,o]=d.useState(!1),[l,c]=d.useState(null),u=p=>{o(!0),c(null),A.approveStaged(e.id,{integrity:e.integrity??"",...p?{acknowledgeDrift:!0}:{}}).then(m=>{m.installed?t(e.name):m.plan&&i(m.plan)}).catch(m=>c(m instanceof oe?m.message:String(m))).finally(()=>o(!1))},h=()=>{o(!0),c(null),A.rejectStaged(e.id).then(()=>s()).catch(p=>c(p instanceof oe?p.message:String(p))).finally(()=>o(!1))},f=(r==null?void 0:r.drift)??[];return n.jsxs(V,{gap:"lg",children:[n.jsx(Kn,{tone:"accent",title:`${e.name} ${e.version}`,meta:n.jsx(ye,{tone:"muted",children:"read, not installed"}),children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:l}),n.jsx(Wt,{items:[{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:P1(e.source)},{label:"Published by",value:e.publisher??"nobody npm will name"},{label:"Integrity",value:n.jsx("span",{className:"mono",children:e.integrity===void 0||e.integrity===""?"none — this came off a disk":e.integrity})},...e.source.kind==="directory"?[]:[{label:"Installs as",value:e.installsAs??"the name its manifest gives, read when you approve — it declares no buddi.name"}],...e.coreAsDependency?[{label:"Core",value:"It asks npm for buddi's core; buddi provides its own."}]:[],...e.stagedHash?[{label:"Files on disk",value:n.jsx("span",{className:"mono",children:e.stagedHash})}]:[],{label:"Dependencies",value:e.dependencies.count===0?"none":`${e.dependencies.count}${e.dependencies.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${e.dependencies.withScripts.join(", ")}`}`}]}),n.jsx(z6,{staged:e}),n.jsx(Y,{title:"What the package says about itself",children:n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"This is its claim, taken from its own buddi.md. Nothing has checked it yet."}),n.jsx(Wt,{items:[{label:"Schema it owns",value:e.claims.schema??"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":e.claims.hosts.join(", ")}]}),e.claims.missing?n.jsx("p",{className:"ui-card-meta",children:"It ships no buddi.md, so it says nothing about itself at all."}):n.jsx("p",{className:"ui-card-meta",children:e.claims.text})]})}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",disabled:a,onClick:h,children:"Not this one"}),n.jsx(I,{variant:"accent",disabled:a||f.length>0,onClick:()=>u(!1),children:"Install"})]})]})}),f.length>0?n.jsx(Kn,{tone:"warning",title:"What it said, and what it does",meta:n.jsx(ye,{tone:"warning",children:"read this first"}),children:n.jsxs(V,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),n.jsx("ul",{className:"plugin-drift",children:f.map(p=>n.jsx("li",{children:p},p))}),n.jsx(M1,{unlocks:(r==null?void 0:r.agents)??[]}),n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",disabled:a,onClick:h,children:"Not this one"}),n.jsx(I,{variant:"danger",disabled:a,onClick:()=>u(!0),children:"Install anyway"})]})]})}):null]})}function H6({checkout:e,name:t}){const[s,r]=d.useState(!1),[i,a]=d.useState(null),o=t?`${t} is installed.`:"Something is installed that this buddi has not loaded.";return n.jsx(Y,{title:"Restart to load it",panel:!0,children:n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:i}),n.jsxs(W,{tone:e?"warning":void 0,role:"status",children:[o," ",e?M6:"Its tools appear once buddi restarts. That closes this dashboard for a few seconds."]}),e?null:n.jsx(Q,{align:"end",children:n.jsx(I,{variant:"accent",disabled:s,onClick:()=>{r(!0),a(null),A.serviceAction("restart").catch(l=>a(l instanceof oe?l.message:String(l))).finally(()=>r(!1))},children:"Restart to load it"})})]})})})}function M1({plugin:e,unlocks:t}){return t.length===0?null:n.jsx(Y,{title:"Agents it would unlock",children:n.jsxs(V,{gap:"sm",divided:!0,children:[t.map(s=>n.jsx(V6,{plugin:e,unlock:s},s.id)),n.jsxs("p",{className:"ui-card-meta",children:["Nothing here is created by installing. Accept creates the agent with the tools listed. You can change or remove it ",n.jsx("a",{href:ot,children:"on the Agents page"}),"."]})]})})}function V6({plugin:e,unlock:t}){const s=$g(e,t.id),r=t.drift.state!=="not-accepted";return n.jsxs(V,{gap:"sm",children:[n.jsxs(Q,{children:[n.jsxs("span",{className:"mono",children:["@",t.handle]}),n.jsx(ye,{tone:t.drift.state==="up-to-date"?"good":"warning",children:t.drift.state}),n.jsx("span",{className:"ui-card-meta",children:t.drift.message}),n.jsx(Es,{}),e&&!r&&!s.created?n.jsx(I,{size:"sm",disabled:s.busy,onClick:s.accept,children:"Accept"}):null]}),n.jsx(se,{message:s.failure}),s.created?n.jsx(iN,{agent:s.created}):null]})}function K6({plugin:e,onChanged:t,onFailed:s}){const[r,i]=d.useState(!1),[a,o]=d.useState(!1),[l,c]=d.useState(""),[u,h]=d.useState(!1),f=m=>{h(!0),m.then(()=>{i(!1),o(!1),c(""),t()}).catch(j=>s(j instanceof oe?j.message:String(j))).finally(()=>h(!1))},p=e.contribution;return n.jsxs(V,{gap:"sm",children:[n.jsx(Kn,{tone:e.loaded?void 0:"critical",title:`${e.name} ${e.version}`,meta:e.loaded?n.jsx(ye,{tone:"good",children:"loaded"}):n.jsx(ye,{tone:"critical",children:"did not load"}),actions:n.jsxs(Q,{align:"end",children:[n.jsx(I,{size:"sm",variant:"ghost",disabled:u,onClick:()=>i(!r),children:"Remove…"}),n.jsx(I,{size:"sm",disabled:u,onClick:()=>f(A.updatePlugin(e.name)),children:"Update"})]}),children:n.jsxs(V,{gap:"sm",children:[e.error?n.jsx(W,{tone:"critical",children:e.error}):null,n.jsx(Wt,{items:[{label:"From",value:P1(e.source)},{label:"Published by",value:D6(e.source,e.publisher)},{label:"Installed",value:_e(e.installedAt)},{label:"Contributes",value:`${p.tools} tool${p.tools===1?"":"s"}, ${p.sentinels} on a timer, ${p.views} view${p.views===1?"":"s"}, ${p.agents} agent${p.agents===1?"":"s"} proposed`}]}),n.jsx(M1,{plugin:e.name,unlocks:e.unlocks})]})}),r?n.jsxs(V,{gap:"sm",children:[n.jsx(W,{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."}),n.jsxs("label",{className:"plugin-check",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:m=>{o(m.target.checked),c("")}}),n.jsx("span",{children:"Also drop its data. Its tables are not recoverable afterwards."})]}),a?n.jsx(J,{label:`Type ${e.name} to confirm`,children:n.jsx("input",{value:l,onChange:m=>c(m.target.value)})}):null,n.jsxs(Q,{align:"end",children:[n.jsx(I,{variant:"ghost",disabled:u,onClick:()=>{i(!1),o(!1),c("")},children:"Cancel"}),n.jsx(I,{variant:"danger",disabled:u||a&&l.trim()!==e.name,onClick:()=>f(A.uninstallPlugin(e.name,a?{purge:!0,confirm:l.trim()}:{})),children:a?"Remove and drop its data":"Remove"})]})]}):null]})}var ll={},G6=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},$1={},On={};let Gg;const Y6=[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];On.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};On.getSymbolTotalCodewords=function(t){return Y6[t]};On.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};On.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Gg=t};On.isKanjiModeEnabled=function(){return typeof Gg<"u"};On.toSJIS=function(t){return Gg(t)};var dd={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+s)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(dd);function O1(){this.buffer=[],this.length=0}O1.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let s=0;s<t;s++)this.putBit((e>>>t-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var q6=O1;function cl(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)}cl.prototype.set=function(e,t,s,r){const i=e*this.size+t;this.data[i]=s,r&&(this.reservedBit[i]=!0)};cl.prototype.get=function(e,t){return this.data[e*this.size+t]};cl.prototype.xor=function(e,t,s){this.data[e*this.size+t]^=s};cl.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Q6=cl,_1={};(function(e){const t=On.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,a=t(r),o=a===145?26:Math.ceil((a-13)/(2*i-2))*2,l=[a-7];for(let c=1;c<i-1;c++)l[c]=l[c-1]-o;return l.push(6),l.reverse()},e.getPositions=function(r){const i=[],a=e.getRowColCoords(r),o=a.length;for(let l=0;l<o;l++)for(let c=0;c<o;c++)l===0&&c===0||l===0&&c===o-1||l===o-1&&c===0||i.push([a[l],a[c]]);return i}})(_1);var D1={};const X6=On.getSymbolSize,Cy=7;D1.getPositions=function(t){const s=X6(t);return[[0,0],[s-Cy,0],[0,s-Cy]]};var L1={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const a=i.size;let o=0,l=0,c=0,u=null,h=null;for(let f=0;f<a;f++){l=c=0,u=h=null;for(let p=0;p<a;p++){let m=i.get(f,p);m===u?l++:(l>=5&&(o+=t.N1+(l-5)),u=m,l=1),m=i.get(p,f),m===h?c++:(c>=5&&(o+=t.N1+(c-5)),h=m,c=1)}l>=5&&(o+=t.N1+(l-5)),c>=5&&(o+=t.N1+(c-5))}return o},e.getPenaltyN2=function(i){const a=i.size;let o=0;for(let l=0;l<a-1;l++)for(let c=0;c<a-1;c++){const u=i.get(l,c)+i.get(l,c+1)+i.get(l+1,c)+i.get(l+1,c+1);(u===4||u===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const a=i.size;let o=0,l=0,c=0;for(let u=0;u<a;u++){l=c=0;for(let h=0;h<a;h++)l=l<<1&2047|i.get(u,h),h>=10&&(l===1488||l===93)&&o++,c=c<<1&2047|i.get(h,u),h>=10&&(c===1488||c===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let a=0;const o=i.data.length;for(let c=0;c<o;c++)a+=i.data[c];return Math.abs(Math.ceil(a*100/o/5)-10)*t.N4};function s(r,i,a){switch(r){case e.Patterns.PATTERN000:return(i+a)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(i+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return i*a%2+i*a%3===0;case e.Patterns.PATTERN110:return(i*a%2+i*a%3)%2===0;case e.Patterns.PATTERN111:return(i*a%3+(i+a)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,a){const o=a.size;for(let l=0;l<o;l++)for(let c=0;c<o;c++)a.isReserved(c,l)||a.xor(c,l,s(i,c,l))},e.getBestMask=function(i,a){const o=Object.keys(e.Patterns).length;let l=0,c=1/0;for(let u=0;u<o;u++){a(u),e.applyMask(u,i);const h=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),h<c&&(c=h,l=u)}return l}})(L1);var fd={};const dr=dd,nc=[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],sc=[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];fd.getBlocksCount=function(t,s){switch(s){case dr.L:return nc[(t-1)*4+0];case dr.M:return nc[(t-1)*4+1];case dr.Q:return nc[(t-1)*4+2];case dr.H:return nc[(t-1)*4+3];default:return}};fd.getTotalCodewordsCount=function(t,s){switch(s){case dr.L:return sc[(t-1)*4+0];case dr.M:return sc[(t-1)*4+1];case dr.Q:return sc[(t-1)*4+2];case dr.H:return sc[(t-1)*4+3];default:return}};var F1={},hd={};const mo=new Uint8Array(512),yu=new Uint8Array(256);(function(){let t=1;for(let s=0;s<255;s++)mo[s]=t,yu[t]=s,t<<=1,t&256&&(t^=285);for(let s=255;s<512;s++)mo[s]=mo[s-255]})();hd.log=function(t){if(t<1)throw new Error("log("+t+")");return yu[t]};hd.exp=function(t){return mo[t]};hd.mul=function(t,s){return t===0||s===0?0:mo[yu[t]+yu[s]]};(function(e){const t=hd;e.mul=function(r,i){const a=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let l=0;l<i.length;l++)a[o+l]^=t.mul(r[o],i[l]);return a},e.mod=function(r,i){let a=new Uint8Array(r);for(;a.length-i.length>=0;){const o=a[0];for(let c=0;c<i.length;c++)a[c]^=t.mul(i[c],o);let l=0;for(;l<a.length&&a[l]===0;)l++;a=a.slice(l)}return a},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let a=0;a<r;a++)i=e.mul(i,new Uint8Array([1,t.exp(a)]));return i}})(F1);const U1=F1;function Yg(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Yg.prototype.initialize=function(t){this.degree=t,this.genPoly=U1.generateECPolynomial(this.degree)};Yg.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const s=new Uint8Array(t.length+this.degree);s.set(t);const r=U1.mod(s,this.genPoly),i=this.degree-r.length;if(i>0){const a=new Uint8Array(this.degree);return a.set(r,i),a}return r};var J6=Yg,B1={},Dr={},qg={};qg.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var Is={};const z1="[0-9]+",Z6="[A-Z $%*+\\-./:]+";let Qo="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Qo=Qo.replace(/u/g,"\\u");const eB="(?:(?![A-Z0-9 $%*+\\-./:]|"+Qo+`)(?:.|[\r
118
+ ]))+`;Is.KANJI=new RegExp(Qo,"g");Is.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Is.BYTE=new RegExp(eB,"g");Is.NUMERIC=new RegExp(z1,"g");Is.ALPHANUMERIC=new RegExp(Z6,"g");const tB=new RegExp("^"+Qo+"$"),nB=new RegExp("^"+z1+"$"),sB=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Is.testKanji=function(t){return tB.test(t)};Is.testNumeric=function(t){return nB.test(t)};Is.testAlphanumeric=function(t){return sB.test(t)};(function(e){const t=qg,s=Is;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,o){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?a.ccBits[0]:o<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return s.testNumeric(a)?e.NUMERIC:s.testAlphanumeric(a)?e.ALPHANUMERIC:s.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(a,o){if(e.isValid(a))return a;try{return r(a)}catch{return o}}})(Dr);(function(e){const t=On,s=fd,r=dd,i=Dr,a=qg,o=7973,l=t.getBCHDigit(o);function c(p,m,j){for(let w=1;w<=40;w++)if(m<=e.getCapacity(w,j,p))return w}function u(p,m){return i.getCharCountIndicator(p,m)+4}function h(p,m){let j=0;return p.forEach(function(w){const b=u(w.mode,m);j+=b+w.getBitsLength()}),j}function f(p,m){for(let j=1;j<=40;j++)if(h(p,j)<=e.getCapacity(j,m,i.MIXED))return j}e.from=function(m,j){return a.isValid(m)?parseInt(m,10):j},e.getCapacity=function(m,j,w){if(!a.isValid(m))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=i.BYTE);const b=t.getSymbolTotalCodewords(m),v=s.getTotalCodewordsCount(m,j),x=(b-v)*8;if(w===i.MIXED)return x;const y=x-u(w,m);switch(w){case i.NUMERIC:return Math.floor(y/10*3);case i.ALPHANUMERIC:return Math.floor(y/11*2);case i.KANJI:return Math.floor(y/13);case i.BYTE:default:return Math.floor(y/8)}},e.getBestVersionForData=function(m,j){let w;const b=r.from(j,r.M);if(Array.isArray(m)){if(m.length>1)return f(m,b);if(m.length===0)return 1;w=m[0]}else w=m;return c(w.mode,w.getLength(),b)},e.getEncodedBits=function(m){if(!a.isValid(m)||m<7)throw new Error("Invalid QR Code version");let j=m<<12;for(;t.getBCHDigit(j)-l>=0;)j^=o<<t.getBCHDigit(j)-l;return m<<12|j}})(B1);var W1={};const $p=On,H1=1335,rB=21522,Ey=$p.getBCHDigit(H1);W1.getEncodedBits=function(t,s){const r=t.bit<<3|s;let i=r<<10;for(;$p.getBCHDigit(i)-Ey>=0;)i^=H1<<$p.getBCHDigit(i)-Ey;return(r<<10|i)^rB};var V1={};const iB=Dr;function ma(e){this.mode=iB.NUMERIC,this.data=e.toString()}ma.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};ma.prototype.getLength=function(){return this.data.length};ma.prototype.getBitsLength=function(){return ma.getBitsLength(this.data.length)};ma.prototype.write=function(t){let s,r,i;for(s=0;s+3<=this.data.length;s+=3)r=this.data.substr(s,3),i=parseInt(r,10),t.put(i,10);const a=this.data.length-s;a>0&&(r=this.data.substr(s),i=parseInt(r,10),t.put(i,a*3+1))};var aB=ma;const oB=Dr,Pf=["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 ga(e){this.mode=oB.ALPHANUMERIC,this.data=e}ga.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};ga.prototype.getLength=function(){return this.data.length};ga.prototype.getBitsLength=function(){return ga.getBitsLength(this.data.length)};ga.prototype.write=function(t){let s;for(s=0;s+2<=this.data.length;s+=2){let r=Pf.indexOf(this.data[s])*45;r+=Pf.indexOf(this.data[s+1]),t.put(r,11)}this.data.length%2&&t.put(Pf.indexOf(this.data[s]),6)};var lB=ga;const cB=Dr;function xa(e){this.mode=cB.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}xa.getBitsLength=function(t){return t*8};xa.prototype.getLength=function(){return this.data.length};xa.prototype.getBitsLength=function(){return xa.getBitsLength(this.data.length)};xa.prototype.write=function(e){for(let t=0,s=this.data.length;t<s;t++)e.put(this.data[t],8)};var uB=xa;const dB=Dr,fB=On;function va(e){this.mode=dB.KANJI,this.data=e}va.getBitsLength=function(t){return t*13};va.prototype.getLength=function(){return this.data.length};va.prototype.getBitsLength=function(){return va.getBitsLength(this.data.length)};va.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let s=fB.toSJIS(this.data[t]);if(s>=33088&&s<=40956)s-=33088;else if(s>=57408&&s<=60351)s-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
119
+ Make sure your charset is UTF-8`);s=(s>>>8&255)*192+(s&255),e.put(s,13)}};var hB=va,K1={exports:{}};(function(e){var t={single_source_shortest_paths:function(s,r,i){var a={},o={};o[r]=0;var l=t.PriorityQueue.make();l.push(r,0);for(var c,u,h,f,p,m,j,w,b;!l.empty();){c=l.pop(),u=c.value,f=c.cost,p=s[u]||{};for(h in p)p.hasOwnProperty(h)&&(m=p[h],j=f+m,w=o[h],b=typeof o[h]>"u",(b||w>j)&&(o[h]=j,l.push(h,j),a[h]=u))}if(typeof i<"u"&&typeof o[i]>"u"){var v=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(v)}return a},extract_shortest_path_from_predecessor_list:function(s,r){for(var i=[],a=r;a;)i.push(a),s[a],a=s[a];return i.reverse(),i},find_path:function(s,r,i){var a=t.single_source_shortest_paths(s,r,i);return t.extract_shortest_path_from_predecessor_list(a,i)},PriorityQueue:{make:function(s){var r=t.PriorityQueue,i={},a;s=s||{};for(a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);return i.queue=[],i.sorter=s.sorter||r.default_sorter,i},default_sorter:function(s,r){return s.cost-r.cost},push:function(s,r){var i={value:s,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(K1);var pB=K1.exports;(function(e){const t=Dr,s=aB,r=lB,i=uB,a=hB,o=Is,l=On,c=pB;function u(v){return unescape(encodeURIComponent(v)).length}function h(v,x,y){const g=[];let N;for(;(N=v.exec(y))!==null;)g.push({data:N[0],index:N.index,mode:x,length:N[0].length});return g}function f(v){const x=h(o.NUMERIC,t.NUMERIC,v),y=h(o.ALPHANUMERIC,t.ALPHANUMERIC,v);let g,N;return l.isKanjiModeEnabled()?(g=h(o.BYTE,t.BYTE,v),N=h(o.KANJI,t.KANJI,v)):(g=h(o.BYTE_KANJI,t.BYTE,v),N=[]),x.concat(y,g,N).sort(function(S,C){return S.index-C.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function p(v,x){switch(x){case t.NUMERIC:return s.getBitsLength(v);case t.ALPHANUMERIC:return r.getBitsLength(v);case t.KANJI:return a.getBitsLength(v);case t.BYTE:return i.getBitsLength(v)}}function m(v){return v.reduce(function(x,y){const g=x.length-1>=0?x[x.length-1]:null;return g&&g.mode===y.mode?(x[x.length-1].data+=y.data,x):(x.push(y),x)},[])}function j(v){const x=[];for(let y=0;y<v.length;y++){const g=v[y];switch(g.mode){case t.NUMERIC:x.push([g,{data:g.data,mode:t.ALPHANUMERIC,length:g.length},{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.ALPHANUMERIC:x.push([g,{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.KANJI:x.push([g,{data:g.data,mode:t.BYTE,length:u(g.data)}]);break;case t.BYTE:x.push([{data:g.data,mode:t.BYTE,length:u(g.data)}])}}return x}function w(v,x){const y={},g={start:{}};let N=["start"];for(let k=0;k<v.length;k++){const S=v[k],C=[];for(let R=0;R<S.length;R++){const E=S[R],P=""+k+R;C.push(P),y[P]={node:E,lastCount:0},g[P]={};for(let O=0;O<N.length;O++){const U=N[O];y[U]&&y[U].node.mode===E.mode?(g[U][P]=p(y[U].lastCount+E.length,E.mode)-p(y[U].lastCount,E.mode),y[U].lastCount+=E.length):(y[U]&&(y[U].lastCount=E.length),g[U][P]=p(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,x))}}N=C}for(let k=0;k<N.length;k++)g[N[k]].end=0;return{map:g,table:y}}function b(v,x){let y;const g=t.getBestModeForData(v);if(y=t.from(x,g),y!==t.BYTE&&y.bit<g.bit)throw new Error('"'+v+'" cannot be encoded with mode '+t.toString(y)+`.
120
+ Suggested mode is: `+t.toString(g));switch(y===t.KANJI&&!l.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new s(v);case t.ALPHANUMERIC:return new r(v);case t.KANJI:return new a(v);case t.BYTE:return new i(v)}}e.fromArray=function(x){return x.reduce(function(y,g){return typeof g=="string"?y.push(b(g,null)):g.data&&y.push(b(g.data,g.mode)),y},[])},e.fromString=function(x,y){const g=f(x,l.isKanjiModeEnabled()),N=j(g),k=w(N,y),S=c.find_path(k.map,"start","end"),C=[];for(let R=1;R<S.length-1;R++)C.push(k.table[S[R]].node);return e.fromArray(m(C))},e.rawSplit=function(x){return e.fromArray(f(x,l.isKanjiModeEnabled()))}})(V1);const pd=On,Mf=dd,mB=q6,gB=Q6,xB=_1,vB=D1,Op=L1,_p=fd,jB=J6,wu=B1,yB=W1,wB=Dr,$f=V1;function bB(e,t){const s=e.size,r=vB.getPositions(t);for(let i=0;i<r.length;i++){const a=r[i][0],o=r[i][1];for(let l=-1;l<=7;l++)if(!(a+l<=-1||s<=a+l))for(let c=-1;c<=7;c++)o+c<=-1||s<=o+c||(l>=0&&l<=6&&(c===0||c===6)||c>=0&&c<=6&&(l===0||l===6)||l>=2&&l<=4&&c>=2&&c<=4?e.set(a+l,o+c,!0,!0):e.set(a+l,o+c,!1,!0))}}function kB(e){const t=e.size;for(let s=8;s<t-8;s++){const r=s%2===0;e.set(s,6,r,!0),e.set(6,s,r,!0)}}function SB(e,t){const s=xB.getPositions(t);for(let r=0;r<s.length;r++){const i=s[r][0],a=s[r][1];for(let o=-2;o<=2;o++)for(let l=-2;l<=2;l++)o===-2||o===2||l===-2||l===2||o===0&&l===0?e.set(i+o,a+l,!0,!0):e.set(i+o,a+l,!1,!0)}}function NB(e,t){const s=e.size,r=wu.getEncodedBits(t);let i,a,o;for(let l=0;l<18;l++)i=Math.floor(l/3),a=l%3+s-8-3,o=(r>>l&1)===1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function Of(e,t,s){const r=e.size,i=yB.getEncodedBits(t,s);let a,o;for(a=0;a<15;a++)o=(i>>a&1)===1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function CB(e,t){const s=e.size;let r=-1,i=s-1,a=7,o=0;for(let l=s-1;l>0;l-=2)for(l===6&&l--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,l-c)){let u=!1;o<t.length&&(u=(t[o]>>>a&1)===1),e.set(i,l-c,u),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||s<=i){i-=r,r=-r;break}}}function EB(e,t,s){const r=new mB;s.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),wB.getCharCountIndicator(c.mode,e)),c.write(r)});const i=pd.getSymbolTotalCodewords(e),a=_p.getTotalCodewordsCount(e,t),o=(i-a)*8;for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const l=(o-r.getLengthInBits())/8;for(let c=0;c<l;c++)r.put(c%2?17:236,8);return AB(r,e,t)}function AB(e,t,s){const r=pd.getSymbolTotalCodewords(t),i=_p.getTotalCodewordsCount(t,s),a=r-i,o=_p.getBlocksCount(t,s),l=r%o,c=o-l,u=Math.floor(r/o),h=Math.floor(a/o),f=h+1,p=u-h,m=new jB(p);let j=0;const w=new Array(o),b=new Array(o);let v=0;const x=new Uint8Array(e.buffer);for(let S=0;S<o;S++){const C=S<c?h:f;w[S]=x.slice(j,j+C),b[S]=m.encode(w[S]),j+=C,v=Math.max(v,C)}const y=new Uint8Array(r);let g=0,N,k;for(N=0;N<v;N++)for(k=0;k<o;k++)N<w[k].length&&(y[g++]=w[k][N]);for(N=0;N<p;N++)for(k=0;k<o;k++)y[g++]=b[k][N];return y}function TB(e,t,s,r){let i;if(Array.isArray(e))i=$f.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const h=$f.rawSplit(e);u=wu.getBestVersionForData(h,s)}i=$f.fromString(e,u||40)}else throw new Error("Invalid data");const a=wu.getBestVersionForData(i,s);if(!a)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=a;else if(t<a)throw new Error(`
121
+ The chosen QR Code version cannot contain this amount of data.
122
+ Minimum version required to store current data is: `+a+`.
123
+ `);const o=EB(t,s,i),l=pd.getSymbolSize(t),c=new gB(l);return bB(c,t),kB(c),SB(c,t),Of(c,s,0),t>=7&&NB(c,t),CB(c,o),isNaN(r)&&(r=Op.getBestMask(c,Of.bind(null,c,s))),Op.applyMask(r,c),Of(c,s,r),{modules:c,version:t,errorCorrectionLevel:s,maskPattern:r,segments:i}}$1.create=function(t,s){if(typeof t>"u"||t==="")throw new Error("No input text");let r=Mf.M,i,a;return typeof s<"u"&&(r=Mf.from(s.errorCorrectionLevel,Mf.M),i=wu.from(s.version),a=Op.from(s.maskPattern),s.toSJISFunc&&pd.setToSJISFunction(s.toSJISFunc)),TB(t,i,r,a)};var G1={},Qg={};(function(e){function t(s){if(typeof s=="number"&&(s=s.toString()),typeof s!="string")throw new Error("Color should be defined as hex string");let r=s.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+s);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(a){return[a,a]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,a=r.width&&r.width>=21?r.width:void 0,o=r.scale||4;return{width:a,scale:a?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 a=e.getScale(r,i);return Math.floor((r+i.margin*2)*a)},e.qrToImageData=function(r,i,a){const o=i.modules.size,l=i.modules.data,c=e.getScale(o,a),u=Math.floor((o+a.margin*2)*c),h=a.margin*c,f=[a.color.light,a.color.dark];for(let p=0;p<u;p++)for(let m=0;m<u;m++){let j=(p*u+m)*4,w=a.color.light;if(p>=h&&m>=h&&p<u-h&&m<u-h){const b=Math.floor((p-h)/c),v=Math.floor((m-h)/c);w=f[l[b*o+v]?1:0]}r[j++]=w.r,r[j++]=w.g,r[j++]=w.b,r[j]=w.a}}})(Qg);(function(e){const t=Qg;function s(i,a,o){i.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=o,a.width=o,a.style.height=o+"px",a.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(a,o,l){let c=l,u=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(u=r()),c=t.getOptions(c);const h=t.getImageWidth(a.modules.size,c),f=u.getContext("2d"),p=f.createImageData(h,h);return t.qrToImageData(p.data,a,c),s(f,u,h),f.putImageData(p,0,0),u},e.renderToDataURL=function(a,o,l){let c=l;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const u=e.render(a,o,c),h=c.type||"image/png",f=c.rendererOpts||{};return u.toDataURL(h,f.quality)}})(G1);var Y1={};const RB=Qg;function Ay(e,t){const s=e.a/255,r=t+'="'+e.hex+'"';return s<1?r+" "+t+'-opacity="'+s.toFixed(2).slice(1)+'"':r}function _f(e,t,s){let r=e+t;return typeof s<"u"&&(r+=" "+s),r}function IB(e,t,s){let r="",i=0,a=!1,o=0;for(let l=0;l<e.length;l++){const c=Math.floor(l%t),u=Math.floor(l/t);!c&&!a&&(a=!0),e[l]?(o++,l>0&&c>0&&e[l-1]||(r+=a?_f("M",c+s,.5+u+s):_f("m",i,0),i=0,a=!1),c+1<t&&e[l+1]||(r+=_f("h",o),o=0)):i++}return r}Y1.render=function(t,s,r){const i=RB.getOptions(s),a=t.modules.size,o=t.modules.data,l=a+i.margin*2,c=i.color.light.a?"<path "+Ay(i.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",u="<path "+Ay(i.color.dark,"stroke")+' d="'+IB(o,a,i.margin)+'"/>',h='viewBox="0 0 '+l+" "+l+'"',p='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+h+' shape-rendering="crispEdges">'+c+u+`</svg>
124
+ `;return typeof r=="function"&&r(null,p),p};const PB=G6,Dp=$1,q1=G1,MB=Y1;function Xg(e,t,s,r,i){const a=[].slice.call(arguments,1),o=a.length,l=typeof a[o-1]=="function";if(!l&&!PB())throw new Error("Callback required as last argument");if(l){if(o<2)throw new Error("Too few arguments provided");o===2?(i=s,s=t,t=r=void 0):o===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=s,s=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(s=t,t=r=void 0):o===2&&!t.getContext&&(r=s,s=t,t=void 0),new Promise(function(c,u){try{const h=Dp.create(s,r);c(e(h,t,r))}catch(h){u(h)}})}try{const c=Dp.create(s,r);i(null,e(c,t,r))}catch(c){i(c)}}ll.create=Dp.create;ll.toCanvas=Xg.bind(null,q1.render);ll.toDataURL=Xg.bind(null,q1.renderToDataURL);ll.toString=Xg.bind(null,function(e,t,s){return MB.render(e,s)});async function $B(e){const t=await ll.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const Ty=10*6e4,OB=2e3;function Q1(e,t){const[s,r]=d.useState(null),[i,a]=d.useState(null),[o,l]=d.useState(!1),[c,u]=d.useState(!1),h=d.useRef(e);h.current=e;const f=d.useRef(t);f.current=t;const p=d.useCallback(async()=>{const m=await A.telegramPairing();r(m),u(!1),l(!1),a(await $B(m.link).catch(()=>""))},[]);return d.useEffect(()=>{if(!s||o||c)return;let m=!1;const j=Math.min(Date.parse(s.expiresAt)||Date.now()+Ty,Date.now()+Ty),w=window.setInterval(()=>{if(Date.now()>=j){u(!0);return}h.current().then(b=>{var v;m||!b||(l(!0),(v=f.current)==null||v.call(f))}).catch(()=>{})},OB);return()=>{m=!0,window.clearInterval(w)}},[s,o,c]),{offer:s,square:i,paired:o,stale:c,ask:p}}function X1({offer:e,square:t,children:s}){return n.jsxs("div",{className:"meet-pair",children:[t?n.jsx("img",{className:"meet-qr",src:t,alt:e.link}):null,n.jsx("a",{className:"meet-link",href:e.link,target:"_blank",rel:"noreferrer",children:e.link}),s]})}const J1=new Set(["approval","question"]),rc={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 _B({timezone:e}){var w,b;const t=re(()=>A.notificationSettings(),[]),s=re(()=>A.notifications(20),[],3e4),[r,i]=d.useState(null),[a,o]=d.useState(!1),[l,c]=d.useState(!1),[u,h]=d.useState(null),f=((w=t.data)==null?void 0:w.channels)??[],p=r??((b=t.data)==null?void 0:b.settings),m=v=>{p&&(c(!1),i({...p,...v}))},j=()=>{p&&(o(!0),c(!1),h(null),A.saveNotificationSettings(p).then(()=>{c(!0),i(null),t.reload()}).catch(v=>h(v instanceof oe?v.message:String(v))).finally(()=>o(!1)))};return n.jsxs(V,{gap:"lg",children:[n.jsx(LB,{timezone:e,onChange:t.reload}),n.jsx(Y,{title:"Notifications",aside:"What buddi tells you when you are not looking at this page.",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:a||!p,onClick:j,children:"Save"}),children:n.jsxs(V,{divided:!0,children:[n.jsx(se,{message:t.error??u}),n.jsx(Y,{title:"Where buddi reaches you",children:p?f.length===0?n.jsx("p",{className:"ui-card-meta",children:"No channel yet, so everything waits for you here. Pair Telegram and buddi can reach you on your phone."}):n.jsx(V,{gap:"sm",children:f.map(v=>{var x;return n.jsx(BB,{channel:v,checked:(p.defaultChannel??((x=f[0])==null?void 0:x.kind))===v.kind,onPick:()=>m({defaultChannel:v.kind})},v.kind)})}):n.jsx(ue,{children:"Loading…"})}),n.jsx(Y,{title:"By kind",children:p?n.jsxs(V,{gap:"sm",children:[WI.map(v=>n.jsxs("div",{className:"pref-row nt-kind",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:rc[v].label}),n.jsx("span",{className:"ui-field-hint",children:rc[v].hint})]}),n.jsxs("select",{"aria-label":rc[v].label,value:zB(p,v,f),onChange:x=>{const y={...p.perKind};x.target.value==="default"?delete y[v]:y[v]=x.target.value,m({perKind:y})},children:[n.jsx("option",{value:"default",children:"Default"}),f.map(x=>n.jsx("option",{value:x.kind,children:x.label},x.kind)),J1.has(v)?null:n.jsx("option",{value:"off",children:"Off"})]})]},v)),n.jsx("p",{className:"ui-field-hint",children:"Off keeps it in the list below and never sends it."})]}):null}),n.jsx(Y,{title:"Quiet hours",children:p?n.jsxs(V,{gap:"sm",children:[n.jsxs("div",{className:"nt-times",children:[n.jsx(J,{label:"From",children:n.jsx("input",{type:"time",value:p.quietStart??"",onChange:v=>m({quietStart:v.target.value||null})})}),n.jsx(J,{label:"Until",children:n.jsx("input",{type:"time",value:p.quietEnd??"",onChange:v=>m({quietEnd:v.target.value||null})})}),n.jsx(J,{label:"End of the day",children:n.jsx("input",{type:"time",value:p.endOfDay,onChange:v=>m({endOfDay:v.target.value})})})]}),n.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}),l?n.jsx(W,{tone:"good",role:"status",children:"Saved."}):null]})}),n.jsx(DB,{}),n.jsxs(Y,{title:"The last twenty",panel:!0,flush:!0,children:[n.jsx(se,{message:s.error}),s.data?s.data.notifications.length===0?n.jsx(ue,{children:"Nothing yet. What buddi tells you will be listed here."}):n.jsx(Xt,{children:s.data.notifications.map(v=>n.jsx(cn,{title:v.title,sub:`${He(v.createdAt,e)} · ${rc[v.kind].label.toLowerCase()} · ${WB(v,f)}`,side:n.jsx(HB,{row:v})},v.id))}):n.jsx(ue,{children:"Loading…"})]})]})}function DB(){var u;const e=re(()=>A.tipsSettings(),[]),[t,s]=d.useState(!1),[r,i]=d.useState(null),[a,o]=d.useState(null),l=a??((u=e.data)==null?void 0:u.enabled)??!0,c=h=>{s(!0),i(null),o(h),A.saveTipsSettings(h).then(f=>o(f.enabled)).catch(f=>{o(!h),i(f instanceof oe?f.message:String(f))}).finally(()=>s(!1))};return n.jsx(Y,{title:"Tips",panel:!0,children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:e.error??r}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:l,disabled:t||!e.data,onChange:h=>c(h.target.checked)}),n.jsx("span",{children:"Tips on Home"})]}),n.jsx("p",{className:"ui-field-hint",children:"When something in buddi has gone unused, Home may say so in one sentence, at most once a day."})]})})}function LB({timezone:e,onChange:t}){var C,R;const s=re(()=>A.telegramBot(),[]),r=re(()=>A.telegramDevices(),[]),[i,a]=d.useState(!1),[o,l]=d.useState(""),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState(null),j=d.useRef(new Set),w=Q1(()=>A.telegramDevices().then(E=>E.devices.some(P=>!j.current.has(P.id))),()=>{r.reload(),t()}),b=((C=s.data)==null?void 0:C.configured)??!1,v=!b||i,x=()=>{var P;if(o.trim()===""||c)return;u(!0),f(null);const E=i&&(((P=s.data)==null?void 0:P.running)??!1);A.saveTelegramToken(o.trim()).then(O=>{l(""),a(!1),f(O.restartNeeded?{ok:!1,text:O.note??"Saved. It will be ready the next time buddi starts."}:E?{ok:!0,text:"Saved. The new bot takes over the next time buddi starts."}:{ok:!0,text:"Saved."}),s.reload(),t()}).catch(O=>f({ok:!1,text:O instanceof oe?O.message:String(O)})).finally(()=>u(!1))},y=()=>{var E;m(null),j.current=new Set((((E=r.data)==null?void 0:E.devices)??[]).map(P=>P.id)),w.ask().catch(P=>m(P instanceof oe?P.message:String(P)))},{offer:g,square:N,paired:k,stale:S}=w;return n.jsx(Y,{title:"Telegram",aside:"Talk to buddi from your phone.",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{title:"The bot",foot:v?n.jsxs(n.Fragment,{children:[i?n.jsx(I,{variant:"ghost",onClick:()=>{a(!1),l("")},children:"Cancel"}):null,n.jsx(I,{variant:"accent",disabled:c||o.trim()==="",onClick:x,children:"Save token"})]}):void 0,children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:s.error}),!s.data&&!s.error?n.jsx(ue,{children:"Loading…"}):b&&!i?n.jsxs("div",{className:"nt-channel",children:[n.jsx("span",{className:"pref-label",children:(R=s.data)!=null&&R.username?`Bot: @${s.data.username}`:"A bot token is saved."}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{a(!0),f(null)},children:"Replace token"})]}):null,v?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Ask @BotFather for a bot and paste its token here."}),n.jsx(J,{label:"Bot token",grow:!0,children:n.jsx("input",{type:"password",value:o,autoComplete:"off",spellCheck:!1,onChange:E=>l(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),x())}})})]}):null,h?n.jsx(W,{tone:h.ok?"good":"warning",role:"status",children:h.text}):null]})}),n.jsxs(Y,{title:"Your devices",children:[n.jsx(se,{message:r.error}),r.data?r.data.devices.length===0?n.jsx("p",{className:"ui-card-meta",children:"No phone is paired yet."}):n.jsx(Xt,{children:r.data.devices.map(E=>n.jsx(cn,{title:E.name??`Telegram user ${E.userId}`,sub:`Paired ${He(E.pairedAt,e)} · ${E.lastSeenAt?`last spoke ${_e(E.lastSeenAt)}`:"has not spoken yet"}`,side:n.jsx(FB,{id:E.id,onGone:()=>{r.reload(),t()}})},E.id))}):r.error?null:n.jsx(ue,{children:"Loading…"})]}),n.jsx(Y,{title:"Pair a device",foot:b&&(!g||k)?n.jsx(I,{variant:g?void 0:"accent",onClick:y,children:"Pair a phone"}):b&&S?n.jsx(I,{variant:"accent",onClick:y,children:"New code"}):void 0,children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:p}),b?k?n.jsx(W,{tone:"good",role:"status",children:"Paired."}):g&&S?n.jsx("p",{className:"ui-card-meta",children:"That code has run out."}):g?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Open this on your phone, then send /start to the bot."}),n.jsx(X1,{offer:g,square:N,children:n.jsx(UB,{text:g.link})}),n.jsxs("p",{className:"ui-field-hint",children:["The code works until ",He(g.expiresAt,e),"."]})]}):n.jsx("p",{className:"ui-card-meta",children:"Pair another phone, or the first one if you skipped it."}):n.jsx("p",{className:"ui-card-meta",children:"Save a bot token first."})]})})]})})}function FB({id:e,onGone:t}){const[s,r]=d.useState(!1),[i,a]=d.useState(!1),[o,l]=d.useState(null);if(!s)return n.jsx(I,{size:"sm",onClick:()=>r(!0),children:"Unpair"});const c=()=>{a(!0),l(null),A.unpairTelegramDevice(e).then(t).catch(u=>l(u instanceof oe?u.message:String(u))).finally(()=>a(!1))};return n.jsxs("span",{className:"nt-channel",children:[n.jsx("span",{className:"ui-field-hint",role:o?"alert":void 0,children:o??"It will no longer reach your agents."}),n.jsx(I,{size:"sm",variant:"ghost",disabled:i,onClick:()=>r(!1),children:"Keep"}),n.jsx(I,{size:"sm",variant:"danger",disabled:i,onClick:c,children:"Unpair"})]})}function UB({text:e}){const[t,s]=d.useState(null),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){s("Select the link to copy it.");return}navigator.clipboard.writeText(e).then(()=>s("Copied."),()=>s("Select the link to copy it."))};return n.jsxs("span",{className:"nt-channel",children:[n.jsx(I,{size:"sm",onClick:r,children:"Copy"}),t?n.jsx("span",{className:"ui-field-hint",role:"status",children:t}):null]})}function BB({channel:e,checked:t,onPick:s}){const[r,i]=d.useState(!1),[a,o]=d.useState(null),l=()=>{i(!0),o(null),A.testChannel(e.kind).then(()=>o({ok:!0,text:"Sent. Check that it arrived."})).catch(c=>o({ok:!1,text:c instanceof oe?c.message:String(c)})).finally(()=>i(!1))};return n.jsxs("div",{className:"nt-channel",children:[n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:"nt-default-channel",checked:t,onChange:s}),n.jsxs("span",{className:"nt-channel-text",children:[n.jsxs("span",{className:"pref-label",children:[e.label,e.where?`, ${e.where}`:""]}),n.jsxs("span",{className:"ui-field-hint",children:["The title and a few lines of each message go to ",e.label,"."]}),a?n.jsx("span",{className:"nt-channel-sent","data-tone":a.ok?void 0:"critical",role:"status",children:a.text}):null]})]}),n.jsx(I,{size:"sm",disabled:r,onClick:l,children:"Send a test"})]})}function zB(e,t,s){const r=e.perKind[t];return r==="off"?J1.has(t)?"default":"off":r&&s.some(i=>i.kind===r)?r:"default"}function WB(e,t){var s;return e.channel&&e.channel!=="dashboard"?((s=t.find(r=>r.kind===e.channel))==null?void 0:s.label)??e.channel:"dashboard"}function HB({row:e}){return e.state==="failed"?n.jsxs("span",{className:"nt-state","data-tone":"critical",children:["Failed: ",e.error??"no reason given"]}):e.actedAt?n.jsx("span",{className:"nt-state",children:"Acted on"}):e.seenAt?n.jsx("span",{className:"nt-state",children:"Seen"}):e.state==="held"?n.jsx("span",{className:"nt-state",children:"Waiting"}):e.state==="stored"?n.jsx("span",{className:"nt-state",children:"Kept"}):e.state==="sent"?n.jsx("span",{className:"nt-state",children:"Sent"}):n.jsx("span",{className:"nt-state",children:"Not seen"})}const VB={you:"person",appearance:"sun",notifications:"bell",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",connections:"globe",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function KB(e){const t=_M.map(r=>({id:r.id,route:Ze(r.id),label:r.label,icon:VB[r.id],group:r.group})),s=[...e].sort((r,i)=>r.title.localeCompare(i.title,void 0,{sensitivity:"base"})||r.plugin.localeCompare(i.plugin)||r.id.localeCompare(i.id)).map(r=>({id:Zk(r.plugin,r.id),route:Zu(r.plugin,r.id),label:r.title,icon:TN(r.icon),group:"plugins"}));return[...t,...s]}function Z1(e){return OM.map(t=>({id:t.id,label:t.label,entries:e.filter(s=>s.group===t.id)})).filter(t=>t.entries.length>0)}function eC(e,t,s){return t?`${e}, ${t} open`:s?`${e}, ${s}`:void 0}function GB({entries:e,active:t,counts:s={},dots:r={},navigate:i}){var u;const a=d.useRef(null),o=Z1(e),l=e.some(h=>h.id===t)?t:(u=e[0])==null?void 0:u.id,c=h=>{var j;const f=[...((j=a.current)==null?void 0:j.querySelectorAll("a.settings-nav-link"))??[]],p=f.indexOf(document.activeElement);if(p===-1)return;const m=w=>{var b;h.preventDefault(),(b=f[Math.max(0,Math.min(f.length-1,w))])==null||b.focus()};if(h.key==="ArrowDown")m(p+1);else if(h.key==="ArrowUp")m(p-1);else if(h.key==="Home")m(0);else if(h.key==="End")m(f.length-1);else if(h.key==="Enter"||h.key===" "){h.preventDefault();const w=f[p].getAttribute("href");w&&i(w)}};return n.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:a,onKeyDown:c,children:o.map(h=>n.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${h.id}`,children:[n.jsx("div",{className:"settings-nav-label",id:`settings-nav-${h.id}`,children:h.label}),h.entries.map(f=>{const p=f.id===t,m=s[f.id],j=r[f.id];return n.jsxs("a",{className:"settings-nav-link",href:f.route,"data-active":p?"true":void 0,"aria-current":p?"page":void 0,"aria-label":eC(f.label,m,j),tabIndex:f.id===l?0:-1,onClick:w=>{w.preventDefault(),i(f.route)},children:[n.jsx(Te,{name:f.icon,className:"settings-nav-icon"}),n.jsx("span",{className:"settings-nav-text",children:f.label}),m?n.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:m>99?"99+":m}):j?n.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","data-testid":"settings-nav-dot","aria-hidden":"true"}):null]},f.id)})]},h.id))})}function YB({entries:e,active:t,counts:s={},dots:r={},navigate:i}){const a=Z1(e),o=e.find(l=>l.id===t)??e[0];return n.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:n.jsxs(rg,{modal:!1,children:[n.jsx(ig,{asChild:!0,children:n.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(o==null?void 0:o.label)??""}`,children:[o?n.jsx(Te,{name:o.icon,className:"settings-nav-icon"}):null,n.jsx("span",{className:"settings-nav-text",children:o==null?void 0:o.label}),n.jsx(Te,{name:"chevron-down",className:"settings-menu-chevron"})]})}),n.jsx(ag,{children:n.jsx(og,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:n.jsx(X2,{value:t,onValueChange:l=>{const c=e.find(u=>u.id===l);c&&i(c.route)},children:a.map((l,c)=>n.jsxs(Q2,{children:[c>0?n.jsx(Nc,{className:"ui-menu-sep"}):null,n.jsx(lg,{className:"ui-menu-label",children:l.label}),l.entries.map(u=>{const h=s[u.id],f=r[u.id];return n.jsxs(J2,{value:u.id,className:"ui-menu-item settings-menu-item","data-active":u.id===t?"true":void 0,"aria-label":eC(u.label,h,f),children:[n.jsxs("span",{className:"settings-menu-entry",children:[n.jsx(Te,{name:u.icon,className:"settings-nav-icon"}),n.jsx("span",{className:"settings-nav-text",children:u.label})]}),h?n.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:h>99?"99+":h}):f?n.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","aria-hidden":"true"}):null]},u.id)})]},l.id))})})})]})})}function qB({hash:e,timezone:t,navigate:s,agents:r,pluginPages:i}){var x,y,g;const a=DM(e),o=NN(i!==void 0),l=i??o,c=IM(e),u=c?l.find(c.plugin,c.page):void 0,h=Yo(zg),f=KB(l.settings),m={proposals:((y=(x=re(()=>Promise.resolve().then(()=>A.proposals()),[],3e4).data)==null?void 0:x.open)==null?void 0:y.length)??0},j=re(()=>A.version(),[]),w=re(()=>Promise.resolve().then(()=>A.connectionSignals()),[],6e4),b={};j.data&&!j.data.checkout&&j.data.updateAvailable&&(b.system="a newer buddi is ready"),(((g=w.data)==null?void 0:g.signals)??[]).length>0&&(b.connections=RN);const v={entries:f,active:a,counts:m,dots:b,navigate:N=>s(N)};return n.jsxs("div",{className:"settings",children:[h?null:n.jsx(GB,{...v}),n.jsx("div",{className:"settings-body",children:n.jsxs("div",{className:"ui-page",children:[n.jsxs("header",{className:"ui-page-head",children:[n.jsx("h2",{className:"ui-page-title",children:"Settings"}),n.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),h?n.jsx(YB,{...v}):null,u?n.jsx(p4,{page:u,navigate:s,timezone:t,siblings:l.all.filter(N=>N.plugin===u.plugin)}):null,a==="you"?n.jsx(y6,{embedded:!0}):null,a==="appearance"?n.jsx(QB,{}):null,a==="notifications"?n.jsx(_B,{timezone:t}):null,a==="memory"?n.jsx(HN,{embedded:!0,agents:r,timezone:t}):null,a==="proposals"?n.jsx(C6,{embedded:!0,plugin:MM(e)}):null,a==="accounts"?n.jsx(RU,{embedded:!0}):null,a==="computer"?n.jsx(pL,{embedded:!0,timezone:t}):null,a==="secrets"?n.jsx(ZU,{embedded:!0,timezone:t}):null,a==="connections"?n.jsx(d6,{embedded:!0,timezone:t}):null,a==="watchers"?n.jsx(v6,{timezone:t,embedded:!0}):null,a==="backup"?n.jsx(bU,{}):null,a==="plugins"?n.jsx(F6,{}):null,a==="system"?n.jsx(XB,{timezone:t}):null]})})]})}function QB(){const[e,t]=_N();return n.jsx(Y,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:n.jsxs(V,{divided:!0,gap:"lg",children:[n.jsx(Df,{label:"Theme",hint:"System follows your Mac.",children:n.jsx(uo,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:e.theme,onChange:s=>t({theme:s})})}),n.jsx(Df,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:n.jsx(uo,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:e.ground,onChange:s=>t({ground:s})})}),n.jsx(Df,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:n.jsx(uo,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:e.width,onChange:s=>t({width:s})})})]})})}function Df({label:e,hint:t,children:s}){return n.jsxs("div",{className:"pref-row ui-section",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:e}),n.jsx("span",{className:"ui-field-hint",children:t})]}),s]})}function XB({timezone:e}){const t=re(()=>A.overview(),[],15e3),s=re(()=>A.session(),[]),r=re(()=>A.providerAccounts(),[]),i=t.data;return n.jsxs(V,{gap:"lg",children:[n.jsx(se,{message:t.error}),n.jsx(dz,{}),i?n.jsx(Y,{title:"The queue",panel:!0,actions:n.jsx(I,{size:"sm",variant:i.paused?"accent":void 0,onClick:()=>{A.setPaused(!i.paused).then(()=>t.reload())},children:i.paused?"Resume the queue":"Pause the queue"}),children:n.jsxs("p",{className:"ui-card-meta",children:[i.paused?"Paused. Nothing is being claimed until you resume.":"Running. Jobs are claimed as they come due."," ",i.paused?n.jsx(ye,{tone:"warning",children:"paused"}):n.jsx(ye,{tone:"good",children:"running"})]})}):null,n.jsxs(Y,{title:"This host",panel:!0,children:[n.jsx(Wt,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?He(i.now,e):"…"},{label:"Bound to",value:s.data?`${s.data.host}:${s.data.port}`:"…"},{label:"Credential vault",value:r.data?tz(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?n.jsx(W,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),n.jsx(ez,{}),n.jsx(JB,{}),n.jsx(Y,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?n.jsx(ue,{children:"No sources are installed."}):n.jsx(Wt,{items:i.mail.map(a=>({key:a.sourceId,label:n.jsx("span",{className:"mono",children:a.sourceId}),value:a.lastError?n.jsx("span",{className:"critical",children:a.lastError}):n.jsxs("span",{children:["polled ",_e(a.lastRunAt)]})}))}):n.jsx(ue,{children:"Loading…"})})]})}function JB(){var m;const e=re(()=>A.tailscale(),[]),[t,s]=d.useState(null),[r,i]=d.useState(!1),[a,o]=d.useState(null),[l,c]=d.useState(!1),u=e.data,h=t??((u==null?void 0:u.login)||((m=u==null?void 0:u.self)==null?void 0:m.login)||""),f=(u==null?void 0:u.proxied)===!0,p=j=>{i(!0),o(null),c(!1),A.setTailscale({enabled:j,login:h.trim()}).then(()=>{c(!0)}).catch(w=>o(w instanceof oe?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return n.jsx(Y,{title:"Sign in through Tailscale",panel:!0,foot:n.jsx(I,{variant:"accent",disabled:r||!u||f,onClick:()=>p((u==null?void 0:u.enabled)??!1),children:"Save"}),children:n.jsx(V,{divided:!0,children:n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:e.error??a}),n.jsx("p",{className:"ui-card-meta",children:u?u.available&&u.self?`Tailscale is running on this machine as ${u.self.login}.`:u.available?"Tailscale is running on this machine.":"Tailscale is not running here.":"…"}),f?n.jsxs(n.Fragment,{children:[n.jsx(W,{tone:"warning",children:"Change this from the computer buddi runs on."}),n.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${h}`:"Off"})]}):null,n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||f,onChange:j=>p(j.target.checked)}),n.jsx("span",{children:"Let this Tailscale login sign in"})]}),n.jsx(J,{label:"Tailscale login",children:n.jsx("input",{type:"text",value:h,placeholder:"you@example.com",disabled:r||!u||f,onChange:j=>s(j.target.value)})}),n.jsx("p",{className:"ui-card-meta",children:"Anyone signed in to Tailscale as this login, on any device in your tailnet, is signed in to buddi. The proxy must run on this machine:"}),n.jsxs("div",{className:"tailscale-command",children:[n.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),n.jsx(I,{size:"sm",disabled:r||!u,onClick:()=>{ZB((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),n.jsx("p",{className:"ui-card-meta",children:"This gives your tailnet the trust this machine already has: buddi cannot tell the Tailscale proxy from another program running here, and any program that can reach the dashboard on this machine can already read buddi’s files."}),l?n.jsx(W,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function ZB(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function ez(){var u;const e=re(()=>A.service(),[],1e4),[t,s]=d.useState(null),[r,i]=d.useState(!1),[a,o]=d.useState(null),l=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!l)return null;const c=h=>{i(!0),o(null),A.serviceAction(h).then(()=>{s(null)}).catch(f=>{o(f.message)}).finally(()=>{i(!1),e.reload()})};return n.jsx(Y,{title:"Service",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsx(Wt,{items:[{label:"Database",value:n.jsx(Ry,{state:l.database,pid:l.databasePid})},{label:"Gateway",value:n.jsx(Ry,{state:l.gateway,pid:l.gatewayPid})},{label:"Supervisor",value:n.jsxs("span",{className:"mono",children:["pid ",l.supervisorPid]})}]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:a}),t?n.jsx(W,{tone:"warning",role:"alert",children:t==="stop"?"Stopping the gateway closes this dashboard. The database keeps running; run buddi in a terminal to bring the dashboard back.":"Restarting the gateway closes this dashboard for a few seconds. If it does not come back on its own, run buddi in a terminal."}):n.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),n.jsx(Q,{align:"end",children:t?n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",disabled:r,onClick:()=>{s(null),o(null)},children:"Cancel"}),n.jsx(I,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>{s("stop")},children:"Stop gateway"}),n.jsx(I,{variant:"accent",onClick:()=>{s("restart")},children:"Restart gateway"})]})})]})})]})})}function Ry({state:e,pid:t}){return n.jsxs("span",{children:[n.jsx(ye,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?n.jsx("span",{className:"ui-card-meta",children:"no process"}):n.jsxs("span",{className:"mono",children:["pid ",t]})]})}function tz(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const nz=2e3,Iy={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."},sz=new Set(["done","failed","rolled-back"]),rz="The check asks the npm registry for the newest version and sends nothing else.",iz="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",az="A checkout upgrades with git pull, then buddi upgrade in a terminal.",oz=10*6e4,lz="buddi did not come back. Run buddi doctor in a terminal.";function cz(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 uz(e,t,s,r){const[i,a]=d.useState(void 0),[o,l]=d.useState(!1),[c,u]=d.useState(null),h=d.useRef(!1),f=d.useRef(s),p=d.useRef(r);return f.current=s,p.current=r,d.useEffect(()=>{if(!e){a(void 0),l(!1),h.current=!1;return}let m=!1,j=0;const w=()=>{h.current=!0,j=Date.now()+oz,l(!0)},b=()=>{if(Date.now()<j){A.session().then(y=>{m||y.version!==void 0&&y.version===t||(m=!0,f.current())}).catch(()=>{}),A.version().then(y=>{const g=y.history[y.history.length-1];m||(g==null?void 0:g.outcome)!=="failed"||(m=!0,l(!1),u(cz(g)))}).catch(()=>{});return}m=!0,l(!1),u(lz)},v=()=>{if(!m){if(h.current)return b();A.upgradeJob(e).then(y=>{var g;m||(a(y),u(null),(sz.has(y.phase)||y.finishedAt)&&(m=!0,y.phase==="failed"&&((g=p.current)==null||g.call(p,y))))}).catch(y=>{m||(y instanceof oe&&y.status!==0&&y.status<500?u(y.message):w())})}};v();const x=window.setInterval(v,nz);return()=>{m=!0,window.clearInterval(x)}},[e,t]),{job:i,away:o,error:c}}function dz({reload:e}){var g;const t=re(()=>A.version(),[]),[s,r]=d.useState(null),[i,a]=d.useState(!1),[o,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),p=(g=t.data)==null?void 0:g.current,m=e??(()=>window.location.reload()),j=d.useCallback(N=>{r(null),f(N)},[]),w=uz(s,p,m,j),b=t.data,v=()=>{l(!0),u(null),A.checkVersion().catch(N=>u(N instanceof oe?N.message:String(N))).finally(()=>{l(!1),t.reload()})},x=N=>{l(!0),u(null),A.setVersionCheck(N).catch(k=>u(k instanceof oe?k.message:String(k))).finally(()=>{l(!1),t.reload()})},y=()=>{l(!0),u(null),f(null),A.startUpgrade(b==null?void 0:b.latest).then(N=>{var k;a(!1),r(((k=N.job)==null?void 0:k.id)??null)}).catch(N=>u(N instanceof oe?N.message:String(N))).finally(()=>l(!1))};return b!=null&&b.checkout?n.jsx(Y,{title:"Version",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsx(Wt,{items:[{label:"Running",value:n.jsx("span",{className:"mono",children:b.current})}]})}),n.jsx(Y,{children:n.jsx("p",{className:"ui-card-meta",children:az})})]})}):n.jsx(Y,{title:"Version",panel:!0,children:n.jsxs(V,{divided:!0,children:[n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(se,{message:t.error??c}),n.jsx(Wt,{items:[{label:"Running",value:b?n.jsx("span",{className:"mono",children:b.current}):"…"},{label:"Newest",value:b?b.updateAvailable&&b.latest?n.jsxs("span",{children:["A newer buddi is available: ",n.jsx("span",{className:"mono",children:b.latest})]}):b.checkedAt?n.jsxs("span",{children:["This is the latest, as of ",_e(b.checkedAt),"."]}):n.jsx("span",{children:"Not checked yet."}):"…"}]}),b!=null&&b.error?n.jsxs(W,{tone:"warning",children:["The last check did not get an answer: ",b.error]}):null,n.jsx(Q,{align:"end",children:n.jsx(I,{disabled:o,onClick:v,children:"Check now"})})]})}),n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:(b==null?void 0:b.checkEnabled)??!1,disabled:o||!b,onChange:N=>x(N.target.checked)}),n.jsx("span",{children:"Check once a day"})]}),n.jsx("p",{className:"ui-card-meta",children:rz})]})}),b!=null&&b.updateAvailable&&b.latest&&b.latestNotes?n.jsx(Y,{title:`What changes in ${b.latest}`,children:n.jsx(Qs,{text:b.latestNotes})}):null,n.jsx(Y,{children:n.jsxs(V,{gap:"sm",children:[n.jsx(fz,{...w,job:w.job??h??void 0}),i?n.jsx(W,{tone:"warning",role:"alert",children:iz}):null,n.jsx(Q,{align:"end",children:i?n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",disabled:o,onClick:()=>a(!1),children:"Cancel"}),n.jsxs(I,{variant:"accent",disabled:o,onClick:y,children:["Upgrade to ",b==null?void 0:b.latest]})]}):n.jsx(I,{variant:"accent",disabled:o||s!==null||!(b!=null&&b.updateAvailable),onClick:()=>a(!0),children:b!=null&&b.updateAvailable&&b.latest?`Upgrade to ${b.latest}`:"Upgrade"})})]})}),b&&b.history.length>0?n.jsx(Y,{title:"Upgrades so far",children:n.jsx(Wt,{items:b.history.slice().reverse().map(N=>({key:N.startedAt,label:n.jsxs("span",{className:"mono",children:[N.from," → ",N.to]}),value:n.jsx(hz,{attempt:N})}))})}):null]})})}function fz({job:e,away:t,error:s}){return s?n.jsx(se,{message:s}):t?n.jsx(W,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="failed"?n.jsxs(W,{tone:"critical",role:"alert",children:[Iy.failed," ",e.error??""," buddi is still running on the version it had."]}):n.jsx(W,{tone:e.phase==="done"?"good":void 0,role:"status",children:Iy[e.phase]??e.detail??e.phase}):null}function hz({attempt:e}){return n.jsxs("span",{children:[n.jsx(ye,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",_e(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?n.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",n.jsx("span",{className:"mono",children:e.backup})]}):null]})}const Lp=["name","clock","brain","browser","assistant","handover"],tC={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function nC(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function pz(e){var a,o,l;const t=nC(e.accounts),s=e.assistant?(((a=e.accounts)==null?void 0:a.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(s==null?void 0:s.accountId)??((l=(o=e.onboarding)==null?void 0:o.details)==null?void 0:l.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(s==null?void 0:s.model)??i.defaultModel}}function sC(e){var r,i,a;const t=pz(e),s=e.onboarding&&!e.onboarding.needs.agent?e.assistant:void 0;return{...(r=e.owner)!=null&&r.preferredName?{name:e.owner.preferredName}:{},...(i=e.owner)!=null&&i.timezone?{clock:e.owner.timezone}:{},...t?{brain:t}:{},...(a=e.onboarding)!=null&&a.stepsDone.includes("browser")||s?{browser:e.browser??"other"}:{},...s?{assistant:s}:{}}}function mz(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 Ic(e){return Lp.find(t=>!mz(e,t))??"handover"}function gz(e,t){const s=Lp.indexOf(t);return Lp.filter((r,i)=>i<s||r===t)}function xz(e,t){const s={...e};return delete s[t],s}const Fp="buddi.firstRun.restore";function Lf(e){try{e===null?window.sessionStorage.removeItem(Fp):window.sessionStorage.setItem(Fp,e)}catch{}}function rC(){try{return window.sessionStorage.getItem(Fp)}catch{return null}}function vz(e){const t=sC(e),s=Ic(t);return{answers:t,open:s,stay:s!=="handover"}}function jz(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function yz(e){const t=e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,20).replace(/-+$/,"");return t===""?"assistant":t}const wz=550,bz=6e4,kz=5*6e4,iC=1500,Sz=3e3;function Pa(){const e=d.useRef(null);return d.useEffect(()=>{let t=0,s=0;const r=o=>{const l=o.ownerDocument.activeElement;return l===null||l===o.ownerDocument.body||l===o.ownerDocument.documentElement},i=()=>{const o=e.current;o&&r(o)&&o.focus()},a=()=>{i(),s=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(a):a(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(s),window.removeEventListener("focus",i)}},[]),e}function aC(){const[e,t]=d.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}});return d.useEffect(()=>{var i;let s;try{s=window.matchMedia("(prefers-reduced-motion: reduce)")}catch{return}const r=a=>t(a.matches);return(i=s.addEventListener)==null||i.call(s,"change",r),()=>{var a;return(a=s.removeEventListener)==null?void 0:a.call(s,"change",r)}},[]),e}function Fe({children:e,at:t=0}){const s=aC(),[r,i]=d.useState(s||t===0);return d.useEffect(()=>{if(s){i(!0);return}const a=window.setTimeout(()=>i(!0),wz*t);return()=>window.clearTimeout(a)},[s,t]),r?n.jsx("div",{className:"wb-msg","data-role":"assistant",children:n.jsx("div",{className:"wb-bubble",children:e})}):n.jsx(rs,{})}function rs({line:e}){const{report:t}=d.useContext(Jg);return d.useEffect(()=>(t(!0),()=>t(!1)),[t]),n.jsx("div",{className:"wb-msg","data-role":"assistant",children:n.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[e,n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]})})}const Jg=d.createContext({busy:0,report:()=>{}});function Nz({children:e}){const[t,s]=d.useState(0),r=d.useCallback(a=>s(o=>Math.max(0,o+(a?1:-1))),[]),i=d.useMemo(()=>({busy:t,report:r}),[t,r]);return n.jsx(Jg.Provider,{value:i,children:e})}function Me({children:e}){const{busy:t}=d.useContext(Jg),s=d.useRef(null),[r,i]=d.useState(!1);return d.useEffect(()=>{const a=s.current,o=a==null?void 0:a.closest(".meet-thread");if(t===0||!a||!o){i(!1);return}const l=[...o.querySelectorAll(".meet-turn > .wb-msg-who")].filter(c=>getComputedStyle(c).display!=="none");i(l.at(-1)===a)},[t]),n.jsxs("div",{className:"meet-turn",children:[n.jsxs("div",{className:"wb-msg-who",ref:s,children:[n.jsx(sd,{state:r?"working":"idle",size:"sm",className:"meet-turn-mark"}),n.jsx("span",{children:"buddi"})]}),e]})}const oC=d.createContext({body:null,actions:null});function lC({children:e,actions:t}){const s=d.useContext(oC),r=e==null?null:s.body?da.createPortal(e,s.body):e,i=t==null?null:s.actions?da.createPortal(t,s.actions):t;return n.jsxs(n.Fragment,{children:[r,i]})}function ic({text:e,onChange:t}){return n.jsxs("div",{className:"wb-msg","data-role":"user",children:[n.jsx("div",{className:"wb-bubble",children:e}),n.jsx("button",{type:"button",className:"meet-change",onClick:t,children:_.change})]})}function kt({children:e,actions:t}){return n.jsx(lC,{actions:t?n.jsx("span",{className:"meet-actions",children:t}):null,children:e?n.jsx("div",{className:"meet-ask",children:e}):null})}function Rr({onClick:e,disabled:t}){return n.jsxs(I,{variant:"ghost",onClick:e,disabled:t,children:[n.jsx(Te,{name:"chevron-left"}),_.brain.back]})}function Cz({navigate:e,timezone:t}){var it;const[s,r]=d.useState(void 0);d.useEffect(()=>{A.session().then(ke=>r(ke.platform)).catch(()=>{})},[]);const[i,a]=d.useState({}),[o,l]=d.useState(null),[c,u]=d.useState(void 0),[h,f]=d.useState(void 0),[p,m]=d.useState([]),[j,w]=d.useState(null),[b,v]=d.useState(null),[x,y]=d.useState(!1),[g,N]=d.useState(null),[k,S]=d.useState(null),[C,R]=d.useState(null),[E,P]=d.useState(null),O=d.useMemo(()=>({body:C,actions:E}),[C,E]),[U,T]=d.useState(null),[M,L]=d.useState(!1),K=d.useCallback(()=>L(!0),[]),[D,q]=d.useState(()=>rC()?"running":"idle"),[F,H]=d.useState({}),[le,ie]=d.useState([]),[ae,ge]=d.useState(0),X=d.useRef(void 0),de=d.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),me=d.useRef(e);me.current=e;const $e=d.useCallback(async(ke=!0,De=!1)=>{var Lr,z,ve,Ye,ht,tn,Ps,Lt;const[ee,Ce,B,Ee,St,nt]=await Promise.all([A.onboarding().catch(()=>{}),A.owner().catch(()=>{}),A.providerAccounts().catch(()=>{}),Le.agents().catch(()=>{}),A.browser().catch(()=>{}),A.providers().catch(()=>{})]);u(B);const Mt=(z=(Lr=nt==null?void 0:nt.providers.find(nn=>nn.kind==="anthropic"))==null?void 0:Lr.defaultModel)==null?void 0:z.trim();f(Mt||void 0),m((Ce==null?void 0:Ce.zones)??[]),N(((ve=ee==null?void 0:ee.details)==null?void 0:ve.conversationId)??null);const Ke=(Ee==null?void 0:Ee.agents.find(nn=>nn.id===Ee.defaultAgentId))??(Ee==null?void 0:Ee.agents[0]);Ke&&w(Ke),S(ee&&!ee.needs.agent&&Ke?{id:Ke.id,name:Ke.name,avatar:((Ye=Ke.avatar)==null?void 0:Ye.kind)==="emoji"?Ke.avatar.value:"",description:Ke.description,...Ke.picture?{picture:Ke.picture}:{}}:null);const jt={onboarding:ee,owner:Ce,accounts:B,browser:(ht=St==null?void 0:St.browser)==null?void 0:ht.engine,...Ke?{assistant:{id:Ke.id,name:Ke.name,avatar:((tn=Ke.avatar)==null?void 0:tn.kind)==="emoji"?Ke.avatar.value:""}}:{}},us=sC(jt);if(De){const nn=vz(jt);if(a(nn.answers),l(nn.open),!nn.stay){const ji=(Ps=ee==null?void 0:ee.details)==null?void 0:Ps.conversationId;me.current(ji&&Ke?Ve(Ke.id,ji):zt,!0)}return}if(ke&&(ee==null?void 0:ee.state)==="done"){const nn=(Lt=ee.details)==null?void 0:Lt.conversationId;me.current(nn&&Ke?Ve(Ke.id,nn):zt,!0);return}ke&&(a(us),l(nn=>nn??Ic(us)))},[]);d.useEffect(()=>{$e()},[$e]);const ne=(ke,De={})=>{A.onboardingStep(tC[ke],De).catch(()=>{})},be=ke=>{let De=ke;for(;;){const ee=Ic(De);if(ee==="brain"&&F.brain)De={...De,brain:F.brain};else if(ee==="browser"&&F.browser)De={...De,browser:F.browser};else return De}},Ne=(ke,De)=>{const ee=be(De);ee.brain&&(X.current=ee.brain),v(null),a(ee),ne(ke,ke==="brain"&&ee.brain?{accountId:ee.brain.accountId}:{}),l(Ic(ee))},Qe=ke=>{v(null),a(De=>xz(De,ke)),l(ke)},Ie=()=>{const ke=i.brain??X.current,De=i.browser;v(null),H({}),ie([]),a({}),l("name"),ge(ee=>ee+1),(async()=>{var Mt;const[ee,Ce,B]=await Promise.all([Promise.resolve().then(()=>A.providerAccounts()).catch(()=>{}),Promise.resolve().then(()=>A.telegram()).catch(()=>{}),Promise.resolve().then(()=>A.browser()).catch(()=>{})]),Ee=nC(ee),St=ke&&Ee.some(Ke=>Ke.id===ke.accountId)?ke:void 0,nt=De==="installed"||((Mt=B==null?void 0:B.browser)==null?void 0:Mt.engine)==="chromium"?"chromium":void 0;ee&&u(ee),H({...St?{brain:St}:{},...nt?{browser:nt}:{}}),ie([...new Set(Ee.map(Ke=>Ke.label)),...Ce!=null&&Ce.paired?[_.startOver.telegram]:[],...nt?[_.startOver.browser]:[]])})()},rt=D==="idle"&&!U&&!M&&o!==null&&(o!=="name"||Object.keys(i).length>0),fe=()=>{y(!0),A.skipOnboarding().then(()=>e(zt)).catch(ke=>v(ke instanceof oe?ke.message:String(ke))).finally(()=>y(!1))},xe=D==="form"||D==="running"?[]:o?gz(i,o):[],ze=re(()=>A.version().catch(()=>({current:""})),[]),Oe=d.useRef(null);return d.useEffect(()=>{const ke=Oe.current;if(!ke)return;const De=()=>{ke.scrollTop=ke.scrollHeight};De();let ee;try{ee=new ResizeObserver(De),ke.firstElementChild&&ee.observe(ke.firstElementChild)}catch{}return()=>ee==null?void 0:ee.disconnect()},[xe.length,o,i,b]),n.jsx(oC.Provider,{value:O,children:n.jsx("div",{className:"meet",children:n.jsxs("div",{className:"meet-stack",children:[n.jsxs("header",{className:"meet-head",children:[n.jsx("img",{className:"meet-head-mascot",src:_r("core"),alt:"","aria-hidden":"true"}),n.jsxs("span",{className:"meet-head-who",children:[n.jsx("span",{className:"meet-head-name",children:"buddi"}),n.jsx("span",{className:"meet-head-line",children:s===void 0||s==="darwin"?_.tagline:_.taglineElsewhere}),(it=ze.data)!=null&&it.current?n.jsxs("span",{className:"meet-head-version mono",children:["buddi ",ze.data.current]}):null]})]}),n.jsxs("div",{className:"meet-board",children:[n.jsx("div",{className:"meet-scroll thin-scroll",ref:Oe,children:n.jsx("div",{className:"meet-thread","data-testid":"meet-thread",children:n.jsxs(Nz,{children:[n.jsx(Me,{children:_.opening.map((ke,De)=>n.jsx(Fe,{at:De,children:ke},ke))}),n.jsx(Ez,{state:D,offered:o==="name"&&i.name===void 0,name:i.name,onState:q,onDone:()=>{q("idle"),$e(!0,!0)},onTrouble:v}),le.length>0?n.jsx(Me,{children:n.jsx(Fe,{children:_.startOver.said(le.join(", "))})}):null,xe.map(ke=>n.jsx(Az,{id:ke,openNow:o===ke,answers:i,accounts:c,claudeModel:h,zones:p,browserZone:de,assistantAgent:j,met:g,onMet:N,existing:k,navigate:e,onCarriesOn:T,onClosed:K,onSettled:De=>Ne(ke,De),onChange:()=>Qe(ke),onTrouble:v,onReload:()=>void $e(!1),onPickAnotherBrain:()=>Qe("brain")},`${ae}-${ke}`)),b?n.jsx(Me,{children:n.jsx(Fe,{children:b})}):null]})})}),n.jsxs("footer",{className:"meet-dock",children:[n.jsx("div",{className:"meet-dock-ask",ref:R}),n.jsxs("div",{className:"meet-dock-row",children:[M?n.jsx("span",{}):U?n.jsx("a",{className:"meet-later",href:U,onClick:ke=>{ke.preventDefault(),e(U,!0)},children:_.done.open}):n.jsxs("span",{className:"meet-quiet",children:[n.jsx("button",{className:"meet-later",type:"button",disabled:x,onClick:fe,children:_.later}),rt?n.jsx("button",{className:"meet-later",type:"button",disabled:x,onClick:Ie,children:_.startOver.link}):null]}),n.jsx("div",{className:"meet-dock-actions",ref:P})]})]})]})]})})})}function Ez({state:e,offered:t,name:s,onState:r,onDone:i,onTrouble:a}){const[o,l]=d.useState(()=>rC()),[c,u]=d.useState([]),[h,f]=d.useState(!1),[p,m]=d.useState(null),[j,w]=d.useState(""),[b,v]=d.useState(!1);d.useEffect(()=>{if(!o)return;let g=!1;const N=()=>{A.backupJob(o).then(S=>{g||(u(C=>C.includes(S.phase)?C:[...C,S.phase]),S.phase==="done"?(g=!0,Lf(null),f(!0),i()):(S.phase==="rolled-back"||S.phase==="failed")&&(g=!0,Lf(null),l(null),a(S.error??_.restore.phases[S.phase]),r("idle")))}).catch(()=>{})};N();const k=window.setInterval(N,iC);return()=>{g=!0,window.clearInterval(k)}},[o]);const x=()=>{!p||b||(v(!0),a(null),A.firstRunRestore(p,j.trim()).then(g=>{Lf(g.job.id),l(g.job.id),r("running")}).catch(g=>a(g instanceof oe?g.message:String(g))).finally(()=>v(!1)))},y=c.filter(g=>g in _.restore.phases);return n.jsxs(n.Fragment,{children:[t&&e==="idle"&&!h?n.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:_.restore.offer}):null,e==="form"?n.jsxs(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>r("idle"),children:_.restore.cancel}),n.jsx(I,{variant:"accent",disabled:b||!p,onClick:x,children:_.restore.submit})]}),children:[n.jsx(J,{label:_.restore.file,grow:!0,children:n.jsx("input",{type:"file",onChange:g=>{var N;return m(((N=g.target.files)==null?void 0:N[0])??null)}})}),n.jsx(J,{label:_.restore.passphrase,hint:_.restore.passphraseHint,children:n.jsx("input",{type:"password",autoComplete:"off",value:j,onChange:g=>w(g.target.value)})})]}):null,e==="running"||h?n.jsxs(Me,{children:[n.jsx(Fe,{children:_.restore.started}),y.map(g=>n.jsx(Fe,{children:_.restore.phases[g]},g))]}):null,h?n.jsxs(Me,{children:[s?n.jsx(Fe,{children:_.restore.welcome(s)}):null,n.jsx(Fe,{children:_.restore.keys})]}):null]})}function Az(e){var a,o,l,c,u;const{id:t,openNow:s,answers:r,onChange:i}=e;if(t==="name")return n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{at:1,children:_.name.ask})}),s?n.jsx(Tz,{...e}):n.jsx(ic,{text:r.name??"",onChange:i})]});if(t==="clock")return n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{at:1,children:_.clock.ask(r.name??"",r.clock??e.browserZone)})}),s?n.jsx(Rz,{...e}):n.jsx(ic,{text:_.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{at:1,children:_.brain.ask})}),s?n.jsx(Iz,{...e}):n.jsxs(n.Fragment,{children:[n.jsx(ic,{text:_.brain.answer(((a=r.brain)==null?void 0:a.label)??""),onChange:i}),n.jsxs(Me,{children:[n.jsx(Fe,{children:(o=r.brain)!=null&&o.freeTier?_.brain.worksOnFlash(r.brain.model):_.brain.works(((l=r.brain)==null?void 0:l.model)??"")}),n.jsx(Hz,{...e})]})]})]});if(t==="browser"){if(s)return n.jsx(Xz,{...e});const h=Qz(r.browser);return h?n.jsx(Me,{children:n.jsx(Fe,{children:h})}):null}return t==="assistant"?n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{at:1,children:_.assistant.ask})}),s?n.jsx(Zz,{...e}):n.jsx(ic,{text:`${((c=r.assistant)==null?void 0:c.avatar)??""} ${((u=r.assistant)==null?void 0:u.name)??""}`.trim(),onChange:i})]}):n.jsx(e5,{...e})}function Tz({answers:e,onSettled:t,onTrouble:s}){const r=Pa(),[i,a]=d.useState(e.name??""),[o,l]=d.useState(!1),c=()=>{const u=i.trim();u===""||o||(l(!0),A.setOwner({preferredName:u}).then(()=>t({...e,name:u})).catch(h=>s(h instanceof oe?h.message:String(h))).finally(()=>l(!1)))};return n.jsx(kt,{actions:n.jsx(I,{variant:"accent",disabled:o||i.trim()==="",onClick:c,children:_.name.submit}),children:n.jsx("input",{ref:r,className:"meet-input","aria-label":_.name.placeholder,placeholder:_.name.placeholder,maxLength:80,value:i,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function Rz({answers:e,zones:t,browserZone:s,onSettled:r,onTrouble:i}){const[a,o]=d.useState(!1),[l,c]=d.useState(s),[u,h]=d.useState(!1),f=p=>{h(!0),A.setOwner({timezone:p}).then(()=>r({...e,clock:p})).catch(m=>i(m instanceof oe?m.message:String(m))).finally(()=>h(!1))};return a?n.jsx(kt,{actions:n.jsx(I,{variant:"accent",disabled:u,onClick:()=>f(l),children:_.clock.yes}),children:n.jsx("select",{className:"meet-input","aria-label":_.clock.label,value:l,onChange:p=>c(p.target.value),children:(t.includes(l)?t:[l,...t]).map(p=>n.jsx("option",{value:p,children:p},p))})}):n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>o(!0),children:_.clock.another}),n.jsx(I,{variant:"accent",disabled:u,onClick:()=>f(s),children:_.clock.yes})]})})}function Iz(e){const{accounts:t,answers:s,onSettled:r,onReload:i}=e,[a,o]=d.useState(null),[l,c]=d.useState(null),[u,h]=d.useState(!1),[f,p]=d.useState(null),[m,j]=d.useState(null),w=(t==null?void 0:t.anthropicOAuthEnabled)===!0,b=(t==null?void 0:t.codexEnabled)===!0,v=t==null?void 0:t.gemini,[x,y]=d.useState(null);d.useEffect(()=>{let C=!1;const R=()=>{A.ollama().then(P=>{C||p(P)}).catch(()=>{})};R();const E=window.setInterval(R,4e3);return()=>{C=!0,window.clearInterval(E)}},[]);const g=async C=>{if(s.assistant??e.existing)try{await A.bindBrain({accountId:C.accountId,model:C.model})}catch(R){return R instanceof oe?R.message:String(R)}return i(),r({...s,brain:C}),null},N=async(C,R,E)=>{h(!0),c(null);try{const P=await A.saveProviderAccount(C);let O=await A.testProviderAccount(P.id),U=C.defaultModel,T=!1;if(O.state!=="connected"&&E&&E!==U&&d1(O)){const L=(await A.providerAccounts()).accounts.find(K=>K.id===P.id);L&&(await A.saveProviderAccount({id:L.id,revision:L.revision,label:L.label,kind:L.kind,auth:L.auth,baseUrl:L.baseUrl,defaultModel:E,enabled:L.enabled}),O=await A.testProviderAccount(P.id),O.state==="connected"&&(U=E,T=!0))}if(O.state!=="connected"){try{const L=(await A.providerAccounts()).accounts.find(K=>K.id===P.id);L&&await A.removeProviderAccount(P.id,L.revision)}catch{}return c(O.message),O}const M=await g({accountId:P.id,label:R,model:U,...T?{freeTier:T}:{}});return M&&c(M),O}catch(P){return c(P instanceof oe?P.message:String(P)),null}finally{h(!1)}},k=async C=>{h(!0),c(null);try{const R=await A.saveProviderAccount(C);let E;try{E=await A.testProviderAccount(R.id)}finally{try{const P=(await A.providerAccounts()).accounts.find(O=>O.id===R.id);P&&await A.removeProviderAccount(R.id,P.revision)}catch{}}return E.state!=="connected"&&c(E.message),E}catch(R){return c(R instanceof oe?R.message:String(R)),null}finally{h(!1)}},S=(C,R,E)=>{if(C.length<=1){N(R(C[0]??""),E);return}j({models:C,make:R,label:E})};return m?n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{children:_.brain.model.ask})}),u?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.service})}):l?n.jsx(Me,{children:n.jsx(Fe,{children:l})}):null,n.jsx(Dz,{busy:u,models:m.models,onUse:C=>void N(m.make(C),m.label)})]}):a==="gemini"&&v?n.jsx(Fz,{busy:u,problem:l,preset:v,onBack:()=>o(null),onUse:N}):a==="key"?n.jsx(Lz,{busy:u,problem:l,onBack:()=>o(null),onUse:N}):a==="service"?n.jsx(Bz,{busy:u,problem:l,address:(f==null?void 0:f.cloudBaseUrl)??"",onBack:()=>o(null),onOffer:S,onTrial:k,onUse:N}):a==="ollama"?n.jsx(Uz,{busy:u,problem:l,probe:f,onBack:()=>o(null),onOffer:S}):a==="cloud"?n.jsx(Wz,{busy:u,consent:x,onBack:()=>{x==null||x.close(),y(null),o(null)},onConnected:g,...e}):a==="chatgpt"?n.jsx(Kz,{busy:u,consent:x,onBack:()=>{x==null||x.close(),y(null),o(null)},onConnected:g,...e}):a==="claude"?n.jsx(Yz,{busy:u,problem:l,onBack:()=>o(null),onConnected:g,...e}):n.jsx(lC,{children:n.jsxs("div",{className:"meet-cards",role:"group","aria-label":_.brain.ask,children:[w?n.jsx(Hr,{mark:n.jsx(Pz,{}),card:_.brain.cards.claude,onPick:()=>o("claude")}):null,b?n.jsx(Hr,{mark:n.jsx(Mz,{}),card:_.brain.cards.chatgpt,onPick:()=>{y(typeof window.open=="function"?window.open("","_blank"):null),o("chatgpt")}}):null,v?n.jsx(Hr,{mark:n.jsx(_z,{}),card:_.brain.cards.gemini,onPick:()=>o("gemini")}):null,n.jsx(Hr,{mark:n.jsx($z,{}),card:_.brain.cards.key,onPick:()=>o("key")}),n.jsx(Hr,{mark:n.jsx(Oz,{}),card:_.brain.cards.ollama,note:f===null?_.brain.ollama.looking:f.running?_.brain.ollama.found:_.brain.ollama.missing,onPick:()=>o("ollama")}),n.jsx(Hr,{mark:n.jsx(Py,{}),card:_.brain.cards.cloud,onPick:()=>{y(typeof window.open=="function"?window.open("","_blank"):null),o("cloud")}}),n.jsx(Hr,{mark:n.jsx(Py,{}),card:_.brain.cards.service,onPick:()=>o("service")})]})})}function Hr({mark:e,card:t,note:s,onPick:r}){return n.jsxs("button",{type:"button",className:"meet-card",onClick:r,children:[n.jsx("span",{className:"meet-card-mark","aria-hidden":"true",children:e}),n.jsxs("span",{className:"meet-card-words",children:[n.jsx("span",{className:"meet-card-title",children:t.title}),n.jsx("span",{className:"meet-card-line",children:s??t.line}),t.know?n.jsx("span",{className:"meet-card-know",children:t.know}):null]})]})}function Pz(){const e=[0,45,90,135,180,225,270,315];return n.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",children:e.map(t=>n.jsx("rect",{x:"11.1",y:"2.6",width:"1.8",height:"8.6",rx:"0.9",fill:"currentColor",transform:`rotate(${t} 12 12)`},t))})}function Mz(){return n.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M5.4 4.6h13.2a2 2 0 0 1 2 2v8.2a2 2 0 0 1-2 2h-7.4l-4.4 3.4v-3.4H5.4a2 2 0 0 1-2-2V6.6a2 2 0 0 1 2-2Z"}),n.jsx("path",{d:"M8 9.4h8"}),n.jsx("path",{d:"M8 12.6h5"})]})}function $z(){return n.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"8",cy:"8",r:"3.6"}),n.jsx("path",{d:"M10.6 10.6 19.4 19.4"}),n.jsx("path",{d:"M13.8 13.8 11.9 15.7"}),n.jsx("path",{d:"M16.6 16.6 14.7 18.5"})]})}function Oz(){return n.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3.2",y:"4.6",width:"17.6",height:"11.2",rx:"2"}),n.jsx("path",{d:"M9.4 19.4h5.2"}),n.jsx("path",{d:"M12 15.8v3.6"})]})}function _z(){return n.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round",children:n.jsx("path",{d:"M12 3c.6 4.6 3.9 8.4 9 9-5.1.6-8.4 4.4-9 9-.6-4.6-3.9-8.4-9-9 5.1-.6 8.4-4.4 9-9Z"})})}function Py(){return n.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M7.2 18.3h9.6a3.8 3.8 0 0 0 .5-7.6 5.4 5.4 0 0 0-10.3-1.2 3.9 3.9 0 0 0 .2 8.8Z"})})}function Dz({busy:e,models:t,onUse:s}){const[r,i]=d.useState(t[0]??"");return n.jsx(kt,{actions:n.jsx(I,{variant:"accent",disabled:e||r==="",onClick:()=>s(r),children:_.brain.model.submit}),children:n.jsx(J,{label:_.brain.model.label,grow:!0,children:n.jsx("select",{value:r,onChange:a=>i(a.target.value),children:t.map(a=>n.jsx("option",{value:a,children:a},a))})})})}function cC({models:e,picked:t,disabled:s,onPick:r}){return n.jsx(J,{label:_.brain.model.label,grow:!0,children:n.jsx("select",{value:t,disabled:s,onChange:i=>r(i.target.value),children:e.map(i=>n.jsx("option",{value:i,children:i},i))})})}function Lz({busy:e,problem:t,onBack:s,onUse:r}){const i=Pa(),[a,o]=d.useState(""),[l,c]=d.useState(null),[u,h]=d.useState(!1),[f,p]=d.useState([]),[m,j]=d.useState(""),[w,b]=d.useState(!1),v=e||u,x=!w&&t!==null&&f.length>0,y=l??jz(a),g=()=>{const N=a.trim();N===""||v||(h(!0),b(!1),(async()=>{var R;let k=y==="anthropic"?"claude-sonnet-5":"gpt-5",S=f;if(x&&m!=="")k=m;else try{const E=await A.probeModels({kind:y,auth:"api-key",secret:N});k=((R=E.models.find(P=>P.isDefault))==null?void 0:R.id)??k,S=E.models.map(P=>P.id)}catch{S=[]}h(!1);const C=await r({label:y==="anthropic"?_.brain.key.anthropic:_.brain.key.openai,kind:y,auth:"api-key",baseUrl:"",defaultModel:k,enabled:!0,secret:N},y==="anthropic"?_.brain.key.anthropic:_.brain.key.openai);if(!(!C||C.state==="connected")){if(qm(C)){b(!0),p([]);return}p(S.includes(k)||S.length===0?S:[k,...S]),j(k)}})())};return n.jsxs(n.Fragment,{children:[v?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.key})}):w?n.jsx(Me,{children:n.jsx(Fe,{children:_.brain.key.refused})}):t?n.jsx(Me,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:s,disabled:v}),n.jsx(I,{variant:"accent",disabled:v||a.trim()==="",onClick:g,children:x?_.brain.model.retry:_.brain.key.submit})]}),children:[n.jsx(J,{label:_.brain.key.field,grow:!0,children:n.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:_.brain.key.placeholder,value:a,onChange:N=>{o(N.target.value),p([])},onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),g())}})}),x?n.jsx(cC,{models:f,picked:m,disabled:v,onPick:j}):null,n.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(y==="anthropic"?"openai":"anthropic"),children:[y==="anthropic"?_.brain.key.anthropic:_.brain.key.openai," · ",_.brain.key.which]})]})]})}function Fz({busy:e,problem:t,preset:s,onBack:r,onUse:i}){const a=Pa(),[o,l]=d.useState(""),[c,u]=d.useState(!1),[h,f]=d.useState([]),[p,m]=d.useState(""),j=e||c,w=t!==null&&h.length>0,b=()=>{const v=o.trim();v===""||j||(u(!0),(async()=>{let x=o1,y;if(w&&p!=="")x=p;else try{const N=(await A.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:s.baseUrl,secret:v})).models.map(k=>k.id);x=l1(N)??x,y=u1(x)?c1(N):void 0,f(AU(N)),m(y??x)}catch{}u(!1),await i({label:_.brain.gemini.label,kind:"openai-compatible",auth:"api-key",baseUrl:s.baseUrl,defaultModel:x,enabled:!0,secret:v},_.brain.gemini.label,y)})())};return n.jsxs(n.Fragment,{children:[j?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.gemini})}):t?n.jsx(Me,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:r,disabled:j}),n.jsx(I,{variant:"accent",disabled:j||o.trim()==="",onClick:b,children:_.brain.gemini.submit})]}),children:[n.jsx(J,{label:_.brain.gemini.field,grow:!0,children:n.jsx("input",{ref:a,type:"password",autoComplete:"off",spellCheck:!1,placeholder:_.brain.gemini.placeholder,value:o,onChange:v=>l(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),b())}})}),w?n.jsx(J,{label:_.brain.model.label,grow:!0,children:n.jsx("select",{value:p,disabled:j,onChange:v=>m(v.target.value),children:h.map(v=>n.jsx("option",{value:v,children:v},v))})}):null,n.jsx("a",{className:"meet-quiet",href:s.keyUrl,target:"_blank",rel:"noreferrer",children:_.brain.gemini.get})]})]})}function Uz({busy:e,problem:t,probe:s,onBack:r,onOffer:i}){const a=(s==null?void 0:s.models)??[],o=()=>{s&&i(a,l=>({label:_.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:s.baseUrl,defaultModel:l,enabled:!0}),_.brain.cards.ollama.title)};return n.jsxs(n.Fragment,{children:[e?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.ollama})}):t?n.jsx(Me,{children:n.jsx(Fe,{children:t})}):null,n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:r,disabled:e}),s!=null&&s.running?n.jsx(I,{variant:"accent",disabled:e||a.length===0,onClick:o,children:_.brain.ollama.connect}):s?n.jsx(Zt,{variant:"accent",href:s.downloadUrl,target:"_blank",rel:"noreferrer",children:_.brain.ollama.download}):null]}),children:n.jsx("span",{className:"meet-line",children:s===null?_.brain.ollama.looking:s.running?_.brain.ollama.found:_.brain.ollama.missing})})]})}function Bz({busy:e,problem:t,address:s,onBack:r,onOffer:i,onTrial:a,onUse:o}){const l=Pa(),[c,u]=d.useState(s),[h,f]=d.useState(""),[p,m]=d.useState(!1),[j,w]=d.useState([]),[b,v]=d.useState(""),[x,y]=d.useState(!1),g=e||p,N=!x&&t!==null&&j.length>0,k=()=>{c.trim()===""||g||(m(!0),y(!1),(async()=>{var M;const S=h.trim()?"api-key":"none",C=L=>({label:_.brain.cards.service.title,kind:"openai-compatible",auth:S,baseUrl:c.trim(),defaultModel:L,enabled:!0,...h.trim()?{secret:h.trim()}:{}}),R=(L,K,D)=>{if(!(!L||L.state==="connected")){if(qm(L)){y(!0),w([]);return}w(K),v(D)}};if(S==="api-key"&&N&&b!==""){m(!1),R(await o(C(b),_.brain.cards.service.title),j,b);return}let E=[],P;try{const L=await A.probeModels({kind:"openai-compatible",auth:S,baseUrl:c.trim(),...h.trim()?{secret:h.trim()}:{}});E=L.models.map(K=>K.id),P=(M=L.models.find(K=>K.isDefault))==null?void 0:M.id}catch{}m(!1);const O=P?[P]:E;if(S==="none"){i(O,C,_.brain.cards.service.title);return}const U=O[0]??"";if(O.length<=1){R(await o(C(U),_.brain.cards.service.title),E,U);return}const T=await a(C(U));(T==null?void 0:T.state)==="connected"?i(O,C,_.brain.cards.service.title):R(T,E,U)})())};return n.jsxs(n.Fragment,{children:[g?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.service})}):x?n.jsx(Me,{children:n.jsx(Fe,{children:_.brain.key.refused})}):t?n.jsx(Me,{children:n.jsx(Fe,{children:t})}):null,n.jsxs(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:r,disabled:g}),n.jsx(I,{variant:"accent",disabled:g||c.trim()==="",onClick:k,children:N?_.brain.model.retry:_.brain.service.submit})]}),children:[n.jsx(J,{label:_.brain.service.address,grow:!0,children:n.jsx("input",{ref:l,value:c,placeholder:_.brain.service.addressPlaceholder,onChange:S=>{u(S.target.value),w([])}})}),n.jsx(J,{label:_.brain.service.key,children:n.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:h,onChange:S=>{f(S.target.value),w([])}})}),N?n.jsx(cC,{models:j,picked:b,disabled:g,onPick:v}):null]})]})}const zz=2e3;function Wz({busy:e,consent:t,onBack:s,onConnected:r,accounts:i}){const[a,o]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(0),m=d.useRef(-1),j=d.useRef(null),w=_.brain.cloud.label;d.useEffect(()=>{if(m.current===f)return;m.current=f,o(!0),c(null);const v=f===0?t:j.current;(async()=>{try{const x=((i==null?void 0:i.accounts)??[]).find(k=>k.auth==="device-key"),y=x?{id:x.id}:await A.saveProviderAccount({label:w,kind:"openai-compatible",auth:"device-key",baseUrl:"",defaultModel:wc,enabled:!0}),g=(await A.providerAccounts()).accounts.find(k=>k.id===y.id),N=await A.ollamaConnect(g.id,g.revision);h({id:g.id,attemptId:N.attemptId,url:N.verificationUrl}),v&&(v.location.href=N.verificationUrl)}catch(x){v==null||v.close(),c(x instanceof oe?x.message:String(x))}finally{o(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let v=!1,x=!1;const y=async()=>{if(!(v||x)){x=!0;try{const N=await A.ollamaPoll(u.id,u.attemptId);if(v||N.state==="waiting")return;if(v=!0,h(null),N.state==="failed"){c(N.message);return}o(!0),c(await b(u.id)),o(!1)}catch{}finally{x=!1}}},g=window.setInterval(()=>void y(),zz);return()=>{v=!0,window.clearInterval(g)}},[u]);const b=async v=>{try{const x=(await A.accountModels(v).catch(()=>({models:[]}))).models.map(k=>k.id),y=x.length===0||x.includes(wc)?wc:x[0],g=(await A.providerAccounts()).accounts.find(k=>k.id===v);g&&g.defaultModel!==y&&await A.saveProviderAccount({id:g.id,revision:g.revision,label:g.label,kind:g.kind,auth:g.auth,baseUrl:g.baseUrl,defaultModel:y,enabled:g.enabled});const N=await A.testProviderAccount(v);return N.state!=="connected"?N.message:await r({accountId:v,label:w,model:y})}catch(x){return x instanceof oe?x.message:String(x)}};return n.jsxs(n.Fragment,{children:[a||e?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.cloud})}):l?n.jsx(Me,{children:n.jsx(Fe,{children:l})}):u?n.jsx(Me,{children:n.jsx(Fe,{children:_.brain.cloud.waiting})}):null,n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:s,disabled:a||e}),u?n.jsx(Zt,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:_.brain.cloud.open}):l?n.jsx(I,{variant:"accent",disabled:a||e,onClick:()=>{j.current=typeof window.open=="function"?window.open("","_blank"):null,p(v=>v+1)},children:_.brain.cloud.again}):null]})})]})}function Hz({answers:e,accounts:t,onSettled:s,onTrouble:r}){var p;const i=e.brain,a=i?((t==null?void 0:t.accounts)??[]).find(m=>m.id===i.accountId):void 0,[o,l]=d.useState([]),[c,u]=d.useState(!1),h=(a==null?void 0:a.auth)==="device-key"||(a==null?void 0:a.kind)==="codex"||!!a&&TU(a,(p=t==null?void 0:t.gemini)==null?void 0:p.baseUrl);if(d.useEffect(()=>{if(!h||!a)return;let m=!1;return A.accountModels(a.id).then(j=>{m||l(j.models.map(w=>w.id))}).catch(()=>{}),()=>{m=!0}},[h,a==null?void 0:a.id]),!h||!a||!i||o.length<2)return null;const f=m=>{m===i.model||c||(u(!0),r(null),(async()=>{try{await A.saveProviderAccount({id:a.id,revision:a.revision,label:a.label,kind:a.kind,auth:a.auth,baseUrl:a.baseUrl,defaultModel:m,enabled:a.enabled}),e.assistant&&await A.bindBrain({accountId:a.id,model:m}),s({...e,brain:{accountId:i.accountId,label:i.label,model:m}})}catch(j){r(j instanceof oe?j.message:String(j))}finally{u(!1)}})())};return n.jsx(Fe,{children:n.jsx(J,{label:_.brain.model.change,children:n.jsx("select",{value:i.model,disabled:c,onChange:m=>f(m.target.value),children:(o.includes(i.model)?o:[i.model,...o]).map(m=>n.jsx("option",{value:m,children:m},m))})})})}const My="gpt-5.5",Vz=2e3;function Kz({busy:e,consent:t,onBack:s,onConnected:r,accounts:i}){const[a,o]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(0),m=d.useRef(-1),j=d.useRef(null),w=d.useRef(null),b=_.brain.chatgpt.label;d.useEffect(()=>()=>{const y=w.current;w.current=null,y&&A.codexAccountAction(y.id,"cancel-login",y.revision).catch(()=>{})},[]),d.useEffect(()=>{if(m.current===f)return;m.current=f,o(!0),c(null);const y=f===0?t:j.current;(async()=>{try{const g=((i==null?void 0:i.accounts)??[]).find(C=>C.kind==="codex"),N=g?{id:g.id}:await A.saveProviderAccount({label:b,kind:"codex",auth:"chatgpt",baseUrl:"",defaultModel:My,enabled:!0}),k=(await A.providerAccounts()).accounts.find(C=>C.id===N.id),S=await A.codexAccountAction(k.id,"login",k.revision);if(!(S!=null&&S.verificationUrl)||!S.userCode)throw new Error((S==null?void 0:S.message)??_.brain.chatgpt.failed);w.current={id:k.id,revision:k.revision},h({id:k.id,revision:k.revision,url:S.verificationUrl,code:S.userCode}),y&&(y.location.href=S.verificationUrl)}catch(g){y==null||y.close(),c(g instanceof oe||g instanceof Error?g.message:String(g))}finally{o(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let y=!1,g=!1;const N=async()=>{if(!(y||g)){g=!0;try{const S=(await A.providerAccounts()).accounts.find(R=>R.id===u.id);if(y)return;const C=S==null?void 0:S.login;if(!C||C.state==="pending")return;if(y=!0,w.current=null,h(null),C.state!=="connected"){c(C.message??_.brain.chatgpt.failed);return}o(!0),c(await v(u.id)),o(!1)}catch{}finally{g=!1}}},k=window.setInterval(()=>void N(),Vz);return()=>{y=!0,window.clearInterval(k)}},[u]);const v=async y=>{var g,N;try{const k=(await A.accountModels(y).catch(()=>({models:[]}))).models,S=((g=k.find(R=>R.isDefault))==null?void 0:g.id)??((N=k[0])==null?void 0:N.id)??My,C=(await A.providerAccounts()).accounts.find(R=>R.id===y);return C&&C.defaultModel!==S&&await A.saveProviderAccount({id:C.id,revision:C.revision,label:C.label,kind:C.kind,auth:C.auth,baseUrl:C.baseUrl,defaultModel:S,enabled:C.enabled}),await r({accountId:y,label:b,model:S})}catch(k){return k instanceof oe?k.message:String(k)}},x=()=>{const y=w.current;w.current=null,y&&A.codexAccountAction(y.id,"cancel-login",y.revision).catch(()=>{}),s()};return n.jsxs(n.Fragment,{children:[a||e?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.chatgpt})}):l?n.jsx(Me,{children:n.jsx(Fe,{children:l})}):u?n.jsx(Me,{children:n.jsxs(Fe,{children:[_.brain.chatgpt.codeBefore,n.jsx("strong",{children:u.code}),_.brain.chatgpt.codeAfter]})}):null,n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:x,disabled:a||e}),u?n.jsx(Zt,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:_.brain.chatgpt.open}):l?n.jsx(I,{variant:"accent",disabled:a||e,onClick:()=>{j.current=typeof window.open=="function"?window.open("","_blank"):null,p(y=>y+1)},children:_.brain.chatgpt.again}):null]}),children:u?n.jsx(f1,{code:u.code,label:_.brain.chatgpt.code}):null})]})}const Gz="claude-sonnet-5";function Yz({busy:e,problem:t,onBack:s,onConnected:r,accounts:i,claudeModel:a}){const[o,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[p,m]=d.useState(""),j=d.useRef(null);d.useEffect(()=>()=>{const y=j.current;j.current=null,y&&A.anthropicAccountAction(y.id,"cancel-login",y.revision).catch(()=>{})},[]);const w=()=>{const y=j.current;j.current=null,y&&A.anthropicAccountAction(y.id,"cancel-login",y.revision).catch(()=>{}),s()},b=a??Gz,v=()=>{l(!0),u(null);const y=typeof window.open=="function"?window.open("","_blank"):null;(async()=>{try{const g=((i==null?void 0:i.accounts)??[]).find(R=>R.auth==="anthropic-oauth"),N=g?{id:g.id}:await A.saveProviderAccount({label:_.brain.cards.claude.title,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:b,enabled:!0}),S=(await A.providerAccounts()).accounts.find(R=>R.id===N.id),C=await A.anthropicAccountAction(S.id,"login",S.revision);j.current={id:S.id,revision:S.revision+1},f({id:S.id,revision:S.revision+1,url:C.verificationUrl??"",attemptId:C.attemptId??""}),y&&C.verificationUrl?y.location.href=C.verificationUrl:y==null||y.close()}catch(g){y==null||y.close(),u(g instanceof oe?g.message:String(g))}finally{l(!1)}})()},x=()=>{!h||p.trim()===""||(j.current=null,l(!0),(async()=>{try{await A.anthropicAccountAction(h.id,"complete-login",h.revision,{attemptId:h.attemptId,code:p.trim()});const y=await A.testProviderAccount(h.id);if(y.state!=="connected"){u(y.message);return}u(await r({accountId:h.id,label:_.brain.cards.claude.title,model:b}))}catch(y){u(y instanceof oe?y.message:String(y))}finally{l(!1)}})())};return n.jsxs(n.Fragment,{children:[o||e?n.jsx(Me,{children:n.jsx(rs,{line:_.brain.checking.claude})}):t??c?n.jsx(Me,{children:n.jsx(Fe,{children:t??c})}):null,h?n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{children:_.brain.claude.waiting})}),n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:w,disabled:o}),n.jsx(Zt,{href:h.url,target:"_blank",rel:"noreferrer",children:_.brain.claude.open}),n.jsx(I,{variant:"accent",disabled:o||p.trim()==="",onClick:x,children:_.brain.claude.finish})]}),children:n.jsx(J,{label:_.brain.claude.paste,grow:!0,children:n.jsx(qz,{value:p,onChange:m})})})]}):n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Rr,{onClick:w,disabled:e||o}),n.jsx(I,{variant:"accent",disabled:e||o,onClick:v,children:_.brain.claude.start})]})})]})}function qz({value:e,onChange:t}){const s=Pa();return n.jsx("input",{ref:s,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function Qz(e){switch(e){case"chrome":return _.browser.chrome;case"chromium":return _.browser.chromium;case"installed":return _.browser.installed;case"skipped":return _.browser.skipped;case"none":return _.browser.missing;default:return null}}function Xz({answers:e,onSettled:t}){const[s,r]=d.useState("checking"),[i,a]=d.useState(null),[o,l]=d.useState(null),[c,u]=d.useState(void 0),[h,f]=d.useState(0),p=d.useRef(!1),m=d.useRef(!1),j=d.useRef(()=>{});if(j.current=b=>{m.current||(m.current=!0,t({...e,browser:b}))},d.useEffect(()=>{let b=!1,v;const x=k=>{b||j.current(k)},y=(k,S)=>{b||(p.current=!1,r("failed"),a(k),l(S??null))},g=async k=>{r("launching");let S;try{S=await A.browserCheck()}catch(C){return y(C instanceof oe?C.message:String(C))}if(!b)return S.ok?x(p.current?"installed":k):y(S.message,S.command)},N=async()=>{var C,R;let k;try{k=await A.browser()}catch{return x("other")}if(b)return;const S=k.browser;if(!S)return x("other");if(((C=S.install)==null?void 0:C.state)==="running"){r("installing"),u(S.install.progress),v=window.setTimeout(()=>void N(),1e3);return}if(S.engine!=="none")return g(S.engine);if(p.current)return y(((R=S.install)==null?void 0:R.line)??"");p.current=!0,r("installing"),u(void 0);try{await A.browserInstall()}catch(E){return y(E instanceof oe?E.message:String(E))}b||(v=window.setTimeout(()=>void N(),1e3))};return N(),()=>{b=!0,window.clearTimeout(v)}},[h]),s==="checking")return n.jsx(rs,{});const w=s==="installing"||s==="launching";return n.jsxs(n.Fragment,{children:[n.jsxs(Me,{children:[p.current||s==="installing"?n.jsx(Fe,{children:_.browser.needs}):null,s==="installing"?n.jsx("div",{className:"wb-msg","data-role":"assistant",children:n.jsx("div",{className:"wb-bubble",children:n.jsx(eN,{progress:c})})}):s==="launching"?n.jsx(rs,{line:_.browser.launching}):n.jsx(Fe,{children:_.browser.failed(i??"")})]}),n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:()=>j.current("skipped"),children:_.browser.skip}),n.jsx(I,{variant:"accent",disabled:w,onClick:()=>{r("launching"),l(null),f(b=>b+1)},children:w?_.browser.installing:_.browser.retry})]}),children:s==="failed"&&o?n.jsx(Jz,{command:o}):null})]})}function Jz({command:e}){const[t,s]=d.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){s("failed");return}navigator.clipboard.writeText(e).then(()=>s("done"),()=>s("failed"))};return n.jsxs(V,{gap:"sm",children:[n.jsx(bt,{label:"The command to run",children:e}),n.jsxs(Q,{align:"end",children:[t==="failed"?n.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,n.jsx(I,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function Zz({answers:e,existing:t,onSettled:s,onTrouble:r,onReload:i}){const[a,o]=d.useState(()=>(t==null?void 0:t.name)??g$),[l,c]=d.useState(()=>t!=null&&t.picture?{kind:"kept",url:t.picture}:t!=null&&t.avatar?{kind:"emoji",value:t.avatar}:{kind:"mascot",role:"core"}),[u,h]=d.useState(t?null:_.assistant.purposeValue),[f,p]=d.useState(t?"":_.assistant.purposeValue);d.useEffect(()=>{if(!t)return;let b=!1;return A.firstAgentPersona().then(v=>{b||(h(v.persona),p(v.persona))},v=>{b||r(v instanceof oe?v.message:String(v))}),()=>{b=!0}},[t==null?void 0:t.id]);const[m,j]=d.useState(!1),w=()=>{if(a.trim()===""||m)return;j(!0);const b=l.kind==="emoji"?{avatar:l.value}:{},v=!t||u!==null&&f.trim()!==""&&f.trim()!==u.trim()?{instructions:f.trim()}:{},x=t?A.updateFirstAgent({name:a.trim(),...v,...b}):A.createFirstAgent({name:a.trim(),handle:yz(a),description:"",...v,...b,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let y;try{y=await x}catch(N){r(N instanceof oe?N.message:String(N)),j(!1);return}let g=null;try{l.kind==="mascot"?await A.uploadAgentPicture(y.id,await YN(l.role)):l.kind==="emoji"&&(t!=null&&t.picture)&&await A.removeAgentPicture(y.id)}catch(N){g=N instanceof oe?N.message:String(N)}j(!1),i(),s({...e,assistant:{id:y.id,name:a.trim(),avatar:l.kind==="emoji"?l.value:""}}),g&&r(g)})()};return n.jsxs(kt,{actions:n.jsx(I,{variant:"accent",disabled:m||a.trim()===""||u===null,onClick:w,children:_.assistant.submit}),children:[n.jsx("span",{className:"meet-chosen-face","data-kind":l.kind==="emoji"?"emoji":"image","aria-hidden":"true",children:l.kind==="emoji"?l.value:n.jsx("img",{src:l.kind==="mascot"?_r(l.role):l.url,alt:""})}),n.jsx(J,{label:_.assistant.name,children:n.jsx("input",{value:a,maxLength:60,onChange:b=>o(b.target.value)})}),n.jsx(qN,{face:l,onPick:c}),n.jsx(J,{label:_.assistant.purpose,wide:!0,children:n.jsx("textarea",{className:"meet-purpose",value:f,maxLength:8e3,rows:Math.max(4,f.split(`
125
+ `).length+1),onChange:b=>p(b.target.value)})})]})}function e5({answers:e,assistantAgent:t,met:s,onMet:r,onCarriesOn:i,onClosed:a,navigate:o,onPickAnotherBrain:l}){const c=e.assistant,[u,h]=d.useState(s),[f,p]=d.useState([]),[m,j]=d.useState(!1),[w,b]=d.useState(!1),[v,x]=d.useState(!0),[y,g]=d.useState("open"),[N,k]=d.useState(null);d.useEffect(()=>{let M=!1;return Promise.resolve().then(()=>A.telegram()).then(L=>{M||k((L==null?void 0:L.paired)===!0)}).catch(()=>{M||k(!1)}),()=>{M=!0}},[]);const[S,C]=d.useState(!1),R=aC(),E=d.useRef(!1),P=d.useMemo(()=>t?[t]:[],[t]);d.useEffect(()=>{if(!c||E.current)return;if(E.current=!0,s){h(s);return}let M=!1;return(async()=>{try{const L=await Le.startConversation(c.id);if(M)return;h(L.conversationId),r(L.conversationId),await A.onboardingStep(tC.handover,{conversationId:L.conversationId}).catch(()=>{}),await Le.send(c.id,{conversationId:L.conversationId,text:y$,opening:!0})}catch{M||(x(!1),j(!0))}})(),()=>{M=!0}},[c==null?void 0:c.id,s]),d.useEffect(()=>{if(!u)return;let M=!1;const L=Date.now(),K=()=>{Le.conversation(u).then(q=>{if(M)return;p(q.messages);const F=Date.now()-L;if(q.messages.some($y)){x(!1),j(!1),b(!1);return}const H=q.runs??[],le=H.some(ae=>ae.finishedAt===null),ie=H.length>0&&!le;b(le&&F>=bz),(ie||F>=kz)&&(x(!1),j(!0))}).catch(()=>{})};K();const D=window.setInterval(K,iC);return()=>{M=!0,window.clearInterval(D)}},[u]);const O=c&&u?Ve(c.id,u):null,U=f.some($y);d.useEffect(()=>{U&&O&&i(O)},[U,O,i]),d.useEffect(()=>{if(!S||!O||R)return;const M=window.setTimeout(()=>o(O,!0),Sz);return()=>window.clearTimeout(M)},[S,O,R,o]);const T=S&&O!==null;return d.useEffect(()=>{T&&a()},[T,a]),n.jsxs(n.Fragment,{children:[n.jsx(Ag,{messages:f,live:[],now:Date.now(),onOpen:()=>{},working:v,agents:P,agentName:(c==null?void 0:c.name)??"",...c?{agentId:c.id}:{},emptyHint:_.handover.waiting,plain:!0,workingLine:_.handover.looking((c==null?void 0:c.name)??"")}),w&&!m?n.jsx(Me,{children:n.jsx(Fe,{children:_.handover.slow})}):null,m?n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{children:_.handover.silent})}),n.jsx(kt,{actions:n.jsx(I,{variant:"accent",onClick:l,children:_.handover.again})})]}):null,S?n.jsx(Me,{children:n.jsx(Fe,{children:_.done.said})}):null,U&&N!==null&&!m?n.jsx(Me,{children:n.jsx(Fe,{children:N?_.offers.paired((c==null?void 0:c.name)??""):_.offers.said((c==null?void 0:c.name)??"")})}):null,U&&N!==null&&y==="open"?n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:N?"accent":"default",onClick:()=>{g("gone"),C(!0)},children:_.offers.notNow}),N?null:n.jsx(I,{variant:"accent",onClick:()=>g("phone"),children:_.offers.phone})]})}):null,U&&y==="phone"?n.jsx(t5,{onPaired:()=>C(!0),onDismiss:()=>{g("gone"),C(!0)}}):null,T&&O?n.jsx(kt,{actions:n.jsx(Zt,{variant:"accent",href:O,onClick:M=>{M.preventDefault(),o(O,!0)},children:_.done.open}),children:n.jsx("span",{className:"meet-line",children:R?_.done.ready:_.done.leaving})}):null]})}function $y(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function t5({onPaired:e,onDismiss:t}){const s=Pa(),[r,i]=d.useState(""),[a,o]=d.useState(!1),[l,c]=d.useState(null),{offer:u,square:h,paired:f,stale:p,ask:m}=Q1(()=>A.telegram().then(b=>b.paired),e),j=()=>{r.trim()===""||a||(o(!0),c(null),(async()=>{try{const b=await A.saveTelegramToken(r.trim());if(i(""),b.restartNeeded){c(b.note??_.telegram.restart);return}await m()}catch(b){c(b instanceof oe?b.message:String(b))}finally{o(!1)}})())},w=()=>{c(null),m().catch(b=>c(b instanceof oe?b.message:String(b)))};return f?n.jsx(Me,{children:n.jsx(Fe,{children:_.telegram.paired})}):u?n.jsxs(n.Fragment,{children:[n.jsx(Me,{children:n.jsx(Fe,{children:p?_.telegram.expired:_.telegram.scan})}),n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:t,children:_.offers.notNow}),p?n.jsx(I,{variant:"accent",onClick:w,children:_.telegram.newCode}):null]}),children:p?null:n.jsx(X1,{offer:u,square:h})})]}):n.jsxs(n.Fragment,{children:[n.jsxs(Me,{children:[n.jsx(Fe,{children:_.telegram.how}),l?n.jsx(Fe,{children:l}):null]}),n.jsx(kt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(I,{variant:"ghost",onClick:t,children:_.offers.notNow}),n.jsx(I,{variant:"accent",disabled:a||r.trim()==="",onClick:j,children:_.telegram.submit})]}),children:n.jsx(J,{label:_.telegram.field,grow:!0,children:n.jsx("input",{ref:s,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),j())}})})})]})}const n5="(max-width: 1080px)";function s5(){const[e,t]=d.useState(()=>window.location.hash||zt);d.useEffect(()=>{const r=()=>t(window.location.hash||zt);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const s=d.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,s]}function r5(){const[e,t]=_N();d.useEffect(()=>{ON(e)},[e]);const s=d.useCallback(r=>t({theme:r}),[t]);return[e.theme,s]}const Oy=new Map;function i5(){var it,ke,De;const[e,t]=s5(),[s,r]=d.useState("UTC"),[i,a]=d.useState({approvals:0,failed:0}),[o,l]=r5(),c=Yo(zg),[u,h]=d.useState(!1),[f,p]=d.useState([]),[m,j]=d.useState(null),[w,b]=d.useState(null),[v,x]=d.useState([]),[y,g]=d.useState(!1),[N,k]=d.useState(null),S=ZM(),C=f.find(ee=>ee.id===m)??null,R=C!==null&&hF(e),[E,P]=d.useState(!1),O=d.useCallback(()=>P(!0),[]);d.useEffect(()=>{R||P(!1)},[R]),C4(t,Cc(e)===null,R?O:void 0);const U=Yo(n5),T=s1(),M=NN(),L=re(()=>Promise.resolve().then(()=>A.version()),[],60*6e4).data,K=L&&!L.checkout&&L.updateAvailable?L:null,D=AN(L==null?void 0:L.web),q=((it=re(()=>Promise.resolve().then(()=>A.connectionSignals()),[],6e4).data)==null?void 0:it.signals)??[],[F,H]=d.useState(new Map);d.useEffect(()=>{const ee=()=>{A.conversations().then(B=>{const Ee=new Map;for(const St of B.conversations){const nt=St.lastMessageAt??St.createdAt,Mt=Ee.get(St.agentId);(!Mt||nt>Mt)&&Ee.set(St.agentId,nt)}H(Ee)}).catch(()=>{})};ee();const Ce=window.setInterval(ee,3e4);return()=>window.clearInterval(Ce)},[e]);const[le,ie]=d.useState(!1);d.useEffect(()=>{if(le)return;let ee=!1;return A.onboarding().then(Ce=>{ee||(ie(!0),Ce.state==="pending"&&Ce.needs.model&&!Cc(window.location.hash)&&t(NM,!0))}).catch(()=>{ee||ie(!0)}),()=>{ee=!0}},[le,t]),d.useEffect(()=>{const ee=LM(e);ee&&t(ee,!0)},[e,t]),d.useEffect(()=>{let ee=!1;const Ce=()=>{Le.agents().then(Ee=>{ee||(p(Ee.agents),VM(Ee.defaultAgentId??null),j(Ee.defaultAgentId??null),b(St=>{var nt;return St??Ee.defaultAgentId??((nt=Ee.agents[0])==null?void 0:nt.id)??null}))}).catch(()=>{})};Ce();const B=window.setInterval(Ce,15e3);return window.addEventListener("focus",Ce),window.addEventListener(Uo,Ce),()=>{ee=!0,window.clearInterval(B),window.removeEventListener("focus",Ce),window.removeEventListener(Uo,Ce)}},[e]),d.useEffect(()=>{let ee=!1;const Ce=()=>{Le.groups().then(Ee=>{ee||x(Ee.groups)}).catch(()=>{})};Ce();const B=window.setInterval(Ce,3e4);return()=>{ee=!0,window.clearInterval(B)}},[e]);const ae=nS(f,m),ge=EM(e),X=Jk(e),de=X?v.find(ee=>ee.id===X.groupId)??null:null,me=X?null:(ge==null?void 0:ge.agentId)??w;d.useEffect(()=>{ge&&b(ge.agentId)},[ge==null?void 0:ge.agentId]);const $e=ee=>{b(ee),t(Ve(ee))},ne=ee=>t(co(ee)),be=d.useCallback((ee,Ce,B=!0)=>t(X?co(X.groupId,Ce):Ve(ee,Ce),B),[t,X==null?void 0:X.groupId]),[Ne,Qe]=d.useState(!1);d.useEffect(()=>{A.session().then(ee=>{r(ee.timezone),Qe(!0)}).catch(()=>{})},[]);const Ie=bF(Ne);EF(Ne,Ie.refresh,()=>Qe(!1)),d.useEffect(()=>{const ee=()=>{A.overview().then(B=>a({approvals:B.approvals.pending,failed:B.jobs.failed??0})).catch(()=>{})};ee();const Ce=window.setInterval(ee,2e4);return()=>window.clearInterval(Ce)},[]),d.useEffect(()=>{if(!Ne)return;if(e===FM){g(!0),t(br,!0);return}const ee=UM(e),Ce=new Date().toDateString();!ee||Oy.get(ee)===Ce||(Oy.set(ee,Ce),A.tipsSeenPage(ee).catch(()=>{}))},[e,Ne,t]);const rt=Cc(e),fe=eS(e),xe=fe===br,ze=N?v.find(ee=>ee.id===N)??null:null,Oe=y?n.jsx(ny,{agents:f,onClose:()=>g(!1),onCreated:ee=>{x(Ce=>[...Ce,ee]),g(!1),t(co(ee.id))}}):ze?n.jsx(ny,{agents:f,group:ze,onClose:()=>k(null),onSaved:ee=>{x(Ce=>Ce.map(B=>B.id===ee.id?ee:B)),k(null)},onArchived:ee=>{x(Ce=>Ce.filter(B=>B.id!==ee)),k(null),t(br)}}):null;return rt?n.jsx(tj,{delayDuration:400,children:n.jsxs(zv,{swipeDirection:"right",children:[n.jsx(Cz,{navigate:t,timezone:s}),n.jsx(Wv,{className:"ui-toasts"})]})}):n.jsx(S$,{picture:(ke=f.find(ee=>ee.id===m))==null?void 0:ke.picture,children:n.jsx(tj,{delayDuration:400,children:n.jsxs(zv,{swipeDirection:"right",children:[Oe,n.jsxs("div",{className:"wb-shell",children:[n.jsx(mU,{active:((De=T.data)==null?void 0:De.active)===!0,onNavigate:t}),n.jsxs("div",{className:"wb",children:[n.jsx(w4,{attention:i.approvals+i.failed,place:fe,onNavigate:t,theme:o,onTheme:l,plugins:M.rail,updateAvailable:K!==null,settingsDot:q.length>0?RN:void 0,stale:D,version:L&&!L.checkout?{current:L.current,latest:L.latest,updateAvailable:L.updateAvailable}:L?{current:L.current,updateAvailable:!1}:void 0}),xe&&!U?n.jsx(lS,{agents:ae,currentId:me,attention:S,onSelect:$e,lastActivity:F,groups:v,currentGroupId:(de==null?void 0:de.id)??null,onSelectGroup:ne,onNewGroup:()=>g(!0)}):null,xe?n.jsx(nF,{timezone:s,agents:ae,agentId:de?de.coordinator:me,defaultAgentId:m,group:de,onEditGroup:de?()=>k(de.id):void 0,requestedConversationId:(X==null?void 0:X.conversationId)??(ge==null?void 0:ge.conversationId),requestedTab:ge==null?void 0:ge.tab,onConversationOpened:be,onSelectAgent:$e,attention:S,agentsInHeader:U,narrow:c,canvasOpen:u,onOpenCanvas:()=>h(!0),onCloseCanvas:()=>h(!1)}):n.jsx("main",{"data-ground":a5(fe,e)?"plain":void 0,"data-layout":fe===pn?"split":void 0,children:n.jsx(o5,{hash:e,place:fe,timezone:s,navigate:t,agents:f,defaultAgentId:m,attention:S,pluginPages:M,update:K,connectionSignals:q})})]})]}),R&&C?n.jsx(pF,{agent:C,agents:f,open:E,onOpenChange:P,navigate:t}):null,n.jsxs(yF,{placement:jF(R,E),children:[n.jsx(kF,{queue:Ie.queue,agents:f,navigate:t,onDismiss:Ie.dismiss}),n.jsx(Wv,{className:"ui-toasts"})]})]})})})}function a5(e,t){return hg(t)!==null}function o5({place:e,pluginPages:t,...s}){const r={...s,pluginPages:t},i=hg(s.hash);if(i){const a=t.find(i.plugin,i.page);if(a)return n.jsx(SN,{page:a,item:i.item??null,navigate:s.navigate,timezone:s.timezone,siblings:t.all.filter(o=>o.plugin===i.plugin)});if(t.all.length===0)return n.jsx(n.Fragment,{})}switch(e){case ot:return n.jsx(R3,{...s});case mt:return n.jsx(U4,{...s});case pn:return n.jsx(qB,{...r});case li:return n.jsx(g4,{...s});default:return n.jsx(Z3,{...s})}}function l5(){"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=`./sw.js?v=${encodeURIComponent(EN)}`;navigator.serviceWorker.register(e,{scope:"./"}).catch(()=>{})})}const uC=1e4,c5=3e4,dC=6e3,u5=/^(localhost|127(?:\.\d{1,3}){3}|\[?::1\]?)$|\.localhost$/i;function d5(e){return u5.test(e)?n.jsxs(n.Fragment,{children:["Is buddi running on this Mac? ",n.jsx("code",{children:"buddi status"})," says."]}):n.jsx(n.Fragment,{children:"Is Tailscale on, and the Mac it runs on awake?"})}async function fC(e){let t;const s=new Promise((r,i)=>{t=setTimeout(()=>i(new oe(0,au)),e)});try{return{up:!0,version:await Promise.race([A.version(),s])}}catch(r){return FI(r)?{up:!1}:{up:!0}}finally{clearTimeout(t)}}function hC(e){var t;return e.up&&AN((t=e.version)==null?void 0:t.web)?(window.location.reload(),!1):e.up}function f5({host:e,onRetry:t,retrying:s}){return n.jsxs("main",{className:"unreachable",role:"alert",children:[n.jsx("span",{className:"ui-blob","data-size":"lg","aria-hidden":"true",children:n.jsx("img",{src:_r("core"),alt:""})}),n.jsxs("h1",{children:["buddi isn't answering at ",e,"."]}),n.jsx("p",{children:d5(e.replace(/:\d+$/,""))}),n.jsx("div",{className:"unreachable-actions",children:n.jsx(I,{variant:"accent",onClick:t,disabled:s,children:s?"Retrying…":"Retry"})})]})}function h5({children:e}){const[t,s]=d.useState("checking"),[r,i]=d.useState(!1),a=d.useRef(!1),o=d.useCallback(async()=>{if(a.current)return;a.current=!0,i(!0);const l=await fC(dC);a.current=!1,i(!1),s(c=>c==="checking"?l.up?"up":"down":hC(l)?"up":"down")},[]);return d.useEffect(()=>{o()},[o]),d.useEffect(()=>{if(t!=="down")return;const l=window.setInterval(()=>void o(),uC);return()=>window.clearInterval(l)},[t,o]),t==="checking"?null:t==="down"?n.jsx(f5,{host:window.location.host,onRetry:()=>void o(),retrying:r}):n.jsxs(n.Fragment,{children:[n.jsx(m5,{}),e]})}function p5(e=c5){const[t,s]=d.useState(!1);return d.useEffect(()=>{let r;const i=()=>{clearTimeout(r);const o=DI();if(o===null)return s(!1);const l=o+e-Date.now();l<=0?s(!0):r=setTimeout(i,l)};i();const a=LI(i);return()=>{a(),clearTimeout(r)}},[e]),t}function m5(){const e=p5();return d.useEffect(()=>{if(!e)return;const t=window.setInterval(()=>{fC(dC).then(hC)},uC);return()=>window.clearInterval(t)},[e]),e?n.jsx("div",{className:"lost-bar",role:"status",children:"Lost buddi. Retrying…"}):null}function g5({search:e=location.search}){const[t,s]=d.useState(null),r=d.useRef(!1);return d.useEffect(()=>{if(r.current)return;r.current=!0;const i=new URLSearchParams(e);try{history.replaceState(null,"",location.pathname)}catch{}const a=i.get("state")??"",o=i.get("code")??void 0,l=i.get("error")??void 0;A.connectionCallback({state:a,...o?{code:o}:{},...l?{error:l}:{}}).then(c=>{s({ok:!0,name:c.name});try{const u=new BroadcastChannel(T1);u.postMessage({id:c.id}),u.close()}catch{}window.setTimeout(()=>{try{window.close()}catch{}},1500)}).catch(c=>s({ok:!1,message:c instanceof Error?c.message:String(c)}))},[e]),n.jsx("main",{className:"ui-page connections-callback",children:n.jsxs(V,{gap:"lg",children:[n.jsx("h2",{className:"ui-page-title",children:"Connections"}),t===null?n.jsx(W,{tone:"accent",role:"status",children:"Finishing the sign-in…"}):null,t!=null&&t.ok?n.jsx(W,{tone:"good",role:"status",title:`Signed in to ${t.name}`,children:"buddi keeps the sign-in in its vault. You can close this tab; the other one carries on."}):null,t&&!t.ok?n.jsx(W,{tone:"critical",role:"alert",title:"Nothing was connected",children:t.message}):null,t?n.jsx(Zt,{href:"/#/settings/connections",children:"Back to Connections"}):null]})})}const _y=document.getElementById("root");_y&&qb(_y).render(n.jsx(d.StrictMode,{children:location.pathname==="/connections/callback"?n.jsx(g5,{}):n.jsx(h5,{children:n.jsx(i5,{})})}));l5();export{v5 as c,OC as g};