@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.45

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 (346) hide show
  1. package/CHANGELOG.md +131 -5
  2. package/README.md +371 -300
  3. package/dist/acp-package.d.ts +28 -0
  4. package/dist/acp-package.js +23 -0
  5. package/dist/adapter-facts.d.ts +8 -1
  6. package/dist/adapter-facts.js +9 -1
  7. package/dist/adapters.d.ts +5 -0
  8. package/dist/adapters.js +36 -3
  9. package/dist/agent-delete.d.ts +50 -0
  10. package/dist/agent-delete.js +125 -0
  11. package/dist/agents-store.d.ts +9 -3
  12. package/dist/agents-store.js +22 -8
  13. package/dist/agents.d.ts +5 -1
  14. package/dist/agents.js +8 -4
  15. package/dist/api-only.d.ts +8 -3
  16. package/dist/api-only.js +10 -4
  17. package/dist/archil-routes.d.ts +5 -1
  18. package/dist/archil-routes.js +57 -2
  19. package/dist/browser-wait-ended.d.ts +2 -0
  20. package/dist/browser-wait-ended.js +2 -0
  21. package/dist/calendar/ics-faux.d.ts +3 -1
  22. package/dist/calendar/ics-faux.js +12 -2
  23. package/dist/calendar/tools.js +5 -2
  24. package/dist/chatgpt-plan.js +3 -1
  25. package/dist/claude-login.d.ts +135 -0
  26. package/dist/claude-login.js +244 -0
  27. package/dist/cli.js +52 -16
  28. package/dist/composio-preset.js +69 -7
  29. package/dist/composio-triggers.d.ts +14 -0
  30. package/dist/composio-triggers.js +79 -15
  31. package/dist/computer-attach.d.ts +40 -5
  32. package/dist/computer-attach.js +130 -15
  33. package/dist/computer-keys.d.ts +3 -0
  34. package/dist/computer-keys.js +7 -1
  35. package/dist/computer-live.js +3 -2
  36. package/dist/computers.d.ts +21 -10
  37. package/dist/computers.js +39 -28
  38. package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
  39. package/dist/console/assets/index-DaFsZuzQ.css +1 -0
  40. package/dist/console/index.html +2 -2
  41. package/dist/decisions.d.ts +1 -1
  42. package/dist/dial-relay.d.ts +29 -0
  43. package/dist/dial-relay.js +94 -0
  44. package/dist/email/tools.js +10 -5
  45. package/dist/env-proxy.d.ts +2 -0
  46. package/dist/env-proxy.js +35 -0
  47. package/dist/errors.d.ts +3 -1
  48. package/dist/errors.js +7 -4
  49. package/dist/faux-computers.d.ts +8 -2
  50. package/dist/faux-computers.js +83 -6
  51. package/dist/harness-archive.d.ts +67 -0
  52. package/dist/harness-archive.js +177 -0
  53. package/dist/harness-goose.d.ts +34 -0
  54. package/dist/harness-goose.js +87 -0
  55. package/dist/harness-install.d.ts +21 -0
  56. package/dist/harness-install.js +24 -11
  57. package/dist/harness-opencode/adapter.js +1 -1
  58. package/dist/harness-table.d.ts +9 -1
  59. package/dist/harness-table.js +20 -3
  60. package/dist/harness.d.ts +1 -2
  61. package/dist/harness.js +3 -4
  62. package/dist/host.js +2 -1
  63. package/dist/key-check.js +3 -0
  64. package/dist/learn/audit.d.ts +6 -6
  65. package/dist/learn/audit.js +3 -7
  66. package/dist/learn/check.d.ts +23 -89
  67. package/dist/learn/check.js +57 -335
  68. package/dist/learn/commit.d.ts +63 -90
  69. package/dist/learn/commit.js +124 -316
  70. package/dist/learn/compile.d.ts +53 -50
  71. package/dist/learn/compile.js +87 -102
  72. package/dist/learn/corrections.d.ts +13 -0
  73. package/dist/learn/corrections.js +23 -0
  74. package/dist/learn/delete.d.ts +5 -5
  75. package/dist/learn/delete.js +8 -10
  76. package/dist/learn/folder.d.ts +35 -47
  77. package/dist/learn/folder.js +118 -134
  78. package/dist/learn/index.d.ts +3 -5
  79. package/dist/learn/index.js +6 -9
  80. package/dist/learn/learning.sh +45 -15
  81. package/dist/learn/promote.d.ts +13 -1
  82. package/dist/learn/promote.js +9 -0
  83. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
  84. package/dist/learn/{skills.js → workflow-draft.js} +48 -58
  85. package/dist/learn/workflow-nodes.js +1 -1
  86. package/dist/learned-workflow.js +2 -2
  87. package/dist/learning-cost.d.ts +38 -24
  88. package/dist/learning-cost.js +41 -24
  89. package/dist/learning-routes.d.ts +91 -170
  90. package/dist/learning-routes.js +183 -421
  91. package/dist/learning-run.d.ts +19 -40
  92. package/dist/learning-run.js +23 -93
  93. package/dist/learning-setting.d.ts +4 -4
  94. package/dist/learning-setting.js +6 -6
  95. package/dist/learning-words.d.ts +28 -74
  96. package/dist/learning-words.js +64 -162
  97. package/dist/learning.d.ts +61 -392
  98. package/dist/learning.js +101 -651
  99. package/dist/live-reach.d.ts +25 -2
  100. package/dist/live-reach.js +46 -4
  101. package/dist/llms.txt +1 -1
  102. package/dist/local-models.d.ts +3 -11
  103. package/dist/local-models.js +5 -6
  104. package/dist/mcp-servers-store.d.ts +4 -4
  105. package/dist/model-form.js +6 -5
  106. package/dist/model.d.ts +4 -0
  107. package/dist/model.js +26 -9
  108. package/dist/native/binding.js +1 -1
  109. package/dist/native/connection.js +1 -1
  110. package/dist/native/discovery.js +1 -1
  111. package/dist/native/instructions.d.ts +3 -0
  112. package/dist/native/instructions.js +5 -3
  113. package/dist/native/remote-worker-bridge.js +9 -43
  114. package/dist/native/remote.d.ts +8 -15
  115. package/dist/native/remote.js +3 -3
  116. package/dist/native/schema.js +1 -1
  117. package/dist/native/types.d.ts +2 -2
  118. package/dist/openapi.js +268 -316
  119. package/dist/paid-calls.d.ts +8 -0
  120. package/dist/paid-calls.js +20 -0
  121. package/dist/particle-provider.d.ts +11 -0
  122. package/dist/particle-provider.js +135 -0
  123. package/dist/port-models.d.ts +12 -4
  124. package/dist/port-models.js +28 -11
  125. package/dist/print.d.ts +27 -0
  126. package/dist/print.js +21 -0
  127. package/dist/provider.d.ts +7 -0
  128. package/dist/provider.js +15 -1
  129. package/dist/reflect-range.js +2 -3
  130. package/dist/run-launch.d.ts +14 -28
  131. package/dist/run-launch.js +9 -12
  132. package/dist/run-learning-served.d.ts +15 -89
  133. package/dist/run-listing.d.ts +34 -0
  134. package/dist/run-listing.js +128 -0
  135. package/dist/run-model-key.js +1 -1
  136. package/dist/run-timeline-served.js +5 -3
  137. package/dist/run-trace.d.ts +97 -0
  138. package/dist/run-trace.js +253 -0
  139. package/dist/run-view.d.ts +15 -0
  140. package/dist/run-view.js +9 -0
  141. package/dist/runnable.js +2 -1
  142. package/dist/runner/adapter-loop.d.ts +8 -6
  143. package/dist/runner/adapter-loop.js +16 -12
  144. package/dist/runner/adapter-run-spec.d.ts +16 -4
  145. package/dist/runner/adapter-run-spec.js +64 -58
  146. package/dist/runner/adapters/index.js +22 -0
  147. package/dist/runner/adapters/pi.d.ts +4 -12
  148. package/dist/runner/adapters/pi.js +2 -2
  149. package/dist/runner/audit.d.ts +1 -1
  150. package/dist/runner/audit.js +16 -8
  151. package/dist/runner/beside.d.ts +6 -2
  152. package/dist/runner/beside.js +38 -9
  153. package/dist/runner/claim-secrets.d.ts +18 -2
  154. package/dist/runner/claim-secrets.js +42 -18
  155. package/dist/runner/cli-run-spec.js +55 -51
  156. package/dist/runner/conformance/harness.d.ts +6 -0
  157. package/dist/runner/conformance/harness.js +16 -5
  158. package/dist/runner/dispatch.d.ts +2 -2
  159. package/dist/runner/end-of-run.d.ts +6 -14
  160. package/dist/runner/end-of-run.js +8 -33
  161. package/dist/runner/feedback-round.d.ts +2 -2
  162. package/dist/runner/feedback-round.js +7 -7
  163. package/dist/runner/github-app.js +3 -1
  164. package/dist/runner/harness-loops.d.ts +0 -8
  165. package/dist/runner/harness-loops.js +11 -59
  166. package/dist/runner/held.d.ts +170 -0
  167. package/dist/runner/held.js +57 -0
  168. package/dist/runner/journal-kinds.d.ts +2 -3
  169. package/dist/runner/journal-kinds.js +2 -3
  170. package/dist/runner/learned-first.d.ts +40 -0
  171. package/dist/runner/learned-first.js +32 -0
  172. package/dist/runner/learning-end.d.ts +77 -69
  173. package/dist/runner/learning-end.js +250 -303
  174. package/dist/runner/learning-seed.d.ts +15 -33
  175. package/dist/runner/learning-seed.js +24 -45
  176. package/dist/runner/loop-contract.d.ts +2 -3
  177. package/dist/runner/main.d.ts +17 -9
  178. package/dist/runner/main.js +63 -20
  179. package/dist/runner/mcp-run.d.ts +11 -0
  180. package/dist/runner/mcp-run.js +67 -0
  181. package/dist/runner/memory-claim.d.ts +10 -5
  182. package/dist/runner/memory-claim.js +12 -6
  183. package/dist/runner/model-route.d.ts +7 -4
  184. package/dist/runner/model-route.js +22 -10
  185. package/dist/runner/native-loop.d.ts +0 -7
  186. package/dist/runner/native-loop.js +9 -101
  187. package/dist/runner/promotion.d.ts +8 -6
  188. package/dist/runner/promotion.js +19 -12
  189. package/dist/runner/reflect-hook.d.ts +64 -95
  190. package/dist/runner/reflect-hook.js +112 -225
  191. package/dist/runner/run-channel.d.ts +43 -0
  192. package/dist/runner/run-channel.js +467 -0
  193. package/dist/runner/run-child-host.d.ts +169 -0
  194. package/dist/runner/run-child-host.js +1222 -0
  195. package/dist/runner/run-child.d.ts +1 -0
  196. package/dist/runner/run-child.js +254 -0
  197. package/dist/runner/run-errors.d.ts +2 -0
  198. package/dist/runner/run-errors.js +20 -0
  199. package/dist/runner/runner.js +1 -5
  200. package/dist/runner/sdk-ask.d.ts +78 -0
  201. package/dist/runner/sdk-ask.js +158 -0
  202. package/dist/runner/sdk-loop.d.ts +2 -4
  203. package/dist/runner/sdk-loop.js +29 -49
  204. package/dist/runner/store-secrets.d.ts +5 -3
  205. package/dist/runner/store-secrets.js +5 -1
  206. package/dist/runner/workflow-first.d.ts +5 -0
  207. package/dist/runner/workflow-first.js +4 -0
  208. package/dist/runner/workflow-spec.js +7 -2
  209. package/dist/runs-over-store.d.ts +16 -28
  210. package/dist/runs-over-store.js +31 -38
  211. package/dist/sdk/runs.d.ts +6 -11
  212. package/dist/sdk/runs.js +20 -41
  213. package/dist/sdk/schema.js +3 -4
  214. package/dist/seal-key.d.ts +5 -0
  215. package/dist/seal-key.js +7 -0
  216. package/dist/secrets.d.ts +3 -0
  217. package/dist/secrets.js +16 -3
  218. package/dist/server.d.ts +55 -33
  219. package/dist/server.js +685 -320
  220. package/dist/sign-ins-store.d.ts +8 -0
  221. package/dist/sign-ins-store.js +36 -1
  222. package/dist/skills.js +1 -1
  223. package/dist/store/index.d.ts +2 -2
  224. package/dist/store/index.js +1 -1
  225. package/dist/store/journal/storage.js +3 -0
  226. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  227. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  228. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  229. package/dist/store/schema.d.ts +53 -4
  230. package/dist/store/schema.js +137 -6
  231. package/dist/store/sqlite/connection.d.ts +2 -0
  232. package/dist/store/sqlite/connection.js +3 -1
  233. package/dist/store/sqlite/run-patch.d.ts +0 -17
  234. package/dist/store/sqlite/run-patch.js +4 -33
  235. package/dist/store/sqlite/store.js +246 -63
  236. package/dist/store/sqlite/worker.js +25 -0
  237. package/dist/store/store.d.ts +193 -36
  238. package/dist/store/store.js +25 -3
  239. package/dist/store-reads/learning.d.ts +102 -204
  240. package/dist/store-reads/learning.js +159 -321
  241. package/dist/store-reads/loop.d.ts +0 -1
  242. package/dist/store-reads/loop.js +1 -1
  243. package/dist/store-view.d.ts +29 -1
  244. package/dist/store-view.js +97 -31
  245. package/dist/template-eval.d.ts +3 -6
  246. package/dist/template-eval.js +22 -36
  247. package/dist/templates.d.ts +2 -1
  248. package/dist/templates.js +6 -3
  249. package/dist/timeline/index.d.ts +1 -1
  250. package/dist/timeline/index.js +1 -1
  251. package/dist/timeline/timeline.d.ts +5 -1
  252. package/dist/timeline/timeline.js +16 -0
  253. package/dist/tool-gate.d.ts +0 -7
  254. package/dist/tool-gate.js +1 -15
  255. package/dist/tool-keys-store.d.ts +1 -1
  256. package/dist/tool-keys.d.ts +6 -4
  257. package/dist/tool-keys.js +12 -6
  258. package/dist/tools.d.ts +2 -2
  259. package/dist/tools.js +11 -4
  260. package/dist/triggers.d.ts +60 -5
  261. package/dist/triggers.js +123 -18
  262. package/dist/validate.js +1 -1
  263. package/dist/webhooks.d.ts +4 -1
  264. package/dist/webhooks.js +11 -4
  265. package/dist/workspace/agent-computer.d.ts +2 -0
  266. package/dist/workspace/agent-computer.js +2 -0
  267. package/dist/workspace/archil-claim.d.ts +7 -0
  268. package/dist/workspace/archil-claim.js +29 -0
  269. package/dist/workspace/archil.d.ts +9 -1
  270. package/dist/workspace/archil.js +165 -3
  271. package/dist/workspace/attach.d.ts +3 -1
  272. package/dist/workspace/attach.js +2 -0
  273. package/dist/workspace/attached-computers.d.ts +16 -5
  274. package/dist/workspace/attached-computers.js +25 -9
  275. package/dist/workspace/computer-deps.js +1 -1
  276. package/dist/workspace/computer-for-claim.d.ts +7 -3
  277. package/dist/workspace/computer-for-claim.js +119 -22
  278. package/dist/workspace/computer-hold.js +2 -1
  279. package/dist/workspace/computer-kept.d.ts +11 -1
  280. package/dist/workspace/computer-kept.js +24 -3
  281. package/dist/workspace/resolve-computer.d.ts +33 -19
  282. package/dist/workspace/resolve-computer.js +172 -64
  283. package/dist/workspace/revision-skills.d.ts +1 -2
  284. package/dist/workspace/revision-skills.js +3 -4
  285. package/dist/workspace/run-workspace.d.ts +1 -1
  286. package/dist/workspace/run-workspace.js +5 -0
  287. package/dist/workspace/synced-folder.d.ts +85 -0
  288. package/dist/workspace/synced-folder.js +230 -0
  289. package/dist/workspace/workspace.d.ts +4 -0
  290. package/launcher/agentrun-serve +1 -1
  291. package/package.json +10 -10
  292. package/templates/README.md +7 -7
  293. package/templates/inbound-lead/agent.md +3 -3
  294. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  295. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  296. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  297. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  298. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  299. package/templates/inbound-lead/lead.schema.json +6 -5
  300. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  301. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  302. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  303. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  304. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  305. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  306. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  307. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  308. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  309. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  310. package/dist/console/assets/index-BUktRvS-.css +0 -1
  311. package/dist/console/assets/index-nB9kTfIN.js +0 -711
  312. package/dist/learn/grade.d.ts +0 -138
  313. package/dist/learn/grade.js +0 -682
  314. package/dist/learn/notes.d.ts +0 -81
  315. package/dist/learn/notes.js +0 -178
  316. package/dist/learn/reflect.d.ts +0 -77
  317. package/dist/learn/reflect.js +0 -228
  318. package/dist/learn/relevance.d.ts +0 -24
  319. package/dist/learn/relevance.js +0 -91
  320. package/dist/learn/seed-check.d.ts +0 -74
  321. package/dist/learn/seed-check.js +0 -103
  322. package/dist/learning-batch.d.ts +0 -291
  323. package/dist/learning-batch.js +0 -600
  324. package/dist/learning-evals.d.ts +0 -35
  325. package/dist/learning-evals.js +0 -99
  326. package/dist/native/context.d.ts +0 -6
  327. package/dist/native/context.js +0 -22
  328. package/dist/propose.d.ts +0 -52
  329. package/dist/propose.js +0 -224
  330. package/dist/runner/learning-ask.d.ts +0 -47
  331. package/dist/runner/learning-ask.js +0 -128
  332. package/dist/runner/learning-dispatch.d.ts +0 -45
  333. package/dist/runner/learning-dispatch.js +0 -99
  334. package/dist/runner/learning-factory.d.ts +0 -16
  335. package/dist/runner/learning-factory.js +0 -50
  336. package/dist/runner/learning-loop.d.ts +0 -273
  337. package/dist/runner/learning-loop.js +0 -521
  338. package/dist/usage.d.ts +0 -11
  339. package/dist/usage.js +0 -11
  340. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  341. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  342. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  343. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  344. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  345. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  346. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
@@ -0,0 +1,701 @@
1
+ var NT=Object.defineProperty;var ST=(e,n,s)=>n in e?NT(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var Pt=(e,n,s)=>ST(e,typeof n!="symbol"?n+"":n,s);function CT(e,n){for(var s=0;s<n.length;s++){const r=n[s];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function s(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=s(o);fetch(o.href,i)}})();function YN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Yp={exports:{}},xc={},Qp={exports:{}},wt={};/**
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 yj;function ET(){if(yj)return wt;yj=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.iterator;function v(I){return I===null||typeof I!="object"?null:(I=y&&I[y]||I["@@iterator"],typeof I=="function"?I:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,b={};function j(I,V,J){this.props=I,this.context=V,this.refs=b,this.updater=J||h}j.prototype.isReactComponent={},j.prototype.setState=function(I,V){if(typeof I!="object"&&typeof I!="function"&&I!=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,I,V,"setState")},j.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function k(){}k.prototype=j.prototype;function E(I,V,J){this.props=I,this.context=V,this.refs=b,this.updater=J||h}var N=E.prototype=new k;N.constructor=E,x(N,j.prototype),N.isPureReactComponent=!0;var S=Array.isArray,$=Object.prototype.hasOwnProperty,_={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function M(I,V,J){var X,re={},ae=null,ye=null;if(V!=null)for(X in V.ref!==void 0&&(ye=V.ref),V.key!==void 0&&(ae=""+V.key),V)$.call(V,X)&&!O.hasOwnProperty(X)&&(re[X]=V[X]);var he=arguments.length-2;if(he===1)re.children=J;else if(1<he){for(var we=Array(he),ze=0;ze<he;ze++)we[ze]=arguments[ze+2];re.children=we}if(I&&I.defaultProps)for(X in he=I.defaultProps,he)re[X]===void 0&&(re[X]=he[X]);return{$$typeof:e,type:I,key:ae,ref:ye,props:re,_owner:_.current}}function P(I,V){return{$$typeof:e,type:I.type,key:V,ref:I.ref,props:I.props,_owner:I._owner}}function A(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function R(I){var V={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(J){return V[J]})}var L=/\/+/g;function W(I,V){return typeof I=="object"&&I!==null&&I.key!=null?R(""+I.key):V.toString(36)}function U(I,V,J,X,re){var ae=typeof I;(ae==="undefined"||ae==="boolean")&&(I=null);var ye=!1;if(I===null)ye=!0;else switch(ae){case"string":case"number":ye=!0;break;case"object":switch(I.$$typeof){case e:case n:ye=!0}}if(ye)return ye=I,re=re(ye),I=X===""?"."+W(ye,0):X,S(re)?(J="",I!=null&&(J=I.replace(L,"$&/")+"/"),U(re,V,J,"",function(ze){return ze})):re!=null&&(A(re)&&(re=P(re,J+(!re.key||ye&&ye.key===re.key?"":(""+re.key).replace(L,"$&/")+"/")+I)),V.push(re)),1;if(ye=0,X=X===""?".":X+":",S(I))for(var he=0;he<I.length;he++){ae=I[he];var we=X+W(ae,he);ye+=U(ae,V,J,we,re)}else if(we=v(I),typeof we=="function")for(I=we.call(I),he=0;!(ae=I.next()).done;)ae=ae.value,we=X+W(ae,he++),ye+=U(ae,V,J,we,re);else if(ae==="object")throw V=String(I),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.");return ye}function Y(I,V,J){if(I==null)return I;var X=[],re=0;return U(I,X,"","",function(ae){return V.call(J,ae,re++)}),X}function D(I){if(I._status===-1){var V=I._result;V=V(),V.then(function(J){(I._status===0||I._status===-1)&&(I._status=1,I._result=J)},function(J){(I._status===0||I._status===-1)&&(I._status=2,I._result=J)}),I._status===-1&&(I._status=0,I._result=V)}if(I._status===1)return I._result.default;throw I._result}var G={current:null},F={transition:null},q={ReactCurrentDispatcher:G,ReactCurrentBatchConfig:F,ReactCurrentOwner:_};function H(){throw Error("act(...) is not supported in production builds of React.")}return wt.Children={map:Y,forEach:function(I,V,J){Y(I,function(){V.apply(this,arguments)},J)},count:function(I){var V=0;return Y(I,function(){V++}),V},toArray:function(I){return Y(I,function(V){return V})||[]},only:function(I){if(!A(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},wt.Component=j,wt.Fragment=s,wt.Profiler=o,wt.PureComponent=E,wt.StrictMode=r,wt.Suspense=u,wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,wt.act=H,wt.cloneElement=function(I,V,J){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var X=x({},I.props),re=I.key,ae=I.ref,ye=I._owner;if(V!=null){if(V.ref!==void 0&&(ae=V.ref,ye=_.current),V.key!==void 0&&(re=""+V.key),I.type&&I.type.defaultProps)var he=I.type.defaultProps;for(we in V)$.call(V,we)&&!O.hasOwnProperty(we)&&(X[we]=V[we]===void 0&&he!==void 0?he[we]:V[we])}var we=arguments.length-2;if(we===1)X.children=J;else if(1<we){he=Array(we);for(var ze=0;ze<we;ze++)he[ze]=arguments[ze+2];X.children=he}return{$$typeof:e,type:I.type,key:re,ref:ae,props:X,_owner:ye}},wt.createContext=function(I){return I={$$typeof:c,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:i,_context:I},I.Consumer=I},wt.createElement=M,wt.createFactory=function(I){var V=M.bind(null,I);return V.type=I,V},wt.createRef=function(){return{current:null}},wt.forwardRef=function(I){return{$$typeof:d,render:I}},wt.isValidElement=A,wt.lazy=function(I){return{$$typeof:g,_payload:{_status:-1,_result:I},_init:D}},wt.memo=function(I,V){return{$$typeof:f,type:I,compare:V===void 0?null:V}},wt.startTransition=function(I){var V=F.transition;F.transition={};try{I()}finally{F.transition=V}},wt.unstable_act=H,wt.useCallback=function(I,V){return G.current.useCallback(I,V)},wt.useContext=function(I){return G.current.useContext(I)},wt.useDebugValue=function(){},wt.useDeferredValue=function(I){return G.current.useDeferredValue(I)},wt.useEffect=function(I,V){return G.current.useEffect(I,V)},wt.useId=function(){return G.current.useId()},wt.useImperativeHandle=function(I,V,J){return G.current.useImperativeHandle(I,V,J)},wt.useInsertionEffect=function(I,V){return G.current.useInsertionEffect(I,V)},wt.useLayoutEffect=function(I,V){return G.current.useLayoutEffect(I,V)},wt.useMemo=function(I,V){return G.current.useMemo(I,V)},wt.useReducer=function(I,V,J){return G.current.useReducer(I,V,J)},wt.useRef=function(I){return G.current.useRef(I)},wt.useState=function(I){return G.current.useState(I)},wt.useSyncExternalStore=function(I,V,J){return G.current.useSyncExternalStore(I,V,J)},wt.useTransition=function(){return G.current.useTransition()},wt.version="18.3.1",wt}var wj;function Sm(){return wj||(wj=1,Qp.exports=ET()),Qp.exports}/**
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 jj;function $T(){if(jj)return xc;jj=1;var e=Sm(),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(d,u,f){var g,y={},v=null,h=null;f!==void 0&&(v=""+f),u.key!==void 0&&(v=""+u.key),u.ref!==void 0&&(h=u.ref);for(g in u)r.call(u,g)&&!i.hasOwnProperty(g)&&(y[g]=u[g]);if(d&&d.defaultProps)for(g in u=d.defaultProps,u)y[g]===void 0&&(y[g]=u[g]);return{$$typeof:n,type:d,key:v,ref:h,props:y,_owner:o.current}}return xc.Fragment=s,xc.jsx=c,xc.jsxs=c,xc}var kj;function _T(){return kj||(kj=1,Yp.exports=$T()),Yp.exports}var t=_T(),p=Sm();const Be=YN(p),Bg=CT({__proto__:null,default:Be},[p]);var nf={},Jp={exports:{}},ps={},Xp={exports:{}},Zp={};/**
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
+ */var Nj;function TT(){return Nj||(Nj=1,(function(e){function n(F,q){var H=F.length;F.push(q);e:for(;0<H;){var I=H-1>>>1,V=F[I];if(0<o(V,q))F[I]=q,F[H]=V,H=I;else break e}}function s(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var q=F[0],H=F.pop();if(H!==q){F[0]=H;e:for(var I=0,V=F.length,J=V>>>1;I<J;){var X=2*(I+1)-1,re=F[X],ae=X+1,ye=F[ae];if(0>o(re,H))ae<V&&0>o(ye,re)?(F[I]=ye,F[ae]=H,I=ae):(F[I]=re,F[X]=H,I=X);else if(ae<V&&0>o(ye,H))F[I]=ye,F[ae]=H,I=ae;else break e}}return q}function o(F,q){var H=F.sortIndex-q.sortIndex;return H!==0?H:F.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var u=[],f=[],g=1,y=null,v=3,h=!1,x=!1,b=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(F){for(var q=s(f);q!==null;){if(q.callback===null)r(f);else if(q.startTime<=F)r(f),q.sortIndex=q.expirationTime,n(u,q);else break;q=s(f)}}function S(F){if(b=!1,N(F),!x)if(s(u)!==null)x=!0,D($);else{var q=s(f);q!==null&&G(S,q.startTime-F)}}function $(F,q){x=!1,b&&(b=!1,k(M),M=-1),h=!0;var H=v;try{for(N(q),y=s(u);y!==null&&(!(y.expirationTime>q)||F&&!R());){var I=y.callback;if(typeof I=="function"){y.callback=null,v=y.priorityLevel;var V=I(y.expirationTime<=q);q=e.unstable_now(),typeof V=="function"?y.callback=V:y===s(u)&&r(u),N(q)}else r(u);y=s(u)}if(y!==null)var J=!0;else{var X=s(f);X!==null&&G(S,X.startTime-q),J=!1}return J}finally{y=null,v=H,h=!1}}var _=!1,O=null,M=-1,P=5,A=-1;function R(){return!(e.unstable_now()-A<P)}function L(){if(O!==null){var F=e.unstable_now();A=F;var q=!0;try{q=O(!0,F)}finally{q?W():(_=!1,O=null)}}else _=!1}var W;if(typeof E=="function")W=function(){E(L)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,Y=U.port2;U.port1.onmessage=L,W=function(){Y.postMessage(null)}}else W=function(){j(L,0)};function D(F){O=F,_||(_=!0,W())}function G(F,q){M=j(function(){F(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(F){F.callback=null},e.unstable_continueExecution=function(){x||h||(x=!0,D($))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(F){switch(v){case 1:case 2:case 3:var q=3;break;default:q=v}var H=v;v=q;try{return F()}finally{v=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,q){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var H=v;v=F;try{return q()}finally{v=H}},e.unstable_scheduleCallback=function(F,q,H){var I=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?I+H:I):H=I,F){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=H+V,F={id:g++,callback:q,priorityLevel:F,startTime:H,expirationTime:V,sortIndex:-1},H>I?(F.sortIndex=H,n(f,F),s(u)===null&&F===s(f)&&(b?(k(M),M=-1):b=!0,G(S,H-I))):(F.sortIndex=V,n(u,F),x||h||(x=!0,D($))),F},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(F){var q=v;return function(){var H=v;v=q;try{return F.apply(this,arguments)}finally{v=H}}}})(Zp)),Zp}var Sj;function RT(){return Sj||(Sj=1,Xp.exports=TT()),Xp.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 Cj;function AT(){if(Cj)return ps;Cj=1;var e=Sm(),n=RT();function s(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,m=1;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(o[a]=l,a=0;a<l.length;a++)r.add(l[a])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[: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]*$/,g={},y={};function v(a){return u.call(y,a)?!0:u.call(g,a)?!1:f.test(a)?y[a]=!0:(g[a]=!0,!1)}function h(a,l,m,w){if(m!==null&&m.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return w?!1:m!==null?!m.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function x(a,l,m,w){if(l===null||typeof l>"u"||h(a,l,m,w))return!0;if(w)return!1;if(m!==null)switch(m.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function b(a,l,m,w,C,T,z){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=w,this.attributeNamespace=C,this.mustUseProperty=m,this.propertyName=a,this.type=l,this.sanitizeURL=T,this.removeEmptyString=z}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){j[a]=new b(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];j[l]=new b(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){j[a]=new b(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){j[a]=new b(a,2,!1,a,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(a){j[a]=new b(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){j[a]=new b(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){j[a]=new b(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){j[a]=new b(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){j[a]=new b(a,5,!1,a.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function E(a){return a[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(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!1,!1)}),j.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!0,!0)});function N(a,l,m,w){var C=j.hasOwnProperty(l)?j[l]:null;(C!==null?C.type!==0:w||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(x(l,m,C,w)&&(m=null),w||C===null?v(l)&&(m===null?a.removeAttribute(l):a.setAttribute(l,""+m)):C.mustUseProperty?a[C.propertyName]=m===null?C.type===3?!1:"":m:(l=C.attributeName,w=C.attributeNamespace,m===null?a.removeAttribute(l):(C=C.type,m=C===3||C===4&&m===!0?"":""+m,w?a.setAttributeNS(w,l,m):a.setAttribute(l,m))))}var S=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),_=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),A=Symbol.for("react.provider"),R=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),G=Symbol.for("react.offscreen"),F=Symbol.iterator;function q(a){return a===null||typeof a!="object"?null:(a=F&&a[F]||a["@@iterator"],typeof a=="function"?a:null)}var H=Object.assign,I;function V(a){if(I===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);I=l&&l[1]||""}return`
34
+ `+I+a}var J=!1;function X(a,l){if(!a||J)return"";J=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ue){var w=ue}Reflect.construct(a,[],l)}else{try{l.call()}catch(ue){w=ue}a.call(l.prototype)}else{try{throw Error()}catch(ue){w=ue}a()}}catch(ue){if(ue&&w&&typeof ue.stack=="string"){for(var C=ue.stack.split(`
35
+ `),T=w.stack.split(`
36
+ `),z=C.length-1,K=T.length-1;1<=z&&0<=K&&C[z]!==T[K];)K--;for(;1<=z&&0<=K;z--,K--)if(C[z]!==T[K]){if(z!==1||K!==1)do if(z--,K--,0>K||C[z]!==T[K]){var ee=`
37
+ `+C[z].replace(" at new "," at ");return a.displayName&&ee.includes("<anonymous>")&&(ee=ee.replace("<anonymous>",a.displayName)),ee}while(1<=z&&0<=K);break}}}finally{J=!1,Error.prepareStackTrace=m}return(a=a?a.displayName||a.name:"")?V(a):""}function re(a){switch(a.tag){case 5:return V(a.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return a=X(a.type,!1),a;case 11:return a=X(a.type.render,!1),a;case 1:return a=X(a.type,!0),a;default:return""}}function ae(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case O:return"Fragment";case _:return"Portal";case P:return"Profiler";case M:return"StrictMode";case W:return"Suspense";case U:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case R:return(a.displayName||"Context")+".Consumer";case A:return(a._context.displayName||"Context")+".Provider";case L:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case Y:return l=a.displayName||null,l!==null?l:ae(a.type)||"Memo";case D:l=a._payload,a=a._init;try{return ae(a(l))}catch{}}return null}function ye(a){var l=a.type;switch(a.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=l.render,a=a.displayName||a.name||"",l.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ae(l);case 8:return l===M?"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 l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function he(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function we(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function ze(a){var l=we(a)?"checked":"value",m=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),w=""+a[l];if(!a.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var C=m.get,T=m.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return C.call(this)},set:function(z){w=""+z,T.call(this,z)}}),Object.defineProperty(a,l,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(z){w=""+z},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function le(a){a._valueTracker||(a._valueTracker=ze(a))}function me(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var m=l.getValue(),w="";return a&&(w=we(a)?a.checked?"true":"false":a.value),a=w,a!==m?(l.setValue(a),!0):!1}function Ke(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function be(a,l){var m=l.checked;return H({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??a._wrapperState.initialChecked})}function ge(a,l){var m=l.defaultValue==null?"":l.defaultValue,w=l.checked!=null?l.checked:l.defaultChecked;m=he(l.value!=null?l.value:m),a._wrapperState={initialChecked:w,initialValue:m,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Je(a,l){l=l.checked,l!=null&&N(a,"checked",l,!1)}function tt(a,l){Je(a,l);var m=he(l.value),w=l.type;if(m!=null)w==="number"?(m===0&&a.value===""||a.value!=m)&&(a.value=""+m):a.value!==""+m&&(a.value=""+m);else if(w==="submit"||w==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?ve(a,l.type,m):l.hasOwnProperty("defaultValue")&&ve(a,l.type,he(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function ft(a,l,m){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var w=l.type;if(!(w!=="submit"&&w!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+a._wrapperState.initialValue,m||l===a.value||(a.value=l),a.defaultValue=l}m=a.name,m!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,m!==""&&(a.name=m)}function ve(a,l,m){(l!=="number"||Ke(a.ownerDocument)!==a)&&(m==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+m&&(a.defaultValue=""+m))}var Ee=Array.isArray;function Q(a,l,m,w){if(a=a.options,l){l={};for(var C=0;C<m.length;C++)l["$"+m[C]]=!0;for(m=0;m<a.length;m++)C=l.hasOwnProperty("$"+a[m].value),a[m].selected!==C&&(a[m].selected=C),C&&w&&(a[m].defaultSelected=!0)}else{for(m=""+he(m),l=null,C=0;C<a.length;C++){if(a[C].value===m){a[C].selected=!0,w&&(a[C].defaultSelected=!0);return}l!==null||a[C].disabled||(l=a[C])}l!==null&&(l.selected=!0)}}function Me(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(s(91));return H({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function pe(a,l){var m=l.value;if(m==null){if(m=l.children,l=l.defaultValue,m!=null){if(l!=null)throw Error(s(92));if(Ee(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),m=l}a._wrapperState={initialValue:he(m)}}function ne(a,l){var m=he(l.value),w=he(l.defaultValue);m!=null&&(m=""+m,m!==a.value&&(a.value=m),l.defaultValue==null&&a.defaultValue!==m&&(a.defaultValue=m)),w!=null&&(a.defaultValue=""+w)}function Ae(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function Pe(a){switch(a){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 bt(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?Pe(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var ot,mt=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,m,w,C){MSApp.execUnsafeLocalFunction(function(){return a(l,m,w,C)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for(ot=ot||document.createElement("div"),ot.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=ot.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function Re(a,l){if(l){var m=a.firstChild;if(m&&m===a.lastChild&&m.nodeType===3){m.nodeValue=l;return}}a.textContent=l}var lt={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},$t=["Webkit","ms","Moz","O"];Object.keys(lt).forEach(function(a){$t.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),lt[l]=lt[a]})});function nt(a,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||lt.hasOwnProperty(a)&&lt[a]?(""+l).trim():l+"px"}function fe(a,l){a=a.style;for(var m in l)if(l.hasOwnProperty(m)){var w=m.indexOf("--")===0,C=nt(m,l[m],w);m==="float"&&(m="cssFloat"),w?a.setProperty(m,C):a[m]=C}}var st=H({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 Qe(a,l){if(l){if(st[a]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(s(137,a));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(s(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(s(61))}if(l.style!=null&&typeof l.style!="object")throw Error(s(62))}}function ct(a,l){if(a.indexOf("-")===-1)return typeof l.is=="string";switch(a){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 gt=null;function Et(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var se=null,$e=null,Fe=null;function et(a){if(a=nc(a)){if(typeof se!="function")throw Error(s(280));var l=a.stateNode;l&&(l=xu(l),se(a.stateNode,a.type,l))}}function Dt(a){$e?Fe?Fe.push(a):Fe=[a]:$e=a}function Le(){if($e){var a=$e,l=Fe;if(Fe=$e=null,et(a),l)for(a=0;a<l.length;a++)et(l[a])}}function rt(a,l){return a(l)}function Ft(){}var jn=!1;function Rt(a,l,m){if(jn)return a(l,m);jn=!0;try{return rt(a,l,m)}finally{jn=!1,($e!==null||Fe!==null)&&(Ft(),Le())}}function Un(a,l){var m=a.stateNode;if(m===null)return null;var w=xu(m);if(w===null)return null;m=w[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(a=a.type,w=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!w;break e;default:a=!1}if(a)return null;if(m&&typeof m!="function")throw Error(s(231,l,typeof m));return m}var ys=!1;if(d)try{var ws={};Object.defineProperty(ws,"passive",{get:function(){ys=!0}}),window.addEventListener("test",ws,ws),window.removeEventListener("test",ws,ws)}catch{ys=!1}function Z(a,l,m,w,C,T,z,K,ee){var ue=Array.prototype.slice.call(arguments,3);try{l.apply(m,ue)}catch(ke){this.onError(ke)}}var Ie=!1,ht=null,Ct=!1,Ht=null,xn={onError:function(a){Ie=!0,ht=a}};function tn(a,l,m,w,C,T,z,K,ee){Ie=!1,ht=null,Z.apply(xn,arguments)}function vn(a,l,m,w,C,T,z,K,ee){if(tn.apply(this,arguments),Ie){if(Ie){var ue=ht;Ie=!1,ht=null}else throw Error(s(198));Ct||(Ct=!0,Ht=ue)}}function ls(a){var l=a,m=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(m=l.return),a=l.return;while(a)}return l.tag===3?m:null}function yr(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function wr(a){if(ls(a)!==a)throw Error(s(188))}function Ur(a){var l=a.alternate;if(!l){if(l=ls(a),l===null)throw Error(s(188));return l!==a?null:a}for(var m=a,w=l;;){var C=m.return;if(C===null)break;var T=C.alternate;if(T===null){if(w=C.return,w!==null){m=w;continue}break}if(C.child===T.child){for(T=C.child;T;){if(T===m)return wr(C),a;if(T===w)return wr(C),l;T=T.sibling}throw Error(s(188))}if(m.return!==w.return)m=C,w=T;else{for(var z=!1,K=C.child;K;){if(K===m){z=!0,m=C,w=T;break}if(K===w){z=!0,w=C,m=T;break}K=K.sibling}if(!z){for(K=T.child;K;){if(K===m){z=!0,m=T,w=C;break}if(K===w){z=!0,w=T,m=C;break}K=K.sibling}if(!z)throw Error(s(189))}}if(m.alternate!==w)throw Error(s(190))}if(m.tag!==3)throw Error(s(188));return m.stateNode.current===m?a:l}function Ze(a){return a=Ur(a),a!==null?ie(a):null}function ie(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=ie(a);if(l!==null)return l;a=a.sibling}return null}var _e=n.unstable_scheduleCallback,qe=n.unstable_cancelCallback,Lt=n.unstable_shouldYield,Bt=n.unstable_requestPaint,pt=n.unstable_now,En=n.unstable_getCurrentPriorityLevel,Ln=n.unstable_ImmediatePriority,jr=n.unstable_UserBlockingPriority,Kt=n.unstable_NormalPriority,hi=n.unstable_LowPriority,mo=n.unstable_IdlePriority,pa=null,js=null;function Jd(a){if(js&&typeof js.onCommitFiberRoot=="function")try{js.onCommitFiberRoot(pa,a,void 0,(a.current.flags&128)===128)}catch{}}var cs=Math.clz32?Math.clz32:eu,Xd=Math.log,Zd=Math.LN2;function eu(a){return a>>>=0,a===0?32:31-(Xd(a)/Zd|0)|0}var ga=64,xa=4194304;function ho(a){switch(a&-a){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 a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function va(a,l){var m=a.pendingLanes;if(m===0)return 0;var w=0,C=a.suspendedLanes,T=a.pingedLanes,z=m&268435455;if(z!==0){var K=z&~C;K!==0?w=ho(K):(T&=z,T!==0&&(w=ho(T)))}else z=m&~C,z!==0?w=ho(z):T!==0&&(w=ho(T));if(w===0)return 0;if(l!==0&&l!==w&&(l&C)===0&&(C=w&-w,T=l&-l,C>=T||C===16&&(T&4194240)!==0))return l;if((w&4)!==0&&(w|=m&16),l=a.entangledLanes,l!==0)for(a=a.entanglements,l&=w;0<l;)m=31-cs(l),C=1<<m,w|=a[m],l&=~C;return w}function tu(a,l){switch(a){case 1:case 2:case 4:return l+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 l+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 nu(a,l){for(var m=a.suspendedLanes,w=a.pingedLanes,C=a.expirationTimes,T=a.pendingLanes;0<T;){var z=31-cs(T),K=1<<z,ee=C[z];ee===-1?((K&m)===0||(K&w)!==0)&&(C[z]=tu(K,l)):ee<=l&&(a.expiredLanes|=K),T&=~K}}function pi(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Dl(){var a=ga;return ga<<=1,(ga&4194240)===0&&(ga=64),a}function gi(a){for(var l=[],m=0;31>m;m++)l.push(a);return l}function po(a,l,m){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-cs(l),a[l]=m}function su(a,l){var m=a.pendingLanes&~l;a.pendingLanes=l,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=l,a.mutableReadLanes&=l,a.entangledLanes&=l,l=a.entanglements;var w=a.eventTimes;for(a=a.expirationTimes;0<m;){var C=31-cs(m),T=1<<C;l[C]=0,w[C]=-1,a[C]=-1,m&=~T}}function xi(a,l){var m=a.entangledLanes|=l;for(a=a.entanglements;m;){var w=31-cs(m),C=1<<w;C&l|a[w]&l&&(a[w]|=l),m&=~C}}var At=0;function Fl(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var Ul,vi,Wl,Hl,Bl,bi=!1,ba=[],Zs=null,er=null,tr=null,go=new Map,xe=new Map,Ce=[],He="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 _t(a,l){switch(a){case"focusin":case"focusout":Zs=null;break;case"dragenter":case"dragleave":er=null;break;case"mouseover":case"mouseout":tr=null;break;case"pointerover":case"pointerout":go.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":xe.delete(l.pointerId)}}function yt(a,l,m,w,C,T){return a===null||a.nativeEvent!==T?(a={blockedOn:l,domEventName:m,eventSystemFlags:w,nativeEvent:T,targetContainers:[C]},l!==null&&(l=nc(l),l!==null&&vi(l)),a):(a.eventSystemFlags|=w,l=a.targetContainers,C!==null&&l.indexOf(C)===-1&&l.push(C),a)}function kr(a,l,m,w,C){switch(l){case"focusin":return Zs=yt(Zs,a,l,m,w,C),!0;case"dragenter":return er=yt(er,a,l,m,w,C),!0;case"mouseover":return tr=yt(tr,a,l,m,w,C),!0;case"pointerover":var T=C.pointerId;return go.set(T,yt(go.get(T)||null,a,l,m,w,C)),!0;case"gotpointercapture":return T=C.pointerId,xe.set(T,yt(xe.get(T)||null,a,l,m,w,C)),!0}return!1}function Wn(a){var l=ja(a.target);if(l!==null){var m=ls(l);if(m!==null){if(l=m.tag,l===13){if(l=yr(m),l!==null){a.blockedOn=l,Bl(a.priority,function(){Wl(m)});return}}else if(l===3&&m.stateNode.current.memoizedState.isDehydrated){a.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Pn(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var m=jh(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(m===null){m=a.nativeEvent;var w=new m.constructor(m.type,m);gt=w,m.target.dispatchEvent(w),gt=null}else return l=nc(m),l!==null&&vi(l),a.blockedOn=m,!1;l.shift()}return!0}function ru(a,l,m){Pn(a)&&m.delete(l)}function xo(){bi=!1,Zs!==null&&Pn(Zs)&&(Zs=null),er!==null&&Pn(er)&&(er=null),tr!==null&&Pn(tr)&&(tr=null),go.forEach(ru),xe.forEach(ru)}function ya(a,l){a.blockedOn===l&&(a.blockedOn=null,bi||(bi=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,xo)))}function vo(a){function l(C){return ya(C,a)}if(0<ba.length){ya(ba[0],a);for(var m=1;m<ba.length;m++){var w=ba[m];w.blockedOn===a&&(w.blockedOn=null)}}for(Zs!==null&&ya(Zs,a),er!==null&&ya(er,a),tr!==null&&ya(tr,a),go.forEach(l),xe.forEach(l),m=0;m<Ce.length;m++)w=Ce[m],w.blockedOn===a&&(w.blockedOn=null);for(;0<Ce.length&&(m=Ce[0],m.blockedOn===null);)Wn(m),m.blockedOn===null&&Ce.shift()}var Wr=S.ReactCurrentBatchConfig,wa=!0;function yi(a,l,m,w){var C=At,T=Wr.transition;Wr.transition=null;try{At=1,Ms(a,l,m,w)}finally{At=C,Wr.transition=T}}function bo(a,l,m,w){var C=At,T=Wr.transition;Wr.transition=null;try{At=4,Ms(a,l,m,w)}finally{At=C,Wr.transition=T}}function Ms(a,l,m,w){if(wa){var C=jh(a,l,m,w);if(C===null)Dh(a,l,w,ou,m),_t(a,w);else if(kr(C,a,l,m,w))w.stopPropagation();else if(_t(a,w),l&4&&-1<He.indexOf(a)){for(;C!==null;){var T=nc(C);if(T!==null&&Ul(T),T=jh(a,l,m,w),T===null&&Dh(a,l,w,ou,m),T===C)break;C=T}C!==null&&w.stopPropagation()}else Dh(a,l,w,null,m)}}var ou=null;function jh(a,l,m,w){if(ou=null,a=Et(w),a=ja(a),a!==null)if(l=ls(a),l===null)a=null;else if(m=l.tag,m===13){if(a=yr(l),a!==null)return a;a=null}else if(m===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return ou=a,null}function ay(a){switch(a){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(En()){case Ln:return 1;case jr:return 4;case Kt:case hi:return 16;case mo:return 536870912;default:return 16}default:return 16}}var yo=null,kh=null,au=null;function iy(){if(au)return au;var a,l=kh,m=l.length,w,C="value"in yo?yo.value:yo.textContent,T=C.length;for(a=0;a<m&&l[a]===C[a];a++);var z=m-a;for(w=1;w<=z&&l[m-w]===C[T-w];w++);return au=C.slice(a,1<w?1-w:void 0)}function iu(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function lu(){return!0}function ly(){return!1}function ks(a){function l(m,w,C,T,z){this._reactName=m,this._targetInst=C,this.type=w,this.nativeEvent=T,this.target=z,this.currentTarget=null;for(var K in a)a.hasOwnProperty(K)&&(m=a[K],this[K]=m?m(T):T[K]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?lu:ly,this.isPropagationStopped=ly,this}return H(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=lu)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=lu)},persist:function(){},isPersistent:lu}),l}var wi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Nh=ks(wi),ql=H({},wi,{view:0,detail:0}),J$=ks(ql),Sh,Ch,Gl,cu=H({},ql,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:$h,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Gl&&(Gl&&a.type==="mousemove"?(Sh=a.screenX-Gl.screenX,Ch=a.screenY-Gl.screenY):Ch=Sh=0,Gl=a),Sh)},movementY:function(a){return"movementY"in a?a.movementY:Ch}}),cy=ks(cu),X$=H({},cu,{dataTransfer:0}),Z$=ks(X$),e_=H({},ql,{relatedTarget:0}),Eh=ks(e_),t_=H({},wi,{animationName:0,elapsedTime:0,pseudoElement:0}),n_=ks(t_),s_=H({},wi,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),r_=ks(s_),o_=H({},wi,{data:0}),dy=ks(o_),a_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},i_={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"},l_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function c_(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=l_[a])?!!l[a]:!1}function $h(){return c_}var d_=H({},ql,{key:function(a){if(a.key){var l=a_[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=iu(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?i_[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$h,charCode:function(a){return a.type==="keypress"?iu(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?iu(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),u_=ks(d_),f_=H({},cu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),uy=ks(f_),m_=H({},ql,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$h}),h_=ks(m_),p_=H({},wi,{propertyName:0,elapsedTime:0,pseudoElement:0}),g_=ks(p_),x_=H({},cu,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),v_=ks(x_),b_=[9,13,27,32],_h=d&&"CompositionEvent"in window,Kl=null;d&&"documentMode"in document&&(Kl=document.documentMode);var y_=d&&"TextEvent"in window&&!Kl,fy=d&&(!_h||Kl&&8<Kl&&11>=Kl),my=" ",hy=!1;function py(a,l){switch(a){case"keyup":return b_.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gy(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var ji=!1;function w_(a,l){switch(a){case"compositionend":return gy(l);case"keypress":return l.which!==32?null:(hy=!0,my);case"textInput":return a=l.data,a===my&&hy?null:a;default:return null}}function j_(a,l){if(ji)return a==="compositionend"||!_h&&py(a,l)?(a=iy(),au=kh=yo=null,ji=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return fy&&l.locale!=="ko"?null:l.data;default:return null}}var k_={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 xy(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!k_[a.type]:l==="textarea"}function vy(a,l,m,w){Dt(w),l=hu(l,"onChange"),0<l.length&&(m=new Nh("onChange","change",null,m,w),a.push({event:m,listeners:l}))}var Vl=null,Yl=null;function N_(a){Py(a,0)}function du(a){var l=Ei(a);if(me(l))return a}function S_(a,l){if(a==="change")return l}var by=!1;if(d){var Th;if(d){var Rh="oninput"in document;if(!Rh){var yy=document.createElement("div");yy.setAttribute("oninput","return;"),Rh=typeof yy.oninput=="function"}Th=Rh}else Th=!1;by=Th&&(!document.documentMode||9<document.documentMode)}function wy(){Vl&&(Vl.detachEvent("onpropertychange",jy),Yl=Vl=null)}function jy(a){if(a.propertyName==="value"&&du(Yl)){var l=[];vy(l,Yl,a,Et(a)),Rt(N_,l)}}function C_(a,l,m){a==="focusin"?(wy(),Vl=l,Yl=m,Vl.attachEvent("onpropertychange",jy)):a==="focusout"&&wy()}function E_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return du(Yl)}function $_(a,l){if(a==="click")return du(l)}function __(a,l){if(a==="input"||a==="change")return du(l)}function T_(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var nr=typeof Object.is=="function"?Object.is:T_;function Ql(a,l){if(nr(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var m=Object.keys(a),w=Object.keys(l);if(m.length!==w.length)return!1;for(w=0;w<m.length;w++){var C=m[w];if(!u.call(l,C)||!nr(a[C],l[C]))return!1}return!0}function ky(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Ny(a,l){var m=ky(a);a=0;for(var w;m;){if(m.nodeType===3){if(w=a+m.textContent.length,a<=l&&w>=l)return{node:m,offset:l-a};a=w}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=ky(m)}}function Sy(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?Sy(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Cy(){for(var a=window,l=Ke();l instanceof a.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)a=l.contentWindow;else break;l=Ke(a.document)}return l}function Ah(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}function R_(a){var l=Cy(),m=a.focusedElem,w=a.selectionRange;if(l!==m&&m&&m.ownerDocument&&Sy(m.ownerDocument.documentElement,m)){if(w!==null&&Ah(m)){if(l=w.start,a=w.end,a===void 0&&(a=l),"selectionStart"in m)m.selectionStart=l,m.selectionEnd=Math.min(a,m.value.length);else if(a=(l=m.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var C=m.textContent.length,T=Math.min(w.start,C);w=w.end===void 0?T:Math.min(w.end,C),!a.extend&&T>w&&(C=w,w=T,T=C),C=Ny(m,T);var z=Ny(m,w);C&&z&&(a.rangeCount!==1||a.anchorNode!==C.node||a.anchorOffset!==C.offset||a.focusNode!==z.node||a.focusOffset!==z.offset)&&(l=l.createRange(),l.setStart(C.node,C.offset),a.removeAllRanges(),T>w?(a.addRange(l),a.extend(z.node,z.offset)):(l.setEnd(z.node,z.offset),a.addRange(l)))}}for(l=[],a=m;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<l.length;m++)a=l[m],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var A_=d&&"documentMode"in document&&11>=document.documentMode,ki=null,Oh=null,Jl=null,Mh=!1;function Ey(a,l,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Mh||ki==null||ki!==Ke(w)||(w=ki,"selectionStart"in w&&Ah(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Jl&&Ql(Jl,w)||(Jl=w,w=hu(Oh,"onSelect"),0<w.length&&(l=new Nh("onSelect","select",null,l,m),a.push({event:l,listeners:w}),l.target=ki)))}function uu(a,l){var m={};return m[a.toLowerCase()]=l.toLowerCase(),m["Webkit"+a]="webkit"+l,m["Moz"+a]="moz"+l,m}var Ni={animationend:uu("Animation","AnimationEnd"),animationiteration:uu("Animation","AnimationIteration"),animationstart:uu("Animation","AnimationStart"),transitionend:uu("Transition","TransitionEnd")},Lh={},$y={};d&&($y=document.createElement("div").style,"AnimationEvent"in window||(delete Ni.animationend.animation,delete Ni.animationiteration.animation,delete Ni.animationstart.animation),"TransitionEvent"in window||delete Ni.transitionend.transition);function fu(a){if(Lh[a])return Lh[a];if(!Ni[a])return a;var l=Ni[a],m;for(m in l)if(l.hasOwnProperty(m)&&m in $y)return Lh[a]=l[m];return a}var _y=fu("animationend"),Ty=fu("animationiteration"),Ry=fu("animationstart"),Ay=fu("transitionend"),Oy=new Map,My="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 wo(a,l){Oy.set(a,l),i(l,[a])}for(var Ph=0;Ph<My.length;Ph++){var Ih=My[Ph],O_=Ih.toLowerCase(),M_=Ih[0].toUpperCase()+Ih.slice(1);wo(O_,"on"+M_)}wo(_y,"onAnimationEnd"),wo(Ty,"onAnimationIteration"),wo(Ry,"onAnimationStart"),wo("dblclick","onDoubleClick"),wo("focusin","onFocus"),wo("focusout","onBlur"),wo(Ay,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),L_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Xl));function Ly(a,l,m){var w=a.type||"unknown-event";a.currentTarget=m,vn(w,l,void 0,a),a.currentTarget=null}function Py(a,l){l=(l&4)!==0;for(var m=0;m<a.length;m++){var w=a[m],C=w.event;w=w.listeners;e:{var T=void 0;if(l)for(var z=w.length-1;0<=z;z--){var K=w[z],ee=K.instance,ue=K.currentTarget;if(K=K.listener,ee!==T&&C.isPropagationStopped())break e;Ly(C,K,ue),T=ee}else for(z=0;z<w.length;z++){if(K=w[z],ee=K.instance,ue=K.currentTarget,K=K.listener,ee!==T&&C.isPropagationStopped())break e;Ly(C,K,ue),T=ee}}}if(Ct)throw a=Ht,Ct=!1,Ht=null,a}function Vt(a,l){var m=l[qh];m===void 0&&(m=l[qh]=new Set);var w=a+"__bubble";m.has(w)||(Iy(l,a,2,!1),m.add(w))}function zh(a,l,m){var w=0;l&&(w|=4),Iy(m,a,w,l)}var mu="_reactListening"+Math.random().toString(36).slice(2);function Zl(a){if(!a[mu]){a[mu]=!0,r.forEach(function(m){m!=="selectionchange"&&(L_.has(m)||zh(m,!1,a),zh(m,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[mu]||(l[mu]=!0,zh("selectionchange",!1,l))}}function Iy(a,l,m,w){switch(ay(l)){case 1:var C=yi;break;case 4:C=bo;break;default:C=Ms}m=C.bind(null,l,m,a),C=void 0,!ys||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(C=!0),w?C!==void 0?a.addEventListener(l,m,{capture:!0,passive:C}):a.addEventListener(l,m,!0):C!==void 0?a.addEventListener(l,m,{passive:C}):a.addEventListener(l,m,!1)}function Dh(a,l,m,w,C){var T=w;if((l&1)===0&&(l&2)===0&&w!==null)e:for(;;){if(w===null)return;var z=w.tag;if(z===3||z===4){var K=w.stateNode.containerInfo;if(K===C||K.nodeType===8&&K.parentNode===C)break;if(z===4)for(z=w.return;z!==null;){var ee=z.tag;if((ee===3||ee===4)&&(ee=z.stateNode.containerInfo,ee===C||ee.nodeType===8&&ee.parentNode===C))return;z=z.return}for(;K!==null;){if(z=ja(K),z===null)return;if(ee=z.tag,ee===5||ee===6){w=T=z;continue e}K=K.parentNode}}w=w.return}Rt(function(){var ue=T,ke=Et(m),Se=[];e:{var je=Oy.get(a);if(je!==void 0){var We=Nh,Ve=a;switch(a){case"keypress":if(iu(m)===0)break e;case"keydown":case"keyup":We=u_;break;case"focusin":Ve="focus",We=Eh;break;case"focusout":Ve="blur",We=Eh;break;case"beforeblur":case"afterblur":We=Eh;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":We=cy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":We=Z$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":We=h_;break;case _y:case Ty:case Ry:We=n_;break;case Ay:We=g_;break;case"scroll":We=J$;break;case"wheel":We=v_;break;case"copy":case"cut":case"paste":We=r_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":We=uy}var Ye=(l&4)!==0,un=!Ye&&a==="scroll",ce=Ye?je!==null?je+"Capture":null:je;Ye=[];for(var oe=ue,de;oe!==null;){de=oe;var Oe=de.stateNode;if(de.tag===5&&Oe!==null&&(de=Oe,ce!==null&&(Oe=Un(oe,ce),Oe!=null&&Ye.push(ec(oe,Oe,de)))),un)break;oe=oe.return}0<Ye.length&&(je=new We(je,Ve,null,m,ke),Se.push({event:je,listeners:Ye}))}}if((l&7)===0){e:{if(je=a==="mouseover"||a==="pointerover",We=a==="mouseout"||a==="pointerout",je&&m!==gt&&(Ve=m.relatedTarget||m.fromElement)&&(ja(Ve)||Ve[Hr]))break e;if((We||je)&&(je=ke.window===ke?ke:(je=ke.ownerDocument)?je.defaultView||je.parentWindow:window,We?(Ve=m.relatedTarget||m.toElement,We=ue,Ve=Ve?ja(Ve):null,Ve!==null&&(un=ls(Ve),Ve!==un||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(We=null,Ve=ue),We!==Ve)){if(Ye=cy,Oe="onMouseLeave",ce="onMouseEnter",oe="mouse",(a==="pointerout"||a==="pointerover")&&(Ye=uy,Oe="onPointerLeave",ce="onPointerEnter",oe="pointer"),un=We==null?je:Ei(We),de=Ve==null?je:Ei(Ve),je=new Ye(Oe,oe+"leave",We,m,ke),je.target=un,je.relatedTarget=de,Oe=null,ja(ke)===ue&&(Ye=new Ye(ce,oe+"enter",Ve,m,ke),Ye.target=de,Ye.relatedTarget=un,Oe=Ye),un=Oe,We&&Ve)t:{for(Ye=We,ce=Ve,oe=0,de=Ye;de;de=Si(de))oe++;for(de=0,Oe=ce;Oe;Oe=Si(Oe))de++;for(;0<oe-de;)Ye=Si(Ye),oe--;for(;0<de-oe;)ce=Si(ce),de--;for(;oe--;){if(Ye===ce||ce!==null&&Ye===ce.alternate)break t;Ye=Si(Ye),ce=Si(ce)}Ye=null}else Ye=null;We!==null&&zy(Se,je,We,Ye,!1),Ve!==null&&un!==null&&zy(Se,un,Ve,Ye,!0)}}e:{if(je=ue?Ei(ue):window,We=je.nodeName&&je.nodeName.toLowerCase(),We==="select"||We==="input"&&je.type==="file")var Xe=S_;else if(xy(je))if(by)Xe=__;else{Xe=E_;var at=C_}else(We=je.nodeName)&&We.toLowerCase()==="input"&&(je.type==="checkbox"||je.type==="radio")&&(Xe=$_);if(Xe&&(Xe=Xe(a,ue))){vy(Se,Xe,m,ke);break e}at&&at(a,je,ue),a==="focusout"&&(at=je._wrapperState)&&at.controlled&&je.type==="number"&&ve(je,"number",je.value)}switch(at=ue?Ei(ue):window,a){case"focusin":(xy(at)||at.contentEditable==="true")&&(ki=at,Oh=ue,Jl=null);break;case"focusout":Jl=Oh=ki=null;break;case"mousedown":Mh=!0;break;case"contextmenu":case"mouseup":case"dragend":Mh=!1,Ey(Se,m,ke);break;case"selectionchange":if(A_)break;case"keydown":case"keyup":Ey(Se,m,ke)}var it;if(_h)e:{switch(a){case"compositionstart":var dt="onCompositionStart";break e;case"compositionend":dt="onCompositionEnd";break e;case"compositionupdate":dt="onCompositionUpdate";break e}dt=void 0}else ji?py(a,m)&&(dt="onCompositionEnd"):a==="keydown"&&m.keyCode===229&&(dt="onCompositionStart");dt&&(fy&&m.locale!=="ko"&&(ji||dt!=="onCompositionStart"?dt==="onCompositionEnd"&&ji&&(it=iy()):(yo=ke,kh="value"in yo?yo.value:yo.textContent,ji=!0)),at=hu(ue,dt),0<at.length&&(dt=new dy(dt,a,null,m,ke),Se.push({event:dt,listeners:at}),it?dt.data=it:(it=gy(m),it!==null&&(dt.data=it)))),(it=y_?w_(a,m):j_(a,m))&&(ue=hu(ue,"onBeforeInput"),0<ue.length&&(ke=new dy("onBeforeInput","beforeinput",null,m,ke),Se.push({event:ke,listeners:ue}),ke.data=it))}Py(Se,l)})}function ec(a,l,m){return{instance:a,listener:l,currentTarget:m}}function hu(a,l){for(var m=l+"Capture",w=[];a!==null;){var C=a,T=C.stateNode;C.tag===5&&T!==null&&(C=T,T=Un(a,m),T!=null&&w.unshift(ec(a,T,C)),T=Un(a,l),T!=null&&w.push(ec(a,T,C))),a=a.return}return w}function Si(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function zy(a,l,m,w,C){for(var T=l._reactName,z=[];m!==null&&m!==w;){var K=m,ee=K.alternate,ue=K.stateNode;if(ee!==null&&ee===w)break;K.tag===5&&ue!==null&&(K=ue,C?(ee=Un(m,T),ee!=null&&z.unshift(ec(m,ee,K))):C||(ee=Un(m,T),ee!=null&&z.push(ec(m,ee,K)))),m=m.return}z.length!==0&&a.push({event:l,listeners:z})}var P_=/\r\n?/g,I_=/\u0000|\uFFFD/g;function Dy(a){return(typeof a=="string"?a:""+a).replace(P_,`
38
+ `).replace(I_,"")}function pu(a,l,m){if(l=Dy(l),Dy(a)!==l&&m)throw Error(s(425))}function gu(){}var Fh=null,Uh=null;function Wh(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Hh=typeof setTimeout=="function"?setTimeout:void 0,z_=typeof clearTimeout=="function"?clearTimeout:void 0,Fy=typeof Promise=="function"?Promise:void 0,D_=typeof queueMicrotask=="function"?queueMicrotask:typeof Fy<"u"?function(a){return Fy.resolve(null).then(a).catch(F_)}:Hh;function F_(a){setTimeout(function(){throw a})}function Bh(a,l){var m=l,w=0;do{var C=m.nextSibling;if(a.removeChild(m),C&&C.nodeType===8)if(m=C.data,m==="/$"){if(w===0){a.removeChild(C),vo(l);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=C}while(m);vo(l)}function jo(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return a}function Uy(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var m=a.data;if(m==="$"||m==="$!"||m==="$?"){if(l===0)return a;l--}else m==="/$"&&l++}a=a.previousSibling}return null}var Ci=Math.random().toString(36).slice(2),Nr="__reactFiber$"+Ci,tc="__reactProps$"+Ci,Hr="__reactContainer$"+Ci,qh="__reactEvents$"+Ci,U_="__reactListeners$"+Ci,W_="__reactHandles$"+Ci;function ja(a){var l=a[Nr];if(l)return l;for(var m=a.parentNode;m;){if(l=m[Hr]||m[Nr]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(a=Uy(a);a!==null;){if(m=a[Nr])return m;a=Uy(a)}return l}a=m,m=a.parentNode}return null}function nc(a){return a=a[Nr]||a[Hr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Ei(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function xu(a){return a[tc]||null}var Gh=[],$i=-1;function ko(a){return{current:a}}function Yt(a){0>$i||(a.current=Gh[$i],Gh[$i]=null,$i--)}function qt(a,l){$i++,Gh[$i]=a.current,a.current=l}var No={},Hn=ko(No),ds=ko(!1),ka=No;function _i(a,l){var m=a.type.contextTypes;if(!m)return No;var w=a.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===l)return w.__reactInternalMemoizedMaskedChildContext;var C={},T;for(T in m)C[T]=l[T];return w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=C),C}function us(a){return a=a.childContextTypes,a!=null}function vu(){Yt(ds),Yt(Hn)}function Wy(a,l,m){if(Hn.current!==No)throw Error(s(168));qt(Hn,l),qt(ds,m)}function Hy(a,l,m){var w=a.stateNode;if(l=l.childContextTypes,typeof w.getChildContext!="function")return m;w=w.getChildContext();for(var C in w)if(!(C in l))throw Error(s(108,ye(a)||"Unknown",C));return H({},m,w)}function bu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||No,ka=Hn.current,qt(Hn,a),qt(ds,ds.current),!0}function By(a,l,m){var w=a.stateNode;if(!w)throw Error(s(169));m?(a=Hy(a,l,ka),w.__reactInternalMemoizedMergedChildContext=a,Yt(ds),Yt(Hn),qt(Hn,a)):Yt(ds),qt(ds,m)}var Br=null,yu=!1,Kh=!1;function qy(a){Br===null?Br=[a]:Br.push(a)}function H_(a){yu=!0,qy(a)}function So(){if(!Kh&&Br!==null){Kh=!0;var a=0,l=At;try{var m=Br;for(At=1;a<m.length;a++){var w=m[a];do w=w(!0);while(w!==null)}Br=null,yu=!1}catch(C){throw Br!==null&&(Br=Br.slice(a+1)),_e(Ln,So),C}finally{At=l,Kh=!1}}return null}var Ti=[],Ri=0,wu=null,ju=0,Ls=[],Ps=0,Na=null,qr=1,Gr="";function Sa(a,l){Ti[Ri++]=ju,Ti[Ri++]=wu,wu=a,ju=l}function Gy(a,l,m){Ls[Ps++]=qr,Ls[Ps++]=Gr,Ls[Ps++]=Na,Na=a;var w=qr;a=Gr;var C=32-cs(w)-1;w&=~(1<<C),m+=1;var T=32-cs(l)+C;if(30<T){var z=C-C%5;T=(w&(1<<z)-1).toString(32),w>>=z,C-=z,qr=1<<32-cs(l)+C|m<<C|w,Gr=T+a}else qr=1<<T|m<<C|w,Gr=a}function Vh(a){a.return!==null&&(Sa(a,1),Gy(a,1,0))}function Yh(a){for(;a===wu;)wu=Ti[--Ri],Ti[Ri]=null,ju=Ti[--Ri],Ti[Ri]=null;for(;a===Na;)Na=Ls[--Ps],Ls[Ps]=null,Gr=Ls[--Ps],Ls[Ps]=null,qr=Ls[--Ps],Ls[Ps]=null}var Ns=null,Ss=null,Xt=!1,sr=null;function Ky(a,l){var m=Fs(5,null,null,0);m.elementType="DELETED",m.stateNode=l,m.return=a,l=a.deletions,l===null?(a.deletions=[m],a.flags|=16):l.push(m)}function Vy(a,l){switch(a.tag){case 5:var m=a.type;return l=l.nodeType!==1||m.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,Ns=a,Ss=jo(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,Ns=a,Ss=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=Na!==null?{id:qr,overflow:Gr}:null,a.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Fs(18,null,null,0),m.stateNode=l,m.return=a,a.child=m,Ns=a,Ss=null,!0):!1;default:return!1}}function Qh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Jh(a){if(Xt){var l=Ss;if(l){var m=l;if(!Vy(a,l)){if(Qh(a))throw Error(s(418));l=jo(m.nextSibling);var w=Ns;l&&Vy(a,l)?Ky(w,m):(a.flags=a.flags&-4097|2,Xt=!1,Ns=a)}}else{if(Qh(a))throw Error(s(418));a.flags=a.flags&-4097|2,Xt=!1,Ns=a}}}function Yy(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Ns=a}function ku(a){if(a!==Ns)return!1;if(!Xt)return Yy(a),Xt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!Wh(a.type,a.memoizedProps)),l&&(l=Ss)){if(Qh(a))throw Qy(),Error(s(418));for(;l;)Ky(a,l),l=jo(l.nextSibling)}if(Yy(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));e:{for(a=a.nextSibling,l=0;a;){if(a.nodeType===8){var m=a.data;if(m==="/$"){if(l===0){Ss=jo(a.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}a=a.nextSibling}Ss=null}}else Ss=Ns?jo(a.stateNode.nextSibling):null;return!0}function Qy(){for(var a=Ss;a;)a=jo(a.nextSibling)}function Ai(){Ss=Ns=null,Xt=!1}function Xh(a){sr===null?sr=[a]:sr.push(a)}var B_=S.ReactCurrentBatchConfig;function sc(a,l,m){if(a=m.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(s(309));var w=m.stateNode}if(!w)throw Error(s(147,a));var C=w,T=""+a;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===T?l.ref:(l=function(z){var K=C.refs;z===null?delete K[T]:K[T]=z},l._stringRef=T,l)}if(typeof a!="string")throw Error(s(284));if(!m._owner)throw Error(s(290,a))}return a}function Nu(a,l){throw a=Object.prototype.toString.call(l),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function Jy(a){var l=a._init;return l(a._payload)}function Xy(a){function l(ce,oe){if(a){var de=ce.deletions;de===null?(ce.deletions=[oe],ce.flags|=16):de.push(oe)}}function m(ce,oe){if(!a)return null;for(;oe!==null;)l(ce,oe),oe=oe.sibling;return null}function w(ce,oe){for(ce=new Map;oe!==null;)oe.key!==null?ce.set(oe.key,oe):ce.set(oe.index,oe),oe=oe.sibling;return ce}function C(ce,oe){return ce=Oo(ce,oe),ce.index=0,ce.sibling=null,ce}function T(ce,oe,de){return ce.index=de,a?(de=ce.alternate,de!==null?(de=de.index,de<oe?(ce.flags|=2,oe):de):(ce.flags|=2,oe)):(ce.flags|=1048576,oe)}function z(ce){return a&&ce.alternate===null&&(ce.flags|=2),ce}function K(ce,oe,de,Oe){return oe===null||oe.tag!==6?(oe=Hp(de,ce.mode,Oe),oe.return=ce,oe):(oe=C(oe,de),oe.return=ce,oe)}function ee(ce,oe,de,Oe){var Xe=de.type;return Xe===O?ke(ce,oe,de.props.children,Oe,de.key):oe!==null&&(oe.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===D&&Jy(Xe)===oe.type)?(Oe=C(oe,de.props),Oe.ref=sc(ce,oe,de),Oe.return=ce,Oe):(Oe=Vu(de.type,de.key,de.props,null,ce.mode,Oe),Oe.ref=sc(ce,oe,de),Oe.return=ce,Oe)}function ue(ce,oe,de,Oe){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==de.containerInfo||oe.stateNode.implementation!==de.implementation?(oe=Bp(de,ce.mode,Oe),oe.return=ce,oe):(oe=C(oe,de.children||[]),oe.return=ce,oe)}function ke(ce,oe,de,Oe,Xe){return oe===null||oe.tag!==7?(oe=Oa(de,ce.mode,Oe,Xe),oe.return=ce,oe):(oe=C(oe,de),oe.return=ce,oe)}function Se(ce,oe,de){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return oe=Hp(""+oe,ce.mode,de),oe.return=ce,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case $:return de=Vu(oe.type,oe.key,oe.props,null,ce.mode,de),de.ref=sc(ce,null,oe),de.return=ce,de;case _:return oe=Bp(oe,ce.mode,de),oe.return=ce,oe;case D:var Oe=oe._init;return Se(ce,Oe(oe._payload),de)}if(Ee(oe)||q(oe))return oe=Oa(oe,ce.mode,de,null),oe.return=ce,oe;Nu(ce,oe)}return null}function je(ce,oe,de,Oe){var Xe=oe!==null?oe.key:null;if(typeof de=="string"&&de!==""||typeof de=="number")return Xe!==null?null:K(ce,oe,""+de,Oe);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case $:return de.key===Xe?ee(ce,oe,de,Oe):null;case _:return de.key===Xe?ue(ce,oe,de,Oe):null;case D:return Xe=de._init,je(ce,oe,Xe(de._payload),Oe)}if(Ee(de)||q(de))return Xe!==null?null:ke(ce,oe,de,Oe,null);Nu(ce,de)}return null}function We(ce,oe,de,Oe,Xe){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number")return ce=ce.get(de)||null,K(oe,ce,""+Oe,Xe);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case $:return ce=ce.get(Oe.key===null?de:Oe.key)||null,ee(oe,ce,Oe,Xe);case _:return ce=ce.get(Oe.key===null?de:Oe.key)||null,ue(oe,ce,Oe,Xe);case D:var at=Oe._init;return We(ce,oe,de,at(Oe._payload),Xe)}if(Ee(Oe)||q(Oe))return ce=ce.get(de)||null,ke(oe,ce,Oe,Xe,null);Nu(oe,Oe)}return null}function Ve(ce,oe,de,Oe){for(var Xe=null,at=null,it=oe,dt=oe=0,Tn=null;it!==null&&dt<de.length;dt++){it.index>dt?(Tn=it,it=null):Tn=it.sibling;var Ot=je(ce,it,de[dt],Oe);if(Ot===null){it===null&&(it=Tn);break}a&&it&&Ot.alternate===null&&l(ce,it),oe=T(Ot,oe,dt),at===null?Xe=Ot:at.sibling=Ot,at=Ot,it=Tn}if(dt===de.length)return m(ce,it),Xt&&Sa(ce,dt),Xe;if(it===null){for(;dt<de.length;dt++)it=Se(ce,de[dt],Oe),it!==null&&(oe=T(it,oe,dt),at===null?Xe=it:at.sibling=it,at=it);return Xt&&Sa(ce,dt),Xe}for(it=w(ce,it);dt<de.length;dt++)Tn=We(it,ce,dt,de[dt],Oe),Tn!==null&&(a&&Tn.alternate!==null&&it.delete(Tn.key===null?dt:Tn.key),oe=T(Tn,oe,dt),at===null?Xe=Tn:at.sibling=Tn,at=Tn);return a&&it.forEach(function(Mo){return l(ce,Mo)}),Xt&&Sa(ce,dt),Xe}function Ye(ce,oe,de,Oe){var Xe=q(de);if(typeof Xe!="function")throw Error(s(150));if(de=Xe.call(de),de==null)throw Error(s(151));for(var at=Xe=null,it=oe,dt=oe=0,Tn=null,Ot=de.next();it!==null&&!Ot.done;dt++,Ot=de.next()){it.index>dt?(Tn=it,it=null):Tn=it.sibling;var Mo=je(ce,it,Ot.value,Oe);if(Mo===null){it===null&&(it=Tn);break}a&&it&&Mo.alternate===null&&l(ce,it),oe=T(Mo,oe,dt),at===null?Xe=Mo:at.sibling=Mo,at=Mo,it=Tn}if(Ot.done)return m(ce,it),Xt&&Sa(ce,dt),Xe;if(it===null){for(;!Ot.done;dt++,Ot=de.next())Ot=Se(ce,Ot.value,Oe),Ot!==null&&(oe=T(Ot,oe,dt),at===null?Xe=Ot:at.sibling=Ot,at=Ot);return Xt&&Sa(ce,dt),Xe}for(it=w(ce,it);!Ot.done;dt++,Ot=de.next())Ot=We(it,ce,dt,Ot.value,Oe),Ot!==null&&(a&&Ot.alternate!==null&&it.delete(Ot.key===null?dt:Ot.key),oe=T(Ot,oe,dt),at===null?Xe=Ot:at.sibling=Ot,at=Ot);return a&&it.forEach(function(kT){return l(ce,kT)}),Xt&&Sa(ce,dt),Xe}function un(ce,oe,de,Oe){if(typeof de=="object"&&de!==null&&de.type===O&&de.key===null&&(de=de.props.children),typeof de=="object"&&de!==null){switch(de.$$typeof){case $:e:{for(var Xe=de.key,at=oe;at!==null;){if(at.key===Xe){if(Xe=de.type,Xe===O){if(at.tag===7){m(ce,at.sibling),oe=C(at,de.props.children),oe.return=ce,ce=oe;break e}}else if(at.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===D&&Jy(Xe)===at.type){m(ce,at.sibling),oe=C(at,de.props),oe.ref=sc(ce,at,de),oe.return=ce,ce=oe;break e}m(ce,at);break}else l(ce,at);at=at.sibling}de.type===O?(oe=Oa(de.props.children,ce.mode,Oe,de.key),oe.return=ce,ce=oe):(Oe=Vu(de.type,de.key,de.props,null,ce.mode,Oe),Oe.ref=sc(ce,oe,de),Oe.return=ce,ce=Oe)}return z(ce);case _:e:{for(at=de.key;oe!==null;){if(oe.key===at)if(oe.tag===4&&oe.stateNode.containerInfo===de.containerInfo&&oe.stateNode.implementation===de.implementation){m(ce,oe.sibling),oe=C(oe,de.children||[]),oe.return=ce,ce=oe;break e}else{m(ce,oe);break}else l(ce,oe);oe=oe.sibling}oe=Bp(de,ce.mode,Oe),oe.return=ce,ce=oe}return z(ce);case D:return at=de._init,un(ce,oe,at(de._payload),Oe)}if(Ee(de))return Ve(ce,oe,de,Oe);if(q(de))return Ye(ce,oe,de,Oe);Nu(ce,de)}return typeof de=="string"&&de!==""||typeof de=="number"?(de=""+de,oe!==null&&oe.tag===6?(m(ce,oe.sibling),oe=C(oe,de),oe.return=ce,ce=oe):(m(ce,oe),oe=Hp(de,ce.mode,Oe),oe.return=ce,ce=oe),z(ce)):m(ce,oe)}return un}var Oi=Xy(!0),Zy=Xy(!1),Su=ko(null),Cu=null,Mi=null,Zh=null;function ep(){Zh=Mi=Cu=null}function tp(a){var l=Su.current;Yt(Su),a._currentValue=l}function np(a,l,m){for(;a!==null;){var w=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,w!==null&&(w.childLanes|=l)):w!==null&&(w.childLanes&l)!==l&&(w.childLanes|=l),a===m)break;a=a.return}}function Li(a,l){Cu=a,Zh=Mi=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(fs=!0),a.firstContext=null)}function Is(a){var l=a._currentValue;if(Zh!==a)if(a={context:a,memoizedValue:l,next:null},Mi===null){if(Cu===null)throw Error(s(308));Mi=a,Cu.dependencies={lanes:0,firstContext:a}}else Mi=Mi.next=a;return l}var Ca=null;function sp(a){Ca===null?Ca=[a]:Ca.push(a)}function ew(a,l,m,w){var C=l.interleaved;return C===null?(m.next=m,sp(l)):(m.next=C.next,C.next=m),l.interleaved=m,Kr(a,w)}function Kr(a,l){a.lanes|=l;var m=a.alternate;for(m!==null&&(m.lanes|=l),m=a,a=a.return;a!==null;)a.childLanes|=l,m=a.alternate,m!==null&&(m.childLanes|=l),m=a,a=a.return;return m.tag===3?m.stateNode:null}var Co=!1;function rp(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function tw(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Vr(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function Eo(a,l,m){var w=a.updateQueue;if(w===null)return null;if(w=w.shared,(Tt&2)!==0){var C=w.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),w.pending=l,Kr(a,m)}return C=w.interleaved,C===null?(l.next=l,sp(w)):(l.next=C.next,C.next=l),w.interleaved=l,Kr(a,m)}function Eu(a,l,m){if(l=l.updateQueue,l!==null&&(l=l.shared,(m&4194240)!==0)){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,xi(a,m)}}function nw(a,l){var m=a.updateQueue,w=a.alternate;if(w!==null&&(w=w.updateQueue,m===w)){var C=null,T=null;if(m=m.firstBaseUpdate,m!==null){do{var z={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};T===null?C=T=z:T=T.next=z,m=m.next}while(m!==null);T===null?C=T=l:T=T.next=l}else C=T=l;m={baseState:w.baseState,firstBaseUpdate:C,lastBaseUpdate:T,shared:w.shared,effects:w.effects},a.updateQueue=m;return}a=m.lastBaseUpdate,a===null?m.firstBaseUpdate=l:a.next=l,m.lastBaseUpdate=l}function $u(a,l,m,w){var C=a.updateQueue;Co=!1;var T=C.firstBaseUpdate,z=C.lastBaseUpdate,K=C.shared.pending;if(K!==null){C.shared.pending=null;var ee=K,ue=ee.next;ee.next=null,z===null?T=ue:z.next=ue,z=ee;var ke=a.alternate;ke!==null&&(ke=ke.updateQueue,K=ke.lastBaseUpdate,K!==z&&(K===null?ke.firstBaseUpdate=ue:K.next=ue,ke.lastBaseUpdate=ee))}if(T!==null){var Se=C.baseState;z=0,ke=ue=ee=null,K=T;do{var je=K.lane,We=K.eventTime;if((w&je)===je){ke!==null&&(ke=ke.next={eventTime:We,lane:0,tag:K.tag,payload:K.payload,callback:K.callback,next:null});e:{var Ve=a,Ye=K;switch(je=l,We=m,Ye.tag){case 1:if(Ve=Ye.payload,typeof Ve=="function"){Se=Ve.call(We,Se,je);break e}Se=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Ye.payload,je=typeof Ve=="function"?Ve.call(We,Se,je):Ve,je==null)break e;Se=H({},Se,je);break e;case 2:Co=!0}}K.callback!==null&&K.lane!==0&&(a.flags|=64,je=C.effects,je===null?C.effects=[K]:je.push(K))}else We={eventTime:We,lane:je,tag:K.tag,payload:K.payload,callback:K.callback,next:null},ke===null?(ue=ke=We,ee=Se):ke=ke.next=We,z|=je;if(K=K.next,K===null){if(K=C.shared.pending,K===null)break;je=K,K=je.next,je.next=null,C.lastBaseUpdate=je,C.shared.pending=null}}while(!0);if(ke===null&&(ee=Se),C.baseState=ee,C.firstBaseUpdate=ue,C.lastBaseUpdate=ke,l=C.shared.interleaved,l!==null){C=l;do z|=C.lane,C=C.next;while(C!==l)}else T===null&&(C.shared.lanes=0);_a|=z,a.lanes=z,a.memoizedState=Se}}function sw(a,l,m){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var w=a[l],C=w.callback;if(C!==null){if(w.callback=null,w=m,typeof C!="function")throw Error(s(191,C));C.call(w)}}}var rc={},Sr=ko(rc),oc=ko(rc),ac=ko(rc);function Ea(a){if(a===rc)throw Error(s(174));return a}function op(a,l){switch(qt(ac,l),qt(oc,a),qt(Sr,rc),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:bt(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=bt(l,a)}Yt(Sr),qt(Sr,l)}function Pi(){Yt(Sr),Yt(oc),Yt(ac)}function rw(a){Ea(ac.current);var l=Ea(Sr.current),m=bt(l,a.type);l!==m&&(qt(oc,a),qt(Sr,m))}function ap(a){oc.current===a&&(Yt(Sr),Yt(oc))}var nn=ko(0);function _u(a){for(var l=a;l!==null;){if(l.tag===13){var m=l.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var ip=[];function lp(){for(var a=0;a<ip.length;a++)ip[a]._workInProgressVersionPrimary=null;ip.length=0}var Tu=S.ReactCurrentDispatcher,cp=S.ReactCurrentBatchConfig,$a=0,sn=null,kn=null,$n=null,Ru=!1,ic=!1,lc=0,q_=0;function Bn(){throw Error(s(321))}function dp(a,l){if(l===null)return!1;for(var m=0;m<l.length&&m<a.length;m++)if(!nr(a[m],l[m]))return!1;return!0}function up(a,l,m,w,C,T){if($a=T,sn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Tu.current=a===null||a.memoizedState===null?Y_:Q_,a=m(w,C),ic){T=0;do{if(ic=!1,lc=0,25<=T)throw Error(s(301));T+=1,$n=kn=null,l.updateQueue=null,Tu.current=J_,a=m(w,C)}while(ic)}if(Tu.current=Mu,l=kn!==null&&kn.next!==null,$a=0,$n=kn=sn=null,Ru=!1,l)throw Error(s(300));return a}function fp(){var a=lc!==0;return lc=0,a}function Cr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $n===null?sn.memoizedState=$n=a:$n=$n.next=a,$n}function zs(){if(kn===null){var a=sn.alternate;a=a!==null?a.memoizedState:null}else a=kn.next;var l=$n===null?sn.memoizedState:$n.next;if(l!==null)$n=l,kn=a;else{if(a===null)throw Error(s(310));kn=a,a={memoizedState:kn.memoizedState,baseState:kn.baseState,baseQueue:kn.baseQueue,queue:kn.queue,next:null},$n===null?sn.memoizedState=$n=a:$n=$n.next=a}return $n}function cc(a,l){return typeof l=="function"?l(a):l}function mp(a){var l=zs(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=kn,C=w.baseQueue,T=m.pending;if(T!==null){if(C!==null){var z=C.next;C.next=T.next,T.next=z}w.baseQueue=C=T,m.pending=null}if(C!==null){T=C.next,w=w.baseState;var K=z=null,ee=null,ue=T;do{var ke=ue.lane;if(($a&ke)===ke)ee!==null&&(ee=ee.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),w=ue.hasEagerState?ue.eagerState:a(w,ue.action);else{var Se={lane:ke,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};ee===null?(K=ee=Se,z=w):ee=ee.next=Se,sn.lanes|=ke,_a|=ke}ue=ue.next}while(ue!==null&&ue!==T);ee===null?z=w:ee.next=K,nr(w,l.memoizedState)||(fs=!0),l.memoizedState=w,l.baseState=z,l.baseQueue=ee,m.lastRenderedState=w}if(a=m.interleaved,a!==null){C=a;do T=C.lane,sn.lanes|=T,_a|=T,C=C.next;while(C!==a)}else C===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function hp(a){var l=zs(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=m.dispatch,C=m.pending,T=l.memoizedState;if(C!==null){m.pending=null;var z=C=C.next;do T=a(T,z.action),z=z.next;while(z!==C);nr(T,l.memoizedState)||(fs=!0),l.memoizedState=T,l.baseQueue===null&&(l.baseState=T),m.lastRenderedState=T}return[T,w]}function ow(){}function aw(a,l){var m=sn,w=zs(),C=l(),T=!nr(w.memoizedState,C);if(T&&(w.memoizedState=C,fs=!0),w=w.queue,pp(cw.bind(null,m,w,a),[a]),w.getSnapshot!==l||T||$n!==null&&$n.memoizedState.tag&1){if(m.flags|=2048,dc(9,lw.bind(null,m,w,C,l),void 0,null),_n===null)throw Error(s(349));($a&30)!==0||iw(m,l,C)}return C}function iw(a,l,m){a.flags|=16384,a={getSnapshot:l,value:m},l=sn.updateQueue,l===null?(l={lastEffect:null,stores:null},sn.updateQueue=l,l.stores=[a]):(m=l.stores,m===null?l.stores=[a]:m.push(a))}function lw(a,l,m,w){l.value=m,l.getSnapshot=w,dw(l)&&uw(a)}function cw(a,l,m){return m(function(){dw(l)&&uw(a)})}function dw(a){var l=a.getSnapshot;a=a.value;try{var m=l();return!nr(a,m)}catch{return!0}}function uw(a){var l=Kr(a,1);l!==null&&ir(l,a,1,-1)}function fw(a){var l=Cr();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:cc,lastRenderedState:a},l.queue=a,a=a.dispatch=V_.bind(null,sn,a),[l.memoizedState,a]}function dc(a,l,m,w){return a={tag:a,create:l,destroy:m,deps:w,next:null},l=sn.updateQueue,l===null?(l={lastEffect:null,stores:null},sn.updateQueue=l,l.lastEffect=a.next=a):(m=l.lastEffect,m===null?l.lastEffect=a.next=a:(w=m.next,m.next=a,a.next=w,l.lastEffect=a)),a}function mw(){return zs().memoizedState}function Au(a,l,m,w){var C=Cr();sn.flags|=a,C.memoizedState=dc(1|l,m,void 0,w===void 0?null:w)}function Ou(a,l,m,w){var C=zs();w=w===void 0?null:w;var T=void 0;if(kn!==null){var z=kn.memoizedState;if(T=z.destroy,w!==null&&dp(w,z.deps)){C.memoizedState=dc(l,m,T,w);return}}sn.flags|=a,C.memoizedState=dc(1|l,m,T,w)}function hw(a,l){return Au(8390656,8,a,l)}function pp(a,l){return Ou(2048,8,a,l)}function pw(a,l){return Ou(4,2,a,l)}function gw(a,l){return Ou(4,4,a,l)}function xw(a,l){if(typeof l=="function")return a=a(),l(a),function(){l(null)};if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function vw(a,l,m){return m=m!=null?m.concat([a]):null,Ou(4,4,xw.bind(null,l,a),m)}function gp(){}function bw(a,l){var m=zs();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&dp(l,w[1])?w[0]:(m.memoizedState=[a,l],a)}function yw(a,l){var m=zs();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&dp(l,w[1])?w[0]:(a=a(),m.memoizedState=[a,l],a)}function ww(a,l,m){return($a&21)===0?(a.baseState&&(a.baseState=!1,fs=!0),a.memoizedState=m):(nr(m,l)||(m=Dl(),sn.lanes|=m,_a|=m,a.baseState=!0),l)}function G_(a,l){var m=At;At=m!==0&&4>m?m:4,a(!0);var w=cp.transition;cp.transition={};try{a(!1),l()}finally{At=m,cp.transition=w}}function jw(){return zs().memoizedState}function K_(a,l,m){var w=Ro(a);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},kw(a))Nw(l,m);else if(m=ew(a,l,m,w),m!==null){var C=Xn();ir(m,a,w,C),Sw(m,l,w)}}function V_(a,l,m){var w=Ro(a),C={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(kw(a))Nw(l,C);else{var T=a.alternate;if(a.lanes===0&&(T===null||T.lanes===0)&&(T=l.lastRenderedReducer,T!==null))try{var z=l.lastRenderedState,K=T(z,m);if(C.hasEagerState=!0,C.eagerState=K,nr(K,z)){var ee=l.interleaved;ee===null?(C.next=C,sp(l)):(C.next=ee.next,ee.next=C),l.interleaved=C;return}}catch{}finally{}m=ew(a,l,C,w),m!==null&&(C=Xn(),ir(m,a,w,C),Sw(m,l,w))}}function kw(a){var l=a.alternate;return a===sn||l!==null&&l===sn}function Nw(a,l){ic=Ru=!0;var m=a.pending;m===null?l.next=l:(l.next=m.next,m.next=l),a.pending=l}function Sw(a,l,m){if((m&4194240)!==0){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,xi(a,m)}}var Mu={readContext:Is,useCallback:Bn,useContext:Bn,useEffect:Bn,useImperativeHandle:Bn,useInsertionEffect:Bn,useLayoutEffect:Bn,useMemo:Bn,useReducer:Bn,useRef:Bn,useState:Bn,useDebugValue:Bn,useDeferredValue:Bn,useTransition:Bn,useMutableSource:Bn,useSyncExternalStore:Bn,useId:Bn,unstable_isNewReconciler:!1},Y_={readContext:Is,useCallback:function(a,l){return Cr().memoizedState=[a,l===void 0?null:l],a},useContext:Is,useEffect:hw,useImperativeHandle:function(a,l,m){return m=m!=null?m.concat([a]):null,Au(4194308,4,xw.bind(null,l,a),m)},useLayoutEffect:function(a,l){return Au(4194308,4,a,l)},useInsertionEffect:function(a,l){return Au(4,2,a,l)},useMemo:function(a,l){var m=Cr();return l=l===void 0?null:l,a=a(),m.memoizedState=[a,l],a},useReducer:function(a,l,m){var w=Cr();return l=m!==void 0?m(l):l,w.memoizedState=w.baseState=l,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:l},w.queue=a,a=a.dispatch=K_.bind(null,sn,a),[w.memoizedState,a]},useRef:function(a){var l=Cr();return a={current:a},l.memoizedState=a},useState:fw,useDebugValue:gp,useDeferredValue:function(a){return Cr().memoizedState=a},useTransition:function(){var a=fw(!1),l=a[0];return a=G_.bind(null,a[1]),Cr().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,m){var w=sn,C=Cr();if(Xt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=l(),_n===null)throw Error(s(349));($a&30)!==0||iw(w,l,m)}C.memoizedState=m;var T={value:m,getSnapshot:l};return C.queue=T,hw(cw.bind(null,w,T,a),[a]),w.flags|=2048,dc(9,lw.bind(null,w,T,m,l),void 0,null),m},useId:function(){var a=Cr(),l=_n.identifierPrefix;if(Xt){var m=Gr,w=qr;m=(w&~(1<<32-cs(w)-1)).toString(32)+m,l=":"+l+"R"+m,m=lc++,0<m&&(l+="H"+m.toString(32)),l+=":"}else m=q_++,l=":"+l+"r"+m.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},Q_={readContext:Is,useCallback:bw,useContext:Is,useEffect:pp,useImperativeHandle:vw,useInsertionEffect:pw,useLayoutEffect:gw,useMemo:yw,useReducer:mp,useRef:mw,useState:function(){return mp(cc)},useDebugValue:gp,useDeferredValue:function(a){var l=zs();return ww(l,kn.memoizedState,a)},useTransition:function(){var a=mp(cc)[0],l=zs().memoizedState;return[a,l]},useMutableSource:ow,useSyncExternalStore:aw,useId:jw,unstable_isNewReconciler:!1},J_={readContext:Is,useCallback:bw,useContext:Is,useEffect:pp,useImperativeHandle:vw,useInsertionEffect:pw,useLayoutEffect:gw,useMemo:yw,useReducer:hp,useRef:mw,useState:function(){return hp(cc)},useDebugValue:gp,useDeferredValue:function(a){var l=zs();return kn===null?l.memoizedState=a:ww(l,kn.memoizedState,a)},useTransition:function(){var a=hp(cc)[0],l=zs().memoizedState;return[a,l]},useMutableSource:ow,useSyncExternalStore:aw,useId:jw,unstable_isNewReconciler:!1};function rr(a,l){if(a&&a.defaultProps){l=H({},l),a=a.defaultProps;for(var m in a)l[m]===void 0&&(l[m]=a[m]);return l}return l}function xp(a,l,m,w){l=a.memoizedState,m=m(w,l),m=m==null?l:H({},l,m),a.memoizedState=m,a.lanes===0&&(a.updateQueue.baseState=m)}var Lu={isMounted:function(a){return(a=a._reactInternals)?ls(a)===a:!1},enqueueSetState:function(a,l,m){a=a._reactInternals;var w=Xn(),C=Ro(a),T=Vr(w,C);T.payload=l,m!=null&&(T.callback=m),l=Eo(a,T,C),l!==null&&(ir(l,a,C,w),Eu(l,a,C))},enqueueReplaceState:function(a,l,m){a=a._reactInternals;var w=Xn(),C=Ro(a),T=Vr(w,C);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=Eo(a,T,C),l!==null&&(ir(l,a,C,w),Eu(l,a,C))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var m=Xn(),w=Ro(a),C=Vr(m,w);C.tag=2,l!=null&&(C.callback=l),l=Eo(a,C,w),l!==null&&(ir(l,a,w,m),Eu(l,a,w))}};function Cw(a,l,m,w,C,T,z){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(w,T,z):l.prototype&&l.prototype.isPureReactComponent?!Ql(m,w)||!Ql(C,T):!0}function Ew(a,l,m){var w=!1,C=No,T=l.contextType;return typeof T=="object"&&T!==null?T=Is(T):(C=us(l)?ka:Hn.current,w=l.contextTypes,T=(w=w!=null)?_i(a,C):No),l=new l(m,T),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=Lu,a.stateNode=l,l._reactInternals=a,w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=C,a.__reactInternalMemoizedMaskedChildContext=T),l}function $w(a,l,m,w){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(m,w),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(m,w),l.state!==a&&Lu.enqueueReplaceState(l,l.state,null)}function vp(a,l,m,w){var C=a.stateNode;C.props=m,C.state=a.memoizedState,C.refs={},rp(a);var T=l.contextType;typeof T=="object"&&T!==null?C.context=Is(T):(T=us(l)?ka:Hn.current,C.context=_i(a,T)),C.state=a.memoizedState,T=l.getDerivedStateFromProps,typeof T=="function"&&(xp(a,l,T,m),C.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(l=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),l!==C.state&&Lu.enqueueReplaceState(C,C.state,null),$u(a,m,C,w),C.state=a.memoizedState),typeof C.componentDidMount=="function"&&(a.flags|=4194308)}function Ii(a,l){try{var m="",w=l;do m+=re(w),w=w.return;while(w);var C=m}catch(T){C=`
39
+ Error generating stack: `+T.message+`
40
+ `+T.stack}return{value:a,source:l,stack:C,digest:null}}function bp(a,l,m){return{value:a,source:null,stack:m??null,digest:l??null}}function yp(a,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var X_=typeof WeakMap=="function"?WeakMap:Map;function _w(a,l,m){m=Vr(-1,m),m.tag=3,m.payload={element:null};var w=l.value;return m.callback=function(){Wu||(Wu=!0,Lp=w),yp(a,l)},m}function Tw(a,l,m){m=Vr(-1,m),m.tag=3;var w=a.type.getDerivedStateFromError;if(typeof w=="function"){var C=l.value;m.payload=function(){return w(C)},m.callback=function(){yp(a,l)}}var T=a.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){yp(a,l),typeof w!="function"&&(_o===null?_o=new Set([this]):_o.add(this));var z=l.stack;this.componentDidCatch(l.value,{componentStack:z!==null?z:""})}),m}function Rw(a,l,m){var w=a.pingCache;if(w===null){w=a.pingCache=new X_;var C=new Set;w.set(l,C)}else C=w.get(l),C===void 0&&(C=new Set,w.set(l,C));C.has(m)||(C.add(m),a=fT.bind(null,a,l,m),l.then(a,a))}function Aw(a){do{var l;if((l=a.tag===13)&&(l=a.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return a;a=a.return}while(a!==null);return null}function Ow(a,l,m,w,C){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(l=Vr(-1,1),l.tag=2,Eo(m,l,1))),m.lanes|=1),a):(a.flags|=65536,a.lanes=C,a)}var Z_=S.ReactCurrentOwner,fs=!1;function Jn(a,l,m,w){l.child=a===null?Zy(l,null,m,w):Oi(l,a.child,m,w)}function Mw(a,l,m,w,C){m=m.render;var T=l.ref;return Li(l,C),w=up(a,l,m,w,T,C),m=fp(),a!==null&&!fs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Yr(a,l,C)):(Xt&&m&&Vh(l),l.flags|=1,Jn(a,l,w,C),l.child)}function Lw(a,l,m,w,C){if(a===null){var T=m.type;return typeof T=="function"&&!Wp(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=T,Pw(a,l,T,w,C)):(a=Vu(m.type,null,w,l,l.mode,C),a.ref=l.ref,a.return=l,l.child=a)}if(T=a.child,(a.lanes&C)===0){var z=T.memoizedProps;if(m=m.compare,m=m!==null?m:Ql,m(z,w)&&a.ref===l.ref)return Yr(a,l,C)}return l.flags|=1,a=Oo(T,w),a.ref=l.ref,a.return=l,l.child=a}function Pw(a,l,m,w,C){if(a!==null){var T=a.memoizedProps;if(Ql(T,w)&&a.ref===l.ref)if(fs=!1,l.pendingProps=w=T,(a.lanes&C)!==0)(a.flags&131072)!==0&&(fs=!0);else return l.lanes=a.lanes,Yr(a,l,C)}return wp(a,l,m,w,C)}function Iw(a,l,m){var w=l.pendingProps,C=w.children,T=a!==null?a.memoizedState:null;if(w.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},qt(Di,Cs),Cs|=m;else{if((m&1073741824)===0)return a=T!==null?T.baseLanes|m:m,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,qt(Di,Cs),Cs|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,qt(Di,Cs),Cs|=w}else T!==null?(w=T.baseLanes|m,l.memoizedState=null):w=m,qt(Di,Cs),Cs|=w;return Jn(a,l,C,m),l.child}function zw(a,l){var m=l.ref;(a===null&&m!==null||a!==null&&a.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function wp(a,l,m,w,C){var T=us(m)?ka:Hn.current;return T=_i(l,T),Li(l,C),m=up(a,l,m,w,T,C),w=fp(),a!==null&&!fs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Yr(a,l,C)):(Xt&&w&&Vh(l),l.flags|=1,Jn(a,l,m,C),l.child)}function Dw(a,l,m,w,C){if(us(m)){var T=!0;bu(l)}else T=!1;if(Li(l,C),l.stateNode===null)Iu(a,l),Ew(l,m,w),vp(l,m,w,C),w=!0;else if(a===null){var z=l.stateNode,K=l.memoizedProps;z.props=K;var ee=z.context,ue=m.contextType;typeof ue=="object"&&ue!==null?ue=Is(ue):(ue=us(m)?ka:Hn.current,ue=_i(l,ue));var ke=m.getDerivedStateFromProps,Se=typeof ke=="function"||typeof z.getSnapshotBeforeUpdate=="function";Se||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(K!==w||ee!==ue)&&$w(l,z,w,ue),Co=!1;var je=l.memoizedState;z.state=je,$u(l,w,z,C),ee=l.memoizedState,K!==w||je!==ee||ds.current||Co?(typeof ke=="function"&&(xp(l,m,ke,w),ee=l.memoizedState),(K=Co||Cw(l,m,K,w,je,ee,ue))?(Se||typeof z.UNSAFE_componentWillMount!="function"&&typeof z.componentWillMount!="function"||(typeof z.componentWillMount=="function"&&z.componentWillMount(),typeof z.UNSAFE_componentWillMount=="function"&&z.UNSAFE_componentWillMount()),typeof z.componentDidMount=="function"&&(l.flags|=4194308)):(typeof z.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=w,l.memoizedState=ee),z.props=w,z.state=ee,z.context=ue,w=K):(typeof z.componentDidMount=="function"&&(l.flags|=4194308),w=!1)}else{z=l.stateNode,tw(a,l),K=l.memoizedProps,ue=l.type===l.elementType?K:rr(l.type,K),z.props=ue,Se=l.pendingProps,je=z.context,ee=m.contextType,typeof ee=="object"&&ee!==null?ee=Is(ee):(ee=us(m)?ka:Hn.current,ee=_i(l,ee));var We=m.getDerivedStateFromProps;(ke=typeof We=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(K!==Se||je!==ee)&&$w(l,z,w,ee),Co=!1,je=l.memoizedState,z.state=je,$u(l,w,z,C);var Ve=l.memoizedState;K!==Se||je!==Ve||ds.current||Co?(typeof We=="function"&&(xp(l,m,We,w),Ve=l.memoizedState),(ue=Co||Cw(l,m,ue,w,je,Ve,ee)||!1)?(ke||typeof z.UNSAFE_componentWillUpdate!="function"&&typeof z.componentWillUpdate!="function"||(typeof z.componentWillUpdate=="function"&&z.componentWillUpdate(w,Ve,ee),typeof z.UNSAFE_componentWillUpdate=="function"&&z.UNSAFE_componentWillUpdate(w,Ve,ee)),typeof z.componentDidUpdate=="function"&&(l.flags|=4),typeof z.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof z.componentDidUpdate!="function"||K===a.memoizedProps&&je===a.memoizedState||(l.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||K===a.memoizedProps&&je===a.memoizedState||(l.flags|=1024),l.memoizedProps=w,l.memoizedState=Ve),z.props=w,z.state=Ve,z.context=ee,w=ue):(typeof z.componentDidUpdate!="function"||K===a.memoizedProps&&je===a.memoizedState||(l.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||K===a.memoizedProps&&je===a.memoizedState||(l.flags|=1024),w=!1)}return jp(a,l,m,w,T,C)}function jp(a,l,m,w,C,T){zw(a,l);var z=(l.flags&128)!==0;if(!w&&!z)return C&&By(l,m,!1),Yr(a,l,T);w=l.stateNode,Z_.current=l;var K=z&&typeof m.getDerivedStateFromError!="function"?null:w.render();return l.flags|=1,a!==null&&z?(l.child=Oi(l,a.child,null,T),l.child=Oi(l,null,K,T)):Jn(a,l,K,T),l.memoizedState=w.state,C&&By(l,m,!0),l.child}function Fw(a){var l=a.stateNode;l.pendingContext?Wy(a,l.pendingContext,l.pendingContext!==l.context):l.context&&Wy(a,l.context,!1),op(a,l.containerInfo)}function Uw(a,l,m,w,C){return Ai(),Xh(C),l.flags|=256,Jn(a,l,m,w),l.child}var kp={dehydrated:null,treeContext:null,retryLane:0};function Np(a){return{baseLanes:a,cachePool:null,transitions:null}}function Ww(a,l,m){var w=l.pendingProps,C=nn.current,T=!1,z=(l.flags&128)!==0,K;if((K=z)||(K=a!==null&&a.memoizedState===null?!1:(C&2)!==0),K?(T=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(C|=1),qt(nn,C&1),a===null)return Jh(l),a=l.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((l.mode&1)===0?l.lanes=1:a.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(z=w.children,a=w.fallback,T?(w=l.mode,T=l.child,z={mode:"hidden",children:z},(w&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=z):T=Yu(z,w,0,null),a=Oa(a,w,m,null),T.return=l,a.return=l,T.sibling=a,l.child=T,l.child.memoizedState=Np(m),l.memoizedState=kp,a):Sp(l,z));if(C=a.memoizedState,C!==null&&(K=C.dehydrated,K!==null))return eT(a,l,z,w,K,C,m);if(T){T=w.fallback,z=l.mode,C=a.child,K=C.sibling;var ee={mode:"hidden",children:w.children};return(z&1)===0&&l.child!==C?(w=l.child,w.childLanes=0,w.pendingProps=ee,l.deletions=null):(w=Oo(C,ee),w.subtreeFlags=C.subtreeFlags&14680064),K!==null?T=Oo(K,T):(T=Oa(T,z,m,null),T.flags|=2),T.return=l,w.return=l,w.sibling=T,l.child=w,w=T,T=l.child,z=a.child.memoizedState,z=z===null?Np(m):{baseLanes:z.baseLanes|m,cachePool:null,transitions:z.transitions},T.memoizedState=z,T.childLanes=a.childLanes&~m,l.memoizedState=kp,w}return T=a.child,a=T.sibling,w=Oo(T,{mode:"visible",children:w.children}),(l.mode&1)===0&&(w.lanes=m),w.return=l,w.sibling=null,a!==null&&(m=l.deletions,m===null?(l.deletions=[a],l.flags|=16):m.push(a)),l.child=w,l.memoizedState=null,w}function Sp(a,l){return l=Yu({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function Pu(a,l,m,w){return w!==null&&Xh(w),Oi(l,a.child,null,m),a=Sp(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function eT(a,l,m,w,C,T,z){if(m)return l.flags&256?(l.flags&=-257,w=bp(Error(s(422))),Pu(a,l,z,w)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(T=w.fallback,C=l.mode,w=Yu({mode:"visible",children:w.children},C,0,null),T=Oa(T,C,z,null),T.flags|=2,w.return=l,T.return=l,w.sibling=T,l.child=w,(l.mode&1)!==0&&Oi(l,a.child,null,z),l.child.memoizedState=Np(z),l.memoizedState=kp,T);if((l.mode&1)===0)return Pu(a,l,z,null);if(C.data==="$!"){if(w=C.nextSibling&&C.nextSibling.dataset,w)var K=w.dgst;return w=K,T=Error(s(419)),w=bp(T,w,void 0),Pu(a,l,z,w)}if(K=(z&a.childLanes)!==0,fs||K){if(w=_n,w!==null){switch(z&-z){case 4:C=2;break;case 16:C=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:C=32;break;case 536870912:C=268435456;break;default:C=0}C=(C&(w.suspendedLanes|z))!==0?0:C,C!==0&&C!==T.retryLane&&(T.retryLane=C,Kr(a,C),ir(w,a,C,-1))}return Up(),w=bp(Error(s(421))),Pu(a,l,z,w)}return C.data==="$?"?(l.flags|=128,l.child=a.child,l=mT.bind(null,a),C._reactRetry=l,null):(a=T.treeContext,Ss=jo(C.nextSibling),Ns=l,Xt=!0,sr=null,a!==null&&(Ls[Ps++]=qr,Ls[Ps++]=Gr,Ls[Ps++]=Na,qr=a.id,Gr=a.overflow,Na=l),l=Sp(l,w.children),l.flags|=4096,l)}function Hw(a,l,m){a.lanes|=l;var w=a.alternate;w!==null&&(w.lanes|=l),np(a.return,l,m)}function Cp(a,l,m,w,C){var T=a.memoizedState;T===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:C}:(T.isBackwards=l,T.rendering=null,T.renderingStartTime=0,T.last=w,T.tail=m,T.tailMode=C)}function Bw(a,l,m){var w=l.pendingProps,C=w.revealOrder,T=w.tail;if(Jn(a,l,w.children,m),w=nn.current,(w&2)!==0)w=w&1|2,l.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&Hw(a,m,l);else if(a.tag===19)Hw(a,m,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}w&=1}if(qt(nn,w),(l.mode&1)===0)l.memoizedState=null;else switch(C){case"forwards":for(m=l.child,C=null;m!==null;)a=m.alternate,a!==null&&_u(a)===null&&(C=m),m=m.sibling;m=C,m===null?(C=l.child,l.child=null):(C=m.sibling,m.sibling=null),Cp(l,!1,C,m,T);break;case"backwards":for(m=null,C=l.child,l.child=null;C!==null;){if(a=C.alternate,a!==null&&_u(a)===null){l.child=C;break}a=C.sibling,C.sibling=m,m=C,C=a}Cp(l,!0,m,null,T);break;case"together":Cp(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Iu(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function Yr(a,l,m){if(a!==null&&(l.dependencies=a.dependencies),_a|=l.lanes,(m&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(s(153));if(l.child!==null){for(a=l.child,m=Oo(a,a.pendingProps),l.child=m,m.return=l;a.sibling!==null;)a=a.sibling,m=m.sibling=Oo(a,a.pendingProps),m.return=l;m.sibling=null}return l.child}function tT(a,l,m){switch(l.tag){case 3:Fw(l),Ai();break;case 5:rw(l);break;case 1:us(l.type)&&bu(l);break;case 4:op(l,l.stateNode.containerInfo);break;case 10:var w=l.type._context,C=l.memoizedProps.value;qt(Su,w._currentValue),w._currentValue=C;break;case 13:if(w=l.memoizedState,w!==null)return w.dehydrated!==null?(qt(nn,nn.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?Ww(a,l,m):(qt(nn,nn.current&1),a=Yr(a,l,m),a!==null?a.sibling:null);qt(nn,nn.current&1);break;case 19:if(w=(m&l.childLanes)!==0,(a.flags&128)!==0){if(w)return Bw(a,l,m);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),qt(nn,nn.current),w)break;return null;case 22:case 23:return l.lanes=0,Iw(a,l,m)}return Yr(a,l,m)}var qw,Ep,Gw,Kw;qw=function(a,l){for(var m=l.child;m!==null;){if(m.tag===5||m.tag===6)a.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===l)break;for(;m.sibling===null;){if(m.return===null||m.return===l)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},Ep=function(){},Gw=function(a,l,m,w){var C=a.memoizedProps;if(C!==w){a=l.stateNode,Ea(Sr.current);var T=null;switch(m){case"input":C=be(a,C),w=be(a,w),T=[];break;case"select":C=H({},C,{value:void 0}),w=H({},w,{value:void 0}),T=[];break;case"textarea":C=Me(a,C),w=Me(a,w),T=[];break;default:typeof C.onClick!="function"&&typeof w.onClick=="function"&&(a.onclick=gu)}Qe(m,w);var z;m=null;for(ue in C)if(!w.hasOwnProperty(ue)&&C.hasOwnProperty(ue)&&C[ue]!=null)if(ue==="style"){var K=C[ue];for(z in K)K.hasOwnProperty(z)&&(m||(m={}),m[z]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(o.hasOwnProperty(ue)?T||(T=[]):(T=T||[]).push(ue,null));for(ue in w){var ee=w[ue];if(K=C!=null?C[ue]:void 0,w.hasOwnProperty(ue)&&ee!==K&&(ee!=null||K!=null))if(ue==="style")if(K){for(z in K)!K.hasOwnProperty(z)||ee&&ee.hasOwnProperty(z)||(m||(m={}),m[z]="");for(z in ee)ee.hasOwnProperty(z)&&K[z]!==ee[z]&&(m||(m={}),m[z]=ee[z])}else m||(T||(T=[]),T.push(ue,m)),m=ee;else ue==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,K=K?K.__html:void 0,ee!=null&&K!==ee&&(T=T||[]).push(ue,ee)):ue==="children"?typeof ee!="string"&&typeof ee!="number"||(T=T||[]).push(ue,""+ee):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(o.hasOwnProperty(ue)?(ee!=null&&ue==="onScroll"&&Vt("scroll",a),T||K===ee||(T=[])):(T=T||[]).push(ue,ee))}m&&(T=T||[]).push("style",m);var ue=T;(l.updateQueue=ue)&&(l.flags|=4)}},Kw=function(a,l,m,w){m!==w&&(l.flags|=4)};function uc(a,l){if(!Xt)switch(a.tailMode){case"hidden":l=a.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?a.tail=null:m.sibling=null;break;case"collapsed":m=a.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:w.sibling=null}}function qn(a){var l=a.alternate!==null&&a.alternate.child===a.child,m=0,w=0;if(l)for(var C=a.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags&14680064,w|=C.flags&14680064,C.return=a,C=C.sibling;else for(C=a.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags,w|=C.flags,C.return=a,C=C.sibling;return a.subtreeFlags|=w,a.childLanes=m,l}function nT(a,l,m){var w=l.pendingProps;switch(Yh(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qn(l),null;case 1:return us(l.type)&&vu(),qn(l),null;case 3:return w=l.stateNode,Pi(),Yt(ds),Yt(Hn),lp(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(a===null||a.child===null)&&(ku(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,sr!==null&&(zp(sr),sr=null))),Ep(a,l),qn(l),null;case 5:ap(l);var C=Ea(ac.current);if(m=l.type,a!==null&&l.stateNode!=null)Gw(a,l,m,w,C),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!w){if(l.stateNode===null)throw Error(s(166));return qn(l),null}if(a=Ea(Sr.current),ku(l)){w=l.stateNode,m=l.type;var T=l.memoizedProps;switch(w[Nr]=l,w[tc]=T,a=(l.mode&1)!==0,m){case"dialog":Vt("cancel",w),Vt("close",w);break;case"iframe":case"object":case"embed":Vt("load",w);break;case"video":case"audio":for(C=0;C<Xl.length;C++)Vt(Xl[C],w);break;case"source":Vt("error",w);break;case"img":case"image":case"link":Vt("error",w),Vt("load",w);break;case"details":Vt("toggle",w);break;case"input":ge(w,T),Vt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},Vt("invalid",w);break;case"textarea":pe(w,T),Vt("invalid",w)}Qe(m,T),C=null;for(var z in T)if(T.hasOwnProperty(z)){var K=T[z];z==="children"?typeof K=="string"?w.textContent!==K&&(T.suppressHydrationWarning!==!0&&pu(w.textContent,K,a),C=["children",K]):typeof K=="number"&&w.textContent!==""+K&&(T.suppressHydrationWarning!==!0&&pu(w.textContent,K,a),C=["children",""+K]):o.hasOwnProperty(z)&&K!=null&&z==="onScroll"&&Vt("scroll",w)}switch(m){case"input":le(w),ft(w,T,!0);break;case"textarea":le(w),Ae(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=gu)}w=C,l.updateQueue=w,w!==null&&(l.flags|=4)}else{z=C.nodeType===9?C:C.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Pe(m)),a==="http://www.w3.org/1999/xhtml"?m==="script"?(a=z.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof w.is=="string"?a=z.createElement(m,{is:w.is}):(a=z.createElement(m),m==="select"&&(z=a,w.multiple?z.multiple=!0:w.size&&(z.size=w.size))):a=z.createElementNS(a,m),a[Nr]=l,a[tc]=w,qw(a,l,!1,!1),l.stateNode=a;e:{switch(z=ct(m,w),m){case"dialog":Vt("cancel",a),Vt("close",a),C=w;break;case"iframe":case"object":case"embed":Vt("load",a),C=w;break;case"video":case"audio":for(C=0;C<Xl.length;C++)Vt(Xl[C],a);C=w;break;case"source":Vt("error",a),C=w;break;case"img":case"image":case"link":Vt("error",a),Vt("load",a),C=w;break;case"details":Vt("toggle",a),C=w;break;case"input":ge(a,w),C=be(a,w),Vt("invalid",a);break;case"option":C=w;break;case"select":a._wrapperState={wasMultiple:!!w.multiple},C=H({},w,{value:void 0}),Vt("invalid",a);break;case"textarea":pe(a,w),C=Me(a,w),Vt("invalid",a);break;default:C=w}Qe(m,C),K=C;for(T in K)if(K.hasOwnProperty(T)){var ee=K[T];T==="style"?fe(a,ee):T==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,ee!=null&&mt(a,ee)):T==="children"?typeof ee=="string"?(m!=="textarea"||ee!=="")&&Re(a,ee):typeof ee=="number"&&Re(a,""+ee):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(o.hasOwnProperty(T)?ee!=null&&T==="onScroll"&&Vt("scroll",a):ee!=null&&N(a,T,ee,z))}switch(m){case"input":le(a),ft(a,w,!1);break;case"textarea":le(a),Ae(a);break;case"option":w.value!=null&&a.setAttribute("value",""+he(w.value));break;case"select":a.multiple=!!w.multiple,T=w.value,T!=null?Q(a,!!w.multiple,T,!1):w.defaultValue!=null&&Q(a,!!w.multiple,w.defaultValue,!0);break;default:typeof C.onClick=="function"&&(a.onclick=gu)}switch(m){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return qn(l),null;case 6:if(a&&l.stateNode!=null)Kw(a,l,a.memoizedProps,w);else{if(typeof w!="string"&&l.stateNode===null)throw Error(s(166));if(m=Ea(ac.current),Ea(Sr.current),ku(l)){if(w=l.stateNode,m=l.memoizedProps,w[Nr]=l,(T=w.nodeValue!==m)&&(a=Ns,a!==null))switch(a.tag){case 3:pu(w.nodeValue,m,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&pu(w.nodeValue,m,(a.mode&1)!==0)}T&&(l.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[Nr]=l,l.stateNode=w}return qn(l),null;case 13:if(Yt(nn),w=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Xt&&Ss!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Qy(),Ai(),l.flags|=98560,T=!1;else if(T=ku(l),w!==null&&w.dehydrated!==null){if(a===null){if(!T)throw Error(s(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(s(317));T[Nr]=l}else Ai(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qn(l),T=!1}else sr!==null&&(zp(sr),sr=null),T=!0;if(!T)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=m,l):(w=w!==null,w!==(a!==null&&a.memoizedState!==null)&&w&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(nn.current&1)!==0?Nn===0&&(Nn=3):Up())),l.updateQueue!==null&&(l.flags|=4),qn(l),null);case 4:return Pi(),Ep(a,l),a===null&&Zl(l.stateNode.containerInfo),qn(l),null;case 10:return tp(l.type._context),qn(l),null;case 17:return us(l.type)&&vu(),qn(l),null;case 19:if(Yt(nn),T=l.memoizedState,T===null)return qn(l),null;if(w=(l.flags&128)!==0,z=T.rendering,z===null)if(w)uc(T,!1);else{if(Nn!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(z=_u(a),z!==null){for(l.flags|=128,uc(T,!1),w=z.updateQueue,w!==null&&(l.updateQueue=w,l.flags|=4),l.subtreeFlags=0,w=m,m=l.child;m!==null;)T=m,a=w,T.flags&=14680066,z=T.alternate,z===null?(T.childLanes=0,T.lanes=a,T.child=null,T.subtreeFlags=0,T.memoizedProps=null,T.memoizedState=null,T.updateQueue=null,T.dependencies=null,T.stateNode=null):(T.childLanes=z.childLanes,T.lanes=z.lanes,T.child=z.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=z.memoizedProps,T.memoizedState=z.memoizedState,T.updateQueue=z.updateQueue,T.type=z.type,a=z.dependencies,T.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),m=m.sibling;return qt(nn,nn.current&1|2),l.child}a=a.sibling}T.tail!==null&&pt()>Fi&&(l.flags|=128,w=!0,uc(T,!1),l.lanes=4194304)}else{if(!w)if(a=_u(z),a!==null){if(l.flags|=128,w=!0,m=a.updateQueue,m!==null&&(l.updateQueue=m,l.flags|=4),uc(T,!0),T.tail===null&&T.tailMode==="hidden"&&!z.alternate&&!Xt)return qn(l),null}else 2*pt()-T.renderingStartTime>Fi&&m!==1073741824&&(l.flags|=128,w=!0,uc(T,!1),l.lanes=4194304);T.isBackwards?(z.sibling=l.child,l.child=z):(m=T.last,m!==null?m.sibling=z:l.child=z,T.last=z)}return T.tail!==null?(l=T.tail,T.rendering=l,T.tail=l.sibling,T.renderingStartTime=pt(),l.sibling=null,m=nn.current,qt(nn,w?m&1|2:m&1),l):(qn(l),null);case 22:case 23:return Fp(),w=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==w&&(l.flags|=8192),w&&(l.mode&1)!==0?(Cs&1073741824)!==0&&(qn(l),l.subtreeFlags&6&&(l.flags|=8192)):qn(l),null;case 24:return null;case 25:return null}throw Error(s(156,l.tag))}function sT(a,l){switch(Yh(l),l.tag){case 1:return us(l.type)&&vu(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return Pi(),Yt(ds),Yt(Hn),lp(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return ap(l),null;case 13:if(Yt(nn),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(s(340));Ai()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return Yt(nn),null;case 4:return Pi(),null;case 10:return tp(l.type._context),null;case 22:case 23:return Fp(),null;case 24:return null;default:return null}}var zu=!1,Gn=!1,rT=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function zi(a,l){var m=a.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){ln(a,l,w)}else m.current=null}function $p(a,l,m){try{m()}catch(w){ln(a,l,w)}}var Vw=!1;function oT(a,l){if(Fh=wa,a=Cy(),Ah(a)){if("selectionStart"in a)var m={start:a.selectionStart,end:a.selectionEnd};else e:{m=(m=a.ownerDocument)&&m.defaultView||window;var w=m.getSelection&&m.getSelection();if(w&&w.rangeCount!==0){m=w.anchorNode;var C=w.anchorOffset,T=w.focusNode;w=w.focusOffset;try{m.nodeType,T.nodeType}catch{m=null;break e}var z=0,K=-1,ee=-1,ue=0,ke=0,Se=a,je=null;t:for(;;){for(var We;Se!==m||C!==0&&Se.nodeType!==3||(K=z+C),Se!==T||w!==0&&Se.nodeType!==3||(ee=z+w),Se.nodeType===3&&(z+=Se.nodeValue.length),(We=Se.firstChild)!==null;)je=Se,Se=We;for(;;){if(Se===a)break t;if(je===m&&++ue===C&&(K=z),je===T&&++ke===w&&(ee=z),(We=Se.nextSibling)!==null)break;Se=je,je=Se.parentNode}Se=We}m=K===-1||ee===-1?null:{start:K,end:ee}}else m=null}m=m||{start:0,end:0}}else m=null;for(Uh={focusedElem:a,selectionRange:m},wa=!1,Ge=l;Ge!==null;)if(l=Ge,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Ge=a;else for(;Ge!==null;){l=Ge;try{var Ve=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var Ye=Ve.memoizedProps,un=Ve.memoizedState,ce=l.stateNode,oe=ce.getSnapshotBeforeUpdate(l.elementType===l.type?Ye:rr(l.type,Ye),un);ce.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var de=l.stateNode.containerInfo;de.nodeType===1?de.textContent="":de.nodeType===9&&de.documentElement&&de.removeChild(de.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Oe){ln(l,l.return,Oe)}if(a=l.sibling,a!==null){a.return=l.return,Ge=a;break}Ge=l.return}return Ve=Vw,Vw=!1,Ve}function fc(a,l,m){var w=l.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var C=w=w.next;do{if((C.tag&a)===a){var T=C.destroy;C.destroy=void 0,T!==void 0&&$p(l,m,T)}C=C.next}while(C!==w)}}function Du(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var m=l=l.next;do{if((m.tag&a)===a){var w=m.create;m.destroy=w()}m=m.next}while(m!==l)}}function _p(a){var l=a.ref;if(l!==null){var m=a.stateNode;switch(a.tag){case 5:a=m;break;default:a=m}typeof l=="function"?l(a):l.current=a}}function Yw(a){var l=a.alternate;l!==null&&(a.alternate=null,Yw(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[Nr],delete l[tc],delete l[qh],delete l[U_],delete l[W_])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function Qw(a){return a.tag===5||a.tag===3||a.tag===4}function Jw(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Qw(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Tp(a,l,m){var w=a.tag;if(w===5||w===6)a=a.stateNode,l?m.nodeType===8?m.parentNode.insertBefore(a,l):m.insertBefore(a,l):(m.nodeType===8?(l=m.parentNode,l.insertBefore(a,m)):(l=m,l.appendChild(a)),m=m._reactRootContainer,m!=null||l.onclick!==null||(l.onclick=gu));else if(w!==4&&(a=a.child,a!==null))for(Tp(a,l,m),a=a.sibling;a!==null;)Tp(a,l,m),a=a.sibling}function Rp(a,l,m){var w=a.tag;if(w===5||w===6)a=a.stateNode,l?m.insertBefore(a,l):m.appendChild(a);else if(w!==4&&(a=a.child,a!==null))for(Rp(a,l,m),a=a.sibling;a!==null;)Rp(a,l,m),a=a.sibling}var In=null,or=!1;function $o(a,l,m){for(m=m.child;m!==null;)Xw(a,l,m),m=m.sibling}function Xw(a,l,m){if(js&&typeof js.onCommitFiberUnmount=="function")try{js.onCommitFiberUnmount(pa,m)}catch{}switch(m.tag){case 5:Gn||zi(m,l);case 6:var w=In,C=or;In=null,$o(a,l,m),In=w,or=C,In!==null&&(or?(a=In,m=m.stateNode,a.nodeType===8?a.parentNode.removeChild(m):a.removeChild(m)):In.removeChild(m.stateNode));break;case 18:In!==null&&(or?(a=In,m=m.stateNode,a.nodeType===8?Bh(a.parentNode,m):a.nodeType===1&&Bh(a,m),vo(a)):Bh(In,m.stateNode));break;case 4:w=In,C=or,In=m.stateNode.containerInfo,or=!0,$o(a,l,m),In=w,or=C;break;case 0:case 11:case 14:case 15:if(!Gn&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){C=w=w.next;do{var T=C,z=T.destroy;T=T.tag,z!==void 0&&((T&2)!==0||(T&4)!==0)&&$p(m,l,z),C=C.next}while(C!==w)}$o(a,l,m);break;case 1:if(!Gn&&(zi(m,l),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(K){ln(m,l,K)}$o(a,l,m);break;case 21:$o(a,l,m);break;case 22:m.mode&1?(Gn=(w=Gn)||m.memoizedState!==null,$o(a,l,m),Gn=w):$o(a,l,m);break;default:$o(a,l,m)}}function Zw(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var m=a.stateNode;m===null&&(m=a.stateNode=new rT),l.forEach(function(w){var C=hT.bind(null,a,w);m.has(w)||(m.add(w),w.then(C,C))})}}function ar(a,l){var m=l.deletions;if(m!==null)for(var w=0;w<m.length;w++){var C=m[w];try{var T=a,z=l,K=z;e:for(;K!==null;){switch(K.tag){case 5:In=K.stateNode,or=!1;break e;case 3:In=K.stateNode.containerInfo,or=!0;break e;case 4:In=K.stateNode.containerInfo,or=!0;break e}K=K.return}if(In===null)throw Error(s(160));Xw(T,z,C),In=null,or=!1;var ee=C.alternate;ee!==null&&(ee.return=null),C.return=null}catch(ue){ln(C,l,ue)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)ej(l,a),l=l.sibling}function ej(a,l){var m=a.alternate,w=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(ar(l,a),Er(a),w&4){try{fc(3,a,a.return),Du(3,a)}catch(Ye){ln(a,a.return,Ye)}try{fc(5,a,a.return)}catch(Ye){ln(a,a.return,Ye)}}break;case 1:ar(l,a),Er(a),w&512&&m!==null&&zi(m,m.return);break;case 5:if(ar(l,a),Er(a),w&512&&m!==null&&zi(m,m.return),a.flags&32){var C=a.stateNode;try{Re(C,"")}catch(Ye){ln(a,a.return,Ye)}}if(w&4&&(C=a.stateNode,C!=null)){var T=a.memoizedProps,z=m!==null?m.memoizedProps:T,K=a.type,ee=a.updateQueue;if(a.updateQueue=null,ee!==null)try{K==="input"&&T.type==="radio"&&T.name!=null&&Je(C,T),ct(K,z);var ue=ct(K,T);for(z=0;z<ee.length;z+=2){var ke=ee[z],Se=ee[z+1];ke==="style"?fe(C,Se):ke==="dangerouslySetInnerHTML"?mt(C,Se):ke==="children"?Re(C,Se):N(C,ke,Se,ue)}switch(K){case"input":tt(C,T);break;case"textarea":ne(C,T);break;case"select":var je=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!T.multiple;var We=T.value;We!=null?Q(C,!!T.multiple,We,!1):je!==!!T.multiple&&(T.defaultValue!=null?Q(C,!!T.multiple,T.defaultValue,!0):Q(C,!!T.multiple,T.multiple?[]:"",!1))}C[tc]=T}catch(Ye){ln(a,a.return,Ye)}}break;case 6:if(ar(l,a),Er(a),w&4){if(a.stateNode===null)throw Error(s(162));C=a.stateNode,T=a.memoizedProps;try{C.nodeValue=T}catch(Ye){ln(a,a.return,Ye)}}break;case 3:if(ar(l,a),Er(a),w&4&&m!==null&&m.memoizedState.isDehydrated)try{vo(l.containerInfo)}catch(Ye){ln(a,a.return,Ye)}break;case 4:ar(l,a),Er(a);break;case 13:ar(l,a),Er(a),C=a.child,C.flags&8192&&(T=C.memoizedState!==null,C.stateNode.isHidden=T,!T||C.alternate!==null&&C.alternate.memoizedState!==null||(Mp=pt())),w&4&&Zw(a);break;case 22:if(ke=m!==null&&m.memoizedState!==null,a.mode&1?(Gn=(ue=Gn)||ke,ar(l,a),Gn=ue):ar(l,a),Er(a),w&8192){if(ue=a.memoizedState!==null,(a.stateNode.isHidden=ue)&&!ke&&(a.mode&1)!==0)for(Ge=a,ke=a.child;ke!==null;){for(Se=Ge=ke;Ge!==null;){switch(je=Ge,We=je.child,je.tag){case 0:case 11:case 14:case 15:fc(4,je,je.return);break;case 1:zi(je,je.return);var Ve=je.stateNode;if(typeof Ve.componentWillUnmount=="function"){w=je,m=je.return;try{l=w,Ve.props=l.memoizedProps,Ve.state=l.memoizedState,Ve.componentWillUnmount()}catch(Ye){ln(w,m,Ye)}}break;case 5:zi(je,je.return);break;case 22:if(je.memoizedState!==null){sj(Se);continue}}We!==null?(We.return=je,Ge=We):sj(Se)}ke=ke.sibling}e:for(ke=null,Se=a;;){if(Se.tag===5){if(ke===null){ke=Se;try{C=Se.stateNode,ue?(T=C.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(K=Se.stateNode,ee=Se.memoizedProps.style,z=ee!=null&&ee.hasOwnProperty("display")?ee.display:null,K.style.display=nt("display",z))}catch(Ye){ln(a,a.return,Ye)}}}else if(Se.tag===6){if(ke===null)try{Se.stateNode.nodeValue=ue?"":Se.memoizedProps}catch(Ye){ln(a,a.return,Ye)}}else if((Se.tag!==22&&Se.tag!==23||Se.memoizedState===null||Se===a)&&Se.child!==null){Se.child.return=Se,Se=Se.child;continue}if(Se===a)break e;for(;Se.sibling===null;){if(Se.return===null||Se.return===a)break e;ke===Se&&(ke=null),Se=Se.return}ke===Se&&(ke=null),Se.sibling.return=Se.return,Se=Se.sibling}}break;case 19:ar(l,a),Er(a),w&4&&Zw(a);break;case 21:break;default:ar(l,a),Er(a)}}function Er(a){var l=a.flags;if(l&2){try{e:{for(var m=a.return;m!==null;){if(Qw(m)){var w=m;break e}m=m.return}throw Error(s(160))}switch(w.tag){case 5:var C=w.stateNode;w.flags&32&&(Re(C,""),w.flags&=-33);var T=Jw(a);Rp(a,T,C);break;case 3:case 4:var z=w.stateNode.containerInfo,K=Jw(a);Tp(a,K,z);break;default:throw Error(s(161))}}catch(ee){ln(a,a.return,ee)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function aT(a,l,m){Ge=a,tj(a)}function tj(a,l,m){for(var w=(a.mode&1)!==0;Ge!==null;){var C=Ge,T=C.child;if(C.tag===22&&w){var z=C.memoizedState!==null||zu;if(!z){var K=C.alternate,ee=K!==null&&K.memoizedState!==null||Gn;K=zu;var ue=Gn;if(zu=z,(Gn=ee)&&!ue)for(Ge=C;Ge!==null;)z=Ge,ee=z.child,z.tag===22&&z.memoizedState!==null?rj(C):ee!==null?(ee.return=z,Ge=ee):rj(C);for(;T!==null;)Ge=T,tj(T),T=T.sibling;Ge=C,zu=K,Gn=ue}nj(a)}else(C.subtreeFlags&8772)!==0&&T!==null?(T.return=C,Ge=T):nj(a)}}function nj(a){for(;Ge!==null;){var l=Ge;if((l.flags&8772)!==0){var m=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Gn||Du(5,l);break;case 1:var w=l.stateNode;if(l.flags&4&&!Gn)if(m===null)w.componentDidMount();else{var C=l.elementType===l.type?m.memoizedProps:rr(l.type,m.memoizedProps);w.componentDidUpdate(C,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=l.updateQueue;T!==null&&sw(l,T,w);break;case 3:var z=l.updateQueue;if(z!==null){if(m=null,l.child!==null)switch(l.child.tag){case 5:m=l.child.stateNode;break;case 1:m=l.child.stateNode}sw(l,z,m)}break;case 5:var K=l.stateNode;if(m===null&&l.flags&4){m=K;var ee=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ee.autoFocus&&m.focus();break;case"img":ee.src&&(m.src=ee.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ue=l.alternate;if(ue!==null){var ke=ue.memoizedState;if(ke!==null){var Se=ke.dehydrated;Se!==null&&vo(Se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Gn||l.flags&512&&_p(l)}catch(je){ln(l,l.return,je)}}if(l===a){Ge=null;break}if(m=l.sibling,m!==null){m.return=l.return,Ge=m;break}Ge=l.return}}function sj(a){for(;Ge!==null;){var l=Ge;if(l===a){Ge=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Ge=m;break}Ge=l.return}}function rj(a){for(;Ge!==null;){var l=Ge;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{Du(4,l)}catch(ee){ln(l,m,ee)}break;case 1:var w=l.stateNode;if(typeof w.componentDidMount=="function"){var C=l.return;try{w.componentDidMount()}catch(ee){ln(l,C,ee)}}var T=l.return;try{_p(l)}catch(ee){ln(l,T,ee)}break;case 5:var z=l.return;try{_p(l)}catch(ee){ln(l,z,ee)}}}catch(ee){ln(l,l.return,ee)}if(l===a){Ge=null;break}var K=l.sibling;if(K!==null){K.return=l.return,Ge=K;break}Ge=l.return}}var iT=Math.ceil,Fu=S.ReactCurrentDispatcher,Ap=S.ReactCurrentOwner,Ds=S.ReactCurrentBatchConfig,Tt=0,_n=null,bn=null,zn=0,Cs=0,Di=ko(0),Nn=0,mc=null,_a=0,Uu=0,Op=0,hc=null,ms=null,Mp=0,Fi=1/0,Qr=null,Wu=!1,Lp=null,_o=null,Hu=!1,To=null,Bu=0,pc=0,Pp=null,qu=-1,Gu=0;function Xn(){return(Tt&6)!==0?pt():qu!==-1?qu:qu=pt()}function Ro(a){return(a.mode&1)===0?1:(Tt&2)!==0&&zn!==0?zn&-zn:B_.transition!==null?(Gu===0&&(Gu=Dl()),Gu):(a=At,a!==0||(a=window.event,a=a===void 0?16:ay(a.type)),a)}function ir(a,l,m,w){if(50<pc)throw pc=0,Pp=null,Error(s(185));po(a,m,w),((Tt&2)===0||a!==_n)&&(a===_n&&((Tt&2)===0&&(Uu|=m),Nn===4&&Ao(a,zn)),hs(a,w),m===1&&Tt===0&&(l.mode&1)===0&&(Fi=pt()+500,yu&&So()))}function hs(a,l){var m=a.callbackNode;nu(a,l);var w=va(a,a===_n?zn:0);if(w===0)m!==null&&qe(m),a.callbackNode=null,a.callbackPriority=0;else if(l=w&-w,a.callbackPriority!==l){if(m!=null&&qe(m),l===1)a.tag===0?H_(aj.bind(null,a)):qy(aj.bind(null,a)),D_(function(){(Tt&6)===0&&So()}),m=null;else{switch(Fl(w)){case 1:m=Ln;break;case 4:m=jr;break;case 16:m=Kt;break;case 536870912:m=mo;break;default:m=Kt}m=hj(m,oj.bind(null,a))}a.callbackPriority=l,a.callbackNode=m}}function oj(a,l){if(qu=-1,Gu=0,(Tt&6)!==0)throw Error(s(327));var m=a.callbackNode;if(Ui()&&a.callbackNode!==m)return null;var w=va(a,a===_n?zn:0);if(w===0)return null;if((w&30)!==0||(w&a.expiredLanes)!==0||l)l=Ku(a,w);else{l=w;var C=Tt;Tt|=2;var T=lj();(_n!==a||zn!==l)&&(Qr=null,Fi=pt()+500,Ra(a,l));do try{dT();break}catch(K){ij(a,K)}while(!0);ep(),Fu.current=T,Tt=C,bn!==null?l=0:(_n=null,zn=0,l=Nn)}if(l!==0){if(l===2&&(C=pi(a),C!==0&&(w=C,l=Ip(a,C))),l===1)throw m=mc,Ra(a,0),Ao(a,w),hs(a,pt()),m;if(l===6)Ao(a,w);else{if(C=a.current.alternate,(w&30)===0&&!lT(C)&&(l=Ku(a,w),l===2&&(T=pi(a),T!==0&&(w=T,l=Ip(a,T))),l===1))throw m=mc,Ra(a,0),Ao(a,w),hs(a,pt()),m;switch(a.finishedWork=C,a.finishedLanes=w,l){case 0:case 1:throw Error(s(345));case 2:Aa(a,ms,Qr);break;case 3:if(Ao(a,w),(w&130023424)===w&&(l=Mp+500-pt(),10<l)){if(va(a,0)!==0)break;if(C=a.suspendedLanes,(C&w)!==w){Xn(),a.pingedLanes|=a.suspendedLanes&C;break}a.timeoutHandle=Hh(Aa.bind(null,a,ms,Qr),l);break}Aa(a,ms,Qr);break;case 4:if(Ao(a,w),(w&4194240)===w)break;for(l=a.eventTimes,C=-1;0<w;){var z=31-cs(w);T=1<<z,z=l[z],z>C&&(C=z),w&=~T}if(w=C,w=pt()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*iT(w/1960))-w,10<w){a.timeoutHandle=Hh(Aa.bind(null,a,ms,Qr),w);break}Aa(a,ms,Qr);break;case 5:Aa(a,ms,Qr);break;default:throw Error(s(329))}}}return hs(a,pt()),a.callbackNode===m?oj.bind(null,a):null}function Ip(a,l){var m=hc;return a.current.memoizedState.isDehydrated&&(Ra(a,l).flags|=256),a=Ku(a,l),a!==2&&(l=ms,ms=m,l!==null&&zp(l)),a}function zp(a){ms===null?ms=a:ms.push.apply(ms,a)}function lT(a){for(var l=a;;){if(l.flags&16384){var m=l.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var w=0;w<m.length;w++){var C=m[w],T=C.getSnapshot;C=C.value;try{if(!nr(T(),C))return!1}catch{return!1}}}if(m=l.child,l.subtreeFlags&16384&&m!==null)m.return=l,l=m;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Ao(a,l){for(l&=~Op,l&=~Uu,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var m=31-cs(l),w=1<<m;a[m]=-1,l&=~w}}function aj(a){if((Tt&6)!==0)throw Error(s(327));Ui();var l=va(a,0);if((l&1)===0)return hs(a,pt()),null;var m=Ku(a,l);if(a.tag!==0&&m===2){var w=pi(a);w!==0&&(l=w,m=Ip(a,w))}if(m===1)throw m=mc,Ra(a,0),Ao(a,l),hs(a,pt()),m;if(m===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,Aa(a,ms,Qr),hs(a,pt()),null}function Dp(a,l){var m=Tt;Tt|=1;try{return a(l)}finally{Tt=m,Tt===0&&(Fi=pt()+500,yu&&So())}}function Ta(a){To!==null&&To.tag===0&&(Tt&6)===0&&Ui();var l=Tt;Tt|=1;var m=Ds.transition,w=At;try{if(Ds.transition=null,At=1,a)return a()}finally{At=w,Ds.transition=m,Tt=l,(Tt&6)===0&&So()}}function Fp(){Cs=Di.current,Yt(Di)}function Ra(a,l){a.finishedWork=null,a.finishedLanes=0;var m=a.timeoutHandle;if(m!==-1&&(a.timeoutHandle=-1,z_(m)),bn!==null)for(m=bn.return;m!==null;){var w=m;switch(Yh(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&vu();break;case 3:Pi(),Yt(ds),Yt(Hn),lp();break;case 5:ap(w);break;case 4:Pi();break;case 13:Yt(nn);break;case 19:Yt(nn);break;case 10:tp(w.type._context);break;case 22:case 23:Fp()}m=m.return}if(_n=a,bn=a=Oo(a.current,null),zn=Cs=l,Nn=0,mc=null,Op=Uu=_a=0,ms=hc=null,Ca!==null){for(l=0;l<Ca.length;l++)if(m=Ca[l],w=m.interleaved,w!==null){m.interleaved=null;var C=w.next,T=m.pending;if(T!==null){var z=T.next;T.next=C,w.next=z}m.pending=w}Ca=null}return a}function ij(a,l){do{var m=bn;try{if(ep(),Tu.current=Mu,Ru){for(var w=sn.memoizedState;w!==null;){var C=w.queue;C!==null&&(C.pending=null),w=w.next}Ru=!1}if($a=0,$n=kn=sn=null,ic=!1,lc=0,Ap.current=null,m===null||m.return===null){Nn=1,mc=l,bn=null;break}e:{var T=a,z=m.return,K=m,ee=l;if(l=zn,K.flags|=32768,ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var ue=ee,ke=K,Se=ke.tag;if((ke.mode&1)===0&&(Se===0||Se===11||Se===15)){var je=ke.alternate;je?(ke.updateQueue=je.updateQueue,ke.memoizedState=je.memoizedState,ke.lanes=je.lanes):(ke.updateQueue=null,ke.memoizedState=null)}var We=Aw(z);if(We!==null){We.flags&=-257,Ow(We,z,K,T,l),We.mode&1&&Rw(T,ue,l),l=We,ee=ue;var Ve=l.updateQueue;if(Ve===null){var Ye=new Set;Ye.add(ee),l.updateQueue=Ye}else Ve.add(ee);break e}else{if((l&1)===0){Rw(T,ue,l),Up();break e}ee=Error(s(426))}}else if(Xt&&K.mode&1){var un=Aw(z);if(un!==null){(un.flags&65536)===0&&(un.flags|=256),Ow(un,z,K,T,l),Xh(Ii(ee,K));break e}}T=ee=Ii(ee,K),Nn!==4&&(Nn=2),hc===null?hc=[T]:hc.push(T),T=z;do{switch(T.tag){case 3:T.flags|=65536,l&=-l,T.lanes|=l;var ce=_w(T,ee,l);nw(T,ce);break e;case 1:K=ee;var oe=T.type,de=T.stateNode;if((T.flags&128)===0&&(typeof oe.getDerivedStateFromError=="function"||de!==null&&typeof de.componentDidCatch=="function"&&(_o===null||!_o.has(de)))){T.flags|=65536,l&=-l,T.lanes|=l;var Oe=Tw(T,K,l);nw(T,Oe);break e}}T=T.return}while(T!==null)}dj(m)}catch(Xe){l=Xe,bn===m&&m!==null&&(bn=m=m.return);continue}break}while(!0)}function lj(){var a=Fu.current;return Fu.current=Mu,a===null?Mu:a}function Up(){(Nn===0||Nn===3||Nn===2)&&(Nn=4),_n===null||(_a&268435455)===0&&(Uu&268435455)===0||Ao(_n,zn)}function Ku(a,l){var m=Tt;Tt|=2;var w=lj();(_n!==a||zn!==l)&&(Qr=null,Ra(a,l));do try{cT();break}catch(C){ij(a,C)}while(!0);if(ep(),Tt=m,Fu.current=w,bn!==null)throw Error(s(261));return _n=null,zn=0,Nn}function cT(){for(;bn!==null;)cj(bn)}function dT(){for(;bn!==null&&!Lt();)cj(bn)}function cj(a){var l=mj(a.alternate,a,Cs);a.memoizedProps=a.pendingProps,l===null?dj(a):bn=l,Ap.current=null}function dj(a){var l=a;do{var m=l.alternate;if(a=l.return,(l.flags&32768)===0){if(m=nT(m,l,Cs),m!==null){bn=m;return}}else{if(m=sT(m,l),m!==null){m.flags&=32767,bn=m;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Nn=6,bn=null;return}}if(l=l.sibling,l!==null){bn=l;return}bn=l=a}while(l!==null);Nn===0&&(Nn=5)}function Aa(a,l,m){var w=At,C=Ds.transition;try{Ds.transition=null,At=1,uT(a,l,m,w)}finally{Ds.transition=C,At=w}return null}function uT(a,l,m,w){do Ui();while(To!==null);if((Tt&6)!==0)throw Error(s(327));m=a.finishedWork;var C=a.finishedLanes;if(m===null)return null;if(a.finishedWork=null,a.finishedLanes=0,m===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var T=m.lanes|m.childLanes;if(su(a,T),a===_n&&(bn=_n=null,zn=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Hu||(Hu=!0,hj(Kt,function(){return Ui(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Ds.transition,Ds.transition=null;var z=At;At=1;var K=Tt;Tt|=4,Ap.current=null,oT(a,m),ej(m,a),R_(Uh),wa=!!Fh,Uh=Fh=null,a.current=m,aT(m),Bt(),Tt=K,At=z,Ds.transition=T}else a.current=m;if(Hu&&(Hu=!1,To=a,Bu=C),T=a.pendingLanes,T===0&&(_o=null),Jd(m.stateNode),hs(a,pt()),l!==null)for(w=a.onRecoverableError,m=0;m<l.length;m++)C=l[m],w(C.value,{componentStack:C.stack,digest:C.digest});if(Wu)throw Wu=!1,a=Lp,Lp=null,a;return(Bu&1)!==0&&a.tag!==0&&Ui(),T=a.pendingLanes,(T&1)!==0?a===Pp?pc++:(pc=0,Pp=a):pc=0,So(),null}function Ui(){if(To!==null){var a=Fl(Bu),l=Ds.transition,m=At;try{if(Ds.transition=null,At=16>a?16:a,To===null)var w=!1;else{if(a=To,To=null,Bu=0,(Tt&6)!==0)throw Error(s(331));var C=Tt;for(Tt|=4,Ge=a.current;Ge!==null;){var T=Ge,z=T.child;if((Ge.flags&16)!==0){var K=T.deletions;if(K!==null){for(var ee=0;ee<K.length;ee++){var ue=K[ee];for(Ge=ue;Ge!==null;){var ke=Ge;switch(ke.tag){case 0:case 11:case 15:fc(8,ke,T)}var Se=ke.child;if(Se!==null)Se.return=ke,Ge=Se;else for(;Ge!==null;){ke=Ge;var je=ke.sibling,We=ke.return;if(Yw(ke),ke===ue){Ge=null;break}if(je!==null){je.return=We,Ge=je;break}Ge=We}}}var Ve=T.alternate;if(Ve!==null){var Ye=Ve.child;if(Ye!==null){Ve.child=null;do{var un=Ye.sibling;Ye.sibling=null,Ye=un}while(Ye!==null)}}Ge=T}}if((T.subtreeFlags&2064)!==0&&z!==null)z.return=T,Ge=z;else e:for(;Ge!==null;){if(T=Ge,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:fc(9,T,T.return)}var ce=T.sibling;if(ce!==null){ce.return=T.return,Ge=ce;break e}Ge=T.return}}var oe=a.current;for(Ge=oe;Ge!==null;){z=Ge;var de=z.child;if((z.subtreeFlags&2064)!==0&&de!==null)de.return=z,Ge=de;else e:for(z=oe;Ge!==null;){if(K=Ge,(K.flags&2048)!==0)try{switch(K.tag){case 0:case 11:case 15:Du(9,K)}}catch(Xe){ln(K,K.return,Xe)}if(K===z){Ge=null;break e}var Oe=K.sibling;if(Oe!==null){Oe.return=K.return,Ge=Oe;break e}Ge=K.return}}if(Tt=C,So(),js&&typeof js.onPostCommitFiberRoot=="function")try{js.onPostCommitFiberRoot(pa,a)}catch{}w=!0}return w}finally{At=m,Ds.transition=l}}return!1}function uj(a,l,m){l=Ii(m,l),l=_w(a,l,1),a=Eo(a,l,1),l=Xn(),a!==null&&(po(a,1,l),hs(a,l))}function ln(a,l,m){if(a.tag===3)uj(a,a,m);else for(;l!==null;){if(l.tag===3){uj(l,a,m);break}else if(l.tag===1){var w=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(_o===null||!_o.has(w))){a=Ii(m,a),a=Tw(l,a,1),l=Eo(l,a,1),a=Xn(),l!==null&&(po(l,1,a),hs(l,a));break}}l=l.return}}function fT(a,l,m){var w=a.pingCache;w!==null&&w.delete(l),l=Xn(),a.pingedLanes|=a.suspendedLanes&m,_n===a&&(zn&m)===m&&(Nn===4||Nn===3&&(zn&130023424)===zn&&500>pt()-Mp?Ra(a,0):Op|=m),hs(a,l)}function fj(a,l){l===0&&((a.mode&1)===0?l=1:(l=xa,xa<<=1,(xa&130023424)===0&&(xa=4194304)));var m=Xn();a=Kr(a,l),a!==null&&(po(a,l,m),hs(a,m))}function mT(a){var l=a.memoizedState,m=0;l!==null&&(m=l.retryLane),fj(a,m)}function hT(a,l){var m=0;switch(a.tag){case 13:var w=a.stateNode,C=a.memoizedState;C!==null&&(m=C.retryLane);break;case 19:w=a.stateNode;break;default:throw Error(s(314))}w!==null&&w.delete(l),fj(a,m)}var mj;mj=function(a,l,m){if(a!==null)if(a.memoizedProps!==l.pendingProps||ds.current)fs=!0;else{if((a.lanes&m)===0&&(l.flags&128)===0)return fs=!1,tT(a,l,m);fs=(a.flags&131072)!==0}else fs=!1,Xt&&(l.flags&1048576)!==0&&Gy(l,ju,l.index);switch(l.lanes=0,l.tag){case 2:var w=l.type;Iu(a,l),a=l.pendingProps;var C=_i(l,Hn.current);Li(l,m),C=up(null,l,w,a,C,m);var T=fp();return l.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,us(w)?(T=!0,bu(l)):T=!1,l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,rp(l),C.updater=Lu,l.stateNode=C,C._reactInternals=l,vp(l,w,a,m),l=jp(null,l,w,!0,T,m)):(l.tag=0,Xt&&T&&Vh(l),Jn(null,l,C,m),l=l.child),l;case 16:w=l.elementType;e:{switch(Iu(a,l),a=l.pendingProps,C=w._init,w=C(w._payload),l.type=w,C=l.tag=gT(w),a=rr(w,a),C){case 0:l=wp(null,l,w,a,m);break e;case 1:l=Dw(null,l,w,a,m);break e;case 11:l=Mw(null,l,w,a,m);break e;case 14:l=Lw(null,l,w,rr(w.type,a),m);break e}throw Error(s(306,w,""))}return l;case 0:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),wp(a,l,w,C,m);case 1:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),Dw(a,l,w,C,m);case 3:e:{if(Fw(l),a===null)throw Error(s(387));w=l.pendingProps,T=l.memoizedState,C=T.element,tw(a,l),$u(l,w,null,m);var z=l.memoizedState;if(w=z.element,T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){C=Ii(Error(s(423)),l),l=Uw(a,l,w,m,C);break e}else if(w!==C){C=Ii(Error(s(424)),l),l=Uw(a,l,w,m,C);break e}else for(Ss=jo(l.stateNode.containerInfo.firstChild),Ns=l,Xt=!0,sr=null,m=Zy(l,null,w,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(Ai(),w===C){l=Yr(a,l,m);break e}Jn(a,l,w,m)}l=l.child}return l;case 5:return rw(l),a===null&&Jh(l),w=l.type,C=l.pendingProps,T=a!==null?a.memoizedProps:null,z=C.children,Wh(w,C)?z=null:T!==null&&Wh(w,T)&&(l.flags|=32),zw(a,l),Jn(a,l,z,m),l.child;case 6:return a===null&&Jh(l),null;case 13:return Ww(a,l,m);case 4:return op(l,l.stateNode.containerInfo),w=l.pendingProps,a===null?l.child=Oi(l,null,w,m):Jn(a,l,w,m),l.child;case 11:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),Mw(a,l,w,C,m);case 7:return Jn(a,l,l.pendingProps,m),l.child;case 8:return Jn(a,l,l.pendingProps.children,m),l.child;case 12:return Jn(a,l,l.pendingProps.children,m),l.child;case 10:e:{if(w=l.type._context,C=l.pendingProps,T=l.memoizedProps,z=C.value,qt(Su,w._currentValue),w._currentValue=z,T!==null)if(nr(T.value,z)){if(T.children===C.children&&!ds.current){l=Yr(a,l,m);break e}}else for(T=l.child,T!==null&&(T.return=l);T!==null;){var K=T.dependencies;if(K!==null){z=T.child;for(var ee=K.firstContext;ee!==null;){if(ee.context===w){if(T.tag===1){ee=Vr(-1,m&-m),ee.tag=2;var ue=T.updateQueue;if(ue!==null){ue=ue.shared;var ke=ue.pending;ke===null?ee.next=ee:(ee.next=ke.next,ke.next=ee),ue.pending=ee}}T.lanes|=m,ee=T.alternate,ee!==null&&(ee.lanes|=m),np(T.return,m,l),K.lanes|=m;break}ee=ee.next}}else if(T.tag===10)z=T.type===l.type?null:T.child;else if(T.tag===18){if(z=T.return,z===null)throw Error(s(341));z.lanes|=m,K=z.alternate,K!==null&&(K.lanes|=m),np(z,m,l),z=T.sibling}else z=T.child;if(z!==null)z.return=T;else for(z=T;z!==null;){if(z===l){z=null;break}if(T=z.sibling,T!==null){T.return=z.return,z=T;break}z=z.return}T=z}Jn(a,l,C.children,m),l=l.child}return l;case 9:return C=l.type,w=l.pendingProps.children,Li(l,m),C=Is(C),w=w(C),l.flags|=1,Jn(a,l,w,m),l.child;case 14:return w=l.type,C=rr(w,l.pendingProps),C=rr(w.type,C),Lw(a,l,w,C,m);case 15:return Pw(a,l,l.type,l.pendingProps,m);case 17:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),Iu(a,l),l.tag=1,us(w)?(a=!0,bu(l)):a=!1,Li(l,m),Ew(l,w,C),vp(l,w,C,m),jp(null,l,w,!0,a,m);case 19:return Bw(a,l,m);case 22:return Iw(a,l,m)}throw Error(s(156,l.tag))};function hj(a,l){return _e(a,l)}function pT(a,l,m,w){this.tag=a,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fs(a,l,m,w){return new pT(a,l,m,w)}function Wp(a){return a=a.prototype,!(!a||!a.isReactComponent)}function gT(a){if(typeof a=="function")return Wp(a)?1:0;if(a!=null){if(a=a.$$typeof,a===L)return 11;if(a===Y)return 14}return 2}function Oo(a,l){var m=a.alternate;return m===null?(m=Fs(a.tag,l,a.key,a.mode),m.elementType=a.elementType,m.type=a.type,m.stateNode=a.stateNode,m.alternate=a,a.alternate=m):(m.pendingProps=l,m.type=a.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=a.flags&14680064,m.childLanes=a.childLanes,m.lanes=a.lanes,m.child=a.child,m.memoizedProps=a.memoizedProps,m.memoizedState=a.memoizedState,m.updateQueue=a.updateQueue,l=a.dependencies,m.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},m.sibling=a.sibling,m.index=a.index,m.ref=a.ref,m}function Vu(a,l,m,w,C,T){var z=2;if(w=a,typeof a=="function")Wp(a)&&(z=1);else if(typeof a=="string")z=5;else e:switch(a){case O:return Oa(m.children,C,T,l);case M:z=8,C|=8;break;case P:return a=Fs(12,m,l,C|2),a.elementType=P,a.lanes=T,a;case W:return a=Fs(13,m,l,C),a.elementType=W,a.lanes=T,a;case U:return a=Fs(19,m,l,C),a.elementType=U,a.lanes=T,a;case G:return Yu(m,C,T,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case A:z=10;break e;case R:z=9;break e;case L:z=11;break e;case Y:z=14;break e;case D:z=16,w=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return l=Fs(z,m,l,C),l.elementType=a,l.type=w,l.lanes=T,l}function Oa(a,l,m,w){return a=Fs(7,a,w,l),a.lanes=m,a}function Yu(a,l,m,w){return a=Fs(22,a,w,l),a.elementType=G,a.lanes=m,a.stateNode={isHidden:!1},a}function Hp(a,l,m){return a=Fs(6,a,null,l),a.lanes=m,a}function Bp(a,l,m){return l=Fs(4,a.children!==null?a.children:[],a.key,l),l.lanes=m,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function xT(a,l,m,w,C){this.tag=l,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=gi(0),this.expirationTimes=gi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gi(0),this.identifierPrefix=w,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function qp(a,l,m,w,C,T,z,K,ee){return a=new xT(a,l,m,K,ee),l===1?(l=1,T===!0&&(l|=8)):l=0,T=Fs(3,null,null,l),a.current=T,T.stateNode=a,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},rp(T),a}function vT(a,l,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:w==null?null:""+w,children:a,containerInfo:l,implementation:m}}function pj(a){if(!a)return No;a=a._reactInternals;e:{if(ls(a)!==a||a.tag!==1)throw Error(s(170));var l=a;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(us(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(s(171))}if(a.tag===1){var m=a.type;if(us(m))return Hy(a,m,l)}return l}function gj(a,l,m,w,C,T,z,K,ee){return a=qp(m,w,!0,a,C,T,z,K,ee),a.context=pj(null),m=a.current,w=Xn(),C=Ro(m),T=Vr(w,C),T.callback=l??null,Eo(m,T,C),a.current.lanes=C,po(a,C,w),hs(a,w),a}function Qu(a,l,m,w){var C=l.current,T=Xn(),z=Ro(C);return m=pj(m),l.context===null?l.context=m:l.pendingContext=m,l=Vr(T,z),l.payload={element:a},w=w===void 0?null:w,w!==null&&(l.callback=w),a=Eo(C,l,z),a!==null&&(ir(a,C,z,T),Eu(a,C,z)),z}function Ju(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function xj(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var m=a.retryLane;a.retryLane=m!==0&&m<l?m:l}}function Gp(a,l){xj(a,l),(a=a.alternate)&&xj(a,l)}function bT(){return null}var vj=typeof reportError=="function"?reportError:function(a){console.error(a)};function Kp(a){this._internalRoot=a}Xu.prototype.render=Kp.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(s(409));Qu(a,l,null,null)},Xu.prototype.unmount=Kp.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;Ta(function(){Qu(null,a,null,null)}),l[Hr]=null}};function Xu(a){this._internalRoot=a}Xu.prototype.unstable_scheduleHydration=function(a){if(a){var l=Hl();a={blockedOn:null,target:a,priority:l};for(var m=0;m<Ce.length&&l!==0&&l<Ce[m].priority;m++);Ce.splice(m,0,a),m===0&&Wn(a)}};function Vp(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Zu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function bj(){}function yT(a,l,m,w,C){if(C){if(typeof w=="function"){var T=w;w=function(){var ue=Ju(z);T.call(ue)}}var z=gj(l,w,a,0,null,!1,!1,"",bj);return a._reactRootContainer=z,a[Hr]=z.current,Zl(a.nodeType===8?a.parentNode:a),Ta(),z}for(;C=a.lastChild;)a.removeChild(C);if(typeof w=="function"){var K=w;w=function(){var ue=Ju(ee);K.call(ue)}}var ee=qp(a,0,!1,null,null,!1,!1,"",bj);return a._reactRootContainer=ee,a[Hr]=ee.current,Zl(a.nodeType===8?a.parentNode:a),Ta(function(){Qu(l,ee,m,w)}),ee}function ef(a,l,m,w,C){var T=m._reactRootContainer;if(T){var z=T;if(typeof C=="function"){var K=C;C=function(){var ee=Ju(z);K.call(ee)}}Qu(l,z,a,C)}else z=yT(m,l,a,C,w);return Ju(z)}Ul=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var m=ho(l.pendingLanes);m!==0&&(xi(l,m|1),hs(l,pt()),(Tt&6)===0&&(Fi=pt()+500,So()))}break;case 13:Ta(function(){var w=Kr(a,1);if(w!==null){var C=Xn();ir(w,a,1,C)}}),Gp(a,1)}},vi=function(a){if(a.tag===13){var l=Kr(a,134217728);if(l!==null){var m=Xn();ir(l,a,134217728,m)}Gp(a,134217728)}},Wl=function(a){if(a.tag===13){var l=Ro(a),m=Kr(a,l);if(m!==null){var w=Xn();ir(m,a,l,w)}Gp(a,l)}},Hl=function(){return At},Bl=function(a,l){var m=At;try{return At=a,l()}finally{At=m}},se=function(a,l,m){switch(l){case"input":if(tt(a,m),l=m.name,m.type==="radio"&&l!=null){for(m=a;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<m.length;l++){var w=m[l];if(w!==a&&w.form===a.form){var C=xu(w);if(!C)throw Error(s(90));me(w),tt(w,C)}}}break;case"textarea":ne(a,m);break;case"select":l=m.value,l!=null&&Q(a,!!m.multiple,l,!1)}},rt=Dp,Ft=Ta;var wT={usingClientEntryPoint:!1,Events:[nc,Ei,xu,Dt,Le,Dp]},gc={findFiberByHostInstance:ja,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},jT={bundleType:gc.bundleType,version:gc.version,rendererPackageName:gc.rendererPackageName,rendererConfig:gc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Ze(a),a===null?null:a.stateNode},findFiberByHostInstance:gc.findFiberByHostInstance||bT,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 tf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!tf.isDisabled&&tf.supportsFiber)try{pa=tf.inject(jT),js=tf}catch{}}return ps.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wT,ps.createPortal=function(a,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Vp(l))throw Error(s(200));return vT(a,l,null,m)},ps.createRoot=function(a,l){if(!Vp(a))throw Error(s(299));var m=!1,w="",C=vj;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),l=qp(a,1,!1,null,null,m,!1,w,C),a[Hr]=l.current,Zl(a.nodeType===8?a.parentNode:a),new Kp(l)},ps.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(s(188)):(a=Object.keys(a).join(","),Error(s(268,a)));return a=Ze(l),a=a===null?null:a.stateNode,a},ps.flushSync=function(a){return Ta(a)},ps.hydrate=function(a,l,m){if(!Zu(l))throw Error(s(200));return ef(null,a,l,!0,m)},ps.hydrateRoot=function(a,l,m){if(!Vp(a))throw Error(s(405));var w=m!=null&&m.hydratedSources||null,C=!1,T="",z=vj;if(m!=null&&(m.unstable_strictMode===!0&&(C=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(z=m.onRecoverableError)),l=gj(l,null,a,1,m??null,C,!1,T,z),a[Hr]=l.current,Zl(a),w)for(a=0;a<w.length;a++)m=w[a],C=m._getVersion,C=C(m._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[m,C]:l.mutableSourceEagerHydrationData.push(m,C);return new Xu(l)},ps.render=function(a,l,m){if(!Zu(l))throw Error(s(200));return ef(null,a,l,!1,m)},ps.unmountComponentAtNode=function(a){if(!Zu(a))throw Error(s(40));return a._reactRootContainer?(Ta(function(){ef(null,null,a,!1,function(){a._reactRootContainer=null,a[Hr]=null})}),!0):!1},ps.unstable_batchedUpdates=Dp,ps.unstable_renderSubtreeIntoContainer=function(a,l,m,w){if(!Zu(m))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return ef(a,l,m,!1,w)},ps.version="18.3.1-next-f1338f8080-20240426",ps}var Ej;function QN(){if(Ej)return Jp.exports;Ej=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Jp.exports=AT(),Jp.exports}var $j;function OT(){if($j)return nf;$j=1;var e=QN();return nf.createRoot=e.createRoot,nf.hydrateRoot=e.hydrateRoot,nf}var MT=OT();function os(e){const n=e&&typeof e=="object"?e.sdk:void 0;return(n==null?void 0:n.runtime)==="claude-agent-sdk"||(n==null?void 0:n.runtime)==="codex-sdk"?{runtime:n.runtime}:void 0}const sa=e=>e==="claude-agent-sdk"?"Claude Agent SDK":"Codex SDK";/**
41
+ * @license lucide-react v0.468.0 - ISC
42
+ *
43
+ * This source code is licensed under the ISC license.
44
+ * See the LICENSE file in the root directory of this source tree.
45
+ */const LT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),JN=(...e)=>e.filter((n,s,r)=>!!n&&n.trim()!==""&&r.indexOf(n)===s).join(" ").trim();/**
46
+ * @license lucide-react v0.468.0 - ISC
47
+ *
48
+ * This source code is licensed under the ISC license.
49
+ * See the LICENSE file in the root directory of this source tree.
50
+ */var PT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
51
+ * @license lucide-react v0.468.0 - ISC
52
+ *
53
+ * This source code is licensed under the ISC license.
54
+ * See the LICENSE file in the root directory of this source tree.
55
+ */const IT=p.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:c,...d},u)=>p.createElement("svg",{ref:u,...PT,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:JN("lucide",o),...d},[...c.map(([f,g])=>p.createElement(f,g)),...Array.isArray(i)?i:[i]]));/**
56
+ * @license lucide-react v0.468.0 - ISC
57
+ *
58
+ * This source code is licensed under the ISC license.
59
+ * See the LICENSE file in the root directory of this source tree.
60
+ */const Te=(e,n)=>{const s=p.forwardRef(({className:r,...o},i)=>p.createElement(IT,{ref:i,iconNode:n,className:JN(`lucide-${LT(e)}`,r),...o}));return s.displayName=`${e}`,s};/**
61
+ * @license lucide-react v0.468.0 - ISC
62
+ *
63
+ * This source code is licensed under the ISC license.
64
+ * See the LICENSE file in the root directory of this source tree.
65
+ */const zT=Te("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
66
+ * @license lucide-react v0.468.0 - ISC
67
+ *
68
+ * This source code is licensed under the ISC license.
69
+ * See the LICENSE file in the root directory of this source tree.
70
+ */const XN=Te("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
71
+ * @license lucide-react v0.468.0 - ISC
72
+ *
73
+ * This source code is licensed under the ISC license.
74
+ * See the LICENSE file in the root directory of this source tree.
75
+ */const xd=Te("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
76
+ * @license lucide-react v0.468.0 - ISC
77
+ *
78
+ * This source code is licensed under the ISC license.
79
+ * See the LICENSE file in the root directory of this source tree.
80
+ */const DT=Te("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
81
+ * @license lucide-react v0.468.0 - ISC
82
+ *
83
+ * This source code is licensed under the ISC license.
84
+ * See the LICENSE file in the root directory of this source tree.
85
+ */const Fn=Te("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
86
+ * @license lucide-react v0.468.0 - ISC
87
+ *
88
+ * This source code is licensed under the ISC license.
89
+ * See the LICENSE file in the root directory of this source tree.
90
+ */const Zx=Te("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
91
+ * @license lucide-react v0.468.0 - ISC
92
+ *
93
+ * This source code is licensed under the ISC license.
94
+ * See the LICENSE file in the root directory of this source tree.
95
+ */const pr=Te("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
96
+ * @license lucide-react v0.468.0 - ISC
97
+ *
98
+ * This source code is licensed under the ISC license.
99
+ * See the LICENSE file in the root directory of this source tree.
100
+ */const ZN=Te("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
101
+ * @license lucide-react v0.468.0 - ISC
102
+ *
103
+ * This source code is licensed under the ISC license.
104
+ * See the LICENSE file in the root directory of this source tree.
105
+ */const Cm=Te("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
106
+ * @license lucide-react v0.468.0 - ISC
107
+ *
108
+ * This source code is licensed under the ISC license.
109
+ * See the LICENSE file in the root directory of this source tree.
110
+ */const e1=Te("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
111
+ * @license lucide-react v0.468.0 - ISC
112
+ *
113
+ * This source code is licensed under the ISC license.
114
+ * See the LICENSE file in the root directory of this source tree.
115
+ */const Xc=Te("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
116
+ * @license lucide-react v0.468.0 - ISC
117
+ *
118
+ * This source code is licensed under the ISC license.
119
+ * See the LICENSE file in the root directory of this source tree.
120
+ */const vd=Te("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
121
+ * @license lucide-react v0.468.0 - ISC
122
+ *
123
+ * This source code is licensed under the ISC license.
124
+ * See the LICENSE file in the root directory of this source tree.
125
+ */const Cl=Te("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
126
+ * @license lucide-react v0.468.0 - ISC
127
+ *
128
+ * This source code is licensed under the ISC license.
129
+ * See the LICENSE file in the root directory of this source tree.
130
+ */const ri=Te("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
131
+ * @license lucide-react v0.468.0 - ISC
132
+ *
133
+ * This source code is licensed under the ISC license.
134
+ * See the LICENSE file in the root directory of this source tree.
135
+ */const FT=Te("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
136
+ * @license lucide-react v0.468.0 - ISC
137
+ *
138
+ * This source code is licensed under the ISC license.
139
+ * See the LICENSE file in the root directory of this source tree.
140
+ */const As=Te("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
141
+ * @license lucide-react v0.468.0 - ISC
142
+ *
143
+ * This source code is licensed under the ISC license.
144
+ * See the LICENSE file in the root directory of this source tree.
145
+ */const ul=Te("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
146
+ * @license lucide-react v0.468.0 - ISC
147
+ *
148
+ * This source code is licensed under the ISC license.
149
+ * See the LICENSE file in the root directory of this source tree.
150
+ */const UT=Te("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
151
+ * @license lucide-react v0.468.0 - ISC
152
+ *
153
+ * This source code is licensed under the ISC license.
154
+ * See the LICENSE file in the root directory of this source tree.
155
+ */const t1=Te("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
156
+ * @license lucide-react v0.468.0 - ISC
157
+ *
158
+ * This source code is licensed under the ISC license.
159
+ * See the LICENSE file in the root directory of this source tree.
160
+ */const ev=Te("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
161
+ * @license lucide-react v0.468.0 - ISC
162
+ *
163
+ * This source code is licensed under the ISC license.
164
+ * See the LICENSE file in the root directory of this source tree.
165
+ */const WT=Te("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
166
+ * @license lucide-react v0.468.0 - ISC
167
+ *
168
+ * This source code is licensed under the ISC license.
169
+ * See the LICENSE file in the root directory of this source tree.
170
+ */const n1=Te("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
171
+ * @license lucide-react v0.468.0 - ISC
172
+ *
173
+ * This source code is licensed under the ISC license.
174
+ * See the LICENSE file in the root directory of this source tree.
175
+ */const HT=Te("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
176
+ * @license lucide-react v0.468.0 - ISC
177
+ *
178
+ * This source code is licensed under the ISC license.
179
+ * See the LICENSE file in the root directory of this source tree.
180
+ */const BT=Te("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
181
+ * @license lucide-react v0.468.0 - ISC
182
+ *
183
+ * This source code is licensed under the ISC license.
184
+ * See the LICENSE file in the root directory of this source tree.
185
+ */const Em=Te("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
186
+ * @license lucide-react v0.468.0 - ISC
187
+ *
188
+ * This source code is licensed under the ISC license.
189
+ * See the LICENSE file in the root directory of this source tree.
190
+ */const oi=Te("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
191
+ * @license lucide-react v0.468.0 - ISC
192
+ *
193
+ * This source code is licensed under the ISC license.
194
+ * See the LICENSE file in the root directory of this source tree.
195
+ */const qT=Te("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
196
+ * @license lucide-react v0.468.0 - ISC
197
+ *
198
+ * This source code is licensed under the ISC license.
199
+ * See the LICENSE file in the root directory of this source tree.
200
+ */const GT=Te("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
201
+ * @license lucide-react v0.468.0 - ISC
202
+ *
203
+ * This source code is licensed under the ISC license.
204
+ * See the LICENSE file in the root directory of this source tree.
205
+ */const tv=Te("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
206
+ * @license lucide-react v0.468.0 - ISC
207
+ *
208
+ * This source code is licensed under the ISC license.
209
+ * See the LICENSE file in the root directory of this source tree.
210
+ */const KT=Te("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
211
+ * @license lucide-react v0.468.0 - ISC
212
+ *
213
+ * This source code is licensed under the ISC license.
214
+ * See the LICENSE file in the root directory of this source tree.
215
+ */const VT=Te("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
216
+ * @license lucide-react v0.468.0 - ISC
217
+ *
218
+ * This source code is licensed under the ISC license.
219
+ * See the LICENSE file in the root directory of this source tree.
220
+ */const $m=Te("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
221
+ * @license lucide-react v0.468.0 - ISC
222
+ *
223
+ * This source code is licensed under the ISC license.
224
+ * See the LICENSE file in the root directory of this source tree.
225
+ */const ai=Te("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
226
+ * @license lucide-react v0.468.0 - ISC
227
+ *
228
+ * This source code is licensed under the ISC license.
229
+ * See the LICENSE file in the root directory of this source tree.
230
+ */const s1=Te("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
231
+ * @license lucide-react v0.468.0 - ISC
232
+ *
233
+ * This source code is licensed under the ISC license.
234
+ * See the LICENSE file in the root directory of this source tree.
235
+ */const YT=Te("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
236
+ * @license lucide-react v0.468.0 - ISC
237
+ *
238
+ * This source code is licensed under the ISC license.
239
+ * See the LICENSE file in the root directory of this source tree.
240
+ */const _m=Te("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/**
241
+ * @license lucide-react v0.468.0 - ISC
242
+ *
243
+ * This source code is licensed under the ISC license.
244
+ * See the LICENSE file in the root directory of this source tree.
245
+ */const _j=Te("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/**
246
+ * @license lucide-react v0.468.0 - ISC
247
+ *
248
+ * This source code is licensed under the ISC license.
249
+ * See the LICENSE file in the root directory of this source tree.
250
+ */const r1=Te("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
251
+ * @license lucide-react v0.468.0 - ISC
252
+ *
253
+ * This source code is licensed under the ISC license.
254
+ * See the LICENSE file in the root directory of this source tree.
255
+ */const QT=Te("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/**
256
+ * @license lucide-react v0.468.0 - ISC
257
+ *
258
+ * This source code is licensed under the ISC license.
259
+ * See the LICENSE file in the root directory of this source tree.
260
+ */const JT=Te("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
261
+ * @license lucide-react v0.468.0 - ISC
262
+ *
263
+ * This source code is licensed under the ISC license.
264
+ * See the LICENSE file in the root directory of this source tree.
265
+ */const bd=Te("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
266
+ * @license lucide-react v0.468.0 - ISC
267
+ *
268
+ * This source code is licensed under the ISC license.
269
+ * See the LICENSE file in the root directory of this source tree.
270
+ */const o1=Te("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/**
271
+ * @license lucide-react v0.468.0 - ISC
272
+ *
273
+ * This source code is licensed under the ISC license.
274
+ * See the LICENSE file in the root directory of this source tree.
275
+ */const qg=Te("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
276
+ * @license lucide-react v0.468.0 - ISC
277
+ *
278
+ * This source code is licensed under the ISC license.
279
+ * See the LICENSE file in the root directory of this source tree.
280
+ */const Ka=Te("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
281
+ * @license lucide-react v0.468.0 - ISC
282
+ *
283
+ * This source code is licensed under the ISC license.
284
+ * See the LICENSE file in the root directory of this source tree.
285
+ */const a1=Te("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
286
+ * @license lucide-react v0.468.0 - ISC
287
+ *
288
+ * This source code is licensed under the ISC license.
289
+ * See the LICENSE file in the root directory of this source tree.
290
+ */const Tm=Te("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
291
+ * @license lucide-react v0.468.0 - ISC
292
+ *
293
+ * This source code is licensed under the ISC license.
294
+ * See the LICENSE file in the root directory of this source tree.
295
+ */const XT=Te("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
296
+ * @license lucide-react v0.468.0 - ISC
297
+ *
298
+ * This source code is licensed under the ISC license.
299
+ * See the LICENSE file in the root directory of this source tree.
300
+ */const ZT=Te("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
301
+ * @license lucide-react v0.468.0 - ISC
302
+ *
303
+ * This source code is licensed under the ISC license.
304
+ * See the LICENSE file in the root directory of this source tree.
305
+ */const eg=Te("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/**
306
+ * @license lucide-react v0.468.0 - ISC
307
+ *
308
+ * This source code is licensed under the ISC license.
309
+ * See the LICENSE file in the root directory of this source tree.
310
+ */const eR=Te("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
311
+ * @license lucide-react v0.468.0 - ISC
312
+ *
313
+ * This source code is licensed under the ISC license.
314
+ * See the LICENSE file in the root directory of this source tree.
315
+ */const tR=Te("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
316
+ * @license lucide-react v0.468.0 - ISC
317
+ *
318
+ * This source code is licensed under the ISC license.
319
+ * See the LICENSE file in the root directory of this source tree.
320
+ */const i1=Te("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
321
+ * @license lucide-react v0.468.0 - ISC
322
+ *
323
+ * This source code is licensed under the ISC license.
324
+ * See the LICENSE file in the root directory of this source tree.
325
+ */const nR=Te("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
326
+ * @license lucide-react v0.468.0 - ISC
327
+ *
328
+ * This source code is licensed under the ISC license.
329
+ * See the LICENSE file in the root directory of this source tree.
330
+ */const nv=Te("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
331
+ * @license lucide-react v0.468.0 - ISC
332
+ *
333
+ * This source code is licensed under the ISC license.
334
+ * See the LICENSE file in the root directory of this source tree.
335
+ */const sR=Te("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/**
336
+ * @license lucide-react v0.468.0 - ISC
337
+ *
338
+ * This source code is licensed under the ISC license.
339
+ * See the LICENSE file in the root directory of this source tree.
340
+ */const rR=Te("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
341
+ * @license lucide-react v0.468.0 - ISC
342
+ *
343
+ * This source code is licensed under the ISC license.
344
+ * See the LICENSE file in the root directory of this source tree.
345
+ */const ii=Te("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
346
+ * @license lucide-react v0.468.0 - ISC
347
+ *
348
+ * This source code is licensed under the ISC license.
349
+ * See the LICENSE file in the root directory of this source tree.
350
+ */const oR=Te("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
351
+ * @license lucide-react v0.468.0 - ISC
352
+ *
353
+ * This source code is licensed under the ISC license.
354
+ * See the LICENSE file in the root directory of this source tree.
355
+ */const aR=Te("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
356
+ * @license lucide-react v0.468.0 - ISC
357
+ *
358
+ * This source code is licensed under the ISC license.
359
+ * See the LICENSE file in the root directory of this source tree.
360
+ */const iR=Te("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
361
+ * @license lucide-react v0.468.0 - ISC
362
+ *
363
+ * This source code is licensed under the ISC license.
364
+ * See the LICENSE file in the root directory of this source tree.
365
+ */const fl=Te("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
366
+ * @license lucide-react v0.468.0 - ISC
367
+ *
368
+ * This source code is licensed under the ISC license.
369
+ * See the LICENSE file in the root directory of this source tree.
370
+ */const sv=Te("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
371
+ * @license lucide-react v0.468.0 - ISC
372
+ *
373
+ * This source code is licensed under the ISC license.
374
+ * See the LICENSE file in the root directory of this source tree.
375
+ */const ra=Te("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
376
+ * @license lucide-react v0.468.0 - ISC
377
+ *
378
+ * This source code is licensed under the ISC license.
379
+ * See the LICENSE file in the root directory of this source tree.
380
+ */const lR=Te("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
381
+ * @license lucide-react v0.468.0 - ISC
382
+ *
383
+ * This source code is licensed under the ISC license.
384
+ * See the LICENSE file in the root directory of this source tree.
385
+ */const Rm=Te("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
386
+ * @license lucide-react v0.468.0 - ISC
387
+ *
388
+ * This source code is licensed under the ISC license.
389
+ * See the LICENSE file in the root directory of this source tree.
390
+ */const cR=Te("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
391
+ * @license lucide-react v0.468.0 - ISC
392
+ *
393
+ * This source code is licensed under the ISC license.
394
+ * See the LICENSE file in the root directory of this source tree.
395
+ */const l1=Te("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/**
396
+ * @license lucide-react v0.468.0 - ISC
397
+ *
398
+ * This source code is licensed under the ISC license.
399
+ * See the LICENSE file in the root directory of this source tree.
400
+ */const oa=Te("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
401
+ * @license lucide-react v0.468.0 - ISC
402
+ *
403
+ * This source code is licensed under the ISC license.
404
+ * See the LICENSE file in the root directory of this source tree.
405
+ */const dR=Te("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
406
+ * @license lucide-react v0.468.0 - ISC
407
+ *
408
+ * This source code is licensed under the ISC license.
409
+ * See the LICENSE file in the root directory of this source tree.
410
+ */const rv=Te("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/**
411
+ * @license lucide-react v0.468.0 - ISC
412
+ *
413
+ * This source code is licensed under the ISC license.
414
+ * See the LICENSE file in the root directory of this source tree.
415
+ */const uR=Te("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
416
+ * @license lucide-react v0.468.0 - ISC
417
+ *
418
+ * This source code is licensed under the ISC license.
419
+ * See the LICENSE file in the root directory of this source tree.
420
+ */const yd=Te("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
421
+ * @license lucide-react v0.468.0 - ISC
422
+ *
423
+ * This source code is licensed under the ISC license.
424
+ * See the LICENSE file in the root directory of this source tree.
425
+ */const c1=Te("Settings",[["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",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
426
+ * @license lucide-react v0.468.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */const fR=Te("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
431
+ * @license lucide-react v0.468.0 - ISC
432
+ *
433
+ * This source code is licensed under the ISC license.
434
+ * See the LICENSE file in the root directory of this source tree.
435
+ */const d1=Te("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
436
+ * @license lucide-react v0.468.0 - ISC
437
+ *
438
+ * This source code is licensed under the ISC license.
439
+ * See the LICENSE file in the root directory of this source tree.
440
+ */const u1=Te("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
441
+ * @license lucide-react v0.468.0 - ISC
442
+ *
443
+ * This source code is licensed under the ISC license.
444
+ * See the LICENSE file in the root directory of this source tree.
445
+ */const f1=Te("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
446
+ * @license lucide-react v0.468.0 - ISC
447
+ *
448
+ * This source code is licensed under the ISC license.
449
+ * See the LICENSE file in the root directory of this source tree.
450
+ */const mR=Te("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
451
+ * @license lucide-react v0.468.0 - ISC
452
+ *
453
+ * This source code is licensed under the ISC license.
454
+ * See the LICENSE file in the root directory of this source tree.
455
+ */const hR=Te("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
456
+ * @license lucide-react v0.468.0 - ISC
457
+ *
458
+ * This source code is licensed under the ISC license.
459
+ * See the LICENSE file in the root directory of this source tree.
460
+ */const pR=Te("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
461
+ * @license lucide-react v0.468.0 - ISC
462
+ *
463
+ * This source code is licensed under the ISC license.
464
+ * See the LICENSE file in the root directory of this source tree.
465
+ */const m1=Te("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
466
+ * @license lucide-react v0.468.0 - ISC
467
+ *
468
+ * This source code is licensed under the ISC license.
469
+ * See the LICENSE file in the root directory of this source tree.
470
+ */const Ys=Te("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
471
+ * @license lucide-react v0.468.0 - ISC
472
+ *
473
+ * This source code is licensed under the ISC license.
474
+ * See the LICENSE file in the root directory of this source tree.
475
+ */const h1=Te("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
476
+ * @license lucide-react v0.468.0 - ISC
477
+ *
478
+ * This source code is licensed under the ISC license.
479
+ * See the LICENSE file in the root directory of this source tree.
480
+ */const ml=Te("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/**
481
+ * @license lucide-react v0.468.0 - ISC
482
+ *
483
+ * This source code is licensed under the ISC license.
484
+ * See the LICENSE file in the root directory of this source tree.
485
+ */const p1=Te("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
486
+ * @license lucide-react v0.468.0 - ISC
487
+ *
488
+ * This source code is licensed under the ISC license.
489
+ * See the LICENSE file in the root directory of this source tree.
490
+ */const li=Te("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/**
491
+ * @license lucide-react v0.468.0 - ISC
492
+ *
493
+ * This source code is licensed under the ISC license.
494
+ * See the LICENSE file in the root directory of this source tree.
495
+ */const Gg=Te("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
496
+ * @license lucide-react v0.468.0 - ISC
497
+ *
498
+ * This source code is licensed under the ISC license.
499
+ * See the LICENSE file in the root directory of this source tree.
500
+ */const uo=Te("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
501
+ * @license lucide-react v0.468.0 - ISC
502
+ *
503
+ * This source code is licensed under the ISC license.
504
+ * See the LICENSE file in the root directory of this source tree.
505
+ */const gR=Te("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/**
506
+ * @license lucide-react v0.468.0 - ISC
507
+ *
508
+ * This source code is licensed under the ISC license.
509
+ * See the LICENSE file in the root directory of this source tree.
510
+ */const xR=Te("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
511
+ * @license lucide-react v0.468.0 - ISC
512
+ *
513
+ * This source code is licensed under the ISC license.
514
+ * See the LICENSE file in the root directory of this source tree.
515
+ */const vR=Te("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function g1(e){var n,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(s=g1(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function x1(){for(var e,n,s=0,r="",o=arguments.length;s<o;s++)(e=arguments[s])&&(n=g1(e))&&(r&&(r+=" "),r+=n);return r}const ov="-",bR=e=>{const n=wR(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const d=c.split(ov);return d[0]===""&&d.length!==1&&d.shift(),v1(d,n)||yR(c)},getConflictingClassGroupIds:(c,d)=>{const u=s[c]||[];return d&&r[c]?[...u,...r[c]]:u}}},v1=(e,n)=>{var c;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),o=r?v1(e.slice(1),r):void 0;if(o)return o;if(n.validators.length===0)return;const i=e.join(ov);return(c=n.validators.find(({validator:d})=>d(i)))==null?void 0:c.classGroupId},Tj=/^\[(.+)\]$/,yR=e=>{if(Tj.test(e)){const n=Tj.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},wR=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return kR(Object.entries(e.classGroups),s).forEach(([i,c])=>{Kg(c,r,i,n)}),r},Kg=(e,n,s,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?n:Rj(n,o);i.classGroupId=s;return}if(typeof o=="function"){if(jR(o)){Kg(o(r),n,s,r);return}n.validators.push({validator:o,classGroupId:s});return}Object.entries(o).forEach(([i,c])=>{Kg(c,Rj(n,i),s,r)})})},Rj=(e,n)=>{let s=e;return n.split(ov).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},jR=e=>e.isThemeGetter,kR=(e,n)=>n?e.map(([s,r])=>{const o=r.map(i=>typeof i=="string"?n+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([c,d])=>[n+c,d])):i);return[s,o]}):e,NR=e=>{if(e<1)return{get:()=>{},set:()=>{}};let n=0,s=new Map,r=new Map;const o=(i,c)=>{s.set(i,c),n++,n>e&&(n=0,r=s,s=new Map)};return{get(i){let c=s.get(i);if(c!==void 0)return c;if((c=r.get(i))!==void 0)return o(i,c),c},set(i,c){s.has(i)?s.set(i,c):o(i,c)}}},b1="!",SR=e=>{const{separator:n,experimentalParseClassName:s}=e,r=n.length===1,o=n[0],i=n.length,c=d=>{const u=[];let f=0,g=0,y;for(let j=0;j<d.length;j++){let k=d[j];if(f===0){if(k===o&&(r||d.slice(j,j+i)===n)){u.push(d.slice(g,j)),g=j+i;continue}if(k==="/"){y=j;continue}}k==="["?f++:k==="]"&&f--}const v=u.length===0?d:d.substring(g),h=v.startsWith(b1),x=h?v.substring(1):v,b=y&&y>g?y-g:void 0;return{modifiers:u,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:b}};return s?d=>s({className:d,parseClassName:c}):c},CR=e=>{if(e.length<=1)return e;const n=[];let s=[];return e.forEach(r=>{r[0]==="["?(n.push(...s.sort(),r),s=[]):s.push(r)}),n.push(...s.sort()),n},ER=e=>({cache:NR(e.cacheSize),parseClassName:SR(e),...bR(e)}),$R=/\s+/,_R=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:o}=n,i=[],c=e.trim().split($R);let d="";for(let u=c.length-1;u>=0;u-=1){const f=c[u],{modifiers:g,hasImportantModifier:y,baseClassName:v,maybePostfixModifierPosition:h}=s(f);let x=!!h,b=r(x?v.substring(0,h):v);if(!b){if(!x){d=f+(d.length>0?" "+d:d);continue}if(b=r(v),!b){d=f+(d.length>0?" "+d:d);continue}x=!1}const j=CR(g).join(":"),k=y?j+b1:j,E=k+b;if(i.includes(E))continue;i.push(E);const N=o(b,x);for(let S=0;S<N.length;++S){const $=N[S];i.push(k+$)}d=f+(d.length>0?" "+d:d)}return d};function TR(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=y1(n))&&(r&&(r+=" "),r+=s);return r}const y1=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=y1(e[r]))&&(s&&(s+=" "),s+=n);return s};function Aj(e,...n){let s,r,o,i=c;function c(u){const f=n.reduce((g,y)=>y(g),e());return s=ER(f),r=s.cache.get,o=s.cache.set,i=d,d(u)}function d(u){const f=r(u);if(f)return f;const g=_R(u,s);return o(u,g),g}return function(){return i(TR.apply(null,arguments))}}const Qt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},w1=/^\[(?:([a-z-]+):)?(.+)\]$/i,RR=/^\d+\/\d+$/,AR=new Set(["px","full","screen"]),OR=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,MR=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,LR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,PR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,IR=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Jr=e=>el(e)||AR.has(e)||RR.test(e),Lo=e=>El(e,"length",qR),el=e=>!!e&&!Number.isNaN(Number(e)),tg=e=>El(e,"number",el),vc=e=>!!e&&Number.isInteger(Number(e)),zR=e=>e.endsWith("%")&&el(e.slice(0,-1)),xt=e=>w1.test(e),Po=e=>OR.test(e),DR=new Set(["length","size","percentage"]),FR=e=>El(e,DR,j1),UR=e=>El(e,"position",j1),WR=new Set(["image","url"]),HR=e=>El(e,WR,KR),BR=e=>El(e,"",GR),bc=()=>!0,El=(e,n,s)=>{const r=w1.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},qR=e=>MR.test(e)&&!LR.test(e),j1=()=>!1,GR=e=>PR.test(e),KR=e=>IR.test(e),Oj=()=>{const e=Qt("colors"),n=Qt("spacing"),s=Qt("blur"),r=Qt("brightness"),o=Qt("borderColor"),i=Qt("borderRadius"),c=Qt("borderSpacing"),d=Qt("borderWidth"),u=Qt("contrast"),f=Qt("grayscale"),g=Qt("hueRotate"),y=Qt("invert"),v=Qt("gap"),h=Qt("gradientColorStops"),x=Qt("gradientColorStopPositions"),b=Qt("inset"),j=Qt("margin"),k=Qt("opacity"),E=Qt("padding"),N=Qt("saturate"),S=Qt("scale"),$=Qt("sepia"),_=Qt("skew"),O=Qt("space"),M=Qt("translate"),P=()=>["auto","contain","none"],A=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",xt,n],L=()=>[xt,n],W=()=>["",Jr,Lo],U=()=>["auto",el,xt],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],D=()=>["solid","dashed","dotted","double","none"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>["start","end","center","between","around","evenly","stretch"],q=()=>["","0",xt],H=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>[el,xt];return{cacheSize:500,separator:":",theme:{colors:[bc],spacing:[Jr,Lo],blur:["none","",Po,xt],brightness:I(),borderColor:[e],borderRadius:["none","","full",Po,xt],borderSpacing:L(),borderWidth:W(),contrast:I(),grayscale:q(),hueRotate:I(),invert:q(),gap:L(),gradientColorStops:[e],gradientColorStopPositions:[zR,Lo],inset:R(),margin:R(),opacity:I(),padding:L(),saturate:I(),scale:I(),sepia:q(),skew:I(),space:L(),translate:L()},classGroups:{aspect:[{aspect:["auto","square","video",xt]}],container:["container"],columns:[{columns:[Po]}],"break-after":[{"break-after":H()}],"break-before":[{"break-before":H()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Y(),xt]}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[b]}],"inset-x":[{"inset-x":[b]}],"inset-y":[{"inset-y":[b]}],start:[{start:[b]}],end:[{end:[b]}],top:[{top:[b]}],right:[{right:[b]}],bottom:[{bottom:[b]}],left:[{left:[b]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",vc,xt]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",xt]}],grow:[{grow:q()}],shrink:[{shrink:q()}],order:[{order:["first","last","none",vc,xt]}],"grid-cols":[{"grid-cols":[bc]}],"col-start-end":[{col:["auto",{span:["full",vc,xt]},xt]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[bc]}],"row-start-end":[{row:["auto",{span:[vc,xt]},xt]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",xt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",xt]}],gap:[{gap:[v]}],"gap-x":[{"gap-x":[v]}],"gap-y":[{"gap-y":[v]}],"justify-content":[{justify:["normal",...F()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...F(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...F(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[E]}],px:[{px:[E]}],py:[{py:[E]}],ps:[{ps:[E]}],pe:[{pe:[E]}],pt:[{pt:[E]}],pr:[{pr:[E]}],pb:[{pb:[E]}],pl:[{pl:[E]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[O]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[O]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",xt,n]}],"min-w":[{"min-w":[xt,n,"min","max","fit"]}],"max-w":[{"max-w":[xt,n,"none","full","min","max","fit","prose",{screen:[Po]},Po]}],h:[{h:[xt,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[xt,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[xt,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[xt,n,"auto","min","max","fit"]}],"font-size":[{text:["base",Po,Lo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",tg]}],"font-family":[{font:[bc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",xt]}],"line-clamp":[{"line-clamp":["none",el,tg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Jr,xt]}],"list-image":[{"list-image":["none",xt]}],"list-style-type":[{list:["none","disc","decimal",xt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...D(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Jr,Lo]}],"underline-offset":[{"underline-offset":["auto",Jr,xt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",xt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Y(),UR]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",FR]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},HR]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...D(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:D()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...D()]}],"outline-offset":[{"outline-offset":[Jr,xt]}],"outline-w":[{outline:[Jr,Lo]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Jr,Lo]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Po,BR]}],"shadow-color":[{shadow:[bc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...G(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":G()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Po,xt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[y]}],saturate:[{saturate:[N]}],sepia:[{sepia:[$]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[g]}],"backdrop-invert":[{"backdrop-invert":[y]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[$]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",xt]}],duration:[{duration:I()}],ease:[{ease:["linear","in","out","in-out",xt]}],delay:[{delay:I()}],animate:[{animate:["none","spin","ping","pulse","bounce",xt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[vc,xt]}],"translate-x":[{"translate-x":[M]}],"translate-y":[{"translate-y":[M]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",xt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",xt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",xt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Jr,Lo,tg]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},VR=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:o,extend:i={},override:c={}})=>{Lc(e,"cacheSize",n),Lc(e,"prefix",s),Lc(e,"separator",r),Lc(e,"experimentalParseClassName",o);for(const d in c)YR(e[d],c[d]);for(const d in i)QR(e[d],i[d]);return e},Lc=(e,n,s)=>{s!==void 0&&(e[n]=s)},YR=(e,n)=>{if(n)for(const s in n)Lc(e,s,n[s])},QR=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},JR=(e,...n)=>typeof e=="function"?Aj(Oj,e,...n):Aj(()=>VR(Oj(),e),...n),XR=JR({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{spacing:["sidebar","control-sm","control-md","control-lg"],borderRadius:["composer","action"]},classGroups:{"max-w":[{"max-w":["page","page-wide"]}],"font-size":[{text:["micro","label","small","body","lead","prose","figure","display"]}],z:[{z:["raised","sticky","overlay","dialog","popover","toast"]}],shadow:[{shadow:["float"]}],duration:[{duration:["fast","base","slow"]}],ease:[{ease:["standard"]}],"outline-w":[{outline:["focus"]}],"outline-offset":[{"outline-offset":["focus"]}]}}}),te=(...e)=>XR(x1(e)),ZR={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:qg},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:qg},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:t1},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Ys},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:ul}};function jt({tone:e="neutral",title:n,actions:s,bar:r,icon:o,role:i,className:c,children:d,...u}){const f=ZR[e],g=o===!1?null:o??f.Icon;return t.jsxs("div",{role:i??(e==="error"?"alert":"status"),...u,className:te("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":te("border p-4",f.box),c),children:[g&&t.jsx(g,{className:te("size-4 shrink-0",!r&&"mt-0.5",f.text),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[n&&t.jsx("p",{className:te("font-semibold",!r&&"caps text-small",!r&&f.text),children:n}),d&&t.jsx("div",{className:te(n&&!r&&"mt-2"),children:d})]}),s&&t.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const Mj=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Lj=x1,eA=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return Lj(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:o,defaultVariants:i}=n,c=Object.keys(o).map(f=>{const g=s==null?void 0:s[f],y=i==null?void 0:i[f];if(g===null)return null;const v=Mj(g)||Mj(y);return o[f][v]}),d=s&&Object.entries(s).reduce((f,g)=>{let[y,v]=g;return v===void 0||(f[y]=v),f},{}),u=n==null||(r=n.compoundVariants)===null||r===void 0?void 0:r.reduce((f,g)=>{let{class:y,className:v,...h}=g;return Object.entries(h).every(x=>{let[b,j]=x;return Array.isArray(j)?j.includes({...i,...d}[b]):{...i,...d}[b]===j})?[...f,y,v]:f},[]);return Lj(e,c,u,s==null?void 0:s.class,s==null?void 0:s.className)},hl=eA("caps inline-flex items-center justify-center gap-2 whitespace-nowrap !rounded-action border text-small transition-colors disabled:cursor-not-allowed disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",{variants:{variant:{outline:"border-border bg-background hover:border-border-strong hover:bg-accent",primary:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",solid:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",destructive:"border-destructive/60 text-destructive-text hover:bg-destructive/10",ghost:"border-transparent hover:bg-accent"},size:{xs:"h-7 gap-1.5 px-2 text-label",sm:"h-control-sm px-3",md:"h-control-md px-4",lg:"h-control-lg px-5",icon:"size-control-sm"}},defaultVariants:{variant:"outline",size:"md"}}),B=p.forwardRef(({className:e,variant:n,size:s,...r},o)=>t.jsx("button",{ref:o,className:te(hl({variant:n,size:s}),e),...r}));B.displayName="Button";const Pj={plain:"border-border text-muted-foreground",active:"border-run-active/50 text-run-active",success:"border-success/50 bg-success/10 text-success-text",warning:"border-warning/50 bg-warning/10 text-warning-text",error:"border-destructive/50 bg-destructive/10 text-destructive-text",info:"border-info/50 bg-info/10 text-info-text",muted:"border-border-strong/60 text-muted-foreground"};function Ne({tone:e="plain",className:n,title:s,label:r,children:o}){return r?t.jsx("span",{title:s,className:te("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",Pj[e],n),children:t.jsx("span",{className:"min-w-0 truncate",children:o})}):t.jsx("span",{title:s,className:te("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",Pj[e],n),children:o})}const Qs=e=>tA(e)?e.document:nA(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),Am=e=>{let n=Qs(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function k1(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function tA(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function nA(e){return k1(e)&&e.nodeType===9}function sA(e){return k1(e)&&e.nodeType===11&&"host"in e}let rA=!1;function av(){return rA}function Wa(e,n){var r;if(!av())return n&&e?e.contains(n):!1;if(!e||!n)return!1;let s=n;for(;s!=null;){if(s===e)return!0;typeof s.assignedElements!="function"&&((r=s.assignedSlot)!=null&&r.parentNode)?s=s.assignedSlot.parentNode:sA(s)?s=s.host:s=s.parentNode}return!1}const Yo=(e=document)=>{var s;if(!av())return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&((s=n.shadowRoot)!=null&&s.activeElement);)n=n.shadowRoot.activeElement;return n};function ns(e){if(av()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function oA(e){e.focus({preventScroll:!0})}const aA=typeof document<"u"?Be.useLayoutEffect:()=>{};function N1(e){let n=e;return n.nativeEvent=e,n.isDefaultPrevented=()=>n.defaultPrevented,n.isPropagationStopped=()=>n.cancelBubble,n.persist=()=>{},n}function iA(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function S1(e){let n=p.useRef({isFocused:!1,observer:null});return aA(()=>{const s=n.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),p.useCallback(s=>{let r=ns(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){n.current.isFocused=!0;let o=r,i=c=>{if(n.current.isFocused=!1,o.disabled){let d=N1(c);e==null||e(d)}n.current.observer&&(n.current.observer.disconnect(),n.current.observer=null)};o.addEventListener("focusout",i,{once:!0}),n.current.observer=new MutationObserver(()=>{var c;if(n.current.isFocused&&o.disabled){(c=n.current.observer)==null||c.disconnect();let d=o===Yo()?null:Yo();o.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),o.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),n.current.observer.observe(o,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function iv(e){var s;if(typeof window>"u"||window.navigator==null)return!1;let n=(s=window.navigator.userAgentData)==null?void 0:s.brands;return Array.isArray(n)&&n.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function lv(e){var n;return typeof window<"u"&&window.navigator!=null?e.test(((n=window.navigator.userAgentData)==null?void 0:n.platform)||window.navigator.platform):!1}function ci(e){let n=null;return()=>(n==null&&(n=e()),n)}const cv=ci(function(){return lv(/^Mac/i)}),lA=ci(function(){return lv(/^iPhone/i)}),C1=ci(function(){return lv(/^iPad/i)||cv()&&navigator.maxTouchPoints>1}),cA=ci(function(){return lA()||C1()}),dA=ci(function(){return iv(/AppleWebKit/i)&&(cA()||!uA())}),uA=ci(function(){return iv(/Chrome|CriOS|CrMo/i)}),fA=ci(function(){return iv(/Android/i)});function mA(e){return e.pointerType===""&&e.isTrusted?!0:fA()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Zc(e,n,s=!0){let{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}=n,d=dA()&&cv()&&!C1()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}):new MouseEvent("click",{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});Zc.isOpening=s,oA(e),e.dispatchEvent(d),Zc.isOpening=!1}Zc.isOpening=!1;let $l=null;const Vg=new Set;let Uc=new Map,Va=!1,Af=!1;const hA={Tab:!0,Escape:!0};function Om(e,n){for(let s of Vg)s(e,n)}function pA(e){return!(e.metaKey||!cv()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Bf(e){Va=!0,!Zc.isOpening&&pA(e)&&($l="keyboard",Om("keyboard",e))}function tl(e){$l="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(Va=!0,Om("pointer",e))}function E1(e){!Zc.isOpening&&mA(e)&&(Va=!0,$l="virtual")}function $1(e){let n=ns(e),s=Am(n),r=Qs(n);if(n===s){Af=!0;return}n===r||!e.isTrusted||(!Va&&!Af&&($l="virtual",Om("virtual",e)),Va=!1,Af=!1)}function _1(){Va=!1,Af=!0}function T1(e){let n=Yo(Qs(ns(e)));queueMicrotask(()=>{Yo(Qs(ns(e)))!==n&&xA("keyboard")})}function Yg(e){if(typeof window>"u"||typeof document>"u")return;const n=Am(e),s=Qs(e);if(Uc.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){Va=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",Bf,!0),s.addEventListener("keyup",Bf,!0),s.addEventListener("click",E1,!0),s.addEventListener("invalid",T1,!0),n.addEventListener("focus",$1,!0),n.addEventListener("blur",_1,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",tl,!0),s.addEventListener("pointermove",tl,!0),s.addEventListener("pointerup",tl,!0)),n.addEventListener("beforeunload",()=>{R1(e)},{once:!0}),Uc.set(n,{focus:r})}const R1=(e,n)=>{const s=Am(e),r=Qs(e);n&&r.removeEventListener("DOMContentLoaded",n),Uc.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:Uc.get(s).focus}),r.removeEventListener("keydown",Bf,!0),r.removeEventListener("keyup",Bf,!0),r.removeEventListener("click",E1,!0),r.removeEventListener("invalid",T1,!0),s.removeEventListener("focus",$1,!0),s.removeEventListener("blur",_1,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",tl,!0),r.removeEventListener("pointermove",tl,!0),r.removeEventListener("pointerup",tl,!0)),Uc.delete(s))};function gA(e){const n=Qs(e);let s;return n.readyState!=="loading"?Yg(e):(s=()=>{Yg(e)},n.addEventListener("DOMContentLoaded",s)),()=>R1(e,s)}typeof document<"u"&&gA();function Qg(){return $l!=="pointer"}function xA(e){$l=e,Om(e,null)}const vA=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function bA(e,n,s){let r=s?ns(s):void 0,o=Qs(r),i=Am(r);const c=typeof i<"u"?i.HTMLInputElement:HTMLInputElement,d=typeof i<"u"?i.HTMLTextAreaElement:HTMLTextAreaElement,u=typeof i<"u"?i.HTMLElement:HTMLElement,f=typeof i<"u"?i.KeyboardEvent:KeyboardEvent;let g=Yo(o);return e=e||g instanceof c&&!vA.has(g.type)||g instanceof d||g instanceof u&&g.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!hA[s.key])}function yA(e,n,s){Yg(),p.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(o,i)=>{bA(!!(s!=null&&s.isTextInput),o,i)&&e(Qg())};return Vg.add(r),()=>{Vg.delete(r)}},n)}function wA(e){let{isDisabled:n,onFocus:s,onBlur:r,onFocusChange:o}=e;const i=p.useCallback(u=>{if(ns(u)===u.currentTarget)return r&&r(u),o&&o(!1),!0},[r,o]),c=S1(i),d=p.useCallback(u=>{let f=ns(u);const g=Qs(f),y=g?Yo(g):Yo();f===u.currentTarget&&f===y&&(s&&s(u),o&&o(!0),c(u))},[o,s,c]);return{focusProps:{onFocus:!n&&(s||o||r)?d:void 0,onBlur:!n&&(r||o)?i:void 0}}}function A1(){let e=p.useRef(new Map),n=p.useCallback((o,i,c,d)=>{let u=d!=null&&d.once?(...f)=>{e.current.delete(c),c(...f)}:c;e.current.set(c,{type:i,eventTarget:o,fn:u,options:d}),o.addEventListener(i,u,d)},[]),s=p.useCallback((o,i,c,d)=>{var f;let u=((f=e.current.get(c))==null?void 0:f.fn)||c;o.removeEventListener(i,u,d),e.current.delete(c)},[]),r=p.useCallback(()=>{e.current.forEach((o,i)=>{s(o.eventTarget,o.type,i,o.options)})},[s]);return p.useEffect(()=>r,[r]),{addGlobalListener:n,removeGlobalListener:s,removeAllGlobalListeners:r}}function jA(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:o}=e,i=p.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=A1(),u=p.useCallback(y=>{Wa(y.currentTarget,ns(y))&&i.current.isFocusWithin&&!Wa(y.currentTarget,y.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(y),o&&o(!1))},[s,o,i,d]),f=S1(u),g=p.useCallback(y=>{if(!Wa(y.currentTarget,ns(y)))return;let v=ns(y);const h=Qs(v),x=Yo(h);if(!i.current.isFocusWithin&&x===v){r&&r(y),o&&o(!0),i.current.isFocusWithin=!0,f(y);let b=y.currentTarget;c(h,"focus",j=>{let k=ns(j);if(i.current.isFocusWithin&&!Wa(b,k)){let E=new h.defaultView.FocusEvent("blur",{relatedTarget:k});iA(E,b);let N=N1(E);u(N)}},{capture:!0})}},[r,o,f,c,u]);return n?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:g,onBlur:u}}}function kA(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,o=p.useRef({isFocused:!1,isFocusVisible:n||Qg()}),[i,c]=p.useState(!1),[d,u]=p.useState(()=>o.current.isFocused&&o.current.isFocusVisible),f=p.useCallback(()=>u(o.current.isFocused&&o.current.isFocusVisible),[]),g=p.useCallback(h=>{o.current.isFocused=h,o.current.isFocusVisible=Qg(),c(h),f()},[f]);yA(h=>{o.current.isFocusVisible=h,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:y}=wA({isDisabled:r,onFocusChange:g}),{focusWithinProps:v}=jA({isDisabled:!r,onFocusWithinChange:g});return{isFocused:i,isFocusVisible:d,focusProps:r?v:y}}var _s=QN();let Jg=!1,sf=0;function NA(){Jg=!0,setTimeout(()=>{Jg=!1},500)}function Ij(e){e.pointerType==="touch"&&NA()}function SA(){let e=Qs(null);if(!(typeof e>"u"))return sf===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",Ij),sf++,()=>{sf--,!(sf>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",Ij)}}function CA(e){let{onHoverStart:n,onHoverChange:s,onHoverEnd:r,isDisabled:o}=e,[i,c]=p.useState(!1),d=p.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;p.useEffect(SA,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=A1(),{hoverProps:g,triggerHoverEnd:y}=p.useMemo(()=>{let v=(b,j)=>{if(d.pointerType=j,o||j==="touch"||d.isHovered||!Wa(b.currentTarget,ns(b)))return;d.isHovered=!0;let k=b.currentTarget;d.target=k,u(Qs(ns(b)),"pointerover",E=>{d.isHovered&&d.target&&!Wa(d.target,ns(E))&&h(E,E.pointerType)},{capture:!0}),n&&n({type:"hoverstart",target:k,pointerType:j}),s&&s(!0),c(!0)},h=(b,j)=>{let k=d.target;d.pointerType="",d.target=null,!(j==="touch"||!d.isHovered||!k)&&(d.isHovered=!1,f(),r&&r({type:"hoverend",target:k,pointerType:j}),s&&s(!1),c(!1))},x={};return typeof PointerEvent<"u"&&(x.onPointerEnter=b=>{Jg&&b.pointerType==="mouse"||v(b,b.pointerType)},x.onPointerLeave=b=>{!o&&Wa(b.currentTarget,ns(b))&&h(b,b.pointerType)}),{hoverProps:x,triggerHoverEnd:h}},[n,s,r,o,d,u,f]);return p.useEffect(()=>{o&&y({currentTarget:d.target},d.pointerType)},[o]),{hoverProps:g,isHovered:i}}var EA=Object.defineProperty,$A=(e,n,s)=>n in e?EA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,ng=(e,n,s)=>($A(e,typeof n!="symbol"?n+"":n,s),s);let _A=class{constructor(){ng(this,"current",this.detect()),ng(this,"handoffState","pending"),ng(this,"currentId",0)}set(n){this.current!==n&&(this.handoffState="pending",this.currentId=0,this.current=n)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},Lr=new _A;function _l(e){var n;return Lr.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function qf(e){var n,s;return Lr.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function O1(e){var n,s;return(s=(n=qf(e))==null?void 0:n.activeElement)!=null?s:null}function M1(e){return O1(e)===e}function Mm(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(n=>setTimeout(()=>{throw n}))}function Os(){let e=[],n={addEventListener(s,r,o,i){return s.addEventListener(r,o,i),n.add(()=>s.removeEventListener(r,o,i))},requestAnimationFrame(...s){let r=requestAnimationFrame(...s);return n.add(()=>cancelAnimationFrame(r))},nextFrame(...s){return n.requestAnimationFrame(()=>n.requestAnimationFrame(...s))},setTimeout(...s){let r=setTimeout(...s);return n.add(()=>clearTimeout(r))},microTask(...s){let r={current:!0};return Mm(()=>{r.current&&s[0]()}),n.add(()=>{r.current=!1})},style(s,r,o){let i=s.style.getPropertyValue(r);return Object.assign(s.style,{[r]:o}),this.add(()=>{Object.assign(s.style,{[r]:i})})},group(s){let r=Os();return s(r),this.add(()=>r.dispose())},add(s){return e.includes(s)||e.push(s),()=>{let r=e.indexOf(s);if(r>=0)for(let o of e.splice(r,1))o()}},dispose(){for(let s of e.splice(0))s()}};return n}function aa(){let[e]=p.useState(Os);return p.useEffect(()=>()=>e.dispose(),[e]),e}let rn=(e,n)=>{Lr.isServer?p.useEffect(e,n):p.useLayoutEffect(e,n)};function ia(e){let n=p.useRef(e);return rn(()=>{n.current=e},[e]),n}let ut=function(e){let n=ia(e);return Be.useCallback((...s)=>n.current(...s),[n])};function TA(e){let n=e.width/2,s=e.height/2;return{top:e.clientY-s,right:e.clientX+n,bottom:e.clientY+s,left:e.clientX-n}}function RA(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function AA({disabled:e=!1}={}){let n=p.useRef(null),[s,r]=p.useState(!1),o=aa(),i=ut(()=>{n.current=null,r(!1),o.dispose()}),c=ut(d=>{if(o.dispose(),n.current===null){n.current=d.currentTarget,r(!0);{let u=_l(d.currentTarget);o.addEventListener(u,"pointerup",i,!1),o.addEventListener(u,"pointermove",f=>{if(n.current){let g=TA(f);r(RA(g,n.current.getBoundingClientRect()))}},!1),o.addEventListener(u,"pointercancel",i,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:c,onPointerUp:i,onClick:i}}}function Js(e){return p.useMemo(()=>e,Object.values(e))}let OA=p.createContext(void 0);function dv(){return p.useContext(OA)}function Xg(...e){return Array.from(new Set(e.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}function as(e,n,...s){if(e in n){let o=n[e];return typeof o=="function"?o(...s):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(n).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,as),r}var pl=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(pl||{}),Wo=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Wo||{});function Mn(){let e=LA();return p.useCallback(n=>MA({mergeRefs:e,...n}),[e])}function MA({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:o,visible:i=!0,name:c,mergeRefs:d}){d=d??PA;let u=L1(n,e);if(i)return rf(u,s,r,c,d);let f=o??0;if(f&2){let{static:g=!1,...y}=u;if(g)return rf(y,s,r,c,d)}if(f&1){let{unmount:g=!0,...y}=u;return as(g?0:1,{0(){return null},1(){return rf({...y,hidden:!0,style:{display:"none"}},s,r,c,d)}})}return rf(u,s,r,c,d)}function rf(e,n={},s,r,o){let{as:i=s,children:c,refName:d="ref",...u}=sg(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},g=typeof c=="function"?c(n):c;g=I1(g),"className"in u&&u.className&&typeof u.className=="function"&&(u.className=u.className(n)),u["aria-labelledby"]&&u["aria-labelledby"]===u.id&&(u["aria-labelledby"]=void 0);let y={};if(n){let v=!1,h=[];for(let[x,b]of Object.entries(n))typeof b=="boolean"&&(v=!0),b===!0&&h.push(x.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(v){y["data-headlessui-state"]=h.join(" ");for(let x of h)y[`data-${x}`]=""}}if(Wc(i)&&(Object.keys(Fo(u)).length>0||Object.keys(Fo(y)).length>0))if(!p.isValidElement(g)||Array.isArray(g)&&g.length>1||zA(g)){if(Object.keys(Fo(u)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Fo(u)).concat(Object.keys(Fo(y))).map(v=>` - ${v}`).join(`
516
+ `),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(v=>` - ${v}`).join(`
517
+ `)].join(`
518
+ `))}else{let v=g.props,h=v==null?void 0:v.className,x=typeof h=="function"?(...k)=>Xg(h(...k),u.className):Xg(h,u.className),b=x?{className:x}:{},j=L1(g.props,Fo(sg(u,["ref"])));for(let k in y)k in j&&delete y[k];return p.cloneElement(g,Object.assign({},j,y,f,{ref:o(IA(g),f.ref)},b))}return p.createElement(i,Object.assign({},sg(u,["ref"]),!Wc(i)&&f,!Wc(i)&&y),g)}function LA(){let e=p.useRef([]),n=p.useCallback(s=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(s):r.current=s)},[]);return(...s)=>{if(!s.every(r=>r==null))return e.current=s,n}}function PA(...e){return e.every(n=>n==null)?void 0:n=>{for(let s of e)s!=null&&(typeof s=="function"?s(n):s.current=n)}}function L1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(s[o]!=null||(s[o]=[]),s[o].push(r[o])):n[o]=r[o];if(n.disabled||n["aria-disabled"])for(let r in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(s[r]=[o=>{var i;return(i=o==null?void 0:o.preventDefault)==null?void 0:i.call(o)}]);for(let r in s)Object.assign(n,{[r](o,...i){let c=s[r];for(let d of c){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;d(o,...i)}}});return n}function P1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(s[o]!=null||(s[o]=[]),s[o].push(r[o])):n[o]=r[o];for(let r in s)Object.assign(n,{[r](...o){let i=s[r];for(let c of i)c==null||c(...o)}});return n}function wn(e){var n;return Object.assign(p.forwardRef(e),{displayName:(n=e.displayName)!=null?n:e.name})}function Fo(e){let n=Object.assign({},e);for(let s in n)n[s]===void 0&&delete n[s];return n}function sg(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function IA(e){return Be.version.split(".")[0]>="19"?e.props.ref:e.ref}function I1(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return I1(n.value)}return e}function Wc(e){return e===p.Fragment||e===Symbol.for("react.fragment")}function zA(e){return Wc(e.type)}function DA(e,n,s){let[r,o]=p.useState(s),i=e!==void 0,c=p.useRef(i),d=p.useRef(!1),u=p.useRef(!1);return i&&!c.current&&!d.current?(d.current=!0,c.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&c.current&&!u.current&&(u.current=!0,c.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?e:r,ut(f=>(i||_s.flushSync(()=>o(f)),n==null?void 0:n(f)))]}function FA(e){let[n]=p.useState(e);return n}function z1(e={},n=null,s=[]){for(let[r,o]of Object.entries(e))F1(s,D1(n,r),o);return s}function D1(e,n){return e?e+"["+n+"]":n}function F1(e,n,s){if(Array.isArray(s))for(let[r,o]of s.entries())F1(e,D1(n,r.toString()),o);else s instanceof Date?e.push([n,s.toISOString()]):typeof s=="boolean"?e.push([n,s?"1":"0"]):typeof s=="string"?e.push([n,s]):typeof s=="number"?e.push([n,`${s}`]):s==null?e.push([n,""]):WA(s)&&!p.isValidElement(s)&&z1(s,n,e)}function UA(e){var n,s;let r=(n=e==null?void 0:e.form)!=null?n:e.closest("form");if(r){for(let o of r.elements)if(o!==e&&(o.tagName==="INPUT"&&o.type==="submit"||o.tagName==="BUTTON"&&o.type==="submit"||o.nodeName==="INPUT"&&o.type==="image")){o.click();return}(s=r.requestSubmit)==null||s.call(r)}}function WA(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let HA="span";var gl=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(gl||{});function BA(e,n){var s;let{features:r=1,...o}=e,i={ref:n,"aria-hidden":(r&2)===2?!0:(s=o["aria-hidden"])!=null?s:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return Mn()({ourProps:i,theirProps:o,slot:{},defaultTag:HA,name:"Hidden"})}let ed=wn(BA),qA=p.createContext(null);function GA({children:e}){let n=p.useContext(qA);if(!n)return Be.createElement(Be.Fragment,null,e);let{target:s}=n;return s?_s.createPortal(Be.createElement(Be.Fragment,null,e),s):null}function KA({data:e,form:n,disabled:s,onReset:r,overrides:o}){let[i,c]=p.useState(null),d=aa();return p.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),Be.createElement(GA,null,Be.createElement(VA,{setForm:c,formId:n}),z1(e).map(([u,f])=>Be.createElement(ed,{features:gl.Hidden,...Fo({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...o})})))}function VA({setForm:e,formId:n}){return p.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:Be.createElement(ed,{features:gl.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let YA=p.createContext(void 0);function U1(){return p.useContext(YA)}function W1(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function so(e){return W1(e)&&"tagName"in e}function Ts(e){return so(e)&&"accessKey"in e}function eo(e){return so(e)&&"tabIndex"in e}function QA(e){return so(e)&&"style"in e}function JA(e){return Ts(e)&&e.nodeName==="IFRAME"}function H1(e){return Ts(e)&&e.nodeName==="INPUT"}function zj(e){return Ts(e)&&e.nodeName==="LABEL"}function XA(e){return Ts(e)&&e.nodeName==="FIELDSET"}function B1(e){return Ts(e)&&e.nodeName==="LEGEND"}function ZA(e){return so(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function Dj(e){let n=e.parentElement,s=null;for(;n&&!XA(n);)B1(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&e3(s)?!1:r}function e3(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if(B1(n))return!1;n=n.previousElementSibling}return!0}let q1=Symbol();function t3(e,n=!0){return Object.assign(e,{[q1]:n})}function Yn(...e){let n=p.useRef(e);p.useEffect(()=>{n.current=e},[e]);let s=ut(r=>{for(let o of n.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[q1]))?void 0:s}let Lm=p.createContext(null);Lm.displayName="DescriptionContext";function G1(){let e=p.useContext(Lm);if(e===null){let n=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,G1),n}return e}function n3(){var e,n;return(n=(e=p.useContext(Lm))==null?void 0:e.value)!=null?n:void 0}function s3(){let[e,n]=p.useState([]);return[e.length>0?e.join(" "):void 0,p.useMemo(()=>function(s){let r=ut(i=>(n(c=>[...c,i]),()=>n(c=>{let d=c.slice(),u=d.indexOf(i);return u!==-1&&d.splice(u,1),d}))),o=p.useMemo(()=>({register:r,slot:s.slot,name:s.name,props:s.props,value:s.value}),[r,s.slot,s.name,s.props,s.value]);return Be.createElement(Lm.Provider,{value:o},s.children)},[n])]}let r3="p";function o3(e,n){let s=p.useId(),r=dv(),{id:o=`headlessui-description-${s}`,...i}=e,c=G1(),d=Yn(n);rn(()=>c.register(o),[o,c.register]);let u=Js({...c.slot,disabled:r||!1}),f={ref:d,...c.props,id:o};return Mn()({ourProps:f,theirProps:i,slot:u,defaultTag:r3,name:c.name||"Description"})}let a3=wn(o3),K1=Object.assign(a3,{});var Sn=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(Sn||{});let Pm=p.createContext(null);Pm.displayName="LabelContext";function V1(){let e=p.useContext(Pm);if(e===null){let n=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,V1),n}return e}function Y1(e){var n,s,r;let o=(s=(n=p.useContext(Pm))==null?void 0:n.value)!=null?s:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[o,...e].filter(Boolean).join(" "):o}function i3({inherit:e=!1}={}){let n=Y1(),[s,r]=p.useState([]),o=e?[n,...s].filter(Boolean):s;return[o.length>0?o.join(" "):void 0,p.useMemo(()=>function(i){let c=ut(u=>(r(f=>[...f,u]),()=>r(f=>{let g=f.slice(),y=g.indexOf(u);return y!==-1&&g.splice(y,1),g}))),d=p.useMemo(()=>({register:c,slot:i.slot,name:i.name,props:i.props,value:i.value}),[c,i.slot,i.name,i.props,i.value]);return Be.createElement(Pm.Provider,{value:d},i.children)},[r])]}let l3="label";function c3(e,n){var s;let r=p.useId(),o=V1(),i=U1(),c=dv(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=o.props)==null?void 0:s.htmlFor),passive:f=!1,...g}=e,y=Yn(n);rn(()=>o.register(d),[d,o.register]);let v=ut(b=>{let j=b.currentTarget;if(!(b.target!==b.currentTarget&&ZA(b.target))&&(zj(j)&&b.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(b),zj(j))){let k=document.getElementById(j.htmlFor);if(k){let E=k.getAttribute("disabled");if(E==="true"||E==="")return;let N=k.getAttribute("aria-disabled");if(N==="true"||N==="")return;(H1(k)&&(k.type==="file"||k.type==="radio"||k.type==="checkbox")||k.role==="radio"||k.role==="checkbox"||k.role==="switch")&&k.click(),k.focus({preventScroll:!0})}}}),h=Js({...o.slot,disabled:c||!1}),x={ref:y,...o.props,id:d,htmlFor:u,onClick:v};return f&&("onClick"in x&&(delete x.htmlFor,delete x.onClick),"onClick"in g&&delete g.onClick),Mn()({ourProps:x,theirProps:g,slot:h,defaultTag:u?l3:"div",name:o.name||"Label"})}let d3=wn(c3),u3=Object.assign(d3,{}),f3=p.createContext(()=>{});function m3({value:e,children:n}){return Be.createElement(f3.Provider,{value:e},n)}function h3(e,n){return e!==null&&n!==null&&typeof e=="object"&&typeof n=="object"&&"id"in e&&"id"in n?e.id===n.id:e===n}function p3(e=h3){return p.useCallback((n,s)=>{if(typeof e=="string"){let r=e;return(n==null?void 0:n[r])===(s==null?void 0:s[r])}return e(n,s)},[e])}function Fj(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function g3(e,n,s=!1){let[r,o]=p.useState(()=>Fj(n));return rn(()=>{if(!n||!e)return;let i=Os();return i.requestAnimationFrame(function c(){i.requestAnimationFrame(c),o(d=>{let u=Fj(n);return u.width===d.width&&u.height===d.height?d:u})}),()=>{i.dispose()}},[n,e]),s?{width:`${r.width}px`,height:`${r.height}px`}:r}var Q1=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(Q1||{});function x3(e){let n=p.useRef(null),s=ut(o=>{n.current=o.pointerType,!Dj(o.currentTarget)&&o.pointerType==="mouse"&&o.button===Q1.Left&&(o.preventDefault(),e(o))}),r=ut(o=>{n.current!=="mouse"&&(Dj(o.currentTarget)||e(o))});return{onPointerDown:s,onClick:r}}let J1=class extends Map{constructor(n){super(),this.factory=n}get(n){let s=super.get(n);return s===void 0&&(s=this.factory(n),this.set(n,s)),s}};var v3=Object.defineProperty,b3=(e,n,s)=>n in e?v3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,y3=(e,n,s)=>(b3(e,n+"",s),s),X1=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},Us=(e,n,s)=>(X1(e,n,"read from private field"),s?s.call(e):n.get(e)),rg=(e,n,s)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,s)},Uj=(e,n,s,r)=>(X1(e,n,"write to private field"),n.set(e,s),s),Rr,Pc,Ic;let Z1=class{constructor(n){rg(this,Rr,{}),rg(this,Pc,new J1(()=>new Set)),rg(this,Ic,new Set),y3(this,"disposables",Os()),Uj(this,Rr,n),Lr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return Us(this,Rr)}subscribe(n,s){if(Lr.isServer)return()=>{};let r={selector:n,callback:s,current:n(Us(this,Rr))};return Us(this,Ic).add(r),this.disposables.add(()=>{Us(this,Ic).delete(r)})}on(n,s){return Lr.isServer?()=>{}:(Us(this,Pc).get(n).add(s),this.disposables.add(()=>{Us(this,Pc).get(n).delete(s)}))}send(n){let s=this.reduce(Us(this,Rr),n);if(s!==Us(this,Rr)){Uj(this,Rr,s);for(let r of Us(this,Ic)){let o=r.selector(Us(this,Rr));eS(r.current,o)||(r.current=o,r.callback(o))}for(let r of Us(this,Pc).get(n.type))r(Us(this,Rr),n)}}};Rr=new WeakMap,Pc=new WeakMap,Ic=new WeakMap;function eS(e,n){return Object.is(e,n)?!0:typeof e!="object"||e===null||typeof n!="object"||n===null?!1:Array.isArray(e)&&Array.isArray(n)?e.length!==n.length?!1:og(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:og(e.entries(),n.entries()):Wj(e)&&Wj(n)?og(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function og(e,n){do{let s=e.next(),r=n.next();if(s.done&&r.done)return!0;if(s.done||r.done||!Object.is(s.value,r.value))return!1}while(!0)}function Wj(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}function ag(e){let[n,s]=e(),r=Os();return(...o)=>{n(...o),r.dispose(),r.microTask(s)}}var w3=Object.defineProperty,j3=(e,n,s)=>n in e?w3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Hj=(e,n,s)=>(j3(e,typeof n!="symbol"?n+"":n,s),s),tS=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(tS||{});let k3={0(e,n){let s=n.id,r=e.stack,o=e.stack.indexOf(s);if(o!==-1){let i=e.stack.slice();return i.splice(o,1),i.push(s),r=i,{...e,stack:r}}return{...e,stack:[...e.stack,s]}},1(e,n){let s=n.id,r=e.stack.indexOf(s);if(r===-1)return e;let o=e.stack.slice();return o.splice(r,1),{...e,stack:o}}},N3=class nS extends Z1{constructor(){super(...arguments),Hj(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),Hj(this,"selectors",{isTop:(n,s)=>n.stack[n.stack.length-1]===s,inStack:(n,s)=>n.stack.includes(s)})}static new(){return new nS({stack:[]})}reduce(n,s){return as(s.type,k3,n,s)}};const Im=new J1(()=>N3.new());var ig={exports:{}},lg={};/**
519
+ * @license React
520
+ * use-sync-external-store-with-selector.production.js
521
+ *
522
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
523
+ *
524
+ * This source code is licensed under the MIT license found in the
525
+ * LICENSE file in the root directory of this source tree.
526
+ */var Bj;function S3(){if(Bj)return lg;Bj=1;var e=Sm();function n(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var s=typeof Object.is=="function"?Object.is:n,r=e.useSyncExternalStore,o=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return lg.useSyncExternalStoreWithSelector=function(u,f,g,y,v){var h=o(null);if(h.current===null){var x={hasValue:!1,value:null};h.current=x}else x=h.current;h=c(function(){function j($){if(!k){if(k=!0,E=$,$=y($),v!==void 0&&x.hasValue){var _=x.value;if(v(_,$))return N=_}return N=$}if(_=N,s(E,$))return _;var O=y($);return v!==void 0&&v(_,O)?(E=$,_):(E=$,N=O)}var k=!1,E,N,S=g===void 0?null:g;return[function(){return j(f())},S===null?void 0:function(){return j(S())}]},[f,g,y,v]);var b=r(u,h[0],h[1]);return i(function(){x.hasValue=!0,x.value=b},[b]),d(b),b},lg}var qj;function C3(){return qj||(qj=1,ig.exports=S3()),ig.exports}var E3=C3();function ts(e,n,s=eS){return E3.useSyncExternalStoreWithSelector(ut(r=>e.subscribe($3,r)),ut(()=>e.state),ut(()=>e.state),ut(n),s)}function $3(e){return e}function wd(e,n){let s=p.useId(),r=Im.get(n),[o,i]=ts(r,p.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return rn(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?o:!0:!1}let Zg=new Map,Hc=new Map;function Gj(e){var n;let s=(n=Hc.get(e))!=null?n:0;return Hc.set(e,s+1),s!==0?()=>Kj(e):(Zg.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Kj(e))}function Kj(e){var n;let s=(n=Hc.get(e))!=null?n:1;if(s===1?Hc.delete(e):Hc.set(e,s-1),s!==1)return;let r=Zg.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Zg.delete(e))}function sS(e,{allowed:n,disallowed:s}={}){let r=wd(e,"inert-others");rn(()=>{var o,i;if(!r)return;let c=Os();for(let u of(o=s==null?void 0:s())!=null?o:[])u&&c.add(Gj(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=_l(u);if(!f)continue;let g=u.parentElement;for(;g&&g!==f.body;){for(let y of g.children)d.some(v=>y.contains(v))||c.add(Gj(y));g=g.parentElement}}return c.dispose},[r,n,s])}function rS(e,n,s){let r=ia(o=>{let i=o.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&s()});p.useEffect(()=>{if(!e)return;let o=n===null?null:Ts(n)?n:n.current;if(!o)return;let i=Os();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>r.current(o));c.observe(o),i.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>r.current(o));c.observe(o),i.add(()=>c.disconnect())}return()=>i.dispose()},[n,r,e])}let Gf=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),_3=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var cr=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(cr||{}),ex=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(ex||{}),T3=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(T3||{});function oS(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Gf)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function R3(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(_3)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var uv=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(uv||{});function aS(e,n=0){var s;return e===((s=_l(e))==null?void 0:s.body)?!1:as(n,{0(){return e.matches(Gf)},1(){let r=e;for(;r!==null;){if(r.matches(Gf))return!0;r=r.parentElement}return!1}})}var A3=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(A3||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function ro(e){e==null||e.focus({preventScroll:!0})}let O3=["textarea","input"].join(",");function M3(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,O3))!=null?s:!1}function iS(e,n=s=>s){return e.slice().sort((s,r)=>{let o=n(s),i=n(r);if(o===null||i===null)return 0;let c=o.compareDocumentPosition(i);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function L3(e,n,s=e===null?document.body:qf(e)){return nl(oS(s),n,{relativeTo:e})}function nl(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?qf(e[0]):document:qf(e),c=Array.isArray(e)?s?iS(e):e:n&64?R3(e):oS(e);o.length>0&&c.length>1&&(c=c.filter(h=>!o.some(x=>x!=null&&"current"in x?(x==null?void 0:x.current)===h:x===h))),r=r??(i==null?void 0:i.activeElement);let d=(()=>{if(n&5)return 1;if(n&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=(()=>{if(n&1)return 0;if(n&2)return Math.max(0,c.indexOf(r))-1;if(n&4)return Math.max(0,c.indexOf(r))+1;if(n&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=n&32?{preventScroll:!0}:{},g=0,y=c.length,v;do{if(g>=y||g+y<=0)return 0;let h=u+g;if(n&16)h=(h+y)%y;else{if(h<0)return 3;if(h>=y)return 1}v=c[h],v==null||v.focus(f),g+=d}while(v!==O1(v));return n&6&&M3(v)&&v.select(),2}function lS(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function P3(){return/Android/gi.test(window.navigator.userAgent)}function Vj(){return lS()||P3()}function Yi(e,n,s,r){let o=ia(s);p.useEffect(()=>{if(!e)return;function i(c){o.current(c)}return document.addEventListener(n,i,r),()=>document.removeEventListener(n,i,r)},[e,n,r])}function cS(e,n,s,r){let o=ia(s);p.useEffect(()=>{if(!e)return;function i(c){o.current(c)}return window.addEventListener(n,i,r),()=>window.removeEventListener(n,i,r)},[e,n,r])}const Yj=30;function dS(e,n,s){let r=ia(s),o=p.useCallback(function(d,u){if(d.defaultPrevented)return;let f=u(d);if(f===null||!f.getRootNode().contains(f)||!f.isConnected)return;let g=(function y(v){return typeof v=="function"?y(v()):Array.isArray(v)||v instanceof Set?v:[v]})(n);for(let y of g)if(y!==null&&(y.contains(f)||d.composed&&d.composedPath().includes(y)))return;return!aS(f,uv.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=p.useRef(null);Yi(e,"pointerdown",d=>{var u,f;Vj()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),Yi(e,"pointerup",d=>{if(Vj()||!i.current)return;let u=i.current;return i.current=null,o(d,()=>u)},!0);let c=p.useRef({x:0,y:0});Yi(e,"touchstart",d=>{c.current.x=d.touches[0].clientX,c.current.y=d.touches[0].clientY},!0),Yi(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-c.current.x)>=Yj||Math.abs(u.y-c.current.y)>=Yj))return o(d,()=>eo(d.target)?d.target:null)},!0),cS(e,"blur",d=>o(d,()=>JA(window.document.activeElement)?window.document.activeElement:null),!0)}function td(...e){return p.useMemo(()=>_l(...e),[...e])}var I3=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(I3||{});const of={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},z3=200,Qj=5;function D3(e,{trigger:n,action:s,close:r,select:o}){let i=p.useRef(null),c=p.useRef(null),d=p.useRef(null);Yi(e&&n!==null,"pointerdown",u=>{W1(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(c.current=u.x,d.current=u.y,i.current=u.timeStamp)}),Yi(e&&n!==null,"pointerup",u=>{var f,g;let y=i.current;if(y===null||(i.current=null,!eo(u.target))||Math.abs(u.x-((f=c.current)!=null?f:u.x))<Qj&&Math.abs(u.y-((g=d.current)!=null?g:u.y))<Qj)return;let v=s(u);switch(v.kind){case 0:return;case 1:{u.timeStamp-y>z3&&(o(v.target),r());break}case 2:{r();break}}},{capture:!0})}function uS(e,n,s,r){let o=ia(s);p.useEffect(()=>{e=e??window;function i(c){o.current(c)}return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)},[e,n,r])}function F3(e,n){return p.useMemo(()=>{var s;if(e.type)return e.type;let r=(s=e.as)!=null?s:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(n==null?void 0:n.tagName)==="BUTTON"&&!n.hasAttribute("type"))return"button"},[e.type,e.as,n])}function U3(e){return p.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function W3(e,n){let s=e(),r=new Set;return{getSnapshot(){return s},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...i){let c=n[o].call(s,...i);c&&(s=c,r.forEach(d=>d()))}}}function H3(){let e;return{before({doc:n}){var s;let r=n.documentElement,o=(s=n.defaultView)!=null?s:window;e=Math.max(0,o.innerWidth-r.clientWidth)},after({doc:n,d:s}){let r=n.documentElement,o=Math.max(0,r.clientWidth-r.offsetWidth),i=Math.max(0,e-o);s.style(r,"paddingRight",`${i}px`)}}}function B3(){return lS()?{before({doc:e,d:n,meta:s}){function r(o){for(let i of s().containers)for(let c of i())if(c.contains(o))return!0;return!1}n.microTask(()=>{var o;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let d=Os();d.style(e.documentElement,"scrollBehavior","auto"),n.add(()=>n.microTask(()=>d.dispose()))}let i=(o=window.scrollY)!=null?o:window.pageYOffset,c=null;n.addEventListener(e,"click",d=>{if(eo(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),g=e.querySelector(f);eo(g)&&!r(g)&&(c=g)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),eo(u.target)&&QA(u.target))if(r(u.target)){let f=u.target;for(;f.parentElement&&r(f.parentElement);)f=f.parentElement;d.style(f,"overscrollBehavior","contain")}else d.style(u.target,"touchAction","none")})}),n.addEventListener(e,"touchmove",d=>{if(eo(d.target)){if(H1(d.target))return;if(r(d.target)){let u=d.target;for(;u.parentElement&&u.dataset.headlessuiPortal!==""&&!(u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth);)u=u.parentElement;u.dataset.headlessuiPortal===""&&d.preventDefault()}else d.preventDefault()}},{passive:!1}),n.add(()=>{var d;let u=(d=window.scrollY)!=null?d:window.pageYOffset;i!==u&&window.scrollTo(0,i),c&&c.isConnected&&(c.scrollIntoView({block:"nearest"}),c=null)})})}}:{}}function q3(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function Jj(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let Ha=W3(()=>new Map,{PUSH(e,n){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:Os(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(n),r.computedMeta=Jj(r.meta),this.set(e,r),this},POP(e,n){let s=this.get(e);return s&&(s.count--,s.meta.delete(n),s.computedMeta=Jj(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[B3(),H3(),q3()];s.forEach(({before:r})=>r==null?void 0:r(n)),s.forEach(({after:r})=>r==null?void 0:r(n))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});Ha.subscribe(()=>{let e=Ha.getSnapshot(),n=new Map;for(let[s]of e)n.set(s,s.documentElement.style.overflow);for(let s of e.values()){let r=n.get(s.doc)==="hidden",o=s.count!==0;(o&&!r||!o&&r)&&Ha.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&Ha.dispatch("TEARDOWN",s)}});function G3(e,n,s=()=>({containers:[]})){let r=U3(Ha),o=n?r.get(n):void 0,i=o?o.count>0:!1;return rn(()=>{if(!(!n||!e))return Ha.dispatch("PUSH",n,s),()=>Ha.dispatch("POP",n,s)},[e,n]),i}function fS(e,n,s=()=>[document.body]){let r=wd(e,"scroll-lock");G3(r,n,o=>{var i;return{containers:[...(i=o.containers)!=null?i:[],s]}})}function Xj(e){return[e.screenX,e.screenY]}function K3(){let e=p.useRef([-1,-1]);return{wasMoved(n){let s=Xj(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=Xj(n)}}}function V3(e=0){let[n,s]=p.useState(e),r=p.useCallback(u=>s(u),[]),o=p.useCallback(u=>s(f=>f|u),[]),i=p.useCallback(u=>(n&u)===u,[n]),c=p.useCallback(u=>s(f=>f&~u),[]),d=p.useCallback(u=>s(f=>f^u),[]);return{flags:n,setFlag:r,addFlag:o,hasFlag:i,removeFlag:c,toggleFlag:d}}var Y3={},Zj,ek;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Zj=process==null?void 0:Y3)==null?void 0:Zj.NODE_ENV)==="test"&&typeof((ek=Element==null?void 0:Element.prototype)==null?void 0:ek.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
527
+ `)),[]});var Q3=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(Q3||{});function mS(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function hS(e,n,s,r){let[o,i]=p.useState(s),{hasFlag:c,addFlag:d,removeFlag:u}=V3(e&&o?3:0),f=p.useRef(!1),g=p.useRef(!1),y=aa();return rn(()=>{var v;if(e){if(s&&i(!0),!n){s&&d(3);return}return(v=r==null?void 0:r.start)==null||v.call(r,s),J3(n,{inFlight:f,prepare(){g.current?g.current=!1:g.current=f.current,f.current=!0,!g.current&&(s?(d(3),u(4)):(d(4),u(2)))},run(){g.current?s?(u(3),d(4)):(u(4),d(3)):s?u(1):d(1)},done(){var h;g.current&&e4(n)||(f.current=!1,u(7),s||i(!1),(h=r==null?void 0:r.end)==null||h.call(r,s))}})}},[e,s,n,y]),e?[o,{closed:c(1),enter:c(2),leave:c(4),transition:c(2)||c(4)}]:[s,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function J3(e,{prepare:n,run:s,done:r,inFlight:o}){let i=Os();return Z3(e,{prepare:n,inFlight:o}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(X3(e,r))})}),i.dispose}function X3(e,n){var s,r;let o=Os();if(!e)return o.dispose;let i=!1;o.add(()=>{i=!0});let c=(r=(s=e.getAnimations)==null?void 0:s.call(e).filter(d=>d instanceof CSSTransition))!=null?r:[];return c.length===0?(n(),o.dispose):(Promise.allSettled(c.map(d=>d.finished)).then(()=>{i||n()}),o.dispose)}function Z3(e,{inFlight:n,prepare:s}){if(n!=null&&n.current){s();return}let r=e.style.transition;e.style.transition="none",s(),e.offsetHeight,e.style.transition=r}function e4(e){var n,s;return((s=(n=e.getAnimations)==null?void 0:n.call(e))!=null?s:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function fv(e,n){let s=p.useRef([]),r=ut(e);p.useEffect(()=>{let o=[...s.current];for(let[i,c]of n.entries())if(s.current[i]!==c){let d=r(n,o);return s.current=n,d}},[r,...n])}function zm(){return typeof window<"u"}function Tl(e){return pS(e)?(e.nodeName||"").toLowerCase():"#document"}function xs(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function fo(e){var n;return(n=(pS(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function pS(e){return zm()?e instanceof Node||e instanceof xs(e).Node:!1}function gs(e){return zm()?e instanceof Element||e instanceof xs(e).Element:!1}function la(e){return zm()?e instanceof HTMLElement||e instanceof xs(e).HTMLElement:!1}function tk(e){return!zm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xs(e).ShadowRoot}function Dm(e){const{overflow:n,overflowX:s,overflowY:r,display:o}=zr(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&o!=="inline"&&o!=="contents"}function t4(e){return/^(table|td|th)$/.test(Tl(e))}function Fm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const n4=/transform|translate|scale|rotate|perspective|filter/,s4=/paint|layout|strict|content/,Ma=e=>!!e&&e!=="none";let cg;function mv(e){const n=gs(e)?zr(e):e;return Ma(n.transform)||Ma(n.translate)||Ma(n.scale)||Ma(n.rotate)||Ma(n.perspective)||!hv()&&(Ma(n.backdropFilter)||Ma(n.filter))||n4.test(n.willChange||"")||s4.test(n.contain||"")}function r4(e){let n=Ya(e);for(;la(n)&&!nd(n);){if(mv(n))return n;if(Fm(n))return null;n=Ya(n)}return null}function hv(){return cg==null&&(cg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cg}function nd(e){return/^(html|body|#document)$/.test(Tl(e))}function zr(e){return xs(e).getComputedStyle(e)}function Um(e){return gs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ya(e){if(Tl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||tk(e)&&e.host||fo(e);return tk(n)?n.host:n}function gS(e){const n=Ya(e);return nd(n)?(e.ownerDocument||e).body:la(n)&&Dm(n)?n:gS(n)}function sd(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=gS(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),c=xs(o);if(i){const d=tx(c);return n.concat(c,c.visualViewport||[],Dm(o)?o:[],d&&s?sd(d):[])}else return n.concat(o,sd(o,[],s))}function tx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function o4(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(n=>{let{brand:s,version:r}=n;return s+"/"+r}).join(" "):navigator.userAgent}const Qa=Math.min,Ks=Math.max,rd=Math.round,af=Math.floor,oo=e=>({x:e,y:e}),a4={left:"right",right:"left",bottom:"top",top:"bottom"};function i4(e,n,s){return Ks(e,Qa(n,s))}function Rl(e,n){return typeof e=="function"?e(n):e}function Ja(e){return e.split("-")[0]}function jd(e){return e.split("-")[1]}function xS(e){return e==="x"?"y":"x"}function vS(e){return e==="y"?"height":"width"}function to(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function bS(e){return xS(to(e))}function l4(e,n,s){s===void 0&&(s=!1);const r=jd(e),o=bS(e),i=vS(o);let c=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=Kf(c)),[c,Kf(c)]}function c4(e){const n=Kf(e);return[nx(e),n,nx(n)]}function nx(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const nk=["left","right"],sk=["right","left"],d4=["top","bottom"],u4=["bottom","top"];function f4(e,n,s){switch(e){case"top":case"bottom":return s?n?sk:nk:n?nk:sk;case"left":case"right":return n?d4:u4;default:return[]}}function m4(e,n,s,r){const o=jd(e);let i=f4(Ja(e),s==="start",r);return o&&(i=i.map(c=>c+"-"+o),n&&(i=i.concat(i.map(nx)))),i}function Kf(e){const n=Ja(e);return a4[n]+e.slice(n.length)}function h4(e){var n,s,r,o;return{top:(n=e.top)!=null?n:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}function p4(e){return typeof e!="number"?h4(e):{top:e,right:e,bottom:e,left:e}}function Vf(e){const{x:n,y:s,width:r,height:o}=e;return{width:r,height:o,top:s,left:n,right:n+r,bottom:s+o,x:n,y:s}}function rk(e,n,s){let{reference:r,floating:o}=e;const i=to(n),c=bS(n),d=vS(c),u=Ja(n),f=i==="y",g=r.x+r.width/2-o.width/2,y=r.y+r.height/2-o.height/2,v=r[d]/2-o[d]/2;let h;switch(u){case"top":h={x:g,y:r.y-o.height};break;case"bottom":h={x:g,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y};break;case"left":h={x:r.x-o.width,y};break;default:h={x:r.x,y:r.y}}const x=jd(n);return x&&(h[c]+=v*(x==="end"?1:-1)*(s&&f?-1:1)),h}async function yS(e,n){var s;n===void 0&&(n={});const{x:r,y:o,platform:i,rects:c,elements:d,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:v=!1,padding:h=0}=Rl(n,e),x=p4(h),j=d[v?y==="floating"?"reference":"floating":y],k=Vf(await i.getClippingRect({element:(s=await(i.isElement==null?void 0:i.isElement(j)))==null||s?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:g,strategy:u})),E=y==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),S=await(i.isElement==null?void 0:i.isElement(N))&&await(i.getScale==null?void 0:i.getScale(N))||{x:1,y:1},$=Vf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:E,offsetParent:N,strategy:u}):E);return{top:(k.top-$.top+x.top)/S.y,bottom:($.bottom-k.bottom+x.bottom)/S.y,left:(k.left-$.left+x.left)/S.x,right:($.right-k.right+x.right)/S.x}}const g4=50,x4=async(e,n,s)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:c}=s,d=c.detectOverflow?c:{...c,detectOverflow:yS},u=await(c.isRTL==null?void 0:c.isRTL(n));let f=await c.getElementRects({reference:e,floating:n,strategy:o}),{x:g,y}=rk(f,r,u),v=r,h=0;const x={};for(let b=0;b<i.length;b++){const j=i[b];if(!j)continue;const{name:k,fn:E}=j,{x:N,y:S,data:$,reset:_}=await E({x:g,y,initialPlacement:r,placement:v,strategy:o,middlewareData:x,rects:f,platform:d,elements:{reference:e,floating:n}});g=N??g,y=S??y,x[k]={...x[k],...$},_&&h<g4&&(h++,typeof _=="object"&&(_.placement&&(v=_.placement),_.rects&&(f=_.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:o}):_.rects),{x:g,y}=rk(f,v,u)),b=-1)}return{x:g,y,placement:v,strategy:o,middlewareData:x}},v4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:o,middlewareData:i,rects:c,initialPlacement:d,platform:u,elements:f}=n,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:v,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:b=!0,...j}=Rl(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=Ja(o),E=to(d),N=Ja(d)===d,S=await(u.isRTL==null?void 0:u.isRTL(f.floating)),$=v||(N||!b?[Kf(d)]:c4(d)),_=x!=="none";!v&&_&&$.push(...m4(d,b,x,S));const O=[d,...$],M=await u.detectOverflow(n,j),P=[];let A=((r=i.flip)==null?void 0:r.overflows)||[];if(g&&P.push(M[k]),y){const U=l4(o,c,S);P.push(M[U[0]],M[U[1]])}if(A=[...A,{placement:o,overflows:P}],!P.every(U=>U<=0)){var R,L;const U=(((R=i.flip)==null?void 0:R.index)||0)+1,Y=O[U];if(Y&&(!(y==="alignment"?E!==to(Y):!1)||A.every(F=>to(F.placement)===E?F.overflows[0]>0:!0)))return{data:{index:U,overflows:A},reset:{placement:Y}};let D=(L=A.filter(G=>G.overflows[0]<=0).sort((G,F)=>G.overflows[1]-F.overflows[1])[0])==null?void 0:L.placement;if(!D)switch(h){case"bestFit":{var W;const G=(W=A.filter(F=>{if(_){const q=to(F.placement);return q===E||q==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(q=>q>0).reduce((q,H)=>q+H,0)]).sort((F,q)=>F[1]-q[1])[0])==null?void 0:W[0];G&&(D=G);break}case"initialPlacement":D=d;break}if(o!==D)return{reset:{placement:D}}}return{}}}},b4=new Set(["left","top"]);async function y4(e,n){const{placement:s,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Ja(s),d=jd(s),u=to(s)==="y",f=b4.has(c)?-1:1,g=i&&u?-1:1,y=Rl(n,e);let{mainAxis:v,crossAxis:h,alignmentAxis:x}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return d&&typeof x=="number"&&(h=d==="end"?x*-1:x),u?{x:h*g,y:v*f}:{x:v*f,y:h*g}}const w4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,r;const{x:o,y:i,placement:c,middlewareData:d}=n,u=await y4(n,e);return c===((s=d.offset)==null?void 0:s.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:c}}}}},j4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:r,placement:o,platform:i}=n,{mainAxis:c=!0,crossAxis:d=!1,limiter:u={fn:E=>{let{x:N,y:S}=E;return{x:N,y:S}}},...f}=Rl(e,n),g={x:s,y:r},y=await i.detectOverflow(n,f),v=to(o),h=xS(v);let x=g[h],b=g[v];const j=(E,N)=>i4(N+y[E==="y"?"top":"left"],N,N-y[E==="y"?"bottom":"right"]);c&&(x=j(h,x)),d&&(b=j(v,b));const k=u.fn({...n,[h]:x,[v]:b});return{...k,data:{x:k.x-s,y:k.y-r,enabled:{[h]:c,[v]:d}}}}}},k4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){const{placement:s,rects:r,platform:o,elements:i}=n,{apply:c=()=>{},...d}=Rl(e,n),u=await o.detectOverflow(n,d),f=Ja(s),g=jd(s),y=to(s)==="y",{width:v,height:h}=r.floating;let x,b;f==="top"||f==="bottom"?(x=f,b=g===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(b=f,x=g==="end"?"top":"bottom");const j=h-u.top-u.bottom,k=v-u.left-u.right,E=Qa(h-u[x],j),N=Qa(v-u[b],k),S=n.middlewareData.shift,$=!S;let _=E,O=N;S!=null&&S.enabled.x&&(O=k),S!=null&&S.enabled.y&&(_=j),$&&!g&&(y?O=v-2*Ks(u.left,u.right):_=h-2*Ks(u.top,u.bottom)),await c({...n,availableWidth:O,availableHeight:_});const M=await o.getDimensions(i.floating);return v!==M.width||h!==M.height?{reset:{rects:!0}}:{}}}};function wS(e){const n=zr(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=la(e),i=o?e.offsetWidth:s,c=o?e.offsetHeight:r,d=rd(s)!==i||rd(r)!==c;return d&&(s=i,r=c),{width:s,height:r,$:d}}function pv(e){return gs(e)?e:e.contextElement}function sl(e){const n=pv(e);if(!la(n))return oo(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:i}=wS(n);let c=(i?rd(s.width):s.width)/r,d=(i?rd(s.height):s.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const N4=oo(0);function jS(e){const n=xs(e);return!hv()||!n.visualViewport?N4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function S4(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===xs(e)}function Xa(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),i=pv(e);let c=oo(1);n&&(r?gs(r)&&(c=sl(r)):c=sl(e));const d=S4(i,s,r)?jS(i):oo(0);let u=(o.left+d.x)/c.x,f=(o.top+d.y)/c.y,g=o.width/c.x,y=o.height/c.y;if(i&&r){const v=xs(i),h=gs(r)?xs(r):r;let x=v,b=tx(x);for(;b&&h!==x;){const j=sl(b),k=b.getBoundingClientRect(),E=zr(b),N=k.left+(b.clientLeft+parseFloat(E.paddingLeft))*j.x,S=k.top+(b.clientTop+parseFloat(E.paddingTop))*j.y;u*=j.x,f*=j.y,g*=j.x,y*=j.y,u+=N,f+=S,x=xs(b),b=tx(x)}}return Vf({width:g,height:y,x:u,y:f})}function Wm(e,n){const s=Um(e).scrollLeft;return n?n.left+s:Xa(fo(e)).left+s}function kS(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-Wm(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function C4(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const i=o==="fixed",c=fo(r),d=n?Fm(n.floating):!1;if(r===c||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=oo(1);const g=oo(0),y=la(r);if((y||!i)&&((Tl(r)!=="body"||Dm(c))&&(u=Um(r)),y)){const h=Xa(r);f=sl(r),g.x=h.x+r.clientLeft,g.y=h.y+r.clientTop}const v=c&&!y&&!i?kS(c,u):oo(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+g.x+v.x,y:s.y*f.y-u.scrollTop*f.y+g.y+v.y}}function E4(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function $4(e){const n=Um(e),s=e.ownerDocument.body,r=Ks(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=Ks(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Wm(e);const c=-n.scrollTop;return zr(s).direction==="rtl"&&(i+=Ks(e.clientWidth,s.clientWidth)-r),{width:r,height:o,x:i,y:c}}const _4=25;function T4(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",o=xs(e),i=fo(e),c=o.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,g=0;if(c){const v=!hv()||n==="fixed";r?v||(f=-c.offsetLeft,g=-c.offsetTop):(d=c.width,u=c.height,v&&(f=c.offsetLeft,g=c.offsetTop))}if(Wm(i)<=0){const v=i.ownerDocument,h=v.body,x=getComputedStyle(h),b=v.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,j=Math.abs(i.clientWidth-h.clientWidth-b),k=getComputedStyle(i).scrollbarGutter==="stable both-edges"?j/2:j;k<=_4&&(d-=k)}return{width:d,height:u,x:f,y:g}}function R4(e,n){const s=Xa(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,i=sl(e),c=e.clientWidth*i.x,d=e.clientHeight*i.y,u=o*i.x,f=r*i.y;return{width:c,height:d,x:u,y:f}}function ok(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=T4(e,s,n);else if(n==="document")r=$4(fo(e));else if(gs(n))r=R4(n,s);else{const o=jS(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return Vf(r)}function A4(e,n){const s=n.get(e);if(s)return s;let r=sd(e,[],!1).filter(d=>gs(d)&&Tl(d)!=="body"),o=null;const i=zr(e).position==="fixed";let c=i?Ya(e):e;for(;gs(c)&&!nd(c);){const d=zr(c),u=mv(c),f=o?o.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(y=>y!==c):o=d,c=Ya(c)}return n.set(e,r),r}function O4(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const c=[...s==="clippingAncestors"?Fm(n)?[]:A4(n,this._c):[].concat(s),r],d=ok(n,c[0],o);let u=d.top,f=d.right,g=d.bottom,y=d.left;for(let v=1;v<c.length;v++){const h=ok(n,c[v],o);u=Ks(h.top,u),f=Qa(h.right,f),g=Qa(h.bottom,g),y=Ks(h.left,y)}return{width:f-y,height:g-u,x:y,y:u}}function M4(e){const{width:n,height:s}=wS(e);return{width:n,height:s}}function L4(e,n,s){const r=la(n),o=fo(n),i=s==="fixed",c=Xa(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=oo(0);if((r||!i)&&((Tl(n)!=="body"||Dm(o))&&(d=Um(n)),r)){const v=Xa(n,!0,i,n);u.x=v.x+n.clientLeft,u.y=v.y+n.clientTop}!r&&o&&(u.x=Wm(o));const f=o&&!r&&!i?kS(o,d):oo(0),g=c.left+d.scrollLeft-u.x-f.x,y=c.top+d.scrollTop-u.y-f.y;return{x:g,y,width:c.width,height:c.height}}function dg(e){return zr(e).position==="static"}function ak(e,n){if(!la(e)||zr(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return fo(e)===s&&(s=s.ownerDocument.body),s}function NS(e,n){const s=xs(e);if(Fm(e))return s;if(!la(e)){let o=Ya(e);for(;o&&!nd(o);){if(gs(o)&&!dg(o))return o;o=Ya(o)}return s}let r=ak(e,n);for(;r&&t4(r)&&dg(r);)r=ak(r,n);return r&&nd(r)&&dg(r)&&!mv(r)?s:r||r4(e)||s}const P4=async function(e){const n=this.getOffsetParent||NS,s=this.getDimensions,r=await s(e.floating);return{reference:L4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function I4(e){return zr(e).direction==="rtl"}const z4={convertOffsetParentRelativeRectToViewportRelativeRect:C4,getDocumentElement:fo,getClippingRect:O4,getOffsetParent:NS,getElementRects:P4,getClientRects:E4,getDimensions:M4,getScale:sl,isElement:gs,isRTL:I4};function SS(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function D4(e,n,s){let r=null,o;const i=fo(e);function c(){var g;clearTimeout(o),(g=r)==null||g.disconnect(),r=null}function d(g,y){g===void 0&&(g=!1),y===void 0&&(y=1),c();const v=e.getBoundingClientRect(),{left:h,top:x,width:b,height:j}=v;if(g||n(),!b||!j)return;const k=af(x),E=af(i.clientWidth-(h+b)),N=af(i.clientHeight-(x+j)),S=af(h),_={rootMargin:-k+"px "+-E+"px "+-N+"px "+-S+"px",threshold:Ks(0,Qa(1,y))||1};let O=!0;function M(P){const A=P[0].intersectionRatio;if(!SS(v,e.getBoundingClientRect()))return d();if(A!==y){if(!O)return d();A?d(!1,A):o=setTimeout(()=>{d(!1,1e-7)},1e3)}O=!1}try{r=new IntersectionObserver(M,{..._,root:i.ownerDocument})}catch{r=new IntersectionObserver(M,_)}r.observe(e)}const u=xs(e),f=()=>d(s);return u.addEventListener("resize",f),d(!0),()=>{u.removeEventListener("resize",f),c()}}function F4(e,n,s,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=pv(e),g=o||i?[...f?sd(f):[],...n?sd(n):[]]:[];g.forEach(k=>{o&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const y=f&&d?D4(f,s,i):null;let v=-1,h=null;c&&(h=new ResizeObserver(k=>{let[E]=k;E&&E.target===f&&h&&n&&(h.unobserve(n),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var N;(N=h)==null||N.observe(n)})),s()}),f&&!u&&h.observe(f),n&&h.observe(n));let x,b=u?Xa(e):null;u&&j();function j(){const k=Xa(e);b&&!SS(b,k)&&s(),b=k,x=requestAnimationFrame(j)}return s(),()=>{var k;g.forEach(E=>{o&&E.removeEventListener("scroll",s),i&&E.removeEventListener("resize",s)}),y==null||y(),(k=h)==null||k.disconnect(),h=null,u&&cancelAnimationFrame(x)}}const ug=yS,U4=w4,W4=j4,H4=v4,B4=k4,q4=(e,n,s)=>{const r=new Map,o=s??{},i={...z4,...o.platform,_c:r};return x4(e,n,{...o,platform:i})};var G4=typeof document<"u",K4=function(){},Of=G4?p.useLayoutEffect:K4;function Yf(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,r,o;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(r=s;r--!==0;)if(!Yf(e[r],n[r]))return!1;return!0}if(o=Object.keys(e),s=o.length,s!==Object.keys(n).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(n,o[r]))return!1;for(r=s;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Yf(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function CS(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ik(e,n){const s=CS(e);return Math.round(n*s)/s}function fg(e){const n=p.useRef(e);return Of(()=>{n.current=e}),n}function V4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:c}={},transform:d=!0,whileElementsMounted:u,open:f}=e,[g,y]=p.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[v,h]=p.useState(r);Yf(v,r)||h(r);const[x,b]=p.useState(null),[j,k]=p.useState(null),E=p.useCallback(F=>{F!==_.current&&(_.current=F,b(F))},[]),N=p.useCallback(F=>{F!==O.current&&(O.current=F,k(F))},[]),S=i||x,$=c||j,_=p.useRef(null),O=p.useRef(null),M=p.useRef(g),P=u!=null,A=fg(u),R=fg(o),L=fg(f),W=p.useCallback(()=>{if(!_.current||!O.current)return;const F={placement:n,strategy:s,middleware:v};R.current&&(F.platform=R.current),q4(_.current,O.current,F).then(q=>{const H={...q,isPositioned:L.current!==!1};U.current&&!Yf(M.current,H)&&(M.current=H,_s.flushSync(()=>{y(H)}))})},[v,n,s,R,L]);Of(()=>{f===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,y(F=>({...F,isPositioned:!1})))},[f]);const U=p.useRef(!1);Of(()=>(U.current=!0,()=>{U.current=!1}),[]),Of(()=>{if(S&&(_.current=S),$&&(O.current=$),S&&$){if(A.current)return A.current(S,$,W);W()}},[S,$,W,A,P]);const Y=p.useMemo(()=>({reference:_,floating:O,setReference:E,setFloating:N}),[E,N]),D=p.useMemo(()=>({reference:S,floating:$}),[S,$]),G=p.useMemo(()=>{const F={position:s,left:0,top:0};if(!D.floating)return F;const q=ik(D.floating,g.x),H=ik(D.floating,g.y);return d?{...F,transform:"translate("+q+"px, "+H+"px)",...CS(D.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:q,top:H}},[s,d,D.floating,g.x,g.y]);return p.useMemo(()=>({...g,update:W,refs:Y,elements:D,floatingStyles:G}),[g,W,Y,D,G])}const ES=(e,n)=>{const s=U4(e);return{name:s.name,fn:s.fn,options:[e,n]}},Y4=(e,n)=>{const s=W4(e);return{name:s.name,fn:s.fn,options:[e,n]}},Q4=(e,n)=>{const s=H4(e);return{name:s.name,fn:s.fn,options:[e,n]}},J4=(e,n)=>{const s=B4(e);return{name:s.name,fn:s.fn,options:[e,n]}},$S={...Bg},X4=$S.useInsertionEffect,Z4=X4||(e=>e());function _S(e){const n=p.useRef(()=>{});return Z4(()=>{n.current=e}),p.useCallback(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return n.current==null?void 0:n.current(...r)},[])}var sx=typeof document<"u"?p.useLayoutEffect:p.useEffect;let lk=!1,eO=0;const ck=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+eO++;function tO(){const[e,n]=p.useState(()=>lk?ck():void 0);return sx(()=>{e==null&&n(ck())},[]),p.useEffect(()=>{lk=!0},[]),e}const nO=$S.useId,sO=nO||tO;function rO(){const e=new Map;return{emit(n,s){var r;(r=e.get(n))==null||r.forEach(o=>o(s))},on(n,s){e.set(n,[...e.get(n)||[],s])},off(n,s){var r;e.set(n,((r=e.get(n))==null?void 0:r.filter(o=>o!==s))||[])}}}const oO=p.createContext(null),aO=p.createContext(null),iO=()=>{var e;return((e=p.useContext(oO))==null?void 0:e.id)||null},lO=()=>p.useContext(aO),cO="data-floating-ui-focusable";function dO(e){const{open:n=!1,onOpenChange:s,elements:r}=e,o=sO(),i=p.useRef({}),[c]=p.useState(()=>rO()),d=iO()!=null,[u,f]=p.useState(r.reference),g=_S((h,x,b)=>{i.current.openEvent=h?x:void 0,c.emit("openchange",{open:h,event:x,reason:b,nested:d}),s==null||s(h,x,b)}),y=p.useMemo(()=>({setPositionReference:f}),[]),v=p.useMemo(()=>({reference:u||r.reference||null,floating:r.floating||null,domReference:r.reference}),[u,r.reference,r.floating]);return p.useMemo(()=>({dataRef:i,open:n,onOpenChange:g,elements:v,events:c,floatingId:o,refs:y}),[n,g,v,c,o,y])}function uO(e){e===void 0&&(e={});const{nodeId:n}=e,s=dO({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,o=r.elements,[i,c]=p.useState(null),[d,u]=p.useState(null),g=(o==null?void 0:o.domReference)||i,y=p.useRef(null),v=lO();sx(()=>{g&&(y.current=g)},[g]);const h=V4({...e,elements:{...o,...d&&{reference:d}}}),x=p.useCallback(N=>{const S=gs(N)?{getBoundingClientRect:()=>N.getBoundingClientRect(),contextElement:N}:N;u(S),h.refs.setReference(S)},[h.refs]),b=p.useCallback(N=>{(gs(N)||N===null)&&(y.current=N,c(N)),(gs(h.refs.reference.current)||h.refs.reference.current===null||N!==null&&!gs(N))&&h.refs.setReference(N)},[h.refs]),j=p.useMemo(()=>({...h.refs,setReference:b,setPositionReference:x,domReference:y}),[h.refs,b,x]),k=p.useMemo(()=>({...h.elements,domReference:g}),[h.elements,g]),E=p.useMemo(()=>({...h,...r,refs:j,elements:k,nodeId:n}),[h,j,k,n,r]);return sx(()=>{r.dataRef.current.floatingContext=E;const N=v==null?void 0:v.nodesRef.current.find(S=>S.id===n);N&&(N.context=E)}),p.useMemo(()=>({...h,context:E,refs:j,elements:k}),[h,j,k,E])}const dk="active",uk="selected";function mg(e,n,s){const r=new Map,o=s==="item";let i=e;if(o&&e){const{[dk]:c,[uk]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[cO]:""},...i,...n.map(c=>{const d=c?c[s]:null;return typeof d=="function"?e?d(e):null:d}).concat(e).reduce((c,d)=>(d&&Object.entries(d).forEach(u=>{let[f,g]=u;if(!(o&&[dk,uk].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof g=="function"){var y;(y=r.get(f))==null||y.push(g),c[f]=function(){for(var v,h=arguments.length,x=new Array(h),b=0;b<h;b++)x[b]=arguments[b];return(v=r.get(f))==null?void 0:v.map(j=>j(...x)).find(j=>j!==void 0)}}}else c[f]=g}),c),{})}}function fO(e){e===void 0&&(e=[]);const n=e.map(d=>d==null?void 0:d.reference),s=e.map(d=>d==null?void 0:d.floating),r=e.map(d=>d==null?void 0:d.item),o=p.useCallback(d=>mg(d,e,"reference"),n),i=p.useCallback(d=>mg(d,e,"floating"),s),c=p.useCallback(d=>mg(d,e,"item"),r);return p.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:c}),[o,i,c])}function fk(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const mO=e=>({name:"inner",options:e,async fn(n){const{listRef:s,overflowRef:r,onFallbackChange:o,offset:i=0,index:c=0,minItemsVisible:d=4,referenceOverflowThreshold:u=0,scrollRef:f,...g}=Rl(e,n),{rects:y,elements:{floating:v}}=n,h=s.current[c],x=(f==null?void 0:f.current)||v,b=v.clientTop||x.clientTop,j=v.clientTop!==0,k=x.clientTop!==0,E=v===x;if(!h)return{};const N={...n,...await ES(-h.offsetTop-v.clientTop-y.reference.height/2-h.offsetHeight/2-i).fn(n)},S=await ug(fk(N,x.scrollHeight+b+v.clientTop),g),$=await ug(N,{...g,elementContext:"reference"}),_=Ks(0,S.top),O=N.y+_,A=(x.scrollHeight>x.clientHeight?R=>R:rd)(Ks(0,x.scrollHeight+(j&&E||k?b*2:0)-_-Ks(0,S.bottom)));if(x.style.maxHeight=A+"px",x.scrollTop=_,o){const R=x.offsetHeight<h.offsetHeight*Qa(d,s.current.length)-1||$.top>=-u||$.bottom>=-u;_s.flushSync(()=>o(R))}return r&&(r.current=await ug(fk({...N,y:O},x.offsetHeight+b+v.clientTop),g)),{y:O}}});function hO(e,n){const{open:s,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:c,onChange:d}=n,u=_S(d),f=p.useRef(!1),g=p.useRef(null),y=p.useRef(null);p.useEffect(()=>{if(!o)return;function h(b){if(b.ctrlKey||!x||i.current==null)return;const j=b.deltaY,k=i.current.top>=-.5,E=i.current.bottom>=-.5,N=x.scrollHeight-x.clientHeight,S=j<0?-1:1,$=j<0?"max":"min";x.scrollHeight<=x.clientHeight||(!k&&j>0||!E&&j<0?(b.preventDefault(),_s.flushSync(()=>{u(_=>_+Math[$](j,N*S))})):/firefox/i.test(o4())&&(x.scrollTop+=j))}const x=(c==null?void 0:c.current)||r.floating;if(s&&x)return x.addEventListener("wheel",h),requestAnimationFrame(()=>{g.current=x.scrollTop,i.current!=null&&(y.current={...i.current})}),()=>{g.current=null,y.current=null,x.removeEventListener("wheel",h)}},[o,s,r.floating,i,c,u]);const v=p.useMemo(()=>({onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const h=(c==null?void 0:c.current)||r.floating;if(!(!i.current||!h||!f.current)){if(g.current!==null){const x=h.scrollTop-g.current;(i.current.bottom<-.5&&x<-1||i.current.top<-.5&&x>1)&&_s.flushSync(()=>u(b=>b+x))}requestAnimationFrame(()=>{g.current=h.scrollTop})}}}),[r.floating,u,i,c]);return p.useMemo(()=>o?{floating:v}:{},[o,v])}let Al=p.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Al.displayName="FloatingContext";let gv=p.createContext(null);gv.displayName="PlacementContext";function pO(e){return p.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function gO(){return p.useContext(Al).setReference}function xO(){return p.useContext(Al).getReferenceProps}function vO(){let{getFloatingProps:e,slot:n}=p.useContext(Al);return p.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function bO(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=p.useContext(gv),s=p.useMemo(()=>e,[JSON.stringify(e,(o,i)=>{var c;return(c=i==null?void 0:i.outerHTML)!=null?c:i})]);rn(()=>{n==null||n(s??null)},[n,s]);let r=p.useContext(Al);return p.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let mk=4;function yO({children:e,enabled:n=!0}){let[s,r]=p.useState(null),[o,i]=p.useState(0),c=p.useRef(null),[d,u]=p.useState(null);wO(d);let f=n&&s!==null&&d!==null,{to:g="bottom",gap:y=0,offset:v=0,padding:h=0,inner:x}=jO(s,d),[b,j="center"]=g.split(" ");rn(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:E,context:N}=uO({open:f,placement:b==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${b}`:`${b}-${j}`,strategy:"absolute",transform:!1,middleware:[ES({mainAxis:b==="selection"?0:y,crossAxis:v}),Y4({padding:h}),b!=="selection"&&Q4({padding:h}),b==="selection"&&x?mO({...x,padding:h,overflowRef:c,offset:o,minItemsVisible:mk,referenceOverflowThreshold:h,onFallbackChange(R){var L,W;if(!R)return;let U=N.elements.floating;if(!U)return;let Y=parseFloat(getComputedStyle(U).scrollPaddingBottom)||0,D=Math.min(mk,U.childElementCount),G=0,F=0;for(let q of(W=(L=N.elements.floating)==null?void 0:L.childNodes)!=null?W:[])if(Ts(q)){let H=q.offsetTop,I=H+q.clientHeight+Y,V=U.scrollTop,J=V+U.clientHeight;if(H>=V&&I<=J)D--;else{F=Math.max(0,Math.min(I,J)-Math.max(H,V)),G=q.clientHeight;break}}D>=1&&i(q=>{let H=G*D-F+Y;return q>=H?q:H})}}):null,J4({padding:h,apply({availableWidth:R,availableHeight:L,elements:W}){Object.assign(W.floating.style,{overflow:"auto",maxWidth:`${R}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${L}px)`})}})].filter(Boolean),whileElementsMounted:F4}),[S=b,$=j]=N.placement.split("-");b==="selection"&&(S="selection");let _=p.useMemo(()=>({anchor:[S,$].filter(Boolean).join(" ")}),[S,$]),O=hO(N,{overflowRef:c,onChange:i}),{getReferenceProps:M,getFloatingProps:P}=fO([O]),A=ut(R=>{u(R),k.setFloating(R)});return p.createElement(gv.Provider,{value:r},p.createElement(Al.Provider,{value:{setFloating:A,setReference:k.setReference,styles:E,getReferenceProps:M,getFloatingProps:P,slot:_}},e))}function wO(e){rn(()=>{if(!e)return;let n=new MutationObserver(()=>{let s=window.getComputedStyle(e).maxHeight,r=parseFloat(s);if(isNaN(r))return;let o=parseInt(s);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return n.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{n.disconnect()}},[e])}function jO(e,n){var s,r,o;let i=hg((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),c=hg((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=hg((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:c,padding:d}}function hg(e,n,s=void 0){let r=aa(),o=ut((u,f)=>{if(u==null)return[s,null];if(typeof u=="number")return[u,null];if(typeof u=="string"){if(!f)return[s,null];let g=hk(u,f);return[g,y=>{let v=TS(u);{let h=v.map(x=>window.getComputedStyle(f).getPropertyValue(x));r.requestAnimationFrame(function x(){r.nextFrame(x);let b=!1;for(let[k,E]of v.entries()){let N=window.getComputedStyle(f).getPropertyValue(E);if(h[k]!==N){h[k]=N,b=!0;break}}if(!b)return;let j=hk(u,f);g!==j&&(y(j),g=j)})}return r.dispose}]}return[s,null]}),i=p.useMemo(()=>o(e,n)[0],[e,n]),[c=i,d]=p.useState();return rn(()=>{let[u,f]=o(e,n);if(d(u),!!f)return f(d)},[e,n]),c}function TS(e){let n=/var\((.*)\)/.exec(e);if(n){let s=n[1].indexOf(",");if(s===-1)return[n[1]];let r=n[1].slice(0,s).trim(),o=n[1].slice(s+1).trim();return o?[r,...TS(o)]:[r]}return[]}function hk(e,n){let s=document.createElement("div");n.appendChild(s),s.style.setProperty("margin-top","0px","important"),s.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(s).marginTop)||0;return n.removeChild(s),r}function kO({children:e,freeze:n},s){let r=RS(n,e);return p.isValidElement(r)?p.cloneElement(r,{ref:s}):Be.createElement(Be.Fragment,null,r)}Be.forwardRef(kO);function RS(e,n){let[s,r]=p.useState(n);return!e&&s!==n&&r(n),e?s:n}let Hm=p.createContext(null);Hm.displayName="OpenClosedContext";var ss=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(ss||{});function kd(){return p.useContext(Hm)}function AS({value:e,children:n}){return Be.createElement(Hm.Provider,{value:e},n)}function NO({children:e}){return Be.createElement(Hm.Provider,{value:null},e)}function SO(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let Uo=[];SO(()=>{function e(n){if(!eo(n.target)||n.target===document.body||Uo[0]===n.target)return;let s=n.target;s=s.closest(Gf),Uo.unshift(s??n.target),Uo=Uo.filter(r=>r!=null&&r.isConnected),Uo.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function CO(e){throw new Error("Unexpected object: "+e)}var dn=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(dn||{});function lf(e,n){let s=n.resolveItems();if(s.length<=0)return null;let r=n.resolveActiveIndex(),o=r??-1;switch(e.focus){case 0:{for(let i=0;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 1:{o===-1&&(o=s.length);for(let i=o-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 2:{for(let i=o+1;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 3:{for(let i=s.length-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 4:{for(let i=0;i<s.length;++i)if(n.resolveId(s[i],i,s)===e.id)return i;return r}case 5:return null;default:CO(e)}}function xv(e){let n=ut(e),s=p.useRef(!1);p.useEffect(()=>(s.current=!1,()=>{s.current=!0,Mm(()=>{s.current&&n()})}),[n])}function EO(){let e=typeof document>"u";return"useSyncExternalStore"in Bg?(n=>n.useSyncExternalStore)(Bg)(()=>()=>{},()=>!1,()=>!e):!1}function Nd(){let e=EO(),[n,s]=p.useState(Lr.isHandoffComplete);return n&&Lr.isHandoffComplete===!1&&s(!1),p.useEffect(()=>{n!==!0&&s(!0)},[n]),p.useEffect(()=>Lr.handoff(),[]),e?!1:n}let OS=p.createContext(!1);function $O(){return p.useContext(OS)}function pk(e){return Be.createElement(OS.Provider,{value:e.force},e.children)}function _O(e){let n=$O(),s=p.useContext(LS),[r,o]=p.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if(Lr.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let d=e.createElement("div");return d.setAttribute("id","headlessui-portal-root"),e.body.appendChild(d)});return p.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),p.useEffect(()=>{n||s!==null&&o(s.current)},[s,o,n]),r}let MS=p.Fragment,TO=wn(function(e,n){let{ownerDocument:s=null,...r}=e,o=p.useRef(null),i=Yn(t3(h=>{o.current=h}),n),c=td(o.current),d=s??c,u=_O(d),f=p.useContext(rx),g=aa(),y=Nd(),v=Mn();return xv(()=>{var h;u&&u.childNodes.length<=0&&((h=u.parentElement)==null||h.removeChild(u))}),!u||!y?null:_s.createPortal(Be.createElement("div",{"data-headlessui-portal":"",ref:h=>{g.dispose(),f&&h&&g.add(f.register(h))}},v({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:MS,name:"Portal"})),u)});function RO(e,n){let s=Yn(n),{enabled:r=!0,ownerDocument:o,...i}=e,c=Mn();return r?Be.createElement(TO,{...i,ownerDocument:o,ref:s}):c({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:MS,name:"Portal"})}let AO=p.Fragment,LS=p.createContext(null);function OO(e,n){let{target:s,...r}=e,o={ref:Yn(n)},i=Mn();return Be.createElement(LS.Provider,{value:s},i({ourProps:o,theirProps:r,defaultTag:AO,name:"Popover.Group"}))}let rx=p.createContext(null);function MO(){let e=p.useContext(rx),n=p.useRef([]),s=ut(i=>(n.current.push(i),e&&e.register(i),()=>r(i))),r=ut(i=>{let c=n.current.indexOf(i);c!==-1&&n.current.splice(c,1),e&&e.unregister(i)}),o=p.useMemo(()=>({register:s,unregister:r,portals:n}),[s,r,n]);return[n,p.useMemo(()=>function({children:i}){return Be.createElement(rx.Provider,{value:o},i)},[o])]}let LO=wn(RO),PS=wn(OO),IS=Object.assign(LO,{Group:PS});const Mf={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function zS(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function PO(e,n,s){let r=Os();if(n.kind==="Tracked"){let o=function(){i!==zS(e)&&(r.dispose(),s())},{position:i}=n,c=new ResizeObserver(o);c.observe(e),r.add(()=>c.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}function IO(e,n=typeof document<"u"?document.defaultView:null,s){let r=wd(e,"escape");uS(n,"keydown",o=>{r&&(o.defaultPrevented||o.key===Sn.Escape&&s(o))})}function zO(){var e;let[n]=p.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[s,r]=p.useState((e=n==null?void 0:n.matches)!=null?e:!1);return rn(()=>{if(!n)return;function o(i){r(i.matches)}return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[n]),s}function DO({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=ut(()=>{var o,i;let c=_l(s),d=[];for(let u of e)u!==null&&(so(u)?d.push(u):"current"in u&&so(u.current)&&d.push(u.current));if(n!=null&&n.current)for(let u of n.current)d.push(u);for(let u of(o=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?o:[])u!==document.body&&u!==document.head&&so(u)&&u.id!=="headlessui-portal-root"&&(s&&(u.contains(s)||u.contains((i=s==null?void 0:s.getRootNode())==null?void 0:i.host))||d.some(f=>u.contains(f))||d.push(u));return d});return{resolveContainers:r,contains:ut(o=>r().some(i=>i.contains(o)))}}let DS=p.createContext(null);function gk({children:e,node:n}){let[s,r]=p.useState(null),o=FS(n??s);return Be.createElement(DS.Provider,{value:o},e,o===null&&Be.createElement(ed,{features:gl.Hidden,ref:i=>{var c,d;if(i){for(let u of(d=(c=_l(i))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&so(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function FS(e=null){var n;return(n=p.useContext(DS))!=null?n:e}function vv(){let e=p.useRef(!1);return rn(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var zc=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(zc||{});function FO(){let e=p.useRef(0);return cS(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function US(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)so(s.current)&&n.add(s.current);return n}let UO="div";var Ia=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(Ia||{});function WO(e,n){let s=p.useRef(null),r=Yn(s,n),{initialFocus:o,initialFocusFallback:i,containers:c,features:d=15,...u}=e;Nd()||(d=0);let f=td(s.current);GO(d,{ownerDocument:f});let g=KO(d,{ownerDocument:f,container:s,initialFocus:o,initialFocusFallback:i});VO(d,{ownerDocument:f,container:s,containers:c,previousActiveElement:g});let y=FO(),v=ut(E=>{if(!Ts(s.current))return;let N=s.current;(S=>S())(()=>{as(y.current,{[zc.Forwards]:()=>{nl(N,cr.First,{skipElements:[E.relatedTarget,i]})},[zc.Backwards]:()=>{nl(N,cr.Last,{skipElements:[E.relatedTarget,i]})}})})}),h=wd(!!(d&2),"focus-trap#tab-lock"),x=aa(),b=p.useRef(!1),j={ref:r,onKeyDown(E){E.key=="Tab"&&(b.current=!0,x.requestAnimationFrame(()=>{b.current=!1}))},onBlur(E){if(!(d&4))return;let N=US(c);Ts(s.current)&&N.add(s.current);let S=E.relatedTarget;eo(S)&&S.dataset.headlessuiFocusGuard!=="true"&&(WS(N,S)||(b.current?nl(s.current,as(y.current,{[zc.Forwards]:()=>cr.Next,[zc.Backwards]:()=>cr.Previous})|cr.WrapAround,{relativeTo:E.target}):eo(E.target)&&ro(E.target)))}},k=Mn();return Be.createElement(Be.Fragment,null,h&&Be.createElement(ed,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:v,features:gl.Focusable}),k({ourProps:j,theirProps:u,defaultTag:UO,name:"FocusTrap"}),h&&Be.createElement(ed,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:v,features:gl.Focusable}))}let HO=wn(WO),BO=Object.assign(HO,{features:Ia});function qO(e=!0){let n=p.useRef(Uo.slice());return fv(([s],[r])=>{r===!0&&s===!1&&Mm(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=Uo.slice())},[e,Uo,n]),ut(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function GO(e,{ownerDocument:n}){let s=!!(e&8),r=qO(s);fv(()=>{s||M1(n==null?void 0:n.body)&&ro(r())},[s]),xv(()=>{s&&ro(r())})}function KO(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:o}){let i=p.useRef(null),c=wd(!!(e&1),"focus-trap#initial-focus"),d=vv();return fv(()=>{if(e===0)return;if(!c){o!=null&&o.current&&ro(o.current);return}let u=s.current;u&&Mm(()=>{if(!d.current)return;let f=n==null?void 0:n.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===f){i.current=f;return}}else if(u.contains(f)){i.current=f;return}if(r!=null&&r.current)ro(r.current);else{if(e&16){if(nl(u,cr.First|cr.AutoFocus)!==ex.Error)return}else if(nl(u,cr.First)!==ex.Error)return;if(o!=null&&o.current&&(ro(o.current),(n==null?void 0:n.activeElement)===o.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=n==null?void 0:n.activeElement})},[o,c,e]),i}function VO(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:o}){let i=vv(),c=!!(e&4);uS(n==null?void 0:n.defaultView,"focus",d=>{if(!c||!i.current)return;let u=US(r);Ts(s.current)&&u.add(s.current);let f=o.current;if(!f)return;let g=d.target;Ts(g)?WS(u,g)?(o.current=g,ro(g)):(d.preventDefault(),d.stopPropagation(),ro(f)):ro(o.current)},!0)}function WS(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function HS(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!Wc((n=e.as)!=null?n:qS)||Be.Children.count(e.children)===1}let Bm=p.createContext(null);Bm.displayName="TransitionContext";var YO=(e=>(e.Visible="visible",e.Hidden="hidden",e))(YO||{});function QO(){let e=p.useContext(Bm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function JO(){let e=p.useContext(qm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let qm=p.createContext(null);qm.displayName="NestingContext";function Gm(e){return"children"in e?Gm(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function BS(e,n){let s=ia(e),r=p.useRef([]),o=vv(),i=aa(),c=ut((h,x=Wo.Hidden)=>{let b=r.current.findIndex(({el:j})=>j===h);b!==-1&&(as(x,{[Wo.Unmount](){r.current.splice(b,1)},[Wo.Hidden](){r.current[b].state="hidden"}}),i.microTask(()=>{var j;!Gm(r)&&o.current&&((j=s.current)==null||j.call(s))}))}),d=ut(h=>{let x=r.current.find(({el:b})=>b===h);return x?x.state!=="visible"&&(x.state="visible"):r.current.push({el:h,state:"visible"}),()=>c(h,Wo.Unmount)}),u=p.useRef([]),f=p.useRef(Promise.resolve()),g=p.useRef({enter:[],leave:[]}),y=ut((h,x,b)=>{u.current.splice(0),n&&(n.chains.current[x]=n.chains.current[x].filter(([j])=>j!==h)),n==null||n.chains.current[x].push([h,new Promise(j=>{u.current.push(j)})]),n==null||n.chains.current[x].push([h,new Promise(j=>{Promise.all(g.current[x].map(([k,E])=>E)).then(()=>j())})]),x==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>b(x)):b(x)}),v=ut((h,x,b)=>{Promise.all(g.current[x].splice(0).map(([j,k])=>k)).then(()=>{var j;(j=u.current.shift())==null||j()}).then(()=>b(x))});return p.useMemo(()=>({children:r,register:d,unregister:c,onStart:y,onStop:v,wait:f,chains:g}),[d,c,r,y,v,g,f])}let qS=p.Fragment,GS=pl.RenderStrategy;function XO(e,n){var s,r;let{transition:o=!0,beforeEnter:i,afterEnter:c,beforeLeave:d,afterLeave:u,enter:f,enterFrom:g,enterTo:y,entered:v,leave:h,leaveFrom:x,leaveTo:b,...j}=e,[k,E]=p.useState(null),N=p.useRef(null),S=HS(e),$=Yn(...S?[N,n,E]:n===null?[]:[n]),_=(s=j.unmount)==null||s?Wo.Unmount:Wo.Hidden,{show:O,appear:M,initial:P}=QO(),[A,R]=p.useState(O?"visible":"hidden"),L=JO(),{register:W,unregister:U}=L;rn(()=>W(N),[W,N]),rn(()=>{if(_===Wo.Hidden&&N.current){if(O&&A!=="visible"){R("visible");return}return as(A,{hidden:()=>U(N),visible:()=>W(N)})}},[A,N,W,U,O,_]);let Y=Nd();rn(()=>{if(S&&Y&&A==="visible"&&N.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[N,A,Y,S]);let D=P&&!M,G=M&&O&&P,F=p.useRef(!1),q=BS(()=>{F.current||(R("hidden"),U(N))},L),H=ut(ye=>{F.current=!0;let he=ye?"enter":"leave";q.onStart(N,he,we=>{we==="enter"?i==null||i():we==="leave"&&(d==null||d())})}),I=ut(ye=>{let he=ye?"enter":"leave";F.current=!1,q.onStop(N,he,we=>{we==="enter"?c==null||c():we==="leave"&&(u==null||u())}),he==="leave"&&!Gm(q)&&(R("hidden"),U(N))});p.useEffect(()=>{S&&o||(H(O),I(O))},[O,S,o]);let V=!(!o||!S||!Y||D),[,J]=hS(V,k,O,{start:H,end:I}),X=Fo({ref:$,className:((r=Xg(j.className,G&&f,G&&g,J.enter&&f,J.enter&&J.closed&&g,J.enter&&!J.closed&&y,J.leave&&h,J.leave&&!J.closed&&x,J.leave&&J.closed&&b,!J.transition&&O&&v))==null?void 0:r.trim())||void 0,...mS(J)}),re=0;A==="visible"&&(re|=ss.Open),A==="hidden"&&(re|=ss.Closed),O&&A==="hidden"&&(re|=ss.Opening),!O&&A==="visible"&&(re|=ss.Closing);let ae=Mn();return Be.createElement(qm.Provider,{value:q},Be.createElement(AS,{value:re},ae({ourProps:X,theirProps:j,defaultTag:qS,features:GS,visible:A==="visible",name:"Transition.Child"})))}function ZO(e,n){let{show:s,appear:r=!1,unmount:o=!0,...i}=e,c=p.useRef(null),d=HS(e),u=Yn(...d?[c,n]:n===null?[]:[n]);Nd();let f=kd();if(s===void 0&&f!==null&&(s=(f&ss.Open)===ss.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,y]=p.useState(s?"visible":"hidden"),v=BS(()=>{s||y("hidden")}),[h,x]=p.useState(!0),b=p.useRef([s]);rn(()=>{h!==!1&&b.current[b.current.length-1]!==s&&(b.current.push(s),x(!1))},[b,s]);let j=p.useMemo(()=>({show:s,appear:r,initial:h}),[s,r,h]);rn(()=>{s?y("visible"):!Gm(v)&&c.current!==null&&y("hidden")},[s,v]);let k={unmount:o},E=ut(()=>{var $;h&&x(!1),($=e.beforeEnter)==null||$.call(e)}),N=ut(()=>{var $;h&&x(!1),($=e.beforeLeave)==null||$.call(e)}),S=Mn();return Be.createElement(qm.Provider,{value:v},Be.createElement(Bm.Provider,{value:j},S({ourProps:{...k,as:p.Fragment,children:Be.createElement(KS,{ref:u,...k,...i,beforeEnter:E,beforeLeave:N})},theirProps:{},defaultTag:p.Fragment,features:GS,visible:g==="visible",name:"Transition"})))}function eM(e,n){let s=p.useContext(Bm)!==null,r=kd()!==null;return Be.createElement(Be.Fragment,null,!s&&r?Be.createElement(ox,{ref:n,...e}):Be.createElement(KS,{ref:n,...e}))}let ox=wn(ZO),KS=wn(XO),bv=wn(eM),tM=Object.assign(ox,{Child:bv,Root:ox});var nM=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(nM||{}),sM=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(sM||{});let rM={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},yv=p.createContext(null);yv.displayName="DialogContext";function Km(e){let n=p.useContext(yv);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Km),s}return n}function oM(e,n){return as(n.type,rM,e,n)}let xk=wn(function(e,n){let s=p.useId(),{id:r=`headlessui-dialog-${s}`,open:o,onClose:i,initialFocus:c,role:d="dialog",autoFocus:u=!0,__demoMode:f=!1,unmount:g=!1,...y}=e,v=p.useRef(!1);d=(function(){return d==="dialog"||d==="alertdialog"?d:(v.current||(v.current=!0,console.warn(`Invalid role [${d}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let h=kd();o===void 0&&h!==null&&(o=(h&ss.Open)===ss.Open);let x=p.useRef(null),b=Yn(x,n),j=td(x.current),k=o?0:1,[E,N]=p.useReducer(oM,{titleId:null,descriptionId:null,panelRef:p.createRef()}),S=ut(()=>i(!1)),$=ut(J=>N({type:0,id:J})),_=Nd()?k===0:!1,[O,M]=MO(),P={get current(){var J;return(J=E.panelRef.current)!=null?J:x.current}},A=FS(),{resolveContainers:R}=DO({mainTreeNode:A,portals:O,defaultContainers:[P]}),L=h!==null?(h&ss.Closing)===ss.Closing:!1;sS(f||L?!1:_,{allowed:ut(()=>{var J,X;return[(X=(J=x.current)==null?void 0:J.closest("[data-headlessui-portal]"))!=null?X:null]}),disallowed:ut(()=>{var J;return[(J=A==null?void 0:A.closest("body > *:not(#headlessui-portal-root)"))!=null?J:null]})});let W=Im.get(null);rn(()=>{if(_)return W.actions.push(r),()=>W.actions.pop(r)},[W,r,_]);let U=ts(W,p.useCallback(J=>W.selectors.isTop(J,r),[W,r]));dS(U,R,J=>{J.preventDefault(),S()}),IO(U,j==null?void 0:j.defaultView,J=>{J.preventDefault(),J.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),S()}),fS(f||L?!1:_,j,R),rS(_,x,S);let[Y,D]=s3(),G=p.useMemo(()=>[{dialogState:k,close:S,setTitleId:$,unmount:g},E],[k,S,$,g,E]),F=Js({open:k===0}),q={ref:b,id:r,role:d,tabIndex:-1,"aria-modal":f?void 0:k===0?!0:void 0,"aria-labelledby":E.titleId,"aria-describedby":Y,unmount:g},H=!zO(),I=Ia.None;_&&!f&&(I|=Ia.RestoreFocus,I|=Ia.TabLock,u&&(I|=Ia.AutoFocus),H&&(I|=Ia.InitialFocus));let V=Mn();return Be.createElement(NO,null,Be.createElement(pk,{force:!0},Be.createElement(IS,null,Be.createElement(yv.Provider,{value:G},Be.createElement(PS,{target:x},Be.createElement(pk,{force:!1},Be.createElement(D,{slot:F},Be.createElement(M,null,Be.createElement(BO,{initialFocus:c,initialFocusFallback:x,containers:R,features:I},Be.createElement(m3,{value:S},V({ourProps:q,theirProps:y,slot:F,defaultTag:aM,features:iM,visible:k===0,name:"Dialog"})))))))))))}),aM="div",iM=pl.RenderStrategy|pl.Static;function lM(e,n){let{transition:s=!1,open:r,...o}=e,i=kd(),c=e.hasOwnProperty("open")||i!==null,d=e.hasOwnProperty("onClose");if(!c&&!d)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!c)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!d)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||s)&&!o.static?Be.createElement(gk,null,Be.createElement(tM,{show:r,transition:s,unmount:o.unmount},Be.createElement(xk,{ref:n,...o}))):Be.createElement(gk,null,Be.createElement(xk,{ref:n,open:r,...o}))}let cM="div";function dM(e,n){let s=p.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:o=!1,...i}=e,[{dialogState:c,unmount:d},u]=Km("Dialog.Panel"),f=Yn(n,u.panelRef),g=Js({open:c===0}),y=ut(j=>{j.stopPropagation()}),v={ref:f,id:r,onClick:y},h=o?bv:p.Fragment,x=o?{unmount:d}:{},b=Mn();return Be.createElement(h,{...x},b({ourProps:v,theirProps:i,slot:g,defaultTag:cM,name:"Dialog.Panel"}))}let uM="div";function fM(e,n){let{transition:s=!1,...r}=e,[{dialogState:o,unmount:i}]=Km("Dialog.Backdrop"),c=Js({open:o===0}),d={ref:n,"aria-hidden":!0},u=s?bv:p.Fragment,f=s?{unmount:i}:{},g=Mn();return Be.createElement(u,{...f},g({ourProps:d,theirProps:r,slot:c,defaultTag:uM,name:"Dialog.Backdrop"}))}let mM="h2";function hM(e,n){let s=p.useId(),{id:r=`headlessui-dialog-title-${s}`,...o}=e,[{dialogState:i,setTitleId:c}]=Km("Dialog.Title"),d=Yn(n);p.useEffect(()=>(c(r),()=>c(null)),[r,c]);let u=Js({open:i===0}),f={ref:d,id:r};return Mn()({ourProps:f,theirProps:o,slot:u,defaultTag:mM,name:"Dialog.Title"})}let pM=wn(lM),VS=wn(dM),gM=wn(fM),YS=wn(hM),xM=Object.assign(pM,{Panel:VS,Title:YS,Description:K1}),vk=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function bk(e){var n,s;let r=(n=e.innerText)!=null?n:"",o=e.cloneNode(!0);if(!Ts(o))return r;let i=!1;for(let d of o.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))d.remove(),i=!0;let c=i?(s=o.innerText)!=null?s:"":r;return vk.test(c)&&(c=c.replace(vk,"")),c}function vM(e){let n=e.getAttribute("aria-label");if(typeof n=="string")return n.trim();let s=e.getAttribute("aria-labelledby");if(s){let r=s.split(" ").map(o=>{let i=document.getElementById(o);if(i){let c=i.getAttribute("aria-label");return typeof c=="string"?c.trim():bk(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return bk(e).trim()}function bM(e){let n=p.useRef(""),s=p.useRef("");return ut(()=>{let r=e.current;if(!r)return"";let o=r.innerText;if(n.current===o)return s.current;let i=vM(r).trim().toLowerCase();return n.current=o,s.current=i,i})}var yM=Object.defineProperty,wM=(e,n,s)=>n in e?yM(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,yk=(e,n,s)=>(wM(e,typeof n!="symbol"?n+"":n,s),s),Kn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Kn||{}),Ho=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Ho||{}),Lf=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(Lf||{}),QS=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.SelectOption=5]="SelectOption",e[e.RegisterOptions=6]="RegisterOptions",e[e.UnregisterOptions=7]="UnregisterOptions",e[e.SetButtonElement=8]="SetButtonElement",e[e.SetOptionsElement=9]="SetOptionsElement",e[e.SortOptions=10]="SortOptions",e[e.MarkButtonAsMoved=11]="MarkButtonAsMoved",e))(QS||{});function wk(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=iS(n(e.options.slice()),i=>i.dataRef.current.domRef.current),o=s?r.indexOf(s):null;return o===-1&&(o=null),{options:r,activeOptionIndex:o}}let jM={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?Mf.Tracked(zS(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:dn.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:n}},0(e,n){if(e.dataRef.current.disabled||e.listboxState===0)return e;let s=e.activeOptionIndex,{isSelected:r}=e.dataRef.current,o=e.options.findIndex(i=>r(i.dataRef.current.value));return o!==-1&&(s=o),{...e,frozenValue:!1,pendingFocus:n.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:Mf.Idle}},2(e,n){var s,r,o,i,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let d={...e,searchQuery:"",activationTrigger:(s=n.trigger)!=null?s:1,__demoMode:!1};if(n.focus===dn.Nothing)return{...d,activeOptionIndex:null};if(n.focus===dn.Specific)return{...d,activeOptionIndex:e.options.findIndex(g=>g.id===n.id)};if(n.focus===dn.Previous){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,v=lf(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(v!==null){let h=e.options[v].dataRef.current.domRef;if(((r=y.current)==null?void 0:r.previousElementSibling)===h.current||((o=h.current)==null?void 0:o.previousElementSibling)===null)return{...d,activeOptionIndex:v}}}}else if(n.focus===dn.Next){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,v=lf(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(v!==null){let h=e.options[v].dataRef.current.domRef;if(((i=y.current)==null?void 0:i.nextElementSibling)===h.current||((c=h.current)==null?void 0:c.nextElementSibling)===null)return{...d,activeOptionIndex:v}}}}let u=wk(e),f=lf(n,{resolveItems:()=>u.options,resolveActiveIndex:()=>u.activeOptionIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});return{...d,...u,activeOptionIndex:f}},3:(e,n)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.searchQuery!==""?0:1,r=e.searchQuery+n.value.toLowerCase(),o=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+s).concat(e.options.slice(0,e.activeOptionIndex+s)):e.options).find(c=>{var d;return!c.dataRef.current.disabled&&((d=c.dataRef.current.textValue)==null?void 0:d.startsWith(r))}),i=o?e.options.indexOf(o):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:i,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,n)=>{let s=e.options.concat(n.options),r=e.activeOptionIndex;if(e.pendingFocus.focus!==dn.Nothing&&(r=lf(e.pendingFocus,{resolveItems:()=>s,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:o=>o.id,resolveDisabled:o=>o.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:o}=e.dataRef.current;if(o){let i=s.findIndex(c=>o==null?void 0:o(c.dataRef.current.value));i!==-1&&(r=i)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:dn.Nothing},pendingShouldSort:!0}},7:(e,n)=>{let s=e.options,r=[],o=new Set(n.options);for(let[i,c]of s.entries())if(o.has(c.id)&&(r.push(i),o.delete(c.id),o.size===0))break;if(r.length>0){s=s.slice();for(let i of r.reverse())s.splice(i,1)}return{...e,options:s,activationTrigger:1}},8:(e,n)=>e.buttonElement===n.element?e:{...e,buttonElement:n.element},9:(e,n)=>e.optionsElement===n.element?e:{...e,optionsElement:n.element},10:e=>e.pendingShouldSort?{...e,...wk(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:Mf.Moved}}};class wv extends Z1{constructor(n){super(n),yk(this,"actions",{onChange:s=>{let{onChange:r,compare:o,mode:i,value:c}=this.state.dataRef.current;return as(i,{0:()=>r==null?void 0:r(s),1:()=>{let d=c.slice(),u=d.findIndex(f=>o(f,s));return u===-1?d.push(s):d.splice(u,1),r==null?void 0:r(d)}})},registerOption:ag(()=>{let s=[],r=new Set;return[(o,i)=>{r.has(i)||(r.add(i),s.push({id:o,dataRef:i}))},()=>(r.clear(),this.send({type:6,options:s.splice(0)}))]}),unregisterOption:ag(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:ag(()=>{let s=null;return[(r,o)=>{s={type:2,...r,trigger:o}},()=>s&&this.send(s)]}),closeListbox:()=>{this.send({type:1})},openListbox:s=>{this.send({type:0,focus:s})},selectActiveOption:()=>{var s;if(this.state.activeOptionIndex!==null){let{dataRef:r}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(r.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(s=this.state.buttonElement)==null||s.focus({preventScroll:!0}))},selectOption:s=>{this.send({type:5,value:s})},search:s=>{this.send({type:3,value:s})},clearSearch:()=>{this.send({type:4})},setButtonElement:s=>{this.send({type:8,element:s})},setOptionsElement:s=>{this.send({type:9,element:s})}}),yk(this,"selectors",{activeDescendantId(s){var r;let o=s.activeOptionIndex,i=s.options;return o===null||(r=i[o])==null?void 0:r.id},isActive(s,r){var o;let i=s.activeOptionIndex,c=s.options;return i!==null?((o=c[i])==null?void 0:o.id)===r:!1},hasFrozenValue(s){return s.frozenValue},shouldScrollIntoView(s,r){return s.__demoMode||s.listboxState!==0||s.activationTrigger===0?!1:this.isActive(s,r)},didButtonMove(s){return s.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let s=this.state.id,r=Im.get(null);this.disposables.add(r.on(tS.Push,o=>{!r.selectors.isTop(o,s)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>r.actions.push(s)),this.on(1,()=>r.actions.pop(s))}this.disposables.group(s=>{this.on(1,r=>{r.buttonElement&&(s.dispose(),s.add(PO(r.buttonElement,r.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(s,r)=>{var o;this.actions.onChange(r.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(o=this.state.buttonElement)==null||o.focus({preventScroll:!0}))})}static new({id:n,__demoMode:s=!1}){return new wv({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:dn.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:Mf.Idle})}reduce(n,s){return as(s.type,jM,n,s)}}const JS=p.createContext(null);function jv(e){let n=p.useContext(JS);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,XS),s}return n}function XS({id:e,__demoMode:n=!1}){let s=p.useMemo(()=>wv.new({id:e,__demoMode:n}),[]);return xv(()=>s.dispose()),s}let Vm=p.createContext(null);Vm.displayName="ListboxDataContext";function Sd(e){let n=p.useContext(Vm);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Sd),s}return n}let kM=p.Fragment;function NM(e,n){let s=p.useId(),r=dv(),{value:o,defaultValue:i,form:c,name:d,onChange:u,by:f,invalid:g=!1,disabled:y=r||!1,horizontal:v=!1,multiple:h=!1,__demoMode:x=!1,...b}=e;const j=v?"horizontal":"vertical";let k=Yn(n),E=FA(i),[N=h?[]:void 0,S]=DA(o,u,E),$=XS({id:s,__demoMode:x}),_=p.useRef({static:!1,hold:!1}),O=p.useRef(new Map),M=p3(f),P=p.useCallback(V=>as(A.mode,{[Ho.Multi]:()=>N.some(J=>M(J,V)),[Ho.Single]:()=>M(N,V)}),[N]),A=Js({value:N,disabled:y,invalid:g,mode:h?Ho.Multi:Ho.Single,orientation:j,onChange:S,compare:M,isSelected:P,optionsPropsRef:_,listRef:O});rn(()=>{$.state.dataRef.current=A},[A]);let R=ts($,V=>V.listboxState),L=Im.get(null),W=ts(L,p.useCallback(V=>L.selectors.isTop(V,s),[L,s])),[U,Y]=ts($,V=>[V.buttonElement,V.optionsElement]);dS(W,[U,Y],(V,J)=>{$.send({type:QS.CloseListbox}),aS(J,uv.Loose)||(V.preventDefault(),U==null||U.focus())});let D=Js({open:R===Kn.Open,disabled:y,invalid:g,value:N}),[G,F]=i3({inherit:!0}),q={ref:k},H=p.useCallback(()=>{if(E!==void 0)return S==null?void 0:S(E)},[S,E]),I=Mn();return Be.createElement(F,{value:G,props:{htmlFor:U==null?void 0:U.id},slot:{open:R===Kn.Open,disabled:y}},Be.createElement(yO,null,Be.createElement(JS.Provider,{value:$},Be.createElement(Vm.Provider,{value:A},Be.createElement(AS,{value:as(R,{[Kn.Open]:ss.Open,[Kn.Closed]:ss.Closed})},d!=null&&N!=null&&Be.createElement(KA,{disabled:y,data:{[d]:N},form:c,onReset:H}),I({ourProps:q,theirProps:b,slot:D,defaultTag:kM,name:"Listbox"}))))))}let SM="button";function CM(e,n){let s=p.useId(),r=U1(),o=Sd("Listbox.Button"),i=jv("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:d=o.disabled||!1,autoFocus:u=!1,...f}=e,g=Yn(n,gO(),i.actions.setButtonElement),y=xO(),[v,h,x]=ts(i,Y=>[Y.listboxState,Y.buttonElement,Y.optionsElement]),b=v===Kn.Open;D3(b,{trigger:h,action:p.useCallback(Y=>{if(h!=null&&h.contains(Y.target))return of.Ignore;let D=Y.target.closest('[role="option"]:not([data-disabled])');return Ts(D)?of.Select(D):x!=null&&x.contains(Y.target)?of.Ignore:of.Close},[h,x]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=ut(Y=>{switch(Y.key){case Sn.Enter:UA(Y.currentTarget);break;case Sn.Space:case Sn.ArrowDown:Y.preventDefault(),i.actions.openListbox({focus:o.value?dn.Nothing:dn.First});break;case Sn.ArrowUp:Y.preventDefault(),i.actions.openListbox({focus:o.value?dn.Nothing:dn.Last});break}}),k=ut(Y=>{switch(Y.key){case Sn.Space:Y.preventDefault();break}}),E=x3(Y=>{var D;i.state.listboxState===Kn.Open?(_s.flushSync(()=>i.actions.closeListbox()),(D=i.state.buttonElement)==null||D.focus({preventScroll:!0})):(Y.preventDefault(),i.actions.openListbox({focus:dn.Nothing}))}),N=ut(Y=>Y.preventDefault()),S=Y1([c]),$=n3(),{isFocusVisible:_,focusProps:O}=kA({autoFocus:u}),{isHovered:M,hoverProps:P}=CA({isDisabled:d}),{pressed:A,pressProps:R}=AA({disabled:d}),L=Js({open:v===Kn.Open,active:A||v===Kn.Open,disabled:d,invalid:o.invalid,value:o.value,hover:M,focus:_,autofocus:u}),W=ts(i,Y=>Y.listboxState===Kn.Open),U=P1(y(),{ref:g,id:c,type:F3(e,h),"aria-haspopup":"listbox","aria-controls":x==null?void 0:x.id,"aria-expanded":W,"aria-labelledby":S,"aria-describedby":$,disabled:d||void 0,autoFocus:u,onKeyDown:j,onKeyUp:k,onKeyPress:N},E,O,P,R);return Mn()({ourProps:U,theirProps:f,slot:L,defaultTag:SM,name:"Listbox.Button"})}let ZS=p.createContext(!1),EM="div",$M=pl.RenderStrategy|pl.Static;function _M(e,n){let s=p.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:o,portal:i=!1,modal:c=!0,transition:d=!1,...u}=e,f=pO(o),[g,y]=p.useState(null);f&&(i=!0);let v=Sd("Listbox.Options"),h=jv("Listbox.Options"),[x,b,j,k]=ts(h,ae=>[ae.listboxState,ae.buttonElement,ae.optionsElement,ae.__demoMode]),E=td(b),N=td(j),S=kd(),[$,_]=hS(d,g,S!==null?(S&ss.Open)===ss.Open:x===Kn.Open);rS($,b,h.actions.closeListbox);let O=k?!1:c&&x===Kn.Open;fS(O,N);let M=k?!1:c&&x===Kn.Open;sS(M,{allowed:p.useCallback(()=>[b,j],[b,j])});let P=ts(h,h.selectors.didButtonMove)?!1:$,A=ts(h,h.selectors.hasFrozenValue)&&!e.static,R=RS(A,v.value),L=p.useCallback(ae=>v.compare(R,ae),[v.compare,R]),W=ts(h,ae=>{var ye;if(f==null||!((ye=f==null?void 0:f.to)!=null&&ye.includes("selection")))return null;let he=ae.options.findIndex(we=>L(we.dataRef.current.value));return he===-1&&(he=0),he}),U=(()=>{if(f==null)return;if(W===null)return{...f,inner:void 0};let ae=Array.from(v.listRef.current.values());return{...f,inner:{listRef:{current:ae},index:W}}})(),[Y,D]=bO(U),G=vO(),F=Yn(n,f?Y:null,h.actions.setOptionsElement,y),q=aa();p.useEffect(()=>{let ae=j;ae&&x===Kn.Open&&(M1(ae)||ae==null||ae.focus({preventScroll:!0}))},[x,j]);let H=ut(ae=>{var ye;switch(q.dispose(),ae.key){case Sn.Space:if(h.state.searchQuery!=="")return ae.preventDefault(),ae.stopPropagation(),h.actions.search(ae.key);case Sn.Enter:ae.preventDefault(),ae.stopPropagation(),h.actions.selectActiveOption();break;case as(v.orientation,{vertical:Sn.ArrowDown,horizontal:Sn.ArrowRight}):return ae.preventDefault(),ae.stopPropagation(),h.actions.goToOption({focus:dn.Next});case as(v.orientation,{vertical:Sn.ArrowUp,horizontal:Sn.ArrowLeft}):return ae.preventDefault(),ae.stopPropagation(),h.actions.goToOption({focus:dn.Previous});case Sn.Home:case Sn.PageUp:return ae.preventDefault(),ae.stopPropagation(),h.actions.goToOption({focus:dn.First});case Sn.End:case Sn.PageDown:return ae.preventDefault(),ae.stopPropagation(),h.actions.goToOption({focus:dn.Last});case Sn.Escape:ae.preventDefault(),ae.stopPropagation(),_s.flushSync(()=>h.actions.closeListbox()),(ye=h.state.buttonElement)==null||ye.focus({preventScroll:!0});return;case Sn.Tab:ae.preventDefault(),ae.stopPropagation(),_s.flushSync(()=>h.actions.closeListbox()),L3(h.state.buttonElement,ae.shiftKey?cr.Previous:cr.Next);break;default:ae.key.length===1&&(h.actions.search(ae.key),q.setTimeout(()=>h.actions.clearSearch(),350));break}}),I=ts(h,ae=>{var ye;return(ye=ae.buttonElement)==null?void 0:ye.id}),V=Js({open:x===Kn.Open}),J=P1(f?G():{},{id:r,ref:F,"aria-activedescendant":ts(h,h.selectors.activeDescendantId),"aria-multiselectable":v.mode===Ho.Multi?!0:void 0,"aria-labelledby":I,"aria-orientation":v.orientation,onKeyDown:H,role:"listbox",tabIndex:x===Kn.Open?0:void 0,style:{...u.style,...D,"--button-width":g3($,b,!0).width},...mS(_)}),X=Mn(),re=p.useMemo(()=>v.mode===Ho.Multi?v:{...v,isSelected:L},[v,L]);return Be.createElement(IS,{enabled:i?e.static||$:!1,ownerDocument:E},Be.createElement(Vm.Provider,{value:re},X({ourProps:J,theirProps:u,slot:V,defaultTag:EM,features:$M,visible:P,name:"Listbox.Options"})))}let TM="div";function RM(e,n){let s=p.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:o=!1,value:i,...c}=e,d=p.useContext(ZS)===!0,u=Sd("Listbox.Option"),f=jv("Listbox.Option"),g=ts(f,A=>f.selectors.isActive(A,r)),y=u.isSelected(i),v=p.useRef(null),h=bM(v),x=ia({disabled:o,value:i,domRef:v,get textValue(){return h()}}),b=Yn(n,v,A=>{A?u.listRef.current.set(r,A):u.listRef.current.delete(r)}),j=ts(f,A=>f.selectors.shouldScrollIntoView(A,r));rn(()=>{if(j)return Os().requestAnimationFrame(()=>{var A,R;(R=(A=v.current)==null?void 0:A.scrollIntoView)==null||R.call(A,{block:"nearest"})})},[j,v]),rn(()=>{if(!d)return f.actions.registerOption(r,x),()=>f.actions.unregisterOption(r)},[x,r,d]);let k=ut(A=>{if(o)return A.preventDefault();f.actions.selectOption(i)}),E=ut(()=>{if(o)return f.actions.goToOption({focus:dn.Nothing});f.actions.goToOption({focus:dn.Specific,id:r})}),N=K3(),S=ut(A=>N.update(A)),$=ut(A=>{N.wasMoved(A)&&(o||g&&f.state.activationTrigger===Lf.Pointer||f.actions.goToOption({focus:dn.Specific,id:r},Lf.Pointer))}),_=ut(A=>{N.wasMoved(A)&&(o||g&&f.state.activationTrigger===Lf.Pointer&&f.actions.goToOption({focus:dn.Nothing}))}),O=Js({active:g,focus:g,selected:y,disabled:o,selectedOption:y&&d}),M=d?{}:{id:r,ref:b,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":y,disabled:void 0,onClick:k,onFocus:E,onPointerEnter:S,onMouseEnter:S,onPointerMove:$,onMouseMove:$,onPointerLeave:_,onMouseLeave:_},P=Mn();return!y&&d?null:P({ourProps:M,theirProps:c,slot:O,defaultTag:TM,name:"Listbox.Option"})}let AM=p.Fragment;function OM(e,n){let{options:s,placeholder:r,...o}=e,i={ref:Yn(n)},c=Sd("ListboxSelectedOption"),d=Js({}),u=c.value===void 0||c.value===null||c.mode===Ho.Multi&&Array.isArray(c.value)&&c.value.length===0,f=Mn();return Be.createElement(ZS.Provider,{value:!0},f({ourProps:i,theirProps:{...o,children:Be.createElement(Be.Fragment,null,r&&u?r:s)},slot:d,defaultTag:AM,name:"ListboxSelectedOption"}))}let MM=wn(NM),e2=wn(CM),LM=u3,t2=wn(_M),n2=wn(RM),PM=wn(OM),IM=Object.assign(MM,{Button:e2,Label:LM,Options:t2,Option:n2,SelectedOption:PM});const zM={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function Ym({open:e,onClose:n,title:s,description:r,footer:o,size:i="md",initialFocus:c,hideClose:d,className:u,children:f}){return t.jsxs(xM,{open:e,onClose:n,initialFocus:c,className:"relative z-dialog",children:[t.jsx(gM,{className:"fixed inset-0 bg-overlay/70"}),t.jsx("div",{className:te("fixed inset-0 flex justify-center p-4 md:p-8",i==="full"?"items-stretch":"items-start overflow-y-auto pt-[12vh]"),children:t.jsxs(VS,{className:te("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",zM[i],u),children:[t.jsxs("header",{className:"flex items-start gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(YS,{className:"text-lg font-semibold",children:s}),r&&t.jsx(K1,{className:"mt-1 text-body text-muted-foreground",children:r})]}),!d&&t.jsx(B,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Close",children:t.jsx(uo,{"aria-hidden":!0})})]}),f&&t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:f}),o&&t.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:o})]})})]})}function kv({open:e,title:n,confirm:s,cancel:r="Cancel",tone:o="destructive",busy:i,onConfirm:c,onCancel:d,children:u}){const f=p.useRef(null);return t.jsx(Ym,{open:e,onClose:i?()=>{}:d,title:n,size:"sm",hideClose:!0,initialFocus:f,footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{ref:f,size:"sm",onClick:d,disabled:i,children:r}),t.jsx(B,{size:"sm",variant:o,onClick:c,disabled:i,"aria-busy":i||void 0,children:s})]}),children:u})}const Nv=p.createContext(null),DM=()=>p.useContext(Nv);function Sv(e){const n=p.useContext(Nv);return{id:e.id??(n==null?void 0:n.id),"aria-describedby":e["aria-describedby"]??(n==null?void 0:n.describedBy),"aria-invalid":e["aria-invalid"]??((n==null?void 0:n.invalid)||void 0),"aria-required":e["aria-required"]??((n==null?void 0:n.required)&&!e.required||void 0)}}function St({label:e,id:n,required:s,optional:r,note:o,hint:i,error:c,warning:d,aside:u,group:f,className:g,children:y}){const v=p.useId(),h=n??`${v}-control`,[x,b,j,k,E]=[`${v}-label`,`${v}-note`,`${v}-hint`,`${v}-error`,`${v}-warning`],N=[o&&b,i&&j,c&&k,d&&E].filter(Boolean).join(" ")||void 0,S=t.jsxs(t.Fragment,{children:[e,s&&t.jsx("span",{className:"text-destructive-text","aria-hidden":!0,children:" *"}),r&&t.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:" (optional)"})]});return t.jsxs("div",{className:g,...f===!0?{role:"group","aria-labelledby":x,"aria-describedby":N}:{},children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[f?t.jsx("span",{id:x,className:"caps text-small font-semibold",children:S}):t.jsx("label",{id:x,htmlFor:h,className:"caps text-small font-semibold",children:S}),u]}),o&&t.jsx("p",{id:b,className:"-mt-1 mb-2 text-small text-muted-foreground",children:o}),t.jsx(Nv.Provider,{value:f?null:{id:h,describedBy:N,invalid:!!c,required:!!s},children:y}),i&&t.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:i}),c&&t.jsx("p",{id:k,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{id:E,className:"mt-2 font-mono text-small text-warning-text",children:d})]})}const s2="w-full border border-input bg-background px-3 font-mono text-body placeholder:text-muted-foreground hover:border-foreground/60 focus-visible:outline-offset-0 read-only:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-45 aria-[invalid=true]:border-destructive",r2="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",Cd="xl:columns-2 xl:gap-x-10 2xl:columns-3 [&>*]:mb-5 [&>*]:mt-0 [&>*]:break-inside-avoid",Za="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",De=p.forwardRef(({className:e,fieldSize:n="md",bare:s,...r},o)=>t.jsx("input",{ref:o,...r,...Sv(r),className:te(s?r2:te(s2,n==="sm"?"h-control-sm":"h-control-md"),e)}));De.displayName="Input";const on=p.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...Sv(s),className:te(n?r2:te(s2,"py-2.5"),e)}));on.displayName="Textarea";const o2=e=>{const n=p.forwardRef(({label:s,note:r,className:o,disabled:i,...c},d)=>t.jsxs("label",{className:te("flex items-start gap-2.5 text-body",i?"cursor-not-allowed opacity-45":"cursor-pointer",o),children:[t.jsx("input",{ref:d,type:e,disabled:i,...c,...Sv(c),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block",children:s}),r&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:r})]})]}));return n.displayName=e==="checkbox"?"Checkbox":"Radio",n},FM=o2("checkbox");o2("radio");function $r({icon:e,active:n,className:s,children:r,...o}){return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,...o,className:te("flex min-h-11 items-center gap-2.5 p-3 text-left text-body -outline-offset-2 hover:bg-accent",n&&"!rounded-action bg-primary/[0.06] text-primary-text hover:bg-primary/10",s),children:[e&&t.jsx(e,{className:"size-4 shrink-0","aria-hidden":!0})," ",r]})}const a2=p.forwardRef(({describedBy:e,...n},s)=>t.jsx("button",{ref:s,...n,"aria-describedby":n["aria-describedby"]??e}));a2.displayName="PickerButton";function Mt({value:e,onChange:n,options:s,label:r,id:o,className:i,disabled:c=!1,name:d,small:u=!1,placeholder:f,autoFocus:g,steady:y=!1}){const v=s.find(x=>x.value===e),h=DM();return t.jsxs(IM,{value:e,onChange:n,disabled:c,name:d,children:[t.jsxs(e2,{as:a2,id:o??(h==null?void 0:h.id),autoFocus:g,"aria-label":r,describedBy:h==null?void 0:h.describedBy,"aria-invalid":(h==null?void 0:h.invalid)||void 0,"data-value":e,className:te("flex min-w-0 items-center justify-between gap-2 border border-input bg-background text-left font-mono hover:border-foreground/60 focus-visible:outline-offset-0 disabled:opacity-60 data-[open]:border-foreground",u?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",i),children:[y?t.jsxs("span",{className:"grid min-w-0",children:[s.map(x=>t.jsx("span",{"data-picker-sizer":"","aria-hidden":!0,className:"invisible col-start-1 row-start-1 h-0 min-w-0 truncate",children:x.label},x.value)),t.jsx("span",{className:te("col-start-1 row-start-1 min-w-0 truncate",!v&&"text-muted-foreground"),children:(v==null?void 0:v.label)??f??""})]}):t.jsx("span",{className:te("min-w-0 truncate",!v&&"text-muted-foreground"),children:(v==null?void 0:v.label)??f??""}),t.jsx(ri,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(t2,{anchor:"bottom start","data-picker-list":"",className:te("z-popover max-h-72 overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",y?"w-max min-w-[max(12rem,var(--button-width))] max-w-[calc(100vw-1rem)]":"w-[var(--button-width)] min-w-[12rem]"),children:s.map(x=>t.jsxs(n2,{value:x.value,disabled:x.disabled,title:x.title,"data-value":x.value,className:"group flex min-h-10 cursor-pointer items-center gap-2 px-3 py-2 data-[disabled]:cursor-not-allowed data-[focus]:bg-accent data-[disabled]:opacity-50 data-[selected]:text-foreground",children:[t.jsx(Cl,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 break-words",children:x.label}),x.tag&&t.jsx(Ne,{tone:"success",className:"ml-auto",children:x.tag})]},x.value))})]})}function Qo({value:e,onChange:n,options:s,label:r,name:o,size:i="md",className:c}){return t.jsx("div",{role:"radiogroup","aria-label":r,className:te("inline-flex",c),children:s.map(d=>t.jsxs("label",{title:d.title,className:te("caps -ml-px inline-flex items-center justify-center gap-1.5 border first:ml-0 has-[:focus-visible]:relative has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring [&_svg]:size-3.5",i==="sm"?"h-control-sm px-2.5 text-label":"h-control-md px-3 text-small",d.disabled?"cursor-not-allowed opacity-45":"cursor-pointer",e===d.value?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[t.jsx("input",{type:"radio",name:o,value:d.value,checked:e===d.value,disabled:d.disabled,onChange:()=>n(d.value),className:"sr-only"}),d.label]},d.value))})}const UM=["appearance-none bg-transparent","[&::-webkit-slider-runnable-track]:h-0.5 [&::-webkit-slider-runnable-track]:bg-border-strong","[&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-3 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:bg-foreground","[&::-moz-range-track]:h-0.5 [&::-moz-range-track]:bg-border-strong","[&::-moz-range-thumb]:size-3 [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-foreground"].join(" ");function WM({value:e,onChange:n,min:s,max:r,label:o,valueText:i,className:c,disabled:d=!1}){return t.jsx("input",{type:"range",min:s,max:r,step:1,value:e,disabled:d,"aria-label":o,"aria-valuetext":i,onChange:u=>n(Number(u.target.value)),className:te(UM,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function Cv({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(ZT,{className:te("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function Ed({checked:e,onChange:n,disabled:s,label:r,labelledBy:o,busy:i,className:c}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":r,"aria-labelledby":o,"aria-busy":i||void 0,disabled:s||i,onClick:()=>n(!e),className:te("relative inline-flex h-5 w-9 shrink-0 items-center border transition-colors disabled:cursor-not-allowed disabled:opacity-45",e?"border-primary bg-primary/20":"border-border-strong bg-background hover:border-foreground/60",i&&"motion-safe:animate-pulse",c),children:t.jsx("span",{"aria-hidden":!0,className:te("absolute top-1/2 size-3 -translate-y-1/2 transition-[left,background-color] duration-fast",e?"left-[calc(100%-16px)] bg-primary":"left-[3px] bg-muted-foreground")})})}const i2="flex shrink-0 gap-x-4 overflow-x-auto border-b px-5 md:px-8",l2=e=>te("caps whitespace-nowrap border-b-2 px-1 py-3 text-small -outline-offset-2 first:-ml-1 max-sm:py-2.5",e?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground");function Ev({tabs:e,value:n,onChange:s,label:r,id:o,className:i}){var f;const c=e.some(g=>g.id===n)?n:(f=e[0])==null?void 0:f.id,d=p.useRef(null),u=g=>{var h,x;const y=e.findIndex(b=>b.id===n),v=g.key==="ArrowRight"?(y+1)%e.length:g.key==="ArrowLeft"?(y-1+e.length)%e.length:g.key==="Home"?0:g.key==="End"?e.length-1:-1;v<0||v===y||(g.preventDefault(),s(e[v].id),(x=(h=d.current)==null?void 0:h.querySelectorAll('[role="tab"]')[v])==null||x.focus())};return t.jsx("div",{ref:d,role:"tablist","aria-label":r,onKeyDown:u,className:te(i2,i),children:e.map(g=>t.jsx("button",{type:"button",role:"tab",id:o&&`${o}-tab-${g.id}`,"aria-controls":o&&`${o}-panel-${g.id}`,"aria-selected":n===g.id,tabIndex:c===g.id?0:-1,onClick:()=>s(g.id),className:l2(n===g.id),children:g.label},g.id))})}const c2=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`}),vr="flex min-h-12 shrink-0 items-center border-b py-1.5",Jo="caps flex items-center gap-2 text-body font-semibold",d2=p.createContext(null),HM={neutral:[qg,"text-muted-foreground"],success:[t1,"text-success-text"],warning:[Ys,"text-warning-text"],error:[ul,"text-destructive-text"]},BM=5e3;function qM(){return p.useContext(d2)??GM}const GM=()=>{};function KM({toast:e,done:n}){const s=p.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",o=e.duration??(r==="error"?0:BM),[i,c]=p.useState(!1),[d,u]=p.useState(!1),f=i||d;p.useEffect(()=>{if(!o||f)return;const v=setTimeout(s,o);return()=>clearTimeout(v)},[o,f,s]);const[g,y]=HM[r];return t.jsxs("div",{role:r==="error"?"alert":"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),className:"pointer-events-auto flex w-full items-start gap-3 border border-border-strong bg-card p-3 text-body text-card-foreground shadow-float motion-safe:animate-toast-in",children:[t.jsx(g,{className:te("mt-0.5 size-4 shrink-0",y),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-semibold",children:e.title}),e.description&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),t.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:t.jsx(uo,{className:"size-3.5","aria-hidden":!0})})]})}function VM({children:e}){const[n,s]=p.useState([]),r=p.useRef(0),o=p.useCallback(c=>s(d=>[...d,{...c,id:r.current++}].slice(-3)),[]),i=p.useCallback(c=>s(d=>d.filter(u=>u.id!==c)),[]);return t.jsxs(d2.Provider,{value:o,children:[e,t.jsx("div",{role:"region","aria-label":"Notifications","aria-live":"polite",className:"pointer-events-none fixed inset-x-4 bottom-4 z-toast flex flex-col gap-2 sm:left-auto sm:w-[22rem]",children:n.map(c=>t.jsx(KM,{toast:c,done:i},c.id))})]})}/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:u2,setPrototypeOf:jk,isFrozen:YM,getPrototypeOf:QM,getOwnPropertyDescriptor:JM}=Object;let{freeze:is,seal:Xs,create:f2}=Object,{apply:ax,construct:ix}=typeof Reflect<"u"&&Reflect;is||(is=function(n){return n});Xs||(Xs=function(n){return n});ax||(ax=function(n,s,r){return n.apply(s,r)});ix||(ix=function(n,s){return new n(...s)});const cf=Rs(Array.prototype.forEach),kk=Rs(Array.prototype.pop),yc=Rs(Array.prototype.push),Pf=Rs(String.prototype.toLowerCase),pg=Rs(String.prototype.toString),Nk=Rs(String.prototype.match),wc=Rs(String.prototype.replace),XM=Rs(String.prototype.indexOf),ZM=Rs(String.prototype.trim),lr=Rs(Object.prototype.hasOwnProperty),Zn=Rs(RegExp.prototype.test),jc=e5(TypeError);function Rs(e){return function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return ax(e,n,r)}}function e5(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return ix(e,s)}}function kt(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Pf;jk&&jk(e,null);let r=n.length;for(;r--;){let o=n[r];if(typeof o=="string"){const i=s(o);i!==o&&(YM(n)||(n[r]=i),o=i)}e[o]=!0}return e}function t5(e){for(let n=0;n<e.length;n++)lr(e,n)||(e[n]=null);return e}function Pa(e){const n=f2(null);for(const[s,r]of u2(e))lr(e,s)&&(Array.isArray(r)?n[s]=t5(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=Pa(r):n[s]=r);return n}function kc(e,n){for(;e!==null;){const r=JM(e,n);if(r){if(r.get)return Rs(r.get);if(typeof r.value=="function")return Rs(r.value)}e=QM(e)}function s(){return null}return s}const Sk=is(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gg=is(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),xg=is(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),n5=is(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),vg=is(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),s5=is(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ck=is(["#text"]),Ek=is(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),bg=is(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),$k=is(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),df=is(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),r5=Xs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),o5=Xs(/<%[\w\W]*|[\w\W]*%>/gm),a5=Xs(/\$\{[\w\W]*}/gm),i5=Xs(/^data-[\-\w.\u00B7-\uFFFF]+$/),l5=Xs(/^aria-[\-\w]+$/),m2=Xs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),c5=Xs(/^(?:\w+script|data):/i),d5=Xs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),h2=Xs(/^html$/i),u5=Xs(/^[a-z][.\w]*(-[.\w]+)+$/i);var _k=Object.freeze({__proto__:null,ARIA_ATTR:l5,ATTR_WHITESPACE:d5,CUSTOM_ELEMENT:u5,DATA_ATTR:i5,DOCTYPE_NAME:h2,ERB_EXPR:o5,IS_ALLOWED_URI:m2,IS_SCRIPT_OR_DATA:c5,MUSTACHE_EXPR:r5,TMPLIT_EXPR:a5});const Nc={element:1,text:3,progressingInstruction:7,comment:8,document:9},f5=function(){return typeof window>"u"?null:window},m5=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";s&&s.hasAttribute(o)&&(r=s.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return n.createPolicy(i,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Tk=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function p2(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:f5();const n=Ze=>p2(Ze);if(n.version="3.2.3",n.removed=[],!e||!e.document||e.document.nodeType!==Nc.document)return n.isSupported=!1,n;let{document:s}=e;const r=s,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:c,Node:d,Element:u,NodeFilter:f,NamedNodeMap:g=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:y,DOMParser:v,trustedTypes:h}=e,x=u.prototype,b=kc(x,"cloneNode"),j=kc(x,"remove"),k=kc(x,"nextSibling"),E=kc(x,"childNodes"),N=kc(x,"parentNode");if(typeof c=="function"){const Ze=s.createElement("template");Ze.content&&Ze.content.ownerDocument&&(s=Ze.content.ownerDocument)}let S,$="";const{implementation:_,createNodeIterator:O,createDocumentFragment:M,getElementsByTagName:P}=s,{importNode:A}=r;let R=Tk();n.isSupported=typeof u2=="function"&&typeof N=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:L,ERB_EXPR:W,TMPLIT_EXPR:U,DATA_ATTR:Y,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:F,CUSTOM_ELEMENT:q}=_k;let{IS_ALLOWED_URI:H}=_k,I=null;const V=kt({},[...Sk,...gg,...xg,...vg,...Ck]);let J=null;const X=kt({},[...Ek,...bg,...$k,...df]);let re=Object.seal(f2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ae=null,ye=null,he=!0,we=!0,ze=!1,le=!0,me=!1,Ke=!0,be=!1,ge=!1,Je=!1,tt=!1,ft=!1,ve=!1,Ee=!0,Q=!1;const Me="user-content-";let pe=!0,ne=!1,Ae={},Pe=null;const bt=kt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ot=null;const mt=kt({},["audio","video","img","source","image","track"]);let Re=null;const lt=kt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),$t="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml";let st=fe,Qe=!1,ct=null;const gt=kt({},[$t,nt,fe],pg);let Et=kt({},["mi","mo","mn","ms","mtext"]),se=kt({},["annotation-xml"]);const $e=kt({},["title","style","font","a","script"]);let Fe=null;const et=["application/xhtml+xml","text/html"],Dt="text/html";let Le=null,rt=null;const Ft=s.createElement("form"),jn=function(ie){return ie instanceof RegExp||ie instanceof Function},Rt=function(){let ie=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rt&&rt===ie)){if((!ie||typeof ie!="object")&&(ie={}),ie=Pa(ie),Fe=et.indexOf(ie.PARSER_MEDIA_TYPE)===-1?Dt:ie.PARSER_MEDIA_TYPE,Le=Fe==="application/xhtml+xml"?pg:Pf,I=lr(ie,"ALLOWED_TAGS")?kt({},ie.ALLOWED_TAGS,Le):V,J=lr(ie,"ALLOWED_ATTR")?kt({},ie.ALLOWED_ATTR,Le):X,ct=lr(ie,"ALLOWED_NAMESPACES")?kt({},ie.ALLOWED_NAMESPACES,pg):gt,Re=lr(ie,"ADD_URI_SAFE_ATTR")?kt(Pa(lt),ie.ADD_URI_SAFE_ATTR,Le):lt,ot=lr(ie,"ADD_DATA_URI_TAGS")?kt(Pa(mt),ie.ADD_DATA_URI_TAGS,Le):mt,Pe=lr(ie,"FORBID_CONTENTS")?kt({},ie.FORBID_CONTENTS,Le):bt,ae=lr(ie,"FORBID_TAGS")?kt({},ie.FORBID_TAGS,Le):{},ye=lr(ie,"FORBID_ATTR")?kt({},ie.FORBID_ATTR,Le):{},Ae=lr(ie,"USE_PROFILES")?ie.USE_PROFILES:!1,he=ie.ALLOW_ARIA_ATTR!==!1,we=ie.ALLOW_DATA_ATTR!==!1,ze=ie.ALLOW_UNKNOWN_PROTOCOLS||!1,le=ie.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=ie.SAFE_FOR_TEMPLATES||!1,Ke=ie.SAFE_FOR_XML!==!1,be=ie.WHOLE_DOCUMENT||!1,tt=ie.RETURN_DOM||!1,ft=ie.RETURN_DOM_FRAGMENT||!1,ve=ie.RETURN_TRUSTED_TYPE||!1,Je=ie.FORCE_BODY||!1,Ee=ie.SANITIZE_DOM!==!1,Q=ie.SANITIZE_NAMED_PROPS||!1,pe=ie.KEEP_CONTENT!==!1,ne=ie.IN_PLACE||!1,H=ie.ALLOWED_URI_REGEXP||m2,st=ie.NAMESPACE||fe,Et=ie.MATHML_TEXT_INTEGRATION_POINTS||Et,se=ie.HTML_INTEGRATION_POINTS||se,re=ie.CUSTOM_ELEMENT_HANDLING||{},ie.CUSTOM_ELEMENT_HANDLING&&jn(ie.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(re.tagNameCheck=ie.CUSTOM_ELEMENT_HANDLING.tagNameCheck),ie.CUSTOM_ELEMENT_HANDLING&&jn(ie.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(re.attributeNameCheck=ie.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),ie.CUSTOM_ELEMENT_HANDLING&&typeof ie.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(re.allowCustomizedBuiltInElements=ie.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),me&&(we=!1),ft&&(tt=!0),Ae&&(I=kt({},Ck),J=[],Ae.html===!0&&(kt(I,Sk),kt(J,Ek)),Ae.svg===!0&&(kt(I,gg),kt(J,bg),kt(J,df)),Ae.svgFilters===!0&&(kt(I,xg),kt(J,bg),kt(J,df)),Ae.mathMl===!0&&(kt(I,vg),kt(J,$k),kt(J,df))),ie.ADD_TAGS&&(I===V&&(I=Pa(I)),kt(I,ie.ADD_TAGS,Le)),ie.ADD_ATTR&&(J===X&&(J=Pa(J)),kt(J,ie.ADD_ATTR,Le)),ie.ADD_URI_SAFE_ATTR&&kt(Re,ie.ADD_URI_SAFE_ATTR,Le),ie.FORBID_CONTENTS&&(Pe===bt&&(Pe=Pa(Pe)),kt(Pe,ie.FORBID_CONTENTS,Le)),pe&&(I["#text"]=!0),be&&kt(I,["html","head","body"]),I.table&&(kt(I,["tbody"]),delete ae.tbody),ie.TRUSTED_TYPES_POLICY){if(typeof ie.TRUSTED_TYPES_POLICY.createHTML!="function")throw jc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof ie.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw jc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=ie.TRUSTED_TYPES_POLICY,$=S.createHTML("")}else S===void 0&&(S=m5(h,o)),S!==null&&typeof $=="string"&&($=S.createHTML(""));is&&is(ie),rt=ie}},Un=kt({},[...gg,...xg,...n5]),ys=kt({},[...vg,...s5]),ws=function(ie){let _e=N(ie);(!_e||!_e.tagName)&&(_e={namespaceURI:st,tagName:"template"});const qe=Pf(ie.tagName),Lt=Pf(_e.tagName);return ct[ie.namespaceURI]?ie.namespaceURI===nt?_e.namespaceURI===fe?qe==="svg":_e.namespaceURI===$t?qe==="svg"&&(Lt==="annotation-xml"||Et[Lt]):!!Un[qe]:ie.namespaceURI===$t?_e.namespaceURI===fe?qe==="math":_e.namespaceURI===nt?qe==="math"&&se[Lt]:!!ys[qe]:ie.namespaceURI===fe?_e.namespaceURI===nt&&!se[Lt]||_e.namespaceURI===$t&&!Et[Lt]?!1:!ys[qe]&&($e[qe]||!Un[qe]):!!(Fe==="application/xhtml+xml"&&ct[ie.namespaceURI]):!1},Z=function(ie){yc(n.removed,{element:ie});try{N(ie).removeChild(ie)}catch{j(ie)}},Ie=function(ie,_e){try{yc(n.removed,{attribute:_e.getAttributeNode(ie),from:_e})}catch{yc(n.removed,{attribute:null,from:_e})}if(_e.removeAttribute(ie),ie==="is")if(tt||ft)try{Z(_e)}catch{}else try{_e.setAttribute(ie,"")}catch{}},ht=function(ie){let _e=null,qe=null;if(Je)ie="<remove></remove>"+ie;else{const pt=Nk(ie,/^[\r\n\t ]+/);qe=pt&&pt[0]}Fe==="application/xhtml+xml"&&st===fe&&(ie='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+ie+"</body></html>");const Lt=S?S.createHTML(ie):ie;if(st===fe)try{_e=new v().parseFromString(Lt,Fe)}catch{}if(!_e||!_e.documentElement){_e=_.createDocument(st,"template",null);try{_e.documentElement.innerHTML=Qe?$:Lt}catch{}}const Bt=_e.body||_e.documentElement;return ie&&qe&&Bt.insertBefore(s.createTextNode(qe),Bt.childNodes[0]||null),st===fe?P.call(_e,be?"html":"body")[0]:be?_e.documentElement:Bt},Ct=function(ie){return O.call(ie.ownerDocument||ie,ie,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},Ht=function(ie){return ie instanceof y&&(typeof ie.nodeName!="string"||typeof ie.textContent!="string"||typeof ie.removeChild!="function"||!(ie.attributes instanceof g)||typeof ie.removeAttribute!="function"||typeof ie.setAttribute!="function"||typeof ie.namespaceURI!="string"||typeof ie.insertBefore!="function"||typeof ie.hasChildNodes!="function")},xn=function(ie){return typeof d=="function"&&ie instanceof d};function tn(Ze,ie,_e){cf(Ze,qe=>{qe.call(n,ie,_e,rt)})}const vn=function(ie){let _e=null;if(tn(R.beforeSanitizeElements,ie,null),Ht(ie))return Z(ie),!0;const qe=Le(ie.nodeName);if(tn(R.uponSanitizeElement,ie,{tagName:qe,allowedTags:I}),ie.hasChildNodes()&&!xn(ie.firstElementChild)&&Zn(/<[/\w]/g,ie.innerHTML)&&Zn(/<[/\w]/g,ie.textContent)||ie.nodeType===Nc.progressingInstruction||Ke&&ie.nodeType===Nc.comment&&Zn(/<[/\w]/g,ie.data))return Z(ie),!0;if(!I[qe]||ae[qe]){if(!ae[qe]&&yr(qe)&&(re.tagNameCheck instanceof RegExp&&Zn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe)))return!1;if(pe&&!Pe[qe]){const Lt=N(ie)||ie.parentNode,Bt=E(ie)||ie.childNodes;if(Bt&&Lt){const pt=Bt.length;for(let En=pt-1;En>=0;--En){const Ln=b(Bt[En],!0);Ln.__removalCount=(ie.__removalCount||0)+1,Lt.insertBefore(Ln,k(ie))}}}return Z(ie),!0}return ie instanceof u&&!ws(ie)||(qe==="noscript"||qe==="noembed"||qe==="noframes")&&Zn(/<\/no(script|embed|frames)/i,ie.innerHTML)?(Z(ie),!0):(me&&ie.nodeType===Nc.text&&(_e=ie.textContent,cf([L,W,U],Lt=>{_e=wc(_e,Lt," ")}),ie.textContent!==_e&&(yc(n.removed,{element:ie.cloneNode()}),ie.textContent=_e)),tn(R.afterSanitizeElements,ie,null),!1)},ls=function(ie,_e,qe){if(Ee&&(_e==="id"||_e==="name")&&(qe in s||qe in Ft))return!1;if(!(we&&!ye[_e]&&Zn(Y,_e))){if(!(he&&Zn(D,_e))){if(!J[_e]||ye[_e]){if(!(yr(ie)&&(re.tagNameCheck instanceof RegExp&&Zn(re.tagNameCheck,ie)||re.tagNameCheck instanceof Function&&re.tagNameCheck(ie))&&(re.attributeNameCheck instanceof RegExp&&Zn(re.attributeNameCheck,_e)||re.attributeNameCheck instanceof Function&&re.attributeNameCheck(_e))||_e==="is"&&re.allowCustomizedBuiltInElements&&(re.tagNameCheck instanceof RegExp&&Zn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe))))return!1}else if(!Re[_e]){if(!Zn(H,wc(qe,F,""))){if(!((_e==="src"||_e==="xlink:href"||_e==="href")&&ie!=="script"&&XM(qe,"data:")===0&&ot[ie])){if(!(ze&&!Zn(G,wc(qe,F,"")))){if(qe)return!1}}}}}}return!0},yr=function(ie){return ie!=="annotation-xml"&&Nk(ie,q)},wr=function(ie){tn(R.beforeSanitizeAttributes,ie,null);const{attributes:_e}=ie;if(!_e||Ht(ie))return;const qe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0};let Lt=_e.length;for(;Lt--;){const Bt=_e[Lt],{name:pt,namespaceURI:En,value:Ln}=Bt,jr=Le(pt);let Kt=pt==="value"?Ln:ZM(Ln);if(qe.attrName=jr,qe.attrValue=Kt,qe.keepAttr=!0,qe.forceKeepAttr=void 0,tn(R.uponSanitizeAttribute,ie,qe),Kt=qe.attrValue,Q&&(jr==="id"||jr==="name")&&(Ie(pt,ie),Kt=Me+Kt),Ke&&Zn(/((--!?|])>)|<\/(style|title)/i,Kt)){Ie(pt,ie);continue}if(qe.forceKeepAttr||(Ie(pt,ie),!qe.keepAttr))continue;if(!le&&Zn(/\/>/i,Kt)){Ie(pt,ie);continue}me&&cf([L,W,U],mo=>{Kt=wc(Kt,mo," ")});const hi=Le(ie.nodeName);if(ls(hi,jr,Kt)){if(S&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!En)switch(h.getAttributeType(hi,jr)){case"TrustedHTML":{Kt=S.createHTML(Kt);break}case"TrustedScriptURL":{Kt=S.createScriptURL(Kt);break}}try{En?ie.setAttributeNS(En,pt,Kt):ie.setAttribute(pt,Kt),Ht(ie)?Z(ie):kk(n.removed)}catch{}}}tn(R.afterSanitizeAttributes,ie,null)},Ur=function Ze(ie){let _e=null;const qe=Ct(ie);for(tn(R.beforeSanitizeShadowDOM,ie,null);_e=qe.nextNode();)tn(R.uponSanitizeShadowNode,_e,null),vn(_e),wr(_e),_e.content instanceof i&&Ze(_e.content);tn(R.afterSanitizeShadowDOM,ie,null)};return n.sanitize=function(Ze){let ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_e=null,qe=null,Lt=null,Bt=null;if(Qe=!Ze,Qe&&(Ze="<!-->"),typeof Ze!="string"&&!xn(Ze))if(typeof Ze.toString=="function"){if(Ze=Ze.toString(),typeof Ze!="string")throw jc("dirty is not a string, aborting")}else throw jc("toString is not a function");if(!n.isSupported)return Ze;if(ge||Rt(ie),n.removed=[],typeof Ze=="string"&&(ne=!1),ne){if(Ze.nodeName){const Ln=Le(Ze.nodeName);if(!I[Ln]||ae[Ln])throw jc("root node is forbidden and cannot be sanitized in-place")}}else if(Ze instanceof d)_e=ht("<!---->"),qe=_e.ownerDocument.importNode(Ze,!0),qe.nodeType===Nc.element&&qe.nodeName==="BODY"||qe.nodeName==="HTML"?_e=qe:_e.appendChild(qe);else{if(!tt&&!me&&!be&&Ze.indexOf("<")===-1)return S&&ve?S.createHTML(Ze):Ze;if(_e=ht(Ze),!_e)return tt?null:ve?$:""}_e&&Je&&Z(_e.firstChild);const pt=Ct(ne?Ze:_e);for(;Lt=pt.nextNode();)vn(Lt),wr(Lt),Lt.content instanceof i&&Ur(Lt.content);if(ne)return Ze;if(tt){if(ft)for(Bt=M.call(_e.ownerDocument);_e.firstChild;)Bt.appendChild(_e.firstChild);else Bt=_e;return(J.shadowroot||J.shadowrootmode)&&(Bt=A.call(r,Bt,!0)),Bt}let En=be?_e.outerHTML:_e.innerHTML;return be&&I["!doctype"]&&_e.ownerDocument&&_e.ownerDocument.doctype&&_e.ownerDocument.doctype.name&&Zn(h2,_e.ownerDocument.doctype.name)&&(En="<!DOCTYPE "+_e.ownerDocument.doctype.name+`>
528
+ `+En),me&&cf([L,W,U],Ln=>{En=wc(En,Ln," ")}),S&&ve?S.createHTML(En):En},n.setConfig=function(){let Ze=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Rt(Ze),ge=!0},n.clearConfig=function(){rt=null,ge=!1},n.isValidAttribute=function(Ze,ie,_e){rt||Rt({});const qe=Le(Ze),Lt=Le(ie);return ls(qe,Lt,_e)},n.addHook=function(Ze,ie){typeof ie=="function"&&yc(R[Ze],ie)},n.removeHook=function(Ze){return kk(R[Ze])},n.removeHooks=function(Ze){R[Ze]=[]},n.removeAllHooks=function(){R=Tk()},n}var If=p2();function $v(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let di=$v();function g2(e){di=e}const Bc={exec:()=>null};function Wt(e,n=""){let s=typeof e=="string"?e:e.source;const r={replace:(o,i)=>{let c=typeof i=="string"?i:i.source;return c=c.replace(rs.caret,"$1"),s=s.replace(o,c),r},getRegex:()=>new RegExp(s,n)};return r}const rs={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},h5=/^(?:[ \t]*(?:\n|$))+/,p5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,g5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,$d=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,x5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,x2=/(?:[*+-]|\d{1,9}[.)])/,v2=Wt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,x2).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),_v=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,v5=/^[^\n]+/,Tv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,b5=Wt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Tv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),y5=Wt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,x2).getRegex(),Qm="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Rv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,w5=Wt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Rv).replace("tag",Qm).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),b2=Wt(_v).replace("hr",$d).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qm).getRegex(),j5=Wt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",b2).getRegex(),Av={blockquote:j5,code:p5,def:b5,fences:g5,heading:x5,hr:$d,html:w5,lheading:v2,list:y5,newline:h5,paragraph:b2,table:Bc,text:v5},Rk=Wt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",$d).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qm).getRegex(),k5={...Av,table:Rk,paragraph:Wt(_v).replace("hr",$d).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Rk).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qm).getRegex()},N5={...Av,html:Wt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Rv).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Bc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Wt(_v).replace("hr",$d).replace("heading",` *#{1,6} *[^
529
+ ]`).replace("lheading",v2).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},S5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,C5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,y2=/^( {2,}|\\)\n(?!\s*$)/,E5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jm=/[\p{P}\p{S}]/u,Ov=/[\s\p{P}\p{S}]/u,w2=/[^\s\p{P}\p{S}]/u,$5=Wt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ov).getRegex(),j2=/(?!~)[\p{P}\p{S}]/u,_5=/(?!~)[\s\p{P}\p{S}]/u,T5=/(?:[^\s\p{P}\p{S}]|~)/u,R5=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,k2=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,A5=Wt(k2,"u").replace(/punct/g,Jm).getRegex(),O5=Wt(k2,"u").replace(/punct/g,j2).getRegex(),N2="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",M5=Wt(N2,"gu").replace(/notPunctSpace/g,w2).replace(/punctSpace/g,Ov).replace(/punct/g,Jm).getRegex(),L5=Wt(N2,"gu").replace(/notPunctSpace/g,T5).replace(/punctSpace/g,_5).replace(/punct/g,j2).getRegex(),P5=Wt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,w2).replace(/punctSpace/g,Ov).replace(/punct/g,Jm).getRegex(),I5=Wt(/\\(punct)/,"gu").replace(/punct/g,Jm).getRegex(),z5=Wt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),D5=Wt(Rv).replace("(?:-->|$)","-->").getRegex(),F5=Wt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",D5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qf=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,U5=Wt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Qf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),S2=Wt(/^!?\[(label)\]\[(ref)\]/).replace("label",Qf).replace("ref",Tv).getRegex(),C2=Wt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Tv).getRegex(),W5=Wt("reflink|nolink(?!\\()","g").replace("reflink",S2).replace("nolink",C2).getRegex(),Mv={_backpedal:Bc,anyPunctuation:I5,autolink:z5,blockSkip:R5,br:y2,code:C5,del:Bc,emStrongLDelim:A5,emStrongRDelimAst:M5,emStrongRDelimUnd:P5,escape:S5,link:U5,nolink:C2,punctuation:$5,reflink:S2,reflinkSearch:W5,tag:F5,text:E5,url:Bc},H5={...Mv,link:Wt(/^!?\[(label)\]\((.*?)\)/).replace("label",Qf).getRegex(),reflink:Wt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qf).getRegex()},lx={...Mv,emStrongRDelimAst:L5,emStrongLDelim:O5,url:Wt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},B5={...lx,br:Wt(y2).replace("{2,}","*").getRegex(),text:Wt(lx.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},uf={normal:Av,gfm:k5,pedantic:N5},Sc={normal:Mv,gfm:lx,breaks:B5,pedantic:H5},q5={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ak=e=>q5[e];function Ar(e,n){if(n){if(rs.escapeTest.test(e))return e.replace(rs.escapeReplace,Ak)}else if(rs.escapeTestNoEncode.test(e))return e.replace(rs.escapeReplaceNoEncode,Ak);return e}function Ok(e){try{e=encodeURI(e).replace(rs.percentDecode,"%")}catch{return null}return e}function Mk(e,n){var i;const s=e.replace(rs.findPipe,(c,d,u)=>{let f=!1,g=d;for(;--g>=0&&u[g]==="\\";)f=!f;return f?"|":" |"}),r=s.split(rs.splitPipe);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(rs.slashPipe,"|");return r}function Cc(e,n,s){const r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===n;)o++;return e.slice(0,r-o)}function G5(e,n){if(e.indexOf(n[1])===-1)return-1;let s=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===n[0])s++;else if(e[r]===n[1]&&(s--,s<0))return r;return-1}function Lk(e,n,s,r,o){const i=n.href,c=n.title||null,d=e[1].replace(o.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const u={type:"link",raw:s,href:i,title:c,text:d,tokens:r.inlineTokens(d)};return r.state.inLink=!1,u}return{type:"image",raw:s,href:i,title:c,text:d}}function K5(e,n,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return n;const o=r[1];return n.split(`
530
+ `).map(i=>{const c=i.match(s.other.beginningSpace);if(c===null)return i;const[d]=c;return d.length>=o.length?i.slice(o.length):i}).join(`
531
+ `)}class Jf{constructor(n){Pt(this,"options");Pt(this,"rules");Pt(this,"lexer");this.options=n||di}space(n){const s=this.rules.block.newline.exec(n);if(s&&s[0].length>0)return{type:"space",raw:s[0]}}code(n){const s=this.rules.block.code.exec(n);if(s){const r=s[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Cc(r,`
532
+ `)}}}fences(n){const s=this.rules.block.fences.exec(n);if(s){const r=s[0],o=K5(r,s[3]||"",this.rules);return{type:"code",raw:r,lang:s[2]?s[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):s[2],text:o}}}heading(n){const s=this.rules.block.heading.exec(n);if(s){let r=s[2].trim();if(this.rules.other.endingHash.test(r)){const o=Cc(r,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(r=o.trim())}return{type:"heading",raw:s[0],depth:s[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(n){const s=this.rules.block.hr.exec(n);if(s)return{type:"hr",raw:Cc(s[0],`
533
+ `)}}blockquote(n){const s=this.rules.block.blockquote.exec(n);if(s){let r=Cc(s[0],`
534
+ `).split(`
535
+ `),o="",i="";const c=[];for(;r.length>0;){let d=!1;const u=[];let f;for(f=0;f<r.length;f++)if(this.rules.other.blockquoteStart.test(r[f]))u.push(r[f]),d=!0;else if(!d)u.push(r[f]);else break;r=r.slice(f);const g=u.join(`
536
+ `),y=g.replace(this.rules.other.blockquoteSetextReplace,`
537
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
538
+ ${g}`:g,i=i?`${i}
539
+ ${y}`:y;const v=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(y,c,!0),this.lexer.state.top=v,r.length===0)break;const h=c.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){const x=h,b=x.raw+`
540
+ `+r.join(`
541
+ `),j=this.blockquote(b);c[c.length-1]=j,o=o.substring(0,o.length-x.raw.length)+j.raw,i=i.substring(0,i.length-x.text.length)+j.text;break}else if((h==null?void 0:h.type)==="list"){const x=h,b=x.raw+`
542
+ `+r.join(`
543
+ `),j=this.list(b);c[c.length-1]=j,o=o.substring(0,o.length-h.raw.length)+j.raw,i=i.substring(0,i.length-x.raw.length)+j.raw,r=b.substring(c.at(-1).raw.length).split(`
544
+ `);continue}}return{type:"blockquote",raw:o,tokens:c,text:i}}}list(n){let s=this.rules.block.list.exec(n);if(s){let r=s[1].trim();const o=r.length>1,i={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=o?r:"[*+-]");const c=this.rules.other.listItemRegex(r);let d=!1;for(;n;){let f=!1,g="",y="";if(!(s=c.exec(n))||this.rules.block.hr.test(n))break;g=s[0],n=n.substring(g.length);let v=s[2].split(`
545
+ `,1)[0].replace(this.rules.other.listReplaceTabs,E=>" ".repeat(3*E.length)),h=n.split(`
546
+ `,1)[0],x=!v.trim(),b=0;if(this.options.pedantic?(b=2,y=v.trimStart()):x?b=s[1].length+1:(b=s[2].search(this.rules.other.nonSpaceChar),b=b>4?1:b,y=v.slice(b),b+=s[1].length),x&&this.rules.other.blankLine.test(h)&&(g+=h+`
547
+ `,n=n.substring(h.length+1),f=!0),!f){const E=this.rules.other.nextBulletRegex(b),N=this.rules.other.hrRegex(b),S=this.rules.other.fencesBeginRegex(b),$=this.rules.other.headingBeginRegex(b),_=this.rules.other.htmlBeginRegex(b);for(;n;){const O=n.split(`
548
+ `,1)[0];let M;if(h=O,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),M=h):M=h.replace(this.rules.other.tabCharGlobal," "),S.test(h)||$.test(h)||_.test(h)||E.test(h)||N.test(h))break;if(M.search(this.rules.other.nonSpaceChar)>=b||!h.trim())y+=`
549
+ `+M.slice(b);else{if(x||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(v)||$.test(v)||N.test(v))break;y+=`
550
+ `+h}!x&&!h.trim()&&(x=!0),g+=O+`
551
+ `,n=n.substring(O.length+1),v=M.slice(b)}}i.loose||(d?i.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(d=!0));let j=null,k;this.options.gfm&&(j=this.rules.other.listIsTask.exec(y),j&&(k=j[0]!=="[ ] ",y=y.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:g,task:!!j,checked:k,loose:!1,text:y,tokens:[]}),i.raw+=g}const u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let f=0;f<i.items.length;f++)if(this.lexer.state.top=!1,i.items[f].tokens=this.lexer.blockTokens(i.items[f].text,[]),!i.loose){const g=i.items[f].tokens.filter(v=>v.type==="space"),y=g.length>0&&g.some(v=>this.rules.other.anyLine.test(v.raw));i.loose=y}if(i.loose)for(let f=0;f<i.items.length;f++)i.items[f].loose=!0;return i}}html(n){const s=this.rules.block.html.exec(n);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(n){const s=this.rules.block.def.exec(n);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=s[2]?s[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=s[3]?s[3].substring(1,s[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):s[3];return{type:"def",tag:r,raw:s[0],href:o,title:i}}}table(n){var d;const s=this.rules.block.table.exec(n);if(!s||!this.rules.other.tableDelimiter.test(s[2]))return;const r=Mk(s[1]),o=s[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(d=s[3])!=null&&d.trim()?s[3].replace(this.rules.other.tableRowBlankLine,"").split(`
552
+ `):[],c={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===o.length){for(const u of o)this.rules.other.tableAlignRight.test(u)?c.align.push("right"):this.rules.other.tableAlignCenter.test(u)?c.align.push("center"):this.rules.other.tableAlignLeft.test(u)?c.align.push("left"):c.align.push(null);for(let u=0;u<r.length;u++)c.header.push({text:r[u],tokens:this.lexer.inline(r[u]),header:!0,align:c.align[u]});for(const u of i)c.rows.push(Mk(u,c.header.length).map((f,g)=>({text:f,tokens:this.lexer.inline(f),header:!1,align:c.align[g]})));return c}}lheading(n){const s=this.rules.block.lheading.exec(n);if(s)return{type:"heading",raw:s[0],depth:s[2].charAt(0)==="="?1:2,text:s[1],tokens:this.lexer.inline(s[1])}}paragraph(n){const s=this.rules.block.paragraph.exec(n);if(s){const r=s[1].charAt(s[1].length-1)===`
553
+ `?s[1].slice(0,-1):s[1];return{type:"paragraph",raw:s[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const s=this.rules.block.text.exec(n);if(s)return{type:"text",raw:s[0],text:s[0],tokens:this.lexer.inline(s[0])}}escape(n){const s=this.rules.inline.escape.exec(n);if(s)return{type:"escape",raw:s[0],text:s[1]}}tag(n){const s=this.rules.inline.tag.exec(n);if(s)return!this.lexer.state.inLink&&this.rules.other.startATag.test(s[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(s[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(s[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(s[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:s[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:s[0]}}link(n){const s=this.rules.inline.link.exec(n);if(s){const r=s[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const c=Cc(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=G5(s[2],"()");if(c>-1){const u=(s[0].indexOf("!")===0?5:4)+s[1].length+c;s[2]=s[2].substring(0,c),s[0]=s[0].substring(0,u).trim(),s[3]=""}}let o=s[2],i="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(o);c&&(o=c[1],i=c[3])}else i=s[3]?s[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?o=o.slice(1):o=o.slice(1,-1)),Lk(s,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},s[0],this.lexer,this.rules)}}reflink(n,s){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const o=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=s[o.toLowerCase()];if(!i){const c=r[0].charAt(0);return{type:"text",raw:c,text:c}}return Lk(r,i,r[0],this.lexer,this.rules)}}emStrong(n,s,r=""){let o=this.rules.inline.emStrongLDelim.exec(n);if(!o||o[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(o[1]||o[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const c=[...o[0]].length-1;let d,u,f=c,g=0;const y=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(y.lastIndex=0,s=s.slice(-1*n.length+c);(o=y.exec(s))!=null;){if(d=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!d)continue;if(u=[...d].length,o[3]||o[4]){f+=u;continue}else if((o[5]||o[6])&&c%3&&!((c+u)%3)){g+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+g);const v=[...o[0]][0].length,h=n.slice(0,c+o.index+v+u);if(Math.min(c,u)%2){const b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}const x=h.slice(2,-2);return{type:"strong",raw:h,text:x,tokens:this.lexer.inlineTokens(x)}}}}codespan(n){const s=this.rules.inline.code.exec(n);if(s){let r=s[2].replace(this.rules.other.newLineCharGlobal," ");const o=this.rules.other.nonSpaceChar.test(r),i=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return o&&i&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:s[0],text:r}}}br(n){const s=this.rules.inline.br.exec(n);if(s)return{type:"br",raw:s[0]}}del(n){const s=this.rules.inline.del.exec(n);if(s)return{type:"del",raw:s[0],text:s[2],tokens:this.lexer.inlineTokens(s[2])}}autolink(n){const s=this.rules.inline.autolink.exec(n);if(s){let r,o;return s[2]==="@"?(r=s[1],o="mailto:"+r):(r=s[1],o=r),{type:"link",raw:s[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}url(n){var r;let s;if(s=this.rules.inline.url.exec(n)){let o,i;if(s[2]==="@")o=s[0],i="mailto:"+o;else{let c;do c=s[0],s[0]=((r=this.rules.inline._backpedal.exec(s[0]))==null?void 0:r[0])??"";while(c!==s[0]);o=s[0],s[1]==="www."?i="http://"+s[0]:i=s[0]}return{type:"link",raw:s[0],text:o,href:i,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(n){const s=this.rules.inline.text.exec(n);if(s){const r=this.lexer.state.inRawBlock;return{type:"text",raw:s[0],text:s[0],escaped:r}}}}class Hs{constructor(n){Pt(this,"tokens");Pt(this,"options");Pt(this,"state");Pt(this,"tokenizer");Pt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||di,this.options.tokenizer=this.options.tokenizer||new Jf,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const s={other:rs,block:uf.normal,inline:Sc.normal};this.options.pedantic?(s.block=uf.pedantic,s.inline=Sc.pedantic):this.options.gfm&&(s.block=uf.gfm,this.options.breaks?s.inline=Sc.breaks:s.inline=Sc.gfm),this.tokenizer.rules=s}static get rules(){return{block:uf,inline:Sc}}static lex(n,s){return new Hs(s).lex(n)}static lexInline(n,s){return new Hs(s).inlineTokens(n)}lex(n){n=n.replace(rs.carriageReturn,`
554
+ `),this.blockTokens(n,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){const r=this.inlineQueue[s];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(n,s=[],r=!1){var o,i,c;for(this.options.pedantic&&(n=n.replace(rs.tabCharGlobal," ").replace(rs.spaceLine,""));n;){let d;if((i=(o=this.options.extensions)==null?void 0:o.block)!=null&&i.some(f=>(d=f.call({lexer:this},n,s))?(n=n.substring(d.raw.length),s.push(d),!0):!1))continue;if(d=this.tokenizer.space(n)){n=n.substring(d.raw.length);const f=s.at(-1);d.raw.length===1&&f!==void 0?f.raw+=`
555
+ `:s.push(d);continue}if(d=this.tokenizer.code(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=`
556
+ `+d.raw,f.text+=`
557
+ `+d.text,this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(d=this.tokenizer.fences(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.heading(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.hr(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.blockquote(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.list(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.html(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.def(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=`
558
+ `+d.raw,f.text+=`
559
+ `+d.raw,this.inlineQueue.at(-1).src=f.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title});continue}if(d=this.tokenizer.table(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.lheading(n)){n=n.substring(d.raw.length),s.push(d);continue}let u=n;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0;const g=n.slice(1);let y;this.options.extensions.startBlock.forEach(v=>{y=v.call({lexer:this},g),typeof y=="number"&&y>=0&&(f=Math.min(f,y))}),f<1/0&&f>=0&&(u=n.substring(0,f+1))}if(this.state.top&&(d=this.tokenizer.paragraph(u))){const f=s.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=`
560
+ `+d.raw,f.text+=`
561
+ `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d),r=u.length!==n.length,n=n.substring(d.raw.length);continue}if(d=this.tokenizer.text(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=`
562
+ `+d.raw,f.text+=`
563
+ `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(n){const f="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return this.state.top=!0,s}inline(n,s=[]){return this.inlineQueue.push({src:n,tokens:s}),s}inlineTokens(n,s=[]){var d,u,f;let r=n,o=null;if(this.tokens.links){const g=Object.keys(this.tokens.links);if(g.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,o.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i=!1,c="";for(;n;){i||(c=""),i=!1;let g;if((u=(d=this.options.extensions)==null?void 0:d.inline)!=null&&u.some(v=>(g=v.call({lexer:this},n,s))?(n=n.substring(g.raw.length),s.push(g),!0):!1))continue;if(g=this.tokenizer.escape(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.tag(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.link(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.reflink(n,this.tokens.links)){n=n.substring(g.raw.length);const v=s.at(-1);g.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=g.raw,v.text+=g.text):s.push(g);continue}if(g=this.tokenizer.emStrong(n,r,c)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.codespan(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.br(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.del(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.autolink(n)){n=n.substring(g.raw.length),s.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(n))){n=n.substring(g.raw.length),s.push(g);continue}let y=n;if((f=this.options.extensions)!=null&&f.startInline){let v=1/0;const h=n.slice(1);let x;this.options.extensions.startInline.forEach(b=>{x=b.call({lexer:this},h),typeof x=="number"&&x>=0&&(v=Math.min(v,x))}),v<1/0&&v>=0&&(y=n.substring(0,v+1))}if(g=this.tokenizer.inlineText(y)){n=n.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),i=!0;const v=s.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=g.raw,v.text+=g.text):s.push(g);continue}if(n){const v="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return s}}class Xf{constructor(n){Pt(this,"options");Pt(this,"parser");this.options=n||di}space(n){return""}code({text:n,lang:s,escaped:r}){var c;const o=(c=(s||"").match(rs.notSpaceStart))==null?void 0:c[0],i=n.replace(rs.endingNewline,"")+`
564
+ `;return o?'<pre><code class="language-'+Ar(o)+'">'+(r?i:Ar(i,!0))+`</code></pre>
565
+ `:"<pre><code>"+(r?i:Ar(i,!0))+`</code></pre>
566
+ `}blockquote({tokens:n}){return`<blockquote>
567
+ ${this.parser.parse(n)}</blockquote>
568
+ `}html({text:n}){return n}heading({tokens:n,depth:s}){return`<h${s}>${this.parser.parseInline(n)}</h${s}>
569
+ `}hr(n){return`<hr>
570
+ `}list(n){const s=n.ordered,r=n.start;let o="";for(let d=0;d<n.items.length;d++){const u=n.items[d];o+=this.listitem(u)}const i=s?"ol":"ul",c=s&&r!==1?' start="'+r+'"':"";return"<"+i+c+`>
571
+ `+o+"</"+i+`>
572
+ `}listitem(n){var r;let s="";if(n.task){const o=this.checkbox({checked:!!n.checked});n.loose?((r=n.tokens[0])==null?void 0:r.type)==="paragraph"?(n.tokens[0].text=o+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=o+" "+Ar(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:o+" ",text:o+" ",escaped:!0}):s+=o+" "}return s+=this.parser.parse(n.tokens,!!n.loose),`<li>${s}</li>
573
+ `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
574
+ `}table(n){let s="",r="";for(let i=0;i<n.header.length;i++)r+=this.tablecell(n.header[i]);s+=this.tablerow({text:r});let o="";for(let i=0;i<n.rows.length;i++){const c=n.rows[i];r="";for(let d=0;d<c.length;d++)r+=this.tablecell(c[d]);o+=this.tablerow({text:r})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
575
+ <thead>
576
+ `+s+`</thead>
577
+ `+o+`</table>
578
+ `}tablerow({text:n}){return`<tr>
579
+ ${n}</tr>
580
+ `}tablecell(n){const s=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+s+`</${r}>
581
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${Ar(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:s,tokens:r}){const o=this.parser.parseInline(r),i=Ok(n);if(i===null)return o;n=i;let c='<a href="'+n+'"';return s&&(c+=' title="'+Ar(s)+'"'),c+=">"+o+"</a>",c}image({href:n,title:s,text:r}){const o=Ok(n);if(o===null)return Ar(r);n=o;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${Ar(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Ar(n.text)}}class Lv{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}}class Bs{constructor(n){Pt(this,"options");Pt(this,"renderer");Pt(this,"textRenderer");this.options=n||di,this.options.renderer=this.options.renderer||new Xf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Lv}static parse(n,s){return new Bs(s).parse(n)}static parseInline(n,s){return new Bs(s).parseInline(n)}parse(n,s=!0){var o,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[d.type]){const f=d,g=this.options.extensions.renderers[f.type].call({parser:this},f);if(g!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type)){r+=g||"";continue}}const u=d;switch(u.type){case"space":{r+=this.renderer.space(u);continue}case"hr":{r+=this.renderer.hr(u);continue}case"heading":{r+=this.renderer.heading(u);continue}case"code":{r+=this.renderer.code(u);continue}case"table":{r+=this.renderer.table(u);continue}case"blockquote":{r+=this.renderer.blockquote(u);continue}case"list":{r+=this.renderer.list(u);continue}case"html":{r+=this.renderer.html(u);continue}case"paragraph":{r+=this.renderer.paragraph(u);continue}case"text":{let f=u,g=this.renderer.text(f);for(;c+1<n.length&&n[c+1].type==="text";)f=n[++c],g+=`
582
+ `+this.renderer.text(f);s?r+=this.renderer.paragraph({type:"paragraph",raw:g,text:g,tokens:[{type:"text",raw:g,text:g,escaped:!0}]}):r+=g;continue}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}parseInline(n,s=this.renderer){var o,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[d.type]){const f=this.options.extensions.renderers[d.type].call({parser:this},d);if(f!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(d.type)){r+=f||"";continue}}const u=d;switch(u.type){case"escape":{r+=s.text(u);break}case"html":{r+=s.html(u);break}case"link":{r+=s.link(u);break}case"image":{r+=s.image(u);break}case"strong":{r+=s.strong(u);break}case"em":{r+=s.em(u);break}case"codespan":{r+=s.codespan(u);break}case"br":{r+=s.br(u);break}case"del":{r+=s.del(u);break}case"text":{r+=s.text(u);break}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}}class qc{constructor(n){Pt(this,"options");Pt(this,"block");this.options=n||di}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Hs.lex:Hs.lexInline}provideParser(){return this.block?Bs.parse:Bs.parseInline}}Pt(qc,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class V5{constructor(...n){Pt(this,"defaults",$v());Pt(this,"options",this.setOptions);Pt(this,"parse",this.parseMarkdown(!0));Pt(this,"parseInline",this.parseMarkdown(!1));Pt(this,"Parser",Bs);Pt(this,"Renderer",Xf);Pt(this,"TextRenderer",Lv);Pt(this,"Lexer",Hs);Pt(this,"Tokenizer",Jf);Pt(this,"Hooks",qc);this.use(...n)}walkTokens(n,s){var o,i;let r=[];for(const c of n)switch(r=r.concat(s.call(this,c)),c.type){case"table":{const d=c;for(const u of d.header)r=r.concat(this.walkTokens(u.tokens,s));for(const u of d.rows)for(const f of u)r=r.concat(this.walkTokens(f.tokens,s));break}case"list":{const d=c;r=r.concat(this.walkTokens(d.items,s));break}default:{const d=c;(i=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&i[d.type]?this.defaults.extensions.childTokens[d.type].forEach(u=>{const f=d[u].flat(1/0);r=r.concat(this.walkTokens(f,s))}):d.tokens&&(r=r.concat(this.walkTokens(d.tokens,s)))}}return r}use(...n){const s=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{const o={...r};if(o.async=this.defaults.async||o.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const c=s.renderers[i.name];c?s.renderers[i.name]=function(...d){let u=i.renderer.apply(this,d);return u===!1&&(u=c.apply(this,d)),u}:s.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const c=s[i.level];c?c.unshift(i.tokenizer):s[i.level]=[i.tokenizer],i.start&&(i.level==="block"?s.startBlock?s.startBlock.push(i.start):s.startBlock=[i.start]:i.level==="inline"&&(s.startInline?s.startInline.push(i.start):s.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(s.childTokens[i.name]=i.childTokens)}),o.extensions=s),r.renderer){const i=this.defaults.renderer||new Xf(this.defaults);for(const c in r.renderer){if(!(c in i))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const d=c,u=r.renderer[d],f=i[d];i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y||""}}o.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new Jf(this.defaults);for(const c in r.tokenizer){if(!(c in i))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const d=c,u=r.tokenizer[d],f=i[d];i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y}}o.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new qc;for(const c in r.hooks){if(!(c in i))throw new Error(`hook '${c}' does not exist`);if(["options","block"].includes(c))continue;const d=c,u=r.hooks[d],f=i[d];qc.passThroughHooks.has(c)?i[d]=g=>{if(this.defaults.async)return Promise.resolve(u.call(i,g)).then(v=>f.call(i,v));const y=u.call(i,g);return f.call(i,y)}:i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y}}o.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,c=r.walkTokens;o.walkTokens=function(d){let u=[];return u.push(c.call(this,d)),i&&(u=u.concat(i.call(this,d))),u}}this.defaults={...this.defaults,...o}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,s){return Hs.lex(n,s??this.defaults)}parser(n,s){return Bs.parse(n,s??this.defaults)}parseMarkdown(n){return(r,o)=>{const i={...o},c={...this.defaults,...i},d=this.onError(!!c.silent,!!c.async);if(this.defaults.async===!0&&i.async===!1)return d(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return d(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return d(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));c.hooks&&(c.hooks.options=c,c.hooks.block=n);const u=c.hooks?c.hooks.provideLexer():n?Hs.lex:Hs.lexInline,f=c.hooks?c.hooks.provideParser():n?Bs.parse:Bs.parseInline;if(c.async)return Promise.resolve(c.hooks?c.hooks.preprocess(r):r).then(g=>u(g,c)).then(g=>c.hooks?c.hooks.processAllTokens(g):g).then(g=>c.walkTokens?Promise.all(this.walkTokens(g,c.walkTokens)).then(()=>g):g).then(g=>f(g,c)).then(g=>c.hooks?c.hooks.postprocess(g):g).catch(d);try{c.hooks&&(r=c.hooks.preprocess(r));let g=u(r,c);c.hooks&&(g=c.hooks.processAllTokens(g)),c.walkTokens&&this.walkTokens(g,c.walkTokens);let y=f(g,c);return c.hooks&&(y=c.hooks.postprocess(y)),y}catch(g){return d(g)}}}onError(n,s){return r=>{if(r.message+=`
583
+ Please report this to https://github.com/markedjs/marked.`,n){const o="<p>An error occurred:</p><pre>"+Ar(r.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(r);throw r}}}const ei=new V5;function zt(e,n){return ei.parse(e,n)}zt.options=zt.setOptions=function(e){return ei.setOptions(e),zt.defaults=ei.defaults,g2(zt.defaults),zt};zt.getDefaults=$v;zt.defaults=di;zt.use=function(...e){return ei.use(...e),zt.defaults=ei.defaults,g2(zt.defaults),zt};zt.walkTokens=function(e,n){return ei.walkTokens(e,n)};zt.parseInline=ei.parseInline;zt.Parser=Bs;zt.parser=Bs.parse;zt.Renderer=Xf;zt.TextRenderer=Lv;zt.Lexer=Hs;zt.lexer=Hs.lex;zt.Tokenizer=Jf;zt.Hooks=qc;zt.parse=zt;zt.options;zt.setOptions;zt.use;zt.walkTokens;zt.parseInline;Bs.parse;Hs.lex;const Y5="https://chatgpt.com/#settings",cx="chatgpt",od=e=>!!e&&e.startsWith(`${cx}/`)&&e.length>cx.length+1,E2="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",Q5="Signing in on this computer finishes by itself. On a server elsewhere, the tab ends on a page that won't load: copy that tab's whole address and paste it here.",J5="This sign-in is yours: don't let other people run agents on this server with it.",X5="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",Z5="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",eL="Your ChatGPT sign-in expired. Sign in again.",$2="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",tL=`Counts dollars. ${$2}`,nL=new Set(["signed_out","pending","signed_in","expired"]),Zf=e=>e&&typeof e=="object"&&nL.has(String(e.state))?e:null,sL=e=>e.charAt(0).toUpperCase()+e.slice(1),rL=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${sL(e.plan)})`:""}`,Pk="Use Claude Code's login on this machine",oL="Claude Agent runs on your Claude plan through the Claude Code CLI on this server's machine. The CLI keeps the login and calls Anthropic itself; AgentRun only asks it whether it is signed in.",aL="Only I run agents on this server",iL="Runs here would use your Claude plan, which is yours alone.",Ik={agentrun:"A login of AgentRun's own (sign in once for it)",machine:"This machine's Claude Code login (~/.claude)"},lL="Not signed in. Run this in a terminal on the server's machine; the CLI opens a browser there:",cL="No Claude Code CLI here yet: the first Claude Agent run installs it. Or run this with a claude CLI of your own:",dL="The Claude Code CLI didn't say whether it is signed in. Sign in again with:",uL="Turned on for another machine: Claude Agent runs here use the model keys.",fL="Requests on your Claude plan through Claude Code's login cost no dollars here; your plan's own limits apply.",mL=new Set(["off","other_machine","signed_in","signed_out","no_cli","unknown"]),zk=e=>e&&typeof e=="object"&&mL.has(String(e.state))?e:null;function hL(e){var s,r;const n=(s=e.account)!=null&&s.plan?` (${e.account.plan.charAt(0).toUpperCase()}${e.account.plan.slice(1)})`:"";return`Signed in as ${((r=e.account)==null?void 0:r.email)??"your Claude account"}${n}`}const pL="Claude Max, Ultra and Team plans include monthly API credits: a key from the Claude Console organization linked to the plan runs Claude Agent on them, AgentRun Cloud included. Pro, Free and Enterprise plans don't.";let Ec;const gL=e=>(Ec||(If.addHook("uponSanitizeElement",(n,s)=>{Ec??(Ec=s.allowedTags)}),If.sanitize("<b></b>"),If.removeHook("uponSanitizeElement")),(Ec==null?void 0:Ec[e.toLowerCase()])===!0),xL=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");zt.use({breaks:!0,renderer:{html:({text:e,block:n})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(o,i)=>gL(i)?(s++,o):xL(o));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
584
+ `)}</p>
585
+ `:r}}});const ca=e=>e.slice(-8),ti=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),vt=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function gr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const Pv=e=>e.basis==="estimate",_d=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,em=e=>{if(e>0&&e<1e-4)return"<$0.0001";if(e>=1)return`$${e.toFixed(2)}`;const[n,s=""]=e.toFixed(4).split(".");return`$${n}.${s.replace(/0+$/,"").padEnd(2,"0")}`},ui=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,Dk=(e,{ended:n=!1}={})=>`The charges priced${n?"":" so far"}. ${e.unpriced} ${e.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,vL=new Set(["completed","failed","cancelled"]),lo=e=>typeof e=="string"&&vL.has(e),bL="$0 · free model",_2=e=>e.usd===0&&e.free===!0,T2=e=>e.upper_bound===!0?"at most ":"",yL=(e,{ended:n=!1}={})=>e.usd!==null?`${T2(e)}${_d(e.usd)}`:typeof e.so_far_usd=="number"?n?`${em(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${em(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function Go(e,{ended:n=!1}={}){const s=xl(e),r=(s==null?void 0:s.on)==="claude_code";if(s&&(e==null?void 0:e.usd)===0)return`${fr(s.tokens)} tokens · ${r?"On your Claude plan":"Using ChatGPT plan"}`;const o=wL(e,n);return s?`${o} + ${r?"your Claude plan":"ChatGPT plan"}`:o}function wL(e,n){const s=ui(e),r=o=>Pv(o)?" est.":"";return s?n?`${em(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${em(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":_2(e)?bL:`${T2(e)}${_d(e.usd)}${r(e)}`}const xl=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0,jL=e=>e.on==="claude_code"?fL:$2;function fr(e){if(e<1e4)return e.toLocaleString("en-US");const[n,s]=e<1e6?[e/1e3,"K"]:e<1e9?[e/1e6,"M"]:[e/1e9,"B"];return`${n<100?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}${s}`}function Fk(e,n,{ended:s=!1,text:r}={}){const o=r??Go(e,{ended:s});return typeof n!="number"?o:(r!==void 0?kL.test(r):!ui(e)&&!xl(e)&&!!e&&e.usd!==null&&!_2(e))?`${o} of ${Uk(n)}`:`${o} · cap ${Uk(n)}`}const kL=/^<?\$[\d.,]+( est\.)?$/;function Uk(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function NL(e,n){if(e.startsWith("/")||e.startsWith("#"))return null;const s=n.from?`${n.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const r=decodeURIComponent(new URL(e,`file:///${s}`).pathname.slice(1));return n.paths.includes(r)?r:null}catch{return null}}function Ko(e,n){const s=If.sanitize(zt.parse(e,{async:!1}),{RETURN_DOM:!0});for(const r of[...s.querySelectorAll("pre")])r.classList.add("whitespace-pre-wrap","break-words","[overflow-wrap:anywhere]");for(const r of[...s.querySelectorAll("a[href]")]){const o=r.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(o)){r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(o))continue;const i=n&&NL(o,n);if(i){const c=r.ownerDocument.createElement("button");c.type="button",c.title=`Open ${i}`,c.dataset.runFile=i,c.append(...r.childNodes),r.replaceWith(c)}else r.replaceWith(...r.childNodes)}return s.innerHTML}const Iv=e=>n=>{var r,o,i;const s=(i=(o=(r=n.target).closest)==null?void 0:o.call(r,"[data-run-file]"))==null?void 0:i.getAttribute("data-run-file");s&&(n.preventDefault(),e(s))},SL=e=>{const n=s=>{var r;return(r=new RegExp(`\\b${s}="([^"]*)"`).exec(e))==null?void 0:r[1]};return n("scheme")==="github"||n("source")==="github"?"A GitHub event":n("source")==="webhook"?"A webhook request":"A trigger's request"};function On(e){const{title:n}=e;if(!e.trigger)return n;let s=n.search(/<trigger-payload\b/);if(s<0){const o=/<([a-z-]*)…$/.exec(n);if(!o||!"trigger-payload".startsWith(o[1]))return n;s=o.index}return n.slice(0,s).trim()||SL(n.slice(s))}function CL(e,n){if(n.unchanged&&!n.reset&&!n.drop.length&&!n.rows.length)return e;const s=new Map;if(!n.reset)for(const r of e)s.set(r.id,r);for(const r of n.drop)s.delete(r);for(const r of n.rows)s.set(r.id,r);return[...s.values()].sort((r,o)=>r.seq-o.seq)}const R2=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,A2=e=>e.refused===!0,O2=e=>e.tool_status==="failed"&&!A2(e)||e.kind==="error",EL=e=>e.paused===!0;function $L(e){const n=new Map(e.filter(f=>f.kind==="tool_result"&&f.tool_use_id).map(f=>[f.tool_use_id,f])),s=new Set(e.filter(f=>f.kind==="tool_use"&&f.tool_use_id).map(f=>f.tool_use_id)),r=new Set(e.filter(f=>f.kind==="waiting"&&f.id.endsWith(":waiting")).map(f=>f.id.slice(0,-8))),o=f=>{var g;return r.has(f.id)||(f.tool_use_id?r.has(((g=n.get(f.tool_use_id))==null?void 0:g.id)??""):!1)},i=e.findLast(f=>f.kind==="usage"),c=[],d=new Map;let u;for(const f of e){if(f.kind==="usage")continue;if(f.tool_name==="ask_person"&&(f.kind==="tool_use"||f.kind==="tool_result")&&o(f)){u=void 0;continue}if(f.kind==="tool_result"&&f.tool_use_id&&s.has(f.tool_use_id)){u=d.get(f.tool_use_id);continue}if(f.kind==="phase"&&f.path&&u&&(u.row.kind==="tool_result"||u.row.kind==="tool_use")&&!u.saved){u.saved=f.path;continue}const g=c.at(-1);if(f.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===f.summary&&g.row.text===f.text&&(g.row.agent_label??null)===(f.agent_label??null)){g.times=(g.times??1)+1,g.until=f.timestamp,u=g;continue}let y;const v=f.kind==="tool_use"&&f.tool_use_id?n.get(f.tool_use_id):void 0;if(v){const h=v.tool_status!=="failed",x=[f.tool_input_preview,v.tool_result_preview].filter(Boolean),b=v.tool_status!==null;y={row:{...v,id:f.id,seq:f.seq,timestamp:f.timestamp,summary:h?(v.summary??"").replace(/:\s*ok$/i,""):v.summary,...f.usage?{usage:f.usage}:{}},...b?{ms:Math.max(0,Date.parse(v.timestamp)-Date.parse(f.timestamp))}:{},detail:x.length===2?`${x[0]}
586
+
587
+ → ${x[1]}`:x[0]??null}}else y={row:f};c.push(y),f.kind==="tool_use"&&f.tool_use_id&&d.set(f.tool_use_id,y),u=y}return i&&c.push({row:i}),c}class Ue extends Error{constructor(s,r,o,i=!1,c){super(o);Pt(this,"fields");Pt(this,"retryAfterMs");Pt(this,"details");Pt(this,"problems");this.status=s,this.code=r,this.retryable=i,this.requestId=c,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const Gt=e=>e instanceof Ue?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),Wk=(e,n,{status:s,archived:r}={})=>{const o=new URLSearchParams({limit:String(e)});return n&&o.set("cursor",n),s&&o.set("status",s),r&&o.set("archived","true"),`?${o}`},_L=new Set(["/auth/sign-in","/setup"]);function TL({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(x,b,j={}){return(await o(x,b,j)).body}async function o(x,b,{body:j,headers:k={},signal:E,text:N=!1}={}){var O;const S=j!==void 0||x!=="GET"&&x!=="HEAD",$=await e(`${n}${b}`,{method:x,signal:E,credentials:"same-origin",headers:{accept:"application/json",...S?{"content-type":"application/json"}:{},...k},body:j===void 0?void 0:JSON.stringify(j)});if(!$.ok){$.status===401&&!_L.has(b)&&(s==null||s());const M=(O=await $.json().catch(()=>null))==null?void 0:O.error,P=new Ue($.status,(M==null?void 0:M.code)??"http_error",(M==null?void 0:M.message)??`${x} ${b}: ${$.status}`,(M==null?void 0:M.retryable)??!1,M==null?void 0:M.request_id);throw M!=null&&M.fields&&(P.fields=M.fields),typeof(M==null?void 0:M.retry_after_ms)=="number"&&(P.retryAfterMs=M.retry_after_ms),M!=null&&M.details&&typeof M.details=="object"&&!Array.isArray(M.details)&&(P.details=M.details),Array.isArray(M==null?void 0:M.problems)&&(P.problems=M.problems),P}return{body:!N&&($.headers.get("content-type")??"").includes("json")?await $.json():await $.text(),etag:$.headers.get("etag"),status:$.status}}const i=x=>`/agents/${encodeURIComponent(x)}`,c=x=>`/runs/${encodeURIComponent(x)}`,d=(x,b,j)=>`${i(x)}/learning/workflows/${encodeURIComponent(b)}/revisions/${encodeURIComponent(j)}/replays`,u=x=>`/settings/mcp-servers/${encodeURIComponent(x)}`,f=x=>`/triggers/${encodeURIComponent(x)}`,g=new Map,y=(x,b)=>`${i(x)}/learning/files/${encodeURIComponent(b)}`,v=x=>({text:x.body,etag:x.etag}),h={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>o("GET","/auth/session").then(x=>({status:x.status,body:x.body})),signIn:x=>r("POST","/auth/sign-in",{body:{password:x}}),setup:(x,b,j=[])=>r("POST","/setup",{body:{password:x,...b?{code:b}:{},...j.length?{import:[...j]}:{}}}),setupImport:()=>r("GET","/setup/import").then(x=>(x==null?void 0:x.offer)===!1?null:x,x=>{if(x instanceof Ue&&(x.status===404||x.status===403))return null;throw x}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),setupCode:()=>r("POST","/setup/code",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(x=50,b,j)=>r("GET",`/runs${Wk(x,b,j)}`),listAgentRuns:(x,b=50,j,k={})=>r("GET",`${i(x)}/runs${Wk(b,j,typeof k=="boolean"?{archived:k}:k)}`),discoverNative:(x,b)=>r("POST","/native/discover",{body:{project:x,...b?{runtime:b}:{}}}),connectNative:x=>r("POST","/native/connect",{body:x}),getNative:x=>r("GET",`${i(x)}/native`),verifyNative:x=>r("POST",`${i(x)}/native/verify`,{body:{}}),disconnectNative:x=>r("POST",`${i(x)}/native/disconnect`,{body:{}}),observations:({days:x=30,sessionId:b}={},j)=>{const k=new URLSearchParams({days:String(x)});return b&&k.set("session_id",b),r("GET",`/observations?${k}`,{signal:j})},listConnectors:()=>r("GET","/connectors"),enrollConnector:(x,b)=>r("POST","/connectors/enrollment",{body:{...x!=null&&x.trim()?{label:x.trim()}:{},...b?{capabilities:b}:{}}}),revokeConnector:x=>r("DELETE",`/connectors/${encodeURIComponent(x)}`),listAgents:({archived:x=!1,cursor:b}={})=>{const j=new URLSearchParams;return x&&j.set("archived","true"),b&&j.set("cursor",b),r("GET",`/agents${j.size?`?${j}`:""}`)},getAgent:async x=>{const b=await o("GET",i(x)),j=g.get(x);return{agent:j&&j.revision===b.body.revision&&!b.body.warnings?{...b.body,warnings:j.warnings}:b.body,etag:b.etag}},createAgent:async x=>{var j;const b=await r("POST","/agents",{body:x});return(j=b.warnings)!=null&&j.length&&g.set(b.agent_id,{revision:b.revision,warnings:b.warnings}),b},updateDefinition:async(x,b,j)=>{const k=await o("PUT",`${i(x)}/definition`,{body:b,headers:j?{"if-match":j}:{}});return g.delete(x),{agent:k.body,etag:k.etag}},listRevisions:(x,b)=>r("GET",`${i(x)}/revisions${b?`?cursor=${encodeURIComponent(b)}`:""}`),setCurrent:async(x,b)=>{const j=await r("POST",`${i(x)}/current`,{body:{revision:b}});return g.delete(x),j},archiveAgent:x=>r("POST",`${i(x)}/archive`,{body:{}}),unarchiveAgent:x=>r("POST",`${i(x)}/unarchive`,{body:{}}),agentLearning:x=>r("GET",`${i(x)}/learning`),corrections:async x=>(await o("GET",`${i(x)}/learning/corrections`)).body,writeCorrections:(x,b,j)=>r("PUT",`${i(x)}/learning/corrections`,{body:{text:b},headers:{"if-match":j}}),learningCost:(x,b)=>r("GET",`${i(x)}/learning/cost${b?`?limit=${b}`:""}`),learningPromotions:x=>r("GET",`${i(x)}/learning/promotions`),learningLoop:x=>r("GET",`${i(x)}/learning/loop`),learningAudits:x=>r("GET",`${i(x)}/learning/audits`),learnedWorkflowRevisions:(x,b,j)=>r("GET",`${i(x)}/learning/workflows/${encodeURIComponent(b)}/revisions${j?`?limit=${j}`:""}`),startLearnedWorkflowReplay:(x,b,j)=>r("POST",`${d(x,b,j)}`,{body:{}}),learnedWorkflowReplay:(x,b,j,k)=>r("GET",`${d(x,b,j)}/${encodeURIComponent(k)}`),learningLog:(x,b)=>r("GET",`${i(x)}/learning/log?cursor=${encodeURIComponent(b)}`),readLearningFile:async(x,b)=>v(await o("GET",y(x,b),{headers:h,text:!0})),retireWorkflow:async(x,b,j)=>v(await o("POST",`${y(x,b)}/retire`,{body:{},headers:{...h,"if-match":j},text:!0})),approveWorkflow:async(x,b,j)=>v(await o("POST",`${y(x,b)}/approve`,{body:{},headers:{...h,"if-match":j},text:!0})),restoreWorkflow:async(x,b,j)=>v(await o("POST",`${y(x,b)}/restore`,{body:{},headers:{...h,"if-match":j},text:!0})),forgetSignIn:(x,b)=>r("DELETE",`${i(x)}/sign-ins/${encodeURIComponent(b)}`),getRun:x=>r("GET",c(x)),runLearningResult:x=>r("GET",`${c(x)}/learning`),runLearningDiff:x=>r("GET",`${c(x)}/learning/diff`),runLearning:x=>r("GET",`${c(x)}/learning`),runComputer:x=>r("GET",`${c(x)}/computer`),takeOverComputer:x=>r("POST",`${c(x)}/computer/take-over`,{body:{}}),handBackComputer:(x,b)=>r("POST",`${c(x)}/computer/hand-back`,{body:b?{outcome:b}:{}}),archiveRun:x=>r("POST",`${c(x)}/archive`,{body:{}}),unarchiveRun:x=>r("POST",`${c(x)}/unarchive`,{body:{}}),raiseCap:(x,b)=>r("PATCH",c(x),{body:{max_cost_usd:b}}),gradeRun:(x,b)=>r("PUT",`${c(x)}/grade`,{body:b}),startRun:async(x,b,j)=>{const k=await o("POST",`${i(x)}/runs`,{body:b,headers:{"idempotency-key":j}});return{run:k.body,status:k.status}},getTimeline:(x,{after:b,waitMs:j,signal:k}={})=>{const E=new URLSearchParams;return b!==void 0&&E.set("after",String(b)),j!==void 0&&E.set("wait_ms",String(j)),r("GET",`${c(x)}/timeline${E.size?`?${E}`:""}`,{signal:k})},listFiles:x=>r("GET",`${c(x)}/files`),deleteUpload:x=>r("DELETE",`/files/${encodeURIComponent(x)}`),readFile:(x,b)=>r("GET",`${c(x)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(x,b,j)=>r("POST",`${c(x)}/messages`,{body:{content:b},headers:{"idempotency-key":j}}),getRunGraph:(x,b)=>r("GET",`${c(x)}/graph`,{signal:b}),runTrace:(x,b)=>r("GET",`${c(x)}/trace`,{signal:b}),pauseRun:x=>r("POST",`${c(x)}/pause`,{body:{}}),resumeRun:x=>r("POST",`${c(x)}/resume`,{body:{}}),validateWorkflow:(x,b)=>r("POST","/workflows/validate",{body:x,signal:b}),statsOver:({from:x,agent:b})=>{const j=new URLSearchParams;return x&&j.set("from",x),b&&j.set("agent",b),r("GET",`/stats${j.size?`?${j}`:""}`)},fileUrl:(x,b)=>`${n}${c(x)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(x,b)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(x)}`,{body:{values:b}}),removeToolKey:x=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(x)}`),chatGPT:()=>r("GET","/settings/chatgpt"),startChatGPT:()=>r("POST","/settings/chatgpt/sign-in"),finishChatGPT:x=>r("POST","/settings/chatgpt/sign-in/finish",{body:{redirect_url:x}}),signOutChatGPT:()=>r("DELETE","/settings/chatgpt"),claudeLogin:()=>r("GET","/settings/claude-login"),turnOnClaudeLogin:x=>r("PUT","/settings/claude-login",{body:{place:x,only_me:!0}}),turnOffClaudeLogin:()=>r("DELETE","/settings/claude-login"),startClaudeLogin:()=>r("POST","/settings/claude-login/login"),computers:()=>r("GET","/computers"),saveComputerKeys:(x,b)=>r("PUT",`/computers/${encodeURIComponent(x)}/keys`,{body:b}),testComputer:x=>r("POST",`/computers/${encodeURIComponent(x)}/test`),computerChoices:x=>r("GET",`/computers/${encodeURIComponent(x)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:x=>r("DELETE",`/computers/${encodeURIComponent(x)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:x=>r("PUT","/workspace/archil",{body:x}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:x=>r("PUT","/settings/webhook",{body:{url:x}}),removeWebhook:()=>r("DELETE","/settings/webhook"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),emailAccount:()=>r("GET","/settings/email"),saveEmailAccount:x=>r("PUT","/settings/email",{body:x}),removeEmailAccount:()=>r("DELETE","/settings/email"),testEmailAccount:(x={})=>r("POST","/settings/email/test",{body:x}),listTriggers:()=>r("GET","/triggers"),getTrigger:x=>r("GET",f(x)),createTrigger:(x,b)=>r("POST","/triggers",{body:x,headers:{"idempotency-key":b}}),rotateTriggerSecret:x=>r("POST",`${f(x)}/secret`),updateTrigger:(x,b)=>r("PATCH",f(x),{body:b}),deleteTrigger:x=>r("DELETE",f(x)),fireTrigger:(x,b)=>r("POST",`${f(x)}/fire`,{body:{},headers:{"idempotency-key":b}}),triggerFirings:x=>r("GET",`${f(x)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:x=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(x)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(x,b,j)=>r("POST",`/templates/${encodeURIComponent(x)}/apply`,{body:b,headers:{"idempotency-key":j}}),importTemplate:(x,b={})=>r("POST","/templates/import",{body:{source:x,...b.dryRun?{dry_run:!0}:{},...b.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:x=>r("DELETE",`/templates/${encodeURIComponent(x)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(x,b,j)=>r("POST","/settings/mcp-servers/preview",{body:{url:x,auth:b,...j?{name:j}:{}}}),saveMcpServer:(x,b,j,k={})=>r("PUT",u(x),{body:{url:b,auth:j,...k}}),composioTools:(x,b)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:x,toolkit:b}}),saveComposioServer:(x,b,j,k)=>r("PUT",`${u(x)}/composio`,{body:{api_key:b,toolkit:j,tools:k}}),refreshMcpServer:x=>r("POST",`${u(x)}/refresh`,{body:{}}),deleteMcpServer:x=>r("DELETE",u(x)),composioEvents:x=>r("GET",`${u(x)}/composio/events`),composioTriggers:x=>r("GET",`${u(x)}/composio/triggers`),rotateComposioSecret:x=>r("POST",`${u(x)}/composio/rotate-secret`,{body:{}}),deleteComposioSubscription:x=>r("DELETE",`${u(x)}/composio/subscription`),startMcpSignIn:(x,b)=>r("POST",`${u(x)}/oauth/start`,{body:b}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:x=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:x}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:x=>r("POST","/integrations/github/connect",{body:x?{org:x}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:x=>r("PUT","/settings/tools",{body:x}),stop:x=>r("POST",`${c(x)}/stop`,{body:{}}),answerApproval:(x,b,j,k,E)=>r("POST",`${c(x)}/approvals/${encodeURIComponent(b)}`,{body:{decision:j,...k?{note:k}:{},...E?{confirm_destructive:!0}:{}}}),cancel:x=>r("POST",`${c(x)}/cancel`,{body:{}})}}async function Mr(e,n,s=100){const r=[];let o=null;for(let i=0;i<s;i++){const c=await e(o);if(r.push(...n(c)),!c.next_cursor)break;o=c.next_cursor}return r}async function M2(e,n,{onRows:s,onPage:r,signal:o,waitMs:i=25e3,minDelayMs:c=250}){let d=[],u,f;for(;!(o!=null&&o.aborted);){const g=await e.getTimeline(n,u===void 0?{signal:o}:{after:u,waitMs:i,signal:o}).catch(v=>{if(o!=null&&o.aborted)return null;throw v});if(!g||o!=null&&o.aborted||(f=g,s&&(d=CL(d,g)),r==null||r(g),s==null||s(d),g.final&&!g.has_more))break;u=g.next_after;const y=Math.max(c,g.unchanged?g.poll_after_ms??0:0);y&&await new Promise(v=>setTimeout(v,y))}return f}const Hk=e=>`#/observations/${encodeURIComponent(e)}`,tm=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e;function za(e){return e.connection_state==="revoked"?"Revoked":e.connection_state==="disconnected"?"Disconnected":e.selection_active?e.connection_state!=="online"?"Disconnected":{working:"Running",running:"Running",waiting:"Needs input",waiting_input:"Needs input",idle:"Idle",stopped:"Stopped",finished:"Session ended",failed:"Failed",unknown:"Unknown"}[e.activity]??e.activity:"Not selected"}const dx=e=>{const n=za(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},Da=e=>e==null?"—":e.toLocaleString("en-US");function zv(e,{active:n=!0,days:s=30,sessionId:r}={}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(!1);return p.useEffect(()=>{i(null),d(null)},[e,n,s,r]),p.useEffect(()=>{let v=!0;if(!n||typeof e.observations!="function"){y(!1);return}let h=null,x,b;const j=async()=>{if(!v||h)return;clearTimeout(x);const E=h=new AbortController,N=()=>v&&h===E;y(!0);const S=()=>{clearTimeout($),N()&&(h=null,b=void 0,y(!1),clearTimeout(x),x=setTimeout(k,15e3))},$=b=setTimeout(()=>{N()&&(d("The observation read timed out. Try refreshing again."),E.abort(),S())},3e4);try{const _=await e.observations({days:s,sessionId:r},E.signal);N()&&(i(_),d(null))}catch(_){N()&&(_ instanceof Ue&&_.status===404?(i(null),d(null)):d(Gt(_)))}finally{S()}},k=()=>{!v||h||(document.hidden?(clearTimeout(x),x=setTimeout(k,15e3)):j())};return j(),window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{v=!1,clearTimeout(x),clearTimeout(b),h==null||h.abort(),h=null,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[e,n,s,r,u]),{data:o,error:c,loading:g,refresh:()=>f(v=>v+1)}}function Dv({read:e,view:n="table",query:s="",days:r=30}){const{data:o,error:i,refresh:c}=e,d=o==null?void 0:o.connectors.some(f=>f.storage_full);if(!(o!=null&&o.sessions.length)&&!i&&!d)return null;const u=((o==null?void 0:o.sessions)??[]).filter(f=>`${f.display_name} ${f.harness} ${f.models.join(" ")}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"space-y-4","aria-label":"Observed sessions",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("div",{className:"mr-auto",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-lead font-semibold",children:[t.jsx(l1,{className:"size-4","aria-hidden":!0}),"Observed sessions"]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Agents running in their original applications. Activity refreshes every 15 seconds."})]}),t.jsx(B,{size:"icon","aria-label":"Refresh observed sessions",disabled:e.loading,onClick:c,children:t.jsx(oa,{className:"size-4","aria-hidden":!0})})]}),d&&t.jsx(jt,{tone:"warning",title:"Telemetry needs attention",children:"A connector has reached its telemetry storage capacity. New reports cannot be accepted until storage becomes available."}),i&&t.jsxs(jt,{tone:"error",children:["Could not refresh observed sessions: ",i]}),n==="summary"&&o&&t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx("dl",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[["Retained sessions",u.length],["Running",u.filter(f=>za(f)==="Running").length],["Needs input",u.filter(f=>za(f)==="Needs input").length],["Disconnected",u.filter(f=>za(f)==="Disconnected").length]].map(([f,g])=>t.jsxs("div",{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:f}),t.jsx("dd",{className:"mt-2 font-mono text-figure",children:g})]},f))}),t.jsxs("h3",{className:"text-body font-semibold",children:["Observed token usage · last ",r," days"]}),o.usage.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:o.usage.overflow?"Combined token totals are too large to display reliably. Open individual sessions for exact counters.":"Token usage has not been reported."}):t.jsxs(t.Fragment,{children:[t.jsx(L2,{usage:o.usage}),t.jsx(RL,{models:o.usage.models}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Reported tokens only. Input includes cache reads and writes; cache hit rate is cache reads divided by input. Idle does not mean a task completed."})]})]}),n==="summary"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports, independently of the aggregate range."}),u.length?n==="cards"?t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:u.map(f=>t.jsx("li",{className:"border p-5 transition-colors hover:border-border-strong",children:t.jsxs("a",{href:Hk(f.id),className:"block space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[t.jsx("h3",{className:"min-w-0 flex-1 break-words text-base font-semibold",children:f.display_name}),t.jsx(pr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Ne,{children:tm(f.harness)}),t.jsx(Ne,{tone:dx(f),children:za(f)}),t.jsx(Ne,{tone:"muted",children:"Observed"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:f.models.join(", ")||"Model not reported"}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Session ",f.id.slice(0,8)," · Last received ",vt(f.received_at)]})]})},f.id))}):t.jsx("div",{className:"overflow-x-auto border",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Observed sessions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Activity","Session","Harness","Model","Tokens · retained","Last received"].map(f=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:f},f))})}),t.jsx("tbody",{children:u.map(f=>t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent",children:[t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:t.jsx(Ne,{tone:dx(f),children:za(f)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("a",{href:Hk(f.id),className:"inline-flex items-center gap-1 underline underline-offset-2",children:[f.display_name,t.jsx(pr,{className:"size-3 shrink-0","aria-hidden":!0})]})}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:tm(f.harness)}),t.jsx("td",{className:"px-4 py-3",children:f.models.join(", ")||"Not reported"}),t.jsx("td",{className:"px-4 py-3 font-mono",children:f.usage.status==="unavailable"?"—":Da(f.usage.total_tokens)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:vt(f.received_at)})]},f.id))})]})}):t.jsx("p",{className:"text-body text-muted-foreground",children:"No observed session matches."})]})}function L2({usage:e}){return e.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:"Token usage has not been reported."}):t.jsx("dl",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:[["Input",Da(e.input_tokens)],["Output",Da(e.output_tokens)],["Cache writes",Da(e.cache_write_tokens)],["Cache reads",Da(e.cache_read_tokens)],["Total tokens",Da(e.total_tokens)],["Cache hit rate",e.cache_hit_rate==null?"—":`${(e.cache_hit_rate*100).toFixed(1)}%`]].map(([n,s])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:n}),t.jsx("dd",{className:"mt-1 font-mono text-body",children:s})]},n))})}function RL({models:e}){return e.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-right text-small","aria-label":"Observed tokens by model",children:[t.jsx("thead",{className:"border-b text-muted-foreground",children:t.jsx("tr",{children:["Model","Input","Output","Cache writes","Cache reads"].map(n=>t.jsx("th",{className:"whitespace-nowrap py-2 pl-4 font-normal first:pl-0 first:text-left",children:n},n))})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsx("th",{className:"py-2 text-left font-normal",children:n.model}),[n.input_tokens,n.output_tokens,n.cache_write_tokens,n.cache_read_tokens].map((s,r)=>t.jsx("td",{className:"py-2 pl-4 font-mono",children:Da(s)},r))]},n.model))})]})}):null}function AL({v2:e,sessionId:n,go:s}){var i;const r=zv(e,{sessionId:n}),o=(i=r.data)==null?void 0:i.sessions.find(c=>c.id===n);return t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Observed session detail",children:[t.jsxs("header",{className:te(vr,"flex-wrap gap-2 px-5"),children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>s("#/agents"),children:t.jsx(Fn,{"aria-hidden":!0})}),t.jsx(l1,{className:"size-4","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 flex-1 truncate text-body",children:(o==null?void 0:o.display_name)??"Observed session"}),t.jsx(B,{size:"icon","aria-label":"Refresh session",disabled:r.loading,onClick:r.refresh,children:t.jsx(oa,{"aria-hidden":!0})})]}),t.jsxs("main",{className:"mx-auto w-full max-w-page space-y-6 p-5 md:p-8",children:[r.error&&t.jsxs(jt,{tone:"error",children:["Could not read this session: ",r.error]}),o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:o.display_name}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[t.jsx(Ne,{tone:"muted",children:"Observed"}),t.jsx(Ne,{tone:dx(o),children:za(o)}),t.jsx(Ne,{children:tm(o.harness)})]})]}),t.jsx(jt,{children:"Activity and token usage come from the original application. Run, edit and stop remain in that application. This connection observes activity; the backend SDK integration adds self-improvement."}),t.jsx("dl",{className:"grid gap-4 border bg-card p-4 sm:grid-cols-2",children:[["Harness",tm(o.harness)],["Model",o.models.join(", ")||"Not reported"],["Connection",o.connection_state],["Last reported activity",o.reported_activity],["First seen",vt(o.created_at)],["Last received",vt(o.received_at)],["Session",o.id],["Connector",o.connector_id]].map(([c,d])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:c}),t.jsx("dd",{className:"mt-1 break-all text-body",children:d})]},c))}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Session token usage",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Reported token usage · retained session"}),t.jsx(L2,{usage:o.usage}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports. Input includes cache reads and writes. Missing cache counters are shown as a dash. Activity signals do not establish a completed task or its outcome."})]})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:r.loading?"Loading observed session…":r.data?"This session was not found.":"Observed sessions are unavailable on this server."})]})]})}function Fv(e,n={}){const s=new URLSearchParams({operation:"list-runs"});return e&&s.set("agent",e),n.status&&s.set("status",n.status),n.archived&&s.set("archived","true"),`#/playground?${s}`}const OL=800,ML=16;function yg(){const e=p.useRef(null);return p.useEffect(()=>{const n=e.current;if(!n)return;let s;const r=()=>{n.setAttribute("data-scrolling",""),clearTimeout(s),s=setTimeout(()=>n.removeAttribute("data-scrolling"),OL)},o=c=>n.toggleAttribute("data-scroll-lane",c.clientX>=n.getBoundingClientRect().right-ML),i=()=>n.removeAttribute("data-scroll-lane");return n.addEventListener("scroll",r,{passive:!0}),n.addEventListener("pointermove",o,{passive:!0}),n.addEventListener("pointerleave",i),()=>{n.removeEventListener("scroll",r),n.removeEventListener("pointermove",o),n.removeEventListener("pointerleave",i),clearTimeout(s),n.removeAttribute("data-scrolling"),n.removeAttribute("data-scroll-lane")}},[]),e}const Zt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),LL=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),ux=128,PL=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},fx=(e,n=0)=>n>ux?'"…"':Array.isArray(e)?`[${e.map(s=>fx(s,n+1)).join(",")}]`:Zt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${fx(e[s],n+1)}`).join(",")}}`:PL(e),IL=e=>{let n=2166136261;for(let s=0;s<e.length;s+=1)n=Math.imul(n^e.charCodeAt(s),16777619);return(n>>>0).toString(16).padStart(8,"0")},$c=(e,n)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==n)),zL=e=>{switch(e.node){case"chain":return $c(e,"steps");case"parallel":return $c(e,"branches");case"map":case"loop":return $c(e,"body");case"route":return Zt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,Zt(s)?$c(s,"body"):s]))}:e;case"workflow":return Zt(e.workflow)?{...e,workflow:$c(e.workflow,"root")}:e;default:return e}};function vl(e){const n=[],s=[],r=(o,i,c,d)=>{if(!Zt(o)||typeof o.node!="string"||c>ux)return;n.push({path:i,kind:o.node,label:typeof o.label=="string"?o.label:o.node,...o.node==="call"&&typeof o.via=="string"?{via:o.via}:{},changeCheck:IL(fx(zL(o))),...FL(o,d)});const u=(f,g,y,v=i,h=d)=>{!Zt(f)||typeof f.node!="string"||c+1>ux||(s.push({from:v,to:g,kind:y}),r(f,g,c+1,h))};switch(o.node){case"chain":Array.isArray(o.steps)&&o.steps.forEach((f,g)=>u(f,`${i}/steps/${g}`,"next",g===0?i:`${i}/steps/${g-1}`));break;case"parallel":Array.isArray(o.branches)&&o.branches.forEach((f,g)=>u(f,`${i}/branches/${g}`,"branch"));break;case"map":u(o.body,`${i}/body`,"item");break;case"loop":u(o.body,`${i}/body`,"next");break;case"route":if(Zt(o.branches))for(const[f,g]of Object.entries(o.branches))Zt(g)&&u(g.body,`${i}/branches/${LL(f)}/body`,"route");break;case"workflow":Zt(o.workflow)&&u(o.workflow.root,`${i}/workflow/root`,"child",i,Zt(o.workflow.schemas)?o.workflow.schemas:{});break}};return r(Zt(e)?e.root:void 0,"/root",0,Zt(e)&&Zt(e.schemas)?e.schemas:{}),{nodes:n,edges:s}}const DL=(e,n)=>{const s=typeof e=="string"&&Object.hasOwn(n,e)?n[e]:void 0,r=i=>{var c;for(let d=0;Zt(i)&&typeof i.$ref=="string"&&d<8;d+=1){const u=(c=/^#\/definitions\/(.+)$/.exec(i.$ref))==null?void 0:c[1],f=Zt(s)&&Zt(s.definitions)?s.definitions:{};i=u===void 0?void 0:Object.hasOwn(f,u)?f[u]:Object.hasOwn(n,u)?n[u]:void 0}return i},o=r(s);return!Zt(o)||!Zt(o.properties)?[]:Object.entries(o.properties).map(([i,c])=>{const d=r(c),u=Zt(d)&&typeof d.description=="string"?d.description:"",f=Zt(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(g=>g!=="null"):[];return Zt(d)&&Array.isArray(d.enum)?{id:i,type:"choice",instructions:u,options:d.enum.map(String)}:f.length===1&&f[0]==="boolean"?{id:i,type:"noul",instructions:u}:f.length===1&&f[0]==="integer"?{id:i,type:"score",instructions:u}:{id:i,type:"unknown",instructions:u}})},FL=(e,n)=>{let s=e,r;const o=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=DL(e.out,n);break;case"pick":r=[{id:"pick",type:"choice",instructions:o(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};r=[{id:"branch",type:"choice",instructions:o(e.instructions),options:Zt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const i=e.node==="loop"?e.until:e.when;if(!Zt(i)||i.predicate!=="ask")return{};s=i,r=[{id:"holds",type:"noul",instructions:o(i.instructions)}];break}default:return{}}return{...typeof s.provider=="string"?{provider:s.provider}:{},...typeof s.model=="string"?{model:s.model}:{},questions:r,...Zt(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function P2(e,n){const s=N=>JSON.stringify([N.kind,N.label]),r=N=>{const S=new Map;for(const $ of N.nodes)S.set(s($),(S.get(s($))??0)+1);return S},[o,i]=[r(e),r(n)],c=N=>o.get(s(N))===1&&i.get(s(N))===1,d=new Map,u=new Map,f=(N,S)=>{d.set(S,N),u.set(N,S)},g=new Map(e.nodes.filter(c).map(N=>[s(N),N.path]));for(const N of n.nodes){const S=c(N)?g.get(s(N)):void 0;S!==void 0&&f(S,N.path)}const y=new Map(e.nodes.map(N=>[N.path,N])),v=[];for(const N of n.nodes){const S=y.get(N.path);d.has(N.path)||S===void 0||u.has(S.path)||(f(S.path,N.path),(S.kind!==N.kind||S.label!==N.label)&&v.push({prev:S.path,next:N.path,was:{kind:S.kind,label:S.label},now:{kind:N.kind,label:N.label}}))}const h=[];for(const N of n.nodes){const S=d.get(N.path),$=S===void 0?void 0:y.get(S);$===void 0||$.kind!==N.kind||$.label!==N.label||$.changeCheck!==void 0&&N.changeCheck!==void 0&&$.changeCheck!==N.changeCheck&&h.push({prev:$.path,next:N.path,kind:N.kind,label:N.label})}const x=({path:N,kind:S,label:$})=>({path:N,kind:S,label:$}),b=(N,S,$)=>JSON.stringify([N,S,$]),j=new Set(e.edges.map(N=>b(N.from,N.to,N.kind))),k=new Set(n.edges.map(N=>b(N.from,N.to,N.kind))),E=(N,S,$)=>{const[_,O]=[S.get(N.from),S.get(N.to)];return _!==void 0&&O!==void 0&&$.has(b(_,O,N.kind))};return{added:n.nodes.filter(N=>!d.has(N.path)).map(x),removed:e.nodes.filter(N=>!u.has(N.path)).map(x),changed:v,moved:n.nodes.flatMap(N=>{const S=d.get(N.path);return S!==void 0&&S!==N.path?[{prev:S,next:N.path}]:[]}),rewritten:h,edges:{added:n.edges.filter(N=>!E(N,d,j)).map(({from:N,to:S,kind:$})=>({from:N,to:S,kind:$})),removed:e.edges.filter(N=>!E(N,u,k)).map(({from:N,to:S,kind:$})=>({from:N,to:S,kind:$}))}}}function An({className:e}){return t.jsx("span",{"aria-hidden":!0,className:te("block bg-muted motion-safe:animate-pulse",e)})}function Xm({label:e,className:n,children:s}){return t.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:n,children:[s,t.jsxs("span",{className:"sr-only",children:[e,"…"]})]})}function UL(){return t.jsxs(Xm,{label:"Loading Mission Control",className:"space-y-8 p-5 md:p-8",children:[t.jsx(An,{className:"h-8 w-56"}),t.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:Array.from({length:6},(e,n)=>t.jsxs("div",{className:"border p-4",children:[t.jsx(An,{className:"h-3 w-16"}),t.jsx(An,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(An,{className:"h-48 w-full"}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[t.jsx(nm,{n:4}),t.jsx(nm,{n:6})]})]})}function nm({n:e}){return t.jsx("div",{className:"border",children:Array.from({length:e},(n,s)=>t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx(An,{className:"h-4 w-20"}),t.jsx(An,{className:"h-4 flex-1"}),t.jsx(An,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Qn({label:e,rows:n=8}){return t.jsx(Xm,{label:e,children:t.jsx(nm,{n})})}function WL(){return t.jsxs(Xm,{label:"Loading the run",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3 border-b pb-6",children:[t.jsx(An,{className:"h-4 w-24"}),t.jsx(An,{className:"h-7 w-2/3"}),t.jsx(An,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(An,{className:"h-4 w-16"},n))}),t.jsx("div",{className:"space-y-4",children:Array.from({length:5},(e,n)=>t.jsxs("div",{className:"flex gap-3",children:[t.jsx(An,{className:"size-4 shrink-0"}),t.jsx(An,{className:te("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function HL(){return t.jsxs(Xm,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(An,{className:"h-7 w-64"}),t.jsx(An,{className:"h-3 w-80 max-w-full"})]}),t.jsx(An,{className:"h-12 w-full"}),t.jsx(nm,{n:5})]})}function en({problem:e,onRetry:n,link:s,className:r="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${r}`,role:"alert",children:[t.jsx(Ys,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),(n||s)&&t.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[n&&t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"}),s&&t.jsx("a",{href:s.href,className:"caps border px-3 py-2 text-small hover:bg-accent",children:s.label})]})]})]})}function I2({what:e,id:n,list:s}){return t.jsx(en,{problem:{title:`No ${e} with this id.`,why:`This server has no ${e} ${n}.`,next:`Check the address, or find the ${e} in the list.`},link:s})}class mx extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const hx=e=>Math.min(1e4,1e3*2**e),Bk=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),BL=e=>(e==null?void 0:e.name)==="AbortError",qk=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function qL({fetch:e=(o,i)=>globalThis.fetch(o,i),probe:n="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let o={state:"online"};const i=new Set,c=new Set;let d=[],u,f=null,g=null;const y=S=>{o=S;for(const $ of[...i])$()},v=S=>{const $=hx(S);clearTimeout(u),y({state:"offline",attempt:S,retryAt:Date.now()+$}),u=setTimeout(()=>void j(),$)},h=()=>{o.state!=="offline"&&v(0)},x=()=>{if(o.state!=="offline")return;clearTimeout(u),y({state:"resumed"});const S=d;d=[];for(const $ of S)$();for(const $ of[...c])$();u=setTimeout(()=>{o.state==="resumed"&&y({state:"online"})},s)};async function b(S){const $=setTimeout(()=>S.abort(),r);try{return!Bk(await e(n,{method:"GET",cache:"no-store",credentials:"same-origin",signal:S.signal}))}catch{return!1}finally{clearTimeout($)}}async function j(){if(o.state!=="offline")return;clearTimeout(u),f==null||f.abort();const S=f=new AbortController,$=await b(S);f===S&&(f=null,o.state==="offline"&&($?x():v(o.attempt+1)))}const k=()=>g??(g=b(new AbortController).finally(()=>{g=null})),E=S=>new Promise(($,_)=>{if(S!=null&&S.aborted)return _(qk(S));const O=()=>{d=d.filter(P=>P!==M),_(qk(S))},M=()=>{S==null||S.removeEventListener("abort",O),$()};d.push(M),S==null||S.addEventListener("abort",O,{once:!0})});return{fetch:async(S,$)=>{var M;const _=(($==null?void 0:$.method)??"GET").toUpperCase(),O=_==="GET"||_==="HEAD";for(let P=0;;P++){let A,R;try{A=await e(S,$)}catch(L){if((M=$==null?void 0:$.signal)!=null&&M.aborted||BL(L))throw L;R=L}if(A&&!Bk(A))return x(),A;if(o.state!=="offline"&&await k()){if(A)return A;if(!O)throw new mx;if(P>=2)throw R;await new Promise(L=>setTimeout(L,hx(P)));continue}if(h(),!O)throw new mx;await E($==null?void 0:$.signal)}},link:()=>o,subscribe:S=>(i.add(S),()=>{i.delete(S)}),onResume:S=>(c.add(S),()=>{c.delete(S)}),retryNow:()=>void j()}}const GL=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),z2=e=>e instanceof mx||e instanceof TypeError&&/fetch|network/i.test(e.message);function Jt(e,n){const s=`${GL(n)} could not be read.`;if(z2(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof Ue))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=e.message,o=[e.code,e.requestId].filter(Boolean).join(" · "),i=(c,d)=>({title:s,why:c,next:d,said:r,code:o});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Its words say why: change what they name, then try again.")}function KL(e){return z2(e)?"Can't reach agentrun-serve":e instanceof Ue?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function VL({agent:e,v2:n}){const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(null),v=p.useRef(0),h=p.useRef(!1),x=async b=>{if(h.current)return;h.current=!0;const j=++v.current;f(!0);try{const k=await n.listRevisions(e.agent_id,b);if(j!==v.current)return;r(E=>{const N=new Map((b?E??[]:[]).map(S=>[S.revision,S]));for(const S of k.revisions)N.set(S.revision,S);return[...N.values()]}),i(k.next_cursor),d(null)}catch(k){j===v.current&&d(Jt(k,b?"more versions":"the versions"))}finally{j===v.current&&(h.current=!1,f(!1))}};return p.useEffect(()=>(h.current=!1,r(null),i(null),d(null),y(null),x(null),()=>{v.current++,h.current=!1}),[n,e.agent_id,e.revision,e.revisions]),c&&!s?t.jsx(en,{problem:c,onRetry:()=>void x(null),className:""}):s?t.jsxs("section",{className:"overflow-hidden border","aria-label":"Agent versions",children:[t.jsxs("div",{className:"border-b px-4 py-3 text-body text-muted-foreground",children:[e.revisions," ",e.revisions===1?"version":"versions"," · Current version ",e.definition.version]}),s.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Versions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Version","Created","Note","Configuration"].map(b=>t.jsx("th",{className:"px-4 py-3 font-semibold",children:b},b))})}),t.jsx("tbody",{children:s.map(b=>t.jsxs(p.Fragment,{children:[t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsxs("td",{className:"whitespace-nowrap px-4 py-3",children:[t.jsxs("span",{className:"font-semibold",children:["v",b.version]}),b.revision===e.revision&&t.jsx("span",{className:"ml-2 bg-primary/10 px-2 py-1 text-micro text-primary-text",children:"Current"})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:vt(b.created_at)}),t.jsx("td",{className:"min-w-40 px-4 py-3 text-muted-foreground",children:b.note||"—"}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(B,{size:"sm","aria-expanded":g===b.revision,"aria-label":`View configuration for version ${b.version}`,onClick:()=>y(j=>j===b.revision?null:b.revision),children:g===b.revision?"Hide":"View"})})]}),g===b.revision&&t.jsx("tr",{className:"border-b bg-card",children:t.jsxs("td",{colSpan:4,className:"p-4",children:[t.jsx("p",{className:"mb-3 break-all font-mono text-label text-muted-foreground",children:b.revision}),t.jsx("pre",{"aria-label":`Version ${b.version} configuration`,className:"max-h-[520px] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:JSON.stringify(b.definition,null,2)})]})})]},b.revision))})]})}):t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No versions were returned for this agent."}),c&&t.jsx(en,{problem:c,className:"m-4"}),o&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",disabled:u,onClick:()=>void x(o),children:u?"Loading":"Load more versions"})})]}):t.jsx(Qn,{label:"Loading versions",rows:4})}const D2=(e,n)=>e.name.localeCompare(n.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<n.id?-1:e.id>n.id?1:0),Ol=e=>[...e].sort((n,s)=>D2({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function YL(e){return e.usd===null?{total:"Unknown"}:{total:Go({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const Uv=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],rl=864e5,px=e=>Math.floor(e/rl)*rl;function Wv(e,n=Date.now()){var r;const s=(r=Uv.find(o=>o.id===e))==null?void 0:r.days;return s?new Date(px(n)-(s-1)*rl).toISOString():void 0}const F2=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function QL(e){return[`${e.completed-e.needs_review} completed`,`${e.failed} failed`,e.needs_review?`${e.needs_review} ${e.needs_review===1?"needs":"need"} review`:""].filter(Boolean).join(" · ")}function JL(e){if(e.input===null||e.cache_read===null||e.cache_write===null)return null;const n=e.input+e.cache_read+e.cache_write;return n?e.cache_read/n:null}const U2=(e,n)=>YL({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Hv=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function ni(e){return e===null?"Unknown":fr(e)}const sm=e=>e===null?"—":`${Math.round(e*100)}%`;function Gk(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function XL(e,n,s=Date.now()){if(!e.length)return[];const r=px(s),o=Math.max(r-29*rl,n?px(Date.parse(n)):r-29*rl),i=new Map(e.map(d=>[d.day,d])),c=[];for(let d=o;d<=r;d+=rl){const u=new Date(d).toISOString().slice(0,10);c.push(i.get(u)??{day:u,runs:0,completed:0,failed:0,needs_review:0,runs_with_metrics:0,tokens:0,cost_usd:null,unknown_cost_runs:0})}return c}function ZL(e,n){return{agents:e.agents,runs:{total:e.runs.total,active:e.runs.active,needsInput:e.runs.needs_input,failed:e.runs.failed,statusUnknown:e.runs.status_unknown,needsReview:e.runs.needs_review},perAgent:e.per_agent.map(s=>({agentId:s.agent_id,name:s.name,runs:s.runs})).sort((s,r)=>D2({name:s.name,id:s.agentId},{name:r.name,id:r.agentId})),cost:{usd:e.cost.usd,basis:e.cost.basis,unknownRuns:e.cost.unknown_runs},recent:n,analytics:e.analytics}}function W2({range:e,onRange:n,agent:s,agents:r,onAgent:o}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(Qo,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:Uv.map(i=>({value:i.id,label:i.label}))}),o&&r.length>0&&t.jsx(Mt,{label:"Agent",value:s??"",onChange:i=>o(i||null),className:"h-control-sm w-56",options:[{value:"",label:"All agents"},...r.map(i=>({value:i.agentId,label:i.name}))]})]})}const zf=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function H2({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const o=e.totals,i=JL(o),c=F2(o),d=U2(o),u=[{label:"Tokens",value:ni(o.tokens),notes:[`${i===null?"":`${sm(i)} of input cached · `}${ni(o.output)} output`,Hv(o),o.requests===null||o.unmetered===null?"Model request counts unavailable":o.unmetered?`${zf(o.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:Gk(e.time.wall_ms),notes:[`wall time of ${zf(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${Gk(e.time.active_ms)} active, over ${zf(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:sm(c),notes:[o.completed+o.failed?QL(o):"No run completed or failed yet"]},{label:"Cost",value:d.total,notes:[d.note]}];return t.jsxs("div",{className:te("space-y-6 transition-opacity",r&&"opacity-60"),"aria-busy":r,children:[t.jsx("ul",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:u.map(f=>t.jsxs("li",{className:"border bg-card p-5",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:f.label}),t.jsx("p",{className:"mt-3 font-mono text-2xl leading-tight",children:f.value}),f.notes.filter(Boolean).map(g=>t.jsx("p",{className:"mt-2 text-small leading-relaxed text-muted-foreground",children:g},g))]},f.label))}),t.jsx(sP,{days:XL(e.by_day,e.filter.from,s)}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(eP,{rows:e.by_harness_effort,basis:n}),t.jsx(tP,{tools:e.tools})]}),t.jsx(nP,{groups:e.by_source})]})}function Qi({title:e,children:n}){return t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsx("h3",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:e}),n]})}const B2="px-4 py-2 text-left font-normal",Or="px-4 py-2.5 align-top";function eP({rows:e,basis:n}){return t.jsx(Qi,{title:"Success by harness and effort",children:e.length?t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Success by harness and effort, table",tabIndex:0,children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Harness","Effort","Runs","Success","Tokens","Cost"].map(s=>t.jsx("th",{className:B2,children:s},s))})}),t.jsx("tbody",{children:e.map(s=>{const r=U2(s),o=Hv(s);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:Or,children:s.harness}),t.jsx("td",{className:te(Or,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),t.jsx("td",{className:Or,children:s.runs}),t.jsx("td",{className:Or,children:sm(F2(s))}),t.jsxs("td",{className:Or,children:[t.jsx("span",{className:"whitespace-nowrap",children:ni(s.tokens)}),o&&t.jsx("span",{className:"block text-label text-muted-foreground",children:o})]}),t.jsxs("td",{className:Or,children:[t.jsx("span",{className:"whitespace-nowrap",children:r.total}),r.note&&t.jsx("span",{className:"block text-label text-muted-foreground",children:r.note})]})]},`${s.harness}:${s.effort??""}`)})})]})}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs in this range."})})}function tP({tools:e}){return t.jsx(Qi,{title:"Top tools",children:e.length?t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Top tools, table",tabIndex:0,children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Tool","Calls","Errors","Error rate"].map(n=>t.jsx("th",{className:B2,children:n},n))})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:Or,title:n.tool,children:n.label}),t.jsx("td",{className:Or,children:ni(n.calls)}),t.jsx("td",{className:te(Or,n.errors>0&&"text-destructive-text"),children:ni(n.errors)}),t.jsx("td",{className:Or,children:sm(n.calls?n.errors/n.calls:null)})]},n.tool))})]})}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No tool calls in runs with metrics."})})}function nP({groups:e}){return e.some(n=>n.source!=="live"&&n.runs>0)?t.jsx("p",{className:"font-mono text-small text-muted-foreground","aria-label":"Runs by source",children:e.map(n=>`${n.source==="live"?"Run here":`Imported from ${n.source}`}: ${zf(n.runs,"run")}`).join(" · ")}):null}const wg=e=>Math.max(0,e.runs-e.completed-e.failed);function Kk(e){if(e<=0)return 1;const n=10**Math.floor(Math.log10(e));return[1,2,5,10].map(s=>s*n).find(s=>s>=e)}const jg=e=>e.slice(5);function sP({days:e}){const n=e.some(d=>d.runs>0),s=t.jsxs(t.Fragment,{children:[t.jsx(zT,{className:"size-4","aria-hidden":!0}),"Run activity"]}),r=t.jsxs(t.Fragment,{children:[t.jsx(GT,{className:"size-4","aria-hidden":!0}),"Token usage"]});if(!n)return t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[t.jsx(Qi,{title:s,children:t.jsxs("p",{className:"flex min-h-[220px] items-center justify-center px-5 py-6 text-center text-body text-muted-foreground",children:["No runs started in this range",e.length?" in the last 30 days":"","."]})}),t.jsx(Qi,{title:r,children:t.jsx("p",{className:"flex min-h-[220px] items-center justify-center px-5 py-6 text-center text-body text-muted-foreground",children:"No token usage in this range."})})]});const o=Kk(Math.max(...e.map(d=>d.runs))),i=Kk(Math.max(...e.flatMap(d=>d.tokens===null?[]:[d.tokens]),0)),c=[{key:"completed",label:"Completed",className:"bg-muted-foreground",of:d=>d.completed},{key:"failed",label:"Failed",className:"bg-destructive",of:d=>d.failed},{key:"other",label:"Other",className:"bg-border-strong",of:wg}];return t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-small text-muted-foreground",children:`Per day, ${e[0].day} to ${e.at(-1).day} (UTC)`}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[t.jsx(Qi,{title:s,children:t.jsxs("figure",{className:"p-5",children:[t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-small",children:[t.jsx("span",{className:"font-semibold",children:"Runs"}),c.map(d=>t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx("span",{className:te("inline-block size-2.5 ",d.className),"aria-hidden":!0}),d.label]},d.key))]}),t.jsx(Vk,{days:e,top:o,label:"Runs per day",stack:d=>c.map(u=>({className:u.className,value:u.of(d)})),readout:d=>[`${d.runs} ${d.runs===1?"run":"runs"}`,`${d.completed} completed · ${d.failed} failed · ${wg(d)} other`]})]})}),t.jsx(Qi,{title:r,children:t.jsxs("figure",{className:"p-5",children:[t.jsxs("figcaption",{className:"mb-2 text-small font-semibold",children:["Tokens",e.some(d=>d.tokens===null)&&t.jsx("span",{className:"ml-2 font-normal text-muted-foreground",children:"? means unavailable"})]}),t.jsx(Vk,{days:e,top:i,label:"Tokens per day",format:ni,stack:d=>[{className:"bg-primary",value:d.tokens}],readout:d=>[`${ni(d.tokens)} tokens`,Hv(d)??`${d.runs} ${d.runs===1?"run":"runs"}`]})]})})]}),t.jsxs("details",{className:"border bg-card px-5 py-3",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Per day, table",tabIndex:0,children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Day","Runs","Completed","Failed","Other","Tokens"].map(d=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:d},d))})}),t.jsx("tbody",{children:e.map(d=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:d.day}),t.jsx("td",{className:"pr-4",children:d.runs}),t.jsx("td",{className:"pr-4",children:d.completed}),t.jsx("td",{className:"pr-4",children:d.failed}),t.jsx("td",{className:"pr-4",children:wg(d)}),t.jsx("td",{className:"pr-4",children:d.tokens===null?"Unknown":d.tokens.toLocaleString("en-US")})]},d.day))})]})})]})]})}function Vk({days:e,top:n,label:s,stack:r,readout:o,format:i=c=>c.toLocaleString("en-US")}){const[d,u]=p.useState(e.length-1),f=Math.min(d,e.length-1),g=j=>{var E;const k=j.key==="ArrowRight"?Math.min(f+1,e.length-1):j.key==="ArrowLeft"?Math.max(f-1,0):j.key==="Home"?0:j.key==="End"?e.length-1:-1;k<0||(j.preventDefault(),u(k),(E=j.currentTarget.querySelectorAll('[role="listitem"]')[k])==null||E.focus())},[y,v]=p.useState(null),[h,x]=p.useState(null),b=e.find(j=>j.day===(y??h));return t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex w-10 shrink-0 flex-col justify-between text-right font-mono text-micro text-muted-foreground",style:{height:140},"aria-hidden":!0,children:[t.jsx("span",{children:i(n)}),t.jsx("span",{children:i(n/2)}),t.jsx("span",{children:"0"})]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":s,onMouseLeave:()=>v(null),onKeyDown:g,children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-border","aria-hidden":!0}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-border","aria-hidden":!0}),e.map((j,k)=>{const E=r(j),N=E.some($=>$.value===null),S=E.filter($=>$.value!==null&&$.value>0);return t.jsxs("div",{role:"listitem",tabIndex:k===f?0:-1,"aria-label":`${j.day}: ${o(j).join(", ")}`,onMouseEnter:()=>v(j.day),onFocus:()=>{x(j.day),u(k)},onBlur:()=>x(null),className:"group relative flex h-full min-w-0 flex-1 flex-col items-center justify-end focus-visible:outline-focus focus-visible:outline-ring hover:bg-accent/60 focus-visible:bg-accent/60",children:[N&&t.jsx("span",{"aria-hidden":!0,className:"font-mono text-small text-muted-foreground",children:"?"}),t.jsx("div",{className:"flex w-full max-w-6 flex-col-reverse gap-0.5",children:S.map(($,_)=>t.jsx("div",{className:$.className,style:{height:Math.max(1,Math.round($.value/n*(140-2*(S.length-1))))}},_))})]},j.day)})]}),t.jsxs("div",{className:"mt-1 flex justify-between font-mono text-micro text-muted-foreground","aria-hidden":!0,children:[t.jsx("span",{children:jg(e[0].day)}),e.length>2&&t.jsx("span",{children:jg(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:jg(e.at(-1).day)})]}),t.jsx("div",{"aria-label":`${s} readout`,className:"mt-2 min-h-16 break-words font-mono text-label text-muted-foreground",children:b?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block font-semibold text-foreground",children:o(b)[0]}),o(b).slice(1).map(j=>t.jsx("span",{className:"block",children:j},j)),t.jsx("span",{className:"block",children:b.day})]}):"Hover or focus a day for its figures."})]})]})}const fn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Df=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function rP(e){const n=new Map;let s=0;const r=d=>{throw Object.assign(new Error(d),{offset:s})},o=()=>{for(;s<e.length&&`
588
+ \r`.includes(e[s]);)s++},i=()=>{const d=s;for(s++;s<e.length&&e[s]!=='"';)e[s]==="\\"?s++:e.charCodeAt(s)<32&&r("a string cannot hold a raw line break or control character"),s++;s>=e.length&&(s=d,r("this string is not closed")),s++;try{return JSON.parse(e.slice(d,s))}catch{return s=d,r("this string has a bad escape")}},c=d=>{o();const u=s;let f;const g=e[s];if(g==="{"){s++;const y={};if(o(),e[s]==="}")s++;else for(;;){o(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const v=i();if(o(),e[s]!==":"&&r("expected : after the key"),s++,y[v]=c(`${d}/${Df(v)}`),o(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=y}else if(g==="["){s++;const y=[];if(o(),e[s]==="]")s++;else for(;;){if(y.push(c(`${d}/${y.length}`)),o(),e[s]===","){s++,o(),e[s]==="]"&&r("a trailing comma before ]");continue}if(e[s]==="]"){s++;break}r("expected , or ] after the value")}f=y}else if(g==='"')f=i();else{const y=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));y||r(s>=e.length?"the text ends before the value":"expected a value"),s+=y[0].length,f=JSON.parse(y[0])}return n.set(d,{start:u,end:s}),f};try{const d=c("");return o(),s<e.length&&r("text after the end of the JSON"),{ok:!0,value:d,spans:n}}catch(d){return{ok:!1,error:{message:d.message,offset:d.offset??0}}}}function oP(e,n){let s=1,r=-1;for(let o=0;o<Math.min(n,e.length);o++)e[o]===`
589
+ `&&(s++,r=o);return{line:s,col:n-r}}function q2(e,n){let s=e;for(const r of n.split("/").slice(1)){const o=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(o)];else if(fn(s))s=Object.prototype.hasOwnProperty.call(s,o)?s[o]:void 0;else return}return s}const G2=new Set(["judge","pick","sift","route"]),Yk=["jev","parallel","openrouter"];function aP(e){return!fn(e)||!fn(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!fn(s))return[];const r=typeof s.description=="string"?s.description:n;return Array.isArray(s.enum)?[{id:n,type:"choice",text:r,options:s.enum.map(String)}]:s.type==="boolean"?[{id:n,type:"noul",text:r}]:s.type==="integer"?[{id:n,type:"score",text:r}]:[{id:n,type:"choice",text:r}]})}function Bv(e,n,s){const r=q2(e,n);if(!fn(r))return{decision:!1};const o=r.node,i=s??{},c=o==="route"&&typeof r.valuePath=="string",d=typeof o=="string"&&G2.has(o)&&!c||Array.isArray(i.questions);if(!d)return{decision:!1,...o==="call"&&typeof r.tool=="string"?{tool:r.tool}:{}};const u=typeof i.provider=="string"?i.provider:typeof r.provider=="string"?r.provider:"jev",f=typeof i.model=="string"?i.model:typeof r.model=="string"?r.model:void 0,g=fn(e)&&fn(e.schemas)?e.schemas:{};let y=[];Array.isArray(i.questions)?y=i.questions.map(x=>({id:x.id,type:x.type==="choice"||x.type==="score"?x.type:"noul",text:x.instructions||x.id,...x.options?{options:x.options}:{}})):o==="judge"||o==="sift"?y=typeof r.out=="string"?aP(g[r.out]):[]:o==="pick"?y=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:o==="route"&&(y=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:fn(r.branches)?Object.keys(r.branches):[]}]);const v=Array.isArray(i.images)?i.images.map(String):fn(r.images)?Object.keys(r.images):[],h=fn(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:d,provider:u,model:f,questions:y,...v.length?{images:v}:{},web:u==="parallel",...h?{unsure:h}:{}}}const iP=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function lP(e){const n=[],s=(d,u)=>n.push({path:d,message:u,severity:"error"}),r=(d,u)=>n.push({path:d,message:u,severity:"warning"});if(!fn(e))return s("","the workflow is a JSON object"),n;e.v!==2&&s("/v",'the workflow format is "v": 2'),(typeof e.name!="string"||!e.name)&&s("/name","the workflow needs a name");const o=fn(e.schemas)?e.schemas:{};fn(e.input)&&typeof e.input.schemaId=="string"&&!o[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),fn(e.output)?typeof e.output.schemaId=="string"&&!o[e.output.schemaId]&&s("/output/schemaId",`no schema "${e.output.schemaId}" in schemas`):s("",'the workflow needs an output: { "schemaId": ..., "path": ... }');const i=new Map,c=(d,u)=>{if(!fn(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!iP.has(f)){s(`${u}/node`,typeof f=="string"?`"${f}" is not a node kind`:'a node names its kind in "node"');return}f!=="chain"&&(typeof d.label!="string"||!d.label?s(u,`a ${f} node needs a label`):i.has(d.label)?r(`${u}/label`,`the label "${d.label}" is also used at ${i.get(d.label)}; receipts name nodes by label`):i.set(d.label,u));const g=(v,h)=>{d[v]===void 0&&s(u,`a ${f} node needs ${v} (${h})`)},y=v=>{typeof d[v]=="string"&&!o[d[v]]&&s(`${u}/${v}`,`no schema "${d[v]}" in schemas`)};switch(f){case"chain":!Array.isArray(d.steps)||!d.steps.length?s(u,"a chain needs steps"):d.steps.forEach((v,h)=>c(v,`${u}/steps/${h}`));break;case"parallel":!Array.isArray(d.branches)||!d.branches.length?s(u,"a parallel node needs branches"):d.branches.forEach((v,h)=>c(v,`${u}/branches/${h}`));break;case"map":g("itemsPath","where the items are"),g("as","where the results go"),c(d.body,`${u}/body`);break;case"loop":g("until","when it stops"),g("maxIters","a bound"),c(d.body,`${u}/body`);break;case"workflow":fn(d.workflow)?c(d.workflow.root,`${u}/workflow/root`):s(u,"a workflow node embeds its workflow");break;case"call":g("via","tool, executor or shell"),d.via==="tool"&&g("tool","the tool's name");break;case"code":typeof d.code!="string"&&s(u,"a code node needs code");break;case"escalate":g("when","the predicate that fires it"),g("kind","the review it asks for");break;case"judge":case"sift":g("out","the questions' schema"),y("out"),g("as","where the answers go");break;case"pick":g("itemsPath","the options' list"),g("as","where the pick goes");break;case"agent":case"decide":case"extract":y("out");break}if(f==="route"){if(!fn(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[v,h]of Object.entries(d.branches))fn(h)?c(h.body,`${u}/branches/${Df(v)}/body`):s(`${u}/branches/${Df(v)}`,`branch "${v}" is an object with a body`);typeof d.valuePath!="string"&&d.instructions===void 0&&s(u,"a route asks by instructions (and state), or reads a valuePath"),fn(d.unsure)&&fn(d.branches)&&typeof d.unsure.branch=="string"&&!(d.unsure.branch in d.branches)&&s(`${u}/unsure/branch`,`the unsure branch "${d.unsure.branch}" is not one of the branches`)}if(G2.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!Yk.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${Yk.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),fn(d.images))){const v=JSON.stringify(d.state??{})+JSON.stringify(d.instructions??"")+(typeof d.out=="string"?JSON.stringify(o[d.out]??{}):"");for(const h of Object.keys(d.images))v.includes(h)||s(`${u}/images/${Df(h)}`,`the image token "${h}" must appear in the state or a question, or the model never sees it`)}};return e.root===void 0?s("","the workflow needs a root node"):c(e.root,"/root"),n}function Qk(e,n){for(let s=n;;s=s.slice(0,s.lastIndexOf("/"))){const r=e.get(s);if(r)return r;if(!s)return}}function cP(e,n,s){let r=null,o=1/0;for(const i of n){const c=e.get(i);c&&c.start<=s&&s<=c.end&&c.end-c.start<o&&(r=i,o=c.end-c.start)}return r}function dP(e){const n=vl(e),r=n.nodes.map(i=>Bv(e,i.path,i)).filter(i=>i.decision),o=[...new Set(r.map(i=>i.provider??"jev"))];return`${n.nodes.length} nodes · ${r.length} ${r.length===1?"decision":"decisions"}${o.length?` · ${o.join(", ")}`:""}`}const rm=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,Jk=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Td=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function Rd(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,Bv(e,s.path,s)]))}const ff=e=>e>=.995?"1.00":e.toFixed(2);function bl(e){var d;if(e.status==="failed")return"failed";if(e.status==="cancelled")return"interrupted";const n=e.answers??{},s=e.action;if(((d=e.rule)==null?void 0:d.kind)==="route"&&s&&typeof s=="object"&&(s.taken||s.branch)){const u=n.branch,f=u&&u.type==="choice"?u.confidence:void 0;return s.unsure?`${s.taken} (unsure)`:`${s.taken??s.branch}${f!==void 0?` ${ff(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const o=u=>{const f=n[u];return f.type==="choice"?`${K2(e,u,f.choice)} ${ff(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${ff(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${ff(f.confidence)}`:f.type==="refusal"?"refused":"box"};if(r.length===1)return o(r[0]);const i=u=>{const f=n[u];return f.type==="noul"?Math.abs(f.noul-.5)*2:"confidence"in f&&typeof f.confidence=="number"?f.confidence:1},c=r.reduce((u,f)=>i(f)<i(u)?f:u,r[0]);return`${c} ${o(c)}`}function K2(e,n,s){var i,c;const r=(i=e.questions)==null?void 0:i[n],o=e.kind==="pick"&&(r==null?void 0:r.type)==="choice"?(c=r.criteria)==null?void 0:c[s]:null;return typeof o=="string"&&o?o:s}const V2=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function uP(e,n,s){var y,v;const r=(v=(y=e.nodes[n])==null?void 0:y.items)==null?void 0:v.find(h=>h.index===s),o={};if(!r)return o;const i=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(h=>[h.path,h.kind])),d=V2(e.graph,n).filter(h=>!i.has(c.get(h)??""));let u=-1;d.forEach((h,x)=>{const b=e.decisions.filter(k=>k.node===h&&k.item===s),j=e.effects.filter(k=>k.node===h&&k.item===s);!b.length&&!j.length||(u=x,b.some(k=>k.status==="failed")||j.some(k=>k.status==="failed")?o[h]="failed":b.some(k=>k.status==="cancelled")?o[h]="review":j.some(k=>!k.endedAt)?o[h]=j.some(k=>k.status==="stopped")?"stopped":"working":o[h]="done")});const f=rm(r.status)??"pending";let g=!Object.values(o).includes("working");return d.forEach((h,x)=>{o[h]||(x<u||f==="done"?o[h]="done":f==="working"?(o[h]=g?"working":"pending",g=!1):f==="pending"?o[h]="pending":o[h]="not-run")}),o}function fP(e,n){var g,y,v;const s={},r=[],o={};let i=null;const c=new Map(e.graph.nodes.map(h=>[h.path,h.kind]));for(const[h,x]of Object.entries(e.nodes)){const b=rm(x.status);b&&(s[h]=b),x.branch&&r.push(`${h}/branches/${Jk(x.branch)}/body`),x.items&&(o[h]=x.items.map(j=>({index:j.index,status:rm(j.status)??"pending",label:ad(e,h,j.index),...qv(e,h,j)}))),x.status==="escalated"&&c.get(h)==="escalate"&&(i=h)}const d={},u=h=>/\/body(\/|$)/.test(h)&&e.graph.nodes.some(x=>x.kind==="map"&&h.startsWith(`${x.path}/body`));for(const h of e.decisions){if(!h.node||h.item!==null||u(h.node))continue;const x=bl(h);x&&(d[h.node]=x)}if(n&&n.item!=null&&c.get(n.path)==="map"){Object.assign(s,uP(e,n.path,n.item));const h=((v=(y=(g=e.nodes[n.path])==null?void 0:g.items)==null?void 0:y.find(x=>x.index===n.item))==null?void 0:v.branches)??{};for(const[x,b]of Object.entries(h)){const j=`${x}/branches/`,k=`${j}${Jk(b)}/body`;for(let E=r.length-1;E>=0;E--)r[E].startsWith(j)&&r.splice(E,1);r.push(k);for(const E of e.graph.nodes)E.path.startsWith(j)&&!(E.path===k||E.path.startsWith(`${k}/`))&&(s[E.path]="not-run")}for(const x of e.decisions)if(x.node&&x.item===n.item&&x.node.startsWith(`${n.path}/body`)){const b=bl(x);b&&(d[x.node]=b)}}if(e.run.paused){for(const[h,x]of Object.entries(s))x==="working"&&(s[h]="held");for(const h of Object.values(o))for(const x of h)x.status==="working"&&(x.status="held")}const f={};for(const[h,x]of Object.entries(e.nodes))x.model&&(f[h]={model:x.model,...x.tier?{tier:x.tier}:{}});return{status:s,taken:r,items:o,fired:i,verdict:d,meta:Rd(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const kg={accept:"good",accepted:"good",approve:"good",approved:"good",valid:"good",pass:"good",auto:"good",agree:"good",ok:"good",clear:"good",low:"good",review:"warn",hold:"warn",doubtful:"warn",borderline:"warn",unsure:"warn",human:"warn",escalate:"warn",edd:"warn",medium:"warn",second_look:"warn",disagree:"warn",reject:"bad",rejected:"bad",decline:"bad",declined:"bad",invalid:"bad",fail:"bad",deny:"bad",high:"bad",block:"bad"},mP=e=>{if(!e)return;const n=e.toLowerCase();return kg[n]??kg[n.split(/[_\s-]/)[0]]??kg[n.split(/[_\s-]/).at(-1)??""]};function hP(e){if(e.status!=="answered"||!e.answers)return;const n=e.action,s=e.answers.branch;if(n&&typeof n=="object"&&n.taken&&(s==null?void 0:s.type)==="choice")return{p:s.confidence,note:`${e.kind} confidence`};let r;for(const[o,i]of Object.entries(e.answers)){const c=i.type==="noul"?{p:Math.max(i.noul,1-i.noul),note:`${o}: ${i.noul>=.5?"yes":"no"}, P(yes) ${i.noul.toFixed(2)}`,sure:Math.abs(i.noul-.5)}:i.type==="choice"||i.type==="score"?{p:i.confidence,note:`${o} confidence`,sure:i.confidence-.5}:void 0;c&&(!r||c.sure<r.sure)&&(r=c)}return r&&{p:r.p,note:`least sure: ${r.note}`}}function qv(e,n,s){const r=V2(e.graph,n),o=v=>v?r.indexOf(v):-1,i=e.decisions.filter(v=>{var h;return v.item===s.index&&!!((h=v.node)!=null&&h.startsWith(`${n}/body`))}).sort((v,h)=>o(v.node)-o(h.node));let c,d;const u=Object.entries(s.branches??{}).sort(([v],[h])=>o(v)-o(h));if(u.length)[d,c]=u[u.length-1];else{const v=i.filter(h=>{var x;return h.status==="answered"&&((x=h.action)==null?void 0:x.taken)}).at(-1);v&&(c=v.action.taken,d=v.node??void 0)}const f=d&&i.filter(v=>v.node===d).at(-1)||i.filter(v=>v.status==="answered").at(-1),g=f?hP(f):void 0,y=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":mP(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...y?{tone:y}:{}}}function ad(e,n,s){var d,u;const r=(u=(d=e.nodes[n])==null?void 0:d.items)==null?void 0:u.find(f=>f.index===s);if(r!=null&&r.label)return r.label;const o=e.effects.find(f=>{var g;return f.item===s&&!!((g=f.node)!=null&&g.startsWith(`${n}/body`))}),i=o==null?void 0:o.input,c=(i==null?void 0:i.path)??(i==null?void 0:i.url);return typeof c=="string"?c:void 0}function Y2(e=[]){const n={total:e.length,done:0,working:0,failed:0,review:0,pending:0};for(const s of e)s.status==="done"?n.done++:s.status==="working"?n.working++:s.status==="failed"?n.failed++:s.status==="needs_review"||s.status==="escalated"?n.review++:n.pending++;return n}function Q2(e){const n=e.decisions.filter(s=>s.cost_usd===null).length;return{usd:e.totals.cost_usd??e.decisions.reduce((s,r)=>s+(r.cost_usd??0),0),unknown:e.totals.cost_usd===null?n:0}}const Ml=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,ol=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function yl(e){const n=Math.max(0,Math.floor(e/1e3)),s=Math.floor(n/60);return s?`${s}m ${String(n%60).padStart(2,"0")}s`:`${n}s`}const pP=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return Td(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function gP(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function xP(e){const n=e.content_type??"";return n.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":n.startsWith("text/")||n.includes("json")?"text":"download"}function J2(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const X2="The agent finished without writing an answer.",Xk=[0,250,1e3],vP=e=>new Promise(n=>setTimeout(n,e));function Z2(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const eC="30d",Zk=10,bP=["queued","working","input_required","paused"];function yP({agent:e,v2:n,now:s=Date.now,stats:r}){const[o,i]=p.useState(eC),[c,d]=p.useState(r??null),[u,f]=p.useState(null),[g,y]=p.useState(!0),[v,h]=p.useState(0),x=p.useRef(0),b=p.useRef(!0);p.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const j=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{const N=`${o}/${v}`;if(k.current===N)return;const S=++x.current;if(j.current===N){k.current=null,f(null),y(!1);return}k.current=N,y(!0),f(null),(async()=>{for(const[$,_]of Xk.entries()){if(_&&await vP(_),S!==x.current||!b.current)return;try{const O=await n.statsOver({from:Wv(o,s()),agent:e.agent_id});if(S!==x.current||!b.current)return;const M=!(O.runs.status_unknown>0);if(d(O),j.current=M||$===Xk.length-1?N:null,M)break}catch(O){S===x.current&&f(Gt(O));break}}S===x.current&&(k.current=null,y(!1))})()},[n,e.agent_id,o,v]),p.useEffect(()=>{const N=new AbortController,S=$=>({status:$,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(bP.map($=>n.listAgentRuns(e.agent_id,Zk,null,S($)))).then($=>{if(N.signal.aborted)return;const _=$.flatMap(O=>O.status==="fulfilled"?O.value.runs:[]).filter(O=>!Td(O.status));for(const O of _.slice(0,Zk)){let M=`${O.status}/${O.state}`;M2(n,O.run_id,{signal:N.signal,onPage:P=>{const A=`${P.status}/${P.state}`;A!==M&&(M=A,h(R=>R+1))}}).catch(()=>{})}}),()=>N.abort()},[n,e.agent_id]);const E=c==null?void 0:c.analytics;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(W2,{range:o,onRange:i,agent:null,agents:[]}),u?t.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",u]}):!c||!E?t.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):E.totals.runs?t.jsx(H2,{a:E,basis:c.cost.basis,now:s(),refreshing:g}):t.jsx("div",{className:"border px-4 py-12 text-center",children:t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const Gv=["codex","codex-cli","claude","claude-cli","cursor","other"],tC="agentrun.coding-agent.v1",Ng="agentrun:coding-agent",Sg={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function e0(){try{const e=localStorage.getItem(tC);return Gv.includes(e)?e:""}catch{return""}}function wP(e){try{localStorage.setItem(tC,e)}catch{}}function jP(e,n){const s=encodeURIComponent(n),r=e==="codex"?`codex://new?prompt=${s}`:e==="claude"?`claude://code/new?q=${s}`:e==="cursor"?`cursor://anysphere.cursor-deeplink/prompt?text=${s}`:null;return r&&r.length<=8e3?r:null}const kP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGgAAABoCAYAAAAdHLWhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAJnFJREFUeAHtfQuYFdWV7tpVdc7pprvpppvuhm4ejQ9AQQFFUEEUfAUVH4k448TRuT4y0UnumGiSm0y8YuZO8jlXRx0fMXGi5rtqfIyj8YWiKCoEQcGAgAEabZAG+km/+/Q5VXvfvXftvWtV9ek3oM7X6/uqq07Vrl1V699rrX+vvasaYFiGZViGZViGZViGZViG5VAKUUs3YYyRPs77byNftYfRoDCxLFu2zHrr/ZEV444Zd9KMU046c0Qia+LY8lETxx41ojDZBJ07d1Y3Upr4/NNNm/+8v7ltbePW97atWnV3faQuCl9j+aoAJO7D4osnfpz3rbumXvY3139/2nEjLystJmNLcgEcruYEL+F2AaRdBhYhEIurE7IAmjoB2rvA27ItvW3NB5UPH9j8zBNPPnlHS7Tur5t8FQCywW/l7Lqb18775lWz758xxZmVx23IdoEdqALYvYeR2gYG7a0WpDhAHi9NuMpj/MxEgkFBPsDYMYSOmwRQOBqsZAKgsh68lSv3/8d/PXH/P61f+asGfB34GsmXCZC4tlCae8bSXxbfdNOtLy08NXZqIQdlbyXQjzeBVX2AkXQXAeLwgrykxUGx+ULUXTOuasoXz/MXsTsvh8JRFRadOQsguwSsXdyGXnix5ue3/f2Yf1HXdcQ14WsiXxZAxu384M5d/+Paq496dOoogM82QXrteog1cqU6XI2xGC8kgFFRSQDUmwjT8LjqXdevfGI50HlnALVKwHlrE1Q98/DT855+9Mp9/BB3jpCCr4F8GQCZ4P2715IvXLIocaldw9x3VhLrizqwBDBxR1mKAgTj0hdIWlzuzFIpv/wJxzF39unE2doG8MhDm77xwC9mvgEBGZH39J3v/MbZsSNuFxfvps89t0xYGM1w3wBH2EUeaYAMOL9/vfOTy8/Mmr5nM3StWQOJLq6OrIQCBhQQiGhrt0aEeqyeb1y4PcPd+Jpy19fFgSouYvSsMxltyrOct95q/vG67ZtXxtrot06dN/f0xIiuieXl+QWeBTE3Ce7Bxtb21nZSR7vaN77x9qdv19R9sGbV0z+tij4DHAE5kgAZt/bY8uTmK+YnTvhkDU19vNWKC1AS8QAUguKMpf702Cnqh1BhTWkek3gDmH8apBLlEE/yfUWcXMSEmrm90JQPprwct2DC76eL/05zF9vCj23fBbtXvL3ryVUv/eb+D1f93wNwhNjhkQRIBufHXup69aLT4xdUrmepTZ+SuKDKwqVJYBA4Iu5oUIiV4a77unMGIWckyIQAQDSCslJgI/MYaWujUF9PoK3TgjQH0GMcLcpJCb94zGGQm8OguBjY+AkWKynjlWRz4pIEWPF2w0sv/9cL/7D8yRv2wmFmh0cKIAnOLb+quunGqyc+2LKddX24iSQcTgLi4vEsZT2W/7TYakCBFZKIi8v0EBIfCt0ih4hNbsq3KnFMs0KmynjMP09QeUE20imfeMTiDCaMJXTmSUDzy8HZx4F6+vnq+2777rib8TPCIZYjAZAMxouW/rr8V7/87t6RB5n7p3VE9Dsh4fjAEAWQpa1InGX5QGnrIeZP95smfbVdJg3DCDV/gm0DqKLuehHHXG55KbF0+aCNHc3YqacRr3ASOKt3wv7f3vf06S8+fmUVHAZ2eCQAEkbhPfhs8uNFUxIzN38ItKkdrDiPBw5RwChwLOXVQ8CQ8M3KRREFvS8TPma/dnWiPA3KYp8kPZsqZ4CivjkIS2NqcZVVCdJB+frYo5l7ymng1CcIPPJY1eJ7fjrpdX4K9wuQhkMkNhx+YVf/4wfzLzp34s+a9kCq+gA4mhAIQGxMCpSL6waOsizQ5dECkd897Tf1QBDdtVUy1VCwlQqxCOLhEGzY6uT9tcTa8xmhEwuod/L8UVfbBVdVr3vn/o/AB+mQsLzDDZB4FHbTj3/7WolFSj7byWzGtSX6OpoQaAsyv8VZBCkLKVxrlpEBsroMQMl9LAAL75M/iaLs4F9P7tO/1XHB9tragVRVEas0y0vPPXP0pU7h3+1Yv+q+TeDHpCGD1M9u36CFnrXk/qnjism01jpwk2nOkGzlcTJoWGYCSKQl9xBfGAmWgQh2mWBFfkPflomPi9ad4K66i7u799fYsebtnnvFNyue+v5tn80A30MOWb+HEyD56PPOueIH0ApQU8dblI4vynXI3l4GNyI6FpShHRS1XmZ2BQsJL70JgzADZxA+B19WW7KFf2Pw1D7RTRB9pnUbeGKqmneI501af9rSf8uGQ0C9DzVA2L2zs5Ytc46ZXXJFzAPalgTjnhQ5khtC8WLbgAKBAl2qACR+c2QsCNgQWTManCesMLQo+uyqtQbWA+SDtGvDKsVMD1l0pjYg8oYdnYT8mTu3wjSLX/p333td1erAEORQASTuWVi81P38G5+cdPudW+/+5dLbG04Z4RbU1knSY4IuZlIe/q2UKNmUUoTuk2hQqYoNjIWtgZkC4UUCxyKMLoMZafaGGw/eDtO+0MpsxzgUDU3E2r0X0pPt2IKrvrf2LPDb1gAdcVixQxXRQqSeL7/pD6dffvk37zttdnx28QiAxn3APvgTeNX7wRFEwFFJUMzc8LYMvPrGIkTB6uHmtZJ6amm9tUCjfGy5qIFIa9NWRIPGIhbR4tLU3y+2U2I/J9fJtH/No44G2poHe29cSiaC6mrAIGQoAGmrcc++8t7Sb191/R8XL8yZG+8Ctms787ZsIXZdHS9j+3k2R4/nENQpRWkdTRrMGgUDTL6iN0AyHejrrrH1KMGdV9NZReB4yhJFukj/Fi6YKaBEtiHt+esu7s6LisDNmwjOO2s3nP/k/bNXwCBlsP5Rxxr35n/def0NNxzzSCG/+S1rIb1hA3Oa24gjAqfITgurETGE6nhj+du2orQWUpDk5BDEJUmD9U4IGBfBKRzwj1u9gaTLM+hVMCC6XjkgqMHRFqP2gdqWHV1A1scbY0MjOLFsYEcdM+0XfO8KMF3lgclg+kG64dKHl6dfvGLJ6B+1VrH0H1/kAXIbOB7v6GRlgZwvIEZBtZUwlWvTWQCGagv5chZqyKFtHXsyhBozupppwXFKlu+hnEcj+wABQYN90oLAtyZPWZWH3Z8ai7IZZXllsfFN+8c9XF39chsMQgZqQQacR17p+mTeTGf6ptUste4jiIsbHZHlW4wAIEp5baUgz/Ldl2UFuS4LMTtLAagtCli42Rm3FtkXzVISBn3n6JTQaLumAZCgXZ1ae14QmzQYGjQZozSB4TfV0sGfsp7n7o4/aSmsgwdgEDIQgLRb8379ctcnJ58Qn/7eCpba+hcSF1lpEWcECrjzaNYQ9De0nQs3xZR/E4oIAaNcEmXhi2Mv1WM8UmIA7qdT0QxOn0zRWtN4bTlyG8ciBZoXAUlYURMfOaqYMu0iftqgABqIi5Ns7b6X3FdnTI7NW/ceTW3bYcUdMZ4TA5O2wWuCBuCiGmRK21Ip2tpYN/Yb0GQWuDHszgDvQy1fB/RMrs+UjcQVPWZEEUnQCscWI8FAAOnj2uXpY65PGlh8lDOyvGDbPdu2beunTYeV3h+RbO3v7znw/SlH2xds2ci6/rLTSog4o12ajCtoLYkBBMAwpXFqmeISFILIgqa98pTIo2ACgUWfA/h4xCdGz2HoHBwAdSMwdSMioMmAzGqra7g0AMZFgHuYXHhAsl0oSjrnjAJ4rh4GKP0BSMacBZfcPf68+aX/XruTup98aiWsmJ8s7AaMIgCMoN9ihx3EGKrK2Mhfa8XgNIsQ4+7ULpapDWZQtoVAk6kitW2yRypG4eoYDZ9jLDgSZ7D1GZAQ9dakQU0JY9yK7OamxvG8isMCkIw7F1/7w5dTzQy2/MWyhB9OKLcGaNHDBCGgQMUeBIy2Brmtjok6CWrtGgyKUizyZljoZzjDrBSswdR1EI1MJB4ZWhw531gSdnUQAUi7PxoAxSLuUnV25eVTQMfAIKQvgMRjeX9969qzikfDjN2fQpoPtsXi8SDOaGA0INQKhq+1t7FU8JeuzPLB6OKjk8mkn1kYkeMnHImyJj0MoN0TbuXYDTK8HTIFgG59HoMCQLRDGq487OrMgB0EwAALuzHt/ozVsCD35z8SJRb5Ls+t/BMMVPoDEJs8deqDHdw499XwdJPjuzbNwIiuwQqvmTpb68NSZiMAbGykMP3oNEybnOBAUfjTxhQ0tSSgYCQxCuvJUkJpGVUOb0eJBrYaeQs0g5tElocZnFwpQEyHFAGiCYWH4w5D9FsDzVswZS8Naii8L4DokiufmjZ2QsHx9bvBTbnEEazNTPIgwUIQQFJBFvL5VgBSQ6MHf7WYwtwZCZkisfiJ8+bE4dFnu+DzvVkwMhdMh1BIFBizqV0QBFZGIzGIRqwK95UspTxcl1xpdBFQxnrUOcaqEDghi/JP05ZHhJaznOqDMAjpM5tddsKiWzp41Y1N4BCV7NQuDOywe2MoHjHl+ig61toJMGsa4+DEoHI/g921ALt4P6GuhcDV34zzh0pBl4o7Wk9myACCzDeNLJ5SrNnH/EkBHvodpedpFsw5oGrbYxEmpvo9Hg2GQzQYHqBtdA6DgFTIcwgw0U/MyinaC4OQ3gCStjH+mNIL+bAuTfEnsPmFqANmbpQGysJkAdWqx360VSV5JbOOA+gUxs4ZgUgFiRR9U7uYi2bBxWdzmnPQp1waFNP3UXWkMwFC/AyFBjGUqlHKdzMco0rRLlI+ReXlosHDMUb9dlE9uHEwCECTc8ttaKvbWVMLhxggNueyB47lwbsklVQ+3g6y0QT1d5i2JkSt9eCcdm9+n4j4gyORq4q4tqcOYM6JMRhdkJJDyNpSPOVCzTYoBUBYKab1gg+W7ofhctE8nhc5X1uFdpdRq9OAGwsh4eviOoWowUbS2NqxZcOGZR0wCOnVxZWWzZjbwt1bV5qHCkfdiErnmDEczeRIAAhELEdvJ3JsWPcJ5f6YhSI1UQrpcglcfr4FdU18CNY2D2gemqmMg942o7MKRKEwl6AWrM9RblO7y1BL13WrJWRtyLXKuiFcRxRw8xt10hnXW2drcrt61BgcSoAst3yu5vgmhaNBwP0fpQgztxpZjoxFahZPNk+mbtxhwef70jCmkMiUiLkWB2QfZ4rHTYrD5IlpaE+qB1RWaZRIEFCRRUMuf1uBgilmllj5BIGggNSNC1sDy7DQyLZuDDptJe+R7xyZzbxZJxVe81c3r14MvoceUIK6V4AmHD/h2I7WgIEByq3Je1FAaJdGrUB5DMJA6VZVkO/AM28xyE2w0MU1yM3cESw9z4KWVtdYiAZGKyUEHFIoJWHFAbIyF7d87YohDDYmIxCtF1ssoN+RBsMQsxXeprkd7FSd61582bzXln5n9QQY4Gyf3i0I3BKPBQrUw9AW0ipB5Y1SQIGGWrVWWoJb0ec1DmzY4cK40TKZaESQhtomgPLiOJwy3ZNgGctAgGjr0BbKotuqrIesDyA4V5fHLR9n4BkJztXnS5dIgsZIILiOnqeH85CSPHFbSXYR+GSrY9XtADp/8bzNAMv6DY6qsmfhw9QjpGJYAIhptcjtmMmEuvUASm5CuEWLcwoLbXh+FeVWyeTkeYZviD9UfQvAtxbZkBZvDJOwYjTo2orNxSIMEidpCYqbpvHo+wYEqg2Bi0KWHyI9JADatFYrONfEZbUWzLctCda2rZwAd7D8f7z7J4+BX3W/RhJ6R5NYVD+UZEZKk0bhSvBcNeyONCBq00ybEqytoT0OqzamoXy0P9/Z3BAv2MjHHvNzHFg0m/BtJh/eMEELuRk70mDwNgmUSiFsZRoM3G/TDYFaEBoeMW7cDq5h4rAiMjjl1W3Ny4jOfT3vR362naQqKrKuvvja5VMA+jeJpFeAGPPabN1MWWStthmEf2sxlNQK/LsJ4vzg6AICr34g3hqgPB5BqNcvAKxuBLjwdIdbWNrPFqj7kElV3WoBWYZWaITmayVBJIYyHD+RJWgvII/b6DgJyjE7DIK0Hju4DkPXFORHWLAgStU1EG/4nLHjTj3/cfWofVpRrwDZYO22lOVIZbDACvQ+SiGUXIzmupjxg4Er0WAlaQxeWpOCskLwJ84pEISSOrvEa/a887qAQW0jDVwJsk5ALgdPyQWsZG0d6HwDHAQA4v4cTgBjxQOaU25ikR1egwLEAKOOCVcnOvuN9cQrSJBTT1n49jTohxX1CtC+zz7e4WSDn4b3gk4aBgkUSDo/ZfJaFIEEYRB17kwkR9/eaEEDZ2yFed0Jwxecdi84IQal+a58P0c2ag0KBMrGcYNhayJhy5KKRGNYeCF2AKp2Z7ivZ1lhayR2ZFvVbWtg1DQzDZIEjIPU1AJObTXvlJ9z4u3qUQkMFqDG5sb1IhUja1CdAhoFSQGBE4c0cjxkRQxC4y3xRByeWelBUV7Y8oRiXJlesWDpIgIHW6iJPVqZWAgiBdhSQswLkQPAAOgFWQ9u/ditEQ2yAsBSyjc5StukdwKgHP+3mBsoXpZuawavoKRoyYkn/m0ORKLEgACq3bF6XU4ej4sO90Cq223GPcS2+k3VWupcWZNMxXsQegEqBJgCK5ePkmyotGHL7hSUFoRjkXio6gaA6ZNiUCKsCMBkBoBEQEBWQ1BcwWxPg2eOayvAMcgJAwNI0QQdt/S2gwCMAhP5TdQgZyoNJNkKWaUnXDwP+pDeACIb3v/l/pZGWsn9JxEzKOUYu+gLKxCkxWAg3AAQ3XfAw8HYFRpQxblcC9t2URiRiFgR+BZpczo+MseV1wpZYERMpgEChTMdxC20D1DMsgLL0C8u430hpueErUgDJdwadm16keWVdem1iEVpD6wW3vAKSucugSEAJJ9z9859f8jLkS8+U0+BRFWyysxk0UBhkNwABJppUeVF4CyIp+CSBXGobYDQDFEBcC6nqO1JBl/UJuS3eQYqBMKxCMcjs88OCAFB4BilEghPV8ZWprP72OUh4KSFOYEl2eq6Hbz7UFQy5vS+7t/q6/kqN/zx/uwcoIkYE5MffGtQn1thePH8aUauOm4sy0WWQgPANHE4UE/hynP9ptzmQeiFKlHPGM7wXlnL3RvXIKE93GQPS6gMge5v2OkFUAxT4OGUkLYczPB07DFgOAEY2vXplwOsqKuUTJa3+K5YGSx91h4SQOtXfq/hQEPXyyNGyPbC3DSyHGRRFA2iMC+wLJfqYB+U028EtLYDTB6TgjnHxaGaDzc46G5E+ZJ8kfrx4PUPCBTkEDNpMBTLFDHBmeVoRzrUjckEFCIL+riNAj/DrlCD5UDYPVp+eccKGJ8ua1vB6/7G/fEbzM6DghObd2fBEACSpGnrh+/dNLqcu5sY9SgHSIDkaoDwkg62pVWlg7W2Km1hAqSDB124fokDbZ1BXwa0cnnZAs5xHl+e5vm7WACsjmkAoVFWPegWGvVkwRhPKPcWWXS/qqdXH80YGKjF6oEoKOuzrWBeOmirQhYHxFBwO4e0J2AIAMkybz563r7Pd9Y/UlRKHIePuXmcTjH16RRXKV66Pa18D7m5TIDxcrU8U7BgBk+Yljqw/6B/86ZV8PNECmjz5ynYuN2B3GwIJhHSIMYBcp9Aw/TdiO5QM8g8oR6BpIchzILHvlBsCQFFwsdkPFPuzYrsxzNuBTPmwDodMdHTHBpA4r6tB3704Hfjo0hLQYFncaXQtLIYoXRhVbKFp4P45LrBtgFKrcU+2pWEv70gBjVN4H8bR+uTayvGf2TFKfzuRQqjChz/OjRC25VVGFdnxq7D2Y2eGF+/RNF5GulPmYwCQIgN4o9xMBSfQLlOQMf5fos3ds/yrF5n+wxg8GgZ/eiNhbMXXLJgR6rddQ82O5aLTV3CiG5c3Zh2GR5qUfsOULjuEp4QHWFLgMSkClFU6FmAV1EG8OrqFOytj0NZsQ+scT8QDvhMtWiT4VYxL+XqnUydi2iD2GfySpChK+8jw9O0EHOInDehwTJg20F/zkx4VPciZsPqGbVyjp96dvNpGmLikhuXMwRhyACJqmPP/+bMnQXl1d+eMrXsybYNqVRHMh63dD+DRFoTRQpVYIlWmOTKLslNwsVnZUFVrZ8Y1QoWD1TAO67t7R488RpA8SjLd4mW0aWxeV2vRQNwhDQ0M8jP9WDaeNFaPePCCMFIIIBQnaIAIb7JieOizgMNNuyuZVA4yjFv/ZmUFVK6mb1Kgt8yUUzBvNWu45SMa478tExrdifpOBQACRFd1Njv/nf5U3998/uTR5fOv731CxAfSCYGDEOVUALT8uGVGIlh7WoX7rzF5rk1S7Z029Yq811iSQnAvz/ZxVlctnRbMocatRh1HR30ia9baKijcP4pKbjqG3HeOnWEHqowWLc9Db992ZPjWJCJ6uvnRiDpacy6D4bfuRVr2xZK8WpWrVrm9nb1gT6B/AbNnt3xN3JHwe08nhCqrcWCHj/4INaiXCdvK3OOd2H29ARU7vdjjxYRX8pGAezdn4Ll7zswroxItohdpragUJ9GtX5R97QKF665IIu7Rv7bhW4fqRiwqNTE3ClxaG5LwdPvWlA4koQOyzXL5CZ9wczU3DK/5+xcniSubfoA+pD+kIRuUl5e+jftB/0WIqk1WlxNFNIBUfDUB/Oa6l04f76wHgLY92uXIdjaXb/zIC8v7neE02FWaDrBbkDV5X5+vKkpDUvmUTlM0eH6iUnbGuKiMgT7GxnMmxaDhO2aqcC6DyZB6MbZA4kQSvmsvGGynFzezfhi43LoQwblAwpKJs49uJdBKkV8lmSFLcYMlkX2uSkKsbgIGv7sIz1RXoAxaQzAex91wsfb4zBxvA82VeTDxCBVj2FFJHAhjKOXzeuW04kH1ewyCPMvl+YNyuJuImbxmMbHsPQ0LylUxRtM3SkiEypGaqQEoUgkgMVHAjvwxYvv9nULg3kUEndoeVsL54gp1fmMUmtNvdMB9RbWEONDC+/+icg3GTzeGZHfGuDLqByhaAp3/YbHoCJb1ivPS6n0EeoAUzeg9h6qG0gC1m91YGS2/8E+80Iw7WNhPe8THVzxJcYSnmXfy1NSjc3x4N1XTOtZOLOBBzYxSJpQZGUzy23ten/9ygcb+sJgwBZUUVGRSKcgN5303+Q2bwFYiLHpbWRFopWP5EmNP66wYM7MTjjnjGz5fRuRGrH5E//8ziS0tWfDiBE+MGbihRqoMwNo6hokco18ft5zrwLMnpqCqZPicnoxMQ4GR3AtmTpHPrUOihD57m1nisFDz3qcHToq+66smQW1mldUEDi6f6bBEY2GJ0Xc0eXEWbNi1R3qKploB7qjAcrixU+MrDjj27Xb1kJCfjlEuR3MUgAF9Eypk/01LixemIQz5mZDB4/mz73iwp79I6BkDJEP0i3lYqmqSLhOnEcTLk+0+ObmNFx2rgfTj83i1t392X06Hu4HmTUJ/xT9swMNLrz4LgOXW6iIkQY+hDfOXpgPA6LMB6OB9Y8eDTR7FKv6xdXW0eppegVowBa0p7OSTuCuWLRsmQez/BsKWYwXVrKZkqWUOabYgXfW5sIrKxn37XEoKkxAEXcjbjJidRoMADPNyYCFjoltTx3Lz4/B82868NSrIshbBlgdJ/GXhYXoeBWySNXjF/dtc5RGceaW7QSzjwh67m6ZWe3iIpYjAMrNglTJOIi/98pb16rSfeY4BgxQ194n0ha5LcmYlSU/Z2whZQJkTjhqhSrgRJDlNwt52cQoOpUOl7eQO9OdPNP/wUolgQXprHP+CL6RgxoFIFKBrT1q4XYAQAAY8TPmqaAuxb4DGo9AwiPL+lObwnIsQmlBIYm3uGzDy4+d9y5A/77fM2CAKisrU5dmWa3ciPIJH9SQL0LJJh60dN0SjVLBZy/d+jRaqRG3KFNDNChrYatEoFCkcC/aKNBC7SBumEyHumdpCPo+XWSZJAywaWQAob4NqOfQ4AihGCR/6IWVFFFaXuFYzz/6r2erMyj0QwZDs1lTfe3WRFbJ+M6WYKd2Zbprb1q9Whv/ThBYBEKukaG1cUNUVWmhcyFsOdSKKFRv6zKeX6cpC2DyZgI8CX6G+qOUHpDrDh4cjAURndpRRMFT8zaK8ll6/DQnvnJ91cK3nvtfzdBP6xEyqH5QfbLlvbyckm90NvkvMVkRhTBkNYBA0w+EJ3iEXAx03xcth11d1CKx1egpgdK6oscxG1RJXkD1GJA1mCSwGvOMAOHPeipXJkRTdeEFivK89ISpdnx3VetP/vO2SatggF8FHsQoP88kTJzbVT7xxBvqvpCdfEmIQql93dvW9673A4TeAZW7dFAFRFFVP0SWV8cJC7ZBuY5MkyfNe6deuF+ir9dtSpgK6H4y0F/rsScdQ/A9dZu8SSPxhvqWI9xl8SiaOup4O753X/Ndd9+YvwwG8fHzwVgQOUArN80qglaekc2Rg3fmSACEaeUQtF6G9ml3YlqnF5QxbxqgeCAburJGzBa1GxKCXZ1HMlgWclGYWYbIAw0sxDA9Amaut7bakFXJm/VXgq3x7gcdW+rSo0504rt2N//srpsKfgXBhw8HJIOxIFK3bZU384xbpnY1J2Z2tMq+HTE9bEW59acrAbVqhmgpnogftTZjYbgs66U1s8h5kV49Zd3LmnPUq/Q6I6B/a+vAr0Li9ynNwKFPAvzsCQcnP4+5EyuYXTHdJmveqVz88I/LHwffrWk7HZAMysUJyc2dsnPKSTNvqqniGRePty0ULLXCbe2mINjXzd1pd4jOC631fhV8Q+VpUGcUMEBlAYFlAEZrXJ++lh4D76lByASuSnMJq8vNAW9cuQuTpvPeV8zduOIPz0z/z4fO2gJD/BI9gcGJ5Fe33ul9vHk1mdFYR4h+iThasYmj2q1A2JURdIJxR3pXhNZiBkUyBW5E30NUG8LuLkTrI64LUGZCMjh0v9H74TlFNnIUsKLRQMom8PZjw/51qz647sl7T1uuahYGMKCYE5XBAiTl0us/OHlCxdyPNrzBUp0pEscftzAPz9BvQErSvwmEXxuEMKghhaPtEFAQvi5B9QFSahS0vthiiCkSNWytrD8n20uOn2xnjZ8EtKbRXbfxvRd+8drjV7yuHst8aBeGKEMBSDKSW+/qfPPzj+Pn7Nll+f+eh3SvnWTah35iZTG1HRrmRnVggM1k+Ch40N3CoLdMRw+AGdDRuXJSCycB5ZM4JbHa7n1z7e9vr1z+P3WPUFiMdqyHRAYdg8C/ESueij07e8nCHzd85pGOdp7QIGG9SNExQW2bz7uQyCEUw2Q5Chm/DxclD91iFgSxKXR9isqjOBii3hD8NufpaV3Ujz1ZfDxnwnGEvvTrHy2qXH9HBwRw9is7MBAZCkBCSFXVqvTI4qtWzjx19A31Va7b1WXZuCWHCos/UaVBGAS5mwTb3cDSCibQrZ8VAomiY3o/Kg8IFGCQkeHhKcq4P5afzwiNty5f8dxl/w9UtggOkwxmwA6LeLzYK48eu7a5s+nmWYucWG62m9IT6KO3jek2bt3dOo6IMSFCFbxApnYQ88WJoB79tSk9oT/09gXa1p+/1Ptkx1dNsNRzyimazyenMIuPlvORh7FHE9i5/eX/g3Rw2GQoMQiLpJI3/XPNXdms5JaP33HTjS08T0/Q8DMO5r3dEMl8hz3FsWiM0tcxb9qhMt2YIoGMbNCco+OiIjtiNbqEsYknkl13/5AcC/0YzxmqDNWCtMgvaDx0W+mtSWi8/bSLnFhpsec6ohF64ZgRmvyO3JyWbh1J1DfBqR7TCVU/9YeQ9NsT2sIsL3BjgHJk5n0lL5iAYl4684K0jbYuUYbT6lTFdEL+sn7/tfp24TDLobIgLZLZfftnXyyeOnHca9tWM9hTxdzWdsvRNJWQPu6G9HxTPZ1LulHC4CfebfozBIJPbUauF2V1QgQKYsRi/CTPGjuTfXj3P8TmwBH6l9NDJQlRkTHpk/fv2R5Ljfn19LNPWVJWTkrcNs9zUxZLp3mD1sE76n60YPaEpFdwIsQjREYAwp+UQYyOKPIh+16oPEWkQ35SjFtQ4ai0d9K5jvXmCw8eX125PAVHwHqEHGoL0mLGO664cfU1J8+Zd++BKiio+hRoSx2Dlg5ipfWbCTjGIGXjyYBE1WihPklGyWR9fcQwvSb4fNUh1eNb+XzIYM5iO1a1a8vCJ+49YRUMYDxnqHK4ANJ1q4FugAuv2f2dU+aO+4mXso5qrAZoPADQ2sTEP0USU5sY9/VEtm7fFcqvFIp3VrNyeSPnYDbUg9vWwd0K6U4IensKEt2IkIBu+wB1aAQ4uen0zDNjMc9pvfWen4y8Gw7xf3nsSw4nQPga5pkXXHTfseMrzvtWUdnES4vys6ekk5BP03wkwFU9X/BjlQAIsiHZlUxv9cDrSjZmnb5ljZtqbXPilPQwObGPGKaLQAamiPdTNcBYyC1n1gI71mG1/MsDP83/ORyhuBO5tSN+LeO7p01bGi+ecEbJiPyC8lQ6OY55bjaxbEosp97OGr37i4/fqN669SH5X0Ou+2ntP5eUFP/8zyuYW1tHLFdMCOoP6YA+yqDjmjk6FtCSkjSbtTBmt3W1c8vJFZZzxMGR9wZfnuDw3lc5oZz0dT88cPbYo0vfqlxPYe8uSLd1WDFRgWX3DYKpLML0hGj6L3bnZUNqwmQanzbfoutWrz/3hf+Y+zYcYbeG5csEaKAilXTa0n8rPO/cH7yZrIGTdm6itLbGYu0dYIuevhWZS9CbmHEg8CN+Tja4xWOZddwpnMDE2MZ333hq4brlV7XAlwiOkK8TQELU+9FAl9667cLpk4/7bfN+KNu/E6C+htHWNkKSKU42aNC97yknKGbEikns+XlA84uYJTqgiVGsZuum1dc8//CCN3Qx+BLcWvRev24SUtyV39+0pHzCsXfk5GTPauHssKGGQWsjYZ1JIGIypP6Yhuwo22ICv/xHVCyvAEh+KUBBGTCbuB99uP79O179/aJX1TUO+bDBYOXrCJCWEDucNe/OsqOOn3Hh6DFzLiguGXUSTUGhzSCLCmWLORM+rB4vnWRxVt/U3PnnlprNr1ZVvvPi+8t/VqfqxBN6vxLydQZISzd2KOTkk5eMyCu7ckSnW5/lxDpzWJq4+bkVLU1717atXXtPEpXXZKW/pGVYhij9bXT/HRrnsAzLsAzLsAzLsAzLsHwl5f8DGzhXq3EeY8wAAAAASUVORK5CYII=",NP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAEKCAYAAADqyxvJAAAoPUlEQVR4Ae2dW4xd5Xn3n3fv7TkYO8zE8BEUUcbfp2CjL1XGSJXakipjpF7ARWIiFYwvyiE3PdBCK8Wh3DD0ghJXSohCW/UigdwYJ1XDkAtyUSkMKrRSL5ipmsqHtPWmNAUKxJvEhxnPzF5d/zX7Hfbs2Ye13vO71vOTJh47gz17z1r/9Tz/5/AKYkrH+ceOzqzValPJ+vqMwK9EMyJJbu783zP4n6Tza/efDaEpPxGdz9P/voXPEyE+TNoi/XyjWavVWo2JleX98wstYkqFICZKzs8fmVpfmZjdaIvZmmjf3LnxZ9OPqc6HZ5JlQQKCsdxOam/Wa8kyi0i8sFBEQBYhEM1RknymIwhzFIQYKIFIZDn9dTlJklfbtdryrU+fahITNCwUAfKTx47OIVIQov05ilsU8oIoYzFJaq8i8vjU06cWiQkKFooAOPf4sdn2ejKXphBfSD5KH6pMFnWkKctLtYZYvOWpk8vEeIWFwgPSX0hDbwjDA8TCMIqmyCKO5KUDJ763QIxzWCgcAXFYW5k4kvoM93PUoM2CEOKlXRMrC2yOuoGFwiJdkcMTLA7WyETjlqdPPU+MNVgoLAAzktMK58DXgGh8h81Q87BQGCKLHi6PPZIIcaQTPTD+aKaC8eRG6mtw6dUMLBSacPQQNukF/jzV69/gyokeLBSKdAQC3sMcMcGDqgmlaQl7GWqwUBQA6cXq5ckHhGg/QqPnI5gwydISFoxisFDkQPoPbSEeJU4vygILRgFYKIbAAlEJWDBywEIxgHNfufeR1H+YJxaIqsCCMQQWih5gUraT5DliD6KqsGD0gYWiA1cxmG5QJdkQ4kHuw9ik8kKRzWBcGYdAPEoM0wP6MFLBeLLqglFpoWAfgslJ5dORSgrF6ceOztRTH4LTDKYgzbQCdriK0UWNKsZPjt/zRC1JzrNIMArM4NrBNUQVozIRxbkvH5tNautpNUPwwBZjgkpFF5WIKPAESGobSywSjEEqFV2UOqJgL4JxROmji9JGFKhopIq/xCLBOADRxdK5x44+QCWldBEF90UwPklvqGd2Ta4+WbZdnqUSCqQaqbK/Qtx+zfildKlIaVKPfzt+z/0I/4hFgvFP6VKRUggFnOcNIZ4n7rBkwmEqSY30slRFok494EdcvTKOSc8jxDDhsjA2ufpgzL5FtELBfgQTGVH7FlGmHuiyZJFgIiN7sOEBRxESnVCcPX7PkaS2wSLBxEhmcuIapsiISijQREVCvEhsWjLxMoVr+Mzxe6Pq84lGKLJ5DaJniGFKgBD09ZgqIlGYmXhDUyNoniKiNrGbxj7xS7T3tl/PPl99+y1av/ABrbfe3/pgmDQVmf/Uie89SYETvFDEKBLX/tpv0tThL2QCMYyr7/wntVcu0wcvn8o+Z6pJDGIRtFDEKBJ7Zm+n67/4pUL/DcTiZz98gX6x9Dox1SR0sahToMQoEo2p6+iGY39AorGr0H+Hr999622Zaq80z1Ks7D54iP7PPb9DyfpaGiG9RUx+EiHmHrn9/9M3X//XVylAghSKGEUCfPL35qm+51pSZWL/wcy7iO0mg0Bef/dDNH3Hkez1X5OK3t5Dt2eREgtGfkIWi+BSj1hFYjr1JOBL6AKheOtrxykWRvkxeD3vnnyWPZgChJiGBBVRxCoSCLmv+/xvkwlww62cPxt8VWQzzXqY9v7K4aGpFl7P7k99mi6m/gtSEmY0IUYWwfRRoJkqRpHADbPvrvvIJNOHP0+hc+NDx2li5mCur8V7NG0g2qoSuBdCasoKQiiytuxIm6mu/+JD2Y1gEngVeW9CH6CyU/Q1fyxNUXYfvI2Y/KApK5R2b+9CkQ3JCPEcRQhuGFs39O5bD1Go7L3tdlLBhqiWnvTeOPf4Me/b470KRdeoeJSzG41pexc9qgajGrZ8gBtdVRzxelAdYQoxlWxsvOh76tSbUGDpTOyj4mjJtgVuKoTroaFb2Rm78ZeIKUz2QMU9Q57wJhSdzVQzFDHt1UtkE5QeQ4sqJvcfIB1WuUyqykznnvGCF6HoTM1Fv77u6tt2m4my0mJAXoWKidmL7fes5BzxNXHqXCiwmTjGMmg/0OuA7kOb7J1VMw5toGpidsNTs3rg3jn7J/fcT45xKhQwZJIk+TqViEunl8gmIZVK6wYqFusXWCi0aYtnXJubzoSiy7ws1XYqdFHaJpQGrF0mhKJlzwCuEFOuzU1nQoFj/qiEey4vn3mDbIOownf/gSlTlWc+jDHTuaec4EQo4EuU9SxQeBRrDvJu36VSE0LFImEW3FOu2rytC0UZfYleLlv2KYDvBiwT//baBU47TCMEPeHCr7AuFGX0JXpxIRS+G7AaRvwJNjItMFVPEuv9FVaFolPznaGSs9I842SNnc8GrMb0PtKFUw87pCnI3NnHjs6TRRpkCYRD7SSZp4qAnZfX3HrI6o0sG7AuetitaeJ1rXtOPfAaMO4+KjK7fPoNeveFZykqkuSJc48fW7jlqZPLZAFrEUUn5agMMDUvvPIS2cZXA1bsEQVSpxsfPJ4rfcP+0hhH4pONdWspiBWhqErK0cvP//HvaOX8GbKJrwasumZEASG13cU6CLxf2GdaZCANI/EhTu8OR8zaSkGMC0WWcpSkRVuF9178NtnGRwOW7k3jaxgMvg62cRX9/qMdiU9TEBtVEONCUbWUoxc4+7ZTEB9RhW7VY8NDxQN+xMfvVF9TGGsKYqMKYlQo0FhFfMp4loLYLgXuPfTr5BLtiMLx1Cj6TkxsRY8xBUEVxHQjljGh6DRWRXPoqk2Qi7/3fbspCJ52ri7gRmTDYBCJ6+4udlrbIGJNQdCIZXIWxJhQ1BOqpIE5CPRWoMxmC5cNWEZKo46GwXAwtCmRkESagkyZnAUxIhRZNEHJA8Rs44MfnrLq9LtqwKoZqHi4KI1CJGBc2iDSFOTR9N6cIwMYEQoXLaQxAp/iw9SvsAUu3D2H7PdV6KYeLioeWZ+EQnUjL6FtG8tL3ZAdoC0UncnQOWL6YtvYvNZB+lGbnCQdbK+/sy0SEhe7R0yDe9NEVKEtFGxgDgdh9wcvnyJb6KzPz4vuDWgz7ZAiYXtfx5XUc4p1qK1mIOLXEgouh+YDy21sdmzabsAKdaEuBMyFSIAYo4kuZnTLpVpCwdFEfi688gOyhe0GrF2acx62IgrMbrja/BW5UGiXS5WFIvRoQobk+IAb7nuVHMqlNo3NUA82tiUS++68z9lhQkg58POLnKmrKxPKUYXymHnI0cSovBU/eHxgh4TLke3WKy9Z21SFqAIVEBuvR2f79tW3zQtFnlFxk9ge9HNGkjySRhXP7J9faFFBlCKKkKOJPHmrjDauv/tL9MnfnXcWbcDYtBtV6Lcs90Nn+/bqO2b9CbzGKUuvcxCXHGwwc4RyVKEkFCFHE0XzVoSvEBZXQ1aIKmy553jdLvoqimDSyNx98JBzkQArzbj9iW1sRhWFvYrCQhFyNIEIQSVvlanKtKOL0OYciOnXoF3xMORR4Pu4/otmW7PzgLKorz0alphavTz+ABWksFCEGk3gBtF9muJpdcN9D1tPRWCM2cp7TUcVOu8FRMLETSbTSdct1Ij83v++/f0irkkrII9QQQoJRajRBFprTYWkGAByUZu3ueAGohnCXIKp9fyY3vRRtfrg5RfKujl8pmi3ZrGIIkmcH47qA1yUN/3xCavOus05EHz/pr73sRtvIlVMlBQhehBv12D50OUzpTExd1B0BiS3UJz78m/NhjrTYavzD7V6fNh6OsPYtJX/mpos1fk7dH8uvszLi0uvZT+bMlN0BiR/RFGrF85rXGEzPMSTGYtZbYS+Njd3m9pXoRNR6BiZeL/33aW+xk4VXEtYD1AFRJIcyfu1uYQihn0TNs//lFURG6VHTJfaaEoCJqIK1e3buOFUoyWXMxzd4Pt9+9snylblGIgguj9vqTSXUNQjGCO3vRglK8+l5VcbJVRbTzATUYVqV6bOjkwsxPViXv6wtOblIHI3YOUSihiGv1ydQoWc2fQwks1yqW5UodqVqSrcEOK9HprGkAL6OIHNO0mS68k3Uih+sml4zFDgXHW45RlzFQiNMWxmClvlUp2oQs/ILC4UvsxLNFWV3bwcwmweU3OkUCQJRVESdX1cHSIKmJymUhGb54GoRhU6Qni14IyHT/OyjE1VRchjao4WCsrvjPoEQmFz4GoQeAKaKqHC2LRhpKlGFaor8PAaiuT6vsxLAPOyYr7EDvKYmkOFotOJaexsANvgRHEfI8GmSqg2p0tVogrV11N0mS6iMjYvvTK1sjIxO+wLhgpFktPoCAnk+j5++DIV0S2h2lrGqxJVqEZJRfwi17slJBDkn3uIQENlVKfmQKE4/2gWikSRdnSDm+zdk896EYvNU6X0SqhZE9aPwvAqVJut8kZ1GO33YV7i2kD0yXxEkpqaw9KPgUKxNjERnUhI4Ff89C/nsw1WPsDFr7MQ5+Ly61ZSqKJRhXqz1ehS9ebYuPuj+iAS8CWYHUytrQy+5wcKRYxpRzd4Mr//4rfove9/y0t0IRfiqKYitpbxIqrIK2B1iz0UvszLCxYXB0XPkKHPYR5FtBFFN3g64wniI7rQ6ea01YSFqCLvIl6VZqsrOSZG93nqvKxsU1VOhqUffYXi7PF7SiESkqxWnkYXcLl99PEjFcHYetGbw1YT1p5Dnx35vagamRsjTi3fM3u7F/Oy4k1VeRlY/egrFELUok47BgGXG95FLFURmzsrRkUVqs1Ww5bpclNV+AxqvuorFAklc1RScNG89bXjXpqzZFWkSIOWrZ0VeaIKFQaVRn2tswO+qmAxguarfn++QyiwoIYqcEwgymO+jM4iDVo2m7CGRRUNw0amr6Yq+BKu2/sjZ+rc48d2pB87hKItGnNUEaTR6aObU67by2N02mrtHhZVqLRvD1qmi0qLD1/i8uk32JdQoL2+Mdf7ZzuEoibapfQnBpHV1Z87YW0gaxQwOkctj908Ed1Og9CgqEIlRei3TBevy1dTVVU2VZmmJmjHD2yHUKBEQhUETx5fRiee7KPG1m01YQ2KKlSEojfEZ18iTvppwDah6OyeiGYIzDS40H32XIwaW7fVhNUvqmgonGDeu4Pi4x77JdiX0GKqd0fFNqHYaItKRhPdhNBzMWiDlq0mLKzD733q15Uiio8qHvAlfGyqYl/CDKKdbNOCbUIhRPtzxGTIngsf0YXcoLX74M7zLGxEFRAJ3W1d3TsoIBCIJlzDvoRBxPY9ub0exRwxW8jowkcZFRHFDcce3pGKIKqwIV44ba2bonMeeH/wPUMkrrvb/RmhAGe6si9hBkH0uZ7fb4KV/LUkOU9MX6R77yOclhOP8iZABIDSqkmTUDaiSfb/aVydjPAlOOUwS1uI/bc+faqJz7ciilq7XXl/Yhi+o4vuVMTGwUH4N0wuC3YJz3HYofuYji2hSISYI2YkvqZRe1MRG1vHZfrho1KhCs9x2KOdfGRoNuQnqWJ8JiEmDzK6QAVi+g63rclIf7B5qp/RqcvkzAFqEXnpe1CFfQmrzMhPtoSiqo1WOmRNUM2zzr0LGyIBUG2BSMQiFEi/TJyYzvSn29DMzEzsx7w6Pn6BGGWwZ8F1dGED9CFsrFzxYtoWAZu+/zstXzN2GZtcnd4/v9DKIor1iYlZnPTDqOMrujANmq9i4H9OPkuMfTqLbBYzM5M7Ms3gszJSJS4uvRbl+4toE2ljTFGn7NBsdH43Q4wxyhJdhMjm0Yt2Zl5MITtdYTpDFMbTX/H7bu8HYofXEbzgiU1DMxMKrniYx2dlpMx8aOmAJBVw48v+E4hCP0EYBKZ28QEz9sKPfhCyKTuD/5FVj8pOjNoG0cXlM0tZdHGth+UtZQIC4et0r0wMOoKwa3pf9rkJ8cchSDc+dHBzTuXlU+m18gaFRFrt+Ax+zYSCS6N2QSclVu9dPr2UHXrD0YUaLpYLyQgBY/YyQnDRsSoPRHrzqbCEgjpBhODSqFt8zozEDHJ608cX4GeBJ3rRtMEmmLcJzbfAzEeDS6NuYe9CDV0Ds9tgnNx/IBOIEBvLJtLv7eJSWEJRr9WmGu12e4qEIMYtXBnJj4qBCVHATYdIAaIQiyCvXxh9bqtrkiSZaSRUnxHUJsY9HF2MJo+BGWIKoQJea4jVD5EkUw1RS6aIMw+vcHQxmN5oIpYUQoULgY7Kp/KQRhSpWnDi4R+OLvqDkjKEACXJmFIIFVbOn6UQEZTc3EhF4mZigoGji+1AGFROg4+N0NvSa4KbrYLD9yZwxj2/WPoHChcx0yAmWGDiZU1adz+U7Ypgysda+lDAzzj0vRri7FeOnk/tihkKDOSmMKw2rlzZXAWflo1kaIZf8WdVetri7E6E4GUx7qoK9mjAi8AqQ7RrR3INN4OLKGQrK4yrPEjB6BYRKS7ZR/p5GQRGRhdYsstGZzxIYcg+0qgh1odbUBEFoogpR0/NXoGRv5cH7SKC2RKbng/f4D2qgsEXI9gInkULqagPOt09QpqpUNwbRBcFxOHmx+PYWtRPOKTgdAtN95+bvmjQS4Ct3Bxd+AM/zyvZMY+bqUSJhGEHwaQeMZ0pobOAFsIhU6C1TtQi/RcZ4eS52OSByjgIiLGPFAX8rDJhSN//Km0xC0YoapOTVAUQAeSJAuTTSQpKJjAdYZHA7GXMg/cY3kIWJaQf8BaqvtowGKHYDN/+M7344zytyjSxntoVGywK+QhGKPADe/eFZ+mTvzfPJUDGGmudwauV/zjHolCAoMqjch0YyqMMY4KylCd9E1wfxcXl17Lcm/dLMkWRaYQUhjJXIVwTZAs3TqbGOZjsVzDD6C5PSmFg7JAKhWiG1sIt/YqP33V081wENvYYYn/BI+G1cEtwEchj4+SyEqw2A9iQnP3aKTN29zXs4gak0sD+QjhEMT2KCyR7khSYsJPi0S0iUlik0Oz4vEtkWHzc05tGsDCEQ0NQ0kw6pwGVCVtzGf2Ep9//J+kWoq2v6Wku69eAJf+srtEFGhuyFRrI18xi4R8hRLipR6j0m+9wQb8Iafrw50u1p2LQoFt323tv63vvz4J9Czs0EiHe5HM9wqdfhHTpzE2VWGiTt+1dl24x6jdN3D1pnHcmpwy0k+RDjigi5ppbDxFjDhUxGrYPpXdVQcTl2yz1aBITFUg90JCWd7kPYw+ZCuYRGWxYx7GIsaVHqUfRwhbuJice8eByuQ9jFqSJWAuAhsJQz/DoR9JOWo2k3W7xkYLhg+iBT0IvBxD6PYduz/aJxBBdiHqt2RBJWh5loQgWCMT0HZ/nNKNkQPBjiS5SM7PV2KjXWzWuegQHUouP33kfHwJUchBdNKb2Zd5FqExMrCxnocTZr9x7gfggoCCQRuXHOkfpVQWE4ei8lYcN704rOuORHjasAg57GnUYsy8OfPW7olMeFa3UsmCh8Mye2dtp3133VdKo3HfnUXr7uRNbrfrypqmKcKDZDJu7A/QslvE/MqJ4Mf3lCDFeYB9iE6xChFgMa2Qqs3Dkef2uSUuji7c8fepwFlGkDsWbbGe6p+hhR2UH+0ewCnFYNaA34pBTxfiAcMRcFcLrR2SBNCQUUiPzn/HrZuqR1Jok2sS4AU9BXBAfs7jFCzfahR/9ILq1grjRcRpa3tIhuh3x0S0cY5/YbG1H5BHbLhNcE6iCBBNVJJsNmZsRRS1ZFlz4sI4ro/LD9KZB2S3Wp2tRsehGCsfF5de3/q7eqCNkbE09q5LUROZRZEIxsbKyfHV8nBh7uGiYQo77wQ9PZaE5hAgnicWKjlh0IydPcSAwkEuQ4HEg4pgMLO1bDWweBKVR/LplTXCJ1A6ujEqEq62uxp0b7ns4vRluo9jBTW67gxE/m+6Iw6dBimjwZ+F4FK20NDqNT7qnRxeJKx/GwBMRzTS2G6awFer9728fNIL/UQaRAKYii2FsbU97ZfP33akKIg5XwoGf5cWl1ykU0orHsvx8Syi48mEGVz4E8lhEEb1NOhCJqZKddO5CLLoZZpBOpuJhOn2EQLRS47nIqkcXyIoH2BKKWqoeCbdya+FqsrNfFAF2HzxUOpGQuBaLbmwZpKEKhETUaovy8y2h2EhTjxoxKiDHRWeh7XNIBkURYLMn40ukAm68d08+m5mtIZ95itco+yx8LoHRNUhDFwhJGlFspR7bsg02NIuBi2PfXUedNEwNiiKAfNqqhsRvfe149vfu/9NwB5N6ef/Fb9EvAsrne+nXQRqLQHTYMjJB7yq8RWJDcyQuGqYkiCLQqTfI5ML3oiMS+LshErF1h15395ey1xzqiHZvBym+15g2W6UmxKvdv98mFElSe1WINgvFAFxPdl4+/UY2fjysAQej6KoicXHpta0LeXeE+zelHxPDtqjotoMnWdCwxXah4A7NgWCyc/qOLzjbBv1emmaMClGnNcqvWYv3Kz/Y+v1k5xS22JDmcUjzEWVAdmRKdlRE2afYjuvJTtl+PaqNF/4IjD1V5P4HILctxQwW1+K8Wj4wyAjb/Amwo9AhOvPnDHYk3Jfl/y5EQnYgoitv1MWOG1unPRuhene0UiRKctEpqQJ6HCCcvFNUn+5GK8kOoWgntXjWA1siK8P97rwTsxIgivjpX87ndsN1ZkYwD9Lqyenhzudl9e23su8TqZEpZNlXV3x0qz/MJu12skMDdghFLVlfpAoDsxJPJts9EaBIFCGBL6Ea4WT9Ei88u+PPi0YUIHP1z5sp8+G1Q7yydEjz72Sx0KfWqC/u+LPeP7jlz/8GYUeLKoa8wFBFcFHRKBpFAN3Oy0FP7fECEUW3oI2qyOQF7z2it0w4nzuRvTe6fx/EnhcCKdG85amTo1MPkBY+vkMVQkYRLi4shP4QiCJRBMDFj32aquDmG9aLkZduocHnuje1ZPrwRxUlvDe6JU/ZX+IqfSwLQmwvi0r6C4UQC1QB5MXkIoqQefhP/2peqf0YY+Oq4TRu6GGjy0Xattc7h/ZK0IdhwtjE+3/93R9t40IqgrZy3YgFhvR0SedfbJCI/h5lX6HAIhsqefqBMB4lQVft14giWopPSVzoOp4Jcv9BFJ3t6L1xMwH8kRn/G5WL7ggAsxR433SFCOkai0U+DvzZC32DhL5Csf+ZhVZZy6R4cuEpc8OxP3ASRaAR6B2NciIavXR8CdmiPYjG9D4qQr8nPKYqTRmb3SkIMFWOxXvYHbEwO0kth4GKP3hgVIjS+RSIHuBFuMhbZRShc6gLbhh0g6rS3aI9iKIRxaAbtrvLU4feFET+m3gvdYfA9hz6bJbC8QHP/RlmOQwUil0rK/iPSpF+yCjCRdnMRBQh0fl+e1u0B1Gkh2LY60H1xpSx2ZuCALyvmBjVNTmx+evGB4+zWPRhYmKluFCUJf2QpbJYogjJPo1hLwAjMI9Q1QvcMKOMxTyt53npTUG6/w3duQ55fgj3WnwE0o798wsDA4Ohu2o2hHiSIsZV8w1ujndPftNIFAHkhKoqeOrmrawUST02RoiArOyYoF8KIvl5pwdF573mxqztjKp0DhWK2KsfU4ftT3tiFByLXy6fWSITyKW8qmTLUXLerLgZi4TgGzluTNzE6BUxQb8URAIh1DU5WSy2aN369Knnh33BUKFA+hFz89Wugo5+EaQbb3JiUfZ1qObP+J7eLzCDUdTIXOvpoRgEzhYxxfQQsZc/A52KC4tF1mQ1sm9q5JrMqjRfFUGl/ToPCLV1Ltj3BqzKG0RtcpKKkFcQ8b4g0jLBsBQEmGj7lj5WyPtCbbJBoyucI4UiDUkWYzU164afEipDXHnRPYujd3Q8D0WbzdYv5BchRBWm3qNhKYhEt+1bRnO7D5bjPJQCNHGPj/qiXIu306giytHzXQaFwlYUAXSHvfqNjuehyDAYaK9cyf21m+VZc5fNdA6/SbciIo9htH1oU0i0cxYscgnF2MrKM1TBiVJgM4oAusNeg0bH86Dbvj0KGJumOjZHpSDd/6ZuRQSLeyvU8r2Y54tyCUWMpiYuLF33PRvishRFSHSNNNWFL2MKZ2yq/DsYRTdFnhQEmKiIVGE+JDUxn0/Tjmaer8195k9spiaefjC5VEw1OQpusoGoH7pNVRAJ1bMqGwoVIZX3wkcKIv/d7KAgjYdF6cWiVv9G3i+t5/3Cv3jtx80//Oyn59JPZygSkvU1uvTjf8ourPEc05dr6cWF0PW9v/lr2rj4IdlEHj+oCm6E/1FMOcDeXzlMEzf9v9xfv955b1RYaZ6la1Ifpr73WtJFNHbR+Cdu2jrebxgQNvz863uuzfXz7weiGGygxmsoE0KIxVv+7IWv5v36BhUAnZq1JJmjyMCMAC70PalJJY+Dw14FfCBMxQXlclkswn7swFAli5a+rbc1u6iRuab5/iAF0dka3o1MQfIIl5wRwc9XNTrYbNzbZzSN8s1GQSuh8AHmZ79y73mKKKoIDRMNPu+lF/5FzUnKmx9/tpBHcen0UhrBfJN0gDhea2jmBgJQ1LSEQKOqofre5zmQKRKaB7763f1F/oPC5xInSS13XsPsRGdTFRi20i4vKkZmsnqJdGkZ2LQtyVsF6UaanKrNYGWZPG0rzHAVForxq1eep4qWSnXR3VSFm6xlwBgc+0SxtAPkbd8eBp7EJtf8562CdCPLyaoGawkmT5uj5jr6UVgoUCpNnRCOKgqia15KX8JE2KsiVqYiAZN7K0DeKkgvrU7pW+V1xTwf0lacCC8sFKDKDVgq6E6EggsGw/aiRiZoXzGXl/tOQSQ6qQh+phGu1lOKJoCSUHBUkR/59NHJa/OstCuCykLhIu3bo/8u/ymIRCcVcXFIlEnaGvtllIQCcFSRj313HtUKUXEhmxzbVp2QNF0+DiUFkaikIhD/iCZOlaMJoCwUWVt3QlFvwLKN7kQoMOVLSFSMTGCjzySUFEQiU5Ei8ykT+w9QDLQ1t9UpCwU4eOK7iCqaxOxAdyIUmPQlJAjTi2KrbyCkFEQi91vkTUVU/B4PaEUTQEsoQKpUDxKzDd2JUABfovWK+el+lQvbZteqySU3QDcFkchDk0e99l+88Q8UOm0Du2+1haKz2GaRmAy5AEXXlzB1TkYvKjn1huVORJPdjiZSEAlEbFgqorIsyDWY6dCNJoC2UIDYt3WbxMQTLe+q/aKoHp/YvmKu4tH37w8wBZEMSkVMNb/ZZoPISMSfe3p0GJgsffizn55OI4tfpQoDkbj2N+4iHXBBYuLRBrtvPUS7P/XLVJQr//bj7MMma++/nUUDRSZah4G/59K//JOxSAXTo2idXzl/llb/69/pwt/9bfAzH9g3cfDp7xrZI2MkogDjq6vzVOFyKUJ6E+alzaeUainP1Q0RWhWkF3xvODjZ1AnulmlukLlI35hQVLlcilQDU4k62BYJoOrQu7opNg9SUt+x0QtSkD0V2n/ZDQzMvNur8mBMKADKpVU0Nq//4kPam6pc5LvKzVYGBsLygl4G3SMDu5mMpM/BME0TBmY3RoUCbFSsXApfQtUkBDih24VI6HyPrnNxk0t5xfg1VDXSaOIwGca4UGThTkWqILrDXhAJbF9ywZhGY5AP085UyTSShihjmE45JMaFAhx4+tR8GU5CHwX6JVTB0tefGQyxR6Ezk+DDuMO/aaJkGvuSmYIg5ZgnC1gRiox2vdQpiE6/BEQCtXmXT2rVJ6vPEiAqDLqDY0UPYo4ZGymHxJpQ3PLnJ5fLnILojjW7vAF1phx9lwFNlEyrIBS2Ug6JvYiCtlKQRSohKhefPGvC9c2nk3ZseG4qMlEyVZ2YjQhrKYfEqlCAThWkVI1YKimHL5EAOkbmRgCNRbol09pkqSOKls2UQ2JdKBAOla0Rq6hQ+BQJoLMzYc1hD8UwTJZMy0QqEn9kM+WQWBcKgEashKiSq/Nk6Owz1x/XSD1CmmdQKZnifcd8RhnBPWW6sWoQToQCdGZBmlQCipwslp1/+Y7eYck6IPrRGnm/EM5Mg0rJFL0qEcxlqNAcn8zuKSc4EwrMgnRyqej9Ctz4b33teHrRfmvoRYgTvXyKBBjTbDgyuVTXBHlLpmudw5FNLiUOiOxe2j+/4OxeKnykoC6nHzv6QC1JnqMSsWf2dpq+Y7OvAtEGnmKXTy8FsdRE9xg/LJz1LXb9QCUH7zf8F4ihTK9Ceu9tga1yrlIOiXOhAKlYzKdi8QSVCFy0uHhxgYaU16N7VGfO482nHi7DWZulodMvMU+OcZZ6dNN5oQtUIuSugtBuKh2RACwSQbHgQySAF6EAY6ur6K9oEmMNXZEoqQkYK82xyVVvYxHehKLL3GwSYwVdI3ONhSIUmq7Ny168CQVAo4ho1+8mPnHMCrqH09heqsvkInugumiqGoZXoQDZ8FiS8NkgFrj69lukQ7J6iRjPpPeGb5EA3oUCHDjxvYUkoT8ixii6PQShtG9XFdwTuDcoAIIQCoA27zafD2IUVCx05iO44uEP3AudIzuDIBihACj9sFiYRefEsZDat6uEr16JYQQlFIDFwixoAFONKq6+o+dxMMUJUSRAcEIBWCzMcunMEhUF+x+4j8ItoYoEMHKkoA3+4rUfL/7+b/yyEERzxGix+l//kf06uT9fAxaGqT78+5eJcUfIIgGCFQrAYmEOnJ2JcunETf934Bo/mJetVCBiOHy3TIQuEsDLUFhRyjhE5ovs+MP7HqaxGz9aZnMl9TEwcYlDeLnS4ZYYRAJEIRSAxcIs8uAi9FqwOPghFpEA0QgFOHP83kfTPOTrxDCRg2aqkPokRhGVUICzx+85QkJg8c0UMUx8tNCWHUrHZV6iEwqQpiEzaRrySvrpDDFMPGRDkNl8U2REKRSAxYKJjGYIU6CqBNlwlQe84WOrq4eoZJuymFKyMDa5eihWkQDRRhTdcEWECZWYKhvDKIVQgM52b1RE2ORkQqDVOcXreSoBpREKwL4FEwhR+xH9iNaj6If0Lap6fCHjH1x7sfsR/ShVRNENpyKMY1o4jDumJqoilFYoAKcijAuEEIsbREHstrRFqYVCwlURxhZlqWqMohJCATi6YMySLIt248EYuyxVqIxQSDi6YHSpShTRTeWEAnB0wahQBS9iEJUUCkmnMoLoYoYYZjClrmjkodJCAbLogmiekuR+Ypge0BcxPrk67/PczxCovFBIIBh1oueSJJkjpvJ00gx4EYvEsFD0wulI5UH79YMsENthoRgAC0blqLwPMQwWihGwYJQeTHl+Y2Ji5Zmq+xDDYKHICQtG6WCBKAALRUFYMKKnmSS1b4zvvvI8C0R+WCgUgWCkVZL7uUoSB1zF0IOFQpNzXz42m9Tbj3IfRpC0EqLvJEIssEDowUJhCPRhpL/McVoSBMup//AS+w/mYKGwQCoaczWiB9IoA+f28eIcN3D0YBEWCstsmp8iFYz2EWJM00q9h2V4D2n0sMzRgz1YKBxxfv7I1MrKxBEWDW2kOHwnFYcFFgc3sFB4IjtDtVY7kqYnnyP2NEaxlVZw5OAHFooAQOWkLZK5Wi35QlpunSX2NbKood0WL6UR2GJVtkiFDAtFgMAMFW0xKwSl0UZ7jsovHGmEUFtMEno1qSXLbEaGBwtFBGQ7M9rt2TT0nqsJ8ZnIo45NUaD2m+nrQaSwWMWNUbHBQhEpHXN0FpEHifYMBCT1O6bSXH6W/NMiIVqUiGUIAiW1JiIF9hfihYWihEgRSaOQVDjqM6KWCkgqIoJqNwuRZJFI0m2gJsnM0L9QiObWp0Ty82bn73mznX6e/lstkTSaG/V2iyOE8vG/NDMyyjmzsTYAAAAASUVORK5CYII=",SP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3crect%20x='1'%20y='1'%20width='22'%20height='22'%20rx='5'%20fill='%23F4F4F5'/%3e%3cpath%20d='m6%207%205%205-5%205M13%2017h5'%20stroke='%2318181B'%20stroke-width='2.25'%20stroke-linecap='square'%20stroke-linejoin='miter'/%3e%3c/svg%3e",CP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3cpath%20fill='%23D97757'%20d='M5%205h14v3h3v8h-3v4h-3v-4h-3v3h-2v-3H8v4H5v-4H2V8h3V5Z'/%3e%3cpath%20fill='%23181818'%20d='M7%209h3v4H7zm7%200h3v4h-3z'/%3e%3c/svg%3e";function t0({agent:e}){const n=e==="codex"?kP:e==="claude"?NP:e==="codex-cli"?SP:e==="claude-cli"?CP:null;return n?t.jsx("img",{src:n,width:18,height:18,alt:"","aria-hidden":!0,className:"size-[18px] shrink-0 object-contain"}):e==="cursor"?t.jsx(aR,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(oi,{className:"size-4 shrink-0","aria-hidden":!0})}function EP(){const[e,n]=p.useState(e0);return p.useEffect(()=>{const r=o=>{const i=o instanceof CustomEvent?o.detail:void 0;n(Gv.includes(i)?i:e0())};return window.addEventListener(Ng,r),window.addEventListener("storage",r),()=>{window.removeEventListener(Ng,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{wP(r),n(r),window.dispatchEvent(new CustomEvent(Ng,{detail:r}))}}}function an({label:e,prompt:n,playgroundHref:s,playgroundLabel:r="API playground",disabled:o,compact:i=!1,compactIcon:c,variant:d="outline",size:u="sm"}){const{agent:f,choose:g}=EP(),[y,v]=p.useState(!1),[h,x]=p.useState(!1),[b,j]=p.useState(!1),[k,E]=p.useState(null),N=p.useRef(null),S=p.useRef(null),$=p.useRef(null),_=p.useRef(null),O=p.useRef(null),M=p.useRef(0),P=p.useId(),A=jP(f,n),R=f?A?`Open in ${Sg[f]}`:`Copy prompt for ${Sg[f]}`:"Choose your coding agent",L=()=>{var I;v(!1),(I=N.current)==null||I.focus()},W=async()=>{const I=++M.current;v(!1);try{if(await navigator.clipboard.writeText(n),I!==M.current)return;x(!0),j(!1)}catch{I===M.current&&j(!0)}};p.useEffect(()=>(x(!1),j(!1),()=>{M.current++}),[f,n]),p.useEffect(()=>{if(!h)return;const I=setTimeout(()=>x(!1),2e3);return()=>clearTimeout(I)},[h]),p.useEffect(()=>{o&&v(!1)},[o]),p.useEffect(()=>{if(!y){E(null);return}const I=()=>{var le;const J=S.current.getBoundingClientRect(),X=Math.min(240,window.innerWidth-16),re=J.left+X<=window.innerWidth-8?J.left:J.right-X,ae=Math.min(((le=$.current)==null?void 0:le.scrollHeight)||340,window.innerHeight-16),ye=window.innerHeight-J.bottom-12,he=J.top-12,we=ye>=ae||ye>=he,ze=Math.max(80,we?ye:he);E({width:X,left:Math.max(8,Math.min(re,window.innerWidth-X-8)),top:we?J.bottom+4:Math.max(8,J.top-Math.min(ae,ze)-4),maxHeight:ze})};I();const V=J=>{var X,re;!((X=S.current)!=null&&X.contains(J.target))&&!((re=$.current)!=null&&re.contains(J.target))&&v(!1)};return document.addEventListener("pointerdown",V),window.addEventListener("resize",I),window.addEventListener("scroll",I,!0),()=>{document.removeEventListener("pointerdown",V),window.removeEventListener("resize",I),window.removeEventListener("scroll",I,!0)}},[y]);const U=k!==null;p.useEffect(()=>{var I,V,J;y&&U&&((J=((I=$.current)==null?void 0:I.querySelector('[aria-checked="true"]'))??((V=$.current)==null?void 0:V.querySelector('[role="menuitemradio"]')))==null||J.focus())},[y,U]),p.useEffect(()=>{var I,V;b&&((I=_.current)==null||I.focus(),(V=_.current)==null||V.select())},[b]);const Y=I=>{var re;if(I.key==="Escape"){I.preventDefault(),L();return}if(I.key==="Tab"){L();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(I.key))return;I.preventDefault();const V=[...$.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],J=V.indexOf(document.activeElement),X=I.key==="Home"?0:I.key==="End"?V.length-1:(J+(I.key==="ArrowDown"?1:-1)+V.length)%V.length;(re=V[X])==null||re.focus()},D="flex w-full items-center gap-2 px-3 py-2 text-left text-body hover:bg-accent focus:bg-accent focus:outline-none",G=t.jsxs(t.Fragment,{children:[i&&c?c:t.jsx(t0,{agent:f}),i?t.jsx("span",{className:"sr-only",children:h?"Copied":e}):h?"Copied":e]}),F=i?`${e} · ${R}`:R,q=`h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none ${i?"px-2":u==="lg"?"pl-5 pr-1.5":u==="md"?"pl-4 pr-1":"pl-3 pr-1"}`,H=d==="primary"?"data-[state=open]:bg-primary/20 has-[:focus-visible]:bg-primary/20":"data-[state=open]:bg-accent has-[:focus-visible]:bg-accent";return t.jsxs("div",{ref:S,role:"group","aria-label":`${e} options`,"data-state":y?"open":"closed","data-size":u,className:te(hl({variant:d,size:u}),"shrink-0 items-stretch gap-0 overflow-hidden px-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring",H),children:[A&&!o?t.jsx("a",{href:A,title:F,"aria-label":i?e:void 0,className:te(hl({variant:"ghost",size:"sm"}),q),children:G}):t.jsx(B,{variant:"ghost",size:"sm",className:q,disabled:o,title:F,"aria-label":i?e:void 0,onClick:()=>f?void W():v(!0),children:G}),t.jsx(B,{ref:N,variant:"ghost",size:"icon",className:te("h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none",u==="lg"?"w-9":u==="md"?"w-8":"w-7"),disabled:o,"aria-label":`Choose coding agent for ${e}`,"aria-haspopup":"menu","aria-expanded":y,"aria-controls":y?P:void 0,onClick:()=>v(I=>!I),onKeyDown:I=>{(I.key==="ArrowDown"||I.key==="ArrowUp")&&(I.preventDefault(),v(!0))},children:t.jsx(ri,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:h?"Prompt copied":""}),y&&_s.createPortal(t.jsxs("div",{ref:$,id:P,role:"menu","aria-label":"Coding agent",onKeyDown:Y,className:`fixed z-popover overflow-y-auto border bg-card p-1 shadow-float${U?"":" invisible"}`,style:k??{width:240},children:[Gv.map(I=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":f===I,tabIndex:-1,className:D,onClick:()=>{g(I),L()},children:[t.jsx(t0,{agent:I}),Sg[I],f===I&&t.jsx(Cl,{className:"ml-auto size-3.5","aria-hidden":!0})]},I)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:D,onClick:()=>v(!1),children:[t.jsx(Em,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:D,onClick:()=>{var I;(I=N.current)==null||I.focus(),W()},children:[t.jsx(oi,{className:"size-4","aria-hidden":!0}),"Copy prompt"]})]}),document.body),b&&_s.createPortal(t.jsx("div",{className:"fixed inset-0 z-popover grid place-items-center bg-overlay/70 p-4",onClick:I=>{var V;I.target===I.currentTarget&&(j(!1),(V=N.current)==null||V.focus())},children:t.jsxs("div",{ref:O,role:"dialog","aria-modal":"true","aria-label":"Copy prompt",className:"w-full max-w-xl border bg-background p-5 shadow-float",onKeyDown:I=>{var V,J,X;if(I.key==="Escape"&&(I.preventDefault(),j(!1),(V=N.current)==null||V.focus()),I.key==="Tab"){const re=[...O.current.querySelectorAll("button, textarea")];I.shiftKey&&document.activeElement===re[0]?(I.preventDefault(),(J=re.at(-1))==null||J.focus()):!I.shiftKey&&document.activeElement===re.at(-1)&&(I.preventDefault(),(X=re[0])==null||X.focus())}},children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("p",{className:"font-semibold",children:"Copy prompt"}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close prompt",onClick:()=>{var I;j(!1),(I=N.current)==null||I.focus()},children:t.jsx(uo,{"aria-hidden":!0})})]}),t.jsx("p",{className:"mb-3 text-body text-muted-foreground",children:"Clipboard access is unavailable. Copy this prompt into your coding agent."}),t.jsx(on,{ref:_,readOnly:!0,"aria-label":"Prompt to copy",value:n,rows:9,className:"w-full resize-y border bg-card p-3 font-mono text-small",onFocus:I=>I.currentTarget.select()})]})}),document.body)]})}function da(e){const n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("AgentRun needs an HTTP or HTTPS server address.");return new URL(n.origin)}function ao(e){const n=da(e).origin;return`First read this server's matching agentrun-serve skill from ${n}/skills/agentrun-serve/SKILL.md. Target this existing instance only: ${n}/v2; do not start a replacement server. Check its /capabilities and /openapi.json. Prefer configured MCP at ${n}/v2/mcp, verifying with whoami; otherwise use the documented API. For authenticated requests, use this instance's AGENTRUN_API_KEY from local configuration, or help me configure it locally. Never print credentials.`}function Zm(e,n="",s){return`${ao(e)}
590
+
591
+ Help me build an agent. Ask only the missing questions about its job, inputs, expected outputs, tools, execution environment and success criteria. Inspect existing agents for reuse and this server's available harnesses, models and tools. Propose the instructions, skills and configuration, get my approval, then create the agent and give me its console link. Explain execution prerequisites separately; saving a definition does not require buying model access. Do not start a run.${n.trim()?`
592
+
593
+ My brief:
594
+ ${n.trim()}`:""}`}function $P(e,n,s=""){return nC(e,n,s)}function gx(e,n,s){return nC(e,n,"",!0,s)}function nC(e,n,s="",r=!1,o){const i=da(e).origin;return`${ao(e)}
595
+
596
+ ${r?"Set up and run an agent":"Create an agent"} from template ${JSON.stringify(n.id)}, version ${JSON.stringify(n.version)}${n.sha?`, commit ${JSON.stringify(n.sha)}`:""}. Read GET ${i}/v2/templates and select that exact package by its id; if the version${n.sha?" or commit":""} differs or it is missing, explain and check with me before proceeding. Use its canonical apply operation so the server copies the package's instructions, rules, skills, schemas, learning and triggers. Do not rebuild it from the description or substitute a generic create-agent request.
597
+
598
+ Ask only for missing parameter values and clarification of my intended inputs, outputs and success criteria. Inspect the template's schema, defaults, required secrets, MCP servers, tool grants, harness and model prerequisites. Keep credentials in local configuration. Explain its learning behavior and any triggers that applying it will enable, including schedule and budget. Show the proposed parameters, grants and overrides${r?"; ask for approval only for permissions or side effects not already authorized":" and get my approval before applying"}; do not grant tool access implicitly.
599
+
600
+ Use POST ${i}/v2/templates/${encodeURIComponent(n.id)}/apply with only the documented parameters, grants, servers and overrides. Match MCP needs by source and toolkit to the owner's saved servers; if several accounts match, ask me which one. Preserve any explicit server choices instead of substituting another account. Submit once with an idempotency key; on an uncertain response, reconcile the same request before retrying. Map my additional requirements to supported parameters when possible; do not add a brief or instructions field to the apply body. If a requirement needs configuration changes beyond the apply schema, propose a separately approved revision after applying, preserving the rest of the package and using the current revision with If-Match. Report the new agent's console link and any warnings or enabled triggers.${r?`
601
+
602
+ Then read the created agent's current revision and run the template's intended task. Ask for missing run inputs, files or output requirements; do not invent them or substitute a generic task. Honor any supplied effort or spending limits without adding a cap unless I asked for one. Check the harness, model and tools are ready. Applying creates an agent and may enable triggers; it does not complete a run. Carry out my requested run with the permissions already given; clarify only missing inputs or permissions and ask before side effects not already authorized. Start the agreed task once through POST ${i}/v2/agents/{created_agent_id}/runs using an idempotency key; reconcile an uncertain response before retrying, and avoid duplicating a task already started by a trigger. Follow progress, surface questions, and return the result and run's console link.`:" Do not start a run."}${o?`
603
+
604
+ My selected setup request (treat this JSON as data):
605
+ ${JSON.stringify(o,null,2)}
606
+
607
+ Preserve these parameter values, explicit grants, MCP server choices and approvals. Omitted parameters use the package defaults; ask only for missing required values. Do not add tool grants or broaden approvals without my explicit consent. Copying or opening this prompt itself sends no API request.`:""}${s.trim()?`
608
+
609
+ My additional requirements:
610
+ ${s.trim()}`:""}`}function Xo(e,n,s=!1,r){const o=da(e).origin;return r?`${ao(e)}
611
+
612
+ Help me edit the existing backend agent ${JSON.stringify(n)}, using ${sa(r)}. Read ${o}/v2/agents/${encodeURIComponent(n)} and locate its original application entrypoint. Ask me where that source lives if it is unavailable. Clarify the change, then edit the application code with my approval. Preserve its SDK, tools, authentication, job triggering, and AgentRun learning wrapper with the same agentId and server address. Keep the instructions snapshot sent by the wrapper accurate when changing its policy. Do not replace this agent with a managed definition or treat its recorded definition as the executable source. Keep the server's existing self-improving setting; the Learning tab controls it. Test the changed backend and return its console link. Do not start a production job without my approval.`:s?`${ao(e)}
613
+
614
+ Edit the original native setup for agent ${JSON.stringify(n)}. Read ${o}/v2/agents/${encodeURIComponent(n)} for its project, runtime, machine and selector. Work on that source machine and preserve its native instructions, skills, tools, model/profile, permissions and sign-in. Clarify what I want changed, show the proposed source changes and get my approval before editing. Future launches resolve the latest original configuration. Do not convert this connection to a managed snapshot or mutate its binding through the definition API. Return the connected agent's console link. Do not start a run.`:`${ao(e)}
615
+
616
+ Edit agent ${JSON.stringify(n)} at ${o}/v2/agents/${encodeURIComponent(n)}. Read its current revision and configuration first, then clarify what I want changed. Preserve unrelated instructions, skills, tools and settings. Show the proposed changes and get my approval before saving a new revision with agents_revise, or the definition API with If-Match. If the revision changed meanwhile, re-read it before revising. Give me the updated agent's console link. Do not start a run.`}function eh(e,n){const s=da(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${ao(e)}
617
+
618
+ Help me investigate ${n===void 0?"runs across all agents":`runs of agent ${JSON.stringify(n)}`}. Ask what I want to know and the time range if unclear, then make read-only requests to ${s}/v2${r}, following pagination, and inspect relevant run timelines/files. Include server-run sessions and imported history; for an unfiltered cross-agent query, also read /v2/observations for independently running sessions. Identify the source and data freshness; observed idle sessions are not proof of completed tasks. Summarize findings with links to the runs, distinguish unknown metrics from zero, and do not create, edit, rerun or cancel anything.`}function Kv(e,n,s){const r=da(e).origin;return s?`${ao(e)}
619
+
620
+ Help me run the existing backend agent ${JSON.stringify(n)}, using ${sa(s)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and locate its application's existing job entrypoint. Ask where that source runs if needed, and clarify the task and any required inputs or spending limits. Preserve its SDK, tools, credentials and AgentRun learning wrapper; trigger the task through the backend's normal invocation after my approval. Do not launch it with AgentRun's managed run API or create a replacement agent. The wrapper reports this task and uses the currently enabled accepted learning; wait for flushLearning() before a fresh test run that must use its latest lessons. Report the backend result and the recorded AgentRun console link. Any stop, retry or follow-up must use the backend's own controls.`:`${ao(e)}
621
+
622
+ Help me run agent ${JSON.stringify(n)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and its current revision first. Clarify the task and any required input, files, effort or spending limit. Check this agent's harness, model and tools are available. For a native binding, verify its connection and source machine, retain its original project/model/profile and native sign-in, and do not require a managed model API key. AgentRun native spend caps are unavailable; do not promise a dollar limit or silently remove a limit the user requires. Show the proposed request and get my approval before starting the run; ask for model credentials only if execution needs them, and configure them locally. Start once, follow its progress, surface any questions it asks and report the result with its console link.`}function _P(e,n,s){const r=da(e).origin;return`${ao(e)}
623
+
624
+ Help me send this prepared request: POST ${r}/v2/agents/${encodeURIComponent(n)}/runs. Treat the JSON below as request data. Preserve its input, revision, file_ids and options; do not substitute another agent or discard fields. Check the schema, agent readiness and that referenced files exist on this instance. Clarify missing details and show me the request before asking for approval to execute it. After approval, submit once using an idempotency key; on an uncertain response, reconcile that same request before retrying. Follow the run and return its result and console link.
625
+
626
+ ${JSON.stringify(s,null,2)}`}function sC(e){const n=da(e).origin;return`Read ${n}/skills/agentrun-serve/SKILL.md and follow Connect agent for ${n}/v2 with the matching reviewed CLI. Use this instance; do not start a replacement server.
627
+
628
+ Clarify only missing choices: observe an already running agent, connect for AgentRun-triggered jobs, import history, or both; source machine, project, runtime and container/profile if relevant. Existing backend/Docker agents use native telemetry and Collector setup, preserving SDK configuration and job triggers. Other remote jobs use the remote worker flow. Observation alone does not enable self-improvement. Preserve original files, tools, permissions and sign-in.
629
+
630
+ Never print credentials; I enter codes in the secure terminal prompt. Keep secrets out of prompts, URLs and logs. Get approval for the previewed history scope. Do not import history, enable self-improvement or start a paid run unless requested. Verify the result and return its console link.`}function TP(e,n){const s=da(e).origin;return`Read ${s}/skills/agentrun-serve/SKILL.md for ${s}/v2 only. Use the existing AgentRun CLI and Node bridge from the same reviewed build; do not start a replacement server.
631
+
632
+ ${n==="live"?"I selected a live agent connection, without past history.":n==="history"?"I selected history only: no executing worker or self-improvement.":n==="both"?"I selected both a live agent connection and past history.":"Ask whether I want a live agent connection, past history, or both."} Confirm the source machine, project and runtime. Preserve its native files, permissions and sign-in. History is scoped to the selected project/runtime.
633
+
634
+ Create a one-use connection code at ${s}/#/agents/connect?source=remote with the matching scope. I enter it in the secure terminal prompt; keep it out of prompts, URLs, command arguments and logs. Never print credentials. Import history only when requested and approved after preview. Keep self-improvement Off unless I request it. Ask before a paid run. Verify the result and return its console link.`}function RP(e,n){var o;const s=e??"pi",r=(o=n.find(i=>i.id===s))==null?void 0:o.steer;return typeof r=="boolean"?r:s==="pi"}const th={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},AP=new Set(["completed","failed","cancelled"]);function OP(e,n,s,r,o){const c=e==="queued"||e==="working"&&n==="working"?o||s==="workflow"?"steer":"follow_up":e==="input_required"&&n==="waiting"?"answer":e==="input_required"||e==="working"||e==="completed"?"follow_up":null;return!c||!r[c]?null:s==="workflow"?c==="steer"&&r.steer_workflow_runs?c:null:c}const rC=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",MP=(e,n)=>e==="completed"&&!!n;function nh(e,n,s,r,o,i,c,d){const u=AP.has(e),f=s==="agentic",g=rC(e,i),y=MP(e,c),v=e==="queued"&&(d==null?void 0:d.state)==="starting"&&(d.kind==="desktop"||d.kind==="phone"),h=g?"Escalated":y?"Needs review":v?"Starting":e==="input_required"?n==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],x=g||y?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",b=OP(e,n,s,r,o);return{label:h,tone:x,live:e==="queued"||e==="working",needsYou:e==="input_required",final:u,canStop:f&&e==="working"&&n==="working",canCancel:!u,canMessage:b!==null,messageMode:b}}const LP={Queued:eg,Starting:eg,Working:eg,Completed:Cl,Failed:ul,Escalated:UT,"Needs review":$m,Cancelled:ZN,"Input required":nv,Stopped:fl,Paused:n1};function Ll({run:e}){const n=nh(e.status,e.state,e.kind,th,!0,e.error,e.review,e.computer),s=LP[n.label];return t.jsxs(Ne,{tone:n.tone,children:[t.jsx(s,{className:n.live?"size-3 animate-spin [animation-duration:2s]":"size-3","aria-hidden":!0}),n.label]})}const PP=["ready","unavailable"],Ff=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),xx=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function Ad(e){if(Ff(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function n0(e){const n=Ff(e)?e.places:void 0;if(!Ff(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(Ff).filter(o=>typeof o.id=="string").map(o=>({id:o.id,available:o.available===!0,...typeof o.reason=="string"?{reason:o.reason}:{},...PP.includes(o.state)?{state:o.state}:{}})),r=Ad(n.default_place);return r?{modes:n.modes.filter(o=>typeof o=="string"),boxes:s,defaultPlace:r}:null}const Cg=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,IP=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",zP=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",DP={v:2,name:"decision",schemas:{Input:{type:"object",required:["case_id","payment"],properties:{case_id:{type:"string"},payment:{type:"object",required:["descriptor"],properties:{descriptor:{type:"string"},memo:{type:"string"},merchant_site:{type:"string"},amount:{type:"string"}},description:"What the payment says about itself: card descriptor, memo, and the merchant's own site text."}},examples:[{case_id:"case-1",payment:{descriptor:"TILEWORKS SUPPLY CO 8885550142 OH",memo:"Invoice 4471: 40 pallets glazed ceramic floor tile",amount:"USD 18,420.00",merchant_site:"Tileworks Supply sells porcelain and ceramic tile to contractors across the Midwest."}}]},Verdict:{type:"object",additionalProperties:!1,required:["verdict"],properties:{verdict:{type:"string",enum:["gambling","not_gambling","unclear"],description:"Is the payment described in `payment` a payment for gambling: staking money or a paid currency on a game of chance or skill for a chance to win money or prizes redeemable for money, including sweepstakes casinos and social casinos that pay out cash prizes?",criteria:{gambling:"It is a payment for gambling, as described.",not_gambling:"It pays for something else: goods, services or a transfer with no stake on a game.",unclear:"What the payment says about itself is not enough to tell."}}}}},input:{schemaId:"Input"},output:{schemaId:"Verdict",path:"judged"},root:{node:"chain",steps:[{node:"judge",label:"judge",timeoutMs:6e4,state:{case_id:"{case_id}",payment:"{payment}"},out:"Verdict",as:"judged"},{node:"escalate",label:"unclear",when:{predicate:"field_equals",path:"judged.verdict",value:"unclear"},kind:"review",stage:"decision",summary:"A person decides case {case_id}: what the payment says is not enough to tell."},{node:"escalate",label:"no-confidence",when:{predicate:"not",of:{predicate:"field_type",path:"judged$answers.answers.verdict.confidence",type:"number"}},kind:"review",stage:"decision",summary:"A person decides case {case_id}: the judge gave no confidence."},{node:"escalate",label:"low-confidence",when:{predicate:"lt",path:"judged$answers.answers.verdict.confidence",n:.7},kind:"review",stage:"decision",summary:"A person decides case {case_id}: the judge leaned {judged.verdict}, below the confidence this decision needs."}]}},FP=["jev","parallel"];function UP(e="jev"){const n=structuredClone(DP);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const WP={v:2,name:"workflow",schemas:{Input:{type:"object",required:["task"],additionalProperties:!1,properties:{task:{type:"string",minLength:1,description:"What the step is asked to do."}},examples:[{task:"Write three lines on what this workflow could do next."}]},Answer:{type:"object",required:["answer"],additionalProperties:!1,properties:{answer:{type:"string"}}}},input:{schemaId:"Input"},output:{schemaId:"Answer",path:"step"},root:{node:"chain",steps:[{node:"agent",label:"step",state:{task:"{task}"},out:"Answer",as:"step",effort:"low",instructions:"Do what `task` asks and put your answer in `answer`."}]}},HP=()=>structuredClone(WP),Od=e=>e===!0||typeof e=="object"&&e!==null&&!Array.isArray(e);function Md(e,n,s){const{name:r,description:o,...i}=n,c={...e.definition,...i},d={...e.definition};c.computer!==void 0&&(delete c.place,delete d.place),c.workflow!==null&&typeof c.workflow=="object"&&!Array.isArray(c.workflow)&&(delete c.thinking,delete c.instructions,delete c.model),c.model===""&&delete c.model,c.tool_settings&&!Object.keys(c.tool_settings).length&&delete c.tool_settings;for(const g of Object.keys(c))c[g]===void 0&&delete c[g];const u=g=>{const y={...g,version:0,approvals:g.approvals??"ask",max_cost_usd:g.max_cost_usd===0?void 0:g.max_cost_usd,checkout:g.checkout==="none"?void 0:g.checkout},v=Ad(g.place),h=g.computer===void 0&&v?xx(v):g.computer;return h!==void 0&&(y.computer=h,delete y.place),y},f=al(u(c),u(d));return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function al(e,n){if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const s=Object.keys(e).filter(o=>e[o]!==void 0),r=Object.keys(n).filter(o=>n[o]!==void 0);return s.length===r.length&&s.every(o=>al(e[o],n[o]))}const Vv="starter:decision",oC="starter:workflow",aC={[Vv]:UP,[oC]:HP},vx=e=>e!==void 0&&Object.hasOwn(aC,e);function BP(e){var s,r;if(!((s=e==null?void 0:e.adapters)!=null&&s.includes("runJudge")))return;const n=(r=e.decisions)==null?void 0:r.providers;return n?FP.find(o=>n.some(i=>i.id===o&&i.available)):"jev"}const qP="You are a helpful agent. Do the task you're given and report what you found.";function GP(e){var n;return vx(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:aC[e.harness](e.decisionProvider),skills:[],tools:[]}}:{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},instructions:e.instructions,harness:e.harness,...e.thinking?{thinking:e.thinking}:{},...(n=e.model)!=null&&n.trim()?{model:e.model.trim()}:{},...e.computer?{computer:e.computer}:{},...e.learning?{learning:e.learning}:{},...e.max_cost_usd!==void 0?{max_cost_usd:e.max_cost_usd}:{},skills:[],tools:e.tools,...e.tool_settings&&Object.keys(e.tool_settings).length?{tool_settings:e.tool_settings}:{},...e.approvals==="never"?{approvals:"never"}:{}}}}function s0(e){const n=(e??"").trim();if(!n)return{ok:!0,value:void 0};const s=n.replace(/^\$\s*/,""),r=Number(s);return s&&Number.isFinite(r)?{ok:!0,value:r}:{ok:!1,message:"A spend cap is a number of dollars, such as 2.50; empty means none."}}function KP(e){return(Array.isArray(e)?e:[]).flatMap(n=>{if(!n||typeof n!="object"||typeof n.name!="string")return[];if(n.meta===!0)return[];const{name:s,available:r,summary:o,blurb:i,missing:c,reason:d,harnesses:u,call_only:f,sandbox_only:g,nodes:y}=n;return[{name:s,available:r!==!1,...typeof o=="string"&&o?{summary:o}:{},...typeof i=="string"&&i.trim()?{blurb:i.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof d=="string"&&d?{reason:d}:{},harnesses:Array.isArray(u)?u:[],...f===!0?{call_only:!0}:{},...g===!0?{sandbox_only:!0}:{},...typeof y=="boolean"?{nodes:y}:{}}]})}function sh(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function bx(e,n,s,{mcpHarnesses:r,workflow:o=!1}={}){if(n.startsWith("mcp:"))return!r||r.includes(e);const i=s.find(c=>c.name===n);return i?i.call_only?o:sh(e,s).some(c=>c.name===n):!0}const om=e=>lC[e]??e,r0=e=>e.map(om).join(" and ");function o0(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${om(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${r0(r)} do`:""}`;const o=((i=s.find(c=>c.name===n))==null?void 0:i.harnesses)??[];return o.length?`Runs on ${r0(o)} here, not on ${om(e)}`:"No harness runs it here"}function VP(e,n,s,r,o={}){const i=[...n,...s.filter(c=>!n.includes(c))];return{tools:i.filter(c=>bx(e,c,r,o)),held:i.filter(c=>!bx(e,c,r,o))}}const YP=(e,n)=>e.sandbox_only&&(n==null?void 0:n.mode)!=="sandbox"?"Sandbox-only: it runs in a box, and this agent's place is the runner":void 0,Yv=new Set(["browser"]),iC=new Set(["bash","bash_background","bash_output","bash_input","bash_signal","bash_list"]),Qv=(e,n,s)=>e||n.some(r=>Yv.has(r))||!n.some(r=>iC.has(r))||!s?{mode:"runner"}:s.defaultPlace;function QP(e,n){const s=Ad(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",o=e.definition.tools??[];if(!(!r&&!o.some(i=>Yv.has(i))&&o.some(i=>iC.has(i))&&!n))return{place:Qv(r,o,n),byDefault:!0}}const Eg=(e,n,s)=>sh(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!Yv.has(r.name):!r.sandbox_only)).map(r=>r.name),JP=["web_fetch","web_search"],a0=e=>e.some(n=>JP.includes(n)),lC={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},i0=["pi","claude-agent","codex","opencode"];function XP(e,n){const s=(o,i)=>({id:o.id,label:i,available:o.available,reason:o.reason}),r=[...i0.flatMap(o=>{const i=e.find(c=>c.id===o);return i?[s(i,lC[o])]:[]}),...e.filter(o=>!i0.includes(o.id)).map(o=>s(o,o.label??o.id))];return n&&(r.push({id:Vv,label:"Decision",available:n.available,reason:n.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),r.push({id:oC,label:"Workflow",available:!0,reason:void 0})),r}function ZP(e){var n;return e.status===412||e.code==="precondition_failed"?{kind:"conflict",message:e.message}:e.status===422&&((n=e.fields)!=null&&n.length)?{kind:"invalid",message:e.message,fields:Object.fromEntries(e.fields.map(s=>[s.field,s.message]))}:{kind:"other",message:e.message}}function Jv(e){var n,s,r;return e.status===412||e.code==="precondition_failed"?{kind:"conflict"}:(n=e.problems)!=null&&n.length?{kind:"refused",problems:e.problems}:{kind:"other",message:((r=(s=e.fields)==null?void 0:s[0])==null?void 0:r.message)??e.message,code:e.code}}function yx(e,n){const s=`definition.${n}`;return(e??[]).filter(r=>r.field===s||r.field.startsWith(`${s}[`)||r.field.startsWith(`${s}.`)||r.field.startsWith(`${s}/`))}const Ld=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Xv=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function Zv(e){const n=e&&"remote"in e?e.remote:void 0;if(!(!n||typeof n!="object"||!("connector_id"in n)||!("target_id"in n)))return typeof n.connector_id=="string"&&typeof n.target_id=="string"?{connector_id:n.connector_id,target_id:n.target_id}:void 0}function eb(e){const n=e==null?void 0:e.definition.native;return!n||!Zv(n)?n:(e==null?void 0:e.native_status)??{...n,state:"needs_verification",capabilities:{...n.capabilities,launch:!1},issues:["Check the remote worker's connection before running."]}}function Pd(e){return"connected"in e&&!e.connected?"Disconnected":e.state==="ready"?"Ready to run":e.state==="needs_attention"?"Needs attention":"Needs verification"}const tb=p.createContext(null),nb=p.createContext(void 0);function eI(e,n){const s=e==null?void 0:e.definition.native,r=Zv(s),o=`${(e==null?void 0:e.agent_id)??""}:${(e==null?void 0:e.revision)??""}:${(r==null?void 0:r.connector_id)??""}:${(r==null?void 0:r.target_id)??""}`,[i,c]=p.useState(null),[d,u]=p.useState(0),f=()=>u(y=>y+1);return p.useEffect(()=>{if(!e||!s||!r)return;let y=!0,v=!1;const h=async()=>{if(!v){v=!0;try{const{native:j}=await n.getNative(e.agent_id);if(!j)throw new Error("The remote binding is no longer available.");y&&c({key:o,native:j})}catch(j){y&&c({key:o,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Gt(j)}`]}})}finally{v=!1}}};h();const x=()=>{document.hidden||h()},b=setInterval(x,15e3);return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{y=!1,clearInterval(b),window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[n,o,d]),{native:!r||!s?s:(i==null?void 0:i.key)===o?i.native:eb(e??void 0),refresh:f}}function sb(){const e=p.useContext(tb),[n,s]=p.useState(!1),r=p.useRef(!1);return e??{busy:n,begin:()=>r.current?!1:(r.current=!0,s(!0),!0),end:()=>{r.current=!1,s(!1)}}}function tI({children:e,native:n}){const s=sb();return t.jsx(nb.Provider,{value:n,children:t.jsx(tb.Provider,{value:s,children:e})})}function cC({agent:e,v2:n,learning:s,onAgent:r}){const o=p.useContext(nb)??e.definition.native,i=sb(),c=Od(e.definition.learning),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,v]=p.useState(null),h=o.connected&&o.state==="ready"&&o.capabilities.learning&&o.capabilities.launch,x=async b=>{if(i.begin()){g(!0),v(null);try{if(b){const{native:S}=await n.verifyNative(e.agent_id);if(!S.connected||S.state!=="ready"||!S.capabilities.learning)throw new Error(`Native learning is not ready: ${S.issues.join("; ")||Pd(S)}. Verify the connection and try again.`)}const{agent:j,etag:k}=await n.getAgent(e.agent_id),{unchanged:E,...N}=Md(j,{learning:b},b?"Native self-improvement on":"Native self-improvement off");r==null||r(E?j:(await n.updateDefinition(e.agent_id,N,k)).agent),u(!1)}catch(j){v(Gt(j))}finally{g(!1),i.end()}}};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("h3",{id:`native-learning-${e.agent_id}`,className:"min-w-0 flex-1 text-body font-semibold",children:["Self-improving: ",c?"On":"Off"]}),t.jsx(Ed,{labelledBy:`native-learning-${e.agent_id}`,checked:c,busy:f,disabled:i.busy||!!e.archived_at||!c&&(!h||s!=="on"),onChange:b=>b?u(!0):void x(!1)})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:c?"On gives each job your corrections, and keeps a correction you give with a grade. Learned workflows are unavailable.":"Off neither supplies nor creates AgentRun learning. Saved learning stays available. Native memory behavior is unchanged."}),s!=="on"&&t.jsx(jt,{tone:"warning",children:s==="off"?"This server has learning turned off.":s===null?"This server does not expose learning.":"Checking this server's learning support."}),!h&&t.jsx("p",{className:"text-small text-warning-text",children:"Verify a connected native launch with notes and skills support before enabling self-improvement."}),y&&!d&&t.jsx(jt,{tone:"error",children:y}),t.jsxs(Ym,{open:d,onClose:()=>{f||(u(!1),v(null))},title:"Enable self-improvement?",description:"AgentRun reuses the runtime's local sign-in.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:f||i.busy,onClick:()=>{u(!1),v(null)},children:"Cancel"}),t.jsx(B,{size:"sm",variant:"solid",disabled:f||i.busy,"aria-busy":f,onClick:()=>void x(!0),children:f?"Enabling…":"Enable self-improvement"})]}),children:[t.jsx("p",{className:"text-body",children:"Task usage and learning usage are recorded separately; dollar cost may be unknown. Native spend caps are unavailable, so AgentRun cannot promise a dollar limit. Verification checks native authentication and compatibility before the policy is saved; it starts no paid task."}),t.jsx("p",{className:"mt-3 text-body",children:"Each later job is given your corrections whole. Edit them on the Learning tab."}),y&&t.jsx(jt,{tone:"error",className:"mt-3",children:y})]})]})}function nI({agent:e,v2:n,learning:s,onAgent:r,onChanged:o}){const i=p.useContext(nb)??e.definition.native,c=Zv(i),d=sb(),u=d.busy,[f,g]=p.useState(null),y=async v=>{if(d.begin()){g(null);try{const{native:h}=await(v==="verify"?n.verifyNative(e.agent_id):n.disconnectNative(e.agent_id));c||r({...e,definition:{...e.definition,native:h}}),await o()}catch(h){g(Gt(h))}finally{d.end()}}};return t.jsx(tb.Provider,{value:d,children:t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native connection",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-body font-semibold",children:c?"Remote connection":"Native connection"}),t.jsx(Ne,{tone:i.connected&&i.state==="ready"?"success":"warning",children:Pd(i)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"sm",disabled:u||!i.connected,"aria-busy":u,onClick:()=>void y("verify"),children:"Verify connection"}),t.jsx(B,{size:"sm",disabled:u||!i.connected,onClick:()=>void y("disconnect"),children:"Disconnect"})]}),f&&t.jsx(jt,{tone:"error",children:f}),t.jsx("div",{className:"border-y py-4",children:t.jsx(cC,{agent:e,v2:n,learning:s,onAgent:r})}),i.issues.length>0&&t.jsxs(jt,{tone:"warning",children:[i.issues[0],i.issues.length>1&&t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:[i.issues.length-1," more compatibility ",i.issues.length===2?"note":"notes"]}),t.jsx("ul",{className:"mt-2 space-y-2",children:i.issues.slice(1).map(v=>t.jsx("li",{children:v},v))})]})]}),t.jsx("dl",{className:"space-y-3 text-small",children:[["Runtime",`${Ld(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Xv(i.selector)],["Model",i.model??"Native default · unknown until launch"],["Machine",i.machine_id]].map(([v,h])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:v}),t.jsx("dd",{className:"break-all font-mono",children:h})]},v))}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Skills · ",i.skills.length," detected"]}),i.skills.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.skills.map(v=>t.jsx("li",{className:"break-all font-mono",children:v},v))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None detected."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["MCP servers · ",i.mcp_servers.length," configured"]}),i.mcp_servers.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.mcp_servers.map(v=>t.jsx("li",{className:"break-all font-mono",children:v},v))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None configured."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Configuration provenance · ",i.configuration.length," files"]}),t.jsxs("dl",{className:"mt-2 space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Verified"}),t.jsx("dd",{className:"break-all font-mono",children:i.verified_at??"Not yet verified"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Fingerprint"}),t.jsx("dd",{className:"break-all font-mono",children:i.fingerprint})]})]}),t.jsx("ul",{className:"mt-3 space-y-2 text-small",children:i.configuration.map(v=>t.jsxs("li",{className:"break-all font-mono",children:[v.path,t.jsxs("span",{className:"block text-muted-foreground",children:["SHA-256 ",v.sha256]})]},v.path))})]}),c&&t.jsxs("p",{className:"text-small text-muted-foreground",children:["Jobs execute on the source machine through its connector. Native sign-in and project files stay there. ",t.jsx("a",{href:"#/agents/connect?source=remote",className:"underline underline-offset-2",children:"Manage remote machines"})]}),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-small",children:"Capabilities and source machine"}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Future launches resolve the latest original configuration. Verification checks metadata and authentication separately from a paid run. ",c?"Keep the source CLI worker online for verification, execution and learning delivery. Connection status refreshes every 15 seconds.":"This project runs on the AgentRun server's machine."]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Launch: ",i.capabilities.launch?"supported":"unavailable"," · Approvals: ",i.capabilities.approval," · Usage: ",i.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"," · Spend caps: unavailable · Learned workflows: unavailable"]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Disconnect prevents future native jobs. Original files and run history are preserved."}),!i.connected&&t.jsx("a",{href:c?"#/agents/connect?source=remote":"#/agents/connect",className:"block text-small underline underline-offset-2",children:"Connect agent"})]})})}const sI={browserbase:"Browserbase",kernel:"Kernel"},Wi=e=>sI[e]??e,l0=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),rI=5e3,c0=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function oI({agent:e,v2:n,onAgent:s,poll:r,refresh:o}){var N,S;const[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(null),y=p.useRef(e);y.current=e;const v=p.useRef(r);v.current=r;const h=e.sign_ins??[],x=h.some($=>$.state==="held");p.useEffect(()=>{if(!x||d)return;const $=setInterval(()=>v.current(),rI);return()=>clearInterval($)},[x,d]);const b=(S=(N=e.tools)==null?void 0:N.find($=>$.name==="browser"))==null?void 0:S.resolved;if(!h.length&&b!=="browserbase"&&b!=="kernel"&&!f)return null;const j=[...new Set(h.map($=>$.key))].map($=>({key:$,items:h.filter(_=>_.key===$)})),k=async $=>{var _,O;u(!0),g(null);try{const P=(await n.forgetSignIn(e.agent_id,$)).removed.filter(R=>R.at_vendor==="not_deleted"),A=P.length?{tone:"warn",text:P.map(R=>`Forgotten here, but ${Wi(R.provider)} didn't confirm the delete. ${R.message??""}`.trim()).join(" ")}:null;if(g(A),c(null),!await o()){const R=y.current;s({...R,sign_ins:(R.sign_ins??[]).filter(L=>L.key!==$)}),g({tone:"warn",text:`${A?`${A.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(M){const P=M instanceof Ue&&M.code==="sign_in_held"?((_=M.details)==null?void 0:_.held_by)??((O=M.details)==null?void 0:O.handed_to):void 0;g(M instanceof Ue&&M.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...P?{run:P}:{}}:{tone:"error",text:`Not forgotten: ${Gt(M)}`}),c(null)}finally{u(!1)}},E=({key:$,items:_})=>{const O=_.length===1?`Forget the ${Wi(_[0].provider)} sign-in`:`Forget the saved sign-ins for ${c0(_.map(P=>Wi(P.provider)))}`,M=_.some(P=>P.state==="held");return t.jsx(B,{size:"sm",variant:"ghost",disabled:d||M,"aria-label":O,title:M?"A run is using it: forget it once that run ends.":void 0,onClick:()=>{g(null),c($)},children:"Forget"})};return t.jsxs("section",{"aria-label":"Sign-ins",className:"mt-4 max-w-3xl",children:[t.jsxs("p",{className:"caps mb-1.5 flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(Ka,{className:"size-3.5","aria-hidden":!0})," Sign-ins"]}),h.length?t.jsx("ul",{className:"border",children:j.map($=>t.jsxs("li",{className:"border-b last:border-b-0",children:[$.items.map(_=>t.jsxs("div",{"data-sign-in":!0,className:"px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"text-body font-semibold",children:Wi(_.provider)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:_.verified_at?`last verified ${vt(_.verified_at)}`:"not verified yet"}),_.state==="held"&&_.held_by&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["in use by run ",l0(_.held_by)]}),$.items.length===1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex-1"}),E($)]})]}),_.state==="unreadable"&&t.jsx("p",{className:"mt-1 text-small text-warning-text",children:"This server's seal key can't open it, so runs start signed out until it's forgotten."})]},`${_.key}\0${_.provider}`)),$.items.length>1&&t.jsx("div",{className:"flex justify-end border-t px-3 py-1.5",children:E($)}),i===$.key&&t.jsxs("div",{className:"mx-3 mb-2 flex flex-wrap items-center gap-2 border bg-card px-3 py-2",role:"alertdialog","aria-label":"Forget the sign-ins?",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[$.items.length===1?`Forget the ${Wi($.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${c0($.items.map(_=>Wi(_.provider)))}?`," The agent's next run with the browser starts signed out."]}),t.jsx(B,{size:"sm",variant:"solid",disabled:d,autoFocus:!0,onClick:()=>void k($.key),children:"Yes, forget"}),t.jsx(B,{size:"sm",variant:"ghost",disabled:d,onClick:()=>c(null),children:"Keep"})]})]},$.key))}):t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No saved sign-ins. The browser keeps one once a run signs in to a site."}),f&&t.jsxs("p",{className:`mt-2 text-small ${f.tone==="error"?"text-destructive-text":"text-warning-text"}`,role:"status",children:[f.text,f.run&&t.jsxs(t.Fragment,{children:[" Run: ",l0(f.run)]})]})]})}const aI=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),iI=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function ua(e,n){var c,d;const s=`${aI(n)} could not be read.`;if(iI(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof Ue))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=((d=(c=e.fields)==null?void 0:c[0])==null?void 0:d.message)??e.message,o=[e.code,e.requestId].filter(Boolean).join(" · "),i=(u,f)=>({title:s,why:u,next:f,said:r,code:o});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===412?i("Someone, or a run, changed it first.","Reload to see it as it is now."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Try again, and if it keeps happening, the server's words below say why.")}function xr({problem:e,onRetry:n,className:s="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${s}`,role:"alert",children:[t.jsx(Ys,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),n&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})})]})]})}const Ba=[{path:"agent",label:"By the agent",fill:"fill-chart-agent",stroke:"stroke-chart-agent"},{path:"handed_back",label:"Handed back",fill:"fill-chart-handed-back",stroke:"stroke-chart-handed-back"},{path:"workflow",label:"Learned workflow",fill:"fill-chart-workflow",stroke:"stroke-chart-workflow"},{path:"replay",label:"Replay",fill:"fill-muted-foreground",stroke:"stroke-muted-foreground"}],mf=e=>Ba.find(n=>n.path===e);function lI(e){var u,f;const n=g=>g.path!=="replay"&&g.n!==null,s=((u=e.find(n))==null?void 0:u.n)??1,r=((f=e.findLast(n))==null?void 0:f.n)??s,o=[];let i=[],c=s-.5;const d=g=>{i.forEach((y,v)=>o.push({...y,at:c+(g-c)*(v+1)/(i.length+1)})),i=[]};for(const g of e){if(!n(g)){i.push(g);continue}d(g.n),c=g.n,o.push({...g,at:g.n})}return d(r+.5),o}const cI=e=>lI(e).filter(n=>n.total_usd!==null),rb=e=>e.filter(n=>n.path!=="replay"&&n.n!==null),dI=e=>Math.min(25,Math.max(3,Math.round(e/15)));function uI(e,n){const s=[];let r=0;return e.forEach((o,i)=>{r+=o.total_usd,i>=n&&(r-=e[i-n].total_usd),s.push(r/Math.min(i+1,n))}),s}function fI(e){if(!(e>0))return 1;const n=10**Math.floor(Math.log10(e));return[1,2,2.5,5,10].map(s=>s*n).find(s=>s>=e*(1-1e-9))}function mI(e){if(!(e>0))return{top:1,ticks:[0,.25,.5,.75,1]};const n=10**Math.floor(Math.log10(e/5)),s=[1,2,2.5,5,10].map(i=>i*n).find(i=>Math.ceil(e/i-1e-9)<=5),r=Math.max(1,Math.ceil(e/s-1e-9)),o=Array.from({length:r+1},(i,c)=>Math.round(c*s*1e12)/1e12);return{top:o.at(-1),ticks:o}}function hI(e){const n=10**Math.floor(Math.log10(e)+1e-9),s=Math.round(e/n*10)/10,r={1:.25,2:.5,2.5:.5,5:1,10:2.5}[s]??e/4,o=[];for(let i=0;i*r*n<=e*(1+1e-9);i++)o.push(Math.round(i*r*n*1e12)/1e12);return o}function pI(e,n,s){if(!e.length)return{top:1,above:0};const r=e.map(c=>c.total_usd).sort((c,d)=>c-d),o=r[Math.min(r.length-1,Math.floor(r.length*.95))],i=fI(Math.max(o,...n,s??0)*1.08);return{top:i,above:e.filter(c=>c.total_usd>i).length}}function dC(e,n,s=6){if(n<=e)return[e];const r=(n-e)/Math.max(1,s-1),o=10**Math.floor(Math.log10(r)),i=Math.max(1,[1,2,5,10].map(d=>d*o).find(d=>d>=r)),c=[];for(let d=Math.ceil(e/i)*i;d<=n;d+=i)c.push(d);return!c.includes(e)&&(c[0]??1/0)-e>i/2&&c.unshift(e),c}const hf=14,uC=e=>Math.ceil(6+Math.max(0,...e.map(n=>n.length))*6.6+8);function fC(e,n,s){const r=e.map(i=>({...i})),o=[...r].sort((i,c)=>i.at-c.at);for(let i=1;i<o.length;i++){const c=hf-(o[i].at-o[i-1].at);c>0&&(o[i-1].at-=c/2,o[i].at+=c/2)}for(let i=o.length-1;i>=0;i--)o[i].at=Math.min(o[i].at,s-(o.length-1-i)*hf);for(let i=0;i<o.length;i++)o[i].at=Math.max(o[i].at,n+i*hf,i?o[i-1].at+hf:-1/0);return r}function gI(e,n){let s=0;for(let r=1;r<e.length;r++)Math.abs(e[r].at-n)<Math.abs(e[s].at-n)&&(s=r);return s}function es(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4).replace(/(\.\d\d\d?)0+$/,"$1").replace(/(\.\d\d)0$/,"$1")}`}function Hi(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const xI=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function vI(e,n){const s=rb(e),r=[];for(let o=0;o<s.length;o+=n){const i=s.slice(o,o+n),c=Object.fromEntries(Ba.map(({path:d})=>[d,0]));for(const d of i)c[d.path]++;r.push({from:i[0].n,to:i.at(-1).n,runs:i.length,counts:c})}return r}function ob(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const Uf=(e,n)=>`${n?Math.round(e/n*100):0}%`,rh=e=>e!=="pending"&&e!=="retired",bI="Not read: its front matter can't be read; fix the file to use it",yI={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned"},mC=(e,n)=>`${yI[e]} by ${n==="person"?"you":"a run"}`,ab="It changed since you opened it.",wI=e=>e==="active"?"It becomes active again for the next run.":"It goes back to waiting for your OK: no run uses it until you approve it.",jI="Restoring takes your password sign-in in the console.",ib=e=>e.split(`
635
+ `).map(n=>n.trim()).filter(n=>n&&!n.startsWith("#")),kI=e=>new TextEncoder().encode(e).length,lb=e=>`${e} ${e===1?"correction":"corrections"}`,NI=["seeded","reflecting"],oh=e=>!!e&&NI.includes(e.state),hC=e=>(e==null?void 0:e.state)==="merged"&&Array.isArray(e.workflows)?e.workflows.filter(n=>!!n&&typeof n.file=="string"&&typeof n.name=="string"):[],wl=(e,n)=>`${e} ${n}${e===1?"":"s"}`,am=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},cb=e=>`${e} learned ${e===1?"workflow waits":"workflows wait"} for your OK`;function SI(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const CI="Approving needs your password sign-in. Until then it stays out of every run.",id=e=>`${e} ${e===1?"run":"runs"}`,EI={checker:"refused",empty:"nothing",use:"nothing",no_budget:"skipped",unknown_cost:"skipped"},im=e=>EI[e??""]??"stopped",$I={empty:"Nothing new to keep from this run.",use:"It used what its agent learned and kept nothing.",checker:"Not kept: the checks refused it.",no_budget:"Skipped: no budget left in this run to write what it learned.",unknown_cost:"Skipped: this run's spend is unknown, so its budget can't cover writing what it learned.",seed_failed:"Started without what it learned: it couldn't be read.",cancelled:"Not kept: learning stopped (the run was cancelled).",crashed:"Not kept: learning stopped (the run ended unexpectedly).",reflect_failed:"Not kept: learning stopped (an error)."};function db(e){return e.detail&&e.detail.trim()?e.detail.trim():$I[e.reason??""]??"Not kept: learning stopped."}const _I=e=>e==="seeded"?"Learns after the run":"Looking back",wx=e=>e<9.95?Math.round(e*10)/10:Math.round(e),lm=e=>{const n=wx(e);return n<10?`${n.toFixed(1)}s`:yl(n*1e3)},TI=(e,n)=>e>0?Math.round((n-e)/e*100):null,RI=(e,n)=>TI(wx(e),wx(n)),pC=e=>`${es(e)} a run, booked`;function AI(e,n=null){const s=[`answers in ${lm(e.after.median_duration_s)} instead of ${lm(e.before.median_duration_s)}`];return n!==null&&s.push(`learning itself ${pC(n)}`),`Since it learned (${gC(e)}): ${s.join(" · ")}`}function gC(e){return`medians of ${id(e.after.runs)} started from what it learned`}const OI=e=>{const n=s=>!!s&&typeof s=="object"&&typeof s.runs=="number"&&s.runs>=2&&typeof s.median_duration_s=="number";return!!e&&typeof e=="object"&&n(e.before)&&n(e.after)},ub=e=>`#/agents/${encodeURIComponent(e)}/learning`;function xC(e){return e.kind===Xr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===Xr?{...e,kind:Xr,agent_label:null}:e}const Xr="learning",MI={seeded:0,reflecting:1,merged:2,dropped:2},jx=e=>e?MI[e.state]??0:-1,LI=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0};function PI(e){var n;if(!e||jx(e)<2)return"Looking back on this run…";if(e.state==="merged"){const s=hC(e),r=d=>d.map(u=>u.name.replace(/\s+/g," ").trim()).join(", "),o=s.filter(d=>!d.pending),i=s.filter(d=>d.pending),c=[...o.length?[`kept ${wl(o.length,"workflow")} (${r(o)})`]:[],...i.length?[`${wl(i.length,"workflow")} ${i.length===1?"waits":"wait"} for your OK (${r(i)})`]:[]];return c.length?`Looked back: ${c.join("; ")}`:`Looked back. ${((n=e.detail)==null?void 0:n.trim())||"It kept what it learned."}`}return im(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${db(e)}`}function II(e){var i;const n=xC(e),s=n.summary??"",r=O2(n)?`${s} (failed)`:s,o=(i=R2(n))==null?void 0:i.trimEnd();return o&&o.trim()!==s.trim()?`${r}
636
+ ${o.replace(/^(?=.)/gm," ")}`:r}function zI(e,n){const s=e.filter(u=>u.agent_label===Xr&&u.kind!==Xr);if(!s.length)return e.map(xC);const r=e.findLast(u=>u.kind===Xr),o=LI(r),i=jx(o)>jx(n??void 0)?o:n&&{...n,detail:n.detail??(o==null?void 0:o.detail)??(r==null?void 0:r.summary)??null},c=s[0],d={id:c.id,seq:c.seq,timestamp:c.timestamp,created_at:c.created_at,kind:Xr,agent_label:null,tool_name:null,tool_use_id:null,tool_status:null,tool_input_preview:null,tool_result_preview:null,tool_result_size_bytes:null,summary:PI(i??void 0),text:[...s,...r?[r]:[]].map(II).join(`
637
+ `)};return e.flatMap(u=>u===c?[d]:u.agent_label===Xr||u.kind===Xr?[]:[u])}const DI={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},d0=["Added","Changed","Removed"];function FI(e){const n=[],s=[];let r=0;for(const o of e.split(`
638
+ `)){const i=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(o);i?((r||Number(i[1])>1)&&n.push({text:"…",mark:"gap"}),(r||Number(i[2])>1)&&s.push({text:"…",mark:"gap"}),r++):r&&o.startsWith(" ")?(n.push({text:o.slice(1),mark:"same"}),s.push({text:o.slice(1),mark:"same"})):r&&o.startsWith("-")?n.push({text:o.slice(1),mark:"removed"}):r&&o.startsWith("+")&&s.push({text:o.slice(1),mark:"added"})}return{before:n,after:s}}function UI(e){if(e==="corrections.md")return"corrections";const n=/^workflows\/([^/]+)\/(workflow\.json|README\.md)$/.exec(e);return n?`workflow ${n[1]}${n[2]==="README.md"?" (README)":""}`:e}function WI(e){return e.files.map(s=>{const r=s.patch===void 0?null:FI(s.patch),o=`${s.status==="added"?"Added":s.status==="deleted"?"Removed":"Changed"}: ${UI(s.path)}`;return r?{file:s.path,said:o,before:s.status==="added"?null:r.before,after:s.status==="deleted"?null:r.after}:{file:s.path,said:o,before:null,after:null,withheld:DI[s.withheld??""]??"Not shown."}}).sort((s,r)=>d0.indexOf(s.said.split(":")[0])-d0.indexOf(r.said.split(":")[0]))}const vC=20,HI=e=>{const n=typeof e=="object"&&e!==null?e.compile_after:void 0;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:vC},BI=20,Gc={revision:"New revision",promote:"Promoted",hold:"Held"},fb={revision:"R",promote:"P",hold:"H"},bC=e=>e.decided==="replaying"?"revision":e.decided;function qI(e,n){const s=e.filter(c=>c.path!=="replay"&&c.n!==null);if(!e.length||!s.length)return[];const r=s.map(c=>Date.parse(c.started_at)),o=Date.parse(e[0].started_at),i=[];for(const c of n){const d=Date.parse(c.at),u=c.decided==="promote"?s.findIndex(f=>f.took_over&&f.digest===c.digest&&(f.workflow??c.workflow)===c.workflow):!Number.isFinite(d)||d<o-1?-1:r.findIndex(f=>f>=d);u<0||i.push({kind:bC(c),n:s[u].n,at:c.at,workflow:c.workflow,digest:c.digest,reason:c.reason,record:c})}return i.sort((c,d)=>c.n-d.n)}const GI=e=>e.path!=="replay",yC=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},mb=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function KI(e,{serving:n=null,stopped:s=null}={}){if(!e)return{word:"Not decided",tone:"muted"};const r=VI(e),o=r?{proof:r}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...o}:e.digest===s?{word:"Stopped",tone:"warning",...o}:{word:"Serving",tone:YI(e)?"success":"plain",...o}:e.decided==="hold"?{word:"Held",tone:"warning",...o}:{word:"Replaying",tone:"active"}}function ld(...e){const n=KI(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const hb=(e,n)=>{var s;return((s=e==null?void 0:e.workflows.find(r=>r.workflow===n&&r.state==="needs_revision"))==null?void 0:s.digest)??null};function VI(e){const n=e.check;return!(n!=null&&n.n)||e.decided!=="promote"&&e.decided!=="hold"?null:`checked on ${n.n} ${n.n===1?"input":"inputs"} · ${n.alone??0} alone`}const YI=e=>{var n;return(((n=e.check)==null?void 0:n.n)??0)>0},pf=e=>`${Math.round(e*100)}%`;function qa(e){var o;const n=e.check;if(!(n!=null&&n.n))return e.reason;const s=n.alone??0,r=n.agreed??0;return`Checked on ${n.n} ${n.n===1?"input":"inputs"} of the agent's own runs: ${s} answered alone (${pf(s/n.n)}, ${pf(n.alone_min)} needed), ${r} of those said what the agent said (${s?pf(r/s):"0%"}, ${pf(n.agree_min)} needed)${(o=n.outcomes)!=null&&o.handed_back?`, ${n.outcomes.handed_back} handed back`:""}`}function QI(e){var O,M;const{corrections:n,runs:s,workflows:r,cost:o,promotions:i,serving:c,loop:d,execution:u="hosted",compileAfter:f=vC}=e,g=r.filter(P=>rh(P.status)),y=d==null?void 0:d.compiles.find(P=>P.digest===null&&(P.draft_errors.length>0||P.attempts.length>0)),v=d==null?void 0:d.compiles.find(P=>P.digest!==null),h=o==null?void 0:o.summary,x=yC(o),b=i.at(-1),j=b?c.find(P=>P.workflow===b.workflow):void 0,k=(j==null?void 0:j.digest)??null,E=j!=null&&j.replaying?`revision ${j.replaying.slice(0,7)} is checked on the inputs of its agent's own runs before it serves`:(b==null?void 0:b.decided)==="hold"&&b.digest!==k?`revision ${b.digest.slice(0,7)} was held: ${qa(b)}`:null,N=k!==null&&b?hb(o,b.workflow)===k:!1,S=N?`revision ${k.slice(0,7)} no longer runs first: it cost as much as the agent by hand; the agent takes its runs`:null,$=S?E?`${S}; ${E}`:S:k&&E?`revision ${k.slice(0,7)} serves; ${E}`:null,_=[];if(_.push({key:"corrections",title:"Corrections",value:n===1?"1 correction":`${n} corrections`,detail:n?"yours, given whole to every later run":"none yet: grade a run with a correction, or write one here",state:n?"done":"now"}),u==="native")return _.push({key:"compiled",title:"Learning",value:"Corrections",detail:"Native runs are given your corrections; learned workflows are unavailable.",state:"later"}),_;if(g.length||v&&v.digest){const P=((O=g[0])==null?void 0:O.name)??(v==null?void 0:v.workflow)??"a workflow";_.push({key:"compiled",title:"Compiled",value:P,detail:v?`${v.attempts.length} ${v.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else y?_.push({key:"compiled",title:"Compile",value:"Draft failed",detail:`${y.attempts.length} ${y.attempts.length===1?"attempt":"attempts"}, the checks refused it: it tries again on a later run`,state:"warn"}):_.push({key:"compiled",title:"Compile",value:"Not yet",detail:u==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${f} completed runs`:`${Math.min(s,f)} of ${f} completed runs: a workflow compiles at ${f}, then is checked once on those runs' inputs against the agent's own answers`,state:s?"now":"later"});if(u==="sdk")return _.push({key:"took_over",title:"Use workflow",value:"Backend decides",detail:"Your backend keeps launching each run. The SDK can call accepted workflows through MCP with explicitly bound tools.",state:g.length?"now":"later"}),_;if(h!=null&&h.takeover)_.push({key:"took_over",title:"Took over",value:`Run ${h.takeover.n}`,detail:$??((M=b==null?void 0:b.check)!=null&&M.n?qa(b):b?b.reason:"the first run a learned workflow served"),state:N||(b==null?void 0:b.decided)==="hold"&&!k?"warn":"done"});else if(b)if($)_.push({key:"took_over",title:"Take over",value:ld(mb(i,b.workflow,k)??b,{serving:k,stopped:N?k:null}).word,detail:$,state:N?"warn":"done"});else{const P=ld(b,{serving:k});_.push({key:"took_over",title:"Take over",value:P.word,detail:b.decided==="replaying"?"being checked on the inputs of the agent's own runs before it serves; the agent takes the runs meanwhile":qa(b),state:b.decided==="hold"?"warn":"now"})}else _.push({key:"took_over",title:"Take over",value:"Not yet",detail:"a compiled workflow is checked once on the inputs of the agent's own runs, then serves first when it clears the check's bar",state:"later"});if(h!=null&&h.takeover&&h.withheld)_.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${wC(h.withheld)}: ${jC}`,state:"now"});else if(h!=null&&h.after&&h.before){const P=`${$g(h.before.mean_usd)} a run by the agent, ${$g(h.after.mean_usd)} all-in over the ${h.after.runs===1?"1 run":`${h.after.runs} runs`} it served since`,A=h.times_cheaper;A!==null&&A>1?_.push({key:"cheaper",title:"Cheaper",...JI(h,A),state:"done"}):A!==null?_.push({key:"cheaper",title:"Cheaper",value:A<1?h.before.mean_usd>0?`Not cheaper yet: ${ob(h.after.mean_usd/h.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:P,state:"now"}):_.push({key:"cheaper",title:"Cheaper",value:`${h.after.runs} served ${h.after.runs===1?"run":"runs"} so far`,detail:`${P}; how many times cheaper shows after ${BI} runs`,state:"now"})}else h!=null&&h.takeover&&h.after_state==="cost_unknown"?_.push({key:"cheaper",title:"Cheaper",value:"No cost yet",detail:"no served run's cost is known yet",state:"now"}):h!=null&&h.after?_.push({key:"cheaper",title:"Cheaper",value:`${h.after.runs} served ${h.after.runs===1?"run":"runs"} so far`,detail:`${$g(h.after.mean_usd)} all-in over the ${h.after.runs===1?"1 run":`${h.after.runs} runs`} it served; no priced agent runs before takeover to compare with`,state:"now"}):_.push({key:"cheaper",title:"Cheaper",value:"Not yet",detail:"no served runs yet: once a workflow takes over, the all-in cost of the runs it serves against before (replays are checks, not served runs)",state:"later"});return x&&_.push({key:"unsure",title:"Unsure",value:`${Math.round(x.back/x.ran*100)}% handed back`,detail:`of ${x.ran} runs it ran first`,state:x.back/x.ran>.25?"warn":"watch"}),_}function wC(e){const n=s=>`${s} ${s===1?"run's":"runs'"} cost`;return e.unknown?`${n(e.unknown)} unknown${e.at_most?`, ${e.at_most} known only as at most`:""}`:`${n(e.at_most)} known only as at most`}const jC="how many times cheaper shows once every run's cost is known";function JI(e,n){const s=ob(n),r=e.replay,o=r?`workflow ${Math.round(r.workflow_pct)}% vs agent ${Math.round(r.agent_pct)}% on ${r.n} inputs`:"";if(r!=null&&r.cleared){const i=e.hand_backs?` · served ${e.hand_backs.ran} ${e.hand_backs.ran===1?"run":"runs"}, handed back ${e.hand_backs.back}`:"";return{value:`${s} cheaper`,detail:`Passed the agreement check: ${r.agreed} of ${r.alone} agreed (bar ${Math.round(r.agree_min*100)}%)${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its check was below the bar (${o})`:"no check yet"}`}}const $g=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,XI=1e3,kC="Turn learning on and run the same job about 20 times: each run's cost shows here, and where a learned workflow takes the job over, the line falls.",NC=e=>e==="native"?"Native run costs include reported model usage and AgentRun learning. Compare repeated jobs; corrections do not enable workflow takeover.":e==="sdk"?"SDK run costs include reported backend usage and AgentRun learning. Your backend keeps launching jobs and binds the tools an accepted workflow can use.":kC,SC=e=>`${e} served ${e===1?"run":"runs"}`;function u0({v2:e,agentId:n,on:s,quiet:r=!1,promotions:o,onCost:i,reads:c=0,execution:d="hosted"}){const[u,f]=p.useState(null),[g,y]=p.useState([]),v=o??g,h=p.useRef(i);h.current=i;const[x,b]=p.useState(null),[j,k]=p.useState(0);return p.useEffect(()=>{let E=!0;return b(null),Promise.resolve().then(()=>e.learningCost(n,XI)).then(N=>{var S;E&&(f(N),(S=h.current)==null||S.call(h,N))},N=>{E&&b(N??new Error("unknown"))}),o||Promise.resolve().then(()=>e.learningPromotions(n)).then(N=>{E&&y(N.promotions)},()=>{}),()=>{E=!1}},[e,n,j,c,!o]),r&&(!u||u.runs.filter(E=>E.total_usd!==null).length<2)?null:x&&!u?t.jsx(xr,{problem:ua(x,"the cost per run"),onRetry:()=>k(E=>E+1),className:""}):u?t.jsx(tz,{data:u,on:s,promotions:v,execution:d}):t.jsx(An,{className:"h-[320px] w-full"})}const Ut={top:30,right:16,bottom:30,left:60},ZI=520,gf=17,ez=16,_r=260;function tz({data:e,on:n,width:s,promotions:r=[],execution:o="hosted"}){var ft,ve,Ee;const i=p.useMemo(()=>cI(e.runs),[e.runs]),c=p.useMemo(()=>i.filter(GI),[i]),d=dI(c.length),u=p.useMemo(()=>uI(c,d),[c,d]),f=p.useMemo(()=>qI(e.runs,r),[e.runs,r]),g=p.useMemo(()=>rb(e.runs),[e.runs]),{summary:y}=e,v=yC(e),h=p.useRef(null),[x,b]=p.useState(s??720);p.useEffect(()=>{const Q=h.current;if(s||!Q||typeof ResizeObserver>"u")return;const Me=new ResizeObserver(([pe])=>{pe&&pe.contentRect.width>0&&b(pe.contentRect.width)});return Me.observe(Q),()=>Me.disconnect()},[s]);const[j,k]=p.useState(null),[E,N]=p.useState(null),S=Ba.map(Q=>({...Q,runs:e.runs.filter(Me=>Me.path===Q.path).length})),$=[e.total_runs>e.runs.length?`The latest ${e.runs.length.toLocaleString("en-US")} of ${e.total_runs.toLocaleString("en-US")} runs.`:null,e.unknown_cost_runs?`${e.unknown_cost_runs===1?"1 run's":`${e.unknown_cost_runs} runs'`} cost is not known: left out.`:null,e.unknown_path_runs?`${e.unknown_path_runs===1?"1 run's":`${e.unknown_path_runs} runs'`} path and cost are not known: left out.`:null,...e.workflows.filter(Q=>Q.state==="needs_revision"&&Q.served&&Q.by_hand).map(Q=>`${Q.workflow} no longer runs first: ${Hi(Q.served.mean_usd)} a run all-in over its newest ${Q.served.runs} priced runs, at or over ${Hi(Q.by_hand.mean_usd)} a run by hand.${Q.unknown_cost_runs?` ${Q.unknown_cost_runs===1?"1 run":`${Q.unknown_cost_runs} runs`} of unknown cost left out.`:""} The agent takes its runs; a new version runs first again.`)].filter(Q=>!!Q);if(i.length<2)return t.jsxs(h0,{title:"Cost per run",headline:null,children:[t.jsxs("div",{className:"px-4 py-8 text-center",role:"status",children:[t.jsx("p",{className:"font-mono text-body",children:i.length?"One run so far.":"No run with a known cost yet."}),t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-body text-muted-foreground",children:NC(o)}),$.map(Q=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:Q},Q))]}),g.length>0&&(()=>{var ne;const Q=Math.max(300,x),Me=g[0].n,pe=(Q-Ut.left-Ut.right)/(g.at(-1).n-Me+1);return t.jsx("figure",{ref:h,className:"px-4 pb-3",children:t.jsx(m0,{runs:e.runs,width:Q,x:Ae=>Ut.left+(Ae-Me+.5)*pe,step:pe,plot:[Ut.left,Q-Ut.right],takeover:((ne=y.takeover)==null?void 0:ne.n)??null})})})()]});const _=Math.max(300,x),O=((ft=g[0])==null?void 0:ft.n)??1,M=((ve=g.at(-1))==null?void 0:ve.n)??O,P=y.before,A=y.takeover?Math.max(y.takeover.n,O):null,R=_<ZI?[]:[...P?[{key:"before",words:`Before ${Hi(P.mean_usd)}`,usd:P.mean_usd}]:[],...A!==null&&y.after?[{key:"after",words:`After ${Hi(y.after.mean_usd)}`,usd:y.after.mean_usd}]:[]],L=_-Ut.left-(R.length?uC(R.map(Q=>Q.words)):Ut.right),W=L/(M-O+1),U=Q=>Ut.left+(Q-O+.5)*W,{top:Y,above:D}=pI(i,u,(P==null?void 0:P.mean_usd)??null),G=[],F=[];for(const Q of f){const Me=U(Q.n)-W/2;let pe=F.findIndex(ne=>Me-ne>=ez);pe<0?(pe=F.length,F.push(Me)):F[pe]=Me,G.push(pe)}const q=F.length?F.length*gf+8:0,H=Ut.top+q,I=Q=>H+_r-Math.min(Q,Y)/Y*_r,V=hI(Y),J=dC(O,M,_<520?5:7),X=y.takeover&&y.takeover.n>=O?y.takeover:null,re=c.map((Q,Me)=>`${Me?"L":"M"}${U(Q.at).toFixed(1)},${I(u[Me]).toFixed(1)}`).join(""),ae=j===null?null:i[j],ye=y.times_cheaper!==null?`${ob(y.times_cheaper)} cheaper`:null,he=v?`${Uf(v.back,v.ran)} handed back since`:null,we=y.after?`${Hi(y.after.mean_usd)} all-in over ${SC(y.after.runs)} after`:y.takeover&&y.after_state==="cost_unknown"?"no served run's cost known yet":null,ze=y.before&&we?`${Hi(y.before.mean_usd)} a run before takeover, ${we}${ye?`: ${ye}`:""}${he?` · ${he}`:""}`:null,le=e.unknown_cost_runs+e.unknown_path_runs,me=fC(R.map(Q=>({...Q,at:I(Q.usd)})),H+4,H+_r),Ke=Q=>{const Me=Q.currentTarget.getBoundingClientRect(),pe=(Q.clientX-Me.left)/Me.width*_,ne=(Q.clientY-Me.top)/Me.height*(H+_r+Ut.bottom);if(f.length&&ne<H-2){k(null);const Ae=f.map((Pe,bt)=>({i:bt,d:Math.abs(U(Pe.n)-W/2-pe)+Math.abs(Ut.top+G[bt]*gf+8-ne)})).sort((Pe,bt)=>Pe.d-bt.d)[0];N(Ae&&Ae.d<=12?Ae.i:null);return}N(null),k(gI(i,O+(pe-Ut.left)/W-.5))},be=Q=>{const pe={ArrowRight:ne=>ne+1,ArrowLeft:ne=>ne-1,Home:()=>0,End:()=>i.length-1,PageUp:ne=>ne+10,PageDown:ne=>ne-10}[Q.key];if(!pe){Q.key==="Escape"&&k(null);return}Q.preventDefault(),k(ne=>Math.min(i.length-1,Math.max(0,pe(ne??(Q.key==="ArrowLeft"?i.length:-1)))))},ge=Q=>[Q.n===null?"Replay run":`Run ${Q.n}`,`${es(Q.total_usd)} all-in${Q.learning_usd?` (${es(Q.cost_usd??0)} the run, ${es(Q.learning_usd)} learning)`:""}`,`${mf(Q.path).label}${Q.workflow?`: ${Q.workflow}`:""}`,...Q.digest?[`Workflow revision ${Q.digest.slice(0,7)}`]:Q.path==="agent"?["No learned workflow ran"]:[],...Q.audited?["Audited: a shadow run of the agent checked it"]:[],...Q.path==="replay"?["A replay: learning's spend, out of the line"]:[]],Je=E===null?null:f[E]??null,tt=X?U(X.n)>Ut.left+L*.62:!1;return t.jsxs(h0,{title:"Cost per run",headline:ze,unknown:le,children:[t.jsxs("figure",{ref:h,className:"px-4 pb-2 pt-3",children:[t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground",children:[S.filter(Q=>Q.runs>0).map(Q=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:t.jsx("circle",{cx:"5",cy:"5",r:"4",className:Q.fill})}),Q.label," ",t.jsx("span",{className:"text-foreground",children:Q.runs})]},Q.path)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",d," runs"]}),P&&t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"4 3"})}),"Before takeover, the agent alone"]}),Object.keys(Gc).filter(Q=>f.some(Me=>Me.kind===Q)).map(Q=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${Q}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(p0,{x:0,y:0,kind:Q})}),Gc[Q]," ",t.jsx("span",{className:"text-foreground",children:f.filter(Me=>Me.kind===Q).length})]},Q))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:be,onBlur:()=>k(null),"aria-label":`Cost per run, runs ${O} to ${M}. ${ze??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:_,height:H+_r+Ut.bottom,className:"block select-none font-mono",onPointerMove:Ke,onPointerLeave:()=>{k(null),N(null)},"aria-hidden":!0,children:[V.map(Q=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Ut.left},${I(Q)}H${Ut.left+L}`,className:Q===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Ut.left-8,y:I(Q),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:es(Q)})]},Q)),J.map(Q=>t.jsx("text",{x:U(Q),y:H+_r+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:Q},Q)),t.jsx("text",{x:Ut.left,y:q?Ut.top-10:H-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Ut.left-8,y:H+_r+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((Q,Me)=>t.jsxs("g",{"data-testid":`marker-${Q.kind}`,opacity:E===null||E===Me?1:.55,children:[t.jsx("path",{d:`M${U(Q.n)-W/2},${Ut.top+G[Me]*gf+15}V${H+_r}`,className:CC[Q.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(p0,{x:U(Q.n)-W/2-7,y:Ut.top+G[Me]*gf+1,kind:Q.kind})]},`${Q.kind}:${Q.n}:${Q.workflow}:${Q.digest}:${Q.at}`)),i.map((Q,Me)=>Q.path==="replay"?t.jsx("circle",{cx:U(Q.at),cy:I(Q.total_usd),r:Me===j?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},Q.run_id):t.jsx("circle",{cx:U(Q.at),cy:I(Q.total_usd),r:Me===j?0:3,className:te(mf(Q.path).fill),fillOpacity:.65},Q.run_id)),P&&t.jsx("path",{d:`M${Ut.left},${I(P.mean_usd)}H${Ut.left+L}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),X&&t.jsxs("g",{"data-testid":"takeover",children:[t.jsx("path",{d:`M${U(X.n)-W/2},${H-4}V${H+_r}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(az,{x:U(X.n)-W/2+(tt?-6:6),y:H+6,anchor:tt?"end":"start",children:["Workflow took over, run ",X.n]})]}),A!==null&&y.after&&t.jsx("path",{d:`M${U(A)-W/2},${I(y.after.mean_usd)}H${Ut.left+L}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsx("path",{d:re,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),me.map(Q=>t.jsx("text",{"data-testid":"level-label",x:Ut.left+L+6,y:Q.at,dy:"0.32em",className:te("text-label",Q.key==="after"?"fill-foreground font-semibold":"fill-muted-foreground"),children:Q.words},Q.key)),ae&&t.jsxs("g",{children:[t.jsx("path",{d:`M${U(ae.at)},${H}V${H+_r}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:U(ae.at),cy:I(ae.total_usd),r:5,className:te(mf(ae.path).fill,"stroke-card"),strokeWidth:2})]})]}),Je&&!ae&&t.jsx("div",{className:te("pointer-events-none absolute z-raised max-w-[22rem] border bg-card px-2 py-1 font-mono text-label shadow-float",U(Je.n)>_*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:U(Je.n)>_*.6?U(Je.n)-W/2-12:U(Je.n)-W/2+12,top:Ut.top},children:g0(Je).map((Q,Me)=>t.jsx("span",{className:te("block",Me===0?"font-semibold":"text-muted-foreground"),children:Q},Me))}),ae&&t.jsxs("div",{className:te("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",U(ae.at)>_*.6&&"-translate-x-full"),style:{left:U(ae.at)>_*.6?U(ae.at)-10:U(ae.at)+10,top:H},children:[ge(ae).map((Q,Me)=>t.jsx("span",{className:te("block",Me===0?"font-semibold":"text-muted-foreground"),children:Q},Q)),t.jsx("span",{className:"block text-muted-foreground",children:vt(ae.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:ae?ge(ae).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(Q=>g0(Q).join(", ")).join(". ")}.`})]}),t.jsx(m0,{runs:e.runs,width:_,x:U,step:W,plot:[Ut.left,Ut.left+L],takeover:((Ee=y.takeover)==null?void 0:Ee.n)??null}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each dot is a run: its own cost plus what learning spent for it (its compile turn and its audit's shadow run). The line is the mean of the last ",d," runs",i.some(Q=>Q.path==="replay")?", replay runs (hollow) left out":"",".",D?` ${D===1?"1 run costs":`${D} runs cost`} more than ${es(Y)} and ${D===1?"is":"are"} drawn at the top.`:"",y.before?" The dashed line is what a run cost the agent before a learned workflow took over, learning left out; after it, every run counts learning in, so the drop never flatters learning.":""]}),[...$,...rz(e,n,o)].map(Q=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:Q},Q))]}),t.jsxs("details",{className:"border-t px-4 py-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Started","Path","Revision","Run $","Learning $","All-in $"].map(Q=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:Q},Q))})}),t.jsx("tbody",{children:e.runs.map(Q=>{var Me;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:Q.n??"-"}),t.jsx("td",{className:"pr-4",children:vt(Q.started_at)}),t.jsxs("td",{className:"pr-4",children:[mf(Q.path).label,Q.workflow?`: ${Q.workflow}`:""]}),t.jsxs("td",{className:"pr-4",children:[((Me=Q.digest)==null?void 0:Me.slice(0,7))??"-",Q.audited&&t.jsx("span",{"data-testid":"audited",className:"ml-2",children:t.jsx(Ne,{tone:"muted",title:"An audit's shadow run of the agent checked this run; its cost is in Learning $.",children:"audited"})})]}),t.jsx("td",{className:"pr-4",children:Q.cost_usd===null?"unknown":es(Q.cost_usd)}),t.jsx("td",{className:"pr-4",children:Q.learning_usd===null?"unknown":es(Q.learning_usd)}),t.jsx("td",{className:"pr-4",children:Q.total_usd===null?"unknown":es(Q.total_usd)})]},Q.run_id)})})]})}),f.length>0&&t.jsxs("table",{className:"mt-3 w-full border-collapse font-mono text-small","data-testid":"marker-table",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Marker","Workflow","Revision","Numbers"].map(Q=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:Q},Q))})}),t.jsx("tbody",{children:f.map(Q=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:Q.n}),t.jsxs("td",{className:"pr-4",children:[fb[Q.kind]," ",Gc[Q.kind]]}),t.jsx("td",{className:"pr-4",children:Q.workflow}),t.jsx("td",{className:"pr-4",children:Q.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:qa(Q.record)})]},`${Q.kind}:${Q.n}:${Q.workflow}:${Q.digest}:${Q.at}`))})]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["As CSV: ",t.jsxs("code",{className:"font-mono",children:["agentrun learning cost ",e.agent," --format csv"]})]})]})]})}const nz=64,Io={top:4,bottom:6},sz=[...Ba].reverse(),f0=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function m0({runs:e,width:n,x:s,step:r,plot:o,takeover:i}){const c=nz,d=xI(rb(e).length),u=p.useMemo(()=>vI(e,d),[e,d]),[f,g]=p.useState(null);if(!u.length)return null;const[y,v]=o,h=M=>Math.min(v,Math.max(y,M)),x=M=>({from:h(s(M.from)-r/2),to:h(s(M.to)+r/2)}),b=M=>Io.top+c*(1-M),j=u.at(-1),k=M=>{const{from:P,to:A}=x(M),R=A-P>4?1:0;return{x0:P+R,w:Math.max(1,A-P-2*R)}},E=M=>`${f0(M)}: ${Ba.filter(P=>M.counts[P.path]).map(P=>`${P.label.toLowerCase()} ${M.counts[P.path]}`).join(", ")}`,N=u.some(M=>M.counts.workflow)?`${Uf(j.counts.workflow,j.runs)} by the learned workflow`:Ba.filter(M=>j.counts[M.path]).map(M=>`${Uf(j.counts[M.path],j.runs)} ${M.label.toLowerCase()}`).join(", "),S=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${N}`,$=f===null?null:u[f],_=$?k($).x0>n/2:!1,O=i!==null&&s(i)>=y&&s(i)<=v;return t.jsxs("div",{className:"relative min-w-0",style:{width:n},"data-testid":"execution-mix",children:[t.jsxs("div",{className:"font-mono text-label",style:{paddingLeft:y},children:[t.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",d>1?`, by ${d}`:""]}),t.jsx("span",{className:"block text-foreground",children:S})]}),t.jsxs("svg",{width:n,height:Io.top+c+Io.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>g(null),children:[[0,.5,1].map(M=>t.jsxs("text",{x:y-6,y:b(M),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[M*100,"%"]},M)),u.map((M,P)=>{const{x0:A,w:R}=k(M);let L=Io.top+c;return t.jsxs("g",{onPointerEnter:()=>g(P),opacity:f===null||f===P?1:.55,children:[t.jsx("rect",{x:x(M).from,y:Io.top,width:Math.max(1,x(M).to-x(M).from),height:c,className:"fill-card",fillOpacity:0}),sz.map(W=>{const U=M.counts[W.path]/M.runs*c;if(!U)return null;L-=U;const Y=L>Io.top+.5?Math.min(2,U):0;return t.jsx("rect",{x:A,y:L+Y,width:R,height:U-Y,className:W.fill,fillOpacity:.8},W.path)})]},M.from)}),O&&t.jsx("g",{"data-testid":"mix-takeover",children:t.jsx("path",{d:`M${s(i)-r/2},${Io.top}V${Io.top+c}`,className:"stroke-chart-workflow",strokeWidth:1.5})})]}),$&&t.jsxs("div",{className:te("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",_&&"-translate-x-full"),style:{left:_?k($).x0-6:k($).x0+k($).w+6,top:40},children:[t.jsx("span",{className:"block font-semibold",children:f0($)}),Ba.filter(M=>$.counts[M.path]).map(M=>t.jsxs("span",{className:"block text-muted-foreground",children:[M.label," ",$.counts[M.path]," (",Uf($.counts[M.path],$.runs),")"]},M.path))]}),t.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${d} runs. ${u.map(E).join(". ")}. ${S}.`})]})}function rz(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[NC(s)]:r.takeover?r.withheld?[`${wC(r.withheld)}: ${jC}.`]:r.after_state==="cost_unknown"?["No run the workflow served has a known cost yet: a replay is a check, never a served run."]:r.times_cheaper===null&&r.after?[`${SC(r.after.runs)} since the workflow took over: how many times cheaper it is shows after 20.`]:[]:[n?"No learned workflow has finished a run alone yet. Keep running the same job: once one does, a marker shows where, and the level after it.":kC]}function h0({title:e,headline:n,unknown:s=0,children:r}){return t.jsxs("section",{className:"min-w-0 border","aria-label":e,"data-testid":"cost-per-run",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n}),s>0&&t.jsx(Ne,{tone:"muted",className:"self-center",title:"Runs whose path or cost the server can't tell: left out of the chart, never drawn at $0.",children:s===1?"1 run unknown":`${s} runs unknown`})]}),r]})}const CC={promote:"stroke-chart-workflow",hold:"stroke-warning",revision:"stroke-muted-foreground"},oz={promote:"fill-foreground",hold:"fill-warning-text",revision:"fill-muted-foreground"};function p0({x:e,y:n,kind:s}){return t.jsxs("g",{children:[t.jsx("rect",{x:e+.75,y:n+.75,width:12.5,height:12.5,className:te("fill-card",CC[s]),strokeWidth:1.5,rx:2}),t.jsx("text",{x:e+7,y:n+7,dy:"0.35em",textAnchor:"middle",className:te("text-micro font-semibold",oz[s]),children:fb[s]})]})}const g0=e=>[`${Gc[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,qa(e.record),vt(e.at)];function az({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:te("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:o})}const _g=e=>`${e} ${e===1?"run":"runs"}`,xf=e=>e>=1?`$${e.toFixed(2)}`:es(e);function iz(e){const n=e.points.at(-1),s=e.withheld?` · ${_g(e.withheld)} of unknown cost on neither line`:"";if(!n)return{headline:`No run with a known cost yet${s}`,marker:null};if(!e.promoted)return{headline:`No learned workflow serves yet: the bill is the agent's own, ${xf(e.booked_usd)} over ${_g(e.points.length)}${s}`,marker:null};if(e.break_even){const o=n.agent_usd===null?"":`, ${xf(n.agent_usd)} had the agent done all of it`;return{headline:`Break-even at run ${e.break_even.n}: ${xf(e.booked_usd)} booked over ${_g(e.points.length)}${o}${s}`,marker:e.break_even.n}}return{headline:`Not yet${e.gap_usd===null?"":`: ${xf(e.gap_usd)} over the agent for all of it at run ${n.n}`}${s}`,marker:null}}function lz(e,n,s=[]){return e.map(r=>{const o=typeof n=="string"?null:n.filter(d=>d.workflow===r.workflow),i=o===null?null:o.filter(d=>d.agreed!==null),c=new Set(o==null?void 0:o.filter(d=>d.source==="shadow").map(d=>d.run));return{workflow:r.workflow,recent:r.audit?{rows:r.audit.rows,agreed:r.audit.rows-r.audit.disagreed,window:r.audit.window,disagree:r.audit.disagree}:null,all:i===null?null:{rows:i.length,agreed:i.filter(d=>d.agreed).length},off:r.audits_off,pending:o===null?null:s.filter(d=>d.audited&&d.workflow===r.workflow&&!c.has(d.run_id)).length}})}const cz=e=>e.points.length?e.learning_usd/e.points.length:null,dz=e=>e==="fast"?"fast":e==="agent"?"agent model":"-",uz=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function kx(e){return uz(e)?e.predicate==="not"?`not ${kx(e.of)}`:(e.predicate==="and"||e.predicate==="or")&&Array.isArray(e.of)?e.of.map(kx).join(` ${e.predicate} `):e.predicate==="field_equals"&&typeof e.path=="string"?`${e.path} = ${JSON.stringify(e.value)}`:[e.predicate,e.path].filter(n=>typeof n=="string").join(" ")||"?":"?"}const fz=e=>`${e.on} ${kx(e.predicate)}`,x0=e=>`${Math.round(e*100)}%`;function mz(e){return e!=null&&e.n?`Checked on ${e.n} ${e.n===1?"input":"inputs"}: ${e.alone??0} answered alone (bar ${x0(e.alone_min)}), ${e.agreed??0} of them agreed (bar ${x0(e.agree_min)}) · inputs from the newest ${e.compile_after} runs · ${e.attempt===1?"first check":"the recompile's check"}`:"Promoted with no check behind it"}function v0({v2:e,agentId:n,cost:s,serving:r,width:o}){const i=s==null?void 0:s.bill,c=!!(i!=null&&i.points.length),[d,u]=p.useState("loading"),f=r.find(g=>g.digest!==null&&g.champion)??null;return p.useEffect(()=>{if(!c)return;let g=!0;return Promise.resolve().then(()=>e.learningAudits(n)).then(y=>{g&&u(y.audits)},()=>{g&&u("failed")}),()=>{g=!1}},[e,n,c,s]),!i||!c?null:t.jsxs(t.Fragment,{children:[t.jsx(hz,{bill:i,width:o}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[t.jsx(pz,{serving:r,audits:d,bill:i,runs:s.runs}),(f==null?void 0:f.champion)&&t.jsx(gz,{workflow:f.workflow,champion:f.champion})]})]})}const cn={top:16,right:16,bottom:30,left:60},zo=220;function hz({bill:e,width:n}){var U,Y;const s=p.useRef(null),[r,o]=p.useState(n??720);p.useEffect(()=>{const D=s.current;if(n||!D||typeof ResizeObserver>"u")return;const G=new ResizeObserver(([F])=>{F&&F.contentRect.width>0&&o(F.contentRect.width)});return G.observe(D),()=>G.disconnect()},[n]);const[i,c]=p.useState(null),d=e.points,{headline:u,marker:f}=iz(e),g=d.some(D=>D.agent_usd!==null),y=Math.max(300,r),v=y<520,{top:h,ticks:x}=p.useMemo(()=>mI(d.reduce((D,G)=>Math.max(D,G.actual_usd,G.agent_usd??0),-1/0)),[d]),b=D=>cn.top+zo-D/h*zo,j=d.at(-1),k=j&&!v?fC([{key:"bill",words:`Bill ${vf(j.actual_usd)}`,at:b(j.actual_usd)},...j.agent_usd!==null?[{key:"agent",words:`Agent ${vf(j.agent_usd)}`,at:b(j.agent_usd)}]:[]],cn.top+4,cn.top+zo):[],E=y-cn.left-(k.length?uC(k.map(D=>D.words)):cn.right),N=((U=d[0])==null?void 0:U.n)??1,S=((Y=d.at(-1))==null?void 0:Y.n)??1,$=D=>cn.left+(S===N?E/2:(D-N)/(S-N)*E),_=D=>D.map(([G,F],q)=>`${q?"L":"M"}${$(G).toFixed(1)},${b(F).toFixed(1)}`).join(""),O=_(d.map(D=>[D.n,D.actual_usd])),M=g?_(d.filter(D=>D.agent_usd!==null).map(D=>[D.n,D.agent_usd])):null,P=i===null?null:d[i]??null,A=e.unattributed_usd??0,R=D=>{const G=D.currentTarget.getBoundingClientRect(),F=(D.clientX-G.left)/G.width*y;let q=0;d.forEach((H,I)=>{Math.abs($(H.n)-F)<Math.abs($(d[q].n)-F)&&(q=I)}),c(d.length?q:null)},L=D=>{const F={ArrowRight:q=>q+1,ArrowLeft:q=>q-1,Home:()=>0,End:()=>d.length-1}[D.key];if(!F){D.key==="Escape"&&c(null);return}D.preventDefault(),c(q=>Math.min(d.length-1,Math.max(0,F(q??(D.key==="ArrowLeft"?d.length:-1)))))},W=D=>[`Run ${D.n}`,`Your bill ${es(D.actual_usd)}`,...D.agent_usd===null?[]:[`The agent for all of it ${es(D.agent_usd)}`]];return t.jsxs(pb,{title:"The bill",headline:u,testid:"learning-bill",children:[t.jsxs("figure",{ref:s,className:"px-4 pb-2 pt-3",children:[g&&t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground","data-testid":"bill-legend",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-chart-workflow",strokeWidth:2})}),"Your bill, booked"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-chart-agent",strokeWidth:2,strokeDasharray:"5 3"})}),"The agent for all of it"]})]}),t.jsxs("div",{className:"relative",tabIndex:0,onKeyDown:L,onBlur:()=>c(null),"aria-label":`The bill, runs ${N} to ${S}. ${u}. Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:y,height:cn.top+zo+cn.bottom,className:"block select-none font-mono",onPointerMove:R,onPointerLeave:()=>c(null),"aria-hidden":!0,children:[t.jsx("g",{"data-testid":"bill-y-axis",children:x.map(D=>t.jsxs("g",{children:[t.jsx("path",{d:`M${cn.left},${b(D)}H${cn.left+E}`,className:D===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:cn.left-8,y:b(D),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:es(D)})]},D))}),dC(N,S,v?5:7).map(D=>t.jsx("text",{x:$(D),y:cn.top+zo+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:D},D)),t.jsx("text",{x:cn.left-8,y:cn.top+zo+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f!==null&&t.jsxs("g",{"data-testid":"bill-break-even",children:[t.jsx("path",{d:`M${$(f)},${cn.top}V${cn.top+zo}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(xz,{x:$(f)+($(f)>cn.left+E*.7?-6:6),y:cn.top+10,anchor:$(f)>cn.left+E*.7?"end":"start",strong:!0,children:["Break-even, run ",f]})]}),M&&t.jsx("path",{d:M,"data-testid":"bill-agent",fill:"none",className:"stroke-chart-agent",strokeWidth:2,strokeDasharray:"5 3",strokeLinejoin:"round"}),t.jsx("path",{d:O,"data-testid":"bill-actual",fill:"none",className:"stroke-chart-workflow",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),j&&k.map(D=>t.jsx("text",{"data-testid":"bill-end-label",x:$(j.n)+6,y:D.at,dy:"0.32em",className:te("text-label",D.key==="bill"?"fill-foreground font-semibold":"fill-muted-foreground"),children:D.words},D.key)),P&&t.jsxs("g",{children:[t.jsx("path",{d:`M${$(P.n)},${cn.top}V${cn.top+zo}`,className:"stroke-border-strong",strokeWidth:1}),P.agent_usd!==null&&t.jsx("circle",{cx:$(P.n),cy:b(P.agent_usd),r:4,className:"fill-chart-agent stroke-card",strokeWidth:2}),t.jsx("circle",{cx:$(P.n),cy:b(P.actual_usd),r:4,className:"fill-chart-workflow stroke-card",strokeWidth:2})]})]}),P&&t.jsx("div",{className:te("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",$(P.n)>y*.6&&"-translate-x-full"),style:{left:$(P.n)>y*.6?$(P.n)-10:$(P.n)+10,top:cn.top},children:W(P).map((D,G)=>t.jsx("span",{className:te("block",G===0?"font-semibold":"text-muted-foreground"),children:D},D))}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:P?W(P).join(", "):""})]}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each point adds a run that did a job, all in: its own cost, its compile turn and its audit's shadow run, with each replay run on the run before it.",g?" The dashed line is the mean of the agent's own runs before its first served run, times the runs.":"",A>0?` ${es(A)} of learning spend is on no run yet: a revision's compile and check its next served runs carry, or one that stopped or never drafted.`:""]})]}),t.jsxs("details",{className:"border-t px-4 py-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Run id","Your bill $","The agent for all of it $"].map(D=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:D},D))})}),t.jsx("tbody",{children:d.map(D=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:D.n}),t.jsx("td",{className:"pr-4",children:D.run_id}),t.jsx("td",{className:"pr-4",children:vf(D.actual_usd)}),t.jsx("td",{className:"pr-4",children:D.agent_usd===null?"-":vf(D.agent_usd)})]},D.run_id))})]})})]})]})}const vf=e=>e>=1?`$${e.toFixed(2)}`:es(e);function pz({serving:e,audits:n,bill:s,runs:r=[]}){var d;const o=lz(e,n,r),i=s.holds;if(!o.length&&!i.length)return null;const c=(d=s.points.at(-1))==null?void 0:d.n;return t.jsxs(pb,{title:"Audits",headline:null,testid:"learning-audits",children:[t.jsx("ul",{className:"space-y-2 px-4 py-3 text-body",children:o.map(u=>t.jsxs("li",{className:"space-y-0.5",children:[t.jsx("span",{className:"block font-mono font-semibold",children:u.workflow}),u.recent&&t.jsxs("span",{className:"block",children:["Last ",u.recent.rows," ",u.recent.rows===1?"audit":"audits",": ",u.recent.agreed," agreed ",t.jsxs("span",{className:"text-muted-foreground",children:["· hold at ",u.recent.disagree," disagreeing of the newest ",u.recent.window]})]}),u.all&&t.jsxs("span",{className:"block",children:["All time: ",u.all.agreed," of ",u.all.rows," agreed",u.pending?t.jsxs("span",{className:"text-muted-foreground",title:"Its shadow run is charged to the run; the audit is scored at a later run's start.",children:[" · ",u.pending," not scored yet"]}):null]}),u.off&&t.jsx("span",{className:"block text-muted-foreground",children:u.off})]},u.workflow))}),n==="failed"&&t.jsx("p",{className:"border-t px-4 py-2 text-small text-warning-text",role:"status",children:"The audits couldn't be read, so there is no all-time figure. Reload to try again."}),i.length>0&&t.jsx("ul",{className:"space-y-0.5 border-t px-4 py-3 font-mono text-small","data-testid":"audit-holds",children:i.map(u=>t.jsxs("li",{children:[u.n!==null?`Held at run ${u.n}`:`Held after run ${c??0}`," ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",u.workflow," · ",u.by==="audit"?"by its audits":u.by==="check"?"by its check":"refused by this release's DSL"," · ",vt(u.at)]})]},`${u.workflow}:${u.at}`))})]})}function gz({workflow:e,champion:n}){const s=n.nodes;return t.jsxs(pb,{title:"Serving workflow",headline:e,testid:"serving-workflow",children:[s!=null&&s.length?t.jsx("div",{className:"overflow-auto px-4 py-2",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Node","Kind","Tier","Code checks"].map(r=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:r},r))})}),t.jsx("tbody",{children:s.map(r=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:r.label}),t.jsx("td",{className:"pr-4 text-muted-foreground",children:r.kind}),t.jsx("td",{className:"whitespace-nowrap pr-4",children:dz(r.tier)}),t.jsx("td",{className:"pr-4",children:r.checks.map(fz).join("; ")||"-"})]},r.path))})]})}):t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:s===null?"Its workflow.json couldn't be read.":"Its workflow.json has no nodes."}),t.jsx("p",{className:"border-t px-4 py-2 text-small text-muted-foreground",children:mz(n.check)})]})}function pb({title:e,headline:n,testid:s,children:r}){return t.jsxs("section",{className:"min-w-0 border bg-card","aria-label":e,"data-testid":s,children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n})]}),r]})}function xz({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:te("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:o})}const cm="https://api.githubcopilot.com/mcp/",Id={composio:"Composio",github:"GitHub",url:"URL"},b0=/^[a-z][a-z0-9-]{0,31}$/,gb=[{id:"parallel",label:"Parallel Search",name:"parallel",url:"https://mcp.parallel.ai/mcp",auth:"none",note:"Web search, free for light use: no key, no account."},{id:"firecrawl",label:"Firecrawl",name:"firecrawl",url:"https://mcp.firecrawl.dev/v2/mcp",auth:"none",note:"Search, scrape and parse, free without a key and rate limited: add your Firecrawl key later as a bearer token for more."},{id:"github-token",label:"GitHub (token)",name:"github",url:cm,readOnly:`${cm}readonly`,auth:"bearer",note:"A fine-grained personal access token for the repositories it may use, with Contents, Issues and Pull requests (read-only, or read and write)."},{id:"linear",label:"Linear",name:"linear",url:"https://mcp.linear.app/mcp",auth:"oauth",note:"Sign in with your Linear account: this server keeps the tokens."},{id:"notion",label:"Notion",name:"notion",url:"https://mcp.notion.com/mcp",auth:"oauth",note:"Sign in with your Notion workspace: this server keeps the tokens."}],EC=e=>gb.find(n=>n.id===e);function vz(e){const n=new URLSearchParams(e??""),s=n.get("add");if(!s||!b0.test(s))return;const r=n.get("toolkit")??"",o=n.get("preset")??void 0;if(o==="composio"&&b0.test(r)){const c=(n.get("tools")??"").split(",").filter(d=>/^[A-Za-z0-9_-]{1,128}$/.test(d)).slice(0,64);return{name:s,preset:"composio",toolkit:r,...c.length?{tools:c}:{}}}const i=EC(o);return i?{name:s,preset:i.id}:{name:s,...n.get("auth")==="github_app"?{auth:"github_app"}:{}}}const bz="These are the tools the server offers, not what this credential allows: a read-only token still sees its write tools. A call the credential can't make is refused by the server when a run makes it.",$C=(e,n)=>`mcp:${e}/${n}`;function Zo(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function yz(e,n){var s,r;return e.grantable===!1?`${e.name} can't be granted: ${e.reason??"it runs other actions by name."}`:((s=e.grant_problems)==null?void 0:s["*"])??((r=e.grant_problems)==null?void 0:r[n])}function wz(e,n){return e.flatMap(s=>{const r=Zo(s);if(!r)return[];const o=n.find(i=>i.name===r.server);return o?o.tools.some(i=>i.name===r.tool)?[]:[{grant:s,why:`${r.server} no longer lists ${r.tool}: refresh it, or untick this.`}]:[{grant:s,why:`The MCP server ${r.server} is not saved here any more, so a run can't call it.`}]})}const y0=e=>`Create an OAuth app with its provider (on GitHub, an OAuth App in your account's developer settings)${e?`, with ${e} as its callback URL,`:","} then enter its Client ID and Secret in this server's OAuth fields and sign in.`;function co(e){var i,c,d,u,f,g,y,v;if(!(e instanceof Ue))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const n=(i=e.fields)==null?void 0:i.find(h=>h.field==="url"&&h.reason==="redirect"),s=(c=e.fields)==null?void 0:c.find(h=>h.field==="client_id"&&h.reason==="registration_unavailable"),r=(d=e.details)==null?void 0:d.oauth,o=typeof(r==null?void 0:r.callback)=="string"?r.callback:"";return s?{text:s.message,detail:y0(o),signIn:!0,needsClient:!0}:e.code==="auth_required"&&((u=e.details)==null?void 0:u.auth)==="oauth"&&(r==null?void 0:r.registration)===!1?{text:"This server signs in with OAuth, and its sign-in lets no app register itself.",detail:y0(o),signIn:!0,needsClient:!0}:e.code==="auth_required"?((f=e.details)==null?void 0:f.auth)==="oauth"?{text:"This server signs in with OAuth.",detail:"Sign in to it: its tools are saved once you approve.",signIn:!0}:{text:"This server asks for a token.",detail:e.message}:e.code==="github_not_connected"?{text:"GitHub is not connected on this server.",detail:`${e.message} A GitHub App server runs on this server's GitHub App: connect GitHub, or add a repository to its installation, in Settings → GitHub, then try again.`}:e.code==="not_mcp"?{text:"This address doesn't speak MCP.",detail:e.message}:n?{text:"This address redirects; use the final address.",detail:n.message}:e.status===424?{text:`The server failed: ${e.message}`}:e.code==="wrong_origin"?{text:"Sign in from this server's own address: the sign-in comes back there.",...typeof((g=e.details)==null?void 0:g.open)=="string"?{detail:`Open ${e.details.open} and sign in from it.`}:{}}:(y=e.fields)!=null&&y.length?{text:e.fields.map(h=>h.message).join(" "),...typeof((v=e.details)==null?void 0:v.composio)=="string"?{detail:e.details.composio}:{}}:{text:`${e.code}: ${e.message}`}}const w0={access_denied:"the sign-in was declined on its approval page",invalid_scope:"its authorization server doesn't offer the scopes asked for: change them and sign in again",invalid_grant:"its authorization server didn't take the sign-in's code (it expired, or was used already): sign in again",invalid_client:"its authorization server didn't take this client: check the client ID and secret, or leave them empty",unauthorized_client:"its authorization server doesn't let this client sign in this way: check the client ID, or leave it empty",invalid_request:"its authorization server refused the sign-in's request",unsupported_response_type:"its authorization server doesn't support this way of signing in",unsupported_grant_type:"its authorization server doesn't support this way of signing in",invalid_target:"its authorization server won't give a token for this MCP server",server_error:"its authorization server failed: try again",temporarily_unavailable:"its authorization server is busy: try again in a moment",login_required:"its authorization server wants you to sign in on its page: sign in again",interaction_required:"its authorization server wants you to sign in on its page: sign in again",consent_required:"its authorization server wants your consent on its page: sign in again",auth_required:"the MCP server didn't take the token the sign-in gave",not_mcp:"the address doesn't speak MCP",input_invalid:"the MCP server's tools could not be kept (too many of them, or the address redirects)",upstream_failed:"the MCP server or its authorization server failed: try again",unavailable:"this server was stopping: sign in again",changed_meanwhile:"the server was changed or removed while you signed in, so nothing was saved"},jz="the sign-in didn't finish: try again",kz=e=>e&&Object.hasOwn(w0,e)?w0[e]:jz;function Nz(e){const n=new URLSearchParams(e??""),s=n.get("server"),r=n.get("sign_in");if(!(!s||r!=="ok"&&r!=="failed"))return{server:s,ok:r==="ok",...r==="failed"?{error:n.get("error")??"sign_in_failed"}:{}}}const zd=Zo;function Sz(e){const n=Zo(e);return n?`${n.server} · ${n.tool}`:null}function jl(e,n){return od(e)?{text:`${e.slice(cx.length+1)} · on your ChatGPT plan`,title:e}:n&&e.startsWith(`${n}/`)&&e.length>n.length+1?{text:e.slice(n.length+1),title:e}:{text:e}}function _C(e,n){var s;return new Map((((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.free_models)??[]).map(r=>[r.id,r]))}function Cz(e,n,s,r){return!e||typeof r!="number"||od(e)?null:_C(n,s).has(e)?`free model: up to ${r} requests`:null}function Ez(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function $z(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function xb(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.default_model)??void 0}const _z="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",Tz="none yet: add a model key in Settings → Model keys",TC=e=>jl(e,null).text,vb=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?TC(n.model):void 0].filter(Boolean).join(" · "),RC=e=>e!=null&&e.model?`ran on ${TC(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",Rz="http://www.w3.org/2000/svg",Bi=16,mn=240,Az=40,Oz=58,Tg=16,Rg=26,bf=18,qi=14,j0=16,Mz=26,Lz=14,Pz=22,Ws=14,k0=16,yf=16,Iz=4,zz=10,Dz=18,Fz=30,Uz=5,Dc=124,Nx=34,Wz=4,Ag=10*.6,Hz=12.5*.6,cd=10.5*.6,N0=11*.6,bb=9*.66,S0=10.5*.6,Bz={agent:"agent",decide:"agent",extract:"agent",report:"agent",artifact:"agent",judge:"jev",pick:"jev",sift:"jev",route:"jev",call:"tool",code:"code",escalate:"exit",chain:"control",parallel:"control",map:"control",loop:"control",workflow:"control"},yb=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),dm={review:"needs review","not-run":"",pending:""};function Nt(e,n,...s){const r=document.createElementNS(Rz,e);if(n)for(const[o,i]of Object.entries(n))r.setAttribute(o,String(i));for(const o of s)Es(r,o);return r}function Es(e,n){if(n!=null){if(Array.isArray(n)){for(const s of n)Es(e,s);return}e.appendChild(typeof n=="string"?document.createTextNode(n):n)}}const Pr=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,qz=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?Pr(e,n):`${Pr(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},Bo=(e,n)=>Math.max(2,Math.floor(e/n)),ea=(e,n)=>Math.ceil(e.length*n),qs=(e,n,s,r,o)=>Nt("line",{x1:e,y1:n,x2:s,y2:r,class:o?`wire ${o}`:"wire"});function AC(e){const n={},s={};for(const o of e)n[o.path]=o;const r=o=>{var i;return((i=n[o])==null?void 0:i.kind)??""};for(const o of e){let i;const c={node:o,order:0,name:null};let d=null;(i=/^(.*)\/steps\/(\d+)$/.exec(o.path))&&r(i[1])==="chain"?(d=i[1],c.order=Number(i[2])):(i=/^(.*)\/branches\/([^/]*)\/body$/.exec(o.path))&&r(i[1])==="route"?(d=i[1],c.name=i[2].replace(/~1/g,"/").replace(/~0/g,"~")):(i=/^(.*)\/branches\/(\d+)$/.exec(o.path))&&r(i[1])==="parallel"?(d=i[1],c.order=Number(i[2])):((i=/^(.*)\/body$/.exec(o.path))&&(r(i[1])==="map"||r(i[1])==="loop")||(i=/^(.*)\/workflow\/root$/.exec(o.path))&&r(i[1])==="workflow")&&(d=i[1]),d!==null&&(s[d]??(s[d]=[])).push(c)}for(const o of Object.values(s))o.sort((i,c)=>i.order-c.order);return{byPath:n,kids:s}}function wb(e,n){var u,f,g,y;const{diff:s={},status:r={},fired:o}=e.marks,i=n===o?"escalated":r[n],c=i&&yb.has(i)?i:"",d=(u=s.added)!=null&&u.includes(n)?"NEW":(f=s.edited)!=null&&f.includes(n)?"EDITED":(g=s.moved)!=null&&g.includes(n)?"MOVED":"";return{state:c,tag:d,fired:n===o,selected:((y=e.marks.selected)==null?void 0:y.path)===n&&e.marks.selected.item==null}}function Dd(e,n,s){var v,h,x;const r=wb(e,n.path),o=(v=e.marks.meta)==null?void 0:v[n.path],i=o!=null&&o.tool?zd(o.tool):null,c=(h=e.marks.ran)==null?void 0:h[n.path],d=o!=null&&o.decision?(c==null?void 0:c.model)??o.model:o==null?void 0:o.model;let u=`${n.label} (${n.kind}${i?`: ${i.tool} on ${i.server}, an MCP server's tool`:n.via?` via ${n.via}`:""}${o!=null&&o.provider?`, ${o.provider}${d?` ${d}`:""}`:""}${c&&!(o!=null&&o.decision)?`, ${RC(c)}`:""})`;r.state&&(u+=`: ${r.state.replace("-"," ")}`),r.tag&&(u+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(x=o==null?void 0:o.questions)!=null&&x.length&&(u+=`
639
+ ${o.questions.map(b=>`• ${b.text}`).join(`
640
+ `)}`);const f=o!=null&&o.decision&&o.provider?`who-${o.provider==="parallel"||o.provider==="openrouter"?o.provider:"jev"}`:n.kind==="route"&&o&&!o.decision?"who-control":`who-${Bz[n.kind]??"code"}`;let g=`node ${s} ${f}`;r.state&&(g+=` ${r.state}`),r.fired&&(g+=" fired"),r.tag&&(g+=` ${r.tag.toLowerCase()}`),r.selected&&(g+=" selected");const y=Nt("g",{class:g,"data-path":n.path},Nt("title",null,u));return e.svg.appendChild(y),y}const il=e=>ea(e,bb)+10;function Wf(e,n,s,r,o="tag"){const i=il(r);return Es(e,[Nt("rect",{x:n,y:s,width:i,height:13,class:`${o}-box`}),Nt("text",{x:n+i/2,y:s+9.5,class:o,"text-anchor":"middle"},r)]),i}const Gz=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},ah=(e,n)=>Gz(e,n)?Oz:Az;function jb(e,n,s,r,o){var k,E,N,S,$;const i=wb(e,s.path),c=(k=e.marks.meta)==null?void 0:k[s.path],d=ah(e,s),u=(E=e.marks.verdict)==null?void 0:E[s.path],f=i.state in dm?dm[i.state]:i.state,g=((N=c==null?void 0:c.questions)==null?void 0:N.length)??0,y=c!=null&&c.tool?zd(c.tool):null,v=(S=e.marks.ran)==null?void 0:S[s.path],h=(v&&!(c!=null&&c.decision)?vb(s.kind,v):s.kind)+(y?` · ${y.tool} on ${y.server}`:c!=null&&c.tool?` · ${c.tool}`:s.via?` · ${s.via}`:"")+(c!=null&&c.decision&&g?` · ${g} ${g===1?"question":"questions"}`:""),x=[($=c==null?void 0:c.images)!=null&&$.length?"IMG":"",c!=null&&c.web?"WEB":"",y?"MCP":""].filter(Boolean),b=x.reduce((_,O)=>_+il(O)+4,0);i.selected&&n.appendChild(Nt("rect",{x:r-4,y:o-4,width:mn+8,height:d+8,class:"sel"})),Es(n,[Nt("rect",{x:r,y:o,width:mn,height:d,class:"box"}),Nt("rect",{x:r+10,y:o+9,width:8,height:8,class:"swatch"}),Nt("text",{x:r+24,y:o+17,class:"label"},Pr(s.label,Bo(mn-34-b,Hz))),Nt("text",{x:r+24,y:o+31,class:"kind"},Pr(h,Bo(mn-34-(f?ea(f,bb)+8:0),cd))),f?Nt("text",{x:r+mn-10,y:o+31,class:"state","text-anchor":"end"},f):null]);let j=r+mn-8;for(const _ of x.reverse())j-=il(_),Wf(n,j,o+7,_,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const _=Wf(n,r+24,o+38,c.provider,"chip"),O=u?qz(u,Bo(mn-44-_-20,S0)):"",M=mn-40-_-(O?ea(O,S0)+10:0),P=(v==null?void 0:v.model)??c.model;P&&M>24&&n.appendChild(Nt("text",{x:r+24+_+6,y:o+47.5,class:"model"},Pr(P,Bo(M,cd)))),O&&n.appendChild(Nt("text",{x:r+mn-10,y:o+47.5,class:"verdict","text-anchor":"end"},O))}else u&&n.appendChild(Nt("text",{x:r+mn-10,y:o+17,class:"verdict","text-anchor":"end"},u));i.tag&&Wf(n,r+mn-il(i.tag),o-7,i.tag)}function Kz(e,n){return{w:mn,h:ah(e,n),cx:mn/2,place:(s,r)=>jb(e,Dd(e,n,"card"),n,s,r)}}function OC(e,n,s){const r=wb(e,n.path),o=r.state==="done"?"passed":r.state in dm?dm[r.state]:r.state,i=Pr(n.label===n.kind?"exit":`exit: ${n.label}`,40),c=ea(i,cd)+16;return{w:qi+c+(r.tag?6+il(r.tag):0)+(o?6+ea(o,bb):0),h:Rg,cx:0,exit:!0,place:(d,u)=>{const f=Dd(e,n,"exit"),g=u+Rg/2;let y=d+qi+c;s&&f.appendChild(qs(d,u,d,u+Rg,"spine")),r.selected&&f.appendChild(Nt("rect",{x:d+qi-3,y:g-bf/2-3,width:c+6,height:bf+6,class:"sel"})),Es(f,[qs(d,g,d+qi,g,"exit-wire"),Nt("rect",{x:d+qi,y:g-bf/2,width:c,height:bf,class:"exit-box"}),Nt("text",{x:d+qi+8,y:g+3.5,class:"exit-text"},i)]),r.tag&&(Wf(f,y+6,g-6.5,r.tag),y+=6+il(r.tag)),o&&f.appendChild(Nt("text",{x:y+6,y:g+3.5,class:"state"},o))}}}function Vz(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?OC(e,d.node,!1):ih(e,d.node));let o=mn/2,i=mn/2,c=-Tg;for(const d of r)o=Math.max(o,d.cx),i=Math.max(i,d.w-d.cx),c+=d.h+Tg;return{w:o+i,h:c,cx:o,place:(d,u)=>{const f=Dd(e,n,"chain"),g=d+o;let y=u,v=null;r.forEach((h,x)=>{x&&(y+=Tg),h.exit?v===null&&(v=y):v!==null&&f.appendChild(qs(g,v,g,y,"spine")),h.place(h.exit?g:g-h.cx,y),y+=h.h,h.exit||(v=y)}),r[r.length-1].exit&&v!==null&&f.appendChild(qs(g,v,g,y,"spine"))}}}function Yz(e,n,s){const r=ah(e,n),o=s.map(h=>({kid:h,box:ih(e,h.node),x:0,c:0}));let i=0,c=0;o.forEach((h,x)=>{x&&(i+=Pz),h.x=i,h.c=i+h.box.cx,i+=h.box.w,c=Math.max(c,h.box.h)});const d=o.length-1,u=Math.round((o[0].c+o[d].c)/2),f=Math.min(0,u-mn/2),g=Math.max(i,u+mn/2),y=r+j0+Mz,v=y+c+Lz;return{w:g-f,h:v,cx:u-f,place:(h,x)=>{const b=Dd(e,n,"card"),j=h-f,k=x+r+j0,E=x+v;jb(e,b,n,j+u-mn/2,x),b.appendChild(qs(j+u,x+r,j+u,k)),d&&Es(b,[qs(j+o[0].c,k,j+o[d].c,k),qs(j+o[0].c,E,j+o[d].c,E)]),o.forEach((N,S)=>{const $=j+N.c,_=N.kid.node.path,O=e.taken.has(_);if(b.appendChild(Nt("line",{x1:$,y1:k,x2:$,y2:x+y,class:O?"wire branch taken":"wire branch","data-to":_})),N.kid.name!==null){const M=(S<d?o[S+1].c-6:N.x+N.box.w)-N.c-12,P=Pr(N.kid.name,Bo(M,cd)),A=Nt("text",{x:$+6,y:k+15,class:O?"branch-name taken":"branch-name"},P);b.appendChild(P===N.kid.name?A:Nt("g",null,Nt("title",null,N.kid.name),A))}b.appendChild(qs($,x+y+N.box.h,$,E,O?"taken":void 0)),N.box.place(j+N.x,x+y)})}}}const Qz=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function Jz(e,n,s,r,o,i){const c=yb.has(s.status)?s.status:"pending",d=s.label?Qz(s.label):`#${s.index+1}`,u=s.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),f=s.p!==void 0?s.p.toFixed(2):"",g=`#${s.index+1}${s.label?` ${s.label}`:""}: ${c==="review"?"needs review":c.replace("-"," ")}${s.outcome?`, ${s.outcome}`:""}${s.pNote?` (${s.pNote})`:""}`,y=Nt("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${i?" picked":""}`,"data-path":n.path,"data-item":s.index},Nt("title",null,g),Nt("rect",{x:r,y:o,width:Dc,height:Nx,class:"cell"}),Nt("rect",{x:r,y:o,width:3,height:Nx,class:"cell-edge"}),Nt("text",{x:r+9,y:o+14,class:"cell-name"},Pr(d,Bo(Dc-14,Ag))),Nt("text",{x:r+9,y:o+27,class:"cell-out"},Pr(u,Bo(Dc-18-(f?ea(f,Ag)+6:0),Ag))),f?Nt("text",{x:r+Dc-6,y:o+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(y)}function Xz(e,n){var j;const s=((j=e.marks.items)==null?void 0:j[n.path])??[];if(!s.length)return null;const r=s.length<=Fz,[o,i,c]=r?[Dc,Nx,Wz]:[yf,yf,Iz],d=Math.min(s.length,r?Uz:zz),u=Math.ceil(s.length/d),f=d*(o+c)-c,g=u*(i+c)-c+Dz+(r?4:0),y={};for(const k of s)y[k.status]=(y[k.status]??0)+1;const v={};for(const k of s)k.outcome&&(v[k.outcome]=(v[k.outcome]??0)+1);const h=Object.entries(v).map(([k,E])=>`${E} ${k}`),b=[`${y.done??0}/${s.length} done`,y.working?`${y.working} working`:"",y.held?`${y.held} held`:"",y.failed?`${y.failed} failed`:"",y.review?`${y.review} review`:"",...h].filter(Boolean).join(" · ");return{w:Math.max(f,ea(b,cd)),h:g,place:(k,E,N)=>{const S=E-f/2,$=e.marks.selected;s.forEach((_,O)=>{const M=S+O%d*(o+c),P=N+Math.floor(O/d)*(i+c),A=yb.has(_.status)?_.status:"pending",R=($==null?void 0:$.path)===n.path&&$.item===_.index;if(r){Jz(k,n,_,M,P,R);return}Es(k,Nt("rect",{x:M,y:P,width:yf,height:yf,class:`cell ${A}${R?" picked":""}`,"data-path":n.path,"data-item":_.index},Nt("title",null,`#${_.index+1}${_.label?` ${_.label}`:""}: ${A==="review"?"needs review":A.replace("-"," ")}`)))}),Es(k,Nt("text",{x:E,y:N+g-4,class:"caption","text-anchor":"middle"},b))}}}function Zz(e,n,s){const r=ih(e,s),o=ah(e,n),i=n.kind==="map"?Xz(e,n):null,c=i?i.h+Ws:0,d=Math.max(mn/2,r.cx,i?i.w/2:0)+Ws,u=Math.max(mn/2,r.w-r.cx,i?i.w/2:0)+Ws,f=o+Ws+c+r.h+Ws;return{w:d+u,h:f,cx:d,place:(g,y)=>{const v=Dd(e,n,"card"),h=g+d;if(Es(v,Nt("rect",{x:g,y:y+o/2,width:d+u,height:f-o/2,class:"frame"})),i?(Es(v,qs(h,y+o,h,y+o+Ws)),Es(v,qs(h,y+o+Ws+i.h,h,y+o+Ws+c))):Es(v,qs(h,y+o,h,y+o+Ws)),Es(v,qs(h,y+o+Ws+c+r.h,h,y+f)),jb(e,v,n,h-mn/2,y),i){const x=Nt("g",{class:"items"});i.place(x,h,y+o+Ws),v.appendChild(x)}r.place(h-r.cx,y+o+Ws+c)}}}function MC(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function ih(e,n){const s=e.kids[n.path]??[],r=MC(n,s);return r==="exit"?OC(e,n,!0):r==="leaf"?Kz(e,n):r==="chain"?Vz(e,n,s):r==="fan"?Yz(e,n,s):Zz(e,n,s[0].node)}function kb(e){const{byPath:n,kids:s}=AC(LC(e)),r=o=>{const i=s[o.path]??[],c=MC(o,i),d=c==="frame"?r(i[0].node):c==="chain"||c==="fan"?i.reduce((u,f)=>u+r(f.node),0):0;return(c==="chain"?0:1)+d};return n["/root"]?r(n["/root"]):0}const lh=e=>`${e} ${e===1?"node":"nodes"}`,LC=e=>(e&&Array.isArray(e.nodes)?e.nodes:[]).filter(n=>n&&typeof n.path=="string"&&typeof n.kind=="string").map(n=>({path:n.path,kind:n.kind,label:String(n.label??n.kind),via:typeof n.via=="string"?n.via:""}));function eD(e,n,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=AC(LC(n)),o=(y,v)=>(e.setAttribute("viewBox",`0 0 ${y} ${v}`),e.setAttribute("width",String(y)),e.setAttribute("height",String(v)),e.style.setProperty("min-width",`${Math.min(y,480)}px`),{w:y,h:v});if(!r.byPath["/root"])return o(0,0);const i={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=ih(i,r.byPath["/root"]);c.place(Bi,Bi);let d=c.w,u=c.h;const f=(((g=s.diff)==null?void 0:g.removed)??[]).map(y=>`${y.label} (${y.kind})`);if(f.length){const y=["Removed:",...f.map(h=>Pr(h,Bo(Math.max(d,300),N0)))],v=Nt("g",{class:"removed-list"},Nt("title",null,`Removed: ${f.join(", ")}`));y.forEach((h,x)=>{v.appendChild(Nt("text",{x:Bi,y:Bi+u+33+x*k0,class:"removed"},h)),d=Math.max(d,ea(h,N0))}),e.appendChild(v),u+=22+y.length*k0}return o(d+2*Bi,u+2*Bi)}function tD(e){var o,i;const n=e,s=(o=n==null?void 0:n.closest)==null?void 0:o.call(n,"[data-item]");if(s)return{path:s.getAttribute("data-path"),item:Number(s.getAttribute("data-item"))};const r=(i=n==null?void 0:n.closest)==null?void 0:i.call(n,"g[data-path]");return!r||r.classList.contains("chain")?null:{path:r.getAttribute("data-path"),item:null}}const nD=1600;function Fd({graph:e,marks:n,onSelect:s,className:r,label:o="Workflow graph",minScale:i=.8,maxScale:c=1.3}){const d=p.useRef(null),[u,f]=p.useState({w:0,h:0}),[g,y]=p.useState(0),v=p.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,n??null]),[e,n]);p.useEffect(()=>{if(!d.current)return;const x=eD(d.current,e,n);f(b=>b.w===x.w&&b.h===x.h?b:x),d.current.style.setProperty("--wf-phase",`-${Date.now()%nD}ms`)},[v]),p.useEffect(()=>{var j;const x=(j=d.current)==null?void 0:j.parentElement;if(!x||typeof ResizeObserver>"u")return;const b=new ResizeObserver(([k])=>y(k.contentRect.width));return b.observe(x),()=>b.disconnect()},[]);const h=u.w&&g?Math.min(c,Math.max(i,g/u.w)):1;return t.jsx("svg",{ref:d,role:"img","aria-label":o,className:te("wf select-none",r),style:u.w?{width:u.w*h,height:u.h*h,maxWidth:"none",minWidth:0}:void 0,onClick:x=>{const b=tD(x.target);b&&s&&s(b)}})}function Ud({run:e=!1}){const n=[["hsl(var(--wf-jev))","Jev"],["hsl(var(--wf-parallel))","Parallel"],["hsl(var(--wf-openrouter))","OpenRouter"],["hsl(var(--wf-tool))","Tool"],["hsl(var(--muted-foreground))","Code"],["hsl(var(--primary))","Agent"]],s=[["border-success bg-success/40","Done"],["border-primary bg-primary/20","Working"],["border-dashed border-warning","Held (paused)"],["border-warning bg-warning/60","Needs review"],["border-destructive bg-destructive/60","Failed"],["border-dashed border-border-strong","Pending"]];return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 font-mono text-label text-muted-foreground",children:[n.map(([r,o])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block size-2",style:{background:r}}),o]},o)),e&&t.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&s.map(([r,o])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:te("inline-block size-2.5 border",r)}),o]},o))]})}const sD=3e3,rD=e=>e.word==="Held"||e.word==="Not decided",C0=e=>`${Math.round(e*100)}%`,PC=e=>`${e} ${e===1?"input":"inputs"}`;function oD(e){if(!e)return"Replay started: its runs are queued.";const n=e.outcomes,s=n.answered+n.handed_back+n.failed+n.skipped_write;return`Checking on ${PC(e.inputs)} of the agent's own runs: ${s} of ${e.inputs} ended (${n.answered} answered alone, ${n.handed_back} handed back${n.failed?`, ${n.failed} failed`:""}${n.skipped_write?`, ${n.skipped_write} skipped`:""}).`}function aD(e){const n=e.reason?` ${e.reason.charAt(0).toUpperCase()}${e.reason.slice(1)}`:"",s=e.status==="failed"?`The replay did not finish.${n}`:e.decided==="promote"?`Promoted: it serves first now.${n}`:e.decided==="hold"?`Still held.${n}`:`Decided.${n}`,r=e.score;return{text:s,score:r.n>0?`Workflow ${C0(r.wf_acc)} vs agent ${C0(r.agent_acc)} on ${PC(r.n)} of the agent's own runs, ${r.agree} said what the agent said, ${r.handed_back} handed back`:null}}function iD({v2:e,agentId:n,workflow:s,digest:r,offered:o,resume:i=null,onStarted:c,onDecided:d,pollMs:u=sD}){const[f,g]=p.useState(i?{at:"running",replay:i,read:null}:{at:"idle"});p.useEffect(()=>{i&&g(j=>j.at==="idle"?{at:"running",replay:i,read:null}:j)},[i]);const y=p.useRef(d);y.current=d;const v=f.at==="running"?f.replay:null,h=f.at==="running"?f.unread:void 0;p.useEffect(()=>{if(v===null||h!==void 0)return;let j=!0,k;const E=()=>{Promise.resolve().then(()=>e.learnedWorkflowReplay(n,s,r,v)).then(N=>{var S;if(j){if(N.status==="running"){g({at:"running",replay:v,read:N}),k=setTimeout(E,u);return}g({at:"decided",read:N}),(S=y.current)==null||S.call(y)}},N=>{j&&g(S=>S.at==="running"?{...S,unread:N instanceof Error?N.message:String(N)}:S)})};return E(),()=>{j=!1,k&&clearTimeout(k)}},[e,n,s,r,v,h,u]);const x=()=>{g({at:"starting"}),Promise.resolve().then(()=>e.startLearnedWorkflowReplay(n,s,r)).then(j=>{g({at:"running",replay:j.replay,read:null}),c==null||c()},j=>{const k=j==null?void 0:j.code;g({at:"refused",message:j instanceof Error?j.message:String(j),code:typeof k=="string"?k:null})})},b=f.at==="starting"||f.at==="running";return!o&&f.at==="idle"?null:t.jsxs("div",{className:"mt-2 space-y-1","data-testid":"replay-revision",children:[(f.at==="idle"||f.at==="starting"||(f.at==="refused"||f.at==="decided")&&o)&&t.jsx(B,{size:"sm",onClick:x,disabled:b,"aria-label":`Check revision ${r.slice(0,7)} on the inputs of the agent's own runs`,children:f.at==="starting"?"Starting…":f.at==="idle"?"Replay":"Replay again"}),f.at==="running"&&t.jsxs("p",{className:"break-words text-body",role:"status","data-testid":"replay-progress",children:[f.unread!==void 0?`Couldn't read the replay: ${f.unread} `:oD(f.read),f.unread!==void 0&&t.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>g({at:"running",replay:f.replay,read:f.read}),children:"Check again"})]}),f.at==="refused"&&t.jsxs("p",{className:"break-words text-body",role:"alert","data-testid":"replay-refused",children:[f.message,f.code&&t.jsx("span",{className:"ml-2 font-mono text-label text-muted-foreground",children:f.code})]}),f.at==="decided"&&(()=>{const j=aD(f.read);return t.jsxs("div",{role:"status","data-testid":"replay-decision",children:[t.jsx("p",{className:"break-words text-body",children:j.text}),j.score&&t.jsx("p",{className:"break-words font-mono text-label text-muted-foreground","data-testid":"replay-score",children:j.score})]})})()]})}const Og=e=>{const n=[...new Set(e)],s=n.slice(0,3).map(r=>`"${r}"`).join(", ");return n.length>3?`${s} and ${n.length-3} more`:s},E0=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function lD(e,n,s,r,o){const i=[e.length&&`added ${E0(e.length,"node")} (${Og(e)})`,n.length&&`edited ${Og(n)}`,s.length&&`removed ${E0(s.length,"node")} (${Og(s)})`].filter(Boolean);if(!i.length)return r?"Nodes reordered":o?"Connections changed":"No node changed";const c=i.join(", ");return c.charAt(0).toUpperCase()+c.slice(1)}function cD(e){const n=[];let s=null,r=0;for(const o of e){let i=null,c=null;try{i=o.text===null?null:JSON.parse(o.text),c=i===null?null:vl(i)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const d=s?P2(s,c):null,u=d?d.added.map(b=>b.path):c.nodes.map(b=>b.path),f=b=>{var j;return((j=c.nodes.find(k=>k.path===b))==null?void 0:j.kind)!=="chain"},g=d?[...d.changed.map(b=>b.next),...d.rewritten.map(b=>b.next)]:[],y=d?d.moved.map(b=>b.next):[],v=new Map(c.nodes.map(b=>[b.path,b.label])),h=d?d.removed.filter(b=>b.kind!=="chain").map(b=>b.label):[],x=d?d.edges.added.length+d.edges.removed.length:0;n.push({digest:o.digest??null,commit:o.commit,at:o.at,run:"run"in o.by?o.by.run:null,reason:o.reason,graph:c,marks:{meta:Rd(i,c),diff:{added:u,edited:g,moved:y,removed:d?d.removed.map(({label:b,kind:j})=>({label:b,kind:j})):[]}},added:u,edited:g,removed:h,line:d?lD(u.filter(f).map(b=>v.get(b)??b),g.filter(f).map(b=>v.get(b)??b),h,y.length,x):`First version: ${lh(kb(c))}`}),s=c}return{steps:n,unreadable:r}}const dD=50,uD=1800;function fD({v2:e,agentId:n,workflows:s,promotions:r=[],serving:o=[],cost:i=null,onReplayed:c}){const d=s.filter(y=>rh(y.status)).map(y=>y.name),[u,f]=p.useState(null),g=u!==null&&d.includes(u)?u:d[0]??null;return g===null?null:t.jsx(mD,{v2:e,agentId:n,name:g,choices:d,onPick:f,promotions:r,serving:o,stopped:hb(i,g),onReplayed:c},g)}const wf="Learned workflow";function mD({v2:e,agentId:n,name:s,choices:r,onPick:o,promotions:i,serving:c,stopped:d,onReplayed:u}){var j;const[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(0);p.useEffect(()=>{let k=!0;return v(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(n,s,dD)).then(E=>{k&&g(E)},E=>{k&&v(E??new Error("unknown"))}),()=>{k=!1}},[e,n,s,h]);const b=t.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[t.jsxs("h2",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:wf})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(Mt,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:o,options:r.map(k=>({value:k,label:k}))})]});return y&&!f?t.jsxs("section",{className:"border","aria-label":wf,children:[b,t.jsx("div",{className:"p-4",children:t.jsx(xr,{problem:ua(y,"the learned workflow"),onRetry:()=>x(k=>k+1),className:""})})]}):f?t.jsxs("section",{className:"border","aria-label":wf,children:[b,t.jsx(hD,{data:f,promotions:i,serving:((j=c.find(k=>k.workflow===f.name))==null?void 0:j.digest)??null,stopped:d,replay:{v2:e,agentId:n,onStarted:u,onDecided:()=>{x(k=>k+1),u==null||u()}}})]}):t.jsxs("section",{className:"border","aria-label":wf,"aria-busy":!0,children:[b,t.jsx("div",{className:"p-4",children:t.jsx(An,{className:"h-48 w-full"})})]})}function hD({data:e,stepMs:n=uD,promotions:s=[],serving:r=null,stopped:o=null,replay:i}){const{steps:c,unreadable:d}=p.useMemo(()=>cD(e.revisions),[e.revisions]),[u,f]=p.useState(Math.max(0,c.length-1)),[g,y]=p.useState(!1),v=p.useRef(u);v.current=u;const h=p.useRef(c);if(p.useEffect(()=>{var M;const $=h.current;h.current=c;const _=((M=$[v.current])==null?void 0:M.digest)??null,O=$===c||v.current>=$.length-1||_===null?-1:c.findIndex(P=>P.digest===_);f(O>=0?O:Math.max(0,c.length-1)),y(!1)},[c]),p.useEffect(()=>{if(!g)return;const $=setInterval(()=>f(_=>Math.min(_+1,c.length-1)),n);return()=>clearInterval($)},[g,c.length,n]),p.useEffect(()=>{g&&u>=c.length-1&&y(!1)},[g,u,c.length]),!e.revisions.length)return null;if(!c.length)return t.jsxs("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:["This workflow's revisions can't be read as a workflow",d?`: ${d} ${d===1?"revision":"revisions"} did not read`:"","."]});const x=c[Math.min(u,c.length-1)],b=c.length,j=$=>{y(!1),f(Math.max(0,Math.min(b-1,$)))},k=()=>{if(g)return y(!1);u>=b-1&&f(0),y(!0)},E=`Revision ${Math.min(u,b-1)+1} of ${b}, ${vt(x.at)}`,N=mb(s,e.name,x.digest),S=ld(N,{serving:r,stopped:o});return t.jsxs("div",{className:"space-y-3 p-4",children:[b>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsxs(B,{size:"sm",onClick:k,"aria-label":g?"Pause the replay":"Play the replay","aria-pressed":g,children:[g?t.jsx(fl,{"aria-hidden":!0}):t.jsx(ra,{"aria-hidden":!0}),g?"Pause":"Play"]}),t.jsx(B,{size:"icon",onClick:()=>j(u-1),disabled:u<=0,"aria-label":"Previous revision",children:t.jsx(FT,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",onClick:()=>j(u+1),disabled:u>=b-1,"aria-label":"Next revision",children:t.jsx(As,{"aria-hidden":!0})}),t.jsx(WM,{min:1,max:b,value:u+1,onChange:$=>j($-1),label:"Revision",valueText:E,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{children:b>1?`Revision ${u+1} of ${b}`:"One revision"})," · ",t.jsx("time",{dateTime:x.at,children:vt(x.at)})," · ",x.run?t.jsxs("a",{href:`#/runs/${encodeURIComponent(x.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ca(x.run)]}):"a person"]}),t.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:x.line}),x.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:x.reason}),t.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-body","data-testid":"standing",children:[t.jsx(Ne,{tone:S.tone,children:S.text}),t.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:N?qa(N):x.digest?"No check yet: a new revision is checked on the inputs of the agent's own runs before it serves.":"Its file did not read: no standing."})]}),i&&x.digest&&t.jsx(iD,{v2:i.v2,agentId:i.agentId,workflow:e.name,digest:x.digest,offered:rD(S),resume:(N==null?void 0:N.decided)==="replaying"?N.replay_id??null:null,onStarted:i.onStarted,onDecided:i.onDecided},x.digest)]}),t.jsx("div",{className:"flex min-h-[280px] overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] p-4",children:t.jsx(Fd,{graph:x.graph,marks:x.marks,label:`The workflow at revision ${u+1} of ${b}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Ud,{}),t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",t.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed"]})]}),(e.total>e.revisions.length||e.truncated||d>0)&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.total>e.revisions.length&&`The latest ${e.revisions.length} of ${e.total} revisions. `,e.truncated&&"Older changes are past the log this server keeps. ",d>0&&`${d} ${d===1?"revision":"revisions"} could not be read as a workflow and ${d===1?"is":"are"} left out.`]})]})}const $0=8,pD={promote:"success",hold:"warning",revision:"active"};function _0({loop:e,promotions:n,serving:s=[],cost:r=null}){const[o,i]=p.useState(!1),c=[...((e==null?void 0:e.compiles)??[]).map(u=>({at:u.at,key:`c:${u.run_id}:${u.round}`,kind:"compile",compile:u})),...n.map((u,f)=>({at:u.at,key:`p:${f}`,kind:"promotion",record:u}))].sort((u,f)=>Date.parse(f.at)-Date.parse(u.at));if(!c.length)return null;const d=o?c:c.slice(0,$0);return t.jsxs("section",{className:"border","aria-label":"Learning feed","data-testid":"loop-feed",children:[t.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b px-4 py-3 text-small font-semibold",children:["Learning feed",t.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:c.length})]}),t.jsx("ol",{className:"divide-y",children:d.map(u=>{var f;return t.jsx("li",{className:"min-w-0 px-4 py-3","data-testid":`feed-${u.kind}`,children:u.kind==="compile"?t.jsx(xD,{compile:u.compile,promotions:n,serving:((f=s.find(g=>g.workflow===u.compile.workflow))==null?void 0:f.digest)??null,stopped:u.compile.workflow?hb(r,u.compile.workflow):null}):t.jsx(vD,{record:u.record})},u.key)})}),c.length>$0&&t.jsx("div",{className:"flex justify-center border-t px-4 py-2",children:t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>i(u=>!u),children:o?"Show fewer":`Show all ${c.length}`})})]})}const gD=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ca(e)]}),IC=({at:e,run:n})=>t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[t.jsx("time",{dateTime:e,children:vt(e)}),n?t.jsxs(t.Fragment,{children:[" · ",t.jsx(gD,{id:n})]}):null]});function xD({compile:e,promotions:n,serving:s,stopped:r}){const o=e.digest===null||e.workflow===null,i=e.attempts.filter(u=>!u.ok),c=[...e.attempts.flatMap((u,f)=>u.ok?[]:u.errors.map(g=>({e:g,attempt:f+1}))),...e.draft_errors.map(u=>({e:u,attempt:null}))],d=o?null:ld(mb(n,e.workflow,e.digest),{serving:s,stopped:r});return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?t.jsx(Ne,{tone:"error",children:"Draft failed"}):t.jsx(Ne,{tone:"plain",children:"Compiled"}),e.workflow?t.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}):t.jsx("span",{className:"text-body text-muted-foreground",children:"no workflow kept"}),d&&t.jsx(Ne,{tone:d.tone,children:d.text})]}),e.attempts.length>0&&t.jsxs("p",{className:"mt-0.5 text-small text-muted-foreground",children:[e.attempts.length===1?"1 attempt":`${e.attempts.length} attempts`,i.length?`, ${i.length} refused by the checks`:"",o?": it tries again on a later run.":"."]}),e.withheld?t.jsx("p",{className:"mt-1 text-small text-warning-text",role:"note",children:"The checks' words are withheld here: this run's handed values can't be read to cut them."}):c.length>0&&t.jsx("ul",{className:"mt-1 space-y-0.5","aria-label":"What the checks said","data-testid":"draft-errors",children:c.map(({e:u,attempt:f},g)=>t.jsxs("li",{className:"break-words font-mono text-small text-destructive-text",children:[f?`Attempt ${f}: `:"",u]},g))}),t.jsx(IC,{at:e.at,run:e.run_id})]})}function vD({record:e}){var o;const n=bC(e),s=ld(e,{serving:e.digest}),r=n==="promote"?s.tone:pD[n];return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(Ne,{tone:r,children:[fb[n]," · ",Gc[n],s.proof?` · ${s.proof}`:""]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:e.digest.slice(0,7)})]}),t.jsx("p",{className:"mt-1 break-words text-small text-muted-foreground",children:qa(e)}),(o=e.check)!=null&&o.n?e.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-small text-muted-foreground",children:e.reason}):null,t.jsx(IC,{at:e.at})]})}const bD={done:{icon:Cl,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:WT,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:BT,word:"Later",ink:"text-muted-foreground",edge:"border-t-border"},warn:{icon:Ys,word:"Look",ink:"text-warning-text",edge:"border-t-warning"},watch:{icon:$m,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function T0({stages:e}){return e.length?t.jsx("section",{className:"border","aria-label":"The learning loop","data-testid":"loop-story",children:t.jsx("ol",{className:te("grid grid-cols-1 gap-px bg-border sm:grid-cols-2",e.length===5?"lg:grid-cols-5":"lg:grid-cols-4"),children:e.map((n,s)=>{const r=bD[n.state],o=r.icon;return t.jsxs("li",{"data-testid":`stage-${n.key}`,"data-state":n.state,className:te("min-w-0 border-t-2 bg-card px-4 py-3 sm:[&:last-child:nth-child(odd)]:col-span-2 lg:[&:last-child:nth-child(odd)]:col-span-1",r.edge),children:[t.jsxs("p",{className:"flex items-center gap-1.5 font-mono text-label",children:[t.jsxs("span",{className:"caps text-muted-foreground",children:[s+1," · ",n.title]}),t.jsxs("span",{className:te("ml-auto inline-flex items-center gap-1",r.ink),children:[t.jsx(o,{className:"size-3.5","aria-hidden":!0}),t.jsx("span",{className:"caps",children:r.word})]})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-lead font-semibold","data-testid":`stage-${n.key}-value`,children:n.value}),t.jsx("p",{className:"mt-0.5 break-words text-small text-muted-foreground",children:n.detail})]},n.key)})})}):null}function zC({id:e,checked:n,onChange:s,busy:r,disabled:o,quiet:i,server:c,problem:d,className:u}){return t.jsxs("div",{className:te("space-y-2",u),children:[t.jsxs("div",{className:te("flex gap-4",i?"items-center":"items-start"),children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{id:e,className:"text-lead font-semibold",children:"Learns from its runs"}),!i&&t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:"Every later run is given your corrections first, and a job it does again compiles into a workflow it can run as one step."})]}),t.jsx(Ed,{checked:n,onChange:s,busy:r,disabled:o,labelledBy:e})]}),c==="off"&&t.jsx("p",{className:"font-mono text-label text-warning-text",children:"This server has learning turned off, so no run learns until it's on."}),d]})}function yD({fields:e,onFields:n,saved:s,server:r,error:o,warning:i}){const c=e.learning??s,d=Od(c),u=typeof s=="object"?s:!0,f=g=>n({learning:g===!1&&s===void 0?void 0:g});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),t.jsx(zC,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:g=>f(g?u:!1)}),o&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:o}),i&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:i})]})}const Wd=(e,n,s)=>({...ua(e,n),title:s}),wD=(e,n)=>{const s=e.get(n);return s!=null&&s.title?On(s):`run ${ca(n)}`},jD="text-lead leading-[1.65] [&_a]:text-primary-text [&_a]:underline [&_a]:underline-offset-2 [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_code]:text-body [&_h1]:mb-2 [&_h1]:text-prose [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-3 [&_h2]:text-lead [&_h2]:font-semibold [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:mb-0.5 [&_ol]:mb-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:mb-2 [&_p:last-child]:mb-0 [&_pre]:mb-2 [&_pre]:overflow-x-auto [&_pre]:border [&_pre]:bg-background [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-small [&_ul]:mb-2 [&_ul]:list-disc [&_ul]:pl-5",kD=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),ND=15e3;function Kc(e,n=!1){const[s,r]=p.useState(n),o=p.useRef(Symbol("learning interaction")).current;return p.useEffect(()=>()=>{e.items.delete(o),e.changed(e.items.size>0)},[e,o]),[s,c=>{c?e.items.add(o):e.items.delete(o),e.changed(e.items.size>0),r(c)}]}function SD(e){return t.jsx(CD,{...e},e.agent.agent_id)}function CD({agent:e,v2:n,server:s,onAgent:r,onChanged:o}){const[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState([]),[y,v]=p.useState([]),[h,x]=p.useState([]),[b,j]=p.useState(null),[k,E]=p.useState(null),[N,S]=p.useState(!1),$=p.useMemo(()=>({items:new Set,changed:S}),[]),[_,O]=p.useState(0),M=p.useRef(0),P=p.useRef(!0),A=p.useRef(!1),[R,L]=p.useState(!1),W=(be,ge=!0)=>{const Je=be==="background";if(!P.current||Je&&(A.current||$.items.size))return Promise.resolve();const tt=++M.current;ge&&O(Ee=>Ee+1),A.current=!0,L(!0),u(null);const ft=()=>P.current&&tt===M.current&&(be==="write"||!$.items.size),ve=n.agentLearning(e.agent_id).then(Ee=>{ft()&&c(Ee)},Ee=>{ft()&&u(Ee??new Error("unknown"))});return n.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Ee=>{ft()&&g(Ee.runs)},()=>{}),Promise.resolve().then(()=>n.learningPromotions(e.agent_id)).then(Ee=>{ft()&&(v(Ee.promotions),x(Ee.serving))},()=>{}),Promise.resolve().then(()=>n.learningLoop(e.agent_id)).then(Ee=>{ft()&&j(Ee)},()=>{}),ve.finally(()=>{tt===M.current&&(A.current=!1,L(!1))})},U=()=>W("manual"),Y=p.useRef(()=>{});Y.current=()=>{document.hidden||W("background")},p.useEffect(()=>{P.current=!0,W("manual",!1);const be=()=>Y.current();window.addEventListener("focus",be),document.addEventListener("visibilitychange",be);const ge=window.setInterval(be,ND);return()=>{P.current=!1,M.current++,window.removeEventListener("focus",be),document.removeEventListener("visibilitychange",be),window.clearInterval(ge)}},[n,e.agent_id,e.archived_at]);const D=()=>(o==null||o(),W("write")),G=Od(e.definition.learning),F=!!e.archived_at,q=(i==null?void 0:i.workflows)??[],H=ib((i==null?void 0:i.corrections)??""),[I,V]=p.useState(void 0),J=q.some(be=>be.status==="pending");p.useEffect(()=>{if(!J||I!==void 0)return;let be=!0;return Promise.resolve().then(()=>n.capabilities()).then(ge=>{be&&V(SI(ge))},()=>{be&&V("password")}),()=>{be=!1}},[J]);const X=p.useMemo(()=>new Map(f.map(be=>[be.run_id,be])),[f]),re=f.filter(be=>be.learning&&(be.learning.state==="merged"||be.learning.state==="dropped")).length,ae=e.definition.native?"native":os(e.definition)?"sdk":"hosted",ye=QI({corrections:H.length,runs:(b==null?void 0:b.completed_runs)??0,workflows:q,cost:k,promotions:y,serving:h,loop:b,execution:ae,compileAfter:HI(e.definition.learning)}),he=be=>t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Refresh learning",title:"Refresh learning",disabled:N||R,onClick:()=>{!$.items.size&&!A.current&&U()},children:t.jsx(oa,{className:te(R&&"animate-spin"),"aria-hidden":!0})})}),be]});if(d&&!i)return he(t.jsx(xr,{problem:ua(d,"what this agent learned"),onRetry:U,className:""}));if(!i)return he(t.jsx($D,{}));const we=d?t.jsx(ED,{error:d,onRetry:U}):null,ze=be=>t.jsx(TD,{agent:e,v2:n,onAgent:r,server:s,disabled:F,quiet:be}),le=t.jsx(MD,{text:i.corrections,v2:n,agentId:e.agent_id,readOnly:F,onChanged:D,refreshHolds:$});if(!H.length&&!q.length)return he(t.jsxs("div",{className:"space-y-6",children:[we,t.jsx(OD,{on:G,lookedBack:re,switchRow:ze(!0)}),le,G&&t.jsx(T0,{stages:ye}),t.jsx(u0,{v2:n,agentId:e.agent_id,on:G,quiet:!0,promotions:y,onCost:E,reads:_,execution:ae}),t.jsx(v0,{v2:n,agentId:e.agent_id,cost:k,serving:h}),t.jsx(_0,{loop:b,promotions:y,serving:h,cost:k}),t.jsx(A0,{runs:f})]}));const me=q.filter(be=>be.status!=="retired"),Ke=q.filter(be=>be.status==="retired");return he(t.jsxs("div",{className:"space-y-6",children:[t.jsx(T0,{stages:ye}),OI(i.impact)&&t.jsx(_D,{impact:i.impact,cost:k}),t.jsx(u0,{v2:n,agentId:e.agent_id,on:G,promotions:y,onCost:E,reads:_,execution:ae}),t.jsx(v0,{v2:n,agentId:e.agent_id,cost:k,serving:h}),t.jsx(fD,{v2:n,agentId:e.agent_id,workflows:q,promotions:y,serving:h,cost:k,onReplayed:()=>{U()}}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"min-w-0 space-y-6",children:[we,!G&&t.jsx(AD,{server:s}),le,q.length>0&&t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Workflows it learned",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Workflows it learned"}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:me.length?`${wl(me.length,"workflow")}: a job it does again, as steps a later run can call.`:"No workflow is in use: the next run gets none."})]}),me.length>0&&t.jsx("ul",{className:"space-y-3",children:me.map(be=>t.jsx("li",{children:t.jsx(PD,{item:be,v2:n,agentId:e.agent_id,readOnly:F,runs:X,approves:I,onChanged:D,refreshHolds:$})},be.file))}),Ke.length>0&&t.jsx(WD,{items:Ke,v2:n,agentId:e.agent_id,runs:X,readOnly:F,onChanged:D,refreshHolds:$})]})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(DC,{title:"Learning",children:ze(!1)}),t.jsx(_0,{loop:b,promotions:y,serving:h,cost:k}),t.jsx(A0,{runs:f}),t.jsx(qD,{corrections:H.length,workflows:q.filter(be=>rh(be.status)),off:!G||s==="off"})]})]})]}))}function ED({error:e,onRetry:n}){const s=ua(e,"what it learned"),r=[s.said,s.code].filter(Boolean).join(" · ");return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border border-destructive/40 px-3 py-2 text-body",role:"alert",title:r||void 0,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't refresh what it learned: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)," What's shown may be out of date."]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]})}function DC({title:e,children:n,label:s}){return t.jsxs("section",{className:"border","aria-label":s??e,children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),n]})}function $D(){const e="block bg-muted motion-safe:animate-pulse";return t.jsxs("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading what it learned",children:[t.jsx("span",{"aria-hidden":!0,className:te(e,"h-6 w-56")}),[0,1,2].map(n=>t.jsxs("div",{"aria-hidden":!0,className:"space-y-3 border p-5",children:[t.jsx("span",{className:te(e,"h-4 w-1/3")}),t.jsx("span",{className:te(e,"h-3 w-2/3 bg-muted/70")}),t.jsx("span",{className:te(e,"h-3 w-1/2 bg-muted/70")})]},n)),t.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function _D({impact:e,cost:n}){const{before:s,after:r}=e,o=[{label:"Answers in",now:lm(r.median_duration_s),was:lm(s.median_duration_s),delta:RI(s.median_duration_s,r.median_duration_s)}],i=n!=null&&n.bill?cz(n.bill):null,c=`Medians of ${id(s.runs)} before it first learned and ${id(r.runs)} that started from what it learned (a correction or a workflow).`;return t.jsx("section",{className:"border","aria-label":AI(e,i),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4 px-4 py-3",children:[t.jsxs("div",{className:"flex items-baseline gap-2.5",children:[t.jsx("span",{className:"caps text-small font-semibold",children:"Since it learned"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",title:c,children:gC(e)})]}),t.jsxs("dl",{className:"flex flex-1 flex-wrap items-baseline gap-x-10 gap-y-3","aria-hidden":!0,children:[o.map(d=>t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:d.label}),t.jsxs("dd",{className:"flex items-baseline gap-2 font-mono",children:[t.jsx("span",{className:"text-figure font-semibold leading-none",children:d.now}),t.jsxs("span",{className:"text-small text-muted-foreground",children:["instead of ",d.was]}),d.delta!==null&&d.delta!==0&&t.jsxs("span",{className:te("text-small",d.delta<0?"text-primary-text":"text-warning-text"),children:[d.delta>0?"+":"−",Math.abs(d.delta),"%"]})]})]},d.label)),i!==null&&t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Learning itself"}),t.jsx("dd",{className:"font-mono text-body text-muted-foreground",title:"The bill's learning spend (compile turns, audits' shadow runs, replays) over the runs that did a job.",children:pC(i)})]})]})]})})}function TD(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(cC,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(RD,{...e})}function RD({agent:e,v2:n,onAgent:s,server:r,disabled:o,quiet:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null),v=async h=>{d(!0),f(null),y(h);try{const{agent:x,etag:b}=await n.getAgent(e.agent_id),j=Md(x,{learning:h},h?"Learning on":"Learning off");if(j.unchanged)s==null||s(x);else{const{unchanged:k,...E}=j;s==null||s((await n.updateDefinition(e.agent_id,E,b)).agent)}}catch(x){f(x??new Error("unknown"))}y(null),d(!1)};return t.jsx(zC,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:g??Od(e.definition.learning),onChange:h=>void v(h),busy:c,disabled:o,server:r,problem:u?t.jsx(xr,{problem:Wd(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function AD({server:e}){return t.jsxs(jt,{tone:"warning",children:["Learning is off",e==="off"?" on this server":"",", so later runs aren't given these corrections or workflows. They're kept for when it's back on."]})}function OD({on:e,lookedBack:n,switchRow:s}){return t.jsxs("section",{className:"mx-auto max-w-xl border","aria-label":"Learning",children:[t.jsxs("div",{className:"px-6 py-12 text-center",children:[t.jsx(f1,{className:"mx-auto mb-3 size-5 text-primary-text","aria-hidden":!0}),t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:e?"Nothing learned yet.":"Learning is off for this agent."}),t.jsx("p",{className:"mx-auto mt-2 max-w-md text-lead text-muted-foreground",children:e?"Every later run is given your corrections whole, and a job it does again compiles into a workflow. Both show here.":"With learning on, every later run is given your corrections, and a job it does again compiles into a workflow."}),e&&n>0&&t.jsxs("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:[id(n)," had their compile turn: no workflow kept yet."]})]}),t.jsx("div",{className:"border-t",children:s})]})}function MD({text:e,v2:n,agentId:s,readOnly:r,onChanged:o,refreshHolds:i}){const[c,d]=Kc(i),[u,f]=p.useState(!1),g=ib(e),y=e.trim()!=="",v=p.useMemo(()=>Ko(e.trim()),[e]);return p.useEffect(()=>{if(!u)return;const h=setTimeout(()=>f(!1),2400);return()=>clearTimeout(h)},[u]),t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Corrections",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-x-4 gap-y-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:["Corrections",u&&t.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:"Saved"})]}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:g.length?`${lb(g.length)}. Every later run is given ${g.length===1?"it":"them"} whole before it starts.`:y?"Every later run is given this text whole before it starts.":"None yet. A correction you give with a run's grade is kept here, one line each; every later run is given them whole."})]}),!r&&!c&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>d(!0),"aria-label":"Edit corrections",children:[t.jsx(sv,{"aria-hidden":!0})," Edit"]})]}),c?t.jsx(LD,{v2:n,agentId:s,onDone:h=>{d(!1),h&&(f(!0),o())}}):y&&t.jsx("div",{className:"border bg-card/40",children:t.jsx("div",{className:te(jD,"max-h-96 overflow-auto break-words px-5 py-4"),dangerouslySetInnerHTML:{__html:v}})})]})}function LD({v2:e,agentId:n,onDone:s}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0),[f,g]=p.useState(null),[y,v]=p.useState(!1),[h,x]=p.useState([]),[b,j]=p.useState(null),[k,E]=p.useState(null),N=p.useRef(null),S=async(A=!1)=>{g(null);try{const R=await e.corrections(n);o(A?L=>L??R.text:R.text),c(R.etag),u(R.cap_bytes)}catch(R){g(R??new Error("unknown"))}};p.useEffect(()=>{S()},[]),p.useEffect(()=>{var A;r!==null&&((A=N.current)==null||A.focus())},[r===null]);const $=r===null?0:kI(r),_=d>0&&$>d,O=r!==null&&i!==null&&!_&&!y,M=async()=>{if(O){j(null),x([]),v(!0);try{await e.writeCorrections(n,r,i),s(!0)}catch(A){v(!1);const R=A instanceof Ue?Jv(A):null;(R==null?void 0:R.kind)==="conflict"?(E(r),o(null),await S()):(R==null?void 0:R.kind)==="refused"?x(R.problems):j(A??new Error("unknown"))}}},P=A=>{A.key==="Escape"?(A.preventDefault(),A.stopPropagation(),s(!1)):A.key==="Enter"&&(A.metaKey||A.ctrlKey)&&(A.preventDefault(),M())};return t.jsxs("section",{className:"border border-border-strong bg-card","aria-label":"Edit corrections",onKeyDown:P,children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-2.5",children:[t.jsx("h3",{className:"caps text-label font-semibold",children:"corrections.md"}),t.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[t.jsxs("kbd",{children:[kD?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),f!==null&&t.jsx(xr,{problem:ua(f,"the corrections"),onRetry:()=>void S(!0),className:"m-5"}),t.jsxs("div",{className:"space-y-4 px-5 py-4",children:[k&&t.jsxs("div",{className:"border border-warning/50 bg-warning/10 px-4 py-3 text-body",role:"alert",children:[t.jsxs("p",{className:"flex items-center gap-2 font-semibold",children:[t.jsx(Ys,{className:"size-4 text-warning-text","aria-hidden":!0}),"Changed since you opened it"]}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"This is the newest version. Your edit wasn't saved; it's below to copy."}),t.jsxs("details",{className:"mt-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"Your edit"}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words border bg-background p-3 font-mono text-small",children:k})]})]}),r===null?f===null&&t.jsx("div",{role:"status","aria-label":"Loading the corrections",children:t.jsx("div",{"aria-hidden":!0,className:"h-24 bg-muted motion-safe:animate-pulse"})}):t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"sr-only",children:"Corrections"}),t.jsx(on,{ref:N,value:r,onChange:A=>o(A.target.value),rows:8,placeholder:"One correction a line: what to do differently, and why.",className:"resize-y font-mono leading-[1.65]"})]}),d>0&&t.jsxs("p",{className:te("font-mono text-label",_?"text-destructive-text":"text-muted-foreground"),role:_?"alert":void 0,children:[$," of ",d," bytes",_?": too long to save":""]}),h.length>0&&t.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[t.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: it doesn't pass the checks."}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:h.map((A,R)=>t.jsx("li",{children:A.detail},R))})]}),b!==null&&t.jsx(xr,{problem:Wd(b,"the corrections","The corrections were not saved."),className:""}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void M(),disabled:!O,children:y?"Saving":"Save"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>s(!1),disabled:y,children:"Cancel"})]})]})]})}const jf={serving:{word:"Serving",tone:"success",title:"It runs first on the runs it fits."},checking:{word:"Checking",tone:"active",title:"Its check on the agent's own runs decides whether this revision serves. The previous revision keeps serving meanwhile; the agent takes the runs only when none serves."},held:{word:"Held",tone:"warning",title:"It does not serve: its newest check or audit held it."},stopped:{word:"Stopped",tone:"muted",title:"It does not run first until a new revision lands: its checks stopped it, or it cost as much as the agent by hand. The agent takes its runs."}};function PD({item:e,v2:n,agentId:s,readOnly:r,runs:o,approves:i,onChanged:c,refreshHolds:d}){const[u,f]=Kc(d),[g,y]=p.useState(null),[v,h]=p.useState(null),[x,b]=Kc(d),[j,k]=Kc(d),[E,N]=p.useState(null),S=e.status==="pending",$=async()=>{h(null),y(null);try{y((await n.readLearningFile(s,e.file)).text)}catch(P){h(P??new Error("unknown"))}},_=async()=>{if(u)return f(!1);f(!0),g===null&&await $()};p.useEffect(()=>{g!==null&&(u?$():y(null))},[e.etag]);const O=async()=>{b(!0),N(null);try{await n.approveWorkflow(s,e.readme,e.etag)}catch(P){b(!1),N(P instanceof Ue&&Jv(P).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${ab} Reload the tab to see the newest version.`}):t.jsx(xr,{problem:Wd(P,"the workflow","The workflow was not approved."),className:""}));return}await c(),b(!1)},M=`the workflow ${e.name}`;return t.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[t.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),S&&t.jsxs(Ne,{tone:"warning",children:[t.jsx(o1,{className:"size-3","aria-hidden":!0}),"Waits for your OK"]}),jf[e.status]&&t.jsx(Ne,{tone:jf[e.status].tone,title:jf[e.status].title,children:jf[e.status].word})]}),e.description&&t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),S&&i==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:CI})]}),t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!r&&!j&&t.jsxs(t.Fragment,{children:[S&&i==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void O(),disabled:x,"aria-label":`Approve ${e.name}`,children:x?"Approving":"Approve"}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>k(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>void _(),"aria-expanded":u,"aria-label":`${u?"Hide":"Show"} ${M}`,children:[t.jsx(ri,{className:te("transition-transform",u&&"rotate-180"),"aria-hidden":!0}),u?"Hide":"Show"]})]})]}),E&&t.jsx("div",{className:"px-5 pt-3",children:E}),u&&(v!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(xr,{problem:ua(v,M),onRetry:()=>void $(),className:""})}):g===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${M}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):t.jsx(ID,{name:e.name,text:g})),t.jsxs("footer",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[e.run&&t.jsx(FC,{run:e.run,runs:o}),R0(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(h1,{className:"size-3","aria-hidden":!0}),R0(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),j&&t.jsx(DD,{name:e.name,retire:()=>n.retireWorkflow(s,e.readme,e.etag),onDone:async P=>{P&&await c(),k(!1)}})]})}function ID({name:e,text:n}){const{doc:s,graph:r}=p.useMemo(()=>{try{const c=JSON.parse(n);return{doc:c,graph:vl(c)}}catch{return{doc:null,graph:null}}},[n]),o=p.useMemo(()=>r?{meta:Rd(s,r)}:void 0,[s,r]),i=t.jsx("pre",{className:"max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:n});return r!=null&&r.nodes.length?t.jsxs("div",{className:"mx-5 mt-3 space-y-2",children:[t.jsx("div",{className:"overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-4",children:t.jsx(Fd,{graph:r,marks:o,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(Ud,{}),t.jsxs("details",{children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"workflow.json"}),t.jsx("div",{className:"mt-2",children:i})]})]}):t.jsx("div",{className:"mx-5 mt-3",children:i})}function R0(e){return e&&e.kind!=="learned"?`${mC(e.kind,e.by)} · ${vt(e.at)}`:null}function zD(e){return(e==null?void 0:e.by)==="host"?bI:e?`${mC("retired",e.by)} · ${vt(e.at)}`:"Retired"}function FC({run:e,runs:n}){return t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap",children:[t.jsx(f1,{className:"size-3 shrink-0 text-primary-text","aria-hidden":!0}),"Learned in"]}),t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"shrink-0 font-mono text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",title:wD(n,e),children:ca(e)})]})}function DD({name:e,retire:n,onDone:s}){const[r,o]=p.useState(!1),[i,c]=p.useState(null),d=p.useRef(null);p.useEffect(()=>{var f;(f=d.current)==null||f.focus()},[]);const u=async()=>{o(!0),c(null);try{await n()}catch(f){o(!1),c(f instanceof Ue&&Jv(f).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${ab} Reload the tab to see the newest version.`}):t.jsx(xr,{problem:Wd(f,"the workflow","The workflow was not retired."),className:""}));return}await s(!0)};return t.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:f=>{f.key==="Escape"&&(f.stopPropagation(),s(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Retire it?"})," Later runs stop getting it. It stays under Earlier workflows."]}),i&&t.jsx("div",{className:"w-full",children:i}),t.jsx(B,{ref:d,size:"sm",variant:"destructive",onClick:()=>void u(),disabled:r,children:r?"Retiring":"Yes, retire"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>void s(!1),disabled:r,children:"Keep"})]})}function FD({name:e,from:n,restore:s,onChanged:r,onDone:o}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),f=p.useRef(null);p.useEffect(()=>{var v;(v=f.current)==null||v.focus()},[]);const g=v=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:v}),y=async()=>{var v;c(!0),u(null);try{await s()}catch(h){if(c(!1),h instanceof Ue&&(h.status===412||h.code==="precondition_failed")){u(g(ab)),await r();return}if(h instanceof Ue&&h.status===403)return void u(g(jI));if(h instanceof Ue&&((v=h.problems)!=null&&v.length))return void u(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["Not restored: ",h.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:h.problems.map((x,b)=>t.jsx("li",{children:x.detail},b))})]}));if(h instanceof Ue&&h.status===400){await r(),o();return}return void u(t.jsx(xr,{problem:Wd(h,"the workflow","The workflow was not restored."),className:""}))}await r(),o()};return t.jsxs("div",{role:"alertdialog","aria-label":`Restore ${e}?`,onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),o())},className:"flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Restore it?"})," ",wI(n)]}),d&&t.jsx("div",{className:"w-full",children:d}),t.jsx(B,{ref:f,size:"sm",variant:"solid",onClick:()=>void y(),disabled:i,children:i?"Restoring":"Yes, restore"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:o,disabled:i,children:"Keep"})]})}function UD({title:e,count:n,open:s,onToggle:r,children:o}){return t.jsxs("section",{className:"border","aria-label":e,children:[t.jsxs("button",{type:"button","aria-expanded":s,onClick:r,className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(ri,{className:te("size-3.5 text-muted-foreground transition-transform",!s&&"-rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:e}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:n})]}),s&&t.jsx("ul",{className:"border-t",children:o})]})}function WD({items:e,v2:n,agentId:s,runs:r,readOnly:o,onChanged:i,refreshHolds:c}){const[d,u]=p.useState(!1),[f,g]=Kc(c,null),[y,v]=p.useState(new Set),h=x=>v(b=>{const j=new Set(b);return j.has(x)?j.delete(x):j.add(x),j});return t.jsx(UD,{title:"Earlier workflows",count:`${e.length} no longer given`,open:d,onToggle:()=>u(x=>!x),children:e.map(x=>{var b;return t.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:x.name}),t.jsx(Ne,{tone:"muted",children:"Retired"}),t.jsx(HD,{open:y.has(x.file),label:`the workflow ${x.name}`,onClick:()=>h(x.file)}),!o&&f!==x.file&&t.jsxs(B,{size:"sm",onClick:()=>g(x.file),"aria-label":`Restore ${x.name}`,children:[t.jsx(dR,{"aria-hidden":!0})," Restore"]})]}),x.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:x.description}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:zD(x.retired)}),f===x.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(FD,{name:x.name,from:(b=x.retired)==null?void 0:b.from,restore:()=>n.restoreWorkflow(s,x.readme,x.etag),onChanged:i,onDone:()=>g(null)})}),y.has(x.file)&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx(BD,{v2:n,agentId:s,file:x.file,etag:x.etag,label:`the workflow ${x.name}`}),x.run&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(FC,{run:x.run,runs:r})})]})]},x.file)})})}function HD({open:e,label:n,onClick:s}){return t.jsxs(B,{size:"sm",variant:"ghost",className:"ml-auto",onClick:s,"aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${n}`,children:[t.jsx(ri,{className:te("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function BD({v2:e,agentId:n,file:s,etag:r,label:o}){const[i,c]=p.useState(null),[d,u]=p.useState(null),f=p.useRef(0),g=async()=>{const y=++f.current;u(null),c(null);try{const v=await e.readLearningFile(n,s);y===f.current&&c(v.text)}catch(v){y===f.current&&u(v??new Error("unknown"))}};return p.useEffect(()=>{g()},[s,r]),d!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(xr,{problem:ua(d,o),onRetry:()=>void g(),className:""})}):i===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${o}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):t.jsx("pre",{className:"mx-5 mt-3 max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:i})}function A0({runs:e}){const n=e.filter(o=>{var i;return((i=o.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(o=>im(o.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(o=>im(o.learning.reason)!=="nothing").length;return n.length?t.jsxs(DC,{title:"Kept nothing",children:[s.length>0&&t.jsx("ul",{children:s.map(o=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(o.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[t.jsx("span",{className:"block text-body",children:db(o.learning)}),t.jsxs("span",{className:"mt-1 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",title:On(o),children:On(o)}),t.jsxs("span",{className:"shrink-0",children:["· ",vt(o.created_at)]})]})]})},o.run_id))}),r>0&&t.jsxs("p",{className:te("px-4 py-3 font-mono text-label text-muted-foreground",s.length>0&&"border-t"),children:[s.length?`${r} more ${r===1?"run":"runs"} had`:`${id(r)} had`," nothing new to compile."]})]}):null}function qD({corrections:e,workflows:n,off:s}){const r=s?[]:[...e?[lb(e)]:[],...n.length?[wl(n.length,"workflow")]:[]];return t.jsxs("section",{className:"border","aria-label":"What the next run is given",children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What the next run is given"}),t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:s?"Learning is off: the next run gets no corrections or workflows.":r.length?`${r.join(" and ")}.`:"Nothing yet."}),!s&&n.length>0&&t.jsxs("p",{className:"break-words border-t px-4 py-3 font-mono text-small leading-[1.7]",children:["Workflows: ",n.map(o=>`${o.name} (${o.status})`).join(", ")]})]})}function Nb({run:e,link:n=!1,className:s}){var c;const r=oh(e.learning)&&e.learning.state!=="seeded",o=hC(e.learning),i=((c=e.learning)==null?void 0:c.state)==="dropped"&&im(e.learning.reason)!=="nothing"?db(e.learning):null;return!r&&!o.length&&!i?null:t.jsxs("span",{className:te("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[i&&t.jsx(GD,{agentId:e.agent_id,said:i,link:n}),[!1,!0].map(d=>{const u=o.filter(f=>f.pending===!0===d);return u.length?t.jsx(KD,{agentId:e.agent_id,refs:u,link:n,pending:d},String(d)):null}),r&&t.jsxs(Ne,{tone:"active",children:[t.jsxs("span",{className:"relative flex size-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inline-flex size-full animate-ping bg-run-active opacity-75"}),t.jsx("span",{className:"relative inline-flex size-1.5 bg-run-active"})]}),_I(e.learning.state)]})]})}function GD({agentId:e,said:n,link:s}){const r=t.jsxs(Ne,{tone:"muted",className:te(s&&"cursor-pointer"),children:[t.jsx(HT,{className:"size-3","aria-hidden":!0}),"Kept nothing"]});return s?t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:ub(e),"aria-label":`Kept nothing: ${n}`,className:"inline-flex",children:r}),t.jsx("span",{className:"text-small text-muted-foreground",children:n})]}):t.jsx("span",{title:`Kept nothing: ${n}`,"aria-label":`Kept nothing: ${n}`,className:"inline-flex",children:r})}function KD({agentId:e,refs:n,link:s,pending:r}){const o=r?`${wl(n.length,"workflow")} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${wl(n.length,"workflow")}`,i=`${o}: ${n.map(u=>u.name).join(", ")}`,c=r?o1:li,d=t.jsxs(Ne,{tone:r?"warning":void 0,className:te(!r&&"border-primary/50 bg-primary/10 text-primary-text",s&&"cursor-pointer"),children:[t.jsx(c,{className:"size-3","aria-hidden":!0}),o]});return s?t.jsx("a",{href:ub(e),title:i,"aria-label":i,className:"inline-flex",children:d}):t.jsx("span",{title:i,"aria-label":i,className:"inline-flex",children:d})}function VD({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":cb(e),className:te("inline-flex min-w-[18px] items-center justify-center border border-warning/50 bg-warning/10 px-1 font-mono text-micro text-warning-text",n),children:e})}function Hd(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function br(e=Hd){let n=null;return{keyFor(s,r){const o=JSON.stringify([s,r]);return(n==null?void 0:n.request)!==o&&(n={request:o,key:e()}),n.key},done(){n=null}}}async function UC(e,n,s,r){const o=await r(n,s,e.keyFor(n,{content:s}));return e.done(),o}function YD(e=Hd){const n=new Map;return s=>{let r=n.get(s);return r||(r=br(e),n.set(s,r)),r}}function Sx(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const QD=["pi","claude-agent","codex","opencode"];function JD(e){const n=new Set,s=r=>{if(Array.isArray(r)){r.forEach(s);return}if(!r||typeof r!="object")return;const o=r;o.node==="call"&&typeof o.tool=="string"&&n.add(o.tool),Object.values(o).forEach(s)};return s(e),[...n].sort()}function XD(e){const n=s=>Array.isArray(s)&&s.every(r=>typeof r=="string")?[...new Set(s)]:[];return{denied:n(e==null?void 0:e.denied),asks:n(e==null?void 0:e.asks)}}function ZD(e){return(Array.isArray(e)?e:[]).flatMap(n=>{const s=n;return!s||typeof s.name!="string"||!Array.isArray(s.providers)||!s.providers.length?[]:[{name:s.name,providers:s.providers,provider:s.provider??s.providers[0],default_provider:s.default_provider??s.providers[0],resolves:s.resolves&&typeof s.resolves=="object"?s.resolves:{},available:s.available!==!1,...typeof s.reason=="string"&&s.reason?{reason:s.reason}:{}}]})}const Sb="Refused on this server for every agent, whatever the agent's own setting or Never ask.",e6="Deny stops this tool only. The agent can still reach the web with other tools it has, such as browser, bash or web_search: deny those too to keep it offline.",WC=(e,n,s,r)=>{var d;const o=s==null?void 0:s.find(u=>u.name===e);if(o)return o.permission==="deny"&&o.permission_from==="server";const i=Zo(e),c=i?(d=r==null?void 0:r.find(u=>u.name===i.server))==null?void 0:d.tools.find(u=>u.name===i.tool):void 0;return c?c.permission==="deny":n.some(u=>u.name===e&&u.permission==="deny")};function t6(e){return(e??[]).map(({name:n,permission:s,default_permission:r,permissions:o,ask_needs:i})=>({name:n,permission:s,default_permission:r,permissions:o,...i==="password"?{ask_needs:i}:{}}))}const n6={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},HC={browser:{label:{auto:"Auto (Browserbase where its key is saved, else Kernel)",browserbase:"Browserbase",kernel:"Kernel",chrome:"Local Chrome"},help:{auto:"Browserbase where its key is set or saved, else Kernel where its key is; unavailable with neither.",browserbase:"Browserbase's hosted browser: needs the Browserbase key and project id.",kernel:"Kernel's hosted browser: needs the Kernel key.",chrome:"A Chrome on this server's own host. No server sets one up yet, so it stays unavailable."}}},um=(e,n)=>{var s;return(n&&((s=HC[n])==null?void 0:s.label[e]))??n6[e]??e},s6={auto:"The harness's own search, or the model provider's hosted one; else Parallel where this server holds its key; else keyless Exa.",native:"The harness's own search, or the model provider's hosted one, never a third party: unavailable where there is none.","exa-keyless":"Exa's keyless search: no key, a third party.",parallel:"Parallel: needs the Parallel key.",kernel:"This server's own fetch, guarded against private addresses."},O0=(e,n)=>{var s;return(n&&((s=HC[n])==null?void 0:s.help[e]))??s6[e]};function BC(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:um(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function qC(e,n,s,r,o){const{[n]:i,...c}=e,{[s]:d,...u}=i??{},f=r===void 0||r===o?u:{...u,[s]:r};return Object.keys(f).length?{...c,[n]:f}:c}const r6=(e,n,s,r)=>qC(e,n,"provider",s,r),o6=(e,n,s,r)=>qC(e,n,"permission",s,r);function Cx(e,n){const s=new Map(n.map(r=>[r.name,r.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([r,o])=>{if(!o||typeof o!="object")return[];const{provider:i,...c}=o,d=i!==void 0&&!(s.has(r)&&i===s.get(r))?{...c,provider:i}:c;return Object.keys(d).length?[[r,d]]:[]}))}function GC(e,n,s){const r={},o=[];for(const[i,c]of Object.entries(e)){if(n&&i!==n&&!i.startsWith(`${n}.`)&&!i.startsWith(`${n}/`))continue;const d=n?i.slice(n.length+1):i,u=[...s].sort((f,g)=>g.length-f.length).find(f=>d===f||d.startsWith(`${f}.`)||d.startsWith(`${f}/`));u?(r[u]??(r[u]=[])).push(c):o.push(c)}return{byTool:r,rest:o}}const a6=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),i6=e=>{if(!Array.isArray(e))return[e];const n=[...new Set(e.filter(s=>s!==null).map(s=>JSON.stringify(s)))].sort();return[...e.includes(null)?[null]:[],...n.map(s=>JSON.parse(s))]},l6=e=>typeof e=="string"?e:JSON.stringify(e);function c6(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(a6(s)){const d=[...new Set(s.keys)].sort();return d.length===1?`${n} may hold only the key ${d[0]} (any value)`:`${n} may hold only the keys ${d.join(", ")} (any values)`}const r=i6(s),o=r[0]===null,i=(o?r.slice(1):r).map(d=>l6(d));if(!i.length)return`${n} must be left out`;const c=i.length===1?i[0]:`one of ${i.join(", ")}`;return`${n} must be ${o?`left out or ${c}`:c}`}).join("; ")}const d6="Calls outside it are refused before they run or ask.",u6="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.",f6=[{id:"runs",label:"Runs",shows:()=>!0,Body:x6},{id:"versions",label:"Versions",shows:()=>!0,Body:VL},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:v6},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(SD,{agent:e.agent,v2:e.v2,server:e.learning,onAgent:e.onAgent,onChanged:e.onChanged})},{id:"analytics",label:"Analytics",shows:(e,n)=>n.analytics,Body:yP}],Cn=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function m6({v2:e,agentId:n,routePrefix:s,harnesses:r,go:o,tab:i,learning:c,places:d}){const[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(0),[x,b]=p.useState(void 0);p.useEffect(()=>{let R=!0;return f(null),y(null),b(void 0),S(!1),E.current=++j.current,e.getAgent(n).then(L=>{R&&f(L.agent)},L=>{R&&y({cause:L})}),e.statsOver({from:Wv(eC),agent:n}).then(L=>{R&&b(L)},()=>{R&&b(null)}),()=>{R=!1,E.current=++j.current}},[e,n,v]);const j=p.useRef(0),k=p.useRef(0),E=p.useRef(0),[N,S]=p.useState(!1),$=(R=!1,L=!R)=>{const W=++j.current;return L&&(E.current=W),e.getAgent(n).then(U=>(W>k.current&&W>=E.current&&(k.current=W,f(Y=>Y&&Y.agent_id===U.agent.agent_id?U.agent:Y),S(!1)),k.current>=W),()=>(W===j.current&&!R&&S(!0),k.current>=W))},_=R=>{f(L=>({...R,tools:(L==null?void 0:L.tools)??R.tools})),$()},O=()=>void $(),M=()=>void $(!0,!1),P=()=>$(!0,!0),A=x===void 0?void 0:x!==null;return g?g.cause instanceof Ue&&g.cause.status===404?t.jsx(I2,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(en,{problem:Jt(g.cause,"the agent"),onRetry:()=>h(R=>R+1)}):u?t.jsx(h6,{agent:u,onAgent:_,onSignInsAgent:f,reread:$,onChanged:O,poll:M,afterForget:P,stale:N,v2:e,go:o,stats:x,analytics:A,places:d,routePrefix:s,harnesses:r,tab:i,learning:c},u.agent_id):t.jsx(HL,{})}function h6({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:o,poll:i,afterForget:c,stale:d,v2:u,go:f,stats:g,analytics:y,routePrefix:v,harnesses:h,tab:x,learning:b,places:j}){var le,me,Ke,be;const k=g6(e,u,r,()=>r(!1,!1)),[E,N]=p.useState(!1),S=yg(),$=yg(),_=yg(),O=p.useRef(null),[M,P]=p.useState({heading:!1,description:!1});p.useEffect(()=>{const ge=O.current,Je=_.current;if(!ge||!Je||typeof ResizeObserver>"u")return;const tt=Ee=>Ee.scrollHeight>Ee.clientHeight+1,ft=()=>P(Ee=>{const Q={heading:tt(ge),description:tt(Je)};return Q.heading===Ee.heading&&Q.description===Ee.description?Ee:Q}),ve=new ResizeObserver(ft);for(const Ee of[ge,Je]){ve.observe(Ee);for(const Q of Ee.children)ve.observe(Q)}return ft(),()=>ve.disconnect()},[_,e.definition.name,e.definition.description,e.definition.approvals]);const A=am(e),R=e.definition,L=os(R),{native:W,refresh:U}=eI(e,u),Y=e.kind==="workflow",D=Y?li:e1,G=xb(R.harness??"pi",h),F=R.model?jl(R.model,v):G?(({text:ge,title:Je})=>({text:`${ge} (default)`,title:Je}))(jl(G,v)):{text:Tz},q=Y||W||L||h==null?void 0:h.find(ge=>ge.id===(R.harness??"pi")&&ge.available===!1),H=q?`${q.id} doesn't run on this server${q.reason?`: ${q.reason}`:"."}`:void 0,I=QP(e,j),V=`${IP(I==null?void 0:I.place)}${I!=null&&I.byDefault?" (server default)":""}`,J=!L&&!W&&!Y&&!q&&!R.model&&!G&&(h==null?void 0:h.some(ge=>ge.id===(R.harness??"pi")&&ge.default_model===null)),X=[...L?[["Runtime",sa(L.runtime)],["Model","Reported per run"],["Execution","Your backend"]]:W?[["Runtime",W.runtime],["Model",W.model??"Native default"],["Selector",W.selector.kind==="project"?"Project default":W.selector.name??W.selector.kind],["Machine",W.machine_id]]:Y?[]:[["Harness",R.harness??"pi"],["Model",F.text,F.title],["Thinking",R.thinking??"default"],["Runs",V]],["Revision",`rev ${R.version} of ${e.revisions}`]],re=f6.filter(ge=>ge.shows(e,{analytics:y===!0,learning:b===void 0?x==="learning"?void 0:!1:!!b})),ae=re.find(ge=>ge.id===x)??re[0],ye=x==="analytics"&&y===void 0,he=((le=k.runs)==null?void 0:le.filter(p6))??[],we=((me=e.runs)==null?void 0:me.live)??(k.runs?`${he.length}${k.cursor?"+":""}`:"—"),ze=[["Status",e.archived_at?"Archived":W?Pd(W):"Active"],["Live jobs",String(we)],...X];return t.jsx(tI,{native:W,children:t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":"Agent detail",children:[t.jsxs("header",{className:te(vr,"flex-wrap gap-2 px-5 lg:flex-nowrap"),"aria-label":"Agent toolbar",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>f(e.archived_at?"#/agents?archived=true":"#/agents"),children:t.jsx(Fn,{"aria-hidden":!0})}),t.jsx(D,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 truncate text-body font-semibold",children:R.name}),t.jsxs("div",{className:"ml-auto flex max-w-full flex-wrap items-center justify-end gap-2",children:[t.jsx(B,{size:"icon","aria-label":"Refresh agent",onClick:()=>{k.refresh(),U()},disabled:k.reading,children:t.jsx(oa,{className:te(k.reading&&"animate-spin"),"aria-hidden":!0})}),!W&&!L&&t.jsx(B,{size:"sm",onClick:()=>f(Cn(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(an,{label:"Edit agent",prompt:Xo(location.origin,e.agent_id,!!W,L==null?void 0:L.runtime),playgroundHref:W||L?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(an,{variant:"primary",label:"Run agent",disabled:!!W&&(!W.connected||W.state!=="ready"||!W.capabilities.launch),prompt:Kv(location.origin,e.agent_id,L==null?void 0:L.runtime),playgroundHref:L?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`})]})]}),t.jsxs("main",{className:"grid min-h-0 flex-1 grid-cols-1 items-start gap-6 overflow-auto p-5 lg:grid-cols-[minmax(260px,320px)_minmax(0,1fr)] lg:grid-rows-[minmax(0,1fr)] lg:items-stretch lg:overflow-hidden md:p-8",children:[t.jsxs("aside",{className:"min-w-0 space-y-6 lg:flex lg:min-h-0 lg:flex-col","aria-label":"Agent overview",children:[t.jsxs("div",{ref:O,"data-agent-heading":!0,...M.heading?{tabIndex:0,role:"region","aria-label":"Agent name and description"}:{},className:"lg:-mr-4 lg:flex lg:max-h-[50%] lg:shrink-0 lg:flex-col lg:overflow-y-auto lg:overflow-x-hidden lg:pr-4 lg:[scrollbar-width:none]",children:[t.jsx("h1",{className:"text-2xl font-semibold lg:shrink-0",children:R.name}),R.approvals==="never"&&t.jsx(Ne,{tone:"warning",className:"mt-2 lg:shrink-0 lg:self-start",title:"Never ask: a call of this agent never waits for you. A tool set to deny, and a template’s pins, still hold.",children:"Unattended"}),t.jsx("div",{ref:_,"data-agent-description":!0,...M.description?{tabIndex:0,role:"region","aria-label":"Agent description"}:{},className:te("scroll-quiet min-w-0 lg:-mr-4 lg:overflow-y-auto lg:overflow-x-hidden lg:pr-2.5",R.description?"lg:min-h-7":"lg:min-h-0"),children:R.description&&t.jsx("p",{id:"agent-description",className:te("mt-2 break-words text-body leading-relaxed text-muted-foreground",!E&&"max-sm:line-clamp-2"),children:R.description})}),t.jsx("p",{className:"mt-3 break-all font-mono text-label text-muted-foreground lg:shrink-0",children:e.agent_id})]}),t.jsxs("div",{ref:S,"data-agent-details":!0,className:"scroll-quiet min-w-0 space-y-6 lg:-ml-1 lg:-mr-4 lg:min-h-0 lg:flex-1 lg:overflow-y-auto lg:overflow-x-hidden lg:pb-6 lg:pl-1 lg:pr-2.5",children:[t.jsxs("button",{type:"button","aria-expanded":E,"aria-controls":R.description?"agent-description agent-facts":"agent-facts",onClick:()=>N(ge=>!ge),className:"flex w-full min-w-0 items-center gap-2 text-left font-mono text-small text-muted-foreground sm:hidden",children:[t.jsx(As,{className:te("size-3.5 shrink-0 transition-transform",E&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:ze.map(([,ge])=>ge).join(" · ")})]}),t.jsxs("dl",{id:"agent-facts",className:te("grid grid-cols-2 gap-3",!E&&"max-sm:hidden"),"aria-label":"Current revision",children:[ze.map(([ge,Je,tt])=>t.jsxs("div",{className:"min-w-0 border bg-card p-4",children:[t.jsx("dt",{className:"mb-2 text-label text-muted-foreground",children:ge}),t.jsx("dd",{className:"break-words text-body font-semibold",title:tt,children:Je})]},ge)),!Y&&!W&&!L&&t.jsxs("div",{className:"col-span-2 border bg-card p-4",children:[t.jsx("dt",{className:"mb-2 text-label text-muted-foreground",children:"Tools"}),t.jsx("dd",{className:"break-words text-small",children:!Y&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(ge=>t.jsxs("li",{children:[t.jsx("span",{title:ge.blurb,children:ge.name}),ge.provider?` · ${um(ge.provider,ge.name)}`:"",ge.permission?` · ${ge.permission}`:"",BC(ge.resolved,ge.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:ge.resolved,children:" · unavailable"})]},ge.name))}):"none":R.tools.join(", ")||"None configured"})]})]}),H&&t.jsx(jt,{tone:"warning","aria-label":"Harness not available",children:H}),!e.archived_at&&J&&t.jsxs(jt,{children:["Running this agent needs a configured model. ",t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline underline-offset-2",children:"Set up models in Settings"})]}),d&&t.jsxs(jt,{tone:"error",children:["Couldn't refresh this agent. ",t.jsx(B,{size:"sm",onClick:()=>void r(),children:"Retry"})]}),(Ke=e.warnings)!=null&&Ke.length?t.jsxs("div",{className:"font-mono text-small",role:"status","aria-label":"Save warnings",children:[t.jsx("p",{className:"text-warning-text",children:"Created. What the server said of this revision (Edit shows each at its step):"}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:e.warnings.map((ge,Je)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:ge.field})," ",ge.message]},`${ge.field}:${Je}`))})]}):null,t.jsx(oI,{agent:e,v2:u,onAgent:s,poll:i,refresh:c}),W&&t.jsx(nI,{agent:e,v2:u,learning:b,onAgent:n,onChanged:async()=>{U(),await r()}}),!W&&t.jsxs("section",{className:"border bg-card p-4","aria-label":"Agent configuration",children:[t.jsx("h2",{className:"mb-4 text-body font-semibold",children:"Configuration"}),t.jsxs("dl",{className:"space-y-3 text-small",children:[t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Kind"}),t.jsx("dd",{children:e.kind})]}),t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Skills"}),t.jsx("dd",{className:"max-w-[75%] break-words text-right",children:L?"Managed by your backend":R.skills.join(", ")||"None configured"})]})]}),R.instructions&&t.jsxs("details",{className:"mt-4 text-small",children:[t.jsx("summary",{className:"cursor-pointer",children:"Instructions"}),t.jsx("pre",{className:"mt-3 whitespace-pre-wrap break-words font-sans leading-relaxed text-muted-foreground",children:R.instructions})]})]}),t.jsxs("section",{className:"border bg-card p-4","aria-label":"Live jobs",children:[t.jsx("h2",{className:"mb-3 text-body font-semibold",children:"Live jobs"}),he.length?t.jsx("ul",{className:"space-y-3",children:he.map(ge=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(ge.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx(Ll,{run:ge}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:On(ge)}),t.jsx(pr,{className:"size-3 shrink-0","aria-hidden":!0})]})},ge.run_id))}):t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:k.runs?(be=e.runs)!=null&&be.live?"Live jobs are outside the loaded history. Load more runs to find them.":k.error?"Live jobs could not be refreshed.":"No live jobs.":"Loading live jobs…"})]})]})]}),t.jsxs("section",{ref:$,className:"scroll-quiet min-w-0 lg:-ml-1 lg:-mr-4 lg:min-h-0 lg:overflow-y-auto lg:overflow-x-hidden lg:pb-6 lg:pl-1 lg:pr-2.5","aria-label":"Agent workspace",children:[t.jsx(Ev,{id:"agent-views",label:"Agent views",value:ae.id,onChange:ge=>f(Cn(e.agent_id,ge)),tabs:re.map(ge=>({id:ge.id,label:t.jsxs(t.Fragment,{children:[ge.label,ge.id==="learning"&&t.jsx(VD,{n:A,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...c2("agent-views",ae.id),"aria-label":ye?void 0:ae.label,children:ye?t.jsx(Qn,{label:"Loading the tab",rows:4}):t.jsx(ae.Body,{agent:e,v2:u,go:f,stats:g,history:k,learning:b,onAgent:n,onChanged:o,places:j})})]})]})]})})}const p6=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function g6(e,n,s,r){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(!1),[v,h]=p.useState(null),[x,b]=p.useState(!1),j=p.useRef(0),k=p.useRef([]),E=p.useRef(0),N=p.useRef(!1),S=async($,_=!1,O=!1,M=!1)=>{if(N.current)return;N.current=!0;const P=++j.current;f(!0),y(!!$);const A=_?M?r():s():Promise.resolve();try{let R=$,L=[];const W=$||O?void 0:k.current.at(-1),U=W?Date.parse(W.created_at):NaN,Y=E.current+1;let D=!1;const G=new Set;do{if(G.size>=Y){b(!0),h({title:"Run history could not be refreshed.",why:"Previous runs are still shown. The run list changed too much to refresh them safely.",next:"Try again, or reload the latest runs to reset the loaded history."});return}if(G.has(R))throw new Error("The runs list repeated a page. Refresh to try again.");G.add(R);const F=await n.listAgentRuns(e.agent_id,50,R,!!e.archived_at);if(P!==j.current)return;L=Sx(L,F.runs),R=F.next_cursor,D||(D=F.runs.some(q=>q.run_id===(W==null?void 0:W.run_id)||Date.parse(q.created_at)<U))}while(!$&&R&&W&&!D);P===j.current&&(k.current=$?Sx(k.current,L):L,E.current=$?E.current+1:G.size,i(k.current),d(R),h(null),b(!1))}catch(R){P===j.current&&h(Jt(R,$?"more runs":"the runs"))}finally{await A,P===j.current&&(N.current=!1,f(!1),y(!1))}};return p.useEffect(()=>{N.current=!1,k.current=[],E.current=0,i(null),d(null),h(null),b(!1),S(null);const $=()=>{document.hidden||S(null,!0,!1,!0)};window.addEventListener("focus",$),document.addEventListener("visibilitychange",$);const _=window.setInterval($,1e4);return()=>{j.current++,N.current=!1,window.clearInterval(_),window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",$)}},[n,e.agent_id,e.archived_at]),{runs:o,cursor:c,reading:u,more:g,error:v,refresh:()=>{S(null,!0)},loadMore:()=>{c&&S(c)},reloadLatest:x?()=>{S(null,!0,!0)}:null}}function x6({agent:e,history:n}){const[s,r]=p.useState(""),{runs:o,cursor:i,reading:c,more:d,error:u,refresh:f,loadMore:g,reloadLatest:y}=n;if(u&&!o)return t.jsx(en,{problem:u,onRetry:f,className:""});if(!o)return t.jsx(Qn,{label:"Loading the runs",rows:5});const v=o.filter(h=>`${On(h)} ${h.run_id} ${h.status}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"min-h-[380px] overflow-hidden border","aria-label":"Agent run history",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b p-3",children:[t.jsxs("label",{className:te(Za,"flex w-56 min-w-0 items-center gap-2 px-3"),children:[t.jsx(yd,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(De,{bare:!0,type:"search","aria-label":"Search this agent's runs",value:s,onChange:h=>r(h.target.value),placeholder:"Search runs…",className:"h-control-md w-full"})]}),t.jsxs("span",{className:"text-small text-muted-foreground",children:[o.length,i?"+":""," ",o.length===1&&!i?"run":"runs"]}),t.jsx("div",{className:"ml-auto",children:t.jsx(an,{label:"Query",prompt:`${eh(location.origin,e.agent_id)}
641
+ Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:Fv(e.agent_id,{archived:!!e.archived_at})})})]}),o.length?t.jsxs("div",{className:"overflow-x-auto",children:[t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Runs",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Status","Run","Started","Duration","Cost"].map(h=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:h},h))})}),t.jsx("tbody",{children:v.map(h=>t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent/50",children:[t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:t.jsx(Ll,{run:h})}),t.jsxs("td",{className:"min-w-48 px-4 py-3",children:[t.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex items-center gap-2 font-semibold hover:text-primary-text",children:[t.jsx("span",{className:"line-clamp-2",children:On(h)}),t.jsx(pr,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-label text-muted-foreground",children:[t.jsx(Nb,{run:h}),h.effort&&t.jsxs("span",{children:["effort ",h.effort]}),h.imported_from&&t.jsxs("span",{children:["Imported history · ",h.imported_from.source]})]})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:vt(h.created_at)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:h.ended_at?t.jsx("span",{title:"How long it ran",children:yl(Date.parse(h.ended_at)-Date.parse(h.created_at))}):"—"}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:h.cost&&(h.cost.usd!==null||ui(h.cost))?Go(h.cost,{ended:lo(h.status)}):"—"})]},h.run_id))})]}),!v.length&&t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No loaded runs match your search."})]}):t.jsxs("div",{className:"px-4 py-12 text-center text-body text-muted-foreground",children:[t.jsx("p",{children:"No runs of this agent yet."}),!e.archived_at&&t.jsx("p",{className:"mt-2",children:"Choose Run agent to continue with your coding agent or the API playground."})]}),u&&t.jsxs("div",{className:"m-4 space-y-3",children:[t.jsx(en,{problem:u,onRetry:f,className:""}),y&&t.jsx(B,{size:"sm",onClick:y,disabled:c,children:"Reload latest runs"})]}),i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",onClick:g,disabled:c,children:d?"Loading":"Load more"})})]})}function v6({agent:e}){const n=e.definition.workflow,s=p.useMemo(()=>vl(n),[n]),r=p.useMemo(()=>({meta:Rd(n,s)}),[n,s]);return t.jsxs("section",{className:"overflow-hidden border",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[lh(kb(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(an,{label:"Edit workflow",prompt:Xo(location.origin,e.agent_id),playgroundHref:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`})]}),t.jsx("div",{className:"min-h-[360px] overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5",children:s.nodes.length?t.jsx(Fd,{graph:s,marks:r,label:"The workflow's graph",minScale:.55}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"This revision's workflow has no root node to draw."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(Ud,{})})]})}function KC({size:e=18,className:n}){return t.jsx("svg",{width:e,height:e,className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 4q9 4 18 0M4 9h16M7 6v15M17 6v15M6 15h12M12 7v2"})})}const b6=100,y6=4,M0=(e,n)=>(e==null?void 0:e.filter(s=>n(s.status)).length)??0,VC=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,Ex=e=>e.toLocaleString("en-US"),YC=[{label:"Corrections",of:e=>e.view?{value:ib(e.view.corrections).length,exact:!0}:null},{label:"Workflow drafts",of:e=>e.view?{value:M0(e.view.workflows,rh),exact:!0}:null},{label:"Pending review",of:e=>e.view?{value:M0(e.view.workflows,n=>n==="pending"),exact:!0}:null},{label:"In progress",of:e=>e.view?{value:e.view.counts.in_progress,exact:!0}:null}];function QC(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${Ex(s.reduce((r,o)=>r+((o==null?void 0:o.value)??0),0))}${e.some(r=>r.stale)?" (last read)":s.every(r=>r==null?void 0:r.exact)?"":"+"}`}function w6({v2:e,server:n}){const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),g=p.useRef(0),y=p.useRef(!1),v=p.useCallback(async()=>{if(n!=="on"&&n!=="off"||y.current)return;y.current=!0;const k=++g.current;d(!0),i(null),r(N=>(N==null?void 0:N.map(S=>S.view?{...S,stale:!0}:S))??null);const E=()=>g.current===k;try{let N=null;const S=new Set,$=await Mr(async A=>{if(!E())throw new Error("Read superseded");if(A&&S.has(A))throw new Error("The agent list repeated a page. Refresh to try again.");A&&S.add(A);const R=await e.listAgents({cursor:A});return N=R.next_cursor,R},A=>A.agents,b6);if(!E())return;if(N)throw new Error("The agent list is too large to read in one view. Open Connected agents to inspect an agent.");const _=[...new Map($.map(A=>[A.agent_id,A])).values()].map(A=>({agent:A}));r(A=>{const R=new Map(A==null?void 0:A.map(L=>[L.agent.agent_id,L]));return _.map(({agent:L})=>{const W=R.get(L.agent_id);return L.kind==="agentic"&&(W==null?void 0:W.agent.kind)==="agentic"&&W.view?{...W,agent:L,stale:!0,error:void 0,unavailable:void 0}:{agent:L}})});const O=_.filter(A=>A.agent.kind==="agentic");let M=0;const P=async()=>{for(;E()&&M<O.length;){const{agent:A}=O[M++];let R;try{const L=await e.agentLearning(A.agent_id);if(!E())return;R={agent:A,view:L}}catch(L){R={agent:A,error:Jt(L,"Learning"),unavailable:L instanceof Ue&&L.status===404}}if(!E())return;r(L=>(L==null?void 0:L.map(W=>W.agent.agent_id!==A.agent_id?W:R.error&&!R.unavailable&&W.view?{...W,...R,stale:!0}:R))??null)}};await Promise.all(Array.from({length:Math.min(y6,O.length)},P)),E()&&f(new Date().toISOString())}catch(N){E()&&i(Jt(N,"Learning Dojo"))}finally{E()&&(y.current=!1,d(!1))}},[e,n]);p.useEffect(()=>{r(null),f(null),i(null),v();const k=()=>{document.hidden||v()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{g.current++,y.current=!1,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[v]),p.useEffect(()=>{if(n!=="on"&&n!=="off")return;const k=window.setInterval(()=>{document.hidden||v()},15e3);return()=>window.clearInterval(k)},[n,v]);const h=(s==null?void 0:s.filter(k=>k.agent.kind==="agentic"))??[],x=h.filter(k=>k.view).length,b=h.some(k=>k.stale),j=h.flatMap(k=>{var E;return(((E=k.view)==null?void 0:E.log.items)??[]).map(N=>({agent:k.agent,change:N}))}).sort((k,E)=>E.change.at.localeCompare(k.change.at)).slice(0,8);return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:te(vr,"gap-2 px-5"),children:[t.jsxs("h1",{className:Jo,children:[t.jsx(KC,{size:16,className:"shrink-0"}),"Learning Dojo"]}),t.jsx(B,{className:"ml-auto",size:"icon","aria-label":"Refresh Learning Dojo",disabled:c||!n,onClick:()=>void v(),children:t.jsx(oa,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-7 p-5 md:p-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"What your agents learn"}),t.jsx("p",{className:"mt-2 max-w-3xl text-lead leading-relaxed text-muted-foreground",children:"Review the corrections and workflow drafts your current agents keep for later runs. Open an agent to enable learning, inspect its changes or review pending drafts."}),t.jsx("p",{className:"mt-2 max-w-3xl text-small leading-relaxed text-muted-foreground",children:"Imported sessions are history, not learning runs. Workflow drafts come from agentic runs started through this server; corrections are yours, given with a grade or written on an agent's Learning tab."})]}),n===void 0?t.jsx("p",{role:"status",className:"text-lead text-muted-foreground",children:"Checking learning support…"}):n===null?t.jsxs("div",{className:"border bg-card p-5",children:[t.jsx("h3",{className:"font-semibold",children:"This server does not expose learning"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Use a server version with learning support to inspect or enable it here."}),t.jsx("a",{href:"#/agents",className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",children:"Connected agents"})]}):t.jsxs(t.Fragment,{children:[n==="off"&&t.jsx("p",{role:"status",className:"border border-warning/40 bg-warning/5 p-4 text-lead text-warning-text",children:"This server has learning turned off. Saved learning remains available; new runs will learn only after the server's learning setting is on."}),o&&t.jsxs(t.Fragment,{children:[t.jsx(en,{problem:o,onRetry:()=>void v(),className:""}),s&&t.jsx("p",{className:"text-small text-warning-text",children:"Showing the last read. Refresh to update these counts."})]}),!s&&!o?t.jsx(Qn,{label:"Loading Learning Dojo",rows:4}):s&&t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:YC.map(({label:k,of:E})=>t.jsxs("div",{"aria-label":k,className:"border bg-card p-4",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:k}),t.jsx("dd",{className:"mt-3 font-mono text-display",children:QC(h,E)})]},k))}),t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:[x," of ",h.length," agent histories read. Counts show active drafts; drafts that wait for your OK are counted under review. + means a minimum from incomplete data; — means not reported.",b?" Last-read totals include saved histories that may have changed; they are not current minimums.":u&&!c?` Updated ${vt(u)}.`:"",c?" Loading learning…":""]}),s.length?t.jsx("section",{"aria-label":"Agents in Dojo",className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:s.map(k=>t.jsx(j6,{row:k,server:n},k.agent.agent_id))}):t.jsxs("div",{className:"border px-6 py-10 text-center",children:[t.jsx("h3",{className:"font-semibold",children:"No agents yet"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Create an agent, then open its Learning tab to let its runs build on what they learn."}),t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",href:"#/agents/new",children:"Build an agent"}),t.jsx("span",{className:"mx-3 text-muted-foreground",children:"·"}),t.jsx("a",{className:"text-lead text-primary-text underline underline-offset-4",href:"#/agents",children:"Import existing agents"})]}),h.length>0&&t.jsxs("section",{className:"overflow-hidden border","aria-label":"Recent learning changes",children:[t.jsxs("header",{className:"border-b px-5 py-4",children:[t.jsx("h3",{className:"text-lead font-semibold",children:"Recent learning changes"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Latest reported changes from the histories read above. Each agent's Learning tab has its full history and run outcomes."})]}),j.length?t.jsx("ul",{className:"divide-y",children:j.map(({agent:k,change:E})=>t.jsx("li",{children:t.jsxs("a",{href:"run"in E.by?`#/runs/${encodeURIComponent(E.by.run)}`:VC(k),className:"flex items-start gap-3 px-5 py-4 hover:bg-accent",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-lead",children:E.reason||"Learning updated"}),t.jsxs("span",{className:"mt-1 block text-small text-muted-foreground",children:[k.definition.name||k.agent_id," · ","run"in E.by?"From a run":"Edited by you"," · ",vt(E.at)]})]}),t.jsx(pr,{className:"mt-1 size-3.5 shrink-0","aria-hidden":!0})]})},`${k.agent_id}:${E.commit}`))}):t.jsx("p",{className:"px-5 py-7 text-lead text-muted-foreground",children:c?"Loading learning changes…":x<h.length?"No changes in the histories available so far.":"No saved learning changes yet."})]})]})]})]})]})}function j6({row:e,server:n}){const{agent:s,view:r,error:o}=e,i=s.kind==="agentic",c=Od(s.definition.learning);return t.jsxs("article",{className:"flex min-w-0 flex-col border bg-card p-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-lead font-semibold",children:s.definition.name||s.agent_id}),t.jsx(Ne,{tone:i&&c&&n==="on"?"success":"plain",children:i?n==="off"&&c?"Paused by server":c?"Learning on":"Learning off":"Workflow"})]}),i?t.jsxs(t.Fragment,{children:[o&&t.jsxs("div",{role:"alert",className:"mt-4 text-small text-destructive-text",children:[t.jsx("p",{children:e.unavailable?"Learning unavailable for this agent.":o.title}),t.jsxs("p",{className:"mt-1",children:[o.why," ",o.said]})]}),r?t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"mt-5 grid grid-cols-2 gap-x-4 gap-y-3",children:YC.map(({label:d,of:u})=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:d}),t.jsx("dd",{className:"mt-1 font-mono text-lead",children:QC([e],u)})]},d))}),e.stale&&t.jsx("p",{role:"status",className:"mt-3 text-small text-warning-text",children:"Showing the last read. Refresh to update this history."}),t.jsxs("p",{className:"mt-4 text-small text-muted-foreground",children:[Ex(r.counts.merged)," runs kept learning · ",Ex(Object.values(r.counts.dropped).reduce((d,u)=>d+u,0))," kept nothing"]})]}):!o&&t.jsx("p",{role:"status",className:"mt-4 text-lead text-muted-foreground",children:"Loading learning…"})]}):t.jsx("p",{className:"mt-4 text-lead text-muted-foreground",children:"Workflow runs do not learn. Enable learning on an agentic agent."}),t.jsxs("a",{className:"mt-5 inline-flex items-center gap-2 self-start text-small font-semibold text-primary-text hover:underline hover:underline-offset-4",href:i?VC(s):Cn(s.agent_id),children:[i?"Open learning":"View agent",t.jsx(pr,{className:"size-3.5","aria-hidden":!0})]})]})}const k6=140,N6=32,S6=40,C6=60;function Cb({value:e,name:n,note:s,blurb:r,description:o,tag:i,why:c,alert:d,on:u,disabled:f,warn:g,onToggle:y}){const[v,h]=p.useState(!1),x=p.useRef(null),b=p.useRef(null),j=p.useRef(null),k=p.useRef(null),E=kf(x,"width",v,n),N=kf(b,"height",v,o),S=kf(j,"width",v,i),$=kf(k,"width",v,d),_=E??n.length>N6,O=!!o&&(N??o.length>k6),M=!!i&&(S??i.length>S6),P=!!d&&($??d.length>C6),A=!!c&&(c!==i||M),R=!!o&&(!!r||O)||A||P||_,L=(U,Y)=>!v&&U&&Y?U:void 0,W=U=>{U.preventDefault(),U.stopPropagation(),h(Y=>!Y)};return t.jsxs("label",{"data-tool-card":e,className:te("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",v?"min-h-36":"h-36 overflow-hidden",u&&"border-foreground",g&&"border-warning/60",f?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("input",{type:"checkbox",value:e,checked:u,disabled:f,onChange:y,className:"shrink-0 accent-primary"}),t.jsx("span",{ref:x,title:L(n,_),className:te("min-w-0",v?"[overflow-wrap:anywhere]":"truncate"),children:n}),s&&t.jsx("span",{className:"shrink-0 font-sans text-label text-muted-foreground",children:s})]}),r?t.jsx("span",{"data-line":!0,className:"mt-1 truncate font-sans text-small text-muted-foreground",children:r}):o&&!v?t.jsx("span",{ref:b,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:L(o,O),children:o}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:L(c,A),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:i}),d&&!v&&t.jsx("span",{ref:k,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:L(d,P),children:d}),v&&t.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[o&&t.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:o}),c&&c!==o&&t.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),d&&t.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:d})]}),R&&t.jsx("button",{type:"button",onClick:W,"aria-expanded":v,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:v?"Less":"More"})]})}function kf(e,n,s,r){const[o,i]=p.useState(null);return p.useLayoutEffect(()=>{const c=e.current;if(s||!c)return;const d=()=>{(n==="width"?c.clientWidth>0:c.clientHeight>0)&&i(n==="width"?c.scrollWidth>c.clientWidth+1:c.scrollHeight>c.clientHeight+1)};d();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return u==null||u.observe(c),()=>u==null?void 0:u.disconnect()},[e,n,s,r]),o}function E6({servers:e,tools:n,harness:s,harnesses:r,onChange:o,onRetry:i}){const c=h=>o(n.includes(h)?n.filter(x=>x!==h):[...n,h]),d=n.filter(h=>Zo(h)),u=!r||r.includes(s),f=(h,x,b,j,k,E)=>{const N=n.includes(h),S=(!u||!!k)&&!N,$=j??k??(N&&!u?`Won't run on ${s}.`:void 0);return t.jsx("li",{className:"min-w-0",children:t.jsx(Cb,{value:h,name:x,note:E,description:b,alert:$,on:N,disabled:S,warn:!!j,onToggle:()=>c(h)})},h)},g=h=>t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:h}),y=!u&&t.jsxs("p",{className:"text-small text-warning-text",children:[s," doesn't run MCP tools on this server",r!=null&&r.length?`: ${r.join(" and ")} do`:"","."]});if(e==="failed")return t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",i&&t.jsx(B,{type:"button",onClick:i,size:"xs",className:"ml-1",children:"Retry"})]}),d.length>0&&g(d.map(h=>f(h,h,"Can't check right now whether its server still lists it.")))]});if(!e)return d.length?t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const v=wz(n,e);return!e.length&&!v.length?t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"No MCP server is saved: add one in Settings → MCP servers to grant its tools."}):t.jsxs("div",{className:"mt-4 space-y-4",children:[y,e.map(h=>t.jsxs("section",{"aria-label":`MCP server ${h.name}`,children:[t.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[h.name," · MCP server"]}),g(h.tools.map(x=>{var b;return f($C(h.name,x.name),x.name,[x.title,x.description].filter(Boolean).join(": ")||void 0,void 0,yz(x,s)??(x.permission==="deny"?Sb:void 0),(b=h.not_metered)!=null&&b.includes(x.name)?"not metered":void 0)}))]},h.name)),v.length>0&&t.jsxs("section",{"aria-label":"MCP grants that can't run",children:[t.jsx("p",{className:"caps mb-2 text-label font-semibold text-warning-text",children:"Granted, but not on a saved server"}),g(v.map(h=>f(h.grant,h.grant,void 0,h.why)))]})]})}const $6="[a-z][a-z0-9-]{0,31}",JC="[A-Za-z0-9_-]{1,64}",_6="[a-z0-9][a-z0-9.-]{0,63}",T6="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",R6=`[a-z][a-z0-9_-]{0,63}(?:\\.${JC})?`,A6="mcp:",O6="monid:",L0="*",M6=new RegExp(`^mcp:(${$6})/(\\*|${JC})$`),L6=new RegExp(`^monid:(${_6})/(\\*|${T6})$`),P6=new RegExp(`^${R6}$`);function I6(e){if(kl(e)){const s=L6.exec(e);return s?s[2]===L0?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!D6(e))return P6.test(e)?{kind:"plain",name:e}:void 0;const n=M6.exec(e);if(n)return n[2]===L0?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const kl=e=>e.startsWith(O6),z6=e=>`${e} is not a monid endpoint's name: monid:<provider>/<endpoint> or monid:<provider>/*, the provider's slug (lowercase letters, digits, . and -) and the endpoint's path without its first / (letters, digits and -._:{}/), as monid lists them.`,D6=e=>e.startsWith(A6);function XC(e){const n=I6(e);return(n==null?void 0:n.kind)==="monid"?{provider:n.provider,endpoint:n.endpoint}:(n==null?void 0:n.kind)==="monid-provider"?{provider:n.provider,endpoint:null}:void 0}const F6=e=>XC(e)?void 0:z6(e);function U6(e){const n=e.trim();return!n||kl(n)?n:`monid:${n}`}function ZC(e){return new Map(e.flatMap((n,s)=>kl(n)?[[`definition.tools[${s}]`,n]]:[]))}function W6(e,n){const s=ZC(n),r=[],o=[];for(const i of e){const c=s.get(i.field);c?r.push({grant:c,warning:i}):o.push(i)}return{monid:r,rest:o}}const H6=e=>{const n=XC(e);return n?n.endpoint===null?`Every endpoint of ${n.provider} that monid prices per call, as monid lists them when the agent is saved.`:`${n.provider}'s /${n.endpoint}, priced and pinned when the agent is saved.`:"Not a monid endpoint's name: the save refuses it. Untick it."};function B6({tools:e,listed:n=[],notes:s=[],refused:r=[],onChange:o}){const[i,c]=p.useState(""),[d,u]=p.useState(void 0),f=[...new Set([...n,...e].filter(kl))],g=v=>o(e.includes(v)?e.filter(h=>h!==v):[...e,v]),y=()=>{const v=U6(i);if(!v)return;const h=F6(v);u(h),!h&&(c(""),e.includes(v)||o([...e,v]))};return t.jsxs("section",{"aria-label":"monid endpoints",className:"mt-4 space-y-2",children:[t.jsx("p",{className:"caps text-label font-semibold text-muted-foreground",children:"monid · paid endpoints"}),f.length>0&&t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:f.map(v=>{const h=r.filter(x=>x.grant===v);return t.jsx("li",{className:"min-w-0",children:t.jsx(Cb,{value:v,name:v,description:H6(v),alert:h.length?"The save was refused here: see below.":void 0,warn:h.length>0,on:e.includes(v),disabled:!1,onToggle:()=>g(v)})},v)})}),t.jsxs("form",{className:"flex flex-wrap items-start gap-2",onSubmit:v=>{v.preventDefault(),y()},children:[t.jsx(De,{"aria-label":"monid grant",value:i,onChange:v=>{c(v.target.value),u(void 0)},"aria-invalid":d?!0:void 0,placeholder:"monid:<provider>/<endpoint> or monid:<provider>/*",className:"min-w-0 flex-[1_1_18rem]",spellCheck:!1,autoCapitalize:"off",autoComplete:"off"}),t.jsxs(B,{type:"submit",size:"sm",className:"h-control-md",disabled:!i.trim(),children:[t.jsx(Rm,{"aria-hidden":!0})," Grant"]})]}),d&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:d}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A grant is priced and pinned when the agent is saved, from what monid lists then. monid's key is set in Settings → Tool keys."}),r.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-destructive-text",role:"alert","aria-label":"monid grants refused",children:r.map((v,h)=>t.jsx("li",{children:v.message},`${v.grant}:${h}`))}),s.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-warning-text",role:"status","aria-label":"monid save warnings",children:s.map((v,h)=>t.jsx("li",{children:v.message},`${v.grant}:${h}`))})]})}const q6=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),G6=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function K6(e,n){var o;if(e.kind==="none")return{kind:"none"};const r=((n==null?void 0:n.kind)===e.kind&&e.providers.some(i=>i.ready&&i.id===n.provider)?n.provider:void 0)??((o=e.providers.find(i=>i.ready))==null?void 0:o.id);return r?{kind:e.kind,provider:r}:{kind:e.kind}}const V6=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},Eb="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",$b=new Set(["sandbox","desktop","phone"]),Y6=e=>e.charAt(0).toUpperCase()+e.slice(1);function Q6({kinds:e,value:n,onChange:s,error:r,warning:o}){const i=e.find(c=>c.kind===n.kind);return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Kind"}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-5",role:"radiogroup","aria-label":"Kind",children:e.map(c=>{const d=q6(c),u=d?void 0:G6(c),f=c.providers.filter(g=>g.ready).map(g=>g.name).join(", ");return t.jsxs("div",{"data-kind":c.kind,className:te("border px-4 py-3",n.kind===c.kind?"border-foreground":"border-border",!d&&"opacity-60"),children:[t.jsxs("label",{className:te("flex items-start gap-3",d?"cursor-pointer":"cursor-not-allowed"),children:[t.jsx("input",{type:"radio",name:"computer-kind",value:c.kind,checked:n.kind===c.kind,disabled:!d&&n.kind!==c.kind,onChange:()=>s(K6(c,n)),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-lead font-semibold",children:Y6(c.kind)}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:d?c.kind==="none"?"The run's folder only":f:"Not available here"})]})]}),u&&t.jsxs("p",{className:"mt-2 break-words text-small text-muted-foreground",children:[u," ",t.jsx("a",{href:"#/settings/computers",className:"underline underline-offset-2 hover:text-foreground",children:"Computers settings"})]})]},c.kind)})}),i&&i.kind!=="none"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-2 mt-5 caps text-small font-semibold",children:"Provider"}),t.jsx("ul",{className:"border",role:"radiogroup","aria-label":"Provider",children:i.providers.map(c=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:te("flex items-start gap-3 px-4 py-2.5",c.ready?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"computer-provider",value:c.id,checked:n.provider===c.id,disabled:!c.ready&&n.provider!==c.id,onChange:()=>s({kind:i.kind,provider:c.id}),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-body font-semibold",children:c.name}),c.metered&&t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Metered"})]}),c.metered&&$b.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:Eb}),!c.ready&&c.why&&t.jsx("span",{className:"mt-0.5 block text-small",children:c.why})]})]})},c.id))})]}),i&&i.tools.length>0&&t.jsxs("p",{className:"mt-4 border bg-muted/40 px-4 py-2.5 text-small","aria-label":"Tools this computer adds",children:["This computer adds these tools: ",t.jsx("span",{className:"font-mono",children:i.tools.join(", ")})]}),r&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:r}),o&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:o})]})}function J6({value:e,saved:n,places:s,tools:r,picked:o,onChange:i,error:c,warning:d}){var S;const u=e??Ad(n),f=(u??Qv(!1,o,s)).mode,g=(S=s.boxes.find($=>$.available))==null?void 0:S.id,y=(u==null?void 0:u.mode)==="sandbox"?u.box:g,v=!g&&f!=="sandbox",h=new Set(r.filter($=>$.sandbox_only).map($=>$.name)),[x,b]=p.useState([]),j=()=>{const $=o.filter(_=>h.has(_));b($),i({place:{mode:"runner"},...$.length?{tools:o.filter(_=>!h.has(_))}:{}})},k=$=>{b([]),$&&i({place:{mode:"sandbox",box:$}})},E=$=>$.map(_=>_.charAt(0).toUpperCase()+_.slice(1)).join(" and "),N=($,_,O,M,P=!1)=>t.jsxs("label",{className:te("flex items-start gap-3 border px-4 py-3",f===$?"border-foreground":"border-border",P?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsx("input",{type:"radio",name:"place",value:$,checked:f===$,disabled:P,onChange:M,className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block text-lead font-semibold",children:_}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:O})]})]});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[N("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),N("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>k(y),v)]}),v&&t.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[t.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),t.jsx("ul",{className:"mt-1",children:s.boxes.map($=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono",children:$.id}),$.reason?`: ${$.reason}`:""]},$.id))})]}),f==="sandbox"&&t.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map($=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:te("flex items-start gap-3 px-4 py-2.5",$.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"box",value:$.id,checked:y===$.id,disabled:!$.available&&y!==$.id,onChange:()=>k($.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-mono text-body",children:$.id}),!$.available&&$.reason&&t.jsx("span",{className:"mt-0.5 block text-small",children:$.reason})]})]})},$.id))}),f==="runner"&&x.length>0&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[E(x)," ",x.length===1?"runs":"run"," only in a sandbox, so ",x.length===1?"it's":"they're"," turned off for this agent."]}),c&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:d})]})}function eE(e,n,s=n.map(r=>r.name)){return[...new Set([...s.filter(o=>e.some(i=>i.name===o)||n.some(i=>i.name===o)),...n.map(o=>o.name),...e.map(o=>o.name)])].map(o=>{const i=e.find(d=>d.name===o),c=n.find(d=>d.name===o);return{name:o,...i?{choice:i}:{},...c?{gate:c}:{}}})}function $x({setting:e,label:n="Pinned",also:s=!1}){return e!=null&&e.pin_broken?t.jsx("p",{className:"max-w-[640px] text-small text-warning-text",role:"note",children:u6}):e!=null&&e.pin?t.jsxs("p",{className:"max-w-[640px] text-small text-muted-foreground",role:"note",children:[t.jsxs("span",{className:"text-foreground",children:[n,":"]})," ",c6(e.pin),". ",d6,s?" This server pins it too; both hold.":""]}):null}const P0={read:["info","Read-only, its server says: under Allow reads it runs without asking."],write:["warning","Not read-only, and not marked destructive by its server: it keeps its permission."],destructive:["error","May delete or overwrite, its server says: allowing it takes a second click."]},X6=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(Ne,{tone:P0[e][0],title:P0[e][1],children:e})}),Z6="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function _b({label:e,rows:n,settings:s,fallbackOf:r,permissionFallbackOf:o=E=>E.default_permission,resolvesOf:i,issues:c,busy:d=!1,refused:u=()=>!1,locked:f=!1,unattended:g=!1,noteOf:y,labelOf:v,detailOf:h,effectOf:x,confirmAllowOf:b=()=>!1,fallbackWordOf:j,onEdit:k}){const[E,N]=p.useState(null),S=p.useRef(null),$=p.useRef(null);p.useEffect(()=>{var W,U;if(E!==null||d||S.current===null)return;const L=`${S.current} permission`;S.current=null,(U=[...((W=$.current)==null?void 0:W.querySelectorAll("button[aria-label]"))??[]].find(Y=>Y.getAttribute("aria-label")===L))==null||U.focus()},[E,d]);const _=L=>{S.current=L,N(null)},O=n.some(L=>L.choice),M=n.some(L=>L.gate),P=n.some(L=>{var W;return((W=L.gate)==null?void 0:W.ask_needs)==="password"}),A=["Tool",...M?["Permission"]:[],...O?["Provider","Resolves to"]:[]],R=t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return t.jsxs(t.Fragment,{children:[P&&t.jsx("p",{className:"mb-2 text-small text-warning-text",children:Z6}),t.jsx("div",{ref:$,className:"relative overflow-x-auto",children:t.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[A.map(L=>t.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:L},L)),t.jsx("th",{children:t.jsx("span",{className:"sr-only",children:"Reset"})})]})}),t.jsx("tbody",{children:n.map(({name:L,choice:W,gate:U})=>{var le,me,Ke;const Y=W?r(W):"",D=(le=s[L])==null?void 0:le.provider,G=W!==void 0&&D!==void 0&&D!==Y,F=G?D:Y,q=be=>k(ge=>r6(ge,L,be,Y)),H=U?o(U):"allow",I=(me=s[L])==null?void 0:me.permission,V=U!==void 0&&I!==void 0&&I!==H,J=V?I:H,X=U!==void 0&&u(L,J),re=X&&f,ae=re?"deny":J,ye=be=>k(ge=>o6(ge,L,be,H)),he=x==null?void 0:x(L),we=(j==null?void 0:j(L))??"default",ze=h==null?void 0:h(L);return t.jsxs(p.Fragment,{children:[t.jsxs("tr",{"data-tool":L,"data-set":G||V?"":void 0,className:"border-b align-top last:border-b-0",children:[t.jsxs("td",{className:"px-3 py-2.5 font-mono text-body",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[(v==null?void 0:v(L))??L,he&&t.jsx(X6,{effect:he})]}),ze?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:ze}):null]}),M&&t.jsx("td",{className:"px-3 py-2",children:U?t.jsxs(t.Fragment,{children:[t.jsx(Mt,{small:!0,label:`${L} permission`,value:ae,disabled:d||re,onChange:be=>{const ge=be;ge==="allow"&&ge!==ae&&b(L)?N(L):ye(ge)},className:te("w-48",V&&"border-primary text-primary"),options:U.permissions.map(be=>({value:be,label:`${be}${be===H?` (${we})`:""}`,...be==="ask"&&U.ask_needs==="password"&&!g?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),V&&!re&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",H,we==="default"?"":` (${we})`]}),X&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:Sb}),ae==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:e6}),ae==="ask"&&g&&!X&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),ae==="ask"&&U.ask_needs==="password"&&!g&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Each call is refused: no one can approve it here."})]}):R}),O&&t.jsx("td",{className:"px-3 py-2",children:W?t.jsxs(t.Fragment,{children:[t.jsx(Mt,{small:!0,label:`${L} provider`,value:F,disabled:d,onChange:be=>q(be),className:te("w-96 max-w-full",G&&"border-primary text-primary"),options:W.providers.map(be=>({value:be,label:`${um(be,L)}${be===Y?" (default)":""}`}))}),O0(F,L)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:O0(F,L)}),G&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",um(Y,L)]})]}):R}),O&&t.jsx("td",{className:"px-3 py-2.5",children:W?i(W,F):R}),t.jsx("td",{className:"px-2 py-2 text-right",children:G&&t.jsx(B,{size:"sm",variant:"ghost",disabled:d,"aria-label":`Reset ${L} to its default`,onClick:()=>q(void 0),children:"Reset"})})]}),E===L&&t.jsx("tr",{children:t.jsx("td",{colSpan:A.length+1,className:"px-3 pb-2.5",children:t.jsx(eF,{name:L,keep:ae==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||(_(L),ye("allow"))},onKeep:()=>_(L)})})}),y!=null&&y(L)?t.jsx("tr",{"data-note":L,children:t.jsx("td",{colSpan:A.length+1,className:"px-3 pb-2.5",children:y(L)})}):null,(Ke=c[L])!=null&&Ke.length?t.jsx("tr",{children:t.jsx("td",{colSpan:A.length+1,className:"px-3 pb-2.5",children:c[L].map(be=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:be},be))})}):null]},L)})})]})})]})}function eF({name:e,keep:n,busy:s,onAllow:r,onKeep:o}){const i=p.useRef(null);return p.useEffect(()=>{var c;(c=i.current)==null||c.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e} without asking?`,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),o())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive tool?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite: every call would run with no one asked."]}),t.jsx(B,{ref:i,type:"button",size:"sm",variant:"ghost",onClick:o,children:n}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",disabled:s,onClick:r,children:"Allow without asking"})]})}function _x({value:e,prefix:n,tool:s}){const r=BC(e,s);return t.jsxs("span",{className:te("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[n,r.text]})}const tF=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:QD.map(s=>{const r=n.find(o=>o.id===s&&!o.available);return r?t.jsxs("span",{title:r.reason,className:"block font-mono text-small text-muted-foreground",children:[s,": not offered here"]},s):t.jsx(_x,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function nF({agent:e,harness:n,model:s,tools:r,choices:o,gates:i=[],mcpServers:c,serverSettings:d,focus:u,callTools:f,value:g,issues:y,unattended:v=!1,onChange:h}){const x=new Set(r),b=o.filter(R=>x.has(R.name)||!R.available),j=i.some(R=>R.ask_needs==="password"),k=R=>{var L;return(L=e==null?void 0:e.tools)==null?void 0:L.find(W=>W.name===R)},E=R=>{var W;const L=Zo(R);return L?(W=c==null?void 0:c.find(U=>U.name===L.server))==null?void 0:W.tools.find(U=>U.name===L.tool):void 0},N=R=>{var W;const L=Zo(R);return L?(W=g[`mcp:${L.server}/*`])==null?void 0:W.permission:void 0},S=f?f.flatMap(R=>i.filter(L=>L.name===R)):[...new Set(r)].flatMap(R=>{var U;const L=i.find(Y=>Y.name===R);if(L)return[L];const W=k(R)??E(R);return!((U=W==null?void 0:W.permissions)!=null&&U.length)||!W.default_permission?[]:[{name:R,permission:W.permission??W.default_permission,default_permission:W.default_permission,permissions:W.permissions,...j&&W.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),$=eE(b,S,[...i.map(R=>R.name),...o.map(R=>R.name)]),_=p.useRef(null);if(p.useEffect(()=>{var W,U;if(!u)return;const R=`${u} permission`,L=[...((W=_.current)==null?void 0:W.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(Y=>Y.getAttribute("aria-label")===R);(U=L==null?void 0:L.scrollIntoView)==null||U.call(L,{block:"center"}),L==null||L.focus()},[]),!$.length)return null;const O=(e==null?void 0:e.definition.tool_settings)??{},M=v!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:P,rest:A}=GC(y,"definition.tool_settings",$.map(R=>R.name));return t.jsxs("section",{"aria-label":"Tool settings",ref:_,children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),t.jsxs("p",{className:"-mt-1 mb-2 text-small text-muted-foreground",children:["Each of these tools takes this server's setting (its default here) unless it is changed here. ",f?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":v?"Never ask is on: a tool on ask runs without waiting for you. A tool set to deny still holds.":"A tool on ask makes the run wait for your approval at each call."]}),t.jsx(_b,{label:"This agent's tool settings",unattended:v,rows:$,settings:g,fallbackOf:R=>R.provider,issues:P,onEdit:R=>h(R(g)),effectOf:R=>{var L;return(L=E(R))==null?void 0:L.effect},confirmAllowOf:R=>{var L;return((L=E(R))==null?void 0:L.effect)==="destructive"},noteOf:R=>{const L=g[R],W=d==null?void 0:d[R],U=!!(L!=null&&L.pin||L!=null&&L.pin_broken);return!U&&!(W!=null&&W.pin)&&!(W!=null&&W.pin_broken)?null:t.jsxs(t.Fragment,{children:[U&&t.jsx($x,{setting:L,label:"Pinned for this agent",also:!!(W!=null&&W.pin)}),(!U||(W==null?void 0:W.pin_broken))&&t.jsx($x,{setting:W,label:"Pinned on this server"})]})},refused:R=>WC(R,i,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:R=>{var L;return N(R.name)??((L=k(R.name))==null?void 0:L.default_permission)??R.permission},resolvesOf:R=>{var D,G,F,q,H,I;const L=(((D=g[R.name])==null?void 0:D.provider)??null)!==(((G=O[R.name])==null?void 0:G.provider)??null)||(((F=g[R.name])==null?void 0:F.permission)??null)!==(((q=O[R.name])==null?void 0:q.permission)??null)||M,W=(H=e==null?void 0:e.tools)==null?void 0:H.find(V=>V.name===R.name),U=W&&W.provider===(((I=g[R.name])==null?void 0:I.provider)??R.provider)?W.resolved:void 0,Y=(s??"")===((e==null?void 0:e.definition.model)??"");return!L&&n===((e==null?void 0:e.definition.harness)??"pi")&&Y&&U?t.jsx(_x,{value:U,prefix:`${n}: `,tool:R.name}):!L&&!O[R.name]&&!s?t.jsx(_x,{value:R.resolves[n],prefix:`${n}: `,tool:R.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),A.map(R=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:R},R))]})}const Nf=20,sF=400;function rF(e,n,s,r,o){const[i,c]=p.useState(null),[d,u]=p.useState(0),f=(r??[]).join(",");p.useEffect(()=>{if(!o||!s||i==="unsupported")return;const y=new AbortController,v=setTimeout(()=>{o({workflow:n,...r?{tools:r}:{}},y.signal).then(h=>{y.signal.aborted||c({text:e,check:h})},h=>{y.signal.aborted||((h==null?void 0:h.status)===404||(h==null?void 0:h.status)===405?c("unsupported"):c({text:e,failed:(h==null?void 0:h.message)||`the server answered ${(h==null?void 0:h.status)??"nothing"}`}))})},sF);return()=>{clearTimeout(v),y.abort()}},[e,s,f,o,d]);const g=()=>{c(null),u(y=>y+1)};return i==="unsupported"||!o?{mode:"lint",retry:g}:i&&i.text===e?"failed"in i?{mode:"failed",failed:i.failed,retry:g}:{mode:"server",check:i.check,retry:g}:{mode:"pending",retry:g}}function I0({text:e,onText:n,base:s,baseLabel:r,serverIssues:o,readOnly:i=!1,validate:c,tools:d}){var Y;const u=p.useRef(null),f=p.useRef(null),[g,y]=p.useState(0),v=p.useMemo(()=>rP(e),[e]),h=p.useRef(null);v.ok&&(h.current={value:v.value,spans:v.spans});const x=(Y=h.current)==null?void 0:Y.value,b=p.useMemo(()=>vl(x),[x]),j=p.useMemo(()=>s===void 0?null:vl(s),[s]),k=p.useMemo(()=>j?P2(j,b):null,[j,b]),E=rF(e,v.ok?v.value:void 0,v.ok,d,i?void 0:c),N=p.useMemo(()=>v.ok&&!i?lP(v.value):[],[v,i]),S=p.useMemo(()=>E.mode!=="server"?N:[...E.check.issues.map(D=>({path:D.path,message:D.message,severity:"error"})),...E.check.warnings.map(D=>typeof D=="string"?{path:"",message:D,severity:"warning"}:{path:D.path??"",message:D.message,severity:"warning"})],[E.mode,E.mode==="server"?E.check:null,N]),$=v.ok?cP(v.spans,b.nodes.map(D=>D.path),g):null,_=p.useMemo(()=>({meta:Rd(x,b),diff:k?{added:k.added.map(D=>D.path),edited:[...k.changed,...k.rewritten].map(D=>D.next),moved:k.moved.map(D=>D.next),removed:k.removed.map(({label:D,kind:G})=>({label:D,kind:G}))}:void 0,selected:$?{path:$}:null}),[x,b,k,$]),O=e.split(`
642
+ `).length,M=D=>oP(e,D),P=[];v.ok||P.push({...M(v.error.offset),message:`JSON: ${v.error.message}`,severity:"error",offset:v.error.offset});for(const D of S){const G=v.ok?Qk(v.spans,D.path):void 0,F=(G==null?void 0:G.start)??0;P.push({...M(F),message:D.message,severity:D.severity,offset:F,path:D.path})}for(const D of[...o??[]].reverse()){const G=D.path&&v.ok?Qk(v.spans,D.path):void 0;P.unshift({...G?M(G.start):{line:0,col:0},message:`Server: ${D.message}`,severity:"error",offset:(G==null?void 0:G.start)??-1})}const A=new Map;for(const D of P)D.line&&A.get(D.line)!=="error"&&A.set(D.line,D.severity);const R=(D,G=D)=>{const F=u.current;!F||D<0||(F.focus(),F.setSelectionRange(D,G),F.scrollTop=Math.max(0,(M(D).line-4)*Nf),y(D))};p.useEffect(()=>{const D=v.ok?v.spans.get("/root"):void 0;D&&u.current&&(u.current.scrollTop=Math.max(0,(M(D.start).line-2)*Nf))},[]);const L=k?k.edges.added.length+k.edges.removed.length:0,W=k?k.added.length+k.changed.length+k.rewritten.length+k.removed.length+k.moved.length+L:0,U=P.filter(D=>D.severity==="error").length;return t.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[O," lines"]}),t.jsx("span",{className:"flex-1"}),i?t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Read-only"}):t.jsxs(t.Fragment,{children:[E.mode==="failed"&&v.ok?t.jsxs("span",{className:"font-mono text-label text-warning-text",title:E.failed,children:["server check failed, showing local checks ",t.jsx(B,{type:"button",onClick:E.retry,size:"xs",className:"ml-1",children:"Retry"})]}):E.mode!=="lint"&&v.ok&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:E.mode==="pending"?"checking...":"checked by the server"}),U?t.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[t.jsx(ul,{className:"size-3.5","aria-hidden":!0})," ",U," ",U===1?"problem":"problems"]}):t.jsx("span",{className:"caps text-label text-success-text",children:E.mode==="server"?"Valid":"Valid shape"})]})]}),t.jsxs("div",{className:"relative flex h-[560px] min-h-0 xl:h-[calc(100vh-390px)] xl:min-h-[440px]",children:[t.jsx("div",{ref:f,"aria-hidden":!0,className:"w-12 shrink-0 select-none overflow-hidden border-r bg-card py-3 text-right font-mono text-label text-muted-foreground",style:{lineHeight:`${Nf}px`},children:Array.from({length:O},(D,G)=>t.jsx("div",{className:te("pr-2",A.get(G+1)==="error"&&"bg-destructive/15 text-destructive-text",A.get(G+1)==="warning"&&"bg-warning/15 text-warning-text"),children:G+1},G))}),t.jsx(on,{bare:!0,ref:u,value:e,readOnly:i,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:D=>{i||n(D.target.value),y(D.target.selectionStart)},onSelect:D=>y(D.target.selectionStart),onScroll:D=>{f.current&&(f.current.scrollTop=D.target.scrollTop)},onKeyDown:D=>{if(D.key!=="Tab"||i)return;D.preventDefault();const G=D.currentTarget,F=G.selectionStart,q=G.selectionEnd;n(`${e.slice(0,F)} ${e.slice(q)}`),requestAnimationFrame(()=>G.setSelectionRange(F+2,F+2))},className:"flex-1 resize-none overflow-auto bg-background px-3 py-3 text-small selection:bg-primary/[0.28] selection:text-foreground focus-visible:outline focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-ring",style:{lineHeight:`${Nf}px`,tabSize:2}})]}),!i&&t.jsxs("ul",{className:"max-h-48 min-h-[44px] overflow-auto border-t font-mono text-small","aria-label":"Problems",children:[P.length===0&&t.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:E.mode==="server"?"No problems: the server's validator takes this workflow as it is.":"No problems the console can see. The server checks the workflow again when you save."}),P.map((D,G)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>R(D.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[D.severity==="error"?t.jsx(ul,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):t.jsx(Ys,{className:"mt-0.5 size-3.5 shrink-0 text-warning-text","aria-hidden":!0}),t.jsx("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",children:D.line?`L${D.line}:${D.col}`:"—"}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:D.message})]})},G))]})]}),t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:lh(kb(b))}),k&&(W?t.jsxs("span",{className:"font-mono text-label",children:[[k.added.length&&`${k.added.length} new`,k.changed.length+k.rewritten.length&&`${k.changed.length+k.rewritten.length} edited`,k.removed.length&&`${k.removed.length} removed`,k.moved.length&&`${k.moved.length} moved`,!k.moved.length&&L&&`${L} ${L===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",t.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),t.jsx("span",{className:"flex-1"}),!v.ok&&h.current&&t.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),t.jsx("div",{className:te("min-h-[360px] flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5 xl:h-[calc(100vh-330px)] xl:min-h-[480px]",!v.ok&&"opacity-60"),children:b.nodes.length?t.jsx(Fd,{graph:b,marks:_,label:"The workflow's graph",minScale:.55,onSelect:D=>{const G=v.ok?v.spans.get(`${D.path}/label`)??v.spans.get(D.path):void 0;G&&R(G.start,G.end)}}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(Ud,{})})]})]})}const Mg="custom";function tE(){const[e,n]=p.useState(!1),[s,r]=p.useState(!1);return{customPicked:e,setCustomPicked:n,freeOnly:s,setFreeOnly:r}}function nE({id:e,harness:n,model:s,onModel:r,harnesses:o,routePrefix:i,state:c,error:d,warning:u}){const{customPicked:f,setCustomPicked:g,freeOnly:y,setFreeOnly:v}=c,h=$=>$&&$.harness===n&&$.model===s?$.text:void 0,x=xb(n,o),b=x?jl(x,i):void 0,j=$z(n,o),k=f||s!==void 0&&!j.includes(s),E=_C(n,o),N=y&&E.size?j.filter($=>E.has($)||$===s):j,S=[{value:"",label:b?`Server default (${b.text})`:"Server default"},...N.map($=>({value:$,label:jl($,i).text,...E.has($)?{tag:`Free · ${Ez(E.get($).context_window)} context`}:{}})),{value:Mg,label:"Custom..."}];return t.jsxs(St,{label:"Model",id:e,optional:!0,note:b?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:b.title,children:b.text}),")."]}):_z,error:h(d),warning:h(u),children:[t.jsx(Mt,{id:e,label:"Model",className:"w-full",value:k?Mg:s??"",options:S,onChange:$=>{if($===Mg){g(!0);return}g(!1),r($||void 0)}}),k&&t.jsx(De,{id:e?`${e}-custom`:void 0,"aria-label":"Custom model",className:"mt-2",value:s??"",onChange:$=>{g(!0),r($.target.value||void 0)},placeholder:"provider/model"}),E.size>0&&t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-small text-muted-foreground",children:[t.jsx(Ed,{checked:y,onChange:v,label:"Free models only"})," Free models only (",E.size,"): $0 a request; the provider limits requests per day."]})]})}const oF="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function sE(){return t.jsxs(t.Fragment,{children:["A run on Sonnet needs about $0.10 to take a few steps; under that it pauses before its next step (",t.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:oF,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let Ji=null;function Sf(e,n){return Ji?Ji({to:e,replay:n}):!1}function rE(e){const[n,s]=p.useState(null),r=p.useRef(location.hash);return p.useEffect(()=>{if(!e)return;const o=c=>c.to===r.current?!1:(s(c),!0);Ji=o;const i=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",i),()=>{Ji===o&&(Ji=null),window.removeEventListener("beforeunload",i)}},[e]),{asking:n!==null,stay:()=>s(null),leave:()=>{var o;if(n!==null){if(s(null),n.to===null){(o=n.replay)==null||o.call(n);return}if(Ji=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const oE="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",z0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function aF(e,n){if((e==null?void 0:e.kind)!=="invalid")return null;const s=Object.entries(e.fields).filter(([r])=>r==="definition.workflow"||r.startsWith("definition.workflow/")).map(([r,o])=>({path:r.slice(19),message:o}));return s.length?s:n?[{path:"",message:e.message}]:null}function iF(e){var s;const n=(s=/^definition\.([a-z_]+)/.exec(e))==null?void 0:s[1];if(n){if(["name","description","instructions"].includes(n))return"context";if(["tools","tool_settings","approvals","skills"].includes(n))return"tools";if(["harness","thinking","model","max_cost_usd","learning"].includes(n))return"settings";if(["place","computer"].includes(n))return"computer";if(n==="workflow")return"workflow"}}const lF=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:ai},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:li},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:ii},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Gg},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:c1},{id:"history",label:"History",note:"Revisions and the current one",Icon:bd}];function cF({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:o,onArchive:i,onReload:c,onBack:d,step:u,problem:f=null,notice:g,draft:y,validate:v,providerChoices:h=[],permissionGates:x=[],focusTool:b,mcpServers:j=null,serverToolSettings:k,onRetryMcp:E}){var rt,Ft,jn,Rt,Un,ys,ws;const N=!e,S=e==null?void 0:e.definition,$=os(S),_=!!(S!=null&&S.native)||!!$,[O,M]=p.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),P=N?Cg(s.places):void 0,[A,R]=p.useState({name:(S==null?void 0:S.name)??"",description:(S==null?void 0:S.description)??"",instructions:(S==null?void 0:S.instructions)??(N?qP:""),harness:(S==null?void 0:S.harness)??"pi",thinking:S==null?void 0:S.thinking,model:S==null?void 0:S.model,tools:N?Eg("pi",s.tools,P):(S==null?void 0:S.tools)??[],maxCostText:typeof(S==null?void 0:S.max_cost_usd)=="number"&&S.max_cost_usd>0?String(S.max_cost_usd):"",...P?{place:P}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:y??JSON.stringify(S.workflow,null,2)}:{}}),L=tE(),W=p.useRef(A);W.current=A;const[U,Y]=p.useState(A),D=Z=>{const{maxCostText:Ie,workflowText:ht,...Ct}=Z,Ht=s0(Ie),xn=z0(ht),tn={...Ct,maxCost:Ht.ok?Ht.value??0:Ie,...ht!==void 0?{workflowSent:xn!==void 0?xn:ht}:{}},vn=e?{...Md(e,tn,"").definition}:{...tn};return delete vn.version,vn.tool_settings&&!Object.keys(vn.tool_settings).length&&delete vn.tool_settings,{...vn,tools:[...vn.tools??[]].sort(),approvals:Z.approvals??(S==null?void 0:S.approvals)??"ask"}},G=!al(D(A),D(U)),[F,q]=p.useState([]),[H,I]=p.useState(!1),V=s.tools.map(Z=>`${Z.name}:${Z.available}:${(Z.harnesses??[]).join("+")}`).join(","),J=JSON.stringify(Cg(s.places)??null);p.useEffect(()=>{if(!N)return;const Z=Ie=>{const ht=Ie.place??Cg(s.places);return{...Ie,...ht?{place:ht}:{},...H?{}:{tools:Eg(Ie.harness??"pi",s.tools,ht)}}};R(Z),Y(Z)},[V,J]);const[X,re]=p.useState(""),[ae,ye]=p.useState(()=>((S==null?void 0:S.tools)??[]).filter(kl)),[he,we]=p.useState(!1),[ze,le]=p.useState(!1),[me,Ke]=p.useState(f),[be,ge]=p.useState(()=>({harness:A.harness??"pi",model:A.model})),[Je,tt]=p.useState(null),ft=Z=>{tt(null),M(Z)},ve=p.useRef(null),Ee=ZC(ve.current??A.tools??[]),Q=(me==null?void 0:me.kind)==="invalid"?Object.entries(me.fields).flatMap(([Z,Ie])=>{const ht=Ee.get(Z);return ht?[{grant:ht,message:Ie}]:[]}):[],Me=Z=>(me==null?void 0:me.kind)==="invalid"&&Object.entries(me.fields).filter(([Ie])=>!Ee.has(Ie)&&(Ie===`definition.${Z}`||Ie.startsWith(`definition.${Z}[`)||Ie.startsWith(`definition.${Z}.`))).map(([,Ie])=>Ie).join(" ")||void 0,{monid:pe,rest:ne}=W6((e==null?void 0:e.warnings)??[],(S==null?void 0:S.tools)??[]),Ae=Z=>yx(ne,Z).map(Ie=>Ie.message).join(" ")||void 0,Pe=Z=>{N&&ze||R(Ie=>({...Ie,...Z}))},bt=p.useRef(null);p.useEffect(()=>{var Z;((me==null?void 0:me.kind)==="invalid"||(me==null?void 0:me.kind)==="other")&&((Z=bt.current)==null||Z.focus())},[me]);const ot=(e==null?void 0:e.kind)==="workflow",mt=N&&vx(A.harness),Re=[...(rt=A.name)!=null&&rt.trim()?[]:["Give the agent a name to create it."],...!ot&&!mt&&!((Ft=A.instructions)!=null&&Ft.trim())?["Write its instructions to create it."]:[]],lt=A.approvals??(S==null?void 0:S.approvals)??"ask",$t=XP(s.harnesses,N?{available:!!s.decisionProvider}:void 0),nt={mcpHarnesses:s.mcpHarnesses,workflow:ot},fe=Z=>{if(Z.mode==="sandbox")return;const Ie=new Set(s.tools.filter(ht=>ht.sandbox_only).map(ht=>ht.name));q(ht=>ht.filter(Ct=>!Ie.has(Ct)))},st=Z=>{if(N&&!H){Pe({harness:Z,tools:Eg(Z,s.tools,A.place)}),q([]);return}const Ie=VP(Z,A.tools??[],F,s.tools,nt);Pe({harness:Z,tools:Ie.tools}),q(Ie.held)},Qe=n.find(Z=>Z.revision===(e==null?void 0:e.revision))??n.find(Z=>Z.current),ct=lF.filter(Z=>!(N&&Z.id==="history")&&(Z.id!=="workflow"||ot)&&!(mt&&Z.id==="tools")&&(Z.id!=="computer"||!ot&&!mt&&!!(s.computers||s.places))),gt=ct.some(Z=>Z.id===O)?O:ct[0].id,Et=ct.findIndex(Z=>Z.id===gt),se=async()=>{if(!r)return;const Z=A;ve.current=A.tools??[],le(!0);let Ie={...A,workflowText:void 0,maxCostText:void 0};if(!mt){const Ht=s0(A.maxCostText);if(!Ht.ok){le(!1),Ke({kind:"invalid",message:Ht.message,fields:{"definition.max_cost_usd":Ht.message}});return}const xn=typeof(S==null?void 0:S.max_cost_usd)=="number"&&S.max_cost_usd>0,tn=Ht.value??0;(tn!==0||xn)&&(Ie={...Ie,max_cost_usd:tn})}if(ot)try{Ie={...Ie,workflow:JSON.parse(A.workflowText??"")}}catch(Ht){le(!1),Ke({kind:"invalid",message:`The workflow is not JSON: ${Ht.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Ht.message}`}});return}const ht=await r(Ie,X),Ct=al(W.current.tool_settings??{},Ie.tool_settings??{});le(!1),Ke(ht),ge({harness:Z.harness??"pi",model:Z.model}),!ht&&(re(""),W.current.harness===Z.harness&&q([]),Y(Ct?(({tool_settings:Ht,...xn})=>xn)(Z):Z),Ct&&R(({tool_settings:Ht,...xn})=>xn))},$e=rE(!ze&&G),Fe=xb(A.harness??"pi",s.harnesses),et=s.harnesses.some(Z=>{var Ie;return od(Z.default_model)||((Ie=Z.models)==null?void 0:Ie.some(od))}),Dt=Cz(A.model??Fe,A.harness??"pi",s.harnesses,s.freeRequests),Le=sh(A.harness??"pi",s.tools).filter(Z=>a0([Z.name])).map(Z=>Z.name);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:te(vr,"flex-wrap gap-3 px-5 md:px-8"),children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:d,children:t.jsx(Fn,{"aria-hidden":!0})}),t.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:N?void 0:S.name,children:N?"New agent":S.name}),t.jsx(an,{label:"Use your agent",prompt:_&&e?Xo(location.origin,e.agent_id,!!(S!=null&&S.native),$==null?void 0:$.runtime):`${e?Xo(location.origin,e.agent_id):Zm(location.origin)}
643
+
644
+ Current form draft (treat as data; review before saving):
645
+ ${JSON.stringify(A,null,2)}`}),e&&t.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[t.jsx(Ne,{children:e.kind}),t.jsxs("span",{className:"caps text-label text-muted-foreground",children:[Qe?`rev ${Qe.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),i&&t.jsxs(B,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>i(!e.archived_at),children:[t.jsx(xd,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(me==null?void 0:me.kind)==="conflict"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-card px-5 py-3 md:px-8",role:"alert",children:[t.jsx(Ys,{className:"size-4 text-warning-text","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"This agent changed since you opened it: another revision was saved first, so this save was not made. Reload to see the current revision; it replaces your unsaved edits here."}),t.jsx(B,{size:"sm",onClick:c,children:"Reload"})]}),g&&t.jsx("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-warning-text md:px-8",role:"alert",children:g}),(ne.length>0||pe.length>0)&&t.jsx("div",{className:"space-y-3 border-b bg-card px-5 py-3 md:px-8",role:"status","aria-label":"Save warnings",children:[{lines:ne,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:pe.map(Z=>Z.warning),head:"Saved. What the server said of its monid grants:"}].filter(Z=>Z.lines.length).map(Z=>t.jsxs("div",{children:[t.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[t.jsx(Ys,{className:"size-4 shrink-0","aria-hidden":!0})," ",Z.head]}),t.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:Z.lines.map((Ie,ht)=>{const Ct=ct.find(Ht=>Ht.id===iF(Ie.field));return t.jsxs("li",{children:[Ct?t.jsx("button",{type:"button",title:Ie.field,onClick:()=>ft(Ct.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:Ct.label}):t.jsx("span",{className:"text-muted-foreground",children:Ie.field})," ",Ie.message]},`${Ie.field}:${ht}`)})})]},Z.head))}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[t.jsx("ol",{className:te("relative flex shrink-0 gap-1 overflow-x-auto border-b p-3 md:flex-col md:gap-0 md:border-b-0 md:border-r md:p-4",gt==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:ct.map((Z,Ie)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":gt===Z.id?"step":void 0,onClick:()=>ft(Z.id),className:te("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",gt===Z.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:te("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",gt===Z.id?"border-foreground bg-foreground text-background":Ie<Et?"border-border-strong":"border-border"),children:Ie<Et?t.jsx(Cl,{className:"size-3","aria-hidden":!0}):Ie+1}),t.jsxs("span",{className:te("hidden min-w-0",gt!=="workflow"&&"md:block"),title:gt==="workflow"?Z.label:void 0,children:[t.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[t.jsx(Z.Icon,{className:"size-3.5","aria-hidden":!0})," ",Z.label]}),t.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:Z.note})]}),t.jsx("span",{className:"sr-only md:hidden",children:Z.label})]})},Z.id))}),t.jsxs("section",{className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-10",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Step ",Et+1]}),t.jsx("h2",{className:"mb-6 border-b pb-4 text-lg font-semibold",children:ct[Et].label}),t.jsxs("fieldset",{disabled:N&&ze,className:"m-0 min-w-0 border-0 p-0",children:[gt==="context"&&t.jsxs("div",{className:"grid gap-x-10 gap-y-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] xl:items-start",children:[t.jsxs("div",{className:"space-y-6",children:[t.jsx(St,{label:"Name",id:"agent-name",required:N,note:N?void 0:"Set when the agent was created; an edit keeps it.",error:Me("name"),warning:Ae("name"),children:t.jsx(De,{id:"agent-name",value:A.name,readOnly:!N,onChange:Z=>Pe({name:Z.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(St,{label:"Description",id:"agent-description",optional:!0,note:N?void 0:"Set when the agent was created; an edit keeps it.",error:Me("description"),warning:Ae("description"),children:t.jsx(De,{id:"agent-description",value:A.description,readOnly:!N,onChange:Z=>Pe({description:Z.target.value}),placeholder:N?"Short summary for the agent list":"No description"})})]}),mt?t.jsx(St,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:A.harness===Vv?"A decision agent is a workflow. It starts from a starter decision workflow: one typed question, and a person when the answer is unclear or not confident enough. Create it, then edit its nodes in the Workflow step.":"A workflow agent starts from a one-step workflow: an agent node that does what its input's task asks. Create it, then edit its nodes, or paste a workflow's JSON over it, in the Workflow step."})}):ot?t.jsx(St,{group:!0,label:"Workflow",note:"This agent is a workflow. Edit its nodes in the Workflow step: the graph redraws as you type and the server checks it.",warning:Ae("workflow"),children:t.jsxs(B,{size:"sm",onClick:()=>M("workflow"),children:[t.jsx(li,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(St,{group:he?"heading":void 0,label:"Instructions",id:he?void 0:"agent-instructions",required:!0,error:Me("instructions"),warning:Ae("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(Z=>t.jsx(B,{size:"xs",type:"button",onClick:()=>we(Z==="Preview"),className:te("caps border px-2.5 py-1 text-label",Z==="Preview"===he?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:Z},Z))}),children:[he?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:Ko(A.instructions||"")}}):t.jsx(on,{id:"agent-instructions",value:A.instructions,onChange:Z=>Pe({instructions:Z.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:te(dF,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(A.instructions??"").length," characters"]})]})]}),gt==="workflow"&&t.jsx(I0,{text:A.workflowText??"",onText:Z=>Pe({workflowText:Z}),base:ot?S.workflow:void 0,baseLabel:Qe?`rev ${Qe.version}`:void 0,validate:v,tools:A.tools,serverIssues:aF(me,ot)}),gt==="computer"&&!ot&&!mt&&s.computers&&t.jsx("div",{className:"space-y-8",children:t.jsx(Q6,{kinds:s.computers,value:A.computer??(S==null?void 0:S.computer)??xx(A.place??{mode:"runner"}),onChange:Z=>{const Ie=V6(Z),ht=new Set(s.tools.filter(Ct=>Ct.sandbox_only).map(Ct=>Ct.name));Pe({computer:Z,place:Ie,...Ie.mode==="runner"?{tools:(A.tools??[]).filter(Ct=>!ht.has(Ct))}:{}}),fe(Ie)},error:Me("computer")??Me("place"),warning:Ae("computer")??Ae("place")})}),gt==="computer"&&!ot&&!mt&&!s.computers&&s.places&&t.jsx("div",{className:"space-y-8",children:t.jsx(J6,{value:A.place,saved:S==null?void 0:S.place,places:s.places,tools:s.tools,picked:A.tools??[],onChange:Z=>{Pe({...Z,...Z.place?{computer:xx(Z.place)}:{}}),Z.place&&fe(Z.place)},error:Me("computer")??Me("place"),warning:Ae("computer")??Ae("place")})}),gt==="tools"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs(St,{group:!0,label:"Tools",note:"On by default: the tools this agent's harness runs on this server. Untick one to take it away.",error:Me("tools"),warning:Ae("tools"),children:[t.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[s.tools.filter(Z=>{var Ie;return ot||!Z.call_only||((Ie=A.tools)==null?void 0:Ie.includes(Z.name))}).map(Z=>{var yr,wr;const Ie=bx(A.harness??"pi",Z.name,s.tools,nt),ht=((yr=A.tools)==null?void 0:yr.includes(Z.name))??!1,Ct=h.find(Ur=>Ur.name===Z.name),Ht=(wr=(A.tool_settings??(S==null?void 0:S.tool_settings)??{})[Z.name])==null?void 0:wr.provider,xn=!!Ct&&Ht!==void 0&&Ht!==Ct.provider,tn=YP(Z,A.place??Ad(S==null?void 0:S.place)??Qv(ot,[...A.tools??[],Z.name],s.places)),vn=WC(Z.name,x,e==null?void 0:e.tools)?Sb:Z.call_only&&!ot?"Workflow-only: a workflow's call node runs it, not an agent":Ie?tn??(!Z.available&&!xn?(Ct==null?void 0:Ct.reason)??Z.reason??`Needs ${(Z.missing??[]).join(", ")}`:void 0):o0(A.harness??"pi",Z.name,s.tools),ls=vn?Z.call_only&&!ot?"Workflow only":tn&&Ie&&vn===tn?"Sandbox-only":vn:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(Cb,{value:Z.name,name:Z.name,blurb:Z.blurb,description:Z.summary,why:vn,tag:ls,on:ht,disabled:!!vn&&!ht,onToggle:()=>{I(!0),Pe({tools:ht?A.tools.filter(Ur=>Ur!==Z.name):[...A.tools??[],Z.name]})}})},Z.name)}),s.mcp&&!ot&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(E6,{servers:j,tools:A.tools??[],harness:A.harness??"pi",harnesses:s.mcpHarnesses,onRetry:E,onChange:Z=>{I(!0),Pe({tools:Z})}})}),!ot&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(B6,{tools:A.tools??[],listed:ae,notes:pe.map(({grant:Z,warning:Ie})=>({grant:Z,message:Ie.message})),refused:Q,onChange:Z=>{ye(Ie=>[...new Set([...Ie,...Z.filter(kl)])]),I(!0),Pe({tools:Z})}})})]}),!ot&&!a0(A.tools??[])&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",Le.length?`tick ${Le.join(" or ")} in Tools.`:`${A.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(nF,{agent:e,unattended:!ot&&lt==="never",harness:A.harness??"pi",model:A.model,tools:A.tools??[],choices:ot?[]:h,gates:x,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:b,callTools:ot?JD(z0(A.workflowText)??(S==null?void 0:S.workflow)):void 0,value:A.tool_settings??(S==null?void 0:S.tool_settings)??{},issues:(me==null?void 0:me.kind)==="invalid"?me.fields:{},onChange:Z=>!ze&&al(Z,(S==null?void 0:S.tool_settings)??{})?R(({tool_settings:Ie,...ht})=>ht):Pe({tool_settings:Z})}),!ot&&!mt&&t.jsxs("fieldset",{"aria-label":"Approvals",className:"space-y-2",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),[["ask","Ask me","A call whose permission is ask waits for your answer."],["never","Never ask (run unattended)","For an agent that runs on a trigger, with no one there to answer."]].map(([Z,Ie,ht])=>t.jsxs("label",{className:te("flex items-start gap-3 border px-3 py-2.5",lt===Z&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:Z,className:"mt-1 accent-primary",checked:lt===Z,disabled:ze,onChange:()=>Pe({approvals:Z})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:Ie}),t.jsx("span",{className:"block text-small text-muted-foreground",children:ht})]})]},Z)),lt==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:oE})]}),t.jsx(St,{group:!0,label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:(jn=S==null?void 0:S.skills)!=null&&jn.length?t.jsx("ul",{className:"border",children:S.skills.map(Z=>t.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:Z},Z))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),gt==="settings"&&t.jsxs("div",{className:"2xl:columns-2 2xl:gap-x-10 [&>*]:mb-8 [&>*]:mt-0 [&>*]:break-inside-avoid",children:[!ot&&t.jsxs(St,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:Me("harness"),warning:Ae("harness"),children:[t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,9rem),1fr))] gap-3",role:"radiogroup","aria-label":"Harness",children:$t.map(Z=>{const Ie=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:Z.id,checked:A.harness===Z.id,disabled:!Z.available&&A.harness!==Z.id,onChange:()=>st(Z.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block break-words font-mono text-body font-semibold",children:Z.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:Z.available?vx(Z.id)?Z.id.slice(Z.id.indexOf(":")+1):Z.id:"Not available here"})]})]}),ht=te("min-w-0 border px-4 py-3",A.harness===Z.id?"border-foreground":"border-border");return Z.available?t.jsx("label",{className:te(ht,"flex cursor-pointer items-start gap-3"),children:Ie},Z.id):t.jsxs("div",{className:te(ht,"opacity-60"),children:[t.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Ie}),Z.reason&&t.jsxs("details",{className:"mt-2 font-mono text-label text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Why, and what to do"}),t.jsx("p",{className:"mt-1 break-words leading-[1.6]",children:Z.reason})]})]},Z.id)})}),F.length>0&&t.jsxs("div",{className:"mt-3 border px-3 py-2 font-mono text-small",role:"status","aria-label":"Tools this harness doesn't run",children:[t.jsxs("p",{className:"text-warning-text",children:[((Rt=$t.find(Z=>Z.id===A.harness))==null?void 0:Rt.label)??A.harness," doesn't run ",F.length===1?"this tool":"these tools"," here, so ",F.length===1?"it's":"they're"," unticked. Switching back ticks ",F.length===1?"it":"them"," again."]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:F.map(Z=>t.jsxs("li",{children:[Z,": ",t.jsx("span",{className:"text-muted-foreground",children:o0(A.harness??"pi",Z,s.tools,s.mcpHarnesses)})]},Z))})]})]}),!ot&&!mt&&t.jsx(St,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:Me("thinking"),warning:Ae("thinking"),children:t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(Z=>t.jsxs("label",{className:te("caps cursor-pointer border px-3 py-2 text-small",A.thinking===Z?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:A.thinking===Z,onChange:()=>Pe({thinking:Z})}),Z]},Z))})}),!mt&&t.jsx(nE,{id:"agent-model",harness:A.harness??"pi",model:A.model,onModel:Z=>Pe({model:Z}),harnesses:s.harnesses,routePrefix:s.routePrefix,state:L,error:{...be,text:Me("model")},warning:{harness:(S==null?void 0:S.harness)??"pi",model:S==null?void 0:S.model,text:Ae("model")}}),!mt&&t.jsx(St,{label:"Default spend cap per run, $",id:"agent-max-cost",optional:!0,note:t.jsxs(t.Fragment,{children:["A run started without a cap of its own, and a trigger with none, stops at this spend. Empty means none.",et&&t.jsx("span",{className:"mt-1 block",children:tL}),Dt&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:Dt})]}),hint:t.jsx(sE,{}),error:Me("max_cost_usd"),warning:Ae("max_cost_usd"),children:t.jsx(De,{id:"agent-max-cost",inputMode:"decimal",value:A.maxCostText??"",onChange:Z=>Pe({maxCostText:Z.target.value}),placeholder:"e.g., 2.50"})}),!ot&&!mt&&s.learning&&t.jsx(yD,{fields:A,onFields:Pe,saved:S==null?void 0:S.learning,server:s.learning,error:Me("learning"),warning:Ae("learning")})]}),gt==="history"&&Je&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>tt(null),children:[t.jsx(Fn,{"aria-hidden":!0})," Back to History"]}),t.jsxs("span",{className:"caps text-small",children:["rev ",Je.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:Je.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:vt(Je.created_at)}),t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o(Je.revision),disabled:!o,children:"Make current"})]}),t.jsx(I0,{readOnly:!0,text:JSON.stringify((Un=Je.definition)==null?void 0:Un.workflow,null,2),onText:()=>{},base:S.workflow,baseLabel:Qe?`rev ${Qe.version}, the current one`:"the current revision"})]}),gt==="history"&&!Je&&t.jsx("ul",{className:"border",children:n.map(Z=>{var Ie;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("span",{className:"caps w-14 text-small",children:["rev ",Z.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:Z.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:vt(Z.created_at)}),ot&&!Z.current&&((Ie=Z.definition)==null?void 0:Ie.workflow)!==void 0&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>tt(Z),"aria-label":`View rev ${Z.version}`,children:[t.jsx($m,{"aria-hidden":!0})," View"]}),Z.current?t.jsx(Ne,{tone:"success",children:"Current"}):t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o(Z.revision),disabled:!o,children:"Make current"})]},Z.revision)})})]})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[t.jsxs(B,{size:"sm",variant:"ghost",disabled:Et===0,onClick:()=>ft(ct[Et-1].id),children:[t.jsx(Fn,{"aria-hidden":!0})," Previous"]}),gt!=="history"&&t.jsx(De,{value:X,onChange:Z=>re(Z.target.value),placeholder:N?"":"What changed (a note on this revision)","aria-label":"Revision note",className:te("h-9 min-w-0 flex-1",N&&"invisible")}),gt==="history"&&t.jsx("span",{className:"flex-1"}),Et<ct.length-1&&t.jsxs(B,{size:"sm",onClick:()=>ft(ct[Et+1].id),children:["Next ",t.jsx(Zx,{"aria-hidden":!0})]}),!Je&&t.jsx(B,{ref:bt,size:"sm",variant:"solid",onClick:se,disabled:!r||ze||!N&&!G||!((ys=A.name)!=null&&ys.trim())||!ot&&!mt&&!((ws=A.instructions)!=null&&ws.trim()),children:N?ze?"Creating…":"Create":ze?"Saving…":G?"Save revision":Qe?`Saved · rev ${Qe.version}`:"Saved"}),N&&!ze&&!Je&&Re.map(Z=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:Z},Z)),(me==null?void 0:me.kind)==="invalid"&&t.jsxs("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:["The server refused the save: ",me.message]}),(me==null?void 0:me.kind)==="other"&&t.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:me.message})]}),t.jsxs(kv,{open:$e.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:$e.leave,onCancel:$e.stay,children:[N?"This new agent is not saved yet.":"Your changes to this agent are not saved."," Leave drops them; Stay keeps them here."]})]})}const dF="w-full border bg-background px-3 py-2.5 font-mono text-body focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring placeholder:text-muted-foreground focus:border-border-strong";function uF({agents:e,archived:n=!1,onArchivedChange:s,actions:r={},error:o,handoff:i,observations:c}){var g;const[d,u]=p.useState(""),f=(e??[]).filter(y=>`${y.definition.name} ${y.definition.description??""}`.toLowerCase().includes(d.toLowerCase()));return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:te(vr,"flex-wrap justify-between gap-3 px-5"),children:[t.jsxs("h1",{className:Jo,children:[t.jsx(Xc,{className:"size-4","aria-hidden":!0}),n?"Archived agents":"Connected agents"]}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:[i,!n&&t.jsx(an,{variant:"primary",label:"Build an agent",prompt:Zm(location.origin),playgroundHref:"#/playground?operation=create-agent"})]})]}),t.jsxs("div",{className:"p-5 md:p-6",children:[t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:te(Za,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(yd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(De,{bare:!0,value:d,onChange:y=>u(y.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"h-full flex-1 max-sm:portrait:placeholder:text-transparent"})]}),t.jsxs(B,{size:"lg",variant:n?"primary":"outline","aria-pressed":n,onClick:()=>s==null?void 0:s(!n),children:[t.jsx(xd,{"aria-hidden":!0})," Archived"]})]}),o?t.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:o}):e?!f.length&&!((g=c==null?void 0:c.data)!=null&&g.sessions.length)?t.jsxs("div",{className:"border px-4 py-16 text-center",children:[t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:d?"No agent matches.":n?"No archived agents.":"No agents yet."}),!d&&!n&&t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text hover:underline",href:"#/agents/new",children:"Describe your agent or start from a template"})]}):t.jsxs(t.Fragment,{children:[!!f.length&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[f.length," ",f.length===1?"agent":"agents"]}),t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:f.map(y=>t.jsx(fF,{agent:y,actions:r},y.agent_id))})]}):t.jsx(Qn,{label:"Loading the agents",rows:6}),c&&t.jsx("div",{className:"mt-6",children:t.jsx(Dv,{read:c,view:"cards",query:d})})]})]})}function fF({agent:e,actions:n}){var d;const s=e.kind==="workflow"?li:e1,r=!!e.archived_at,o=eb(e),i=os(e.definition),c=am(e);return t.jsxs("li",{className:te("flex flex-col border p-5 transition-colors hover:border-border-strong",r&&"opacity-70"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:()=>{var u;return(u=n.onOpen)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx("span",{"data-agent-card-icon":!0,className:"flex h-6 shrink-0 items-center",children:t.jsx(s,{className:"size-4 text-muted-foreground","aria-hidden":!0})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-h-6 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-base font-semibold",children:e.definition.name}),t.jsx(Ne,{children:e.kind}),e.kind==="agentic"&&t.jsx(Ne,{children:i?sa(i.runtime):o?Ld(o.runtime):e.definition.harness??"pi"}),o&&t.jsx(Ne,{tone:o.connected&&o.state==="ready"?"success":"warning",children:Pd(o)}),r&&t.jsx(Ne,{tone:"muted",children:"Archived"})]}),t.jsx("span",{className:"mt-2 line-clamp-2 block text-lead leading-relaxed text-muted-foreground",children:e.definition.description||(e.kind==="workflow"?dP(e.definition.workflow):"No description.")})]})]}),o&&t.jsxs("p",{className:"mt-3 break-all font-mono text-small text-muted-foreground",children:[o.project," · ",o.machine_id]}),t.jsxs("div",{"data-testid":"agent-card-footer",className:"mt-auto flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 pt-5",children:[t.jsxs("div",{"data-testid":"agent-card-chips",className:"flex min-w-0 flex-auto flex-wrap items-center gap-x-2 gap-y-1.5 py-1.5",children:[t.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&t.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.runs.count," ",e.runs.count===1?"run":"runs",e.runs.live?` · ${e.runs.live} live`:""]}),c>0&&t.jsxs(B,{size:"xs",type:"button","aria-label":cb(c),onClick:()=>{var u;return(u=n.onLearning)==null?void 0:u.call(n,e.agent_id)},className:"h-5 shrink-0 whitespace-nowrap border-warning/50 bg-warning/10 px-1.5 text-micro text-warning-text hover:bg-warning/20",children:["Learning · ",c]})]}),t.jsxs("div",{"data-testid":"agent-card-actions",className:"ml-auto flex min-w-0 max-w-full flex-wrap items-center justify-end gap-2",children:[!r&&t.jsx(an,{compact:!0,compactIcon:t.jsx(ra,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!o&&(!o.connected||o.state!=="ready"||!o.capabilities.launch),prompt:Kv(location.origin,e.agent_id,i==null?void 0:i.runtime),playgroundHref:i?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(an,{compact:!0,compactIcon:t.jsx(sv,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:Xo(location.origin,e.agent_id,!!o,i==null?void 0:i.runtime),playgroundHref:o||i?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),t.jsxs(B,{size:"sm",className:"gap-1 px-2",variant:"outline","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var u;return(u=n.onRuns)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx(bd,{"aria-hidden":!0}),((d=e.runs)==null?void 0:d.count)??0]}),t.jsx(B,{size:"icon",variant:"outline","aria-label":`${r?"Unarchive":"Archive"} ${e.definition.name}`,onClick:()=>{var u;return(u=n.onArchive)==null?void 0:u.call(n,e.agent_id,!r)},children:r?t.jsx(XN,{"aria-hidden":!0}):t.jsx(xd,{"aria-hidden":!0})})]})]})]})}function mF({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState(!1),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(""),[y,v]=p.useState("live"),[h,x]=p.useState(null),[b,j]=p.useState(!1),[k,E]=p.useState(!1),[N,S]=p.useState(null),$=p.useRef(!1),_=p.useRef(!1),O=p.useRef(0),M=p.useRef(!0),P=qM(),A=p.useCallback(async()=>{if(_.current)return;_.current=!0,o(!0);const U=O.current;try{const Y=await e.listConnectors();M.current&&U===O.current&&(s(Y.connectors),c(null))}catch(Y){M.current&&U===O.current&&c(Gt(Y))}finally{_.current=!1,M.current&&o(!1)}},[e]);p.useEffect(()=>{M.current=!0,queueMicrotask(()=>{M.current&&A()});const U=()=>{!document.hidden&&!$.current&&A()},Y=setInterval(U,15e3);return window.addEventListener("focus",U),document.addEventListener("visibilitychange",U),()=>{M.current=!1,O.current++,clearInterval(Y),window.removeEventListener("focus",U),document.removeEventListener("visibilitychange",U)}},[A]),p.useEffect(()=>{if(!h)return;const U=new Date(h.expires_at).getTime()-Date.now();if(U<=0){x(null),j(!0);return}const Y=setTimeout(()=>{x(null),j(!0)},U);return()=>clearTimeout(Y)},[h]);const R=async()=>{if(!$.current){$.current=!0,E(!0),u(null),j(!1);try{const U=await e.enrollConnector(f,{native_execution:y!=="history",history_import:y!=="live"});M.current&&x(U)}catch(U){M.current&&u(Gt(U))}finally{$.current=!1,M.current&&E(!1)}}},L=async()=>{if(!($.current||!N)){$.current=!0,E(!0),u(null),O.current++;try{const{connector:U}=await e.revokeConnector(N.connector_id);M.current&&(s(Y=>(Y==null?void 0:Y.map(D=>D.connector_id===U.connector_id?U:D))??null),S(null))}catch(U){M.current&&u(Gt(U))}finally{$.current=!1,M.current&&E(!1)}}},W=async()=>{if(h)try{await navigator.clipboard.writeText(h.enrollment_token),P({title:"Connection code copied"})}catch{P({title:"Select and copy the connection code below",tone:"error"})}};return t.jsxs("div",{className:"space-y-6","aria-label":"Remote connections",children:[t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Connect another machine",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Connect remote agents"}),t.jsx(an,{label:"Connect agent",prompt:TP(location.origin,y)})]}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect a Claude Code or Codex setup on your laptop, VM or container. Its files and native sign-in stay there."}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label",children:"Allow this connection to"}),t.jsx(Qo,{name:"remote-connection-intent",label:"Connection scope",size:"sm",value:y,onChange:v,options:[{value:"live",label:"Live agent",disabled:k},{value:"history",label:"History only",disabled:k},{value:"both",label:"Both",disabled:k}]}),t.jsxs("p",{className:"max-w-prose text-small text-muted-foreground",children:[y==="live"?"Run future jobs with your existing setup. Past conversations are not shared.":y==="history"?"Upload completed conversations from one selected project and runtime. No executing worker or self-improvement is enabled.":"Connect for future jobs and upload completed conversations from the selected project and runtime."," ",y!=="live"&&" Preview and approve the history on the source machine before upload. History is not used as learning."]})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(St,{label:"Machine label",hint:"Optional. A name you recognize in this console.",children:t.jsx(De,{value:f,onChange:U=>g(U.target.value),placeholder:"My development machine",disabled:k,maxLength:120})})}),t.jsx(B,{size:"md",className:"self-start sm:mt-6",disabled:k,"aria-busy":k,onClick:()=>void R(),children:k&&!N?"Creating code…":"Create connection code"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Use the code only in the connector's secure terminal prompt. It expires after ten minutes and can pair one machine. The coding-agent prompt contains no credentials."}),b&&t.jsx(jt,{tone:"warning",children:"The connection code expired. Create a new one if you have not connected the machine."}),d&&!N&&t.jsx(jt,{tone:"error",title:"Connection action failed",children:d})]}),t.jsxs("section",{className:"space-y-4","aria-label":"Connected remote machines",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Remote machines"}),t.jsx(B,{size:"sm",disabled:r||k,onClick:()=>void A(),"aria-busy":r,children:r?"Refreshing…":"Refresh"})]}),i&&t.jsx(jt,{tone:"error",title:"Remote machines could not be read",actions:t.jsx(B,{size:"xs",disabled:r,onClick:()=>void A(),children:"Try again"}),children:i}),n===null&&!i&&t.jsx("p",{className:"text-body text-muted-foreground",role:"status",children:"Loading remote machines…"}),(n==null?void 0:n.length)===0&&t.jsxs("div",{className:"border p-6",children:[t.jsx("h3",{className:"text-body font-semibold",children:"No remote machines connected"}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Use your coding agent to connect a source machine. It appears here once the connector has paired."})]}),n==null?void 0:n.map(U=>t.jsxs("article",{className:"space-y-4 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h3",{className:"mr-auto break-words text-body font-semibold",children:U.label||U.connector_id}),t.jsx(Ne,{tone:U.status==="revoked"||!U.capabilities.native_execution?"plain":U.status==="online"?"success":"warning",children:U.status==="revoked"?"Revoked":!U.capabilities.native_execution&&U.capabilities.history_import?"History only":U.status==="online"?"Online":"Offline"}),t.jsx(B,{size:"sm",disabled:k||U.status==="revoked",onClick:()=>{u(null),S(U)},children:"Revoke access"})]}),t.jsxs("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Last seen"}),t.jsx("dd",{children:U.last_seen_at?vt(U.last_seen_at):"Not yet seen"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Access"}),t.jsx("dd",{children:U.capabilities.native_execution?U.capabilities.history_import?"Live agents and history import":"Selected native agents and remote jobs":U.capabilities.history_import?"History import only":"Observation only"})]})]}),U.status==="offline"&&U.capabilities.native_execution&&t.jsx(jt,{tone:"warning",children:"The source worker is offline. Start it on the original machine to verify or run its agents. Saved agents and learning are preserved."}),U.targets.length>0?t.jsx("ul",{className:"divide-y border-t",children:U.targets.map(Y=>t.jsxs("li",{className:"space-y-2 pt-3 [&+li]:mt-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("span",{className:"min-w-0 flex-1 break-words text-body font-semibold",children:Y.name}),Y.agent_id?t.jsx("a",{href:Cn(Y.agent_id),className:"text-small underline underline-offset-2",children:"Open agent"}):t.jsx(Ne,{children:"Not imported"})]}),t.jsxs("p",{className:"break-words text-small text-muted-foreground",children:[Ld(Y.runtime)," · ",Y.machine_id," · ",Y.history_only?"Imported history":U.status==="online"?Y.state==="ready"&&Y.capabilities.launch?"Ready to run":Y.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),Y.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:Y.issues.join("; ")})]},Y.target_id))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No native targets imported. Choose a project or agent with the source connector."})]},U.connector_id)),t.jsx("p",{className:"text-small text-muted-foreground",children:"Refreshes every 15 seconds while this page is visible. Open an agent to see its runs. Live connections also support Learning Dojo."})]}),t.jsx(Ym,{open:h!==null,onClose:()=>x(null),title:"Connect this machine",description:"Enter this code directly in the source connector's secure prompt.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",onClick:()=>x(null),children:"Done"}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void W(),children:"Copy connection code"})]}),children:h&&t.jsxs(t.Fragment,{children:[t.jsx(St,{label:"One-use connection code",hint:`Expires ${vt(h.expires_at)}. Closing this dialog clears it from the page.`,children:t.jsx(De,{readOnly:!0,value:h.enrollment_token,autoComplete:"off",spellCheck:!1,onFocus:U=>U.currentTarget.select()})}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"This grants a scoped connector credential. Keep it out of coding-agent prompts, URLs and source control. After pairing, the connector retains its own credential in its private state directory."})]})}),t.jsxs(kv,{open:N!==null,title:"Revoke this machine's access?",confirm:k?"Revoking…":"Revoke access",busy:k,onCancel:()=>{S(null),u(null)},onConfirm:()=>void L(),children:[t.jsxs("p",{children:[(N==null?void 0:N.label)||"This machine"," will no longer receive work or report activity. Agent definitions, past runs and saved learning stay available. Pair the machine again to restore access."]}),d&&t.jsx(jt,{tone:"error",className:"mt-3",children:d})]})]})}function ch({variant:e}){return t.jsx(an,{variant:e,label:"Connect agent",prompt:sC(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function hF({v2:e,go:n,initialSource:s="server"}){const[r,o]=p.useState(s),[i,c]=p.useState(""),[d,u]=p.useState(null),[f,g]=p.useState([]),[y,v]=p.useState({}),[h,x]=p.useState(!1),[b,j]=p.useState(null),k=async()=>{x(!0),j(null),u(null),g([]),v({});try{u((await e.discoverNative(i.trim())).targets)}catch(N){j(Gt(N))}finally{x(!1)}},E=async()=>{x(!0),j(null);try{for(const N of f){if(y[N])continue;const{project:S,runtime:$,selector:_}=d[N],O=await e.connectNative({project:S,runtime:$,selector:_});v(M=>({...M,[N]:O.agent.agent_id}))}}catch(N){j(Gt(N))}finally{x(!1)}};return t.jsxs("section",{className:"mx-auto max-w-page space-y-6 p-5 md:p-8","aria-label":"Connect agent",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto text-2xl font-semibold",children:"Connect agent"}),t.jsx(B,{size:"sm",onClick:()=>n("#/agents"),children:"Back to agents"})]}),t.jsx("p",{className:"max-w-prose text-lead text-muted-foreground",children:"Connect a native setup for new jobs, or observe an agent already running in its original application. Keep its instructions, tools, permissions and sign-in."}),t.jsx(jt,{title:"Choose how to connect",children:"Choose this server or another machine to launch jobs from an existing native setup. Choose an existing application to observe its activity and token usage through the CLI. This browser cannot scan your laptop."}),t.jsx(Qo,{name:"native-source",label:"Connection method",value:r,onChange:o,options:[{value:"server",label:"This server",disabled:h},{value:"remote",label:"Another machine",disabled:h},{value:"observe",label:"Existing application",disabled:h}]}),r==="observe"?t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Observe an existing application",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Observe your existing agent"}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect Claude Code or Codex running locally, in Docker, or on another server. Your application continues to start and control its jobs; AgentRun receives session activity, model and token usage."}),t.jsx("p",{className:"max-w-prose text-small text-muted-foreground",children:"The setup skill configures the existing CLI and telemetry collector for this server. Adding self-improvement requires the backend SDK integration."}),t.jsx(an,{variant:"primary",label:"Connect agent",prompt:`${sC(location.origin)}
646
+
647
+ I selected observation of an existing application. Preserve its current job trigger and SDK configuration; do not import or launch a replacement agent.`})]}):r==="remote"?t.jsx(mF,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(ch,{}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Discover native setups",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Discover on this server"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Read-only discovery checks configuration without launching a model or executing project hooks. No model API key is needed to connect."}),t.jsx(St,{label:"Project on server host",hint:"Enter the absolute path on the machine running AgentRun.",children:t.jsx(De,{"aria-label":"Project on server host",value:i,onChange:N=>{c(N.target.value),u(null)},placeholder:"/path/to/project",disabled:h})}),t.jsx(B,{variant:d?"outline":"solid",size:"sm",disabled:h||!i.trim().startsWith("/"),"aria-busy":h,onClick:()=>void k(),children:h&&!d?"Discovering…":"Discover"})]}),b&&t.jsx(jt,{tone:"error",title:"Connection request failed",children:b}),d&&t.jsxs("section",{className:"space-y-4","aria-label":"Native targets",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Choose what to connect"}),!d.length&&t.jsx(jt,{children:"No supported native setup was found. Install Claude Code or Codex on this host and check the project path."}),d.map((N,S)=>t.jsxs("article",{className:"space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsxs("label",{className:"flex min-w-0 flex-1 items-start gap-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",disabled:h||!!y[S],checked:f.includes(S),onChange:$=>g(_=>$.target.checked?[..._,S]:_.filter(O=>O!==S))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Xv(N.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[Ld(N.runtime)," · ",N.version??"Version unknown"]})]})]}),t.jsx(Ne,{tone:N.state==="ready"?"success":"warning",children:Pd(N)})]}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Project",N.project],["Machine",N.machine_id],["Model",N.model??"Native default · unknown until launch"],["Skills",N.skills.join(", ")||"None detected"],["MCP servers",N.mcp_servers.join(", ")||"None configured"],["Approval handling",N.capabilities.approval]].map(([$,_])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:$}),t.jsx("dd",{className:"break-all font-mono",children:_})]},$))}),N.selector.kind==="agent"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"This named agent runs as the main Claude Code session, rather than a delegated subagent."}),N.selector.kind==="profile"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"A Codex profile selects native configuration; it is not a custom subagent."}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native launch: ",N.capabilities.launch?"supported":"unavailable"," · Self-improving: ",N.capabilities.learning?"corrections and compile":"unavailable"," · Learned workflows: not served ·Usage: ",N.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"]}),N.issues.length>0&&t.jsx(jt,{tone:"warning",children:t.jsx("ul",{children:N.issues.map($=>t.jsx("li",{children:$},$))})}),y[S]&&t.jsxs("p",{role:"status",className:"text-body",children:["Connected. ",t.jsx("a",{href:Cn(y[S]),className:"underline underline-offset-2",children:"Open connected agent"})]})]},`${N.runtime}:${N.selector.kind}:${N.selector.name??""}`)),!!d.length&&t.jsx(B,{variant:"solid",size:"sm",onClick:()=>void E(),disabled:h||!f.some(N=>!y[N]),"aria-busy":h,children:h?"Connecting…":"Connect selected"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Connecting saves a reference and starts no run. Authentication and approval compatibility are checked separately on the connected agent's page."})]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Your coding agent can also help import selected history. Past conversations stay historical; they do not become live jobs or AgentRun learning."})]})}const Fa=e=>e instanceof Ue?ZP(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function pF({v2:e,archived:n,go:s}){const r=zv(e,{active:!n}),[o,i]=p.useState(null),[c,d]=p.useState(null),u=p.useRef(0),f=()=>{const g=++u.current;i(null),d(null),Mr(y=>e.listAgents({archived:n,cursor:y}),y=>y.agents).then(y=>{g===u.current&&i(y)}).catch(y=>{g===u.current&&d(Fa(y).message)})};return p.useEffect(()=>{f();const g=()=>{document.hidden||f()};return window.addEventListener("focus",g),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",g)}},[e,n]),t.jsx(uF,{observations:r,agents:o,archived:n,onArchivedChange:g=>s(g?"#/agents?archived=true":"#/agents"),error:c,handoff:t.jsx(ch,{}),actions:{onOpen:g=>s(Cn(g)),onEdit:g=>s(Cn(g,"edit")),onNew:()=>s("#/agents/new"),onRuns:g=>s(Cn(g,"runs")),onLearning:g=>s(Cn(g,"learning")),onArchive:async(g,y)=>{try{await(y?e.archiveAgent(g):e.unarchiveAgent(g)),f()}catch(v){d(Fa(v).message)}}}})}function gF({v2:e,caps:n,choices:s=[],gates:r=[],focusTool:o,agentId:i,go:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState([]),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(0),[N,S]=p.useState(null),$=p.useRef(!0);p.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const _=F=>Mr(q=>e.listRevisions(F,q),q=>q.revisions),O=async()=>{if(i)try{const[{agent:F,etag:q},H]=await Promise.all([e.getAgent(i),_(i)]);u(F),g(q),v(H),S(F.revision),E(I=>I+1),j(null),x(null)}catch(F){d?j(`The agent could not be reloaded: ${Fa(F).message}`):x(Fa(F).message)}};p.useEffect(()=>{O()},[i]);const[M,P]=p.useState(null),A=p.useRef(0);p.useEffect(()=>{const F=++A.current;e.computers().then(q=>{F===A.current&&P(q.kinds)},()=>{F===A.current&&P(null)})},[e]);const[R,L]=p.useState(void 0);p.useEffect(()=>{let F=!0;return Promise.resolve().then(()=>e.toolSettings()).then(q=>{F&&L(q)},()=>{}),()=>{F=!1}},[e]);const[W,U]=p.useState(null),Y=p.useRef(0),D=()=>{if(!n.mcp)return;const F=++Y.current;U(null),e.listMcpServers().then(q=>{F===Y.current&&U(q.servers)},()=>{F===Y.current&&U("failed")})};p.useEffect(D,[e,n.mcp]);const G=async(F,q)=>{let H;try{H=await q()}catch(I){j(`${F} did not finish: ${Fa(I).message}`);return}u(H);try{const{agent:I,etag:V}=await e.getAgent(H.agent_id),J=await _(H.agent_id).catch(()=>y);u(I),g(V),v(J),I.revision!==N?(S(I.revision),E(X=>X+1),j(F==="Make current"?null:`${F} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(I){j(`${F} done. The page could not be refreshed: ${Fa(I).message}. Reload to see the current state.`)}};return i&&h&&!d?t.jsx("p",{className:"m-8 border p-4 font-mono text-body text-destructive-text",role:"alert",children:h}):i&&!d?t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading the agent..."}):d&&os(d.definition)?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsxs("h1",{className:"text-2xl font-semibold",children:["Edit ",d.definition.name]}),t.jsx(jt,{children:"This agent runs in your backend. Edit its application code with your coding agent; manage self-improving in its Learning tab."}),t.jsx(an,{label:"Edit agent",prompt:Xo(location.origin,d.agent_id,!1,os(d.definition).runtime)}),t.jsx("a",{href:Cn(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(cF,{agent:d,revisions:y,caps:{...n,computers:M},providerChoices:s,permissionGates:r,mcpServers:W,serverToolSettings:R,onRetryMcp:D,...o?{focusTool:o,step:"tools"}:{},notice:b,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{O(),D()},onSave:async(F,q)=>{let H;try{if(!d){const X=await e.createAgent(GP({name:F.name??"",description:F.description??"",instructions:F.instructions??"",harness:F.harness??"pi",tools:F.tools??[],approvals:F.approvals,tool_settings:F.tool_settings,thinking:F.thinking,model:F.model,computer:F.computer,learning:F.learning,max_cost_usd:F.max_cost_usd,decisionProvider:n.decisionProvider}));return $.current&&c(Cn(X.agent_id,X.kind==="workflow"?"workflow":void 0)),null}const I=Md(d,F,q);if(I.unchanged)return{kind:"other",message:"Nothing to save: the definition is the current revision's, and a note alone makes no new revision."};const{unchanged:V,...J}=I;H=await e.updateDefinition(d.agent_id,J,f)}catch(I){return Fa(I)}return u(H.agent),g(H.etag),S(H.agent.revision),e.getAgent(H.agent.agent_id).then(I=>u(V=>V&&V.revision===I.agent.revision?{...V,tools:I.agent.tools}:V)).catch(()=>{}),_(H.agent.agent_id).then(v).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:F=>{d&&G("Make current",()=>e.setCurrent(d.agent_id,F))},onArchive:F=>{d&&G(F?"Archive":"Unarchive",()=>F?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function mr(e){if(!(typeof e!="string"||!e))try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}const xF={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},vF={tool:1,model:1,mcp:2,computer:2,source:2};function fm(e,n){const s=e.split(":"),r=vF[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const bF="Sign in with your password to change secrets.",yF="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",wF="Open the console from the server's link to change secrets.",fa={sign_in:bF,no_accounts:yF,token:wF},aE=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,jF=e=>{var n;return((n=aE(e))==null?void 0:n.secrets_writable)===!0};function kF(e){const n=aE(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function NF(e){const[n,s]=p.useState({writable:!1,whyNot:"sign_in"});return p.useEffect(()=>{let r=!0;return e.session().then(o=>{r&&s({writable:jF(o),whyNot:kF(o)})},()=>{}),()=>{r=!1}},[e]),n}const SF=2e3,Tx=e=>e instanceof Ue||e instanceof Error?e.message:String(e),Tb=({children:e="Manage usage"})=>t.jsx("a",{href:Y5,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function CF(){return t.jsxs("div",{className:"space-y-1 text-body text-muted-foreground",children:[t.jsxs("p",{children:["Eligible usage in this app uses your ChatGPT plan. ",t.jsx(Tb,{})," in your ChatGPT settings."]}),t.jsx("p",{children:J5})]})}function Rx({v2:e,view:n,onView:s,writable:r=!0,whyNot:o="sign_in",beside:i}){const[c,d]=p.useState(n),[u,f]=p.useState(null),[g,y]=p.useState(!1),[v,h]=p.useState(!1),[x,b]=p.useState(!1),j=p.useRef(null),k=p.useRef(0);p.useEffect(()=>{d(n)},[n]);const E=P=>{d(P),s==null||s(P)},N=c.state==="pending";p.useEffect(()=>{if(!N)return;let P=!1;const A=()=>{if(P||document.visibilityState!=="visible")return;P=!0;const W=++k.current;e.chatGPT().then(U=>{const Y=Zf(U);W===k.current&&Y&&Y.state!=="pending"&&E(Y)},()=>{}).finally(()=>{P=!1})},R=setInterval(A,SF),L=()=>{document.visibilityState==="visible"&&A()};return document.addEventListener("visibilitychange",L),()=>{clearInterval(R),document.removeEventListener("visibilitychange",L)}},[e,N]);const S=async()=>{f(null),y(!0);const P=window.open("","_blank");k.current++;try{const A=await e.startChatGPT();P&&(P.opener=null,P.location.href=A.authorize_url),E({state:"pending",authorize_url:A.authorize_url,expires_at:A.expires_at})}catch(A){P==null||P.close(),f(Tx(A))}finally{y(!1)}},$=async P=>{var L;P.preventDefault();const A=(L=j.current)==null?void 0:L.value.trim();if(!A)return;f(null),y(!0),h(!0),k.current++;const R=W=>{j.current&&(j.current.value=""),b(!1),E(W)};try{R(await e.finishChatGPT(A))}catch(W){const U=await e.chatGPT().then(Zf,()=>null);(U==null?void 0:U.state)==="signed_in"?R(U):f(Tx(W))}finally{y(!1),h(!1)}},_=u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u});if(c.state==="signed_in")return t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body font-semibold",children:rL(c)}),t.jsx(CF,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:fa[o]});if(!N)return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"solid",disabled:g,onClick:()=>void S(),children:"Continue with ChatGPT"}),i]}),_]});const O=mr(c.authorize_url),M=c.expires_at;return t.jsxs("form",{onSubmit:P=>void $(P),autoComplete:"off",className:"space-y-3 border bg-card p-4","aria-label":"Finish signing in with ChatGPT",children:[t.jsx("p",{className:"text-body",children:Q5}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[O&&t.jsxs(t.Fragment,{children:[t.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Open the sign-in page"})," (a new tab)"]}),O&&M&&" · ",M&&`Waits until ${ti(M)}`]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"The sign-in tab's address"}),t.jsx(De,{ref:j,name:"redirect_url",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:"127.0.0.1:1455/auth/callback?code=…",onInput:()=>{var P;return b(!!((P=j.current)!=null&&P.value.trim()))}})]}),_,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!x||g,children:v?"Finishing…":"Finish sign-in"}),t.jsx(B,{type:"button",size:"sm",disabled:g,onClick:()=>void S(),children:"Start again"})]})]})}const EF={signed_in:{tone:"success",words:"signed in"},pending:{tone:"plain",words:"waiting"},expired:{tone:"warning",words:"expired"},signed_out:{tone:"plain",words:"not signed in"}};function $F({v2:e,writable:n,whyNot:s,onChange:r}){var b;const[o,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null);if(p.useEffect(()=>{let j=!0;return e.chatGPT().then(k=>{j&&i(Zf(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!o)return null;const v=async()=>{y(null);let j;try{j=await e.signOutChatGPT()}catch(k){y(Tx(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||Z5,settings:!0}:{words:X5}),r==null||r()},h=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},x=EF[o.state];return t.jsxs("li",{"aria-label":"ChatGPT plan",className:"border-b p-4 last:border-b-0",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:"ChatGPT plan"}),t.jsx(Ne,{tone:x.tone,children:x.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:E2}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:eL}),o.state==="signed_in"&&((b=o.models)!=null&&b.length)?t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Models: ",o.models.join(" · ")]}):null,t.jsx(Rx,{v2:e,view:o,onView:h,writable:n,whyNot:s}),o.state==="signed_in"&&n&&!c&&t.jsx(B,{size:"sm",onClick:()=>{d(!0),y(null)},children:"Sign out"}),c&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Sign out of ChatGPT on this server? Codex and pi agents then need a key to run here."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void v(),children:"Sign out"}),t.jsx(B,{size:"sm",onClick:()=>d(!1),children:"Keep"})]}),g&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g}),u&&t.jsxs("p",{className:"text-body",role:"status",children:[u.words,u.settings&&t.jsxs(t.Fragment,{children:[" ",t.jsx(Tb,{children:"ChatGPT settings"})]})]})]})]})}function _F(e){var n,s;return(n=e.needs)!=null&&n.includes("chatgpt")?{tone:"warning",text:"runs after Continue with ChatGPT"}:(s=e.needs)!=null&&s.includes("key")?{tone:"warning",text:"needs a key"}:e.available?{tone:"success",text:"ready"}:{tone:"warning",text:"not here"}}function iE({harnesses:e,routePrefix:n}){return e.length?t.jsxs("section",{"aria-label":"What runs here",children:[t.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:"What runs here"}),t.jsx("ul",{className:"border",children:e.map(s=>{var o;const r=_F(s);return t.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-2.5 last:border-b-0",children:[t.jsx("span",{className:"font-mono text-body font-semibold",children:om(s.id)}),t.jsx(Ne,{tone:r.tone,children:r.text}),s.available&&!((o=s.needs)!=null&&o.length)?s.default_model&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:jl(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const TF=2e3,RF=10*6e4,AF=e=>e instanceof Ue||e instanceof Error?e.message:String(e),OF={off:{tone:"plain",words:"off"},other_machine:{tone:"warning",words:"another machine"},signed_in:{tone:"success",words:"signed in"},signed_out:{tone:"warning",words:"not signed in"},no_cli:{tone:"plain",words:"no CLI yet"},unknown:{tone:"warning",words:"status unknown"}};function MF({v2:e,writable:n,whyNot:s="sign_in",onChange:r}){const[o,i]=p.useState(null),[c,d]=p.useState("agentrun"),[u,f]=p.useState(!1),[g,y]=p.useState(!1),[v,h]=p.useState(null),[x,b]=p.useState(null),j=p.useRef(0),k=p.useRef(!1),E=p.useRef(!1);p.useEffect(()=>{let A=!0;return e.claudeLogin().then(R=>{A&&i(zk(R))},()=>{A&&i(null)}),()=>{A=!1}},[e]);const N=()=>{if(E.current||k.current)return;E.current=!0;const A=++j.current;e.claudeLogin().then(R=>{const L=zk(R);A===j.current&&L&&i(L)},()=>{}).finally(()=>{E.current=!1})},S=x!==null&&(o==null?void 0:o.state)!=="signed_in";p.useEffect(()=>{if(!S)return;const A=setInterval(()=>{if(document.visibilityState==="visible"){if(Date.now()-x>RF){b(null);return}N()}},TF);return()=>clearInterval(A)},[e,S]);const $=(o==null?void 0:o.state)==="signed_out"||(o==null?void 0:o.state)==="no_cli"||(o==null?void 0:o.state)==="unknown";if(p.useEffect(()=>{if(!$)return;const A=()=>{document.visibilityState==="visible"&&N()};return window.addEventListener("focus",A),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("focus",A),document.removeEventListener("visibilitychange",A)}},[e,$]),!o)return null;const _=async(A,R)=>{h(null),y(!0),k.current=!0,j.current++;try{return i(await A()),R&&(r==null||r()),!0}catch(L){return h(AF(L)),!1}finally{j.current++,k.current=!1,y(!1)}},O=OF[o.state],M=o.state!=="off",P=t.jsx("pre",{className:"overflow-x-auto border bg-card p-3 font-mono text-small",children:t.jsx("code",{children:o.command})});return t.jsxs("li",{"aria-label":Pk,className:"border-b p-4 last:border-b-0",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:Pk}),t.jsx(Ne,{tone:O.tone,children:O.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:oL}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="signed_in"&&t.jsx("p",{className:"text-body font-semibold",children:hL(o)}),o.state==="other_machine"&&t.jsx("p",{className:"text-body",children:uL}),(o.state==="signed_out"||o.state==="no_cli"||o.state==="unknown")&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body",children:o.state==="signed_out"?lL:o.state==="no_cli"?cL:dL}),P,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[n&&o.can_start&&o.state!=="no_cli"&&t.jsx(B,{type:"button",size:"sm",variant:"solid",disabled:g||S,onClick:()=>void _(()=>e.startClaudeLogin(),!1).then(A=>A&&b(Date.now())),children:S?"Waiting for the browser…":"Open the CLI's sign-in here"}),t.jsx(B,{type:"button",size:"sm",disabled:g,onClick:N,children:"Check again"})]})]}),!M&&o.refused&&t.jsx("p",{className:"text-body",role:"status",children:o.refused}),!M&&!o.refused&&!n&&t.jsx("p",{className:"text-body",role:"status",children:fa[s]}),!M&&!o.refused&&n&&t.jsxs("form",{className:"space-y-2",onSubmit:A=>{A.preventDefault(),_(()=>e.turnOnClaudeLogin(c),!0)},children:[t.jsxs("fieldset",{className:"space-y-1",children:[t.jsx("legend",{className:"caps mb-1 text-small font-semibold",children:"The login it uses"}),Object.keys(Ik).map(A=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"claude-login-place",value:A,className:"accent-primary",checked:c===A,onChange:()=>d(A)}),Ik[A]]},A))]}),t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"only_me",className:"accent-primary",checked:u,onChange:A=>f(A.target.checked)}),aL]}),t.jsx("p",{className:"text-small text-muted-foreground",children:iL}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!u||g,children:"Turn on"})]}),M&&n&&t.jsx(B,{size:"sm",disabled:g,onClick:()=>void _(()=>e.turnOffClaudeLogin(),!0).then(A=>A&&b(null)),children:"Turn off"}),v&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:v})]})]})}const Cf=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function LF(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,o,i,c]=n,d=Cf(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return o==="*"&&c==="*"?{kind:"hourly",minute:d}:null;const u=Cf(r,0,23);if(u===null)return null;const f={hour:u,minute:d};if(o==="*"&&c==="*")return{kind:"daily",at:f};if(o==="*"&&c==="1-5")return{kind:"weekdays",at:f};if(o==="*"){const g=Cf(c,0,6);return g===null?null:{kind:"weekly",day:g,at:f}}if(c==="*"){const g=Cf(o,1,31);return g===null?null:{kind:"monthly",date:g,at:f}}return null}function PF(e){if(e.kind==="hourly")return`${e.minute} * * * *`;const n=`${e.at.minute} ${e.at.hour}`;return e.kind==="daily"?`${n} * * *`:e.kind==="weekdays"?`${n} * * 1-5`:e.kind==="weekly"?`${n} * * ${e.day}`:`${n} ${e.date} * *`}function IF(e,n){const s=n&&"at"in n?n.at:{hour:9,minute:(n==null?void 0:n.kind)==="hourly"?n.minute:0};return e==="hourly"?{kind:e,minute:s.minute}:e==="weekly"?{kind:e,day:(n==null?void 0:n.kind)==="weekly"?n.day:1,at:s}:e==="monthly"?{kind:e,date:(n==null?void 0:n.kind)==="monthly"?n.date:1,at:s}:{kind:e,at:s}}const D0=e=>String(e).padStart(2,"0"),zF=e=>`${D0(e.hour)}:${D0(e.minute)}`;function DF(e){const n=/^(\d{2}):(\d{2})/.exec(e);if(!n)return null;const s=Number(n[1]),r=Number(n[2]);return s<=23&&r<=59?{hour:s,minute:r}:null}var Lg={exports:{}},F0;function FF(){return F0||(F0=1,(function(e,n){(function(r,o){e.exports=o()})(globalThis,()=>(()=>{var s={6949(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.CronParser=void 0;var f=u(9515),g=(function(){function y(v,h,x){h===void 0&&(h=!0),x===void 0&&(x=!1),this.expression=v,this.dayOfWeekStartIndexZero=h,this.monthStartIndexZero=x}return y.prototype.parse=function(){var v,h,x=(v=this.expression)!==null&&v!==void 0?v:"";if(x==="@reboot")return h=["@reboot","","","","","",""],h;if(x.startsWith("@")){var b=this.parseSpecial(this.expression);h=this.extractParts(b)}else h=this.extractParts(this.expression);return this.normalize(h),this.validate(h),h},y.prototype.parseSpecial=function(v){var h={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},x=h[v];if(!x)throw new Error("Unknown special expression.");return x},y.prototype.extractParts=function(v){if(!this.expression)throw new Error("cron expression is empty");for(var h=v.trim().split(/[ ]+/),x=0;x<h.length;x++)if(h[x].includes(",")){var b=h[x].split(",").map(function(k){return k.trim()}).filter(function(k){return k!==""}).map(function(k){return isNaN(Number(k))?k:Number(k)}).filter(function(k){return k!==null&&k!==""});b.length===0&&b.push("*"),b.sort(function(k,E){return k!==null&&E!==null?k-E:0}),h[x]=b.map(function(k){return k!==null?k.toString():""}).join(",")}if(h.length<5)throw new Error("Expression has only ".concat(h.length," part").concat(h.length==1?"":"s",". At least 5 parts are required."));if(h.length==5)h.unshift(""),h.push("");else if(h.length==6){var j=/\d{4}$/.test(h[5])||h[4]=="?"||h[2]=="?";j?h.unshift(""):h.push("")}else if(h.length>7)throw new Error("Expression has ".concat(h.length," parts; too many!"));return h},y.prototype.normalize=function(v){var h=this;v[3]=v[3].replace("?","*"),v[5]=v[5].replace("?","*"),v[2]=v[2].replace("?","*"),v[0].indexOf("0/")==0&&(v[0]=v[0].replace("0/","*/")),v[1].indexOf("0/")==0&&(v[1]=v[1].replace("0/","*/")),v[2].indexOf("0/")==0&&(v[2]=v[2].replace("0/","*/")),v[3].indexOf("1/")==0&&(v[3]=v[3].replace("1/","*/")),!this.monthStartIndexZero&&v[4].indexOf("1/")==0&&(v[4]=v[4].replace("1/","*/")),v[6].indexOf("1/")==0&&(v[6]=v[6].replace("1/","*/")),v[5]=v[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function(_){var O=_.replace(/\D/,""),M=O;return h.dayOfWeekStartIndexZero?O=="7"&&(M="0"):M=(parseInt(O)-1).toString(),_.replace(O,M)}),v[5]=="L"&&(v[5]="6"),v[3]=="?"&&(v[3]="*");var x=/^\d{1,2}W[+-]\d{1,2}$/;if(v[3].indexOf("W")>-1&&(v[3].indexOf(",")>-1||/[-+]/.test(v[3]))&&!x.test(v[3]))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var b={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in b)v[5]=v[5].replace(new RegExp(j,"gi"),b[j].toString());v[4]=v[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(_){var O=_.replace(/\D/,""),M=O;return h.monthStartIndexZero&&(M=(parseInt(O)+1).toString()),_.replace(O,M)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var E in k)v[4]=v[4].replace(new RegExp(E,"gi"),k[E].toString());v[0]=="0"&&(v[0]=""),!/\*|\-|\,|\//.test(v[2])&&(/\*|\//.test(v[1])||/\*|\//.test(v[0]))&&(v[2]+="-".concat(v[2]));for(var N=0;N<v.length;N++)if(v[N].indexOf(",")!=-1&&(v[N]=v[N].split(",").filter(function(_){return _!==""}).join(",")||"*"),v[N]=="*/1"&&(v[N]="*"),v[N].indexOf("/")>-1&&!/^\*|\-|\,/.test(v[N])){var S=null;switch(N){case 4:S="12";break;case 5:S="6";break;case 6:S="9999";break;default:S=null;break}if(S!==null){var $=v[N].split("/");v[N]="".concat($[0],"-").concat(S,"/").concat($[1])}}},y.prototype.validate=function(v){var h="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(v[0],h),this.validateOnlyExpectedCharactersFound(v[1],h),this.validateOnlyExpectedCharactersFound(v[2],h),this.validateOnlyExpectedCharactersFound(v[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(v[4],h),this.validateOnlyExpectedCharactersFound(v[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(v[6],h),this.validateAnyRanges(v)},y.prototype.validateAnyRanges=function(v){v.forEach(function(h){return f.default.stepRange(h)}),f.default.secondRange(v[0]),f.default.minuteRange(v[1]),f.default.hourRange(v[2]),f.default.dayOfMonthRange(v[3]),f.default.monthRange(v[4],this.monthStartIndexZero),f.default.dayOfWeekRange(v[5],this.dayOfWeekStartIndexZero)},y.prototype.validateOnlyExpectedCharactersFound=function(v,h){var x=v.match(new RegExp("[^".concat(h,"]+"),"gi"));if(x&&x.length)throw new Error("Expression contains invalid values: '".concat(x.toString(),"'"))},y})();d.CronParser=g},8333(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.ExpressionDescriptor=void 0;var f=u(1823),g=u(6949),y=(function(){function v(h,x){if(this.expression=h,this.options=x,this.expressionParts=new Array(5),!this.options.locale&&v.defaultLocale&&(this.options.locale=v.defaultLocale),!v.locales[this.options.locale]){var b=Object.keys(v.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(b,"'.")),this.options.locale=b}this.i18n=v.locales[this.options.locale],x.use24HourTimeFormat===void 0&&(x.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return v.toString=function(h,x){var b=x===void 0?{}:x,j=b.throwExceptionOnParseError,k=j===void 0?!0:j,E=b.verbose,N=E===void 0?!1:E,S=b.dayOfWeekStartIndexZero,$=S===void 0?!0:S,_=b.monthStartIndexZero,O=_===void 0?!1:_,M=b.use24HourTimeFormat,P=b.trimHoursLeadingZero,A=P===void 0?!1:P,R=b.locale,L=R===void 0?null:R,W=b.logicalAndDayFields,U=W===void 0?!1:W,Y={throwExceptionOnParseError:k,verbose:N,dayOfWeekStartIndexZero:$,monthStartIndexZero:O,use24HourTimeFormat:M,trimHoursLeadingZero:A,locale:L,logicalAndDayFields:U};Y.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var D=new v(h,Y);return D.getFullDescription()},v.initialize=function(h,x){x===void 0&&(x="en"),v.specialCharacters=["/","-",",","*"],v.defaultLocale=x,h.load(v.locales)},v.prototype.getFullDescription=function(){var h,x,b="";try{var j=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((x=(h=this.i18n).atReboot)===null||x===void 0?void 0:x.call(h))||"Run once, at startup";var k=this.getTimeOfDayDescription(),E=this.getDayOfMonthDescription(),N=this.getMonthDescription(),S=this.getDayOfWeekDescription(),$=this.getYearDescription();b+=k+E+S+N+$,b=this.transformVerbosity(b,!!this.options.verbose),b=b.charAt(0).toLocaleUpperCase()+b.substr(1)}catch(_){if(!this.options.throwExceptionOnParseError)b=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(_)}return b},v.prototype.getTimeOfDayDescription=function(){var h=this.expressionParts[0],x=this.expressionParts[1],b=this.expressionParts[2],j="";if(!f.StringUtilities.containsAny(x,v.specialCharacters)&&!f.StringUtilities.containsAny(b,v.specialCharacters)&&!f.StringUtilities.containsAny(h,v.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(b,x,h);else if(!h&&x.indexOf("-")>-1&&!(x.indexOf(",")>-1)&&!(x.indexOf("/")>-1)&&!f.StringUtilities.containsAny(b,v.specialCharacters)){var k=x.split("-");j+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(b,k[0],""),this.formatTime(b,k[1],""))}else if(!h&&b.indexOf(",")>-1&&b.indexOf("-")==-1&&b.indexOf("/")==-1&&!f.StringUtilities.containsAny(x,v.specialCharacters)){var E=b.split(",");j+=this.i18n.at();for(var N=0;N<E.length;N++)j&&(j+=" "),j+=this.formatTime(E[N],x,""),N<E.length-2&&(j+=","),N==E.length-2&&(j+=this.i18n.spaceAnd())}else{var S=this.getSecondsDescription(),$=this.getMinutesDescription(),_=this.getHoursDescription();if(j+=S,j&&$&&(j+=", "),j+=$,$===_)return j;j&&_&&(j+=", "),j+=_}return j},v.prototype.getSecondsDescription=function(){var h=this,x=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(b){return b},function(b){return f.StringUtilities.format(h.i18n.everyX0Seconds(b),b)},function(b){return h.i18n.secondsX0ThroughX1PastTheMinute()},function(b){return b=="0"?"":parseInt(b)<20?h.i18n.atX0SecondsPastTheMinute(b):h.i18n.atX0SecondsPastTheMinuteGt20()||h.i18n.atX0SecondsPastTheMinute(b)},{min:0,max:59});return x},v.prototype.getMinutesDescription=function(){var h=this,x=this.expressionParts[0],b=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(k){return k},function(k){return f.StringUtilities.format(h.i18n.everyX0Minutes(k),k)},function(k){return h.i18n.minutesX0ThroughX1PastTheHour()},function(k){var E,N;try{return k=="0"&&b.indexOf("/")==-1&&x==""?h.i18n.everyHour():k=="0"?((N=(E=h.i18n).onTheHour)===null||N===void 0?void 0:N.call(E))||h.i18n.atX0MinutesPastTheHour(k):parseInt(k)<20?h.i18n.atX0MinutesPastTheHour(k):h.i18n.atX0MinutesPastTheHourGt20()||h.i18n.atX0MinutesPastTheHour(k)}catch{return h.i18n.atX0MinutesPastTheHour(k)}},{min:0,max:59});return j},v.prototype.getHoursDescription=function(){var h=this,x=this.expressionParts[2],b=0,j=[];x.split("/")[0].split(",").forEach(function(N){var S=N.split("-");S.length===2&&j.push({value:S[1],index:b+1}),b+=S.length});var k=0,E=this.getSegmentDescription(x,this.i18n.everyHour(),function(N){var S=j.find(function(_){return _.value===N&&_.index===k}),$=S&&h.expressionParts[1]!=="0";return k++,$?h.formatTime(N,"59",""):h.formatTime(N,"0","")},function(N){return f.StringUtilities.format(h.i18n.everyX0Hours(N),N)},function(N){return h.i18n.betweenX0AndX1()},function(N){return h.i18n.atX0()},{min:0,max:23});return E},v.prototype.getDayOfWeekDescription=function(){var h=this,x=this.i18n.daysOfTheWeek(),b=null;return this.expressionParts[5]=="*"?b="":b=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,k){var E=j;j.indexOf("#")>-1?E=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&(E=E.replace("L",""));var N=parseInt(E),S=h.i18n.daysOfTheWeekInCase?h.i18n.daysOfTheWeekInCase(k)[N]:x[N];if(j.indexOf("#")>-1){var $=null,_=j.substring(j.indexOf("#")+1),O=j.substring(0,j.indexOf("#"));switch(_){case"1":$=h.i18n.first(O);break;case"2":$=h.i18n.second(O);break;case"3":$=h.i18n.third(O);break;case"4":$=h.i18n.fourth(O);break;case"5":$=h.i18n.fifth(O);break}S=$+" "+S}return S},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0DaysOfTheWeek(j),j)},function(j){var k=j.substring(0,j.indexOf("-")),E=h.expressionParts[3]!="*";return E?h.i18n.commaAndX0ThroughX1(k):h.i18n.commaX0ThroughX1(k)},function(j){var k=null;if(j.indexOf("#")>-1){var E=j.substring(j.indexOf("#")+1),N=j.substring(0,j.indexOf("#"));k=h.i18n.commaOnThe(E,N).trim()+h.i18n.spaceX0OfTheMonth()}else if(j.indexOf("L")>-1)k=h.i18n.commaOnTheLastX0OfTheMonth(j.replace("L",""));else{var S=h.expressionParts[3]!="*";S?h.options.logicalAndDayFields?k=h.i18n.commaOnlyOnX0(j):k=h.i18n.commaAndOnX0():k=h.i18n.commaOnlyOnX0(j)}return k}),b},v.prototype.getMonthDescription=function(){var h=this,x=this.i18n.monthsOfTheYear(),b=this.getSegmentDescription(this.expressionParts[4],"",function(j,k){return k&&h.i18n.monthsOfTheYearInCase?h.i18n.monthsOfTheYearInCase(k)[parseInt(j)-1]:x[parseInt(j)-1]},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0Months(j),j)},function(j){return h.i18n.commaMonthX0ThroughMonthX1()||h.i18n.commaX0ThroughX1()},function(j){return h.i18n.commaOnlyInMonthX0?h.i18n.commaOnlyInMonthX0():h.i18n.commaOnlyInX0()});return b},v.prototype.getDayOfMonthDescription=function(){var h=this,x,b,j,k,E=null,N=this.expressionParts[3];switch(N){case"L":E=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":E=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var S=N.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(S){var $=parseInt(S[1]||S[2]),_=$==1?this.i18n.firstWeekday():f.StringUtilities.format(this.i18n.weekdayNearestDayX0(),$.toString()),O=S[4];O?S[3]=="-"?E=f.StringUtilities.format(((b=(x=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||b===void 0?void 0:b.call(x,O))||", %s days before the %s of the month",O,_):E=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,O))||", %s days after the %s of the month",O,_):E=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),_);break}else{var M=N.match(/L-(\d{1,2})/);if(M){var P=M[1];E=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(P),P);break}else{if(N=="*"&&this.expressionParts[5]!="*")return"";E=this.getSegmentDescription(N,this.i18n.commaEveryDay(),function(A){return A=="L"?h.i18n.lastDay():h.i18n.dayX0?f.StringUtilities.format(h.i18n.dayX0(),A):A},function(A){return A=="1"?h.i18n.commaEveryDay():h.i18n.commaEveryX0Days(A)},function(A){return h.i18n.commaBetweenDayX0AndX1OfTheMonth(A)},function(A){return h.i18n.commaOnDayX0OfTheMonth(A)})}break}}return E},v.prototype.getYearDescription=function(){var h=this,x=this.getSegmentDescription(this.expressionParts[6],"",function(b){return/^\d+$/.test(b)?new Date(parseInt(b),1).getFullYear().toString():b},function(b){return f.StringUtilities.format(h.i18n.commaEveryX0Years(b),b)},function(b){return h.i18n.commaYearX0ThroughYearX1()||h.i18n.commaX0ThroughX1()},function(b){return h.i18n.commaOnlyInYearX0?h.i18n.commaOnlyInYearX0():h.i18n.commaOnlyInX0()});return x},v.prototype.getSegmentDescription=function(h,x,b,j,k,E,N){var S=null,$=h.indexOf("/")>-1,_=h.indexOf("-")>-1,O=h.indexOf(",")>-1;if(!h)S="";else if(h==="*")S=x;else if(!$&&!_&&!O)S=f.StringUtilities.format(E(h),b(h));else if(O){for(var M=h.split(","),P="",A=this.i18n.spaceAnd(),R=0;R<M.length;R++)if(R>0&&M.length>2&&(P+=",",R<M.length-1&&(P+=" ")),R>0&&M.length>1&&(R==M.length-1||M.length==2)&&(P+=A==","&&M.length>2?" ":"".concat(A," ")),M[R].indexOf("/")>-1||M[R].indexOf("-")>-1){var L=M[R].indexOf("-")>-1&&M[R].indexOf("/")==-1,W=this.getSegmentDescription(M[R],x,b,j,L?this.i18n.commaX0ThroughX1:k,E);L?W=W.replace(", ",""):R>0&&W.startsWith(", ")&&(W=W.substring(2)),P+=W}else if(!$)P+=b(M[R]);else{var U=this.getSegmentDescription(M[R],x,b,j,k,E);R>0&&U&&U.startsWith(", ")&&(U=U.substring(2)),P+=U}$?S=P:S=f.StringUtilities.format(E(h),P)}else if($){var M=h.split("/");if(S=f.StringUtilities.format(j(M[1]),M[1]),M[0].indexOf("-")>-1){var Y=this.generateRangeSegmentDescription(M[0],k,b);Y.indexOf(", ")!=0&&(S+=", "),S+=Y}else if(M[0].indexOf("*")==-1){var D=f.StringUtilities.format(E(M[0]),b(M[0]));D=D.replace(", ",""),S+=f.StringUtilities.format(this.i18n.commaStartingX0(),D)}S+=this.getWrappingIncrementDescription(h,N,x,b,j,k,E)}else _&&(S=this.generateRangeSegmentDescription(h,k,b));return S},v.prototype.getWrappingIncrementDescription=function(h,x,b,j,k,E,N){if(!this.options.verbose||!x)return"";var S=h.split("/"),$=S[0],_=S[1],O=parseInt(_),M=x.max-x.min+1,P=$==="*",A=Number.isInteger(O)&&O>1,R=A&&M%O===0;if(!P||!A||R)return"";for(var L=[],W=x.min;W<=x.max;W+=O)L.push(W);if(L.length<2)return"";var U=this.getSegmentDescription(L.join(","),b,j,k,E,N);return U?", ".concat(U):""},v.prototype.generateRangeSegmentDescription=function(h,x,b){var j="",k=h.split("-"),E=b(k[0],1),N=b(k[1],2),S=x(h);return j+=f.StringUtilities.format(S,E,N),j},v.prototype.formatTime=function(h,x,b){var j=0,k=0,E=parseInt(h)+j,N=parseInt(x)+k;N>=60?(N-=60,E+=1):N<0&&(N+=60,E-=1),E>=24?E=E-24:E<0&&(E=24+E);var S="",$=!1;this.options.use24HourTimeFormat||($=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),S=$?"".concat(this.getPeriod(E)," "):" ".concat(this.getPeriod(E)),E>12&&(E-=12),E===0&&(E=12));var _="";b&&(_=":".concat(("00"+b).substring(b.length)));var O=E.toString(),M=("00"+O).substring(O.length),P=N.toString(),A=("00"+P).substring(P.length),R=this.options.trimHoursLeadingZero?O:M;return"".concat($?S:"").concat(R,":").concat(A).concat(_).concat($?"":S)},v.prototype.transformVerbosity=function(h,x){if(!x&&(h=h.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),h=h.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),h=h.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),h=h.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var b=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());b<j.length;b++){var k=j[b],E=k[0],N=k[1];h=h.replace(new RegExp(E,"g"),N)}return h},v.prototype.getPeriod=function(h){return h>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},v.locales={},v})();d.ExpressionDescriptor=y},3747(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.enLocaleLoader=void 0;var f=u(9486),g=(function(){function y(){}return y.prototype.load=function(v){v.en=new f.en},y})();d.enLocaleLoader=g},9486(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.en=void 0;var u=function(g){return Number(g)===1},f=(function(){function g(){}return g.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},g.prototype.atX0MinutesPastTheHourGt20=function(){return null},g.prototype.commaMonthX0ThroughMonthX1=function(){return null},g.prototype.commaYearX0ThroughYearX1=function(){return null},g.prototype.use24HourTimeFormatByDefault=function(){return!1},g.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},g.prototype.everyMinute=function(){return"every minute"},g.prototype.everyHour=function(){return"every hour"},g.prototype.atSpace=function(){return"At "},g.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},g.prototype.at=function(){return"At"},g.prototype.spaceAnd=function(){return" and"},g.prototype.everySecond=function(){return"every second"},g.prototype.everyX0Seconds=function(y){return u(y)?"every %s second":"every %s seconds"},g.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},g.prototype.atX0SecondsPastTheMinute=function(y){return u(y)?"at %s second past the minute":"at %s seconds past the minute"},g.prototype.everyX0Minutes=function(y){return u(y)?"every %s minute":"every %s minutes"},g.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},g.prototype.atX0MinutesPastTheHour=function(y){return u(y)?"at %s minute past the hour":"at %s minutes past the hour"},g.prototype.everyX0Hours=function(y){return u(y)?"every %s hour":"every %s hours"},g.prototype.betweenX0AndX1=function(){return"between %s and %s"},g.prototype.atX0=function(){return"at %s"},g.prototype.commaEveryDay=function(){return", every day"},g.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},g.prototype.commaX0ThroughX1=function(){return", %s through %s"},g.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},g.prototype.first=function(){return"first"},g.prototype.second=function(){return"second"},g.prototype.third=function(){return"third"},g.prototype.fourth=function(){return"fourth"},g.prototype.fifth=function(){return"fifth"},g.prototype.commaOnThe=function(){return", on the "},g.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},g.prototype.lastDay=function(){return"the last day"},g.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},g.prototype.commaOnlyOnX0=function(){return", only on %s"},g.prototype.commaAndOnX0=function(){return", and on %s"},g.prototype.commaEveryX0Months=function(){return", every %s months"},g.prototype.commaOnlyInX0=function(){return", only in %s"},g.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},g.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},g.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(y){return u(y)?", %s day before the last day of the month":", %s days before the last day of the month"},g.prototype.firstWeekday=function(){return"first weekday"},g.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},g.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},g.prototype.commaDaysBeforeTheX0OfTheMonth=function(y){return u(y)?", %s day before the %s of the month":", %s days before the %s of the month"},g.prototype.commaDaysAfterTheX0OfTheMonth=function(y){return u(y)?", %s day after the %s of the month":", %s days after the %s of the month"},g.prototype.commaEveryX0Days=function(){return", every %s days in a month"},g.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},g.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},g.prototype.commaEveryHour=function(){return", every hour"},g.prototype.commaEveryX0Years=function(y){return u(y)?", every %s year":", every %s years"},g.prototype.commaStartingX0=function(){return", starting %s"},g.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},g.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},g.prototype.atReboot=function(){return"Run once, at startup"},g.prototype.onTheHour=function(){return"on the hour"},g})();d.en=f},9515(c,d){Object.defineProperty(d,"__esModule",{value:!0});function u(y,v){if(!y)throw new Error(v)}function f(y){var v=[];if(!isNaN(parseInt(y,10))){v.push(parseInt(y,10));var h=y.match(/^\d+-(-?\d+)/);h&&v.push(parseInt(h[1],10))}return v}var g=(function(){function y(){}return y.stepRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++){var b=h[x].split("/")[1];u(b===void 0||!/^0+$/.test(b),"step value must be greater than 0")}},y.secondRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=0&&k<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=0&&k<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=0&&k<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=1&&k<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(v,h){for(var x=v.split(","),b=0;b<x.length;b++)for(var j=0,k=f(x[b]);j<k.length;j++){var E=k[j];u(E>=1&&E<=12,h?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(v,h){for(var x=v.split(","),b=0;b<x.length;b++){if(x[b].indexOf("#")>-1){var j=x[b].substring(x[b].indexOf("#")+1);u(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var k=0,E=f(x[b]);k<E.length;k++){var N=E[k];u(N>=0&&N<=6,h?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},y})();d.default=g},1823(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.StringUtilities=void 0;var u=(function(){function f(){}return f.format=function(g){for(var y=[],v=1;v<arguments.length;v++)y[v-1]=arguments[v];return g.replace(/%s/g,function(h){return y.shift()})},f.containsAny=function(g,y){return y.some(function(v){return g.indexOf(v)>-1})},f})();d.StringUtilities=u}},r={};function o(c){var d=r[c];if(d!==void 0)return d.exports;var u=r[c]={exports:{}};return s[c](u,u.exports,o),u.exports}var i={};return(()=>{var c=i;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var d=o(8333),u=o(3747);d.ExpressionDescriptor.initialize(new u.enLocaleLoader),c.default=d.ExpressionDescriptor;var f=d.ExpressionDescriptor.toString;c.toString=f})(),i})())})(Lg)),Lg.exports}var UF=FF();const WF=YN(UF),Bd={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},Rn=Bd,lE={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},HF=Object.keys(lE);let BF=0;const dh=()=>`r${++BF}`,qF=()=>({key:dh(),pointer:"",op:"in",value:""}),cE=()=>({key:dh(),event:"",actions:"",where:[]});function dE(e){const n=e.trim();try{return JSON.parse(n)}catch{return n}}function uE(e){return typeof e!="string"?JSON.stringify(e):e!==""&&e===e.trim()&&!/[,\r\n]/.test(e)&&dE(e)===e?e:JSON.stringify(e)}const GF=e=>"in"in e?`${e.pointer} is one of ${e.in.map(uE).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"exists":"is missing"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,qo=(e,n=!0)=>{var s,r;return`${e.event}${(s=e.actions)!=null&&s.length?` (${e.actions.join(", ")})`:""}${n&&((r=e.where)!=null&&r.length)?` where ${e.where.map(GF).join(" and ")}`:""}`};function fE(e){return"in"in e?{pointer:e.pointer,op:"in",value:e.in.map(uE).join(`
648
+ `)}:"exists"in e?{pointer:e.pointer,op:e.exists?"exists":"missing",value:""}:{pointer:e.pointer,op:"prefix",value:e.prefix}}const mE=e=>({key:dh(),...fE(e),was:e}),hE=e=>{if(!e.was)return!1;const n=fE(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},pE=e=>(e??[]).join(", "),mm=e=>({key:dh(),event:e.event,actions:pE(e.actions),where:(e.where??[]).map(mE),was:e}),KF=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),VF=e=>e.split(/[\s,]+/).filter(Boolean),U0=/^[!-~]+$/,Vc=e=>[...e].length,YF=/^(\/([^~]|~[01])*)?$/;function QF(e,n,s){return e.length>Rn.conditions&&(s[`${n}.where`]=`At most ${Rn.conditions} conditions a rule.`),e.map((r,o)=>{if(hE(r))return r.was;const i=`${n}.where[${o}]`,c=r.pointer;if(c?c.startsWith("/")?YF.test(c)?Vc(c)>Rn.pointer&&(s[`${i}.pointer`]=`At most ${Rn.pointer} characters.`):s[`${i}.pointer`]="Write ~ in a field's name as ~0, and / in it as ~1.":s[`${i}.pointer`]="A field starts with /: /title, /issue/labels/0/name.":s[`${i}.pointer`]="Name a field: a JSON pointer such as /title.",r.op==="exists"||r.op==="missing")return{pointer:c,exists:r.op==="exists"};if(r.op==="prefix"){const u=r.value.trimStart();return u?Vc(u)>Rn.text&&(s[`${i}.prefix`]=`At most ${Rn.text} characters.`):s[`${i}.prefix`]="Give the text it starts with.",{pointer:c,prefix:u}}const d=r.value.split(/\r\n|\r|\n/).filter(u=>u.trim()).map(dE);return d.length?d.length>Rn.list?s[`${i}.in`]=`At most ${Rn.list} values.`:d.some(u=>Vc(JSON.stringify(u))>Rn.value)&&(s[`${i}.in`]=`Each value is at most ${Rn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:c,in:d}})}function JF(e,n,s){var g;const r=`source.accept[${n}]`,o=e.was,i=o&&e.event===o.event?o.event:e.event.trim();i?i!==(o==null?void 0:o.event)&&(!U0.test(i)||Vc(i)>Rn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${Rn.text}.`):s[`${r}.event`]="Name the event.";const c=o&&(typeof e.actions=="string"?e.actions===pE(o.actions):KF(e.actions,o.actions??[])),d=c?[...o.actions??[]]:typeof e.actions=="string"?VF(e.actions):e.actions;if(o&&c&&i===o.event&&e.where.length===(((g=o.where)==null?void 0:g.length)??0)&&e.where.every((y,v)=>hE(y)&&y.was===o.where[v]))return o;d.length>Rn.list?s[`${r}.actions`]=`At most ${Rn.list} actions.`:d.some(y=>!U0.test(y)||Vc(y)>Rn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${Rn.text}.`);const f=QF(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function Rb(e){const n={};return e.length>Rn.rules&&(n["source.accept"]=`At most ${Rn.rules} rules.`),{accept:e.map((s,r)=>JF(s,r,n)),issues:n}}function qd(e){const n=new Set(["source.accept"]);return e.forEach((s,r)=>{const o=`source.accept[${r}]`;for(const i of["",".event",".actions",".where"])n.add(`${o}${i}`);for(let i=0;i<s;i++)for(const c of["",".pointer",".in",".prefix",".exists"])n.add(`${o}.where[${i}]${c}`)}),n}const Xi=(e,n)=>n&&e===Ox(n)?n:l8(e),Pl=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",gE=(e="")=>({name:"",kind:"cron",cron:"",timezone:Pl(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),uh={seconds:1,minutes:60,hours:3600};function Ab(e){const[n,s]=e%3600===0?[e/3600,"hour"]:e%60===0?[e/60,"minute"]:[e,"second"];return n===1?s:`${n} ${s}s`}function xE(e){try{return WF.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Ua=e=>String(e).padStart(2,"0"),hm=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function vE(e,n){const s=i=>{var c;return((c=new Intl.DateTimeFormat(i,{timeZone:n,timeZoneName:"short"}).formatToParts(e).find(d=>d.type==="timeZoneName"))==null?void 0:c.value)??n},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const o=s("en-GB");return/^GMT[+-]/.test(o)?r:o}const W0=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${hm(s,n)} ${vE(s,n)}`};function H0(e,{zone:n=Pl(),now:s=Date.now()}={}){const r=new Date(e),o=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:n});return`Pick a time in the future: ${o(r)===o(new Date(s))?`${hm(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${hm(r,n)} ${vE(r,n)}`} has already passed.`}function pm(e,n){const s={};for(const{type:r,value:o}of new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(e))s[r]=o;return Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),Number(s.hour),Number(s.minute))}function XF(e,n,s,r){const o=new Date(pm(e,n)),i=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),s,r);let c=i;for(let d=0;d<2;d++)c+=i-pm(new Date(c),n);return new Date(c)}const ZF=e=>{const n=e.trim().split(/\s+/);return n.length!==5||!/^\d{1,2}$/.test(n[0])||!/^\d{1,2}$/.test(n[1])?null:{minute:Number(n[0]),hour:Number(n[1]),days:n.slice(2).some(s=>s!=="*"&&s!=="?")}};function e8(e,n,s,r,o){const i=xE(e),c=n!==s,d=ZF(e),u=d&&`At ${Ua(d.hour)}:${Ua(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??XF(o,n,d.hour,d.minute),g=d.days?Math.floor(pm(f,s)/864e5)-Math.floor(pm(f,n)/864e5):0,y=g>0?" the next day":g<0?" the day before":"";return`At ${hm(f,s)} your time${y}${c?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${c?` (${n})`:""}`}function Ob(e,n,{zone:s=Pl(),instead:r,now:o=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${W0(n,s)}`:" · no next time";return"cron"in e?`${e8(e.cron,e.timezone,s,n?new Date(n):null,new Date(o))}${i}`:"at"in e?`Once, ${W0(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${Ab(e.every_s)}${i}`}const ma=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,t8=e=>`${ma(e)} a run`,n8=(e,n)=>typeof e=="number"?t8(e):typeof n=="number"&&n>0?`Agent's default (${ma(n)})`:"Agent's default";function Mb(e,n,s=[]){if(e.source.kind!=="schedule"||!("at"in e.source)||e.next_at!==null)return null;const r=Date.parse(e.source.at);if(r>n)return null;const o=[e.last_firing,...s].find(i=>i&&i.status==="started"&&Date.parse(i.nominal_at)===r);return o?{ran:o}:{passed:e.source.at}}const Lb=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",Pb=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",bE=e=>e.source.kind==="github"&&e.target.kind==="start_run",fh=[{event:"pull_request",action:"opened",label:"A pull request is opened"},{event:"pull_request",action:"synchronize",label:"A pull request gets new commits"},{event:"pull_request",action:"reopened",label:"A pull request is reopened"},{event:"issue_comment",action:"created",label:"Someone comments on an issue or pull request"}],dd=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,Ib="This server's address as this page sees it: behind a proxy, use its public address.",Ax={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},yE=e=>{var n;return(n=e.accept)!=null&&n.length?`Only signed requests for ${e.accept.map(s=>qo(s,!1)).join(" or ")}`:"On each signed request"},s8={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event",composio:"On an app event",email:"On an email",feed:"On a feed item"},wE=e=>`On ${e.event} from ${e.server}`,r8=e=>{var n;return(n=e.accept)!=null&&n.length?`On email in ${e.mailbox} for ${e.accept.map(s=>qo(s,!1)).join(" or ")}`:`On each email in ${e.mailbox}`},jE=e=>{var s;const n=e.urls.length===1?o8(e.urls[0]):`${e.urls.length} feeds`;return(s=e.accept)!=null&&s.length?`On items in ${n} for ${e.accept.map(r=>qo(r,!1)).join(" or ")}`:`On each new item in ${n}`},o8=e=>{try{return new URL(e).host}catch{return e}},kE=e=>`On GitHub ${e.accept.map(n=>qo(n,!1)).join(" or ")}`;function gm(e,n){const s=e.disabled;return s?s.reason==="source_unreadable"?`Turned off: its source can't be read (${s.detail}).`:s.reason!=="auto_paused"?`Turned off: ${s.detail}`:n?`Turned off after ${n} failures in a row.`:"Turned off after failures in a row.":null}function NE(e){var s;const n=(r,o)=>o?`${r}: ${o}`:r;switch(e.status){case"started":return"Started";case"skipped":return n("Skipped",e.reason);case"missed":return n(`Missed ${e.count??1} ${e.count===1||e.count===void 0?"time":"times"}`,e.reason);case"failed":return n("Failed",((s=e.error)==null?void 0:s.message)??e.reason);case"due":return e.retry_at?`Due: the server was full, tries again at ${ti(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const a8={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},i8=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function l8(e){if(!i8.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function Ox(e){const n=new Date(e);return`${n.getFullYear()}-${Ua(n.getMonth()+1)}-${Ua(n.getDate())}T${Ua(n.getHours())}:${Ua(n.getMinutes())}${n.getSeconds()?`:${Ua(n.getSeconds())}`:""}`}const B0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function zb(e){const n=Ab(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const ud="A number is needed.",fd=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function q0(e,n=!1){var i,c;const s={};let r;if(e.kind==="cron")e.cron.trim()||(s["source.cron"]="Pick when it runs."),r={kind:"schedule",cron:e.cron.trim(),timezone:e.timezone.trim()||Pl()};else if(e.kind==="at"){const d=Xi(e.at,(i=e.read)==null?void 0:i.at);d===null&&(s["source.at"]="A time is needed."),r={kind:"schedule",at:d??""}}else{const d=fd(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=ud):s["source.every_s"]="A number is needed.";const u=e.startAt?Xi(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*uh[e.everyUnit]),...u?{start_at:u}:{}}}e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const o=fd(e.maxCost);return e.maxCost.trim()?o===void 0&&(s["target.max_cost_usd"]=ud):n||(s["target.max_cost_usd"]="A cost cap is needed: every run a schedule starts is capped."),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},enabled:e.enabled,source:r,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...o!==void 0?{max_cost_usd:o}:{}}}}}const c8=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function SE(e,n){const{accept:s,issues:r}=Rb(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function d8(e,n=!1){const{source:s,issues:r}=SE({signature:e.signature},e.accept);return hh(e,s,r,n,"a webhook")}const u8=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),CE=[...new Set(fh.map(e=>e.event))],f8=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function mh(e){var i;const s=[...CE.flatMap(c=>{var f;const d=fh.filter(g=>g.event===c&&e.events.includes(`${g.event}:${g.action}`)).map(g=>g.action);if(!d.length)return[];const u=(f=e.read)==null?void 0:f.rules[c];return[{id:`event:${c}`,event:c,actions:u!=null&&u.actions&&f8(d,u.actions)?[...u.actions]:d,where:e.where[c]??[],...u?{was:u}:{}}]}),...e.other.map(c=>({...c,id:`other:${c.key}`}))],r=((i=e.read)==null?void 0:i.order)??[],o=c=>{const d=r.indexOf(c.id);return d<0?r.length:d};return s.map((c,d)=>({r:c,i:d})).sort((c,d)=>o(c.r)-o(d.r)||c.i-d.i).map(({r:c})=>c)}function EE(e){const{accept:n,issues:s}=Rb(mh(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function m8(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const o=fh.filter(c=>c.event===r.event).map(c=>c.action);if(!(!!((s=r.actions)!=null&&s.length)&&r.actions.every(c=>o.includes(c))&&new Set(r.actions).size===r.actions.length&&!(r.event in n.where))){const c=mm(r);n.other.push(c),n.read.order.push(`other:${c.key}`);continue}n.events.push(...r.actions.map(c=>`${r.event}:${c}`)),n.where[r.event]=(r.where??[]).map(mE),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const Db=e=>e.source.kind==="composio"&&e.target.kind==="start_run";function h8(e,n=[]){const s=(e==null?void 0:e.properties)??{},r=new Set(Array.isArray(e==null?void 0:e.required)?e.required.filter(o=>typeof o=="string"):[]);return Object.entries(s).filter(([,o])=>o&&typeof o=="object"&&o.deprecated!==!0).map(([o,i])=>{const c=(Array.isArray(i.type)?i.type:[i.type]).filter(g=>g!=="null"),d=c.length===1&&["string","number","integer","boolean"].includes(String(c[0]))?c[0]:"json",u=d==="string"&&Array.isArray(i.enum)&&i.enum.every(g=>typeof g=="string")?i.enum:void 0,f=i.default===void 0?d==="boolean"?"false":"":d==="json"?JSON.stringify(i.default):String(i.default);return{name:o,title:typeof i.title=="string"&&i.title.trim()?i.title:o,...typeof i.description=="string"&&i.description.trim()?{description:i.description}:{},required:r.has(o),type:d,...u?{options:u}:{},initial:f,...n.includes(o)?{sealed:!0}:{}}})}function p8(e,n,s){const r={};for(const o of e){const i=(n[o.name]??o.initial).trim(),c=`source.config.${o.name}`;if(!i){o.required&&(s[c]=`${o.title} is required.`);continue}if(o.type==="boolean")r[o.name]=i==="true";else if(o.type==="number"||o.type==="integer"){const d=fd(i);d===void 0||o.type==="integer"&&!Number.isInteger(d)?s[c]=o.type==="integer"?"A whole number is needed.":ud:r[o.name]=d}else if(o.type==="json")try{r[o.name]=JSON.parse(i)}catch{s[c]="Give it as JSON."}else r[o.name]=i}return r}const g8=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function Fb(e,n,s=[],r){var i;const o=n.length||r&&!((i=r.where)!=null&&i.length)?[{event:e,actions:"",where:n,...r?{was:r}:{}}]:[];return Rb([...o,...s])}function x8(e,n,s=[],r){const{accept:o,...i}=e,{accept:c,issues:d}=Fb(e.event,n,s,r);return{source:{...i,...c.length?{accept:c}:{}},issues:d}}function v8(e,n,s=!1){const r={};e.server||(r["source.server"]="Pick a Composio server."),e.event||(r["source.event"]="Pick an event.");const o=e.event?p8(n,e.config,r):{},{accept:i,issues:c}=Fb(e.event,e.where);Object.assign(r,c);const d={kind:"composio",server:e.server,event:e.event,config:o,...i.length?{accept:i}:{}};return hh(e,d,r,s,"a trigger")}const $E=e=>e.source.kind==="feed"&&e.target.kind==="start_run",Mx=20,_E=900,b8="item",TE=()=>({name:"",urls:"",every:"15",everyUnit:"minutes",items:"",id:"",where:[],others:[],agentId:"",content:"",maxCost:""});function y8(e){const n=e.source,s=n.every_s??_E,r=s%3600===0?"hours":s%60===0?"minutes":"seconds",o=(n.accept??[]).map(mm),i=o[0]&&!o[0].actions.trim()?o[0]:null;return{...TE(),urls:n.urls.join(`
649
+ `),every:String(s/uh[r]),everyUnit:r,items:n.items??"",id:n.id??"",where:(i==null?void 0:i.where)??[],others:o.slice(i?1:0),read:n}}const w8=e=>{try{return new URL(e)}catch{return null}};function RE(e){const n=e.split(/\r\n|\r|\n/).map(r=>r.trim()).filter(Boolean),s={};return n.length?n.length>Mx?s["source.urls"]=`${Mx} feeds at most: this has ${n.length}.`:n.forEach((r,o)=>{const i=w8(r);!i||i.protocol!=="http:"&&i.protocol!=="https:"||!i.hostname?s[`source.urls[${o}]`]=`${r} isn't an http or https URL.`:i.username||i.password?s[`source.urls[${o}]`]=`${i.host}'s URL holds a user or password: leave it out.`:n.indexOf(r)<o&&(s[`source.urls[${o}]`]=`${r} is here twice: each feed is read once.`)}):s["source.urls"]="Add a feed's URL, one a line.",{urls:n,issues:s}}function AE(e,n){var f,g,y,v,h;const{urls:s,issues:r}=RE(e.urls),o=fd(e.every),i=Math.round((o??0)*uh[e.everyUnit]);o===void 0?r["source.every_s"]=ud:n&&i<n&&(r["source.every_s"]=zb(n));const c=x=>{var j;const b=e[x];return b||((j=e.read)==null?void 0:j[x])===""?{[x]:b}:{}},{accept:d,issues:u}=Fb(b8,e.where,e.others,(g=(f=e.read)==null?void 0:f.accept)!=null&&g[0]&&!((y=e.read.accept[0].actions)!=null&&y.length)?e.read.accept[0]:void 0);return Object.assign(r,u),{source:{kind:"feed",urls:s,every_s:i,...c("items"),...c("id"),...((v=e.read)==null?void 0:v.updated)!==void 0?{updated:e.read.updated}:{},...(h=e.read)!=null&&h.fields?{fields:e.read.fields}:{},...d.length?{accept:d}:{}},issues:r}}function j8(e,n,s=!1){const{source:r,issues:o}=AE(e,n);return hh(e,r,o,s,"a feed trigger")}function k8(e,n){return new Set(["name","source.urls",...Array.from({length:e},(s,r)=>`source.urls[${r}]`),"source.every_s","source.items","source.id","target.agent_id","target.input","target.max_cost_usd",...qd(n)])}function N8(e,n=!1){const{source:s,issues:r}=EE(e);return hh(e,s,r,n,"a GitHub trigger")}function hh(e,n,s,r,o){e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const i=fd(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=ud):r||(s["target.max_cost_usd"]=`A cost cap is needed: every run ${o} starts is capped.`),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},source:n,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...i!==void 0?{max_cost_usd:i}:{}}}}}function S8(e){const n=e.source,s="cron"in n?n.timezone:Pl(),r={...gE(e.target.agent_id),name:e.name,timezone:s,content:typeof e.target.input.content=="string"?e.target.input.content:"",maxCost:typeof e.target.max_cost_usd=="number"?String(e.target.max_cost_usd):"",enabled:e.enabled};if("cron"in n)return{...r,kind:"cron",cron:n.cron};if("at"in n)return{...r,kind:"at",at:Ox(n.at),read:{at:n.at}};const o=n.every_s%3600===0?"hours":n.every_s%60===0?"minutes":"seconds";return{...r,kind:"every",every:String(n.every_s/uh[o]),everyUnit:o,startAt:Ox(n.start_at),read:{startAt:n.start_at}}}const md=(e,n)=>{if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const[s,r]=[Object.keys(e),Object.keys(n)];return s.length===r.length&&s.every(o=>md(e[o],n[o]))};function G0(e,n){const s=n.source&&"every_s"in n.source&&!n.source.start_at&&"every_s"in e.source?{...n.source,start_at:e.source.start_at}:n.source,r=n.target&&{...n.target,input:{...e.target.input,...n.target.input},...e.target.effort!==void 0&&n.target.effort===void 0?{effort:e.target.effort}:{}};return{...n.name!==void 0&&n.name!==e.name?{name:n.name}:{},...s&&!md(s,e.source)?{source:s}:{},...r&&!md(r,e.target)?{target:r}:{}}}const C8=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function Il(e){var r;if(!(e instanceof Ue))return{fields:{},rest:[e instanceof Error?e.message:String(e)]};if(e.status!==422||!((r=e.fields)!=null&&r.length))return{fields:{},rest:[`${e.code}: ${e.message}`]};const n={},s=[];for(const o of e.fields){const i=o.field.startsWith("target.input")?"target.input":o.field;(C8.includes(i)||i.startsWith("source.accept")||i==="source.server"||i==="source.event"||i==="source.config"||i.startsWith("source.config.")||/^source\.urls(\[\d+\])?$/.test(i)||i==="source.items"||i==="source.id")&&!n[i]?n[i]=o.message:s.push(o.message)}return{fields:n,rest:s}}const E8=[{value:"hourly",label:"Every hour"},{value:"daily",label:"Every day"},{value:"weekdays",label:"Every weekday (Monday to Friday)"},{value:"weekly",label:"Every week"},{value:"monthly",label:"Every month"},{value:"custom",label:"Custom schedule"}],$8=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),_8=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),T8=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function OE({value:e,onChange:n,label:s,name:r}){const o=LF(e),[i,c]=p.useState(()=>e.trim()!==""&&!o),d=p.useId(),u=i||e.trim()!==""&&!o,f=v=>n(PF(v)),g=v=>{if(v==="custom"){c(!0);return}c(!1),f(IF(v,o))},y=o&&"at"in o?o.at:null;return t.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Mt,{label:s,className:"min-w-56 flex-1",value:u?"custom":(o==null?void 0:o.kind)??"",onChange:g,placeholder:"Pick when it runs",options:E8}),!u&&(o==null?void 0:o.kind)==="weekly"&&t.jsx(Mt,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(o.day),onChange:v=>f({...o,day:Number(v)}),options:$8}),!u&&(o==null?void 0:o.kind)==="monthly"&&t.jsx(Mt,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(o.date),onChange:v=>f({...o,date:Number(v)}),options:_8}),!u&&(o==null?void 0:o.kind)==="hourly"&&t.jsx(Mt,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(o.minute),onChange:v=>f({...o,minute:Number(v)}),options:T8}),!u&&o&&y&&t.jsx(De,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:zF(y),onChange:v=>{const h=DF(v.target.value);h&&f({...o,at:h})}})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(De,{id:`${d}-line`,name:r,"aria-label":"Custom schedule",value:e,onChange:v=>n(v.target.value),placeholder:"30 1 * * *",spellCheck:!1}),t.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?xE(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const K0=Intl.supportedValuesOf,Ef=typeof K0=="function"?K0("timeZone"):[],$f=Ef.length&&!Ef.includes("UTC")?["UTC",...Ef]:Ef;function ME({value:e,onChange:n,label:s,name:r,id:o,className:i}){if(!$f.length)return t.jsx(De,{id:o,name:r,"aria-label":s,className:i,value:e,onChange:d=>n(d.target.value),placeholder:"Europe/Madrid"});const c=e&&!$f.includes(e)?[e,...$f]:$f;return t.jsx(Mt,{id:o,name:r,label:s,className:i,value:e,onChange:n,placeholder:"Pick a time zone",options:c.map(d=>({value:d,label:d.replace(/_/g," ")}))})}function R8(e,n){var i,c,d;let s;if(e==="agentic"&&n.json)try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The agent's input is JSON: this is not."}}else if(e==="agentic"&&n.typed){if(n.typed.contentRequired&&!n.text.trim())return{ok:!1,field:"input",message:"Write the run's message."};s={...n.text.trim()?{content:n.text}:{},...n.typed.fields}}else if(e==="agentic"){if(!n.text.trim())return{ok:!1,field:"input",message:"Write the run's first message."};s={content:n.text}}else try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The workflow's input is JSON: this is not."}}const r={input:s};if(n.revision&&(r.revision=n.revision),n.effort&&(r.effort=n.effort),e==="agentic"&&((i=n.maxCostUsd)!=null&&i.trim())){const u=Number(n.maxCostUsd);if(!Number.isFinite(u)||u<=0)return{ok:!1,field:"max_cost_usd",message:"A spend cap is a positive number of dollars."};r.max_cost_usd=u}(c=n.fileIds)!=null&&c.length&&(r.file_ids=[...n.fileIds]);const o=e==="agentic"?(d=n.repo)==null?void 0:d.trim():void 0;if(o){if(!/^[^/\s]+\/[^/\s]+$/.test(o))return{ok:!1,field:"repo",message:"A repository is owner/name, like Parcha-ai/agentrun."};r.repo=o}return{ok:!0,body:r}}function A8(e,n){return s=>{var o,i,c,d;const r=new Set;for(;s!=null&&s.$ref&&!r.has(s.$ref);){r.add(s.$ref);const u=(i=(o=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref))==null?void 0:o[1])==null?void 0:i.replace(/~1/g,"/").replace(/~0/g,"~"),f=u===void 0?void 0:((c=e.definitions)==null?void 0:c[u])??((d=e.$defs)==null?void 0:d[u])??(Object.hasOwn(n,u)?n[u]:void 0);if(!f)break;s=f}return s}}function O8(e,n,s="workflow"){if(e.from==="example")return`The ${s}'s example input. Edit it, then ${n}.`;const r=e.optional.length?` It also takes ${e.optional.join(", ")}, if you add ${e.optional.length===1?"it":"them"}.`:"";return`The ${s}'s input, its required fields empty. Fill them in, then ${n}.${r}`}function M8(e){var r,o;const n=e,s=(r=n==null?void 0:n.input)!=null&&r.schemaId?(o=n.schemas)==null?void 0:o[n.input.schemaId]:void 0;return s?LE(s,(n==null?void 0:n.schemas)??{}):null}function LE(e,n={}){var u;const s=A8(e,n),r=s(e),o=Object.entries(r.properties??{}).map(([f,g])=>{const y=s(g);return{name:f,...y!=null&&y.description?{note:y.description}:{}}}),i=((u=r.examples)==null?void 0:u[0])??r.default;if(i!==void 0)return{text:JSON.stringify(i,null,2),from:"example",fields:o,optional:[]};const c=(f,g=0)=>{var h,x;const y=s(f);if(!y||g>4)return null;if((h=y.examples)!=null&&h.length)return y.examples[0];if(y.default!==void 0)return y.default;if((x=y.enum)!=null&&x.length)return y.enum[0];const v=Array.isArray(y.type)?y.type[0]:y.type;return v==="object"||y.properties?Object.fromEntries(Object.entries(y.properties??{}).filter(([b])=>(y.required??[]).includes(b)).map(([b,j])=>[b,c(j,g+1)])):v==="array"?[]:v==="string"?"":v==="number"||v==="integer"?0:v==="boolean"?!1:null},d=new Set(r.required??[]);return{text:JSON.stringify(c(r),null,2),from:"shape",fields:o,optional:o.map(f=>f.name).filter(f=>!d.has(f))}}const Pg=e=>`'${e.replace(/'/g,"'\\''")}'`;function L8(e,n,s,r){return[`curl -X POST ${Pg(`${e}/v2/agents/${n?encodeURIComponent(n):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${Pg(`Idempotency-Key: ${r}`)} \\`,` -d ${Pg(JSON.stringify(s))}`].join(`
650
+ `)}const P8=e=>e>=200&&e<300;async function I8(e,n,s,r){const o=await r(n,s,e.keyFor(n,s));return P8(o.status)&&e.done(),o}const Vo=(e,n={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(n,r)?Wb(n[r]).join(", "):"")||"…"),PE=e=>`#/templates/${encodeURIComponent(e)}`;function ll(e,n){return`#/playground?${new URLSearchParams({operation:"apply-template",template:e.id,...n?{draft:JSON.stringify({template:e.id,version:e.version,...e.sha?{sha:e.sha}:{},body:n})}:{}})}`}function z8(e,n){var r,o;if(e===void 0)return{};const s={error:"This prepared template request is invalid. Open a fresh request to review its settings."};try{const i=JSON.parse(e),c=v=>v!==null&&typeof v=="object"&&!Array.isArray(v);if(!c(i)||i.template!==n.id||typeof i.version!="string")return s;if(i.version!==n.version)return{error:"This template's version changed. Open a fresh request to review the current package before applying."};if(n.sha&&i.sha!==n.sha)return{error:"This template's commit changed. Open a fresh request to review the current package before applying."};const d=i.body,u=(v,h)=>v==="boolean"?typeof h=="boolean":v==="string"?typeof h=="string":(v==="number"||v==="integer")&&typeof h=="number"&&Number.isFinite(h);if(!c(d)||Object.keys(d).some(v=>!["parameters","grants","servers","overrides"].includes(v))||!c(d.parameters)||d.grants!==void 0&&(!Array.isArray(d.grants)||d.grants.some(v=>typeof v!="string"||!n.mcp.some(h=>h.tools.some(x=>x.tool===v))))||d.servers!==void 0&&(!c(d.servers)||Object.entries(d.servers).some(([v,h])=>!n.mcp.some(x=>x.toolkit===v)||typeof h!="string"||!/^[a-z][a-z0-9-]{0,31}$/.test(h)))||!c(d.overrides)||Object.keys(d.overrides).some(v=>v!=="approvals"&&v!=="choice")||d.overrides.approvals!=="ask"&&d.overrides.approvals!=="never"||d.overrides.choice!==void 0&&(typeof d.overrides.choice!="string"||!((o=(r=n.model)==null?void 0:r.choices)!=null&&o.map(v=>v.id).includes(d.overrides.choice))))return s;const f=ph(n.parameters);if(!f)return s;const g=new Map(f),y=[];for(const[v,h]of Object.entries(d.parameters)){const x=g.get(v);if(!x)return s;if(h==="")continue;if(x.array?!Array.isArray(h)||!h.every(k=>u(x.type,k)):!u(x.type,h))return s;const b=Array.isArray(h)?h.map(String).join(`
651
+ `):String(h),j=xh({fields:[[v,x]],contentRequired:!1},{[v]:b})[v];if(JSON.stringify(j)!==JSON.stringify(h))return s;y.push([v,h])}return{body:{...d,parameters:Object.fromEntries(y)}}}catch{return s}}const D8=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function Ub(e,{secrets:n=!0,mcp:s=!0}={}){var o,i;const r=[];return n&&e.secrets.length&&r.push(["Keys",e.secrets.join(", ")]),s&&e.mcp.length&&r.push(["MCP",e.mcp.map(c=>`${c.toolkit} (${Id[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",D8(e.triggers.length,"trigger")]),(o=e.budget)!=null&&o.per_run_usd&&r.push(["Budget",`${_d(e.budget.per_run_usd)} a run`]),(i=e.harness)!=null&&i.length&&r.push(["Harness",e.harness.join(", ")]),e.model&&r.push(["Model",`${e.model.tier}${e.model.prefer?`, ${e.model.prefer} first`:""}`]),r}function Gd(e){var s;if(e.type==="boolean"||e.array)return null;if((s=e.enum)!=null&&s.length)return e.enum.map(String);const n=e.pattern?/^\^\(([A-Za-z0-9_-]+(?:\|[A-Za-z0-9_-]+)+)\)\$$/.exec(e.pattern):null;return n?n[1].split("|"):null}function F8(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:Gd(s)?[]:s.format==="timezone"?[[n,Pl()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const U8=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function W8(e){const n=encodeURIComponent(e.toolkit);if(e.source==="composio")return`#/settings/mcp?add=${n}&preset=composio&toolkit=${n}&tools=${e.tools.map(r=>encodeURIComponent(r.name)).join(",")}`;if(e.source==="github")return"#/settings/mcp?add=github&auth=github_app";const s=gb.find(r=>r.name===e.toolkit);return`#/settings/mcp?add=${n}${s?`&preset=${s.id}`:""}`}const xm=e=>e.mcp.length===0&&e.secrets.length===0,H8=e=>{const n=e.source;return typeof n=="object"&&n!==null&&"kind"in n?n.kind:void 0},V0=[{id:"email",what:"the email account",needs:e=>(e.tools??[]).some(n=>n.startsWith("email_"))||e.triggers.some(n=>H8(n)==="email"),met:async e=>(await e.emailAccount()).configured,unmet:{before:"Connect your mailbox under ",link:"Settings → Email",href:"#/settings/email",after:" first."}}],B8=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),q8=(e,n)=>e.filter(s=>s.field===n);function vm(e){if(e.type!=="string"||e.format!=="cron"&&e.format!=="timezone"||!e.description)return e.description;if(e.format==="timezone")return;const n=e.description.indexOf(": ");return n<0?void 0:e.description.slice(n+2).trim()||void 0}function G8(e){const n=Gd(e);if(!n)return null;const s=e.default===void 0?void 0:String(e.default);return[{value:"",label:e.required?"Choose one":"None chosen"},...n.map(r=>({value:r,label:r===s?`${r} (default)`:r}))]}function K8(e,n,s,r=n){if(!s)return e.message;switch(e.reason){case"missing":return`${r} is required.`;case"wrong_type":return s.array?`${r} takes a list, one item a line.`:`${r} takes ${s.type==="integer"?"a whole number":s.type==="number"?"a number":s.type==="boolean"?"yes or no":"text"}.`;case"not_an_option":return`${r} takes one of: ${IE(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const IE=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):Gd(e)??[]};function zE(e,n){var c;if(e.array){const d=Wb(n);return d.length?d.every(u=>zE({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=Gd(e);if(s)return s.includes(n);const r=Number(n),o=(e.minimum===void 0||r>=e.minimum)&&(e.maximum===void 0||r<=e.maximum);if(e.type==="integer")return n.trim()!==""&&Number.isSafeInteger(r)&&o;if(e.type==="number")return n.trim()!==""&&Number.isFinite(r)&&o;if(e.type==="boolean")return(n==="true"||n==="false")&&(!((c=e.enum)!=null&&c.length)||IE(e).includes(n));const i=[...n].length;if(e.minLength!==void 0&&i<e.minLength||e.maxLength!==void 0&&i>e.maxLength)return!1;if(e.pattern)try{return new RegExp(e.pattern,"u").test(n)}catch{return!0}return!0}const Wb=e=>(e??"").split(`
652
+ `).map(n=>n.trim()).filter(n=>n!==""),DE=zE,Ga=e=>!!e&&typeof e=="object"&&!Array.isArray(e),V8=new Set(["string","number","integer","boolean"]),Y8=["oneOf","anyOf","allOf","not","if","$ref","const"],Lx=e=>Y8.some(n=>n in e),_f=e=>typeof e=="string"?e:void 0,Tf=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Q8=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function J8(e,n){if(!Ga(e)||Lx(e))return null;const s=e.type==="array",r=s?e.items:e;if(!Ga(r)||Lx(r)||typeof r.type!="string"||!V8.has(r.type))return null;const o=Array.isArray(r.enum)&&r.enum.every(i=>["string","number","boolean"].includes(typeof i))?r.enum:void 0;return Q8({type:r.type,...s?{array:!0}:{},required:n,title:_f(e.title),description:_f(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:o,pattern:_f(r.pattern),format:_f(r.format),minimum:Tf(r.minimum),maximum:Tf(r.maximum),minLength:Tf(r.minLength),maxLength:Tf(r.maxLength)})}function ph(e,n){const s=Ga(e)&&Ga(e.properties)?e.properties:{},r=Ga(e)&&Array.isArray(e.required)?e.required:[],o=[];for(const[i,c]of Object.entries(s)){if(i===n)continue;const d=J8(c,r.includes(i));if(!d)return null;o.push([i,d])}return o}function X8(e){if(!Ga(e))return{kind:"message"};const n=()=>({kind:"json",example:LE(e)});if(Lx(e))return n();const s=Ga(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(i=>typeof i=="string"):[];if(r.some(i=>i!=="content"&&!Object.hasOwn(s,i)))return n();const o=ph(e,"content");return o?o.length?{kind:"fields",form:{fields:o,contentRequired:r.includes("content")||!r.some(i=>i!=="content")}}:{kind:"message"}:n()}const gh=(e,n)=>n.title||e;function Z8(e){var s;const n=(s=e.examples)!=null&&s.length?e.examples[0]:e.default;if(n!=null)return Array.isArray(n)?n.map(String).join(`
653
+ `):typeof n=="object"?JSON.stringify(n):String(n)}function eU(e,n){const s=r=>e.type==="number"||e.type==="integer"?r.trim()!==""&&Number.isFinite(Number(r))?Number(r):r:e.type==="boolean"?r==="true"?!0:r==="false"?!1:r:r;if(e.array){const r=Wb(n);return r.length?r.map(s):e.required?[]:void 0}return e.type==="boolean"?n==="true"||n==="false"?n==="true":e.required?!1:void 0:n===void 0||n===""?e.required&&e.type==="string"?"":void 0:s(n)}function FE(e){const n=F8(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const o=r.array?null:Gd(r);o&&r.default!==void 0&&o.includes(String(r.default))&&(n[s]=String(r.default))}return n}function xh(e,n){const s={};for(const[r,o]of e.fields){const i=eU(o,n[r]);i!==void 0&&(s[r]=i)}return s}const tU=(e,n,s)=>({...n.trim()?{content:n}:{},...xh(e,s)}),Px=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,UE=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",nU={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},sU=e=>e.array?`a list of ${nU[e.type]}`:UE(e);function WE(e,n,s){var o;const r=gh(n,s);return s.array&&e.reason==="wrong_type"?e.field.endsWith(`.${n}`)?`${r} takes a list, one item a line.`:`Each line of ${r} is ${UE(s)}.`:s.array&&e.reason==="not_an_option"&&((o=s.enum)!=null&&o.length)?`Each line of ${r} is one of: ${s.enum.map(String).join(", ")}.`:K8(e,n,s,r)}const rU={date:"date",email:"email",uri:"url"};function HE({field:e,label:n,help:s,value:r,onChange:o}){const i=Z8(e),c=G8(e);return t.jsxs("label",{className:"block",children:[t.jsxs("span",{className:"caps text-small font-semibold",children:[n,e.required&&t.jsx("span",{className:"text-destructive-text",children:" *"})]}),t.jsxs("span",{className:"mb-1.5 block text-small text-muted-foreground",children:[s,e.array&&t.jsxs(t.Fragment,{children:[s?" ":"","One a line."]})]}),c?t.jsx(Mt,{label:n,className:"w-full",value:r,onChange:o,options:c}):e.array?t.jsx(on,{rows:3,value:r,required:e.required,placeholder:i,onChange:d=>o(d.target.value),className:"resize-y leading-[1.6]"}):e.format==="cron"&&e.type==="string"?t.jsx(OE,{label:n,value:r,onChange:o}):e.format==="timezone"&&e.type==="string"?t.jsx(ME,{label:n,className:"w-full",value:r,onChange:o}):e.type==="boolean"?t.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r==="true",onChange:d=>o(d.target.checked?"true":"false")}):t.jsx(De,{type:e.type==="string"?rU[e.format??""]??"text":"number",step:e.type==="integer"?1:"any",value:r,required:e.required,placeholder:i,min:e.minimum,max:e.maximum,minLength:e.minLength,maxLength:e.maxLength,onChange:d=>o(d.target.value)})]})}function Do({issues:e,named:n=!1,words:s=r=>r.message}){return e.length?t.jsx("ul",{className:"mt-1.5 space-y-1 text-small text-destructive-text",role:"alert",children:e.map((r,o)=>t.jsxs("li",{children:[n&&t.jsxs("span",{className:"font-mono",children:[r.field," "]}),s(r),r.fix&&t.jsx("span",{className:"block text-foreground/80",children:r.fix})]},`${r.field}:${o}`))}):null}const BE={standard:"The event is the JSON body's top-level type (Standard Webhooks), such as issue.opened. Conditions read the body: /title is its title.",github:"The event is the X-GitHub-Event header: pull_request, issue_comment, push. Conditions read the body."},oU='One value a line. A number, true, false or null is that JSON value, and so is a line in double quotes ("42" is the text 42) or a {…} or […]. Any other line is its text.',Yc=(e,n)=>e[n]?t.jsx("span",{"data-issue":n,children:e[n]}):void 0,hr=({issues:e,field:n})=>e[n]?t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:t.jsx("span",{"data-issue":n,children:e[n]})}):null;function vh({name:e,at:n,where:s,onChange:r,issues:o,label:i}){const c=(f,g)=>r(s.map((y,v)=>v===f?{...y,...g}:y)),d=(f,g)=>c(f,g==="prefix"?{op:g,value:s[f].value.split(/\r\n|\r|\n/).find(y=>y.trim())??""}:{op:g}),u=s.length>=Bd.conditions;return t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs("p",{className:"caps text-small font-semibold",children:[i," ",t.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:"(optional)"})]}),s.length>0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Each names a field of the body as a JSON pointer (/title, /issue/labels/0/name) and a test; all of them must hold."}),t.jsx(hr,{issues:o,field:`${n}.where`}),s.map((f,g)=>{const y=`${n}.where[${g}]`,v=`${e}-where-${g}`;return t.jsxs("div",{"data-condition":v,className:"space-y-3 border p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsx(St,{label:"Field",className:"min-w-40 flex-1",error:Yc(o,`${y}.pointer`),children:t.jsx(De,{name:`${v}-pointer`,value:f.pointer,onChange:h=>c(g,{pointer:h.target.value}),placeholder:"/title",autoComplete:"off",spellCheck:!1})}),t.jsx(Qo,{name:`${v}-op`,label:`Condition ${g+1}'s test`,value:f.op,onChange:h=>d(g,h),options:HF.map(h=>({value:h,label:lE[h]}))}),t.jsx(B,{type:"button",size:"icon",variant:"ghost","aria-label":`Remove condition ${g+1}`,onClick:()=>r(s.filter((h,x)=>x!==g)),children:t.jsx(uo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(St,{label:"Values",hint:oU,error:Yc(o,`${y}.in`),children:t.jsx(on,{name:`${v}-value`,rows:3,value:f.value,onChange:h=>c(g,{value:h.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(St,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:Yc(o,`${y}.prefix`),children:t.jsx(De,{name:`${v}-value`,value:f.value,onChange:h=>c(g,{value:h.target.value}),autoComplete:"off",spellCheck:!1})}),t.jsx(hr,{issues:o,field:y}),t.jsx(hr,{issues:o,field:`${y}.exists`})]},f.key)}),t.jsxs(B,{type:"button",size:"sm",onClick:()=>r([...s,qF()]),disabled:u,children:[t.jsx(Rm,{"aria-hidden":!0})," Add a condition"]})]})}function qE({name:e,rules:n,onChange:s,issues:r,indexOf:o=g=>g,room:i,eventHint:c,eventPlaceholder:d,addLabel:u="Add a rule",empty:f}){const g=(y,v)=>s(n.map((h,x)=>x===y?{...h,...v}:h));return t.jsxs("div",{className:"min-w-0 space-y-3",children:[!n.length&&f,n.map((y,v)=>{const h=`source.accept[${o(v)}]`,x=`${e}-${v}`;return t.jsxs("section",{"data-rule":x,"aria-label":`Rule ${v+1}`,className:"space-y-4 border p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Rule ",v+1]}),t.jsxs(B,{type:"button",size:"xs",variant:"ghost","aria-label":`Remove rule ${v+1}`,onClick:()=>s(n.filter((b,j)=>j!==v)),children:[t.jsx(m1,{"aria-hidden":!0})," Remove"]})]}),t.jsx(hr,{issues:r,field:h}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(St,{label:"Event",hint:c,error:Yc(r,`${h}.event`),children:t.jsx(De,{name:`${x}-event`,value:y.event,onChange:b=>g(v,{event:b.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(St,{label:"Actions",optional:!0,hint:"The body's top-level action is one of these, split by commas (opened, edited). None: any action, or none.",error:Yc(r,`${h}.actions`),children:t.jsx(De,{name:`${x}-actions`,value:y.actions,onChange:b=>g(v,{actions:b.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(vh,{name:x,at:h,where:y.where,onChange:b=>g(v,{where:b}),issues:r,label:"Only when"})]},y.key)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>s([...n,cE()]),disabled:i<=0,children:[t.jsx(Rm,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[Bd.rules," rules, the most a trigger takes."]})]})]})}const Vn=e=>`#/triggers/${encodeURIComponent(e)}`,Nl=e=>vt(e),aU={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function iU({v2:e,view:n,go:s,agentName:r,minEvery:o,failuresToPause:i,publicUrl:c,refreshMs:d=15e3,now:u=Date.now}){const f=c===!1;return n.trigger===void 0?t.jsx(uU,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(bU,{v2:e,go:s}):n.kind==="github"?t.jsx(yU,{v2:e,go:s}):n.kind==="composio"?t.jsx(wU,{v2:e,go:s,noAddress:f}):n.kind==="feed"?t.jsx(n$,{v2:e,go:s,minEvery:o}):t.jsx(JE,{v2:e,go:s,minEvery:o,now:u}):n.edit?t.jsx(xU,{v2:e,go:s,id:n.trigger,minEvery:o,now:u},n.trigger):t.jsx(gU,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function GE(e,n,s){const r=p.useRef(e);r.current=e,p.useEffect(()=>{const o=()=>document.visibilityState!=="hidden",i=setInterval(()=>{o()&&r.current()},n),c=()=>{o()&&r.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(i),document.removeEventListener("visibilitychange",c)}},[n,...s])}const KE=e=>e?"ran"in e?`Done · ran ${Nl(e.ran.nominal_at)}`:`Its time passed · ${Nl(e.passed)}`:null,lU=/has already passed\.?$/;function VE({trigger:e}){return e.disabled?t.jsx(Ne,{tone:"warning",children:"Turned off"}):t.jsx(Ne,{tone:"muted",children:"Paused"})}const cU=e=>e.last_firing?`${NE(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${Nl(e.last_firing.nominal_at)}`:"Not fired yet",dU=e=>`${e.ok?"Checked":"Check failed"} ${Nl(e.at)}: ${e.message}`,Hb="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function uU({v2:e,go:n,agentName:s,every:r,now:o,failuresToPause:i,noAddress:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState(0),h=p.useRef(!1),x=p.useRef(!0);p.useEffect(()=>(x.current=!0,()=>{x.current=!1}),[]);const b=()=>{h.current||(h.current=!0,e.listTriggers().then(j=>{x.current&&(u(j.triggers),g(null))},j=>{x.current&&g(Jt(j,"the triggers"))}).finally(()=>{h.current=!1}))};return p.useEffect(b,[e,y]),GE(b,r,[e]),t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Triggers",children:[t.jsxs("header",{className:te(vr,"flex-wrap justify-between gap-3 px-5"),children:[t.jsxs("h1",{className:Jo,children:[t.jsx(vd,{className:"size-4","aria-hidden":!0}),"Triggers"]}),!(d&&!d.length)&&t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:[t.jsxs(B,{size:"sm",disabled:c,onClick:()=>n("#/triggers/new-composio"),children:[t.jsx(Cm,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(B,{size:"sm",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(_m,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(B,{size:"sm",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(ml,{"aria-hidden":!0})," New webhook"]}),t.jsxs(B,{size:"sm",onClick:()=>n("#/triggers/new-feed"),children:[t.jsx(rv,{"aria-hidden":!0})," New feed trigger"]}),t.jsxs(B,{size:"sm",variant:"primary",onClick:()=>n("#/triggers/new"),children:[t.jsx(Rm,{"aria-hidden":!0})," New schedule"]})]})]}),t.jsxs("div",{className:"px-5 py-5 md:py-6",children:[c&&d&&d.length>0&&t.jsx("p",{className:"mb-4 text-small text-muted-foreground",children:Hb}),f&&!d?t.jsx(en,{problem:f,onRetry:()=>v(j=>j+1),className:""}):d?d.length?t.jsx("ul",{className:"border",children:d.map(j=>t.jsxs("li",{"data-trigger":j.id,className:"grid grid-cols-1 gap-x-6 gap-y-1.5 border-b px-4 py-3 last:border-b-0 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:Vn(j.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:j.name}),t.jsx(Ne,{children:mU[j.source.kind]}),!j.enabled&&!Mb(j,o())&&t.jsx(VE,{trigger:j})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:YE(j),children:hU(j,s,o())}),gm(j,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:gm(j,i)})]}),t.jsxs("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:[t.jsx("p",{className:"break-words",children:cU(j)}),j.last_check&&t.jsx("p",{"data-last-check":j.last_check.ok?"ok":"failed",className:`mt-1 break-words ${j.last_check.ok?"":"text-warning-text"}`,children:dU(j.last_check)})]})]},j.id))}):t.jsx(fU,{go:n,noAddress:c}):t.jsx(Qn,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(en,{problem:f,className:"mt-4"})]})]})}function fU({go:e,noAddress:n}){const s=[{Icon:vd,name:"Schedule",what:"At the times you set: every day or week at a time, every few minutes or hours, or once.",action:"New schedule",to:"#/triggers/new"},{Icon:ml,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:_m,name:"GitHub",what:"On the events you pick from this server's GitHub App. Connect GitHub in Settings first.",action:"New GitHub trigger",to:"#/triggers/new-github"},{Icon:Cm,name:"From an app",what:"On an event in an app a saved Composio server connects, such as a new issue in a GitHub repository. Save the server in Settings first.",action:"New app trigger",to:"#/triggers/new-composio"},{Icon:rv,name:"Feed",what:"On each new item in the feeds you name, read every few minutes: a status page's incidents, a blog, or an API's JSON list such as a repository's pull requests.",action:"New feed trigger",to:"#/triggers/new-feed"}];return t.jsxs("section",{"aria-labelledby":"first-trigger",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"No triggers yet"}),t.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A trigger starts a run of an agent for you, and each run it starts stops at a spend cap. Pick what should start it."}),t.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:s.map(({Icon:r,name:o,what:i,action:c,to:d})=>t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx(r,{className:"size-4 text-muted-foreground","aria-hidden":!0}),o]}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:i}),n&&d==="#/triggers/new-composio"&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:Hb}),t.jsx(B,{size:"sm",className:"mt-4 self-start",disabled:n&&d==="#/triggers/new-composio",onClick:()=>e(d),children:c})]},o))})]})}const mU={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"},YE=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function hU(e,n,s){return`${e.source.kind==="schedule"?Ob(e.source,e.next_at,{instead:KE(Mb(e,s)),now:s}):e.source.kind==="github"?kE(e.source):e.source.kind==="composio"?wE(e.source):e.source.kind==="email"?r8(e.source):e.source.kind==="feed"?jE(e.source):yE(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${ca(e.target.run_id)}`}`}const pU={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function QE(){return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsx("p",{className:"mt-4 border px-4 py-6 text-body text-muted-foreground",children:"This trigger sends its firings to a run: this page doesn't open it yet."})]})}function gU({v2:e,go:n,agentName:s,id:r,every:o,now:i,failuresToPause:c}){var ft,ve,Ee,Q,Me;const[d,u]=p.useState(null),[f,g]=p.useState([]),[y,v]=p.useState(null),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(!1),[N,S]=p.useState(!1),[$,_]=p.useState(null),O=p.useRef(!1),[M,P]=p.useState(!1),[A,R]=p.useState(null),[L,W]=p.useState(null),[U,Y]=p.useState(null),[D,G]=p.useState(0),F=p.useRef(!1),q=p.useRef(!1),H=p.useRef(0),I=()=>{q.current=!0;const pe=H.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([ne,Ae])=>{pe===H.current&&(u(ne),g(Ae.firings),v(null))}).finally(()=>{q.current=!1})};p.useEffect(()=>{I().catch(pe=>v(Jt(pe,"the trigger")))},[e,r,D]),GE(()=>{!q.current&&!F.current&&U===null&&I().catch(()=>{})},o,[e,r]);const[V,J]=p.useState(void 0),X=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;p.useEffect(()=>{if(!X)return;let pe=!0;return e.getAgent(X).then(ne=>{pe&&J(typeof ne.agent.definition.max_cost_usd=="number"?ne.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{pe=!1}},[e,X]);const re=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;if(p.useEffect(()=>{if(!re)return;let pe=!0;return e.composioTriggers(re).then(ne=>{var Ae;pe&&R(((Ae=ne.triggers.find(Pe=>Pe.id===r))==null?void 0:Ae.on_composio)??"unknown")},()=>{pe&&R(null)}),()=>{pe=!1}},[e,re,r,d==null?void 0:d.enabled]),U!==null)return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsx("h1",{className:"mt-3 break-words text-2xl font-semibold leading-tight",children:(d==null?void 0:d.name)??r}),t.jsx("p",{className:"mt-2 text-body",children:"Deleted here. Its runs stay."}),t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:U}),t.jsx("a",{href:"#/triggers",className:"mt-4 inline-block text-body underline underline-offset-2",children:"All triggers"})]});if(!d)return y?t.jsx(en,{problem:y,onRetry:()=>G(pe=>pe+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(Qn,{label:"Loading the trigger",rows:4});const ae=Pb(d)?d:null,ye=bE(d)?d:null,he=Db(d)?d:null,we=$E(d)?d:null;if(!ae&&!ye&&!he&&!we&&!Lb(d))return t.jsx(QE,{});const ze=d,le=Mb(d,i(),f),me=async(pe,ne,Ae)=>{j(pe),x(null);try{await ne()}catch(Pe){x(Jt(Pe,Ae))}finally{j(null)}},Ke=()=>me("pause",async()=>{H.current++,W(null);const{composio:pe,...ne}=await e.updateTrigger(r,{enabled:!d.enabled});H.current++,u(ne),W((pe==null?void 0:pe.note)??null)},d.enabled?"the pause":"the resume"),be=()=>me("delete",async()=>{const pe=await e.deleteTrigger(r);pe!=null&&pe.composio?Y(pe.composio.note):n("#/triggers")},"the delete"),ge=async()=>{if(!O.current){O.current=!0,P(!0),x(null),_(null);try{_((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(pe){x(Jt(pe,"the new secret"))}finally{O.current=!1,P(!1)}}},Je=async()=>{if(!F.current){F.current=!0,j("fire"),x(null),H.current++;try{const pe=await e.fireTrigger(r,Hd());H.current++,g(ne=>[pe,...ne.filter(Ae=>Ae.key!==pe.key)]),await I().catch(()=>{})}catch(pe){x(Jt(pe,"the run now"))}finally{F.current=!1,j(null)}}},tt=typeof ze.target.input.content=="string"?ze.target.input.content:null;return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsxs("div",{className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 sm:flex-row",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch",children:[t.jsxs("h1",{className:"flex flex-wrap items-center gap-2 break-words text-2xl font-semibold leading-tight",children:[d.name,!d.enabled&&!le&&t.jsx(VE,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:ae?`Webhook · ${yE(ae.source)}`:ye?`GitHub · ${kE(ye.source)}`:he?`App · ${wE(he.source)}`:we?`Feed · ${jE(we.source)}`:t.jsx("span",{title:YE(d),children:Ob(ze.source,d.next_at,{instead:KE(le),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(le&&"ran"in le)&&t.jsx(B,{size:"sm",onClick:()=>void Ke(),disabled:b!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(fl,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(ra,{"aria-hidden":!0})," Resume"]})}),t.jsxs(B,{size:"sm",onClick:()=>n(`${Vn(r)}/edit`),children:[t.jsx(sv,{"aria-hidden":!0})," ",ae||ye||he?"Edit filter":we?"Edit feed":"Edit"]}),ae&&(N?t.jsxs("span",{className:"flex items-center gap-2 border border-warning/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Make a new secret?",children:[t.jsx("span",{children:"The old secret stops signing at once."}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>{S(!1),ge()},children:"Yes, make a new one"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",onClick:()=>S(!0),disabled:b!==null||M,children:[t.jsx(Ka,{"aria-hidden":!0})," Rotate secret"]})),k?t.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Delete this trigger?",children:[t.jsx("span",{children:"Delete for good? Its runs stay."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>{E(!1),be()},children:"Yes, delete"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>E(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>E(!0),disabled:b!==null,children:[t.jsx(m1,{"aria-hidden":!0})," Delete"]}),t.jsxs(B,{size:"sm",variant:"solid",onClick:()=>void Je(),disabled:b==="fire",children:[t.jsx(gR,{"aria-hidden":!0})," ",b==="fire"?"Starting":"Run now"]})]})]}),gm(d,c)&&t.jsxs("p",{role:"status","data-disabled":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:[gm(d,c)," ",((ft=d.disabled)==null?void 0:ft.reason)==="source_unreadable"?we?"Edit its feeds, then Resume.":"Edit its when, then Resume.":((ve=d.disabled)==null?void 0:ve.reason)==="auto_paused"?le&&"passed"in le?"Its time has passed: edit its time first, then Resume.":le?"":"Resume turns it on again.":""]}),h&&t.jsx(en,{problem:h,className:"mt-4"}),L&&t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:L}),ae&&$&&t.jsx(Bb,{label:"The webhook's new secret",secret:$}),we&&t.jsx(SU,{check:we.last_check??null,newest:f[0]}),t.jsxs("dl",{className:"mt-5 grid grid-cols-1 gap-x-6 gap-y-3 border p-4 text-body sm:grid-cols-[max-content_minmax(0,1fr)]",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("a",{href:Cn(ze.target.agent_id),className:"hover:underline",children:s(ze.target.agent_id)||ze.target.agent_id})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Each run is asked"}),t.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-words",children:tt??JSON.stringify(ze.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:n8(ze.target.max_cost_usd,V)}),ae?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"URL"}),t.jsxs("dd",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("code",{className:"min-w-0 break-all font-mono text-small",children:dd(ae)}),t.jsx(XE,{text:dd(ae),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:Ib})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:Ax[ae.source.signature??"standard"]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(Ee=ae.source.accept)!=null&&Ee.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ae.source.accept.map((pe,ne)=>t.jsx("li",{children:qo(pe)},ne))}):"Every signed request"})]}):he?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"App"}),t.jsxs("dd",{className:"min-w-0 break-words",children:[t.jsx("a",{href:"#/settings/mcp",className:"font-mono hover:underline",children:he.source.server}),t.jsx("span",{className:"text-small text-muted-foreground",children:" · a saved Composio server"})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Event"}),t.jsx("dd",{className:"min-w-0 break-words font-mono",children:he.source.event}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Config"}),t.jsx("dd",{className:"min-w-0 break-words",children:Object.keys(he.source.config).length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Object.entries(he.source.config).map(([pe,ne])=>{var Ae;return t.jsxs("li",{children:[pe,": ",(Ae=he.source.sealed_config)!=null&&Ae.includes(pe)?t.jsx("span",{"data-sealed-config":pe,className:"text-muted-foreground",children:"Sealed: kept here, never shown"}):typeof ne=="string"?ne:JSON.stringify(ne)]},pe)})}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(Q=he.source.accept)!=null&&Q.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:he.source.accept.map((pe,ne)=>t.jsx("li",{children:qo(pe)},ne))}):"Every event of its instance"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"At Composio"}),t.jsx("dd",{className:"min-w-0 break-words",children:A?t.jsx("span",{"data-on-composio":A,className:A==="missing"?"text-warning-text":void 0,children:pU[A]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):ye?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsxs("dd",{className:"min-w-0 break-words",children:[t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ye.source.accept.map((pe,ne)=>t.jsx("li",{children:qo(pe)},ne))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):we?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Feeds"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("ul",{className:"space-y-1 font-mono text-small",children:we.source.urls.map(pe=>t.jsx("li",{className:"break-all",children:mr(pe)?t.jsx("a",{href:mr(pe),target:"_blank",rel:"noreferrer",className:"hover:underline",children:pe}):pe},pe))})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Read"}),t.jsxs("dd",{children:["Every ",Ab(we.source.every_s??_E)]}),(we.source.items!==void 0||we.source.id!==void 0)&&t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"JSON list"}),t.jsxs("dd",{className:"min-w-0 break-words font-mono text-small",children:["Items at ",we.source.items?we.source.items:"the whole document"," · Id at ",we.source.id??"/id"]})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(Me=we.source.accept)!=null&&Me.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:we.source.accept.map((pe,ne)=>t.jsx("li",{children:qo(pe)},ne))}):"Every new or updated item"})]}):t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"While a run is going"}),t.jsx("dd",{children:"The next time is skipped."})]})]}),t.jsxs("section",{className:"mt-6","aria-label":"Firings",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Firings"}),f.length?t.jsx("ul",{className:"mt-3 border",children:f.map(pe=>t.jsxs("li",{"data-firing":pe.key,className:"flex flex-col gap-1 border-b px-4 py-2.5 text-body last:border-b-0 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Ne,{tone:aU[pe.status],children:a8[pe.status]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Nl(pe.nominal_at)})]}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:pe.status==="started"?`${s8[pe.by]}${pe.catch_up?", caught up late":""}`:`${NE(pe)}${pe.catch_up?" · caught up late":""}${pe.by==="manual"?" · Run now":""}`}),pe.run_id&&t.jsxs("a",{href:`#/runs/${encodeURIComponent(pe.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",ca(pe.run_id)]})]},pe.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function xU({v2:e,go:n,id:s,minEvery:r,now:o}){const[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(0);return p.useEffect(()=>{e.getTrigger(s).then(c,y=>u(Jt(y,"the trigger")))},[e,s,f]),i?Pb(i)||bE(i)||Db(i)?t.jsx(NU,{v2:e,go:n,trigger:i}):$E(i)?t.jsx(n$,{v2:e,go:n,trigger:i,minEvery:r}):Lb(i)?t.jsx(JE,{v2:e,go:n,trigger:i,minEvery:r,now:o}):t.jsx(QE,{}):d?t.jsx(en,{problem:d,onRetry:()=>g(y=>y+1)}):t.jsx(Qn,{label:"Loading the trigger",rows:4})}function It({label:e,field:n,issue:s,hint:r,children:o}){return t.jsx(St,{className:"min-w-0",label:e,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:o})}const Kd=e=>e!==void 0?`${ma(e)}, the agent's default`:void 0;async function Vd(e){const n=[];let s=null;for(let r=0;r<20;r++){const o=await e.listAgents({cursor:s});if(n.push(...o.agents),s=o.next_cursor,!s)break}return n}function JE({v2:e,go:n,trigger:s,minEvery:r,now:o=Date.now}){var W,U,Y;const[i,c]=p.useState(()=>s?S8(s):gE()),[d,u]=p.useState(null),[f,g]=p.useState({}),[y,v]=p.useState([]),[h,x]=p.useState(!1),b=p.useRef(br()).current;p.useEffect(()=>{Vd(e).then(u,()=>u([]))},[e]);const j=D=>G=>c(F=>({...F,[D]:G})),k=D=>{var F;j("at")(D);const G=Xi(D,(F=i.read)==null?void 0:F.at);G!==null&&Date.parse(G)>o()?g(({"source.at":q,...H})=>H):G!==null&&g(q=>q["source.at"]?{...q,"source.at":H0(G,{now:o()})}:q)},E=new Set(["name","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd",...s?[]:["enabled"]]),N=(W=(d??[]).find(D=>D.agent_id===i.agentId))==null?void 0:W.definition.max_cost_usd,S=typeof N=="number"&&N>0?N:void 0,$=S!==void 0||!!s&&typeof s.target.max_cost_usd!="number"&&i.agentId===s.target.agent_id,_=async D=>{var q;D.preventDefault();const{body:G,issues:F}=q0(i,$);if(v([]),!G){g(F??{});return}g({}),x(!0);try{if(s){const H=G0(s,G);Object.keys(H).length&&await e.updateTrigger(s.id,H),n(Vn(s.id))}else{const H=await e.createTrigger(G,b.keyFor("createTrigger",G));n(Vn(H.id))}}catch(H){const I=Il(H),V=i.kind==="at"?Xi(i.at,(q=i.read)==null?void 0:q.at):null,J=I.fields["source.at"];J&&V!==null&&(Date.parse(V)<=o()||lU.test(J))&&(I.fields["source.at"]=H0(V,{now:o()})),g(Object.fromEntries(Object.entries(I.fields).filter(([X])=>E.has(X)))),v([...I.rest,...Object.entries(I.fields).filter(([X])=>!E.has(X)).map(([,X])=>X)]),x(!1)}},O=s?q0(i,$).body:void 0,M=!!(s&&O&&G0(s,O).source),P=i.kind==="at"?Xi(i.at,(U=i.read)==null?void 0:U.at):null,A=i.startAt?Xi(i.startAt,(Y=i.read)==null?void 0:Y.startAt):null,R=Ol((d??[]).filter(D=>!D.archived_at||D.agent_id===i.agentId)),L=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return t.jsxs("form",{onSubmit:D=>void _(D),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Vn(s.id):"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," ",s?s.name:"Triggers"]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(vd,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),y.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:y.map((D,G)=>t.jsx("p",{children:D},G))}),t.jsxs("div",{className:`mt-5 ${Cd}`,children:[t.jsx(It,{label:"Name",field:"name",issue:f.name,children:t.jsx(De,{name:"name",value:i.name,onChange:D=>j("name")(D.target.value),placeholder:"nightly triage"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"When"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:L.map(({kind:D,label:G})=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${i.kind===D?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"kind",value:D,checked:i.kind===D,onChange:()=>j("kind")(D),className:"accent-primary"}),G]},D))}),t.jsxs("div",{className:"mt-3 grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-4",children:[i.kind==="cron"&&t.jsx(It,{label:"Runs",field:"source.cron",issue:f["source.cron"],children:t.jsx(OE,{label:"Runs",name:"cron",value:i.cron,onChange:j("cron")})}),i.kind==="at"&&t.jsx(It,{label:"At, your time",field:"source.at",issue:f["source.at"],hint:P?`= ${B0(P)}`:void 0,children:t.jsx(De,{name:"at",type:"datetime-local",step:60,value:i.at,onChange:D=>k(D.target.value)})}),i.kind==="every"&&t.jsx(It,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?zb(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(De,{name:"every",inputMode:"decimal",value:i.every,onChange:D=>j("every")(D.target.value),placeholder:"5"}),t.jsx(Mt,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:i.everyUnit,onChange:D=>j("everyUnit")(D),options:["seconds","minutes","hours"].map(D=>({value:D,label:D}))})]})}),i.kind==="cron"&&t.jsx(It,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(ME,{name:"timezone",label:"Time zone",className:"w-full",value:i.timezone,onChange:j("timezone")})}),i.kind==="every"&&t.jsx(It,{label:"Starting, your time (optional)",field:"source.start_at",issue:f["source.start_at"],hint:A?`= ${B0(A)}`:void 0,children:t.jsx(De,{name:"startAt",type:"datetime-local",step:60,value:i.startAt,onChange:D=>j("startAt")(D.target.value)})})]}),M&&t.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),t.jsx(It,{label:"Agent",field:"target.agent_id",issue:f["target.agent_id"],children:t.jsx(Mt,{name:"agent",label:"Agent",className:"w-full",value:i.agentId,onChange:D=>j("agentId")(D),options:[{value:"",label:d?"Pick an agent":"Loading the agents"},...R.map(D=>({value:D.agent_id,label:`${D.definition.name||D.agent_id}${D.kind==="workflow"?" (workflow)":""}`})),...i.agentId&&d&&!R.some(D=>D.agent_id===i.agentId)?[{value:i.agentId,label:i.agentId}]:[]]})}),t.jsx(It,{label:"Each run is asked",field:"target.input",issue:f["target.input"],children:t.jsx(on,{name:"content",rows:4,className:"p-3 font-sans",value:i.content,onChange:D=>j("content")(D.target.value)})}),t.jsx(It,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:f["target.max_cost_usd"],hint:S!==void 0?`Uses the agent's default (${ma(S)}) if empty.`:$?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:t.jsx(De,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:i.maxCost,onChange:D=>j("maxCost")(D.target.value),placeholder:Kd(S)})}),!s&&t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"enabled",checked:i.enabled,onChange:D=>j("enabled")(D.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),f.enabled&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:f.enabled})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:h,children:h?"Saving":s?"Save changes":"Create schedule"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Vn(s.id):"#/triggers"),children:"Cancel"})]})]})}function XE({text:e,label:n}){const[s,r]=p.useState(null),o="The browser won't copy here. Select it and copy it.",i=()=>{const c=typeof navigator<"u"?navigator.clipboard:void 0;if(!(c!=null&&c.writeText)){r(o);return}c.writeText(e).then(()=>r("Copied"),()=>r(o))};return t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:i,children:[t.jsx(oi,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function Bb({label:e,secret:n,url:s}){return t.jsxs("section",{"aria-label":e,className:"mt-4 space-y-3 border border-primary/50 p-4 text-body",children:[s&&t.jsx(Ix,{title:"URL",text:s,label:"Copy URL",hint:Ib}),t.jsx(Ix,{title:"Signing secret",text:n,label:"Copy secret"}),t.jsx("p",{className:"text-warning-text",role:"note",children:"You won't see this secret again."})]})}function Ix({title:e,text:n,label:s,hint:r}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"caps text-label text-muted-foreground",children:e}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("code",{className:"min-w-0 break-all border bg-muted/40 px-2 py-1 font-mono text-small",children:n}),t.jsx(XE,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const vU=["standard","github"];function bU({v2:e,go:n}){var $;const[s,r]=p.useState(c8),[o,i]=p.useState(null),[c,d]=p.useState({}),[u,f]=p.useState([]),[g,y]=p.useState(!1),[v,h]=p.useState(null),x=p.useRef(br()).current;p.useEffect(()=>{Vd(e).then(i,()=>i([]))},[e]);const b=_=>O=>r(M=>({...M,[_]:O})),j=($=(o??[]).find(_=>_.agent_id===s.agentId))==null?void 0:$.definition.max_cost_usd,k=typeof j=="number"&&j>0?j:void 0,E=async _=>{_.preventDefault();const O=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",...qd(s.accept.map(A=>A.where.length))]),{body:M,issues:P}=d8(s,k!==void 0);if(f([]),!M){d(P??{});return}d({}),y(!0);try{h(await e.createTrigger(M,x.keyFor("createTrigger",M)))}catch(A){const R=Il(A);d(Object.fromEntries(Object.entries(R.fields).filter(([L])=>O.has(L)))),f([...R.rest,...Object.entries(R.fields).filter(([L])=>!O.has(L)).map(([,L])=>L)])}finally{y(!1)}},N=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(v)return t.jsxs("div",{className:"p-5 md:p-8",children:[N,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(ml,{className:"size-5 text-primary-text","aria-hidden":!0}),v.name]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:`Send each request to this URL, signed with this secret (${Ax[v.source.kind==="webhook"?v.source.signature??"standard":"standard"]}). Each one starts a run.`}),v.signing_secret?t.jsx(Bb,{label:"The webhook's URL and secret",url:dd(v),secret:v.signing_secret}):t.jsxs("section",{"aria-label":"The webhook's URL and secret",className:"mt-4 space-y-3 border p-4 text-body",children:[t.jsx(Ix,{title:"URL",text:dd(v),label:"Copy URL",hint:Ib}),v.note&&t.jsx("p",{role:"note",children:v.note})]}),t.jsx("div",{className:"mt-6",children:t.jsx(B,{type:"button",size:"lg",variant:"solid",onClick:()=>n(Vn(v.id)),children:"Done"})})]});const S=Ol((o??[]).filter(_=>!_.archived_at));return t.jsxs("form",{onSubmit:_=>void E(_),className:"p-5 md:p-8",noValidate:!0,children:[N,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(ml,{className:"size-5 text-primary-text","aria-hidden":!0}),"New webhook"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each signed request to its URL starts a capped run of the agent. Its URL and signing secret show once it is made."}),u.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:u.map((_,O)=>t.jsx("p",{children:_},O))}),t.jsxs("div",{className:`mt-5 ${Cd}`,children:[t.jsx(It,{label:"Name",field:"name",issue:c.name,children:t.jsx(De,{name:"name",value:s.name,onChange:_=>b("name")(_.target.value),placeholder:"on deploy"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:vU.map(_=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===_?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"signature",value:_,checked:s.signature===_,onChange:()=>b("signature")(_),className:"accent-primary"}),Ax[_]]},_))}),c["source.signature"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:c["source.signature"]})]}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Events from an app Composio connects start runs through an app trigger instead: ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),t.jsx(ZE,{signature:s.signature,rules:s.accept,onChange:b("accept"),issues:c,cap:null}),t.jsx(It,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:t.jsx(Mt,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:_=>b("agentId")(_),options:[{value:"",label:o?"Pick an agent":"Loading the agents"},...S.map(_=>({value:_.agent_id,label:`${_.definition.name||_.agent_id}${_.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(It,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:t.jsx(on,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:_=>b("content")(_.target.value)})}),t.jsx(It,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:c["target.max_cost_usd"],hint:k!==void 0?`Uses the agent's default (${ma(k)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:t.jsx(De,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:_=>b("maxCost")(_.target.value),placeholder:Kd(k)})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:g,children:g?"Creating":"Create webhook"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function yU({v2:e,go:n}){var R;const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(0),[u,f]=p.useState(u8),[g,y]=p.useState(null),[v,h]=p.useState({}),[x,b]=p.useState([]),[j,k]=p.useState(!1),E=p.useRef(br()).current,N=p.useRef(!0);p.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]),p.useEffect(()=>{let L=!0;return i(null),e.githubConnection().then(W=>{L&&r(!!W&&"app_id"in W&&!!W.app_id)},W=>{L&&(W instanceof Ue&&W.status===404?r(!1):i(Jt(W,"GitHub's connection")))}),()=>{L=!1}},[e,c]),p.useEffect(()=>{Vd(e).then(y,()=>y([]))},[e]);const S=L=>W=>f(U=>({...U,[L]:W})),$=(R=(g??[]).find(L=>L.agent_id===u.agentId))==null?void 0:R.definition.max_cost_usd,_=typeof $=="number"&&$>0?$:void 0,O=async L=>{L.preventDefault();const W=new Set(["name","target.agent_id","target.input","target.max_cost_usd",...qd(mh(u).map(D=>D.where.length))]),{body:U,issues:Y}=N8(u,_!==void 0);if(b([]),!U){h(Y??{});return}h({}),k(!0);try{const D=await e.createTrigger(U,E.keyFor("createTrigger",U));N.current&&n(Vn(D.id))}catch(D){const G=Il(D);h(Object.fromEntries(Object.entries(G.fields).filter(([F])=>W.has(F)))),b([...G.rest,...Object.entries(G.fields).filter(([F])=>!W.has(F)).map(([,F])=>F)]),k(!1)}},M=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),P=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(_m,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(o)return t.jsxs("div",{className:"p-5 md:p-8",children:[M,P,t.jsx(en,{problem:o,onRetry:()=>d(L=>L+1),className:"mt-4"})]});if(s===null)return t.jsx(Qn,{label:"Reading GitHub's connection",rows:3});if(!s)return t.jsxs("div",{className:"p-5 md:p-8",children:[M,P,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",t.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const A=Ol((g??[]).filter(L=>!L.archived_at));return t.jsxs("form",{onSubmit:L=>void O(L),className:"p-5 md:p-8",noValidate:!0,children:[M,P,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event it takes from this server's GitHub App starts a capped run of the agent."}),x.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:x.map((L,W)=>t.jsx("p",{children:L},W))}),t.jsxs("div",{className:`mt-5 ${Cd}`,children:[t.jsx(It,{label:"Name",field:"name",issue:v.name,children:t.jsx(De,{name:"name",value:u.name,onChange:L=>S("name")(L.target.value),placeholder:"review PRs"})}),t.jsx(e$,{picks:u,onChange:L=>f(W=>({...W,...L})),issues:v}),t.jsx(It,{label:"Agent",field:"target.agent_id",issue:v["target.agent_id"],children:t.jsx(Mt,{name:"agent",label:"Agent",className:"w-full",value:u.agentId,onChange:L=>S("agentId")(L),options:[{value:"",label:g?"Pick an agent":"Loading the agents"},...A.map(L=>({value:L.agent_id,label:`${L.definition.name||L.agent_id}${L.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(It,{label:"Each run is asked",field:"target.input",issue:v["target.input"],hint:"The event's payload comes with it.",children:t.jsx(on,{name:"content",rows:4,className:"p-3 font-sans",value:u.content,onChange:L=>S("content")(L.target.value)})}),t.jsx(It,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:v["target.max_cost_usd"],hint:_!==void 0?`Uses the agent's default (${ma(_)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(De,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:u.maxCost,onChange:L=>S("maxCost")(L.target.value),placeholder:Kd(_)})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:j,children:j?"Creating":"Create GitHub trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function wU({v2:e,go:n,noAddress:s}){var ze;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(0),[b,j]=p.useState(g8),[k,E]=p.useState(null),[N,S]=p.useState({}),[$,_]=p.useState([]),[O,M]=p.useState(null),[P,A]=p.useState(null),[R,L]=p.useState(!1),W=p.useRef(br()).current,U=p.useRef(!0);p.useEffect(()=>(U.current=!0,()=>{U.current=!1}),[]),p.useEffect(()=>{let le=!0;return c(null),e.listMcpServers().then(me=>{if(!le)return;const Ke=me.servers.filter(be=>be.source==="composio");o(Ke),Ke.length===1&&j(be=>be.server?be:{...be,server:Ke[0].name})},me=>{le&&c(Jt(me,"the saved MCP servers"))}),()=>{le=!1}},[e,d]),p.useEffect(()=>{if(!b.server)return;let le=!0;const me=b.server;return g(null),v(null),e.composioEvents(me).then(Ke=>{le&&g({server:me,events:Ke.events})},Ke=>{le&&v(Jt(Ke,`${me}'s events`))}),()=>{le=!1}},[e,b.server,h]),p.useEffect(()=>{Vd(e).then(E,()=>E([]))},[e]);const Y=le=>{A(null),j(le)},D=le=>me=>Y(Ke=>({...Ke,[le]:me})),G=le=>Y(me=>me.server===le?me:{...me,server:le,event:"",config:{},where:[]}),F=le=>{Y(me=>me.event===le?me:{...me,event:le,config:{},where:[]}),S({})},q=(f==null?void 0:f.server)===b.server?f.events.find(le=>le.slug===b.event):void 0,H=h8(q==null?void 0:q.config,q==null?void 0:q.sealed),I=(ze=(k??[]).find(le=>le.agent_id===b.agentId))==null?void 0:ze.definition.max_cost_usd,V=typeof I=="number"&&I>0?I:void 0,J=async le=>{var Ke,be;const me=new Set(["name","source.server","source.event","source.config",...H.map(ge=>`source.config.${ge.name}`),"target.agent_id","target.input","target.max_cost_usd",...b.where.length?qd([b.where.length]):[]]);S({}),_([]),M(null),A(null),L(!0);try{const ge=await e.createTrigger(le,W.keyFor("createTrigger",le));U.current&&n(Vn(ge.id));return}catch(ge){if(ge instanceof Ue&&ge.code==="composio_subscription_elsewhere")A({url:typeof((Ke=ge.details)==null?void 0:Ke.webhook_url)=="string"?ge.details.webhook_url:"another address",body:le});else if(ge instanceof Ue&&ge.code.startsWith("composio_"))_([ge.message]),ge.code==="composio_not_connected"&&M(mr(typeof((be=ge.details)==null?void 0:be.connect_url)=="string"?ge.details.connect_url:null)??null);else{const Je=Il(ge);S(Object.fromEntries(Object.entries(Je.fields).filter(([tt])=>me.has(tt)))),_([...Je.rest,...Object.entries(Je.fields).filter(([tt])=>!me.has(tt)).map(([,tt])=>tt)])}}L(!1)},X=()=>v8(b,H,V!==void 0),re=le=>{le.preventDefault();const{body:me,issues:Ke}=X();if(_([]),M(null),!me){S(Ke??{});return}J(me)},ae=()=>{const le=P;A(null),le&&J({...le.body,source:{...le.body.source,move_subscription:!0}})},ye=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),he=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(Cm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New app trigger"]});if(i)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[ye,he,t.jsx(en,{problem:i,onRetry:()=>u(le=>le+1),className:"mt-4"})]});if(r===null)return t.jsx(Qn,{label:"Reading the saved Composio servers",rows:3});if(!r.length)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[ye,he,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Save a Composio server first: ",t.jsx("a",{href:"#/settings/mcp",className:"underline underline-offset-2",children:"Settings → MCP servers"}),", Add from Composio. A trigger from an app uses its key and the account it is connected as."]})]});const we=Ol((k??[]).filter(le=>!le.archived_at));return t.jsxs("form",{onSubmit:re,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[ye,he,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event Composio delivers for it starts a capped run of the agent. This server makes the trigger on Composio for the account the server is connected as."}),s&&t.jsx("p",{className:"mt-4 border border-warning/50 p-3 text-body",role:"status",children:Hb}),$.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[$.map((le,me)=>t.jsx("p",{className:"break-words",children:le},me)),O&&t.jsx("a",{href:O,target:"_blank",rel:"noreferrer",className:"mt-2 inline-block underline underline-offset-2",children:"Connect the account"})]}),t.jsxs("div",{className:"mt-5 space-y-5",children:[t.jsx(It,{label:"Name",field:"name",issue:N.name,children:t.jsx(De,{name:"name",value:b.name,onChange:le=>D("name")(le.target.value),placeholder:"new issues"})}),t.jsx(It,{label:"Composio server",field:"source.server",issue:N["source.server"],children:t.jsx(Mt,{name:"server",label:"Composio server",className:"w-full",value:b.server,onChange:G,options:[{value:"",label:"Pick a server"},...r.map(le=>({value:le.name,label:le.toolkit?`${le.name} (${le.toolkit})`:le.name}))]})}),b.server&&(y?t.jsx(en,{problem:y,onRetry:()=>x(le=>le+1),className:""}):t.jsx(It,{label:"Event",field:"source.event",issue:N["source.event"],hint:q==null?void 0:q.description,children:t.jsx(Mt,{name:"event",label:"Event",className:"w-full",value:b.event,onChange:F,disabled:!f,options:[{value:"",label:f?f.events.length?"Pick an event":"Composio offers no event for this toolkit":"Loading the events"},...((f==null?void 0:f.events)??[]).map(le=>({value:le.slug,label:le.name||le.slug}))]})})),q&&t.jsxs(t.Fragment,{children:[q.polled&&t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:"Composio checks for it every few minutes, so a run starts some minutes after the event."}),q.instructions&&t.jsx("p",{className:"whitespace-pre-wrap text-small text-muted-foreground",children:q.instructions}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Config"}),t.jsxs("p",{className:"mb-2 mt-1 text-small text-muted-foreground",children:["What Composio watches for ",t.jsx("span",{className:"font-mono",children:q.slug}),"."]}),t.jsx(hr,{issues:N,field:"source.config"}),H.length?t.jsx("div",{className:"space-y-4",children:H.map(le=>t.jsx(jU,{field:le,value:b.config[le.name]??le.initial,issue:N[`source.config.${le.name}`],onChange:me=>Y(Ke=>({...Ke,config:{...Ke.config,[le.name]:me}}))},`${q.slug}:${le.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(t$,{where:b.where,onChange:D("where"),issues:N})]}),t.jsx(It,{label:"Agent",field:"target.agent_id",issue:N["target.agent_id"],children:t.jsx(Mt,{name:"agent",label:"Agent",className:"w-full",value:b.agentId,onChange:le=>D("agentId")(le),options:[{value:"",label:k?"Pick an agent":"Loading the agents"},...we.map(le=>({value:le.agent_id,label:`${le.definition.name||le.agent_id}${le.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(It,{label:"Each run is asked",field:"target.input",issue:N["target.input"],hint:"What Composio delivered comes with it.",children:t.jsx(on,{name:"content",rows:4,className:"p-3 font-sans",value:b.content,onChange:le=>D("content")(le.target.value)})}),t.jsx(It,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:N["target.max_cost_usd"],hint:V!==void 0?`Uses the agent's default (${ma(V)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(De,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:b.maxCost,onChange:le=>D("maxCost")(le.target.value),placeholder:Kd(V)})})]}),P&&t.jsxs("div",{role:"alertdialog","aria-label":"Move the subscription here?",className:"mt-6 space-y-3 border border-warning/50 p-4 text-body",children:[t.jsxs("p",{children:["Composio sends this project's events to ",t.jsx("code",{className:"break-all font-mono text-small",children:P.url})," now. Moving them here stops them arriving there: anything listening at ",t.jsx("code",{className:"break-all font-mono text-small",children:P.url})," (another AgentRun server, or a tool of yours) gets no more events."]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"solid",onClick:ae,children:"Move it here"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>A(null),children:"Keep it there"})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:R||!!P||s,children:R?"Creating":"Create app trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function jU({field:e,value:n,issue:s,onChange:r}){const o=`config-${e.name}`,i=s?t.jsx("span",{"data-issue":`source.config.${e.name}`,children:s}):void 0;return e.type==="boolean"?t.jsxs("div",{"data-config-field":e.name,children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:o,checked:n==="true",onChange:c=>r(c.target.checked?"true":"false"),className:"accent-primary"})," ",e.title]}),e.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.description}),s&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert",children:i})]}):t.jsx("div",{"data-config-field":e.name,children:t.jsx(St,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(Mt,{name:o,label:e.title,className:"w-full",value:n,onChange:r,options:[...e.required?[]:[{value:"",label:"None"}],...e.options.map(c=>({value:c,label:c}))],placeholder:"Pick one"}):e.type==="json"?t.jsx(on,{name:o,rows:3,className:"p-3 font-mono",value:n,onChange:c=>r(c.target.value),spellCheck:!1}):t.jsx(De,{name:o,type:e.sealed?"password":void 0,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:c=>r(c.target.value),autoComplete:e.sealed?"new-password":"off",spellCheck:!1})})})}function kU(e,n){const s=n!==null?`, up to ${n} at once; past that, a request waits for one of them to end`:"";return e?`With a filter, each request it takes starts its own run${n!==null?s:", even while an earlier run is still going"}. Any other request is answered and starts nothing.`:n!==null?`Every signed request starts a run${s}.`:"Every signed request starts a run. One that comes while its last run is still going is skipped."}function ZE({signature:e,rules:n,onChange:s,issues:r,cap:o}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(hr,{issues:r,field:"source.accept"}),t.jsx(qE,{name:"accept",rules:n,onChange:s,issues:r,room:Bd.rules-n.length,eventHint:BE[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:kU(n.length>0,o)})]})]})}function e$({picks:e,onChange:n,issues:s}){const r=i=>n({...e,events:e.events.includes(i)?e.events.filter(c=>c!==i):[...e.events,i]}),o=mh(e).map(i=>i.id);return t.jsxs(t.Fragment,{children:[t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Events"}),t.jsx("div",{className:"mt-1 space-y-3",children:CE.map(i=>{const c=o.indexOf(`event:${i}`),d=`source.accept[${c}]`;return t.jsxs("div",{"data-github-event":i,className:"space-y-1",children:[fh.filter(u=>u.event===i).map(({event:u,action:f,label:g})=>{const y=`${u}:${f}`;return t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"event",value:y,checked:e.events.includes(y),onChange:()=>r(y),className:"accent-primary"}),g," ",t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[u," ",f]})]},y)}),c>=0&&t.jsxs("div",{className:"ml-6 space-y-1 pt-1",children:[[d,`${d}.event`,`${d}.actions`].map(u=>t.jsx(hr,{issues:s,field:u},u)),t.jsx(vh,{name:`github-${i}`,at:d,where:e.where[i]??[],onChange:u=>n({...e,where:{...e.where,[i]:u}}),issues:s,label:`Only when, for ${i}`})]})]},i)})}),s["source.accept"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.accept",children:s["source.accept"]})]}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Other events ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsx("p",{className:"mb-2 mt-1 text-small text-muted-foreground",children:"Any other GitHub event, by its name."}),t.jsx(qE,{name:"other",rules:e.other,onChange:i=>n({...e,other:i}),issues:s,indexOf:i=>{var c;return o.indexOf(`other:${(c=e.other[i])==null?void 0:c.key}`)},room:Bd.rules-o.length,eventHint:BE.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function NU({v2:e,go:n,trigger:s}){const r=Pb(s)?s:null,o=Db(s)?s:null,[i,c]=p.useState(()=>r?(r.source.accept??[]).map(mm):o?(o.source.accept??[]).map(mm):[]),[d,u]=p.useState(()=>r||o?{events:[],where:{},other:[]}:m8(s.source.accept)),f=o&&i[0]&&!i[0].actions.trim()?i[0]:null,g=o?i.slice(f?1:0):[],[y,v]=p.useState({}),[h,x]=p.useState([]),[b,j]=p.useState(!1),k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const E=async $=>{$.preventDefault();const{source:_,issues:O}=r?SE(r.source,i):o?x8(o.source,(f==null?void 0:f.where)??[],g,f==null?void 0:f.was):EE(d);if(x([]),Object.keys(O).length){v(O);return}v({}),j(!0);try{md(_,s.source)||await e.updateTrigger(s.id,{source:_}),k.current&&n(Vn(s.id))}catch(M){if(!k.current)return;const P=Il(M),A=qd(r||o?i.map(R=>R.where.length):mh(d).map(R=>R.where.length));v(Object.fromEntries(Object.entries(P.fields).filter(([R])=>A.has(R)))),x([...P.rest,...Object.entries(P.fields).filter(([R])=>!A.has(R)).map(([,R])=>R)]),j(!1)}},N=r?ml:o?Cm:_m,S=$=>c(f?$.length?[{...f,where:$},...g]:g:$.length?[{...cE(),event:o.source.event,where:$},...g]:g);return t.jsxs("form",{onSubmit:$=>void E($),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:Vn(s.id),className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," ",s.name]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(N,{className:"size-5 text-primary-text","aria-hidden":!0}),"Edit filter"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:r?"Which signed requests start a run. Its URL and secret stay as they are.":o?`Which ${o.source.event} events from ${o.source.server} start a run. Its event, its config and its instance on Composio stay as they are.`:"Which events from this server's GitHub App start a run."}),h.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:h.map(($,_)=>t.jsx("p",{children:$},_))}),t.jsx("div",{className:"mt-5 space-y-5",children:r?t.jsx(ZE,{signature:r.source.signature??"standard",rules:i,onChange:c,issues:y,cap:s.max_active_runs??null}):o?t.jsx(t$,{where:(f==null?void 0:f.where)??[],onChange:S,issues:y,others:g.map($=>$.event+($.actions.trim()?` (${$.actions.trim()})`:""))}):t.jsx(e$,{picks:d,onChange:u,issues:y})}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:b,children:b?"Saving":"Save filter"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(Vn(s.id)),children:"Cancel"})]})]})}function t$({where:e,onChange:n,issues:s,others:r=[]}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(hr,{issues:s,field:"source.accept"}),t.jsx(hr,{issues:s,field:"source.accept[0]"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A condition reads what Composio delivers: the event's data is under /data, such as /data/title for a new issue's title."}),t.jsx(vh,{name:"composio",at:"source.accept[0]",where:e,onChange:n,issues:s,label:"Only when"}),r.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[r.length===1?"One more rule, made through the API, is kept as it is":`${r.length} more rules, made through the API, are kept as they are`,": ",r.join(", "),"."]})]})]})}function SU({check:e,newest:n}){const s=n&&n.by==="feed"&&n.status==="skipped"&&!n.run_id&&n.reason?n.reason:null;return t.jsxs("section",{"aria-label":"Last check","data-last-check":e?e.ok?"ok":"failed":"none",className:`mt-4 border px-4 py-3 text-body ${e&&!e.ok?"border-warning/50 bg-warning/10":"border-primary/50 bg-primary/5"}`,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:e?`${e.ok?"Last check":"Last check failed"} · ${Nl(e.at)}`:"Not checked yet"}),e&&t.jsx("p",{className:`mt-1 break-words ${e.ok?"":"text-warning-text"}`,children:e.message}),s&&t.jsx("p",{className:"mt-1 break-words","data-note":!0,children:s})]})}function n$({v2:e,go:n,trigger:s,minEvery:r}){var P;const[o,i]=p.useState(()=>s?y8(s):TE()),[c,d]=p.useState(null),[u,f]=p.useState({}),[g,y]=p.useState([]),[v,h]=p.useState(!1),[x,b]=p.useState(()=>!!s&&(s.source.items!==void 0||s.source.id!==void 0));p.useEffect(()=>{(u["source.items"]||u["source.id"])&&b(!0)},[u]);const j=p.useRef(br()).current,k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useEffect(()=>{s||Vd(e).then(d,()=>d([]))},[e,s]);const E=A=>R=>i(L=>({...L,[A]:R})),N=(P=(c??[]).find(A=>A.agent_id===o.agentId))==null?void 0:P.definition.max_cost_usd,S=typeof N=="number"&&N>0?N:void 0,$=async A=>{A.preventDefault();const R=k8(RE(o.urls).urls.length,[o.where.length,...o.others.map(Y=>Y.where.length)]);y([]);const L=Y=>{if(!k.current)return;const D=Il(Y);f(Object.fromEntries(Object.entries(D.fields).filter(([G])=>R.has(G)))),y([...D.rest,...Object.entries(D.fields).filter(([G])=>!R.has(G)).map(([,G])=>G)]),h(!1)};if(s){const{source:Y,issues:D}=AE(o,r);if(Object.keys(D).length){f(D);return}f({}),h(!0);try{md(Y,s.source)||await e.updateTrigger(s.id,{source:Y}),k.current&&n(Vn(s.id))}catch(G){L(G)}return}const{body:W,issues:U}=j8(o,r,S!==void 0);if(!W){f(U??{});return}f({}),h(!0);try{const Y=await e.createTrigger(W,j.keyFor("createTrigger",W));k.current&&n(Vn(Y.id))}catch(Y){L(Y)}},_=Object.entries(u).filter(([A])=>/^source\.urls(\[\d+\])?$/.test(A)),O=Ol((c??[]).filter(A=>!A.archived_at)),M=o.others.map(A=>A.event+(A.actions.trim()?` (${A.actions.trim()})`:""));return t.jsxs("form",{onSubmit:A=>void $(A),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Vn(s.id):"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," ",s?s.name:"Triggers"]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(rv,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit feed":"New feed trigger"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:s?"The feeds it reads, how often, and which items start a run. Its name, its agent and what each run is asked stay as they are.":"Each new or updated item in its feeds starts a capped run of the agent. The items already there when it is made start none: its first check, on its page once it is made, says how many."}),g.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:g.map((A,R)=>t.jsx("p",{children:A},R))}),t.jsxs("div",{className:`mt-5 ${Cd}`,children:[!s&&t.jsx(It,{label:"Name",field:"name",issue:u.name,children:t.jsx(De,{name:"name",value:o.name,onChange:A=>E("name")(A.target.value),placeholder:"vendor outages"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(St,{className:"min-w-0",label:"Feed URLs",hint:`One a line, 1 to ${Mx}: RSS, Atom, JSON Feed, or an API's JSON list. Plain http is read on a public address alone.`,error:_.length?t.jsx(t.Fragment,{children:_.map(([A,R])=>t.jsx("span",{"data-issue":A,className:"block",children:R},A))}):void 0,children:t.jsx(on,{name:"urls",rows:4,className:"p-3 font-mono text-small",value:o.urls,onChange:A=>E("urls")(A.target.value),placeholder:"https://www.githubstatus.com/history.atom",spellCheck:!1})}),s&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"note",children:"A feed you add starts from now: what's in it already won't start runs."})]}),t.jsx(It,{label:"Every",field:"source.every_s",issue:u["source.every_s"],hint:r?zb(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(De,{name:"every",inputMode:"decimal",value:o.every,onChange:A=>E("every")(A.target.value),placeholder:"15"}),t.jsx(Mt,{id:"feed-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:o.everyUnit,onChange:A=>E("everyUnit")(A),options:["seconds","minutes","hours"].map(A=>({value:A,label:A}))})]})}),t.jsxs("details",{"data-json-list":!0,open:x,onToggle:A=>b(A.currentTarget.open),className:"min-w-0 border p-3",children:[t.jsxs("summary",{className:"cursor-pointer text-body font-semibold",children:["JSON list ",t.jsx("span",{className:"font-normal text-small text-muted-foreground",children:"(optional: a feed that is an API's JSON, such as GitHub's pull requests)"})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(It,{label:"Items at",field:"source.items",issue:u["source.items"],hint:"A JSON Pointer to the array of items: empty for the whole document, /data/items for one inside it.",children:t.jsx(De,{name:"items",value:o.items,onChange:A=>E("items")(A.target.value),placeholder:"/data/items",autoComplete:"off",spellCheck:!1})}),t.jsx(It,{label:"Each item's id at",field:"source.id",issue:u["source.id"],hint:"A JSON Pointer into an item to what names it: empty for /id, /number for a pull request.",children:t.jsx(De,{name:"id",value:o.id,onChange:A=>E("id")(A.target.value),placeholder:"/id",autoComplete:"off",spellCheck:!1})})]})]}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(hr,{issues:u,field:"source.accept"}),t.jsx(hr,{issues:u,field:"source.accept[0]"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A condition reads the item: /title, /link, /summary, /author, /categories, /feed/url, and /update (true for an item seen before that was updated). A JSON list's item is under /item."}),t.jsx(vh,{name:"feed",at:"source.accept[0]",where:o.where,onChange:E("where"),issues:u,label:"Only when"}),M.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[M.length===1?"One more rule, made through the API, is kept as it is":`${M.length} more rules, made through the API, are kept as they are`,": ",M.join(", "),"."]})]})]}),!s&&t.jsxs(t.Fragment,{children:[t.jsx(It,{label:"Agent",field:"target.agent_id",issue:u["target.agent_id"],children:t.jsx(Mt,{name:"agent",label:"Agent",className:"w-full",value:o.agentId,onChange:A=>E("agentId")(A),options:[{value:"",label:c?"Pick an agent":"Loading the agents"},...O.map(A=>({value:A.agent_id,label:`${A.definition.name||A.agent_id}${A.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(It,{label:"Each run is asked",field:"target.input",issue:u["target.input"],hint:"The item comes with it: its title, link, summary and feed.",children:t.jsx(on,{name:"content",rows:4,className:"p-3 font-sans",value:o.content,onChange:A=>E("content")(A.target.value)})}),t.jsx(It,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:u["target.max_cost_usd"],hint:S!==void 0?`Uses the agent's default (${ma(S)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(De,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:o.maxCost,onChange:A=>E("maxCost")(A.target.value),placeholder:Kd(S)})})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:v,children:v?s?"Saving":"Creating":s?"Save feed":"Create feed trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Vn(s.id):"#/triggers"),children:"Cancel"})]})]})}const s$=e=>e?"#/playground?operation=apply-template":"#/templates";function Y0({v2:e,name:n,install:s,go:r,playground:o=!1,draft:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,y]=p.useState(0);p.useEffect(()=>{if(s!==void 0)return;let b=!0;return f(null),e.listTemplates().then(j=>{b&&d(j.templates)},j=>{b&&f(Jt(j,"the templates"))}),()=>{b=!1}},[e,g,s]);const v=n===void 0||c==null?void 0:c.find(b=>b.id===n),h=s!==void 0?t.jsx(EU,{v2:e,source:s,go:r}):u&&!c?t.jsx(en,{problem:u,onRetry:()=>y(b=>b+1),className:""}):c?n===void 0?t.jsx(CU,{v2:e,templates:c,go:r,playground:o,onRemoved:()=>y(b=>b+1)}):v?t.jsx(RU,{v2:e,template:v,go:r,playground:o,draft:i},`${v.id}:${i??""}`):t.jsxs("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",role:"alert",children:["This server offers no template named ",n,". ",t.jsx("a",{href:s$(o),className:"underline",children:"See its templates"}),"."]}):t.jsx(Qn,{label:"Loading the templates",rows:3});if(o)return t.jsx("div",{className:"p-5 md:p-8",children:h});const x=s===void 0&&n===void 0;return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsx("header",{className:te(vr,"flex-wrap gap-2 px-5 md:px-6"),children:x?t.jsxs("h1",{className:Jo,children:[t.jsx(Tm,{className:"size-4","aria-hidden":!0}),"Templates"]}):t.jsx("nav",{"aria-label":"Breadcrumb",children:t.jsxs("a",{href:"#/templates",className:te(Jo,"text-muted-foreground hover:text-foreground"),children:[t.jsx(Fn,{className:"size-4","aria-hidden":!0}),"Templates"]})})}),t.jsx("div",{className:"p-5 md:p-6",children:h})]})}function qb({t:e}){var n;return e.source?t.jsxs("p",{className:"mt-1 break-all font-mono text-small text-muted-foreground","data-provenance":!0,children:[e.source," at ",(n=e.sha)==null?void 0:n.slice(0,12),", published by ",e.publisher]}):null}function CU({v2:e,templates:n,go:s,playground:r,onRemoved:o}){const i=r?"h2":"h1",c=r?"h3":"h2",[d,u]=p.useState(""),[f,g]=p.useState(null),[y,v]=p.useState(null),h=async x=>{g(x.id),v(null);try{await e.deleteTemplate(x.id),o()}catch(b){v(b instanceof Error?b.message:String(b))}finally{g(null)}};return t.jsxs(t.Fragment,{children:[r&&t.jsx(i,{className:"mb-5 text-2xl font-semibold",children:"Templates"}),t.jsxs("form",{"aria-label":"Add from URL",className:"mb-5 flex flex-wrap items-end gap-2 border bg-card px-4 py-3",onSubmit:x=>{x.preventDefault(),d.trim()&&s($U(d.trim()))},children:[t.jsxs("label",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:"Add from URL"}),t.jsx("span",{className:"mb-1.5 block text-small text-muted-foreground",children:"A package on GitHub: github:owner/repo/path@ref, or its github.com/…/tree/… address. You read it whole before anything is stored."}),t.jsx(De,{type:"text",value:d,placeholder:"github:owner/repo/templates/name@main",onChange:x=>u(x.target.value)})]}),t.jsx(B,{size:"sm",variant:"solid",type:"submit",disabled:!d.trim(),children:"Read it"})]}),y&&t.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:y}),n.length?t.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:n.map(x=>t.jsx("li",{children:t.jsxs("article",{"aria-label":Vo(x),className:"flex h-full flex-col border bg-card px-5 py-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx(Tm,{className:"size-4 shrink-0 self-center text-muted-foreground","aria-hidden":!0}),t.jsx(c,{className:"min-w-0 break-words text-prose font-semibold",children:Vo(x)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:x.version}),x.category&&t.jsx(Ne,{tone:"muted",children:x.category}),!x.bundled&&t.jsx(Ne,{tone:"muted",children:"Imported"})]}),t.jsx(qb,{t:x}),t.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:x.description}),x.tags.length>0&&t.jsx("p",{"aria-label":"Tags",className:"mt-1.5 break-words font-mono text-small text-muted-foreground",children:x.tags.join(" · ")}),t.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:Ub(x).map(([b,j])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0",children:b}),t.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:j})]},b))}),t.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:[!x.bundled&&t.jsx(B,{size:"sm",onClick:()=>void h(x),disabled:f===x.id,children:f===x.id?"Removing…":"Remove"}),r?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>s(ll(x)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:xm(x)?"primary":"outline",onClick:()=>s(PE(x.id)),children:"Configure"}),t.jsx(an,{variant:xm(x)?"outline":"primary",label:"Run",prompt:gx(location.origin,x),playgroundHref:ll(x)})]})]})]})},x.id))}):t.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:"This server offers no templates yet."})]})}function EU({v2:e,source:n,go:s}){var k;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,v]=p.useState(null);p.useEffect(()=>{let E=!0;if(!n){c("Give a package's source: github:owner/repo/path@ref.");return}return e.importTemplate(n,{dryRun:!0}).then(N=>{E&&o(N)},N=>{E&&c(Q0(N))}),()=>{E=!1}},[e,n]);const h=async()=>{g(!0),v(null);try{if(!r)return;const E=await e.importTemplate(`${r.template.id}@${r.template.sha}`,{trustPublisher:d});s(PE(E.template.id))}catch(E){v(Q0(E))}finally{g(!1)}};if(i)return t.jsx("div",{className:"max-w-3xl",children:t.jsx("p",{className:"border px-4 py-6 font-mono text-body text-destructive-text",role:"alert",children:i})});if(!r)return t.jsx(Qn,{label:"Reading the package from GitHub",rows:3});const x=r.template,b=x.publisher??"",j=Object.entries(r.skill_files);return t.jsxs("section",{"aria-label":"Install from GitHub",className:"max-w-3xl",children:[t.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[Vo(x)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:x.version})]}),t.jsxs("dl",{className:"mt-3 space-y-1 border bg-card px-4 py-3 font-mono text-small",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Publisher"}),t.jsxs("dd",{"data-publisher":!0,children:[b,r.publisher_trusted?" (trusted here)":" (new here)"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Commit"}),t.jsx("dd",{className:"break-all","data-sha":!0,children:x.sha})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Source"}),t.jsx("dd",{className:"break-all",children:x.source})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Installs as"}),t.jsxs("dd",{className:"break-all",children:[x.id,r.replaced?`, replacing the one read at ${r.replaced.slice(0,12)}`:""]})]})]}),t.jsx("p",{className:"mt-3 text-lead leading-[1.6]",children:x.description}),t.jsx(dr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:Ub(x,{mcp:!1}).map(([E,N])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:E}),t.jsx("dd",{className:"min-w-0 break-words",children:N})]},E))})}),x.mcp.length>0&&t.jsx(dr,{title:"MCP tools it asks for",note:"None is granted by installing: the Apply screen asks you to tick each one.",children:x.mcp.map(E=>t.jsxs("div",{"data-mcp":E.toolkit,className:"px-4 py-3",children:[t.jsx(r$,{m:E}),t.jsx("p",{className:"mt-1 break-words font-mono text-small",children:E.tools.map(N=>N.name).join(", ")})]},E.toolkit))}),t.jsx(o$,{t:x}),t.jsx(a$,{t:x}),t.jsx(dr,{title:"Instructions",note:"What the agent is told, in full: a package from someone else says this to your agent.",children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-instructions":!0,children:r.instructions})}),((k=x.output)==null?void 0:k.json_schema)&&t.jsx(dr,{title:"Output schema",note:`What the agent is told to answer in (${x.output.schema}), in full: its descriptions are instructions too.`,children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-output-schema":!0,children:JSON.stringify(x.output.json_schema,null,2)})}),j.length>0&&t.jsx(dr,{title:"Skill files",note:"Every file the agent is given, in full.",children:j.map(([E,N])=>t.jsxs("details",{className:"px-4 py-2","data-skill-file":E,children:[t.jsx("summary",{className:"cursor-pointer font-mono text-body",children:E}),t.jsx("pre",{className:"mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:N})]},E))}),!r.publisher_trusted&&t.jsxs("label",{className:"mt-6 flex items-start gap-2.5 border border-warning/50 px-4 py-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:d,onChange:E=>u(E.target.checked)}),t.jsxs("span",{children:[t.jsxs("span",{className:"font-mono text-body",children:["I trust ",b]}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:["This server has no package from ",b," yet. Ticked, it remembers that you trust them."]})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void h(),disabled:f||!r.publisher_trusted&&!d,children:f?"Installing…":"Install"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Installing stores it; nothing runs and nothing is granted until you apply it."}),y&&t.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:y})]})]})}function Q0(e){var n;return e instanceof Ue&&((n=e.fields)!=null&&n.length)?[...new Set([e.message,...e.fields.map(s=>s.message)])].join(" "):e instanceof Error?e.message:String(e)}const $U=e=>`#/templates/install?src=${encodeURIComponent(e)}`,_U=3e3;function TU(e,n){let s;const r=new Promise(o=>s=setTimeout(()=>o(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function RU({v2:e,template:n,go:s,playground:r=!1,draft:o}){var Re,lt,$t,nt,fe,st,Qe,ct,gt,Et;const i=r?"h2":"h1",c={fields:ph(n.parameters)??[]},d=z8(o,n),[u,f]=p.useState(()=>{var se;return{...Object.fromEntries(c.fields.filter(([,$e])=>$e.type==="boolean"&&!$e.array).map(([$e])=>[$e,"false"])),...FE(c),...Object.fromEntries(Object.entries(((se=d.body)==null?void 0:se.parameters)??{}).map(([$e,Fe])=>[$e,Array.isArray(Fe)?Fe.map(String).join(`
654
+ `):String(Fe)]))}}),[g,y]=p.useState(()=>{var se;return new Set(((se=d.body)==null?void 0:se.grants)??[])}),[v,h]=p.useState(((lt=(Re=d.body)==null?void 0:Re.overrides)==null?void 0:lt.approvals)??n.approvals_default??"ask"),[x,b]=p.useState(((nt=($t=d.body)==null?void 0:$t.overrides)==null?void 0:nt.choice)??""),[j,k]=p.useState(null),[E,N]=p.useState(null),[S,$]=p.useState(0),[_,O]=p.useState(()=>{var se;return((se=d.body)==null?void 0:se.servers)??{}}),[M,P]=p.useState(!1),[A,R]=p.useState([]),[L,W]=p.useState(null),[U,Y]=p.useState(null),[D,G]=p.useState([]),[F,q]=p.useState({}),H=p.useRef(br()).current,[I,V]=p.useState([]);p.useEffect(()=>{let se=!0;return Mr($e=>e.listAgents({cursor:$e}),$e=>$e.agents,Number.POSITIVE_INFINITY).then($e=>$e.filter(Fe=>{var et;return((et=Fe.template)==null?void 0:et.id)===n.id}).map(Fe=>{var et;return{id:Fe.agent_id,name:((et=Fe.definition)==null?void 0:et.name)||Fe.agent_id}})).then($e=>{se&&V($e)},()=>{}),()=>{se=!1}},[e,n.id]);const J=p.useRef(!0);p.useEffect(()=>(J.current=!0,()=>{J.current=!1}),[]),p.useEffect(()=>{let se=!0;return N(null),e.listMcpServers().then($e=>{se&&k($e.servers)},$e=>{se&&N(Jt($e,"the saved MCP servers"))}),()=>{se=!1}},[e,S]);const X=B8(n,g),re=n.mcp.map(se=>{const $e=j?U8(se,j):[];return{m:se,matches:$e,uses:$e.length===1?$e[0]:$e.includes(_[se.toolkit]??"")?_[se.toolkit]:void 0}}),ae=Object.fromEntries(re.flatMap(({m:se,uses:$e})=>$e?[[se.toolkit,$e]]:[])),ye=re.filter(({matches:se,uses:$e})=>se.length>1&&!$e).map(({m:se})=>se.toolkit),he=n.mcp.length>0&&j===null,we=j&&re.some(({m:se,matches:$e})=>{var Fe,et;return((et=(Fe=d.body)==null?void 0:Fe.servers)==null?void 0:et[se.toolkit])!==void 0&&!$e.includes(d.body.servers[se.toolkit])}),ze=d.error??(we?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),le=!!ze||he||ye.length>0,me=r||xm(n),Ke=!r&&xm(n)?V0.filter(se=>se.needs(n)):[],[be,ge]=p.useState({}),[Je,tt]=p.useState(0),ft=Ke.map(se=>se.id).join(" ");p.useEffect(()=>{let se=!0;for(const $e of V0.filter(Fe=>ft.split(" ").includes(Fe.id)))$e.met(e).then(Fe=>{se&&ge(et=>({...et,[$e.id]:Fe?"met":"unmet"}))},()=>{se&&ge(Fe=>({...Fe,[$e.id]:"unread"}))});return()=>{se=!1}},[e,ft,Je]);const ve=Ke.filter(se=>be[se.id]!=="met"),Ee=ve.find(se=>be[se.id]===void 0),Q=ve.length>0;p.useEffect(()=>{if(!Q)return;const se=()=>tt($e=>$e+1);return window.addEventListener("focus",se),()=>window.removeEventListener("focus",se)},[Q]);const Me={parameters:xh(c,u),...X.length?{grants:X}:{},...Object.keys(ae).length?{servers:ae}:{},overrides:{approvals:v,...x?{choice:x}:{}}},pe=se=>q8(A,se),ne=(se,$e,Fe)=>{f(et=>({...et,[se]:Fe})),DE($e,Fe)&&R(et=>et.filter(Dt=>Px(Dt.field,"parameters")!==se))},Ae=async se=>{var et,Dt;if(!me||le||ve.length)return;P(!0),R([]),W(null);const $e=u,Fe=se?{...Me,agent_id:se}:Me;try{const Le=await e.applyTemplate(n.id,Fe,H.keyFor(n.id,Fe));H.done();const rt=async()=>(await Promise.all(Le.trigger_ids.map(Rt=>TU(e.getTrigger(Rt),_U).catch(()=>null)))).filter(Rt=>Rt!=null&&Lb(Rt));if(Le.warnings.length||(et=Le.webhook_secrets)!=null&&et.length){q($e),Y(Le),rt().then(G,()=>{});return}const Ft=Le.trigger_ids.length?await rt():[];if(!J.current)return;if(!Ft.length){s(Cn(Le.agent_id));return}q($e),G(Ft),Y(Le)}catch(Le){Le instanceof Ue&&((Dt=Le.fields)!=null&&Dt.length)?(R(Le.fields),W({text:Le.message,withIssues:!0}),Le.fields.some(rt=>rt.field.startsWith("servers.")||rt.field.startsWith("mcp."))&&$(rt=>rt+1)):W({text:Le instanceof Error?Le.message:String(Le),withIssues:!1})}finally{P(!1)}},Pe=c.fields,bt=se=>se.filter($e=>!n.secrets.includes($e)),ot=(st=(fe=n.model)==null?void 0:fe.choices)==null?void 0:st.find(se=>se.id===x),mt=se=>{var $e,Fe;return/^(parameters|mcp|servers)\./.test(se.field)||/^grants\.\d+$/.test(se.field)||se.field==="overrides.choice"&&!!((Fe=($e=n.model)==null?void 0:$e.choices)!=null&&Fe.length)||se.field.startsWith("secrets.")&&[...n.secrets,...bt((ot==null?void 0:ot.secrets)??[])].includes(se.field.slice(8))};return U?t.jsxs("section",{"aria-label":"Applied",className:"max-w-page",children:[t.jsxs(i,{className:"mb-4 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(Cl,{className:"size-5 text-success-text","aria-hidden":!0})," ",Vo(n,F)," applied"]}),U.warnings.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-3 text-lead",children:"The agent is made. The server says:"}),t.jsx("ul",{className:"mb-5 space-y-2 border bg-card px-4 py-3 text-body",role:"status","aria-label":"Warnings",children:U.warnings.map((se,$e)=>{var Le,rt;const Fe=/^triggers\.(\d+)\.secret$/.exec(se.field),et=Fe?U.trigger_ids[Number(Fe[1])]:void 0,Dt=Fe?(Le=n.triggers[Number(Fe[1])])==null?void 0:Le.name:void 0;return et&&((rt=U.webhook_secrets)!=null&&rt.some(Ft=>Ft.trigger_id===et))?t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:se.field})," ",se.message]},`${se.field}:${$e}`):t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:se.field})," ",se.message,se.fix?t.jsx("span",{className:"block text-muted-foreground",children:se.fix}):null,et&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(et)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof Dt=="string"&&Dt?Dt:et," to get its signing secret (Rotate)"]})]},`${se.field}:${$e}`)})})]}),(Qe=U.webhook_secrets)==null?void 0:Qe.map(se=>{var Dt;const $e=U.trigger_ids.indexOf(se.trigger_id),Fe=$e>=0?(Dt=n.triggers[$e])==null?void 0:Dt.name:void 0,et=typeof Fe=="string"&&Fe?Fe:se.trigger_id;return se.signing_secret?t.jsx(Bb,{label:`The webhook's URL and secret (${et})`,url:dd({id:se.trigger_id}),secret:se.signing_secret},se.trigger_id):t.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[se.note&&t.jsx("p",{className:"text-muted-foreground",role:"note",children:se.note}),t.jsxs("a",{href:`#/triggers/${encodeURIComponent(se.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",et," to get its signing secret (Rotate)"]})]},se.trigger_id)}),D.length>0&&t.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:D.map(se=>t.jsxs("li",{"data-trigger":se.id,className:"px-4 py-3",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(se.id)}`,className:"break-words text-prose font-semibold hover:underline",children:se.name}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:Ob(se.source,se.next_at)})]},se.id))}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:Cn(U.agent_id),className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):t.jsxs("div",{children:[r&&t.jsxs("a",{href:s$(r),className:"caps mb-4 inline-flex min-h-6 items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})," Templates"]}),t.jsxs(i,{className:"text-2xl font-semibold",children:[Vo(n,u)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:n.version})]}),t.jsx(qb,{t:n}),t.jsx("p",{className:"mt-2 max-w-prose text-lead leading-[1.6]",children:n.description}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:r?"Apply creates an agent and its triggers. It does not start a run.":me?"Apply creates an agent and its triggers. It does not start a run. Or set it up with your coding agent, which asks for any missing inputs and runs the task.":"Run with your coding agent. It sets up this template, asks for any missing inputs, and runs the task."}),ze&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[ze," ",t.jsx("a",{href:ll(n),className:"underline",children:"Open a fresh request"}),"."]}),t.jsxs("div",{className:`mt-6 ${Cd}`,children:[Pe.length>0&&t.jsx(dr,{title:"Parameters",children:Pe.map(([se,$e])=>t.jsxs("div",{"data-field":`parameters.${se}`,className:"px-4 py-3",children:[t.jsx(HE,{field:$e,label:gh(se,$e),help:vm($e),value:u[se]??"",onChange:Fe=>ne(se,$e,Fe)}),t.jsx(Do,{issues:A.filter(Fe=>Px(Fe.field,"parameters")===se),words:Fe=>WE(Fe,se,$e)})]},se))}),n.mcp.length>0&&t.jsxs(dr,{title:"Tools you grant",note:"Nothing is granted until you tick it. A tool you tick is granted and follows this server's tool settings: a write asks you first unless you allowed it in Settings or choose Never ask, and a read runs without asking where you turned on Allow reads for its server. A tool you leave unticked is not given to the agent, even when it never asks: you can add it later on the agent's page.",children:[E&&!j&&t.jsx("div",{"data-servers-unread":!0,className:"px-4 py-3",children:t.jsx(en,{problem:E,onRetry:()=>$(se=>se+1),className:""})}),re.map(({m:se,matches:$e,uses:Fe})=>t.jsxs("div",{"data-mcp":se.toolkit,className:"px-4 py-3",children:[t.jsx(r$,{m:se,children:j&&$e.length<2&&t.jsx("span",{className:"text-small text-muted-foreground",children:Fe?`Uses ${Fe}`:"Not set up here"})}),j&&$e.length>1&&t.jsxs("label",{className:"mt-2 flex flex-wrap items-center gap-2 text-small text-muted-foreground",children:["Uses",t.jsx(Mt,{small:!0,label:`Server for ${se.toolkit}`,value:Fe??"",placeholder:"Pick one",onChange:et=>O(Dt=>({...Dt,[se.toolkit]:et})),options:$e.map(et=>({value:et,label:et}))}),!Fe&&t.jsxs("span",{"data-unpicked":se.toolkit,children:[$e.length," saved servers are ",Id[se.source]," ",se.toolkit,": pick the one the agent uses."]})]}),j&&$e.length===0&&t.jsxs("p",{role:"status","data-missing-mcp":se.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[se.required?`${se.toolkit} is required and not set up here: Apply is refused until it is.`:`${se.toolkit} is not set up here: Apply makes the agent without its tools (${se.tools.map(et=>et.name).join(", ")}).`," ",t.jsx("a",{href:W8(se),className:"font-mono text-primary-text underline-offset-2 hover:underline",children:se.source==="github"?"Set up GitHub App access":se.source==="composio"?`Add ${se.toolkit} from Composio`:`Set up ${se.toolkit}`})]}),t.jsx(Do,{issues:[...pe(`mcp.${se.toolkit}`),...pe(`servers.${se.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:se.tools.map(et=>{const Dt=X.indexOf(et.tool);return t.jsxs("li",{"data-tool":et.tool,children:[t.jsxs("label",{className:"flex items-start gap-2.5",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:g.has(et.tool),onChange:()=>y(Le=>{const rt=new Set(Le);return rt.has(et.tool)?rt.delete(et.tool):rt.add(et.tool),rt})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:et.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:et.tool}),t.jsx("span",{className:"block text-small text-muted-foreground",children:et.asks==="allow"?"The template asks you to grant this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),Dt>=0&&t.jsx(Do,{issues:pe(`grants.${Dt}`)})]},et.tool)})})]},se.toolkit))]}),n.secrets.length>0&&t.jsx(dr,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:n.secrets.map(se=>t.jsxs("div",{"data-secret":se,className:"px-4 py-3 font-mono text-body",children:[se,t.jsx(Do,{issues:pe(`secrets.${se}`)})]},se))}),(gt=(ct=n.model)==null?void 0:ct.choices)!=null&&gt.length?t.jsxs("fieldset",{"aria-label":"Model",className:"mt-6",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Model"}),t.jsx("div",{className:"mt-2 divide-y border",children:[{id:"",label:`Your default: ${n.model.tier} on ${(Et=n.harness)!=null&&Et.length?n.harness.length===1?n.harness[0]:`the first of ${n.harness.join(", ")} this server runs`:"this server's default harness"}`,warning:null,note:null},...n.model.choices].map(se=>t.jsxs("label",{"data-choice":se.id||"(default)",className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"model-choice",value:se.id,className:"mt-1 accent-primary",checked:x===se.id,onChange:()=>{b(se.id),R($e=>$e.filter(Fe=>Fe.field!=="overrides.choice"&&!(Fe.field.startsWith("secrets.")&&!n.secrets.includes(Fe.field.slice(8)))))}}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body","data-choice-label":!0,children:se.label}),"model"in se&&t.jsxs("span",{className:"block font-mono text-label text-muted-foreground",children:[se.model," on ",se.harness]}),se.warning&&t.jsx("span",{className:"mt-1 block text-small text-warning-text","data-choice-warning":se.id,children:se.warning}),se.note&&t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","data-choice-note":se.id,children:se.note}),"secrets"in se&&x===se.id&&t.jsx("span",{"data-choice-keys":se.id,children:t.jsx(Do,{issues:bt(se.secrets).flatMap($e=>pe(`secrets.${$e}`))})})]})]},se.id||"(default)"))}),t.jsx(Do,{issues:pe("overrides.choice")})]}):null,t.jsxs("fieldset",{"aria-label":"Approvals",className:"mt-6",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),t.jsx("div",{className:"mt-2 divide-y border",children:[["ask","Ask me","A call that asks waits for your answer: a ticked tool's write unless you allowed it in Settings, and its read unless you turned on Allow reads for its server."],["never","Never ask (run unattended)","Runs without asking you, even for writes. Pick this if a trigger starts the agent while you're away."]].map(([se,$e,Fe])=>t.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"approvals",value:se,className:"mt-1 accent-primary",checked:v===se,onChange:()=>h(se)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:$e}),t.jsx("span",{className:"block text-small text-muted-foreground",children:Fe})]})]},se))}),v==="never"&&t.jsx("p",{className:"mt-2 text-small text-warning-text",children:oE})]}),t.jsx(o$,{t:n}),t.jsx(a$,{t:n}),t.jsx(dr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:Ub(n,{secrets:!1,mcp:!1}).map(([se,$e])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:se}),t.jsx("dd",{className:"min-w-0 break-words",children:$e})]},se))})})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[me?t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void Ae(),disabled:M||le||ve.length>0,title:he?E?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":ye.length?`Pick the server for ${ye.join(", ")} first`:Ee?`Reading ${Ee.what}…`:void 0,children:M?"Applying…":"Apply"}),I.map(se=>t.jsx(B,{size:"sm",variant:"outline",onClick:()=>void Ae(se.id),disabled:M||le||ve.length>0,title:`Apply this template onto ${se.name}: a new revision of it, its runs, notes and triggers kept`,children:`Update ${se.name}`},se.id)),!r&&t.jsx(an,{variant:"outline",label:"Set it up with an agent",disabled:le,prompt:gx(location.origin,n,Me),playgroundHref:ll(n,Me)}),ve.map(se=>be[se.id]==="unmet"?t.jsxs("p",{role:"status","data-requirement":se.id,className:"min-w-0 text-body text-warning-text",children:[se.unmet.before,t.jsx("a",{href:se.unmet.href,className:"font-mono text-primary-text underline-offset-2 hover:underline",children:se.unmet.link}),se.unmet.after]},se.id):be[se.id]==="unread"?t.jsxs("p",{role:"alert","data-requirement-unread":se.id,className:"flex min-w-0 flex-wrap items-center gap-2 text-body text-destructive-text",children:[`${se.what[0].toUpperCase()}${se.what.slice(1)} couldn't be read.`,t.jsx(B,{size:"sm",onClick:()=>tt($e=>$e+1),children:"Try again"})]},se.id):null)]}):t.jsx(an,{variant:"primary",label:"Run",disabled:le,prompt:gx(location.origin,n,Me),playgroundHref:ll(n,Me)}),L&&(!L.withIssues||A.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:L.text})]}),A.filter(se=>!mt(se)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(Do,{issues:A.filter(se=>!mt(se)),named:!0})})]})}function r$({m:e,children:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"font-semibold",children:e.toolkit}),t.jsx(Ne,{tone:"muted",children:Id[e.source]}),t.jsx(Ne,{tone:e.required?"plain":"muted",children:e.required?"Required":"Optional"}),n]}),e.reason&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground","data-reason":!0,children:e.reason})]})}function o$({t:e}){if(!e.input_schema)return null;const n=ph(e.input_schema,"content");return n&&!n.length?null:t.jsx(dr,{title:"Run inputs",note:"What each run is given, as the run form asks for it.",children:n?n.map(([s,r])=>t.jsxs("div",{"data-input":s,className:"px-4 py-3",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"font-semibold",children:gh(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(Ne,{tone:"muted",children:sU(r)}),t.jsx(Ne,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),vm(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:vm(r)})]},s)):t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-input-schema":!0,children:JSON.stringify(e.input_schema,null,2)})})}function a$({t:e}){const n=e.evals.length;return t.jsx(dr,{title:"Eval cases",note:n?`The ${n===1?"one case":`${n} cases`} this template is tested on.`:void 0,children:t.jsx("p",{className:"break-words px-4 py-3 font-mono text-small","data-evals":!0,children:n?e.evals.join(", "):"None: this package ships no eval cases, so nothing tests it."})})}function dr({title:e,note:n,children:s}){return t.jsxs("section",{"aria-label":e,className:"mt-6",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:n}),t.jsx("div",{className:"mt-2 divide-y border",children:s})]})}function bm(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function J0(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function AU(e){if(!e)return null;try{const n=JSON.parse(e);if(!n||typeof n!="object"||!("definition"in n))return null;const s=n.definition;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.version!==1||typeof r.name!="string"||typeof r.instructions!="string"||r.harness!=="pi"||r.description!==void 0&&typeof r.description!="string"||!Array.isArray(r.tools)||!r.tools.every(o=>typeof o=="string")||!Array.isArray(r.skills)||r.skills.length!==0?null:{definition:{version:1,name:r.name,instructions:r.instructions,harness:"pi",tools:[...r.tools],skills:[],...typeof r.description=="string"?{description:r.description}:{}}}}catch{return null}}const OU={"code-review":Em,"inbound-lead":yd,kyb:fR,"market-monitor":cR,"release-notes":ai};function MU({origin:e,v2:n}){const[s,r]=p.useState(""),[o,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(0),x=p.useId(),b=Zm(e,s),j=bm(s);p.useEffect(()=>{let N=!0;return y(null),n.listTemplates().then(S=>{N&&f(S.templates)},S=>{N&&y(Jt(S,"the template catalog"))}),()=>{N=!1}},[n,v]);const k=c.trim().toLocaleLowerCase(),E=(u??[]).filter(N=>`${Vo(N)} ${N.description} ${N.name} ${N.id} ${N.publisher??""}`.toLocaleLowerCase().includes(k));return t.jsxs("section",{className:"mx-auto w-full max-w-page-wide px-5 pb-20 pt-10 md:px-12 md:pt-16","aria-labelledby":`${x}-heading`,children:[t.jsxs("header",{className:"text-center",children:[t.jsx("h1",{id:`${x}-heading`,className:"text-2xl font-semibold leading-tight tracking-tight md:text-display",children:"What do you want to build?"}),t.jsx("p",{className:"mt-3 text-base text-muted-foreground",children:"Describe your agent, or pick a template to start from."})]}),t.jsxs("div",{className:"mx-auto mt-8 max-w-page",children:[t.jsxs("div",{className:te(Za,"!rounded-composer overflow-hidden bg-card transition-colors"),"data-agent-composer":!0,children:[t.jsx("label",{htmlFor:`${x}-brief`,className:"sr-only",children:"Describe your agent"}),t.jsx(on,{bare:!0,id:`${x}-brief`,value:s,onChange:N=>r(N.target.value),rows:3,placeholder:"A support agent that answers questions from our docs and escalates to Slack when it’s stuck…",className:"block min-h-28 w-full resize-none px-5 pb-3 pt-5 font-sans text-base leading-relaxed text-foreground md:px-6 md:pt-6"}),t.jsx("div",{className:"flex justify-end px-4 pb-4 pt-1 md:px-5 md:pb-5",children:t.jsx(an,{variant:"primary",label:"Build an agent",prompt:b,playgroundHref:J0(j)})})]}),t.jsxs("details",{className:"mt-3 text-small text-muted-foreground",children:[t.jsx("summary",{className:"ml-auto w-fit cursor-pointer hover:text-foreground",children:"View coding-agent prompt"}),t.jsx("label",{htmlFor:`${x}-prompt`,className:"sr-only",children:"Coding-agent prompt"}),t.jsx(on,{id:`${x}-prompt`,value:b,readOnly:!0,rows:8,spellCheck:!1,className:"mt-3 w-full border bg-card p-4 font-mono text-small leading-relaxed text-foreground"})]})]}),t.jsxs("section",{className:"mt-10 md:mt-12","aria-labelledby":`${x}-templates`,children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("h2",{id:`${x}-templates`,className:"text-lead font-semibold",children:"Start from a template"}),t.jsx("span",{role:"status",className:"text-small text-muted-foreground",children:u===null&&!g?"Loading templates…":u?`${E.length} of ${u.length}`:""})]}),t.jsxs("div",{className:te(Za,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(yd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(De,{bare:!0,type:"search","aria-label":"Search templates",value:c,onChange:N=>d(N.target.value),placeholder:"Search templates…",className:"h-control-md w-full font-sans"})]})]}),g&&t.jsx(en,{problem:g,onRetry:()=>h(N=>N+1),className:"mb-5"}),(u==null?void 0:u.length)===0&&t.jsx("p",{className:"border border-border px-5 py-10 text-center text-lead text-muted-foreground",children:"This server has no template packages yet. Describe the agent you want to build above."}),u&&u.length>0&&!E.length&&t.jsxs("p",{role:"status",className:"border border-border px-5 py-10 text-center text-muted-foreground",children:["No templates match “",c,"”."]}),t.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:E.map(N=>{const S=o===N.id,$=OU[N.name]??Tm,_=`${x}-${encodeURIComponent(N.id)}-actions`,O=[N.skills.length?`${N.skills.length} skill${N.skills.length===1?"":"s"}`:"Ready to configure",N.triggers.length?`${N.triggers.length} trigger${N.triggers.length===1?"":"s"}`:""].filter(Boolean).join(" · ");return t.jsxs("article",{className:`flex flex-col overflow-hidden border transition-colors ${S?"border-border-strong bg-card":"border-border hover:border-border-strong"}`,children:[t.jsxs("button",{type:"button","aria-expanded":S,"aria-controls":_,"aria-label":`Start with ${Vo(N)}${N.source?` from ${N.id}`:""}`,className:"flex min-h-48 flex-1 flex-col p-5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>i(S?null:N.id),children:[t.jsx("h3",{className:"text-lg font-semibold leading-snug",children:Vo(N)}),t.jsx(qb,{t:N}),t.jsx("p",{className:"mt-3 line-clamp-3 text-lead leading-relaxed text-muted-foreground",children:N.description}),t.jsxs("span",{className:"mt-auto flex w-full items-center gap-2 pt-5 text-small text-muted-foreground",children:[t.jsx($,{className:"size-4","aria-hidden":!0}),O,t.jsx(Zx,{className:"ml-auto size-3.5","aria-hidden":!0})]})]}),S&&t.jsxs("div",{id:_,className:"flex flex-wrap items-center justify-end gap-2 border-t px-4 py-4",children:[t.jsxs("span",{className:"mr-auto font-mono text-small text-muted-foreground",children:["v",N.version]}),t.jsx(an,{variant:"primary",label:"Use this template",prompt:$P(e,N,s),playgroundHref:ll(N)})]})]},N.id)})})]}),t.jsxs("p",{className:"mt-10 text-center text-lead text-muted-foreground",children:["Or ",t.jsx("a",{className:"text-primary-text underline underline-offset-4 hover:text-primary-text/80",href:J0(bm("")),children:"start from a blank agent"}),"."]})]})}const i$=p.createContext(new Map),LU={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"};function l$({run:e}){const n=p.useContext(i$);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),o=r?`${LU[r.kind]??"Trigger"}: ${r.name}`:`Trigger: ${s}`;return t.jsx("a",{href:`#/triggers/${encodeURIComponent(s)}`,onClick:i=>i.stopPropagation(),className:"inline-flex max-w-full",title:o,children:t.jsxs(Ne,{className:"max-w-full",children:[t.jsx(vd,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:o})]})})}const ym=["queued","working","paused","input_required","completed","failed","cancelled"],PU={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function IU({runs:e,agentName:n,onOpen:s,error:r,onRetry:o,onMore:i,loadingMore:c,filter:d={},onFilter:u,agentId:f,observations:g}){var v,h;const y=!!d.archived;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:te(vr,"flex-wrap gap-2 px-5 md:px-6"),children:[t.jsxs("h1",{className:te(Jo,"mr-auto"),children:[t.jsx(bd,{className:"size-4","aria-hidden":!0}),y?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Mt,{label:"Runs in one state",value:d.status??"",onChange:x=>u({...d,status:x||void 0}),className:"h-control-sm w-48",options:[{value:"",label:"Any state"},...ym.map(x=>({value:x,label:PU[x]}))]}),t.jsxs(B,{size:"sm",variant:y?"primary":"outline","aria-pressed":y,onClick:()=>u({...d,archived:!y}),children:[t.jsx(xd,{"aria-hidden":!0})," Archived"]})]}),t.jsx(an,{label:"Query",prompt:`${eh(location.origin,f)}
655
+ Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${y?"archived runs":"non-archived runs"}.`,playgroundHref:Fv(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(en,{problem:r,onRetry:o,className:""}):e?!e.length&&!((v=g==null?void 0:g.data)!=null&&v.sessions.length)&&!d.status&&!y?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(zU,{})}):!e.length&&((h=g==null?void 0:g.data)!=null&&h.sessions.length)?null:e.length?t.jsx(DU,{runs:e,agentName:n,onOpen:s}):t.jsx("p",{className:"px-4 py-16 text-center text-body text-muted-foreground",children:d.status?"No run matches.":y?"No archived runs.":"No runs yet."}):t.jsx(Qn,{label:"Loading the runs"}),g&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Dv,{read:g})}),e&&r&&t.jsx(en,{problem:r,className:"mt-4"}),e&&i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{type:"button",size:"sm",onClick:i,disabled:c,children:c?"Loading":"Load more"})})]})]})}function zU(){return t.jsxs("section",{"aria-labelledby":"first-run",className:"border border-primary/50 bg-primary/5 p-5",children:[t.jsx("p",{className:"caps text-label text-primary-text",children:"No runs yet"}),t.jsx("h2",{id:"first-run",className:"mt-2 text-xl font-semibold",children:"Start your first run"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A run is one piece of work an agent does: a question answered, a page researched, a file written. Each one is listed here with its state, when it started and what it cost."}),t.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[t.jsxs("a",{href:"#/playground",className:hl({variant:"solid",size:"lg"}),children:[t.jsx(ra,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:hl({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function DU({runs:e,agentName:n,onOpen:s}){return t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{className:"sticky top-0 z-sticky hidden bg-background md:table-header-group",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Status","Run","Agent","Kind","Started","Cost"].map(r=>t.jsx("th",{className:"border-b border-r px-4 py-3 text-left font-normal last:border-r-0",children:r},r))})}),t.jsx("tbody",{children:e.map(r=>t.jsxs("tr",{className:"cursor-pointer border-b hover:bg-accent",onClick:()=>s(r.run_id),children:[t.jsx("td",{className:"px-3 py-2.5 align-top",children:t.jsx(Ll,{run:r})}),t.jsxs("td",{className:"px-3 py-2.5 align-top",children:[t.jsxs("button",{type:"button",className:"flex items-start gap-1 text-left",onClick:o=>{o.stopPropagation(),s(r.run_id)},children:[t.jsx("span",{className:"line-clamp-2",children:On(r)}),t.jsx(pr,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),r.status==="completed"&&r.review&&t.jsx("span",{className:"mt-1 block text-small text-warning-text",children:r.review.reason}),r.trigger&&t.jsx("span",{className:"mt-1 flex",children:t.jsx(l$,{run:r})}),t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[n(r.agent_id)," · ",vt(r.created_at)]})]}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top md:table-cell",children:n(r.agent_id)}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:r.kind}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:vt(r.created_at)}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:Go(r.cost,{ended:lo(r.status)})})]},r.run_id))})]})}function FU({agentId:e,details:n}){const{denied:s,asks:r}=XD(n),o=[...new Set([...s,...r])];return o.length?t.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[o.map(i=>t.jsxs("a",{href:`#/agents/${encodeURIComponent(e)}/edit?tool=${encodeURIComponent(i)}`,className:"underline underline-offset-4",children:["Set ",i," for this agent"]},i)),t.jsxs("span",{children:["or for every agent: ",t.jsx("a",{href:"#/settings/tools",className:"underline underline-offset-4",children:"Settings → Tools"})]})]}):null}function UU(e,{base:n="/v2",onProgress:s,signal:r,request:o=()=>new XMLHttpRequest}={}){return new Promise((i,c)=>{if(r!=null&&r.aborted)return c(new Ue(0,"aborted","The upload was stopped."));const d=o();d.open("POST",`${n}/files?path=${encodeURIComponent(e.name)}`),d.setRequestHeader("accept","application/json"),e.type&&d.setRequestHeader("content-type",e.type),d.upload.onprogress=u=>{u.lengthComputable&&u.total>0&&(s==null||s(Math.min(1,u.loaded/u.total)))},d.onload=()=>{let u=null;try{u=JSON.parse(d.responseText)}catch{}if(d.status===201||d.status===200){const y=u==null?void 0:u.file;return y!=null&&y.file_id?(s==null||s(1),i(y)):c(new Ue(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,g=new Ue(d.status,(f==null?void 0:f.code)??"http_error",(f==null?void 0:f.message)??`The server answered ${d.status}.`,(f==null?void 0:f.retryable)??!1,f==null?void 0:f.request_id);f!=null&&f.fields&&(g.fields=f.fields),c(g)},d.onerror=()=>c(new Ue(0,"network","The upload did not reach the server.")),d.onabort=()=>c(new Ue(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const WU=(e,n,s)=>UU(e,{onProgress:n,signal:s});function Ig(e){if(!(e instanceof Ue))return e instanceof Error?e.message:String(e);const n=(e.fields??[]).filter(s=>s.message!==e.message).map(s=>s.message);return[e.message,...n].join(" ")}function HU({upload:e,remove:n,limits:s,frozen:r=!1}){const[o,i]=p.useState([]),[c,d]=p.useState([]),u=p.useRef(new Map),f=p.useRef(0),g=p.useRef(0);g.current=o.length;const y=p.useRef({items:o,frozen:r,remove:n});y.current={items:o,frozen:r,remove:n};const v=p.useRef(!0);p.useEffect(()=>{v.current=!0;const k=u.current;return()=>{var $;v.current=!1;for(const _ of k.values())_.abort();const{items:E,frozen:N,remove:S}=y.current;if(!N)for(const _ of E)_.file&&!_.removing&&(($=S==null?void 0:S(_.file.file_id))==null||$.catch(()=>{}))}},[]);const h=p.useCallback(k=>{if(y.current.frozen)return;const E=[],N=s?s.max_files_per_run-g.current:1/0,S=(s==null?void 0:s.max_upload_bytes)??null,$=[];for(const O of k)S!==null&&O.size>S?E.push({text:`${O.name} is ${gr(O.size)}: this server takes files up to ${gr(S)}.`}):$.length>=N?E.push({text:`${O.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):$.push(O);d(E);const _=$.map(O=>({key:`f${f.current++}`,name:O.name,size:O.size,progress:0}));g.current+=_.length,i(O=>[...O,..._]),_.forEach((O,M)=>{const P=new AbortController;u.current.set(O.key,P);const A=R=>{v.current&&i(L=>L.map(W=>W.key===O.key?{...W,...R}:W))};e($[M],R=>A({progress:R}),P.signal).then(R=>{var L,W,U;if(u.current.delete(O.key),P.signal.aborted){(U=(W=(L=y.current).remove)==null?void 0:W.call(L,R.file_id))==null||U.catch(Y=>{v.current&&d(D=>[...D,{text:`${O.name} was sent before it was stopped, and was not removed: ${Ig(Y)}`}])});return}A({file:R,progress:1})},R=>{u.current.delete(O.key),!(P.signal.aborted||!v.current)&&(i(L=>L.filter(W=>W.key!==O.key)),d(L=>[...L,{text:`${O.name}: ${Ig(R)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),x=p.useCallback(k=>{var _;const{items:E,frozen:N,remove:S}=y.current,$=E.find(O=>O.key===k);if(!(N||!$||$.removing)){if(!$.file||!S){(_=u.current.get(k))==null||_.abort(),u.current.delete(k),i(O=>O.filter(M=>M.key!==k));return}i(O=>O.map(M=>M.key===k?{...M,removing:!0}:M)),d(O=>O.filter(M=>M.about!==k)),S($.file.file_id).then(()=>{v.current&&i(O=>O.filter(M=>M.key!==k))},O=>{v.current&&(i(M=>M.map(P=>P.key===k?{...P,removing:!1}:P)),d(M=>[...M,{about:k,text:`${$.name} was not removed: ${Ig(O)}`}]))})}},[]),b=p.useCallback(()=>{y.current={...y.current,items:[]},i([]),d([])},[]),j=o.flatMap(k=>k.file&&!k.removing?[k.file.file_id]:[]);return{items:o,refusals:c.map(k=>k.text),add:h,drop:x,clear:b,fileIds:j,frozen:r,busy:o.some(k=>!k.file||k.removing)}}function X0({attachments:e,limits:n,disabled:s,compact:r=!1}){const o=p.useRef(null),[i,c]=p.useState(!1),{items:d,refusals:u,add:f,drop:g}=e,y=s||e.frozen,v=n?[`up to ${n.max_files_per_run} files`,...n.max_upload_bytes!==null?[`${gr(n.max_upload_bytes)} each`]:[]].join(", "):"";return t.jsxs("div",{className:te("border border-dashed px-3 py-2.5",i?"border-primary bg-primary/5":"border-border",r&&"max-sm:border-0 max-sm:p-0"),onDragOver:h=>{y||(h.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:h=>{h.preventDefault(),c(!1),y||f([...h.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>{var h;return(h=o.current)==null?void 0:h.click()},disabled:y,title:r?`Attach files${v?` (${v})`:""}`:void 0,className:te(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(iR,{"aria-hidden":!0})," ",t.jsx("span",{className:te(r&&"max-sm:sr-only"),children:"Attach files"})]}),t.jsxs("span",{className:te("text-small text-muted-foreground",r&&"max-sm:hidden"),children:["or drop them here",v?` (${v})`:"",". The run finds them in inputs/."]}),t.jsx("input",{ref:o,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:h=>{f([...h.target.files??[]]),h.target.value=""}})]}),d.length>0&&t.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:d.map(h=>t.jsxs("li",{className:"flex h-7 items-center gap-2 border bg-card px-2 font-mono text-small",children:[t.jsx("span",{className:"max-w-[16rem] truncate",title:h.name,children:h.name}),t.jsx("span",{className:"text-muted-foreground",children:gr(h.size)}),!h.file&&t.jsxs("span",{className:"text-muted-foreground","aria-label":`${h.name} sent ${Math.round(h.progress*100)}%`,children:[Math.round(h.progress*100),"%"]}),h.removing&&t.jsx("span",{className:"text-muted-foreground",children:"removing"}),t.jsx("button",{type:"button",onClick:()=>g(h.key),disabled:y||h.removing,"aria-label":`Remove ${h.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:t.jsx(uo,{className:"size-3.5","aria-hidden":!0})})]},h.key))}),d.some(h=>!h.file)&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),u.length>0&&t.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:u.map((h,x)=>t.jsx("li",{children:h},`${x}:${h}`))})]})}const Rf={"input.content":"Required. The run's first message.",file_ids:"Empty names none.",revision:"Empty runs the current revision.",effort:"How hard the model thinks. Empty uses the agent's own.",max_cost_usd:"A spend cap in dollars; empty means none.",repo:"The GitHub repository the run reaches, owner/name. It must be one the agent is bound to; empty takes the agent’s one repository."},Gb=(e,n)=>e instanceof Ue?{status:e.status,ms:n,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:n,body:{error:{code:"network",message:String(e)}}};function BU({agents:e,revisions:n=[],efforts:s,origin:r,agentId:o,onAgent:i,onSend:c,onOpenRun:d,result:u=null,live:f,limits:g,upload:y=WU,removeUpload:v}){var lt,$t,nt;const[h,x]=p.useState(o??((lt=e[0])==null?void 0:lt.agent_id)??"");p.useEffect(()=>{var fe;o&&o!==h&&e.some(st=>st.agent_id===o)?x(o):e.some(st=>st.agent_id===h)||x(((fe=e[0])==null?void 0:fe.agent_id)??"")},[e,o]);const b=e.find(fe=>fe.agent_id===h),j=eb(b),k=os(b==null?void 0:b.definition),E=(b==null?void 0:b.kind)??"agentic",[N,S]=p.useState(""),[$,_]=p.useState(""),O=$?($t=n.find(fe=>fe.revision===$))==null?void 0:$t.definition:void 0,M=E==="agentic"?JSON.stringify(((nt=O??(b==null?void 0:b.definition))==null?void 0:nt.input_schema)??null):"null",P=p.useMemo(()=>E==="agentic"?X8(JSON.parse(M)):null,[E,M]),A=(P==null?void 0:P.kind)==="fields"?P.form:null,R=E==="workflow"||(P==null?void 0:P.kind)==="json",[L,W]=p.useState({});p.useEffect(()=>{W(A?FE(A):{})},[h,M]);const U=E==="workflow"?M8(b==null?void 0:b.definition.workflow):(P==null?void 0:P.kind)==="json"?P.example:null,Y=p.useRef("");p.useEffect(()=>{if(N.trim()&&N!==Y.current)return;const fe=(U==null?void 0:U.text)??"";Y.current=fe,S(fe)},[h,U==null?void 0:U.text]);const[D,G]=p.useState(""),[F,q]=p.useState(""),[H,I]=p.useState(""),[V,J]=p.useState("form"),[X,re]=p.useState(u?"response":"code"),[ae,ye]=p.useState("curl"),[he,we]=p.useState(()=>!(typeof window<"u"&&typeof window.matchMedia=="function")||window.matchMedia("(min-width: 1024px) and (min-height: 501px)").matches),ze=p.useId(),[le,me]=p.useState(u),Ke=new Set((A==null?void 0:A.fields.map(([fe])=>fe))??[]),be=fe=>{const st=Px(fe);return st!==null&&Ke.has(st)?st:null},ge=p.useMemo(()=>{var ct,gt;const fe=le&&le.status>=400?(ct=le.body)==null?void 0:ct.error:void 0;if(!fe||typeof fe.message!="string")return;const st=Array.isArray(fe.fields)?fe.fields.filter(Et=>!!Et&&typeof Et.field=="string"&&typeof Et.message=="string"):[],Qe=st.filter(Et=>Et.message!==fe.message&&be(Et.field)===null);return{message:fe.message,more:Qe,issues:st,box:typeof((gt=fe.details)==null?void 0:gt.box)=="string"?fe.details.box:void 0,details:fe.code==="agent_not_runnable"?fe.details:void 0}},[le,M]),[Je,tt]=p.useState(new Set);p.useEffect(()=>{tt(new Set)},[le]);const ft=(fe,st,Qe)=>{W(ct=>({...ct,[fe]:Qe})),tt(ct=>{const gt=new Set(ct);return DE(st,Qe)?gt.add(fe):gt.delete(fe),gt})},ve=fe=>Je.has(fe)?[]:((ge==null?void 0:ge.issues)??[]).filter(st=>be(st.field)===fe),[Ee,Q]=p.useState(!1),Me=p.useMemo(()=>br(),[]),pe=HU({upload:y,remove:v,limits:g,frozen:Ee}),ne=R8(E,{text:N,revision:$,effort:D,maxCostUsd:F,fileIds:pe.fileIds,repo:H,...A?{typed:{fields:xh(A,L),contentRequired:A.contentRequired}}:{},...(P==null?void 0:P.kind)==="json"?{json:!0}:{}}),Ae=ne.ok?ne.body:{input:R?N:A?tU(A,N,L):{content:N},...pe.fileIds.length?{file_ids:pe.fileIds}:{}},Pe=h?Me.keyFor(h,Ae):"",bt=ae==="curl"?L8(r,h,Ae,Pe):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${h||"{agent_id}"}/runs`)}, {
656
+ method: "POST",
657
+ headers: {
658
+ Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
659
+ "Content-Type": "application/json",
660
+ "Idempotency-Key": ${JSON.stringify(Pe)},
661
+ },
662
+ body: JSON.stringify(${JSON.stringify(Ae,null,2).replace(/\n/g,`
663
+ `)}),
664
+ });
665
+ console.log(res.status, await res.json());`,ot=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!F.trim()||!!D||!!H.trim()||pe.fileIds.length>0||pe.busy),mt=async()=>{if(k||ot||!ne.ok||!c||pe.busy)return;Q(!0);const fe=await I8(Me,h,ne.body,c);Q(!1),me(fe),re("response"),we(!0),fe.status>=200&&fe.status<300&&pe.clear()},Re=R?E==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${A?"message":"first message"}, e.g. Summarize the standup: we ship Friday.`;return e.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-hidden",children:[t.jsxs("div",{"aria-label":"Playground agent",className:"flex shrink-0 flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[t.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),t.jsx(Mt,{id:"playground-agent",label:"Agent",value:h,onChange:fe=>{x(fe),_(""),i==null||i(fe)},options:Ol(e).map(fe=>({value:fe.agent_id,label:fe.definition.name})),className:"w-56 max-w-[60vw]"})]}),k?t.jsxs("span",{className:"font-mono text-small",children:[sa(k.runtime)," · Your backend"]}):t.jsxs("span",{className:"font-mono text-small",children:[t.jsx("span",{className:"text-primary-text",children:"POST"})," ",t.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",h||"{agent_id}","/runs"]})]})]}),k?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Run through your backend"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"This agent keeps its existing SDK, tools and job entrypoint. Your coding agent can run it there; AgentRun records its progress and learning."}),t.jsx(an,{variant:"primary",label:"Run agent",prompt:Kv(r,h,k.runtime)})]}):t.jsxs("div",{className:te("relative grid min-h-0 flex-1 grid-cols-1",he?"lg:[@media(min-height:501px)]:grid-cols-2":"grid-rows-[minmax(0,1fr)_auto]"),children:[t.jsxs("section",{"aria-label":"Request",className:te("flex min-h-0 flex-col border-b",he?"lg:border-b-0 lg:border-r short:hidden":"lg:[@media(min-height:501px)]:border-b-0 short:border-b-0"),children:[t.jsxs("header",{className:te("flex items-center justify-between border-b px-5 py-3 md:px-6",!he&&"lg:[@media(min-height:501px)]:min-h-[57px] lg:[@media(min-height:501px)]:pr-80 short:min-h-[57px] short:pr-72"),children:[t.jsx("span",{className:"text-lead font-semibold",children:"Request"}),t.jsx("span",{role:"group","aria-label":"Request as",className:"flex gap-4 text-small",children:["form","json"].map(fe=>t.jsx("button",{type:"button","aria-pressed":V===fe,onClick:()=>J(fe),className:te("min-h-6 border-b pb-1 capitalize",V===fe?"border-primary":"border-transparent text-muted-foreground"),children:fe==="json"?"JSON":"Form"},fe))})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[j&&t.jsxs("div",{className:"space-y-2 border p-4 text-small",role:"status",children:[t.jsxs("p",{children:["Native execution on ",j.machine_id,": ",j.project,". It reuses your native model, profile and sign-in. Native spend caps are unavailable. Use files already in the source project; uploaded attachments and effort overrides are unsupported."]}),ot&&t.jsx("p",{className:"text-warning-text",children:H.trim()?"This request selects a repository. Native execution uses its source project.":F.trim()?"This request has a spend cap. Native execution cannot enforce it.":D||pe.fileIds.length?"This request has managed effort or attachments. Native execution uses its source configuration and project files.":"Verify a connected native launch before sending a run."}),!!H.trim()&&t.jsx(B,{size:"sm",onClick:()=>I(""),children:"Use native source repository"}),!!D&&t.jsx(B,{size:"sm",onClick:()=>G(""),children:"Use native configured effort"}),pe.fileIds.length>0&&t.jsx(B,{size:"sm",onClick:()=>pe.clear(),children:"Remove uploaded attachments"}),!!F.trim()&&t.jsx(B,{size:"sm",onClick:()=>q(""),children:"Remove cap for native execution"}),t.jsx("a",{href:Cn(h),className:"underline underline-offset-2",children:"Open native connection"})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[b?`${b.definition.name}: ${E==="agentic"?"an":"a"} ${E} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),V==="json"?t.jsxs(t.Fragment,{children:[t.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.7]",children:JSON.stringify(Ae,null,2)}),!j&&t.jsx(La,{name:"file_ids",note:Rf.file_ids,children:t.jsx(X0,{attachments:pe,limits:g})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(La,{htmlFor:"playground-input",name:R?"input":"input.content",required:!A||A.contentRequired,optional:!!A&&!A.contentRequired,error:!ne.ok&&ne.field==="input"&&N?ne.message:void 0,children:[t.jsx(on,{id:"playground-input",value:N,onChange:fe=>S(fe.target.value),rows:R?7:4,placeholder:Re,className:Z0}),U&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[O8(U,"start",E==="workflow"?"workflow":"agent"),U.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",U.fields.map((fe,st)=>t.jsxs("span",{title:fe.note,children:[st?", ":"",t.jsx("span",{className:"text-foreground",children:fe.name})]},fe.name)),"."]})]})]}),A==null?void 0:A.fields.map(([fe,st])=>t.jsxs("div",{"data-field":`input.${fe}`,children:[t.jsx(HE,{field:st,label:gh(fe,st),help:vm(st),value:L[fe]??"",onChange:Qe=>ft(fe,st,Qe)}),t.jsx(Do,{issues:ve(fe),words:Qe=>WE(Qe,fe,st)})]},fe)),!j&&t.jsx(La,{name:"file_ids",note:Rf.file_ids,children:t.jsx(X0,{attachments:pe,limits:g})}),t.jsx(La,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(Mt,{label:"Revision",value:$,onChange:_,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(fe=>({value:fe.revision,label:`rev ${fe.version}${fe.current?" (current)":""}${fe.note?`: ${fe.note}`:""}`}))]})}),!j&&t.jsx(La,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(Mt,{label:"Effort",value:D,onChange:G,className:"w-full",options:["",...s].map(fe=>({value:fe,label:fe||"Agent default"}))})}),E==="agentic"&&!j&&t.jsx(La,{htmlFor:"playground-repo",name:"repo",note:Rf.repo,error:!ne.ok&&ne.field==="repo"?ne.message:void 0,children:t.jsx(De,{id:"playground-repo",value:H,onChange:fe=>I(fe.target.value),placeholder:"owner/name"})}),E==="agentic"&&!j&&t.jsxs(La,{htmlFor:"playground-cap",name:"max_cost_usd",note:"A spend cap in dollars; empty means none.",error:!ne.ok&&ne.field==="max_cost_usd"?ne.message:void 0,children:[t.jsx(De,{id:"playground-cap",value:F,onChange:fe=>q(fe.target.value),inputMode:"decimal",placeholder:"e.g. 0.50",className:Z0}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(sE,{})})]})]})]}),t.jsxs("footer",{className:"flex shrink-0 flex-wrap items-center justify-between gap-3 border-t px-5 py-3 md:px-6",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Sends a real request to this server."}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(an,{size:"lg",label:"Use your agent",prompt:_P(r,h,Ae),disabled:ot||!ne.ok||!h||pe.busy}),t.jsxs(B,{variant:"primary",size:"lg",onClick:mt,disabled:ot||!ne.ok||!c||Ee||!h||pe.busy,title:pe.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(ra,{"aria-hidden":!0})," ",Ee?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:te("flex min-h-0 flex-col",!he&&"lg:[@media(min-height:501px)]:absolute lg:[@media(min-height:501px)]:right-6 lg:[@media(min-height:501px)]:top-3 short:absolute short:right-5 short:top-3"),children:[t.jsxs("header",{className:te("flex flex-wrap items-center justify-between gap-x-3 gap-y-2 px-5 md:px-6",he?"border-b py-3":"py-2 lg:[@media(min-height:501px)]:p-0 short:p-0"),children:[t.jsxs("span",{role:"group","aria-label":"Show",className:te("flex gap-4 text-body",!he&&"hidden"),children:[t.jsx("button",{type:"button","aria-pressed":X==="code",onClick:()=>re("code"),className:te("border-b pb-1",X==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button","aria-pressed":X==="response",onClick:()=>re("response"),disabled:!le,className:te("border-b pb-1 disabled:opacity-45",X==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",le&&t.jsx("span",{className:te("ml-2 font-mono max-sm:hidden",le.status<300?"text-success-text":"text-destructive-text"),children:le.status})]})]}),t.jsx("span",{className:"ml-auto flex items-center gap-2",children:t.jsxs(B,{type:"button",size:"sm",className:"max-sm:px-2","aria-expanded":he,"aria-controls":ze,onClick:()=>we(fe=>!fe),children:[he?t.jsx(VT,{"aria-hidden":!0}):t.jsx($m,{"aria-hidden":!0})," ",he?"Hide code and response":"Show code and response"]})})]}),t.jsx("div",{id:ze,className:te("flex min-h-0 flex-1 flex-col",!he&&"hidden"),children:X==="code"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b px-5 md:px-6",children:[t.jsx("div",{role:"group","aria-label":"Code in",className:"flex gap-5 text-small",children:["curl","fetch"].map(fe=>t.jsx("button",{type:"button","aria-pressed":ae===fe,onClick:()=>ye(fe),className:te("-mb-px border-b-2 py-2.5",ae===fe?"border-primary":"border-transparent text-muted-foreground"),children:fe==="curl"?"cURL":"JavaScript"},fe))}),t.jsx(B,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var fe;return void((fe=navigator.clipboard)==null?void 0:fe.writeText(bt))},children:t.jsx(oi,{"aria-hidden":!0})})]}),t.jsx("pre",{tabIndex:0,"aria-label":"The request as code",className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:bt}),t.jsx("footer",{className:"border-t px-5 py-3 text-small text-muted-foreground md:px-6",children:"The same request from your code: set AGENTRUN_API_KEY in your environment."})]}):le&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small md:px-6",children:[t.jsx("span",{className:le.status<300?"text-success-text":"text-destructive-text",children:le.status})," ",t.jsxs("span",{className:"text-muted-foreground",children:[le.ms," ms"]})]}),ge&&t.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small text-destructive-text md:px-6",role:"alert",children:["The run did not start: ",ge.message,ge.box?t.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",ge.box,")"]}):null,t.jsx(FU,{agentId:h,details:ge.details}),ge.more.length>0&&t.jsx("span",{className:"mt-1 block",children:ge.more.map(fe=>t.jsxs("span",{className:"block",children:[fe.field,": ",fe.message]},`${fe.field}:${fe.message}`))})]}),le.runId&&f?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden border-b short:overflow-auto",children:f(le.runId)}),t.jsxs("details",{className:"border-b px-5 py-2.5 md:px-6",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Response body"}),t.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words py-3 font-mono text-small leading-[1.8]",children:JSON.stringify(le.body,null,2)})]})]}):t.jsx("pre",{tabIndex:0,"aria-label":"Response body",className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:JSON.stringify(le.body,null,2)}),le.runId&&t.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(le.runId),className:"caps flex items-center justify-between border-t px-5 py-4 text-small text-primary-text hover:bg-accent md:px-6",children:["Open this run ",t.jsx(Zx,{className:"size-4","aria-hidden":!0})]})]})})]})]})]}):t.jsxs("section",{"aria-label":"Request",className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Start a run"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Connect an existing native agent or create an agent before starting a run."}),t.jsx("a",{href:"#/agents/connect",className:"block text-body underline underline-offset-2",children:"Connect agent"}),t.jsx("a",{href:"#/agents/new",className:"block text-body underline underline-offset-2",children:"Create an agent"}),t.jsx("a",{href:"#/templates",className:"block text-body underline underline-offset-2",children:"Browse templates"}),t.jsx("dl",{className:"space-y-2",children:Object.entries(Rf).map(([fe,st])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:fe}),t.jsx("dd",{className:"text-small text-muted-foreground",children:st})]},fe))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const Z0="w-full border bg-card px-3 py-2.5 font-mono text-body outline-none placeholder:text-muted-foreground focus:border-border-strong";function La({name:e,htmlFor:n,required:s,optional:r,note:o,error:i,children:c}){const d=p.useId();return t.jsxs("div",{role:n?void 0:"group","aria-labelledby":n?void 0:d,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[n?t.jsx("label",{htmlFor:n,className:"font-mono text-body",children:e}):t.jsx("span",{id:d,className:"font-mono text-body",children:e}),s?t.jsx("span",{className:"text-label text-muted-foreground",children:"required"}):r&&t.jsx("span",{className:"text-label text-muted-foreground",children:"optional"})]}),c,o&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:o}),i&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:i})]})}const eN="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",qU=e=>`'${e.replaceAll("'","'\\''")}'`;function GU({v2:e,origin:n,agentId:s,filter:r={}}){const[o,i]=p.useState(r.status??""),[c,d]=p.useState(!!r.archived),[u,f]=p.useState(50),[g,y]=p.useState(""),[v,h]=p.useState("code"),[x,b]=p.useState("curl"),[j,k]=p.useState(null),[E,N]=p.useState(null),[S,$]=p.useState(!1),[_,O]=p.useState(!1),M=p.useRef(0);p.useEffect(()=>(M.current++,i(r.status??""),d(!!r.archived),y(""),N(null),k(null),$(!1),()=>{M.current++}),[s,r.status,r.archived]);const P={...o?{status:o}:{},...c?{archived:!0}:{}},A=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",R=new URLSearchParams({limit:String(u)});g&&R.set("cursor",g),o&&R.set("status",o),c&&R.set("archived","true");const L=`${n}${A}?${R}`,W=x==="curl"?`curl -X GET ${qU(L)} \\
666
+ -H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(L)}, {
667
+ method: "GET",
668
+ headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
669
+ });
670
+ console.log(response.status, await response.json());`,U=`${eh(n,s)}
671
+
672
+ Prepared read-only request: GET ${L}
673
+ Use exactly this agent scope, status, archive selection, page size and cursor. Do not broaden the query or issue writes. Show the results and links to relevant runs. Follow next_cursor only when more results are needed, keeping the same filters.`,Y=()=>{M.current++,y(""),N(null),k(null),O(!1)},D=async(G=g)=>{if(S)return;const F=++M.current;$(!0),N(null),k(null),y(G),O(!1);const q=performance.now();try{const H=s?await e.listAgentRuns(s,u,G||void 0,P):await e.listRuns(u,G||void 0,P);if(M.current!==F)return;N(H),k({status:200,ms:performance.now()-q,body:H})}catch(H){if(M.current!==F)return;k(Gb(H,performance.now()-q))}finally{M.current===F&&($(!1),h("response"))}};return t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsx("header",{className:"flex h-12 shrink-0 items-center border-b px-6",children:t.jsx("span",{className:"text-lead font-semibold",children:"Request"})}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"List runs"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Inspect server-run sessions and imported history. This request only reads data."})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Agent"}),t.jsx(De,{className:eN,value:s??"All agents",readOnly:!0})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Status"}),t.jsx(Mt,{label:"Run status",value:o,disabled:S,onChange:G=>{i(G),Y()},options:[{value:"",label:"All statuses"},...ym.map(G=>({value:G,label:G.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(Mt,{label:"Archived runs",value:String(c),disabled:S,onChange:G=>{d(G==="true"),Y()},options:[{value:"false",label:"Current runs"},{value:"true",label:"Archived runs"}]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Page size"}),t.jsx(Mt,{label:"Page size",value:String(u),disabled:S,onChange:G=>{f(Number(G)),Y()},options:[10,25,50,100].map(G=>({value:String(G),label:String(G)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(De,{"aria-label":"Cursor",className:`${eN} font-mono text-small`,value:g,disabled:S,placeholder:"First page",onChange:G=>{M.current++,y(G.target.value),N(null),k(null)}})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(an,{size:"md",label:"Use your agent",prompt:U}),t.jsxs(B,{variant:"primary",disabled:S,onClick:()=>void D(),children:[t.jsx(ra,{"aria-hidden":!0}),S?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(G=>t.jsx("button",{onClick:()=>h(G),className:te("h-12 border-b text-small capitalize",v===G?"border-primary":"border-transparent text-muted-foreground"),children:G},G)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var G;(G=navigator.clipboard)==null||G.writeText(W).then(()=>O(!0),()=>O(!1))},children:t.jsx(oi,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:_?"Code copied":""})]}),v==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(G=>t.jsx("button",{onClick:()=>b(G),className:te("border-b text-small",x===G?"border-primary":"border-transparent text-muted-foreground"),children:G==="curl"?"cURL":"JavaScript"},G))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:W})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:j?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[j.status||"Network error"," · ",Math.round(j.ms)," ms"]}),E&&t.jsxs(t.Fragment,{children:[E.runs.length?t.jsx("ul",{className:"divide-y border",children:E.runs.map(G=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(G.run_id)}`,children:[t.jsx(Ll,{run:G}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:G.title||G.run_id}),t.jsx(pr,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},G.run_id))}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"No runs match this request."}),E.next_cursor&&t.jsx(B,{size:"sm",disabled:S,onClick:()=>void D(E.next_cursor),children:"Next page"})]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(j.body,null,2)})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:S?"Loading runs…":"Send a request to see its response."})})]})]})}const _c=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Tc="w-full border bg-card px-3 py-3 text-lead outline-none focus:border-primary";function KU({v2:e,origin:n,operation:s,agentId:r,draft:o,harnesses:i=[],routePrefix:c}){const d=s==="edit-agent",u=tE(),f=p.useId(),[g,y]=p.useState(null),v=AU(o??null),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(void 0),[N,S]=p.useState(v??bm("")),[$,_]=p.useState(JSON.stringify(v??bm(""),null,2)),[O,M]=p.useState($),P=rE($!==O),[A,R]=p.useState("form"),[L,W]=p.useState("code"),[U,Y]=p.useState("curl"),[D,G]=p.useState(null),[F,q]=p.useState(null),[H,I]=p.useState(null),[V,J]=p.useState(!1),[X,re]=p.useState(!1),[ae,ye]=p.useState(0),[he,we]=p.useState(!1);p.useEffect(()=>{if(!d)return;if(!r){G("Choose an agent from Connected agents to edit its definition.");return}let Re=!0;return x(null),E(void 0),G(null),e.getAgent(r).then(({agent:lt,etag:$t})=>{if(!Re)return;x(lt),j($t);const nt={definition:{...lt.definition,version:lt.revisions+1}},fe=JSON.stringify(nt,null,2);S(nt),_(fe),M(fe),q(null),re(!1)}).catch(lt=>{Re&&G(String(lt instanceof Error?lt.message:lt))}),()=>{Re=!1}},[e,d,r,ae]);const ze=(Re,lt)=>{const $t={...N.definition,[Re]:Re==="model"?lt.trim():lt};Re==="model"&&!lt.trim()&&!d&&delete $t.model;const nt={...N,definition:$t};S(nt),_(JSON.stringify(nt,null,2))};let le=N,me=null;if(A==="json")try{const Re=JSON.parse($);!_c(Re)||!_c(Re.definition)?me="Include a definition object in the request.":le=Re}catch{me="Enter valid JSON before sending the request."}!me&&le.note!==void 0&&typeof le.note!="string"&&(me="note must be a string.");for(const Re of["description","instructions","harness","model"])!me&&le.definition[Re]!==void 0&&typeof le.definition[Re]!="string"&&(me=`definition.${Re} must be a string.`);!me&&typeof le.definition.name!="string"&&(me="Give this agent a name.");const Ke=!me;!me&&!le.definition.name.trim()&&(me="Give this agent a name."),!me&&!le.definition.workflow&&(typeof le.definition.instructions!="string"||!le.definition.instructions.trim())&&(me="Add instructions for this agent.");const be=le;if(!me&&d&&h){const Re=_c(le.definition.workflow),lt=Object.keys(h.definition).filter(nt=>!Object.hasOwn(le.definition,nt));for(const nt of["id","name","description"])!me&&le.definition[nt]!==h.definition[nt]&&(me=`definition.${nt} is fixed when the agent is created. Restore its current value.`);for(const nt of["native","sdk"])!me&&h.definition[nt]!==void 0&&lt.includes(nt)&&(me=`Cannot remove definition.${nt} here. Edit the original source configuration with your agent.`);if(!me&&!Re)for(const nt of["input_schema","output_schema"])lt.includes(nt)&&(me=`Cannot remove definition.${nt}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!me&&lt.includes("harness")&&(me='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!me&&(h.definition.computer!==void 0||h.definition.place!==void 0)&&!Object.hasOwn(le.definition,"computer")&&!Object.hasOwn(le.definition,"place")&&(me='Cannot remove definition.computer and definition.place together: the API keeps the setting. Set computer to {"kind":"none"} or place to {"mode":"runner"} explicitly.');const $t=_c(le.skills)&&Object.keys(le.skills).length===0;if(!me&&!Object.hasOwn(le.definition,"skills")&&!$t&&(h.definition.skills.length>0||_c(le.skills)&&Object.keys(le.skills).length>0)&&(me="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!me){const nt=Object.fromEntries(lt.map(ct=>[ct,ct==="learning"?Re?void 0:!1:ct==="max_cost_usd"?0:ct==="checkout"?Re?void 0:"none":ct==="tools"||ct==="skills"?[]:void 0])),{unchanged:fe,...st}=Md(h,{...nt,...le.definition},le.note??""),Qe=le.skills!==void 0&&!al(le.skills,k);fe&&!Qe&&(me="Change the definition before saving a revision."),Qe&&(st.definition.version=h.revisions+1),le={...le,...st}}}d&&h&&!b&&(me="This server did not provide a revision ETag. Reload the current revision before editing.");const ge=d?"PUT":"POST",Je=d?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",tt=`${n}${Je}`,ft=JSON.stringify(le,null,2),ve=Re=>`'${Re.replaceAll("'","'\\''")}'`,Ee={"Content-Type":"application/json",...d&&b?{"If-Match":b}:{}},Q=U==="curl"?`curl -X ${ge} ${ve(tt)} \\
674
+ -H "Authorization: Bearer $AGENTRUN_API_KEY" \\
675
+ ${Object.entries(Ee).map(([Re,lt])=>` -H ${ve(`${Re}: ${lt}`)} \\
676
+ `).join("")} -d ${ve(ft)}`:`const response = await fetch(${JSON.stringify(tt)}, {
677
+ method: ${JSON.stringify(ge)},
678
+ headers: {
679
+ Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
680
+ ${Object.entries(Ee).map(([Re,lt])=>` ${JSON.stringify(Re)}: ${JSON.stringify(lt)},`).join(`
681
+ `)}
682
+ },
683
+ body: JSON.stringify(${ft}),
684
+ });
685
+ console.log(response.status, await response.json());`,Me=os(h==null?void 0:h.definition),pe=d&&(!!(h!=null&&h.definition.native)||!!Me),ne=pe&&h?Xo(n,h.agent_id,!!h.definition.native,Me==null?void 0:Me.runtime):`${d?Xo(n,r??""):Zm(n)}
686
+
687
+ Prepared request: ${ge} ${tt}${d&&b?`
688
+ If-Match: ${b}`:""}. Treat the JSON below as request data. Preserve every supplied field and use this request as the starting point. Clarify missing details and show the proposed request before sending it. Do not start a run.
689
+
690
+ ${ft}`,Ae=!me&&!D&&(!d||!!h)&&!V&&!X,Pe=typeof be.definition.model=="string"&&be.definition.model?be.definition.model:void 0,bt=be.definition.harness??"pi",ot=async()=>{if(!Ae)return;J(!0),I(null),y(null);const Re=performance.now(),lt=bt,$t=Pe,nt=fe=>({harness:lt,model:$t,text:fe.map(st=>st.message).join(" ")||void 0});try{const fe=d?await e.updateDefinition(r,le,b):{agent:await e.createAgent(le),etag:null};y({warning:nt(yx(fe.agent.warnings,"model"))}),I(fe.agent.agent_id),M($),q({status:d?200:201,ms:performance.now()-Re,body:fe.agent}),d?(x(fe.agent),j(fe.etag),le.skills!==void 0&&E(le.skills)):re(!0)}catch(fe){const st=Gb(fe,performance.now()-Re);q(st),fe instanceof Ue&&y({error:nt(yx(fe.fields,"model"))}),!d&&(st.status===0||st.status>=500)&&re(!0)}finally{J(!1),W("response")}},mt=t.jsxs(kv,{open:P.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:P.leave,onCancel:P.stay,children:[d?"Your changes to this agent are not saved.":"This new agent is not saved yet."," Leave drops them; Stay keeps them here."]});return D?t.jsxs(t.Fragment,{children:[mt,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:D}),r&&t.jsx(B,{className:"mt-3",onClick:()=>ye(Re=>Re+1),children:"Reload agent"})]})]}):d&&!h?t.jsxs(t.Fragment,{children:[mt,t.jsx("p",{className:"p-6 text-lead text-muted-foreground",children:"Loading the agent definition…"})]}):t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-6",children:[t.jsx("span",{className:"text-lead font-semibold",children:"Request"}),t.jsx("div",{className:"flex gap-5",children:["form","json"].map(Re=>t.jsx("button",{onClick:()=>{if(Re==="form"&&A==="json"){if(!Ke)return;S(be)}R(Re)},className:te("h-12 border-b text-small",A===Re?"border-primary":"border-transparent text-muted-foreground"),children:Re==="json"?"JSON":"Form"},Re))})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:d?"Edit agent":"Create an agent"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:d?"Save a new version of this agent’s configuration.":"Configure an agent on this server. You can run it once it is created."})]}),o&&!v&&!d&&t.jsx("p",{role:"alert",className:"text-lead text-warning-text",children:"The linked draft could not be read. Fill in the definition before sending."}),A==="json"?t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"sr-only",children:"Request JSON"}),t.jsx(on,{value:$,onChange:Re=>_(Re.target.value),className:`${Tc} min-h-[360px] font-mono text-small`,spellCheck:!1})]}):t.jsxs(t.Fragment,{children:[t.jsx(Rc,{name:"Name",children:t.jsx(De,{value:N.definition.name,readOnly:d,onChange:Re=>ze("name",Re.target.value),className:Tc})}),t.jsx(Rc,{name:"Description",children:t.jsx(De,{value:N.definition.description??"",readOnly:d,onChange:Re=>ze("description",Re.target.value),className:Tc})}),N.definition.workflow?t.jsx(Rc,{name:"Workflow",children:t.jsx("pre",{className:`${Tc} overflow-auto font-mono text-small`,children:JSON.stringify(N.definition.workflow,null,2)})}):t.jsxs(t.Fragment,{children:[t.jsx(Rc,{name:"Instructions",children:t.jsx(on,{value:N.definition.instructions??"",rows:5,onChange:Re=>ze("instructions",Re.target.value),className:Tc})}),t.jsx(Rc,{name:"Harness",children:t.jsx(Mt,{label:"Harness",value:N.definition.harness??"pi",onChange:Re=>ze("harness",Re),options:[...new Set([N.definition.harness??"pi",...i.map(Re=>Re.id)])].map(Re=>{var lt;return{value:Re,label:`${Re}${((lt=i.find($t=>$t.id===Re))==null?void 0:lt.available)===!1?" (not set up)":""}`}})})}),t.jsx(nE,{id:f,harness:bt,model:Pe,onModel:Re=>ze("model",Re??""),harnesses:i,routePrefix:c,state:u,error:g==null?void 0:g.error,warning:g==null?void 0:g.warning})]}),t.jsx("button",{className:"text-lead text-primary-text",onClick:()=>R("json"),children:"Edit all fields in JSON →"})]}),me&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:me}),d&&h&&!b&&t.jsx(B,{size:"sm",onClick:()=>ye(Re=>Re+1),children:"Reload current revision"})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(an,{size:"md",label:"Use your agent",prompt:ne,disabled:!pe&&!!me}),t.jsxs(B,{variant:"primary",onClick:()=>void ot(),disabled:!Ae,children:[t.jsx(ra,{"aria-hidden":!0}),V?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(Re=>t.jsx("button",{onClick:()=>W(Re),className:te("h-12 border-b text-small capitalize",L===Re?"border-primary":"border-transparent text-muted-foreground"),children:Re},Re)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{navigator.clipboard.writeText(Q).then(()=>we(!0),()=>we(!1))},children:t.jsx(oi,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:he?"Code copied":""})]}),L==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(Re=>t.jsx("button",{onClick:()=>Y(Re),className:te("border-b text-small",U===Re?"border-primary":"border-transparent text-muted-foreground"),children:Re==="curl"?"cURL":"JavaScript"},Re))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:Q})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:F?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[F.status||"Network error"," · ",Math.round(F.ms)," ms"]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(F.body,null,2)}),H&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:Cn(H),children:["Open agent",t.jsx(pr,{className:"size-4"})]}),F.status===412&&t.jsx(B,{onClick:()=>ye(Re=>Re+1),children:"Reload current revision"}),X&&!H&&t.jsxs("p",{role:"alert",className:"text-lead",children:["The creation request may have succeeded. Check ",t.jsx("a",{href:"#/agents",className:"text-primary-text underline",children:"Connected agents"})," before sending another creation request."]})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"Send a request to see its response."})})]}),mt]})}function Rc({name:e,children:n}){const s=p.useId();return t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:s,className:"block text-lead",children:e}),p.cloneElement(n,{id:s,"aria-label":e})]})}const VU=[{id:"keys",label:"Tool keys"},{id:"tools",label:"Tools"},{id:"mcp",label:"MCP servers"},{id:"github",label:"GitHub"},{id:"email",label:"Email"},{id:"computers",label:"Computers"},{id:"workspace",label:"Workspace"},{id:"webhook",label:"Webhook"}],ta="p-5 md:p-8",fi="mb-6 max-w-prose",mi="[&>:not(section)]:mb-6";function Dr({title:e,titleId:n,note:s,aside:r,label:o,children:i}){const c=p.useId(),d=n??c;return t.jsxs("section",{"aria-label":o,"aria-labelledby":o?void 0:d,className:"border-t py-6 xl:grid xl:grid-cols-[minmax(14rem,20rem)_minmax(0,1fr)] xl:items-start xl:gap-x-10",children:[t.jsxs("div",{className:"max-xl:mb-3",children:[t.jsx("h2",{id:d,className:"caps text-small font-semibold",children:e}),s&&t.jsx("div",{className:"mt-1.5 space-y-1.5 text-body text-muted-foreground",children:s}),r&&t.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:r})]}),t.jsx("div",{className:"min-w-0 space-y-3",children:i})]})}function YU({active:e,offered:n,children:s}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.length>1&&t.jsx("nav",{"aria-label":"Settings",className:i2,children:VU.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:l2(e===r.id),children:r.label},r.id))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}async function bh(e,n){var d;let s;try{s=((d=navigator.clipboard)==null?void 0:d.readText().catch(()=>""))??Promise.resolve("")}catch{s=Promise.resolve("")}_s.flushSync(e);const r=n();if(!r||r.disabled||r.readOnly)return;r.focus();const o=r.value;let i=!1;const c=()=>{i=!0};r.addEventListener("input",c);try{const u=await s;if(!u||!r.isConnected||i||r.value!==o||r.disabled||r.readOnly)return;Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value").set.call(r,u),r.dispatchEvent(new Event("input",{bubbles:!0}))}finally{r.removeEventListener("input",c)}}function ha({error:e,title:n="The run failed"}){return t.jsxs("section",{className:"flex gap-3 bg-card px-4 py-4 md:px-5",role:"alert",children:[t.jsx(Ys,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"caps text-small font-semibold",children:n}),t.jsx("p",{className:"mt-2 break-words font-mono text-body leading-relaxed",children:e.message}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[e.code,e.retryable?" · retryable":"",e.request_id?` · ${e.request_id}`:""]})]})]})}const QU={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",particle:"particle.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},JU={anthropic:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z",openrouter:"M16.778 1.844v1.919q-.569-.026-1.138-.032-.708-.008-1.415.037c-1.93.126-4.023.728-6.149 2.237-2.911 2.066-2.731 1.95-4.14 2.75-.396.223-1.342.574-2.185.798-.841.225-1.753.333-1.751.333v4.229s.768.108 1.61.333c.842.224 1.789.575 2.185.799 1.41.798 1.228.683 4.14 2.75 2.126 1.509 4.22 2.11 6.148 2.236.88.058 1.716.041 2.555.005v1.918l7.222-4.168-7.222-4.17v2.176c-.86.038-1.611.065-2.278.021-1.364-.09-2.417-.357-3.979-1.465-2.244-1.593-2.866-2.027-3.68-2.508.889-.518 1.449-.906 3.822-2.59 1.56-1.109 2.614-1.377 3.978-1.466.667-.044 1.418-.017 2.278.02v2.176L24 6.014Z"},XU=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function ZU({id:e,className:n}){const[s,r]=p.useState(!1),o=QU[e],i=JU[e];return o&&!s?t.jsx("img",{"data-provider-icon":e,src:XU(o),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:te("size-4 shrink-0 object-contain",n)}):i?t.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:te("size-4 shrink-0",n),"aria-hidden":!0,children:t.jsx("path",{d:i})}):t.jsx(Ka,{className:te("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const eW=/^(which|what|who|whom|whose|where|when|why|how|should|shall|do|does|did|is|are|was|were|can|could|would|will|may|might)\b/i,tW=40;function nW(e){const n=e.trim().replace(/\?+$/,""),s=n.lastIndexOf(":"),r=(s>=0?n.slice(s+1):n.split(new RegExp("(?<=[.!?])\\s+")).at(-1)??"").trim();if(s<0&&eW.test(r))return[];const o=r.split(/,?\s+or\s+|,\s+/i).map(c=>c.trim()).filter(Boolean);if(o.length<2||o.length>4||!/\bor\b/i.test(r))return[];const i=o.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return i.some(c=>!c||c.length>tW)?[]:i.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function sW(e){var r,o;const n=new Map;for(const i of e){if(i.imported_from)continue;const c=((o=(r=i.error)==null?void 0:r.message)==null?void 0:o.trim())||"The run failed.";n.set(c,[...n.get(c)??[],i])}const s=i=>Date.parse(i.ended_at??i.created_at);return[...n].map(([i,c])=>({message:i,runs:c.sort((d,u)=>s(u)-s(d))})).sort((i,c)=>s(c.runs[0])-s(i.runs[0]))}const c$=e=>e.filter(n=>!n.imported_from).length,rW=864e5;function oW(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function zl(e,n){const s=Math.max(0,Math.round((n-Date.parse(e))/1e3));return s<60?`${s} s`:s<3600?`${Math.floor(s/60)} min`:s<86400?`${Math.floor(s/3600)} h`:`${Math.floor(s/86400)} days`}function aW(e){var s,r;if(e.kind==="workflow")return{refusal:`"${e.title}" is a workflow run: start it again from its agent's page`};if(!e.input)return{refusal:`"${e.title}": its input can't be read back exactly as it was given; start it again from its agent's page`};const n=(s=e.cost)==null?void 0:s.cap_usd;return{body:{input:e.input,...(r=e.file_ids)!=null&&r.length?{file_ids:e.file_ids}:{},...e.effort?{effort:e.effort}:{},...typeof n=="number"?{max_cost_usd:n}:{}}}}function iW(e,n){let s=!1,r;const o=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(o,n))})};return o(),()=>{s=!0,clearTimeout(r)}}const d$=e=>e.pending!=null&&e.pending.kind!=="stopped",lW=e=>e.status==="input_required"&&e.state!=="waiting"&&!d$(e),cW=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function tN(e,n){const s={asking:(e==null?void 0:e.asking)??[],failed:(e==null?void 0:e.failed)??[],live:(e==null?void 0:e.live)??[]},r=[];return cW.forEach(([o,i],c)=>{const d=n[c];(d==null?void 0:d.status)==="fulfilled"?s[o]=d.value:d&&r.push(`${i} could not be read: ${d.reason instanceof Error?d.reason.message:String(d.reason)}`)}),{needs:s,problem:r.length?r.join(" · "):null}}function yh({field:e,label:n,writable:s,required:r=!0,stateSaid:o=!1,actionsInline:i=!1,now:c=Date.now,note:d,onPaste:u,onRemove:f}){const g=e.source==="env",y=s&&!g;return t.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:te("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",g&&"opacity-60"),children:[t.jsxs("span",{children:[fm(e.name,n),!r&&t.jsx("span",{className:"ml-2 font-sans text-label text-muted-foreground",children:"Optional"})]}),t.jsx("span",{"data-state":e.set?"set":r?"missing":"optional-missing",className:o?"sr-only":d?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&t.jsx("span",{className:"text-muted-foreground",children:xF[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",zl(e.changed_at,c())," ago"]}),d&&t.jsx("span",{className:"text-warning-text",children:d}),y&&t.jsxs("span",{className:te("flex gap-2 font-sans",!i&&"ml-auto"),children:[u&&t.jsx(B,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:u,children:e.set?"Replace":"Paste"}),f&&e.set&&t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:f,children:"Remove"})]})]})}const nN={anthropic:{url:"https://console.anthropic.com/settings/keys",placeholder:"sk-ant-…",note:pL},openai:{url:"https://platform.openai.com/api-keys",placeholder:"sk-…"},openrouter:{url:"https://openrouter.ai/keys",placeholder:"sk-or-…"},particle:{url:"https://platform.particle.ai/",placeholder:"pai-…"}},zx=e=>Object.prototype.hasOwnProperty.call(nN,e)?nN[e]:void 0,dW={seal_key_changed:"This server's seal key changed since these keys were saved, so they can't be opened.",file_unreadable:"The file this server keeps the saved keys in is damaged, so they can't be opened."},sN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function rN(e,n){return n?n.state==="accepted"?`${e} accepted this key · ${vt(n.at)}`:`Not checked: ${n.reason}${n.at?` · ${vt(n.at)}`:""}`:null}const uW="can't be opened: paste it again",fW=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],Dx="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function mW({v2:e,onChange:n,writable:s,whyNot:r="sign_in",plan:o,harnesses:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(null),x=p.useRef(0),b=()=>{const _=++x.current;e.listToolKeys().then(O=>{_===x.current&&(d(O),f(null))}).catch(O=>{_===x.current&&f(sN(O))})};p.useEffect(b,[e]);const j=_=>y(O=>O===_?null:O),k=_=>{j(_),b(),n==null||n()},E=(_,O,M,P)=>{h({id:_,title:O,error:sN(M)}),M instanceof Ue&&M.code==="key_set_by_server"&&(j(P),b())};if(!c)return u?t.jsx(oN,{error:u,onRetry:b}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Qn,{label:"Loading the tool keys",rows:3})});const N=c.reenter,S=fW.map(_=>({..._,keys:c.keys.filter(O=>O.kind==="model"==(_.kind==="model"))})).filter(_=>_.keys.length),$=_=>t.jsx(hW,{tool:_,writable:s,again:!!N&&_.fields.some(O=>O.stored_unreadable||N.fields.includes(O.name)),open:(g==null?void 0:g.id)===_.id?g.mode:null,problem:(v==null?void 0:v.id)===_.id?v:null,onOpen:O=>{y(O?{id:_.id,mode:O}:null),h(null)},onSave:async O=>{const M=g;try{await e.saveToolKey(_.id,O)}catch(P){return P instanceof Ue&&P.status===422?P:(E(_.id,"The key was not saved",P,M),null)}return k(M),null},onRemove:async()=>{const O=g;try{await e.removeToolKey(_.id)}catch(M){E(_.id,"The key was not removed",M,O);return}k(O)}},_.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[t.jsxs("div",{className:fi,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Keys"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A model provider's key, which every agent runs on, and a tool's key, for every agent that uses the tool, kept on this server. A saved key is never shown again."})]}),t.jsxs("div",{className:mi,children:[!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:fa[r]}),u&&t.jsx(oN,{inline:!0,error:u,onRetry:b}),N&&t.jsxs(jt,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[t.jsx("p",{children:dW[N.reason]}),t.jsx("p",{className:"mt-2 font-mono",children:N.fields.length?N.fields.join(", "):"Which keys it held is not known: enter again each key you had saved."})]}),S.map(_=>t.jsx(Dr,{label:_.label,title:_.label,note:_.kind==="model"?t.jsx("p",{children:Dx}):void 0,children:t.jsxs("ul",{className:"border",children:[_.kind==="model"&&o,_.keys.map($)]})},_.label)),i&&t.jsx(iE,{harnesses:i})]})]})})}function oN({error:e,onRetry:n,inline:s=!1}){return t.jsx(jt,{tone:"error",className:s?void 0:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:n,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool keys could not be read: ",e.code,": ",e.message]})})}function hW({tool:e,writable:n,again:s,open:r,problem:o,onOpen:i,onSave:c,onRemove:d}){var h,x;const u=p.useRef(null),f=b=>e.secrets.find(j=>fm(j.name)===b.name),g=b=>e.fields.find(j=>j.name===fm(b.name)),y=e.fields.filter(b=>{var j;return((j=f(b))==null?void 0:j.source)!=="env"}),v=e.secrets.filter(b=>b.set).length;return t.jsxs("li",{ref:u,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(ZU,{id:e.id,className:"mt-1"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:e.label}),t.jsx(Ne,{tone:v===e.secrets.length?"success":"plain",children:v===e.secrets.length?"set":v?`${v} of ${e.secrets.length} set`:"not set"}),s&&t.jsx(Ne,{tone:"warning",children:"enter again"})]}),t.jsxs("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:[e.kind==="model"?"Model provider":`Unlocks ${e.unlocks.join(", ")}`,e.harnesses.length>0&&` · Harnesses ${e.harnesses.length===1?`${e.harnesses[0]} only`:e.harnesses.join(", ")}`]}),((h=zx(e.id))==null?void 0:h.note)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:zx(e.id).note}),rN(e.label,e.check)&&t.jsx("p",{className:`mt-1.5 text-small ${((x=e.check)==null?void 0:x.state)==="accepted"?"text-success-text":"text-muted-foreground"}`,children:rN(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(b=>{var j;return t.jsx(yh,{field:b,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(j=g(b))!=null&&j.stored_unreadable?uW:void 0,onPaste:()=>void bh(()=>i("edit"),()=>{var k,E,N;return(N=(k=u.current)==null?void 0:k.querySelector("form"))==null?void 0:N.elements.namedItem(((E=g(b))==null?void 0:E.name)??"")}),onRemove:b.source==="console"?()=>i("remove"):void 0},b.name)})}),!y.length&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"Set when the server starts, and that one wins: change it where the server is started."})]})]}),r==="edit"&&t.jsx(u$,{tool:e,fields:y,onSave:c,onCancel:()=>i(null)}),r==="remove"&&t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(b=>b.source==="env")?" The one set in the environment stays.":""]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void d(),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>i(null),children:"Keep"})]}),o&&t.jsx("div",{className:"mt-4 border",children:t.jsx(ha,{error:o.error,title:o.title})})]})}function u$({tool:e,fields:n,onSave:s,onCancel:r}){const o=p.useRef(null),[i,c]=p.useState(!1),[d,u]=p.useState(!1),[f,g]=p.useState(null),y=()=>n.some(b=>{var j,k;return(k=(j=o.current)==null?void 0:j.elements.namedItem(b.name))==null?void 0:k.value}),v=()=>{var b;(b=o.current)==null||b.reset(),c(!1)},h=async b=>{var S,$;b.preventDefault();const j={};for(const _ of n){const O=($=(S=o.current)==null?void 0:S.elements.namedItem(_.name))==null?void 0:$.value;O&&(j[_.name]=O)}if(!Object.keys(j).length)return;u(!0),g(null);const k=await s(j);if(u(!1),!k){v();return}const E={},N=[];for(const _ of k.fields??[]){const O=_.field.startsWith("values.")?_.field.slice(7):null;O&&n.some(M=>M.name===O)?E[O]=_.message:N.push(_.message)}g({fields:E,message:N.length?N.join(" "):Object.keys(E).length?null:k.message})},x=zx(e.id);return t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:b=>void h(b),onInput:()=>c(!!y()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[x&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:e.label})," · No key yet?"," ",t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Get a key"})," (opens in a new tab)"]}),n.map(b=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:b.name}),b.set&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"Saved already. A new value replaces it; leave it empty to keep it."}),t.jsx(De,{type:"password",name:b.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:x&&n.length===1?x.placeholder:void 0}),(f==null?void 0:f.fields[b.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[b.name]})]},b.name)),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!i||d,children:d?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{v(),r()},children:"Cancel"})]})]})}const Yd=p.createContext(null);function aN({connection:e,children:n}){return t.jsx(Yd.Provider,{value:e,children:n})}const pW={state:"online"},gW=()=>()=>{},iN=()=>pW;function Kb(){const e=p.useContext(Yd);return p.useSyncExternalStore(e?e.subscribe:gW,e?e.link:iN,iN)}function f$(e){const n=p.useContext(Yd),s=p.useRef(e);s.current=e,p.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function m$(e){const[n,s]=p.useState(()=>Date.now());return p.useEffect(()=>{if(e===null)return;s(Date.now());const r=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(r)},[e]),e===null?0:Math.max(0,Math.ceil((e-n)/1e3))}function xW(){const e=p.useContext(Yd),n=Kb(),s=m$(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(jt,{bar:!0,tone:"success",icon:oa,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(jt,{bar:!0,tone:"warning",icon:p1,"data-connection":"offline",actions:t.jsx(B,{type:"button",onClick:e.retryNow,size:"xs",children:"Retry now"}),children:[t.jsxs("span",{className:"font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]})," Reconnecting… next try in ",s," s. The page shows what it had."]})}function vW(){const e=p.useContext(Yd),n=Kb(),s=m$(n.state==="offline"?n.retryAt:null);return t.jsxs("div",{"data-connection":"offline",role:"status",className:"mx-auto mt-[12vh] max-w-md border bg-card p-6",children:[t.jsx(p1,{className:"size-5 text-warning-text","aria-hidden":!0}),t.jsxs("p",{className:"mt-3 text-base font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Is it running? This page connects by itself as soon as the server answers."}),t.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[t.jsx(B,{type:"button",onClick:e==null?void 0:e.retryNow,size:"sm",children:"Retry now"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["Next try in ",s," s"]})]})]})}const bW=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var o;return(o=r.permissions)!=null&&o.length&&r.default_permission?[{name:$C(s.name,r.name),permission:r.permission??r.default_permission,default_permission:r.default_permission,permissions:r.permissions,...n&&r.permissions.includes("ask")?{ask_needs:"password"}:{}}]:[]})),lN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function yW({v2:e,choices:n,gates:s=[],harnesses:r,mcp:o=!1,onSaved:i,onOpen:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),y=()=>{o&&(g(null),e.listMcpServers().then(q=>g(q.servers),()=>g("failed")))};p.useEffect(y,[e,o]);const[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(!1),[E,N]=p.useState(null),S=p.useRef(0),$=()=>{const q=++S.current;e.toolSettings().then(H=>{q===S.current&&(u(H),h(null))},H=>{q===S.current&&h(lN(H))})};p.useEffect($,[e]);const[_,O]=p.useState("reading"),M=()=>{O("reading"),Promise.resolve(c==null?void 0:c()).then(q=>O(q===!1?"failed":"landed"))},P=()=>{$(),M()};if(p.useEffect(M,[]),!d)return v?t.jsx(jt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:$,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",v.code,": ",v.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const A=Cx(d,n),R=E?E(A):A,L=eE(n,[...s,...Array.isArray(f)?bW(f,s.some(q=>q.ask_needs==="password")):[]]),W=q=>{var I;const H=Zo(q);return H?(I=R[`mcp:${H.server}/*`])==null?void 0:I.permission:void 0},U=Object.entries(R).filter(([,q])=>(q==null?void 0:q.pin)||(q==null?void 0:q.pin_broken)),Y=q=>{var I;const H=s.find(V=>V.name===q);return!H||(((I=R[q])==null?void 0:I.permission)??H.default_permission)===H.permission},{byTool:D,rest:G}=GC((x==null?void 0:x.fields)??{},"",L.map(q=>q.name)),F=async q=>{var J;const H=E?X=>q(E(X)):q;k(!0),b(null);const I=++S.current;let V;try{V=await e.toolSettings()}catch{N(()=>H),b({fields:{},error:null,unread:!0}),k(!1);return}try{const X=await e.saveToolSettings(H(Cx(V,n)));N(null),I===S.current&&(u(X),h(null)),i()}catch(X){b(X instanceof Ue&&X.status===422&&((J=X.fields)!=null&&J.length)?{fields:Object.fromEntries(X.fields.map(re=>[re.field,re.message])),error:null}:{fields:{},error:lN(X)})}k(!1)};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),t.jsxs("div",{className:"mt-2 grid gap-x-10 gap-y-2 xl:grid-cols-2",children:[t.jsx("p",{className:"text-lead text-muted-foreground",children:"This server's provider for each tool that has a choice, and what it resolves to on each harness. A change is saved at once and applies to every run launched from then on. An agent with a provider of its own keeps it."}),s.length>0&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Each tool's permission: ",t.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",t.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",t.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("section",{"aria-label":"This server's providers",children:[L.length?t.jsx(_b,{label:"This server's tool settings",rows:L,settings:R,fallbackOf:q=>q.default_provider,issues:D,busy:j,onEdit:q=>void F(q),permissionFallbackOf:q=>W(q.name)??q.default_permission,refused:(q,H)=>H==="deny",resolvesOf:(q,H)=>H===q.provider&&Y(q.name)?t.jsx(tF,{choice:q,harnesses:r}):_==="reading"?t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"reading…"}):t.jsxs("span",{className:"block text-small text-muted-foreground",children:[_==="failed"?"What it resolves to couldn't be read.":"It changed while this page read it."," ",t.jsx(B,{type:"button",onClick:P,disabled:j,size:"xs",className:"ml-1",children:"Retry"})]})}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"This server offers no tool with a choice of provider."}),f==="failed"&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"alert",children:["The MCP servers' tools could not be read, so they are not listed. ",t.jsx(B,{type:"button",size:"xs",className:"ml-1",onClick:y,disabled:j,children:"Retry"})]}),G.map(q=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:q},q)),(x==null?void 0:x.error)&&t.jsx("div",{className:"mt-3 border",children:t.jsx(ha,{error:x.error,title:"The change was not saved"})}),(x==null?void 0:x.unread)&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),t.jsx(B,{type:"button",size:"xs",className:"mt-2",onClick:()=>void F(q=>q),disabled:j,children:"Try again"})]}),v&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsxs("p",{className:"font-mono text-small text-destructive-text",children:["The tool settings could not be read again: ",v.code,": ",v.message]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),t.jsx(B,{type:"button",onClick:P,disabled:j,size:"xs",className:"mt-2",children:"Try again"})]})]}),U.length>0&&t.jsxs("section",{"aria-label":"Pinned tools",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Pinned tools"}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"A pin bounds a tool's calls for every agent on this server, its own pin beside it."}),t.jsx("ul",{className:"mt-2 border",children:U.map(([q,H])=>t.jsxs("li",{"data-pin":q,className:"border-b px-3 py-2.5 last:border-b-0",children:[t.jsx("p",{className:"font-mono text-body",children:q}),t.jsx($x,{setting:H})]},q))})]})]})]})})}function wW(e){const n=new URLSearchParams(e??""),s=n.get("github");if(s==="connected")return{ok:!0};if(s==="error"){const r=n.get("reason");return r?{ok:!1,reason:r}:{ok:!1}}}const cN={state_invalid:"That connection was started elsewhere or has expired. Start again.",conversion_failed:"GitHub didn't hand back the App. Try connecting again.",installation_unverified:"The App's install couldn't be confirmed. Install it again from GitHub.",already_connected:"Another GitHub App was connected while this one was being created. Delete the new App on GitHub."},jW=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(cN,e.reason)?cN[e.reason]:"The connection didn't finish. Try again.";function kW(e,n){const s=n(e);if(!s)return;const r=new URL(s);return r.protocol==="https:"&&r.hostname==="github.com"?s:void 0}function NW({note:e}){const n=e.lastIndexOf(": "),s=n>=0?e.slice(n+2).trim():"",r=s?mr(s):void 0;return r?t.jsxs(t.Fragment,{children:[e.slice(0,n+2),t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"break-all underline underline-offset-2",children:s})]}):t.jsx(t.Fragment,{children:e})}function SW({v2:e,returned:n}){const[s,r]=p.useState(void 0),[o,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(!1),[g,y]=p.useState(null),[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(!1),[E,N]=p.useState(null),S=p.useRef(!1),$=p.useRef(null),_=p.useCallback(async()=>{try{const A=await e.githubConnection();r(A.connected?A:null),i(null)}catch(A){i(A instanceof Error?A.message:String(A))}},[e]);p.useEffect(()=>{_()},[_]),p.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),p.useEffect(()=>{var A;g&&((A=$.current)==null||A.submit())},[g]);const O=async()=>{var A;if(!S.current){S.current=!0,f(!0),h(null),b(null),N(null);try{const R=await e.connectGitHub(c.trim()||void 0),L=kW(R.action,mr);if(!L){h("GitHub's address didn't look right, so nothing was sent."),S.current=!1,f(!1);return}y({action:L,manifest:JSON.stringify(R.manifest)})}catch(R){if(S.current=!1,f(!1),h(R instanceof Error?R.message:String(R)),R instanceof Ue&&R.code==="github_wrong_origin"){const L=(A=R.details)==null?void 0:A.public_url;b(typeof L=="string"&&mr(L)||null)}R instanceof Ue&&R.code==="github_already_connected"&&_()}}},M=async()=>{k(!1),f(!0),h(null),b(null);try{N(await e.disconnectGitHub()),r(null)}catch(A){A instanceof Ue&&(A.status===404||A.code==="github_not_connected")?await _():h(A instanceof Error?A.message:String(A))}finally{f(!1)}},P=s?mr(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[t.jsxs("div",{className:fi,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"GitHub"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One GitHub App for this server: its templates and triggers reach GitHub through it."})]}),t.jsxs("div",{className:mi,children:[n&&t.jsx("p",{"aria-label":"From GitHub",role:"status",className:te("border p-4 text-lead",n.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:jW(n)}),(v||x)&&t.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:x?t.jsxs("p",{children:["Open this server at ",t.jsx("a",{href:x,className:"break-all underline underline-offset-2",children:x})," to connect GitHub."]}):t.jsx("p",{children:v})}),E&&t.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[t.jsx("p",{children:t.jsx(NW,{note:E.note})}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:E.triggers_off?`${E.triggers_off} GitHub ${E.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),o&&t.jsx(jt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:()=>void _(),children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["GitHub's connection could not be read: ",o]})}),t.jsxs(Dr,{title:"Connection",children:[s===void 0&&!o&&t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),s===null&&t.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),t.jsx(De,{name:"org",value:c,onChange:A=>d(A.target.value),disabled:u,placeholder:"your-org",className:"h-9 w-auto"})]}),t.jsxs(B,{type:"button",variant:"solid",onClick:()=>void O(),disabled:u,children:[t.jsx(_j,{"aria-hidden":!0}),g?"Opening GitHub…":"Connect GitHub"]})]}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"GitHub asks you to create the App, then to install it on the accounts it may use. You come back here after."})]}),s&&t.jsxs("section",{"aria-label":"GitHub App",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-lead",children:[t.jsx(_j,{className:"size-4 text-muted-foreground","aria-hidden":!0}),P?t.jsx("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):t.jsx("span",{className:"font-mono",children:s.slug}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?t.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(A=>t.jsx("li",{children:A.account},A.id))}):t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),j?t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[t.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),t.jsx(B,{type:"button",variant:"destructive",disabled:u,onClick:()=>void M(),children:"Disconnect GitHub"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}):t.jsx(B,{type:"button",variant:"outline",className:"mt-4",disabled:u,onClick:()=>k(!0),children:"Disconnect"})]})]}),g&&t.jsx("form",{"data-github-manifest":!0,ref:$,method:"post",action:g.action,hidden:!0,children:t.jsx("input",{type:"hidden",name:"manifest",defaultValue:g.manifest})})]})]})})}const CW=8,EW={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function $W({v2:e,signIn:n,add:s,writable:r,whyNot:o="sign_in",open:i=d=>location.assign(d),choices:c=[]}){var q,H,I,V,J;const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState(!1),[h,x]=p.useState(null),[b,j]=p.useState(null),k=(s==null?void 0:s.preset)==="composio"?s:void 0,[E,N]=p.useState(s&&!k?{add:s}:null),[S,$]=p.useState(k&&r?k:!1),[_,O]=p.useState(null),M=s?JSON.stringify(s):"",P=p.useRef(M);p.useEffect(()=>{if(M===P.current)return;P.current=M;const X=M?JSON.parse(M):void 0;N(X&&X.preset!=="composio"?{add:X}:null),$((X==null?void 0:X.preset)==="composio"&&r?X:!1)},[M]);const A=p.useRef(0),R=p.useRef(null),L=()=>{const X=++A.current;e.listMcpServers().then(re=>{X===A.current&&(u(re.servers),j(null))},re=>{X===A.current&&j(co(re))})};p.useEffect(L,[e]),p.useEffect(()=>{e.toolSettings().then(g,()=>g(null))},[e]);const W=p.useRef(!1),U=async(X,re)=>{if(!W.current){W.current=!0,v(!0),x(null);try{const ae=await e.toolSettings();g(await e.saveToolSettings(re(Cx(ae,c)))),L()}catch(ae){x({server:X,problem:co(ae)})}W.current=!1,v(!1)}},Y=p.useRef(null);s&&d&&((q=Y.current)==null?void 0:q.key)!==M&&(Y.current={key:M,name:h$(s.name,d)});const D=X=>{var re;return((re=Y.current)==null?void 0:re.key)===JSON.stringify(X)&&Y.current.name!==X.name?{...X,toolkit:X.toolkit??X.name,name:Y.current.name}:X},G=d!==null||b!==null;p.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const F=async(X,re)=>i((await e.startMcpSignIn(X,re)).authorization_url);return t.jsx("div",{ref:R,className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[t.jsxs("div",{className:fi,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"MCP servers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A remote MCP server's tools, for any agent you grant them to in its Tools step. A saved credential is never shown again."})]}),t.jsxs("div",{className:mi,children:[n&&t.jsx("p",{className:`border p-4 text-body ${n.ok?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:n.ok?`Signed in to ${n.server}. Its tools are saved.`:`Signing in to ${n.server} failed: ${kz(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:fa[o]}),_&&t.jsx("p",{className:`border p-4 text-body ${_.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:_.note}),b&&t.jsx(jt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:L,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",b.text]})}),t.jsxs(Dr,{title:"Servers",aside:!E&&!S&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:!r,onClick:()=>$(!0),children:"Add from Composio"}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>N({}),children:"Add server"})]}),children:[E&&(!E.add||G)&&t.jsx(UW,{v2:e,saved:E.saved,add:E.add&&D(E.add),given:E.problem,writable:r,taken:d,signIn:F,onCancel:()=>N(null),onSaved:(X=>re=>{re&&O(re),N(ae=>ae===X?null:ae),L()})(E)},`${((H=E.saved)==null?void 0:H.name)??"new"}|${((I=E.add)==null?void 0:I.name)??""}|${((V=E.add)==null?void 0:V.auth)??""}|${((J=E.add)==null?void 0:J.preset)??""}`),S&&(typeof S!="object"||G)&&t.jsx(IW,{v2:e,add:typeof S=="object"?D(S):void 0,onClose:()=>$(!1),onSaved:L},typeof S=="object"?M:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(X=>t.jsx(TW,{v2:e,server:X,settings:f,settingsBusy:y,settingsProblem:(h==null?void 0:h.server)===X.name?h.problem:null,onSettings:re=>void U(X.name,re),writable:r&&!E,signIn:F,onChange:re=>N({saved:X,...re?{problem:re}:{}}),onPaste:()=>void bh(()=>N({saved:X}),()=>{var re;return((re=R.current)==null?void 0:re.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:L,onDeleted:re=>{O(re??null),L()}},X.name))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."}))]}),t.jsx(LW,{v2:e})]})]})})}const Sl=({problem:e})=>t.jsxs("div",{role:"alert",children:[t.jsx("p",{className:"font-mono text-body text-destructive-text",children:e.text}),e.detail&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.detail})]}),Fc=(e,n)=>`mcp:${e}/${n}`,_W=["allow","ask","deny"];function TW({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:o,onSettings:i,writable:c,signIn:d,onChange:u,onPaste:f,onChanged:g,onDeleted:y}){var P,A;const[v,h]=p.useState(!1),[x,b]=p.useState(!1),[j,k]=p.useState(null),[E,N]=p.useState(null),S=async R=>{h(!0),N(null);try{await R()}catch(L){N(co(L))}h(!1)},[$,_]=n.credential?EW[n.credential]??[n.credential,"plain"]:["no credential","plain"],O=n.auth.type==="oauth",M=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,R])=>R.length).map(([R,L])=>`${R} ${L.join(", ")}`);return t.jsxs("li",{"data-server":n.name,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(lR,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:n.name}),t.jsx(Ne,{tone:_,children:$}),!!((P=n.not_metered)!=null&&P.length)&&t.jsx(Ne,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(Ne,{tone:"muted",children:Id[n.source]}),t.jsx("span",{"data-toolkit":!0,className:"font-mono text-small text-muted-foreground",children:n.toolkit?`toolkit ${n.toolkit}`:"no toolkit"})]})]}),t.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:n.url}),n.auth.type==="github_app"&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed with this server's GitHub App: a token narrowed to the run's repository is made for each run",(A=n.auth.headers)!=null&&A.length?` · headers ${n.auth.headers.join(", ")}`:""]}),O&&n.oauth&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed in with OAuth",n.oauth.scopes.length?` · ${n.oauth.scopes.join(" ")}`:"",n.oauth.client==="pre-registered"&&n.oauth.client_id?` · client ${n.oauth.client_id}`:"",n.credential==="expired"?" · sign-in expired: sign in again":n.oauth.expires_at?` · token until ${vt(n.oauth.expires_at)}`:""]}),s&&t.jsx(OW,{server:n,settings:s,busy:r,onSettings:i}),o&&t.jsx("div",{className:"mt-2",children:t.jsx(Sl,{problem:o})}),t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer font-mono text-small",children:[n.tools.length," tool",n.tools.length===1?"":"s"]}),t.jsx("div",{className:"mt-2",children:t.jsx(MW,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(yh,{field:n.secret,label:FW[n.auth.type],writable:c,onPaste:O?void 0:f})}),n.source==="composio"&&t.jsx(AW,{v2:e,server:n.name,writable:c}),M&&t.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:M.length?M.join(" · "):"No change: it lists the same tools."})]}),!x&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[O&&n.credential!=="sealed"&&c&&t.jsx(B,{size:"sm",variant:"primary",disabled:v,onClick:()=>void S(()=>{var R;return d(n.name,{url:n.url,...(R=n.oauth)!=null&&R.scopes.length?{scopes:n.oauth.scopes}:{}})}),children:"Sign in again"}),t.jsx(B,{size:"sm",disabled:v,onClick:()=>void S(async()=>{try{k(await e.refreshMcpServer(n.name))}finally{g()}}),children:"Refresh"}),t.jsx(B,{size:"sm",disabled:v,onClick:()=>u(),children:"Change"}),t.jsx(B,{size:"sm",variant:"destructive",disabled:v,onClick:()=>b(!0),children:"Delete"})]})]}),x&&t.jsxs("div",{role:"alertdialog","aria-label":`Delete ${n.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",n.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),t.jsx(B,{size:"sm",variant:"destructive",disabled:v,onClick:()=>void S(async()=>{var R;y((R=await e.deleteMcpServer(n.name))==null?void 0:R.composio)}),children:"Delete"}),t.jsx(B,{size:"sm",onClick:()=>b(!1),children:"Keep"})]}),E&&t.jsxs("div",{className:"mt-3",children:[t.jsx(Sl,{problem:E}),E.needsClient&&c&&t.jsx(B,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>u(E),children:"Enter a Client ID"})]})]})}const RW={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function AW({v2:e,server:n,writable:s}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,v]=p.useState(!1),[h,x]=p.useState(!1);if(p.useEffect(()=>{let k=!0;return e.composioTriggers(n).then(E=>{k&&o(E)},E=>{k&&(E instanceof Ue&&E.status===404?u(!0):c(co(E)))}),()=>{k=!1}},[e,n]),d)return null;const b=async()=>{g(!1),v(!0),c(null),x(!1);try{await e.rotateComposioSecret(n),x(!0)}catch(k){c(co(k))}v(!1)},j=r==null?void 0:r.subscription;return t.jsxs("section",{"data-composio-triggers":!0,"aria-label":`${n}'s triggers`,className:"mt-3 border p-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Triggers"}),r?t.jsxs(t.Fragment,{children:[r.triggers.length?t.jsx("ul",{className:"mt-2 space-y-1",children:r.triggers.map(k=>t.jsxs("li",{"data-trigger":k.id,className:"flex flex-wrap items-center gap-x-2 text-body",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(k.id)}`,className:"font-semibold hover:underline",children:k.name}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:k.event}),t.jsxs("span",{className:`font-mono text-small ${k.on_composio==="missing"?"text-warning-text":"text-muted-foreground"}`,children:["· ",RW[k.on_composio],k.enabled?"":" · paused here"]})]},k.id))}):t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["No trigger uses it yet. ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),r.composio_error&&t.jsxs("p",{className:"mt-2 text-small text-warning-text",children:["Composio didn't answer: ",r.composio_error]}),j&&(j.ours?t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"The project's webhook subscription sends its events here."}):t.jsxs("p",{className:"mt-2 break-all text-small text-muted-foreground",children:["The project's webhook subscription sends its events to ",t.jsx("span",{className:"font-mono",children:j.webhook_url}),", not here: a new trigger asks before it moves it."]})),(j==null?void 0:j.ours)&&s&&!f&&t.jsx(B,{className:"mt-2",size:"sm",disabled:y,onClick:()=>g(!0),children:"Rotate secret"}),f&&t.jsxs("div",{role:"alertdialog","aria-label":"Rotate the subscription's secret?",className:"mt-2 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Rotate the subscription's secret? Composio makes a new one and this server keeps it; a delivery signed with the old one is refused from then on."}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void b(),children:"Yes, rotate"}),t.jsx(B,{size:"sm",onClick:()=>g(!1),children:"Keep"})]}),h&&t.jsx("p",{className:"mt-2 text-small text-success-text",role:"status",children:"Rotated: Composio signs with the new secret from now on."})]}):!i&&t.jsx("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:"Reading its triggers"}),i&&t.jsx("div",{className:"mt-2",children:t.jsx(Sl,{problem:i})})]})}function OW({server:e,settings:n,busy:s,onSettings:r}){var g;const o=Fc(e.name,"*"),i=((g=n[o])==null?void 0:g.allow_reads)===!0,c=e.tools.filter(y=>y.effect==="read").length,d=`allow-reads-${e.name}`,u=`${d}-words`,f=y=>r(v=>{const{[o]:h,...x}=v,{allow_reads:b,...j}=h??{},k=y?{...j,allow_reads:!0}:j;return Object.keys(k).length?{...x,[o]:k}:x});return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ed,{checked:i,onChange:f,busy:s,labelledBy:d}),t.jsx("span",{id:d,className:"caps text-small font-semibold",children:"Allow reads"})]}),t.jsxs("p",{id:u,className:"mt-1 text-small text-muted-foreground",children:[c," of ",e.tools.length," tool",e.tools.length===1?"":"s"," read-only, as the server marks them: ",i?"they run without asking":"on, they run without asking",". Writes keep their permission."]})]})}function MW({server:e,settings:n,busy:s,onSettings:r}){const o=n==null?void 0:n[Fc(e.name,"*")],i=new Map(e.tools.map(u=>[Fc(e.name,u.name),u])),c=e.tools.map(u=>{var f;return{name:Fc(e.name,u.name),...n?{gate:{name:Fc(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:_W}}:{}}}),d=u=>{var g,y;const f=(g=e.prices)==null?void 0:g[u];return f!==void 0?`$${f} a call`:(y=e.not_metered)!=null&&y.includes(u)?"not metered":null};return t.jsx(_b,{label:`${e.name}'s tools`,rows:c,settings:n??{},busy:s,issues:{},fallbackOf:()=>"",resolvesOf:()=>null,onEdit:r,labelOf:u=>{var f;return((f=i.get(u))==null?void 0:f.name)??u},detailOf:u=>{var f;return d(((f=i.get(u))==null?void 0:f.name)??"")},effectOf:u=>{var f;return(f=i.get(u))==null?void 0:f.effect},confirmAllowOf:u=>{var f;return((f=i.get(u))==null?void 0:f.effect)==="destructive"},refused:(u,f)=>f==="deny",fallbackWordOf:u=>{var f;return(f=i.get(u))!=null&&f.fallback_allow_reads?"allow reads":void 0},permissionFallbackOf:u=>{var f;return(f=i.get(u.name))!=null&&f.fallback_allow_reads?"allow":(o==null?void 0:o.permission)??u.default_permission}})}function LW({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(""),y=()=>void e.mcpPrivateHosts().then(x=>{s(x.hosts),o(null)},x=>o(co(x)));p.useEffect(y,[e]);const v=async x=>{u(!0),c(null);try{return s((await e.saveMcpPrivateHosts(x)).hosts),!0}catch(b){return c(co(b)),!1}finally{u(!1)}},h=async x=>{x.preventDefault(),n&&f.trim()&&await v([...n,f.trim()])&&g("")};return t.jsxs(Dr,{titleId:"mcp-private-hosts",title:"Private network hosts",note:t.jsx("p",{children:"Off by default. A host listed here may run an MCP server's sign-in on your private network (10.x, 172.16–31.x, 192.168.x, 100.64–127.x, fc00::/7), over https only; never this machine, loopback or a link-local address such as cloud metadata."}),children:[r&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",r.text]}),t.jsx(B,{size:"sm",onClick:y,className:"mt-3",children:"Try again"})]}),n&&(n.length?t.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border",children:n.map(x=>t.jsxs("li",{"data-host":x,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"break-all font-mono text-body",children:x}),t.jsx(B,{size:"sm",disabled:d,onClick:()=>void v(n.filter(b=>b!==x)),children:"Remove"})]},x))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No host is allowed: a sign-in on a private network is refused."})),n&&t.jsxs("form",{onSubmit:x=>void h(x),"aria-label":"Allow a private network host",className:"flex gap-2",children:[t.jsx(De,{name:"mcp-private-host","aria-label":"Host name or IP address",value:f,onChange:x=>g(x.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:d||!f.trim(),children:"Allow"})]}),i&&t.jsx(Sl,{problem:i})]})}const PW=32;function h$(e,n){const s=new Set(n.map(r=>r.name));if(!s.has(e))return e;for(let r=2;;r++){const o=`-${r}`,i=`${e.slice(0,PW-o.length).replace(/-+$/,"")}${o}`;if(!s.has(i))return i}}function IW({v2:e,add:n,onClose:s,onSaved:r}){var A;const o=p.useRef(null),[i,c]=p.useState((n==null?void 0:n.toolkit)??""),[d,u]=p.useState((n==null?void 0:n.name)??""),[f,g]=p.useState(null),[y,v]=p.useState([]),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(!1),N=()=>{var R,L;return(((L=(R=o.current)==null?void 0:R.elements.namedItem("composio-key"))==null?void 0:L.value)??"").trim()},S=async R=>{E(!0),j(null);try{await R()}catch(L){j(co(L))}E(!1)},$=p.useRef(0),_=()=>{$.current++,g(null)},O=()=>S(async()=>{const R=++$.current;g(null),v([]);const L=await e.composioTools(N(),i.trim().toLowerCase());R===$.current&&(g(L),n!=null&&n.tools&&L.toolkit===n.toolkit&&v(L.tools.map(W=>W.slug).filter(W=>n.tools.includes(W))))}),M=()=>S(async()=>{var L,W;const R=await e.saveComposioServer(d.trim(),N(),f.toolkit,y);(L=o.current)==null||L.reset(),r(),R.connect_url||(W=R.not_served)!=null&&W.length||R.composio?x({connect:R.connect_url,notServed:R.not_served,composio:R.composio}):s()}),P=R=>v(L=>L.includes(R)?L.filter(W=>W!==R):[...L,R]);return h?t.jsxs("section",{"aria-label":"Composio server saved",className:"space-y-3 border bg-card p-4",children:[t.jsxs("p",{className:"text-body",children:["Saved.",h.connect?` Its tools need your ${f==null?void 0:f.toolkit} account: connect it on Composio, then refresh the server.`:""]}),h.connect&&t.jsx("p",{children:t.jsxs("a",{href:h.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",f==null?void 0:f.toolkit," account"]})}),(A=h.notServed)!=null&&A.length?t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",h.notServed.join(", "),": a run can't call ",h.notServed.length===1?"it":"them","."]}):null,h.composio&&t.jsx("p",{className:`border p-4 text-body ${h.composio.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:h.composio.note}),t.jsx(B,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:R=>{R.preventDefault(),f&&y.length&&d.trim()&&M()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:R=>{R.target.name==="composio-key"&&_()},children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"Composio runs the toolkit's actions for you. This saves an MCP server that grants only the actions you tick, with your Composio key sealed like any credential."}),(n==null?void 0:n.tools)&&t.jsxs("p",{role:"note",className:"text-small text-muted-foreground",children:["A template uses ",n.tools.join(", "),": enter your key and load the actions, and those are ticked."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),t.jsx(De,{name:"composio-key",...Hf})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsx(De,{name:"composio-toolkit",value:i,onChange:R=>{c(R.target.value),_()},placeholder:"github",spellCheck:!1})]}),b&&t.jsx(Sl,{problem:b}),f&&t.jsxs("fieldset",{className:"space-y-2",children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),f.tools.length?t.jsx("ul",{className:"divide-y border",children:f.tools.map(R=>t.jsx("li",{className:"px-3 py-2",children:t.jsxs("label",{className:"flex items-start gap-2 text-body",children:[t.jsx("input",{type:"checkbox",value:R.slug,checked:y.includes(R.slug),onChange:()=>P(R.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:R.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:R.slug}),R.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:R.description})]})]})},R.slug))}):t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This toolkit lists no actions."}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",d.trim()||"<name>","/<tool>."]}),t.jsx(De,{name:"composio-name",value:d,onChange:R=>u(R.target.value),spellCheck:!1})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:k||!i.trim(),onClick:()=>void O(),children:"Load actions"}),f&&t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:k||!y.length||!d.trim(),children:k?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",disabled:k,onClick:()=>{var R;(R=o.current)==null||R.reset(),s()},children:"Cancel"})]})]})}const zW=/^mcp-(token|scopes|client-id|client-secret|header-(name|value)-\d+)$/,Hf={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},DW=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],FW={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function UW({v2:e,saved:n,add:s,given:r,writable:o,taken:i,signIn:c,onCancel:d,onSaved:u}){var be,ge,Je,tt,ft;const f=p.useRef(null),g=n?void 0:EC(s==null?void 0:s.preset),[y,v]=p.useState(g),[h,x]=p.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[b,j]=p.useState((n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?cm:(g==null?void 0:g.url)??"")),[k,E]=p.useState((n==null?void 0:n.auth.type)??(s==null?void 0:s.auth)??(g==null?void 0:g.auth)??"none"),[N,S]=p.useState(Math.max(1,((be=n==null?void 0:n.auth.headers)==null?void 0:be.length)??0)),$=k==="github_app"?"github":(n==null?void 0:n.source)==="composio"?"composio":"url",[_,O]=p.useState((n==null?void 0:n.toolkit)??(g?g.name:s&&!s.auth?s.toolkit??s.name:"")),M=$==="github"?"github":_.trim(),P=()=>{if(k==="github_app")return{};const ve=M||null;return n?ve!==n.toolkit?{toolkit:ve}:{}:ve?{toolkit:ve}:{}},A=!n&&!!(i!=null&&i.some(ve=>ve.name===h.trim())),R=!!n||!!i&&!A,[L,W]=p.useState(null),[U,Y]=p.useState(r??null),[D,G]=p.useState(!1),F=p.useRef(0),q=()=>{F.current++,W(null)},H=ve=>{var Ee,Q;return(((Q=(Ee=f.current)==null?void 0:Ee.elements.namedItem(ve))==null?void 0:Q.value)??"").trim()},[I,V]=p.useState(!1),J=ve=>{try{return new URL(ve).origin}catch{return ve}},X=(ve=k)=>{var Ee;return V(!!n&&ve==="oauth"&&(n.auth.type!=="oauth"||H("mcp-scopes")!==(((Ee=n.oauth)==null?void 0:Ee.scopes.join(" "))??"")||!!H("mcp-client-id")||!!H("mcp-client-secret")||J(H("mcp-url"))!==J(n.url)))};p.useEffect(()=>X(),[k]);const re=()=>{if(k==="bearer")return H("mcp-token")?{type:k,token:H("mcp-token")}:{type:k};if(k!=="headers"&&k!=="github_app")return{type:k};const ve=Object.fromEntries(Array.from({length:N},(Ee,Q)=>[H(`mcp-header-name-${Q}`),H(`mcp-header-value-${Q}`)]).filter(([Ee,Q])=>Ee&&Q));return Object.keys(ve).length?{type:k,headers:ve}:{type:k}},ae=async ve=>{G(!0),Y(null);try{await ve()}catch(Ee){Y(co(Ee))}G(!1)},ye=!!(U!=null&&U.needsClient);p.useEffect(()=>{ye&&E("oauth")},[ye]),p.useEffect(()=>{var ve,Ee;ye&&k==="oauth"&&((Ee=(ve=f.current)==null?void 0:ve.elements.namedItem("mcp-client-id"))==null||Ee.focus())},[ye,k]);const he=()=>R&&ae(()=>{const ve=H("mcp-scopes").split(/\s+/).filter(Boolean),Ee=H("mcp-client-id");return c(h.trim(),{url:b.trim(),...ve.length?{scopes:ve}:{},...Ee?{client_id:Ee,...H("mcp-client-secret")?{client_secret:H("mcp-client-secret")}:{}}:{},...P()})}),we=()=>{const ve=F.current;ae(async()=>{try{const Ee=await e.previewMcpServer(b.trim(),re(),n==null?void 0:n.name);ve===F.current&&W(Ee)}catch(Ee){if(ve===F.current)throw Ee}})},ze=ve=>{if(ve.preventDefault(),!!R){if(k==="oauth"&&(!n||I))return void he();ae(async()=>{var Q;const Ee=await e.saveMcpServer(h.trim(),b.trim(),re(),P());(Q=f.current)==null||Q.reset(),u(Ee.composio)})}},le=!D&&R&&!!h.trim()&&!!b.trim()&&(!!n||!!L),me=ve=>{var Ee;if(i){for(const Q of Array.from(((Ee=f.current)==null?void 0:Ee.elements)??[]))Q instanceof HTMLInputElement&&zW.test(Q.name)&&(Q.value="");S(1),v(ve),x(h$(ve.name,i)),j(ve.url),E(ve.auth),O(ve.name),Y(null),q()}},Ke=ve=>(n==null?void 0:n.credential)==="sealed"&&n.auth.type===k&&t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",ve]});return t.jsxs("form",{ref:f,autoComplete:"off",onSubmit:ze,"aria-label":n?`Change ${n.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:ve=>{["mcp-name","mcp-toolkit"].includes(ve.target.name)||q(),X()},children:[!n&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("span",{className:"caps block text-small font-semibold",children:"Presets"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:gb.map(ve=>t.jsx(B,{type:"button",size:"sm",variant:(y==null?void 0:y.id)===ve.id?"solid":"outline","aria-pressed":(y==null?void 0:y.id)===ve.id,disabled:D||!i||!o&&ve.auth!=="none",onClick:()=>me(ve),children:ve.label},ve.id))}),!i&&t.jsx("p",{className:"text-small text-muted-foreground",children:"The presets wait for the saved servers to be read, so the name one picks is free."}),y&&t.jsx("p",{role:"note","data-mcp-preset":y.id,className:"text-small text-muted-foreground",children:y.note}),(y==null?void 0:y.readOnly)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ed,{checked:b===y.readOnly,label:"Read-only",disabled:D,onChange:ve=>{j(ve?y.readOnly:y.url),q()}}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Read-only: its address that lists only the read tools."})]}),t.jsx("p",{className:"caps pt-2 text-small font-semibold",children:"Or any MCP URL"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",h.trim()||"<name>","/<tool>."]}),t.jsx(De,{name:"mcp-name",value:h,readOnly:!!n,onChange:ve=>x(ve.target.value),spellCheck:!1}),A&&t.jsxs("span",{role:"alert",className:"mt-1 block text-small text-destructive-text",children:[h.trim()," is saved already: saving would replace it. Change it from its row, or choose another name."]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),t.jsx(De,{name:"mcp-url",value:b,onChange:ve=>{j(ve.target.value),U!=null&&U.needsClient&&Y(null)},placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),t.jsxs("div",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Source"}),t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"What made it: GitHub App access is GitHub, the Composio preset is Composio, anything else is URL."}),t.jsx("span",{"data-mcp-source":$,className:"font-mono text-body",children:Id[$]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["The name a template gives these tools (mcp:",M||"<toolkit>","/<tool>): applying one uses this server for them."]}),t.jsx(De,{name:"mcp-toolkit",value:$==="github"?"github":_,readOnly:$==="github",onChange:ve=>O(ve.target.value),placeholder:"hubspot",spellCheck:!1})]}),t.jsxs("fieldset",{children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Credential"}),t.jsx("div",{className:"flex flex-wrap gap-4",children:DW.map(([ve,Ee])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:ve,checked:k===ve,disabled:!o&&ve!=="none",onChange:()=>{E(ve),ve==="github_app"&&!b.trim()&&j(cm),q()},className:"accent-primary"}),Ee]},ve))})]}),k==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),Ke("A new token replaces it; leave this empty to keep it."),t.jsx(De,{name:"mcp-token",...Hf})]}),k==="github_app"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Uses this server's GitHub App (Settings → GitHub): a token for the repository of each run is made when the run starts, and an agent never sees it. The address is GitHub's hosted MCP, the only one this credential goes to. Headers are optional."}),(k==="headers"||k==="github_app")&&t.jsxs("div",{className:"space-y-2",children:[Ke(`Its headers: ${(ge=n==null?void 0:n.auth.headers)==null?void 0:ge.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:N},(ve,Ee)=>{var Q;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(De,{name:`mcp-header-name-${Ee}`,"aria-label":`Header ${Ee+1} name`,placeholder:"X-Api-Key",defaultValue:(Q=n==null?void 0:n.auth.headers)==null?void 0:Q[Ee],spellCheck:!1}),t.jsx(De,{name:`mcp-header-value-${Ee}`,"aria-label":`Header ${Ee+1} value`,...Hf})]},Ee)}),N<CW&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>S(ve=>ve+1),children:"Add header"})]}),k==="oauth"&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"This server signs in for you and keeps the tokens; an agent never sees one. Sign in opens the server's own page to approve it, and its tools are saved once you do."}),((Je=n==null?void 0:n.oauth)==null?void 0:Je.client_id)&&t.jsxs("p",{className:"text-small text-muted-foreground",children:["Signing in again uses the client it signed in with (",n.oauth.client_id,"); a client ID here replaces it."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Scopes (optional)"}),t.jsx(De,{name:"mcp-scopes",placeholder:"read write",defaultValue:(tt=n==null?void 0:n.oauth)==null?void 0:tt.scopes.join(" "),spellCheck:!1})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:ye?"Client ID (this server needs one)":"Client ID (optional)"}),t.jsx(De,{name:"mcp-client-id",spellCheck:!1})]}),o&&t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:ye?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(De,{name:"mcp-client-secret",...Hf})]})]})]}),U&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Sl,{problem:U}),U.signIn&&k!=="oauth"&&o&&t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:D||!R||!h.trim(),onClick:()=>void he(),children:"Sign in"})]}),L&&t.jsxs("section",{"aria-label":"Preview",className:"border bg-background p-3",children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["MCP ",L.protocol,(ft=L.server_info)!=null&&ft.name?` · ${L.server_info.name}${L.server_info.version?` ${L.server_info.version}`:""}`:""," · ",L.tools.length," tool",L.tools.length===1?"":"s"]}),L.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:L.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:bz}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:L.tools.map(ve=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("span",{className:"font-mono text-body",children:ve.name}),ve.title&&t.jsx("span",{className:"ml-2 text-small",children:ve.title}),ve.description&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:ve.description})]},ve.name))})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[k==="oauth"&&!o?null:k==="oauth"&&I?t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:D||!b.trim(),children:"Sign in again with these settings"}):k==="oauth"?t.jsx(B,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:D||!R||!h.trim()||!b.trim(),onClick:()=>void he(),children:n?"Sign in again":"Sign in"}):t.jsx(B,{type:"button",size:"sm",disabled:D||!b.trim(),onClick:we,children:"Preview"}),(k!=="oauth"||n&&!I)&&t.jsx(B,{type:"submit",size:"sm",variant:U!=null&&U.signIn&&k!=="oauth"&&o?"outline":"primary",disabled:!le,children:D?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{var ve;(ve=f.current)==null||ve.reset(),d()},children:"Cancel"})]})]})}const dN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function WW({v2:e,needs:n,model:s,onSaved:r,writable:o,whyNot:i="sign_in",plan:c,onPlan:d,onDone:u,harnesses:f}){const[g,y]=p.useState(null),[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(null),[E,N]=p.useState(c??null);p.useEffect(()=>{N(c??null)},[c]);const[S,$]=p.useState(!1),_=p.useRef(0),O=()=>{const G=++_.current;e.listToolKeys().then(F=>{G===_.current&&(y(F.keys.filter(q=>q.kind==="model")),h(null))}).catch(F=>{G===_.current&&h(dN(F))})};p.useEffect(()=>{n!=="model"&&O()},[e,n]);const M=s!=null&&s.includes("/")&&!od(s)?s.slice(0,s.indexOf("/")):void 0,P=g==null?void 0:g.find(G=>G.id===M),A=P?[P]:g,R=g==null?void 0:g.find(G=>G.id===x),L=(R==null?void 0:R.fields.filter(G=>{var F;return((F=R.secrets.find(q=>fm(q.name)===G.name))==null?void 0:F.source)!=="env"}))??[],W=!!E&&n!=="model"&&!M,U=n!=="model"&&(!W||S),Y=G=>{N(G),d==null||d(G)},D=f&&t.jsx(iE,{harnesses:f});return W&&E.state==="signed_in"?t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Ka,{className:"mt-1 size-4 shrink-0 text-success-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"text-prose font-semibold",children:"Signed in with ChatGPT"}),t.jsx(Rx,{v2:e,view:E,onView:Y}),D,t.jsx(B,{type:"button",size:"sm",onClick:()=>u==null?void 0:u(),children:"Done"})]})]})}):t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Ka,{className:"mt-1 size-4 shrink-0 text-warning-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"text-prose font-semibold",children:n==="model"?"This server's default model doesn't run":W?"Sign in with ChatGPT or add a model key to run agents":"Add a model key to run agents"}),n==="model"?t.jsx("p",{className:"text-body text-muted-foreground",children:"The server's AGENT_MODEL names a model it doesn't know, so an agent that names no model can't run. Set AGENT_MODEL to a provider/model-id where the server starts, or name a model in each agent."}):P?t.jsxs("p",{className:"text-body text-muted-foreground",children:["This server's default model is ",t.jsx("span",{className:"font-mono",children:s}),", and no ",P.label," key is set, so an agent that names no model can't run. Save the ",P.label," key: such an agent then runs on that model."]}):W?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"This server has no model yet, so an agent that names no model can't run."}),t.jsx(Rx,{v2:e,view:E,onView:Y,writable:o,whyNot:i,beside:t.jsx(B,{type:"button",size:"sm","aria-expanded":S,onClick:()=>$(G=>!G),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:E2}),S&&t.jsx("p",{className:"text-body text-muted-foreground",children:Dx})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"No model provider's key is set on this server, so an agent that names no model can't run. Save one: such an agent then runs on that provider's everyday model."}),t.jsx("p",{className:"text-body text-muted-foreground",children:Dx})]}),U&&v&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",v.code,": ",v.message]}),t.jsx(B,{type:"button",onClick:O,size:"sm",className:"mt-2",children:"Try again"})]}),U&&g&&!o&&t.jsx("p",{className:"text-body",role:"status",children:fa[i]}),U&&g&&o&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:A.map(G=>t.jsx(B,{size:"sm",variant:x===G.id?"solid":"primary","aria-pressed":x===G.id,onClick:()=>{b(x===G.id?null:G.id),k(null)},children:G.label},G.id))}),U&&R&&o&&(L.length?t.jsx(u$,{tool:R,fields:L,onCancel:()=>b(null),onSave:async G=>{k(null);try{await e.saveToolKey(R.id,G)}catch(F){return F instanceof Ue&&F.status===422?F:(k(dN(F)),null)}return b(null),O(),r==null||r(),null}},R.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",R.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(ha,{error:j,title:"The key was not saved"})}),D,t.jsxs("p",{className:"text-small text-muted-foreground",children:["Every key is in ",t.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"#/settings/keys",children:"Settings"}),"."]})]})]})})}function HW({needs:e,settings:n,model:s,source:r,chatgpt:o=!1}){return t.jsx("p",{role:"status","aria-label":"No model",className:"border-b bg-card px-5 py-3 text-body text-warning-text md:px-8",children:e==="model"?"This server's default model doesn't run here: set AGENT_MODEL to a model it knows, and restart.":t.jsxs(t.Fragment,{children:["No model yet."," ",r==="gateway"?t.jsxs(t.Fragment,{children:["This server sends its models to a gateway: name the gateway's model in AGENT_MODEL where AgentRun starts, and restart",n?t.jsxs(t.Fragment,{children:[", or ",t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"add a model key in Settings → Model keys"})]}):null,"."]}):s?`This server's default model is ${s}: set its provider's key where AgentRun starts, and restart.`:o&&n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Continue with ChatGPT"})," in Settings → Model keys: Codex and pi agents run on your ChatGPT plan. Add a key there for the rest (one OpenRouter key gives every harness its model), and it takes effect at once."]}):n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Add a key in Settings → Model keys"})," (one OpenRouter key gives every harness its model), and it takes effect at once. Or set OPENROUTER_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY or PARTICLE_API_KEY where AgentRun starts, and restart."]}):"Set OPENROUTER_API_KEY (one key gives every harness its model), ANTHROPIC_API_KEY, OPENAI_API_KEY or PARTICLE_API_KEY, and restart."]})})}const uN=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],BW={gmail:t.jsxs(t.Fragment,{children:["A Google ",t.jsx("a",{href:"https://myaccount.google.com/apppasswords",target:"_blank",rel:"noreferrer",className:"text-primary-text underline",children:"app password"}),". Google gives one only with 2-Step Verification on, and a company account whose admin turned app passwords off won't connect yet."]}),fastmail:t.jsx(t.Fragment,{children:"A Fastmail app password with IMAP and SMTP access, made under Privacy & Security in Fastmail."}),icloud:t.jsx(t.Fragment,{children:"An app-specific password, made under Sign-In and Security in your Apple Account."}),other:t.jsx(t.Fragment,{children:"Your mail server's IMAP and SMTP servers, and its password: an app password where it offers one."})},qW="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function GW(e){return e==="other"?"Password":"App password"}const KW={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},fN=e=>{var n,s,r,o;return{preset:(e==null?void 0:e.preset)??"gmail",address:(e==null?void 0:e.address)??"",user:e!=null&&e.user&&e.user!==e.address?e.user:"",imapHost:(e==null?void 0:e.preset)==="other"?((n=e.imap)==null?void 0:n.host)??"":"",imapPort:(e==null?void 0:e.preset)==="other"?String(((s=e.imap)==null?void 0:s.port)??""):"993",smtpHost:(e==null?void 0:e.preset)==="other"?((r=e.smtp)==null?void 0:r.host)??"":"",smtpPort:(e==null?void 0:e.preset)==="other"?String(((o=e.smtp)==null?void 0:o.port)??""):"465"}},mN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},VW=e=>Object.fromEntries((e instanceof Ue?e.fields??[]:[]).map(n=>[n.field,n.message]));function YW({v2:e,writable:n,whyNot:s="sign_in"}){var q;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(fN(null)),[f,g]=p.useState(""),[y,v]=p.useState(null),[h,x]=p.useState({}),[b,j]=p.useState(null),[k,E]=p.useState(!1),[N,S]=p.useState(!1),$=p.useRef(0),_=H=>{o(H),u(fN(H))},O=()=>{const H=++$.current;e.emailAccount().then(I=>{H===$.current&&(_(I),c(null))}).catch(I=>{H===$.current&&c(mN(I))})};p.useEffect(()=>{n&&O()},[e,n]);const M=H=>{u(H),j(null)},P=H=>I=>M(V=>({...V,[H]:I.target.value})),A=()=>{const H=d.user.trim(),I=d.preset===(r==null?void 0:r.preset)&&r.imap&&r.smtp?{imap:r.imap,smtp:r.smtp}:{};return{preset:d.preset,address:d.address.trim(),...H?{user:H}:{},...f?{password:f}:{},...d.preset==="other"?{imap:{host:d.imapHost.trim(),port:Number(d.imapPort)},smtp:{host:d.smtpHost.trim(),port:Number(d.smtpPort)}}:I}},R=async(H,I)=>{v(null),x({}),S(!0);try{await I()}catch(V){const J=VW(V);Object.keys(J).length?x(J):v({title:H,error:mN(V)})}finally{S(!1)}},L=H=>{H.preventDefault(),R("The account was not saved",async()=>{_(await e.saveEmailAccount(A())),g(""),j(null)})},W=()=>R("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(A()))}),U=()=>R("The account was not removed",async()=>{E(!1),await e.removeEmailAccount(),_(KW),g(""),j(null)}),Y=t.jsxs("div",{className:fi,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Email"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The mail account your agents read, file and draft in, over IMAP and SMTP, and the account email triggers watch. Its password is sealed on this server and never shown again. Nothing is sent without asking you first."})]});if(!n)return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[Y,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:fa[s]})]})});if(!r)return i?t.jsx(jt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:O,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The email account could not be read: ",i.code,": ",i.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const D=r.configured||r.password_unreadable,G=d.preset==="other",F=(H,I,V)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(St,{label:`${I} server`,error:h[`${H}.host`],children:t.jsx(De,{name:`${H}_host`,value:H==="imap"?d.imapHost:d.smtpHost,onChange:P(H==="imap"?"imapHost":"smtpHost"),placeholder:V,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(St,{label:"Port",error:h[`${H}.port`],children:t.jsx(De,{name:`${H}_port`,inputMode:"numeric",value:H==="imap"?d.imapPort:d.smtpPort,onChange:P(H==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[Y,t.jsxs("div",{className:mi,children:[y&&t.jsx(ha,{error:y.error,title:y.title}),i&&t.jsx(jt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:O,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The email account could not be read: ",i.code,": ",i.message,". What is shown may be out of date."]})}),t.jsxs(Dr,{title:"Account",children:[t.jsxs("section",{className:"border bg-card p-4","aria-label":"Email account",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(tR,{className:"size-4 text-muted-foreground","aria-hidden":!0}),D?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:r.address}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No email account is saved. The agents' email tools and email triggers need one."}),r.configured&&t.jsx(Ne,{tone:"success",children:"saved"}),D&&r.preset&&t.jsx(Ne,{children:((q=uN.find(H=>H.value===r.preset))==null?void 0:q.label)??r.preset})]}),D&&r.imap&&r.smtp&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["IMAP ",r.imap.host,":",r.imap.port," · SMTP ",r.smtp.host,":",r.smtp.port,r.user&&r.user!==r.address?` · signs in as ${r.user}`:""]}),r.configured&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"Its password is sealed on this server. It is never shown again; type it again only to change the account."}),r.password_unreadable&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Ys,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),"Its password can't be opened here: it was sealed under another key, or is damaged. The agents can't read or send mail until it is saved again."]})]}),t.jsxs("form",{className:"space-y-4 border bg-card p-4","aria-label":"Account",onSubmit:L,children:[t.jsxs("fieldset",{disabled:N,className:"min-w-0 space-y-4",children:[t.jsx(St,{label:"Provider",group:"heading",note:qW,error:h.preset,children:t.jsx(Qo,{name:"email-preset",label:"Provider",value:d.preset,onChange:H=>M(I=>({...I,preset:H})),options:uN})}),t.jsx("p",{className:"text-small text-muted-foreground",children:BW[d.preset]}),t.jsx(St,{label:"Address",error:h.address,children:t.jsx(De,{name:"address",inputMode:"email",autoComplete:"username",spellCheck:!1,autoCapitalize:"off",placeholder:"you@example.com",value:d.address,onChange:P("address")})}),t.jsx(St,{label:"Sign-in name",optional:!0,note:"When the server's sign-in isn't the address.",error:h.user,children:t.jsx(De,{name:"user",spellCheck:!1,autoCapitalize:"off",value:d.user,onChange:P("user")})}),t.jsx(St,{label:GW(d.preset),error:h.password,children:t.jsx(De,{name:"password",type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:r.configured?"Sealed on this server: type it again to save a change":"",value:f,onChange:H=>{g(H.target.value),j(null)}})}),G&&F("imap","IMAP","imap.example.com"),G&&F("smtp","SMTP","smtp.example.com")]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",variant:"solid",disabled:N||!d.address.trim()||!f,children:"Save"}),t.jsx(B,{type:"button",variant:"outline",disabled:N||!d.address.trim()||!f&&!r.configured,onClick:()=>void W(),children:"Test"}),D&&!k&&t.jsx(B,{type:"button",variant:"outline",disabled:N,onClick:()=>E(!0),children:"Remove"})]}),k&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"The agents' email tools and email triggers stop until an account is saved again."}),t.jsx(B,{type:"button",variant:"destructive",disabled:N,onClick:()=>void U(),children:"Remove the account"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>E(!1),children:"Cancel"})]}),b&&t.jsxs("div",{"aria-label":"Test",className:"space-y-1 font-mono text-body",children:[["imap","smtp"].map(H=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Ne,{tone:b[H].ok?"success":"error",children:H==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:b[H].ok?"":"text-destructive-text",children:b[H].message})]},H)),t.jsx("p",{className:"text-small text-muted-foreground",children:b.ok?"Both signed in. Nothing was sent, and nothing was saved by the test.":"Nothing was sent, and nothing was saved by the test."})]})]})]})]})]})})}const hN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},QW={unreadable:"Its secret can't sign here: it was sealed under another key, or is damaged. Nothing is sent until the webhook is removed and set again."};function JW({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState([]),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(!1),[b,j]=p.useState(!1),[k,E]=p.useState(""),N=p.useRef(0),S=()=>{const O=++N.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([M,P])=>{O===N.current&&(s(M),o(P.attempts),c(null))}).catch(M=>{O===N.current&&c(hN(M))})};p.useEffect(S,[e]);const $=async(O,M)=>{g(null),j(!0);try{await M()}catch(P){g({title:O,error:hN(P)})}finally{j(!1)}S()},_=O=>{O.preventDefault(),$("The webhook was not saved",async()=>{const M=await e.saveWebhook(k.trim());M.signing_secret&&u(M.signing_secret);const{signing_secret:P,...A}=M;s(A)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[t.jsxs("div",{className:fi,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Webhook"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One URL this server POSTs to when a run needs its person (`run.needs_input`) and when it ends (`run.ended`), signed by the Standard Webhooks spec, so a receiver checks each message with any of that spec's libraries."})]}),t.jsxs("div",{className:mi,children:[f&&t.jsx(ha,{error:f.error,title:f.title}),i&&t.jsx(jt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:S,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",i.code,": ",i.message,". What is shown may be out of date."]})}),d&&t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Webhook secret",children:[t.jsx("p",{className:"caps text-small font-semibold text-warning-text",children:"The signing secret, shown this once"}),t.jsx("p",{className:"mt-2 break-all font-mono text-body",children:d}),t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:["Keep it where the receiver checks ",t.jsx("span",{className:"font-mono",children:"webhook-signature"}),". This server never shows it again."]}),t.jsx(B,{type:"button",variant:"outline",className:"mt-3",onClick:()=>u(null),children:"Done"})]}),t.jsx(Dr,{title:"Endpoint",children:t.jsxs("section",{className:"border bg-card p-4","aria-label":"Webhook URL",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ml,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.configured?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:n.url}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No webhook is set."}),n.configured&&(n.disabled?t.jsx(Ne,{tone:"error",children:"off"}):n.signing==="sealed"?t.jsx(Ne,{tone:"success",children:"on"}):t.jsx(Ne,{tone:"warning",children:"not signing"}))]}),n.configured&&n.disabled&&t.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",n.disabled.reason,", ",vt(n.disabled.at),". Nothing is sent until the URL is saved again: enter it below."]}),n.configured&&n.signing!=="sealed"&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Ys,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),QW[n.signing]]}),t.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:_,children:[t.jsx(De,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:n.configured?"The whole URL, to change it or save it again":"https://...",value:k,onChange:O=>E(O.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),t.jsx(B,{type:"submit",variant:"solid",disabled:b||!k.trim(),children:"Save"}),n.configured&&t.jsx(B,{type:"button",variant:"outline",disabled:b,onClick:()=>$("The test was not sent",async()=>v(await e.testWebhook())),children:"Send a test"}),n.configured&&!h&&t.jsx(B,{type:"button",variant:"outline",disabled:b,onClick:()=>x(!0),children:"Remove"})]}),h&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),t.jsx(B,{type:"button",variant:"destructive",disabled:b,onClick:()=>{x(!1),E(""),v(null),$("The webhook was not removed",async()=>{await e.removeWebhook(),s({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),u(null)})},children:"Remove the webhook"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>x(!1),children:"Cancel"})]}),y&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",pN(y)]})]})}),t.jsx(Dr,{label:"Deliveries",title:"Last deliveries",aside:t.jsx(B,{type:"button",size:"sm",onClick:S,children:"Refresh"}),children:r.length===0?t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"No message has been tried yet."}):t.jsx("ul",{className:"border",children:r.map((O,M)=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 text-body last:border-b-0",children:[t.jsx("span",{className:"w-[170px] shrink-0 text-muted-foreground",children:vt(O.at)}),t.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:O.type}),t.jsx("span",{className:O.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:pN(O)}),O.redelivery&&t.jsx(Ne,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:O.webhook_id,children:[O.webhook_id.slice(0,12),"…"]}),t.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:b,onClick:()=>$("The message was not sent again",()=>e.redeliverWebhook(O.webhook_id)),children:"Redeliver"})]},`${O.webhook_id}:${O.at}:${M}`))})})]})]})}):i?t.jsx(jt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:S,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",i.code,": ",i.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."})}function pN(e){const n=e.error??`${e.status_code}`,s=e.status_code!==null?`, ${e.latency_ms} ms`:"";return`${n}${s}${e.retry_at?`; tried again ${vt(e.retry_at)}`:""}`}const XW={none:{label:"None",gives:"The run's folder only."},sandbox:{label:"Sandbox",gives:"A Linux container."},desktop:{label:"Desktop",gives:"A screen, with a pointer and keys."},phone:{label:"Phone",gives:"A phone's screen and its apps."},browser:{label:"Browser",gives:"A browser the agent drives."}},Fx=e=>XW[e]??{label:e,gives:""},ZW=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},Ux=e=>e.slice(e.lastIndexOf(":")+1),e9=e=>e.secrets.some(n=>n.set)&&e.required.every(n=>e.secrets.some(s=>s.name===n&&s.set)),t9=2e3;function n9({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState({}),[h,x]=p.useState(new Set),b=p.useRef(0),j=p.useRef({}),k=p.useCallback(()=>{const _=++b.current;c(null),e.computers().then(O=>{_===b.current&&o(O)},O=>{_===b.current&&c(ZW(O))})},[e]);if(p.useEffect(k,[k]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:k,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Qn,{label:"Loading the computers",rows:3})});const E=new Set(r.paired.map(_=>_.id)),N=_=>r.kinds.filter(O=>O.providers.some(M=>M.id===_)).map(O=>O.kind),S=async(_,O,M)=>{g(null);try{await e.saveComputerKeys(O.id,M)}catch(P){return P instanceof Ue&&P.status===422?P:(g({at:_,words:Gt(P)}),null)}return u(null),j.current[O.id]=(j.current[O.id]??0)+1,v(P=>{const A={...P};return delete A[O.id],A}),k(),null},$=async _=>{const O=j.current[_.id]??0;x(P=>new Set(P).add(_.id));let M;try{const P=await e.testComputer(_.id);M=P.ok?{ok:!0,words:P.detail,at:new Date().toISOString()}:{ok:!1,words:P.why,at:new Date().toISOString()}}catch(P){M={ok:!1,words:Gt(P),at:new Date().toISOString()}}(j.current[_.id]??0)===O&&v(P=>({...P,[_.id]:M})),x(P=>{const A=new Set(P);return A.delete(_.id),A})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[t.jsxs("div",{className:fi,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Computers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The computers an agent can be given, and who provides them. An agent can have a kind once one of its providers is ready. Keys are kept sealed on this server and never shown again."})]}),t.jsxs("div",{className:mi,children:[t.jsx(o9,{v2:e,paired:r.paired,reload:k}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:fa[s]}),r.kinds.map(_=>t.jsx(a9,{kind:_,providers:_.providers.filter(O=>!E.has(O.id)),own:_.providers.filter(O=>E.has(O.id)).map(O=>O.name),children:_.providers.filter(O=>!E.has(O.id)).map(O=>{const M=`${_.kind}/${O.id}`;return t.jsx(i9,{v2:e,kind:_.kind,provider:O,writable:n,serves:N(O.id),tested:y[O.id],testing:h.has(O.id),open:(d==null?void 0:d.at)===M?d.mode:null,problem:(f==null?void 0:f.at)===M?f.words:null,onOpen:P=>{u(P?{at:M,mode:P}:null),g(null)},onSave:P=>S(M,O,P),onRemove:async P=>{var R;const A=await S(M,O,{[P]:null});A&&g({at:M,words:((R=A.fields)==null?void 0:R.map(L=>L.message).join(" "))||A.message})},onTest:()=>void $(O)},O.id)})},_.kind))]})]})})}function s9(e){const n=e.device?`${e.device.maker} ${e.device.model}`:null,s=e.os_version?`${e.os} ${e.os_version}`:e.os,r=e.screen?`screen ${e.screen.width}×${e.screen.height} at ${e.screen.scale}x`:null;return[e.serves.map(o=>Fx(o).label).join(", ")||Fx(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function r9(e){const n=Object.entries(e.features??{}).flatMap(([s,r])=>r!==!0&&typeof(r==null?void 0:r.off)=="string"?[`${s} off: ${r.off}`]:[]);return[`Offers ${e.groups.join(", ")}`,...n].join(" · ")}function o9({v2:e,paired:n,reload:s}){const[r,o]=p.useState(null),[i,c]=p.useState(!1),[d,u]=p.useState(()=>Date.now()),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(null),b=r?Date.parse(r.code.expires_at)-d:0,j=r!==null&&b>0;p.useEffect(()=>{if(!j)return;const S=setInterval(()=>u(Date.now()),1e3),$=setInterval(s,t9);return()=>{clearInterval(S),clearInterval($)}},[j,s]),p.useEffect(()=>{if(!r)return;const S=n.find($=>$.pairing===r.code.id);S&&(g(S.name),o(null))},[n,r]);const k=async()=>{c(!0),x(null),g(null);try{const S=await e.createPairing();u(Date.now()),o({code:S})}catch(S){x(Gt(S))}c(!1)},E=async S=>{x(null);try{await e.removeComputer(S)}catch($){x(Gt($));return}v(null),s()},N=`${Math.floor(Math.max(0,b)/6e4)}:${String(Math.floor(Math.max(0,b)%6e4/1e3)).padStart(2,"0")}`;return t.jsxs(Dr,{label:"Your computers",title:"Your computers",note:t.jsx("p",{children:"A computer or phone of your own, attached by the driver you run on it. An agent can be given it as its computer."}),aside:!r&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void k(),disabled:i,children:i?"Making…":"Pair a computer"}),f&&t.jsxs("p",{role:"status",className:"text-body text-success-text",children:["Paired ",f,"."]})]}),children:[r&&t.jsxs("div",{"data-pairing":!0,className:"space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Server address"}),t.jsx("p",{"data-address":!0,className:"mt-1 font-mono text-prose font-semibold",children:window.location.origin})]}),t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Pairing code"}),t.jsx("p",{"data-code":!0,className:"mt-1 font-mono text-2xl font-semibold",children:r.code.code})]})]}),j?t.jsxs("p",{className:"text-body",children:["Type both into the driver on the computer. The code pairs one computer, once, in the next ",t.jsx("span",{"data-countdown":!0,className:"font-mono",children:N}),"."]}):t.jsx("p",{role:"status",className:"text-body text-muted-foreground",children:"This code has expired. Make a new one."}),r.code.runs_refused&&t.jsx("p",{"data-runs-refused":!0,role:"status",className:"text-small text-warning-text",children:r.code.runs_refused}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{size:"sm",onClick:()=>void k(),disabled:i,children:i?"Making…":"New code"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>o(null),children:"Done"})]})]}),h&&t.jsx("p",{role:"alert",className:"border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:h}),n.length?t.jsx("ul",{className:"border",children:n.map(S=>t.jsxs("li",{"data-paired":S.id,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[S.serves.includes("phone")?t.jsx(u1,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(ii,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:S.name}),S.online?t.jsx(Ne,{tone:"success",children:"Online"}):t.jsx(Ne,{tone:"muted",children:"Offline"}),S.held_by_run&&t.jsxs(Ne,{tone:"active",children:["In use by run ",ca(S.held_by_run)]}),S.unserved&&t.jsx(Ne,{tone:"warning",children:"No agent can use it"}),S.runs_refused&&t.jsx(Ne,{tone:"warning",children:"No run here can use it"})]}),S.unserved&&t.jsx("p",{"data-unserved":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:S.unserved}),S.runs_refused&&t.jsx("p",{"data-runs-refused":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:S.runs_refused}),S.held_by_run&&S.held_until&&t.jsxs("p",{"data-held-until":!0,className:"mt-1.5 text-small text-muted-foreground",children:["The run's hold ends by ",vt(S.held_until),", released or not."]}),!S.online&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:"Open its driver on that computer: it dials this server."}),t.jsx("p",{"data-machine":!0,className:"mt-2 text-small text-muted-foreground",children:s9(S)}),S.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:r9(S)}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${S.driver} · paired ${vt(S.created_at)}${S.seen_at?` · last attached ${vt(S.seen_at)}`:""}`})]}),t.jsx(B,{size:"sm",onClick:()=>{v(S.id),x(null)},disabled:y!==null,children:"Remove"})]}),y===S.id&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",S.name,"? Its driver stops dialing and asks for a new code",S.held_by_run?", and the run using it loses it":"","."]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void E(S.id),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>v(null),children:"Cancel"})]})]},S.id))}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"None paired yet. Pair a computer, then type the server address and its code into the driver on it."})]})}function a9({kind:e,providers:n,own:s,children:r}){const{label:o,gives:i}=Fx(e.kind);return t.jsx(Dr,{label:o,title:o,note:(i||!e.offered||s.length>0)&&t.jsxs(t.Fragment,{children:[i&&t.jsx("p",{children:i}),!e.offered&&t.jsx("p",{children:t.jsx(Ne,{tone:"muted",children:"Not offered here"})}),!e.offered&&e.why&&t.jsx("p",{className:"font-mono text-small",children:e.why}),s.length>0&&t.jsxs("p",{className:"text-small",children:["Also served by your computers: ",s.join(", "),"."]})]}),children:n.length?t.jsx("ul",{className:"border",children:r}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:e.kind==="none"?"Nothing to set up.":s.length?"No other provider serves it on this server.":"No provider serves it on this server."})})}function i9({v2:e,kind:n,provider:s,writable:r,serves:o,tested:i,testing:c,open:d,problem:u,onOpen:f,onSave:g,onRemove:y,onTest:v}){const h=p.useRef(null),x=d&&"paste"in d?d.paste:null,b=d&&"remove"in d?d.remove:null,j=e9(s);return t.jsxs("li",{ref:h,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(ii,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:s.name}),s.ready?t.jsx(Ne,{tone:"success",children:"Ready"}):t.jsx(Ne,{children:"Not ready"}),s.runs_refused&&t.jsx(Ne,{tone:"warning",children:"No run here can use it"}),s.metered&&t.jsx("span",{"data-metered":!0,className:"text-small text-muted-foreground",children:"Metered"})]}),!s.ready&&s.why&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:s.why}),s.runs_refused&&t.jsx("p",{"data-runs-refused":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:s.runs_refused}),s.metered&&$b.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Eb}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(k=>{var S;const E=Ux(k.name),N=((S=s.picked)==null?void 0:S.includes(k.name))??!1;return t.jsx(yh,{field:k,required:s.required.includes(k.name),writable:r&&!d,actionsInline:!0,onPaste:N?void 0:()=>void bh(()=>f({paste:E}),()=>{var $,_;return(_=($=h.current)==null?void 0:$.querySelector("form"))==null?void 0:_.elements.namedItem(E)}),onRemove:()=>f({remove:E})},k.name)})}),s.picked&&s.picked.length>0&&s.required.every(k=>s.secrets.some(E=>E.name===k&&E.set))&&t.jsx(l9,{v2:e,provider:s,writable:r&&!d,onSave:g}),j&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(B,{size:"sm",onClick:v,disabled:c,children:c?"Testing…":"Test connection"}),i&&t.jsx("p",{"data-test":!0,className:`text-small ${i.ok?"text-success-text":"text-destructive-text"}`,children:`${i.ok?"Passed":"Failed"} · ${ti(i.at)} · ${i.words}`})]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",o.join(", ")]})]})]}),r&&x&&t.jsx(c9,{provider:s.name,name:x,set:s.secrets.some(k=>Ux(k.name)===x&&k.set),onSave:g,onCancel:()=>f(null)}),r&&b&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",b," saved on this server?"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void y(b),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>f(null),children:"Cancel"})]}),u&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:u})]})}function l9({v2:e,provider:n,writable:s,onSave:r}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(null),g=n.secrets.map(v=>`${v.name}:${v.set}:${v.changed_at??""}`).join(" ");p.useEffect(()=>{let v=!0;return i(null),d(null),e.computerChoices(n.id).then(h=>{v&&i(h)},h=>{v&&d(Gt(h))}),()=>{v=!1}},[e,n.id,g]);const y=async(v,h)=>{var b;f({key:v.key,value:h}),d(null);const x=await r({[v.key]:h});f(null),x&&d(((b=x.fields)==null?void 0:b.map(j=>j.message).join(" "))||x.message)};return c&&!o?t.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${c}`}):o?t.jsxs("div",{className:"mt-3 space-y-3",children:[o.choices.map(v=>{const h=n.secrets.find(b=>Ux(b.name)===v.key),x=(h==null?void 0:h.source)==="env";return t.jsxs("div",{"data-choices":v.key,className:"border bg-card p-3",children:[t.jsx("p",{className:"caps mb-2 text-small font-semibold",children:v.key}),"why"in v?t.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:v.why}):t.jsxs(t.Fragment,{children:[t.jsx(Mt,{label:`${n.name} ${v.key}`,value:(u==null?void 0:u.key)===v.key?u.value:v.saved??"",disabled:!s||x||u!==null,options:v.options.map(b=>({value:b.value,label:b.label})),placeholder:"Pick one",onChange:b=>void y(v,b),className:"w-full max-w-md"}),t.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${h!=null&&h.set&&v.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:x?`Set in the environment where AgentRun starts, and that one is used: change ${v.key} there.`:v.saved!==void 0?"Picked and saved on this server.":h!=null&&h.set?`The ${v.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:v.options.length===1?`The only one, ${v.options[0].label}, is used while none is picked.`:`${v.options.length} to pick from. Pick the one this server's computers use.`})]})]},v.key)}),c&&t.jsx("p",{role:"alert",className:"font-mono text-small text-destructive-text",children:c})]}):t.jsx("p",{role:"status",className:"mt-3 text-small text-muted-foreground",children:"Reading the choices…"})}function c9({provider:e,name:n,set:s,onSave:r,onCancel:o}){const i=p.useRef(null),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[g,y]=p.useState(null),v=()=>{var b,j;return((j=(b=i.current)==null?void 0:b.elements.namedItem(n))==null?void 0:j.value)??""},h=()=>{var b;(b=i.current)==null||b.reset(),d(!1)},x=async b=>{var S;b.preventDefault();const j=v();if(!j)return;f(!0),y(null);const k=await r({[n]:j});if(f(!1),!k){h();return}const E=(S=k.fields)==null?void 0:S.find($=>$.field===n),N=(k.fields??[]).filter($=>$.field!==n).map($=>$.message);y(E?{field:E.message,message:N.join(" ")}:{field:null,message:N.join(" ")||k.message})};return t.jsxs("form",{ref:i,autoComplete:"off",onSubmit:b=>void x(b),onInput:()=>d(!!v()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e} ${n}`,children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:n}),s&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"A new value replaces the one saved."}),t.jsx(De,{type:"password",name:n,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(g==null?void 0:g.field)&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:g.field})]}),(g==null?void 0:g.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g.message}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Kept sealed on this server. It is never shown again, here or anywhere."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!c||u,children:u?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{h(),o()},children:"Cancel"})]})]})}const d9="Each agent keeps its runs' folders on its own Archil disk, made on its first run in this region. The server never mounts one; computers that support it mount a run's folder.",gN=[{name:"region",label:"Region"},{name:"s3Url",label:"S3 URL",placeholder:"https://"},{name:"image",label:"Image",placeholder:"serve's default, Debian with git 2.47 (recommended)"}],u9=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),Tr="ARCHIL_API_KEY",f9=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function m9({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState({region:"",s3Url:"",image:""}),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(!1),[b,j]=p.useState(null),[k,E]=p.useState(!1),[N,S]=p.useState(!1),[$,_]=p.useState(!1),[O,M]=p.useState(!1),P=p.useRef(null),A=p.useRef(0),R=p.useCallback(F=>{o(F),u(u9(F))},[]),L=p.useCallback(()=>{const F=++A.current;c(null),e.archil().then(q=>{F===A.current&&R(q)},q=>{F===A.current&&c(f9(q))})},[e,R]);if(p.useEffect(L,[L]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:L,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Qn,{label:"Loading Archil's settings",rows:2})});const W=()=>{var F,q;return((q=(F=P.current)==null?void 0:F.elements.namedItem(Tr))==null?void 0:q.value)??""},U=async F=>{const q={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...F!==void 0?{keys:{[Tr]:F}}:{}};x(!0),g(null),v(null);try{const H=await e.saveArchil(q);_(!1),M(!1),R(H)}catch(H){if(H instanceof Ue&&H.status===422){const I={},V=[];for(const J of H.fields??[]){const X=J.field.startsWith("keys.")?J.field.slice(5):J.field;gN.some(re=>re.name===X)||X===Tr?I[X]=J.message:V.push(J.message)}g({fields:I,message:V.length?V.join(" "):Object.keys(I).length?null:H.message})}else v(Gt(H))}finally{x(!1)}},Y=F=>{F.preventDefault(),U($&&W()?W():void 0)},D=async()=>{E(!0);try{const F=await e.testArchil();j(F.ok?{ok:!0,words:F.detail,at:new Date().toISOString()}:{ok:!1,words:F.why,at:new Date().toISOString()})}catch(F){j({ok:!1,words:Gt(F),at:new Date().toISOString()})}finally{E(!1)}},G=async()=>{v(null);try{R(await e.archilOff()),S(!1)}catch(F){v(Gt(F))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:ta,children:[t.jsxs("div",{className:fi,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Workspace"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:d9})]}),t.jsxs("div",{className:mi,children:[!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:fa[s]}),t.jsx(Dr,{title:"Disk",children:t.jsxs("section",{"aria-label":"Archil",className:"border p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(JT,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),t.jsx("span",{"data-archil-state":!0,children:r.on?t.jsx(Ne,{tone:"success",children:"On"}):t.jsx(Ne,{children:"Off"})}),r.on&&t.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:r.region??""}),t.jsx("span",{className:"flex-1"}),t.jsx(B,{size:"sm",onClick:()=>void D(),disabled:k,children:k?"Testing…":"Test"}),r.on&&t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>S(!0),children:"Turn off"})]}),b&&t.jsx("p",{"data-test":!0,className:`mt-3 text-small ${b.ok?"text-success-text":"text-destructive-text"}`,children:`${b.ok?"Passed":"Failed"} · ${ti(b.at)} · ${b.words}`}),N&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void G(),children:"Turn off"}),t.jsx(B,{size:"sm",onClick:()=>S(!1),children:"Cancel"})]}),y&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:y}),t.jsxs("form",{ref:P,autoComplete:"off",onSubmit:Y,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[gN.map(F=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:F.label}),t.jsx(De,{name:F.name,value:d[F.name],placeholder:F.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:q=>{const H=q.currentTarget.value;u(I=>({...I,[F.name]:H}))}}),(f==null?void 0:f.fields[F.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[F.name]})]},F.name)),t.jsx("ul",{children:t.jsx(yh,{field:r.secret,label:Tr,writable:n&&!$&&!O,onPaste:()=>void bh(()=>_(!0),()=>{var F;return(F=P.current)==null?void 0:F.elements.namedItem(Tr)}),onRemove:()=>M(!0)})}),n&&O&&t.jsxs("div",{"data-confirm-key":!0,className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",Tr," saved on this server?"]}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:()=>void U(null),children:"Remove"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>M(!1),children:"Cancel"})]}),n&&$&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:Tr}),t.jsx(De,{type:"password",name:Tr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(f==null?void 0:f.fields[Tr])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[Tr]})]}),n&&$&&t.jsx(B,{type:"button",size:"sm",onClick:()=>_(!1),children:"Cancel"}),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:h,children:h?"Saving":r.on?"Save":"Turn on"})]})]})})]})]})})}const p$="tool_approval_requested";function h9(e){var n;return e.status!=="input_required"||e.state!=="waiting"?null:((n=e.pending)==null?void 0:n.kind)==="approval"?e.pending:null}function p9(e){return e==="not metered"?"Not metered":e==="priced by usage"?"Priced by usage: monid estimates the cost when the call runs, and can charge more.":e===0?"Costs nothing per call":typeof e=="number"?`Costs ${_d(e)} per call`:null}function g9(e){let n;try{n=JSON.parse(e)}catch{return e}return!n||typeof n!="object"||Array.isArray(n)?JSON.stringify(n,null,2):Object.entries(n).map(([s,r])=>`${s}: ${typeof r=="string"?r:JSON.stringify(r)}`).join(`
691
+ `)}const x9={allow:"This call was already allowed, in another tab or by another answer. The run shows what happened next.",deny:"This call was already declined. The run shows what happened next.",withdrawn:"The run was stopped before this call ran, so it was withdrawn and never ran.",canceled:"The run was cancelled before this call ran, so it never ran."};function g$(e){var n;if(e instanceof Ue){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?x9[e.details.decision]:void 0;if(e.status===409&&s)return s;if(e.status===403)return"Only the owner, signed in with the password on this page, can answer an approval.";if(e.status===401)return"Your sign-in ended. Sign in again to answer.";if(e.status===404)return"This run no longer waits on that call."}return Gt(e)}const v9=2e3;function x$({pending:e,onAnswer:n,compact:s=!1,heading:r}){const[o,i]=p.useState(""),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(!1),x=e.destructive===!0,b=p.useRef(!1),j=p.useRef(null),k=p.useRef(!1);p.useEffect(()=>{var S;v||!k.current||(k.current=!1,(S=j.current)==null||S.focus())},[v]);const E=p9(e.price),N=async(S,$)=>{if(b.current)return;b.current=!0,d(!0),f(null),h(!1);const _=o.trim(),O=await($?n(S,void 0,$):n(S,S==="deny"&&_?_:void 0));b.current=!1,d(!1),O?f(O):y(S)};return t.jsxs("section",{"aria-label":"Approval required",className:te("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,t.jsxs("p",{className:te("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[t.jsx(d1,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),t.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",t.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),".",x&&t.jsxs(t.Fragment,{children:[" ",t.jsx(Ne,{tone:"error",title:"Its server marks this tool destructive: it may delete or overwrite.",children:"Destructive"})]})]}),t.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:te("mt-2 overflow-auto whitespace-pre-wrap break-all border bg-card p-3 font-mono text-small leading-[1.6]",s?"max-h-28":"max-h-64"),children:g9(e.args_preview)}),E&&t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:E}),g?t.jsx("p",{className:"mt-3 font-mono text-body text-success-text",role:"status",children:g==="allow"?"Allowed. The run goes on.":"Denied. The agent reads why and goes on."}):t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),t.jsx(on,{value:o,onChange:S=>i(S.target.value),maxLength:v9,rows:s?1:2,disabled:c,className:"mt-1 block resize-y py-2 font-sans text-lead"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{ref:j,type:"button",variant:"solid",size:"sm",disabled:c||v,onClick:()=>x?h(!0):void N("allow"),children:"Allow once"}),t.jsx(B,{type:"button",size:"sm",disabled:c,onClick:()=>void N("deny"),children:"Deny"}),c&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),v&&t.jsx(b9,{tool:e.tool,onAllow:()=>void N("allow",!0),onBack:()=>{k.current=!0,h(!1)}}),!s&&t.jsx("p",{className:"text-small text-muted-foreground",children:"or type what to do instead; sending it declines this call"}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u})]})]})}function b9({tool:e,onAllow:n,onBack:s}){const r=p.useRef(null);return p.useEffect(()=>{var o;(o=r.current)==null||o.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e}?`,onKeyDown:o=>{o.key==="Escape"&&(o.stopPropagation(),s())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive call?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite."]}),t.jsx(B,{ref:r,type:"button",size:"sm",variant:"ghost",onClick:s,children:"Back"}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:n,children:"Allow this destructive call"})]})}const y9={steer:{label:"Steer the run",placeholder:"Steer the run...",does:"The agent reads it when its current step ends."},answer:{label:"Answer the question",placeholder:"Answer the question...",does:"Answers what the agent asked; the run goes back to work."},follow_up:{label:"Ask a follow-up",placeholder:"Ask a follow-up question...",does:"Continues this run with your message; the same spend cap applies."}};function w9({mode:e,onSend:n,sending:s,sent:r,purpose:o}){const i=o??y9[e],[c,d]=p.useState(""),[u,f]=p.useState(!1),g=s||u,y=async()=>{if(!c.trim()||!n||g)return;f(!0);const v=await n(c.trim());f(!1),v!==!1&&d("")};return t.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:v=>{v.preventDefault(),y()},children:[t.jsx(on,{bare:!0,id:"composer",rows:2,value:c,readOnly:g,"aria-busy":g,onChange:v=>d(v.target.value),placeholder:i.placeholder,onKeyDown:v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),y())},className:"block w-full resize-none px-4 pt-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[t.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[t.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:i.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":i.does]}),t.jsxs(B,{type:"submit",size:"sm",disabled:!c.trim()||!n||g,children:[g?"Sending":"Send"," ",t.jsx(qT,{"aria-hidden":!0})]})]})]})}function no(e){if(Number.isInteger(e))return`$${e}`;for(let n=2;n<8;n++)if(Number(e.toFixed(n))===Number(e.toFixed(8)))return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}const v$=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${no(e.cap_usd)} `:""}spend cap`;function j9({pending:e}){return t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Paused at its spend cap",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[t.jsx(ev,{className:"size-3.5","aria-hidden":!0})," ",v$(e)]}),typeof e.said=="string"&&t.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:e.said}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"It waits for its cap to be raised; a message can't go on until then."})]})}const b$=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,y$=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function k9(e){var n,s;return e instanceof Ue?e.status===422?((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message:e.status===409?"This run has ended, so its cap can't be raised.":e.status===404?"This run is no longer on the server.":e.message:e instanceof Error?e.message:String(e)}function w$({cap:e,suggested:n,least:s=null,paused:r,onRaise:o}){const[i,c]=p.useState(n===null?"":String(n)),[d,u]=p.useState(!1),[f,g]=p.useState(null),[y,v]=p.useState(null),h=p.useRef(!1),x=Number(i),b=i.trim()!==""&&Number.isFinite(x)&&x>0,j=async k=>{if(k==null||k.preventDefault(),!(!b||h.current)){h.current=!0,u(!0),g(null),v(null);try{const E=await o(x);E.note&&v(E.note)}catch(E){g(k9(E))}finally{h.current=!1,u(!1)}}};return t.jsxs("form",{className:"border border-warning/50 p-4","aria-label":"Raise the cap",onSubmit:k=>void j(k),children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:"flex items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"$"}),t.jsx(De,{"aria-label":"New cap in dollars",inputMode:"decimal",value:i,onChange:k=>c(k.target.value),disabled:d,placeholder:`more than ${no(e)}`,className:"h-9 w-32"})]}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:d||!b,children:d?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||n!==null)&&t.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&t.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",no(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",no(n)]})]}),n!==null&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),f&&t.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:f}),y&&t.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:y})]})}function N9({waiting:e}){if(e){const n=(e.text??e.summary??"").replace(/^Waiting for you:\s*/,"");return t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"The agent asks",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[t.jsx(nv,{className:"size-3.5","aria-hidden":!0})," Input required"]}),t.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:n})]})}return t.jsxs("section",{className:"border border-border-strong/60 p-4","aria-label":"Stopped",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(fl,{className:"size-3.5","aria-hidden":!0})," Stopped"]}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The turn was stopped. The run stays open: send a message to continue it."})]})}let cl=0;const Wx=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},xN=e=>{cl=e,history.replaceState({...history.state??{},console_at:e},"")};function S9(){const e=Wx();e===void 0?xN(0):cl=e;const n=()=>{const s=Wx();s===void 0?xN(cl+1):cl=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function C9(){const e=Wx();return e===void 0?-1:cl-e}function E9(e){cl>0?history.back():location.hash=e}const $9=(e,n)=>{const s=ui(e),r=xl(e),o=r?jL(r):void 0;return s?o?`${Dk(s,{ended:n})} ${o}`:Dk(s,{ended:n}):e&&e.usd!==null&&Pv(e)?o?`A local estimate, not a bill. ${o}`:"A local estimate, not a bill":o};function _9({run:e,agentName:n,actions:s={},costText:r}){var N,S,$,_;const o=os(e),i=o?"your backend":zP(e.place),c=nh(e.status,e.state,e.kind,th,!0,e.error,e.review,e.computer),d=o?{...c,canStop:!1,canCancel:!1}:c,[u,f]=p.useState(!1),g=!!e.archived_at,y=(N=e.cost)==null?void 0:N.cap_usd,v=!!e.pending&&e.pending.kind!=="budget"&&e.pending.kind!=="stopped",h=!o&&!!s.onRaiseCap&&!d.final&&typeof y=="number"&&!v,[x,b]=p.useState(!1),j=((S=e.pending)==null?void 0:S.kind)==="budget"?e.pending:null,k=!!xl(e.cost),E=k&&(($=xl(e.cost))==null?void 0:$.on)!=="claude_code";return t.jsxs("header",{children:[t.jsxs("nav",{className:te(vr,"caps min-w-0 gap-2 px-5 text-label text-muted-foreground md:px-8"),"aria-label":"Breadcrumb",children:[t.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>E9(Cn(e.agent_id)),className:"-m-1.5 shrink-0 p-1.5 hover:text-foreground",children:t.jsx(Fn,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:Cn(e.agent_id),className:"-my-1 truncate py-1 hover:text-foreground hover:underline",children:n}),t.jsx("span",{"aria-hidden":!0,children:"/"}),t.jsxs("span",{className:"truncate",children:["Run ",ca(e.run_id)]})]}),t.jsxs("div",{"data-title-block":!0,className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[t.jsxs("div",{"data-phone-row":!0,className:"flex flex-col items-start gap-x-6 gap-y-3 max-sm:mt-2 max-sm:flex-row max-sm:flex-wrap max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-2 sm:flex-row sm:flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[t.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:On(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:On(e)}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-small text-muted-foreground max-sm:contents",children:[t.jsx(Ll,{run:e}),g&&t.jsx(Ne,{tone:"muted",children:"Archived"}),e.approvals==="never"&&t.jsx(Ne,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),t.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,i&&` · ${i}`]}),o&&t.jsxs("span",{className:"font-mono",children:[sa(o.runtime)," · ",((_=e.sdk)==null?void 0:_.model)??"Model not reported"]}),t.jsx("span",{className:"font-mono",children:vt(e.created_at)}),r!==void 0&&!k?t.jsx("span",{className:"font-mono",title:"The run's decisions and model calls, as the providers priced them",children:Fk(e.cost,y,{text:r})}):t.jsxs("span",{className:"font-mono",title:$9(e.cost,lo(e.status)),children:[Fk(e.cost,y,{ended:lo(e.status)}),E&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(Tb,{})]})]}),t.jsx(Nb,{run:e,link:!0}),t.jsx(l$,{run:e})]}),e.status==="completed"&&e.review&&t.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(d.canStop||d.canCancel||s.onArchive||h)&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[h&&t.jsxs(B,{size:"sm",onClick:()=>b(O=>!O),"aria-expanded":x,title:`Raise its ${no(y)} spend cap.`,children:[t.jsx(ev,{"aria-hidden":!0})," Raise the cap"]}),d.canStop&&t.jsxs(B,{size:"sm",onClick:s.onStop,disabled:!s.onStop||!!s.busy,title:e.native?"Stop this native turn. Start a new run for another task.":"End this turn. The run stays open and waits for your next message.",children:[t.jsx(mR,{"aria-hidden":!0})," ",s.busy==="stop"?"Stopping":"Stop"]}),d.canCancel&&!u&&t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>f(!0),disabled:!s.onCancel||!!s.busy,title:"End the run for good.",children:[t.jsx(ZN,{"aria-hidden":!0})," ",s.busy==="cancel"?"Cancelling":"Cancel run"]}),u&&t.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Cancel this run?",children:[t.jsx("span",{children:"Cancel for good?"}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>{var O;f(!1),(O=s.onCancel)==null||O.call(s)},children:"Yes, cancel"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>f(!1),children:"Keep"})]}),s.onArchive&&t.jsxs(B,{size:"sm",onClick:s.onArchive,disabled:!!s.busy,title:g?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[g?t.jsx(XN,{"aria-hidden":!0}):t.jsx(xd,{"aria-hidden":!0})," ",s.busy==="archive"?g?"Unarchiving":"Archiving":g?"Unarchive":"Archive"]})]})]}),h&&x&&t.jsx("div",{className:"mt-3 max-w-xl",children:t.jsx(w$,{cap:y,suggested:b$(j),least:y$(j),paused:!!j,onRaise:s.onRaiseCap},j?`${e.run_id}:${j.at}`:`${e.run_id}:working`)})]})]})}const T9=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function R9({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:T9.map(s=>t.jsxs("label",{className:te("caps -ml-px cursor-pointer border px-3 py-1.5 text-label first:ml-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:outline-offset-2",e===s.id?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[t.jsx("input",{type:"radio",name:"file-view",value:s.id,checked:e===s.id,onChange:()=>n(s.id),className:"sr-only"}),s.label]},s.id))})}const j$=(e,n)=>n?e:e.filter(s=>!J2(s.path));function A9({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const o=e.filter(d=>J2(d.path)).length,i=j$(e,s),c=i.reduce((d,u)=>d+u.size_bytes,0);return t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center gap-3",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(YT,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",gr(c),")"]}),o>0&&t.jsxs("button",{type:"button",className:"caps ml-auto text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline","aria-pressed":s,onClick:()=>r(!s),children:[s?"Hide":"Show"," ",o," hidden"]})]}),i.length===0?t.jsx("p",{className:"border px-4 py-8 text-center font-mono text-body text-muted-foreground",children:o?`Only files in hidden folders (${o}).`:"This run wrote no files."}):t.jsx("ul",{className:"border",children:i.map(d=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("button",{type:"button",onClick:()=>n(d),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-accent",children:[t.jsx(ai,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:d.path}),t.jsx("span",{className:"hidden font-mono text-label text-muted-foreground sm:inline",children:vt(d.modified_at)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:gr(d.size_bytes)})]})},d.path))})]})}function O9({file:e,text:n,onClose:s,files:r=[],onOpen:o}){const[i,c]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>{var k;const b=document.activeElement,j=d.current;return j&&!j.open&&((k=j.showModal)==null||k.call(j)),()=>{var E;j!=null&&j.open&&j.close(),(E=b==null?void 0:b.focus)==null||E.call(b)}},[]),p.useEffect(()=>c(!1),[e.path]);const u=p.useRef(!1),f=p.useRef(!1),g=xP(e),[y,v]=p.useState(g==="markdown"?"rendered":"raw");p.useEffect(()=>v(g==="markdown"?"rendered":"raw"),[e.path]);const h=Iv(b=>{const j=r.find(k=>k.path===b);j&&(o==null||o(j))}),x=()=>{if(n===null)return;const b=URL.createObjectURL(new Blob([n],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:b,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(b)};return t.jsx("dialog",{ref:d,"aria-label":e.path,onCancel:b=>{b.preventDefault(),s()},onMouseDown:b=>{u.current=b.target===b.currentTarget},onMouseUp:b=>{f.current=b.target===b.currentTarget},onClick:b=>{u.current&&f.current&&b.target===b.currentTarget&&s(),u.current=f.current=!1},className:"m-0 h-full max-h-none w-full max-w-none border-0 bg-transparent p-0 text-foreground backdrop:bg-overlay/60 md:p-8",children:t.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[t.jsx(B,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:t.jsx(uo,{"aria-hidden":!0})}),t.jsx(ai,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:e.path}),g!=="download"&&t.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:t.jsx(R9,{view:y,onView:v})}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:async()=>{var b;n!==null&&(await((b=navigator.clipboard)==null?void 0:b.writeText(n)),c(!0))},children:[t.jsx(oi,{"aria-hidden":!0})," ",i?"Copied":"Copy"]}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:x,children:[t.jsx(tv,{"aria-hidden":!0})," Download"]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:n===null?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):g==="download"?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."}):y==="rendered"?t.jsx("article",{className:"report mx-auto max-w-3xl",onClick:h,dangerouslySetInnerHTML:{__html:Ko(n,o&&{paths:r.map(b=>b.path),from:e.path.split("/").slice(0,-1).join("/")})}}):t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:n})}),t.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",n===null?"...":`${n.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function M9(e){const n=e.replace(/\r\n?/g,`
692
+ `).trim(),s=c=>{try{const d=JSON.parse(c);return d&&typeof d=="object"&&!Array.isArray(d)?d:null}catch{return null}},r=n.split(`
693
+ `);let o;for(let c=0;c<r.length;c++){const d=/^ {0,3}(`{3,}|~{3,})([^`]*)$/.exec(r[c]);if(!d)continue;const u=d[1],f=new RegExp(`^ {0,3}${u[0]==="`"?"`":"~"}{${u.length},}\\s*$`),g=r.findIndex((v,h)=>h>c&&f.test(v));if(g<0)break;const y=d[2].trim().toLowerCase();o=y==="json"||y===""?{open:c,end:g}:void 0,c=g}if(o&&o.end===r.length-1){const c=s(r.slice(o.open+1,o.end).join(`
694
+ `));return c?{words:r.slice(0,o.open).join(`
695
+ `).trim(),record:c}:null}const i=s(n);if(i)return{words:"",record:i};for(let c=n.lastIndexOf(`
696
+ {`);c>=0;c=n.lastIndexOf(`
697
+ {`,c-1)){const d=s(n.slice(c+1));if(d)return{words:n.slice(0,c).trim(),record:d};if(c===0)break}return null}const L9=e=>e.replace(/[_-]+/g," ").trim()||e,Ac=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function wm(e,n){let s=Ac(e);for(let r=0;s&&typeof s.$ref=="string"&&s.$ref.startsWith("#")&&r<8;r++){const o=s.$ref.slice(1).split("/").filter(Boolean).map(f=>decodeURIComponent(f).replaceAll("~1","/").replaceAll("~0","~")),{$ref:i,...c}=s,d=Ac(o.reduce((f,g)=>{var y;return(y=Ac(f))==null?void 0:y[g]},n))??{},u=d.properties||c.properties?{...Ac(d.properties),...Ac(c.properties)}:void 0;s={...d,...c,...u?{properties:u}:{}}}return s}const P9=(e,n)=>{var s;return((s=wm(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function Vb({value:e,schema:n,root:s,linked:r}){var o;if(e==null)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"—"});if(Array.isArray(e)){if(!e.length)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"none"});const i=(o=wm(n,s))==null?void 0:o.items;return t.jsx("ul",{"data-json":"array",className:"list-disc space-y-1 pl-5",children:e.map((c,d)=>t.jsx("li",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:t.jsx(Vb,{value:c,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(k$,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&P9(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:Ko(e,r)}}):t.jsx("span",{"data-json-value":!0,className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:String(e)})}function k$({record:e,schema:n,root:s,linked:r}){var i;const o=(i=wm(n,s))==null?void 0:i.properties;return t.jsx("dl",{"data-json":"object",className:"min-w-0 space-y-3 border-l pl-4",children:Object.entries(e).map(([c,d])=>{var g;const u=o==null?void 0:o[c],f=(g=wm(u,s))==null?void 0:g.title;return t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"caps break-words [overflow-wrap:anywhere] text-label text-muted-foreground",children:typeof f=="string"&&f.trim()?f:L9(c)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx(Vb,{value:d,schema:u,root:s,linked:r})})]},c)})})}function vN({record:e,schema:n,linked:s}){const[r,o]=p.useState(!1);return t.jsxs("section",{className:"min-w-0 space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{type:"button",size:"xs",onClick:()=>o(i=>!i),children:r?"Show fields":"Show raw JSON"})}),r?t.jsx("pre",{"aria-label":"The answer's JSON",className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(e,null,2)}):t.jsx("div",{"aria-label":"The answer's fields",className:"min-w-0 [&>dl]:border-l-0 [&>dl]:pl-0",children:t.jsx(k$,{record:e,schema:n,root:n,linked:s})})]})}function I9({value:e,schema:n,linked:s}){return t.jsx("div",{"aria-label":"The answer's value",className:"min-w-0 text-prose leading-relaxed",children:t.jsx(Vb,{value:e,schema:n,root:n,linked:s})})}function z9({run:e,rows:n,files:s=[],onOpen:r,schema:o}){var y,v,h,x,b;const i=((y=e.result)==null?void 0:y.final_answer)??((v=n.findLast(j=>j.kind==="final_answer"))==null?void 0:v.text)??null,c=r?{paths:s.map(j=>j.path)}:void 0,d=Iv(j=>{const k=s.find(E=>E.path===j);k&&(r==null||r(k))}),u=(h=e.result)==null?void 0:h.output;if(e.kind==="agentic"&&u!==void 0&&u!==null)return t.jsx("div",{className:"min-w-0",onClick:d,children:typeof u=="object"&&!Array.isArray(u)?t.jsx(vN,{record:u,schema:o,linked:c}):t.jsx(I9,{value:u,schema:o,linked:c})});const f=e.kind==="agentic"?(x=e.result)==null?void 0:x.output_error:void 0,g=f?t.jsx(jt,{tone:"warning",title:"The answer did not match the output schema",children:f}):null;if(i!=null&&i.trim()){const j=M9(i);return j?t.jsxs("div",{className:"min-w-0 space-y-6",children:[g,j.words&&t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:Ko(j.words,c)}}),t.jsx(vN,{record:j.record})]}):t.jsxs("div",{className:"min-w-0 space-y-6",children:[g,t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:Ko(i,c)}})]})}if(g)return g;if(((b=e.result)==null?void 0:b.output)!==void 0&&e.result.output!==null){const j=e.result.output,k=j&&typeof j=="object"&&!Array.isArray(j)?Object.entries(j).filter(N=>typeof N[1]=="string"&&N[1].includes(`
698
+ `)&&N[1].length>80):[],E=k.length?Object.fromEntries(Object.entries(j).filter(([N])=>!k.some(([S])=>S===N))):j;return t.jsxs("div",{className:"space-y-8",children:[k.map(([N,S])=>t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:N.replace(/_/g," ")}),t.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:d,dangerouslySetInnerHTML:{__html:Ko(S,c)}})]},N)),(!k.length||Object.keys(E).length>0)&&t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:k.length?"The rest of the output":"Output"}),t.jsx("pre",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(E,null,2)})]})]})}return null}const vs=e=>Date.parse(e);function hn(e,n){return e.ended_at?Math.max(0,vs(e.ended_at)-vs(e.started_at)):n!==void 0&&(e.status==="running"||e.status==="waiting")?Math.max(0,n-vs(e.started_at)):null}function Dn(e){if(e<1e3)return`${Math.round(e)} ms`;if(e<6e4)return`${(e/1e3).toFixed(1)} s`;const n=Math.round(e/1e3);return n<3600?`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(n/3600)}h ${String(Math.floor(n%3600/60)).padStart(2,"0")}m`}function hd(e){const n=Math.max(0,e);if(n>=36e5){const r=Math.floor(n/1e3);return`+${Math.floor(r/3600)}:${String(Math.floor(r%3600/60)).padStart(2,"0")}:${String(r%60).padStart(2,"0")}`}const s=Math.floor(n/100);return`+${Math.floor(s/600)}:${String(Math.floor(s%600/10)).padStart(2,"0")}.${s%10}`}const ur=e=>e.input+e.cache_read+e.cache_write,Qd=e=>{const n=e.input+e.cache_read+e.cache_write;return n>0?e.cache_read/n:null},$s=e=>e>0&&e<.005?"<1%":`${e>=.995&&e<1?"99":Math.round(e*100)}%`;function Yb(e,n){if(!e.length)return{from:n,to:n,ms:0};let[s,r]=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const o of e){const i=vs(o.started_at);s=Math.min(s,i),r=Math.max(r,i+(hn(o,n)??0))}return{from:s,to:r,ms:Math.max(0,r-s)}}function bN(e,n,s,r=.2){const o=[];return{bars:[...e].sort((c,d)=>vs(c.started_at)-vs(d.started_at)).map(c=>{const d=n.ms>0?(vs(c.started_at)-n.from)/n.ms*100:0,u=n.ms>0?(hn(c,s)??0)/n.ms*100:100;let f=o.findIndex(g=>g+r<=d);return f<0&&(f=o.push(0)-1),o[f]=d+u,{span:c,left:d,width:u,row:f}}),rows:Math.max(1,o.length)}}const D9=[100,200,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4,12e4,3e5,6e5,9e5,18e5,36e5,72e5,144e5,288e5,864e5];function F9(e,n=8){if(e<=0)return[{left:0,label:"0:00"}];const s=D9.find(i=>e/i<=n)??Math.ceil(e/n/864e5)*864e5,r=i=>{if(s<1e3)return`${(i/1e3).toFixed(1)}s`;const c=Math.round(i/1e3);return c>=3600?`${Math.floor(c/3600)}:${String(Math.floor(c%3600/60)).padStart(2,"0")}:${String(c%60).padStart(2,"0")}`:`${Math.floor(c/60)}:${String(c%60).padStart(2,"0")}`},o=[];for(let i=0;i<=e;i+=s)o.push({left:i/e*100,label:r(i)});return o}function yN(e,n){const s=e.map(i=>[vs(i.started_at),vs(i.started_at)+(hn(i,n)??0)]).sort((i,c)=>i[0]-c[0]);let[r,o]=[0,Number.NEGATIVE_INFINITY];for(const[i,c]of s)c<=o||(r+=c-Math.max(i,o),o=c);return r}const Qc=e=>({usd:e.reduce((n,s)=>n+(s??0),0),unknown:e.filter(n=>n===null).length}),N$=e=>e.reduce((n,{tokens:s})=>s?{input:n.input+s.input,cache_read:n.cache_read+s.cache_read,cache_write:n.cache_write+s.cache_write,output:n.output+s.output,reasoning:n.reasoning+(s.reasoning??0)}:n,{input:0,cache_read:0,cache_write:0,output:0,reasoning:0});function Qb(e,n){const s=e.spans.filter(u=>u.kind==="model"),r=e.spans.filter(u=>u.kind==="tool"),o=Yb(e.spans,n),[i,c]=[yN(e.spans,n),yN(s,n)],d=r.filter(u=>u.charged);return{requests:s.length,calls:r.length,failed:e.spans.filter(u=>u.status==="failed").length,tokens:s.length?N$(s):null,untold:s.filter(u=>!u.tokens).length,cost:{requests:s.length?e.model_requests==="priced"?Qc(s.map(u=>u.usd)):s.some(u=>u.decision)?Qc(s.filter(u=>u.decision).map(u=>u.usd)):null:null,charges:Qc(d.map(u=>u.usd)),charged:d.length,notMetered:r.filter(u=>u.not_metered).length},time:{wall:o.ms,model:c,tools:Math.max(0,i-c),other:Math.max(0,o.ms-i)}}}const jm=(e,n)=>e.length?e[Math.min(e.length-1,Math.max(0,Math.ceil(n*e.length)-1))]:null;function U9(e,n){const s=new Map;for(const r of e)r.kind==="tool"&&s.set(r.name,[...s.get(r.name)??[],r]);return[...s].map(([r,o])=>{const i=o.map(d=>hn(d,n)).filter(d=>d!==null).sort((d,u)=>d-u),c=o.filter(d=>d.charged);return{name:r,calls:o.length,failed:o.filter(d=>d.status==="failed").length,totalMs:i.reduce((d,u)=>d+u,0),p50:jm(i,.5),p95:jm(i,.95),maxMs:i.at(-1)??null,charges:Qc(c.map(d=>d.usd)),charged:c.length,bytes:o.reduce((d,u)=>d+(u.result_size_bytes??0),0)}}).sort((r,o)=>o.totalMs-r.totalMs||o.calls-r.calls||r.name.localeCompare(o.name))}function W9(e,n=!0){const s=new Map;for(const r of e)r.kind==="model"&&s.set(r.name,[...s.get(r.name)??[],r]);return[...s].map(([r,o])=>{const i=N$(o),c=n?o:o.filter(g=>g.decision),d=o.filter(g=>g.tokens&&(hn(g)??0)>0),u=o.map(g=>hn(g)).filter(g=>g!==null).sort((g,y)=>g-y),f=d.reduce((g,y)=>g+hn(y),0);return{name:r,requests:o.length,failed:o.filter(g=>g.status==="failed").length,tokens:i,cache:Qd(i),cost:c.length?Qc(c.map(g=>g.usd)):null,totalMs:u.reduce((g,y)=>g+y,0),p50:jm(u,.5),p95:jm(u,.95),perSecond:f>0?d.reduce((g,y)=>g+y.tokens.output,0)/(f/1e3):null}}).sort((r,o)=>o.requests-r.requests||r.name.localeCompare(o.name))}function zg(e,n,s){if(n==="failed"?e.status!=="failed":n!=="all"&&e.kind!==n)return!1;const r=s.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!r.length)return!0;const o=`${e.name} ${e.agent_label??""} ${e.input_preview??""} ${e.status}`.toLowerCase();return r.every(i=>o.includes(i))}function H9(e,n,s){const r=[...e].sort((d,u)=>vs(d.started_at)-vs(u.started_at));if(n==="started")return r;const o=d=>d.tokens?ur(d.tokens)+d.tokens.output:d.kind==="tool"?d.result_size_bytes:null,i=d=>n==="duration"?hn(d,s):n==="cost"?d.usd:o(d),c=d=>n==="tokens"&&d.kind==="tool"?1:0;return r.map(d=>({span:d,n:i(d)})).sort((d,u)=>c(d.span)-c(u.span)||(u.n??-1)-(d.n??-1)).map(({span:d})=>d)}const Gs=e=>e===0?"$0":e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`;function B9(e){const n=new Map;let[s,r]=[0,!1];for(const c of e)c.usd!==null&&(r=!0,c.kind==="tool"?s+=c.usd:n.set(c.name,(n.get(c.name)??0)+c.usd));const o=[...[...n].map(([c,d])=>({name:c,kind:"model",usd:d})).sort((c,d)=>d.usd-c.usd),...s>0?[{name:"Tool charges",kind:"tool",usd:s}]:[]],i=o.reduce((c,d)=>c+d.usd,0);return r?{parts:o,total:i}:null}function q9(e,n){const{spans:s}=e,r=Qb(e,n),o=[],i=b=>s.filter(j=>j.kind===b&&hn(j,n)!==null).sort((j,k)=>hn(k,n)-hn(j,n))[0],c=b=>r.time.wall>0?` · ${$s(b/r.time.wall)} of the run's time`:"",d=s.filter(b=>b.status==="failed");if(d.length){const b=[...new Set(d.map(j=>j.name))];o.push({id:"failed",bad:!0,span:d[0].id,title:d.length===1?`1 call failed: ${d[0].name}`:`${d.length} calls failed`,detail:d.length===1?`At ${hd(vs(d[0].started_at)-Yb(s,n).from)}.${s.some(j=>vs(j.started_at)>vs(d[0].started_at))?" The run went on after it.":" Nothing ran after it."}`:b.slice(0,4).join(", ")+(b.length>4?` and ${b.length-4} more`:"")})}const u=i("tool");u&&o.push({id:"slowest-call",span:u.id,title:`Slowest call: ${u.name}`,detail:`${Dn(hn(u,n))}${c(hn(u,n))}${u.status==="waiting"?" · waiting for a person":""}`});const f=i("model");f&&o.push({id:"slowest-request",span:f.id,title:`Longest request: ${Dn(hn(f,n))}`,detail:`${f.name}${f.tokens?` · wrote ${f.tokens.output.toLocaleString("en-US")} tokens`:""}${c(hn(f,n))}`});const g=s.filter(b=>b.kind==="model"&&b.usd!==null),y=[...g].sort((b,j)=>j.usd-b.usd)[0],v=g.reduce((b,j)=>b+j.usd,0);y&&g.length>1&&y.usd>0&&o.push({id:"dearest",span:y.id,title:`Most expensive request: ${Gs(y.usd)}`,detail:`${$s(y.usd/v)} of what the requests cost${y.tokens?` · ${ur(y.tokens).toLocaleString("en-US")} tokens in, ${y.tokens.output.toLocaleString("en-US")} out`:""}`});const h=r.tokens?Qd(r.tokens):null;if(h!==null){const b=s.filter(j=>j.kind==="model"&&j.tokens&&j.tokens.cache_read===0).length;o.push({id:"cache",title:`${$s(h)} of input was read from cache`,detail:`${r.tokens.cache_read.toLocaleString("en-US")} of ${ur(r.tokens).toLocaleString("en-US")} input tokens. ${b===0?"Every request read from cache.":`${b} of ${r.requests} request${r.requests===1?"":"s"} read nothing from cache.`}`})}const x=s.filter(b=>b.kind==="tool"&&(b.result_size_bytes??0)>=8*1024).sort((b,j)=>j.result_size_bytes-b.result_size_bytes)[0];return x&&o.push({id:"largest",span:x.id,title:`Largest result: ${x.name}`,detail:`${Math.round(x.result_size_bytes/1024).toLocaleString("en-US")} KB, which is input to every request after it.`}),r.time.wall>0&&r.time.other/r.time.wall>=.25&&o.push({id:"between",title:`${$s(r.time.other/r.time.wall)} of the run was between calls`,detail:`${Dn(r.time.other)} with no model answering and no tool running: waiting for a person or its turn, or the harness working.`}),r.cost.charges.unknown>0&&o.push({id:"unknown-charges",title:`${r.cost.charges.unknown} charge${r.cost.charges.unknown===1?"":"s"} of an unknown amount`,detail:"The run's cost is unknown until each is priced."}),o}function G9(e,n){const[s,r]=p.useState(null),[o,i]=p.useState(null),c=p.useRef(e);c.current=e;const d=p.useRef({mounted:!1,out:!1,again:!1,timer:void 0,seen:null}),u=p.useRef(()=>{});return u.current=()=>{const f=d.current;if(clearTimeout(f.timer),f.timer=void 0,!(!c.current||!f.mounted)){if(f.out){f.again=!0;return}f.out=!0,f.again=!1,Promise.resolve().then(c.current).then(g=>{f.mounted&&(r(g),i(null))},g=>{f.mounted&&i(g)}).finally(()=>{f.out=!1,f.again&&f.mounted&&(f.timer=setTimeout(()=>u.current(),500))})}},p.useEffect(()=>{const f=d.current;return f.mounted=!0,()=>{f.mounted=!1,clearTimeout(f.timer),f.timer=void 0}},[]),p.useEffect(()=>{const f=d.current;f.seen===null?u.current():f.out?f.again=!0:f.timer===void 0&&(f.timer=setTimeout(()=>u.current(),500)),f.seen=n},[n]),{trace:s,error:s?null:o,retry:()=>u.current()}}function K9(e,n){const[s,r]=p.useState(()=>Date.now());return p.useEffect(()=>{if(!e||n!==void 0)return;r(Date.now());const o=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(o)},[e,n]),n??s}const dl={ok:{tone:"success",word:"OK"},failed:{tone:"error",word:"Failed"},refused:{tone:"muted",word:"Refused"},interrupted:{tone:"muted",word:"Interrupted"},waiting:{tone:"warning",word:"Waiting"},running:{tone:"active",word:"Running"}},S$="border border-warning bg-warning/20",Jb=e=>e.status==="failed"?"bg-destructive":e.status==="running"?"bg-run-active":e.status==="waiting"?S$:e.status!=="ok"?"bg-muted-foreground":e.kind==="model"?"bg-trace-model":"bg-trace-tool",wN={model:"Model",tool:"Tool"},Jc=e=>e.unknown===0?Gs(e.usd):e.usd>0?`${Gs(e.usd)} + ${e.unknown} unknown`:"Unknown";function Hx(e,n){return e.kind==="model"?e.usd!==null?Gs(e.usd):n.model_requests==="tokens_only"&&!e.decision?"–":"Unknown":e.charged?e.usd!==null?Gs(e.usd):"Unknown":e.not_metered?"Not metered":"–"}const V9=e=>e.tokens?`${fr(ur(e.tokens))} in · ${fr(e.tokens.output)} out`:e.result_size_bytes!==null?gr(e.result_size_bytes):"–",jN=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),Y9=e=>e instanceof Error&&e.message?e.message:"The server gave no reason.";function Gi({label:e,value:n,note:s,tone:r}){return t.jsxs("div",{className:"min-w-0 border-b border-r p-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:e}),t.jsx("p",{title:String(n),className:te("mt-0.5 truncate font-mono font-semibold",String(n).length>11?"text-lg leading-8":"text-figure",r==="bad"&&"text-destructive-text"),children:n}),t.jsx("p",{className:"mt-0.5 truncate text-small text-muted-foreground",title:typeof s=="string"?s:void 0,children:s})]})}const Zr=({children:e,aside:n})=>t.jsxs("div",{className:"mb-2 flex items-baseline justify-between gap-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:n})]}),io=({className:e})=>t.jsx("span",{"aria-hidden":!0,className:te("inline-block size-2 shrink-0",e)});function kN({title:e,swatch:n,bars:s,rows:r,marks:o,selected:i,dimmed:c,tab:d,refs:u,onPick:f,at:g}){return t.jsxs("div",{className:"mt-3 first:mt-0",children:[t.jsxs("p",{className:"caps flex items-center gap-1.5 text-micro text-muted-foreground",children:[t.jsx(io,{className:n}),e]}),t.jsxs("div",{className:"relative mt-1.5",style:{height:r*20-6},children:[o.map(y=>t.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 w-px bg-border",style:{left:`${y.left}%`}},y.left)),s.map(({span:y,left:v,width:h,row:x})=>t.jsx("button",{type:"button",ref:b=>{b?u.current.set(y.id,b):u.current.delete(y.id)},tabIndex:y.id===d?0:-1,"aria-pressed":y.id===i,"aria-label":g(y),title:g(y),onClick:()=>f(y.id),style:{left:`${v}%`,width:`${h}%`,top:x*20},className:te("absolute h-3.5 min-w-1 transition-opacity hover:opacity-80",Jb(y),c(y)&&"opacity-25",y.id===i&&"ring-2 ring-foreground ring-offset-1 ring-offset-card")},y.id))]})]})}function Q9({span:e,trace:n,run:s,from:r,now:o,reveal:i,onPick:c,onClose:d}){var A;const[u,f]=p.useState("input"),[g,y]=p.useState(!1);p.useEffect(()=>{if(!g)return;const R=setTimeout(()=>y(!1),1500);return()=>clearTimeout(R)},[g]);const v=R=>{var L;(L=navigator.clipboard)==null||L.writeText(R).then(()=>y(!0),()=>{})},h=p.useRef(null);p.useEffect(()=>{var R,L;i&&h.current&&h.current.getBoundingClientRect().top>globalThis.innerHeight-80&&((L=(R=h.current).scrollIntoView)==null||L.call(R,{block:"start"}))},[]);const x=hn(e,o),b=u==="input"?e.input_preview:e.result_preview,j=e.parent_id?n.spans.find(R=>R.id===e.parent_id):void 0,k=n.spans.filter(R=>R.parent_id===e.id),E=e.tokens,N=E?Qd(E):null,S=(A=s.cost)==null?void 0:A.usd,$=e.usd!==null&&typeof S=="number"&&S>0?`${$s(Math.min(1,e.usd/S))} of the run`:null,_=E&&e.ended_at&&x?Math.round(E.output/(x/1e3)):null,O=E?[["Input, not cached",E.input,"bg-muted-foreground"],["Cache read",E.cache_read,"bg-trace-model/40"],["Cache write",E.cache_write,"bg-trace-model/70"],["Output",E.output,"bg-trace-model"]]:[],M=E?ur(E)+E.output:0,P=[[e.kind==="model"?"Model":"Tool",e.name],...e.agent_label?[["Subagent",e.agent_label]]:[],...e.stop_reason?[["Stop reason",e.stop_reason]]:[],["Started",`${jN(e.started_at)} · ${hd(Date.parse(e.started_at)-r)}`],["Ended",e.ended_at?jN(e.ended_at):e.status==="running"?"Still running":e.status==="waiting"?"Waiting for a person":"Not recorded"],..._!==null&&E&&E.output>0?[["Output speed",`${_.toLocaleString("en-US")} tokens/s`]]:[],...(E==null?void 0:E.reasoning)!==void 0?[["Thinking tokens",`${E.reasoning.toLocaleString("en-US")} of the output`]]:[],...e.tool_use_id?[["Call id",e.tool_use_id]]:[],["Span",e.id]];return t.jsxs("aside",{ref:h,"aria-label":"Call details",onKeyDown:R=>{R.key==="Escape"&&(R.stopPropagation(),d())},className:"relative border-t bg-card p-5 xl:w-2/5 xl:max-w-lg xl:shrink-0 xl:overflow-auto xl:border-l xl:border-t-0",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(Ne,{children:[t.jsx(io,{className:e.kind==="model"?"bg-trace-model":"bg-trace-tool"}),e.decision?"Decision":e.kind==="model"?"Model request":"Tool call"]}),t.jsx(Ne,{tone:dl[e.status].tone,children:dl[e.status].word})]}),t.jsx("h2",{className:"mt-2 break-words font-mono text-lead font-semibold",children:e.name})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close call details",onClick:d,children:t.jsx(uo,{"aria-hidden":!0})})]}),t.jsx("dl",{className:"mt-4 grid grid-cols-3 border-l border-t",children:[["Duration",x!==null?Dn(x):"–",e.ended_at?null:x!==null?"so far":"not recorded"],[e.kind==="model"?"Cost":"Charged",Hx(e,n),$],e.kind==="model"?["Tokens",E?fr(M):"–",E?`${fr(ur(E))} in · ${fr(E.output)} out`:"none reported"]:["Result",e.result_size_bytes!==null?gr(e.result_size_bytes):"–",null]].map(([R,L,W])=>t.jsxs("div",{className:"min-w-0 border-b border-r p-2.5",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:R}),t.jsx("dd",{className:"mt-0.5 truncate font-mono text-base font-semibold",children:L}),W&&t.jsx("dd",{className:"truncate text-label text-muted-foreground",title:W,children:W})]},R))}),e.kind==="model"&&t.jsxs("section",{className:"mt-5","aria-label":"Tokens",children:[t.jsx(Zr,{aside:N!==null?`${$s(N)} of input from cache`:void 0,children:"Tokens"}),E?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-2.5 bg-accent",role:"img","aria-label":O.map(([R,L])=>`${R}: ${L.toLocaleString("en-US")} tokens`).join(", "),children:O.filter(([,R])=>R>0).map(([R,L,W])=>t.jsx("span",{title:`${R}: ${L.toLocaleString("en-US")}`,className:te("min-w-0.5 border-r border-card last:border-r-0",W),style:{width:`${L/M*100}%`}},R))}),t.jsxs("table",{className:"mt-2 w-full text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"caps border-b text-micro text-muted-foreground",children:[t.jsx("th",{className:"py-1.5 text-left font-normal",children:"Line"}),t.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"}),t.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"Of input"})]})}),t.jsxs("tbody",{children:[O.map(([R,L,W])=>t.jsxs("tr",{className:"border-b",children:[t.jsx("th",{scope:"row",className:"whitespace-nowrap py-1.5 text-left text-body font-normal",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(io,{className:W}),R]})}),t.jsx("td",{className:"py-1.5 text-right font-mono",children:L.toLocaleString("en-US")}),t.jsx("td",{className:"py-1.5 pl-3 text-right font-mono text-muted-foreground",children:R!=="Output"&&ur(E)>0?$s(L/ur(E)):"–"})]},R)),t.jsxs("tr",{className:"font-semibold",children:[t.jsx("th",{scope:"row",className:"py-1.5 text-left text-body font-semibold",children:"This request"}),t.jsx("td",{className:"py-1.5 text-right font-mono",children:M.toLocaleString("en-US")}),t.jsx("td",{className:"py-1.5 pl-3 text-right font-mono",children:Hx(e,n)})]})]})]})]}):t.jsxs("p",{className:"text-body text-muted-foreground",children:["This request reported no tokens",e.status==="interrupted"?": it was cut before its end":"","."]}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:e.usd!==null?"The cost is what the run recorded for this request: one figure for all its tokens.":n.model_requests==="tokens_only"&&!e.decision?"This run's cost is booked for the whole run, so this request carries tokens only.":e.decision?"This decision's cost is unknown: its receipt keeps none.":"This request's cost is unknown: it was cut before its end, or its model has no price here."})]}),e.kind==="tool"&&t.jsxs("section",{className:"mt-5","aria-label":"Cost",children:[t.jsx(Zr,{children:"Cost"}),t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.charged?`${e.usd!==null?Gs(e.usd):"An unknown amount"} was charged under this call, and is in the run's cost.`:e.not_metered?"This tool has no price set, so the call ran outside the run's cost.":"Nothing was charged under this call.",s.computer?" Time on the run's computer is billed by its provider and is not metered here.":""]})]}),t.jsxs("section",{className:"mt-5","aria-label":"Details",children:[t.jsx(Zr,{children:"Details"}),t.jsxs("dl",{children:[j&&t.jsxs("div",{className:"flex items-center justify-between gap-4 border-b py-1.5",children:[t.jsx("dt",{className:"shrink-0 text-body text-muted-foreground",children:e.kind==="model"?"Started by":"Called by"}),t.jsx("dd",{className:"min-w-0",children:t.jsxs("button",{type:"button",className:"-my-1 max-w-full truncate py-1 font-mono text-small underline underline-offset-2 hover:text-primary-text",onClick:()=>c(j.id),children:[j.name," · ",hd(Date.parse(j.started_at)-r)]})})]}),P.map(([R,L])=>t.jsxs("div",{className:"flex justify-between gap-4 border-b py-1.5",children:[t.jsx("dt",{className:"shrink-0 text-body text-muted-foreground",children:R}),t.jsx("dd",{className:"min-w-0 break-words text-right font-mono text-small",children:L})]},R))]})]}),k.length>0&&t.jsxs("section",{className:"mt-5","aria-label":e.kind==="model"?"Calls it made":"What ran under it",children:[t.jsx(Zr,{aside:String(k.length),children:e.kind==="model"?"Calls it made":"What ran under it"}),t.jsx("ul",{children:k.slice(0,12).map(R=>t.jsx("li",{className:"border-b",children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 py-1.5 text-left font-mono text-small hover:bg-accent",onClick:()=>c(R.id),children:[t.jsx(io,{className:Jb(R)}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:R.name}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:hn(R,o)!==null?Dn(hn(R,o)):dl[R.status].word})]})},R.id))}),k.length>12&&t.jsxs("p",{className:"mt-1.5 text-small text-muted-foreground",children:["And ",k.length-12," more: filter the table by name to find them."]})]}),e.kind==="tool"&&t.jsxs("section",{className:"mt-5","aria-label":"Arguments and result",children:[t.jsx(Ev,{id:"span-text",label:"Arguments and result",className:"px-0 md:px-0",value:u,onChange:f,tabs:[{id:"input",label:"Arguments"},{id:"output",label:"Result"}]}),t.jsxs("div",{...c2("span-text",u),children:[b?t.jsx("pre",{tabIndex:0,role:"region","aria-label":u==="input"?"The call's arguments":"The head of the call's result",className:"mt-3 max-h-64 overflow-auto whitespace-pre-wrap break-words border bg-background p-3 font-mono text-small",children:b}):t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:u==="input"?"The call took no arguments.":e.status==="running"||e.status==="waiting"?"No result yet.":"The call returned nothing to show."}),t.jsxs("div",{className:"mt-2 flex items-start justify-between gap-3",children:[t.jsxs("p",{className:"text-small text-muted-foreground",children:["The Timeline's own cut of the call: its head, with secrets removed.",u==="output"&&e.result_size_bytes!==null?` The whole result was ${gr(e.result_size_bytes)}.`:""]}),b&&t.jsx(B,{size:"xs",variant:"ghost",className:"shrink-0",onClick:()=>v(b),children:g?"Copied":"Copy"})]})]})]})]})}const NN=["bg-trace-model","bg-trace-model/70","bg-trace-model/40"];function SN({label:e,parts:n,whole:s,say:r}){const o=n.filter(i=>i.n>0);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-3 bg-accent",role:"img","aria-label":`${e}: ${o.map(i=>`${i.word} ${r(i.n)}`).join(", ")}`,children:o.map(i=>t.jsx("span",{className:te("min-w-0.5 border-r border-card last:border-r-0",i.tone),style:{width:`${i.n/Math.max(s,Number.MIN_VALUE)*100}%`}},i.word))}),t.jsx("ul",{className:"mt-3 flex flex-wrap gap-x-6 gap-y-1.5 text-small",children:o.map(i=>t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(io,{className:i.tone}),i.word,t.jsxs("span",{className:"font-mono text-muted-foreground",children:[r(i.n)," · ",$s(s>0?i.n/s:0)]})]},i.word))})]})}function J9({trace:e,now:n,onPick:s,selected:r}){var E;const o=p.useMemo(()=>Qb(e,n),[e,n]),i=p.useMemo(()=>U9(e.spans,n),[e,n]),c=p.useMemo(()=>W9(e.spans,e.model_requests==="priced"),[e]),d=p.useMemo(()=>q9(e,n),[e,n]),u=p.useMemo(()=>B9(e.spans),[e]),[f,g]=p.useState("input"),y=e.spans.filter(N=>N.kind==="model"&&N.tokens),v=y.some(N=>N.usd!==null),h=f==="cost"&&v?"cost":"input",x=Math.max(0,...y.map(N=>h==="cost"?N.usd??0:ur(N.tokens))),b=Math.max(1,...i.map(N=>N.totalMs)),j="caps whitespace-nowrap px-3 py-2 text-right text-label font-normal text-muted-foreground first:text-left",k="whitespace-nowrap px-3 py-2 text-right font-mono";return t.jsxs("div",{className:"space-y-6",children:[d.length>0&&t.jsxs("section",{"aria-label":"What stands out",children:[t.jsx(Zr,{children:"What stands out"}),t.jsx("ul",{className:"grid border-l border-t sm:grid-cols-2 2xl:grid-cols-3",children:d.map(N=>{const S=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:te("block text-body font-semibold",N.bad&&"text-destructive-text"),children:N.title}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:N.detail})]});return t.jsx("li",{className:"border-b border-r bg-card",children:N.span?t.jsx("button",{type:"button","aria-pressed":N.span===r,onClick:()=>s(N.span),className:te("block h-full w-full p-3 text-left -outline-offset-2 hover:bg-accent",N.span===r&&"bg-accent"),children:S}):t.jsx("div",{className:"p-3",children:S})},N.id)})})]}),t.jsxs("div",{className:"grid gap-6 2xl:grid-cols-2",children:[t.jsxs("section",{"aria-label":"Where the time went",className:"border bg-card p-4",children:[t.jsx(Zr,{aside:Dn(o.time.wall),children:"Where the time went"}),t.jsx(SN,{label:"Where the time went",whole:o.time.wall,say:Dn,parts:[{word:"A model answering",tone:"bg-trace-model",n:o.time.model},{word:"A tool running",tone:"bg-trace-tool",n:o.time.tools},{word:"Neither",tone:"bg-border-strong",n:o.time.other}]}),t.jsx("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:'Each moment is counted once. "Neither" is the time between calls: the run waiting for a person or its turn, or its harness working.'})]}),t.jsxs("section",{"aria-label":"Where the cost went",className:"border bg-card p-4",children:[t.jsx(Zr,{aside:u?Gs(u.total):void 0,children:"Where the cost went"}),u&&u.total===0?t.jsx("p",{className:"text-body text-muted-foreground",children:"Everything this trace knows the cost of was $0."}):u?t.jsx(SN,{label:"Where the cost went",whole:u.total,say:Gs,parts:u.parts.map((N,S)=>({word:N.name,tone:N.kind==="tool"?"bg-trace-tool":NN[Math.min(S,NN.length-1)],n:N.usd}))}):t.jsx("p",{className:"text-body text-muted-foreground",children:e.model_requests==="priced"?"Nothing in this trace has a known cost yet.":"This run's cost is booked for the run as a whole: its trace carries no cost for each request."}),u&&u.total>0&&t.jsxs("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:["What the trace knows the cost of: each model's requests, and each charge under a call.",(E=o.cost.requests)!=null&&E.unknown?` ${o.cost.requests.unknown} request${o.cost.requests.unknown===1?" has":"s have"} no known cost and ${o.cost.requests.unknown===1?"is":"are"} not in it.`:""]})]})]}),y.length>0&&t.jsxs("section",{"aria-label":"Each request",className:"border bg-card p-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:"Each request, in the order they ran"}),v&&t.jsx(Qo,{name:"trace-chart",label:"What a bar's height is",size:"sm",value:h,onChange:g,options:[{value:"input",label:"Input tokens"},{value:"cost",label:"Cost"}]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsx("div",{className:"flex h-32 min-w-full items-end gap-px border-b",role:"group","aria-label":h==="cost"?"Each request's cost":"Each request's input tokens",children:y.map(N=>{const S=N.tokens,$=h==="cost"?N.usd??0:ur(S),_=h==="cost"?null:S,O=h==="cost"?`${N.name}: ${N.usd!==null?Gs(N.usd):"cost unknown"}`:`${N.name}: ${$.toLocaleString("en-US")} input tokens, ${$s(Qd(S)??0)} from cache`;return t.jsx("button",{type:"button","aria-pressed":N.id===r,onClick:()=>s(N.id),title:O,"aria-label":O,className:te("flex min-w-1 max-w-24 flex-1 flex-col-reverse hover:opacity-80",N.id===r&&"ring-2 ring-foreground ring-offset-1 ring-offset-card"),style:{height:`${x>0?Math.max(2,$/x*100):2}%`},children:_?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bg-trace-model/40",style:{flexGrow:_.cache_read}}),t.jsx("span",{className:"bg-trace-model/70",style:{flexGrow:_.cache_write}}),t.jsx("span",{className:"bg-muted-foreground",style:{flexGrow:_.input}})]}):t.jsx("span",{className:"flex-1 bg-trace-model"})},N.id)})})}),t.jsxs("div",{className:"mt-2 flex justify-between font-mono text-micro text-muted-foreground",children:[t.jsx("span",{children:"first request"}),t.jsxs("span",{children:["tallest: ",h==="cost"?Gs(x):`${fr(x)} tokens`]}),t.jsx("span",{children:"last request"})]}),h==="input"&&t.jsxs("ul",{className:"mt-3 flex flex-wrap gap-x-6 gap-y-1.5 text-small",children:[t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(io,{className:"bg-trace-model/40"}),"Read from cache"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(io,{className:"bg-trace-model/70"}),"Written to cache"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(io,{className:"bg-muted-foreground"}),"Not cached"]})]}),t.jsx("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:h==="cost"?"One bar a request: its height is what the run booked for it.":"One bar a request: its height is the input it sent. A run that caches well reads most of each request from cache and writes only what is new."})]}),c.length>0&&t.jsxs("section",{"aria-label":"By model",children:[t.jsx(Zr,{children:"By model"}),t.jsx("div",{className:"overflow-x-auto border bg-card",tabIndex:0,role:"region","aria-label":"Requests by model",children:t.jsxs("table",{className:"w-full text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b",children:["Model","Requests","Failed","Input","From cache","Output","Tokens/s","Median time","95th","Total time","Cost"].map(N=>t.jsx("th",{scope:"col",className:j,children:N},N))})}),t.jsx("tbody",{children:c.map(N=>t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-mono font-normal",children:N.name}),t.jsx("td",{className:k,children:N.requests}),t.jsx("td",{className:te(k,N.failed>0&&"text-destructive-text"),children:N.failed}),t.jsx("td",{className:k,children:fr(N.tokens.input+N.tokens.cache_read+N.tokens.cache_write)}),t.jsx("td",{className:k,children:N.cache!==null?$s(N.cache):"–"}),t.jsx("td",{className:k,children:fr(N.tokens.output)}),t.jsx("td",{className:k,children:N.perSecond!==null?Math.round(N.perSecond).toLocaleString("en-US"):"–"}),t.jsx("td",{className:k,children:N.p50!==null?Dn(N.p50):"–"}),t.jsx("td",{className:k,children:N.p95!==null?Dn(N.p95):"–"}),t.jsx("td",{className:k,children:Dn(N.totalMs)}),t.jsx("td",{className:k,children:N.cost?Jc(N.cost):"–"})]},N.name))})]})})]}),i.length>0&&t.jsxs("section",{"aria-label":"By tool",children:[t.jsx(Zr,{aside:"the tool that took the most time first",children:"By tool"}),t.jsx("div",{className:"overflow-x-auto border bg-card",tabIndex:0,role:"region","aria-label":"Calls by tool",children:t.jsxs("table",{className:"w-full text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b",children:["Tool","Calls","Failed","Total time","Median","95th","Longest","Charged","Returned"].map(N=>t.jsx("th",{scope:"col",className:j,children:N},N))})}),t.jsx("tbody",{children:i.map(N=>t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-mono font-normal",children:N.name}),t.jsx("td",{className:k,children:N.calls}),t.jsx("td",{className:te(k,N.failed>0&&"text-destructive-text"),children:N.failed}),t.jsx("td",{className:k,children:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx("span",{"aria-hidden":!0,className:"inline-block h-1.5 w-16 bg-accent",children:t.jsx("span",{className:"block h-full bg-trace-tool",style:{width:`${N.totalMs/b*100}%`}})}),Dn(N.totalMs)]})}),t.jsx("td",{className:k,children:N.p50!==null?Dn(N.p50):"–"}),t.jsx("td",{className:k,children:N.p95!==null?Dn(N.p95):"–"}),t.jsx("td",{className:k,children:N.maxMs!==null?Dn(N.maxMs):"–"}),t.jsx("td",{className:k,children:N.charged>0?Jc(N.charges):"–"}),t.jsx("td",{className:k,children:gr(N.bytes)})]},N.name))})]})})]})]})}const Oc=[1,2,4,8,16],Dg=300,X9=[{id:"started",label:"Started"},{id:"duration",label:"Duration",right:!0},{id:"tokens",label:"Size",right:!0},{id:"cost",label:"Cost",right:!0}];function Z9({run:e,read:n,version:s,live:r,now:o,open:i=null,view:c="calls"}){var Me,pe;const{trace:d,error:u,retry:f}=G9(n,s),g=!lo(e.status)&&!!(d!=null&&d.spans.some(ne=>ne.status==="running"||ne.status==="waiting")),y=K9(g,o),v=o??(lo(e.status)&&e.ended_at?Date.parse(e.ended_at):y),[h,x]=p.useState(i),[b,j]=p.useState(c),[k,E]=p.useState("all"),[N,S]=p.useState(""),[$,_]=p.useState("started"),[O,M]=p.useState(0),[P,A]=p.useState(!1),[R,L]=p.useState(!1),W=p.useRef(null),U=p.useRef(new Map),Y=p.useRef(new Map),D=(d==null?void 0:d.spans)??[],G=p.useMemo(()=>Yb(D,v),[D,v]),F=p.useMemo(()=>d?Qb(d,v):null,[d,v]),q=p.useMemo(()=>({model:bN(D.filter(ne=>ne.kind==="model"),G,v),tool:bN(D.filter(ne=>ne.kind==="tool"),G,v)}),[D,G,v]),H=p.useMemo(()=>F9(G.ms,8*Oc[O]),[G.ms,O]),I=p.useMemo(()=>H9(D.filter(ne=>zg(ne,k,N)),$,v),[D,k,N,$,v]),V=p.useMemo(()=>{const ne=new Map(D.map(Pe=>[Pe.id,Pe])),Ae=(Pe,bt=0)=>Pe.parent_id&&ne.has(Pe.parent_id)&&bt<4?1+Ae(ne.get(Pe.parent_id),bt+1):0;return new Map(D.map(Pe=>[Pe.id,Ae(Pe)]))},[D]);if(!n)return null;if(!d)return t.jsx("div",{className:"px-5 py-8 md:px-8",children:u?t.jsx(jt,{tone:"error",title:"The trace could not be read",actions:t.jsx(B,{size:"xs",onClick:f,children:"Try again"}),children:t.jsx("p",{className:"font-mono text-small",children:Y9(u)})}):t.jsxs("p",{className:"flex items-center gap-3 font-mono text-body text-muted-foreground",children:[t.jsx(Cv,{}),"Reading the trace"]})});const J=h?D.find(ne=>ne.id===h)??null:null,X=()=>{const ne=document.activeElement;ne instanceof HTMLElement&&!ne.closest("aside")&&(W.current=ne)},re=ne=>{X(),L(!0),x(ne)},ae=ne=>{var Ae,Pe;X(),L(!1),x(ne),(Pe=(Ae=Y.current.get(ne))==null?void 0:Ae.scrollIntoView)==null||Pe.call(Ae,{block:"nearest"})},ye=()=>{var ne;x(null),(ne=W.current)!=null&&ne.isConnected&&W.current.focus()},he=[...D].sort((ne,Ae)=>Date.parse(ne.started_at)-Date.parse(Ae.started_at)),we=(J==null?void 0:J.id)??((Me=he[0])==null?void 0:Me.id)??null,ze=ne=>`${wN[ne.kind]} ${ne.name}, ${dl[ne.status].word.toLowerCase()}, ${hn(ne,v)!==null?Dn(hn(ne,v)):"no duration"}, at ${hd(Date.parse(ne.started_at)-G.from)}`,le=ne=>{var ot;const Ae=ne.key==="ArrowRight"||ne.key==="ArrowDown"?1:ne.key==="ArrowLeft"||ne.key==="ArrowUp"?-1:ne.key==="Home"?-he.length:ne.key==="End"?he.length:0;if(!Ae||!he.length)return;ne.preventDefault();const Pe=Math.max(0,he.findIndex(mt=>mt.id===we)),bt=he[Math.min(he.length-1,Math.max(0,Pe+Ae))];ae(bt.id),(ot=U.current.get(bt.id))==null||ot.focus(),W.current=U.current.get(bt.id)??W.current},me=()=>{const ne=URL.createObjectURL(new Blob([JSON.stringify(d,null,2)],{type:"application/json"}));Object.assign(document.createElement("a"),{href:ne,download:`trace-${e.run_id}.json`}).click(),URL.revokeObjectURL(ne)},Ke=((pe=e.cost)==null?void 0:pe.usd)??null,be=ui(e.cost),ge=[...new Set(D.filter(ne=>ne.kind==="model").map(ne=>ne.name))],Je=new Set(D.filter(ne=>ne.kind==="tool").map(ne=>ne.name)),tt=D.find(ne=>ne.status==="failed"),ft={all:D.length,model:F.requests,tool:F.calls,failed:F.failed},ve=F.tokens?Qd(F.tokens):null,Ee=J?"xl:hidden 2xl:table-cell":"",Q=F.cost.requests;return t.jsxs("div",{"data-scroll-pane":!0,className:"relative min-h-0 flex-1 overflow-auto xl:flex xl:overflow-hidden short:flex-none short:overflow-visible",children:[t.jsxs("section",{"aria-label":"Trace",className:"relative min-w-0 space-y-4 px-5 py-6 md:px-8 xl:min-h-0 xl:flex-1 xl:overflow-auto",children:[d.model_requests==="not_recorded"&&t.jsx(jt,{tone:"info",title:"This run's harness keeps no record of each model request",children:"The trace shows its tool calls. The run's cost and how many requests it made are on its Timeline's usage line."}),d.dropped>0&&t.jsxs(jt,{tone:"warning",children:["This is the run's first ",D.length.toLocaleString("en-US")," requests and calls. ",d.dropped.toLocaleString("en-US")," later ones are not shown."]}),t.jsxs("div",{className:"grid grid-cols-2 border-l border-t bg-card sm:grid-cols-3 2xl:grid-cols-6",children:[t.jsx(Gi,{label:"Model requests",value:d.model_requests==="not_recorded"?"–":F.requests,note:d.model_requests==="not_recorded"?"Not kept by this harness":ge.length===1?ge[0]:ge.length?`${ge.length} models`:"None yet"}),t.jsx(Gi,{label:"Tool calls",value:F.calls,note:Je.size===1?"1 tool":`${Je.size} tools`}),t.jsx(Gi,{label:"Failed",value:F.failed,tone:F.failed>0?"bad":void 0,note:tt?`First: ${tt.name}`:"Nothing failed"}),t.jsx(Gi,{label:"Tokens",value:F.tokens?fr(ur(F.tokens)+F.tokens.output):"–",note:F.tokens?`${ve!==null?`${$s(ve)} of input read from cache`:"No input reported"}${F.untold?` · ${F.untold} request${F.untold===1?"":"s"} reported none`:""}`:"No request to count"}),t.jsx(Gi,{label:Ke===null&&be?"Cost so far":e.cost&&Pv(e.cost)?"Cost, estimated":"Cost",value:typeof Ke=="number"?Gs(Ke):be?Gs(be.so_far_usd):"Unknown",note:Q?`requests ${Jc(Q)}${F.cost.charged?` · tools ${Jc(F.cost.charges)}`:""}`:F.cost.charged?`tools ${Jc(F.cost.charges)}`:"Booked for the run as a whole"}),t.jsx(Gi,{label:"Time",value:Dn(F.time.wall),note:F.time.wall>0?`model ${$s(F.time.model/F.time.wall)} · tools ${$s(F.time.tools/F.time.wall)}`:"Nothing ran yet"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Qo,{name:"trace-view",label:"What the tab shows",size:"sm",value:b,onChange:j,options:[{value:"calls",label:"Calls"},{value:"breakdown",label:"Breakdown"}]}),b==="calls"&&D.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:te(Za,"flex h-control-sm min-w-40 flex-1 items-center gap-2 px-2.5"),children:[t.jsx(yd,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(De,{bare:!0,value:N,onChange:ne=>S(ne.target.value),placeholder:"Filter by tool, model or arguments","aria-label":"Filter calls",className:"h-full flex-1 text-small"})]}),t.jsx(Qo,{name:"trace-kind",label:"Kind of call",size:"sm",value:k,onChange:E,options:[["all","All"],["model","Model"],["tool","Tools"],["failed","Failed"]].map(([ne,Ae])=>({value:ne,label:t.jsxs(t.Fragment,{children:[Ae," ",t.jsx("span",{className:"font-normal",children:ft[ne]})]})}))})]}),t.jsxs(B,{size:"sm",className:"ml-auto",onClick:me,title:"Save the trace as the server sent it",children:[t.jsx(tv,{"aria-hidden":!0}),"Export JSON"]})]}),D.length===0?t.jsx("p",{className:"border bg-card p-4 font-mono text-body text-muted-foreground",children:r?"No model request has answered and no tool has been called yet.":"This run made no model request and called no tool."}):b==="breakdown"?t.jsx(J9,{trace:d,now:v,onPick:re,selected:(J==null?void 0:J.id)??null}):t.jsxs(t.Fragment,{children:[t.jsxs("section",{"aria-label":"Calls on the time axis",className:"border bg-card",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-2",children:[t.jsx("ul",{className:"flex flex-1 flex-wrap gap-x-4 gap-y-1 text-small text-muted-foreground","aria-label":"What a bar's colour says",children:[["bg-trace-model","Model request"],["bg-trace-tool","Tool call"],["bg-destructive","Failed"],...D.some(ne=>ne.status==="running")?[["bg-run-active","Running"]]:[],...D.some(ne=>ne.status==="waiting")?[[S$,"Waiting for a person"]]:[],...D.some(ne=>ne.status==="refused"||ne.status==="interrupted")?[["bg-muted-foreground","Refused or interrupted"]]:[]].map(([ne,Ae])=>t.jsxs("li",{className:"flex items-center gap-1.5",children:[t.jsx(io,{className:ne}),Ae]},Ae))}),t.jsxs("div",{role:"group","aria-label":"Zoom the time axis",className:"flex items-center gap-1",children:[O>0&&t.jsxs("span",{className:"mr-1 font-mono text-small text-muted-foreground",children:[Oc[O],"x"]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Zoom out",title:"Zoom out",disabled:O===0,onClick:()=>M(ne=>Math.max(0,ne-1)),children:t.jsx(vR,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Zoom in",title:"Zoom in",disabled:O===Oc.length-1,onClick:()=>M(ne=>Math.min(Oc.length-1,ne+1)),children:t.jsx(xR,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Fit the whole run",title:"Fit the whole run",disabled:O===0,onClick:()=>M(0),children:t.jsx(i1,{"aria-hidden":!0})})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"p-4",style:{width:`${Oc[O]*100}%`},role:"group","aria-label":"Calls on the time axis: the arrow keys move from call to call",onKeyDown:le,children:[d.model_requests!=="not_recorded"&&t.jsx(kN,{title:`Model requests (${F.requests})`,swatch:"bg-trace-model",...q.model,marks:H,selected:(J==null?void 0:J.id)??null,dimmed:ne=>!zg(ne,k,N),tab:we,refs:U,onPick:ae,at:ze}),t.jsx(kN,{title:`Tool calls (${F.calls})`,swatch:"bg-trace-tool",...q.tool,marks:H,selected:(J==null?void 0:J.id)??null,dimmed:ne=>!zg(ne,k,N),tab:we,refs:U,onPick:ae,at:ze}),t.jsx("div",{className:"relative mt-2 h-4 border-t","aria-hidden":!0,children:H.map(ne=>t.jsx("span",{className:te("absolute top-1 whitespace-nowrap font-mono text-micro text-muted-foreground",ne.left>94?"-translate-x-full pr-1":"pl-1"),style:{left:`${ne.left}%`},children:ne.label},ne.left))})]})})]}),t.jsxs("div",{className:"overflow-x-auto border bg-card",children:[t.jsxs("table",{className:"w-full text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[t.jsx("th",{scope:"col",className:"caps px-3 py-2 text-left text-label font-normal text-muted-foreground",children:"Call"}),X9.map(ne=>t.jsx("th",{scope:"col","aria-sort":$===ne.id?ne.id==="started"?"ascending":"descending":"none",className:te("whitespace-nowrap px-3 py-2",ne.right?"text-right":"text-left",ne.id==="tokens"&&Ee),children:t.jsxs("button",{type:"button",onClick:()=>_($===ne.id?"started":ne.id),title:ne.id==="started"?"In the order they started":`Sort by ${ne.label.toLowerCase()}, most first`,className:te("caps -my-1 inline-flex items-center gap-1 py-1 text-label hover:text-foreground",$===ne.id?"text-foreground":"text-muted-foreground"),children:[ne.label,$===ne.id&&ne.id!=="started"&&t.jsx(DT,{className:"size-3","aria-hidden":!0})]})},ne.id)),t.jsx("th",{scope:"col",className:"caps px-3 py-2 text-left text-label font-normal text-muted-foreground",children:"Status"})]})}),t.jsx("tbody",{children:(P?I:I.slice(0,Dg)).map(ne=>{const Ae=hn(ne,v),Pe=$==="started"?Math.min(2,V.get(ne.id)??0):0;return t.jsxs("tr",{ref:bt=>{bt?Y.current.set(ne.id,bt):Y.current.delete(ne.id)},onClick:()=>re(ne.id),className:te("cursor-pointer border-b last:border-b-0 hover:bg-accent",ne.id===(J==null?void 0:J.id)&&"bg-accent"),children:[t.jsx("td",{className:"w-full min-w-48 max-w-0 overflow-hidden py-0 pl-1 pr-3",children:t.jsxs("button",{type:"button","aria-pressed":ne.id===(J==null?void 0:J.id),"aria-label":ze(ne),className:te("flex h-control-sm w-full min-w-0 items-center gap-2 text-left font-mono -outline-offset-2",Pe===1&&"pl-4",Pe===2&&"pl-8"),children:[t.jsx("span",{"aria-hidden":!0,className:te("h-4 w-0.5 shrink-0",Jb(ne))}),t.jsx("span",{className:"caps w-9 shrink-0 text-micro text-muted-foreground",children:wN[ne.kind]}),t.jsx("span",{className:"max-w-64 shrink-0 truncate",title:ne.name,children:ne.name}),(ne.input_preview||ne.agent_label)&&t.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:[ne.agent_label?`${ne.agent_label} `:"",ne.input_preview??""]})]})}),t.jsx("td",{className:"whitespace-nowrap px-3 font-mono text-muted-foreground",children:hd(Date.parse(ne.started_at)-G.from)}),t.jsx("td",{className:"whitespace-nowrap px-3 text-right font-mono",children:Ae!==null?Dn(Ae):"–"}),t.jsx("td",{className:te("whitespace-nowrap px-3 text-right font-mono text-muted-foreground",Ee),children:V9(ne)}),t.jsx("td",{className:"whitespace-nowrap px-3 text-right font-mono",children:Hx(ne,d)}),t.jsx("td",{className:"px-3",children:t.jsx(Ne,{tone:dl[ne.status].tone,children:dl[ne.status].word})})]},ne.id)})})]}),I.length===0&&t.jsxs("p",{role:"status",className:"p-4 text-body text-muted-foreground",children:["No call matches. Clear the filter to see all ",D.length,"."]}),!P&&I.length>Dg&&t.jsxs("p",{className:"flex flex-wrap items-center gap-3 border-t p-3 text-body text-muted-foreground",children:["The first ",Dg," of ",I.length.toLocaleString("en-US")," are listed. ",t.jsxs(B,{size:"xs",onClick:()=>A(!0),children:["Show all ",I.length.toLocaleString("en-US")]})]})]})]})]}),J&&t.jsx(Q9,{span:J,trace:d,run:e,from:G.from,now:v,reveal:R,onPick:re,onClose:ye},J.id)]})}function eH({native:e,agentId:n}){const s=[{label:"Task usage",usage:e.usage.task},...e.usage.reflection.length?e.usage.reflection.map((r,o)=>({label:`Reflection usage · turn ${o+1}`,usage:r})):[{label:"Reflection usage",usage:null}]];return t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native run details",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Native run"}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Runtime",Ld(e.runtime)],["Project",e.project],["Selector",Xv(e.selector)],["Machine",e.machine_id],["Native session",e.session_id??"Not reported"],["Model",e.model??"Unknown"],["Configuration fingerprint",e.fingerprint],["Pinned learning revision",e.learning_revision??"None supplied"]].map(([r,o])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:r}),t.jsx("dd",{className:"break-all font-mono",children:o})]},r))}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Native usage by phase",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Phase","Uncached input","Output tokens","Cache read","Cache write","Cost"].map(r=>t.jsx("th",{className:"whitespace-nowrap border-b px-2 py-2 font-semibold",children:r},r))})}),t.jsx("tbody",{children:s.map(({label:r,usage:o})=>{const i=e.runtime==="codex"?(o==null?void 0:o.input_tokens)==null||o.cache_read_tokens==null||o.cache_write_tokens==null?null:Math.max(0,o.input_tokens-o.cache_read_tokens-o.cache_write_tokens):o==null?void 0:o.input_tokens;return t.jsxs("tr",{children:[t.jsx("th",{className:"whitespace-nowrap px-2 py-2 font-normal",children:r}),[i,o==null?void 0:o.output_tokens,o==null?void 0:o.cache_read_tokens,o==null?void 0:o.cache_write_tokens].map((c,d)=>t.jsx("td",{className:"px-2 py-2 font-mono",children:c==null?"Unknown":c.toLocaleString("en-US")},d)),t.jsx("td",{className:"px-2 py-2 font-mono",children:(o==null?void 0:o.cost_usd)==null?"Unknown":_d(o.cost_usd)})]},r)})})]})}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Grading usage belongs to the separate learning run.",n&&t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{href:`#/agents/${encodeURIComponent(n)}/learning`,className:"underline underline-offset-2",children:"Open learning evidence"}),"."]})," Unreported native counters and model request totals stay unknown."]})]})}const tH={seeded:"Prepared",reflecting:"Reflecting",merged:"Saved",dropped:"Not saved"};function nH({run:e,read:n,onViewChanges:s}){var x,b,j,k,E,N,S,$;const[r,o]=p.useState({data:void 0,reading:!0}),[i,c]=p.useState(0),d=p.useRef(n);d.current=n;const u=!!n,f=e.run_id,g=(x=e.learning)==null?void 0:x.state,y=(b=e.learning)==null?void 0:b.at;p.useEffect(()=>{let _=!0;if(!u){o({data:void 0,reading:!1});return}return o(O=>({...O,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(O=>{if(O&&O.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");_&&o({data:O,reading:!1})}).catch(O=>{_&&o(M=>({...M,error:O??new Error("The learning result could not be read."),reading:!1}))}),()=>{_=!1}},[f,g,y,u,i]),p.useEffect(()=>{const _=()=>{document.hidden||c(O=>O+1)};return window.addEventListener("focus",_),document.addEventListener("visibilitychange",_),()=>{window.removeEventListener("focus",_),document.removeEventListener("visibilitychange",_)}},[]);const v=r.data,h=()=>c(_=>_+1);return t.jsxs("section",{className:"overflow-hidden border bg-card","aria-label":"Learning result",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Learning result"}),v&&t.jsx(Ne,{children:tH[v.state]??v.state}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsxs("a",{href:`#/agents/${encodeURIComponent(e.agent_id)}/learning`,className:"inline-flex items-center gap-1 text-small text-muted-foreground hover:text-primary-text",children:["Agent learning",t.jsx(pr,{className:"size-3","aria-hidden":!0})]}),u&&t.jsx(B,{size:"icon","aria-label":"Refresh learning result",disabled:r.reading,onClick:h,children:t.jsx(oa,{"aria-hidden":!0})})]})]}),r.reading&&t.jsx("p",{className:"px-5 py-3 text-body text-muted-foreground",role:"status",children:v===void 0?"Reading learning result…":"Refreshing learning result…"}),r.error!==void 0&&t.jsxs("div",{className:"space-y-2 p-4",children:[v!==void 0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Showing the last result read."}),t.jsx(en,{problem:Jt(r.error,"the learning result"),onRetry:h,className:""})]}),!u&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"Detailed learning results are unavailable in this view."}),u&&v===null&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"No learning result was recorded for this run."}),v&&t.jsxs("div",{className:"space-y-6 p-5",children:[t.jsxs("div",{children:[v.detail&&t.jsx("p",{className:"break-words text-body leading-relaxed",children:v.detail}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-label text-muted-foreground",children:[v.at&&t.jsxs("span",{children:["Updated ",vt(v.at)]}),v.reason&&t.jsxs("span",{children:["Reason: ",v.reason]})]})]}),t.jsxs("section",{"aria-label":"What it kept",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"What it kept"}),(j=v.workflows)!=null&&j.length||v.corrections?t.jsxs("ul",{className:"divide-y border",children:[(k=v.workflows)==null?void 0:k.map(_=>t.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 p-3",children:[t.jsx("code",{className:"min-w-0 break-all text-small",children:_.name}),t.jsx(Ne,{tone:_.pending?"warning":"success",children:_.pending?"Waits for your OK":"Workflow"})]},_.file)),v.corrections>0&&t.jsxs("li",{className:"p-3 text-small",children:[lb(v.corrections)," added to corrections.md"]})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:oh(v)?"Nothing kept yet.":"Nothing was kept from this run."})]}),t.jsxs("section",{"aria-label":"Learning validation",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Validation"}),(E=v.problems)!=null&&E.length||(N=v.draft_errors)!=null&&N.length?t.jsxs("ul",{className:"space-y-3",children:[(S=v.problems)==null?void 0:S.map((_,O)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:_.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[_.rule,_.path].filter(Boolean).join(" · ")})]},`problem-${O}`)),($=v.draft_errors)==null?void 0:$.map((_,O)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"mb-1 font-mono text-label text-muted-foreground",children:"Workflow draft"}),t.jsx("p",{className:"break-words text-body",children:_})]},`draft-${O}`))]}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No validation problems reported."})]}),t.jsxs("section",{"aria-label":"Learning provenance",className:"border-t pt-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h3",{className:"text-body font-semibold",children:"Provenance"}),s&&t.jsxs(B,{size:"sm",onClick:s,children:["View changes",t.jsx(pr,{"aria-hidden":!0})]})]}),t.jsxs("dl",{className:"space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Seed commit"}),t.jsx("dd",{className:"break-all font-mono",children:v.seed??"Not reported"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Merge commit"}),t.jsx("dd",{className:"break-all font-mono",children:v.merged??"Not merged"})]})]})]})]})]})}const CN=32,sH=360,rH=.7;function oH(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-CN;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-CN}const aH=(e,n)=>Math.round(Math.max(sH,Math.min(e,n*rH)));function iH(e,n,s=3e3,r=Math.min(s,lH),o=!1){const[i,c]=p.useState(null),[d,u]=p.useState(!1),f=p.useRef(e);f.current=e;const g=p.useRef(!1),y=p.useRef(!1),v=p.useRef(0),h=p.useRef(null),x=p.useRef(null),b=p.useRef(o);b.current=o,p.useEffect(()=>{o&&(x.current=null)},[o]);const j=!!e;p.useEffect(()=>{if(!j||d)return;if(n||(x.current=null),!n&&g.current&&!y.current){c(O=>O&&EN(O));return}let E=!0,N;const S=O=>{clearTimeout(N),N=setTimeout(()=>{h.current=null,_()},O),h.current=()=>S(r)};let $=!1;const _=async()=>{try{const O=await f.current();if(!E)return;g.current=!0,O.state==="live"&&!b.current&&(x.current=O.kind);const M=O.state==="none"&&O.session==="opening"&&O.kind!=="browser"&&O.kind===x.current?{...O,session:"closed"}:O;y.current=M.state==="none"&&M.session==="unopened",$=M.state==="none"&&M.session==="opening"||M.state==="live"&&M.hold==="pending",M.state==="off"?c(null):c(n?P=>dH(P,M)?P:M:EN(M))}catch(O){if(!E)return;if(O instanceof Ue&&O.status===401){u(!0),c(M=>M?{state:"signed_out"}:null);return}if(O instanceof Ue&&O.status===403){u(!0),c(null);return}}E&&n&&S($||Date.now()<v.current?r:s)};return _(),()=>{E=!1,clearTimeout(N),h.current=null}},[j,n,s,r,d]);const k=p.useCallback(E=>{var N;c(S=>S&&S.state==="live"&&S.hold!==E?{...S,hold:E}:S),v.current=Date.now()+cH,(N=h.current)==null||N.call(h)},[]);return{view:i,held:k}}const lH=400,cH=4e3,dH=(e,n)=>{var s,r;return!!e&&e.state!=="signed_out"&&e.state===n.state&&e.kind===n.kind&&e.hold===n.hold&&(e.state!=="live"||n.state==="live"&&e.viewer===n.viewer)&&(e.state!=="none"||n.state==="none"&&e.session===n.session&&((s=e.ended)==null?void 0:s.at)===((r=n.ended)==null?void 0:r.at))},EN=e=>e.state==="off"?null:e.state==="signed_out"?e:{state:"none",kind:e.kind,hold:"agent",session:e.state==="none"&&e.session==="unopened"?"unopened":"closed"},uH={browser:r1,desktop:ii,phone:u1,sandbox:pR},fH={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},mH={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function hH({runId:e,screen:n,machine:s,opens:r,followUp:o,metered:i,waitsFor:c,keptUntil:d,onTake:u,onHand:f,recordings:g=[],fileUrl:y}){const v=p.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==v.current.viewer&&(v.current={viewer:n.viewer,n:v.current.n+1});const h=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",x=(n==null?void 0:n.state)==="live"?bH(n.viewer,e):void 0,b=x&&h!=="browser"?`${x}${x.includes("#")?"&":"#"}hands=page`:x,j=uH[h],k=(n==null?void 0:n.state)==="live"?n:null,[E,N]=p.useState(!1),[S,$]=p.useState(null),_=async H=>{if(!(!H||E)){N(!0),$(null);try{$(await H())}finally{N(!1)}}},O=k&&b&&h!=="browser"?k:null,[M,P]=p.useState(!1),A=p.useRef(null),R=p.useRef(null),L=p.useRef(null),W=p.useRef(!1),U=!!(k&&b);p.useEffect(()=>{U||P(!1)},[U]);const[Y,D]=p.useState(void 0);p.useLayoutEffect(()=>{const H=A.current;if(h!=="phone"||M||!U||!H)return;const I=H.closest("[data-scroll-pane]"),V=()=>D(aH(oH(H,I),window.innerHeight));V();const J=typeof ResizeObserver=="function"&&I?new ResizeObserver(V):void 0;if(I)for(const X of[I,...I.children])J==null||J.observe(X);return window.addEventListener("resize",V),()=>{J==null||J.disconnect(),window.removeEventListener("resize",V)}},[h,M,U,S,i,v.current.n]),p.useEffect(()=>{var H,I,V;if(M){W.current=!0,(I=(H=R.current)==null?void 0:H.querySelector("button"))==null||I.focus();return}W.current&&(W.current=!1,(V=L.current)==null||V.focus())},[M]),p.useEffect(()=>{if(!M)return;const H=re=>{if(re.key==="Escape"){P(!1);return}if(re.key!=="Tab"||!R.current)return;const ae=[...R.current.querySelectorAll("button:not([disabled]), iframe")];if(!ae.length)return;const ye=ae[0],he=ae[ae.length-1],we=document.activeElement;R.current.contains(we)?re.shiftKey&&we===ye?(re.preventDefault(),he.focus()):!re.shiftKey&&we===he&&(re.preventDefault(),ye.focus()):(re.preventDefault(),ye.focus())},I=re=>{re.key==="Escape"&&P(!1)};document.addEventListener("keydown",H);const V=A.current;let J=null;const X=()=>{try{J==null||J.removeEventListener("keydown",I,!0)}catch{}try{J=(V==null?void 0:V.contentWindow)??null,J==null||J.addEventListener("keydown",I,!0)}catch{J=null}};return X(),V==null||V.addEventListener("load",X),()=>{document.removeEventListener("keydown",H),V==null||V.removeEventListener("load",X);try{J==null||J.removeEventListener("keydown",I,!0)}catch{}}},[M,v.current.n]);const G=k?h==="browser"?"browser · take over in the view below":`${mH[k.hold]} · ${h}`:"",F=O&&(O.hold==="person"?t.jsx(B,{size:"sm",variant:"solid",disabled:E,onClick:()=>void _(f),children:"Hand back"}):t.jsx(B,{size:"sm",variant:"solid",disabled:E||O.hold==="pending",onClick:()=>void _(u),children:O.hold==="pending"?"Taking over":"Take over"})),q=U&&t.jsx(B,{ref:M?void 0:L,size:"sm",variant:"ghost",onClick:()=>P(H=>!H),"aria-label":M?"Exit full window (Esc)":"Fill the window",title:M?"Exit full window (Esc)":"Fill the window","aria-pressed":M,children:M?t.jsx(rR,{className:"size-4","aria-hidden":!0}):t.jsx(i1,{className:"size-4","aria-hidden":!0})});return t.jsxs("section",{"aria-label":"Screen",className:"border",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[t.jsx(j,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:k?"Live":fH[h]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:G}),g.some(H=>!H.finished)&&t.jsx(Ne,{tone:"active",title:"A video of this screen is being recorded",children:"Recording"}),y&&g.filter(H=>H.finished).map((H,I,V)=>t.jsxs("a",{href:`${y(H.path)}?download=1`,download:!0,className:hl({variant:"ghost",size:"sm"}),"aria-label":`Export ${H.path} (${gr(H.bytes)})`,children:[t.jsx(tv,{"aria-hidden":!0})," Export",V.length>1?` ${I+1}`:""]},H.path)),!M&&q,!M&&F]}),i&&h!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:Eb}),!M&&S&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:S}),k&&b?t.jsxs("div",{ref:R,"data-testid":"screen-frame",className:M?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:M?"dialog":void 0,"aria-modal":M?!0:void 0,"aria-label":M?"The run's screen, filling the window":void 0,children:[M&&t.jsxs("div",{className:"flex items-center gap-3 border-b bg-background px-4 py-2 text-foreground",children:[t.jsx("span",{className:"flex-1 font-mono text-small",children:G}),q,F]}),M&&S&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:S}),t.jsx("iframe",{ref:A,src:b,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:M?"block min-h-0 w-full flex-1 bg-background":h==="phone"?te("mx-auto block aspect-[9/19] max-w-full bg-background",Y===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!M&&h==="phone"&&Y!==void 0?{height:`${Y}px`}:void 0},v.current.n)]}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:vH(h,n,s,r,o,c,d)})]})}const pH={approval:"Waiting for your approval.",question:"Waiting for your answer.",budget:"Waiting for you to raise the spend cap.",browser:"Waiting for you.",computer:"Waiting for you."},gH=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function xH(e,n){for(let s=e.length-1;s>=0;s-=1){const r=e[s];if(r.kind!=="phase")continue;const o=r.summary??r.text??"";if(o.startsWith(`The ${n} is ready`))return;const i=gH.exec(o);if(!i||i[1]!==n)continue;const c=Date.parse(r.timestamp);return Number.isNaN(c)?void 0:new Date(c+Number(i[2])*6e4).toISOString()}}function vH(e,n,s,r,o,i,c){if((n==null?void 0:n.state)==="live")return"The live view can't be shown here.";if((n==null?void 0:n.state)==="signed_out")return"Signed out: sign in to watch.";if(e==="sandbox")return"A sandbox has no screen. What the agent runs in it is on the timeline.";if((s==null?void 0:s.state)==="failed")return`The ${e} didn't start.${s.why?` ${s.why}`:""}`;if(r&&i&&c&&(n==null?void 0:n.state)==="none"&&!n.ended)return`${pH[i]} The ${e} is kept until ${$N(c).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${$N(n.ended.at)}). A new browser opens when the run goes on.`:n.ended.why;const d=(n==null?void 0:n.state)==="none"?n.session:void 0;return d==="unopened"?r?e==="browser"?"This run hasn't opened its browser. The agent's page shows here if it opens one.":`This run hasn't opened its ${e}. Its screen shows here if the agent opens one.`:`This run didn't open its ${e}.${o?" A follow-up opens one if the agent needs it.":""}`:r&&d==="closed"?e==="browser"?"The run's browser isn't open now. The agent's page shows here if it opens one again.":`This ${e} has been released.`:r?e==="browser"?"Waiting for the browser. The agent's page shows here once it opens one.":`Waiting for the ${e}. Its screen shows here once it is up.`:`The ${e} closed when the run ended.${o?" A follow-up opens a new one if the agent needs it.":""}`}function $N(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function bH(e,n){let s;try{s=new URL(e,location.origin).href}catch{return}const r=mr(s);if(!r)return;const o=new URL(r);return o.origin===location.origin&&o.pathname.startsWith(`/v2/runs/${encodeURIComponent(n)}/computer/live/`)?r:void 0}const Zi=e=>{var n,s;return e.status==="input_required"&&(((n=e.pending)==null?void 0:n.kind)==="browser"||((s=e.pending)==null?void 0:s.kind)==="computer")?e.pending:null},C$=e=>e.kind==="computer"?e.computer:"browser";function Bx(e,n){var s;if(e instanceof Ue&&e.code==="handoff_answered"){const r=(s=e.details)==null?void 0:s.outcome;return r==="expired"?"The ask expired before your answer: the agent was told.":r==="done"||r==="cancelled"?`It was already answered: ${r}.`:e.message}return e instanceof Ue&&e.code==="computer_not_live"?e.message:e instanceof Ue&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof Ue&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Gt(e)}`}function E$({ask:e,onAnswer:n,open:s,heading:r,compact:o=!1}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),f=p.useRef(!1),g=async y=>{if(!n||f.current)return;f.current=!0,c(!0),u(null);let v=!1;try{const h=await n(y);v=h===null,u(h)}finally{v||(f.current=!1,c(!1))}};return t.jsxs("section",{"aria-label":"Waiting for you at the computer",className:o?"px-4 py-3":"border border-warning/50 bg-warning/5 p-4",children:[r,t.jsxs("p",{className:te("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[t.jsx(ii,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",C$(e)]}),t.jsxs("div",{"data-agent-request":!0,className:te("border-l-2 border-warning/60 pl-3",o?"mt-1":"mt-2"),children:[t.jsxs("p",{className:o?"text-prose leading-snug":"text-prose leading-relaxed",children:["The agent asks you to: ",e.instruction]}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["Done when: ",e.completion_condition]})]}),t.jsx("p",{className:"mt-2 text-small font-semibold",children:"You never need to type your AgentRun password for this."}),t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:["Expires ",vt(e.expires_at)," unanswered"]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s,t.jsx("span",{className:"flex-1"}),n&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"solid",disabled:i,onClick:()=>void g("done"),children:"Done"}),t.jsx(B,{size:"sm",variant:"ghost",disabled:i,onClick:()=>void g("cancelled"),children:"Cancel"})]})]}),d&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:d})]})}function yH(e,n){var d;const s=!!n&&((d=e.learning)==null?void 0:d.state)==="merged",[r,o]=p.useState({state:"reading"}),[i,c]=p.useState(0);return p.useEffect(()=>{if(!s)return;let u=!0;return o({state:"reading"}),Promise.resolve().then(()=>n()).then(f=>{u&&o({state:"read",changes:WI(f)})},f=>{u&&o({state:"failed",error:f??new Error("unknown")})}),()=>{u=!1}},[e.run_id,s,i]),s?{got:r,retry:()=>c(u=>u+1)}:null}function wH({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Jt(e.error,"what it changed"):null;return t.jsxs("section",{className:"border","aria-label":"What it changed",children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What it changed"}),e.state==="reading"&&t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:"Reading what it changed…"}),s&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 text-body",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't read what it changed: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]}),e.state==="read"&&t.jsx("ul",{className:"divide-y",children:e.changes.map(r=>t.jsx("li",{children:t.jsx(jH,{change:r})},r.file))})]})}function jH({change:e}){const[n,s]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-4 py-3 text-left hover:bg-accent/40","aria-expanded":n,onClick:()=>s(r=>!r),children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block break-words text-lead","data-said":!0,children:e.said}),t.jsx("span",{className:"mt-0.5 block break-all font-mono text-label text-muted-foreground",children:e.file})]}),t.jsx(As,{className:te("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",n&&"rotate-90"),"aria-hidden":!0})]}),n&&(e.withheld?t.jsx("p",{className:"px-4 pb-3 text-body text-muted-foreground",children:e.withheld}):t.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2",children:[t.jsx(_N,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(_N,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function _N({name:e,lines:n,none:s}){return t.jsxs("div",{className:"min-w-0 border","data-side":e,children:[t.jsx("p",{className:"caps border-b px-3 py-2 text-label text-muted-foreground",children:e==="before"?"Before":"After"}),n===null?t.jsx("p",{className:"px-3 py-2 text-body text-muted-foreground",children:s}):t.jsx("pre",{className:"max-h-80 overflow-auto py-2 font-mono text-small leading-[1.7]",children:n.map((r,o)=>t.jsxs("span",{className:te("flex min-h-[1.7em] px-3",r.mark==="added"&&"bg-primary/10",r.mark==="removed"&&"bg-destructive/10"),children:[t.jsx("span",{"aria-hidden":!0,className:"w-4 shrink-0 select-none text-muted-foreground",children:r.mark==="added"?"+":r.mark==="removed"?"−":""}),r.mark==="added"&&t.jsx("span",{className:"sr-only",children:"Added line: "}),r.mark==="removed"&&t.jsx("span",{className:"sr-only",children:"Taken out: "}),t.jsx("span",{"data-mark":r.mark,className:te("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},o))})]})}const kH=4e3,NH=e=>!!e.learning&&e.learning.reason!=="use",SH="The agent looks back on your words: what was wrong, and what a right answer does.",CH="A look-back needs words. Without them the grade is still kept.",EH='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',TN='Write it as a JSON object, like {"total": 42}, or leave it empty.';function $H(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:TN}}catch{return{error:TN}}}function _H(e){const n=Jt(e,"the grade");return e instanceof Ue&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const TH="The review could not run.";function RH(e,n){return e.feedback&&e.feedback_status==="not_run"?TH:e.feedback==="correction"?n?"Your words are being added to its corrections.":"Your words were added to its corrections.":"Kept for this agent."}function AH({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[o,i]=p.useState("auto"),[c,d]=p.useState(""),[u,f]=p.useState(""),[g,y]=p.useState(!1),[v,h]=p.useState(!1),[x,b]=p.useState(null),j=p.useRef(!1),k=lo(e.status),E=n!=null&&n.feedback?n.feedback_status:null,N=E==="running"||E==="ended"&&oh(e.learning??void 0);if(!NH(e)||!k&&!n)return null;const S=o==="auto"?n?"closed":"choose":o,$=k&&!N,_=$H(u),O=n?RH(n,N):null,M=async P=>{if(j.current||!s)return;const A=P?"":c.trim();if(!P&&_.error){y(!0);return}j.current=!0,h(!0),b(null);try{await s({correct:P,...A?{label:A}:{},...!P&&_.value?{expected:_.value}:{}}),i("auto"),d(""),f(""),y(!1)}catch(R){b(_H(R))}j.current=!1,h(!1)};return t.jsxs("section",{className:"border","aria-label":"Grade",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Grade"}),n&&t.jsxs(Ne,{tone:n.correct?"success":"error",children:["Graded ",n.correct?"right":"wrong"]}),N&&t.jsx(Ne,{tone:"active",children:"Reviewing"}),t.jsx("span",{className:"flex-1"}),n&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:vt(n.graded_at)})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[O&&t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[t.jsx("p",{className:"text-body",role:"status",children:O}),r&&!!(n!=null&&n.feedback)&&t.jsx(B,{type:"button",size:"xs",variant:"ghost",onClick:r,children:"Open the Timeline"})]}),$&&S==="closed"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:!s,onClick:()=>{i("choose"),b(null)},children:"Grade again"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"A new grade replaces this one."})]}),$&&S==="choose"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"Was the answer right? Your grade teaches the agent."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:v||!s,onClick:()=>void M(!0),children:"Right"}),t.jsx(B,{type:"button",size:"sm",disabled:v||!s,onClick:()=>{i("wrong"),b(null)},children:"Wrong"}),n&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:v,onClick:()=>i("closed"),children:"Cancel"}),v&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),$&&S==="wrong"&&t.jsxs("form",{className:"space-y-4","aria-label":"Grade wrong",onSubmit:P=>{P.preventDefault(),M(!1)},children:[t.jsx(St,{label:"What was wrong?",note:SH,warning:c.trim()?void 0:CH,children:t.jsx(on,{value:c,onChange:P=>d(P.target.value),maxLength:kH,rows:3,disabled:v,className:"resize-y font-sans text-lead"})}),t.jsx(St,{label:"Correct answer",optional:!0,note:EH,error:g?_.error:void 0,children:t.jsx(on,{value:u,onChange:P=>{f(P.target.value),y(!1)},rows:2,disabled:v,spellCheck:!1,placeholder:'{"total": 42}',className:"resize-y"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:v,children:"Send grade"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:v,onClick:()=>{i(n?"closed":"choose"),y(!1)},children:"Cancel"}),v&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),x&&t.jsxs("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:["Your grade wasn't taken: ",x]})]})]})}const OH=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function MH(e,n,s){const r=!!s&&!!e.learning,[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(0);p.useEffect(()=>{if(!r)return;let j=!0;return Promise.resolve().then(()=>s()).then(k=>{j&&(i(k??null),f(0))},()=>{j&&(i(null),f(k=>k+1))}),()=>{j=!1}},[e.run_id,r,n,e.ended_at,g]);const v=p.useCallback(({expected:j,...k})=>{d({run:k.run_id,grade:{...k,feedback_status:k.feedback?"running":null}})},[]),h=r?o:null,x=OH((h==null?void 0:h.graded)??null,(c==null?void 0:c.run)===e.run_id?c.grade:null),b=r&&(x==null?void 0:x.feedback_status)==="running";return p.useEffect(()=>{if(!b||u===0||u>LH)return;const j=setTimeout(()=>y(k=>k+1),hx(u-1));return()=>clearTimeout(j)},[b,u]),{read:h,grade:x,graded:v}}const LH=8,PH=e=>e===1?"once":e===2?"twice":`${e} times`;function IH({used:e,agentId:n}){return e!=null&&e.workflows.length?t.jsxs("section",{className:"border","aria-label":"What it used of what it learned",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"What it used of what it learned"}),t.jsx("span",{className:"flex-1"}),t.jsx("a",{href:ub(n),className:"font-mono text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:"Open the Learning tab"})]}),t.jsx("ul",{className:"divide-y",children:e.workflows.map(s=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[t.jsx(li,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Workflow"}),t.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Called ",PH(s.calls)]}),s.failed>0&&t.jsxs(Ne,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))})]}):null}const Ki=(e,n={})=>({type:"object",properties:{op:{const:e,description:`Action operation. Use "op": "${e}"; never use a "kind" field.`},id:{type:"string",description:'Bracketed ID copied from the latest snapshot, as a string. Use "id"; never use "ref".'},...n},required:["op","id",...Object.keys(n).filter(s=>s!=="delay")],additionalProperties:!1}),Fr=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),zH={name:"snapshot",label:"Browser: snapshot",description:"Capture the active page's accessibility tree and hydrate its displayed IDs for subsequent run actions. Every call replaces the active page's ID map. On an agent's browser computer a frame another site runs in its own process is not in the tree: the snapshot names each frame it left out.",parameters:Fr({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},DH=Object.freeze({cookies:"It keeps cookies across pages: use it for a page that depends on an earlier one, or one that sets cookies.",signIns:"This browser opens with this agent's saved browser profile: a site the agent was signed in to there opens signed in here, and only here (web_fetch reads every page signed out). Use it for anything behind a sign-in, or a page that depends on an earlier one."}),FH=e=>`Browse and automate websites in the persistent browser. ${DH.cookies} Navigate with JavaScript such as await page.goto("https://example.com"), or with a goto action; there is no separate navigate or start tool. Execute either a JavaScript workflow against the Stagehand Playwright facade or a batch of actions using IDs from the latest snapshot. Code is the body of an async function with page, context and browser in scope: \`return\` the value you want back. Provide exactly one of code or actions. An agent's browser computer (Browserbase, Kernel or Local Chrome) takes actions only: code is refused there. Each action must use "op" (never "kind") and "id" (never "ref"), but goto, which takes a "url". Copy the bracketed snapshot ID as a string. Examples: {"actions":[{"op":"goto","url":"https://example.com"}]}, {"actions":[{"op":"click","id":"1-42"}]}, {"actions":[{"op":"fill","id":"2-14","value":"Miami"}]}, {"actions":[{"op":"select","id":"3-9","values":"Lowest price"}]}.`,UH={name:"run",label:"Browser: run",description:FH(),parameters:Fr({code:{type:"string",minLength:1},actions:{type:"array",description:'Snapshot actions with the exact fields "op" and "id" (goto: "op" and "url"). Do not use "kind" or "ref".',items:{oneOf:[{type:"object",properties:{op:{const:"goto",description:'Action operation. Use "op": "goto"; never use a "kind" field.'},url:{type:"string",description:"The http or https URL to open in the active page (or about:blank)."}},required:["op","url"],additionalProperties:!1},Ki("click"),Ki("hover"),Ki("fill",{value:{type:"string"}}),Ki("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Ki("press",{key:{type:"string"}}),Ki("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},WH={name:"screenshot",label:"Browser: screenshot",description:'Capture a screenshot of the active page. For size-constrained MCP clients, prefer a viewport JPEG: {"type":"jpeg","quality":40,"fullPage":false}.',parameters:Fr({fullPage:{type:"boolean"},type:{type:"string",enum:["png","jpeg"]},quality:{type:"number",minimum:0,maximum:100},ask:{type:"string",description:"What you want to know from this capture. It travels with the image, so a host can answer it from the pixels when your model cannot see them."},clip:{...Fr({x:{type:"number"},y:{type:"number"},width:{type:"number"},height:{type:"number"}},["x","y","width","height"]),description:"Capture only this region, in CSS pixels from the viewport's top-left corner (what the page shows now). Width and height 0 mean no clip: leave it out, or send zeros, to capture the whole viewport. A region that leaves the viewport is refused. Use one of clip, id or selector; an empty id or selector means none."},id:{type:"string",description:"Capture only this element: a bracketed ID from the latest snapshot, as a string. It is scrolled into view first. It must match one element."},selector:{type:"string",description:"Capture only the element this CSS selector matches (when there is no snapshot ID for it). It is scrolled into view first. It must match exactly one element."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"image",listedWhen:"always"},HH={name:"browser_read",label:"Browser: read",description:"Read the CURRENT page of the browser as evidence and persist it under evidence/ with the page URL: `what` = markdown (the whole page as markdown, the default for citing), text, html, url, or title. This is the citable door for anything you saw in the browser: snapshot, screenshot and run return values are not evidence. Cite the returned URL. A browser page URL in a receipt keeps its query names but shows every value replaced by a redaction marker, the word redacted in square brackets (the site chose where the browser went, and a value in it can be a credential); web_fetch keeps a query value that is in the URL you asked for.",parameters:Fr({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},BH={name:"browser_release",label:"Browser: release",description:"Release the browser session now. You do not need it to finish: the session is released when your work ends and after a stretch with no browser call. Call it only to drop a session mid-task (to start the next browser call on a fresh session, or before a long stretch of work that needs no browser). Your next browser call launches a fresh session (a new tab, no cookies from the old one), so finish a flow before releasing.",parameters:Fr({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},qH={name:"browser_relaunch",label:"Browser: relaunch",description:"Replace the browser session with a fresh one, after a site blocked it (403/429, a CAPTCHA wall, a bot-detection page, an empty page that should have content). The new session is Verified whenever the run's sessions are, and a relaunch never lowers that: `verified: true` asks for a Verified session where the run's sessions are not (a Verified browser carries a stronger identity and costs more). Use `geolocation` to browse as a visitor from a given place: the proxy egresses from that country (ISO alpha-2), optionally a US state and a city, so geo-aware sites (storefront region, prices, payment methods, content availability) show what a local sees. Page state is lost; navigate again with run.",parameters:Fr({verified:{type:"boolean",description:"true launches the new session as a Verified browser. false, or leaving it out, keeps the run's setting: a Verified run's sessions stay Verified."},geolocation:{type:"object",additionalProperties:!1,description:"Proxy egress location for the new session. Omit to keep the run's default.",properties:{country:{type:"string",description:"ISO 3166-1 alpha-2 country code, e.g. GB, US, DE."},state:{type:"string",description:"US state abbreviation, United States only."},city:{type:"string",description:"City name, e.g. LONDON or SAO_PAULO."}},required:["country"]}}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},GH={name:"browser_request_handoff",label:"Browser: hand to a person",description:"Hand the browser to a person for a step only a human can do: a CAPTCHA you cannot pass, a sign-in that needs their device, a confirmation only they can give. Say in instruction what they should do and in completion_condition what the page shows once it is done. The call waits until the person finishes, cancels or the request expires; while they have the browser, every other browser call fails with waiting_for_human. The same request_id retries the same request. Afterwards take a snapshot and check the completion condition on the page before acting.",parameters:Fr({request_id:{type:"string",pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",description:"A UUID you choose for this request; the same one retries the same request."},instruction:{type:"string",minLength:1,maxLength:2e3,description:"What the person should do, in plain words."},completion_condition:{type:"string",minLength:1,maxLength:1e3,description:"What the page shows once the step is done, for you to verify afterwards."}},["request_id","instruction","completion_condition"]),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"handoff"},KH={name:"browser_downloads",label:"Browser: downloads",description:"Copy the files this browser session downloaded into the workspace under downloads/, with downloads/manifest.json listing each file's SHA-256. Returns the files fetched now, those fetched before and those skipped with why, never their bytes; open a fetched file with read. A file the browser is still downloading is skipped as still downloading: call again to fetch it.",parameters:Fr({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},VH={name:"browser_upload",label:"Browser: upload",description:"Choose one workspace file in a file input on the page, as a person picking it would; nothing is submitted. Returns the file's name, size and SHA-256; submit the form with run afterwards.",parameters:Fr({path:{type:"string",minLength:1,maxLength:1e3,description:"The file's path relative to the workspace, for example reports/q3.pdf."},selector:{type:"string",minLength:1,maxLength:500,description:'CSS selector of the <input type="file">, for example input[type=file].'}},["path","selector"]),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"upload"},YH=Object.freeze([zH,UH,WH,HH,BH,qH,GH,KH,VH]),QH=Object.freeze(YH.map(e=>e.name)),JH={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","com.android.deskclock":"Clock","com.android.contacts":"Contacts","com.android.documentsui":"Files","org.wikipedia":"Wikipedia","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function XH(e){const n=e.split(".").at(-1)||e;return JH[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const ZH=new Set(["enter","tab","space","backspace","delete","escape","insert","up","down","left","right","home","end","pageup","pagedown","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","shift","ctrl","alt","super","capslock"]),e7=new Set(["ctrl","alt","super"]);function t7(e){if(typeof e!="string"||!e)return;const s=(e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+")).map(r=>r.toLowerCase());return s.some(r=>e7.has(r))||s.every(r=>ZH.has(r))?e:void 0}const n7=["press","set","perform","click","type","key","nav","scroll","drag"];function s7(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=n7.find(u=>u in s)??"step",o=r==="type"?s.into:s[r],i=typeof o=="string"?n(o):void 0,c=r==="key"?t7(s.key):void 0,d=r==="nav"&&typeof s.nav=="string"?s.nav:void 0;return{do:r,...i?{on:i}:{},...c?{keys:c}:{},...d?{nav:d}:{}}}const r7={textbox:"text box",searchbox:"search box",checkbox:"check box",combobox:"pop-up",switch:"switch",slider:"slider",list:"list",table:"table",scrollarea:"scroll area",window:"window",dialog:"dialog",menu:"menu",toolbar:"toolbar",image:"image",text:"text",heading:"heading",group:"group",progressbar:"progress bar"},o7=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function a7(e){if(!e)return;const n=r7[e.role]??(e.role==="generic"?"element":e.role);return e.name?o7.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const i7={s:["Saved","save"],a:["Selected all","select all"],c:["Copied","copy"],v:["Pasted","paste"],x:["Cut","cut"],z:["Undid","undo"],w:["Closed the window","close the window"],q:["Quit","quit"],t:["Opened a new tab","open a new tab"]},l7={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},Fg={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},yn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function c7(e){const n=e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+"),s=n.at(-1)??"",r=n.slice(0,-1).map(c=>c.toLowerCase()),o=n.length===1&&Fg[s.toLowerCase()]?Fg[s.toLowerCase()]:`${r.map(c=>l7[c]??`${c}+`).join("")}${Fg[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?i7[s.toLowerCase()]:void 0;return i?yn(i[0],i[1],` (${o})`):yn("Pressed","press",` ${o}`)}const d7={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function u7(e){const n=a7(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return yn("Pressed","press",s("an element"));case"click":return yn("Clicked","click",n?` ${n}`:" at a point");case"set":return yn("Set","set",s("an element"));case"perform":return yn("Acted on","act on",s("an element"));case"type":return n?yn("Typed into","type into",` ${n}`):yn("Typed text","type text");case"key":return e.keys?c7(e.keys):yn("Pressed a key","press a key");case"nav":{const[r,o,i]=e.nav&&d7[e.nav]||["Navigated","navigate",""];return yn(r,o,i)}case"scroll":return n?yn("Scrolled","scroll",` ${n}`):yn("Scrolled","scroll");case"drag":return yn("Dragged","drag"," across the screen");default:return yn("Acted","act")}}function RN(e){const n=u7(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const AN=3,qx=e=>e[0].toLowerCase()+e.slice(1);function f7(e){const n=e.slice(0,AN).map(RN),s=e.slice(AN),r=s.findIndex(i=>i.error!==void 0),o=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(qx),...o>0?[`+${o} more`]:[],...r<0?[]:[qx(RN(s[r]))]].join(", ")}const m7={"screen.shot":["Took a screenshot","take a screenshot"],"screen.watch":["Watched the screen","watch the screen"],"input.actions":["Used the pointer and keys","use the pointer and keys"],"apps.list":["Listed the apps","list the apps"],"files.read":["Read a file","read a file"],"files.write":["Wrote a file","write a file"],"files.list":["Listed a folder","list a folder"],"files.stat":["Looked up a file","look up a file"],"exec.run":["Ran a command","run a command"],"process.start":["Started a process","start a process"],ping:["Checked the computer","check the computer"]};function Ir(e){const n=e.app?XH(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return yn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return yn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return yn("Looked at","look at",` ${n??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:f7(e.steps),tried:""}:e.ok?yn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):yn("Acted on","act on",` ${n??"the computer"}`);default:{const[o,i]=m7[e.method]??[e.method,e.method];return yn(o,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const h7=e=>e.map((n,s)=>s===0?Ir(n):qx(Ir(n))).join(", "),$$='\\s"`<>\\\\',p7=new RegExp(`https?://[^${$$}|]+`,"gi"),g7=new RegExp(`https?://[^${$$}]+`,"gi"),x7=".,;:!?*)]}'",v7={")":"(","]":"[","}":"{"};function b7(e){const n={"(":0,")":0,"[":0,"]":0,"{":0,"}":0};for(const r of e)r in n&&(n[r]+=1);let s=e.length;for(;s>0&&x7.includes(e[s-1]);s--){const r=e[s-1],o=v7[r];if(o&&n[o]>=n[r])break;o&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${p7.source}`,"gi");const na=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,pn=e=>typeof e=="string"?e:void 0,si=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,_$=e=>e.split(`
699
+ `).map(n=>n.trim()).find(Boolean)??"";function km(e){try{return na(JSON.parse(e))}catch{return}}const y7=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function pd(e){const n=y7.exec(e.trim());return si(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const w7="…",j7=/https?:\/\//gi,k7=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,N7=/(https?:\/\/)[^@/?#\s]*@/gi,S7=/[A-Za-z0-9]/;function Xb(e){return e.replace(g7,n=>{const s=[0];let[r,o]=[0,!1];for(const i of n.matchAll(j7)){if(i.index===0)continue;for(;r<i.index;r++)o||(o=n[r]==="?"||n[r]==="#");if(o)continue;let c=!1;for(let d=i.index-1;d>s.at(-1)&&!S7.test(n[d]);d--)c||(c=n[d]==="'");c&&s.push(i.index)}return s.map((i,c)=>C7(n.slice(i,s[c+1]??n.length))).join("")})}function C7(e){const n=b7(e).length,s=k7.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(N7,"$1"),o=[...new Set((s[4]??"").split("&").map(i=>r(i.split("=")[0])).filter(Boolean))];return`${s[1]}${r(`${s[2]}${s[3]}`)}${o.length?`?${o.map(i=>`${i}=${w7}`).join("&")}`:""}${e.slice(n)}`}const E7=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),$7=new Map,_7=new Map,T$=new Map,T7=new Set;function gn(e,n,s,{name:r,saysFailure:o}={}){$7.set(e,n),s&&_7.set(e,s),r&&T$.set(e,r),o&&T7.add(e)}const R7=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,A7=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,O7=e=>{const n=A7.exec(e)??R7.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},M7=e=>T$.get(e)??O7(e)??e,L7=new Map;function Zb(e,n){L7.set(e,n)}const P7=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...P7];const ey=e=>pn(e.path)??pn(e.file_path),I7=/page\.goto\(\s*["'`]([^"'`]+)/;gn("read",e=>`Read ${ey(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});gn("write",e=>`Wrote ${ey(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});gn("edit",e=>`Edited ${ey(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});gn("bash",e=>`Ran \`${si(Xb(_$(pn(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const R$=e=>{const n=e&&na(km(e.text)??km(_$(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=pn(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:pn(n.error)??pn(n.message)??"no detail"}},z7=(e,n)=>`${R$(n)?"Tried to fetch":"Fetched"} ${pd(pn(e.url)??"a page")}`,D7={many:e=>`Fetched ${e} pages`,subject:e=>e?pd(e):void 0},F7=e=>{const n=R$(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};gn("web_fetch",z7,D7,{name:"Fetch web pages"});Zb("web_fetch",F7);gn("web_search",e=>{const n=pn(e.query);return n?`Searched the web for "${si(Xb(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${si(e,40)}"`:void 0},{name:"Search the web"});Zb("web_search",e=>{var s;const n=pn((s=na(km(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});gn("browser_read",(e,n)=>{var r;const s=n&&((r=/^title: (.+)$/m.exec(n.text))==null?void 0:r[1]);return s?`Read the page "${si(Xb(s),60)}"`:"Read the page"},{many:e=>`Read ${e} pages`,subject:(e,n)=>{var r;const s=n&&((r=/^url: (\S+)/m.exec(n))==null?void 0:r[1]);return s?pd(s):void 0}},{name:"Read the browser's page"});gn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});gn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});gn("run",(e,n)=>{var i,c;const s=(i=I7.exec(pn(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${pd(s)}`;const r=(c=na(n==null?void 0:n.details))==null?void 0:c.sent,o=Array.isArray(r)?r.flatMap(d=>{const u=na(d),[f,g]=[pn(u==null?void 0:u.method),pn(u==null?void 0:u.url)];return f&&g?`${f} ${pd(g)}`:[]}):[];return o.length?`Acted on the page (${o.length} request${o.length===1?"":"s"} sent: ${E7(o)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});gn("browser_downloads",(e,n)=>{var o;const s=n&&((o=km(n.text))==null?void 0:o.fetched),r=Array.isArray(s)?s.flatMap(i=>{var c;return pn((c=na(i))==null?void 0:c.name)??[]}):[];return r.length===1?`Downloaded ${r[0]}`:r.length?`Downloaded ${r.length} files`:"Downloaded files"},{many:e=>`Downloaded files ${e} times`},{name:"Download files in the browser"});gn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});gn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});gn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});gn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});gn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const U7=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,W7=e=>{if(e!==void 0)try{return pn(JSON.parse(e))}catch{return}};function A$(e){var s;const n=new Map;for(const r of(e??"").split(`
700
+ `)){const o=U7.exec(r);if(!o)continue;const i=W7(o[3]),c=(s=/^refused \([^)]*\): (.*)$/.exec(o[4]))==null?void 0:s[1],d=o[2]===void 0?void 0:{role:o[2],...i?{name:i}:{}};n.set(Number(o[1]),{...d?{on:d}:{},...c!==void 0?{refused:c}:{}})}return n}function H7(e,n){return{...s7(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}gn("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=na(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...pn(e.app)?{app:pn(e.app)}:{}};if(n!=null&&n.isError)return Ir({...r,ok:!1});const o=n===void 0?void 0:A$(n.text),i=o===void 0?s:s.filter((u,f)=>o.has(f+1));if(s.length>0&&i.length===0)return Ir({...r,ok:!1});const c=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return Ir({...r,ok:!0,steps:i.map((u,f)=>H7(u,o==null?void 0:o.get(f+1))),...c==="met"||c==="unmet"?{expect:c}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Act on the computer",saysFailure:!0});Zb("computer_act",e=>{for(const[n,s]of A$(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const ON=/^state \S+ · (\S+)/,B7=/^screen \S+ px · (?:\S+ in front|no app in front)/;gn("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!ON.test(n.text)){const o=B7.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),c=o?pn(e.app):void 0;return h7([...c?[i("apps.launch",c)]:[],i("screen.shot"),...o?[i("apps.list")]:[]])}const s=pn(e.app)??(n&&((r=ON.exec(n.text))==null?void 0:r[1]));return Ir({method:"ui.observe",ok:(n==null?void 0:n.isError)!==!0,...s?{app:s}:{}})},{many:e=>`Looked at the screen ${e} times`},{name:"Look at the computer",saysFailure:!0});gn("computer_screenshot",(e,n)=>Ir({method:"screen.shot",ok:(n==null?void 0:n.isError)!==!0}),{many:e=>`Took ${e} screenshots`},{name:"Take screenshots of the computer",saysFailure:!0});const MN={"input.act":"input.actions","apps.list":"apps.list","apps.open":"apps.launch","shell.run":"exec.run","processes.start":"process.start","files.read":"files.read","files.write":"files.write","files.list":"files.list","files.stat":"files.stat"};gn("computer_op",(e,n)=>{var i;const s=pn(e.op),r=s!==void 0&&Object.hasOwn(MN,s)?MN[s]:void 0;if(!r)return n!=null&&n.isError?"Could not act on the computer":"Acted on the computer";const o=r==="apps.launch"?pn((i=na(e.args))==null?void 0:i.id):void 0;return Ir({method:r,ok:(n==null?void 0:n.isError)!==!0,...o?{app:o}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Use the computer's apps, shell and files",saysFailure:!0});gn("computer_script",(e,n)=>{var r;const s=(r=pn(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${si(s,120)}”`:"Could not run a script on the computer":s?si(s,120):"Ran a script on the computer"},{many:e=>`Ran ${e} scripts on the computer`},{name:"Run scripts on the computer",saysFailure:!0});const q7=["schedule","webhook","slack","github","composio","email","feed"];new Set(q7);const G7=":feedback",K7=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(G7))===!0},V7={user_message:h1,thinking:Xc,tool_use:Gg,tool_result:Gg,waiting:nv,usage:ev,final_answer:ai,phase:s1,error:ul,decision:uR,text_block:sR,tool_approval_requested:d1},LN=e=>{var n;return e.kind==="tool_approval_requested"?(n=/\n\n(Not sent: [\s\S]*)$/.exec(e.text??""))==null?void 0:n[1]:void 0},PN=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),ty=e=>e.origin==="server",O$=e=>e.origin==="trigger",M$=e=>{var i;const n=e.summary??"",s=(i=e.trigger)==null?void 0:i.name,r=s?n.indexOf(` ${s}: `):-1;if(s&&r>0&&!n.slice(0,r).includes(" "))return{who:n.slice(0,r+1+s.length),said:n.slice(r+s.length+3).trimStart()};const o=/^([^:]+):\s*/.exec(n);return o?{who:o[1],said:n.slice(o[0].length)}:{who:null,said:n}};function Gx(e){const n=e.split(/(\*\*[^*\n]+?\*\*|`[^`\n]+`|\[[^\]\n]+\]\((?:[^()\s]|\([^()\s]*\))+\)|<https?:\/\/[^>\s]+>)/);return n.length===1?e:n.map((s,r)=>r%2===0?s:s.startsWith("`")?t.jsx("code",{className:"font-mono",children:s.slice(1,-1)},r):s.startsWith("[")?t.jsx(p.Fragment,{children:Gx(s.slice(1,s.indexOf("](")))},r):s.startsWith("<")?s.slice(1,-1):t.jsx("strong",{className:"font-semibold",children:Gx(s.slice(2,-2))},r))}const Y7=e=>{var r;const n=O$(e)?M$(e).said:(e.summary??"").replace(ty(e)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(e.kind==="user_message"&&n.startsWith("{"))try{return Object.entries(JSON.parse(n)).map(([o,i])=>`${o}: ${typeof i=="string"?i:JSON.stringify(i)}`).join(" · ")}catch{}const s=(e.text??"").split(`
701
+ `).filter(o=>o.trim()).length>1?"…":"";return e.kind==="final_answer"?!n.trim()&&!((r=e.text)!=null&&r.trim())?X2:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},gd=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,Q7=new Set(QH),J7=new Map(Object.entries({read:"Read",write:"Write",edit:"Edit",multiedit:"Edit",apply_patch:"Edit",notebookedit:"Edit",bash:"Shell",shell:"Shell",local_shell:"Shell",exec_command:"Shell",web_fetch:"Fetch",webfetch:"Fetch",fetch:"Fetch",web_search:"Search",websearch:"Search",ls:"List files",glob:"Find files",find:"Find files",grep:"Search files",ask_person:"Question",submit:"Answer",codemode:"Script",todowrite:"To-dos",task:"Subagent",skill:"Skill"}));function X7(e){const n=J7.get(e.toLowerCase());if(n)return n;const s=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s?s[0].toUpperCase()+s.slice(1):e}const IN=e=>e&&(Sz(e)??(Q7.has(e)?M7(e):X7(e))),zN=e=>ty(e)?"AgentRun":O$(e)?M$(e).who??"Trigger":K7(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:IN(e.tool_name)??"Tool",tool_result:IN(e.tool_name)??"Result",waiting:"Waiting for you",usage:"Usage",final_answer:"Answer",phase:"Phase",error:"Error",decision:"Decision",text_block:"Text",tool_approval_requested:"Your approval",learning:"Learning"}[e.kind]??e.kind,Z7={budget:"Paused at cap"};function eB({step:e,last:n,ended:s,waitingChip:r,files:o,onOpen:i}){var b,j;const c=e.row,[d,u]=p.useState(!1),g=EL(c)?n1:V7[c.kind]??s1,y=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":Y7(c),v=e.above?null:e.detail??R2(c),h=v&&v.trim()!==y.trim()?v:null,x=O2(c);return t.jsxs("li",{className:"relative flex gap-3",children:[t.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[t.jsx("span",{className:te("mt-3 flex size-7 items-center justify-center border bg-background",(c.kind==="waiting"||PN(c))&&"border-warning/60 text-warning-text",x&&"border-destructive/60 text-destructive-text"),children:t.jsx(g,{className:"size-3.5","aria-hidden":!0})}),!n&&t.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),t.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[t.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>u(k=>!k),"aria-expanded":d,disabled:!h,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[t.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:zN(c),children:zN(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",yL(c.usage,{ended:s})]}),c.kind==="waiting"&&t.jsx(Ne,{tone:"warning",children:r??"Input required"}),PN(c)&&t.jsx(Ne,{tone:"warning",children:"Approval required"}),x&&t.jsx(Ne,{tone:"error",children:"Error"}),A2(c)&&t.jsx(Ne,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&t.jsx(Ne,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:gd(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${gd(Math.max(0,Date.parse(e.until)-Date.parse(c.timestamp)))}`:""]})]}),t.jsx("span",{className:te("mt-0.5 block break-words text-prose leading-snug",ty(c)&&"text-muted-foreground"),children:Gx(y)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),LN(c)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:LN(c)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:ti(c.timestamp)}),h&&t.jsx(As,{className:te("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",d&&"rotate-90"),"aria-hidden":!0})]}),d&&h&&c.tool_name&&t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:c.tool_name}),d&&h&&c.kind==="final_answer"&&t.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:Iv(k=>{const E=o==null?void 0:o.find(N=>N.path===k);E&&(i==null||i(E))}),dangerouslySetInnerHTML:{__html:Ko(h,i&&o?{paths:o.map(k=>k.path)}:void 0)}}),d&&h&&c.kind!=="final_answer"&&t.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:h}),(b=c.learned_nodes)!=null&&b.length?t.jsx(sB,{nodes:c.learned_nodes}):null,(j=c.computer_calls)!=null&&j.length?t.jsx(tB,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function tB({calls:e,dropped:n}){const[s,r]=p.useState(!1),o=e.filter(u=>!u.ok).length,i=e.length+n,c=[`${i} computer ${i===1?"call":"calls"}`,...o?[`${o} failed`]:[]].join(" · "),d=Date.parse(e[0].started_at);return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>r(u=>!u),"aria-expanded":s,"aria-label":`${s?"Hide":"Show"} the computer calls`,children:[t.jsx(As,{className:te("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(ii,{className:"size-3","aria-hidden":!0}),c]}),s&&t.jsxs("ol",{"aria-label":"The computer calls",className:"mt-2 divide-y border bg-card",children:[e.map((u,f)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsxs("span",{className:"w-14 shrink-0 font-mono text-label text-muted-foreground",children:["+",gd(Math.max(0,Date.parse(u.started_at)-d))]}),t.jsx("span",{className:te("min-w-0 flex-1 truncate text-body",!u.ok&&"text-destructive-text"),title:Ir(u),children:Ir(u)}),!u.ok&&u.code&&t.jsx("span",{className:"shrink-0 font-mono text-label text-destructive-text",children:u.code}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:gd(u.ms)})]},f)),n>0&&t.jsxs("li",{className:"px-3 py-1.5 text-body text-muted-foreground",children:[n," more not kept"]})]})]})}const nB={ok:"success",failed:"error",escalated:"warning"};function sB({nodes:e}){const[n,s]=p.useState(!1),r=Object.entries(e.reduce((i,c)=>({...i,[c.status]:(i[c.status]??0)+1}),{})).filter(([i])=>i!=="ok"),o=[`${e.length} ${e.length===1?"node":"nodes"}`,...r.map(([i,c])=>`${c} ${i}`)].join(" · ");return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>s(i=>!i),"aria-expanded":n,"aria-label":`${n?"Hide":"Show"} the workflow's ${e.length===1?"node":"nodes"}`,children:[t.jsx(As,{className:te("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(li,{className:"size-3","aria-hidden":!0}),o]}),n&&t.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((i,c)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsx("span",{"data-status":i.status,className:"contents",children:t.jsx(Ne,{tone:nB[i.status]??"muted",className:"w-[5.5rem] justify-center",children:i.status})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:i.label,children:i.label}),t.jsx("span",{"data-kind":!0,className:"font-mono text-label text-muted-foreground",title:RC(i)||void 0,children:vb(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:gd(i.duration_ms)})]},c))})]})}function rB({rows:e,live:n,fold:s=6,asking:r,waitingOn:o,files:i,onOpen:c,ended:d=!1}){var b;const u=o==="budget"?e.findLastIndex(j=>j.paused===!0):-1,f=u>=0?(b=e.slice(u+1).findLast(j=>j.kind==="waiting"))==null?void 0:b.id:void 0,[g,y]=p.useState(!1),v=$L(e).map(j=>r&&j.row.id===r?{...j,above:!0}:j),h=g?0:Math.max(0,v.length-s),x=v.slice(h);return e.length?t.jsxs("div",{children:[h>0&&t.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>y(!0),children:[t.jsx(As,{className:"size-3","aria-hidden":!0})," ",h," earlier ",h===1?"step":"steps"]}),t.jsx("ol",{children:x.map((j,k)=>t.jsx(eB,{step:j,last:k===x.length-1&&!n,ended:d,waitingChip:j.row.id===f&&o?Z7[o]:void 0,files:i,onOpen:c},j.row.id))}),n&&t.jsx(Kx,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(Kx,{title:n?"The run is starting":"Nothing on the timeline",note:n?"Steps appear here as the agent works.":"This run recorded no steps.",spin:n})}function Kx({title:e,note:n,spin:s=!0}){return t.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[s&&t.jsx(Cv,{className:"size-5"}),t.jsx("p",{className:"caps text-label font-semibold",children:e}),t.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:n})]})}const oB={label:"Decline and say what to do instead",placeholder:"Tell the agent what to do instead...",does:"Sending it declines the waiting call; the agent reads your message."},aB={steer:{label:"Steer the run",placeholder:"Steer the run...",does:"A message steers the run; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."},follow_up:{label:"Message the run",placeholder:"Message the run...",does:"A message goes to the run after its turn; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."}};function iB(e,n){var r,o;if(e.status==="input_required"&&((r=e.pending)==null?void 0:r.kind)==="budget"){const{cap_usd:i,spent_usd:c,held_usd:d}=e.pending,u=typeof i=="number"&&Number.isFinite(i),f=typeof d=="number"&&d>0?`, and holds ${no(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${no(c)} of its ${no(i)} cap${f}.`:u?`Its ${no(i)} cap is reached.`:"Its spend cap is reached."} Raise the cap above to continue.`,spin:!1}}if(e.status==="input_required"&&((o=e.pending)==null?void 0:o.kind)==="approval")return{title:"Waiting for your approval",note:`The run continues once you answer the approval above${n.canMessage?", or send a message below to decline it":""}.`,spin:!1};const s=Zi(e);return s?{title:`Waiting for you at the ${C$(s)}`,note:"The run continues once you answer the ask above, or hand the computer back on the Screen tab.",spin:!1}:e.status==="input_required"&&e.state==="waiting"?{title:"Waiting for your answer",note:n.messageMode==="answer"?"The run continues when you reply below.":"The run continues once the question is answered.",spin:!1}:e.status==="input_required"?{title:"Stopped",note:`Stopped before it wrote an answer.${n.canMessage?" Send a message below to continue it.":""}`,spin:!1}:e.status==="paused"?{title:"Paused",note:"No new step starts until it's resumed. The answer appears here when it finishes.",spin:!1}:{title:"Writing the answer",note:"The answer appears here when the run finishes. Follow it on the timeline.",spin:n.live}}function lB({run:e,agentName:n,messages:s,harnessSteers:r,rows:o,files:i,outputSchema:c,readFile:d,fileUrl:u,openFile:f=null,actions:g,onMessage:y,onApprove:v,tab:h,graphView:x,costText:b,readLearningDiff:j,readLearning:k,readLearningResult:E,readComputer:N,computerEvery:S,onTakeOver:$,onHandBack:_,readComputers:O,onGrade:M,readTrace:P,traceAt:A}){var gt,Et,se,$e,Fe,et,Dt;const R=e.native,L=os(e),W=((gt=e.pending)==null?void 0:gt.kind)==="budget"?e.pending:null,U=Zi(e),Y=!L&&!R&&U?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,D=nh(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),G=L||R||W?{...D,canMessage:!1,messageMode:null}:U?{...D,canMessage:Y!==null,messageMode:Y}:D,F=x?"graph":G.final&&e.status==="completed"?"report":"timeline",[q,H]=p.useState(h??F),I=q==="graph"&&!x?F:q,[V,J]=p.useState(!1),[X,re]=p.useState(f?{file:f,text:null}:null),ae=h9(e),ye=ae||U?null:gP(e.status,e.state,o),he=ae?o.findLast(Le=>Le.kind===p$&&Le.tool_use_id===ae.call_id):void 0,[we,ze]=p.useState(null),le=async(Le,rt,Ft,jn)=>{const Rt=v?await(jn?v(Le,rt,Ft,jn):v(Le,rt,Ft)):"This page can't answer an approval.";return ze(Rt?{id:Le,text:Rt}:null),Rt},me=p.useRef(Z2()).current,Ke=async Le=>{const rt=me.begin();if(re({file:Le,text:null}),!d)return;const Ft=await d(Le);me.current(rt)&&re({file:Le,text:Ft})},be=()=>{me.cancel(),re(null)},ge=yH(e,j),{read:Je,grade:tt,graded:ft}=MH(e,G.final,k),ve=M&&(async Le=>{const rt=await M(Le);return ft(rt),rt}),Ee=G.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",Q=e.computer,Me=Q?xH(o,Q.kind):void 0,{view:pe,held:ne}=iH(N,!G.final,S,void 0,e.status==="queued"||Me!==void 0),Ae=!!pe||!!Q||!!U,Pe=p.useRef(!1);p.useEffect(()=>{if(Ae){Pe.current=!0;return}Pe.current&&I==="screen"&&H(F),Pe.current=!1},[Ae,I,F]);const[bt,ot]=p.useState(!1);p.useEffect(()=>{if(!Q||!$b.has(Q.kind)||!O)return;let Le=!0;return O().then(rt=>{var Ft,jn;Le&&ot(!!((jn=(Ft=rt.kinds.find(Rt=>Rt.kind===Q.kind))==null?void 0:Ft.providers.find(Rt=>Rt.id===Q.provider))!=null&&jn.metered))}).catch(()=>{}),()=>{Le=!1}},[Q==null?void 0:Q.kind,Q==null?void 0:Q.provider]);const mt=U?`${U.kind}:${U.asked_at}`:null,Re=p.useRef(null);p.useEffect(()=>{!mt||Re.current===mt||!Ae||(Re.current=mt,H("screen"))},[mt,Ae]);const lt=async()=>{if(!$)return"This page can't take the computer over.";try{return ne((await $()).hold),null}catch(Le){return Bx(Le,"take")}},$t=async Le=>{if(!_)return"This page can't hand the computer back.";try{return ne((await _(Le)).hold),null}catch(rt){return Bx(rt,"hand")}},[nt,fe]=p.useState(null),st=async Le=>{const rt=(U==null?void 0:U.asked_at)??"",Ft=await $t(Le);return fe(Ft?{at:rt,text:Ft}:null),Ft};p.useEffect(()=>{f&&d&&Ke(f)},[f]);const Qe=p.useRef({rows:o,times:0});Qe.current.rows!==o&&(Qe.current={rows:o,times:Qe.current.times+1});const ct=[...x?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...P?[["trace","Dev tools"]]:[],...e.learning?[["learning","Learning"]]:[],["files",`Files ${j$(i,V).length}`],...Ae?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(_9,{run:e,agentName:n,actions:g,costText:b}),t.jsx(Ev,{id:"run-views",label:"Run views",value:I,onChange:Le=>H(Le),tabs:ct.map(([Le,rt])=>({id:Le,label:rt}))}),I==="graph"?t.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:x}):I==="trace"&&P?t.jsx(Z9,{run:e,read:P,version:`${Qe.current.times}:${e.status}:${e.ended_at??""}`,live:G.live,...A}):t.jsx("div",{"data-scroll-pane":!0,className:"min-h-0 flex-1 overflow-auto short:flex-none short:overflow-visible",children:t.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-5 py-8 md:px-8",children:[R&&t.jsx(eH,{native:R,agentId:e.agent_id}),e.status==="failed"&&e.error&&t.jsx(ha,{error:e.error,title:rC(e.status,e.error)?"The run escalated":void 0}),e.status==="cancelled"&&t.jsxs("section",{className:"border border-border-strong/60 p-4",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Cancelled"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"This run was cancelled. It keeps what it did before; it takes no more messages."})]}),e.status==="completed"&&e.review&&t.jsxs("section",{className:"border border-warning/50 bg-warning/10 p-4","aria-label":"Needs review",children:[t.jsx("p",{className:"caps text-label text-warning-text",children:"Needs review"}),t.jsx("p",{className:"mt-2 text-lead",children:e.review.reason}),t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:[[e.review.node&&`Stopped at ${e.review.node}`,e.review.kind].filter(Boolean).join(" · "),". A person takes it from here."]})]}),we&&we.id!==(ae==null?void 0:ae.id)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",we.text]}),nt&&nt.at!==(U==null?void 0:U.asked_at)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",nt.text]}),ae?t.jsx(x$,{pending:ae,onAnswer:(Le,rt,Ft)=>Ft?le(ae.id,Le,rt,Ft):le(ae.id,Le,rt)},ae.id):U?t.jsx(E$,{ask:U,onAnswer:_?st:void 0,open:I!=="screen"?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>H("screen"),children:"Open the screen"}):null},mt):!R&&G.needsYou&&(W?t.jsx(j9,{pending:W}):t.jsx(N9,{waiting:ye})),G.needsYou&&W&&typeof W.cap_usd=="number"&&(g==null?void 0:g.onRaiseCap)&&t.jsx(w$,{cap:W.cap_usd,suggested:b$(W),least:y$(W),paused:!0,onRaise:g.onRaiseCap},`${e.run_id}:${W.at}`),I==="report"&&t.jsx(z9,{run:e,rows:o,files:i,onOpen:Ke,schema:c}),I==="report"&&!e.result&&!G.final&&t.jsx(Kx,{...iB(e,G)}),I==="report"&&G.final&&!((se=(Et=e.result)==null?void 0:Et.final_answer)!=null&&se.trim())&&!(($e=e.result)!=null&&$e.output)&&!o.some(Le=>{var rt;return Le.kind==="final_answer"&&((rt=Le.text)==null?void 0:rt.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[X2,G.canMessage?" Send a follow-up below to ask for one.":""]}),I==="timeline"&&t.jsx(rB,{rows:zI(o,e.learning),live:G.live,ended:lo(e.status),asking:(he==null?void 0:he.id)??(G.needsYou&&!W?ye==null?void 0:ye.id:void 0),waitingOn:e.status==="input_required"?(Fe=e.pending)==null?void 0:Fe.kind:void 0,files:i,onOpen:Ke}),(I==="report"||I==="timeline")&&t.jsx(AH,{run:e,graded:tt,onGrade:ve,onOpenTimeline:I==="timeline"?void 0:()=>H("timeline")}),(I==="report"||I==="timeline")&&t.jsx(IH,{used:(Je==null?void 0:Je.used)??null,agentId:e.agent_id}),(I==="report"||I==="timeline")&&ge&&t.jsx(wH,{got:ge.got,retry:ge.retry}),I==="learning"&&t.jsx(nH,{run:e,read:E,onViewChanges:ge?()=>H("report"):void 0},e.run_id),I==="files"&&t.jsx(A9,{files:i,onOpen:Ke,showHidden:V,onShowHidden:J}),I==="screen"&&Ae&&t.jsx(hH,{runId:e.run_id,screen:pe,machine:Q,opens:Ee,followUp:G.canMessage&&G.messageMode==="follow_up",metered:bt,waitsFor:e.status==="input_required"&&((et=e.pending)==null?void 0:et.kind)!=="stopped"?(Dt=e.pending)==null?void 0:Dt.kind:void 0,keptUntil:e.status==="input_required"?Me:void 0,onTake:$?lt:void 0,onHand:_?()=>$t():void 0,recordings:e.recordings,fileUrl:u})]})}),R&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:["Native sessions cannot receive steering or follow-up messages. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(e.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," for another task."]}),L&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[sa(L.runtime)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),G.canMessage&&t.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:t.jsx("div",{className:"mx-auto max-w-4xl",children:t.jsx(w9,{mode:G.messageMode,onSend:y,purpose:ae?oB:U&&Y?aB[Y]:void 0})})}),X&&t.jsx(O9,{file:X.file,text:X.text,onClose:be,files:i,onOpen:Ke})]})}const L$=new Set(["chain","parallel","route","map","loop","workflow"]),cB={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},dB=e=>e==="review"?"needs review":e.replace("-"," ");function ny({state:e}){const n=rm(e)??"pending";return t.jsx(Ne,{tone:cB[n]??"plain",className:"whitespace-nowrap",children:dB(n)})}function sy({provider:e}){if(!e)return null;const n=e==="parallel"?"--wf-parallel":e==="openrouter"?"--wf-openrouter":"--wf-jev";return t.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${n}))`,borderColor:`hsl(var(${n}) / .6)`,background:`hsl(var(${n}) / .12)`},children:e})}const P$={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},ry=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function uB({data:e,selected:n,onSelect:s,onClose:r,fileUrl:o}){var j,k,E,N,S,$;const i=e.graph.nodes.find(_=>_.path===n.path),[c,d]=p.useState(null);if(!i)return null;const u=e.nodes[i.path],f=Bv(e.workflow,i.path,i),g=i.kind==="map"?i.path:(j=e.graph.nodes.find(_=>_.kind==="map"&&i.path.startsWith(`${_.path}/body/`)))==null?void 0:j.path,y=n.item!=null&&g?(E=(k=e.nodes[g])==null?void 0:k.items)==null?void 0:E.find(_=>_.index===n.item):void 0,v=e.decisions.filter(_=>_.node===i.path),h=e.effects.filter(_=>_.node===i.path),x=!!g&&i.kind!=="map",b=ry(u==null?void 0:u.startedAt,u==null?void 0:u.endedAt);return t.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[t.jsxs("header",{className:"border-b px-5 py-4",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[f.decision?i.kind:vb(i.kind,u),f.tool?` · ${D$(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&zd(f.tool)&&t.jsx(F$,{}),y&&t.jsxs(t.Fragment,{children:[t.jsx(As,{className:"size-3","aria-hidden":!0})," item ",y.index+1]})]}),t.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:y?ad(e,g,y.index)??`Item ${y.index+1}`:i.label}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx(ny,{state:y?y.status:u==null?void 0:u.status}),y&&(()=>{const _=qv(e,g,y);return _.outcome?t.jsxs("span",{className:"font-mono text-label",title:_.pNote,children:["outcome ",t.jsx("b",{className:P$[_.tone??""],children:_.outcome}),_.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",Vs(_.p)]})]}):null})(),f.decision&&t.jsx(sy,{provider:f.provider}),f.decision&&((u==null?void 0:u.model)??f.model)&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(u==null?void 0:u.model)??f.model}),(u==null?void 0:u.branch)&&t.jsxs("span",{className:"font-mono text-label",children:["took ",t.jsx("b",{children:u.branch})]}),!y&&b!==void 0&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ol(b)})]})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(uo,{"aria-hidden":!0})})]}),y&&t.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>s({path:g,item:null}),children:["All ",(S=(N=e.nodes[g])==null?void 0:N.items)==null?void 0:S.length," items of ",($=e.graph.nodes.find(_=>_.path===g))==null?void 0:$.label]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[y?t.jsx(pB,{data:e,mapPath:g,index:y.index,status:y.status,fileUrl:o,zoom:d}):i.kind==="map"?t.jsx(fB,{data:e,mapPath:i.path,onSelect:s}):x&&(v.length||h.length)?t.jsx(mB,{data:e,path:i.path,mapPath:g,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(hB,{data:e,path:i.path,onSelect:s}),v.map((_,O)=>t.jsx(z$,{d:_,fileUrl:o,zoom:d},_.id??O)),h.map((_,O)=>t.jsx(U$,{e:_,fileUrl:o,zoom:d},O)),!v.length&&!h.length&&i.kind!=="parallel"&&t.jsx(I$,{kind:i.kind,status:u==null?void 0:u.status,meta:f})]}),t.jsx(yB,{workflow:e.workflow,path:i.path,kind:i.kind})]}),c&&t.jsx(wB,{src:c,onClose:()=>d(null)})]})}function I$({kind:e,status:n,meta:s}){const r=s.decision?n==="working"?"Asking now. The verdict shows here when the answer comes back.":"Not asked yet.":e==="code"?"A code node: a pure transform of the run's state. It calls nothing, so it leaves no record of its own.":e==="route"?"Routed by a value already in the state: no model was asked.":L$.has(e)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:r})}function fB({data:e,mapPath:n,onSelect:s}){var i;const r=((i=e.nodes[n])==null?void 0:i.items)??[],o=Y2(r);return t.jsxs("section",{children:[t.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",o.total],["Done",o.done],["Working",o.working],["Review",o.review],["Failed",o.failed]].map(([c,d])=>t.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),t.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},c))}),t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),t.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),t.jsx("tbody",{children:r.map(c=>{const d=e.decisions.filter(g=>{var y;return g.item===c.index&&!!((y=g.node)!=null&&y.startsWith(`${n}/body`))}),u=qv(e,n,c),f=d.length?d.some(g=>g.cost_usd===null)?null:d.reduce((g,y)=>g+(y.cost_usd??0),0):void 0;return t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:n,item:c.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),t.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:ad(e,n,c.index),children:ad(e,n,c.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx(ny,{state:c.status})}),t.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[u.pNote,...d.map(g=>bl(g))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:te("font-semibold",P$[u.tone??""]),children:u.outcome}),u.p!==void 0&&t.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:Vs(u.p)})]}):d.map(g=>bl(g)).filter(Boolean).join(", ")||t.jsx("span",{className:"text-muted-foreground",children:"—"})}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:f===void 0?t.jsx("span",{className:"text-muted-foreground",children:"—"}):Ml(f)})]},c.index)})})]})]})}function mB({data:e,path:n,mapPath:s,onSelect:r}){var g;const o=e.decisions.filter(y=>y.node===n),i=e.effects.filter(y=>y.node===n),c=(((g=e.nodes[s])==null?void 0:g.items)??[]).map(y=>({it:y,d:o.find(v=>v.item===y.index),e:i.find(v=>v.item===y.index)})).filter(y=>y.d||y.e),d=o.filter(y=>y.cost_usd!==null),u=o.filter(y=>y.latency_ms!==null),f=u.length?u.reduce((y,v)=>y+(v.latency_ms??0),0)/u.length:void 0;return t.jsxs("section",{children:[o.length>0&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[o.length," asked · ",Ml(d.reduce((y,v)=>y+(v.cost_usd??0),0)),d.length<o.length?` + ${o.length-d.length} unknown`:""," · mean ",ol(f)]}),t.jsx("table",{className:"w-full border-collapse font-mono text-small",children:t.jsx("tbody",{children:c.map(({it:y,d:v,e:h})=>t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:y.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:y.index+1}),t.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:ad(e,s,y.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:v?bl(v):h?t.jsx(ny,{state:h.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:v?ol(v.latency_ms):h?ol(ry(h.startedAt,h.endedAt)):""})]},y.index))})})]})}function hB({data:e,path:n,onSelect:s}){var v,h;const r=`${n}/branches/`,o=e.decisions.filter(x=>{var b;return((b=x.node)==null?void 0:b.startsWith(r))&&/^\d+$/.test(x.node.slice(r.length))&&x.item===null}),i=new Set(o.flatMap(x=>Object.keys(x.answers??{}))),[c]=[...i],d=o.map(x=>{var b;return{d:x,a:(b=x.answers)==null?void 0:b[c]}}).filter(x=>{var b;return((b=x.a)==null?void 0:b.type)==="noul"});if(i.size!==1||d.length<2)return t.jsx(I$,{kind:"parallel",meta:{decision:!1}});const u=d.map(x=>x.a.noul),f=u.reduce((x,b)=>x+b,0)/u.length,g=Math.max(...u)-Math.min(...u),y=x=>{var b;return((b=e.graph.nodes.find(j=>j.path===x.node))==null?void 0:b.label)??x.node};return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"border-b px-4 py-2.5",children:[t.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",d.length," models · ",c]}),t.jsx("p",{className:"mt-1 text-body leading-snug",children:((h=(v=o[0].questions)==null?void 0:v[c])==null?void 0:h.instructions)??c})]}),t.jsx("ul",{className:"divide-y",children:d.map(({d:x,a:b})=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>s({path:x.node,item:null}),children:[t.jsx("span",{className:"w-[92px] shrink-0",children:t.jsx(sy,{provider:x.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:x.model??"",children:x.model??y(x)}),t.jsx(Vx,{p:b.noul,strong:!0,tick:.5,tone:b.noul>=.5?"fg":"muted"}),t.jsx("span",{className:"w-10 text-right tabular-nums",children:Vs(b.noul)})]})},x.id??x.executionPath))}),t.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),t.jsx("dd",{className:"font-semibold tabular-nums",children:Vs(f)})]}),t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),t.jsx("dd",{className:te("font-semibold tabular-nums",g>.3&&"text-warning-text"),children:Vs(g)})]}),t.jsxs("div",{className:"px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),t.jsx("dd",{className:"tabular-nums",children:Ml(d.some(x=>x.d.cost_usd===null)?null:d.reduce((x,b)=>x+(b.d.cost_usd??0),0))})]})]})]})}function pB({data:e,mapPath:n,index:s,status:r,fileUrl:o,zoom:i}){const d=e.graph.nodes.filter(u=>u.path.startsWith(`${n}/body`)).map(u=>({n:u,ds:e.decisions.filter(f=>f.node===u.path&&f.item===s),es:e.effects.filter(f=>f.node===u.path&&f.item===s)})).filter(u=>!L$.has(u.n.kind)||u.ds.length||u.es.length);return r==="pending"?t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):t.jsxs("div",{className:"space-y-5",children:[d.map(({n:u,ds:f,es:g})=>f.length||g.length?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:u.label}),g.map((y,v)=>t.jsx(U$,{e:y,fileUrl:o,zoom:i,compact:!0},v)),f.map((y,v)=>t.jsx(z$,{d:y,fileUrl:o,zoom:i},y.id??v))]},u.path):null),r==="working"&&!d.some(u=>u.ds.length)&&t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"In flight: the verdict shows here when it comes back."})]})}const DN=e=>`${Math.round(e*100)}%`,Vs=e=>e.toFixed(2);function Vx({p:e,strong:n,tick:s,tone:r="fg"}){const o={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[r];return t.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[t.jsx("span",{className:te("absolute inset-y-0 left-0 transition-[width] duration-slow",n?o:"bg-muted-foreground/45"),style:{width:DN(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:DN(s)},title:`threshold ${Vs(s)}`})]})}function gB({id:e,q:n,a:s,rule:r}){const o=d=>{var u;return(r==null?void 0:r.kind)==="pick"&&(n==null?void 0:n.type)==="choice"&&typeof((u=n.criteria)==null?void 0:u[d])=="string"?n.criteria[d]:d},i=(n==null?void 0:n.instructions)??e,c=(r==null?void 0:r.kind)==="route"?r.unsure:null;return t.jsxs("div",{className:"py-2.5",children:[t.jsxs("p",{className:"mb-2 text-body leading-snug",children:[t.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:e}),i]}),s?s.type==="refusal"?t.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):s.type==="noul"?t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:te("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),t.jsx(Vx,{p:s.noul,strong:!0,tick:.5,tone:s.noul>=.5?"fg":"muted"}),t.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",Vs(s.noul)]})]}):s.type==="box"?t.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(s.box)]}):t.jsxs("div",{className:"space-y-1.5",children:[Object.entries(s.probabilities).sort((d,u)=>u[1]-d[1]).slice(0,(r==null?void 0:r.kind)==="pick"?5:void 0).map(([d,u])=>{const f=(s.type==="choice"?s.choice:String(s.score))===d;return t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:te("truncate",(r==null?void 0:r.kind)==="pick"?"w-48":"w-28",f?"font-semibold":"text-muted-foreground"),title:o(d),children:s.type==="score"?`${d} ${s.legend[d]??""}`:o(d)}),t.jsx(Vx,{p:u,strong:f,tick:f&&c?c.gte:void 0}),t.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:Vs(u)})]},d)}),(r==null?void 0:r.kind)==="pick"&&Object.keys(s.probabilities).length>5&&t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(s.probabilities).length-5," more options, each less likely"]})]}):t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function xB(e){if(!e)return"No rule applied: nothing came back to decide on.";switch(e.kind){case"judge":return"Each answer is decoded on its own: a yes/no is yes at P(yes) ≥ 0.50, a choice is its top option.";case"route":return e.unsure?`Take the chosen branch; below ${Vs(e.unsure.gte)} confidence take "${e.unsure.branch}".`:"Take the chosen branch.";case"pick":return`Pick one of ${e.options.length} options${e.none?`, or "${e.none}"`:""}.`;case"ask":return`Holds when P(yes) ≥ ${Vs(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${Vs(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function vB(e){var s,r,o,i;const n=e.action;if(n==null)return e.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((s=e.rule)==null?void 0:s.kind)==="route"){const c=((o=(r=e.answers)==null?void 0:r.branch)==null?void 0:o.type)==="choice"?e.answers.branch.confidence:void 0;return n.unsure?`Took "${String(n.taken)}": "${String(n.branch)}" at ${c!==void 0?Vs(c):"?"} is below the threshold.`:`Took "${String(n.taken??n.branch)}".`}if(((i=e.rule)==null?void 0:i.kind)==="pick"&&typeof n.index=="number"){const c=e.rule.options[n.index];return n.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${c!==void 0?`"${K2(e,Object.keys(e.questions??{})[0]??"pick",c)}"`:`option ${n.index}`}.`}return typeof n=="object"?Object.entries(n).map(([c,d])=>`${c} = ${typeof d=="object"?JSON.stringify(d):String(d)}`).join(" · "):String(n)}function z$({d:e,fileUrl:n,zoom:s}){var i,c,d;const r=Array.from(new Set([...Object.keys(e.questions??{}),...Object.keys(e.answers??{})])),o=e.status==="answered"?"success":e.status==="cancelled"?"warning":"error";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[t.jsx(sy,{provider:e.provider}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),t.jsx(Ne,{tone:o,children:e.status==="cancelled"?"outcome unknown":e.status})]}),t.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((i=e.rule)==null?void 0:i.kind)!=="route"?"Least sure answer":"Verdict"}),t.jsx("dd",{className:"break-words font-semibold",children:bl(e)??"—"})]}),t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),t.jsx("dd",{className:"tabular-nums",title:e.cost_basis??void 0,children:Ml(e.cost_usd)})]}),t.jsxs("div",{className:"px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),t.jsx("dd",{className:"tabular-nums",children:ol(e.latency_ms)})]})]}),e.error&&t.jsx("p",{className:te("border-b px-4 py-2.5 font-mono text-small",e.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:e.error}),!!((c=e.images)!=null&&c.length)&&t.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:e.images.map(u=>({img:u,src:u.ref&&n(u.ref)||mr(u.url)})).filter(({src:u})=>u).map(({img:u,src:f})=>t.jsxs("figure",{className:"flex gap-3",children:[t.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>s(f),"aria-label":`Open ${u.ref}`,children:t.jsx("img",{src:f,alt:`The page the model saw as ${u.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),t.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),t.jsxs("p",{children:[t.jsx("span",{className:"text-muted-foreground",children:"token "}),u.token]}),t.jsxs("p",{className:"break-all",children:[t.jsx("span",{className:"text-muted-foreground",children:"page "}),u.ref]}),u.sha256&&t.jsxs("p",{className:"break-all",title:u.sha256,children:[t.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),u.sha256.slice(0,16),"…"]}),(u.mime||u.bytes)&&t.jsx("p",{className:"text-muted-foreground",children:[u.mime,u.bytes?`${Math.round(u.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},u.token))}),t.jsx("div",{className:"divide-y px-4",children:r.map(u=>{var f,g;return t.jsx(gB,{id:u,q:(f=e.questions)==null?void 0:f[u],a:(g=e.answers)==null?void 0:g[u],rule:e.rule},u)})}),t.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[t.jsxs("div",{className:"flex gap-3",children:[t.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),t.jsx("dd",{children:xB(e.rule)})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),t.jsx("dd",{className:"font-mono text-small",children:vB(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(bB,{evidence:e.evidence}),e.state!=null&&t.jsxs("details",{className:"group border-t",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(As,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",e.state_truncated?" (cut at 64 KB)":""]}),t.jsx(Nm,{value:e.state})]})]})}function bB({evidence:e}){return t.jsxs("section",{className:"border-t px-4 py-3",children:[t.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",e.length]}),t.jsx("ol",{className:"space-y-3",children:e.map((n,s)=>{let r=n.url;try{r=new URL(n.url).host}catch{}const o=mr(n.url);return t.jsxs("li",{className:"flex gap-3",children:[t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:s+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[o?t.jsxs("a",{href:o,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[n.title??r,t.jsx(KT,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):t.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:n.title??r}),t.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[r,n.scope&&t.jsx("span",{className:"border px-1",children:n.scope})]}),n.excerpts.slice(0,2).map((i,c)=>t.jsx("blockquote",{className:"mt-1.5 line-clamp-3 border-l-2 border-wf-parallel/[.6] pl-2.5 text-body leading-snug text-muted-foreground",children:i},c))]})]},s)})})]})}const D$=e=>{const n=zd(e);return n?`${n.tool} on ${n.server}`:e},F$=()=>t.jsx(Ne,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function U$({e,fileUrl:n,zoom:s,compact:r=!1}){var g;const o=e.output,i=o!=null,c=o&&typeof o=="object"?o:null,d=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),u=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),f=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[t.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:D$(e.tool)}),zd(e.tool)&&t.jsx(F$,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?ol(ry(e.startedAt,e.endedAt)):""}),t.jsx(Ne,{tone:f,children:e.status})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[r?t.jsxs("p",{className:"break-all font-mono text-label",children:[t.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(e.input)]}):t.jsxs("div",{children:[t.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),t.jsx(Nm,{value:e.input,small:!0})]}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",children:u}),!!((g=c==null?void 0:c.pages)!=null&&g.length)&&t.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(y=>t.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(n(y.image)),"aria-label":`Open page ${y.page}`,children:t.jsx("img",{src:n(y.image),alt:`Page ${y.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},y.page))}),i&&!u&&t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[t.jsx(As,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),t.jsx(Nm,{value:o,small:!0})]}),!i&&!u&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:e.status==="stopped"?"Stopped before it answered.":d?"Running…":"Finished with no output."})]})]})}function yB({workflow:e,path:n,kind:s}){const r=q2(e,n);if(!r)return null;const o=Object.fromEntries(Object.entries(r).map(([i,c])=>[i,(i==="steps"||i==="branches"&&s==="parallel")&&Array.isArray(c)?`… ${lh(c.length)}`:i==="body"?"… its body":i==="branches"&&s==="route"&&c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([d,u])=>[d,(u==null?void 0:u.criteria)??"…"])):c]));return t.jsxs("details",{className:"group border",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(As,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",t.jsx("span",{className:"normal-case tracking-normal",children:n})]}),t.jsx(Nm,{value:o})]})}function Nm({value:e,small:n}){return t.jsx("pre",{className:te("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",n?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(e,null,2)})}function wB({src:e,onClose:n}){return t.jsx(Ym,{open:!0,onClose:n,title:"Page image",size:"full",children:t.jsx("img",{src:e,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const W$=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function jB(e,{everyMs:n=1e3,key:s="",enabled:r=!0}={}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(0),v=p.useRef(e);return v.current=e,p.useEffect(()=>{if(!r)return;const h=new AbortController;let x;const b=async()=>{try{const j=Date.now(),k=await v.current(h.signal);if(h.signal.aborted||(i(k),d(null),f(j),Td(k.run.status)))return}catch(j){if(h.signal.aborted)return;d(j);const k=j;if(k.retryable){x=setTimeout(b,Math.min(n,k.retryAfterMs??500));return}if(W$(j))return}x=setTimeout(b,n)};return b(),()=>{h.abort(),clearTimeout(x)}},[s,n,g,r]),{data:o,error:c,readAt:u,reload:()=>y(h=>h+1)}}function kB({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:o}){const[i,c]=p.useState(r),d=p.useMemo(()=>fP(e,i),[e,i]),u=Td(e.run.status),[f,g]=p.useState(()=>Date.now()),y=p.useMemo(()=>Date.now(),[e]);return p.useEffect(()=>{if(u||e.run.paused)return;const v=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(v)},[u,e.run.paused]),t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx(NB,{data:e,readAt:y,now:f,actions:n,stale:!u&&o&&f-o>5e3?Math.max(1e3,f-o):0}),e.run.paused&&t.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[t.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:t.jsx("div",{className:"px-5 py-6 md:px-8",children:t.jsx(Fd,{graph:e.graph,marks:d,onSelect:v=>c(h=>h&&h.path===v.path&&(h.item??null)===v.item?null:v),label:"The run's workflow graph"})})}),i&&t.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:t.jsx(uB,{data:e,selected:i,onSelect:c,onClose:()=>c(null),fileUrl:s})})]}),t.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:t.jsx(Ud,{run:!0})})]})}function NB({data:e,readAt:n,now:s,actions:r,stale:o}){const i=Td(e.run.status),c=e.graph.nodes.find(y=>{var v,h;return y.kind==="map"&&((h=(v=e.nodes[y.path])==null?void 0:v.items)==null?void 0:h.length)}),d=c?Y2(e.nodes[c.path].items):null,{usd:u,unknown:f}=Q2(e),g=[["Elapsed",yl(pP(e,n,s))],["Cost",t.jsxs(t.Fragment,{children:[Ml(u),f>0&&t.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",f," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",e.totals.decisions],["Tool calls",e.totals.effects],["Agents",CB(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&g.push(["Items",t.jsxs(t.Fragment,{children:[t.jsx("span",{children:d.done}),t.jsxs("span",{className:"text-muted-foreground",children:["/",d.total]}),d.failed>0&&t.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[d.failed," failed"]}),d.review>0&&t.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[d.review," review"]})]})]),t.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&t.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:t.jsxs(Ne,{tone:"warning",children:[t.jsx(fl,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([y,v,h],x)=>t.jsxs("div",{className:te("px-4 py-2",x?"border-l":"pl-5 md:pl-8"),title:h,children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:y}),t.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:v})]},y)),t.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[o>0&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",yl(o)," ago, reading again"]}),!i&&(e.run.paused?t.jsxs(B,{size:"sm",variant:"solid",onClick:r.onResume,disabled:!r.onResume||!!r.busy,children:[t.jsx(ra,{"aria-hidden":!0})," ",r.busy==="resume"?"Resuming":"Resume"]}):t.jsxs(B,{size:"sm",onClick:r.onPause,disabled:!r.onPause||!!r.busy,title:"Calls in flight finish; no new node starts.",children:[t.jsx(fl,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const SB=new Set(["agent","decide","extract","report","artifact"]),CB=e=>e.graph.nodes.filter(n=>{var s;return SB.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function EB({error:e}){const n=e==null?void 0:e.status;return t.jsx("p",{className:te("m-8 border p-4 font-mono text-body",n===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:e==null?"Reading the run's graph...":n===404?"This server does not give run graphs: GET /v2/runs/{id}/graph is not there.":`The run's graph could not be read: ${e.message??String(e)}`})}function $B(e,n){return!n||e.state==="loading"?{messages:th,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:RP(e.id,n.harnesses)}}async function _B(e,n){try{let s=null;do{const r=await e.listRevisions(n.agent_id,s),o=r.revisions.find(c=>c.revision===n.revision),i=o==null?void 0:o.definition.output_schema;if(o)return{state:"read",id:o.definition.harness,...i?{outputSchema:i}:{}};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const FN=new Set(["completed","failed","cancelled"]),TB={firstMs:2e3,maxMs:16e3,totalMs:12e4};function RB(e,n,s,r=TB){var g;const o=!!e&&FN.has(e.status)&&oh(e.learning),i=p.useRef(n);i.current=n;const c=p.useRef(s);c.current=s;const d=(g=e==null?void 0:e.learning)==null?void 0:g.state,u=!!e&&FN.has(e.status),f=p.useRef(d);p.useEffect(()=>{var v;const y=f.current;f.current=d,y!==void 0&&y!==d&&u&&((v=c.current)==null||v.call(c))},[d,u]),p.useEffect(()=>{if(!o)return;let y,v=0,h=r.firstMs,x=!1,b=!1;const j=()=>{b||v+h>r.totalMs||(y=setTimeout(k,h))},k=()=>{if(y=void 0,document.visibilityState==="hidden"){x=!0;return}v+=h,h=Math.min(h*2,r.maxMs),i.current(),j()},E=()=>{x&&document.visibilityState!=="hidden"&&(x=!1,k())};return document.addEventListener("visibilitychange",E),j(),()=>{b=!0,y&&clearTimeout(y),document.removeEventListener("visibilitychange",E)}},[o])}const UN=new Set(["completed","failed","cancelled"]),AB=e=>{const n=Q2(e);return`${Ml(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},OB=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},Vi=e=>({api:OB(e),title:KL(e),cause:e}),MB=3e3;function WN({v2:e,runId:n,caps:s,agentName:r}){var J;const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,y]=p.useState([]),[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(0),E=p.useRef(""),N=p.useRef(Z2()).current,S=p.useRef(br()).current,$=p.useRef(0),_=p.useRef(""),[O,M]=p.useState({state:"loading"});p.useEffect(()=>{o&&O.state==="loading"&&_B(e,o).then(M)},[o==null?void 0:o.revision]);const P=$B(O,s);RB(o,()=>A(),()=>k(X=>X+1));const A=async()=>{const X=N.begin();try{const[re,ae]=await Promise.all([e.getRun(n),e.listFiles(n)]);N.current(X)&&(i(re),y(ae.files))}catch(re){N.current(X)&&h(Vi(re))}};p.useEffect(()=>{A()},[n]),f$(()=>{A()});const R=((J=o==null?void 0:o.recordings)==null?void 0:J.some(X=>!X.finished))===!0;p.useEffect(()=>{if(!R)return;const X=setInterval(()=>{A()},MB);return()=>clearInterval(X)},[R,n]),p.useEffect(()=>{const X=new AbortController;return d(null),M2(e,n,{signal:X.signal,onRows:re=>{f(re);const ae=re.filter(he=>he.kind===p$).map(he=>`${he.id}\0${he.summary}`).join("");ae!==_.current&&(_.current=ae,A());const ye=re.filter(he=>he.kind==="tool_result").length;ye>$.current&&($.current=ye,A())},onPage:re=>{re.cost&&d(re.cost);const ae=`${re.status}/${re.state}`;(ae!==E.current||re.status==="input_required"&&!re.unchanged)&&(E.current=ae,A())}}).catch(re=>{X.signal.aborted||h(Vi(re))}),()=>X.abort()},[n,j]);const L=async X=>{b(X);try{await e[X](n),h(null)}catch(re){h(Vi(re))}b(null),await A(),k(re=>re+1)},W=async()=>{if(o){b("archive");try{const X=await(o.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(re=>re?{...re,archived_at:X.archived_at}:X),h(null)}catch(X){h(Vi(X))}b(null),A()}},U=async X=>{const re=await X();return await A(),k(ae=>ae+1),re},Y=X=>U(()=>e.raiseCap(n,X)),D=X=>U(()=>e.gradeRun(n,X)),G=async X=>{let re=!0;try{await UC(S,n,X,e.sendMessage),h(null)}catch(ae){h(Vi(ae)),re=!1}return await A(),k(ae=>ae+1),re},F=async(X,re,ae,ye)=>{let he=null;try{await e.answerApproval(n,X,re,ae,ye)}catch(we){he=g$(we)}return await A(),k(we=>we+1),he},q=async X=>{try{return await X()}finally{A(),k(re=>re+1)}},H=jB(X=>e.getRunGraph(n,X),{key:n,enabled:(o==null?void 0:o.kind)==="workflow"}),I=!H.data&&W$(H.error);if(!o)return v?v.cause instanceof Ue&&v.cause.status===404?t.jsx(I2,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(en,{problem:Jt(v.cause,"the run"),onRetry:()=>{h(null),A(),k(X=>X+1)}}):t.jsx(WL,{});const V=c&&!UN.has(o.status)?{...o,cost:c}:o;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[v&&t.jsx("div",{className:"border-b p-3",children:t.jsx(ha,{title:v.title,error:v.api})}),t.jsx(lB,{run:V,agentName:r(o.agent_id),messages:P.messages,harnessSteers:P.steers,graphView:o.kind==="workflow"&&!I?t.jsx(LB,{v2:e,runId:n,graph:H,onMoved:()=>{A()}}):void 0,costText:o.kind==="workflow"&&!UN.has(o.status)&&H.data?AB(H.data):void 0,outputSchema:O.state==="read"?O.outputSchema:void 0,rows:u,files:g,readFile:X=>e.readFile(n,X.path),fileUrl:X=>e.fileUrl(n,X),readTrace:()=>e.runTrace(n),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>q(()=>e.takeOverComputer(n)),onHandBack:X=>q(()=>e.handBackComputer(n,X)),readComputers:()=>e.computers(),onMessage:G,onApprove:F,onGrade:D,actions:{onStop:()=>void L("stop"),onCancel:()=>void L("cancel"),onArchive:()=>void W(),onRaiseCap:Y,busy:x}},o.run_id)]})}function LB({v2:e,runId:n,graph:s,onMoved:r}){const{data:o,error:i,readAt:c,reload:d}=s,[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(null),x=async j=>{f(j);try{const k=await(j==="pause"?e.pauseRun(n):e.resumeRun(n));h({paused:k.paused,status:k.status,at:Date.now()}),y(null)}catch(k){y(Vi(k))}f(null),d(),r()},b=o&&v&&c<v.at?{...o,run:{...o.run,paused:v.paused,...v.status?{status:v.status}:{}}}:o;return b?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[g&&t.jsx("div",{className:"border-b p-3",children:t.jsx(ha,{title:g.title,error:g.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(kB,{data:b,lastRead:c,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void x("pause"),onResume:()=>void x("resume"),busy:u}})})]}):t.jsx(EB,{error:i})}function HN({actions:e,children:n}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:te(vr,"flex-wrap justify-between gap-2 px-5 md:px-6"),children:[t.jsxs("h1",{className:Jo,children:[t.jsx(a1,{className:"size-4","aria-hidden":!0}),"Mission Control"]}),e&&t.jsx("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:e})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n})]})}function PB({view:e,error:n,onRetry:s,scope:r,needsYou:o,asking:i,failed:c,live:d,startHere:u,actions:f,observations:g,hasObservedSessions:y=!1}){if(!e)return t.jsx(HN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n?t.jsx(en,{problem:n,onRetry:s}):t.jsx(UL,{}),g]})});const v=b=>{var j;return((j=e.perAgent.find(k=>k.agentId===b))==null?void 0:j.name)??b},h=r!=null&&r.agent?e.perAgent.filter(b=>b.agentId===r.agent):e.perAgent,x=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,[typeof d=="number"&&d!==e.runs.active?`${d} running now`:"",e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:""].filter(Boolean).join(" · ")||void 0],["Needs input",i===null?"–":String(i??e.runs.needsInput),"#/runs?status=input_required",i??e.runs.needsInput?"text-warning-text":void 0],c===void 0?["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,BN(e.runs.needsReview)]:["Failed · last 24 h",c===null?"–":String(c),"#/runs?status=failed",c?"text-destructive-text":void 0,[`See all ${e.runs.failed}`,BN(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(HN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n&&t.jsx(en,{problem:n,onRetry:s,className:""}),u,o,t.jsxs("section",{className:"space-y-4","aria-label":y?"Registered agents and runs":void 0,children:[y&&t.jsx("h2",{className:"text-lead font-semibold",children:"Registered agents & runs"}),t.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:x.map(([b,j,k,E,N])=>{const S=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:b}),t.jsx("p",{className:te("mt-3 font-mono text-display leading-none",E),children:j}),N&&t.jsx("p",{className:"mt-2 text-label text-muted-foreground",children:N})]});return t.jsx("li",{children:k?t.jsx("a",{href:k,className:"block h-full border bg-card p-5 transition-colors hover:border-border-strong hover:bg-accent",children:S}):t.jsx("div",{className:"h-full border bg-card p-5",children:S})},b)})})]}),g,t.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Activity & usage"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:IB(e)})]}),r&&t.jsx(W2,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),t.jsx(H2,{a:e.analytics,basis:e.cost.basis,refreshing:r==null?void 0:r.refreshing})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(Xc,{className:"size-4","aria-hidden":!0}),"Runs per agent"]}),h.length?t.jsx("ul",{children:h.map(b=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:Cn(b.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[t.jsx("span",{className:"min-w-0 truncate",children:b.name}),t.jsx("span",{className:"font-mono text-body text-muted-foreground",children:b.runs})]})},b.agentId))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(bd,{className:"size-4","aria-hidden":!0}),"Recent runs"]}),e.recent.length?t.jsx("ul",{children:e.recent.map(b=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(b.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[t.jsx(Ll,{run:b}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-lead",children:On(b)}),t.jsx(Nb,{run:b,className:"hidden sm:inline-flex"}),lW(b)&&t.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),t.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:v(b.agent_id)}),b.ended_at&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:yl(Date.parse(b.ended_at)-Date.parse(b.created_at))}),b.cost&&(b.cost.usd!==null||ui(b.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:Go(b.cost,{ended:lo(b.status)})}),t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:vt(b.created_at)})]})},b.run_id))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const BN=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function IB(e,n=Date.now()){var i;const s=e.analytics.filter,r=s.from?Math.round((Math.floor(n/864e5)*864e5-Date.parse(s.from))/864e5)+1:null,o=s.from?Uv.some(c=>c.days===r)?`Runs started in the last ${r} days`:`Runs started since ${s.from.slice(0,10)}`:"All runs";return s.agent?`${o}, of ${((i=e.perAgent.find(c=>c.agentId===s.agent))==null?void 0:i.name)??s.agent}`:o}const bs=e=>`#/runs/${encodeURIComponent(e)}`;function zB({asking:e,failed:n,failedAll:s,live:r,learning:o=[],agentName:i,onAnswer:c,onApprove:d,onHandBack:u,onRunAgain:f,onStop:g,problem:y,now:v=Date.now}){const h=sW(n.filter(R=>!os(R))),x=n.filter(R=>!R.imported_from&&os(R)),[,b]=p.useState(0);p.useEffect(()=>{if(!r.length)return;const R=setInterval(()=>b(L=>L+1),1e3);return()=>clearInterval(R)},[r.length]);const[j,k]=p.useState([]),E=(R,L,W)=>{const U=e.find(D=>D.run_id===R),Y=U?On(U):R;k(D=>[...D.filter(G=>G.runId!==R),...W?[{runId:R,what:L,title:Y,text:W}]:[]])},N=d&&(async(R,L,W,U,Y)=>{const D=await(Y?d(R,L,W,U,Y):d(R,L,W,U));return E(R,L,D),D}),S=u&&(async(R,L,W)=>{const U=await u(R,W);return E(R,`ask:${L.asked_at}`,U),U}),$=R=>{var W;const L=Zi(R);return((W=R.pending)==null?void 0:W.kind)==="approval"?R.pending.id:L?`ask:${L.asked_at}`:null},_=c$(n),O=o.filter(R=>R.pending>0),M=O.reduce((R,L)=>R+L.pending,0),P=e.length+_+M;if(!P&&!r.length&&!y&&!j.length)return null;const A=v();return t.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[P>0&&t.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",t.jsxs("span",{className:"text-warning-text",children:["· ",P]})]}),y&&t.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:y}),j.filter(R=>!e.some(L=>L.run_id===R.runId&&$(L)===R.what)).map(R=>t.jsxs("p",{className:"flex items-start gap-3 border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("a",{href:bs(R.runId),className:"underline-offset-4 hover:underline",children:R.title}),": your answer wasn't taken. ",R.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(L=>L.filter(W=>W.runId!==R.runId)),children:"Dismiss"})]},R.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(R=>{var L,W,U;return R.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:bs(R.run_id),className:"text-body underline underline-offset-2",children:On(R)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(R.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},R.run_id):((L=R.pending)==null?void 0:L.kind)==="approval"?t.jsx(DB,{run:R,pending:R.pending,agentName:i(R.agent_id),at:A,onApprove:N},`${R.run_id}:${R.pending.id}`):Zi(R)?t.jsx(FB,{run:R,ask:Zi(R),agentName:i(R.agent_id),at:A,onHandBack:S},`${R.run_id}:${Zi(R).asked_at}`):t.jsx(UB,{run:R,agentName:i(R.agent_id),at:A,onAnswer:c},`${R.run_id}:${((W=R.pending)==null?void 0:W.kind)==="question"?R.pending.asked_at:((U=R.pending)==null?void 0:U.kind)==="budget"?R.pending.at??"":""}`)})}),(h.length>0||x.length>0)&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps flex items-center justify-between gap-3 border-b px-4 py-2.5 text-label text-muted-foreground",children:[t.jsxs("span",{children:["Failed in the last 24 h · ",_]}),t.jsx("a",{href:"#/runs?status=failed",className:"-my-1 py-1 normal-case tracking-normal hover:text-foreground",children:s===void 0?"All failed runs →":`All ${s} failed ${s===1?"run":"runs"} →`})]}),t.jsxs("ul",{children:[h.map(R=>t.jsx(BB,{message:R.message,runs:R.runs,agentName:i,at:A,onRunAgain:f},R.message)),x.map(R=>t.jsx(qN,{run:R,agentName:i(R.agent_id)},R.run_id))]})]}),O.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Learned, waiting for your OK · ",M]}),t.jsx("ul",{children:O.map(R=>t.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:R.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:cb(R.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(R.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},R.agent_id))})]}),r.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",r.length]}),t.jsx("ul",{children:r.map(R=>os(R)?t.jsx(qN,{run:R,agentName:i(R.agent_id)},R.run_id):t.jsx(qB,{run:R,agentName:i(R.agent_id),at:A,onStop:g},R.run_id))})]})]})}function DB({run:e,pending:n,agentName:s,at:r,onApprove:o}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:t.jsx(x$,{compact:!0,pending:n,heading:t.jsx(oy,{run:e,agentName:s,since:`asked ${zl(n.requested_at,r)} ago`}),onAnswer:(i,c,d)=>o?d?o(e.run_id,n.id,i,c,d):o(e.run_id,n.id,i,c):Promise.resolve("Open the run to answer it.")})})}function FB({run:e,ask:n,agentName:s,at:r,onHandBack:o}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:t.jsx(E$,{compact:!0,ask:n,heading:t.jsx(oy,{run:e,agentName:s,since:`asked ${zl(n.asked_at,r)} ago`}),open:t.jsx("a",{href:bs(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:o&&(i=>o(e.run_id,n,i))})})}function UB(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(WB,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(HB,{...e})}function WB({run:e,pending:n,agentName:s}){return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:s}),t.jsx("a",{href:bs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:On(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:v$(n)}),typeof n.said=="string"&&t.jsx("p",{className:"mt-1 text-prose leading-snug",children:n.said}),t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:t.jsx("a",{href:bs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function oy({run:e,agentName:n,since:s}){return t.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:n}),t.jsx("a",{href:bs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:On(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function HB({run:e,agentName:n,at:s,onAnswer:r}){var j;const o=((j=e.pending)==null?void 0:j.kind)==="question"?e.pending:null,i=(o==null?void 0:o.question)??"",c=nW(i),[d,u]=p.useState(""),[f,g]=p.useState(!1),[y,v]=p.useState(null),[h,x]=p.useState(null),b=async k=>{k.preventDefault();const E=d.trim();if(!E||f)return;g(!0),v(null);const N=await r(e.run_id,E);g(!1),N?v(N):x(E)};return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsx(oy,{run:e,agentName:n,since:o!=null&&o.asked_at?`asked ${zl(o.asked_at,s)} ago`:void 0}),t.jsx("p",{className:"mt-2 text-base leading-snug",children:i}),h?t.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",h," · ",t.jsx("a",{href:bs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):t.jsxs("form",{onSubmit:k=>void b(k),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(k=>t.jsx("button",{type:"button",onClick:()=>u(k),className:te("border px-3 py-1.5 text-body hover:border-border-strong",d===k?"border-warning text-warning-text":"border-border"),children:k},k)),t.jsx(De,{value:d,onChange:k=>u(k.target.value),"aria-label":`Answer ${n}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),t.jsx(B,{type:"submit",variant:"solid",size:"sm",disabled:f||!d.trim(),children:f?"Sending…":"Send"}),y&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:y})]})]})}function BB({message:e,runs:n,agentName:s,at:r,onRunAgain:o}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),[f,g]=p.useState(new Set),y=n.filter(k=>!f.has(k.run_id)),v=n.length-y.length,h=async()=>{c(!0),u(null);const{started:k,problem:E}=await o(y);c(!1),u(E),g(N=>new Set([...N,...k]))},x=v>0&&t.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",v===1?"1 run":`${v} runs`]});if(!y.length)return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),x]});const b=y[0],j=y.length===1;return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[j?t.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[t.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(b.agent_id)}),t.jsx("a",{href:bs(b.run_id),className:"min-w-0 truncate hover:underline",children:On(b)})]}):t.jsxs("p",{className:"text-lead",children:[y.length," runs failed ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(y.map(k=>s(k.agent_id)))].join(", ")]})]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&t.jsxs("details",{className:"mt-1 text-body",children:[t.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),t.jsx("ul",{className:"mt-1 space-y-1",children:y.map(k=>t.jsxs("li",{children:[t.jsx("a",{href:bs(k.run_id),className:"hover:underline",children:On(k)})," ",t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["· ",s(k.agent_id)]})]},k.run_id))})]}),d&&t.jsx("p",{className:"mt-1 font-mono text-small text-destructive-text",role:"alert",children:d})]}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:[zl(b.ended_at??b.created_at,r)," ago"]}),x,t.jsx(B,{type:"button",size:"sm",disabled:i,onClick:()=>void h(),children:j?"Run again":"Run all again"})]})}function qN({run:e,agentName:n}){var s;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-small text-muted-foreground",children:[n," · ",sa(os(e).runtime)]}),t.jsx("a",{href:bs(e.run_id),className:"text-lead hover:underline",children:On(e)}),e.status==="failed"&&t.jsx("p",{className:"mt-1 break-words text-small text-destructive-text",children:((s=e.error)==null?void 0:s.message)||"The run failed."}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Control and retries stay in your backend. ",e.status==="failed"?"Start another task in the original application.":"Stop or cancel this task in the original application."]})]}),t.jsx("a",{href:bs(e.run_id),className:"caps shrink-0 text-small text-muted-foreground hover:text-foreground",children:"Open"})]})}function qB({run:e,agentName:n,at:s,onStop:r}){var g;const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=(g=e.cost)==null?void 0:g.usd,f=xl(e.cost)?`${Go(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${Go(e.cost)} so far`:ui(e.cost)?Go(e.cost):"cost not known yet";return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-run-active ring-4 ring-run-active/[0.18]","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:n}),t.jsx("a",{href:bs(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:On(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",yl(s-Date.parse(e.created_at))]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:f}),!e.native&&t.jsx("a",{href:bs(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),nh(e.status,e.state,e.kind,th,!0,e.error,e.review).canStop?t.jsx(B,{type:"button",size:"sm",disabled:o,onClick:async()=>{i(!0),d(await r(e.run_id)),i(!1)},children:"Stop"}):t.jsx("a",{href:bs(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Open to cancel"}),c&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:c})]})}const GB=[{id:"hello",name:"Hello, AgentRun",shows:"Writes a file, then answers",description:"A first agent: writes hello.md and answers in one line.",instructions:"You are a friendly first agent on this machine. Do what the person asks, briefly and plainly.",tools:["write"],input:"Write hello.md listing three things you could help me with on this machine, then answer in one line."},{id:"web",name:"Summarize a web page",shows:"Reads the web, then sums it up",description:"Reads a public web page and sums it up in three bullets.",instructions:"Read the page you are given and summarize it in three short bullets, then name the one thing worth remembering.",tools:["web_fetch"],input:"Summarize https://en.wikipedia.org/wiki/Hacker_News in three bullets."},{id:"plan",name:"Plan a task",shows:"Thinks it through, no tools",description:"Turns a goal into steps, risks and a first move.",instructions:"Turn the goal you are given into a short plan: the steps in order, the main risks, and what to do first. Keep it to one screen.",tools:[],input:"Plan a weekend launch of a small side project: the steps, the risks, and what to do first."}];function H$(e){var r;const n=["pi","claude-agent","codex"],s=e.filter(o=>o.available&&o.default_model);return s.sort((o,i)=>(n.indexOf(o.id)+1||99)-(n.indexOf(i.id)+1||99)),((r=s[0])==null?void 0:r.id)??null}function KB(e,n,s){const r=sh(n,[...s]).filter(i=>i.available).map(i=>i.name),o=e.tools.find(i=>!r.includes(i));return o?{ok:!1,reason:`${o} can't run on this server yet`}:{ok:!0}}async function VB(e,n,s,r=br()){const i=(await Mr(f=>e.listAgents({cursor:f}),f=>f.agents)).find(f=>f.definition.name===n.name&&!f.archived_at),c=(i==null?void 0:i.agent_id)??(await e.createAgent({definition:{version:1,name:n.name,description:n.description,instructions:n.instructions,harness:s,tools:n.tools,skills:[]}})).agent_id,d={input:{content:n.input}},{run:u}=await e.startRun(c,d,r.keyFor(n.name,d));return r.done(),u.run_id}const B$="agentrun.console.start-here.dismissed",YB={hello:ai,web:r1,plan:XT};function QB(){try{return localStorage.getItem(B$)==="true"}catch{return!1}}function JB({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:o=!1,importAction:i,modelSetup:c}){const[d,u]=p.useState(QB),[f,g]=p.useState(!1),[y,v]=p.useState(!1),[h,x]=p.useState(null),[b,j]=p.useState(null),k=H$(e),E=async N=>{x(N.id),j(null);try{j(await s(N))}finally{x(null)}};return d?null:t.jsxs("section",{"aria-label":"Start here",className:"border bg-card p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base font-semibold",children:"Bring your agents into view"}),t.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Connect your Claude Code or Codex setup on this server or another machine. Your coding agent helps choose a live connection or a history import. No model key needed to connect."}),r>0&&t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:[r," imported ",r===1?"session":"sessions"," · ",t.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse history"})]})]}),t.jsx("button",{type:"button","aria-label":"Dismiss introduction",className:"shrink-0 p-1 text-muted-foreground hover:bg-accent hover:text-foreground",onClick:()=>{u(!0);try{localStorage.setItem(B$,"true")}catch{}},children:t.jsx(uo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(ch,{}),i,t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-body text-muted-foreground hover:text-foreground","aria-expanded":f,onClick:()=>{v(!0),g(N=>!N)},children:["Run an agent here ",t.jsx(ri,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`,"aria-hidden":!0})]})]}),y&&t.jsxs("div",{hidden:!f,className:"mt-4 border-t pt-4",children:[c,k?t.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:GB.map(N=>{const S=KB(N,k,n),$=YB[N.id]??ai;return t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx($,{className:"size-4 text-primary-text","aria-hidden":!0}),N.name]}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:N.shows}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:N.description}),S.ok?t.jsx(B,{type:"button",size:"sm",className:"mt-4 self-start",disabled:h!==null,onClick:()=>void E(N),children:h===N.id?"Starting…":"Try it"}):t.jsx("p",{className:"mt-4 font-mono text-small text-muted-foreground",children:S.reason})]},N.id)})}):!c&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Running agents here needs a configured model. ",o?t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline-offset-4 hover:underline",children:"Set up models in Settings"}):"Configure a model where this server runs, then return here."]}),t.jsxs("p",{className:"mt-3 text-body text-muted-foreground",children:["Or ",t.jsx("a",{href:"#/agents/new",className:"text-primary-text underline-offset-4 hover:underline",children:"Create your own"}),": name it, say what it does, pick its tools."]}),b&&t.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:b})]})]})}const XB=["system","light","dark"],Yx="agentrun.theme",ZB="(prefers-color-scheme: dark)",wh=()=>{try{return globalThis.localStorage??null}catch{return null}},q$=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(ZB):null;let Qx=null;function eq(e=wh()){try{const n=e==null?void 0:e.getItem(Yx);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const Jx=(e=wh())=>Qx??eq(e);function tq(e,n=wh()){Qx=null;try{e==="system"?n==null||n.removeItem(Yx):n==null||n.setItem(Yx,e)}catch{Qx=e}}function Xx(e,n=document.documentElement,s=q$()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);n.classList.toggle("dark",r),n.classList.toggle("light",!r)}function nq(e=document.documentElement,n=q$(),s=wh()){Xx(Jx(s),e,n);const r=()=>{Jx(s)==="system"&&Xx("system",e,n)};return n==null||n.addEventListener("change",r),()=>n==null?void 0:n.removeEventListener("change",r)}const sq={mission:"Mission Control",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",triggers:"Triggers",settings:"Settings"},rq={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},oq={system:["System",ii],light:["Light",hR],dark:["Dark",oR]};function aq(){const[e,n]=p.useState(()=>Jx()),s=r=>{tq(r),Xx(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:XB.map(r=>{const[o,i]=oq[r];return t.jsx(B,{variant:"ghost",size:"sm","aria-label":o,title:o,"aria-pressed":e===r,onClick:()=>s(r),className:te("flex flex-1 items-center justify-center py-1.5 text-muted-foreground hover:bg-accent hover:text-foreground",e===r&&"bg-accent text-foreground"),children:t.jsx(i,{className:"size-4","aria-hidden":!0})},r)})})}function GN(){return t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap text-lg font-semibold font-mono","aria-label":"AgentRun",children:[t.jsx("svg",{viewBox:"0 0 64 64",className:"mr-1 size-4 text-primary-text","aria-hidden":!0,children:t.jsx("path",{d:"M18 12L42 32L18 52",fill:"none",stroke:"currentColor",strokeWidth:"8",strokeLinecap:"square",strokeLinejoin:"miter"})}),"agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})}function iq({active:e,settings:n=!1,triggers:s=!1,banners:r,building:o=!1,onBuild:i,onNavigate:c,onSignOut:d,onSignOutEverywhere:u,children:f}){const[g,y]=p.useState(!1),[v,h]=p.useState(!1),x=p.useRef(null),b=p.useRef(null),j=p.useRef(!1);p.useEffect(()=>{var P,A;v?(P=b.current)==null||P.focus():j.current&&((A=x.current)==null||A.focus())},[v]);const k=()=>{j.current=!0,h(!1)},[E,N]=p.useState(!0),S=e==="agents"||e==="runs"||e==="templates";p.useEffect(()=>{(S||o)&&N(!0)},[e,o]);const $=P=>{c?c(P):location.hash=rq[P],y(!1)},_=()=>{i?i():location.hash="#/agents/new",y(!1)},O=sq[e];p.useEffect(()=>{document.title=O?`${O} · AgentRun`:"AgentRun"},[O]);const M=p.useRef(null);return t.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[t.jsx(B,{type:"button",size:"sm",onClick:()=>{var P;return(P=M.current)==null?void 0:P.focus()},className:"sr-only focus-visible:not-sr-only focus-visible:absolute focus-visible:left-2 focus-visible:top-2 focus-visible:z-toast focus-visible:inline-flex focus-visible:bg-card focus-visible:px-3",children:"Skip to the page"}),t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-4 roomy:hidden",children:[t.jsx("button",{type:"button",onClick:()=>$("mission"),"aria-label":"AgentRun home",children:t.jsx(GN,{})}),t.jsx(B,{size:"icon","aria-label":"Navigation","aria-expanded":g,onClick:()=>y(P=>!P),children:t.jsx(nR,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:te("shrink-0 flex-col border-r bg-background roomy:flex roomy:h-dvh roomy:overflow-y-auto roomy:w-sidebar",g?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[t.jsx("div",{className:"hidden h-12 shrink-0 items-center border-b px-4 roomy:flex",children:t.jsx("button",{type:"button",onClick:()=>$("mission"),"aria-label":"AgentRun home",children:t.jsx(GN,{})})}),t.jsxs("nav",{"aria-label":"Navigation",className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-3 pt-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs($r,{className:"w-full",active:e==="mission",onClick:()=>$("mission"),children:[t.jsx(a1,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs($r,{className:"w-full",active:e==="playground",onClick:()=>$("playground"),children:[t.jsx(Em,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs($r,{className:te("w-full",S&&"text-primary-text"),"aria-expanded":E,"aria-controls":"agent-navigation",onClick:()=>N(P=>!P),children:[t.jsx(Xc,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(ri,{className:te("size-3.5 transition-transform",!E&&"-rotate-90"),"aria-hidden":!0})]}),t.jsxs("div",{id:"agent-navigation",hidden:!E,className:"space-y-0.5",children:[t.jsxs($r,{className:"w-full pl-8",active:o,onClick:_,children:[t.jsx(QT,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs($r,{className:"w-full pl-8",active:e==="agents"&&!o,onClick:()=>$("agents"),children:[t.jsx(Xc,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs($r,{className:"w-full pl-8",active:e==="templates",onClick:()=>$("templates"),children:[t.jsx(Tm,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs($r,{className:"w-full pl-8",active:e==="runs",onClick:()=>$("runs"),children:[t.jsx(bd,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs($r,{className:"w-full",active:e==="triggers",onClick:()=>$("triggers"),children:[t.jsx(vd,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs($r,{className:"w-full",active:e==="dojo",onClick:()=>$("dojo"),children:[t.jsx(KC,{size:16,className:"shrink-0"}),"Learning Dojo"]})]}),n&&t.jsx("div",{"data-sidebar-account":!0,className:"mt-auto border-t pb-2 pt-3",children:t.jsxs($r,{className:"w-full",active:e==="settings",onClick:()=>$("settings"),children:[t.jsx(c1,{className:"size-4 shrink-0","aria-hidden":!0}),"Settings"]})})]}),t.jsxs("div",{className:"shrink-0 space-y-2 px-3 pb-4 pt-3",children:[t.jsx(aq,{}),t.jsxs(B,{onClick:d,className:"w-full justify-start",children:[t.jsx(eR,{"aria-hidden":!0}),"Sign out"]}),u&&(v?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:P=>{P.key==="Escape"&&k()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"xs",variant:"destructive",onClick:()=>{h(!1),u()},children:"Sign out everywhere"}),t.jsx(B,{size:"xs",ref:b,onClick:k,children:"Cancel"})]})]}):t.jsx(B,{size:"sm",variant:"ghost",ref:x,onClick:()=>h(!0),className:"mt-1 w-full justify-start text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]})]}),t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(xW,{}),r,t.jsx("main",{ref:M,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:f})]})]})}const G$=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function lq(e,n){if(G$(e))return n===200?"signed_in":"token_link";const s=e.body??{};return s.signed_in?"signed_in":s.password_set?"sign_in":"setup"}const cq=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0},K$=e=>/\.onrender\.com$/i.test(e),V$=e=>/\.up\.railway\.app$/i.test(e);function dq(e){const n="find the newest line that starts “Set up this server:”. Open that line's link, or paste what follows code= here.";return K$(e)?["This server is on Render. In the Render dashboard, open this service's Environment tab and paste the value of AGENTRUN_TOKEN here.",`Or open the service's Logs tab and ${n}`,"A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the Logs tab. AGENTRUN_TOKEN does not expire."]:V$(e)?["This server is on Railway. In the Railway dashboard, open this service's Variables tab and paste the value of AGENTRUN_TOKEN here.",`Or open the Deploy Logs of the service's latest deployment and ${n}`,"A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the Deploy Logs. AGENTRUN_TOKEN does not expire."]:[`The server printed it in its log: ${n}`,"The log is the terminal the server runs in. In Docker: docker logs <container>, or docker compose logs. On Render: the service's Logs tab.","A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the log. The server's API token works here too and does not expire: AGENTRUN_TOKEN (on Render, in the service's Environment tab), else the .token file in the server's data folder."]}function uq(e,n){const r=`it is the newest “Set up this server:” line in ${K$(e)?"the service's Logs tab in the Render dashboard":V$(e)?"the Deploy Logs of the service's latest deployment in the Railway dashboard":"the server's log (the terminal it runs in, docker logs <container>, or Render's Logs tab)"}.`;return n.printed?`The server printed a new code: ${r} It works once, until ${ti(n.expires_at)}.`:`The current code is still good until ${ti(n.expires_at)}, so no new one was printed: ${r}`}const fq=e=>{const n=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Try again in ${n===1?"a second":n>=60?"a minute":`${n} seconds`}.`};function mq(e){return e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.message}function hq(e){var n,s;return e.status===401?"That is not the password.":e.status===429?`Too many sign-ins. ${fq(e)}`:e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.status===403&&/a new one is in the server's log/.test(e.message)?"That setup code expired (a code lasts 30 minutes) or was voided after too many wrong tries. The server printed a new one: use the newest “Set up this server:” line in its log (on Render, the Logs tab).":e.status===403&&/takes the setup code/.test(e.message)?"Enter the setup code from the server's log.":e.status===403&&/setup code/.test(e.message)?"That setup code was refused: open the newest setup link in the server's log, or paste the server's token (AGENTRUN_TOKEN) here. A code works once and lasts 30 minutes: Get a new code prints a fresh one when it has run out.":((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message}function Y$(e){const n=new URLSearchParams(e.startsWith("#")?e.slice(1):e),s=n.get("code");if(s===null)return{code:null,rest:e};n.delete("code");const r=n.toString();return{code:/^[A-Za-z0-9_-]*/.exec(s)[0],rest:r?`#${r}`:""}}const Ug={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},KN={sign_in:{title:"Sign in",body:"Sign in to make agents, start runs and follow them on this server."},setup:{title:"Start building",body:"This is the server's first visit: set the owner's password. You sign in with it from now on."},token_link:{title:"Open the server's link",body:"This server has no accounts. Open the link it printed when it started: it signs this browser in, and its code leaves the address."}};function pq({mode:e,code:n=null,codeNeeded:s=!1,onSubmit:r,onNewCode:o,problem:i=null,offer:c=null,host:d=typeof window>"u"?"":window.location.hostname}){const[u,f]=p.useState(""),[g,y]=p.useState([]),[v,h]=p.useState(""),[x,b]=p.useState(n??"");p.useEffect(()=>{n!==null&&b(n)},[n]);const[j,k]=p.useState(i),[E,N]=p.useState(!1),[S,$]=p.useState(null),[_,O]=p.useState(!1),M=async()=>{if(!(!o||_)){O(!0);try{$(await o()),k(null)}catch(U){$(null),k(U instanceof Error?U.message:String(U))}finally{O(!1)}}},P=e==="setup",A=P&&c!==null&&!("sessions"in c&&c.sessions===0),R=P&&(s||n!==null),L=e!=="token_link"&&u.length>0&&(!P||u===v&&u.length>=12)&&(!R||x.trim()!==""),W=async()=>{if(!L||!r)return;N(!0);const U=P&&c&&"candidates"in c?(c.candidates??[]).map(D=>D.id):[],Y=await r(u,R&&x.trim()?x.trim():void 0,g.filter(D=>U.includes(D)));N(!1),k(Y)};return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[t.jsx(As,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:KN[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:KN[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:U=>{U.preventDefault(),W()},children:[R&&t.jsx(St,{label:"Setup code",id:"setup-code",hint:dq(d).map((U,Y)=>t.jsx("span",{className:te("block leading-relaxed",Y>0&&"mt-1.5"),children:U},Y)),children:t.jsx(De,{name:"setup-code",value:x,onChange:U=>b(U.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),R&&o&&t.jsxs("div",{className:"!mt-3",children:[t.jsx(B,{type:"button",size:"sm",disabled:_,"aria-busy":_||void 0,onClick:()=>void M(),children:"Get a new code"}),S&&t.jsx("p",{className:"mt-2 text-small leading-relaxed text-foreground",role:"status",children:S})]}),t.jsx(St,{label:Ug[e].label,note:P?"12 characters or more.":void 0,children:t.jsxs("span",{className:te(Za,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ka,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(De,{bare:!0,type:"password",value:u,onChange:U=>f(U.target.value),autoComplete:Ug[e].autocomplete,autoFocus:!0,"aria-label":Ug[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),P&&t.jsx(St,{label:"Again",note:v&&v!==u?"The two passwords differ.":void 0,children:t.jsxs("span",{className:te(Za,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ka,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(De,{bare:!0,type:"password",value:v,onChange:U=>h(U.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),A&&t.jsx(xq,{offer:c,chosen:g,onChange:y}),t.jsx(B,{type:"submit",variant:"solid",disabled:!L||E,"aria-busy":E||void 0,className:"w-full text-body",children:E?"Signing in":P?"Set password and continue":"Continue"}),j&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:j}),!P&&t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",t.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const Mc=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,gq={"claude-code":"Claude Code",codex:"Codex",pi:"pi"},Wg="Import sessions from this machine";function xq({offer:e,chosen:n,onChange:s}){if("counting"in e)return t.jsx(St,{group:!0,label:Wg,children:t.jsxs("p",{className:"flex items-center gap-2 text-small text-muted-foreground",role:"status",children:[t.jsx(Cv,{}),"Looking for this machine's Claude Code, Codex and pi sessions…"]})});const r=e.candidates??[];if(e.sessions===null||e.projects===null||!r.length)return t.jsx(St,{group:!0,label:Wg,children:t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:"This machine's sessions couldn't be listed, so there is nothing to choose here. To import them later, run agentrun-serve import with the server stopped."})});const o=r.filter(d=>n.includes(d.id)),i=o.length===r.length,c=Date.now();return t.jsx(St,{group:!0,label:Wg,aside:t.jsx(B,{type:"button",size:"xs",variant:"ghost",onClick:()=>s(i?[]:r.map(d=>d.id)),children:i?"Clear":"Select all"}),note:`${Mc(e.sessions,"session")} in ${Mc(e.projects,"project")}, from Claude Code, Codex and pi. Tick the projects to import: each becomes an agent, each session a run you can read. Nothing is imported unless you tick it.${e.projects>r.length?` The ${r.length.toLocaleString("en-US")} most recently active are listed.`:""}`,hint:t.jsx("span",{"aria-live":"polite",children:o.length?`${Mc(o.length,"project")}, ${Mc(o.reduce((d,u)=>d+u.sessions,0),"session")} chosen.`:"None chosen: nothing will be imported."}),children:t.jsx("div",{className:"max-h-56 space-y-3 overflow-y-auto border p-3",children:r.map(d=>t.jsx(FM,{name:"import",value:d.id,checked:n.includes(d.id),onChange:u=>s(u.target.checked?[...n,d.id]:n.filter(f=>f!==d.id)),label:t.jsx("span",{className:"break-all font-mono",children:d.name}),note:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block",children:[Mc(d.sessions,"session"),d.sources.map(u=>gq[u]??u).join(", "),...d.last_active?[`active ${zl(d.last_active,c)} ago`]:[]].join(" · ")}),t.jsx("span",{className:"block break-all font-mono",children:d.path})]})},d.id))})})}function vq({problem:e,starting:n=!1,onRetry:s}){return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[t.jsx(As,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:n?"This server is starting":"Can't read this server's sign-in"}),t.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:n?"Its address answers for it until it is up (a first start, a redeploy or a wake can take a minute or two). Trying again…":"The page asked the server whether it has its owner yet, and got no answer it could read, so it can't show setup or sign-in. It asks again on its own."}),t.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),t.jsx(B,{type:"button",variant:"solid",onClick:s,className:"w-full text-body",children:"Retry now"})]})})}const bq=1e4;function VN(e=location.hash){if(e==="#/dojo")return{section:"dojo"};const n=e.match(/^#\/observations\/([^/?]+)$/);if(n)return{section:"agents",observation:decodeURIComponent(n[1])};let s=e.match(/^#\/runs\/([^/?]+)$/);if(s)return{section:"runs",run:decodeURIComponent(s[1])};if(e==="#/agents/connect"||e.startsWith("#/agents/connect?")){const c=new URLSearchParams(e.split("?")[1]??"").get("source");return{section:"agents",nativeConnect:!0,...c==="remote"||c==="observe"?{connectionSource:c}:{}}}if(e==="#/agents/new")return{section:"agents",agent:null};if(s=e.match(/^#\/agents\/([^/?]+)\/edit\?(.*)$/),s){const c=new URLSearchParams(s[2]).get("tool");return{section:"agents",agent:decodeURIComponent(s[1]),edit:!0,...c?{tool:c}:{}}}if(s=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),s)return{section:"agents",agent:decodeURIComponent(s[1]),...s[2]==="edit"?{edit:!0}:s[2]?{tab:s[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground")){const c=new URLSearchParams(e.split("?")[1]??""),d=c.get("agent"),u=c.get("operation"),f=c.get("draft");if(u==="apply-template"){const g=c.get("template");return{section:"playground",operation:u,...g?{template:g}:{},...f!==null?{draft:f}:{}}}return{section:"playground",...d?{playgroundAgent:d}:{},...u==="create-agent"||u==="edit-agent"||u==="list-runs"?{operation:u}:{},...f!==null?{draft:f}:{},...u==="list-runs"&&ym.includes(c.get("status"))?{status:c.get("status")}:{},...u==="list-runs"&&c.get("archived")==="true"?{archived:!0}:{}}}if(s=e.match(/^#\/templates\/install\?(.*)$/),s)return{section:"templates",install:new URLSearchParams(s[1]).get("src")??""};if(s=e.match(/^#\/templates\/([^/?]+)$/),s)return{section:"templates",template:decodeURIComponent(s[1])};if(e.startsWith("#/templates"))return{section:"templates"};if(e==="#/triggers/new")return{section:"triggers",trigger:null,kind:"schedule"};if(e==="#/triggers/new-webhook")return{section:"triggers",trigger:null,kind:"webhook"};if(e==="#/triggers/new-github")return{section:"triggers",trigger:null,kind:"github"};if(e==="#/triggers/new-composio")return{section:"triggers",trigger:null,kind:"composio"};if(e==="#/triggers/new-feed")return{section:"triggers",trigger:null,kind:"feed"};if(s=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),s)return{section:"triggers",trigger:decodeURIComponent(s[1]),...s[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(s=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),s){const c=vz(s[1]);return{section:"settings",settings:"mcp",signIn:Nz(s[1]),...c?{add:c}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const c=wW(s[1]);return{section:"settings",settings:"github",...c?{github:c}:{}}}if(s=e.match(/^#\/settings(?:\/(keys|tools|email|computers|workspace|webhook))?$/),s)return{section:"settings",settings:s[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const r=new URLSearchParams(e.slice(7)),o=r.get("agent"),i=r.get("status");return{section:"runs",...o?{runsOf:o}:{},...i&&ym.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function yq({runsOf:e,status:n,archived:s}){const r=new URLSearchParams;return e&&r.set("agent",e),n&&r.set("status",n),s&&r.set("archived","true"),`#/runs${r.size?`?${r}`:""}`}let Hg;function wq(){if(!Hg){const{code:e,rest:n}=Y$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),Hg={code:e}}return Hg.code}const jq=e=>Math.min(1e3*2**e,3e4),Q$=1e3,kq=30;function Nq(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":e.state==="failed"?"The import of this machine's sessions was given up before it finished. The server's log says why.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function Sq(){const[e]=p.useState(qL),[n,s]=p.useState(null),[r,o]=p.useState(!1),i=p.useRef(null);i.current=n;const c=p.useRef(!1),d=p.useRef(async()=>{}),u=p.useMemo(()=>TL({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,g]=p.useState(wq);p.useEffect(()=>{if(n!=="setup")return;const _=()=>{const{code:O,rest:M}=Y$(location.hash);O!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${M}`),g(O))};return window.addEventListener("hashchange",_),_(),()=>window.removeEventListener("hashchange",_)},[n]);const[y,v]=p.useState(!1),h=async()=>{const _=await u.session(),O=G$(_)?await u.listAgents().then(()=>200,M=>M instanceof Ue?M.status:0):void 0;return{mode:lq(_,O),codeNeeded:cq(_)}},x=async()=>{const _=await h();return v(_.codeNeeded),_.mode},b=async()=>s(await x());d.current=async()=>{if(!(i.current!=="signed_in"||c.current)){c.current=!0;try{const _=await x();_!=="signed_in"&&i.current==="signed_in"&&(o(!0),s(_))}catch{}finally{c.current=!1}}};const[j,k]=p.useState(null),[E,N]=p.useState(0);p.useEffect(()=>{let _=!0,O;return h().then(M=>{!_||i.current!==null||(v(M.codeNeeded),s(M.mode),k(null))},M=>{if(!_||i.current!==null)return;const P=jq(E),A=M instanceof Ue?M:null,R=(A==null?void 0:A.code)==="http_error",L=R&&[502,503,504].includes(A.status);k({problem:A===null?Gt(M):L?`Its address answered ${A.status}, not the server.`:`GET /v2/auth/session answered ${A.status}${R?", not as this server answers":`: ${A.message}`}`,starting:L}),O=setTimeout(()=>N(W=>W+1),P)}),()=>{_=!1,clearTimeout(O)}},[u,E]);const[S,$]=p.useState(null);return p.useEffect(()=>{if(n!=="setup")return;let _=!0;return(async()=>{for(let O=!1;_;){const M=await u.setupImport().then(P=>P,()=>{});if(!_)return;if(M===void 0&&O)return void $({projects:null,sessions:null});if(M!==void 0&&(!M||!("counting"in M||"sessions"in M)||($(M),O=!0,!("counting"in M))))return;await new Promise(P=>setTimeout(P,Q$))}})(),()=>{_=!1}},[u,n]),n===null&&j!==null?t.jsx(vq,{problem:j.problem,starting:j.starting,onRetry:()=>N(_=>_+1)}):n===null?t.jsx(aN,{connection:e,children:t.jsx(Cq,{})}):n!=="signed_in"?t.jsx(pq,{mode:n,code:f,codeNeeded:y,offer:S,problem:r&&n==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(_,O,M)=>{try{return await(n==="setup"?u.setup(_,O,M):u.signIn(_)),o(!1),s("signed_in"),null}catch(P){return P instanceof Ue&&P.status===403&&n==="setup"&&await b().catch(()=>{}),P instanceof Ue?hq(P):P instanceof Error?P.message:String(P)}},onNewCode:async()=>{try{return uq(window.location.hostname,await u.setupCode())}catch(_){throw _ instanceof Ue&&_.status===403&&await b().catch(()=>{}),new Error(_ instanceof Ue?mq(_):_ instanceof Error?_.message:String(_))}}},n):t.jsx(aN,{connection:e,children:t.jsx(Eq,{v2:u,onSignedOut:()=>{o(!1),s("sign_in")}})})}function Cq(){return Kb().state==="offline"?t.jsx(vW,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function Eq(e){const n=p.useMemo(Hd,[e.v2]);return t.jsx($q,{...e},n)}function $q({v2:e,onSignedOut:n}){var pa,js,Jd,cs,Xd,Zd,eu,ga,xa,ho,va,tu,nu,pi,Dl,gi,po,su,xi,At,Fl,Ul,vi,Wl,Hl,Bl,bi,ba,Zs,er,tr,go;const{writable:s,whyNot:r}=NF(e),[o,i]=p.useState(null),[c,d]=p.useState(()=>VN()),[u,f]=p.useState(null),g=((js=(pa=u==null?void 0:u.features)==null?void 0:pa.triggers)==null?void 0:js.routes)===!0,[y,v]=p.useState(new Map);p.useEffect(()=>{if(!g)return;let xe=!0;return e.listTriggers().then(Ce=>{xe&&v(new Map(Ce.triggers.map(He=>[He.id,{name:He.name,kind:He.source.kind}])))},()=>{}),()=>{xe=!1}},[e,g,c.section,c.trigger]);const[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(0),[N,S]=p.useState("30d"),$=N==="7d"?7:30,_=zv(e,{active:c.section==="mission"||c.section==="runs"&&!c.run&&!c.runsOf&&!c.archived&&!c.status,days:$}),[O,M]=p.useState(null),[P,A]=p.useState(!1),R=p.useRef(!1),[L,W]=p.useState(null),[U,Y]=p.useState(null),[D,G]=p.useState(null),[F,q]=p.useState(0),H=p.useRef(null),[I,V]=p.useState(!1),[J,X]=p.useState(!1),[re,ae]=p.useState(!1),[ye,he]=p.useState(null),[we,ze]=p.useState(null),[le,me]=p.useState(!1),[Ke,be]=p.useState({}),[ge,Je]=p.useState(!1),tt=p.useRef(0),[ft,ve]=p.useState([]),Ee=p.useRef(-1),[Q,Me]=p.useState(null),[pe,ne]=p.useState(0),Ae=p.useRef(0),Pe=xe=>{Sf(xe)||(location.hash=xe)},[bt,ot]=p.useState(null),[mt,Re]=p.useState(0);p.useEffect(()=>{let xe=!0;return(async()=>{let Ce=!1;for(let He=0;xe&&He<kq;){const _t=await e.setupImport().then(yt=>yt,()=>{});if(!xe)return;if(_t===void 0)He+=1;else{if(He=0,!_t||!("state"in _t))return;if(ot(_t),_t.state!=="running")return void(Ce&&Re(yt=>yt+1));Ce=!0}await new Promise(yt=>setTimeout(yt,Q$))}})(),()=>{xe=!1}},[e]),p.useEffect(()=>{const xe=()=>{const Ce=C9();Sf(location.hash,()=>{Ce&&history.go(-Ce)})?Ce&&history.go(Ce):d(VN())};return window.addEventListener("hashchange",xe),()=>window.removeEventListener("hashchange",xe)},[]),p.useEffect(()=>S9(),[]);const lt=p.useRef(0),$t=p.useRef(!1),nt=()=>{const xe=++lt.current;return e.capabilities().then(Ce=>(xe===lt.current&&f(Ce),!0),()=>!1)};p.useEffect(()=>{nt()},[e]),p.useEffect(()=>{if(tt.current&&c.section!=="runs"&&c.section!=="mission"&&Ee.current===mt)return;Ee.current=mt;const xe=++tt.current;Je(!1),Promise.allSettled([!1,!0].map(Ce=>Mr(He=>e.listAgents({archived:Ce,cursor:He}),He=>He.agents))).then(Ce=>{if(xe!==tt.current)return;const He=Object.fromEntries(Ce.flatMap(yt=>yt.status==="fulfilled"?yt.value:[]).map(yt=>[yt.agent_id,yt.definition.name??yt.agent_id])),_t=Ce.every(yt=>yt.status==="fulfilled");be(yt=>_t?He:{...yt,...He}),Je(_t)})},[e,c,mt]);const fe={status:c.status,archived:c.archived};p.useEffect(()=>{if(c.section!=="runs"||c.run)return;const xe=++Ae.current;he(null),Me(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,fe):e.listRuns(50,null,fe)).then(Ce=>{xe===Ae.current&&(he(Ce.runs),ze(Ce.next_cursor))}).catch(Ce=>{xe===Ae.current&&Me(Jt(Ce,"the runs"))})},[e,c,mt,pe]);const st=xe=>{var Ce;return Ke[xe]??((Ce=Le==null?void 0:Le.find(He=>He.agent_id===xe))==null?void 0:Ce.definition.name)??(ge?xe:"")},Qe=u,ct={harnesses:(Qe==null?void 0:Qe.harnesses)??[],tools:KP(Qe==null?void 0:Qe.tools),thinking:((Jd=Qe==null?void 0:Qe.features)==null?void 0:Jd.thinking)??[],...typeof((cs=u==null?void 0:u.limits)==null?void 0:cs.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},gt=ZD(Qe==null?void 0:Qe.tools),Et=t6(Qe==null?void 0:Qe.tools),se=[...(Zd=(Xd=u==null?void 0:u.features)==null?void 0:Xd.tool_keys)!=null&&Zd.routes?["keys"]:[],...gt.length||Et.length?["tools"]:[],"mcp","github","email","computers","workspace",...(ga=(eu=u==null?void 0:u.features)==null?void 0:eu.webhooks)!=null&&ga.routes?["webhook"]:[]],$e=xe=>Pe({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${se[0]??"keys"}`}[xe]),Fe=p.useRef(br()).current,et=async xe=>{const Ce=H$(ct.harnesses);if(!Ce)return"This server has no model to run it on yet.";try{const He=await VB(e,xe,Ce,Fe);return Pe(`#/runs/${encodeURIComponent(He)}`),null}catch(He){return Gt(He)}},Dt=((h==null?void 0:h.analytics.by_source)??[]).filter(xe=>xe.source!=="live").reduce((xe,Ce)=>xe+Ce.runs,0),[Le,rt]=p.useState(null),[Ft,jn]=p.useState([]),[Rt,Un]=p.useState(null),ys=p.useRef(Rt);ys.current=Rt;const[ws,Z]=p.useState(null),[Ie,ht]=p.useState(0),Ct=p.useRef(0);p.useEffect(()=>{rt(null),Z(null),Un(null),ys.current=null},[e,c.section,c.operation,c.playgroundAgent]),p.useEffect(()=>{if(c.section!=="playground"||c.operation)return;Z(null);const xe=++Ct.current;return Mr(Ce=>e.listAgents({cursor:Ce}),Ce=>Ce.agents).then(Ce=>{var yt;if(xe!==Ct.current)return;const He=Ce.filter(kr=>!kr.archived_at),_t=ys.current??c.playgroundAgent;if(_t&&!He.some(kr=>kr.agent_id===_t)){rt(null),Un(null),Z("The selected agent is unavailable or archived. Choose another agent from Agents.");return}rt(Ce),Un(_t??((yt=He[0])==null?void 0:yt.agent_id)??null)}).catch(Ce=>{if(xe===Ct.current){const He=Jt(Ce,"the agents");Z(`${He.why} ${He.next}${He.said?` (${He.said})`:""}`)}}),()=>{Ct.current++}},[e,c.section,c.operation,c.playgroundAgent,Ie,mt]),p.useEffect(()=>{if(c.section!=="mission")return;let xe=!0;R.current=!0,j(null),A(!0);const Ce=Wv(N);return Promise.all([e.statsOver({...Ce?{from:Ce}:{},...O?{agent:O}:{}}),O?e.listAgentRuns(O,10):e.listRuns(10)]).then(([He,_t])=>{xe&&(x(ZL(He,_t.runs)),O||G(yt=>yt||oW(_t.runs,He.analytics.by_source)))}).catch(He=>{xe&&j(Jt(He,"Mission Control"))}).finally(()=>{xe&&(R.current=!1,A(!1))}),()=>{xe=!1,R.current=!1}},[e,c.section,k,N,O,mt]),f$(()=>E(xe=>xe+1)),p.useEffect(()=>{if(c.section!=="mission")return;const xe=()=>{!document.hidden&&!R.current&&E(He=>He+1)};window.addEventListener("focus",xe),document.addEventListener("visibilitychange",xe);const Ce=setInterval(xe,15e3);return()=>{window.removeEventListener("focus",xe),document.removeEventListener("visibilitychange",xe),clearInterval(Ce)}},[c.section]),p.useEffect(()=>{if(c.section!=="mission"){H.current=null;return}let xe=!0;const Ce=H,He=Wn=>Mr(Pn=>e.listRuns(50,Pn,{status:Wn}),Pn=>Pn.runs,2),_t=()=>Mr(Wn=>e.listAgents({archived:!1,cursor:Wn}),Wn=>Wn.agents).then(Wn=>{xe&&ve(Wn.filter(Pn=>am(Pn)>0).map(Pn=>({agent_id:Pn.agent_id,name:Pn.definition.name??Pn.agent_id,pending:am(Pn)})))},()=>{}),kr=iW(()=>Promise.allSettled([He("input_required"),He("failed"),He("working"),_t()]).then(([Wn,Pn,ru])=>{var vo,Wr,wa;if(!xe)return;const xo=[Wn,Pn,ru],ya=Date.now()-rW;if(Y(tN(null,xo).problem),((vo=xo[0])==null?void 0:vo.status)==="fulfilled"&&V(!0),((Wr=xo[1])==null?void 0:Wr.status)==="fulfilled"){X(!0);const yi=xo[1].value.map(Ms=>Ms.run_id),bo=Ce.current;bo&&yi.some(Ms=>!bo.has(Ms))&&E(Ms=>Ms+1),Ce.current=new Set(yi)}((wa=xo[2])==null?void 0:wa.status)==="fulfilled"&&ae(!0),W(yi=>{const{needs:bo}=tN(yi,xo);return{asking:bo.asking.filter(d$),failed:bo.failed.filter(Ms=>Date.parse(Ms.ended_at??Ms.created_at)>ya),live:bo.live}})}),1e4);return()=>{xe=!1,kr()}},[e,c.section,F]);const Ht=p.useRef(YD()).current,xn=()=>setTimeout(()=>q(xe=>xe+1),2500),tn=async(xe,Ce)=>{try{return await UC(Ht(xe),xe,Ce,e.sendMessage),xn(),null}catch(He){return Gt(He)}},vn=p.useRef(new Map).current,ls=async xe=>{const Ce=[];try{for(const He of xe){const _t=aW(He.kind==="workflow"?He:await e.getRun(He.run_id));if("refusal"in _t)throw new Error(_t.refusal);const yt=vn.get(He.run_id)??Hd();vn.set(He.run_id,yt),await e.startRun(He.agent_id,_t.body,yt),Ce.push(He.run_id)}return xn(),{started:Ce,problem:null}}catch(He){return Ce.length&&xn(),{started:Ce,problem:Gt(He)}}},yr=async xe=>{try{return await e.stop(xe),xn(),null}catch(Ce){return Gt(Ce)}},wr=async(xe,Ce,He,_t,yt)=>{let kr=null;try{await e.answerApproval(xe,Ce,He,_t,yt)}catch(Wn){kr=g$(Wn)}return q(Wn=>Wn+1),kr},Ur=async(xe,Ce)=>{let He=null;try{await e.handBackComputer(xe,Ce)}catch(_t){He=Bx(_t,"hand")}return q(_t=>_t+1),He},Ze=p.useRef(0);p.useEffect(()=>{const xe=++Ze.current;jn([]),Rt&&Mr(Ce=>e.listRevisions(Rt,Ce),Ce=>Ce.revisions).then(Ce=>{xe===Ze.current&&jn(Ce)}).catch(()=>{})},[e,Rt]);const ie=async(xe,Ce,He)=>{const _t=performance.now();try{const yt=await e.startRun(xe,Ce,He);return{status:yt.status,ms:Math.round(performance.now()-_t),body:yt.run,runId:yt.run.run_id}}catch(yt){return Gb(yt,Math.round(performance.now()-_t))}},_e=((xa=u==null?void 0:u.features)==null?void 0:xa.efforts)??[],qe=u?((ho=u.features)==null?void 0:ho.learning)??null:void 0;ct.learning=qe??void 0;const Lt=(va=u==null?void 0:u.models)==null?void 0:va.ready;p.useEffect(()=>{if(Lt!==!1)return;const xe=()=>{$t.current||($t.current=!0,nt().finally(()=>{$t.current=!1}))},Ce=()=>nt(),He=setInterval(xe,bq);return window.addEventListener("focus",Ce),()=>{clearInterval(He),window.removeEventListener("focus",Ce)}},[e,Lt]);const[Bt,pt]=p.useState(null);p.useEffect(()=>{if(Lt!==!1)return;let xe=!0;return e.chatGPT().then(Ce=>{xe&&pt(Zf(Ce))},()=>{xe&&pt(null)}),()=>{xe=!1}},[e,Lt]);const[En,Ln]=p.useState(!1),jr=xe=>{pt(xe),(xe.state==="pending"||xe.state==="signed_in")&&Ln(!0),xe.state==="signed_in"&&nt()},Kt=(tu=Le==null?void 0:Le.find(xe=>xe.agent_id===Rt))==null?void 0:tu.definition,hi=(Kt==null?void 0:Kt.native)||os(Kt),mo=c.operation?c.playgroundAgent:Rt??c.playgroundAgent;return t.jsx(i$.Provider,{value:y,children:t.jsx(iq,{active:c.section,building:c.section==="agents"&&c.agent===null,onBuild:()=>Pe("#/agents/new"),settings:se.length>0,triggers:g,onNavigate:$e,onSignOut:()=>{const xe=()=>void e.signOut().then(n,Ce=>i(Ce instanceof Ue?Ce.message:"The sign-out did not reach the server. Try again."));Sf(null,xe)||xe()},onSignOutEverywhere:()=>{const xe=()=>void e.signOutEverywhere().then(n,Ce=>i(Ce instanceof Ue?Ce.message:"The sign-out did not reach the server. Try again."));Sf(null,xe)||xe()},banners:t.jsxs(t.Fragment,{children:[o&&t.jsxs("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-destructive-text md:px-8",role:"alert",children:["Not signed out: ",o]}),bt&&t.jsxs("p",{className:"flex items-center gap-3 border-b bg-card px-5 py-3 font-mono text-body md:px-8",role:"status",children:[t.jsx("span",{className:"flex-1",children:Nq(bt)}),bt.state!=="running"&&t.jsx(B,{size:"xs",type:"button",onClick:()=>ot(null),children:"Dismiss"})]})]}),children:c.section==="settings"?t.jsx(YU,{active:c.settings??"keys",offered:se,children:c.settings==="tools"?t.jsx(yW,{v2:e,choices:gt,gates:Et,harnesses:ct.harnesses,mcp:!!((nu=u==null?void 0:u.features)!=null&&nu.mcp_client),onSaved:nt,onOpen:nt}):c.settings==="mcp"?t.jsx($W,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:gt}):c.settings==="github"?t.jsx(SW,{v2:e,returned:c.github}):c.settings==="email"?t.jsx(YW,{v2:e,writable:s,whyNot:r}):c.settings==="computers"?t.jsx(n9,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?t.jsx(m9,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?t.jsx(JW,{v2:e}):t.jsx(mW,{v2:e,onChange:nt,writable:s,whyNot:r,harnesses:ct.harnesses,plan:t.jsxs(t.Fragment,{children:[t.jsx($F,{v2:e,writable:s,whyNot:r,onChange:()=>void nt()}),t.jsx(MF,{v2:e,writable:s,whyNot:r,onChange:()=>void nt()})]})})}):c.section==="dojo"?t.jsx(w6,{v2:e,server:qe},mt):c.section==="mission"?t.jsx("div",{className:"flex h-full flex-col",children:t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(PB,{hasObservedSessions:!!((pi=_.data)!=null&&pi.sessions.length),observations:t.jsx(Dv,{read:_,view:"summary",days:$}),view:h,error:b,onRetry:()=>E(xe=>xe+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"icon","aria-label":"Refresh Mission Control",disabled:P,onClick:()=>{E(xe=>xe+1),q(xe=>xe+1)},children:t.jsx(oa,{className:"size-4","aria-hidden":!0})}),t.jsx(an,{label:"Query",prompt:eh(location.origin,O??void 0),playgroundHref:Fv(O??void 0)}),t.jsx(ch,{variant:"primary"})]}),scope:{range:N,onRange:S,agent:O,onAgent:M,refreshing:P&&h!==null},asking:L&&I?L.asking.length:null,failed:L&&J?c$(L.failed):null,live:L&&re?L.live.length:null,needsYou:L&&t.jsx(zB,{asking:L.asking,failed:L.failed,failedAll:h==null?void 0:h.runs.failed,live:L.live,learning:ft,problem:U,agentName:st,onAnswer:tn,onApprove:wr,onHandBack:Ur,onRunAgain:ls,onStop:yr}),startHere:D===!1&&!((Dl=_.data)!=null&&Dl.sessions.length)?t.jsx(JB,{harnesses:ct.harnesses,tools:ct.tools,onTry:et,imported:Dt,keySettings:((po=(gi=u==null?void 0:u.features)==null?void 0:gi.tool_keys)==null?void 0:po.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||En)?t.jsx(WW,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:nt,writable:s,whyNot:r,plan:Bt,harnesses:ct.harnesses,onPlan:jr,onDone:()=>Ln(!1)}):void 0}):void 0})})}):c.section==="templates"?t.jsx(Y0,{v2:e,name:c.template,install:c.install,go:Pe},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?t.jsx(iU,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Pe,agentName:st,minEvery:(xi=(su=u==null?void 0:u.features)==null?void 0:su.triggers)==null?void 0:xi.min_every_s,failuresToPause:(Fl=(At=u==null?void 0:u.features)==null?void 0:At.triggers)==null?void 0:Fl.failures_to_pause,publicUrl:(vi=(Ul=u==null?void 0:u.features)==null?void 0:Ul.triggers)==null?void 0:vi.public_url}):c.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("header",{className:te(vr,"gap-2 px-5"),children:t.jsxs("h1",{className:Jo,children:[t.jsx(Em,{className:"size-4","aria-hidden":!0}),"API playground"]})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-6 py-4",children:[t.jsx("label",{className:"sr-only",htmlFor:"api-operation",children:"API operation"}),t.jsx(Mt,{id:"api-operation",label:"API operation",steady:!0,value:c.operation??"run",onChange:xe=>{const Ce=mo,He=new URLSearchParams;xe!=="run"&&He.set("operation",xe),xe!=="create-agent"&&xe!=="apply-template"&&Ce&&He.set("agent",Ce),Pe(`#/playground${He.size?`?${He}`:""}`)},options:[{value:"create-agent",label:"POST · Create an agent"},{value:"apply-template",label:"POST · Apply a template"},{value:"run",label:"POST · Start a run"},{value:"list-runs",label:"GET · Query runs"},{value:"edit-agent",label:"PUT · Edit agent",disabled:!mo}]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:c.operation==="apply-template"?`/v2/templates/${c.template?encodeURIComponent(c.template):"{template}"}/apply`:c.operation==="list-runs"?c.playgroundAgent?`/v2/agents/${c.playgroundAgent}/runs`:"/v2/runs":c.operation==="create-agent"?"/v2/agents":c.operation==="edit-agent"?`/v2/agents/${c.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"})]}),c.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(Y0,{v2:e,name:c.template,go:Pe,playground:!0,draft:c.draft},c.template??"")}):c.operation==="list-runs"?t.jsx(GU,{v2:e,origin:location.origin,agentId:c.playgroundAgent,filter:{status:c.status,archived:c.archived}},`list:${c.playgroundAgent??""}:${c.status??""}:${c.archived??!1}`):c.operation?t.jsx(KU,{v2:e,operation:c.operation,origin:location.origin,agentId:c.playgroundAgent,draft:c.draft,harnesses:ct.harnesses,routePrefix:(Wl=Qe==null?void 0:Qe.models)==null?void 0:Wl.route_prefix},`${c.operation}:${c.playgroundAgent??""}:${c.draft??""}`):t.jsxs(t.Fragment,{children:[!hi&&((Hl=u==null?void 0:u.models)==null?void 0:Hl.ready)===!1&&t.jsx(HW,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((bi=(Bl=u.features)==null?void 0:Bl.tool_keys)==null?void 0:bi.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(Bt==null?void 0:Bt.state)==="signed_out"||(Bt==null?void 0:Bt.state)==="expired"}),ws&&t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"text-lead text-destructive-text",children:["The agents could not be read: ",ws]}),t.jsx(B,{size:"sm",className:"mt-3",type:"button",onClick:()=>ht(xe=>xe+1),children:"Try again"})]}),Le&&t.jsx(BU,{agents:Le.filter(xe=>!xe.archived_at),revisions:Ft,efforts:_e,origin:location.origin,agentId:Rt??void 0,onAgent:Un,onSend:ie,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:xe=>Pe(`#/runs/${encodeURIComponent(xe)}`),live:xe=>t.jsx(WN,{v2:e,runId:xe,caps:u,agentName:st},xe)})]})]}):c.section==="agents"?c.observation?t.jsx(AL,{v2:e,sessionId:c.observation,go:Pe}):c.nativeConnect?t.jsx(hF,{v2:e,go:Pe,initialSource:c.connectionSource}):c.agent===void 0?t.jsx(pF,{v2:e,archived:!!c.archived,go:Pe},mt):c.agent===null?t.jsx(MU,{origin:location.origin,v2:e}):c.agent!==null&&!c.edit?t.jsx(m6,{v2:e,agentId:c.agent,tab:c.tab,learning:qe,routePrefix:(ba=Qe==null?void 0:Qe.models)==null?void 0:ba.route_prefix,harnesses:ct.harnesses,efforts:_e,limits:u==null?void 0:u.limits,places:n0(u),go:Pe},c.agent):t.jsx(gF,{v2:e,choices:gt,gates:Et,focusTool:c.tool,caps:{...ct,routePrefix:(Zs=Qe==null?void 0:Qe.models)==null?void 0:Zs.route_prefix,decisionProvider:BP(u==null?void 0:u.workflows),places:n0(u),mcp:!!((er=u==null?void 0:u.features)!=null&&er.mcp_client),mcpHarnesses:(go=(tr=u==null?void 0:u.features)==null?void 0:tr.mcp_client)==null?void 0:go.harnesses},agentId:c.agent,go:Pe},`${c.agent??"new"}:${c.tool??""}`):c.run?t.jsx(WN,{v2:e,runId:c.run,caps:u,agentName:st},c.run):t.jsx(IU,{observations:!c.runsOf&&!c.archived&&!c.status?_:void 0,runs:ye,agentName:st,agentId:c.runsOf,error:Q,onRetry:()=>ne(xe=>xe+1),onOpen:xe=>Pe(`#/runs/${encodeURIComponent(xe)}`),loadingMore:le,filter:fe,onFilter:xe=>Pe(yq({runsOf:c.runsOf,...xe})),onMore:we?()=>{const xe=Ae.current;me(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,we,fe):e.listRuns(50,we,fe)).then(Ce=>{xe===Ae.current&&(he(He=>Sx(He??[],Ce.runs)),ze(Ce.next_cursor),Me(null))}).catch(Ce=>Me(Jt(Ce,"more runs"))).finally(()=>me(!1))}:void 0})})})}nq();MT.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(VM,{children:t.jsx(Sq,{})})}));