@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.38

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 (399) hide show
  1. package/CHANGELOG.md +282 -0
  2. package/README.md +155 -92
  3. package/dist/agent-rows.d.ts +1 -1
  4. package/dist/agents-store.d.ts +35 -3
  5. package/dist/agents-store.js +39 -14
  6. package/dist/answer-json.d.ts +34 -1
  7. package/dist/answer-json.js +91 -9
  8. package/dist/api-only.d.ts +1 -1
  9. package/dist/api-only.js +2 -2
  10. package/dist/browser-cost.js +52 -93
  11. package/dist/cap.d.ts +0 -390
  12. package/dist/cap.js +4 -937
  13. package/dist/catalog.js +1 -1
  14. package/dist/composio-preset.d.ts +17 -0
  15. package/dist/composio-preset.js +43 -1
  16. package/dist/computer-calls.d.ts +36 -24
  17. package/dist/computer-calls.js +110 -27
  18. package/dist/computer-live.d.ts +5 -0
  19. package/dist/computer-live.js +12 -0
  20. package/dist/computer-setting.d.ts +15 -2
  21. package/dist/computer-setting.js +20 -4
  22. package/dist/computer-view.d.ts +3 -2
  23. package/dist/computer-view.js +5 -4
  24. package/dist/computer-viewer.js +26 -12
  25. package/dist/computers.d.ts +4 -1
  26. package/dist/computers.js +12 -6
  27. package/dist/console/assets/index-CjqQirbo.css +1 -0
  28. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  29. package/dist/console/index.html +2 -2
  30. package/dist/console-links.d.ts +2 -0
  31. package/dist/console-links.js +3 -0
  32. package/dist/decisions.js +4 -0
  33. package/dist/faux-computers.js +4 -2
  34. package/dist/harness-opencode/adapter.js +7 -3
  35. package/dist/harness-opencode/facts.js +0 -2
  36. package/dist/harness-opencode/host/policy.d.ts +2 -5
  37. package/dist/harness-opencode/host/policy.js +8 -32
  38. package/dist/harness-table.d.ts +0 -2
  39. package/dist/harness-table.js +0 -2
  40. package/dist/host-tools.d.ts +1 -5
  41. package/dist/host-tools.js +7 -10
  42. package/dist/hosted-search.d.ts +0 -2
  43. package/dist/hosted-search.js +0 -21
  44. package/dist/key-words.d.ts +3 -2
  45. package/dist/key-words.js +4 -2
  46. package/dist/learn/check.d.ts +6 -1
  47. package/dist/learn/check.js +12 -4
  48. package/dist/learn/commit.d.ts +10 -0
  49. package/dist/learn/commit.js +18 -4
  50. package/dist/learn/compile.d.ts +243 -0
  51. package/dist/learn/compile.js +471 -0
  52. package/dist/learn/general.d.ts +3 -0
  53. package/dist/learn/general.js +4 -2
  54. package/dist/learn/grade.d.ts +1 -1
  55. package/dist/learn/grade.js +7 -6
  56. package/dist/learn/notes.d.ts +8 -0
  57. package/dist/learn/notes.js +18 -0
  58. package/dist/learn/promote.d.ts +253 -0
  59. package/dist/learn/promote.js +428 -0
  60. package/dist/learn/refit.d.ts +39 -0
  61. package/dist/learn/refit.js +236 -0
  62. package/dist/learn/reflect.d.ts +5 -25
  63. package/dist/learn/reflect.js +14 -131
  64. package/dist/learn/replay-calls.d.ts +63 -0
  65. package/dist/learn/replay-calls.js +158 -0
  66. package/dist/learn/skills.d.ts +17 -9
  67. package/dist/learn/skills.js +132 -42
  68. package/dist/learn/workflow-nodes.d.ts +15 -0
  69. package/dist/learn/workflow-nodes.js +44 -0
  70. package/dist/learned-nodes.d.ts +50 -2
  71. package/dist/learned-nodes.js +41 -2
  72. package/dist/learned-workflow.d.ts +19 -3
  73. package/dist/learned-workflow.js +105 -26
  74. package/dist/learning-batch.d.ts +2 -2
  75. package/dist/learning-batch.js +1 -1
  76. package/dist/learning-cost.d.ts +18 -6
  77. package/dist/learning-cost.js +15 -7
  78. package/dist/learning-routes.d.ts +14 -2
  79. package/dist/learning-routes.js +14 -3
  80. package/dist/learning-words.d.ts +7 -0
  81. package/dist/learning-words.js +7 -0
  82. package/dist/learning.d.ts +31 -6
  83. package/dist/learning.js +7 -4
  84. package/dist/llm.js +0 -3
  85. package/dist/mcp-gateway.d.ts +12 -20
  86. package/dist/mcp-gateway.js +16 -44
  87. package/dist/mcp-oauth.d.ts +5 -0
  88. package/dist/mcp-oauth.js +1 -1
  89. package/dist/mcp-pin-first.d.ts +37 -0
  90. package/dist/mcp-pin-first.js +107 -0
  91. package/dist/mcp-probe.d.ts +8 -9
  92. package/dist/mcp-probe.js +16 -33
  93. package/dist/mcp-servers-store.d.ts +89 -22
  94. package/dist/mcp-servers-store.js +131 -25
  95. package/dist/mcp-sources.d.ts +39 -0
  96. package/dist/mcp-sources.js +74 -0
  97. package/dist/mcp-store.d.ts +11 -0
  98. package/dist/mcp-store.js +16 -2
  99. package/dist/mcp-wire.d.ts +22 -0
  100. package/dist/mcp-wire.js +36 -0
  101. package/dist/mcp.js +3 -3
  102. package/dist/meta-tool-names.d.ts +1 -0
  103. package/dist/meta-tool-names.js +3 -0
  104. package/dist/model.d.ts +13 -0
  105. package/dist/model.js +46 -15
  106. package/dist/monid.d.ts +51 -25
  107. package/dist/monid.js +226 -140
  108. package/dist/openapi.js +336 -66
  109. package/dist/paid-calls.d.ts +26 -29
  110. package/dist/paid-calls.js +46 -102
  111. package/dist/propose.d.ts +7 -1
  112. package/dist/propose.js +18 -6
  113. package/dist/provider.js +9 -2
  114. package/dist/reflect-range.js +2 -1
  115. package/dist/rows.d.ts +5 -3
  116. package/dist/rows.js +15 -4
  117. package/dist/run-launch.d.ts +13 -0
  118. package/dist/run-launch.js +6 -0
  119. package/dist/run-learning-served.d.ts +13 -2
  120. package/dist/run-manifest.d.ts +5 -0
  121. package/dist/run-manifest.js +20 -0
  122. package/dist/run-secrets.js +2 -3
  123. package/dist/run-timeline-served.js +5 -2
  124. package/dist/run-view.d.ts +17 -6
  125. package/dist/run-view.js +51 -22
  126. package/dist/runnable.d.ts +0 -3
  127. package/dist/runnable.js +37 -29
  128. package/dist/runner/adapter-loop.d.ts +24 -10
  129. package/dist/runner/adapter-loop.js +852 -314
  130. package/dist/runner/adapter-run-spec.d.ts +12 -6
  131. package/dist/runner/adapter-run-spec.js +97 -46
  132. package/dist/runner/adapters/pi-computer.d.ts +3 -1
  133. package/dist/runner/adapters/pi-computer.js +13 -5
  134. package/dist/runner/adapters/pi.d.ts +16 -7
  135. package/dist/runner/adapters/pi.js +94 -33
  136. package/dist/runner/cli-run-spec.js +67 -27
  137. package/dist/runner/computer-channel.js +2 -1
  138. package/dist/runner/conformance/harness.d.ts +3 -0
  139. package/dist/runner/conformance/harness.js +145 -4
  140. package/dist/runner/conformance/subject.d.ts +11 -4
  141. package/dist/runner/end-of-run.d.ts +6 -5
  142. package/dist/runner/end-of-run.js +9 -6
  143. package/dist/runner/feedback-round.d.ts +52 -0
  144. package/dist/runner/feedback-round.js +79 -0
  145. package/dist/runner/journal-kinds.d.ts +24 -6
  146. package/dist/runner/journal-kinds.js +15 -0
  147. package/dist/runner/learning-end.d.ts +54 -19
  148. package/dist/runner/learning-end.js +272 -99
  149. package/dist/runner/learning-loop.d.ts +19 -1
  150. package/dist/runner/learning-loop.js +5 -2
  151. package/dist/runner/learning-seed.d.ts +4 -0
  152. package/dist/runner/learning-seed.js +14 -0
  153. package/dist/runner/loop-contract.d.ts +19 -3
  154. package/dist/runner/loop.d.ts +16 -1
  155. package/dist/runner/loop.js +21 -1
  156. package/dist/runner/mcp-claim.d.ts +5 -1
  157. package/dist/runner/mcp-claim.js +66 -50
  158. package/dist/runner/mcp-run.d.ts +16 -52
  159. package/dist/runner/mcp-run.js +12 -84
  160. package/dist/runner/meta-tools.d.ts +37 -0
  161. package/dist/runner/meta-tools.js +268 -0
  162. package/dist/runner/metrics.js +14 -3
  163. package/dist/runner/model-route.js +12 -3
  164. package/dist/runner/monid-run.d.ts +16 -0
  165. package/dist/runner/monid-run.js +96 -0
  166. package/dist/runner/promotion.d.ts +80 -0
  167. package/dist/runner/promotion.js +562 -0
  168. package/dist/runner/reflect-hook.d.ts +36 -21
  169. package/dist/runner/reflect-hook.js +138 -49
  170. package/dist/runner/runner.js +26 -4
  171. package/dist/runner/sessions.d.ts +8 -3
  172. package/dist/runner/sessions.js +5 -1
  173. package/dist/runner/step-guard.d.ts +62 -0
  174. package/dist/runner/step-guard.js +93 -0
  175. package/dist/runner/subagent.d.ts +0 -3
  176. package/dist/runner/subagent.js +7 -12
  177. package/dist/runner/workflow-first.d.ts +216 -0
  178. package/dist/runner/workflow-first.js +303 -0
  179. package/dist/runner/workflow-loop.js +17 -10
  180. package/dist/runner/workflow-spec.d.ts +1 -0
  181. package/dist/runner/workflow-spec.js +7 -3
  182. package/dist/runs-over-store.d.ts +11 -2
  183. package/dist/runs-over-store.js +21 -11
  184. package/dist/server.d.ts +88 -16
  185. package/dist/server.js +380 -87
  186. package/dist/settings-wake.d.ts +8 -6
  187. package/dist/settings-wake.js +13 -7
  188. package/dist/store/agent-body.d.ts +14 -3
  189. package/dist/store/agent-body.js +14 -10
  190. package/dist/store/command-wake.d.ts +3 -2
  191. package/dist/store/command-wake.js +4 -4
  192. package/dist/store/postgres/connection.js +3 -1
  193. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  194. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  195. package/dist/store/schema.d.ts +9 -0
  196. package/dist/store/schema.js +28 -8
  197. package/dist/store/sqlite/connection.d.ts +2 -2
  198. package/dist/store/sqlite/connection.js +2 -2
  199. package/dist/store/sqlite/run-patch.js +19 -7
  200. package/dist/store/sqlite/store.js +59 -18
  201. package/dist/store/store.d.ts +46 -14
  202. package/dist/store-reads/journal.d.ts +25 -1
  203. package/dist/store-reads/journal.js +63 -49
  204. package/dist/store-reads/learning.d.ts +101 -15
  205. package/dist/store-reads/learning.js +195 -61
  206. package/dist/store-reads/loop.d.ts +61 -0
  207. package/dist/store-reads/loop.js +111 -0
  208. package/dist/store-view.d.ts +3 -2
  209. package/dist/store-view.js +35 -17
  210. package/dist/template-eval.d.ts +18 -9
  211. package/dist/template-eval.js +91 -66
  212. package/dist/template-github-permissions.d.ts +2 -2
  213. package/dist/template-github-permissions.js +2 -1
  214. package/dist/template-import.d.ts +31 -0
  215. package/dist/template-import.js +121 -0
  216. package/dist/template-source.d.ts +51 -0
  217. package/dist/template-source.js +371 -0
  218. package/dist/templates.d.ts +218 -46
  219. package/dist/templates.js +493 -181
  220. package/dist/timeline/computer.d.ts +48 -0
  221. package/dist/timeline/computer.js +169 -0
  222. package/dist/timeline/index.d.ts +4 -3
  223. package/dist/timeline/index.js +4 -3
  224. package/dist/timeline/labels.d.ts +6 -2
  225. package/dist/timeline/labels.js +93 -2
  226. package/dist/timeline/origin.d.ts +19 -5
  227. package/dist/timeline/origin.js +11 -4
  228. package/dist/timeline/timeline.d.ts +11 -17
  229. package/dist/timeline/timeline.js +24 -9
  230. package/dist/tool-gate.d.ts +73 -46
  231. package/dist/tool-gate.js +133 -66
  232. package/dist/tool-keys.d.ts +4 -1
  233. package/dist/tool-keys.js +8 -3
  234. package/dist/tool-list.d.ts +26 -0
  235. package/dist/tool-list.js +43 -0
  236. package/dist/tool-names.d.ts +71 -0
  237. package/dist/tool-names.js +99 -0
  238. package/dist/tool-plane.d.ts +29 -27
  239. package/dist/tool-plane.js +65 -37
  240. package/dist/tools.d.ts +22 -6
  241. package/dist/tools.js +24 -20
  242. package/dist/validate.d.ts +15 -7
  243. package/dist/validate.js +91 -44
  244. package/dist/web-fetch.d.ts +1 -7
  245. package/dist/web-fetch.js +2 -22
  246. package/dist/workspace/computer-deps.d.ts +3 -0
  247. package/dist/workspace/computer-deps.js +5 -2
  248. package/dist/workspace/computer-for-claim.d.ts +6 -0
  249. package/dist/workspace/computer-for-claim.js +32 -14
  250. package/dist/workspace/computer-hold.js +7 -1
  251. package/dist/workspace/computer-script.d.ts +23 -7
  252. package/dist/workspace/computer-script.js +48 -14
  253. package/dist/workspace/index.d.ts +2 -2
  254. package/dist/workspace/index.js +1 -1
  255. package/dist/workspace/kind-skills/desktop/SKILL.md +13 -0
  256. package/dist/workspace/kind-skills/phone/SKILL.md +4 -0
  257. package/dist/workspace/local.js +2 -2
  258. package/dist/workspace/resolve-computer.d.ts +21 -1
  259. package/dist/workspace/resolve-computer.js +32 -14
  260. package/dist/workspace/run-tools.d.ts +28 -10
  261. package/dist/workspace/run-tools.js +39 -11
  262. package/dist/{tool-budget.d.ts → wrap-up.d.ts} +1 -18
  263. package/dist/wrap-up.js +21 -0
  264. package/launcher/agentrun-serve +4 -2
  265. package/package.json +9 -9
  266. package/templates/README.md +111 -45
  267. package/templates/code-review/agent.md +30 -14
  268. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  269. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  270. package/templates/code-review/evals/injection/case.yaml +2 -1
  271. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  272. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  273. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  274. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  275. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  276. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  277. package/templates/code-review/evals/null-name/case.yaml +2 -1
  278. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  279. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  280. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  281. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  282. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  283. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  284. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  285. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  286. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  287. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  288. package/templates/code-review/evals/re-review/case.yaml +2 -1
  289. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  290. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  291. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  292. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  293. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  294. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  295. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  296. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  297. package/templates/code-review/skills/review/DEEP.md +3 -2
  298. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  299. package/templates/code-review/skills/review/SKILL.md +4 -3
  300. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  301. package/templates/inbound-lead/agent.md +26 -16
  302. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  303. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  304. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  305. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  306. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  307. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  308. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  309. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  310. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  311. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  312. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  313. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  314. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  315. package/templates/kyb/agent.md +15 -5
  316. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  317. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  318. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  319. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  320. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  321. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  322. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  323. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  324. package/templates/kyb/kyb.schema.json +8 -7
  325. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  326. package/templates/market-monitor/agent.md +19 -12
  327. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  328. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  329. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  330. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  331. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  332. package/templates/release-notes/agent.md +32 -10
  333. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  334. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  335. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  336. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  337. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  338. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  339. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  340. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  341. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  342. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  343. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  344. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  345. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  346. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  347. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  348. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  349. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  350. package/templates/release-notes/notes.schema.json +1 -1
  351. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  352. package/dist/console/assets/index-Cn6JX1uH.js +0 -563
  353. package/dist/console/assets/index-DRN62V5v.css +0 -1
  354. package/dist/tool-blurbs.d.ts +0 -4
  355. package/dist/tool-blurbs.js +0 -28
  356. package/dist/tool-budget.js +0 -62
  357. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  358. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  359. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  360. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  361. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  362. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  363. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  364. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  365. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  366. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  367. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  368. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  369. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  370. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  371. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  372. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  373. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  374. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  375. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  376. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  377. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  378. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  379. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  380. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  381. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  382. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  383. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  384. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  385. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  386. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  387. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  388. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  389. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  390. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  391. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  392. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  393. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  394. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  395. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  396. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  397. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  398. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  399. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
@@ -0,0 +1,576 @@
1
+ var C$=Object.defineProperty;var T$=(e,t,s)=>t in e?C$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var gt=(e,t,s)=>T$(e,typeof t!="symbol"?t+"":t,s);function R$(e,t){for(var s=0;s<t.length;s++){const r=t[s];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function s(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=s(a);fetch(a.href,l)}})();function $k(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vp={exports:{}},yl={},wp={exports:{}},it={};/**
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 pv;function A$(){if(pv)return it;pv=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.iterator;function h(P){return P===null||typeof P!="object"?null:(P=y&&P[y]||P["@@iterator"],typeof P=="function"?P:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,w={};function k(P,B,q){this.props=P,this.context=B,this.refs=w,this.updater=q||m}k.prototype.isReactComponent={},k.prototype.setState=function(P,B){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,B,"setState")},k.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function N(){}N.prototype=k.prototype;function A(P,B,q){this.props=P,this.context=B,this.refs=w,this.updater=q||m}var _=A.prototype=new N;_.constructor=A,v(_,k.prototype),_.isPureReactComponent=!0;var S=Array.isArray,E=Object.prototype.hasOwnProperty,T={current:null},C={key:!0,ref:!0,__self:!0,__source:!0};function R(P,B,q){var ce,de={},ue=null,Q=null;if(B!=null)for(ce in B.ref!==void 0&&(Q=B.ref),B.key!==void 0&&(ue=""+B.key),B)E.call(B,ce)&&!C.hasOwnProperty(ce)&&(de[ce]=B[ce]);var fe=arguments.length-2;if(fe===1)de.children=q;else if(1<fe){for(var ye=Array(fe),Ee=0;Ee<fe;Ee++)ye[Ee]=arguments[Ee+2];de.children=ye}if(P&&P.defaultProps)for(ce in fe=P.defaultProps,fe)de[ce]===void 0&&(de[ce]=fe[ce]);return{$$typeof:e,type:P,key:ue,ref:Q,props:de,_owner:T.current}}function D(P,B){return{$$typeof:e,type:P.type,key:B,ref:P.ref,props:P.props,_owner:P._owner}}function L(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function O(P){var B={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(q){return B[q]})}var I=/\/+/g;function W(P,B){return typeof P=="object"&&P!==null&&P.key!=null?O(""+P.key):B.toString(36)}function U(P,B,q,ce,de){var ue=typeof P;(ue==="undefined"||ue==="boolean")&&(P=null);var Q=!1;if(P===null)Q=!0;else switch(ue){case"string":case"number":Q=!0;break;case"object":switch(P.$$typeof){case e:case t:Q=!0}}if(Q)return Q=P,de=de(Q),P=ce===""?"."+W(Q,0):ce,S(de)?(q="",P!=null&&(q=P.replace(I,"$&/")+"/"),U(de,B,q,"",function(Ee){return Ee})):de!=null&&(L(de)&&(de=D(de,q+(!de.key||Q&&Q.key===de.key?"":(""+de.key).replace(I,"$&/")+"/")+P)),B.push(de)),1;if(Q=0,ce=ce===""?".":ce+":",S(P))for(var fe=0;fe<P.length;fe++){ue=P[fe];var ye=ce+W(ue,fe);Q+=U(ue,B,q,ye,de)}else if(ye=h(P),typeof ye=="function")for(P=ye.call(P),fe=0;!(ue=P.next()).done;)ue=ue.value,ye=ce+W(ue,fe++),Q+=U(ue,B,q,ye,de);else if(ue==="object")throw B=String(P),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return Q}function J(P,B,q){if(P==null)return P;var ce=[],de=0;return U(P,ce,"","",function(ue){return B.call(q,ue,de++)}),ce}function F(P){if(P._status===-1){var B=P._result;B=B(),B.then(function(q){(P._status===0||P._status===-1)&&(P._status=1,P._result=q)},function(q){(P._status===0||P._status===-1)&&(P._status=2,P._result=q)}),P._status===-1&&(P._status=0,P._result=B)}if(P._status===1)return P._result.default;throw P._result}var Z={current:null},z={transition:null},H={ReactCurrentDispatcher:Z,ReactCurrentBatchConfig:z,ReactCurrentOwner:T};function V(){throw Error("act(...) is not supported in production builds of React.")}return it.Children={map:J,forEach:function(P,B,q){J(P,function(){B.apply(this,arguments)},q)},count:function(P){var B=0;return J(P,function(){B++}),B},toArray:function(P){return J(P,function(B){return B})||[]},only:function(P){if(!L(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},it.Component=k,it.Fragment=s,it.Profiler=a,it.PureComponent=A,it.StrictMode=r,it.Suspense=d,it.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H,it.act=V,it.cloneElement=function(P,B,q){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var ce=v({},P.props),de=P.key,ue=P.ref,Q=P._owner;if(B!=null){if(B.ref!==void 0&&(ue=B.ref,Q=T.current),B.key!==void 0&&(de=""+B.key),P.type&&P.type.defaultProps)var fe=P.type.defaultProps;for(ye in B)E.call(B,ye)&&!C.hasOwnProperty(ye)&&(ce[ye]=B[ye]===void 0&&fe!==void 0?fe[ye]:B[ye])}var ye=arguments.length-2;if(ye===1)ce.children=q;else if(1<ye){fe=Array(ye);for(var Ee=0;Ee<ye;Ee++)fe[Ee]=arguments[Ee+2];ce.children=fe}return{$$typeof:e,type:P.type,key:de,ref:ue,props:ce,_owner:Q}},it.createContext=function(P){return P={$$typeof:c,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:l,_context:P},P.Consumer=P},it.createElement=R,it.createFactory=function(P){var B=R.bind(null,P);return B.type=P,B},it.createRef=function(){return{current:null}},it.forwardRef=function(P){return{$$typeof:u,render:P}},it.isValidElement=L,it.lazy=function(P){return{$$typeof:g,_payload:{_status:-1,_result:P},_init:F}},it.memo=function(P,B){return{$$typeof:p,type:P,compare:B===void 0?null:B}},it.startTransition=function(P){var B=z.transition;z.transition={};try{P()}finally{z.transition=B}},it.unstable_act=V,it.useCallback=function(P,B){return Z.current.useCallback(P,B)},it.useContext=function(P){return Z.current.useContext(P)},it.useDebugValue=function(){},it.useDeferredValue=function(P){return Z.current.useDeferredValue(P)},it.useEffect=function(P,B){return Z.current.useEffect(P,B)},it.useId=function(){return Z.current.useId()},it.useImperativeHandle=function(P,B,q){return Z.current.useImperativeHandle(P,B,q)},it.useInsertionEffect=function(P,B){return Z.current.useInsertionEffect(P,B)},it.useLayoutEffect=function(P,B){return Z.current.useLayoutEffect(P,B)},it.useMemo=function(P,B){return Z.current.useMemo(P,B)},it.useReducer=function(P,B,q){return Z.current.useReducer(P,B,q)},it.useRef=function(P){return Z.current.useRef(P)},it.useState=function(P){return Z.current.useState(P)},it.useSyncExternalStore=function(P,B,q){return Z.current.useSyncExternalStore(P,B,q)},it.useTransition=function(){return Z.current.useTransition()},it.version="18.3.1",it}var hv;function of(){return hv||(hv=1,wp.exports=A$()),wp.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 gv;function O$(){if(gv)return yl;gv=1;var e=of(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(u,d,p){var g,y={},h=null,m=null;p!==void 0&&(h=""+p),d.key!==void 0&&(h=""+d.key),d.ref!==void 0&&(m=d.ref);for(g in d)r.call(d,g)&&!l.hasOwnProperty(g)&&(y[g]=d[g]);if(u&&u.defaultProps)for(g in d=u.defaultProps,d)y[g]===void 0&&(y[g]=d[g]);return{$$typeof:t,type:u,key:h,ref:m,props:y,_owner:a.current}}return yl.Fragment=s,yl.jsx=c,yl.jsxs=c,yl}var xv;function M$(){return xv||(xv=1,vp.exports=O$()),vp.exports}var n=M$(),x=of();const Oe=$k(x),fh=R$({__proto__:null,default:Oe},[x]);var Fu={},kp={exports:{}},Kn={},jp={exports:{}},Np={};/**
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 yv;function L$(){return yv||(yv=1,(function(e){function t(z,H){var V=z.length;z.push(H);e:for(;0<V;){var P=V-1>>>1,B=z[P];if(0<a(B,H))z[P]=H,z[V]=B,V=P;else break e}}function s(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var H=z[0],V=z.pop();if(V!==H){z[0]=V;e:for(var P=0,B=z.length,q=B>>>1;P<q;){var ce=2*(P+1)-1,de=z[ce],ue=ce+1,Q=z[ue];if(0>a(de,V))ue<B&&0>a(Q,de)?(z[P]=Q,z[ue]=V,P=ue):(z[P]=de,z[ce]=V,P=ce);else if(ue<B&&0>a(Q,V))z[P]=Q,z[ue]=V,P=ue;else break e}}return H}function a(z,H){var V=z.sortIndex-H.sortIndex;return V!==0?V:z.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var d=[],p=[],g=1,y=null,h=3,m=!1,v=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(z){for(var H=s(p);H!==null;){if(H.callback===null)r(p);else if(H.startTime<=z)r(p),H.sortIndex=H.expirationTime,t(d,H);else break;H=s(p)}}function S(z){if(w=!1,_(z),!v)if(s(d)!==null)v=!0,F(E);else{var H=s(p);H!==null&&Z(S,H.startTime-z)}}function E(z,H){v=!1,w&&(w=!1,N(R),R=-1),m=!0;var V=h;try{for(_(H),y=s(d);y!==null&&(!(y.expirationTime>H)||z&&!O());){var P=y.callback;if(typeof P=="function"){y.callback=null,h=y.priorityLevel;var B=P(y.expirationTime<=H);H=e.unstable_now(),typeof B=="function"?y.callback=B:y===s(d)&&r(d),_(H)}else r(d);y=s(d)}if(y!==null)var q=!0;else{var ce=s(p);ce!==null&&Z(S,ce.startTime-H),q=!1}return q}finally{y=null,h=V,m=!1}}var T=!1,C=null,R=-1,D=5,L=-1;function O(){return!(e.unstable_now()-L<D)}function I(){if(C!==null){var z=e.unstable_now();L=z;var H=!0;try{H=C(!0,z)}finally{H?W():(T=!1,C=null)}}else T=!1}var W;if(typeof A=="function")W=function(){A(I)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,J=U.port2;U.port1.onmessage=I,W=function(){J.postMessage(null)}}else W=function(){k(I,0)};function F(z){C=z,T||(T=!0,W())}function Z(z,H){R=k(function(){z(e.unstable_now())},H)}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(z){z.callback=null},e.unstable_continueExecution=function(){v||m||(v=!0,F(E))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return s(d)},e.unstable_next=function(z){switch(h){case 1:case 2:case 3:var H=3;break;default:H=h}var V=h;h=H;try{return z()}finally{h=V}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,H){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var V=h;h=z;try{return H()}finally{h=V}},e.unstable_scheduleCallback=function(z,H,V){var P=e.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?P+V:P):V=P,z){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=V+B,z={id:g++,callback:H,priorityLevel:z,startTime:V,expirationTime:B,sortIndex:-1},V>P?(z.sortIndex=V,t(p,z),s(d)===null&&z===s(p)&&(w?(N(R),R=-1):w=!0,Z(S,V-P))):(z.sortIndex=B,t(d,z),v||m||(v=!0,F(E))),z},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(z){var H=h;return function(){var V=h;h=H;try{return z.apply(this,arguments)}finally{h=V}}}})(Np)),Np}var bv;function P$(){return bv||(bv=1,jp.exports=L$()),jp.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 vv;function I$(){if(vv)return Kn;vv=1;var e=of(),t=P$();function s(o){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+o,f=1;f<arguments.length;f++)i+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+o+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function l(o,i){c(o,i),c(o+"Capture",i)}function c(o,i){for(a[o]=i,o=0;o<i.length;o++)r.add(i[o])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,p=/^[: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 h(o){return d.call(y,o)?!0:d.call(g,o)?!1:p.test(o)?y[o]=!0:(g[o]=!0,!1)}function m(o,i,f,b){if(f!==null&&f.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return b?!1:f!==null?!f.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function v(o,i,f,b){if(i===null||typeof i>"u"||m(o,i,f,b))return!0;if(b)return!1;if(f!==null)switch(f.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function w(o,i,f,b,j,$,M){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=b,this.attributeNamespace=j,this.mustUseProperty=f,this.propertyName=o,this.type=i,this.sanitizeURL=$,this.removeEmptyString=M}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){k[o]=new w(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var i=o[0];k[i]=new w(i,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){k[o]=new w(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){k[o]=new w(o,2,!1,o,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(o){k[o]=new w(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){k[o]=new w(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){k[o]=new w(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){k[o]=new w(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){k[o]=new w(o,5,!1,o.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function A(o){return o[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(o){var i=o.replace(N,A);k[i]=new w(i,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var i=o.replace(N,A);k[i]=new w(i,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var i=o.replace(N,A);k[i]=new w(i,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!1,!1)}),k.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!0,!0)});function _(o,i,f,b){var j=k.hasOwnProperty(i)?k[i]:null;(j!==null?j.type!==0:b||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(v(i,f,j,b)&&(f=null),b||j===null?h(i)&&(f===null?o.removeAttribute(i):o.setAttribute(i,""+f)):j.mustUseProperty?o[j.propertyName]=f===null?j.type===3?!1:"":f:(i=j.attributeName,b=j.attributeNamespace,f===null?o.removeAttribute(i):(j=j.type,f=j===3||j===4&&f===!0?"":""+f,b?o.setAttributeNS(b,i,f):o.setAttribute(i,f))))}var S=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),T=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),O=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),Z=Symbol.for("react.offscreen"),z=Symbol.iterator;function H(o){return o===null||typeof o!="object"?null:(o=z&&o[z]||o["@@iterator"],typeof o=="function"?o:null)}var V=Object.assign,P;function B(o){if(P===void 0)try{throw Error()}catch(f){var i=f.stack.trim().match(/\n( *(at )?)/);P=i&&i[1]||""}return`
34
+ `+P+o}var q=!1;function ce(o,i){if(!o||q)return"";q=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(le){var b=le}Reflect.construct(o,[],i)}else{try{i.call()}catch(le){b=le}o.call(i.prototype)}else{try{throw Error()}catch(le){b=le}o()}}catch(le){if(le&&b&&typeof le.stack=="string"){for(var j=le.stack.split(`
35
+ `),$=b.stack.split(`
36
+ `),M=j.length-1,G=$.length-1;1<=M&&0<=G&&j[M]!==$[G];)G--;for(;1<=M&&0<=G;M--,G--)if(j[M]!==$[G]){if(M!==1||G!==1)do if(M--,G--,0>G||j[M]!==$[G]){var X=`
37
+ `+j[M].replace(" at new "," at ");return o.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",o.displayName)),X}while(1<=M&&0<=G);break}}}finally{q=!1,Error.prepareStackTrace=f}return(o=o?o.displayName||o.name:"")?B(o):""}function de(o){switch(o.tag){case 5:return B(o.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return o=ce(o.type,!1),o;case 11:return o=ce(o.type.render,!1),o;case 1:return o=ce(o.type,!0),o;default:return""}}function ue(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case C:return"Fragment";case T:return"Portal";case D:return"Profiler";case R:return"StrictMode";case W:return"Suspense";case U:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case O:return(o.displayName||"Context")+".Consumer";case L:return(o._context.displayName||"Context")+".Provider";case I:var i=o.render;return o=o.displayName,o||(o=i.displayName||i.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case J:return i=o.displayName||null,i!==null?i:ue(o.type)||"Memo";case F:i=o._payload,o=o._init;try{return ue(o(i))}catch{}}return null}function Q(o){var i=o.type;switch(o.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=i.render,o=o.displayName||o.name||"",i.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ue(i);case 8:return i===R?"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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function fe(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function ye(o){var i=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Ee(o){var i=ye(o)?"checked":"value",f=Object.getOwnPropertyDescriptor(o.constructor.prototype,i),b=""+o[i];if(!o.hasOwnProperty(i)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var j=f.get,$=f.set;return Object.defineProperty(o,i,{configurable:!0,get:function(){return j.call(this)},set:function(M){b=""+M,$.call(this,M)}}),Object.defineProperty(o,i,{enumerable:f.enumerable}),{getValue:function(){return b},setValue:function(M){b=""+M},stopTracking:function(){o._valueTracker=null,delete o[i]}}}}function ge(o){o._valueTracker||(o._valueTracker=Ee(o))}function se(o){if(!o)return!1;var i=o._valueTracker;if(!i)return!0;var f=i.getValue(),b="";return o&&(b=ye(o)?o.checked?"true":"false":o.value),o=b,o!==f?(i.setValue(o),!0):!1}function pe(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function Y(o,i){var f=i.checked;return V({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??o._wrapperState.initialChecked})}function _e(o,i){var f=i.defaultValue==null?"":i.defaultValue,b=i.checked!=null?i.checked:i.defaultChecked;f=fe(i.value!=null?i.value:f),o._wrapperState={initialChecked:b,initialValue:f,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Ze(o,i){i=i.checked,i!=null&&_(o,"checked",i,!1)}function Je(o,i){Ze(o,i);var f=fe(i.value),b=i.type;if(f!=null)b==="number"?(f===0&&o.value===""||o.value!=f)&&(o.value=""+f):o.value!==""+f&&(o.value=""+f);else if(b==="submit"||b==="reset"){o.removeAttribute("value");return}i.hasOwnProperty("value")?et(o,i.type,f):i.hasOwnProperty("defaultValue")&&et(o,i.type,fe(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(o.defaultChecked=!!i.defaultChecked)}function xt(o,i,f){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var b=i.type;if(!(b!=="submit"&&b!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+o._wrapperState.initialValue,f||i===o.value||(o.value=i),o.defaultValue=i}f=o.name,f!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,f!==""&&(o.name=f)}function et(o,i,f){(i!=="number"||pe(o.ownerDocument)!==o)&&(f==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+f&&(o.defaultValue=""+f))}var ae=Array.isArray;function Ae(o,i,f,b){if(o=o.options,i){i={};for(var j=0;j<f.length;j++)i["$"+f[j]]=!0;for(f=0;f<o.length;f++)j=i.hasOwnProperty("$"+o[f].value),o[f].selected!==j&&(o[f].selected=j),j&&b&&(o[f].defaultSelected=!0)}else{for(f=""+fe(f),i=null,j=0;j<o.length;j++){if(o[j].value===f){o[j].selected=!0,b&&(o[j].defaultSelected=!0);return}i!==null||o[j].disabled||(i=o[j])}i!==null&&(i.selected=!0)}}function Ce(o,i){if(i.dangerouslySetInnerHTML!=null)throw Error(s(91));return V({},i,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function Ge(o,i){var f=i.value;if(f==null){if(f=i.children,i=i.defaultValue,f!=null){if(i!=null)throw Error(s(92));if(ae(f)){if(1<f.length)throw Error(s(93));f=f[0]}i=f}i==null&&(i=""),f=i}o._wrapperState={initialValue:fe(f)}}function kt(o,i){var f=fe(i.value),b=fe(i.defaultValue);f!=null&&(f=""+f,f!==o.value&&(o.value=f),i.defaultValue==null&&o.defaultValue!==f&&(o.defaultValue=f)),b!=null&&(o.defaultValue=""+b)}function We(o){var i=o.textContent;i===o._wrapperState.initialValue&&i!==""&&i!==null&&(o.value=i)}function rt(o){switch(o){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 yn(o,i){return o==null||o==="http://www.w3.org/1999/xhtml"?rt(i):o==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Dt,sn=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,f,b,j){MSApp.execUnsafeLocalFunction(function(){return o(i,f,b,j)})}:o})(function(o,i){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=i;else{for(Dt=Dt||document.createElement("div"),Dt.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=Dt.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;i.firstChild;)o.appendChild(i.firstChild)}});function me(o,i){if(i){var f=o.firstChild;if(f&&f===o.lastChild&&f.nodeType===3){f.nodeValue=i;return}}o.textContent=i}var Te={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},tt=["Webkit","ms","Moz","O"];Object.keys(Te).forEach(function(o){tt.forEach(function(i){i=i+o.charAt(0).toUpperCase()+o.substring(1),Te[i]=Te[o]})});function Fe(o,i,f){return i==null||typeof i=="boolean"||i===""?"":f||typeof i!="number"||i===0||Te.hasOwnProperty(o)&&Te[o]?(""+i).trim():i+"px"}function lt(o,i){o=o.style;for(var f in i)if(i.hasOwnProperty(f)){var b=f.indexOf("--")===0,j=Fe(f,i[f],b);f==="float"&&(f="cssFloat"),b?o.setProperty(f,j):o[f]=j}}var Ke=V({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 Ft(o,i){if(i){if(Ke[o]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(s(137,o));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(s(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(s(61))}if(i.style!=null&&typeof i.style!="object")throw Error(s(62))}}function Qn(o,i){if(o.indexOf("-")===-1)return typeof i.is=="string";switch(o){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 Jn=null;function Zn(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var bn=null,es=null,un=null;function ms(o){if(o=sl(o)){if(typeof bn!="function")throw Error(s(280));var i=o.stateNode;i&&(i=tu(i),bn(o.stateNode,o.type,i))}}function gr(o){es?un?un.push(o):un=[o]:es=o}function Nt(){if(es){var o=es,i=un;if(un=es=null,ms(o),i)for(o=0;o<i.length;o++)ms(i[o])}}function Cn(o,i){return o(i)}function ps(){}var hs=!1;function gs(o,i,f){if(hs)return o(i,f);hs=!0;try{return Cn(o,i,f)}finally{hs=!1,(es!==null||un!==null)&&(ps(),Nt())}}function Un(o,i){var f=o.stateNode;if(f===null)return null;var b=tu(f);if(b===null)return null;f=b[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(b=!b.disabled)||(o=o.type,b=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!b;break e;default:o=!1}if(o)return null;if(f&&typeof f!="function")throw Error(s(231,i,typeof f));return f}var Ms=!1;if(u)try{var ee={};Object.defineProperty(ee,"passive",{get:function(){Ms=!0}}),window.addEventListener("test",ee,ee),window.removeEventListener("test",ee,ee)}catch{Ms=!1}function Se(o,i,f,b,j,$,M,G,X){var le=Array.prototype.slice.call(arguments,3);try{i.apply(f,le)}catch(xe){this.onError(xe)}}var Ye=!1,ft=null,jt=!1,Ut=null,vn={onError:function(o){Ye=!0,ft=o}};function St(o,i,f,b,j,$,M,G,X){Ye=!1,ft=null,Se.apply(vn,arguments)}function zr(o,i,f,b,j,$,M,G,X){if(St.apply(this,arguments),Ye){if(Ye){var le=ft;Ye=!1,ft=null}else throw Error(s(198));jt||(jt=!0,Ut=le)}}function Tn(o){var i=o,f=o;if(o.alternate)for(;i.return;)i=i.return;else{o=i;do i=o,(i.flags&4098)!==0&&(f=i.return),o=i.return;while(o)}return i.tag===3?f:null}function Ls(o){if(o.tag===13){var i=o.memoizedState;if(i===null&&(o=o.alternate,o!==null&&(i=o.memoizedState)),i!==null)return i.dehydrated}return null}function Ps(o){if(Tn(o)!==o)throw Error(s(188))}function $a(o){var i=o.alternate;if(!i){if(i=Tn(o),i===null)throw Error(s(188));return i!==o?null:o}for(var f=o,b=i;;){var j=f.return;if(j===null)break;var $=j.alternate;if($===null){if(b=j.return,b!==null){f=b;continue}break}if(j.child===$.child){for($=j.child;$;){if($===f)return Ps(j),o;if($===b)return Ps(j),i;$=$.sibling}throw Error(s(188))}if(f.return!==b.return)f=j,b=$;else{for(var M=!1,G=j.child;G;){if(G===f){M=!0,f=j,b=$;break}if(G===b){M=!0,b=j,f=$;break}G=G.sibling}if(!M){for(G=$.child;G;){if(G===f){M=!0,f=$,b=j;break}if(G===b){M=!0,b=$,f=j;break}G=G.sibling}if(!M)throw Error(s(189))}}if(f.alternate!==b)throw Error(s(190))}if(f.tag!==3)throw Error(s(188));return f.stateNode.current===f?o:i}function He(o){return o=$a(o),o!==null?te(o):null}function te(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var i=te(o);if(i!==null)return i;o=o.sibling}return null}var ve=t.unstable_scheduleCallback,Me=t.unstable_cancelCallback,vt=t.unstable_shouldYield,Wt=t.unstable_requestPaint,nt=t.unstable_now,Qt=t.unstable_getCurrentPriorityLevel,dn=t.unstable_ImmediatePriority,Is=t.unstable_UserBlockingPriority,At=t.unstable_NormalPriority,To=t.unstable_LowPriority,Dr=t.unstable_IdlePriority,Ro=null,ts=null;function Lc(o){if(ts&&typeof ts.onCommitFiberRoot=="function")try{ts.onCommitFiberRoot(Ro,o,void 0,(o.current.flags&128)===128)}catch{}}var Wn=Math.clz32?Math.clz32:zc,Pc=Math.log,Ic=Math.LN2;function zc(o){return o>>>=0,o===0?32:31-(Pc(o)/Ic|0)|0}var Ao=64,Oo=4194304;function Fr(o){switch(o&-o){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 o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function Mo(o,i){var f=o.pendingLanes;if(f===0)return 0;var b=0,j=o.suspendedLanes,$=o.pingedLanes,M=f&268435455;if(M!==0){var G=M&~j;G!==0?b=Fr(G):($&=M,$!==0&&(b=Fr($)))}else M=f&~j,M!==0?b=Fr(M):$!==0&&(b=Fr($));if(b===0)return 0;if(i!==0&&i!==b&&(i&j)===0&&(j=b&-b,$=i&-i,j>=$||j===16&&($&4194240)!==0))return i;if((b&4)!==0&&(b|=f&16),i=o.entangledLanes,i!==0)for(o=o.entanglements,i&=b;0<i;)f=31-Wn(i),j=1<<f,b|=o[f],i&=~j;return b}function Dc(o,i){switch(o){case 1:case 2:case 4:return i+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 i+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 we(o,i){for(var f=o.suspendedLanes,b=o.pingedLanes,j=o.expirationTimes,$=o.pendingLanes;0<$;){var M=31-Wn($),G=1<<M,X=j[M];X===-1?((G&f)===0||(G&b)!==0)&&(j[M]=Dc(G,i)):X<=i&&(o.expiredLanes|=G),$&=~G}}function je(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function ze(){var o=Ao;return Ao<<=1,(Ao&4194240)===0&&(Ao=64),o}function dt(o){for(var i=[],f=0;31>f;f++)i.push(o);return i}function at(o,i,f){o.pendingLanes|=i,i!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,i=31-Wn(i),o[i]=f}function Ur(o,i){var f=o.pendingLanes&~i;o.pendingLanes=i,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=i,o.mutableReadLanes&=i,o.entangledLanes&=i,i=o.entanglements;var b=o.eventTimes;for(o=o.expirationTimes;0<f;){var j=31-Wn(f),$=1<<j;i[j]=0,b[j]=-1,o[j]=-1,f&=~$}}function fn(o,i){var f=o.entangledLanes|=i;for(o=o.entanglements;f;){var b=31-Wn(f),j=1<<b;j&i|o[b]&i&&(o[b]|=i),f&=~j}}var st=0;function Fc(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var xr,Ii,zi,Di,Fi,Wr=!1,zs=[],mn=null,Hr=null,Br=null,Ui=new Map,Wi=new Map,Gr=[],Q2="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 Qx(o,i){switch(o){case"focusin":case"focusout":mn=null;break;case"dragenter":case"dragleave":Hr=null;break;case"mouseover":case"mouseout":Br=null;break;case"pointerover":case"pointerout":Ui.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wi.delete(i.pointerId)}}function Hi(o,i,f,b,j,$){return o===null||o.nativeEvent!==$?(o={blockedOn:i,domEventName:f,eventSystemFlags:b,nativeEvent:$,targetContainers:[j]},i!==null&&(i=sl(i),i!==null&&Ii(i)),o):(o.eventSystemFlags|=b,i=o.targetContainers,j!==null&&i.indexOf(j)===-1&&i.push(j),o)}function J2(o,i,f,b,j){switch(i){case"focusin":return mn=Hi(mn,o,i,f,b,j),!0;case"dragenter":return Hr=Hi(Hr,o,i,f,b,j),!0;case"mouseover":return Br=Hi(Br,o,i,f,b,j),!0;case"pointerover":var $=j.pointerId;return Ui.set($,Hi(Ui.get($)||null,o,i,f,b,j)),!0;case"gotpointercapture":return $=j.pointerId,Wi.set($,Hi(Wi.get($)||null,o,i,f,b,j)),!0}return!1}function Jx(o){var i=Lo(o.target);if(i!==null){var f=Tn(i);if(f!==null){if(i=f.tag,i===13){if(i=Ls(f),i!==null){o.blockedOn=i,Fi(o.priority,function(){zi(f)});return}}else if(i===3&&f.stateNode.current.memoizedState.isDehydrated){o.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}o.blockedOn=null}function Uc(o){if(o.blockedOn!==null)return!1;for(var i=o.targetContainers;0<i.length;){var f=Vf(o.domEventName,o.eventSystemFlags,i[0],o.nativeEvent);if(f===null){f=o.nativeEvent;var b=new f.constructor(f.type,f);Jn=b,f.target.dispatchEvent(b),Jn=null}else return i=sl(f),i!==null&&Ii(i),o.blockedOn=f,!1;i.shift()}return!0}function Zx(o,i,f){Uc(o)&&f.delete(i)}function Z2(){Wr=!1,mn!==null&&Uc(mn)&&(mn=null),Hr!==null&&Uc(Hr)&&(Hr=null),Br!==null&&Uc(Br)&&(Br=null),Ui.forEach(Zx),Wi.forEach(Zx)}function Bi(o,i){o.blockedOn===i&&(o.blockedOn=null,Wr||(Wr=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Z2)))}function Gi(o){function i(j){return Bi(j,o)}if(0<zs.length){Bi(zs[0],o);for(var f=1;f<zs.length;f++){var b=zs[f];b.blockedOn===o&&(b.blockedOn=null)}}for(mn!==null&&Bi(mn,o),Hr!==null&&Bi(Hr,o),Br!==null&&Bi(Br,o),Ui.forEach(i),Wi.forEach(i),f=0;f<Gr.length;f++)b=Gr[f],b.blockedOn===o&&(b.blockedOn=null);for(;0<Gr.length&&(f=Gr[0],f.blockedOn===null);)Jx(f),f.blockedOn===null&&Gr.shift()}var Ea=S.ReactCurrentBatchConfig,Wc=!0;function e_(o,i,f,b){var j=st,$=Ea.transition;Ea.transition=null;try{st=1,qf(o,i,f,b)}finally{st=j,Ea.transition=$}}function t_(o,i,f,b){var j=st,$=Ea.transition;Ea.transition=null;try{st=4,qf(o,i,f,b)}finally{st=j,Ea.transition=$}}function qf(o,i,f,b){if(Wc){var j=Vf(o,i,f,b);if(j===null)um(o,i,b,Hc,f),Qx(o,b);else if(J2(j,o,i,f,b))b.stopPropagation();else if(Qx(o,b),i&4&&-1<Q2.indexOf(o)){for(;j!==null;){var $=sl(j);if($!==null&&xr($),$=Vf(o,i,f,b),$===null&&um(o,i,b,Hc,f),$===j)break;j=$}j!==null&&b.stopPropagation()}else um(o,i,b,null,f)}}var Hc=null;function Vf(o,i,f,b){if(Hc=null,o=Zn(b),o=Lo(o),o!==null)if(i=Tn(o),i===null)o=null;else if(f=i.tag,f===13){if(o=Ls(i),o!==null)return o;o=null}else if(f===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;o=null}else i!==o&&(o=null);return Hc=o,null}function ey(o){switch(o){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(Qt()){case dn:return 1;case Is:return 4;case At:case To:return 16;case Dr:return 536870912;default:return 16}default:return 16}}var qr=null,Kf=null,Bc=null;function ty(){if(Bc)return Bc;var o,i=Kf,f=i.length,b,j="value"in qr?qr.value:qr.textContent,$=j.length;for(o=0;o<f&&i[o]===j[o];o++);var M=f-o;for(b=1;b<=M&&i[f-b]===j[$-b];b++);return Bc=j.slice(o,1<b?1-b:void 0)}function Gc(o){var i=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&i===13&&(o=13)):o=i,o===10&&(o=13),32<=o||o===13?o:0}function qc(){return!0}function ny(){return!1}function ns(o){function i(f,b,j,$,M){this._reactName=f,this._targetInst=j,this.type=b,this.nativeEvent=$,this.target=M,this.currentTarget=null;for(var G in o)o.hasOwnProperty(G)&&(f=o[G],this[G]=f?f($):$[G]);return this.isDefaultPrevented=($.defaultPrevented!=null?$.defaultPrevented:$.returnValue===!1)?qc:ny,this.isPropagationStopped=ny,this}return V(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=qc)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=qc)},persist:function(){},isPersistent:qc}),i}var Ca={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yf=ns(Ca),qi=V({},Ca,{view:0,detail:0}),n_=ns(qi),Xf,Qf,Vi,Vc=V({},qi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zf,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Vi&&(Vi&&o.type==="mousemove"?(Xf=o.screenX-Vi.screenX,Qf=o.screenY-Vi.screenY):Qf=Xf=0,Vi=o),Xf)},movementY:function(o){return"movementY"in o?o.movementY:Qf}}),sy=ns(Vc),s_=V({},Vc,{dataTransfer:0}),r_=ns(s_),o_=V({},qi,{relatedTarget:0}),Jf=ns(o_),a_=V({},Ca,{animationName:0,elapsedTime:0,pseudoElement:0}),i_=ns(a_),l_=V({},Ca,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),c_=ns(l_),u_=V({},Ca,{data:0}),ry=ns(u_),d_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},f_={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"},m_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function p_(o){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(o):(o=m_[o])?!!i[o]:!1}function Zf(){return p_}var h_=V({},qi,{key:function(o){if(o.key){var i=d_[o.key]||o.key;if(i!=="Unidentified")return i}return o.type==="keypress"?(o=Gc(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?f_[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zf,charCode:function(o){return o.type==="keypress"?Gc(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Gc(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),g_=ns(h_),x_=V({},Vc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),oy=ns(x_),y_=V({},qi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zf}),b_=ns(y_),v_=V({},Ca,{propertyName:0,elapsedTime:0,pseudoElement:0}),w_=ns(v_),k_=V({},Vc,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),j_=ns(k_),N_=[9,13,27,32],em=u&&"CompositionEvent"in window,Ki=null;u&&"documentMode"in document&&(Ki=document.documentMode);var S_=u&&"TextEvent"in window&&!Ki,ay=u&&(!em||Ki&&8<Ki&&11>=Ki),iy=" ",ly=!1;function cy(o,i){switch(o){case"keyup":return N_.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function uy(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Ta=!1;function __(o,i){switch(o){case"compositionend":return uy(i);case"keypress":return i.which!==32?null:(ly=!0,iy);case"textInput":return o=i.data,o===iy&&ly?null:o;default:return null}}function $_(o,i){if(Ta)return o==="compositionend"||!em&&cy(o,i)?(o=ty(),Bc=Kf=qr=null,Ta=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return ay&&i.locale!=="ko"?null:i.data;default:return null}}var E_={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 dy(o){var i=o&&o.nodeName&&o.nodeName.toLowerCase();return i==="input"?!!E_[o.type]:i==="textarea"}function fy(o,i,f,b){gr(b),i=Jc(i,"onChange"),0<i.length&&(f=new Yf("onChange","change",null,f,b),o.push({event:f,listeners:i}))}var Yi=null,Xi=null;function C_(o){Ty(o,0)}function Kc(o){var i=La(o);if(se(i))return o}function T_(o,i){if(o==="change")return i}var my=!1;if(u){var tm;if(u){var nm="oninput"in document;if(!nm){var py=document.createElement("div");py.setAttribute("oninput","return;"),nm=typeof py.oninput=="function"}tm=nm}else tm=!1;my=tm&&(!document.documentMode||9<document.documentMode)}function hy(){Yi&&(Yi.detachEvent("onpropertychange",gy),Xi=Yi=null)}function gy(o){if(o.propertyName==="value"&&Kc(Xi)){var i=[];fy(i,Xi,o,Zn(o)),gs(C_,i)}}function R_(o,i,f){o==="focusin"?(hy(),Yi=i,Xi=f,Yi.attachEvent("onpropertychange",gy)):o==="focusout"&&hy()}function A_(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return Kc(Xi)}function O_(o,i){if(o==="click")return Kc(i)}function M_(o,i){if(o==="input"||o==="change")return Kc(i)}function L_(o,i){return o===i&&(o!==0||1/o===1/i)||o!==o&&i!==i}var Ds=typeof Object.is=="function"?Object.is:L_;function Qi(o,i){if(Ds(o,i))return!0;if(typeof o!="object"||o===null||typeof i!="object"||i===null)return!1;var f=Object.keys(o),b=Object.keys(i);if(f.length!==b.length)return!1;for(b=0;b<f.length;b++){var j=f[b];if(!d.call(i,j)||!Ds(o[j],i[j]))return!1}return!0}function xy(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function yy(o,i){var f=xy(o);o=0;for(var b;f;){if(f.nodeType===3){if(b=o+f.textContent.length,o<=i&&b>=i)return{node:f,offset:i-o};o=b}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=xy(f)}}function by(o,i){return o&&i?o===i?!0:o&&o.nodeType===3?!1:i&&i.nodeType===3?by(o,i.parentNode):"contains"in o?o.contains(i):o.compareDocumentPosition?!!(o.compareDocumentPosition(i)&16):!1:!1}function vy(){for(var o=window,i=pe();i instanceof o.HTMLIFrameElement;){try{var f=typeof i.contentWindow.location.href=="string"}catch{f=!1}if(f)o=i.contentWindow;else break;i=pe(o.document)}return i}function sm(o){var i=o&&o.nodeName&&o.nodeName.toLowerCase();return i&&(i==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||i==="textarea"||o.contentEditable==="true")}function P_(o){var i=vy(),f=o.focusedElem,b=o.selectionRange;if(i!==f&&f&&f.ownerDocument&&by(f.ownerDocument.documentElement,f)){if(b!==null&&sm(f)){if(i=b.start,o=b.end,o===void 0&&(o=i),"selectionStart"in f)f.selectionStart=i,f.selectionEnd=Math.min(o,f.value.length);else if(o=(i=f.ownerDocument||document)&&i.defaultView||window,o.getSelection){o=o.getSelection();var j=f.textContent.length,$=Math.min(b.start,j);b=b.end===void 0?$:Math.min(b.end,j),!o.extend&&$>b&&(j=b,b=$,$=j),j=yy(f,$);var M=yy(f,b);j&&M&&(o.rangeCount!==1||o.anchorNode!==j.node||o.anchorOffset!==j.offset||o.focusNode!==M.node||o.focusOffset!==M.offset)&&(i=i.createRange(),i.setStart(j.node,j.offset),o.removeAllRanges(),$>b?(o.addRange(i),o.extend(M.node,M.offset)):(i.setEnd(M.node,M.offset),o.addRange(i)))}}for(i=[],o=f;o=o.parentNode;)o.nodeType===1&&i.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<i.length;f++)o=i[f],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var I_=u&&"documentMode"in document&&11>=document.documentMode,Ra=null,rm=null,Ji=null,om=!1;function wy(o,i,f){var b=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;om||Ra==null||Ra!==pe(b)||(b=Ra,"selectionStart"in b&&sm(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Ji&&Qi(Ji,b)||(Ji=b,b=Jc(rm,"onSelect"),0<b.length&&(i=new Yf("onSelect","select",null,i,f),o.push({event:i,listeners:b}),i.target=Ra)))}function Yc(o,i){var f={};return f[o.toLowerCase()]=i.toLowerCase(),f["Webkit"+o]="webkit"+i,f["Moz"+o]="moz"+i,f}var Aa={animationend:Yc("Animation","AnimationEnd"),animationiteration:Yc("Animation","AnimationIteration"),animationstart:Yc("Animation","AnimationStart"),transitionend:Yc("Transition","TransitionEnd")},am={},ky={};u&&(ky=document.createElement("div").style,"AnimationEvent"in window||(delete Aa.animationend.animation,delete Aa.animationiteration.animation,delete Aa.animationstart.animation),"TransitionEvent"in window||delete Aa.transitionend.transition);function Xc(o){if(am[o])return am[o];if(!Aa[o])return o;var i=Aa[o],f;for(f in i)if(i.hasOwnProperty(f)&&f in ky)return am[o]=i[f];return o}var jy=Xc("animationend"),Ny=Xc("animationiteration"),Sy=Xc("animationstart"),_y=Xc("transitionend"),$y=new Map,Ey="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 Vr(o,i){$y.set(o,i),l(i,[o])}for(var im=0;im<Ey.length;im++){var lm=Ey[im],z_=lm.toLowerCase(),D_=lm[0].toUpperCase()+lm.slice(1);Vr(z_,"on"+D_)}Vr(jy,"onAnimationEnd"),Vr(Ny,"onAnimationIteration"),Vr(Sy,"onAnimationStart"),Vr("dblclick","onDoubleClick"),Vr("focusin","onFocus"),Vr("focusout","onBlur"),Vr(_y,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zi="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(" "),F_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Zi));function Cy(o,i,f){var b=o.type||"unknown-event";o.currentTarget=f,zr(b,i,void 0,o),o.currentTarget=null}function Ty(o,i){i=(i&4)!==0;for(var f=0;f<o.length;f++){var b=o[f],j=b.event;b=b.listeners;e:{var $=void 0;if(i)for(var M=b.length-1;0<=M;M--){var G=b[M],X=G.instance,le=G.currentTarget;if(G=G.listener,X!==$&&j.isPropagationStopped())break e;Cy(j,G,le),$=X}else for(M=0;M<b.length;M++){if(G=b[M],X=G.instance,le=G.currentTarget,G=G.listener,X!==$&&j.isPropagationStopped())break e;Cy(j,G,le),$=X}}}if(jt)throw o=Ut,jt=!1,Ut=null,o}function $t(o,i){var f=i[gm];f===void 0&&(f=i[gm]=new Set);var b=o+"__bubble";f.has(b)||(Ry(i,o,2,!1),f.add(b))}function cm(o,i,f){var b=0;i&&(b|=4),Ry(f,o,b,i)}var Qc="_reactListening"+Math.random().toString(36).slice(2);function el(o){if(!o[Qc]){o[Qc]=!0,r.forEach(function(f){f!=="selectionchange"&&(F_.has(f)||cm(f,!1,o),cm(f,!0,o))});var i=o.nodeType===9?o:o.ownerDocument;i===null||i[Qc]||(i[Qc]=!0,cm("selectionchange",!1,i))}}function Ry(o,i,f,b){switch(ey(i)){case 1:var j=e_;break;case 4:j=t_;break;default:j=qf}f=j.bind(null,i,f,o),j=void 0,!Ms||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(j=!0),b?j!==void 0?o.addEventListener(i,f,{capture:!0,passive:j}):o.addEventListener(i,f,!0):j!==void 0?o.addEventListener(i,f,{passive:j}):o.addEventListener(i,f,!1)}function um(o,i,f,b,j){var $=b;if((i&1)===0&&(i&2)===0&&b!==null)e:for(;;){if(b===null)return;var M=b.tag;if(M===3||M===4){var G=b.stateNode.containerInfo;if(G===j||G.nodeType===8&&G.parentNode===j)break;if(M===4)for(M=b.return;M!==null;){var X=M.tag;if((X===3||X===4)&&(X=M.stateNode.containerInfo,X===j||X.nodeType===8&&X.parentNode===j))return;M=M.return}for(;G!==null;){if(M=Lo(G),M===null)return;if(X=M.tag,X===5||X===6){b=$=M;continue e}G=G.parentNode}}b=b.return}gs(function(){var le=$,xe=Zn(f),be=[];e:{var he=$y.get(o);if(he!==void 0){var Re=Yf,Ie=o;switch(o){case"keypress":if(Gc(f)===0)break e;case"keydown":case"keyup":Re=g_;break;case"focusin":Ie="focus",Re=Jf;break;case"focusout":Ie="blur",Re=Jf;break;case"beforeblur":case"afterblur":Re=Jf;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Re=sy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Re=r_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Re=b_;break;case jy:case Ny:case Sy:Re=i_;break;case _y:Re=w_;break;case"scroll":Re=n_;break;case"wheel":Re=j_;break;case"copy":case"cut":case"paste":Re=c_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Re=oy}var De=(i&4)!==0,Ht=!De&&o==="scroll",re=De?he!==null?he+"Capture":null:he;De=[];for(var ne=le,oe;ne!==null;){oe=ne;var ke=oe.stateNode;if(oe.tag===5&&ke!==null&&(oe=ke,re!==null&&(ke=Un(ne,re),ke!=null&&De.push(tl(ne,ke,oe)))),Ht)break;ne=ne.return}0<De.length&&(he=new Re(he,Ie,null,f,xe),be.push({event:he,listeners:De}))}}if((i&7)===0){e:{if(he=o==="mouseover"||o==="pointerover",Re=o==="mouseout"||o==="pointerout",he&&f!==Jn&&(Ie=f.relatedTarget||f.fromElement)&&(Lo(Ie)||Ie[yr]))break e;if((Re||he)&&(he=xe.window===xe?xe:(he=xe.ownerDocument)?he.defaultView||he.parentWindow:window,Re?(Ie=f.relatedTarget||f.toElement,Re=le,Ie=Ie?Lo(Ie):null,Ie!==null&&(Ht=Tn(Ie),Ie!==Ht||Ie.tag!==5&&Ie.tag!==6)&&(Ie=null)):(Re=null,Ie=le),Re!==Ie)){if(De=sy,ke="onMouseLeave",re="onMouseEnter",ne="mouse",(o==="pointerout"||o==="pointerover")&&(De=oy,ke="onPointerLeave",re="onPointerEnter",ne="pointer"),Ht=Re==null?he:La(Re),oe=Ie==null?he:La(Ie),he=new De(ke,ne+"leave",Re,f,xe),he.target=Ht,he.relatedTarget=oe,ke=null,Lo(xe)===le&&(De=new De(re,ne+"enter",Ie,f,xe),De.target=oe,De.relatedTarget=Ht,ke=De),Ht=ke,Re&&Ie)t:{for(De=Re,re=Ie,ne=0,oe=De;oe;oe=Oa(oe))ne++;for(oe=0,ke=re;ke;ke=Oa(ke))oe++;for(;0<ne-oe;)De=Oa(De),ne--;for(;0<oe-ne;)re=Oa(re),oe--;for(;ne--;){if(De===re||re!==null&&De===re.alternate)break t;De=Oa(De),re=Oa(re)}De=null}else De=null;Re!==null&&Ay(be,he,Re,De,!1),Ie!==null&&Ht!==null&&Ay(be,Ht,Ie,De,!0)}}e:{if(he=le?La(le):window,Re=he.nodeName&&he.nodeName.toLowerCase(),Re==="select"||Re==="input"&&he.type==="file")var Ue=T_;else if(dy(he))if(my)Ue=M_;else{Ue=A_;var qe=R_}else(Re=he.nodeName)&&Re.toLowerCase()==="input"&&(he.type==="checkbox"||he.type==="radio")&&(Ue=O_);if(Ue&&(Ue=Ue(o,le))){fy(be,Ue,f,xe);break e}qe&&qe(o,he,le),o==="focusout"&&(qe=he._wrapperState)&&qe.controlled&&he.type==="number"&&et(he,"number",he.value)}switch(qe=le?La(le):window,o){case"focusin":(dy(qe)||qe.contentEditable==="true")&&(Ra=qe,rm=le,Ji=null);break;case"focusout":Ji=rm=Ra=null;break;case"mousedown":om=!0;break;case"contextmenu":case"mouseup":case"dragend":om=!1,wy(be,f,xe);break;case"selectionchange":if(I_)break;case"keydown":case"keyup":wy(be,f,xe)}var Ve;if(em)e:{switch(o){case"compositionstart":var Xe="onCompositionStart";break e;case"compositionend":Xe="onCompositionEnd";break e;case"compositionupdate":Xe="onCompositionUpdate";break e}Xe=void 0}else Ta?cy(o,f)&&(Xe="onCompositionEnd"):o==="keydown"&&f.keyCode===229&&(Xe="onCompositionStart");Xe&&(ay&&f.locale!=="ko"&&(Ta||Xe!=="onCompositionStart"?Xe==="onCompositionEnd"&&Ta&&(Ve=ty()):(qr=xe,Kf="value"in qr?qr.value:qr.textContent,Ta=!0)),qe=Jc(le,Xe),0<qe.length&&(Xe=new ry(Xe,o,null,f,xe),be.push({event:Xe,listeners:qe}),Ve?Xe.data=Ve:(Ve=uy(f),Ve!==null&&(Xe.data=Ve)))),(Ve=S_?__(o,f):$_(o,f))&&(le=Jc(le,"onBeforeInput"),0<le.length&&(xe=new ry("onBeforeInput","beforeinput",null,f,xe),be.push({event:xe,listeners:le}),xe.data=Ve))}Ty(be,i)})}function tl(o,i,f){return{instance:o,listener:i,currentTarget:f}}function Jc(o,i){for(var f=i+"Capture",b=[];o!==null;){var j=o,$=j.stateNode;j.tag===5&&$!==null&&(j=$,$=Un(o,f),$!=null&&b.unshift(tl(o,$,j)),$=Un(o,i),$!=null&&b.push(tl(o,$,j))),o=o.return}return b}function Oa(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function Ay(o,i,f,b,j){for(var $=i._reactName,M=[];f!==null&&f!==b;){var G=f,X=G.alternate,le=G.stateNode;if(X!==null&&X===b)break;G.tag===5&&le!==null&&(G=le,j?(X=Un(f,$),X!=null&&M.unshift(tl(f,X,G))):j||(X=Un(f,$),X!=null&&M.push(tl(f,X,G)))),f=f.return}M.length!==0&&o.push({event:i,listeners:M})}var U_=/\r\n?/g,W_=/\u0000|\uFFFD/g;function Oy(o){return(typeof o=="string"?o:""+o).replace(U_,`
38
+ `).replace(W_,"")}function Zc(o,i,f){if(i=Oy(i),Oy(o)!==i&&f)throw Error(s(425))}function eu(){}var dm=null,fm=null;function mm(o,i){return o==="textarea"||o==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var pm=typeof setTimeout=="function"?setTimeout:void 0,H_=typeof clearTimeout=="function"?clearTimeout:void 0,My=typeof Promise=="function"?Promise:void 0,B_=typeof queueMicrotask=="function"?queueMicrotask:typeof My<"u"?function(o){return My.resolve(null).then(o).catch(G_)}:pm;function G_(o){setTimeout(function(){throw o})}function hm(o,i){var f=i,b=0;do{var j=f.nextSibling;if(o.removeChild(f),j&&j.nodeType===8)if(f=j.data,f==="/$"){if(b===0){o.removeChild(j),Gi(i);return}b--}else f!=="$"&&f!=="$?"&&f!=="$!"||b++;f=j}while(f);Gi(i)}function Kr(o){for(;o!=null;o=o.nextSibling){var i=o.nodeType;if(i===1||i===3)break;if(i===8){if(i=o.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return o}function Ly(o){o=o.previousSibling;for(var i=0;o;){if(o.nodeType===8){var f=o.data;if(f==="$"||f==="$!"||f==="$?"){if(i===0)return o;i--}else f==="/$"&&i++}o=o.previousSibling}return null}var Ma=Math.random().toString(36).slice(2),tr="__reactFiber$"+Ma,nl="__reactProps$"+Ma,yr="__reactContainer$"+Ma,gm="__reactEvents$"+Ma,q_="__reactListeners$"+Ma,V_="__reactHandles$"+Ma;function Lo(o){var i=o[tr];if(i)return i;for(var f=o.parentNode;f;){if(i=f[yr]||f[tr]){if(f=i.alternate,i.child!==null||f!==null&&f.child!==null)for(o=Ly(o);o!==null;){if(f=o[tr])return f;o=Ly(o)}return i}o=f,f=o.parentNode}return null}function sl(o){return o=o[tr]||o[yr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function La(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(s(33))}function tu(o){return o[nl]||null}var xm=[],Pa=-1;function Yr(o){return{current:o}}function Et(o){0>Pa||(o.current=xm[Pa],xm[Pa]=null,Pa--)}function _t(o,i){Pa++,xm[Pa]=o.current,o.current=i}var Xr={},wn=Yr(Xr),Hn=Yr(!1),Po=Xr;function Ia(o,i){var f=o.type.contextTypes;if(!f)return Xr;var b=o.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===i)return b.__reactInternalMemoizedMaskedChildContext;var j={},$;for($ in f)j[$]=i[$];return b&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=i,o.__reactInternalMemoizedMaskedChildContext=j),j}function Bn(o){return o=o.childContextTypes,o!=null}function nu(){Et(Hn),Et(wn)}function Py(o,i,f){if(wn.current!==Xr)throw Error(s(168));_t(wn,i),_t(Hn,f)}function Iy(o,i,f){var b=o.stateNode;if(i=i.childContextTypes,typeof b.getChildContext!="function")return f;b=b.getChildContext();for(var j in b)if(!(j in i))throw Error(s(108,Q(o)||"Unknown",j));return V({},f,b)}function su(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||Xr,Po=wn.current,_t(wn,o),_t(Hn,Hn.current),!0}function zy(o,i,f){var b=o.stateNode;if(!b)throw Error(s(169));f?(o=Iy(o,i,Po),b.__reactInternalMemoizedMergedChildContext=o,Et(Hn),Et(wn),_t(wn,o)):Et(Hn),_t(Hn,f)}var br=null,ru=!1,ym=!1;function Dy(o){br===null?br=[o]:br.push(o)}function K_(o){ru=!0,Dy(o)}function Qr(){if(!ym&&br!==null){ym=!0;var o=0,i=st;try{var f=br;for(st=1;o<f.length;o++){var b=f[o];do b=b(!0);while(b!==null)}br=null,ru=!1}catch(j){throw br!==null&&(br=br.slice(o+1)),ve(dn,Qr),j}finally{st=i,ym=!1}}return null}var za=[],Da=0,ou=null,au=0,xs=[],ys=0,Io=null,vr=1,wr="";function zo(o,i){za[Da++]=au,za[Da++]=ou,ou=o,au=i}function Fy(o,i,f){xs[ys++]=vr,xs[ys++]=wr,xs[ys++]=Io,Io=o;var b=vr;o=wr;var j=32-Wn(b)-1;b&=~(1<<j),f+=1;var $=32-Wn(i)+j;if(30<$){var M=j-j%5;$=(b&(1<<M)-1).toString(32),b>>=M,j-=M,vr=1<<32-Wn(i)+j|f<<j|b,wr=$+o}else vr=1<<$|f<<j|b,wr=o}function bm(o){o.return!==null&&(zo(o,1),Fy(o,1,0))}function vm(o){for(;o===ou;)ou=za[--Da],za[Da]=null,au=za[--Da],za[Da]=null;for(;o===Io;)Io=xs[--ys],xs[ys]=null,wr=xs[--ys],xs[ys]=null,vr=xs[--ys],xs[ys]=null}var ss=null,rs=null,Tt=!1,Fs=null;function Uy(o,i){var f=ks(5,null,null,0);f.elementType="DELETED",f.stateNode=i,f.return=o,i=o.deletions,i===null?(o.deletions=[f],o.flags|=16):i.push(f)}function Wy(o,i){switch(o.tag){case 5:var f=o.type;return i=i.nodeType!==1||f.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(o.stateNode=i,ss=o,rs=Kr(i.firstChild),!0):!1;case 6:return i=o.pendingProps===""||i.nodeType!==3?null:i,i!==null?(o.stateNode=i,ss=o,rs=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(f=Io!==null?{id:vr,overflow:wr}:null,o.memoizedState={dehydrated:i,treeContext:f,retryLane:1073741824},f=ks(18,null,null,0),f.stateNode=i,f.return=o,o.child=f,ss=o,rs=null,!0):!1;default:return!1}}function wm(o){return(o.mode&1)!==0&&(o.flags&128)===0}function km(o){if(Tt){var i=rs;if(i){var f=i;if(!Wy(o,i)){if(wm(o))throw Error(s(418));i=Kr(f.nextSibling);var b=ss;i&&Wy(o,i)?Uy(b,f):(o.flags=o.flags&-4097|2,Tt=!1,ss=o)}}else{if(wm(o))throw Error(s(418));o.flags=o.flags&-4097|2,Tt=!1,ss=o}}}function Hy(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;ss=o}function iu(o){if(o!==ss)return!1;if(!Tt)return Hy(o),Tt=!0,!1;var i;if((i=o.tag!==3)&&!(i=o.tag!==5)&&(i=o.type,i=i!=="head"&&i!=="body"&&!mm(o.type,o.memoizedProps)),i&&(i=rs)){if(wm(o))throw By(),Error(s(418));for(;i;)Uy(o,i),i=Kr(i.nextSibling)}if(Hy(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(317));e:{for(o=o.nextSibling,i=0;o;){if(o.nodeType===8){var f=o.data;if(f==="/$"){if(i===0){rs=Kr(o.nextSibling);break e}i--}else f!=="$"&&f!=="$!"&&f!=="$?"||i++}o=o.nextSibling}rs=null}}else rs=ss?Kr(o.stateNode.nextSibling):null;return!0}function By(){for(var o=rs;o;)o=Kr(o.nextSibling)}function Fa(){rs=ss=null,Tt=!1}function jm(o){Fs===null?Fs=[o]:Fs.push(o)}var Y_=S.ReactCurrentBatchConfig;function rl(o,i,f){if(o=f.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(s(309));var b=f.stateNode}if(!b)throw Error(s(147,o));var j=b,$=""+o;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===$?i.ref:(i=function(M){var G=j.refs;M===null?delete G[$]:G[$]=M},i._stringRef=$,i)}if(typeof o!="string")throw Error(s(284));if(!f._owner)throw Error(s(290,o))}return o}function lu(o,i){throw o=Object.prototype.toString.call(i),Error(s(31,o==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":o))}function Gy(o){var i=o._init;return i(o._payload)}function qy(o){function i(re,ne){if(o){var oe=re.deletions;oe===null?(re.deletions=[ne],re.flags|=16):oe.push(ne)}}function f(re,ne){if(!o)return null;for(;ne!==null;)i(re,ne),ne=ne.sibling;return null}function b(re,ne){for(re=new Map;ne!==null;)ne.key!==null?re.set(ne.key,ne):re.set(ne.index,ne),ne=ne.sibling;return re}function j(re,ne){return re=oo(re,ne),re.index=0,re.sibling=null,re}function $(re,ne,oe){return re.index=oe,o?(oe=re.alternate,oe!==null?(oe=oe.index,oe<ne?(re.flags|=2,ne):oe):(re.flags|=2,ne)):(re.flags|=1048576,ne)}function M(re){return o&&re.alternate===null&&(re.flags|=2),re}function G(re,ne,oe,ke){return ne===null||ne.tag!==6?(ne=pp(oe,re.mode,ke),ne.return=re,ne):(ne=j(ne,oe),ne.return=re,ne)}function X(re,ne,oe,ke){var Ue=oe.type;return Ue===C?xe(re,ne,oe.props.children,ke,oe.key):ne!==null&&(ne.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===F&&Gy(Ue)===ne.type)?(ke=j(ne,oe.props),ke.ref=rl(re,ne,oe),ke.return=re,ke):(ke=Au(oe.type,oe.key,oe.props,null,re.mode,ke),ke.ref=rl(re,ne,oe),ke.return=re,ke)}function le(re,ne,oe,ke){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==oe.containerInfo||ne.stateNode.implementation!==oe.implementation?(ne=hp(oe,re.mode,ke),ne.return=re,ne):(ne=j(ne,oe.children||[]),ne.return=re,ne)}function xe(re,ne,oe,ke,Ue){return ne===null||ne.tag!==7?(ne=qo(oe,re.mode,ke,Ue),ne.return=re,ne):(ne=j(ne,oe),ne.return=re,ne)}function be(re,ne,oe){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=pp(""+ne,re.mode,oe),ne.return=re,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case E:return oe=Au(ne.type,ne.key,ne.props,null,re.mode,oe),oe.ref=rl(re,null,ne),oe.return=re,oe;case T:return ne=hp(ne,re.mode,oe),ne.return=re,ne;case F:var ke=ne._init;return be(re,ke(ne._payload),oe)}if(ae(ne)||H(ne))return ne=qo(ne,re.mode,oe,null),ne.return=re,ne;lu(re,ne)}return null}function he(re,ne,oe,ke){var Ue=ne!==null?ne.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number")return Ue!==null?null:G(re,ne,""+oe,ke);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case E:return oe.key===Ue?X(re,ne,oe,ke):null;case T:return oe.key===Ue?le(re,ne,oe,ke):null;case F:return Ue=oe._init,he(re,ne,Ue(oe._payload),ke)}if(ae(oe)||H(oe))return Ue!==null?null:xe(re,ne,oe,ke,null);lu(re,oe)}return null}function Re(re,ne,oe,ke,Ue){if(typeof ke=="string"&&ke!==""||typeof ke=="number")return re=re.get(oe)||null,G(ne,re,""+ke,Ue);if(typeof ke=="object"&&ke!==null){switch(ke.$$typeof){case E:return re=re.get(ke.key===null?oe:ke.key)||null,X(ne,re,ke,Ue);case T:return re=re.get(ke.key===null?oe:ke.key)||null,le(ne,re,ke,Ue);case F:var qe=ke._init;return Re(re,ne,oe,qe(ke._payload),Ue)}if(ae(ke)||H(ke))return re=re.get(oe)||null,xe(ne,re,ke,Ue,null);lu(ne,ke)}return null}function Ie(re,ne,oe,ke){for(var Ue=null,qe=null,Ve=ne,Xe=ne=0,an=null;Ve!==null&&Xe<oe.length;Xe++){Ve.index>Xe?(an=Ve,Ve=null):an=Ve.sibling;var pt=he(re,Ve,oe[Xe],ke);if(pt===null){Ve===null&&(Ve=an);break}o&&Ve&&pt.alternate===null&&i(re,Ve),ne=$(pt,ne,Xe),qe===null?Ue=pt:qe.sibling=pt,qe=pt,Ve=an}if(Xe===oe.length)return f(re,Ve),Tt&&zo(re,Xe),Ue;if(Ve===null){for(;Xe<oe.length;Xe++)Ve=be(re,oe[Xe],ke),Ve!==null&&(ne=$(Ve,ne,Xe),qe===null?Ue=Ve:qe.sibling=Ve,qe=Ve);return Tt&&zo(re,Xe),Ue}for(Ve=b(re,Ve);Xe<oe.length;Xe++)an=Re(Ve,re,Xe,oe[Xe],ke),an!==null&&(o&&an.alternate!==null&&Ve.delete(an.key===null?Xe:an.key),ne=$(an,ne,Xe),qe===null?Ue=an:qe.sibling=an,qe=an);return o&&Ve.forEach(function(ao){return i(re,ao)}),Tt&&zo(re,Xe),Ue}function De(re,ne,oe,ke){var Ue=H(oe);if(typeof Ue!="function")throw Error(s(150));if(oe=Ue.call(oe),oe==null)throw Error(s(151));for(var qe=Ue=null,Ve=ne,Xe=ne=0,an=null,pt=oe.next();Ve!==null&&!pt.done;Xe++,pt=oe.next()){Ve.index>Xe?(an=Ve,Ve=null):an=Ve.sibling;var ao=he(re,Ve,pt.value,ke);if(ao===null){Ve===null&&(Ve=an);break}o&&Ve&&ao.alternate===null&&i(re,Ve),ne=$(ao,ne,Xe),qe===null?Ue=ao:qe.sibling=ao,qe=ao,Ve=an}if(pt.done)return f(re,Ve),Tt&&zo(re,Xe),Ue;if(Ve===null){for(;!pt.done;Xe++,pt=oe.next())pt=be(re,pt.value,ke),pt!==null&&(ne=$(pt,ne,Xe),qe===null?Ue=pt:qe.sibling=pt,qe=pt);return Tt&&zo(re,Xe),Ue}for(Ve=b(re,Ve);!pt.done;Xe++,pt=oe.next())pt=Re(Ve,re,Xe,pt.value,ke),pt!==null&&(o&&pt.alternate!==null&&Ve.delete(pt.key===null?Xe:pt.key),ne=$(pt,ne,Xe),qe===null?Ue=pt:qe.sibling=pt,qe=pt);return o&&Ve.forEach(function(E$){return i(re,E$)}),Tt&&zo(re,Xe),Ue}function Ht(re,ne,oe,ke){if(typeof oe=="object"&&oe!==null&&oe.type===C&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case E:e:{for(var Ue=oe.key,qe=ne;qe!==null;){if(qe.key===Ue){if(Ue=oe.type,Ue===C){if(qe.tag===7){f(re,qe.sibling),ne=j(qe,oe.props.children),ne.return=re,re=ne;break e}}else if(qe.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===F&&Gy(Ue)===qe.type){f(re,qe.sibling),ne=j(qe,oe.props),ne.ref=rl(re,qe,oe),ne.return=re,re=ne;break e}f(re,qe);break}else i(re,qe);qe=qe.sibling}oe.type===C?(ne=qo(oe.props.children,re.mode,ke,oe.key),ne.return=re,re=ne):(ke=Au(oe.type,oe.key,oe.props,null,re.mode,ke),ke.ref=rl(re,ne,oe),ke.return=re,re=ke)}return M(re);case T:e:{for(qe=oe.key;ne!==null;){if(ne.key===qe)if(ne.tag===4&&ne.stateNode.containerInfo===oe.containerInfo&&ne.stateNode.implementation===oe.implementation){f(re,ne.sibling),ne=j(ne,oe.children||[]),ne.return=re,re=ne;break e}else{f(re,ne);break}else i(re,ne);ne=ne.sibling}ne=hp(oe,re.mode,ke),ne.return=re,re=ne}return M(re);case F:return qe=oe._init,Ht(re,ne,qe(oe._payload),ke)}if(ae(oe))return Ie(re,ne,oe,ke);if(H(oe))return De(re,ne,oe,ke);lu(re,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"?(oe=""+oe,ne!==null&&ne.tag===6?(f(re,ne.sibling),ne=j(ne,oe),ne.return=re,re=ne):(f(re,ne),ne=pp(oe,re.mode,ke),ne.return=re,re=ne),M(re)):f(re,ne)}return Ht}var Ua=qy(!0),Vy=qy(!1),cu=Yr(null),uu=null,Wa=null,Nm=null;function Sm(){Nm=Wa=uu=null}function _m(o){var i=cu.current;Et(cu),o._currentValue=i}function $m(o,i,f){for(;o!==null;){var b=o.alternate;if((o.childLanes&i)!==i?(o.childLanes|=i,b!==null&&(b.childLanes|=i)):b!==null&&(b.childLanes&i)!==i&&(b.childLanes|=i),o===f)break;o=o.return}}function Ha(o,i){uu=o,Nm=Wa=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&i)!==0&&(Gn=!0),o.firstContext=null)}function bs(o){var i=o._currentValue;if(Nm!==o)if(o={context:o,memoizedValue:i,next:null},Wa===null){if(uu===null)throw Error(s(308));Wa=o,uu.dependencies={lanes:0,firstContext:o}}else Wa=Wa.next=o;return i}var Do=null;function Em(o){Do===null?Do=[o]:Do.push(o)}function Ky(o,i,f,b){var j=i.interleaved;return j===null?(f.next=f,Em(i)):(f.next=j.next,j.next=f),i.interleaved=f,kr(o,b)}function kr(o,i){o.lanes|=i;var f=o.alternate;for(f!==null&&(f.lanes|=i),f=o,o=o.return;o!==null;)o.childLanes|=i,f=o.alternate,f!==null&&(f.childLanes|=i),f=o,o=o.return;return f.tag===3?f.stateNode:null}var Jr=!1;function Cm(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Yy(o,i){o=o.updateQueue,i.updateQueue===o&&(i.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function jr(o,i){return{eventTime:o,lane:i,tag:0,payload:null,callback:null,next:null}}function Zr(o,i,f){var b=o.updateQueue;if(b===null)return null;if(b=b.shared,(mt&2)!==0){var j=b.pending;return j===null?i.next=i:(i.next=j.next,j.next=i),b.pending=i,kr(o,f)}return j=b.interleaved,j===null?(i.next=i,Em(b)):(i.next=j.next,j.next=i),b.interleaved=i,kr(o,f)}function du(o,i,f){if(i=i.updateQueue,i!==null&&(i=i.shared,(f&4194240)!==0)){var b=i.lanes;b&=o.pendingLanes,f|=b,i.lanes=f,fn(o,f)}}function Xy(o,i){var f=o.updateQueue,b=o.alternate;if(b!==null&&(b=b.updateQueue,f===b)){var j=null,$=null;if(f=f.firstBaseUpdate,f!==null){do{var M={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};$===null?j=$=M:$=$.next=M,f=f.next}while(f!==null);$===null?j=$=i:$=$.next=i}else j=$=i;f={baseState:b.baseState,firstBaseUpdate:j,lastBaseUpdate:$,shared:b.shared,effects:b.effects},o.updateQueue=f;return}o=f.lastBaseUpdate,o===null?f.firstBaseUpdate=i:o.next=i,f.lastBaseUpdate=i}function fu(o,i,f,b){var j=o.updateQueue;Jr=!1;var $=j.firstBaseUpdate,M=j.lastBaseUpdate,G=j.shared.pending;if(G!==null){j.shared.pending=null;var X=G,le=X.next;X.next=null,M===null?$=le:M.next=le,M=X;var xe=o.alternate;xe!==null&&(xe=xe.updateQueue,G=xe.lastBaseUpdate,G!==M&&(G===null?xe.firstBaseUpdate=le:G.next=le,xe.lastBaseUpdate=X))}if($!==null){var be=j.baseState;M=0,xe=le=X=null,G=$;do{var he=G.lane,Re=G.eventTime;if((b&he)===he){xe!==null&&(xe=xe.next={eventTime:Re,lane:0,tag:G.tag,payload:G.payload,callback:G.callback,next:null});e:{var Ie=o,De=G;switch(he=i,Re=f,De.tag){case 1:if(Ie=De.payload,typeof Ie=="function"){be=Ie.call(Re,be,he);break e}be=Ie;break e;case 3:Ie.flags=Ie.flags&-65537|128;case 0:if(Ie=De.payload,he=typeof Ie=="function"?Ie.call(Re,be,he):Ie,he==null)break e;be=V({},be,he);break e;case 2:Jr=!0}}G.callback!==null&&G.lane!==0&&(o.flags|=64,he=j.effects,he===null?j.effects=[G]:he.push(G))}else Re={eventTime:Re,lane:he,tag:G.tag,payload:G.payload,callback:G.callback,next:null},xe===null?(le=xe=Re,X=be):xe=xe.next=Re,M|=he;if(G=G.next,G===null){if(G=j.shared.pending,G===null)break;he=G,G=he.next,he.next=null,j.lastBaseUpdate=he,j.shared.pending=null}}while(!0);if(xe===null&&(X=be),j.baseState=X,j.firstBaseUpdate=le,j.lastBaseUpdate=xe,i=j.shared.interleaved,i!==null){j=i;do M|=j.lane,j=j.next;while(j!==i)}else $===null&&(j.shared.lanes=0);Wo|=M,o.lanes=M,o.memoizedState=be}}function Qy(o,i,f){if(o=i.effects,i.effects=null,o!==null)for(i=0;i<o.length;i++){var b=o[i],j=b.callback;if(j!==null){if(b.callback=null,b=f,typeof j!="function")throw Error(s(191,j));j.call(b)}}}var ol={},nr=Yr(ol),al=Yr(ol),il=Yr(ol);function Fo(o){if(o===ol)throw Error(s(174));return o}function Tm(o,i){switch(_t(il,i),_t(al,o),_t(nr,ol),o=i.nodeType,o){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:yn(null,"");break;default:o=o===8?i.parentNode:i,i=o.namespaceURI||null,o=o.tagName,i=yn(i,o)}Et(nr),_t(nr,i)}function Ba(){Et(nr),Et(al),Et(il)}function Jy(o){Fo(il.current);var i=Fo(nr.current),f=yn(i,o.type);i!==f&&(_t(al,o),_t(nr,f))}function Rm(o){al.current===o&&(Et(nr),Et(al))}var Ot=Yr(0);function mu(o){for(var i=o;i!==null;){if(i.tag===13){var f=i.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break;for(;i.sibling===null;){if(i.return===null||i.return===o)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Am=[];function Om(){for(var o=0;o<Am.length;o++)Am[o]._workInProgressVersionPrimary=null;Am.length=0}var pu=S.ReactCurrentDispatcher,Mm=S.ReactCurrentBatchConfig,Uo=0,Mt=null,Jt=null,rn=null,hu=!1,ll=!1,cl=0,X_=0;function kn(){throw Error(s(321))}function Lm(o,i){if(i===null)return!1;for(var f=0;f<i.length&&f<o.length;f++)if(!Ds(o[f],i[f]))return!1;return!0}function Pm(o,i,f,b,j,$){if(Uo=$,Mt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,pu.current=o===null||o.memoizedState===null?e$:t$,o=f(b,j),ll){$=0;do{if(ll=!1,cl=0,25<=$)throw Error(s(301));$+=1,rn=Jt=null,i.updateQueue=null,pu.current=n$,o=f(b,j)}while(ll)}if(pu.current=yu,i=Jt!==null&&Jt.next!==null,Uo=0,rn=Jt=Mt=null,hu=!1,i)throw Error(s(300));return o}function Im(){var o=cl!==0;return cl=0,o}function sr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rn===null?Mt.memoizedState=rn=o:rn=rn.next=o,rn}function vs(){if(Jt===null){var o=Mt.alternate;o=o!==null?o.memoizedState:null}else o=Jt.next;var i=rn===null?Mt.memoizedState:rn.next;if(i!==null)rn=i,Jt=o;else{if(o===null)throw Error(s(310));Jt=o,o={memoizedState:Jt.memoizedState,baseState:Jt.baseState,baseQueue:Jt.baseQueue,queue:Jt.queue,next:null},rn===null?Mt.memoizedState=rn=o:rn=rn.next=o}return rn}function ul(o,i){return typeof i=="function"?i(o):i}function zm(o){var i=vs(),f=i.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=o;var b=Jt,j=b.baseQueue,$=f.pending;if($!==null){if(j!==null){var M=j.next;j.next=$.next,$.next=M}b.baseQueue=j=$,f.pending=null}if(j!==null){$=j.next,b=b.baseState;var G=M=null,X=null,le=$;do{var xe=le.lane;if((Uo&xe)===xe)X!==null&&(X=X.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),b=le.hasEagerState?le.eagerState:o(b,le.action);else{var be={lane:xe,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};X===null?(G=X=be,M=b):X=X.next=be,Mt.lanes|=xe,Wo|=xe}le=le.next}while(le!==null&&le!==$);X===null?M=b:X.next=G,Ds(b,i.memoizedState)||(Gn=!0),i.memoizedState=b,i.baseState=M,i.baseQueue=X,f.lastRenderedState=b}if(o=f.interleaved,o!==null){j=o;do $=j.lane,Mt.lanes|=$,Wo|=$,j=j.next;while(j!==o)}else j===null&&(f.lanes=0);return[i.memoizedState,f.dispatch]}function Dm(o){var i=vs(),f=i.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=o;var b=f.dispatch,j=f.pending,$=i.memoizedState;if(j!==null){f.pending=null;var M=j=j.next;do $=o($,M.action),M=M.next;while(M!==j);Ds($,i.memoizedState)||(Gn=!0),i.memoizedState=$,i.baseQueue===null&&(i.baseState=$),f.lastRenderedState=$}return[$,b]}function Zy(){}function eb(o,i){var f=Mt,b=vs(),j=i(),$=!Ds(b.memoizedState,j);if($&&(b.memoizedState=j,Gn=!0),b=b.queue,Fm(sb.bind(null,f,b,o),[o]),b.getSnapshot!==i||$||rn!==null&&rn.memoizedState.tag&1){if(f.flags|=2048,dl(9,nb.bind(null,f,b,j,i),void 0,null),on===null)throw Error(s(349));(Uo&30)!==0||tb(f,i,j)}return j}function tb(o,i,f){o.flags|=16384,o={getSnapshot:i,value:f},i=Mt.updateQueue,i===null?(i={lastEffect:null,stores:null},Mt.updateQueue=i,i.stores=[o]):(f=i.stores,f===null?i.stores=[o]:f.push(o))}function nb(o,i,f,b){i.value=f,i.getSnapshot=b,rb(i)&&ob(o)}function sb(o,i,f){return f(function(){rb(i)&&ob(o)})}function rb(o){var i=o.getSnapshot;o=o.value;try{var f=i();return!Ds(o,f)}catch{return!0}}function ob(o){var i=kr(o,1);i!==null&&Bs(i,o,1,-1)}function ab(o){var i=sr();return typeof o=="function"&&(o=o()),i.memoizedState=i.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ul,lastRenderedState:o},i.queue=o,o=o.dispatch=Z_.bind(null,Mt,o),[i.memoizedState,o]}function dl(o,i,f,b){return o={tag:o,create:i,destroy:f,deps:b,next:null},i=Mt.updateQueue,i===null?(i={lastEffect:null,stores:null},Mt.updateQueue=i,i.lastEffect=o.next=o):(f=i.lastEffect,f===null?i.lastEffect=o.next=o:(b=f.next,f.next=o,o.next=b,i.lastEffect=o)),o}function ib(){return vs().memoizedState}function gu(o,i,f,b){var j=sr();Mt.flags|=o,j.memoizedState=dl(1|i,f,void 0,b===void 0?null:b)}function xu(o,i,f,b){var j=vs();b=b===void 0?null:b;var $=void 0;if(Jt!==null){var M=Jt.memoizedState;if($=M.destroy,b!==null&&Lm(b,M.deps)){j.memoizedState=dl(i,f,$,b);return}}Mt.flags|=o,j.memoizedState=dl(1|i,f,$,b)}function lb(o,i){return gu(8390656,8,o,i)}function Fm(o,i){return xu(2048,8,o,i)}function cb(o,i){return xu(4,2,o,i)}function ub(o,i){return xu(4,4,o,i)}function db(o,i){if(typeof i=="function")return o=o(),i(o),function(){i(null)};if(i!=null)return o=o(),i.current=o,function(){i.current=null}}function fb(o,i,f){return f=f!=null?f.concat([o]):null,xu(4,4,db.bind(null,i,o),f)}function Um(){}function mb(o,i){var f=vs();i=i===void 0?null:i;var b=f.memoizedState;return b!==null&&i!==null&&Lm(i,b[1])?b[0]:(f.memoizedState=[o,i],o)}function pb(o,i){var f=vs();i=i===void 0?null:i;var b=f.memoizedState;return b!==null&&i!==null&&Lm(i,b[1])?b[0]:(o=o(),f.memoizedState=[o,i],o)}function hb(o,i,f){return(Uo&21)===0?(o.baseState&&(o.baseState=!1,Gn=!0),o.memoizedState=f):(Ds(f,i)||(f=ze(),Mt.lanes|=f,Wo|=f,o.baseState=!0),i)}function Q_(o,i){var f=st;st=f!==0&&4>f?f:4,o(!0);var b=Mm.transition;Mm.transition={};try{o(!1),i()}finally{st=f,Mm.transition=b}}function gb(){return vs().memoizedState}function J_(o,i,f){var b=so(o);if(f={lane:b,action:f,hasEagerState:!1,eagerState:null,next:null},xb(o))yb(i,f);else if(f=Ky(o,i,f,b),f!==null){var j=An();Bs(f,o,b,j),bb(f,i,b)}}function Z_(o,i,f){var b=so(o),j={lane:b,action:f,hasEagerState:!1,eagerState:null,next:null};if(xb(o))yb(i,j);else{var $=o.alternate;if(o.lanes===0&&($===null||$.lanes===0)&&($=i.lastRenderedReducer,$!==null))try{var M=i.lastRenderedState,G=$(M,f);if(j.hasEagerState=!0,j.eagerState=G,Ds(G,M)){var X=i.interleaved;X===null?(j.next=j,Em(i)):(j.next=X.next,X.next=j),i.interleaved=j;return}}catch{}finally{}f=Ky(o,i,j,b),f!==null&&(j=An(),Bs(f,o,b,j),bb(f,i,b))}}function xb(o){var i=o.alternate;return o===Mt||i!==null&&i===Mt}function yb(o,i){ll=hu=!0;var f=o.pending;f===null?i.next=i:(i.next=f.next,f.next=i),o.pending=i}function bb(o,i,f){if((f&4194240)!==0){var b=i.lanes;b&=o.pendingLanes,f|=b,i.lanes=f,fn(o,f)}}var yu={readContext:bs,useCallback:kn,useContext:kn,useEffect:kn,useImperativeHandle:kn,useInsertionEffect:kn,useLayoutEffect:kn,useMemo:kn,useReducer:kn,useRef:kn,useState:kn,useDebugValue:kn,useDeferredValue:kn,useTransition:kn,useMutableSource:kn,useSyncExternalStore:kn,useId:kn,unstable_isNewReconciler:!1},e$={readContext:bs,useCallback:function(o,i){return sr().memoizedState=[o,i===void 0?null:i],o},useContext:bs,useEffect:lb,useImperativeHandle:function(o,i,f){return f=f!=null?f.concat([o]):null,gu(4194308,4,db.bind(null,i,o),f)},useLayoutEffect:function(o,i){return gu(4194308,4,o,i)},useInsertionEffect:function(o,i){return gu(4,2,o,i)},useMemo:function(o,i){var f=sr();return i=i===void 0?null:i,o=o(),f.memoizedState=[o,i],o},useReducer:function(o,i,f){var b=sr();return i=f!==void 0?f(i):i,b.memoizedState=b.baseState=i,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:i},b.queue=o,o=o.dispatch=J_.bind(null,Mt,o),[b.memoizedState,o]},useRef:function(o){var i=sr();return o={current:o},i.memoizedState=o},useState:ab,useDebugValue:Um,useDeferredValue:function(o){return sr().memoizedState=o},useTransition:function(){var o=ab(!1),i=o[0];return o=Q_.bind(null,o[1]),sr().memoizedState=o,[i,o]},useMutableSource:function(){},useSyncExternalStore:function(o,i,f){var b=Mt,j=sr();if(Tt){if(f===void 0)throw Error(s(407));f=f()}else{if(f=i(),on===null)throw Error(s(349));(Uo&30)!==0||tb(b,i,f)}j.memoizedState=f;var $={value:f,getSnapshot:i};return j.queue=$,lb(sb.bind(null,b,$,o),[o]),b.flags|=2048,dl(9,nb.bind(null,b,$,f,i),void 0,null),f},useId:function(){var o=sr(),i=on.identifierPrefix;if(Tt){var f=wr,b=vr;f=(b&~(1<<32-Wn(b)-1)).toString(32)+f,i=":"+i+"R"+f,f=cl++,0<f&&(i+="H"+f.toString(32)),i+=":"}else f=X_++,i=":"+i+"r"+f.toString(32)+":";return o.memoizedState=i},unstable_isNewReconciler:!1},t$={readContext:bs,useCallback:mb,useContext:bs,useEffect:Fm,useImperativeHandle:fb,useInsertionEffect:cb,useLayoutEffect:ub,useMemo:pb,useReducer:zm,useRef:ib,useState:function(){return zm(ul)},useDebugValue:Um,useDeferredValue:function(o){var i=vs();return hb(i,Jt.memoizedState,o)},useTransition:function(){var o=zm(ul)[0],i=vs().memoizedState;return[o,i]},useMutableSource:Zy,useSyncExternalStore:eb,useId:gb,unstable_isNewReconciler:!1},n$={readContext:bs,useCallback:mb,useContext:bs,useEffect:Fm,useImperativeHandle:fb,useInsertionEffect:cb,useLayoutEffect:ub,useMemo:pb,useReducer:Dm,useRef:ib,useState:function(){return Dm(ul)},useDebugValue:Um,useDeferredValue:function(o){var i=vs();return Jt===null?i.memoizedState=o:hb(i,Jt.memoizedState,o)},useTransition:function(){var o=Dm(ul)[0],i=vs().memoizedState;return[o,i]},useMutableSource:Zy,useSyncExternalStore:eb,useId:gb,unstable_isNewReconciler:!1};function Us(o,i){if(o&&o.defaultProps){i=V({},i),o=o.defaultProps;for(var f in o)i[f]===void 0&&(i[f]=o[f]);return i}return i}function Wm(o,i,f,b){i=o.memoizedState,f=f(b,i),f=f==null?i:V({},i,f),o.memoizedState=f,o.lanes===0&&(o.updateQueue.baseState=f)}var bu={isMounted:function(o){return(o=o._reactInternals)?Tn(o)===o:!1},enqueueSetState:function(o,i,f){o=o._reactInternals;var b=An(),j=so(o),$=jr(b,j);$.payload=i,f!=null&&($.callback=f),i=Zr(o,$,j),i!==null&&(Bs(i,o,j,b),du(i,o,j))},enqueueReplaceState:function(o,i,f){o=o._reactInternals;var b=An(),j=so(o),$=jr(b,j);$.tag=1,$.payload=i,f!=null&&($.callback=f),i=Zr(o,$,j),i!==null&&(Bs(i,o,j,b),du(i,o,j))},enqueueForceUpdate:function(o,i){o=o._reactInternals;var f=An(),b=so(o),j=jr(f,b);j.tag=2,i!=null&&(j.callback=i),i=Zr(o,j,b),i!==null&&(Bs(i,o,b,f),du(i,o,b))}};function vb(o,i,f,b,j,$,M){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(b,$,M):i.prototype&&i.prototype.isPureReactComponent?!Qi(f,b)||!Qi(j,$):!0}function wb(o,i,f){var b=!1,j=Xr,$=i.contextType;return typeof $=="object"&&$!==null?$=bs($):(j=Bn(i)?Po:wn.current,b=i.contextTypes,$=(b=b!=null)?Ia(o,j):Xr),i=new i(f,$),o.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=bu,o.stateNode=i,i._reactInternals=o,b&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=j,o.__reactInternalMemoizedMaskedChildContext=$),i}function kb(o,i,f,b){o=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(f,b),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(f,b),i.state!==o&&bu.enqueueReplaceState(i,i.state,null)}function Hm(o,i,f,b){var j=o.stateNode;j.props=f,j.state=o.memoizedState,j.refs={},Cm(o);var $=i.contextType;typeof $=="object"&&$!==null?j.context=bs($):($=Bn(i)?Po:wn.current,j.context=Ia(o,$)),j.state=o.memoizedState,$=i.getDerivedStateFromProps,typeof $=="function"&&(Wm(o,i,$,f),j.state=o.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(i=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),i!==j.state&&bu.enqueueReplaceState(j,j.state,null),fu(o,f,j,b),j.state=o.memoizedState),typeof j.componentDidMount=="function"&&(o.flags|=4194308)}function Ga(o,i){try{var f="",b=i;do f+=de(b),b=b.return;while(b);var j=f}catch($){j=`
39
+ Error generating stack: `+$.message+`
40
+ `+$.stack}return{value:o,source:i,stack:j,digest:null}}function Bm(o,i,f){return{value:o,source:null,stack:f??null,digest:i??null}}function Gm(o,i){try{console.error(i.value)}catch(f){setTimeout(function(){throw f})}}var s$=typeof WeakMap=="function"?WeakMap:Map;function jb(o,i,f){f=jr(-1,f),f.tag=3,f.payload={element:null};var b=i.value;return f.callback=function(){_u||(_u=!0,ap=b),Gm(o,i)},f}function Nb(o,i,f){f=jr(-1,f),f.tag=3;var b=o.type.getDerivedStateFromError;if(typeof b=="function"){var j=i.value;f.payload=function(){return b(j)},f.callback=function(){Gm(o,i)}}var $=o.stateNode;return $!==null&&typeof $.componentDidCatch=="function"&&(f.callback=function(){Gm(o,i),typeof b!="function"&&(to===null?to=new Set([this]):to.add(this));var M=i.stack;this.componentDidCatch(i.value,{componentStack:M!==null?M:""})}),f}function Sb(o,i,f){var b=o.pingCache;if(b===null){b=o.pingCache=new s$;var j=new Set;b.set(i,j)}else j=b.get(i),j===void 0&&(j=new Set,b.set(i,j));j.has(f)||(j.add(f),o=x$.bind(null,o,i,f),i.then(o,o))}function _b(o){do{var i;if((i=o.tag===13)&&(i=o.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return o;o=o.return}while(o!==null);return null}function $b(o,i,f,b,j){return(o.mode&1)===0?(o===i?o.flags|=65536:(o.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(i=jr(-1,1),i.tag=2,Zr(f,i,1))),f.lanes|=1),o):(o.flags|=65536,o.lanes=j,o)}var r$=S.ReactCurrentOwner,Gn=!1;function Rn(o,i,f,b){i.child=o===null?Vy(i,null,f,b):Ua(i,o.child,f,b)}function Eb(o,i,f,b,j){f=f.render;var $=i.ref;return Ha(i,j),b=Pm(o,i,f,b,$,j),f=Im(),o!==null&&!Gn?(i.updateQueue=o.updateQueue,i.flags&=-2053,o.lanes&=~j,Nr(o,i,j)):(Tt&&f&&bm(i),i.flags|=1,Rn(o,i,b,j),i.child)}function Cb(o,i,f,b,j){if(o===null){var $=f.type;return typeof $=="function"&&!mp($)&&$.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(i.tag=15,i.type=$,Tb(o,i,$,b,j)):(o=Au(f.type,null,b,i,i.mode,j),o.ref=i.ref,o.return=i,i.child=o)}if($=o.child,(o.lanes&j)===0){var M=$.memoizedProps;if(f=f.compare,f=f!==null?f:Qi,f(M,b)&&o.ref===i.ref)return Nr(o,i,j)}return i.flags|=1,o=oo($,b),o.ref=i.ref,o.return=i,i.child=o}function Tb(o,i,f,b,j){if(o!==null){var $=o.memoizedProps;if(Qi($,b)&&o.ref===i.ref)if(Gn=!1,i.pendingProps=b=$,(o.lanes&j)!==0)(o.flags&131072)!==0&&(Gn=!0);else return i.lanes=o.lanes,Nr(o,i,j)}return qm(o,i,f,b,j)}function Rb(o,i,f){var b=i.pendingProps,j=b.children,$=o!==null?o.memoizedState:null;if(b.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},_t(Va,os),os|=f;else{if((f&1073741824)===0)return o=$!==null?$.baseLanes|f:f,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:o,cachePool:null,transitions:null},i.updateQueue=null,_t(Va,os),os|=o,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=$!==null?$.baseLanes:f,_t(Va,os),os|=b}else $!==null?(b=$.baseLanes|f,i.memoizedState=null):b=f,_t(Va,os),os|=b;return Rn(o,i,j,f),i.child}function Ab(o,i){var f=i.ref;(o===null&&f!==null||o!==null&&o.ref!==f)&&(i.flags|=512,i.flags|=2097152)}function qm(o,i,f,b,j){var $=Bn(f)?Po:wn.current;return $=Ia(i,$),Ha(i,j),f=Pm(o,i,f,b,$,j),b=Im(),o!==null&&!Gn?(i.updateQueue=o.updateQueue,i.flags&=-2053,o.lanes&=~j,Nr(o,i,j)):(Tt&&b&&bm(i),i.flags|=1,Rn(o,i,f,j),i.child)}function Ob(o,i,f,b,j){if(Bn(f)){var $=!0;su(i)}else $=!1;if(Ha(i,j),i.stateNode===null)wu(o,i),wb(i,f,b),Hm(i,f,b,j),b=!0;else if(o===null){var M=i.stateNode,G=i.memoizedProps;M.props=G;var X=M.context,le=f.contextType;typeof le=="object"&&le!==null?le=bs(le):(le=Bn(f)?Po:wn.current,le=Ia(i,le));var xe=f.getDerivedStateFromProps,be=typeof xe=="function"||typeof M.getSnapshotBeforeUpdate=="function";be||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(G!==b||X!==le)&&kb(i,M,b,le),Jr=!1;var he=i.memoizedState;M.state=he,fu(i,b,M,j),X=i.memoizedState,G!==b||he!==X||Hn.current||Jr?(typeof xe=="function"&&(Wm(i,f,xe,b),X=i.memoizedState),(G=Jr||vb(i,f,G,b,he,X,le))?(be||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(i.flags|=4194308)):(typeof M.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=b,i.memoizedState=X),M.props=b,M.state=X,M.context=le,b=G):(typeof M.componentDidMount=="function"&&(i.flags|=4194308),b=!1)}else{M=i.stateNode,Yy(o,i),G=i.memoizedProps,le=i.type===i.elementType?G:Us(i.type,G),M.props=le,be=i.pendingProps,he=M.context,X=f.contextType,typeof X=="object"&&X!==null?X=bs(X):(X=Bn(f)?Po:wn.current,X=Ia(i,X));var Re=f.getDerivedStateFromProps;(xe=typeof Re=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(G!==be||he!==X)&&kb(i,M,b,X),Jr=!1,he=i.memoizedState,M.state=he,fu(i,b,M,j);var Ie=i.memoizedState;G!==be||he!==Ie||Hn.current||Jr?(typeof Re=="function"&&(Wm(i,f,Re,b),Ie=i.memoizedState),(le=Jr||vb(i,f,le,b,he,Ie,X)||!1)?(xe||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(b,Ie,X),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(b,Ie,X)),typeof M.componentDidUpdate=="function"&&(i.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof M.componentDidUpdate!="function"||G===o.memoizedProps&&he===o.memoizedState||(i.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||G===o.memoizedProps&&he===o.memoizedState||(i.flags|=1024),i.memoizedProps=b,i.memoizedState=Ie),M.props=b,M.state=Ie,M.context=X,b=le):(typeof M.componentDidUpdate!="function"||G===o.memoizedProps&&he===o.memoizedState||(i.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||G===o.memoizedProps&&he===o.memoizedState||(i.flags|=1024),b=!1)}return Vm(o,i,f,b,$,j)}function Vm(o,i,f,b,j,$){Ab(o,i);var M=(i.flags&128)!==0;if(!b&&!M)return j&&zy(i,f,!1),Nr(o,i,$);b=i.stateNode,r$.current=i;var G=M&&typeof f.getDerivedStateFromError!="function"?null:b.render();return i.flags|=1,o!==null&&M?(i.child=Ua(i,o.child,null,$),i.child=Ua(i,null,G,$)):Rn(o,i,G,$),i.memoizedState=b.state,j&&zy(i,f,!0),i.child}function Mb(o){var i=o.stateNode;i.pendingContext?Py(o,i.pendingContext,i.pendingContext!==i.context):i.context&&Py(o,i.context,!1),Tm(o,i.containerInfo)}function Lb(o,i,f,b,j){return Fa(),jm(j),i.flags|=256,Rn(o,i,f,b),i.child}var Km={dehydrated:null,treeContext:null,retryLane:0};function Ym(o){return{baseLanes:o,cachePool:null,transitions:null}}function Pb(o,i,f){var b=i.pendingProps,j=Ot.current,$=!1,M=(i.flags&128)!==0,G;if((G=M)||(G=o!==null&&o.memoizedState===null?!1:(j&2)!==0),G?($=!0,i.flags&=-129):(o===null||o.memoizedState!==null)&&(j|=1),_t(Ot,j&1),o===null)return km(i),o=i.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((i.mode&1)===0?i.lanes=1:o.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(M=b.children,o=b.fallback,$?(b=i.mode,$=i.child,M={mode:"hidden",children:M},(b&1)===0&&$!==null?($.childLanes=0,$.pendingProps=M):$=Ou(M,b,0,null),o=qo(o,b,f,null),$.return=i,o.return=i,$.sibling=o,i.child=$,i.child.memoizedState=Ym(f),i.memoizedState=Km,o):Xm(i,M));if(j=o.memoizedState,j!==null&&(G=j.dehydrated,G!==null))return o$(o,i,M,b,G,j,f);if($){$=b.fallback,M=i.mode,j=o.child,G=j.sibling;var X={mode:"hidden",children:b.children};return(M&1)===0&&i.child!==j?(b=i.child,b.childLanes=0,b.pendingProps=X,i.deletions=null):(b=oo(j,X),b.subtreeFlags=j.subtreeFlags&14680064),G!==null?$=oo(G,$):($=qo($,M,f,null),$.flags|=2),$.return=i,b.return=i,b.sibling=$,i.child=b,b=$,$=i.child,M=o.child.memoizedState,M=M===null?Ym(f):{baseLanes:M.baseLanes|f,cachePool:null,transitions:M.transitions},$.memoizedState=M,$.childLanes=o.childLanes&~f,i.memoizedState=Km,b}return $=o.child,o=$.sibling,b=oo($,{mode:"visible",children:b.children}),(i.mode&1)===0&&(b.lanes=f),b.return=i,b.sibling=null,o!==null&&(f=i.deletions,f===null?(i.deletions=[o],i.flags|=16):f.push(o)),i.child=b,i.memoizedState=null,b}function Xm(o,i){return i=Ou({mode:"visible",children:i},o.mode,0,null),i.return=o,o.child=i}function vu(o,i,f,b){return b!==null&&jm(b),Ua(i,o.child,null,f),o=Xm(i,i.pendingProps.children),o.flags|=2,i.memoizedState=null,o}function o$(o,i,f,b,j,$,M){if(f)return i.flags&256?(i.flags&=-257,b=Bm(Error(s(422))),vu(o,i,M,b)):i.memoizedState!==null?(i.child=o.child,i.flags|=128,null):($=b.fallback,j=i.mode,b=Ou({mode:"visible",children:b.children},j,0,null),$=qo($,j,M,null),$.flags|=2,b.return=i,$.return=i,b.sibling=$,i.child=b,(i.mode&1)!==0&&Ua(i,o.child,null,M),i.child.memoizedState=Ym(M),i.memoizedState=Km,$);if((i.mode&1)===0)return vu(o,i,M,null);if(j.data==="$!"){if(b=j.nextSibling&&j.nextSibling.dataset,b)var G=b.dgst;return b=G,$=Error(s(419)),b=Bm($,b,void 0),vu(o,i,M,b)}if(G=(M&o.childLanes)!==0,Gn||G){if(b=on,b!==null){switch(M&-M){case 4:j=2;break;case 16:j=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:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(b.suspendedLanes|M))!==0?0:j,j!==0&&j!==$.retryLane&&($.retryLane=j,kr(o,j),Bs(b,o,j,-1))}return fp(),b=Bm(Error(s(421))),vu(o,i,M,b)}return j.data==="$?"?(i.flags|=128,i.child=o.child,i=y$.bind(null,o),j._reactRetry=i,null):(o=$.treeContext,rs=Kr(j.nextSibling),ss=i,Tt=!0,Fs=null,o!==null&&(xs[ys++]=vr,xs[ys++]=wr,xs[ys++]=Io,vr=o.id,wr=o.overflow,Io=i),i=Xm(i,b.children),i.flags|=4096,i)}function Ib(o,i,f){o.lanes|=i;var b=o.alternate;b!==null&&(b.lanes|=i),$m(o.return,i,f)}function Qm(o,i,f,b,j){var $=o.memoizedState;$===null?o.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:b,tail:f,tailMode:j}:($.isBackwards=i,$.rendering=null,$.renderingStartTime=0,$.last=b,$.tail=f,$.tailMode=j)}function zb(o,i,f){var b=i.pendingProps,j=b.revealOrder,$=b.tail;if(Rn(o,i,b.children,f),b=Ot.current,(b&2)!==0)b=b&1|2,i.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=i.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&Ib(o,f,i);else if(o.tag===19)Ib(o,f,i);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break e;for(;o.sibling===null;){if(o.return===null||o.return===i)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}b&=1}if(_t(Ot,b),(i.mode&1)===0)i.memoizedState=null;else switch(j){case"forwards":for(f=i.child,j=null;f!==null;)o=f.alternate,o!==null&&mu(o)===null&&(j=f),f=f.sibling;f=j,f===null?(j=i.child,i.child=null):(j=f.sibling,f.sibling=null),Qm(i,!1,j,f,$);break;case"backwards":for(f=null,j=i.child,i.child=null;j!==null;){if(o=j.alternate,o!==null&&mu(o)===null){i.child=j;break}o=j.sibling,j.sibling=f,f=j,j=o}Qm(i,!0,f,null,$);break;case"together":Qm(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function wu(o,i){(i.mode&1)===0&&o!==null&&(o.alternate=null,i.alternate=null,i.flags|=2)}function Nr(o,i,f){if(o!==null&&(i.dependencies=o.dependencies),Wo|=i.lanes,(f&i.childLanes)===0)return null;if(o!==null&&i.child!==o.child)throw Error(s(153));if(i.child!==null){for(o=i.child,f=oo(o,o.pendingProps),i.child=f,f.return=i;o.sibling!==null;)o=o.sibling,f=f.sibling=oo(o,o.pendingProps),f.return=i;f.sibling=null}return i.child}function a$(o,i,f){switch(i.tag){case 3:Mb(i),Fa();break;case 5:Jy(i);break;case 1:Bn(i.type)&&su(i);break;case 4:Tm(i,i.stateNode.containerInfo);break;case 10:var b=i.type._context,j=i.memoizedProps.value;_t(cu,b._currentValue),b._currentValue=j;break;case 13:if(b=i.memoizedState,b!==null)return b.dehydrated!==null?(_t(Ot,Ot.current&1),i.flags|=128,null):(f&i.child.childLanes)!==0?Pb(o,i,f):(_t(Ot,Ot.current&1),o=Nr(o,i,f),o!==null?o.sibling:null);_t(Ot,Ot.current&1);break;case 19:if(b=(f&i.childLanes)!==0,(o.flags&128)!==0){if(b)return zb(o,i,f);i.flags|=128}if(j=i.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),_t(Ot,Ot.current),b)break;return null;case 22:case 23:return i.lanes=0,Rb(o,i,f)}return Nr(o,i,f)}var Db,Jm,Fb,Ub;Db=function(o,i){for(var f=i.child;f!==null;){if(f.tag===5||f.tag===6)o.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===i)break;for(;f.sibling===null;){if(f.return===null||f.return===i)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},Jm=function(){},Fb=function(o,i,f,b){var j=o.memoizedProps;if(j!==b){o=i.stateNode,Fo(nr.current);var $=null;switch(f){case"input":j=Y(o,j),b=Y(o,b),$=[];break;case"select":j=V({},j,{value:void 0}),b=V({},b,{value:void 0}),$=[];break;case"textarea":j=Ce(o,j),b=Ce(o,b),$=[];break;default:typeof j.onClick!="function"&&typeof b.onClick=="function"&&(o.onclick=eu)}Ft(f,b);var M;f=null;for(le in j)if(!b.hasOwnProperty(le)&&j.hasOwnProperty(le)&&j[le]!=null)if(le==="style"){var G=j[le];for(M in G)G.hasOwnProperty(M)&&(f||(f={}),f[M]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(a.hasOwnProperty(le)?$||($=[]):($=$||[]).push(le,null));for(le in b){var X=b[le];if(G=j!=null?j[le]:void 0,b.hasOwnProperty(le)&&X!==G&&(X!=null||G!=null))if(le==="style")if(G){for(M in G)!G.hasOwnProperty(M)||X&&X.hasOwnProperty(M)||(f||(f={}),f[M]="");for(M in X)X.hasOwnProperty(M)&&G[M]!==X[M]&&(f||(f={}),f[M]=X[M])}else f||($||($=[]),$.push(le,f)),f=X;else le==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,G=G?G.__html:void 0,X!=null&&G!==X&&($=$||[]).push(le,X)):le==="children"?typeof X!="string"&&typeof X!="number"||($=$||[]).push(le,""+X):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(a.hasOwnProperty(le)?(X!=null&&le==="onScroll"&&$t("scroll",o),$||G===X||($=[])):($=$||[]).push(le,X))}f&&($=$||[]).push("style",f);var le=$;(i.updateQueue=le)&&(i.flags|=4)}},Ub=function(o,i,f,b){f!==b&&(i.flags|=4)};function fl(o,i){if(!Tt)switch(o.tailMode){case"hidden":i=o.tail;for(var f=null;i!==null;)i.alternate!==null&&(f=i),i=i.sibling;f===null?o.tail=null:f.sibling=null;break;case"collapsed":f=o.tail;for(var b=null;f!==null;)f.alternate!==null&&(b=f),f=f.sibling;b===null?i||o.tail===null?o.tail=null:o.tail.sibling=null:b.sibling=null}}function jn(o){var i=o.alternate!==null&&o.alternate.child===o.child,f=0,b=0;if(i)for(var j=o.child;j!==null;)f|=j.lanes|j.childLanes,b|=j.subtreeFlags&14680064,b|=j.flags&14680064,j.return=o,j=j.sibling;else for(j=o.child;j!==null;)f|=j.lanes|j.childLanes,b|=j.subtreeFlags,b|=j.flags,j.return=o,j=j.sibling;return o.subtreeFlags|=b,o.childLanes=f,i}function i$(o,i,f){var b=i.pendingProps;switch(vm(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jn(i),null;case 1:return Bn(i.type)&&nu(),jn(i),null;case 3:return b=i.stateNode,Ba(),Et(Hn),Et(wn),Om(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(o===null||o.child===null)&&(iu(i)?i.flags|=4:o===null||o.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Fs!==null&&(cp(Fs),Fs=null))),Jm(o,i),jn(i),null;case 5:Rm(i);var j=Fo(il.current);if(f=i.type,o!==null&&i.stateNode!=null)Fb(o,i,f,b,j),o.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!b){if(i.stateNode===null)throw Error(s(166));return jn(i),null}if(o=Fo(nr.current),iu(i)){b=i.stateNode,f=i.type;var $=i.memoizedProps;switch(b[tr]=i,b[nl]=$,o=(i.mode&1)!==0,f){case"dialog":$t("cancel",b),$t("close",b);break;case"iframe":case"object":case"embed":$t("load",b);break;case"video":case"audio":for(j=0;j<Zi.length;j++)$t(Zi[j],b);break;case"source":$t("error",b);break;case"img":case"image":case"link":$t("error",b),$t("load",b);break;case"details":$t("toggle",b);break;case"input":_e(b,$),$t("invalid",b);break;case"select":b._wrapperState={wasMultiple:!!$.multiple},$t("invalid",b);break;case"textarea":Ge(b,$),$t("invalid",b)}Ft(f,$),j=null;for(var M in $)if($.hasOwnProperty(M)){var G=$[M];M==="children"?typeof G=="string"?b.textContent!==G&&($.suppressHydrationWarning!==!0&&Zc(b.textContent,G,o),j=["children",G]):typeof G=="number"&&b.textContent!==""+G&&($.suppressHydrationWarning!==!0&&Zc(b.textContent,G,o),j=["children",""+G]):a.hasOwnProperty(M)&&G!=null&&M==="onScroll"&&$t("scroll",b)}switch(f){case"input":ge(b),xt(b,$,!0);break;case"textarea":ge(b),We(b);break;case"select":case"option":break;default:typeof $.onClick=="function"&&(b.onclick=eu)}b=j,i.updateQueue=b,b!==null&&(i.flags|=4)}else{M=j.nodeType===9?j:j.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=rt(f)),o==="http://www.w3.org/1999/xhtml"?f==="script"?(o=M.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof b.is=="string"?o=M.createElement(f,{is:b.is}):(o=M.createElement(f),f==="select"&&(M=o,b.multiple?M.multiple=!0:b.size&&(M.size=b.size))):o=M.createElementNS(o,f),o[tr]=i,o[nl]=b,Db(o,i,!1,!1),i.stateNode=o;e:{switch(M=Qn(f,b),f){case"dialog":$t("cancel",o),$t("close",o),j=b;break;case"iframe":case"object":case"embed":$t("load",o),j=b;break;case"video":case"audio":for(j=0;j<Zi.length;j++)$t(Zi[j],o);j=b;break;case"source":$t("error",o),j=b;break;case"img":case"image":case"link":$t("error",o),$t("load",o),j=b;break;case"details":$t("toggle",o),j=b;break;case"input":_e(o,b),j=Y(o,b),$t("invalid",o);break;case"option":j=b;break;case"select":o._wrapperState={wasMultiple:!!b.multiple},j=V({},b,{value:void 0}),$t("invalid",o);break;case"textarea":Ge(o,b),j=Ce(o,b),$t("invalid",o);break;default:j=b}Ft(f,j),G=j;for($ in G)if(G.hasOwnProperty($)){var X=G[$];$==="style"?lt(o,X):$==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&sn(o,X)):$==="children"?typeof X=="string"?(f!=="textarea"||X!=="")&&me(o,X):typeof X=="number"&&me(o,""+X):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(a.hasOwnProperty($)?X!=null&&$==="onScroll"&&$t("scroll",o):X!=null&&_(o,$,X,M))}switch(f){case"input":ge(o),xt(o,b,!1);break;case"textarea":ge(o),We(o);break;case"option":b.value!=null&&o.setAttribute("value",""+fe(b.value));break;case"select":o.multiple=!!b.multiple,$=b.value,$!=null?Ae(o,!!b.multiple,$,!1):b.defaultValue!=null&&Ae(o,!!b.multiple,b.defaultValue,!0);break;default:typeof j.onClick=="function"&&(o.onclick=eu)}switch(f){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}}b&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return jn(i),null;case 6:if(o&&i.stateNode!=null)Ub(o,i,o.memoizedProps,b);else{if(typeof b!="string"&&i.stateNode===null)throw Error(s(166));if(f=Fo(il.current),Fo(nr.current),iu(i)){if(b=i.stateNode,f=i.memoizedProps,b[tr]=i,($=b.nodeValue!==f)&&(o=ss,o!==null))switch(o.tag){case 3:Zc(b.nodeValue,f,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&Zc(b.nodeValue,f,(o.mode&1)!==0)}$&&(i.flags|=4)}else b=(f.nodeType===9?f:f.ownerDocument).createTextNode(b),b[tr]=i,i.stateNode=b}return jn(i),null;case 13:if(Et(Ot),b=i.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(Tt&&rs!==null&&(i.mode&1)!==0&&(i.flags&128)===0)By(),Fa(),i.flags|=98560,$=!1;else if($=iu(i),b!==null&&b.dehydrated!==null){if(o===null){if(!$)throw Error(s(318));if($=i.memoizedState,$=$!==null?$.dehydrated:null,!$)throw Error(s(317));$[tr]=i}else Fa(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;jn(i),$=!1}else Fs!==null&&(cp(Fs),Fs=null),$=!0;if(!$)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=f,i):(b=b!==null,b!==(o!==null&&o.memoizedState!==null)&&b&&(i.child.flags|=8192,(i.mode&1)!==0&&(o===null||(Ot.current&1)!==0?Zt===0&&(Zt=3):fp())),i.updateQueue!==null&&(i.flags|=4),jn(i),null);case 4:return Ba(),Jm(o,i),o===null&&el(i.stateNode.containerInfo),jn(i),null;case 10:return _m(i.type._context),jn(i),null;case 17:return Bn(i.type)&&nu(),jn(i),null;case 19:if(Et(Ot),$=i.memoizedState,$===null)return jn(i),null;if(b=(i.flags&128)!==0,M=$.rendering,M===null)if(b)fl($,!1);else{if(Zt!==0||o!==null&&(o.flags&128)!==0)for(o=i.child;o!==null;){if(M=mu(o),M!==null){for(i.flags|=128,fl($,!1),b=M.updateQueue,b!==null&&(i.updateQueue=b,i.flags|=4),i.subtreeFlags=0,b=f,f=i.child;f!==null;)$=f,o=b,$.flags&=14680066,M=$.alternate,M===null?($.childLanes=0,$.lanes=o,$.child=null,$.subtreeFlags=0,$.memoizedProps=null,$.memoizedState=null,$.updateQueue=null,$.dependencies=null,$.stateNode=null):($.childLanes=M.childLanes,$.lanes=M.lanes,$.child=M.child,$.subtreeFlags=0,$.deletions=null,$.memoizedProps=M.memoizedProps,$.memoizedState=M.memoizedState,$.updateQueue=M.updateQueue,$.type=M.type,o=M.dependencies,$.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),f=f.sibling;return _t(Ot,Ot.current&1|2),i.child}o=o.sibling}$.tail!==null&&nt()>Ka&&(i.flags|=128,b=!0,fl($,!1),i.lanes=4194304)}else{if(!b)if(o=mu(M),o!==null){if(i.flags|=128,b=!0,f=o.updateQueue,f!==null&&(i.updateQueue=f,i.flags|=4),fl($,!0),$.tail===null&&$.tailMode==="hidden"&&!M.alternate&&!Tt)return jn(i),null}else 2*nt()-$.renderingStartTime>Ka&&f!==1073741824&&(i.flags|=128,b=!0,fl($,!1),i.lanes=4194304);$.isBackwards?(M.sibling=i.child,i.child=M):(f=$.last,f!==null?f.sibling=M:i.child=M,$.last=M)}return $.tail!==null?(i=$.tail,$.rendering=i,$.tail=i.sibling,$.renderingStartTime=nt(),i.sibling=null,f=Ot.current,_t(Ot,b?f&1|2:f&1),i):(jn(i),null);case 22:case 23:return dp(),b=i.memoizedState!==null,o!==null&&o.memoizedState!==null!==b&&(i.flags|=8192),b&&(i.mode&1)!==0?(os&1073741824)!==0&&(jn(i),i.subtreeFlags&6&&(i.flags|=8192)):jn(i),null;case 24:return null;case 25:return null}throw Error(s(156,i.tag))}function l$(o,i){switch(vm(i),i.tag){case 1:return Bn(i.type)&&nu(),o=i.flags,o&65536?(i.flags=o&-65537|128,i):null;case 3:return Ba(),Et(Hn),Et(wn),Om(),o=i.flags,(o&65536)!==0&&(o&128)===0?(i.flags=o&-65537|128,i):null;case 5:return Rm(i),null;case 13:if(Et(Ot),o=i.memoizedState,o!==null&&o.dehydrated!==null){if(i.alternate===null)throw Error(s(340));Fa()}return o=i.flags,o&65536?(i.flags=o&-65537|128,i):null;case 19:return Et(Ot),null;case 4:return Ba(),null;case 10:return _m(i.type._context),null;case 22:case 23:return dp(),null;case 24:return null;default:return null}}var ku=!1,Nn=!1,c$=typeof WeakSet=="function"?WeakSet:Set,Le=null;function qa(o,i){var f=o.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(b){It(o,i,b)}else f.current=null}function Zm(o,i,f){try{f()}catch(b){It(o,i,b)}}var Wb=!1;function u$(o,i){if(dm=Wc,o=vy(),sm(o)){if("selectionStart"in o)var f={start:o.selectionStart,end:o.selectionEnd};else e:{f=(f=o.ownerDocument)&&f.defaultView||window;var b=f.getSelection&&f.getSelection();if(b&&b.rangeCount!==0){f=b.anchorNode;var j=b.anchorOffset,$=b.focusNode;b=b.focusOffset;try{f.nodeType,$.nodeType}catch{f=null;break e}var M=0,G=-1,X=-1,le=0,xe=0,be=o,he=null;t:for(;;){for(var Re;be!==f||j!==0&&be.nodeType!==3||(G=M+j),be!==$||b!==0&&be.nodeType!==3||(X=M+b),be.nodeType===3&&(M+=be.nodeValue.length),(Re=be.firstChild)!==null;)he=be,be=Re;for(;;){if(be===o)break t;if(he===f&&++le===j&&(G=M),he===$&&++xe===b&&(X=M),(Re=be.nextSibling)!==null)break;be=he,he=be.parentNode}be=Re}f=G===-1||X===-1?null:{start:G,end:X}}else f=null}f=f||{start:0,end:0}}else f=null;for(fm={focusedElem:o,selectionRange:f},Wc=!1,Le=i;Le!==null;)if(i=Le,o=i.child,(i.subtreeFlags&1028)!==0&&o!==null)o.return=i,Le=o;else for(;Le!==null;){i=Le;try{var Ie=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Ie!==null){var De=Ie.memoizedProps,Ht=Ie.memoizedState,re=i.stateNode,ne=re.getSnapshotBeforeUpdate(i.elementType===i.type?De:Us(i.type,De),Ht);re.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var oe=i.stateNode.containerInfo;oe.nodeType===1?oe.textContent="":oe.nodeType===9&&oe.documentElement&&oe.removeChild(oe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(ke){It(i,i.return,ke)}if(o=i.sibling,o!==null){o.return=i.return,Le=o;break}Le=i.return}return Ie=Wb,Wb=!1,Ie}function ml(o,i,f){var b=i.updateQueue;if(b=b!==null?b.lastEffect:null,b!==null){var j=b=b.next;do{if((j.tag&o)===o){var $=j.destroy;j.destroy=void 0,$!==void 0&&Zm(i,f,$)}j=j.next}while(j!==b)}}function ju(o,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var f=i=i.next;do{if((f.tag&o)===o){var b=f.create;f.destroy=b()}f=f.next}while(f!==i)}}function ep(o){var i=o.ref;if(i!==null){var f=o.stateNode;switch(o.tag){case 5:o=f;break;default:o=f}typeof i=="function"?i(o):i.current=o}}function Hb(o){var i=o.alternate;i!==null&&(o.alternate=null,Hb(i)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(i=o.stateNode,i!==null&&(delete i[tr],delete i[nl],delete i[gm],delete i[q_],delete i[V_])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function Bb(o){return o.tag===5||o.tag===3||o.tag===4}function Gb(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||Bb(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function tp(o,i,f){var b=o.tag;if(b===5||b===6)o=o.stateNode,i?f.nodeType===8?f.parentNode.insertBefore(o,i):f.insertBefore(o,i):(f.nodeType===8?(i=f.parentNode,i.insertBefore(o,f)):(i=f,i.appendChild(o)),f=f._reactRootContainer,f!=null||i.onclick!==null||(i.onclick=eu));else if(b!==4&&(o=o.child,o!==null))for(tp(o,i,f),o=o.sibling;o!==null;)tp(o,i,f),o=o.sibling}function np(o,i,f){var b=o.tag;if(b===5||b===6)o=o.stateNode,i?f.insertBefore(o,i):f.appendChild(o);else if(b!==4&&(o=o.child,o!==null))for(np(o,i,f),o=o.sibling;o!==null;)np(o,i,f),o=o.sibling}var pn=null,Ws=!1;function eo(o,i,f){for(f=f.child;f!==null;)qb(o,i,f),f=f.sibling}function qb(o,i,f){if(ts&&typeof ts.onCommitFiberUnmount=="function")try{ts.onCommitFiberUnmount(Ro,f)}catch{}switch(f.tag){case 5:Nn||qa(f,i);case 6:var b=pn,j=Ws;pn=null,eo(o,i,f),pn=b,Ws=j,pn!==null&&(Ws?(o=pn,f=f.stateNode,o.nodeType===8?o.parentNode.removeChild(f):o.removeChild(f)):pn.removeChild(f.stateNode));break;case 18:pn!==null&&(Ws?(o=pn,f=f.stateNode,o.nodeType===8?hm(o.parentNode,f):o.nodeType===1&&hm(o,f),Gi(o)):hm(pn,f.stateNode));break;case 4:b=pn,j=Ws,pn=f.stateNode.containerInfo,Ws=!0,eo(o,i,f),pn=b,Ws=j;break;case 0:case 11:case 14:case 15:if(!Nn&&(b=f.updateQueue,b!==null&&(b=b.lastEffect,b!==null))){j=b=b.next;do{var $=j,M=$.destroy;$=$.tag,M!==void 0&&(($&2)!==0||($&4)!==0)&&Zm(f,i,M),j=j.next}while(j!==b)}eo(o,i,f);break;case 1:if(!Nn&&(qa(f,i),b=f.stateNode,typeof b.componentWillUnmount=="function"))try{b.props=f.memoizedProps,b.state=f.memoizedState,b.componentWillUnmount()}catch(G){It(f,i,G)}eo(o,i,f);break;case 21:eo(o,i,f);break;case 22:f.mode&1?(Nn=(b=Nn)||f.memoizedState!==null,eo(o,i,f),Nn=b):eo(o,i,f);break;default:eo(o,i,f)}}function Vb(o){var i=o.updateQueue;if(i!==null){o.updateQueue=null;var f=o.stateNode;f===null&&(f=o.stateNode=new c$),i.forEach(function(b){var j=b$.bind(null,o,b);f.has(b)||(f.add(b),b.then(j,j))})}}function Hs(o,i){var f=i.deletions;if(f!==null)for(var b=0;b<f.length;b++){var j=f[b];try{var $=o,M=i,G=M;e:for(;G!==null;){switch(G.tag){case 5:pn=G.stateNode,Ws=!1;break e;case 3:pn=G.stateNode.containerInfo,Ws=!0;break e;case 4:pn=G.stateNode.containerInfo,Ws=!0;break e}G=G.return}if(pn===null)throw Error(s(160));qb($,M,j),pn=null,Ws=!1;var X=j.alternate;X!==null&&(X.return=null),j.return=null}catch(le){It(j,i,le)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)Kb(i,o),i=i.sibling}function Kb(o,i){var f=o.alternate,b=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(Hs(i,o),rr(o),b&4){try{ml(3,o,o.return),ju(3,o)}catch(De){It(o,o.return,De)}try{ml(5,o,o.return)}catch(De){It(o,o.return,De)}}break;case 1:Hs(i,o),rr(o),b&512&&f!==null&&qa(f,f.return);break;case 5:if(Hs(i,o),rr(o),b&512&&f!==null&&qa(f,f.return),o.flags&32){var j=o.stateNode;try{me(j,"")}catch(De){It(o,o.return,De)}}if(b&4&&(j=o.stateNode,j!=null)){var $=o.memoizedProps,M=f!==null?f.memoizedProps:$,G=o.type,X=o.updateQueue;if(o.updateQueue=null,X!==null)try{G==="input"&&$.type==="radio"&&$.name!=null&&Ze(j,$),Qn(G,M);var le=Qn(G,$);for(M=0;M<X.length;M+=2){var xe=X[M],be=X[M+1];xe==="style"?lt(j,be):xe==="dangerouslySetInnerHTML"?sn(j,be):xe==="children"?me(j,be):_(j,xe,be,le)}switch(G){case"input":Je(j,$);break;case"textarea":kt(j,$);break;case"select":var he=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!$.multiple;var Re=$.value;Re!=null?Ae(j,!!$.multiple,Re,!1):he!==!!$.multiple&&($.defaultValue!=null?Ae(j,!!$.multiple,$.defaultValue,!0):Ae(j,!!$.multiple,$.multiple?[]:"",!1))}j[nl]=$}catch(De){It(o,o.return,De)}}break;case 6:if(Hs(i,o),rr(o),b&4){if(o.stateNode===null)throw Error(s(162));j=o.stateNode,$=o.memoizedProps;try{j.nodeValue=$}catch(De){It(o,o.return,De)}}break;case 3:if(Hs(i,o),rr(o),b&4&&f!==null&&f.memoizedState.isDehydrated)try{Gi(i.containerInfo)}catch(De){It(o,o.return,De)}break;case 4:Hs(i,o),rr(o);break;case 13:Hs(i,o),rr(o),j=o.child,j.flags&8192&&($=j.memoizedState!==null,j.stateNode.isHidden=$,!$||j.alternate!==null&&j.alternate.memoizedState!==null||(op=nt())),b&4&&Vb(o);break;case 22:if(xe=f!==null&&f.memoizedState!==null,o.mode&1?(Nn=(le=Nn)||xe,Hs(i,o),Nn=le):Hs(i,o),rr(o),b&8192){if(le=o.memoizedState!==null,(o.stateNode.isHidden=le)&&!xe&&(o.mode&1)!==0)for(Le=o,xe=o.child;xe!==null;){for(be=Le=xe;Le!==null;){switch(he=Le,Re=he.child,he.tag){case 0:case 11:case 14:case 15:ml(4,he,he.return);break;case 1:qa(he,he.return);var Ie=he.stateNode;if(typeof Ie.componentWillUnmount=="function"){b=he,f=he.return;try{i=b,Ie.props=i.memoizedProps,Ie.state=i.memoizedState,Ie.componentWillUnmount()}catch(De){It(b,f,De)}}break;case 5:qa(he,he.return);break;case 22:if(he.memoizedState!==null){Qb(be);continue}}Re!==null?(Re.return=he,Le=Re):Qb(be)}xe=xe.sibling}e:for(xe=null,be=o;;){if(be.tag===5){if(xe===null){xe=be;try{j=be.stateNode,le?($=j.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none"):(G=be.stateNode,X=be.memoizedProps.style,M=X!=null&&X.hasOwnProperty("display")?X.display:null,G.style.display=Fe("display",M))}catch(De){It(o,o.return,De)}}}else if(be.tag===6){if(xe===null)try{be.stateNode.nodeValue=le?"":be.memoizedProps}catch(De){It(o,o.return,De)}}else if((be.tag!==22&&be.tag!==23||be.memoizedState===null||be===o)&&be.child!==null){be.child.return=be,be=be.child;continue}if(be===o)break e;for(;be.sibling===null;){if(be.return===null||be.return===o)break e;xe===be&&(xe=null),be=be.return}xe===be&&(xe=null),be.sibling.return=be.return,be=be.sibling}}break;case 19:Hs(i,o),rr(o),b&4&&Vb(o);break;case 21:break;default:Hs(i,o),rr(o)}}function rr(o){var i=o.flags;if(i&2){try{e:{for(var f=o.return;f!==null;){if(Bb(f)){var b=f;break e}f=f.return}throw Error(s(160))}switch(b.tag){case 5:var j=b.stateNode;b.flags&32&&(me(j,""),b.flags&=-33);var $=Gb(o);np(o,$,j);break;case 3:case 4:var M=b.stateNode.containerInfo,G=Gb(o);tp(o,G,M);break;default:throw Error(s(161))}}catch(X){It(o,o.return,X)}o.flags&=-3}i&4096&&(o.flags&=-4097)}function d$(o,i,f){Le=o,Yb(o)}function Yb(o,i,f){for(var b=(o.mode&1)!==0;Le!==null;){var j=Le,$=j.child;if(j.tag===22&&b){var M=j.memoizedState!==null||ku;if(!M){var G=j.alternate,X=G!==null&&G.memoizedState!==null||Nn;G=ku;var le=Nn;if(ku=M,(Nn=X)&&!le)for(Le=j;Le!==null;)M=Le,X=M.child,M.tag===22&&M.memoizedState!==null?Jb(j):X!==null?(X.return=M,Le=X):Jb(j);for(;$!==null;)Le=$,Yb($),$=$.sibling;Le=j,ku=G,Nn=le}Xb(o)}else(j.subtreeFlags&8772)!==0&&$!==null?($.return=j,Le=$):Xb(o)}}function Xb(o){for(;Le!==null;){var i=Le;if((i.flags&8772)!==0){var f=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:Nn||ju(5,i);break;case 1:var b=i.stateNode;if(i.flags&4&&!Nn)if(f===null)b.componentDidMount();else{var j=i.elementType===i.type?f.memoizedProps:Us(i.type,f.memoizedProps);b.componentDidUpdate(j,f.memoizedState,b.__reactInternalSnapshotBeforeUpdate)}var $=i.updateQueue;$!==null&&Qy(i,$,b);break;case 3:var M=i.updateQueue;if(M!==null){if(f=null,i.child!==null)switch(i.child.tag){case 5:f=i.child.stateNode;break;case 1:f=i.child.stateNode}Qy(i,M,f)}break;case 5:var G=i.stateNode;if(f===null&&i.flags&4){f=G;var X=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&f.focus();break;case"img":X.src&&(f.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var le=i.alternate;if(le!==null){var xe=le.memoizedState;if(xe!==null){var be=xe.dehydrated;be!==null&&Gi(be)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Nn||i.flags&512&&ep(i)}catch(he){It(i,i.return,he)}}if(i===o){Le=null;break}if(f=i.sibling,f!==null){f.return=i.return,Le=f;break}Le=i.return}}function Qb(o){for(;Le!==null;){var i=Le;if(i===o){Le=null;break}var f=i.sibling;if(f!==null){f.return=i.return,Le=f;break}Le=i.return}}function Jb(o){for(;Le!==null;){var i=Le;try{switch(i.tag){case 0:case 11:case 15:var f=i.return;try{ju(4,i)}catch(X){It(i,f,X)}break;case 1:var b=i.stateNode;if(typeof b.componentDidMount=="function"){var j=i.return;try{b.componentDidMount()}catch(X){It(i,j,X)}}var $=i.return;try{ep(i)}catch(X){It(i,$,X)}break;case 5:var M=i.return;try{ep(i)}catch(X){It(i,M,X)}}}catch(X){It(i,i.return,X)}if(i===o){Le=null;break}var G=i.sibling;if(G!==null){G.return=i.return,Le=G;break}Le=i.return}}var f$=Math.ceil,Nu=S.ReactCurrentDispatcher,sp=S.ReactCurrentOwner,ws=S.ReactCurrentBatchConfig,mt=0,on=null,qt=null,hn=0,os=0,Va=Yr(0),Zt=0,pl=null,Wo=0,Su=0,rp=0,hl=null,qn=null,op=0,Ka=1/0,Sr=null,_u=!1,ap=null,to=null,$u=!1,no=null,Eu=0,gl=0,ip=null,Cu=-1,Tu=0;function An(){return(mt&6)!==0?nt():Cu!==-1?Cu:Cu=nt()}function so(o){return(o.mode&1)===0?1:(mt&2)!==0&&hn!==0?hn&-hn:Y_.transition!==null?(Tu===0&&(Tu=ze()),Tu):(o=st,o!==0||(o=window.event,o=o===void 0?16:ey(o.type)),o)}function Bs(o,i,f,b){if(50<gl)throw gl=0,ip=null,Error(s(185));at(o,f,b),((mt&2)===0||o!==on)&&(o===on&&((mt&2)===0&&(Su|=f),Zt===4&&ro(o,hn)),Vn(o,b),f===1&&mt===0&&(i.mode&1)===0&&(Ka=nt()+500,ru&&Qr()))}function Vn(o,i){var f=o.callbackNode;we(o,i);var b=Mo(o,o===on?hn:0);if(b===0)f!==null&&Me(f),o.callbackNode=null,o.callbackPriority=0;else if(i=b&-b,o.callbackPriority!==i){if(f!=null&&Me(f),i===1)o.tag===0?K_(ev.bind(null,o)):Dy(ev.bind(null,o)),B_(function(){(mt&6)===0&&Qr()}),f=null;else{switch(Fc(b)){case 1:f=dn;break;case 4:f=Is;break;case 16:f=At;break;case 536870912:f=Dr;break;default:f=At}f=lv(f,Zb.bind(null,o))}o.callbackPriority=i,o.callbackNode=f}}function Zb(o,i){if(Cu=-1,Tu=0,(mt&6)!==0)throw Error(s(327));var f=o.callbackNode;if(Ya()&&o.callbackNode!==f)return null;var b=Mo(o,o===on?hn:0);if(b===0)return null;if((b&30)!==0||(b&o.expiredLanes)!==0||i)i=Ru(o,b);else{i=b;var j=mt;mt|=2;var $=nv();(on!==o||hn!==i)&&(Sr=null,Ka=nt()+500,Bo(o,i));do try{h$();break}catch(G){tv(o,G)}while(!0);Sm(),Nu.current=$,mt=j,qt!==null?i=0:(on=null,hn=0,i=Zt)}if(i!==0){if(i===2&&(j=je(o),j!==0&&(b=j,i=lp(o,j))),i===1)throw f=pl,Bo(o,0),ro(o,b),Vn(o,nt()),f;if(i===6)ro(o,b);else{if(j=o.current.alternate,(b&30)===0&&!m$(j)&&(i=Ru(o,b),i===2&&($=je(o),$!==0&&(b=$,i=lp(o,$))),i===1))throw f=pl,Bo(o,0),ro(o,b),Vn(o,nt()),f;switch(o.finishedWork=j,o.finishedLanes=b,i){case 0:case 1:throw Error(s(345));case 2:Go(o,qn,Sr);break;case 3:if(ro(o,b),(b&130023424)===b&&(i=op+500-nt(),10<i)){if(Mo(o,0)!==0)break;if(j=o.suspendedLanes,(j&b)!==b){An(),o.pingedLanes|=o.suspendedLanes&j;break}o.timeoutHandle=pm(Go.bind(null,o,qn,Sr),i);break}Go(o,qn,Sr);break;case 4:if(ro(o,b),(b&4194240)===b)break;for(i=o.eventTimes,j=-1;0<b;){var M=31-Wn(b);$=1<<M,M=i[M],M>j&&(j=M),b&=~$}if(b=j,b=nt()-b,b=(120>b?120:480>b?480:1080>b?1080:1920>b?1920:3e3>b?3e3:4320>b?4320:1960*f$(b/1960))-b,10<b){o.timeoutHandle=pm(Go.bind(null,o,qn,Sr),b);break}Go(o,qn,Sr);break;case 5:Go(o,qn,Sr);break;default:throw Error(s(329))}}}return Vn(o,nt()),o.callbackNode===f?Zb.bind(null,o):null}function lp(o,i){var f=hl;return o.current.memoizedState.isDehydrated&&(Bo(o,i).flags|=256),o=Ru(o,i),o!==2&&(i=qn,qn=f,i!==null&&cp(i)),o}function cp(o){qn===null?qn=o:qn.push.apply(qn,o)}function m$(o){for(var i=o;;){if(i.flags&16384){var f=i.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var b=0;b<f.length;b++){var j=f[b],$=j.getSnapshot;j=j.value;try{if(!Ds($(),j))return!1}catch{return!1}}}if(f=i.child,i.subtreeFlags&16384&&f!==null)f.return=i,i=f;else{if(i===o)break;for(;i.sibling===null;){if(i.return===null||i.return===o)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function ro(o,i){for(i&=~rp,i&=~Su,o.suspendedLanes|=i,o.pingedLanes&=~i,o=o.expirationTimes;0<i;){var f=31-Wn(i),b=1<<f;o[f]=-1,i&=~b}}function ev(o){if((mt&6)!==0)throw Error(s(327));Ya();var i=Mo(o,0);if((i&1)===0)return Vn(o,nt()),null;var f=Ru(o,i);if(o.tag!==0&&f===2){var b=je(o);b!==0&&(i=b,f=lp(o,b))}if(f===1)throw f=pl,Bo(o,0),ro(o,i),Vn(o,nt()),f;if(f===6)throw Error(s(345));return o.finishedWork=o.current.alternate,o.finishedLanes=i,Go(o,qn,Sr),Vn(o,nt()),null}function up(o,i){var f=mt;mt|=1;try{return o(i)}finally{mt=f,mt===0&&(Ka=nt()+500,ru&&Qr())}}function Ho(o){no!==null&&no.tag===0&&(mt&6)===0&&Ya();var i=mt;mt|=1;var f=ws.transition,b=st;try{if(ws.transition=null,st=1,o)return o()}finally{st=b,ws.transition=f,mt=i,(mt&6)===0&&Qr()}}function dp(){os=Va.current,Et(Va)}function Bo(o,i){o.finishedWork=null,o.finishedLanes=0;var f=o.timeoutHandle;if(f!==-1&&(o.timeoutHandle=-1,H_(f)),qt!==null)for(f=qt.return;f!==null;){var b=f;switch(vm(b),b.tag){case 1:b=b.type.childContextTypes,b!=null&&nu();break;case 3:Ba(),Et(Hn),Et(wn),Om();break;case 5:Rm(b);break;case 4:Ba();break;case 13:Et(Ot);break;case 19:Et(Ot);break;case 10:_m(b.type._context);break;case 22:case 23:dp()}f=f.return}if(on=o,qt=o=oo(o.current,null),hn=os=i,Zt=0,pl=null,rp=Su=Wo=0,qn=hl=null,Do!==null){for(i=0;i<Do.length;i++)if(f=Do[i],b=f.interleaved,b!==null){f.interleaved=null;var j=b.next,$=f.pending;if($!==null){var M=$.next;$.next=j,b.next=M}f.pending=b}Do=null}return o}function tv(o,i){do{var f=qt;try{if(Sm(),pu.current=yu,hu){for(var b=Mt.memoizedState;b!==null;){var j=b.queue;j!==null&&(j.pending=null),b=b.next}hu=!1}if(Uo=0,rn=Jt=Mt=null,ll=!1,cl=0,sp.current=null,f===null||f.return===null){Zt=1,pl=i,qt=null;break}e:{var $=o,M=f.return,G=f,X=i;if(i=hn,G.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var le=X,xe=G,be=xe.tag;if((xe.mode&1)===0&&(be===0||be===11||be===15)){var he=xe.alternate;he?(xe.updateQueue=he.updateQueue,xe.memoizedState=he.memoizedState,xe.lanes=he.lanes):(xe.updateQueue=null,xe.memoizedState=null)}var Re=_b(M);if(Re!==null){Re.flags&=-257,$b(Re,M,G,$,i),Re.mode&1&&Sb($,le,i),i=Re,X=le;var Ie=i.updateQueue;if(Ie===null){var De=new Set;De.add(X),i.updateQueue=De}else Ie.add(X);break e}else{if((i&1)===0){Sb($,le,i),fp();break e}X=Error(s(426))}}else if(Tt&&G.mode&1){var Ht=_b(M);if(Ht!==null){(Ht.flags&65536)===0&&(Ht.flags|=256),$b(Ht,M,G,$,i),jm(Ga(X,G));break e}}$=X=Ga(X,G),Zt!==4&&(Zt=2),hl===null?hl=[$]:hl.push($),$=M;do{switch($.tag){case 3:$.flags|=65536,i&=-i,$.lanes|=i;var re=jb($,X,i);Xy($,re);break e;case 1:G=X;var ne=$.type,oe=$.stateNode;if(($.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||oe!==null&&typeof oe.componentDidCatch=="function"&&(to===null||!to.has(oe)))){$.flags|=65536,i&=-i,$.lanes|=i;var ke=Nb($,G,i);Xy($,ke);break e}}$=$.return}while($!==null)}rv(f)}catch(Ue){i=Ue,qt===f&&f!==null&&(qt=f=f.return);continue}break}while(!0)}function nv(){var o=Nu.current;return Nu.current=yu,o===null?yu:o}function fp(){(Zt===0||Zt===3||Zt===2)&&(Zt=4),on===null||(Wo&268435455)===0&&(Su&268435455)===0||ro(on,hn)}function Ru(o,i){var f=mt;mt|=2;var b=nv();(on!==o||hn!==i)&&(Sr=null,Bo(o,i));do try{p$();break}catch(j){tv(o,j)}while(!0);if(Sm(),mt=f,Nu.current=b,qt!==null)throw Error(s(261));return on=null,hn=0,Zt}function p$(){for(;qt!==null;)sv(qt)}function h$(){for(;qt!==null&&!vt();)sv(qt)}function sv(o){var i=iv(o.alternate,o,os);o.memoizedProps=o.pendingProps,i===null?rv(o):qt=i,sp.current=null}function rv(o){var i=o;do{var f=i.alternate;if(o=i.return,(i.flags&32768)===0){if(f=i$(f,i,os),f!==null){qt=f;return}}else{if(f=l$(f,i),f!==null){f.flags&=32767,qt=f;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{Zt=6,qt=null;return}}if(i=i.sibling,i!==null){qt=i;return}qt=i=o}while(i!==null);Zt===0&&(Zt=5)}function Go(o,i,f){var b=st,j=ws.transition;try{ws.transition=null,st=1,g$(o,i,f,b)}finally{ws.transition=j,st=b}return null}function g$(o,i,f,b){do Ya();while(no!==null);if((mt&6)!==0)throw Error(s(327));f=o.finishedWork;var j=o.finishedLanes;if(f===null)return null;if(o.finishedWork=null,o.finishedLanes=0,f===o.current)throw Error(s(177));o.callbackNode=null,o.callbackPriority=0;var $=f.lanes|f.childLanes;if(Ur(o,$),o===on&&(qt=on=null,hn=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||$u||($u=!0,lv(At,function(){return Ya(),null})),$=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||$){$=ws.transition,ws.transition=null;var M=st;st=1;var G=mt;mt|=4,sp.current=null,u$(o,f),Kb(f,o),P_(fm),Wc=!!dm,fm=dm=null,o.current=f,d$(f),Wt(),mt=G,st=M,ws.transition=$}else o.current=f;if($u&&($u=!1,no=o,Eu=j),$=o.pendingLanes,$===0&&(to=null),Lc(f.stateNode),Vn(o,nt()),i!==null)for(b=o.onRecoverableError,f=0;f<i.length;f++)j=i[f],b(j.value,{componentStack:j.stack,digest:j.digest});if(_u)throw _u=!1,o=ap,ap=null,o;return(Eu&1)!==0&&o.tag!==0&&Ya(),$=o.pendingLanes,($&1)!==0?o===ip?gl++:(gl=0,ip=o):gl=0,Qr(),null}function Ya(){if(no!==null){var o=Fc(Eu),i=ws.transition,f=st;try{if(ws.transition=null,st=16>o?16:o,no===null)var b=!1;else{if(o=no,no=null,Eu=0,(mt&6)!==0)throw Error(s(331));var j=mt;for(mt|=4,Le=o.current;Le!==null;){var $=Le,M=$.child;if((Le.flags&16)!==0){var G=$.deletions;if(G!==null){for(var X=0;X<G.length;X++){var le=G[X];for(Le=le;Le!==null;){var xe=Le;switch(xe.tag){case 0:case 11:case 15:ml(8,xe,$)}var be=xe.child;if(be!==null)be.return=xe,Le=be;else for(;Le!==null;){xe=Le;var he=xe.sibling,Re=xe.return;if(Hb(xe),xe===le){Le=null;break}if(he!==null){he.return=Re,Le=he;break}Le=Re}}}var Ie=$.alternate;if(Ie!==null){var De=Ie.child;if(De!==null){Ie.child=null;do{var Ht=De.sibling;De.sibling=null,De=Ht}while(De!==null)}}Le=$}}if(($.subtreeFlags&2064)!==0&&M!==null)M.return=$,Le=M;else e:for(;Le!==null;){if($=Le,($.flags&2048)!==0)switch($.tag){case 0:case 11:case 15:ml(9,$,$.return)}var re=$.sibling;if(re!==null){re.return=$.return,Le=re;break e}Le=$.return}}var ne=o.current;for(Le=ne;Le!==null;){M=Le;var oe=M.child;if((M.subtreeFlags&2064)!==0&&oe!==null)oe.return=M,Le=oe;else e:for(M=ne;Le!==null;){if(G=Le,(G.flags&2048)!==0)try{switch(G.tag){case 0:case 11:case 15:ju(9,G)}}catch(Ue){It(G,G.return,Ue)}if(G===M){Le=null;break e}var ke=G.sibling;if(ke!==null){ke.return=G.return,Le=ke;break e}Le=G.return}}if(mt=j,Qr(),ts&&typeof ts.onPostCommitFiberRoot=="function")try{ts.onPostCommitFiberRoot(Ro,o)}catch{}b=!0}return b}finally{st=f,ws.transition=i}}return!1}function ov(o,i,f){i=Ga(f,i),i=jb(o,i,1),o=Zr(o,i,1),i=An(),o!==null&&(at(o,1,i),Vn(o,i))}function It(o,i,f){if(o.tag===3)ov(o,o,f);else for(;i!==null;){if(i.tag===3){ov(i,o,f);break}else if(i.tag===1){var b=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(to===null||!to.has(b))){o=Ga(f,o),o=Nb(i,o,1),i=Zr(i,o,1),o=An(),i!==null&&(at(i,1,o),Vn(i,o));break}}i=i.return}}function x$(o,i,f){var b=o.pingCache;b!==null&&b.delete(i),i=An(),o.pingedLanes|=o.suspendedLanes&f,on===o&&(hn&f)===f&&(Zt===4||Zt===3&&(hn&130023424)===hn&&500>nt()-op?Bo(o,0):rp|=f),Vn(o,i)}function av(o,i){i===0&&((o.mode&1)===0?i=1:(i=Oo,Oo<<=1,(Oo&130023424)===0&&(Oo=4194304)));var f=An();o=kr(o,i),o!==null&&(at(o,i,f),Vn(o,f))}function y$(o){var i=o.memoizedState,f=0;i!==null&&(f=i.retryLane),av(o,f)}function b$(o,i){var f=0;switch(o.tag){case 13:var b=o.stateNode,j=o.memoizedState;j!==null&&(f=j.retryLane);break;case 19:b=o.stateNode;break;default:throw Error(s(314))}b!==null&&b.delete(i),av(o,f)}var iv;iv=function(o,i,f){if(o!==null)if(o.memoizedProps!==i.pendingProps||Hn.current)Gn=!0;else{if((o.lanes&f)===0&&(i.flags&128)===0)return Gn=!1,a$(o,i,f);Gn=(o.flags&131072)!==0}else Gn=!1,Tt&&(i.flags&1048576)!==0&&Fy(i,au,i.index);switch(i.lanes=0,i.tag){case 2:var b=i.type;wu(o,i),o=i.pendingProps;var j=Ia(i,wn.current);Ha(i,f),j=Pm(null,i,b,o,j,f);var $=Im();return i.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,Bn(b)?($=!0,su(i)):$=!1,i.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Cm(i),j.updater=bu,i.stateNode=j,j._reactInternals=i,Hm(i,b,o,f),i=Vm(null,i,b,!0,$,f)):(i.tag=0,Tt&&$&&bm(i),Rn(null,i,j,f),i=i.child),i;case 16:b=i.elementType;e:{switch(wu(o,i),o=i.pendingProps,j=b._init,b=j(b._payload),i.type=b,j=i.tag=w$(b),o=Us(b,o),j){case 0:i=qm(null,i,b,o,f);break e;case 1:i=Ob(null,i,b,o,f);break e;case 11:i=Eb(null,i,b,o,f);break e;case 14:i=Cb(null,i,b,Us(b.type,o),f);break e}throw Error(s(306,b,""))}return i;case 0:return b=i.type,j=i.pendingProps,j=i.elementType===b?j:Us(b,j),qm(o,i,b,j,f);case 1:return b=i.type,j=i.pendingProps,j=i.elementType===b?j:Us(b,j),Ob(o,i,b,j,f);case 3:e:{if(Mb(i),o===null)throw Error(s(387));b=i.pendingProps,$=i.memoizedState,j=$.element,Yy(o,i),fu(i,b,null,f);var M=i.memoizedState;if(b=M.element,$.isDehydrated)if($={element:b,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},i.updateQueue.baseState=$,i.memoizedState=$,i.flags&256){j=Ga(Error(s(423)),i),i=Lb(o,i,b,f,j);break e}else if(b!==j){j=Ga(Error(s(424)),i),i=Lb(o,i,b,f,j);break e}else for(rs=Kr(i.stateNode.containerInfo.firstChild),ss=i,Tt=!0,Fs=null,f=Vy(i,null,b,f),i.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(Fa(),b===j){i=Nr(o,i,f);break e}Rn(o,i,b,f)}i=i.child}return i;case 5:return Jy(i),o===null&&km(i),b=i.type,j=i.pendingProps,$=o!==null?o.memoizedProps:null,M=j.children,mm(b,j)?M=null:$!==null&&mm(b,$)&&(i.flags|=32),Ab(o,i),Rn(o,i,M,f),i.child;case 6:return o===null&&km(i),null;case 13:return Pb(o,i,f);case 4:return Tm(i,i.stateNode.containerInfo),b=i.pendingProps,o===null?i.child=Ua(i,null,b,f):Rn(o,i,b,f),i.child;case 11:return b=i.type,j=i.pendingProps,j=i.elementType===b?j:Us(b,j),Eb(o,i,b,j,f);case 7:return Rn(o,i,i.pendingProps,f),i.child;case 8:return Rn(o,i,i.pendingProps.children,f),i.child;case 12:return Rn(o,i,i.pendingProps.children,f),i.child;case 10:e:{if(b=i.type._context,j=i.pendingProps,$=i.memoizedProps,M=j.value,_t(cu,b._currentValue),b._currentValue=M,$!==null)if(Ds($.value,M)){if($.children===j.children&&!Hn.current){i=Nr(o,i,f);break e}}else for($=i.child,$!==null&&($.return=i);$!==null;){var G=$.dependencies;if(G!==null){M=$.child;for(var X=G.firstContext;X!==null;){if(X.context===b){if($.tag===1){X=jr(-1,f&-f),X.tag=2;var le=$.updateQueue;if(le!==null){le=le.shared;var xe=le.pending;xe===null?X.next=X:(X.next=xe.next,xe.next=X),le.pending=X}}$.lanes|=f,X=$.alternate,X!==null&&(X.lanes|=f),$m($.return,f,i),G.lanes|=f;break}X=X.next}}else if($.tag===10)M=$.type===i.type?null:$.child;else if($.tag===18){if(M=$.return,M===null)throw Error(s(341));M.lanes|=f,G=M.alternate,G!==null&&(G.lanes|=f),$m(M,f,i),M=$.sibling}else M=$.child;if(M!==null)M.return=$;else for(M=$;M!==null;){if(M===i){M=null;break}if($=M.sibling,$!==null){$.return=M.return,M=$;break}M=M.return}$=M}Rn(o,i,j.children,f),i=i.child}return i;case 9:return j=i.type,b=i.pendingProps.children,Ha(i,f),j=bs(j),b=b(j),i.flags|=1,Rn(o,i,b,f),i.child;case 14:return b=i.type,j=Us(b,i.pendingProps),j=Us(b.type,j),Cb(o,i,b,j,f);case 15:return Tb(o,i,i.type,i.pendingProps,f);case 17:return b=i.type,j=i.pendingProps,j=i.elementType===b?j:Us(b,j),wu(o,i),i.tag=1,Bn(b)?(o=!0,su(i)):o=!1,Ha(i,f),wb(i,b,j),Hm(i,b,j,f),Vm(null,i,b,!0,o,f);case 19:return zb(o,i,f);case 22:return Rb(o,i,f)}throw Error(s(156,i.tag))};function lv(o,i){return ve(o,i)}function v$(o,i,f,b){this.tag=o,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ks(o,i,f,b){return new v$(o,i,f,b)}function mp(o){return o=o.prototype,!(!o||!o.isReactComponent)}function w$(o){if(typeof o=="function")return mp(o)?1:0;if(o!=null){if(o=o.$$typeof,o===I)return 11;if(o===J)return 14}return 2}function oo(o,i){var f=o.alternate;return f===null?(f=ks(o.tag,i,o.key,o.mode),f.elementType=o.elementType,f.type=o.type,f.stateNode=o.stateNode,f.alternate=o,o.alternate=f):(f.pendingProps=i,f.type=o.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=o.flags&14680064,f.childLanes=o.childLanes,f.lanes=o.lanes,f.child=o.child,f.memoizedProps=o.memoizedProps,f.memoizedState=o.memoizedState,f.updateQueue=o.updateQueue,i=o.dependencies,f.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},f.sibling=o.sibling,f.index=o.index,f.ref=o.ref,f}function Au(o,i,f,b,j,$){var M=2;if(b=o,typeof o=="function")mp(o)&&(M=1);else if(typeof o=="string")M=5;else e:switch(o){case C:return qo(f.children,j,$,i);case R:M=8,j|=8;break;case D:return o=ks(12,f,i,j|2),o.elementType=D,o.lanes=$,o;case W:return o=ks(13,f,i,j),o.elementType=W,o.lanes=$,o;case U:return o=ks(19,f,i,j),o.elementType=U,o.lanes=$,o;case Z:return Ou(f,j,$,i);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case L:M=10;break e;case O:M=9;break e;case I:M=11;break e;case J:M=14;break e;case F:M=16,b=null;break e}throw Error(s(130,o==null?o:typeof o,""))}return i=ks(M,f,i,j),i.elementType=o,i.type=b,i.lanes=$,i}function qo(o,i,f,b){return o=ks(7,o,b,i),o.lanes=f,o}function Ou(o,i,f,b){return o=ks(22,o,b,i),o.elementType=Z,o.lanes=f,o.stateNode={isHidden:!1},o}function pp(o,i,f){return o=ks(6,o,null,i),o.lanes=f,o}function hp(o,i,f){return i=ks(4,o.children!==null?o.children:[],o.key,i),i.lanes=f,i.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},i}function k$(o,i,f,b,j){this.tag=i,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=dt(0),this.expirationTimes=dt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dt(0),this.identifierPrefix=b,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function gp(o,i,f,b,j,$,M,G,X){return o=new k$(o,i,f,G,X),i===1?(i=1,$===!0&&(i|=8)):i=0,$=ks(3,null,null,i),o.current=$,$.stateNode=o,$.memoizedState={element:b,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},Cm($),o}function j$(o,i,f){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:b==null?null:""+b,children:o,containerInfo:i,implementation:f}}function cv(o){if(!o)return Xr;o=o._reactInternals;e:{if(Tn(o)!==o||o.tag!==1)throw Error(s(170));var i=o;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(Bn(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(s(171))}if(o.tag===1){var f=o.type;if(Bn(f))return Iy(o,f,i)}return i}function uv(o,i,f,b,j,$,M,G,X){return o=gp(f,b,!0,o,j,$,M,G,X),o.context=cv(null),f=o.current,b=An(),j=so(f),$=jr(b,j),$.callback=i??null,Zr(f,$,j),o.current.lanes=j,at(o,j,b),Vn(o,b),o}function Mu(o,i,f,b){var j=i.current,$=An(),M=so(j);return f=cv(f),i.context===null?i.context=f:i.pendingContext=f,i=jr($,M),i.payload={element:o},b=b===void 0?null:b,b!==null&&(i.callback=b),o=Zr(j,i,M),o!==null&&(Bs(o,j,M,$),du(o,j,M)),M}function Lu(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function dv(o,i){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var f=o.retryLane;o.retryLane=f!==0&&f<i?f:i}}function xp(o,i){dv(o,i),(o=o.alternate)&&dv(o,i)}function N$(){return null}var fv=typeof reportError=="function"?reportError:function(o){console.error(o)};function yp(o){this._internalRoot=o}Pu.prototype.render=yp.prototype.render=function(o){var i=this._internalRoot;if(i===null)throw Error(s(409));Mu(o,i,null,null)},Pu.prototype.unmount=yp.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var i=o.containerInfo;Ho(function(){Mu(null,o,null,null)}),i[yr]=null}};function Pu(o){this._internalRoot=o}Pu.prototype.unstable_scheduleHydration=function(o){if(o){var i=Di();o={blockedOn:null,target:o,priority:i};for(var f=0;f<Gr.length&&i!==0&&i<Gr[f].priority;f++);Gr.splice(f,0,o),f===0&&Jx(o)}};function bp(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function Iu(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function mv(){}function S$(o,i,f,b,j){if(j){if(typeof b=="function"){var $=b;b=function(){var le=Lu(M);$.call(le)}}var M=uv(i,b,o,0,null,!1,!1,"",mv);return o._reactRootContainer=M,o[yr]=M.current,el(o.nodeType===8?o.parentNode:o),Ho(),M}for(;j=o.lastChild;)o.removeChild(j);if(typeof b=="function"){var G=b;b=function(){var le=Lu(X);G.call(le)}}var X=gp(o,0,!1,null,null,!1,!1,"",mv);return o._reactRootContainer=X,o[yr]=X.current,el(o.nodeType===8?o.parentNode:o),Ho(function(){Mu(i,X,f,b)}),X}function zu(o,i,f,b,j){var $=f._reactRootContainer;if($){var M=$;if(typeof j=="function"){var G=j;j=function(){var X=Lu(M);G.call(X)}}Mu(i,M,o,j)}else M=S$(f,i,o,j,b);return Lu(M)}xr=function(o){switch(o.tag){case 3:var i=o.stateNode;if(i.current.memoizedState.isDehydrated){var f=Fr(i.pendingLanes);f!==0&&(fn(i,f|1),Vn(i,nt()),(mt&6)===0&&(Ka=nt()+500,Qr()))}break;case 13:Ho(function(){var b=kr(o,1);if(b!==null){var j=An();Bs(b,o,1,j)}}),xp(o,1)}},Ii=function(o){if(o.tag===13){var i=kr(o,134217728);if(i!==null){var f=An();Bs(i,o,134217728,f)}xp(o,134217728)}},zi=function(o){if(o.tag===13){var i=so(o),f=kr(o,i);if(f!==null){var b=An();Bs(f,o,i,b)}xp(o,i)}},Di=function(){return st},Fi=function(o,i){var f=st;try{return st=o,i()}finally{st=f}},bn=function(o,i,f){switch(i){case"input":if(Je(o,f),i=f.name,f.type==="radio"&&i!=null){for(f=o;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<f.length;i++){var b=f[i];if(b!==o&&b.form===o.form){var j=tu(b);if(!j)throw Error(s(90));se(b),Je(b,j)}}}break;case"textarea":kt(o,f);break;case"select":i=f.value,i!=null&&Ae(o,!!f.multiple,i,!1)}},Cn=up,ps=Ho;var _$={usingClientEntryPoint:!1,Events:[sl,La,tu,gr,Nt,up]},xl={findFiberByHostInstance:Lo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},$$={bundleType:xl.bundleType,version:xl.version,rendererPackageName:xl.rendererPackageName,rendererConfig:xl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=He(o),o===null?null:o.stateNode},findFiberByHostInstance:xl.findFiberByHostInstance||N$,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 Du=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Du.isDisabled&&Du.supportsFiber)try{Ro=Du.inject($$),ts=Du}catch{}}return Kn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=_$,Kn.createPortal=function(o,i){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bp(i))throw Error(s(200));return j$(o,i,null,f)},Kn.createRoot=function(o,i){if(!bp(o))throw Error(s(299));var f=!1,b="",j=fv;return i!=null&&(i.unstable_strictMode===!0&&(f=!0),i.identifierPrefix!==void 0&&(b=i.identifierPrefix),i.onRecoverableError!==void 0&&(j=i.onRecoverableError)),i=gp(o,1,!1,null,null,f,!1,b,j),o[yr]=i.current,el(o.nodeType===8?o.parentNode:o),new yp(i)},Kn.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var i=o._reactInternals;if(i===void 0)throw typeof o.render=="function"?Error(s(188)):(o=Object.keys(o).join(","),Error(s(268,o)));return o=He(i),o=o===null?null:o.stateNode,o},Kn.flushSync=function(o){return Ho(o)},Kn.hydrate=function(o,i,f){if(!Iu(i))throw Error(s(200));return zu(null,o,i,!0,f)},Kn.hydrateRoot=function(o,i,f){if(!bp(o))throw Error(s(405));var b=f!=null&&f.hydratedSources||null,j=!1,$="",M=fv;if(f!=null&&(f.unstable_strictMode===!0&&(j=!0),f.identifierPrefix!==void 0&&($=f.identifierPrefix),f.onRecoverableError!==void 0&&(M=f.onRecoverableError)),i=uv(i,null,o,1,f??null,j,!1,$,M),o[yr]=i.current,el(o),b)for(o=0;o<b.length;o++)f=b[o],j=f._getVersion,j=j(f._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[f,j]:i.mutableSourceEagerHydrationData.push(f,j);return new Pu(i)},Kn.render=function(o,i,f){if(!Iu(i))throw Error(s(200));return zu(null,o,i,!1,f)},Kn.unmountComponentAtNode=function(o){if(!Iu(o))throw Error(s(40));return o._reactRootContainer?(Ho(function(){zu(null,null,o,!1,function(){o._reactRootContainer=null,o[yr]=null})}),!0):!1},Kn.unstable_batchedUpdates=up,Kn.unstable_renderSubtreeIntoContainer=function(o,i,f,b){if(!Iu(f))throw Error(s(200));if(o==null||o._reactInternals===void 0)throw Error(s(38));return zu(o,i,f,!1,b)},Kn.version="18.3.1-next-f1338f8080-20240426",Kn}var wv;function Ek(){if(wv)return kp.exports;wv=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(t){console.error(t)}}return e(),kp.exports=I$(),kp.exports}var kv;function z$(){if(kv)return Fu;kv=1;var e=Ek();return Fu.createRoot=e.createRoot,Fu.hydrateRoot=e.hydrateRoot,Fu}var D$=z$();const Rt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),F$=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),mh=128,U$=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},ph=(e,t=0)=>t>mh?'"…"':Array.isArray(e)?`[${e.map(s=>ph(s,t+1)).join(",")}]`:Rt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${ph(e[s],t+1)}`).join(",")}}`:U$(e),W$=e=>{let t=2166136261;for(let s=0;s<e.length;s+=1)t=Math.imul(t^e.charCodeAt(s),16777619);return(t>>>0).toString(16).padStart(8,"0")},bl=(e,t)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==t)),H$=e=>{switch(e.node){case"chain":return bl(e,"steps");case"parallel":return bl(e,"branches");case"map":case"loop":return bl(e,"body");case"route":return Rt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([t,s])=>[t,Rt(s)?bl(s,"body"):s]))}:e;case"workflow":return Rt(e.workflow)?{...e,workflow:bl(e.workflow,"root")}:e;default:return e}};function hi(e){const t=[],s=[],r=(a,l,c,u)=>{if(!Rt(a)||typeof a.node!="string"||c>mh)return;t.push({path:l,kind:a.node,label:typeof a.label=="string"?a.label:a.node,...a.node==="call"&&typeof a.via=="string"?{via:a.via}:{},changeCheck:W$(ph(H$(a))),...G$(a,u)});const d=(p,g,y,h=l,m=u)=>{!Rt(p)||typeof p.node!="string"||c+1>mh||(s.push({from:h,to:g,kind:y}),r(p,g,c+1,m))};switch(a.node){case"chain":Array.isArray(a.steps)&&a.steps.forEach((p,g)=>d(p,`${l}/steps/${g}`,"next",g===0?l:`${l}/steps/${g-1}`));break;case"parallel":Array.isArray(a.branches)&&a.branches.forEach((p,g)=>d(p,`${l}/branches/${g}`,"branch"));break;case"map":d(a.body,`${l}/body`,"item");break;case"loop":d(a.body,`${l}/body`,"next");break;case"route":if(Rt(a.branches))for(const[p,g]of Object.entries(a.branches))Rt(g)&&d(g.body,`${l}/branches/${F$(p)}/body`,"route");break;case"workflow":Rt(a.workflow)&&d(a.workflow.root,`${l}/workflow/root`,"child",l,Rt(a.workflow.schemas)?a.workflow.schemas:{});break}};return r(Rt(e)?e.root:void 0,"/root",0,Rt(e)&&Rt(e.schemas)?e.schemas:{}),{nodes:t,edges:s}}const B$=(e,t)=>{const s=typeof e=="string"&&Object.hasOwn(t,e)?t[e]:void 0,r=l=>{var c;for(let u=0;Rt(l)&&typeof l.$ref=="string"&&u<8;u+=1){const d=(c=/^#\/definitions\/(.+)$/.exec(l.$ref))==null?void 0:c[1],p=Rt(s)&&Rt(s.definitions)?s.definitions:{};l=d===void 0?void 0:Object.hasOwn(p,d)?p[d]:Object.hasOwn(t,d)?t[d]:void 0}return l},a=r(s);return!Rt(a)||!Rt(a.properties)?[]:Object.entries(a.properties).map(([l,c])=>{const u=r(c),d=Rt(u)&&typeof u.description=="string"?u.description:"",p=Rt(u)?(Array.isArray(u.type)?u.type:[u.type]).filter(g=>g!=="null"):[];return Rt(u)&&Array.isArray(u.enum)?{id:l,type:"choice",instructions:d,options:u.enum.map(String)}:p.length===1&&p[0]==="boolean"?{id:l,type:"noul",instructions:d}:p.length===1&&p[0]==="integer"?{id:l,type:"score",instructions:d}:{id:l,type:"unknown",instructions:d}})},G$=(e,t)=>{let s=e,r;const a=l=>typeof l=="string"?l:"";switch(e.node){case"judge":case"sift":r=B$(e.out,t);break;case"pick":r=[{id:"pick",type:"choice",instructions:a(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};r=[{id:"branch",type:"choice",instructions:a(e.instructions),options:Rt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const l=e.node==="loop"?e.until:e.when;if(!Rt(l)||l.predicate!=="ask")return{};s=l,r=[{id:"holds",type:"noul",instructions:a(l.instructions)}];break}default:return{}}return{...typeof s.provider=="string"?{provider:s.provider}:{},...typeof s.model=="string"?{model:s.model}:{},questions:r,...Rt(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function Ck(e,t){const s=_=>JSON.stringify([_.kind,_.label]),r=_=>{const S=new Map;for(const E of _.nodes)S.set(s(E),(S.get(s(E))??0)+1);return S},[a,l]=[r(e),r(t)],c=_=>a.get(s(_))===1&&l.get(s(_))===1,u=new Map,d=new Map,p=(_,S)=>{u.set(S,_),d.set(_,S)},g=new Map(e.nodes.filter(c).map(_=>[s(_),_.path]));for(const _ of t.nodes){const S=c(_)?g.get(s(_)):void 0;S!==void 0&&p(S,_.path)}const y=new Map(e.nodes.map(_=>[_.path,_])),h=[];for(const _ of t.nodes){const S=y.get(_.path);u.has(_.path)||S===void 0||d.has(S.path)||(p(S.path,_.path),(S.kind!==_.kind||S.label!==_.label)&&h.push({prev:S.path,next:_.path,was:{kind:S.kind,label:S.label},now:{kind:_.kind,label:_.label}}))}const m=[];for(const _ of t.nodes){const S=u.get(_.path),E=S===void 0?void 0:y.get(S);E===void 0||E.kind!==_.kind||E.label!==_.label||E.changeCheck!==void 0&&_.changeCheck!==void 0&&E.changeCheck!==_.changeCheck&&m.push({prev:E.path,next:_.path,kind:_.kind,label:_.label})}const v=({path:_,kind:S,label:E})=>({path:_,kind:S,label:E}),w=(_,S,E)=>JSON.stringify([_,S,E]),k=new Set(e.edges.map(_=>w(_.from,_.to,_.kind))),N=new Set(t.edges.map(_=>w(_.from,_.to,_.kind))),A=(_,S,E)=>{const[T,C]=[S.get(_.from),S.get(_.to)];return T!==void 0&&C!==void 0&&E.has(w(T,C,_.kind))};return{added:t.nodes.filter(_=>!u.has(_.path)).map(v),removed:e.nodes.filter(_=>!d.has(_.path)).map(v),changed:h,moved:t.nodes.flatMap(_=>{const S=u.get(_.path);return S!==void 0&&S!==_.path?[{prev:S,next:_.path}]:[]}),rewritten:m,edges:{added:t.edges.filter(_=>!A(_,u,k)).map(({from:_,to:S,kind:E})=>({from:_,to:S,kind:E})),removed:e.edges.filter(_=>!A(_,d,N)).map(({from:_,to:S,kind:E})=>({from:_,to:S,kind:E}))}}}/**
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 q$=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Tk=(...e)=>e.filter((t,s,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===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 V$={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 K$=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:a="",children:l,iconNode:c,...u},d)=>x.createElement("svg",{ref:d,...V$,width:t,height:t,stroke:e,strokeWidth:r?Number(s)*24/Number(t):s,className:Tk("lucide",a),...u},[...c.map(([p,g])=>x.createElement(p,g)),...Array.isArray(l)?l:[l]]));/**
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 $e=(e,t)=>{const s=x.forwardRef(({className:r,...a},l)=>x.createElement(K$,{ref:l,iconNode:t,className:Tk(`lucide-${q$(e)}`,r),...a}));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 Rk=$e("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"}]]);/**
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 cc=$e("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"}]]);/**
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 Es=$e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
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 fg=$e("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
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 Y$=$e("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
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 Ak=$e("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
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 jd=$e("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
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 mg=$e("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"}]]);/**
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 X$=$e("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"}]]);/**
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 af=$e("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"}]]);/**
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 uc=$e("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
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 va=$e("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
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 Q$=$e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
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 cs=$e("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
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 gi=$e("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"}]]);/**
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 J$=$e("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"}]]);/**
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 Ok=$e("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
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 pg=$e("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"}]]);/**
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 Z$=$e("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
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 Mk=$e("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"}]]);/**
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 eE=$e("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
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 tE=$e("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
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 lf=$e("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"}]]);/**
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 nE=$e("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
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 sE=$e("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"}]]);/**
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 rE=$e("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"}]]);/**
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 hg=$e("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"}]]);/**
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 Si=$e("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"}]]);/**
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 Lk=$e("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"}]]);/**
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 oE=$e("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"}]]);/**
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 gg=$e("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"}]]);/**
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 jv=$e("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"}]]);/**
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 Pk=$e("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"}]]);/**
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 aE=$e("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"}]]);/**
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 xg=$e("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"}]]);/**
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 yg=$e("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"}]]);/**
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 hh=$e("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
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 ia=$e("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"}]]);/**
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 iE=$e("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
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 lE=$e("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
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 Ik=$e("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"}]]);/**
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 cE=$e("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"}]]);/**
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 uE=$e("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
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 Sp=$e("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"}]]);/**
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 dE=$e("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"}]]);/**
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 fE=$e("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"}]]);/**
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 mE=$e("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"}]]);/**
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 bg=$e("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"}]]);/**
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 pE=$e("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"}]]);/**
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 hE=$e("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"}]]);/**
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 wa=$e("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"}]]);/**
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 gE=$e("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
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 xE=$e("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"}]]);/**
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 xi=$e("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"}]]);/**
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 dc=$e("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"}]]);/**
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 _i=$e("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
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 yE=$e("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"}]]);/**
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 yi=$e("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
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 bE=$e("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"}]]);/**
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 zk=$e("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"}]]);/**
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 vE=$e("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"}]]);/**
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 wE=$e("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
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 Dk=$e("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"}]]);/**
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 Fk=$e("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"}]]);/**
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 Uk=$e("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
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 vg=$e("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"}]]);/**
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 kE=$e("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
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 jE=$e("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
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 NE=$e("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"}]]);/**
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 Wk=$e("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
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 SE=$e("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"}]]);/**
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 Zs=$e("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"}]]);/**
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 wg=$e("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"}]]);/**
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 Bl=$e("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"}]]);/**
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 Hk=$e("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"}]]);/**
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 ka=$e("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"}]]);/**
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 Nd=$e("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"}]]);/**
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 fc=$e("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
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 _E=$e("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"}]]);function Bk(e){var t,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(s=Bk(e[t]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function Gk(){for(var e,t,s=0,r="",a=arguments.length;s<a;s++)(e=arguments[s])&&(t=Bk(e))&&(r&&(r+=" "),r+=t);return r}const kg="-",$E=e=>{const t=CE(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const u=c.split(kg);return u[0]===""&&u.length!==1&&u.shift(),qk(u,t)||EE(c)},getConflictingClassGroupIds:(c,u)=>{const d=s[c]||[];return u&&r[c]?[...d,...r[c]]:d}}},qk=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const s=e[0],r=t.nextPart.get(s),a=r?qk(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const l=e.join(kg);return(c=t.validators.find(({validator:u})=>u(l)))==null?void 0:c.classGroupId},Nv=/^\[(.+)\]$/,EE=e=>{if(Nv.test(e)){const t=Nv.exec(e)[1],s=t==null?void 0:t.substring(0,t.indexOf(":"));if(s)return"arbitrary.."+s}},CE=e=>{const{theme:t,prefix:s}=e,r={nextPart:new Map,validators:[]};return RE(Object.entries(e.classGroups),s).forEach(([l,c])=>{gh(c,r,l,t)}),r},gh=(e,t,s,r)=>{e.forEach(a=>{if(typeof a=="string"){const l=a===""?t:Sv(t,a);l.classGroupId=s;return}if(typeof a=="function"){if(TE(a)){gh(a(r),t,s,r);return}t.validators.push({validator:a,classGroupId:s});return}Object.entries(a).forEach(([l,c])=>{gh(c,Sv(t,l),s,r)})})},Sv=(e,t)=>{let s=e;return t.split(kg).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},TE=e=>e.isThemeGetter,RE=(e,t)=>t?e.map(([s,r])=>{const a=r.map(l=>typeof l=="string"?t+l:typeof l=="object"?Object.fromEntries(Object.entries(l).map(([c,u])=>[t+c,u])):l);return[s,a]}):e,AE=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=new Map,r=new Map;const a=(l,c)=>{s.set(l,c),t++,t>e&&(t=0,r=s,s=new Map)};return{get(l){let c=s.get(l);if(c!==void 0)return c;if((c=r.get(l))!==void 0)return a(l,c),c},set(l,c){s.has(l)?s.set(l,c):a(l,c)}}},Vk="!",OE=e=>{const{separator:t,experimentalParseClassName:s}=e,r=t.length===1,a=t[0],l=t.length,c=u=>{const d=[];let p=0,g=0,y;for(let k=0;k<u.length;k++){let N=u[k];if(p===0){if(N===a&&(r||u.slice(k,k+l)===t)){d.push(u.slice(g,k)),g=k+l;continue}if(N==="/"){y=k;continue}}N==="["?p++:N==="]"&&p--}const h=d.length===0?u:u.substring(g),m=h.startsWith(Vk),v=m?h.substring(1):h,w=y&&y>g?y-g:void 0;return{modifiers:d,hasImportantModifier:m,baseClassName:v,maybePostfixModifierPosition:w}};return s?u=>s({className:u,parseClassName:c}):c},ME=e=>{if(e.length<=1)return e;const t=[];let s=[];return e.forEach(r=>{r[0]==="["?(t.push(...s.sort(),r),s=[]):s.push(r)}),t.push(...s.sort()),t},LE=e=>({cache:AE(e.cacheSize),parseClassName:OE(e),...$E(e)}),PE=/\s+/,IE=(e,t)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:a}=t,l=[],c=e.trim().split(PE);let u="";for(let d=c.length-1;d>=0;d-=1){const p=c[d],{modifiers:g,hasImportantModifier:y,baseClassName:h,maybePostfixModifierPosition:m}=s(p);let v=!!m,w=r(v?h.substring(0,m):h);if(!w){if(!v){u=p+(u.length>0?" "+u:u);continue}if(w=r(h),!w){u=p+(u.length>0?" "+u:u);continue}v=!1}const k=ME(g).join(":"),N=y?k+Vk:k,A=N+w;if(l.includes(A))continue;l.push(A);const _=a(w,v);for(let S=0;S<_.length;++S){const E=_[S];l.push(N+E)}u=p+(u.length>0?" "+u:u)}return u};function zE(){let e=0,t,s,r="";for(;e<arguments.length;)(t=arguments[e++])&&(s=Kk(t))&&(r&&(r+=" "),r+=s);return r}const Kk=e=>{if(typeof e=="string")return e;let t,s="";for(let r=0;r<e.length;r++)e[r]&&(t=Kk(e[r]))&&(s&&(s+=" "),s+=t);return s};function _v(e,...t){let s,r,a,l=c;function c(d){const p=t.reduce((g,y)=>y(g),e());return s=LE(p),r=s.cache.get,a=s.cache.set,l=u,u(d)}function u(d){const p=r(d);if(p)return p;const g=IE(d,s);return a(d,g),g}return function(){return l(zE.apply(null,arguments))}}const Ct=e=>{const t=s=>s[e]||[];return t.isThemeGetter=!0,t},Yk=/^\[(?:([a-z-]+):)?(.+)\]$/i,DE=/^\d+\/\d+$/,FE=new Set(["px","full","screen"]),UE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,WE=/\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$/,HE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,BE=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,GE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_r=e=>oi(e)||FE.has(e)||DE.test(e),io=e=>$i(e,"length",ZE),oi=e=>!!e&&!Number.isNaN(Number(e)),_p=e=>$i(e,"number",oi),vl=e=>!!e&&Number.isInteger(Number(e)),qE=e=>e.endsWith("%")&&oi(e.slice(0,-1)),ot=e=>Yk.test(e),lo=e=>UE.test(e),VE=new Set(["length","size","percentage"]),KE=e=>$i(e,VE,Xk),YE=e=>$i(e,"position",Xk),XE=new Set(["image","url"]),QE=e=>$i(e,XE,tC),JE=e=>$i(e,"",eC),wl=()=>!0,$i=(e,t,s)=>{const r=Yk.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):s(r[2]):!1},ZE=e=>WE.test(e)&&!HE.test(e),Xk=()=>!1,eC=e=>BE.test(e),tC=e=>GE.test(e),$v=()=>{const e=Ct("colors"),t=Ct("spacing"),s=Ct("blur"),r=Ct("brightness"),a=Ct("borderColor"),l=Ct("borderRadius"),c=Ct("borderSpacing"),u=Ct("borderWidth"),d=Ct("contrast"),p=Ct("grayscale"),g=Ct("hueRotate"),y=Ct("invert"),h=Ct("gap"),m=Ct("gradientColorStops"),v=Ct("gradientColorStopPositions"),w=Ct("inset"),k=Ct("margin"),N=Ct("opacity"),A=Ct("padding"),_=Ct("saturate"),S=Ct("scale"),E=Ct("sepia"),T=Ct("skew"),C=Ct("space"),R=Ct("translate"),D=()=>["auto","contain","none"],L=()=>["auto","hidden","clip","visible","scroll"],O=()=>["auto",ot,t],I=()=>[ot,t],W=()=>["",_r,io],U=()=>["auto",oi,ot],J=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],F=()=>["solid","dashed","dotted","double","none"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],z=()=>["start","end","center","between","around","evenly","stretch"],H=()=>["","0",ot],V=()=>["auto","avoid","all","avoid-page","page","left","right","column"],P=()=>[oi,ot];return{cacheSize:500,separator:":",theme:{colors:[wl],spacing:[_r,io],blur:["none","",lo,ot],brightness:P(),borderColor:[e],borderRadius:["none","","full",lo,ot],borderSpacing:I(),borderWidth:W(),contrast:P(),grayscale:H(),hueRotate:P(),invert:H(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[qE,io],inset:O(),margin:O(),opacity:P(),padding:I(),saturate:P(),scale:P(),sepia:H(),skew:P(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",ot]}],container:["container"],columns:[{columns:[lo]}],"break-after":[{"break-after":V()}],"break-before":[{"break-before":V()}],"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:[...J(),ot]}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",vl,ot]}],basis:[{basis:O()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ot]}],grow:[{grow:H()}],shrink:[{shrink:H()}],order:[{order:["first","last","none",vl,ot]}],"grid-cols":[{"grid-cols":[wl]}],"col-start-end":[{col:["auto",{span:["full",vl,ot]},ot]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[wl]}],"row-start-end":[{row:["auto",{span:[vl,ot]},ot]}],"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",ot]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ot]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...z()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...z(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...z(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[A]}],px:[{px:[A]}],py:[{py:[A]}],ps:[{ps:[A]}],pe:[{pe:[A]}],pt:[{pt:[A]}],pr:[{pr:[A]}],pb:[{pb:[A]}],pl:[{pl:[A]}],m:[{m:[k]}],mx:[{mx:[k]}],my:[{my:[k]}],ms:[{ms:[k]}],me:[{me:[k]}],mt:[{mt:[k]}],mr:[{mr:[k]}],mb:[{mb:[k]}],ml:[{ml:[k]}],"space-x":[{"space-x":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ot,t]}],"min-w":[{"min-w":[ot,t,"min","max","fit"]}],"max-w":[{"max-w":[ot,t,"none","full","min","max","fit","prose",{screen:[lo]},lo]}],h:[{h:[ot,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ot,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ot,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ot,t,"auto","min","max","fit"]}],"font-size":[{text:["base",lo,io]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",_p]}],"font-family":[{font:[wl]}],"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",ot]}],"line-clamp":[{"line-clamp":["none",oi,_p]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_r,ot]}],"list-image":[{"list-image":["none",ot]}],"list-style-type":[{list:["none","disc","decimal",ot]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_r,io]}],"underline-offset":[{"underline-offset":["auto",_r,ot]}],"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:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ot]}],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",ot]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...J(),YE]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",KE]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},QE]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[l]}],"rounded-s":[{"rounded-s":[l]}],"rounded-e":[{"rounded-e":[l]}],"rounded-t":[{"rounded-t":[l]}],"rounded-r":[{"rounded-r":[l]}],"rounded-b":[{"rounded-b":[l]}],"rounded-l":[{"rounded-l":[l]}],"rounded-ss":[{"rounded-ss":[l]}],"rounded-se":[{"rounded-se":[l]}],"rounded-ee":[{"rounded-ee":[l]}],"rounded-es":[{"rounded-es":[l]}],"rounded-tl":[{"rounded-tl":[l]}],"rounded-tr":[{"rounded-tr":[l]}],"rounded-br":[{"rounded-br":[l]}],"rounded-bl":[{"rounded-bl":[l]}],"border-w":[{border:[u]}],"border-w-x":[{"border-x":[u]}],"border-w-y":[{"border-y":[u]}],"border-w-s":[{"border-s":[u]}],"border-w-e":[{"border-e":[u]}],"border-w-t":[{"border-t":[u]}],"border-w-r":[{"border-r":[u]}],"border-w-b":[{"border-b":[u]}],"border-w-l":[{"border-l":[u]}],"border-opacity":[{"border-opacity":[N]}],"border-style":[{border:[...F(),"hidden"]}],"divide-x":[{"divide-x":[u]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[u]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[N]}],"divide-style":[{divide:F()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...F()]}],"outline-offset":[{"outline-offset":[_r,ot]}],"outline-w":[{outline:[_r,io]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[_r,io]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",lo,JE]}],"shadow-color":[{shadow:[wl]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...Z(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Z()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",lo,ot]}],grayscale:[{grayscale:[p]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[y]}],saturate:[{saturate:[_]}],sepia:[{sepia:[E]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[p]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[g]}],"backdrop-invert":[{"backdrop-invert":[y]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[_]}],"backdrop-sepia":[{"backdrop-sepia":[E]}],"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",ot]}],duration:[{duration:P()}],ease:[{ease:["linear","in","out","in-out",ot]}],delay:[{delay:P()}],animate:[{animate:["none","spin","ping","pulse","bounce",ot]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[vl,ot]}],"translate-x":[{"translate-x":[R]}],"translate-y":[{"translate-y":[R]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ot]}],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",ot]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"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",ot]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[_r,io,_p]}],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"]}}},nC=(e,{cacheSize:t,prefix:s,separator:r,experimentalParseClassName:a,extend:l={},override:c={}})=>{Rl(e,"cacheSize",t),Rl(e,"prefix",s),Rl(e,"separator",r),Rl(e,"experimentalParseClassName",a);for(const u in c)sC(e[u],c[u]);for(const u in l)rC(e[u],l[u]);return e},Rl=(e,t,s)=>{s!==void 0&&(e[t]=s)},sC=(e,t)=>{if(t)for(const s in t)Rl(e,s,t[s])},rC=(e,t)=>{if(t)for(const s in t){const r=t[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},oC=(e,...t)=>typeof e=="function"?_v($v,e,...t):_v(()=>nC($v(),e),...t),aC=oC({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{spacing:["sidebar","control-sm","control-md","control-lg"]},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"]}]}}}),ie=(...e)=>aC(Gk(e));function iC({value:e,onChange:t,options:s,label:r,name:a,size:l="md",className:c}){return n.jsx("div",{role:"radiogroup","aria-label":r,className:ie("inline-flex",c),children:s.map(u=>n.jsxs("label",{title:u.title,className:ie("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",l==="sm"?"h-control-sm px-2.5 text-label":"h-control-md px-3 text-small",u.disabled?"cursor-not-allowed opacity-45":"cursor-pointer",e===u.value?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[n.jsx("input",{type:"radio",name:a,value:u.value,checked:e===u.value,disabled:u.disabled,onChange:()=>t(u.value),className:"sr-only"}),u.label]},u.value))})}const Rs=e=>lC(e)?e.document:cC(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),cf=e=>{let t=Rs(e);return(t==null?void 0:t.defaultView)??(typeof window<"u"?window:void 0)};function Qk(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function lC(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function cC(e){return Qk(e)&&e.nodeType===9}function uC(e){return Qk(e)&&e.nodeType===11&&"host"in e}let dC=!1;function jg(){return dC}function ta(e,t){var r;if(!jg())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let s=t;for(;s!=null;){if(s===e)return!0;typeof s.assignedElements!="function"&&((r=s.assignedSlot)!=null&&r.parentNode)?s=s.assignedSlot.parentNode:uC(s)?s=s.host:s=s.parentNode}return!1}const jo=(e=document)=>{var s;if(!jg())return e.activeElement;let t=e.activeElement;for(;t&&"shadowRoot"in t&&((s=t.shadowRoot)!=null&&s.activeElement);)t=t.shadowRoot.activeElement;return t};function Ln(e){if(jg()&&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 fC(e){e.focus({preventScroll:!0})}const mC=typeof document<"u"?Oe.useLayoutEffect:()=>{};function Jk(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function pC(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Zk(e){let t=x.useRef({isFocused:!1,observer:null});return mC(()=>{const s=t.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),x.useCallback(s=>{let r=Ln(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){t.current.isFocused=!0;let a=r,l=c=>{if(t.current.isFocused=!1,a.disabled){let u=Jk(c);e==null||e(u)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};a.addEventListener("focusout",l,{once:!0}),t.current.observer=new MutationObserver(()=>{var c;if(t.current.isFocused&&a.disabled){(c=t.current.observer)==null||c.disconnect();let u=a===jo()?null:jo();a.dispatchEvent(new FocusEvent("blur",{relatedTarget:u})),a.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:u}))}}),t.current.observer.observe(a,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function Ng(e){var s;if(typeof window>"u"||window.navigator==null)return!1;let t=(s=window.navigator.userAgentData)==null?void 0:s.brands;return Array.isArray(t)&&t.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function Sg(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function ja(e){let t=null;return()=>(t==null&&(t=e()),t)}const _g=ja(function(){return Sg(/^Mac/i)}),hC=ja(function(){return Sg(/^iPhone/i)}),ej=ja(function(){return Sg(/^iPad/i)||_g()&&navigator.maxTouchPoints>1}),gC=ja(function(){return hC()||ej()}),xC=ja(function(){return Ng(/AppleWebKit/i)&&(gC()||!yC())}),yC=ja(function(){return Ng(/Chrome|CriOS|CrMo/i)}),bC=ja(function(){return Ng(/Android/i)});function vC(e){return e.pointerType===""&&e.isTrusted?!0:bC()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Gl(e,t,s=!0){let{metaKey:r,ctrlKey:a,altKey:l,shiftKey:c}=t,u=xC()&&_g()&&!ej()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:a,altKey:l,shiftKey:c}):new MouseEvent("click",{metaKey:r,ctrlKey:a,altKey:l,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});Gl.isOpening=s,fC(e),e.dispatchEvent(u),Gl.isOpening=!1}Gl.isOpening=!1;let Ei=null;const xh=new Set;let Il=new Map,la=!1,dd=!1;const wC={Tab:!0,Escape:!0};function uf(e,t){for(let s of xh)s(e,t)}function kC(e){return!(e.metaKey||!_g()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Sd(e){la=!0,!Gl.isOpening&&kC(e)&&(Ei="keyboard",uf("keyboard",e))}function ai(e){Ei="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(la=!0,uf("pointer",e))}function tj(e){!Gl.isOpening&&vC(e)&&(la=!0,Ei="virtual")}function nj(e){let t=Ln(e),s=cf(t),r=Rs(t);if(t===s){dd=!0;return}t===r||!e.isTrusted||(!la&&!dd&&(Ei="virtual",uf("virtual",e)),la=!1,dd=!1)}function sj(){la=!1,dd=!0}function rj(e){let t=jo(Rs(Ln(e)));queueMicrotask(()=>{jo(Rs(Ln(e)))!==t&&NC("keyboard")})}function yh(e){if(typeof window>"u"||typeof document>"u")return;const t=cf(e),s=Rs(e);if(Il.get(t))return;let r=t.HTMLElement.prototype.focus;Reflect.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){la=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",Sd,!0),s.addEventListener("keyup",Sd,!0),s.addEventListener("click",tj,!0),s.addEventListener("invalid",rj,!0),t.addEventListener("focus",nj,!0),t.addEventListener("blur",sj,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",ai,!0),s.addEventListener("pointermove",ai,!0),s.addEventListener("pointerup",ai,!0)),t.addEventListener("beforeunload",()=>{oj(e)},{once:!0}),Il.set(t,{focus:r})}const oj=(e,t)=>{const s=cf(e),r=Rs(e);t&&r.removeEventListener("DOMContentLoaded",t),Il.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:Il.get(s).focus}),r.removeEventListener("keydown",Sd,!0),r.removeEventListener("keyup",Sd,!0),r.removeEventListener("click",tj,!0),r.removeEventListener("invalid",rj,!0),s.removeEventListener("focus",nj,!0),s.removeEventListener("blur",sj,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",ai,!0),r.removeEventListener("pointermove",ai,!0),r.removeEventListener("pointerup",ai,!0)),Il.delete(s))};function jC(e){const t=Rs(e);let s;return t.readyState!=="loading"?yh(e):(s=()=>{yh(e)},t.addEventListener("DOMContentLoaded",s)),()=>oj(e,s)}typeof document<"u"&&jC();function bh(){return Ei!=="pointer"}function NC(e){Ei=e,uf(e,null)}const SC=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function _C(e,t,s){let r=s?Ln(s):void 0,a=Rs(r),l=cf(r);const c=typeof l<"u"?l.HTMLInputElement:HTMLInputElement,u=typeof l<"u"?l.HTMLTextAreaElement:HTMLTextAreaElement,d=typeof l<"u"?l.HTMLElement:HTMLElement,p=typeof l<"u"?l.KeyboardEvent:KeyboardEvent;let g=jo(a);return e=e||g instanceof c&&!SC.has(g.type)||g instanceof u||g instanceof d&&g.isContentEditable,!(e&&t==="keyboard"&&s instanceof p&&!wC[s.key])}function $C(e,t,s){yh(),x.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(a,l)=>{_C(!!(s!=null&&s.isTextInput),a,l)&&e(bh())};return xh.add(r),()=>{xh.delete(r)}},t)}function EC(e){let{isDisabled:t,onFocus:s,onBlur:r,onFocusChange:a}=e;const l=x.useCallback(d=>{if(Ln(d)===d.currentTarget)return r&&r(d),a&&a(!1),!0},[r,a]),c=Zk(l),u=x.useCallback(d=>{let p=Ln(d);const g=Rs(p),y=g?jo(g):jo();p===d.currentTarget&&p===y&&(s&&s(d),a&&a(!0),c(d))},[a,s,c]);return{focusProps:{onFocus:!t&&(s||a||r)?u:void 0,onBlur:!t&&(r||a)?l:void 0}}}function aj(){let e=x.useRef(new Map),t=x.useCallback((a,l,c,u)=>{let d=u!=null&&u.once?(...p)=>{e.current.delete(c),c(...p)}:c;e.current.set(c,{type:l,eventTarget:a,fn:d,options:u}),a.addEventListener(l,d,u)},[]),s=x.useCallback((a,l,c,u)=>{var p;let d=((p=e.current.get(c))==null?void 0:p.fn)||c;a.removeEventListener(l,d,u),e.current.delete(c)},[]),r=x.useCallback(()=>{e.current.forEach((a,l)=>{s(a.eventTarget,a.type,l,a.options)})},[s]);return x.useEffect(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:r}}function CC(e){let{isDisabled:t,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:a}=e,l=x.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:u}=aj(),d=x.useCallback(y=>{ta(y.currentTarget,Ln(y))&&l.current.isFocusWithin&&!ta(y.currentTarget,y.relatedTarget)&&(l.current.isFocusWithin=!1,u(),s&&s(y),a&&a(!1))},[s,a,l,u]),p=Zk(d),g=x.useCallback(y=>{if(!ta(y.currentTarget,Ln(y)))return;let h=Ln(y);const m=Rs(h),v=jo(m);if(!l.current.isFocusWithin&&v===h){r&&r(y),a&&a(!0),l.current.isFocusWithin=!0,p(y);let w=y.currentTarget;c(m,"focus",k=>{let N=Ln(k);if(l.current.isFocusWithin&&!ta(w,N)){let A=new m.defaultView.FocusEvent("blur",{relatedTarget:N});pC(A,w);let _=Jk(A);d(_)}},{capture:!0})}},[r,a,p,c,d]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:g,onBlur:d}}}function TC(e={}){let{autoFocus:t=!1,isTextInput:s,within:r}=e,a=x.useRef({isFocused:!1,isFocusVisible:t||bh()}),[l,c]=x.useState(!1),[u,d]=x.useState(()=>a.current.isFocused&&a.current.isFocusVisible),p=x.useCallback(()=>d(a.current.isFocused&&a.current.isFocusVisible),[]),g=x.useCallback(m=>{a.current.isFocused=m,a.current.isFocusVisible=bh(),c(m),p()},[p]);$C(m=>{a.current.isFocusVisible=m,p()},[s,l],{enabled:l,isTextInput:s});let{focusProps:y}=EC({isDisabled:r,onFocusChange:g}),{focusWithinProps:h}=CC({isDisabled:!r,onFocusWithinChange:g});return{isFocused:l,isFocusVisible:u,focusProps:r?h:y}}var fr=Ek();let vh=!1,Uu=0;function RC(){vh=!0,setTimeout(()=>{vh=!1},500)}function Ev(e){e.pointerType==="touch"&&RC()}function AC(){let e=Rs(null);if(!(typeof e>"u"))return Uu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",Ev),Uu++,()=>{Uu--,!(Uu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",Ev)}}function OC(e){let{onHoverStart:t,onHoverChange:s,onHoverEnd:r,isDisabled:a}=e,[l,c]=x.useState(!1),u=x.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;x.useEffect(AC,[]);let{addGlobalListener:d,removeAllGlobalListeners:p}=aj(),{hoverProps:g,triggerHoverEnd:y}=x.useMemo(()=>{let h=(w,k)=>{if(u.pointerType=k,a||k==="touch"||u.isHovered||!ta(w.currentTarget,Ln(w)))return;u.isHovered=!0;let N=w.currentTarget;u.target=N,d(Rs(Ln(w)),"pointerover",A=>{u.isHovered&&u.target&&!ta(u.target,Ln(A))&&m(A,A.pointerType)},{capture:!0}),t&&t({type:"hoverstart",target:N,pointerType:k}),s&&s(!0),c(!0)},m=(w,k)=>{let N=u.target;u.pointerType="",u.target=null,!(k==="touch"||!u.isHovered||!N)&&(u.isHovered=!1,p(),r&&r({type:"hoverend",target:N,pointerType:k}),s&&s(!1),c(!1))},v={};return typeof PointerEvent<"u"&&(v.onPointerEnter=w=>{vh&&w.pointerType==="mouse"||h(w,w.pointerType)},v.onPointerLeave=w=>{!a&&ta(w.currentTarget,Ln(w))&&m(w,w.pointerType)}),{hoverProps:v,triggerHoverEnd:m}},[t,s,r,a,u,d,p]);return x.useEffect(()=>{a&&y({currentTarget:u.target},u.pointerType)},[a]),{hoverProps:g,isHovered:l}}var MC=Object.defineProperty,LC=(e,t,s)=>t in e?MC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,$p=(e,t,s)=>(LC(e,typeof t!="symbol"?t+"":t,s),s);let PC=class{constructor(){$p(this,"current",this.detect()),$p(this,"handoffState","pending"),$p(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}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"}},cr=new PC;function Ci(e){var t;return cr.isServer?null:e==null?document:(t=e==null?void 0:e.ownerDocument)!=null?t:document}function _d(e){var t,s;return cr.isServer?null:e==null?document:(s=(t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))!=null?s:document}function ij(e){var t,s;return(s=(t=_d(e))==null?void 0:t.activeElement)!=null?s:null}function lj(e){return ij(e)===e}function df(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function us(){let e=[],t={addEventListener(s,r,a,l){return s.addEventListener(r,a,l),t.add(()=>s.removeEventListener(r,a,l))},requestAnimationFrame(...s){let r=requestAnimationFrame(...s);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...s){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...s))},setTimeout(...s){let r=setTimeout(...s);return t.add(()=>clearTimeout(r))},microTask(...s){let r={current:!0};return df(()=>{r.current&&s[0]()}),t.add(()=>{r.current=!1})},style(s,r,a){let l=s.style.getPropertyValue(r);return Object.assign(s.style,{[r]:a}),this.add(()=>{Object.assign(s.style,{[r]:l})})},group(s){let r=us();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 a of e.splice(r,1))a()}},dispose(){for(let s of e.splice(0))s()}};return t}function _o(){let[e]=x.useState(us);return x.useEffect(()=>()=>e.dispose(),[e]),e}let Pt=(e,t)=>{cr.isServer?x.useEffect(e,t):x.useLayoutEffect(e,t)};function $o(e){let t=x.useRef(e);return Pt(()=>{t.current=e},[e]),t}let Qe=function(e){let t=$o(e);return Oe.useCallback((...s)=>t.current(...s),[t])};function IC(e){let t=e.width/2,s=e.height/2;return{top:e.clientY-s,right:e.clientX+t,bottom:e.clientY+s,left:e.clientX-t}}function zC(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function DC({disabled:e=!1}={}){let t=x.useRef(null),[s,r]=x.useState(!1),a=_o(),l=Qe(()=>{t.current=null,r(!1),a.dispose()}),c=Qe(u=>{if(a.dispose(),t.current===null){t.current=u.currentTarget,r(!0);{let d=Ci(u.currentTarget);a.addEventListener(d,"pointerup",l,!1),a.addEventListener(d,"pointermove",p=>{if(t.current){let g=IC(p);r(zC(g,t.current.getBoundingClientRect()))}},!1),a.addEventListener(d,"pointercancel",l,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:c,onPointerUp:l,onClick:l}}}function As(e){return x.useMemo(()=>e,Object.values(e))}let FC=x.createContext(void 0);function $g(){return x.useContext(FC)}function wh(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function zn(e,t,...s){if(e in t){let a=t[e];return typeof a=="function"?a(...s):a}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(a=>`"${a}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,zn),r}var bi=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(bi||{}),xo=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(xo||{});function cn(){let e=WC();return x.useCallback(t=>UC({mergeRefs:e,...t}),[e])}function UC({ourProps:e,theirProps:t,slot:s,defaultTag:r,features:a,visible:l=!0,name:c,mergeRefs:u}){u=u??HC;let d=cj(t,e);if(l)return Wu(d,s,r,c,u);let p=a??0;if(p&2){let{static:g=!1,...y}=d;if(g)return Wu(y,s,r,c,u)}if(p&1){let{unmount:g=!0,...y}=d;return zn(g?0:1,{0(){return null},1(){return Wu({...y,hidden:!0,style:{display:"none"}},s,r,c,u)}})}return Wu(d,s,r,c,u)}function Wu(e,t={},s,r,a){let{as:l=s,children:c,refName:u="ref",...d}=Ep(e,["unmount","static"]),p=e.ref!==void 0?{[u]:e.ref}:{},g=typeof c=="function"?c(t):c;g=dj(g),"className"in d&&d.className&&typeof d.className=="function"&&(d.className=d.className(t)),d["aria-labelledby"]&&d["aria-labelledby"]===d.id&&(d["aria-labelledby"]=void 0);let y={};if(t){let h=!1,m=[];for(let[v,w]of Object.entries(t))typeof w=="boolean"&&(h=!0),w===!0&&m.push(v.replace(/([A-Z])/g,k=>`-${k.toLowerCase()}`));if(h){y["data-headlessui-state"]=m.join(" ");for(let v of m)y[`data-${v}`]=""}}if(zl(l)&&(Object.keys(po(d)).length>0||Object.keys(po(y)).length>0))if(!x.isValidElement(g)||Array.isArray(g)&&g.length>1||GC(g)){if(Object.keys(po(d)).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(po(d)).concat(Object.keys(po(y))).map(h=>` - ${h}`).join(`
456
+ `),"","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(h=>` - ${h}`).join(`
457
+ `)].join(`
458
+ `))}else{let h=g.props,m=h==null?void 0:h.className,v=typeof m=="function"?(...N)=>wh(m(...N),d.className):wh(m,d.className),w=v?{className:v}:{},k=cj(g.props,po(Ep(d,["ref"])));for(let N in y)N in k&&delete y[N];return x.cloneElement(g,Object.assign({},k,y,p,{ref:a(BC(g),p.ref)},w))}return x.createElement(l,Object.assign({},Ep(d,["ref"]),!zl(l)&&p,!zl(l)&&y),g)}function WC(){let e=x.useRef([]),t=x.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,t}}function HC(...e){return e.every(t=>t==null)?void 0:t=>{for(let s of e)s!=null&&(typeof s=="function"?s(t):s.current=t)}}function cj(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},s={};for(let r of e)for(let a in r)a.startsWith("on")&&typeof r[a]=="function"?(s[a]!=null||(s[a]=[]),s[a].push(r[a])):t[a]=r[a];if(t.disabled||t["aria-disabled"])for(let r in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(s[r]=[a=>{var l;return(l=a==null?void 0:a.preventDefault)==null?void 0:l.call(a)}]);for(let r in s)Object.assign(t,{[r](a,...l){let c=s[r];for(let u of c){if((a instanceof Event||(a==null?void 0:a.nativeEvent)instanceof Event)&&a.defaultPrevented)return;u(a,...l)}}});return t}function uj(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},s={};for(let r of e)for(let a in r)a.startsWith("on")&&typeof r[a]=="function"?(s[a]!=null||(s[a]=[]),s[a].push(r[a])):t[a]=r[a];for(let r in s)Object.assign(t,{[r](...a){let l=s[r];for(let c of l)c==null||c(...a)}});return t}function Yt(e){var t;return Object.assign(x.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function po(e){let t=Object.assign({},e);for(let s in t)t[s]===void 0&&delete t[s];return t}function Ep(e,t=[]){let s=Object.assign({},e);for(let r of t)r in s&&delete s[r];return s}function BC(e){return Oe.version.split(".")[0]>="19"?e.props.ref:e.ref}function dj(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let t=e._payload;if(t!=null&&t.status==="fulfilled")return dj(t.value)}return e}function zl(e){return e===x.Fragment||e===Symbol.for("react.fragment")}function GC(e){return zl(e.type)}function qC(e,t,s){let[r,a]=x.useState(s),l=e!==void 0,c=x.useRef(l),u=x.useRef(!1),d=x.useRef(!1);return l&&!c.current&&!u.current?(u.current=!0,c.current=l,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.")):!l&&c.current&&!d.current&&(d.current=!0,c.current=l,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.")),[l?e:r,Qe(p=>(l||fr.flushSync(()=>a(p)),t==null?void 0:t(p)))]}function VC(e){let[t]=x.useState(e);return t}function fj(e={},t=null,s=[]){for(let[r,a]of Object.entries(e))pj(s,mj(t,r),a);return s}function mj(e,t){return e?e+"["+t+"]":t}function pj(e,t,s){if(Array.isArray(s))for(let[r,a]of s.entries())pj(e,mj(t,r.toString()),a);else s instanceof Date?e.push([t,s.toISOString()]):typeof s=="boolean"?e.push([t,s?"1":"0"]):typeof s=="string"?e.push([t,s]):typeof s=="number"?e.push([t,`${s}`]):s==null?e.push([t,""]):YC(s)&&!x.isValidElement(s)&&fj(s,t,e)}function KC(e){var t,s;let r=(t=e==null?void 0:e.form)!=null?t:e.closest("form");if(r){for(let a of r.elements)if(a!==e&&(a.tagName==="INPUT"&&a.type==="submit"||a.tagName==="BUTTON"&&a.type==="submit"||a.nodeName==="INPUT"&&a.type==="image")){a.click();return}(s=r.requestSubmit)==null||s.call(r)}}function YC(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}let XC="span";var vi=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(vi||{});function QC(e,t){var s;let{features:r=1,...a}=e,l={ref:t,"aria-hidden":(r&2)===2?!0:(s=a["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 cn()({ourProps:l,theirProps:a,slot:{},defaultTag:XC,name:"Hidden"})}let ql=Yt(QC),JC=x.createContext(null);function ZC({children:e}){let t=x.useContext(JC);if(!t)return Oe.createElement(Oe.Fragment,null,e);let{target:s}=t;return s?fr.createPortal(Oe.createElement(Oe.Fragment,null,e),s):null}function eT({data:e,form:t,disabled:s,onReset:r,overrides:a}){let[l,c]=x.useState(null),u=_o();return x.useEffect(()=>{if(r&&l)return u.addEventListener(l,"reset",r)},[l,t,r]),Oe.createElement(ZC,null,Oe.createElement(tT,{setForm:c,formId:t}),fj(e).map(([d,p])=>Oe.createElement(ql,{features:vi.Hidden,...po({key:d,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:t,disabled:s,name:d,value:p,...a})})))}function tT({setForm:e,formId:t}){return x.useEffect(()=>{if(t){let s=document.getElementById(t);s&&e(s)}},[e,t]),t?null:Oe.createElement(ql,{features:vi.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let nT=x.createContext(void 0);function hj(){return x.useContext(nT)}function gj(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function Ar(e){return gj(e)&&"tagName"in e}function is(e){return Ar(e)&&"accessKey"in e}function Tr(e){return Ar(e)&&"tabIndex"in e}function sT(e){return Ar(e)&&"style"in e}function rT(e){return is(e)&&e.nodeName==="IFRAME"}function xj(e){return is(e)&&e.nodeName==="INPUT"}function Cv(e){return is(e)&&e.nodeName==="LABEL"}function oT(e){return is(e)&&e.nodeName==="FIELDSET"}function yj(e){return is(e)&&e.nodeName==="LEGEND"}function aT(e){return Ar(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function Tv(e){let t=e.parentElement,s=null;for(;t&&!oT(t);)yj(t)&&(s=t),t=t.parentElement;let r=(t==null?void 0:t.getAttribute("disabled"))==="";return r&&iT(s)?!1:r}function iT(e){if(!e)return!1;let t=e.previousElementSibling;for(;t!==null;){if(yj(t))return!1;t=t.previousElementSibling}return!0}let bj=Symbol();function lT(e,t=!0){return Object.assign(e,{[bj]:t})}function En(...e){let t=x.useRef(e);x.useEffect(()=>{t.current=e},[e]);let s=Qe(r=>{for(let a of t.current)a!=null&&(typeof a=="function"?a(r):a.current=r)});return e.every(r=>r==null||(r==null?void 0:r[bj]))?void 0:s}let ff=x.createContext(null);ff.displayName="DescriptionContext";function vj(){let e=x.useContext(ff);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,vj),t}return e}function cT(){var e,t;return(t=(e=x.useContext(ff))==null?void 0:e.value)!=null?t:void 0}function uT(){let[e,t]=x.useState([]);return[e.length>0?e.join(" "):void 0,x.useMemo(()=>function(s){let r=Qe(l=>(t(c=>[...c,l]),()=>t(c=>{let u=c.slice(),d=u.indexOf(l);return d!==-1&&u.splice(d,1),u}))),a=x.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 Oe.createElement(ff.Provider,{value:a},s.children)},[t])]}let dT="p";function fT(e,t){let s=x.useId(),r=$g(),{id:a=`headlessui-description-${s}`,...l}=e,c=vj(),u=En(t);Pt(()=>c.register(a),[a,c.register]);let d=As({...c.slot,disabled:r||!1}),p={ref:u,...c.props,id:a};return cn()({ourProps:p,theirProps:l,slot:d,defaultTag:dT,name:c.name||"Description"})}let mT=Yt(fT),wj=Object.assign(mT,{});var en=(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))(en||{});let mf=x.createContext(null);mf.displayName="LabelContext";function kj(){let e=x.useContext(mf);if(e===null){let t=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,kj),t}return e}function jj(e){var t,s,r;let a=(s=(t=x.useContext(mf))==null?void 0:t.value)!=null?s:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[a,...e].filter(Boolean).join(" "):a}function pT({inherit:e=!1}={}){let t=jj(),[s,r]=x.useState([]),a=e?[t,...s].filter(Boolean):s;return[a.length>0?a.join(" "):void 0,x.useMemo(()=>function(l){let c=Qe(d=>(r(p=>[...p,d]),()=>r(p=>{let g=p.slice(),y=g.indexOf(d);return y!==-1&&g.splice(y,1),g}))),u=x.useMemo(()=>({register:c,slot:l.slot,name:l.name,props:l.props,value:l.value}),[c,l.slot,l.name,l.props,l.value]);return Oe.createElement(mf.Provider,{value:u},l.children)},[r])]}let hT="label";function gT(e,t){var s;let r=x.useId(),a=kj(),l=hj(),c=$g(),{id:u=`headlessui-label-${r}`,htmlFor:d=l??((s=a.props)==null?void 0:s.htmlFor),passive:p=!1,...g}=e,y=En(t);Pt(()=>a.register(u),[u,a.register]);let h=Qe(w=>{let k=w.currentTarget;if(!(w.target!==w.currentTarget&&aT(w.target))&&(Cv(k)&&w.preventDefault(),a.props&&"onClick"in a.props&&typeof a.props.onClick=="function"&&a.props.onClick(w),Cv(k))){let N=document.getElementById(k.htmlFor);if(N){let A=N.getAttribute("disabled");if(A==="true"||A==="")return;let _=N.getAttribute("aria-disabled");if(_==="true"||_==="")return;(xj(N)&&(N.type==="file"||N.type==="radio"||N.type==="checkbox")||N.role==="radio"||N.role==="checkbox"||N.role==="switch")&&N.click(),N.focus({preventScroll:!0})}}}),m=As({...a.slot,disabled:c||!1}),v={ref:y,...a.props,id:u,htmlFor:d,onClick:h};return p&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in g&&delete g.onClick),cn()({ourProps:v,theirProps:g,slot:m,defaultTag:d?hT:"div",name:a.name||"Label"})}let xT=Yt(gT),yT=Object.assign(xT,{}),bT=x.createContext(()=>{});function vT({value:e,children:t}){return Oe.createElement(bT.Provider,{value:e},t)}function wT(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function kT(e=wT){return x.useCallback((t,s)=>{if(typeof e=="string"){let r=e;return(t==null?void 0:t[r])===(s==null?void 0:s[r])}return e(t,s)},[e])}function Rv(e){if(e===null)return{width:0,height:0};let{width:t,height:s}=e.getBoundingClientRect();return{width:t,height:s}}function jT(e,t,s=!1){let[r,a]=x.useState(()=>Rv(t));return Pt(()=>{if(!t||!e)return;let l=us();return l.requestAnimationFrame(function c(){l.requestAnimationFrame(c),a(u=>{let d=Rv(t);return d.width===u.width&&d.height===u.height?u:d})}),()=>{l.dispose()}},[t,e]),s?{width:`${r.width}px`,height:`${r.height}px`}:r}var Nj=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(Nj||{});function NT(e){let t=x.useRef(null),s=Qe(a=>{t.current=a.pointerType,!Tv(a.currentTarget)&&a.pointerType==="mouse"&&a.button===Nj.Left&&(a.preventDefault(),e(a))}),r=Qe(a=>{t.current!=="mouse"&&(Tv(a.currentTarget)||e(a))});return{onPointerDown:s,onClick:r}}let Sj=class extends Map{constructor(t){super(),this.factory=t}get(t){let s=super.get(t);return s===void 0&&(s=this.factory(t),this.set(t,s)),s}};var ST=Object.defineProperty,_T=(e,t,s)=>t in e?ST(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,$T=(e,t,s)=>(_T(e,t+"",s),s),_j=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)},js=(e,t,s)=>(_j(e,t,"read from private field"),s?s.call(e):t.get(e)),Cp=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},Av=(e,t,s,r)=>(_j(e,t,"write to private field"),t.set(e,s),s),ar,Al,Ol;let $j=class{constructor(t){Cp(this,ar,{}),Cp(this,Al,new Sj(()=>new Set)),Cp(this,Ol,new Set),$T(this,"disposables",us()),Av(this,ar,t),cr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return js(this,ar)}subscribe(t,s){if(cr.isServer)return()=>{};let r={selector:t,callback:s,current:t(js(this,ar))};return js(this,Ol).add(r),this.disposables.add(()=>{js(this,Ol).delete(r)})}on(t,s){return cr.isServer?()=>{}:(js(this,Al).get(t).add(s),this.disposables.add(()=>{js(this,Al).get(t).delete(s)}))}send(t){let s=this.reduce(js(this,ar),t);if(s!==js(this,ar)){Av(this,ar,s);for(let r of js(this,Ol)){let a=r.selector(js(this,ar));Ej(r.current,a)||(r.current=a,r.callback(a))}for(let r of js(this,Al).get(t.type))r(js(this,ar),t)}}};ar=new WeakMap,Al=new WeakMap,Ol=new WeakMap;function Ej(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null?!1:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:Tp(e[Symbol.iterator](),t[Symbol.iterator]()):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?e.size!==t.size?!1:Tp(e.entries(),t.entries()):Ov(e)&&Ov(t)?Tp(Object.entries(e)[Symbol.iterator](),Object.entries(t)[Symbol.iterator]()):!1}function Tp(e,t){do{let s=e.next(),r=t.next();if(s.done&&r.done)return!0;if(s.done||r.done||!Object.is(s.value,r.value))return!1}while(!0)}function Ov(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function Rp(e){let[t,s]=e(),r=us();return(...a)=>{t(...a),r.dispose(),r.microTask(s)}}var ET=Object.defineProperty,CT=(e,t,s)=>t in e?ET(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Mv=(e,t,s)=>(CT(e,typeof t!="symbol"?t+"":t,s),s),Cj=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(Cj||{});let TT={0(e,t){let s=t.id,r=e.stack,a=e.stack.indexOf(s);if(a!==-1){let l=e.stack.slice();return l.splice(a,1),l.push(s),r=l,{...e,stack:r}}return{...e,stack:[...e.stack,s]}},1(e,t){let s=t.id,r=e.stack.indexOf(s);if(r===-1)return e;let a=e.stack.slice();return a.splice(r,1),{...e,stack:a}}},RT=class Tj extends $j{constructor(){super(...arguments),Mv(this,"actions",{push:t=>this.send({type:0,id:t}),pop:t=>this.send({type:1,id:t})}),Mv(this,"selectors",{isTop:(t,s)=>t.stack[t.stack.length-1]===s,inStack:(t,s)=>t.stack.includes(s)})}static new(){return new Tj({stack:[]})}reduce(t,s){return zn(s.type,TT,t,s)}};const pf=new Sj(()=>RT.new());var Ap={exports:{}},Op={};/**
459
+ * @license React
460
+ * use-sync-external-store-with-selector.production.js
461
+ *
462
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
463
+ *
464
+ * This source code is licensed under the MIT license found in the
465
+ * LICENSE file in the root directory of this source tree.
466
+ */var Lv;function AT(){if(Lv)return Op;Lv=1;var e=of();function t(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var s=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,a=e.useRef,l=e.useEffect,c=e.useMemo,u=e.useDebugValue;return Op.useSyncExternalStoreWithSelector=function(d,p,g,y,h){var m=a(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=c(function(){function k(E){if(!N){if(N=!0,A=E,E=y(E),h!==void 0&&v.hasValue){var T=v.value;if(h(T,E))return _=T}return _=E}if(T=_,s(A,E))return T;var C=y(E);return h!==void 0&&h(T,C)?(A=E,T):(A=E,_=C)}var N=!1,A,_,S=g===void 0?null:g;return[function(){return k(p())},S===null?void 0:function(){return k(S())}]},[p,g,y,h]);var w=r(d,m[0],m[1]);return l(function(){v.hasValue=!0,v.value=w},[w]),u(w),w},Op}var Pv;function OT(){return Pv||(Pv=1,Ap.exports=AT()),Ap.exports}var MT=OT();function Mn(e,t,s=Ej){return MT.useSyncExternalStoreWithSelector(Qe(r=>e.subscribe(LT,r)),Qe(()=>e.state),Qe(()=>e.state),Qe(t),s)}function LT(e){return e}function mc(e,t){let s=x.useId(),r=pf.get(t),[a,l]=Mn(r,x.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return Pt(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?l?a:!0:!1}let kh=new Map,Dl=new Map;function Iv(e){var t;let s=(t=Dl.get(e))!=null?t:0;return Dl.set(e,s+1),s!==0?()=>zv(e):(kh.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>zv(e))}function zv(e){var t;let s=(t=Dl.get(e))!=null?t:1;if(s===1?Dl.delete(e):Dl.set(e,s-1),s!==1)return;let r=kh.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,kh.delete(e))}function Rj(e,{allowed:t,disallowed:s}={}){let r=mc(e,"inert-others");Pt(()=>{var a,l;if(!r)return;let c=us();for(let d of(a=s==null?void 0:s())!=null?a:[])d&&c.add(Iv(d));let u=(l=t==null?void 0:t())!=null?l:[];for(let d of u){if(!d)continue;let p=Ci(d);if(!p)continue;let g=d.parentElement;for(;g&&g!==p.body;){for(let y of g.children)u.some(h=>y.contains(h))||c.add(Iv(y));g=g.parentElement}}return c.dispose},[r,t,s])}function Aj(e,t,s){let r=$o(a=>{let l=a.getBoundingClientRect();l.x===0&&l.y===0&&l.width===0&&l.height===0&&s()});x.useEffect(()=>{if(!e)return;let a=t===null?null:is(t)?t:t.current;if(!a)return;let l=us();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>r.current(a));c.observe(a),l.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>r.current(a));c.observe(a),l.add(()=>c.disconnect())}return()=>l.dispose()},[t,r,e])}let $d=["[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(","),PT=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var Ks=(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))(Ks||{}),jh=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(jh||{}),IT=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(IT||{});function Oj(e=document.body){return e==null?[]:Array.from(e.querySelectorAll($d)).sort((t,s)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function zT(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(PT)).sort((t,s)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var Eg=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Eg||{});function Mj(e,t=0){var s;return e===((s=Ci(e))==null?void 0:s.body)?!1:zn(t,{0(){return e.matches($d)},1(){let r=e;for(;r!==null;){if(r.matches($d))return!0;r=r.parentElement}return!1}})}var DT=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(DT||{});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 Or(e){e==null||e.focus({preventScroll:!0})}let FT=["textarea","input"].join(",");function UT(e){var t,s;return(s=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,FT))!=null?s:!1}function Lj(e,t=s=>s){return e.slice().sort((s,r)=>{let a=t(s),l=t(r);if(a===null||l===null)return 0;let c=a.compareDocumentPosition(l);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function WT(e,t,s=e===null?document.body:_d(e)){return ii(Oj(s),t,{relativeTo:e})}function ii(e,t,{sorted:s=!0,relativeTo:r=null,skipElements:a=[]}={}){let l=Array.isArray(e)?e.length>0?_d(e[0]):document:_d(e),c=Array.isArray(e)?s?Lj(e):e:t&64?zT(e):Oj(e);a.length>0&&c.length>1&&(c=c.filter(m=>!a.some(v=>v!=null&&"current"in v?(v==null?void 0:v.current)===m:v===m))),r=r??(l==null?void 0:l.activeElement);let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,c.indexOf(r))-1;if(t&4)return Math.max(0,c.indexOf(r))+1;if(t&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),p=t&32?{preventScroll:!0}:{},g=0,y=c.length,h;do{if(g>=y||g+y<=0)return 0;let m=d+g;if(t&16)m=(m+y)%y;else{if(m<0)return 3;if(m>=y)return 1}h=c[m],h==null||h.focus(p),g+=u}while(h!==ij(h));return t&6&&UT(h)&&h.select(),2}function Pj(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function HT(){return/Android/gi.test(window.navigator.userAgent)}function Dv(){return Pj()||HT()}function ti(e,t,s,r){let a=$o(s);x.useEffect(()=>{if(!e)return;function l(c){a.current(c)}return document.addEventListener(t,l,r),()=>document.removeEventListener(t,l,r)},[e,t,r])}function Ij(e,t,s,r){let a=$o(s);x.useEffect(()=>{if(!e)return;function l(c){a.current(c)}return window.addEventListener(t,l,r),()=>window.removeEventListener(t,l,r)},[e,t,r])}const Fv=30;function zj(e,t,s){let r=$o(s),a=x.useCallback(function(u,d){if(u.defaultPrevented)return;let p=d(u);if(p===null||!p.getRootNode().contains(p)||!p.isConnected)return;let g=(function y(h){return typeof h=="function"?y(h()):Array.isArray(h)||h instanceof Set?h:[h]})(t);for(let y of g)if(y!==null&&(y.contains(p)||u.composed&&u.composedPath().includes(y)))return;return!Mj(p,Eg.Loose)&&p.tabIndex!==-1&&u.preventDefault(),r.current(u,p)},[r,t]),l=x.useRef(null);ti(e,"pointerdown",u=>{var d,p;Dv()||(l.current=((p=(d=u.composedPath)==null?void 0:d.call(u))==null?void 0:p[0])||u.target)},!0),ti(e,"pointerup",u=>{if(Dv()||!l.current)return;let d=l.current;return l.current=null,a(u,()=>d)},!0);let c=x.useRef({x:0,y:0});ti(e,"touchstart",u=>{c.current.x=u.touches[0].clientX,c.current.y=u.touches[0].clientY},!0),ti(e,"touchend",u=>{let d={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(d.x-c.current.x)>=Fv||Math.abs(d.y-c.current.y)>=Fv))return a(u,()=>Tr(u.target)?u.target:null)},!0),Ij(e,"blur",u=>a(u,()=>rT(window.document.activeElement)?window.document.activeElement:null),!0)}function Vl(...e){return x.useMemo(()=>Ci(...e),[...e])}var BT=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(BT||{});const Hu={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},GT=200,Uv=5;function qT(e,{trigger:t,action:s,close:r,select:a}){let l=x.useRef(null),c=x.useRef(null),u=x.useRef(null);ti(e&&t!==null,"pointerdown",d=>{gj(d==null?void 0:d.target)&&t!=null&&t.contains(d.target)&&(c.current=d.x,u.current=d.y,l.current=d.timeStamp)}),ti(e&&t!==null,"pointerup",d=>{var p,g;let y=l.current;if(y===null||(l.current=null,!Tr(d.target))||Math.abs(d.x-((p=c.current)!=null?p:d.x))<Uv&&Math.abs(d.y-((g=u.current)!=null?g:d.y))<Uv)return;let h=s(d);switch(h.kind){case 0:return;case 1:{d.timeStamp-y>GT&&(a(h.target),r());break}case 2:{r();break}}},{capture:!0})}function Dj(e,t,s,r){let a=$o(s);x.useEffect(()=>{e=e??window;function l(c){a.current(c)}return e.addEventListener(t,l,r),()=>e.removeEventListener(t,l,r)},[e,t,r])}function VT(e,t){return x.useMemo(()=>{var s;if(e.type)return e.type;let r=(s=e.as)!=null?s:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(t==null?void 0:t.tagName)==="BUTTON"&&!t.hasAttribute("type"))return"button"},[e.type,e.as,t])}function KT(e){return x.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function YT(e,t){let s=e(),r=new Set;return{getSnapshot(){return s},subscribe(a){return r.add(a),()=>r.delete(a)},dispatch(a,...l){let c=t[a].call(s,...l);c&&(s=c,r.forEach(u=>u()))}}}function XT(){let e;return{before({doc:t}){var s;let r=t.documentElement,a=(s=t.defaultView)!=null?s:window;e=Math.max(0,a.innerWidth-r.clientWidth)},after({doc:t,d:s}){let r=t.documentElement,a=Math.max(0,r.clientWidth-r.offsetWidth),l=Math.max(0,e-a);s.style(r,"paddingRight",`${l}px`)}}}function QT(){return Pj()?{before({doc:e,d:t,meta:s}){function r(a){for(let l of s().containers)for(let c of l())if(c.contains(a))return!0;return!1}t.microTask(()=>{var a;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=us();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let l=(a=window.scrollY)!=null?a:window.pageYOffset,c=null;t.addEventListener(e,"click",u=>{if(Tr(u.target))try{let d=u.target.closest("a");if(!d)return;let{hash:p}=new URL(d.href),g=e.querySelector(p);Tr(g)&&!r(g)&&(c=g)}catch{}},!0),t.group(u=>{t.addEventListener(e,"touchstart",d=>{if(u.dispose(),Tr(d.target)&&sT(d.target))if(r(d.target)){let p=d.target;for(;p.parentElement&&r(p.parentElement);)p=p.parentElement;u.style(p,"overscrollBehavior","contain")}else u.style(d.target,"touchAction","none")})}),t.addEventListener(e,"touchmove",u=>{if(Tr(u.target)){if(xj(u.target))return;if(r(u.target)){let d=u.target;for(;d.parentElement&&d.dataset.headlessuiPortal!==""&&!(d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth);)d=d.parentElement;d.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let d=(u=window.scrollY)!=null?u:window.pageYOffset;l!==d&&window.scrollTo(0,l),c&&c.isConnected&&(c.scrollIntoView({block:"nearest"}),c=null)})})}}:{}}function JT(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Wv(e){let t={};for(let s of e)Object.assign(t,s(t));return t}let na=YT(()=>new Map,{PUSH(e,t){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:us(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(t),r.computedMeta=Wv(r.meta),this.set(e,r),this},POP(e,t){let s=this.get(e);return s&&(s.count--,s.meta.delete(t),s.computedMeta=Wv(s.meta)),this},SCROLL_PREVENT(e){let t={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[QT(),XT(),JT()];s.forEach(({before:r})=>r==null?void 0:r(t)),s.forEach(({after:r})=>r==null?void 0:r(t))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});na.subscribe(()=>{let e=na.getSnapshot(),t=new Map;for(let[s]of e)t.set(s,s.documentElement.style.overflow);for(let s of e.values()){let r=t.get(s.doc)==="hidden",a=s.count!==0;(a&&!r||!a&&r)&&na.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&na.dispatch("TEARDOWN",s)}});function ZT(e,t,s=()=>({containers:[]})){let r=KT(na),a=t?r.get(t):void 0,l=a?a.count>0:!1;return Pt(()=>{if(!(!t||!e))return na.dispatch("PUSH",t,s),()=>na.dispatch("POP",t,s)},[e,t]),l}function Fj(e,t,s=()=>[document.body]){let r=mc(e,"scroll-lock");ZT(r,t,a=>{var l;return{containers:[...(l=a.containers)!=null?l:[],s]}})}function Hv(e){return[e.screenX,e.screenY]}function eR(){let e=x.useRef([-1,-1]);return{wasMoved(t){let s=Hv(t);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(t){e.current=Hv(t)}}}function tR(e=0){let[t,s]=x.useState(e),r=x.useCallback(d=>s(d),[]),a=x.useCallback(d=>s(p=>p|d),[]),l=x.useCallback(d=>(t&d)===d,[t]),c=x.useCallback(d=>s(p=>p&~d),[]),u=x.useCallback(d=>s(p=>p^d),[]);return{flags:t,setFlag:r,addFlag:a,hasFlag:l,removeFlag:c,toggleFlag:u}}var nR={},Bv,Gv;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Bv=process==null?void 0:nR)==null?void 0:Bv.NODE_ENV)==="test"&&typeof((Gv=Element==null?void 0:Element.prototype)==null?void 0:Gv.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(`
467
+ `)),[]});var sR=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(sR||{});function Uj(e){let t={};for(let s in e)e[s]===!0&&(t[`data-${s}`]="");return t}function Wj(e,t,s,r){let[a,l]=x.useState(s),{hasFlag:c,addFlag:u,removeFlag:d}=tR(e&&a?3:0),p=x.useRef(!1),g=x.useRef(!1),y=_o();return Pt(()=>{var h;if(e){if(s&&l(!0),!t){s&&u(3);return}return(h=r==null?void 0:r.start)==null||h.call(r,s),rR(t,{inFlight:p,prepare(){g.current?g.current=!1:g.current=p.current,p.current=!0,!g.current&&(s?(u(3),d(4)):(u(4),d(2)))},run(){g.current?s?(d(3),u(4)):(d(4),u(3)):s?d(1):u(1)},done(){var m;g.current&&iR(t)||(p.current=!1,d(7),s||l(!1),(m=r==null?void 0:r.end)==null||m.call(r,s))}})}},[e,s,t,y]),e?[a,{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 rR(e,{prepare:t,run:s,done:r,inFlight:a}){let l=us();return aR(e,{prepare:t,inFlight:a}),l.nextFrame(()=>{s(),l.requestAnimationFrame(()=>{l.add(oR(e,r))})}),l.dispose}function oR(e,t){var s,r;let a=us();if(!e)return a.dispose;let l=!1;a.add(()=>{l=!0});let c=(r=(s=e.getAnimations)==null?void 0:s.call(e).filter(u=>u instanceof CSSTransition))!=null?r:[];return c.length===0?(t(),a.dispose):(Promise.allSettled(c.map(u=>u.finished)).then(()=>{l||t()}),a.dispose)}function aR(e,{inFlight:t,prepare:s}){if(t!=null&&t.current){s();return}let r=e.style.transition;e.style.transition="none",s(),e.offsetHeight,e.style.transition=r}function iR(e){var t,s;return((s=(t=e.getAnimations)==null?void 0:t.call(e))!=null?s:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function Cg(e,t){let s=x.useRef([]),r=Qe(e);x.useEffect(()=>{let a=[...s.current];for(let[l,c]of t.entries())if(s.current[l]!==c){let u=r(t,a);return s.current=t,u}},[r,...t])}function hf(){return typeof window<"u"}function Ti(e){return Hj(e)?(e.nodeName||"").toLowerCase():"#document"}function Xn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ir(e){var t;return(t=(Hj(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Hj(e){return hf()?e instanceof Node||e instanceof Xn(e).Node:!1}function Yn(e){return hf()?e instanceof Element||e instanceof Xn(e).Element:!1}function Eo(e){return hf()?e instanceof HTMLElement||e instanceof Xn(e).HTMLElement:!1}function qv(e){return!hf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xn(e).ShadowRoot}function gf(e){const{overflow:t,overflowX:s,overflowY:r,display:a}=mr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+s)&&a!=="inline"&&a!=="contents"}function lR(e){return/^(table|td|th)$/.test(Ti(e))}function xf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const cR=/transform|translate|scale|rotate|perspective|filter/,uR=/paint|layout|strict|content/,Vo=e=>!!e&&e!=="none";let Mp;function Tg(e){const t=Yn(e)?mr(e):e;return Vo(t.transform)||Vo(t.translate)||Vo(t.scale)||Vo(t.rotate)||Vo(t.perspective)||!Rg()&&(Vo(t.backdropFilter)||Vo(t.filter))||cR.test(t.willChange||"")||uR.test(t.contain||"")}function dR(e){let t=ca(e);for(;Eo(t)&&!Kl(t);){if(Tg(t))return t;if(xf(t))return null;t=ca(t)}return null}function Rg(){return Mp==null&&(Mp=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Mp}function Kl(e){return/^(html|body|#document)$/.test(Ti(e))}function mr(e){return Xn(e).getComputedStyle(e)}function yf(e){return Yn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ca(e){if(Ti(e)==="html")return e;const t=e.assignedSlot||e.parentNode||qv(e)&&e.host||Ir(e);return qv(t)?t.host:t}function Bj(e){const t=ca(e);return Kl(t)?(e.ownerDocument||e).body:Eo(t)&&gf(t)?t:Bj(t)}function Yl(e,t,s){var r;t===void 0&&(t=[]),s===void 0&&(s=!0);const a=Bj(e),l=a===((r=e.ownerDocument)==null?void 0:r.body),c=Xn(a);if(l){const u=Nh(c);return t.concat(c,c.visualViewport||[],gf(a)?a:[],u&&s?Yl(u):[])}else return t.concat(a,Yl(a,[],s))}function Nh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fR(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:s,version:r}=t;return s+"/"+r}).join(" "):navigator.userAgent}const ua=Math.min,Cs=Math.max,Xl=Math.round,Bu=Math.floor,Mr=e=>({x:e,y:e}),mR={left:"right",right:"left",bottom:"top",top:"bottom"};function pR(e,t,s){return Cs(e,ua(t,s))}function Ri(e,t){return typeof e=="function"?e(t):e}function da(e){return e.split("-")[0]}function pc(e){return e.split("-")[1]}function Gj(e){return e==="x"?"y":"x"}function qj(e){return e==="y"?"height":"width"}function Rr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Vj(e){return Gj(Rr(e))}function hR(e,t,s){s===void 0&&(s=!1);const r=pc(e),a=Vj(e),l=qj(a);let c=a==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=Ed(c)),[c,Ed(c)]}function gR(e){const t=Ed(e);return[Sh(e),t,Sh(t)]}function Sh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Vv=["left","right"],Kv=["right","left"],xR=["top","bottom"],yR=["bottom","top"];function bR(e,t,s){switch(e){case"top":case"bottom":return s?t?Kv:Vv:t?Vv:Kv;case"left":case"right":return t?xR:yR;default:return[]}}function vR(e,t,s,r){const a=pc(e);let l=bR(da(e),s==="start",r);return a&&(l=l.map(c=>c+"-"+a),t&&(l=l.concat(l.map(Sh)))),l}function Ed(e){const t=da(e);return mR[t]+e.slice(t.length)}function wR(e){var t,s,r,a;return{top:(t=e.top)!=null?t:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(a=e.left)!=null?a:0}}function kR(e){return typeof e!="number"?wR(e):{top:e,right:e,bottom:e,left:e}}function Cd(e){const{x:t,y:s,width:r,height:a}=e;return{width:r,height:a,top:s,left:t,right:t+r,bottom:s+a,x:t,y:s}}function Yv(e,t,s){let{reference:r,floating:a}=e;const l=Rr(t),c=Vj(t),u=qj(c),d=da(t),p=l==="y",g=r.x+r.width/2-a.width/2,y=r.y+r.height/2-a.height/2,h=r[u]/2-a[u]/2;let m;switch(d){case"top":m={x:g,y:r.y-a.height};break;case"bottom":m={x:g,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y};break;case"left":m={x:r.x-a.width,y};break;default:m={x:r.x,y:r.y}}const v=pc(t);return v&&(m[c]+=h*(v==="end"?1:-1)*(s&&p?-1:1)),m}async function Kj(e,t){var s;t===void 0&&(t={});const{x:r,y:a,platform:l,rects:c,elements:u,strategy:d}=e,{boundary:p="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:h=!1,padding:m=0}=Ri(t,e),v=kR(m),k=u[h?y==="floating"?"reference":"floating":y],N=Cd(await l.getClippingRect({element:(s=await(l.isElement==null?void 0:l.isElement(k)))==null||s?k:k.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:p,rootBoundary:g,strategy:d})),A=y==="floating"?{x:r,y:a,width:c.floating.width,height:c.floating.height}:c.reference,_=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),S=await(l.isElement==null?void 0:l.isElement(_))&&await(l.getScale==null?void 0:l.getScale(_))||{x:1,y:1},E=Cd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:A,offsetParent:_,strategy:d}):A);return{top:(N.top-E.top+v.top)/S.y,bottom:(E.bottom-N.bottom+v.bottom)/S.y,left:(N.left-E.left+v.left)/S.x,right:(E.right-N.right+v.right)/S.x}}const jR=50,NR=async(e,t,s)=>{const{placement:r="bottom",strategy:a="absolute",middleware:l=[],platform:c}=s,u=c.detectOverflow?c:{...c,detectOverflow:Kj},d=await(c.isRTL==null?void 0:c.isRTL(t));let p=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:g,y}=Yv(p,r,d),h=r,m=0;const v={};for(let w=0;w<l.length;w++){const k=l[w];if(!k)continue;const{name:N,fn:A}=k,{x:_,y:S,data:E,reset:T}=await A({x:g,y,initialPlacement:r,placement:h,strategy:a,middlewareData:v,rects:p,platform:u,elements:{reference:e,floating:t}});g=_??g,y=S??y,v[N]={...v[N],...E},T&&m<jR&&(m++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(p=T.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):T.rects),{x:g,y}=Yv(p,h,d)),w=-1)}return{x:g,y,placement:h,strategy:a,middlewareData:v}},SR=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,r;const{placement:a,middlewareData:l,rects:c,initialPlacement:u,platform:d,elements:p}=t,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...k}=Ri(e,t);if((s=l.arrow)!=null&&s.alignmentOffset)return{};const N=da(a),A=Rr(u),_=da(u)===u,S=await(d.isRTL==null?void 0:d.isRTL(p.floating)),E=h||(_||!w?[Ed(u)]:gR(u)),T=v!=="none";!h&&T&&E.push(...vR(u,w,v,S));const C=[u,...E],R=await d.detectOverflow(t,k),D=[];let L=((r=l.flip)==null?void 0:r.overflows)||[];if(g&&D.push(R[N]),y){const U=hR(a,c,S);D.push(R[U[0]],R[U[1]])}if(L=[...L,{placement:a,overflows:D}],!D.every(U=>U<=0)){var O,I;const U=(((O=l.flip)==null?void 0:O.index)||0)+1,J=C[U];if(J&&(!(y==="alignment"?A!==Rr(J):!1)||L.every(z=>Rr(z.placement)===A?z.overflows[0]>0:!0)))return{data:{index:U,overflows:L},reset:{placement:J}};let F=(I=L.filter(Z=>Z.overflows[0]<=0).sort((Z,z)=>Z.overflows[1]-z.overflows[1])[0])==null?void 0:I.placement;if(!F)switch(m){case"bestFit":{var W;const Z=(W=L.filter(z=>{if(T){const H=Rr(z.placement);return H===A||H==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(H=>H>0).reduce((H,V)=>H+V,0)]).sort((z,H)=>z[1]-H[1])[0])==null?void 0:W[0];Z&&(F=Z);break}case"initialPlacement":F=u;break}if(a!==F)return{reset:{placement:F}}}return{}}}},_R=new Set(["left","top"]);async function $R(e,t){const{placement:s,platform:r,elements:a}=e,l=await(r.isRTL==null?void 0:r.isRTL(a.floating)),c=da(s),u=pc(s),d=Rr(s)==="y",p=_R.has(c)?-1:1,g=l&&d?-1:1,y=Ri(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:v}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return u&&typeof v=="number"&&(m=u==="end"?v*-1:v),d?{x:m*g,y:h*p}:{x:h*p,y:m*g}}const ER=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,r;const{x:a,y:l,placement:c,middlewareData:u}=t,d=await $R(t,e);return c===((s=u.offset)==null?void 0:s.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:a+d.x,y:l+d.y,data:{...d,placement:c}}}}},CR=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:r,placement:a,platform:l}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:d={fn:A=>{let{x:_,y:S}=A;return{x:_,y:S}}},...p}=Ri(e,t),g={x:s,y:r},y=await l.detectOverflow(t,p),h=Rr(a),m=Gj(h);let v=g[m],w=g[h];const k=(A,_)=>pR(_+y[A==="y"?"top":"left"],_,_-y[A==="y"?"bottom":"right"]);c&&(v=k(m,v)),u&&(w=k(h,w));const N=d.fn({...t,[m]:v,[h]:w});return{...N,data:{x:N.x-s,y:N.y-r,enabled:{[m]:c,[h]:u}}}}}},TR=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:s,rects:r,platform:a,elements:l}=t,{apply:c=()=>{},...u}=Ri(e,t),d=await a.detectOverflow(t,u),p=da(s),g=pc(s),y=Rr(s)==="y",{width:h,height:m}=r.floating;let v,w;p==="top"||p==="bottom"?(v=p,w=g===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(w=p,v=g==="end"?"top":"bottom");const k=m-d.top-d.bottom,N=h-d.left-d.right,A=ua(m-d[v],k),_=ua(h-d[w],N),S=t.middlewareData.shift,E=!S;let T=A,C=_;S!=null&&S.enabled.x&&(C=N),S!=null&&S.enabled.y&&(T=k),E&&!g&&(y?C=h-2*Cs(d.left,d.right):T=m-2*Cs(d.top,d.bottom)),await c({...t,availableWidth:C,availableHeight:T});const R=await a.getDimensions(l.floating);return h!==R.width||m!==R.height?{reset:{rects:!0}}:{}}}};function Yj(e){const t=mr(e);let s=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=Eo(e),l=a?e.offsetWidth:s,c=a?e.offsetHeight:r,u=Xl(s)!==l||Xl(r)!==c;return u&&(s=l,r=c),{width:s,height:r,$:u}}function Ag(e){return Yn(e)?e:e.contextElement}function li(e){const t=Ag(e);if(!Eo(t))return Mr(1);const s=t.getBoundingClientRect(),{width:r,height:a,$:l}=Yj(t);let c=(l?Xl(s.width):s.width)/r,u=(l?Xl(s.height):s.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const RR=Mr(0);function Xj(e){const t=Xn(e);return!Rg()||!t.visualViewport?RR:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function AR(e,t,s){return t===void 0&&(t=!1),!!s&&t&&s===Xn(e)}function fa(e,t,s,r){t===void 0&&(t=!1),s===void 0&&(s=!1);const a=e.getBoundingClientRect(),l=Ag(e);let c=Mr(1);t&&(r?Yn(r)&&(c=li(r)):c=li(e));const u=AR(l,s,r)?Xj(l):Mr(0);let d=(a.left+u.x)/c.x,p=(a.top+u.y)/c.y,g=a.width/c.x,y=a.height/c.y;if(l&&r){const h=Xn(l),m=Yn(r)?Xn(r):r;let v=h,w=Nh(v);for(;w&&m!==v;){const k=li(w),N=w.getBoundingClientRect(),A=mr(w),_=N.left+(w.clientLeft+parseFloat(A.paddingLeft))*k.x,S=N.top+(w.clientTop+parseFloat(A.paddingTop))*k.y;d*=k.x,p*=k.y,g*=k.x,y*=k.y,d+=_,p+=S,v=Xn(w),w=Nh(v)}}return Cd({width:g,height:y,x:d,y:p})}function bf(e,t){const s=yf(e).scrollLeft;return t?t.left+s:fa(Ir(e)).left+s}function Qj(e,t){const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-bf(e,s),a=s.top+t.scrollTop;return{x:r,y:a}}function OR(e){let{elements:t,rect:s,offsetParent:r,strategy:a}=e;const l=a==="fixed",c=Ir(r),u=t?xf(t.floating):!1;if(r===c||u&&l)return s;let d={scrollLeft:0,scrollTop:0},p=Mr(1);const g=Mr(0),y=Eo(r);if((y||!l)&&((Ti(r)!=="body"||gf(c))&&(d=yf(r)),y)){const m=fa(r);p=li(r),g.x=m.x+r.clientLeft,g.y=m.y+r.clientTop}const h=c&&!y&&!l?Qj(c,d):Mr(0);return{width:s.width*p.x,height:s.height*p.y,x:s.x*p.x-d.scrollLeft*p.x+g.x+h.x,y:s.y*p.y-d.scrollTop*p.y+g.y+h.y}}function MR(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function LR(e){const t=yf(e),s=e.ownerDocument.body,r=Cs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),a=Cs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let l=-t.scrollLeft+bf(e);const c=-t.scrollTop;return mr(s).direction==="rtl"&&(l+=Cs(e.clientWidth,s.clientWidth)-r),{width:r,height:a,x:l,y:c}}const PR=25;function IR(e,t,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",a=Xn(e),l=Ir(e),c=a.visualViewport;let u=l.clientWidth,d=l.clientHeight,p=0,g=0;if(c){const h=!Rg()||t==="fixed";r?h||(p=-c.offsetLeft,g=-c.offsetTop):(u=c.width,d=c.height,h&&(p=c.offsetLeft,g=c.offsetTop))}if(bf(l)<=0){const h=l.ownerDocument,m=h.body,v=getComputedStyle(m),w=h.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,k=Math.abs(l.clientWidth-m.clientWidth-w),N=getComputedStyle(l).scrollbarGutter==="stable both-edges"?k/2:k;N<=PR&&(u-=N)}return{width:u,height:d,x:p,y:g}}function zR(e,t){const s=fa(e,!0,t==="fixed"),r=s.top+e.clientTop,a=s.left+e.clientLeft,l=li(e),c=e.clientWidth*l.x,u=e.clientHeight*l.y,d=a*l.x,p=r*l.y;return{width:c,height:u,x:d,y:p}}function Xv(e,t,s){let r;if(t==="viewport"||t==="layoutViewport")r=IR(e,s,t);else if(t==="document")r=LR(Ir(e));else if(Yn(t))r=zR(t,s);else{const a=Xj(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Cd(r)}function DR(e,t){const s=t.get(e);if(s)return s;let r=Yl(e,[],!1).filter(u=>Yn(u)&&Ti(u)!=="body"),a=null;const l=mr(e).position==="fixed";let c=l?ca(e):e;for(;Yn(c)&&!Kl(c);){const u=mr(c),d=Tg(c),p=a?a.position:l?"fixed":"";!d&&(p==="fixed"||p==="absolute"&&u.position==="static")?r=r.filter(y=>y!==c):a=u,c=ca(c)}return t.set(e,r),r}function FR(e){let{element:t,boundary:s,rootBoundary:r,strategy:a}=e;const c=[...s==="clippingAncestors"?xf(t)?[]:DR(t,this._c):[].concat(s),r],u=Xv(t,c[0],a);let d=u.top,p=u.right,g=u.bottom,y=u.left;for(let h=1;h<c.length;h++){const m=Xv(t,c[h],a);d=Cs(m.top,d),p=ua(m.right,p),g=ua(m.bottom,g),y=Cs(m.left,y)}return{width:p-y,height:g-d,x:y,y:d}}function UR(e){const{width:t,height:s}=Yj(e);return{width:t,height:s}}function WR(e,t,s){const r=Eo(t),a=Ir(t),l=s==="fixed",c=fa(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const d=Mr(0);if((r||!l)&&((Ti(t)!=="body"||gf(a))&&(u=yf(t)),r)){const h=fa(t,!0,l,t);d.x=h.x+t.clientLeft,d.y=h.y+t.clientTop}!r&&a&&(d.x=bf(a));const p=a&&!r&&!l?Qj(a,u):Mr(0),g=c.left+u.scrollLeft-d.x-p.x,y=c.top+u.scrollTop-d.y-p.y;return{x:g,y,width:c.width,height:c.height}}function Lp(e){return mr(e).position==="static"}function Qv(e,t){if(!Eo(e)||mr(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return Ir(e)===s&&(s=s.ownerDocument.body),s}function Jj(e,t){const s=Xn(e);if(xf(e))return s;if(!Eo(e)){let a=ca(e);for(;a&&!Kl(a);){if(Yn(a)&&!Lp(a))return a;a=ca(a)}return s}let r=Qv(e,t);for(;r&&lR(r)&&Lp(r);)r=Qv(r,t);return r&&Kl(r)&&Lp(r)&&!Tg(r)?s:r||dR(e)||s}const HR=async function(e){const t=this.getOffsetParent||Jj,s=this.getDimensions,r=await s(e.floating);return{reference:WR(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function BR(e){return mr(e).direction==="rtl"}const GR={convertOffsetParentRelativeRectToViewportRelativeRect:OR,getDocumentElement:Ir,getClippingRect:FR,getOffsetParent:Jj,getElementRects:HR,getClientRects:MR,getDimensions:UR,getScale:li,isElement:Yn,isRTL:BR};function Zj(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qR(e,t,s){let r=null,a;const l=Ir(e);function c(){var g;clearTimeout(a),(g=r)==null||g.disconnect(),r=null}function u(g,y){g===void 0&&(g=!1),y===void 0&&(y=1),c();const h=e.getBoundingClientRect(),{left:m,top:v,width:w,height:k}=h;if(g||t(),!w||!k)return;const N=Bu(v),A=Bu(l.clientWidth-(m+w)),_=Bu(l.clientHeight-(v+k)),S=Bu(m),T={rootMargin:-N+"px "+-A+"px "+-_+"px "+-S+"px",threshold:Cs(0,ua(1,y))||1};let C=!0;function R(D){const L=D[0].intersectionRatio;if(!Zj(h,e.getBoundingClientRect()))return u();if(L!==y){if(!C)return u();L?u(!1,L):a=setTimeout(()=>{u(!1,1e-7)},1e3)}C=!1}try{r=new IntersectionObserver(R,{...T,root:l.ownerDocument})}catch{r=new IntersectionObserver(R,T)}r.observe(e)}const d=Xn(e),p=()=>u(s);return d.addEventListener("resize",p),u(!0),()=>{d.removeEventListener("resize",p),c()}}function VR(e,t,s,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,p=Ag(e),g=a||l?[...p?Yl(p):[],...t?Yl(t):[]]:[];g.forEach(N=>{a&&N.addEventListener("scroll",s),l&&N.addEventListener("resize",s)});const y=p&&u?qR(p,s,l):null;let h=-1,m=null;c&&(m=new ResizeObserver(N=>{let[A]=N;A&&A.target===p&&m&&t&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var _;(_=m)==null||_.observe(t)})),s()}),p&&!d&&m.observe(p),t&&m.observe(t));let v,w=d?fa(e):null;d&&k();function k(){const N=fa(e);w&&!Zj(w,N)&&s(),w=N,v=requestAnimationFrame(k)}return s(),()=>{var N;g.forEach(A=>{a&&A.removeEventListener("scroll",s),l&&A.removeEventListener("resize",s)}),y==null||y(),(N=m)==null||N.disconnect(),m=null,d&&cancelAnimationFrame(v)}}const Pp=Kj,KR=ER,YR=CR,XR=SR,QR=TR,JR=(e,t,s)=>{const r=new Map,a=s??{},l={...GR,...a.platform,_c:r};return NR(e,t,{...a,platform:l})};var ZR=typeof document<"u",e3=function(){},fd=ZR?x.useLayoutEffect:e3;function Td(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let s,r,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(r=s;r--!==0;)if(!Td(e[r],t[r]))return!1;return!0}if(a=Object.keys(e),s=a.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(t,a[r]))return!1;for(r=s;r--!==0;){const l=a[r];if(!(l==="_owner"&&e.$$typeof)&&!Td(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function e1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Jv(e,t){const s=e1(e);return Math.round(t*s)/s}function Ip(e){const t=x.useRef(e);return fd(()=>{t.current=e}),t}function t3(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:r=[],platform:a,elements:{reference:l,floating:c}={},transform:u=!0,whileElementsMounted:d,open:p}=e,[g,y]=x.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=x.useState(r);Td(h,r)||m(r);const[v,w]=x.useState(null),[k,N]=x.useState(null),A=x.useCallback(z=>{z!==T.current&&(T.current=z,w(z))},[]),_=x.useCallback(z=>{z!==C.current&&(C.current=z,N(z))},[]),S=l||v,E=c||k,T=x.useRef(null),C=x.useRef(null),R=x.useRef(g),D=d!=null,L=Ip(d),O=Ip(a),I=Ip(p),W=x.useCallback(()=>{if(!T.current||!C.current)return;const z={placement:t,strategy:s,middleware:h};O.current&&(z.platform=O.current),JR(T.current,C.current,z).then(H=>{const V={...H,isPositioned:I.current!==!1};U.current&&!Td(R.current,V)&&(R.current=V,fr.flushSync(()=>{y(V)}))})},[h,t,s,O,I]);fd(()=>{p===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,y(z=>({...z,isPositioned:!1})))},[p]);const U=x.useRef(!1);fd(()=>(U.current=!0,()=>{U.current=!1}),[]),fd(()=>{if(S&&(T.current=S),E&&(C.current=E),S&&E){if(L.current)return L.current(S,E,W);W()}},[S,E,W,L,D]);const J=x.useMemo(()=>({reference:T,floating:C,setReference:A,setFloating:_}),[A,_]),F=x.useMemo(()=>({reference:S,floating:E}),[S,E]),Z=x.useMemo(()=>{const z={position:s,left:0,top:0};if(!F.floating)return z;const H=Jv(F.floating,g.x),V=Jv(F.floating,g.y);return u?{...z,transform:"translate("+H+"px, "+V+"px)",...e1(F.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:H,top:V}},[s,u,F.floating,g.x,g.y]);return x.useMemo(()=>({...g,update:W,refs:J,elements:F,floatingStyles:Z}),[g,W,J,F,Z])}const t1=(e,t)=>{const s=KR(e);return{name:s.name,fn:s.fn,options:[e,t]}},n3=(e,t)=>{const s=YR(e);return{name:s.name,fn:s.fn,options:[e,t]}},s3=(e,t)=>{const s=XR(e);return{name:s.name,fn:s.fn,options:[e,t]}},r3=(e,t)=>{const s=QR(e);return{name:s.name,fn:s.fn,options:[e,t]}},n1={...fh},o3=n1.useInsertionEffect,a3=o3||(e=>e());function s1(e){const t=x.useRef(()=>{});return a3(()=>{t.current=e}),x.useCallback(function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}var _h=typeof document<"u"?x.useLayoutEffect:x.useEffect;let Zv=!1,i3=0;const ew=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+i3++;function l3(){const[e,t]=x.useState(()=>Zv?ew():void 0);return _h(()=>{e==null&&t(ew())},[]),x.useEffect(()=>{Zv=!0},[]),e}const c3=n1.useId,u3=c3||l3;function d3(){const e=new Map;return{emit(t,s){var r;(r=e.get(t))==null||r.forEach(a=>a(s))},on(t,s){e.set(t,[...e.get(t)||[],s])},off(t,s){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(a=>a!==s))||[])}}}const f3=x.createContext(null),m3=x.createContext(null),p3=()=>{var e;return((e=x.useContext(f3))==null?void 0:e.id)||null},h3=()=>x.useContext(m3),g3="data-floating-ui-focusable";function x3(e){const{open:t=!1,onOpenChange:s,elements:r}=e,a=u3(),l=x.useRef({}),[c]=x.useState(()=>d3()),u=p3()!=null,[d,p]=x.useState(r.reference),g=s1((m,v,w)=>{l.current.openEvent=m?v:void 0,c.emit("openchange",{open:m,event:v,reason:w,nested:u}),s==null||s(m,v,w)}),y=x.useMemo(()=>({setPositionReference:p}),[]),h=x.useMemo(()=>({reference:d||r.reference||null,floating:r.floating||null,domReference:r.reference}),[d,r.reference,r.floating]);return x.useMemo(()=>({dataRef:l,open:t,onOpenChange:g,elements:h,events:c,floatingId:a,refs:y}),[t,g,h,c,a,y])}function y3(e){e===void 0&&(e={});const{nodeId:t}=e,s=x3({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,a=r.elements,[l,c]=x.useState(null),[u,d]=x.useState(null),g=(a==null?void 0:a.domReference)||l,y=x.useRef(null),h=h3();_h(()=>{g&&(y.current=g)},[g]);const m=t3({...e,elements:{...a,...u&&{reference:u}}}),v=x.useCallback(_=>{const S=Yn(_)?{getBoundingClientRect:()=>_.getBoundingClientRect(),contextElement:_}:_;d(S),m.refs.setReference(S)},[m.refs]),w=x.useCallback(_=>{(Yn(_)||_===null)&&(y.current=_,c(_)),(Yn(m.refs.reference.current)||m.refs.reference.current===null||_!==null&&!Yn(_))&&m.refs.setReference(_)},[m.refs]),k=x.useMemo(()=>({...m.refs,setReference:w,setPositionReference:v,domReference:y}),[m.refs,w,v]),N=x.useMemo(()=>({...m.elements,domReference:g}),[m.elements,g]),A=x.useMemo(()=>({...m,...r,refs:k,elements:N,nodeId:t}),[m,k,N,t,r]);return _h(()=>{r.dataRef.current.floatingContext=A;const _=h==null?void 0:h.nodesRef.current.find(S=>S.id===t);_&&(_.context=A)}),x.useMemo(()=>({...m,context:A,refs:k,elements:N}),[m,k,N,A])}const tw="active",nw="selected";function zp(e,t,s){const r=new Map,a=s==="item";let l=e;if(a&&e){const{[tw]:c,[nw]:u,...d}=e;l=d}return{...s==="floating"&&{tabIndex:-1,[g3]:""},...l,...t.map(c=>{const u=c?c[s]:null;return typeof u=="function"?e?u(e):null:u}).concat(e).reduce((c,u)=>(u&&Object.entries(u).forEach(d=>{let[p,g]=d;if(!(a&&[tw,nw].includes(p)))if(p.indexOf("on")===0){if(r.has(p)||r.set(p,[]),typeof g=="function"){var y;(y=r.get(p))==null||y.push(g),c[p]=function(){for(var h,m=arguments.length,v=new Array(m),w=0;w<m;w++)v[w]=arguments[w];return(h=r.get(p))==null?void 0:h.map(k=>k(...v)).find(k=>k!==void 0)}}}else c[p]=g}),c),{})}}function b3(e){e===void 0&&(e=[]);const t=e.map(u=>u==null?void 0:u.reference),s=e.map(u=>u==null?void 0:u.floating),r=e.map(u=>u==null?void 0:u.item),a=x.useCallback(u=>zp(u,e,"reference"),t),l=x.useCallback(u=>zp(u,e,"floating"),s),c=x.useCallback(u=>zp(u,e,"item"),r);return x.useMemo(()=>({getReferenceProps:a,getFloatingProps:l,getItemProps:c}),[a,l,c])}function sw(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const v3=e=>({name:"inner",options:e,async fn(t){const{listRef:s,overflowRef:r,onFallbackChange:a,offset:l=0,index:c=0,minItemsVisible:u=4,referenceOverflowThreshold:d=0,scrollRef:p,...g}=Ri(e,t),{rects:y,elements:{floating:h}}=t,m=s.current[c],v=(p==null?void 0:p.current)||h,w=h.clientTop||v.clientTop,k=h.clientTop!==0,N=v.clientTop!==0,A=h===v;if(!m)return{};const _={...t,...await t1(-m.offsetTop-h.clientTop-y.reference.height/2-m.offsetHeight/2-l).fn(t)},S=await Pp(sw(_,v.scrollHeight+w+h.clientTop),g),E=await Pp(_,{...g,elementContext:"reference"}),T=Cs(0,S.top),C=_.y+T,L=(v.scrollHeight>v.clientHeight?O=>O:Xl)(Cs(0,v.scrollHeight+(k&&A||N?w*2:0)-T-Cs(0,S.bottom)));if(v.style.maxHeight=L+"px",v.scrollTop=T,a){const O=v.offsetHeight<m.offsetHeight*ua(u,s.current.length)-1||E.top>=-d||E.bottom>=-d;fr.flushSync(()=>a(O))}return r&&(r.current=await Pp(sw({..._,y:C},v.offsetHeight+w+h.clientTop),g)),{y:C}}});function w3(e,t){const{open:s,elements:r}=e,{enabled:a=!0,overflowRef:l,scrollRef:c,onChange:u}=t,d=s1(u),p=x.useRef(!1),g=x.useRef(null),y=x.useRef(null);x.useEffect(()=>{if(!a)return;function m(w){if(w.ctrlKey||!v||l.current==null)return;const k=w.deltaY,N=l.current.top>=-.5,A=l.current.bottom>=-.5,_=v.scrollHeight-v.clientHeight,S=k<0?-1:1,E=k<0?"max":"min";v.scrollHeight<=v.clientHeight||(!N&&k>0||!A&&k<0?(w.preventDefault(),fr.flushSync(()=>{d(T=>T+Math[E](k,_*S))})):/firefox/i.test(fR())&&(v.scrollTop+=k))}const v=(c==null?void 0:c.current)||r.floating;if(s&&v)return v.addEventListener("wheel",m),requestAnimationFrame(()=>{g.current=v.scrollTop,l.current!=null&&(y.current={...l.current})}),()=>{g.current=null,y.current=null,v.removeEventListener("wheel",m)}},[a,s,r.floating,l,c,d]);const h=x.useMemo(()=>({onKeyDown(){p.current=!0},onWheel(){p.current=!1},onPointerMove(){p.current=!1},onScroll(){const m=(c==null?void 0:c.current)||r.floating;if(!(!l.current||!m||!p.current)){if(g.current!==null){const v=m.scrollTop-g.current;(l.current.bottom<-.5&&v<-1||l.current.top<-.5&&v>1)&&fr.flushSync(()=>d(w=>w+v))}requestAnimationFrame(()=>{g.current=m.scrollTop})}}}),[r.floating,d,l,c]);return x.useMemo(()=>a?{floating:h}:{},[a,h])}let Ai=x.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Ai.displayName="FloatingContext";let Og=x.createContext(null);Og.displayName="PlacementContext";function k3(e){return x.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function j3(){return x.useContext(Ai).setReference}function N3(){return x.useContext(Ai).getReferenceProps}function S3(){let{getFloatingProps:e,slot:t}=x.useContext(Ai);return x.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":t.anchor}),[e,t])}function _3(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=x.useContext(Og),s=x.useMemo(()=>e,[JSON.stringify(e,(a,l)=>{var c;return(c=l==null?void 0:l.outerHTML)!=null?c:l})]);Pt(()=>{t==null||t(s??null)},[t,s]);let r=x.useContext(Ai);return x.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let rw=4;function $3({children:e,enabled:t=!0}){let[s,r]=x.useState(null),[a,l]=x.useState(0),c=x.useRef(null),[u,d]=x.useState(null);E3(u);let p=t&&s!==null&&u!==null,{to:g="bottom",gap:y=0,offset:h=0,padding:m=0,inner:v}=C3(s,u),[w,k="center"]=g.split(" ");Pt(()=>{p&&l(0)},[p]);let{refs:N,floatingStyles:A,context:_}=y3({open:p,placement:w==="selection"?k==="center"?"bottom":`bottom-${k}`:k==="center"?`${w}`:`${w}-${k}`,strategy:"absolute",transform:!1,middleware:[t1({mainAxis:w==="selection"?0:y,crossAxis:h}),n3({padding:m}),w!=="selection"&&s3({padding:m}),w==="selection"&&v?v3({...v,padding:m,overflowRef:c,offset:a,minItemsVisible:rw,referenceOverflowThreshold:m,onFallbackChange(O){var I,W;if(!O)return;let U=_.elements.floating;if(!U)return;let J=parseFloat(getComputedStyle(U).scrollPaddingBottom)||0,F=Math.min(rw,U.childElementCount),Z=0,z=0;for(let H of(W=(I=_.elements.floating)==null?void 0:I.childNodes)!=null?W:[])if(is(H)){let V=H.offsetTop,P=V+H.clientHeight+J,B=U.scrollTop,q=B+U.clientHeight;if(V>=B&&P<=q)F--;else{z=Math.max(0,Math.min(P,q)-Math.max(V,B)),Z=H.clientHeight;break}}F>=1&&l(H=>{let V=Z*F-z+J;return H>=V?H:V})}}):null,r3({padding:m,apply({availableWidth:O,availableHeight:I,elements:W}){Object.assign(W.floating.style,{overflow:"auto",maxWidth:`${O}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${I}px)`})}})].filter(Boolean),whileElementsMounted:VR}),[S=w,E=k]=_.placement.split("-");w==="selection"&&(S="selection");let T=x.useMemo(()=>({anchor:[S,E].filter(Boolean).join(" ")}),[S,E]),C=w3(_,{overflowRef:c,onChange:l}),{getReferenceProps:R,getFloatingProps:D}=b3([C]),L=Qe(O=>{d(O),N.setFloating(O)});return x.createElement(Og.Provider,{value:r},x.createElement(Ai.Provider,{value:{setFloating:L,setReference:N.setReference,styles:A,getReferenceProps:R,getFloatingProps:D,slot:T}},e))}function E3(e){Pt(()=>{if(!e)return;let t=new MutationObserver(()=>{let s=window.getComputedStyle(e).maxHeight,r=parseFloat(s);if(isNaN(r))return;let a=parseInt(s);isNaN(a)||r!==a&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function C3(e,t){var s,r,a;let l=Dp((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",t),c=Dp((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),u=Dp((a=e==null?void 0:e.padding)!=null?a:"var(--anchor-padding, 0)",t);return{...e,gap:l,offset:c,padding:u}}function Dp(e,t,s=void 0){let r=_o(),a=Qe((d,p)=>{if(d==null)return[s,null];if(typeof d=="number")return[d,null];if(typeof d=="string"){if(!p)return[s,null];let g=ow(d,p);return[g,y=>{let h=r1(d);{let m=h.map(v=>window.getComputedStyle(p).getPropertyValue(v));r.requestAnimationFrame(function v(){r.nextFrame(v);let w=!1;for(let[N,A]of h.entries()){let _=window.getComputedStyle(p).getPropertyValue(A);if(m[N]!==_){m[N]=_,w=!0;break}}if(!w)return;let k=ow(d,p);g!==k&&(y(k),g=k)})}return r.dispose}]}return[s,null]}),l=x.useMemo(()=>a(e,t)[0],[e,t]),[c=l,u]=x.useState();return Pt(()=>{let[d,p]=a(e,t);if(u(d),!!p)return p(u)},[e,t]),c}function r1(e){let t=/var\((.*)\)/.exec(e);if(t){let s=t[1].indexOf(",");if(s===-1)return[t[1]];let r=t[1].slice(0,s).trim(),a=t[1].slice(s+1).trim();return a?[r,...r1(a)]:[r]}return[]}function ow(e,t){let s=document.createElement("div");t.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 t.removeChild(s),r}function T3({children:e,freeze:t},s){let r=o1(t,e);return x.isValidElement(r)?x.cloneElement(r,{ref:s}):Oe.createElement(Oe.Fragment,null,r)}Oe.forwardRef(T3);function o1(e,t){let[s,r]=x.useState(t);return!e&&s!==t&&r(t),e?s:t}let vf=x.createContext(null);vf.displayName="OpenClosedContext";var Pn=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Pn||{});function hc(){return x.useContext(vf)}function a1({value:e,children:t}){return Oe.createElement(vf.Provider,{value:e},t)}function R3({children:e}){return Oe.createElement(vf.Provider,{value:null},e)}function A3(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let ho=[];A3(()=>{function e(t){if(!Tr(t.target)||t.target===document.body||ho[0]===t.target)return;let s=t.target;s=s.closest($d),ho.unshift(s??t.target),ho=ho.filter(r=>r!=null&&r.isConnected),ho.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 O3(e){throw new Error("Unexpected object: "+e)}var zt=(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))(zt||{});function Gu(e,t){let s=t.resolveItems();if(s.length<=0)return null;let r=t.resolveActiveIndex(),a=r??-1;switch(e.focus){case 0:{for(let l=0;l<s.length;++l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 1:{a===-1&&(a=s.length);for(let l=a-1;l>=0;--l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 2:{for(let l=a+1;l<s.length;++l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 3:{for(let l=s.length-1;l>=0;--l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 4:{for(let l=0;l<s.length;++l)if(t.resolveId(s[l],l,s)===e.id)return l;return r}case 5:return null;default:O3(e)}}function Mg(e){let t=Qe(e),s=x.useRef(!1);x.useEffect(()=>(s.current=!1,()=>{s.current=!0,df(()=>{s.current&&t()})}),[t])}function M3(){let e=typeof document>"u";return"useSyncExternalStore"in fh?(t=>t.useSyncExternalStore)(fh)(()=>()=>{},()=>!1,()=>!e):!1}function gc(){let e=M3(),[t,s]=x.useState(cr.isHandoffComplete);return t&&cr.isHandoffComplete===!1&&s(!1),x.useEffect(()=>{t!==!0&&s(!0)},[t]),x.useEffect(()=>cr.handoff(),[]),e?!1:t}let i1=x.createContext(!1);function L3(){return x.useContext(i1)}function aw(e){return Oe.createElement(i1.Provider,{value:e.force},e.children)}function P3(e){let t=L3(),s=x.useContext(c1),[r,a]=x.useState(()=>{var l;if(!t&&s!==null)return(l=s.current)!=null?l:null;if(cr.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let u=e.createElement("div");return u.setAttribute("id","headlessui-portal-root"),e.body.appendChild(u)});return x.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),x.useEffect(()=>{t||s!==null&&a(s.current)},[s,a,t]),r}let l1=x.Fragment,I3=Yt(function(e,t){let{ownerDocument:s=null,...r}=e,a=x.useRef(null),l=En(lT(m=>{a.current=m}),t),c=Vl(a.current),u=s??c,d=P3(u),p=x.useContext($h),g=_o(),y=gc(),h=cn();return Mg(()=>{var m;d&&d.childNodes.length<=0&&((m=d.parentElement)==null||m.removeChild(d))}),!d||!y?null:fr.createPortal(Oe.createElement("div",{"data-headlessui-portal":"",ref:m=>{g.dispose(),p&&m&&g.add(p.register(m))}},h({ourProps:{ref:l},theirProps:r,slot:{},defaultTag:l1,name:"Portal"})),d)});function z3(e,t){let s=En(t),{enabled:r=!0,ownerDocument:a,...l}=e,c=cn();return r?Oe.createElement(I3,{...l,ownerDocument:a,ref:s}):c({ourProps:{ref:s},theirProps:l,slot:{},defaultTag:l1,name:"Portal"})}let D3=x.Fragment,c1=x.createContext(null);function F3(e,t){let{target:s,...r}=e,a={ref:En(t)},l=cn();return Oe.createElement(c1.Provider,{value:s},l({ourProps:a,theirProps:r,defaultTag:D3,name:"Popover.Group"}))}let $h=x.createContext(null);function U3(){let e=x.useContext($h),t=x.useRef([]),s=Qe(l=>(t.current.push(l),e&&e.register(l),()=>r(l))),r=Qe(l=>{let c=t.current.indexOf(l);c!==-1&&t.current.splice(c,1),e&&e.unregister(l)}),a=x.useMemo(()=>({register:s,unregister:r,portals:t}),[s,r,t]);return[t,x.useMemo(()=>function({children:l}){return Oe.createElement($h.Provider,{value:a},l)},[a])]}let W3=Yt(z3),u1=Yt(F3),d1=Object.assign(W3,{Group:u1});const md={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function f1(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function H3(e,t,s){let r=us();if(t.kind==="Tracked"){let a=function(){l!==f1(e)&&(r.dispose(),s())},{position:l}=t,c=new ResizeObserver(a);c.observe(e),r.add(()=>c.disconnect()),r.addEventListener(window,"scroll",a,{passive:!0}),r.addEventListener(window,"resize",a)}return()=>r.dispose()}function B3(e,t=typeof document<"u"?document.defaultView:null,s){let r=mc(e,"escape");Dj(t,"keydown",a=>{r&&(a.defaultPrevented||a.key===en.Escape&&s(a))})}function G3(){var e;let[t]=x.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[s,r]=x.useState((e=t==null?void 0:t.matches)!=null?e:!1);return Pt(()=>{if(!t)return;function a(l){r(l.matches)}return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[t]),s}function q3({defaultContainers:e=[],portals:t,mainTreeNode:s}={}){let r=Qe(()=>{var a,l;let c=Ci(s),u=[];for(let d of e)d!==null&&(Ar(d)?u.push(d):"current"in d&&Ar(d.current)&&u.push(d.current));if(t!=null&&t.current)for(let d of t.current)u.push(d);for(let d of(a=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?a:[])d!==document.body&&d!==document.head&&Ar(d)&&d.id!=="headlessui-portal-root"&&(s&&(d.contains(s)||d.contains((l=s==null?void 0:s.getRootNode())==null?void 0:l.host))||u.some(p=>d.contains(p))||u.push(d));return u});return{resolveContainers:r,contains:Qe(a=>r().some(l=>l.contains(a)))}}let m1=x.createContext(null);function iw({children:e,node:t}){let[s,r]=x.useState(null),a=p1(t??s);return Oe.createElement(m1.Provider,{value:a},e,a===null&&Oe.createElement(ql,{features:vi.Hidden,ref:l=>{var c,u;if(l){for(let d of(u=(c=Ci(l))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?u:[])if(d!==document.body&&d!==document.head&&Ar(d)&&d!=null&&d.contains(l)){r(d);break}}}}))}function p1(e=null){var t;return(t=x.useContext(m1))!=null?t:e}function Lg(){let e=x.useRef(!1);return Pt(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Ml=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Ml||{});function V3(){let e=x.useRef(0);return Ij(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function h1(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let s of e.current)Ar(s.current)&&t.add(s.current);return t}let K3="div";var Qo=(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))(Qo||{});function Y3(e,t){let s=x.useRef(null),r=En(s,t),{initialFocus:a,initialFocusFallback:l,containers:c,features:u=15,...d}=e;gc()||(u=0);let p=Vl(s.current);Z3(u,{ownerDocument:p});let g=eA(u,{ownerDocument:p,container:s,initialFocus:a,initialFocusFallback:l});tA(u,{ownerDocument:p,container:s,containers:c,previousActiveElement:g});let y=V3(),h=Qe(A=>{if(!is(s.current))return;let _=s.current;(S=>S())(()=>{zn(y.current,{[Ml.Forwards]:()=>{ii(_,Ks.First,{skipElements:[A.relatedTarget,l]})},[Ml.Backwards]:()=>{ii(_,Ks.Last,{skipElements:[A.relatedTarget,l]})}})})}),m=mc(!!(u&2),"focus-trap#tab-lock"),v=_o(),w=x.useRef(!1),k={ref:r,onKeyDown(A){A.key=="Tab"&&(w.current=!0,v.requestAnimationFrame(()=>{w.current=!1}))},onBlur(A){if(!(u&4))return;let _=h1(c);is(s.current)&&_.add(s.current);let S=A.relatedTarget;Tr(S)&&S.dataset.headlessuiFocusGuard!=="true"&&(g1(_,S)||(w.current?ii(s.current,zn(y.current,{[Ml.Forwards]:()=>Ks.Next,[Ml.Backwards]:()=>Ks.Previous})|Ks.WrapAround,{relativeTo:A.target}):Tr(A.target)&&Or(A.target)))}},N=cn();return Oe.createElement(Oe.Fragment,null,m&&Oe.createElement(ql,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:h,features:vi.Focusable}),N({ourProps:k,theirProps:d,defaultTag:K3,name:"FocusTrap"}),m&&Oe.createElement(ql,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:h,features:vi.Focusable}))}let X3=Yt(Y3),Q3=Object.assign(X3,{features:Qo});function J3(e=!0){let t=x.useRef(ho.slice());return Cg(([s],[r])=>{r===!0&&s===!1&&df(()=>{t.current.splice(0)}),r===!1&&s===!0&&(t.current=ho.slice())},[e,ho,t]),Qe(()=>{var s;return(s=t.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function Z3(e,{ownerDocument:t}){let s=!!(e&8),r=J3(s);Cg(()=>{s||lj(t==null?void 0:t.body)&&Or(r())},[s]),Mg(()=>{s&&Or(r())})}function eA(e,{ownerDocument:t,container:s,initialFocus:r,initialFocusFallback:a}){let l=x.useRef(null),c=mc(!!(e&1),"focus-trap#initial-focus"),u=Lg();return Cg(()=>{if(e===0)return;if(!c){a!=null&&a.current&&Or(a.current);return}let d=s.current;d&&df(()=>{if(!u.current)return;let p=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===p){l.current=p;return}}else if(d.contains(p)){l.current=p;return}if(r!=null&&r.current)Or(r.current);else{if(e&16){if(ii(d,Ks.First|Ks.AutoFocus)!==jh.Error)return}else if(ii(d,Ks.First)!==jh.Error)return;if(a!=null&&a.current&&(Or(a.current),(t==null?void 0:t.activeElement)===a.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}l.current=t==null?void 0:t.activeElement})},[a,c,e]),l}function tA(e,{ownerDocument:t,container:s,containers:r,previousActiveElement:a}){let l=Lg(),c=!!(e&4);Dj(t==null?void 0:t.defaultView,"focus",u=>{if(!c||!l.current)return;let d=h1(r);is(s.current)&&d.add(s.current);let p=a.current;if(!p)return;let g=u.target;is(g)?g1(d,g)?(a.current=g,Or(g)):(u.preventDefault(),u.stopPropagation(),Or(p)):Or(a.current)},!0)}function g1(e,t){for(let s of e)if(s.contains(t))return!0;return!1}function x1(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!zl((t=e.as)!=null?t:b1)||Oe.Children.count(e.children)===1}let wf=x.createContext(null);wf.displayName="TransitionContext";var nA=(e=>(e.Visible="visible",e.Hidden="hidden",e))(nA||{});function sA(){let e=x.useContext(wf);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function rA(){let e=x.useContext(kf);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let kf=x.createContext(null);kf.displayName="NestingContext";function jf(e){return"children"in e?jf(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function y1(e,t){let s=$o(e),r=x.useRef([]),a=Lg(),l=_o(),c=Qe((m,v=xo.Hidden)=>{let w=r.current.findIndex(({el:k})=>k===m);w!==-1&&(zn(v,{[xo.Unmount](){r.current.splice(w,1)},[xo.Hidden](){r.current[w].state="hidden"}}),l.microTask(()=>{var k;!jf(r)&&a.current&&((k=s.current)==null||k.call(s))}))}),u=Qe(m=>{let v=r.current.find(({el:w})=>w===m);return v?v.state!=="visible"&&(v.state="visible"):r.current.push({el:m,state:"visible"}),()=>c(m,xo.Unmount)}),d=x.useRef([]),p=x.useRef(Promise.resolve()),g=x.useRef({enter:[],leave:[]}),y=Qe((m,v,w)=>{d.current.splice(0),t&&(t.chains.current[v]=t.chains.current[v].filter(([k])=>k!==m)),t==null||t.chains.current[v].push([m,new Promise(k=>{d.current.push(k)})]),t==null||t.chains.current[v].push([m,new Promise(k=>{Promise.all(g.current[v].map(([N,A])=>A)).then(()=>k())})]),v==="enter"?p.current=p.current.then(()=>t==null?void 0:t.wait.current).then(()=>w(v)):w(v)}),h=Qe((m,v,w)=>{Promise.all(g.current[v].splice(0).map(([k,N])=>N)).then(()=>{var k;(k=d.current.shift())==null||k()}).then(()=>w(v))});return x.useMemo(()=>({children:r,register:u,unregister:c,onStart:y,onStop:h,wait:p,chains:g}),[u,c,r,y,h,g,p])}let b1=x.Fragment,v1=bi.RenderStrategy;function oA(e,t){var s,r;let{transition:a=!0,beforeEnter:l,afterEnter:c,beforeLeave:u,afterLeave:d,enter:p,enterFrom:g,enterTo:y,entered:h,leave:m,leaveFrom:v,leaveTo:w,...k}=e,[N,A]=x.useState(null),_=x.useRef(null),S=x1(e),E=En(...S?[_,t,A]:t===null?[]:[t]),T=(s=k.unmount)==null||s?xo.Unmount:xo.Hidden,{show:C,appear:R,initial:D}=sA(),[L,O]=x.useState(C?"visible":"hidden"),I=rA(),{register:W,unregister:U}=I;Pt(()=>W(_),[W,_]),Pt(()=>{if(T===xo.Hidden&&_.current){if(C&&L!=="visible"){O("visible");return}return zn(L,{hidden:()=>U(_),visible:()=>W(_)})}},[L,_,W,U,C,T]);let J=gc();Pt(()=>{if(S&&J&&L==="visible"&&_.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[_,L,J,S]);let F=D&&!R,Z=R&&C&&D,z=x.useRef(!1),H=y1(()=>{z.current||(O("hidden"),U(_))},I),V=Qe(Q=>{z.current=!0;let fe=Q?"enter":"leave";H.onStart(_,fe,ye=>{ye==="enter"?l==null||l():ye==="leave"&&(u==null||u())})}),P=Qe(Q=>{let fe=Q?"enter":"leave";z.current=!1,H.onStop(_,fe,ye=>{ye==="enter"?c==null||c():ye==="leave"&&(d==null||d())}),fe==="leave"&&!jf(H)&&(O("hidden"),U(_))});x.useEffect(()=>{S&&a||(V(C),P(C))},[C,S,a]);let B=!(!a||!S||!J||F),[,q]=Wj(B,N,C,{start:V,end:P}),ce=po({ref:E,className:((r=wh(k.className,Z&&p,Z&&g,q.enter&&p,q.enter&&q.closed&&g,q.enter&&!q.closed&&y,q.leave&&m,q.leave&&!q.closed&&v,q.leave&&q.closed&&w,!q.transition&&C&&h))==null?void 0:r.trim())||void 0,...Uj(q)}),de=0;L==="visible"&&(de|=Pn.Open),L==="hidden"&&(de|=Pn.Closed),C&&L==="hidden"&&(de|=Pn.Opening),!C&&L==="visible"&&(de|=Pn.Closing);let ue=cn();return Oe.createElement(kf.Provider,{value:H},Oe.createElement(a1,{value:de},ue({ourProps:ce,theirProps:k,defaultTag:b1,features:v1,visible:L==="visible",name:"Transition.Child"})))}function aA(e,t){let{show:s,appear:r=!1,unmount:a=!0,...l}=e,c=x.useRef(null),u=x1(e),d=En(...u?[c,t]:t===null?[]:[t]);gc();let p=hc();if(s===void 0&&p!==null&&(s=(p&Pn.Open)===Pn.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,y]=x.useState(s?"visible":"hidden"),h=y1(()=>{s||y("hidden")}),[m,v]=x.useState(!0),w=x.useRef([s]);Pt(()=>{m!==!1&&w.current[w.current.length-1]!==s&&(w.current.push(s),v(!1))},[w,s]);let k=x.useMemo(()=>({show:s,appear:r,initial:m}),[s,r,m]);Pt(()=>{s?y("visible"):!jf(h)&&c.current!==null&&y("hidden")},[s,h]);let N={unmount:a},A=Qe(()=>{var E;m&&v(!1),(E=e.beforeEnter)==null||E.call(e)}),_=Qe(()=>{var E;m&&v(!1),(E=e.beforeLeave)==null||E.call(e)}),S=cn();return Oe.createElement(kf.Provider,{value:h},Oe.createElement(wf.Provider,{value:k},S({ourProps:{...N,as:x.Fragment,children:Oe.createElement(w1,{ref:d,...N,...l,beforeEnter:A,beforeLeave:_})},theirProps:{},defaultTag:x.Fragment,features:v1,visible:g==="visible",name:"Transition"})))}function iA(e,t){let s=x.useContext(wf)!==null,r=hc()!==null;return Oe.createElement(Oe.Fragment,null,!s&&r?Oe.createElement(Eh,{ref:t,...e}):Oe.createElement(w1,{ref:t,...e}))}let Eh=Yt(aA),w1=Yt(oA),Pg=Yt(iA),lA=Object.assign(Eh,{Child:Pg,Root:Eh});var cA=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(cA||{}),uA=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(uA||{});let dA={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},Ig=x.createContext(null);Ig.displayName="DialogContext";function Nf(e){let t=x.useContext(Ig);if(t===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Nf),s}return t}function fA(e,t){return zn(t.type,dA,e,t)}let lw=Yt(function(e,t){let s=x.useId(),{id:r=`headlessui-dialog-${s}`,open:a,onClose:l,initialFocus:c,role:u="dialog",autoFocus:d=!0,__demoMode:p=!1,unmount:g=!1,...y}=e,h=x.useRef(!1);u=(function(){return u==="dialog"||u==="alertdialog"?u:(h.current||(h.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let m=hc();a===void 0&&m!==null&&(a=(m&Pn.Open)===Pn.Open);let v=x.useRef(null),w=En(v,t),k=Vl(v.current),N=a?0:1,[A,_]=x.useReducer(fA,{titleId:null,descriptionId:null,panelRef:x.createRef()}),S=Qe(()=>l(!1)),E=Qe(q=>_({type:0,id:q})),T=gc()?N===0:!1,[C,R]=U3(),D={get current(){var q;return(q=A.panelRef.current)!=null?q:v.current}},L=p1(),{resolveContainers:O}=q3({mainTreeNode:L,portals:C,defaultContainers:[D]}),I=m!==null?(m&Pn.Closing)===Pn.Closing:!1;Rj(p||I?!1:T,{allowed:Qe(()=>{var q,ce;return[(ce=(q=v.current)==null?void 0:q.closest("[data-headlessui-portal]"))!=null?ce:null]}),disallowed:Qe(()=>{var q;return[(q=L==null?void 0:L.closest("body > *:not(#headlessui-portal-root)"))!=null?q:null]})});let W=pf.get(null);Pt(()=>{if(T)return W.actions.push(r),()=>W.actions.pop(r)},[W,r,T]);let U=Mn(W,x.useCallback(q=>W.selectors.isTop(q,r),[W,r]));zj(U,O,q=>{q.preventDefault(),S()}),B3(U,k==null?void 0:k.defaultView,q=>{q.preventDefault(),q.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),S()}),Fj(p||I?!1:T,k,O),Aj(T,v,S);let[J,F]=uT(),Z=x.useMemo(()=>[{dialogState:N,close:S,setTitleId:E,unmount:g},A],[N,S,E,g,A]),z=As({open:N===0}),H={ref:w,id:r,role:u,tabIndex:-1,"aria-modal":p?void 0:N===0?!0:void 0,"aria-labelledby":A.titleId,"aria-describedby":J,unmount:g},V=!G3(),P=Qo.None;T&&!p&&(P|=Qo.RestoreFocus,P|=Qo.TabLock,d&&(P|=Qo.AutoFocus),V&&(P|=Qo.InitialFocus));let B=cn();return Oe.createElement(R3,null,Oe.createElement(aw,{force:!0},Oe.createElement(d1,null,Oe.createElement(Ig.Provider,{value:Z},Oe.createElement(u1,{target:v},Oe.createElement(aw,{force:!1},Oe.createElement(F,{slot:z},Oe.createElement(R,null,Oe.createElement(Q3,{initialFocus:c,initialFocusFallback:v,containers:O,features:P},Oe.createElement(vT,{value:S},B({ourProps:H,theirProps:y,slot:z,defaultTag:mA,features:pA,visible:N===0,name:"Dialog"})))))))))))}),mA="div",pA=bi.RenderStrategy|bi.Static;function hA(e,t){let{transition:s=!1,open:r,...a}=e,l=hc(),c=e.hasOwnProperty("open")||l!==null,u=e.hasOwnProperty("onClose");if(!c&&!u)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(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!l&&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)&&!a.static?Oe.createElement(iw,null,Oe.createElement(lA,{show:r,transition:s,unmount:a.unmount},Oe.createElement(lw,{ref:t,...a}))):Oe.createElement(iw,null,Oe.createElement(lw,{ref:t,open:r,...a}))}let gA="div";function xA(e,t){let s=x.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:a=!1,...l}=e,[{dialogState:c,unmount:u},d]=Nf("Dialog.Panel"),p=En(t,d.panelRef),g=As({open:c===0}),y=Qe(k=>{k.stopPropagation()}),h={ref:p,id:r,onClick:y},m=a?Pg:x.Fragment,v=a?{unmount:u}:{},w=cn();return Oe.createElement(m,{...v},w({ourProps:h,theirProps:l,slot:g,defaultTag:gA,name:"Dialog.Panel"}))}let yA="div";function bA(e,t){let{transition:s=!1,...r}=e,[{dialogState:a,unmount:l}]=Nf("Dialog.Backdrop"),c=As({open:a===0}),u={ref:t,"aria-hidden":!0},d=s?Pg:x.Fragment,p=s?{unmount:l}:{},g=cn();return Oe.createElement(d,{...p},g({ourProps:u,theirProps:r,slot:c,defaultTag:yA,name:"Dialog.Backdrop"}))}let vA="h2";function wA(e,t){let s=x.useId(),{id:r=`headlessui-dialog-title-${s}`,...a}=e,[{dialogState:l,setTitleId:c}]=Nf("Dialog.Title"),u=En(t);x.useEffect(()=>(c(r),()=>c(null)),[r,c]);let d=As({open:l===0}),p={ref:u,id:r};return cn()({ourProps:p,theirProps:a,slot:d,defaultTag:vA,name:"Dialog.Title"})}let kA=Yt(hA),k1=Yt(xA),jA=Yt(bA),j1=Yt(wA),NA=Object.assign(kA,{Panel:k1,Title:j1,Description:wj}),cw=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function uw(e){var t,s;let r=(t=e.innerText)!=null?t:"",a=e.cloneNode(!0);if(!is(a))return r;let l=!1;for(let u of a.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))u.remove(),l=!0;let c=l?(s=a.innerText)!=null?s:"":r;return cw.test(c)&&(c=c.replace(cw,"")),c}function SA(e){let t=e.getAttribute("aria-label");if(typeof t=="string")return t.trim();let s=e.getAttribute("aria-labelledby");if(s){let r=s.split(" ").map(a=>{let l=document.getElementById(a);if(l){let c=l.getAttribute("aria-label");return typeof c=="string"?c.trim():uw(l).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return uw(e).trim()}function _A(e){let t=x.useRef(""),s=x.useRef("");return Qe(()=>{let r=e.current;if(!r)return"";let a=r.innerText;if(t.current===a)return s.current;let l=SA(r).trim().toLowerCase();return t.current=a,s.current=l,l})}var $A=Object.defineProperty,EA=(e,t,s)=>t in e?$A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,dw=(e,t,s)=>(EA(e,typeof t!="symbol"?t+"":t,s),s),Sn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Sn||{}),yo=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(yo||{}),pd=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(pd||{}),N1=(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))(N1||{});function fw(e,t=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=Lj(t(e.options.slice()),l=>l.dataRef.current.domRef.current),a=s?r.indexOf(s):null;return a===-1&&(a=null),{options:r,activeOptionIndex:a}}let CA={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let t=e.buttonElement?md.Tracked(f1(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:zt.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:t}},0(e,t){if(e.dataRef.current.disabled||e.listboxState===0)return e;let s=e.activeOptionIndex,{isSelected:r}=e.dataRef.current,a=e.options.findIndex(l=>r(l.dataRef.current.value));return a!==-1&&(s=a),{...e,frozenValue:!1,pendingFocus:t.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:md.Idle}},2(e,t){var s,r,a,l,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let u={...e,searchQuery:"",activationTrigger:(s=t.trigger)!=null?s:1,__demoMode:!1};if(t.focus===zt.Nothing)return{...u,activeOptionIndex:null};if(t.focus===zt.Specific)return{...u,activeOptionIndex:e.options.findIndex(g=>g.id===t.id)};if(t.focus===zt.Previous){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,h=Gu(t,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(h!==null){let m=e.options[h].dataRef.current.domRef;if(((r=y.current)==null?void 0:r.previousElementSibling)===m.current||((a=m.current)==null?void 0:a.previousElementSibling)===null)return{...u,activeOptionIndex:h}}}}else if(t.focus===zt.Next){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,h=Gu(t,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(h!==null){let m=e.options[h].dataRef.current.domRef;if(((l=y.current)==null?void 0:l.nextElementSibling)===m.current||((c=m.current)==null?void 0:c.nextElementSibling)===null)return{...u,activeOptionIndex:h}}}}let d=fw(e),p=Gu(t,{resolveItems:()=>d.options,resolveActiveIndex:()=>d.activeOptionIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});return{...u,...d,activeOptionIndex:p}},3:(e,t)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.searchQuery!==""?0:1,r=e.searchQuery+t.value.toLowerCase(),a=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+s).concat(e.options.slice(0,e.activeOptionIndex+s)):e.options).find(c=>{var u;return!c.dataRef.current.disabled&&((u=c.dataRef.current.textValue)==null?void 0:u.startsWith(r))}),l=a?e.options.indexOf(a):-1;return l===-1||l===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:l,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,t)=>{let s=e.options.concat(t.options),r=e.activeOptionIndex;if(e.pendingFocus.focus!==zt.Nothing&&(r=Gu(e.pendingFocus,{resolveItems:()=>s,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:a}=e.dataRef.current;if(a){let l=s.findIndex(c=>a==null?void 0:a(c.dataRef.current.value));l!==-1&&(r=l)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:zt.Nothing},pendingShouldSort:!0}},7:(e,t)=>{let s=e.options,r=[],a=new Set(t.options);for(let[l,c]of s.entries())if(a.has(c.id)&&(r.push(l),a.delete(c.id),a.size===0))break;if(r.length>0){s=s.slice();for(let l of r.reverse())s.splice(l,1)}return{...e,options:s,activationTrigger:1}},8:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},9:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},10:e=>e.pendingShouldSort?{...e,...fw(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:md.Moved}}};class zg extends $j{constructor(t){super(t),dw(this,"actions",{onChange:s=>{let{onChange:r,compare:a,mode:l,value:c}=this.state.dataRef.current;return zn(l,{0:()=>r==null?void 0:r(s),1:()=>{let u=c.slice(),d=u.findIndex(p=>a(p,s));return d===-1?u.push(s):u.splice(d,1),r==null?void 0:r(u)}})},registerOption:Rp(()=>{let s=[],r=new Set;return[(a,l)=>{r.has(l)||(r.add(l),s.push({id:a,dataRef:l}))},()=>(r.clear(),this.send({type:6,options:s.splice(0)}))]}),unregisterOption:Rp(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:Rp(()=>{let s=null;return[(r,a)=>{s={type:2,...r,trigger:a}},()=>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})}}),dw(this,"selectors",{activeDescendantId(s){var r;let a=s.activeOptionIndex,l=s.options;return a===null||(r=l[a])==null?void 0:r.id},isActive(s,r){var a;let l=s.activeOptionIndex,c=s.options;return l!==null?((a=c[l])==null?void 0:a.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=pf.get(null);this.disposables.add(r.on(Cj.Push,a=>{!r.selectors.isTop(a,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(H3(r.buttonElement,r.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(s,r)=>{var a;this.actions.onChange(r.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(a=this.state.buttonElement)==null||a.focus({preventScroll:!0}))})}static new({id:t,__demoMode:s=!1}){return new zg({id:t,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:zt.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:md.Idle})}reduce(t,s){return zn(s.type,CA,t,s)}}const S1=x.createContext(null);function Dg(e){let t=x.useContext(S1);if(t===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,_1),s}return t}function _1({id:e,__demoMode:t=!1}){let s=x.useMemo(()=>zg.new({id:e,__demoMode:t}),[]);return Mg(()=>s.dispose()),s}let Sf=x.createContext(null);Sf.displayName="ListboxDataContext";function xc(e){let t=x.useContext(Sf);if(t===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,xc),s}return t}let TA=x.Fragment;function RA(e,t){let s=x.useId(),r=$g(),{value:a,defaultValue:l,form:c,name:u,onChange:d,by:p,invalid:g=!1,disabled:y=r||!1,horizontal:h=!1,multiple:m=!1,__demoMode:v=!1,...w}=e;const k=h?"horizontal":"vertical";let N=En(t),A=VC(l),[_=m?[]:void 0,S]=qC(a,d,A),E=_1({id:s,__demoMode:v}),T=x.useRef({static:!1,hold:!1}),C=x.useRef(new Map),R=kT(p),D=x.useCallback(B=>zn(L.mode,{[yo.Multi]:()=>_.some(q=>R(q,B)),[yo.Single]:()=>R(_,B)}),[_]),L=As({value:_,disabled:y,invalid:g,mode:m?yo.Multi:yo.Single,orientation:k,onChange:S,compare:R,isSelected:D,optionsPropsRef:T,listRef:C});Pt(()=>{E.state.dataRef.current=L},[L]);let O=Mn(E,B=>B.listboxState),I=pf.get(null),W=Mn(I,x.useCallback(B=>I.selectors.isTop(B,s),[I,s])),[U,J]=Mn(E,B=>[B.buttonElement,B.optionsElement]);zj(W,[U,J],(B,q)=>{E.send({type:N1.CloseListbox}),Mj(q,Eg.Loose)||(B.preventDefault(),U==null||U.focus())});let F=As({open:O===Sn.Open,disabled:y,invalid:g,value:_}),[Z,z]=pT({inherit:!0}),H={ref:N},V=x.useCallback(()=>{if(A!==void 0)return S==null?void 0:S(A)},[S,A]),P=cn();return Oe.createElement(z,{value:Z,props:{htmlFor:U==null?void 0:U.id},slot:{open:O===Sn.Open,disabled:y}},Oe.createElement($3,null,Oe.createElement(S1.Provider,{value:E},Oe.createElement(Sf.Provider,{value:L},Oe.createElement(a1,{value:zn(O,{[Sn.Open]:Pn.Open,[Sn.Closed]:Pn.Closed})},u!=null&&_!=null&&Oe.createElement(eT,{disabled:y,data:{[u]:_},form:c,onReset:V}),P({ourProps:H,theirProps:w,slot:F,defaultTag:TA,name:"Listbox"}))))))}let AA="button";function OA(e,t){let s=x.useId(),r=hj(),a=xc("Listbox.Button"),l=Dg("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:u=a.disabled||!1,autoFocus:d=!1,...p}=e,g=En(t,j3(),l.actions.setButtonElement),y=N3(),[h,m,v]=Mn(l,J=>[J.listboxState,J.buttonElement,J.optionsElement]),w=h===Sn.Open;qT(w,{trigger:m,action:x.useCallback(J=>{if(m!=null&&m.contains(J.target))return Hu.Ignore;let F=J.target.closest('[role="option"]:not([data-disabled])');return is(F)?Hu.Select(F):v!=null&&v.contains(J.target)?Hu.Ignore:Hu.Close},[m,v]),close:l.actions.closeListbox,select:l.actions.selectActiveOption});let k=Qe(J=>{switch(J.key){case en.Enter:KC(J.currentTarget);break;case en.Space:case en.ArrowDown:J.preventDefault(),l.actions.openListbox({focus:a.value?zt.Nothing:zt.First});break;case en.ArrowUp:J.preventDefault(),l.actions.openListbox({focus:a.value?zt.Nothing:zt.Last});break}}),N=Qe(J=>{switch(J.key){case en.Space:J.preventDefault();break}}),A=NT(J=>{var F;l.state.listboxState===Sn.Open?(fr.flushSync(()=>l.actions.closeListbox()),(F=l.state.buttonElement)==null||F.focus({preventScroll:!0})):(J.preventDefault(),l.actions.openListbox({focus:zt.Nothing}))}),_=Qe(J=>J.preventDefault()),S=jj([c]),E=cT(),{isFocusVisible:T,focusProps:C}=TC({autoFocus:d}),{isHovered:R,hoverProps:D}=OC({isDisabled:u}),{pressed:L,pressProps:O}=DC({disabled:u}),I=As({open:h===Sn.Open,active:L||h===Sn.Open,disabled:u,invalid:a.invalid,value:a.value,hover:R,focus:T,autofocus:d}),W=Mn(l,J=>J.listboxState===Sn.Open),U=uj(y(),{ref:g,id:c,type:VT(e,m),"aria-haspopup":"listbox","aria-controls":v==null?void 0:v.id,"aria-expanded":W,"aria-labelledby":S,"aria-describedby":E,disabled:u||void 0,autoFocus:d,onKeyDown:k,onKeyUp:N,onKeyPress:_},A,C,D,O);return cn()({ourProps:U,theirProps:p,slot:I,defaultTag:AA,name:"Listbox.Button"})}let $1=x.createContext(!1),MA="div",LA=bi.RenderStrategy|bi.Static;function PA(e,t){let s=x.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:a,portal:l=!1,modal:c=!0,transition:u=!1,...d}=e,p=k3(a),[g,y]=x.useState(null);p&&(l=!0);let h=xc("Listbox.Options"),m=Dg("Listbox.Options"),[v,w,k,N]=Mn(m,ue=>[ue.listboxState,ue.buttonElement,ue.optionsElement,ue.__demoMode]),A=Vl(w),_=Vl(k),S=hc(),[E,T]=Wj(u,g,S!==null?(S&Pn.Open)===Pn.Open:v===Sn.Open);Aj(E,w,m.actions.closeListbox);let C=N?!1:c&&v===Sn.Open;Fj(C,_);let R=N?!1:c&&v===Sn.Open;Rj(R,{allowed:x.useCallback(()=>[w,k],[w,k])});let D=Mn(m,m.selectors.didButtonMove)?!1:E,L=Mn(m,m.selectors.hasFrozenValue)&&!e.static,O=o1(L,h.value),I=x.useCallback(ue=>h.compare(O,ue),[h.compare,O]),W=Mn(m,ue=>{var Q;if(p==null||!((Q=p==null?void 0:p.to)!=null&&Q.includes("selection")))return null;let fe=ue.options.findIndex(ye=>I(ye.dataRef.current.value));return fe===-1&&(fe=0),fe}),U=(()=>{if(p==null)return;if(W===null)return{...p,inner:void 0};let ue=Array.from(h.listRef.current.values());return{...p,inner:{listRef:{current:ue},index:W}}})(),[J,F]=_3(U),Z=S3(),z=En(t,p?J:null,m.actions.setOptionsElement,y),H=_o();x.useEffect(()=>{let ue=k;ue&&v===Sn.Open&&(lj(ue)||ue==null||ue.focus({preventScroll:!0}))},[v,k]);let V=Qe(ue=>{var Q;switch(H.dispose(),ue.key){case en.Space:if(m.state.searchQuery!=="")return ue.preventDefault(),ue.stopPropagation(),m.actions.search(ue.key);case en.Enter:ue.preventDefault(),ue.stopPropagation(),m.actions.selectActiveOption();break;case zn(h.orientation,{vertical:en.ArrowDown,horizontal:en.ArrowRight}):return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:zt.Next});case zn(h.orientation,{vertical:en.ArrowUp,horizontal:en.ArrowLeft}):return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:zt.Previous});case en.Home:case en.PageUp:return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:zt.First});case en.End:case en.PageDown:return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:zt.Last});case en.Escape:ue.preventDefault(),ue.stopPropagation(),fr.flushSync(()=>m.actions.closeListbox()),(Q=m.state.buttonElement)==null||Q.focus({preventScroll:!0});return;case en.Tab:ue.preventDefault(),ue.stopPropagation(),fr.flushSync(()=>m.actions.closeListbox()),WT(m.state.buttonElement,ue.shiftKey?Ks.Previous:Ks.Next);break;default:ue.key.length===1&&(m.actions.search(ue.key),H.setTimeout(()=>m.actions.clearSearch(),350));break}}),P=Mn(m,ue=>{var Q;return(Q=ue.buttonElement)==null?void 0:Q.id}),B=As({open:v===Sn.Open}),q=uj(p?Z():{},{id:r,ref:z,"aria-activedescendant":Mn(m,m.selectors.activeDescendantId),"aria-multiselectable":h.mode===yo.Multi?!0:void 0,"aria-labelledby":P,"aria-orientation":h.orientation,onKeyDown:V,role:"listbox",tabIndex:v===Sn.Open?0:void 0,style:{...d.style,...F,"--button-width":jT(E,w,!0).width},...Uj(T)}),ce=cn(),de=x.useMemo(()=>h.mode===yo.Multi?h:{...h,isSelected:I},[h,I]);return Oe.createElement(d1,{enabled:l?e.static||E:!1,ownerDocument:A},Oe.createElement(Sf.Provider,{value:de},ce({ourProps:q,theirProps:d,slot:B,defaultTag:MA,features:LA,visible:D,name:"Listbox.Options"})))}let IA="div";function zA(e,t){let s=x.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:a=!1,value:l,...c}=e,u=x.useContext($1)===!0,d=xc("Listbox.Option"),p=Dg("Listbox.Option"),g=Mn(p,L=>p.selectors.isActive(L,r)),y=d.isSelected(l),h=x.useRef(null),m=_A(h),v=$o({disabled:a,value:l,domRef:h,get textValue(){return m()}}),w=En(t,h,L=>{L?d.listRef.current.set(r,L):d.listRef.current.delete(r)}),k=Mn(p,L=>p.selectors.shouldScrollIntoView(L,r));Pt(()=>{if(k)return us().requestAnimationFrame(()=>{var L,O;(O=(L=h.current)==null?void 0:L.scrollIntoView)==null||O.call(L,{block:"nearest"})})},[k,h]),Pt(()=>{if(!u)return p.actions.registerOption(r,v),()=>p.actions.unregisterOption(r)},[v,r,u]);let N=Qe(L=>{if(a)return L.preventDefault();p.actions.selectOption(l)}),A=Qe(()=>{if(a)return p.actions.goToOption({focus:zt.Nothing});p.actions.goToOption({focus:zt.Specific,id:r})}),_=eR(),S=Qe(L=>_.update(L)),E=Qe(L=>{_.wasMoved(L)&&(a||g&&p.state.activationTrigger===pd.Pointer||p.actions.goToOption({focus:zt.Specific,id:r},pd.Pointer))}),T=Qe(L=>{_.wasMoved(L)&&(a||g&&p.state.activationTrigger===pd.Pointer&&p.actions.goToOption({focus:zt.Nothing}))}),C=As({active:g,focus:g,selected:y,disabled:a,selectedOption:y&&u}),R=u?{}:{id:r,ref:w,role:"option",tabIndex:a===!0?void 0:-1,"aria-disabled":a===!0?!0:void 0,"aria-selected":y,disabled:void 0,onClick:N,onFocus:A,onPointerEnter:S,onMouseEnter:S,onPointerMove:E,onMouseMove:E,onPointerLeave:T,onMouseLeave:T},D=cn();return!y&&u?null:D({ourProps:R,theirProps:c,slot:C,defaultTag:IA,name:"Listbox.Option"})}let DA=x.Fragment;function FA(e,t){let{options:s,placeholder:r,...a}=e,l={ref:En(t)},c=xc("ListboxSelectedOption"),u=As({}),d=c.value===void 0||c.value===null||c.mode===yo.Multi&&Array.isArray(c.value)&&c.value.length===0,p=cn();return Oe.createElement($1.Provider,{value:!0},p({ourProps:l,theirProps:{...a,children:Oe.createElement(Oe.Fragment,null,r&&d?r:s)},slot:u,defaultTag:DA,name:"ListboxSelectedOption"}))}let UA=Yt(RA),E1=Yt(OA),WA=yT,C1=Yt(PA),T1=Yt(zA),HA=Yt(FA),BA=Object.assign(UA,{Button:E1,Label:WA,Options:C1,Option:T1,SelectedOption:HA});const Fg=x.createContext(null),GA=()=>x.useContext(Fg);function Ug(e){const t=x.useContext(Fg);return{id:e.id??(t==null?void 0:t.id),"aria-describedby":e["aria-describedby"]??(t==null?void 0:t.describedBy),"aria-invalid":e["aria-invalid"]??((t==null?void 0:t.invalid)||void 0),"aria-required":e["aria-required"]??((t==null?void 0:t.required)&&!e.required||void 0)}}function Xs({label:e,id:t,required:s,optional:r,note:a,hint:l,error:c,warning:u,aside:d,group:p,className:g,children:y}){const h=x.useId(),m=t??`${h}-control`,[v,w,k,N,A]=[`${h}-label`,`${h}-note`,`${h}-hint`,`${h}-error`,`${h}-warning`],_=[a&&w,l&&k,c&&N,u&&A].filter(Boolean).join(" ")||void 0,S=n.jsxs(n.Fragment,{children:[e,s&&n.jsx("span",{className:"text-destructive-text","aria-hidden":!0,children:" *"}),r&&n.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:" (optional)"})]});return n.jsxs("div",{className:g,...p===!0?{role:"group","aria-labelledby":v,"aria-describedby":_}:{},children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[p?n.jsx("span",{id:v,className:"caps text-small font-semibold",children:S}):n.jsx("label",{id:v,htmlFor:m,className:"caps text-small font-semibold",children:S}),d]}),a&&n.jsx("p",{id:w,className:"-mt-1 mb-2 text-small text-muted-foreground",children:a}),n.jsx(Fg.Provider,{value:p?null:{id:m,describedBy:_,invalid:!!c,required:!!s},children:y}),l&&n.jsx("p",{id:k,className:"mt-1.5 text-small text-muted-foreground",children:l}),c&&n.jsx("p",{id:N,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),u&&n.jsx("p",{id:A,className:"mt-2 font-mono text-small text-warning-text",children:u})]})}const R1="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",A1="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",O1="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",Be=x.forwardRef(({className:e,fieldSize:t="md",bare:s,...r},a)=>n.jsx("input",{ref:a,...r,...Ug(r),className:ie(s?A1:ie(R1,t==="sm"?"h-control-sm":"h-control-md"),e)}));Be.displayName="Input";const ds=x.forwardRef(({className:e,bare:t,...s},r)=>n.jsx("textarea",{ref:r,...s,...Ug(s),className:ie(t?A1:ie(R1,"py-2.5"),e)}));ds.displayName="Textarea";const M1=e=>{const t=x.forwardRef(({label:s,note:r,className:a,disabled:l,...c},u)=>n.jsxs("label",{className:ie("flex items-start gap-2.5 text-body",l?"cursor-not-allowed opacity-45":"cursor-pointer",a),children:[n.jsx("input",{ref:u,type:e,disabled:l,...c,...Ug(c),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block",children:s}),r&&n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:r})]})]}));return t.displayName=e==="checkbox"?"Checkbox":"Radio",t},qA=M1("checkbox");M1("radio");function Lt({value:e,onChange:t,options:s,label:r,id:a,className:l,disabled:c=!1,name:u,small:d=!1,placeholder:p,autoFocus:g}){const y=s.find(m=>m.value===e),h=GA();return n.jsxs(BA,{value:e,onChange:t,disabled:c,name:u,children:[n.jsxs(E1,{id:a??(h==null?void 0:h.id),autoFocus:g,"aria-label":r,"aria-describedby":h==null?void 0:h.describedBy,"aria-invalid":(h==null?void 0:h.invalid)||void 0,"data-value":e,className:ie("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",d?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",l),children:[n.jsx("span",{className:ie("min-w-0 truncate",!y&&"text-muted-foreground"),children:(y==null?void 0:y.label)??p??""}),n.jsx(va,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),n.jsx(C1,{anchor:"bottom start","data-picker-list":"",className:"z-popover max-h-72 w-[var(--button-width)] min-w-[12rem] overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",children:s.map(m=>n.jsxs(T1,{value:m.value,disabled:m.disabled,title:m.title,"data-value":m.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:[n.jsx(uc,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 break-words",children:m.label})]},m.value))})]})}const L1=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<t.id?-1:e.id>t.id?1:0),_f=e=>[...e].sort((t,s)=>L1({name:t.definition.name||t.agent_id,id:t.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_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:P1,setPrototypeOf:mw,isFrozen:VA,getPrototypeOf:KA,getOwnPropertyDescriptor:YA}=Object;let{freeze:Dn,seal:Os,create:I1}=Object,{apply:Ch,construct:Th}=typeof Reflect<"u"&&Reflect;Dn||(Dn=function(t){return t});Os||(Os=function(t){return t});Ch||(Ch=function(t,s,r){return t.apply(s,r)});Th||(Th=function(t,s){return new t(...s)});const qu=ls(Array.prototype.forEach),pw=ls(Array.prototype.pop),kl=ls(Array.prototype.push),hd=ls(String.prototype.toLowerCase),Fp=ls(String.prototype.toString),hw=ls(String.prototype.match),jl=ls(String.prototype.replace),XA=ls(String.prototype.indexOf),QA=ls(String.prototype.trim),qs=ls(Object.prototype.hasOwnProperty),On=ls(RegExp.prototype.test),Nl=JA(TypeError);function ls(e){return function(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return Ch(e,t,r)}}function JA(e){return function(){for(var t=arguments.length,s=new Array(t),r=0;r<t;r++)s[r]=arguments[r];return Th(e,s)}}function ct(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:hd;mw&&mw(e,null);let r=t.length;for(;r--;){let a=t[r];if(typeof a=="string"){const l=s(a);l!==a&&(VA(t)||(t[r]=l),a=l)}e[a]=!0}return e}function ZA(e){for(let t=0;t<e.length;t++)qs(e,t)||(e[t]=null);return e}function Xo(e){const t=I1(null);for(const[s,r]of P1(e))qs(e,s)&&(Array.isArray(r)?t[s]=ZA(r):r&&typeof r=="object"&&r.constructor===Object?t[s]=Xo(r):t[s]=r);return t}function Sl(e,t){for(;e!==null;){const r=YA(e,t);if(r){if(r.get)return ls(r.get);if(typeof r.value=="function")return ls(r.value)}e=KA(e)}function s(){return null}return s}const gw=Dn(["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"]),Up=Dn(["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"]),Wp=Dn(["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"]),eO=Dn(["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"]),Hp=Dn(["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"]),tO=Dn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),xw=Dn(["#text"]),yw=Dn(["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"]),Bp=Dn(["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"]),bw=Dn(["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"]),Vu=Dn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nO=Os(/\{\{[\w\W]*|[\w\W]*\}\}/gm),sO=Os(/<%[\w\W]*|[\w\W]*%>/gm),rO=Os(/\$\{[\w\W]*}/gm),oO=Os(/^data-[\-\w.\u00B7-\uFFFF]+$/),aO=Os(/^aria-[\-\w]+$/),z1=Os(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),iO=Os(/^(?:\w+script|data):/i),lO=Os(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),D1=Os(/^html$/i),cO=Os(/^[a-z][.\w]*(-[.\w]+)+$/i);var vw=Object.freeze({__proto__:null,ARIA_ATTR:aO,ATTR_WHITESPACE:lO,CUSTOM_ELEMENT:cO,DATA_ATTR:oO,DOCTYPE_NAME:D1,ERB_EXPR:sO,IS_ALLOWED_URI:z1,IS_SCRIPT_OR_DATA:iO,MUSTACHE_EXPR:nO,TMPLIT_EXPR:rO});const _l={element:1,text:3,progressingInstruction:7,comment:8,document:9},uO=function(){return typeof window>"u"?null:window},dO=function(t,s){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const a="data-tt-policy-suffix";s&&s.hasAttribute(a)&&(r=s.getAttribute(a));const l="dompurify"+(r?"#"+r:"");try{return t.createPolicy(l,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+l+" could not be created."),null}},ww=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function F1(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:uO();const t=He=>F1(He);if(t.version="3.2.3",t.removed=[],!e||!e.document||e.document.nodeType!==_l.document)return t.isSupported=!1,t;let{document:s}=e;const r=s,a=r.currentScript,{DocumentFragment:l,HTMLTemplateElement:c,Node:u,Element:d,NodeFilter:p,NamedNodeMap:g=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:y,DOMParser:h,trustedTypes:m}=e,v=d.prototype,w=Sl(v,"cloneNode"),k=Sl(v,"remove"),N=Sl(v,"nextSibling"),A=Sl(v,"childNodes"),_=Sl(v,"parentNode");if(typeof c=="function"){const He=s.createElement("template");He.content&&He.content.ownerDocument&&(s=He.content.ownerDocument)}let S,E="";const{implementation:T,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:D}=s,{importNode:L}=r;let O=ww();t.isSupported=typeof P1=="function"&&typeof _=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:I,ERB_EXPR:W,TMPLIT_EXPR:U,DATA_ATTR:J,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:Z,ATTR_WHITESPACE:z,CUSTOM_ELEMENT:H}=vw;let{IS_ALLOWED_URI:V}=vw,P=null;const B=ct({},[...gw,...Up,...Wp,...Hp,...xw]);let q=null;const ce=ct({},[...yw,...Bp,...bw,...Vu]);let de=Object.seal(I1(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}})),ue=null,Q=null,fe=!0,ye=!0,Ee=!1,ge=!0,se=!1,pe=!0,Y=!1,_e=!1,Ze=!1,Je=!1,xt=!1,et=!1,ae=!0,Ae=!1;const Ce="user-content-";let Ge=!0,kt=!1,We={},rt=null;const yn=ct({},["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 Dt=null;const sn=ct({},["audio","video","img","source","image","track"]);let me=null;const Te=ct({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",Fe="http://www.w3.org/2000/svg",lt="http://www.w3.org/1999/xhtml";let Ke=lt,Ft=!1,Qn=null;const Jn=ct({},[tt,Fe,lt],Fp);let Zn=ct({},["mi","mo","mn","ms","mtext"]),bn=ct({},["annotation-xml"]);const es=ct({},["title","style","font","a","script"]);let un=null;const ms=["application/xhtml+xml","text/html"],gr="text/html";let Nt=null,Cn=null;const ps=s.createElement("form"),hs=function(te){return te instanceof RegExp||te instanceof Function},gs=function(){let te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Cn&&Cn===te)){if((!te||typeof te!="object")&&(te={}),te=Xo(te),un=ms.indexOf(te.PARSER_MEDIA_TYPE)===-1?gr:te.PARSER_MEDIA_TYPE,Nt=un==="application/xhtml+xml"?Fp:hd,P=qs(te,"ALLOWED_TAGS")?ct({},te.ALLOWED_TAGS,Nt):B,q=qs(te,"ALLOWED_ATTR")?ct({},te.ALLOWED_ATTR,Nt):ce,Qn=qs(te,"ALLOWED_NAMESPACES")?ct({},te.ALLOWED_NAMESPACES,Fp):Jn,me=qs(te,"ADD_URI_SAFE_ATTR")?ct(Xo(Te),te.ADD_URI_SAFE_ATTR,Nt):Te,Dt=qs(te,"ADD_DATA_URI_TAGS")?ct(Xo(sn),te.ADD_DATA_URI_TAGS,Nt):sn,rt=qs(te,"FORBID_CONTENTS")?ct({},te.FORBID_CONTENTS,Nt):yn,ue=qs(te,"FORBID_TAGS")?ct({},te.FORBID_TAGS,Nt):{},Q=qs(te,"FORBID_ATTR")?ct({},te.FORBID_ATTR,Nt):{},We=qs(te,"USE_PROFILES")?te.USE_PROFILES:!1,fe=te.ALLOW_ARIA_ATTR!==!1,ye=te.ALLOW_DATA_ATTR!==!1,Ee=te.ALLOW_UNKNOWN_PROTOCOLS||!1,ge=te.ALLOW_SELF_CLOSE_IN_ATTR!==!1,se=te.SAFE_FOR_TEMPLATES||!1,pe=te.SAFE_FOR_XML!==!1,Y=te.WHOLE_DOCUMENT||!1,Je=te.RETURN_DOM||!1,xt=te.RETURN_DOM_FRAGMENT||!1,et=te.RETURN_TRUSTED_TYPE||!1,Ze=te.FORCE_BODY||!1,ae=te.SANITIZE_DOM!==!1,Ae=te.SANITIZE_NAMED_PROPS||!1,Ge=te.KEEP_CONTENT!==!1,kt=te.IN_PLACE||!1,V=te.ALLOWED_URI_REGEXP||z1,Ke=te.NAMESPACE||lt,Zn=te.MATHML_TEXT_INTEGRATION_POINTS||Zn,bn=te.HTML_INTEGRATION_POINTS||bn,de=te.CUSTOM_ELEMENT_HANDLING||{},te.CUSTOM_ELEMENT_HANDLING&&hs(te.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(de.tagNameCheck=te.CUSTOM_ELEMENT_HANDLING.tagNameCheck),te.CUSTOM_ELEMENT_HANDLING&&hs(te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(de.attributeNameCheck=te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),te.CUSTOM_ELEMENT_HANDLING&&typeof te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),se&&(ye=!1),xt&&(Je=!0),We&&(P=ct({},xw),q=[],We.html===!0&&(ct(P,gw),ct(q,yw)),We.svg===!0&&(ct(P,Up),ct(q,Bp),ct(q,Vu)),We.svgFilters===!0&&(ct(P,Wp),ct(q,Bp),ct(q,Vu)),We.mathMl===!0&&(ct(P,Hp),ct(q,bw),ct(q,Vu))),te.ADD_TAGS&&(P===B&&(P=Xo(P)),ct(P,te.ADD_TAGS,Nt)),te.ADD_ATTR&&(q===ce&&(q=Xo(q)),ct(q,te.ADD_ATTR,Nt)),te.ADD_URI_SAFE_ATTR&&ct(me,te.ADD_URI_SAFE_ATTR,Nt),te.FORBID_CONTENTS&&(rt===yn&&(rt=Xo(rt)),ct(rt,te.FORBID_CONTENTS,Nt)),Ge&&(P["#text"]=!0),Y&&ct(P,["html","head","body"]),P.table&&(ct(P,["tbody"]),delete ue.tbody),te.TRUSTED_TYPES_POLICY){if(typeof te.TRUSTED_TYPES_POLICY.createHTML!="function")throw Nl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof te.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Nl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=te.TRUSTED_TYPES_POLICY,E=S.createHTML("")}else S===void 0&&(S=dO(m,a)),S!==null&&typeof E=="string"&&(E=S.createHTML(""));Dn&&Dn(te),Cn=te}},Un=ct({},[...Up,...Wp,...eO]),Ms=ct({},[...Hp,...tO]),ee=function(te){let ve=_(te);(!ve||!ve.tagName)&&(ve={namespaceURI:Ke,tagName:"template"});const Me=hd(te.tagName),vt=hd(ve.tagName);return Qn[te.namespaceURI]?te.namespaceURI===Fe?ve.namespaceURI===lt?Me==="svg":ve.namespaceURI===tt?Me==="svg"&&(vt==="annotation-xml"||Zn[vt]):!!Un[Me]:te.namespaceURI===tt?ve.namespaceURI===lt?Me==="math":ve.namespaceURI===Fe?Me==="math"&&bn[vt]:!!Ms[Me]:te.namespaceURI===lt?ve.namespaceURI===Fe&&!bn[vt]||ve.namespaceURI===tt&&!Zn[vt]?!1:!Ms[Me]&&(es[Me]||!Un[Me]):!!(un==="application/xhtml+xml"&&Qn[te.namespaceURI]):!1},Se=function(te){kl(t.removed,{element:te});try{_(te).removeChild(te)}catch{k(te)}},Ye=function(te,ve){try{kl(t.removed,{attribute:ve.getAttributeNode(te),from:ve})}catch{kl(t.removed,{attribute:null,from:ve})}if(ve.removeAttribute(te),te==="is")if(Je||xt)try{Se(ve)}catch{}else try{ve.setAttribute(te,"")}catch{}},ft=function(te){let ve=null,Me=null;if(Ze)te="<remove></remove>"+te;else{const nt=hw(te,/^[\r\n\t ]+/);Me=nt&&nt[0]}un==="application/xhtml+xml"&&Ke===lt&&(te='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+te+"</body></html>");const vt=S?S.createHTML(te):te;if(Ke===lt)try{ve=new h().parseFromString(vt,un)}catch{}if(!ve||!ve.documentElement){ve=T.createDocument(Ke,"template",null);try{ve.documentElement.innerHTML=Ft?E:vt}catch{}}const Wt=ve.body||ve.documentElement;return te&&Me&&Wt.insertBefore(s.createTextNode(Me),Wt.childNodes[0]||null),Ke===lt?D.call(ve,Y?"html":"body")[0]:Y?ve.documentElement:Wt},jt=function(te){return C.call(te.ownerDocument||te,te,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Ut=function(te){return te instanceof y&&(typeof te.nodeName!="string"||typeof te.textContent!="string"||typeof te.removeChild!="function"||!(te.attributes instanceof g)||typeof te.removeAttribute!="function"||typeof te.setAttribute!="function"||typeof te.namespaceURI!="string"||typeof te.insertBefore!="function"||typeof te.hasChildNodes!="function")},vn=function(te){return typeof u=="function"&&te instanceof u};function St(He,te,ve){qu(He,Me=>{Me.call(t,te,ve,Cn)})}const zr=function(te){let ve=null;if(St(O.beforeSanitizeElements,te,null),Ut(te))return Se(te),!0;const Me=Nt(te.nodeName);if(St(O.uponSanitizeElement,te,{tagName:Me,allowedTags:P}),te.hasChildNodes()&&!vn(te.firstElementChild)&&On(/<[/\w]/g,te.innerHTML)&&On(/<[/\w]/g,te.textContent)||te.nodeType===_l.progressingInstruction||pe&&te.nodeType===_l.comment&&On(/<[/\w]/g,te.data))return Se(te),!0;if(!P[Me]||ue[Me]){if(!ue[Me]&&Ls(Me)&&(de.tagNameCheck instanceof RegExp&&On(de.tagNameCheck,Me)||de.tagNameCheck instanceof Function&&de.tagNameCheck(Me)))return!1;if(Ge&&!rt[Me]){const vt=_(te)||te.parentNode,Wt=A(te)||te.childNodes;if(Wt&&vt){const nt=Wt.length;for(let Qt=nt-1;Qt>=0;--Qt){const dn=w(Wt[Qt],!0);dn.__removalCount=(te.__removalCount||0)+1,vt.insertBefore(dn,N(te))}}}return Se(te),!0}return te instanceof d&&!ee(te)||(Me==="noscript"||Me==="noembed"||Me==="noframes")&&On(/<\/no(script|embed|frames)/i,te.innerHTML)?(Se(te),!0):(se&&te.nodeType===_l.text&&(ve=te.textContent,qu([I,W,U],vt=>{ve=jl(ve,vt," ")}),te.textContent!==ve&&(kl(t.removed,{element:te.cloneNode()}),te.textContent=ve)),St(O.afterSanitizeElements,te,null),!1)},Tn=function(te,ve,Me){if(ae&&(ve==="id"||ve==="name")&&(Me in s||Me in ps))return!1;if(!(ye&&!Q[ve]&&On(J,ve))){if(!(fe&&On(F,ve))){if(!q[ve]||Q[ve]){if(!(Ls(te)&&(de.tagNameCheck instanceof RegExp&&On(de.tagNameCheck,te)||de.tagNameCheck instanceof Function&&de.tagNameCheck(te))&&(de.attributeNameCheck instanceof RegExp&&On(de.attributeNameCheck,ve)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(ve))||ve==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&On(de.tagNameCheck,Me)||de.tagNameCheck instanceof Function&&de.tagNameCheck(Me))))return!1}else if(!me[ve]){if(!On(V,jl(Me,z,""))){if(!((ve==="src"||ve==="xlink:href"||ve==="href")&&te!=="script"&&XA(Me,"data:")===0&&Dt[te])){if(!(Ee&&!On(Z,jl(Me,z,"")))){if(Me)return!1}}}}}}return!0},Ls=function(te){return te!=="annotation-xml"&&hw(te,H)},Ps=function(te){St(O.beforeSanitizeAttributes,te,null);const{attributes:ve}=te;if(!ve||Ut(te))return;const Me={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let vt=ve.length;for(;vt--;){const Wt=ve[vt],{name:nt,namespaceURI:Qt,value:dn}=Wt,Is=Nt(nt);let At=nt==="value"?dn:QA(dn);if(Me.attrName=Is,Me.attrValue=At,Me.keepAttr=!0,Me.forceKeepAttr=void 0,St(O.uponSanitizeAttribute,te,Me),At=Me.attrValue,Ae&&(Is==="id"||Is==="name")&&(Ye(nt,te),At=Ce+At),pe&&On(/((--!?|])>)|<\/(style|title)/i,At)){Ye(nt,te);continue}if(Me.forceKeepAttr||(Ye(nt,te),!Me.keepAttr))continue;if(!ge&&On(/\/>/i,At)){Ye(nt,te);continue}se&&qu([I,W,U],Dr=>{At=jl(At,Dr," ")});const To=Nt(te.nodeName);if(Tn(To,Is,At)){if(S&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Qt)switch(m.getAttributeType(To,Is)){case"TrustedHTML":{At=S.createHTML(At);break}case"TrustedScriptURL":{At=S.createScriptURL(At);break}}try{Qt?te.setAttributeNS(Qt,nt,At):te.setAttribute(nt,At),Ut(te)?Se(te):pw(t.removed)}catch{}}}St(O.afterSanitizeAttributes,te,null)},$a=function He(te){let ve=null;const Me=jt(te);for(St(O.beforeSanitizeShadowDOM,te,null);ve=Me.nextNode();)St(O.uponSanitizeShadowNode,ve,null),zr(ve),Ps(ve),ve.content instanceof l&&He(ve.content);St(O.afterSanitizeShadowDOM,te,null)};return t.sanitize=function(He){let te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ve=null,Me=null,vt=null,Wt=null;if(Ft=!He,Ft&&(He="<!-->"),typeof He!="string"&&!vn(He))if(typeof He.toString=="function"){if(He=He.toString(),typeof He!="string")throw Nl("dirty is not a string, aborting")}else throw Nl("toString is not a function");if(!t.isSupported)return He;if(_e||gs(te),t.removed=[],typeof He=="string"&&(kt=!1),kt){if(He.nodeName){const dn=Nt(He.nodeName);if(!P[dn]||ue[dn])throw Nl("root node is forbidden and cannot be sanitized in-place")}}else if(He instanceof u)ve=ft("<!---->"),Me=ve.ownerDocument.importNode(He,!0),Me.nodeType===_l.element&&Me.nodeName==="BODY"||Me.nodeName==="HTML"?ve=Me:ve.appendChild(Me);else{if(!Je&&!se&&!Y&&He.indexOf("<")===-1)return S&&et?S.createHTML(He):He;if(ve=ft(He),!ve)return Je?null:et?E:""}ve&&Ze&&Se(ve.firstChild);const nt=jt(kt?He:ve);for(;vt=nt.nextNode();)zr(vt),Ps(vt),vt.content instanceof l&&$a(vt.content);if(kt)return He;if(Je){if(xt)for(Wt=R.call(ve.ownerDocument);ve.firstChild;)Wt.appendChild(ve.firstChild);else Wt=ve;return(q.shadowroot||q.shadowrootmode)&&(Wt=L.call(r,Wt,!0)),Wt}let Qt=Y?ve.outerHTML:ve.innerHTML;return Y&&P["!doctype"]&&ve.ownerDocument&&ve.ownerDocument.doctype&&ve.ownerDocument.doctype.name&&On(D1,ve.ownerDocument.doctype.name)&&(Qt="<!DOCTYPE "+ve.ownerDocument.doctype.name+`>
468
+ `+Qt),se&&qu([I,W,U],dn=>{Qt=jl(Qt,dn," ")}),S&&et?S.createHTML(Qt):Qt},t.setConfig=function(){let He=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};gs(He),_e=!0},t.clearConfig=function(){Cn=null,_e=!1},t.isValidAttribute=function(He,te,ve){Cn||gs({});const Me=Nt(He),vt=Nt(te);return Tn(Me,vt,ve)},t.addHook=function(He,te){typeof te=="function"&&kl(O[He],te)},t.removeHook=function(He){return pw(O[He])},t.removeHooks=function(He){O[He]=[]},t.removeAllHooks=function(){O=ww()},t}var gd=F1();function Wg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Na=Wg();function U1(e){Na=e}const Fl={exec:()=>null};function wt(e,t=""){let s=typeof e=="string"?e:e.source;const r={replace:(a,l)=>{let c=typeof l=="string"?l:l.source;return c=c.replace(In.caret,"$1"),s=s.replace(a,c),r},getRegex:()=>new RegExp(s,t)};return r}const In={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")},fO=/^(?:[ \t]*(?:\n|$))+/,mO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,pO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,yc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,W1=/(?:[*+-]|\d{1,9}[.)])/,H1=wt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,W1).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(),Hg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,gO=/^[^\n]+/,Bg=/(?!\s*\])(?:\\.|[^\[\]\\])+/,xO=wt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),yO=wt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,W1).getRegex(),$f="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",Gg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bO=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",Gg).replace("tag",$f).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),B1=wt(Hg).replace("hr",yc).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",$f).getRegex(),vO=wt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",B1).getRegex(),qg={blockquote:vO,code:mO,def:xO,fences:pO,heading:hO,hr:yc,html:bO,lheading:H1,list:yO,newline:fO,paragraph:B1,table:Fl,text:gO},kw=wt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",yc).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",$f).getRegex(),wO={...qg,table:kw,paragraph:wt(Hg).replace("hr",yc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",kw).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",$f).getRegex()},kO={...qg,html:wt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Gg).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:Fl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:wt(Hg).replace("hr",yc).replace("heading",` *#{1,6} *[^
469
+ ]`).replace("lheading",H1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},jO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,NO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,G1=/^( {2,}|\\)\n(?!\s*$)/,SO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ef=/[\p{P}\p{S}]/u,Vg=/[\s\p{P}\p{S}]/u,q1=/[^\s\p{P}\p{S}]/u,_O=wt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Vg).getRegex(),V1=/(?!~)[\p{P}\p{S}]/u,$O=/(?!~)[\s\p{P}\p{S}]/u,EO=/(?:[^\s\p{P}\p{S}]|~)/u,CO=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,K1=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,TO=wt(K1,"u").replace(/punct/g,Ef).getRegex(),RO=wt(K1,"u").replace(/punct/g,V1).getRegex(),Y1="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",AO=wt(Y1,"gu").replace(/notPunctSpace/g,q1).replace(/punctSpace/g,Vg).replace(/punct/g,Ef).getRegex(),OO=wt(Y1,"gu").replace(/notPunctSpace/g,EO).replace(/punctSpace/g,$O).replace(/punct/g,V1).getRegex(),MO=wt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,q1).replace(/punctSpace/g,Vg).replace(/punct/g,Ef).getRegex(),LO=wt(/\\(punct)/,"gu").replace(/punct/g,Ef).getRegex(),PO=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(),IO=wt(Gg).replace("(?:-->|$)","-->").getRegex(),zO=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",IO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Rd=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,DO=wt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Rd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),X1=wt(/^!?\[(label)\]\[(ref)\]/).replace("label",Rd).replace("ref",Bg).getRegex(),Q1=wt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bg).getRegex(),FO=wt("reflink|nolink(?!\\()","g").replace("reflink",X1).replace("nolink",Q1).getRegex(),Kg={_backpedal:Fl,anyPunctuation:LO,autolink:PO,blockSkip:CO,br:G1,code:NO,del:Fl,emStrongLDelim:TO,emStrongRDelimAst:AO,emStrongRDelimUnd:MO,escape:jO,link:DO,nolink:Q1,punctuation:_O,reflink:X1,reflinkSearch:FO,tag:zO,text:SO,url:Fl},UO={...Kg,link:wt(/^!?\[(label)\]\((.*?)\)/).replace("label",Rd).getRegex(),reflink:wt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Rd).getRegex()},Rh={...Kg,emStrongRDelimAst:OO,emStrongLDelim:RO,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.!#$%&'*+\/=?_`{\|}~-]+@)))/},WO={...Rh,br:wt(G1).replace("{2,}","*").getRegex(),text:wt(Rh.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ku={normal:qg,gfm:wO,pedantic:kO},$l={normal:Kg,gfm:Rh,breaks:WO,pedantic:UO},HO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},jw=e=>HO[e];function ir(e,t){if(t){if(In.escapeTest.test(e))return e.replace(In.escapeReplace,jw)}else if(In.escapeTestNoEncode.test(e))return e.replace(In.escapeReplaceNoEncode,jw);return e}function Nw(e){try{e=encodeURI(e).replace(In.percentDecode,"%")}catch{return null}return e}function Sw(e,t){var l;const s=e.replace(In.findPipe,(c,u,d)=>{let p=!1,g=u;for(;--g>=0&&d[g]==="\\";)p=!p;return p?"|":" |"}),r=s.split(In.splitPipe);let a=0;if(r[0].trim()||r.shift(),r.length>0&&!((l=r.at(-1))!=null&&l.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;a<r.length;a++)r[a]=r[a].trim().replace(In.slashPipe,"|");return r}function El(e,t,s){const r=e.length;if(r===0)return"";let a=0;for(;a<r&&e.charAt(r-a-1)===t;)a++;return e.slice(0,r-a)}function BO(e,t){if(e.indexOf(t[1])===-1)return-1;let s=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])s++;else if(e[r]===t[1]&&(s--,s<0))return r;return-1}function _w(e,t,s,r,a){const l=t.href,c=t.title||null,u=e[1].replace(a.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const d={type:"link",raw:s,href:l,title:c,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,d}return{type:"image",raw:s,href:l,title:c,text:u}}function GO(e,t,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return t;const a=r[1];return t.split(`
470
+ `).map(l=>{const c=l.match(s.other.beginningSpace);if(c===null)return l;const[u]=c;return u.length>=a.length?l.slice(a.length):l}).join(`
471
+ `)}class Ad{constructor(t){gt(this,"options");gt(this,"rules");gt(this,"lexer");this.options=t||Na}space(t){const s=this.rules.block.newline.exec(t);if(s&&s[0].length>0)return{type:"space",raw:s[0]}}code(t){const s=this.rules.block.code.exec(t);if(s){const r=s[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s[0],codeBlockStyle:"indented",text:this.options.pedantic?r:El(r,`
472
+ `)}}}fences(t){const s=this.rules.block.fences.exec(t);if(s){const r=s[0],a=GO(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:a}}}heading(t){const s=this.rules.block.heading.exec(t);if(s){let r=s[2].trim();if(this.rules.other.endingHash.test(r)){const a=El(r,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(r=a.trim())}return{type:"heading",raw:s[0],depth:s[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const s=this.rules.block.hr.exec(t);if(s)return{type:"hr",raw:El(s[0],`
473
+ `)}}blockquote(t){const s=this.rules.block.blockquote.exec(t);if(s){let r=El(s[0],`
474
+ `).split(`
475
+ `),a="",l="";const c=[];for(;r.length>0;){let u=!1;const d=[];let p;for(p=0;p<r.length;p++)if(this.rules.other.blockquoteStart.test(r[p]))d.push(r[p]),u=!0;else if(!u)d.push(r[p]);else break;r=r.slice(p);const g=d.join(`
476
+ `),y=g.replace(this.rules.other.blockquoteSetextReplace,`
477
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
478
+ ${g}`:g,l=l?`${l}
479
+ ${y}`:y;const h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(y,c,!0),this.lexer.state.top=h,r.length===0)break;const m=c.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){const v=m,w=v.raw+`
480
+ `+r.join(`
481
+ `),k=this.blockquote(w);c[c.length-1]=k,a=a.substring(0,a.length-v.raw.length)+k.raw,l=l.substring(0,l.length-v.text.length)+k.text;break}else if((m==null?void 0:m.type)==="list"){const v=m,w=v.raw+`
482
+ `+r.join(`
483
+ `),k=this.list(w);c[c.length-1]=k,a=a.substring(0,a.length-m.raw.length)+k.raw,l=l.substring(0,l.length-v.raw.length)+k.raw,r=w.substring(c.at(-1).raw.length).split(`
484
+ `);continue}}return{type:"blockquote",raw:a,tokens:c,text:l}}}list(t){let s=this.rules.block.list.exec(t);if(s){let r=s[1].trim();const a=r.length>1,l={type:"list",raw:"",ordered:a,start:a?+r.slice(0,-1):"",loose:!1,items:[]};r=a?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=a?r:"[*+-]");const c=this.rules.other.listItemRegex(r);let u=!1;for(;t;){let p=!1,g="",y="";if(!(s=c.exec(t))||this.rules.block.hr.test(t))break;g=s[0],t=t.substring(g.length);let h=s[2].split(`
485
+ `,1)[0].replace(this.rules.other.listReplaceTabs,A=>" ".repeat(3*A.length)),m=t.split(`
486
+ `,1)[0],v=!h.trim(),w=0;if(this.options.pedantic?(w=2,y=h.trimStart()):v?w=s[1].length+1:(w=s[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,y=h.slice(w),w+=s[1].length),v&&this.rules.other.blankLine.test(m)&&(g+=m+`
487
+ `,t=t.substring(m.length+1),p=!0),!p){const A=this.rules.other.nextBulletRegex(w),_=this.rules.other.hrRegex(w),S=this.rules.other.fencesBeginRegex(w),E=this.rules.other.headingBeginRegex(w),T=this.rules.other.htmlBeginRegex(w);for(;t;){const C=t.split(`
488
+ `,1)[0];let R;if(m=C,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),R=m):R=m.replace(this.rules.other.tabCharGlobal," "),S.test(m)||E.test(m)||T.test(m)||A.test(m)||_.test(m))break;if(R.search(this.rules.other.nonSpaceChar)>=w||!m.trim())y+=`
489
+ `+R.slice(w);else{if(v||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(h)||E.test(h)||_.test(h))break;y+=`
490
+ `+m}!v&&!m.trim()&&(v=!0),g+=C+`
491
+ `,t=t.substring(C.length+1),h=R.slice(w)}}l.loose||(u?l.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(u=!0));let k=null,N;this.options.gfm&&(k=this.rules.other.listIsTask.exec(y),k&&(N=k[0]!=="[ ] ",y=y.replace(this.rules.other.listReplaceTask,""))),l.items.push({type:"list_item",raw:g,task:!!k,checked:N,loose:!1,text:y,tokens:[]}),l.raw+=g}const d=l.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.text.trimEnd();else return;l.raw=l.raw.trimEnd();for(let p=0;p<l.items.length;p++)if(this.lexer.state.top=!1,l.items[p].tokens=this.lexer.blockTokens(l.items[p].text,[]),!l.loose){const g=l.items[p].tokens.filter(h=>h.type==="space"),y=g.length>0&&g.some(h=>this.rules.other.anyLine.test(h.raw));l.loose=y}if(l.loose)for(let p=0;p<l.items.length;p++)l.items[p].loose=!0;return l}}html(t){const s=this.rules.block.html.exec(t);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(t){const s=this.rules.block.def.exec(t);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=s[2]?s[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=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:a,title:l}}}table(t){var u;const s=this.rules.block.table.exec(t);if(!s||!this.rules.other.tableDelimiter.test(s[2]))return;const r=Sw(s[1]),a=s[2].replace(this.rules.other.tableAlignChars,"").split("|"),l=(u=s[3])!=null&&u.trim()?s[3].replace(this.rules.other.tableRowBlankLine,"").split(`
492
+ `):[],c={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===a.length){for(const d of a)this.rules.other.tableAlignRight.test(d)?c.align.push("right"):this.rules.other.tableAlignCenter.test(d)?c.align.push("center"):this.rules.other.tableAlignLeft.test(d)?c.align.push("left"):c.align.push(null);for(let d=0;d<r.length;d++)c.header.push({text:r[d],tokens:this.lexer.inline(r[d]),header:!0,align:c.align[d]});for(const d of l)c.rows.push(Sw(d,c.header.length).map((p,g)=>({text:p,tokens:this.lexer.inline(p),header:!1,align:c.align[g]})));return c}}lheading(t){const s=this.rules.block.lheading.exec(t);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(t){const s=this.rules.block.paragraph.exec(t);if(s){const r=s[1].charAt(s[1].length-1)===`
493
+ `?s[1].slice(0,-1):s[1];return{type:"paragraph",raw:s[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const s=this.rules.block.text.exec(t);if(s)return{type:"text",raw:s[0],text:s[0],tokens:this.lexer.inline(s[0])}}escape(t){const s=this.rules.inline.escape.exec(t);if(s)return{type:"escape",raw:s[0],text:s[1]}}tag(t){const s=this.rules.inline.tag.exec(t);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(t){const s=this.rules.inline.link.exec(t);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=El(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=BO(s[2],"()");if(c>-1){const d=(s[0].indexOf("!")===0?5:4)+s[1].length+c;s[2]=s[2].substring(0,c),s[0]=s[0].substring(0,d).trim(),s[3]=""}}let a=s[2],l="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(a);c&&(a=c[1],l=c[3])}else l=s[3]?s[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?a=a.slice(1):a=a.slice(1,-1)),_w(s,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},s[0],this.lexer,this.rules)}}reflink(t,s){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){const a=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),l=s[a.toLowerCase()];if(!l){const c=r[0].charAt(0);return{type:"text",raw:c,text:c}}return _w(r,l,r[0],this.lexer,this.rules)}}emStrong(t,s,r=""){let a=this.rules.inline.emStrongLDelim.exec(t);if(!a||a[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(a[1]||a[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const c=[...a[0]].length-1;let u,d,p=c,g=0;const y=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(y.lastIndex=0,s=s.slice(-1*t.length+c);(a=y.exec(s))!=null;){if(u=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!u)continue;if(d=[...u].length,a[3]||a[4]){p+=d;continue}else if((a[5]||a[6])&&c%3&&!((c+d)%3)){g+=d;continue}if(p-=d,p>0)continue;d=Math.min(d,d+p+g);const h=[...a[0]][0].length,m=t.slice(0,c+a.index+h+d);if(Math.min(c,d)%2){const w=m.slice(1,-1);return{type:"em",raw:m,text:w,tokens:this.lexer.inlineTokens(w)}}const v=m.slice(2,-2);return{type:"strong",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(t){const s=this.rules.inline.code.exec(t);if(s){let r=s[2].replace(this.rules.other.newLineCharGlobal," ");const a=this.rules.other.nonSpaceChar.test(r),l=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return a&&l&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:s[0],text:r}}}br(t){const s=this.rules.inline.br.exec(t);if(s)return{type:"br",raw:s[0]}}del(t){const s=this.rules.inline.del.exec(t);if(s)return{type:"del",raw:s[0],text:s[2],tokens:this.lexer.inlineTokens(s[2])}}autolink(t){const s=this.rules.inline.autolink.exec(t);if(s){let r,a;return s[2]==="@"?(r=s[1],a="mailto:"+r):(r=s[1],a=r),{type:"link",raw:s[0],text:r,href:a,tokens:[{type:"text",raw:r,text:r}]}}}url(t){var r;let s;if(s=this.rules.inline.url.exec(t)){let a,l;if(s[2]==="@")a=s[0],l="mailto:"+a;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]);a=s[0],s[1]==="www."?l="http://"+s[0]:l=s[0]}return{type:"link",raw:s[0],text:a,href:l,tokens:[{type:"text",raw:a,text:a}]}}}inlineText(t){const s=this.rules.inline.text.exec(t);if(s){const r=this.lexer.state.inRawBlock;return{type:"text",raw:s[0],text:s[0],escaped:r}}}}class Ss{constructor(t){gt(this,"tokens");gt(this,"options");gt(this,"state");gt(this,"tokenizer");gt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Na,this.options.tokenizer=this.options.tokenizer||new Ad,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:In,block:Ku.normal,inline:$l.normal};this.options.pedantic?(s.block=Ku.pedantic,s.inline=$l.pedantic):this.options.gfm&&(s.block=Ku.gfm,this.options.breaks?s.inline=$l.breaks:s.inline=$l.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ku,inline:$l}}static lex(t,s){return new Ss(s).lex(t)}static lexInline(t,s){return new Ss(s).inlineTokens(t)}lex(t){t=t.replace(In.carriageReturn,`
494
+ `),this.blockTokens(t,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(t,s=[],r=!1){var a,l,c;for(this.options.pedantic&&(t=t.replace(In.tabCharGlobal," ").replace(In.spaceLine,""));t;){let u;if((l=(a=this.options.extensions)==null?void 0:a.block)!=null&&l.some(p=>(u=p.call({lexer:this},t,s))?(t=t.substring(u.raw.length),s.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);const p=s.at(-1);u.raw.length===1&&p!==void 0?p.raw+=`
495
+ `:s.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);const p=s.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=`
496
+ `+u.raw,p.text+=`
497
+ `+u.text,this.inlineQueue.at(-1).src=p.text):s.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);const p=s.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=`
498
+ `+u.raw,p.text+=`
499
+ `+u.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title});continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),s.push(u);continue}let d=t;if((c=this.options.extensions)!=null&&c.startBlock){let p=1/0;const g=t.slice(1);let y;this.options.extensions.startBlock.forEach(h=>{y=h.call({lexer:this},g),typeof y=="number"&&y>=0&&(p=Math.min(p,y))}),p<1/0&&p>=0&&(d=t.substring(0,p+1))}if(this.state.top&&(u=this.tokenizer.paragraph(d))){const p=s.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=`
500
+ `+u.raw,p.text+=`
501
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):s.push(u),r=d.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);const p=s.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=`
502
+ `+u.raw,p.text+=`
503
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):s.push(u);continue}if(t){const p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return this.state.top=!0,s}inline(t,s=[]){return this.inlineQueue.push({src:t,tokens:s}),s}inlineTokens(t,s=[]){var u,d,p;let r=t,a=null;if(this.tokens.links){const g=Object.keys(this.tokens.links);if(g.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,a.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let l=!1,c="";for(;t;){l||(c=""),l=!1;let g;if((d=(u=this.options.extensions)==null?void 0:u.inline)!=null&&d.some(h=>(g=h.call({lexer:this},t,s))?(t=t.substring(g.raw.length),s.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);const h=s.at(-1);g.type==="text"&&(h==null?void 0:h.type)==="text"?(h.raw+=g.raw,h.text+=g.text):s.push(g);continue}if(g=this.tokenizer.emStrong(t,r,c)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.del(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),s.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),s.push(g);continue}let y=t;if((p=this.options.extensions)!=null&&p.startInline){let h=1/0;const m=t.slice(1);let v;this.options.extensions.startInline.forEach(w=>{v=w.call({lexer:this},m),typeof v=="number"&&v>=0&&(h=Math.min(h,v))}),h<1/0&&h>=0&&(y=t.substring(0,h+1))}if(g=this.tokenizer.inlineText(y)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),l=!0;const h=s.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=g.raw,h.text+=g.text):s.push(g);continue}if(t){const h="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return s}}class Od{constructor(t){gt(this,"options");gt(this,"parser");this.options=t||Na}space(t){return""}code({text:t,lang:s,escaped:r}){var c;const a=(c=(s||"").match(In.notSpaceStart))==null?void 0:c[0],l=t.replace(In.endingNewline,"")+`
504
+ `;return a?'<pre><code class="language-'+ir(a)+'">'+(r?l:ir(l,!0))+`</code></pre>
505
+ `:"<pre><code>"+(r?l:ir(l,!0))+`</code></pre>
506
+ `}blockquote({tokens:t}){return`<blockquote>
507
+ ${this.parser.parse(t)}</blockquote>
508
+ `}html({text:t}){return t}heading({tokens:t,depth:s}){return`<h${s}>${this.parser.parseInline(t)}</h${s}>
509
+ `}hr(t){return`<hr>
510
+ `}list(t){const s=t.ordered,r=t.start;let a="";for(let u=0;u<t.items.length;u++){const d=t.items[u];a+=this.listitem(d)}const l=s?"ol":"ul",c=s&&r!==1?' start="'+r+'"':"";return"<"+l+c+`>
511
+ `+a+"</"+l+`>
512
+ `}listitem(t){var r;let s="";if(t.task){const a=this.checkbox({checked:!!t.checked});t.loose?((r=t.tokens[0])==null?void 0:r.type)==="paragraph"?(t.tokens[0].text=a+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=a+" "+ir(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:a+" ",text:a+" ",escaped:!0}):s+=a+" "}return s+=this.parser.parse(t.tokens,!!t.loose),`<li>${s}</li>
513
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
514
+ `}table(t){let s="",r="";for(let l=0;l<t.header.length;l++)r+=this.tablecell(t.header[l]);s+=this.tablerow({text:r});let a="";for(let l=0;l<t.rows.length;l++){const c=t.rows[l];r="";for(let u=0;u<c.length;u++)r+=this.tablecell(c[u]);a+=this.tablerow({text:r})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
515
+ <thead>
516
+ `+s+`</thead>
517
+ `+a+`</table>
518
+ `}tablerow({text:t}){return`<tr>
519
+ ${t}</tr>
520
+ `}tablecell(t){const s=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+s+`</${r}>
521
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${ir(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:s,tokens:r}){const a=this.parser.parseInline(r),l=Nw(t);if(l===null)return a;t=l;let c='<a href="'+t+'"';return s&&(c+=' title="'+ir(s)+'"'),c+=">"+a+"</a>",c}image({href:t,title:s,text:r}){const a=Nw(t);if(a===null)return ir(r);t=a;let l=`<img src="${t}" alt="${r}"`;return s&&(l+=` title="${ir(s)}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:ir(t.text)}}class Yg{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class _s{constructor(t){gt(this,"options");gt(this,"renderer");gt(this,"textRenderer");this.options=t||Na,this.options.renderer=this.options.renderer||new Od,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Yg}static parse(t,s){return new _s(s).parse(t)}static parseInline(t,s){return new _s(s).parseInline(t)}parse(t,s=!0){var a,l;let r="";for(let c=0;c<t.length;c++){const u=t[c];if((l=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&l[u.type]){const p=u,g=this.options.extensions.renderers[p.type].call({parser:this},p);if(g!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type)){r+=g||"";continue}}const d=u;switch(d.type){case"space":{r+=this.renderer.space(d);continue}case"hr":{r+=this.renderer.hr(d);continue}case"heading":{r+=this.renderer.heading(d);continue}case"code":{r+=this.renderer.code(d);continue}case"table":{r+=this.renderer.table(d);continue}case"blockquote":{r+=this.renderer.blockquote(d);continue}case"list":{r+=this.renderer.list(d);continue}case"html":{r+=this.renderer.html(d);continue}case"paragraph":{r+=this.renderer.paragraph(d);continue}case"text":{let p=d,g=this.renderer.text(p);for(;c+1<t.length&&t[c+1].type==="text";)p=t[++c],g+=`
522
+ `+this.renderer.text(p);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 p='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}parseInline(t,s=this.renderer){var a,l;let r="";for(let c=0;c<t.length;c++){const u=t[c];if((l=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&l[u.type]){const p=this.options.extensions.renderers[u.type].call({parser:this},u);if(p!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){r+=p||"";continue}}const d=u;switch(d.type){case"escape":{r+=s.text(d);break}case"html":{r+=s.html(d);break}case"link":{r+=s.link(d);break}case"image":{r+=s.image(d);break}case"strong":{r+=s.strong(d);break}case"em":{r+=s.em(d);break}case"codespan":{r+=s.codespan(d);break}case"br":{r+=s.br(d);break}case"del":{r+=s.del(d);break}case"text":{r+=s.text(d);break}default:{const p='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}}class Ul{constructor(t){gt(this,"options");gt(this,"block");this.options=t||Na}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Ss.lex:Ss.lexInline}provideParser(){return this.block?_s.parse:_s.parseInline}}gt(Ul,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class qO{constructor(...t){gt(this,"defaults",Wg());gt(this,"options",this.setOptions);gt(this,"parse",this.parseMarkdown(!0));gt(this,"parseInline",this.parseMarkdown(!1));gt(this,"Parser",_s);gt(this,"Renderer",Od);gt(this,"TextRenderer",Yg);gt(this,"Lexer",Ss);gt(this,"Tokenizer",Ad);gt(this,"Hooks",Ul);this.use(...t)}walkTokens(t,s){var a,l;let r=[];for(const c of t)switch(r=r.concat(s.call(this,c)),c.type){case"table":{const u=c;for(const d of u.header)r=r.concat(this.walkTokens(d.tokens,s));for(const d of u.rows)for(const p of d)r=r.concat(this.walkTokens(p.tokens,s));break}case"list":{const u=c;r=r.concat(this.walkTokens(u.items,s));break}default:{const u=c;(l=(a=this.defaults.extensions)==null?void 0:a.childTokens)!=null&&l[u.type]?this.defaults.extensions.childTokens[u.type].forEach(d=>{const p=u[d].flat(1/0);r=r.concat(this.walkTokens(p,s))}):u.tokens&&(r=r.concat(this.walkTokens(u.tokens,s)))}}return r}use(...t){const s=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const a={...r};if(a.async=this.defaults.async||a.async||!1,r.extensions&&(r.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const c=s.renderers[l.name];c?s.renderers[l.name]=function(...u){let d=l.renderer.apply(this,u);return d===!1&&(d=c.apply(this,u)),d}:s.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const c=s[l.level];c?c.unshift(l.tokenizer):s[l.level]=[l.tokenizer],l.start&&(l.level==="block"?s.startBlock?s.startBlock.push(l.start):s.startBlock=[l.start]:l.level==="inline"&&(s.startInline?s.startInline.push(l.start):s.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(s.childTokens[l.name]=l.childTokens)}),a.extensions=s),r.renderer){const l=this.defaults.renderer||new Od(this.defaults);for(const c in r.renderer){if(!(c in l))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const u=c,d=r.renderer[u],p=l[u];l[u]=(...g)=>{let y=d.apply(l,g);return y===!1&&(y=p.apply(l,g)),y||""}}a.renderer=l}if(r.tokenizer){const l=this.defaults.tokenizer||new Ad(this.defaults);for(const c in r.tokenizer){if(!(c in l))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const u=c,d=r.tokenizer[u],p=l[u];l[u]=(...g)=>{let y=d.apply(l,g);return y===!1&&(y=p.apply(l,g)),y}}a.tokenizer=l}if(r.hooks){const l=this.defaults.hooks||new Ul;for(const c in r.hooks){if(!(c in l))throw new Error(`hook '${c}' does not exist`);if(["options","block"].includes(c))continue;const u=c,d=r.hooks[u],p=l[u];Ul.passThroughHooks.has(c)?l[u]=g=>{if(this.defaults.async)return Promise.resolve(d.call(l,g)).then(h=>p.call(l,h));const y=d.call(l,g);return p.call(l,y)}:l[u]=(...g)=>{let y=d.apply(l,g);return y===!1&&(y=p.apply(l,g)),y}}a.hooks=l}if(r.walkTokens){const l=this.defaults.walkTokens,c=r.walkTokens;a.walkTokens=function(u){let d=[];return d.push(c.call(this,u)),l&&(d=d.concat(l.call(this,u))),d}}this.defaults={...this.defaults,...a}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,s){return Ss.lex(t,s??this.defaults)}parser(t,s){return _s.parse(t,s??this.defaults)}parseMarkdown(t){return(r,a)=>{const l={...a},c={...this.defaults,...l},u=this.onError(!!c.silent,!!c.async);if(this.defaults.async===!0&&l.async===!1)return u(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 u(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return u(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));c.hooks&&(c.hooks.options=c,c.hooks.block=t);const d=c.hooks?c.hooks.provideLexer():t?Ss.lex:Ss.lexInline,p=c.hooks?c.hooks.provideParser():t?_s.parse:_s.parseInline;if(c.async)return Promise.resolve(c.hooks?c.hooks.preprocess(r):r).then(g=>d(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=>p(g,c)).then(g=>c.hooks?c.hooks.postprocess(g):g).catch(u);try{c.hooks&&(r=c.hooks.preprocess(r));let g=d(r,c);c.hooks&&(g=c.hooks.processAllTokens(g)),c.walkTokens&&this.walkTokens(g,c.walkTokens);let y=p(g,c);return c.hooks&&(y=c.hooks.postprocess(y)),y}catch(g){return u(g)}}}onError(t,s){return r=>{if(r.message+=`
523
+ Please report this to https://github.com/markedjs/marked.`,t){const a="<p>An error occurred:</p><pre>"+ir(r.message+"",!0)+"</pre>";return s?Promise.resolve(a):a}if(s)return Promise.reject(r);throw r}}}const ma=new qO;function bt(e,t){return ma.parse(e,t)}bt.options=bt.setOptions=function(e){return ma.setOptions(e),bt.defaults=ma.defaults,U1(bt.defaults),bt};bt.getDefaults=Wg;bt.defaults=Na;bt.use=function(...e){return ma.use(...e),bt.defaults=ma.defaults,U1(bt.defaults),bt};bt.walkTokens=function(e,t){return ma.walkTokens(e,t)};bt.parseInline=ma.parseInline;bt.Parser=_s;bt.parser=_s.parse;bt.Renderer=Od;bt.TextRenderer=Yg;bt.Lexer=Ss;bt.lexer=Ss.lex;bt.Tokenizer=Ad;bt.Hooks=Ul;bt.parse=bt;bt.options;bt.setOptions;bt.use;bt.walkTokens;bt.parseInline;_s.parse;Ss.lex;let Cl;const VO=e=>(Cl||(gd.addHook("uponSanitizeElement",(t,s)=>{Cl??(Cl=s.allowedTags)}),gd.sanitize("<b></b>"),gd.removeHook("uponSanitizeElement")),(Cl==null?void 0:Cl[e.toLowerCase()])===!0),KO=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");bt.use({breaks:!0,renderer:{html:({text:e,block:t})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(a,l)=>VO(l)?(s++,a):KO(a));return t&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
524
+ `)}</p>
525
+ `:r}}});const Co=e=>e.slice(-8),Cf=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),ht=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function wi(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const J1=e=>e.basis==="estimate",wo=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Md=e=>{if(e>0&&e<1e-4)return"<$0.0001";if(e>=1)return`$${e.toFixed(2)}`;const[t,s=""]=e.toFixed(4).split(".");return`$${t}.${s.replace(/0+$/,"").padEnd(2,"0")}`},Oi=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,YO=(e,{ended:t=!1}={})=>`The charges priced${t?"":" so far"}. ${e.unpriced} ${e.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,XO=new Set(["completed","failed","cancelled"]),pa=e=>typeof e=="string"&&XO.has(e),QO=(e,{ended:t=!1}={})=>e.usd!==null?wo(e.usd):typeof e.so_far_usd=="number"?t?`${Md(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${Md(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function No(e,{ended:t=!1}={}){const s=Oi(e),r=a=>J1(a)?" est.":"";return s?t?`${Md(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${Md(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":`${wo(e.usd)}${r(e)}`}function $w(e,t,{ended:s=!1,text:r}={}){const a=r??No(e,{ended:s});return typeof t!="number"?a:(r!==void 0?JO.test(r):!Oi(e)&&!!e&&e.usd!==null)?`${a} of ${Ew(t)}`:`${a} · cap ${Ew(t)}`}const JO=/^<?\$[\d.,]+( est\.)?$/;function Ew(e){for(let t=2;t<8;t++)if(Number(e.toFixed(t))===e)return`$${e.toFixed(t)}`;return`$${e.toFixed(8)}`}function ZO(e,t){if(e.startsWith("/")||e.startsWith("#"))return null;const s=t.from?`${t.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const r=decodeURIComponent(new URL(e,`file:///${s}`).pathname.slice(1));return t.paths.includes(r)?r:null}catch{return null}}function Lr(e,t){const s=gd.sanitize(bt.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 a=r.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(a)){r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(a))continue;const l=t&&ZO(a,t);if(l){const c=r.ownerDocument.createElement("button");c.type="button",c.title=`Open ${l}`,c.dataset.runFile=l,c.append(...r.childNodes),r.replaceWith(c)}else r.replaceWith(...r.childNodes)}return s.innerHTML}const Xg=e=>t=>{var r,a,l;const s=(l=(a=(r=t.target).closest)==null?void 0:a.call(r,"[data-run-file]"))==null?void 0:l.getAttribute("data-run-file");s&&(t.preventDefault(),e(s))},e4=e=>{const t=s=>{var r;return(r=new RegExp(`\\b${s}="([^"]*)"`).exec(e))==null?void 0:r[1]};return t("scheme")==="github"||t("source")==="github"?"A GitHub event":t("source")==="webhook"?"A webhook request":"A trigger's request"};function xn(e){const{title:t}=e;if(!e.trigger)return t;let s=t.search(/<trigger-payload\b/);if(s<0){const a=/<([a-z-]*)…$/.exec(t);if(!a||!"trigger-payload".startsWith(a[1]))return t;s=a.index}return t.slice(0,s).trim()||e4(t.slice(s))}function t4(e){return e.usd===null?{total:"Unknown"}:{total:No({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const Qg=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],ci=864e5,Ah=e=>Math.floor(e/ci)*ci;function Jg(e,t=Date.now()){var r;const s=(r=Qg.find(a=>a.id===e))==null?void 0:r.days;return s?new Date(Ah(t)-(s-1)*ci).toISOString():void 0}const Z1=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function n4(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 s4(e){const t=e.input+e.cache_read+e.cache_write;return t?e.cache_read/t:null}const eN=(e,t)=>t4({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Zg=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function ha(e){if(e<1e4)return e.toLocaleString("en-US");const[t,s]=e<1e6?[e/1e3,"K"]:e<1e9?[e/1e6,"M"]:[e/1e9,"B"];return`${t<100?t.toFixed(1).replace(/\.0$/,""):Math.round(t)}${s}`}const Ld=e=>e===null?"—":`${Math.round(e*100)}%`;function Cw(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function r4(e,t,s=Date.now()){if(!e.length)return[];const r=Ah(s),a=Math.max(r-29*ci,t?Ah(Date.parse(t)):r-29*ci),l=new Map(e.map(u=>[u.day,u])),c=[];for(let u=a;u<=r;u+=ci){const d=new Date(u).toISOString().slice(0,10);c.push(l.get(d)??{day:d,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 o4(e,t){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)=>L1({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:t,analytics:e.analytics}}function tN({range:e,onRange:t,agent:s,agents:r,onAgent:a}){return n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsx(iC,{label:"Range",name:"mission-range",value:e,onChange:t,options:Qg.map(l=>({value:l.id,label:l.label}))}),a&&r.length>0&&n.jsx(Lt,{label:"Agent",value:s??"",onChange:l=>a(l||null),className:"h-[38px] w-56",options:[{value:"",label:"All agents"},...r.map(l=>({value:l.agentId,label:l.name}))]})]})}const xd=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function nN({a:e,basis:t,now:s=Date.now(),refreshing:r=!1}){const a=e.totals,l=s4(a),c=Z1(a),u=eN(a),d=[{label:"Tokens",value:ha(a.tokens),notes:[`${l===null?"":`${Ld(l)} of input cached · `}${ha(a.output)} output`,Zg(a),a.unmetered?`${xd(a.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:Cw(e.time.wall_ms),notes:[`wall time of ${xd(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${Cw(e.time.active_ms)} active, over ${xd(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Ld(c),notes:[a.completed+a.failed?n4(a):"No run completed or failed yet"]},{label:"Cost",value:u.total,notes:[u.note]}];return n.jsxs("div",{className:ie("space-y-6 transition-opacity",r&&"opacity-60"),"aria-busy":r,children:[n.jsx("ul",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:d.map(p=>n.jsxs("li",{className:"border p-4",children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:p.label}),n.jsx("p",{className:"mt-2 font-mono text-xl font-semibold",children:p.value}),p.notes.filter(Boolean).map(g=>n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:g},g))]},p.label))}),n.jsx(c4,{days:r4(e.by_day,e.filter.from,s)}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-2",children:[n.jsx(a4,{rows:e.by_harness_effort,basis:t}),n.jsx(i4,{tools:e.tools})]}),n.jsx(l4,{groups:e.by_source})]})}function Pd({title:e,children:t}){return n.jsxs("section",{className:"border",children:[n.jsx("h3",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),t]})}const sN="px-4 py-2 text-left font-normal",lr="px-4 py-2.5 align-top";function a4({rows:e,basis:t}){return n.jsx(Pd,{title:"Success by harness and effort",children:e.length?n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full border-collapse text-body",children:[n.jsx("thead",{children:n.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Harness","Effort","Runs","Success","Tokens","Cost"].map(s=>n.jsx("th",{className:sN,children:s},s))})}),n.jsx("tbody",{children:e.map(s=>{const r=eN(s),a=Zg(s);return n.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[n.jsx("td",{className:lr,children:s.harness}),n.jsx("td",{className:ie(lr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),n.jsx("td",{className:lr,children:s.runs}),n.jsx("td",{className:lr,children:Ld(Z1(s))}),n.jsxs("td",{className:lr,children:[n.jsx("span",{className:"whitespace-nowrap",children:ha(s.tokens)}),a&&n.jsx("span",{className:"block text-label text-muted-foreground",children:a})]}),n.jsxs("td",{className:lr,children:[n.jsx("span",{className:"whitespace-nowrap",children:r.total}),r.note&&n.jsx("span",{className:"block text-label text-muted-foreground",children:r.note})]})]},`${s.harness}:${s.effort??""}`)})})]})}):n.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs in this range."})})}function i4({tools:e}){return n.jsx(Pd,{title:"Top tools",children:e.length?n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full border-collapse text-body",children:[n.jsx("thead",{children:n.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Tool","Calls","Errors","Error rate"].map(t=>n.jsx("th",{className:sN,children:t},t))})}),n.jsx("tbody",{children:e.map(t=>n.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[n.jsx("td",{className:lr,title:t.tool,children:t.label}),n.jsx("td",{className:lr,children:ha(t.calls)}),n.jsx("td",{className:ie(lr,t.errors>0&&"text-destructive-text"),children:ha(t.errors)}),n.jsx("td",{className:lr,children:Ld(t.calls?t.errors/t.calls:null)})]},t.tool))})]})}):n.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 l4({groups:e}){return e.some(t=>t.source!=="live"&&t.runs>0)?n.jsx("p",{className:"font-mono text-small text-muted-foreground","aria-label":"Runs by source",children:e.map(t=>`${t.source==="live"?"Run here":`Imported from ${t.source}`}: ${xd(t.runs,"run")}`).join(" · ")}):null}const Gp=e=>Math.max(0,e.runs-e.completed-e.failed);function Tw(e){if(e<=0)return 1;const t=10**Math.floor(Math.log10(e));return[1,2,5,10].map(s=>s*t).find(s=>s>=e)}const qp=e=>e.slice(5);function c4({days:e}){if(!e.some(l=>l.runs>0))return n.jsx(Pd,{title:"Per day",children:n.jsxs("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:["No runs started in this range",e.length?" in the last 30 days":"","."]})});const s=Tw(Math.max(...e.map(l=>l.runs))),r=Tw(Math.max(...e.map(l=>l.tokens))),a=[{key:"completed",label:"Completed",className:"bg-muted-foreground",of:l=>l.completed},{key:"failed",label:"Failed",className:"bg-destructive",of:l=>l.failed},{key:"other",label:"Other",className:"bg-border-strong",of:Gp}];return n.jsxs(Pd,{title:`Per day, ${e[0].day} to ${e.at(-1).day} (UTC)`,children:[n.jsxs("div",{className:"grid grid-cols-1 gap-6 p-4 xl:grid-cols-2",children:[n.jsxs("figure",{children:[n.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-small",children:[n.jsx("span",{className:"font-semibold",children:"Runs"}),a.map(l=>n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx("span",{className:ie("inline-block size-2.5",l.className),"aria-hidden":!0}),l.label]},l.key))]}),n.jsx(Rw,{days:e,top:s,label:"Runs per day",stack:l=>a.map(c=>({className:c.className,value:c.of(l)})),readout:l=>[`${l.runs} ${l.runs===1?"run":"runs"}`,`${l.completed} completed · ${l.failed} failed · ${Gp(l)} other`]})]}),n.jsxs("figure",{children:[n.jsx("figcaption",{className:"mb-2 text-small font-semibold",children:"Tokens"}),n.jsx(Rw,{days:e,top:r,label:"Tokens per day",format:ha,stack:l=>[{className:"bg-primary",value:l.tokens}],readout:l=>[`${ha(l.tokens)} tokens`,Zg(l)??`${l.runs} ${l.runs===1?"run":"runs"}`]})]})]}),n.jsxs("details",{className:"border-t px-4 py-2",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Day","Runs","Completed","Failed","Other","Tokens"].map(l=>n.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:l},l))})}),n.jsx("tbody",{children:e.map(l=>n.jsxs("tr",{children:[n.jsx("td",{className:"py-0.5 pr-4",children:l.day}),n.jsx("td",{className:"pr-4",children:l.runs}),n.jsx("td",{className:"pr-4",children:l.completed}),n.jsx("td",{className:"pr-4",children:l.failed}),n.jsx("td",{className:"pr-4",children:Gp(l)}),n.jsx("td",{className:"pr-4",children:l.tokens.toLocaleString("en-US")})]},l.day))})]})})]})]})}function Rw({days:e,top:t,label:s,stack:r,readout:a,format:l=c=>c.toLocaleString("en-US")}){return n.jsxs("div",{className:"flex gap-2",children:[n.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:[n.jsx("span",{children:l(t)}),n.jsx("span",{children:l(t/2)}),n.jsx("span",{children:"0"})]}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":s,children:[n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-border","aria-hidden":!0}),n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-border","aria-hidden":!0}),e.map(u=>{const d=r(u).filter(p=>p.value>0);return n.jsxs("div",{role:"listitem",tabIndex:0,"aria-label":`${u.day}: ${a(u).join(", ")}`,className:"group relative flex h-full min-w-0 flex-1 flex-col items-center justify-end outline-none hover:bg-accent/60 focus-visible:bg-accent/60",children:[n.jsx("div",{className:"flex w-full max-w-[24px] flex-col-reverse gap-[2px]",children:d.map((p,g)=>n.jsx("div",{className:ie(p.className,g===d.length-1&&""),style:{height:Math.max(1,Math.round(p.value/t*(140-2*(d.length-1))))}},g))}),n.jsxs("div",{className:"pointer-events-none absolute bottom-full left-1/2 z-raised mb-1 hidden -translate-x-1/2 whitespace-nowrap border bg-card px-2 py-1 text-left font-mono text-label shadow-float group-hover:block group-focus-visible:block",children:[n.jsx("span",{className:"block font-semibold",children:a(u)[0]}),a(u).slice(1).map(p=>n.jsx("span",{className:"block text-muted-foreground",children:p},p)),n.jsx("span",{className:"block text-muted-foreground",children:u.day})]})]},u.day)})]}),n.jsxs("div",{className:"mt-1 flex justify-between font-mono text-micro text-muted-foreground","aria-hidden":!0,children:[n.jsx("span",{children:qp(e[0].day)}),e.length>2&&n.jsx("span",{children:qp(e[Math.floor(e.length/2)].day)}),n.jsx("span",{children:qp(e.at(-1).day)})]})]})]})}function u4(e,t){if(t.unchanged&&!t.reset&&!t.drop.length&&!t.rows.length)return e;const s=new Map;if(!t.reset)for(const r of e)s.set(r.id,r);for(const r of t.drop)s.delete(r);for(const r of t.rows)s.set(r.id,r);return[...s.values()].sort((r,a)=>r.seq-a.seq)}const rN=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,oN=e=>e.refused===!0,aN=e=>e.tool_status==="failed"&&!oN(e)||e.kind==="error",d4=e=>e.paused===!0;function f4(e){const t=new Map(e.filter(p=>p.kind==="tool_result"&&p.tool_use_id).map(p=>[p.tool_use_id,p])),s=new Set(e.filter(p=>p.kind==="tool_use"&&p.tool_use_id).map(p=>p.tool_use_id)),r=new Set(e.filter(p=>p.kind==="waiting"&&p.id.endsWith(":waiting")).map(p=>p.id.slice(0,-8))),a=p=>{var g;return r.has(p.id)||(p.tool_use_id?r.has(((g=t.get(p.tool_use_id))==null?void 0:g.id)??""):!1)},l=e.findLast(p=>p.kind==="usage"),c=[],u=new Map;let d;for(const p of e){if(p.kind==="usage")continue;if(p.tool_name==="ask_person"&&(p.kind==="tool_use"||p.kind==="tool_result")&&a(p)){d=void 0;continue}if(p.kind==="tool_result"&&p.tool_use_id&&s.has(p.tool_use_id)){d=u.get(p.tool_use_id);continue}if(p.kind==="phase"&&p.path&&d&&(d.row.kind==="tool_result"||d.row.kind==="tool_use")&&!d.saved){d.saved=p.path;continue}const g=c.at(-1);if(p.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===p.summary&&g.row.text===p.text&&(g.row.agent_label??null)===(p.agent_label??null)){g.times=(g.times??1)+1,g.until=p.timestamp,d=g;continue}let y;const h=p.kind==="tool_use"&&p.tool_use_id?t.get(p.tool_use_id):void 0;if(h){const m=h.tool_status!=="failed",v=[p.tool_input_preview,h.tool_result_preview].filter(Boolean),w=h.tool_status!==null;y={row:{...h,id:p.id,seq:p.seq,timestamp:p.timestamp,summary:m?(h.summary??"").replace(/:\s*ok$/i,""):h.summary,...p.usage?{usage:p.usage}:{}},...w?{ms:Math.max(0,Date.parse(h.timestamp)-Date.parse(p.timestamp))}:{},detail:v.length===2?`${v[0]}
526
+
527
+ → ${v[1]}`:v[0]??null}}else y={row:p};c.push(y),p.kind==="tool_use"&&p.tool_use_id&&u.set(p.tool_use_id,y),d=y}return l&&c.push({row:l}),c}class Pe extends Error{constructor(s,r,a,l=!1,c){super(a);gt(this,"fields");gt(this,"retryAfterMs");gt(this,"details");gt(this,"problems");this.status=s,this.code=r,this.retryable=l,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 tn=e=>e instanceof Pe?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),Aw=(e,t,{status:s,archived:r}={})=>{const a=new URLSearchParams({limit:String(e)});return t&&a.set("cursor",t),s&&a.set("status",s),r&&a.set("archived","true"),`?${a}`},m4=new Set(["/auth/sign-in","/setup"]);function p4({fetch:e=globalThis.fetch.bind(globalThis),base:t="/v2",onSignedOut:s}={}){async function r(m,v,w={}){return(await a(m,v,w)).body}async function a(m,v,{body:w,headers:k={},signal:N,text:A=!1}={}){var T;const _=w!==void 0||m!=="GET"&&m!=="HEAD",S=await e(`${t}${v}`,{method:m,signal:N,credentials:"same-origin",headers:{accept:"application/json",..._?{"content-type":"application/json"}:{},...k},body:w===void 0?void 0:JSON.stringify(w)});if(!S.ok){S.status===401&&!m4.has(v)&&(s==null||s());const C=(T=await S.json().catch(()=>null))==null?void 0:T.error,R=new Pe(S.status,(C==null?void 0:C.code)??"http_error",(C==null?void 0:C.message)??`${m} ${v}: ${S.status}`,(C==null?void 0:C.retryable)??!1,C==null?void 0:C.request_id);throw C!=null&&C.fields&&(R.fields=C.fields),typeof(C==null?void 0:C.retry_after_ms)=="number"&&(R.retryAfterMs=C.retry_after_ms),C!=null&&C.details&&typeof C.details=="object"&&!Array.isArray(C.details)&&(R.details=C.details),Array.isArray(C==null?void 0:C.problems)&&(R.problems=C.problems),R}return{body:!A&&(S.headers.get("content-type")??"").includes("json")?await S.json():await S.text(),etag:S.headers.get("etag"),status:S.status}}const l=m=>`/agents/${encodeURIComponent(m)}`,c=m=>`/runs/${encodeURIComponent(m)}`,u=m=>`/settings/mcp-servers/${encodeURIComponent(m)}`,d=m=>`/triggers/${encodeURIComponent(m)}`,p=new Map,g=(m,v)=>`${l(m)}/learning/files/${encodeURIComponent(v)}`,y=m=>({note:m.body,etag:m.etag}),h={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>a("GET","/auth/session").then(m=>({status:m.status,body:m.body})),signIn:m=>r("POST","/auth/sign-in",{body:{password:m}}),setup:(m,v,w=!1)=>r("POST","/setup",{body:{password:m,...v?{code:v}:{},...w?{import:!0}:{}}}),setupImport:()=>r("GET","/setup/import").then(m=>(m==null?void 0:m.offer)===!1?null:m,m=>{if(m instanceof Pe&&(m.status===404||m.status===403))return null;throw m}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(m=50,v,w)=>r("GET",`/runs${Aw(m,v,w)}`),listAgentRuns:(m,v=50,w,k={})=>r("GET",`${l(m)}/runs${Aw(v,w,typeof k=="boolean"?{archived:k}:k)}`),listAgents:({archived:m=!1,cursor:v}={})=>{const w=new URLSearchParams;return m&&w.set("archived","true"),v&&w.set("cursor",v),r("GET",`/agents${w.size?`?${w}`:""}`)},getAgent:async m=>{const v=await a("GET",l(m)),w=p.get(m);return{agent:w&&w.revision===v.body.revision&&!v.body.warnings?{...v.body,warnings:w.warnings}:v.body,etag:v.etag}},createAgent:async m=>{var w;const v=await r("POST","/agents",{body:m});return(w=v.warnings)!=null&&w.length&&p.set(v.agent_id,{revision:v.revision,warnings:v.warnings}),v},updateDefinition:async(m,v,w)=>{const k=await a("PUT",`${l(m)}/definition`,{body:v,headers:w?{"if-match":w}:{}});return p.delete(m),{agent:k.body,etag:k.etag}},listRevisions:(m,v)=>r("GET",`${l(m)}/revisions${v?`?cursor=${encodeURIComponent(v)}`:""}`),setCurrent:async(m,v)=>{const w=await r("POST",`${l(m)}/current`,{body:{revision:v}});return p.delete(m),w},archiveAgent:m=>r("POST",`${l(m)}/archive`,{body:{}}),unarchiveAgent:m=>r("POST",`${l(m)}/unarchive`,{body:{}}),agentLearning:m=>r("GET",`${l(m)}/learning`),learningCost:(m,v)=>r("GET",`${l(m)}/learning/cost${v?`?limit=${v}`:""}`),learningBatches:m=>r("GET",`${l(m)}/learning/batches`),learningBatch:(m,v)=>r("GET",`${l(m)}/learning/batches/${encodeURIComponent(v)}`),startLearningBatch:(m,v)=>r("POST",`${l(m)}/learning/batches`,{body:v}),cancelLearningBatch:(m,v)=>r("POST",`${l(m)}/learning/batches/${encodeURIComponent(v)}/cancel`,{body:{}}),learningEvals:m=>r("GET",`${l(m)}/learning/evals`),learningPromotions:m=>r("GET",`${l(m)}/learning/promotions`),learningLoop:m=>r("GET",`${l(m)}/learning/loop`),learnedWorkflowRevisions:(m,v,w)=>r("GET",`${l(m)}/learning/workflows/${encodeURIComponent(v)}/revisions${w?`?limit=${w}`:""}`),learningNotes:(m,v)=>r("GET",`${l(m)}/learning/notes?cursor=${encodeURIComponent(v)}`),learningLog:(m,v)=>r("GET",`${l(m)}/learning/log?cursor=${encodeURIComponent(v)}`),readNote:async(m,v)=>y(await a("GET",g(m,v),{headers:h,text:!0})),writeNote:async(m,v,w,k)=>y(await a("PUT",g(m,v),{body:{text:w},headers:{...h,..."etag"in k?{"if-match":k.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(m,v,w)=>y(await a("POST",`${g(m,v)}/retire`,{body:{},headers:{...h,"if-match":w},text:!0})),approveNote:async(m,v,w)=>y(await a("POST",`${g(m,v)}/approve`,{body:{},headers:{...h,"if-match":w},text:!0})),restoreNote:async(m,v,w)=>y(await a("POST",`${g(m,v)}/restore`,{body:{},headers:{...h,"if-match":w},text:!0})),forgetSignIn:(m,v)=>r("DELETE",`${l(m)}/sign-ins/${encodeURIComponent(v)}`),promoteWorkflow:async(m,v,w)=>{var N;const k=await r("POST",`${l(m)}/learning/workflows/${encodeURIComponent(v)}/promote`,{body:{},headers:{"idempotency-key":w}});return(N=k.warnings)!=null&&N.length&&p.set(k.agent_id,{revision:k.revision,warnings:k.warnings}),k},getRun:m=>r("GET",c(m)),runLearningDiff:m=>r("GET",`${c(m)}/learning/diff`),runLearning:m=>r("GET",`${c(m)}/learning`),runComputer:m=>r("GET",`${c(m)}/computer`),takeOverComputer:m=>r("POST",`${c(m)}/computer/take-over`,{body:{}}),handBackComputer:(m,v)=>r("POST",`${c(m)}/computer/hand-back`,{body:v?{outcome:v}:{}}),archiveRun:m=>r("POST",`${c(m)}/archive`,{body:{}}),unarchiveRun:m=>r("POST",`${c(m)}/unarchive`,{body:{}}),raiseCap:(m,v)=>r("PATCH",c(m),{body:{max_cost_usd:v}}),startRun:async(m,v,w)=>{const k=await a("POST",`${l(m)}/runs`,{body:v,headers:{"idempotency-key":w}});return{run:k.body,status:k.status}},getTimeline:(m,{after:v,waitMs:w,signal:k}={})=>{const N=new URLSearchParams;return v!==void 0&&N.set("after",String(v)),w!==void 0&&N.set("wait_ms",String(w)),r("GET",`${c(m)}/timeline${N.size?`?${N}`:""}`,{signal:k})},listFiles:m=>r("GET",`${c(m)}/files`),deleteUpload:m=>r("DELETE",`/files/${encodeURIComponent(m)}`),readFile:(m,v)=>r("GET",`${c(m)}/files/${v.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(m,v,w)=>r("POST",`${c(m)}/messages`,{body:{content:v},headers:{"idempotency-key":w}}),getRunGraph:(m,v)=>r("GET",`${c(m)}/graph`,{signal:v}),pauseRun:m=>r("POST",`${c(m)}/pause`,{body:{}}),resumeRun:m=>r("POST",`${c(m)}/resume`,{body:{}}),validateWorkflow:(m,v)=>r("POST","/workflows/validate",{body:m,signal:v}),statsOver:({from:m,agent:v})=>{const w=new URLSearchParams;return m&&w.set("from",m),v&&w.set("agent",v),r("GET",`/stats${w.size?`?${w}`:""}`)},fileUrl:(m,v)=>`${t}${c(m)}/files/${v.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(m,v)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(m)}`,{body:{values:v}}),removeToolKey:m=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(m)}`),computers:()=>r("GET","/computers"),saveComputerKeys:(m,v)=>r("PUT",`/computers/${encodeURIComponent(m)}/keys`,{body:v}),testComputer:m=>r("POST",`/computers/${encodeURIComponent(m)}/test`),computerChoices:m=>r("GET",`/computers/${encodeURIComponent(m)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:m=>r("DELETE",`/computers/${encodeURIComponent(m)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:m=>r("PUT","/workspace/archil",{body:m}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:m=>r("PUT","/settings/webhook",{body:{url:m}}),removeWebhook:()=>r("DELETE","/settings/webhook"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),listTriggers:()=>r("GET","/triggers"),getTrigger:m=>r("GET",d(m)),createTrigger:(m,v)=>r("POST","/triggers",{body:m,headers:{"idempotency-key":v}}),rotateTriggerSecret:(m,v={})=>r("POST",`${d(m)}/secret`,{body:v}),updateTrigger:(m,v)=>r("PATCH",d(m),{body:v}),deleteTrigger:m=>r("DELETE",d(m)),fireTrigger:(m,v)=>r("POST",`${d(m)}/fire`,{body:{},headers:{"idempotency-key":v}}),triggerFirings:m=>r("GET",`${d(m)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:m=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(m)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(m,v,w)=>r("POST",`/templates/${encodeURIComponent(m)}/apply`,{body:v,headers:{"idempotency-key":w}}),importTemplate:(m,v={})=>r("POST","/templates/import",{body:{source:m,...v.dryRun?{dry_run:!0}:{},...v.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:m=>r("DELETE",`/templates/${encodeURIComponent(m)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(m,v,w)=>r("POST","/settings/mcp-servers/preview",{body:{url:m,auth:v,...w?{name:w}:{}}}),saveMcpServer:(m,v,w,k={})=>r("PUT",u(m),{body:{url:v,auth:w,...k}}),composioTools:(m,v)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:m,toolkit:v}}),saveComposioServer:(m,v,w,k)=>r("PUT",`${u(m)}/composio`,{body:{api_key:v,toolkit:w,tools:k}}),refreshMcpServer:m=>r("POST",`${u(m)}/refresh`,{body:{}}),deleteMcpServer:m=>r("DELETE",u(m)),startMcpSignIn:(m,v)=>r("POST",`${u(m)}/oauth/start`,{body:v}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:m=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:m}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:m=>r("POST","/integrations/github/connect",{body:m?{org:m}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:m=>r("PUT","/settings/tools",{body:m}),stop:m=>r("POST",`${c(m)}/stop`,{body:{}}),answerApproval:(m,v,w,k,N)=>r("POST",`${c(m)}/approvals/${encodeURIComponent(v)}`,{body:{decision:w,...k?{note:k}:{},...N?{confirm_destructive:!0}:{}}}),cancel:m=>r("POST",`${c(m)}/cancel`,{body:{}})}}async function go(e,t,s=100){const r=[];let a=null;for(let l=0;l<s;l++){const c=await e(a);if(r.push(...t(c)),!c.next_cursor)break;a=c.next_cursor}return r}async function ex(e,t,{onRows:s,onPage:r,signal:a,waitMs:l=25e3,minDelayMs:c=250}){let u=[],d,p;for(;!(a!=null&&a.aborted);){const g=await e.getTimeline(t,d===void 0?{signal:a}:{after:d,waitMs:l,signal:a}).catch(h=>{if(a!=null&&a.aborted)return null;throw h});if(!g||a!=null&&a.aborted||(p=g,s&&(u=u4(u,g)),r==null||r(g),s==null||s(u),g.final&&!g.has_more))break;d=g.next_after;const y=Math.max(c,g.unchanged?g.poll_after_ms??0:0);y&&await new Promise(h=>setTimeout(h,y))}return p}const Bt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),yd=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function h4(e){const t=new Map;let s=0;const r=u=>{throw Object.assign(new Error(u),{offset:s})},a=()=>{for(;s<e.length&&`
528
+ \r`.includes(e[s]);)s++},l=()=>{const u=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=u,r("this string is not closed")),s++;try{return JSON.parse(e.slice(u,s))}catch{return s=u,r("this string has a bad escape")}},c=u=>{a();const d=s;let p;const g=e[s];if(g==="{"){s++;const y={};if(a(),e[s]==="}")s++;else for(;;){a(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const h=l();if(a(),e[s]!==":"&&r("expected : after the key"),s++,y[h]=c(`${u}/${yd(h)}`),a(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}p=y}else if(g==="["){s++;const y=[];if(a(),e[s]==="]")s++;else for(;;){if(y.push(c(`${u}/${y.length}`)),a(),e[s]===","){s++,a(),e[s]==="]"&&r("a trailing comma before ]");continue}if(e[s]==="]"){s++;break}r("expected , or ] after the value")}p=y}else if(g==='"')p=l();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,p=JSON.parse(y[0])}return t.set(u,{start:d,end:s}),p};try{const u=c("");return a(),s<e.length&&r("text after the end of the JSON"),{ok:!0,value:u,spans:t}}catch(u){return{ok:!1,error:{message:u.message,offset:u.offset??0}}}}function g4(e,t){let s=1,r=-1;for(let a=0;a<Math.min(t,e.length);a++)e[a]===`
529
+ `&&(s++,r=a);return{line:s,col:t-r}}function iN(e,t){let s=e;for(const r of t.split("/").slice(1)){const a=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(a)];else if(Bt(s))s=Object.prototype.hasOwnProperty.call(s,a)?s[a]:void 0;else return}return s}const lN=new Set(["judge","pick","sift","route"]),Ow=["jev","parallel","openrouter"];function x4(e){return!Bt(e)||!Bt(e.properties)?[]:Object.entries(e.properties).flatMap(([t,s])=>{if(!Bt(s))return[];const r=typeof s.description=="string"?s.description:t;return Array.isArray(s.enum)?[{id:t,type:"choice",text:r,options:s.enum.map(String)}]:s.type==="boolean"?[{id:t,type:"noul",text:r}]:s.type==="integer"?[{id:t,type:"score",text:r}]:[{id:t,type:"choice",text:r}]})}function tx(e,t,s){const r=iN(e,t);if(!Bt(r))return{decision:!1};const a=r.node,l=s??{},c=a==="route"&&typeof r.valuePath=="string",u=typeof a=="string"&&lN.has(a)&&!c||Array.isArray(l.questions);if(!u)return{decision:!1,...a==="call"&&typeof r.tool=="string"?{tool:r.tool}:{}};const d=typeof l.provider=="string"?l.provider:typeof r.provider=="string"?r.provider:"jev",p=typeof l.model=="string"?l.model:typeof r.model=="string"?r.model:void 0,g=Bt(e)&&Bt(e.schemas)?e.schemas:{};let y=[];Array.isArray(l.questions)?y=l.questions.map(v=>({id:v.id,type:v.type==="choice"||v.type==="score"?v.type:"noul",text:v.instructions||v.id,...v.options?{options:v.options}:{}})):a==="judge"||a==="sift"?y=typeof r.out=="string"?x4(g[r.out]):[]:a==="pick"?y=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:a==="route"&&(y=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:Bt(r.branches)?Object.keys(r.branches):[]}]);const h=Array.isArray(l.images)?l.images.map(String):Bt(r.images)?Object.keys(r.images):[],m=Bt(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:u,provider:d,model:p,questions:y,...h.length?{images:h}:{},web:d==="parallel",...m?{unsure:m}:{}}}const y4=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function b4(e){const t=[],s=(u,d)=>t.push({path:u,message:d,severity:"error"}),r=(u,d)=>t.push({path:u,message:d,severity:"warning"});if(!Bt(e))return s("","the workflow is a JSON object"),t;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 a=Bt(e.schemas)?e.schemas:{};Bt(e.input)&&typeof e.input.schemaId=="string"&&!a[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),Bt(e.output)?typeof e.output.schemaId=="string"&&!a[e.output.schemaId]&&s("/output/schemaId",`no schema "${e.output.schemaId}" in schemas`):s("",'the workflow needs an output: { "schemaId": ..., "path": ... }');const l=new Map,c=(u,d)=>{if(!Bt(u)){s(d,'expected a node (an object with a "node" kind)');return}const p=u.node;if(typeof p!="string"||!y4.has(p)){s(`${d}/node`,typeof p=="string"?`"${p}" is not a node kind`:'a node names its kind in "node"');return}p!=="chain"&&(typeof u.label!="string"||!u.label?s(d,`a ${p} node needs a label`):l.has(u.label)?r(`${d}/label`,`the label "${u.label}" is also used at ${l.get(u.label)}; receipts name nodes by label`):l.set(u.label,d));const g=(h,m)=>{u[h]===void 0&&s(d,`a ${p} node needs ${h} (${m})`)},y=h=>{typeof u[h]=="string"&&!a[u[h]]&&s(`${d}/${h}`,`no schema "${u[h]}" in schemas`)};switch(p){case"chain":!Array.isArray(u.steps)||!u.steps.length?s(d,"a chain needs steps"):u.steps.forEach((h,m)=>c(h,`${d}/steps/${m}`));break;case"parallel":!Array.isArray(u.branches)||!u.branches.length?s(d,"a parallel node needs branches"):u.branches.forEach((h,m)=>c(h,`${d}/branches/${m}`));break;case"map":g("itemsPath","where the items are"),g("as","where the results go"),c(u.body,`${d}/body`);break;case"loop":g("until","when it stops"),g("maxIters","a bound"),c(u.body,`${d}/body`);break;case"workflow":Bt(u.workflow)?c(u.workflow.root,`${d}/workflow/root`):s(d,"a workflow node embeds its workflow");break;case"call":g("via","tool, executor or shell"),u.via==="tool"&&g("tool","the tool's name");break;case"code":typeof u.code!="string"&&s(d,"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(p==="route"){if(!Bt(u.branches)||!Object.keys(u.branches).length)s(d,"a route needs branches");else for(const[h,m]of Object.entries(u.branches))Bt(m)?c(m.body,`${d}/branches/${yd(h)}/body`):s(`${d}/branches/${yd(h)}`,`branch "${h}" is an object with a body`);typeof u.valuePath!="string"&&u.instructions===void 0&&s(d,"a route asks by instructions (and state), or reads a valuePath"),Bt(u.unsure)&&Bt(u.branches)&&typeof u.unsure.branch=="string"&&!(u.unsure.branch in u.branches)&&s(`${d}/unsure/branch`,`the unsure branch "${u.unsure.branch}" is not one of the branches`)}if(lN.has(p)&&!(p==="route"&&typeof u.valuePath=="string")&&(u.provider!==void 0&&!Ow.includes(u.provider)&&r(`${d}/provider`,`provider "${String(u.provider)}" is not one of ${Ow.join(", ")}`),u.provider==="openrouter"&&typeof u.model!="string"&&s(d,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),Bt(u.images))){const h=JSON.stringify(u.state??{})+JSON.stringify(u.instructions??"")+(typeof u.out=="string"?JSON.stringify(a[u.out]??{}):"");for(const m of Object.keys(u.images))h.includes(m)||s(`${d}/images/${yd(m)}`,`the image token "${m}" 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"),t}function Mw(e,t){for(let s=t;;s=s.slice(0,s.lastIndexOf("/"))){const r=e.get(s);if(r)return r;if(!s)return}}function v4(e,t,s){let r=null,a=1/0;for(const l of t){const c=e.get(l);c&&c.start<=s&&s<=c.end&&c.end-c.start<a&&(r=l,a=c.end-c.start)}return r}function w4(e){const t=hi(e),r=t.nodes.map(l=>tx(e,l.path,l)).filter(l=>l.decision),a=[...new Set(r.map(l=>l.provider??"jev"))];return`${t.nodes.length} nodes · ${r.length} ${r.length===1?"decision":"decisions"}${a.length?` · ${a.join(", ")}`:""}`}const Id=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,Lw=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),bc=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function vc(e,t){return Object.fromEntries(t.nodes.map(s=>[s.path,tx(e,s.path,s)]))}const Yu=e=>e>=.995?"1.00":e.toFixed(2);function ki(e){var u;if(e.status==="failed")return"failed";if(e.status==="cancelled")return"interrupted";const t=e.answers??{},s=e.action;if(((u=e.rule)==null?void 0:u.kind)==="route"&&s&&typeof s=="object"&&(s.taken||s.branch)){const d=t.branch,p=d&&d.type==="choice"?d.confidence:void 0;return s.unsure?`${s.taken} (unsure)`:`${s.taken??s.branch}${p!==void 0?` ${Yu(p)}`:""}`}const r=Object.keys(t);if(!r.length)return;const a=d=>{const p=t[d];return p.type==="choice"?`${cN(e,d,p.choice)} ${Yu(p.probabilities[p.choice]??p.confidence)}`:p.type==="noul"?`${p.noul>=.5?"yes":"no"} ${Yu(p.noul>=.5?p.noul:1-p.noul)}`:p.type==="score"?`${p.score} ${Yu(p.confidence)}`:p.type==="refusal"?"refused":"box"};if(r.length===1)return a(r[0]);const l=d=>{const p=t[d];return p.type==="noul"?Math.abs(p.noul-.5)*2:"confidence"in p&&typeof p.confidence=="number"?p.confidence:1},c=r.reduce((d,p)=>l(p)<l(d)?p:d,r[0]);return`${c} ${a(c)}`}function cN(e,t,s){var l,c;const r=(l=e.questions)==null?void 0:l[t],a=e.kind==="pick"&&(r==null?void 0:r.type)==="choice"?(c=r.criteria)==null?void 0:c[s]:null;return typeof a=="string"&&a?a:s}const uN=(e,t)=>e.nodes.filter(s=>s.path.startsWith(`${t}/body`)).map(s=>s.path);function k4(e,t,s){var y,h;const r=(h=(y=e.nodes[t])==null?void 0:y.items)==null?void 0:h.find(m=>m.index===s),a={};if(!r)return a;const l=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(m=>[m.path,m.kind])),u=uN(e.graph,t).filter(m=>!l.has(c.get(m)??""));let d=-1;u.forEach((m,v)=>{const w=e.decisions.filter(N=>N.node===m&&N.item===s),k=e.effects.filter(N=>N.node===m&&N.item===s);!w.length&&!k.length||(d=v,w.some(N=>N.status==="failed")||k.some(N=>N.status==="failed")?a[m]="failed":w.some(N=>N.status==="cancelled")?a[m]="review":k.some(N=>!N.endedAt)?a[m]=k.some(N=>N.status==="stopped")?"stopped":"working":a[m]="done")});const p=Id(r.status)??"pending";let g=!Object.values(a).includes("working");return u.forEach((m,v)=>{a[m]||(v<d||p==="done"?a[m]="done":p==="working"?(a[m]=g?"working":"pending",g=!1):p==="pending"?a[m]="pending":a[m]="not-run")}),a}function j4(e,t){var g,y,h;const s={},r=[],a={};let l=null;const c=new Map(e.graph.nodes.map(m=>[m.path,m.kind]));for(const[m,v]of Object.entries(e.nodes)){const w=Id(v.status);w&&(s[m]=w),v.branch&&r.push(`${m}/branches/${Lw(v.branch)}/body`),v.items&&(a[m]=v.items.map(k=>({index:k.index,status:Id(k.status)??"pending",label:Ql(e,m,k.index),...nx(e,m,k)}))),v.status==="escalated"&&c.get(m)==="escalate"&&(l=m)}const u={},d=m=>/\/body(\/|$)/.test(m)&&e.graph.nodes.some(v=>v.kind==="map"&&m.startsWith(`${v.path}/body`));for(const m of e.decisions){if(!m.node||m.item!==null||d(m.node))continue;const v=ki(m);v&&(u[m.node]=v)}if(t&&t.item!=null&&c.get(t.path)==="map"){Object.assign(s,k4(e,t.path,t.item));const m=((h=(y=(g=e.nodes[t.path])==null?void 0:g.items)==null?void 0:y.find(v=>v.index===t.item))==null?void 0:h.branches)??{};for(const[v,w]of Object.entries(m)){const k=`${v}/branches/`,N=`${k}${Lw(w)}/body`;for(let A=r.length-1;A>=0;A--)r[A].startsWith(k)&&r.splice(A,1);r.push(N);for(const A of e.graph.nodes)A.path.startsWith(k)&&!(A.path===N||A.path.startsWith(`${N}/`))&&(s[A.path]="not-run")}for(const v of e.decisions)if(v.node&&v.item===t.item&&v.node.startsWith(`${t.path}/body`)){const w=ki(v);w&&(u[v.node]=w)}}if(e.run.paused){for(const[m,v]of Object.entries(s))v==="working"&&(s[m]="held");for(const m of Object.values(a))for(const v of m)v.status==="working"&&(v.status="held")}const p={};for(const[m,v]of Object.entries(e.nodes))v.model&&(p[m]={model:v.model,...v.tier?{tier:v.tier}:{}});return{status:s,taken:r,items:a,fired:l,verdict:u,meta:vc(e.workflow,e.graph),selected:t,...Object.keys(p).length?{ran:p}:{}}}const Vp={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"},N4=e=>{if(!e)return;const t=e.toLowerCase();return Vp[t]??Vp[t.split(/[_\s-]/)[0]]??Vp[t.split(/[_\s-]/).at(-1)??""]};function S4(e){if(e.status!=="answered"||!e.answers)return;const t=e.action,s=e.answers.branch;if(t&&typeof t=="object"&&t.taken&&(s==null?void 0:s.type)==="choice")return{p:s.confidence,note:`${e.kind} confidence`};let r;for(const[a,l]of Object.entries(e.answers)){const c=l.type==="noul"?{p:Math.max(l.noul,1-l.noul),note:`${a}: ${l.noul>=.5?"yes":"no"}, P(yes) ${l.noul.toFixed(2)}`,sure:Math.abs(l.noul-.5)}:l.type==="choice"||l.type==="score"?{p:l.confidence,note:`${a} confidence`,sure:l.confidence-.5}:void 0;c&&(!r||c.sure<r.sure)&&(r=c)}return r&&{p:r.p,note:`least sure: ${r.note}`}}function nx(e,t,s){const r=uN(e.graph,t),a=h=>h?r.indexOf(h):-1,l=e.decisions.filter(h=>{var m;return h.item===s.index&&!!((m=h.node)!=null&&m.startsWith(`${t}/body`))}).sort((h,m)=>a(h.node)-a(m.node));let c,u;const d=Object.entries(s.branches??{}).sort(([h],[m])=>a(h)-a(m));if(d.length)[u,c]=d[d.length-1];else{const h=l.filter(m=>{var v;return m.status==="answered"&&((v=m.action)==null?void 0:v.taken)}).at(-1);h&&(c=h.action.taken,u=h.node??void 0)}const p=u&&l.filter(h=>h.node===u).at(-1)||l.filter(h=>h.status==="answered").at(-1),g=p?S4(p):void 0,y=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":N4(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...y?{tone:y}:{}}}function Ql(e,t,s){var u,d;const r=(d=(u=e.nodes[t])==null?void 0:u.items)==null?void 0:d.find(p=>p.index===s);if(r!=null&&r.label)return r.label;const a=e.effects.find(p=>{var g;return p.item===s&&!!((g=p.node)!=null&&g.startsWith(`${t}/body`))}),l=a==null?void 0:a.input,c=(l==null?void 0:l.path)??(l==null?void 0:l.url);return typeof c=="string"?c:void 0}function dN(e=[]){const t={total:e.length,done:0,working:0,failed:0,review:0,pending:0};for(const s of e)s.status==="done"?t.done++:s.status==="working"?t.working++:s.status==="failed"?t.failed++:s.status==="needs_review"||s.status==="escalated"?t.review++:t.pending++;return t}function fN(e){const t=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?t:0}}const Mi=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,ui=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function ji(e){const t=Math.max(0,Math.floor(e/1e3)),s=Math.floor(t/60);return s?`${s}m ${String(t%60).padStart(2,"0")}s`:`${t}s`}const _4=(e,t,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||t)-Date.parse(e.run.startedAt);return bc(e.run.status)||e.run.paused?r:r+Math.max(0,s-t)};function $4(e,t,s){return e!=="input_required"||t!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function E4(e){const t=e.content_type??"";return t.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":t.startsWith("text/")||t.includes("json")?"text":"download"}function mN(e){return e.split("/").slice(0,-1).some(t=>t.startsWith(".")||t==="__pycache__"||t==="node_modules")}const pN="The agent finished without writing an answer.",Oh=[0,250,1e3],hN=e=>new Promise(t=>setTimeout(t,e));function zd(){let e=0;return{begin:()=>++e,current:t=>t===e,cancel:()=>{e++}}}const gN="30d",Pw=10,C4=["queued","working","input_required","paused"];function T4({agent:e,v2:t,now:s=Date.now,stats:r}){const[a,l]=x.useState(gN),[c,u]=x.useState(r??null),[d,p]=x.useState(null),[g,y]=x.useState(!0),[h,m]=x.useState(0),v=x.useRef(0),w=x.useRef(!0);x.useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]);const k=x.useRef(null),N=x.useRef(null);x.useEffect(()=>{const _=`${a}/${h}`;if(N.current===_)return;const S=++v.current;if(k.current===_){N.current=null,p(null),y(!1);return}N.current=_,y(!0),p(null),(async()=>{for(const[E,T]of Oh.entries()){if(T&&await hN(T),S!==v.current||!w.current)return;try{const C=await t.statsOver({from:Jg(a,s()),agent:e.agent_id});if(S!==v.current||!w.current)return;const R=!(C.runs.status_unknown>0);if(u(C),k.current=R||E===Oh.length-1?_:null,R)break}catch(C){S===v.current&&p(tn(C));break}}S===v.current&&(N.current=null,y(!1))})()},[t,e.agent_id,a,h]),x.useEffect(()=>{const _=new AbortController,S=E=>({status:E,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(C4.map(E=>t.listAgentRuns(e.agent_id,Pw,null,S(E)))).then(E=>{if(_.signal.aborted)return;const T=E.flatMap(C=>C.status==="fulfilled"?C.value.runs:[]).filter(C=>!bc(C.status));for(const C of T.slice(0,Pw)){let R=`${C.status}/${C.state}`;ex(t,C.run_id,{signal:_.signal,onPage:D=>{const L=`${D.status}/${D.state}`;L!==R&&(R=L,m(O=>O+1))}}).catch(()=>{})}}),()=>_.abort()},[t,e.agent_id]);const A=c==null?void 0:c.analytics;return n.jsxs("div",{className:"space-y-6",children:[n.jsx(tN,{range:a,onRange:l,agent:null,agents:[]}),d?n.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",d]}):!c||!A?n.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):A.totals.runs?n.jsx(nN,{a:A,basis:c.cost.basis,now:s(),refreshing:g}):n.jsx("div",{className:"border px-4 py-12 text-center",children:n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const R4={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:hh},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:hh},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:Ok},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Zs},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:gi}};function _n({tone:e="neutral",title:t,actions:s,bar:r,icon:a,role:l,className:c,children:u,...d}){const p=R4[e],g=a===!1?null:a??p.Icon;return n.jsxs("div",{role:l??(e==="error"?"alert":"status"),...d,className:ie("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":ie("border p-4",p.box),c),children:[g&&n.jsx(g,{className:ie("size-4 shrink-0",!r&&"mt-0.5",p.text),"aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[t&&n.jsx("p",{className:ie("font-semibold",!r&&"caps text-small",!r&&p.text),children:t}),u&&n.jsx("div",{className:ie(t&&!r&&"mt-2"),children:u})]}),s&&n.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const Iw=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,zw=Gk,A4=(e,t)=>s=>{var r;if((t==null?void 0:t.variants)==null)return zw(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:a,defaultVariants:l}=t,c=Object.keys(a).map(p=>{const g=s==null?void 0:s[p],y=l==null?void 0:l[p];if(g===null)return null;const h=Iw(g)||Iw(y);return a[p][h]}),u=s&&Object.entries(s).reduce((p,g)=>{let[y,h]=g;return h===void 0||(p[y]=h),p},{}),d=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((p,g)=>{let{class:y,className:h,...m}=g;return Object.entries(m).every(v=>{let[w,k]=v;return Array.isArray(k)?k.includes({...l,...u}[w]):{...l,...u}[w]===k})?[...p,y,h]:p},[]);return zw(e,c,d,s==null?void 0:s.class,s==null?void 0:s.className)},Ni=A4("caps inline-flex items-center justify-center gap-2 whitespace-nowrap 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-primary text-primary-text hover:bg-primary/10",solid:"border-primary bg-primary text-primary-foreground hover:bg-primary/90",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"}}),K=x.forwardRef(({className:e,variant:t,size:s,...r},a)=>n.jsx("button",{ref:a,className:ie(Ni({variant:t,size:s}),e),...r}));K.displayName="Button";const Dw={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:t,title:s,label:r,children:a}){return r?n.jsx("span",{title:s,className:ie("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",Dw[e],t),children:n.jsx("span",{className:"min-w-0 truncate",children:a})}):n.jsx("span",{title:s,className:ie("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",Dw[e],t),children:a})}const O4={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function sx({open:e,onClose:t,title:s,description:r,footer:a,size:l="md",initialFocus:c,hideClose:u,className:d,children:p}){return n.jsxs(NA,{open:e,onClose:t,initialFocus:c,className:"relative z-dialog",children:[n.jsx(jA,{className:"fixed inset-0 bg-overlay/70"}),n.jsx("div",{className:ie("fixed inset-0 flex justify-center p-4 md:p-8",l==="full"?"items-stretch":"items-start overflow-y-auto pt-[12vh]"),children:n.jsxs(k1,{className:ie("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",O4[l],d),children:[n.jsxs("header",{className:"flex items-start gap-3 border-b px-5 py-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx(j1,{className:"text-lg font-semibold",children:s}),r&&n.jsx(wj,{className:"mt-1 text-body text-muted-foreground",children:r})]}),!u&&n.jsx(K,{size:"icon",variant:"ghost",onClick:t,"aria-label":"Close",children:n.jsx(fc,{"aria-hidden":!0})})]}),p&&n.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:p}),a&&n.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:a})]})})]})}function M4({open:e,title:t,confirm:s,cancel:r="Cancel",tone:a="destructive",busy:l,onConfirm:c,onCancel:u,children:d}){const p=x.useRef(null);return n.jsx(sx,{open:e,onClose:l?()=>{}:u,title:t,size:"sm",hideClose:!0,initialFocus:p,footer:n.jsxs(n.Fragment,{children:[n.jsx(K,{ref:p,size:"sm",onClick:u,disabled:l,children:r}),n.jsx(K,{size:"sm",variant:a,onClick:c,disabled:l,"aria-busy":l||void 0,children:s})]}),children:d})}function L4({icon:e,active:t,className:s,children:r,...a}){return n.jsxs("button",{type:"button","aria-current":t?"page":void 0,...a,className:ie("flex min-h-11 items-center gap-2.5 p-3 text-left text-body -outline-offset-2 hover:bg-accent",t&&"relative bg-primary/[0.06] text-primary-text before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-primary",s),children:[e&&n.jsx(e,{className:"size-4 shrink-0","aria-hidden":!0})," ",r]})}const P4=["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 I4({value:e,onChange:t,min:s,max:r,label:a,valueText:l,className:c,disabled:u=!1}){return n.jsx("input",{type:"range",min:s,max:r,step:1,value:e,disabled:u,"aria-label":a,"aria-valuetext":l,onChange:d=>t(Number(d.target.value)),className:ie(P4,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function z4({label:e,className:t}){return n.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[n.jsx(uE,{className:ie("size-4 animate-spin text-run-active",t),"aria-hidden":!0}),e&&n.jsx("span",{className:"sr-only",children:e})]})}function xN({checked:e,onChange:t,disabled:s,label:r,labelledBy:a,busy:l,className:c}){return n.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":r,"aria-labelledby":a,"aria-busy":l||void 0,disabled:s||l,onClick:()=>t(!e),className:ie("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",l&&"motion-safe:animate-pulse",c),children:n.jsx("span",{"aria-hidden":!0,className:ie("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")})})}function yN({tabs:e,value:t,onChange:s,label:r,id:a,className:l}){var p;const c=e.some(g=>g.id===t)?t:(p=e[0])==null?void 0:p.id,u=x.useRef(null),d=g=>{var m,v;const y=e.findIndex(w=>w.id===t),h=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;h<0||h===y||(g.preventDefault(),s(e[h].id),(v=(m=u.current)==null?void 0:m.querySelectorAll('[role="tab"]')[h])==null||v.focus())};return n.jsx("div",{ref:u,role:"tablist","aria-label":r,onKeyDown:d,className:ie("flex border-b px-5 md:px-8",l),children:e.map(g=>n.jsx("button",{type:"button",role:"tab",id:a&&`${a}-tab-${g.id}`,"aria-controls":a&&`${a}-panel-${g.id}`,"aria-selected":t===g.id,tabIndex:c===g.id?0:-1,onClick:()=>s(g.id),className:ie("caps -mb-px whitespace-nowrap border-b-2 px-3 py-3 text-small -outline-offset-2 max-sm:px-2.5 max-sm:py-2",t===g.id?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground"),children:g.label},g.id))})}function D4({tip:e,children:t,className:s,align:r="start"}){const a=x.useId();return n.jsxs("span",{className:ie("group/tip relative inline-flex",s),children:[x.cloneElement(t,{"aria-describedby":a}),n.jsx("span",{role:"tooltip",id:a,className:ie("pointer-events-none absolute top-full z-popover mt-1.5 hidden w-max max-w-[min(20rem,80vw)] border border-border-strong bg-card px-3 py-2 text-left font-sans text-small normal-case leading-snug tracking-normal text-card-foreground shadow-float group-hover/tip:block group-focus-within/tip:block",r==="end"?"right-0":"left-0"),children:e})]})}const F4=x.createContext(null),U4={neutral:[hh,"text-muted-foreground"],success:[Ok,"text-success-text"],warning:[Zs,"text-warning-text"],error:[gi,"text-destructive-text"]},W4=5e3;function H4({toast:e,done:t}){const s=x.useCallback(()=>t(e.id),[t,e.id]),r=e.tone??"neutral",a=e.duration??(r==="error"?0:W4),[l,c]=x.useState(!1),[u,d]=x.useState(!1),p=l||u;x.useEffect(()=>{if(!a||p)return;const h=setTimeout(s,a);return()=>clearTimeout(h)},[a,p,s]);const[g,y]=U4[r];return n.jsxs("div",{role:r==="error"?"alert":"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>d(!0),onBlur:()=>d(!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:[n.jsx(g,{className:ie("mt-0.5 size-4 shrink-0",y),"aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"font-semibold",children:e.title}),e.description&&n.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),n.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:n.jsx(fc,{className:"size-3.5","aria-hidden":!0})})]})}function B4({children:e}){const[t,s]=x.useState([]),r=x.useRef(0),a=x.useCallback(c=>s(u=>[...u,{...c,id:r.current++}].slice(-3)),[]),l=x.useCallback(c=>s(u=>u.filter(d=>d.id!==c)),[]);return n.jsxs(F4.Provider,{value:a,children:[e,n.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:t.map(c=>n.jsx(H4,{toast:c,done:l},c.id))})]})}const Dd=[{id:"claude",label:"Claude Code app",instruction:"Open your project in Claude Code and paste the prompt into a new or existing conversation."},{id:"claude-cli",label:"Claude Code CLI",instruction:"Open your project in a terminal, start Claude Code with claude, and paste the prompt."},{id:"codex",label:"Codex app",instruction:"Open your project in the Codex app and paste the prompt into a new or existing chat."},{id:"codex-cli",label:"Codex CLI",instruction:"Open your project in a terminal, start Codex with codex, and paste the prompt."}],bN="agentrun.coding-agent",G4="https://github.com/Parcha-ai/agentrun/tree/main/packages/serve/skills/agentrun-serve",vN=()=>{try{return globalThis.localStorage??null}catch{return null}};function q4(e=vN()){var t;try{const s=e==null?void 0:e.getItem(bN);return((t=Dd.find(r=>r.id===s))==null?void 0:t.id)??"claude"}catch{return"claude"}}function V4(e,t=vN()){try{t==null||t.setItem(bN,e)}catch{}}const Fw=e=>Dd.find(t=>t.id===e)??Dd[0];function Uw(e,t=(s=>(s=globalThis.location)==null?void 0:s.href)()){const r=new URL(e||"/",t),a=r.pathname.replace(/\/+$/,"");return{origin:r.origin,path:a,api:`${r.origin}${a}`}}const K4={create:"Create an AgentRun agent on this server.",edit:"Review and revise this AgentRun agent.",run:"Run this AgentRun agent on its pinned revision."};function Y4(e,t,s){const{origin:r,path:a,api:l}=Uw(t),c=a.endsWith("/v2"),u=e.kind==="create"?"":encodeURIComponent(e.agentId),d=e.kind==="create"?`POST ${a}/agents`:e.kind==="edit"?`PUT ${a}/agents/${u}/definition`:`POST ${a}/agents/${u}/runs`,p=e.kind==="run"?{...e.input!==void 0?{input:e.input}:{},...e.effort?{effort:e.effort}:{},...e.maxCostUsd!==void 0?{max_cost_usd:e.maxCostUsd}:{},revision:e.revision}:void 0,g={server:l,operation:d,...e.kind==="create"?{}:{agent_id:e.agentId,revision:e.revision},...p?{request:p}:{}},y=s?`${Uw(s).api}/`:void 0,h=e.kind==="create"?[`Create it with POST ${a}/agents and one Idempotency-Key for the request and any unchanged retry.`,"Write a native definition: instructions with the tools the agent needs, or a workflow this server supports. Include every skill file the person supplies in the same request.","Do not submit missing requirements or configuration this server's capabilities do not offer."]:e.kind==="edit"?[`Read the agent first with GET ${a}/agents/${u} and keep its ETag.`,`Send the full definition with PUT ${a}/agents/${u}/definition, a higher version and If-Match set to that ETag. Keep the agent's identity and every field you were not asked to change; skill files do not change through this route.`,"A 412 precondition_failed means another revision was saved first: report it, and do not overwrite that revision."]:[`Read the pinned revision's input contract. Start the run with POST ${a}/agents/${u}/runs, the revision pinned, and one stable Idempotency-Key for this run and any unchanged retry.`,e.maxCostUsd!==void 0?"Keep max_cost_usd exactly as the request has it: the person typed that spend cap for this run.":"Do not add a spending cap unless the person asks for one.","Follow the run's actual status, its questions (input_required), its result and its files until it ends."];return[K4[e.kind],"","Install or update the public AgentRun Server skill with your own skill installation workflow:",G4,`Read its SKILL.md, then ${c?`${r}/llms.txt and `:""}${l}/openapi.json. Check ${l}/capabilities before you choose models, tools or workflow features.`,"",`Use this existing server. Authentication is separate from the skill: use the AgentRun API token the owner configured in your environment, as the skill describes. Never print a credential or ask for one in the conversation. The console's browser session does not sign you in.${c?` You can work over the server's MCP endpoint (${l}/mcp), as the skill connects it, or over the HTTP API.`:""}`,"","Task context:","```json",JSON.stringify(g,null,2),"```","","Ask about missing task inputs, required outputs and scope before you submit anything. Keep the answers and any approval already given. Explain the change or the run first when it still needs approval.",...h,`Report the server's actual answer and the ${e.kind==="run"?"run":"revision"} it names${y?`, with its link in the console (${y})`:""}. Keep an unknown cost unknown. Copying this prompt submitted nothing, so do not claim that anything ran before the server says so.`].join(`
530
+ `)}const X4={create:"Build with your coding agent",edit:"Edit with your coding agent",run:"Run with your coding agent"},Q4=()=>globalThis.location?`${location.origin}${location.pathname}`:void 0;function J4({open:e,onClose:t,context:s,serverUrl:r="/v2",consoleUrl:a=Q4()}){const[l,c]=x.useState(()=>q4()),[u,d]=x.useState(()=>Y4(s,r,a)),[p,g]=x.useState("no"),y=x.useRef(null),h=Fw(l),m=async()=>{var v,w,k;try{if(!((v=navigator.clipboard)!=null&&v.writeText))throw new Error("No clipboard");await navigator.clipboard.writeText(u),g("yes")}catch{g("unavailable"),(w=y.current)==null||w.focus(),(k=y.current)==null||k.select()}};return n.jsx(sx,{open:e,onClose:t,size:"lg",title:X4[s.kind],description:"Pick where you work, then review and copy the prompt. Nothing opens or runs from here.",footer:n.jsxs(n.Fragment,{children:[n.jsx(K,{size:"sm",onClick:t,children:"Close"}),n.jsxs(K,{size:"sm",variant:"solid",onClick:()=>void m(),disabled:!u.trim(),children:[n.jsx(lf,{"aria-hidden":!0})," Copy prompt"]})]}),children:n.jsxs("div",{className:"space-y-5",children:[n.jsx(Xs,{label:"Application",hint:h.instruction,children:n.jsx(Lt,{label:"Application",autoFocus:!0,value:l,className:"w-full sm:w-72",onChange:v=>{const w=Fw(v).id;V4(w),c(w),g("no")},options:Dd.map(v=>({value:v.id,label:v.label}))})}),n.jsx(Xs,{label:"Prompt",note:"Review it and edit it before you copy it. It holds the task and no credential: your coding agent signs in to the server on its own.",children:n.jsx(ds,{ref:y,value:u,rows:14,spellCheck:!1,className:"resize-y text-small leading-relaxed",onChange:v=>{d(v.target.value),g("no")}})}),p==="yes"&&n.jsxs(_n,{tone:"success",title:"Copied",children:["Paste it into ",h.label,". Nothing was sent to the server."]}),p==="unavailable"&&n.jsx(_n,{tone:"warning",role:"alert",title:"Clipboard unavailable",children:"The prompt is selected in its field. Copy it with your keyboard (Ctrl+C, or Cmd+C on a Mac)."})]})})}function rx({context:e,label:t,serverUrl:s="/v2",size:r="sm",iconOnPhone:a,unavailable:l,className:c}){const[u,d]=x.useState(null),[p,g]=x.useState(!1),[y,h]=x.useState(0);return n.jsxs(n.Fragment,{children:[n.jsxs(K,{size:r,onClick:()=>{d(typeof e=="function"?e():e),h(m=>m+1),g(!0)},"aria-haspopup":"dialog",disabled:!!l,title:l??(a?t:void 0),className:ie(a&&"max-sm:w-8 max-sm:shrink-0 max-sm:px-0",c),children:[n.jsx(kE,{"aria-hidden":!0})," ",a?n.jsx("span",{className:"max-sm:sr-only",children:t}):t]}),u&&n.jsx(J4,{open:p,onClose:()=>g(!1),context:u,serverUrl:s},y)]})}const Z4="Not read: its front matter can't be read; fix the file to use it",e5={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},wN=(e,t)=>`${e5[e]} by ${t==="person"?"you":"a run"}`,Mh=e=>e.readme??e.file,Kp="Can't tell which version this is: reload.",Tf="It changed since you opened it.",t5=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.",n5=e=>`It makes a new agent that runs the steps of ${e} on their own, with no agent loop, under this agent's tool settings, approvals and cap. ${e} stays here, unchanged.`,s5="Making an agent from it takes your password sign-in in the console.",r5="Restoring takes your password sign-in in the console.",kN=["feedback","project","reference","user"],o5={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},jN=e=>o5[e]??e,a5={feedback:"How to work: a rule or a correction",project:"Facts about the work itself",reference:"Where to find things",user:"About the person it works for"},i5=["seeded","reflecting","proposed"],NN=e=>!!e&&i5.includes(e.state),wc=e=>Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&typeof t.file=="string"&&typeof t.name=="string"):[],SN=e=>wc(e==null?void 0:e.given),_N=e=>wc(e==null?void 0:e.read),Jl=e=>(e==null?void 0:e.state)==="merged"?wc(e.learned):[],ox=e=>wc(e==null?void 0:e.pending),$N=e=>wc(e),Ww=e=>(e==null?void 0:e.state)==="merged"?$N(e.skills):[],Hw=e=>(e==null?void 0:e.state)==="merged"?$N(e.workflows):[],l5=e=>ox(e).length>0,Fd=(e,t)=>`${e} ${t}${e===1?"":"s"}`,EN=e=>e.status==="pending",Ud=e=>{var t;return((t=e==null?void 0:e.learning)==null?void 0:t.pending)??0},ax=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function c5(e){const t=e&&typeof e=="object"?e.learning:void 0;return t&&typeof t=="object"&&t.approve===!0?"yes":"password"}const CN="Approving needs your password sign-in. Until then it stays out of every run.",u5="It changes what this agent trusts or skips, so it waits for you.",d5="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",TN="[redacted]",RN=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",di=e=>`${e} ${e===1?"note":"notes"}`,ko=e=>`${e} ${e===1?"run":"runs"}`,f5={grader:"refused",checker:"refused",screen:"refused",screen_down:"refused",unparsed:"refused",empty:"nothing",no_budget:"skipped",unknown_cost:"skipped",no_write_tool:"skipped",tool_denied:"skipped"},Wd=e=>f5[e??""]??"stopped",m5={empty:"Nothing new to remember from this run.",unparsed:"Not kept: its notes weren't in the expected format.",grader:"Not kept: it wouldn't help later runs enough.",checker:"Not kept: it held something that must not be stored.",screen:"Not kept: it held something that must not be stored.",screen_down:"Not kept: it couldn't be checked for safety.",no_write_tool:"Not kept: this agent can't write notes (give it the write tool).",tool_denied:"Not kept: this agent isn't allowed to write notes.",no_budget:"Skipped: no budget left in this run to look back.",unknown_cost:"Skipped: no budget left in this run to look back.",seed_failed:"Started without its notes: they couldn't be read.",cancelled:"Not kept: learning stopped (the run was cancelled).",crashed:"Not kept: learning stopped (the run ended unexpectedly).",reflect_timeout:"Not kept: learning stopped (it ran out of time).",reflect_failed:"Not kept: learning stopped (an error).",propose_failed:"Not kept: learning stopped (an error).",grade_failed:"Not kept: learning stopped (the check couldn't run)."};function ix(e){return e.detail&&e.detail.trim()?e.detail.trim():m5[e.reason??""]??"Not kept: learning stopped."}const p5=e=>e==="seeded"?"Learns after the run":"Looking back",Hd=e=>ji(Math.round(e)*1e3),fi=e=>No({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),Bw=(e,t)=>e>0?Math.round((t-e)/e*100):null,AN=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",ON=e=>e.after.median_learning_usd;function h5(e){const t=[`answers in ${Hd(e.after.median_duration_s)} instead of ${Hd(e.before.median_duration_s)}`];AN(e)&&t.push(`${fi(e.after.median_cost_usd)} instead of ${fi(e.before.median_cost_usd)} a run`);const s=ON(e);return s!==null&&t.push(`learning itself ${fi(s)} a run`),`Since it learned (on ${ko(e.after.runs)}): ${t.join(" · ")}`}const g5=e=>{const t=s=>!!s&&typeof s=="object"&&typeof s.runs=="number"&&s.runs>=2&&typeof s.median_duration_s=="number";return!!e&&typeof e=="object"&&t(e.before)&&t(e.after)},x5=/^---\n([\s\S]*?)\n?^---$\n?/m,Lh=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function Bd(e){const t=e.replace(/\r\n/g,`
531
+ `),s=t.startsWith(`---
532
+ `)?x5.exec(t):null;if(!s||s.index!==0)return{name:"",description:"",type:"project",body:t,rest:[]};const r={},a=[];for(const c of s[1].split(`
533
+ `)){const u=/^(name|description|type):(?:\s+(.*))?$/.exec(c);u&&!(u[1]in r)?r[u[1]]=Lh((u[2]??"").trim()):c.trim()&&a.push(c)}const l=kN.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:l,body:t.slice(s[0].length),rest:a}}const Gw=e=>{const t=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(t)?t.includes('"')?`'${t}'`:`"${t}"`:t},y5=e=>`---
534
+ name: ${Gw(e.name)}
535
+ description: ${Gw(e.description)}
536
+ type: ${e.type}
537
+ ${e.rest.map(t=>`${t}
538
+ `).join("")}---
539
+ ${e.body.replace(/^\n*/,`
540
+ `)}`;function b5(e){const t=Bd(e).rest.find(r=>/^supersedes:/.test(r)),s=t?Lh(t.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>Lh(r.trim())).filter(Boolean):[]}const Zl=e=>Bd(e).body.replace(/^\n+/,"");function qw(e,t=[]){const s=e.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"note";let r=`${s}.md`;for(let a=2;t.includes(r);a++)r=`${s}-${a}.md`;return r}const Rf=(e,t=[])=>{const s=t.filter(a=>a!==TN),r=new URLSearchParams(s.map(a=>["note",a]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function MN(e){return e.kind===Cr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===Cr?{...e,kind:Cr,agent_label:null}:e}const Cr="learning",v5={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},Ph=e=>e?v5[e.state]??0:-1,w5=e=>{const t=e==null?void 0:e.learning;return t&&typeof t=="object"&&typeof t.state=="string"?t:void 0},Vw=e=>e.charAt(0).toLowerCase()+e.slice(1);function k5(e){var s,r;if(!e||Ph(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${Vw(((s=e.detail)==null?void 0:s.trim())||"Checking its new notes…")}`;const t=a=>a.map(l=>l.name.replace(/\s+/g," ").trim()).join(", ");if(e.state==="merged"){const a=Jl(e),l=ox(e),c=[...a.length?[`kept ${di(a.length)} (${t(a)})`]:[],...l.length?[`${Vw(RN(l.length))} (${t(l)})`]:[]];return c.length?`Looked back: ${c.join("; ")}`:`Looked back. ${((r=e.detail)==null?void 0:r.trim())||"It kept what it learned."}`}return Wd(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${ix(e)}`}function j5(e){var l;const t=MN(e),s=t.summary??"",r=aN(t)?`${s} (failed)`:s,a=(l=rN(t))==null?void 0:l.trimEnd();return a&&a.trim()!==s.trim()?`${r}
541
+ ${a.replace(/^(?=.)/gm," ")}`:r}function LN(e,t){const s=e.filter(d=>d.agent_label===Cr&&d.kind!==Cr);if(!s.length)return e.map(MN);const r=e.findLast(d=>d.kind===Cr),a=w5(r),l=Ph(a)>Ph(t??void 0)?a:t&&{...t,detail:t.detail??(a==null?void 0:a.detail)??(r==null?void 0:r.summary)??null},c=s[0],u={id:c.id,seq:c.seq,timestamp:c.timestamp,created_at:c.created_at,kind:Cr,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:k5(l??void 0),text:[...s,...r?[r]:[]].map(j5).join(`
542
+ `)};return e.flatMap(d=>d===c?[u]:d.agent_label===Cr||d.kind===Cr?[]:[d])}const N5={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},Kw=["Added","Replaced","Retired","Removed","Changed"];function S5(e){const t=[],s=[];let r=0;for(const a of e.split(`
543
+ `)){const l=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(a);l?((r||Number(l[1])>1)&&t.push({text:"…",mark:"gap"}),(r||Number(l[2])>1)&&s.push({text:"…",mark:"gap"}),r++):r&&a.startsWith(" ")?(t.push({text:a.slice(1),mark:"same"}),s.push({text:a.slice(1),mark:"same"})):r&&a.startsWith("-")?t.push({text:a.slice(1),mark:"removed"}):r&&a.startsWith("+")&&s.push({text:a.slice(1),mark:"added"})}return{before:t,after:s}}function _5(e,t){const s=e.files.filter(u=>u.path!=="MEMORY.md"),r=new Map(s.map(u=>[u.path,u.patch===void 0?null:S5(u.patch)])),a=new Map([...SN(t),..._N(t),...Jl(t)].map(u=>[u.file,u.name])),l=u=>{const d=r.get(u),p=[...(d==null?void 0:d.after)??[],...(d==null?void 0:d.before)??[]].find(g=>g.mark!=="gap"&&/^name:\s*\S/.test(g.text));return a.get(u)??(p==null?void 0:p.text.replace(/^name:\s*/,"").trim())??u.replace(/\.md$/,"")};return s.map(u=>{var m,v;const d=r.get(u.path),p=l(u.path),g=((d==null?void 0:d.after)??[]).filter(w=>w.mark==="added").map(w=>w.text.trim()),y=((m=g.find(w=>w.startsWith("superseded_by:")))==null?void 0:m.replace(/^superseded_by:\s*/,""))??((v=Jl(t).find(w=>{var k;return(k=w.supersedes)==null?void 0:k.includes(u.path)}))==null?void 0:v.file),h=u.status==="added"?`Added: ${p}`:u.status==="deleted"?`Removed: ${p}`:g.includes("status: superseded")||!d&&y?`Replaced: ${p}${y?` → ${l(y)}`:""}`:g.includes("status: retired")?`Retired: ${p}`:`Changed: ${p}`;return d?{file:u.path,said:h,before:u.status==="added"?null:d.before,after:u.status==="deleted"?null:d.after}:{file:u.path,said:h,before:null,after:null,withheld:N5[u.withheld??""]??"Not shown."}}).sort((u,d)=>Kw.indexOf(u.said.split(":")[0])-Kw.indexOf(d.said.split(":")[0]))}function $5(e){const t=new Map;for(const s of e)for(const r of s.files){const a=t.get(r)??{};"run"in s.by&&(a.run={id:s.by.run,at:s.at,reason:s.reason}),t.set(r,a)}return t}function Af({run:e,link:t=!1,className:s}){var y;const r=SN(e.learning),a=_N(e.learning),l=Jl(e.learning),c=NN(e.learning)&&e.learning.state!=="seeded",u=ox(e.learning),d=l5(e.learning),p=[...Ww(e.learning),...Hw(e.learning)],g=((y=e.learning)==null?void 0:y.state)==="dropped"&&Wd(e.learning.reason)!=="nothing"?ix(e.learning):null;return!r.length&&!a.length&&!l.length&&!c&&!d&&!p.length&&!g?null:n.jsxs("span",{className:ie("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[r.length>0&&n.jsx(Xu,{agentId:e.agent_id,refs:r,link:t,kind:"given"}),a.length>0&&n.jsx(Xu,{agentId:e.agent_id,refs:a,link:t,kind:"read"}),l.length>0&&n.jsx(Xu,{agentId:e.agent_id,refs:l,link:t,kind:"learned",replaces:l.reduce((h,m)=>{var v;return h+(((v=m.supersedes)==null?void 0:v.length)??0)},0)}),d&&n.jsx(Xu,{agentId:e.agent_id,refs:u,link:t,kind:"pending"}),g&&n.jsx(E5,{agentId:e.agent_id,said:g,link:t}),["skill","workflow"].flatMap(h=>{const m=(h==="skill"?Ww:Hw)(e.learning);return[!1,!0].map(v=>{const w=m.filter(k=>k.pending===!0===v);return w.length?n.jsx(C5,{agentId:e.agent_id,refs:w,link:t,kind:h,pending:v},`${h}-${v}`):null})}),c&&n.jsxs(Ne,{tone:"active",children:[n.jsxs("span",{className:"relative flex size-1.5","aria-hidden":!0,children:[n.jsx("span",{className:"absolute inline-flex size-full animate-ping bg-run-active opacity-75"}),n.jsx("span",{className:"relative inline-flex size-1.5 bg-run-active"})]}),p5(e.learning.state)]})]})}function E5({agentId:e,said:t,link:s}){const r=n.jsxs(Ne,{tone:"muted",className:ie(s&&"cursor-pointer"),children:[n.jsx(eE,{className:"size-3","aria-hidden":!0}),"Kept nothing"]});return s?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[n.jsx("a",{href:Rf(e),"aria-label":`Kept nothing: ${t}`,className:"inline-flex",children:r}),n.jsx("span",{className:"text-small text-muted-foreground",children:t})]}):n.jsx("span",{title:`Kept nothing: ${t}`,"aria-label":`Kept nothing: ${t}`,className:"inline-flex",children:r})}function C5({agentId:e,refs:t,link:s,kind:r,pending:a}){const l=a?`${Fd(t.length,r)} ${t.length===1?"waits":"wait"} for your OK`:`Learned ${Fd(t.length,r)}`,c=`${l}: ${t.map(p=>p.name).join(", ")}`,u=a?yg:r==="skill"?Nd:ka,d=n.jsxs(Ne,{tone:a?"warning":void 0,className:ie(!a&&"border-primary/50 bg-primary/10 text-primary-text",s&&"cursor-pointer"),children:[n.jsx(u,{className:"size-3","aria-hidden":!0}),l]});return s?n.jsx("a",{href:Rf(e),title:c,"aria-label":c,className:"inline-flex",children:d}):n.jsx("span",{title:c,"aria-label":c,className:"inline-flex",children:d})}function Xu({agentId:e,refs:t,link:s,kind:r,replaces:a=0}){const l=r==="pending"?RN(t.length):r==="given"?`Started with: ${di(t.length)}`:r==="read"?`Read: ${di(t.length)}`:`Learned ${di(t.length)}`,c=t.map(m=>m.name).join(", "),u=r==="given"||r==="read",d=u?jd:r==="pending"?yg:vg,p=n.jsxs(Ne,{tone:r==="pending"?"warning":void 0,className:ie(r==="learned"?"border-primary/50 bg-primary/10 text-primary-text":u?"border-border-strong/70 text-foreground/80":"",s&&"cursor-pointer transition-colors group-hover/tip:border-foreground/70"),children:[n.jsx(d,{className:"size-3","aria-hidden":!0}),l]}),g=t.filter(m=>m.file!==TN),y=`${l}${c?`: ${c}`:""}${a?` (replaces ${a===1?"1 older note":`${a} older notes`})`:""}`;if(!s||!g.length&&r!=="pending")return n.jsx("span",{title:y,"aria-label":y,className:"inline-flex",children:p});const h=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"caps block text-micro text-muted-foreground",children:r==="given"?"This run started with":r==="read"?"This run read":r==="learned"?"This run kept":"Waits for your OK before any run reads it"}),t.length>0&&n.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(m=>n.jsx("li",{className:"font-semibold",children:m.name},m.file))}),a>0&&n.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["Replaces ",a===1?"1 older note":`${a} older notes`,"."]}),n.jsx("span",{className:"mt-1.5 block text-label text-muted-foreground",children:"Open in Learning"})]});return n.jsx(D4,{tip:h,children:n.jsx("a",{href:Rf(e,g.map(m=>m.file)),"aria-label":y,className:"inline-flex",children:p})})}function T5({n:e,className:t}){return e<=0?null:n.jsx("span",{"aria-label":ax(e),className:ie("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",t),children:e})}function R5(e,t){var a;const s=e??"pi",r=(a=t.find(l=>l.id===s))==null?void 0:a.steer;return typeof r=="boolean"?r:s==="pi"}const kc={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},A5=new Set(["completed","failed","cancelled"]);function O5(e,t,s,r,a){const c=e==="queued"||e==="working"&&t==="working"?a||s==="workflow"?"steer":"follow_up":e==="input_required"&&t==="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 PN=(e,t)=>e==="failed"&&(t==null?void 0:t.code)==="escalated",M5=(e,t)=>e==="completed"&&!!t;function jc(e,t,s,r,a,l,c,u){const d=A5.has(e),p=s==="agentic",g=PN(e,l),y=M5(e,c),h=e==="queued"&&(u==null?void 0:u.state)==="starting"&&(u.kind==="desktop"||u.kind==="phone"),m=g?"Escalated":y?"Needs review":h?"Starting":e==="input_required"?t==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],v=g||y?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",w=O5(e,t,s,r,a);return{label:m,tone:v,live:e==="queued"||e==="working",needsYou:e==="input_required",final:d,canStop:p&&e==="working"&&t==="working",canCancel:!d,canMessage:w!==null,messageMode:w}}const L5={Queued:Sp,Starting:Sp,Working:Sp,Completed:uc,Failed:gi,Escalated:J$,"Needs review":hg,Cancelled:Ak,"Input required":bg,Stopped:xi,Paused:Mk};function Nc({run:e}){const t=jc(e.status,e.state,e.kind,kc,!0,e.error,e.review,e.computer),s=L5[t.label];return n.jsxs(Ne,{tone:t.tone,children:[n.jsx(s,{className:t.live?"size-3 animate-spin [animation-duration:2s]":"size-3","aria-hidden":!0}),t.label]})}const Xa=(e,t={})=>({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".'},...t},required:["op","id",...Object.keys(t).filter(s=>s!=="delay")],additionalProperties:!1}),pr=(e,t=[])=>({type:"object",additionalProperties:!1,properties:e,...t.length?{required:t}:{}}),P5={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:pr({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},I5=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."}),z5=e=>`Browse and automate websites in the persistent browser. ${I5.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"}]}.`,D5={name:"run",label:"Browser: run",description:z5(),parameters:pr({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},Xa("click"),Xa("hover"),Xa("fill",{value:{type:"string"}}),Xa("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Xa("press",{key:{type:"string"}}),Xa("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},F5={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:pr({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:{...pr({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"},U5={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:pr({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},W5={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:pr({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},H5={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:pr({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"},B5={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:pr({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"},G5={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:pr({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},q5={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:pr({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"},V5=Object.freeze([P5,D5,F5,U5,W5,H5,B5,G5,q5]),K5=Object.freeze(V5.map(e=>e.name)),Y5={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function X5(e){const t=e.split(".").at(-1)||e;return Y5[e]??(t?t[0].toUpperCase()+t.slice(1):e)}const Q5=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"]),J5=new Set(["ctrl","alt","super"]);function Z5(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=>J5.has(r))||s.every(r=>Q5.has(r))?e:void 0}const eM=["press","set","perform","click","type","key","nav","scroll","drag"];function tM(e,t){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=eM.find(d=>d in s)??"step",a=r==="type"?s.into:s[r],l=typeof a=="string"?t(a):void 0,c=r==="key"?Z5(s.key):void 0,u=r==="nav"&&typeof s.nav=="string"?s.nav:void 0;return{do:r,...l?{on:l}:{},...c?{keys:c}:{},...u?{nav:u}:{}}}const nM={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"},sM=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function rM(e){if(!e)return;const t=nM[e.role]??(e.role==="generic"?"element":e.role);return e.name?sM.has(e.role)?`“${e.name}”`:`the ${t} “${e.name}”`:`the ${t}`}const oM={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"]},aM={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},Yp={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},Vt=(e,t,s="")=>({did:`${e}${s}`,tried:`${t}${s}`});function iM(e){const t=e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+"),s=t.at(-1)??"",r=t.slice(0,-1).map(c=>c.toLowerCase()),a=t.length===1&&Yp[s.toLowerCase()]?Yp[s.toLowerCase()]:`${r.map(c=>aM[c]??`${c}+`).join("")}${Yp[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,l=r.length===1&&r[0]==="super"?oM[s.toLowerCase()]:void 0;return l?Vt(l[0],l[1],` (${a})`):Vt("Pressed","press",` ${a}`)}const lM={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function cM(e){const t=rM(e.on),s=r=>` ${t??r}`;switch(e.do){case"press":return Vt("Pressed","press",s("an element"));case"click":return Vt("Clicked","click",t?` ${t}`:" at a point");case"set":return Vt("Set","set",s("an element"));case"perform":return Vt("Acted on","act on",s("an element"));case"type":return t?Vt("Typed into","type into",` ${t}`):Vt("Typed text","type text");case"key":return e.keys?iM(e.keys):Vt("Pressed a key","press a key");case"nav":{const[r,a,l]=e.nav&&lM[e.nav]||["Navigated","navigate",""];return Vt(r,a,l)}case"scroll":return t?Vt("Scrolled","scroll",` ${t}`):Vt("Scrolled","scroll");case"drag":return Vt("Dragged","drag"," across the screen");default:return Vt("Acted","act")}}function Yw(e){const t=cM(e);return e.error===void 0?t.did:`Could not ${t.tried}`}const Xw=3,Ih=e=>e[0].toLowerCase()+e.slice(1);function uM(e){const t=e.slice(0,Xw).map(Yw),s=e.slice(Xw),r=s.findIndex(l=>l.error!==void 0),a=r<0?s.length:s.length-1;return[t[0],...t.slice(1).map(Ih),...a>0?[`+${a} more`]:[],...r<0?[]:[Ih(Yw(s[r]))]].join(", ")}const dM={"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 Pr(e){const t=e.app?X5(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return Vt("Opened","open",` ${t??"an app"}`);case"apps.terminate":return Vt("Quit","quit",` ${t??"an app"}`);case"ui.observe":return Vt("Looked at","look at",` ${t??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:uM(e.steps),tried:""}:e.ok?Vt("Waited for","wait for",` ${t??"the window"}${e.expect==="unmet"?" (not seen)":""}`):Vt("Acted on","act on",` ${t??"the computer"}`);default:{const[a,l]=dM[e.method]??[e.method,e.method];return Vt(a,l)}}})();return e.ok?s.did:`Could not ${s.tried}`}const fM=e=>e.map((t,s)=>s===0?Pr(t):Ih(Pr(t))).join(", "),ga=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,nn=e=>typeof e=="string"?e:void 0,xa=(e,t)=>e.length>t?`${e.slice(0,t-3)}...`:e,IN=e=>e.split(`
544
+ `).map(t=>t.trim()).find(Boolean)??"";function Gd(e){try{return ga(JSON.parse(e))}catch{return}}const mM=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function ec(e){const t=mM.exec(e.trim());return xa(t?`${t[1]}${t[2]==="/"?"":t[2]}`:e.split(/[?#]/)[0]??"",80)}const pM="…",hM=/https?:\/\/[^\s"'`<>\\]+/gi,gM=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i;function lx(e){return e.replace(hM,t=>{var l;const s=((l=/[.,;:!?)\]}]+$/.exec(t))==null?void 0:l[0])??"",r=gM.exec(t.slice(0,t.length-s.length));if(!r)return t;const a=[...new Set((r[4]??"").split("&").map(c=>c.split("=")[0]).filter(Boolean))];return`${r[1]}${r[2]}${r[3]}${a.length?`?${a.map(c=>`${c}=${pM}`).join("&")}`:""}${s}`})}const xM=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),yM=new Map,bM=new Map,zN=new Map,vM=new Set;function Xt(e,t,s,{name:r,saysFailure:a}={}){yM.set(e,t),s&&bM.set(e,s),r&&zN.set(e,r),a&&vM.add(e)}const wM=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,kM=e=>{const t=wM.exec(e);return t&&t[1]!=="hands"?`${t[1]} · ${t[2]}`:void 0},jM=e=>zN.get(e)??kM(e)??e,NM=new Map;function cx(e,t){NM.set(e,t)}const SM=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...SM];const ux=e=>nn(e.path)??nn(e.file_path),_M=/page\.goto\(\s*["'`]([^"'`]+)/;Xt("read",e=>`Read ${ux(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});Xt("write",e=>`Wrote ${ux(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});Xt("edit",e=>`Edited ${ux(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});Xt("bash",e=>`Ran \`${xa(lx(IN(nn(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const DN=e=>{const t=e&&ga(Gd(e.text)??Gd(IN(e.text)));if((t==null?void 0:t.ok)!==!1)return;const s=nn(t.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:nn(t.error)??nn(t.message)??"no detail"}},$M=(e,t)=>`${DN(t)?"Tried to fetch":"Fetched"} ${ec(nn(e.url)??"a page")}`,EM={many:e=>`Fetched ${e} pages`,subject:e=>e?ec(e):void 0},CM=e=>{const t=DN(e);return t&&{failed:!0,text:`${t.refused?"refused":"failed"}: ${t.detail}`}};Xt("web_fetch",$M,EM,{name:"Fetch web pages"});cx("web_fetch",CM);Xt("web_search",e=>{const t=nn(e.query);return t?`Searched the web for "${xa(lx(t),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${xa(e,40)}"`:void 0},{name:"Search the web"});cx("web_search",e=>{var s;const t=nn((s=ga(Gd(e.text)))==null?void 0:s.error);return t!==void 0?{failed:!0,text:`failed: ${t}`}:void 0});Xt("browser_read",(e,t)=>{var r;const s=t&&((r=/^title: (.+)$/m.exec(t.text))==null?void 0:r[1]);return s?`Read the page "${xa(lx(s),60)}"`:"Read the page"},{many:e=>`Read ${e} pages`,subject:(e,t)=>{var r;const s=t&&((r=/^url: (\S+)/m.exec(t))==null?void 0:r[1]);return s?ec(s):void 0}},{name:"Read the browser's page"});Xt("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});Xt("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});Xt("run",(e,t)=>{var l,c;const s=(l=_M.exec(nn(e.code)??""))==null?void 0:l[1];if(s)return`Opened ${ec(s)}`;const r=(c=ga(t==null?void 0:t.details))==null?void 0:c.sent,a=Array.isArray(r)?r.flatMap(u=>{const d=ga(u),[p,g]=[nn(d==null?void 0:d.method),nn(d==null?void 0:d.url)];return p&&g?`${p} ${ec(g)}`:[]}):[];return a.length?`Acted on the page (${a.length} request${a.length===1?"":"s"} sent: ${xM(a)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});Xt("browser_downloads",(e,t)=>{var a;const s=t&&((a=Gd(t.text))==null?void 0:a.fetched),r=Array.isArray(s)?s.flatMap(l=>{var c;return nn((c=ga(l))==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"});Xt("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});Xt("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});Xt("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});Xt("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});Xt("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const TM=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,RM=e=>{if(e!==void 0)try{return nn(JSON.parse(e))}catch{return}};function FN(e){var s;const t=new Map;for(const r of(e??"").split(`
545
+ `)){const a=TM.exec(r);if(!a)continue;const l=RM(a[3]),c=(s=/^refused \([^)]*\): (.*)$/.exec(a[4]))==null?void 0:s[1],u=a[2]===void 0?void 0:{role:a[2],...l?{name:l}:{}};t.set(Number(a[1]),{...u?{on:u}:{},...c!==void 0?{refused:c}:{}})}return t}function AM(e,t){return{...tM(e,()=>t==null?void 0:t.on),...(t==null?void 0:t.refused)!==void 0?{error:"refused"}:{}}}Xt("computer_act",(e,t)=>{var u;const s=Array.isArray(e.steps)?e.steps.flatMap(d=>{const p=ga(d);return p?[p]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...nn(e.app)?{app:nn(e.app)}:{}};if(t!=null&&t.isError)return Pr({...r,ok:!1});const a=t===void 0?void 0:FN(t.text),l=a===void 0?s:s.filter((d,p)=>a.has(p+1));if(s.length>0&&l.length===0)return Pr({...r,ok:!1});const c=t&&((u=/^expect: (met|unmet)$/m.exec(t.text))==null?void 0:u[1]);return Pr({...r,ok:!0,steps:l.map((d,p)=>AM(d,a==null?void 0:a.get(p+1))),...c==="met"||c==="unmet"?{expect:c}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Act on the computer",saysFailure:!0});cx("computer_act",e=>{for(const[t,s]of FN(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${t} refused: ${s.refused}`}});const Qw=/^state \S+ · (\S+)/,OM=/^screen \S+ px · (?:\S+ in front|no app in front)/;Xt("computer_observe",(e,t)=>{var r;if(t&&!t.isError&&!Qw.test(t.text)){const a=OM.test(t.text),l=(u,d)=>({method:u,started_at:"",ms:0,ok:!0,...d?{app:d}:{}}),c=a?nn(e.app):void 0;return fM([...c?[l("apps.launch",c)]:[],l("screen.shot"),...a?[l("apps.list")]:[]])}const s=nn(e.app)??(t&&((r=Qw.exec(t.text))==null?void 0:r[1]));return Pr({method:"ui.observe",ok:(t==null?void 0:t.isError)!==!0,...s?{app:s}:{}})},{many:e=>`Looked at the screen ${e} times`},{name:"Look at the computer",saysFailure:!0});Xt("computer_screenshot",(e,t)=>Pr({method:"screen.shot",ok:(t==null?void 0:t.isError)!==!0}),{many:e=>`Took ${e} screenshots`},{name:"Take screenshots of the computer",saysFailure:!0});Xt("computer_script",(e,t)=>{var r;const s=(r=nn(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return t!=null&&t.isError?s?`Could not run the script “${xa(s,120)}”`:"Could not run a script on the computer":s?xa(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 Jw="https://api.githubcopilot.com/mcp/",Sc={composio:"Composio",github:"GitHub",url:"URL"},Zw=/^[a-z][a-z0-9-]{0,31}$/;function MM(e){const t=new URLSearchParams(e??""),s=t.get("add");if(!s||!Zw.test(s))return;const r=t.get("toolkit")??"";if(t.get("preset")==="composio"&&Zw.test(r)){const a=(t.get("tools")??"").split(",").filter(l=>/^[A-Za-z0-9_-]{1,128}$/.test(l)).slice(0,64);return{name:s,preset:"composio",toolkit:r,...a.length?{tools:a}:{}}}return{name:s,...t.get("auth")==="github_app"?{auth:"github_app"}:{}}}const LM="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.",UN=(e,t)=>`mcp:${e}/${t}`;function ya(e){const t=/^mcp:([^/]+)\/(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}function PM(e,t){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[t])}function IM(e,t){return e.flatMap(s=>{const r=ya(s);if(!r)return[];const a=t.find(l=>l.name===r.server);return a?a.tools.some(l=>l.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 e0=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 ba(e){var l,c,u,d,p,g,y;if(!(e instanceof Pe))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const t=(l=e.fields)==null?void 0:l.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=(u=e.details)==null?void 0:u.oauth,a=typeof(r==null?void 0:r.callback)=="string"?r.callback:"";return s?{text:s.message,detail:e0(a),signIn:!0,needsClient:!0}:e.code==="auth_required"&&((d=e.details)==null?void 0:d.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:e0(a),signIn:!0,needsClient:!0}:e.code==="auth_required"?((p=e.details)==null?void 0:p.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}:t?{text:"This address redirects; use the final address.",detail:t.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(" ")}:{text:`${e.code}: ${e.message}`}}const t0={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"},zM="the sign-in didn't finish: try again",DM=e=>e&&Object.hasOwn(t0,e)?t0[e]:zM;function FM(e){const t=new URLSearchParams(e??""),s=t.get("server"),r=t.get("sign_in");if(!(!s||r!=="ok"&&r!=="failed"))return{server:s,ok:r==="ok",...r==="failed"?{error:t.get("error")??"sign_in_failed"}:{}}}const _c=ya;function UM(e){const t=/^mcp__([a-z][a-z0-9-]{0,31})__(.+)$/.exec(e);return t&&t[1]!=="hands"?`${t[1]} · ${t[2]}`:null}const dx=(e,t)=>[e,t!=null&&t.model?t.tier:void 0,t==null?void 0:t.model].filter(Boolean).join(" · "),WN=e=>e!=null&&e.model?`ran on ${e.model}${e.tier?` (the ${e.tier} tier)`:""}`:"",WM={user_message:wg,thinking:X$,tool_use:Nd,tool_result:Nd,waiting:bg,usage:pg,final_answer:Si,phase:Lk,error:gi,decision:vE,text_block:pE,tool_approval_requested:Fk},n0=e=>{var t;return e.kind==="tool_approval_requested"?(t=/\n\n(Not sent: [\s\S]*)$/.exec(e.text??""))==null?void 0:t[1]:void 0},s0=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),fx=e=>e.origin==="server",HN=e=>e.origin==="trigger",BN=e=>{var l;const t=e.summary??"",s=(l=e.trigger)==null?void 0:l.name,r=s?t.indexOf(` ${s}: `):-1;if(s&&r>0&&!t.slice(0,r).includes(" "))return{who:t.slice(0,r+1+s.length),said:t.slice(r+s.length+3).trimStart()};const a=/^([^:]+):\s*/.exec(t);return a?{who:a[1],said:t.slice(a[0].length)}:{who:null,said:t}};function GN(e){const t=e.split(/(\*\*[^*\n]+?\*\*|`[^`\n]+`)/);return t.length===1?e:t.map((s,r)=>r%2===0?s:s.startsWith("`")?n.jsx("code",{className:"font-mono",children:s.slice(1,-1)},r):n.jsx("strong",{className:"font-semibold",children:GN(s.slice(2,-2))},r))}const HM=e=>{var r;const t=HN(e)?BN(e).said:(e.summary??"").replace(fx(e)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(e.kind==="user_message"&&t.startsWith("{"))try{return Object.entries(JSON.parse(t)).map(([a,l])=>`${a}: ${typeof l=="string"?l:JSON.stringify(l)}`).join(" · ")}catch{}const s=(e.text??"").split(`
546
+ `).filter(a=>a.trim()).length>1?"…":"";return e.kind==="final_answer"?!t.trim()&&!((r=e.text)!=null&&r.trim())?pN:`${t.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${t}${s}`:t},tc=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,BM=new Set(K5),GM=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 qM(e){const t=e.replace(/^mcp__.+?__/,""),s=GM.get(t.toLowerCase());if(s)return s;const r=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return r?r[0].toUpperCase()+r.slice(1):e}const r0=e=>e&&(UM(e)??(BM.has(e)?jM(e):qM(e))),o0=e=>fx(e)?"AgentRun":HN(e)?BN(e).who??"Trigger":{user_message:"You",thinking:"Thinking",tool_use:r0(e.tool_name)??"Tool",tool_result:r0(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,VM={budget:"Paused at cap"};function KM({step:e,last:t,ended:s,waitingChip:r,files:a,onOpen:l}){var w,k;const c=e.row,[u,d]=x.useState(!1),g=d4(c)?Mk:WM[c.kind]??Lk,y=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":HM(c),h=e.above?null:e.detail??rN(c),m=h&&h.trim()!==y.trim()?h:null,v=aN(c);return n.jsxs("li",{className:"relative flex gap-3",children:[n.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[n.jsx("span",{className:ie("mt-3 flex size-7 items-center justify-center border bg-background",(c.kind==="waiting"||s0(c))&&"border-warning/60 text-warning-text",v&&"border-destructive/60 text-destructive-text"),children:n.jsx(g,{className:"size-3.5","aria-hidden":!0})}),!t&&n.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),n.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[n.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>d(N=>!N),"aria-expanded":u,disabled:!m,children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[n.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:o0(c),children:o0(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&n.jsxs("span",{className:"font-mono text-label",children:["· ",QO(c.usage,{ended:s})]}),c.kind==="waiting"&&n.jsx(Ne,{tone:"warning",children:r??"Input required"}),s0(c)&&n.jsx(Ne,{tone:"warning",children:"Approval required"}),v&&n.jsx(Ne,{tone:"error",children:"Error"}),oN(c)&&n.jsx(Ne,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&n.jsx(Ne,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&n.jsx("span",{className:"font-mono text-label",children:tc(e.ms)}),e.times&&n.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${tc(Math.max(0,Date.parse(e.until)-Date.parse(c.timestamp)))}`:""]})]}),n.jsx("span",{className:ie("mt-0.5 block break-words text-prose leading-snug",fx(c)&&"text-muted-foreground"),children:GN(y)}),e.saved&&n.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),n0(c)&&n.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:n0(c)})]}),n.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:Cf(c.timestamp)}),m&&n.jsx(cs,{className:ie("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",u&&"rotate-90"),"aria-hidden":!0})]}),u&&m&&c.tool_name&&n.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:c.tool_name}),u&&m&&c.kind==="final_answer"&&n.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:Xg(N=>{const A=a==null?void 0:a.find(_=>_.path===N);A&&(l==null||l(A))}),dangerouslySetInnerHTML:{__html:Lr(m,l&&a?{paths:a.map(N=>N.path)}:void 0)}}),u&&m&&c.kind!=="final_answer"&&n.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:m}),(w=c.learned_nodes)!=null&&w.length?n.jsx(QM,{nodes:c.learned_nodes}):null,(k=c.computer_calls)!=null&&k.length?n.jsx(YM,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function YM({calls:e,dropped:t}){const[s,r]=x.useState(!1),a=e.filter(d=>!d.ok).length,l=e.length+t,c=[`${l} computer ${l===1?"call":"calls"}`,...a?[`${a} failed`]:[]].join(" · "),u=Date.parse(e[0].started_at);return n.jsxs("div",{className:"mt-2",children:[n.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>r(d=>!d),"aria-expanded":s,"aria-label":`${s?"Hide":"Show"} the computer calls`,children:[n.jsx(cs,{className:ie("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),n.jsx(wa,{className:"size-3","aria-hidden":!0}),c]}),s&&n.jsxs("ol",{"aria-label":"The computer calls",className:"mt-2 divide-y border bg-card",children:[e.map((d,p)=>n.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[n.jsxs("span",{className:"w-14 shrink-0 font-mono text-label text-muted-foreground",children:["+",tc(Math.max(0,Date.parse(d.started_at)-u))]}),n.jsx("span",{className:ie("min-w-0 flex-1 truncate text-body",!d.ok&&"text-destructive-text"),title:Pr(d),children:Pr(d)}),!d.ok&&d.code&&n.jsx("span",{className:"shrink-0 font-mono text-label text-destructive-text",children:d.code}),n.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:tc(d.ms)})]},p)),t>0&&n.jsxs("li",{className:"px-3 py-1.5 text-body text-muted-foreground",children:[t," more not kept"]})]})]})}const XM={ok:"success",failed:"error",escalated:"warning"};function QM({nodes:e}){const[t,s]=x.useState(!1),r=Object.entries(e.reduce((l,c)=>({...l,[c.status]:(l[c.status]??0)+1}),{})).filter(([l])=>l!=="ok"),a=[`${e.length} ${e.length===1?"node":"nodes"}`,...r.map(([l,c])=>`${c} ${l}`)].join(" · ");return n.jsxs("div",{className:"mt-2",children:[n.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>s(l=>!l),"aria-expanded":t,"aria-label":`${t?"Hide":"Show"} the workflow's ${e.length===1?"node":"nodes"}`,children:[n.jsx(cs,{className:ie("size-3 transition-transform",t&&"rotate-90"),"aria-hidden":!0}),n.jsx(ka,{className:"size-3","aria-hidden":!0}),a]}),t&&n.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((l,c)=>n.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[n.jsx("span",{"data-status":l.status,className:"contents",children:n.jsx(Ne,{tone:XM[l.status]??"muted",className:"w-[5.5rem] justify-center",children:l.status})}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:l.label,children:l.label}),n.jsx("span",{"data-kind":!0,className:"font-mono text-label text-muted-foreground",title:WN(l)||void 0,children:dx(l.kind,l)}),n.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:tc(l.duration_ms)})]},c))})]})}function qN({rows:e,live:t,fold:s=6,asking:r,waitingOn:a,files:l,onOpen:c,ended:u=!1}){var w;const d=a==="budget"?e.findLastIndex(k=>k.paused===!0):-1,p=d>=0?(w=e.slice(d+1).findLast(k=>k.kind==="waiting"))==null?void 0:w.id:void 0,[g,y]=x.useState(!1),h=f4(e).map(k=>r&&k.row.id===r?{...k,above:!0}:k),m=g?0:Math.max(0,h.length-s),v=h.slice(m);return e.length?n.jsxs("div",{children:[m>0&&n.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:[n.jsx(cs,{className:"size-3","aria-hidden":!0})," ",m," earlier ",m===1?"step":"steps"]}),n.jsx("ol",{children:v.map((k,N)=>n.jsx(KM,{step:k,last:N===v.length-1&&!t,ended:u,waitingChip:k.row.id===p&&a?VM[a]:void 0,files:l,onOpen:c},k.row.id))}),t&&n.jsx(zh,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):n.jsx(zh,{title:t?"The run is starting":"Nothing on the timeline",note:t?"Steps appear here as the agent works.":"This run recorded no steps.",spin:t})}function zh({title:e,note:t,spin:s=!0}){return n.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[s&&n.jsx(z4,{className:"size-5"}),n.jsx("p",{className:"caps text-label font-semibold",children:e}),n.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:t})]})}const a0=new Set(["completed","failed","cancelled"]),JM={firstMs:2e3,maxMs:16e3,totalMs:12e4};function VN(e,t,s,r=JM){var g;const a=!!e&&a0.has(e.status)&&NN(e.learning),l=x.useRef(t);l.current=t;const c=x.useRef(s);c.current=s;const u=(g=e==null?void 0:e.learning)==null?void 0:g.state,d=!!e&&a0.has(e.status),p=x.useRef(u);x.useEffect(()=>{var h;const y=p.current;p.current=u,y!==void 0&&y!==u&&d&&((h=c.current)==null||h.call(c))},[u,d]),x.useEffect(()=>{if(!a)return;let y,h=0,m=r.firstMs,v=!1,w=!1;const k=()=>{w||h+m>r.totalMs||(y=setTimeout(N,m))},N=()=>{if(y=void 0,document.visibilityState==="hidden"){v=!0;return}h+=m,m=Math.min(m*2,r.maxMs),l.current(),k()},A=()=>{v&&document.visibilityState!=="hidden"&&(v=!1,N())};return document.addEventListener("visibilitychange",A),k(),()=>{w=!0,y&&clearTimeout(y),document.removeEventListener("visibilitychange",A)}},[a])}function ZM({v2:e,run:t,onRun:s}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,d]=x.useState(null),[p,g]=x.useState(null),[y,h]=x.useState(!1),[m,v]=x.useState(0),w=x.useRef(zd()).current,k=x.useRef(`${t.status}/${t.state}`),N=x.useRef(null),A=x.useRef(k.current),_=async T=>{const C=w.begin();N.current=T;let R="";for(const D of Oh){if(D&&await hN(D),!w.current(C))return;try{const L=await e.getRun(t.run_id);if(!w.current(C))return;k.current=T,N.current=null,g(null),s(L);return}catch(L){R=tn(L)}}w.current(C)&&(N.current=null,g(R))};x.useEffect(()=>{const T=new AbortController;return ex(e,t.run_id,{signal:T.signal,onRows:a,onPage:C=>{d({status:C.status,state:C.state});const R=`${C.status}/${C.state}`,D=R!==A.current;if(A.current=R,R===k.current){w.cancel(),N.current=null,g(null);return}(D||N.current===null)&&_(R)}}).catch(C=>{T.signal.aborted||c(tn(C))}),()=>{T.abort(),w.cancel(),N.current=null}},[e,t.run_id,m]),VN(t,()=>{const T=k.current;e.getRun(t.run_id).then(C=>{k.current===T&&N.current===null&&s(C)},()=>{})},()=>v(T=>T+1));const S=`#/runs/${encodeURIComponent(t.run_id)}`,E=u??t;return n.jsxs("section",{className:"mb-6 border","aria-label":"Latest run",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"Latest run"}),p?n.jsx(Ne,{tone:"muted",children:"Not refreshed"}):n.jsx(Nc,{run:t}),n.jsx("a",{href:S,className:"min-w-0 flex-1 truncate text-lead hover:underline",title:xn(t),children:xn(t)}),n.jsx(Af,{run:t,link:!0}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ht(t.created_at)}),n.jsxs("a",{href:S,className:Ni({size:"sm"}),children:["Open the run ",n.jsx(fg,{"aria-hidden":!0})]})]}),p&&n.jsxs("p",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2 font-mono text-small text-destructive-text",role:"alert",children:["This run could not be refreshed: ",p,n.jsx(K,{type:"button",disabled:y,onClick:()=>{h(!0),_(A.current).finally(()=>h(!1))},size:"xs",className:"text-foreground",children:y?"Retrying":"Retry"})]}),n.jsx("div",{className:"px-4 py-3",children:l?n.jsxs("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:["The timeline could not be read: ",l]}):r?n.jsx(qN,{rows:LN(r,t.learning),live:jc(E.status,E.state,t.kind,kc,!0).live,ended:pa(E.status)}):n.jsx("p",{className:"py-6 text-center font-mono text-body text-muted-foreground",children:"Reading the timeline..."})})]})}function $n({problem:e,onRetry:t,link:s,className:r="m-8"}){return n.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${r}`,role:"alert",children:[n.jsx(Zs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-prose font-semibold",children:e.title}),n.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&n.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),(t||s)&&n.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[t&&n.jsx(K,{type:"button",onClick:t,size:"sm",children:"Try again"}),s&&n.jsx("a",{href:s.href,className:"caps border px-3 py-2 text-small hover:bg-accent",children:s.label})]})]})]})}function KN({what:e,id:t,list:s}){return n.jsx($n,{problem:{title:`No ${e} with this id.`,why:`This server has no ${e} ${t}.`,next:`Check the address, or find the ${e} in the list.`},link:s})}const Qu=(e,t,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=t&&r<=s?r:null};function eL(e){const t=e.trim().split(/\s+/);if(t.length!==5)return null;const[s,r,a,l,c]=t,u=Qu(s,0,59);if(u===null||l!=="*")return null;if(r==="*")return a==="*"&&c==="*"?{kind:"hourly",minute:u}:null;const d=Qu(r,0,23);if(d===null)return null;const p={hour:d,minute:u};if(a==="*"&&c==="*")return{kind:"daily",at:p};if(a==="*"&&c==="1-5")return{kind:"weekdays",at:p};if(a==="*"){const g=Qu(c,0,6);return g===null?null:{kind:"weekly",day:g,at:p}}if(c==="*"){const g=Qu(a,1,31);return g===null?null:{kind:"monthly",date:g,at:p}}return null}function tL(e){if(e.kind==="hourly")return`${e.minute} * * * *`;const t=`${e.at.minute} ${e.at.hour}`;return e.kind==="daily"?`${t} * * *`:e.kind==="weekdays"?`${t} * * 1-5`:e.kind==="weekly"?`${t} * * ${e.day}`:`${t} ${e.date} * *`}function nL(e,t){const s=t&&"at"in t?t.at:{hour:9,minute:(t==null?void 0:t.kind)==="hourly"?t.minute:0};return e==="hourly"?{kind:e,minute:s.minute}:e==="weekly"?{kind:e,day:(t==null?void 0:t.kind)==="weekly"?t.day:1,at:s}:e==="monthly"?{kind:e,date:(t==null?void 0:t.kind)==="monthly"?t.date:1,at:s}:{kind:e,at:s}}const i0=e=>String(e).padStart(2,"0"),sL=e=>`${i0(e.hour)}:${i0(e.minute)}`;function rL(e){const t=/^(\d{2}):(\d{2})/.exec(e);if(!t)return null;const s=Number(t[1]),r=Number(t[2]);return s<=23&&r<=59?{hour:s,minute:r}:null}var Xp={exports:{}},l0;function oL(){return l0||(l0=1,(function(e,t){(function(r,a){e.exports=a()})(globalThis,()=>(()=>{var s={6949(c,u,d){Object.defineProperty(u,"__esModule",{value:!0}),u.CronParser=void 0;var p=d(9515),g=(function(){function y(h,m,v){m===void 0&&(m=!0),v===void 0&&(v=!1),this.expression=h,this.dayOfWeekStartIndexZero=m,this.monthStartIndexZero=v}return y.prototype.parse=function(){var h,m,v=(h=this.expression)!==null&&h!==void 0?h:"";if(v==="@reboot")return m=["@reboot","","","","","",""],m;if(v.startsWith("@")){var w=this.parseSpecial(this.expression);m=this.extractParts(w)}else m=this.extractParts(this.expression);return this.normalize(m),this.validate(m),m},y.prototype.parseSpecial=function(h){var m={"@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"},v=m[h];if(!v)throw new Error("Unknown special expression.");return v},y.prototype.extractParts=function(h){if(!this.expression)throw new Error("cron expression is empty");for(var m=h.trim().split(/[ ]+/),v=0;v<m.length;v++)if(m[v].includes(",")){var w=m[v].split(",").map(function(N){return N.trim()}).filter(function(N){return N!==""}).map(function(N){return isNaN(Number(N))?N:Number(N)}).filter(function(N){return N!==null&&N!==""});w.length===0&&w.push("*"),w.sort(function(N,A){return N!==null&&A!==null?N-A:0}),m[v]=w.map(function(N){return N!==null?N.toString():""}).join(",")}if(m.length<5)throw new Error("Expression has only ".concat(m.length," part").concat(m.length==1?"":"s",". At least 5 parts are required."));if(m.length==5)m.unshift(""),m.push("");else if(m.length==6){var k=/\d{4}$/.test(m[5])||m[4]=="?"||m[2]=="?";k?m.unshift(""):m.push("")}else if(m.length>7)throw new Error("Expression has ".concat(m.length," parts; too many!"));return m},y.prototype.normalize=function(h){var m=this;h[3]=h[3].replace("?","*"),h[5]=h[5].replace("?","*"),h[2]=h[2].replace("?","*"),h[0].indexOf("0/")==0&&(h[0]=h[0].replace("0/","*/")),h[1].indexOf("0/")==0&&(h[1]=h[1].replace("0/","*/")),h[2].indexOf("0/")==0&&(h[2]=h[2].replace("0/","*/")),h[3].indexOf("1/")==0&&(h[3]=h[3].replace("1/","*/")),!this.monthStartIndexZero&&h[4].indexOf("1/")==0&&(h[4]=h[4].replace("1/","*/")),h[6].indexOf("1/")==0&&(h[6]=h[6].replace("1/","*/")),h[5]=h[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function(T){var C=T.replace(/\D/,""),R=C;return m.dayOfWeekStartIndexZero?C=="7"&&(R="0"):R=(parseInt(C)-1).toString(),T.replace(C,R)}),h[5]=="L"&&(h[5]="6"),h[3]=="?"&&(h[3]="*");var v=/^\d{1,2}W[+-]\d{1,2}$/;if(h[3].indexOf("W")>-1&&(h[3].indexOf(",")>-1||/[-+]/.test(h[3]))&&!v.test(h[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 w={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var k in w)h[5]=h[5].replace(new RegExp(k,"gi"),w[k].toString());h[4]=h[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(T){var C=T.replace(/\D/,""),R=C;return m.monthStartIndexZero&&(R=(parseInt(C)+1).toString()),T.replace(C,R)});var N={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 A in N)h[4]=h[4].replace(new RegExp(A,"gi"),N[A].toString());h[0]=="0"&&(h[0]=""),!/\*|\-|\,|\//.test(h[2])&&(/\*|\//.test(h[1])||/\*|\//.test(h[0]))&&(h[2]+="-".concat(h[2]));for(var _=0;_<h.length;_++)if(h[_].indexOf(",")!=-1&&(h[_]=h[_].split(",").filter(function(T){return T!==""}).join(",")||"*"),h[_]=="*/1"&&(h[_]="*"),h[_].indexOf("/")>-1&&!/^\*|\-|\,/.test(h[_])){var S=null;switch(_){case 4:S="12";break;case 5:S="6";break;case 6:S="9999";break;default:S=null;break}if(S!==null){var E=h[_].split("/");h[_]="".concat(E[0],"-").concat(S,"/").concat(E[1])}}},y.prototype.validate=function(h){var m="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(h[0],m),this.validateOnlyExpectedCharactersFound(h[1],m),this.validateOnlyExpectedCharactersFound(h[2],m),this.validateOnlyExpectedCharactersFound(h[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(h[4],m),this.validateOnlyExpectedCharactersFound(h[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(h[6],m),this.validateAnyRanges(h)},y.prototype.validateAnyRanges=function(h){h.forEach(function(m){return p.default.stepRange(m)}),p.default.secondRange(h[0]),p.default.minuteRange(h[1]),p.default.hourRange(h[2]),p.default.dayOfMonthRange(h[3]),p.default.monthRange(h[4],this.monthStartIndexZero),p.default.dayOfWeekRange(h[5],this.dayOfWeekStartIndexZero)},y.prototype.validateOnlyExpectedCharactersFound=function(h,m){var v=h.match(new RegExp("[^".concat(m,"]+"),"gi"));if(v&&v.length)throw new Error("Expression contains invalid values: '".concat(v.toString(),"'"))},y})();u.CronParser=g},8333(c,u,d){Object.defineProperty(u,"__esModule",{value:!0}),u.ExpressionDescriptor=void 0;var p=d(1823),g=d(6949),y=(function(){function h(m,v){if(this.expression=m,this.options=v,this.expressionParts=new Array(5),!this.options.locale&&h.defaultLocale&&(this.options.locale=h.defaultLocale),!h.locales[this.options.locale]){var w=Object.keys(h.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(w,"'.")),this.options.locale=w}this.i18n=h.locales[this.options.locale],v.use24HourTimeFormat===void 0&&(v.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return h.toString=function(m,v){var w=v===void 0?{}:v,k=w.throwExceptionOnParseError,N=k===void 0?!0:k,A=w.verbose,_=A===void 0?!1:A,S=w.dayOfWeekStartIndexZero,E=S===void 0?!0:S,T=w.monthStartIndexZero,C=T===void 0?!1:T,R=w.use24HourTimeFormat,D=w.trimHoursLeadingZero,L=D===void 0?!1:D,O=w.locale,I=O===void 0?null:O,W=w.logicalAndDayFields,U=W===void 0?!1:W,J={throwExceptionOnParseError:N,verbose:_,dayOfWeekStartIndexZero:E,monthStartIndexZero:C,use24HourTimeFormat:R,trimHoursLeadingZero:L,locale:I,logicalAndDayFields:U};J.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var F=new h(m,J);return F.getFullDescription()},h.initialize=function(m,v){v===void 0&&(v="en"),h.specialCharacters=["/","-",",","*"],h.defaultLocale=v,m.load(h.locales)},h.prototype.getFullDescription=function(){var m,v,w="";try{var k=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=k.parse(),this.expressionParts[0]==="@reboot")return((v=(m=this.i18n).atReboot)===null||v===void 0?void 0:v.call(m))||"Run once, at startup";var N=this.getTimeOfDayDescription(),A=this.getDayOfMonthDescription(),_=this.getMonthDescription(),S=this.getDayOfWeekDescription(),E=this.getYearDescription();w+=N+A+S+_+E,w=this.transformVerbosity(w,!!this.options.verbose),w=w.charAt(0).toLocaleUpperCase()+w.substr(1)}catch(T){if(!this.options.throwExceptionOnParseError)w=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(T)}return w},h.prototype.getTimeOfDayDescription=function(){var m=this.expressionParts[0],v=this.expressionParts[1],w=this.expressionParts[2],k="";if(!p.StringUtilities.containsAny(v,h.specialCharacters)&&!p.StringUtilities.containsAny(w,h.specialCharacters)&&!p.StringUtilities.containsAny(m,h.specialCharacters))k+=this.i18n.atSpace()+this.formatTime(w,v,m);else if(!m&&v.indexOf("-")>-1&&!(v.indexOf(",")>-1)&&!(v.indexOf("/")>-1)&&!p.StringUtilities.containsAny(w,h.specialCharacters)){var N=v.split("-");k+=p.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(w,N[0],""),this.formatTime(w,N[1],""))}else if(!m&&w.indexOf(",")>-1&&w.indexOf("-")==-1&&w.indexOf("/")==-1&&!p.StringUtilities.containsAny(v,h.specialCharacters)){var A=w.split(",");k+=this.i18n.at();for(var _=0;_<A.length;_++)k&&(k+=" "),k+=this.formatTime(A[_],v,""),_<A.length-2&&(k+=","),_==A.length-2&&(k+=this.i18n.spaceAnd())}else{var S=this.getSecondsDescription(),E=this.getMinutesDescription(),T=this.getHoursDescription();if(k+=S,k&&E&&(k+=", "),k+=E,E===T)return k;k&&T&&(k+=", "),k+=T}return k},h.prototype.getSecondsDescription=function(){var m=this,v=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(w){return w},function(w){return p.StringUtilities.format(m.i18n.everyX0Seconds(w),w)},function(w){return m.i18n.secondsX0ThroughX1PastTheMinute()},function(w){return w=="0"?"":parseInt(w)<20?m.i18n.atX0SecondsPastTheMinute(w):m.i18n.atX0SecondsPastTheMinuteGt20()||m.i18n.atX0SecondsPastTheMinute(w)},{min:0,max:59});return v},h.prototype.getMinutesDescription=function(){var m=this,v=this.expressionParts[0],w=this.expressionParts[2],k=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(N){return N},function(N){return p.StringUtilities.format(m.i18n.everyX0Minutes(N),N)},function(N){return m.i18n.minutesX0ThroughX1PastTheHour()},function(N){var A,_;try{return N=="0"&&w.indexOf("/")==-1&&v==""?m.i18n.everyHour():N=="0"?((_=(A=m.i18n).onTheHour)===null||_===void 0?void 0:_.call(A))||m.i18n.atX0MinutesPastTheHour(N):parseInt(N)<20?m.i18n.atX0MinutesPastTheHour(N):m.i18n.atX0MinutesPastTheHourGt20()||m.i18n.atX0MinutesPastTheHour(N)}catch{return m.i18n.atX0MinutesPastTheHour(N)}},{min:0,max:59});return k},h.prototype.getHoursDescription=function(){var m=this,v=this.expressionParts[2],w=0,k=[];v.split("/")[0].split(",").forEach(function(_){var S=_.split("-");S.length===2&&k.push({value:S[1],index:w+1}),w+=S.length});var N=0,A=this.getSegmentDescription(v,this.i18n.everyHour(),function(_){var S=k.find(function(T){return T.value===_&&T.index===N}),E=S&&m.expressionParts[1]!=="0";return N++,E?m.formatTime(_,"59",""):m.formatTime(_,"0","")},function(_){return p.StringUtilities.format(m.i18n.everyX0Hours(_),_)},function(_){return m.i18n.betweenX0AndX1()},function(_){return m.i18n.atX0()},{min:0,max:23});return A},h.prototype.getDayOfWeekDescription=function(){var m=this,v=this.i18n.daysOfTheWeek(),w=null;return this.expressionParts[5]=="*"?w="":w=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(k,N){var A=k;k.indexOf("#")>-1?A=k.substring(0,k.indexOf("#")):k.indexOf("L")>-1&&(A=A.replace("L",""));var _=parseInt(A),S=m.i18n.daysOfTheWeekInCase?m.i18n.daysOfTheWeekInCase(N)[_]:v[_];if(k.indexOf("#")>-1){var E=null,T=k.substring(k.indexOf("#")+1),C=k.substring(0,k.indexOf("#"));switch(T){case"1":E=m.i18n.first(C);break;case"2":E=m.i18n.second(C);break;case"3":E=m.i18n.third(C);break;case"4":E=m.i18n.fourth(C);break;case"5":E=m.i18n.fifth(C);break}S=E+" "+S}return S},function(k){return parseInt(k)==1?"":p.StringUtilities.format(m.i18n.commaEveryX0DaysOfTheWeek(k),k)},function(k){var N=k.substring(0,k.indexOf("-")),A=m.expressionParts[3]!="*";return A?m.i18n.commaAndX0ThroughX1(N):m.i18n.commaX0ThroughX1(N)},function(k){var N=null;if(k.indexOf("#")>-1){var A=k.substring(k.indexOf("#")+1),_=k.substring(0,k.indexOf("#"));N=m.i18n.commaOnThe(A,_).trim()+m.i18n.spaceX0OfTheMonth()}else if(k.indexOf("L")>-1)N=m.i18n.commaOnTheLastX0OfTheMonth(k.replace("L",""));else{var S=m.expressionParts[3]!="*";S?m.options.logicalAndDayFields?N=m.i18n.commaOnlyOnX0(k):N=m.i18n.commaAndOnX0():N=m.i18n.commaOnlyOnX0(k)}return N}),w},h.prototype.getMonthDescription=function(){var m=this,v=this.i18n.monthsOfTheYear(),w=this.getSegmentDescription(this.expressionParts[4],"",function(k,N){return N&&m.i18n.monthsOfTheYearInCase?m.i18n.monthsOfTheYearInCase(N)[parseInt(k)-1]:v[parseInt(k)-1]},function(k){return parseInt(k)==1?"":p.StringUtilities.format(m.i18n.commaEveryX0Months(k),k)},function(k){return m.i18n.commaMonthX0ThroughMonthX1()||m.i18n.commaX0ThroughX1()},function(k){return m.i18n.commaOnlyInMonthX0?m.i18n.commaOnlyInMonthX0():m.i18n.commaOnlyInX0()});return w},h.prototype.getDayOfMonthDescription=function(){var m=this,v,w,k,N,A=null,_=this.expressionParts[3];switch(_){case"L":A=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":A=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var S=_.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(S){var E=parseInt(S[1]||S[2]),T=E==1?this.i18n.firstWeekday():p.StringUtilities.format(this.i18n.weekdayNearestDayX0(),E.toString()),C=S[4];C?S[3]=="-"?A=p.StringUtilities.format(((w=(v=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||w===void 0?void 0:w.call(v,C))||", %s days before the %s of the month",C,T):A=p.StringUtilities.format(((N=(k=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||N===void 0?void 0:N.call(k,C))||", %s days after the %s of the month",C,T):A=p.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),T);break}else{var R=_.match(/L-(\d{1,2})/);if(R){var D=R[1];A=p.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(D),D);break}else{if(_=="*"&&this.expressionParts[5]!="*")return"";A=this.getSegmentDescription(_,this.i18n.commaEveryDay(),function(L){return L=="L"?m.i18n.lastDay():m.i18n.dayX0?p.StringUtilities.format(m.i18n.dayX0(),L):L},function(L){return L=="1"?m.i18n.commaEveryDay():m.i18n.commaEveryX0Days(L)},function(L){return m.i18n.commaBetweenDayX0AndX1OfTheMonth(L)},function(L){return m.i18n.commaOnDayX0OfTheMonth(L)})}break}}return A},h.prototype.getYearDescription=function(){var m=this,v=this.getSegmentDescription(this.expressionParts[6],"",function(w){return/^\d+$/.test(w)?new Date(parseInt(w),1).getFullYear().toString():w},function(w){return p.StringUtilities.format(m.i18n.commaEveryX0Years(w),w)},function(w){return m.i18n.commaYearX0ThroughYearX1()||m.i18n.commaX0ThroughX1()},function(w){return m.i18n.commaOnlyInYearX0?m.i18n.commaOnlyInYearX0():m.i18n.commaOnlyInX0()});return v},h.prototype.getSegmentDescription=function(m,v,w,k,N,A,_){var S=null,E=m.indexOf("/")>-1,T=m.indexOf("-")>-1,C=m.indexOf(",")>-1;if(!m)S="";else if(m==="*")S=v;else if(!E&&!T&&!C)S=p.StringUtilities.format(A(m),w(m));else if(C){for(var R=m.split(","),D="",L=this.i18n.spaceAnd(),O=0;O<R.length;O++)if(O>0&&R.length>2&&(D+=",",O<R.length-1&&(D+=" ")),O>0&&R.length>1&&(O==R.length-1||R.length==2)&&(D+=L==","&&R.length>2?" ":"".concat(L," ")),R[O].indexOf("/")>-1||R[O].indexOf("-")>-1){var I=R[O].indexOf("-")>-1&&R[O].indexOf("/")==-1,W=this.getSegmentDescription(R[O],v,w,k,I?this.i18n.commaX0ThroughX1:N,A);I?W=W.replace(", ",""):O>0&&W.startsWith(", ")&&(W=W.substring(2)),D+=W}else if(!E)D+=w(R[O]);else{var U=this.getSegmentDescription(R[O],v,w,k,N,A);O>0&&U&&U.startsWith(", ")&&(U=U.substring(2)),D+=U}E?S=D:S=p.StringUtilities.format(A(m),D)}else if(E){var R=m.split("/");if(S=p.StringUtilities.format(k(R[1]),R[1]),R[0].indexOf("-")>-1){var J=this.generateRangeSegmentDescription(R[0],N,w);J.indexOf(", ")!=0&&(S+=", "),S+=J}else if(R[0].indexOf("*")==-1){var F=p.StringUtilities.format(A(R[0]),w(R[0]));F=F.replace(", ",""),S+=p.StringUtilities.format(this.i18n.commaStartingX0(),F)}S+=this.getWrappingIncrementDescription(m,_,v,w,k,N,A)}else T&&(S=this.generateRangeSegmentDescription(m,N,w));return S},h.prototype.getWrappingIncrementDescription=function(m,v,w,k,N,A,_){if(!this.options.verbose||!v)return"";var S=m.split("/"),E=S[0],T=S[1],C=parseInt(T),R=v.max-v.min+1,D=E==="*",L=Number.isInteger(C)&&C>1,O=L&&R%C===0;if(!D||!L||O)return"";for(var I=[],W=v.min;W<=v.max;W+=C)I.push(W);if(I.length<2)return"";var U=this.getSegmentDescription(I.join(","),w,k,N,A,_);return U?", ".concat(U):""},h.prototype.generateRangeSegmentDescription=function(m,v,w){var k="",N=m.split("-"),A=w(N[0],1),_=w(N[1],2),S=v(m);return k+=p.StringUtilities.format(S,A,_),k},h.prototype.formatTime=function(m,v,w){var k=0,N=0,A=parseInt(m)+k,_=parseInt(v)+N;_>=60?(_-=60,A+=1):_<0&&(_+=60,A-=1),A>=24?A=A-24:A<0&&(A=24+A);var S="",E=!1;this.options.use24HourTimeFormat||(E=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),S=E?"".concat(this.getPeriod(A)," "):" ".concat(this.getPeriod(A)),A>12&&(A-=12),A===0&&(A=12));var T="";w&&(T=":".concat(("00"+w).substring(w.length)));var C=A.toString(),R=("00"+C).substring(C.length),D=_.toString(),L=("00"+D).substring(D.length),O=this.options.trimHoursLeadingZero?C:R;return"".concat(E?S:"").concat(O,":").concat(L).concat(T).concat(E?"":S)},h.prototype.transformVerbosity=function(m,v){if(!v&&(m=m.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),m=m.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),m=m.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),m=m.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var w=0,k=Object.entries(this.i18n.conciseVerbosityReplacements());w<k.length;w++){var N=k[w],A=N[0],_=N[1];m=m.replace(new RegExp(A,"g"),_)}return m},h.prototype.getPeriod=function(m){return m>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},h.locales={},h})();u.ExpressionDescriptor=y},3747(c,u,d){Object.defineProperty(u,"__esModule",{value:!0}),u.enLocaleLoader=void 0;var p=d(9486),g=(function(){function y(){}return y.prototype.load=function(h){h.en=new p.en},y})();u.enLocaleLoader=g},9486(c,u){Object.defineProperty(u,"__esModule",{value:!0}),u.en=void 0;var d=function(g){return Number(g)===1},p=(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 d(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 d(y)?"at %s second past the minute":"at %s seconds past the minute"},g.prototype.everyX0Minutes=function(y){return d(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 d(y)?"at %s minute past the hour":"at %s minutes past the hour"},g.prototype.everyX0Hours=function(y){return d(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 d(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 d(y)?", %s day before the %s of the month":", %s days before the %s of the month"},g.prototype.commaDaysAfterTheX0OfTheMonth=function(y){return d(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 d(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})();u.en=p},9515(c,u){Object.defineProperty(u,"__esModule",{value:!0});function d(y,h){if(!y)throw new Error(h)}function p(y){var h=[];if(!isNaN(parseInt(y,10))){h.push(parseInt(y,10));var m=y.match(/^\d+-(-?\d+)/);m&&h.push(parseInt(m[1],10))}return h}var g=(function(){function y(){}return y.stepRange=function(h){for(var m=h.split(","),v=0;v<m.length;v++){var w=m[v].split("/")[1];d(w===void 0||!/^0+$/.test(w),"step value must be greater than 0")}},y.secondRange=function(h){for(var m=h.split(","),v=0;v<m.length;v++)for(var w=0,k=p(m[v]);w<k.length;w++){var N=k[w];d(N>=0&&N<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(h){for(var m=h.split(","),v=0;v<m.length;v++)for(var w=0,k=p(m[v]);w<k.length;w++){var N=k[w];d(N>=0&&N<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(h){for(var m=h.split(","),v=0;v<m.length;v++)for(var w=0,k=p(m[v]);w<k.length;w++){var N=k[w];d(N>=0&&N<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(h){for(var m=h.split(","),v=0;v<m.length;v++)for(var w=0,k=p(m[v]);w<k.length;w++){var N=k[w];d(N>=1&&N<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(h,m){for(var v=h.split(","),w=0;w<v.length;w++)for(var k=0,N=p(v[w]);k<N.length;k++){var A=N[k];d(A>=1&&A<=12,m?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(h,m){for(var v=h.split(","),w=0;w<v.length;w++){if(v[w].indexOf("#")>-1){var k=v[w].substring(v[w].indexOf("#")+1);d(/^[1-5]$/.test(k),"DOW nth weekday must be >= 1 and <= 5")}for(var N=0,A=p(v[w]);N<A.length;N++){var _=A[N];d(_>=0&&_<=6,m?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},y})();u.default=g},1823(c,u){Object.defineProperty(u,"__esModule",{value:!0}),u.StringUtilities=void 0;var d=(function(){function p(){}return p.format=function(g){for(var y=[],h=1;h<arguments.length;h++)y[h-1]=arguments[h];return g.replace(/%s/g,function(m){return y.shift()})},p.containsAny=function(g,y){return y.some(function(h){return g.indexOf(h)>-1})},p})();u.StringUtilities=d}},r={};function a(c){var u=r[c];if(u!==void 0)return u.exports;var d=r[c]={exports:{}};return s[c](d,d.exports,a),d.exports}var l={};return(()=>{var c=l;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var u=a(8333),d=a(3747);u.ExpressionDescriptor.initialize(new d.enLocaleLoader),c.default=u.ExpressionDescriptor;var p=u.ExpressionDescriptor.toString;c.toString=p})(),l})())})(Xp)),Xp.exports}var aL=oL();const iL=$k(aL),ni=(e,t)=>t&&e===Fh(t)?t:bL(e),Li=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",YN=(e="")=>({name:"",kind:"cron",cron:"",timezone:Li(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),XN={seconds:1,minutes:60,hours:3600};function QN(e){const[t,s]=e%3600===0?[e/3600,"hour"]:e%60===0?[e/60,"minute"]:[e,"second"];return t===1?s:`${t} ${s}s`}function JN(e){try{return iL.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Jo=e=>String(e).padStart(2,"0"),qd=(e,t)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:t});function ZN(e,t){const s=l=>{var c;return((c=new Intl.DateTimeFormat(l,{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(u=>u.type==="timeZoneName"))==null?void 0:c.value)??t},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const a=s("en-GB");return/^GMT[+-]/.test(a)?r:a}const c0=(e,t)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:t}).replace(",","")}, ${qd(s,t)} ${ZN(s,t)}`};function u0(e,{zone:t=Li(),now:s=Date.now()}={}){const r=new Date(e),a=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:t});return`Pick a time in the future: ${a(r)===a(new Date(s))?`${qd(r,t)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:t})}, ${qd(r,t)} ${ZN(r,t)}`} has already passed.`}function Vd(e,t){const s={};for(const{type:r,value:a}of new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(e))s[r]=a;return Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),Number(s.hour),Number(s.minute))}function lL(e,t,s,r){const a=new Date(Vd(e,t)),l=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),s,r);let c=l;for(let u=0;u<2;u++)c+=l-Vd(new Date(c),t);return new Date(c)}const cL=e=>{const t=e.trim().split(/\s+/);return t.length!==5||!/^\d{1,2}$/.test(t[0])||!/^\d{1,2}$/.test(t[1])?null:{minute:Number(t[0]),hour:Number(t[1]),days:t.slice(2).some(s=>s!=="*"&&s!=="?")}};function uL(e,t,s,r,a){const l=JN(e),c=t!==s,u=cL(e),d=u&&`At ${Jo(u.hour)}:${Jo(u.minute)}`;if(u&&d&&l.startsWith(d))try{const p=r??lL(a,t,u.hour,u.minute),g=u.days?Math.floor(Vd(p,s)/864e5)-Math.floor(Vd(p,t)/864e5):0,y=g>0?" the next day":g<0?" the day before":"";return`At ${qd(p,s)} your time${y}${c?` (${d.slice(3)} ${t})`:""}${l.slice(d.length)}`}catch{}return`${l}${c?` (${t})`:""}`}function mx(e,t,{zone:s=Li(),instead:r,now:a=Date.now()}={}){const l=r?` · ${r}`:t?` · next ${c0(t,s)}`:" · no next time";return"cron"in e?`${uL(e.cron,e.timezone,s,t?new Date(t):null,new Date(a))}${l}`:"at"in e?`Once, ${c0(e.at,s)}${!r&&t&&Date.parse(t)===Date.parse(e.at)?"":l}`:`Every ${QN(e.every_s)}${l}`}const Pi=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,dL=e=>`${Pi(e)} a run`,fL=(e,t)=>typeof e=="number"?dL(e):typeof t=="number"&&t>0?`Agent's default (${Pi(t)})`:"Agent's default";function px(e,t,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>t)return null;const a=[e.last_firing,...s].find(l=>l&&l.status==="started"&&Date.parse(l.nominal_at)===r);return a?{ran:a}:{passed:e.source.at}}const hx=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",mL=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",pL=e=>e.source.kind==="github"&&e.target.kind==="start_run",eS=[{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"}],nc=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,gx="This server's address as this page sees it: behind a proxy, use its public address.",Dh={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)",composio:"Composio's (webhook-signature, keyed by its secret as given)"},hL=e=>"in"in e?`${e.pointer} is one of ${e.in.map(t=>JSON.stringify(t)).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"is there":"is absent"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,Kd=(e,t=!0)=>{var s,r;return`${e.event}${(s=e.actions)!=null&&s.length?` (${e.actions.join(", ")})`:""}${t&&((r=e.where)!=null&&r.length)?` where ${e.where.map(hL).join(" and ")}`:""}`},tS=e=>{var t;return(t=e.accept)!=null&&t.length?`Only signed requests for ${e.accept.map(s=>Kd(s,!1)).join(" or ")}`:"On each signed request"},gL={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event"},nS=e=>`On GitHub ${e.accept.map(t=>Kd(t,!1)).join(" or ")}`;function Yd(e,t){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}`:t?`Turned off after ${t} failures in a row.`:"Turned off after failures in a row.":null}function sS(e){var s;const t=(r,a)=>a?`${r}: ${a}`:r;switch(e.status){case"started":return"Started";case"skipped":return t("Skipped",e.reason);case"missed":return t(`Missed ${e.count??1} ${e.count===1||e.count===void 0?"time":"times"}`,e.reason);case"failed":return t("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 ${Cf(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const xL={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},yL=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function bL(e){if(!yL.test(e))return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString().replace(/\.\d{3}Z$/,"Z")}function Fh(e){const t=new Date(e);return`${t.getFullYear()}-${Jo(t.getMonth()+1)}-${Jo(t.getDate())}T${Jo(t.getHours())}:${Jo(t.getMinutes())}${t.getSeconds()?`:${Jo(t.getSeconds())}`:""}`}const d0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function vL(e){const t=QN(e);return/^\d/.test(t)?`At least ${t}.`:`At least ${t==="hour"?"an":"a"} ${t}.`}const Uh="A number is needed.",Wh=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function f0(e,t=!1){var l,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()||Li()};else if(e.kind==="at"){const u=ni(e.at,(l=e.read)==null?void 0:l.at);u===null&&(s["source.at"]="A time is needed."),r={kind:"schedule",at:u??""}}else{const u=Wh(e.every);e.every.trim()?u===void 0&&(s["source.every_s"]=Uh):s["source.every_s"]="A number is needed.";const d=e.startAt?ni(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((u??0)*XN[e.everyUnit]),...d?{start_at:d}:{}}}e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const a=Wh(e.maxCost);return e.maxCost.trim()?a===void 0&&(s["target.max_cost_usd"]=Uh):t||(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},...a!==void 0?{max_cost_usd:a}:{}}}}}const wL=()=>({name:"",signature:"standard",agentId:"",content:"",maxCost:""});function kL(e,t=!1){return rS(e,{kind:"webhook",signature:e.signature},{},t,"a webhook")}const jL=()=>({name:"",events:["pull_request:opened"],agentId:"",content:"",maxCost:""});function NL(e,t=!1){const s=[];for(const{event:r,action:a}of eS.filter(l=>e.events.includes(`${l.event}:${l.action}`))){const l=s.find(c=>c.event===r);l?l.actions.push(a):s.push({event:r,actions:[a]})}return rS(e,{kind:"github",accept:s},s.length?{}:{"source.accept":"Pick at least one event."},t,"a GitHub trigger")}function rS(e,t,s,r,a){e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const l=Wh(e.maxCost);return e.maxCost.trim()?l===void 0&&(s["target.max_cost_usd"]=Uh):r||(s["target.max_cost_usd"]=`A cost cap is needed: every run ${a} starts is capped.`),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},source:t,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...l!==void 0?{max_cost_usd:l}:{}}}}}function SL(e){const t=e.source,s="cron"in t?t.timezone:Li(),r={...YN(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 t)return{...r,kind:"cron",cron:t.cron};if("at"in t)return{...r,kind:"at",at:Fh(t.at),read:{at:t.at}};const a=t.every_s%3600===0?"hours":t.every_s%60===0?"minutes":"seconds";return{...r,kind:"every",every:String(t.every_s/XN[a]),everyUnit:a,startAt:Fh(t.start_at),read:{startAt:t.start_at}}}const Hh=(e,t)=>{if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const[s,r]=[Object.keys(e),Object.keys(t)];return s.length===r.length&&s.every(a=>Hh(e[a],t[a]))};function m0(e,t){const s=t.source&&"every_s"in t.source&&!t.source.start_at&&"every_s"in e.source?{...t.source,start_at:e.source.start_at}:t.source,r=t.target&&{...t.target,input:{...e.target.input,...t.target.input},...e.target.effort!==void 0&&t.target.effort===void 0?{effort:e.target.effort}:{}};return{...t.name!==void 0&&t.name!==e.name?{name:t.name}:{},...s&&!Hh(s,e.source)?{source:s}:{},...r&&!Hh(r,e.target)?{target:r}:{}}}const _L=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function xx(e){var r;if(!(e instanceof Pe))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 t={},s=[];for(const a of e.fields){const l=a.field.startsWith("target.input")?"target.input":a.field;_L.includes(l)&&!t[l]?t[l]=a.message:s.push(a.message)}return{fields:t,rest:s}}const $L=[{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"}],EL=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),CL=Array.from({length:31},(e,t)=>({value:String(t+1),label:String(t+1)})),TL=Array.from({length:60},(e,t)=>({value:String(t),label:`:${String(t).padStart(2,"0")}`}));function oS({value:e,onChange:t,label:s,name:r}){const a=eL(e),[l,c]=x.useState(()=>e.trim()!==""&&!a),u=x.useId(),d=l||e.trim()!==""&&!a,p=h=>t(tL(h)),g=h=>{if(h==="custom"){c(!0);return}c(!1),p(nL(h,a))},y=a&&"at"in a?a.at:null;return n.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(Lt,{label:s,className:"min-w-56 flex-1",value:d?"custom":(a==null?void 0:a.kind)??"",onChange:g,placeholder:"Pick when it runs",options:$L}),!d&&(a==null?void 0:a.kind)==="weekly"&&n.jsx(Lt,{id:`${u}-day`,label:"Day of the week",className:"w-40",value:String(a.day),onChange:h=>p({...a,day:Number(h)}),options:EL}),!d&&(a==null?void 0:a.kind)==="monthly"&&n.jsx(Lt,{id:`${u}-date`,label:"Day of the month",className:"w-24",value:String(a.date),onChange:h=>p({...a,date:Number(h)}),options:CL}),!d&&(a==null?void 0:a.kind)==="hourly"&&n.jsx(Lt,{id:`${u}-minute`,label:"Minutes past the hour",className:"w-24",value:String(a.minute),onChange:h=>p({...a,minute:Number(h)}),options:TL}),!d&&a&&y&&n.jsx(Be,{id:`${u}-at`,type:"time","aria-label":"At",className:"w-32",value:sL(y),onChange:h=>{const m=rL(h.target.value);m&&p({...a,at:m})}})]}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Be,{id:`${u}-line`,name:r,"aria-label":"Custom schedule",value:e,onChange:h=>t(h.target.value),placeholder:"30 1 * * *",spellCheck:!1}),n.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?JN(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const p0=Intl.supportedValuesOf,Ju=typeof p0=="function"?p0("timeZone"):[],Zu=Ju.length&&!Ju.includes("UTC")?["UTC",...Ju]:Ju;function aS({value:e,onChange:t,label:s,name:r,id:a,className:l}){if(!Zu.length)return n.jsx(Be,{id:a,name:r,"aria-label":s,className:l,value:e,onChange:u=>t(u.target.value),placeholder:"Europe/Madrid"});const c=e&&!Zu.includes(e)?[e,...Zu]:Zu;return n.jsx(Lt,{id:a,name:r,label:s,className:l,value:e,onChange:t,placeholder:"Pick a time zone",options:c.map(u=>({value:u,label:u.replace(/_/g," ")}))})}function Of(){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 t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function er(e=Of){let t=null;return{keyFor(s,r){const a=JSON.stringify([s,r]);return(t==null?void 0:t.request)!==a&&(t={request:a,key:e()}),t.key},done(){t=null}}}async function iS(e,t,s,r){const a=await r(t,s,e.keyFor(t,{content:s}));return e.done(),a}function RL(e=Of){const t=new Map;return s=>{let r=t.get(s);return r||(r=er(e),t.set(s,r)),r}}function lS(e,t){const s=new Set(e.map(r=>r.run_id));return[...e,...t.filter(r=>!s.has(r.run_id))]}function cS(e,t){var l,c,u;let s;if(e==="agentic"&&t.json)try{s=JSON.parse(t.text)}catch{return{ok:!1,field:"input",message:"The agent's input is JSON: this is not."}}else if(e==="agentic"&&t.typed){if(t.typed.contentRequired&&!t.text.trim())return{ok:!1,field:"input",message:"Write the run's message."};s={...t.text.trim()?{content:t.text}:{},...t.typed.fields}}else if(e==="agentic"){if(!t.text.trim())return{ok:!1,field:"input",message:"Write the run's first message."};s={content:t.text}}else try{s=JSON.parse(t.text)}catch{return{ok:!1,field:"input",message:"The workflow's input is JSON: this is not."}}const r={input:s};if(t.revision&&(r.revision=t.revision),t.effort&&(r.effort=t.effort),e==="agentic"&&((l=t.maxCostUsd)!=null&&l.trim())){const d=Number(t.maxCostUsd);if(!Number.isFinite(d)||d<=0)return{ok:!1,field:"max_cost_usd",message:"A spend cap is a positive number of dollars."};r.max_cost_usd=d}(c=t.fileIds)!=null&&c.length&&(r.file_ids=[...t.fileIds]);const a=e==="agentic"?(u=t.repo)==null?void 0:u.trim():void 0;if(a){if(!/^[^/\s]+\/[^/\s]+$/.test(a))return{ok:!1,field:"repo",message:"A repository is owner/name, like Parcha-ai/agentrun."};r.repo=a}return{ok:!0,body:r}}function AL(e,t){return s=>{var a,l,c,u;const r=new Set;for(;s!=null&&s.$ref&&!r.has(s.$ref);){r.add(s.$ref);const d=(l=(a=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref))==null?void 0:a[1])==null?void 0:l.replace(/~1/g,"/").replace(/~0/g,"~"),p=d===void 0?void 0:((c=e.definitions)==null?void 0:c[d])??((u=e.$defs)==null?void 0:u[d])??(Object.hasOwn(t,d)?t[d]:void 0);if(!p)break;s=p}return s}}function uS(e,t,s="workflow"){if(e.from==="example")return`The ${s}'s example input. Edit it, then ${t}.`;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 ${t}.${r}`}function dS(e){var r,a;const t=e,s=(r=t==null?void 0:t.input)!=null&&r.schemaId?(a=t.schemas)==null?void 0:a[t.input.schemaId]:void 0;return s?fS(s,(t==null?void 0:t.schemas)??{}):null}function fS(e,t={}){var d;const s=AL(e,t),r=s(e),a=Object.entries(r.properties??{}).map(([p,g])=>{const y=s(g);return{name:p,...y!=null&&y.description?{note:y.description}:{}}}),l=((d=r.examples)==null?void 0:d[0])??r.default;if(l!==void 0)return{text:JSON.stringify(l,null,2),from:"example",fields:a,optional:[]};const c=(p,g=0)=>{var m,v;const y=s(p);if(!y||g>4)return null;if((m=y.examples)!=null&&m.length)return y.examples[0];if(y.default!==void 0)return y.default;if((v=y.enum)!=null&&v.length)return y.enum[0];const h=Array.isArray(y.type)?y.type[0]:y.type;return h==="object"||y.properties?Object.fromEntries(Object.entries(y.properties??{}).filter(([w])=>(y.required??[]).includes(w)).map(([w,k])=>[w,c(k,g+1)])):h==="array"?[]:h==="string"?"":h==="number"||h==="integer"?0:h==="boolean"?!1:null},u=new Set(r.required??[]);return{text:JSON.stringify(c(r),null,2),from:"shape",fields:a,optional:a.map(p=>p.name).filter(p=>!u.has(p))}}const Qp=e=>`'${e.replace(/'/g,"'\\''")}'`;function OL(e,t,s,r){return[`curl -X POST ${Qp(`${e}/v2/agents/${t?encodeURIComponent(t):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${Qp(`Idempotency-Key: ${r}`)} \\`,` -d ${Qp(JSON.stringify(s))}`].join(`
547
+ `)}const ML=e=>e>=200&&e<300;async function mS(e,t,s,r){const a=await r(t,s,e.keyFor(t,s));return ML(a.status)&&e.done(),a}const sc=(e,t={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(t,r)?bx(t[r]).join(", "):"")||"…"),pS=e=>`#/templates/${encodeURIComponent(e)}`,LL=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function yx(e,{secrets:t=!0,mcp:s=!0}={}){var a,l;const r=[];return t&&e.secrets.length&&r.push(["Keys",e.secrets.join(", ")]),s&&e.mcp.length&&r.push(["MCP",e.mcp.map(c=>`${c.toolkit} (${Sc[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",LL(e.triggers.length,"trigger")]),(a=e.budget)!=null&&a.per_run_usd&&r.push(["Budget",`${wo(e.budget.per_run_usd)} a run`]),(l=e.harness)!=null&&l.length&&r.push(["Harness",e.harness.join(", ")]),e.model&&r.push(["Model",`${e.model.tier}${e.model.prefer?`, ${e.model.prefer} first`:""}`]),r}function $c(e){var s;if(e.type==="boolean"||e.array)return null;if((s=e.enum)!=null&&s.length)return e.enum.map(String);const t=e.pattern?/^\^\(([A-Za-z0-9_-]+(?:\|[A-Za-z0-9_-]+)+)\)\$$/.exec(e.pattern):null;return t?t[1].split("|"):null}function PL(e){return Object.fromEntries(Object.entries(e).flatMap(([t,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[t,String(s.default)]]:[]:$c(s)?[]:s.format==="timezone"?[[t,Li()]]:s.format==="cron"?typeof s.default=="string"?[[t,s.default]]:[]:[]))}const IL=(e,t)=>t.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function zL(e){const t=encodeURIComponent(e.toolkit);return e.source==="composio"?`#/settings/mcp?add=${t}&preset=composio&toolkit=${t}&tools=${e.tools.map(s=>encodeURIComponent(s.name)).join(",")}`:e.source==="github"?"#/settings/mcp?add=github&auth=github_app":`#/settings/mcp?add=${t}`}const DL=(e,t)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>t.has(s)),FL=(e,t)=>e.filter(s=>s.field===t);function rc(e){if(e.type!=="string"||e.format!=="cron"&&e.format!=="timezone"||!e.description)return e.description;if(e.format==="timezone")return;const t=e.description.indexOf(": ");return t<0?void 0:e.description.slice(t+2).trim()||void 0}function UL(e){const t=$c(e);if(!t)return null;const s=e.default===void 0?void 0:String(e.default);return[{value:"",label:e.required?"Choose one":"None chosen"},...t.map(r=>({value:r,label:r===s?`${r} (default)`:r}))]}function WL(e,t,s,r=t){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: ${hS(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const hS=e=>{var t;return(t=e.enum)!=null&&t.length?e.enum.map(String):$c(e)??[]};function gS(e,t){var c;if(e.array){const u=bx(t);return u.length?u.every(d=>gS({...e,array:!1,required:!0},d)):!e.required}if(t==="")return!e.required;const s=$c(e);if(s)return s.includes(t);const r=Number(t),a=(e.minimum===void 0||r>=e.minimum)&&(e.maximum===void 0||r<=e.maximum);if(e.type==="integer")return t.trim()!==""&&Number.isSafeInteger(r)&&a;if(e.type==="number")return t.trim()!==""&&Number.isFinite(r)&&a;if(e.type==="boolean")return(t==="true"||t==="false")&&(!((c=e.enum)!=null&&c.length)||hS(e).includes(t));const l=[...t].length;if(e.minLength!==void 0&&l<e.minLength||e.maxLength!==void 0&&l>e.maxLength)return!1;if(e.pattern)try{return new RegExp(e.pattern,"u").test(t)}catch{return!0}return!0}const bx=e=>(e??"").split(`
548
+ `).map(t=>t.trim()).filter(t=>t!==""),vx=gS,sa=e=>!!e&&typeof e=="object"&&!Array.isArray(e),HL=new Set(["string","number","integer","boolean"]),BL=["oneOf","anyOf","allOf","not","if","$ref","const"],Bh=e=>BL.some(t=>t in e),ed=e=>typeof e=="string"?e:void 0,td=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,GL=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0));function qL(e,t){if(!sa(e)||Bh(e))return null;const s=e.type==="array",r=s?e.items:e;if(!sa(r)||Bh(r)||typeof r.type!="string"||!HL.has(r.type))return null;const a=Array.isArray(r.enum)&&r.enum.every(l=>["string","number","boolean"].includes(typeof l))?r.enum:void 0;return GL({type:r.type,...s?{array:!0}:{},required:t,title:ed(e.title),description:ed(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:a,pattern:ed(r.pattern),format:ed(r.format),minimum:td(r.minimum),maximum:td(r.maximum),minLength:td(r.minLength),maxLength:td(r.maxLength)})}function wx(e,t){const s=sa(e)&&sa(e.properties)?e.properties:{},r=sa(e)&&Array.isArray(e.required)?e.required:[],a=[];for(const[l,c]of Object.entries(s)){if(l===t)continue;const u=qL(c,r.includes(l));if(!u)return null;a.push([l,u])}return a}function xS(e){if(!sa(e))return{kind:"message"};const t=()=>({kind:"json",example:fS(e)});if(Bh(e))return t();const s=sa(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(l=>typeof l=="string"):[];if(r.some(l=>l!=="content"&&!Object.hasOwn(s,l)))return t();const a=wx(e,"content");return a?a.length?{kind:"fields",form:{fields:a,contentRequired:r.includes("content")||!r.some(l=>l!=="content")}}:{kind:"message"}:t()}const Ec=(e,t)=>t.title||e;function VL(e){var s;const t=(s=e.examples)!=null&&s.length?e.examples[0]:e.default;if(t!=null)return Array.isArray(t)?t.map(String).join(`
549
+ `):typeof t=="object"?JSON.stringify(t):String(t)}function KL(e,t){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=bx(t);return r.length?r.map(s):e.required?[]:void 0}return e.type==="boolean"?t==="true"||t==="false"?t==="true":e.required?!1:void 0:t===void 0||t===""?e.required&&e.type==="string"?"":void 0:s(t)}function kx(e){const t=PL(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const a=r.array?null:$c(r);a&&r.default!==void 0&&a.includes(String(r.default))&&(t[s]=String(r.default))}return t}function Mf(e,t){const s={};for(const[r,a]of e.fields){const l=KL(a,t[r]);l!==void 0&&(s[r]=l)}return s}const YL=(e,t,s)=>({...t.trim()?{content:t}:{},...Mf(e,s)}),Xd=(e,t="input")=>e.startsWith(`${t}.`)?e.slice(t.length+1).split(".")[0]:null,yS=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",XL={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},QL=e=>e.array?`a list of ${XL[e.type]}`:yS(e);function jx(e,t,s){var a;const r=Ec(t,s);return s.array&&e.reason==="wrong_type"?e.field.endsWith(`.${t}`)?`${r} takes a list, one item a line.`:`Each line of ${r} is ${yS(s)}.`:s.array&&e.reason==="not_an_option"&&((a=s.enum)!=null&&a.length)?`Each line of ${r} is one of: ${s.enum.map(String).join(", ")}.`:WL(e,t,s,r)}const JL={date:"date",email:"email",uri:"url"};function Nx({field:e,label:t,help:s,value:r,onChange:a}){const l=VL(e),c=UL(e);return n.jsxs("label",{className:"block",children:[n.jsxs("span",{className:"caps text-small font-semibold",children:[t,e.required&&n.jsx("span",{className:"text-destructive-text",children:" *"})]}),n.jsxs("span",{className:"mb-1.5 block text-small text-muted-foreground",children:[s,e.array&&n.jsxs(n.Fragment,{children:[s?" ":"","One a line."]})]}),c?n.jsx(Lt,{label:t,className:"w-full",value:r,onChange:a,options:c}):e.array?n.jsx(ds,{rows:3,value:r,required:e.required,placeholder:l,onChange:u=>a(u.target.value),className:"resize-y leading-[1.6]"}):e.format==="cron"&&e.type==="string"?n.jsx(oS,{label:t,value:r,onChange:a}):e.format==="timezone"&&e.type==="string"?n.jsx(aS,{label:t,className:"w-full",value:r,onChange:a}):e.type==="boolean"?n.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r==="true",onChange:u=>a(u.target.checked?"true":"false")}):n.jsx(Be,{type:e.type==="string"?JL[e.format??""]??"text":"number",step:e.type==="integer"?1:"any",value:r,required:e.required,placeholder:l,min:e.minimum,max:e.maximum,minLength:e.minLength,maxLength:e.maxLength,onChange:u=>a(u.target.value)})]})}function Zo({issues:e,named:t=!1,words:s=r=>r.message}){return e.length?n.jsx("ul",{className:"mt-1.5 space-y-1 text-small text-destructive-text",role:"alert",children:e.map((r,a)=>n.jsxs("li",{children:[t&&n.jsxs("span",{className:"font-mono",children:[r.field," "]}),s(r),r.fix&&n.jsx("span",{className:"block text-foreground/80",children:r.fix})]},`${r.field}:${a}`))}):null}function ZL(e,{base:t="/v2",onProgress:s,signal:r,request:a=()=>new XMLHttpRequest}={}){return new Promise((l,c)=>{if(r!=null&&r.aborted)return c(new Pe(0,"aborted","The upload was stopped."));const u=a();u.open("POST",`${t}/files?path=${encodeURIComponent(e.name)}`),u.setRequestHeader("accept","application/json"),e.type&&u.setRequestHeader("content-type",e.type),u.upload.onprogress=d=>{d.lengthComputable&&d.total>0&&(s==null||s(Math.min(1,d.loaded/d.total)))},u.onload=()=>{let d=null;try{d=JSON.parse(u.responseText)}catch{}if(u.status===201||u.status===200){const y=d==null?void 0:d.file;return y!=null&&y.file_id?(s==null||s(1),l(y)):c(new Pe(u.status,"bad_answer","The server's answer named no file."))}const p=d==null?void 0:d.error,g=new Pe(u.status,(p==null?void 0:p.code)??"http_error",(p==null?void 0:p.message)??`The server answered ${u.status}.`,(p==null?void 0:p.retryable)??!1,p==null?void 0:p.request_id);p!=null&&p.fields&&(g.fields=p.fields),c(g)},u.onerror=()=>c(new Pe(0,"network","The upload did not reach the server.")),u.onabort=()=>c(new Pe(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>u.abort(),{once:!0}),u.send(e)})}const bS=(e,t,s)=>ZL(e,{onProgress:t,signal:s});function Jp(e){if(!(e instanceof Pe))return e instanceof Error?e.message:String(e);const t=(e.fields??[]).filter(s=>s.message!==e.message).map(s=>s.message);return[e.message,...t].join(" ")}function vS({upload:e,remove:t,limits:s,frozen:r=!1}){const[a,l]=x.useState([]),[c,u]=x.useState([]),d=x.useRef(new Map),p=x.useRef(0),g=x.useRef(0);g.current=a.length;const y=x.useRef({items:a,frozen:r,remove:t});y.current={items:a,frozen:r,remove:t};const h=x.useRef(!0);x.useEffect(()=>{h.current=!0;const N=d.current;return()=>{var E;h.current=!1;for(const T of N.values())T.abort();const{items:A,frozen:_,remove:S}=y.current;if(!_)for(const T of A)T.file&&!T.removing&&((E=S==null?void 0:S(T.file.file_id))==null||E.catch(()=>{}))}},[]);const m=x.useCallback(N=>{if(y.current.frozen)return;const A=[],_=s?s.max_files_per_run-g.current:1/0,S=(s==null?void 0:s.max_upload_bytes)??null,E=[];for(const C of N)S!==null&&C.size>S?A.push({text:`${C.name} is ${wi(C.size)}: this server takes files up to ${wi(S)}.`}):E.length>=_?A.push({text:`${C.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):E.push(C);u(A);const T=E.map(C=>({key:`f${p.current++}`,name:C.name,size:C.size,progress:0}));g.current+=T.length,l(C=>[...C,...T]),T.forEach((C,R)=>{const D=new AbortController;d.current.set(C.key,D);const L=O=>{h.current&&l(I=>I.map(W=>W.key===C.key?{...W,...O}:W))};e(E[R],O=>L({progress:O}),D.signal).then(O=>{var I,W,U;if(d.current.delete(C.key),D.signal.aborted){(U=(W=(I=y.current).remove)==null?void 0:W.call(I,O.file_id))==null||U.catch(J=>{h.current&&u(F=>[...F,{text:`${C.name} was sent before it was stopped, and was not removed: ${Jp(J)}`}])});return}L({file:O,progress:1})},O=>{d.current.delete(C.key),!(D.signal.aborted||!h.current)&&(l(I=>I.filter(W=>W.key!==C.key)),u(I=>[...I,{text:`${C.name}: ${Jp(O)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),v=x.useCallback(N=>{var T;const{items:A,frozen:_,remove:S}=y.current,E=A.find(C=>C.key===N);if(!(_||!E||E.removing)){if(!E.file||!S){(T=d.current.get(N))==null||T.abort(),d.current.delete(N),l(C=>C.filter(R=>R.key!==N));return}l(C=>C.map(R=>R.key===N?{...R,removing:!0}:R)),u(C=>C.filter(R=>R.about!==N)),S(E.file.file_id).then(()=>{h.current&&l(C=>C.filter(R=>R.key!==N))},C=>{h.current&&(l(R=>R.map(D=>D.key===N?{...D,removing:!1}:D)),u(R=>[...R,{about:N,text:`${E.name} was not removed: ${Jp(C)}`}]))})}},[]),w=x.useCallback(()=>{y.current={...y.current,items:[]},l([]),u([])},[]),k=a.flatMap(N=>N.file&&!N.removing?[N.file.file_id]:[]);return{items:a,refusals:c.map(N=>N.text),add:m,drop:v,clear:w,fileIds:k,frozen:r,busy:a.some(N=>!N.file||N.removing)}}function Gh({attachments:e,limits:t,disabled:s,compact:r=!1}){const a=x.useRef(null),[l,c]=x.useState(!1),{items:u,refusals:d,add:p,drop:g}=e,y=s||e.frozen,h=t?[`up to ${t.max_files_per_run} files`,...t.max_upload_bytes!==null?[`${wi(t.max_upload_bytes)} each`]:[]].join(", "):"";return n.jsxs("div",{className:ie("border border-dashed px-3 py-2.5",l?"border-primary bg-primary/5":"border-border",r&&"max-sm:border-0 max-sm:p-0"),onDragOver:m=>{y||(m.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:m=>{m.preventDefault(),c(!1),y||p([...m.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(K,{type:"button",size:"sm",onClick:()=>{var m;return(m=a.current)==null?void 0:m.click()},disabled:y,title:r?`Attach files${h?` (${h})`:""}`:void 0,className:ie(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[n.jsx(xE,{"aria-hidden":!0})," ",n.jsx("span",{className:ie(r&&"max-sm:sr-only"),children:"Attach files"})]}),n.jsxs("span",{className:ie("text-small text-muted-foreground",r&&"max-sm:hidden"),children:["or drop them here",h?` (${h})`:"",". The run finds them in inputs/."]}),n.jsx("input",{ref:a,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:m=>{p([...m.target.files??[]]),m.target.value=""}})]}),u.length>0&&n.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:u.map(m=>n.jsxs("li",{className:"flex h-7 items-center gap-2 border bg-card px-2 font-mono text-small",children:[n.jsx("span",{className:"max-w-[16rem] truncate",title:m.name,children:m.name}),n.jsx("span",{className:"text-muted-foreground",children:wi(m.size)}),!m.file&&n.jsxs("span",{className:"text-muted-foreground","aria-label":`${m.name} sent ${Math.round(m.progress*100)}%`,children:[Math.round(m.progress*100),"%"]}),m.removing&&n.jsx("span",{className:"text-muted-foreground",children:"removing"}),n.jsx("button",{type:"button",onClick:()=>g(m.key),disabled:y||m.removing,"aria-label":`Remove ${m.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:n.jsx(fc,{className:"size-3.5","aria-hidden":!0})})]},m.key))}),u.some(m=>!m.file)&&n.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),d.length>0&&n.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:d.map((m,v)=>n.jsx("li",{children:m},`${v}:${m}`))})]})}const eP=["pi","claude-agent","codex","opencode"];function tP(e){const t=new Set,s=r=>{if(Array.isArray(r)){r.forEach(s);return}if(!r||typeof r!="object")return;const a=r;a.node==="call"&&typeof a.tool=="string"&&t.add(a.tool),Object.values(a).forEach(s)};return s(e),[...t].sort()}function nP(e){const t=s=>Array.isArray(s)&&s.every(r=>typeof r=="string")?[...new Set(s)]:[];return{denied:t(e==null?void 0:e.denied),asks:t(e==null?void 0:e.asks)}}function sP(e){return(Array.isArray(e)?e:[]).flatMap(t=>{const s=t;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 Sx="Refused on this server for every agent, whatever the agent's own setting or Never ask.",rP="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.",wS=(e,t,s,r)=>{var u;const a=s==null?void 0:s.find(d=>d.name===e);if(a)return a.permission==="deny"&&a.permission_from==="server";const l=ya(e),c=l?(u=r==null?void 0:r.find(d=>d.name===l.server))==null?void 0:u.tools.find(d=>d.name===l.tool):void 0;return c?c.permission==="deny":t.some(d=>d.name===e&&d.permission==="deny")};function oP(e){return(e??[]).map(({name:t,permission:s,default_permission:r,permissions:a,ask_needs:l})=>({name:t,permission:s,default_permission:r,permissions:a,...l==="password"?{ask_needs:l}:{}}))}const aP={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},kS={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."}}},Qd=(e,t)=>{var s;return(t&&((s=kS[t])==null?void 0:s.label[e]))??aP[e]??e},iP={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."},h0=(e,t)=>{var s;return(t&&((s=kS[t])==null?void 0:s.help[e]))??iP[e]};function jS(e,t){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:Qd(e,t),unavailable:!1}:{text:"not known",unavailable:!1}}function NS(e,t,s,r,a){const{[t]:l,...c}=e,{[s]:u,...d}=l??{},p=r===void 0||r===a?d:{...d,[s]:r};return Object.keys(p).length?{...c,[t]:p}:c}const lP=(e,t,s,r)=>NS(e,t,"provider",s,r),cP=(e,t,s,r)=>NS(e,t,"permission",s,r);function qh(e,t){const s=new Map(t.map(r=>[r.name,r.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([r,a])=>{if(!a||typeof a!="object")return[];const{provider:l,...c}=a,u=l!==void 0&&!(s.has(r)&&l===s.get(r))?{...c,provider:l}:c;return Object.keys(u).length?[[r,u]]:[]}))}function SS(e,t,s){const r={},a=[];for(const[l,c]of Object.entries(e)){if(t&&l!==t&&!l.startsWith(`${t}.`)&&!l.startsWith(`${t}/`))continue;const u=t?l.slice(t.length+1):l,d=[...s].sort((p,g)=>g.length-p.length).find(p=>u===p||u.startsWith(`${p}.`)||u.startsWith(`${p}/`));d?(r[d]??(r[d]=[])).push(c):a.push(c)}return{byTool:r,rest:a}}const uP=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),dP=e=>{if(!Array.isArray(e))return[e];const t=[...new Set(e.filter(s=>s!==null).map(s=>JSON.stringify(s)))].sort();return[...e.includes(null)?[null]:[],...t.map(s=>JSON.parse(s))]},fP=e=>typeof e=="string"?e:JSON.stringify(e);function mP(e){return Object.keys(e).sort().map(t=>{const s=e[t];if(uP(s)){const u=[...new Set(s.keys)].sort();return u.length===1?`${t} may hold only the key ${u[0]} (any value)`:`${t} may hold only the keys ${u.join(", ")} (any values)`}const r=dP(s),a=r[0]===null,l=(a?r.slice(1):r).map(u=>fP(u));if(!l.length)return`${t} must be left out`;const c=l.length===1?l[0]:`one of ${l.join(", ")}`;return`${t} must be ${a?`left out or ${c}`:c}`}).join("; ")}const pP="Calls outside it are refused before they run or ask.",hP="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.";function _S({agentId:e,details:t}){const{denied:s,asks:r}=nP(t),a=[...new Set([...s,...r])];return a.length?n.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[a.map(l=>n.jsxs("a",{href:`#/agents/${encodeURIComponent(e)}/edit?tool=${encodeURIComponent(l)}`,className:"underline underline-offset-4",children:["Set ",l," for this agent"]},l)),n.jsxs("span",{children:["or for every agent: ",n.jsx("a",{href:"#/settings/tools",className:"underline underline-offset-4",children:"Settings → Tools"})]})]}):null}function ur(e){if(Number.isInteger(e))return`$${e}`;for(let t=2;t<8;t++)if(Number(e.toFixed(t))===Number(e.toFixed(8)))return`$${e.toFixed(t)}`;return`$${e.toFixed(8)}`}const $S=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${ur(e.cap_usd)} `:""}spend cap`;function gP({pending:e}){return n.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Paused at its spend cap",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[n.jsx(pg,{className:"size-3.5","aria-hidden":!0})," ",$S(e)]}),typeof e.said=="string"&&n.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:e.said}),n.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 ES=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,CS=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function xP(e){var t,s;return e instanceof Pe?e.status===422?((s=(t=e.fields)==null?void 0:t[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 TS({cap:e,suggested:t,least:s=null,paused:r,onRaise:a}){const[l,c]=x.useState(t===null?"":String(t)),[u,d]=x.useState(!1),[p,g]=x.useState(null),[y,h]=x.useState(null),m=x.useRef(!1),v=Number(l),w=l.trim()!==""&&Number.isFinite(v)&&v>0,k=async N=>{if(N==null||N.preventDefault(),!(!w||m.current)){m.current=!0,d(!0),g(null),h(null);try{const A=await a(v);A.note&&h(A.note)}catch(A){g(xP(A))}finally{m.current=!1,d(!1)}}};return n.jsxs("form",{className:"border border-warning/50 p-4","aria-label":"Raise the cap",onSubmit:N=>void k(N),children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsxs("label",{className:"flex items-center gap-2 font-mono text-body",children:[n.jsx("span",{className:"text-muted-foreground",children:"$"}),n.jsx(Be,{"aria-label":"New cap in dollars",inputMode:"decimal",value:l,onChange:N=>c(N.target.value),disabled:u,placeholder:`more than ${ur(e)}`,className:"h-9 w-32"})]}),n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:u||!w,children:u?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||t!==null)&&n.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&n.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",ur(s)]}),t!==null&&n.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",ur(t)]})]}),t!==null&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),p&&n.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:p}),y&&n.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:y})]})}function yP({waiting:e}){if(e){const t=(e.text??e.summary??"").replace(/^Waiting for you:\s*/,"");return n.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"The agent asks",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[n.jsx(bg,{className:"size-3.5","aria-hidden":!0})," Input required"]}),n.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:t})]})}return n.jsxs("section",{className:"border border-border-strong/60 p-4","aria-label":"Stopped",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[n.jsx(xi,{className:"size-3.5","aria-hidden":!0})," Stopped"]}),n.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."})]})}function bP({agent:e,efforts:t,v2:s,go:r,blocked:a,limits:l,upload:c=bS}){var P,B;const u=e.kind==="workflow",d=x.useMemo(()=>u?null:xS(e.definition.input_schema),[u,e.definition.input_schema]),p=(d==null?void 0:d.kind)==="fields"?d.form:null,g=u||(d==null?void 0:d.kind)==="json",y=x.useMemo(()=>u?dS(e.definition.workflow):(d==null?void 0:d.kind)==="json"?d.example:null,[u,e.definition.workflow,d]),[h,m]=x.useState((y==null?void 0:y.text)??""),[v,w]=x.useState(()=>p?kx(p):{}),[k,N]=x.useState(""),[A,_]=x.useState(""),[S,E]=x.useState(null),T=x.useMemo(()=>er(),[]),[C,R]=x.useState(!1),D=vS({upload:c,remove:s.deleteUpload,limits:l,frozen:C}),L=cS(e.kind,{text:h,effort:k,maxCostUsd:A,fileIds:D.fileIds,...p?{typed:{fields:Mf(p,v),contentRequired:p.contentRequired}}:{},...(d==null?void 0:d.kind)==="json"?{json:!0}:{}}),O=new Set((p==null?void 0:p.fields.map(([q])=>q))??[]),I=q=>{const ce=Xd(q.field);return ce!==null&&O.has(ce)?ce:null},W=(q,ce,de)=>{w(ue=>({...ue,[q]:de})),vx(ce,de)&&E(ue=>ue!=null&&ue.fields?{...ue,fields:ue.fields.filter(Q=>I(Q)!==q)}:ue)},U=typeof e.definition.max_cost_usd=="number"?e.definition.max_cost_usd:null,J=async(q,ce,de)=>{var ue;try{const Q=await s.startRun(q,ce,de);return{status:Q.status,runId:Q.run.run_id}}catch(Q){return Q instanceof Pe?{status:Q.status,problem:{message:Q.message,fields:Q.fields,...Q.code==="agent_not_runnable"&&typeof((ue=Q.details)==null?void 0:ue.box)=="string"?{box:Q.details.box}:{},...Q.code==="agent_not_runnable"&&Q.details?{details:Q.details}:{}}}:{status:0,problem:{message:Q instanceof Error?Q.message:String(Q)}}}},F=x.useRef(!0);x.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]);const Z=async()=>{if(!L.ok||C||a||D.busy)return;R(!0),E(null);const q=await mS(T,e.agent_id,L.body,J);F.current&&(R(!1),q.runId?(D.clear(),r(`#/runs/${encodeURIComponent(q.runId)}`)):E(q.problem??{message:`The server answered ${q.status}.`}))},z=u?null:!L.ok&&L.field==="max_cost_usd"?L.message:((B=(P=S==null?void 0:S.fields)==null?void 0:P.find(q=>q.field==="max_cost_usd"))==null?void 0:B.message)??null,H=((S==null?void 0:S.fields)??[]).filter(q=>q.message!==(S==null?void 0:S.message)&&!(z&&q.field==="max_cost_usd")&&I(q)===null),V=p?p.contentRequired?"The run's message":"The run's message (optional)":"The run's first message";return n.jsxs("section",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8","aria-label":"Start a run",children:[n.jsxs("div",{"data-phone-row":!0,className:"max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:gap-x-2 max-sm:gap-y-2",children:[n.jsxs("div",{className:"flex flex-col gap-3 max-sm:contents lg:flex-row lg:items-start",children:[n.jsx(ds,{value:h,onChange:q=>m(q.target.value),rows:g?6:2,spellCheck:!g,"aria-label":g?"The run's input, as JSON":V,placeholder:u?"The workflow's input, as JSON":g?"The agent's input, as JSON":V,onKeyDown:q=>{q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&(q.preventDefault(),Z())},className:ie("min-w-0 flex-1 resize-y max-sm:order-first max-sm:basis-full",g?"leading-[1.6]":"max-sm:h-10")}),n.jsxs("div",{"data-controls":!0,className:"flex items-center gap-3 max-sm:order-last max-sm:min-w-0 max-sm:max-w-full max-sm:flex-wrap max-sm:gap-2 sm:shrink-0",children:[t.length>0&&n.jsxs("div",{className:"flex items-center gap-2",title:"How hard the model thinks before it answers. default leaves it to the agent.",children:[n.jsxs("span",{className:"flex flex-col leading-tight",children:[n.jsx("label",{htmlFor:"runbar-effort",className:"caps text-label text-muted-foreground",children:"Effort"}),n.jsx("span",{className:"text-label text-muted-foreground max-sm:hidden",children:"How hard the model thinks"})]}),n.jsx(Lt,{id:"runbar-effort",label:"Effort",value:k,onChange:N,className:"w-32",options:["",...t].map(q=>({value:q,label:q||"default"}))})]}),!u&&n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"flex items-center gap-2",title:U!==null?`This run's spend cap in US dollars. Empty uses the agent's default, ${ur(U)}.`:"This run's spend cap in US dollars. Empty runs it with no cap.",children:[n.jsxs("span",{className:"flex flex-col leading-tight",children:[n.jsx("label",{htmlFor:"runbar-cap",className:"caps text-label text-muted-foreground",children:"Spend cap"}),n.jsx("span",{className:"text-label text-muted-foreground max-sm:hidden",children:"This run, US dollars"})]}),n.jsx(Be,{id:"runbar-cap",value:A,onChange:q=>{var ce;_(q.target.value),(ce=S==null?void 0:S.fields)!=null&&ce.some(de=>de.field==="max_cost_usd")&&E(null)},inputMode:"decimal","aria-label":"Spend cap","aria-invalid":z?!0:void 0,placeholder:U!==null?ur(U):"none",className:"w-24"})]}),z&&n.jsx("p",{className:"mt-1 max-w-[16rem] font-mono text-label text-destructive-text",role:"alert","data-issue":"max_cost_usd",children:z})]}),n.jsxs(K,{variant:"solid",onClick:()=>void Z(),disabled:!L.ok||C||!!a||D.busy,title:a??(D.busy?"Waiting for the files to be sent":void 0),children:[n.jsx(_i,{"aria-hidden":!0})," ",C?"Starting":"Run"]})]})]}),p&&n.jsx("div",{role:"group","aria-label":"The run's input",className:"mt-3 grid gap-3 max-sm:mt-0 max-sm:basis-full md:grid-cols-2",children:p.fields.map(([q,ce])=>n.jsxs("div",{"data-field":`input.${q}`,children:[n.jsx(Nx,{field:ce,label:Ec(q,ce),help:rc(ce),value:v[q]??"",onChange:de=>W(q,ce,de)}),n.jsx(Zo,{issues:((S==null?void 0:S.fields)??[]).filter(de=>I(de)===q),words:de=>jx(de,q,ce)})]},q))}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 max-sm:mt-0",children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx(Gh,{attachments:D,limits:l,disabled:!!a,compact:!0})}),n.jsx(rx,{label:"Run with your coding agent",className:"max-sm:hidden",unavailable:D.items.length?"Remove the attached files first: they are for a run started here, and are deleted when you leave this page. Your coding agent uploads its own.":!L.ok&&L.field==="max_cost_usd"&&A.trim()?"Fix the spend cap first: the handoff carries it, and a cap that is not a positive number of dollars cannot be handed over.":void 0,context:()=>({kind:"run",agentId:e.agent_id,revision:e.revision,...L.ok?{input:L.body.input}:{},...k?{effort:k}:{},...L.ok&&L.body.max_cost_usd!==void 0?{maxCostUsd:L.body.max_cost_usd}:{}})})]})]}),y&&n.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:uS(y,"run",u?"workflow":"agent")}),!L.ok&&L.field!=="max_cost_usd"&&h.trim()&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:L.message}),S&&n.jsxs("div",{className:"mt-3 border border-destructive/50 bg-destructive/10 px-3 py-2 font-mono text-small text-destructive-text",role:"alert",children:[n.jsxs("p",{children:["The run did not start: ",S.message]}),S.box&&n.jsxs("p",{className:"mt-1",children:["This server can't run the ",S.box," box this agent runs in: change where it runs in its settings."]}),n.jsx(_S,{agentId:e.agent_id,details:S.details}),H.length>0&&n.jsx("ul",{className:"mt-1",children:H.map(q=>n.jsxs("li",{children:[q.field,": ",q.message]},`${q.field}:${q.message}`))})]})]})}function Kt({className:e}){return n.jsx("span",{"aria-hidden":!0,className:ie("block bg-muted motion-safe:animate-pulse",e)})}function Lf({label:e,className:t,children:s}){return n.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:t,children:[s,n.jsxs("span",{className:"sr-only",children:[e,"…"]})]})}function vP(){return n.jsxs(Lf,{label:"Loading Mission Control",className:"mx-auto max-w-[1600px] space-y-8 px-6 py-8",children:[n.jsx(Kt,{className:"h-8 w-56"}),n.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:Array.from({length:6},(e,t)=>n.jsxs("div",{className:"border p-4",children:[n.jsx(Kt,{className:"h-3 w-16"}),n.jsx(Kt,{className:"mt-3 h-6 w-12"})]},t))}),n.jsx(Kt,{className:"h-48 w-full"}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[n.jsx(Jd,{n:4}),n.jsx(Jd,{n:6})]})]})}function Jd({n:e}){return n.jsx("div",{className:"border",children:Array.from({length:e},(t,s)=>n.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[n.jsx(Kt,{className:"h-4 w-20"}),n.jsx(Kt,{className:"h-4 flex-1"}),n.jsx(Kt,{className:"hidden h-4 w-24 sm:block"})]},s))})}function fs({label:e,rows:t=8}){return n.jsx(Lf,{label:e,children:n.jsx(Jd,{n:t})})}function wP(){return n.jsxs(Lf,{label:"Loading the run",className:"space-y-6 p-5 md:p-8",children:[n.jsxs("div",{className:"space-y-3 border-b pb-6",children:[n.jsx(Kt,{className:"h-4 w-24"}),n.jsx(Kt,{className:"h-7 w-2/3"}),n.jsx(Kt,{className:"h-3 w-1/3"})]}),n.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,t)=>n.jsx(Kt,{className:"h-4 w-16"},t))}),n.jsx("div",{className:"space-y-4",children:Array.from({length:5},(e,t)=>n.jsxs("div",{className:"flex gap-3",children:[n.jsx(Kt,{className:"size-4 shrink-0"}),n.jsx(Kt,{className:ie("h-4",t%2?"w-1/2":"w-3/4")})]},t))})]})}function kP(){return n.jsxs(Lf,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsx(Kt,{className:"h-7 w-64"}),n.jsx(Kt,{className:"h-3 w-80 max-w-full"})]}),n.jsx(Kt,{className:"h-12 w-full"}),n.jsx(Jd,{n:5})]})}const jP={browserbase:"Browserbase",kernel:"Kernel"},Qa=e=>jP[e]??e,g0=e=>n.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),NP=5e3,x0=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function SP({agent:e,v2:t,onAgent:s,poll:r,refresh:a}){var _,S;const[l,c]=x.useState(null),[u,d]=x.useState(!1),[p,g]=x.useState(null),y=x.useRef(e);y.current=e;const h=x.useRef(r);h.current=r;const m=e.sign_ins??[],v=m.some(E=>E.state==="held");x.useEffect(()=>{if(!v||u)return;const E=setInterval(()=>h.current(),NP);return()=>clearInterval(E)},[v,u]);const w=(S=(_=e.tools)==null?void 0:_.find(E=>E.name==="browser"))==null?void 0:S.resolved;if(!m.length&&w!=="browserbase"&&w!=="kernel"&&!p)return null;const k=[...new Set(m.map(E=>E.key))].map(E=>({key:E,items:m.filter(T=>T.key===E)})),N=async E=>{var T,C;d(!0),g(null);try{const D=(await t.forgetSignIn(e.agent_id,E)).removed.filter(O=>O.at_vendor==="not_deleted"),L=D.length?{tone:"warn",text:D.map(O=>`Forgotten here, but ${Qa(O.provider)} didn't confirm the delete. ${O.message??""}`.trim()).join(" ")}:null;if(g(L),c(null),!await a()){const O=y.current;s({...O,sign_ins:(O.sign_ins??[]).filter(I=>I.key!==E)}),g({tone:"warn",text:`${L?`${L.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(R){const D=R instanceof Pe&&R.code==="sign_in_held"?((T=R.details)==null?void 0:T.held_by)??((C=R.details)==null?void 0:C.handed_to):void 0;g(R instanceof Pe&&R.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...D?{run:D}:{}}:{tone:"error",text:`Not forgotten: ${tn(R)}`}),c(null)}finally{d(!1)}},A=({key:E,items:T})=>{const C=T.length===1?`Forget the ${Qa(T[0].provider)} sign-in`:`Forget the saved sign-ins for ${x0(T.map(D=>Qa(D.provider)))}`,R=T.some(D=>D.state==="held");return n.jsx(K,{size:"sm",variant:"ghost",disabled:u||R,"aria-label":C,title:R?"A run is using it: forget it once that run ends.":void 0,onClick:()=>{g(null),c(E)},children:"Forget"})};return n.jsxs("section",{"aria-label":"Sign-ins",className:"mt-4 max-w-3xl",children:[n.jsxs("p",{className:"caps mb-1.5 flex items-center gap-2 text-label text-muted-foreground",children:[n.jsx(ia,{className:"size-3.5","aria-hidden":!0})," Sign-ins"]}),m.length?n.jsx("ul",{className:"border",children:k.map(E=>n.jsxs("li",{className:"border-b last:border-b-0",children:[E.items.map(T=>n.jsxs("div",{"data-sign-in":!0,className:"px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsx("span",{className:"text-body font-semibold",children:Qa(T.provider)}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:T.verified_at?`last verified ${ht(T.verified_at)}`:"not verified yet"}),T.state==="held"&&T.held_by&&n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["in use by run ",g0(T.held_by)]}),E.items.length===1&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"flex-1"}),A(E)]})]}),T.state==="unreadable"&&n.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."})]},`${T.key}\0${T.provider}`)),E.items.length>1&&n.jsx("div",{className:"flex justify-end border-t px-3 py-1.5",children:A(E)}),l===E.key&&n.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:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[E.items.length===1?`Forget the ${Qa(E.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${x0(E.items.map(T=>Qa(T.provider)))}?`," The agent's next run with the browser starts signed out."]}),n.jsx(K,{size:"sm",variant:"solid",disabled:u,autoFocus:!0,onClick:()=>void N(E.key),children:"Yes, forget"}),n.jsx(K,{size:"sm",variant:"ghost",disabled:u,onClick:()=>c(null),children:"Keep"})]})]},E.key))}):n.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."}),p&&n.jsxs("p",{className:`mt-2 text-small ${p.tone==="error"?"text-destructive-text":"text-warning-text"}`,role:"status",children:[p.text,p.run&&n.jsxs(n.Fragment,{children:[" Run: ",g0(p.run)]})]})]})}const _P=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),$P=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function hr(e,t){var c,u;const s=`${_P(t)} could not be read.`;if($P(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof Pe))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=((u=(c=e.fields)==null?void 0:c[0])==null?void 0:u.message)??e.message,a=[e.code,e.requestId].filter(Boolean).join(" · "),l=(d,p)=>({title:s,why:d,next:p,said:r,code:a});return e.status===401?l("This browser is signed out.","Reload the page to sign in again."):e.status===403?l("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?l("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===412?l("Someone, or a run, changed it first.","Reload to see it as it is now."):e.status===429?l("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?l("The server is busy.","Try again in a moment."):e.status>=500?l("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):l("The server turned the request down.","Try again, and if it keeps happening, the server's words below say why.")}function Fn({problem:e,onRetry:t,className:s="m-8"}){return n.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${s}`,role:"alert",children:[n.jsx(Zs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-prose font-semibold",children:e.title}),n.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&n.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),t&&n.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:n.jsx(K,{type:"button",onClick:t,size:"sm",children:"Try again"})})]})]})}const ra=[{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"}],nd=e=>ra.find(t=>t.path===e),EP=e=>e.filter(t=>t.total_usd!==null),CP=e=>Math.min(25,Math.max(3,Math.round(e/15)));function TP(e,t){const s=[];let r=0;return e.forEach((a,l)=>{r+=a.total_usd,l>=t&&(r-=e[l-t].total_usd),s.push(r/Math.min(l+1,t))}),s}function RP(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e));return[1,2,2.5,5,10].map(s=>s*t).find(s=>s>=e*(1-1e-9))}function AP(e){const t=10**Math.floor(Math.log10(e)+1e-9),s=Math.round(e/t*10)/10,r={1:.25,2:.5,2.5:.5,5:1,10:2.5}[s]??e/4,a=[];for(let l=0;l*r*t<=e*(1+1e-9);l++)a.push(Math.round(l*r*t*1e12)/1e12);return a}function OP(e,t,s){if(!e.length)return{top:1,above:0};const r=e.map(c=>c.total_usd).sort((c,u)=>c-u),a=r[Math.min(r.length-1,Math.floor(r.length*.95))],l=RP(Math.max(a,...t,s??0)*1.08);return{top:l,above:e.filter(c=>c.total_usd>l).length}}function MP(e,t,s=6){if(t<=e)return[e];const r=(t-e)/Math.max(1,s-1),a=10**Math.floor(Math.log10(r)),l=Math.max(1,[1,2,5,10].map(u=>u*a).find(u=>u>=r)),c=[];for(let u=Math.ceil(e/l)*l;u<=t;u+=l)c.push(u);return!c.includes(e)&&(c[0]??1/0)-e>l/2&&c.unshift(e),c}function LP(e,t){let s=0;for(let r=1;r<e.length;r++)Math.abs(e[r].n-t)<Math.abs(e[s].n-t)&&(s=r);return s}function co(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 Vs(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const PP=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function IP(e,t){const s=[];for(let r=0;r<e.length;r+=t){const a=e.slice(r,r+t),l=Object.fromEntries(ra.map(({path:c})=>[c,0]));for(const c of a)l[c.path]++;s.push({from:a[0].n,to:a.at(-1).n,runs:a.length,counts:l})}return s}function Vh(e){const t=Math.round(e*10)/10;return`${t>=10?Math.round(e):t.toFixed(1)}x`}const bd=(e,t)=>`${t?Math.round(e/t*100):0}%`,Zp=3,sd=5,zP=20,Wl={revision:"New revision",promote:"Promoted",hold:"Held",refit:"Refit",superseded:"Superseded"},_x={revision:"R",promote:"P",hold:"H",refit:"F",superseded:"S"},RS=e=>e.source==="refit"?"refit":e.decided==="replaying"?"revision":e.decided;function DP(e,t){if(!e.length)return[];const s=e.map(l=>Date.parse(l.started_at)),r=s[0],a=[];for(const l of t){const c=Date.parse(l.at);if(!Number.isFinite(c)||c<r-1)continue;const u=s.findIndex(g=>g>=c);if(u<0)continue;const d=RS(l),p=e[u].n;a.push({kind:d,n:p,at:l.at,workflow:l.workflow,digest:l.digest,reason:l.reason,record:l})}return a.sort((l,c)=>l.n-c.n)}const FP=e=>e.path!=="replay",AS=e=>{var t;return(t=e==null?void 0:e.summary.hand_backs)!=null&&t.ran?e.summary.hand_backs:null},$x=(e,t,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===t&&r.digest===s);function UP(e,{serving:t=null,refit:s,stopped:r=null}={}){if(s)return{word:"Refit",tone:"muted"};if(!e)return{word:"Not decided",tone:"muted"};const a=WP(e),l=a?{proof:a}:{};return e.decided==="promote"?e.digest!==t?{word:"Served",tone:"muted",...l}:e.digest===r?{word:"Stopped",tone:"warning",...l}:{word:"Serving",tone:HP(e)?"success":"plain",...l}:e.decided==="hold"?{word:"Held",tone:"warning",...l}:e.decided==="superseded"?{word:"Superseded",tone:"muted"}:{word:"Replaying",tone:"active"}}function oc(...e){const t=UP(...e);return{...t,text:t.proof?`${t.word} · ${t.proof}`:t.word}}const Ex=(e,t)=>{var s;return((s=e==null?void 0:e.workflows.find(r=>r.workflow===t&&r.state==="needs_revision"))==null?void 0:s.digest)??null},OS=(e,t,s)=>s===null?void 0:[...e].reverse().find(r=>{var a;return r.workflow===t&&r.source==="refit"&&r.decided==="promote"&&((a=r.refit)==null?void 0:a.from)===s});function WP(e){var r;const t=e.replay,s=t?` · ${t.n-t.handed_back} alone`:"";return e.source==="dry_run"?"not replayed":e.source==="refit"?t?`refit on ${t.n} ${t.n===1?"row":"rows"}${s}`:null:e.source!=="replay"||!t||e.decided==="replaying"||e.decided==="superseded"?null:t.n?`replayed ${t.n}${(r=t.of)!=null&&r.length?`/${t.of.length}`:""}${s}`:"0 replays answered"}const HP=e=>{var t;return(e.source==="replay"||e.source==="refit")&&(((t=e.replay)==null?void 0:t.n)??0)>0},y0=e=>`${Math.round(e*100)}%`,BP=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`;function oa(e){const t=e.replay;return!t||!t.n?e.reason:`${e.source==="refit"?"Refit on":e.source==="graded"?"Checked on":"Replay on"} ${t.n} graded ${t.n===1?"input":"inputs"}: workflow ${y0(t.wf_acc)} vs agent ${y0(t.agent_acc)} (${BP(t.delta)}), ${t.handed_back} handed back${t.skipped_write?`, ${t.skipped_write} skipped`:""}`}function GP(e){const t=[];let s;try{s=e===null?null:JSON.parse(e)}catch{return t}const r=(a,l,c)=>{if(Array.isArray(a)){a.forEach((p,g)=>r(p,`${l}/${g}`,c));return}if(!a||typeof a!="object")return;const u=a,d=u.guard;typeof u.label=="string"&&d&&typeof d=="object"&&!Array.isArray(d)&&(d.signal==="self"||d.signal==="jev"||d.signal==="both")&&typeof d.threshold=="number"&&t.push({label:u.label,node:`${c}${u.label}`,path:l,signal:d.signal,threshold:d.threshold,fitted:!!d.fit});for(const[p,g]of Object.entries(u)){if(p==="guard")continue;const y=p==="workflow"&&u.node==="workflow"&&typeof u.label=="string";r(g,`${l}/${p.replace(/~/g,"~0").replace(/\//g,"~1")}`,y?`${c}${u.label}/`:c)}};return r(s,"",""),t}const qP={self:"its own confidence",jev:"Jev",both:"its own confidence and Jev"};function VP(e,t=.1){const s=Math.round(1/t),r=Array.from({length:s},(a,l)=>({from:l*t,to:(l+1)*t,right:0,wrong:0,ungraded:0}));for(const a of e){const l=a.p===null?0:Math.min(s-1,Math.max(0,Math.floor(a.p/t+1e-9))),c=r[l];a.correct===!0?c.right+=1:a.correct===!1?c.wrong+=1:c.ungraded+=1}return r}const KP=(e,t,s,r)=>e&&s?e.guards.find(a=>a.workflow===t&&a.digest===s&&a.node===r):void 0;function MS(e){const t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!t)return null;const s=t[1].split(/\r?\n/).find(a=>/^compiled_into\s*:/.test(a)),r=s==null?void 0:s.replace(/^compiled_into\s*:\s*/,"").trim().replace(/^["']|["']$/g,"");return r||null}function YP(e){var D,L;const{notes:t,compiledNotes:s,runs:r,workflows:a,cost:l,promotions:c,serving:u,loop:d,mode:p="full"}=e,g=p==="notes",y=a.filter(O=>O.status==="active"),h=d==null?void 0:d.compiles.find(O=>O.digest===null&&(O.draft_errors.length>0||O.attempts.length>0)),m=d==null?void 0:d.compiles.find(O=>O.digest!==null),v=l==null?void 0:l.summary,w=AS(l),k=c.at(-1),N=k?u.find(O=>O.workflow===k.workflow):void 0,A=(N==null?void 0:N.digest)??null,_=N!=null&&N.replaying?`revision ${N.replaying.slice(0,7)} replays on graded inputs before it serves`:(k==null?void 0:k.decided)==="hold"&&k.digest!==A?`revision ${k.digest.slice(0,7)} was held: ${oa(k)}`:null,S=A!==null&&k?Ex(l,k.workflow)===A:!1,E=S?`revision ${A.slice(0,7)} no longer runs first: it cost as much as the agent by hand; its next run asks the agent for a new version`:null,T=E?_?`${E}; ${_}`:E:A&&_?`revision ${A.slice(0,7)} serves; ${_}`:null,C=[];if(C.push({key:"notes",title:"Learned",value:t===1?"1 note":`${t} notes`,detail:s?`${s} compiled into a workflow`:t?"kept from its runs, read by every later run":"none yet: a run keeps what it learns at its end",state:t?"done":"now"}),y.length||m&&m.digest){const O=((D=y[0])==null?void 0:D.name)??(m==null?void 0:m.workflow)??"a workflow";C.push({key:"compiled",title:"Compiled",value:O,detail:m?`from ${m.from_notes.length} ${m.from_notes.length===1?"note":"notes"}, ${m.attempts.length} ${m.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else h?C.push({key:"compiled",title:"Compile",value:"Draft failed",detail:`${h.attempts.length} ${h.attempts.length===1?"attempt":"attempts"}, the checks refused it: it tries again on a later run`,state:"warn"}):g?C.push({key:"compiled",title:"Compile",value:"Notes only",detail:`this agent learns notes only: no workflow compiles from them. Full learning compiles one at ${Zp} notes or ${sd} runs`,state:"later"}):C.push({key:"compiled",title:"Compile",value:"Not yet",detail:`${t} of ${Zp} notes, ${Math.min(r,sd)} of ${sd} runs: a workflow compiles at ${Zp} notes or ${sd} runs`,state:t||r?"now":"later"});if(v!=null&&v.takeover)C.push({key:"took_over",title:"Took over",value:`Run ${v.takeover.n}`,detail:T??((L=k==null?void 0:k.replay)!=null&&L.n?oa(k):k?k.reason:"the first run a learned workflow finished alone"),state:S||(k==null?void 0:k.decided)==="hold"&&!A?"warn":"done"});else if(k)if(T)C.push({key:"took_over",title:"Take over",value:oc($x(c,k.workflow,A)??k,{serving:A,stopped:S?A:null}).word,detail:T,state:S?"warn":"done"});else{const O=oc(k,{serving:A});C.push({key:"took_over",title:"Take over",value:O.word,detail:k.decided==="replaying"?"replaying on graded inputs before it serves; the agent takes the runs meanwhile":oa(k),state:k.decided==="hold"?"warn":"now"})}else g||C.push({key:"took_over",title:"Take over",value:"Not yet",detail:"a compiled workflow replays on graded runs, then serves first when it does as well as the agent",state:"later"});if(v!=null&&v.after&&v.before){const O=`${b0(v.before.mean_usd)} a run by the agent, ${b0(v.after.mean_usd)} all-in since`,I=v.times_cheaper;I!==null&&I>1?C.push({key:"cheaper",title:"Cheaper",value:`${v0(I)} cheaper`,detail:O,state:"done"}):I!==null?C.push({key:"cheaper",title:"Cheaper",value:I<1?v.before.mean_usd>0?`Not cheaper yet: ${v0(v.after.mean_usd/v.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:O,state:"now"}):C.push({key:"cheaper",title:"Cheaper",value:`${v.after.runs} ${v.after.runs===1?"run":"runs"} so far`,detail:`${O}; how many times cheaper shows after ${zP} runs`,state:"now"})}else g||C.push({key:"cheaper",title:"Cheaper",value:"Not yet",detail:"once a workflow takes over, each run's all-in cost against before",state:"later"});const R=((d==null?void 0:d.guards)??[]).filter(O=>O.runs>0&&O.threshold!==null).sort((O,I)=>I.escalated/I.runs-O.escalated/O.runs)[0];if(w||R){const O=w?`${Math.round(w.back/w.ran*100)}% handed back`:"no run since";C.push({key:"unsure",title:"Unsure",value:O,detail:R?`most at "${R.node}": ${R.escalated} of ${R.runs} under ${R.threshold.toFixed(2)}`:`of ${w.ran} runs it ran first`,state:w&&w.back/w.ran>.25?"warn":"watch"})}return C}const b0=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,v0=e=>{const t=Math.round(e*10)/10;return`${t>=10?Math.round(e):t.toFixed(1)}x`},XP=1e3,LS="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.";function w0({v2:e,agentId:t,on:s,quiet:r=!1,promotions:a,onCost:l}){const[c,u]=x.useState(null),[d,p]=x.useState([]),g=a??d,y=x.useRef(l);y.current=l;const[h,m]=x.useState(null),[v,w]=x.useState(0);return x.useEffect(()=>{let k=!0;return m(null),Promise.resolve().then(()=>e.learningCost(t,XP)).then(N=>{var A;k&&(u(N),(A=y.current)==null||A.call(y,N))},N=>{k&&m(N??new Error("unknown"))}),a||Promise.resolve().then(()=>e.learningPromotions(t)).then(N=>{k&&p(N.promotions)},()=>{}),()=>{k=!1}},[e,t,v,!a]),r&&(!c||c.runs.filter(k=>k.total_usd!==null).length<2)?null:h&&!c?n.jsx(Fn,{problem:hr(h,"the cost per run"),onRetry:()=>w(k=>k+1),className:""}):c?n.jsx(JP,{data:c,on:s,promotions:g}):n.jsx(Kt,{className:"h-[320px] w-full"})}const yt={top:30,right:16,bottom:30,left:60},rd=17,QP=16,$r=260;function JP({data:e,on:t,width:s,promotions:r=[]}){var pe;const a=x.useMemo(()=>EP(e.runs),[e.runs]),l=x.useMemo(()=>a.filter(FP),[a]),c=CP(l.length),u=x.useMemo(()=>TP(l,c),[l,c]),d=x.useMemo(()=>DP(e.runs,r),[e.runs,r]),{summary:p}=e,g=AS(e),y=x.useRef(null),[h,m]=x.useState(s??720);x.useEffect(()=>{const Y=y.current;if(s||!Y||typeof ResizeObserver>"u")return;const _e=new ResizeObserver(([Ze])=>{Ze&&Ze.contentRect.width>0&&m(Ze.contentRect.width)});return _e.observe(Y),()=>_e.disconnect()},[s]);const[v,w]=x.useState(null),[k,N]=x.useState(null),A=ra.map(Y=>({...Y,runs:e.runs.filter(_e=>_e.path===Y.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(Y=>Y.state==="needs_revision"&&Y.served&&Y.by_hand).map(Y=>`${Y.workflow} no longer runs first: ${Vs(Y.served.mean_usd)} a run all-in over its last ${Y.served.runs} runs, at or over ${Vs(Y.by_hand.mean_usd)} a run by hand.${Y.unknown_cost_runs?` ${Y.unknown_cost_runs===1?"1 run":`${Y.unknown_cost_runs} runs`} of unknown cost left out.`:""} Its next run asks the agent for a new version, which runs first again.`)].filter(Y=>!!Y);if(a.length<2)return n.jsxs(N0,{title:"Cost per run",headline:null,children:[n.jsxs("div",{className:"px-4 py-8 text-center",role:"status",children:[n.jsx("p",{className:"font-mono text-body",children:a.length?"One run so far.":"No run with a known cost yet."}),n.jsx("p",{className:"mx-auto mt-1 max-w-prose text-body text-muted-foreground",children:LS}),_.map(Y=>n.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:Y},Y))]}),e.runs.length>0&&(()=>{var Ze;const Y=Math.max(300,h),_e=(Y-yt.left-yt.right)/(e.runs.at(-1).n-e.runs[0].n+1);return n.jsx("figure",{ref:y,className:"px-4 pb-3",children:n.jsx(j0,{runs:e.runs,width:Y,x:Je=>yt.left+(Je-e.runs[0].n+.5)*_e,step:_e,plot:[yt.left,Y-yt.right],takeover:((Ze=p.takeover)==null?void 0:Ze.n)??null})})})()]});const S=Math.max(300,h),E=S-yt.left-yt.right,T=e.runs[0].n,C=e.runs.at(-1).n,R=E/(C-T+1),D=Y=>yt.left+(Y-T+.5)*R,L=p.before,{top:O,above:I}=OP(a,u,(L==null?void 0:L.mean_usd)??null),W=[],U=[];for(const Y of d){const _e=D(Y.n)-R/2;let Ze=U.findIndex(Je=>_e-Je>=QP);Ze<0?(Ze=U.length,U.push(_e)):U[Ze]=_e,W.push(Ze)}const J=U.length?U.length*rd+8:0,F=yt.top+J,Z=Y=>F+$r-Math.min(Y,O)/O*$r,z=AP(O),H=MP(T,C,S<520?5:7),V=p.takeover&&p.takeover.n>=T?p.takeover:null,P=p.takeover?Math.max(p.takeover.n,T):null,B=l.map((Y,_e)=>`${_e?"L":"M"}${D(Y.n).toFixed(1)},${Z(u[_e]).toFixed(1)}`).join(""),q=v===null?null:a[v],ce=p.times_cheaper!==null?`${Vh(p.times_cheaper)} cheaper`:null,de=g?`${bd(g.back,g.ran)} handed back since`:null,ue=p.before&&p.after?`${Vs(p.before.mean_usd)} a run before takeover, ${Vs(p.after.mean_usd)} all-in after${ce?`: ${ce}`:""}${de?` · ${de}`:""}`:null,Q=e.unknown_cost_runs+e.unknown_path_runs,fe=Y=>{const _e=Y.currentTarget.getBoundingClientRect(),Ze=(Y.clientX-_e.left)/_e.width*S,Je=(Y.clientY-_e.top)/_e.height*(F+$r+yt.bottom);if(d.length&&Je<F-2){w(null);const xt=d.map((et,ae)=>({i:ae,d:Math.abs(D(et.n)-R/2-Ze)+Math.abs(yt.top+W[ae]*rd+8-Je)})).sort((et,ae)=>et.d-ae.d)[0];N(xt&&xt.d<=12?xt.i:null);return}N(null),w(LP(a,T+(Ze-yt.left)/R-.5))},ye=Y=>{const Ze={ArrowRight:Je=>Je+1,ArrowLeft:Je=>Je-1,Home:()=>0,End:()=>a.length-1,PageUp:Je=>Je+10,PageDown:Je=>Je-10}[Y.key];if(!Ze){Y.key==="Escape"&&w(null);return}Y.preventDefault(),w(Je=>Math.min(a.length-1,Math.max(0,Ze(Je??(Y.key==="ArrowLeft"?a.length:-1)))))},Ee=Y=>[`Run ${Y.n}`,`${co(Y.total_usd)} all-in${Y.learning_usd?` (${co(Y.cost_usd??0)} the run, ${co(Y.learning_usd)} learning)`:""}`,`${nd(Y.path).label}${Y.workflow?`: ${Y.workflow}`:""}`,Y.learned_revision?`Learned revision ${Y.learned_revision.slice(0,7)}`:"Nothing learned yet",...Y.path==="replay"?["A replay: learning's spend, out of the line"]:[]],ge=k===null?null:d[k]??null,se=V?D(V.n)>yt.left+E*.62:!1;return n.jsxs(N0,{title:"Cost per run",headline:ue,unknown:Q,children:[n.jsxs("figure",{ref:y,className:"px-4 pb-2 pt-3",children:[n.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground",children:[A.filter(Y=>Y.runs>0).map(Y=>n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:n.jsx("circle",{cx:"5",cy:"5",r:"4",className:Y.fill})}),Y.label," ",n.jsx("span",{className:"text-foreground",children:Y.runs})]},Y.path)),n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:n.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",c," runs"]}),L&&n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:n.jsx("path",{d:"M1,5H17",className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"4 3"})}),"Before takeover, the agent alone"]}),Object.keys(Wl).filter(Y=>d.some(_e=>_e.kind===Y)).map(Y=>n.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${Y}`,children:[n.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:n.jsx(S0,{x:0,y:0,kind:Y})}),Wl[Y]," ",n.jsx("span",{className:"text-foreground",children:d.filter(_e=>_e.kind===Y).length})]},Y))]}),n.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:ye,onBlur:()=>w(null),"aria-label":`Cost per run, runs ${T} to ${C}. ${ue??""} Arrow keys step through the runs.`,children:[n.jsxs("svg",{width:S,height:F+$r+yt.bottom,className:"block select-none font-mono",onPointerMove:fe,onPointerLeave:()=>{w(null),N(null)},"aria-hidden":!0,children:[z.map(Y=>n.jsxs("g",{children:[n.jsx("path",{d:`M${yt.left},${Z(Y)}H${yt.left+E}`,className:Y===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),n.jsx("text",{x:yt.left-8,y:Z(Y),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:co(Y)})]},Y)),H.map(Y=>n.jsx("text",{x:D(Y),y:F+$r+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:Y},Y)),n.jsx("text",{x:yt.left,y:J?yt.top-10:F-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),n.jsx("text",{x:yt.left-8,y:F+$r+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),d.map((Y,_e)=>n.jsxs("g",{"data-testid":`marker-${Y.kind}`,opacity:k===null||k===_e?1:.55,children:[n.jsx("path",{d:`M${D(Y.n)-R/2},${yt.top+W[_e]*rd+15}V${F+$r}`,className:PS[Y.kind],strokeWidth:1,strokeDasharray:"2 3"}),n.jsx(S0,{x:D(Y.n)-R/2-7,y:yt.top+W[_e]*rd+1,kind:Y.kind})]},`${Y.kind}:${Y.n}:${Y.workflow}:${Y.digest}:${Y.at}`)),a.map((Y,_e)=>Y.path==="replay"?n.jsx("circle",{cx:D(Y.n),cy:Z(Y.total_usd),r:_e===v?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},Y.run_id):n.jsx("circle",{cx:D(Y.n),cy:Z(Y.total_usd),r:_e===v?0:3,className:ie(nd(Y.path).fill),fillOpacity:.65},Y.run_id)),L&&n.jsxs("g",{children:[n.jsx("path",{d:`M${yt.left},${Z(L.mean_usd)}H${yt.left+E}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),n.jsxs(eh,{x:yt.left+E-4,y:Z(L.mean_usd)-6,anchor:"end",children:["Before takeover ",Vs(L.mean_usd)]})]}),V&&n.jsxs("g",{children:[n.jsx("path",{d:`M${D(V.n)},${F-4}V${F+$r}`,className:"stroke-chart-workflow",strokeWidth:1.5}),n.jsxs(eh,{x:D(V.n)+(se?-6:6),y:F+6,anchor:se?"end":"start",children:["Workflow took over, run ",V.n]})]}),P!==null&&p.after&&n.jsxs("g",{children:[n.jsx("path",{d:`M${D(P)},${Z(p.after.mean_usd)}H${yt.left+E}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),n.jsxs(eh,{x:yt.left+E-4,y:Z(p.after.mean_usd)-8,anchor:"end",strong:!0,children:[S<520?"After":"After takeover"," ",Vs(p.after.mean_usd),ce?` · ${ce}`:""]})]}),n.jsx("path",{d:B,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),q&&n.jsxs("g",{children:[n.jsx("path",{d:`M${D(q.n)},${F}V${F+$r}`,className:"stroke-border-strong",strokeWidth:1}),n.jsx("circle",{cx:D(q.n),cy:Z(q.total_usd),r:5,className:ie(nd(q.path).fill,"stroke-card"),strokeWidth:2})]})]}),ge&&!q&&n.jsx("div",{className:ie("pointer-events-none absolute z-raised max-w-[22rem] border bg-card px-2 py-1 font-mono text-label shadow-float",D(ge.n)>S*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:D(ge.n)>S*.6?D(ge.n)-R/2-12:D(ge.n)-R/2+12,top:yt.top},children:_0(ge).map((Y,_e)=>n.jsx("span",{className:ie("block",_e===0?"font-semibold":"text-muted-foreground"),children:Y},_e))}),q&&n.jsxs("div",{className:ie("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",D(q.n)>S*.6&&"-translate-x-full"),style:{left:D(q.n)>S*.6?D(q.n)-10:D(q.n)+10,top:F},children:[Ee(q).map((Y,_e)=>n.jsx("span",{className:ie("block",_e===0?"font-semibold":"text-muted-foreground"),children:Y},Y)),n.jsx("span",{className:"block text-muted-foreground",children:ht(q.started_at)})]}),n.jsx("p",{className:"sr-only","aria-live":"polite",children:q?Ee(q).join(", "):""}),d.length>0&&n.jsx("p",{className:"sr-only",children:`Markers: ${d.map(Y=>_0(Y).join(", ")).join(". ")}.`})]}),n.jsx(j0,{runs:e.runs,width:S,x:D,step:R,plot:[yt.left,yt.left+E],takeover:((pe=p.takeover)==null?void 0:pe.n)??null}),n.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 (the look-back and the grade). The line is the mean of the last ",c," runs",a.some(Y=>Y.path==="replay")?", replay runs (hollow) left out":"",".",I?` ${I===1?"1 run costs":`${I} runs cost`} more than ${co(O)} and ${I===1?"is":"are"} drawn at the top.`:"",p.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.":""]}),[..._,...tI(e,t)].map(Y=>n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:Y},Y))]}),n.jsxs("details",{className:"border-t px-4 py-2",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),n.jsx("div",{className:"max-h-96 overflow-auto",children:n.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[n.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:n.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Started","Path","Revision","Run $","Learning $","All-in $"].map(Y=>n.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:Y},Y))})}),n.jsx("tbody",{children:e.runs.map(Y=>{var _e;return n.jsxs("tr",{children:[n.jsx("td",{className:"py-0.5 pr-4",children:Y.n}),n.jsx("td",{className:"pr-4",children:ht(Y.started_at)}),n.jsxs("td",{className:"pr-4",children:[nd(Y.path).label,Y.workflow?`: ${Y.workflow}`:""]}),n.jsx("td",{className:"pr-4",children:((_e=Y.learned_revision)==null?void 0:_e.slice(0,7))??"-"}),n.jsx("td",{className:"pr-4",children:Y.cost_usd===null?"unknown":co(Y.cost_usd)}),n.jsx("td",{className:"pr-4",children:Y.learning_usd===null?"unknown":co(Y.learning_usd)}),n.jsx("td",{className:"pr-4",children:Y.total_usd===null?"unknown":co(Y.total_usd)})]},Y.run_id)})})]})}),d.length>0&&n.jsxs("table",{className:"mt-3 w-full border-collapse font-mono text-small","data-testid":"marker-table",children:[n.jsx("thead",{children:n.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Marker","Workflow","Revision","Numbers"].map(Y=>n.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:Y},Y))})}),n.jsx("tbody",{children:d.map(Y=>n.jsxs("tr",{children:[n.jsx("td",{className:"py-0.5 pr-4",children:Y.n}),n.jsxs("td",{className:"pr-4",children:[_x[Y.kind]," ",Wl[Y.kind]]}),n.jsx("td",{className:"pr-4",children:Y.workflow}),n.jsx("td",{className:"pr-4",children:Y.digest.slice(0,7)}),n.jsx("td",{className:"pr-4 font-sans",children:oa(Y.record)})]},`${Y.kind}:${Y.n}:${Y.workflow}:${Y.digest}:${Y.at}`))})]}),n.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["As CSV: ",n.jsxs("code",{className:"font-mono",children:["agentrun learning cost ",e.agent," --format csv"]})]})]})]})}const ZP=64,uo={top:4,bottom:6},eI=[...ra].reverse(),k0=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function j0({runs:e,width:t,x:s,step:r,plot:a,takeover:l}){const c=ZP,u=PP(e.length),d=x.useMemo(()=>IP(e,u),[e,u]),[p,g]=x.useState(null);if(!d.length)return null;const[y,h]=a,m=R=>Math.min(h,Math.max(y,R)),v=R=>({from:m(s(R.from)-r/2),to:m(s(R.to)+r/2)}),w=R=>uo.top+c*(1-R),k=d.at(-1),N=R=>{const{from:D,to:L}=v(R),O=L-D>4?1:0;return{x0:D+O,w:Math.max(1,L-D-2*O)}},A=R=>`${k0(R)}: ${ra.filter(D=>R.counts[D.path]).map(D=>`${D.label.toLowerCase()} ${R.counts[D.path]}`).join(", ")}`,_=d.some(R=>R.counts.workflow)?`${bd(k.counts.workflow,k.runs)} by the learned workflow`:ra.filter(R=>k.counts[R.path]).map(R=>`${bd(k.counts[R.path],k.runs)} ${R.label.toLowerCase()}`).join(", "),S=`Last ${k.runs===1?"run":`${k.runs} runs`}: ${_}`,E=p===null?null:d[p],T=E?N(E).x0>t/2:!1,C=l!==null&&s(l)>=y&&s(l)<=h;return n.jsxs("div",{className:"relative min-w-0",style:{width:t},"data-testid":"execution-mix",children:[n.jsxs("div",{className:"font-mono text-label",style:{paddingLeft:y},children:[n.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",u>1?`, by ${u}`:""]}),n.jsx("span",{className:"block text-foreground",children:S})]}),n.jsxs("svg",{width:t,height:uo.top+c+uo.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>g(null),children:[[0,.5,1].map(R=>n.jsxs("text",{x:y-6,y:w(R),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[R*100,"%"]},R)),d.map((R,D)=>{const{x0:L,w:O}=N(R);let I=uo.top+c;return n.jsxs("g",{onPointerEnter:()=>g(D),opacity:p===null||p===D?1:.55,children:[n.jsx("rect",{x:v(R).from,y:uo.top,width:Math.max(1,v(R).to-v(R).from),height:c,className:"fill-card",fillOpacity:0}),eI.map(W=>{const U=R.counts[W.path]/R.runs*c;if(!U)return null;I-=U;const J=I>uo.top+.5?Math.min(2,U):0;return n.jsx("rect",{x:L,y:I+J,width:O,height:U-J,className:W.fill,fillOpacity:.8},W.path)})]},R.from)}),C&&n.jsx("g",{"data-testid":"mix-takeover",children:n.jsx("path",{d:`M${s(l)-r/2},${uo.top}V${uo.top+c}`,className:"stroke-chart-workflow",strokeWidth:1.5})})]}),E&&n.jsxs("div",{className:ie("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",T&&"-translate-x-full"),style:{left:T?N(E).x0-6:N(E).x0+N(E).w+6,top:40},children:[n.jsx("span",{className:"block font-semibold",children:k0(E)}),ra.filter(R=>E.counts[R.path]).map(R=>n.jsxs("span",{className:"block text-muted-foreground",children:[R.label," ",E.counts[R.path]," (",bd(E.counts[R.path],E.runs),")"]},R.path))]}),n.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${u} runs. ${d.map(A).join(". ")}. ${S}.`})]})}function tI(e,t){const s=e.summary;return s.takeover?s.times_cheaper===null&&s.after?[`${s.after.runs===1?"1 run":`${s.after.runs} runs`} since the workflow took over: how many times cheaper it is shows after 20.`]:[]:[t?"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.":LS]}function N0({title:e,headline:t,unknown:s=0,children:r}){return n.jsxs("section",{className:"min-w-0 border","aria-label":e,"data-testid":"cost-per-run",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[n.jsx("h3",{className:"caps text-small font-semibold",children:e}),t&&n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:t}),s>0&&n.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 PS={promote:"stroke-chart-workflow",hold:"stroke-warning",refit:"stroke-foreground",revision:"stroke-muted-foreground",superseded:"stroke-muted-foreground"},nI={promote:"fill-foreground",hold:"fill-warning-text",refit:"fill-foreground",revision:"fill-muted-foreground",superseded:"fill-muted-foreground"};function S0({x:e,y:t,kind:s}){return n.jsxs("g",{children:[n.jsx("rect",{x:e+.75,y:t+.75,width:12.5,height:12.5,className:ie("fill-card",PS[s]),strokeWidth:1.5,rx:2}),n.jsx("text",{x:e+7,y:t+7,dy:"0.35em",textAnchor:"middle",className:ie("text-micro font-semibold",nI[s]),children:_x[s]})]})}const _0=e=>[`${Wl[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,oa(e.record),ht(e.at)];function eh({x:e,y:t,anchor:s="start",strong:r=!1,children:a}){return n.jsx("text",{x:e,y:t,textAnchor:s,className:ie("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:a})}function sI(e){const t=[];let s=[],r="",a=!1;const l=e.replace(/^/,"");for(let c=0;c<l.length;c++){const u=l[c];a?u==='"'?l[c+1]==='"'?(r+='"',c++):a=!1:r+=u:u==='"'&&r===""?a=!0:u===","?(s.push(r),r=""):u===`
550
+ `||u==="\r"?(u==="\r"&&l[c+1]===`
551
+ `&&c++,s.push(r),r="",s.some(d=>d.trim()!=="")&&t.push(s),s=[]):r+=u}return a?null:(s.push(r),s.some(c=>c.trim()!=="")&&t.push(s),t)}function rI(e){var l;const t=sI(e);if(!t)return{error:"The file ends inside a quoted cell: a quote is not closed."};const s=(l=t.shift())==null?void 0:l.map(c=>c.trim());if(!s||!t.length)return{error:"The file needs a header line and at least one row."};if(s.some(c=>c===""))return{error:"A column in the header line has no name."};const r=s.find((c,u)=>s.indexOf(c)!==u);if(r!==void 0)return{error:`The column ${r} is named twice in the header line.`};const a=t.findIndex(c=>c.length!==s.length);return a>=0?{error:`Row ${a+1} has ${t[a].length} cells, and the header line has ${s.length}.`}:{columns:s,rows:t.map(c=>Object.fromEntries(s.map((u,d)=>[u,c[d]])))}}const $0=500,oI=5,Kh=e=>e.status==="running";function aI(e){return e.status==="cancelled"?`Cancelled after ${e.finished} of ${e.total} rows.`:e.status!=="stopped"?null:e.stopped==="cap"?`Stopped after ${e.finished} of ${e.total} rows: what is left of the cap does not cover another row.`:e.stopped==="cost_unknown"?`Stopped after ${e.finished} of ${e.total} rows: a row's cost is not known, and the cap is never guessed at.`:`Stopped after ${e.finished} of ${e.total} rows${e.error?`: ${e.error}`:"."}`}const iI={agent:"by hand",handed_back:"handed back",workflow:"workflow"},lI=2e3;function E0({v2:e,agentId:t,onFinished:s,pollMs:r=lI}){const[a,l]=x.useState(void 0),[c,u]=x.useState(null),[d,p]=x.useState(!1),[g,y]=x.useState(0),h=x.useRef(!1),m=x.useRef(s);if(m.current=s,x.useEffect(()=>{let w=!0,k;const N=async A=>{var _,S;try{const E=A??((_=(await e.learningBatches(t)).batches[0])==null?void 0:_.id),T=E?await e.learningBatch(t,E):null;if(!w)return;l(T),u(null),T&&Kh(T)?(h.current=!0,k=setTimeout(()=>void N(T.id),r)):T&&h.current&&(h.current=!1,(S=m.current)==null||S.call(m))}catch(E){if(!w)return;u(E??new Error("unknown")),k=setTimeout(()=>void N(A),r*2)}};return N(),()=>{w=!1,clearTimeout(k)}},[e,t,r,g]),a===void 0&&!c)return n.jsx(Kt,{className:"h-24 w-full"});if(a===void 0)return n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsxs("p",{className:"font-mono text-small text-muted-foreground",role:"status",children:["Learn from a CSV is not available right now: ",c instanceof Error?c.message:String(c),"."]}),n.jsx(K,{size:"sm",variant:"outline",onClick:()=>{u(null),y(w=>w+1)},children:"Read again"})]});const v=a&&Kh(a);return n.jsxs("section",{className:"space-y-4","aria-label":"Learn from a CSV",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:"Learn from a CSV"}),!v&&!d&&n.jsx(K,{size:"sm",onClick:()=>p(!0),children:a?"Learn from another CSV":"Learn from a CSV"})]}),!!c&&n.jsxs("p",{className:"font-mono text-small text-warning-text",role:"status",children:["The batch was not read again: ",c instanceof Error?c.message:String(c),". Trying again."]}),d&&!v&&n.jsx(cI,{v2:e,agentId:t,onStarted:w=>{h.current=!0,l(w),p(!1),y(k=>k+1)},onCancel:()=>p(!1)}),a&&!d&&n.jsx(fI,{v2:e,agentId:t,batch:a,onBatch:l}),!a&&!d&&n.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Give it rows you already have answers for. It runs on each in order, learning as it goes, and is told the right answer after each one."})]})}function cI({v2:e,agentId:t,onStarted:s,onCancel:r}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[d,p]=x.useState([]),[g,y]=x.useState(""),[h,m]=x.useState(String(oI)),[v,w]=x.useState(!1),[k,N]=x.useState(null),A=async T=>{var L;const C=(L=T.target.files)==null?void 0:L[0];if(!C)return;N(null);const R=rI(await C.text());if("error"in R){l(null),u(R.error);return}u(R.rows.length>$0?`A batch takes at most ${$0} rows: this file has ${R.rows.length}.`:null),l({name:C.name,columns:R.columns,rows:R.rows});const D=R.columns.at(-1);y(D),p(R.columns.filter(O=>O!==D))},_=Number(h),S=!!a&&!c&&d.length>0&&!!g&&!d.includes(g)&&Number.isFinite(_)&&_>0,E=async()=>{var T,C;if(!(!a||!S)){w(!0),N(null);try{s(await e.startLearningBatch(t,{inputs:d,answer:g,rows:a.rows,max_cost_usd:_}))}catch(R){N(R instanceof Pe?((C=(T=R.fields)==null?void 0:T[0])==null?void 0:C.message)??R.message:R instanceof Error?R.message:String(R)),w(!1)}}};return n.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[n.jsx(Xs,{label:"CSV file",note:"A header line, then one row for each thing to learn from. The file is read here; its rows go to the server.",children:n.jsx("input",{type:"file",accept:".csv,text/csv",onChange:T=>void A(T),"aria-label":"CSV file",className:"block w-full font-mono text-body file:mr-3 file:border file:border-input file:bg-background file:px-3 file:py-1.5 file:font-mono"})}),c&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),a&&!("error"in a)&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[a.name,": ",a.rows.length," rows, ",a.columns.length," columns"]}),n.jsx(Xs,{label:"The agent is given",group:!0,note:"The columns each run reads. The answer column is never one of them.",children:n.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:a.columns.map(T=>n.jsx(qA,{label:T,checked:d.includes(T),disabled:T===g,onChange:C=>p(R=>C.target.checked?a.columns.filter(D=>R.includes(D)||D===T):R.filter(D=>D!==T))},T))})}),n.jsx(Xs,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:n.jsx(Lt,{label:"The answer column",value:g,onChange:T=>{y(T),p(C=>C.filter(R=>R!==T))},options:a.columns.map(T=>({value:T,label:T}))})}),n.jsx(Xs,{label:"Cap, in dollars",note:"Caps what the runs spend (each run, its look-back and its review). A row starts only when what is left covers it. Grades are counted in the cost but not capped.",hint:S?`Up to ${wo(_)} for ${a.rows.length} rows.`:void 0,children:n.jsx(Be,{inputMode:"decimal",value:h,onChange:T=>m(T.target.value),className:"max-w-40","aria-label":"Cap, in dollars"})}),n.jsx(uI,{columns:[...d,g].filter(Boolean),rows:a.rows.slice(0,3)})]}),k&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:k}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(K,{variant:"primary",disabled:!S||v,onClick:()=>void E(),children:v?"Starting":"Learn"}),n.jsx(K,{variant:"ghost",onClick:r,disabled:v,children:"Cancel"})]})]})}function uI({columns:e,rows:t}){return n.jsx("div",{className:"overflow-x-auto","aria-label":"The first rows",children:n.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.map(s=>n.jsx("th",{className:"caps border-b px-2 py-1 text-left font-semibold",children:s},s))})}),n.jsx("tbody",{children:t.map((s,r)=>n.jsx("tr",{children:e.map(a=>n.jsx("td",{className:"max-w-64 truncate border-b px-2 py-1",children:s[a]},a))},r))})]})})}const dI={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function fI({v2:e,agentId:t,batch:s,onBatch:r}){const[a,l]=x.useState(!1),[c,u]=x.useState(null),d=async()=>{l(!0),u(null);try{r(await e.cancelLearningBatch(t,s.id))}catch(y){u(y instanceof Error?y.message:String(y))}l(!1)},p=aI(s),g=s.cost_usd===null?"unknown":wo(s.cost_usd);return n.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ne,{tone:dI[s.status],children:s.status}),n.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),Kh(s)&&n.jsx(K,{size:"sm",variant:"destructive",disabled:a,onClick:()=>void d(),children:"Cancel"})]}),n.jsx("div",{className:"h-2 w-full bg-muted",role:"progressbar","aria-label":"Rows done","aria-valuemin":0,"aria-valuemax":s.total,"aria-valuenow":s.finished,children:n.jsx("div",{className:"h-full bg-primary",style:{width:`${s.total?s.finished/s.total*100:0}%`}})}),p&&n.jsx(_n,{tone:"warning",children:p}),s.status==="completed"&&n.jsx(_n,{tone:"success",children:"Every row ran. The results are below."}),c&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),n.jsxs("dl",{className:"grid grid-cols-2 gap-3 font-mono text-body sm:grid-cols-4",children:[n.jsx(fo,{label:"Right",value:`${s.right}`}),n.jsx(fo,{label:"Wrong",value:`${s.wrong}`}),n.jsx(fo,{label:"Failed",value:`${s.failed}`}),n.jsx(fo,{label:"Cost so far",value:`${g} of ${wo(s.max_cost_usd)}`}),n.jsx(fo,{label:"Notes learned",value:`${s.lessons.notes.length}`}),n.jsx(fo,{label:"Skills learned",value:`${s.lessons.skills.length}`}),n.jsx(fo,{label:"Workflow revisions",value:`${s.revisions.length}`}),n.jsx(fo,{label:"Paths",value:`${s.paths.agent} by hand, ${s.paths.handed_back} handed back, ${s.paths.workflow} workflow`})]}),s.lessons.notes.length+s.lessons.skills.length+s.lessons.workflows.length>0&&n.jsxs("p",{className:"text-body text-muted-foreground",children:["Learned: ",[...s.lessons.notes,...s.lessons.skills.map(y=>`${y} (skill)`),...s.lessons.workflows.map(y=>`${y} (workflow)`)].join(", "),"."]}),n.jsx("div",{className:"max-h-96 overflow-auto",children:n.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsx("tr",{children:["Row","Result","Path","Cost","Answer","Reference"].map(y=>n.jsx("th",{className:"caps sticky top-0 border-b bg-card px-2 py-1 text-left font-semibold",children:y},y))})}),n.jsx("tbody",{children:s.rows.map(y=>n.jsxs("tr",{"aria-current":s.current===y.n?"step":void 0,children:[n.jsx("td",{className:"border-b px-2 py-1",children:y.n}),n.jsx("td",{className:"border-b px-2 py-1",children:y.state==="done"?n.jsx(Ne,{tone:y.right?"success":"error",children:y.right?"right":"wrong"}):y.state==="failed"?n.jsx(Ne,{tone:"error",title:y.error,children:"failed"}):n.jsx(Ne,{tone:y.state==="running"?"active":"muted",children:y.state==="running"?"running":"waiting"})}),n.jsx("td",{className:"border-b px-2 py-1",children:y.path?iI[y.path]:""}),n.jsx("td",{className:"border-b px-2 py-1",children:y.total_usd==null?"":wo(y.total_usd)}),n.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:y.answer??void 0,children:y.answer??""}),n.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:y.reference,children:y.reference})]},y.n))})]})})]})}const fo=({label:e,value:t})=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:e}),n.jsx("dd",{className:"break-words",children:t})]}),mI="Run the agent on jobs it never learned from and record the counts: agentrun learning record-eval <agent> --body @eval.json (POST /v2/agents/{id}/learning/evals).",th=e=>`${Math.round(e*1e3)/10}%`;function pI(e){const{cost_per_task_usd:t,baseline_cost_per_task_usd:s}=e,r=t!==null&&s!==null,a=r&&t>0?s/t:null,[l,c]=e.ci;return{accuracy:th(e.accuracy),accuracyVs:`95% interval ${th(l)} to ${th(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?a===null||s===0?Vs(t):a>=1?`${Vh(a)} cheaper`:`${Vh(t/s)} the cost`:t!==null?Vs(t):"Not counted",costVs:r?`${Vs(t)} a task vs ${Vs(s)} by hand`:t!==null?`${Vs(t)} a task; by hand not counted`:"The test did not count the cost a task."}}function C0({v2:e,agentId:t,quiet:s=!1}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,d]=x.useState(0);return x.useEffect(()=>{let p=!0;return c(null),Promise.resolve().then(()=>e.learningEvals(t)).then(g=>{p&&a(g)},g=>{p&&c(g??new Error("unknown"))}),()=>{p=!1}},[e,t,u]),s&&!(r!=null&&r.latest)?null:l&&!r?n.jsx(Fn,{problem:hr(l,"the held-out test"),onRetry:()=>d(p=>p+1),className:""}):r?n.jsx(hI,{result:r.latest}):n.jsx(Kt,{className:"h-[116px] w-full"})}function hI({result:e}){return n.jsxs("section",{className:"min-w-0 border","aria-label":"Held-out test","data-testid":"held-out-test",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[n.jsx("h3",{className:"caps text-small font-semibold",children:"Held-out test"}),e&&n.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[e.n.toLocaleString("en-US")," jobs it never learned from · ",e.name," · ",ht(e.recorded_at),e.learned_revision?` · revision ${e.learned_revision.slice(0,7)}`:""]})]}),e?n.jsx(gI,{result:e}):n.jsxs("div",{className:"px-4 py-4",role:"status",children:[n.jsx("p",{className:"font-mono text-body",children:"Not measured yet."}),n.jsx("p",{className:"mt-1 max-w-prose text-body text-muted-foreground",children:mI})]})]})}function gI({result:e}){const t=pI(e),s=[{label:"Held-out accuracy",value:t.accuracy,lines:[t.accuracyVs]},{label:"Cost a task",value:t.cost,lines:[t.costVs]}];return n.jsxs(n.Fragment,{children:[n.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2",children:s.map((r,a)=>n.jsxs("div",{className:a?"border-t px-4 py-3 sm:border-l sm:border-t-0":"px-4 py-3",children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:r.label}),n.jsx("dd",{className:"mt-1 font-mono text-figure font-semibold tabular-nums",children:r.value}),r.lines.map(l=>n.jsx("dd",{className:"mt-0.5 font-mono text-small text-muted-foreground",children:l},l))]},r.label))}),e.label_source&&n.jsxs("p",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["Labels: ",e.label_source]})]})}const xI="http://www.w3.org/2000/svg",Ja=16,Gt=240,yI=40,bI=58,nh=16,sh=26,od=18,Za=14,T0=16,vI=26,wI=14,kI=22,Ns=14,R0=16,ad=16,jI=4,NI=10,SI=18,_I=30,$I=5,Ll=124,Yh=34,EI=4,rh=10*.6,CI=12.5*.6,ac=10.5*.6,A0=11*.6,Cx=9*.66,O0=10.5*.6,TI={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"},Tx=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Zd={review:"needs review","not-run":"",pending:""};function ut(e,t,...s){const r=document.createElementNS(xI,e);if(t)for(const[a,l]of Object.entries(t))r.setAttribute(a,String(l));for(const a of s)as(r,a);return r}function as(e,t){if(t!=null){if(Array.isArray(t)){for(const s of t)as(e,s);return}e.appendChild(typeof t=="string"?document.createTextNode(t):t)}}const dr=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,RI=(e,t)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=t?dr(e,t):`${dr(s[1],Math.max(2,t-s[2].length-1))} ${s[2]}`},bo=(e,t)=>Math.max(2,Math.floor(e/t)),So=(e,t)=>Math.ceil(e.length*t),$s=(e,t,s,r,a)=>ut("line",{x1:e,y1:t,x2:s,y2:r,class:a?`wire ${a}`:"wire"});function IS(e){const t={},s={};for(const a of e)t[a.path]=a;const r=a=>{var l;return((l=t[a])==null?void 0:l.kind)??""};for(const a of e){let l;const c={node:a,order:0,name:null};let u=null;(l=/^(.*)\/steps\/(\d+)$/.exec(a.path))&&r(l[1])==="chain"?(u=l[1],c.order=Number(l[2])):(l=/^(.*)\/branches\/([^/]*)\/body$/.exec(a.path))&&r(l[1])==="route"?(u=l[1],c.name=l[2].replace(/~1/g,"/").replace(/~0/g,"~")):(l=/^(.*)\/branches\/(\d+)$/.exec(a.path))&&r(l[1])==="parallel"?(u=l[1],c.order=Number(l[2])):((l=/^(.*)\/body$/.exec(a.path))&&(r(l[1])==="map"||r(l[1])==="loop")||(l=/^(.*)\/workflow\/root$/.exec(a.path))&&r(l[1])==="workflow")&&(u=l[1]),u!==null&&(s[u]??(s[u]=[])).push(c)}for(const a of Object.values(s))a.sort((l,c)=>l.order-c.order);return{byPath:t,kids:s}}function Rx(e,t){var d,p,g,y;const{diff:s={},status:r={},fired:a}=e.marks,l=t===a?"escalated":r[t],c=l&&Tx.has(l)?l:"",u=(d=s.added)!=null&&d.includes(t)?"NEW":(p=s.edited)!=null&&p.includes(t)?"EDITED":(g=s.moved)!=null&&g.includes(t)?"MOVED":"";return{state:c,tag:u,fired:t===a,selected:((y=e.marks.selected)==null?void 0:y.path)===t&&e.marks.selected.item==null}}function Cc(e,t,s){var h,m,v;const r=Rx(e,t.path),a=(h=e.marks.meta)==null?void 0:h[t.path],l=a!=null&&a.tool?_c(a.tool):null,c=(m=e.marks.ran)==null?void 0:m[t.path],u=a!=null&&a.decision?(c==null?void 0:c.model)??a.model:a==null?void 0:a.model;let d=`${t.label} (${t.kind}${l?`: ${l.tool} on ${l.server}, an MCP server's tool`:t.via?` via ${t.via}`:""}${a!=null&&a.provider?`, ${a.provider}${u?` ${u}`:""}`:""}${c&&!(a!=null&&a.decision)?`, ${WN(c)}`:""})`;r.state&&(d+=`: ${r.state.replace("-"," ")}`),r.tag&&(d+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(v=a==null?void 0:a.questions)!=null&&v.length&&(d+=`
552
+ ${a.questions.map(w=>`• ${w.text}`).join(`
553
+ `)}`);const p=a!=null&&a.decision&&a.provider?`who-${a.provider==="parallel"||a.provider==="openrouter"?a.provider:"jev"}`:t.kind==="route"&&a&&!a.decision?"who-control":`who-${TI[t.kind]??"code"}`;let g=`node ${s} ${p}`;r.state&&(g+=` ${r.state}`),r.fired&&(g+=" fired"),r.tag&&(g+=` ${r.tag.toLowerCase()}`),r.selected&&(g+=" selected");const y=ut("g",{class:g,"data-path":t.path},ut("title",null,d));return e.svg.appendChild(y),y}const mi=e=>So(e,Cx)+10;function vd(e,t,s,r,a="tag"){const l=mi(r);return as(e,[ut("rect",{x:t,y:s,width:l,height:13,class:`${a}-box`}),ut("text",{x:t+l/2,y:s+9.5,class:a,"text-anchor":"middle"},r)]),l}const AI=(e,t)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[t.path])!=null&&r.decision)},Pf=(e,t)=>AI(e,t)?bI:yI;function Ax(e,t,s,r,a){var N,A,_,S,E;const l=Rx(e,s.path),c=(N=e.marks.meta)==null?void 0:N[s.path],u=Pf(e,s),d=(A=e.marks.verdict)==null?void 0:A[s.path],p=l.state in Zd?Zd[l.state]:l.state,g=((_=c==null?void 0:c.questions)==null?void 0:_.length)??0,y=c!=null&&c.tool?_c(c.tool):null,h=(S=e.marks.ran)==null?void 0:S[s.path],m=(h&&!(c!=null&&c.decision)?dx(s.kind,h):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"}`:""),v=[(E=c==null?void 0:c.images)!=null&&E.length?"IMG":"",c!=null&&c.web?"WEB":"",y?"MCP":""].filter(Boolean),w=v.reduce((T,C)=>T+mi(C)+4,0);l.selected&&t.appendChild(ut("rect",{x:r-4,y:a-4,width:Gt+8,height:u+8,class:"sel"})),as(t,[ut("rect",{x:r,y:a,width:Gt,height:u,class:"box"}),ut("rect",{x:r+10,y:a+9,width:8,height:8,class:"swatch"}),ut("text",{x:r+24,y:a+17,class:"label"},dr(s.label,bo(Gt-34-w,CI))),ut("text",{x:r+24,y:a+31,class:"kind"},dr(m,bo(Gt-34-(p?So(p,Cx)+8:0),ac))),p?ut("text",{x:r+Gt-10,y:a+31,class:"state","text-anchor":"end"},p):null]);let k=r+Gt-8;for(const T of v.reverse())k-=mi(T),vd(t,k,a+7,T,"badge"),k-=4;if(c!=null&&c.decision&&c.provider){const T=vd(t,r+24,a+38,c.provider,"chip"),C=d?RI(d,bo(Gt-44-T-20,O0)):"",R=Gt-40-T-(C?So(C,O0)+10:0),D=(h==null?void 0:h.model)??c.model;D&&R>24&&t.appendChild(ut("text",{x:r+24+T+6,y:a+47.5,class:"model"},dr(D,bo(R,ac)))),C&&t.appendChild(ut("text",{x:r+Gt-10,y:a+47.5,class:"verdict","text-anchor":"end"},C))}else d&&t.appendChild(ut("text",{x:r+Gt-10,y:a+17,class:"verdict","text-anchor":"end"},d));l.tag&&vd(t,r+Gt-mi(l.tag),a-7,l.tag)}function OI(e,t){return{w:Gt,h:Pf(e,t),cx:Gt/2,place:(s,r)=>Ax(e,Cc(e,t,"card"),t,s,r)}}function zS(e,t,s){const r=Rx(e,t.path),a=r.state==="done"?"passed":r.state in Zd?Zd[r.state]:r.state,l=dr(t.label===t.kind?"exit":`exit: ${t.label}`,40),c=So(l,ac)+16;return{w:Za+c+(r.tag?6+mi(r.tag):0)+(a?6+So(a,Cx):0),h:sh,cx:0,exit:!0,place:(u,d)=>{const p=Cc(e,t,"exit"),g=d+sh/2;let y=u+Za+c;s&&p.appendChild($s(u,d,u,d+sh,"spine")),r.selected&&p.appendChild(ut("rect",{x:u+Za-3,y:g-od/2-3,width:c+6,height:od+6,class:"sel"})),as(p,[$s(u,g,u+Za,g,"exit-wire"),ut("rect",{x:u+Za,y:g-od/2,width:c,height:od,class:"exit-box"}),ut("text",{x:u+Za+8,y:g+3.5,class:"exit-text"},l)]),r.tag&&(vd(p,y+6,g-6.5,r.tag),y+=6+mi(r.tag)),a&&p.appendChild(ut("text",{x:y+6,y:g+3.5,class:"state"},a))}}}function MI(e,t,s){const r=s.map(u=>u.node.kind==="escalate"?zS(e,u.node,!1):If(e,u.node));let a=Gt/2,l=Gt/2,c=-nh;for(const u of r)a=Math.max(a,u.cx),l=Math.max(l,u.w-u.cx),c+=u.h+nh;return{w:a+l,h:c,cx:a,place:(u,d)=>{const p=Cc(e,t,"chain"),g=u+a;let y=d,h=null;r.forEach((m,v)=>{v&&(y+=nh),m.exit?h===null&&(h=y):h!==null&&p.appendChild($s(g,h,g,y,"spine")),m.place(m.exit?g:g-m.cx,y),y+=m.h,m.exit||(h=y)}),r[r.length-1].exit&&h!==null&&p.appendChild($s(g,h,g,y,"spine"))}}}function LI(e,t,s){const r=Pf(e,t),a=s.map(m=>({kid:m,box:If(e,m.node),x:0,c:0}));let l=0,c=0;a.forEach((m,v)=>{v&&(l+=kI),m.x=l,m.c=l+m.box.cx,l+=m.box.w,c=Math.max(c,m.box.h)});const u=a.length-1,d=Math.round((a[0].c+a[u].c)/2),p=Math.min(0,d-Gt/2),g=Math.max(l,d+Gt/2),y=r+T0+vI,h=y+c+wI;return{w:g-p,h,cx:d-p,place:(m,v)=>{const w=Cc(e,t,"card"),k=m-p,N=v+r+T0,A=v+h;Ax(e,w,t,k+d-Gt/2,v),w.appendChild($s(k+d,v+r,k+d,N)),u&&as(w,[$s(k+a[0].c,N,k+a[u].c,N),$s(k+a[0].c,A,k+a[u].c,A)]),a.forEach((_,S)=>{const E=k+_.c,T=_.kid.node.path,C=e.taken.has(T);if(w.appendChild(ut("line",{x1:E,y1:N,x2:E,y2:v+y,class:C?"wire branch taken":"wire branch","data-to":T})),_.kid.name!==null){const R=(S<u?a[S+1].c-6:_.x+_.box.w)-_.c-12,D=dr(_.kid.name,bo(R,ac)),L=ut("text",{x:E+6,y:N+15,class:C?"branch-name taken":"branch-name"},D);w.appendChild(D===_.kid.name?L:ut("g",null,ut("title",null,_.kid.name),L))}w.appendChild($s(E,v+y+_.box.h,E,A,C?"taken":void 0)),_.box.place(k+_.x,v+y)})}}}const PI=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function II(e,t,s,r,a,l){const c=Tx.has(s.status)?s.status:"pending",u=s.label?PI(s.label):`#${s.index+1}`,d=s.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),p=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=ut("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${l?" picked":""}`,"data-path":t.path,"data-item":s.index},ut("title",null,g),ut("rect",{x:r,y:a,width:Ll,height:Yh,class:"cell"}),ut("rect",{x:r,y:a,width:3,height:Yh,class:"cell-edge"}),ut("text",{x:r+9,y:a+14,class:"cell-name"},dr(u,bo(Ll-14,rh))),ut("text",{x:r+9,y:a+27,class:"cell-out"},dr(d,bo(Ll-18-(p?So(p,rh)+6:0),rh))),p?ut("text",{x:r+Ll-6,y:a+27,class:"cell-p","text-anchor":"end"},p):null);e.appendChild(y)}function zI(e,t){var k;const s=((k=e.marks.items)==null?void 0:k[t.path])??[];if(!s.length)return null;const r=s.length<=_I,[a,l,c]=r?[Ll,Yh,EI]:[ad,ad,jI],u=Math.min(s.length,r?$I:NI),d=Math.ceil(s.length/u),p=u*(a+c)-c,g=d*(l+c)-c+SI+(r?4:0),y={};for(const N of s)y[N.status]=(y[N.status]??0)+1;const h={};for(const N of s)N.outcome&&(h[N.outcome]=(h[N.outcome]??0)+1);const m=Object.entries(h).map(([N,A])=>`${A} ${N}`),w=[`${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`:"",...m].filter(Boolean).join(" · ");return{w:Math.max(p,So(w,ac)),h:g,place:(N,A,_)=>{const S=A-p/2,E=e.marks.selected;s.forEach((T,C)=>{const R=S+C%u*(a+c),D=_+Math.floor(C/u)*(l+c),L=Tx.has(T.status)?T.status:"pending",O=(E==null?void 0:E.path)===t.path&&E.item===T.index;if(r){II(N,t,T,R,D,O);return}as(N,ut("rect",{x:R,y:D,width:ad,height:ad,class:`cell ${L}${O?" picked":""}`,"data-path":t.path,"data-item":T.index},ut("title",null,`#${T.index+1}${T.label?` ${T.label}`:""}: ${L==="review"?"needs review":L.replace("-"," ")}`)))}),as(N,ut("text",{x:A,y:_+g-4,class:"caption","text-anchor":"middle"},w))}}}function DI(e,t,s){const r=If(e,s),a=Pf(e,t),l=t.kind==="map"?zI(e,t):null,c=l?l.h+Ns:0,u=Math.max(Gt/2,r.cx,l?l.w/2:0)+Ns,d=Math.max(Gt/2,r.w-r.cx,l?l.w/2:0)+Ns,p=a+Ns+c+r.h+Ns;return{w:u+d,h:p,cx:u,place:(g,y)=>{const h=Cc(e,t,"card"),m=g+u;if(as(h,ut("rect",{x:g,y:y+a/2,width:u+d,height:p-a/2,class:"frame"})),l?(as(h,$s(m,y+a,m,y+a+Ns)),as(h,$s(m,y+a+Ns+l.h,m,y+a+Ns+c))):as(h,$s(m,y+a,m,y+a+Ns)),as(h,$s(m,y+a+Ns+c+r.h,m,y+p)),Ax(e,h,t,m-Gt/2,y),l){const v=ut("g",{class:"items"});l.place(v,m,y+a+Ns),h.appendChild(v)}r.place(m-r.cx,y+a+Ns+c)}}}function DS(e,t){return e.kind==="escalate"?"exit":t.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function If(e,t){const s=e.kids[t.path]??[],r=DS(t,s);return r==="exit"?zS(e,t,!0):r==="leaf"?OI(e,t):r==="chain"?MI(e,t,s):r==="fan"?LI(e,t,s):DI(e,t,s[0].node)}function Ox(e){const{byPath:t,kids:s}=IS(FS(e)),r=a=>{const l=s[a.path]??[],c=DS(a,l),u=c==="frame"?r(l[0].node):c==="chain"||c==="fan"?l.reduce((d,p)=>d+r(p.node),0):0;return(c==="chain"?0:1)+u};return t["/root"]?r(t["/root"]):0}const zf=e=>`${e} ${e===1?"node":"nodes"}`,FS=e=>(e&&Array.isArray(e.nodes)?e.nodes:[]).filter(t=>t&&typeof t.path=="string"&&typeof t.kind=="string").map(t=>({path:t.path,kind:t.kind,label:String(t.label??t.kind),via:typeof t.via=="string"?t.via:""}));function FI(e,t,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=IS(FS(t)),a=(y,h)=>(e.setAttribute("viewBox",`0 0 ${y} ${h}`),e.setAttribute("width",String(y)),e.setAttribute("height",String(h)),e.style.setProperty("min-width",`${Math.min(y,480)}px`),{w:y,h});if(!r.byPath["/root"])return a(0,0);const l={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=If(l,r.byPath["/root"]);c.place(Ja,Ja);let u=c.w,d=c.h;const p=(((g=s.diff)==null?void 0:g.removed)??[]).map(y=>`${y.label} (${y.kind})`);if(p.length){const y=["Removed:",...p.map(m=>dr(m,bo(Math.max(u,300),A0)))],h=ut("g",{class:"removed-list"},ut("title",null,`Removed: ${p.join(", ")}`));y.forEach((m,v)=>{h.appendChild(ut("text",{x:Ja,y:Ja+d+33+v*R0,class:"removed"},m)),u=Math.max(u,So(m,A0))}),e.appendChild(h),d+=22+y.length*R0}return a(u+2*Ja,d+2*Ja)}function UI(e){var a,l;const t=e,s=(a=t==null?void 0:t.closest)==null?void 0:a.call(t,"[data-item]");if(s)return{path:s.getAttribute("data-path"),item:Number(s.getAttribute("data-item"))};const r=(l=t==null?void 0:t.closest)==null?void 0:l.call(t,"g[data-path]");return!r||r.classList.contains("chain")?null:{path:r.getAttribute("data-path"),item:null}}const WI=1600;function Tc({graph:e,marks:t,onSelect:s,className:r,label:a="Workflow graph",minScale:l=.8,maxScale:c=1.3}){const u=x.useRef(null),[d,p]=x.useState({w:0,h:0}),[g,y]=x.useState(0),h=x.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,t??null]),[e,t]);x.useEffect(()=>{if(!u.current)return;const v=FI(u.current,e,t);p(w=>w.w===v.w&&w.h===v.h?w:v),u.current.style.setProperty("--wf-phase",`-${Date.now()%WI}ms`)},[h]),x.useEffect(()=>{var k;const v=(k=u.current)==null?void 0:k.parentElement;if(!v||typeof ResizeObserver>"u")return;const w=new ResizeObserver(([N])=>y(N.contentRect.width));return w.observe(v),()=>w.disconnect()},[]);const m=d.w&&g?Math.min(c,Math.max(l,g/d.w)):1;return n.jsx("svg",{ref:u,role:"img","aria-label":a,className:ie("wf select-none",r),style:d.w?{width:d.w*m,height:d.h*m,maxWidth:"none",minWidth:0}:void 0,onClick:v=>{const w=UI(v.target);w&&s&&s(w)}})}function Rc({run:e=!1}){const t=[["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 n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 font-mono text-label text-muted-foreground",children:[t.map(([r,a])=>n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block size-2",style:{background:r}}),a]},a)),e&&n.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&s.map(([r,a])=>n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:ie("inline-block size-2.5 border",r)}),a]},a))]})}const US={self:"self",jev:"jev",both:"self+jev"},HI=e=>`${US[e.signal]} ≥${e.threshold.toFixed(2)}`,BI=(e,t)=>t?`${Math.round(e/t*100)}%`:"0%";function GI({guards:e,workflow:t,digest:s,loop:r}){return e.length?n.jsxs("section",{className:"border","aria-label":"Where it is unsure","data-testid":"step-guards",children:[n.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-3 py-2",children:[n.jsx("h3",{className:"caps text-label font-semibold",children:"Where it is unsure"}),n.jsx("p",{className:"text-small text-muted-foreground",children:"Each guarded step hands the run back to the agent when its p is under the threshold."})]}),n.jsx("ul",{className:"divide-y",children:e.map(a=>n.jsx(qI,{guard:a,stats:KP(r,t,s,a.node)},a.node))}),n.jsx(KI,{})]}):null}function qI({guard:e,stats:t}){const s=(t==null?void 0:t.right)??0,r=(t==null?void 0:t.wrong)??0,a=(t==null?void 0:t.replays)??0,l=(t==null?void 0:t.grades_past)??0,c=s+r?` · graded ${s} right, ${r} wrong`:l?"":" · none graded",u=l?` · ${l} older ${l===1?"run's grade is":"runs' grades are"} past the newest grades kept`:"";return n.jsxs("li",{className:"grid grid-cols-1 gap-x-4 gap-y-2 px-3 py-2.5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center","data-testid":"guard-row",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"min-w-0 break-words font-mono text-body font-semibold",children:e.node}),n.jsx(Ne,{tone:"plain",title:`Reads ${qP[e.signal]}`,children:US[e.signal]}),n.jsxs(Ne,{tone:"muted",children:[e.fitted?"fitted":"threshold"," ",e.threshold.toFixed(2)]})]}),n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:t&&t.runs?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:ie("font-semibold",t.escalated/t.runs>.25?"text-warning-text":"text-foreground"),children:[BI(t.escalated,t.runs)," handed back"]})," (",t.escalated," of ",t.runs," runs)",c,u,a?` · ${a} replay ${a===1?"run":"runs"} apart`:""]}):a?`Replayed on ${a} graded ${a===1?"input":"inputs"}; no run served yet.`:"No run of this revision yet."})]}),t&&t.points.length>0&&n.jsx(VI,{guard:e,stats:t})]})}const mo=168,or=36,M0=2;function VI({guard:e,stats:t}){const s=VP(t.points),r=Math.max(1,...s.map(u=>u.right+u.wrong+u.ungraded)),a=mo/s.length,l=u=>Math.min(mo-1,Math.max(1,u*mo)),c=s.filter(u=>u.right+u.wrong+u.ungraded).map(u=>`p ${u.from.toFixed(1)} to ${u.to.toFixed(1)}: ${[u.right&&`${u.right} right`,u.wrong&&`${u.wrong} wrong`,u.ungraded&&`${u.ungraded} not graded`].filter(Boolean).join(", ")}`);return n.jsxs("figure",{className:"m-0 shrink-0","data-testid":"guard-histogram",children:[n.jsxs("svg",{width:mo,height:or+14,className:"block font-mono","aria-hidden":!0,children:[s.map(u=>{let d=or;const p=[[u.right,"fill-success"],[u.wrong,"fill-destructive"],[u.ungraded,"fill-muted-foreground"]];return n.jsxs("g",{children:[n.jsx("title",{children:`p ${u.from.toFixed(1)}–${u.to.toFixed(1)}: ${u.right} right, ${u.wrong} wrong, ${u.ungraded} not graded`}),n.jsx("rect",{x:u.from*mo,y:0,width:a,height:or,className:"fill-card",fillOpacity:0}),p.map(([g,y])=>{if(!g)return null;const h=g/r*(or-2);d-=h;const m=d>.5&&d+h<or-.5?1:0;return n.jsx("rect",{x:u.from*mo+M0/2,y:d+m,width:a-M0,height:Math.max(1,h-m),className:y,fillOpacity:y==="fill-muted-foreground"?.45:.85},y)})]},u.from)}),n.jsx("path",{d:`M0,${or+.5}H${mo}`,className:"stroke-border-strong",strokeWidth:1}),n.jsx("path",{d:`M${l(e.threshold)},0V${or+3}`,className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"}),n.jsx("text",{x:0,y:or+12,className:"fill-muted-foreground text-micro",children:"0"}),n.jsx("text",{x:mo,y:or+12,textAnchor:"end",className:"fill-muted-foreground text-micro",children:"1"}),n.jsx("text",{x:l(e.threshold),y:or+12,textAnchor:"middle",className:"fill-foreground text-micro font-semibold",children:e.threshold.toFixed(2)})]}),t.points.length<t.runs&&n.jsxs("p",{className:"m-0 font-mono text-micro text-muted-foreground",children:["p of the newest ",t.points.length," runs"]}),n.jsx("figcaption",{className:"sr-only",children:`${e.node}: p by run${t.points.length<t.runs?`, the newest ${t.points.length} of ${t.runs}`:""}. ${c.join(". ")}.`})]})}function KI(){const e=[["Right","fill-success",.85],["Wrong","fill-destructive",.85],["Not graded","fill-muted-foreground",.45]];return n.jsxs("p",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 font-mono text-label text-muted-foreground",children:[n.jsx("span",{className:"caps",children:"p by run"}),e.map(([t,s,r])=>n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:n.jsx("rect",{width:"10",height:"10",className:s,fillOpacity:r})}),t]},t)),n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"12",height:"10","aria-hidden":!0,children:n.jsx("path",{d:"M6,0V10",className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"})}),"Threshold"]}),n.jsx("span",{children:"A missing signal counts as 0 and hands back."})]})}const oh=e=>{const t=[...new Set(e)],s=t.slice(0,3).map(r=>`"${r}"`).join(", ");return t.length>3?`${s} and ${t.length-3} more`:s},L0=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function YI(e,t,s,r,a){const l=[e.length&&`added ${L0(e.length,"node")} (${oh(e)})`,t.length&&`edited ${oh(t)}`,s.length&&`removed ${L0(s.length,"node")} (${oh(s)})`].filter(Boolean);if(!l.length)return r?"Nodes reordered":a?"Connections changed":"No node changed";const c=l.join(", ");return c.charAt(0).toUpperCase()+c.slice(1)}function XI(e){const t=[];let s=null,r=0;for(const a of e){let l=null,c=null;try{l=a.text===null?null:JSON.parse(a.text),c=l===null?null:hi(l)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const u=s?Ck(s,c):null,d=u?u.added.map(N=>N.path):c.nodes.map(N=>N.path),p=N=>{var A;return((A=c.nodes.find(_=>_.path===N))==null?void 0:A.kind)!=="chain"},g=u?[...u.changed.map(N=>N.next),...u.rewritten.map(N=>N.next)]:[],y=u?u.moved.map(N=>N.next):[],h=new Map(c.nodes.map(N=>[N.path,N.label])),m=u?u.removed.filter(N=>N.kind!=="chain").map(N=>N.label):[],v=u?u.edges.added.length+u.edges.removed.length:0,w=GP(a.text),k=Object.fromEntries(w.flatMap(N=>c.nodes.some(A=>A.path===N.path)?[[N.node,N.path]]:[]));t.push({digest:a.digest??null,guards:w,guardPaths:k,commit:a.commit,at:a.at,run:"run"in a.by?a.by.run:null,reason:a.reason,graph:c,marks:{meta:vc(l,c),diff:{added:d,edited:g,moved:y,removed:u?u.removed.map(({label:N,kind:A})=>({label:N,kind:A})):[]}},added:d,edited:g,removed:m,line:u?YI(d.filter(p).map(N=>h.get(N)??N),g.filter(p).map(N=>h.get(N)??N),m,y.length,v):`First version: ${zf(Ox(c))}`}),s=c}return{steps:t,unreadable:r}}const QI=50,JI=1800;function ZI({v2:e,agentId:t,workflows:s,promotions:r=[],serving:a=[],loop:l=null,cost:c=null}){const u=s.filter(y=>y.status==="active").map(y=>y.name),[d,p]=x.useState(null),g=d!==null&&u.includes(d)?d:u[0]??null;return g===null?null:n.jsx(ez,{v2:e,agentId:t,name:g,choices:u,onPick:p,promotions:r,serving:a,loop:l,stopped:Ex(c,g)},g)}const id="Learned workflow";function ez({v2:e,agentId:t,name:s,choices:r,onPick:a,promotions:l,serving:c,loop:u,stopped:d}){var k;const[p,g]=x.useState(null),[y,h]=x.useState(null),[m,v]=x.useState(0);x.useEffect(()=>{let N=!0;return h(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(t,s,QI)).then(A=>{N&&g(A)},A=>{N&&h(A??new Error("unknown"))}),()=>{N=!1}},[e,t,s,m]);const w=n.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[n.jsxs("h2",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"caps text-small font-semibold",children:id})," ",n.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&n.jsx(Lt,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:a,options:r.map(N=>({value:N,label:N}))})]});return y&&!p?n.jsxs("section",{className:"border","aria-label":id,children:[w,n.jsx("div",{className:"p-4",children:n.jsx(Fn,{problem:hr(y,"the learned workflow"),onRetry:()=>v(N=>N+1),className:""})})]}):p?n.jsxs("section",{className:"border","aria-label":id,children:[w,n.jsx(tz,{data:p,promotions:l,serving:((k=c.find(N=>N.workflow===p.name))==null?void 0:k.digest)??null,loop:u,stopped:d})]}):n.jsxs("section",{className:"border","aria-label":id,"aria-busy":!0,children:[w,n.jsx("div",{className:"p-4",children:n.jsx(Kt,{className:"h-48 w-full"})})]})}function tz({data:e,stepMs:t=JI,promotions:s=[],serving:r=null,loop:a=null,stopped:l=null}){const{steps:c,unreadable:u}=x.useMemo(()=>XI(e.revisions),[e.revisions]),[d,p]=x.useState(Math.max(0,c.length-1)),[g,y]=x.useState(!1);if(x.useEffect(()=>{p(Math.max(0,c.length-1)),y(!1)},[c]),x.useEffect(()=>{if(!g)return;const T=setInterval(()=>p(C=>Math.min(C+1,c.length-1)),t);return()=>clearInterval(T)},[g,c.length,t]),x.useEffect(()=>{g&&d>=c.length-1&&y(!1)},[g,d,c.length]),!e.revisions.length)return null;if(!c.length)return n.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",u?`: ${u} ${u===1?"revision":"revisions"} did not read`:"","."]});const h=c[Math.min(d,c.length-1)],m=c.length,v=T=>{y(!1),p(Math.max(0,Math.min(m-1,T)))},w=()=>{if(g)return y(!1);d>=m-1&&p(0),y(!0)},k=`Revision ${Math.min(d,m-1)+1} of ${m}, ${ht(h.at)}`,N=$x(s,e.name,h.digest),A=OS(s,e.name,h.digest),_=oc(N,{serving:r,refit:A,stopped:l}),S=h.guards.length?{...h.marks,verdict:Object.fromEntries(h.guards.flatMap(T=>h.guardPaths[T.node]?[[h.guardPaths[T.node],HI(T)]]:[]))}:h.marks,E=(N==null?void 0:N.source)==="refit"&&N.refit?N.refit:null;return n.jsxs("div",{className:"space-y-3 p-4",children:[m>1&&n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsxs(K,{size:"sm",onClick:w,"aria-label":g?"Pause the replay":"Play the replay","aria-pressed":g,children:[g?n.jsx(xi,{"aria-hidden":!0}):n.jsx(_i,{"aria-hidden":!0}),g?"Pause":"Play"]}),n.jsx(K,{size:"icon",onClick:()=>v(d-1),disabled:d<=0,"aria-label":"Previous revision",children:n.jsx(Q$,{"aria-hidden":!0})}),n.jsx(K,{size:"icon",onClick:()=>v(d+1),disabled:d>=m-1,"aria-label":"Next revision",children:n.jsx(cs,{"aria-hidden":!0})}),n.jsx(I4,{min:1,max:m,value:d+1,onChange:T=>v(T-1),label:"Revision",valueText:k,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[n.jsx("span",{children:m>1?`Revision ${d+1} of ${m}`:"One revision"})," · ",n.jsx("time",{dateTime:h.at,children:ht(h.at)})," · ",h.run?n.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",Co(h.run)]}):"a person"]}),n.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:h.line}),h.reason&&n.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:h.reason}),n.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-body","data-testid":"standing",children:[n.jsx(Ne,{tone:_.tone,children:_.text}),n.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:A?`Its thresholds were refit: revision ${A.digest.slice(0,7)} serves in its place.`:N?oa(N):h.digest?"No replay yet: a new revision replays on the last graded inputs before it serves.":"Its file did not read: no standing."})]}),E&&n.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground","data-testid":"refit",children:N==null?void 0:N.reason})]}),n.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:n.jsx(Tc,{graph:h.graph,marks:S,label:`The workflow at revision ${d+1} of ${m}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Rc,{}),n.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[n.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",n.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed",h.guards.length?n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"font-semibold text-foreground",children:"jev ≥0.70"})," the step's guard: its signal and threshold"]}):null]})]}),n.jsx(GI,{guards:h.guards,workflow:e.name,digest:h.digest,loop:a}),(e.total>e.revisions.length||e.truncated||u>0)&&n.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. ",u>0&&`${u} ${u===1?"revision":"revisions"} could not be read as a workflow and ${u===1?"is":"are"} left out.`]})]})}const P0=8,nz={promote:"success",hold:"warning",refit:"plain",revision:"active",superseded:"muted"};function I0({loop:e,promotions:t,serving:s=[],cost:r=null}){const[a,l]=x.useState(!1),c=[...((e==null?void 0:e.compiles)??[]).map(d=>({at:d.at,key:`c:${d.run_id}:${d.round}`,kind:"compile",compile:d})),...t.map((d,p)=>({at:d.at,key:`p:${p}`,kind:"promotion",record:d}))].sort((d,p)=>Date.parse(p.at)-Date.parse(d.at));if(!c.length)return null;const u=a?c:c.slice(0,P0);return n.jsxs("section",{className:"border","aria-label":"Learning feed","data-testid":"loop-feed",children:[n.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b px-4 py-3 text-small font-semibold",children:["Learning feed",n.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:c.length})]}),n.jsx("ol",{className:"divide-y",children:u.map(d=>{var p;return n.jsx("li",{className:"min-w-0 px-4 py-3","data-testid":`feed-${d.kind}`,children:d.kind==="compile"?n.jsx(rz,{compile:d.compile,promotions:t,serving:((p=s.find(g=>g.workflow===d.compile.workflow))==null?void 0:p.digest)??null,stopped:d.compile.workflow?Ex(r,d.compile.workflow):null}):n.jsx(oz,{record:d.record})},d.key)})}),c.length>P0&&n.jsx("div",{className:"flex justify-center border-t px-4 py-2",children:n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>l(d=>!d),children:a?"Show fewer":`Show all ${c.length}`})})]})}const sz=({id:e})=>n.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",Co(e)]}),WS=({at:e,run:t})=>n.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[n.jsx("time",{dateTime:e,children:ht(e)}),t?n.jsxs(n.Fragment,{children:[" · ",n.jsx(sz,{id:t})]}):null]});function rz({compile:e,promotions:t,serving:s,stopped:r}){const a=e.digest===null||e.workflow===null,l=e.attempts.filter(d=>!d.ok),c=[...e.attempts.flatMap((d,p)=>d.ok?[]:d.errors.map(g=>({e:g,attempt:p+1}))),...e.draft_errors.map(d=>({e:d,attempt:null}))],u=a?null:oc($x(t,e.workflow,e.digest),{serving:s,refit:OS(t,e.workflow,e.digest),stopped:r});return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a?n.jsx(Ne,{tone:"error",children:"Draft failed"}):n.jsx(Ne,{tone:"plain",children:"Compiled"}),e.workflow?n.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}):n.jsx("span",{className:"text-body text-muted-foreground",children:"no workflow kept"}),u&&n.jsx(Ne,{tone:u.tone,children:u.text})]}),e.from_notes.length>0&&n.jsxs("p",{className:"mt-1 break-words text-small text-muted-foreground",children:["From ",e.from_notes.length===1?"1 note":`${e.from_notes.length} notes`,": ",n.jsx("span",{className:"font-mono text-foreground",children:e.from_notes.join(", ")})]}),e.attempts.length>0&&n.jsxs("p",{className:"mt-0.5 text-small text-muted-foreground",children:[e.attempts.length===1?"1 attempt":`${e.attempts.length} attempts`,l.length?`, ${l.length} refused by the checks`:"",a?": it tries again on a later run.":"."]}),e.withheld?n.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&&n.jsx("ul",{className:"mt-1 space-y-0.5","aria-label":"What the checks said","data-testid":"draft-errors",children:c.map(({e:d,attempt:p},g)=>n.jsxs("li",{className:"break-words font-mono text-small text-destructive-text",children:[p?`Attempt ${p}: `:"",d]},g))}),n.jsx(WS,{at:e.at,run:e.run_id})]})}function oz({record:e}){var a;const t=RS(e),s=oc(e,{serving:e.digest}),r=t==="promote"?s.tone:nz[t];return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(Ne,{tone:r,children:[_x[t]," · ",Wl[t],s.proof?` · ${s.proof}`:""]}),n.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:e.digest.slice(0,7)})]}),n.jsx("p",{className:"mt-1 break-words text-small text-muted-foreground",children:oa(e)}),(a=e.replay)!=null&&a.n?e.reason&&n.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-small text-muted-foreground",children:e.reason}):null,n.jsx(WS,{at:e.at})]})}const az={done:{icon:uc,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:Z$,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:tE,word:"Later",ink:"text-muted-foreground",edge:"border-t-border"},warn:{icon:Zs,word:"Look",ink:"text-warning-text",edge:"border-t-warning"},watch:{icon:hg,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function z0({stages:e}){return e.length?n.jsx("section",{className:"border","aria-label":"The learning loop","data-testid":"loop-story",children:n.jsx("ol",{className:ie("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((t,s)=>{const r=az[t.state],a=r.icon;return n.jsxs("li",{"data-testid":`stage-${t.key}`,"data-state":t.state,className:ie("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:[n.jsxs("p",{className:"flex items-center gap-1.5 font-mono text-label",children:[n.jsxs("span",{className:"caps text-muted-foreground",children:[s+1," · ",t.title]}),n.jsxs("span",{className:ie("ml-auto inline-flex items-center gap-1",r.ink),children:[n.jsx(a,{className:"size-3.5","aria-hidden":!0}),n.jsx("span",{className:"caps",children:r.word})]})]}),n.jsx("p",{className:"mt-1 break-words font-mono text-lead font-semibold","data-testid":`stage-${t.key}-value`,children:t.value}),n.jsx("p",{className:"mt-0.5 break-words text-small text-muted-foreground",children:t.detail})]},t.key)})})}):null}function HS({id:e,checked:t,onChange:s,busy:r,disabled:a,quiet:l,server:c,problem:u,className:d}){return n.jsxs("div",{className:ie("space-y-2",d),children:[n.jsxs("div",{className:ie("flex gap-4",l?"items-center":"items-start"),children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{id:e,className:"text-lead font-semibold",children:"Learns from its runs"}),!l&&n.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:"After each run, it looks back and keeps a short note when something will help next time; later runs read them first."})]}),n.jsx(xN,{checked:t,onChange:s,busy:r,disabled:a,labelledBy:e})]}),c==="off"&&n.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."}),u]})}function iz({fields:e,onFields:t,saved:s,server:r,error:a,warning:l}){const c=e.learning??s,u=c===!0||c==="notes",d=p=>t({learning:p===!1&&s===void 0?void 0:p});return n.jsxs("div",{children:[n.jsx("div",{className:"mb-2",children:n.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),n.jsx(HS,{id:"learning-switch",className:"border px-4 py-3",checked:u,server:r,onChange:p=>d(p?s==="notes"?"notes":!0:!1)}),u&&n.jsx("fieldset",{"aria-label":"What it learns",className:"mt-2 space-y-2",children:[[!0,"Notes, skills and workflows","Once a job repeats, it can learn it as a workflow and run it as one step."],["notes","Notes and skills only","It never runs a learned workflow, and is never asked to draft one."]].map(([p,g,y])=>n.jsxs("label",{className:ie("flex items-start gap-3 border px-3 py-2.5",c===p&&"border-foreground"),children:[n.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:c===p,onChange:()=>d(p)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono text-body",children:g}),n.jsx("span",{className:"block text-small text-muted-foreground",children:y})]})]},String(p)))}),a&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:a}),l&&n.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:l})]})}const lz=["ready","unavailable"],wd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),D0=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function Df(e){if(wd(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function F0(e){const t=wd(e)?e.places:void 0;if(!wd(t)||!Array.isArray(t.modes)||!Array.isArray(t.boxes))return null;const s=t.boxes.filter(wd).filter(a=>typeof a.id=="string").map(a=>({id:a.id,available:a.available===!0,...typeof a.reason=="string"?{reason:a.reason}:{},...lz.includes(a.state)?{state:a.state}:{}})),r=Df(t.default_place);return r?{modes:t.modes.filter(a=>typeof a=="string"),boxes:s,defaultPlace:r}:null}const ah=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,cz=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",uz=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",dz={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."}]}},fz=["jev","parallel"];function mz(e="jev"){const t=structuredClone(dz);return e!=="jev"&&Object.assign(t.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),t}const pz={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`."}]}},hz=()=>structuredClone(pz);function Mx(e,t,s){const{name:r,description:a,...l}=t,c={...e.definition,...l},u={...e.definition};c.computer!==void 0&&(delete c.place,delete u.place),e.kind==="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 p of Object.keys(c))c[p]===void 0&&delete c[p];const d=Hl({...c,version:0},{...u,version:0});return c.version=d?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:d}}function Hl(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const s=Object.keys(e).filter(a=>e[a]!==void 0),r=Object.keys(t).filter(a=>t[a]!==void 0);return s.length===r.length&&s.every(a=>Hl(e[a],t[a]))}const Lx="decision",BS="workflow",GS={[Lx]:mz,[BS]:hz},qS=e=>e!==void 0&&Object.hasOwn(GS,e);function gz(e){var s,r;if(!((s=e==null?void 0:e.adapters)!=null&&s.includes("runJudge")))return;const t=(r=e.decisions)==null?void 0:r.providers;return t?fz.find(a=>t.some(l=>l.id===a&&l.available)):"jev"}const xz="You are a helpful agent. Do the task you're given and report what you found.";function yz(e){var t;return qS(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:GS[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}:{},...(t=e.model)!=null&&t.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 U0(e){const t=(e??"").trim();if(!t)return{ok:!0,value:void 0};const s=t.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 bz(e){return(Array.isArray(e)?e:[]).flatMap(t=>{if(!t||typeof t!="object"||typeof t.name!="string")return[];if(t.meta===!0)return[];const{name:s,available:r,summary:a,blurb:l,missing:c,reason:u,harnesses:d,call_only:p,sandbox_only:g,nodes:y}=t;return[{name:s,available:r!==!1,...typeof a=="string"&&a?{summary:a}:{},...typeof l=="string"&&l.trim()?{blurb:l.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof u=="string"&&u?{reason:u}:{},harnesses:Array.isArray(d)?d:[],...p===!0?{call_only:!0}:{},...g===!0?{sandbox_only:!0}:{},...typeof y=="boolean"?{nodes:y}:{}}]})}function Ff(e,t){return t.filter(s=>!s.call_only&&s.harnesses.includes(e))}function Xh(e,t,s,{mcpHarnesses:r,workflow:a=!1}={}){if(t.startsWith("mcp:"))return!r||r.includes(e);const l=s.find(c=>c.name===t);return l?l.call_only?a:Ff(e,s).some(c=>c.name===t):!0}const Qh=e=>KS[e]??e,W0=e=>e.map(Qh).join(" and ");function H0(e,t,s,r){var l;if(t.startsWith("mcp:"))return`${Qh(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${W0(r)} do`:""}`;const a=((l=s.find(c=>c.name===t))==null?void 0:l.harnesses)??[];return a.length?`Runs on ${W0(a)} here, not on ${Qh(e)}`:"No harness runs it here"}function vz(e,t,s,r,a={}){const l=[...t,...s.filter(c=>!t.includes(c))];return{tools:l.filter(c=>Xh(e,c,r,a)),held:l.filter(c=>!Xh(e,c,r,a))}}const wz=(e,t)=>e.sandbox_only&&(t==null?void 0:t.mode)!=="sandbox"?"Sandbox-only: it runs in a box, and this agent's place is the runner":void 0,Px=new Set(["browser"]),Ix=(e,t,s)=>e||t.some(r=>Px.has(r))||!s?{mode:"runner"}:s.defaultPlace;function VS(e,t){const s=Df(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",a=e.definition.tools??[];if(!(!r&&!a.some(l=>Px.has(l))&&!t))return{place:Ix(r,a,t),byDefault:!0}}const ih=(e,t,s)=>Ff(e,t).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!Px.has(r.name):!r.sandbox_only)).map(r=>r.name),kz=["web_fetch","web_search"],B0=e=>e.some(t=>kz.includes(t)),KS={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},jz=["pi","claude-agent","codex","opencode"];function Nz(e,t){const s=jz.flatMap(r=>{const a=e.find(l=>l.id===r);return a?[{id:r,label:KS[r],available:a.available,reason:a.reason}]:[]});return t&&(s.push({id:Lx,label:"Decision",available:t.available,reason:t.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),s.push({id:BS,label:"Workflow",available:!0,reason:void 0})),s}function Sz(e){var t;return e.status===412||e.code==="precondition_failed"?{kind:"conflict",message:e.message}:e.status===422&&((t=e.fields)!=null&&t.length)?{kind:"invalid",message:e.message,fields:Object.fromEntries(e.fields.map(s=>[s.field,s.message]))}:{kind:"other",message:e.message}}function Uf(e,t=!1){var s,r,a;return e.status===412||e.code==="precondition_failed"?t?{kind:"taken"}:{kind:"conflict"}:(s=e.problems)!=null&&s.length?{kind:"refused",problems:e.problems}:{kind:"other",message:((a=(r=e.fields)==null?void 0:r[0])==null?void 0:a.message)??e.message,code:e.code}}function _z(e,t){const s=`definition.${t}`;return(e??[]).filter(r=>r.field===s||r.field.startsWith(`${s}[`)||r.field.startsWith(`${s}.`)||r.field.startsWith(`${s}/`))}const Sa=(e,t,s)=>({...hr(e,t),title:s}),$z=(e,t)=>{const s=e.get(t);return s!=null&&s.title?xn(s):`run ${Co(t)}`},YS="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",Ez=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),G0=20;function Cz({agent:e,v2:t,focus:s=[],server:r,onAgent:a,places:l,onChanged:c}){var et;const[u,d]=x.useState(null),[p,g]=x.useState(null),[y,h]=x.useState([]),[m,v]=x.useState([]),[w,k]=x.useState([]),[N,A]=x.useState(null),[_,S]=x.useState(null),[E,T]=x.useState({items:[],cursor:null,pages:0}),[C,R]=x.useState({items:[],cursor:null,pages:0}),[D,L]=x.useState(!1),[O,I]=x.useState(0),W=x.useRef(0),U=x.useRef(!1),J=()=>{const ae=++W.current;U.current=!1,g(null);const Ae=t.agentLearning(e.agent_id).then(Ce=>{ae===W.current&&(d(Ce),T({items:[],cursor:Ce.notes.next_cursor,pages:0}),R({items:[],cursor:Ce.log.next_cursor,pages:0}))},Ce=>{ae===W.current&&g(Ce??new Error("unknown"))});return t.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Ce=>{ae===W.current&&h(Ce.runs)},()=>{}),Promise.resolve().then(()=>t.learningPromotions(e.agent_id)).then(Ce=>{ae===W.current&&(v(Ce.promotions),k(Ce.serving))},()=>{}),Promise.resolve().then(()=>t.learningLoop(e.agent_id)).then(Ce=>{ae===W.current&&A(Ce)},()=>{}),Ae};x.useEffect(()=>{J()},[t,e.agent_id]);const F=()=>(c==null||c(),J()),Z=()=>{if(!E.cursor||U.current)return;const ae=W.current;U.current=!0,t.learningNotes(e.agent_id,E.cursor).then(Ae=>{ae===W.current&&(U.current=!1,T(Ce=>({items:[...Ce.items,...Ae.items.filter(Ge=>!Ce.items.some(kt=>kt.file===Ge.file))],cursor:Ae.next_cursor,pages:Ce.pages+1})))},Ae=>{ae===W.current&&(U.current=!1,T(Ce=>({...Ce,error:Ae??new Error("unknown")})))})},z=e.definition.learning===!0||e.definition.learning==="notes",H=!!e.archived_at,V=x.useMemo(()=>[...(u==null?void 0:u.notes.items)??[],...E.items],[u,E.items]),P=V.filter(ae=>ae.status==="active"),B=V.filter(EN),q=(u==null?void 0:u.skills)??[],ce=(u==null?void 0:u.workflows)??[],[de,ue]=x.useState(void 0),fe=B.length>0||[...q,...ce].some(ae=>ae.status==="pending")||ce.some(ae=>ae.status==="active");x.useEffect(()=>{if(!fe||de!==void 0)return;let ae=!0;return Promise.resolve().then(()=>t.capabilities()).then(Ae=>{ae&&ue(c5(Ae))},()=>{ae&&ue("password")}),()=>{ae=!1}},[fe]);const ye=V.filter(ae=>ae.status==="superseded"||ae.status==="retired"),Ee=x.useMemo(()=>{const ae=new Map(V.map(Ce=>[Ce.file,Ce])),Ae=new Map;for(const Ce of V){if(Ce.status==="superseded")continue;const kt=[...new Set([...b5(Ce.text),...V.filter(We=>We.status==="superseded"&&We.superseded_by===Ce.file).map(We=>We.file)])].flatMap(We=>{const rt=ae.get(We);return rt?rt.status==="superseded"&&rt.superseded_by===Ce.file?[{file:We,name:rt.name}]:[]:[{file:We,name:null}]});kt.length&&Ae.set(Ce.file,kt)}return Ae},[V]),ge=x.useMemo(()=>new Map(y.map(ae=>[ae.run_id,ae])),[y]),se=x.useMemo(()=>$5([...(u==null?void 0:u.log.items)??[],...C.items]),[u,C.items]),pe=s.filter(ae=>!V.some(Ae=>Ae.file===ae)).length>0;x.useEffect(()=>{u&&pe&&E.cursor&&E.error===void 0&&E.pages<G0&&Z()},[u,pe,E.cursor,E.pages]);const Y=V.some(ae=>!se.has(ae.file));x.useEffect(()=>{if(!u||!Y||!C.cursor||C.pages>=G0)return;const ae=W.current;t.learningLog(e.agent_id,C.cursor).then(Ae=>{ae===W.current&&R(Ce=>({items:[...Ce.items,...Ae.items],cursor:Ae.next_cursor,pages:Ce.pages+1}))},()=>{ae===W.current&&R(Ae=>({...Ae,cursor:null}))})},[u,Y,C.cursor]);const _e=y.filter(ae=>ae.learning&&(ae.learning.state==="merged"||ae.learning.state==="dropped")).length,Ze=YP({notes:P.length,compiledNotes:V.filter(ae=>ae.status!=="retired"&&MS(ae.text)!==null).length,runs:y.filter(ae=>ae.status==="completed").length,workflows:ce,cost:_,promotions:m,serving:w,loop:N,mode:e.definition.learning==="notes"?"notes":"full"});if(p&&!u)return n.jsx(Fn,{problem:hr(p,"what this agent learned"),onRetry:J,className:""});if(!u)return n.jsx(Rz,{});const Je=p?n.jsx(Tz,{error:p,onRetry:J}):null,xt=ae=>n.jsx(Oz,{agent:e,v2:t,onAgent:a,server:r,disabled:H,quiet:ae});return!V.length&&!q.length&&!ce.length&&!D?n.jsxs("div",{className:"space-y-6",children:[Je,n.jsx(Lz,{on:z,lookedBack:_e,switchRow:xt(!0),onAdd:H?void 0:()=>L(!0)}),z&&n.jsx(z0,{stages:Ze}),n.jsx(C0,{v2:t,agentId:e.agent_id,quiet:!0}),z&&!H&&n.jsx(E0,{v2:t,agentId:e.agent_id,onFinished:()=>{I(ae=>ae+1),J()}}),n.jsx(w0,{v2:t,agentId:e.agent_id,on:z,quiet:!0,promotions:m,onCost:S},O),n.jsx(I0,{loop:N,promotions:m,serving:w,cost:_}),n.jsx(V0,{runs:y})]}):n.jsxs("div",{className:"space-y-6",children:[B.length>0&&n.jsxs("section",{className:"border border-warning/50","aria-label":"Waiting for your OK",children:[n.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b border-warning/50 px-4 py-3 text-small font-semibold",children:["Waiting for your OK",n.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:B.length})]}),n.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:u5}),((et=VS(e,l))==null?void 0:et.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&n.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:d5}),n.jsx("ul",{className:"space-y-3 p-4",children:B.map(ae=>n.jsx("li",{children:n.jsx(q0,{note:ae,v2:t,agentId:e.agent_id,readOnly:H,focused:s.includes(ae.file),from:se.get(ae.file),runs:ge,onChanged:F,approves:de,replaces:Ee.get(ae.file)})},ae.file))})]}),n.jsx(z0,{stages:Ze}),n.jsx(C0,{v2:t,agentId:e.agent_id}),g5(u.impact)&&n.jsx(Az,{impact:u.impact}),z&&!H&&n.jsx(E0,{v2:t,agentId:e.agent_id,onFinished:()=>{I(ae=>ae+1),J()}}),n.jsx(w0,{v2:t,agentId:e.agent_id,on:z,promotions:m,onCost:S},O),n.jsx(ZI,{v2:t,agentId:e.agent_id,workflows:ce,promotions:m,serving:w,loop:N,cost:_}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[n.jsxs("div",{className:"min-w-0 space-y-6",children:[n.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Notes",children:[n.jsxs("div",{className:"flex flex-wrap items-end gap-x-4 gap-y-2",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"What it has learned"}),n.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:P.length?`${di(P.length)} in use. Every later run reads ${P.length===1?"it":"them"} before it starts.`:[...q,...ce].some(ae=>ae.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!H&&!D&&n.jsxs(K,{size:"sm",onClick:()=>L(!0),children:[n.jsx(yi,{"aria-hidden":!0})," Add a note"]})]}),Je,!z&&n.jsx(Mz,{server:r}),D&&n.jsx(e2,{title:"New note",v2:t,agentId:e.agent_id,taken:V.map(ae=>ae.file),onDone:ae=>{L(!1),ae&&F()}},"new"),n.jsx("ul",{className:"space-y-3",children:P.map(ae=>n.jsx("li",{children:n.jsx(q0,{note:ae,v2:t,agentId:e.agent_id,readOnly:H,focused:s.includes(ae.file),from:se.get(ae.file),runs:ge,onChanged:F,replaces:Ee.get(ae.file)})},ae.file))}),E.error!==void 0&&n.jsx(Fn,{problem:hr(E.error,"more notes"),onRetry:Z,className:""}),E.cursor&&n.jsx("div",{className:"flex justify-center",children:n.jsx(K,{size:"sm",onClick:Z,children:"Load more notes"})}),ye.length>0&&n.jsx(Fz,{notes:ye,all:V,from:se,focus:s,runs:ge,v2:t,agentId:e.agent_id,readOnly:H,onChanged:F})]}),["skill","workflow"].map(ae=>{const Ae=ae==="skill"?q:ce;if(!Ae.length)return null;const Ce=ae==="skill"?"Skills it learned":"Workflows it learned",Ge=Ae.filter(We=>We.status!=="retired"),kt=Ae.filter(We=>We.status==="retired");return n.jsxs("section",{className:"min-w-0 space-y-3","aria-label":Ce,children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold",children:Ce}),n.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:Ge.length?ae==="skill"?`${Fd(Ge.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${Fd(Ge.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${ae} is in use: the next run gets none.`})]}),Ge.length>0&&n.jsx("ul",{className:"space-y-3",children:Ge.map(We=>n.jsx("li",{children:n.jsx(Pz,{item:We,kind:ae,v2:t,agentId:e.agent_id,readOnly:H,runs:ge,approves:de,onChanged:F})},We.file))}),kt.length>0&&n.jsx(Uz,{kind:ae,items:kt,v2:t,agentId:e.agent_id,runs:ge,readOnly:H,onChanged:F})]},ae)})]}),n.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[n.jsx(XS,{title:"Learning",children:xt(!1)}),n.jsx(I0,{loop:N,promotions:m,serving:w,cost:_}),n.jsx(V0,{runs:y}),n.jsx(Hz,{index:u.index,skills:q.filter(ae=>ae.status==="active").map(ae=>ae.name),off:!z||r==="off"})]})]})]})}function Tz({error:e,onRetry:t}){const s=hr(e,"the notes"),r=[s.said,s.code].filter(Boolean).join(" · ");return n.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:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't refresh the notes: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)," What's shown may be out of date."]}),n.jsx(K,{type:"button",onClick:t,size:"sm",children:"Try again"})]})}function XS({title:e,children:t,label:s}){return n.jsxs("section",{className:"border","aria-label":s??e,children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),t]})}function Rz(){const e="block bg-muted motion-safe:animate-pulse";return n.jsxs("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading what it learned",children:[n.jsx("span",{"aria-hidden":!0,className:ie(e,"h-6 w-56")}),[0,1,2].map(t=>n.jsxs("div",{"aria-hidden":!0,className:"space-y-3 border p-5",children:[n.jsx("span",{className:ie(e,"h-4 w-1/3")}),n.jsx("span",{className:ie(e,"h-3 w-2/3 bg-muted/70")}),n.jsx("span",{className:ie(e,"h-3 w-1/2 bg-muted/70")})]},t)),n.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function Az({impact:e}){const{before:t,after:s}=e,r=[{label:"Answers in",now:Hd(s.median_duration_s),was:Hd(t.median_duration_s),delta:Bw(t.median_duration_s,s.median_duration_s)},...AN(e)?[{label:"A run costs",now:fi(s.median_cost_usd),was:fi(t.median_cost_usd),delta:Bw(t.median_cost_usd,s.median_cost_usd)}]:[]],a=ON(e),l=[`Medians of ${ko(t.runs)} before it first learned and ${ko(s.runs)} that started from what it learned (a note, a skill or a workflow).`,`Costs are of the ${t.cost_runs} and ${s.cost_runs} runs whose cost is known.`].join(" ");return n.jsx("section",{className:"border","aria-label":h5(e),children:n.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4 px-4 py-3",children:[n.jsxs("div",{className:"flex items-baseline gap-2.5",children:[n.jsx("span",{className:"caps text-small font-semibold",children:"Since it learned"}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",title:l,children:["on ",ko(s.runs)]})]}),n.jsxs("dl",{className:"flex flex-1 flex-wrap items-baseline gap-x-10 gap-y-3","aria-hidden":!0,children:[r.map(c=>n.jsxs("div",{className:"flex items-baseline gap-3",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:c.label}),n.jsxs("dd",{className:"flex items-baseline gap-2 font-mono",children:[n.jsx("span",{className:"text-figure font-semibold leading-none",children:c.now}),n.jsxs("span",{className:"text-small text-muted-foreground",children:["instead of ",c.was]}),c.delta!==null&&c.delta!==0&&n.jsxs("span",{className:ie("text-small",c.delta<0?"text-primary-text":"text-warning-text"),children:[c.delta>0?"+":"−",Math.abs(c.delta),"%"]})]})]},c.label)),a!==null&&n.jsxs("div",{className:"flex items-baseline gap-3",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Learning itself"}),n.jsxs("dd",{className:"font-mono text-body text-muted-foreground",children:[fi(a)," a run"]})]})]})]})})}function Oz({agent:e,v2:t,onAgent:s,server:r,disabled:a,quiet:l}){const[c,u]=x.useState(!1),[d,p]=x.useState(null),[g,y]=x.useState(null),h=async m=>{u(!0),p(null),y(m);try{const{agent:v,etag:w}=await t.getAgent(e.agent_id),k=Mx(v,{learning:m},m?"Learning on":"Learning off");if(k.unchanged)s==null||s(v);else{const{unchanged:N,...A}=k;s==null||s((await t.updateDefinition(e.agent_id,A,w)).agent)}}catch(v){p(v??new Error("unknown"))}y(null),u(!1)};return n.jsx(HS,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:l,checked:g??(e.definition.learning===!0||e.definition.learning==="notes"),onChange:m=>void h(m),busy:c,disabled:a,server:r,problem:d?n.jsx(Fn,{problem:Sa(d,"the agent","Learning was not changed."),className:"mt-2"}):null})}function Mz({server:e}){return n.jsxs(_n,{tone:"warning",children:["Learning is off",e==="off"?" on this server":"",", so later runs don't read these notes. They're kept for when it's back on."]})}function Lz({on:e,lookedBack:t,switchRow:s,onAdd:r}){return n.jsxs("section",{className:"mx-auto max-w-xl border","aria-label":"Learning",children:[n.jsxs("div",{className:"px-6 py-12 text-center",children:[n.jsx(vg,{className:"mx-auto mb-3 size-5 text-primary-text","aria-hidden":!0}),n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:e?"Nothing learned yet.":"Learning is off for this agent."}),n.jsx("p",{className:"mx-auto mt-2 max-w-md text-lead text-muted-foreground",children:e?"After each run, it looks back and keeps a note when something will help next time. Its notes show here, and every later run reads them first.":"With learning on, it keeps short notes on what worked after each run, and every later run reads them before it starts."}),e&&t>0&&n.jsxs("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:[ko(t)," looked back: nothing worth keeping yet."]})]}),n.jsx("div",{className:"border-t",children:s}),r&&n.jsx("div",{className:"flex justify-center border-t px-4 py-3",children:n.jsxs(K,{size:"sm",variant:"ghost",onClick:r,children:[n.jsx(yi,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function q0({note:e,v2:t,agentId:s,readOnly:r,focused:a,from:l,runs:c,onChanged:u,approves:d,replaces:p=[]}){const[g,y]=x.useState(!1),[h,m]=x.useState(!1),[v,w]=x.useState(!1),[k,N]=x.useState(a),[A,_]=x.useState(null),[S,E]=x.useState(!1),[T,C]=x.useState(null),R=x.useRef(null),D=EN(e),L=async()=>{const U=J=>n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:J});E(!0),C(null);try{await t.approveNote(s,e.file,e.etag)}catch(J){E(!1),C(J instanceof Pe&&Uf(J).kind==="conflict"?U(`${Tf} Reload the tab to see the newest version.`):n.jsx(Fn,{problem:Sa(J,"the note","The note was not approved."),className:""}));return}await u(),E(!1)};if(x.useEffect(()=>{var J,F;if(!a)return;N(!0),(F=(J=R.current)==null?void 0:J.scrollIntoView)==null||F.call(J,{block:"center",behavior:"smooth"});const U=setTimeout(()=>N(!1),2600);return()=>clearTimeout(U)},[a]),x.useEffect(()=>{if(!A)return;const U=setTimeout(()=>_(null),2400);return()=>clearTimeout(U)},[A]),g)return n.jsx(e2,{title:"Edit note",v2:t,agentId:s,file:e.file,seen:e,onDone:U=>{y(!1),U&&(_("Saved"),u())}});const O=Zl(e.text),I=Jh(e.last_change),W=MS(e.text);return n.jsxs("article",{ref:R,id:`note-${e.file}`,tabIndex:-1,"aria-label":e.name,className:ie("border bg-card/40 outline-none focus-visible:border-primary transition-[border-color,box-shadow] duration-slow",k&&"border-primary ring-1 ring-primary"),children:[n.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"min-w-0 break-words text-prose font-semibold leading-snug",children:e.name}),n.jsx(Ne,{children:jN(e.type)}),e.origin==="you"&&n.jsx(Ne,{tone:"muted",children:"From you"}),W&&n.jsxs(Ne,{tone:"success",label:!0,title:`This note went into the learned workflow ${W}`,children:["Compiled into ",W]}),A&&n.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:A})]}),n.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),D&&d==="password"&&n.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:CN})]}),!r&&!v&&n.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[D?d==="yes"&&n.jsx(K,{size:"sm",variant:"solid",onClick:()=>void L(),disabled:S,"aria-label":`Approve ${e.name}`,children:S?"Approving":"Approve"}):n.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>y(!0),"aria-label":`Edit ${e.name}`,children:[n.jsx(dc,{"aria-hidden":!0})," Edit"]}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>w(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),T&&n.jsx("div",{className:"px-5 pt-3",children:T}),O.trim()&&n.jsx(Hf,{text:O}),n.jsxs("footer",{className:"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:[(l==null?void 0:l.run)&&n.jsx(Wf,{run:l.run.id,runs:c,at:l.run.at,reason:l.run.reason}),I&&n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(wg,{className:"size-3","aria-hidden":!0}),I]}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(jd,{className:"size-3","aria-hidden":!0}),"Given to ",ko(e.runs.given)]}),e.runs.read>0&&n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(jd,{className:"size-3","aria-hidden":!0}),"Read in ",ko(e.runs.read)]}),p.length>0&&n.jsxs("button",{type:"button",onClick:()=>m(U=>!U),"aria-expanded":h,className:"flex items-center gap-1.5 hover:text-foreground",children:[n.jsx(iE,{className:"size-3","aria-hidden":!0}),"Replaces ",p.length," older ",p.length===1?"note":"notes",n.jsx(va,{className:ie("size-3 transition-transform",h&&"rotate-180"),"aria-hidden":!0})]})]}),h&&p.length>0&&n.jsx("ul",{"aria-label":"Notes it replaces",className:"space-y-1 border-t px-5 py-2.5 text-body text-muted-foreground",children:p.map(U=>n.jsx("li",{className:ie("break-words",U.name===null&&"font-mono text-small"),children:U.name??U.file},U.file))}),v&&n.jsx(JS,{name:e.name,kind:"note",retire:()=>t.retireNote(s,e.file,e.etag),onDone:async U=>{U&&await u(),w(!1)}})]})}function Pz({item:e,kind:t,v2:s,agentId:r,readOnly:a,runs:l,approves:c,onChanged:u}){const[d,p]=x.useState(!1),[g,y]=x.useState(null),[h,m]=x.useState(null),[v,w]=x.useState(null),[k,N]=x.useState(!1),[A,_]=x.useState(!1),[S,E]=x.useState(!1),T=x.useRef(er()).current,[C,R]=x.useState(null),[D,L]=x.useState(null),O=e.status==="pending",I=t==="workflow"&&e.status==="active"&&c==="yes",W=async()=>{w(null),y(null),m(null);try{const z=await s.readNote(r,e.file);y(z.note),m(z.etag)}catch(z){w(z??new Error("unknown"))}},U=async()=>{if(d)return p(!1);p(!0),g===null&&await W()};x.useEffect(()=>{g===null&&h===null||(d?W():(y(null),m(null)))},[e.etag]);const J=t==="skill"&&d&&h?h:e.etag,F=async()=>{N(!0),L(null);try{await s.approveNote(r,Mh(e),J)}catch(z){N(!1),L(z instanceof Pe&&Uf(z).kind==="conflict"?n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Tf} Reload the tab to see the newest version.`}):n.jsx(Fn,{problem:Sa(z,`the ${t}`,`The ${t} was not approved.`),className:""}));return}await u(),N(!1)},Z=`the ${t} ${e.name}`;return n.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[n.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),O&&n.jsxs(Ne,{tone:"warning",children:[n.jsx(yg,{className:"size-3","aria-hidden":!0}),"Waits for your OK"]})]}),e.description&&n.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),O&&c==="password"&&n.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:CN})]}),n.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!a&&!A&&!S&&n.jsxs(n.Fragment,{children:[O&&c==="yes"&&n.jsx(K,{size:"sm",variant:"solid",onClick:()=>void F(),disabled:k,"aria-label":`Approve ${e.name}`,children:k?"Approving":"Approve"}),I&&n.jsx(K,{size:"sm",onClick:()=>{R(null),E(!0)},"aria-label":`Make ${e.name} an agent`,children:"Make this an agent"}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>_(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),n.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>void U(),"aria-expanded":d,"aria-label":`${d?"Hide":"Show"} ${Z}`,children:[n.jsx(va,{className:ie("transition-transform",d&&"rotate-180"),"aria-hidden":!0}),d?"Hide":"Show"]})]})]}),D&&n.jsx("div",{className:"px-5 pt-3",children:D}),C&&n.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",n.jsx("a",{href:`#/agents/${encodeURIComponent(C.agent_id)}`,className:"font-mono underline underline-offset-2",children:C.definition.name}),". Open it to run it."]}),d&&(v!==null?n.jsx("div",{className:"px-5 pt-3",children:n.jsx(Fn,{problem:hr(v,Z),onRetry:()=>void W(),className:""})}):g===null?n.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${Z}`,children:n.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):t==="skill"?n.jsx(Hf,{text:Zl(g)}):n.jsx(Iz,{name:e.name,text:g})),n.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&&n.jsx(Wf,{run:e.run,runs:l}),Jh(e.last_change)&&n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(wg,{className:"size-3","aria-hidden":!0}),Jh(e.last_change)]}),n.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),A&&n.jsx(JS,{name:e.name,kind:t,retire:()=>s.retireNote(r,Mh(e),J),onDone:async z=>{z&&await u(),_(!1)}}),S&&n.jsx(Dz,{name:e.name,keys:T,promote:z=>s.promoteWorkflow(r,e.name,z),onDone:z=>{E(!1),z&&R(z)}})]})}function Iz({name:e,text:t}){const{doc:s,graph:r}=x.useMemo(()=>{try{const c=JSON.parse(t);return{doc:c,graph:hi(c)}}catch{return{doc:null,graph:null}}},[t]),a=x.useMemo(()=>r?{meta:vc(s,r)}:void 0,[s,r]),l=n.jsx("pre",{className:"max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:t});return r!=null&&r.nodes.length?n.jsxs("div",{className:"mx-5 mt-3 space-y-2",children:[n.jsx("div",{className:"overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-4",children:n.jsx(Tc,{graph:r,marks:a,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),n.jsx(Rc,{}),n.jsxs("details",{children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"workflow.json"}),n.jsx("div",{className:"mt-2",children:l})]})]}):n.jsx("div",{className:"mx-5 mt-3",children:l})}function Jh(e){return e&&e.kind!=="learned"?`${wN(e.kind,e.by)} · ${ht(e.at)}`:null}function QS(e){return(e==null?void 0:e.by)==="host"?Z4:e?`${wN("retired",e.by)} · ${ht(e.at)}`:"Retired"}function Wf({run:e,runs:t,at:s,reason:r}){return n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap",title:r?`Kept because: ${r}`:void 0,children:[n.jsx(vg,{className:"size-3 shrink-0 text-primary-text","aria-hidden":!0}),"Learned in"]}),n.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"shrink-0 font-mono text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",title:$z(t,e),children:Co(e)}),s&&n.jsxs("span",{className:"shrink-0",children:["· ",ht(s)]})]})}function Hf({text:e}){const[t,s]=x.useState(!1),r=e.split(`
554
+ `).length>8||e.length>520,a=x.useMemo(()=>Lr(e),[e]);return n.jsxs("div",{className:"px-5 pb-4 pt-3",children:[n.jsxs("div",{className:ie("relative",r&&!t&&"max-h-[9.5rem] overflow-hidden"),children:[n.jsx("div",{className:YS,dangerouslySetInnerHTML:{__html:a}}),r&&!t&&n.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-background to-transparent","aria-hidden":!0})]}),r&&n.jsxs("button",{type:"button",onClick:()=>s(l=>!l),className:"caps mt-2 flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(va,{className:ie("size-3.5 transition-transform",t&&"rotate-180"),"aria-hidden":!0}),t?"Show less":"Show all"]})]})}const zz={note:"Later runs stop reading it. It stays under Earlier notes.",skill:"Later runs stop getting it. It stays under Earlier skills.",workflow:"Later runs stop getting it. It stays under Earlier workflows."};function JS({name:e,kind:t,retire:s,onDone:r}){const[a,l]=x.useState(!1),[c,u]=x.useState(null),d=x.useRef(null);x.useEffect(()=>{var y;(y=d.current)==null||y.focus()},[]);const p=y=>n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:y}),g=async()=>{l(!0),u(null);try{await s()}catch(y){l(!1),u(y instanceof Pe&&Uf(y).kind==="conflict"?p(`${Tf} Reload the tab to see the newest version.`):n.jsx(Fn,{problem:Sa(y,`the ${t}`,`The ${t} was not retired.`),className:""}));return}await r(!0)};return n.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:y=>{y.key==="Escape"&&(y.stopPropagation(),r(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",zz[t]]}),c&&n.jsx("div",{className:"w-full",children:c}),n.jsx(K,{ref:d,size:"sm",variant:"destructive",onClick:()=>void g(),disabled:a,children:a?"Retiring":"Yes, retire"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>void r(!1),disabled:a,children:"Keep"})]})}function Dz({name:e,keys:t,promote:s,onDone:r}){const[a,l]=x.useState(!1),[c,u]=x.useState(null),d=x.useRef(null);x.useEffect(()=>{var g;(g=d.current)==null||g.focus()},[]);const p=async()=>{var y;l(!0),u(null);let g;try{g=await s(t.keyFor("promote",e))}catch(h){return l(!1),h instanceof Pe&&h.status<500&&t.done(),h instanceof Pe&&h.status===403?void u(n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:s5})):h instanceof Pe&&((y=h.problems)!=null&&y.length)?void u(n.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[n.jsxs("p",{children:["No agent was made: ",h.message]}),n.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:h.problems.map((m,v)=>n.jsx("li",{children:m.detail},v))})]})):void u(n.jsx(Fn,{problem:Sa(h,"the agent","No agent was made."),className:""}))}t.done(),r(g)};return n.jsxs("div",{role:"alertdialog","aria-label":`Make ${e} an agent?`,onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),a||r(null))},className:"flex flex-wrap items-center gap-3 border-t px-5 py-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Make it an agent?"})," ",n5(e)]}),c&&n.jsx("div",{className:"w-full",children:c}),n.jsx(K,{ref:d,size:"sm",variant:"solid",onClick:()=>void p(),disabled:a,children:a?"Making the agent":"Yes, make the agent"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(null),disabled:a,children:"Cancel"})]})}function ZS({name:e,kind:t,from:s,restore:r,onChanged:a,onDone:l}){const[c,u]=x.useState(!1),[d,p]=x.useState(null),g=x.useRef(null);x.useEffect(()=>{var m;(m=g.current)==null||m.focus()},[]);const y=m=>n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:m}),h=async()=>{var m;u(!0),p(null);try{await r()}catch(v){if(u(!1),v instanceof Pe&&(v.status===412||v.code==="precondition_failed")){p(y(Tf)),await a();return}if(v instanceof Pe&&v.status===403)return void p(y(r5));if(v instanceof Pe&&((m=v.problems)!=null&&m.length))return void p(n.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[n.jsxs("p",{children:["Not restored: ",v.message]}),n.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:v.problems.map((w,k)=>n.jsx("li",{children:w.detail},k))})]}));if(v instanceof Pe&&v.status===400){await a(),l();return}return void p(n.jsx(Fn,{problem:Sa(v,`the ${t}`,`The ${t} was not restored.`),className:""}))}await a(),l()};return n.jsxs("div",{role:"alertdialog","aria-label":`Restore ${e}?`,onKeyDown:m=>{m.key==="Escape"&&(m.stopPropagation(),l())},className:"flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Restore it?"})," ",t5(s)]}),d&&n.jsx("div",{className:"w-full",children:d}),n.jsx(K,{ref:g,size:"sm",variant:"solid",onClick:()=>void h(),disabled:c,children:c?"Restoring":"Yes, restore"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:l,disabled:c,children:"Keep"})]})}function e2({title:e,v2:t,agentId:s,file:r,seen:a,taken:l=[],onDone:c}){const[u,d]=x.useState(a?Bd(a.text):{name:"",description:"",type:"feedback",body:`
555
+ `,rest:[]}),[p,g]=x.useState((a==null?void 0:a.etag)??null),[y,h]=x.useState(null),[m,v]=x.useState(!1),[w,k]=x.useState([]),[N,A]=x.useState(null),[_,S]=x.useState(!1),[E,T]=x.useState(null),C=x.useRef(null),R=async()=>{if(r)try{const W=await t.readNote(s,r);d(Bd(W.note)),g(W.etag),h(null)}catch(W){h(W??new Error("unknown"))}};x.useEffect(()=>{var W;(W=C.current)==null||W.focus()},[]);const D=W=>d(U=>({...U,...W})),L=u.name.trim()!==""&&u.description.trim()!==""&&!m,O=async()=>{if(!L)return;if(A(null),k([]),S(!1),r&&!p){A(Kp);return}v(!0);const W=y5(u);try{await t.writeNote(s,r??qw(u.name,l),W,r?{etag:p??""}:{create:!0}),c(!0)}catch(U){v(!1);const J=U instanceof Pe?Uf(U,!r):null;(J==null?void 0:J.kind)==="conflict"?(T(W),await R()):(J==null?void 0:J.kind)==="refused"?k(J.problems):(J==null?void 0:J.kind)==="taken"?S(!0):A(U??new Error("unknown"))}},I=W=>{W.key==="Escape"?(W.preventDefault(),W.stopPropagation(),c(!1)):W.key==="Enter"&&(W.metaKey||W.ctrlKey||W.target.tagName==="INPUT")&&(W.preventDefault(),O())};return n.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:I,children:[n.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-2.5",children:[n.jsx("h3",{className:"caps text-label font-semibold",children:e}),n.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[n.jsxs("kbd",{children:[Ez?"⌘":"Ctrl","+Enter"]})," save · ",n.jsx("kbd",{children:"Esc"})," cancel"]})]}),y!==null&&n.jsx(Fn,{problem:hr(y,"the note"),onRetry:()=>{h(null),R()},className:"m-5"}),n.jsxs("div",{className:"space-y-4 px-5 py-4",children:[E&&n.jsxs("div",{className:"border border-warning/50 bg-warning/10 px-4 py-3 text-body",role:"alert",children:[n.jsxs("p",{className:"flex items-center gap-2 font-semibold",children:[n.jsx(Zs,{className:"size-4 text-warning-text","aria-hidden":!0}),"Changed since you opened it"]}),n.jsx("p",{className:"mt-1 text-muted-foreground",children:"This is the newest version. Your edit wasn't saved; it's below to copy."}),n.jsxs("details",{className:"mt-2",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"Your edit"}),n.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:E})]})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Name"}),n.jsx(Be,{ref:C,value:u.name,onChange:W=>D({name:W.target.value}),placeholder:"e.g., Try /policies/refund-policy first"})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Description"}),n.jsx("span",{className:"-mt-0.5 mb-1.5 block text-small text-muted-foreground",children:"One line: what the next run sees before it opens the note."}),n.jsx(Be,{value:u.description,onChange:W=>D({description:W.target.value}),placeholder:"When it applies, and what to do"})]}),n.jsxs("fieldset",{children:[n.jsx("legend",{className:"caps mb-1.5 text-label font-semibold",children:"Type"}),n.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Type",children:kN.map(W=>n.jsxs("label",{className:ie("caps cursor-pointer border px-3 py-1.5 text-label",u.type===W?"border-foreground":"text-muted-foreground hover:text-foreground"),title:W,children:[n.jsx("input",{type:"radio",name:`type-${r??"new"}`,className:"sr-only",checked:u.type===W,onChange:()=>D({type:W})}),jN(W)]},W))}),n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:a5[u.type]})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Note"}),n.jsx(ds,{value:u.body.replace(/^\n/,""),onChange:W=>D({body:`
556
+ ${W.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),w.length>0&&n.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[n.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: the note doesn't pass the checks."}),n.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:w.map((W,U)=>n.jsx("li",{children:W.detail},U))})]}),_&&n.jsx("p",{className:"text-body text-destructive-text",role:"alert",children:"Not saved: a note by this name exists already. Change its name."}),N===Kp?n.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",Kp]}):N!==null&&n.jsx(Fn,{problem:Sa(N,"the note","The note was not saved."),className:""}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(K,{size:"sm",variant:"solid",onClick:()=>void O(),disabled:!L,children:m?"Saving":r?"Save":"Add note"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>c(!1),disabled:m,children:"Cancel"}),!r&&u.name.trim()&&n.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:qw(u.name,l)})]})]})]})}function Fz({notes:e,all:t,from:s,focus:r,runs:a,v2:l,agentId:c,readOnly:u,onChanged:d}){const[p,g]=x.useState(null),[y,h]=x.useState(e.some(_=>r.includes(_.file))),[m,v]=x.useState(new Set),w=_=>v(S=>{const E=new Set(S);return E.has(_)?E.delete(_):E.add(_),E}),k=e.some(_=>r.includes(_.file));x.useEffect(()=>{k&&h(!0)},[k]);const N=_=>{var S;return((S=t.find(E=>E.file===_))==null?void 0:S.name)??_},A=_=>{var E;const S=document.getElementById(`note-${_}`);(E=S==null?void 0:S.scrollIntoView)==null||E.call(S,{block:"center",behavior:"smooth"}),S==null||S.focus({preventScroll:!0})};return n.jsx(t2,{title:"Earlier notes",count:`${e.length} no longer read`,open:y,onToggle:()=>h(_=>!_),children:e.map(_=>{var C,R;const S=_.status==="retired",E=S&&m.has(_.file),T=(C=s.get(_.file))==null?void 0:C.run;return n.jsxs("li",{id:`note-${_.file}`,className:ie("border-b px-4 py-3 last:border-b-0",r.includes(_.file)&&"bg-primary/5"),children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"text-lead text-muted-foreground line-through decoration-muted-foreground/40",children:_.name}),n.jsx(Ne,{tone:"muted",children:S?"Retired":"Replaced"}),S&&n.jsx(n2,{open:E,label:`the note ${_.name}`,onClick:()=>w(_.file)}),S&&!u&&_.etag&&p!==_.file&&n.jsxs(K,{size:"sm",onClick:()=>g(_.file),"aria-label":`Restore ${_.name}`,children:[n.jsx(zk,{"aria-hidden":!0})," Restore"]})]}),n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:_.status==="superseded"&&_.superseded_by?n.jsxs(n.Fragment,{children:["Replaced by ",n.jsx("button",{type:"button",onClick:()=>A(_.superseded_by),className:"text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",children:N(_.superseded_by)})]}):S?QS(_.retired):null}),p===_.file&&n.jsx("div",{className:"-mx-4 mt-2",children:n.jsx(ZS,{name:_.name,kind:"note",from:(R=_.retired)==null?void 0:R.from,restore:()=>l.restoreNote(c,_.file,_.etag),onChanged:d,onDone:()=>g(null)})}),E&&n.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[n.jsx("p",{className:"mt-2 px-5 text-body text-muted-foreground",children:_.description}),Zl(_.text).trim()&&n.jsx(Hf,{text:Zl(_.text)}),T&&n.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:n.jsx(Wf,{run:T.id,runs:a,at:T.at,reason:T.reason})})]})]},_.file)})})}function t2({title:e,count:t,open:s,onToggle:r,children:a}){return n.jsxs("section",{className:"border","aria-label":e,children:[n.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:[n.jsx(va,{className:ie("size-3.5 text-muted-foreground transition-transform",!s&&"-rotate-90"),"aria-hidden":!0}),n.jsx("span",{className:"caps text-small font-semibold",children:e}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:t})]}),s&&n.jsx("ul",{className:"border-t",children:a})]})}function Uz({kind:e,items:t,v2:s,agentId:r,runs:a,readOnly:l,onChanged:c}){const[u,d]=x.useState(!1),[p,g]=x.useState(null),[y,h]=x.useState(new Set),m=v=>h(w=>{const k=new Set(w);return k.has(v)?k.delete(v):k.add(v),k});return n.jsx(t2,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${t.length} no longer given`,open:u,onToggle:()=>d(v=>!v),children:t.map(v=>{var w;return n.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:v.name}),n.jsx(Ne,{tone:"muted",children:"Retired"}),n.jsx(n2,{open:y.has(v.file),label:`the ${e} ${v.name}`,onClick:()=>m(v.file)}),!l&&p!==v.file&&n.jsxs(K,{size:"sm",onClick:()=>g(v.file),"aria-label":`Restore ${v.name}`,children:[n.jsx(zk,{"aria-hidden":!0})," Restore"]})]}),v.description&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:v.description}),n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:QS(v.retired)}),p===v.file&&n.jsx("div",{className:"-mx-4 mt-2",children:n.jsx(ZS,{name:v.name,kind:e,from:(w=v.retired)==null?void 0:w.from,restore:()=>s.restoreNote(r,Mh(v),v.etag),onChanged:c,onDone:()=>g(null)})}),y.has(v.file)&&n.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[n.jsx(Wz,{v2:s,agentId:r,file:v.file,etag:v.etag,kind:e,label:`the ${e} ${v.name}`}),v.run&&n.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:n.jsx(Wf,{run:v.run,runs:a})})]})]},v.file)})})}function n2({open:e,label:t,onClick:s}){return n.jsxs(K,{size:"sm",variant:"ghost",className:"ml-auto",onClick:s,"aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${t}`,children:[n.jsx(va,{className:ie("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function Wz({v2:e,agentId:t,file:s,etag:r,kind:a,label:l}){const[c,u]=x.useState(null),[d,p]=x.useState(null),g=x.useRef(0),y=async()=>{const h=++g.current;p(null),u(null);try{const m=await e.readNote(t,s);h===g.current&&u(m.note)}catch(m){h===g.current&&p(m??new Error("unknown"))}};return x.useEffect(()=>{y()},[s,r]),d!==null?n.jsx("div",{className:"px-5 pt-3",children:n.jsx(Fn,{problem:hr(d,l),onRetry:()=>void y(),className:""})}):c===null?n.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${l}`,children:n.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):a==="skill"?n.jsx(Hf,{text:Zl(c)}):n.jsx("pre",{className:"mx-5 mt-3 max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:c})}function V0({runs:e}){const t=e.filter(a=>{var l;return((l=a.learning)==null?void 0:l.state)==="dropped"}),s=t.filter(a=>Wd(a.learning.reason)!=="nothing").slice(0,6),r=t.length-t.filter(a=>Wd(a.learning.reason)!=="nothing").length;return t.length?n.jsxs(XS,{title:"Kept nothing",children:[s.length>0&&n.jsx("ul",{children:s.map(a=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:`#/runs/${encodeURIComponent(a.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[n.jsx("span",{className:"block text-body",children:ix(a.learning)}),n.jsxs("span",{className:"mt-1 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 truncate",title:xn(a),children:xn(a)}),n.jsxs("span",{className:"shrink-0",children:["· ",ht(a.created_at)]})]})]})},a.run_id))}),r>0&&n.jsxs("p",{className:ie("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`:`${ko(r)} had`," nothing new to remember."]})]}):null}function Hz({index:e,skills:t,off:s}){const[r,a]=x.useState(!1),l=s?0:e.split(`
557
+ `).filter(p=>p.trim()).length,c=x.useMemo(()=>Lr(e.trim()),[e]),u=s?[]:t,d=u.length?`${u.length} ${u.length===1?"skill":"skills"}`:"";return n.jsxs("section",{className:"border","aria-label":"What the next run reads",children:[n.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(p=>!p),className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[n.jsx(va,{className:ie("size-3.5 text-muted-foreground transition-transform",!r&&"-rotate-90"),"aria-hidden":!0}),n.jsx("span",{className:"caps text-small font-semibold",children:"What the next run reads"}),n.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:[l?di(l):"",d].filter(Boolean).join(" · ")||"nothing"})]}),r&&n.jsxs("div",{className:"border-t",children:[s?n.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:"Learning is off: the next run gets no notes or skills."}):l?n.jsx("div",{className:ie(YS,"max-h-72 overflow-auto break-words px-4 py-3 text-body"),dangerouslySetInnerHTML:{__html:c}}):n.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:u.length?"No note is in use.":"Nothing yet: no note is in use."}),u.length>0&&n.jsxs("p",{className:"break-words border-t px-4 py-3 font-mono text-small leading-[1.7]",children:["Active skills: ",u.join(", ")]}),n.jsx("p",{className:"border-t px-4 py-2 text-label text-muted-foreground",children:"Read-only: the notes in use, one line each, and the agent's active skills."})]})]})}function ef(e,t){return t&&e.startsWith(`${t}/`)&&e.length>t.length+1?{text:e.slice(t.length+1),title:e}:{text:e}}function Bz(e,t){var s;return((s=t==null?void 0:t.find(r=>r.id===e))==null?void 0:s.models)??[]}function s2(e,t){var s;return((s=t==null?void 0:t.find(r=>r.id===e))==null?void 0:s.default_model)??void 0}const Gz="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",qz="none yet: add a model key in Settings → Model keys";class Zh extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const K0=e=>Math.min(1e4,1e3*2**e),Y0=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),Vz=e=>(e==null?void 0:e.name)==="AbortError",X0=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function Kz({fetch:e=(a,l)=>globalThis.fetch(a,l),probe:t="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let a={state:"online"};const l=new Set,c=new Set;let u=[],d,p=null,g=null;const y=S=>{a=S;for(const E of[...l])E()},h=S=>{const E=K0(S);clearTimeout(d),y({state:"offline",attempt:S,retryAt:Date.now()+E}),d=setTimeout(()=>void k(),E)},m=()=>{a.state!=="offline"&&h(0)},v=()=>{if(a.state!=="offline")return;clearTimeout(d),y({state:"resumed"});const S=u;u=[];for(const E of S)E();for(const E of[...c])E();d=setTimeout(()=>{a.state==="resumed"&&y({state:"online"})},s)};async function w(S){const E=setTimeout(()=>S.abort(),r);try{return!Y0(await e(t,{method:"GET",cache:"no-store",credentials:"same-origin",signal:S.signal}))}catch{return!1}finally{clearTimeout(E)}}async function k(){if(a.state!=="offline")return;clearTimeout(d),p==null||p.abort();const S=p=new AbortController,E=await w(S);p===S&&(p=null,a.state==="offline"&&(E?v():h(a.attempt+1)))}const N=()=>g??(g=w(new AbortController).finally(()=>{g=null})),A=S=>new Promise((E,T)=>{if(S!=null&&S.aborted)return T(X0(S));const C=()=>{u=u.filter(D=>D!==R),T(X0(S))},R=()=>{S==null||S.removeEventListener("abort",C),E()};u.push(R),S==null||S.addEventListener("abort",C,{once:!0})});return{fetch:async(S,E)=>{var R;const T=((E==null?void 0:E.method)??"GET").toUpperCase(),C=T==="GET"||T==="HEAD";for(let D=0;;D++){let L,O;try{L=await e(S,E)}catch(I){if((R=E==null?void 0:E.signal)!=null&&R.aborted||Vz(I))throw I;O=I}if(L&&!Y0(L))return v(),L;if(a.state!=="offline"&&await N()){if(L)return L;if(!C)throw new Zh;if(D>=2)throw O;await new Promise(I=>setTimeout(I,K0(D)));continue}if(m(),!C)throw new Zh;await A(E==null?void 0:E.signal)}},link:()=>a,subscribe:S=>(l.add(S),()=>{l.delete(S)}),onResume:S=>(c.add(S),()=>{c.delete(S)}),retryNow:()=>void k()}}const Yz=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),r2=e=>e instanceof Zh||e instanceof TypeError&&/fetch|network/i.test(e.message);function ln(e,t){const s=`${Yz(t)} could not be read.`;if(r2(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof Pe))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,a=[e.code,e.requestId].filter(Boolean).join(" · "),l=(c,u)=>({title:s,why:c,next:u,said:r,code:a});return e.status===401?l("This browser is signed out.","Reload the page to sign in again."):e.status===403?l("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?l("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===429?l("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?l("The server is busy.","Try again in a moment."):e.status>=500?l("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):l("The server turned the request down.","Its words say why: change what they name, then try again.")}function Xz(e){return r2(e)?"Can't reach agentrun-serve":e instanceof Pe?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}const Qz=[{id:"runs",label:"Runs",shows:()=>!0,Body:Zz},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:eD},{id:"learning",label:"Learning",shows:(e,t)=>e.kind==="agentic"&&t.learning!==!1,Body:e=>n.jsx(Cz,{agent:e.agent,v2:e.v2,focus:e.focus,server:e.learning,onAgent:e.onAgent,places:e.places,onChanged:e.onChanged})},{id:"analytics",label:"Analytics",shows:(e,t)=>t.analytics,Body:T4}],Qs=(e,t)=>`#/agents/${encodeURIComponent(e)}${t?`/${t}`:e==="new"?"/runs":""}`;function Jz({v2:e,agentId:t,routePrefix:s,harnesses:r,efforts:a=[],go:l,tab:c,limits:u,learning:d,notes:p,places:g}){var Ee,ge;const[y,h]=x.useState(null),[m,v]=x.useState(null),[w,k]=x.useState(0),[N,A]=x.useState(void 0),[_,S]=x.useState(!1);x.useEffect(()=>{let se=!0;return h(null),v(null),A(void 0),e.getAgent(t).then(pe=>{se&&h(pe.agent)},pe=>{se&&v({cause:pe})}),e.statsOver({from:Jg(gN),agent:t}).then(pe=>{se&&A(pe)},()=>{se&&A(null)}),()=>{se=!1}},[e,t,w]);const E=Ud(y),T=x.useRef(0),C=x.useRef(0),R=x.useRef(0),[D,L]=x.useState(!1),O=(se=!1,pe=!se)=>{const Y=++T.current;return pe&&(R.current=Y),e.getAgent(t).then(_e=>(Y>C.current&&Y>=R.current&&(C.current=Y,h(Ze=>Ze&&Ze.agent_id===_e.agent.agent_id?_e.agent:Ze),L(!1)),C.current>=Y),()=>(Y===T.current&&!se&&L(!0),C.current>=Y))},I=se=>{h(pe=>({...se,tools:(pe==null?void 0:pe.tools)??se.tools})),O()},W=()=>void O(),U=()=>void O(!0,!1),J=()=>O(!0,!0),F=N===void 0?void 0:N!==null;if(m)return m.cause instanceof Pe&&m.cause.status===404?n.jsx(KN,{what:"agent",id:t,list:{href:"#/agents",label:"Open the agents list"}}):n.jsx($n,{problem:ln(m.cause,"the agent"),onRetry:()=>k(se=>se+1)});if(!y)return n.jsx(kP,{});const Z=y.definition,z=y.kind==="workflow",H=z?ka:mg,V=s2(Z.harness??"pi",r),P=Z.model?ef(Z.model,s):V?(({text:se,title:pe})=>({text:`${se} (default)`,title:pe}))(ef(V,s)):{text:qz},B=z||r==null?void 0:r.find(se=>se.id===(Z.harness??"pi")&&se.available===!1),q=B?`${B.id} doesn't run on this server${B.reason?`: ${B.reason}`:"."}`:void 0,ce=VS(y,g),de=`${cz(ce==null?void 0:ce.place)}${ce!=null&&ce.byDefault?" (server default)":""}`,ue=[...z?[]:[["Harness",Z.harness??"pi"],["Model",P.text,P.title],["Thinking",Z.thinking??"default"],["Runs",de]],["Revision",`rev ${Z.version} of ${y.revisions}`]],Q=Qz.filter(se=>se.shows(y,{analytics:F===!0,learning:d===void 0?c==="learning"?void 0:!1:!!d})),fe=Q.find(se=>se.id===c)??Q[0],ye=c==="analytics"&&F===void 0;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[n.jsxs("div",{"data-phone-row":!0,className:"flex flex-col gap-3 max-sm:flex-row max-sm:items-center",children:[n.jsxs("button",{type:"button",onClick:()=>l(y.archived_at?"#/agents?archived=true":"#/agents"),className:"caps flex items-center gap-2 self-start text-label text-muted-foreground hover:text-foreground max-sm:-m-1 max-sm:self-center max-sm:p-1",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," ",n.jsx("span",{className:"max-sm:sr-only",children:"Agents"})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-3 max-sm:min-w-0 max-sm:flex-1 max-sm:flex-nowrap max-sm:gap-2",children:[n.jsx(H,{className:"size-5 shrink-0 text-muted-foreground max-sm:hidden","aria-hidden":!0}),n.jsx("h1",{className:"min-w-0 truncate font-mono text-xl font-semibold max-sm:text-lg",children:Z.name}),n.jsx(Ne,{children:y.kind}),y.archived_at&&n.jsx(Ne,{tone:"muted",children:"Archived"}),Z.approvals==="never"&&n.jsx(Ne,{tone:"warning",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"}),n.jsx("span",{className:"flex-1"}),n.jsxs(K,{size:"sm",onClick:()=>l(Qs(y.agent_id,"edit")),title:"Edit",className:"max-sm:w-8 max-sm:shrink-0 max-sm:px-0",children:[n.jsx(dc,{"aria-hidden":!0})," ",n.jsx("span",{className:"max-sm:sr-only",children:"Edit"})]}),n.jsx(rx,{context:{kind:"edit",agentId:y.agent_id,revision:y.revision},label:"Edit with your coding agent",iconOnPhone:!0})]})]}),Z.description&&n.jsx("p",{id:"agent-description",className:ie("mt-2 max-w-3xl text-lead text-muted-foreground",!_&&"max-sm:line-clamp-2"),children:Z.description}),n.jsxs("button",{type:"button","aria-expanded":_,"aria-controls":Z.description?"agent-description agent-facts":"agent-facts",onClick:()=>S(se=>!se),className:"mt-1.5 flex w-full min-w-0 items-center gap-1.5 text-left font-mono text-small text-muted-foreground sm:hidden",children:[n.jsx(cs,{className:ie("size-3.5 shrink-0 transition-transform",_&&"rotate-90"),"aria-hidden":!0}),n.jsx("span",{className:"truncate",children:ue.map(([,se])=>se).join(" · ")})]}),n.jsxs("dl",{id:"agent-facts",className:ie("mt-3 flex flex-wrap gap-x-6 gap-y-2",!_&&"max-sm:hidden"),"aria-label":"Current revision",children:[ue.map(([se,pe,Y])=>n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:se}),n.jsx("dd",{className:"font-mono text-small",title:Y,children:pe})]},se)),!z&&n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Tools"}),n.jsx("dd",{className:"font-mono text-small",children:(Ee=y.tools)!=null&&Ee.length?n.jsx("ul",{className:"flex flex-wrap gap-x-4 gap-y-1","aria-label":"Tools",children:y.tools.map(se=>n.jsxs("li",{children:[n.jsx("span",{title:se.blurb,children:se.name}),se.provider?` · ${Qd(se.provider,se.name)}`:"",se.permission?` · ${se.permission}`:"",jS(se.resolved,se.name).unavailable&&n.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:se.resolved,children:" · unavailable"})]},se.name))}):"none"})]})]}),D&&n.jsxs("p",{role:"alert",className:"mt-3 flex items-center gap-3 text-body text-warning-text",children:["Couldn't refresh this agent.",n.jsx(K,{size:"sm",variant:"outline",onClick:()=>O(),children:"Retry"})]}),q&&n.jsx("p",{className:"mt-3 font-mono text-small text-warning-text",role:"status","aria-label":"Harness not available",children:q}),(ge=y.warnings)!=null&&ge.length?n.jsxs("div",{className:"mt-3 font-mono text-small",role:"status","aria-label":"Save warnings",children:[n.jsx("p",{className:"text-warning-text",children:"Created. What the server said of this revision (Edit shows each at its step):"}),n.jsx("ul",{className:"mt-1 space-y-0.5",children:y.warnings.map((se,pe)=>n.jsxs("li",{children:[n.jsx("span",{className:"text-muted-foreground",children:se.field})," ",se.message]},`${se.field}:${pe}`))})]}):null,n.jsx(SP,{agent:y,v2:e,onAgent:h,poll:U,refresh:J})]}),!y.archived_at&&n.jsx(bP,{agent:y,efforts:a,v2:e,go:l,blocked:q,limits:u}),n.jsx(yN,{tabs:Q.map(se=>se.id==="learning"?{...se,label:n.jsxs(n.Fragment,{children:[se.label,n.jsx(T5,{n:E,className:"ml-1.5"})]})}:se),value:fe.id,onChange:se=>l(Qs(y.agent_id,se))}),n.jsx("div",{role:"tabpanel","aria-label":ye?void 0:fe.label,className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-8",children:ye?n.jsx(fs,{label:"Loading the tab",rows:4}):n.jsx(fe.Body,{agent:y,v2:e,go:l,stats:N,focus:p,learning:d,onAgent:I,onChanged:W,places:g})})]})}function Zz({agent:e,v2:t}){const[s,r]=x.useState(null),[a,l]=x.useState(null),[c,u]=x.useState(!1),[d,p]=x.useState(null),g=x.useRef(0),y=h=>{const m=++g.current;p(null),h&&u(!0),t.listAgentRuns(e.agent_id,50,h,!!e.archived_at).then(v=>{m===g.current&&(r(w=>h?lS(w??[],v.runs):v.runs),l(v.next_cursor))}).catch(v=>{m===g.current&&p(ln(v,h?"more runs":"the runs"))}).finally(()=>{m===g.current&&u(!1)})};return x.useEffect(()=>{y(null)},[t,e.agent_id]),d&&!s?n.jsx($n,{problem:d,onRetry:()=>y(null),className:""}):s?s.length?n.jsxs(n.Fragment,{children:[n.jsx(ZM,{v2:t,run:s[0],onRun:h=>r(m=>m&&m.map(v=>v.run_id===h.run_id?h:v))},s[0].run_id),n.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[s.length,a?"+":""," ",s.length===1&&!a?"run":"runs"]}),n.jsx("ul",{className:"border","aria-label":"Runs",children:s.map(h=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex flex-wrap items-center gap-x-4 gap-y-1 px-4 py-3 hover:bg-accent",children:[n.jsx(Nc,{run:h}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-lead",title:xn(h),children:xn(h)}),n.jsx(Af,{run:h}),h.effort&&n.jsxs(Ne,{children:["effort ",h.effort]}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ht(h.created_at)}),h.ended_at&&n.jsx("span",{className:"font-mono text-small text-muted-foreground",title:"How long it ran",children:ji(Date.parse(h.ended_at)-Date.parse(h.created_at))}),h.cost&&(h.cost.usd!==null||Oi(h.cost))&&n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:No(h.cost,{ended:pa(h.status)})})]})},h.run_id))}),d&&n.jsx($n,{problem:d,className:"mt-4"}),a&&n.jsx("div",{className:"mt-4 flex justify-center",children:n.jsx(K,{type:"button",size:"sm",onClick:()=>y(a),disabled:c,children:c?"Loading":"Load more"})})]}):n.jsxs("div",{className:"border px-4 py-12 text-center",children:[n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent yet."}),!e.archived_at&&n.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Start one above: its timeline shows here as the agent works."})]}):n.jsx(fs,{label:"Loading the runs",rows:5})}function eD({agent:e,go:t}){const s=e.definition.workflow,r=x.useMemo(()=>hi(s),[s]),a=x.useMemo(()=>({meta:vc(s,r)}),[s,r]);return n.jsxs("section",{className:"border",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[zf(Ox(r))," · rev ",e.definition.version]}),n.jsx("span",{className:"flex-1"}),n.jsxs(K,{size:"sm",onClick:()=>t(Qs(e.agent_id,"edit")),children:[n.jsx(dc,{"aria-hidden":!0})," Edit the workflow"]})]}),n.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:r.nodes.length?n.jsx(Tc,{graph:r,marks:a,label:"The workflow's graph",minScale:.55}):n.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."})}),n.jsx("div",{className:"border-t px-4 py-2",children:n.jsx(Rc,{})})]})}const tD=140,nD=32,sD=40,rD=60;function zx({value:e,name:t,note:s,blurb:r,description:a,tag:l,why:c,alert:u,on:d,disabled:p,warn:g,onToggle:y}){const[h,m]=x.useState(!1),v=x.useRef(null),w=x.useRef(null),k=x.useRef(null),N=x.useRef(null),A=ld(v,"width",h,t),_=ld(w,"height",h,a),S=ld(k,"width",h,l),E=ld(N,"width",h,u),T=A??t.length>nD,C=!!a&&(_??a.length>tD),R=!!l&&(S??l.length>sD),D=!!u&&(E??u.length>rD),L=!!c&&(c!==l||R),O=!!a&&(!!r||C)||L||D||T,I=(U,J)=>!h&&U&&J?U:void 0,W=U=>{U.preventDefault(),U.stopPropagation(),m(J=>!J)};return n.jsxs("label",{"data-tool-card":e,className:ie("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",h?"min-h-36":"h-36 overflow-hidden",d&&"border-foreground",g&&"border-warning/60",p?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[n.jsx("input",{type:"checkbox",value:e,checked:d,disabled:p,onChange:y,className:"shrink-0 accent-primary"}),n.jsx("span",{ref:v,title:I(t,T),className:ie("min-w-0",h?"[overflow-wrap:anywhere]":"truncate"),children:t}),s&&n.jsx("span",{className:"shrink-0 font-sans text-label text-muted-foreground",children:s})]}),r?n.jsx("span",{"data-line":!0,className:"mt-1 truncate font-sans text-small text-muted-foreground",children:r}):a&&!h?n.jsx("span",{ref:w,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:I(a,C),children:a}):null,l&&n.jsx("span",{ref:k,"data-tag":!0,title:I(c,L),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:l}),u&&!h&&n.jsx("span",{ref:N,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:I(u,D),children:u}),h&&n.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[a&&n.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:a}),c&&c!==a&&n.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),u&&n.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:u})]}),O&&n.jsx("button",{type:"button",onClick:W,"aria-expanded":h,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:h?"Less":"More"})]})}function ld(e,t,s,r){const[a,l]=x.useState(null);return x.useLayoutEffect(()=>{const c=e.current;if(s||!c)return;const u=()=>{(t==="width"?c.clientWidth>0:c.clientHeight>0)&&l(t==="width"?c.scrollWidth>c.clientWidth+1:c.scrollHeight>c.clientHeight+1)};u();const d=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return d==null||d.observe(c),()=>d==null?void 0:d.disconnect()},[e,t,s,r]),a}function oD({servers:e,tools:t,harness:s,harnesses:r,onChange:a,onRetry:l}){const c=m=>a(t.includes(m)?t.filter(v=>v!==m):[...t,m]),u=t.filter(m=>ya(m)),d=!r||r.includes(s),p=(m,v,w,k,N,A)=>{const _=t.includes(m),S=(!d||!!N)&&!_,E=k??N??(_&&!d?`Won't run on ${s}.`:void 0);return n.jsx("li",{className:"min-w-0",children:n.jsx(zx,{value:m,name:v,note:A,description:w,alert:E,on:_,disabled:S,warn:!!k,onToggle:()=>c(m)})},m)},g=m=>n.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:m}),y=!d&&n.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 n.jsxs("div",{className:"mt-4 space-y-2",children:[n.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",l&&n.jsx(K,{type:"button",onClick:l,size:"xs",className:"ml-1",children:"Retry"})]}),u.length>0&&g(u.map(m=>p(m,m,"Can't check right now whether its server still lists it.")))]});if(!e)return u.length?n.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const h=IM(t,e);return!e.length&&!h.length?n.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."}):n.jsxs("div",{className:"mt-4 space-y-4",children:[y,e.map(m=>n.jsxs("section",{"aria-label":`MCP server ${m.name}`,children:[n.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[m.name," · MCP server"]}),g(m.tools.map(v=>{var w;return p(UN(m.name,v.name),v.name,[v.title,v.description].filter(Boolean).join(": ")||void 0,void 0,PM(v,s)??(v.permission==="deny"?Sx:void 0),(w=m.not_metered)!=null&&w.includes(v.name)?"not metered":void 0)}))]},m.name)),h.length>0&&n.jsxs("section",{"aria-label":"MCP grants that can't run",children:[n.jsx("p",{className:"caps mb-2 text-label font-semibold text-warning-text",children:"Granted, but not on a saved server"}),g(h.map(m=>p(m.grant,m.grant,void 0,m.why)))]})]})}const aD="[a-z0-9][a-z0-9.-]{0,63}",iD="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",lD=new RegExp(`^monid:(${aD})/(\\*|${iD})$`),ic=e=>e.startsWith("monid:");function o2(e){const t=lD.exec(e);return t?{provider:t[1],endpoint:t[2]==="*"?null:t[2]}:void 0}function cD(e){if(!o2(e))return`${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.`}function uD(e){const t=e.trim();return!t||ic(t)?t:`monid:${t}`}function a2(e){return new Map(e.flatMap((t,s)=>ic(t)?[[`definition.tools[${s}]`,t]]:[]))}function dD(e,t){const s=a2(t),r=[],a=[];for(const l of e){const c=s.get(l.field);c?r.push({grant:c,warning:l}):a.push(l)}return{monid:r,rest:a}}const fD=e=>{const t=o2(e);return t?t.endpoint===null?`Every endpoint of ${t.provider} that monid prices per call, as monid lists them when the agent is saved.`:`${t.provider}'s /${t.endpoint}, priced and pinned when the agent is saved.`:"Not a monid endpoint's name: the save refuses it. Untick it."};function mD({tools:e,listed:t=[],notes:s=[],refused:r=[],onChange:a}){const[l,c]=x.useState(""),[u,d]=x.useState(void 0),p=[...new Set([...t,...e].filter(ic))],g=h=>a(e.includes(h)?e.filter(m=>m!==h):[...e,h]),y=()=>{const h=uD(l);if(!h)return;const m=cD(h);d(m),!m&&(c(""),e.includes(h)||a([...e,h]))};return n.jsxs("section",{"aria-label":"monid endpoints",className:"mt-4 space-y-2",children:[n.jsx("p",{className:"caps text-label font-semibold text-muted-foreground",children:"monid · paid endpoints"}),p.length>0&&n.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:p.map(h=>{const m=r.filter(v=>v.grant===h);return n.jsx("li",{className:"min-w-0",children:n.jsx(zx,{value:h,name:h,description:fD(h),alert:m.length?"The save was refused here: see below.":void 0,warn:m.length>0,on:e.includes(h),disabled:!1,onToggle:()=>g(h)})},h)})}),n.jsxs("form",{className:"flex flex-wrap items-start gap-2",onSubmit:h=>{h.preventDefault(),y()},children:[n.jsx(Be,{"aria-label":"monid grant",value:l,onChange:h=>{c(h.target.value),d(void 0)},"aria-invalid":u?!0:void 0,placeholder:"monid:<provider>/<endpoint> or monid:<provider>/*",className:"min-w-0 flex-[1_1_18rem]",spellCheck:!1,autoCapitalize:"off",autoComplete:"off"}),n.jsxs(K,{type:"submit",size:"sm",className:"h-control-md",disabled:!l.trim(),children:[n.jsx(yi,{"aria-hidden":!0})," Grant"]})]}),u&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u}),n.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&&n.jsx("ul",{className:"space-y-1 font-mono text-small text-destructive-text",role:"alert","aria-label":"monid grants refused",children:r.map((h,m)=>n.jsx("li",{children:h.message},`${h.grant}:${m}`))}),s.length>0&&n.jsx("ul",{className:"space-y-1 font-mono text-small text-warning-text",role:"status","aria-label":"monid save warnings",children:s.map((h,m)=>n.jsx("li",{children:h.message},`${h.grant}:${m}`))})]})}const pD=e=>e.offered&&(e.kind==="none"||e.providers.some(t=>t.ready)),hD=e=>{var t;return e.why??((t=e.providers.find(s=>!s.ready))==null?void 0:t.why)};function gD(e,t){var a;if(e.kind==="none")return{kind:"none"};const r=((t==null?void 0:t.kind)===e.kind&&e.providers.some(l=>l.ready&&l.id===t.provider)?t.provider:void 0)??((a=e.providers.find(l=>l.ready))==null?void 0:a.id);return r?{kind:e.kind,provider:r}:{kind:e.kind}}const xD=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},Dx="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",Fx=new Set(["sandbox","desktop","phone"]),yD=e=>e.charAt(0).toUpperCase()+e.slice(1);function bD({kinds:e,value:t,onChange:s,error:r,warning:a}){const l=e.find(c=>c.kind===t.kind);return n.jsxs("div",{children:[n.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Kind"}),n.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 u=pD(c),d=u?void 0:hD(c),p=c.providers.filter(g=>g.ready).map(g=>g.name).join(", ");return n.jsxs("div",{"data-kind":c.kind,className:ie("border px-4 py-3",t.kind===c.kind?"border-foreground":"border-border",!u&&"opacity-60"),children:[n.jsxs("label",{className:ie("flex items-start gap-3",u?"cursor-pointer":"cursor-not-allowed"),children:[n.jsx("input",{type:"radio",name:"computer-kind",value:c.kind,checked:t.kind===c.kind,disabled:!u&&t.kind!==c.kind,onChange:()=>s(gD(c,t)),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-lead font-semibold",children:yD(c.kind)}),n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:u?c.kind==="none"?"The run's folder only":p:"Not available here"})]})]}),d&&n.jsxs("p",{className:"mt-2 break-words text-small text-muted-foreground",children:[d," ",n.jsx("a",{href:"#/settings/computers",className:"underline underline-offset-2 hover:text-foreground",children:"Computers settings"})]})]},c.kind)})}),l&&l.kind!=="none"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mb-2 mt-5 caps text-small font-semibold",children:"Provider"}),n.jsx("ul",{className:"border",role:"radiogroup","aria-label":"Provider",children:l.providers.map(c=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("label",{className:ie("flex items-start gap-3 px-4 py-2.5",c.ready?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[n.jsx("input",{type:"radio",name:"computer-provider",value:c.id,checked:t.provider===c.id,disabled:!c.ready&&t.provider!==c.id,onChange:()=>s({kind:l.kind,provider:c.id}),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("span",{className:"text-body font-semibold",children:c.name}),c.metered&&n.jsx("span",{className:"caps text-label text-muted-foreground",children:"Metered"})]}),c.metered&&Fx.has(l.kind)&&n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:Dx}),!c.ready&&c.why&&n.jsx("span",{className:"mt-0.5 block text-small",children:c.why})]})]})},c.id))})]}),l&&l.tools.length>0&&n.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: ",n.jsx("span",{className:"font-mono",children:l.tools.join(", ")})]}),r&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:r}),a&&n.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:a})]})}function vD({value:e,saved:t,places:s,tools:r,picked:a,onChange:l,error:c,warning:u}){var S;const d=e??Df(t),p=(d??Ix(!1,a,s)).mode,g=(S=s.boxes.find(E=>E.available))==null?void 0:S.id,y=(d==null?void 0:d.mode)==="sandbox"?d.box:g,h=!g&&p!=="sandbox",m=new Set(r.filter(E=>E.sandbox_only).map(E=>E.name)),[v,w]=x.useState([]),k=()=>{const E=a.filter(T=>m.has(T));w(E),l({place:{mode:"runner"},...E.length?{tools:a.filter(T=>!m.has(T))}:{}})},N=E=>{w([]),E&&l({place:{mode:"sandbox",box:E}})},A=E=>E.map(T=>T.charAt(0).toUpperCase()+T.slice(1)).join(" and "),_=(E,T,C,R,D=!1)=>n.jsxs("label",{className:ie("flex items-start gap-3 border px-4 py-3",p===E?"border-foreground":"border-border",D?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[n.jsx("input",{type:"radio",name:"place",value:E,checked:p===E,disabled:D,onChange:R,className:"mt-1 accent-primary"}),n.jsxs("span",{children:[n.jsx("span",{className:"block text-lead font-semibold",children:T}),n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:C})]})]});return n.jsxs("div",{children:[n.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),n.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[_("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",k),_("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>N(y),h)]}),h&&n.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[n.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),n.jsx("ul",{className:"mt-1",children:s.boxes.map(E=>n.jsxs("li",{children:[n.jsx("span",{className:"font-mono",children:E.id}),E.reason?`: ${E.reason}`:""]},E.id))})]}),p==="sandbox"&&n.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map(E=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("label",{className:ie("flex items-start gap-3 px-4 py-2.5",E.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[n.jsx("input",{type:"radio",name:"box",value:E.id,checked:y===E.id,disabled:!E.available&&y!==E.id,onChange:()=>N(E.id),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block font-mono text-body",children:E.id}),!E.available&&E.reason&&n.jsx("span",{className:"mt-0.5 block text-small",children:E.reason})]})]})},E.id))}),p==="runner"&&v.length>0&&n.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[A(v)," ",v.length===1?"runs":"run"," only in a sandbox, so ",v.length===1?"it's":"they're"," turned off for this agent."]}),c&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),u&&n.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:u})]})}function i2(e,t,s=t.map(r=>r.name)){return[...new Set([...s.filter(a=>e.some(l=>l.name===a)||t.some(l=>l.name===a)),...t.map(a=>a.name),...e.map(a=>a.name)])].map(a=>{const l=e.find(u=>u.name===a),c=t.find(u=>u.name===a);return{name:a,...l?{choice:l}:{},...c?{gate:c}:{}}})}function eg({setting:e,label:t="Pinned",also:s=!1}){return e!=null&&e.pin_broken?n.jsx("p",{className:"max-w-[640px] text-small text-warning-text",role:"note",children:hP}):e!=null&&e.pin?n.jsxs("p",{className:"max-w-[640px] text-small text-muted-foreground",role:"note",children:[n.jsxs("span",{className:"text-foreground",children:[t,":"]})," ",mP(e.pin),". ",pP,s?" This server pins it too; both hold.":""]}):null}const Q0={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."]},wD=({effect:e})=>n.jsx("span",{"data-effect":e,children:n.jsx(Ne,{tone:Q0[e][0],title:Q0[e][1],children:e})}),kD="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function Ux({label:e,rows:t,settings:s,fallbackOf:r,permissionFallbackOf:a=A=>A.default_permission,resolvesOf:l,issues:c,busy:u=!1,refused:d=()=>!1,locked:p=!1,unattended:g=!1,noteOf:y,labelOf:h,detailOf:m,effectOf:v,confirmAllowOf:w=()=>!1,fallbackWordOf:k,onEdit:N}){const[A,_]=x.useState(null),S=x.useRef(null),E=x.useRef(null);x.useEffect(()=>{var W,U;if(A!==null||u||S.current===null)return;const I=`${S.current} permission`;S.current=null,(U=[...((W=E.current)==null?void 0:W.querySelectorAll("button[aria-label]"))??[]].find(J=>J.getAttribute("aria-label")===I))==null||U.focus()},[A,u]);const T=I=>{S.current=I,_(null)},C=t.some(I=>I.choice),R=t.some(I=>I.gate),D=t.some(I=>{var W;return((W=I.gate)==null?void 0:W.ask_needs)==="password"}),L=["Tool",...R?["Permission"]:[],...C?["Provider","Resolves to"]:[]],O=n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return n.jsxs(n.Fragment,{children:[D&&n.jsx("p",{className:"mb-2 text-small text-warning-text",children:kD}),n.jsx("div",{ref:E,className:"relative overflow-x-auto",children:n.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[L.map(I=>n.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:I},I)),n.jsx("th",{children:n.jsx("span",{className:"sr-only",children:"Reset"})})]})}),n.jsx("tbody",{children:t.map(({name:I,choice:W,gate:U})=>{var ge,se,pe;const J=W?r(W):"",F=(ge=s[I])==null?void 0:ge.provider,Z=W!==void 0&&F!==void 0&&F!==J,z=Z?F:J,H=Y=>N(_e=>lP(_e,I,Y,J)),V=U?a(U):"allow",P=(se=s[I])==null?void 0:se.permission,B=U!==void 0&&P!==void 0&&P!==V,q=B?P:V,ce=U!==void 0&&d(I,q),de=ce&&p,ue=de?"deny":q,Q=Y=>N(_e=>cP(_e,I,Y,V)),fe=v==null?void 0:v(I),ye=(k==null?void 0:k(I))??"default",Ee=m==null?void 0:m(I);return n.jsxs(x.Fragment,{children:[n.jsxs("tr",{"data-tool":I,"data-set":Z||B?"":void 0,className:"border-b align-top last:border-b-0",children:[n.jsxs("td",{className:"px-3 py-2.5 font-mono text-body",children:[n.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[(h==null?void 0:h(I))??I,fe&&n.jsx(wD,{effect:fe})]}),Ee?n.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:Ee}):null]}),R&&n.jsx("td",{className:"px-3 py-2",children:U?n.jsxs(n.Fragment,{children:[n.jsx(Lt,{small:!0,label:`${I} permission`,value:ue,disabled:u||de,onChange:Y=>{const _e=Y;_e==="allow"&&_e!==ue&&w(I)?_(I):Q(_e)},className:ie(k?"w-48":"w-36",B&&"border-primary text-primary"),options:U.permissions.map(Y=>({value:Y,label:`${Y}${Y===V?` (${ye})`:""}`,...Y==="ask"&&U.ask_needs==="password"&&!g?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),B&&!de&&n.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",V,ye==="default"?"":` (${ye})`]}),ce&&n.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:Sx}),ue==="deny"&&n.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:rP}),ue==="ask"&&g&&!ce&&n.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),ue==="ask"&&U.ask_needs==="password"&&!g&&n.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."})]}):O}),C&&n.jsx("td",{className:"px-3 py-2",children:W?n.jsxs(n.Fragment,{children:[n.jsx(Lt,{small:!0,label:`${I} provider`,value:z,disabled:u,onChange:Y=>H(Y),className:ie("w-56 max-w-full",Z&&"border-primary text-primary"),options:W.providers.map(Y=>({value:Y,label:`${Qd(Y,I)}${Y===J?" (default)":""}`}))}),h0(z,I)&&n.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:h0(z,I)}),Z&&n.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Qd(J,I)]})]}):O}),C&&n.jsx("td",{className:"px-3 py-2.5",children:W?l(W,z):O}),n.jsx("td",{className:"px-2 py-2 text-right",children:Z&&n.jsx(K,{size:"sm",variant:"ghost",disabled:u,"aria-label":`Reset ${I} to its default`,onClick:()=>H(void 0),children:"Reset"})})]}),A===I&&n.jsx("tr",{children:n.jsx("td",{colSpan:L.length+1,className:"px-3 pb-2.5",children:n.jsx(jD,{name:I,keep:ue==="ask"?"Keep asking":"Cancel",busy:u,onAllow:()=>{u||(T(I),Q("allow"))},onKeep:()=>T(I)})})}),y!=null&&y(I)?n.jsx("tr",{"data-note":I,children:n.jsx("td",{colSpan:L.length+1,className:"px-3 pb-2.5",children:y(I)})}):null,(pe=c[I])!=null&&pe.length?n.jsx("tr",{children:n.jsx("td",{colSpan:L.length+1,className:"px-3 pb-2.5",children:c[I].map(Y=>n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:Y},Y))})}):null]},I)})})]})})]})}function jD({name:e,keep:t,busy:s,onAllow:r,onKeep:a}){const l=x.useRef(null);return x.useEffect(()=>{var c;(c=l.current)==null||c.focus()},[]),n.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e} without asking?`,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),a())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Allow a destructive tool?"})," Its server marks ",n.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite: every call would run with no one asked."]}),n.jsx(K,{ref:l,type:"button",size:"sm",variant:"ghost",onClick:a,children:t}),n.jsx(K,{type:"button",size:"sm",variant:"destructive",disabled:s,onClick:r,children:"Allow without asking"})]})}function tg({value:e,prefix:t,tool:s}){const r=jS(e,s);return n.jsxs("span",{className:ie("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[t,r.text]})}const ND=({choice:e,harnesses:t=[]})=>n.jsx(n.Fragment,{children:eP.map(s=>{const r=t.find(a=>a.id===s&&!a.available);return r?n.jsxs("span",{title:r.reason,className:"block font-mono text-small text-muted-foreground opacity-60",children:[s,": not offered here"]},s):n.jsx(tg,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function SD({agent:e,harness:t,model:s,tools:r,choices:a,gates:l=[],mcpServers:c,serverSettings:u,focus:d,callTools:p,value:g,issues:y,unattended:h=!1,onChange:m}){const v=new Set(r),w=a.filter(O=>v.has(O.name)||!O.available),k=l.some(O=>O.ask_needs==="password"),N=O=>{var I;return(I=e==null?void 0:e.tools)==null?void 0:I.find(W=>W.name===O)},A=O=>{var W;const I=ya(O);return I?(W=c==null?void 0:c.find(U=>U.name===I.server))==null?void 0:W.tools.find(U=>U.name===I.tool):void 0},_=O=>{var W;const I=ya(O);return I?(W=g[`mcp:${I.server}/*`])==null?void 0:W.permission:void 0},S=p?p.flatMap(O=>l.filter(I=>I.name===O)):[...new Set(r)].flatMap(O=>{var U;const I=l.find(J=>J.name===O);if(I)return[I];const W=N(O)??A(O);return!((U=W==null?void 0:W.permissions)!=null&&U.length)||!W.default_permission?[]:[{name:O,permission:W.permission??W.default_permission,default_permission:W.default_permission,permissions:W.permissions,...k&&W.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),E=i2(w,S,[...l.map(O=>O.name),...a.map(O=>O.name)]),T=x.useRef(null);if(x.useEffect(()=>{var W,U;if(!d)return;const O=`${d} permission`,I=[...((W=T.current)==null?void 0:W.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(J=>J.getAttribute("aria-label")===O);(U=I==null?void 0:I.scrollIntoView)==null||U.call(I,{block:"center"}),I==null||I.focus()},[]),!E.length)return null;const C=(e==null?void 0:e.definition.tool_settings)??{},R=h!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:D,rest:L}=SS(y,"definition.tool_settings",E.map(O=>O.name));return n.jsxs("section",{"aria-label":"Tool settings",ref:T,children:[n.jsx("div",{className:"mb-2",children:n.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),n.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. ",p?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":h?"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."]}),n.jsx(Ux,{label:"This agent's tool settings",unattended:h,rows:E,settings:g,fallbackOf:O=>O.provider,issues:D,onEdit:O=>m(O(g)),effectOf:O=>{var I;return(I=A(O))==null?void 0:I.effect},confirmAllowOf:O=>{var I;return((I=A(O))==null?void 0:I.effect)==="destructive"},noteOf:O=>{const I=g[O],W=u==null?void 0:u[O],U=!!(I!=null&&I.pin||I!=null&&I.pin_broken);return!U&&!(W!=null&&W.pin)&&!(W!=null&&W.pin_broken)?null:n.jsxs(n.Fragment,{children:[U&&n.jsx(eg,{setting:I,label:"Pinned for this agent",also:!!(W!=null&&W.pin)}),(!U||(W==null?void 0:W.pin_broken))&&n.jsx(eg,{setting:W,label:"Pinned on this server"})]})},refused:O=>wS(O,l,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:O=>{var I;return _(O.name)??((I=N(O.name))==null?void 0:I.default_permission)??O.permission},resolvesOf:O=>{var F,Z,z,H,V,P;const I=(((F=g[O.name])==null?void 0:F.provider)??null)!==(((Z=C[O.name])==null?void 0:Z.provider)??null)||(((z=g[O.name])==null?void 0:z.permission)??null)!==(((H=C[O.name])==null?void 0:H.permission)??null)||R,W=(V=e==null?void 0:e.tools)==null?void 0:V.find(B=>B.name===O.name),U=W&&W.provider===(((P=g[O.name])==null?void 0:P.provider)??O.provider)?W.resolved:void 0,J=(s??"")===((e==null?void 0:e.definition.model)??"");return!I&&t===((e==null?void 0:e.definition.harness)??"pi")&&J&&U?n.jsx(tg,{value:U,prefix:`${t}: `,tool:O.name}):!I&&!C[O.name]&&!s?n.jsx(tg,{value:O.resolves[t],prefix:`${t}: `,tool:O.name}):n.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),L.map(O=>n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:O},O))]})}const cd=20,_D=400;function $D(e,t,s,r,a){const[l,c]=x.useState(null),[u,d]=x.useState(0),p=(r??[]).join(",");x.useEffect(()=>{if(!a||!s||l==="unsupported")return;const y=new AbortController,h=setTimeout(()=>{a({workflow:t,...r?{tools:r}:{}},y.signal).then(m=>{y.signal.aborted||c({text:e,check:m})},m=>{y.signal.aborted||((m==null?void 0:m.status)===404||(m==null?void 0:m.status)===405?c("unsupported"):c({text:e,failed:(m==null?void 0:m.message)||`the server answered ${(m==null?void 0:m.status)??"nothing"}`}))})},_D);return()=>{clearTimeout(h),y.abort()}},[e,s,p,a,u]);const g=()=>{c(null),d(y=>y+1)};return l==="unsupported"||!a?{mode:"lint",retry:g}:l&&l.text===e?"failed"in l?{mode:"failed",failed:l.failed,retry:g}:{mode:"server",check:l.check,retry:g}:{mode:"pending",retry:g}}function J0({text:e,onText:t,base:s,baseLabel:r,serverIssues:a,readOnly:l=!1,validate:c,tools:u}){var J;const d=x.useRef(null),p=x.useRef(null),[g,y]=x.useState(0),h=x.useMemo(()=>h4(e),[e]),m=x.useRef(null);h.ok&&(m.current={value:h.value,spans:h.spans});const v=(J=m.current)==null?void 0:J.value,w=x.useMemo(()=>hi(v),[v]),k=x.useMemo(()=>s===void 0?null:hi(s),[s]),N=x.useMemo(()=>k?Ck(k,w):null,[k,w]),A=$D(e,h.ok?h.value:void 0,h.ok,u,l?void 0:c),_=x.useMemo(()=>h.ok&&!l?b4(h.value):[],[h,l]),S=x.useMemo(()=>A.mode!=="server"?_:[...A.check.issues.map(F=>({path:F.path,message:F.message,severity:"error"})),...A.check.warnings.map(F=>typeof F=="string"?{path:"",message:F,severity:"warning"}:{path:F.path??"",message:F.message,severity:"warning"})],[A.mode,A.mode==="server"?A.check:null,_]),E=h.ok?v4(h.spans,w.nodes.map(F=>F.path),g):null,T=x.useMemo(()=>({meta:vc(v,w),diff:N?{added:N.added.map(F=>F.path),edited:[...N.changed,...N.rewritten].map(F=>F.next),moved:N.moved.map(F=>F.next),removed:N.removed.map(({label:F,kind:Z})=>({label:F,kind:Z}))}:void 0,selected:E?{path:E}:null}),[v,w,N,E]),C=e.split(`
558
+ `).length,R=F=>g4(e,F),D=[];h.ok||D.push({...R(h.error.offset),message:`JSON: ${h.error.message}`,severity:"error",offset:h.error.offset});for(const F of S){const Z=h.ok?Mw(h.spans,F.path):void 0,z=(Z==null?void 0:Z.start)??0;D.push({...R(z),message:F.message,severity:F.severity,offset:z,path:F.path})}for(const F of[...a??[]].reverse()){const Z=F.path&&h.ok?Mw(h.spans,F.path):void 0;D.unshift({...Z?R(Z.start):{line:0,col:0},message:`Server: ${F.message}`,severity:"error",offset:(Z==null?void 0:Z.start)??-1})}const L=new Map;for(const F of D)F.line&&L.get(F.line)!=="error"&&L.set(F.line,F.severity);const O=(F,Z=F)=>{const z=d.current;!z||F<0||(z.focus(),z.setSelectionRange(F,Z),z.scrollTop=Math.max(0,(R(F).line-4)*cd),y(F))};x.useEffect(()=>{const F=h.ok?h.spans.get("/root"):void 0;F&&d.current&&(d.current.scrollTop=Math.max(0,(R(F.start).line-2)*cd))},[]);const I=N?N.edges.added.length+N.edges.removed.length:0,W=N?N.added.length+N.changed.length+N.rewritten.length+N.removed.length+N.moved.length+I:0,U=D.filter(F=>F.severity==="error").length;return n.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[n.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[n.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[C," lines"]}),n.jsx("span",{className:"flex-1"}),l?n.jsx("span",{className:"caps text-label text-muted-foreground",children:"Read-only"}):n.jsxs(n.Fragment,{children:[A.mode==="failed"&&h.ok?n.jsxs("span",{className:"font-mono text-label text-warning-text",title:A.failed,children:["server check failed, showing local checks ",n.jsx(K,{type:"button",onClick:A.retry,size:"xs",className:"ml-1",children:"Retry"})]}):A.mode!=="lint"&&h.ok&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:A.mode==="pending"?"checking...":"checked by the server"}),U?n.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[n.jsx(gi,{className:"size-3.5","aria-hidden":!0})," ",U," ",U===1?"problem":"problems"]}):n.jsx("span",{className:"caps text-label text-success-text",children:A.mode==="server"?"Valid":"Valid shape"})]})]}),n.jsxs("div",{className:"relative flex h-[560px] min-h-0 xl:h-[calc(100vh-390px)] xl:min-h-[440px]",children:[n.jsx("div",{ref:p,"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:`${cd}px`},children:Array.from({length:C},(F,Z)=>n.jsx("div",{className:ie("pr-2",L.get(Z+1)==="error"&&"bg-destructive/15 text-destructive-text",L.get(Z+1)==="warning"&&"bg-warning/15 text-warning-text"),children:Z+1},Z))}),n.jsx(ds,{bare:!0,ref:d,value:e,readOnly:l,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:F=>{l||t(F.target.value),y(F.target.selectionStart)},onSelect:F=>y(F.target.selectionStart),onScroll:F=>{p.current&&(p.current.scrollTop=F.target.scrollTop)},onKeyDown:F=>{if(F.key!=="Tab"||l)return;F.preventDefault();const Z=F.currentTarget,z=Z.selectionStart,H=Z.selectionEnd;t(`${e.slice(0,z)} ${e.slice(H)}`),requestAnimationFrame(()=>Z.setSelectionRange(z+2,z+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:`${cd}px`,tabSize:2}})]}),!l&&n.jsxs("ul",{className:"max-h-48 min-h-[44px] overflow-auto border-t font-mono text-small","aria-label":"Problems",children:[D.length===0&&n.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:A.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."}),D.map((F,Z)=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>O(F.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[F.severity==="error"?n.jsx(gi,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):n.jsx(Zs,{className:"mt-0.5 size-3.5 shrink-0 text-warning-text","aria-hidden":!0}),n.jsx("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",children:F.line?`L${F.line}:${F.col}`:"—"}),n.jsx("span",{className:"min-w-0 flex-1 break-words",children:F.message})]})},Z))]})]}),n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:zf(Ox(w))}),N&&(W?n.jsxs("span",{className:"font-mono text-label",children:[[N.added.length&&`${N.added.length} new`,N.changed.length+N.rewritten.length&&`${N.changed.length+N.rewritten.length} edited`,N.removed.length&&`${N.removed.length} removed`,N.moved.length&&`${N.moved.length} moved`,!N.moved.length&&I&&`${I} ${I===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",n.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),n.jsx("span",{className:"flex-1"}),!h.ok&&m.current&&n.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),n.jsx("div",{className:ie("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]",!h.ok&&"opacity-60"),children:w.nodes.length?n.jsx(Tc,{graph:w,marks:T,label:"The workflow's graph",minScale:.55,onSelect:F=>{const Z=h.ok?h.spans.get(`${F.path}/label`)??h.spans.get(F.path):void 0;Z&&O(Z.start,Z.end)}}):n.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),n.jsx("div",{className:"border-t px-4 py-2",children:n.jsx(Rc,{})})]})]})}const ED="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function l2(){return n.jsxs(n.Fragment,{children:["A run on Sonnet needs about $0.10 to take a few steps; under that it pauses before its next step (",n.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:ED,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let si=null;function ud(e,t){return si?si({to:e,replay:t}):!1}function CD(e){const[t,s]=x.useState(null),r=x.useRef(location.hash);return x.useEffect(()=>{if(!e)return;const a=c=>c.to===r.current?!1:(s(c),!0);si=a;const l=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",l),()=>{si===a&&(si=null),window.removeEventListener("beforeunload",l)}},[e]),{asking:t!==null,stay:()=>s(null),leave:()=>{var a;if(t!==null){if(s(null),t.to===null){(a=t.replay)==null||a.call(t);return}if(si=null,!t.replay){location.hash=t.to;return}location.hash!==r.current?window.addEventListener("hashchange",t.replay,{once:!0}):t.replay()}}}}const c2="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",lh="custom",Z0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function TD(e,t){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,a])=>({path:r.slice(19),message:a}));return s.length?s:t?[{path:"",message:e.message}]:null}function RD(e){var s;const t=(s=/^definition\.([a-z_]+)/.exec(e))==null?void 0:s[1];if(t){if(["name","description","instructions"].includes(t))return"context";if(["tools","tool_settings","approvals","skills"].includes(t))return"tools";if(["harness","thinking","model","max_cost_usd","learning"].includes(t))return"settings";if(["place","computer"].includes(t))return"computer";if(t==="workflow")return"workflow"}}const AD=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Si},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:ka},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:wa},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Nd},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:Dk},{id:"history",label:"History",note:"Revisions and the current one",Icon:xg}];function OD({agent:e,revisions:t=[],caps:s,onSave:r,onMakeCurrent:a,onArchive:l,onReload:c,onBack:u,step:d,problem:p=null,notice:g,draft:y,validate:h,providerChoices:m=[],permissionGates:v=[],focusTool:w,mcpServers:k=null,serverToolSettings:N,onRetryMcp:A}){var Nt,Cn,ps,hs,gs,Un,Ms;const _=!e,S=e==null?void 0:e.definition,[E,T]=x.useState(d??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),C=_?ah(s.places):void 0,[R,D]=x.useState({name:(S==null?void 0:S.name)??"",description:(S==null?void 0:S.description)??"",instructions:(S==null?void 0:S.instructions)??(_?xz:""),harness:(S==null?void 0:S.harness)??"pi",thinking:S==null?void 0:S.thinking,model:S==null?void 0:S.model,tools:_?ih("pi",s.tools,C):(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):"",...C?{place:C}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:y??JSON.stringify(S.workflow,null,2)}:{}}),[L,O]=x.useState(!1),I=x.useRef(R);I.current=R;const[W,U]=x.useState(R),J=ee=>{const{maxCostText:Se,workflowText:Ye,...ft}=ee,jt=U0(Se),Ut=Z0(Ye),vn={...ft,maxCost:jt.ok?jt.value??0:Se,...Ye!==void 0?{workflowSent:Ut!==void 0?Ut:Ye}:{}},St=e?{...Mx(e,vn,"").definition}:{...vn};return delete St.version,St.tool_settings&&!Object.keys(St.tool_settings).length&&delete St.tool_settings,{...St,tools:[...St.tools??[]].sort(),approvals:ee.approvals??(S==null?void 0:S.approvals)??"ask"}},F=!Hl(J(R),J(W)),[Z,z]=x.useState([]),[H,V]=x.useState(!1),P=s.tools.map(ee=>`${ee.name}:${ee.available}:${(ee.harnesses??[]).join("+")}`).join(","),B=JSON.stringify(ah(s.places)??null);x.useEffect(()=>{if(!_)return;const ee=Se=>{const Ye=Se.place??ah(s.places);return{...Se,...Ye?{place:Ye}:{},...H?{}:{tools:ih(Se.harness??"pi",s.tools,Ye)}}};D(ee),U(ee)},[P,B]);const[q,ce]=x.useState(""),[de,ue]=x.useState(()=>((S==null?void 0:S.tools)??[]).filter(ic)),[Q,fe]=x.useState(!1),[ye,Ee]=x.useState(!1),[ge,se]=x.useState(p),[pe,Y]=x.useState(null),_e=ee=>{Y(null),T(ee)},Ze=x.useRef(null),Je=a2(Ze.current??R.tools??[]),xt=(ge==null?void 0:ge.kind)==="invalid"?Object.entries(ge.fields).flatMap(([ee,Se])=>{const Ye=Je.get(ee);return Ye?[{grant:Ye,message:Se}]:[]}):[],et=ee=>(ge==null?void 0:ge.kind)==="invalid"&&Object.entries(ge.fields).filter(([Se])=>!Je.has(Se)&&(Se===`definition.${ee}`||Se.startsWith(`definition.${ee}[`)||Se.startsWith(`definition.${ee}.`))).map(([,Se])=>Se).join(" ")||void 0,{monid:ae,rest:Ae}=dD((e==null?void 0:e.warnings)??[],(S==null?void 0:S.tools)??[]),Ce=ee=>_z(Ae,ee).map(Se=>Se.message).join(" ")||void 0,Ge=ee=>{_&&ye||D(Se=>({...Se,...ee}))},kt=x.useRef(null);x.useEffect(()=>{var ee;((ge==null?void 0:ge.kind)==="invalid"||(ge==null?void 0:ge.kind)==="other")&&((ee=kt.current)==null||ee.focus())},[ge]);const We=(e==null?void 0:e.kind)==="workflow",rt=_&&qS(R.harness),yn=[...(Nt=R.name)!=null&&Nt.trim()?[]:["Give the agent a name to create it."],...!We&&!rt&&!((Cn=R.instructions)!=null&&Cn.trim())?["Write its instructions to create it."]:[]],Dt=R.approvals??(S==null?void 0:S.approvals)??"ask",sn=Nz(s.harnesses,_?{available:!!s.decisionProvider}:void 0),me={mcpHarnesses:s.mcpHarnesses,workflow:We},Te=ee=>{if(ee.mode==="sandbox")return;const Se=new Set(s.tools.filter(Ye=>Ye.sandbox_only).map(Ye=>Ye.name));z(Ye=>Ye.filter(ft=>!Se.has(ft)))},tt=ee=>{if(_&&!H){Ge({harness:ee,tools:ih(ee,s.tools,R.place)}),z([]);return}const Se=vz(ee,R.tools??[],Z,s.tools,me);Ge({harness:ee,tools:Se.tools}),z(Se.held)},Fe=t.find(ee=>ee.revision===(e==null?void 0:e.revision))??t.find(ee=>ee.current),lt=AD.filter(ee=>!(_&&ee.id==="history")&&(ee.id!=="workflow"||We)&&!(rt&&ee.id==="tools")&&(ee.id!=="computer"||!We&&!rt&&!!(s.computers||s.places))),Ke=lt.some(ee=>ee.id===E)?E:lt[0].id,Ft=lt.findIndex(ee=>ee.id===Ke),Qn=async()=>{if(!r)return;const ee=R;Ze.current=R.tools??[],Ee(!0);let Se={...R,workflowText:void 0,maxCostText:void 0};if(!rt){const jt=U0(R.maxCostText);if(!jt.ok){Ee(!1),se({kind:"invalid",message:jt.message,fields:{"definition.max_cost_usd":jt.message}});return}const Ut=typeof(S==null?void 0:S.max_cost_usd)=="number"&&S.max_cost_usd>0,vn=jt.value??0;(vn!==0||Ut)&&(Se={...Se,max_cost_usd:vn})}if(We)try{Se={...Se,workflow:JSON.parse(R.workflowText??"")}}catch(jt){Ee(!1),se({kind:"invalid",message:`The workflow is not JSON: ${jt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${jt.message}`}});return}const Ye=await r(Se,q),ft=Hl(I.current.tool_settings??{},Se.tool_settings??{});Ee(!1),se(Ye),!Ye&&(ce(""),I.current.harness===ee.harness&&z([]),U(ft?(({tool_settings:jt,...Ut})=>Ut)(ee):ee),ft&&D(({tool_settings:jt,...Ut})=>Ut))},Jn=CD(!ye&&F),Zn=s2(R.harness??"pi",s.harnesses),bn=Zn?ef(Zn,s.routePrefix):void 0,es=Bz(R.harness??"pi",s.harnesses),un=L||R.model!==void 0&&!es.includes(R.model),ms=[{value:"",label:bn?`Server default (${bn.text})`:"Server default"},...es.map(ee=>({value:ee,label:ef(ee,s.routePrefix).text})),{value:lh,label:"Custom..."}],gr=Ff(R.harness??"pi",s.tools).filter(ee=>B0([ee.name])).map(ee=>ee.name);return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4 md:px-8",children:[n.jsx(K,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:u,children:n.jsx(Es,{"aria-hidden":!0})}),n.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:_?void 0:S.name,children:_?"New agent":S.name}),e&&n.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[n.jsx(Ne,{children:e.kind}),n.jsxs("span",{className:"caps text-label text-muted-foreground",children:[Fe?`rev ${Fe.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),l&&n.jsxs(K,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>l(!e.archived_at),children:[n.jsx(cc,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(ge==null?void 0:ge.kind)==="conflict"&&n.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-card px-5 py-3 md:px-8",role:"alert",children:[n.jsx(Zs,{className:"size-4 text-warning-text","aria-hidden":!0}),n.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."}),n.jsx(K,{size:"sm",onClick:c,children:"Reload"})]}),g&&n.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}),(Ae.length>0||ae.length>0)&&n.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:Ae,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:ae.map(ee=>ee.warning),head:"Saved. What the server said of its monid grants:"}].filter(ee=>ee.lines.length).map(ee=>n.jsxs("div",{children:[n.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[n.jsx(Zs,{className:"size-4 shrink-0","aria-hidden":!0})," ",ee.head]}),n.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:ee.lines.map((Se,Ye)=>{const ft=lt.find(jt=>jt.id===RD(Se.field));return n.jsxs("li",{children:[ft?n.jsx("button",{type:"button",title:Se.field,onClick:()=>_e(ft.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:ft.label}):n.jsx("span",{className:"text-muted-foreground",children:Se.field})," ",Se.message]},`${Se.field}:${Ye}`)})})]},ee.head))}),n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[n.jsx("ol",{className:ie("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",Ke==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:lt.map((ee,Se)=>n.jsx("li",{className:"shrink-0",children:n.jsxs("button",{type:"button","aria-current":Ke===ee.id?"step":void 0,onClick:()=>_e(ee.id),className:ie("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",Ke===ee.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[n.jsx("span",{className:ie("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",Ke===ee.id?"border-foreground bg-foreground text-background":Se<Ft?"border-border-strong":"border-border"),children:Se<Ft?n.jsx(uc,{className:"size-3","aria-hidden":!0}):Se+1}),n.jsxs("span",{className:ie("hidden min-w-0",Ke!=="workflow"&&"md:block"),title:Ke==="workflow"?ee.label:void 0,children:[n.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[n.jsx(ee.Icon,{className:"size-3.5","aria-hidden":!0})," ",ee.label]}),n.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:ee.note})]}),n.jsx("span",{className:"sr-only md:hidden",children:ee.label})]})},ee.id))}),n.jsx("section",{className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-10",children:n.jsxs("fieldset",{disabled:_&&ye,className:"m-0 min-w-0 border-0 p-0",children:[n.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Step ",Ft+1]}),n.jsx("h2",{className:"caps mb-6 border-b pb-4 text-prose font-semibold",children:lt[Ft].label}),Ke==="context"&&n.jsxs("div",{className:"max-w-3xl space-y-6",children:[n.jsx(Gs,{label:"Name",id:"agent-name",required:_,note:_?void 0:"Set when the agent was created; an edit keeps it.",error:et("name"),warning:Ce("name"),children:n.jsx(Be,{id:"agent-name",value:R.name,readOnly:!_,onChange:ee=>Ge({name:ee.target.value}),placeholder:"e.g., Invoice checker"})}),n.jsx(Gs,{label:"Description",id:"agent-description",optional:!0,note:_?void 0:"Set when the agent was created; an edit keeps it.",error:et("description"),warning:Ce("description"),children:n.jsx(Be,{id:"agent-description",value:R.description,readOnly:!_,onChange:ee=>Ge({description:ee.target.value}),placeholder:_?"Short summary for the agent list":"No description"})}),rt?n.jsx(Gs,{label:"Workflow",children:n.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:R.harness===Lx?"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."})}):We?n.jsx(Gs,{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:Ce("workflow"),children:n.jsxs(K,{size:"sm",onClick:()=>T("workflow"),children:[n.jsx(ka,{"aria-hidden":!0})," Open the workflow"]})}):n.jsxs(Gs,{label:"Instructions",id:Q?void 0:"agent-instructions",required:!0,error:et("instructions"),warning:Ce("instructions"),aside:n.jsx("span",{className:"flex",children:["Preview","Edit"].map(ee=>n.jsx(K,{type:"button",size:"xs","aria-pressed":ee==="Preview"===Q,onClick:()=>fe(ee==="Preview"),className:ie("-ml-px first:ml-0",ee==="Preview"===Q?"relative border-foreground bg-foreground text-background hover:bg-foreground":"text-muted-foreground"),children:ee},ee))}),children:[Q?n.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:Lr(R.instructions||"")}}):n.jsx(ds,{id:"agent-instructions",value:R.instructions,onChange:ee=>Ge({instructions:ee.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:"resize-y leading-[1.7]"}),n.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(R.instructions??"").length," characters"]})]})]}),Ke==="workflow"&&n.jsx(J0,{text:R.workflowText??"",onText:ee=>Ge({workflowText:ee}),base:We?S.workflow:void 0,baseLabel:Fe?`rev ${Fe.version}`:void 0,validate:h,tools:R.tools,serverIssues:TD(ge,We)}),Ke==="computer"&&!We&&!rt&&s.computers&&n.jsx("div",{className:"max-w-4xl space-y-8",children:n.jsx(bD,{kinds:s.computers,value:R.computer??(S==null?void 0:S.computer)??D0(R.place??{mode:"runner"}),onChange:ee=>{const Se=xD(ee),Ye=new Set(s.tools.filter(ft=>ft.sandbox_only).map(ft=>ft.name));Ge({computer:ee,place:Se,...Se.mode==="runner"?{tools:(R.tools??[]).filter(ft=>!Ye.has(ft))}:{}}),Te(Se)},error:et("computer")??et("place"),warning:Ce("computer")??Ce("place")})}),Ke==="computer"&&!We&&!rt&&!s.computers&&s.places&&n.jsx("div",{className:"max-w-3xl space-y-8",children:n.jsx(vD,{value:R.place,saved:S==null?void 0:S.place,places:s.places,tools:s.tools,picked:R.tools??[],onChange:ee=>{Ge({...ee,...ee.place?{computer:D0(ee.place)}:{}}),ee.place&&Te(ee.place)},error:et("computer")??et("place"),warning:Ce("computer")??Ce("place")})}),Ke==="tools"&&n.jsxs("div",{className:"max-w-3xl space-y-6",children:[n.jsxs(Gs,{label:"Tools",note:"On by default: the tools this agent's harness runs on this server. Untick one to take it away.",error:et("tools"),warning:Ce("tools"),children:[n.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[s.tools.filter(ee=>{var Se;return We||!ee.call_only||((Se=R.tools)==null?void 0:Se.includes(ee.name))}).map(ee=>{var Tn,Ls;const Se=Xh(R.harness??"pi",ee.name,s.tools,me),Ye=((Tn=R.tools)==null?void 0:Tn.includes(ee.name))??!1,ft=m.find(Ps=>Ps.name===ee.name),jt=(Ls=(R.tool_settings??(S==null?void 0:S.tool_settings)??{})[ee.name])==null?void 0:Ls.provider,Ut=!!ft&&jt!==void 0&&jt!==ft.provider,vn=wz(ee,R.place??Df(S==null?void 0:S.place)??Ix(We,R.tools??[],s.places)),St=wS(ee.name,v,e==null?void 0:e.tools)?Sx:ee.call_only&&!We?"Workflow-only: a workflow's call node runs it, not an agent":Se?vn??(!ee.available&&!Ut?(ft==null?void 0:ft.reason)??ee.reason??`Needs ${(ee.missing??[]).join(", ")}`:void 0):H0(R.harness??"pi",ee.name,s.tools),zr=St?ee.call_only&&!We?"Workflow only":vn&&Se&&St===vn?"Sandbox-only":St:void 0;return n.jsx("li",{className:"min-w-0",children:n.jsx(zx,{value:ee.name,name:ee.name,blurb:ee.blurb,description:ee.summary,why:St,tag:zr,on:Ye,disabled:!!St&&!Ye,onToggle:()=>{V(!0),Ge({tools:Ye?R.tools.filter(Ps=>Ps!==ee.name):[...R.tools??[],ee.name]})}})},ee.name)}),s.mcp&&!We&&n.jsx("li",{className:"sm:col-span-2",children:n.jsx(oD,{servers:k,tools:R.tools??[],harness:R.harness??"pi",harnesses:s.mcpHarnesses,onRetry:A,onChange:ee=>{V(!0),Ge({tools:ee})}})}),!We&&n.jsx("li",{className:"sm:col-span-2",children:n.jsx(mD,{tools:R.tools??[],listed:de,notes:ae.map(({grant:ee,warning:Se})=>({grant:ee,message:Se.message})),refused:xt,onChange:ee=>{ue(Se=>[...new Set([...Se,...ee.filter(ic)])]),V(!0),Ge({tools:ee})}})})]}),!We&&!B0(R.tools??[])&&n.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",gr.length?`tick ${gr.join(" or ")} in Tools.`:`${R.harness??"pi"} runs no web tool on this server.`]})]}),n.jsx(SD,{agent:e,unattended:!We&&Dt==="never",harness:R.harness??"pi",model:R.model,tools:R.tools??[],choices:We?[]:m,gates:v,mcpServers:Array.isArray(k)?k:void 0,serverSettings:N,focus:w,callTools:We?tP(Z0(R.workflowText)??(S==null?void 0:S.workflow)):void 0,value:R.tool_settings??(S==null?void 0:S.tool_settings)??{},issues:(ge==null?void 0:ge.kind)==="invalid"?ge.fields:{},onChange:ee=>!ye&&Hl(ee,(S==null?void 0:S.tool_settings)??{})?D(({tool_settings:Se,...Ye})=>Ye):Ge({tool_settings:ee})}),!We&&!rt&&n.jsxs("fieldset",{"aria-label":"Approvals",className:"space-y-2",children:[n.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(([ee,Se,Ye])=>n.jsxs("label",{className:ie("flex items-start gap-3 border px-3 py-2.5",Dt===ee&&"border-foreground"),children:[n.jsx("input",{type:"radio",name:"approvals",value:ee,className:"mt-1 accent-primary",checked:Dt===ee,disabled:ye,onChange:()=>Ge({approvals:ee})}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono text-body",children:Se}),n.jsx("span",{className:"block text-small text-muted-foreground",children:Ye})]})]},ee)),Dt==="never"&&n.jsx("p",{className:"text-small text-warning-text",children:c2})]}),n.jsx(Gs,{label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:(ps=S==null?void 0:S.skills)!=null&&ps.length?n.jsx("ul",{className:"border",children:S.skills.map(ee=>n.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:ee},ee))}):n.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),Ke==="settings"&&n.jsxs("div",{className:"max-w-3xl space-y-8",children:[!We&&n.jsxs(Gs,{named:!0,label:"Harness",note:"What runtime runs this agent.",error:et("harness"),warning:Ce("harness"),children:[n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,9rem),1fr))] gap-3",role:"radiogroup","aria-label":"Harness",children:sn.map(ee=>{const Se=n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"radio",name:"harness",value:ee.id,checked:R.harness===ee.id,disabled:!ee.available&&R.harness!==ee.id,onChange:()=>tt(ee.id),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block break-words font-mono text-body font-semibold",children:ee.label}),n.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:ee.available?ee.id:"Not available here"})]})]}),Ye=ie("min-w-0 border px-4 py-3",R.harness===ee.id?"border-foreground":"border-border");return ee.available?n.jsx("label",{className:ie(Ye,"flex cursor-pointer items-start gap-3"),children:Se},ee.id):n.jsxs("div",{className:ie(Ye,"opacity-60"),children:[n.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Se}),ee.reason&&n.jsxs("details",{className:"mt-2 font-mono text-label text-muted-foreground",children:[n.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Why, and what to do"}),n.jsx("p",{className:"mt-1 break-words leading-[1.6]",children:ee.reason})]})]},ee.id)})}),Z.length>0&&n.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:[n.jsxs("p",{className:"text-warning-text",children:[((hs=sn.find(ee=>ee.id===R.harness))==null?void 0:hs.label)??R.harness," doesn't run ",Z.length===1?"this tool":"these tools"," here, so ",Z.length===1?"it's":"they're"," unticked. Switching back ticks ",Z.length===1?"it":"them"," again."]}),n.jsx("ul",{className:"mt-1 space-y-0.5",children:Z.map(ee=>n.jsxs("li",{children:[ee,": ",n.jsx("span",{className:"text-muted-foreground",children:H0(R.harness??"pi",ee,s.tools,s.mcpHarnesses)})]},ee))})]})]}),!We&&!rt&&n.jsx(Gs,{named:!0,label:"Thinking",note:"How hard the model thinks before it answers.",error:et("thinking"),warning:Ce("thinking"),children:n.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(ee=>n.jsxs("label",{className:ie("caps cursor-pointer border px-3 py-2 text-small",R.thinking===ee?"border-foreground":"text-muted-foreground"),children:[n.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:R.thinking===ee,onChange:()=>Ge({thinking:ee})}),ee]},ee))})}),!rt&&n.jsxs(Gs,{label:"Model",id:"agent-model",optional:!0,note:bn?n.jsxs(n.Fragment,{children:["Empty uses the server's default (",n.jsx("span",{title:bn.title,children:bn.text}),")."]}):Gz,error:et("model"),warning:Ce("model"),children:[n.jsx(Lt,{id:"agent-model",label:"Model",className:"w-full",value:un?lh:R.model??"",options:ms,onChange:ee=>{if(ee===lh){O(!0);return}O(!1),Ge({model:ee||void 0})}}),un&&n.jsx(Be,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:R.model??"",onChange:ee=>{O(!0),Ge({model:ee.target.value||void 0})},placeholder:"provider/model"})]}),!rt&&n.jsx(Gs,{label:"Default spend cap per run, $",id:"agent-max-cost",optional:!0,note:"A run started without a cap of its own, and a trigger with none, stops at this spend. Empty means none.",hint:n.jsx(l2,{}),error:et("max_cost_usd"),warning:Ce("max_cost_usd"),children:n.jsx(Be,{id:"agent-max-cost",inputMode:"decimal",value:R.maxCostText??"",onChange:ee=>Ge({maxCostText:ee.target.value}),placeholder:"e.g., 2.50"})}),!We&&!rt&&s.learning&&n.jsx(iz,{fields:R,onFields:Ge,saved:S==null?void 0:S.learning,server:s.learning,error:et("learning"),warning:Ce("learning")})]}),Ke==="history"&&pe&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>Y(null),children:[n.jsx(Es,{"aria-hidden":!0})," Back to History"]}),n.jsxs("span",{className:"caps text-small",children:["rev ",pe.version]}),n.jsx("span",{className:"min-w-0 flex-1 text-lead",children:pe.note??n.jsx("span",{className:"text-muted-foreground",children:"No note"})}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(pe.created_at)}),n.jsx(K,{size:"sm",onClick:()=>a==null?void 0:a(pe.revision),disabled:!a,children:"Make current"})]}),n.jsx(J0,{readOnly:!0,text:JSON.stringify((gs=pe.definition)==null?void 0:gs.workflow,null,2),onText:()=>{},base:S.workflow,baseLabel:Fe?`rev ${Fe.version}, the current one`:"the current revision"})]}),Ke==="history"&&!pe&&n.jsx("ul",{className:"max-w-3xl border",children:t.map(ee=>{var Se;return n.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[n.jsxs("span",{className:"caps w-14 text-small",children:["rev ",ee.version]}),n.jsx("span",{className:"min-w-0 flex-[1_1_14rem] break-words text-lead",children:ee.note??n.jsx("span",{className:"text-muted-foreground",children:"No note"})}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(ee.created_at)}),We&&!ee.current&&((Se=ee.definition)==null?void 0:Se.workflow)!==void 0&&n.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>Y(ee),"aria-label":`View rev ${ee.version}`,children:[n.jsx(hg,{"aria-hidden":!0})," View"]}),ee.current?n.jsx(Ne,{tone:"success",children:"Current"}):n.jsx(K,{size:"sm",onClick:()=>a==null?void 0:a(ee.revision),disabled:!a,children:"Make current"})]},ee.revision)})})]})})]}),n.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[n.jsxs(K,{size:"sm",variant:"ghost",disabled:Ft===0,onClick:()=>_e(lt[Ft-1].id),children:[n.jsx(Es,{"aria-hidden":!0})," Previous"]}),Ke!=="history"&&n.jsx(Be,{value:q,onChange:ee=>ce(ee.target.value),placeholder:_?"":"What changed (a note on this revision)","aria-label":"Revision note",className:ie("h-9 min-w-0 flex-1",_&&"invisible")}),Ke==="history"&&n.jsx("span",{className:"flex-1"}),Ft<lt.length-1&&n.jsxs(K,{size:"sm",onClick:()=>_e(lt[Ft+1].id),children:["Next ",n.jsx(fg,{"aria-hidden":!0})]}),!pe&&n.jsx(K,{ref:kt,size:"sm",variant:"solid",onClick:Qn,disabled:!r||ye||!_&&!F||!((Un=R.name)!=null&&Un.trim())||!We&&!rt&&!((Ms=R.instructions)!=null&&Ms.trim()),children:_?ye?"Creating…":"Create":ye?"Saving…":F?"Save revision":Fe?`Saved · rev ${Fe.version}`:"Saved"}),_&&!ye&&!pe&&yn.map(ee=>n.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:ee},ee)),(ge==null?void 0:ge.kind)==="invalid"&&n.jsxs("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:["The server refused the save: ",ge.message]}),(ge==null?void 0:ge.kind)==="other"&&n.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:ge.message})]}),n.jsxs(M4,{open:Jn.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:Jn.leave,onCancel:Jn.stay,children:[_?"This new agent is not saved yet.":"Your changes to this agent are not saved."," Leave drops them; Stay keeps them here."]})]})}const Gs=({named:e,...t})=>n.jsx(Xs,{...t,group:t.id?!1:e?"heading":!0});function MD({agents:e,archived:t=!1,onArchivedChange:s,actions:r={},error:a,handoff:l}){const[c,u]=x.useState(""),d=(e??[]).filter(p=>`${p.definition.name} ${p.definition.description??""}`.toLowerCase().includes(c.toLowerCase()));return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[n.jsxs("label",{className:ie("flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3",O1),children:[n.jsx(wE,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx(Be,{bare:!0,value:c,onChange:p=>u(p.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"flex-1 max-sm:portrait:placeholder:text-transparent"})]}),n.jsxs(K,{size:"lg",variant:t?"primary":"outline","aria-pressed":t,onClick:()=>s==null?void 0:s(!t),children:[n.jsx(cc,{"aria-hidden":!0})," Archived"]}),!t&&l,!t&&n.jsxs(K,{size:"lg",variant:"primary",onClick:r.onNew,children:[n.jsx(yi,{"aria-hidden":!0})," New agent"]})]}),a?n.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:a}):e?d.length?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[d.length," ",d.length===1?"agent":"agents"]}),n.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:d.map(p=>n.jsx(LD,{agent:p,actions:r},p.agent_id))})]}):n.jsxs("div",{className:"border px-4 py-12 text-center",children:[n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:c?"No agent matches.":t?"No archived agents.":"No agents yet."}),!c&&!t&&n.jsxs(K,{className:"mt-4",variant:"primary",onClick:r.onNew,children:[n.jsx(yi,{"aria-hidden":!0})," New agent"]})]}):n.jsx(fs,{label:"Loading the agents",rows:6})]})}function LD({agent:e,actions:t}){const s=e.kind==="workflow"?ka:mg,r=!!e.archived_at,a=Ud(e);return n.jsxs("li",{className:ie("flex flex-col border p-4",r&&"opacity-70"),children:[n.jsxs("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:()=>{var l;return(l=t.onOpen)==null?void 0:l.call(t,e.agent_id)},children:[n.jsx(s,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-prose font-semibold",children:e.definition.name}),n.jsx(Ne,{children:e.kind}),e.kind==="agentic"&&n.jsx(Ne,{children:e.definition.harness??"pi"}),r&&n.jsx(Ne,{tone:"muted",children:"Archived"})]}),n.jsx("span",{className:"mt-1.5 line-clamp-2 block font-mono text-small leading-relaxed text-muted-foreground",children:e.definition.description||(e.kind==="workflow"?w4(e.definition.workflow):"No description.")})]})]}),n.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-4",children:[n.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:[n.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&n.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.runs.count," ",e.runs.count===1?"run":"runs",e.runs.live?` · ${e.runs.live} live`:""]}),a>0&&n.jsxs(K,{size:"xs","aria-label":ax(a),onClick:()=>{var l;return(l=t.onLearning)==null?void 0:l.call(t,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 · ",a]})]}),n.jsxs("div",{"data-testid":"agent-card-actions",className:"ml-auto flex shrink-0 items-center gap-2",children:[n.jsx(K,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`Edit ${e.definition.name}`,onClick:()=>{var l;return(l=t.onEdit)==null?void 0:l.call(t,e.agent_id)},children:n.jsx(dc,{"aria-hidden":!0})}),n.jsx(K,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var l;return(l=t.onRuns)==null?void 0:l.call(t,e.agent_id)},children:n.jsx(xg,{"aria-hidden":!0})}),n.jsx(K,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`${r?"Unarchive":"Archive"} ${e.definition.name}`,onClick:()=>{var l;return(l=t.onArchive)==null?void 0:l.call(t,e.agent_id,!r)},children:r?n.jsx(Rk,{"aria-hidden":!0}):n.jsx(cc,{"aria-hidden":!0})})]})]})]})}const ea=e=>e instanceof Pe?Sz(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function PD({v2:e,archived:t,go:s}){const[r,a]=x.useState(null),[l,c]=x.useState(null),u=x.useRef(0),d=()=>{const p=++u.current;a(null),c(null),go(g=>e.listAgents({archived:t,cursor:g}),g=>g.agents).then(g=>{p===u.current&&a(g)}).catch(g=>{p===u.current&&c(ea(g).message)})};return x.useEffect(d,[e,t]),n.jsx(MD,{agents:r,archived:t,onArchivedChange:p=>s(p?"#/agents?archived=true":"#/agents"),error:l,handoff:n.jsx(rx,{context:{kind:"create"},label:"Build with your coding agent",size:"lg",iconOnPhone:!0,className:"max-sm:w-11"}),actions:{onOpen:p=>s(Qs(p)),onEdit:p=>s(Qs(p,"edit")),onNew:()=>s("#/agents/new"),onRuns:p=>s(Qs(p,"runs")),onLearning:p=>s(Qs(p,"learning")),onArchive:async(p,g)=>{try{await(g?e.archiveAgent(p):e.unarchiveAgent(p)),d()}catch(y){c(ea(y).message)}}}})}function ID({v2:e,caps:t,choices:s=[],gates:r=[],focusTool:a,agentId:l,go:c}){const[u,d]=x.useState(null),[p,g]=x.useState(null),[y,h]=x.useState([]),[m,v]=x.useState(null),[w,k]=x.useState(null),[N,A]=x.useState(0),[_,S]=x.useState(null),E=x.useRef(!0);x.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]);const T=z=>go(H=>e.listRevisions(z,H),H=>H.revisions),C=async()=>{if(l)try{const[{agent:z,etag:H},V]=await Promise.all([e.getAgent(l),T(l)]);d(z),g(H),h(V),S(z.revision),A(P=>P+1),k(null),v(null)}catch(z){u?k(`The agent could not be reloaded: ${ea(z).message}`):v(ea(z).message)}};x.useEffect(()=>{C()},[l]);const[R,D]=x.useState(null),L=x.useRef(0);x.useEffect(()=>{const z=++L.current;e.computers().then(H=>{z===L.current&&D(H.kinds)},()=>{z===L.current&&D(null)})},[e]);const[O,I]=x.useState(void 0);x.useEffect(()=>{let z=!0;return Promise.resolve().then(()=>e.toolSettings()).then(H=>{z&&I(H)},()=>{}),()=>{z=!1}},[e]);const[W,U]=x.useState(null),J=x.useRef(0),F=()=>{if(!t.mcp)return;const z=++J.current;U(null),e.listMcpServers().then(H=>{z===J.current&&U(H.servers)},()=>{z===J.current&&U("failed")})};x.useEffect(F,[e,t.mcp]);const Z=async(z,H)=>{let V;try{V=await H()}catch(P){k(`${z} did not finish: ${ea(P).message}`);return}d(V);try{const{agent:P,etag:B}=await e.getAgent(V.agent_id),q=await T(V.agent_id).catch(()=>y);d(P),g(B),h(q),P.revision!==_?(S(P.revision),A(ce=>ce+1),k(z==="Make current"?null:`${z} done. This agent changed since you opened it: the form now shows its current revision.`)):k(null)}catch(P){k(`${z} done. The page could not be refreshed: ${ea(P).message}. Reload to see the current state.`)}};return l&&m&&!u?n.jsx("p",{className:"m-8 border p-4 font-mono text-body text-destructive-text",role:"alert",children:m}):l&&!u?n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading the agent..."}):n.jsx(OD,{agent:u,revisions:y,caps:{...t,computers:R},providerChoices:s,permissionGates:r,mcpServers:W,serverToolSettings:O,onRetryMcp:F,...a?{focusTool:a,step:"tools"}:{},notice:w,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{C(),F()},onSave:async(z,H)=>{let V;try{if(!u){const ce=await e.createAgent(yz({name:z.name??"",description:z.description??"",instructions:z.instructions??"",harness:z.harness??"pi",tools:z.tools??[],approvals:z.approvals,tool_settings:z.tool_settings,thinking:z.thinking,model:z.model,computer:z.computer,learning:z.learning,max_cost_usd:z.max_cost_usd,decisionProvider:t.decisionProvider}));return E.current&&c(Qs(ce.agent_id,ce.kind==="workflow"?"workflow":void 0)),null}const P=Mx(u,z,H);if(P.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:B,...q}=P;V=await e.updateDefinition(u.agent_id,q,p)}catch(P){return ea(P)}return d(V.agent),g(V.etag),S(V.agent.revision),e.getAgent(V.agent.agent_id).then(P=>d(B=>B&&B.revision===P.agent.revision?{...B,tools:P.agent.tools}:B)).catch(()=>{}),T(V.agent.agent_id).then(h).catch(()=>k("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:z=>{u&&Z("Make current",()=>e.setCurrent(u.agent_id,z))},onArchive:z=>{u&&Z(z?"Archive":"Unarchive",()=>z?e.archiveAgent(u.agent_id):e.unarchiveAgent(u.agent_id))}},`${(u==null?void 0:u.agent_id)??"new"}:${N}`)}function _a({error:e,title:t="The run failed"}){return n.jsxs("section",{className:"flex gap-3 bg-card px-4 py-4 md:px-5",role:"alert",children:[n.jsx(Zs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"caps text-small font-semibold",children:t}),n.jsx("p",{className:"mt-2 break-words font-mono text-body leading-relaxed",children:e.message}),n.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 zD={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},DD={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"},FD=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function UD({id:e,className:t}){const[s,r]=x.useState(!1),a=zD[e],l=DD[e];return a&&!s?n.jsx("img",{"data-provider-icon":e,src:FD(a),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:ie("size-4 shrink-0 object-contain",t)}):l?n.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:ie("size-4 shrink-0",t),"aria-hidden":!0,children:n.jsx("path",{d:l})}):n.jsx(ia,{className:ie("size-4 shrink-0 text-muted-foreground",t),"aria-hidden":!0})}const WD=/^(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,HD=40;function BD(e){const t=e.trim().replace(/\?+$/,""),s=t.lastIndexOf(":"),r=(s>=0?t.slice(s+1):t.split(new RegExp("(?<=[.!?])\\s+")).at(-1)??"").trim();if(s<0&&WD.test(r))return[];const a=r.split(/,?\s+or\s+|,\s+/i).map(c=>c.trim()).filter(Boolean);if(a.length<2||a.length>4||!/\bor\b/i.test(r))return[];const l=a.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return l.some(c=>!c||c.length>HD)?[]:l.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function GD(e){var r,a;const t=new Map;for(const l of e){if(l.imported_from)continue;const c=((a=(r=l.error)==null?void 0:r.message)==null?void 0:a.trim())||"The run failed.";t.set(c,[...t.get(c)??[],l])}const s=l=>Date.parse(l.ended_at??l.created_at);return[...t].map(([l,c])=>({message:l,runs:c.sort((u,d)=>s(d)-s(u))})).sort((l,c)=>s(c.runs[0])-s(l.runs[0]))}const u2=e=>e.filter(t=>!t.imported_from).length,qD=864e5;function VD(e,t){return e.some(s=>!s.imported_from)||t.some(s=>s.source==="live"&&s.runs>0)}function Ac(e,t){const s=Math.max(0,Math.round((t-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 KD(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 t=(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 t=="number"?{max_cost_usd:t}:{}}}}function YD(e,t){let s=!1,r;const a=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(a,t))})};return a(),()=>{s=!0,clearTimeout(r)}}const d2=e=>e.pending!=null,XD=e=>e.status==="input_required"&&e.state!=="waiting"&&!d2(e),QD=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function ek(e,t){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 QD.forEach(([a,l],c)=>{const u=t[c];(u==null?void 0:u.status)==="fulfilled"?s[a]=u.value:u&&r.push(`${l} could not be read: ${u.reason instanceof Error?u.reason.message:String(u.reason)}`)}),{needs:s,problem:r.length?r.join(" · "):null}}const JD={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},ZD={tool:1,model:1,mcp:2,computer:2,source:2};function tf(e,t){const s=e.split(":"),r=ZD[s[0]];return(r===void 0?"":s.slice(r).join(":"))||t||s.slice(1).join(":")}const e6="Sign in with your password to change secrets.",t6="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",n6="Open the console from the server's link to change secrets.",Oc={sign_in:e6,no_accounts:t6,token:n6},f2=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,s6=e=>{var t;return((t=f2(e))==null?void 0:t.secrets_writable)===!0};function r6(e){const t=f2(e);return t!=null&&t.secrets_reason?t.secrets_reason:(t==null?void 0:t.accounts)===!1?"no_accounts":"sign_in"}function o6(e){const[t,s]=x.useState({writable:!1,whyNot:"sign_in"});return x.useEffect(()=>{let r=!0;return e.session().then(a=>{r&&s({writable:s6(a),whyNot:r6(a)})},()=>{}),()=>{r=!1}},[e]),t}function Bf({field:e,label:t,writable:s,required:r=!0,stateSaid:a=!1,now:l=Date.now,note:c,onPaste:u,onRemove:d}){const p=e.source==="env",g=s&&!p;return n.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:ie("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",p&&"opacity-60"),children:[n.jsxs("span",{children:[tf(e.name,t),!r&&n.jsx("span",{className:"ml-2 font-sans text-label text-muted-foreground",children:"Optional"})]}),n.jsx("span",{"data-state":e.set?"set":r?"missing":"optional-missing",className:a?"sr-only":c?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&n.jsx("span",{className:"text-muted-foreground",children:JD[e.source]}),e.changed_at&&n.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Ac(e.changed_at,l())," ago"]}),c&&n.jsx("span",{className:"text-warning-text",children:c}),g&&n.jsxs("span",{className:"ml-auto flex gap-2 font-sans",children:[u&&n.jsx(K,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:u,children:e.set?"Replace":"Paste"}),d&&e.set&&n.jsx(K,{type:"button",size:"sm",variant:"destructive",onClick:d,children:"Remove"})]})]})}const tk={anthropic:{url:"https://console.anthropic.com/settings/keys",placeholder:"sk-ant-…"},openai:{url:"https://platform.openai.com/api-keys",placeholder:"sk-…"},openrouter:{url:"https://openrouter.ai/keys",placeholder:"sk-or-…"}},a6=e=>Object.prototype.hasOwnProperty.call(tk,e)?tk[e]:void 0,i6={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."},nk=e=>e instanceof Pe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function sk(e,t){return t?t.state==="accepted"?`${e} accepted this key · ${ht(t.at)}`:`Not checked: ${t.reason}${t.at?` · ${ht(t.at)}`:""}`:null}const l6="can't be opened: paste it again",c6=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],m2="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function u6({v2:e,onChange:t,writable:s,whyNot:r="sign_in"}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[d,p]=x.useState(null),[g,y]=x.useState(null),h=x.useRef(0),m=()=>{const S=++h.current;e.listToolKeys().then(E=>{S===h.current&&(l(E),u(null))}).catch(E=>{S===h.current&&u(nk(E))})};x.useEffect(m,[e]);const v=S=>p(E=>E===S?null:E),w=S=>{v(S),m(),t==null||t()},k=(S,E,T,C)=>{y({id:S,title:E,error:nk(T)}),T instanceof Pe&&T.code==="key_set_by_server"&&(v(C),m())};if(!a)return c?n.jsx(rk,{error:c,onRetry:m}):n.jsx("div",{className:"p-5 md:p-8",children:n.jsx(fs,{label:"Loading the tool keys",rows:3})});const N=a.reenter,A=c6.map(S=>({...S,keys:a.keys.filter(E=>E.kind==="model"==(S.kind==="model"))})).filter(S=>S.keys.length),_=S=>n.jsx(d6,{tool:S,writable:s,again:!!N&&S.fields.some(E=>E.stored_unreadable||N.fields.includes(E.name)),open:(d==null?void 0:d.id)===S.id?d.mode:null,problem:(g==null?void 0:g.id)===S.id?g:null,onOpen:E=>{p(E?{id:S.id,mode:E}:null),y(null)},onSave:async E=>{const T=d;try{await e.saveToolKey(S.id,E)}catch(C){return C instanceof Pe&&C.status===422?C:(k(S.id,"The key was not saved",C,T),null)}return w(T),null},onRemove:async()=>{const E=d;try{await e.removeToolKey(S.id)}catch(T){k(S.id,"The key was not removed",T,E);return}w(E)}},S.id);return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Keys"}),n.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."})]}),!s&&n.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Oc[r]}),c&&n.jsx(rk,{inline:!0,error:c,onRetry:m}),N&&n.jsxs(_n,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[n.jsx("p",{children:i6[N.reason]}),n.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."})]}),A.map(S=>n.jsxs("section",{"aria-label":S.label,children:[A.length>1&&n.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:S.label}),S.kind==="model"&&n.jsx("p",{className:"mb-2 text-body text-muted-foreground",children:m2}),n.jsx("ul",{className:"border",children:S.keys.map(_)})]},S.label))]})})}function rk({error:e,onRetry:t,inline:s=!1}){return n.jsx(_n,{tone:"error",className:s?void 0:"m-8",actions:n.jsx(K,{type:"button",size:"xs",onClick:t,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The tool keys could not be read: ",e.code,": ",e.message]})})}function d6({tool:e,writable:t,again:s,open:r,problem:a,onOpen:l,onSave:c,onRemove:u}){var h;const d=m=>e.secrets.find(v=>tf(v.name)===m.name),p=m=>e.fields.find(v=>v.name===tf(m.name)),g=e.fields.filter(m=>{var v;return((v=d(m))==null?void 0:v.source)!=="env"}),y=e.secrets.filter(m=>m.set).length;return n.jsxs("li",{className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[n.jsx(UD,{id:e.id,className:"mt-1"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-prose font-semibold",children:e.label}),n.jsx(Ne,{tone:y===e.secrets.length?"success":"plain",children:y===e.secrets.length?"set":y?`${y} of ${e.secrets.length} set`:"not set"}),s&&n.jsx(Ne,{tone:"warning",children:"enter again"})]}),n.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(", ")}`]}),sk(e.label,e.check)&&n.jsx("p",{className:`mt-1.5 text-small ${((h=e.check)==null?void 0:h.state)==="accepted"?"text-success-text":"text-muted-foreground"}`,children:sk(e.label,e.check)}),n.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(m=>{var v;return n.jsx(Bf,{field:m,stateSaid:e.secrets.length===1,writable:t&&r===null,note:(v=p(m))!=null&&v.stored_unreadable?l6:void 0,onPaste:()=>l("edit"),onRemove:m.source==="console"?()=>l("remove"):void 0},m.name)})}),!g.length&&n.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"&&n.jsx(p2,{tool:e,fields:g,onSave:c,onCancel:()=>l(null)}),r==="remove"&&n.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(m=>m.source==="env")?" The one set in the environment stays.":""]}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>void u(),children:"Remove"}),n.jsx(K,{size:"sm",onClick:()=>l(null),children:"Keep"})]}),a&&n.jsx("div",{className:"mt-4 border",children:n.jsx(_a,{error:a.error,title:a.title})})]})}function p2({tool:e,fields:t,onSave:s,onCancel:r}){const a=x.useRef(null),[l,c]=x.useState(!1),[u,d]=x.useState(!1),[p,g]=x.useState(null),y=()=>t.some(w=>{var k,N;return(N=(k=a.current)==null?void 0:k.elements.namedItem(w.name))==null?void 0:N.value}),h=()=>{var w;(w=a.current)==null||w.reset(),c(!1)},m=async w=>{var S,E;w.preventDefault();const k={};for(const T of t){const C=(E=(S=a.current)==null?void 0:S.elements.namedItem(T.name))==null?void 0:E.value;C&&(k[T.name]=C)}if(!Object.keys(k).length)return;d(!0),g(null);const N=await s(k);if(d(!1),!N){h();return}const A={},_=[];for(const T of N.fields??[]){const C=T.field.startsWith("values.")?T.field.slice(7):null;C&&t.some(R=>R.name===C)?A[C]=T.message:_.push(T.message)}g({fields:A,message:_.length?_.join(" "):Object.keys(A).length?null:N.message})},v=a6(e.id);return n.jsxs("form",{ref:a,autoComplete:"off",onSubmit:w=>void m(w),onInput:()=>c(!!y()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[v&&n.jsxs("p",{className:"text-body text-muted-foreground",children:[n.jsx("span",{className:"font-semibold text-foreground",children:e.label})," · No key yet?"," ",n.jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-2",children:"Get a key"})," (opens in a new tab)"]}),t.map(w=>n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:w.name}),w.set&&n.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."}),n.jsx(Be,{type:"password",name:w.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:v&&t.length===1?v.placeholder:void 0}),(p==null?void 0:p.fields[w.name])&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[w.name]})]},w.name)),(p==null?void 0:p.message)&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:p.message}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:!l||u,children:u?"Saving":"Save"}),n.jsx(K,{type:"button",size:"sm",onClick:()=>{h(),r()},children:"Cancel"})]})]})}const Mc=x.createContext(null);function ok({connection:e,children:t}){return n.jsx(Mc.Provider,{value:e,children:t})}const f6={state:"online"},m6=()=>()=>{},ak=()=>f6;function Wx(){const e=x.useContext(Mc);return x.useSyncExternalStore(e?e.subscribe:m6,e?e.link:ak,ak)}function h2(e){const t=x.useContext(Mc),s=x.useRef(e);s.current=e,x.useEffect(()=>t==null?void 0:t.onResume(()=>s.current()),[t])}function g2(e){const[t,s]=x.useState(()=>Date.now());return x.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-t)/1e3))}function p6(){const e=x.useContext(Mc),t=Wx(),s=g2(t.state==="offline"?t.retryAt:null);return!e||t.state==="online"?null:t.state==="resumed"?n.jsxs(_n,{bar:!0,tone:"success",icon:bE,"data-connection":"resumed",children:[n.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):n.jsxs(_n,{bar:!0,tone:"warning",icon:Hk,"data-connection":"offline",actions:n.jsx(K,{type:"button",onClick:e.retryNow,size:"xs",children:"Retry now"}),children:[n.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 h6(){const e=x.useContext(Mc),t=Wx(),s=g2(t.state==="offline"?t.retryAt:null);return n.jsxs("div",{"data-connection":"offline",role:"status",className:"mx-auto mt-[12vh] max-w-md border bg-card p-6",children:[n.jsx(Hk,{className:"size-5 text-warning-text","aria-hidden":!0}),n.jsxs("p",{className:"mt-3 text-base font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]}),n.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."}),n.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[n.jsx(K,{type:"button",onClick:e==null?void 0:e.retryNow,size:"sm",children:"Retry now"}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["Next try in ",s," s"]})]})]})}const g6=[{id:"keys",label:"Tool keys"},{id:"tools",label:"Tools"},{id:"mcp",label:"MCP servers"},{id:"github",label:"GitHub"},{id:"computers",label:"Computers"},{id:"workspace",label:"Workspace"},{id:"webhook",label:"Webhook"}];function x6({active:e,offered:t,children:s}){return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.length>1&&n.jsx("nav",{"aria-label":"Settings",className:"flex shrink-0 gap-1 border-b px-6",children:g6.filter(r=>t.includes(r.id)).map(r=>n.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:ie("caps -mb-px border-b-2 px-3 py-3 text-small",e===r.id?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground"),children:r.label},r.id))}),n.jsx("div",{className:"min-h-0 flex-1",children:s})]})}const y6=(e,t)=>e.flatMap(s=>s.tools.flatMap(r=>{var a;return(a=r.permissions)!=null&&a.length&&r.default_permission?[{name:UN(s.name,r.name),permission:r.permission??r.default_permission,default_permission:r.default_permission,permissions:r.permissions,...t&&r.permissions.includes("ask")?{ask_needs:"password"}:{}}]:[]})),ik=e=>e instanceof Pe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function b6({v2:e,choices:t,gates:s=[],harnesses:r,mcp:a=!1,onSaved:l,onOpen:c}){const[u,d]=x.useState(null),[p,g]=x.useState(null),y=()=>{a&&(g(null),e.listMcpServers().then(H=>g(H.servers),()=>g("failed")))};x.useEffect(y,[e,a]);const[h,m]=x.useState(null),[v,w]=x.useState(null),[k,N]=x.useState(!1),[A,_]=x.useState(null),S=x.useRef(0),E=()=>{const H=++S.current;e.toolSettings().then(V=>{H===S.current&&(d(V),m(null))},V=>{H===S.current&&m(ik(V))})};x.useEffect(E,[e]);const[T,C]=x.useState("reading"),R=()=>{C("reading"),Promise.resolve(c==null?void 0:c()).then(H=>C(H===!1?"failed":"landed"))},D=()=>{E(),R()};if(x.useEffect(R,[]),!u)return h?n.jsx(_n,{tone:"error",className:"m-8",actions:n.jsx(K,{type:"button",size:"xs",onClick:E,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",h.code,": ",h.message]})}):n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const L=qh(u,t),O=A?A(L):L,I=i2(t,[...s,...Array.isArray(p)?y6(p,s.some(H=>H.ask_needs==="password")):[]]),W=H=>{var P;const V=ya(H);return V?(P=O[`mcp:${V.server}/*`])==null?void 0:P.permission:void 0},U=Object.entries(O).filter(([,H])=>(H==null?void 0:H.pin)||(H==null?void 0:H.pin_broken)),J=H=>{var P;const V=s.find(B=>B.name===H);return!V||(((P=O[H])==null?void 0:P.permission)??V.default_permission)===V.permission},{byTool:F,rest:Z}=SS((v==null?void 0:v.fields)??{},"",I.map(H=>H.name)),z=async H=>{var q;const V=A?ce=>H(A(ce)):H;N(!0),w(null);const P=++S.current;let B;try{B=await e.toolSettings()}catch{_(()=>V),w({fields:{},error:null,unread:!0}),N(!1);return}try{const ce=await e.saveToolSettings(V(qh(B,t)));_(null),P===S.current&&(d(ce),m(null)),l()}catch(ce){w(ce instanceof Pe&&ce.status===422&&((q=ce.fields)!=null&&q.length)?{fields:Object.fromEntries(ce.fields.map(de=>[de.field,de.message])),error:null}:{fields:{},error:ik(ce)})}N(!1)};return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),n.jsx("p",{className:"mt-2 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&&n.jsxs("p",{className:"mt-2 text-lead text-muted-foreground",children:["Each tool's permission: ",n.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",n.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",n.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."]})]}),n.jsxs("section",{"aria-label":"This server's providers",children:[I.length?n.jsx(Ux,{label:"This server's tool settings",rows:I,settings:O,fallbackOf:H=>H.default_provider,issues:F,busy:k,onEdit:H=>void z(H),permissionFallbackOf:H=>W(H.name)??H.default_permission,refused:(H,V)=>V==="deny",resolvesOf:(H,V)=>V===H.provider&&J(H.name)?n.jsx(ND,{choice:H,harnesses:r}):T==="reading"?n.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"reading…"}):n.jsxs("span",{className:"block text-small text-muted-foreground",children:[T==="failed"?"What it resolves to couldn't be read.":"It changed while this page read it."," ",n.jsx(K,{type:"button",onClick:D,disabled:k,size:"xs",className:"ml-1",children:"Retry"})]})}):n.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."}),p==="failed"&&n.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. ",n.jsx(K,{type:"button",size:"xs",className:"ml-1",onClick:y,disabled:k,children:"Retry"})]}),Z.map(H=>n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:H},H)),(v==null?void 0:v.error)&&n.jsx("div",{className:"mt-3 border",children:n.jsx(_a,{error:v.error,title:"The change was not saved"})}),(v==null?void 0:v.unread)&&n.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[n.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),n.jsx(K,{type:"button",size:"xs",className:"mt-2",onClick:()=>void z(H=>H),disabled:k,children:"Try again"})]}),h&&n.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[n.jsxs("p",{className:"font-mono text-small text-destructive-text",children:["The tool settings could not be read again: ",h.code,": ",h.message]}),n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),n.jsx(K,{type:"button",onClick:D,disabled:k,size:"xs",className:"mt-2",children:"Try again"})]})]}),U.length>0&&n.jsxs("section",{"aria-label":"Pinned tools",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:"Pinned tools"}),n.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."}),n.jsx("ul",{className:"mt-2 border",children:U.map(([H,V])=>n.jsxs("li",{"data-pin":H,className:"border-b px-3 py-2.5 last:border-b-0",children:[n.jsx("p",{className:"font-mono text-body",children:H}),n.jsx(eg,{setting:V})]},H))})]})]})})}function v6(e){const t=new URLSearchParams(e??""),s=t.get("github");if(s==="connected")return{ok:!0};if(s==="error"){const r=t.get("reason");return r?{ok:!1,reason:r}:{ok:!1}}}const lk={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."},w6=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(lk,e.reason)?lk[e.reason]:"The connection didn't finish. Try again.";function k6(e,t){const s=t(e);if(!s)return;const r=new URL(s);return r.protocol==="https:"&&r.hostname==="github.com"?s:void 0}function aa(e){if(!(typeof e!="string"||!e))try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function j6({note:e}){const t=e.lastIndexOf(": "),s=t>=0?e.slice(t+2).trim():"",r=s?aa(s):void 0;return r?n.jsxs(n.Fragment,{children:[e.slice(0,t+2),n.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"break-all underline underline-offset-2",children:s})]}):n.jsx(n.Fragment,{children:e})}function N6({v2:e,returned:t}){const[s,r]=x.useState(void 0),[a,l]=x.useState(null),[c,u]=x.useState(""),[d,p]=x.useState(!1),[g,y]=x.useState(null),[h,m]=x.useState(null),[v,w]=x.useState(null),[k,N]=x.useState(!1),[A,_]=x.useState(null),S=x.useRef(!1),E=x.useRef(null),T=x.useCallback(async()=>{try{const L=await e.githubConnection();r(L.connected?L:null),l(null)}catch(L){l(L instanceof Error?L.message:String(L))}},[e]);x.useEffect(()=>{T()},[T]),x.useEffect(()=>{t&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),x.useEffect(()=>{var L;g&&((L=E.current)==null||L.submit())},[g]);const C=async()=>{var L;if(!S.current){S.current=!0,p(!0),m(null),w(null),_(null);try{const O=await e.connectGitHub(c.trim()||void 0),I=k6(O.action,aa);if(!I){m("GitHub's address didn't look right, so nothing was sent."),S.current=!1,p(!1);return}y({action:I,manifest:JSON.stringify(O.manifest)})}catch(O){if(S.current=!1,p(!1),m(O instanceof Error?O.message:String(O)),O instanceof Pe&&O.code==="github_wrong_origin"){const I=(L=O.details)==null?void 0:L.public_url;w(typeof I=="string"&&aa(I)||null)}O instanceof Pe&&O.code==="github_already_connected"&&T()}}},R=async()=>{N(!1),p(!0),m(null),w(null);try{_(await e.disconnectGitHub()),r(null)}catch(L){L instanceof Pe&&(L.status===404||L.code==="github_not_connected")?await T():m(L instanceof Error?L.message:String(L))}finally{p(!1)}},D=s?aa(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"GitHub"}),n.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&&n.jsx("p",{"aria-label":"From GitHub",role:"status",className:ie("border p-4 text-lead",t.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:w6(t)}),(h||v)&&n.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:v?n.jsxs("p",{children:["Open this server at ",n.jsx("a",{href:v,className:"break-all underline underline-offset-2",children:v})," to connect GitHub."]}):n.jsx("p",{children:h})}),A&&n.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[n.jsx("p",{children:n.jsx(j6,{note:A.note})}),n.jsx("p",{className:"mt-1 text-muted-foreground",children:A.triggers_off?`${A.triggers_off} GitHub ${A.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),a&&n.jsx(_n,{tone:"error",actions:n.jsx(K,{type:"button",size:"xs",onClick:()=>void T(),children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["GitHub's connection could not be read: ",a]})}),s===void 0&&!a&&n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),s===null&&n.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[n.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[n.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),n.jsx(Be,{name:"org",value:c,onChange:L=>u(L.target.value),disabled:d,placeholder:"your-org",className:"h-9 w-auto"})]}),n.jsxs(K,{type:"button",variant:"solid",onClick:()=>void C(),disabled:d,children:[n.jsx(jv,{"aria-hidden":!0}),g?"Opening GitHub…":"Connect GitHub"]})]}),n.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&&n.jsxs("section",{"aria-label":"GitHub App",className:"border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-lead",children:[n.jsx(jv,{className:"size-4 text-muted-foreground","aria-hidden":!0}),D?n.jsx("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):n.jsx("span",{className:"font-mono",children:s.slug}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?n.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(L=>n.jsx("li",{children:L.account},L.id))}):n.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),k?n.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[n.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),n.jsx(K,{type:"button",variant:"destructive",disabled:d,onClick:()=>void R(),children:"Disconnect GitHub"}),n.jsx(K,{type:"button",variant:"ghost",onClick:()=>N(!1),children:"Cancel"})]}):n.jsx(K,{type:"button",variant:"outline",className:"mt-4",disabled:d,onClick:()=>N(!0),children:"Disconnect"})]}),g&&n.jsx("form",{"data-github-manifest":!0,ref:E,method:"post",action:g.action,hidden:!0,children:n.jsx("input",{type:"hidden",name:"manifest",defaultValue:g.manifest})})]})})}const S6=8,_6={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function $6({v2:e,signIn:t,add:s,writable:r,whyNot:a="sign_in",open:l=u=>location.assign(u),choices:c=[]}){var z,H,V,P;const[u,d]=x.useState(null),[p,g]=x.useState(null),[y,h]=x.useState(!1),[m,v]=x.useState(null),[w,k]=x.useState(null),N=(s==null?void 0:s.preset)==="composio"?s:void 0,[A,_]=x.useState(s&&!N?{add:s}:null),[S,E]=x.useState(N&&r?N:!1),[T,C]=x.useState(null),R=s?JSON.stringify(s):"",D=x.useRef(R);x.useEffect(()=>{if(R===D.current)return;D.current=R;const B=R?JSON.parse(R):void 0;_(B&&B.preset!=="composio"?{add:B}:null),E((B==null?void 0:B.preset)==="composio"&&r?B:!1)},[R]);const L=x.useRef(0),O=()=>{const B=++L.current;e.listMcpServers().then(q=>{B===L.current&&(d(q.servers),k(null))},q=>{B===L.current&&k(ba(q))})};x.useEffect(O,[e]),x.useEffect(()=>{e.toolSettings().then(g,()=>g(null))},[e]);const I=x.useRef(!1),W=async(B,q)=>{if(!I.current){I.current=!0,h(!0),v(null);try{const ce=await e.toolSettings();g(await e.saveToolSettings(q(qh(ce,c)))),O()}catch(ce){v({server:B,problem:ba(ce)})}I.current=!1,h(!1)}},U=x.useRef(null);s&&u&&((z=U.current)==null?void 0:z.key)!==R&&(U.current={key:R,name:M6(s.name,u)});const J=B=>{var q;return((q=U.current)==null?void 0:q.key)===JSON.stringify(B)&&U.current.name!==B.name?{...B,toolkit:B.toolkit??B.name,name:U.current.name}:B},F=u!==null||w!==null;x.useEffect(()=>{t&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[t]);const Z=async(B,q)=>l((await e.startMcpSignIn(B,q)).authorization_url);return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"MCP servers"}),n.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."})]}),!A&&!S&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx(K,{size:"sm",variant:"primary",onClick:()=>_({}),children:"Add server"}),n.jsx(K,{size:"sm",disabled:!r,onClick:()=>E(!0),children:"Add from Composio"})]})]}),t&&n.jsx("p",{className:`border p-4 text-body ${t.ok?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:t.ok?`Signed in to ${t.server}. Its tools are saved.`:`Signing in to ${t.server} failed: ${DM(t.error)}.`}),!r&&n.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Oc[a]}),T&&n.jsx("p",{className:"border border-warning/50 p-4 text-body text-warning-text",role:"status",children:T}),w&&n.jsx(_n,{tone:"error",actions:n.jsx(K,{type:"button",size:"xs",onClick:O,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",w.text]})}),A&&(!A.add||F)&&n.jsx(z6,{v2:e,saved:A.saved,add:A.add&&J(A.add),given:A.problem,writable:r,signIn:Z,onCancel:()=>_(null),onSaved:(B=>()=>{_(q=>q===B?null:q),O()})(A)},`${((H=A.saved)==null?void 0:H.name)??"new"}|${((V=A.add)==null?void 0:V.name)??""}|${((P=A.add)==null?void 0:P.auth)??""}`),S&&(typeof S!="object"||F)&&n.jsx(L6,{v2:e,add:typeof S=="object"?J(S):void 0,onClose:()=>E(!1),onSaved:O},typeof S=="object"?R:"new"),u&&(u.length?n.jsx("ul",{className:"border",children:u.map(B=>n.jsx(C6,{v2:e,server:B,settings:p,settingsBusy:y,settingsProblem:(m==null?void 0:m.server)===B.name?m.problem:null,onSettings:q=>void W(B.name,q),writable:r&&!A,signIn:Z,onChange:q=>_({saved:B,...q?{problem:q}:{}}),onChanged:O,onDeleted:q=>{C(q??null),O()}},B.name))}):n.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."})),n.jsx(A6,{v2:e})]})})}const lc=({problem:e})=>n.jsxs("div",{role:"alert",children:[n.jsx("p",{className:"font-mono text-body text-destructive-text",children:e.text}),e.detail&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.detail})]}),Pl=(e,t)=>`mcp:${e}/${t}`,E6=["allow","ask","deny"];function C6({v2:e,server:t,settings:s,settingsBusy:r,settingsProblem:a,onSettings:l,writable:c,signIn:u,onChange:d,onChanged:p,onDeleted:g}){var R,D;const[y,h]=x.useState(!1),[m,v]=x.useState(!1),[w,k]=x.useState(null),[N,A]=x.useState(null),_=async L=>{h(!0),A(null);try{await L()}catch(O){A(ba(O))}h(!1)},[S,E]=t.credential?_6[t.credential]??[t.credential,"plain"]:["no credential","plain"],T=t.auth.type==="oauth",C=w&&[["Added",w.added],["Removed",w.removed],["Changed",w.changed]].filter(([,L])=>L.length).map(([L,O])=>`${L} ${O.join(", ")}`);return n.jsxs("li",{"data-server":t.name,className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[n.jsx(yE,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-prose font-semibold",children:t.name}),n.jsx(Ne,{tone:E,children:S}),!!((R=t.not_metered)!=null&&R.length)&&n.jsx(Ne,{tone:"plain",children:"not metered"}),t.source&&n.jsxs(n.Fragment,{children:[n.jsx(Ne,{tone:"muted",children:Sc[t.source]}),n.jsx("span",{"data-toolkit":!0,className:"font-mono text-small text-muted-foreground",children:t.toolkit?`toolkit ${t.toolkit}`:"no toolkit"})]})]}),n.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:t.url}),t.auth.type==="github_app"&&n.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",(D=t.auth.headers)!=null&&D.length?` · headers ${t.auth.headers.join(", ")}`:""]}),T&&t.oauth&&n.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed in with OAuth",t.oauth.scopes.length?` · ${t.oauth.scopes.join(" ")}`:"",t.oauth.client==="pre-registered"&&t.oauth.client_id?` · client ${t.oauth.client_id}`:"",t.credential==="expired"?" · sign-in expired: sign in again":t.oauth.expires_at?` · token until ${ht(t.oauth.expires_at)}`:""]}),s&&n.jsx(T6,{server:t,settings:s,busy:r,onSettings:l}),a&&n.jsx("div",{className:"mt-2",children:n.jsx(lc,{problem:a})}),n.jsxs("details",{className:"mt-2",children:[n.jsxs("summary",{className:"cursor-pointer font-mono text-small",children:[t.tools.length," tool",t.tools.length===1?"":"s"]}),n.jsx("div",{className:"mt-2",children:n.jsx(R6,{server:t,settings:s,busy:r,onSettings:l})})]}),t.secret&&n.jsx("ul",{className:"mt-2",children:n.jsx(Bf,{field:t.secret,label:I6[t.auth.type],writable:c,onPaste:T?void 0:()=>d()})}),C&&n.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:C.length?C.join(" · "):"No change: it lists the same tools."})]}),!m&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[T&&t.credential!=="sealed"&&c&&n.jsx(K,{size:"sm",variant:"primary",disabled:y,onClick:()=>void _(()=>{var L;return u(t.name,{url:t.url,...(L=t.oauth)!=null&&L.scopes.length?{scopes:t.oauth.scopes}:{}})}),children:"Sign in again"}),n.jsx(K,{size:"sm",disabled:y,onClick:()=>void _(async()=>{try{k(await e.refreshMcpServer(t.name))}finally{p()}}),children:"Refresh"}),n.jsx(K,{size:"sm",disabled:y,onClick:()=>d(),children:"Change"}),n.jsx(K,{size:"sm",variant:"destructive",disabled:y,onClick:()=>v(!0),children:"Delete"})]})]}),m&&n.jsxs("div",{role:"alertdialog","aria-label":`Delete ${t.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",t.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),n.jsx(K,{size:"sm",variant:"destructive",disabled:y,onClick:()=>void _(async()=>{var L,O;g((O=(L=await e.deleteMcpServer(t.name))==null?void 0:L.composio)==null?void 0:O.note)}),children:"Delete"}),n.jsx(K,{size:"sm",onClick:()=>v(!1),children:"Keep"})]}),N&&n.jsxs("div",{className:"mt-3",children:[n.jsx(lc,{problem:N}),N.needsClient&&c&&n.jsx(K,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>d(N),children:"Enter a Client ID"})]})]})}function T6({server:e,settings:t,busy:s,onSettings:r}){var g;const a=Pl(e.name,"*"),l=((g=t[a])==null?void 0:g.allow_reads)===!0,c=e.tools.filter(y=>y.effect==="read").length,u=`allow-reads-${e.name}`,d=`${u}-words`,p=y=>r(h=>{const{[a]:m,...v}=h,{allow_reads:w,...k}=m??{},N=y?{...k,allow_reads:!0}:k;return Object.keys(N).length?{...v,[a]:N}:v});return n.jsxs("div",{className:"mt-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xN,{checked:l,onChange:p,busy:s,labelledBy:u}),n.jsx("span",{id:u,className:"caps text-small font-semibold",children:"Allow reads"})]}),n.jsxs("p",{id:d,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: ",l?"they run without asking":"on, they run without asking",". Writes keep their permission."]})]})}function R6({server:e,settings:t,busy:s,onSettings:r}){const a=t==null?void 0:t[Pl(e.name,"*")],l=new Map(e.tools.map(d=>[Pl(e.name,d.name),d])),c=e.tools.map(d=>{var p;return{name:Pl(e.name,d.name),...t?{gate:{name:Pl(e.name,d.name),permission:d.permission??"ask",default_permission:d.default_permission??"ask",permissions:(p=d.permissions)!=null&&p.length?d.permissions:E6}}:{}}}),u=d=>{var g,y;const p=(g=e.prices)==null?void 0:g[d];return p!==void 0?`$${p} a call`:(y=e.not_metered)!=null&&y.includes(d)?"not metered":null};return n.jsx(Ux,{label:`${e.name}'s tools`,rows:c,settings:t??{},busy:s,issues:{},fallbackOf:()=>"",resolvesOf:()=>null,onEdit:r,labelOf:d=>{var p;return((p=l.get(d))==null?void 0:p.name)??d},detailOf:d=>{var p;return u(((p=l.get(d))==null?void 0:p.name)??"")},effectOf:d=>{var p;return(p=l.get(d))==null?void 0:p.effect},confirmAllowOf:d=>{var p;return((p=l.get(d))==null?void 0:p.effect)==="destructive"},refused:(d,p)=>p==="deny",fallbackWordOf:d=>{var p;return(p=l.get(d))!=null&&p.fallback_allow_reads?"allow reads":void 0},permissionFallbackOf:d=>{var p;return(p=l.get(d.name))!=null&&p.fallback_allow_reads?"allow":(a==null?void 0:a.permission)??d.default_permission}})}function A6({v2:e}){const[t,s]=x.useState(null),[r,a]=x.useState(null),[l,c]=x.useState(null),[u,d]=x.useState(!1),[p,g]=x.useState(""),y=()=>void e.mcpPrivateHosts().then(v=>{s(v.hosts),a(null)},v=>a(ba(v)));x.useEffect(y,[e]);const h=async v=>{d(!0),c(null);try{return s((await e.saveMcpPrivateHosts(v)).hosts),!0}catch(w){return c(ba(w)),!1}finally{d(!1)}},m=async v=>{v.preventDefault(),t&&p.trim()&&await h([...t,p.trim()])&&g("")};return n.jsxs("section",{"aria-labelledby":"mcp-private-hosts",className:"space-y-3 border bg-card p-4",children:[n.jsx("h2",{id:"mcp-private-hosts",className:"caps text-small font-semibold",children:"Private network hosts"}),n.jsx("p",{className:"text-body text-muted-foreground",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."}),r&&n.jsxs("div",{role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",r.text]}),n.jsx(K,{size:"sm",onClick:y,className:"mt-3",children:"Try again"})]}),t&&(t.length?n.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border bg-background",children:t.map(v=>n.jsxs("li",{"data-host":v,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[n.jsx("span",{className:"break-all font-mono text-body",children:v}),n.jsx(K,{size:"sm",disabled:u,onClick:()=>void h(t.filter(w=>w!==v)),children:"Remove"})]},v))}):n.jsx("p",{className:"border bg-background px-3 py-3 font-mono text-body text-muted-foreground",children:"No host is allowed: a sign-in on a private network is refused."})),t&&n.jsxs("form",{onSubmit:v=>void m(v),"aria-label":"Allow a private network host",className:"flex gap-2",children:[n.jsx(Be,{name:"mcp-private-host","aria-label":"Host name or IP address",value:p,onChange:v=>g(v.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:u||!p.trim(),children:"Allow"})]}),l&&n.jsx(lc,{problem:l})]})}const O6=32;function M6(e,t){const s=new Set(t.map(r=>r.name));if(!s.has(e))return e;for(let r=2;;r++){const a=`-${r}`,l=`${e.slice(0,O6-a.length).replace(/-+$/,"")}${a}`;if(!s.has(l))return l}}function L6({v2:e,add:t,onClose:s,onSaved:r}){var L;const a=x.useRef(null),[l,c]=x.useState((t==null?void 0:t.toolkit)??""),[u,d]=x.useState((t==null?void 0:t.name)??""),[p,g]=x.useState(null),[y,h]=x.useState([]),[m,v]=x.useState(null),[w,k]=x.useState(null),[N,A]=x.useState(!1),_=()=>{var O,I;return(((I=(O=a.current)==null?void 0:O.elements.namedItem("composio-key"))==null?void 0:I.value)??"").trim()},S=async O=>{A(!0),k(null);try{await O()}catch(I){k(ba(I))}A(!1)},E=x.useRef(0),T=()=>{E.current++,g(null)},C=()=>S(async()=>{const O=++E.current;g(null),h([]);const I=await e.composioTools(_(),l.trim().toLowerCase());O===E.current&&(g(I),t!=null&&t.tools&&I.toolkit===t.toolkit&&h(I.tools.map(W=>W.slug).filter(W=>t.tools.includes(W))))}),R=()=>S(async()=>{var I,W;const O=await e.saveComposioServer(u.trim(),_(),p.toolkit,y);(I=a.current)==null||I.reset(),r(),O.connect_url||(W=O.not_served)!=null&&W.length?v({connect:O.connect_url,notServed:O.not_served}):s()}),D=O=>h(I=>I.includes(O)?I.filter(W=>W!==O):[...I,O]);return m?n.jsxs("section",{"aria-label":"Composio server saved",className:"space-y-3 border bg-card p-4",children:[n.jsxs("p",{className:"text-body",children:["Saved.",m.connect?` Its tools need your ${p==null?void 0:p.toolkit} account: connect it on Composio, then refresh the server.`:""]}),m.connect&&n.jsx("p",{children:n.jsxs("a",{href:m.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",p==null?void 0:p.toolkit," account"]})}),(L=m.notServed)!=null&&L.length?n.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",m.notServed.join(", "),": a run can't call ",m.notServed.length===1?"it":"them","."]}):null,n.jsx(K,{size:"sm",onClick:s,children:"Done"})]}):n.jsxs("form",{ref:a,autoComplete:"off",onSubmit:O=>{O.preventDefault(),p&&y.length&&u.trim()&&R()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:O=>{O.target.name==="composio-key"&&T()},children:[n.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."}),(t==null?void 0:t.tools)&&n.jsxs("p",{role:"note",className:"text-small text-muted-foreground",children:["A template uses ",t.tools.join(", "),": enter your key and load the actions, and those are ticked."]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),n.jsx(Be,{name:"composio-key",...kd})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),n.jsx(Be,{name:"composio-toolkit",value:l,onChange:O=>{c(O.target.value),T()},placeholder:"github",spellCheck:!1})]}),w&&n.jsx(lc,{problem:w}),p&&n.jsxs("fieldset",{className:"space-y-2",children:[n.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),p.tools.length?n.jsx("ul",{className:"divide-y border",children:p.tools.map(O=>n.jsx("li",{className:"px-3 py-2",children:n.jsxs("label",{className:"flex items-start gap-2 text-body",children:[n.jsx("input",{type:"checkbox",value:O.slug,checked:y.includes(O.slug),onChange:()=>D(O.slug),className:"mt-1 accent-primary"}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono",children:O.name}),n.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:O.slug}),O.description&&n.jsx("span",{className:"block text-small text-muted-foreground",children:O.description})]})]})},O.slug))}):n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This toolkit lists no actions."}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),n.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:",u.trim()||"<name>","/<tool>."]}),n.jsx(Be,{name:"composio-name",value:u,onChange:O=>d(O.target.value),spellCheck:!1})]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(K,{type:"button",size:"sm",disabled:N||!l.trim(),onClick:()=>void C(),children:"Load actions"}),p&&n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:N||!y.length||!u.trim(),children:N?"Working":"Save"}),n.jsx(K,{type:"button",size:"sm",disabled:N,onClick:()=>{var O;(O=a.current)==null||O.reset(),s()},children:"Cancel"})]})]})}const kd={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},P6=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],I6={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function z6({v2:e,saved:t,add:s,given:r,writable:a,signIn:l,onCancel:c,onSaved:u}){var Q,fe,ye,Ee,ge;const d=x.useRef(null),[p,g]=x.useState((t==null?void 0:t.name)??(s==null?void 0:s.name)??""),[y,h]=x.useState((t==null?void 0:t.url)??((s==null?void 0:s.auth)==="github_app"?Jw:"")),[m,v]=x.useState((t==null?void 0:t.auth.type)??(s==null?void 0:s.auth)??"none"),[w,k]=x.useState(Math.max(1,((Q=t==null?void 0:t.auth.headers)==null?void 0:Q.length)??0)),N=m==="github_app"?"github":(t==null?void 0:t.source)==="composio"?"composio":"url",[A,_]=x.useState((t==null?void 0:t.toolkit)??(s&&!s.auth?s.toolkit??s.name:"")),S=N==="github"?"github":A.trim(),E=()=>{if(m==="github_app")return{};const se=S||null;return t?se!==t.toolkit?{toolkit:se}:{}:se?{toolkit:se}:{}},[T,C]=x.useState(null),[R,D]=x.useState(r??null),[L,O]=x.useState(!1),I=x.useRef(0),W=()=>{I.current++,C(null)},U=se=>{var pe,Y;return(((Y=(pe=d.current)==null?void 0:pe.elements.namedItem(se))==null?void 0:Y.value)??"").trim()},[J,F]=x.useState(!1),Z=se=>{try{return new URL(se).origin}catch{return se}},z=(se=m)=>{var pe;return F(!!t&&se==="oauth"&&(t.auth.type!=="oauth"||U("mcp-scopes")!==(((pe=t.oauth)==null?void 0:pe.scopes.join(" "))??"")||!!U("mcp-client-id")||!!U("mcp-client-secret")||Z(U("mcp-url"))!==Z(t.url)))};x.useEffect(()=>z(),[m]);const H=()=>{if(m==="bearer")return U("mcp-token")?{type:m,token:U("mcp-token")}:{type:m};if(m!=="headers"&&m!=="github_app")return{type:m};const se=Object.fromEntries(Array.from({length:w},(pe,Y)=>[U(`mcp-header-name-${Y}`),U(`mcp-header-value-${Y}`)]).filter(([pe,Y])=>pe&&Y));return Object.keys(se).length?{type:m,headers:se}:{type:m}},V=async se=>{O(!0),D(null);try{await se()}catch(pe){D(ba(pe))}O(!1)},P=!!(R!=null&&R.needsClient);x.useEffect(()=>{P&&v("oauth")},[P]),x.useEffect(()=>{var se,pe;P&&m==="oauth"&&((pe=(se=d.current)==null?void 0:se.elements.namedItem("mcp-client-id"))==null||pe.focus())},[P,m]);const B=()=>V(()=>{const se=U("mcp-scopes").split(/\s+/).filter(Boolean),pe=U("mcp-client-id");return l(p.trim(),{url:y.trim(),...se.length?{scopes:se}:{},...pe?{client_id:pe,...U("mcp-client-secret")?{client_secret:U("mcp-client-secret")}:{}}:{},...E()})}),q=()=>{const se=I.current;V(async()=>{try{const pe=await e.previewMcpServer(y.trim(),H(),t==null?void 0:t.name);se===I.current&&C(pe)}catch(pe){if(se===I.current)throw pe}})},ce=se=>{if(se.preventDefault(),m==="oauth"&&(!t||J))return void B();V(async()=>{var pe;await e.saveMcpServer(p.trim(),y.trim(),H(),E()),(pe=d.current)==null||pe.reset(),u()})},de=!L&&!!p.trim()&&!!y.trim()&&(!!t||!!T),ue=se=>(t==null?void 0:t.credential)==="sealed"&&t.auth.type===m&&n.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",se]});return n.jsxs("form",{ref:d,autoComplete:"off",onSubmit:ce,"aria-label":t?`Change ${t.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:se=>{["mcp-name","mcp-toolkit"].includes(se.target.name)||W(),z()},children:[n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),n.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:",p.trim()||"<name>","/<tool>."]}),n.jsx(Be,{name:"mcp-name",value:p,readOnly:!!t,onChange:se=>g(se.target.value),spellCheck:!1})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),n.jsx(Be,{name:"mcp-url",value:y,onChange:se=>{h(se.target.value),R!=null&&R.needsClient&&D(null)},placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),n.jsxs("div",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Source"}),n.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."}),n.jsx("span",{"data-mcp-source":N,className:"font-mono text-body",children:Sc[N]})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),n.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["The name a template gives these tools (mcp:",S||"<toolkit>","/<tool>): applying one uses this server for them."]}),n.jsx(Be,{name:"mcp-toolkit",value:N==="github"?"github":A,readOnly:N==="github",onChange:se=>_(se.target.value),placeholder:"hubspot",spellCheck:!1})]}),n.jsxs("fieldset",{children:[n.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Credential"}),n.jsx("div",{className:"flex flex-wrap gap-4",children:P6.map(([se,pe])=>n.jsxs("label",{className:"flex items-center gap-2 text-body",children:[n.jsx("input",{type:"radio",name:"mcp-auth",value:se,checked:m===se,disabled:!a&&se!=="none",onChange:()=>{v(se),se==="github_app"&&!y.trim()&&h(Jw),W()},className:"accent-primary"}),pe]},se))})]}),m==="bearer"&&n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),ue("A new token replaces it; leave this empty to keep it."),n.jsx(Be,{name:"mcp-token",...kd})]}),m==="github_app"&&n.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."}),(m==="headers"||m==="github_app")&&n.jsxs("div",{className:"space-y-2",children:[ue(`Its headers: ${(fe=t==null?void 0:t.auth.headers)==null?void 0:fe.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:w},(se,pe)=>{var Y;return n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Be,{name:`mcp-header-name-${pe}`,"aria-label":`Header ${pe+1} name`,placeholder:"X-Api-Key",defaultValue:(Y=t==null?void 0:t.auth.headers)==null?void 0:Y[pe],spellCheck:!1}),n.jsx(Be,{name:`mcp-header-value-${pe}`,"aria-label":`Header ${pe+1} value`,...kd})]},pe)}),w<S6&&n.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>k(se=>se+1),children:"Add header"})]}),m==="oauth"&&n.jsxs("div",{className:"space-y-3",children:[n.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."}),((ye=t==null?void 0:t.oauth)==null?void 0:ye.client_id)&&n.jsxs("p",{className:"text-small text-muted-foreground",children:["Signing in again uses the client it signed in with (",t.oauth.client_id,"); a client ID here replaces it."]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Scopes (optional)"}),n.jsx(Be,{name:"mcp-scopes",placeholder:"read write",defaultValue:(Ee=t==null?void 0:t.oauth)==null?void 0:Ee.scopes.join(" "),spellCheck:!1})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("label",{className:"block flex-1",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:P?"Client ID (this server needs one)":"Client ID (optional)"}),n.jsx(Be,{name:"mcp-client-id",spellCheck:!1})]}),a&&n.jsxs("label",{className:"block flex-1",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:P?"Client secret (if its app has one)":"Client secret (optional)"}),n.jsx(Be,{name:"mcp-client-secret",...kd})]})]})]}),R&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(lc,{problem:R}),R.signIn&&m!=="oauth"&&a&&n.jsx(K,{type:"button",size:"sm",variant:"primary",disabled:L||!p.trim(),onClick:()=>void B(),children:"Sign in"})]}),T&&n.jsxs("section",{"aria-label":"Preview",className:"border bg-background p-3",children:[n.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["MCP ",T.protocol,(ge=T.server_info)!=null&&ge.name?` · ${T.server_info.name}${T.server_info.version?` ${T.server_info.version}`:""}`:""," · ",T.tools.length," tool",T.tools.length===1?"":"s"]}),T.instructions&&n.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:T.instructions}),n.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:LM}),n.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:T.tools.map(se=>n.jsxs("li",{className:"px-3 py-2",children:[n.jsx("span",{className:"font-mono text-body",children:se.name}),se.title&&n.jsx("span",{className:"ml-2 text-small",children:se.title}),se.description&&n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:se.description})]},se.name))})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[m==="oauth"&&!a?null:m==="oauth"&&J?n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:L||!y.trim(),children:"Sign in again with these settings"}):m==="oauth"?n.jsx(K,{type:"button",size:"sm",variant:"solid",disabled:L||!p.trim()||!y.trim(),onClick:()=>void B(),children:t?"Sign in again":"Sign in"}):n.jsx(K,{type:"button",size:"sm",disabled:L||!y.trim(),onClick:q,children:"Preview"}),(m!=="oauth"||t&&!J)&&n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:!de,children:L?"Working":"Save"}),n.jsx(K,{type:"button",size:"sm",onClick:()=>{var se;(se=d.current)==null||se.reset(),c()},children:"Cancel"})]})]})}const ck=e=>e instanceof Pe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function D6({v2:e,needs:t,model:s,onSaved:r,writable:a,whyNot:l="sign_in"}){const[c,u]=x.useState(null),[d,p]=x.useState(null),[g,y]=x.useState(null),[h,m]=x.useState(null),v=x.useRef(0),w=()=>{const E=++v.current;e.listToolKeys().then(T=>{E===v.current&&(u(T.keys.filter(C=>C.kind==="model")),p(null))}).catch(T=>{E===v.current&&p(ck(T))})};x.useEffect(()=>{t!=="model"&&w()},[e,t]);const k=s!=null&&s.includes("/")?s.slice(0,s.indexOf("/")):void 0,N=c==null?void 0:c.find(E=>E.id===k),A=N?[N]:c,_=c==null?void 0:c.find(E=>E.id===g),S=(_==null?void 0:_.fields.filter(E=>{var T;return((T=_.secrets.find(C=>tf(C.name)===E.name))==null?void 0:T.source)!=="env"}))??[];return n.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:n.jsxs("div",{className:"mx-auto flex max-w-[1600px] gap-3",children:[n.jsx(ia,{className:"mt-1 size-4 shrink-0 text-warning-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[n.jsx("h2",{className:"text-prose font-semibold",children:t==="model"?"This server's default model doesn't run":"Add a model key to run agents"}),t==="model"?n.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."}):N?n.jsxs("p",{className:"text-body text-muted-foreground",children:["This server's default model is ",n.jsx("span",{className:"font-mono",children:s}),", and no ",N.label," key is set, so an agent that names no model can't run. Save the ",N.label," key: such an agent then runs on that model."]}):n.jsxs(n.Fragment,{children:[n.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."}),n.jsx("p",{className:"text-body text-muted-foreground",children:m2})]}),t!=="model"&&d&&n.jsxs("div",{role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",d.code,": ",d.message]}),n.jsx(K,{type:"button",onClick:w,size:"sm",className:"mt-2",children:"Try again"})]}),t!=="model"&&c&&!a&&n.jsx("p",{className:"text-body",role:"status",children:Oc[l]}),t!=="model"&&c&&a&&n.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:A.map(E=>n.jsx(K,{size:"sm",variant:g===E.id?"solid":"primary","aria-pressed":g===E.id,onClick:()=>{y(g===E.id?null:E.id),m(null)},children:E.label},E.id))}),_&&a&&(S.length?n.jsx(p2,{tool:_,fields:S,onCancel:()=>y(null),onSave:async E=>{m(null);try{await e.saveToolKey(_.id,E)}catch(T){return T instanceof Pe&&T.status===422?T:(m(ck(T)),null)}return y(null),w(),r==null||r(),null}},_.id):n.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",_.label," key when it starts: change it there."]})),h&&n.jsx("div",{className:"border",children:n.jsx(_a,{error:h,title:"The key was not saved"})}),n.jsxs("p",{className:"text-small text-muted-foreground",children:["Every key is in ",n.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"#/settings/keys",children:"Settings"}),"."]})]})]})})}function F6({needs:e,settings:t,model:s,source:r}){return n.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.":n.jsxs(n.Fragment,{children:["No model yet."," ",r==="gateway"?n.jsxs(n.Fragment,{children:["This server sends its models to a gateway: name the gateway's model in AGENT_MODEL where AgentRun starts, and restart",t?n.jsxs(n.Fragment,{children:[", or ",n.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.`:t?n.jsxs(n.Fragment,{children:[n.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 or OPENAI_API_KEY where AgentRun starts, and restart."]}):"Set OPENROUTER_API_KEY (one key gives every harness its model), or ANTHROPIC_API_KEY or OPENAI_API_KEY, and restart."]})})}const uk=e=>e instanceof Pe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},U6={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 W6({v2:e}){const[t,s]=x.useState(null),[r,a]=x.useState([]),[l,c]=x.useState(null),[u,d]=x.useState(null),[p,g]=x.useState(null),[y,h]=x.useState(null),[m,v]=x.useState(!1),[w,k]=x.useState(!1),[N,A]=x.useState(""),_=x.useRef(0),S=()=>{const C=++_.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([R,D])=>{C===_.current&&(s(R),a(D.attempts),c(null))}).catch(R=>{C===_.current&&c(uk(R))})};x.useEffect(S,[e]);const E=async(C,R)=>{g(null),k(!0);try{await R()}catch(D){g({title:C,error:uk(D)})}finally{k(!1)}S()},T=C=>{C.preventDefault(),E("The webhook was not saved",async()=>{const R=await e.saveWebhook(N.trim());R.signing_secret&&d(R.signing_secret);const{signing_secret:D,...L}=R;s(L)})};return t?n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Webhook"}),n.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."})]}),p&&n.jsx(_a,{error:p.error,title:p.title}),l&&n.jsx(_n,{tone:"error",actions:n.jsx(K,{type:"button",size:"xs",onClick:S,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",l.code,": ",l.message,". What is shown may be out of date."]})}),u&&n.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Webhook secret",children:[n.jsx("p",{className:"caps text-small font-semibold text-warning-text",children:"The signing secret, shown this once"}),n.jsx("p",{className:"mt-2 break-all font-mono text-body",children:u}),n.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:["Keep it where the receiver checks ",n.jsx("span",{className:"font-mono",children:"webhook-signature"}),". This server never shows it again."]}),n.jsx(K,{type:"button",variant:"outline",className:"mt-3",onClick:()=>d(null),children:"Done"})]}),n.jsxs("section",{className:"border bg-card p-4","aria-label":"Webhook URL",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Bl,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.configured?n.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:t.url}):n.jsx("span",{className:"text-body text-muted-foreground",children:"No webhook is set."}),t.configured&&(t.disabled?n.jsx(Ne,{tone:"error",children:"off"}):t.signing==="sealed"?n.jsx(Ne,{tone:"success",children:"on"}):n.jsx(Ne,{tone:"warning",children:"not signing"}))]}),t.configured&&t.disabled&&n.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",t.disabled.reason,", ",ht(t.disabled.at),". Nothing is sent until the URL is saved again: enter it below."]}),t.configured&&t.signing!=="sealed"&&n.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[n.jsx(Zs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),U6[t.signing]]}),n.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:T,children:[n.jsx(Be,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:t.configured?"The whole URL, to change it or save it again":"https://...",value:N,onChange:C=>A(C.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),n.jsx(K,{type:"submit",variant:"solid",disabled:w||!N.trim(),children:"Save"}),t.configured&&n.jsx(K,{type:"button",variant:"outline",disabled:w,onClick:()=>E("The test was not sent",async()=>h(await e.testWebhook())),children:"Send a test"}),t.configured&&!m&&n.jsx(K,{type:"button",variant:"outline",disabled:w,onClick:()=>v(!0),children:"Remove"})]}),m&&n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[n.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),n.jsx(K,{type:"button",variant:"destructive",disabled:w,onClick:()=>{v(!1),A(""),h(null),E("The webhook was not removed",async()=>{await e.removeWebhook(),s({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),d(null)})},children:"Remove the webhook"}),n.jsx(K,{type:"button",variant:"ghost",onClick:()=>v(!1),children:"Cancel"})]}),y&&n.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",dk(y)]})]}),n.jsxs("section",{"aria-label":"Deliveries",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"caps text-small font-semibold text-muted-foreground",children:"Last deliveries"}),n.jsx(K,{type:"button",variant:"ghost",onClick:S,children:"Refresh"})]}),r.length===0?n.jsx("p",{className:"mt-2 border p-4 text-body text-muted-foreground",children:"No message has been tried yet."}):n.jsx("ul",{className:"mt-2 border",children:r.map((C,R)=>n.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:[n.jsx("span",{className:"w-[170px] shrink-0 text-muted-foreground",children:ht(C.at)}),n.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:C.type}),n.jsx("span",{className:C.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:dk(C)}),C.redelivery&&n.jsx(Ne,{children:"redelivery"}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:C.webhook_id,children:[C.webhook_id.slice(0,12),"…"]}),n.jsx(K,{type:"button",variant:"outline",size:"sm",disabled:w,onClick:()=>E("The message was not sent again",()=>e.redeliverWebhook(C.webhook_id)),children:"Redeliver"})]},`${C.webhook_id}:${C.at}:${R}`))})]})]})}):l?n.jsx(_n,{tone:"error",className:"m-8",actions:n.jsx(K,{type:"button",size:"xs",onClick:S,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",l.code,": ",l.message]})}):n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."})}function dk(e){const t=e.error??`${e.status_code}`,s=e.status_code!==null?`, ${e.latency_ms} ms`:"";return`${t}${s}${e.retry_at?`; tried again ${ht(e.retry_at)}`:""}`}const H6={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."}},ng=e=>H6[e]??{label:e,gives:""},B6=e=>e instanceof Pe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},sg=e=>e.slice(e.lastIndexOf(":")+1),G6=2e3;function q6({v2:e,writable:t,whyNot:s="sign_in"}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,d]=x.useState(null),[p,g]=x.useState(null),[y,h]=x.useState({}),[m,v]=x.useState(new Set),w=x.useRef(0),k=x.useCallback(()=>{const E=++w.current;c(null),e.computers().then(T=>{E===w.current&&a(T)},T=>{E===w.current&&c(B6(T))})},[e]);if(x.useEffect(k,[k]),!r)return l?n.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",l.code,": ",l.message]}),n.jsx(K,{size:"sm",onClick:k,className:"mt-3",children:"Try again"})]}):n.jsx("div",{className:"p-5 md:p-8",children:n.jsx(fs,{label:"Loading the computers",rows:3})});const N=new Set(r.paired.map(E=>E.id)),A=E=>r.kinds.filter(T=>T.providers.some(C=>C.id===E)).map(T=>T.kind),_=async(E,T,C)=>{g(null);try{await e.saveComputerKeys(T.id,C)}catch(R){return R instanceof Pe&&R.status===422?R:(g({at:E,words:tn(R)}),null)}return d(null),k(),null},S=async E=>{v(C=>new Set(C).add(E.id));let T;try{const C=await e.testComputer(E.id);T=C.ok?{ok:!0,words:C.detail,at:new Date().toISOString()}:{ok:!1,words:C.why,at:new Date().toISOString()}}catch(C){T={ok:!1,words:tn(C),at:new Date().toISOString()}}h(C=>({...C,[E.id]:T})),v(C=>{const R=new Set(C);return R.delete(E.id),R})};return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Computers"}),n.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."})]}),n.jsx(Y6,{v2:e,paired:r.paired,reload:k}),!t&&n.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Oc[s]}),r.kinds.map(E=>n.jsx(X6,{kind:E,providers:E.providers.filter(T=>!N.has(T.id)),own:E.providers.filter(T=>N.has(T.id)).map(T=>T.name),children:E.providers.filter(T=>!N.has(T.id)).map(T=>{const C=`${E.kind}/${T.id}`;return n.jsx(Q6,{v2:e,kind:E.kind,provider:T,writable:t,serves:A(T.id),tested:y[T.id],testing:m.has(T.id),open:(u==null?void 0:u.at)===C?u.mode:null,problem:(p==null?void 0:p.at)===C?p.words:null,onOpen:R=>{d(R?{at:C,mode:R}:null),g(null)},onSave:R=>_(C,T,R),onRemove:async R=>{var L;const D=await _(C,T,{[R]:null});D&&g({at:C,words:((L=D.fields)==null?void 0:L.map(O=>O.message).join(" "))||D.message})},onTest:()=>void S(T)},T.id)})},E.kind))]})})}function V6(e){const t=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(a=>ng(a).label).join(", ")||ng(e.kind).label,t,s,e.arch,r].filter(Boolean).join(" · ")}function K6(e){const t=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(", ")}`,...t].join(" · ")}function Y6({v2:e,paired:t,reload:s}){const[r,a]=x.useState(null),[l,c]=x.useState(!1),[u,d]=x.useState(()=>Date.now()),[p,g]=x.useState(null),[y,h]=x.useState(null),[m,v]=x.useState(null),w=r?Date.parse(r.code.expires_at)-u:0,k=r!==null&&w>0;x.useEffect(()=>{if(!k)return;const S=setInterval(()=>d(Date.now()),1e3),E=setInterval(s,G6);return()=>{clearInterval(S),clearInterval(E)}},[k,s]),x.useEffect(()=>{if(!r)return;const S=t.find(E=>E.pairing===r.code.id);S&&(g(S.name),a(null))},[t,r]);const N=async()=>{c(!0),v(null),g(null);try{const S=await e.createPairing();d(Date.now()),a({code:S})}catch(S){v(tn(S))}c(!1)},A=async S=>{v(null);try{await e.removeComputer(S)}catch(E){v(tn(E));return}h(null),s()},_=`${Math.floor(Math.max(0,w)/6e4)}:${String(Math.floor(Math.max(0,w)%6e4/1e3)).padStart(2,"0")}`;return n.jsxs("section",{"aria-label":"Your computers",children:[n.jsxs("h2",{className:"mb-2 flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"caps text-small font-semibold",children:"Your computers"}),n.jsx("span",{className:"text-small text-muted-foreground",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."})]}),r?n.jsxs("div",{"data-pairing":!0,className:"mb-3 space-y-3 border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Server address"}),n.jsx("p",{"data-address":!0,className:"mt-1 font-mono text-prose font-semibold",children:window.location.origin})]}),n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Pairing code"}),n.jsx("p",{"data-code":!0,className:"mt-1 font-mono text-2xl font-semibold",children:r.code.code})]})]}),k?n.jsxs("p",{className:"text-body",children:["Type both into the driver on the computer. The code pairs one computer, once, in the next ",n.jsx("span",{"data-countdown":!0,className:"font-mono",children:_}),"."]}):n.jsx("p",{role:"status",className:"text-body text-muted-foreground",children:"This code has expired. Make a new one."}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(K,{size:"sm",onClick:()=>void N(),disabled:l,children:l?"Making…":"New code"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(null),children:"Done"})]})]}):n.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-3",children:[n.jsx(K,{size:"sm",variant:"primary",onClick:()=>void N(),disabled:l,children:l?"Making…":"Pair a computer"}),p&&n.jsxs("p",{role:"status",className:"text-body text-success-text",children:["Paired ",p,"."]})]}),m&&n.jsx("p",{role:"alert",className:"mb-3 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:m}),t.length?n.jsx("ul",{className:"border",children:t.map(S=>n.jsxs("li",{"data-paired":S.id,className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[S.serves.includes("phone")?n.jsx(Uk,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):n.jsx(wa,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:S.name}),S.online?n.jsx(Ne,{tone:"success",children:"Online"}):n.jsx(Ne,{tone:"muted",children:"Offline"}),S.held_by_run&&n.jsxs(Ne,{tone:"active",children:["In use by run ",Co(S.held_by_run)]}),S.unserved&&n.jsx(Ne,{tone:"warning",children:"No agent can use it"})]}),S.unserved&&n.jsx("p",{"data-unserved":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:S.unserved}),S.held_by_run&&S.held_until&&n.jsxs("p",{"data-held-until":!0,className:"mt-1.5 text-small text-muted-foreground",children:["The run's hold ends by ",ht(S.held_until),", released or not."]}),!S.online&&n.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:"Open its driver on that computer: it dials this server."}),n.jsx("p",{"data-machine":!0,className:"mt-2 text-small text-muted-foreground",children:V6(S)}),S.groups.length>0&&n.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:K6(S)}),n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${S.driver} · paired ${ht(S.created_at)}${S.seen_at?` · last attached ${ht(S.seen_at)}`:""}`})]}),n.jsx(K,{size:"sm",onClick:()=>{h(S.id),v(null)},disabled:y!==null,children:"Remove"})]}),y===S.id&&n.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.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":"","."]}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>void A(S.id),children:"Remove"}),n.jsx(K,{size:"sm",onClick:()=>h(null),children:"Cancel"})]})]},S.id))}):n.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 X6({kind:e,providers:t,own:s,children:r}){const{label:a,gives:l}=ng(e.kind);return n.jsxs("section",{"aria-label":a,children:[n.jsxs("h2",{className:"mb-2 flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"caps text-small font-semibold",children:a}),l&&n.jsx("span",{className:"text-small text-muted-foreground",children:l}),!e.offered&&n.jsx(Ne,{tone:"muted",children:"Not offered here"})]}),!e.offered&&e.why&&n.jsx("p",{className:"mb-2 font-mono text-small text-muted-foreground",children:e.why}),s.length>0&&n.jsxs("p",{className:"mb-2 text-small text-muted-foreground",children:["Also served by your computers: ",s.join(", "),"."]}),t.length?n.jsx("ul",{className:"border",children:r}):n.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 Q6({v2:e,kind:t,provider:s,writable:r,serves:a,tested:l,testing:c,open:u,problem:d,onOpen:p,onSave:g,onRemove:y,onTest:h}){const m=u&&"paste"in u?u.paste:null,v=u&&"remove"in u?u.remove:null;return n.jsxs("li",{className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[n.jsx(wa,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:s.name}),s.ready?n.jsx(Ne,{tone:"success",children:"Ready"}):n.jsx(Ne,{children:"Not ready"}),s.metered&&n.jsx("span",{"data-metered":!0,className:"text-small text-muted-foreground",children:"Metered"})]}),!s.ready&&s.why&&n.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:s.why}),s.metered&&Fx.has(t)&&n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Dx}),s.secrets.length>0&&n.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(w=>{var A;const k=sg(w.name),N=((A=s.picked)==null?void 0:A.includes(w.name))??!1;return n.jsx(Bf,{field:w,required:s.required.includes(w.name),writable:r&&!u,...N?{}:{onPaste:()=>p({paste:k})},onRemove:()=>p({remove:k})},w.name)})}),s.picked&&s.picked.length>0&&s.required.every(w=>s.secrets.some(k=>k.name===w&&k.set))&&n.jsx(J6,{v2:e,provider:s,writable:r&&!u,onSave:g}),l&&n.jsx("p",{"data-test":!0,className:`mt-2 text-small ${l.ok?"text-success-text":"text-destructive-text"}`,children:`${l.ok?"Passed":"Failed"} · ${Cf(l.at)} · ${l.words}`}),n.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",a.join(", ")]})]}),n.jsx("div",{className:"flex gap-2",children:n.jsx(K,{size:"sm",onClick:h,disabled:c,children:c?"Testing…":"Test connection"})})]}),r&&m&&n.jsx(Z6,{provider:s.name,name:m,set:s.secrets.some(w=>sg(w.name)===m&&w.set),onSave:g,onCancel:()=>p(null)}),r&&v&&n.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",v," saved on this server?"]}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>void y(v),children:"Remove"}),n.jsx(K,{size:"sm",onClick:()=>p(null),children:"Cancel"})]}),d&&n.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:d})]})}function J6({v2:e,provider:t,writable:s,onSave:r}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[d,p]=x.useState(null),g=t.secrets.map(h=>`${h.name}:${h.set}:${h.changed_at??""}`).join(" ");x.useEffect(()=>{let h=!0;return l(null),u(null),e.computerChoices(t.id).then(m=>{h&&l(m)},m=>{h&&u(tn(m))}),()=>{h=!1}},[e,t.id,g]);const y=async(h,m)=>{var w;p({key:h.key,value:m}),u(null);const v=await r({[h.key]:m});p(null),v&&u(((w=v.fields)==null?void 0:w.map(k=>k.message).join(" "))||v.message)};return c&&!a?n.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${c}`}):a?n.jsxs("div",{className:"mt-3 space-y-3",children:[a.choices.map(h=>{const m=t.secrets.find(w=>sg(w.name)===h.key),v=(m==null?void 0:m.source)==="env";return n.jsxs("div",{"data-choices":h.key,className:"border bg-card p-3",children:[n.jsx("p",{className:"caps mb-2 text-small font-semibold",children:h.key}),"why"in h?n.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:h.why}):n.jsxs(n.Fragment,{children:[n.jsx(Lt,{label:`${t.name} ${h.key}`,value:(d==null?void 0:d.key)===h.key?d.value:h.saved??"",disabled:!s||v||d!==null,options:h.options.map(w=>({value:w.value,label:w.label})),placeholder:"Pick one",onChange:w=>void y(h,w),className:"w-full max-w-md"}),n.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${m!=null&&m.set&&h.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:v?`Set in the environment where AgentRun starts, and that one is used: change ${h.key} there.`:h.saved!==void 0?"Picked and saved on this server.":m!=null&&m.set?`The ${h.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:h.options.length===1?`The only one, ${h.options[0].label}, is used while none is picked.`:`${h.options.length} to pick from. Pick the one this server's computers use.`})]})]},h.key)}),c&&n.jsx("p",{role:"alert",className:"font-mono text-small text-destructive-text",children:c})]}):n.jsx("p",{role:"status",className:"mt-3 text-small text-muted-foreground",children:"Reading the choices…"})}function Z6({provider:e,name:t,set:s,onSave:r,onCancel:a}){const l=x.useRef(null),[c,u]=x.useState(!1),[d,p]=x.useState(!1),[g,y]=x.useState(null),h=()=>{var w,k;return((k=(w=l.current)==null?void 0:w.elements.namedItem(t))==null?void 0:k.value)??""},m=()=>{var w;(w=l.current)==null||w.reset(),u(!1)},v=async w=>{var S;w.preventDefault();const k=h();if(!k)return;p(!0),y(null);const N=await r({[t]:k});if(p(!1),!N){m();return}const A=(S=N.fields)==null?void 0:S.find(E=>E.field===t),_=(N.fields??[]).filter(E=>E.field!==t).map(E=>E.message);y(A?{field:A.message,message:_.join(" ")}:{field:null,message:_.join(" ")||N.message})};return n.jsxs("form",{ref:l,autoComplete:"off",onSubmit:w=>void v(w),onInput:()=>u(!!h()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e} ${t}`,children:[n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:t}),s&&n.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"A new value replaces the one saved."}),n.jsx(Be,{type:"password",name:t,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(g==null?void 0:g.field)&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:g.field})]}),(g==null?void 0:g.message)&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g.message}),n.jsx("p",{className:"text-small text-muted-foreground",children:"Kept sealed on this server. It is never shown again, here or anywhere."}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:!c||d,children:d?"Saving":"Save"}),n.jsx(K,{type:"button",size:"sm",onClick:()=>{m(),a()},children:"Cancel"})]})]})}const e8="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.",fk=[{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)"}],t8=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),Er="ARCHIL_API_KEY",n8=e=>e instanceof Pe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function s8({v2:e,writable:t,whyNot:s="sign_in"}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,d]=x.useState({region:"",s3Url:"",image:""}),[p,g]=x.useState(null),[y,h]=x.useState(null),[m,v]=x.useState(!1),[w,k]=x.useState(null),[N,A]=x.useState(!1),[_,S]=x.useState(!1),[E,T]=x.useState(!1),[C,R]=x.useState(!1),D=x.useRef(null),L=x.useRef(0),O=x.useCallback(z=>{a(z),d(t8(z))},[]),I=x.useCallback(()=>{const z=++L.current;c(null),e.archil().then(H=>{z===L.current&&O(H)},H=>{z===L.current&&c(n8(H))})},[e,O]);if(x.useEffect(I,[I]),!r)return l?n.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",l.code,": ",l.message]}),n.jsx(K,{size:"sm",onClick:I,className:"mt-3",children:"Try again"})]}):n.jsx("div",{className:"p-5 md:p-8",children:n.jsx(fs,{label:"Loading Archil's settings",rows:2})});const W=()=>{var z,H;return((H=(z=D.current)==null?void 0:z.elements.namedItem(Er))==null?void 0:H.value)??""},U=async z=>{const H={region:u.region,s3Url:u.s3Url,...u.image?{image:u.image}:{},...z!==void 0?{keys:{[Er]:z}}:{}};v(!0),g(null),h(null);try{const V=await e.saveArchil(H);T(!1),R(!1),O(V)}catch(V){if(V instanceof Pe&&V.status===422){const P={},B=[];for(const q of V.fields??[]){const ce=q.field.startsWith("keys.")?q.field.slice(5):q.field;fk.some(de=>de.name===ce)||ce===Er?P[ce]=q.message:B.push(q.message)}g({fields:P,message:B.length?B.join(" "):Object.keys(P).length?null:V.message})}else h(tn(V))}finally{v(!1)}},J=z=>{z.preventDefault(),U(E&&W()?W():void 0)},F=async()=>{A(!0);try{const z=await e.testArchil();k(z.ok?{ok:!0,words:z.detail,at:new Date().toISOString()}:{ok:!1,words:z.why,at:new Date().toISOString()})}catch(z){k({ok:!1,words:tn(z),at:new Date().toISOString()})}finally{A(!1)}},Z=async()=>{h(null);try{O(await e.archilOff()),S(!1)}catch(z){h(tn(z))}};return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Workspace"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:e8})]}),!t&&n.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Oc[s]}),n.jsxs("section",{"aria-label":"Archil",className:"border p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsx(aE,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),n.jsx("span",{"data-archil-state":!0,children:r.on?n.jsx(Ne,{tone:"success",children:"On"}):n.jsx(Ne,{children:"Off"})}),r.on&&n.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:r.region??""}),n.jsx("span",{className:"flex-1"}),n.jsx(K,{size:"sm",onClick:()=>void F(),disabled:N,children:N?"Testing…":"Test"}),r.on&&n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>S(!0),children:"Turn off"})]}),w&&n.jsx("p",{"data-test":!0,className:`mt-3 text-small ${w.ok?"text-success-text":"text-destructive-text"}`,children:`${w.ok?"Passed":"Failed"} · ${Cf(w.at)} · ${w.words}`}),_&&n.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>void Z(),children:"Turn off"}),n.jsx(K,{size:"sm",onClick:()=>S(!1),children:"Cancel"})]}),y&&n.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:y}),n.jsxs("form",{ref:D,autoComplete:"off",onSubmit:J,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[fk.map(z=>n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:z.label}),n.jsx(Be,{name:z.name,value:u[z.name],placeholder:z.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:H=>{const V=H.currentTarget.value;d(P=>({...P,[z.name]:V}))}}),(p==null?void 0:p.fields[z.name])&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[z.name]})]},z.name)),n.jsx("ul",{children:n.jsx(Bf,{field:r.secret,label:Er,writable:t&&!E&&!C,onPaste:()=>T(!0),onRemove:()=>R(!0)})}),t&&C&&n.jsxs("div",{"data-confirm-key":!0,className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",Er," saved on this server?"]}),n.jsx(K,{type:"button",size:"sm",variant:"destructive",onClick:()=>void U(null),children:"Remove"}),n.jsx(K,{type:"button",size:"sm",onClick:()=>R(!1),children:"Cancel"})]}),t&&E&&n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:Er}),n.jsx(Be,{type:"password",name:Er,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(p==null?void 0:p.fields[Er])&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[Er]})]}),t&&E&&n.jsx(K,{type:"button",size:"sm",onClick:()=>T(!1),children:"Cancel"}),(p==null?void 0:p.message)&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:p.message}),n.jsx(K,{type:"submit",size:"sm",variant:"solid",disabled:m,children:m?"Saving":r.on?"Save":"Turn on"})]})]})]})})}const x2=x.createContext(new Map),r8={schedule:"Schedule",webhook:"Webhook",github:"GitHub"};function y2({run:e}){const t=x.useContext(x2);if(!e.trigger)return null;const{id:s}=e.trigger,r=t.get(s),a=r?`${r8[r.kind]??"Trigger"}: ${r.name}`:`Trigger: ${s}`;return n.jsx("a",{href:`#/triggers/${encodeURIComponent(s)}`,onClick:l=>l.stopPropagation(),className:"inline-flex max-w-full",title:a,children:n.jsxs(Ne,{className:"max-w-full",children:[n.jsx(af,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:a})]})})}const vo=e=>`#/triggers/${encodeURIComponent(e)}`,nf=e=>ht(e),o8={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function a8({v2:e,view:t,go:s,agentName:r,minEvery:a,failuresToPause:l,refreshMs:c=15e3,now:u=Date.now}){return t.trigger===void 0?n.jsx(c8,{v2:e,go:s,agentName:r,every:c*2,now:u,failuresToPause:l}):t.trigger===null?t.kind==="webhook"?n.jsx(g8,{v2:e,go:s}):t.kind==="github"?n.jsx(x8,{v2:e,go:s}):n.jsx(N2,{v2:e,go:s,minEvery:a,now:u}):t.edit?n.jsx(p8,{v2:e,go:s,id:t.trigger,minEvery:a,now:u},t.trigger):n.jsx(m8,{v2:e,go:s,agentName:r,id:t.trigger,every:c,now:u,failuresToPause:l},t.trigger)}function b2(e,t,s){const r=x.useRef(e);r.current=e,x.useEffect(()=>{const a=()=>document.visibilityState!=="hidden",l=setInterval(()=>{a()&&r.current()},t),c=()=>{a()&&r.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(l),document.removeEventListener("visibilitychange",c)}},[t,...s])}const v2=e=>e?"ran"in e?`Done · ran ${nf(e.ran.nominal_at)}`:`Its time passed · ${nf(e.passed)}`:null,i8=/has already passed\.?$/;function w2({trigger:e}){return e.disabled?n.jsx(Ne,{tone:"warning",children:"Turned off"}):n.jsx(Ne,{tone:"muted",children:"Paused"})}const l8=e=>e.last_firing?`${sS(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${nf(e.last_firing.nominal_at)}`:"Not fired yet";function c8({v2:e,go:t,agentName:s,every:r,now:a,failuresToPause:l}){const[c,u]=x.useState(null),[d,p]=x.useState(null),[g,y]=x.useState(0),h=x.useRef(!1),m=x.useRef(!0);x.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const v=()=>{h.current||(h.current=!0,e.listTriggers().then(w=>{m.current&&(u(w.triggers),p(null))},w=>{m.current&&p(ln(w,"the triggers"))}).finally(()=>{h.current=!1}))};return x.useEffect(v,[e,g]),b2(v,r,[e]),n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[n.jsx("h1",{className:"mr-auto font-mono text-2xl font-semibold",children:"Triggers"}),!(c&&!c.length)&&n.jsxs(n.Fragment,{children:[n.jsxs(K,{size:"lg",onClick:()=>t("#/triggers/new-github"),children:[n.jsx(gg,{"aria-hidden":!0})," New GitHub trigger"]}),n.jsxs(K,{size:"lg",onClick:()=>t("#/triggers/new-webhook"),children:[n.jsx(Bl,{"aria-hidden":!0})," New webhook"]}),n.jsxs(K,{size:"lg",variant:"solid",onClick:()=>t("#/triggers/new"),children:[n.jsx(yi,{"aria-hidden":!0})," New schedule"]})]})]}),d&&!c?n.jsx($n,{problem:d,onRetry:()=>y(w=>w+1),className:""}):c?c.length?n.jsx("ul",{className:"border",children:c.map(w=>n.jsxs("li",{"data-trigger":w.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:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("a",{href:vo(w.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:w.name}),n.jsx(Ne,{children:d8[w.source.kind]}),!w.enabled&&!px(w,a())&&n.jsx(w2,{trigger:w})]}),n.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:k2(w),children:f8(w,s,a())}),Yd(w,l)&&n.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:Yd(w,l)})]}),n.jsx("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:n.jsx("p",{className:"break-words",children:l8(w)})})]},w.id))}):n.jsx(u8,{go:t}):n.jsx(fs,{label:"Loading the triggers",rows:4}),c&&d&&n.jsx($n,{problem:d,className:"mt-4"})]})}function u8({go:e}){const t=[{Icon:af,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:Bl,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:gg,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"}];return n.jsxs("section",{"aria-labelledby":"first-trigger",className:"border border-primary/50 bg-primary/5 p-5",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"No triggers yet"}),n.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),n.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."}),n.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-3",children:t.map(({Icon:s,name:r,what:a,action:l,to:c})=>n.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[n.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[n.jsx(s,{className:"size-4 text-primary-text","aria-hidden":!0}),r]}),n.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:a}),n.jsx(K,{size:"sm",variant:c==="#/triggers/new"?"solid":"outline",className:"mt-4 self-start",onClick:()=>e(c),children:l})]},r))})]})}const d8={schedule:"Schedule",webhook:"Webhook",github:"GitHub"},k2=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function f8(e,t,s){return`${e.source.kind==="schedule"?mx(e.source,e.next_at,{instead:v2(px(e,s)),now:s}):e.source.kind==="github"?nS(e.source):tS(e.source)} · ${e.target.kind==="start_run"?t(e.target.agent_id)||e.target.agent_id:`messages run ${Co(e.target.run_id)}`}`}function j2(){return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),n.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 m8({v2:e,go:t,agentName:s,id:r,every:a,now:l,failuresToPause:c}){var Ze,Je,xt,et;const[u,d]=x.useState(null),[p,g]=x.useState([]),[y,h]=x.useState(null),[m,v]=x.useState(null),[w,k]=x.useState(null),[N,A]=x.useState(!1),[_,S]=x.useState(!1),[E,T]=x.useState(!1),[C,R]=x.useState(""),[D,L]=x.useState(!1),[O,I]=x.useState(null),W=x.useRef(!1),[U,J]=x.useState(!1),[F,Z]=x.useState(0),z=x.useRef(!1),H=x.useRef(!1),V=x.useRef(0),P=()=>{H.current=!0;const ae=V.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([Ae,Ce])=>{ae===V.current&&(d(Ae),g(Ce.firings),h(null))}).finally(()=>{H.current=!1})};x.useEffect(()=>{P().catch(ae=>h(ln(ae,"the trigger")))},[e,r,F]),b2(()=>{!H.current&&!z.current&&P().catch(()=>{})},a,[e,r]);const[B,q]=x.useState(void 0),ce=u&&u.target.kind==="start_run"&&typeof u.target.max_cost_usd!="number"?u.target.agent_id:null;if(x.useEffect(()=>{if(!ce)return;let ae=!0;return e.getAgent(ce).then(Ae=>{ae&&q(typeof Ae.agent.definition.max_cost_usd=="number"?Ae.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{ae=!1}},[e,ce]),!u)return y?n.jsx($n,{problem:y,onRetry:()=>Z(ae=>ae+1),link:{href:"#/triggers",label:"All triggers"}}):n.jsx(fs,{label:"Loading the trigger",rows:4});const de=mL(u)?u:null,ue=pL(u)?u:null;if(!de&&!ue&&!hx(u))return n.jsx(j2,{});const Q=u,fe=px(u,l(),p),ye=async(ae,Ae,Ce)=>{k(ae),v(null);try{await Ae()}catch(Ge){v(ln(Ge,Ce))}finally{k(null)}},Ee=()=>ye("pause",async()=>{V.current++;const ae=await e.updateTrigger(r,{enabled:!u.enabled});V.current++,d(ae)},u.enabled?"the pause":"the resume"),ge=()=>ye("delete",async()=>{await e.deleteTrigger(r),t("#/triggers")},"the delete"),se=async()=>{if(!W.current){W.current=!0,J(!0),v(null);try{await e.rotateTriggerSecret(r,{secret:C.trim()}),T(!1),R(""),L(!0)}catch(ae){v(ln(ae,"the secret"))}finally{W.current=!1,J(!1)}}},pe=async()=>{if(!W.current){W.current=!0,J(!0),v(null),I(null);try{I((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(ae){v(ln(ae,"the new secret"))}finally{W.current=!1,J(!1)}}},Y=async()=>{if(!z.current){z.current=!0,k("fire"),v(null),V.current++;try{const ae=await e.fireTrigger(r,Of());V.current++,g(Ae=>[ae,...Ae.filter(Ce=>Ce.key!==ae.key)]),await P().catch(()=>{})}catch(ae){v(ln(ae,"the run now"))}finally{z.current=!1,k(null)}}},_e=typeof Q.target.input.content=="string"?Q.target.input.content:null;return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),n.jsxs("div",{className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 sm:flex-row",children:[n.jsxs("div",{className:"min-w-0 flex-1 self-stretch",children:[n.jsxs("h1",{className:"flex flex-wrap items-center gap-2 break-words text-2xl font-semibold leading-tight",children:[u.name,!u.enabled&&!fe&&n.jsx(w2,{trigger:u})]}),n.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:de?`Webhook · ${tS(de.source)}`:ue?`GitHub · ${nS(ue.source)}`:n.jsx("span",{title:k2(u),children:mx(Q.source,u.next_at,{instead:v2(fe),now:l()})})})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(K,{size:"sm",variant:"solid",onClick:()=>void Y(),disabled:w==="fire",children:[n.jsx(_E,{"aria-hidden":!0})," ",w==="fire"?"Starting":"Run now"]}),!(fe&&"ran"in fe)&&n.jsx(K,{size:"sm",onClick:()=>void Ee(),disabled:w!==null,children:u.enabled?n.jsxs(n.Fragment,{children:[n.jsx(xi,{"aria-hidden":!0})," Pause"]}):n.jsxs(n.Fragment,{children:[n.jsx(_i,{"aria-hidden":!0})," Resume"]})}),!de&&!ue&&n.jsxs(K,{size:"sm",onClick:()=>t(`${vo(r)}/edit`),children:[n.jsx(dc,{"aria-hidden":!0})," Edit"]}),de&&de.source.signature==="composio"&&(E?n.jsxs("form",{className:"flex items-center gap-2",onSubmit:ae=>{ae.preventDefault(),se()},children:[n.jsx(Be,{name:"secret",type:"password",autoComplete:"off","aria-label":"Composio's webhook secret",className:"w-64",value:C,onChange:ae=>R(ae.target.value)}),n.jsx(K,{size:"sm",variant:"solid",type:"submit",disabled:!C.trim()||U,children:"Save"}),n.jsx(K,{size:"sm",variant:"ghost",type:"button",onClick:()=>{T(!1),R("")},children:"Cancel"})]}):n.jsxs(K,{size:"sm",onClick:()=>T(!0),disabled:w!==null||U,children:[n.jsx(ia,{"aria-hidden":!0})," Set secret"]})),de&&de.source.signature!=="composio"&&(_?n.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:[n.jsx("span",{children:"The old secret stops signing at once."}),n.jsx(K,{size:"sm",variant:"solid",onClick:()=>{S(!1),pe()},children:"Yes, make a new one"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:"Keep"})]}):n.jsxs(K,{size:"sm",onClick:()=>S(!0),disabled:w!==null||U,children:[n.jsx(ia,{"aria-hidden":!0})," Rotate secret"]})),N?n.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:[n.jsx("span",{children:"Delete for good? Its runs stay."}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>{A(!1),ge()},children:"Yes, delete"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>A(!1),children:"Keep"})]}):n.jsxs(K,{size:"sm",variant:"destructive",onClick:()=>A(!0),disabled:w!==null,children:[n.jsx(SE,{"aria-hidden":!0})," Delete"]})]})]}),Yd(u,c)&&n.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:[Yd(u,c)," ",((Ze=u.disabled)==null?void 0:Ze.reason)==="source_unreadable"?"Edit its when, then Resume.":((Je=u.disabled)==null?void 0:Je.reason)==="auto_paused"?fe&&"passed"in fe?"Its time has passed: edit its time first, then Resume.":fe?"":"Resume turns it on again.":""]}),m&&n.jsx($n,{problem:m,className:"mt-4"}),de&&O&&n.jsx(Gx,{label:"The webhook's new secret",secret:O}),n.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:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),n.jsx("dd",{className:"min-w-0 break-words",children:n.jsx("a",{href:`#/agents/${encodeURIComponent(Q.target.agent_id)}`,className:"hover:underline",children:s(Q.target.agent_id)||Q.target.agent_id})}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Each run is asked"}),n.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-words",children:_e??JSON.stringify(Q.target.input)}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),n.jsx("dd",{className:"font-mono",children:fL(Q.target.max_cost_usd,B)}),de?n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"URL"}),n.jsxs("dd",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("code",{className:"min-w-0 break-all font-mono text-small",children:nc(de)}),n.jsx(S2,{text:nc(de),label:"Copy URL"}),n.jsx("span",{className:"basis-full text-small text-muted-foreground",children:gx})]}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),n.jsxs("dd",{children:[Dh[de.source.signature??"standard"],de.source.signature==="composio"&&!D&&!((xt=u.secret)!=null&&xt.set)?" (no secret set yet: every request is refused)":""]}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),n.jsx("dd",{className:"min-w-0 break-words",children:(et=de.source.accept)!=null&&et.length?n.jsx("ul",{className:"space-y-1 font-mono text-small",children:de.source.accept.map((ae,Ae)=>n.jsx("li",{children:Kd(ae)},Ae))}):"Every signed request"})]}):ue?n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),n.jsxs("dd",{className:"min-w-0 break-words",children:[n.jsx("ul",{className:"space-y-1 font-mono text-small",children:ue.source.accept.map((ae,Ae)=>n.jsx("li",{children:Kd(ae)},Ae))}),n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"While a run is going"}),n.jsx("dd",{children:"The next time is skipped."})]})]}),n.jsxs("section",{className:"mt-6","aria-label":"Firings",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Firings"}),p.length?n.jsx("ul",{className:"mt-3 border",children:p.map(ae=>n.jsxs("li",{"data-firing":ae.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:[n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(Ne,{tone:o8[ae.status],children:xL[ae.status]}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:nf(ae.nominal_at)})]}),n.jsx("span",{className:"min-w-0 flex-1 break-words",children:ae.status==="started"?`${gL[ae.by]}${ae.catch_up?", caught up late":""}`:`${sS(ae)}${ae.catch_up?" · caught up late":""}${ae.by==="manual"?" · Run now":""}`}),ae.run_id&&n.jsxs("a",{href:`#/runs/${encodeURIComponent(ae.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",Co(ae.run_id)]})]},ae.key))}):n.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function p8({v2:e,go:t,id:s,minEvery:r,now:a}){const[l,c]=x.useState(null),[u,d]=x.useState(null),[p,g]=x.useState(0);return x.useEffect(()=>{e.getTrigger(s).then(c,y=>d(ln(y,"the trigger")))},[e,s,p]),l?hx(l)?n.jsx(N2,{v2:e,go:t,trigger:l,minEvery:r,now:a}):n.jsx(j2,{}):u?n.jsx($n,{problem:u,onRetry:()=>g(y=>y+1)}):n.jsx(fs,{label:"Loading the schedule",rows:4})}function gn({label:e,field:t,issue:s,hint:r,children:a}){return n.jsx(Xs,{className:"min-w-0",label:e,hint:r,error:s?n.jsx("span",{"data-issue":t,children:s}):void 0,children:a})}const Hx=e=>e!==void 0?`${Pi(e)}, the agent's default`:void 0;async function Bx(e){const t=[];let s=null;for(let r=0;r<20;r++){const a=await e.listAgents({cursor:s});if(t.push(...a.agents),s=a.next_cursor,!s)break}return t}function N2({v2:e,go:t,trigger:s,minEvery:r,now:a=Date.now}){var W,U,J;const[l,c]=x.useState(()=>s?SL(s):YN()),[u,d]=x.useState(null),[p,g]=x.useState({}),[y,h]=x.useState([]),[m,v]=x.useState(!1),w=x.useRef(er()).current;x.useEffect(()=>{Bx(e).then(d,()=>d([]))},[e]);const k=F=>Z=>c(z=>({...z,[F]:Z})),N=F=>{var z;k("at")(F);const Z=ni(F,(z=l.read)==null?void 0:z.at);Z!==null&&Date.parse(Z)>a()?g(({"source.at":H,...V})=>V):Z!==null&&g(H=>H["source.at"]?{...H,"source.at":u0(Z,{now:a()})}:H)},A=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"]]),_=(W=(u??[]).find(F=>F.agent_id===l.agentId))==null?void 0:W.definition.max_cost_usd,S=typeof _=="number"&&_>0?_:void 0,E=S!==void 0||!!s&&typeof s.target.max_cost_usd!="number"&&l.agentId===s.target.agent_id,T=async F=>{var H;F.preventDefault();const{body:Z,issues:z}=f0(l,E);if(h([]),!Z){g(z??{});return}g({}),v(!0);try{if(s){const V=m0(s,Z);Object.keys(V).length&&await e.updateTrigger(s.id,V),t(vo(s.id))}else{const V=await e.createTrigger(Z,w.keyFor("createTrigger",Z));t(vo(V.id))}}catch(V){const P=xx(V),B=l.kind==="at"?ni(l.at,(H=l.read)==null?void 0:H.at):null,q=P.fields["source.at"];q&&B!==null&&(Date.parse(B)<=a()||i8.test(q))&&(P.fields["source.at"]=u0(B,{now:a()})),g(Object.fromEntries(Object.entries(P.fields).filter(([ce])=>A.has(ce)))),h([...P.rest,...Object.entries(P.fields).filter(([ce])=>!A.has(ce)).map(([,ce])=>ce)]),v(!1)}},C=s?f0(l,E).body:void 0,R=!!(s&&C&&m0(s,C).source),D=l.kind==="at"?ni(l.at,(U=l.read)==null?void 0:U.at):null,L=l.startAt?ni(l.startAt,(J=l.read)==null?void 0:J.startAt):null,O=_f((u??[]).filter(F=>!F.archived_at||F.agent_id===l.agentId)),I=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return n.jsxs("form",{onSubmit:F=>void T(F),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[n.jsxs("a",{href:s?vo(s.id):"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," ",s?s.name:"Triggers"]}),n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(af,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),y.length>0&&n.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:y.map((F,Z)=>n.jsx("p",{children:F},Z))}),n.jsxs("div",{className:"mt-5 space-y-5",children:[n.jsx(gn,{label:"Name",field:"name",issue:p.name,children:n.jsx(Be,{name:"name",value:l.name,onChange:F=>k("name")(F.target.value),placeholder:"nightly triage"})}),n.jsxs("fieldset",{className:"min-w-0",children:[n.jsx("legend",{className:"caps text-label text-muted-foreground",children:"When"}),n.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:I.map(({kind:F,label:Z})=>n.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${l.kind===F?"border-primary text-primary-text":""}`,children:[n.jsx("input",{type:"radio",name:"kind",value:F,checked:l.kind===F,onChange:()=>k("kind")(F),className:"accent-primary"}),Z]},F))}),n.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[l.kind==="cron"&&n.jsx(gn,{label:"Runs",field:"source.cron",issue:p["source.cron"],children:n.jsx(oS,{label:"Runs",name:"cron",value:l.cron,onChange:k("cron")})}),l.kind==="at"&&n.jsx(gn,{label:"At, your time",field:"source.at",issue:p["source.at"],hint:D?`= ${d0(D)}`:void 0,children:n.jsx(Be,{name:"at",type:"datetime-local",step:60,value:l.at,onChange:F=>N(F.target.value)})}),l.kind==="every"&&n.jsx(gn,{label:"Every",field:"source.every_s",issue:p["source.every_s"],hint:r?vL(r):void 0,children:n.jsxs("span",{className:"flex gap-2",children:[n.jsx(Be,{name:"every",inputMode:"decimal",value:l.every,onChange:F=>k("every")(F.target.value),placeholder:"5"}),n.jsx(Lt,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:l.everyUnit,onChange:F=>k("everyUnit")(F),options:["seconds","minutes","hours"].map(F=>({value:F,label:F}))})]})}),l.kind==="cron"&&n.jsx(gn,{label:"Time zone",field:"source.timezone",issue:p["source.timezone"],hint:"The time zone this schedule runs in.",children:n.jsx(aS,{name:"timezone",label:"Time zone",className:"w-full",value:l.timezone,onChange:k("timezone")})}),l.kind==="every"&&n.jsx(gn,{label:"Starting, your time (optional)",field:"source.start_at",issue:p["source.start_at"],hint:L?`= ${d0(L)}`:void 0,children:n.jsx(Be,{name:"startAt",type:"datetime-local",step:60,value:l.startAt,onChange:F=>k("startAt")(F.target.value)})})]}),R&&n.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),n.jsx(gn,{label:"Agent",field:"target.agent_id",issue:p["target.agent_id"],children:n.jsx(Lt,{name:"agent",label:"Agent",className:"w-full",value:l.agentId,onChange:F=>k("agentId")(F),options:[{value:"",label:u?"Pick an agent":"Loading the agents"},...O.map(F=>({value:F.agent_id,label:`${F.definition.name||F.agent_id}${F.kind==="workflow"?" (workflow)":""}`})),...l.agentId&&u&&!O.some(F=>F.agent_id===l.agentId)?[{value:l.agentId,label:l.agentId}]:[]]})}),n.jsx(gn,{label:"Each run is asked",field:"target.input",issue:p["target.input"],children:n.jsx(ds,{name:"content",rows:4,className:"p-3 font-sans",value:l.content,onChange:F=>k("content")(F.target.value)})}),n.jsx(gn,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:p["target.max_cost_usd"],hint:S!==void 0?`Uses the agent's default (${Pi(S)}) if empty.`:E?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:n.jsx(Be,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:l.maxCost,onChange:F=>k("maxCost")(F.target.value),placeholder:Hx(S)})}),!s&&n.jsxs("div",{children:[n.jsxs("label",{className:"flex items-center gap-2 text-body",children:[n.jsx("input",{type:"checkbox",name:"enabled",checked:l.enabled,onChange:F=>k("enabled")(F.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),p.enabled&&n.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:p.enabled})]})]}),n.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[n.jsx(K,{type:"submit",size:"lg",variant:"solid",disabled:m,children:m?"Saving":s?"Save changes":"Create schedule"}),n.jsx(K,{type:"button",size:"lg",variant:"ghost",onClick:()=>t(s?vo(s.id):"#/triggers"),children:"Cancel"})]})]})}function S2({text:e,label:t}){const[s,r]=x.useState(null),a="The browser won't copy here. Select it and copy it.",l=()=>{const c=typeof navigator<"u"?navigator.clipboard:void 0;if(!(c!=null&&c.writeText)){r(a);return}c.writeText(e).then(()=>r("Copied"),()=>r(a))};return n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[n.jsxs(K,{type:"button",size:"sm",onClick:l,children:[n.jsx(lf,{"aria-hidden":!0})," ",t]}),s&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function Gx({label:e,secret:t,url:s}){return n.jsxs("section",{"aria-label":e,className:"mt-4 space-y-3 border border-primary/50 p-4 text-body",children:[s&&n.jsx(rg,{title:"URL",text:s,label:"Copy URL",hint:gx}),n.jsx(rg,{title:"Signing secret",text:t,label:"Copy secret"}),n.jsx("p",{className:"text-warning-text",role:"note",children:"You won't see this secret again."})]})}function rg({title:e,text:t,label:s,hint:r}){return n.jsxs("div",{className:"min-w-0",children:[n.jsx("span",{className:"caps text-label text-muted-foreground",children:e}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("code",{className:"min-w-0 break-all border bg-muted/40 px-2 py-1 font-mono text-small",children:t}),n.jsx(S2,{text:t,label:s})]}),r&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const h8=["standard","github","composio"];function g8({v2:e,go:t}){var T;const[s,r]=x.useState(wL),[a,l]=x.useState(null),[c,u]=x.useState({}),[d,p]=x.useState([]),[g,y]=x.useState(!1),[h,m]=x.useState(null),v=x.useRef(er()).current;x.useEffect(()=>{Bx(e).then(l,()=>l([]))},[e]);const w=C=>R=>r(D=>({...D,[C]:R})),k=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd"]),N=(T=(a??[]).find(C=>C.agent_id===s.agentId))==null?void 0:T.definition.max_cost_usd,A=typeof N=="number"&&N>0?N:void 0,_=async C=>{C.preventDefault();const{body:R,issues:D}=kL(s,A!==void 0);if(p([]),!R){u(D??{});return}u({}),y(!0);try{m(await e.createTrigger(R,v.keyFor("createTrigger",R)))}catch(L){const O=xx(L);u(Object.fromEntries(Object.entries(O.fields).filter(([I])=>k.has(I)))),p([...O.rest,...Object.entries(O.fields).filter(([I])=>!k.has(I)).map(([,I])=>I)])}finally{y(!1)}},S=n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(h)return n.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[S,n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(Bl,{className:"size-5 text-primary-text","aria-hidden":!0}),h.name]}),n.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:h.source.kind==="webhook"&&h.source.signature==="composio"?"Register this URL as your Composio project's webhook subscription, then set the secret Composio gives you on this trigger with Set secret. Until then every request is refused; after, each Composio event starts a run.":`Send each request to this URL, signed with this secret (${Dh[h.source.kind==="webhook"?h.source.signature??"standard":"standard"]}). Each one starts a run.`}),h.signing_secret?n.jsx(Gx,{label:"The webhook's URL and secret",url:nc(h),secret:h.signing_secret}):n.jsxs("section",{"aria-label":"The webhook's URL and secret",className:"mt-4 space-y-3 border p-4 text-body",children:[n.jsx(rg,{title:"URL",text:nc(h),label:"Copy URL",hint:gx}),h.note&&n.jsx("p",{role:"note",children:h.note})]}),n.jsx("div",{className:"mt-6",children:n.jsx(K,{type:"button",size:"lg",variant:"solid",onClick:()=>t(vo(h.id)),children:"Done"})})]});const E=_f((a??[]).filter(C=>!C.archived_at));return n.jsxs("form",{onSubmit:C=>void _(C),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[S,n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(Bl,{className:"size-5 text-primary-text","aria-hidden":!0}),"New webhook"]}),n.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."}),d.length>0&&n.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:d.map((C,R)=>n.jsx("p",{children:C},R))}),n.jsxs("div",{className:"mt-5 space-y-5",children:[n.jsx(gn,{label:"Name",field:"name",issue:c.name,children:n.jsx(Be,{name:"name",value:s.name,onChange:C=>w("name")(C.target.value),placeholder:"on deploy"})}),n.jsxs("fieldset",{className:"min-w-0",children:[n.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),n.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:h8.map(C=>n.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===C?"border-primary text-primary-text":""}`,children:[n.jsx("input",{type:"radio",name:"signature",value:C,checked:s.signature===C,onChange:()=>w("signature")(C),className:"accent-primary"}),Dh[C]]},C))}),c["source.signature"]&&n.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:c["source.signature"]})]}),s.signature==="composio"&&n.jsx("p",{className:"text-small text-muted-foreground",children:"Composio makes this webhook's secret when you register the trigger's URL as your project's webhook subscription: set it on the trigger then."}),n.jsx(gn,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:n.jsx(Lt,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:C=>w("agentId")(C),options:[{value:"",label:a?"Pick an agent":"Loading the agents"},...E.map(C=>({value:C.agent_id,label:`${C.definition.name||C.agent_id}${C.kind==="workflow"?" (workflow)":""}`}))]})}),n.jsx(gn,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:n.jsx(ds,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:C=>w("content")(C.target.value)})}),n.jsx(gn,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:c["target.max_cost_usd"],hint:A!==void 0?`Uses the agent's default (${Pi(A)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:n.jsx(Be,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:C=>w("maxCost")(C.target.value),placeholder:Hx(A)})})]}),n.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[n.jsx(K,{type:"submit",size:"lg",variant:"solid",disabled:g,children:g?"Creating":"Create webhook"}),n.jsx(K,{type:"button",size:"lg",variant:"ghost",onClick:()=>t("#/triggers"),children:"Cancel"})]})]})}function x8({v2:e,go:t}){var W;const[s,r]=x.useState(null),[a,l]=x.useState(null),[c,u]=x.useState(0),[d,p]=x.useState(jL),[g,y]=x.useState(null),[h,m]=x.useState({}),[v,w]=x.useState([]),[k,N]=x.useState(!1),A=x.useRef(er()).current,_=x.useRef(!0);x.useEffect(()=>(_.current=!0,()=>{_.current=!1}),[]),x.useEffect(()=>{let U=!0;return l(null),e.githubConnection().then(J=>{U&&r(!!J&&"app_id"in J&&!!J.app_id)},J=>{U&&(J instanceof Pe&&J.status===404?r(!1):l(ln(J,"GitHub's connection")))}),()=>{U=!1}},[e,c]),x.useEffect(()=>{Bx(e).then(y,()=>y([]))},[e]);const S=U=>J=>p(F=>({...F,[U]:J})),E=U=>p(J=>({...J,events:J.events.includes(U)?J.events.filter(F=>F!==U):[...J.events,U]})),T=new Set(["name","source.accept","target.agent_id","target.input","target.max_cost_usd"]),C=(W=(g??[]).find(U=>U.agent_id===d.agentId))==null?void 0:W.definition.max_cost_usd,R=typeof C=="number"&&C>0?C:void 0,D=async U=>{U.preventDefault();const{body:J,issues:F}=NL(d,R!==void 0);if(w([]),!J){m(F??{});return}m({}),N(!0);try{const Z=await e.createTrigger(J,A.keyFor("createTrigger",J));_.current&&t(vo(Z.id))}catch(Z){const z=xx(Z);m(Object.fromEntries(Object.entries(z.fields).filter(([H])=>T.has(H)))),w([...z.rest,...Object.entries(z.fields).filter(([H])=>!T.has(H)).map(([,H])=>H)]),N(!1)}},L=n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),O=n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(gg,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(a)return n.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[L,O,n.jsx($n,{problem:a,onRetry:()=>u(U=>U+1),className:"mt-4"})]});if(s===null)return n.jsx(fs,{label:"Reading GitHub's connection",rows:3});if(!s)return n.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[L,O,n.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",n.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 I=_f((g??[]).filter(U=>!U.archived_at));return n.jsxs("form",{onSubmit:U=>void D(U),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[L,O,n.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."}),v.length>0&&n.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:v.map((U,J)=>n.jsx("p",{children:U},J))}),n.jsxs("div",{className:"mt-5 space-y-5",children:[n.jsx(gn,{label:"Name",field:"name",issue:h.name,children:n.jsx(Be,{name:"name",value:d.name,onChange:U=>S("name")(U.target.value),placeholder:"review PRs"})}),n.jsxs("fieldset",{className:"min-w-0",children:[n.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Events"}),n.jsx("div",{className:"mt-1 space-y-1",children:eS.map(({event:U,action:J,label:F})=>{const Z=`${U}:${J}`;return n.jsxs("label",{className:"flex items-center gap-2 text-body",children:[n.jsx("input",{type:"checkbox",name:"event",value:Z,checked:d.events.includes(Z),onChange:()=>E(Z),className:"accent-primary"}),F," ",n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[U," ",J]})]},Z)})}),h["source.accept"]&&n.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.accept",children:h["source.accept"]})]}),n.jsx(gn,{label:"Agent",field:"target.agent_id",issue:h["target.agent_id"],children:n.jsx(Lt,{name:"agent",label:"Agent",className:"w-full",value:d.agentId,onChange:U=>S("agentId")(U),options:[{value:"",label:g?"Pick an agent":"Loading the agents"},...I.map(U=>({value:U.agent_id,label:`${U.definition.name||U.agent_id}${U.kind==="workflow"?" (workflow)":""}`}))]})}),n.jsx(gn,{label:"Each run is asked",field:"target.input",issue:h["target.input"],hint:"The event's payload comes with it.",children:n.jsx(ds,{name:"content",rows:4,className:"p-3 font-sans",value:d.content,onChange:U=>S("content")(U.target.value)})}),n.jsx(gn,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:h["target.max_cost_usd"],hint:R!==void 0?`Uses the agent's default (${Pi(R)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:n.jsx(Be,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:d.maxCost,onChange:U=>S("maxCost")(U.target.value),placeholder:Hx(R)})})]}),n.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[n.jsx(K,{type:"submit",size:"lg",variant:"solid",disabled:k,children:k?"Creating":"Create GitHub trigger"}),n.jsx(K,{type:"button",size:"lg",variant:"ghost",onClick:()=>t("#/triggers"),children:"Cancel"})]})]})}function y8({v2:e,name:t,install:s,go:r}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[d,p]=x.useState(0);if(x.useEffect(()=>{if(s!==void 0)return;let y=!0;return u(null),e.listTemplates().then(h=>{y&&l(h.templates)},h=>{y&&u(ln(h,"the templates"))}),()=>{y=!1}},[e,d,s]),s!==void 0)return n.jsx("div",{className:"p-5 md:p-8",children:n.jsx(v8,{v2:e,source:s,go:r})});const g=t===void 0||a==null?void 0:a.find(y=>y.id===t);return n.jsx("div",{className:"p-5 md:p-8",children:c&&!a?n.jsx($n,{problem:c,onRetry:()=>p(y=>y+1),className:""}):a?t===void 0?n.jsx(b8,{v2:e,templates:a,go:r,onRemoved:()=>p(y=>y+1)}):g?n.jsx(N8,{v2:e,template:g,go:r},g.id):n.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 ",t,". ",n.jsx("a",{href:"#/templates",className:"underline",children:"See its templates"}),"."]}):n.jsx(fs,{label:"Loading the templates",rows:3})})}function _2({t:e}){var t;return e.source?n.jsxs("p",{className:"mt-1 break-all font-mono text-small text-muted-foreground","data-provenance":!0,children:[e.source," at ",(t=e.sha)==null?void 0:t.slice(0,12),", published by ",e.publisher]}):null}function b8({v2:e,templates:t,go:s,onRemoved:r}){const[a,l]=x.useState(""),[c,u]=x.useState(null),[d,p]=x.useState(null),g=async y=>{u(y.id),p(null);try{await e.deleteTemplate(y.id),r()}catch(h){p(h instanceof Error?h.message:String(h))}finally{u(null)}};return n.jsxs(n.Fragment,{children:[n.jsx("h1",{className:"mb-5 font-mono text-2xl font-semibold",children:"Templates"}),n.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:y=>{y.preventDefault(),a.trim()&&s(w8(a.trim()))},children:[n.jsxs("label",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"caps text-small font-semibold",children:"Add from URL"}),n.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."}),n.jsx(Be,{type:"text",value:a,placeholder:"github:owner/repo/templates/name@main",onChange:y=>l(y.target.value)})]}),n.jsx(K,{size:"sm",variant:"solid",type:"submit",disabled:!a.trim(),children:"Read it"})]}),d&&n.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:d}),t.length?n.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:t.map(y=>n.jsx("li",{children:n.jsxs("article",{"aria-label":sc(y),className:"flex h-full flex-col border bg-card px-5 py-4",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx(Ik,{className:"size-4 shrink-0 self-center text-muted-foreground","aria-hidden":!0}),n.jsx("h2",{className:"min-w-0 break-words text-prose font-semibold",children:sc(y)}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:y.version}),y.category&&n.jsx(Ne,{tone:"muted",children:y.category}),!y.bundled&&n.jsx(Ne,{tone:"muted",children:"Imported"})]}),n.jsx(_2,{t:y}),n.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:y.description}),y.tags.length>0&&n.jsx("p",{"aria-label":"Tags",className:"mt-1.5 break-words font-mono text-small text-muted-foreground",children:y.tags.join(" · ")}),n.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:yx(y).map(([h,m])=>n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"shrink-0",children:h}),n.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:m})]},h))}),n.jsxs("div",{className:"mt-auto flex gap-2 pt-4",children:[n.jsx(K,{size:"sm",variant:"solid",onClick:()=>s(pS(y.id)),children:"Apply"}),!y.bundled&&n.jsx(K,{size:"sm",onClick:()=>void g(y),disabled:c===y.id,children:c===y.id?"Removing…":"Remove"})]})]})},y.id))}):n.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 v8({v2:e,source:t,go:s}){var A;const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,d]=x.useState(!1),[p,g]=x.useState(!1),[y,h]=x.useState(null);x.useEffect(()=>{let _=!0;if(!t){c("Give a package's source: github:owner/repo/path@ref.");return}return e.importTemplate(t,{dryRun:!0}).then(S=>{_&&a(S)},S=>{_&&c(mk(S))}),()=>{_=!1}},[e,t]);const m=async()=>{g(!0),h(null);try{if(!r)return;const _=await e.importTemplate(`${r.template.id}@${r.template.sha}`,{trustPublisher:u});s(pS(_.template.id))}catch(_){h(mk(_))}finally{g(!1)}},v=n.jsxs("a",{href:"#/templates",className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," Templates"]});if(l)return n.jsxs("div",{className:"max-w-3xl",children:[v,n.jsx("p",{className:"border px-4 py-6 font-mono text-body text-destructive-text",role:"alert",children:l})]});if(!r)return n.jsx(fs,{label:"Reading the package from GitHub",rows:3});const w=r.template,k=w.publisher??"",N=Object.entries(r.skill_files);return n.jsxs("section",{"aria-label":"Install from GitHub",className:"max-w-3xl",children:[v,n.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[sc(w)," ",n.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:w.version})]}),n.jsxs("dl",{className:"mt-3 space-y-1 border bg-card px-4 py-3 font-mono text-small",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Publisher"}),n.jsxs("dd",{"data-publisher":!0,children:[k,r.publisher_trusted?" (trusted here)":" (new here)"]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Commit"}),n.jsx("dd",{className:"break-all","data-sha":!0,children:w.sha})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Source"}),n.jsx("dd",{className:"break-all",children:w.source})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Installs as"}),n.jsxs("dd",{className:"break-all",children:[w.id,r.replaced?`, replacing the one read at ${r.replaced.slice(0,12)}`:""]})]})]}),n.jsx("p",{className:"mt-3 text-lead leading-[1.6]",children:w.description}),n.jsx(Ys,{title:"What it makes",children:n.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:yx(w,{mcp:!1}).map(([_,S])=>n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"shrink-0 text-muted-foreground",children:_}),n.jsx("dd",{className:"min-w-0 break-words",children:S})]},_))})}),w.mcp.length>0&&n.jsx(Ys,{title:"MCP tools it asks for",note:"None is granted by installing: the Apply screen asks you to tick each one.",children:w.mcp.map(_=>n.jsxs("div",{"data-mcp":_.toolkit,className:"px-4 py-3",children:[n.jsx($2,{m:_}),n.jsx("p",{className:"mt-1 break-words font-mono text-small",children:_.tools.map(S=>S.name).join(", ")})]},_.toolkit))}),n.jsx(E2,{t:w}),n.jsx(C2,{t:w}),n.jsx(Ys,{title:"Instructions",note:"What the agent is told, in full: a package from someone else says this to your agent.",children:n.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})}),((A=w.output)==null?void 0:A.json_schema)&&n.jsx(Ys,{title:"Output schema",note:`What the agent is told to answer in (${w.output.schema}), in full: its descriptions are instructions too.`,children:n.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(w.output.json_schema,null,2)})}),N.length>0&&n.jsx(Ys,{title:"Skill files",note:"Every file the agent is given, in full.",children:N.map(([_,S])=>n.jsxs("details",{className:"px-4 py-2","data-skill-file":_,children:[n.jsx("summary",{className:"cursor-pointer font-mono text-body",children:_}),n.jsx("pre",{className:"mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:S})]},_))}),!r.publisher_trusted&&n.jsxs("label",{className:"mt-6 flex items-start gap-2.5 border border-warning/50 px-4 py-3",children:[n.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:u,onChange:_=>d(_.target.checked)}),n.jsxs("span",{children:[n.jsxs("span",{className:"font-mono text-body",children:["I trust ",k]}),n.jsxs("span",{className:"block text-small text-muted-foreground",children:["This server has no package from ",k," yet. Ticked, it remembers that you trust them."]})]})]}),n.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[n.jsx(K,{size:"sm",variant:"solid",onClick:()=>void m(),disabled:p||!r.publisher_trusted&&!u,children:p?"Installing…":"Install"}),n.jsx("span",{className:"text-small text-muted-foreground",children:"Installing stores it; nothing runs and nothing is granted until you apply it."}),y&&n.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:y})]})]})}function mk(e){var t;return e instanceof Pe&&((t=e.fields)!=null&&t.length)?[...new Set([e.message,...e.fields.map(s=>s.message)])].join(" "):e instanceof Error?e.message:String(e)}const w8=e=>`#/templates/install?src=${encodeURIComponent(e)}`,k8=3e3;function j8(e,t){let s;const r=new Promise(a=>s=setTimeout(()=>a(void 0),t));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function N8({v2:e,template:t,go:s}){var ue;const r={fields:wx(t.parameters)??[]},[a,l]=x.useState(()=>({...Object.fromEntries(r.fields.filter(([,Q])=>Q.type==="boolean"&&!Q.array).map(([Q])=>[Q,"false"])),...kx(r)})),[c,u]=x.useState(new Set),[d,p]=x.useState(t.approvals_default??"ask"),[g,y]=x.useState(null),[h,m]=x.useState(null),[v,w]=x.useState(0),[k,N]=x.useState({}),[A,_]=x.useState(!1),[S,E]=x.useState([]),[T,C]=x.useState(null),[R,D]=x.useState(null),[L,O]=x.useState([]),[I,W]=x.useState({}),U=x.useRef(er()).current,J=x.useRef(!0);x.useEffect(()=>(J.current=!0,()=>{J.current=!1}),[]),x.useEffect(()=>{let Q=!0;return m(null),e.listMcpServers().then(fe=>{Q&&y(fe.servers)},fe=>{Q&&m(ln(fe,"the saved MCP servers"))}),()=>{Q=!1}},[e,v]);const F=DL(t,c),Z=t.mcp.map(Q=>{const fe=g?IL(Q,g):[];return{m:Q,matches:fe,uses:fe.length===1?fe[0]:fe.includes(k[Q.toolkit]??"")?k[Q.toolkit]:void 0}}),z=Object.fromEntries(Z.flatMap(({m:Q,uses:fe})=>fe?[[Q.toolkit,fe]]:[])),H=Z.filter(({matches:Q,uses:fe})=>Q.length>1&&!fe).map(({m:Q})=>Q.toolkit),V=t.mcp.length>0&&g===null,P=Q=>FL(S,Q),B=(Q,fe,ye)=>{l(Ee=>({...Ee,[Q]:ye})),vx(fe,ye)&&E(Ee=>Ee.filter(ge=>Xd(ge.field,"parameters")!==Q))},q=async()=>{var ye,Ee;_(!0),E([]),C(null);const Q=a,fe={parameters:Mf(r,Q),...F.length?{grants:F}:{},...Object.keys(z).length?{servers:z}:{},overrides:{approvals:d}};try{const ge=await e.applyTemplate(t.id,fe,U.keyFor(t.id,fe));U.done();const se=async()=>(await Promise.all(ge.trigger_ids.map(_e=>j8(e.getTrigger(_e),k8).catch(()=>null)))).filter(_e=>_e!=null&&hx(_e));if(ge.warnings.length||(ye=ge.webhook_secrets)!=null&&ye.length){W(Q),D(ge),se().then(O,()=>{});return}const pe=ge.trigger_ids.length?await se():[];if(!J.current)return;if(!pe.length){s(`#/agents/${encodeURIComponent(ge.agent_id)}`);return}W(Q),O(pe),D(ge)}catch(ge){ge instanceof Pe&&((Ee=ge.fields)!=null&&Ee.length)?(E(ge.fields),C({text:ge.message,withIssues:!0}),ge.fields.some(se=>se.field.startsWith("servers.")||se.field.startsWith("mcp."))&&w(se=>se+1)):C({text:ge instanceof Error?ge.message:String(ge),withIssues:!1})}finally{_(!1)}},ce=r.fields,de=Q=>/^(parameters|secrets|mcp|servers)\./.test(Q.field)||/^grants\.\d+$/.test(Q.field);return R?n.jsxs("section",{"aria-label":"Applied",className:"max-w-3xl",children:[n.jsxs("h1",{className:"mb-4 flex items-center gap-2 font-mono text-2xl font-semibold",children:[n.jsx(uc,{className:"size-5 text-success-text","aria-hidden":!0})," ",sc(t,I)," applied"]}),R.warnings.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"mb-3 text-lead",children:"The agent is made. The server says:"}),n.jsx("ul",{className:"mb-5 space-y-2 border bg-card px-4 py-3 text-body",role:"status","aria-label":"Warnings",children:R.warnings.map((Q,fe)=>{var se,pe;const ye=/^triggers\.(\d+)\.secret$/.exec(Q.field),Ee=ye?R.trigger_ids[Number(ye[1])]:void 0,ge=ye?(se=t.triggers[Number(ye[1])])==null?void 0:se.name:void 0;return Ee&&((pe=R.webhook_secrets)!=null&&pe.some(Y=>Y.trigger_id===Ee))?n.jsxs("li",{children:[n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Q.field})," ",Q.message]},`${Q.field}:${fe}`):n.jsxs("li",{children:[n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Q.field})," ",Q.message,Q.fix?n.jsx("span",{className:"block text-muted-foreground",children:Q.fix}):null,Ee&&n.jsxs("a",{href:`#/triggers/${encodeURIComponent(Ee)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof ge=="string"&&ge?ge:Ee," to get its signing secret (Rotate)"]})]},`${Q.field}:${fe}`)})})]}),(ue=R.webhook_secrets)==null?void 0:ue.map(Q=>{var ge;const fe=R.trigger_ids.indexOf(Q.trigger_id),ye=fe>=0?(ge=t.triggers[fe])==null?void 0:ge.name:void 0,Ee=typeof ye=="string"&&ye?ye:Q.trigger_id;return Q.signing_secret?n.jsx(Gx,{label:`The webhook's URL and secret (${Ee})`,url:nc({id:Q.trigger_id}),secret:Q.signing_secret},Q.trigger_id):n.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[Q.note&&n.jsx("p",{className:"text-muted-foreground",role:"note",children:Q.note}),n.jsxs("a",{href:`#/triggers/${encodeURIComponent(Q.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",Ee," to get its signing secret (Rotate)"]})]},Q.trigger_id)}),L.length>0&&n.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:L.map(Q=>n.jsxs("li",{"data-trigger":Q.id,className:"px-4 py-3",children:[n.jsx("a",{href:`#/triggers/${encodeURIComponent(Q.id)}`,className:"break-words text-prose font-semibold hover:underline",children:Q.name}),n.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:mx(Q.source,Q.next_at)})]},Q.id))}),n.jsx("div",{className:"mt-5"}),n.jsx("a",{href:`#/agents/${encodeURIComponent(R.agent_id)}`,className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):n.jsxs("div",{className:"max-w-3xl",children:[n.jsxs("a",{href:"#/templates",className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[n.jsx(Es,{className:"size-3.5","aria-hidden":!0})," Templates"]}),n.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[sc(t,a)," ",n.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:t.version})]}),n.jsx(_2,{t}),n.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:t.description}),ce.length>0&&n.jsx(Ys,{title:"Parameters",children:ce.map(([Q,fe])=>n.jsxs("div",{"data-field":`parameters.${Q}`,className:"px-4 py-3",children:[n.jsx(Nx,{field:fe,label:Ec(Q,fe),help:rc(fe),value:a[Q]??"",onChange:ye=>B(Q,fe,ye)}),n.jsx(Zo,{issues:S.filter(ye=>Xd(ye.field,"parameters")===Q),words:ye=>jx(ye,Q,fe)})]},Q))}),t.mcp.length>0&&n.jsxs(Ys,{title:"Tools you allow",note:"Nothing is granted until you tick it. 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:[h&&!g&&n.jsx("div",{"data-servers-unread":!0,className:"px-4 py-3",children:n.jsx($n,{problem:h,onRetry:()=>w(Q=>Q+1),className:""})}),Z.map(({m:Q,matches:fe,uses:ye})=>n.jsxs("div",{"data-mcp":Q.toolkit,className:"px-4 py-3",children:[n.jsx($2,{m:Q,children:g&&fe.length<2&&n.jsx("span",{className:"text-small text-muted-foreground",children:ye?`Uses ${ye}`:"Not set up here"})}),g&&fe.length>1&&n.jsxs("label",{className:"mt-2 flex flex-wrap items-center gap-2 text-small text-muted-foreground",children:["Uses",n.jsx(Lt,{small:!0,label:`Server for ${Q.toolkit}`,value:ye??"",placeholder:"Pick one",onChange:Ee=>N(ge=>({...ge,[Q.toolkit]:Ee})),options:fe.map(Ee=>({value:Ee,label:Ee}))}),!ye&&n.jsxs("span",{"data-unpicked":Q.toolkit,children:[fe.length," saved servers are ",Sc[Q.source]," ",Q.toolkit,": pick the one the agent uses."]})]}),g&&fe.length===0&&n.jsxs("p",{role:"status","data-missing-mcp":Q.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[Q.required?`${Q.toolkit} is required and not set up here: Apply is refused until it is.`:`${Q.toolkit} is not set up here: Apply makes the agent without its tools (${Q.tools.map(Ee=>Ee.name).join(", ")}).`," ",n.jsx("a",{href:zL(Q),className:"font-mono text-primary-text underline-offset-2 hover:underline",children:Q.source==="github"?"Set up GitHub App access":Q.source==="composio"?`Add ${Q.toolkit} from Composio`:`Set up ${Q.toolkit}`})]}),n.jsx(Zo,{issues:[...P(`mcp.${Q.toolkit}`),...P(`servers.${Q.toolkit}`)]}),n.jsx("ul",{className:"mt-2 space-y-2",children:Q.tools.map(Ee=>{const ge=F.indexOf(Ee.tool);return n.jsxs("li",{"data-tool":Ee.tool,children:[n.jsxs("label",{className:"flex items-start gap-2.5",children:[n.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:c.has(Ee.tool),onChange:()=>u(se=>{const pe=new Set(se);return pe.has(Ee.tool)?pe.delete(Ee.tool):pe.add(Ee.tool),pe})}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"font-mono text-body",children:Ee.name})," ",n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ee.tool}),n.jsx("span",{className:"block text-small",children:"Allow: the agent may call this without asking you."}),n.jsx("span",{className:"block text-small text-muted-foreground",children:Ee.asks==="allow"?"The template asks you to allow this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),ge>=0&&n.jsx(Zo,{issues:P(`grants.${ge}`)})]},Ee.tool)})})]},Q.toolkit))]}),t.secrets.length>0&&n.jsx(Ys,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:t.secrets.map(Q=>n.jsxs("div",{"data-secret":Q,className:"px-4 py-3 font-mono text-body",children:[Q,n.jsx(Zo,{issues:P(`secrets.${Q}`)})]},Q))}),n.jsxs("fieldset",{"aria-label":"Approvals",className:"mt-6",children:[n.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),n.jsx("div",{className:"mt-2 divide-y border",children:[["ask","Ask me","A call whose permission is ask waits for your answer."],["never","Never ask (run unattended)","For an agent that runs on its triggers, with no one there to answer."]].map(([Q,fe,ye])=>n.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[n.jsx("input",{type:"radio",name:"approvals",value:Q,className:"mt-1 accent-primary",checked:d===Q,onChange:()=>p(Q)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono text-body",children:fe}),n.jsx("span",{className:"block text-small text-muted-foreground",children:ye})]})]},Q))}),d==="never"&&n.jsx("p",{className:"mt-2 text-small text-warning-text",children:c2})]}),n.jsx(E2,{t}),n.jsx(C2,{t}),n.jsx(Ys,{title:"What it makes",children:n.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:yx(t,{secrets:!1,mcp:!1}).map(([Q,fe])=>n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"shrink-0 text-muted-foreground",children:Q}),n.jsx("dd",{className:"min-w-0 break-words",children:fe})]},Q))})}),n.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[n.jsx(K,{size:"sm",variant:"solid",onClick:()=>void q(),disabled:A||V||H.length>0,title:V?h?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":H.length?`Pick the server for ${H.join(", ")} first`:void 0,children:A?"Applying…":"Apply"}),T&&(!T.withIssues||S.length>0)&&n.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:T.text})]}),S.filter(Q=>!de(Q)).length>0&&n.jsx("div",{className:"mt-2",children:n.jsx(Zo,{issues:S.filter(Q=>!de(Q)),named:!0})})]})}function $2({m:e,children:t}){return n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[n.jsx("span",{className:"font-semibold",children:e.toolkit}),n.jsx(Ne,{tone:"muted",children:Sc[e.source]}),n.jsx(Ne,{tone:e.required?"plain":"muted",children:e.required?"Required":"Optional"}),t]}),e.reason&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground","data-reason":!0,children:e.reason})]})}function E2({t:e}){if(!e.input_schema)return null;const t=wx(e.input_schema,"content");return t&&!t.length?null:n.jsx(Ys,{title:"Run inputs",note:"What each run is given, as the run form asks for it.",children:t?t.map(([s,r])=>n.jsxs("div",{"data-input":s,className:"px-4 py-3",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[n.jsx("span",{className:"font-semibold",children:Ec(s,r)}),r.title&&n.jsx("span",{className:"text-small text-muted-foreground",children:s}),n.jsx(Ne,{tone:"muted",children:QL(r)}),n.jsx(Ne,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),rc(r)&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:rc(r)})]},s)):n.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 C2({t:e}){const t=e.evals.length;return n.jsx(Ys,{title:"Eval cases",note:t?`The ${t===1?"one case":`${t} cases`} this template is tested on.`:void 0,children:n.jsx("p",{className:"break-words px-4 py-3 font-mono text-small","data-evals":!0,children:t?e.evals.join(", "):"None: this package ships no eval cases, so nothing tests it."})})}function Ys({title:e,note:t,children:s}){return n.jsxs("section",{"aria-label":e,className:"mt-6",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:e}),t&&n.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:t}),n.jsx("div",{className:"mt-2 divide-y border",children:s})]})}const T2="tool_approval_requested";function S8(e){var t;return e.status!=="input_required"||e.state!=="waiting"?null:((t=e.pending)==null?void 0:t.kind)==="approval"?e.pending:null}function _8(e){return e==="not metered"?"Not metered":e===0?"Costs nothing per call":typeof e=="number"?`Costs ${wo(e)} per call`:null}function $8(e){let t;try{t=JSON.parse(e)}catch{return e}return!t||typeof t!="object"||Array.isArray(t)?JSON.stringify(t,null,2):Object.entries(t).map(([s,r])=>`${s}: ${typeof r=="string"?r:JSON.stringify(r)}`).join(`
559
+ `)}const E8={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 R2(e){var t;if(e instanceof Pe){const s=((t=e.details)==null?void 0:t.reason)==="already_answered"&&typeof e.details.decision=="string"?E8[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 tn(e)}const C8=2e3;function A2({pending:e,onAnswer:t,compact:s=!1,heading:r}){const[a,l]=x.useState(""),[c,u]=x.useState(!1),[d,p]=x.useState(null),[g,y]=x.useState(null),[h,m]=x.useState(!1),v=e.destructive===!0,w=x.useRef(!1),k=x.useRef(null),N=x.useRef(!1);x.useEffect(()=>{var S;h||!N.current||(N.current=!1,(S=k.current)==null||S.focus())},[h]);const A=_8(e.price),_=async(S,E)=>{if(w.current)return;w.current=!0,u(!0),p(null),m(!1);const T=a.trim(),C=await(E?t(S,void 0,E):t(S,S==="deny"&&T?T:void 0));w.current=!1,u(!1),C?p(C):y(S)};return n.jsxs("section",{"aria-label":"Approval required",className:ie("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,n.jsxs("p",{className:ie("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[n.jsx(Fk,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),n.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",n.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),".",v&&n.jsxs(n.Fragment,{children:[" ",n.jsx(Ne,{tone:"error",title:"Its server marks this tool destructive: it may delete or overwrite.",children:"Destructive"})]})]}),n.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:ie("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:$8(e.args_preview)}),A&&n.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:A}),g?n.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."}):n.jsxs("div",{className:"mt-3 space-y-2",children:[n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),n.jsx(ds,{value:a,onChange:S=>l(S.target.value),maxLength:C8,rows:s?1:2,disabled:c,className:"mt-1 block resize-y py-2 font-sans text-lead"})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(K,{ref:k,type:"button",variant:"solid",size:"sm",disabled:c||h,onClick:()=>v?m(!0):void _("allow"),children:"Allow once"}),n.jsx(K,{type:"button",size:"sm",disabled:c,onClick:()=>void _("deny"),children:"Deny"}),c&&n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),h&&n.jsx(T8,{tool:e.tool,onAllow:()=>void _("allow",!0),onBack:()=>{N.current=!0,m(!1)}}),!s&&n.jsx("p",{className:"text-small text-muted-foreground",children:"or type what to do instead; sending it declines this call"}),d&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:d})]})]})}function T8({tool:e,onAllow:t,onBack:s}){const r=x.useRef(null);return x.useEffect(()=>{var a;(a=r.current)==null||a.focus()},[]),n.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e}?`,onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),s())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Allow a destructive call?"})," Its server marks ",n.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite."]}),n.jsx(K,{ref:r,type:"button",size:"sm",variant:"ghost",onClick:s,children:"Back"}),n.jsx(K,{type:"button",size:"sm",variant:"destructive",onClick:t,children:"Allow this destructive call"})]})}const R8={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 A8({mode:e,onSend:t,sending:s,sent:r,purpose:a}){const l=a??R8[e],[c,u]=x.useState(""),[d,p]=x.useState(!1),g=s||d,y=async()=>{if(!c.trim()||!t||g)return;p(!0);const h=await t(c.trim());p(!1),h!==!1&&u("")};return n.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:h=>{h.preventDefault(),y()},children:[n.jsx(ds,{bare:!0,id:"composer",rows:2,value:c,readOnly:g,"aria-busy":g,onChange:h=>u(h.target.value),placeholder:l.placeholder,onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),y())},className:"block w-full resize-none px-4 pt-3"}),n.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[n.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[n.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:l.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":l.does]}),n.jsxs(K,{type:"submit",size:"sm",disabled:!c.trim()||!t||g,children:[g?"Sending":"Send"," ",n.jsx(nE,{"aria-hidden":!0})]})]})]})}let pi=0;const og=()=>{var t;const e=(t=history.state)==null?void 0:t.console_at;return typeof e=="number"?e:void 0},pk=e=>{pi=e,history.replaceState({...history.state??{},console_at:e},"")};function O8(){const e=og();e===void 0?pk(0):pi=e;const t=()=>{const s=og();s===void 0?pk(pi+1):pi=s};return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function M8(){const e=og();return e===void 0?-1:pi-e}function L8(e){pi>0?history.back():location.hash=e}const P8=(e,t)=>{const s=Oi(e);return s?YO(s,{ended:t}):e&&e.usd!==null&&J1(e)?"A local estimate, not a bill":void 0};function I8({run:e,agentName:t,actions:s={},costText:r}){var w,k;const a=uz(e.place),l=jc(e.status,e.state,e.kind,kc,!0,e.error,e.review,e.computer),[c,u]=x.useState(!1),d=!!e.archived_at,p=(w=e.cost)==null?void 0:w.cap_usd,g=!!e.pending&&e.pending.kind!=="budget",y=!!s.onRaiseCap&&!l.final&&typeof p=="number"&&!g,[h,m]=x.useState(!1),v=((k=e.pending)==null?void 0:k.kind)==="budget"?e.pending:null;return n.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[n.jsxs("nav",{className:"caps flex min-w-0 items-center gap-2 text-label text-muted-foreground","aria-label":"Breadcrumb",children:[n.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>L8(Qs(e.agent_id)),className:"-m-1 shrink-0 p-1 hover:text-foreground",children:n.jsx(Es,{className:"size-3.5","aria-hidden":!0})}),n.jsx("a",{href:Qs(e.agent_id),className:"truncate hover:text-foreground hover:underline",children:t}),n.jsx("span",{"aria-hidden":!0,children:"/"}),n.jsxs("span",{className:"truncate",children:["Run ",Co(e.run_id)]})]}),n.jsxs("div",{"data-phone-row":!0,className:"mt-3 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:[n.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[n.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:xn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?t:xn(e)}),n.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:[n.jsx(Nc,{run:e}),d&&n.jsx(Ne,{tone:"muted",children:"Archived"}),e.approvals==="never"&&n.jsx(Ne,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),n.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,a&&` · ${a}`]}),n.jsx("span",{className:"font-mono",children:ht(e.created_at)}),r!==void 0?n.jsx("span",{className:"font-mono",title:"The run's decisions and model calls, as the providers priced them",children:$w(e.cost,p,{text:r})}):n.jsx("span",{className:"font-mono",title:P8(e.cost,pa(e.status)),children:$w(e.cost,p,{ended:pa(e.status)})}),n.jsx(Af,{run:e,link:!0}),n.jsx(y2,{run:e})]}),e.status==="completed"&&e.review&&n.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(l.canStop||l.canCancel||s.onArchive||y)&&n.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[y&&n.jsxs(K,{size:"sm",onClick:()=>m(N=>!N),"aria-expanded":h,title:`Raise its ${ur(p)} spend cap.`,children:[n.jsx(pg,{"aria-hidden":!0})," Raise the cap"]}),l.canStop&&n.jsxs(K,{size:"sm",onClick:s.onStop,disabled:!s.onStop||!!s.busy,title:"End this turn. The run stays open and waits for your next message.",children:[n.jsx(jE,{"aria-hidden":!0})," ",s.busy==="stop"?"Stopping":"Stop"]}),l.canCancel&&!c&&n.jsxs(K,{size:"sm",variant:"destructive",onClick:()=>u(!0),disabled:!s.onCancel||!!s.busy,title:"End the run for good.",children:[n.jsx(Ak,{"aria-hidden":!0})," ",s.busy==="cancel"?"Cancelling":"Cancel run"]}),c&&n.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:[n.jsx("span",{children:"Cancel for good?"}),n.jsx(K,{size:"sm",variant:"destructive",onClick:()=>{var N;u(!1),(N=s.onCancel)==null||N.call(s)},children:"Yes, cancel"}),n.jsx(K,{size:"sm",variant:"ghost",onClick:()=>u(!1),children:"Keep"})]}),s.onArchive&&n.jsxs(K,{size:"sm",onClick:s.onArchive,disabled:!!s.busy,title:d?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[d?n.jsx(Rk,{"aria-hidden":!0}):n.jsx(cc,{"aria-hidden":!0})," ",s.busy==="archive"?d?"Unarchiving":"Archiving":d?"Unarchive":"Archive"]})]})]}),y&&h&&n.jsx("div",{className:"mt-3 max-w-xl",children:n.jsx(TS,{cap:p,suggested:ES(v),least:CS(v),paused:!!v,onRaise:s.onRaiseCap},v?`${e.run_id}:${v.at}`:`${e.run_id}:working`)})]})}const z8=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function D8({view:e,onView:t}){return n.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:z8.map(s=>n.jsxs("label",{className:ie("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:[n.jsx("input",{type:"radio",name:"file-view",value:s.id,checked:e===s.id,onChange:()=>t(s.id),className:"sr-only"}),s.label]},s.id))})}const O2=(e,t)=>t?e:e.filter(s=>!mN(s.path));function F8({files:e,onOpen:t,showHidden:s,onShowHidden:r}){const a=e.filter(u=>mN(u.path)).length,l=O2(e,s),c=l.reduce((u,d)=>u+d.size_bytes,0);return n.jsxs("section",{children:[n.jsxs("div",{className:"mb-2 flex items-center gap-3",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[n.jsx(oE,{className:"size-3.5","aria-hidden":!0})," Files · ",l.length," ",l.length===1?"file":"files"," (",wi(c),")"]}),a>0&&n.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"," ",a," hidden"]})]}),l.length===0?n.jsx("p",{className:"border px-4 py-8 text-center font-mono text-body text-muted-foreground",children:a?`Only files in hidden folders (${a}).`:"This run wrote no files."}):n.jsx("ul",{className:"border",children:l.map(u=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("button",{type:"button",onClick:()=>t(u),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-accent",children:[n.jsx(Si,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:u.path}),n.jsx("span",{className:"hidden font-mono text-label text-muted-foreground sm:inline",children:ht(u.modified_at)}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:wi(u.size_bytes)})]})},u.path))})]})}function U8({file:e,text:t,onClose:s,files:r=[],onOpen:a}){const[l,c]=x.useState(!1),u=x.useRef(null);x.useEffect(()=>{var N;const w=document.activeElement,k=u.current;return k&&!k.open&&((N=k.showModal)==null||N.call(k)),()=>{var A;k!=null&&k.open&&k.close(),(A=w==null?void 0:w.focus)==null||A.call(w)}},[]),x.useEffect(()=>c(!1),[e.path]);const d=x.useRef(!1),p=x.useRef(!1),g=E4(e),[y,h]=x.useState(g==="markdown"?"rendered":"raw");x.useEffect(()=>h(g==="markdown"?"rendered":"raw"),[e.path]);const m=Xg(w=>{const k=r.find(N=>N.path===w);k&&(a==null||a(k))}),v=()=>{if(t===null)return;const w=URL.createObjectURL(new Blob([t],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:w,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(w)};return n.jsx("dialog",{ref:u,"aria-label":e.path,onCancel:w=>{w.preventDefault(),s()},onMouseDown:w=>{d.current=w.target===w.currentTarget},onMouseUp:w=>{p.current=w.target===w.currentTarget},onClick:w=>{d.current&&p.current&&w.target===w.currentTarget&&s(),d.current=p.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:n.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[n.jsx(K,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:n.jsx(fc,{"aria-hidden":!0})}),n.jsx(Si,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:e.path}),g!=="download"&&n.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:n.jsx(D8,{view:y,onView:h})}),n.jsxs(K,{size:"sm",disabled:t===null,onClick:async()=>{var w;t!==null&&(await((w=navigator.clipboard)==null?void 0:w.writeText(t)),c(!0))},children:[n.jsx(lf,{"aria-hidden":!0})," ",l?"Copied":"Copy"]}),n.jsxs(K,{size:"sm",disabled:t===null,onClick:v,children:[n.jsx(sE,{"aria-hidden":!0})," Download"]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:t===null?n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):g==="download"?n.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"?n.jsx("article",{className:"report mx-auto max-w-3xl",onClick:m,dangerouslySetInnerHTML:{__html:Lr(t,a&&{paths:r.map(w=>w.path),from:e.path.split("/").slice(0,-1).join("/")})}}):n.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:t})}),n.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",t===null?"...":`${t.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function W8(e){const t=e.replace(/\r\n?/g,`
560
+ `).trim(),s=c=>{try{const u=JSON.parse(c);return u&&typeof u=="object"&&!Array.isArray(u)?u:null}catch{return null}},r=t.split(`
561
+ `);let a;for(let c=0;c<r.length;c++){const u=/^ {0,3}(`{3,}|~{3,})([^`]*)$/.exec(r[c]);if(!u)continue;const d=u[1],p=new RegExp(`^ {0,3}${d[0]==="`"?"`":"~"}{${d.length},}\\s*$`),g=r.findIndex((h,m)=>m>c&&p.test(h));if(g<0)break;const y=u[2].trim().toLowerCase();a=y==="json"||y===""?{open:c,end:g}:void 0,c=g}if(a&&a.end===r.length-1){const c=s(r.slice(a.open+1,a.end).join(`
562
+ `));return c?{words:r.slice(0,a.open).join(`
563
+ `).trim(),record:c}:null}const l=s(t);if(l)return{words:"",record:l};for(let c=t.lastIndexOf(`
564
+ {`);c>=0;c=t.lastIndexOf(`
565
+ {`,c-1)){const u=s(t.slice(c+1));if(u)return{words:t.slice(0,c).trim(),record:u};if(c===0)break}return null}const H8=e=>e.replace(/[_-]+/g," ").trim()||e,Tl=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function sf(e,t){let s=Tl(e);for(let r=0;s&&typeof s.$ref=="string"&&s.$ref.startsWith("#")&&r<8;r++){const a=s.$ref.slice(1).split("/").filter(Boolean).map(p=>decodeURIComponent(p).replaceAll("~1","/").replaceAll("~0","~")),{$ref:l,...c}=s,u=Tl(a.reduce((p,g)=>{var y;return(y=Tl(p))==null?void 0:y[g]},t))??{},d=u.properties||c.properties?{...Tl(u.properties),...Tl(c.properties)}:void 0;s={...u,...c,...d?{properties:d}:{}}}return s}const B8=(e,t)=>{var s;return((s=sf(e,t))==null?void 0:s.contentMediaType)==="text/markdown"};function qx({value:e,schema:t,root:s,linked:r}){var a;if(e==null)return n.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"—"});if(Array.isArray(e)){if(!e.length)return n.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"none"});const l=(a=sf(t,s))==null?void 0:a.items;return n.jsx("ul",{"data-json":"array",className:"list-disc space-y-1 pl-5",children:e.map((c,u)=>n.jsx("li",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:n.jsx(qx,{value:c,schema:l,root:s,linked:r})},u))})}return typeof e=="object"?n.jsx(M2,{record:e,schema:t,root:s,linked:r}):typeof e=="string"&&B8(t,s)?n.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:Lr(e,r)}}):n.jsx("span",{"data-json-value":!0,className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:String(e)})}function M2({record:e,schema:t,root:s,linked:r}){var l;const a=(l=sf(t,s))==null?void 0:l.properties;return n.jsx("dl",{"data-json":"object",className:"min-w-0 space-y-3 border-l pl-4",children:Object.entries(e).map(([c,u])=>{var g;const d=a==null?void 0:a[c],p=(g=sf(d,s))==null?void 0:g.title;return n.jsxs("div",{className:"min-w-0",children:[n.jsx("dt",{className:"caps break-words [overflow-wrap:anywhere] text-label text-muted-foreground",children:typeof p=="string"&&p.trim()?p:H8(c)}),n.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:n.jsx(qx,{value:u,schema:d,root:s,linked:r})})]},c)})})}function hk({record:e,schema:t,linked:s}){const[r,a]=x.useState(!1);return n.jsxs("section",{className:"min-w-0 space-y-3",children:[n.jsx("div",{className:"flex justify-end",children:n.jsx(K,{type:"button",size:"xs",onClick:()=>a(l=>!l),children:r?"Show fields":"Show raw JSON"})}),r?n.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)}):n.jsx("div",{"aria-label":"The answer's fields",className:"min-w-0 [&>dl]:border-l-0 [&>dl]:pl-0",children:n.jsx(M2,{record:e,schema:t,root:t,linked:s})})]})}function G8({value:e,schema:t,linked:s}){return n.jsx("div",{"aria-label":"The answer's value",className:"min-w-0 text-prose leading-relaxed",children:n.jsx(qx,{value:e,schema:t,root:t,linked:s})})}function q8({run:e,rows:t,files:s=[],onOpen:r,schema:a}){var y,h,m,v,w;const l=((y=e.result)==null?void 0:y.final_answer)??((h=t.findLast(k=>k.kind==="final_answer"))==null?void 0:h.text)??null,c=r?{paths:s.map(k=>k.path)}:void 0,u=Xg(k=>{const N=s.find(A=>A.path===k);N&&(r==null||r(N))}),d=(m=e.result)==null?void 0:m.output;if(e.kind==="agentic"&&d!==void 0&&d!==null)return n.jsx("div",{className:"min-w-0",onClick:u,children:typeof d=="object"&&!Array.isArray(d)?n.jsx(hk,{record:d,schema:a,linked:c}):n.jsx(G8,{value:d,schema:a,linked:c})});const p=e.kind==="agentic"?(v=e.result)==null?void 0:v.output_error:void 0,g=p?n.jsx(_n,{tone:"warning",title:"The answer did not match the output schema",children:p}):null;if(l!=null&&l.trim()){const k=W8(l);return k?n.jsxs("div",{className:"min-w-0 space-y-6",children:[g,k.words&&n.jsx("article",{className:"report max-w-none",onClick:u,dangerouslySetInnerHTML:{__html:Lr(k.words,c)}}),n.jsx(hk,{record:k.record})]}):n.jsxs("div",{className:"min-w-0 space-y-6",children:[g,n.jsx("article",{className:"report max-w-none",onClick:u,dangerouslySetInnerHTML:{__html:Lr(l,c)}})]})}if(g)return g;if(((w=e.result)==null?void 0:w.output)!==void 0&&e.result.output!==null){const k=e.result.output,N=k&&typeof k=="object"&&!Array.isArray(k)?Object.entries(k).filter(_=>typeof _[1]=="string"&&_[1].includes(`
566
+ `)&&_[1].length>80):[],A=N.length?Object.fromEntries(Object.entries(k).filter(([_])=>!N.some(([S])=>S===_))):k;return n.jsxs("div",{className:"space-y-8",children:[N.map(([_,S])=>n.jsxs("section",{children:[n.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:_.replace(/_/g," ")}),n.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:u,dangerouslySetInnerHTML:{__html:Lr(S,c)}})]},_)),(!N.length||Object.keys(A).length>0)&&n.jsxs("section",{children:[n.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:N.length?"The rest of the output":"Output"}),n.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(A,null,2)})]})]})}return null}const gk=32,V8=360,K8=.7;function Y8(e,t){const s=e.getBoundingClientRect().top;if(!t)return window.innerHeight-(s+window.scrollY)-gk;const r=s-t.getBoundingClientRect().top+t.scrollTop;return t.clientHeight-r-gk}const X8=(e,t)=>Math.round(Math.max(V8,Math.min(e,t*K8)));function Q8(e,t,s=3e3,r=Math.min(s,J8),a=!1){const[l,c]=x.useState(null),[u,d]=x.useState(!1),p=x.useRef(e);p.current=e;const g=x.useRef(!1),y=x.useRef(!1),h=x.useRef(0),m=x.useRef(null),v=x.useRef(null);x.useEffect(()=>{a&&(v.current=null)},[a]);const w=!!e;x.useEffect(()=>{if(!w||u)return;if(t||(v.current=null),!t&&g.current&&!y.current){c(T=>T&&xk(T));return}let N=!0,A;const _=T=>{clearTimeout(A),A=setTimeout(()=>{m.current=null,E()},T),m.current=()=>_(r)};let S=!1;const E=async()=>{try{const T=await p.current();if(!N)return;g.current=!0,T.state==="live"&&(v.current=T.kind);const C=T.state==="none"&&T.session==="opening"&&T.kind!=="browser"&&T.kind===v.current?{...T,session:"closed"}:T;y.current=C.state==="none"&&C.session==="unopened",S=C.state==="none"&&C.session==="opening"||C.state==="live"&&C.hold==="pending",C.state==="off"?c(null):c(t?R=>eF(R,C)?R:C:xk(C))}catch(T){if(!N)return;if(T instanceof Pe&&T.status===401){d(!0),c(C=>C?{state:"signed_out"}:null);return}if(T instanceof Pe&&T.status===403){d(!0),c(null);return}}N&&t&&_(S||Date.now()<h.current?r:s)};return E(),()=>{N=!1,clearTimeout(A),m.current=null}},[w,t,s,r,u]);const k=x.useCallback(N=>{var A;c(_=>_&&_.state==="live"&&_.hold!==N?{..._,hold:N}:_),h.current=Date.now()+Z8,(A=m.current)==null||A.call(m)},[]);return{view:l,held:k}}const J8=400,Z8=4e3,eF=(e,t)=>{var s,r;return!!e&&e.state!=="signed_out"&&e.state===t.state&&e.kind===t.kind&&e.hold===t.hold&&(e.state!=="live"||t.state==="live"&&e.viewer===t.viewer)&&(e.state!=="none"||t.state==="none"&&e.session===t.session&&((s=e.ended)==null?void 0:s.at)===((r=t.ended)==null?void 0:r.at))},xk=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"},tF={browser:Pk,desktop:wa,phone:Uk,sandbox:Wk},nF={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},sF={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function rF({runId:e,screen:t,machine:s,opens:r,followUp:a,metered:l,onTake:c,onHand:u}){const d=x.useRef({viewer:"",n:0});(t==null?void 0:t.state)==="live"&&t.viewer!==d.current.viewer&&(d.current={viewer:t.viewer,n:d.current.n+1});const p=t&&t.state!=="signed_out"?t.kind:(s==null?void 0:s.kind)??"browser",g=(t==null?void 0:t.state)==="live"?iF(t.viewer,e):void 0,y=g&&p!=="browser"?`${g}${g.includes("#")?"&":"#"}hands=page`:g,h=tF[p],m=(t==null?void 0:t.state)==="live"?t:null,[v,w]=x.useState(!1),[k,N]=x.useState(null),A=async F=>{if(!(!F||v)){w(!0),N(null);try{N(await F())}finally{w(!1)}}},_=m&&y&&p!=="browser"?m:null,[S,E]=x.useState(!1),T=x.useRef(null),C=x.useRef(null),R=x.useRef(null),D=x.useRef(!1),L=!!(m&&y);x.useEffect(()=>{L||E(!1)},[L]);const[O,I]=x.useState(void 0);x.useLayoutEffect(()=>{const F=T.current;if(p!=="phone"||S||!L||!F)return;const Z=F.closest("[data-scroll-pane]"),z=()=>I(X8(Y8(F,Z),window.innerHeight));z();const H=typeof ResizeObserver=="function"&&Z?new ResizeObserver(z):void 0;if(Z)for(const V of[Z,...Z.children])H==null||H.observe(V);return window.addEventListener("resize",z),()=>{H==null||H.disconnect(),window.removeEventListener("resize",z)}},[p,S,L,k,l,d.current.n]),x.useEffect(()=>{var F,Z,z;if(S){D.current=!0,(Z=(F=C.current)==null?void 0:F.querySelector("button"))==null||Z.focus();return}D.current&&(D.current=!1,(z=R.current)==null||z.focus())},[S]),x.useEffect(()=>{if(!S)return;const F=P=>{if(P.key==="Escape"){E(!1);return}if(P.key!=="Tab"||!C.current)return;const B=[...C.current.querySelectorAll("button:not([disabled]), iframe")];if(!B.length)return;const q=B[0],ce=B[B.length-1],de=document.activeElement;C.current.contains(de)?P.shiftKey&&de===q?(P.preventDefault(),ce.focus()):!P.shiftKey&&de===ce&&(P.preventDefault(),q.focus()):(P.preventDefault(),q.focus())},Z=P=>{P.key==="Escape"&&E(!1)};document.addEventListener("keydown",F);const z=T.current;let H=null;const V=()=>{try{H==null||H.removeEventListener("keydown",Z,!0)}catch{}try{H=(z==null?void 0:z.contentWindow)??null,H==null||H.addEventListener("keydown",Z,!0)}catch{H=null}};return V(),z==null||z.addEventListener("load",V),()=>{document.removeEventListener("keydown",F),z==null||z.removeEventListener("load",V);try{H==null||H.removeEventListener("keydown",Z,!0)}catch{}}},[S,d.current.n]);const W=m?p==="browser"?"browser · take over in the view below":`${sF[m.hold]} · ${p}`:"",U=_&&(_.hold==="person"?n.jsx(K,{size:"sm",variant:"solid",disabled:v,onClick:()=>void A(u),children:"Hand back"}):n.jsx(K,{size:"sm",variant:"solid",disabled:v||_.hold==="pending",onClick:()=>void A(c),children:_.hold==="pending"?"Taking over":"Take over"})),J=L&&n.jsx(K,{ref:S?void 0:R,size:"sm",variant:"ghost",onClick:()=>E(F=>!F),"aria-label":S?"Exit full window (Esc)":"Fill the window",title:S?"Exit full window (Esc)":"Fill the window","aria-pressed":S,children:S?n.jsx(hE,{className:"size-4","aria-hidden":!0}):n.jsx(fE,{className:"size-4","aria-hidden":!0})});return n.jsxs("section",{"aria-label":"Screen",className:"border",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[n.jsx(h,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"caps text-small font-semibold",children:m?"Live":nF[p]}),n.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:W}),!S&&U,!S&&J]}),l&&p!=="browser"&&n.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:Dx}),!S&&k&&n.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:k}),m&&y?n.jsxs("div",{ref:C,"data-testid":"screen-frame",className:S?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:S?"dialog":void 0,"aria-modal":S?!0:void 0,"aria-label":S?"The run's screen, filling the window":void 0,children:[S&&n.jsxs("div",{className:"flex items-center gap-3 border-b bg-background px-4 py-2 text-foreground",children:[n.jsx("span",{className:"flex-1 font-mono text-small",children:W}),U,J]}),S&&k&&n.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:k}),n.jsx("iframe",{ref:T,src:y,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:S?"block min-h-0 w-full flex-1 bg-background":p==="phone"?ie("mx-auto block aspect-[9/19] max-w-full bg-background",O===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!S&&p==="phone"&&O!==void 0?{height:`${O}px`}:void 0},d.current.n)]}):n.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:oF(p,t,s,r,a)})]})}function oF(e,t,s,r,a){if((t==null?void 0:t.state)==="live")return"The live view can't be shown here.";if((t==null?void 0:t.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&&(t==null?void 0:t.state)==="none"&&t.ended)return`${t.ended.why} (${aF(t.ended.at)}). A new browser opens when the run goes on.`;const l=(t==null?void 0:t.state)==="none"?t.session:void 0;return l==="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}.${a?" A follow-up opens one if the agent needs it.":""}`:r&&l==="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.${a?" A follow-up opens a new one if the agent needs it.":""}`}function aF(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`at ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function iF(e,t){let s;try{s=new URL(e,location.origin).href}catch{return}const r=aa(s);if(!r)return;const a=new URL(r);return a.origin===location.origin&&a.pathname.startsWith(`/v2/runs/${encodeURIComponent(t)}/computer/live/`)?r:void 0}const ri=e=>{var t,s;return e.status==="input_required"&&(((t=e.pending)==null?void 0:t.kind)==="browser"||((s=e.pending)==null?void 0:s.kind)==="computer")?e.pending:null},L2=e=>e.kind==="computer"?e.computer:"browser";function ag(e,t){var s;if(e instanceof Pe&&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 Pe&&e.code==="computer_not_live"?e.message:e instanceof Pe&&e.status===404?t==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof Pe&&e.status===403?"Sign in with your password to do this from here.":`${t==="hand"?"Not answered":"Not taken"}: ${tn(e)}`}function P2({ask:e,onAnswer:t,open:s,heading:r,compact:a=!1}){const[l,c]=x.useState(!1),[u,d]=x.useState(null),p=x.useRef(!1),g=async y=>{if(!t||p.current)return;p.current=!0,c(!0),d(null);let h=!1;try{const m=await t(y);h=m===null,d(m)}finally{h||(p.current=!1,c(!1))}};return n.jsxs("section",{"aria-label":"Waiting for you at the computer",className:a?"px-4 py-3":"border border-warning/50 bg-warning/5 p-4",children:[r,n.jsxs("p",{className:ie("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[n.jsx(wa,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",L2(e)]}),n.jsxs("div",{"data-agent-request":!0,className:ie("border-l-2 border-warning/60 pl-3",a?"mt-1":"mt-2"),children:[n.jsxs("p",{className:a?"text-prose leading-snug":"text-prose leading-relaxed",children:["The agent asks you to: ",e.instruction]}),n.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["Done when: ",e.completion_condition]})]}),n.jsx("p",{className:"mt-2 text-small font-semibold",children:"You never need to type your AgentRun password for this."}),n.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:["Expires ",ht(e.expires_at)," unanswered"]}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s,n.jsx("span",{className:"flex-1"}),t&&n.jsxs(n.Fragment,{children:[n.jsx(K,{size:"sm",variant:"solid",disabled:l,onClick:()=>void g("done"),children:"Done"}),n.jsx(K,{size:"sm",variant:"ghost",disabled:l,onClick:()=>void g("cancelled"),children:"Cancel"})]})]}),u&&n.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:u})]})}function lF(e,t){const s=!!t&&Jl(e.learning).length>0,[r,a]=x.useState({state:"reading"}),[l,c]=x.useState(0);return x.useEffect(()=>{if(!s)return;let u=!0;return a({state:"reading"}),Promise.resolve().then(()=>t()).then(d=>{u&&a({state:"read",changes:_5(d,e.learning)})},d=>{u&&a({state:"failed",error:d??new Error("unknown")})}),()=>{u=!1}},[e.run_id,s,l]),s?{got:r,retry:()=>c(u=>u+1)}:null}function cF({got:e,retry:t}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?ln(e.error,"what it changed"):null;return n.jsxs("section",{className:"border","aria-label":"What it changed",children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What it changed"}),e.state==="reading"&&n.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:"Reading what it changed…"}),s&&n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 text-body",role:"alert",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't read what it changed: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)]}),n.jsx(K,{type:"button",onClick:t,size:"sm",children:"Try again"})]}),e.state==="read"&&n.jsx("ul",{className:"divide-y",children:e.changes.map(r=>n.jsx("li",{children:n.jsx(uF,{change:r})},r.file))})]})}function uF({change:e}){const[t,s]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-4 py-3 text-left hover:bg-accent/40","aria-expanded":t,onClick:()=>s(r=>!r),children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block break-words text-lead","data-said":!0,children:e.said}),n.jsx("span",{className:"mt-0.5 block break-all font-mono text-label text-muted-foreground",children:e.file})]}),n.jsx(cs,{className:ie("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",t&&"rotate-90"),"aria-hidden":!0})]}),t&&(e.withheld?n.jsx("p",{className:"px-4 pb-3 text-body text-muted-foreground",children:e.withheld}):n.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2",children:[n.jsx(yk,{name:"before",lines:e.before,none:"Not there before."}),n.jsx(yk,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function yk({name:e,lines:t,none:s}){return n.jsxs("div",{className:"min-w-0 border","data-side":e,children:[n.jsx("p",{className:"caps border-b px-3 py-2 text-label text-muted-foreground",children:e==="before"?"Before":"After"}),t===null?n.jsx("p",{className:"px-3 py-2 text-body text-muted-foreground",children:s}):n.jsx("pre",{className:"max-h-80 overflow-auto py-2 font-mono text-small leading-[1.7]",children:t.map((r,a)=>n.jsxs("span",{className:ie("flex min-h-[1.7em] px-3",r.mark==="added"&&"bg-primary/10",r.mark==="removed"&&"bg-destructive/10"),children:[n.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"&&n.jsx("span",{className:"sr-only",children:"Added line: "}),r.mark==="removed"&&n.jsx("span",{className:"sr-only",children:"Taken out: "}),n.jsx("span",{"data-mark":r.mark,className:ie("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},a))})]})}function dF(e,t,s){const r=!!s&&!!e.learning,[a,l]=x.useState(null);return x.useEffect(()=>{if(!r)return;let c=!0;return Promise.resolve().then(()=>s()).then(u=>{c&&l((u==null?void 0:u.used)??null)},()=>{c&&l(null)}),()=>{c=!1}},[e.run_id,r,t]),r?a:null}const fF=e=>e===1?"once":e===2?"twice":`${e} times`;function mF({used:e,agentId:t}){return!e||!e.skills.length&&!e.workflows.length?null:n.jsxs("section",{className:"border","aria-label":"What it used of what it learned",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-3",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:"What it used of what it learned"}),n.jsx("span",{className:"flex-1"}),n.jsx("a",{href:Rf(t),className:"font-mono text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:"Open the Learning tab"})]}),n.jsxs("ul",{className:"divide-y",children:[e.skills.map(s=>n.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[n.jsx(jd,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Skill"}),n.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),s.read?n.jsx(Ne,{tone:"success",children:"Read"}):n.jsx(Ne,{tone:"muted",children:"Given, not read"})]},`skill:${s.name}`)),e.workflows.map(s=>n.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[n.jsx(ka,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Workflow"}),n.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Called ",fF(s.calls)]}),s.failed>0&&n.jsxs(Ne,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const pF={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."},hF={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 gF(e,t){var r,a;if(e.status==="input_required"&&((r=e.pending)==null?void 0:r.kind)==="budget"){const{cap_usd:l,spent_usd:c}=e.pending,u=typeof l=="number"&&Number.isFinite(l);return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${ur(c)} of its ${ur(l)} cap.`:u?`Its ${ur(l)} cap is reached.`:"Its spend cap is reached."} Raise the cap above to continue.`,spin:!1}}if(e.status==="input_required"&&((a=e.pending)==null?void 0:a.kind)==="approval")return{title:"Waiting for your approval",note:`The run continues once you answer the approval above${t.canMessage?", or send a message below to decline it":""}.`,spin:!1};const s=ri(e);return s?{title:`Waiting for you at the ${L2(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:t.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.${t.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:t.live}}function xF({run:e,agentName:t,messages:s,harnessSteers:r,rows:a,files:l,outputSchema:c,readFile:u,openFile:d=null,actions:p,onMessage:g,onApprove:y,tab:h,graphView:m,costText:v,readLearningDiff:w,readLearning:k,readComputer:N,computerEvery:A,onTakeOver:_,onHandBack:S,readComputers:E}){var rt,yn,Dt,sn,me;const T=((rt=e.pending)==null?void 0:rt.kind)==="budget"?e.pending:null,C=ri(e),R=C?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,D=jc(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),L=T?{...D,canMessage:!1,messageMode:null}:C?{...D,canMessage:R!==null,messageMode:R}:D,O=m?"graph":L.final&&e.status==="completed"?"report":"timeline",[I,W]=x.useState(h??O),U=I==="graph"&&!m?O:I,[J,F]=x.useState(!1),[Z,z]=x.useState(d?{file:d,text:null}:null),H=S8(e),V=H||C?null:$4(e.status,e.state,a),P=H?a.findLast(Te=>Te.kind===T2&&Te.tool_use_id===H.call_id):void 0,[B,q]=x.useState(null),ce=async(Te,tt,Fe,lt)=>{const Ke=y?await(lt?y(Te,tt,Fe,lt):y(Te,tt,Fe)):"This page can't answer an approval.";return q(Ke?{id:Te,text:Ke}:null),Ke},de=x.useRef(zd()).current,ue=async Te=>{const tt=de.begin();if(z({file:Te,text:null}),!u)return;const Fe=await u(Te);de.current(tt)&&z({file:Te,text:Fe})},Q=()=>{de.cancel(),z(null)},fe=lF(e,w),ye=dF(e,L.final,k),Ee=L.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",{view:ge,held:se}=Q8(N,!L.final,A,void 0,e.status==="queued"),pe=e.computer,Y=!!ge||!!pe||!!C,_e=x.useRef(!1);x.useEffect(()=>{if(Y){_e.current=!0;return}_e.current&&U==="screen"&&W(O),_e.current=!1},[Y,U,O]);const[Ze,Je]=x.useState(!1);x.useEffect(()=>{if(!pe||!Fx.has(pe.kind)||!E)return;let Te=!0;return E().then(tt=>{var Fe,lt;Te&&Je(!!((lt=(Fe=tt.kinds.find(Ke=>Ke.kind===pe.kind))==null?void 0:Fe.providers.find(Ke=>Ke.id===pe.provider))!=null&&lt.metered))}).catch(()=>{}),()=>{Te=!1}},[pe==null?void 0:pe.kind,pe==null?void 0:pe.provider]);const xt=C?`${C.kind}:${C.asked_at}`:null,et=x.useRef(null);x.useEffect(()=>{!xt||et.current===xt||!Y||(et.current=xt,W("screen"))},[xt,Y]);const ae=async()=>{if(!_)return"This page can't take the computer over.";try{return se((await _()).hold),null}catch(Te){return ag(Te,"take")}},Ae=async Te=>{if(!S)return"This page can't hand the computer back.";try{return se((await S(Te)).hold),null}catch(tt){return ag(tt,"hand")}},[Ce,Ge]=x.useState(null),kt=async Te=>{const tt=(C==null?void 0:C.asked_at)??"",Fe=await Ae(Te);return Ge(Fe?{at:tt,text:Fe}:null),Fe};x.useEffect(()=>{d&&u&&ue(d)},[d]);const We=[...m?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],["files",`Files ${O2(l,J).length}`],...Y?[["screen","Screen"]]:[]];return n.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[n.jsx(I8,{run:e,agentName:t,actions:p,costText:v}),n.jsx(yN,{tabs:We.map(([Te,tt])=>({id:Te,label:tt})),value:U,onChange:W}),U==="graph"?n.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:m}):n.jsx("div",{"data-scroll-pane":!0,className:"min-h-0 flex-1 overflow-auto short:flex-none short:overflow-visible",children:n.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-5 py-8 md:px-8",children:[e.status==="failed"&&e.error&&n.jsx(_a,{error:e.error,title:PN(e.status,e.error)?"The run escalated":void 0}),e.status==="cancelled"&&n.jsxs("section",{className:"border border-border-strong/60 p-4",children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Cancelled"}),n.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&&n.jsxs("section",{className:"border border-warning/50 bg-warning/10 p-4","aria-label":"Needs review",children:[n.jsx("p",{className:"caps text-label text-warning-text",children:"Needs review"}),n.jsx("p",{className:"mt-2 text-lead",children:e.review.reason}),n.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."]})]}),B&&B.id!==(H==null?void 0:H.id)&&n.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: ",B.text]}),Ce&&Ce.at!==(C==null?void 0:C.asked_at)&&n.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: ",Ce.text]}),H?n.jsx(A2,{pending:H,onAnswer:(Te,tt,Fe)=>Fe?ce(H.id,Te,tt,Fe):ce(H.id,Te,tt)},H.id):C?n.jsx(P2,{ask:C,onAnswer:S?kt:void 0,open:U!=="screen"?n.jsx(K,{size:"sm",variant:"primary",onClick:()=>W("screen"),children:"Open the screen"}):null},xt):L.needsYou&&(T?n.jsx(gP,{pending:T}):n.jsx(yP,{waiting:V})),L.needsYou&&T&&typeof T.cap_usd=="number"&&(p==null?void 0:p.onRaiseCap)&&n.jsx(TS,{cap:T.cap_usd,suggested:ES(T),least:CS(T),paused:!0,onRaise:p.onRaiseCap},`${e.run_id}:${T.at}`),U==="report"&&n.jsx(q8,{run:e,rows:a,files:l,onOpen:ue,schema:c}),U==="report"&&!e.result&&!L.final&&n.jsx(zh,{...gF(e,L)}),U==="report"&&L.final&&!((Dt=(yn=e.result)==null?void 0:yn.final_answer)!=null&&Dt.trim())&&!((sn=e.result)!=null&&sn.output)&&!a.some(Te=>{var tt;return Te.kind==="final_answer"&&((tt=Te.text)==null?void 0:tt.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&n.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[pN,L.canMessage?" Send a follow-up below to ask for one.":""]}),U==="timeline"&&n.jsx(qN,{rows:LN(a,e.learning),live:L.live,ended:pa(e.status),asking:(P==null?void 0:P.id)??(L.needsYou&&!T?V==null?void 0:V.id:void 0),waitingOn:e.status==="input_required"?(me=e.pending)==null?void 0:me.kind:void 0,files:l,onOpen:ue}),(U==="report"||U==="timeline")&&n.jsx(mF,{used:ye,agentId:e.agent_id}),(U==="report"||U==="timeline")&&fe&&n.jsx(cF,{got:fe.got,retry:fe.retry}),U==="files"&&n.jsx(F8,{files:l,onOpen:ue,showHidden:J,onShowHidden:F}),U==="screen"&&Y&&n.jsx(rF,{runId:e.run_id,screen:ge,machine:pe,opens:Ee,followUp:L.canMessage&&L.messageMode==="follow_up",metered:Ze,onTake:_?ae:void 0,onHand:S?()=>Ae():void 0})]})}),L.canMessage&&n.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:n.jsx("div",{className:"mx-auto max-w-4xl",children:n.jsx(A8,{mode:L.messageMode,onSend:g,purpose:H?pF:C&&R?hF[R]:void 0})})}),Z&&n.jsx(U8,{file:Z.file,text:Z.text,onClose:Q,files:l,onOpen:ue})]})}const I2=new Set(["chain","parallel","route","map","loop","workflow"]),yF={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},bF=e=>e==="review"?"needs review":e.replace("-"," ");function Vx({state:e}){const t=Id(e)??"pending";return n.jsx(Ne,{tone:yF[t]??"plain",className:"whitespace-nowrap",children:bF(t)})}function Kx({provider:e}){if(!e)return null;const t=e==="parallel"?"--wf-parallel":e==="openrouter"?"--wf-openrouter":"--wf-jev";return n.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${t}))`,borderColor:`hsl(var(${t}) / .6)`,background:`hsl(var(${t}) / .12)`},children:e})}const z2={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},Yx=(e,t)=>e&&t?Date.parse(t)-Date.parse(e):void 0;function vF({data:e,selected:t,onSelect:s,onClose:r,fileUrl:a}){var k,N,A,_,S,E;const l=e.graph.nodes.find(T=>T.path===t.path),[c,u]=x.useState(null);if(!l)return null;const d=e.nodes[l.path],p=tx(e.workflow,l.path,l),g=l.kind==="map"?l.path:(k=e.graph.nodes.find(T=>T.kind==="map"&&l.path.startsWith(`${T.path}/body/`)))==null?void 0:k.path,y=t.item!=null&&g?(A=(N=e.nodes[g])==null?void 0:N.items)==null?void 0:A.find(T=>T.index===t.item):void 0,h=e.decisions.filter(T=>T.node===l.path),m=e.effects.filter(T=>T.node===l.path),v=!!g&&l.kind!=="map",w=Yx(d==null?void 0:d.startedAt,d==null?void 0:d.endedAt);return n.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[n.jsxs("header",{className:"border-b px-5 py-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[p.decision?l.kind:dx(l.kind,d),p.tool?` · ${U2(p.tool)}`:l.via?` · ${l.via}`:"",p.tool&&_c(p.tool)&&n.jsx(W2,{}),y&&n.jsxs(n.Fragment,{children:[n.jsx(cs,{className:"size-3","aria-hidden":!0})," item ",y.index+1]})]}),n.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:y?Ql(e,g,y.index)??`Item ${y.index+1}`:l.label}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n.jsx(Vx,{state:y?y.status:d==null?void 0:d.status}),y&&(()=>{const T=nx(e,g,y);return T.outcome?n.jsxs("span",{className:"font-mono text-label",title:T.pNote,children:["outcome ",n.jsx("b",{className:z2[T.tone??""],children:T.outcome}),T.p!==void 0&&n.jsxs("span",{className:"text-muted-foreground",children:[" · ",Ts(T.p)]})]}):null})(),p.decision&&n.jsx(Kx,{provider:p.provider}),p.decision&&((d==null?void 0:d.model)??p.model)&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(d==null?void 0:d.model)??p.model}),(d==null?void 0:d.branch)&&n.jsxs("span",{className:"font-mono text-label",children:["took ",n.jsx("b",{children:d.branch})]}),!y&&w!==void 0&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ui(w)})]})]}),n.jsx(K,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:n.jsx(fc,{"aria-hidden":!0})})]}),y&&n.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=(_=e.nodes[g])==null?void 0:_.items)==null?void 0:S.length," items of ",(E=e.graph.nodes.find(T=>T.path===g))==null?void 0:E.label]})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[y?n.jsx(NF,{data:e,mapPath:g,index:y.index,status:y.status,fileUrl:a,zoom:u}):l.kind==="map"?n.jsx(wF,{data:e,mapPath:l.path,onSelect:s}):v&&(h.length||m.length)?n.jsx(kF,{data:e,path:l.path,mapPath:g,onSelect:s}):n.jsxs(n.Fragment,{children:[l.kind==="parallel"&&n.jsx(jF,{data:e,path:l.path,onSelect:s}),h.map((T,C)=>n.jsx(F2,{d:T,fileUrl:a,zoom:u},T.id??C)),m.map((T,C)=>n.jsx(H2,{e:T,fileUrl:a,zoom:u},C)),!h.length&&!m.length&&l.kind!=="parallel"&&n.jsx(D2,{kind:l.kind,status:d==null?void 0:d.status,meta:p})]}),n.jsx(CF,{workflow:e.workflow,path:l.path,kind:l.kind})]}),c&&n.jsx(TF,{src:c,onClose:()=>u(null)})]})}function D2({kind:e,status:t,meta:s}){const r=s.decision?t==="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.":I2.has(e)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return n.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:r})}function wF({data:e,mapPath:t,onSelect:s}){var l;const r=((l=e.nodes[t])==null?void 0:l.items)??[],a=dN(r);return n.jsxs("section",{children:[n.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",a.total],["Done",a.done],["Working",a.working],["Review",a.review],["Failed",a.failed]].map(([c,u])=>n.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[n.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),n.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:u})]},c))}),n.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),n.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),n.jsx("tbody",{children:r.map(c=>{const u=e.decisions.filter(g=>{var y;return g.item===c.index&&!!((y=g.node)!=null&&y.startsWith(`${t}/body`))}),d=nx(e,t,c),p=u.length?u.some(g=>g.cost_usd===null)?null:u.reduce((g,y)=>g+(y.cost_usd??0),0):void 0;return n.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:t,item:c.index}),children:[n.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),n.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Ql(e,t,c.index),children:Ql(e,t,c.index)??"—"}),n.jsx("td",{className:"border-b py-1.5 pr-2",children:n.jsx(Vx,{state:c.status})}),n.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[d.pNote,...u.map(g=>ki(g))].filter(Boolean).join(", "),children:d.outcome?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:ie("font-semibold",z2[d.tone??""]),children:d.outcome}),d.p!==void 0&&n.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:Ts(d.p)})]}):u.map(g=>ki(g)).filter(Boolean).join(", ")||n.jsx("span",{className:"text-muted-foreground",children:"—"})}),n.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:p===void 0?n.jsx("span",{className:"text-muted-foreground",children:"—"}):Mi(p)})]},c.index)})})]})]})}function kF({data:e,path:t,mapPath:s,onSelect:r}){var g;const a=e.decisions.filter(y=>y.node===t),l=e.effects.filter(y=>y.node===t),c=(((g=e.nodes[s])==null?void 0:g.items)??[]).map(y=>({it:y,d:a.find(h=>h.item===y.index),e:l.find(h=>h.item===y.index)})).filter(y=>y.d||y.e),u=a.filter(y=>y.cost_usd!==null),d=a.filter(y=>y.latency_ms!==null),p=d.length?d.reduce((y,h)=>y+(h.latency_ms??0),0)/d.length:void 0;return n.jsxs("section",{children:[a.length>0&&n.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[a.length," asked · ",Mi(u.reduce((y,h)=>y+(h.cost_usd??0),0)),u.length<a.length?` + ${a.length-u.length} unknown`:""," · mean ",ui(p)]}),n.jsx("table",{className:"w-full border-collapse font-mono text-small",children:n.jsx("tbody",{children:c.map(({it:y,d:h,e:m})=>n.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:y.index}),children:[n.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:y.index+1}),n.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Ql(e,s,y.index)}),n.jsx("td",{className:"border-b py-1.5 pr-2",children:h?ki(h):m?n.jsx(Vx,{state:m.status}):null}),n.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:h?ui(h.latency_ms):m?ui(Yx(m.startedAt,m.endedAt)):""})]},y.index))})})]})}function jF({data:e,path:t,onSelect:s}){var h,m;const r=`${t}/branches/`,a=e.decisions.filter(v=>{var w;return((w=v.node)==null?void 0:w.startsWith(r))&&/^\d+$/.test(v.node.slice(r.length))&&v.item===null}),l=new Set(a.flatMap(v=>Object.keys(v.answers??{}))),[c]=[...l],u=a.map(v=>{var w;return{d:v,a:(w=v.answers)==null?void 0:w[c]}}).filter(v=>{var w;return((w=v.a)==null?void 0:w.type)==="noul"});if(l.size!==1||u.length<2)return n.jsx(D2,{kind:"parallel",meta:{decision:!1}});const d=u.map(v=>v.a.noul),p=d.reduce((v,w)=>v+w,0)/d.length,g=Math.max(...d)-Math.min(...d),y=v=>{var w;return((w=e.graph.nodes.find(k=>k.path===v.node))==null?void 0:w.label)??v.node};return n.jsxs("section",{className:"border bg-card",children:[n.jsxs("header",{className:"border-b px-4 py-2.5",children:[n.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",u.length," models · ",c]}),n.jsx("p",{className:"mt-1 text-body leading-snug",children:((m=(h=a[0].questions)==null?void 0:h[c])==null?void 0:m.instructions)??c})]}),n.jsx("ul",{className:"divide-y",children:u.map(({d:v,a:w})=>n.jsx("li",{children:n.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:v.node,item:null}),children:[n.jsx("span",{className:"w-[92px] shrink-0",children:n.jsx(Kx,{provider:v.provider})}),n.jsx("span",{className:"w-[132px] shrink-0 truncate",title:v.model??"",children:v.model??y(v)}),n.jsx(ig,{p:w.noul,strong:!0,tick:.5,tone:w.noul>=.5?"fg":"muted"}),n.jsx("span",{className:"w-10 text-right tabular-nums",children:Ts(w.noul)})]})},v.id??v.executionPath))}),n.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),n.jsx("dd",{className:"font-semibold tabular-nums",children:Ts(p)})]}),n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),n.jsx("dd",{className:ie("font-semibold tabular-nums",g>.3&&"text-warning-text"),children:Ts(g)})]}),n.jsxs("div",{className:"px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),n.jsx("dd",{className:"tabular-nums",children:Mi(u.some(v=>v.d.cost_usd===null)?null:u.reduce((v,w)=>v+(w.d.cost_usd??0),0))})]})]})]})}function NF({data:e,mapPath:t,index:s,status:r,fileUrl:a,zoom:l}){const u=e.graph.nodes.filter(d=>d.path.startsWith(`${t}/body`)).map(d=>({n:d,ds:e.decisions.filter(p=>p.node===d.path&&p.item===s),es:e.effects.filter(p=>p.node===d.path&&p.item===s)})).filter(d=>!I2.has(d.n.kind)||d.ds.length||d.es.length);return r==="pending"?n.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."}):n.jsxs("div",{className:"space-y-5",children:[u.map(({n:d,ds:p,es:g})=>p.length||g.length?n.jsxs("div",{className:"space-y-3",children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:d.label}),g.map((y,h)=>n.jsx(H2,{e:y,fileUrl:a,zoom:l,compact:!0},h)),p.map((y,h)=>n.jsx(F2,{d:y,fileUrl:a,zoom:l},y.id??h))]},d.path):null),r==="working"&&!u.some(d=>d.ds.length)&&n.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 bk=e=>`${Math.round(e*100)}%`,Ts=e=>e.toFixed(2);function ig({p:e,strong:t,tick:s,tone:r="fg"}){const a={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[r];return n.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[n.jsx("span",{className:ie("absolute inset-y-0 left-0 transition-[width] duration-slow",t?a:"bg-muted-foreground/45"),style:{width:bk(Math.max(0,Math.min(1,e)))}}),s!==void 0&&n.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:bk(s)},title:`threshold ${Ts(s)}`})]})}function SF({id:e,q:t,a:s,rule:r}){const a=u=>{var d;return(r==null?void 0:r.kind)==="pick"&&(t==null?void 0:t.type)==="choice"&&typeof((d=t.criteria)==null?void 0:d[u])=="string"?t.criteria[u]:u},l=(t==null?void 0:t.instructions)??e,c=(r==null?void 0:r.kind)==="route"?r.unsure:null;return n.jsxs("div",{className:"py-2.5",children:[n.jsxs("p",{className:"mb-2 text-body leading-snug",children:[n.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:e}),l]}),s?s.type==="refusal"?n.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):s.type==="noul"?n.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[n.jsx("span",{className:ie("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),n.jsx(ig,{p:s.noul,strong:!0,tick:.5,tone:s.noul>=.5?"fg":"muted"}),n.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",Ts(s.noul)]})]}):s.type==="box"?n.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(s.box)]}):n.jsxs("div",{className:"space-y-1.5",children:[Object.entries(s.probabilities).sort((u,d)=>d[1]-u[1]).slice(0,(r==null?void 0:r.kind)==="pick"?5:void 0).map(([u,d])=>{const p=(s.type==="choice"?s.choice:String(s.score))===u;return n.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[n.jsx("span",{className:ie("truncate",(r==null?void 0:r.kind)==="pick"?"w-48":"w-28",p?"font-semibold":"text-muted-foreground"),title:a(u),children:s.type==="score"?`${u} ${s.legend[u]??""}`:a(u)}),n.jsx(ig,{p:d,strong:p,tick:p&&c?c.gte:void 0}),n.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:Ts(d)})]},u)}),(r==null?void 0:r.kind)==="pick"&&Object.keys(s.probabilities).length>5&&n.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(s.probabilities).length-5," more options, each less likely"]})]}):n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function _F(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 ${Ts(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) ≥ ${Ts(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${Ts(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function $F(e){var s,r,a,l;const t=e.action;if(t==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=((a=(r=e.answers)==null?void 0:r.branch)==null?void 0:a.type)==="choice"?e.answers.branch.confidence:void 0;return t.unsure?`Took "${String(t.taken)}": "${String(t.branch)}" at ${c!==void 0?Ts(c):"?"} is below the threshold.`:`Took "${String(t.taken??t.branch)}".`}if(((l=e.rule)==null?void 0:l.kind)==="pick"&&typeof t.index=="number"){const c=e.rule.options[t.index];return t.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${c!==void 0?`"${cN(e,Object.keys(e.questions??{})[0]??"pick",c)}"`:`option ${t.index}`}.`}return typeof t=="object"?Object.entries(t).map(([c,u])=>`${c} = ${typeof u=="object"?JSON.stringify(u):String(u)}`).join(" · "):String(t)}function F2({d:e,fileUrl:t,zoom:s}){var l,c,u;const r=Array.from(new Set([...Object.keys(e.questions??{}),...Object.keys(e.answers??{})])),a=e.status==="answered"?"success":e.status==="cancelled"?"warning":"error";return n.jsxs("section",{className:"border bg-card",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[n.jsx(Kx,{provider:e.provider}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),n.jsx(Ne,{tone:a,children:e.status==="cancelled"?"outcome unknown":e.status})]}),n.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((l=e.rule)==null?void 0:l.kind)!=="route"?"Least sure answer":"Verdict"}),n.jsx("dd",{className:"break-words font-semibold",children:ki(e)??"—"})]}),n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),n.jsx("dd",{className:"tabular-nums",title:e.cost_basis??void 0,children:Mi(e.cost_usd)})]}),n.jsxs("div",{className:"px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),n.jsx("dd",{className:"tabular-nums",children:ui(e.latency_ms)})]})]}),e.error&&n.jsx("p",{className:ie("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)&&n.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:e.images.map(d=>({img:d,src:d.ref&&t(d.ref)||aa(d.url)})).filter(({src:d})=>d).map(({img:d,src:p})=>n.jsxs("figure",{className:"flex gap-3",children:[n.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>s(p),"aria-label":`Open ${d.ref}`,children:n.jsx("img",{src:p,alt:`The page the model saw as ${d.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),n.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[n.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),n.jsxs("p",{children:[n.jsx("span",{className:"text-muted-foreground",children:"token "}),d.token]}),n.jsxs("p",{className:"break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:"page "}),d.ref]}),d.sha256&&n.jsxs("p",{className:"break-all",title:d.sha256,children:[n.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),d.sha256.slice(0,16),"…"]}),(d.mime||d.bytes)&&n.jsx("p",{className:"text-muted-foreground",children:[d.mime,d.bytes?`${Math.round(d.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},d.token))}),n.jsx("div",{className:"divide-y px-4",children:r.map(d=>{var p,g;return n.jsx(SF,{id:d,q:(p=e.questions)==null?void 0:p[d],a:(g=e.answers)==null?void 0:g[d],rule:e.rule},d)})}),n.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[n.jsxs("div",{className:"flex gap-3",children:[n.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),n.jsx("dd",{children:_F(e.rule)})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),n.jsx("dd",{className:"font-mono text-small",children:$F(e)})]})]}),!!((u=e.evidence)!=null&&u.length)&&n.jsx(EF,{evidence:e.evidence}),e.state!=null&&n.jsxs("details",{className:"group border-t",children:[n.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:[n.jsx(cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",e.state_truncated?" (cut at 64 KB)":""]}),n.jsx(rf,{value:e.state})]})]})}function EF({evidence:e}){return n.jsxs("section",{className:"border-t px-4 py-3",children:[n.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",e.length]}),n.jsx("ol",{className:"space-y-3",children:e.map((t,s)=>{let r=t.url;try{r=new URL(t.url).host}catch{}const a=aa(t.url);return n.jsxs("li",{className:"flex gap-3",children:[n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:s+1}),n.jsxs("div",{className:"min-w-0 flex-1",children:[a?n.jsxs("a",{href:a,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[t.title??r,n.jsx(rE,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):n.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:t.title??r}),n.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[r,t.scope&&n.jsx("span",{className:"border px-1",children:t.scope})]}),t.excerpts.slice(0,2).map((l,c)=>n.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:l},c))]})]},s)})})]})}const U2=e=>{const t=_c(e);return t?`${t.tool} on ${t.server}`:e},W2=()=>n.jsx(Ne,{tone:"muted",title:"An MCP server's tool",children:n.jsx("span",{"data-mcp":!0,children:"MCP"})});function H2({e,fileUrl:t,zoom:s,compact:r=!1}){var g;const a=e.output,l=a!=null,c=a&&typeof a=="object"?a:null,u=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),d=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),p=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return n.jsxs("section",{className:"border bg-card",children:[n.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[n.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"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:U2(e.tool)}),_c(e.tool)&&n.jsx(W2,{}),n.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?ui(Yx(e.startedAt,e.endedAt)):""}),n.jsx(Ne,{tone:p,children:e.status})]}),n.jsxs("div",{className:"space-y-3 px-4 py-3",children:[r?n.jsxs("p",{className:"break-all font-mono text-label",children:[n.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(e.input)]}):n.jsxs("div",{children:[n.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),n.jsx(rf,{value:e.input,small:!0})]}),d&&n.jsx("p",{className:"font-mono text-small text-destructive-text",children:d}),!!((g=c==null?void 0:c.pages)!=null&&g.length)&&n.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(y=>n.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(t(y.image)),"aria-label":`Open page ${y.page}`,children:n.jsx("img",{src:t(y.image),alt:`Page ${y.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},y.page))}),l&&!d&&n.jsxs("details",{className:"group",children:[n.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[n.jsx(cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),n.jsx(rf,{value:a,small:!0})]}),!l&&!d&&n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:e.status==="stopped"?"Stopped before it answered.":u?"Running…":"Finished with no output."})]})]})}function CF({workflow:e,path:t,kind:s}){const r=iN(e,t);if(!r)return null;const a=Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(l==="steps"||l==="branches"&&s==="parallel")&&Array.isArray(c)?`… ${zf(c.length)}`:l==="body"?"… its body":l==="branches"&&s==="route"&&c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([u,d])=>[u,(d==null?void 0:d.criteria)??"…"])):c]));return n.jsxs("details",{className:"group border",children:[n.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:[n.jsx(cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",n.jsx("span",{className:"normal-case tracking-normal",children:t})]}),n.jsx(rf,{value:a})]})}function rf({value:e,small:t}){return n.jsx("pre",{className:ie("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",t?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(e,null,2)})}function TF({src:e,onClose:t}){return n.jsx(sx,{open:!0,onClose:t,title:"Page image",size:"full",children:n.jsx("img",{src:e,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const B2=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function RF(e,{everyMs:t=1e3,key:s="",enabled:r=!0}={}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[d,p]=x.useState(0),[g,y]=x.useState(0),h=x.useRef(e);return h.current=e,x.useEffect(()=>{if(!r)return;const m=new AbortController;let v;const w=async()=>{try{const k=Date.now(),N=await h.current(m.signal);if(m.signal.aborted||(l(N),u(null),p(k),bc(N.run.status)))return}catch(k){if(m.signal.aborted)return;u(k);const N=k;if(N.retryable){v=setTimeout(w,Math.min(t,N.retryAfterMs??500));return}if(B2(k))return}v=setTimeout(w,t)};return w(),()=>{m.abort(),clearTimeout(v)}},[s,t,g,r]),{data:a,error:c,readAt:d,reload:()=>y(m=>m+1)}}function AF({data:e,actions:t={},fileUrl:s,initial:r=null,lastRead:a}){const[l,c]=x.useState(r),u=x.useMemo(()=>j4(e,l),[e,l]),d=bc(e.run.status),[p,g]=x.useState(()=>Date.now()),y=x.useMemo(()=>Date.now(),[e]);return x.useEffect(()=>{if(d||e.run.paused)return;const h=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(h)},[d,e.run.paused]),n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsx(OF,{data:e,readAt:y,now:p,actions:t,stale:!d&&a&&p-a>5e3?Math.max(1e3,p-a):0}),e.run.paused&&n.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."}),n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[n.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:n.jsx("div",{className:"px-5 py-6 md:px-8",children:n.jsx(Tc,{graph:e.graph,marks:u,onSelect:h=>c(m=>m&&m.path===h.path&&(m.item??null)===h.item?null:h),label:"The run's workflow graph"})})}),l&&n.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:n.jsx(vF,{data:e,selected:l,onSelect:c,onClose:()=>c(null),fileUrl:s})})]}),n.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:n.jsx(Rc,{run:!0})})]})}function OF({data:e,readAt:t,now:s,actions:r,stale:a}){const l=bc(e.run.status),c=e.graph.nodes.find(y=>{var h,m;return y.kind==="map"&&((m=(h=e.nodes[y.path])==null?void 0:h.items)==null?void 0:m.length)}),u=c?dN(e.nodes[c.path].items):null,{usd:d,unknown:p}=fN(e),g=[["Elapsed",ji(_4(e,t,s))],["Cost",n.jsxs(n.Fragment,{children:[Mi(d),p>0&&n.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",p," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",e.totals.decisions],["Tool calls",e.totals.effects],["Agents",LF(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return u&&g.push(["Items",n.jsxs(n.Fragment,{children:[n.jsx("span",{children:u.done}),n.jsxs("span",{className:"text-muted-foreground",children:["/",u.total]}),u.failed>0&&n.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[u.failed," failed"]}),u.review>0&&n.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[u.review," review"]})]})]),n.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&n.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:n.jsxs(Ne,{tone:"warning",children:[n.jsx(xi,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([y,h,m],v)=>n.jsxs("div",{className:ie("px-4 py-2",v?"border-l":"pl-5 md:pl-8"),title:m,children:[n.jsx("p",{className:"caps text-micro text-muted-foreground",children:y}),n.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:h})]},y)),n.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[a>0&&n.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",ji(a)," ago, reading again"]}),!l&&(e.run.paused?n.jsxs(K,{size:"sm",variant:"solid",onClick:r.onResume,disabled:!r.onResume||!!r.busy,children:[n.jsx(_i,{"aria-hidden":!0})," ",r.busy==="resume"?"Resuming":"Resume"]}):n.jsxs(K,{size:"sm",onClick:r.onPause,disabled:!r.onPause||!!r.busy,title:"Calls in flight finish; no new node starts.",children:[n.jsx(xi,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const MF=new Set(["agent","decide","extract","report","artifact"]),LF=e=>e.graph.nodes.filter(t=>{var s;return MF.has(t.kind)&&!["pending","not_run"].includes(((s=e.nodes[t.path])==null?void 0:s.status)??"pending")}).length;function PF({error:e}){const t=e==null?void 0:e.status;return n.jsx("p",{className:ie("m-8 border p-4 font-mono text-body",t===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:e==null?"Reading the run's graph...":t===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 IF(e,t){return!t||e.state==="loading"?{messages:kc,steers:!1}:e.state==="failed"?{messages:t.features.messages,steers:!1}:{messages:t.features.messages,steers:R5(e.id,t.harnesses)}}async function zF(e,t){try{let s=null;do{const r=await e.listRevisions(t.agent_id,s),a=r.revisions.find(c=>c.revision===t.revision),l=a==null?void 0:a.definition.output_schema;if(a)return{state:"read",id:a.definition.harness,...l?{outputSchema:l}:{}};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const vk=new Set(["completed","failed","cancelled"]),DF=e=>{const t=fN(e);return`${Mi(t.usd)}${t.unknown?` + ${t.unknown} unknown`:""}`},FF=e=>e instanceof Pe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},ei=e=>({api:FF(e),title:Xz(e),cause:e});function wk({v2:e,runId:t,caps:s,agentName:r}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[d,p]=x.useState([]),[g,y]=x.useState([]),[h,m]=x.useState(null),[v,w]=x.useState(null),[k,N]=x.useState(0),A=x.useRef(""),_=x.useRef(zd()).current,S=x.useRef(zd()).current,E=x.useRef(er()).current,T=x.useRef(0),C=x.useRef(""),[R,D]=x.useState({state:"loading"});x.useEffect(()=>{a&&R.state==="loading"&&zF(e,a).then(D)},[a==null?void 0:a.revision]);const L=IF(R,s);VN(a,()=>O(),()=>N(P=>P+1));const O=async()=>{const P=_.begin();try{const[B,q]=await Promise.all([e.getRun(t),e.listFiles(t)]);_.current(P)&&(l(B),y(q.files))}catch(B){_.current(P)&&m(ei(B))}};x.useEffect(()=>{O()},[t]),h2(()=>{O()}),x.useEffect(()=>{const P=new AbortController;return u(null),ex(e,t,{signal:P.signal,onRows:B=>{p(B);const q=B.filter(de=>de.kind===T2).map(de=>`${de.id}\0${de.summary}`).join("");q!==C.current&&(C.current=q,O());const ce=B.filter(de=>de.kind==="tool_result").length;if(ce>T.current){T.current=ce;const de=S.begin();e.listFiles(t).then(ue=>{S.current(de)&&y(ue.files)}).catch(()=>{})}},onPage:B=>{B.cost&&u(B.cost);const q=`${B.status}/${B.state}`;(q!==A.current||B.status==="input_required"&&!B.unchanged)&&(A.current=q,O())}}).catch(B=>{P.signal.aborted||m(ei(B))}),()=>P.abort()},[t,k]);const I=async P=>{w(P);try{await e[P](t),m(null)}catch(B){m(ei(B))}w(null),await O(),N(B=>B+1)},W=async()=>{if(a){w("archive");try{const P=await(a.archived_at?e.unarchiveRun(t):e.archiveRun(t));l(B=>B?{...B,archived_at:P.archived_at}:P),m(null)}catch(P){m(ei(P))}w(null),O()}},U=async P=>{const B=await e.raiseCap(t,P);return await O(),N(q=>q+1),B},J=async P=>{let B=!0;try{await iS(E,t,P,e.sendMessage),m(null)}catch(q){m(ei(q)),B=!1}return await O(),N(q=>q+1),B},F=async(P,B,q,ce)=>{let de=null;try{await e.answerApproval(t,P,B,q,ce)}catch(ue){de=R2(ue)}return await O(),N(ue=>ue+1),de},Z=async P=>{try{return await P()}finally{O(),N(B=>B+1)}},z=RF(P=>e.getRunGraph(t,P),{key:t,enabled:(a==null?void 0:a.kind)==="workflow"}),H=!z.data&&B2(z.error);if(!a)return h?h.cause instanceof Pe&&h.cause.status===404?n.jsx(KN,{what:"run",id:t,list:{href:"#/runs",label:"Open the runs list"}}):n.jsx($n,{problem:ln(h.cause,"the run"),onRetry:()=>{m(null),O(),N(P=>P+1)}}):n.jsx(wP,{});const V=c&&!vk.has(a.status)?{...a,cost:c}:a;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[h&&n.jsx("div",{className:"border-b p-3",children:n.jsx(_a,{title:h.title,error:h.api})}),n.jsx(xF,{run:V,agentName:r(a.agent_id),messages:L.messages,harnessSteers:L.steers,graphView:a.kind==="workflow"&&!H?n.jsx(UF,{v2:e,runId:t,graph:z,onMoved:()=>{O()}}):void 0,costText:a.kind==="workflow"&&!vk.has(a.status)&&z.data?DF(z.data):void 0,outputSchema:R.state==="read"?R.outputSchema:void 0,rows:d,files:g,readFile:P=>e.readFile(t,P.path),readLearningDiff:()=>e.runLearningDiff(t),readLearning:()=>e.runLearning(t),readComputer:()=>e.runComputer(t),onTakeOver:()=>Z(()=>e.takeOverComputer(t)),onHandBack:P=>Z(()=>e.handBackComputer(t,P)),readComputers:()=>e.computers(),onMessage:J,onApprove:F,actions:{onStop:()=>void I("stop"),onCancel:()=>void I("cancel"),onArchive:()=>void W(),onRaiseCap:U,busy:v}},a.run_id)]})}function UF({v2:e,runId:t,graph:s,onMoved:r}){const{data:a,error:l,readAt:c,reload:u}=s,[d,p]=x.useState(null),[g,y]=x.useState(null),[h,m]=x.useState(null),v=async k=>{p(k);try{const N=await(k==="pause"?e.pauseRun(t):e.resumeRun(t));m({paused:N.paused,status:N.status,at:Date.now()}),y(null)}catch(N){y(ei(N))}p(null),u(),r()},w=a&&h&&c<h.at?{...a,run:{...a.run,paused:h.paused,...h.status?{status:h.status}:{}}}:a;return w?n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[g&&n.jsx("div",{className:"border-b p-3",children:n.jsx(_a,{title:g.title,error:g.api})}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(AF,{data:w,lastRead:c,fileUrl:k=>e.fileUrl(t,k),actions:{onPause:()=>void v("pause"),onResume:()=>void v("resume"),busy:d}})})]}):n.jsx(PF,{error:l})}function WF({view:e,error:t,onRetry:s,scope:r,needsYou:a,asking:l,failed:c,live:u,startHere:d}){if(t)return n.jsx($n,{problem:t,onRetry:s});if(!e)return n.jsx(vP,{});if(d)return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1600px] space-y-6 px-6 py-8",children:[n.jsx("h1",{className:"text-2xl font-semibold",children:"Mission Control"}),d]})});const p=h=>{var m;return((m=e.perAgent.find(v=>v.agentId===h))==null?void 0:m.name)??h},g=r!=null&&r.agent?e.perAgent.filter(h=>h.agentId===r.agent):e.perAgent,y=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,[typeof u=="number"&&u!==e.runs.active?`${u} running now`:"",e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:""].filter(Boolean).join(" · ")||void 0],["Needs input",l===null?"–":String(l??e.runs.needsInput),"#/runs?status=input_required",l??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,kk(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}`,kk(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1600px] space-y-8 px-6 py-8",children:[n.jsx("h1",{className:"text-2xl font-semibold",children:"Mission Control"}),a,n.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:y.map(([h,m,v,w,k])=>{const N=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:h}),n.jsx("p",{className:ie("mt-2 font-mono text-xl font-semibold",w),children:m}),k&&n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:k})]});return n.jsx("li",{children:v?n.jsx("a",{href:v,className:"block h-full border p-4 hover:border-border-strong hover:bg-accent",children:N}):n.jsx("div",{className:"h-full border p-4",children:N})},h)})}),n.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-3",children:[n.jsx("h2",{className:"text-lg font-semibold",children:HF(e)}),r&&n.jsx(tN,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),n.jsx(nN,{a:e.analytics,basis:e.cost.basis,refreshing:r==null?void 0:r.refreshing})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[n.jsxs("section",{className:"border",children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"Runs per agent"}),g.length?n.jsx("ul",{children:g.map(h=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:Qs(h.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[n.jsx("span",{className:"min-w-0 truncate",children:h.name}),n.jsx("span",{className:"font-mono text-body text-muted-foreground",children:h.runs})]})},h.agentId))}):n.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),n.jsxs("section",{className:"border",children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"Recent runs"}),e.recent.length?n.jsx("ul",{children:e.recent.map(h=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[n.jsx(Nc,{run:h}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"min-w-0 truncate text-lead",children:xn(h)}),n.jsx(Af,{run:h,className:"hidden sm:inline-flex"}),XD(h)&&n.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),n.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:p(h.agent_id)}),h.ended_at&&n.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:ji(Date.parse(h.ended_at)-Date.parse(h.created_at))}),h.cost&&(h.cost.usd!==null||Oi(h.cost))&&n.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:No(h.cost,{ended:pa(h.status)})}),n.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ht(h.created_at)})]})},h.run_id))}):n.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const kk=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function HF(e,t=Date.now()){var l;const s=e.analytics.filter,r=s.from?Math.round((Math.floor(t/864e5)*864e5-Date.parse(s.from))/864e5)+1:null,a=s.from?Qg.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?`${a}, of ${((l=e.perAgent.find(c=>c.agentId===s.agent))==null?void 0:l.name)??s.agent}`:a}const Js=e=>`#/runs/${encodeURIComponent(e)}`;function BF({asking:e,failed:t,failedAll:s,live:r,learning:a=[],agentName:l,onAnswer:c,onApprove:u,onHandBack:d,onRunAgain:p,onStop:g,problem:y,now:h=Date.now}){const m=GD(t),[,v]=x.useState(0);x.useEffect(()=>{if(!r.length)return;const L=setInterval(()=>v(O=>O+1),1e3);return()=>clearInterval(L)},[r.length]);const[w,k]=x.useState([]),N=(L,O,I)=>{const W=e.find(J=>J.run_id===L),U=W?xn(W):L;k(J=>[...J.filter(F=>F.runId!==L),...I?[{runId:L,what:O,title:U,text:I}]:[]])},A=u&&(async(L,O,I,W,U)=>{const J=await(U?u(L,O,I,W,U):u(L,O,I,W));return N(L,O,J),J}),_=d&&(async(L,O,I)=>{const W=await d(L,I);return N(L,`ask:${O.asked_at}`,W),W}),S=L=>{var I;const O=ri(L);return((I=L.pending)==null?void 0:I.kind)==="approval"?L.pending.id:O?`ask:${O.asked_at}`:null},E=u2(t),T=a.filter(L=>L.pending>0),C=T.reduce((L,O)=>L+O.pending,0),R=e.length+E+C;if(!R&&!r.length&&!y&&!w.length)return null;const D=h();return n.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[R>0&&n.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",n.jsxs("span",{className:"text-warning-text",children:["· ",R]})]}),y&&n.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:y}),w.filter(L=>!e.some(O=>O.run_id===L.runId&&S(O)===L.what)).map(L=>n.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:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("a",{href:Js(L.runId),className:"underline-offset-4 hover:underline",children:L.title}),": your answer wasn't taken. ",L.text]}),n.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(O=>O.filter(I=>I.runId!==L.runId)),children:"Dismiss"})]},L.runId)),e.length>0&&n.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(L=>{var O,I,W;return((O=L.pending)==null?void 0:O.kind)==="approval"?n.jsx(GF,{run:L,pending:L.pending,agentName:l(L.agent_id),at:D,onApprove:A},`${L.run_id}:${L.pending.id}`):ri(L)?n.jsx(qF,{run:L,ask:ri(L),agentName:l(L.agent_id),at:D,onHandBack:_},`${L.run_id}:${ri(L).asked_at}`):n.jsx(VF,{run:L,agentName:l(L.agent_id),at:D,onAnswer:c},`${L.run_id}:${((I=L.pending)==null?void 0:I.kind)==="question"?L.pending.asked_at:((W=L.pending)==null?void 0:W.kind)==="budget"?L.pending.at??"":""}`)})}),m.length>0&&n.jsxs("div",{className:"border",children:[n.jsxs("p",{className:"caps flex items-center justify-between border-b px-4 py-2.5 text-label text-muted-foreground",children:[n.jsxs("span",{children:["Failed in the last 24 h · ",E]}),n.jsx("a",{href:"#/runs?status=failed",className:"normal-case tracking-normal hover:text-foreground",children:s===void 0?"All failed runs →":`All ${s} failed ${s===1?"run":"runs"} →`})]}),n.jsx("ul",{children:m.map(L=>n.jsx(XF,{message:L.message,runs:L.runs,agentName:l,at:D,onRunAgain:p},L.message))})]}),T.length>0&&n.jsxs("div",{className:"border",children:[n.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Learned, waiting for your OK · ",C]}),n.jsx("ul",{children:T.map(L=>n.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[n.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:L.name}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:ax(L.pending)}),n.jsx("a",{href:`#/agents/${encodeURIComponent(L.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},L.agent_id))})]}),r.length>0&&n.jsxs("div",{className:"border",children:[n.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",r.length]}),n.jsx("ul",{children:r.map(L=>n.jsx(QF,{run:L,agentName:l(L.agent_id),at:D,onStop:g},L.run_id))})]})]})}function GF({run:e,pending:t,agentName:s,at:r,onApprove:a}){return n.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:n.jsx(A2,{compact:!0,pending:t,heading:n.jsx(Xx,{run:e,agentName:s,since:`asked ${Ac(t.requested_at,r)} ago`}),onAnswer:(l,c,u)=>a?u?a(e.run_id,t.id,l,c,u):a(e.run_id,t.id,l,c):Promise.resolve("Open the run to answer it.")})})}function qF({run:e,ask:t,agentName:s,at:r,onHandBack:a}){return n.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:n.jsx(P2,{compact:!0,ask:t,heading:n.jsx(Xx,{run:e,agentName:s,since:`asked ${Ac(t.asked_at,r)} ago`}),open:n.jsx("a",{href:Js(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:a&&(l=>a(e.run_id,t,l))})})}function VF(e){var t;return((t=e.run.pending)==null?void 0:t.kind)==="budget"?n.jsx(KF,{run:e.run,pending:e.run.pending,agentName:e.agentName}):n.jsx(YF,{...e})}function KF({run:e,pending:t,agentName:s}){return n.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[n.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[n.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:s}),n.jsx("a",{href:Js(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:xn(e)})]}),n.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:$S(t)}),typeof t.said=="string"&&n.jsx("p",{className:"mt-1 text-prose leading-snug",children:t.said}),n.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:n.jsx("a",{href:Js(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function Xx({run:e,agentName:t,since:s}){return n.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[n.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:t}),n.jsx("a",{href:Js(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:xn(e)}),s&&n.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function YF({run:e,agentName:t,at:s,onAnswer:r}){var k;const a=((k=e.pending)==null?void 0:k.kind)==="question"?e.pending:null,l=(a==null?void 0:a.question)??"",c=BD(l),[u,d]=x.useState(""),[p,g]=x.useState(!1),[y,h]=x.useState(null),[m,v]=x.useState(null),w=async N=>{N.preventDefault();const A=u.trim();if(!A||p)return;g(!0),h(null);const _=await r(e.run_id,A);g(!1),_?h(_):v(A)};return n.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[n.jsx(Xx,{run:e,agentName:t,since:a!=null&&a.asked_at?`asked ${Ac(a.asked_at,s)} ago`:void 0}),n.jsx("p",{className:"mt-2 text-base leading-snug",children:l}),m?n.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",m," · ",n.jsx("a",{href:Js(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):n.jsxs("form",{onSubmit:N=>void w(N),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(N=>n.jsx("button",{type:"button",onClick:()=>d(N),className:ie("border px-3 py-1.5 text-body hover:border-border-strong",u===N?"border-warning text-warning-text":"border-border"),children:N},N)),n.jsx(Be,{value:u,onChange:N=>d(N.target.value),"aria-label":`Answer ${t}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),n.jsx(K,{type:"submit",variant:"solid",size:"sm",disabled:p||!u.trim(),children:p?"Sending…":"Send"}),y&&n.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:y})]})]})}function XF({message:e,runs:t,agentName:s,at:r,onRunAgain:a}){const[l,c]=x.useState(!1),[u,d]=x.useState(null),[p,g]=x.useState(new Set),y=t.filter(N=>!p.has(N.run_id)),h=t.length-y.length,m=async()=>{c(!0),d(null);const{started:N,problem:A}=await a(y);c(!1),d(A),g(_=>new Set([..._,...N]))},v=h>0&&n.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",h===1?"1 run":`${h} runs`]});if(!y.length)return n.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:[n.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),n.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),v]});const w=y[0],k=y.length===1;return n.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:[n.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[k?n.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[n.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(w.agent_id)}),n.jsx("a",{href:Js(w.run_id),className:"min-w-0 truncate hover:underline",children:xn(w)})]}):n.jsxs("p",{className:"text-lead",children:[y.length," runs failed ",n.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(y.map(N=>s(N.agent_id)))].join(", ")]})]}),n.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!k&&n.jsxs("details",{className:"mt-1 text-body",children:[n.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),n.jsx("ul",{className:"mt-1 space-y-1",children:y.map(N=>n.jsxs("li",{children:[n.jsx("a",{href:Js(N.run_id),className:"hover:underline",children:xn(N)})," ",n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["· ",s(N.agent_id)]})]},N.run_id))})]}),u&&n.jsx("p",{className:"mt-1 font-mono text-small text-destructive-text",role:"alert",children:u})]}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:[Ac(w.ended_at??w.created_at,r)," ago"]}),v,n.jsx(K,{type:"button",size:"sm",disabled:l,onClick:()=>void m(),children:k?"Run again":"Run all again"})]})}function QF({run:e,agentName:t,at:s,onStop:r}){var g;const[a,l]=x.useState(!1),[c,u]=x.useState(null),d=(g=e.cost)==null?void 0:g.usd,p=d===0?"nothing spent yet":typeof d=="number"?`${No(e.cost)} so far`:Oi(e.cost)?No(e.cost):"cost not known yet";return n.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:[n.jsx("span",{className:"size-2 shrink-0 bg-run-active ring-4 ring-run-active/[0.18]","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:t}),n.jsx("a",{href:Js(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:xn(e)}),n.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",ji(s-Date.parse(e.created_at))]}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:p}),n.jsx("a",{href:Js(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),jc(e.status,e.state,e.kind,kc,!0,e.error,e.review).canStop?n.jsx(K,{type:"button",size:"sm",disabled:a,onClick:async()=>{l(!0),u(await r(e.run_id)),l(!1)},children:"Stop"}):n.jsx("a",{href:Js(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Open to cancel"}),c&&n.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:c})]})}function JF({keyCard:e=!1}){const t="font-mono text-small text-foreground";return n.jsxs("div",{className:"border bg-background p-5",children:[n.jsxs("p",{className:"flex items-center gap-2 text-base font-semibold",children:[n.jsx(ia,{className:"size-4 text-primary-text","aria-hidden":!0}),"Add a model key"]}),n.jsx("p",{className:"mt-2 max-w-prose text-lead leading-relaxed text-muted-foreground",children:e?"Add a model key in the card above, and the templates here run in one click.":n.jsxs(n.Fragment,{children:["This server has no model to run an agent on yet. Start agentrun-serve with the model to run in its environment, ",n.jsx("span",{className:t,children:"AGENT_MODEL"}),"=provider/model-id, and that provider's key (",n.jsx("span",{className:t,children:"ANTHROPIC_API_KEY"}),", ",n.jsx("span",{className:t,children:"OPENAI_API_KEY"})," or ",n.jsx("span",{className:t,children:"OPENROUTER_API_KEY"}),"). Or name a gateway: ",n.jsx("span",{className:t,children:"AGENT_MODEL_BASE_URL"})," and ",n.jsx("span",{className:t,children:"AGENT_MODEL_API_KEY"}),", with the gateway's model in ",n.jsx("span",{className:t,children:"AGENT_MODEL"}),". Then reload this page, and the templates here run in one click."]})})]})}const ZF=[{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 G2(e){var r;const t=["pi","claude-agent","codex"],s=e.filter(a=>a.available&&a.default_model);return s.sort((a,l)=>(t.indexOf(a.id)+1||99)-(t.indexOf(l.id)+1||99)),((r=s[0])==null?void 0:r.id)??null}function e9(e,t,s){const r=Ff(t,[...s]).filter(l=>l.available).map(l=>l.name),a=e.tools.find(l=>!r.includes(l));return a?{ok:!1,reason:`${a} can't run on this server yet`}:{ok:!0}}async function t9(e,t,s,r=er()){const l=(await go(p=>e.listAgents({cursor:p}),p=>p.agents)).find(p=>p.definition.name===t.name&&!p.archived_at),c=(l==null?void 0:l.agent_id)??(await e.createAgent({definition:{version:1,name:t.name,description:t.description,instructions:t.instructions,harness:s,tools:t.tools,skills:[]}})).agent_id,u={input:{content:t.input}},{run:d}=await e.startRun(c,u,r.keyFor(t.name,u));return r.done(),d.run_id}const n9={hello:Si,web:Pk,plan:cE};function s9({harnesses:e,tools:t,onTry:s,imported:r=0,keyCard:a=!1}){const[l,c]=x.useState(null),[u,d]=x.useState(null),p=G2(e),g=async y=>{c(y.id),d(null);const h=await s(y);c(null),d(h)};return n.jsxs("section",{"aria-label":"Start here",className:"space-y-4",children:[n.jsxs("div",{className:"border border-primary/50 bg-primary/5 p-6",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"Start here"}),n.jsx("h2",{className:"mt-2 text-xl font-semibold",children:"Watch an agent work in about ten seconds"}),n.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:p?"Pick one: it makes the agent, runs it, and opens the run as it happens.":"First a model to run on; then one click makes an agent, runs it, and opens the run as it happens."}),n.jsxs("div",{className:"mt-5",children:[p?n.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:ZF.map(y=>{const h=e9(y,p,t),m=n9[y.id]??Si;return n.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[n.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[n.jsx(m,{className:"size-4 text-primary-text","aria-hidden":!0}),y.name]}),n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:y.shows}),n.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:y.description}),h.ok?n.jsx(K,{type:"button",variant:y.id==="hello"?"solid":"outline",size:"sm",className:"mt-4 self-start",disabled:l!==null,onClick:()=>void g(y),children:l===y.id?"Starting…":"Try it"}):n.jsx("p",{className:"mt-4 font-mono text-small text-muted-foreground",children:h.reason})]},y.id)})}):n.jsx(JF,{keyCard:a}),u&&n.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:u})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border px-5 py-4",children:[n.jsxs("p",{className:"text-lead",children:["Or ",n.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."]}),r>0&&n.jsxs("p",{className:"text-lead text-muted-foreground",children:[r," imported sessions to read · ",n.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse them"})]})]})]})}const r9=(e,t)=>e instanceof Pe?{status:e.status,ms:t,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:t,body:{error:{code:"network",message:String(e)}}};function o9({agents:e,revisions:t=[],efforts:s,origin:r,agentId:a,onAgent:l,onSend:c,onOpenRun:u,result:d=null,live:p,limits:g,upload:y=bS,removeUpload:h}){var yn,Dt,sn;const[m,v]=x.useState(a??((yn=e[0])==null?void 0:yn.agent_id)??"");x.useEffect(()=>{var me;a&&a!==m&&e.some(Te=>Te.agent_id===a)?v(a):e.some(Te=>Te.agent_id===m)||v(((me=e[0])==null?void 0:me.agent_id)??"")},[e,a]);const w=e.find(me=>me.agent_id===m),k=(w==null?void 0:w.kind)??"agentic",[N,A]=x.useState(""),[_,S]=x.useState(""),E=_?(Dt=t.find(me=>me.revision===_))==null?void 0:Dt.definition:void 0,T=k==="agentic"?JSON.stringify(((sn=E??(w==null?void 0:w.definition))==null?void 0:sn.input_schema)??null):"null",C=x.useMemo(()=>k==="agentic"?xS(JSON.parse(T)):null,[k,T]),R=(C==null?void 0:C.kind)==="fields"?C.form:null,D=k==="workflow"||(C==null?void 0:C.kind)==="json",[L,O]=x.useState({});x.useEffect(()=>{O(R?kx(R):{})},[m,T]);const I=k==="workflow"?dS(w==null?void 0:w.definition.workflow):(C==null?void 0:C.kind)==="json"?C.example:null,W=x.useRef("");x.useEffect(()=>{if(N.trim()&&N!==W.current)return;const me=(I==null?void 0:I.text)??"";W.current=me,A(me)},[m,I==null?void 0:I.text]);const[U,J]=x.useState(""),[F,Z]=x.useState(""),[z,H]=x.useState(""),[V,P]=x.useState("form"),[B,q]=x.useState(d?"response":"code"),[ce,de]=x.useState("curl"),[ue,Q]=x.useState(!1),[fe,ye]=x.useState(d),Ee=new Set((R==null?void 0:R.fields.map(([me])=>me))??[]),ge=me=>{const Te=Xd(me);return Te!==null&&Ee.has(Te)?Te:null},se=x.useMemo(()=>{var Fe,lt;const me=fe&&fe.status>=400?(Fe=fe.body)==null?void 0:Fe.error:void 0;if(!me||typeof me.message!="string")return;const Te=Array.isArray(me.fields)?me.fields.filter(Ke=>!!Ke&&typeof Ke.field=="string"&&typeof Ke.message=="string"):[],tt=Te.filter(Ke=>Ke.message!==me.message&&ge(Ke.field)===null);return{message:me.message,more:tt,issues:Te,box:typeof((lt=me.details)==null?void 0:lt.box)=="string"?me.details.box:void 0,details:me.code==="agent_not_runnable"?me.details:void 0}},[fe,T]),[pe,Y]=x.useState(new Set);x.useEffect(()=>{Y(new Set)},[fe]);const _e=(me,Te,tt)=>{O(Fe=>({...Fe,[me]:tt})),Y(Fe=>{const lt=new Set(Fe);return vx(Te,tt)?lt.add(me):lt.delete(me),lt})},Ze=me=>pe.has(me)?[]:((se==null?void 0:se.issues)??[]).filter(Te=>ge(Te.field)===me),[Je,xt]=x.useState(!1),et=x.useMemo(()=>er(),[]),ae=vS({upload:y,remove:h,limits:g,frozen:Je}),Ae=cS(k,{text:N,revision:_,effort:U,maxCostUsd:F,fileIds:ae.fileIds,repo:z,...R?{typed:{fields:Mf(R,L),contentRequired:R.contentRequired}}:{},...(C==null?void 0:C.kind)==="json"?{json:!0}:{}}),Ce=Ae.ok?Ae.body:{input:D?N:R?YL(R,N,L):{content:N},...ae.fileIds.length?{file_ids:ae.fileIds}:{}},Ge=m?et.keyFor(m,Ce):"",kt=ce==="curl"?OL(r,m,Ce,Ge):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${m||"{agent_id}"}/runs`)}, {
567
+ method: "POST",
568
+ headers: {
569
+ Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
570
+ "Content-Type": "application/json",
571
+ "Idempotency-Key": ${JSON.stringify(Ge)},
572
+ },
573
+ body: JSON.stringify(${JSON.stringify(Ce,null,2).replace(/\n/g,`
574
+ `)}),
575
+ });
576
+ console.log(res.status, await res.json());`,We=async()=>{if(!Ae.ok||!c||ae.busy)return;xt(!0);const me=await mS(et,m,Ae.body,c);xt(!1),ye(me),q("response"),Q(!0),me.status>=200&&me.status<300&&ae.clear()},rt=D?k==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${R?"message":"first message"}, e.g. Summarize the standup: we ship Friday.`;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.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:[e.length>0&&n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[n.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),n.jsx(Lt,{id:"playground-agent",label:"Agent",placeholder:"Pick an agent",value:m,onChange:me=>{v(me),S(""),l==null||l(me)},options:_f(e).map(me=>({value:me.agent_id,label:me.definition.name})),className:"w-56 max-w-[60vw]"})]}),n.jsxs("span",{className:"font-mono text-small",children:[n.jsx("span",{className:"text-primary-text",children:"POST"})," ",n.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",m||"{agent_id}","/runs"]})]}),n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"caps text-label text-muted-foreground",children:"Live API"}),n.jsx(K,{type:"button",size:"xs",onClick:()=>Q(me=>!me),"aria-expanded":ue,className:"hidden text-muted-foreground hover:text-foreground short:inline-flex",children:ue?"Hide code":"Show code"})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:[@media(min-height:501px)]:grid-cols-2",children:[n.jsx("section",{"aria-label":"Request",className:ie("flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",ue&&"short:hidden"),children:e.length===0?n.jsxs(n.Fragment,{children:[n.jsx("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:n.jsx("span",{className:"pb-1 text-lead font-semibold",children:"Request"})}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[n.jsxs("div",{className:"border border-primary/50 bg-primary/5 p-5",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"No agents yet"}),n.jsx("h2",{className:"mt-2 text-xl font-semibold",children:"Start a run"}),n.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Runs start from an agent. Make one, then send its first request here."}),n.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[n.jsx("a",{href:"#/agents/new",className:Ni({variant:"solid",size:"lg"}),children:"Create an agent"}),n.jsx("a",{href:"#/templates",className:Ni({variant:"outline",size:"lg"}),children:"Browse templates"})]})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"caps text-label text-muted-foreground",children:"What a request takes"}),n.jsx("dl",{className:"mt-3 divide-y border-y",children:Object.entries(Ko).map(([me,Te])=>n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 py-3",children:[n.jsx("dt",{className:"w-40 font-mono text-body",children:me}),n.jsx("dd",{className:"text-small text-muted-foreground",children:Te})]},me))})]})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[n.jsx("span",{className:"text-lead font-semibold",children:"Request"}),n.jsx("span",{className:"flex gap-4 text-small",children:["form","json"].map(me=>n.jsx("button",{type:"button",onClick:()=>P(me),className:ie("border-b pb-1 capitalize",V===me?"border-foreground":"border-transparent text-muted-foreground"),children:me==="json"?"JSON":"Form"},me))})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),n.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[w?`${w.definition.name}: ${k==="agentic"?"an":"a"} ${k} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),V==="json"?n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.7]",children:JSON.stringify(Ce,null,2)}),n.jsx(Yo,{name:"file_ids",note:Ko.file_ids,children:n.jsx(Gh,{attachments:ae,limits:g})})]}):n.jsxs(n.Fragment,{children:[n.jsxs(Yo,{name:D?"input":"input.content",required:!R||R.contentRequired,optional:!!R&&!R.contentRequired,error:!Ae.ok&&Ae.field==="input"&&N?Ae.message:void 0,children:[n.jsx(ds,{value:N,onChange:me=>A(me.target.value),rows:D?7:4,placeholder:rt}),I&&n.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[uS(I,"start",k==="workflow"?"workflow":"agent"),I.fields.length>0&&n.jsxs(n.Fragment,{children:[" Fields: ",I.fields.map((me,Te)=>n.jsxs("span",{title:me.note,children:[Te?", ":"",n.jsx("span",{className:"text-foreground",children:me.name})]},me.name)),"."]})]})]}),R==null?void 0:R.fields.map(([me,Te])=>n.jsxs("div",{"data-field":`input.${me}`,children:[n.jsx(Nx,{field:Te,label:Ec(me,Te),help:rc(Te),value:L[me]??"",onChange:tt=>_e(me,Te,tt)}),n.jsx(Zo,{issues:Ze(me),words:tt=>jx(tt,me,Te)})]},me)),n.jsx(Yo,{name:"file_ids",note:Ko.file_ids,children:n.jsx(Gh,{attachments:ae,limits:g})}),n.jsx(Yo,{name:"revision",note:Ko.revision,children:n.jsx(Lt,{label:"Revision",value:_,onChange:S,className:"w-full",options:[{value:"",label:"The current revision"},...t.map(me=>({value:me.revision,label:`rev ${me.version}${me.current?" (current)":""}${me.note?`: ${me.note}`:""}`}))]})}),n.jsx(Yo,{name:"effort",note:Ko.effort,children:n.jsx("div",{className:"flex gap-2",children:["",...s].map(me=>n.jsx(K,{type:"button",size:"sm","aria-pressed":U===me,onClick:()=>J(me),className:U===me?"border-foreground hover:border-foreground":"text-muted-foreground",children:me||"default"},me||"default"))})}),k==="agentic"&&n.jsx(Yo,{name:"repo",note:Ko.repo,error:!Ae.ok&&Ae.field==="repo"?Ae.message:void 0,children:n.jsx(Be,{value:z,onChange:me=>H(me.target.value),placeholder:"owner/name"})}),k==="agentic"&&n.jsxs(Yo,{name:"max_cost_usd",note:Ko.max_cost_usd,error:!Ae.ok&&Ae.field==="max_cost_usd"?Ae.message:void 0,children:[n.jsx(Be,{value:F,onChange:me=>Z(me.target.value),inputMode:"decimal",placeholder:"e.g. 0.50"}),n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:n.jsx(l2,{})})]})]})]}),n.jsxs("footer",{className:"flex shrink-0 items-center justify-between gap-3 border-t px-5 py-3 md:px-6",children:[n.jsx("span",{className:"text-small text-muted-foreground",children:"Sends a real request to this server."}),n.jsxs(K,{variant:"primary",size:"lg",onClick:We,disabled:!Ae.ok||!c||Je||!m||ae.busy,title:ae.busy?"Waiting for the files to be sent":void 0,children:[n.jsx(_i,{"aria-hidden":!0})," ",Je?"Sending":"Send request"]})]})]})}),n.jsxs("section",{"aria-label":"Code and response",className:ie("flex min-h-0 flex-col",!ue&&"short:hidden"),children:[n.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[n.jsxs("span",{className:"flex gap-4 text-body",children:[n.jsx("button",{type:"button",onClick:()=>q("code"),className:ie("border-b pb-1",B==="code"?"border-foreground":"border-transparent text-muted-foreground"),children:"Code"}),n.jsxs("button",{type:"button",onClick:()=>q("response"),disabled:!fe,className:ie("border-b pb-1 disabled:opacity-45",B==="response"?"border-foreground":"border-transparent text-muted-foreground"),children:["Response",fe&&n.jsx("span",{className:ie("ml-2 font-mono",fe.status<300?"text-success-text":"text-destructive-text"),children:fe.status})]})]}),B==="code"&&n.jsx(K,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var me;return void((me=navigator.clipboard)==null?void 0:me.writeText(kt))},children:n.jsx(lf,{"aria-hidden":!0})})]}),B==="code"?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex gap-5 border-b px-5 text-small md:px-6",children:["curl","fetch"].map(me=>n.jsx("button",{type:"button",onClick:()=>de(me),className:ie("-mb-px border-b-2 py-2.5",ce===me?"border-primary":"border-transparent text-muted-foreground"),children:me==="curl"?"cURL":"JavaScript"},me))}),n.jsx("pre",{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:kt}),n.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."})]}):fe&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small md:px-6",children:[n.jsx("span",{className:fe.status<300?"text-success-text":"text-destructive-text",children:fe.status})," ",n.jsxs("span",{className:"text-muted-foreground",children:[fe.ms," ms"]})]}),se&&n.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: ",se.message,se.box?n.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",se.box,")"]}):null,n.jsx(_S,{agentId:m,details:se.details}),se.more.length>0&&n.jsx("span",{className:"mt-1 block",children:se.more.map(me=>n.jsxs("span",{className:"block",children:[me.field,": ",me.message]},`${me.field}:${me.message}`))})]}),fe.runId&&p?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden border-b short:overflow-auto",children:p(fe.runId)}),n.jsxs("details",{className:"border-b px-5 py-2.5 md:px-6",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Response body"}),n.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(fe.body,null,2)})]})]}):n.jsx("pre",{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(fe.body,null,2)}),fe.runId&&n.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(fe.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 ",n.jsx(fg,{className:"size-4","aria-hidden":!0})]})]})]})]})]})}const Ko={"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."};function Yo({name:e,required:t,optional:s,note:r,error:a,children:l}){return n.jsxs("div",{children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[n.jsx("span",{className:"font-mono text-body",children:e}),t?n.jsx("span",{className:"text-label text-muted-foreground",children:"required"}):s&&n.jsx("span",{className:"text-label text-muted-foreground",children:"optional"})]}),l,r&&n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:r}),a&&n.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:a})]})}const q2=["queued","working","paused","input_required","completed","failed","cancelled"],a9={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function i9({runs:e,agentName:t,onOpen:s,error:r,onRetry:a,onMore:l,loadingMore:c,filter:u={},onFilter:d}){const p=!!u.archived;return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[n.jsx("h1",{className:"mr-auto font-mono text-2xl font-semibold",children:p?"Archived runs":"Runs"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Lt,{label:"Runs in one state",value:u.status??"",onChange:g=>d({...u,status:g||void 0}),className:"h-11 w-48",options:[{value:"",label:"Any state"},...q2.map(g=>({value:g,label:a9[g]}))]}),n.jsxs(K,{size:"lg",variant:p?"primary":"outline","aria-pressed":p,onClick:()=>d({...u,archived:!p}),children:[n.jsx(cc,{"aria-hidden":!0})," Archived"]})]})]}),r&&!e?n.jsx($n,{problem:r,onRetry:a,className:""}):e?e.length?n.jsx(c9,{runs:e,agentName:t,onOpen:s}):u.status||p?n.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:u.status?"No run matches.":"No archived runs."}):n.jsx(l9,{}):n.jsx(fs,{label:"Loading the runs"}),e&&r&&n.jsx($n,{problem:r,className:"mt-4"}),e&&l&&n.jsx("div",{className:"mt-4 flex justify-center",children:n.jsx(K,{type:"button",onClick:l,disabled:c,size:"sm",children:c?"Loading":"Load more"})})]})}function l9(){return n.jsxs("section",{"aria-labelledby":"first-run",className:"border border-primary/50 bg-primary/5 p-5",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"No runs yet"}),n.jsx("h2",{id:"first-run",className:"mt-2 text-xl font-semibold",children:"Start your first run"}),n.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."}),n.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[n.jsxs("a",{href:"#/playground",className:Ni({variant:"solid",size:"lg"}),children:[n.jsx(_i,{"aria-hidden":!0})," Start a run"]}),n.jsx("a",{href:"#/templates",className:Ni({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function c9({runs:e,agentName:t,onOpen:s}){return n.jsxs("table",{className:"w-full border-collapse border text-body",children:[n.jsx("thead",{className:"hidden md:table-header-group",children:n.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Status","Run","Agent","Kind","Started","Cost"].map(r=>n.jsx("th",{className:"border-b px-3 py-2 text-left font-normal",children:r},r))})}),n.jsx("tbody",{children:e.map(r=>n.jsxs("tr",{className:"cursor-pointer border-b hover:bg-accent",onClick:()=>s(r.run_id),children:[n.jsx("td",{className:"px-3 py-2.5 align-top",children:n.jsx(Nc,{run:r})}),n.jsxs("td",{className:"px-3 py-2.5 align-top",children:[n.jsxs("button",{type:"button",className:"flex items-start gap-1 text-left",onClick:a=>{a.stopPropagation(),s(r.run_id)},children:[n.jsx("span",{className:"line-clamp-2",children:xn(r)}),n.jsx(Y$,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),r.status==="completed"&&r.review&&n.jsx("span",{className:"mt-1 block text-small text-warning-text",children:r.review.reason}),r.trigger&&n.jsx("span",{className:"mt-1 flex",children:n.jsx(y2,{run:r})}),n.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[t(r.agent_id)," · ",ht(r.created_at)]})]}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top md:table-cell",children:t(r.agent_id)}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:r.kind}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:ht(r.created_at)}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:No(r.cost,{ended:pa(r.status)})})]},r.run_id))})]})}const u9=["system","light","dark"],lg="agentrun.theme",d9="(prefers-color-scheme: dark)",Gf=()=>{try{return globalThis.localStorage??null}catch{return null}},V2=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(d9):null;let cg=null;function f9(e=Gf()){try{const t=e==null?void 0:e.getItem(lg);return t==="light"||t==="dark"?t:"system"}catch{return"system"}}const ug=(e=Gf())=>cg??f9(e);function m9(e,t=Gf()){cg=null;try{e==="system"?t==null||t.removeItem(lg):t==null||t.setItem(lg,e)}catch{cg=e}}function dg(e,t=document.documentElement,s=V2()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);t.classList.toggle("dark",r),t.classList.toggle("light",!r)}function p9(e=document.documentElement,t=V2(),s=Gf()){dg(ug(s),e,t);const r=()=>{ug(s)==="system"&&dg("system",e,t)};return t==null||t.addEventListener("change",r),()=>t==null?void 0:t.removeEventListener("change",r)}const h9=[{id:"mission",label:"Mission Control",Icon:lE},{id:"playground",label:"Playground",Icon:Wk},{id:"agents",label:"Agents",Icon:mg},{id:"templates",label:"Templates",Icon:Ik},{id:"runs",label:"Runs",Icon:xg},{id:"triggers",label:"Triggers",Icon:af},{id:"settings",label:"Settings",Icon:Dk}],g9={system:["System",wa],light:["Light",NE],dark:["Dark",gE]};function x9(){const[e,t]=x.useState(()=>ug()),s=r=>{m9(r),dg(r),t(r)};return n.jsx("div",{role:"group","aria-label":"Theme",className:"flex border",children:u9.map(r=>{const[a,l]=g9[r];return n.jsx("button",{type:"button","aria-label":a,title:a,"aria-pressed":e===r,onClick:()=>s(r),className:ie("flex flex-1 items-center justify-center py-2 hover:bg-accent",e===r&&"bg-primary/[0.06] text-primary-text"),children:n.jsx(l,{className:"size-4","aria-hidden":!0})},r)})})}function jk(){return n.jsxs("span",{className:"whitespace-nowrap font-mono text-figure font-semibold","aria-label":"AgentRun",children:["agent",n.jsx("span",{className:"text-primary-text",children:".run()"})]})}function y9({active:e,settings:t=!1,triggers:s=!1,onNavigate:r,onSignOut:a,onSignOutEverywhere:l,banners:c,children:u}){const[d,p]=x.useState(!1),[g,y]=x.useState(!1),h=x.useRef(null),m=x.useRef(null),v=x.useRef(!1);x.useEffect(()=>{var k,N;g?(k=m.current)==null||k.focus():v.current&&((N=h.current)==null||N.focus())},[g]);const w=()=>{v.current=!0,y(!1)};return n.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[n.jsxs("header",{className:"flex shrink-0 items-center justify-between border-b px-4 py-3 roomy:hidden",children:[n.jsx(jk,{}),n.jsx(K,{size:"icon",className:"size-9 [&_svg]:size-[18px]","aria-label":"Navigation","aria-expanded":d,onClick:()=>p(k=>!k),children:n.jsx(mE,{"aria-hidden":!0})})]}),n.jsxs("aside",{className:ie("shrink-0 flex-col border-r bg-background px-3 pb-4 pt-6 roomy:flex roomy:h-dvh roomy:w-sidebar roomy:overflow-y-auto",d?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[n.jsx("div",{className:"hidden px-3 pb-[30px] roomy:block",children:n.jsx(jk,{})}),n.jsx("nav",{"aria-label":"Navigation",className:"flex flex-col gap-1",children:h9.filter(k=>(k.id!=="settings"||t)&&(k.id!=="triggers"||s)).map(({id:k,label:N,Icon:A})=>n.jsx(L4,{icon:A,active:e===k,onClick:()=>{r==null||r(k),p(!1)},children:N},k))}),n.jsx("div",{className:"mt-4 roomy:mt-auto",children:n.jsx(x9,{})}),n.jsxs(K,{type:"button",onClick:a,className:"mt-2 justify-start gap-2.5 px-3",children:[n.jsx(dE,{"aria-hidden":!0})," Sign out"]}),l&&(g?n.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:k=>{k.key==="Escape"&&w()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[n.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(K,{type:"button",variant:"destructive",size:"xs",onClick:()=>{y(!1),l()},children:"Sign out everywhere"}),n.jsx(K,{type:"button",ref:m,onClick:w,size:"xs",children:"Cancel"})]})]}):n.jsx("button",{type:"button",ref:h,onClick:()=>y(!0),className:"mt-1 px-3 py-1.5 text-left text-small text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]}),n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[n.jsx(p6,{}),c,n.jsx("main",{className:"relative min-h-0 min-w-0 flex-1 overflow-auto",children:u})]})]})}const ch={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},Nk={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 b9({mode:e,code:t=null,codeNeeded:s=!1,onSubmit:r,problem:a=null,offer:l=null}){const[c,u]=x.useState(""),[d,p]=x.useState(!1),[g,y]=x.useState(""),[h,m]=x.useState(t??"");x.useEffect(()=>{t!==null&&m(t)},[t]);const[v,w]=x.useState(a),[k,N]=x.useState(!1),A=e==="setup",_=A&&l!==null&&!("sessions"in l&&l.sessions===0),S=A&&(s||t!==null),E=e!=="token_link"&&c.length>0&&(!A||c===g&&c.length>=12)&&(!S||h.trim()!==""),T=async()=>{if(!E||!r)return;N(!0);const C=await r(c,S&&h.trim()?h.trim():void 0,A&&_&&d);N(!1),w(C)};return n.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:n.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[n.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[n.jsx(cs,{className:"size-5 text-primary-text","aria-hidden":!0}),n.jsxs("span",{children:["agent",n.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),n.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:Nk[e].title}),n.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:Nk[e].body}),e!=="token_link"&&n.jsxs("form",{className:"space-y-5",onSubmit:C=>{C.preventDefault(),T()},children:[S&&n.jsx(Xs,{label:"Setup code",id:"setup-code",hint:"On Render: paste the server's AGENTRUN_TOKEN from the service's Environment tab. Elsewhere: paste the setup code the server printed in its log, or open the link it prints.",children:n.jsx(Be,{name:"setup-code",value:h,onChange:C=>m(C.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),n.jsx(Xs,{label:ch[e].label,hint:A?"12 characters or more.":void 0,children:n.jsxs("span",{className:ie("flex items-center gap-3 px-3",O1),children:[n.jsx(ia,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx(Be,{bare:!0,type:"password",value:c,onChange:C=>u(C.target.value),autoComplete:ch[e].autocomplete,autoFocus:!0,"aria-label":ch[e].label,className:"h-control-md flex-1 text-lead"})]})}),A&&n.jsx(Xs,{label:"Again",hint:g&&g!==c?"The two passwords differ.":void 0,children:n.jsx(Be,{type:"password",value:g,onChange:C=>y(C.target.value),autoComplete:"new-password","aria-label":"Password again",className:"text-lead"})}),_&&n.jsxs("label",{className:"flex items-start gap-3 text-lead",children:[n.jsx("input",{type:"checkbox",name:"import",checked:d,onChange:C=>p(C.target.checked),className:"mt-1 size-4 accent-primary"}),n.jsxs("span",{children:[n.jsx("span",{className:"block",children:"Import this machine's Claude Code, Codex and pi sessions"}),n.jsx("span",{className:"mt-1 block text-small text-muted-foreground","aria-live":"polite",children:v9(l)})]})]}),n.jsx(K,{type:"submit",variant:"solid",disabled:!E||k,"aria-busy":k||void 0,className:"w-full text-body",children:k?"Signing in":A?"Set password and continue":"Continue"}),v&&n.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:v}),!A&&n.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",n.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",n.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",n.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",n.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const Sk=(e,t)=>`${e.toLocaleString("en-US")} ${t}${e===1?"":"s"}`,uh="Each project becomes an agent, each session a run you can read.";function v9(e){return"counting"in e?`Counting sessions… ${uh}`:e.sessions===null||e.projects===null?`The count isn't known. ${uh}`:`${Sk(e.sessions,"session")} in ${Sk(e.projects,"project")}. ${uh}`}function w9({problem:e,starting:t=!1,onRetry:s}){return n.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:n.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[n.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[n.jsx(cs,{className:"size-5 text-primary-text","aria-hidden":!0}),n.jsxs("span",{children:["agent",n.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),n.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:t?"This server is starting":"Can't read this server's sign-in"}),n.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:t?"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."}),n.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),n.jsx(K,{type:"button",variant:"solid",onClick:s,className:"w-full text-body",children:"Retry now"})]})})}const K2=e=>{var t;return e.status===200&&((t=e.body)==null?void 0:t.accounts)===!1};function k9(e,t){if(K2(e))return t===200?"signed_in":"token_link";const s=e.body??{};return s.signed_in?"signed_in":s.password_set?"sign_in":"setup"}const j9=e=>{var t;return e.status===200&&((t=e.body)==null?void 0:t.setup_code)===!0};function N9(e){var t,s;if(e.status===401)return"That is not the password.";if(e.status===429){const r=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Too many sign-ins. Try again in ${r===1?"a second":r>=60?"a minute":`${r} seconds`}.`}return 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 or was voided after too many wrong tries: a new one is in the server's 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.":((s=(t=e.fields)==null?void 0:t[0])==null?void 0:s.message)??e.message}function Y2(e){const t=new URLSearchParams(e.startsWith("#")?e.slice(1):e),s=t.get("code");if(s===null)return{code:null,rest:e};t.delete("code");const r=t.toString();return{code:/^[A-Za-z0-9_-]*/.exec(s)[0],rest:r?`#${r}`:""}}const S9=1e4;function _k(e=location.hash){let t=e.match(/^#\/runs\/([^/?]+)$/);if(t)return{section:"runs",run:decodeURIComponent(t[1])};if(e==="#/agents/new")return{section:"agents",agent:null};if(t=e.match(/^#\/agents\/([^/?]+)\/learning\?(.*)$/),t)return{section:"agents",agent:decodeURIComponent(t[1]),tab:"learning",notes:new URLSearchParams(t[2]).getAll("note")};if(t=e.match(/^#\/agents\/([^/?]+)\/edit\?(.*)$/),t){const l=new URLSearchParams(t[2]).get("tool");return{section:"agents",agent:decodeURIComponent(t[1]),edit:!0,...l?{tool:l}:{}}}if(t=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),t)return{section:"agents",agent:decodeURIComponent(t[1]),...t[2]==="edit"?{edit:!0}:t[2]?{tab:t[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground"))return{section:"playground"};if(t=e.match(/^#\/templates\/install\?(.*)$/),t)return{section:"templates",install:new URLSearchParams(t[1]).get("src")??""};if(t=e.match(/^#\/templates\/([^/?]+)$/),t)return{section:"templates",template:decodeURIComponent(t[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(t=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),t)return{section:"triggers",trigger:decodeURIComponent(t[1]),...t[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(t=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),t){const l=MM(t[1]);return{section:"settings",settings:"mcp",signIn:FM(t[1]),...l?{add:l}:{}}}if(t=e.match(/^#\/settings\/github(?:\?(.*))?$/),t){const l=v6(t[1]);return{section:"settings",settings:"github",...l?{github:l}:{}}}if(t=e.match(/^#\/settings(?:\/(keys|tools|computers|workspace|webhook))?$/),t)return{section:"settings",settings:t[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const s=new URLSearchParams(e.slice(7)),r=s.get("agent"),a=s.get("status");return{section:"runs",...r?{runsOf:r}:{},...a&&q2.includes(a)?{status:a}:{},...s.get("archived")==="true"?{archived:!0}:{}}}function _9({runsOf:e,status:t,archived:s}){const r=new URLSearchParams;return e&&r.set("agent",e),t&&r.set("status",t),s&&r.set("archived","true"),`#/runs${r.size?`?${r}`:""}`}let dh;function $9(){if(!dh){const{code:e,rest:t}=Y2(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${t}`),dh={code:e}}return dh.code}const E9=e=>Math.min(1e3*2**e,3e4),X2=1e3,C9=30;function T9(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.":`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 R9(){const[e]=x.useState(Kz),[t,s]=x.useState(null),[r,a]=x.useState(!1),l=x.useRef(null);l.current=t;const c=x.useRef(!1),u=x.useRef(async()=>{}),d=x.useMemo(()=>p4({fetch:e.fetch,onSignedOut:()=>void u.current()}),[e]),[p,g]=x.useState($9);x.useEffect(()=>{if(t!=="setup")return;const T=()=>{const{code:C,rest:R}=Y2(location.hash);C!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${R}`),g(C))};return window.addEventListener("hashchange",T),T(),()=>window.removeEventListener("hashchange",T)},[t]);const[y,h]=x.useState(!1),m=async()=>{const T=await d.session(),C=K2(T)?await d.listAgents().then(()=>200,R=>R instanceof Pe?R.status:0):void 0;return{mode:k9(T,C),codeNeeded:j9(T)}},v=async()=>{const T=await m();return h(T.codeNeeded),T.mode},w=async()=>s(await v());u.current=async()=>{if(!(l.current!=="signed_in"||c.current)){c.current=!0;try{const T=await v();T!=="signed_in"&&l.current==="signed_in"&&(a(!0),s(T))}catch{}finally{c.current=!1}}};const[k,N]=x.useState(null),[A,_]=x.useState(0);x.useEffect(()=>{let T=!0,C;return m().then(R=>{!T||l.current!==null||(h(R.codeNeeded),s(R.mode),N(null))},R=>{if(!T||l.current!==null)return;const D=E9(A),L=R instanceof Pe?R:null,O=(L==null?void 0:L.code)==="http_error",I=O&&[502,503,504].includes(L.status);N({problem:L===null?tn(R):I?`Its address answered ${L.status}, not the server.`:`GET /v2/auth/session answered ${L.status}${O?", not as this server answers":`: ${L.message}`}`,starting:I}),C=setTimeout(()=>_(W=>W+1),D)}),()=>{T=!1,clearTimeout(C)}},[d,A]);const[S,E]=x.useState(null);return x.useEffect(()=>{if(t!=="setup")return;let T=!0;return(async()=>{for(let C=!1;T;){const R=await d.setupImport().then(D=>D,()=>{});if(!T)return;if(R===void 0&&C)return void E({projects:null,sessions:null});if(R!==void 0&&(!R||!("counting"in R||"sessions"in R)||(E(R),C=!0,!("counting"in R))))return;await new Promise(D=>setTimeout(D,X2))}})(),()=>{T=!1}},[d,t]),t===null&&k!==null?n.jsx(w9,{problem:k.problem,starting:k.starting,onRetry:()=>_(T=>T+1)}):t===null?n.jsx(ok,{connection:e,children:n.jsx(A9,{})}):t!=="signed_in"?n.jsx(b9,{mode:t,code:p,codeNeeded:y,offer:S,problem:r&&t==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(T,C,R)=>{try{return await(t==="setup"?d.setup(T,C,R):d.signIn(T)),a(!1),s("signed_in"),null}catch(D){return D instanceof Pe&&D.status===403&&t==="setup"&&await w().catch(()=>{}),D instanceof Pe?N9(D):D instanceof Error?D.message:String(D)}}},t):n.jsx(ok,{connection:e,children:n.jsx(O9,{v2:d,onSignedOut:()=>{a(!1),s("sign_in")}})})}function A9(){return Wx().state==="offline"?n.jsx(h6,{}):n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function O9({v2:e,onSignedOut:t}){var ve,Me,vt,Wt,nt,Qt,dn,Is,At,To,Dr,Ro,ts,Lc,Wn,Pc,Ic,zc,Ao,Oo,Fr,Mo,Dc;const{writable:s,whyNot:r}=o6(e),[a,l]=x.useState(null),[c,u]=x.useState(()=>_k()),[d,p]=x.useState(null),g=((Me=(ve=d==null?void 0:d.features)==null?void 0:ve.triggers)==null?void 0:Me.routes)===!0,[y,h]=x.useState(new Map);x.useEffect(()=>{if(!g)return;let we=!0;return e.listTriggers().then(je=>{we&&h(new Map(je.triggers.map(ze=>[ze.id,{name:ze.name,kind:ze.source.kind}])))},()=>{}),()=>{we=!1}},[e,g,c.section,c.trigger]);const[m,v]=x.useState(null),[w,k]=x.useState(null),[N,A]=x.useState(0),[_,S]=x.useState("30d"),[E,T]=x.useState(null),[C,R]=x.useState(!1),[D,L]=x.useState(null),[O,I]=x.useState(null),[W,U]=x.useState(null),[J,F]=x.useState(0),Z=x.useRef(null),[z,H]=x.useState(!1),[V,P]=x.useState(!1),[B,q]=x.useState(!1),[ce,de]=x.useState(null),[ue,Q]=x.useState(null),[fe,ye]=x.useState(!1),[Ee,ge]=x.useState({}),[se,pe]=x.useState(!1),Y=x.useRef(0),[_e,Ze]=x.useState([]),Je=x.useRef(-1),[xt,et]=x.useState(null),[ae,Ae]=x.useState(0),Ce=x.useRef(0),Ge=we=>{ud(we)||(location.hash=we)},[kt,We]=x.useState(null),[rt,yn]=x.useState(0);x.useEffect(()=>{let we=!0;return(async()=>{let je=!1;for(let ze=0;we&&ze<C9;){const dt=await e.setupImport().then(at=>at,()=>{});if(!we)return;if(dt===void 0)ze+=1;else{if(ze=0,!dt||!("state"in dt))return;if(We(dt),dt.state!=="running")return void(je&&yn(at=>at+1));je=!0}await new Promise(at=>setTimeout(at,X2))}})(),()=>{we=!1}},[e]),x.useEffect(()=>{const we=()=>{const je=M8();ud(location.hash,()=>{je&&history.go(-je)})?je&&history.go(je):u(_k())};return window.addEventListener("hashchange",we),()=>window.removeEventListener("hashchange",we)},[]),x.useEffect(()=>O8(),[]);const Dt=x.useRef(0),sn=x.useRef(!1),me=()=>{const we=++Dt.current;return e.capabilities().then(je=>(we===Dt.current&&p(je),!0),()=>!1)};x.useEffect(()=>{me()},[e]),x.useEffect(()=>{if(Y.current&&c.section!=="runs"&&c.section!=="mission"&&Je.current===rt)return;Je.current=rt;const we=++Y.current;pe(!1),Promise.allSettled([!1,!0].map(je=>go(ze=>e.listAgents({archived:je,cursor:ze}),ze=>ze.agents))).then(je=>{if(we!==Y.current)return;const ze=Object.fromEntries(je.flatMap(at=>at.status==="fulfilled"?at.value:[]).map(at=>[at.agent_id,at.definition.name??at.agent_id])),dt=je.every(at=>at.status==="fulfilled");ge(at=>dt?ze:{...at,...ze}),pe(dt)})},[e,c,rt]);const Te={status:c.status,archived:c.archived};x.useEffect(()=>{if(c.section!=="runs"||c.run)return;const we=++Ce.current;de(null),et(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,Te):e.listRuns(50,null,Te)).then(je=>{we===Ce.current&&(de(je.runs),Q(je.next_cursor))}).catch(je=>{we===Ce.current&&et(ln(je,"the runs"))})},[e,c,rt,ae]);const tt=we=>{var je;return Ee[we]??((je=ms==null?void 0:ms.find(ze=>ze.agent_id===we))==null?void 0:je.definition.name)??(se?we:"")},Fe=d,lt=(d==null?void 0:d.models.ready)===!1&&d.models.needs!=="model"&&!d.models.default&&d.models.source!=="gateway"&&!!((Wt=(vt=d.features)==null?void 0:vt.tool_keys)!=null&&Wt.routes),Ke={harnesses:(Fe==null?void 0:Fe.harnesses)??[],tools:bz(Fe==null?void 0:Fe.tools),thinking:((nt=Fe==null?void 0:Fe.features)==null?void 0:nt.thinking)??[]},Ft=sP(Fe==null?void 0:Fe.tools),Qn=oP(Fe==null?void 0:Fe.tools),Jn=[...(dn=(Qt=d==null?void 0:d.features)==null?void 0:Qt.tool_keys)!=null&&dn.routes?["keys"]:[],...Ft.length||Qn.length?["tools"]:[],"mcp","github","computers","workspace",...(At=(Is=d==null?void 0:d.features)==null?void 0:Is.webhooks)!=null&&At.routes?["webhook"]:[]],Zn=we=>Ge({runs:"#/runs",agents:"#/agents",playground:"#/playground",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${Jn[0]??"keys"}`}[we]),bn=x.useRef(er()).current,es=async we=>{const je=G2(Ke.harnesses);if(!je)return"This server has no model to run it on yet.";try{const ze=await t9(e,we,je,bn);return Ge(`#/runs/${encodeURIComponent(ze)}`),null}catch(ze){return tn(ze)}},un=((m==null?void 0:m.analytics.by_source)??[]).filter(we=>we.source!=="live").reduce((we,je)=>we+je.runs,0),[ms,gr]=x.useState(null),[Nt,Cn]=x.useState([]),[ps,hs]=x.useState(null),[gs,Un]=x.useState(null),[Ms,ee]=x.useState(0),Se=x.useRef(0);x.useEffect(()=>{if(c.section!=="playground")return;Un(null);const we=++Se.current;go(je=>e.listAgents({cursor:je}),je=>je.agents).then(je=>{if(we!==Se.current)return;gr(je);const ze=je.filter(dt=>!dt.archived_at);hs(dt=>{var at;return dt&&ze.some(Ur=>Ur.agent_id===dt)?dt:((at=ze[0])==null?void 0:at.agent_id)??null})}).catch(je=>{if(we===Se.current){const ze=ln(je,"the agents");Un(`${ze.why} ${ze.next}${ze.said?` (${ze.said})`:""}`)}})},[e,c.section,Ms,rt]),x.useEffect(()=>{if(c.section!=="mission")return;let we=!0;k(null),R(!0);const je=Jg(_);return Promise.all([e.statsOver({...je?{from:je}:{},...E?{agent:E}:{}}),E?e.listAgentRuns(E,10):e.listRuns(10)]).then(([ze,dt])=>{we&&(v(o4(ze,dt.runs)),E||U(at=>at||VD(dt.runs,ze.analytics.by_source)))}).catch(ze=>{we&&k(ln(ze,"Mission Control"))}).finally(()=>{we&&R(!1)}),()=>{we=!1}},[e,c.section,N,_,E,rt]),h2(()=>A(we=>we+1)),x.useEffect(()=>{if(c.section!=="mission"){Z.current=null;return}let we=!0;const je=Z,ze=fn=>go(st=>e.listRuns(50,st,{status:fn}),st=>st.runs,2),dt=()=>go(fn=>e.listAgents({archived:!1,cursor:fn}),fn=>fn.agents).then(fn=>{we&&Ze(fn.filter(st=>Ud(st)>0).map(st=>({agent_id:st.agent_id,name:st.definition.name??st.agent_id,pending:Ud(st)})))},()=>{}),Ur=YD(()=>Promise.allSettled([ze("input_required"),ze("failed"),ze("working"),dt()]).then(([fn,st,Fc])=>{var zi,Di,Fi;if(!we)return;const xr=[fn,st,Fc],Ii=Date.now()-qD;if(I(ek(null,xr).problem),((zi=xr[0])==null?void 0:zi.status)==="fulfilled"&&H(!0),((Di=xr[1])==null?void 0:Di.status)==="fulfilled"){P(!0);const Wr=xr[1].value.map(mn=>mn.run_id),zs=je.current;zs&&Wr.some(mn=>!zs.has(mn))&&A(mn=>mn+1),je.current=new Set(Wr)}((Fi=xr[2])==null?void 0:Fi.status)==="fulfilled"&&q(!0),L(Wr=>{const{needs:zs}=ek(Wr,xr);return{asking:zs.asking.filter(d2),failed:zs.failed.filter(mn=>Date.parse(mn.ended_at??mn.created_at)>Ii),live:zs.live}})}),1e4);return()=>{we=!1,Ur()}},[e,c.section,J]);const Ye=x.useRef(RL()).current,ft=()=>setTimeout(()=>F(we=>we+1),2500),jt=async(we,je)=>{try{return await iS(Ye(we),we,je,e.sendMessage),ft(),null}catch(ze){return tn(ze)}},Ut=x.useRef(new Map).current,vn=async we=>{const je=[];try{for(const ze of we){const dt=KD(ze.kind==="workflow"?ze:await e.getRun(ze.run_id));if("refusal"in dt)throw new Error(dt.refusal);const at=Ut.get(ze.run_id)??Of();Ut.set(ze.run_id,at),await e.startRun(ze.agent_id,dt.body,at),je.push(ze.run_id)}return ft(),{started:je,problem:null}}catch(ze){return je.length&&ft(),{started:je,problem:tn(ze)}}},St=async we=>{try{return await e.stop(we),ft(),null}catch(je){return tn(je)}},zr=async(we,je,ze,dt,at)=>{let Ur=null;try{await e.answerApproval(we,je,ze,dt,at)}catch(fn){Ur=R2(fn)}return F(fn=>fn+1),Ur},Tn=async(we,je)=>{let ze=null;try{await e.handBackComputer(we,je)}catch(dt){ze=ag(dt,"hand")}return F(dt=>dt+1),ze},Ls=x.useRef(0);x.useEffect(()=>{const we=++Ls.current;Cn([]),ps&&go(je=>e.listRevisions(ps,je),je=>je.revisions).then(je=>{we===Ls.current&&Cn(je)}).catch(()=>{})},[e,ps]);const Ps=async(we,je,ze)=>{const dt=performance.now();try{const at=await e.startRun(we,je,ze);return{status:at.status,ms:Math.round(performance.now()-dt),body:at.run,runId:at.run.run_id}}catch(at){return r9(at,Math.round(performance.now()-dt))}},$a=((To=d==null?void 0:d.features)==null?void 0:To.efforts)??[],He=d?((Dr=d.features)==null?void 0:Dr.learning)??null:void 0;Ke.learning=He??void 0;const te=d==null?void 0:d.models.ready;return x.useEffect(()=>{if(te!==!1)return;const we=()=>{sn.current||(sn.current=!0,me().finally(()=>{sn.current=!1}))},je=()=>me(),ze=setInterval(we,S9);return window.addEventListener("focus",je),()=>{clearInterval(ze),window.removeEventListener("focus",je)}},[e,te]),n.jsx(x2.Provider,{value:y,children:n.jsx(y9,{active:c.section,settings:Jn.length>0,triggers:g,onNavigate:Zn,onSignOut:()=>{const we=()=>void e.signOut().then(t,je=>l(je instanceof Pe?je.message:"The sign-out did not reach the server. Try again."));ud(null,we)||we()},onSignOutEverywhere:()=>{const we=()=>void e.signOutEverywhere().then(t,je=>l(je instanceof Pe?je.message:"The sign-out did not reach the server. Try again."));ud(null,we)||we()},banners:n.jsxs(n.Fragment,{children:[a&&n.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: ",a]}),kt&&n.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:[n.jsx("span",{className:"flex-1",children:T9(kt)}),kt.state!=="running"&&n.jsx(K,{type:"button",size:"xs",onClick:()=>We(null),children:"Dismiss"})]}),(d==null?void 0:d.models.ready)===!1&&c.section!=="mission"&&n.jsx(F6,{needs:d.models.needs,source:d.models.source,model:d.models.default,settings:((ts=(Ro=d.features)==null?void 0:Ro.tool_keys)==null?void 0:ts.routes)===!0})]}),children:c.section==="playground"&&gs?n.jsx(_n,{tone:"error",className:"m-8",actions:n.jsx(K,{type:"button",size:"xs",onClick:()=>ee(we=>we+1),children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The agents could not be read: ",gs]})}):c.section==="settings"?n.jsx(x6,{active:c.settings??"keys",offered:Jn,children:c.settings==="tools"?n.jsx(b6,{v2:e,choices:Ft,gates:Qn,harnesses:Ke.harnesses,mcp:!!((Lc=d==null?void 0:d.features)!=null&&Lc.mcp_client),onSaved:me,onOpen:me}):c.settings==="mcp"?n.jsx($6,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:Ft}):c.settings==="github"?n.jsx(N6,{v2:e,returned:c.github}):c.settings==="computers"?n.jsx(q6,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?n.jsx(s8,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?n.jsx(W6,{v2:e}):n.jsx(u6,{v2:e,onChange:me,writable:s,whyNot:r})}):c.section==="mission"?n.jsxs("div",{className:"flex h-full flex-col",children:[(d==null?void 0:d.models.ready)===!1&&n.jsx(D6,{v2:e,needs:d.models.needs,model:d.models.default,onSaved:me,writable:s,whyNot:r}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(WF,{view:m,error:w,onRetry:()=>A(we=>we+1),scope:{range:_,onRange:S,agent:E,onAgent:T,refreshing:C&&m!==null},asking:D&&z?D.asking.length:null,failed:D&&V?u2(D.failed):null,live:D&&B?D.live.length:null,needsYou:D&&n.jsx(BF,{asking:D.asking,failed:D.failed,failedAll:m==null?void 0:m.runs.failed,live:D.live,learning:_e,problem:O,agentName:tt,onAnswer:jt,onApprove:zr,onHandBack:Tn,onRunAgain:vn,onStop:St}),startHere:W===!1?n.jsx(s9,{harnesses:Ke.harnesses,tools:Ke.tools,onTry:es,imported:un,keyCard:lt}):void 0})})]}):c.section==="templates"?n.jsx(y8,{v2:e,name:c.template,install:c.install,go:Ge},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?n.jsx(a8,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Ge,agentName:tt,minEvery:(Pc=(Wn=d==null?void 0:d.features)==null?void 0:Wn.triggers)==null?void 0:Pc.min_every_s,failuresToPause:(zc=(Ic=d==null?void 0:d.features)==null?void 0:Ic.triggers)==null?void 0:zc.failures_to_pause}):c.section==="playground"?ms&&n.jsx(o9,{agents:ms.filter(we=>!we.archived_at),revisions:Nt,efforts:$a,origin:location.origin,agentId:ps??void 0,onAgent:hs,onSend:Ps,limits:d==null?void 0:d.limits,removeUpload:e.deleteUpload,onOpenRun:we=>Ge(`#/runs/${encodeURIComponent(we)}`),live:we=>n.jsx(wk,{v2:e,runId:we,caps:d,agentName:tt},we)}):c.section==="agents"?c.agent===void 0?n.jsx(PD,{v2:e,archived:!!c.archived,go:Ge},rt):c.agent!==null&&!c.edit?n.jsx(Jz,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:He,routePrefix:(Ao=Fe==null?void 0:Fe.models)==null?void 0:Ao.route_prefix,harnesses:Ke.harnesses,efforts:$a,limits:d==null?void 0:d.limits,places:F0(d),go:Ge},c.agent):n.jsx(ID,{v2:e,choices:Ft,gates:Qn,focusTool:c.tool,caps:{...Ke,routePrefix:(Oo=Fe==null?void 0:Fe.models)==null?void 0:Oo.route_prefix,decisionProvider:gz(d==null?void 0:d.workflows),places:F0(d),mcp:!!((Fr=d==null?void 0:d.features)!=null&&Fr.mcp_client),mcpHarnesses:(Dc=(Mo=d==null?void 0:d.features)==null?void 0:Mo.mcp_client)==null?void 0:Dc.harnesses},agentId:c.agent,go:Ge},`${c.agent??"new"}:${c.tool??""}`):c.run?n.jsx(wk,{v2:e,runId:c.run,caps:d,agentName:tt},c.run):n.jsx(i9,{runs:ce,agentName:tt,error:xt,onRetry:()=>Ae(we=>we+1),onOpen:we=>Ge(`#/runs/${encodeURIComponent(we)}`),loadingMore:fe,filter:Te,onFilter:we=>Ge(_9({runsOf:c.runsOf,...we})),onMore:ue?()=>{const we=Ce.current;ye(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,ue,Te):e.listRuns(50,ue,Te)).then(je=>{we===Ce.current&&(de(ze=>lS(ze??[],je.runs)),Q(je.next_cursor),et(null))}).catch(je=>et(ln(je,"more runs"))).finally(()=>ye(!1))}:void 0})})})}p9();D$.createRoot(document.getElementById("root")).render(n.jsx(x.StrictMode,{children:n.jsx(B4,{children:n.jsx(R9,{})})}));